@harperfast/harper 5.2.10 → 5.3.0-alpha.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/agent/mcpTools.ts +1 -1
- package/agent/session.ts +25 -14
- package/bin/cliOperations.ts +46 -9
- package/bin/copyDb.ts +282 -59
- package/bin/deploySetup.ts +16 -5
- package/bin/harper.ts +1 -1
- package/bin/help.ts +4 -1
- package/bin/lite.ts +4 -1
- package/bin/restart.ts +59 -3
- package/bin/run.ts +6 -11
- package/bin/upgrade.js +7 -3
- package/bin/workloadIdentity.ts +119 -0
- package/components/Application.ts +2414 -242
- package/components/ApplicationScope.ts +8 -0
- package/components/EntryHandler.ts +59 -39
- package/components/OptionsWatcher.ts +150 -74
- package/components/RuntimeModuleTracker.ts +38 -7
- package/components/Scope.ts +37 -15
- package/components/awaitRestart.ts +84 -0
- package/components/componentLoader.ts +340 -30
- package/components/componentPreparationLock.ts +16 -5
- package/components/mcp/adapters/harperHttp.ts +4 -0
- package/components/mcp/listChanged.ts +4 -0
- package/components/mcp/toolRegistry.ts +2 -0
- package/components/mcp/tools/operations.ts +9 -0
- package/components/mcp/tools/schemas/operationDescriptions.ts +2 -2
- package/components/operations.js +270 -78
- package/components/operationsValidation.js +49 -1
- package/components/status/ComponentStatusRegistry.ts +59 -0
- package/config/RootConfigWatcher.ts +80 -34
- package/config/configUtils.ts +291 -34
- package/config/harperConfigEnvVars.ts +170 -27
- package/config-root.schema.json +29 -0
- package/dataLayer/blobBackup.ts +160 -50
- package/dataLayer/delete.ts +6 -1
- package/dataLayer/harperBridge/ResourceBridge.ts +52 -8
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js +3 -1
- package/dataLayer/hdbInfoController.ts +34 -1
- package/dataLayer/insert.ts +44 -1
- package/dataLayer/rocksdbBackup.ts +53 -10
- package/dataLayer/schema.ts +11 -1
- package/dataLayer/schemaDescribe.ts +8 -1
- package/dist/agent/mcpTools.js +1 -1
- package/dist/agent/mcpTools.js.map +1 -1
- package/dist/agent/session.d.ts +22 -0
- package/dist/agent/session.js +26 -15
- package/dist/agent/session.js.map +1 -1
- package/dist/bin/cliOperations.js +48 -9
- package/dist/bin/cliOperations.js.map +1 -1
- package/dist/bin/copyDb.d.ts +12 -1
- package/dist/bin/copyDb.js +248 -60
- package/dist/bin/copyDb.js.map +1 -1
- package/dist/bin/deploySetup.d.ts +2 -0
- package/dist/bin/deploySetup.js +11 -3
- package/dist/bin/deploySetup.js.map +1 -1
- package/dist/bin/harper.js +1 -1
- package/dist/bin/harper.js.map +1 -1
- package/dist/bin/help.js +4 -1
- package/dist/bin/help.js.map +1 -1
- package/dist/bin/lite.js +4 -1
- package/dist/bin/lite.js.map +1 -1
- package/dist/bin/restart.js +54 -5
- package/dist/bin/restart.js.map +1 -1
- package/dist/bin/run.js +4 -10
- package/dist/bin/run.js.map +1 -1
- package/dist/bin/upgrade.js +4 -3
- package/dist/bin/upgrade.js.map +1 -1
- package/dist/bin/workloadIdentity.d.ts +18 -0
- package/dist/bin/workloadIdentity.js +100 -0
- package/dist/bin/workloadIdentity.js.map +1 -0
- package/dist/components/Application.d.ts +139 -16
- package/dist/components/Application.js +2215 -267
- package/dist/components/Application.js.map +1 -1
- package/dist/components/ApplicationScope.d.ts +8 -0
- package/dist/components/ApplicationScope.js +7 -0
- package/dist/components/ApplicationScope.js.map +1 -1
- package/dist/components/EntryHandler.js +26 -10
- package/dist/components/EntryHandler.js.map +1 -1
- package/dist/components/OptionsWatcher.d.ts +1 -0
- package/dist/components/OptionsWatcher.js +141 -74
- package/dist/components/OptionsWatcher.js.map +1 -1
- package/dist/components/RuntimeModuleTracker.js +40 -6
- package/dist/components/RuntimeModuleTracker.js.map +1 -1
- package/dist/components/Scope.js +38 -13
- package/dist/components/Scope.js.map +1 -1
- package/dist/components/awaitRestart.d.ts +33 -0
- package/dist/components/awaitRestart.js +61 -0
- package/dist/components/awaitRestart.js.map +1 -0
- package/dist/components/componentLoader.d.ts +38 -1
- package/dist/components/componentLoader.js +279 -22
- package/dist/components/componentLoader.js.map +1 -1
- package/dist/components/componentPreparationLock.d.ts +5 -0
- package/dist/components/componentPreparationLock.js +14 -6
- package/dist/components/componentPreparationLock.js.map +1 -1
- package/dist/components/mcp/adapters/harperHttp.js +4 -0
- package/dist/components/mcp/adapters/harperHttp.js.map +1 -1
- package/dist/components/mcp/listChanged.js +5 -0
- package/dist/components/mcp/listChanged.js.map +1 -1
- package/dist/components/mcp/toolRegistry.d.ts +1 -0
- package/dist/components/mcp/toolRegistry.js.map +1 -1
- package/dist/components/mcp/tools/operations.d.ts +5 -0
- package/dist/components/mcp/tools/operations.js +9 -0
- package/dist/components/mcp/tools/operations.js.map +1 -1
- package/dist/components/mcp/tools/schemas/operationDescriptions.js +2 -2
- package/dist/components/mcp/tools/schemas/operationDescriptions.js.map +1 -1
- package/dist/components/operations.js +231 -77
- package/dist/components/operations.js.map +1 -1
- package/dist/components/operationsValidation.js +49 -1
- package/dist/components/operationsValidation.js.map +1 -1
- package/dist/components/status/ComponentStatusRegistry.d.ts +0 -4
- package/dist/components/status/ComponentStatusRegistry.js +63 -0
- package/dist/components/status/ComponentStatusRegistry.js.map +1 -1
- package/dist/config/RootConfigWatcher.d.ts +7 -1
- package/dist/config/RootConfigWatcher.js +64 -27
- package/dist/config/RootConfigWatcher.js.map +1 -1
- package/dist/config/configUtils.d.ts +9 -1
- package/dist/config/configUtils.js +254 -33
- package/dist/config/configUtils.js.map +1 -1
- package/dist/config/harperConfigEnvVars.d.ts +16 -0
- package/dist/config/harperConfigEnvVars.js +162 -25
- package/dist/config/harperConfigEnvVars.js.map +1 -1
- package/dist/dataLayer/blobBackup.d.ts +49 -20
- package/dist/dataLayer/blobBackup.js +139 -50
- package/dist/dataLayer/blobBackup.js.map +1 -1
- package/dist/dataLayer/delete.js +1 -1
- package/dist/dataLayer/delete.js.map +1 -1
- package/dist/dataLayer/harperBridge/ResourceBridge.d.ts +14 -1
- package/dist/dataLayer/harperBridge/ResourceBridge.js +51 -10
- package/dist/dataLayer/harperBridge/ResourceBridge.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.d.ts +3 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js +3 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/DeleteAuditLogsBeforeResults.js.map +1 -1
- package/dist/dataLayer/hdbInfoController.d.ts +10 -0
- package/dist/dataLayer/hdbInfoController.js +30 -1
- package/dist/dataLayer/hdbInfoController.js.map +1 -1
- package/dist/dataLayer/insert.d.ts +9 -1
- package/dist/dataLayer/insert.js +30 -0
- package/dist/dataLayer/insert.js.map +1 -1
- package/dist/dataLayer/rocksdbBackup.d.ts +2 -2
- package/dist/dataLayer/rocksdbBackup.js +45 -8
- package/dist/dataLayer/rocksdbBackup.js.map +1 -1
- package/dist/dataLayer/schema.js +8 -0
- package/dist/dataLayer/schema.js.map +1 -1
- package/dist/dataLayer/schemaDescribe.js +8 -1
- package/dist/dataLayer/schemaDescribe.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/json/systemSchema.json +52 -0
- package/dist/resources/DatabaseTransaction.d.ts +55 -3
- package/dist/resources/DatabaseTransaction.js +460 -134
- package/dist/resources/DatabaseTransaction.js.map +1 -1
- package/dist/resources/LMDBTransaction.js +22 -4
- package/dist/resources/LMDBTransaction.js.map +1 -1
- package/dist/resources/PrimaryRocksDatabase.d.ts +1 -0
- package/dist/resources/PrimaryRocksDatabase.js +30 -2
- package/dist/resources/PrimaryRocksDatabase.js.map +1 -1
- package/dist/resources/RecordEncoder.d.ts +20 -0
- package/dist/resources/RecordEncoder.js +94 -9
- package/dist/resources/RecordEncoder.js.map +1 -1
- package/dist/resources/RequestTarget.d.ts +2 -0
- package/dist/resources/RequestTarget.js.map +1 -1
- package/dist/resources/Resource.js +20 -11
- package/dist/resources/Resource.js.map +1 -1
- package/dist/resources/ResourceInterface.d.ts +20 -1
- package/dist/resources/ResourceInterface.js.map +1 -1
- package/dist/resources/RocksIndexStore.d.ts +6 -1
- package/dist/resources/RocksIndexStore.js +24 -10
- package/dist/resources/RocksIndexStore.js.map +1 -1
- package/dist/resources/RocksTransactionLogStore.d.ts +14 -1
- package/dist/resources/RocksTransactionLogStore.js +57 -17
- package/dist/resources/RocksTransactionLogStore.js.map +1 -1
- package/dist/resources/Table.d.ts +112 -8
- package/dist/resources/Table.js +1071 -197
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/auditStore.d.ts +11 -2
- package/dist/resources/auditStore.js +183 -18
- package/dist/resources/auditStore.js.map +1 -1
- package/dist/resources/blob.d.ts +129 -9
- package/dist/resources/blob.js +992 -114
- package/dist/resources/blob.js.map +1 -1
- package/dist/resources/branchDatabase.d.ts +48 -0
- package/dist/resources/branchDatabase.js +892 -0
- package/dist/resources/branchDatabase.js.map +1 -0
- package/dist/resources/crdt.js +50 -12
- package/dist/resources/crdt.js.map +1 -1
- package/dist/resources/databases.d.ts +150 -9
- package/dist/resources/databases.js +1247 -525
- package/dist/resources/databases.js.map +1 -1
- package/dist/resources/defineTable.d.ts +10 -2
- package/dist/resources/defineTable.js +9 -1
- package/dist/resources/defineTable.js.map +1 -1
- package/dist/resources/graphql.d.ts +1 -1
- package/dist/resources/graphql.js +50 -15
- package/dist/resources/graphql.js.map +1 -1
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.d.ts +1 -0
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js +6 -2
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js.map +1 -1
- package/dist/resources/longLivedTransactions.d.ts +71 -0
- package/dist/resources/longLivedTransactions.js +358 -0
- package/dist/resources/longLivedTransactions.js.map +1 -0
- package/dist/resources/models/backendRegistry.d.ts +26 -0
- package/dist/resources/models/backendRegistry.js +60 -2
- package/dist/resources/models/backendRegistry.js.map +1 -1
- package/dist/resources/models/bootstrap.d.ts +33 -1
- package/dist/resources/models/bootstrap.js +416 -31
- package/dist/resources/models/bootstrap.js.map +1 -1
- package/dist/resources/recordLock.d.ts +80 -0
- package/dist/resources/recordLock.js +184 -0
- package/dist/resources/recordLock.js.map +1 -0
- package/dist/resources/replayLogs.d.ts +14 -1
- package/dist/resources/replayLogs.js +152 -24
- package/dist/resources/replayLogs.js.map +1 -1
- package/dist/resources/replayLogsGuards.d.ts +94 -7
- package/dist/resources/replayLogsGuards.js +111 -7
- package/dist/resources/replayLogsGuards.js.map +1 -1
- package/dist/resources/search.js +158 -32
- package/dist/resources/search.js.map +1 -1
- package/dist/resources/transactionBroadcast.d.ts +1 -1
- package/dist/resources/transactionBroadcast.js +2 -2
- package/dist/resources/transactionBroadcast.js.map +1 -1
- package/dist/security/auth.js +61 -30
- package/dist/security/auth.js.map +1 -1
- package/dist/security/authn/oidc/claims.d.ts +22 -0
- package/dist/security/authn/oidc/claims.js +71 -0
- package/dist/security/authn/oidc/claims.js.map +1 -0
- package/dist/security/authn/oidc/identityToken.d.ts +27 -0
- package/dist/security/authn/oidc/identityToken.js +111 -0
- package/dist/security/authn/oidc/identityToken.js.map +1 -0
- package/dist/security/authn/oidc/jwks.d.ts +25 -0
- package/dist/security/authn/oidc/jwks.js +261 -0
- package/dist/security/authn/oidc/jwks.js.map +1 -0
- package/dist/security/authn/oidc/providers/generic.d.ts +13 -0
- package/dist/security/authn/oidc/providers/generic.js +34 -0
- package/dist/security/authn/oidc/providers/generic.js.map +1 -0
- package/dist/security/authn/oidc/providers/githubActions.d.ts +11 -0
- package/dist/security/authn/oidc/providers/githubActions.js +129 -0
- package/dist/security/authn/oidc/providers/githubActions.js.map +1 -0
- package/dist/security/authn/oidc/providers/index.d.ts +37 -0
- package/dist/security/authn/oidc/providers/index.js +24 -0
- package/dist/security/authn/oidc/providers/index.js.map +1 -0
- package/dist/security/authn/oidc/tokenExchange.d.ts +12 -0
- package/dist/security/authn/oidc/tokenExchange.js +306 -0
- package/dist/security/authn/oidc/tokenExchange.js.map +1 -0
- package/dist/security/authn/oidc/trustPolicyOperations.d.ts +49 -0
- package/dist/security/authn/oidc/trustPolicyOperations.js +358 -0
- package/dist/security/authn/oidc/trustPolicyOperations.js.map +1 -0
- package/dist/security/authn/oidc/types.d.ts +38 -0
- package/dist/security/authn/oidc/types.js +6 -0
- package/dist/security/authn/oidc/types.js.map +1 -0
- package/dist/security/certificateVerification/index.js +40 -11
- package/dist/security/certificateVerification/index.js.map +1 -1
- package/dist/security/certificateVerification/trustedIssuers.d.ts +24 -0
- package/dist/security/certificateVerification/trustedIssuers.js +79 -0
- package/dist/security/certificateVerification/trustedIssuers.js.map +1 -0
- package/dist/security/certificateVerification/types.d.ts +1 -0
- package/dist/security/credentialProvenance.d.ts +35 -0
- package/dist/security/credentialProvenance.js +51 -0
- package/dist/security/credentialProvenance.js.map +1 -0
- package/dist/security/credentialRejection.d.ts +4 -0
- package/dist/security/credentialRejection.js +24 -0
- package/dist/security/credentialRejection.js.map +1 -0
- package/dist/security/deferredAuthentication.d.ts +36 -0
- package/dist/security/deferredAuthentication.js +70 -0
- package/dist/security/deferredAuthentication.js.map +1 -0
- package/dist/security/impersonation.d.ts +21 -0
- package/dist/security/impersonation.js +108 -9
- package/dist/security/impersonation.js.map +1 -1
- package/dist/security/jsLoader.d.ts +6 -0
- package/dist/security/jsLoader.js +75 -15
- package/dist/security/jsLoader.js.map +1 -1
- package/dist/security/keys.js +301 -71
- package/dist/security/keys.js.map +1 -1
- package/dist/security/operationScope.d.ts +21 -0
- package/dist/security/operationScope.js +36 -0
- package/dist/security/operationScope.js.map +1 -0
- package/dist/security/permissionsTranslator.js +21 -0
- package/dist/security/permissionsTranslator.js.map +1 -1
- package/dist/security/tokenAuthentication.d.ts +19 -1
- package/dist/security/tokenAuthentication.js +191 -10
- package/dist/security/tokenAuthentication.js.map +1 -1
- package/dist/security/user.js +4 -3
- package/dist/security/user.js.map +1 -1
- package/dist/server/DurableSubscriptionsSession.d.ts +2 -2
- package/dist/server/DurableSubscriptionsSession.js +67 -10
- package/dist/server/DurableSubscriptionsSession.js.map +1 -1
- package/dist/server/REST.js +73 -0
- package/dist/server/REST.js.map +1 -1
- package/dist/server/graphqlQuerying.js +4 -0
- package/dist/server/graphqlQuerying.js.map +1 -1
- package/dist/server/http.d.ts +11 -0
- package/dist/server/http.js +88 -15
- package/dist/server/http.js.map +1 -1
- package/dist/server/itc/serverHandlers.js +8 -1
- package/dist/server/itc/serverHandlers.js.map +1 -1
- package/dist/server/jobs/jobProcess.js +6 -2
- package/dist/server/jobs/jobProcess.js.map +1 -1
- package/dist/server/jobs/jobs.js +4 -1
- package/dist/server/jobs/jobs.js.map +1 -1
- package/dist/server/liveSubscriptionAuth.d.ts +26 -4
- package/dist/server/liveSubscriptionAuth.js +105 -39
- package/dist/server/liveSubscriptionAuth.js.map +1 -1
- package/dist/server/loadRootComponents.js +49 -10
- package/dist/server/loadRootComponents.js.map +1 -1
- package/dist/server/mqtt.d.ts +2 -0
- package/dist/server/mqtt.js +165 -30
- package/dist/server/mqtt.js.map +1 -1
- package/dist/server/nodeName.d.ts +2 -0
- package/dist/server/nodeName.js +107 -23
- package/dist/server/nodeName.js.map +1 -1
- package/dist/server/serverHelpers/Headers.d.ts +25 -0
- package/dist/server/serverHelpers/Headers.js +139 -1
- package/dist/server/serverHelpers/Headers.js.map +1 -1
- package/dist/server/serverHelpers/contentTypes.d.ts +9 -0
- package/dist/server/serverHelpers/contentTypes.js +32 -25
- package/dist/server/serverHelpers/contentTypes.js.map +1 -1
- package/dist/server/serverHelpers/deployValidationState.d.ts +3 -0
- package/dist/server/serverHelpers/deployValidationState.js +9 -19
- package/dist/server/serverHelpers/deployValidationState.js.map +1 -1
- package/dist/server/serverHelpers/operationAuthorizationState.d.ts +12 -0
- package/dist/server/serverHelpers/operationAuthorizationState.js +24 -2
- package/dist/server/serverHelpers/operationAuthorizationState.js.map +1 -1
- package/dist/server/serverHelpers/registeredOperations.d.ts +5 -4
- package/dist/server/serverHelpers/registeredOperations.js +74 -21
- package/dist/server/serverHelpers/registeredOperations.js.map +1 -1
- package/dist/server/serverHelpers/requestSanitization.d.ts +11 -0
- package/dist/server/serverHelpers/requestSanitization.js +20 -0
- package/dist/server/serverHelpers/requestSanitization.js.map +1 -0
- package/dist/server/serverHelpers/serverHandlers.js +6 -3
- package/dist/server/serverHelpers/serverHandlers.js.map +1 -1
- package/dist/server/serverHelpers/serverUtilities.d.ts +18 -0
- package/dist/server/serverHelpers/serverUtilities.js +90 -20
- package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
- package/dist/server/serverHelpers/sharedMessageEncoding.d.ts +67 -0
- package/dist/server/serverHelpers/sharedMessageEncoding.js +280 -0
- package/dist/server/serverHelpers/sharedMessageEncoding.js.map +1 -0
- package/dist/server/serverHelpers/uwsServer.js +19 -1
- package/dist/server/serverHelpers/uwsServer.js.map +1 -1
- package/dist/server/static.js +24 -28
- package/dist/server/static.js.map +1 -1
- package/dist/server/storageReclamation.d.ts +5 -0
- package/dist/server/storageReclamation.js +16 -0
- package/dist/server/storageReclamation.js.map +1 -1
- package/dist/server/threads/itc.d.ts +7 -2
- package/dist/server/threads/itc.js +5 -1
- package/dist/server/threads/itc.js.map +1 -1
- package/dist/server/threads/manageThreads.d.ts +26 -4
- package/dist/server/threads/manageThreads.js +517 -72
- package/dist/server/threads/manageThreads.js.map +1 -1
- package/dist/server/threads/socketRouter.js +89 -26
- package/dist/server/threads/socketRouter.js.map +1 -1
- package/dist/server/threads/threadHeapMemory.d.ts +2 -0
- package/dist/server/threads/threadHeapMemory.js +31 -0
- package/dist/server/threads/threadHeapMemory.js.map +1 -0
- package/dist/server/threads/threadServer.js +46 -15
- package/dist/server/threads/threadServer.js.map +1 -1
- package/dist/sqlEngine/config.d.ts +1 -3
- package/dist/sqlEngine/config.js +19 -16
- package/dist/sqlEngine/config.js.map +1 -1
- package/dist/sqlTranslator/index.d.ts +1 -1
- package/dist/sqlTranslator/index.js +30 -7
- package/dist/sqlTranslator/index.js.map +1 -1
- package/dist/upgrade/directives/5-3-0.d.ts +7 -0
- package/dist/upgrade/directives/5-3-0.js +148 -0
- package/dist/upgrade/directives/5-3-0.js.map +1 -0
- package/dist/upgrade/directives/directivesController.js +2 -1
- package/dist/upgrade/directives/directivesController.js.map +1 -1
- package/dist/utility/OperationFunctionCaller.js +2 -1
- package/dist/utility/OperationFunctionCaller.js.map +1 -1
- package/dist/utility/common_utils.d.ts +16 -0
- package/dist/utility/common_utils.js +32 -6
- package/dist/utility/common_utils.js.map +1 -1
- package/dist/utility/componentNames.d.ts +8 -0
- package/dist/utility/componentNames.js +12 -1
- package/dist/utility/componentNames.js.map +1 -1
- package/dist/utility/environment/environmentManager.js +3 -6
- package/dist/utility/environment/environmentManager.js.map +1 -1
- package/dist/utility/environment/systemInformation.d.ts +1 -0
- package/dist/utility/environment/systemInformation.js +1 -0
- package/dist/utility/environment/systemInformation.js.map +1 -1
- package/dist/utility/errors/commonErrors.d.ts +2 -0
- package/dist/utility/errors/commonErrors.js +2 -0
- package/dist/utility/errors/commonErrors.js.map +1 -1
- package/dist/utility/errors/hdbError.d.ts +17 -0
- package/dist/utility/errors/hdbError.js +30 -1
- package/dist/utility/errors/hdbError.js.map +1 -1
- package/dist/utility/globalSchema.d.ts +18 -0
- package/dist/utility/hdbTerms.d.ts +16 -0
- package/dist/utility/hdbTerms.js +18 -2
- package/dist/utility/hdbTerms.js.map +1 -1
- package/dist/utility/logging/harper_logger.d.ts +2 -0
- package/dist/utility/logging/harper_logger.js +91 -14
- package/dist/utility/logging/harper_logger.js.map +1 -1
- package/dist/utility/logging/logRotator.js +76 -49
- package/dist/utility/logging/logRotator.js.map +1 -1
- package/dist/utility/nodeIdentity.d.ts +9 -0
- package/dist/utility/nodeIdentity.js +58 -0
- package/dist/utility/nodeIdentity.js.map +1 -0
- package/dist/utility/npmUtilities.js +9 -7
- package/dist/utility/npmUtilities.js.map +1 -1
- package/dist/utility/operationPermissions.d.ts +3 -1
- package/dist/utility/operationPermissions.js +16 -1
- package/dist/utility/operationPermissions.js.map +1 -1
- package/dist/utility/operation_authorization.d.ts +10 -7
- package/dist/utility/operation_authorization.js +212 -41
- package/dist/utility/operation_authorization.js.map +1 -1
- package/dist/utility/watchPath.d.ts +29 -0
- package/dist/utility/watchPath.js +68 -0
- package/dist/utility/watchPath.js.map +1 -0
- package/dist/utility/watcherFallback.d.ts +86 -0
- package/dist/utility/watcherFallback.js +278 -1
- package/dist/utility/watcherFallback.js.map +1 -1
- package/dist/validation/configValidator.d.ts +12 -0
- package/dist/validation/configValidator.js +199 -72
- package/dist/validation/configValidator.js.map +1 -1
- package/dist/validation/installValidator.js +12 -0
- package/dist/validation/installValidator.js.map +1 -1
- package/dist/validation/validationWrapper.d.ts +11 -0
- package/dist/validation/validationWrapper.js +16 -3
- package/dist/validation/validationWrapper.js.map +1 -1
- package/index.ts +2 -0
- package/json/systemSchema.json +52 -0
- package/npm-shrinkwrap.json +235 -233
- package/package.json +8 -7
- package/resources/DESIGN.md +114 -52
- package/resources/DatabaseTransaction.ts +522 -130
- package/resources/LMDBTransaction.ts +26 -4
- package/resources/PrimaryRocksDatabase.ts +29 -3
- package/resources/RecordEncoder.ts +103 -8
- package/resources/RequestTarget.ts +2 -0
- package/resources/Resource.ts +17 -9
- package/resources/ResourceInterface.ts +23 -0
- package/resources/RocksIndexStore.ts +30 -10
- package/resources/RocksTransactionLogStore.ts +78 -21
- package/resources/Table.ts +1107 -164
- package/resources/auditStore.ts +187 -21
- package/resources/blob.ts +1029 -110
- package/resources/branchDatabase.ts +941 -0
- package/resources/crdt.ts +76 -12
- package/resources/databases.ts +1354 -522
- package/resources/defineTable.ts +18 -2
- package/resources/graphql.ts +70 -16
- package/resources/indexes/HierarchicalNavigableSmallWorld.ts +6 -2
- package/resources/longLivedTransactions.ts +360 -0
- package/resources/models/backendRegistry.ts +84 -2
- package/resources/models/bootstrap.ts +473 -28
- package/resources/recordLock.ts +253 -0
- package/resources/replayLogs.ts +147 -26
- package/resources/replayLogsGuards.ts +171 -8
- package/resources/search.ts +154 -32
- package/resources/transactionBroadcast.ts +3 -3
- package/security/auth.ts +68 -29
- package/security/authn/oidc/claims.ts +72 -0
- package/security/authn/oidc/identityToken.ts +129 -0
- package/security/authn/oidc/jwks.ts +260 -0
- package/security/authn/oidc/providers/generic.ts +40 -0
- package/security/authn/oidc/providers/githubActions.ts +137 -0
- package/security/authn/oidc/providers/index.ts +52 -0
- package/security/authn/oidc/tokenExchange.ts +300 -0
- package/security/authn/oidc/trustPolicyOperations.ts +343 -0
- package/security/authn/oidc/types.ts +41 -0
- package/security/certificateVerification/index.ts +54 -13
- package/security/certificateVerification/trustedIssuers.ts +76 -0
- package/security/certificateVerification/types.ts +1 -0
- package/security/credentialProvenance.ts +47 -0
- package/security/credentialRejection.ts +22 -0
- package/security/deferredAuthentication.ts +71 -0
- package/security/impersonation.ts +117 -12
- package/security/jsLoader.ts +81 -18
- package/security/keys.ts +298 -72
- package/security/operationScope.ts +33 -0
- package/security/permissionsTranslator.js +23 -0
- package/security/tokenAuthentication.ts +233 -12
- package/security/user.ts +4 -3
- package/server/DESIGN.md +183 -16
- package/server/DurableSubscriptionsSession.ts +71 -11
- package/server/REST.ts +79 -1
- package/server/graphqlQuerying.ts +4 -0
- package/server/http.ts +99 -18
- package/server/itc/serverHandlers.js +8 -1
- package/server/jobs/jobProcess.ts +8 -2
- package/server/jobs/jobs.ts +4 -1
- package/server/liveSubscriptionAuth.ts +129 -46
- package/server/loadRootComponents.js +50 -8
- package/server/mqtt.ts +179 -38
- package/server/nodeName.ts +103 -21
- package/server/serverHelpers/Headers.ts +131 -0
- package/server/serverHelpers/contentTypes.ts +29 -21
- package/server/serverHelpers/deployValidationState.ts +24 -13
- package/server/serverHelpers/operationAuthorizationState.ts +34 -3
- package/server/serverHelpers/registeredOperations.ts +79 -22
- package/server/serverHelpers/requestSanitization.ts +15 -0
- package/server/serverHelpers/serverHandlers.js +6 -3
- package/server/serverHelpers/serverUtilities.ts +104 -31
- package/server/serverHelpers/sharedMessageEncoding.ts +307 -0
- package/server/serverHelpers/uwsServer.ts +17 -2
- package/server/static.ts +23 -29
- package/server/storageReclamation.ts +13 -0
- package/server/threads/itc.js +11 -1
- package/server/threads/manageThreads.js +526 -63
- package/server/threads/socketRouter.ts +81 -26
- package/server/threads/threadHeapMemory.ts +26 -0
- package/server/threads/threadServer.js +43 -15
- package/sqlTranslator/index.ts +31 -8
- package/studio/web/assets/{Chat-Br06zdMA.js → Chat-BnCBegQz.js} +1 -1
- package/studio/web/assets/{FloatingChat-BWImX5fA.js → FloatingChat-CoDW1ySS.js} +3 -3
- package/studio/web/assets/{apiToken-DN0nmDsq.js → apiToken-Bwk5BLXW.js} +1 -1
- package/studio/web/assets/{applications-kSxVoyeU.js → applications-DHxGi7JH.js} +1 -1
- package/studio/web/assets/{cssMode-C1JeufH5.js → cssMode-s0cWI-_M.js} +1 -1
- package/studio/web/assets/{editor-qoo9CrGO.js → editor-DNcRHK54.js} +1 -1
- package/studio/web/assets/{html-Dt4IIy04.js → html-Bdssedlg.js} +1 -1
- package/studio/web/assets/{htmlMode-DXgKKr4C.js → htmlMode-CoDlJ3fw.js} +1 -1
- package/studio/web/assets/{index-6onkYFOG.js → index-D6sxmFLR.js} +5 -5
- package/studio/web/assets/{index.lazy-BrCFnpNJ.js → index.lazy-tmU5BS8s.js} +1 -1
- package/studio/web/assets/{javascript-DNCQGUBc.js → javascript-B8meVSTH.js} +1 -1
- package/studio/web/assets/{jsonMode-CR6HWruP.js → jsonMode-DpIPd35T.js} +1 -1
- package/studio/web/assets/{languageServices-BM4fI4rS.js → languageServices-C_5FMJzQ.js} +1 -1
- package/studio/web/assets/{lspLanguageFeatures-DSa1ttcD.js → lspLanguageFeatures-BIzNBzPK.js} +1 -1
- package/studio/web/assets/{notifications-BHXLnh6x.js → notifications-CQf18QKb.js} +1 -1
- package/studio/web/assets/{notifications-CUmtIA6z.js → notifications-CvZivSbh.js} +1 -1
- package/studio/web/assets/{profile-8BeFSF3j.js → profile-DdOwtntb.js} +1 -1
- package/studio/web/assets/{regions-C8qR0HhD.js → regions-n69fwagr.js} +1 -1
- package/studio/web/assets/{register-B4n5i0SD.js → register-PfWTCXWB.js} +2 -2
- package/studio/web/assets/{setComponentFile-g0_B0lgX.js → setComponentFile-Bg6O7X0S.js} +1 -1
- package/studio/web/assets/{setup-B0CTj_Q5.js → setup-CUx_aUDl.js} +2 -2
- package/studio/web/assets/{status-C6Yib7-K.js → status-D7BVKqX9.js} +1 -1
- package/studio/web/assets/{toggleHighContrast-Dgta7bVi.js → toggleHighContrast-DBSyXzMr.js} +1 -1
- package/studio/web/assets/{tsMode-CH_jHvU-.js → tsMode-BByKCjBS.js} +1 -1
- package/studio/web/assets/{typescript-Co9LCXd5.js → typescript-DDLnLpw9.js} +1 -1
- package/studio/web/assets/{useEntityRestURL-wKC8NsC_.js → useEntityRestURL-31CHGaHk.js} +1 -1
- package/studio/web/assets/{workers-CWeLxCXA.js → workers-pR3jRY9D.js} +1 -1
- package/studio/web/assets/{xml-BadC-0Rk.js → xml-2iRnMhQO.js} +1 -1
- package/studio/web/assets/{yaml-BiUfxPbC.js → yaml-Bf92gJpd.js} +1 -1
- package/studio/web/index.html +1 -1
- package/upgrade/directives/5-3-0.ts +132 -0
- package/upgrade/directives/directivesController.ts +2 -1
- package/utility/OperationFunctionCaller.ts +2 -1
- package/utility/common_utils.ts +30 -5
- package/utility/componentNames.ts +12 -0
- package/utility/environment/environmentManager.ts +3 -7
- package/utility/environment/systemInformation.ts +7 -0
- package/utility/errors/commonErrors.ts +4 -0
- package/utility/errors/hdbError.ts +29 -0
- package/utility/hdbTerms.ts +17 -0
- package/utility/logging/harper_logger.ts +87 -14
- package/utility/logging/logRotator.ts +72 -45
- package/utility/nodeIdentity.ts +45 -0
- package/utility/npmUtilities.ts +10 -8
- package/utility/operationPermissions.ts +18 -1
- package/utility/operation_authorization.ts +231 -42
- package/utility/watchPath.ts +63 -0
- package/utility/watcherFallback.ts +270 -0
- package/validation/configValidator.ts +209 -72
- package/validation/installValidator.ts +15 -0
- package/validation/validationWrapper.ts +18 -4
|
@@ -9,12 +9,17 @@
|
|
|
9
9
|
// running over potentially millions of entries, pinning CPU. These guards classify each
|
|
10
10
|
// entry up front so the loop can skip cleanly.
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.REPLAY_WALL_CLOCK_LIMIT_MS = exports.REPLAY_NO_PROGRESS_TIME_SKIP_FLOOR = exports.REPLAY_NO_PROGRESS_TIME_LIMIT_MS = exports.REPLAY_NO_PROGRESS_COUNT_LIMIT = exports.RECORD_BEARING_FLAGS = void 0;
|
|
12
|
+
exports.MAX_CORRUPT_FRAME_REPORTS = exports.REPLAY_WALL_CLOCK_LIMIT_MS = exports.REPLAY_NO_PROGRESS_TIME_SKIP_FLOOR = exports.REPLAY_NO_PROGRESS_TIME_LIMIT_MS = exports.REPLAY_NO_PROGRESS_COUNT_LIMIT = exports.RECORD_BEARING_FLAGS = void 0;
|
|
13
13
|
exports.classifyAuditEntryForReplay = classifyAuditEntryForReplay;
|
|
14
14
|
exports.isUndecodableValidatedWrite = isUndecodableValidatedWrite;
|
|
15
15
|
exports.shouldAbortStalledReplay = shouldAbortStalledReplay;
|
|
16
16
|
exports.shouldAbortSlowReplay = shouldAbortSlowReplay;
|
|
17
|
+
exports.isMidLogBreak = isMidLogBreak;
|
|
17
18
|
exports.endIteratorOnCorruptFrame = endIteratorOnCorruptFrame;
|
|
19
|
+
exports.getCorruptFrameReports = getCorruptFrameReports;
|
|
20
|
+
exports.getEvictedCorruptFrameReportCount = getEvictedCorruptFrameReportCount;
|
|
21
|
+
exports.clearCorruptFrameReports = clearCorruptFrameReports;
|
|
22
|
+
exports.createCorruptFrameReporter = createCorruptFrameReporter;
|
|
18
23
|
// Mirrors `HAS_RECORD` (16) | `HAS_PARTIAL_RECORD` (32) from auditStore.ts — the action
|
|
19
24
|
// bits the writer sets when an entry carries (or should carry) a record body. Redeclared
|
|
20
25
|
// here so this module stays free of the Harper module graph for unit testing; a lock
|
|
@@ -122,12 +127,26 @@ function shouldAbortSlowReplay(totalElapsedMs, timeLimitMs = exports.REPLAY_WALL
|
|
|
122
127
|
return totalElapsedMs >= timeLimitMs;
|
|
123
128
|
}
|
|
124
129
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
* Whether a corrupt frame is a mid-log break — intact entries followed it, so entries were lost
|
|
131
|
+
* rather than the log merely being torn at its tail. Shared by the reporter below and by
|
|
132
|
+
* `RocksTransactionLogStore.getRange`'s `CorruptFrameStop.midLogBreak`, so the two can't drift on
|
|
133
|
+
* what counts as a mid-log break.
|
|
134
|
+
*/
|
|
135
|
+
function isMidLogBreak(error) {
|
|
136
|
+
return error.resyncPosition != null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Wraps a transaction-log query iterator so a corrupt/torn frame ends that log's iteration cleanly
|
|
140
|
+
* instead of escaping as an uncaughtException.
|
|
141
|
+
*
|
|
142
|
+
* Iteration stops at the break whether or not intact entries follow it. Resuming past a mid-log
|
|
143
|
+
* break would recover those entries, but a transaction log carries no frame-level transaction
|
|
144
|
+
* boundaries: replay groups equal-version entries into one source transaction, so skipping a frame
|
|
145
|
+
* inside such a group applies and checkpoints the surviving subset of a transaction that never
|
|
146
|
+
* committed that way at the source. Availability loss is visible and recoverable; a silently torn
|
|
147
|
+
* transaction is neither. Recovery is deferred until the engine can resume at a proven boundary
|
|
148
|
+
* (harper#2016, harper#2063); `resyncPosition` is used only to report the break as lost entries
|
|
149
|
+
* rather than as a truncated tail.
|
|
131
150
|
*/
|
|
132
151
|
function endIteratorOnCorruptFrame(iterator, onCorruptFrame) {
|
|
133
152
|
let stopped = false;
|
|
@@ -167,4 +186,89 @@ function endIteratorOnCorruptFrame(iterator, onCorruptFrame) {
|
|
|
167
186
|
},
|
|
168
187
|
};
|
|
169
188
|
}
|
|
189
|
+
/** Distinct break sites retained. One physical corruption yields one site, so this is generous. */
|
|
190
|
+
exports.MAX_CORRUPT_FRAME_REPORTS = 256;
|
|
191
|
+
// Re-encounters move a site to the end, so the first key is the least recently seen. Full means
|
|
192
|
+
// evicting that one rather than refusing a new site, which could not then be deduplicated.
|
|
193
|
+
const corruptFrameReports = new Map();
|
|
194
|
+
let evictedCorruptFrameReports = 0;
|
|
195
|
+
/**
|
|
196
|
+
* Every corrupt frame seen by this worker. This is not yet consumed by cluster/health status;
|
|
197
|
+
* callers must aggregate it across worker threads before exposing a node-wide signal.
|
|
198
|
+
*
|
|
199
|
+
* Mid-log breaks are immediately logged at error level even without that consumer.
|
|
200
|
+
*/
|
|
201
|
+
function getCorruptFrameReports() {
|
|
202
|
+
return [...corruptFrameReports.values()];
|
|
203
|
+
}
|
|
204
|
+
/** Break sites evicted because {@link MAX_CORRUPT_FRAME_REPORTS} was reached. */
|
|
205
|
+
function getEvictedCorruptFrameReportCount() {
|
|
206
|
+
return evictedCorruptFrameReports;
|
|
207
|
+
}
|
|
208
|
+
function clearCorruptFrameReports() {
|
|
209
|
+
corruptFrameReports.clear();
|
|
210
|
+
evictedCorruptFrameReports = 0;
|
|
211
|
+
}
|
|
212
|
+
// `logId`/`position` are absent on any rocksdb-js predating the resync support, and every break on
|
|
213
|
+
// a stream would then collapse onto one key — folding genuinely different corruptions into a single
|
|
214
|
+
// count that only ever logs once. The message carries the offset and file in text, so it separates
|
|
215
|
+
// them when the fields can't.
|
|
216
|
+
function corruptFrameKey(logName, error) {
|
|
217
|
+
const { logId, position } = error;
|
|
218
|
+
return logId != null && position != null
|
|
219
|
+
? `${logName}\u0000${logId}:${position}`
|
|
220
|
+
: `${logName}\u0000${error.message}`;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Records a corrupt frame and logs it once per distinct break.
|
|
224
|
+
*
|
|
225
|
+
* A mid-log break is an `error`, not a `warn`: entries after it were acknowledged and are now
|
|
226
|
+
* quarantined behind it. Severity follows the break's own shape, never this pass's outcome — every
|
|
227
|
+
* pass stops, so keying on that would report the #2063 signature with the benign torn-tail `warn`.
|
|
228
|
+
* A site first seen as a torn tail can escalate later, since only a rocksdb-js that reports
|
|
229
|
+
* `resyncPosition` can tell the two apart.
|
|
230
|
+
*/
|
|
231
|
+
function createCorruptFrameReporter(logger) {
|
|
232
|
+
return (logName) => (error) => {
|
|
233
|
+
const midLog = isMidLogBreak(error);
|
|
234
|
+
const unreadableBytes = error.unreadableBytes ?? 0;
|
|
235
|
+
const now = Date.now();
|
|
236
|
+
const key = corruptFrameKey(logName, error);
|
|
237
|
+
const existing = corruptFrameReports.get(key);
|
|
238
|
+
if (existing) {
|
|
239
|
+
corruptFrameReports.delete(key);
|
|
240
|
+
corruptFrameReports.set(key, existing);
|
|
241
|
+
existing.occurrences++;
|
|
242
|
+
existing.lastSeen = now;
|
|
243
|
+
if (!midLog || existing.midLog)
|
|
244
|
+
return;
|
|
245
|
+
existing.midLog = true;
|
|
246
|
+
existing.unreadableBytes = unreadableBytes;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
if (corruptFrameReports.size >= exports.MAX_CORRUPT_FRAME_REPORTS) {
|
|
250
|
+
corruptFrameReports.delete(corruptFrameReports.keys().next().value);
|
|
251
|
+
evictedCorruptFrameReports++;
|
|
252
|
+
}
|
|
253
|
+
corruptFrameReports.set(key, {
|
|
254
|
+
log: logName,
|
|
255
|
+
logId: error.logId ?? undefined,
|
|
256
|
+
position: error.position ?? undefined,
|
|
257
|
+
midLog,
|
|
258
|
+
unreadableBytes,
|
|
259
|
+
firstSeen: now,
|
|
260
|
+
lastSeen: now,
|
|
261
|
+
occurrences: 1,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
if (midLog) {
|
|
265
|
+
logger.error(`Corrupt entry in transaction log "${logName}"; ${unreadableBytes} byte(s) are unreadable and the entries within them are lost. ` +
|
|
266
|
+
'Intact entries follow the break, but reading stops there rather than skipping the frame, which could tear a source transaction: ' +
|
|
267
|
+
'they are quarantined until the log is repaired or this node is re-cloned, and they are neither replayed nor replicated meanwhile.', error);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
logger.warn(`Stopping transaction log "${logName}" at a corrupt entry during replay`, error);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
}
|
|
170
274
|
//# sourceMappingURL=replayLogsGuards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replayLogsGuards.js","sourceRoot":"","sources":["../../resources/replayLogsGuards.ts"],"names":[],"mappings":";AAAA,qFAAqF;AACrF,uFAAuF;AACvF,EAAE;AACF,yFAAyF;AACzF,uFAAuF;AACvF,iFAAiF;AACjF,sFAAsF;AACtF,wFAAwF;AACxF,+CAA+C;;;AAuB/C,kEAUC;AAmBD,kEAEC;AAsCD,4DASC;AAoBD,sDAEC;
|
|
1
|
+
{"version":3,"file":"replayLogsGuards.js","sourceRoot":"","sources":["../../resources/replayLogsGuards.ts"],"names":[],"mappings":";AAAA,qFAAqF;AACrF,uFAAuF;AACvF,EAAE;AACF,yFAAyF;AACzF,uFAAuF;AACvF,iFAAiF;AACjF,sFAAsF;AACtF,wFAAwF;AACxF,+CAA+C;;;AAuB/C,kEAUC;AAmBD,kEAEC;AAsCD,4DASC;AAoBD,sDAEC;AA2CD,sCAEC;AAeD,8DAmCC;AAkCD,wDAEC;AAGD,8EAEC;AAED,4DAGC;AAsBD,gEA6CC;AAzUD,wFAAwF;AACxF,yFAAyF;AACzF,qFAAqF;AACrF,oEAAoE;AACvD,QAAA,oBAAoB,GAAG,EAAE,GAAG,EAAE,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,SAAgB,2BAA2B,CAC1C,MAA0B,EAC1B,OAA2B,EAC3B,SAAkB;IAElB,IAAI,MAAM,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,gBAAgB,CAAC;IAC3E,kFA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B,OAAO,oCAAoC,EAAE,KAAK,CAAC,CAAC;QAC9F,CAAC;IACF,CAAC,CAAC;AACH,CAAC"}
|
package/dist/resources/search.js
CHANGED
|
@@ -18,6 +18,7 @@ const ordered_binary_1 = require("ordered-binary");
|
|
|
18
18
|
const extended_iterable_1 = require("@harperfast/extended-iterable");
|
|
19
19
|
const Table_ts_1 = require("./Table.js");
|
|
20
20
|
const RecordEncoder_ts_1 = require("./RecordEncoder.js");
|
|
21
|
+
const DatabaseTransaction_ts_1 = require("./DatabaseTransaction.js");
|
|
21
22
|
const write_1 = require("./analytics/write");
|
|
22
23
|
const rocksdb_js_1 = require("@harperfast/rocksdb-js");
|
|
23
24
|
// these are ratios/percentages of overall table size
|
|
@@ -212,6 +213,41 @@ function composeRecordFilter(recordFilters, table, context) {
|
|
|
212
213
|
return verdict;
|
|
213
214
|
};
|
|
214
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* A record's index entries are not adjacent — the composite `[indexedValue, primaryKey]` key sorts
|
|
218
|
+
* on the indexed value first — so comparing neighbours cannot collapse them and the scan has to
|
|
219
|
+
* remember what it already yielded (#2434).
|
|
220
|
+
*
|
|
221
|
+
* Heap cost is one key per distinct record in the scanned range, held for the life of the scan, and
|
|
222
|
+
* a page window does not cap it: sibling-condition and row filters run downstream, so a selective
|
|
223
|
+
* filter keeps the scan running and the set growing while the page fills. On a multi-million-row
|
|
224
|
+
* range that is hundreds of MB where main streamed at O(1). Accepted for #2434 over the bounded
|
|
225
|
+
* alternative, which costs a primary read per index entry.
|
|
226
|
+
*/
|
|
227
|
+
function distinctRecords(entries) {
|
|
228
|
+
const distinct = new extended_iterable_1.ExtendedIterable();
|
|
229
|
+
distinct.iterate = (options) => {
|
|
230
|
+
// A non-scalar key decodes to a fresh instance per entry, so identity never matches it;
|
|
231
|
+
// `writeKeyId` is the store's own key equality. Its bytes get their own set because a scalar
|
|
232
|
+
// string id can legitimately carry exactly those bytes, and one set would fold the two —
|
|
233
|
+
// the collision `flattenKey` has, and the reason Table.ts prefixes its key ids.
|
|
234
|
+
const yieldedKeys = new Set();
|
|
235
|
+
const yieldedEncodedKeys = new Set();
|
|
236
|
+
// map rather than filter: filter clears `continueOnRecoverableError` for everything below it
|
|
237
|
+
return entries
|
|
238
|
+
.map((primaryKey) => {
|
|
239
|
+
const isEncoded = typeof primaryKey === 'object' && primaryKey !== null;
|
|
240
|
+
const yielded = isEncoded ? yieldedEncodedKeys : yieldedKeys;
|
|
241
|
+
const identity = isEncoded ? (0, DatabaseTransaction_ts_1.writeKeyId)(primaryKey) : primaryKey;
|
|
242
|
+
if (yielded.has(identity))
|
|
243
|
+
return extended_iterable_1.SKIP;
|
|
244
|
+
yielded.add(identity);
|
|
245
|
+
return primaryKey;
|
|
246
|
+
})
|
|
247
|
+
.iterate(options);
|
|
248
|
+
};
|
|
249
|
+
return distinct;
|
|
250
|
+
}
|
|
215
251
|
/**
|
|
216
252
|
* Search for records or keys, based on the search condition, using an index if available
|
|
217
253
|
* @param searchCondition
|
|
@@ -233,6 +269,9 @@ minResults) {
|
|
|
233
269
|
throw new hdbError_ts_1.ClientError(`Search condition for ${attribute_name} must have a value`);
|
|
234
270
|
}
|
|
235
271
|
let needFullScan;
|
|
272
|
+
// `[indexedValue, primaryKey]` is unique, so a scan that stays inside one indexed value cannot
|
|
273
|
+
// reach a record twice and skips the collapse below
|
|
274
|
+
let scansOneIndexedValue;
|
|
236
275
|
if (Array.isArray(attribute_name)) {
|
|
237
276
|
const firstAttributeName = attribute_name[0];
|
|
238
277
|
// get the potential relationship attribute
|
|
@@ -356,6 +395,7 @@ minResults) {
|
|
|
356
395
|
start = value;
|
|
357
396
|
end = value;
|
|
358
397
|
inclusiveEnd = true;
|
|
398
|
+
scansOneIndexedValue = true;
|
|
359
399
|
break;
|
|
360
400
|
case 'in':
|
|
361
401
|
// Phase 1: route through filter — index-merge optimization is a Phase 2 follow-up.
|
|
@@ -497,7 +537,7 @@ minResults) {
|
|
|
497
537
|
}
|
|
498
538
|
return loaded;
|
|
499
539
|
}
|
|
500
|
-
|
|
540
|
+
const scanned = index.getRange(rangeOptions).map(filter
|
|
501
541
|
? function ({ key, value }) {
|
|
502
542
|
let recordMatcher;
|
|
503
543
|
if (typeof key === 'string' && key.length > terms_ts_1.MAX_SEARCH_KEY_LENGTH) {
|
|
@@ -520,6 +560,14 @@ minResults) {
|
|
|
520
560
|
}));
|
|
521
561
|
}
|
|
522
562
|
: ({ value }) => value);
|
|
563
|
+
// Collapsing AFTER the map is required, not incidental: the condition's own filter tests one
|
|
564
|
+
// element at a time, so a record whose first entry fails it and whose second passes must
|
|
565
|
+
// still be reached. Collapsing first would settle that record on the failing entry and drop
|
|
566
|
+
// it. Scoped to attributes the schema declares multi-valued; a runtime array under an
|
|
567
|
+
// undeclared attribute repeats the same way but stays outside this boundary.
|
|
568
|
+
return scansOneIndexedValue || !findAttribute(Table.attributes, attribute_name)?.elements
|
|
569
|
+
? scanned
|
|
570
|
+
: distinctRecords(scanned);
|
|
523
571
|
}
|
|
524
572
|
else {
|
|
525
573
|
return Table.primaryStore
|
|
@@ -1020,7 +1068,7 @@ function filterByType(searchCondition, Table, context, filtered, isPrimaryKey, e
|
|
|
1020
1068
|
canUseIndex =
|
|
1021
1069
|
canUseIndex && // is it a comparator that makes sense to use index
|
|
1022
1070
|
!isPrimaryKey && // no need to use index for primary keys, since we will be iterating over the primary keys
|
|
1023
|
-
|
|
1071
|
+
Table?.indices[attribute] && // is there an index for this attribute
|
|
1024
1072
|
estimatedIncomingCount > 3; // do we have a valid estimate of multiple incoming records (that is worth using an index for)
|
|
1025
1073
|
if (canUseIndex) {
|
|
1026
1074
|
if (searchCondition.estimated_count == undefined)
|
|
@@ -1077,27 +1125,95 @@ function filterByType(searchCondition, Table, context, filtered, isPrimaryKey, e
|
|
|
1077
1125
|
return recordFilter;
|
|
1078
1126
|
}
|
|
1079
1127
|
}
|
|
1080
|
-
/** The index a condition can be driven by; searchByIndex refuses a rebuilding one, so it reads as absent. */
|
|
1081
|
-
function usableIndex(table, attributeName) {
|
|
1082
|
-
const index = attributeName == null ? undefined : table.indices[attributeName];
|
|
1083
|
-
return index?.isIndexing ? undefined : index;
|
|
1084
|
-
}
|
|
1085
1128
|
/**
|
|
1086
|
-
*
|
|
1087
|
-
*
|
|
1129
|
+
* Estimates a range comparator's entry count from the store's statistical estimate, blended with
|
|
1130
|
+
* the table-fraction heuristic by the estimate's confidence so low-confidence estimates degrade
|
|
1131
|
+
* to the old behavior. Returns undefined (caller falls back to the heuristic) when the store
|
|
1132
|
+
* cannot estimate, the shape is unexpected, or the executed range wouldn't match this one.
|
|
1088
1133
|
*/
|
|
1089
|
-
function
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
if (
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1134
|
+
function estimateRangeCondition(table, condition, searchType, fraction) {
|
|
1135
|
+
const attributeName = condition[0] ?? condition.attribute;
|
|
1136
|
+
const isPrimaryKey = attributeName === table.primaryKey;
|
|
1137
|
+
const store = isPrimaryKey ? table.primaryStore : table.indices[attributeName];
|
|
1138
|
+
// LMDB-backed and custom index stores do not implement estimateCount
|
|
1139
|
+
if (typeof store?.estimateCount !== 'function')
|
|
1140
|
+
return undefined;
|
|
1141
|
+
let value = condition[1] ?? condition.value;
|
|
1142
|
+
if (value instanceof Date)
|
|
1143
|
+
value = value.getTime();
|
|
1144
|
+
let range;
|
|
1145
|
+
switch (searchType) {
|
|
1146
|
+
case 'lt':
|
|
1147
|
+
// `start: true` mirrors searchByIndex: `true` sorts above `null`, so an indexNulls
|
|
1148
|
+
// index's `[null, primaryKey]` entries are outside the executed range
|
|
1149
|
+
range = { start: true, end: value };
|
|
1150
|
+
break;
|
|
1151
|
+
case 'le':
|
|
1152
|
+
range = { start: true, end: value, inclusiveEnd: true };
|
|
1153
|
+
break;
|
|
1154
|
+
case 'gt':
|
|
1155
|
+
range = { start: value, exclusiveStart: true };
|
|
1156
|
+
break;
|
|
1157
|
+
case 'ge':
|
|
1158
|
+
range = { start: value };
|
|
1159
|
+
break;
|
|
1160
|
+
case 'between':
|
|
1161
|
+
case 'gele':
|
|
1162
|
+
case 'gelt':
|
|
1163
|
+
case 'gtlt':
|
|
1164
|
+
case 'gtle': {
|
|
1165
|
+
if (!Array.isArray(value))
|
|
1166
|
+
return undefined;
|
|
1167
|
+
let [start, end] = value;
|
|
1168
|
+
if (start instanceof Date)
|
|
1169
|
+
start = start.getTime();
|
|
1170
|
+
if (end instanceof Date)
|
|
1171
|
+
end = end.getTime();
|
|
1172
|
+
range = {
|
|
1173
|
+
start,
|
|
1174
|
+
end,
|
|
1175
|
+
inclusiveEnd: searchType === 'between' || searchType === 'gele' || searchType === 'gtle',
|
|
1176
|
+
exclusiveStart: searchType === 'gtlt' || searchType === 'gtle',
|
|
1177
|
+
};
|
|
1178
|
+
break;
|
|
1179
|
+
}
|
|
1180
|
+
case 'starts_with': {
|
|
1181
|
+
const prefix = value?.toString();
|
|
1182
|
+
if (!prefix)
|
|
1183
|
+
return undefined;
|
|
1184
|
+
range = { start: prefix, end: getStringPrefixUpperBound(prefix) };
|
|
1185
|
+
break;
|
|
1186
|
+
}
|
|
1187
|
+
case 'prefix': {
|
|
1188
|
+
let start = Array.isArray(value) ? value : [value, null];
|
|
1189
|
+
if (start[start.length - 1] != null)
|
|
1190
|
+
start = start.concat(null);
|
|
1191
|
+
const end = start.slice(0);
|
|
1192
|
+
end[end.length - 1] = ordered_binary_1.MAXIMUM_KEY;
|
|
1193
|
+
range = { start, end };
|
|
1194
|
+
break;
|
|
1195
|
+
}
|
|
1196
|
+
default:
|
|
1197
|
+
return undefined;
|
|
1198
|
+
}
|
|
1199
|
+
// Long string bounds get truncated + filtered at execution (searchByIndex), so the
|
|
1200
|
+
// executed range is wider than this one; don't estimate what won't be iterated.
|
|
1201
|
+
if ((typeof range.start === 'string' && range.start.length > terms_ts_1.MAX_SEARCH_KEY_LENGTH) ||
|
|
1202
|
+
(typeof range.end === 'string' && range.end.length > terms_ts_1.MAX_SEARCH_KEY_LENGTH)) {
|
|
1203
|
+
return undefined;
|
|
1204
|
+
}
|
|
1205
|
+
let count, confidence;
|
|
1206
|
+
try {
|
|
1207
|
+
({ count, confidence } = store.estimateCount(range) ?? {});
|
|
1208
|
+
}
|
|
1209
|
+
catch {
|
|
1210
|
+
// a concurrently closing/dropped store must degrade the plan, not fail the query
|
|
1211
|
+
return undefined;
|
|
1212
|
+
}
|
|
1213
|
+
if (!Number.isFinite(count) || count < 0 || !Number.isFinite(confidence) || confidence < 0 || confidence > 1)
|
|
1214
|
+
return undefined;
|
|
1215
|
+
const heuristic = fraction * estimatedEntryCount(table.primaryStore) + 1;
|
|
1216
|
+
return Math.max(1, Math.round(confidence * count + (1 - confidence) * heuristic));
|
|
1101
1217
|
}
|
|
1102
1218
|
function estimateCondition(table) {
|
|
1103
1219
|
function estimateConditionForTable(condition) {
|
|
@@ -1129,8 +1245,12 @@ function estimateCondition(table) {
|
|
|
1129
1245
|
// skip if it is cached
|
|
1130
1246
|
let searchType = condition.comparator || condition.search_type;
|
|
1131
1247
|
searchType = ALTERNATE_COMPARATOR_NAMES[searchType] || searchType;
|
|
1132
|
-
|
|
1133
|
-
|
|
1248
|
+
if (condition.negated) {
|
|
1249
|
+
// a negated condition always executes as a full scan (searchByIndex forces
|
|
1250
|
+
// needFullScan), so follow the filter-only convention used by contains/ends_with:
|
|
1251
|
+
// estimate Infinity so its positive-range estimate can never win the driving-condition
|
|
1252
|
+
// ordering. Short-circuit here rather than computing (and discarding) a positive-range
|
|
1253
|
+
// estimate that would cross the native FFI boundary for nothing.
|
|
1134
1254
|
condition.estimated_count = Infinity;
|
|
1135
1255
|
}
|
|
1136
1256
|
else if (searchType === terms_ts_1.SEARCH_TYPES.EQUALS || !searchType) {
|
|
@@ -1162,13 +1282,13 @@ function estimateCondition(table) {
|
|
|
1162
1282
|
}
|
|
1163
1283
|
else {
|
|
1164
1284
|
// we only attempt to estimate count on equals operator because that's really all that LMDB supports (some other key-value stores like libmdbx could be considered if we need to do estimated counts of ranges at some point)
|
|
1165
|
-
const index =
|
|
1285
|
+
const index = table.indices[attribute_name];
|
|
1166
1286
|
condition.estimated_count = index ? index.getValuesCount(condition[1] ?? condition.value) : Infinity;
|
|
1167
1287
|
}
|
|
1168
1288
|
}
|
|
1169
1289
|
else if (searchType === 'contains' || searchType === 'ends_with' || searchType === 'ne') {
|
|
1170
1290
|
const attribute_name = condition[0] ?? condition.attribute;
|
|
1171
|
-
const index =
|
|
1291
|
+
const index = table.indices[attribute_name];
|
|
1172
1292
|
if (condition.value === null && searchType === 'ne') {
|
|
1173
1293
|
condition.estimated_count = Math.max(estimatedEntryCount(table.primaryStore) - (index ? index.getValuesCount(null) : 0), 0);
|
|
1174
1294
|
}
|
|
@@ -1177,7 +1297,7 @@ function estimateCondition(table) {
|
|
|
1177
1297
|
}
|
|
1178
1298
|
else if (searchType === 'in') {
|
|
1179
1299
|
const attribute_name = condition[0] ?? condition.attribute;
|
|
1180
|
-
const index =
|
|
1300
|
+
const index = table.indices[attribute_name];
|
|
1181
1301
|
if (Array.isArray(condition.value) && index) {
|
|
1182
1302
|
// Sum of per-value matches (over-counts duplicates but is a fine ceiling)
|
|
1183
1303
|
let estimate = 0;
|
|
@@ -1191,15 +1311,18 @@ function estimateCondition(table) {
|
|
|
1191
1311
|
}
|
|
1192
1312
|
else
|
|
1193
1313
|
condition.estimated_count = Infinity;
|
|
1194
|
-
// for range queries (betweens, startsWith, greater, etc.), just arbitrarily guess
|
|
1195
1314
|
}
|
|
1196
1315
|
else if (searchType === 'starts_with' || searchType === 'prefix')
|
|
1197
|
-
condition.estimated_count =
|
|
1316
|
+
condition.estimated_count =
|
|
1317
|
+
estimateRangeCondition(table, condition, searchType, STARTS_WITH_ESTIMATE) ??
|
|
1318
|
+
STARTS_WITH_ESTIMATE * estimatedEntryCount(table.primaryStore) + 1;
|
|
1198
1319
|
else if (searchType === 'between')
|
|
1199
|
-
condition.estimated_count =
|
|
1320
|
+
condition.estimated_count =
|
|
1321
|
+
estimateRangeCondition(table, condition, searchType, BETWEEN_ESTIMATE) ??
|
|
1322
|
+
BETWEEN_ESTIMATE * estimatedEntryCount(table.primaryStore) + 1;
|
|
1200
1323
|
else if (searchType === 'sort') {
|
|
1201
1324
|
const attribute_name = condition[0] ?? condition.attribute;
|
|
1202
|
-
const index =
|
|
1325
|
+
const index = table.indices[attribute_name];
|
|
1203
1326
|
if (index?.customIndex?.estimateCountAsSort)
|
|
1204
1327
|
// allow custom index to define its own estimation of counts
|
|
1205
1328
|
condition.estimated_count = index.customIndex.estimateCountAsSort(condition);
|
|
@@ -1209,12 +1332,14 @@ function estimateCondition(table) {
|
|
|
1209
1332
|
else {
|
|
1210
1333
|
// for the search types that use the broadest range, try do them last
|
|
1211
1334
|
const attribute_name = condition[0] ?? condition.attribute;
|
|
1212
|
-
const index =
|
|
1335
|
+
const index = table.indices[attribute_name];
|
|
1213
1336
|
if (index?.customIndex?.estimateCount)
|
|
1214
1337
|
// allow custom index to define its own estimation of counts
|
|
1215
1338
|
condition.estimated_count = index.customIndex.estimateCount(condition.value);
|
|
1216
1339
|
else
|
|
1217
|
-
condition.estimated_count =
|
|
1340
|
+
condition.estimated_count =
|
|
1341
|
+
estimateRangeCondition(table, condition, searchType, OPEN_RANGE_ESTIMATE) ??
|
|
1342
|
+
OPEN_RANGE_ESTIMATE * estimatedEntryCount(table.primaryStore) + 1;
|
|
1218
1343
|
}
|
|
1219
1344
|
// we give a condition significantly more weight/preference if we will be ordering by it
|
|
1220
1345
|
if (typeof condition.descending === 'boolean')
|
|
@@ -1427,6 +1552,7 @@ function parseBlock(query, expectedEnd) {
|
|
|
1427
1552
|
break;
|
|
1428
1553
|
case 'group-by':
|
|
1429
1554
|
recordError('group by is not implemented yet');
|
|
1555
|
+
break;
|
|
1430
1556
|
case 'sort':
|
|
1431
1557
|
query.sort = toSortObject(args);
|
|
1432
1558
|
break;
|