harperdb 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/harperdb.js +2 -2
- package/launchServiceScripts/launchCustomFunctions.js +11 -11
- package/launchServiceScripts/launchHarperDB.js +11 -11
- package/launchServiceScripts/launchInstallNATSServer.js +1 -1
- package/launchServiceScripts/launchNatsIngestService.js +11 -11
- package/launchServiceScripts/launchNatsReplyService.js +2 -2
- package/package.json +3 -3
- package/server/ipc/hdbIpcServer.js +1 -1
- package/server/jobs/jobProcess.js +11 -11
- package/utility/scripts/restartHdb.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "harperdb",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "HarperDB is a distributed SQL & NoSQL data platform focused on speed, flexibility, and ease of use.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"database",
|
|
@@ -63,14 +63,14 @@
|
|
|
63
63
|
"json2csv": "5.0.7",
|
|
64
64
|
"jsonata": "1.8.6",
|
|
65
65
|
"jsonwebtoken": "8.5.1",
|
|
66
|
-
"lmdb": "2.7.
|
|
66
|
+
"lmdb": "2.7.6",
|
|
67
67
|
"lodash": "4.17.21",
|
|
68
68
|
"mathjs": "10.4.0",
|
|
69
69
|
"microtime": "3.1.1",
|
|
70
70
|
"minimist": "1.2.6",
|
|
71
71
|
"mkcert": "1.5.0",
|
|
72
72
|
"moment": "2.29.4",
|
|
73
|
-
"msgpackr": "1.
|
|
73
|
+
"msgpackr": "1.8.2",
|
|
74
74
|
"nats": "2.9.2",
|
|
75
75
|
"needle": "3.1.0",
|
|
76
76
|
"node-ipc": "9.1.4",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";var dr=Object.defineProperty;var n=(e,t)=>dr(e,"name",{value:t,configurable:!0});var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var y=P((is,St)=>{"use strict";var d=require("path"),Lr=require("fs");function fr(){let e=__dirname;for(;!Lr.existsSync(d.join(e,"package.json"));){let t=d.dirname(e);if(t===e)throw new Error("Could not find package root");e=t}return e}n(fr,"getHDBPackageRoot");var F=fr(),Ze="js",Se=Ze,Ur="harperdb-config.yaml",pr="defaultConfig.yaml",Dr="hdb",ze=`hdbServer.${Se}`,et=`customFunctionsServer.${Se}`,tt=`hdbIpcServer.${Se}`,gr=`restartHdb.${Se}`,Fe="HarperDB",Ne="Custom Functions",ue="Clustering Hub",Ie="Clustering Leaf",be="Clustering Ingest Service",Be="Clustering Reply Service",Pr="foreground.pid",He={HDB:Fe,IPC:"IPC",CLUSTERING_HUB:ue,CLUSTERING_LEAF:Ie,CLUSTERING_INGEST_SERVICE:be,CLUSTERING_REPLY_SERVICE:Be,CUSTOM_FUNCTIONS:Ne,RESTART_HDB:"Restart HDB",INSTALL:"Install",RUN:"Run",STOP:"Stop",UPGRADE:"Upgrade",REGISTER:"Register",JOB:"Job",PM2_LOGROTATE:"pm2-logrotate",CLUSTERING_UPGRADE_4_0_0:"Upgrade-4-0-0"},Mr={HDB:"hdb.log",IPC:"ipc.log",CLUSTERING_HUB:"clustering_hub.log",CLUSTERING_LEAF:"clustering_leaf.log",CLUSTERING_INGEST_SERVICE:"clustering_ingest_service.log",CLUSTERING_REPLY_SERVICE:"clustering_reply_service.log",CUSTOM_FUNCTIONS:"custom_functions.log",INSTALL:"install.log",CLI:"cli.log",PM2:"pm2.log",CLUSTERING_UPGRADE:"clustering_upgrade.log",JOBS:"jobs.log"},mr={NOTIFY:"notify",FATAL:"fatal",ERROR:"error",WARN:"warn",INFO:"info",DEBUG:"debug",TRACE:"trace"},hr={harperdb:Fe,ipc:"IPC","clustering hub":ue,"clustering leaf":Ie,"clustering ingest service":be,"clustering reply service":Be,"custom functions":Ne,custom_functions:Ne,"pm2-logrotate":He.PM2_LOGROTATE,logrotate:He.PM2_LOGROTATE,clustering:"clustering","clustering config":"clustering config"},Gr={CLUSTERING_HUB_PROC_DESCRIPTOR:ue,CLUSTERING_LEAF_PROC_DESCRIPTOR:Ie,CLUSTERING_INGEST_PROC_DESCRIPTOR:be,CLUSTERING_REPLY_SERVICE_DESCRIPTOR:Be},Ae={HDB:d.join(F,"server/harperdb"),IPC:d.join(F,"server/ipc"),CUSTOM_FUNCTIONS:d.join(F,"server/customFunctions"),CLUSTERING_HUB:d.join(F,"server/nats"),CLUSTERING_LEAF:d.join(F,"server/nats")},Hr={HDB:d.join(Ae.HDB,ze),IPC:d.join(Ae.IPC,tt),CUSTOM_FUNCTIONS:d.join(Ae.CUSTOM_FUNCTIONS,et)},Fr={HDB:d.join(F,"launchServiceScripts/launchHarperDB.js"),CUSTOM_FUNCTIONS:d.join(F,"launchServiceScripts/launchCustomFunctions.js"),NATS_INGEST_SERVICE:d.join(F,"launchServiceScripts/launchNatsIngestService.js"),NATS_REPLY_SERVICE:d.join(F,"launchServiceScripts/launchNatsReplyService.js"),NODES_UPGRADE_4_0_0:d.resolve(F,"launchServiceScripts/launchUpdateNodes4-0-0.js")},br={SUPER_USER:"super_user",CLUSTER_USER:"cluster_user"},rt="support@harperdb.io",Br="customer-success@harperdb.io",_t=1,yr=4141,ot="https://harperdbhelp.zendesk.com/hc/en-us/requests/new",Kr="https://www.harperdb.io/product",wr=`For support, please submit a request at ${ot} or contact ${rt}`,nt=`For license support, please contact ${Br}`,Vr="None of the specified records were found.",vr="hash attribute not found",Yr=`Your current license only supports ${_t} role. ${nt}`,kr="Your current license only supports 3 connections to a node.",qr="127.0.0.1",Wr=1,jr=/^\.$/,xr=/^\.\.$/,$r="U+002E",Jr=/\//g,Qr="U+002F",Xr=/U\+002F/g,Zr=/^U\+002E$/,zr=/^U\+002EU\+002E$/,e_="d",t_=999999,r_="*",__="--max-old-space-size=",o_="system",n_="__hdb_hash",E_=".harperdb",s_=".hdb",i_="keys",T_="hdb_boot_properties.file",S_=".updateConfig.json",R_="SIGTSTP",c_=24,a_=6e4,O_=448,A_="blob",N_="trash",u_="schema",I_="transactions",l_=".count",C_="id",d_="install_log.log",L_="run_log.log",f_="PROCESS_NAME",U_={SETTINGS_PATH_KEY:"settings_path"},Et=require("lodash"),p_={TC_AGREEMENT:"TC_AGREEMENT",CLUSTERING_USER:"CLUSTERING_USER",CLUSTERING_PASSWORD:"CLUSTERING_PASSWORD",HDB_ADMIN_USERNAME:"HDB_ADMIN_USERNAME",HDB_ADMIN_PASSWORD:"HDB_ADMIN_PASSWORD",OPERATIONSAPI_ROOT:"OPERATIONSAPI_ROOT",ROOTPATH:"ROOTPATH",OPERATIONSAPI_NETWORK_PORT:"OPERATIONSAPI_NETWORK_PORT",CLUSTERING_NODENAME:"CLUSTERING_NODENAME",CLUSTERING_ENABLED:"CLUSTERING_ENABLED",CLUSTERING_PORT:"CLUSTERING_PORT",HDB_ROOT:"HDB_ROOT",SERVER_PORT:"SERVER_PORT",NODE_NAME:"NODE_NAME",CLUSTERING:"CLUSTERING"},D_={HDB_PATH_KEY:"HDB_INTERNAL_PATH",HDB_AUTH_HEADER:"hdb_auth_header",HDB_USER_DATA_KEY:"hdb_user",CHUNK_SIZE:1e3,MAX_CHARACTER_SIZE:250},g_={DATA_VERSION:"data_version",UPGRADE_VERSION:"upgrade_version"},P_={JOB_TABLE_NAME:"hdb_job",NODE_TABLE_NAME:"hdb_nodes",ATTRIBUTE_TABLE_NAME:"hdb_attribute",LICENSE_TABLE_NAME:"hdb_license",ROLE_TABLE_NAME:"hdb_role",SCHEMA_TABLE_NAME:"hdb_schema",TABLE_TABLE_NAME:"hdb_table",USER_TABLE_NAME:"hdb_user",INFO_TABLE_NAME:"hdb_info"},M_={JOB_TABLE_HASH_ATTRIBUTE:"id",NODE_TABLE_HASH_ATTRIBUTE:"name",ATTRIBUTE_TABLE_HASH_ATTRIBUTE:"id",LICENSE_TABLE_HASH_ATTRIBUTE:"license_key",ROLE_TABLE_HASH_ATTRIBUTE:"id",SCHEMA_TABLE_HASH_ATTRIBUTE:"name",TABLE_TABLE_HASH_ATTRIBUTE:"id",USER_TABLE_HASH_ATTRIBUTE:"username",INFO_TABLE_ATTRIBUTE:"info_id"},M="hdb_internal:",m_={CREATE_SCHEMA:M+"create_schema",CREATE_TABLE:M+"create_table",CREATE_ATTRIBUTE:M+"create_attribute",ADD_USER:M+"add_user",ALTER_USER:M+"alter_user",DROP_USER:M+"drop_user",HDB_NODES:M+"hdb_nodes",HDB_USERS:M+"hdb_users",HDB_WORKERS:M+"hdb_workers",CATCHUP:M+"catchup",SCHEMA_CATCHUP:M+"schema_catchup",WORKER_ROOM:M+"cluster_workers"},h_={ATTR_ATTRIBUTE_KEY:"attribute",ATTR_CREATEDDATE_KEY:"createddate",ATTR_HASH_ATTRIBUTE_KEY:"hash_attribute",ATTR_ID_KEY:"id",ATTR_NAME_KEY:"name",ATTR_PASSWORD_KEY:"password",ATTR_RESIDENCE_KEY:"residence",ATTR_ROLE_KEY:"role",ATTR_SCHEMA_KEY:"schema",ATTR_SCHEMA_TABLE_KEY:"schema_table",ATTR_TABLE_KEY:"table",ATTR_USERNAME_KEY:"username"},G_="060493.ks",H_=".license",F_={CREATED:"CREATED",IN_PROGRESS:"IN_PROGRESS",COMPLETE:"COMPLETE",ERROR:"ERROR"},i={INSERT:"insert",UPDATE:"update",UPSERT:"upsert",SEARCH_BY_CONDITIONS:"search_by_conditions",SEARCH_BY_HASH:"search_by_hash",SEARCH_BY_VALUE:"search_by_value",SEARCH:"search",SQL:"sql",CSV_DATA_LOAD:"csv_data_load",CSV_FILE_LOAD:"csv_file_load",CSV_URL_LOAD:"csv_url_load",CREATE_SCHEMA:"create_schema",CREATE_TABLE:"create_table",CREATE_ATTRIBUTE:"create_attribute",DROP_SCHEMA:"drop_schema",DROP_TABLE:"drop_table",DESCRIBE_SCHEMA:"describe_schema",DESCRIBE_TABLE:"describe_table",DESCRIBE_ALL:"describe_all",DELETE:"delete",ADD_USER:"add_user",ALTER_USER:"alter_user",DROP_USER:"drop_user",LIST_USERS:"list_users",LIST_ROLES:"list_roles",ADD_ROLE:"add_role",ALTER_ROLE:"alter_role",DROP_ROLE:"drop_role",USER_INFO:"user_info",READ_LOG:"read_log",ADD_NODE:"add_node",UPDATE_NODE:"update_node",EXPORT_TO_S3:"export_to_s3",IMPORT_FROM_S3:"import_from_s3",DELETE_FILES_BEFORE:"delete_files_before",DELETE_RECORDS_BEFORE:"delete_records_before",EXPORT_LOCAL:"export_local",SEARCH_JOBS_BY_START_DATE:"search_jobs_by_start_date",GET_JOB:"get_job",DELETE_JOB:"delete_job",UPDATE_JOB:"update_job",GET_FINGERPRINT:"get_fingerprint",SET_LICENSE:"set_license",GET_REGISTRATION_INFO:"registration_info",CONFIGURE_CLUSTER:"configure_cluster",SET_CONFIGURATION:"set_configuration",CLUSTER_STATUS:"cluster_status",DROP_ATTRIBUTE:"drop_attribute",REMOVE_NODE:"remove_node",RESTART:"restart",RESTART_SERVICE:"restart_service",CATCHUP:"catchup",SYSTEM_INFORMATION:"system_information",DELETE_AUDIT_LOGS_BEFORE:"delete_audit_logs_before",READ_AUDIT_LOG:"read_audit_log",CREATE_AUTHENTICATION_TOKENS:"create_authentication_tokens",REFRESH_OPERATION_TOKEN:"refresh_operation_token",GET_CONFIGURATION:"get_configuration",CUSTOM_FUNCTIONS_STATUS:"custom_functions_status",GET_CUSTOM_FUNCTIONS:"get_custom_functions",GET_CUSTOM_FUNCTION:"get_custom_function",SET_CUSTOM_FUNCTION:"set_custom_function",DROP_CUSTOM_FUNCTION:"drop_custom_function",ADD_CUSTOM_FUNCTION_PROJECT:"add_custom_function_project",DROP_CUSTOM_FUNCTION_PROJECT:"drop_custom_function_project",PACKAGE_CUSTOM_FUNCTION_PROJECT:"package_custom_function_project",DEPLOY_CUSTOM_FUNCTION_PROJECT:"deploy_custom_function_project",CLUSTER_SET_ROUTES:"cluster_set_routes",CLUSTER_DELETE_ROUTES:"cluster_delete_routes",CLUSTER_GET_ROUTES:"cluster_get_routes",READ_TRANSACTION_LOG:"read_transaction_log",DELETE_TRANSACTION_LOGS_BEFORE:"delete_transaction_logs_before",INSTALL_NODE_MODULES:"install_node_modules",AUDIT_NODE_MODULES:"audit_node_modules"},b_={CSV:".csv",JSON:".json"},B_={AWS_ACCESS_KEY:"aws_access_key_id",AWS_SECRET:"aws_secret_access_key",AWS_BUCKET:"bucket",AWS_FILE_KEY:"key"},y_={SELECT:"select",INSERT:"insert",UPDATE:"update",DELETE:"delete"},$={};$[i.CREATE_SCHEMA]=i.CREATE_SCHEMA;$[i.CREATE_TABLE]=i.CREATE_TABLE;$[i.CREATE_ATTRIBUTE]=i.CREATE_ATTRIBUTE;$[i.INSERT]=i.INSERT;$[i.UPDATE]=i.UPDATE;$[i.UPSERT]=i.UPSERT;$[i.DELETE]=i.DELETE;var O=Object.create(null);O[i.DESCRIBE_ALL]=i.DESCRIBE_ALL;O[i.DESCRIBE_TABLE]=i.DESCRIBE_TABLE;O[i.DESCRIBE_SCHEMA]=i.DESCRIBE_SCHEMA;O[i.READ_LOG]=i.READ_LOG;O[i.ADD_NODE]=i.ADD_NODE;O[i.LIST_USERS]=i.LIST_USERS;O[i.LIST_ROLES]=i.LIST_ROLES;O[i.USER_INFO]=i.USER_INFO;O[i.SQL]=i.SQL;O[i.GET_JOB]=i.GET_JOB;O[i.SEARCH_JOBS_BY_START_DATE]=i.SEARCH_JOBS_BY_START_DATE;O[i.DELETE_FILES_BEFORE]=i.DELETE_FILES_BEFORE;O[i.EXPORT_LOCAL]=i.EXPORT_LOCAL;O[i.EXPORT_TO_S3]=i.EXPORT_TO_S3;O[i.CLUSTER_STATUS]=i.CLUSTER_STATUS;O[i.REMOVE_NODE]=i.REMOVE_NODE;O[i.RESTART]=i.RESTART;O[i.CUSTOM_FUNCTIONS_STATUS]=i.CUSTOM_FUNCTIONS_STATUS;O[i.GET_CUSTOM_FUNCTIONS]=i.GET_CUSTOM_FUNCTIONS;O[i.GET_CUSTOM_FUNCTION]=i.GET_CUSTOM_FUNCTION;O[i.SET_CUSTOM_FUNCTION]=i.SET_CUSTOM_FUNCTION;O[i.DROP_CUSTOM_FUNCTION]=i.DROP_CUSTOM_FUNCTION;O[i.ADD_CUSTOM_FUNCTION_PROJECT]=i.ADD_CUSTOM_FUNCTION_PROJECT;O[i.DROP_CUSTOM_FUNCTION_PROJECT]=i.DROP_CUSTOM_FUNCTION_PROJECT;O[i.PACKAGE_CUSTOM_FUNCTION_PROJECT]=i.PACKAGE_CUSTOM_FUNCTION_PROJECT;O[i.DEPLOY_CUSTOM_FUNCTION_PROJECT]=i.DEPLOY_CUSTOM_FUNCTION_PROJECT;var K_={RUN:"run",INSTALL:"install",REGISTER:"register",STOP:"stop",RESTART:"restart",VERSION:"version",UPGRADE:"upgrade"},w_={point:"point",lineString:"lineString",multiLineString:"multiLineString",multiPoint:"multiPoint",multiPolygon:"multiPolygon",polygon:"polygon"},st={HDB_ROOT_KEY:"HDB_ROOT",SERVER_PORT_KEY:"SERVER_PORT",CERT_KEY:"CERTIFICATE",PRIVATE_KEY_KEY:"PRIVATE_KEY",HTTP_SECURE_ENABLED_KEY:"HTTPS_ON",CORS_ENABLED_KEY:"CORS_ON",CORS_WHITELIST_KEY:"CORS_WHITELIST",LOG_LEVEL_KEY:"LOG_LEVEL",LOGGER_KEY:"LOGGER",LOG_PATH_KEY:"LOG_PATH",LOG_ROTATE:"LOG_ROTATE",LOG_ROTATE_MAX_SIZE:"LOG_ROTATE_MAX_SIZE",LOG_ROTATE_RETAIN:"LOG_ROTATE_RETAIN",LOG_ROTATE_COMPRESS:"LOG_ROTATE_COMPRESS",LOG_ROTATE_DATE_FORMAT:"LOG_ROTATE_DATE_FORMAT",LOG_ROTATE_ROTATE_MODULE:"LOG_ROTATE_ROTATE_MODULE",LOG_ROTATE_WORKER_INTERVAL:"LOG_ROTATE_WORKER_INTERVAL",LOG_ROTATE_ROTATE_INTERVAL:"LOG_ROTATE_ROTATE_INTERVAL",LOG_ROTATE_TIMEZONE:"LOG_ROTATE_TIMEZONE",LOG_DAILY_ROTATE_KEY:"LOG_DAILY_ROTATE",LOG_MAX_DAILY_FILES_KEY:"LOG_MAX_DAILY_FILES",PROPS_ENV_KEY:"NODE_ENV",SETTINGS_PATH_KEY:"settings_path",CLUSTERING_PORT_KEY:"CLUSTERING_PORT",CLUSTERING_NODE_NAME_KEY:"NODE_NAME",CLUSTERING_ENABLED_KEY:"CLUSTERING",ALLOW_SELF_SIGNED_SSL_CERTS:"ALLOW_SELF_SIGNED_SSL_CERTS",MAX_HDB_PROCESSES:"MAX_HDB_PROCESSES",INSTALL_USER:"install_user",CLUSTERING_USER_KEY:"CLUSTERING_USER",MAX_CLUSTERING_PROCESSES:"MAX_CLUSTERING_PROCESSES",SERVER_TIMEOUT_KEY:"SERVER_TIMEOUT_MS",SERVER_KEEP_ALIVE_TIMEOUT_KEY:"SERVER_KEEP_ALIVE_TIMEOUT",SERVER_HEADERS_TIMEOUT_KEY:"SERVER_HEADERS_TIMEOUT",DISABLE_TRANSACTION_LOG_KEY:"DISABLE_TRANSACTION_LOG",OPERATION_TOKEN_TIMEOUT_KEY:"OPERATION_TOKEN_TIMEOUT",REFRESH_TOKEN_TIMEOUT_KEY:"REFRESH_TOKEN_TIMEOUT",IPC_SERVER_PORT:"IPC_SERVER_PORT",CUSTOM_FUNCTIONS_ENABLED_KEY:"CUSTOM_FUNCTIONS",CUSTOM_FUNCTIONS_PORT_KEY:"CUSTOM_FUNCTIONS_PORT",CUSTOM_FUNCTIONS_DIRECTORY_KEY:"CUSTOM_FUNCTIONS_DIRECTORY",MAX_CUSTOM_FUNCTION_PROCESSES:"MAX_CUSTOM_FUNCTION_PROCESSES",LOG_TO_FILE:"LOG_TO_FILE",LOG_TO_STDSTREAMS:"LOG_TO_STDSTREAMS",RUN_IN_FOREGROUND:"RUN_IN_FOREGROUND",LOCAL_STUDIO_ON:"LOCAL_STUDIO_ON",STORAGE_WRITE_ASYNC:"STORAGE_WRITE_ASYNC"},V_=Et.invert(st),o={CLUSTERING_USER:"clustering_user",CLUSTERING_ENABLED:"clustering_enabled",CLUSTERING_HUBSERVER_CLUSTER_NAME:"clustering_hubServer_cluster_name",CLUSTERING_HUBSERVER_CLUSTER_NETWORK_PORT:"clustering_hubServer_cluster_network_port",CLUSTERING_HUBSERVER_CLUSTER_NETWORK_ROUTES:"clustering_hubServer_cluster_network_routes",CLUSTERING_HUBSERVER_LEAFNODES_NETWORK_PORT:"clustering_hubServer_leafNodes_network_port",CLUSTERING_HUBSERVER_NETWORK_PORT:"clustering_hubServer_network_port",CLUSTERING_LEAFSERVER_NETWORK_PORT:"clustering_leafServer_network_port",CLUSTERING_LEAFSERVER_NETWORK_ROUTES:"clustering_leafServer_network_routes",CLUSTERING_NODENAME:"clustering_nodeName",CLUSTERING_TLS_CERTIFICATE:"clustering_tls_certificate",CLUSTERING_TLS_PRIVATEKEY:"clustering_tls_privateKey",CLUSTERING_TLS_CERT_AUTH:"clustering_tls_certificateAuthority",CLUSTERING_TLS_INSECURE:"clustering_tls_insecure",CUSTOMFUNCTIONS_ENABLED:"customFunctions_enabled",CUSTOMFUNCTIONS_NETWORK_PORT:"customFunctions_network_port",CUSTOMFUNCTIONS_TLS_CERTIFICATE:"customFunctions_tls_certificate",CUSTOMFUNCTIONS_NETWORK_CORS:"customFunctions_network_cors",CUSTOMFUNCTIONS_NETWORK_CORSACCESSLIST:"customFunctions_network_corsAccessList",CUSTOMFUNCTIONS_NETWORK_HEADERSTIMEOUT:"customFunctions_network_headersTimeout",CUSTOMFUNCTIONS_NETWORK_HTTPS:"customFunctions_network_https",CUSTOMFUNCTIONS_NETWORK_KEEPALIVETIMEOUT:"customFunctions_network_keepAliveTimeout",CUSTOMFUNCTIONS_TLS_PRIVATEKEY:"customFunctions_tls_privateKey",CUSTOMFUNCTIONS_TLS_CERT_AUTH:"customFunctions_tls_certificateAuthority",CUSTOMFUNCTIONS_NETWORK_TIMEOUT:"customFunctions_network_timeout",CUSTOMFUNCTIONS_NODEENV:"customFunctions_nodeEnv",CUSTOMFUNCTIONS_ROOT:"customFunctions_root",HTTP_THREADS:"http_threads",IPC_NETWORK_PORT:"ipc_network_port",LOCALSTUDIO_ENABLED:"localStudio_enabled",LOGGING_FILE:"logging_file",LOGGING_LEVEL:"logging_level",LOGGING_ROOT:"logging_root",LOGGING_ROTATION_COMPRESS:"logging_rotation_compress",LOGGING_ROTATION_DATEFORMAT:"logging_rotation_dateFormat",LOGGING_ROTATION_MAXSIZE:"logging_rotation_maxSize",LOGGING_ROTATION_RETAIN:"logging_rotation_retain",LOGGING_ROTATION_ROTATE:"logging_rotation_rotate",LOGGING_ROTATION_ROTATEINTERVAL:"logging_rotation_rotateInterval",LOGGING_ROTATION_ROTATEMODULE:"logging_rotation_rotateModule",LOGGING_ROTATION_TIMEZONE:"logging_rotation_timezone",LOGGING_ROTATION_WORKERINTERVAL:"logging_rotation_workerInterval",LOGGING_STDSTREAMS:"logging_stdStreams",LOGGING_AUDITLOG:"logging_auditLog",OPERATIONSAPI_AUTHENTICATION_OPERATIONTOKENTIMEOUT:"operationsApi_authentication_operationTokenTimeout",OPERATIONSAPI_AUTHENTICATION_REFRESHTOKENTIMEOUT:"operationsApi_authentication_refreshTokenTimeout",OPERATIONSAPI_FOREGROUND:"operationsApi_foreground",OPERATIONSAPI_TLS_CERTIFICATE:"operationsApi_tls_certificate",OPERATIONSAPI_NETWORK_CORS:"operationsApi_network_cors",OPERATIONSAPI_NETWORK_CORSACCESSLIST:"operationsApi_network_corsAccessList",OPERATIONSAPI_NETWORK_HEADERSTIMEOUT:"operationsApi_network_headersTimeout",OPERATIONSAPI_NETWORK_HTTPS:"operationsApi_network_https",OPERATIONSAPI_NETWORK_KEEPALIVETIMEOUT:"operationsApi_network_keepAliveTimeout",OPERATIONSAPI_NETWORK_PORT:"operationsApi_network_port",OPERATIONSAPI_TLS_PRIVATEKEY:"operationsApi_tls_privateKey",OPERATIONSAPI_TLS_CERT_AUTH:"operationsApi_tls_certificateAuthority",OPERATIONSAPI_NETWORK_TIMEOUT:"operationsApi_network_timeout",OPERATIONSAPI_NODEENV:"operationsApi_nodeEnv",ROOTPATH:"rootPath",STORAGE_WRITEASYNC:"storage_writeAsync",STORAGE_OVERLAPPINGSYNC:"storage_overlappingSync"},v_={hdb_root_key:o.ROOTPATH,hdb_root:o.ROOTPATH,server_port_key:o.OPERATIONSAPI_NETWORK_PORT,server_port:o.OPERATIONSAPI_NETWORK_PORT,cert_key:o.OPERATIONSAPI_TLS_CERTIFICATE,certificate:o.OPERATIONSAPI_TLS_CERTIFICATE,private_key_key:o.OPERATIONSAPI_TLS_PRIVATEKEY,private_key:o.OPERATIONSAPI_TLS_PRIVATEKEY,http_secure_enabled_key:o.OPERATIONSAPI_NETWORK_HTTPS,https_on:o.OPERATIONSAPI_NETWORK_HTTPS,cors_enabled_key:o.OPERATIONSAPI_NETWORK_CORS,cors_on:o.OPERATIONSAPI_NETWORK_CORS,cors_whitelist_key:o.OPERATIONSAPI_NETWORK_CORSACCESSLIST,cors_whitelist:o.OPERATIONSAPI_NETWORK_CORSACCESSLIST,cors_accesslist_key:o.OPERATIONSAPI_NETWORK_CORSACCESSLIST,cors_accesslist:o.OPERATIONSAPI_NETWORK_CORSACCESSLIST,log_level_key:o.LOGGING_LEVEL,log_level:o.LOGGING_LEVEL,log_path_key:o.LOGGING_ROOT,log_path:o.LOGGING_ROOT,log_daily_rotate:o.LOGGING_ROTATION_ROTATE,log_rotate:o.LOGGING_ROTATION_ROTATE,log_rotate_max_size:o.LOGGING_ROTATION_MAXSIZE,log_rotate_retain:o.LOGGING_ROTATION_RETAIN,log_rotate_compress:o.LOGGING_ROTATION_COMPRESS,log_rotate_date_format:o.LOGGING_ROTATION_DATEFORMAT,log_rotate_rotate_module:o.LOGGING_ROTATION_ROTATEMODULE,log_rotate_worker_interval:o.LOGGING_ROTATION_WORKERINTERVAL,log_rotate_rotate_interval:o.LOGGING_ROTATION_ROTATEINTERVAL,log_rotate_timezone:o.LOGGING_ROTATION_TIMEZONE,props_env_key:o.OPERATIONSAPI_NODEENV,node_env:o.OPERATIONSAPI_NODEENV,clustering_node_name_key:o.CLUSTERING_NODENAME,node_name:o.CLUSTERING_NODENAME,clustering_enabled_key:o.CLUSTERING_ENABLED,clustering:o.CLUSTERING_ENABLED,max_http_threads:o.HTTP_THREADS,max_hdb_processes:o.HTTP_THREADS,server_timeout_key:o.OPERATIONSAPI_NETWORK_TIMEOUT,server_timeout_ms:o.OPERATIONSAPI_NETWORK_TIMEOUT,server_keep_alive_timeout_key:o.OPERATIONSAPI_NETWORK_KEEPALIVETIMEOUT,server_keep_alive_timeout:o.OPERATIONSAPI_NETWORK_KEEPALIVETIMEOUT,server_headers_timeout_key:o.OPERATIONSAPI_NETWORK_HEADERSTIMEOUT,server_headers_timeout:o.OPERATIONSAPI_NETWORK_HEADERSTIMEOUT,disable_transaction_log_key:o.LOGGING_AUDITLOG,disable_transaction_log:o.LOGGING_AUDITLOG,operation_token_timeout_key:o.OPERATIONSAPI_AUTHENTICATION_OPERATIONTOKENTIMEOUT,operation_token_timeout:o.OPERATIONSAPI_AUTHENTICATION_OPERATIONTOKENTIMEOUT,refresh_token_timeout_key:o.OPERATIONSAPI_AUTHENTICATION_REFRESHTOKENTIMEOUT,refresh_token_timeout:o.OPERATIONSAPI_AUTHENTICATION_REFRESHTOKENTIMEOUT,ipc_server_port:o.IPC_NETWORK_PORT,custom_functions_enabled_key:o.CUSTOMFUNCTIONS_ENABLED,custom_functions:o.CUSTOMFUNCTIONS_ENABLED,custom_functions_port_key:o.CUSTOMFUNCTIONS_NETWORK_PORT,custom_functions_port:o.CUSTOMFUNCTIONS_NETWORK_PORT,custom_functions_directory_key:o.CUSTOMFUNCTIONS_ROOT,custom_functions_directory:o.CUSTOMFUNCTIONS_ROOT,max_custom_function_processes:o.HTTP_THREADS,log_to_file:o.LOGGING_FILE,log_to_stdstreams:o.LOGGING_STDSTREAMS,run_in_foreground:o.OPERATIONSAPI_FOREGROUND,local_studio_on:o.LOCALSTUDIO_ENABLED,clustering_port:o.CLUSTERING_HUBSERVER_CLUSTER_NETWORK_PORT,clustering_user:o.CLUSTERING_USER,clustering_enabled:o.CLUSTERING_ENABLED,clustering_hubserver_cluster_name:o.CLUSTERING_HUBSERVER_CLUSTER_NAME,clustering_hubserver_cluster_network_port:o.CLUSTERING_HUBSERVER_CLUSTER_NETWORK_PORT,clustering_hubserver_cluster_network_routes:o.CLUSTERING_HUBSERVER_CLUSTER_NETWORK_ROUTES,clustering_hubserver_leafnodes_network_port:o.CLUSTERING_HUBSERVER_LEAFNODES_NETWORK_PORT,clustering_hubserver_network_port:o.CLUSTERING_HUBSERVER_NETWORK_PORT,clustering_leafserver_network_port:o.CLUSTERING_LEAFSERVER_NETWORK_PORT,clustering_leafserver_network_routes:o.CLUSTERING_LEAFSERVER_NETWORK_ROUTES,clustering_nodename:o.CLUSTERING_NODENAME,clustering_tls_certificate:o.CLUSTERING_TLS_CERTIFICATE,clustering_tls_privatekey:o.CLUSTERING_TLS_PRIVATEKEY,clustering_tls_certificateauthority:o.CLUSTERING_TLS_CERT_AUTH,clustering_tls_insecure:o.CLUSTERING_TLS_INSECURE,customfunctions_enabled:o.CUSTOMFUNCTIONS_ENABLED,customfunctions_network_port:o.CUSTOMFUNCTIONS_NETWORK_PORT,customfunctions_tls_certificate:o.CUSTOMFUNCTIONS_TLS_CERTIFICATE,customfunctions_network_cors:o.CUSTOMFUNCTIONS_NETWORK_CORS,customfunctions_network_corsaccesslist:o.CUSTOMFUNCTIONS_NETWORK_CORSACCESSLIST,customfunctions_network_headerstimeout:o.CUSTOMFUNCTIONS_NETWORK_HEADERSTIMEOUT,customfunctions_network_https:o.CUSTOMFUNCTIONS_NETWORK_HTTPS,customfunctions_network_keepalivetimeout:o.CUSTOMFUNCTIONS_NETWORK_KEEPALIVETIMEOUT,customfunctions_tls_privatekey:o.CUSTOMFUNCTIONS_TLS_PRIVATEKEY,customfunctions_tls_certificateauthority:o.CUSTOMFUNCTIONS_TLS_CERT_AUTH,customfunctions_network_timeout:o.CUSTOMFUNCTIONS_NETWORK_TIMEOUT,customfunctions_nodeenv:o.CUSTOMFUNCTIONS_NODEENV,http_threads:o.HTTP_THREADS,customfunctions_processes:o.HTTP_THREADS,customfunctions_root:o.CUSTOMFUNCTIONS_ROOT,ipc_network_port:o.IPC_NETWORK_PORT,localstudio_enabled:o.LOCALSTUDIO_ENABLED,logging_file:o.LOGGING_FILE,logging_level:o.LOGGING_LEVEL,logging_root:o.LOGGING_ROOT,logging_rotation_compress:o.LOGGING_ROTATION_COMPRESS,logging_rotation_dateformat:o.LOGGING_ROTATION_DATEFORMAT,logging_rotation_maxsize:o.LOGGING_ROTATION_MAXSIZE,logging_rotation_retain:o.LOGGING_ROTATION_RETAIN,logging_rotation_rotate:o.LOGGING_ROTATION_ROTATE,logging_rotation_rotateinterval:o.LOGGING_ROTATION_ROTATEINTERVAL,logging_rotation_rotatemodule:o.LOGGING_ROTATION_ROTATEMODULE,logging_rotation_timezone:o.LOGGING_ROTATION_TIMEZONE,logging_rotation_workerinterval:o.LOGGING_ROTATION_WORKERINTERVAL,logging_stdstreams:o.LOGGING_STDSTREAMS,logging_auditlog:o.LOGGING_AUDITLOG,operationsapi_authentication_operationtokentimeout:o.OPERATIONSAPI_AUTHENTICATION_OPERATIONTOKENTIMEOUT,operationsapi_authentication_refreshtokentimeout:o.OPERATIONSAPI_AUTHENTICATION_REFRESHTOKENTIMEOUT,operationsapi_foreground:o.OPERATIONSAPI_FOREGROUND,operationsapi_tls_certificate:o.OPERATIONSAPI_TLS_CERTIFICATE,operationsapi_network_cors:o.OPERATIONSAPI_NETWORK_CORS,operationsapi_network_corsaccesslist:o.OPERATIONSAPI_NETWORK_CORSACCESSLIST,operationsapi_network_headerstimeout:o.OPERATIONSAPI_NETWORK_HEADERSTIMEOUT,operationsapi_network_https:o.OPERATIONSAPI_NETWORK_HTTPS,operationsapi_network_keepalivetimeout:o.OPERATIONSAPI_NETWORK_KEEPALIVETIMEOUT,operationsapi_network_port:o.OPERATIONSAPI_NETWORK_PORT,operationsapi_tls_privatekey:o.OPERATIONSAPI_TLS_PRIVATEKEY,operationsapi_network_timeout:o.OPERATIONSAPI_NETWORK_TIMEOUT,operationsapi_nodeenv:o.OPERATIONSAPI_NODEENV,operationsapi_root:o.ROOTPATH,rootpath:o.ROOTPATH,storage_writeasync:o.STORAGE_WRITEASYNC,storage_overlappingsync:o.STORAGE_OVERLAPPINGSYNC},Y_={csv_file_load:"csv_file_load",csv_data_load:i.CSV_DATA_LOAD,csv_url_load:i.CSV_URL_LOAD,delete_files_before:"delete_files_before",delete_records_before:"delete_records_before",delete_audit_logs_before:"delete_audit_logs_before",delete_transaction_logs_before:"delete_transaction_logs_before",empty_trash:"empty_trash",export_local:"export_local",export_to_s3:"export_to_s3",import_from_s3:"import_from_s3"},k_={CLUSTERING_PAYLOAD:"clustering_payload",DELEGATE_THREAD_RESPONSE:"delegate_thread_response",CLUSTERING:"clustering",SCHEMA:"schema",CLUSTER_STATUS:"cluster_status",JOB:"job",CHILD_STARTED:"child_started",CHILD_STOPPED:"child_stopped",USER:"user",RESTART:"restart"},q_={BIDIRECTIONAL:"BIDIRECTIONAL",OUTBOUND:"OUTBOUND",INBOUND:"INBOUND"},W_={FILE_SYSTEM:"fs",LMDB:"lmdb"},j_={API_CALL_DEFAULT:1e4,VERSION_DEFAULT:"2.2.0"},x_={DEVELOPMENT:8192,DEFAULT:512},$_={IDENTIFY:"identify",AUTHENTICATE:"authenticate",AUTHENTICATE_OK:"authenticated",AUTHENTICATE_FAIL:"authenticate_fail",CONNECTION:"connection",CONNECT:"connect",CATCHUP_REQUEST:"catchup_request",CATCHUP_RESPONSE:"catchup",CONFIRM_MSG:"confirm_msg",ERROR:"error",DISCONNECT:"disconnect",SCHEMA_UPDATE_REQ:"schema_update_request",SCHEMA_UPDATE_RES:"schema_update_response",RECONNECT_ATTEMPT:"reconnect_attempt",CONNECT_ERROR:"connect_error",MESSAGE:"msg",VERSION_MISMATCH:"version_mismatch",DIRECTION_CHANGE:"direction_change"},J_={1e3:"SUCCESSFUL_SHUTDOWN",1001:"CLOSE_GOING_AWAY",1002:"CLOSE_PROTOCOL_ERROR",1003:"CLOSE_UNSUPPORTED",1005:"CLOSE_NO_STATUS",1006:"CLOSE_ABNORMAL",1007:"UNSUPPORTED_PAYLOAD",1008:"POLICY_VIOLATION",1009:"CLOSE_TOO_LARGE",1010:"MANDATORY_EXTENSION",1011:"SERVER_ERROR",1012:"SERVICE_RESTART",1013:"SERVER_BUSY",1014:"BAD_GATEWAY",1015:"HANDSHAKE_FAIL",4141:"LICENSE_LIMIT_REACHED"},Q_={ENOENT:"ENOENT",EACCES:"EACCES"},it={CREATED_TIME:"__createdtime__",UPDATED_TIME:"__updatedtime__"},X_="__clustering__",Z_=Object.values(it),z_=15984864e5,Tt={LESS:"<",LESS_OR_EQ:"<=",GREATER:">",GREATER_OR_EQ:">=",BETWEEN:"..."},eo=Et.invert(Tt),to={GET_CLUSTER_STATUS:"GET_CLUSTER_STATUS",CLUSTER_STATUS_RESPONSE:"CLUSTER_STATUS_RESPONSE",ERROR_RESPONSE:"ERROR",ADD_USER:"ADD_USER",ALTER_USER:"ALTER_USER",DROP_USER:"DROP_USER",HDB_OPERATION:"HDB_OPERATION",ADD_NODE:"ADD_NODE",UPDATE_NODE:"UPDATE_NODE",REMOVE_NODE:"REMOVE_NODE",HDB_USERS_MSG:"HDB_USERS_MSG",HDB_WORKERS:"HDB_WORKERS",HDB_TRANSACTION:"HDB_TRANSACTION"},ro=111,_o=`\r
|
|
2
2
|
`,oo={READ:"read",INSERT:"insert",UPDATE:"update",DELETE:"delete"},no=["*","%"],Eo="unauthorized_access",so="func_val",io={HASH_VALUE:"hash_value",TIMESTAMP:"timestamp",USERNAME:"username"},To={JWT_PRIVATE_KEY_NAME:".jwtPrivate.key",JWT_PUBLIC_KEY_NAME:".jwtPublic.key",JWT_PASSPHRASE_NAME:".jwtPass"},So="hdb_ipc_server",Ro="hdb_ipc_client_",co={RESTART:"restart",CHILD_STARTED:"child_started",CHILD_STOPPED:"child_stopped",SCHEMA:"schema",USER:"user",CLUSTER_STATUS_RESPONSE:"cluster_status_response",CLUSTER_STATUS_REQUEST:"cluster_status_request"},ao={HDB_CORE:"hdb_core",CUSTOM_FUNCTIONS:"custom_functions"},Oo={STOPPED:"stopped",ONLINE:"online"},Ao="3.x.x";St.exports={LOCAL_HARPERDB_OPERATIONS:O,HDB_SUPPORT_ADDRESS:rt,HDB_SUPPORT_URL:ot,HDB_PRICING_URL:Kr,SUPPORT_HELP_MSG:wr,LICENSE_HELP_MSG:nt,HDB_PROC_NAME:ze,HDB_PROC_DESCRIPTOR:Fe,CLUSTERING_LEAF_PROC_DESCRIPTOR:Ie,CLUSTERING_HUB_PROC_DESCRIPTOR:ue,SYSTEM_SCHEMA_NAME:o_,HASH_FOLDER_NAME:n_,HDB_HOME_DIR_NAME:E_,UPDATE_FILE_NAME:S_,LICENSE_KEY_DIR_NAME:i_,BOOT_PROPS_FILE_NAME:T_,JOB_TYPE_ENUM:Y_,JOB_STATUS_ENUM:F_,SYSTEM_TABLE_NAMES:P_,SYSTEM_TABLE_HASH_ATTRIBUTES:M_,OPERATIONS_ENUM:i,VALID_S3_FILE_TYPES:b_,S3_BUCKET_AUTH_KEYS:B_,VALID_SQL_OPS_ENUM:y_,GEO_CONVERSION_ENUM:w_,HDB_SETTINGS_NAMES:st,HDB_SETTINGS_NAMES_REVERSE_LOOKUP:V_,SERVICE_ACTIONS_ENUM:K_,CLUSTER_MESSAGE_TYPE_ENUM:k_,CLUSTER_CONNECTION_DIRECTION_ENUM:q_,CLUSTER_EVENTS_DEFS_ENUM:$_,PERIOD_REGEX:jr,DOUBLE_PERIOD_REGEX:xr,UNICODE_PERIOD:$r,FORWARD_SLASH_REGEX:Jr,UNICODE_FORWARD_SLASH:Qr,ESCAPED_FORWARD_SLASH_REGEX:Xr,ESCAPED_PERIOD_REGEX:Zr,ESCAPED_DOUBLE_PERIOD_REGEX:zr,REG_KEY_FILE_NAME:G_,RESTART_TIMEOUT_MS:a_,HDB_FILE_PERMISSIONS:O_,SCHEMA_DIR_NAME:u_,TRANSACTIONS_DIR_NAME:I_,LIMIT_COUNT_NAME:l_,ID_ATTRIBUTE_STRING:C_,INSERT_MODULE_ENUM:D_,UPGRADE_JSON_FIELD_NAMES_ENUM:g_,RESTART_CODE:R_,RESTART_CODE_NUM:c_,CLUSTER_OPERATIONS:$,SYSTEM_DEFAULT_ATTRIBUTE_NAMES:h_,HDB_INTERNAL_SC_CHANNEL_PREFIX:M,INTERNAL_SC_CHANNELS:m_,CLUSTERING_MESSAGE_TYPES:to,HDB_FILE_SUFFIX:s_,BLOB_FOLDER_NAME:A_,HDB_TRASH_DIR:N_,ORIGINATOR_SET_VALUE:ro,LICENSE_VALUES:j_,RAM_ALLOCATION_ENUM:x_,STORAGE_TYPES_ENUM:W_,TIME_STAMP_NAMES_ENUM:it,TIME_STAMP_NAMES:Z_,PERMS_UPDATE_RELEASE_TIMESTAMP:z_,SEARCH_NOT_FOUND_MESSAGE:Vr,SEARCH_ATTRIBUTE_NOT_FOUND:vr,LICENSE_ROLE_DENIED_RESPONSE:Yr,LICENSE_MAX_CONNS_REACHED:kr,BASIC_LICENSE_MAX_NON_CU_ROLES:_t,BASIC_LICENSE_CLUSTER_CONNECTION_LIMIT_WS_ERROR_CODE:yr,VALUE_SEARCH_COMPARATORS:Tt,VALUE_SEARCH_COMPARATORS_REVERSE_LOOKUP:eo,LICENSE_FILE_NAME:H_,WEBSOCKET_CLOSE_CODE_DESCRIPTION_LOOKUP:J_,NEW_LINE:_o,BASIC_LICENSE_MAX_CLUSTER_USER_ROLES:Wr,MOMENT_DAYS_TAG:e_,API_TURNOVER_SEC:t_,LOOPBACK:qr,CODE_EXTENSION:Se,WILDCARD_SEARCH_VALUE:r_,NODE_ERROR_CODES:Q_,JAVASCRIPT_EXTENSION:Ze,PERMS_CRUD_ENUM:oo,UNAUTHORIZED_PERMISSION_NAME:Eo,SEARCH_WILDCARDS:no,FUNC_VAL:so,READ_AUDIT_LOG_SEARCH_TYPES_ENUM:io,JWT_ENUM:To,CLUSTERING_FLAG:X_,RUN_LOG:L_,INSTALL_LOG:d_,IPC_SERVER_MODULE:tt,HDB_IPC_SERVER:So,IPC_EVENT_TYPES:co,HDB_IPC_CLIENT_PREFIX:Ro,CUSTOM_FUNCTION_PROC_NAME:et,CUSTOM_FUNCTION_PROC_DESCRIPTOR:Ne,SERVICES:ao,MEM_SETTING_KEY:__,HDB_RESTART_SCRIPT:gr,PROCESS_DESCRIPTORS:He,SERVICE_SERVERS:Hr,SERVICE_SERVERS_CWD:Ae,PROCESS_DESCRIPTORS_VALIDATE:hr,LAUNCH_SERVICE_SCRIPTS:Fr,LOG_LEVELS:mr,PROCESS_NAME_ENV_PROP:f_,PROCESS_LOG_NAMES:Mr,PM2_PROCESS_STATUSES:Oo,CONFIG_PARAM_MAP:v_,CONFIG_PARAMS:o,HDB_CONFIG_FILE:Ur,HDB_DEFAULT_CONFIG_FILE:pr,ROLE_TYPES_ENUM:br,BOOT_PROP_PARAMS:U_,INSTALL_PROMPTS:p_,HDB_ROOT_DIR_NAME:Dr,CLUSTERING_PROCESSES:Gr,FOREGROUND_PID_FILE:Pr,PACKAGE_ROOT:F,PRE_4_0_0_VERSION:Ao}});var Ot=P((Ts,at)=>{"use strict";var Rt=require("minimist");at.exports=No;function No(e=[],t=!1){if(!Array.isArray(e))return{};let r,_;t?(r=ct(process.env),_=ct(Rt(process.argv))):(r=process.env,_=Rt(process.argv));let E={};for(let s=0,T=e.length;s<T;s++){let R=e[s];_[R]!==void 0?E[R]=_[R].toString().trim():r[R]!==void 0&&(E[R]=r[R].toString().trim())}return E}n(No,"assignCMDENVVariables");function ct(e){let t,r=Object.keys(e),_=r.length,E={};for(;_--;)t=r[_],E[t.toLowerCase()]=e[t];return E}n(ct,"objKeysToLowerCase")});var te=P((Ss,dt)=>{"use strict";var Z=require("fs-extra"),z=require("path"),Nt=require("yaml"),ut=require("properties-reader"),u=y(),uo=Ot(),Io=require("os"),{PACKAGE_ROOT:we}=y(),U={notify:7,fatal:6,error:5,warn:4,info:3,debug:2,trace:1},le=z.join(we,"logs"),J=process.env.pm_id===void 0,lo=z.join(we,"config/yaml/",u.HDB_DEFAULT_CONFIG_FILE),Ve=process.env.PROCESS_NAME===void 0?u.PROCESS_DESCRIPTORS.INSTALL:process.env.PROCESS_NAME,_e,K,k,f,ye,oe;oe===void 0&&It();dt.exports={createLogFile:Co,notify:Uo,fatal:po,error:Ke,warn:Do,info:Lo,debug:fo,trace:Ct,setLogLevel:Po,log_level:f};function It(){try{if(oe===void 0){let e=go();oe=ut(e),{level:f,config_log_path:ye,to_file:K,to_stream:k}=Mo(oe.get("settings_path"))}}catch(e){if(oe=void 0,e.code===u.NODE_ERROR_CODES.ENOENT){let t=uo(Object.keys(u.CONFIG_PARAM_MAP),!0);for(let s in t){let T=u.CONFIG_PARAM_MAP[s];T&&T.toLowerCase();let R=t[s];if(T===u.CONFIG_PARAMS.LOGGING_LEVEL){f=R;continue}if(T===u.CONFIG_PARAMS.LOGGING_STDSTREAMS){k=R;continue}T===u.CONFIG_PARAMS.LOGGING_FILE&&(K=T)}let{default_level:r,default_to_file:_,default_to_stream:E}=mo();K=K===void 0?_:K,K=At(K),k=k===void 0?E:k,k=At(k),f=f===void 0?r:f,ye=le;return}throw Ke("Error initializing log settings"),Ke(e),e}}n(It,"initLogSettings");function Co(e,t){if(!J){Ct("createLogFile should only be used if the process is not being managed by pm2");return}oe===void 0&&It(),Ve=t;let r;e===u.PROCESS_LOG_NAMES.INSTALL?r=le:r=ye,K&&(_e=z.join(r,e),Z.ensureFileSync(_e))}n(Co,"createLogFile");function ee(e,t){let r=new Date(Date.now()).toISOString(),_="",E=t.length,s=E-1;for(let T=0;T<E;T++){let R=t[T];R instanceof Error&&R.stack?_+=R.stack:typeof R=="object"?_+=JSON.stringify(R):_+=R,T<s&&(_+=" ")}return`{"process_name": "${Ve}", "level": "${e}", "timestamp": "${r}", "message": "${_}"}
|
|
3
3
|
`}n(ee,"createLogRecord");function lt(e){_e===void 0&&(Ve=u.PROCESS_DESCRIPTORS.INSTALL,Z.ensureDirSync(le),_e=z.join(le,u.PROCESS_LOG_NAMES.INSTALL),Z.ensureFileSync(_e)),Z.appendFileSync(_e,e)}n(lt,"writeToLogFile");function Ce(e){K&<(e),k&&process.stdout.write(e)}n(Ce,"nonPm2LogStdOut");function ve(e){K&<(e),k&&process.stderr.write(e)}n(ve,"nonPm2LogStdErr");function Lo(...e){if(U[f]<=U.info){let t=ee("info",e);if(J){Ce(t);return}process.stdout.write(t)}}n(Lo,"info");function Ct(...e){if(U[f]<=U.trace){let t=ee("trace",e);if(J){Ce(t);return}process.stdout.write(t)}}n(Ct,"trace");function Ke(...e){if(U[f]<=U.error){let t=ee("error",e);if(J){ve(t);return}process.stderr.write(t)}}n(Ke,"error");function fo(...e){if(U[f]<=U.debug){let t=ee("debug",e);if(J){Ce(t);return}process.stdout.write(t)}}n(fo,"debug");function Uo(...e){if(U[f]<=U.notify){let t=ee("notify",e);if(J){Ce(t);return}process.stdout.write(t)}}n(Uo,"notify");function po(...e){if(U[f]<=U.fatal){let t=ee("fatal",e);if(J){ve(t);return}process.stderr.write(t)}}n(po,"fatal");function Do(...e){if(U[f]<=U.warn){let t=ee("warn",e);if(J){ve(t);return}process.stderr.write(t)}}n(Do,"warn");function go(){let e;try{e=Io.homedir()}catch{e=process.env.HOME}e||(e="~/");let t=z.join(e,u.HDB_HOME_DIR_NAME,u.BOOT_PROPS_FILE_NAME);return Z.existsSync(t)||(t=z.join(we,"utility/hdb_boot_properties.file")),t}n(go,"getPropsFilePath");function Po(e){f=e}n(Po,"setLogLevel");function At(e){return e===!0||typeof e=="string"&&e.toLowerCase()==="true"}n(At,"autoCastBoolean");function Mo(e){try{if(e.includes("config/settings.js")){let T=ut(e);return{level:T.get(u.HDB_SETTINGS_NAMES.LOG_LEVEL_KEY),config_log_path:z.dirname(T.get(u.HDB_SETTINGS_NAMES.LOG_PATH_KEY)),to_file:T.get(u.HDB_SETTINGS_NAMES.LOG_TO_FILE),to_stream:T.get(u.HDB_SETTINGS_NAMES.LOG_TO_STDSTREAMS)}}let t=Nt.parseDocument(Z.readFileSync(e,"utf8")),r=t.getIn(["logging","level"]),_=t.getIn(["logging","root"]),E=t.getIn(["logging","file"]),s=t.getIn(["logging","stdStreams"]);return{level:r,config_log_path:_,to_file:E,to_stream:s}}catch(t){if(t.code===u.NODE_ERROR_CODES.ENOENT)throw t;console.error("Error accessing config file for logging"),console.error(t)}}n(Mo,"getLogConfig");function mo(){try{let e=Nt.parseDocument(Z.readFileSync(lo,"utf8")),t=e.getIn(["logging","level"]),r=e.getIn(["logging","file"]),_=e.getIn(["logging","stdStreams"]);return{default_level:t,default_to_file:r,default_to_stream:_}}catch(e){console.error("Error accessing default config file for logging"),console.error(e)}}n(mo,"getDefaultConfig")});var ft=P((Rs,Lt)=>{"use strict";var ho=require("util"),Go=require("path"),Ho=require("child_process"),Fo=ho.promisify(Ho.execFile),bo=1e3*1e3*10;Lt.exports={findPs:Bo};async function Bo(e){let t={};try{await Promise.all(["comm","args","ppid","uid","%cpu","%mem"].map(async r=>{let{stdout:_}=await Fo("ps",["wwxo",`pid,${r}`],{maxBuffer:bo});for(let E of _.trim().split(`
|
|
4
|
-
`).slice(1)){E=E.trim();let[s]=E.split(" ",1),T=E.slice(s.length+1).trim();t[s]===void 0&&(t[s]={}),t[s][r]=T}}))}catch(r){throw r}return Object.entries(t).filter(([,r])=>r.comm&&r.args&&r.ppid&&r.uid&&r["%cpu"]&&r["%mem"]&&r.args.includes(e)).map(([r,_])=>({pid:Number.parseInt(r,10),name:Go.basename(_.comm),cmd:_.args,ppid:Number.parseInt(_.ppid,10),uid:Number.parseInt(_.uid,10),cpu:Number.parseFloat(_["%cpu"]),memory:Number.parseFloat(_["%mem"])}))}n(Bo,"findPs")});var Dt=P((cs,pt)=>{"use strict";var yo="__dbis__",Ko="__environment_name__",wo="__dbi_defintion__",Vo={EQUALS:"equals",STARTS_WITH:"startsWith",_STARTS_WITH:"starts_with",ENDS_WITH:"endsWith",_ENDS_WITH:"ends_with",CONTAINS:"contains",SEARCH_ALL:"searchAll",SEARCH_ALL_TO_MAP:"searchAllToMap",BATCH_SEARCH_BY_HASH:"batchSearchByHash",BATCH_SEARCH_BY_HASH_TO_MAP:"batchSearchByHashToMap",GREATER_THAN:"greaterThan",_GREATER_THAN:"greater_than",GREATER_THAN_EQUAL:"greaterThanEqual",_GREATER_THAN_EQUAL:"greater_than_equal",LESS_THAN:"lessThan",_LESS_THAN:"less_than",LESS_THAN_EQUAL:"lessThanEqual",_LESS_THAN_EQUAL:"less_than_equal",BETWEEN:"between"},vo=["__createdtime__","__updatedtime__"],Yo="\uFFFF",Ut={TIMESTAMP:"timestamp",HASH_VALUE:"hash_value",USER_NAME:"user_name"},ko=Object.values(Ut);pt.exports={INTERNAL_DBIS_NAME:yo,DBI_DEFINITION_NAME:wo,SEARCH_TYPES:Vo,TIMESTAMP_NAMES:vo,MAX_SEARCH_KEY_LENGTH:256,ENVIRONMENT_NAME_KEY:Ko,TRANSACTIONS_DBI_NAMES_ENUM:Ut,TRANSACTIONS_DBIS:ko,OVERFLOW_MARKER:Yo}});var de=P((as,bt)=>{"use strict";var gt=y(),Pt=Dt(),Mt={CONTINUE:100,OK:200,CREATED:201,BAD_REQUEST:400,UNAUTHORIZED:401,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,REQUEST_TIMEOUT:408,CONFLICT:409,TOO_MANY_REQUESTS:429,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,INSUFFICIENT_STORAGE:507,NETWORK_AUTHENTICATION_REQUIRED:511},mt=n(e=>`${e} Check logs and try again.`,"CHECK_LOGS_WRAPPER"),ht={500:mt("There was an error processing your request."),400:"Invalid request"},qo=ht[Mt.INTERNAL_SERVER_ERROR],Wo={OP_NOT_SUPPORTED_FOR_FS:e=>`${e} is not available for this instance because it uses the File System data store.`,MISSING_VALUE:e=>`${e} is missing.`,INVALID_VALUE:e=>`${e} is invalid.`,NOT_FOUND:e=>`${e} not found.`},jo={CONFIG_VALIDATION:e=>`HarperDB config file validation error: ${e}`},xo={DEFAULT_BULK_LOAD_ERR:"There was an error during your bulk load into HarperDB.",DOWNLOAD_FILE_ERR:e=>`There was an error downloading '${e}'.`,INSERT_JSON_ERR:"There was an error inserting the downloaded JSON data.",INSERT_CSV_ERR:"There was an error inserting the downloaded CSV data.",INVALID_ACTION_PARAM_ERR:e=>`Bulk load operation failed - ${e} is not a valid 'action' parameter`,INVALID_FILE_EXT_ERR:e=>`Error selecting correct parser - valid file type not found in json - ${e}`,MAX_FILE_SIZE_ERR:(e,t)=>`File size is ${e} bytes, which exceeded the maximum size allowed of: ${t} bytes`,PAPA_PARSE_ERR:"There was an error parsing the downloaded CSV data.",S3_DOWNLOAD_ERR:e=>`There was an error downloading '${e}' from AWS.`,WRITE_TEMP_FILE_ERR:"Error writing temporary file to storage"},$o={BASE_PATH_REQUIRED:"base_path is required",DESTINATION_PATH_REQUIRED:"destination_path is required",ENV_NAME_REQUIRED:"env_name is required",INVALID_BASE_PATH:"invalid base_path",INVALID_DESTINATION_PATH:"invalid destination_path",INVALID_ENVIRONMENT:"invalid environment",ENV_REQUIRED:"env is required",DBI_NAME_REQUIRED:"dbi_name is required",DBI_DOES_NOT_EXIST:"dbi does not exist",HASH_ATTRIBUTE_REQUIRED:"hash_attribute is required",ID_REQUIRED:"id is required",IDS_REQUIRED:"ids is required",IDS_MUST_BE_ARRAY:"ids must be an array",FETCH_ATTRIBUTES_REQUIRED:"fetch_attributes is required",FETCH_ATTRIBUTES_MUST_BE_ARRAY:"fetch_attributes must be an array",ATTRIBUTE_REQUIRED:"attribute is required",SEARCH_VALUE_REQUIRED:"search_value is required",SEARCH_VALUE_TOO_LARGE:"search_value is too long",WRITE_ATTRIBUTES_REQUIRED:"write_attributes is required",WRITE_ATTRIBUTES_MUST_BE_ARRAY:"write_attributes must be an array",RECORDS_REQUIRED:"records is required",RECORDS_MUST_BE_ARRAY:"records must be an array",CANNOT_CREATE_INTERNAL_DBIS_NAME:`cannot create a dbi named ${Pt.INTERNAL_DBIS_NAME}`,CANNOT_DROP_INTERNAL_DBIS_NAME:`cannot drop a dbi named ${Pt.INTERNAL_DBIS_NAME}`,START_VALUE_REQUIRED:"start_value is required",END_VALUE_REQUIRED:"end_value is required",CANNOT_COMPARE_STRING_TO_NUMERIC_KEYS:"cannot compare a string to numeric keys",END_VALUE_MUST_BE_GREATER_THAN_START_VALUE:"end_value must be greater than or equal to start_value",UNKNOWN_SEARCH_TYPE:"unknown search type",CANNOT_DROP_TABLE_HASH_ATTRIBUTE:"cannot drop a table's hash attribute"},Jo={ATTR_NAME_LENGTH_ERR:e=>`transaction aborted due to attribute name ${e} being too long. Attribute names cannot be longer than ${gt.INSERT_MODULE_ENUM.MAX_CHARACTER_SIZE} bytes.`,ATTR_NAME_NULLISH_ERR:"transaction aborted due to record(s) with an attribute name that is null, undefined or empty string",HASH_VAL_LENGTH_ERR:`transaction aborted due to record(s) with a hash value that exceeds ${gt.INSERT_MODULE_ENUM.MAX_CHARACTER_SIZE} bytes, check log for more info`,INVALID_FORWARD_SLASH_IN_HASH_ERR:"transaction aborted due to record(s) with a hash value that contains a forward slash, check log for more info",RECORD_MISSING_HASH_ERR:"transaction aborted due to record(s) with no hash value, check log for more info"},Gt={GENERIC_AUTH_FAIL:"Login failed",USER_INACTIVE:"Cannot complete request: User is inactive",INVALID_TOKEN:"invalid token",NO_ENCRYPTION_KEYS:"unable to generate JWT as there are no encryption keys. please contact your administrator",INVALID_CREDENTIALS:"invalid credentials",PASSWORD_REQUIRED:"password is required",USERNAME_REQUIRED:"username is required",REFRESH_TOKEN_REQUIRED:"refresh_token is required",INVALID_AUTH_OBJECT:"invalid auth_object",INVALID_BODY:"invalid body",TOKEN_EXPIRED:"token expired",REFRESH_TOKEN_SAVE_FAILED:"unable to store refresh_token"},Qo={DEFAULT_INVALID_REQUEST:"Invalid request",OP_AUTH_PERMS_ERROR:"This operation is not authorized due to role restrictions and/or invalid schema items",OP_IS_SU_ONLY:e=>`Operation '${e}' is restricted to 'super_user' roles`,OP_NOT_FOUND:e=>`Operation '${e}' not found`,SYSTEM_TIMESTAMP_PERMS_ERR:"Internal timestamp attributes - '__createdtime_' and '__updatedtime__' - cannot be inserted to or updated by HDB users.",UNKNOWN_OP_AUTH_ERROR:(e,t,r)=>`There was an error authorizing ${e} op on table '${t}.${r}'`,USER_HAS_NO_PERMS:e=>`User ${e} has no role or permissions. Please assign the user a valid role.`,DROP_SYSTEM:"The 'system' schema, tables and records are used internally by HarperDB and cannot be updated or removed."},Xo={ATTR_PERM_MISSING:(e,t)=>`${e.toUpperCase()} attribute permission missing for '${t}'`,ATTR_PERM_MISSING_NAME:"Permission object in 'attribute_permission' missing an 'attribute_name'",ATTR_PERM_NOT_BOOLEAN:(e,t)=>`${e.toUpperCase()} attribute permission for '${t}' must be a boolean`,ATTR_PERMS_ARRAY_MISSING:"Missing 'attribute_permissions' array",ATTR_PERMS_NOT_ARRAY:"Value for 'attribute_permissions' must be an array",INVALID_ATTRIBUTE_IN_PERMS:e=>`Invalid attribute '${e}' in 'attribute_permissions'`,INVALID_PERM_KEY:e=>`Invalid table permission key value '${e}'`,INVALID_ATTR_PERM_KEY:e=>`Invalid attribute permission key value '${e}'`,INVALID_ROLE_JSON_KEYS:e=>`Invalid ${e.length>1?"keys":"key"} in JSON body - '${e.join("', '")}'`,MISMATCHED_TABLE_ATTR_PERMS:e=>`You have a conflict with TABLE permissions for '${e}' being false and ATTRIBUTE permissions being true`,OUTDATED_PERMS_TRANSLATION_ERROR:"This instance was recently upgraded and uses our new role permissions structure. Please login to this instance in HarperDB Studio, go to 'Roles', and click 'Update Role Permission' for all standard roles to migrate them to the new structure.",ROLE_ALREADY_EXISTS:e=>`A role with name '${e}' already exists`,ROLE_NOT_FOUND:"Role not found",ROLE_PERMS_ERROR:"Errors in the role permissions JSON provided",SCHEMA_PERM_ERROR:e=>`Your role does not have permission to view schema metadata for '${e}'`,SCHEMA_TABLE_PERM_ERROR:(e,t)=>`Your role does not have permission to view schema.table metadata for '${e}.${t}'`,SU_ROLE_MISSING_ERROR:"Missing 'super_user' key/value in permission set",SU_CU_ROLE_BOOLEAN_ERROR:e=>`Value for '${e}' permission must be a boolean`,STRUCTURE_USER_ROLE_TYPE_ERROR:e=>`Value for '${e}' permission must be a boolean or Array`,SU_CU_ROLE_NO_PERMS_ALLOWED:e=>`Roles with '${e}' set to true cannot have other permissions set.`,SU_CU_ROLE_COMBINED_ERROR:"Roles cannot have both 'super_user' and 'cluster_user' values included in their permissions set.",TABLE_PERM_MISSING:e=>`Missing table ${e.toUpperCase()} permission`,TABLE_PERM_NOT_BOOLEAN:e=>`Table ${e.toUpperCase()} permission must be a boolean`},Zo={ATTR_NOT_FOUND:(e,t,r)=>`Attribute '${r}' does not exist on '${e}.${t}'`,ATTR_EXISTS_ERR:(e,t,r)=>`Attribute '${r}' already exists in ${e}.${t}'`,DESCRIBE_ALL_ERR:"There was an error during describeAll. Please check the logs and try again.",INVALID_TABLE_ERR:e=>`Invalid table ${JSON.stringify(e)}`,SCHEMA_NOT_FOUND:e=>`Schema '${e}' does not exist`,SCHEMA_EXISTS_ERR:e=>`Schema '${e}' already exists`,TABLE_EXISTS_ERR:(e,t)=>`Table '${t}' already exists in schema '${e}'`,SCHEMA_REQUIRED_ERR:"schema is required",TABLE_NOT_FOUND:(e,t)=>`Table '${e}.${t}' does not exist`,TABLE_REQUIRED_ERR:"table is required"},zo={OUTER_JOIN_TRANSLATION_ERROR:"There was an error translating the final SQL outer join data."},en={ALTER_USER_DUP_ROLES:e=>`Update failed. There are duplicates for the '${e}' role which is not allowed. Update your roles and try again.`,ALTER_USER_ROLE_NOT_FOUND:e=>`Update failed. Requested '${e}' role not found.`,DUP_ROLES_FOUND:e=>`Multiple ${e} roles found. Roles must have unique 'role' value. Please update and try again.`,ROLE_NAME_NOT_FOUND:e=>`${e} role not found`,USER_ALREADY_EXISTS:e=>`User ${e} already exists`,USER_NOT_EXIST:e=>`User ${e} does not exist`},Ht={INVALID_DATE:"Invalid date, must be in ISO-8601 format (YYYY-MM-DD).",SEARCH_CONDITIONS_INVALID_SORT_ATTRIBUTE:e=>`invalid sort attribute '${e}', the attribute must either be the table's hash attribute or an attribute used in conditions.`},Ft={INVALID_IPC_DATA_TYPE:"Invalid IPC event data type, must be an object",MISSING_TYPE:"IPC event missing 'type'",MISSING_MSG:"IPC event missing 'message'",MISSING_ORIGIN:"IPC event message missing 'originator' property",INVALID_EVENT:e=>`IPC server received invalid event type: ${e}`},tn={FUNCTION_STATUS:"Error getting custom function status, check the log for more details",GET_FUNCTIONS:"Error getting custom functions, check the log for more details",GET_FUNCTION:"Error getting custom function, check the log for more details",SET_FUNCTION:"Error setting custom function, check the log for more details",NO_PROJECT:"Project does not exist. Create one using 'add_custom_function_project'",PROJECT_EXISTS:"Project already exists",VALIDATION_ERR:"Error validating request, check the log for more details",NO_FILE:"File does not exist",BAD_FILE_NAME:"File name can only contain alphanumeric, dash and underscore characters",BAD_PROJECT_NAME:"Project name can only contain alphanumeric, dash and underscores characters",BAD_PACKAGE:"Packaged project must be base64-encoded tar file of project directory",DROP_FUNCTION:"Error dropping custom function, check the log for more details",ADD_FUNCTION:"Error adding custom function project, check the log for more details",DROP_FUNCTION_PROJECT:"Error dropping custom function project, check the log for more details",BAD_FILE_PATH:"Filepath must be valid, and contain the name of the tarball you wish to write",NOT_ENABLED:"Custom functions is not enabled, to enable set customFunctions enabled to true in hdb/harperdb-config.yaml file."},rn={CLUSTERING_NOT_ENABLED:"Clustering must be enabled to perform this operation."},_n={...Gt,...xo,...Wo,...Qo,...Xo,...Zo,...zo,...en,...Jo,...Ht,...Ft,...tn,...rn,...jo};bt.exports={CHECK_LOGS_WRAPPER:mt,HDB_ERROR_MSGS:_n,DEFAULT_ERROR_MSGS:ht,DEFAULT_ERROR_RESP:qo,HTTP_STATUS_CODES:Mt,LMDB_ERRORS_ENUM:$o,AUTHENTICATION_ERROR_MSGS:Gt,VALIDATION_ERROR_MSGS:Ht,IPC_ERRORS:Ft}});var Ye=P((Os,Kt)=>{"use strict";var ne=de(),on=te(),nn=y(),Re=class extends Error{constructor(t,r,_,E,s){super(),Error.captureStackTrace(this,Bt),this.http_resp_code=_||ne.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR,this.http_resp_msg=r||(ne.DEFAULT_ERROR_MSGS[_]?ne.DEFAULT_ERROR_MSGS[_]:ne.DEFAULT_ERROR_MSGS[ne.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR]),this.message=t.message?t.message:this.http_resp_msg,this.type=t.name,typeof this.message!="string"&&(this.stack=t.stack),s&&on[E](s)}};n(Re,"HdbError");function Bt(e,t,r,_=nn.LOG_LEVELS.ERROR,E=null,s=!1){if(yt(e))return e;let T=new Re(e,t,r,_,E);return s&&delete T.stack,T}n(Bt,"handleHDBError");function yt(e){return e.__proto__.constructor.name===Re.name}n(yt,"isHDBError");Kt.exports={isHDBError:yt,handleHDBError:Bt,hdb_errors:ne}});var ae=P((Ns,zt)=>{"use strict";var ke=require("path"),En=require("fs-extra"),I=te(),wt=require("fs-extra"),sn=require("truncate-utf8-bytes"),ce=require("os"),Tn=require("net"),Sn=require("recursive-iterator"),l=y(),qt=ft(),Vt=require("papaparse"),Le=require("moment"),{inspect:Rn}=require("util"),vt=require("is-number"),As=require("lodash"),{hdb_errors:fe}=Ye(),Wt=require("util").promisify(setTimeout),cn=100,an=5,On="",An=4,Yt=255,kt={true:!0,false:!1,undefined:null,null:null,NaN:NaN};zt.exports={isEmpty:m,isEmptyOrZeroLength:w,arrayHasEmptyValues:In,arrayHasEmptyOrZeroLengthValues:ln,buildFolderPath:Cn,isBoolean:jt,errorizeMessage:Nn,stripFileExtension:Ln,autoCast:fn,autoCastJSONDeep:qe,removeDir:pn,compareVersions:Dn,isCompatibleDataVersion:gn,escapeRawValue:$t,unescapeValue:Pn,stringifyProps:Mn,valueConverter:mn,timeoutPromise:Gn,isClusterOperation:Fn,getClusterUser:yn,sendTransactionToSocketCluster:bn,checkGlobalSchemaTable:Bn,getHomeDir:Jt,getPropsFilePath:hn,promisifyPapaParse:Kn,removeBOM:Qt,createEventPromise:wn,checkProcessRunning:Vn,checkSchemaTableExist:vn,checkSchemaExists:Xt,checkTableExists:Zt,getStartOfTomorrowInSeconds:Yn,getLimitKey:kn,isObject:dn,isNotEmptyAndHasValue:un,autoCasterIsNumberCheck:xt,backtickASTSchemaItems:qn,isPortTaken:Hn,stopProcess:Wn,createForkArgs:jn,autoCastBoolean:xn,async_set_timeout:Wt,getTableHashAttribute:$n,doesSchemaExist:Jn,doesTableExist:Qn,stringifyObj:Xn,ms_to_time:Zn,PACKAGE_ROOT:l.PACKAGE_ROOT};function Nn(e){return e instanceof Error?e:new Error(e)}n(Nn,"errorizeMessage");function m(e){return e==null}n(m,"isEmpty");function un(e){return!m(e)&&(e||e===0||e===""||jt(e))}n(un,"isNotEmptyAndHasValue");function w(e){return m(e)||e.length===0||e.size===0}n(w,"isEmptyOrZeroLength");function In(e){if(m(e))return!0;for(let t=0;t<e.length;t++)if(m(e[t]))return!0;return!1}n(In,"arrayHasEmptyValues");function ln(e){if(w(e))return!0;for(let t=0;t<e.length;t++)if(w(e[t]))return!0;return!1}n(ln,"arrayHasEmptyOrZeroLengthValues");function Cn(...e){try{return e.join(ke.sep)}catch{console.error(e)}}n(Cn,"buildFolderPath");function jt(e){return m(e)?!1:e===!0||e===!1}n(jt,"isBoolean");function dn(e){return m(e)?!1:typeof e=="object"}n(dn,"isObject");function Ln(e){return w(e)?On:e.slice(0,-An)}n(Ln,"stripFileExtension");function fn(e){return m(e)||e===""||typeof e!="string"?e:kt[e]!==void 0?kt[e]:xt(e)===!0?Number(e):e}n(fn,"autoCast");function Un(e){if(typeof e=="string"&&(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")))try{return JSON.parse(e)}catch{}return e}n(Un,"autoCastJSON");function qe(e){if(e&&typeof e=="object"){if(Array.isArray(e))for(let t=0,r=e.length;t<r;t++){let _=e[t],E=qe(_);E!==_&&(e[t]=E)}else for(let t in e){let r=e[t],_=qe(r);_!==r&&(e[t]=_)}return e}else return Un(e)}n(qe,"autoCastJSONDeep");function xt(e){if(e.startsWith("0.")&&vt(e))return!0;let t=e.toUpperCase().includes("E");return!!((e!=="0"&&e.startsWith("0"))===!1&&t===!1&&vt(e))}n(xt,"autoCasterIsNumberCheck");async function pn(e){if(w(e))throw new Error(`Directory path: ${e} does not exist`);try{await wt.emptyDir(e),await wt.remove(e)}catch(t){throw I.error(`Error removing files in ${e} -- ${t}`),t}}n(pn,"removeDir");function Dn(e,t){if(w(e)){I.info("Invalid current version sent as parameter.");return}if(w(t)){I.info("Invalid upgrade version sent as parameter.");return}let r,_=/(\.0+)+$/,E=e.version?e.version:e,s=t.version?t.version:t,T=E.replace(_,"").split("."),R=s.replace(_,"").split("."),N=Math.min(T.length,R.length);for(let Y=0;Y<N;Y++)if(r=parseInt(T[Y],10)-parseInt(R[Y],10),r)return r;return T.length-R.length}n(Dn,"compareVersions");function gn(e,t,r=!1){let _=e.toString().split("."),E=t.toString().split(".");return _[0]===E[0]&&(!r||_[1]===E[1])}n(gn,"isCompatibleDataVersion");function $t(e){if(m(e))return e;let t=String(e);return t==="."?l.UNICODE_PERIOD:t===".."?l.UNICODE_PERIOD+l.UNICODE_PERIOD:t.replace(l.FORWARD_SLASH_REGEX,l.UNICODE_FORWARD_SLASH)}n($t,"escapeRawValue");function Pn(e){if(m(e))return e;let t=String(e);return t===l.UNICODE_PERIOD?".":t===l.UNICODE_PERIOD+l.UNICODE_PERIOD?"..":String(e).replace(l.ESCAPED_FORWARD_SLASH_REGEX,"/")}n(Pn,"unescapeValue");function Mn(e,t){if(m(e))return I.info("Properties object is null"),"";let r="";return e.each(function(_,E){try{if(t&&t[_]){let s=t[_];for(let T of s)r+=";"+T+ce.EOL}!w(_)&&_[0]===";"?r+=" "+_+E+ce.EOL:w(_)||(r+=_+"="+E+ce.EOL)}catch{I.error(`Found bad property during upgrade with key ${_} and value: ${E}`)}}),r}n(Mn,"stringifyProps");function mn(e){let t;try{t=typeof e=="object"?JSON.stringify(e):e}catch(E){I.error(E),t=e}let r=String($t(t)),_=Buffer.byteLength(r)>Yt?sn(r,Yt)+"/blob":r;return{value:t,value_stripped:r,value_path:_}}n(mn,"valueConverter");function Jt(){let e;try{e=ce.homedir()}catch{e=process.env.HOME}return e||(e="~/"),e}n(Jt,"getHomeDir");function hn(){let e=ke.join(Jt(),l.HDB_HOME_DIR_NAME,l.BOOT_PROPS_FILE_NAME);return En.existsSync(e)||(e=ke.join(__dirname,"../","hdb_boot_properties.file")),e}n(hn,"getPropsFilePath");function Gn(e,t){let r,_;return _=new Promise(function(E){r=setTimeout(function(){E(t)},e)}),{promise:_,cancel:function(){clearTimeout(r)}}}n(Gn,"timeoutPromise");async function Hn(e){if(!e)throw new Error("Invalid port passed as parameter");return new Promise((t,r)=>{let _=Tn.createServer().once("error",E=>{E.code==="EADDRINUSE"?t(!0):r(E)}).once("listening",()=>_.once("close",()=>t(!1)).close()).listen(e)})}n(Hn,"isPortTaken");function Fn(e){try{return l.CLUSTER_OPERATIONS[e.toLowerCase()]!==void 0}catch(t){I.error(`Error checking operation against cluster ops ${t}`)}return!1}n(Fn,"isClusterOperation");function bn(e,t,r){if(global.hdb_socket_client!==void 0){I.trace(`Sending transaction to channel: ${e}`);let{hdb_user:_,hdb_auth_header:E,...s}=t;s.__originator||(s.__originator={}),s.__transacted=!0,r&&(s.__originator[r]=l.ORIGINATOR_SET_VALUE),global.hdb_socket_client.publish(e,s)}}n(bn,"sendTransactionToSocketCluster");function Bn(e,t){if(!global.hdb_schema[e])return fe.HDB_ERROR_MSGS.SCHEMA_NOT_FOUND(e);if(!global.hdb_schema[e]||!global.hdb_schema[e][t])return fe.HDB_ERROR_MSGS.TABLE_NOT_FOUND(e,t)}n(Bn,"checkGlobalSchemaTable");function yn(e,t){if(m(t)){I.warn("No CLUSTERING_USER defined, clustering disabled");return}if(m(e)||w(e)){I.warn("No users to search.");return}let r;try{let _=e.get(t);_&&_.role.permission.cluster_user===!0&&_.active===!0&&(r=_)}catch(_){I.error(`unable to find cluster_user due to: ${_.message}`);return}if(r===void 0){I.warn(`CLUSTERING_USER: ${t} not found or is not active.`);return}return r}n(yn,"getClusterUser");function Kn(){Vt.parsePromise=function(e,t){return new Promise(function(r,_){Vt.parse(e,{header:!0,transformHeader:Qt,chunk:t.bind(null,_),skipEmptyLines:!0,dynamicTyping:!0,error:_,complete:r})})}}n(Kn,"promisifyPapaParse");function Qt(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return e.charCodeAt(0)===65279?e.slice(1):e}n(Qt,"removeBOM");function wn(e,t,r){return new Promise(_=>{t.once(e,E=>{let s=r;I.info(`Got cluster status event response: ${Rn(E)}`);try{s.cancel()}catch{I.error("Error trying to cancel timeout.")}_(E)})})}n(wn,"createEventPromise");async function Vn(e){let t=!0,r=0;do await Wt(cn*r++),(await qt.findPs(e)).length>0&&(t=!1);while(t&&r<an);if(t)throw new Error(`process ${e} was not started`)}n(Vn,"checkProcessRunning");function vn(e,t){let r=Xt(e);if(r)return r;let _=Zt(e,t);if(_)return _}n(vn,"checkSchemaTableExist");function Xt(e){if(!global.hdb_schema[e])return fe.HDB_ERROR_MSGS.SCHEMA_NOT_FOUND(e)}n(Xt,"checkSchemaExists");function Zt(e,t){if(!global.hdb_schema[e][t])return fe.HDB_ERROR_MSGS.TABLE_NOT_FOUND(e,t)}n(Zt,"checkTableExists");function Yn(){let e=Le().utc().add(1,l.MOMENT_DAYS_TAG).startOf(l.MOMENT_DAYS_TAG).unix(),t=Le().utc().unix();return e-t}n(Yn,"getStartOfTomorrowInSeconds");function kn(){return Le().utc().format("DD-MM-YYYY")}n(kn,"getLimitKey");function qn(e){try{let t=new Sn(e);for(let{node:r}of t)r&&(r.columnid&&typeof r.columnid!="string"&&(r.columnid=r.columnid.toString()),r.columnid&&!r.columnid.startsWith("`")&&(r.columnid_orig=r.columnid,r.columnid=`\`${r.columnid}\``),r.tableid&&!r.tableid.startsWith("`")&&(r.tableid_orig=r.tableid,r.tableid=`\`${r.tableid}\``),r.databaseid&&!r.databaseid.startsWith("`")&&(r.databaseid_orig=r.databaseid,r.databaseid=`\`${r.databaseid}\``),r.as&&typeof r.as=="string"&&!r.as.startsWith("[")&&(r.as_orig=r.as,r.as=`\`${r.as}\``))}catch(t){I.error("Got an error back ticking items."),I.error(t)}}n(qn,"backtickASTSchemaItems");async function Wn(e){let t=ce.userInfo();(await qt.findPs(e)).forEach(_=>{(t.uid==0||_.uid==t.uid)&&(process.kill(_.pid),I.trace(`Following process was killed by stopProcess: ${_.cmd}`))})}n(Wn,"stopProcess");function jn(e){return[e]}n(jn,"createForkArgs");function xn(e){return e===!0||typeof e=="string"&&e.toLowerCase()==="true"}n(xn,"autoCastBoolean");function $n(e,t){return global.hdb_schema?.[e]?.[t]?.hash_attribute}n($n,"getTableHashAttribute");function Jn(e){return global?.hdb_schema?.[e]!==void 0}n(Jn,"doesSchemaExist");function Qn(e,t){return global?.hdb_schema?.[e]?.[t]!==void 0}n(Qn,"doesTableExist");function Xn(e){try{return JSON.stringify(e)}catch{return e}}n(Xn,"stringifyObj");function Zn(e){let t=Le.duration(e),r=t.seconds()>0?t.seconds()+"s":"",_=t.minutes()>0?t.minutes()+"m ":"",E=t.hours()>0?t.hours()+"h ":"",s=t.days()>0?t.days()+"d ":"";return(t.years()>0?t.years()+"y ":"")+s+E+_+r}n(Zn,"ms_to_time")});var tr=P((us,er)=>{"use strict";var zn={key:"-----BEGIN RSA PRIVATE KEY-----\rMIIEowIBAAKCAQEArBFJQRfFiJku/KwhV1Ssp7cX61vvuKmd4Rp6A9jB2QLgx8nj\r/+Xhp2hPRkISnOA8BuAxr4dMD9syGJwX4kNy9mbZ5Q0fWZCiEGBpVcU1J+k+N5K4\rSuZ2SqgxeN2IN2RLzt3GyQY4imcdHgNv7aHoXUrEwBx0MeYEw3IIDXtrYKCR2D8I\rvWBfwMUgWa24G8lpWILWA5hd9srRz9NxlAiHSjhbgT7B0xruEpHRCHSyKjvaIJVt\rWBR+amejYsAKVrD/hgrqjsA1123Y6++YqvU6vwg64xhS2kz5r3dkNKhvwbWgpZdI\rIaRvsiB77f4kLGo0vi8RFgJ1ZRjGg3RRK2w1LQIDAQABAoIBAQCEOmh78EOpnGZC\rYBjjHrvrysVD5gvLcfVUtl8Ls7gMB60re1eOIF+PoZZCHKZnDd6zPfiQtj1adg0C\rYnnsM/8VoaZS4gm0b3RLd3ubIQifWhuo40RissY2yxfxlPSH9LhZCY8ojnJG0cTL\resK579E8WCfopjUY33XLqEbN7Ylv39J+DSqInjqV3efJZUa+HqUJ98VxxzodcKMD\rP3bwUU4gHoSSp4pAsOFH5sQhaIWH1IcNjrAwpee2cJQuh4G157RRIuuUpagtaEG/\rXJIiAyBguJyu3JQFnIBQF01N5+omJgXYJ1L0m54543/iIRThmF3zDCDgCyUzmOk+\rH6As9fv1AoGBANOpOtOZLSAScjGsgJamT3ceJ2wCa86g2j8Oxu8lJUmUp5s3tA0v\rBFW5O3S4KR1EXwkLMBUMrfFM8YvzHWxsXBI6XV8azGLvyqPHxr65OhmpGYkGZMXu\rn9okgjkqlewnY2I073gvyK7ppX51UL5y9fF1vlsk+UlW+Rgx/vMHbdcjAoGBANAc\rxRUsxs4QJpbS4zD3JOkHjr24a97TrS3kCybAHUMpR2NrEHPZw9zex0/aphOJUHfL\rIMkOZdpfDqMfxWy4FAEmqBEMkO2SB+h0Wp4P+qp81ax4vGFiB0cD3wtixr11U1tt\rlZ/ZTdv4VDpDFNK1KaplhTDeyuCjeYfS3/GJia9vAoGAcOsAgjBevZR5rXx84WH6\rVO8WUu37u7FenXNxt9VWTinrPMh72uixZFY8nOk+rely1e1NCn3IMko9Ns9NbDFm\r8SaH95vhXArXTYbfxZIlp9jp0YtCqcHDL+p4Oq04bFMbFyJseu7rHj1x18QYfnHw\rOY/6LL/N6k1m+Hx7qgXVmIcCgYB/w0nTCBw84XlvWqSTqQaF8VfWbWP79mP5KmkW\rLxdH5g2noVEGbohqDnK6OXd/wusdwByukiJBf94Skyy25AOT+VFwthA7aU1ljhkb\rtJ+lDuJ28eBkwLPLCzthWBC+u0qjdJFJAzVjd/7tjcU43nNn4s90AzL12iaAFhvZ\rwyA+DQKBgGc/4cdyGJ3YkcA8150gQBawgJZ7q8V1JND87ggWA8wnK3cHn7rMZQl2\r3emDp9HEFXFex5dbGDDqZFAoesZCDxjknIn9oNfW4PvaWS8q7b6ZKLZG1p03Pu7/\rtYaD0kPbo0kysfFT/co+NgHbdykvIyboomfGdNLTUjYuy6lpwpvs\r-----END RSA PRIVATE KEY-----\r".replace(/\r/g,String.fromCharCode(13,10)),cert:"-----BEGIN CERTIFICATE-----\rMIIDXDCCAkSgAwIBAgIFNTE4MzQwDQYJKoZIhvcNAQELBQAwXTEXMBUGA1UEAxMO\rSGFycGVyREIsIEluYy4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDTzEPMA0GA1UE\rBxMGRGVudmVyMRcwFQYDVQQKEw5IYXJwZXJEQiwgSW5jLjAeFw0yMjAzMTEyMzAz\rNDlaFw0yNzAzMTAyMzAzNDlaMF0xFzAVBgNVBAMTDkhhcnBlckRCLCBJbmMuMQsw\rCQYDVQQGEwJVUzELMAkGA1UECBMCQ08xDzANBgNVBAcTBkRlbnZlcjEXMBUGA1UE\rChMOSGFycGVyREIsIEluYy4wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\rAQCsEUlBF8WImS78rCFXVKyntxfrW++4qZ3hGnoD2MHZAuDHyeP/5eGnaE9GQhKc\r4DwG4DGvh0wP2zIYnBfiQ3L2ZtnlDR9ZkKIQYGlVxTUn6T43krhK5nZKqDF43Yg3\rZEvO3cbJBjiKZx0eA2/toehdSsTAHHQx5gTDcggNe2tgoJHYPwi9YF/AxSBZrbgb\ryWlYgtYDmF32ytHP03GUCIdKOFuBPsHTGu4SkdEIdLIqO9oglW1YFH5qZ6NiwApW\rsP+GCuqOwDXXbdjr75iq9Tq/CDrjGFLaTPmvd2Q0qG/BtaCll0ghpG+yIHvt/iQs\rajS+LxEWAnVlGMaDdFErbDUtAgMBAAGjIzAhMA8GA1UdEwEB/wQFMAMBAf8wDgYD\rVR0PAQH/BAQDAgIEMA0GCSqGSIb3DQEBCwUAA4IBAQASR4YW/rPK7PNArHVe9zzM\rb0rKNX/2T9/0nybRhmE/+hdlSgliTAeebmwkUS2APckmekYt/q2ZY2NS65Fo/jjp\rG8TJrtcF4h+ylVqUp0ZXQLFtIsr7r2JZA7hJ6njW6G4DHSZ0gxtECLi4CBlTjzm5\rNmnmIDObvGRTuqmcdAZmXeObbta/He2XIzietukPAYX062pNM+G5XT5UM1eG/Vlp\rN86vjhpyI+ffKy+C60SJqxmKM3ydgN7oLscE7+2wLPN25XqN4W99OwGsp5dTdu/f\r5lPtFayXdJ55e/sNQKmGN+UGLrL05c2MWgjb8U/LFilnupUianceoeSERZmVjzKX\r-----END CERTIFICATE-----\r".replace(/\r/g,String.fromCharCode(13,10))},eE="certificate.pem",tE="privateKey.pem",rE="ca.pem";er.exports={CERTIFICATE_VALUES:zn,CERTIFICATE_PEM_NAME:eE,PRIVATEKEY_PEM_NAME:tE,CA_PEM_NAME:rE}});var _r=P((Is,rr)=>{"use strict";var p=require("validate.js");p.validators.type=function(e,t,r,_){return e===null||typeof e>"u"||p.validators.type.checks[t](e)?null:` must be a '${t}' value`};p.validators.type.checks={Object:function(e){return p.isObject(e)&&!p.isArray(e)},Array:p.isArray,Integer:p.isInteger,Number:p.isNumber,String:p.isString,Date:p.isDate,Boolean:function(e){return typeof e=="boolean"}};p.validators.hasValidFileExt=function(e,t){return!p.isString(e)||e===""||t.filter(r=>e.endsWith(r)).length>0?null:`must include one of the following valid file extensions - '${t.join("', '")}'`};rr.exports={validateObject:_E,validateObjectAsync:oE,validateBySchema:nE};function _E(e,t){if(!e||!t)return new Error("validateObject parameters were null");let r=p(e,t,{format:"flat"});return r?new Error(r):null}n(_E,"validateObject");async function oE(e,t){if(!e||!t)return new Error("validateObject parameters were null");try{await p.async(e,t,{format:"flat"})}catch(r){let _=r.join(",");return new Error(_)}return null}n(oE,"validateObjectAsync");function nE(e,t){let r=t.validate(e,{allowUnknown:!0,abortEarly:!1,errors:{wrap:{label:"'"}}});if(r.error)return new Error(r.error.message)}n(nE,"validateBySchema")});var Er=P((ls,nr)=>{"use strict";var EE=require("fs-extra"),c=require("joi"),sE=require("os"),{boolean:C,string:W,number:V,array:We}=c.types(),b=require("path"),iE=te(),Ue=ae(),j=tr(),TE=_r(),q="keys",SE=j.CERTIFICATE_PEM_NAME,RE=j.PRIVATEKEY_PEM_NAME,cE=j.CA_PEM_NAME,aE=j.CERTIFICATE_PEM_NAME,OE=j.PRIVATEKEY_PEM_NAME,AE=j.CA_PEM_NAME,NE=j.CERTIFICATE_PEM_NAME,uE=j.PRIVATEKEY_PEM_NAME,IE=j.CA_PEM_NAME,lE="log",CE="custom_functions",dE="Invalid logging.rotation.maxSize unit. Available units are G, M or K",LE="Invalid logging.rotation.maxSize value. Value should be a number followed by unit e.g. '10M'",fE="rootPath config parameter is undefined",UE="clustering.enabled config parameter is undefined",Q=V.min(0).required(),pe=We.items({host:W.required(),port:Q}).empty(null),D;nr.exports={configValidator:pE,routesValidator:mE,route_constraints:pe};function pE(e){if(D=e.rootPath,Ue.isEmpty(D))throw fE;let t=C.required(),r=c.valid("production","development").required(),_=V.min(1).max(1e3).empty(null).default(ME),E=W.pattern(/^[\\\/]$|([\\\/][a-zA-Z_0-9\:-]+)+$/,"directory path").empty(null).default(or),s=c.custom(gE).messages({"any.custom":"{:#label} {:#error}"}).empty(null).default(or),T=W.pattern(/^[^\s.,*>]+$/).messages({"string.pattern.base":"{:#label} invalid, must not contain ., * or >"}).empty(null),R=e.clustering?.enabled;if(Ue.isEmpty(R))throw UE;let N;return R===!0?N=c.object({enabled:t,hubServer:c.object({cluster:c.object({name:c.required().empty(null),network:c.object({port:Q,routes:pe}).required()}).required(),leafNodes:c.object({network:c.object({port:Q}).required()}).required(),network:c.object({port:Q}).required()}).required(),leafServer:c.object({network:c.object({port:Q,routes:pe}).required()}).required(),nodeName:T,tls:c.object({certificate:s,certificateAuthority:s,privateKey:s,insecure:C.required()}),user:c.string().required()}).required():N=c.object({enabled:t,tls:c.object({certificate:s,certificateAuthority:s,privateKey:s,insecure:C.required()})}).required(),c.object({clustering:N,customFunctions:c.object({enabled:t,network:c.object({cors:C.required(),corsAccessList:We.required(),headersTimeout:V.min(1).required(),https:C.required(),keepAliveTimeout:V.min(1).required(),port:Q,timeout:V.min(1).required()}),nodeEnv:r,root:E,tls:c.object({certificate:s,certificateAuthority:s,privateKey:s})}).required(),ipc:c.object({network:c.object({port:Q})}).required(),localStudio:c.object({enabled:t}).required(),logging:c.object({file:C.required(),level:c.valid("notify","fatal","error","warn","info","debug","trace"),rotation:c.object({compress:C.required(),dateFormat:W.required(),maxSize:W.custom(PE).required(),retain:V.min(0).required(),rotate:C.required(),rotateInterval:W.required(),rotateModule:C.required(),timezone:W.required(),workerInterval:V.min(1).required()}).required(),root:E,stdStreams:C.required(),auditLog:C.required()}).required(),operationsApi:c.object({authentication:c.object({operationTokenTimeout:c.required(),refreshTokenTimeout:c.required()}).required(),foreground:C.required(),network:c.object({cors:C.required(),corsAccessList:We.required(),headersTimeout:V.min(1).required(),https:C.required(),keepAliveTimeout:V.min(1).required(),port:Q,timeout:V.min(1).required()}).required(),nodeEnv:r,tls:c.object({certificate:s,certificateAuthority:s,privateKey:s})}).required(),rootPath:W.pattern(/^[\\\/]$|([\\\/][a-zA-Z_0-9\:-]+)+$/,"directory path").required(),http:c.object({threads:_}).required(),storage:c.object({writeAsync:C.required(),overlappingSync:C.optional()}).required()}).validate(e,{allowUnknown:!0,abortEarly:!1,errors:{wrap:{label:"'"}}})}n(pE,"configValidator");function DE(e){return EE.existsSync(e)?null:`Specified path ${e} does not exist.`}n(DE,"doesPathExist");function gE(e,t){c.assert(e,W.pattern(/^[\\\/]$|([\\\/][a-zA-Z_0-9\:-]+)+\.pem+$/).messages({"string.pattern.base":"must be a valid directory path and specify a .pem file"}));let r=DE(e);if(r)return t.message(r)}n(gE,"validatePemFile");function PE(e,t){let r=e.slice(-1);if(r!=="G"&&r!=="M"&&r!=="K")return t.message(dE);let _=e.slice(0,-1);if(isNaN(parseInt(_)))return t.message(LE)}n(PE,"validateRotationMaxSize");function ME(e,t){let r=t.state.path.join("."),_=sE.cpus().length,E=_-1;return E===1&&_===2&&(E=_),iE.info(`Detected ${_} cores on this machine, defaulting ${r} to ${E}`),E}n(ME,"setDefaultThreads");function or(e,t){if(!Ue.isEmpty(t.original))return t.original;let r=t.state.path.join(".");if(Ue.isEmpty(D))throw new Error(`Error setting default root for: ${r}. HDB root is not defined`);switch(r){case"customFunctions.root":return b.join(D,CE);case"logging.root":return b.join(D,lE);case"operationsApi.tls.certificate":return b.join(D,q,SE);case"operationsApi.tls.privateKey":return b.join(D,q,RE);case"operationsApi.tls.certificateAuthority":return b.join(D,q,cE);case"customFunctions.tls.certificate":return b.join(D,q,aE);case"customFunctions.tls.privateKey":return b.join(D,q,OE);case"customFunctions.tls.certificateAuthority":return b.join(D,q,AE);case"clustering.tls.certificate":return b.join(D,q,NE);case"clustering.tls.privateKey":return b.join(D,q,uE);case"clustering.tls.certificateAuthority":return b.join(D,q,IE);default:throw new Error(`Error setting default root for config parameter: ${r}. Unrecognized config parameter`)}}n(or,"setDefaultRoot");function mE(e){let t=c.object({routes:pe});return TE.validateBySchema({routes:e},t)}n(mE,"routesValidator")});var Or=P((Cs,ar)=>{"use strict";var A=y(),h=ae(),L=te(),{configValidator:hE,routesValidator:sr}=Er(),B=require("fs-extra"),GE=require("yaml"),Ee=require("path"),HE=require("is-number"),Pe=require("properties-reader"),FE=require("lodash"),{handleHDBError:bE}=Ye(),{HTTP_STATUS_CODES:BE,HDB_ERROR_MSGS:De}=de(),{PACKAGE_ROOT:yE}=y(),KE="Unable to get config value because config is uninitialized",wE="Config successfully initialized",VE="Error backing up config file",vE="Empty parameter sent to getConfigValue",ir=Ee.join(yE,"config","yaml",A.HDB_DEFAULT_CONFIG_FILE),YE="Configuration successfully set. You must restart HarperDB for new config settings to take effect.",ge,g;ar.exports={createConfigFile:kE,getDefaultConfig:qE,getConfigValue:Tr,initConfig:Sr,flattenConfig:re,updateConfigValue:Rr,updateConfigObject:WE,getConfiguration:jE,setConfiguration:xE,readConfigFile:$e,getClusteringRoutes:$E,initOldConfig:cr,getConfigFromFile:JE};function kE(e){let t=se(ir);ge=re(t.toJSON());for(let s in e){let T=A.CONFIG_PARAM_MAP[s.toLowerCase()];if(T!==void 0){let R=T.split("_"),N=je(T,e[s]);try{t.setIn([...R],N)}catch(Y){L.error(Y)}}}xe(t);let r=t.toJSON();g=re(r);let _=t.getIn(["rootPath"]),E=Ee.join(_,A.HDB_CONFIG_FILE);B.createFileSync(E),B.writeFileSync(E,String(t)),L.trace(`Config file written to ${E}`)}n(kE,"createConfigFile");function qE(e){if(ge===void 0){let r=se(ir);ge=re(r.toJSON())}let t=A.CONFIG_PARAM_MAP[e.toLowerCase()];if(t!==void 0)return ge[t.toLowerCase()]}n(qE,"getDefaultConfig");function Tr(e){if(h.isEmpty(e)){L.error(vE);return}if(g===void 0){L.trace(KE);return}let t=A.CONFIG_PARAM_MAP[e.toLowerCase()];if(t!==void 0)return g[t.toLowerCase()]}n(Tr,"getConfigValue");function Sr(e=!1){if(g===void 0||e){let t=h.getPropsFilePath();try{B.accessSync(t,B.constants.F_OK|B.constants.R_OK)}catch(T){throw L.error(T),new Error(`HarperDB properties file at path ${t} does not exist`)}let _=Pe(t).get(A.HDB_SETTINGS_NAMES.SETTINGS_PATH_KEY),E;if(_.includes("config/settings.js"))try{cr(_);return}catch(T){if(T.code!==A.NODE_ERROR_CODES.ENOENT)throw T}try{E=se(_)}catch(T){if(T.code===A.NODE_ERROR_CODES.ENOENT){L.trace(`HarperDB config file not found at ${_}.
|
|
4
|
+
`).slice(1)){E=E.trim();let[s]=E.split(" ",1),T=E.slice(s.length+1).trim();t[s]===void 0&&(t[s]={}),t[s][r]=T}}))}catch(r){throw r}return Object.entries(t).filter(([,r])=>r.comm&&r.args&&r.ppid&&r.uid&&r["%cpu"]&&r["%mem"]&&r.args.includes(e)).map(([r,_])=>({pid:Number.parseInt(r,10),name:Go.basename(_.comm),cmd:_.args,ppid:Number.parseInt(_.ppid,10),uid:Number.parseInt(_.uid,10),cpu:Number.parseFloat(_["%cpu"]),memory:Number.parseFloat(_["%mem"])}))}n(Bo,"findPs")});var Dt=P((cs,pt)=>{"use strict";var yo="__dbis__",Ko="__environment_name__",wo="__dbi_defintion__",Vo={EQUALS:"equals",STARTS_WITH:"startsWith",_STARTS_WITH:"starts_with",ENDS_WITH:"endsWith",_ENDS_WITH:"ends_with",CONTAINS:"contains",SEARCH_ALL:"searchAll",SEARCH_ALL_TO_MAP:"searchAllToMap",BATCH_SEARCH_BY_HASH:"batchSearchByHash",BATCH_SEARCH_BY_HASH_TO_MAP:"batchSearchByHashToMap",GREATER_THAN:"greaterThan",_GREATER_THAN:"greater_than",GREATER_THAN_EQUAL:"greaterThanEqual",_GREATER_THAN_EQUAL:"greater_than_equal",LESS_THAN:"lessThan",_LESS_THAN:"less_than",LESS_THAN_EQUAL:"lessThanEqual",_LESS_THAN_EQUAL:"less_than_equal",BETWEEN:"between"},vo=["__createdtime__","__updatedtime__"],Yo="\uFFFF",Ut={TIMESTAMP:"timestamp",HASH_VALUE:"hash_value",USER_NAME:"user_name"},ko=Object.values(Ut);pt.exports={INTERNAL_DBIS_NAME:yo,DBI_DEFINITION_NAME:wo,SEARCH_TYPES:Vo,TIMESTAMP_NAMES:vo,MAX_SEARCH_KEY_LENGTH:256,ENVIRONMENT_NAME_KEY:Ko,TRANSACTIONS_DBI_NAMES_ENUM:Ut,TRANSACTIONS_DBIS:ko,OVERFLOW_MARKER:Yo}});var de=P((as,bt)=>{"use strict";var gt=y(),Pt=Dt(),Mt={CONTINUE:100,OK:200,CREATED:201,BAD_REQUEST:400,UNAUTHORIZED:401,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,REQUEST_TIMEOUT:408,CONFLICT:409,TOO_MANY_REQUESTS:429,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,INSUFFICIENT_STORAGE:507,NETWORK_AUTHENTICATION_REQUIRED:511},mt=n(e=>`${e} Check logs and try again.`,"CHECK_LOGS_WRAPPER"),ht={500:mt("There was an error processing your request."),400:"Invalid request"},qo=ht[Mt.INTERNAL_SERVER_ERROR],Wo={OP_NOT_SUPPORTED_FOR_FS:e=>`${e} is not available for this instance because it uses the File System data store.`,MISSING_VALUE:e=>`${e} is missing.`,INVALID_VALUE:e=>`${e} is invalid.`,NOT_FOUND:e=>`${e} not found.`},jo={CONFIG_VALIDATION:e=>`HarperDB config file validation error: ${e}`},xo={DEFAULT_BULK_LOAD_ERR:"There was an error during your bulk load into HarperDB.",DOWNLOAD_FILE_ERR:e=>`There was an error downloading '${e}'.`,INSERT_JSON_ERR:"There was an error inserting the downloaded JSON data.",INSERT_CSV_ERR:"There was an error inserting the downloaded CSV data.",INVALID_ACTION_PARAM_ERR:e=>`Bulk load operation failed - ${e} is not a valid 'action' parameter`,INVALID_FILE_EXT_ERR:e=>`Error selecting correct parser - valid file type not found in json - ${e}`,MAX_FILE_SIZE_ERR:(e,t)=>`File size is ${e} bytes, which exceeded the maximum size allowed of: ${t} bytes`,PAPA_PARSE_ERR:"There was an error parsing the downloaded CSV data.",S3_DOWNLOAD_ERR:e=>`There was an error downloading '${e}' from AWS.`,WRITE_TEMP_FILE_ERR:"Error writing temporary file to storage"},$o={BASE_PATH_REQUIRED:"base_path is required",DESTINATION_PATH_REQUIRED:"destination_path is required",ENV_NAME_REQUIRED:"env_name is required",INVALID_BASE_PATH:"invalid base_path",INVALID_DESTINATION_PATH:"invalid destination_path",INVALID_ENVIRONMENT:"invalid environment",ENV_REQUIRED:"env is required",DBI_NAME_REQUIRED:"dbi_name is required",DBI_DOES_NOT_EXIST:"dbi does not exist",HASH_ATTRIBUTE_REQUIRED:"hash_attribute is required",ID_REQUIRED:"id is required",IDS_REQUIRED:"ids is required",IDS_MUST_BE_ARRAY:"ids must be an array",FETCH_ATTRIBUTES_REQUIRED:"fetch_attributes is required",FETCH_ATTRIBUTES_MUST_BE_ARRAY:"fetch_attributes must be an array",ATTRIBUTE_REQUIRED:"attribute is required",SEARCH_VALUE_REQUIRED:"search_value is required",SEARCH_VALUE_TOO_LARGE:"search_value is too long",WRITE_ATTRIBUTES_REQUIRED:"write_attributes is required",WRITE_ATTRIBUTES_MUST_BE_ARRAY:"write_attributes must be an array",RECORDS_REQUIRED:"records is required",RECORDS_MUST_BE_ARRAY:"records must be an array",CANNOT_CREATE_INTERNAL_DBIS_NAME:`cannot create a dbi named ${Pt.INTERNAL_DBIS_NAME}`,CANNOT_DROP_INTERNAL_DBIS_NAME:`cannot drop a dbi named ${Pt.INTERNAL_DBIS_NAME}`,START_VALUE_REQUIRED:"start_value is required",END_VALUE_REQUIRED:"end_value is required",CANNOT_COMPARE_STRING_TO_NUMERIC_KEYS:"cannot compare a string to numeric keys",END_VALUE_MUST_BE_GREATER_THAN_START_VALUE:"end_value must be greater than or equal to start_value",UNKNOWN_SEARCH_TYPE:"unknown search type",CANNOT_DROP_TABLE_HASH_ATTRIBUTE:"cannot drop a table's hash attribute"},Jo={ATTR_NAME_LENGTH_ERR:e=>`transaction aborted due to attribute name ${e} being too long. Attribute names cannot be longer than ${gt.INSERT_MODULE_ENUM.MAX_CHARACTER_SIZE} bytes.`,ATTR_NAME_NULLISH_ERR:"transaction aborted due to record(s) with an attribute name that is null, undefined or empty string",HASH_VAL_LENGTH_ERR:`transaction aborted due to record(s) with a hash value that exceeds ${gt.INSERT_MODULE_ENUM.MAX_CHARACTER_SIZE} bytes, check log for more info`,INVALID_FORWARD_SLASH_IN_HASH_ERR:"transaction aborted due to record(s) with a hash value that contains a forward slash, check log for more info",RECORD_MISSING_HASH_ERR:"transaction aborted due to record(s) with no hash value, check log for more info"},Gt={GENERIC_AUTH_FAIL:"Login failed",USER_INACTIVE:"Cannot complete request: User is inactive",INVALID_TOKEN:"invalid token",NO_ENCRYPTION_KEYS:"unable to generate JWT as there are no encryption keys. please contact your administrator",INVALID_CREDENTIALS:"invalid credentials",PASSWORD_REQUIRED:"password is required",USERNAME_REQUIRED:"username is required",REFRESH_TOKEN_REQUIRED:"refresh_token is required",INVALID_AUTH_OBJECT:"invalid auth_object",INVALID_BODY:"invalid body",TOKEN_EXPIRED:"token expired",REFRESH_TOKEN_SAVE_FAILED:"unable to store refresh_token"},Qo={DEFAULT_INVALID_REQUEST:"Invalid request",OP_AUTH_PERMS_ERROR:"This operation is not authorized due to role restrictions and/or invalid schema items",OP_IS_SU_ONLY:e=>`Operation '${e}' is restricted to 'super_user' roles`,OP_NOT_FOUND:e=>`Operation '${e}' not found`,SYSTEM_TIMESTAMP_PERMS_ERR:"Internal timestamp attributes - '__createdtime_' and '__updatedtime__' - cannot be inserted to or updated by HDB users.",UNKNOWN_OP_AUTH_ERROR:(e,t,r)=>`There was an error authorizing ${e} op on table '${t}.${r}'`,USER_HAS_NO_PERMS:e=>`User ${e} has no role or permissions. Please assign the user a valid role.`,DROP_SYSTEM:"The 'system' schema, tables and records are used internally by HarperDB and cannot be updated or removed."},Xo={ATTR_PERM_MISSING:(e,t)=>`${e.toUpperCase()} attribute permission missing for '${t}'`,ATTR_PERM_MISSING_NAME:"Permission object in 'attribute_permission' missing an 'attribute_name'",ATTR_PERM_NOT_BOOLEAN:(e,t)=>`${e.toUpperCase()} attribute permission for '${t}' must be a boolean`,ATTR_PERMS_ARRAY_MISSING:"Missing 'attribute_permissions' array",ATTR_PERMS_NOT_ARRAY:"Value for 'attribute_permissions' must be an array",INVALID_ATTRIBUTE_IN_PERMS:e=>`Invalid attribute '${e}' in 'attribute_permissions'`,INVALID_PERM_KEY:e=>`Invalid table permission key value '${e}'`,INVALID_ATTR_PERM_KEY:e=>`Invalid attribute permission key value '${e}'`,INVALID_ROLE_JSON_KEYS:e=>`Invalid ${e.length>1?"keys":"key"} in JSON body - '${e.join("', '")}'`,MISMATCHED_TABLE_ATTR_PERMS:e=>`You have a conflict with TABLE permissions for '${e}' being false and ATTRIBUTE permissions being true`,OUTDATED_PERMS_TRANSLATION_ERROR:"This instance was recently upgraded and uses our new role permissions structure. Please login to this instance in HarperDB Studio, go to 'Roles', and click 'Update Role Permission' for all standard roles to migrate them to the new structure.",ROLE_ALREADY_EXISTS:e=>`A role with name '${e}' already exists`,ROLE_NOT_FOUND:"Role not found",ROLE_PERMS_ERROR:"Errors in the role permissions JSON provided",SCHEMA_PERM_ERROR:e=>`Your role does not have permission to view schema metadata for '${e}'`,SCHEMA_TABLE_PERM_ERROR:(e,t)=>`Your role does not have permission to view schema.table metadata for '${e}.${t}'`,SU_ROLE_MISSING_ERROR:"Missing 'super_user' key/value in permission set",SU_CU_ROLE_BOOLEAN_ERROR:e=>`Value for '${e}' permission must be a boolean`,STRUCTURE_USER_ROLE_TYPE_ERROR:e=>`Value for '${e}' permission must be a boolean or Array`,SU_CU_ROLE_NO_PERMS_ALLOWED:e=>`Roles with '${e}' set to true cannot have other permissions set.`,SU_CU_ROLE_COMBINED_ERROR:"Roles cannot have both 'super_user' and 'cluster_user' values included in their permissions set.",TABLE_PERM_MISSING:e=>`Missing table ${e.toUpperCase()} permission`,TABLE_PERM_NOT_BOOLEAN:e=>`Table ${e.toUpperCase()} permission must be a boolean`},Zo={ATTR_NOT_FOUND:(e,t,r)=>`Attribute '${r}' does not exist on '${e}.${t}'`,ATTR_EXISTS_ERR:(e,t,r)=>`Attribute '${r}' already exists in ${e}.${t}'`,DESCRIBE_ALL_ERR:"There was an error during describeAll. Please check the logs and try again.",INVALID_TABLE_ERR:e=>`Invalid table ${JSON.stringify(e)}`,SCHEMA_NOT_FOUND:e=>`Schema '${e}' does not exist`,SCHEMA_EXISTS_ERR:e=>`Schema '${e}' already exists`,TABLE_EXISTS_ERR:(e,t)=>`Table '${t}' already exists in schema '${e}'`,SCHEMA_REQUIRED_ERR:"schema is required",TABLE_NOT_FOUND:(e,t)=>`Table '${e}.${t}' does not exist`,TABLE_REQUIRED_ERR:"table is required"},zo={OUTER_JOIN_TRANSLATION_ERROR:"There was an error translating the final SQL outer join data."},en={ALTER_USER_DUP_ROLES:e=>`Update failed. There are duplicates for the '${e}' role which is not allowed. Update your roles and try again.`,ALTER_USER_ROLE_NOT_FOUND:e=>`Update failed. Requested '${e}' role not found.`,DUP_ROLES_FOUND:e=>`Multiple ${e} roles found. Roles must have unique 'role' value. Please update and try again.`,ROLE_NAME_NOT_FOUND:e=>`${e} role not found`,USER_ALREADY_EXISTS:e=>`User ${e} already exists`,USER_NOT_EXIST:e=>`User ${e} does not exist`},Ht={INVALID_DATE:"Invalid date, must be in ISO-8601 format (YYYY-MM-DD).",SEARCH_CONDITIONS_INVALID_SORT_ATTRIBUTE:e=>`invalid sort attribute '${e}', the attribute must either be the table's hash attribute or an attribute used in conditions.`},Ft={INVALID_IPC_DATA_TYPE:"Invalid IPC event data type, must be an object",MISSING_TYPE:"IPC event missing 'type'",MISSING_MSG:"IPC event missing 'message'",MISSING_ORIGIN:"IPC event message missing 'originator' property",INVALID_EVENT:e=>`IPC server received invalid event type: ${e}`},tn={FUNCTION_STATUS:"Error getting custom function status, check the log for more details",GET_FUNCTIONS:"Error getting custom functions, check the log for more details",GET_FUNCTION:"Error getting custom function, check the log for more details",SET_FUNCTION:"Error setting custom function, check the log for more details",NO_PROJECT:"Project does not exist. Create one using 'add_custom_function_project'",PROJECT_EXISTS:"Project already exists",VALIDATION_ERR:"Error validating request, check the log for more details",NO_FILE:"File does not exist",BAD_FILE_NAME:"File name can only contain alphanumeric, dash and underscore characters",BAD_PROJECT_NAME:"Project name can only contain alphanumeric, dash and underscores characters",BAD_PACKAGE:"Packaged project must be base64-encoded tar file of project directory",DROP_FUNCTION:"Error dropping custom function, check the log for more details",ADD_FUNCTION:"Error adding custom function project, check the log for more details",DROP_FUNCTION_PROJECT:"Error dropping custom function project, check the log for more details",BAD_FILE_PATH:"Filepath must be valid, and contain the name of the tarball you wish to write",NOT_ENABLED:"Custom functions is not enabled, to enable set customFunctions enabled to true in hdb/harperdb-config.yaml file."},rn={CLUSTERING_NOT_ENABLED:"Clustering must be enabled to perform this operation."},_n={...Gt,...xo,...Wo,...Qo,...Xo,...Zo,...zo,...en,...Jo,...Ht,...Ft,...tn,...rn,...jo};bt.exports={CHECK_LOGS_WRAPPER:mt,HDB_ERROR_MSGS:_n,DEFAULT_ERROR_MSGS:ht,DEFAULT_ERROR_RESP:qo,HTTP_STATUS_CODES:Mt,LMDB_ERRORS_ENUM:$o,AUTHENTICATION_ERROR_MSGS:Gt,VALIDATION_ERROR_MSGS:Ht,IPC_ERRORS:Ft}});var Ye=P((Os,Kt)=>{"use strict";var ne=de(),on=te(),nn=y(),Re=class extends Error{constructor(t,r,_,E,s){super(),Error.captureStackTrace(this,Bt),this.http_resp_code=_||ne.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR,this.http_resp_msg=r||(ne.DEFAULT_ERROR_MSGS[_]?ne.DEFAULT_ERROR_MSGS[_]:ne.DEFAULT_ERROR_MSGS[ne.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR]),this.message=t.message?t.message:this.http_resp_msg,this.type=t.name,typeof this.message!="string"&&(this.stack=t.stack),s&&on[E](s)}};n(Re,"HdbError");function Bt(e,t,r,_=nn.LOG_LEVELS.ERROR,E=null,s=!1){if(yt(e))return e;let T=new Re(e,t,r,_,E);return s&&delete T.stack,T}n(Bt,"handleHDBError");function yt(e){return e.__proto__.constructor.name===Re.name}n(yt,"isHDBError");Kt.exports={isHDBError:yt,handleHDBError:Bt,hdb_errors:ne}});var ae=P((Ns,zt)=>{"use strict";var ke=require("path"),En=require("fs-extra"),I=te(),wt=require("fs-extra"),sn=require("truncate-utf8-bytes"),ce=require("os"),Tn=require("net"),Sn=require("recursive-iterator"),l=y(),qt=ft(),Vt=require("papaparse"),Le=require("moment"),{inspect:Rn}=require("util"),vt=require("is-number"),As=require("lodash"),{hdb_errors:fe}=Ye(),Wt=require("util").promisify(setTimeout),cn=100,an=5,On="",An=4,Yt=255,kt={true:!0,false:!1,undefined:null,null:null,NaN:NaN};zt.exports={isEmpty:m,isEmptyOrZeroLength:w,arrayHasEmptyValues:In,arrayHasEmptyOrZeroLengthValues:ln,buildFolderPath:Cn,isBoolean:jt,errorizeMessage:Nn,stripFileExtension:Ln,autoCast:fn,autoCastJSONDeep:qe,removeDir:pn,compareVersions:Dn,isCompatibleDataVersion:gn,escapeRawValue:$t,unescapeValue:Pn,stringifyProps:Mn,valueConverter:mn,timeoutPromise:Gn,isClusterOperation:Fn,getClusterUser:yn,sendTransactionToSocketCluster:bn,checkGlobalSchemaTable:Bn,getHomeDir:Jt,getPropsFilePath:hn,promisifyPapaParse:Kn,removeBOM:Qt,createEventPromise:wn,checkProcessRunning:Vn,checkSchemaTableExist:vn,checkSchemaExists:Xt,checkTableExists:Zt,getStartOfTomorrowInSeconds:Yn,getLimitKey:kn,isObject:dn,isNotEmptyAndHasValue:un,autoCasterIsNumberCheck:xt,backtickASTSchemaItems:qn,isPortTaken:Hn,stopProcess:Wn,createForkArgs:jn,autoCastBoolean:xn,async_set_timeout:Wt,getTableHashAttribute:$n,doesSchemaExist:Jn,doesTableExist:Qn,stringifyObj:Xn,ms_to_time:Zn,PACKAGE_ROOT:l.PACKAGE_ROOT};function Nn(e){return e instanceof Error?e:new Error(e)}n(Nn,"errorizeMessage");function m(e){return e==null}n(m,"isEmpty");function un(e){return!m(e)&&(e||e===0||e===""||jt(e))}n(un,"isNotEmptyAndHasValue");function w(e){return m(e)||e.length===0||e.size===0}n(w,"isEmptyOrZeroLength");function In(e){if(m(e))return!0;for(let t=0;t<e.length;t++)if(m(e[t]))return!0;return!1}n(In,"arrayHasEmptyValues");function ln(e){if(w(e))return!0;for(let t=0;t<e.length;t++)if(w(e[t]))return!0;return!1}n(ln,"arrayHasEmptyOrZeroLengthValues");function Cn(...e){try{return e.join(ke.sep)}catch{console.error(e)}}n(Cn,"buildFolderPath");function jt(e){return m(e)?!1:e===!0||e===!1}n(jt,"isBoolean");function dn(e){return m(e)?!1:typeof e=="object"}n(dn,"isObject");function Ln(e){return w(e)?On:e.slice(0,-An)}n(Ln,"stripFileExtension");function fn(e){return m(e)||e===""||typeof e!="string"?e:kt[e]!==void 0?kt[e]:xt(e)===!0?Number(e):e}n(fn,"autoCast");function Un(e){if(typeof e=="string"&&(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")))try{return JSON.parse(e)}catch{}return e}n(Un,"autoCastJSON");function qe(e){if(e&&typeof e=="object"){if(Array.isArray(e))for(let t=0,r=e.length;t<r;t++){let _=e[t],E=qe(_);E!==_&&(e[t]=E)}else for(let t in e){let r=e[t],_=qe(r);_!==r&&(e[t]=_)}return e}else return Un(e)}n(qe,"autoCastJSONDeep");function xt(e){if(e.startsWith("0.")&&vt(e))return!0;let t=e.toUpperCase().includes("E");return!!((e!=="0"&&e.startsWith("0"))===!1&&t===!1&&vt(e))}n(xt,"autoCasterIsNumberCheck");async function pn(e){if(w(e))throw new Error(`Directory path: ${e} does not exist`);try{await wt.emptyDir(e),await wt.remove(e)}catch(t){throw I.error(`Error removing files in ${e} -- ${t}`),t}}n(pn,"removeDir");function Dn(e,t){if(w(e)){I.info("Invalid current version sent as parameter.");return}if(w(t)){I.info("Invalid upgrade version sent as parameter.");return}let r,_=/(\.0+)+$/,E=e.version?e.version:e,s=t.version?t.version:t,T=E.replace(_,"").split("."),R=s.replace(_,"").split("."),N=Math.min(T.length,R.length);for(let Y=0;Y<N;Y++)if(r=parseInt(T[Y],10)-parseInt(R[Y],10),r)return r;return T.length-R.length}n(Dn,"compareVersions");function gn(e,t,r=!1){let _=e.toString().split("."),E=t.toString().split(".");return _[0]===E[0]&&(!r||_[1]===E[1])}n(gn,"isCompatibleDataVersion");function $t(e){if(m(e))return e;let t=String(e);return t==="."?l.UNICODE_PERIOD:t===".."?l.UNICODE_PERIOD+l.UNICODE_PERIOD:t.replace(l.FORWARD_SLASH_REGEX,l.UNICODE_FORWARD_SLASH)}n($t,"escapeRawValue");function Pn(e){if(m(e))return e;let t=String(e);return t===l.UNICODE_PERIOD?".":t===l.UNICODE_PERIOD+l.UNICODE_PERIOD?"..":String(e).replace(l.ESCAPED_FORWARD_SLASH_REGEX,"/")}n(Pn,"unescapeValue");function Mn(e,t){if(m(e))return I.info("Properties object is null"),"";let r="";return e.each(function(_,E){try{if(t&&t[_]){let s=t[_];for(let T of s)r+=";"+T+ce.EOL}!w(_)&&_[0]===";"?r+=" "+_+E+ce.EOL:w(_)||(r+=_+"="+E+ce.EOL)}catch{I.error(`Found bad property during upgrade with key ${_} and value: ${E}`)}}),r}n(Mn,"stringifyProps");function mn(e){let t;try{t=typeof e=="object"?JSON.stringify(e):e}catch(E){I.error(E),t=e}let r=String($t(t)),_=Buffer.byteLength(r)>Yt?sn(r,Yt)+"/blob":r;return{value:t,value_stripped:r,value_path:_}}n(mn,"valueConverter");function Jt(){let e;try{e=ce.homedir()}catch{e=process.env.HOME}return e||(e="~/"),e}n(Jt,"getHomeDir");function hn(){let e=ke.join(Jt(),l.HDB_HOME_DIR_NAME,l.BOOT_PROPS_FILE_NAME);return En.existsSync(e)||(e=ke.join(__dirname,"../","hdb_boot_properties.file")),e}n(hn,"getPropsFilePath");function Gn(e,t){let r,_;return _=new Promise(function(E){r=setTimeout(function(){E(t)},e)}),{promise:_,cancel:function(){clearTimeout(r)}}}n(Gn,"timeoutPromise");async function Hn(e){if(!e)throw new Error("Invalid port passed as parameter");return new Promise((t,r)=>{let _=Tn.createServer().once("error",E=>{E.code==="EADDRINUSE"?t(!0):r(E)}).once("listening",()=>_.once("close",()=>t(!1)).close()).listen(e)})}n(Hn,"isPortTaken");function Fn(e){try{return l.CLUSTER_OPERATIONS[e.toLowerCase()]!==void 0}catch(t){I.error(`Error checking operation against cluster ops ${t}`)}return!1}n(Fn,"isClusterOperation");function bn(e,t,r){if(global.hdb_socket_client!==void 0){I.trace(`Sending transaction to channel: ${e}`);let{hdb_user:_,hdb_auth_header:E,...s}=t;s.__originator||(s.__originator={}),s.__transacted=!0,r&&(s.__originator[r]=l.ORIGINATOR_SET_VALUE),global.hdb_socket_client.publish(e,s)}}n(bn,"sendTransactionToSocketCluster");function Bn(e,t){if(!global.hdb_schema[e])return fe.HDB_ERROR_MSGS.SCHEMA_NOT_FOUND(e);if(!global.hdb_schema[e]||!global.hdb_schema[e][t])return fe.HDB_ERROR_MSGS.TABLE_NOT_FOUND(e,t)}n(Bn,"checkGlobalSchemaTable");function yn(e,t){if(m(t)){I.warn("No CLUSTERING_USER defined, clustering disabled");return}if(m(e)||w(e)){I.warn("No users to search.");return}let r;try{let _=e.get(t);_&&_.role.permission.cluster_user===!0&&_.active===!0&&(r=_)}catch(_){I.error(`unable to find cluster_user due to: ${_.message}`);return}if(r===void 0){I.warn(`CLUSTERING_USER: ${t} not found or is not active.`);return}return r}n(yn,"getClusterUser");function Kn(){Vt.parsePromise=function(e,t){return new Promise(function(r,_){Vt.parse(e,{header:!0,transformHeader:Qt,chunk:t.bind(null,_),skipEmptyLines:!0,dynamicTyping:!0,error:_,complete:r})})}}n(Kn,"promisifyPapaParse");function Qt(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return e.charCodeAt(0)===65279?e.slice(1):e}n(Qt,"removeBOM");function wn(e,t,r){return new Promise(_=>{t.once(e,E=>{let s=r;I.info(`Got cluster status event response: ${Rn(E)}`);try{s.cancel()}catch{I.error("Error trying to cancel timeout.")}_(E)})})}n(wn,"createEventPromise");async function Vn(e){let t=!0,r=0;do await Wt(cn*r++),(await qt.findPs(e)).length>0&&(t=!1);while(t&&r<an);if(t)throw new Error(`process ${e} was not started`)}n(Vn,"checkProcessRunning");function vn(e,t){let r=Xt(e);if(r)return r;let _=Zt(e,t);if(_)return _}n(vn,"checkSchemaTableExist");function Xt(e){if(!global.hdb_schema[e])return fe.HDB_ERROR_MSGS.SCHEMA_NOT_FOUND(e)}n(Xt,"checkSchemaExists");function Zt(e,t){if(!global.hdb_schema[e][t])return fe.HDB_ERROR_MSGS.TABLE_NOT_FOUND(e,t)}n(Zt,"checkTableExists");function Yn(){let e=Le().utc().add(1,l.MOMENT_DAYS_TAG).startOf(l.MOMENT_DAYS_TAG).unix(),t=Le().utc().unix();return e-t}n(Yn,"getStartOfTomorrowInSeconds");function kn(){return Le().utc().format("DD-MM-YYYY")}n(kn,"getLimitKey");function qn(e){try{let t=new Sn(e);for(let{node:r}of t)r&&(r.columnid&&typeof r.columnid!="string"&&(r.columnid=r.columnid.toString()),r.columnid&&!r.columnid.startsWith("`")&&(r.columnid_orig=r.columnid,r.columnid=`\`${r.columnid}\``),r.tableid&&!r.tableid.startsWith("`")&&(r.tableid_orig=r.tableid,r.tableid=`\`${r.tableid}\``),r.databaseid&&!r.databaseid.startsWith("`")&&(r.databaseid_orig=r.databaseid,r.databaseid=`\`${r.databaseid}\``),r.as&&typeof r.as=="string"&&!r.as.startsWith("[")&&(r.as_orig=r.as,r.as=`\`${r.as}\``))}catch(t){I.error("Got an error back ticking items."),I.error(t)}}n(qn,"backtickASTSchemaItems");async function Wn(e){let t=ce.userInfo();(await qt.findPs(e)).forEach(_=>{(t.uid==0||_.uid==t.uid)&&(process.kill(_.pid),I.trace(`Following process was killed by stopProcess: ${_.cmd}`))})}n(Wn,"stopProcess");function jn(e){return[e]}n(jn,"createForkArgs");function xn(e){return e===!0||typeof e=="string"&&e.toLowerCase()==="true"}n(xn,"autoCastBoolean");function $n(e,t){return global.hdb_schema?.[e]?.[t]?.hash_attribute}n($n,"getTableHashAttribute");function Jn(e){return global?.hdb_schema?.[e]!==void 0}n(Jn,"doesSchemaExist");function Qn(e,t){return global?.hdb_schema?.[e]?.[t]!==void 0}n(Qn,"doesTableExist");function Xn(e){try{return JSON.stringify(e)}catch{return e}}n(Xn,"stringifyObj");function Zn(e){let t=Le.duration(e),r=t.seconds()>0?t.seconds()+"s":"",_=t.minutes()>0?t.minutes()+"m ":"",E=t.hours()>0?t.hours()+"h ":"",s=t.days()>0?t.days()+"d ":"";return(t.years()>0?t.years()+"y ":"")+s+E+_+r}n(Zn,"ms_to_time")});var tr=P((us,er)=>{"use strict";var zn={key:"-----BEGIN RSA PRIVATE KEY-----\rMIIEowIBAAKCAQEArBFJQRfFiJku/KwhV1Ssp7cX61vvuKmd4Rp6A9jB2QLgx8nj\r/+Xhp2hPRkISnOA8BuAxr4dMD9syGJwX4kNy9mbZ5Q0fWZCiEGBpVcU1J+k+N5K4\rSuZ2SqgxeN2IN2RLzt3GyQY4imcdHgNv7aHoXUrEwBx0MeYEw3IIDXtrYKCR2D8I\rvWBfwMUgWa24G8lpWILWA5hd9srRz9NxlAiHSjhbgT7B0xruEpHRCHSyKjvaIJVt\rWBR+amejYsAKVrD/hgrqjsA1123Y6++YqvU6vwg64xhS2kz5r3dkNKhvwbWgpZdI\rIaRvsiB77f4kLGo0vi8RFgJ1ZRjGg3RRK2w1LQIDAQABAoIBAQCEOmh78EOpnGZC\rYBjjHrvrysVD5gvLcfVUtl8Ls7gMB60re1eOIF+PoZZCHKZnDd6zPfiQtj1adg0C\rYnnsM/8VoaZS4gm0b3RLd3ubIQifWhuo40RissY2yxfxlPSH9LhZCY8ojnJG0cTL\resK579E8WCfopjUY33XLqEbN7Ylv39J+DSqInjqV3efJZUa+HqUJ98VxxzodcKMD\rP3bwUU4gHoSSp4pAsOFH5sQhaIWH1IcNjrAwpee2cJQuh4G157RRIuuUpagtaEG/\rXJIiAyBguJyu3JQFnIBQF01N5+omJgXYJ1L0m54543/iIRThmF3zDCDgCyUzmOk+\rH6As9fv1AoGBANOpOtOZLSAScjGsgJamT3ceJ2wCa86g2j8Oxu8lJUmUp5s3tA0v\rBFW5O3S4KR1EXwkLMBUMrfFM8YvzHWxsXBI6XV8azGLvyqPHxr65OhmpGYkGZMXu\rn9okgjkqlewnY2I073gvyK7ppX51UL5y9fF1vlsk+UlW+Rgx/vMHbdcjAoGBANAc\rxRUsxs4QJpbS4zD3JOkHjr24a97TrS3kCybAHUMpR2NrEHPZw9zex0/aphOJUHfL\rIMkOZdpfDqMfxWy4FAEmqBEMkO2SB+h0Wp4P+qp81ax4vGFiB0cD3wtixr11U1tt\rlZ/ZTdv4VDpDFNK1KaplhTDeyuCjeYfS3/GJia9vAoGAcOsAgjBevZR5rXx84WH6\rVO8WUu37u7FenXNxt9VWTinrPMh72uixZFY8nOk+rely1e1NCn3IMko9Ns9NbDFm\r8SaH95vhXArXTYbfxZIlp9jp0YtCqcHDL+p4Oq04bFMbFyJseu7rHj1x18QYfnHw\rOY/6LL/N6k1m+Hx7qgXVmIcCgYB/w0nTCBw84XlvWqSTqQaF8VfWbWP79mP5KmkW\rLxdH5g2noVEGbohqDnK6OXd/wusdwByukiJBf94Skyy25AOT+VFwthA7aU1ljhkb\rtJ+lDuJ28eBkwLPLCzthWBC+u0qjdJFJAzVjd/7tjcU43nNn4s90AzL12iaAFhvZ\rwyA+DQKBgGc/4cdyGJ3YkcA8150gQBawgJZ7q8V1JND87ggWA8wnK3cHn7rMZQl2\r3emDp9HEFXFex5dbGDDqZFAoesZCDxjknIn9oNfW4PvaWS8q7b6ZKLZG1p03Pu7/\rtYaD0kPbo0kysfFT/co+NgHbdykvIyboomfGdNLTUjYuy6lpwpvs\r-----END RSA PRIVATE KEY-----\r".replace(/\r/g,String.fromCharCode(13,10)),cert:"-----BEGIN CERTIFICATE-----\rMIIDXDCCAkSgAwIBAgIFNTE4MzQwDQYJKoZIhvcNAQELBQAwXTEXMBUGA1UEAxMO\rSGFycGVyREIsIEluYy4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDTzEPMA0GA1UE\rBxMGRGVudmVyMRcwFQYDVQQKEw5IYXJwZXJEQiwgSW5jLjAeFw0yMjAzMTEyMzAz\rNDlaFw0yNzAzMTAyMzAzNDlaMF0xFzAVBgNVBAMTDkhhcnBlckRCLCBJbmMuMQsw\rCQYDVQQGEwJVUzELMAkGA1UECBMCQ08xDzANBgNVBAcTBkRlbnZlcjEXMBUGA1UE\rChMOSGFycGVyREIsIEluYy4wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\rAQCsEUlBF8WImS78rCFXVKyntxfrW++4qZ3hGnoD2MHZAuDHyeP/5eGnaE9GQhKc\r4DwG4DGvh0wP2zIYnBfiQ3L2ZtnlDR9ZkKIQYGlVxTUn6T43krhK5nZKqDF43Yg3\rZEvO3cbJBjiKZx0eA2/toehdSsTAHHQx5gTDcggNe2tgoJHYPwi9YF/AxSBZrbgb\ryWlYgtYDmF32ytHP03GUCIdKOFuBPsHTGu4SkdEIdLIqO9oglW1YFH5qZ6NiwApW\rsP+GCuqOwDXXbdjr75iq9Tq/CDrjGFLaTPmvd2Q0qG/BtaCll0ghpG+yIHvt/iQs\rajS+LxEWAnVlGMaDdFErbDUtAgMBAAGjIzAhMA8GA1UdEwEB/wQFMAMBAf8wDgYD\rVR0PAQH/BAQDAgIEMA0GCSqGSIb3DQEBCwUAA4IBAQASR4YW/rPK7PNArHVe9zzM\rb0rKNX/2T9/0nybRhmE/+hdlSgliTAeebmwkUS2APckmekYt/q2ZY2NS65Fo/jjp\rG8TJrtcF4h+ylVqUp0ZXQLFtIsr7r2JZA7hJ6njW6G4DHSZ0gxtECLi4CBlTjzm5\rNmnmIDObvGRTuqmcdAZmXeObbta/He2XIzietukPAYX062pNM+G5XT5UM1eG/Vlp\rN86vjhpyI+ffKy+C60SJqxmKM3ydgN7oLscE7+2wLPN25XqN4W99OwGsp5dTdu/f\r5lPtFayXdJ55e/sNQKmGN+UGLrL05c2MWgjb8U/LFilnupUianceoeSERZmVjzKX\r-----END CERTIFICATE-----\r".replace(/\r/g,String.fromCharCode(13,10))},eE="certificate.pem",tE="privateKey.pem",rE="ca.pem";er.exports={CERTIFICATE_VALUES:zn,CERTIFICATE_PEM_NAME:eE,PRIVATEKEY_PEM_NAME:tE,CA_PEM_NAME:rE}});var _r=P((Is,rr)=>{"use strict";var p=require("validate.js");p.validators.type=function(e,t,r,_){return e===null||typeof e>"u"||p.validators.type.checks[t](e)?null:` must be a '${t}' value`};p.validators.type.checks={Object:function(e){return p.isObject(e)&&!p.isArray(e)},Array:p.isArray,Integer:p.isInteger,Number:p.isNumber,String:p.isString,Date:p.isDate,Boolean:function(e){return typeof e=="boolean"}};p.validators.hasValidFileExt=function(e,t){return!p.isString(e)||e===""||t.filter(r=>e.endsWith(r)).length>0?null:`must include one of the following valid file extensions - '${t.join("', '")}'`};rr.exports={validateObject:_E,validateObjectAsync:oE,validateBySchema:nE};function _E(e,t){if(!e||!t)return new Error("validateObject parameters were null");let r=p(e,t,{format:"flat"});return r?new Error(r):null}n(_E,"validateObject");async function oE(e,t){if(!e||!t)return new Error("validateObject parameters were null");try{await p.async(e,t,{format:"flat"})}catch(r){let _=r.join(",");return new Error(_)}return null}n(oE,"validateObjectAsync");function nE(e,t){let r=t.validate(e,{allowUnknown:!0,abortEarly:!1,errors:{wrap:{label:"'"}}});if(r.error)return new Error(r.error.message)}n(nE,"validateBySchema")});var Er=P((ls,nr)=>{"use strict";var EE=require("fs-extra"),c=require("joi"),sE=require("os"),{boolean:C,string:W,number:V,array:We}=c.types(),b=require("path"),iE=te(),Ue=ae(),j=tr(),TE=_r(),q="keys",SE=j.CERTIFICATE_PEM_NAME,RE=j.PRIVATEKEY_PEM_NAME,cE=j.CA_PEM_NAME,aE=j.CERTIFICATE_PEM_NAME,OE=j.PRIVATEKEY_PEM_NAME,AE=j.CA_PEM_NAME,NE=j.CERTIFICATE_PEM_NAME,uE=j.PRIVATEKEY_PEM_NAME,IE=j.CA_PEM_NAME,lE="log",CE="custom_functions",dE="Invalid logging.rotation.maxSize unit. Available units are G, M or K",LE="Invalid logging.rotation.maxSize value. Value should be a number followed by unit e.g. '10M'",fE="rootPath config parameter is undefined",UE="clustering.enabled config parameter is undefined",Q=V.min(0).required(),pe=We.items({host:W.required(),port:Q}).empty(null),D;nr.exports={configValidator:pE,routesValidator:mE,route_constraints:pe};function pE(e){if(D=e.rootPath,Ue.isEmpty(D))throw fE;let t=C.required(),r=c.valid("production","development").required(),_=V.min(1).max(1e3).empty(null).default(ME),E=W.pattern(/^[\\\/]$|([\\\/][a-zA-Z_0-9\:-]+)+$/,"directory path").empty(null).default(or),s=c.custom(gE).messages({"any.custom":"{:#label} {:#error}"}).empty(null).default(or),T=W.pattern(/^[^\s.,*>]+$/).messages({"string.pattern.base":"{:#label} invalid, must not contain ., * or >"}).empty(null),R=e.clustering?.enabled;if(Ue.isEmpty(R))throw UE;let N;return R===!0?N=c.object({enabled:t,hubServer:c.object({cluster:c.object({name:c.required().empty(null),network:c.object({port:Q,routes:pe}).required()}).required(),leafNodes:c.object({network:c.object({port:Q}).required()}).required(),network:c.object({port:Q}).required()}).required(),leafServer:c.object({network:c.object({port:Q,routes:pe}).required()}).required(),nodeName:T,tls:c.object({certificate:s,certificateAuthority:s,privateKey:s,insecure:C.required()}),user:c.string().required()}).required():N=c.object({enabled:t,tls:c.object({certificate:s,certificateAuthority:s,privateKey:s,insecure:C.required()})}).required(),c.object({clustering:N,customFunctions:c.object({enabled:t,network:c.object({cors:C.required(),corsAccessList:We.required(),headersTimeout:V.min(1).required(),https:C.required(),keepAliveTimeout:V.min(1).required(),port:Q,timeout:V.min(1).required()}),nodeEnv:r,root:E,tls:c.object({certificate:s,certificateAuthority:s,privateKey:s})}).required(),ipc:c.object({network:c.object({port:Q})}).required(),localStudio:c.object({enabled:t}).required(),logging:c.object({file:C.required(),level:c.valid("notify","fatal","error","warn","info","debug","trace"),rotation:c.object({compress:C.required(),dateFormat:W.required(),maxSize:W.custom(PE).required(),retain:V.min(0).required(),rotate:C.required(),rotateInterval:W.required(),rotateModule:C.required(),timezone:W.required(),workerInterval:V.min(1).required()}).required(),root:E,stdStreams:C.required(),auditLog:C.required()}).required(),operationsApi:c.object({authentication:c.object({operationTokenTimeout:c.required(),refreshTokenTimeout:c.required()}).required(),foreground:C.required(),network:c.object({cors:C.required(),corsAccessList:We.required(),headersTimeout:V.min(1).required(),https:C.required(),keepAliveTimeout:V.min(1).required(),port:Q,timeout:V.min(1).required()}).required(),nodeEnv:r,tls:c.object({certificate:s,certificateAuthority:s,privateKey:s})}).required(),rootPath:W.pattern(/^[\\\/]$|([\\\/][a-zA-Z_0-9\:-]+)+$/,"directory path").required(),http:c.object({threads:_}).required(),storage:c.object({writeAsync:C.required(),overlappingSync:C.optional()}).required()}).validate(e,{allowUnknown:!0,abortEarly:!1,errors:{wrap:{label:"'"}}})}n(pE,"configValidator");function DE(e){return EE.existsSync(e)?null:`Specified path ${e} does not exist.`}n(DE,"doesPathExist");function gE(e,t){c.assert(e,W.pattern(/^[\\\/]$|([\\\/][a-zA-Z_0-9\:-]+)+\.pem+$/).messages({"string.pattern.base":"must be a valid directory path and specify a .pem file"}));let r=DE(e);if(r)return t.message(r)}n(gE,"validatePemFile");function PE(e,t){let r=e.slice(-1);if(r!=="G"&&r!=="M"&&r!=="K")return t.message(dE);let _=e.slice(0,-1);if(isNaN(parseInt(_)))return t.message(LE)}n(PE,"validateRotationMaxSize");function ME(e,t){let r=t.state.path.join("."),_=sE.cpus().length,E=_-1;return E<=2&&(E=2),iE.info(`Detected ${_} cores on this machine, defaulting ${r} to ${E}`),E}n(ME,"setDefaultThreads");function or(e,t){if(!Ue.isEmpty(t.original))return t.original;let r=t.state.path.join(".");if(Ue.isEmpty(D))throw new Error(`Error setting default root for: ${r}. HDB root is not defined`);switch(r){case"customFunctions.root":return b.join(D,CE);case"logging.root":return b.join(D,lE);case"operationsApi.tls.certificate":return b.join(D,q,SE);case"operationsApi.tls.privateKey":return b.join(D,q,RE);case"operationsApi.tls.certificateAuthority":return b.join(D,q,cE);case"customFunctions.tls.certificate":return b.join(D,q,aE);case"customFunctions.tls.privateKey":return b.join(D,q,OE);case"customFunctions.tls.certificateAuthority":return b.join(D,q,AE);case"clustering.tls.certificate":return b.join(D,q,NE);case"clustering.tls.privateKey":return b.join(D,q,uE);case"clustering.tls.certificateAuthority":return b.join(D,q,IE);default:throw new Error(`Error setting default root for config parameter: ${r}. Unrecognized config parameter`)}}n(or,"setDefaultRoot");function mE(e){let t=c.object({routes:pe});return TE.validateBySchema({routes:e},t)}n(mE,"routesValidator")});var Or=P((Cs,ar)=>{"use strict";var A=y(),h=ae(),L=te(),{configValidator:hE,routesValidator:sr}=Er(),B=require("fs-extra"),GE=require("yaml"),Ee=require("path"),HE=require("is-number"),Pe=require("properties-reader"),FE=require("lodash"),{handleHDBError:bE}=Ye(),{HTTP_STATUS_CODES:BE,HDB_ERROR_MSGS:De}=de(),{PACKAGE_ROOT:yE}=y(),KE="Unable to get config value because config is uninitialized",wE="Config successfully initialized",VE="Error backing up config file",vE="Empty parameter sent to getConfigValue",ir=Ee.join(yE,"config","yaml",A.HDB_DEFAULT_CONFIG_FILE),YE="Configuration successfully set. You must restart HarperDB for new config settings to take effect.",ge,g;ar.exports={createConfigFile:kE,getDefaultConfig:qE,getConfigValue:Tr,initConfig:Sr,flattenConfig:re,updateConfigValue:Rr,updateConfigObject:WE,getConfiguration:jE,setConfiguration:xE,readConfigFile:$e,getClusteringRoutes:$E,initOldConfig:cr,getConfigFromFile:JE};function kE(e){let t=se(ir);ge=re(t.toJSON());for(let s in e){let T=A.CONFIG_PARAM_MAP[s.toLowerCase()];if(T!==void 0){let R=T.split("_"),N=je(T,e[s]);try{t.setIn([...R],N)}catch(Y){L.error(Y)}}}xe(t);let r=t.toJSON();g=re(r);let _=t.getIn(["rootPath"]),E=Ee.join(_,A.HDB_CONFIG_FILE);B.createFileSync(E),B.writeFileSync(E,String(t)),L.trace(`Config file written to ${E}`)}n(kE,"createConfigFile");function qE(e){if(ge===void 0){let r=se(ir);ge=re(r.toJSON())}let t=A.CONFIG_PARAM_MAP[e.toLowerCase()];if(t!==void 0)return ge[t.toLowerCase()]}n(qE,"getDefaultConfig");function Tr(e){if(h.isEmpty(e)){L.error(vE);return}if(g===void 0){L.trace(KE);return}let t=A.CONFIG_PARAM_MAP[e.toLowerCase()];if(t!==void 0)return g[t.toLowerCase()]}n(Tr,"getConfigValue");function Sr(e=!1){if(g===void 0||e){let t=h.getPropsFilePath();try{B.accessSync(t,B.constants.F_OK|B.constants.R_OK)}catch(T){throw L.error(T),new Error(`HarperDB properties file at path ${t} does not exist`)}let _=Pe(t).get(A.HDB_SETTINGS_NAMES.SETTINGS_PATH_KEY),E;if(_.includes("config/settings.js"))try{cr(_);return}catch(T){if(T.code!==A.NODE_ERROR_CODES.ENOENT)throw T}try{E=se(_)}catch(T){if(T.code===A.NODE_ERROR_CODES.ENOENT){L.trace(`HarperDB config file not found at ${_}.
|
|
5
5
|
This can occur during early stages of install where the config file has not yet been created`);return}else throw L.error(T),new Error(`Error reading HarperDB config file at ${_}`)}xe(E);let s=E.toJSON();g=re(s),L.trace(wE)}}n(Sr,"initConfig");function xe(e){let t=e.toJSON(),r=hE(t);if(r.error)throw De.CONFIG_VALIDATION(r.error.message);e.setIn(["http","threads"],r.value.http.threads),e.setIn(["customFunctions","root"],r.value.customFunctions.root),e.setIn(["logging","root"],r.value.logging.root),e.setIn(["operationsApi","tls","certificate"],r.value.operationsApi.tls.certificate),e.setIn(["operationsApi","tls","privateKey"],r.value.operationsApi.tls.privateKey),e.setIn(["operationsApi","tls","certificateAuthority"],r.value.operationsApi.tls.certificateAuthority),e.setIn(["customFunctions","tls","certificate"],r.value.customFunctions.tls.certificate),e.setIn(["customFunctions","tls","privateKey"],r.value.customFunctions.tls.privateKey),e.setIn(["customFunctions","tls","certificateAuthority"],r.value.customFunctions.tls.certificateAuthority),e.setIn(["clustering","tls","certificate"],r.value.clustering.tls.certificate),e.setIn(["clustering","tls","privateKey"],r.value.clustering.tls.privateKey),e.setIn(["clustering","tls","certificateAuthority"],r.value.clustering.tls.certificateAuthority)}n(xe,"validateConfig");function WE(e,t){g===void 0&&(g={});let r=A.CONFIG_PARAM_MAP[e.toLowerCase()];if(r===void 0){L.trace(`Unable to update config object because config param '${e}' does not exist`);return}g[r.toLowerCase()]=t}n(WE,"updateConfigObject");function Rr(e,t,r=void 0,_=!1,E=!1){g===void 0&&Sr();let s=Tr(A.CONFIG_PARAM_MAP.hdb_root),T=Ee.join(s,A.HDB_CONFIG_FILE),R=se(T);if(r===void 0){let H=A.CONFIG_PARAM_MAP[e.toLowerCase()];if(H===void 0)throw new Error(`Unable to update config, unrecognized config parameter: ${e}`);let Te=H.split("_"),Ge=je(H,t);R.setIn([...Te],Ge)}else for(let H in r){let Te=A.CONFIG_PARAM_MAP[H.toLowerCase()];if(Te!==void 0){let Ge=Te.split("_"),lr=je(Te,r[H]);try{R.setIn([...Ge],lr)}catch(Cr){L.error(Cr)}}}xe(R);let N=R.getIn(["rootPath"]),Y=Ee.join(N,A.HDB_CONFIG_FILE);if(_===!0)try{let H=Ee.join(N,"backup",`${A.HDB_CONFIG_FILE}.bak`);B.copySync(T,H),L.trace(`Config file: ${T} backed up to: ${H}`)}catch(H){L.error(VE),L.error(H)}B.writeFileSync(Y,String(R)),E&&(g=re(R.toJSON())),L.trace(`Config parameter: ${e} updated with value: ${t}`)}n(Rr,"updateConfigValue");function re(e){let t={};for(let r in e)if(!!e.hasOwnProperty(r))if(typeof e[r]=="object"&&e[r]!==null&&!Array.isArray(e[r])){let _=re(e[r]);for(let E in _)!_.hasOwnProperty(E)||(t[r.toLowerCase()+"_"+E]=_[E])}else t[r.toLowerCase()]=e[r];return t}n(re,"flattenConfig");function je(e,t){if(e===A.CONFIG_PARAMS.CLUSTERING_NODENAME||e===A.CONFIG_PARAMS.CLUSTERING_USER){if(!isNaN(t))return t.toString();if(typeof t=="string"&&t.toLowerCase()==="true"||typeof t=="string"&&t.toLowerCase()==="false")return t}else{if(HE(t))return parseFloat(t);if(t===!0||t===!1||Array.isArray(t)||h.isObject(t)||t===null)return t;if(typeof t=="string"&&t.toLowerCase()==="true")return!0;if(typeof t=="string"&&t.toLowerCase()==="false")return!1}if(t===void 0||t.toLowerCase()==="undefined")return null;if(typeof t=="string"&&(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")))try{return JSON.parse(t)}catch{}return h.autoCast(t)}n(je,"castConfigValue");function jE(){let e=h.getPropsFilePath(),r=Pe(e).get(A.HDB_SETTINGS_NAMES.SETTINGS_PATH_KEY);return se(r).toJSON()}n(jE,"getConfiguration");async function xE(e){let{operation:t,hdb_user:r,hdb_auth_header:_,...E}=e;try{return Rr(void 0,void 0,E,!0),YE}catch(s){throw typeof s=="string"||s instanceof String?bE(s,s,BE.BAD_REQUEST,void 0,void 0,!0):s}}n(xE,"setConfiguration");function $e(){let e=h.getPropsFilePath();try{B.accessSync(e,B.constants.F_OK|B.constants.R_OK)}catch(E){throw L.error(E),new Error(`HarperDB properties file at path ${e} does not exist`)}let r=Pe(e).get(A.HDB_SETTINGS_NAMES.SETTINGS_PATH_KEY);return se(r).toJSON()}n($e,"readConfigFile");function se(e){return GE.parseDocument(B.readFileSync(e,"utf8"),{simpleKeys:!0})}n(se,"parseYamlDoc");function $E(){let e=$e(),t=e?.clustering?.hubServer?.cluster?.network?.routes;t=h.isEmptyOrZeroLength(t)?[]:t;let r=sr(t);if(r)throw De.CONFIG_VALIDATION(r.message);let _=e?.clustering?.leafServer?.network?.routes;_=h.isEmptyOrZeroLength(_)?[]:_;let E=sr(_);if(E)throw De.CONFIG_VALIDATION(E.message);if(!h.isEmptyOrZeroLength(_)&&!h.isEmptyOrZeroLength(t)){let s=t.filter(T=>_.some(R=>R.host===T.host&&R.port===T.port));if(!h.isEmptyOrZeroLength(s)){let T=`Duplicate hub and leaf routes found ${JSON.stringify(s)}`;throw De.CONFIG_VALIDATION(T)}}return{hub_routes:t,leaf_routes:_}}n($E,"getClusteringRoutes");function cr(e){let t=Pe(e);g={};for(let r in A.CONFIG_PARAM_MAP){let _=t.get(r.toUpperCase());if(h.isEmpty(_)||typeof _=="string"&&_.trim().length===0)continue;let E=A.CONFIG_PARAM_MAP[r].toLowerCase();E===A.CONFIG_PARAMS.LOGGING_ROOT?g[E]=Ee.dirname(_):g[E]=_}return g}n(cr,"initOldConfig");function JE(e){let t=$e();return FE.get(t,e.replaceAll("_","."))}n(JE,"getConfigFromFile")});var ur=P((ds,Nr)=>{"use strict";var Je=require("fs-extra"),v=require("path"),QE=require("os"),XE=require("properties-reader"),Oe=te(),ie=ae(),S=y(),Me=Or(),ZE="Error initializing environment manager",me="BOOT_PROPS_FILE_PATH",Ar=!1,zE={[S.HDB_SETTINGS_NAMES.INSTALL_USER]:!0,[S.HDB_SETTINGS_NAMES.SETTINGS_PATH_KEY]:!0,[S.HDB_SETTINGS_NAMES.HDB_ROOT_KEY]:!0,BOOT_PROPS_FILE_PATH:!0},x={};Nr.exports={BOOT_PROPS_FILE_PATH:me,getHdbBasePath:es,setHdbBasePath:ts,get:rs,initSync:os,setProperty:a,initTestEnvironment:ns};function es(){return x[S.HDB_SETTINGS_NAMES.HDB_ROOT_KEY]}n(es,"getHdbBasePath");function ts(e){x[S.HDB_SETTINGS_NAMES.HDB_ROOT_KEY]=e}n(ts,"setHdbBasePath");function rs(e){let t=Me.getConfigValue(e);return t===void 0?x[e]:t}n(rs,"get");function a(e,t){zE[e]&&(x[e]=t),Me.updateConfigObject(e,t)}n(a,"setProperty");function _s(){let e;try{e=ie.getPropsFilePath(),Je.accessSync(e,Je.constants.F_OK|Je.constants.R_OK),Ar=!0;let t=XE(e);return x[S.HDB_SETTINGS_NAMES.INSTALL_USER]=t.get(S.HDB_SETTINGS_NAMES.INSTALL_USER),x[S.HDB_SETTINGS_NAMES.SETTINGS_PATH_KEY]=t.get(S.HDB_SETTINGS_NAMES.SETTINGS_PATH_KEY),x[me]=e,!0}catch{return Oe.trace(`Environment manager found no properties file at ${e}`),!1}}n(_s,"doesPropFileExist");function os(e=!1){try{(Ar||_s())&&(Me.initConfig(e),x[S.HDB_SETTINGS_NAMES.HDB_ROOT_KEY]=Me.getConfigValue(S.HDB_SETTINGS_NAMES.HDB_ROOT_KEY))}catch(t){Oe.error(ZE),Oe.error(t),console.error(t),process.exit(1)}}n(os,"initSync");function ns(e={}){try{let{keep_alive_timeout:t,headers_timeout:r,server_timeout:_,https_enabled:E,cors_enabled:s,cors_accesslist:T,local_studio_on:R}=e,N=v.join(__dirname,"../../","unitTests");x[me]=v.join(N,"hdb_boot_properties.file"),a(S.HDB_SETTINGS_NAMES.SETTINGS_PATH_KEY,v.join(N,"settings.test")),a(S.HDB_SETTINGS_NAMES.INSTALL_USER,QE.userInfo().username),a(S.HDB_SETTINGS_NAMES.PRIVATE_KEY_KEY,v.join(N,"envDir","utility","keys","privateKey.pem")),a(S.HDB_SETTINGS_NAMES.CERT_KEY,v.join(N,"envDir","utility","keys","certificate.pem")),a(S.CONFIG_PARAMS.CUSTOMFUNCTIONS_TLS_PRIVATEKEY,v.join(N,"envDir","utility","keys","privateKey.pem")),a(S.CONFIG_PARAMS.CUSTOMFUNCTIONS_TLS_CERTIFICATE,v.join(N,"envDir","utility","keys","certificate.pem")),a(S.HDB_SETTINGS_NAMES.LOG_LEVEL_KEY,"debug"),a(S.HDB_SETTINGS_NAMES.LOG_PATH_KEY,v.join(N,"envDir","log")),a(S.HDB_SETTINGS_NAMES.LOG_DAILY_ROTATE_KEY,!1),a(S.HDB_SETTINGS_NAMES.CLUSTERING_ENABLED_KEY,!0),a(S.HDB_SETTINGS_NAMES.CLUSTERING_NODE_NAME_KEY,"1231412de213"),a(S.HDB_SETTINGS_NAMES.HDB_ROOT_KEY,v.join(N,"envDir")),a(S.HDB_SETTINGS_NAMES.HTTP_SECURE_ENABLED_KEY,ie.isEmpty(E)?!0:E),a(S.CONFIG_PARAMS.CUSTOMFUNCTIONS_NETWORK_HTTPS,ie.isEmpty(E)?!0:E),a(S.HDB_SETTINGS_NAMES.SERVER_PORT_KEY,9925),a(S.HDB_SETTINGS_NAMES.CORS_ENABLED_KEY,ie.isEmpty(s)?!1:s),a(S.CONFIG_PARAMS.CUSTOMFUNCTIONS_NETWORK_CORS,ie.isEmpty(s)?!1:s),a(S.HDB_SETTINGS_NAMES.IPC_SERVER_PORT,9383),a(S.HDB_SETTINGS_NAMES.MAX_CUSTOM_FUNCTION_PROCESSES,2),a(S.HDB_SETTINGS_NAMES.MAX_HDB_PROCESSES,4),a(S.HDB_SETTINGS_NAMES.CUSTOM_FUNCTIONS_PORT_KEY,9926),a(S.HDB_SETTINGS_NAMES.CUSTOM_FUNCTIONS_ENABLED_KEY,!0),a(S.HDB_SETTINGS_NAMES.CUSTOM_FUNCTIONS_DIRECTORY_KEY,v.resolve(__dirname,"../../unitTests/server/customFunctions/custom_functions")),a(S.HDB_SETTINGS_NAMES.LOCAL_STUDIO_ON,ie.isEmpty(R)?!1:R),T&&(a("CORS_ACCESSLIST",T),a(S.CONFIG_PARAMS.CUSTOMFUNCTIONS_NETWORK_CORSACCESSLIST,T)),_&&(a(S.HDB_SETTINGS_NAMES.SERVER_TIMEOUT_KEY,_),a(S.CONFIG_PARAMS.CUSTOMFUNCTIONS_NETWORK_TIMEOUT,_)),t&&(a(S.HDB_SETTINGS_NAMES.SERVER_KEEP_ALIVE_TIMEOUT_KEY,t),a(S.CONFIG_PARAMS.CUSTOMFUNCTIONS_NETWORK_KEEPALIVETIMEOUT,t)),r&&(a(S.HDB_SETTINGS_NAMES.SERVER_HEADERS_TIMEOUT_KEY,r),a(S.CONFIG_PARAMS.CUSTOMFUNCTIONS_NETWORK_HEADERSTIMEOUT,r))}catch(t){let r=`Error reading in HDB environment variables from path ${me}. Please check your boot props and settings files`;Oe.fatal(r),Oe.error(t)}}n(ns,"initTestEnvironment")});var G=require("node-ipc"),Ir=ae(),he=y(),X=te(),{IPC_ERRORS:Qe}=de(),Xe=ur();Xe.initSync();G.config.id=he.HDB_IPC_SERVER;G.config.networkPort=Xe.get(he.HDB_SETTINGS_NAMES.IPC_SERVER_PORT);G.config.silent=!0;G.config.retry=100;G.config.maxConnections=1e3;G.serve(()=>{G.server.on("message",Es),G.server.on("connect",()=>{X.trace("HDB IPC server connected")}),G.server.on("disconnect",()=>{X.trace("HDB IPC server disconnected")}),G.server.on("error",e=>{X.error(`IPC server error: ${e}`)})});function Es(e){if(typeof e!="object"){X.warn(Qe.INVALID_IPC_DATA_TYPE);return}if(Ir.isEmpty(e.type)){X.warn(Qe.MISSING_TYPE);return}if(Ir.isEmpty(e.message)){X.warn(Qe.MISSING_MSG);return}let t=e.type;X.trace(`IPC server received a message type ${t}, with message`,e.message),G.server.broadcast(t,e)}n(Es,"messageListener");G.server.start();X.trace(`HDB IPC Server: ${he.HDB_IPC_SERVER}, started on port: ${Xe.get(he.HDB_SETTINGS_NAMES.IPC_SERVER_PORT)}`);
|