harperdb
Version:
HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.
7 lines • 812 kB
JavaScript
var Lj=Object.create;var Wd=Object.defineProperty;var Mj=Object.getOwnPropertyDescriptor;var vj=Object.getOwnPropertyNames;var Uj=Object.getPrototypeOf,xj=Object.prototype.hasOwnProperty;var a=(e,t)=>Wd(e,"name",{value:t,configurable:!0});var be=(e,t)=>()=>(e&&(t=e(e=0)),t);var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Be=(e,t)=>{for(var r in t)Wd(e,r,{get:t[r],enumerable:!0})},iP=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of vj(t))!xj.call(e,s)&&s!==r&&Wd(e,s,{get:()=>t[s],enumerable:!(n=Mj(t,s))||n.enumerable});return e};var M=(e,t,r)=>(r=e!=null?Lj(Uj(e)):{},iP(t||!e||!e.__esModule?Wd(r,"default",{value:e,enumerable:!0}):r,e)),D=e=>iP(Wd({},"__esModule",{value:!0}),e);var Et=P((QTe,cP)=>{var{join:Bj,dirname:oP}=require("node:path"),{existsSync:Hj,readFileSync:kj}=require("node:fs");function Fj(){let t=__dirname,r,n=0;for(;!Hj(r=Bj(t,"package.json"));)if(t===(t=oP(t))||n++>10)throw new Error("Could not find package root");return r}a(Fj,"findPackageJson");var aP=Fj(),Gj=JSON.parse(kj(aP,"utf8")),qj=oP(aP);cP.exports={packageJson:Gj,PACKAGE_ROOT:qj}});var yp=P((XTe,lP)=>{if(__filename.endsWith("dev.js")){let e=require("fast-glob"),{tmpdir:t}=require("node:os"),{relative:r,join:n}=require("node:path"),{existsSync:s,statSync:i,readFileSync:o,writeFileSync:c,unlinkSync:l}=require("node:fs"),{isMainThread:u}=require("node:worker_threads"),{spawnSync:f,spawn:d}=require("node:child_process");process.setSourceMapsEnabled(!0);let{PACKAGE_ROOT:h}=Et(),_=["bin","components","dataLayer","resources","server","sqlTranslator","upgrade","utility","validation"],p="ts-build";if(u){let R=!1,E=!1;if(E=s(n(h,p))){let T=new Set;e.sync(_.map(O=>`${O}/**/*.ts`),{cwd:h}).forEach(O=>{let v=0,F=0;try{T.add(O),v=i(n(h,O)).mtimeMs-5e3,F=i(n(h,p,O.replace(/.ts$/,".js"))).mtimeMs}catch{}v>F&&(R=!0)}),e.sync(_.map(O=>`${O}/**/*.js`),{cwd:n(h,p)}).forEach(O=>{if(!T.has(O.replace(/.js$/,".ts")))try{l(n(h,p,O))}catch{}})}else R=!0;if(R){console.log("Compiling TypeScript...");let T=f("npx",["tsc"],{cwd:h});if(T.stdout?.length&&console.log(T.stdout.toString()),T.stderr?.length&&console.log(T.stderr.toString()),E){let O=n(t(),"harperdb-tsc.pid"),v=!1;if(s(O))try{process.kill(+o(O,"utf8"),0),v=!0}catch{}if(!v){console.log("Starting background TypeScript compilation...");let F=d("npx",["tsc","--watch"],{detached:!0,cwd:h,stdio:"ignore"});F.on("error",q=>{console.error("Error trying to compile TypeScript",q)}),F.pid&&c(O,String(F.pid),"utf-8"),F.unref()}}}}let S=lP.constructor,g=S._findPath;S._findPath=function(R,E,T){if(R.startsWith(".")&&!T&&E.length===1&&E[0].startsWith(h)&&!E[0].includes("node_modules")){let O=r(h,E[0]),v;O.startsWith(p)?v=n(h,r(p,O)):v=n(h,p,O);let F=n(v,R),q=F+".js";if(s(q))return q;if(F.includes(".")&&s(F))return F}return g(R,E,T)}}});var ui=P(xs=>{"use strict";global.Resource=xs.Resource=void 0;global.tables=xs.tables={};global.databases=xs.databases={};global.getUser=xs.getUser=void 0;global.authenticateUser=xs.authenticateUser=void 0;global.server=xs.server={};global.contentTypes=xs.contentTypes=null;global.threads=xs.threads=[];global.logger={};xs._assignPackageExport=(e,t)=>{global[e]=xs[e]=t}});var Fl={};Be(Fl,{server:()=>Ke});var uP,Ke,Pr=be(()=>{uP=M(ui()),Ke={};(0,uP._assignPackageExport)("server",Ke)});var $={};Be($,{AUTH_AUDIT_STATUS:()=>Bs,AUTH_AUDIT_TYPES:()=>zo,BOOT_PROPS_FILE_NAME:()=>_Q,BOOT_PROP_PARAMS:()=>_P,CLUSTERING_FLAG:()=>kQ,CLUSTERING_PROCESSES:()=>Xj,CLUSTER_MESSAGE_TYPE_ENUM:()=>cA,CLUSTER_OPERATIONS:()=>CQ,CONFIG_PARAMS:()=>B,CONFIG_PARAM_MAP:()=>hP,DATABASES_DIR_NAME:()=>cc,DATABASES_PARAM_CONFIG:()=>MQ,DEFAULT_DATABASE_NAME:()=>eQ,ESCAPED_FORWARD_SLASH_REGEX:()=>uQ,FORWARD_SLASH_REGEX:()=>cQ,FUNC_VAL:()=>KQ,GEO_CONVERSION_ENUM:()=>DQ,HDB_COMPONENT_CONFIG_FILE:()=>Kj,HDB_CONFIG_FILE:()=>$j,HDB_DEFAULT_CONFIG_FILE:()=>Vj,HDB_FILE_PERMISSIONS:()=>pQ,HDB_HOME_DIR_NAME:()=>fQ,HDB_PID_FILE:()=>Zj,HDB_PROCESS_SERVICES:()=>Jj,HDB_PROC_NAME:()=>Yj,HDB_RESTART_SCRIPT:()=>Wj,HDB_ROOT_DIR_NAME:()=>nA,HDB_SETTINGS_NAMES:()=>aA,HDB_SUPPORT_ADDRESS:()=>fP,INFO_TABLE_HASH_ATTRIBUTE:()=>AQ,INSERT_MAX_CHARACTER_SIZE:()=>SQ,INSTALL_PROMPTS:()=>gQ,ITC_EVENT_TYPES:()=>uA,JOB_STATUS_ENUM:()=>OQ,JOB_TYPE_ENUM:()=>vQ,JWT_ENUM:()=>jd,LAUNCH_SERVICE_SCRIPTS:()=>nQ,LEGACY_CONFIG_PARAMS:()=>LQ,LEGACY_DATABASES_DIR_NAME:()=>Np,LICENSE_FILE_NAME:()=>bQ,LICENSE_KEY_DIR_NAME:()=>oA,LICENSE_VALUES:()=>UQ,LOG_LEVELS:()=>rQ,LOG_NAMES:()=>tQ,MEM_SETTING_KEY:()=>dQ,METADATA_PROPERTY:()=>HQ,NODE_ERROR_CODES:()=>BQ,OPERATIONS_ENUM:()=>Yt,PERMS_CRUD_ENUM:()=>$Q,PERMS_UPDATE_RELEASE_TIMESTAMP:()=>qQ,PRE_4_0_0_VERSION:()=>YQ,PROCESS_DESCRIPTORS:()=>Qj,PROCESS_NAME_ENV_PROP:()=>EQ,RAM_ALLOCATION_ENUM:()=>xQ,READ_AUDIT_LOG_SEARCH_TYPES_ENUM:()=>Ip,REG_KEY_FILE_NAME:()=>yQ,RESTART_TIMEOUT_MS:()=>hQ,ROLE_TYPES_ENUM:()=>sQ,S3_BUCKET_AUTH_KEYS:()=>wQ,SEARCH_NOT_FOUND_MESSAGE:()=>oQ,SEARCH_WILDCARDS:()=>VQ,SERVICE_ACTIONS_ENUM:()=>PQ,SUPPORT_HELP_MSG:()=>iQ,SYSTEM_DEFAULT_ATTRIBUTE_NAMES:()=>RQ,SYSTEM_SCHEMA_NAME:()=>zd,SYSTEM_TABLE_NAMES:()=>Gl,THREAD_TYPES:()=>dA,TIME_STAMP_NAMES:()=>GQ,TIME_STAMP_NAMES_ENUM:()=>FQ,TRANSACTIONS_DIR_NAME:()=>mQ,UNICODE_FORWARD_SLASH:()=>lQ,UNICODE_PERIOD:()=>aQ,UPGRADE_JSON_FIELD_NAMES_ENUM:()=>TQ,VALID_S3_FILE_TYPES:()=>NQ,VALID_SQL_OPS_ENUM:()=>IQ,VALUE_SEARCH_COMPARATORS:()=>wp,VALUE_SEARCH_COMPARATORS_REVERSE_LOOKUP:()=>lA});var bp,Op,$j,Vj,nA,Kj,Yj,Wj,dP,rA,sA,iA,zj,jj,Qj,Jj,Xj,Zj,eQ,tQ,rQ,nQ,sQ,fP,iQ,oQ,aQ,cQ,lQ,uQ,dQ,zd,fQ,oA,_Q,hQ,pQ,cc,Np,mQ,EQ,_P,gQ,SQ,TQ,Gl,AQ,RQ,yQ,bQ,OQ,Yt,NQ,wQ,IQ,CQ,PQ,DQ,aA,LQ,B,hP,MQ,vQ,cA,UQ,xQ,BQ,HQ,kQ,pP,mP,FQ,GQ,qQ,wp,lA,$Q,VQ,KQ,Ip,jd,uA,dA,YQ,Bs,zo,G=be(()=>{bp=require("node:path"),Op=M(Et()),$j="harperdb-config.yaml",Vj="defaultConfig.yaml",nA="hdb",Kj="config.yaml",Yj="harperdb.js",Wj="restartHdb.js",dP="HarperDB",rA="Custom Functions",sA="Clustering Hub",iA="Clustering Leaf",zj="Clustering Ingest Service",jj="Clustering Reply Service",Qj={HDB:dP,CLUSTERING_HUB:sA,CLUSTERING_LEAF:iA,CLUSTERING_INGEST_SERVICE:zj,CLUSTERING_REPLY_SERVICE:jj,CUSTOM_FUNCTIONS:rA,RESTART_HDB:"Restart HDB",INSTALL:"Install",RUN:"Run",STOP:"Stop",UPGRADE:"Upgrade",REGISTER:"Register",JOB:"Job",CLUSTERING_UPGRADE_4_0_0:"Upgrade-4-0-0"},Jj={harperdb:dP,"clustering hub":sA,"clustering leaf":iA,"custom functions":rA,custom_functions:rA,clustering:"clustering","clustering config":"clustering config",clustering_config:"clustering_config",http_workers:"http_workers",http:"http"},Xj={CLUSTERING_HUB_PROC_DESCRIPTOR:sA,CLUSTERING_LEAF_PROC_DESCRIPTOR:iA},Zj="hdb.pid",eQ="data",tQ={HDB:"hdb.log",INSTALL:"install.log",CLUSTERING_HUB:"clustering_hub.log",CLUSTERING_LEAF:"clustering_leaf.log"},rQ={NOTIFY:"notify",FATAL:"fatal",ERROR:"error",WARN:"warn",INFO:"info",DEBUG:"debug",TRACE:"trace"},nQ={MAIN:"bin/harperdb.js",NATS_INGEST_SERVICE:(0,bp.join)(Op.PACKAGE_ROOT,"launchServiceScripts/launchNatsIngestService.js"),NATS_REPLY_SERVICE:(0,bp.join)(Op.PACKAGE_ROOT,"launchServiceScripts/launchNatsReplyService.js"),NODES_UPGRADE_4_0_0:(0,bp.join)(Op.PACKAGE_ROOT,"launchServiceScripts/launchUpdateNodes4-0-0.js")},sQ={SUPER_USER:"super_user",CLUSTER_USER:"cluster_user"},fP="support@harperdb.io",iQ=`For support, please submit a request at https://harperdbhelp.zendesk.com/hc/en-us/requests/new or contact ${fP}`,oQ="None of the specified records were found.",aQ="U+002E",cQ=/\//g,lQ="U+002F",uQ=/U\+002F/g,dQ="--max-old-space-size=",zd="system",fQ=".harperdb",oA="keys",_Q="hdb_boot_properties.file",hQ=6e4,pQ=448,cc="database",Np="schema",mQ="transactions",EQ="PROCESS_NAME",_P={SETTINGS_PATH_KEY:"settings_path"},gQ={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",CLUSTERING_NODENAME:"CLUSTERING_NODENAME",CLUSTERING_ENABLED:"CLUSTERING_ENABLED",HDB_CONFIG:"HDB_CONFIG",DEFAULTS_MODE:"DEFAULTS_MODE",REPLICATION_HOSTNAME:"REPLICATION_HOSTNAME",CLUSTERING_PORT:"CLUSTERING_PORT",HDB_ROOT:"HDB_ROOT",SERVER_PORT:"SERVER_PORT",NODE_NAME:"NODE_NAME",CLUSTERING:"CLUSTERING"},SQ=250,TQ={DATA_VERSION:"data_version",UPGRADE_VERSION:"upgrade_version"},Gl={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"},AQ="info_id",RQ={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"},yQ="060493.ks",bQ=".license",OQ={CREATED:"CREATED",IN_PROGRESS:"IN_PROGRESS",COMPLETE:"COMPLETE",ERROR:"ERROR"},Yt={INSERT:"insert",UPDATE:"update",UPSERT:"upsert",SEARCH_BY_CONDITIONS:"search_by_conditions",SEARCH_BY_HASH:"search_by_hash",SEARCH_BY_ID:"search_by_id",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_DATABASE:"create_database",CREATE_TABLE:"create_table",CREATE_ATTRIBUTE:"create_attribute",DROP_SCHEMA:"drop_schema",DROP_DATABASE:"drop_database",DROP_TABLE:"drop_table",DESCRIBE_SCHEMA:"describe_schema",DESCRIBE_DATABASE:"describe_database",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",SET_NODE_REPLICATION:"set_node_replication",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",CLUSTER_NETWORK:"cluster_network",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",LOGIN:"login",LOGOUT:"logout",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",GET_COMPONENTS:"get_components",GET_COMPONENT_FILE:"get_component_file",SET_COMPONENT_FILE:"set_component_file",DROP_COMPONENT:"drop_component",DROP_CUSTOM_FUNCTION:"drop_custom_function",ADD_CUSTOM_FUNCTION_PROJECT:"add_custom_function_project",ADD_COMPONENT:"add_component",DROP_CUSTOM_FUNCTION_PROJECT:"drop_custom_function_project",PACKAGE_CUSTOM_FUNCTION_PROJECT:"package_custom_function_project",DEPLOY_CUSTOM_FUNCTION_PROJECT:"deploy_custom_function_project",PACKAGE_COMPONENT:"package_component",DEPLOY_COMPONENT:"deploy_component",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",PURGE_STREAM:"purge_stream",GET_BACKUP:"get_backup",SIGN_CERTIFICATE:"sign_certificate",CREATE_CSR:"create_csr",LIST_CERTIFICATES:"list_certificates",ADD_CERTIFICATES:"add_certificate",REMOVE_CERTIFICATE:"remove_certificate",ADD_NODE_BACK:"add_node_back",REMOVE_NODE_BACK:"remove_node_back",ADD_SSH_KEY:"add_ssh_key",UPDATE_SSH_KEY:"update_ssh_key",DELETE_SSH_KEY:"delete_ssh_key",LIST_SSH_KEYS:"list_ssh_keys",SET_SSH_KNOWN_HOSTS:"set_ssh_known_hosts",GET_SSH_KNOWN_HOSTS:"get_ssh_known_hosts",GET_KEY:"get_key"},NQ={CSV:".csv",JSON:".json"},wQ={AWS_ACCESS_KEY:"aws_access_key_id",AWS_SECRET:"aws_secret_access_key",AWS_BUCKET:"bucket",AWS_FILE_KEY:"key",REGION:"region"},IQ={SELECT:"select",INSERT:"insert",UPDATE:"update",DELETE:"delete"},CQ={[Yt.INSERT]:Yt.INSERT,[Yt.UPDATE]:Yt.UPDATE,[Yt.UPSERT]:Yt.UPSERT,[Yt.DELETE]:Yt.DELETE},PQ={DEV:"dev",RUN:"run",START:"start",INSTALL:"install",REGISTER:"register",STOP:"stop",RESTART:"restart",VERSION:"version",UPGRADE:"upgrade",HELP:"help",STATUS:"status",OPERATION:"operation",RENEWCERTS:"renew-certs",COPYDB:"copy-db"},DQ={point:"point",lineString:"lineString",multiLineString:"multiLineString",multiPoint:"multiPoint",multiPolygon:"multiPolygon",polygon:"polygon"},aA={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",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"},LQ={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"},B={ANALYTICS_AGGREGATEPERIOD:"analytics_aggregatePeriod",AUTHENTICATION_AUTHORIZELOCAL:"authentication_authorizeLocal",AUTHENTICATION_CACHETTL:"authentication_cacheTTL",AUTHENTICATION_COOKIE_DOMAINS:"authentication_cookie_domains",AUTHENTICATION_COOKIE_EXPIRES:"authentication_cookie_expires",AUTHENTICATION_ENABLESESSIONS:"authentication_enableSessions",AUTHENTICATION_OPERATIONTOKENTIMEOUT:"authentication_operationTokenTimeout",AUTHENTICATION_REFRESHTOKENTIMEOUT:"authentication_refreshTokenTimeout",AUTHENTICATION_HASHFUNCTION:"authentication_hashFunction",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_LEAFSERVER_STREAMS_MAXAGE:"clustering_leafServer_streams_maxAge",CLUSTERING_LEAFSERVER_STREAMS_MAXBYTES:"clustering_leafServer_streams_maxBytes",CLUSTERING_LEAFSERVER_STREAMS_MAXMSGS:"clustering_leafServer_streams_maxMsgs",CLUSTERING_LEAFSERVER_STREAMS_MAXCONSUMEMSGS:"clustering_leafServer_streams_maxConsumeMsgs",CLUSTERING_LEAFSERVER_STREAMS_MAXINGESTTHREADS:"clustering_leafServer_streams_maxIngestThreads",CLUSTERING_LEAFSERVER_STREAMS_PATH:"clustering_leafServer_streams_path",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",CLUSTERING_TLS_VERIFY:"clustering_tls_verify",CLUSTERING_LOGLEVEL:"clustering_logLevel",CLUSTERING_REPUBLISHMESSAGES:"clustering_republishMessages",CLUSTERING_DATABASELEVEL:"clustering_databaseLevel",CUSTOMFUNCTIONS_NETWORK_HTTPS:"customFunctions_network_https",THREADS:"threads",THREADS_COUNT:"threads_count",THREADS_DEBUG:"threads_debug",THREADS_DEBUG_STARTINGPORT:"threads_debug_startingPort",THREADS_DEBUG_PORT:"threads_debug_port",THREADS_DEBUG_HOST:"threads_debug_host",THREADS_DEBUG_WAITFORDEBUGGER:"threads_debug_waitForDebugger",THREADS_MAXHEAPMEMORY:"threads_maxHeapMemory",HTTP_SESSIONAFFINITY:"http_sessionAffinity",HTTP_COMPRESSIONTHRESHOLD:"http_compressionThreshold",HTTP_CORS:"http_cors",HTTP_CORSACCESSLIST:"http_corsAccessList",HTTP_CORSACCESSCONTROLALLOWHEADERS:"http_corsAccessControlAllowHeaders",HTTP_HEADERSTIMEOUT:"http_headersTimeout",HTTP_KEEPALIVETIMEOUT:"http_keepAliveTimeout",HTTP_MAXPARAMLENGTH:"http_maxParamLength",HTTP_TIMEOUT:"http_timeout",HTTP_PORT:"http_port",HTTP_SECUREPORT:"http_securePort",HTTP_MTLS:"http_mtls",HTTP_MTLS_REQUIRED:"http_mtls_required",HTTP_MTLS_USER:"http_mtls_user",HTTP_MAXHEADERSIZE:"http_maxHeaderSize",HTTP_THREADRANGE:"http_threadRange",HTTP_HTTP2:"http_http2",LOCALSTUDIO_ENABLED:"localStudio_enabled",LOGGING_CONSOLE:"logging_console",LOGGING_FILE:"logging_file",LOGGING_LEVEL:"logging_level",LOGGING_ROOT:"logging_root",LOGGING_ROTATION_ENABLED:"logging_rotation_enabled",LOGGING_ROTATION_COMPRESS:"logging_rotation_compress",LOGGING_ROTATION_INTERVAL:"logging_rotation_interval",LOGGING_ROTATION_MAXSIZE:"logging_rotation_maxSize",LOGGING_ROTATION_PATH:"logging_rotation_path",LOGGING_ROTATION_RETENTION:"logging_rotation_retention",LOGGING_STDSTREAMS:"logging_stdStreams",LOGGING_AUDITLOG:"logging_auditLog",LOGGING_AUDITRETENTION:"logging_auditRetention",LOGGING_AUDITAUTHEVENTS_LOGFAILED:"logging_auditAuthEvents_logFailed",LOGGING_AUDITAUTHEVENTS_LOGSUCCESSFUL:"logging_auditAuthEvents_logSuccessful",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_NETWORK_DOMAINSOCKET:"operationsApi_network_domainSocket",OPERATIONSAPI_NETWORK_SECUREPORT:"operationsApi_network_securePort",OPERATIONSAPI_NETWORK_HTTP2:"operationsApi_network_http2",OPERATIONSAPI_TLS:"operationsApi_tls",OPERATIONSAPI_TLS_CERTIFICATE:"operationsApi_tls_certificate",OPERATIONSAPI_TLS_PRIVATEKEY:"operationsApi_tls_privateKey",OPERATIONSAPI_TLS_CERTIFICATEAUTHORITY:"operationsApi_tls_certificateAuthority",OPERATIONSAPI_NETWORK_TIMEOUT:"operationsApi_network_timeout",OPERATIONSAPI_SYSINFO_NETWORK:"operationsApi_sysInfo_network",OPERATIONSAPI_SYSINFO_DISK:"operationsApi_sysInfo_disk",REPLICATION:"replication",REPLICATION_HOSTNAME:"replication_hostname",REPLICATION_URL:"replication_url",REPLICATION_PORT:"replication_port",REPLICATION_SECUREPORT:"replication_securePort",REPLICATION_ROUTES:"replication_routes",REPLICATION_DATABASES:"replication_databases",REPLICATION_ENABLEROOTCAS:"replication_enableRootCAs",REPLICATION_SHARD:"replication_shard",REPLICATION_BLOBTIMEOUT:"replication_blobTimeout",ROOTPATH:"rootPath",SERIALIZATION_BIGINT:"serialization_bigInt",STORAGE_WRITEASYNC:"storage_writeAsync",STORAGE_OVERLAPPINGSYNC:"storage_overlappingSync",STORAGE_CACHING:"storage_caching",STORAGE_COMPRESSION:"storage_compression",STORAGE_NOREADAHEAD:"storage_noReadAhead",STORAGE_PREFETCHWRITES:"storage_prefetchWrites",STORAGE_ENCRYPTION:"storage_encryption",STORAGE_MAXTRANSACTIONQUEUETIME:"storage_maxTransactionQueueTime",STORAGE_PATH:"storage_path",STORAGE_BLOBPATHS:"storage_blobPaths",STORAGE_AUDIT_PATH:"storage_audit_path",STORAGE_MAXFREESPACETOLOAD:"storage_maxFreeSpaceToLoad",STORAGE_MAXFREESPACETORETAIN:"storage_maxFreeSpaceToRetain",STORAGE_PAGESIZE:"storage_pageSize",STORAGE_COMPRESSION_DICTIONARY:"storage_compression_dictionary",STORAGE_COMPRESSION_THRESHOLD:"storage_compression_threshold",STORAGE_COMPACTONSTART:"storage_compactOnStart",STORAGE_COMPACTONSTARTKEEPBACKUP:"storage_compactOnStartKeepBackup",STORAGE_RECLAMATION_THRESHOLD:"storage_reclamation_threshold",STORAGE_RECLAMATION_INTERVAL:"storage_reclamation_interval",STORAGE_RECLAMATION_EVICTIONFACTOR:"storage_reclamation_evictionFactor",DATABASES:"databases",IGNORE_SCRIPTS:"ignoreScripts",MQTT_NETWORK_PORT:"mqtt_network_port",MQTT_WEBSOCKET:"mqtt_webSocket",MQTT_NETWORK_SECUREPORT:"mqtt_network_securePort",MQTT_NETWORK_MTLS:"mqtt_network_mtls",MQTT_NETWORK_MTLS_REQUIRED:"mqtt_network_mtls_required",MQTT_NETWORK_MTLS_CERTIFICATEAUTHORITY:"mqtt_network_mtls_certificateAuthority",MQTT_NETWORK_MTLS_USER:"mqtt_network_mtls_user",MQTT_REQUIREAUTHENTICATION:"mqtt_requireAuthentication",COMPONENTSROOT:"componentsRoot",TLS_CERTIFICATE:"tls_certificate",TLS_PRIVATEKEY:"tls_privateKey",TLS_CERTIFICATEAUTHORITY:"tls_certificateAuthority",TLS_CIPHERS:"tls_ciphers",TLS:"tls",CLONED:"cloned"},hP={settings_path:_P.SETTINGS_PATH_KEY,hdb_root_key:B.ROOTPATH,hdb_root:B.ROOTPATH,rootpath:B.ROOTPATH,server_port_key:B.OPERATIONSAPI_NETWORK_PORT,server_port:B.OPERATIONSAPI_NETWORK_PORT,cert_key:B.TLS_CERTIFICATE,certificate:B.TLS_CERTIFICATE,private_key_key:B.TLS_PRIVATEKEY,private_key:B.TLS_PRIVATEKEY,http_secure_enabled_key:B.OPERATIONSAPI_NETWORK_HTTPS,https_on:B.OPERATIONSAPI_NETWORK_HTTPS,cors_enabled_key:B.OPERATIONSAPI_NETWORK_CORS,cors_on:B.OPERATIONSAPI_NETWORK_CORS,cors_whitelist_key:B.OPERATIONSAPI_NETWORK_CORSACCESSLIST,cors_whitelist:B.OPERATIONSAPI_NETWORK_CORSACCESSLIST,cors_accesslist_key:B.OPERATIONSAPI_NETWORK_CORSACCESSLIST,cors_accesslist:B.OPERATIONSAPI_NETWORK_CORSACCESSLIST,log_level_key:B.LOGGING_LEVEL,log_level:B.LOGGING_LEVEL,log_path_key:B.LOGGING_ROOT,log_path:B.LOGGING_ROOT,clustering_node_name_key:B.CLUSTERING_NODENAME,node_name:B.CLUSTERING_NODENAME,clustering_enabled_key:B.CLUSTERING_ENABLED,clustering:B.CLUSTERING_ENABLED,max_http_threads:B.THREADS_COUNT,max_hdb_processes:B.THREADS_COUNT,server_timeout_key:B.OPERATIONSAPI_NETWORK_TIMEOUT,server_timeout_ms:B.OPERATIONSAPI_NETWORK_TIMEOUT,server_keep_alive_timeout_key:B.OPERATIONSAPI_NETWORK_KEEPALIVETIMEOUT,server_keep_alive_timeout:B.OPERATIONSAPI_NETWORK_KEEPALIVETIMEOUT,server_headers_timeout_key:B.OPERATIONSAPI_NETWORK_HEADERSTIMEOUT,server_headers_timeout:B.OPERATIONSAPI_NETWORK_HEADERSTIMEOUT,disable_transaction_log_key:B.LOGGING_AUDITLOG,disable_transaction_log:B.LOGGING_AUDITLOG,operation_token_timeout_key:B.AUTHENTICATION_OPERATIONTOKENTIMEOUT,operation_token_timeout:B.AUTHENTICATION_OPERATIONTOKENTIMEOUT,refresh_token_timeout_key:B.AUTHENTICATION_REFRESHTOKENTIMEOUT,refresh_token_timeout:B.AUTHENTICATION_REFRESHTOKENTIMEOUT,custom_functions_port_key:B.HTTP_PORT,custom_functions_port:B.HTTP_PORT,custom_functions_directory_key:B.COMPONENTSROOT,custom_functions_directory:B.COMPONENTSROOT,max_custom_function_processes:B.THREADS_COUNT,logging_console:B.LOGGING_CONSOLE,log_to_file:B.LOGGING_FILE,log_to_stdstreams:B.LOGGING_STDSTREAMS,local_studio_on:B.LOCALSTUDIO_ENABLED,clustering_port:B.CLUSTERING_HUBSERVER_CLUSTER_NETWORK_PORT,clustering_user:B.CLUSTERING_USER,customfunctions_network_port:B.HTTP_PORT,customfunctions_tls_certificate:B.TLS_CERTIFICATE,customfunctions_network_cors:B.HTTP_CORS,customfunctions_network_corsaccesslist:B.HTTP_CORSACCESSLIST,customfunctions_network_headerstimeout:B.HTTP_HEADERSTIMEOUT,customfunctions_network_https:B.CUSTOMFUNCTIONS_NETWORK_HTTPS,customfunctions_network_keepalivetimeout:B.HTTP_KEEPALIVETIMEOUT,customfunctions_tls_privatekey:B.TLS_PRIVATEKEY,customfunctions_tls_certificateauthority:B.TLS_CERTIFICATEAUTHORITY,customfunctions_network_timeout:B.HTTP_TIMEOUT,customfunctions_tls:B.TLS,http_threads:B.THREADS_COUNT,threads:B.THREADS_COUNT,threads_count:B.THREADS_COUNT,customfunctions_processes:B.THREADS_COUNT,customfunctions_root:B.COMPONENTSROOT,operationsapi_root:B.ROOTPATH};for(let e in B){let t=B[e];hP[t.toLowerCase()]=t}MQ={TABLES:"tables",PATH:"path",AUDIT_PATH:"auditPath"},vQ={csv_file_load:"csv_file_load",csv_data_load:Yt.CSV_DATA_LOAD,csv_url_load:Yt.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",restart_service:"restart_service"},cA={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"},UQ={VERSION_DEFAULT:"2.2.0"},xQ={DEVELOPMENT:8192,DEFAULT:512},BQ={ENOENT:"ENOENT",EACCES:"EACCES",EEXIST:"EEXIST",ERR_INVALID_ARG_TYPE:"ERR_INVALID_ARG_TYPE"},HQ=Symbol("metadata"),kQ="__clustering__",pP="__createdtime__",mP="__updatedtime__",FQ={CREATED_TIME:pP,UPDATED_TIME:mP},GQ=[pP,mP],qQ=15984864e5,wp={LESS:"<",LESS_OR_EQ:"<=",GREATER:">",GREATER_OR_EQ:">=",BETWEEN:"..."},lA={"<":"LESS","<=":"LESS_OR_EQ",">":"GREATER",">=":"GREATER_OR_EQ","...":"BETWEEN"},$Q={READ:"read",INSERT:"insert",UPDATE:"update",DELETE:"delete"},VQ=["*","%"],KQ="func_val",Ip={HASH_VALUE:"hash_value",TIMESTAMP:"timestamp",USERNAME:"username"},jd={JWT_PRIVATE_KEY_NAME:".jwtPrivate.key",JWT_PUBLIC_KEY_NAME:".jwtPublic.key",JWT_PASSPHRASE_NAME:".jwtPass"},uA={SHUTDOWN:"shutdown",CHILD_STARTED:"child_started",CHILD_STOPPED:"child_stopped",SCHEMA:"schema",USER:"user",CLUSTER_STATUS_RESPONSE:"cluster_status_response",CLUSTER_STATUS_REQUEST:"cluster_status_request",METRICS:"metrics",GET_METRICS:"get_metrics",RESTART:"restart",START_JOB:"start_job",NATS_CONSUMER_UPDATE:"nats_consumer_update"},dA={HTTP:"http"},YQ="3.x.x",Bs={SUCCESS:"success",FAILURE:"failure"},zo={AUTHENTICATION:"authentication",AUTHORIZATION:"authorization"}});var lc=P((eAe,SP)=>{"use strict";var EP=require("minimist");SP.exports=WQ;function WQ(e=[],t=!1){if(!Array.isArray(e))return{};let r,n;t?(r=gP(process.env),n=gP(EP(process.argv))):(r=process.env,n=EP(process.argv));let s={};for(let i=0,o=e.length;i<o;i++){let c=e[i];n[c]!==void 0?s[c]=n[c].toString().trim():r[c]!==void 0&&(s[c]=r[c].toString().trim())}return s}a(WQ,"assignCMDENVVariables");function gP(e){let t,r=Object.keys(e),n=r.length,s={};for(;n--;)t=r[n],s[t.toLowerCase()]=e[t];return s}a(gP,"objKeysToLowerCase")});var X=P((vP,UP)=>{"use strict";var zi=require("fs-extra"),{workerData:zQ,threadId:jQ,isMainThread:QQ}=require("worker_threads"),fi=require("path"),yP=require("yaml"),bP=require("properties-reader"),Wt=(G(),D($)),TP=lc(),JQ=require("os"),{PACKAGE_ROOT:pA}=Et(),{_assignPackageExport:XQ}=ui(),AP=process.stdout.nativeWrite||(process.stdout.nativeWrite=process.stdout.write),hr={notify:7,fatal:6,error:5,warn:4,info:3,debug:2,trace:1},OP={STDOUT:"stdOut",STDERR:"stdErr"},ZQ=fi.join(pA,"logs"),e2=fi.join(pA,"config/yaml/",Wt.HDB_DEFAULT_CONFIG_FILE),t2=1e4,fA,di,as,Dr,Cp,Qd,Pp,jo,Jd;Jd===void 0&&NP();Object.assign(vP,{notify:DP,fatal:LP,error:Dp,warn:MP,info:IP,debug:PP,trace:CP,setLogLevel:l2,log_level:Dr,loggerWithTag:s2,suppressLogging:i2,initLogSettings:NP,logCustomLevel:a2,closeLogFile:mA,logsAtLevel:r2,getLogFilePath:a(()=>Pp,"getLogFilePath"),OUTPUTS:OP,AuthAuditLog:f2});XQ("logger",UP.exports);var _A;function r2(e){return hr[Dr]<=hr[e]}a(r2,"logsAtLevel");function NP(e=!1){try{if(Jd===void 0||e){mA();let t=c2(),r=TP(["ROOTPATH"]);try{Jd=bP(t)}catch(n){if(!r.ROOTPATH||r.ROOTPATH&&!zi.pathExistsSync(fi.join(r.ROOTPATH,Wt.HDB_CONFIG_FILE)))throw n}if({level:Dr,config_log_path:Qd,to_file:di,to_stream:as}=u2(r.ROOTPATH?fi.join(r.ROOTPATH,Wt.HDB_CONFIG_FILE):Jd.get("settings_path")),Cp=Wt.LOG_NAMES.HDB,Pp=fi.join(Qd,Cp),QQ)try{require("segfault-handler").registerHandler(fi.join(Qd,"crash.log"))}catch{}}}catch(t){if(Jd=void 0,t.code===Wt.NODE_ERROR_CODES.ENOENT||t.code===Wt.NODE_ERROR_CODES.ERR_INVALID_ARG_TYPE){let r=TP(Object.keys(Wt.CONFIG_PARAM_MAP),!0);for(let o in r){let c=Wt.CONFIG_PARAM_MAP[o];c&&c.toLowerCase();let l=r[o];if(c===Wt.CONFIG_PARAMS.LOGGING_LEVEL){Dr=l;continue}if(c===Wt.CONFIG_PARAMS.LOGGING_STDSTREAMS){as=l;continue}c===Wt.CONFIG_PARAMS.LOGGING_FILE&&(di=c),c===Wt.CONFIG_PARAMS.LOGGING_CONSOLE&&(fA=c)}let{default_level:n,default_to_file:s,default_to_stream:i}=d2();di=di===void 0?s:di,di=RP(di),as=as===void 0?i:as,as=RP(as),Dr=Dr===void 0?n:Dr,Qd=ZQ,Cp=Wt.LOG_NAMES.INSTALL,Pp=fi.join(Qd,Cp);return}throw Dp("Error initializing log settings"),Dp(t),t}process.env.DEV_MODE&&(as=!0),n2()}a(NP,"initLogSettings");var Qo=!0;function n2(){di&&(process.stdout.write=function(e){return typeof e=="string"&&Qo&&fA!==!1&&(hA(),e=e.toString(),e[e.length-1]===`
`&&(e=e.slice(0,-1)),zi.appendFileSync(jo,Hs("stdout",[e]))),AP.apply(process.stdout,arguments)},process.stderr.write=function(e){return typeof e=="string"&&Qo&&fA!==!1&&(hA(),e[e.length-1]===`
`&&(e=e.slice(0,-1)),zi.appendFileSync(jo,Hs("stderr",[e]))),AP.apply(process.stderr,arguments)})}a(n2,"stdioLogging");function s2(e,t){let r={tagName:e.replace(/ /g,"-")};return{notify:n(DP,"notify"),fatal:n(LP,"fatal"),error:n(Dp,"error"),warn:n(MP,"warn"),info:n(IP,"info"),debug:n(PP,"debug"),trace:n(CP,"trace")};function n(s,i){return!t||hr[Dr]<=hr[i]?function(...o){return s(r,...o)}:null}}a(s2,"loggerWithTag");function i2(e){try{Qo=!1,e()}finally{Qo=!0}}a(i2,"suppressLogging");var o2=zQ?.name?.replace(/ /g,"-")||"main";function Hs(e,t){let r=new Date(Date.now()).toISOString(),n="",s=t.length,i=s-1,o=[e],c=0,l;for(typeof t[0]=="object"&&(t[0]?.tagName?(o.push(t[0]?.tagName),c++):t[0]?.serviceName&&(l=t[0]?.serviceName,c++)),o.unshift(l||o2+"/"+jQ);c<s;c++){let u=t[c];if(u instanceof Error&&u.stack)n+=u.stack,Object.keys(u).length>0&&(n+=`
`+JSON.stringify(u)),u.cause&&(t[c--]=u.cause,u&&(n+=`
Caused by:`));else if(typeof u=="object")try{n+=JSON.stringify(u)}catch{n+="Object ["+Object.keys(u)+"]"}else n+=u;c<i&&(n+=" ")}return`${r} [${o.join("] [")}]: ${n}
`}a(Hs,"createLogRecord");function Xd(e){if(di){if(wP(e),as){Qo=!1;try{process.stdout.write(e)}finally{Qo=!0}}}else as&&process.stdout.write(e)}a(Xd,"logStdOut");function Lp(e){if(di){if(wP(e),as){Qo=!1;try{process.stderr.write(e)}finally{Qo=!0}}}else as&&process.stderr.write(e)}a(Lp,"logStdErr");function wP(e){hA(),jo?zi.appendFileSync(jo,e):_A||console.log(e)}a(wP,"logToFile");function mA(){try{zi.closeSync(jo)}catch{}jo=null}a(mA,"closeLogFile");function hA(){if(!jo){try{jo=zi.openSync(Pp,"a")}catch(e){_A||(_A=!0,console.error(e))}setTimeout(()=>{mA()},t2).unref()}}a(hA,"openLogFile");function IP(...e){hr[Dr]<=hr.info&&Xd(Hs("info",e))}a(IP,"info");function CP(...e){hr[Dr]<=hr.trace&&Xd(Hs("trace",e))}a(CP,"trace");function Dp(...e){hr[Dr]<=hr.error&&Lp(Hs("error",e))}a(Dp,"error");function PP(...e){hr[Dr]<=hr.debug&&Xd(Hs("debug",e))}a(PP,"debug");function DP(...e){hr[Dr]<=hr.notify&&Xd(Hs("notify",e))}a(DP,"notify");function LP(...e){hr[Dr]<=hr.fatal&&Lp(Hs("fatal",e))}a(LP,"fatal");function MP(...e){hr[Dr]<=hr.warn&&Lp(Hs("warn",e))}a(MP,"warn");function a2(e,t,...r){t===OP.STDERR?Lp(Hs(e,r)):Xd(Hs(e,r))}a(a2,"logCustomLevel");function c2(){let e;try{e=JQ.homedir()}catch{e=process.env.HOME}e||(e="~/");let t=fi.join(e,Wt.HDB_HOME_DIR_NAME,Wt.BOOT_PROPS_FILE_NAME);return zi.existsSync(t)||(t=fi.join(pA,"utility/hdb_boot_properties.file")),t}a(c2,"getPropsFilePath");function l2(e){Dr=e}a(l2,"setLogLevel");function RP(e){return e===!0||typeof e=="string"&&e.toLowerCase()==="true"}a(RP,"autoCastBoolean");function u2(e){try{if(e.includes("config/settings.js")){let o=bP(e);return{level:o.get(Wt.HDB_SETTINGS_NAMES.LOG_LEVEL_KEY),config_log_path:fi.dirname(o.get(Wt.HDB_SETTINGS_NAMES.LOG_PATH_KEY)),to_file:o.get(Wt.HDB_SETTINGS_NAMES.LOG_TO_FILE),to_stream:o.get(Wt.HDB_SETTINGS_NAMES.LOG_TO_STDSTREAMS)}}let t=yP.parseDocument(zi.readFileSync(e,"utf8")),r=t.getIn(["logging","level"]),n=t.getIn(["logging","root"]),s=t.getIn(["logging","file"]),i=t.getIn(["logging","stdStreams"]);return{level:r,config_log_path:n,to_file:s,to_stream:i}}catch(t){if(t.code===Wt.NODE_ERROR_CODES.ENOENT)throw t;console.error("Error accessing config file for logging"),console.error(t)}}a(u2,"getLogConfig");function d2(){try{let e=yP.parseDocument(zi.readFileSync(e2,"utf8")),t=e.getIn(["logging","level"]),r=e.getIn(["logging","file"]),n=e.getIn(["logging","stdStreams"]);return{default_level:t,default_to_file:r,default_to_stream:n}}catch(e){console.error("Error accessing default config file for logging"),console.error(e)}}a(d2,"getDefaultConfig");function f2(e,t,r,n,s,i){this.username=e,this.status=t,this.type=r,this.originating_ip=n,this.request_method=s,this.path=i}a(f2,"AuthAuditLog")});var EA=P((nAe,xP)=>{"use strict";var _2=require("util"),h2=require("path"),p2=require("child_process"),m2=_2.promisify(p2.execFile),E2=1e3*1e3*10;xP.exports={findPs:g2};async function g2(e){let t={};try{await Promise.all(["comm","args","ppid","uid","%cpu","%mem"].map(async r=>{let{stdout:n}=await m2("ps",["wwxo",`pid,${r}`],{maxBuffer:E2});for(let s of n.trim().split(`
`).slice(1)){s=s.trim();let[i]=s.split(" ",1),o=s.slice(i.length+1).trim();t[i]===void 0&&(t[i]={}),t[i][r]=o}}))}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,n])=>({pid:Number.parseInt(r,10),name:h2.basename(n.comm),cmd:n.args,ppid:Number.parseInt(n.ppid,10),uid:Number.parseInt(n.uid,10),cpu:Number.parseFloat(n["%cpu"]),memory:Number.parseFloat(n["%mem"])}))}a(g2,"findPs")});var Ft=P((iAe,HP)=>{"use strict";var S2="__dbis__",T2="__txns__",A2="__environment_name__",R2="__dbi_defintion__",y2={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"},b2=["__createdtime__","__updatedtime__"],O2="\uFFFF",BP={TIMESTAMP:"timestamp",HASH_VALUE:"hash_value",USER_NAME:"user_name"},N2=Object.values(BP);HP.exports={AUDIT_STORE_NAME:T2,INTERNAL_DBIS_NAME:S2,DBI_DEFINITION_NAME:R2,SEARCH_TYPES:y2,TIMESTAMP_NAMES:b2,MAX_SEARCH_KEY_LENGTH:256,ENVIRONMENT_NAME_KEY:A2,TRANSACTIONS_DBI_NAMES_ENUM:BP,TRANSACTIONS_DBIS:N2,OVERFLOW_MARKER:O2}});var Dn=P((oAe,WP)=>{"use strict";var kP=(G(),D($)),FP=Ft(),GP={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},qP=a(e=>`${e} Check logs and try again.`,"CHECK_LOGS_WRAPPER"),$P={500:qP("There was an error processing your request."),400:"Invalid request"},w2=$P[GP.INTERNAL_SERVER_ERROR],I2={OP_NOT_SUPPORTED_FOR_FS:a(e=>`${e} is not available for this instance because it uses the File System data store.`,"OP_NOT_SUPPORTED_FOR_FS"),MISSING_VALUE:a(e=>`${e} is missing.`,"MISSING_VALUE"),INVALID_VALUE:a(e=>`${e} is invalid.`,"INVALID_VALUE"),NOT_FOUND:a(e=>`${e} not found.`,"NOT_FOUND")},C2={CONFIG_VALIDATION:a(e=>`HarperDB config file validation error: ${e}`,"CONFIG_VALIDATION")},P2={DEFAULT_BULK_LOAD_ERR:"There was an error during your bulk load into HarperDB.",DOWNLOAD_FILE_ERR:a(e=>`There was an error downloading '${e}'.`,"DOWNLOAD_FILE_ERR"),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:a(e=>`Bulk load operation failed - ${e} is not a valid 'action' parameter`,"INVALID_ACTION_PARAM_ERR"),INVALID_FILE_EXT_ERR:a(e=>`Error selecting correct parser - valid file type not found in json - ${e}`,"INVALID_FILE_EXT_ERR"),MAX_FILE_SIZE_ERR:a((e,t)=>`File size is ${e} bytes, which exceeded the maximum size allowed of: ${t} bytes`,"MAX_FILE_SIZE_ERR"),PAPA_PARSE_ERR:"There was an error parsing the downloaded CSV data.",S3_DOWNLOAD_ERR:a(e=>`There was an error downloading '${e}' from AWS.`,"S3_DOWNLOAD_ERR"),WRITE_TEMP_FILE_ERR:"Error writing temporary file to storage"},D2={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_ITERABLE:"ids must be iterable",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 ${FP.INTERNAL_DBIS_NAME}`,CANNOT_DROP_INTERNAL_DBIS_NAME:`cannot drop a dbi named ${FP.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"},L2={ATTR_NAME_LENGTH_ERR:a(e=>`transaction aborted due to attribute name ${e} being too long. Attribute names cannot be longer than ${kP.INSERT_MAX_CHARACTER_SIZE} bytes.`,"ATTR_NAME_LENGTH_ERR"),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 ${kP.INSERT_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"},VP={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"},M2={DEFAULT_INVALID_REQUEST:"Invalid request",OP_AUTH_PERMS_ERROR:"This operation is not authorized due to role restrictions and/or invalid database items",OP_IS_SU_ONLY:a(e=>`Operation '${e}' is restricted to 'super_user' roles`,"OP_IS_SU_ONLY"),OP_NOT_FOUND:a(e=>`Operation '${e}' not found`,"OP_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:a((e,t,r)=>`There was an error authorizing ${e} op on table '${t}.${r}'`,"UNKNOWN_OP_AUTH_ERROR"),USER_HAS_NO_PERMS:a(e=>`User ${e} has no role or permissions. Please assign the user a valid role.`,"USER_HAS_NO_PERMS"),DROP_SYSTEM:"The 'system' database, tables and records are used internally by HarperDB and cannot be updated or removed."},v2={ATTR_PERM_MISSING:a((e,t)=>`${e.toUpperCase()} attribute permission missing for '${t}'`,"ATTR_PERM_MISSING"),ATTR_PERM_MISSING_NAME:"Permission object in 'attribute_permission' missing an 'attribute_name'",ATTR_PERM_NOT_BOOLEAN:a((e,t)=>`${e.toUpperCase()} attribute permission for '${t}' must be a boolean`,"ATTR_PERM_NOT_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:a(e=>`Invalid attribute '${e}' in 'attribute_permissions'`,"INVALID_ATTRIBUTE_IN_PERMS"),INVALID_PERM_KEY:a(e=>`Invalid table permission key value '${e}'`,"INVALID_PERM_KEY"),INVALID_ATTR_PERM_KEY:a(e=>`Invalid attribute permission key value '${e}'`,"INVALID_ATTR_PERM_KEY"),INVALID_ROLE_JSON_KEYS:a(e=>`Invalid ${e.length>1?"keys":"key"} in JSON body - '${e.join("', '")}'`,"INVALID_ROLE_JSON_KEYS"),MISMATCHED_TABLE_ATTR_PERMS:a(e=>`You have a conflict with TABLE permissions for '${e}' being false and ATTRIBUTE permissions being true`,"MISMATCHED_TABLE_ATTR_PERMS"),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:a(e=>`A role with name '${e}' already exists`,"ROLE_ALREADY_EXISTS"),ROLE_NOT_FOUND:"Role not found",ROLE_PERMS_ERROR:"Errors in the role permissions JSON provided",SCHEMA_PERM_ERROR:a(e=>`Your role does not have permission to view database metadata for '${e}'`,"SCHEMA_PERM_ERROR"),SCHEMA_TABLE_PERM_ERROR:a((e,t)=>`Your role does not have permission to view database.table metadata for '${e}.${t}'`,"SCHEMA_TABLE_PERM_ERROR"),SU_ROLE_MISSING_ERROR:"Missing 'super_user' key/value in permission set",SU_CU_ROLE_BOOLEAN_ERROR:a(e=>`Value for '${e}' permission must be a boolean`,"SU_CU_ROLE_BOOLEAN_ERROR"),STRUCTURE_USER_ROLE_TYPE_ERROR:a(e=>`Value for '${e}' permission must be a boolean or Array`,"STRUCTURE_USER_ROLE_TYPE_ERROR"),SU_CU_ROLE_NO_PERMS_ALLOWED:a(e=>`Roles with '${e}' set to true cannot have other permissions set.`,"SU_CU_ROLE_NO_PERMS_ALLOWED"),SU_CU_ROLE_COMBINED_ERROR:"Roles cannot have both 'super_user' and 'cluster_user' values included in their permissions set.",TABLE_PERM_MISSING:a(e=>`Missing table ${e.toUpperCase()} permission`,"TABLE_PERM_MISSING"),TABLE_PERM_NOT_BOOLEAN:a(e=>`Table ${e.toUpperCase()} permission must be a boolean`,"TABLE_PERM_NOT_BOOLEAN")},U2={ATTR_NOT_FOUND:a((e,t,r)=>`Attribute '${r}' does not exist on '${e}.${t}'`,"ATTR_NOT_FOUND"),ATTR_EXISTS_ERR:a((e,t,r)=>`Attribute '${r}' already exists in ${e}.${t}'`,"ATTR_EXISTS_ERR"),DESCRIBE_ALL_ERR:"There was an error during describeAll. Please check the logs and try again.",INVALID_TABLE_ERR:a(e=>`Invalid table ${JSON.stringify(e)}`,"INVALID_TABLE_ERR"),SCHEMA_NOT_FOUND:a(e=>`database '${e}' does not exist`,"SCHEMA_NOT_FOUND"),SCHEMA_EXISTS_ERR:a(e=>`database '${e}' already exists`,"SCHEMA_EXISTS_ERR"),TABLE_EXISTS_ERR:a((e,t)=>`Table '${t}' already exists in '${e}'`,"TABLE_EXISTS_ERR"),SCHEMA_REQUIRED_ERR:"database is required",TABLE_NOT_FOUND:a((e,t)=>`Table '${e}.${t}' does not exist`,"TABLE_NOT_FOUND"),TABLE_REQUIRED_ERR:"table is required"},x2={OUTER_JOIN_TRANSLATION_ERROR:"There was an error translating the final SQL outer join data."},B2={ALTER_USER_DUP_ROLES:a(e=>`Update failed. There are duplicates for the '${e}' role which is not allowed. Update your roles and try again.`,"ALTER_USER_DUP_ROLES"),ALTER_USER_ROLE_NOT_FOUND:a(e=>`Update failed. Requested '${e}' role not found.`,"ALTER_USER_ROLE_NOT_FOUND"),DUP_ROLES_FOUND:a(e=>`Multiple ${e} roles found. Roles must have unique 'role' value. Please update and try again.`,"DUP_ROLES_FOUND"),ROLE_NAME_NOT_FOUND:a(e=>`${e} role not found`,"ROLE_NAME_NOT_FOUND"),USER_ALREADY_EXISTS:a(e=>`User ${e} already exists`,"USER_ALREADY_EXISTS"),USER_NOT_EXIST:a(e=>`User ${e} does not exist`,"USER_NOT_EXIST")},KP={INVALID_DATE:"Invalid date, must be in ISO-8601 format (YYYY-MM-DD).",SEARCH_CONDITIONS_INVALID_SORT_ATTRIBUTE:a(e=>`invalid sort attribute '${e}', the attribute must either be the table's hash attribute or an attribute used in conditions.`,"SEARCH_CONDITIONS_INVALID_SORT_ATTRIBUTE")},YP={INVALID_ITC_DATA_TYPE:"Invalid ITC event data type, must be an object",MISSING_TYPE:"ITC event missing 'type'",MISSING_MSG:"ITC event missing 'message'",MISSING_ORIGIN:"ITC event message missing 'originator' property",INVALID_EVENT:a(e=>`ITC server received invalid event type: ${e}`,"INVALID_EVENT")},H2={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 fastifyRoutes enabled to true in hdb/harperdb-config.yaml file.",BAD_SSH_KEY_NAME:"SSH key name can only contain alphanumeric, dash and underscore characters"},k2={CLUSTERING_NOT_ENABLED:"Clustering must be enabled to perform this operation."},F2={...VP,...P2,...I2,...M2,...v2,...U2,...x2,...B2,...L2,...KP,...YP,...H2,...k2,...C2};WP.exports={CHECK_LOGS_WRAPPER:qP,HDB_ERROR_MSGS:F2,DEFAULT_ERROR_MSGS:$P,DEFAULT_ERROR_RESP:w2,HTTP_STATUS_CODES:GP,LMDB_ERRORS_ENUM:D2,AUTHENTICATION_ERROR_MSGS:VP,VALIDATION_ERROR_MSGS:KP,ITC_ERRORS:YP}});var he=P((cAe,QP)=>{"use strict";var ql=Dn(),G2=X(),q2=(G(),D($)),Mp=class extends Error{static{a(this,"HdbError")}constructor(t,r,n,s,i){super(),Error.captureStackTrace(this,zP),this.statusCode=n||ql.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR,this.http_resp_msg=r||(ql.DEFAULT_ERROR_MSGS[n]?ql.DEFAULT_ERROR_MSGS[n]:ql.DEFAULT_ERROR_MSGS[ql.HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR]),this.message=t.message?t.message:this.http_resp_msg,this.type=t.name,s&&(this.logLevel=s),typeof this.message!="string"&&(this.stack=t.stack),i&&G2[s](i)}},gA=class extends Error{static{a(this,"ClientError")}constructor(t,r){if(t instanceof Error)return t.statusCode=r||400,t;super(t),this.statusCode=r||400}},SA=class extends Error{static{a(this,"ServerError")}constructor(t,r){super(t),this.statusCode=r||500}};function zP(e,t,r,n=q2.LOG_LEVELS.ERROR,s=null,i=!1){if(jP(e))return e;let o=new Mp(e,t,r,n,s);return i&&delete o.stack,o}a(zP,"handleHDBError");function jP(e){return e.__proto__.constructor.name===Mp.name}a(jP,"isHDBError");QP.exports={isHDBError:jP,handleHDBError:zP,ClientError:gA,ServerError:SA,hdb_errors:ql}});var gt=P((uAe,nD)=>{"use strict";var nf=(G(),D($)),$2=oe(),on=ce(),sf=require("path"),V2=require("minimist"),JP=require("fs-extra"),XP=require("lodash");on.initSync(