@harperfast/harper 5.0.25 → 5.1.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/README.md +11 -10
- package/agent/agent.ts +203 -0
- package/agent/loop.ts +205 -0
- package/agent/operations.ts +148 -0
- package/agent/session.ts +187 -0
- package/agent/tools/fsTools.ts +276 -0
- package/agent/tools/httpFetchTool.ts +112 -0
- package/agent/tools/scheduleTool.ts +68 -0
- package/agent/toolset.ts +43 -0
- package/agent/types.ts +85 -0
- package/bin/{BinObjects.js → BinObjects.ts} +4 -5
- package/bin/cliCredentials.ts +133 -0
- package/bin/cliOperations.ts +339 -0
- package/bin/copyDb.ts +10 -10
- package/bin/deployRenderer.ts +196 -0
- package/bin/{harper.js → harper.ts} +43 -19
- package/bin/{install.js → install.ts} +3 -3
- package/bin/lite.ts +2 -0
- package/bin/login.ts +168 -0
- package/bin/logout.ts +11 -0
- package/bin/mcp/client.ts +407 -0
- package/bin/mcp/doctor.ts +189 -0
- package/bin/mcp/index.ts +80 -0
- package/bin/mcp/options.ts +122 -0
- package/bin/mcp/printConfig.ts +89 -0
- package/bin/multipartBuilder.ts +74 -0
- package/bin/{restart.js → restart.ts} +27 -28
- package/bin/{run.js → run.ts} +41 -30
- package/bin/sseConsumer.ts +126 -0
- package/bin/{status.js → status.ts} +10 -10
- package/bin/{stop.js → stop.ts} +5 -5
- package/bin/upgrade.js +6 -6
- package/components/Application.ts +144 -18
- package/components/ApplicationScope.ts +2 -2
- package/components/ComponentV1.ts +2 -2
- package/components/EntryHandler.ts +159 -9
- package/components/OptionsWatcher.ts +75 -11
- package/components/Scope.ts +125 -15
- package/components/anthropic/index.ts +547 -0
- package/components/bedrock/index.ts +823 -0
- package/components/componentLoader.ts +63 -32
- package/components/deployLifecycle.ts +161 -0
- package/components/deploymentOperations.ts +173 -0
- package/components/deploymentRecorder.ts +402 -0
- package/components/deriveURLPath.ts +4 -4
- package/components/mcp/adapters/fastify.ts +87 -0
- package/components/mcp/adapters/harperHttp.ts +103 -0
- package/components/mcp/audit.ts +75 -0
- package/components/mcp/index.ts +134 -0
- package/components/mcp/jsonrpc.ts +134 -0
- package/components/mcp/lifecycle.ts +105 -0
- package/components/mcp/listChanged.ts +270 -0
- package/components/mcp/rateLimit.ts +217 -0
- package/components/mcp/resources.ts +593 -0
- package/components/mcp/session.ts +151 -0
- package/components/mcp/sessionRegistry.ts +140 -0
- package/components/mcp/toolRegistry.ts +292 -0
- package/components/mcp/tools/application.ts +603 -0
- package/components/mcp/tools/operations.ts +283 -0
- package/components/mcp/tools/schemas/derive.ts +256 -0
- package/components/mcp/tools/schemas/operations.ts +245 -0
- package/components/mcp/transport.ts +517 -0
- package/components/ollama/index.ts +316 -0
- package/components/openai/index.ts +563 -0
- package/components/operations.js +211 -60
- package/components/operationsValidation.js +3 -3
- package/components/packageComponent.ts +97 -29
- package/components/requestRestart.ts +17 -2
- package/components/status/crossThread.ts +14 -5
- package/components/status/errors.ts +1 -1
- package/config/RootConfigWatcher.ts +56 -2
- package/config/configUtils.js +29 -8
- package/config/harperConfigEnvVars.ts +1 -1
- package/config-root.schema.json +74 -0
- package/dataLayer/{CreateAttributeObject.js → CreateAttributeObject.ts} +4 -3
- package/dataLayer/{CreateTableObject.js → CreateTableObject.ts} +2 -1
- package/dataLayer/{DataLayerObjects.js → DataLayerObjects.ts} +17 -9
- package/dataLayer/{DeleteBeforeObject.js → DeleteBeforeObject.ts} +2 -1
- package/dataLayer/{DeleteObject.js → DeleteObject.ts} +3 -2
- package/dataLayer/{DropAttributeObject.js → DropAttributeObject.ts} +2 -1
- package/dataLayer/{GetBackupObject.js → GetBackupObject.ts} +3 -2
- package/dataLayer/{InsertObject.js → InsertObject.ts} +3 -2
- package/dataLayer/{ReadAuditLogObject.js → ReadAuditLogObject.ts} +3 -2
- package/dataLayer/{SQLSearch.js → SQLSearch.ts} +97 -43
- package/dataLayer/{SearchByConditionsObject.js → SearchByConditionsObject.ts} +5 -6
- package/dataLayer/{SearchByHashObject.js → SearchByHashObject.ts} +2 -1
- package/dataLayer/{SearchObject.js → SearchObject.ts} +2 -1
- package/dataLayer/{SqlSearchObject.js → SqlSearchObject.ts} +2 -1
- package/dataLayer/{UpdateObject.js → UpdateObject.ts} +3 -2
- package/dataLayer/{UpsertObject.js → UpsertObject.ts} +3 -2
- package/dataLayer/{bulkLoad.js → bulkLoad.ts} +40 -49
- package/dataLayer/{delete.js → delete.ts} +21 -26
- package/dataLayer/{export.js → export.ts} +22 -26
- package/dataLayer/{getBackup.js → getBackup.ts} +7 -9
- package/dataLayer/harperBridge/BridgeMethods.ts +102 -0
- package/dataLayer/harperBridge/ResourceBridge.ts +27 -26
- package/dataLayer/harperBridge/TableSizeObject.ts +1 -0
- package/dataLayer/harperBridge/bridgeUtility/insertUpdateValidate.js +4 -4
- package/dataLayer/harperBridge/{harperBridge.js → harperBridge.ts} +3 -3
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.js +8 -6
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.js +4 -4
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateSchema.js +1 -1
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateTable.js +6 -4
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteAuditLogsBefore.js +5 -4
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteRecords.js +4 -4
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.js +6 -5
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropSchema.js +5 -4
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropTable.js +5 -5
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbFlush.js +1 -1
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetBackup.js +3 -3
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByHash.js +1 -1
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByValue.js +3 -2
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbReadAuditLog.js +5 -5
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.js +10 -8
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByHash.js +1 -1
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.js +4 -3
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpdateRecords.js +3 -3
- package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.js +6 -5
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.js +2 -1
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializeHashSearch.js +3 -2
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializePaths.js +2 -2
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCheckForNewAttributes.js +5 -4
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsAuditEnvironment.js +6 -3
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.ts +1 -1
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.js +4 -4
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbSearch.js +5 -5
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbWriteTransaction.js +4 -4
- package/dataLayer/{hdbInfoController.js → hdbInfoController.ts} +20 -26
- package/dataLayer/{insert.js → insert.ts} +24 -24
- package/dataLayer/{readAuditLog.js → readAuditLog.ts} +8 -10
- package/dataLayer/{schema.js → schema.ts} +32 -44
- package/dataLayer/{schemaDescribe.js → schemaDescribe.ts} +23 -26
- package/dataLayer/{search.js → search.ts} +9 -15
- package/dataLayer/{transaction.js → transaction.ts} +2 -5
- package/dataLayer/{update.js → update.ts} +19 -22
- package/dist/agent/agent.d.ts +35 -0
- package/dist/agent/agent.js +175 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/loop.d.ts +34 -0
- package/dist/agent/loop.js +176 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/operations.d.ts +17 -0
- package/dist/agent/operations.js +137 -0
- package/dist/agent/operations.js.map +1 -0
- package/dist/agent/session.d.ts +36 -0
- package/dist/agent/session.js +182 -0
- package/dist/agent/session.js.map +1 -0
- package/dist/agent/tools/fsTools.d.ts +19 -0
- package/dist/agent/tools/fsTools.js +286 -0
- package/dist/agent/tools/fsTools.js.map +1 -0
- package/dist/agent/tools/httpFetchTool.d.ts +9 -0
- package/dist/agent/tools/httpFetchTool.js +116 -0
- package/dist/agent/tools/httpFetchTool.js.map +1 -0
- package/dist/agent/tools/scheduleTool.d.ts +22 -0
- package/dist/agent/tools/scheduleTool.js +54 -0
- package/dist/agent/tools/scheduleTool.js.map +1 -0
- package/dist/agent/toolset.d.ts +24 -0
- package/dist/agent/toolset.js +33 -0
- package/dist/agent/toolset.js.map +1 -0
- package/dist/agent/types.d.ts +75 -0
- package/dist/agent/types.js +10 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/bin/BinObjects.d.ts +2 -2
- package/dist/bin/BinObjects.js +6 -3
- package/dist/bin/BinObjects.js.map +1 -1
- package/dist/bin/cliCredentials.d.ts +27 -0
- package/dist/bin/cliCredentials.js +130 -0
- package/dist/bin/cliCredentials.js.map +1 -0
- package/dist/bin/cliOperations.d.ts +7 -7
- package/dist/bin/cliOperations.js +251 -37
- package/dist/bin/cliOperations.js.map +1 -1
- package/dist/bin/copyDb.js +16 -16
- package/dist/bin/copyDb.js.map +1 -1
- package/dist/bin/deployRenderer.d.ts +47 -0
- package/dist/bin/deployRenderer.js +185 -0
- package/dist/bin/deployRenderer.js.map +1 -0
- package/dist/bin/harper.d.ts +2 -1
- package/dist/bin/harper.js +87 -26
- package/dist/bin/harper.js.map +1 -1
- package/dist/bin/install.d.ts +1 -1
- package/dist/bin/install.js +41 -4
- package/dist/bin/install.js.map +1 -1
- package/dist/bin/lite.js +3 -4
- package/dist/bin/lite.js.map +1 -1
- package/dist/bin/login.d.ts +4 -0
- package/dist/bin/login.js +158 -0
- package/dist/bin/login.js.map +1 -0
- package/dist/bin/logout.d.ts +4 -0
- package/dist/bin/logout.js +16 -0
- package/dist/bin/logout.js.map +1 -0
- package/dist/bin/mcp/client.d.ts +34 -0
- package/dist/bin/mcp/client.js +395 -0
- package/dist/bin/mcp/client.js.map +1 -0
- package/dist/bin/mcp/doctor.d.ts +11 -0
- package/dist/bin/mcp/doctor.js +193 -0
- package/dist/bin/mcp/doctor.js.map +1 -0
- package/dist/bin/mcp/index.d.ts +10 -0
- package/dist/bin/mcp/index.js +81 -0
- package/dist/bin/mcp/index.js.map +1 -0
- package/dist/bin/mcp/options.d.ts +33 -0
- package/dist/bin/mcp/options.js +113 -0
- package/dist/bin/mcp/options.js.map +1 -0
- package/dist/bin/mcp/printConfig.d.ts +14 -0
- package/dist/bin/mcp/printConfig.js +85 -0
- package/dist/bin/mcp/printConfig.js.map +1 -0
- package/dist/bin/multipartBuilder.d.ts +26 -0
- package/dist/bin/multipartBuilder.js +55 -0
- package/dist/bin/multipartBuilder.js.map +1 -0
- package/dist/bin/restart.d.ts +3 -2
- package/dist/bin/restart.js +82 -45
- package/dist/bin/restart.js.map +1 -1
- package/dist/bin/run.d.ts +13 -9
- package/dist/bin/run.js +111 -65
- package/dist/bin/run.js.map +1 -1
- package/dist/bin/sseConsumer.d.ts +24 -0
- package/dist/bin/sseConsumer.js +127 -0
- package/dist/bin/sseConsumer.js.map +1 -0
- package/dist/bin/status.d.ts +1 -1
- package/dist/bin/status.js +48 -11
- package/dist/bin/status.js.map +1 -1
- package/dist/bin/stop.d.ts +1 -1
- package/dist/bin/stop.js +43 -6
- package/dist/bin/stop.js.map +1 -1
- package/dist/bin/upgrade.js +6 -6
- package/dist/components/Application.d.ts +29 -17
- package/dist/components/Application.js +134 -28
- package/dist/components/Application.js.map +1 -1
- package/dist/components/ApplicationScope.js +2 -2
- package/dist/components/ComponentV1.d.ts +1 -1
- package/dist/components/ComponentV1.js +5 -5
- package/dist/components/ComponentV1.js.map +1 -1
- package/dist/components/EntryHandler.d.ts +26 -3
- package/dist/components/EntryHandler.js +153 -13
- package/dist/components/EntryHandler.js.map +1 -1
- package/dist/components/OptionsWatcher.d.ts +7 -2
- package/dist/components/OptionsWatcher.js +72 -10
- package/dist/components/OptionsWatcher.js.map +1 -1
- package/dist/components/Scope.d.ts +11 -6
- package/dist/components/Scope.js +105 -9
- package/dist/components/Scope.js.map +1 -1
- package/dist/components/anthropic/index.d.ts +40 -0
- package/dist/components/anthropic/index.js +428 -0
- package/dist/components/anthropic/index.js.map +1 -0
- package/dist/components/bedrock/index.d.ts +79 -0
- package/dist/components/bedrock/index.js +734 -0
- package/dist/components/bedrock/index.js.map +1 -0
- package/dist/components/componentLoader.d.ts +29 -0
- package/dist/components/componentLoader.js +63 -38
- package/dist/components/componentLoader.js.map +1 -1
- package/dist/components/deployLifecycle.d.ts +39 -0
- package/dist/components/deployLifecycle.js +156 -0
- package/dist/components/deployLifecycle.js.map +1 -0
- package/dist/components/deploymentOperations.d.ts +19 -0
- package/dist/components/deploymentOperations.js +185 -0
- package/dist/components/deploymentOperations.js.map +1 -0
- package/dist/components/deploymentRecorder.d.ts +81 -0
- package/dist/components/deploymentRecorder.js +401 -0
- package/dist/components/deploymentRecorder.js.map +1 -0
- package/dist/components/deriveURLPath.d.ts +2 -2
- package/dist/components/deriveURLPath.js +2 -2
- package/dist/components/deriveURLPath.js.map +1 -1
- package/dist/components/mcp/adapters/fastify.d.ts +35 -0
- package/dist/components/mcp/adapters/fastify.js +66 -0
- package/dist/components/mcp/adapters/fastify.js.map +1 -0
- package/dist/components/mcp/adapters/harperHttp.d.ts +38 -0
- package/dist/components/mcp/adapters/harperHttp.js +78 -0
- package/dist/components/mcp/adapters/harperHttp.js.map +1 -0
- package/dist/components/mcp/audit.d.ts +27 -0
- package/dist/components/mcp/audit.js +73 -0
- package/dist/components/mcp/audit.js.map +1 -0
- package/dist/components/mcp/index.d.ts +47 -0
- package/dist/components/mcp/index.js +109 -0
- package/dist/components/mcp/index.js.map +1 -0
- package/dist/components/mcp/jsonrpc.d.ts +71 -0
- package/dist/components/mcp/jsonrpc.js +93 -0
- package/dist/components/mcp/jsonrpc.js.map +1 -0
- package/dist/components/mcp/lifecycle.d.ts +69 -0
- package/dist/components/mcp/lifecycle.js +79 -0
- package/dist/components/mcp/lifecycle.js.map +1 -0
- package/dist/components/mcp/listChanged.d.ts +24 -0
- package/dist/components/mcp/listChanged.js +257 -0
- package/dist/components/mcp/listChanged.js.map +1 -0
- package/dist/components/mcp/rateLimit.d.ts +25 -0
- package/dist/components/mcp/rateLimit.js +226 -0
- package/dist/components/mcp/rateLimit.js.map +1 -0
- package/dist/components/mcp/resources.d.ts +90 -0
- package/dist/components/mcp/resources.js +515 -0
- package/dist/components/mcp/resources.js.map +1 -0
- package/dist/components/mcp/session.d.ts +36 -0
- package/dist/components/mcp/session.js +170 -0
- package/dist/components/mcp/session.js.map +1 -0
- package/dist/components/mcp/sessionRegistry.d.ts +63 -0
- package/dist/components/mcp/sessionRegistry.js +124 -0
- package/dist/components/mcp/sessionRegistry.js.map +1 -0
- package/dist/components/mcp/toolRegistry.d.ts +150 -0
- package/dist/components/mcp/toolRegistry.js +176 -0
- package/dist/components/mcp/toolRegistry.js.map +1 -0
- package/dist/components/mcp/tools/application.d.ts +58 -0
- package/dist/components/mcp/tools/application.js +549 -0
- package/dist/components/mcp/tools/application.js.map +1 -0
- package/dist/components/mcp/tools/operations.d.ts +23 -0
- package/dist/components/mcp/tools/operations.js +303 -0
- package/dist/components/mcp/tools/operations.js.map +1 -0
- package/dist/components/mcp/tools/schemas/derive.d.ts +36 -0
- package/dist/components/mcp/tools/schemas/derive.js +216 -0
- package/dist/components/mcp/tools/schemas/derive.js.map +1 -0
- package/dist/components/mcp/tools/schemas/operations.d.ts +27 -0
- package/dist/components/mcp/tools/schemas/operations.js +243 -0
- package/dist/components/mcp/tools/schemas/operations.js.map +1 -0
- package/dist/components/mcp/transport.d.ts +38 -0
- package/dist/components/mcp/transport.js +467 -0
- package/dist/components/mcp/transport.js.map +1 -0
- package/dist/components/ollama/index.d.ts +46 -0
- package/dist/components/ollama/index.js +239 -0
- package/dist/components/ollama/index.js.map +1 -0
- package/dist/components/openai/index.d.ts +51 -0
- package/dist/components/openai/index.js +475 -0
- package/dist/components/openai/index.js.map +1 -0
- package/dist/components/operations.d.ts +6 -6
- package/dist/components/operations.js +198 -52
- package/dist/components/operations.js.map +1 -1
- package/dist/components/operationsValidation.d.ts +2 -2
- package/dist/components/operationsValidation.js +3 -3
- package/dist/components/packageComponent.d.ts +28 -6
- package/dist/components/packageComponent.js +87 -26
- package/dist/components/packageComponent.js.map +1 -1
- package/dist/components/requestRestart.d.ts +1 -0
- package/dist/components/requestRestart.js +12 -1
- package/dist/components/requestRestart.js.map +1 -1
- package/dist/components/status/crossThread.d.ts +5 -1
- package/dist/components/status/crossThread.js +12 -5
- package/dist/components/status/crossThread.js.map +1 -1
- package/dist/components/status/errors.js +7 -7
- package/dist/config/RootConfigWatcher.d.ts +3 -0
- package/dist/config/RootConfigWatcher.js +52 -1
- package/dist/config/RootConfigWatcher.js.map +1 -1
- package/dist/config/configUtils.js +31 -8
- package/dist/config/configUtils.js.map +1 -1
- package/dist/config/harperConfigEnvVars.js +1 -1
- package/dist/config/harperConfigEnvVars.js.map +1 -1
- package/dist/dataLayer/CreateAttributeObject.d.ts +3 -7
- package/dist/dataLayer/CreateAttributeObject.js +4 -3
- package/dist/dataLayer/CreateAttributeObject.js.map +1 -1
- package/dist/dataLayer/CreateTableObject.d.ts +2 -4
- package/dist/dataLayer/CreateTableObject.js +2 -1
- package/dist/dataLayer/CreateTableObject.js.map +1 -1
- package/dist/dataLayer/DataLayerObjects.d.ts +17 -16
- package/dist/dataLayer/DataLayerObjects.js +19 -5
- package/dist/dataLayer/DataLayerObjects.js.map +1 -1
- package/dist/dataLayer/DeleteBeforeObject.d.ts +3 -5
- package/dist/dataLayer/DeleteBeforeObject.js +2 -1
- package/dist/dataLayer/DeleteBeforeObject.js.map +1 -1
- package/dist/dataLayer/DeleteObject.d.ts +3 -7
- package/dist/dataLayer/DeleteObject.js +4 -3
- package/dist/dataLayer/DeleteObject.js.map +1 -1
- package/dist/dataLayer/DropAttributeObject.d.ts +2 -4
- package/dist/dataLayer/DropAttributeObject.js +2 -1
- package/dist/dataLayer/DropAttributeObject.js.map +1 -1
- package/dist/dataLayer/GetBackupObject.d.ts +3 -5
- package/dist/dataLayer/GetBackupObject.js +4 -3
- package/dist/dataLayer/GetBackupObject.js.map +1 -1
- package/dist/dataLayer/InsertObject.d.ts +3 -8
- package/dist/dataLayer/InsertObject.js +4 -3
- package/dist/dataLayer/InsertObject.js.map +1 -1
- package/dist/dataLayer/ReadAuditLogObject.d.ts +3 -7
- package/dist/dataLayer/ReadAuditLogObject.js +4 -3
- package/dist/dataLayer/ReadAuditLogObject.js.map +1 -1
- package/dist/dataLayer/SQLSearch.d.ts +68 -38
- package/dist/dataLayer/SQLSearch.js +140 -78
- package/dist/dataLayer/SQLSearch.js.map +1 -1
- package/dist/dataLayer/SearchByConditionsObject.d.ts +10 -58
- package/dist/dataLayer/SearchByConditionsObject.js +5 -7
- package/dist/dataLayer/SearchByConditionsObject.js.map +1 -1
- package/dist/dataLayer/SearchByHashObject.d.ts +3 -6
- package/dist/dataLayer/SearchByHashObject.js +2 -1
- package/dist/dataLayer/SearchByHashObject.js.map +1 -1
- package/dist/dataLayer/SearchObject.d.ts +3 -12
- package/dist/dataLayer/SearchObject.js +2 -1
- package/dist/dataLayer/SearchObject.js.map +1 -1
- package/dist/dataLayer/SqlSearchObject.d.ts +2 -4
- package/dist/dataLayer/SqlSearchObject.js +2 -1
- package/dist/dataLayer/SqlSearchObject.js.map +1 -1
- package/dist/dataLayer/UpdateObject.d.ts +3 -7
- package/dist/dataLayer/UpdateObject.js +4 -3
- package/dist/dataLayer/UpdateObject.js.map +1 -1
- package/dist/dataLayer/UpsertObject.d.ts +3 -7
- package/dist/dataLayer/UpsertObject.js +4 -3
- package/dist/dataLayer/UpsertObject.js.map +1 -1
- package/dist/dataLayer/bulkLoad.d.ts +4 -4
- package/dist/dataLayer/bulkLoad.js +122 -88
- package/dist/dataLayer/bulkLoad.js.map +1 -1
- package/dist/dataLayer/delete.d.ts +10 -11
- package/dist/dataLayer/delete.js +74 -39
- package/dist/dataLayer/delete.js.map +1 -1
- package/dist/dataLayer/export.d.ts +8 -8
- package/dist/dataLayer/export.js +90 -55
- package/dist/dataLayer/export.js.map +1 -1
- package/dist/dataLayer/getBackup.d.ts +4 -3
- package/dist/dataLayer/getBackup.js +43 -11
- package/dist/dataLayer/getBackup.js.map +1 -1
- package/dist/dataLayer/harperBridge/BridgeMethods.d.ts +39 -21
- package/dist/dataLayer/harperBridge/BridgeMethods.js +41 -20
- package/dist/dataLayer/harperBridge/BridgeMethods.js.map +1 -1
- package/dist/dataLayer/harperBridge/ResourceBridge.d.ts +2 -2
- package/dist/dataLayer/harperBridge/ResourceBridge.js +26 -25
- package/dist/dataLayer/harperBridge/ResourceBridge.js.map +1 -1
- package/dist/dataLayer/harperBridge/TableSizeObject.d.ts +1 -0
- package/dist/dataLayer/harperBridge/TableSizeObject.js.map +1 -1
- package/dist/dataLayer/harperBridge/bridgeUtility/insertUpdateValidate.d.ts +4 -4
- package/dist/dataLayer/harperBridge/bridgeUtility/insertUpdateValidate.js +4 -4
- package/dist/dataLayer/harperBridge/harperBridge.d.ts +2 -3
- package/dist/dataLayer/harperBridge/harperBridge.js +38 -4
- package/dist/dataLayer/harperBridge/harperBridge.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.d.ts +1 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.js +7 -6
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.d.ts +1 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.js +4 -4
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateSchema.js +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateSchema.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateTable.js +5 -4
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateTable.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteAuditLogsBefore.d.ts +1 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteAuditLogsBefore.js +4 -4
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteAuditLogsBefore.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteRecords.js +4 -4
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.d.ts +1 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.js +5 -5
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropSchema.js +4 -4
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropSchema.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropTable.js +5 -5
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropTable.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbFlush.js +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetBackup.js +3 -3
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByHash.js +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByValue.js +2 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByValue.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbReadAuditLog.js +5 -5
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.d.ts +1 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.js +8 -8
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByHash.d.ts +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByHash.js +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.d.ts +1 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.js +3 -3
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpdateRecords.js +3 -3
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.d.ts +1 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.js +5 -5
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.d.ts +1 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.js +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializeHashSearch.js +2 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializeHashSearch.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializePaths.js +2 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCheckForNewAttributes.js +4 -4
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCheckForNewAttributes.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsAuditEnvironment.d.ts +1 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsAuditEnvironment.js +5 -3
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsAuditEnvironment.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js +2 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.d.ts +1 -2
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.js +4 -4
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.js.map +1 -1
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbSearch.js +5 -5
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbWriteTransaction.js +4 -4
- package/dist/dataLayer/hdbInfoController.d.ts +4 -8
- package/dist/dataLayer/hdbInfoController.js +66 -31
- package/dist/dataLayer/hdbInfoController.js.map +1 -1
- package/dist/dataLayer/insert.d.ts +14 -26
- package/dist/dataLayer/insert.js +63 -28
- package/dist/dataLayer/insert.js.map +1 -1
- package/dist/dataLayer/readAuditLog.d.ts +1 -3
- package/dist/dataLayer/readAuditLog.js +45 -13
- package/dist/dataLayer/readAuditLog.js.map +1 -1
- package/dist/dataLayer/schema.d.ts +10 -10
- package/dist/dataLayer/schema.js +124 -89
- package/dist/dataLayer/schema.js.map +1 -1
- package/dist/dataLayer/schemaDescribe.d.ts +4 -4
- package/dist/dataLayer/schemaDescribe.js +78 -41
- package/dist/dataLayer/schemaDescribe.js.map +1 -1
- package/dist/dataLayer/search.d.ts +4 -4
- package/dist/dataLayer/search.js +12 -13
- package/dist/dataLayer/search.js.map +1 -1
- package/dist/dataLayer/transaction.d.ts +1 -1
- package/dist/dataLayer/transaction.js +3 -4
- package/dist/dataLayer/transaction.js.map +1 -1
- package/dist/dataLayer/update.d.ts +2 -8
- package/dist/dataLayer/update.js +53 -18
- package/dist/dataLayer/update.js.map +1 -1
- package/dist/globals.d.ts +1 -1
- package/dist/globals.js +1 -0
- package/dist/globals.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/json/systemSchema.json +65 -0
- package/dist/launchServiceScripts/launchHarperDB.d.ts +1 -0
- package/dist/launchServiceScripts/launchHarperDB.js +3 -0
- package/dist/launchServiceScripts/launchHarperDB.js.map +1 -0
- package/dist/launchServiceScripts/utility/checkNodeVersion.js +3 -0
- package/dist/launchServiceScripts/utility/checkNodeVersion.js.map +1 -1
- package/dist/resources/DatabaseTransaction.d.ts +14 -6
- package/dist/resources/DatabaseTransaction.js +39 -15
- package/dist/resources/DatabaseTransaction.js.map +1 -1
- package/dist/resources/ErrorResource.d.ts +1 -1
- package/dist/resources/ErrorResource.js +3 -1
- package/dist/resources/ErrorResource.js.map +1 -1
- package/dist/resources/LMDBTransaction.d.ts +10 -13
- package/dist/resources/LMDBTransaction.js +18 -7
- package/dist/resources/LMDBTransaction.js.map +1 -1
- package/dist/resources/RecordEncoder.d.ts +7 -1
- package/dist/resources/RecordEncoder.js +5 -2
- package/dist/resources/RecordEncoder.js.map +1 -1
- package/dist/resources/RequestTarget.d.ts +1 -0
- package/dist/resources/RequestTarget.js.map +1 -1
- package/dist/resources/Resource.d.ts +9 -5
- package/dist/resources/Resource.js +37 -10
- package/dist/resources/Resource.js.map +1 -1
- package/dist/resources/ResourceInterface.d.ts +24 -5
- package/dist/resources/ResourceInterface.js +20 -0
- package/dist/resources/ResourceInterface.js.map +1 -1
- package/dist/resources/Resources.d.ts +3 -4
- package/dist/resources/Resources.js +7 -6
- package/dist/resources/Resources.js.map +1 -1
- package/dist/resources/RocksIndexStore.js +3 -0
- package/dist/resources/RocksIndexStore.js.map +1 -1
- package/dist/resources/RocksTransactionLogStore.d.ts +1 -1
- package/dist/resources/RocksTransactionLogStore.js +46 -27
- package/dist/resources/RocksTransactionLogStore.js.map +1 -1
- package/dist/resources/Table.d.ts +59 -329
- package/dist/resources/Table.js +267 -107
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/analytics/metadata.d.ts +1 -0
- package/dist/resources/analytics/metadata.js +1 -0
- package/dist/resources/analytics/metadata.js.map +1 -1
- package/dist/resources/analytics/read.d.ts +5 -0
- package/dist/resources/analytics/read.js +16 -5
- package/dist/resources/analytics/read.js.map +1 -1
- package/dist/resources/analytics/write.d.ts +28 -0
- package/dist/resources/analytics/write.js +232 -20
- package/dist/resources/analytics/write.js.map +1 -1
- package/dist/resources/auditStore.d.ts +18 -13
- package/dist/resources/auditStore.js +13 -8
- package/dist/resources/auditStore.js.map +1 -1
- package/dist/resources/blob.d.ts +16 -27
- package/dist/resources/blob.js +8 -8
- package/dist/resources/blob.js.map +1 -1
- package/dist/resources/dataLoader.d.ts +1 -1
- package/dist/resources/dataLoader.js +13 -13
- package/dist/resources/databases.d.ts +13 -0
- package/dist/resources/databases.js +160 -52
- package/dist/resources/databases.js.map +1 -1
- package/dist/resources/graphql.d.ts +1 -7
- package/dist/resources/graphql.js +224 -174
- package/dist/resources/graphql.js.map +1 -1
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.d.ts +16 -1
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js +308 -59
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js.map +1 -1
- package/dist/resources/indexes/vector.d.ts +1 -0
- package/dist/resources/indexes/vector.js +14 -0
- package/dist/resources/indexes/vector.js.map +1 -1
- package/dist/resources/loadEnv.d.ts +2 -5
- package/dist/resources/loadEnv.js +21 -18
- package/dist/resources/loadEnv.js.map +1 -1
- package/dist/resources/login.d.ts +2 -3
- package/dist/resources/login.js +5 -4
- package/dist/resources/login.js.map +1 -1
- package/dist/resources/models/Models.d.ts +45 -0
- package/dist/resources/models/Models.js +265 -0
- package/dist/resources/models/Models.js.map +1 -0
- package/dist/resources/models/TestBackend.d.ts +15 -0
- package/dist/resources/models/TestBackend.js +71 -0
- package/dist/resources/models/TestBackend.js.map +1 -0
- package/dist/resources/models/agentLoop.d.ts +125 -0
- package/dist/resources/models/agentLoop.js +746 -0
- package/dist/resources/models/agentLoop.js.map +1 -0
- package/dist/resources/models/analyticsTable.d.ts +65 -0
- package/dist/resources/models/analyticsTable.js +166 -0
- package/dist/resources/models/analyticsTable.js.map +1 -0
- package/dist/resources/models/backendHelpers.d.ts +57 -0
- package/dist/resources/models/backendHelpers.js +109 -0
- package/dist/resources/models/backendHelpers.js.map +1 -0
- package/dist/resources/models/backendRegistry.d.ts +36 -0
- package/dist/resources/models/backendRegistry.js +54 -0
- package/dist/resources/models/backendRegistry.js.map +1 -0
- package/dist/resources/models/bootstrap.d.ts +24 -0
- package/dist/resources/models/bootstrap.js +112 -0
- package/dist/resources/models/bootstrap.js.map +1 -0
- package/dist/resources/models/embedHook.d.ts +33 -0
- package/dist/resources/models/embedHook.js +127 -0
- package/dist/resources/models/embedHook.js.map +1 -0
- package/dist/resources/models/types.d.ts +301 -0
- package/dist/resources/models/types.js +11 -0
- package/dist/resources/models/types.js.map +1 -0
- package/dist/resources/replayLogs.js +7 -1
- package/dist/resources/replayLogs.js.map +1 -1
- package/dist/resources/roles.d.ts +1 -7
- package/dist/resources/roles.js +67 -71
- package/dist/resources/roles.js.map +1 -1
- package/dist/resources/search.d.ts +18 -1
- package/dist/resources/search.js +349 -140
- package/dist/resources/search.js.map +1 -1
- package/dist/resources/tracked.d.ts +1 -1
- package/dist/resources/tracked.js +14 -14
- package/dist/resources/tracked.js.map +1 -1
- package/dist/resources/transaction.d.ts +1 -1
- package/dist/resources/transaction.js +1 -1
- package/dist/resources/transaction.js.map +1 -1
- package/dist/resources/transactionBroadcast.d.ts +1 -1
- package/dist/resources/transactionBroadcast.js.map +1 -1
- package/dist/security/auth.d.ts +1 -5
- package/dist/security/auth.js +34 -25
- package/dist/security/auth.js.map +1 -1
- package/dist/security/certificateVerification/crlVerification.js +7 -1
- package/dist/security/certificateVerification/crlVerification.js.map +1 -1
- package/dist/security/cryptoHash.d.ts +2 -2
- package/dist/security/cryptoHash.js +37 -5
- package/dist/security/cryptoHash.js.map +1 -1
- package/dist/security/data_objects/PermissionAttributeResponseObject.d.ts +3 -4
- package/dist/security/data_objects/PermissionAttributeResponseObject.js +4 -1
- package/dist/security/data_objects/PermissionAttributeResponseObject.js.map +1 -1
- package/dist/security/data_objects/PermissionResponseObject.d.ts +9 -9
- package/dist/security/data_objects/PermissionResponseObject.js +15 -8
- package/dist/security/data_objects/PermissionResponseObject.js.map +1 -1
- package/dist/security/data_objects/PermissionTableResponseObject.d.ts +5 -6
- package/dist/security/data_objects/PermissionTableResponseObject.js +6 -1
- package/dist/security/data_objects/PermissionTableResponseObject.js.map +1 -1
- package/dist/security/fastifyAuth.d.ts +2 -2
- package/dist/security/fastifyAuth.js +131 -22
- package/dist/security/fastifyAuth.js.map +1 -1
- package/dist/security/impersonation.js +15 -15
- package/dist/security/jsLoader.js +18 -5
- package/dist/security/jsLoader.js.map +1 -1
- package/dist/security/keys.d.ts +45 -48
- package/dist/security/keys.js +160 -114
- package/dist/security/keys.js.map +1 -1
- package/dist/security/permissionsTranslator.js +2 -2
- package/dist/security/role.d.ts +5 -5
- package/dist/security/role.js +70 -35
- package/dist/security/role.js.map +1 -1
- package/dist/security/tokenAuthentication.d.ts +13 -0
- package/dist/security/tokenAuthentication.js +57 -27
- package/dist/security/tokenAuthentication.js.map +1 -1
- package/dist/security/user.js +74 -38
- package/dist/security/user.js.map +1 -1
- package/dist/server/DurableSubscriptionsSession.d.ts +4 -2
- package/dist/server/DurableSubscriptionsSession.js +71 -55
- package/dist/server/DurableSubscriptionsSession.js.map +1 -1
- package/dist/server/REST.d.ts +1 -8
- package/dist/server/REST.js +17 -16
- package/dist/server/REST.js.map +1 -1
- package/dist/server/Server.d.ts +23 -4
- package/dist/server/Server.js +1 -1
- package/dist/server/Server.js.map +1 -1
- package/dist/server/fastifyRoutes/helpers/getCORSOptions.js +1 -1
- package/dist/server/fastifyRoutes/helpers/getHeaderTimeoutConfig.js +1 -1
- package/dist/server/fastifyRoutes/helpers/getServerOptions.js +1 -1
- package/dist/server/fastifyRoutes.d.ts +1 -4
- package/dist/server/fastifyRoutes.js +34 -30
- package/dist/server/fastifyRoutes.js.map +1 -1
- package/dist/server/graphqlQuerying.d.ts +1 -1
- package/dist/server/graphqlQuerying.js +8 -7
- package/dist/server/graphqlQuerying.js.map +1 -1
- package/dist/server/http.d.ts +9 -4
- package/dist/server/http.js +523 -47
- package/dist/server/http.js.map +1 -1
- package/dist/server/itc/serverHandlers.js +66 -15
- package/dist/server/itc/serverHandlers.js.map +1 -1
- package/dist/server/jobs/JobObject.d.ts +3 -3
- package/dist/server/jobs/JobObject.js +53 -7
- package/dist/server/jobs/JobObject.js.map +1 -1
- package/dist/server/jobs/jobProcess.js +64 -24
- package/dist/server/jobs/jobProcess.js.map +1 -1
- package/dist/server/jobs/jobRunner.d.ts +7 -6
- package/dist/server/jobs/jobRunner.js +68 -30
- package/dist/server/jobs/jobRunner.js.map +1 -1
- package/dist/server/jobs/jobs.d.ts +18 -7
- package/dist/server/jobs/jobs.js +93 -61
- package/dist/server/jobs/jobs.js.map +1 -1
- package/dist/server/loadRootComponents.js +1 -1
- package/dist/server/middlewareChain.d.ts +80 -0
- package/dist/server/middlewareChain.js +252 -0
- package/dist/server/middlewareChain.js.map +1 -0
- package/dist/server/mqtt.d.ts +1 -8
- package/dist/server/mqtt.js +22 -17
- package/dist/server/mqtt.js.map +1 -1
- package/dist/server/nodeName.js +44 -13
- package/dist/server/nodeName.js.map +1 -1
- package/dist/server/operationsServer.d.ts +2 -2
- package/dist/server/operationsServer.js +106 -33
- package/dist/server/operationsServer.js.map +1 -1
- package/dist/server/serverHelpers/Headers.d.ts +4 -4
- package/dist/server/serverHelpers/Headers.js +2 -0
- package/dist/server/serverHelpers/Headers.js.map +1 -1
- package/dist/server/serverHelpers/JSONStream.d.ts +7 -1
- package/dist/server/serverHelpers/JSONStream.js +12 -3
- package/dist/server/serverHelpers/JSONStream.js.map +1 -1
- package/dist/server/serverHelpers/Request.d.ts +106 -8
- package/dist/server/serverHelpers/Request.js +370 -9
- package/dist/server/serverHelpers/Request.js.map +1 -1
- package/dist/server/serverHelpers/contentTypes.d.ts +1 -1
- package/dist/server/serverHelpers/contentTypes.js +36 -7
- package/dist/server/serverHelpers/contentTypes.js.map +1 -1
- package/dist/server/serverHelpers/multipartParser.d.ts +21 -0
- package/dist/server/serverHelpers/multipartParser.js +142 -0
- package/dist/server/serverHelpers/multipartParser.js.map +1 -0
- package/dist/server/serverHelpers/progressEmitter.d.ts +25 -0
- package/dist/server/serverHelpers/progressEmitter.js +103 -0
- package/dist/server/serverHelpers/progressEmitter.js.map +1 -0
- package/dist/server/serverHelpers/serverHandlers.d.ts +1 -1
- package/dist/server/serverHelpers/serverHandlers.js +38 -7
- package/dist/server/serverHelpers/serverHandlers.js.map +1 -1
- package/dist/server/serverHelpers/serverUtilities.d.ts +4 -2
- package/dist/server/serverHelpers/serverUtilities.js +97 -93
- package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
- package/dist/server/static.js +8 -5
- package/dist/server/static.js.map +1 -1
- package/dist/server/status/index.js +3 -3
- package/dist/server/storageReclamation.d.ts +10 -0
- package/dist/server/storageReclamation.js +68 -9
- package/dist/server/storageReclamation.js.map +1 -1
- package/dist/server/threads/itc.js +7 -4
- package/dist/server/threads/itc.js.map +1 -1
- package/dist/server/threads/manageThreads.d.ts +1 -1
- package/dist/server/threads/manageThreads.js +110 -26
- package/dist/server/threads/manageThreads.js.map +1 -1
- package/dist/server/threads/socketRouter.d.ts +0 -1
- package/dist/server/threads/socketRouter.js +8 -271
- package/dist/server/threads/socketRouter.js.map +1 -1
- package/dist/server/threads/threadServer.d.ts +1 -0
- package/dist/server/threads/threadServer.js +360 -118
- package/dist/server/threads/threadServer.js.map +1 -1
- package/dist/server/threads/workerProcessGuard.d.ts +42 -0
- package/dist/server/threads/workerProcessGuard.js +114 -0
- package/dist/server/threads/workerProcessGuard.js.map +1 -0
- package/dist/server/throttle.js +17 -0
- package/dist/server/throttle.js.map +1 -1
- package/dist/sqlTranslator/SelectValidator.d.ts +21 -24
- package/dist/sqlTranslator/SelectValidator.js +86 -47
- package/dist/sqlTranslator/SelectValidator.js.map +1 -1
- package/dist/sqlTranslator/alasqlFunctionImporter.d.ts +6 -2
- package/dist/sqlTranslator/alasqlFunctionImporter.js +40 -3
- package/dist/sqlTranslator/alasqlFunctionImporter.js.map +1 -1
- package/dist/sqlTranslator/deleteTranslator.d.ts +4 -7
- package/dist/sqlTranslator/deleteTranslator.js +48 -14
- package/dist/sqlTranslator/deleteTranslator.js.map +1 -1
- package/dist/sqlTranslator/index.d.ts +10 -9
- package/dist/sqlTranslator/index.js +69 -30
- package/dist/sqlTranslator/index.js.map +1 -1
- package/dist/sqlTranslator/sql_statement_bucket.d.ts +10 -10
- package/dist/sqlTranslator/sql_statement_bucket.js +55 -13
- package/dist/sqlTranslator/sql_statement_bucket.js.map +1 -1
- package/dist/upgrade/UpgradeObjects.d.ts +2 -3
- package/dist/upgrade/UpgradeObjects.js +37 -4
- package/dist/upgrade/UpgradeObjects.js.map +1 -1
- package/dist/upgrade/directives/5-2-0.d.ts +6 -0
- package/dist/upgrade/directives/5-2-0.js +77 -0
- package/dist/upgrade/directives/5-2-0.js.map +1 -0
- package/dist/upgrade/directives/directivesController.d.ts +10 -10
- package/dist/upgrade/directives/directivesController.js +52 -11
- package/dist/upgrade/directives/directivesController.js.map +1 -1
- package/dist/upgrade/directivesManager.d.ts +1 -1
- package/dist/upgrade/directivesManager.js +53 -18
- package/dist/upgrade/directivesManager.js.map +1 -1
- package/dist/upgrade/upgradePrompt.d.ts +3 -3
- package/dist/upgrade/upgradePrompt.js +65 -30
- package/dist/upgrade/upgradePrompt.js.map +1 -1
- package/dist/upgrade/upgradeUtilities.d.ts +1 -1
- package/dist/upgrade/upgradeUtilities.js +37 -5
- package/dist/upgrade/upgradeUtilities.js.map +1 -1
- package/dist/utility/OperationFunctionCaller.d.ts +1 -1
- package/dist/utility/OperationFunctionCaller.js +45 -10
- package/dist/utility/OperationFunctionCaller.js.map +1 -1
- package/dist/utility/assignCmdEnvVariables.d.ts +1 -2
- package/dist/utility/assignCmdEnvVariables.js +8 -4
- package/dist/utility/assignCmdEnvVariables.js.map +1 -1
- package/dist/utility/common_utils.d.ts +80 -77
- package/dist/utility/common_utils.js +140 -79
- package/dist/utility/common_utils.js.map +1 -1
- package/dist/utility/environment/environmentManager.d.ts +12 -11
- package/dist/utility/environment/environmentManager.js +75 -29
- package/dist/utility/environment/environmentManager.js.map +1 -1
- package/dist/utility/environment/systemInformation.d.ts +4 -0
- package/dist/utility/environment/systemInformation.js +27 -16
- package/dist/utility/environment/systemInformation.js.map +1 -1
- package/dist/utility/errors/commonErrors.d.ts +192 -168
- package/dist/utility/errors/commonErrors.js +49 -18
- package/dist/utility/errors/commonErrors.js.map +1 -1
- package/dist/utility/errors/hdbError.d.ts +37 -51
- package/dist/utility/errors/hdbError.js +65 -26
- package/dist/utility/errors/hdbError.js.map +1 -1
- package/dist/utility/expandEnvVar.d.ts +61 -0
- package/dist/utility/expandEnvVar.js +113 -0
- package/dist/utility/expandEnvVar.js.map +1 -0
- package/dist/utility/functions/geo.js +2 -2
- package/dist/utility/functions/sql/alaSQLExtension.js +1 -1
- package/dist/utility/globalSchema.d.ts +13 -4
- package/dist/utility/globalSchema.js +14 -11
- package/dist/utility/globalSchema.js.map +1 -1
- package/dist/utility/hdbTerms.d.ts +56 -0
- package/dist/utility/hdbTerms.js +56 -0
- package/dist/utility/hdbTerms.js.map +1 -1
- package/dist/utility/install/checkJWTTokensExist.js +1 -1
- package/dist/utility/install/installer.d.ts +9 -12
- package/dist/utility/install/installer.js +87 -51
- package/dist/utility/install/installer.js.map +1 -1
- package/dist/utility/installation.js +3 -3
- package/dist/utility/lmdb/DBIDefinition.d.ts +4 -4
- package/dist/utility/lmdb/DBIDefinition.js +5 -1
- package/dist/utility/lmdb/DBIDefinition.js.map +1 -1
- package/dist/utility/lmdb/DeleteRecordsResponseObject.d.ts +3 -6
- package/dist/utility/lmdb/DeleteRecordsResponseObject.js +2 -1
- package/dist/utility/lmdb/DeleteRecordsResponseObject.js.map +1 -1
- package/dist/utility/lmdb/InsertRecordsResponseObject.d.ts +3 -5
- package/dist/utility/lmdb/InsertRecordsResponseObject.js +2 -1
- package/dist/utility/lmdb/InsertRecordsResponseObject.js.map +1 -1
- package/dist/utility/lmdb/OpenDBIObject.d.ts +11 -15
- package/dist/utility/lmdb/OpenDBIObject.js +54 -6
- package/dist/utility/lmdb/OpenDBIObject.js.map +1 -1
- package/dist/utility/lmdb/OpenEnvironmentObject.d.ts +5 -8
- package/dist/utility/lmdb/OpenEnvironmentObject.js +52 -4
- package/dist/utility/lmdb/OpenEnvironmentObject.js.map +1 -1
- package/dist/utility/lmdb/UpdateRecordsResponseObject.d.ts +3 -6
- package/dist/utility/lmdb/UpdateRecordsResponseObject.js +2 -1
- package/dist/utility/lmdb/UpdateRecordsResponseObject.js.map +1 -1
- package/dist/utility/lmdb/UpsertRecordsResponseObject.d.ts +3 -5
- package/dist/utility/lmdb/UpsertRecordsResponseObject.js +2 -1
- package/dist/utility/lmdb/UpsertRecordsResponseObject.js.map +1 -1
- package/dist/utility/lmdb/cleanLMDBMap.d.ts +1 -1
- package/dist/utility/lmdb/cleanLMDBMap.js +44 -7
- package/dist/utility/lmdb/cleanLMDBMap.js.map +1 -1
- package/dist/utility/lmdb/commonUtility.d.ts +8 -9
- package/dist/utility/lmdb/commonUtility.js +46 -17
- package/dist/utility/lmdb/commonUtility.js.map +1 -1
- package/dist/utility/lmdb/deleteUtility.d.ts +2 -3
- package/dist/utility/lmdb/deleteUtility.js +51 -16
- package/dist/utility/lmdb/deleteUtility.js.map +1 -1
- package/dist/utility/lmdb/environmentUtility.d.ts +69 -36
- package/dist/utility/lmdb/environmentUtility.js +91 -51
- package/dist/utility/lmdb/environmentUtility.js.map +1 -1
- package/dist/utility/lmdb/searchCursorFunctions.d.ts +19 -19
- package/dist/utility/lmdb/searchCursorFunctions.js +46 -14
- package/dist/utility/lmdb/searchCursorFunctions.js.map +1 -1
- package/dist/utility/lmdb/searchUtility.d.ts +142 -73
- package/dist/utility/lmdb/searchUtility.js +91 -55
- package/dist/utility/lmdb/searchUtility.js.map +1 -1
- package/dist/utility/lmdb/terms.d.ts +34 -34
- package/dist/utility/lmdb/terms.js +12 -22
- package/dist/utility/lmdb/terms.js.map +1 -1
- package/dist/utility/lmdb/writeUtility.d.ts +3 -6
- package/dist/utility/lmdb/writeUtility.js +61 -28
- package/dist/utility/lmdb/writeUtility.js.map +1 -1
- package/dist/utility/logging/harper_logger.d.ts +87 -103
- package/dist/utility/logging/harper_logger.js +176 -81
- package/dist/utility/logging/harper_logger.js.map +1 -1
- package/dist/utility/logging/logRotator.d.ts +2 -10
- package/dist/utility/logging/logRotator.js +65 -28
- package/dist/utility/logging/logRotator.js.map +1 -1
- package/dist/utility/logging/logger.js +4 -4
- package/dist/utility/logging/readLog.d.ts +1 -1
- package/dist/utility/logging/readLog.js +54 -17
- package/dist/utility/logging/readLog.js.map +1 -1
- package/dist/utility/logging/transactionLog.d.ts +2 -2
- package/dist/utility/logging/transactionLog.js +51 -16
- package/dist/utility/logging/transactionLog.js.map +1 -1
- package/dist/utility/mount_hdb.d.ts +1 -2
- package/dist/utility/mount_hdb.js +54 -17
- package/dist/utility/mount_hdb.js.map +1 -1
- package/dist/utility/npmUtilities.d.ts +1 -1
- package/dist/utility/npmUtilities.js +54 -19
- package/dist/utility/npmUtilities.js.map +1 -1
- package/dist/utility/operation_authorization.d.ts +36 -9
- package/dist/utility/operation_authorization.js +135 -86
- package/dist/utility/operation_authorization.js.map +1 -1
- package/dist/utility/packageUtils.d.ts +0 -2
- package/dist/utility/packageUtils.js +7 -17
- package/dist/utility/packageUtils.js.map +1 -1
- package/dist/utility/password.js +2 -2
- package/dist/utility/processManagement/processManagement.js +2 -2
- package/dist/utility/processManagement/servicesConfig.js +1 -1
- package/dist/utility/signalling.d.ts +2 -2
- package/dist/utility/signalling.js +51 -16
- package/dist/utility/signalling.js.map +1 -1
- package/dist/utility/watcherFallback.d.ts +36 -0
- package/dist/utility/watcherFallback.js +73 -0
- package/dist/utility/watcherFallback.js.map +1 -0
- package/dist/validation/analyticsValidator.d.ts +1 -0
- package/dist/validation/analyticsValidator.js +79 -0
- package/dist/validation/analyticsValidator.js.map +1 -0
- package/dist/validation/bulkDeleteValidator.d.ts +1 -2
- package/dist/validation/bulkDeleteValidator.js +49 -11
- package/dist/validation/bulkDeleteValidator.js.map +1 -1
- package/dist/validation/check_permissions.d.ts +1 -2
- package/dist/validation/check_permissions.js +38 -3
- package/dist/validation/check_permissions.js.map +1 -1
- package/dist/validation/common_validators.d.ts +20 -20
- package/dist/validation/common_validators.js +62 -31
- package/dist/validation/common_validators.js.map +1 -1
- package/dist/validation/configValidator.d.ts +4 -4
- package/dist/validation/configValidator.js +189 -54
- package/dist/validation/configValidator.js.map +1 -1
- package/dist/validation/deleteValidator.d.ts +1 -2
- package/dist/validation/deleteValidator.js +49 -11
- package/dist/validation/deleteValidator.js.map +1 -1
- package/dist/validation/fileLoadValidator.d.ts +4 -4
- package/dist/validation/fileLoadValidator.js +67 -32
- package/dist/validation/fileLoadValidator.js.map +1 -1
- package/dist/validation/insertValidator.d.ts +1 -2
- package/dist/validation/insertValidator.js +48 -10
- package/dist/validation/insertValidator.js.map +1 -1
- package/dist/validation/installValidator.d.ts +2 -2
- package/dist/validation/installValidator.js +47 -10
- package/dist/validation/installValidator.js.map +1 -1
- package/dist/validation/readLogValidator.d.ts +1 -2
- package/dist/validation/readLogValidator.js +60 -22
- package/dist/validation/readLogValidator.js.map +1 -1
- package/dist/validation/role_validation.d.ts +3 -3
- package/dist/validation/role_validation.js +55 -19
- package/dist/validation/role_validation.js.map +1 -1
- package/dist/validation/schemaMetadataValidator.d.ts +3 -4
- package/dist/validation/schemaMetadataValidator.js +11 -12
- package/dist/validation/schemaMetadataValidator.js.map +1 -1
- package/dist/validation/searchValidator.d.ts +1 -2
- package/dist/validation/searchValidator.js +82 -43
- package/dist/validation/searchValidator.js.map +1 -1
- package/dist/validation/statusValidator.d.ts +1 -1
- package/dist/validation/transactionLogValidator.d.ts +3 -3
- package/dist/validation/transactionLogValidator.js +52 -17
- package/dist/validation/transactionLogValidator.js.map +1 -1
- package/dist/validation/user_validation.d.ts +3 -3
- package/dist/validation/user_validation.js +38 -6
- package/dist/validation/user_validation.js.map +1 -1
- package/dist/validation/validationWrapper.d.ts +3 -3
- package/dist/validation/validationWrapper.js +4 -5
- package/dist/validation/validationWrapper.js.map +1 -1
- package/index.ts +5 -0
- package/json/systemSchema.json +65 -0
- package/launchServiceScripts/utility/checkNodeVersion.js +2 -0
- package/package.json +37 -22
- package/resources/DESIGN.md +98 -0
- package/resources/DatabaseTransaction.ts +58 -30
- package/resources/ErrorResource.ts +2 -1
- package/resources/LMDBTransaction.ts +38 -29
- package/resources/RecordEncoder.ts +12 -4
- package/resources/RequestTarget.ts +2 -0
- package/resources/Resource.ts +89 -56
- package/resources/ResourceInterface.ts +44 -21
- package/resources/Resources.ts +8 -8
- package/resources/RocksIndexStore.ts +3 -0
- package/resources/RocksTransactionLogStore.ts +47 -28
- package/resources/Table.ts +386 -214
- package/resources/analytics/metadata.ts +1 -0
- package/resources/analytics/read.ts +24 -6
- package/resources/analytics/write.ts +240 -17
- package/resources/auditStore.ts +28 -19
- package/resources/blob.ts +53 -53
- package/resources/dataLoader.ts +4 -4
- package/resources/databases.ts +190 -71
- package/resources/graphql.ts +227 -164
- package/resources/indexes/HierarchicalNavigableSmallWorld.ts +294 -65
- package/resources/indexes/vector.ts +17 -0
- package/resources/loadEnv.ts +21 -17
- package/resources/login.ts +5 -3
- package/resources/models/Models.ts +304 -0
- package/resources/models/TestBackend.ts +83 -0
- package/resources/models/agentLoop.ts +895 -0
- package/resources/models/analyticsTable.ts +199 -0
- package/resources/models/backendHelpers.ts +116 -0
- package/resources/models/backendRegistry.ts +66 -0
- package/resources/models/bootstrap.ts +135 -0
- package/resources/models/embedHook.ts +138 -0
- package/resources/models/types.ts +296 -0
- package/resources/replayLogs.ts +15 -7
- package/resources/roles.ts +62 -67
- package/resources/search.ts +355 -135
- package/resources/tracked.ts +8 -8
- package/resources/transaction.ts +8 -8
- package/resources/transactionBroadcast.ts +3 -3
- package/security/auth.ts +35 -26
- package/security/certificateVerification/crlVerification.ts +11 -4
- package/security/{cryptoHash.js → cryptoHash.ts} +3 -8
- package/security/data_objects/{PermissionAttributeResponseObject.js → PermissionAttributeResponseObject.ts} +4 -4
- package/security/data_objects/{PermissionResponseObject.js → PermissionResponseObject.ts} +12 -11
- package/security/data_objects/{PermissionTableResponseObject.js → PermissionTableResponseObject.ts} +6 -4
- package/security/{fastifyAuth.js → fastifyAuth.ts} +93 -20
- package/security/impersonation.ts +3 -3
- package/security/jsLoader.ts +22 -8
- package/security/{keys.js → keys.ts} +113 -121
- package/security/permissionsTranslator.js +2 -2
- package/security/{role.js → role.ts} +26 -33
- package/security/tokenAuthentication.ts +34 -7
- package/security/user.ts +26 -22
- package/server/DESIGN.md +139 -0
- package/server/DurableSubscriptionsSession.ts +67 -50
- package/server/REST.ts +120 -107
- package/server/Server.ts +31 -12
- package/server/fastifyRoutes/helpers/getCORSOptions.js +1 -1
- package/server/fastifyRoutes/helpers/getHeaderTimeoutConfig.js +1 -1
- package/server/fastifyRoutes/helpers/getServerOptions.js +1 -1
- package/server/fastifyRoutes.ts +37 -33
- package/server/graphqlQuerying.ts +6 -5
- package/server/http.ts +517 -26
- package/server/itc/serverHandlers.js +75 -14
- package/server/jobs/{JobObject.js → JobObject.ts} +13 -6
- package/server/jobs/{jobProcess.js → jobProcess.ts} +20 -16
- package/server/jobs/{jobRunner.js → jobRunner.ts} +20 -21
- package/server/jobs/{jobs.js → jobs.ts} +41 -44
- package/server/loadRootComponents.js +1 -1
- package/server/middlewareChain.ts +270 -0
- package/server/mqtt.ts +35 -26
- package/server/nodeName.ts +2 -1
- package/server/operationsServer.ts +85 -10
- package/server/serverHelpers/Headers.ts +10 -8
- package/server/serverHelpers/JSONStream.ts +15 -5
- package/server/serverHelpers/Request.ts +370 -13
- package/server/serverHelpers/contentTypes.ts +42 -11
- package/server/serverHelpers/multipartParser.ts +152 -0
- package/server/serverHelpers/progressEmitter.ts +110 -0
- package/server/serverHelpers/serverHandlers.js +43 -7
- package/server/serverHelpers/serverUtilities.ts +40 -30
- package/server/static.ts +9 -6
- package/server/status/index.ts +2 -2
- package/server/storageReclamation.ts +39 -2
- package/server/threads/itc.js +7 -4
- package/server/threads/manageThreads.js +100 -26
- package/server/threads/socketRouter.ts +12 -275
- package/server/threads/threadServer.js +345 -105
- package/server/threads/workerProcessGuard.ts +93 -0
- package/server/throttle.ts +18 -0
- package/sqlTranslator/{SelectValidator.js → SelectValidator.ts} +41 -49
- package/sqlTranslator/{alasqlFunctionImporter.js → alasqlFunctionImporter.ts} +5 -5
- package/sqlTranslator/{deleteTranslator.js → deleteTranslator.ts} +13 -18
- package/sqlTranslator/{index.js → index.ts} +30 -33
- package/sqlTranslator/{sql_statement_bucket.js → sql_statement_bucket.ts} +49 -20
- package/static/README.md +10 -9
- package/studio/web/assets/{index-CmtPP0YO.js → index-COfIkCT-.js} +5 -5
- package/studio/web/assets/index-COfIkCT-.js.map +1 -0
- package/studio/web/assets/{index.lazy-C8jvGtlu.js → index.lazy-CIvl7Fj9.js} +2 -2
- package/studio/web/assets/{index.lazy-C8jvGtlu.js.map → index.lazy-CIvl7Fj9.js.map} +1 -1
- package/studio/web/assets/{profile-O0DYlJUv.js → profile-B2ZVB--r.js} +2 -2
- package/studio/web/assets/{profile-O0DYlJUv.js.map → profile-B2ZVB--r.js.map} +1 -1
- package/studio/web/assets/{status-BIlJkJby.js → status-Db6WBmhf.js} +2 -2
- package/studio/web/assets/{status-BIlJkJby.js.map → status-Db6WBmhf.js.map} +1 -1
- package/studio/web/index.html +1 -1
- package/upgrade/{UpgradeObjects.js → UpgradeObjects.ts} +3 -6
- package/upgrade/directives/5-2-0.ts +49 -0
- package/upgrade/directives/{directivesController.js → directivesController.ts} +16 -16
- package/upgrade/{directivesManager.js → directivesManager.ts} +7 -11
- package/upgrade/{upgradePrompt.js → upgradePrompt.ts} +8 -14
- package/upgrade/{upgradeUtilities.js → upgradeUtilities.ts} +3 -7
- package/utility/{OperationFunctionCaller.js → OperationFunctionCaller.ts} +7 -7
- package/utility/{assignCmdEnvVariables.js → assignCmdEnvVariables.ts} +6 -8
- package/utility/{common_utils.js → common_utils.ts} +113 -139
- package/utility/environment/{environmentManager.js → environmentManager.ts} +34 -33
- package/utility/environment/systemInformation.ts +18 -4
- package/utility/errors/{commonErrors.js → commonErrors.ts} +9 -9
- package/utility/errors/{hdbError.js → hdbError.ts} +39 -45
- package/utility/expandEnvVar.ts +110 -0
- package/utility/functions/geo.js +2 -2
- package/utility/functions/sql/alaSQLExtension.js +1 -1
- package/utility/globalSchema.ts +30 -0
- package/utility/hdbTerms.ts +56 -0
- package/utility/install/checkJWTTokensExist.js +1 -1
- package/utility/install/{installer.js → installer.ts} +38 -39
- package/utility/installation.ts +2 -2
- package/utility/lmdb/{DBIDefinition.js → DBIDefinition.ts} +4 -1
- package/utility/lmdb/{DeleteRecordsResponseObject.js → DeleteRecordsResponseObject.ts} +2 -1
- package/utility/lmdb/{InsertRecordsResponseObject.js → InsertRecordsResponseObject.ts} +2 -1
- package/utility/lmdb/OpenDBIObject.ts +43 -0
- package/utility/lmdb/{OpenEnvironmentObject.js → OpenEnvironmentObject.ts} +19 -6
- package/utility/lmdb/{UpdateRecordsResponseObject.js → UpdateRecordsResponseObject.ts} +2 -1
- package/utility/lmdb/{UpsertRecordsResponseObject.js → UpsertRecordsResponseObject.ts} +2 -1
- package/utility/lmdb/{cleanLMDBMap.js → cleanLMDBMap.ts} +5 -5
- package/utility/lmdb/{commonUtility.js → commonUtility.ts} +13 -21
- package/utility/lmdb/{deleteUtility.js → deleteUtility.ts} +8 -12
- package/utility/lmdb/{environmentUtility.js → environmentUtility.ts} +43 -52
- package/utility/lmdb/{searchCursorFunctions.js → searchCursorFunctions.ts} +12 -26
- package/utility/lmdb/{searchUtility.js → searchUtility.ts} +75 -64
- package/utility/lmdb/{terms.js → terms.ts} +10 -23
- package/utility/lmdb/{writeUtility.js → writeUtility.ts} +37 -22
- package/utility/logging/{harper_logger.js → harper_logger.ts} +136 -89
- package/utility/logging/{logRotator.js → logRotator.ts} +13 -13
- package/utility/logging/logger.ts +1 -1
- package/utility/logging/{readLog.js → readLog.ts} +19 -19
- package/utility/logging/{transactionLog.js → transactionLog.ts} +10 -14
- package/utility/{mount_hdb.js → mount_hdb.ts} +15 -16
- package/utility/{npmUtilities.js → npmUtilities.ts} +14 -17
- package/utility/{operation_authorization.js → operation_authorization.ts} +173 -124
- package/utility/packageUtils.js +7 -16
- package/utility/password.ts +1 -1
- package/utility/processManagement/processManagement.js +2 -2
- package/utility/processManagement/servicesConfig.js +1 -1
- package/utility/{signalling.js → signalling.ts} +6 -11
- package/utility/watcherFallback.ts +74 -0
- package/validation/analyticsValidator.ts +43 -0
- package/validation/{bulkDeleteValidator.js → bulkDeleteValidator.ts} +5 -5
- package/validation/{check_permissions.js → check_permissions.ts} +3 -3
- package/validation/{common_validators.js → common_validators.ts} +12 -24
- package/validation/{configValidator.js → configValidator.ts} +114 -18
- package/validation/{deleteValidator.js → deleteValidator.ts} +5 -5
- package/validation/{fileLoadValidator.js → fileLoadValidator.ts} +12 -19
- package/validation/{insertValidator.js → insertValidator.ts} +5 -5
- package/validation/{installValidator.js → installValidator.ts} +8 -8
- package/validation/{readLogValidator.js → readLogValidator.ts} +10 -10
- package/validation/{role_validation.js → role_validation.ts} +26 -32
- package/validation/{schemaMetadataValidator.js → schemaMetadataValidator.ts} +5 -11
- package/validation/{searchValidator.js → searchValidator.ts} +12 -11
- package/validation/statusValidator.ts +1 -1
- package/validation/{transactionLogValidator.js → transactionLogValidator.ts} +4 -9
- package/validation/{user_validation.js → user_validation.ts} +4 -10
- package/validation/{validationWrapper.js → validationWrapper.ts} +3 -9
- package/bin/cliOperations.js +0 -159
- package/bin/lite.js +0 -5
- package/dataLayer/harperBridge/BridgeMethods.js +0 -85
- package/studio/web/assets/index-CmtPP0YO.js.map +0 -1
- package/utility/globalSchema.js +0 -35
- package/utility/lmdb/OpenDBIObject.js +0 -31
package/resources/Table.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import { CONFIG_PARAMS, OPERATIONS_ENUM, SYSTEM_TABLE_NAMES, SYSTEM_SCHEMA_NAME } from '../utility/hdbTerms.ts';
|
|
8
8
|
import { type Database } from 'lmdb';
|
|
9
|
-
import {
|
|
9
|
+
import { Script } from 'node:vm';
|
|
10
|
+
import { getIndexedValues } from '../utility/lmdb/commonUtility.ts';
|
|
10
11
|
import { getThisNodeId, exportIdMapping } from './nodeIdMapping.ts';
|
|
11
12
|
import lodash from 'lodash';
|
|
12
13
|
import { ExtendedIterable, SKIP } from '@harperfast/extended-iterable';
|
|
@@ -25,10 +26,10 @@ import lmdbProcessRows from '../dataLayer/harperBridge/lmdbBridge/lmdbUtility/lm
|
|
|
25
26
|
import { Resource, transformForSelect } from './Resource.ts';
|
|
26
27
|
import { when, promiseNormalize } from '../utility/when.ts';
|
|
27
28
|
import { DatabaseTransaction, ImmediateTransaction, TRANSACTION_STATE } from './DatabaseTransaction.ts';
|
|
28
|
-
import * as envMngr from '../utility/environment/environmentManager.
|
|
29
|
+
import * as envMngr from '../utility/environment/environmentManager.ts';
|
|
29
30
|
import { addSubscription } from './transactionBroadcast.ts';
|
|
30
|
-
import { handleHDBError, ClientError, ServerError, AccessViolation } from '../utility/errors/hdbError.
|
|
31
|
-
import * as signalling from '../utility/signalling.
|
|
31
|
+
import { handleHDBError, ClientError, ServerError, AccessViolation } from '../utility/errors/hdbError.ts';
|
|
32
|
+
import * as signalling from '../utility/signalling.ts';
|
|
32
33
|
import { SchemaEventMsg, UserEventMsg } from '../server/threads/itc.js';
|
|
33
34
|
import { databases, table } from './databases.ts';
|
|
34
35
|
import {
|
|
@@ -38,6 +39,7 @@ import {
|
|
|
38
39
|
flattenKey,
|
|
39
40
|
COERCIBLE_OPERATORS,
|
|
40
41
|
executeConditions,
|
|
42
|
+
resolveComparator,
|
|
41
43
|
} from './search.ts';
|
|
42
44
|
import { logger } from '../utility/logging/logger.ts';
|
|
43
45
|
import { Addition, assignTrackedAccessors, updateAndFreeze, hasChanges, GenericTrackedObject } from './tracked.ts';
|
|
@@ -45,7 +47,8 @@ import { transaction, contextStorage } from './transaction.ts';
|
|
|
45
47
|
import { MAXIMUM_KEY, writeKey, compareKeys } from 'ordered-binary';
|
|
46
48
|
import { getWorkerIndex, getWorkerCount } from '../server/threads/manageThreads.js';
|
|
47
49
|
import { HAS_BLOBS, auditRetention, removeAuditEntry } from './auditStore.ts';
|
|
48
|
-
import {
|
|
50
|
+
import { buildEmbedBefore, createDefaultEmbedder, type EmbedAttribute, type Embedder } from './models/embedHook.ts';
|
|
51
|
+
import { autoCast, autoCastBooleanStrict } from '../utility/common_utils.ts';
|
|
49
52
|
import {
|
|
50
53
|
recordUpdater,
|
|
51
54
|
removeEntry,
|
|
@@ -61,7 +64,7 @@ import fs from 'node:fs';
|
|
|
61
64
|
import { Blob, deleteBlobsInObject, findBlobsInObject, startPreCommitBlobsForRecord } from './blob.ts';
|
|
62
65
|
import { onStorageReclamation } from '../server/storageReclamation.ts';
|
|
63
66
|
import { RequestTarget } from './RequestTarget.ts';
|
|
64
|
-
import harperLogger from '../utility/logging/harper_logger.
|
|
67
|
+
import harperLogger from '../utility/logging/harper_logger.ts';
|
|
65
68
|
import { throttle } from '../server/throttle.ts';
|
|
66
69
|
import { RocksDatabase } from '@harperfast/rocksdb-js';
|
|
67
70
|
import { LMDBTransaction, ImmediateTransaction as ImmediateLMDBTransaction } from './LMDBTransaction';
|
|
@@ -78,11 +81,21 @@ export type Attribute = {
|
|
|
78
81
|
nullable?: boolean;
|
|
79
82
|
expiresAt?: boolean;
|
|
80
83
|
isPrimaryKey?: boolean;
|
|
81
|
-
indexed?:
|
|
82
|
-
relationship?:
|
|
83
|
-
computed?:
|
|
84
|
+
indexed?: any;
|
|
85
|
+
relationship?: any;
|
|
86
|
+
computed?: any;
|
|
87
|
+
resolve?: any;
|
|
88
|
+
computedFromExpression?: any;
|
|
89
|
+
embed?: { source: string; model: string };
|
|
90
|
+
version?: any;
|
|
84
91
|
properties?: Array<Attribute>;
|
|
85
92
|
elements?: Attribute;
|
|
93
|
+
sealed?: boolean;
|
|
94
|
+
|
|
95
|
+
definition?: any;
|
|
96
|
+
set?: any;
|
|
97
|
+
enumerable?: boolean;
|
|
98
|
+
select?: any;
|
|
86
99
|
};
|
|
87
100
|
|
|
88
101
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -91,6 +104,7 @@ const NULL_WITH_TIMESTAMP = new Uint8Array(9);
|
|
|
91
104
|
NULL_WITH_TIMESTAMP[8] = 0xc0; // null
|
|
92
105
|
const UNCACHEABLE_TIMESTAMP = Infinity; // we use this when dynamic content is accessed that we can't safely cache, and this prevents earlier timestamps from change the "last" modification
|
|
93
106
|
const RECORD_PRUNING_INTERVAL = 60000; // one minute
|
|
107
|
+
const CACHEABLE_STATUS_CODES = new Set([200, 203, 204, 206, 300, 301, 308, 404, 405, 410, 414, 501]);
|
|
94
108
|
envMngr.initSync();
|
|
95
109
|
const LMDB_PREFETCH_WRITES = envMngr.get(CONFIG_PARAMS.STORAGE_PREFETCHWRITES);
|
|
96
110
|
const LOCK_TIMEOUT = 10000;
|
|
@@ -131,6 +145,7 @@ type ResidencyDefinition = number | string[] | void;
|
|
|
131
145
|
* Instances of the returned class are Resource instances, intended to provide a consistent view or transaction of the table
|
|
132
146
|
* @param options
|
|
133
147
|
*/
|
|
148
|
+
// #section: setup-and-factory
|
|
134
149
|
export function makeTable(options) {
|
|
135
150
|
const {
|
|
136
151
|
primaryKey,
|
|
@@ -154,9 +169,11 @@ export function makeTable(options) {
|
|
|
154
169
|
const updateRecord = recordUpdater(primaryStore, tableId, auditStore);
|
|
155
170
|
let sourceLoad: any; // if a source has a load function (replicator), record it here
|
|
156
171
|
let hasSourceGet: any;
|
|
157
|
-
let primaryKeyAttribute: Attribute
|
|
172
|
+
let primaryKeyAttribute: Attribute | undefined;
|
|
158
173
|
let lastEvictionCompletion: Promise<void> = Promise.resolve();
|
|
159
|
-
let createdTimeProperty: Attribute
|
|
174
|
+
let createdTimeProperty: Attribute | undefined,
|
|
175
|
+
updatedTimeProperty: Attribute | undefined,
|
|
176
|
+
expiresAtProperty: Attribute | undefined;
|
|
160
177
|
for (const attribute of attributes) {
|
|
161
178
|
if (attribute.assignCreatedTime || attribute.name === '__createdtime__') createdTimeProperty = attribute;
|
|
162
179
|
if (attribute.assignUpdatedTime || attribute.name === '__updatedtime__') updatedTimeProperty = attribute;
|
|
@@ -223,6 +240,7 @@ export function makeTable(options) {
|
|
|
223
240
|
#savingOperation?: any; // operation for the record is currently being saved
|
|
224
241
|
|
|
225
242
|
declare getProperty: (name: string) => any;
|
|
243
|
+
// #section: static-config
|
|
226
244
|
static name = tableName; // for display/debugging purposes
|
|
227
245
|
static primaryStore = primaryStore;
|
|
228
246
|
static auditStore = auditStore;
|
|
@@ -241,6 +259,11 @@ export function makeTable(options) {
|
|
|
241
259
|
static updatedTimeProperty = updatedTimeProperty;
|
|
242
260
|
static propertyResolvers;
|
|
243
261
|
static userResolvers = {};
|
|
262
|
+
// `@embed` hook registry. `userSetEmbedders` records names set explicitly via
|
|
263
|
+
// `setEmbedAttribute` so a schema reload refreshes defaults without clobbering them.
|
|
264
|
+
static userEmbedders: { [name: string]: Embedder } = {};
|
|
265
|
+
static userSetEmbedders: Set<string> = new Set();
|
|
266
|
+
static embedAttributes: EmbedAttribute[] = (attributes as any[]).filter((a) => a?.embed);
|
|
244
267
|
static source?: typeof TableResource;
|
|
245
268
|
declare static sourceOptions: any;
|
|
246
269
|
declare static intermediateSource: boolean;
|
|
@@ -258,6 +281,7 @@ export function makeTable(options) {
|
|
|
258
281
|
* @param options
|
|
259
282
|
* @returns
|
|
260
283
|
*/
|
|
284
|
+
// #section: resource-registry
|
|
261
285
|
static sourcedFrom(source, options) {
|
|
262
286
|
// define a source for retrieving invalidated entries for caching purposes
|
|
263
287
|
if (options) {
|
|
@@ -503,10 +527,10 @@ export function makeTable(options) {
|
|
|
503
527
|
}
|
|
504
528
|
});
|
|
505
529
|
if (txnInProgress) txnInProgress.committed = commitResolution;
|
|
506
|
-
if (userRoleUpdate && commitResolution && !commitResolution
|
|
530
|
+
if (userRoleUpdate && commitResolution && !(commitResolution as any).waitingForUserChange) {
|
|
507
531
|
// if the user role changed, asynchronously signal the user change (but don't block this function)
|
|
508
532
|
commitResolution.then(() => signalling.signalUserChange(new UserEventMsg(process.pid)));
|
|
509
|
-
commitResolution.waitingForUserChange = true; // only need to send one signal per transaction
|
|
533
|
+
(commitResolution as any).waitingForUserChange = true; // only need to send one signal per transaction
|
|
510
534
|
}
|
|
511
535
|
|
|
512
536
|
if (event.onCommit) {
|
|
@@ -554,11 +578,7 @@ export function makeTable(options) {
|
|
|
554
578
|
}
|
|
555
579
|
return resource;
|
|
556
580
|
}
|
|
557
|
-
_loadRecord
|
|
558
|
-
target: RequestTarget,
|
|
559
|
-
request: Context,
|
|
560
|
-
resourceOptions?: any
|
|
561
|
-
): MaybePromise<TableResource<Record>> {
|
|
581
|
+
_loadRecord(target: RequestTarget, request: Context, resourceOptions?: any): MaybePromise<TableResource<Record>> {
|
|
562
582
|
const id = target && typeof target === 'object' ? target.id : target;
|
|
563
583
|
if (id == null) return this;
|
|
564
584
|
checkValidId(id);
|
|
@@ -587,9 +607,10 @@ export function makeTable(options) {
|
|
|
587
607
|
// return 504 (rather than 404) if there is no content and the cache-control header
|
|
588
608
|
// dictates not to go to source
|
|
589
609
|
if (!this.doesExist()) throw new ServerError('Entry is not cached', 504);
|
|
610
|
+
if (hasSourceGet && target) target.loadedFromSource = false; // mark it as cached
|
|
590
611
|
} else if (resourceOptions?.ensureLoaded) {
|
|
591
612
|
const loadingFromSource = ensureLoadedFromSource(
|
|
592
|
-
this.constructor.source,
|
|
613
|
+
(this.constructor as any).source,
|
|
593
614
|
id,
|
|
594
615
|
entry,
|
|
595
616
|
request,
|
|
@@ -598,7 +619,7 @@ export function makeTable(options) {
|
|
|
598
619
|
);
|
|
599
620
|
if (loadingFromSource) {
|
|
600
621
|
txn?.disregardReadTxn(); // this could take some time, so don't keep the transaction open if possible
|
|
601
|
-
return when(loadingFromSource
|
|
622
|
+
return when(loadingFromSource as Promise<Entry>, (entry) => {
|
|
602
623
|
TableResource._updateResource(this, entry);
|
|
603
624
|
return this;
|
|
604
625
|
});
|
|
@@ -624,19 +645,20 @@ export function makeTable(options) {
|
|
|
624
645
|
*/
|
|
625
646
|
ensureLoaded() {
|
|
626
647
|
const loadedFromSource = ensureLoadedFromSource(
|
|
627
|
-
this.constructor.source,
|
|
648
|
+
(this.constructor as any).source,
|
|
628
649
|
this.getId(),
|
|
629
650
|
this.#entry,
|
|
630
651
|
this.getContext()
|
|
631
652
|
);
|
|
632
653
|
if (loadedFromSource) {
|
|
633
|
-
return when(loadedFromSource
|
|
654
|
+
return when(loadedFromSource as Promise<Entry>, (entry) => {
|
|
634
655
|
this.#entry = entry;
|
|
635
656
|
this.#record = entry.value;
|
|
636
657
|
this.#version = entry.version;
|
|
637
658
|
});
|
|
638
659
|
}
|
|
639
660
|
}
|
|
661
|
+
// #section: lifecycle-admin
|
|
640
662
|
static getNewId(): any {
|
|
641
663
|
const type = primaryKeyAttribute?.type;
|
|
642
664
|
// the default Resource behavior is to return a GUID, but for a table we can return incrementing numeric keys if the type is (or can be) numeric
|
|
@@ -936,19 +958,13 @@ export function makeTable(options) {
|
|
|
936
958
|
new SchemaEventMsg(process.pid, OPERATIONS_ENUM.DROP_TABLE, databaseName, tableName)
|
|
937
959
|
);
|
|
938
960
|
}
|
|
939
|
-
|
|
940
|
-
* This retrieves the data of this resource. By default, with no argument, just return `this`.
|
|
941
|
-
*/
|
|
942
|
-
get(): TableResource<Record> | undefined;
|
|
961
|
+
// #section: read-path
|
|
943
962
|
/**
|
|
944
963
|
* This retrieves the data of this resource.
|
|
945
964
|
* @param target - If included, is an identifier/query that specifies the requested target to retrieve and query
|
|
946
965
|
*/
|
|
947
|
-
get(target
|
|
948
|
-
|
|
949
|
-
target?: RequestTargetOrId
|
|
950
|
-
): TableResource<Record> | undefined | Record | AsyncIterable<Record> | Promise<Record | AsyncIterable<Record>> {
|
|
951
|
-
const constructor: Resource = this.constructor;
|
|
966
|
+
get(target?: any): any {
|
|
967
|
+
const constructor: any = this.constructor;
|
|
952
968
|
if (typeof target === 'string' && constructor.loadAsInstance !== false) return this.getProperty(target);
|
|
953
969
|
if (isSearchTarget(target)) {
|
|
954
970
|
// go back to the static search method so it gets a chance to override
|
|
@@ -966,7 +982,7 @@ export function makeTable(options) {
|
|
|
966
982
|
recordCount: undefined,
|
|
967
983
|
estimatedRecordRange: undefined,
|
|
968
984
|
};
|
|
969
|
-
if (this.getContext()?.includeExpensiveRecordCountEstimates) {
|
|
985
|
+
if ((this.getContext() as any)?.includeExpensiveRecordCountEstimates) {
|
|
970
986
|
return TableResource.getRecordCount().then((recordCount) => {
|
|
971
987
|
description.recordCount = recordCount.recordCount;
|
|
972
988
|
description.estimatedRecordRange = recordCount.estimatedRange;
|
|
@@ -976,7 +992,7 @@ export function makeTable(options) {
|
|
|
976
992
|
return description;
|
|
977
993
|
}
|
|
978
994
|
if (target !== undefined && constructor.loadAsInstance === false) {
|
|
979
|
-
const context = this.getContext();
|
|
995
|
+
const context: any = this.getContext();
|
|
980
996
|
const txn = txnForContext(context);
|
|
981
997
|
const readTxn = txn.getReadTxn();
|
|
982
998
|
if (readTxn?.isDone) {
|
|
@@ -985,7 +1001,7 @@ export function makeTable(options) {
|
|
|
985
1001
|
const id = requestTargetToId(target);
|
|
986
1002
|
checkValidId(id);
|
|
987
1003
|
let allowed = true;
|
|
988
|
-
if (target
|
|
1004
|
+
if ((target as any)?.checkPermission) {
|
|
989
1005
|
// requesting authorization verification
|
|
990
1006
|
allowed = this.allowRead(context.user, target, context);
|
|
991
1007
|
}
|
|
@@ -1045,11 +1061,12 @@ export function makeTable(options) {
|
|
|
1045
1061
|
}
|
|
1046
1062
|
return promiseNormalize(record, target);
|
|
1047
1063
|
}
|
|
1048
|
-
if (this.doesExist() || target?.ensureLoaded === false || this.getContext()?.returnNonexistent) {
|
|
1064
|
+
if (this.doesExist() || target?.ensureLoaded === false || (this.getContext() as any)?.returnNonexistent) {
|
|
1049
1065
|
return this;
|
|
1050
1066
|
}
|
|
1051
1067
|
return undefined;
|
|
1052
1068
|
}
|
|
1069
|
+
// #section: authz-hooks
|
|
1053
1070
|
/**
|
|
1054
1071
|
* Determine if the user is allowed to get/read data from the current resource
|
|
1055
1072
|
*/
|
|
@@ -1063,20 +1080,20 @@ export function makeTable(options) {
|
|
|
1063
1080
|
// If attribute permissions are defined, we need to ensure there is a select that only returns the attributes the user has permission to
|
|
1064
1081
|
// or if there are relationships, we need to ensure that the user has permission to read from the related table
|
|
1065
1082
|
// Note that if we do not have a select, we do not return any relationships by default.
|
|
1066
|
-
if (!target) target = {};
|
|
1083
|
+
if (!target) target = {} as any;
|
|
1067
1084
|
if (select) {
|
|
1068
1085
|
const selectArray = Array.isArray(select) ? select : [select];
|
|
1069
1086
|
const attrsForType = attribute_permissions?.length > 0 && attributesAsObject(attribute_permissions, 'read');
|
|
1070
|
-
target.select = selectArray
|
|
1071
|
-
.map((property) => {
|
|
1087
|
+
(target as any).select = selectArray
|
|
1088
|
+
.map((property: any) => {
|
|
1072
1089
|
const propertyName = property.name || property;
|
|
1073
1090
|
if (!attrsForType || attrsForType[propertyName]) {
|
|
1074
1091
|
const relatedTable = propertyResolvers[propertyName]?.definition?.tableClass;
|
|
1075
1092
|
if (relatedTable) {
|
|
1076
1093
|
// if there is a related table, we need to ensure the user has permission to read from that table and that attributes are properly restricted
|
|
1077
1094
|
if (!property.name) property = { name: property };
|
|
1078
|
-
if (!property.checkPermission && target.checkPermission)
|
|
1079
|
-
property.checkPermission = target.checkPermission;
|
|
1095
|
+
if (!property.checkPermission && (target as any).checkPermission)
|
|
1096
|
+
property.checkPermission = (target as any).checkPermission;
|
|
1080
1097
|
if (!relatedTable.prototype.allowRead.call(null, user, property, context)) return false;
|
|
1081
1098
|
if (!property.select) return property.name; // no select was applied, just return the name
|
|
1082
1099
|
}
|
|
@@ -1160,6 +1177,7 @@ export function makeTable(options) {
|
|
|
1160
1177
|
return !!tablePermission?.delete && checkContextPermissions(context);
|
|
1161
1178
|
}
|
|
1162
1179
|
|
|
1180
|
+
// #section: write-path-public
|
|
1163
1181
|
/**
|
|
1164
1182
|
* Start updating a record. The returned resource will record changes which are written
|
|
1165
1183
|
* once the corresponding transaction is committed. These changes can (eventually) include CRDT type operations.
|
|
@@ -1209,29 +1227,29 @@ export function makeTable(options) {
|
|
|
1209
1227
|
// updates that were passed into this method
|
|
1210
1228
|
let allowed = true;
|
|
1211
1229
|
if (target == undefined) throw new TypeError('Can not put a record without a target');
|
|
1212
|
-
if (target
|
|
1230
|
+
if ((target as any)?.checkPermission) {
|
|
1213
1231
|
// requesting authorization verification
|
|
1214
|
-
allowed = this.allowUpdate(context.user, updates, context);
|
|
1232
|
+
allowed = this.allowUpdate((context as any).user, updates, context);
|
|
1215
1233
|
}
|
|
1216
1234
|
return when(allowed, (allowed) => {
|
|
1217
1235
|
if (!allowed) {
|
|
1218
|
-
throw new AccessViolation(context.user);
|
|
1236
|
+
throw new AccessViolation((context as any).user);
|
|
1219
1237
|
}
|
|
1220
1238
|
let loading: Promise<any>;
|
|
1221
|
-
if (!this.#entry && this.constructor.loadAsInstance === false) {
|
|
1239
|
+
if (!this.#entry && (this.constructor as any).loadAsInstance === false) {
|
|
1222
1240
|
// load the record if it hasn't been done yet
|
|
1223
1241
|
loading = this._loadRecord(target, context, { ensureLoaded: true, async: true }) as Promise<any>;
|
|
1224
1242
|
}
|
|
1225
1243
|
return when(loading, () => {
|
|
1226
1244
|
this.#changes = updates;
|
|
1227
|
-
|
|
1228
|
-
|
|
1245
|
+
// `when` awaits the embed hook (when `@embed` is active) before resolving,
|
|
1246
|
+
// so the caller's `save()` doesn't run before the write is staged.
|
|
1247
|
+
return when(this._writeUpdate(id, this.#changes, false), () => this);
|
|
1229
1248
|
});
|
|
1230
1249
|
});
|
|
1231
1250
|
}
|
|
1232
1251
|
}
|
|
1233
|
-
this._writeUpdate(id, this.#changes, fullUpdate);
|
|
1234
|
-
return this;
|
|
1252
|
+
return when(this._writeUpdate(id, this.#changes, fullUpdate), () => this);
|
|
1235
1253
|
}
|
|
1236
1254
|
|
|
1237
1255
|
/**
|
|
@@ -1239,29 +1257,31 @@ export function makeTable(options) {
|
|
|
1239
1257
|
*/
|
|
1240
1258
|
save() {
|
|
1241
1259
|
if (this.#savingOperation) {
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
} finally {
|
|
1247
|
-
this.#savingOperation = null;
|
|
1248
|
-
}
|
|
1260
|
+
try {
|
|
1261
|
+
return this.#saveOperation(this.#savingOperation);
|
|
1262
|
+
} finally {
|
|
1263
|
+
this.#savingOperation = null;
|
|
1249
1264
|
}
|
|
1250
1265
|
}
|
|
1251
1266
|
}
|
|
1267
|
+
#saveOperation(operation: any) {
|
|
1268
|
+
const transaction = txnForContext(this.getContext());
|
|
1269
|
+
if (transaction.save) return transaction.save(operation) || operation.promise || operation.result;
|
|
1270
|
+
}
|
|
1252
1271
|
|
|
1253
|
-
addTo(property, value) {
|
|
1272
|
+
addTo(property: any, value: any) {
|
|
1254
1273
|
if (typeof value === 'number' || typeof value === 'bigint') {
|
|
1255
|
-
if (this.#savingOperation?.fullUpdate)
|
|
1274
|
+
if (this.#savingOperation?.fullUpdate)
|
|
1275
|
+
(this as any).set(property, (+this.getProperty(property) || 0) + (value as any));
|
|
1256
1276
|
else {
|
|
1257
|
-
if (!this.#savingOperation) this.update();
|
|
1258
|
-
this.set(property, new Addition(value));
|
|
1277
|
+
if (!this.#savingOperation) (this as any).update();
|
|
1278
|
+
(this as any).set(property, new Addition(value));
|
|
1259
1279
|
}
|
|
1260
1280
|
} else {
|
|
1261
1281
|
throw new Error('Can not add a non-numeric value');
|
|
1262
1282
|
}
|
|
1263
1283
|
}
|
|
1264
|
-
subtractFrom(property, value) {
|
|
1284
|
+
subtractFrom(property: any, value: any) {
|
|
1265
1285
|
if (typeof value === 'number') {
|
|
1266
1286
|
return this.addTo(property, -value);
|
|
1267
1287
|
} else {
|
|
@@ -1289,11 +1309,11 @@ export function makeTable(options) {
|
|
|
1289
1309
|
const context = this.getContext();
|
|
1290
1310
|
if ((target as RequestTarget)?.checkPermission) {
|
|
1291
1311
|
// requesting authorization verification
|
|
1292
|
-
allowed = this.allowDelete(context.user, target as
|
|
1312
|
+
allowed = this.allowDelete((context as any).user, target as any, context);
|
|
1293
1313
|
}
|
|
1294
1314
|
return when(allowed, (allowed: boolean) => {
|
|
1295
1315
|
if (!allowed) {
|
|
1296
|
-
throw new AccessViolation(context.user);
|
|
1316
|
+
throw new AccessViolation((context as any).user);
|
|
1297
1317
|
}
|
|
1298
1318
|
this._writeInvalidate(target ? requestTargetToId(target) : this.getId());
|
|
1299
1319
|
});
|
|
@@ -1330,7 +1350,7 @@ export function makeTable(options) {
|
|
|
1330
1350
|
INVALIDATED,
|
|
1331
1351
|
audit,
|
|
1332
1352
|
{
|
|
1333
|
-
user: context?.user,
|
|
1353
|
+
user: (context as any)?.user,
|
|
1334
1354
|
residencyId: options?.residencyId,
|
|
1335
1355
|
nodeId: options?.nodeId,
|
|
1336
1356
|
viaNodeId: options?.viaNodeId,
|
|
@@ -1355,8 +1375,8 @@ export function makeTable(options) {
|
|
|
1355
1375
|
invalidated: true,
|
|
1356
1376
|
entry: this.#entry,
|
|
1357
1377
|
before:
|
|
1358
|
-
this.constructor.source?.relocate && !context?.source
|
|
1359
|
-
? this.constructor.source.relocate.bind(this.constructor.source, id, undefined, context)
|
|
1378
|
+
(this.constructor as any).source?.relocate && !(context as any)?.source
|
|
1379
|
+
? (this.constructor as any).source.relocate.bind((this.constructor as any).source, id, undefined, context)
|
|
1360
1380
|
: undefined,
|
|
1361
1381
|
commit: (txnTime, existingEntry, _retry, transaction: any) => {
|
|
1362
1382
|
if (precedesExistingVersion(txnTime, existingEntry, options?.nodeId) <= 0) return;
|
|
@@ -1385,7 +1405,7 @@ export function makeTable(options) {
|
|
|
1385
1405
|
metadata,
|
|
1386
1406
|
audit,
|
|
1387
1407
|
{
|
|
1388
|
-
user: context
|
|
1408
|
+
user: (context as any)?.user,
|
|
1389
1409
|
residencyId: options.residencyId,
|
|
1390
1410
|
nodeId: options.nodeId,
|
|
1391
1411
|
viaNodeId: options?.viaNodeId,
|
|
@@ -1469,12 +1489,12 @@ export function makeTable(options) {
|
|
|
1469
1489
|
committed = true;
|
|
1470
1490
|
if (primaryStore.ifVersion) {
|
|
1471
1491
|
// LMDB: committing the wrapper calls doneReadTxn(), removing it from trackedTxns
|
|
1472
|
-
return lmdbTransaction.commit();
|
|
1492
|
+
return (lmdbTransaction as any).commit();
|
|
1473
1493
|
}
|
|
1474
1494
|
// RocksDB: eviction writes went directly into the raw transaction via options;
|
|
1475
1495
|
// commit it directly, as DatabaseTransaction.commit() would abort it (no tracked writes).
|
|
1476
1496
|
// Wrap in Promise.resolve so callers can rely on a thenable return regardless of engine.
|
|
1477
|
-
return
|
|
1497
|
+
return (transaction as any).commit();
|
|
1478
1498
|
} finally {
|
|
1479
1499
|
if (!committed) {
|
|
1480
1500
|
// Skip path or thrown error: abort instead of committing so we don't apply
|
|
@@ -1496,77 +1516,82 @@ export function makeTable(options) {
|
|
|
1496
1516
|
static operation(operation, context) {
|
|
1497
1517
|
operation.table ||= tableName;
|
|
1498
1518
|
operation.schema ||= databaseName;
|
|
1499
|
-
return global.operation(operation, context);
|
|
1519
|
+
return (global as any).operation(operation, context);
|
|
1500
1520
|
}
|
|
1501
1521
|
|
|
1502
1522
|
/**
|
|
1503
1523
|
* Store the provided record data into the current resource. This is not written
|
|
1504
1524
|
* until the corresponding transaction is committed.
|
|
1505
1525
|
*/
|
|
1526
|
+
// @ts-expect-error The implementation intentionally uses a different argument order for back-compat
|
|
1506
1527
|
put(
|
|
1507
1528
|
target: RequestTarget,
|
|
1508
1529
|
record: Record & RecordObject
|
|
1509
1530
|
): void | (Record & Partial<RecordObject>) | Promise<void | (Record & Partial<RecordObject>)> {
|
|
1510
1531
|
if (record === undefined || record instanceof URLSearchParams) {
|
|
1511
|
-
// legacy argument position, shift the arguments and go through the update method for back-compat
|
|
1512
|
-
|
|
1513
|
-
return this.save();
|
|
1532
|
+
// legacy argument position, shift the arguments and go through the update method for back-compat.
|
|
1533
|
+
// `when` settles the embed hook before `save()` so the write is staged first.
|
|
1534
|
+
return when((this as any).update(target, true), () => this.save() as any) as any;
|
|
1514
1535
|
} else {
|
|
1515
1536
|
let allowed = true;
|
|
1516
1537
|
if (target == undefined) throw new TypeError('Can not put a record without a target');
|
|
1517
1538
|
const context = this.getContext();
|
|
1518
|
-
if (target.checkPermission) {
|
|
1539
|
+
if ((target as any).checkPermission) {
|
|
1519
1540
|
// requesting authorization verification
|
|
1520
|
-
allowed = this.allowUpdate(context.user, record, context);
|
|
1541
|
+
allowed = this.allowUpdate((context as any).user, record, context);
|
|
1521
1542
|
}
|
|
1522
1543
|
return when(allowed, (allowed) => {
|
|
1523
1544
|
if (!allowed) {
|
|
1524
|
-
throw new AccessViolation(context.user);
|
|
1545
|
+
throw new AccessViolation((context as any).user);
|
|
1525
1546
|
}
|
|
1526
1547
|
// standard path, handle arrays as multiple updates, and otherwise do a direct update
|
|
1527
1548
|
if (Array.isArray(record)) {
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1549
|
+
// Capture each element's operation synchronously (before any async `@embed`
|
|
1550
|
+
// hook resolves): `#savingOperation` is a single field that parallel writes
|
|
1551
|
+
// would otherwise clobber, so a deferred `save()` would commit the wrong op
|
|
1552
|
+
// — e.g. one element's save running before a later element's vector is written.
|
|
1553
|
+
const writes = record.map((element) => {
|
|
1554
|
+
const id = element[primaryKey];
|
|
1555
|
+
const writePromise = this._writeUpdate(id, element, true);
|
|
1556
|
+
const operation = this.#savingOperation;
|
|
1557
|
+
return when(writePromise, () => this.#saveOperation(operation));
|
|
1558
|
+
});
|
|
1559
|
+
this.#savingOperation = null;
|
|
1560
|
+
return Promise.all(writes) as any;
|
|
1535
1561
|
} else {
|
|
1536
|
-
const id = requestTargetToId(target);
|
|
1537
|
-
this._writeUpdate(id, record, true);
|
|
1538
|
-
return this.save();
|
|
1562
|
+
const id = requestTargetToId(target as any);
|
|
1563
|
+
return when(this._writeUpdate(id, record, true), () => this.save() as any);
|
|
1539
1564
|
}
|
|
1540
|
-
});
|
|
1565
|
+
}) as any;
|
|
1541
1566
|
}
|
|
1542
1567
|
// always return undefined
|
|
1543
1568
|
}
|
|
1544
1569
|
|
|
1545
1570
|
create(
|
|
1546
|
-
target:
|
|
1571
|
+
target: RequestTargetOrId,
|
|
1547
1572
|
record: Partial<Record & RecordObject>
|
|
1548
1573
|
): void | (Record & Partial<RecordObject>) | Promise<Record & Partial<RecordObject>> {
|
|
1549
1574
|
let allowed = true;
|
|
1550
1575
|
const context = this.getContext();
|
|
1551
1576
|
if (!record && !(target instanceof URLSearchParams)) {
|
|
1552
1577
|
// single argument, shift arguments
|
|
1553
|
-
record = target;
|
|
1578
|
+
record = target as any;
|
|
1554
1579
|
target = undefined;
|
|
1555
1580
|
}
|
|
1556
1581
|
if (!record || typeof record !== 'object' || Array.isArray(record)) {
|
|
1557
1582
|
throw new TypeError('Can not create a record without an object');
|
|
1558
1583
|
}
|
|
1559
|
-
if (target?.checkPermission) {
|
|
1584
|
+
if ((target as any)?.checkPermission) {
|
|
1560
1585
|
// requesting authorization verification
|
|
1561
|
-
allowed = this.allowCreate(context.user, record, context);
|
|
1586
|
+
allowed = this.allowCreate((context as any).user, record as any, context);
|
|
1562
1587
|
}
|
|
1563
1588
|
return when(allowed, (allowed) => {
|
|
1564
1589
|
if (!allowed) {
|
|
1565
|
-
throw new AccessViolation(context.user);
|
|
1590
|
+
throw new AccessViolation((context as any).user);
|
|
1566
1591
|
}
|
|
1567
|
-
let id = requestTargetToId(target) ?? record[primaryKey];
|
|
1592
|
+
let id = requestTargetToId(target as any) ?? record[primaryKey];
|
|
1568
1593
|
if (id === undefined) {
|
|
1569
|
-
id = this.constructor.getNewId();
|
|
1594
|
+
id = (this.constructor as any).getNewId();
|
|
1570
1595
|
record[primaryKey] = id; // make this immediately available
|
|
1571
1596
|
} else {
|
|
1572
1597
|
const existing = primaryStore.getSync(id);
|
|
@@ -1574,9 +1599,11 @@ export function makeTable(options) {
|
|
|
1574
1599
|
throw new ClientError('Record already exists', 409);
|
|
1575
1600
|
}
|
|
1576
1601
|
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1602
|
+
// `_writeUpdate` may return a promise when an `@embed` directive
|
|
1603
|
+
// requires running an embedder before the per-write `commit(...)`
|
|
1604
|
+
// closure. `when()` passes through synchronous returns.
|
|
1605
|
+
return when(this._writeUpdate(id, record, true), () => record);
|
|
1606
|
+
}) as any;
|
|
1580
1607
|
}
|
|
1581
1608
|
|
|
1582
1609
|
// @ts-expect-error The implementation handles the possibility of target and recordUpdate being swapped
|
|
@@ -1585,39 +1612,39 @@ export function makeTable(options) {
|
|
|
1585
1612
|
recordUpdate: Partial<Record & RecordObject>
|
|
1586
1613
|
): void | (Record & Partial<RecordObject>) | Promise<void | (Record & Partial<RecordObject>)> {
|
|
1587
1614
|
if (recordUpdate === undefined || recordUpdate instanceof URLSearchParams) {
|
|
1588
|
-
// legacy argument position, shift the arguments and go through the update method for back-compat
|
|
1589
|
-
|
|
1590
|
-
return this.save();
|
|
1615
|
+
// legacy argument position, shift the arguments and go through the update method for back-compat.
|
|
1616
|
+
// `when` settles the embed hook before `save()` so the write is staged first.
|
|
1617
|
+
return when(this.update(target, false), () => this.save() as any) as any;
|
|
1591
1618
|
} else {
|
|
1592
1619
|
// standard path, ensure there is no return object
|
|
1593
1620
|
return when(this.update(target, recordUpdate), () => {
|
|
1594
|
-
return when(this.save(), () => undefined); // wait for the update and save, but return undefined
|
|
1595
|
-
});
|
|
1621
|
+
return when(this.save() as any, () => undefined); // wait for the update and save, but return undefined
|
|
1622
|
+
}) as any;
|
|
1596
1623
|
}
|
|
1597
1624
|
}
|
|
1625
|
+
// #section: write-path-internals
|
|
1598
1626
|
// perform the actual write operation; this may come from a user request to write (put, post, etc.), or
|
|
1599
1627
|
// a notification that a write has already occurred in the canonical data source, we need to update our
|
|
1600
1628
|
// local copy
|
|
1601
1629
|
_writeUpdate(id: Id, recordUpdate: any, fullUpdate: boolean, options?: any) {
|
|
1602
1630
|
const context = this.getContext();
|
|
1603
1631
|
const transaction = txnForContext(context);
|
|
1604
|
-
|
|
1605
1632
|
checkValidId(id);
|
|
1606
1633
|
const entry = this.#entry ?? primaryStore.getEntry(id, { transaction: transaction.getReadTxn() });
|
|
1607
1634
|
const writeToSource = () => {
|
|
1608
|
-
if (!this.constructor.source || context?.source) return;
|
|
1635
|
+
if (!(this.constructor as any).source || (context as any)?.source) return;
|
|
1609
1636
|
if (fullUpdate) {
|
|
1610
1637
|
// full update is a put
|
|
1611
|
-
if (this.constructor.source.put) {
|
|
1612
|
-
return () => this.constructor.source.put(id, recordUpdate, context);
|
|
1638
|
+
if ((this.constructor as any).source.put) {
|
|
1639
|
+
return () => (this.constructor as any).source.put(id, recordUpdate, context);
|
|
1613
1640
|
}
|
|
1614
1641
|
} else {
|
|
1615
1642
|
// incremental update
|
|
1616
|
-
if (this.constructor.source.patch) {
|
|
1617
|
-
return () => this.constructor.source.patch(id, recordUpdate, context);
|
|
1618
|
-
} else if (this.constructor.source.put) {
|
|
1643
|
+
if ((this.constructor as any).source.patch) {
|
|
1644
|
+
return () => (this.constructor as any).source.patch(id, recordUpdate, context);
|
|
1645
|
+
} else if ((this.constructor as any).source.put) {
|
|
1619
1646
|
// if this is incremental, but only have put, we can use that by generating the full record (at least the expected one)
|
|
1620
|
-
return () => this.constructor.source.put(id, updateAndFreeze(this), context);
|
|
1647
|
+
return () => (this.constructor as any).source.put(id, updateAndFreeze(this), context);
|
|
1621
1648
|
}
|
|
1622
1649
|
}
|
|
1623
1650
|
};
|
|
@@ -1626,13 +1653,13 @@ export function makeTable(options) {
|
|
|
1626
1653
|
key: id,
|
|
1627
1654
|
store: primaryStore,
|
|
1628
1655
|
entry,
|
|
1629
|
-
nodeName: context?.nodeName,
|
|
1656
|
+
nodeName: (context as any)?.nodeName,
|
|
1630
1657
|
fullUpdate,
|
|
1631
1658
|
deferSave: true,
|
|
1632
1659
|
validate: (txnTime) => {
|
|
1633
1660
|
if (!recordUpdate) recordUpdate = this.#changes;
|
|
1634
1661
|
if (fullUpdate || (recordUpdate && hasChanges(this.#changes === recordUpdate ? this : recordUpdate))) {
|
|
1635
|
-
if (!context?.source) {
|
|
1662
|
+
if (!(context as any)?.source) {
|
|
1636
1663
|
transaction.checkOverloaded();
|
|
1637
1664
|
this.validate(recordUpdate, !fullUpdate);
|
|
1638
1665
|
if (updatedTimeProperty) {
|
|
@@ -1669,7 +1696,7 @@ export function makeTable(options) {
|
|
|
1669
1696
|
// TODO: else freeze after we have applied the changes
|
|
1670
1697
|
}
|
|
1671
1698
|
} else {
|
|
1672
|
-
transaction.removeWrite?.(write);
|
|
1699
|
+
(transaction as any).removeWrite?.(write);
|
|
1673
1700
|
return false;
|
|
1674
1701
|
}
|
|
1675
1702
|
},
|
|
@@ -1853,7 +1880,7 @@ export function makeTable(options) {
|
|
|
1853
1880
|
let recordToStore: any;
|
|
1854
1881
|
if (fullUpdate && !incrementalUpdateToApply) recordToStore = recordUpdate;
|
|
1855
1882
|
else {
|
|
1856
|
-
if (this.constructor.loadAsInstance === false)
|
|
1883
|
+
if ((this.constructor as any).loadAsInstance === false)
|
|
1857
1884
|
recordToStore = updateAndFreeze(existingRecord, incrementalUpdateToApply ?? recordUpdate);
|
|
1858
1885
|
else {
|
|
1859
1886
|
this.#record = existingRecord;
|
|
@@ -1864,7 +1891,8 @@ export function makeTable(options) {
|
|
|
1864
1891
|
if (recordToStore && recordToStore.getRecord)
|
|
1865
1892
|
throw new Error('Can not assign a record to a record, check for circular references');
|
|
1866
1893
|
if (residencyId == undefined) {
|
|
1867
|
-
if (entry?.residencyId)
|
|
1894
|
+
if (entry?.residencyId)
|
|
1895
|
+
(context as any).previousResidency = TableResource.getResidencyRecord(entry.residencyId);
|
|
1868
1896
|
const residency = residencyFromFunction(TableResource.getResidency(recordToStore, context));
|
|
1869
1897
|
if (residency) {
|
|
1870
1898
|
if (!residency.includes(server.hostname)) {
|
|
@@ -1931,12 +1959,12 @@ export function makeTable(options) {
|
|
|
1931
1959
|
audit,
|
|
1932
1960
|
{
|
|
1933
1961
|
omitLocalRecord,
|
|
1934
|
-
user: context?.user,
|
|
1962
|
+
user: (context as any)?.user,
|
|
1935
1963
|
residencyId,
|
|
1936
1964
|
expiresAt,
|
|
1937
1965
|
nodeId: options?.nodeId,
|
|
1938
1966
|
viaNodeId: options?.viaNodeId,
|
|
1939
|
-
originatingOperation: context?.originatingOperation,
|
|
1967
|
+
originatingOperation: (context as any)?.originatingOperation,
|
|
1940
1968
|
transaction,
|
|
1941
1969
|
tableToTrack: databaseName === 'system' ? null : options?.replay ? null : tableName, // don't track analytics on system tables
|
|
1942
1970
|
additionalAuditRefs: additionalAuditRefs.length > 0 ? additionalAuditRefs : undefined,
|
|
@@ -1949,33 +1977,52 @@ export function makeTable(options) {
|
|
|
1949
1977
|
},
|
|
1950
1978
|
};
|
|
1951
1979
|
this.#savingOperation = write;
|
|
1952
|
-
|
|
1953
|
-
|
|
1980
|
+
// `@embed` hook must run before `addWrite` so the embedder's vector is on the
|
|
1981
|
+
// record when `commit` runs. (The txn `before` slot runs after commit, which
|
|
1982
|
+
// suits blob writes but not embedding, where the vector must be present at commit.)
|
|
1983
|
+
// Known limitation of this write-time placement (a validate-time alternative was
|
|
1984
|
+
// tried and reverted as a Harper-foreign pattern): the embedder sees this write's
|
|
1985
|
+
// payload, before table validation — so a write that later fails validation still
|
|
1986
|
+
// calls the backend, and a tracked-instance mutation (update(id,{}); row.source=…;
|
|
1987
|
+
// save()) that sets the source via accessors after update() won't re-embed. A
|
|
1988
|
+
// resource-layer re-embed is the proper fix; tracked as a follow-up.
|
|
1989
|
+
const embedBefore = buildEmbedBefore(
|
|
1990
|
+
recordUpdate,
|
|
1991
|
+
context,
|
|
1992
|
+
options,
|
|
1993
|
+
TableResource.embedAttributes,
|
|
1994
|
+
TableResource.userEmbedders
|
|
1995
|
+
);
|
|
1996
|
+
const proceed = (): any => {
|
|
1997
|
+
write.beforeIntermediate = preCommitBlobsForRecordBefore(write, recordUpdate);
|
|
1998
|
+
return transaction.addWrite(write as any);
|
|
1999
|
+
};
|
|
2000
|
+
return embedBefore ? embedBefore().then(proceed) : proceed();
|
|
1954
2001
|
}
|
|
1955
2002
|
|
|
1956
2003
|
async delete(target: RequestTargetOrId): Promise<boolean> {
|
|
1957
2004
|
if (isSearchTarget(target)) {
|
|
1958
2005
|
target.select = ['$id']; // just get the primary key of each record so we can delete them
|
|
1959
2006
|
for await (const entry of this.search(target)) {
|
|
1960
|
-
this._writeDelete(entry.$id);
|
|
2007
|
+
this._writeDelete((entry as any).$id);
|
|
1961
2008
|
}
|
|
1962
2009
|
return true;
|
|
1963
2010
|
}
|
|
1964
2011
|
if (target) {
|
|
1965
2012
|
let allowed = true;
|
|
1966
2013
|
const context = this.getContext();
|
|
1967
|
-
if (target
|
|
2014
|
+
if ((target as any)?.checkPermission) {
|
|
1968
2015
|
// requesting authorization verification
|
|
1969
|
-
allowed = this.allowDelete(context.user, target, context);
|
|
2016
|
+
allowed = this.allowDelete((context as any).user, target as any, context);
|
|
1970
2017
|
}
|
|
1971
2018
|
return when(allowed, (allowed: boolean) => {
|
|
1972
2019
|
if (!allowed) {
|
|
1973
|
-
throw new AccessViolation(context.user);
|
|
2020
|
+
throw new AccessViolation((context as any).user);
|
|
1974
2021
|
}
|
|
1975
|
-
const id = requestTargetToId(target);
|
|
2022
|
+
const id = requestTargetToId(target as any);
|
|
1976
2023
|
this._writeDelete(id);
|
|
1977
2024
|
return true;
|
|
1978
|
-
});
|
|
2025
|
+
}) as any;
|
|
1979
2026
|
}
|
|
1980
2027
|
this._writeDelete(this.getId());
|
|
1981
2028
|
return Boolean(this.#record);
|
|
@@ -1990,10 +2037,10 @@ export function makeTable(options) {
|
|
|
1990
2037
|
key: id,
|
|
1991
2038
|
store: primaryStore,
|
|
1992
2039
|
entry,
|
|
1993
|
-
nodeName: context?.nodeName,
|
|
2040
|
+
nodeName: (context as any)?.nodeName,
|
|
1994
2041
|
before:
|
|
1995
|
-
this.constructor.source?.delete && !context?.source
|
|
1996
|
-
? this.constructor.source.delete.bind(this.constructor.source, id, undefined, context)
|
|
2042
|
+
(this.constructor as any).source?.delete && !(context as any)?.source
|
|
2043
|
+
? (this.constructor as any).source.delete.bind((this.constructor as any).source, id, undefined, context)
|
|
1997
2044
|
: undefined,
|
|
1998
2045
|
commit: (txnTime, existingEntry, retry, transaction: any) => {
|
|
1999
2046
|
const existingRecord = existingEntry?.value;
|
|
@@ -2015,7 +2062,7 @@ export function makeTable(options) {
|
|
|
2015
2062
|
0,
|
|
2016
2063
|
audit,
|
|
2017
2064
|
{
|
|
2018
|
-
user: context?.user,
|
|
2065
|
+
user: (context as any)?.user,
|
|
2019
2066
|
nodeId: options?.nodeId,
|
|
2020
2067
|
viaNodeId: options?.viaNodeId,
|
|
2021
2068
|
transaction,
|
|
@@ -2028,10 +2075,11 @@ export function makeTable(options) {
|
|
|
2028
2075
|
removeEntry(primaryStore, existingEntry);
|
|
2029
2076
|
}
|
|
2030
2077
|
},
|
|
2031
|
-
});
|
|
2078
|
+
} as any);
|
|
2032
2079
|
return true;
|
|
2033
2080
|
}
|
|
2034
2081
|
|
|
2082
|
+
// #section: search-query
|
|
2035
2083
|
search(target: RequestTarget): AsyncIterable<Record & Partial<RecordObject>> {
|
|
2036
2084
|
const context = this.getContext();
|
|
2037
2085
|
const txn = txnForContext(context);
|
|
@@ -2039,14 +2087,14 @@ export function makeTable(options) {
|
|
|
2039
2087
|
if (target.parseError) throw target.parseError; // if there was a parse error, we can throw it now
|
|
2040
2088
|
if (target.checkPermission) {
|
|
2041
2089
|
// requesting authorization verification
|
|
2042
|
-
const allowed = this.allowRead(context.user, target, context);
|
|
2090
|
+
const allowed = this.allowRead((context as any).user, target, context);
|
|
2043
2091
|
if (!allowed) {
|
|
2044
|
-
throw new AccessViolation(context.user);
|
|
2092
|
+
throw new AccessViolation((context as any).user);
|
|
2045
2093
|
}
|
|
2046
2094
|
}
|
|
2047
2095
|
if (context) context.lastModified = UNCACHEABLE_TIMESTAMP;
|
|
2048
2096
|
|
|
2049
|
-
let conditions = target.conditions;
|
|
2097
|
+
let conditions: any = target.conditions;
|
|
2050
2098
|
if (!conditions) conditions = Array.isArray(target) ? target : target[Symbol.iterator] ? Array.from(target) : [];
|
|
2051
2099
|
else if (conditions.length === undefined) {
|
|
2052
2100
|
conditions = conditions[Symbol.iterator] ? Array.from(conditions) : [conditions];
|
|
@@ -2064,7 +2112,7 @@ export function makeTable(options) {
|
|
|
2064
2112
|
let orderAlignedCondition;
|
|
2065
2113
|
const filtered = {};
|
|
2066
2114
|
|
|
2067
|
-
function prepareConditions(conditions:
|
|
2115
|
+
function prepareConditions(conditions: any[], operator: string) {
|
|
2068
2116
|
// some validation:
|
|
2069
2117
|
switch (operator) {
|
|
2070
2118
|
case 'and':
|
|
@@ -2082,15 +2130,37 @@ export function makeTable(options) {
|
|
|
2082
2130
|
condition.conditions = prepareConditions(condition.conditions, condition.operator);
|
|
2083
2131
|
continue;
|
|
2084
2132
|
}
|
|
2133
|
+
// Normalize `not_X` comparator forms passed in via structured queries.
|
|
2134
|
+
// The REST parser already does this, but programmatic callers may
|
|
2135
|
+
// pass `not_in`, `not_starts_with`, etc. directly.
|
|
2136
|
+
if (condition.comparator) {
|
|
2137
|
+
const resolved = resolveComparator(condition.comparator);
|
|
2138
|
+
if (resolved.negated) {
|
|
2139
|
+
condition.comparator = resolved.comparator;
|
|
2140
|
+
condition.negated = true;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2085
2143
|
const attribute_name = condition[0] ?? condition.attribute;
|
|
2086
|
-
|
|
2144
|
+
let attribute = attribute_name == null ? primaryKeyAttribute : findAttribute(attributes, attribute_name);
|
|
2145
|
+
if (!attribute && Array.isArray(attribute_name) && attribute_name.length > 1) {
|
|
2146
|
+
// Plain JSON nested path: the leaf may not be declared in the
|
|
2147
|
+
// schema. Fall back to the root attribute so we can validate
|
|
2148
|
+
// existence without requiring the inner structure to be typed.
|
|
2149
|
+
attribute = findAttribute(attributes, attribute_name[0]);
|
|
2150
|
+
}
|
|
2087
2151
|
if (!attribute) {
|
|
2088
2152
|
if (attribute_name != null && !target.allowConditionsOnDynamicAttributes)
|
|
2089
2153
|
throw handleHDBError(new Error(), `${attribute_name} is not a defined attribute`, 404);
|
|
2090
2154
|
} else if (attribute.type || COERCIBLE_OPERATORS[condition.comparator]) {
|
|
2091
|
-
// Do auto-coercion or coercion as required by the attribute type
|
|
2092
|
-
|
|
2093
|
-
|
|
2155
|
+
// Do auto-coercion or coercion as required by the attribute type.
|
|
2156
|
+
// Skipped for nested paths into plain JSON — the root attribute's
|
|
2157
|
+
// type is not the leaf type, so coercion would be wrong.
|
|
2158
|
+
const isNestedPathRoot =
|
|
2159
|
+
Array.isArray(attribute_name) && attribute_name.length > 1 && !attribute.relationship;
|
|
2160
|
+
if (!isNestedPathRoot) {
|
|
2161
|
+
if (condition[1] === undefined) condition.value = coerceTypedValues(condition.value, attribute);
|
|
2162
|
+
else condition[1] = coerceTypedValues(condition[1], attribute);
|
|
2163
|
+
}
|
|
2094
2164
|
}
|
|
2095
2165
|
if (condition.chainedConditions) {
|
|
2096
2166
|
if (condition.chainedConditions.length === 1 && (!condition.operator || condition.operator == 'and')) {
|
|
@@ -2120,7 +2190,7 @@ export function makeTable(options) {
|
|
|
2120
2190
|
}
|
|
2121
2191
|
const isGe = lower.comparator === 'ge' || lower.comparator === 'greater_than_equal';
|
|
2122
2192
|
const isLe = upper.comparator === 'le' || upper.comparator === 'less_than_equal';
|
|
2123
|
-
condition.comparator = (isGe ? 'ge' : 'gt') + (isLe ? 'le' : 'lt');
|
|
2193
|
+
condition.comparator = ((isGe ? 'ge' : 'gt') + (isLe ? 'le' : 'lt')) as any;
|
|
2124
2194
|
condition.value = [lower.value, upper.value];
|
|
2125
2195
|
} else throw new Error('Multiple chained conditions are not currently supported');
|
|
2126
2196
|
}
|
|
@@ -2150,11 +2220,11 @@ export function makeTable(options) {
|
|
|
2150
2220
|
let postOrdering;
|
|
2151
2221
|
if (sort) {
|
|
2152
2222
|
// TODO: Support index-assisted sorts of unions, which will require potentially recursively adding/modifying an order aligned condition and be able to recursively undo it if necessary
|
|
2153
|
-
if (operator !== 'or') {
|
|
2223
|
+
if ((operator as any) !== 'or') {
|
|
2154
2224
|
const attribute_name = sort.attribute;
|
|
2155
2225
|
if (attribute_name == undefined) throw new ClientError('Sort requires an attribute');
|
|
2156
2226
|
orderAlignedCondition = conditions.find(
|
|
2157
|
-
(condition) => flattenKey(condition.attribute) === flattenKey(attribute_name)
|
|
2227
|
+
(condition) => flattenKey(condition.attribute as any) === flattenKey(attribute_name as any)
|
|
2158
2228
|
);
|
|
2159
2229
|
if (orderAlignedCondition) {
|
|
2160
2230
|
// if there is a condition on the same attribute as the first sort, we can use it to align the sort
|
|
@@ -2165,7 +2235,7 @@ export function makeTable(options) {
|
|
|
2165
2235
|
throw handleHDBError(
|
|
2166
2236
|
new Error(),
|
|
2167
2237
|
`${
|
|
2168
|
-
Array.isArray(attribute_name) ? attribute_name.join('.') : attribute_name
|
|
2238
|
+
Array.isArray(attribute_name) ? (attribute_name as any).join('.') : attribute_name
|
|
2169
2239
|
} is not a defined attribute`,
|
|
2170
2240
|
404
|
|
2171
2241
|
);
|
|
@@ -2177,7 +2247,7 @@ export function makeTable(options) {
|
|
|
2177
2247
|
throw handleHDBError(
|
|
2178
2248
|
new Error(),
|
|
2179
2249
|
`${
|
|
2180
|
-
Array.isArray(attribute_name) ? attribute_name.join('.') : attribute_name
|
|
2250
|
+
Array.isArray(attribute_name) ? (attribute_name as any).join('.') : attribute_name
|
|
2181
2251
|
} is not indexed and not combined with any other conditions`,
|
|
2182
2252
|
404
|
|
2183
2253
|
);
|
|
@@ -2213,7 +2283,7 @@ export function makeTable(options) {
|
|
|
2213
2283
|
operator,
|
|
2214
2284
|
postOrdering,
|
|
2215
2285
|
selectApplied: Boolean(select),
|
|
2216
|
-
};
|
|
2286
|
+
} as any;
|
|
2217
2287
|
}
|
|
2218
2288
|
// we mark the read transaction as in use (necessary for a stable read
|
|
2219
2289
|
// transaction, and we really don't care if the
|
|
@@ -2230,7 +2300,7 @@ export function makeTable(options) {
|
|
|
2230
2300
|
(results: any[], filters: Function[]) => transformToEntries(results, select, context, readTxn, filters),
|
|
2231
2301
|
filtered
|
|
2232
2302
|
);
|
|
2233
|
-
const ensure_loaded = target.ensureLoaded !== false;
|
|
2303
|
+
const ensure_loaded = (target as any).ensureLoaded !== false;
|
|
2234
2304
|
const transformToRecord = TableResource.transformEntryForSelect(
|
|
2235
2305
|
select,
|
|
2236
2306
|
context,
|
|
@@ -2263,7 +2333,7 @@ export function makeTable(options) {
|
|
|
2263
2333
|
const columns = [];
|
|
2264
2334
|
for (const column of select) {
|
|
2265
2335
|
if (column === '*') columns.push(...attributes.map((attribute) => attribute.name));
|
|
2266
|
-
else columns.push(column.name || column);
|
|
2336
|
+
else columns.push((column as any).name || column);
|
|
2267
2337
|
}
|
|
2268
2338
|
return columns;
|
|
2269
2339
|
}
|
|
@@ -2303,14 +2373,14 @@ export function makeTable(options) {
|
|
|
2303
2373
|
? entries[Symbol.asyncIterator]()
|
|
2304
2374
|
: entries[Symbol.iterator]();
|
|
2305
2375
|
let dbDone: boolean;
|
|
2306
|
-
const dbOrderedAttribute = sort.dbOrderedAttribute;
|
|
2376
|
+
const dbOrderedAttribute = (sort as any).dbOrderedAttribute;
|
|
2307
2377
|
let enqueuedEntryForNextGroup: any;
|
|
2308
2378
|
let lastGroupingValue: any;
|
|
2309
2379
|
let firstEntry = true;
|
|
2310
2380
|
function createComparator(order: Sort) {
|
|
2311
2381
|
const nextComparator = order.next && createComparator(order.next);
|
|
2312
2382
|
const descending = order.descending;
|
|
2313
|
-
context.sort = order; // make sure this is set to the current sort order
|
|
2383
|
+
(context as any).sort = order; // make sure this is set to the current sort order
|
|
2314
2384
|
return (entryA, entryB) => {
|
|
2315
2385
|
const a = getAttributeValue(entryA, order.attribute, context);
|
|
2316
2386
|
const b = getAttributeValue(entryB, order.attribute, context);
|
|
@@ -2369,7 +2439,7 @@ export function makeTable(options) {
|
|
|
2369
2439
|
ordered.push(entry);
|
|
2370
2440
|
}
|
|
2371
2441
|
} while (true);
|
|
2372
|
-
if (sort.isGrouped) {
|
|
2442
|
+
if ((sort as any).isGrouped) {
|
|
2373
2443
|
// TODO: Return grouped results
|
|
2374
2444
|
}
|
|
2375
2445
|
ordered.sort(comparator);
|
|
@@ -2397,8 +2467,8 @@ export function makeTable(options) {
|
|
|
2397
2467
|
for (let i = 0; i < select.length; i++) {
|
|
2398
2468
|
const column = select[i];
|
|
2399
2469
|
let columnSort;
|
|
2400
|
-
if (column.name === sort.attribute[0]) {
|
|
2401
|
-
columnSort = column.sort || (column.sort = {});
|
|
2470
|
+
if ((column as any).name === sort.attribute[0]) {
|
|
2471
|
+
columnSort = (column as any).sort || ((column as any).sort = {});
|
|
2402
2472
|
while (columnSort.next) columnSort = columnSort.next;
|
|
2403
2473
|
columnSort.attribute = sort.attribute.slice(1);
|
|
2404
2474
|
columnSort.descending = sort.descending;
|
|
@@ -2409,7 +2479,7 @@ export function makeTable(options) {
|
|
|
2409
2479
|
attribute: sort.attribute.slice(1),
|
|
2410
2480
|
descending: sort.descending,
|
|
2411
2481
|
},
|
|
2412
|
-
};
|
|
2482
|
+
} as any;
|
|
2413
2483
|
}
|
|
2414
2484
|
}
|
|
2415
2485
|
}
|
|
@@ -2492,7 +2562,7 @@ export function makeTable(options) {
|
|
|
2492
2562
|
this?.isSync,
|
|
2493
2563
|
(entry: Entry) => entry
|
|
2494
2564
|
);
|
|
2495
|
-
if (entry?.then) return entry.then(transform.bind(this));
|
|
2565
|
+
if ((entry as any)?.then) return (entry as any).then(transform.bind(this));
|
|
2496
2566
|
record = entry?.value;
|
|
2497
2567
|
}
|
|
2498
2568
|
if (
|
|
@@ -2602,12 +2672,22 @@ export function makeTable(options) {
|
|
|
2602
2672
|
} else {
|
|
2603
2673
|
value = record[attribute_name];
|
|
2604
2674
|
if (value && typeof value === 'object' && attribute_name !== attribute) {
|
|
2605
|
-
|
|
2675
|
+
const subTransform = TableResource.transformEntryForSelect(
|
|
2606
2676
|
attribute.select || attribute,
|
|
2607
2677
|
context,
|
|
2608
2678
|
readTxn,
|
|
2609
2679
|
null
|
|
2610
|
-
)
|
|
2680
|
+
);
|
|
2681
|
+
// Plain JSON nested values: arrays project per-element so that
|
|
2682
|
+
// `select: [{ name: 'addresses', select: ['city'] }]` returns
|
|
2683
|
+
// `addresses: [{ city }, { city }]` rather than a single object.
|
|
2684
|
+
if (Array.isArray(value)) {
|
|
2685
|
+
value = value.map((item) =>
|
|
2686
|
+
item && typeof item === 'object' ? subTransform({ value: item } as any) : item
|
|
2687
|
+
);
|
|
2688
|
+
} else if (!(value instanceof Date)) {
|
|
2689
|
+
value = subTransform({ value } as any);
|
|
2690
|
+
}
|
|
2611
2691
|
}
|
|
2612
2692
|
}
|
|
2613
2693
|
callback(value, attribute_name);
|
|
@@ -2618,7 +2698,7 @@ export function makeTable(options) {
|
|
|
2618
2698
|
selected = value;
|
|
2619
2699
|
});
|
|
2620
2700
|
} else if (Array.isArray(select)) {
|
|
2621
|
-
if (select.asArray) {
|
|
2701
|
+
if ((select as any).asArray) {
|
|
2622
2702
|
selected = [];
|
|
2623
2703
|
select.forEach((attribute, index) => {
|
|
2624
2704
|
if (attribute === '*') select[index] = record;
|
|
@@ -2626,7 +2706,7 @@ export function makeTable(options) {
|
|
|
2626
2706
|
});
|
|
2627
2707
|
} else {
|
|
2628
2708
|
selected = {};
|
|
2629
|
-
const forceNulls = select.forceNulls;
|
|
2709
|
+
const forceNulls = (select as any).forceNulls;
|
|
2630
2710
|
for (const attribute of select) {
|
|
2631
2711
|
if (attribute === '*')
|
|
2632
2712
|
for (const key in record) {
|
|
@@ -2650,12 +2730,13 @@ export function makeTable(options) {
|
|
|
2650
2730
|
return transform;
|
|
2651
2731
|
}
|
|
2652
2732
|
|
|
2733
|
+
// #section: pub-sub
|
|
2653
2734
|
async subscribe(request: SubscriptionRequest): Promise<AsyncIterable<Record>> {
|
|
2654
2735
|
if (!auditStore) throw new Error('Can not subscribe to a table without an audit log');
|
|
2655
2736
|
if (!audit) {
|
|
2656
2737
|
table({ table: tableName, database: databaseName, schemaDefined, attributes, audit: true });
|
|
2657
2738
|
}
|
|
2658
|
-
if (!request) request = {};
|
|
2739
|
+
if (!request) request = {} as any;
|
|
2659
2740
|
const getFullRecord = !request.rawEvents;
|
|
2660
2741
|
// While the count, !omitCurrent, and non-collection branches replay older messages, real-time
|
|
2661
2742
|
// messages from the listener accumulate here and are drained at the end of the IIFE so they
|
|
@@ -2670,7 +2751,7 @@ export function makeTable(options) {
|
|
|
2670
2751
|
const subscription = addSubscription(
|
|
2671
2752
|
TableResource,
|
|
2672
2753
|
thisId,
|
|
2673
|
-
function (id: Id, auditRecord
|
|
2754
|
+
function (id: Id, auditRecord?: any, localTime?: any, beginTxn?: any) {
|
|
2674
2755
|
if (dropDuringReplay) return;
|
|
2675
2756
|
try {
|
|
2676
2757
|
let type = auditRecord.type;
|
|
@@ -2969,13 +3050,13 @@ export function makeTable(options) {
|
|
|
2969
3050
|
} else {
|
|
2970
3051
|
let allowed = true;
|
|
2971
3052
|
const context = this.getContext();
|
|
2972
|
-
if (target
|
|
3053
|
+
if ((target as any)?.checkPermission) {
|
|
2973
3054
|
// requesting authorization verification
|
|
2974
|
-
allowed = this.
|
|
3055
|
+
allowed = this.allowDelete((context as any).user, target as any, context);
|
|
2975
3056
|
}
|
|
2976
3057
|
return when(allowed, (allowed: boolean) => {
|
|
2977
3058
|
if (!allowed) {
|
|
2978
|
-
throw new AccessViolation(context.user);
|
|
3059
|
+
throw new AccessViolation((context as any).user);
|
|
2979
3060
|
}
|
|
2980
3061
|
const id = requestTargetToId(target);
|
|
2981
3062
|
this._writePublish(id, message, options);
|
|
@@ -2991,16 +3072,16 @@ export function makeTable(options) {
|
|
|
2991
3072
|
key: id,
|
|
2992
3073
|
store: primaryStore,
|
|
2993
3074
|
entry: this.#entry,
|
|
2994
|
-
nodeName: context?.nodeName,
|
|
3075
|
+
nodeName: (context as any)?.nodeName,
|
|
2995
3076
|
validate: () => {
|
|
2996
|
-
if (!context?.source) {
|
|
3077
|
+
if (!(context as any)?.source) {
|
|
2997
3078
|
transaction.checkOverloaded();
|
|
2998
3079
|
this.validate(message);
|
|
2999
3080
|
}
|
|
3000
3081
|
},
|
|
3001
3082
|
before:
|
|
3002
|
-
this.constructor.source?.publish && !context?.source
|
|
3003
|
-
? this.constructor.source.publish.bind(this.constructor.source, id, message, context)
|
|
3083
|
+
(this.constructor as any).source?.publish && !(context as any)?.source
|
|
3084
|
+
? (this.constructor as any).source.publish.bind((this.constructor as any).source, id, message, context)
|
|
3004
3085
|
: undefined,
|
|
3005
3086
|
commit: (txnTime, existingEntry, _retry, transaction: any) => {
|
|
3006
3087
|
// just need to update the version number of the record so it points to the latest audit record
|
|
@@ -3021,7 +3102,7 @@ export function makeTable(options) {
|
|
|
3021
3102
|
0,
|
|
3022
3103
|
true,
|
|
3023
3104
|
{
|
|
3024
|
-
user: context?.user,
|
|
3105
|
+
user: (context as any)?.user,
|
|
3025
3106
|
residencyId: options?.residencyId,
|
|
3026
3107
|
expiresAt: context?.expiresAt,
|
|
3027
3108
|
nodeId: options?.nodeId,
|
|
@@ -3039,6 +3120,7 @@ export function makeTable(options) {
|
|
|
3039
3120
|
write.beforeIntermediate = preCommitBlobsForRecordBefore(write, message, undefined, true);
|
|
3040
3121
|
transaction.addWrite(write);
|
|
3041
3122
|
}
|
|
3123
|
+
// #section: validation
|
|
3042
3124
|
validate(record: any, patch?: boolean) {
|
|
3043
3125
|
let validationErrors;
|
|
3044
3126
|
const validateValue = (value, attribute: Attribute, name) => {
|
|
@@ -3208,6 +3290,7 @@ export function makeTable(options) {
|
|
|
3208
3290
|
throw new ClientError(validationErrors.join('. '));
|
|
3209
3291
|
}
|
|
3210
3292
|
}
|
|
3293
|
+
// #section: stats-admin
|
|
3211
3294
|
getUpdatedTime() {
|
|
3212
3295
|
return this.#version;
|
|
3213
3296
|
}
|
|
@@ -3226,7 +3309,7 @@ export function makeTable(options) {
|
|
|
3226
3309
|
schemaDefined,
|
|
3227
3310
|
attributes: new_attributes,
|
|
3228
3311
|
});
|
|
3229
|
-
return TableResource.indexingOperation;
|
|
3312
|
+
return (TableResource as any).indexingOperation;
|
|
3230
3313
|
}
|
|
3231
3314
|
static async removeAttributes(names: string[]) {
|
|
3232
3315
|
const new_attributes = attributes.filter((attribute) => !names.includes(attribute.name));
|
|
@@ -3236,7 +3319,7 @@ export function makeTable(options) {
|
|
|
3236
3319
|
schemaDefined,
|
|
3237
3320
|
attributes: new_attributes,
|
|
3238
3321
|
});
|
|
3239
|
-
return TableResource.indexingOperation;
|
|
3322
|
+
return (TableResource as any).indexingOperation;
|
|
3240
3323
|
}
|
|
3241
3324
|
/**
|
|
3242
3325
|
* Get the size of the table in bytes (based on amount of pages stored in the database)
|
|
@@ -3329,6 +3412,14 @@ export function makeTable(options) {
|
|
|
3329
3412
|
* When attributes have been changed, we update the accessors that are assigned to this table
|
|
3330
3413
|
*/
|
|
3331
3414
|
static updatedAttributes() {
|
|
3415
|
+
// Refresh on every call: schema reload mutates `attributes` in place, so the
|
|
3416
|
+
// class-construction snapshot would otherwise go stale.
|
|
3417
|
+
this.embedAttributes = (this.attributes as any[]).filter((a) => a?.embed);
|
|
3418
|
+
// Drop registry entries for attributes that are no longer `@embed`, so a dropped
|
|
3419
|
+
// directive doesn't leave a stale embedder or block a default refresh on re-add.
|
|
3420
|
+
const embedNames = new Set(this.embedAttributes.map((a) => a.name));
|
|
3421
|
+
for (const name of Object.keys(this.userEmbedders)) if (!embedNames.has(name)) delete this.userEmbedders[name];
|
|
3422
|
+
for (const name of this.userSetEmbedders) if (!embedNames.has(name)) this.userSetEmbedders.delete(name);
|
|
3332
3423
|
propertyResolvers = this.propertyResolvers = {
|
|
3333
3424
|
$id: (object, context, entry) => ({ value: entry.key }),
|
|
3334
3425
|
$updatedtime: (object, context, entry) => entry.version,
|
|
@@ -3344,6 +3435,11 @@ export function makeTable(options) {
|
|
|
3344
3435
|
attribute.resolve = null; // reset this
|
|
3345
3436
|
const relationship = attribute.relationship;
|
|
3346
3437
|
const computed = attribute.computed;
|
|
3438
|
+
// Register the default embedder unless an author override is set. Sits outside
|
|
3439
|
+
// the resolver chain below so `@embed` fields still flow through auto-HNSW indexing.
|
|
3440
|
+
if (attribute.embed && !TableResource.userSetEmbedders.has(attribute.name)) {
|
|
3441
|
+
this.userEmbedders[attribute.name] = createDefaultEmbedder(attribute.embed);
|
|
3442
|
+
}
|
|
3347
3443
|
if (relationship) {
|
|
3348
3444
|
if (attribute.indexed) {
|
|
3349
3445
|
console.error(
|
|
@@ -3363,12 +3459,14 @@ export function makeTable(options) {
|
|
|
3363
3459
|
const id = object[relationship.from ? relationship.from : primaryKey];
|
|
3364
3460
|
const relatedTable = attribute.elements.definition.tableClass;
|
|
3365
3461
|
if (returnEntry) {
|
|
3366
|
-
return
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3462
|
+
return (
|
|
3463
|
+
searchByIndex(
|
|
3464
|
+
{ attribute: relationship.to, value: id },
|
|
3465
|
+
txnForContext(context).getReadTxn(),
|
|
3466
|
+
false,
|
|
3467
|
+
relatedTable,
|
|
3468
|
+
false
|
|
3469
|
+
) as any
|
|
3372
3470
|
).map((entry) => {
|
|
3373
3471
|
if (entry && entry.key !== undefined) return entry;
|
|
3374
3472
|
return relatedTable.primaryStore.getEntry(entry, {
|
|
@@ -3449,6 +3547,15 @@ export function makeTable(options) {
|
|
|
3449
3547
|
} else if (computed) {
|
|
3450
3548
|
if (typeof computed.from === 'function') {
|
|
3451
3549
|
this.setComputedAttribute(attribute.name, computed.from);
|
|
3550
|
+
} else if (attribute.computedFromExpression) {
|
|
3551
|
+
// build a fallback scope object with all attribute names set to undefined,
|
|
3552
|
+
// matching the behavior in graphql.ts to prevent ReferenceErrors
|
|
3553
|
+
const attributesFallback: { [key: string]: undefined } = {};
|
|
3554
|
+
for (const attr of this.attributes) attributesFallback[attr.name] = undefined;
|
|
3555
|
+
this.setComputedAttribute(
|
|
3556
|
+
attribute.name,
|
|
3557
|
+
createComputedFrom(attribute.computedFromExpression, attributesFallback)
|
|
3558
|
+
);
|
|
3452
3559
|
}
|
|
3453
3560
|
propertyResolvers[attribute.name] = attribute.resolve = (object, context, entry) => {
|
|
3454
3561
|
const value = typeof computed.from === 'string' ? object[computed.from] : object;
|
|
@@ -3503,6 +3610,7 @@ export function makeTable(options) {
|
|
|
3503
3610
|
}
|
|
3504
3611
|
}
|
|
3505
3612
|
}
|
|
3613
|
+
// #section: computed-history
|
|
3506
3614
|
static setComputedAttribute(attribute_name, resolver) {
|
|
3507
3615
|
const attribute = findAttribute(attributes, attribute_name);
|
|
3508
3616
|
if (!attribute) {
|
|
@@ -3515,6 +3623,25 @@ export function makeTable(options) {
|
|
|
3515
3623
|
}
|
|
3516
3624
|
this.userResolvers[attribute_name] = resolver;
|
|
3517
3625
|
}
|
|
3626
|
+
/**
|
|
3627
|
+
* Override the default embedder for an `@embed` attribute. Return the vector to
|
|
3628
|
+
* store at `attribute_name`. The embedder receives the write payload (the fields
|
|
3629
|
+
* present in the PUT/PATCH body), not the post-merge record, so multi-field
|
|
3630
|
+
* concatenation only works when all source fields are in the same write.
|
|
3631
|
+
*/
|
|
3632
|
+
static setEmbedAttribute(attribute_name: string, embedder: Embedder): void {
|
|
3633
|
+
const attribute = findAttribute(attributes, attribute_name);
|
|
3634
|
+
if (!attribute) {
|
|
3635
|
+
console.error(`The attribute "${attribute_name}" does not exist in the table "${tableName}"`);
|
|
3636
|
+
return;
|
|
3637
|
+
}
|
|
3638
|
+
if (!attribute.embed) {
|
|
3639
|
+
console.error(`The attribute "${attribute_name}" is not declared with @embed in the table "${tableName}"`);
|
|
3640
|
+
return;
|
|
3641
|
+
}
|
|
3642
|
+
this.userEmbedders[attribute_name] = embedder;
|
|
3643
|
+
this.userSetEmbedders.add(attribute_name);
|
|
3644
|
+
}
|
|
3518
3645
|
static async deleteHistory(endTime = 0, cleanupDeletedRecords = false) {
|
|
3519
3646
|
let completion: Promise<void>;
|
|
3520
3647
|
for (const auditRecord of auditStore.getRange({
|
|
@@ -3688,34 +3815,35 @@ export function makeTable(options) {
|
|
|
3688
3815
|
function checkValidId(id) {
|
|
3689
3816
|
switch (typeof id) {
|
|
3690
3817
|
case 'number':
|
|
3818
|
+
if (isNaN(id)) throw new ClientError('Invalid primary key of NaN', 400);
|
|
3691
3819
|
return true;
|
|
3692
3820
|
case 'string':
|
|
3693
3821
|
if (id.length < 659) return true; // max number of characters that can't expand our key size limit
|
|
3694
3822
|
if (id.length > MAX_KEY_BYTES) {
|
|
3695
3823
|
// we can quickly determine this is too big
|
|
3696
|
-
throw new
|
|
3824
|
+
throw new ClientError('Primary key size is too large: ' + id.length, 400);
|
|
3697
3825
|
}
|
|
3698
3826
|
// TODO: We could potentially have a faster test here, Buffer.byteLength is close, but we have to handle characters < 4 that are escaped in ordered-binary
|
|
3699
3827
|
break; // otherwise we have to test it, in this range, unicode characters could put it over the limit
|
|
3700
3828
|
case 'object':
|
|
3701
3829
|
if (id === null) {
|
|
3702
|
-
throw new
|
|
3830
|
+
throw new ClientError('Invalid primary key of null', 400);
|
|
3703
3831
|
}
|
|
3704
3832
|
break; // otherwise we have to test it
|
|
3705
3833
|
case 'bigint':
|
|
3706
3834
|
if (id < 2n ** 64n && id > -(2n ** 64n)) return true;
|
|
3707
3835
|
break; // otherwise we have to test it
|
|
3708
3836
|
default:
|
|
3709
|
-
throw new
|
|
3837
|
+
throw new ClientError('Invalid primary key type: ' + typeof id, 400);
|
|
3710
3838
|
}
|
|
3711
3839
|
// otherwise it is difficult to determine if the key size is too large
|
|
3712
3840
|
// without actually attempting to serialize it
|
|
3713
3841
|
const length = writeKey(id, TEST_WRITE_KEY_BUFFER, 0);
|
|
3714
|
-
if (length > MAX_KEY_BYTES) throw new
|
|
3842
|
+
if (length > MAX_KEY_BYTES) throw new ClientError('Primary key size is too large: ' + id.length, 400);
|
|
3715
3843
|
return true;
|
|
3716
3844
|
}
|
|
3717
3845
|
function requestTargetToId(target: RequestTargetOrId): Id {
|
|
3718
|
-
return typeof target === 'object' && target ? target.id : (target as Id);
|
|
3846
|
+
return typeof target === 'object' && target ? (target as any).id : (target as Id);
|
|
3719
3847
|
}
|
|
3720
3848
|
function isSearchTarget(target: RequestTargetOrId): target is RequestTarget {
|
|
3721
3849
|
return typeof target === 'object' && target && (target as RequestTarget).isCollection;
|
|
@@ -3874,6 +4002,10 @@ export function makeTable(options) {
|
|
|
3874
4002
|
}
|
|
3875
4003
|
|
|
3876
4004
|
function ensureLoadedFromSource(source: typeof TableResource, id, entry, context, resource?, target?) {
|
|
4005
|
+
if (context?.onlyIfCached) {
|
|
4006
|
+
if (!entry?.value) throw new ServerError('Entry is not cached', 504);
|
|
4007
|
+
return;
|
|
4008
|
+
}
|
|
3877
4009
|
if (hasSourceGet) {
|
|
3878
4010
|
let needsSourceData = false;
|
|
3879
4011
|
if (context.noCache) needsSourceData = true;
|
|
@@ -3902,10 +4034,9 @@ export function makeTable(options) {
|
|
|
3902
4034
|
return entry;
|
|
3903
4035
|
});
|
|
3904
4036
|
// if the resource defines a method for indicating if stale-while-revalidate is allowed for a record
|
|
3905
|
-
if (
|
|
4037
|
+
if (entry?.value && resource?.allowStaleWhileRevalidate?.(entry, id)) {
|
|
3906
4038
|
// since we aren't waiting for it any errors won't propagate so we should at least log them
|
|
3907
4039
|
loadingFromSource.catch((error) => logger.warn?.(error));
|
|
3908
|
-
if (context?.onlyIfCached && !resource.doesExist()) throw new ServerError('Entry is not cached', 504);
|
|
3909
4040
|
return; // go ahead and return and let the current stale value be used while we re-validate
|
|
3910
4041
|
} else return loadingFromSource; // return the promise for the resolved value
|
|
3911
4042
|
}
|
|
@@ -3928,7 +4059,7 @@ export function makeTable(options) {
|
|
|
3928
4059
|
if (transaction) {
|
|
3929
4060
|
if (!transaction.db && isRocksDB) {
|
|
3930
4061
|
// this is an uninitialized DatabaseTransaction, we can claim it
|
|
3931
|
-
transaction.db = primaryStore;
|
|
4062
|
+
transaction.db = primaryStore as any;
|
|
3932
4063
|
if (context?.timestamp) transaction.timestamp = context.timestamp;
|
|
3933
4064
|
return transaction;
|
|
3934
4065
|
}
|
|
@@ -3951,7 +4082,9 @@ export function makeTable(options) {
|
|
|
3951
4082
|
transaction = nextTxn;
|
|
3952
4083
|
} while (true);
|
|
3953
4084
|
} else {
|
|
3954
|
-
transaction =
|
|
4085
|
+
transaction = (
|
|
4086
|
+
isRocksDB ? new ImmediateTransaction(primaryStore as any) : new ImmediateLMDBTransaction(primaryStore as any)
|
|
4087
|
+
) as any;
|
|
3955
4088
|
if (context) {
|
|
3956
4089
|
context.transaction = transaction;
|
|
3957
4090
|
if (context.timestamp) transaction.timestamp = context.timestamp;
|
|
@@ -4030,7 +4163,7 @@ export function makeTable(options) {
|
|
|
4030
4163
|
return ids;
|
|
4031
4164
|
}
|
|
4032
4165
|
|
|
4033
|
-
function precedesExistingVersion(txnTime: number, existingEntry: Entry
|
|
4166
|
+
function precedesExistingVersion(txnTime: number, existingEntry: Partial<Entry>, nodeId?: number): number {
|
|
4034
4167
|
if (nodeId === undefined) {
|
|
4035
4168
|
nodeId = getThisNodeId(auditStore);
|
|
4036
4169
|
}
|
|
@@ -4132,7 +4265,7 @@ export function makeTable(options) {
|
|
|
4132
4265
|
expiresAt: undefined,
|
|
4133
4266
|
lastModified: undefined,
|
|
4134
4267
|
};
|
|
4135
|
-
const responseHeaders = context?.responseHeaders;
|
|
4268
|
+
const responseHeaders = (context as any)?.responseHeaders;
|
|
4136
4269
|
return new Promise((resolve, reject) => {
|
|
4137
4270
|
// we don't want to wait for the transaction because we want to return as fast as possible
|
|
4138
4271
|
// and let the transaction commit in the background
|
|
@@ -4157,15 +4290,14 @@ export function makeTable(options) {
|
|
|
4157
4290
|
if (typeof updatedRecord !== 'object') throw new Error('Only objects can be cached and stored in tables');
|
|
4158
4291
|
if (updatedRecord.status > 0 && updatedRecord.headers) {
|
|
4159
4292
|
// if the source has a status code and headers, treat it as a response
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
} // there are definitely more status codes to handle
|
|
4293
|
+
const status = updatedRecord.status;
|
|
4294
|
+
if (status === 304) {
|
|
4295
|
+
// revalidation of our current cached record
|
|
4296
|
+
updatedRecord = existingRecord;
|
|
4297
|
+
version = existingVersion;
|
|
4298
|
+
} else if (!CACHEABLE_STATUS_CODES.has(status)) {
|
|
4299
|
+
// non-cacheable status - propagate to client without caching
|
|
4300
|
+
throw new ServerError(updatedRecord.body || 'Error from source', status);
|
|
4169
4301
|
} else {
|
|
4170
4302
|
let headers: any;
|
|
4171
4303
|
const sourceHeaders = updatedRecord.headers;
|
|
@@ -4193,27 +4325,37 @@ export function makeTable(options) {
|
|
|
4193
4325
|
if (data !== undefined) {
|
|
4194
4326
|
// we have structured data that we have parsed
|
|
4195
4327
|
delete headers['content-type']; // don't store the content type if we have already parsed it
|
|
4196
|
-
updatedRecord = {
|
|
4197
|
-
headers,
|
|
4198
|
-
data,
|
|
4199
|
-
};
|
|
4328
|
+
updatedRecord = { headers, data };
|
|
4200
4329
|
} else {
|
|
4201
|
-
updatedRecord = {
|
|
4202
|
-
headers,
|
|
4203
|
-
body: createBlob(updatedRecord.body),
|
|
4204
|
-
};
|
|
4330
|
+
updatedRecord = { headers, body: createBlob(updatedRecord.body) };
|
|
4205
4331
|
}
|
|
4332
|
+
if (status !== 200) updatedRecord.status = status;
|
|
4206
4333
|
}
|
|
4207
4334
|
}
|
|
4208
4335
|
if (typeof updatedRecord.toJSON === 'function') updatedRecord = updatedRecord.toJSON();
|
|
4209
4336
|
if (primaryKey && updatedRecord[primaryKey] !== id) updatedRecord[primaryKey] = id;
|
|
4210
4337
|
}
|
|
4211
4338
|
resolved = true;
|
|
4212
|
-
|
|
4339
|
+
const resolvedEntry: Entry = {
|
|
4213
4340
|
key: id,
|
|
4214
4341
|
version,
|
|
4215
4342
|
value: updatedRecord,
|
|
4216
|
-
|
|
4343
|
+
expiresAt: sourceContext.expiresAt,
|
|
4344
|
+
metadataFlags: 0,
|
|
4345
|
+
size: 0,
|
|
4346
|
+
localTime: 0,
|
|
4347
|
+
nodeId: 0,
|
|
4348
|
+
residencyId: 0,
|
|
4349
|
+
} as any;
|
|
4350
|
+
// Give the plain object the RecordObject prototype so getExpiresAt/getUpdatedTime
|
|
4351
|
+
// are available on the immediately-resolved entry. We mutate the prototype
|
|
4352
|
+
// in-place rather than copying so that the commit callback (which adds
|
|
4353
|
+
// createdAt/updatedAt to updatedRecord) is still reflected in the entry value.
|
|
4354
|
+
if (updatedRecord && updatedRecord.constructor === Object) {
|
|
4355
|
+
Object.setPrototypeOf(updatedRecord, primaryStore.encoder.structPrototype);
|
|
4356
|
+
entryMap.set(updatedRecord, resolvedEntry);
|
|
4357
|
+
}
|
|
4358
|
+
resolve(resolvedEntry);
|
|
4217
4359
|
} catch (error) {
|
|
4218
4360
|
error.message += ` while resolving record ${id} for ${tableName}`;
|
|
4219
4361
|
if (
|
|
@@ -4231,7 +4373,7 @@ export function makeTable(options) {
|
|
|
4231
4373
|
key: id,
|
|
4232
4374
|
version: existingVersion,
|
|
4233
4375
|
value: existingRecord,
|
|
4234
|
-
});
|
|
4376
|
+
} as any);
|
|
4235
4377
|
logger.trace?.(error.message, '(returned stale record)');
|
|
4236
4378
|
} else reject(error);
|
|
4237
4379
|
const resolveDuration = performance.now() - start;
|
|
@@ -4328,7 +4470,7 @@ export function makeTable(options) {
|
|
|
4328
4470
|
omitLocalRecord ? INVALIDATED : 0,
|
|
4329
4471
|
(audit && (hasChanges || omitLocalRecord)) || null,
|
|
4330
4472
|
{
|
|
4331
|
-
user: sourceContext?.user,
|
|
4473
|
+
user: (sourceContext as any)?.user,
|
|
4332
4474
|
expiresAt: sourceContext.expiresAt,
|
|
4333
4475
|
residencyId,
|
|
4334
4476
|
transaction,
|
|
@@ -4352,7 +4494,7 @@ export function makeTable(options) {
|
|
|
4352
4494
|
txnTime,
|
|
4353
4495
|
0,
|
|
4354
4496
|
(audit && hasChanges) || null,
|
|
4355
|
-
{ user: sourceContext?.user, transaction, tableToTrack: tableName },
|
|
4497
|
+
{ user: (sourceContext as any)?.user, transaction, tableToTrack: tableName },
|
|
4356
4498
|
'delete',
|
|
4357
4499
|
Boolean(invalidated)
|
|
4358
4500
|
);
|
|
@@ -4362,6 +4504,19 @@ export function makeTable(options) {
|
|
|
4362
4504
|
}
|
|
4363
4505
|
},
|
|
4364
4506
|
};
|
|
4507
|
+
// The cache-from-source write bypasses `_writeUpdate`, so wire the embed hook here
|
|
4508
|
+
// too (always the originating node). It runs after the client GET has resolved with
|
|
4509
|
+
// fresh source data, so it's a background commit: an embedder failure aborts the cache
|
|
4510
|
+
// write via the outer error handler (row re-embeds next read) and never reaches the
|
|
4511
|
+
// caller. Source-resolution errors are handled earlier, with the stale-data fallback.
|
|
4512
|
+
const embedBefore = buildEmbedBefore(
|
|
4513
|
+
updatedRecord,
|
|
4514
|
+
sourceContext,
|
|
4515
|
+
undefined,
|
|
4516
|
+
TableResource.embedAttributes,
|
|
4517
|
+
TableResource.userEmbedders
|
|
4518
|
+
);
|
|
4519
|
+
if (embedBefore) await embedBefore();
|
|
4365
4520
|
sourceWrite.before = preCommitBlobsForRecordBefore(sourceWrite, updatedRecord);
|
|
4366
4521
|
dbTxn.addWrite(sourceWrite);
|
|
4367
4522
|
}),
|
|
@@ -4554,8 +4709,10 @@ export function makeTable(options) {
|
|
|
4554
4709
|
if (shardOrResidencyList >= 65536) throw new Error(`Shard id ${shardOrResidencyList} must be below 65536`);
|
|
4555
4710
|
const residencyList = server.shards?.get?.(shardOrResidencyList);
|
|
4556
4711
|
if (residencyList) {
|
|
4557
|
-
logger.trace?.(
|
|
4558
|
-
|
|
4712
|
+
logger.trace?.(
|
|
4713
|
+
`Shard ${shardOrResidencyList} mapped to ${residencyList.map((node) => (node as any).name).join(', ')}`
|
|
4714
|
+
);
|
|
4715
|
+
return residencyList.map((node) => (node as any).name);
|
|
4559
4716
|
}
|
|
4560
4717
|
throw new Error(`Shard ${shardOrResidencyList} is not defined`);
|
|
4561
4718
|
}
|
|
@@ -4579,9 +4736,9 @@ export function makeTable(options) {
|
|
|
4579
4736
|
function preCommitBlobsForRecordBefore(
|
|
4580
4737
|
write: any,
|
|
4581
4738
|
record: any,
|
|
4582
|
-
before?: () => Promise<void
|
|
4739
|
+
before?: () => Promise<void> | void,
|
|
4583
4740
|
saveInRecord?: boolean
|
|
4584
|
-
):
|
|
4741
|
+
): any {
|
|
4585
4742
|
const preCommit = startPreCommitBlobsForRecord(record, primaryStore.rootStore, saveInRecord);
|
|
4586
4743
|
if (preCommit) {
|
|
4587
4744
|
// track the blobs on the write so abort/skip paths can clean up the files if the commit doesn't reference them
|
|
@@ -4590,14 +4747,15 @@ export function makeTable(options) {
|
|
|
4590
4747
|
// them to finish and we return a new callback for the before phase of the commit
|
|
4591
4748
|
const callSources = before;
|
|
4592
4749
|
return callSources
|
|
4593
|
-
? async () => {
|
|
4750
|
+
? async (): Promise<any> => {
|
|
4594
4751
|
// if we are calling the sources first and waiting for blobs, do those in order
|
|
4595
|
-
|
|
4752
|
+
const result = callSources();
|
|
4753
|
+
if (result && (result as any).then) await result;
|
|
4596
4754
|
await preCommit.complete();
|
|
4597
4755
|
}
|
|
4598
4756
|
: () => preCommit.complete();
|
|
4599
4757
|
}
|
|
4600
|
-
return before;
|
|
4758
|
+
return before as any;
|
|
4601
4759
|
}
|
|
4602
4760
|
}
|
|
4603
4761
|
|
|
@@ -4615,6 +4773,20 @@ function noop() {
|
|
|
4615
4773
|
// prefetch callback
|
|
4616
4774
|
}
|
|
4617
4775
|
|
|
4776
|
+
/**
|
|
4777
|
+
* Recreate a computed "from" function from a stored expression string. This is used when a table
|
|
4778
|
+
* is loaded from metadata on a thread that hasn't loaded the GraphQL schema, so the computed
|
|
4779
|
+
* function needs to be reconstructed from the persisted expression.
|
|
4780
|
+
*/
|
|
4781
|
+
function createComputedFrom(computedFromExpression: string, attributesFallback?: any) {
|
|
4782
|
+
const script = new Script(
|
|
4783
|
+
attributesFallback
|
|
4784
|
+
? `function computed(attributes) { return function(record) { with(attributes) { with (record) { return ${computedFromExpression}; } } } } computed;`
|
|
4785
|
+
: `function computed() { return function(record) { with (record) { return ${computedFromExpression}; } } } computed;`
|
|
4786
|
+
);
|
|
4787
|
+
return script.runInThisContext()(attributesFallback);
|
|
4788
|
+
}
|
|
4789
|
+
|
|
4618
4790
|
const ENDS_WITH_TIMEZONE = /[+-][0-9]{2}:[0-9]{2}|[a-zA-Z]$/;
|
|
4619
4791
|
/**
|
|
4620
4792
|
* Coerce a string to the type defined by the attribute
|