@harperfast/harper 5.0.0-alpha.10 → 5.0.0-beta.1
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/bin/BinObjects.js +17 -0
- package/bin/cliOperations.js +157 -0
- package/bin/copyDb.ts +280 -0
- package/bin/harper.js +156 -0
- package/bin/install.js +15 -0
- package/bin/lite.js +5 -0
- package/bin/restart.js +201 -0
- package/bin/run.js +409 -0
- package/bin/status.js +65 -0
- package/bin/stop.js +22 -0
- package/bin/upgrade.js +134 -0
- package/components/Application.ts +646 -0
- package/components/ApplicationScope.ts +49 -0
- package/components/Component.ts +53 -0
- package/components/ComponentV1.ts +342 -0
- package/components/DEFAULT_CONFIG.ts +18 -0
- package/components/EntryHandler.ts +227 -0
- package/components/Logger.ts +14 -0
- package/components/OptionsWatcher.ts +354 -0
- package/components/PluginModule.ts +6 -0
- package/components/Scope.ts +329 -0
- package/components/componentLoader.ts +529 -0
- package/components/deriveCommonPatternBase.ts +31 -0
- package/components/deriveGlobOptions.ts +44 -0
- package/components/deriveURLPath.ts +57 -0
- package/components/operations.js +658 -0
- package/components/operationsValidation.js +246 -0
- package/components/packageComponent.ts +39 -0
- package/components/requestRestart.ts +26 -0
- package/components/resolveBaseURLPath.ts +38 -0
- package/components/status/ComponentStatus.ts +110 -0
- package/components/status/ComponentStatusRegistry.ts +251 -0
- package/components/status/api.ts +153 -0
- package/components/status/crossThread.ts +405 -0
- package/components/status/errors.ts +152 -0
- package/components/status/index.ts +44 -0
- package/components/status/internal.ts +65 -0
- package/components/status/registry.ts +12 -0
- package/components/status/types.ts +96 -0
- package/config/RootConfigWatcher.ts +59 -0
- package/config/configHelpers.ts +11 -0
- package/config/configUtils.js +967 -0
- package/config/harperConfigEnvVars.ts +641 -0
- package/dataLayer/CreateAttributeObject.js +25 -0
- package/dataLayer/CreateTableObject.js +11 -0
- package/dataLayer/DataLayerObjects.js +43 -0
- package/dataLayer/DeleteBeforeObject.js +22 -0
- package/dataLayer/DeleteObject.js +25 -0
- package/dataLayer/DropAttributeObject.js +11 -0
- package/dataLayer/GetBackupObject.js +22 -0
- package/dataLayer/InsertObject.js +24 -0
- package/dataLayer/ReadAuditLogObject.js +24 -0
- package/dataLayer/SQLSearch.js +1335 -0
- package/dataLayer/SearchByConditionsObject.js +61 -0
- package/dataLayer/SearchByHashObject.js +21 -0
- package/dataLayer/SearchObject.js +45 -0
- package/dataLayer/SqlSearchObject.js +14 -0
- package/dataLayer/UpdateObject.js +23 -0
- package/dataLayer/UpsertObject.js +23 -0
- package/dataLayer/bulkLoad.js +813 -0
- package/dataLayer/dataObjects/BulkLoadObjects.js +27 -0
- package/dataLayer/dataObjects/UpsertObject.js +23 -0
- package/dataLayer/delete.js +164 -0
- package/dataLayer/export.js +381 -0
- package/dataLayer/getBackup.js +40 -0
- package/dataLayer/harperBridge/BridgeMethods.js +81 -0
- package/dataLayer/harperBridge/ResourceBridge.ts +633 -0
- package/dataLayer/harperBridge/bridgeUtility/insertUpdateReturnObj.js +28 -0
- package/dataLayer/harperBridge/bridgeUtility/insertUpdateValidate.js +88 -0
- package/dataLayer/harperBridge/harperBridge.js +21 -0
- package/dataLayer/harperBridge/lmdbBridge/LMDBBridge.js +119 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js +19 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.js +112 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.js +67 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateSchema.js +31 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateTable.js +94 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteAuditLogsBefore.js +98 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteRecords.js +89 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.js +109 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropSchema.js +107 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropTable.js +137 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbFlush.js +35 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetBackup.js +111 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByHash.js +28 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByValue.js +29 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbReadAuditLog.js +207 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.js +156 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByHash.js +21 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.js +30 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbTransaction.js +19 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpdateRecords.js +64 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.js +70 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.js +22 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBDeleteTransactionObject.js +23 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBInsertTransactionObject.js +22 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBTransactionObject.js +23 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBUpdateTransactionObject.js +24 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBUpsertTransactionObject.js +24 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.js +25 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializeHashSearch.js +21 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializePaths.js +157 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCheckForNewAttributes.js +94 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsAuditEnvironment.js +39 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js +34 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.js +100 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbSearch.js +371 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbWriteTransaction.js +109 -0
- package/dataLayer/hdbInfoController.js +254 -0
- package/dataLayer/insert.js +266 -0
- package/dataLayer/readAuditLog.js +59 -0
- package/dataLayer/schema.js +366 -0
- package/dataLayer/schemaDescribe.js +289 -0
- package/dataLayer/search.js +60 -0
- package/dataLayer/transaction.js +17 -0
- package/dataLayer/update.js +124 -0
- package/dist/components/Logger.d.ts +12 -0
- package/dist/components/Logger.js +3 -0
- package/dist/components/Logger.js.map +1 -0
- package/dist/components/Scope.d.ts +14 -4
- package/dist/components/Scope.js +18 -10
- package/dist/components/Scope.js.map +1 -1
- package/dist/components/componentLoader.js +16 -9
- package/dist/components/componentLoader.js.map +1 -1
- package/dist/components/operations.js +2 -2
- package/dist/components/operations.js.map +1 -1
- package/dist/config/configUtils.d.ts +1 -1
- package/dist/config/configUtils.js +1 -1
- package/dist/config/configUtils.js.map +1 -1
- package/dist/dataLayer/CreateTableObject.d.ts +2 -2
- package/dist/dataLayer/CreateTableObject.js +2 -2
- package/dist/dataLayer/CreateTableObject.js.map +1 -1
- package/dist/dataLayer/delete.d.ts +1 -1
- package/dist/dataLayer/schema.js +6 -5
- package/dist/dataLayer/schema.js.map +1 -1
- package/dist/dataLayer/schemaDescribe.js +1 -1
- package/dist/dataLayer/schemaDescribe.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/DatabaseTransaction.d.ts +1 -1
- package/dist/resources/IterableEventQueue.d.ts +1 -1
- package/dist/resources/LMDBTransaction.d.ts +5 -1
- package/dist/resources/Resource.d.ts +1 -1
- package/dist/resources/RocksIndexStore.d.ts +3 -3
- package/dist/resources/RocksTransactionLogStore.d.ts +6 -3
- package/dist/resources/Table.d.ts +15 -6
- package/dist/resources/Table.js +4 -1
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/analytics/read.js +32 -22
- package/dist/resources/analytics/read.js.map +1 -1
- package/dist/resources/analytics/write.js +3 -6
- package/dist/resources/analytics/write.js.map +1 -1
- package/dist/resources/auditStore.d.ts +3 -3
- package/dist/resources/blob.d.ts +25 -2
- package/dist/resources/databases.d.ts +12 -2
- package/dist/resources/databases.js +22 -19
- package/dist/resources/databases.js.map +1 -1
- package/dist/resources/search.js +11 -5
- package/dist/resources/search.js.map +1 -1
- package/dist/resources/transaction.d.ts +2 -1
- package/dist/security/auth.js +1 -1
- package/dist/security/auth.js.map +1 -1
- package/dist/security/cryptoHash.d.ts +2 -2
- package/dist/security/jsLoader.js +243 -66
- package/dist/security/jsLoader.js.map +1 -1
- package/dist/security/keys.js +4 -5
- package/dist/security/keys.js.map +1 -1
- package/dist/security/user.js +3 -3
- package/dist/security/user.js.map +1 -1
- package/dist/server/REST.js +16 -2
- package/dist/server/REST.js.map +1 -1
- package/dist/server/Server.d.ts +2 -1
- package/dist/server/Server.js.map +1 -1
- package/dist/server/fastifyRoutes/plugins/hdbCore.d.ts +6 -1
- package/dist/server/fastifyRoutes.js +2 -0
- package/dist/server/fastifyRoutes.js.map +1 -1
- package/dist/server/http.js +12 -6
- package/dist/server/http.js.map +1 -1
- package/dist/server/jobs/JobObject.d.ts +3 -3
- package/dist/server/loadRootComponents.js +1 -0
- package/dist/server/loadRootComponents.js.map +1 -1
- package/dist/server/operationsServer.js +3 -1
- package/dist/server/operationsServer.js.map +1 -1
- package/dist/server/serverHelpers/JSONStream.d.ts +3 -3
- package/dist/server/serverHelpers/Request.d.ts +5 -5
- package/dist/server/serverHelpers/requestTimePlugin.d.ts +1 -1
- package/dist/server/threads/manageThreads.d.ts +2 -2
- package/dist/server/threads/manageThreads.js +50 -35
- package/dist/server/threads/manageThreads.js.map +1 -1
- package/dist/server/threads/socketRouter.d.ts +1 -1
- package/dist/sqlTranslator/deleteTranslator.d.ts +1 -1
- package/dist/utility/AWS/AWSConnector.d.ts +3 -2
- package/dist/utility/common_utils.d.ts +3 -3
- package/dist/utility/environment/systemInformation.d.ts +1 -0
- package/dist/utility/functions/date/dateFunctions.d.ts +11 -11
- package/dist/utility/globalSchema.d.ts +1 -1
- package/dist/utility/hdbTerms.d.ts +3 -0
- package/dist/utility/hdbTerms.js +3 -0
- package/dist/utility/hdbTerms.js.map +1 -1
- package/dist/utility/installation.d.ts +2 -4
- package/dist/utility/installation.js.map +1 -1
- package/dist/utility/lmdb/commonUtility.d.ts +1 -0
- package/dist/utility/lmdb/deleteUtility.d.ts +1 -0
- package/dist/utility/lmdb/environmentUtility.d.ts +1 -0
- package/dist/utility/lmdb/searchUtility.d.ts +2 -1
- package/dist/utility/lmdb/writeUtility.d.ts +1 -0
- package/dist/utility/logging/harper_logger.d.ts +6 -6
- package/dist/utility/processManagement/processManagement.d.ts +1 -1
- package/dist/utility/processManagement/servicesConfig.d.ts +12 -6
- package/dist/validation/common_validators.d.ts +4 -3
- package/dist/validation/configValidator.d.ts +3 -2
- package/index.d.ts +56 -0
- package/index.js +41 -0
- package/json/systemSchema.json +373 -0
- package/launchServiceScripts/launchHarperDB.js +3 -0
- package/launchServiceScripts/utility/checkNodeVersion.js +15 -0
- package/package.json +21 -3
- package/resources/DatabaseTransaction.ts +378 -0
- package/resources/ErrorResource.ts +57 -0
- package/resources/IterableEventQueue.ts +94 -0
- package/resources/LMDBTransaction.ts +349 -0
- package/resources/RecordEncoder.ts +702 -0
- package/resources/RequestTarget.ts +134 -0
- package/resources/Resource.ts +789 -0
- package/resources/ResourceInterface.ts +221 -0
- package/resources/ResourceInterfaceV2.ts +53 -0
- package/resources/ResourceV2.ts +67 -0
- package/resources/Resources.ts +162 -0
- package/resources/RocksIndexStore.ts +70 -0
- package/resources/RocksTransactionLogStore.ts +352 -0
- package/resources/Table.ts +4527 -0
- package/resources/analytics/hostnames.ts +72 -0
- package/resources/analytics/metadata.ts +10 -0
- package/resources/analytics/read.ts +252 -0
- package/resources/analytics/write.ts +803 -0
- package/resources/auditStore.ts +556 -0
- package/resources/blob.ts +1268 -0
- package/resources/crdt.ts +125 -0
- package/resources/dataLoader.ts +527 -0
- package/resources/databases.ts +1290 -0
- package/resources/graphql.ts +221 -0
- package/resources/indexes/HierarchicalNavigableSmallWorld.ts +638 -0
- package/resources/indexes/customIndexes.ts +7 -0
- package/resources/indexes/vector.ts +38 -0
- package/resources/jsResource.ts +86 -0
- package/resources/loadEnv.ts +22 -0
- package/resources/login.ts +18 -0
- package/resources/openApi.ts +409 -0
- package/resources/registrationDeprecated.ts +8 -0
- package/resources/replayLogs.ts +136 -0
- package/resources/roles.ts +98 -0
- package/resources/search.ts +1301 -0
- package/resources/tracked.ts +584 -0
- package/resources/transaction.ts +89 -0
- package/resources/transactionBroadcast.ts +258 -0
- package/security/auth.ts +376 -0
- package/security/certificateVerification/certificateVerificationSource.ts +84 -0
- package/security/certificateVerification/configValidation.ts +107 -0
- package/security/certificateVerification/crlVerification.ts +623 -0
- package/security/certificateVerification/index.ts +121 -0
- package/security/certificateVerification/ocspVerification.ts +148 -0
- package/security/certificateVerification/pkijs-ed25519-patch.ts +188 -0
- package/security/certificateVerification/types.ts +128 -0
- package/security/certificateVerification/verificationConfig.ts +138 -0
- package/security/certificateVerification/verificationUtils.ts +447 -0
- package/security/cryptoHash.js +42 -0
- package/security/data_objects/PermissionAttributeResponseObject.js +15 -0
- package/security/data_objects/PermissionResponseObject.js +115 -0
- package/security/data_objects/PermissionTableResponseObject.js +20 -0
- package/security/fastifyAuth.js +169 -0
- package/security/impersonation.ts +160 -0
- package/security/jsLoader.ts +716 -0
- package/security/keys.js +948 -0
- package/security/permissionsTranslator.js +300 -0
- package/security/role.js +218 -0
- package/security/tokenAuthentication.ts +228 -0
- package/security/user.ts +449 -0
- package/server/DurableSubscriptionsSession.ts +503 -0
- package/server/REST.ts +407 -0
- package/server/Server.ts +89 -0
- package/server/fastifyRoutes/helpers/getCORSOptions.js +36 -0
- package/server/fastifyRoutes/helpers/getHeaderTimeoutConfig.js +15 -0
- package/server/fastifyRoutes/helpers/getServerOptions.js +33 -0
- package/server/fastifyRoutes/plugins/hdbCore.js +39 -0
- package/server/fastifyRoutes.ts +205 -0
- package/server/graphqlQuerying.ts +700 -0
- package/server/http.ts +640 -0
- package/server/itc/serverHandlers.js +161 -0
- package/server/itc/utility/ITCEventObject.js +10 -0
- package/server/jobs/JobObject.js +24 -0
- package/server/jobs/jobProcess.js +69 -0
- package/server/jobs/jobRunner.js +162 -0
- package/server/jobs/jobs.js +304 -0
- package/server/loadRootComponents.js +44 -0
- package/server/mqtt.ts +485 -0
- package/server/nodeName.ts +75 -0
- package/server/operationsServer.ts +313 -0
- package/server/serverHelpers/Headers.ts +108 -0
- package/server/serverHelpers/JSONStream.ts +269 -0
- package/server/serverHelpers/OperationFunctionObject.ts +13 -0
- package/server/serverHelpers/Request.ts +158 -0
- package/server/serverHelpers/contentTypes.ts +637 -0
- package/server/serverHelpers/requestTimePlugin.js +57 -0
- package/server/serverHelpers/serverHandlers.js +148 -0
- package/server/serverHelpers/serverUtilities.ts +473 -0
- package/server/serverRegistry.ts +8 -0
- package/server/static.ts +187 -0
- package/server/status/definitions.ts +37 -0
- package/server/status/index.ts +125 -0
- package/server/storageReclamation.ts +93 -0
- package/server/threads/itc.js +89 -0
- package/server/threads/manageThreads.js +594 -0
- package/server/threads/socketRouter.ts +360 -0
- package/server/threads/threadServer.js +279 -0
- package/server/throttle.ts +73 -0
- package/sqlTranslator/SelectValidator.js +330 -0
- package/sqlTranslator/alasqlFunctionImporter.js +62 -0
- package/sqlTranslator/deleteTranslator.js +67 -0
- package/sqlTranslator/index.js +242 -0
- package/sqlTranslator/sql_statement_bucket.js +472 -0
- package/static/defaultConfig.yaml +3 -0
- package/studio/web/HDBDogOnly.svg +78 -0
- package/studio/web/assets/PPRadioGrotesk-Bold-DDaUYG8E.woff +0 -0
- package/studio/web/assets/fa-brands-400-CEJbCg16.woff +0 -0
- package/studio/web/assets/fa-brands-400-CSYNqBb_.ttf +0 -0
- package/studio/web/assets/fa-brands-400-DnkPfk3o.eot +0 -0
- package/studio/web/assets/fa-brands-400-UxlILjvJ.woff2 +0 -0
- package/studio/web/assets/fa-brands-400-cH1MgKbP.svg +3717 -0
- package/studio/web/assets/fa-regular-400-BhTwtT8w.eot +0 -0
- package/studio/web/assets/fa-regular-400-D1vz6WBx.ttf +0 -0
- package/studio/web/assets/fa-regular-400-DFnMcJPd.woff +0 -0
- package/studio/web/assets/fa-regular-400-DGzu1beS.woff2 +0 -0
- package/studio/web/assets/fa-regular-400-gwj8Pxq-.svg +801 -0
- package/studio/web/assets/fa-solid-900-B4ZZ7kfP.svg +5034 -0
- package/studio/web/assets/fa-solid-900-B6Axprfb.eot +0 -0
- package/studio/web/assets/fa-solid-900-BUswJgRo.woff2 +0 -0
- package/studio/web/assets/fa-solid-900-DOXgCApm.woff +0 -0
- package/studio/web/assets/fa-solid-900-mxuxnBEa.ttf +0 -0
- package/studio/web/assets/index-BTgXJX9d.js +235 -0
- package/studio/web/assets/index-BTgXJX9d.js.map +1 -0
- package/studio/web/assets/index-C-GXfcup.js +37 -0
- package/studio/web/assets/index-C-GXfcup.js.map +1 -0
- package/studio/web/assets/index-PFlNdimM.js +2 -0
- package/studio/web/assets/index-PFlNdimM.js.map +1 -0
- package/studio/web/assets/index-Y2g_iFpU.css +1 -0
- package/studio/web/assets/index-jiPwkrsB.css +1 -0
- package/studio/web/assets/index.lazy-C3TJZJ4o.js +266 -0
- package/studio/web/assets/index.lazy-C3TJZJ4o.js.map +1 -0
- package/studio/web/assets/profiler-DotzgiCJ.js +2 -0
- package/studio/web/assets/profiler-DotzgiCJ.js.map +1 -0
- package/studio/web/assets/react-redux-VxUEx_mU.js +6 -0
- package/studio/web/assets/react-redux-VxUEx_mU.js.map +1 -0
- package/studio/web/assets/startRecording-B_9J9Csd.js +3 -0
- package/studio/web/assets/startRecording-B_9J9Csd.js.map +1 -0
- package/studio/web/fabric-signup-background.webp +0 -0
- package/studio/web/fabric-signup-text.png +0 -0
- package/studio/web/favicon_purple.png +0 -0
- package/studio/web/github-icon.svg +15 -0
- package/studio/web/harper-fabric_black.png +0 -0
- package/studio/web/harper-fabric_white.png +0 -0
- package/studio/web/harper-studio_white.png +0 -0
- package/studio/web/index.html +16 -0
- package/studio/web/running.css +148 -0
- package/studio/web/running.html +147 -0
- package/studio/web/running.js +111 -0
- package/upgrade/UpgradeObjects.js +13 -0
- package/upgrade/directives/directivesController.js +90 -0
- package/upgrade/directivesManager.js +139 -0
- package/upgrade/upgradePrompt.js +124 -0
- package/upgrade/upgradeUtilities.js +28 -0
- package/utility/AWS/AWSConnector.js +29 -0
- package/utility/OperationFunctionCaller.js +63 -0
- package/utility/assignCmdEnvVariables.js +62 -0
- package/utility/common_utils.js +867 -0
- package/utility/environment/environmentManager.js +208 -0
- package/utility/environment/systemInformation.js +355 -0
- package/utility/errors/commonErrors.js +267 -0
- package/utility/errors/hdbError.js +146 -0
- package/utility/functions/date/dateFunctions.js +65 -0
- package/utility/functions/geo.js +355 -0
- package/utility/functions/sql/alaSQLExtension.js +104 -0
- package/utility/globalSchema.js +35 -0
- package/utility/hdbTerms.ts +819 -0
- package/utility/install/checkJWTTokensExist.js +62 -0
- package/utility/install/harperdb.conf +15 -0
- package/utility/install/harperdb.service +14 -0
- package/utility/install/installer.js +635 -0
- package/utility/installation.ts +30 -0
- package/utility/lmdb/DBIDefinition.js +20 -0
- package/utility/lmdb/DeleteRecordsResponseObject.js +25 -0
- package/utility/lmdb/InsertRecordsResponseObject.js +22 -0
- package/utility/lmdb/OpenDBIObject.js +31 -0
- package/utility/lmdb/OpenEnvironmentObject.js +41 -0
- package/utility/lmdb/UpdateRecordsResponseObject.js +25 -0
- package/utility/lmdb/UpsertRecordsResponseObject.js +22 -0
- package/utility/lmdb/cleanLMDBMap.js +65 -0
- package/utility/lmdb/commonUtility.js +119 -0
- package/utility/lmdb/deleteUtility.js +128 -0
- package/utility/lmdb/environmentUtility.js +477 -0
- package/utility/lmdb/searchCursorFunctions.js +187 -0
- package/utility/lmdb/searchUtility.js +918 -0
- package/utility/lmdb/terms.js +57 -0
- package/utility/lmdb/writeUtility.js +407 -0
- package/utility/logging/harper_logger.js +876 -0
- package/utility/logging/logRotator.js +157 -0
- package/utility/logging/logger.ts +24 -0
- package/utility/logging/readLog.js +355 -0
- package/utility/logging/transactionLog.js +57 -0
- package/utility/mount_hdb.js +59 -0
- package/utility/npmUtilities.js +102 -0
- package/utility/operationPermissions.ts +112 -0
- package/utility/operation_authorization.js +836 -0
- package/utility/packageUtils.js +55 -0
- package/utility/password.ts +99 -0
- package/utility/processManagement/processManagement.js +187 -0
- package/utility/processManagement/servicesConfig.js +56 -0
- package/utility/scripts/restartHdb.js +24 -0
- package/utility/scripts/user_data.sh +13 -0
- package/utility/signalling.js +36 -0
- package/utility/terms/certificates.js +81 -0
- package/utility/when.ts +20 -0
- package/v1.d.ts +39 -0
- package/v1.js +41 -0
- package/v2.d.ts +39 -0
- package/v2.js +41 -0
- package/validation/bulkDeleteValidator.js +24 -0
- package/validation/check_permissions.js +19 -0
- package/validation/common_validators.js +95 -0
- package/validation/configValidator.js +331 -0
- package/validation/deleteValidator.js +15 -0
- package/validation/fileLoadValidator.js +153 -0
- package/validation/insertValidator.js +40 -0
- package/validation/installValidator.js +37 -0
- package/validation/readLogValidator.js +64 -0
- package/validation/role_validation.js +320 -0
- package/validation/schemaMetadataValidator.js +42 -0
- package/validation/searchValidator.js +166 -0
- package/validation/statusValidator.ts +66 -0
- package/validation/transactionLogValidator.js +33 -0
- package/validation/user_validation.js +55 -0
- package/validation/validationWrapper.js +105 -0
- package/dist/resources/analytics/profile.d.ts +0 -2
- package/dist/resources/analytics/profile.js +0 -144
- package/dist/resources/analytics/profile.js.map +0 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Status Public API
|
|
3
|
+
*
|
|
4
|
+
* This module provides the clean, simple public API for component status tracking.
|
|
5
|
+
* All internal implementation details are hidden behind this interface.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { componentStatusRegistry } from './registry.ts';
|
|
9
|
+
import { ComponentStatus } from './ComponentStatus.ts';
|
|
10
|
+
import { COMPONENT_STATUS_LEVELS } from './types.ts';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Component Status Builder
|
|
14
|
+
* Provides a fluent interface for reporting component status
|
|
15
|
+
*/
|
|
16
|
+
export class ComponentStatusBuilder {
|
|
17
|
+
private componentName: string;
|
|
18
|
+
|
|
19
|
+
constructor(componentName: string) {
|
|
20
|
+
this.componentName = componentName;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Report component as healthy
|
|
25
|
+
* @param message Optional status message
|
|
26
|
+
* @returns this for chaining
|
|
27
|
+
*/
|
|
28
|
+
healthy(message?: string): this {
|
|
29
|
+
componentStatusRegistry.setStatus(this.componentName, COMPONENT_STATUS_LEVELS.HEALTHY, message);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Report component warning
|
|
35
|
+
* @param message Warning message (required for warnings)
|
|
36
|
+
* @returns this for chaining
|
|
37
|
+
*/
|
|
38
|
+
warning(message: string): this {
|
|
39
|
+
componentStatusRegistry.setStatus(this.componentName, COMPONENT_STATUS_LEVELS.WARNING, message);
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Report component error
|
|
45
|
+
* @param message Error message
|
|
46
|
+
* @param error Optional error object for additional context
|
|
47
|
+
* @returns this for chaining
|
|
48
|
+
*/
|
|
49
|
+
error(message: string, error?: Error): this {
|
|
50
|
+
componentStatusRegistry.setStatus(this.componentName, COMPONENT_STATUS_LEVELS.ERROR, message, error);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Report component as loading
|
|
56
|
+
* @param message Optional loading message
|
|
57
|
+
* @returns this for chaining
|
|
58
|
+
*/
|
|
59
|
+
loading(message?: string): this {
|
|
60
|
+
componentStatusRegistry.setStatus(this.componentName, COMPONENT_STATUS_LEVELS.LOADING, message || 'Loading...');
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Report component status as unknown
|
|
66
|
+
* @param message Optional message explaining why status is unknown
|
|
67
|
+
* @returns this for chaining
|
|
68
|
+
*/
|
|
69
|
+
unknown(message?: string): this {
|
|
70
|
+
componentStatusRegistry.setStatus(this.componentName, COMPONENT_STATUS_LEVELS.UNKNOWN, message);
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get the current status of this component
|
|
76
|
+
* @returns Current component status or undefined if not set
|
|
77
|
+
*/
|
|
78
|
+
get(): ComponentStatus | undefined {
|
|
79
|
+
return componentStatusRegistry.getStatus(this.componentName);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Cache for builders to avoid creating new objects
|
|
84
|
+
const builderCache = new Map<string, ComponentStatusBuilder>();
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get a status builder for a component
|
|
88
|
+
* This is the primary API for reporting component status
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* // Report status
|
|
93
|
+
* statusForComponent('my-service').healthy('Service started');
|
|
94
|
+
* statusForComponent('database').error('Connection failed', err);
|
|
95
|
+
* statusForComponent('cache').warning('Memory usage high');
|
|
96
|
+
*
|
|
97
|
+
* // Get status
|
|
98
|
+
* const status = statusForComponent('my-service').get();
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export function statusForComponent(name: string): ComponentStatusBuilder {
|
|
102
|
+
let builder = builderCache.get(name);
|
|
103
|
+
if (!builder) {
|
|
104
|
+
builder = new ComponentStatusBuilder(name);
|
|
105
|
+
builderCache.set(name, builder);
|
|
106
|
+
}
|
|
107
|
+
return builder;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Component lifecycle hooks for internal use
|
|
112
|
+
* These are used by the component loader
|
|
113
|
+
*/
|
|
114
|
+
export const lifecycle = {
|
|
115
|
+
/**
|
|
116
|
+
* Mark component as starting to load
|
|
117
|
+
*/
|
|
118
|
+
loading(componentName: string, message?: string): void {
|
|
119
|
+
componentStatusRegistry.initializeLoading(componentName, message);
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Mark component as successfully loaded
|
|
124
|
+
*/
|
|
125
|
+
loaded(componentName: string, message?: string): void {
|
|
126
|
+
componentStatusRegistry.markLoaded(componentName, message);
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Mark component as failed to load
|
|
131
|
+
*/
|
|
132
|
+
failed(componentName: string, error: Error | string, message?: string): void {
|
|
133
|
+
componentStatusRegistry.markFailed(componentName, error, message);
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Reset all component statuses (useful for testing)
|
|
139
|
+
*/
|
|
140
|
+
export function reset(): void {
|
|
141
|
+
componentStatusRegistry.reset();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Status level constants for external use
|
|
146
|
+
*/
|
|
147
|
+
export const STATUS = COMPONENT_STATUS_LEVELS;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Re-export only the types that external users need
|
|
151
|
+
*/
|
|
152
|
+
export type { ComponentStatusLevel, AggregatedComponentStatus } from './types.ts';
|
|
153
|
+
export type { ComponentStatus } from './ComponentStatus.ts';
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-Thread Component Status Collection
|
|
3
|
+
*
|
|
4
|
+
* This module handles collecting component status information from all worker threads
|
|
5
|
+
* and aggregating it into a unified view.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { sendItcEvent } from '../../server/threads/itc.js';
|
|
9
|
+
import { getWorkerIndex, onMessageByType, getWorkerCount } from '../../server/threads/manageThreads.js';
|
|
10
|
+
import { ITC_EVENT_TYPES } from '../../utility/hdbTerms.ts';
|
|
11
|
+
import { loggerWithTag } from '../../utility/logging/logger.ts';
|
|
12
|
+
import { ComponentStatusRegistry } from './ComponentStatusRegistry.ts';
|
|
13
|
+
import {
|
|
14
|
+
type ComponentStatusSummary,
|
|
15
|
+
type WorkerComponentStatuses,
|
|
16
|
+
type AggregatedComponentStatus,
|
|
17
|
+
type ComponentStatusLevel,
|
|
18
|
+
COMPONENT_STATUS_LEVELS,
|
|
19
|
+
type ComponentStatusAbnormality,
|
|
20
|
+
} from './types.ts';
|
|
21
|
+
import { ITCError } from './errors.ts';
|
|
22
|
+
|
|
23
|
+
const logger = loggerWithTag('componentStatus.crossThread');
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* CrossThreadStatusCollector Class
|
|
27
|
+
* Handles collection of component status from all worker threads
|
|
28
|
+
*/
|
|
29
|
+
export class CrossThreadStatusCollector {
|
|
30
|
+
private awaitingResponses = new Map<number, Array<WorkerComponentStatuses>>();
|
|
31
|
+
private responseCheckers = new Map<number, () => void>();
|
|
32
|
+
private nextRequestId = 1;
|
|
33
|
+
private listenerAttached = false;
|
|
34
|
+
private readonly timeout: number;
|
|
35
|
+
private cleanupTimer: NodeJS.Timeout | null = null;
|
|
36
|
+
|
|
37
|
+
constructor(timeoutMs: number = 5000) {
|
|
38
|
+
this.timeout = timeoutMs;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Attach the message listener for cross-thread responses
|
|
43
|
+
* This is done once per collector instance to avoid duplicate listeners
|
|
44
|
+
*/
|
|
45
|
+
private attachListener(): void {
|
|
46
|
+
if (this.listenerAttached) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
onMessageByType(ITC_EVENT_TYPES.COMPONENT_STATUS_RESPONSE, ({ message }: any) => {
|
|
51
|
+
const workerLabel = message.isMainThread ? 'main' : `worker-${message.workerIndex}`;
|
|
52
|
+
logger.trace?.('Received component status response from %s, with requestId: %d', workerLabel, message.requestId);
|
|
53
|
+
|
|
54
|
+
// Find the pending request by requestId
|
|
55
|
+
const pendingResponses = this.awaitingResponses.get(message.requestId);
|
|
56
|
+
if (pendingResponses) {
|
|
57
|
+
pendingResponses.push({
|
|
58
|
+
workerIndex: message.workerIndex,
|
|
59
|
+
isMainThread: message.isMainThread || false,
|
|
60
|
+
statuses: message.statuses || [],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Check if we've received all expected responses
|
|
64
|
+
const checkComplete = this.responseCheckers.get(message.requestId);
|
|
65
|
+
if (checkComplete) {
|
|
66
|
+
checkComplete();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
this.listenerAttached = true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Schedule cleanup of stale requests if needed
|
|
76
|
+
*/
|
|
77
|
+
private scheduleCleanup(): void {
|
|
78
|
+
// Clear any existing timer
|
|
79
|
+
if (this.cleanupTimer) {
|
|
80
|
+
clearTimeout(this.cleanupTimer);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Schedule cleanup in 30 seconds if there are pending requests
|
|
84
|
+
if (this.awaitingResponses.size > 0) {
|
|
85
|
+
this.cleanupTimer = setTimeout(() => {
|
|
86
|
+
if (this.awaitingResponses.size > 0) {
|
|
87
|
+
logger.debug?.(`Cleaning up ${this.awaitingResponses.size} stale pending requests`);
|
|
88
|
+
this.awaitingResponses.clear();
|
|
89
|
+
}
|
|
90
|
+
this.cleanupTimer = null;
|
|
91
|
+
}, 30000);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Collect component status information from all threads
|
|
97
|
+
* Returns a Map with component names namespaced by worker index
|
|
98
|
+
*/
|
|
99
|
+
public async collect(registry: ComponentStatusRegistry): Promise<Map<string, ComponentStatusSummary>> {
|
|
100
|
+
try {
|
|
101
|
+
// Ensure listener is attached
|
|
102
|
+
this.attachListener();
|
|
103
|
+
|
|
104
|
+
// Reset cleanup timer on each collect call
|
|
105
|
+
this.scheduleCleanup();
|
|
106
|
+
|
|
107
|
+
// Generate unique request ID and set up response collection
|
|
108
|
+
const requestId = this.nextRequestId++;
|
|
109
|
+
const responses: Array<WorkerComponentStatuses> = [];
|
|
110
|
+
this.awaitingResponses.set(requestId, responses);
|
|
111
|
+
|
|
112
|
+
// Calculate expected number of responses
|
|
113
|
+
// Total threads = main thread (1) + worker threads (workerCount)
|
|
114
|
+
const workerCount = getWorkerCount() || 1;
|
|
115
|
+
const totalThreads = workerCount + 1;
|
|
116
|
+
// We expect responses from all threads except ourselves
|
|
117
|
+
const expectedResponses = totalThreads - 1;
|
|
118
|
+
|
|
119
|
+
// Set up response collection with timeout
|
|
120
|
+
const responsePromise = new Promise<Array<WorkerComponentStatuses>>((resolve, reject) => {
|
|
121
|
+
let resolved = false;
|
|
122
|
+
|
|
123
|
+
// Check if we've received all expected responses
|
|
124
|
+
const checkComplete = () => {
|
|
125
|
+
const collectedResponses = this.awaitingResponses.get(requestId);
|
|
126
|
+
if (collectedResponses && collectedResponses.length >= expectedResponses && !resolved) {
|
|
127
|
+
resolved = true;
|
|
128
|
+
cleanup();
|
|
129
|
+
logger.trace?.(`Collected all ${collectedResponses.length} expected responses for request ${requestId}`);
|
|
130
|
+
resolve(collectedResponses);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// Set up timeout as fallback
|
|
135
|
+
const timeoutHandle = setTimeout(() => {
|
|
136
|
+
if (!resolved) {
|
|
137
|
+
resolved = true;
|
|
138
|
+
const collectedResponses = this.awaitingResponses.get(requestId) || [];
|
|
139
|
+
this.awaitingResponses.delete(requestId);
|
|
140
|
+
// Log timeout with diagnostic info
|
|
141
|
+
logger.debug?.(
|
|
142
|
+
`Collection timeout for request ${requestId}: collected ${collectedResponses.length}/${expectedResponses} responses`
|
|
143
|
+
);
|
|
144
|
+
// Resolve with whatever we've collected so far
|
|
145
|
+
resolve(collectedResponses);
|
|
146
|
+
}
|
|
147
|
+
}, this.timeout);
|
|
148
|
+
|
|
149
|
+
// Ensure cleanup happens no matter what
|
|
150
|
+
const cleanup = () => {
|
|
151
|
+
this.awaitingResponses.delete(requestId);
|
|
152
|
+
clearTimeout(timeoutHandle);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// Store check function for this request
|
|
156
|
+
this.responseCheckers.set(requestId, checkComplete);
|
|
157
|
+
|
|
158
|
+
// Broadcast to ALL threads
|
|
159
|
+
sendItcEvent({
|
|
160
|
+
type: ITC_EVENT_TYPES.COMPONENT_STATUS_REQUEST,
|
|
161
|
+
message: { requestId },
|
|
162
|
+
})
|
|
163
|
+
.then(() => {
|
|
164
|
+
// Request sent successfully, check if we already have all responses
|
|
165
|
+
checkComplete();
|
|
166
|
+
})
|
|
167
|
+
.catch((error: Error) => {
|
|
168
|
+
resolved = true;
|
|
169
|
+
cleanup();
|
|
170
|
+
this.responseCheckers.delete(requestId);
|
|
171
|
+
reject(new ITCError('sendItcEvent', error));
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Get the collected responses for this request
|
|
176
|
+
const collectedResponses = await responsePromise;
|
|
177
|
+
|
|
178
|
+
// Clean up response checker
|
|
179
|
+
this.responseCheckers.delete(requestId);
|
|
180
|
+
|
|
181
|
+
// Aggregate responses from all threads
|
|
182
|
+
const aggregatedStatuses = new Map<string, ComponentStatusSummary>();
|
|
183
|
+
|
|
184
|
+
// Add local thread's component status
|
|
185
|
+
const localStatuses = registry.getAllStatuses();
|
|
186
|
+
const localWorkerIndex = getWorkerIndex();
|
|
187
|
+
const localThreadLabel = localWorkerIndex === undefined ? 'main' : `worker-${localWorkerIndex}`;
|
|
188
|
+
|
|
189
|
+
for (const [name, status] of localStatuses) {
|
|
190
|
+
aggregatedStatuses.set(`${name}@${localThreadLabel}`, {
|
|
191
|
+
...status,
|
|
192
|
+
workerIndex: localWorkerIndex,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Add responses from other threads
|
|
197
|
+
for (const response of collectedResponses) {
|
|
198
|
+
for (const [name, status] of response.statuses) {
|
|
199
|
+
const threadLabel = response.isMainThread ? 'main' : `worker-${response.workerIndex}`;
|
|
200
|
+
aggregatedStatuses.set(`${name}@${threadLabel}`, {
|
|
201
|
+
...status,
|
|
202
|
+
workerIndex: response.workerIndex,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
logger.debug?.(`Collected component status from ${collectedResponses.length + 1} threads (including local)`);
|
|
208
|
+
return aggregatedStatuses;
|
|
209
|
+
} catch (error) {
|
|
210
|
+
if (error instanceof ITCError) {
|
|
211
|
+
logger.error?.(`ITC failure during component status collection: ${error.message}`);
|
|
212
|
+
} else {
|
|
213
|
+
logger.warn?.('Failed to collect component status from all threads:', error);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Log diagnostic information
|
|
217
|
+
logger.debug?.(
|
|
218
|
+
`Collection failed for request. Error: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
// Fallback to local status only
|
|
222
|
+
return this.getLocalStatusOnly(registry);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Get status from local thread only (fallback when cross-thread collection fails)
|
|
228
|
+
*/
|
|
229
|
+
private getLocalStatusOnly(registry: ComponentStatusRegistry): Map<string, ComponentStatusSummary> {
|
|
230
|
+
const localStatuses = registry.getAllStatuses();
|
|
231
|
+
const fallbackStatuses = new Map<string, ComponentStatusSummary>();
|
|
232
|
+
const localWorkerIndex = getWorkerIndex();
|
|
233
|
+
const localThreadLabel = localWorkerIndex === undefined ? 'main' : `worker-${localWorkerIndex}`;
|
|
234
|
+
|
|
235
|
+
for (const [name, status] of localStatuses) {
|
|
236
|
+
fallbackStatuses.set(`${name}@${localThreadLabel}`, {
|
|
237
|
+
...status,
|
|
238
|
+
workerIndex: localWorkerIndex,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
return fallbackStatuses;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Clean up any pending requests and timers (useful for testing)
|
|
246
|
+
*/
|
|
247
|
+
public cleanup(): void {
|
|
248
|
+
this.awaitingResponses.clear();
|
|
249
|
+
this.responseCheckers.clear();
|
|
250
|
+
if (this.cleanupTimer) {
|
|
251
|
+
clearTimeout(this.cleanupTimer);
|
|
252
|
+
this.cleanupTimer = null;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* StatusAggregator Class
|
|
259
|
+
* Handles aggregation of component statuses from multiple threads
|
|
260
|
+
*/
|
|
261
|
+
export class StatusAggregator {
|
|
262
|
+
/**
|
|
263
|
+
* Aggregate component statuses from multiple threads into aggregated view
|
|
264
|
+
*/
|
|
265
|
+
public static aggregate(allStatuses: Map<string, ComponentStatusSummary>): Map<string, AggregatedComponentStatus> {
|
|
266
|
+
const aggregatedMap = new Map<string, AggregatedComponentStatus>();
|
|
267
|
+
|
|
268
|
+
// Group statuses by component name (without thread suffix)
|
|
269
|
+
const componentGroups = new Map<string, Array<[string, ComponentStatusSummary]>>();
|
|
270
|
+
|
|
271
|
+
for (const [nameWithThread, status] of allStatuses) {
|
|
272
|
+
// Extract component name without thread suffix (e.g., "myComponent@worker-1" -> "myComponent")
|
|
273
|
+
const atIndex = nameWithThread.indexOf('@');
|
|
274
|
+
const componentName = atIndex !== -1 ? nameWithThread.substring(0, atIndex) : nameWithThread;
|
|
275
|
+
|
|
276
|
+
let group = componentGroups.get(componentName);
|
|
277
|
+
if (!group) {
|
|
278
|
+
group = [];
|
|
279
|
+
componentGroups.set(componentName, group);
|
|
280
|
+
}
|
|
281
|
+
group.push([nameWithThread, status]);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Process each component group
|
|
285
|
+
for (const [componentName, statusEntries] of componentGroups) {
|
|
286
|
+
const aggregated = this.aggregateComponentGroup(componentName, statusEntries);
|
|
287
|
+
aggregatedMap.set(componentName, aggregated);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return aggregatedMap;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Aggregate status entries for a single component across threads
|
|
295
|
+
*/
|
|
296
|
+
private static aggregateComponentGroup(
|
|
297
|
+
componentName: string,
|
|
298
|
+
statusEntries: Array<[string, ComponentStatusSummary]>
|
|
299
|
+
): AggregatedComponentStatus {
|
|
300
|
+
const lastCheckedTimes: AggregatedComponentStatus['lastChecked'] = {
|
|
301
|
+
workers: {},
|
|
302
|
+
};
|
|
303
|
+
let mostRecentCheckTime = 0;
|
|
304
|
+
let latestMessage: string | undefined;
|
|
305
|
+
let error: Error | string | undefined;
|
|
306
|
+
const statusCounts = new Map<ComponentStatusLevel, number>();
|
|
307
|
+
const abnormalities = new Map<string, ComponentStatusAbnormality>();
|
|
308
|
+
|
|
309
|
+
// Analyze all instances of this component
|
|
310
|
+
for (const [nameWithThread, status] of statusEntries) {
|
|
311
|
+
const atIndex = nameWithThread.lastIndexOf('@');
|
|
312
|
+
const threadLabel = atIndex !== -1 ? nameWithThread.substring(atIndex + 1) : '';
|
|
313
|
+
|
|
314
|
+
// Convert lastChecked to ms since epoch
|
|
315
|
+
const checkTime =
|
|
316
|
+
status.lastChecked instanceof Date ? status.lastChecked.getTime() : new Date(status.lastChecked).getTime();
|
|
317
|
+
|
|
318
|
+
// Store the last checked time based on thread label
|
|
319
|
+
if (threadLabel === 'main') {
|
|
320
|
+
lastCheckedTimes.main = checkTime;
|
|
321
|
+
} else if (threadLabel && threadLabel.startsWith('worker-')) {
|
|
322
|
+
const workerIndex = parseInt(threadLabel.substring(7)); // 'worker-'.length = 7
|
|
323
|
+
if (!isNaN(workerIndex)) {
|
|
324
|
+
lastCheckedTimes.workers[workerIndex] = checkTime;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Track status counts
|
|
329
|
+
statusCounts.set(status.status, (statusCounts.get(status.status) || 0) + 1);
|
|
330
|
+
|
|
331
|
+
// Track messages - prioritize non-healthy messages
|
|
332
|
+
if (status.status !== COMPONENT_STATUS_LEVELS.HEALTHY && status.message) {
|
|
333
|
+
if (!latestMessage || checkTime > mostRecentCheckTime) {
|
|
334
|
+
mostRecentCheckTime = checkTime;
|
|
335
|
+
latestMessage = status.message;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Capture any error
|
|
340
|
+
if (status.error && !error) {
|
|
341
|
+
error = status.error;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Determine overall status (priority: error > warning > loading > unknown > healthy)
|
|
346
|
+
const determinedStatus = this.determineOverallStatus(statusCounts);
|
|
347
|
+
|
|
348
|
+
// Check for abnormalities (inconsistent statuses across threads)
|
|
349
|
+
const uniqueStatuses = Array.from(statusCounts.keys());
|
|
350
|
+
if (uniqueStatuses.length > 1) {
|
|
351
|
+
// There are inconsistencies - populate abnormalities
|
|
352
|
+
for (const [nameWithThread, status] of statusEntries) {
|
|
353
|
+
if (status.status !== determinedStatus) {
|
|
354
|
+
abnormalities.set(nameWithThread, {
|
|
355
|
+
workerIndex: status.workerIndex !== undefined ? status.workerIndex : -1,
|
|
356
|
+
status: status.status,
|
|
357
|
+
message: status.message,
|
|
358
|
+
error: status.error,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Create aggregated status
|
|
365
|
+
const aggregatedStatus: AggregatedComponentStatus = {
|
|
366
|
+
componentName,
|
|
367
|
+
status: determinedStatus,
|
|
368
|
+
lastChecked: lastCheckedTimes,
|
|
369
|
+
latestMessage,
|
|
370
|
+
error,
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
// Only add abnormalities if there are any
|
|
374
|
+
if (abnormalities.size > 0) {
|
|
375
|
+
aggregatedStatus.abnormalities = abnormalities;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return aggregatedStatus;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Determine overall status based on priority
|
|
383
|
+
*/
|
|
384
|
+
private static determineOverallStatus(statusCounts: Map<ComponentStatusLevel, number>): ComponentStatusLevel {
|
|
385
|
+
const statusPriority = [
|
|
386
|
+
COMPONENT_STATUS_LEVELS.ERROR,
|
|
387
|
+
COMPONENT_STATUS_LEVELS.WARNING,
|
|
388
|
+
COMPONENT_STATUS_LEVELS.LOADING,
|
|
389
|
+
COMPONENT_STATUS_LEVELS.UNKNOWN,
|
|
390
|
+
COMPONENT_STATUS_LEVELS.HEALTHY,
|
|
391
|
+
];
|
|
392
|
+
|
|
393
|
+
for (const priorityStatus of statusPriority) {
|
|
394
|
+
if (statusCounts.has(priorityStatus) && statusCounts.get(priorityStatus)! > 0) {
|
|
395
|
+
return priorityStatus;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return COMPONENT_STATUS_LEVELS.UNKNOWN;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// Create singleton instances with configurable timeout
|
|
404
|
+
const TIMEOUT_MS = parseInt(process.env.COMPONENT_STATUS_TIMEOUT || '5000');
|
|
405
|
+
export const crossThreadCollector = new CrossThreadStatusCollector(TIMEOUT_MS);
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Status Error Types
|
|
3
|
+
*
|
|
4
|
+
* This module defines specific error types for the component status system,
|
|
5
|
+
* providing better diagnostics and error handling capabilities.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { HTTP_STATUS_CODES } from '../../utility/errors/commonErrors.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Base error class for component status system
|
|
12
|
+
*/
|
|
13
|
+
export class ComponentStatusError extends Error {
|
|
14
|
+
public readonly statusCode: number;
|
|
15
|
+
public readonly timestamp: Date;
|
|
16
|
+
|
|
17
|
+
constructor(message: string, statusCode: number = HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = 'ComponentStatusError';
|
|
20
|
+
this.statusCode = statusCode;
|
|
21
|
+
this.timestamp = new Date();
|
|
22
|
+
Error.captureStackTrace(this, this.constructor);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Error thrown when cross-thread status collection times out
|
|
28
|
+
*/
|
|
29
|
+
export class CrossThreadTimeoutError extends ComponentStatusError {
|
|
30
|
+
public readonly requestId: number;
|
|
31
|
+
public readonly timeoutMs: number;
|
|
32
|
+
public readonly collectedCount: number;
|
|
33
|
+
|
|
34
|
+
constructor(requestId: number, timeoutMs: number, collectedCount: number) {
|
|
35
|
+
super(
|
|
36
|
+
`Component status collection timeout after ${timeoutMs}ms. ` +
|
|
37
|
+
`Collected ${collectedCount} responses for request ${requestId}.`,
|
|
38
|
+
HTTP_STATUS_CODES.GATEWAY_TIMEOUT
|
|
39
|
+
);
|
|
40
|
+
this.name = 'CrossThreadTimeoutError';
|
|
41
|
+
this.requestId = requestId;
|
|
42
|
+
this.timeoutMs = timeoutMs;
|
|
43
|
+
this.collectedCount = collectedCount;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Error thrown when ITC (Inter-Thread Communication) fails
|
|
49
|
+
*/
|
|
50
|
+
export class ITCError extends ComponentStatusError {
|
|
51
|
+
public readonly operation: string;
|
|
52
|
+
public readonly cause?: Error;
|
|
53
|
+
|
|
54
|
+
constructor(operation: string, cause?: Error) {
|
|
55
|
+
super(
|
|
56
|
+
`Inter-thread communication failed during ${operation}: ${cause?.message || 'Unknown error'}`,
|
|
57
|
+
HTTP_STATUS_CODES.SERVICE_UNAVAILABLE
|
|
58
|
+
);
|
|
59
|
+
this.name = 'ITCError';
|
|
60
|
+
this.operation = operation;
|
|
61
|
+
this.cause = cause;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Error thrown when component status aggregation fails
|
|
67
|
+
*/
|
|
68
|
+
export class AggregationError extends ComponentStatusError {
|
|
69
|
+
public readonly componentCount: number;
|
|
70
|
+
public readonly cause?: Error;
|
|
71
|
+
|
|
72
|
+
constructor(componentCount: number, cause?: Error) {
|
|
73
|
+
super(
|
|
74
|
+
`Failed to aggregate status for ${componentCount} components: ${cause?.message || 'Unknown error'}`,
|
|
75
|
+
HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR
|
|
76
|
+
);
|
|
77
|
+
this.name = 'AggregationError';
|
|
78
|
+
this.componentCount = componentCount;
|
|
79
|
+
this.cause = cause;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Error thrown when a component status operation fails
|
|
85
|
+
*/
|
|
86
|
+
export class ComponentStatusOperationError extends ComponentStatusError {
|
|
87
|
+
public readonly componentName: string;
|
|
88
|
+
public readonly operation: string;
|
|
89
|
+
|
|
90
|
+
constructor(componentName: string, operation: string, message: string) {
|
|
91
|
+
super(`Component '${componentName}' ${operation} failed: ${message}`, HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR);
|
|
92
|
+
this.name = 'ComponentStatusOperationError';
|
|
93
|
+
this.componentName = componentName;
|
|
94
|
+
this.operation = operation;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Information about cross-thread collection results
|
|
100
|
+
*/
|
|
101
|
+
export interface CrossThreadCollectionResult {
|
|
102
|
+
success: boolean;
|
|
103
|
+
collectedFromThreads: number;
|
|
104
|
+
expectedThreads?: number;
|
|
105
|
+
timedOutThreads: number[];
|
|
106
|
+
errors: Error[];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Error thrown with detailed cross-thread collection diagnostics
|
|
111
|
+
*/
|
|
112
|
+
export class CrossThreadCollectionError extends ComponentStatusError {
|
|
113
|
+
public readonly result: CrossThreadCollectionResult;
|
|
114
|
+
|
|
115
|
+
constructor(result: CrossThreadCollectionResult) {
|
|
116
|
+
const message = result.success
|
|
117
|
+
? `Partial collection success: ${result.collectedFromThreads} threads responded` +
|
|
118
|
+
(result.timedOutThreads.length > 0 ? `, ${result.timedOutThreads.length} timed out` : '')
|
|
119
|
+
: `Collection failed: ${result.errors.map((e) => e.message).join(', ')}`;
|
|
120
|
+
|
|
121
|
+
super(message, HTTP_STATUS_CODES.OK); // 200 - partial success is still success
|
|
122
|
+
this.name = 'CrossThreadCollectionError';
|
|
123
|
+
this.result = result;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Get detailed diagnostic information
|
|
128
|
+
*/
|
|
129
|
+
getDiagnostics(): string {
|
|
130
|
+
const lines = [
|
|
131
|
+
`Cross-thread collection ${this.result.success ? 'partially succeeded' : 'failed'}`,
|
|
132
|
+
`Threads responded: ${this.result.collectedFromThreads}`,
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
if (this.result.expectedThreads) {
|
|
136
|
+
lines.push(`Expected threads: ${this.result.expectedThreads}`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (this.result.timedOutThreads.length > 0) {
|
|
140
|
+
lines.push(`Timed out threads: ${this.result.timedOutThreads.join(', ')}`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (this.result.errors.length > 0) {
|
|
144
|
+
lines.push('Errors:');
|
|
145
|
+
this.result.errors.forEach((error, index) => {
|
|
146
|
+
lines.push(` ${index + 1}. ${error.name}: ${error.message}`);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return lines.join('\n');
|
|
151
|
+
}
|
|
152
|
+
}
|