"use strict";

exports.APP_NAME = "Formbird";

exports.SYSTEM_TYPE_DOCUMENT = "document";
exports.SYSTEM_TYPE_VERSION = "version";
exports.SYSTEM_TYPE_TEMPLATE = "template";
exports.SYSTEM_TYPE_ACCOUNT = "account";
exports.SYSTEM_TYPE_RULESET_DOCUMENT = "rulesetdocument";
exports.SYSTEM_TYPE_SYSTEM_ACTION = "systemaction";
exports.SYSTEM_TYPE_SCHEDULE = "schedule";
exports.SYSTEM_TYPE_FILE_REFERENCE = "fileReference";
exports.SYSTEM_TYPE_CONFIGURATION = "configuration";
exports.SYSTEM_TYPE_COMPONENT = "component";
exports.SYSTEM_TYPE_COUNTER = "counter";
exports.SYSTEM_TYPE_PASSWORD_RESET = "passwordReset";
exports.SYSTEM_TYPE_ACCOUNT_SECURITY = "accountSecurity";
exports.SYSTEM_TYPE_ACCOUNT_CONTROL = "accountControl";
exports.SYSTEM_TYPE_ACCOUNT_GROUP_CONFIG = 'accountGroupConfig';
exports.SYSTEM_TYPE_PASSWORD = "password";
exports.SYSTEM_TYPE_RULESET = "ruleset";
exports.SYSTEM_TYPE_RULESET_INCLUDE = "rulesetInclude";
exports.SYSTEM_TYPE_APPLICATION = "application";
exports.SYSTEM_TYPE_VENDOR_LIBRARY = 'vendorLibrary';

exports.STATUS_PENDING = "pending";
exports.STATUS_PROCESSING = "processing";
exports.STATUS_PROCESSED = "processed";
exports.STATUS_ERROR = "error";
exports.STATUS_SUCCESS = "success";
exports.STATUS_WARNING = "warning";
exports.STATUS_INFO = "info";
exports.STATUS_FORBIDDEN = "forbidden";

exports.METHOD_POST = "POST";
exports.METHOD_GET = "GET";
exports.METHOD_DELETE = "DELETE";
exports.METHOD_PUT = "PUT";

exports.DEFAULT_PAGE = 0;
exports.DEFAULT_PAGE_SIZE = 50;
exports.DEFAULT_TOTAL_ITEM = 10000;
exports.DEFAULT_SEARCH_DELAY = 500;
exports.DEFAULT_MAX_SEARCH_QUERY_LENGTH = 2048;

exports.DEFAULT_SEARCH_SELECT_PAGE_SIZE = 5;
exports.DEFAULT_SEARCH_SELECT_PAGE = 0;

//field types
exports.FIELD_TYPE_RELATED = "Related";
exports.FIELD_TYPE_HTML = "html";
exports.FIELD_TYPE_CUSTOM = "Custom";

exports.ELASTIC_DOCUMENT_TYPE = "documents";
exports.ELASTIC_DOCUMENT_PREFIXES = {
    "mongodb": "_source",
    "couchbase": "_source.doc"
};

exports.DEFAULT_DB_PROVIDER = "mongodb";
exports.DEFAULT_DB_CONNECTION = "default";

exports.RULESET_EVENT_NAME = "EventName";

exports.RULESET_RELATIONSHIPS = {
    PRERENDER_EVENT_NAME: {
        name: 'PreRender',
        relName: 'preRenderClientRuleRel'
    },
    ONLOAD_EVENT_NAME: {
        name: "OnLoad",
        relName: "onLoadClientRuleRel"
    },
    ON_FIELD_CHANGE_EVENT_NAME: {
        name: "OnFieldChange",
        relName: "onFieldChangeClientRuleRel"
    },
    PRESAVE_EVENT_NAME: {
        name: "PreSave",
        relName: "preSaveClientRuleRel"
    },
    POSTSAVE_CLIENT_EVENT_NAME: {
        name: 'PostSaveClient',
        relName: 'postSaveClientRuleRel'
    },
    PRESAVE_SERVER_EVENT_NAME: {
        name: "PreSaveServer",
        relName: "preSaveServerRuleRel"
    },
    POSTSAVE_EVENT_NAME: {
        name: "PostSave",
        relName: "postSaveServerRuleRel"
    }
};

exports.ONLOAD_DONE_RULES_EVENT_NAME = "OnLoadDone";

exports.ON_CHANGE_FILTER_EVENT_NAME = "OnChangeFilter";

exports.LOCATION_CHANGE_STATE_EVENT = "$locationChangeStart";
exports.UPDATE_SHOW_VALUE_EVENT = 'updateShowValue';

exports.EVENT_LIST_NAME = "eventList";
exports.EVENT_VALIDATION_VALUES_NAME = "validationValues";

exports.INSERT_OPERATION_TYPE = "Insert";
exports.UPDATE_OPERATION_TYPE = "Update";

exports.CSV_DOC_ID_MATCH_MERGE = "merge";
exports.CSV_DOC_ID_MATCH_REPLACE = "replace";
exports.CSV_DOC_ID_NO_MATCH_ADD = "add";
exports.CSV_DOC_ID_NO_MATCH_ERR = "error";

// operation types for clicking on navigation bar
exports.SAVE_CLICK_OPERATION_TYPE = "SaveClick";
exports.NEW_CLICK_OPERATION_TYPE = "NewClick";
exports.PRINT_CLICK_OPERATION_TYPE = "PrintClick";
exports.MAP_CLICK_OPERATION_TYPE = "MapClick";

// operation types, for checking access
exports.OPERATION_TYPE_READ = "Read";
exports.OPERATION_TYPE_CREATE = "Create";
exports.OPERATION_TYPE_UPDATE = "Update";
exports.OPERATION_TYPE_DELETE = "Delete";
exports.OPERATION_TYPE_EXECUTE = "Execute";
exports.OPERATION_TYPE_OFFLINE = "Offline";

// documents should'nt have any HealthCheck access,
// this is only for api/healthCheck route
exports.OPERATION_TYPE_HEALTH_CHECK = "HealthCheck";

// error types, for server functions
exports.ERROR_TYPE_NOACCESS = "No Access";
exports.ERROR_TYPE_NOTFOUND = "Not Found";
exports.ERROR_TYPE_INTERNAL = "Internal";
exports.ERROR_TYPE_GONE = "Gone";

// websocket messages
exports.WEB_SOCKET_MESSAGE_TEMPLATE_DRAFT_SAVED = "template_draft_saved";
exports.WEB_SOCKET_MESSAGE_UPDATE_PREVIEW = "update_preview";
exports.WEB_SOCKET_MESSAGE_SAVE_DOCUMENT = "save_document";
exports.WEB_SOCKET_MESSAGE_PASSWORD_RESET = 'password_reset';

exports.DIALOG_OK_OPTION = "OK";
exports.DIALOG_CANCEL_OPTION = "CANCEL";

exports.RULESET_AFFECTED_DOCUMENT_ID = "affectedDocId";
exports.RULESET_AFFECTED_TEMPLATE_ID = "affectedTplId";
exports.RULESET_AFFECTED_FIELD_NAME = "affectedFieldName";
exports.RULESET_NEW_FILTER = "newFilter";
exports.RULESET_RESULT_FLAG = "flag";
exports.RULESET_PARENT_DOCUMENT = "parentDoc";
exports.RULESET_CHILD_DOCUMENT = "childDoc";

exports.checkListSeparator = '^';

exports.DEFAULT_MESSAGE_LENGTH = 200;

exports.DEFAULT_EXPIRY_DURATION_MINUTES = 60;

//export type
exports.EXPORT_TYPE_PDF = "pdf";
exports.EXPORT_TYPE_CSV = "csv";

exports.MAKE_CURRENT_VERSION_KEY = 'makeCurrentVersion';
exports.IMPORT_PREVIOUS_VERSION = "importPreviousVersion";

exports.SEARCH_PROVIDERS = {
    COUCHBASE : "couchbase",
    ELASTIC : "elastic"
};

exports.DEFAULT_MAX_UPLOAD_SIZE = 50;  //size in megabytes

exports.SYSTEM_TYPE_QUERY = "query";
