@harperfast/harper 5.0.30 → 5.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +134 -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 +17 -24
- 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 +132 -18
- package/components/anthropic/index.ts +547 -0
- package/components/bedrock/index.ts +823 -0
- package/components/componentLoader.ts +64 -32
- package/components/deployLifecycle.ts +161 -0
- package/components/deploymentOperations.ts +173 -0
- package/components/deploymentRecorder.ts +427 -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 +607 -0
- package/components/mcp/session.ts +151 -0
- package/components/mcp/sessionRegistry.ts +140 -0
- package/components/mcp/toolRegistry.ts +294 -0
- package/components/mcp/tools/application.ts +761 -0
- package/components/mcp/tools/operations.ts +311 -0
- package/components/mcp/tools/schemas/derive.ts +356 -0
- package/components/mcp/tools/schemas/operationDescriptions.ts +241 -0
- package/components/mcp/tools/schemas/operations.ts +301 -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 +217 -60
- package/components/operationsValidation.js +12 -4
- 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 +78 -4
- 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 +123 -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 +14 -22
- package/dist/bin/upgrade.js.map +1 -1
- 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 +112 -12
- 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 +65 -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 +97 -0
- package/dist/components/deploymentRecorder.js +425 -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 +526 -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 +151 -0
- package/dist/components/mcp/toolRegistry.js +177 -0
- package/dist/components/mcp/toolRegistry.js.map +1 -0
- package/dist/components/mcp/tools/application.d.ts +72 -0
- package/dist/components/mcp/tools/application.js +660 -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 +331 -0
- package/dist/components/mcp/tools/operations.js.map +1 -0
- package/dist/components/mcp/tools/schemas/derive.d.ts +50 -0
- package/dist/components/mcp/tools/schemas/derive.js +291 -0
- package/dist/components/mcp/tools/schemas/derive.js.map +1 -0
- package/dist/components/mcp/tools/schemas/operationDescriptions.d.ts +32 -0
- package/dist/components/mcp/tools/schemas/operationDescriptions.js +179 -0
- package/dist/components/mcp/tools/schemas/operationDescriptions.js.map +1 -0
- package/dist/components/mcp/tools/schemas/operations.d.ts +27 -0
- package/dist/components/mcp/tools/schemas/operations.js +299 -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 +205 -52
- package/dist/components/operations.js.map +1 -1
- package/dist/components/operationsValidation.d.ts +2 -2
- package/dist/components/operationsValidation.js +13 -4
- package/dist/components/operationsValidation.js.map +1 -1
- 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 +10 -12
- package/dist/resources/RecordEncoder.js +38 -38
- 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 +25 -5
- package/dist/resources/Resource.js +43 -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 +10 -3
- package/dist/resources/RocksTransactionLogStore.js.map +1 -1
- package/dist/resources/Table.d.ts +76 -329
- package/dist/resources/Table.js +306 -116
- 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 +8 -1
- package/dist/resources/analytics/read.js +69 -8
- 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 +16 -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 +17 -0
- package/dist/resources/databases.js +175 -59
- package/dist/resources/databases.js.map +1 -1
- package/dist/resources/graphql.d.ts +1 -7
- package/dist/resources/graphql.js +267 -173
- package/dist/resources/graphql.js.map +1 -1
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.d.ts +17 -1
- package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js +327 -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/jsonSchemaTypes.d.ts +60 -0
- package/dist/resources/jsonSchemaTypes.js +78 -0
- package/dist/resources/jsonSchemaTypes.js.map +1 -0
- 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/openApi.js +74 -34
- package/dist/resources/openApi.js.map +1 -1
- package/dist/resources/replayLogs.js +7 -1
- package/dist/resources/replayLogs.js.map +1 -1
- package/dist/resources/replayLogsGuards.d.ts +9 -0
- package/dist/resources/replayLogsGuards.js +47 -0
- package/dist/resources/replayLogsGuards.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 +23 -15
- 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 +46 -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-1-0.d.ts +6 -0
- package/dist/upgrade/directives/5-1-0.js +114 -0
- package/dist/upgrade/directives/5-1-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 +2 -8
- package/dist/upgrade/upgradePrompt.js +55 -60
- 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 +54 -1
- package/dist/utility/hdbTerms.js +54 -1
- 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 +117 -54
- 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 +12 -15
- package/dist/utility/lmdb/OpenDBIObject.js +68 -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 +177 -82
- 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 +67 -32
- 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 +80 -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 +38 -24
- 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 +41 -39
- package/resources/RequestTarget.ts +2 -0
- package/resources/Resource.ts +96 -56
- package/resources/ResourceInterface.ts +44 -21
- package/resources/Resources.ts +8 -8
- package/resources/RocksIndexStore.ts +3 -0
- package/resources/RocksTransactionLogStore.ts +13 -4
- package/resources/Table.ts +440 -223
- package/resources/analytics/metadata.ts +1 -0
- package/resources/analytics/read.ts +99 -10
- package/resources/analytics/write.ts +240 -17
- package/resources/auditStore.ts +30 -19
- package/resources/blob.ts +53 -53
- package/resources/dataLoader.ts +4 -4
- package/resources/databases.ts +208 -74
- package/resources/graphql.ts +267 -165
- package/resources/indexes/HierarchicalNavigableSmallWorld.ts +310 -65
- package/resources/indexes/vector.ts +17 -0
- package/resources/jsonSchemaTypes.ts +102 -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/openApi.ts +65 -31
- package/resources/replayLogs.ts +20 -9
- package/resources/replayLogsGuards.ts +45 -0
- package/resources/roles.ts +62 -67
- package/resources/search.ts +355 -135
- package/resources/tracked.ts +18 -9
- package/resources/transaction.ts +8 -8
- package/resources/transactionBroadcast.ts +3 -3
- package/schema.graphql +7 -0
- 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 +3 -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/static/defaultConfig.yaml +0 -1
- package/studio/web/assets/{index-CybLScHg.js → index-Dqr9oVhe.js} +5 -5
- package/studio/web/assets/index-Dqr9oVhe.js.map +1 -0
- package/studio/web/assets/{index.lazy-DKx5-iXF.js → index.lazy-CpKcKb7M.js} +2 -2
- package/studio/web/assets/{index.lazy-DKx5-iXF.js.map → index.lazy-CpKcKb7M.js.map} +1 -1
- package/studio/web/assets/{profile-BOjes0Wl.js → profile-C1cujdsg.js} +2 -2
- package/studio/web/assets/{profile-BOjes0Wl.js.map → profile-C1cujdsg.js.map} +1 -1
- package/studio/web/assets/{status-EWKUIrjT.js → status-CTiIIQlY.js} +2 -2
- package/studio/web/assets/{status-EWKUIrjT.js.map → status-CTiIIQlY.js.map} +1 -1
- package/studio/web/index.html +1 -1
- package/upgrade/{UpgradeObjects.js → UpgradeObjects.ts} +3 -6
- package/upgrade/directives/5-1-0.ts +89 -0
- package/upgrade/directives/{directivesController.js → directivesController.ts} +16 -16
- package/upgrade/{directivesManager.js → directivesManager.ts} +7 -11
- package/upgrade/{upgradePrompt.js → upgradePrompt.ts} +6 -54
- 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 +54 -1
- package/utility/install/checkJWTTokensExist.js +1 -1
- package/utility/install/{installer.js → installer.ts} +66 -42
- 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 +57 -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} +137 -90
- package/utility/logging/{logRotator.js → logRotator.ts} +15 -18
- 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 +44 -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-CybLScHg.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,11 +64,12 @@ 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';
|
|
68
71
|
import { contentTypes } from '../server/serverHelpers/contentTypes';
|
|
72
|
+
import { type JsonSchemaFragment, projectAttributesToProperties } from './jsonSchemaTypes.ts';
|
|
69
73
|
|
|
70
74
|
const { sortBy } = lodash;
|
|
71
75
|
const { validateAttribute } = lmdbProcessRows;
|
|
@@ -73,16 +77,28 @@ const { validateAttribute } = lmdbProcessRows;
|
|
|
73
77
|
export type Attribute = {
|
|
74
78
|
name: string;
|
|
75
79
|
type: 'ID' | 'Int' | 'Float' | 'Long' | 'String' | 'Boolean' | 'Date' | 'Bytes' | 'Any' | 'BigInt' | 'Blob' | string;
|
|
80
|
+
description?: string;
|
|
81
|
+
hidden?: boolean;
|
|
76
82
|
assignCreatedTime?: boolean;
|
|
77
83
|
assignUpdatedTime?: boolean;
|
|
78
84
|
nullable?: boolean;
|
|
79
85
|
expiresAt?: boolean;
|
|
80
86
|
isPrimaryKey?: boolean;
|
|
81
|
-
indexed?:
|
|
82
|
-
relationship?:
|
|
83
|
-
computed?:
|
|
87
|
+
indexed?: any;
|
|
88
|
+
relationship?: any;
|
|
89
|
+
computed?: any;
|
|
90
|
+
resolve?: any;
|
|
91
|
+
computedFromExpression?: any;
|
|
92
|
+
embed?: { source: string; model: string };
|
|
93
|
+
version?: any;
|
|
84
94
|
properties?: Array<Attribute>;
|
|
85
95
|
elements?: Attribute;
|
|
96
|
+
sealed?: boolean;
|
|
97
|
+
|
|
98
|
+
definition?: any;
|
|
99
|
+
set?: any;
|
|
100
|
+
enumerable?: boolean;
|
|
101
|
+
select?: any;
|
|
86
102
|
};
|
|
87
103
|
|
|
88
104
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -91,13 +107,14 @@ const NULL_WITH_TIMESTAMP = new Uint8Array(9);
|
|
|
91
107
|
NULL_WITH_TIMESTAMP[8] = 0xc0; // null
|
|
92
108
|
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
109
|
const RECORD_PRUNING_INTERVAL = 60000; // one minute
|
|
110
|
+
const CACHEABLE_STATUS_CODES = new Set([200, 203, 204, 206, 300, 301, 308, 404, 405, 410, 414, 501]);
|
|
94
111
|
envMngr.initSync();
|
|
95
112
|
const LMDB_PREFETCH_WRITES = envMngr.get(CONFIG_PARAMS.STORAGE_PREFETCHWRITES);
|
|
96
113
|
const LOCK_TIMEOUT = 10000;
|
|
97
|
-
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
114
|
+
// A frozen record we may need to copy-on-mutate before stamping it (records are immutable — decoded
|
|
115
|
+
// records are frozen and 5.2 record caching relies on it). Only plain/record objects qualify: never
|
|
116
|
+
// a Buffer/typed-array (spreading would corrupt the binary into a {0:.., 1:..} object) or a primitive
|
|
117
|
+
// (which reports as frozen and would spread into character/index keys).
|
|
101
118
|
function isFrozenRecordObject(value: any): boolean {
|
|
102
119
|
return (
|
|
103
120
|
value !== null &&
|
|
@@ -141,6 +158,9 @@ export interface Table {
|
|
|
141
158
|
indexingOperations?: Promise<void>;
|
|
142
159
|
source?: new () => ResourceInterface;
|
|
143
160
|
Transaction: ReturnType<typeof makeTable>;
|
|
161
|
+
description?: string;
|
|
162
|
+
properties?: Record<string, JsonSchemaFragment>;
|
|
163
|
+
hidden?: boolean;
|
|
144
164
|
}
|
|
145
165
|
type ResidencyDefinition = number | string[] | void;
|
|
146
166
|
|
|
@@ -149,6 +169,7 @@ type ResidencyDefinition = number | string[] | void;
|
|
|
149
169
|
* Instances of the returned class are Resource instances, intended to provide a consistent view or transaction of the table
|
|
150
170
|
* @param options
|
|
151
171
|
*/
|
|
172
|
+
// #section: setup-and-factory
|
|
152
173
|
export function makeTable(options) {
|
|
153
174
|
const {
|
|
154
175
|
primaryKey,
|
|
@@ -164,17 +185,23 @@ export function makeTable(options) {
|
|
|
164
185
|
sealed,
|
|
165
186
|
splitSegments,
|
|
166
187
|
replicate,
|
|
188
|
+
description,
|
|
189
|
+
hidden,
|
|
167
190
|
} = options;
|
|
168
191
|
let { expirationMS: expirationMs, evictionMS: evictionMs, audit, trackDeletes } = options;
|
|
169
192
|
evictionMs ??= 0;
|
|
170
|
-
let { attributes }: { attributes: Attribute[] } =
|
|
193
|
+
let { attributes, properties }: { attributes: Attribute[]; properties?: Record<string, JsonSchemaFragment> } =
|
|
194
|
+
options;
|
|
171
195
|
if (!attributes) attributes = [];
|
|
196
|
+
if (!properties) properties = projectAttributesToProperties(attributes);
|
|
172
197
|
const updateRecord = recordUpdater(primaryStore, tableId, auditStore);
|
|
173
198
|
let sourceLoad: any; // if a source has a load function (replicator), record it here
|
|
174
199
|
let hasSourceGet: any;
|
|
175
|
-
let primaryKeyAttribute: Attribute
|
|
200
|
+
let primaryKeyAttribute: Attribute | undefined;
|
|
176
201
|
let lastEvictionCompletion: Promise<void> = Promise.resolve();
|
|
177
|
-
let createdTimeProperty: Attribute
|
|
202
|
+
let createdTimeProperty: Attribute | undefined,
|
|
203
|
+
updatedTimeProperty: Attribute | undefined,
|
|
204
|
+
expiresAtProperty: Attribute | undefined;
|
|
178
205
|
for (const attribute of attributes) {
|
|
179
206
|
if (attribute.assignCreatedTime || attribute.name === '__createdtime__') createdTimeProperty = attribute;
|
|
180
207
|
if (attribute.assignUpdatedTime || attribute.name === '__updatedtime__') updatedTimeProperty = attribute;
|
|
@@ -241,6 +268,7 @@ export function makeTable(options) {
|
|
|
241
268
|
#savingOperation?: any; // operation for the record is currently being saved
|
|
242
269
|
|
|
243
270
|
declare getProperty: (name: string) => any;
|
|
271
|
+
// #section: static-config
|
|
244
272
|
static name = tableName; // for display/debugging purposes
|
|
245
273
|
static primaryStore = primaryStore;
|
|
246
274
|
static auditStore = auditStore;
|
|
@@ -252,6 +280,11 @@ export function makeTable(options) {
|
|
|
252
280
|
static databasePath = databasePath;
|
|
253
281
|
static databaseName = databaseName;
|
|
254
282
|
static attributes = attributes;
|
|
283
|
+
static description = description;
|
|
284
|
+
static properties = properties;
|
|
285
|
+
static hidden = hidden;
|
|
286
|
+
static outputSchemas: { [verb: string]: JsonSchemaFragment } | undefined;
|
|
287
|
+
static mcp: { annotations?: { [verb: string]: any } } | undefined;
|
|
255
288
|
static replicate = replicate;
|
|
256
289
|
static sealed = sealed;
|
|
257
290
|
static splitSegments = splitSegments ?? true;
|
|
@@ -259,6 +292,11 @@ export function makeTable(options) {
|
|
|
259
292
|
static updatedTimeProperty = updatedTimeProperty;
|
|
260
293
|
static propertyResolvers;
|
|
261
294
|
static userResolvers = {};
|
|
295
|
+
// `@embed` hook registry. `userSetEmbedders` records names set explicitly via
|
|
296
|
+
// `setEmbedAttribute` so a schema reload refreshes defaults without clobbering them.
|
|
297
|
+
static userEmbedders: { [name: string]: Embedder } = {};
|
|
298
|
+
static userSetEmbedders: Set<string> = new Set();
|
|
299
|
+
static embedAttributes: EmbedAttribute[] = (attributes as any[]).filter((a) => a?.embed);
|
|
262
300
|
static source?: typeof TableResource;
|
|
263
301
|
declare static sourceOptions: any;
|
|
264
302
|
declare static intermediateSource: boolean;
|
|
@@ -276,6 +314,7 @@ export function makeTable(options) {
|
|
|
276
314
|
* @param options
|
|
277
315
|
* @returns
|
|
278
316
|
*/
|
|
317
|
+
// #section: resource-registry
|
|
279
318
|
static sourcedFrom(source, options) {
|
|
280
319
|
// define a source for retrieving invalidated entries for caching purposes
|
|
281
320
|
if (options) {
|
|
@@ -521,10 +560,10 @@ export function makeTable(options) {
|
|
|
521
560
|
}
|
|
522
561
|
});
|
|
523
562
|
if (txnInProgress) txnInProgress.committed = commitResolution;
|
|
524
|
-
if (userRoleUpdate && commitResolution && !commitResolution
|
|
563
|
+
if (userRoleUpdate && commitResolution && !(commitResolution as any).waitingForUserChange) {
|
|
525
564
|
// if the user role changed, asynchronously signal the user change (but don't block this function)
|
|
526
565
|
commitResolution.then(() => signalling.signalUserChange(new UserEventMsg(process.pid)));
|
|
527
|
-
commitResolution.waitingForUserChange = true; // only need to send one signal per transaction
|
|
566
|
+
(commitResolution as any).waitingForUserChange = true; // only need to send one signal per transaction
|
|
528
567
|
}
|
|
529
568
|
|
|
530
569
|
if (event.onCommit) {
|
|
@@ -572,11 +611,7 @@ export function makeTable(options) {
|
|
|
572
611
|
}
|
|
573
612
|
return resource;
|
|
574
613
|
}
|
|
575
|
-
_loadRecord
|
|
576
|
-
target: RequestTarget,
|
|
577
|
-
request: Context,
|
|
578
|
-
resourceOptions?: any
|
|
579
|
-
): MaybePromise<TableResource<Record>> {
|
|
614
|
+
_loadRecord(target: RequestTarget, request: Context, resourceOptions?: any): MaybePromise<TableResource<Record>> {
|
|
580
615
|
const id = target && typeof target === 'object' ? target.id : target;
|
|
581
616
|
if (id == null) return this;
|
|
582
617
|
checkValidId(id);
|
|
@@ -605,9 +640,10 @@ export function makeTable(options) {
|
|
|
605
640
|
// return 504 (rather than 404) if there is no content and the cache-control header
|
|
606
641
|
// dictates not to go to source
|
|
607
642
|
if (!this.doesExist()) throw new ServerError('Entry is not cached', 504);
|
|
643
|
+
if (hasSourceGet && target) target.loadedFromSource = false; // mark it as cached
|
|
608
644
|
} else if (resourceOptions?.ensureLoaded) {
|
|
609
645
|
const loadingFromSource = ensureLoadedFromSource(
|
|
610
|
-
this.constructor.source,
|
|
646
|
+
(this.constructor as any).source,
|
|
611
647
|
id,
|
|
612
648
|
entry,
|
|
613
649
|
request,
|
|
@@ -616,7 +652,7 @@ export function makeTable(options) {
|
|
|
616
652
|
);
|
|
617
653
|
if (loadingFromSource) {
|
|
618
654
|
txn?.disregardReadTxn(); // this could take some time, so don't keep the transaction open if possible
|
|
619
|
-
return when(loadingFromSource
|
|
655
|
+
return when(loadingFromSource as Promise<Entry>, (entry) => {
|
|
620
656
|
TableResource._updateResource(this, entry);
|
|
621
657
|
return this;
|
|
622
658
|
});
|
|
@@ -642,19 +678,20 @@ export function makeTable(options) {
|
|
|
642
678
|
*/
|
|
643
679
|
ensureLoaded() {
|
|
644
680
|
const loadedFromSource = ensureLoadedFromSource(
|
|
645
|
-
this.constructor.source,
|
|
681
|
+
(this.constructor as any).source,
|
|
646
682
|
this.getId(),
|
|
647
683
|
this.#entry,
|
|
648
684
|
this.getContext()
|
|
649
685
|
);
|
|
650
686
|
if (loadedFromSource) {
|
|
651
|
-
return when(loadedFromSource
|
|
687
|
+
return when(loadedFromSource as Promise<Entry>, (entry) => {
|
|
652
688
|
this.#entry = entry;
|
|
653
689
|
this.#record = entry.value;
|
|
654
690
|
this.#version = entry.version;
|
|
655
691
|
});
|
|
656
692
|
}
|
|
657
693
|
}
|
|
694
|
+
// #section: lifecycle-admin
|
|
658
695
|
static getNewId(): any {
|
|
659
696
|
const type = primaryKeyAttribute?.type;
|
|
660
697
|
// 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
|
|
@@ -954,19 +991,13 @@ export function makeTable(options) {
|
|
|
954
991
|
new SchemaEventMsg(process.pid, OPERATIONS_ENUM.DROP_TABLE, databaseName, tableName)
|
|
955
992
|
);
|
|
956
993
|
}
|
|
957
|
-
|
|
958
|
-
* This retrieves the data of this resource. By default, with no argument, just return `this`.
|
|
959
|
-
*/
|
|
960
|
-
get(): TableResource<Record> | undefined;
|
|
994
|
+
// #section: read-path
|
|
961
995
|
/**
|
|
962
996
|
* This retrieves the data of this resource.
|
|
963
997
|
* @param target - If included, is an identifier/query that specifies the requested target to retrieve and query
|
|
964
998
|
*/
|
|
965
|
-
get(target
|
|
966
|
-
|
|
967
|
-
target?: RequestTargetOrId
|
|
968
|
-
): TableResource<Record> | undefined | Record | AsyncIterable<Record> | Promise<Record | AsyncIterable<Record>> {
|
|
969
|
-
const constructor: Resource = this.constructor;
|
|
999
|
+
get(target?: any): any {
|
|
1000
|
+
const constructor: any = this.constructor;
|
|
970
1001
|
if (typeof target === 'string' && constructor.loadAsInstance !== false) return this.getProperty(target);
|
|
971
1002
|
if (isSearchTarget(target)) {
|
|
972
1003
|
// go back to the static search method so it gets a chance to override
|
|
@@ -984,7 +1015,7 @@ export function makeTable(options) {
|
|
|
984
1015
|
recordCount: undefined,
|
|
985
1016
|
estimatedRecordRange: undefined,
|
|
986
1017
|
};
|
|
987
|
-
if (this.getContext()?.includeExpensiveRecordCountEstimates) {
|
|
1018
|
+
if ((this.getContext() as any)?.includeExpensiveRecordCountEstimates) {
|
|
988
1019
|
return TableResource.getRecordCount().then((recordCount) => {
|
|
989
1020
|
description.recordCount = recordCount.recordCount;
|
|
990
1021
|
description.estimatedRecordRange = recordCount.estimatedRange;
|
|
@@ -994,7 +1025,7 @@ export function makeTable(options) {
|
|
|
994
1025
|
return description;
|
|
995
1026
|
}
|
|
996
1027
|
if (target !== undefined && constructor.loadAsInstance === false) {
|
|
997
|
-
const context = this.getContext();
|
|
1028
|
+
const context: any = this.getContext();
|
|
998
1029
|
const txn = txnForContext(context);
|
|
999
1030
|
const readTxn = txn.getReadTxn();
|
|
1000
1031
|
if (readTxn?.isDone) {
|
|
@@ -1003,7 +1034,7 @@ export function makeTable(options) {
|
|
|
1003
1034
|
const id = requestTargetToId(target);
|
|
1004
1035
|
checkValidId(id);
|
|
1005
1036
|
let allowed = true;
|
|
1006
|
-
if (target
|
|
1037
|
+
if ((target as any)?.checkPermission) {
|
|
1007
1038
|
// requesting authorization verification
|
|
1008
1039
|
allowed = this.allowRead(context.user, target, context);
|
|
1009
1040
|
}
|
|
@@ -1063,11 +1094,12 @@ export function makeTable(options) {
|
|
|
1063
1094
|
}
|
|
1064
1095
|
return promiseNormalize(record, target);
|
|
1065
1096
|
}
|
|
1066
|
-
if (this.doesExist() || target?.ensureLoaded === false || this.getContext()?.returnNonexistent) {
|
|
1097
|
+
if (this.doesExist() || target?.ensureLoaded === false || (this.getContext() as any)?.returnNonexistent) {
|
|
1067
1098
|
return this;
|
|
1068
1099
|
}
|
|
1069
1100
|
return undefined;
|
|
1070
1101
|
}
|
|
1102
|
+
// #section: authz-hooks
|
|
1071
1103
|
/**
|
|
1072
1104
|
* Determine if the user is allowed to get/read data from the current resource
|
|
1073
1105
|
*/
|
|
@@ -1081,20 +1113,20 @@ export function makeTable(options) {
|
|
|
1081
1113
|
// If attribute permissions are defined, we need to ensure there is a select that only returns the attributes the user has permission to
|
|
1082
1114
|
// or if there are relationships, we need to ensure that the user has permission to read from the related table
|
|
1083
1115
|
// Note that if we do not have a select, we do not return any relationships by default.
|
|
1084
|
-
if (!target) target = {};
|
|
1116
|
+
if (!target) target = {} as any;
|
|
1085
1117
|
if (select) {
|
|
1086
1118
|
const selectArray = Array.isArray(select) ? select : [select];
|
|
1087
1119
|
const attrsForType = attribute_permissions?.length > 0 && attributesAsObject(attribute_permissions, 'read');
|
|
1088
|
-
target.select = selectArray
|
|
1089
|
-
.map((property) => {
|
|
1120
|
+
(target as any).select = selectArray
|
|
1121
|
+
.map((property: any) => {
|
|
1090
1122
|
const propertyName = property.name || property;
|
|
1091
1123
|
if (!attrsForType || attrsForType[propertyName]) {
|
|
1092
1124
|
const relatedTable = propertyResolvers[propertyName]?.definition?.tableClass;
|
|
1093
1125
|
if (relatedTable) {
|
|
1094
1126
|
// 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
|
|
1095
1127
|
if (!property.name) property = { name: property };
|
|
1096
|
-
if (!property.checkPermission && target.checkPermission)
|
|
1097
|
-
property.checkPermission = target.checkPermission;
|
|
1128
|
+
if (!property.checkPermission && (target as any).checkPermission)
|
|
1129
|
+
property.checkPermission = (target as any).checkPermission;
|
|
1098
1130
|
if (!relatedTable.prototype.allowRead.call(null, user, property, context)) return false;
|
|
1099
1131
|
if (!property.select) return property.name; // no select was applied, just return the name
|
|
1100
1132
|
}
|
|
@@ -1178,6 +1210,7 @@ export function makeTable(options) {
|
|
|
1178
1210
|
return !!tablePermission?.delete && checkContextPermissions(context);
|
|
1179
1211
|
}
|
|
1180
1212
|
|
|
1213
|
+
// #section: write-path-public
|
|
1181
1214
|
/**
|
|
1182
1215
|
* Start updating a record. The returned resource will record changes which are written
|
|
1183
1216
|
* once the corresponding transaction is committed. These changes can (eventually) include CRDT type operations.
|
|
@@ -1227,29 +1260,29 @@ export function makeTable(options) {
|
|
|
1227
1260
|
// updates that were passed into this method
|
|
1228
1261
|
let allowed = true;
|
|
1229
1262
|
if (target == undefined) throw new TypeError('Can not put a record without a target');
|
|
1230
|
-
if (target
|
|
1263
|
+
if ((target as any)?.checkPermission) {
|
|
1231
1264
|
// requesting authorization verification
|
|
1232
|
-
allowed = this.allowUpdate(context.user, updates, context);
|
|
1265
|
+
allowed = this.allowUpdate((context as any).user, updates, context);
|
|
1233
1266
|
}
|
|
1234
1267
|
return when(allowed, (allowed) => {
|
|
1235
1268
|
if (!allowed) {
|
|
1236
|
-
throw new AccessViolation(context.user);
|
|
1269
|
+
throw new AccessViolation((context as any).user);
|
|
1237
1270
|
}
|
|
1238
1271
|
let loading: Promise<any>;
|
|
1239
|
-
if (!this.#entry && this.constructor.loadAsInstance === false) {
|
|
1272
|
+
if (!this.#entry && (this.constructor as any).loadAsInstance === false) {
|
|
1240
1273
|
// load the record if it hasn't been done yet
|
|
1241
1274
|
loading = this._loadRecord(target, context, { ensureLoaded: true, async: true }) as Promise<any>;
|
|
1242
1275
|
}
|
|
1243
1276
|
return when(loading, () => {
|
|
1244
1277
|
this.#changes = updates;
|
|
1245
|
-
|
|
1246
|
-
|
|
1278
|
+
// `when` awaits the embed hook (when `@embed` is active) before resolving,
|
|
1279
|
+
// so the caller's `save()` doesn't run before the write is staged.
|
|
1280
|
+
return when(this._writeUpdate(id, this.#changes, false), () => this);
|
|
1247
1281
|
});
|
|
1248
1282
|
});
|
|
1249
1283
|
}
|
|
1250
1284
|
}
|
|
1251
|
-
this._writeUpdate(id, this.#changes, fullUpdate);
|
|
1252
|
-
return this;
|
|
1285
|
+
return when(this._writeUpdate(id, this.#changes, fullUpdate), () => this);
|
|
1253
1286
|
}
|
|
1254
1287
|
|
|
1255
1288
|
/**
|
|
@@ -1257,29 +1290,31 @@ export function makeTable(options) {
|
|
|
1257
1290
|
*/
|
|
1258
1291
|
save() {
|
|
1259
1292
|
if (this.#savingOperation) {
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
} finally {
|
|
1265
|
-
this.#savingOperation = null;
|
|
1266
|
-
}
|
|
1293
|
+
try {
|
|
1294
|
+
return this.#saveOperation(this.#savingOperation);
|
|
1295
|
+
} finally {
|
|
1296
|
+
this.#savingOperation = null;
|
|
1267
1297
|
}
|
|
1268
1298
|
}
|
|
1269
1299
|
}
|
|
1300
|
+
#saveOperation(operation: any) {
|
|
1301
|
+
const transaction = txnForContext(this.getContext());
|
|
1302
|
+
if (transaction.save) return transaction.save(operation) || operation.promise || operation.result;
|
|
1303
|
+
}
|
|
1270
1304
|
|
|
1271
|
-
addTo(property, value) {
|
|
1305
|
+
addTo(property: any, value: any) {
|
|
1272
1306
|
if (typeof value === 'number' || typeof value === 'bigint') {
|
|
1273
|
-
if (this.#savingOperation?.fullUpdate)
|
|
1307
|
+
if (this.#savingOperation?.fullUpdate)
|
|
1308
|
+
(this as any).set(property, (+this.getProperty(property) || 0) + (value as any));
|
|
1274
1309
|
else {
|
|
1275
|
-
if (!this.#savingOperation) this.update();
|
|
1276
|
-
this.set(property, new Addition(value));
|
|
1310
|
+
if (!this.#savingOperation) (this as any).update();
|
|
1311
|
+
(this as any).set(property, new Addition(value));
|
|
1277
1312
|
}
|
|
1278
1313
|
} else {
|
|
1279
1314
|
throw new Error('Can not add a non-numeric value');
|
|
1280
1315
|
}
|
|
1281
1316
|
}
|
|
1282
|
-
subtractFrom(property, value) {
|
|
1317
|
+
subtractFrom(property: any, value: any) {
|
|
1283
1318
|
if (typeof value === 'number') {
|
|
1284
1319
|
return this.addTo(property, -value);
|
|
1285
1320
|
} else {
|
|
@@ -1307,11 +1342,11 @@ export function makeTable(options) {
|
|
|
1307
1342
|
const context = this.getContext();
|
|
1308
1343
|
if ((target as RequestTarget)?.checkPermission) {
|
|
1309
1344
|
// requesting authorization verification
|
|
1310
|
-
allowed = this.allowDelete(context.user, target as
|
|
1345
|
+
allowed = this.allowDelete((context as any).user, target as any, context);
|
|
1311
1346
|
}
|
|
1312
1347
|
return when(allowed, (allowed: boolean) => {
|
|
1313
1348
|
if (!allowed) {
|
|
1314
|
-
throw new AccessViolation(context.user);
|
|
1349
|
+
throw new AccessViolation((context as any).user);
|
|
1315
1350
|
}
|
|
1316
1351
|
this._writeInvalidate(target ? requestTargetToId(target) : this.getId());
|
|
1317
1352
|
});
|
|
@@ -1348,7 +1383,7 @@ export function makeTable(options) {
|
|
|
1348
1383
|
INVALIDATED,
|
|
1349
1384
|
audit,
|
|
1350
1385
|
{
|
|
1351
|
-
user: context?.user,
|
|
1386
|
+
user: (context as any)?.user,
|
|
1352
1387
|
residencyId: options?.residencyId,
|
|
1353
1388
|
nodeId: options?.nodeId,
|
|
1354
1389
|
viaNodeId: options?.viaNodeId,
|
|
@@ -1373,8 +1408,8 @@ export function makeTable(options) {
|
|
|
1373
1408
|
invalidated: true,
|
|
1374
1409
|
entry: this.#entry,
|
|
1375
1410
|
before:
|
|
1376
|
-
this.constructor.source?.relocate && !context?.source
|
|
1377
|
-
? this.constructor.source.relocate.bind(this.constructor.source, id, undefined, context)
|
|
1411
|
+
(this.constructor as any).source?.relocate && !(context as any)?.source
|
|
1412
|
+
? (this.constructor as any).source.relocate.bind((this.constructor as any).source, id, undefined, context)
|
|
1378
1413
|
: undefined,
|
|
1379
1414
|
commit: (txnTime, existingEntry, _retry, transaction: any) => {
|
|
1380
1415
|
if (precedesExistingVersion(txnTime, existingEntry, options?.nodeId) <= 0) return;
|
|
@@ -1403,7 +1438,7 @@ export function makeTable(options) {
|
|
|
1403
1438
|
metadata,
|
|
1404
1439
|
audit,
|
|
1405
1440
|
{
|
|
1406
|
-
user: context
|
|
1441
|
+
user: (context as any)?.user,
|
|
1407
1442
|
residencyId: options.residencyId,
|
|
1408
1443
|
nodeId: options.nodeId,
|
|
1409
1444
|
viaNodeId: options?.viaNodeId,
|
|
@@ -1487,12 +1522,12 @@ export function makeTable(options) {
|
|
|
1487
1522
|
committed = true;
|
|
1488
1523
|
if (primaryStore.ifVersion) {
|
|
1489
1524
|
// LMDB: committing the wrapper calls doneReadTxn(), removing it from trackedTxns
|
|
1490
|
-
return lmdbTransaction.commit();
|
|
1525
|
+
return (lmdbTransaction as any).commit();
|
|
1491
1526
|
}
|
|
1492
1527
|
// RocksDB: eviction writes went directly into the raw transaction via options;
|
|
1493
1528
|
// commit it directly, as DatabaseTransaction.commit() would abort it (no tracked writes).
|
|
1494
1529
|
// Wrap in Promise.resolve so callers can rely on a thenable return regardless of engine.
|
|
1495
|
-
return
|
|
1530
|
+
return (transaction as any).commit();
|
|
1496
1531
|
} finally {
|
|
1497
1532
|
if (!committed) {
|
|
1498
1533
|
// Skip path or thrown error: abort instead of committing so we don't apply
|
|
@@ -1514,77 +1549,82 @@ export function makeTable(options) {
|
|
|
1514
1549
|
static operation(operation, context) {
|
|
1515
1550
|
operation.table ||= tableName;
|
|
1516
1551
|
operation.schema ||= databaseName;
|
|
1517
|
-
return global.operation(operation, context);
|
|
1552
|
+
return (global as any).operation(operation, context);
|
|
1518
1553
|
}
|
|
1519
1554
|
|
|
1520
1555
|
/**
|
|
1521
1556
|
* Store the provided record data into the current resource. This is not written
|
|
1522
1557
|
* until the corresponding transaction is committed.
|
|
1523
1558
|
*/
|
|
1559
|
+
// @ts-expect-error The implementation intentionally uses a different argument order for back-compat
|
|
1524
1560
|
put(
|
|
1525
1561
|
target: RequestTarget,
|
|
1526
1562
|
record: Record & RecordObject
|
|
1527
1563
|
): void | (Record & Partial<RecordObject>) | Promise<void | (Record & Partial<RecordObject>)> {
|
|
1528
1564
|
if (record === undefined || record instanceof URLSearchParams) {
|
|
1529
|
-
// legacy argument position, shift the arguments and go through the update method for back-compat
|
|
1530
|
-
|
|
1531
|
-
return this.save();
|
|
1565
|
+
// legacy argument position, shift the arguments and go through the update method for back-compat.
|
|
1566
|
+
// `when` settles the embed hook before `save()` so the write is staged first.
|
|
1567
|
+
return when((this as any).update(target, true), () => this.save() as any) as any;
|
|
1532
1568
|
} else {
|
|
1533
1569
|
let allowed = true;
|
|
1534
1570
|
if (target == undefined) throw new TypeError('Can not put a record without a target');
|
|
1535
1571
|
const context = this.getContext();
|
|
1536
|
-
if (target.checkPermission) {
|
|
1572
|
+
if ((target as any).checkPermission) {
|
|
1537
1573
|
// requesting authorization verification
|
|
1538
|
-
allowed = this.allowUpdate(context.user, record, context);
|
|
1574
|
+
allowed = this.allowUpdate((context as any).user, record, context);
|
|
1539
1575
|
}
|
|
1540
1576
|
return when(allowed, (allowed) => {
|
|
1541
1577
|
if (!allowed) {
|
|
1542
|
-
throw new AccessViolation(context.user);
|
|
1578
|
+
throw new AccessViolation((context as any).user);
|
|
1543
1579
|
}
|
|
1544
1580
|
// standard path, handle arrays as multiple updates, and otherwise do a direct update
|
|
1545
1581
|
if (Array.isArray(record)) {
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1582
|
+
// Capture each element's operation synchronously (before any async `@embed`
|
|
1583
|
+
// hook resolves): `#savingOperation` is a single field that parallel writes
|
|
1584
|
+
// would otherwise clobber, so a deferred `save()` would commit the wrong op
|
|
1585
|
+
// — e.g. one element's save running before a later element's vector is written.
|
|
1586
|
+
const writes = record.map((element) => {
|
|
1587
|
+
const id = element[primaryKey];
|
|
1588
|
+
const writePromise = this._writeUpdate(id, element, true);
|
|
1589
|
+
const operation = this.#savingOperation;
|
|
1590
|
+
return when(writePromise, () => this.#saveOperation(operation));
|
|
1591
|
+
});
|
|
1592
|
+
this.#savingOperation = null;
|
|
1593
|
+
return Promise.all(writes) as any;
|
|
1553
1594
|
} else {
|
|
1554
|
-
const id = requestTargetToId(target);
|
|
1555
|
-
this._writeUpdate(id, record, true);
|
|
1556
|
-
return this.save();
|
|
1595
|
+
const id = requestTargetToId(target as any);
|
|
1596
|
+
return when(this._writeUpdate(id, record, true), () => this.save() as any);
|
|
1557
1597
|
}
|
|
1558
|
-
});
|
|
1598
|
+
}) as any;
|
|
1559
1599
|
}
|
|
1560
1600
|
// always return undefined
|
|
1561
1601
|
}
|
|
1562
1602
|
|
|
1563
1603
|
create(
|
|
1564
|
-
target:
|
|
1604
|
+
target: RequestTargetOrId,
|
|
1565
1605
|
record: Partial<Record & RecordObject>
|
|
1566
1606
|
): void | (Record & Partial<RecordObject>) | Promise<Record & Partial<RecordObject>> {
|
|
1567
1607
|
let allowed = true;
|
|
1568
1608
|
const context = this.getContext();
|
|
1569
1609
|
if (!record && !(target instanceof URLSearchParams)) {
|
|
1570
1610
|
// single argument, shift arguments
|
|
1571
|
-
record = target;
|
|
1611
|
+
record = target as any;
|
|
1572
1612
|
target = undefined;
|
|
1573
1613
|
}
|
|
1574
1614
|
if (!record || typeof record !== 'object' || Array.isArray(record)) {
|
|
1575
1615
|
throw new TypeError('Can not create a record without an object');
|
|
1576
1616
|
}
|
|
1577
|
-
if (target?.checkPermission) {
|
|
1617
|
+
if ((target as any)?.checkPermission) {
|
|
1578
1618
|
// requesting authorization verification
|
|
1579
|
-
allowed = this.allowCreate(context.user, record, context);
|
|
1619
|
+
allowed = this.allowCreate((context as any).user, record as any, context);
|
|
1580
1620
|
}
|
|
1581
1621
|
return when(allowed, (allowed) => {
|
|
1582
1622
|
if (!allowed) {
|
|
1583
|
-
throw new AccessViolation(context.user);
|
|
1623
|
+
throw new AccessViolation((context as any).user);
|
|
1584
1624
|
}
|
|
1585
|
-
let id = requestTargetToId(target) ?? record[primaryKey];
|
|
1625
|
+
let id = requestTargetToId(target as any) ?? record[primaryKey];
|
|
1586
1626
|
if (id === undefined) {
|
|
1587
|
-
id = this.constructor.getNewId();
|
|
1627
|
+
id = (this.constructor as any).getNewId();
|
|
1588
1628
|
record[primaryKey] = id; // make this immediately available
|
|
1589
1629
|
} else {
|
|
1590
1630
|
const existing = primaryStore.getSync(id);
|
|
@@ -1592,9 +1632,11 @@ export function makeTable(options) {
|
|
|
1592
1632
|
throw new ClientError('Record already exists', 409);
|
|
1593
1633
|
}
|
|
1594
1634
|
}
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1635
|
+
// `_writeUpdate` may return a promise when an `@embed` directive
|
|
1636
|
+
// requires running an embedder before the per-write `commit(...)`
|
|
1637
|
+
// closure. `when()` passes through synchronous returns.
|
|
1638
|
+
return when(this._writeUpdate(id, record, true), () => record);
|
|
1639
|
+
}) as any;
|
|
1598
1640
|
}
|
|
1599
1641
|
|
|
1600
1642
|
// @ts-expect-error The implementation handles the possibility of target and recordUpdate being swapped
|
|
@@ -1603,39 +1645,39 @@ export function makeTable(options) {
|
|
|
1603
1645
|
recordUpdate: Partial<Record & RecordObject>
|
|
1604
1646
|
): void | (Record & Partial<RecordObject>) | Promise<void | (Record & Partial<RecordObject>)> {
|
|
1605
1647
|
if (recordUpdate === undefined || recordUpdate instanceof URLSearchParams) {
|
|
1606
|
-
// legacy argument position, shift the arguments and go through the update method for back-compat
|
|
1607
|
-
|
|
1608
|
-
return this.save();
|
|
1648
|
+
// legacy argument position, shift the arguments and go through the update method for back-compat.
|
|
1649
|
+
// `when` settles the embed hook before `save()` so the write is staged first.
|
|
1650
|
+
return when(this.update(target, false), () => this.save() as any) as any;
|
|
1609
1651
|
} else {
|
|
1610
1652
|
// standard path, ensure there is no return object
|
|
1611
1653
|
return when(this.update(target, recordUpdate), () => {
|
|
1612
|
-
return when(this.save(), () => undefined); // wait for the update and save, but return undefined
|
|
1613
|
-
});
|
|
1654
|
+
return when(this.save() as any, () => undefined); // wait for the update and save, but return undefined
|
|
1655
|
+
}) as any;
|
|
1614
1656
|
}
|
|
1615
1657
|
}
|
|
1658
|
+
// #section: write-path-internals
|
|
1616
1659
|
// perform the actual write operation; this may come from a user request to write (put, post, etc.), or
|
|
1617
1660
|
// a notification that a write has already occurred in the canonical data source, we need to update our
|
|
1618
1661
|
// local copy
|
|
1619
1662
|
_writeUpdate(id: Id, recordUpdate: any, fullUpdate: boolean, options?: any) {
|
|
1620
1663
|
const context = this.getContext();
|
|
1621
1664
|
const transaction = txnForContext(context);
|
|
1622
|
-
|
|
1623
1665
|
checkValidId(id);
|
|
1624
1666
|
const entry = this.#entry ?? primaryStore.getEntry(id, { transaction: transaction.getReadTxn() });
|
|
1625
1667
|
const writeToSource = () => {
|
|
1626
|
-
if (!this.constructor.source || context?.source) return;
|
|
1668
|
+
if (!(this.constructor as any).source || (context as any)?.source) return;
|
|
1627
1669
|
if (fullUpdate) {
|
|
1628
1670
|
// full update is a put
|
|
1629
|
-
if (this.constructor.source.put) {
|
|
1630
|
-
return () => this.constructor.source.put(id, recordUpdate, context);
|
|
1671
|
+
if ((this.constructor as any).source.put) {
|
|
1672
|
+
return () => (this.constructor as any).source.put(id, recordUpdate, context);
|
|
1631
1673
|
}
|
|
1632
1674
|
} else {
|
|
1633
1675
|
// incremental update
|
|
1634
|
-
if (this.constructor.source.patch) {
|
|
1635
|
-
return () => this.constructor.source.patch(id, recordUpdate, context);
|
|
1636
|
-
} else if (this.constructor.source.put) {
|
|
1676
|
+
if ((this.constructor as any).source.patch) {
|
|
1677
|
+
return () => (this.constructor as any).source.patch(id, recordUpdate, context);
|
|
1678
|
+
} else if ((this.constructor as any).source.put) {
|
|
1637
1679
|
// if this is incremental, but only have put, we can use that by generating the full record (at least the expected one)
|
|
1638
|
-
return () => this.constructor.source.put(id, updateAndFreeze(this), context);
|
|
1680
|
+
return () => (this.constructor as any).source.put(id, updateAndFreeze(this), context);
|
|
1639
1681
|
}
|
|
1640
1682
|
}
|
|
1641
1683
|
};
|
|
@@ -1644,13 +1686,13 @@ export function makeTable(options) {
|
|
|
1644
1686
|
key: id,
|
|
1645
1687
|
store: primaryStore,
|
|
1646
1688
|
entry,
|
|
1647
|
-
nodeName: context?.nodeName,
|
|
1689
|
+
nodeName: (context as any)?.nodeName,
|
|
1648
1690
|
fullUpdate,
|
|
1649
1691
|
deferSave: true,
|
|
1650
1692
|
validate: (txnTime) => {
|
|
1651
1693
|
if (!recordUpdate) recordUpdate = this.#changes;
|
|
1652
1694
|
if (fullUpdate || (recordUpdate && hasChanges(this.#changes === recordUpdate ? this : recordUpdate))) {
|
|
1653
|
-
if (!context?.source) {
|
|
1695
|
+
if (!(context as any)?.source) {
|
|
1654
1696
|
transaction.checkOverloaded();
|
|
1655
1697
|
// Records are intentionally immutable: decoded records are frozen (and 5.2 record
|
|
1656
1698
|
// caching relies on it), so mutating in place would corrupt cached/shared state.
|
|
@@ -1693,7 +1735,7 @@ export function makeTable(options) {
|
|
|
1693
1735
|
// TODO: else freeze after we have applied the changes
|
|
1694
1736
|
}
|
|
1695
1737
|
} else {
|
|
1696
|
-
transaction.removeWrite?.(write);
|
|
1738
|
+
(transaction as any).removeWrite?.(write);
|
|
1697
1739
|
return false;
|
|
1698
1740
|
}
|
|
1699
1741
|
},
|
|
@@ -1733,6 +1775,32 @@ export function makeTable(options) {
|
|
|
1733
1775
|
// of the updates to the record to ensure consistency across the cluster
|
|
1734
1776
|
// TODO: can the previous version be older, but even more previous version be newer?
|
|
1735
1777
|
if (audit) {
|
|
1778
|
+
// A re-delivered out-of-order write (full-copy audit-replay re-delivers writes) must not have
|
|
1779
|
+
// its commutative ops re-folded. additionalAuditRefs is the record's own list of folded
|
|
1780
|
+
// out-of-order versions, read with read-your-writes consistency, so this skips the duplicate up
|
|
1781
|
+
// front — before the audit-log walk below, which can miss it: the walk stops at the depth cap, or
|
|
1782
|
+
// breaks early on a not-yet-visible audit entry, before reaching txnTime, and the keyed
|
|
1783
|
+
// transaction-log lookup it would otherwise use can lag a back-to-back re-delivery (that lag
|
|
1784
|
+
// silently double-applied the increment — #1137). This covers the re-delivery while the ref is
|
|
1785
|
+
// still on the record; a later in-order write rewrites the record and drops the ref (it survives
|
|
1786
|
+
// only as previousAdditionalAuditRefs on the audit log), so that case falls back to the
|
|
1787
|
+
// best-effort keyed lookup in the capped block below — see #1148. precedesExistingVersion(...)
|
|
1788
|
+
// === 0 is the identity tie: same version AND same node (the local node is id 0, so an undefined
|
|
1789
|
+
// options?.nodeId resolves to the same 0 the ref stored).
|
|
1790
|
+
if (
|
|
1791
|
+
existingEntry.additionalAuditRefs?.some(
|
|
1792
|
+
(ref) =>
|
|
1793
|
+
ref.version === txnTime &&
|
|
1794
|
+
precedesExistingVersion(
|
|
1795
|
+
txnTime,
|
|
1796
|
+
{ version: txnTime, localTime: txnTime, key: id, nodeId: ref.nodeId },
|
|
1797
|
+
options?.nodeId
|
|
1798
|
+
) === 0
|
|
1799
|
+
)
|
|
1800
|
+
) {
|
|
1801
|
+
write.skipped = true;
|
|
1802
|
+
return; // out-of-order write already folded into this record
|
|
1803
|
+
}
|
|
1736
1804
|
// incremental CRDT updates are only available with audit logging on
|
|
1737
1805
|
let localTime = existingEntry.localTime;
|
|
1738
1806
|
let auditedVersion = existingEntry.version;
|
|
@@ -1864,8 +1932,12 @@ export function makeTable(options) {
|
|
|
1864
1932
|
// retained window are not layered in — but the authoritative full-copy record restores exact
|
|
1865
1933
|
// convergence. Because we stopped before reaching txnTime, the inline duplicate detection in
|
|
1866
1934
|
// the walk never ran; full-copy audit-replay re-delivers writes, and re-applying one would
|
|
1867
|
-
// double-apply its commutative ops
|
|
1868
|
-
//
|
|
1935
|
+
// double-apply its commutative ops. A re-delivered out-of-order write is already ruled out by
|
|
1936
|
+
// the additionalAuditRefs check at the top of this block; this keyed lookup is the best-effort
|
|
1937
|
+
// guard for the remaining case — a re-delivered write that was originally in-order (so it left
|
|
1938
|
+
// no ref) and is now deeper than the cap. It is best-effort because the transaction-log lookup
|
|
1939
|
+
// can intermittently miss an entry under load (tracked separately); the authoritative full-copy
|
|
1940
|
+
// record still restores exact convergence.
|
|
1869
1941
|
logger.warn?.(
|
|
1870
1942
|
'Out-of-order audit reconciliation exceeded depth cap; reconciling against most recent updates only',
|
|
1871
1943
|
{
|
|
@@ -1921,7 +1993,7 @@ export function makeTable(options) {
|
|
|
1921
1993
|
let recordToStore: any;
|
|
1922
1994
|
if (fullUpdate && !incrementalUpdateToApply) recordToStore = recordUpdate;
|
|
1923
1995
|
else {
|
|
1924
|
-
if (this.constructor.loadAsInstance === false)
|
|
1996
|
+
if ((this.constructor as any).loadAsInstance === false)
|
|
1925
1997
|
recordToStore = updateAndFreeze(existingRecord, incrementalUpdateToApply ?? recordUpdate);
|
|
1926
1998
|
else {
|
|
1927
1999
|
this.#record = existingRecord;
|
|
@@ -1932,7 +2004,8 @@ export function makeTable(options) {
|
|
|
1932
2004
|
if (recordToStore && recordToStore.getRecord)
|
|
1933
2005
|
throw new Error('Can not assign a record to a record, check for circular references');
|
|
1934
2006
|
if (residencyId == undefined) {
|
|
1935
|
-
if (entry?.residencyId)
|
|
2007
|
+
if (entry?.residencyId)
|
|
2008
|
+
(context as any).previousResidency = TableResource.getResidencyRecord(entry.residencyId);
|
|
1936
2009
|
const residency = residencyFromFunction(TableResource.getResidency(recordToStore, context));
|
|
1937
2010
|
if (residency) {
|
|
1938
2011
|
if (!residency.includes(server.hostname)) {
|
|
@@ -1999,12 +2072,12 @@ export function makeTable(options) {
|
|
|
1999
2072
|
audit,
|
|
2000
2073
|
{
|
|
2001
2074
|
omitLocalRecord,
|
|
2002
|
-
user: context?.user,
|
|
2075
|
+
user: (context as any)?.user,
|
|
2003
2076
|
residencyId,
|
|
2004
2077
|
expiresAt,
|
|
2005
2078
|
nodeId: options?.nodeId,
|
|
2006
2079
|
viaNodeId: options?.viaNodeId,
|
|
2007
|
-
originatingOperation: context?.originatingOperation,
|
|
2080
|
+
originatingOperation: (context as any)?.originatingOperation,
|
|
2008
2081
|
transaction,
|
|
2009
2082
|
tableToTrack: databaseName === 'system' ? null : options?.replay ? null : tableName, // don't track analytics on system tables
|
|
2010
2083
|
additionalAuditRefs: additionalAuditRefs.length > 0 ? additionalAuditRefs : undefined,
|
|
@@ -2017,33 +2090,52 @@ export function makeTable(options) {
|
|
|
2017
2090
|
},
|
|
2018
2091
|
};
|
|
2019
2092
|
this.#savingOperation = write;
|
|
2020
|
-
|
|
2021
|
-
|
|
2093
|
+
// `@embed` hook must run before `addWrite` so the embedder's vector is on the
|
|
2094
|
+
// record when `commit` runs. (The txn `before` slot runs after commit, which
|
|
2095
|
+
// suits blob writes but not embedding, where the vector must be present at commit.)
|
|
2096
|
+
// Known limitation of this write-time placement (a validate-time alternative was
|
|
2097
|
+
// tried and reverted as a Harper-foreign pattern): the embedder sees this write's
|
|
2098
|
+
// payload, before table validation — so a write that later fails validation still
|
|
2099
|
+
// calls the backend, and a tracked-instance mutation (update(id,{}); row.source=…;
|
|
2100
|
+
// save()) that sets the source via accessors after update() won't re-embed. A
|
|
2101
|
+
// resource-layer re-embed is the proper fix; tracked as a follow-up.
|
|
2102
|
+
const embedBefore = buildEmbedBefore(
|
|
2103
|
+
recordUpdate,
|
|
2104
|
+
context,
|
|
2105
|
+
options,
|
|
2106
|
+
TableResource.embedAttributes,
|
|
2107
|
+
TableResource.userEmbedders
|
|
2108
|
+
);
|
|
2109
|
+
const proceed = (): any => {
|
|
2110
|
+
write.beforeIntermediate = preCommitBlobsForRecordBefore(write, recordUpdate);
|
|
2111
|
+
return transaction.addWrite(write as any);
|
|
2112
|
+
};
|
|
2113
|
+
return embedBefore ? embedBefore().then(proceed) : proceed();
|
|
2022
2114
|
}
|
|
2023
2115
|
|
|
2024
2116
|
async delete(target: RequestTargetOrId): Promise<boolean> {
|
|
2025
2117
|
if (isSearchTarget(target)) {
|
|
2026
2118
|
target.select = ['$id']; // just get the primary key of each record so we can delete them
|
|
2027
2119
|
for await (const entry of this.search(target)) {
|
|
2028
|
-
this._writeDelete(entry.$id);
|
|
2120
|
+
this._writeDelete((entry as any).$id);
|
|
2029
2121
|
}
|
|
2030
2122
|
return true;
|
|
2031
2123
|
}
|
|
2032
2124
|
if (target) {
|
|
2033
2125
|
let allowed = true;
|
|
2034
2126
|
const context = this.getContext();
|
|
2035
|
-
if (target
|
|
2127
|
+
if ((target as any)?.checkPermission) {
|
|
2036
2128
|
// requesting authorization verification
|
|
2037
|
-
allowed = this.allowDelete(context.user, target, context);
|
|
2129
|
+
allowed = this.allowDelete((context as any).user, target as any, context);
|
|
2038
2130
|
}
|
|
2039
2131
|
return when(allowed, (allowed: boolean) => {
|
|
2040
2132
|
if (!allowed) {
|
|
2041
|
-
throw new AccessViolation(context.user);
|
|
2133
|
+
throw new AccessViolation((context as any).user);
|
|
2042
2134
|
}
|
|
2043
|
-
const id = requestTargetToId(target);
|
|
2135
|
+
const id = requestTargetToId(target as any);
|
|
2044
2136
|
this._writeDelete(id);
|
|
2045
2137
|
return true;
|
|
2046
|
-
});
|
|
2138
|
+
}) as any;
|
|
2047
2139
|
}
|
|
2048
2140
|
this._writeDelete(this.getId());
|
|
2049
2141
|
return Boolean(this.#record);
|
|
@@ -2058,10 +2150,10 @@ export function makeTable(options) {
|
|
|
2058
2150
|
key: id,
|
|
2059
2151
|
store: primaryStore,
|
|
2060
2152
|
entry,
|
|
2061
|
-
nodeName: context?.nodeName,
|
|
2153
|
+
nodeName: (context as any)?.nodeName,
|
|
2062
2154
|
before:
|
|
2063
|
-
this.constructor.source?.delete && !context?.source
|
|
2064
|
-
? this.constructor.source.delete.bind(this.constructor.source, id, undefined, context)
|
|
2155
|
+
(this.constructor as any).source?.delete && !(context as any)?.source
|
|
2156
|
+
? (this.constructor as any).source.delete.bind((this.constructor as any).source, id, undefined, context)
|
|
2065
2157
|
: undefined,
|
|
2066
2158
|
commit: (txnTime, existingEntry, retry, transaction: any) => {
|
|
2067
2159
|
const existingRecord = existingEntry?.value;
|
|
@@ -2083,7 +2175,7 @@ export function makeTable(options) {
|
|
|
2083
2175
|
0,
|
|
2084
2176
|
audit,
|
|
2085
2177
|
{
|
|
2086
|
-
user: context?.user,
|
|
2178
|
+
user: (context as any)?.user,
|
|
2087
2179
|
nodeId: options?.nodeId,
|
|
2088
2180
|
viaNodeId: options?.viaNodeId,
|
|
2089
2181
|
transaction,
|
|
@@ -2096,10 +2188,11 @@ export function makeTable(options) {
|
|
|
2096
2188
|
removeEntry(primaryStore, existingEntry);
|
|
2097
2189
|
}
|
|
2098
2190
|
},
|
|
2099
|
-
});
|
|
2191
|
+
} as any);
|
|
2100
2192
|
return true;
|
|
2101
2193
|
}
|
|
2102
2194
|
|
|
2195
|
+
// #section: search-query
|
|
2103
2196
|
search(target: RequestTarget): AsyncIterable<Record & Partial<RecordObject>> {
|
|
2104
2197
|
const context = this.getContext();
|
|
2105
2198
|
const txn = txnForContext(context);
|
|
@@ -2107,14 +2200,14 @@ export function makeTable(options) {
|
|
|
2107
2200
|
if (target.parseError) throw target.parseError; // if there was a parse error, we can throw it now
|
|
2108
2201
|
if (target.checkPermission) {
|
|
2109
2202
|
// requesting authorization verification
|
|
2110
|
-
const allowed = this.allowRead(context.user, target, context);
|
|
2203
|
+
const allowed = this.allowRead((context as any).user, target, context);
|
|
2111
2204
|
if (!allowed) {
|
|
2112
|
-
throw new AccessViolation(context.user);
|
|
2205
|
+
throw new AccessViolation((context as any).user);
|
|
2113
2206
|
}
|
|
2114
2207
|
}
|
|
2115
2208
|
if (context) context.lastModified = UNCACHEABLE_TIMESTAMP;
|
|
2116
2209
|
|
|
2117
|
-
let conditions = target.conditions;
|
|
2210
|
+
let conditions: any = target.conditions;
|
|
2118
2211
|
if (!conditions) conditions = Array.isArray(target) ? target : target[Symbol.iterator] ? Array.from(target) : [];
|
|
2119
2212
|
else if (conditions.length === undefined) {
|
|
2120
2213
|
conditions = conditions[Symbol.iterator] ? Array.from(conditions) : [conditions];
|
|
@@ -2132,7 +2225,7 @@ export function makeTable(options) {
|
|
|
2132
2225
|
let orderAlignedCondition;
|
|
2133
2226
|
const filtered = {};
|
|
2134
2227
|
|
|
2135
|
-
function prepareConditions(conditions:
|
|
2228
|
+
function prepareConditions(conditions: any[], operator: string) {
|
|
2136
2229
|
// some validation:
|
|
2137
2230
|
switch (operator) {
|
|
2138
2231
|
case 'and':
|
|
@@ -2150,15 +2243,37 @@ export function makeTable(options) {
|
|
|
2150
2243
|
condition.conditions = prepareConditions(condition.conditions, condition.operator);
|
|
2151
2244
|
continue;
|
|
2152
2245
|
}
|
|
2246
|
+
// Normalize `not_X` comparator forms passed in via structured queries.
|
|
2247
|
+
// The REST parser already does this, but programmatic callers may
|
|
2248
|
+
// pass `not_in`, `not_starts_with`, etc. directly.
|
|
2249
|
+
if (condition.comparator) {
|
|
2250
|
+
const resolved = resolveComparator(condition.comparator);
|
|
2251
|
+
if (resolved.negated) {
|
|
2252
|
+
condition.comparator = resolved.comparator;
|
|
2253
|
+
condition.negated = true;
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2153
2256
|
const attribute_name = condition[0] ?? condition.attribute;
|
|
2154
|
-
|
|
2257
|
+
let attribute = attribute_name == null ? primaryKeyAttribute : findAttribute(attributes, attribute_name);
|
|
2258
|
+
if (!attribute && Array.isArray(attribute_name) && attribute_name.length > 1) {
|
|
2259
|
+
// Plain JSON nested path: the leaf may not be declared in the
|
|
2260
|
+
// schema. Fall back to the root attribute so we can validate
|
|
2261
|
+
// existence without requiring the inner structure to be typed.
|
|
2262
|
+
attribute = findAttribute(attributes, attribute_name[0]);
|
|
2263
|
+
}
|
|
2155
2264
|
if (!attribute) {
|
|
2156
2265
|
if (attribute_name != null && !target.allowConditionsOnDynamicAttributes)
|
|
2157
2266
|
throw handleHDBError(new Error(), `${attribute_name} is not a defined attribute`, 404);
|
|
2158
2267
|
} else if (attribute.type || COERCIBLE_OPERATORS[condition.comparator]) {
|
|
2159
|
-
// Do auto-coercion or coercion as required by the attribute type
|
|
2160
|
-
|
|
2161
|
-
|
|
2268
|
+
// Do auto-coercion or coercion as required by the attribute type.
|
|
2269
|
+
// Skipped for nested paths into plain JSON — the root attribute's
|
|
2270
|
+
// type is not the leaf type, so coercion would be wrong.
|
|
2271
|
+
const isNestedPathRoot =
|
|
2272
|
+
Array.isArray(attribute_name) && attribute_name.length > 1 && !attribute.relationship;
|
|
2273
|
+
if (!isNestedPathRoot) {
|
|
2274
|
+
if (condition[1] === undefined) condition.value = coerceTypedValues(condition.value, attribute);
|
|
2275
|
+
else condition[1] = coerceTypedValues(condition[1], attribute);
|
|
2276
|
+
}
|
|
2162
2277
|
}
|
|
2163
2278
|
if (condition.chainedConditions) {
|
|
2164
2279
|
if (condition.chainedConditions.length === 1 && (!condition.operator || condition.operator == 'and')) {
|
|
@@ -2188,7 +2303,7 @@ export function makeTable(options) {
|
|
|
2188
2303
|
}
|
|
2189
2304
|
const isGe = lower.comparator === 'ge' || lower.comparator === 'greater_than_equal';
|
|
2190
2305
|
const isLe = upper.comparator === 'le' || upper.comparator === 'less_than_equal';
|
|
2191
|
-
condition.comparator = (isGe ? 'ge' : 'gt') + (isLe ? 'le' : 'lt');
|
|
2306
|
+
condition.comparator = ((isGe ? 'ge' : 'gt') + (isLe ? 'le' : 'lt')) as any;
|
|
2192
2307
|
condition.value = [lower.value, upper.value];
|
|
2193
2308
|
} else throw new Error('Multiple chained conditions are not currently supported');
|
|
2194
2309
|
}
|
|
@@ -2218,11 +2333,11 @@ export function makeTable(options) {
|
|
|
2218
2333
|
let postOrdering;
|
|
2219
2334
|
if (sort) {
|
|
2220
2335
|
// 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
|
|
2221
|
-
if (operator !== 'or') {
|
|
2336
|
+
if ((operator as any) !== 'or') {
|
|
2222
2337
|
const attribute_name = sort.attribute;
|
|
2223
2338
|
if (attribute_name == undefined) throw new ClientError('Sort requires an attribute');
|
|
2224
2339
|
orderAlignedCondition = conditions.find(
|
|
2225
|
-
(condition) => flattenKey(condition.attribute) === flattenKey(attribute_name)
|
|
2340
|
+
(condition) => flattenKey(condition.attribute as any) === flattenKey(attribute_name as any)
|
|
2226
2341
|
);
|
|
2227
2342
|
if (orderAlignedCondition) {
|
|
2228
2343
|
// if there is a condition on the same attribute as the first sort, we can use it to align the sort
|
|
@@ -2233,7 +2348,7 @@ export function makeTable(options) {
|
|
|
2233
2348
|
throw handleHDBError(
|
|
2234
2349
|
new Error(),
|
|
2235
2350
|
`${
|
|
2236
|
-
Array.isArray(attribute_name) ? attribute_name.join('.') : attribute_name
|
|
2351
|
+
Array.isArray(attribute_name) ? (attribute_name as any).join('.') : attribute_name
|
|
2237
2352
|
} is not a defined attribute`,
|
|
2238
2353
|
404
|
|
2239
2354
|
);
|
|
@@ -2245,7 +2360,7 @@ export function makeTable(options) {
|
|
|
2245
2360
|
throw handleHDBError(
|
|
2246
2361
|
new Error(),
|
|
2247
2362
|
`${
|
|
2248
|
-
Array.isArray(attribute_name) ? attribute_name.join('.') : attribute_name
|
|
2363
|
+
Array.isArray(attribute_name) ? (attribute_name as any).join('.') : attribute_name
|
|
2249
2364
|
} is not indexed and not combined with any other conditions`,
|
|
2250
2365
|
404
|
|
2251
2366
|
);
|
|
@@ -2281,7 +2396,7 @@ export function makeTable(options) {
|
|
|
2281
2396
|
operator,
|
|
2282
2397
|
postOrdering,
|
|
2283
2398
|
selectApplied: Boolean(select),
|
|
2284
|
-
};
|
|
2399
|
+
} as any;
|
|
2285
2400
|
}
|
|
2286
2401
|
// we mark the read transaction as in use (necessary for a stable read
|
|
2287
2402
|
// transaction, and we really don't care if the
|
|
@@ -2298,7 +2413,7 @@ export function makeTable(options) {
|
|
|
2298
2413
|
(results: any[], filters: Function[]) => transformToEntries(results, select, context, readTxn, filters),
|
|
2299
2414
|
filtered
|
|
2300
2415
|
);
|
|
2301
|
-
const ensure_loaded = target.ensureLoaded !== false;
|
|
2416
|
+
const ensure_loaded = (target as any).ensureLoaded !== false;
|
|
2302
2417
|
const transformToRecord = TableResource.transformEntryForSelect(
|
|
2303
2418
|
select,
|
|
2304
2419
|
context,
|
|
@@ -2331,7 +2446,7 @@ export function makeTable(options) {
|
|
|
2331
2446
|
const columns = [];
|
|
2332
2447
|
for (const column of select) {
|
|
2333
2448
|
if (column === '*') columns.push(...attributes.map((attribute) => attribute.name));
|
|
2334
|
-
else columns.push(column.name || column);
|
|
2449
|
+
else columns.push((column as any).name || column);
|
|
2335
2450
|
}
|
|
2336
2451
|
return columns;
|
|
2337
2452
|
}
|
|
@@ -2371,14 +2486,14 @@ export function makeTable(options) {
|
|
|
2371
2486
|
? entries[Symbol.asyncIterator]()
|
|
2372
2487
|
: entries[Symbol.iterator]();
|
|
2373
2488
|
let dbDone: boolean;
|
|
2374
|
-
const dbOrderedAttribute = sort.dbOrderedAttribute;
|
|
2489
|
+
const dbOrderedAttribute = (sort as any).dbOrderedAttribute;
|
|
2375
2490
|
let enqueuedEntryForNextGroup: any;
|
|
2376
2491
|
let lastGroupingValue: any;
|
|
2377
2492
|
let firstEntry = true;
|
|
2378
2493
|
function createComparator(order: Sort) {
|
|
2379
2494
|
const nextComparator = order.next && createComparator(order.next);
|
|
2380
2495
|
const descending = order.descending;
|
|
2381
|
-
context.sort = order; // make sure this is set to the current sort order
|
|
2496
|
+
(context as any).sort = order; // make sure this is set to the current sort order
|
|
2382
2497
|
return (entryA, entryB) => {
|
|
2383
2498
|
const a = getAttributeValue(entryA, order.attribute, context);
|
|
2384
2499
|
const b = getAttributeValue(entryB, order.attribute, context);
|
|
@@ -2437,7 +2552,7 @@ export function makeTable(options) {
|
|
|
2437
2552
|
ordered.push(entry);
|
|
2438
2553
|
}
|
|
2439
2554
|
} while (true);
|
|
2440
|
-
if (sort.isGrouped) {
|
|
2555
|
+
if ((sort as any).isGrouped) {
|
|
2441
2556
|
// TODO: Return grouped results
|
|
2442
2557
|
}
|
|
2443
2558
|
ordered.sort(comparator);
|
|
@@ -2465,8 +2580,8 @@ export function makeTable(options) {
|
|
|
2465
2580
|
for (let i = 0; i < select.length; i++) {
|
|
2466
2581
|
const column = select[i];
|
|
2467
2582
|
let columnSort;
|
|
2468
|
-
if (column.name === sort.attribute[0]) {
|
|
2469
|
-
columnSort = column.sort || (column.sort = {});
|
|
2583
|
+
if ((column as any).name === sort.attribute[0]) {
|
|
2584
|
+
columnSort = (column as any).sort || ((column as any).sort = {});
|
|
2470
2585
|
while (columnSort.next) columnSort = columnSort.next;
|
|
2471
2586
|
columnSort.attribute = sort.attribute.slice(1);
|
|
2472
2587
|
columnSort.descending = sort.descending;
|
|
@@ -2477,7 +2592,7 @@ export function makeTable(options) {
|
|
|
2477
2592
|
attribute: sort.attribute.slice(1),
|
|
2478
2593
|
descending: sort.descending,
|
|
2479
2594
|
},
|
|
2480
|
-
};
|
|
2595
|
+
} as any;
|
|
2481
2596
|
}
|
|
2482
2597
|
}
|
|
2483
2598
|
}
|
|
@@ -2560,7 +2675,7 @@ export function makeTable(options) {
|
|
|
2560
2675
|
this?.isSync,
|
|
2561
2676
|
(entry: Entry) => entry
|
|
2562
2677
|
);
|
|
2563
|
-
if (entry?.then) return entry.then(transform.bind(this));
|
|
2678
|
+
if ((entry as any)?.then) return (entry as any).then(transform.bind(this));
|
|
2564
2679
|
record = entry?.value;
|
|
2565
2680
|
}
|
|
2566
2681
|
if (
|
|
@@ -2670,12 +2785,22 @@ export function makeTable(options) {
|
|
|
2670
2785
|
} else {
|
|
2671
2786
|
value = record[attribute_name];
|
|
2672
2787
|
if (value && typeof value === 'object' && attribute_name !== attribute) {
|
|
2673
|
-
|
|
2788
|
+
const subTransform = TableResource.transformEntryForSelect(
|
|
2674
2789
|
attribute.select || attribute,
|
|
2675
2790
|
context,
|
|
2676
2791
|
readTxn,
|
|
2677
2792
|
null
|
|
2678
|
-
)
|
|
2793
|
+
);
|
|
2794
|
+
// Plain JSON nested values: arrays project per-element so that
|
|
2795
|
+
// `select: [{ name: 'addresses', select: ['city'] }]` returns
|
|
2796
|
+
// `addresses: [{ city }, { city }]` rather than a single object.
|
|
2797
|
+
if (Array.isArray(value)) {
|
|
2798
|
+
value = value.map((item) =>
|
|
2799
|
+
item && typeof item === 'object' ? subTransform({ value: item } as any) : item
|
|
2800
|
+
);
|
|
2801
|
+
} else if (!(value instanceof Date)) {
|
|
2802
|
+
value = subTransform({ value } as any);
|
|
2803
|
+
}
|
|
2679
2804
|
}
|
|
2680
2805
|
}
|
|
2681
2806
|
callback(value, attribute_name);
|
|
@@ -2686,7 +2811,7 @@ export function makeTable(options) {
|
|
|
2686
2811
|
selected = value;
|
|
2687
2812
|
});
|
|
2688
2813
|
} else if (Array.isArray(select)) {
|
|
2689
|
-
if (select.asArray) {
|
|
2814
|
+
if ((select as any).asArray) {
|
|
2690
2815
|
selected = [];
|
|
2691
2816
|
select.forEach((attribute, index) => {
|
|
2692
2817
|
if (attribute === '*') select[index] = record;
|
|
@@ -2694,7 +2819,7 @@ export function makeTable(options) {
|
|
|
2694
2819
|
});
|
|
2695
2820
|
} else {
|
|
2696
2821
|
selected = {};
|
|
2697
|
-
const forceNulls = select.forceNulls;
|
|
2822
|
+
const forceNulls = (select as any).forceNulls;
|
|
2698
2823
|
for (const attribute of select) {
|
|
2699
2824
|
if (attribute === '*')
|
|
2700
2825
|
for (const key in record) {
|
|
@@ -2718,12 +2843,13 @@ export function makeTable(options) {
|
|
|
2718
2843
|
return transform;
|
|
2719
2844
|
}
|
|
2720
2845
|
|
|
2846
|
+
// #section: pub-sub
|
|
2721
2847
|
async subscribe(request: SubscriptionRequest): Promise<AsyncIterable<Record>> {
|
|
2722
2848
|
if (!auditStore) throw new Error('Can not subscribe to a table without an audit log');
|
|
2723
2849
|
if (!audit) {
|
|
2724
2850
|
table({ table: tableName, database: databaseName, schemaDefined, attributes, audit: true });
|
|
2725
2851
|
}
|
|
2726
|
-
if (!request) request = {};
|
|
2852
|
+
if (!request) request = {} as any;
|
|
2727
2853
|
const getFullRecord = !request.rawEvents;
|
|
2728
2854
|
// While the count, !omitCurrent, and non-collection branches replay older messages, real-time
|
|
2729
2855
|
// messages from the listener accumulate here and are drained at the end of the IIFE so they
|
|
@@ -2738,7 +2864,7 @@ export function makeTable(options) {
|
|
|
2738
2864
|
const subscription = addSubscription(
|
|
2739
2865
|
TableResource,
|
|
2740
2866
|
thisId,
|
|
2741
|
-
function (id: Id, auditRecord
|
|
2867
|
+
function (id: Id, auditRecord?: any, localTime?: any, beginTxn?: any) {
|
|
2742
2868
|
if (dropDuringReplay) return;
|
|
2743
2869
|
try {
|
|
2744
2870
|
let type = auditRecord.type;
|
|
@@ -3037,13 +3163,13 @@ export function makeTable(options) {
|
|
|
3037
3163
|
} else {
|
|
3038
3164
|
let allowed = true;
|
|
3039
3165
|
const context = this.getContext();
|
|
3040
|
-
if (target
|
|
3166
|
+
if ((target as any)?.checkPermission) {
|
|
3041
3167
|
// requesting authorization verification
|
|
3042
|
-
allowed = this.
|
|
3168
|
+
allowed = this.allowDelete((context as any).user, target as any, context);
|
|
3043
3169
|
}
|
|
3044
3170
|
return when(allowed, (allowed: boolean) => {
|
|
3045
3171
|
if (!allowed) {
|
|
3046
|
-
throw new AccessViolation(context.user);
|
|
3172
|
+
throw new AccessViolation((context as any).user);
|
|
3047
3173
|
}
|
|
3048
3174
|
const id = requestTargetToId(target);
|
|
3049
3175
|
this._writePublish(id, message, options);
|
|
@@ -3059,16 +3185,16 @@ export function makeTable(options) {
|
|
|
3059
3185
|
key: id,
|
|
3060
3186
|
store: primaryStore,
|
|
3061
3187
|
entry: this.#entry,
|
|
3062
|
-
nodeName: context?.nodeName,
|
|
3188
|
+
nodeName: (context as any)?.nodeName,
|
|
3063
3189
|
validate: () => {
|
|
3064
|
-
if (!context?.source) {
|
|
3190
|
+
if (!(context as any)?.source) {
|
|
3065
3191
|
transaction.checkOverloaded();
|
|
3066
3192
|
this.validate(message);
|
|
3067
3193
|
}
|
|
3068
3194
|
},
|
|
3069
3195
|
before:
|
|
3070
|
-
this.constructor.source?.publish && !context?.source
|
|
3071
|
-
? this.constructor.source.publish.bind(this.constructor.source, id, message, context)
|
|
3196
|
+
(this.constructor as any).source?.publish && !(context as any)?.source
|
|
3197
|
+
? (this.constructor as any).source.publish.bind((this.constructor as any).source, id, message, context)
|
|
3072
3198
|
: undefined,
|
|
3073
3199
|
commit: (txnTime, existingEntry, _retry, transaction: any) => {
|
|
3074
3200
|
// just need to update the version number of the record so it points to the latest audit record
|
|
@@ -3089,7 +3215,7 @@ export function makeTable(options) {
|
|
|
3089
3215
|
0,
|
|
3090
3216
|
true,
|
|
3091
3217
|
{
|
|
3092
|
-
user: context?.user,
|
|
3218
|
+
user: (context as any)?.user,
|
|
3093
3219
|
residencyId: options?.residencyId,
|
|
3094
3220
|
expiresAt: context?.expiresAt,
|
|
3095
3221
|
nodeId: options?.nodeId,
|
|
@@ -3107,6 +3233,7 @@ export function makeTable(options) {
|
|
|
3107
3233
|
write.beforeIntermediate = preCommitBlobsForRecordBefore(write, message, undefined, true);
|
|
3108
3234
|
transaction.addWrite(write);
|
|
3109
3235
|
}
|
|
3236
|
+
// #section: validation
|
|
3110
3237
|
validate(record: any, patch?: boolean) {
|
|
3111
3238
|
let validationErrors;
|
|
3112
3239
|
const validateValue = (value, attribute: Attribute, name) => {
|
|
@@ -3276,6 +3403,7 @@ export function makeTable(options) {
|
|
|
3276
3403
|
throw new ClientError(validationErrors.join('. '));
|
|
3277
3404
|
}
|
|
3278
3405
|
}
|
|
3406
|
+
// #section: stats-admin
|
|
3279
3407
|
getUpdatedTime() {
|
|
3280
3408
|
return this.#version;
|
|
3281
3409
|
}
|
|
@@ -3294,7 +3422,7 @@ export function makeTable(options) {
|
|
|
3294
3422
|
schemaDefined,
|
|
3295
3423
|
attributes: new_attributes,
|
|
3296
3424
|
});
|
|
3297
|
-
return TableResource.indexingOperation;
|
|
3425
|
+
return (TableResource as any).indexingOperation;
|
|
3298
3426
|
}
|
|
3299
3427
|
static async removeAttributes(names: string[]) {
|
|
3300
3428
|
const new_attributes = attributes.filter((attribute) => !names.includes(attribute.name));
|
|
@@ -3304,7 +3432,7 @@ export function makeTable(options) {
|
|
|
3304
3432
|
schemaDefined,
|
|
3305
3433
|
attributes: new_attributes,
|
|
3306
3434
|
});
|
|
3307
|
-
return TableResource.indexingOperation;
|
|
3435
|
+
return (TableResource as any).indexingOperation;
|
|
3308
3436
|
}
|
|
3309
3437
|
/**
|
|
3310
3438
|
* Get the size of the table in bytes (based on amount of pages stored in the database)
|
|
@@ -3397,6 +3525,14 @@ export function makeTable(options) {
|
|
|
3397
3525
|
* When attributes have been changed, we update the accessors that are assigned to this table
|
|
3398
3526
|
*/
|
|
3399
3527
|
static updatedAttributes() {
|
|
3528
|
+
// Refresh on every call: schema reload mutates `attributes` in place, so the
|
|
3529
|
+
// class-construction snapshot would otherwise go stale.
|
|
3530
|
+
this.embedAttributes = (this.attributes as any[]).filter((a) => a?.embed);
|
|
3531
|
+
// Drop registry entries for attributes that are no longer `@embed`, so a dropped
|
|
3532
|
+
// directive doesn't leave a stale embedder or block a default refresh on re-add.
|
|
3533
|
+
const embedNames = new Set(this.embedAttributes.map((a) => a.name));
|
|
3534
|
+
for (const name of Object.keys(this.userEmbedders)) if (!embedNames.has(name)) delete this.userEmbedders[name];
|
|
3535
|
+
for (const name of this.userSetEmbedders) if (!embedNames.has(name)) this.userSetEmbedders.delete(name);
|
|
3400
3536
|
propertyResolvers = this.propertyResolvers = {
|
|
3401
3537
|
$id: (object, context, entry) => ({ value: entry.key }),
|
|
3402
3538
|
$updatedtime: (object, context, entry) => entry.version,
|
|
@@ -3412,6 +3548,11 @@ export function makeTable(options) {
|
|
|
3412
3548
|
attribute.resolve = null; // reset this
|
|
3413
3549
|
const relationship = attribute.relationship;
|
|
3414
3550
|
const computed = attribute.computed;
|
|
3551
|
+
// Register the default embedder unless an author override is set. Sits outside
|
|
3552
|
+
// the resolver chain below so `@embed` fields still flow through auto-HNSW indexing.
|
|
3553
|
+
if (attribute.embed && !TableResource.userSetEmbedders.has(attribute.name)) {
|
|
3554
|
+
this.userEmbedders[attribute.name] = createDefaultEmbedder(attribute.embed);
|
|
3555
|
+
}
|
|
3415
3556
|
if (relationship) {
|
|
3416
3557
|
if (attribute.indexed) {
|
|
3417
3558
|
console.error(
|
|
@@ -3431,12 +3572,14 @@ export function makeTable(options) {
|
|
|
3431
3572
|
const id = object[relationship.from ? relationship.from : primaryKey];
|
|
3432
3573
|
const relatedTable = attribute.elements.definition.tableClass;
|
|
3433
3574
|
if (returnEntry) {
|
|
3434
|
-
return
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3575
|
+
return (
|
|
3576
|
+
searchByIndex(
|
|
3577
|
+
{ attribute: relationship.to, value: id },
|
|
3578
|
+
txnForContext(context).getReadTxn(),
|
|
3579
|
+
false,
|
|
3580
|
+
relatedTable,
|
|
3581
|
+
false
|
|
3582
|
+
) as any
|
|
3440
3583
|
).map((entry) => {
|
|
3441
3584
|
if (entry && entry.key !== undefined) return entry;
|
|
3442
3585
|
return relatedTable.primaryStore.getEntry(entry, {
|
|
@@ -3517,6 +3660,15 @@ export function makeTable(options) {
|
|
|
3517
3660
|
} else if (computed) {
|
|
3518
3661
|
if (typeof computed.from === 'function') {
|
|
3519
3662
|
this.setComputedAttribute(attribute.name, computed.from);
|
|
3663
|
+
} else if (attribute.computedFromExpression) {
|
|
3664
|
+
// build a fallback scope object with all attribute names set to undefined,
|
|
3665
|
+
// matching the behavior in graphql.ts to prevent ReferenceErrors
|
|
3666
|
+
const attributesFallback: { [key: string]: undefined } = {};
|
|
3667
|
+
for (const attr of this.attributes) attributesFallback[attr.name] = undefined;
|
|
3668
|
+
this.setComputedAttribute(
|
|
3669
|
+
attribute.name,
|
|
3670
|
+
createComputedFrom(attribute.computedFromExpression, attributesFallback)
|
|
3671
|
+
);
|
|
3520
3672
|
}
|
|
3521
3673
|
propertyResolvers[attribute.name] = attribute.resolve = (object, context, entry) => {
|
|
3522
3674
|
const value = typeof computed.from === 'string' ? object[computed.from] : object;
|
|
@@ -3571,6 +3723,7 @@ export function makeTable(options) {
|
|
|
3571
3723
|
}
|
|
3572
3724
|
}
|
|
3573
3725
|
}
|
|
3726
|
+
// #section: computed-history
|
|
3574
3727
|
static setComputedAttribute(attribute_name, resolver) {
|
|
3575
3728
|
const attribute = findAttribute(attributes, attribute_name);
|
|
3576
3729
|
if (!attribute) {
|
|
@@ -3583,6 +3736,25 @@ export function makeTable(options) {
|
|
|
3583
3736
|
}
|
|
3584
3737
|
this.userResolvers[attribute_name] = resolver;
|
|
3585
3738
|
}
|
|
3739
|
+
/**
|
|
3740
|
+
* Override the default embedder for an `@embed` attribute. Return the vector to
|
|
3741
|
+
* store at `attribute_name`. The embedder receives the write payload (the fields
|
|
3742
|
+
* present in the PUT/PATCH body), not the post-merge record, so multi-field
|
|
3743
|
+
* concatenation only works when all source fields are in the same write.
|
|
3744
|
+
*/
|
|
3745
|
+
static setEmbedAttribute(attribute_name: string, embedder: Embedder): void {
|
|
3746
|
+
const attribute = findAttribute(attributes, attribute_name);
|
|
3747
|
+
if (!attribute) {
|
|
3748
|
+
console.error(`The attribute "${attribute_name}" does not exist in the table "${tableName}"`);
|
|
3749
|
+
return;
|
|
3750
|
+
}
|
|
3751
|
+
if (!attribute.embed) {
|
|
3752
|
+
console.error(`The attribute "${attribute_name}" is not declared with @embed in the table "${tableName}"`);
|
|
3753
|
+
return;
|
|
3754
|
+
}
|
|
3755
|
+
this.userEmbedders[attribute_name] = embedder;
|
|
3756
|
+
this.userSetEmbedders.add(attribute_name);
|
|
3757
|
+
}
|
|
3586
3758
|
static async deleteHistory(endTime = 0, cleanupDeletedRecords = false) {
|
|
3587
3759
|
let completion: Promise<void>;
|
|
3588
3760
|
for (const auditRecord of auditStore.getRange({
|
|
@@ -3756,34 +3928,35 @@ export function makeTable(options) {
|
|
|
3756
3928
|
function checkValidId(id) {
|
|
3757
3929
|
switch (typeof id) {
|
|
3758
3930
|
case 'number':
|
|
3931
|
+
if (isNaN(id)) throw new ClientError('Invalid primary key of NaN', 400);
|
|
3759
3932
|
return true;
|
|
3760
3933
|
case 'string':
|
|
3761
3934
|
if (id.length < 659) return true; // max number of characters that can't expand our key size limit
|
|
3762
3935
|
if (id.length > MAX_KEY_BYTES) {
|
|
3763
3936
|
// we can quickly determine this is too big
|
|
3764
|
-
throw new
|
|
3937
|
+
throw new ClientError('Primary key size is too large: ' + id.length, 400);
|
|
3765
3938
|
}
|
|
3766
3939
|
// 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
|
|
3767
3940
|
break; // otherwise we have to test it, in this range, unicode characters could put it over the limit
|
|
3768
3941
|
case 'object':
|
|
3769
3942
|
if (id === null) {
|
|
3770
|
-
throw new
|
|
3943
|
+
throw new ClientError('Invalid primary key of null', 400);
|
|
3771
3944
|
}
|
|
3772
3945
|
break; // otherwise we have to test it
|
|
3773
3946
|
case 'bigint':
|
|
3774
3947
|
if (id < 2n ** 64n && id > -(2n ** 64n)) return true;
|
|
3775
3948
|
break; // otherwise we have to test it
|
|
3776
3949
|
default:
|
|
3777
|
-
throw new
|
|
3950
|
+
throw new ClientError('Invalid primary key type: ' + typeof id, 400);
|
|
3778
3951
|
}
|
|
3779
3952
|
// otherwise it is difficult to determine if the key size is too large
|
|
3780
3953
|
// without actually attempting to serialize it
|
|
3781
3954
|
const length = writeKey(id, TEST_WRITE_KEY_BUFFER, 0);
|
|
3782
|
-
if (length > MAX_KEY_BYTES) throw new
|
|
3955
|
+
if (length > MAX_KEY_BYTES) throw new ClientError('Primary key size is too large: ' + id.length, 400);
|
|
3783
3956
|
return true;
|
|
3784
3957
|
}
|
|
3785
3958
|
function requestTargetToId(target: RequestTargetOrId): Id {
|
|
3786
|
-
return typeof target === 'object' && target ? target.id : (target as Id);
|
|
3959
|
+
return typeof target === 'object' && target ? (target as any).id : (target as Id);
|
|
3787
3960
|
}
|
|
3788
3961
|
function isSearchTarget(target: RequestTargetOrId): target is RequestTarget {
|
|
3789
3962
|
return typeof target === 'object' && target && (target as RequestTarget).isCollection;
|
|
@@ -3942,6 +4115,10 @@ export function makeTable(options) {
|
|
|
3942
4115
|
}
|
|
3943
4116
|
|
|
3944
4117
|
function ensureLoadedFromSource(source: typeof TableResource, id, entry, context, resource?, target?) {
|
|
4118
|
+
if (context?.onlyIfCached) {
|
|
4119
|
+
if (!entry?.value) throw new ServerError('Entry is not cached', 504);
|
|
4120
|
+
return;
|
|
4121
|
+
}
|
|
3945
4122
|
if (hasSourceGet) {
|
|
3946
4123
|
let needsSourceData = false;
|
|
3947
4124
|
if (context.noCache) needsSourceData = true;
|
|
@@ -3970,10 +4147,9 @@ export function makeTable(options) {
|
|
|
3970
4147
|
return entry;
|
|
3971
4148
|
});
|
|
3972
4149
|
// if the resource defines a method for indicating if stale-while-revalidate is allowed for a record
|
|
3973
|
-
if (
|
|
4150
|
+
if (entry?.value && resource?.allowStaleWhileRevalidate?.(entry, id)) {
|
|
3974
4151
|
// since we aren't waiting for it any errors won't propagate so we should at least log them
|
|
3975
4152
|
loadingFromSource.catch((error) => logger.warn?.(error));
|
|
3976
|
-
if (context?.onlyIfCached && !resource.doesExist()) throw new ServerError('Entry is not cached', 504);
|
|
3977
4153
|
return; // go ahead and return and let the current stale value be used while we re-validate
|
|
3978
4154
|
} else return loadingFromSource; // return the promise for the resolved value
|
|
3979
4155
|
}
|
|
@@ -3996,7 +4172,7 @@ export function makeTable(options) {
|
|
|
3996
4172
|
if (transaction) {
|
|
3997
4173
|
if (!transaction.db && isRocksDB) {
|
|
3998
4174
|
// this is an uninitialized DatabaseTransaction, we can claim it
|
|
3999
|
-
transaction.db = primaryStore;
|
|
4175
|
+
transaction.db = primaryStore as any;
|
|
4000
4176
|
if (context?.timestamp) transaction.timestamp = context.timestamp;
|
|
4001
4177
|
return transaction;
|
|
4002
4178
|
}
|
|
@@ -4019,7 +4195,9 @@ export function makeTable(options) {
|
|
|
4019
4195
|
transaction = nextTxn;
|
|
4020
4196
|
} while (true);
|
|
4021
4197
|
} else {
|
|
4022
|
-
transaction =
|
|
4198
|
+
transaction = (
|
|
4199
|
+
isRocksDB ? new ImmediateTransaction(primaryStore as any) : new ImmediateLMDBTransaction(primaryStore as any)
|
|
4200
|
+
) as any;
|
|
4023
4201
|
if (context) {
|
|
4024
4202
|
context.transaction = transaction;
|
|
4025
4203
|
if (context.timestamp) transaction.timestamp = context.timestamp;
|
|
@@ -4098,7 +4276,7 @@ export function makeTable(options) {
|
|
|
4098
4276
|
return ids;
|
|
4099
4277
|
}
|
|
4100
4278
|
|
|
4101
|
-
function precedesExistingVersion(txnTime: number, existingEntry: Entry
|
|
4279
|
+
function precedesExistingVersion(txnTime: number, existingEntry: Partial<Entry>, nodeId?: number): number {
|
|
4102
4280
|
if (nodeId === undefined) {
|
|
4103
4281
|
nodeId = getThisNodeId(auditStore);
|
|
4104
4282
|
}
|
|
@@ -4200,7 +4378,7 @@ export function makeTable(options) {
|
|
|
4200
4378
|
expiresAt: undefined,
|
|
4201
4379
|
lastModified: undefined,
|
|
4202
4380
|
};
|
|
4203
|
-
const responseHeaders = context?.responseHeaders;
|
|
4381
|
+
const responseHeaders = (context as any)?.responseHeaders;
|
|
4204
4382
|
return new Promise((resolve, reject) => {
|
|
4205
4383
|
// we don't want to wait for the transaction because we want to return as fast as possible
|
|
4206
4384
|
// and let the transaction commit in the background
|
|
@@ -4225,15 +4403,14 @@ export function makeTable(options) {
|
|
|
4225
4403
|
if (typeof updatedRecord !== 'object') throw new Error('Only objects can be cached and stored in tables');
|
|
4226
4404
|
if (updatedRecord.status > 0 && updatedRecord.headers) {
|
|
4227
4405
|
// if the source has a status code and headers, treat it as a response
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
} // there are definitely more status codes to handle
|
|
4406
|
+
const status = updatedRecord.status;
|
|
4407
|
+
if (status === 304) {
|
|
4408
|
+
// revalidation of our current cached record
|
|
4409
|
+
updatedRecord = existingRecord;
|
|
4410
|
+
version = existingVersion;
|
|
4411
|
+
} else if (!CACHEABLE_STATUS_CODES.has(status)) {
|
|
4412
|
+
// non-cacheable status - propagate to client without caching
|
|
4413
|
+
throw new ServerError(updatedRecord.body || 'Error from source', status);
|
|
4237
4414
|
} else {
|
|
4238
4415
|
let headers: any;
|
|
4239
4416
|
const sourceHeaders = updatedRecord.headers;
|
|
@@ -4261,31 +4438,41 @@ export function makeTable(options) {
|
|
|
4261
4438
|
if (data !== undefined) {
|
|
4262
4439
|
// we have structured data that we have parsed
|
|
4263
4440
|
delete headers['content-type']; // don't store the content type if we have already parsed it
|
|
4264
|
-
updatedRecord = {
|
|
4265
|
-
headers,
|
|
4266
|
-
data,
|
|
4267
|
-
};
|
|
4441
|
+
updatedRecord = { headers, data };
|
|
4268
4442
|
} else {
|
|
4269
|
-
updatedRecord = {
|
|
4270
|
-
headers,
|
|
4271
|
-
body: createBlob(updatedRecord.body),
|
|
4272
|
-
};
|
|
4443
|
+
updatedRecord = { headers, body: createBlob(updatedRecord.body) };
|
|
4273
4444
|
}
|
|
4445
|
+
if (status !== 200) updatedRecord.status = status;
|
|
4274
4446
|
}
|
|
4275
4447
|
}
|
|
4276
4448
|
if (typeof updatedRecord.toJSON === 'function') updatedRecord = updatedRecord.toJSON();
|
|
4277
4449
|
// updatedRecord may still be a frozen record (e.g. a reused existingRecord); copy-on-mutate
|
|
4278
|
-
// before stamping the primary key below (records are immutable —
|
|
4279
|
-
// on it — so we must not write through the frozen object).
|
|
4450
|
+
// before stamping the primary key and created/updated times below (records are immutable —
|
|
4451
|
+
// 5.2 record caching relies on it — so we must not write through the frozen object).
|
|
4280
4452
|
if (isFrozenRecordObject(updatedRecord)) updatedRecord = { ...updatedRecord };
|
|
4281
4453
|
if (primaryKey && updatedRecord[primaryKey] !== id) updatedRecord[primaryKey] = id;
|
|
4282
4454
|
}
|
|
4283
4455
|
resolved = true;
|
|
4284
|
-
|
|
4456
|
+
const resolvedEntry: Entry = {
|
|
4285
4457
|
key: id,
|
|
4286
4458
|
version,
|
|
4287
4459
|
value: updatedRecord,
|
|
4288
|
-
|
|
4460
|
+
expiresAt: sourceContext.expiresAt,
|
|
4461
|
+
metadataFlags: 0,
|
|
4462
|
+
size: 0,
|
|
4463
|
+
localTime: 0,
|
|
4464
|
+
nodeId: 0,
|
|
4465
|
+
residencyId: 0,
|
|
4466
|
+
} as any;
|
|
4467
|
+
// Give the plain object the RecordObject prototype so getExpiresAt/getUpdatedTime
|
|
4468
|
+
// are available on the immediately-resolved entry. We mutate the prototype
|
|
4469
|
+
// in-place rather than copying so that the commit callback (which adds
|
|
4470
|
+
// createdAt/updatedAt to updatedRecord) is still reflected in the entry value.
|
|
4471
|
+
if (updatedRecord && updatedRecord.constructor === Object) {
|
|
4472
|
+
Object.setPrototypeOf(updatedRecord, primaryStore.encoder.structPrototype);
|
|
4473
|
+
entryMap.set(updatedRecord, resolvedEntry);
|
|
4474
|
+
}
|
|
4475
|
+
resolve(resolvedEntry);
|
|
4289
4476
|
} catch (error) {
|
|
4290
4477
|
error.message += ` while resolving record ${id} for ${tableName}`;
|
|
4291
4478
|
if (
|
|
@@ -4303,7 +4490,7 @@ export function makeTable(options) {
|
|
|
4303
4490
|
key: id,
|
|
4304
4491
|
version: existingVersion,
|
|
4305
4492
|
value: existingRecord,
|
|
4306
|
-
});
|
|
4493
|
+
} as any);
|
|
4307
4494
|
logger.trace?.(error.message, '(returned stale record)');
|
|
4308
4495
|
} else reject(error);
|
|
4309
4496
|
const resolveDuration = performance.now() - start;
|
|
@@ -4400,7 +4587,7 @@ export function makeTable(options) {
|
|
|
4400
4587
|
omitLocalRecord ? INVALIDATED : 0,
|
|
4401
4588
|
(audit && (hasChanges || omitLocalRecord)) || null,
|
|
4402
4589
|
{
|
|
4403
|
-
user: sourceContext?.user,
|
|
4590
|
+
user: (sourceContext as any)?.user,
|
|
4404
4591
|
expiresAt: sourceContext.expiresAt,
|
|
4405
4592
|
residencyId,
|
|
4406
4593
|
transaction,
|
|
@@ -4424,7 +4611,7 @@ export function makeTable(options) {
|
|
|
4424
4611
|
txnTime,
|
|
4425
4612
|
0,
|
|
4426
4613
|
(audit && hasChanges) || null,
|
|
4427
|
-
{ user: sourceContext?.user, transaction, tableToTrack: tableName },
|
|
4614
|
+
{ user: (sourceContext as any)?.user, transaction, tableToTrack: tableName },
|
|
4428
4615
|
'delete',
|
|
4429
4616
|
Boolean(invalidated)
|
|
4430
4617
|
);
|
|
@@ -4434,6 +4621,19 @@ export function makeTable(options) {
|
|
|
4434
4621
|
}
|
|
4435
4622
|
},
|
|
4436
4623
|
};
|
|
4624
|
+
// The cache-from-source write bypasses `_writeUpdate`, so wire the embed hook here
|
|
4625
|
+
// too (always the originating node). It runs after the client GET has resolved with
|
|
4626
|
+
// fresh source data, so it's a background commit: an embedder failure aborts the cache
|
|
4627
|
+
// write via the outer error handler (row re-embeds next read) and never reaches the
|
|
4628
|
+
// caller. Source-resolution errors are handled earlier, with the stale-data fallback.
|
|
4629
|
+
const embedBefore = buildEmbedBefore(
|
|
4630
|
+
updatedRecord,
|
|
4631
|
+
sourceContext,
|
|
4632
|
+
undefined,
|
|
4633
|
+
TableResource.embedAttributes,
|
|
4634
|
+
TableResource.userEmbedders
|
|
4635
|
+
);
|
|
4636
|
+
if (embedBefore) await embedBefore();
|
|
4437
4637
|
sourceWrite.before = preCommitBlobsForRecordBefore(sourceWrite, updatedRecord);
|
|
4438
4638
|
dbTxn.addWrite(sourceWrite);
|
|
4439
4639
|
}),
|
|
@@ -4626,8 +4826,10 @@ export function makeTable(options) {
|
|
|
4626
4826
|
if (shardOrResidencyList >= 65536) throw new Error(`Shard id ${shardOrResidencyList} must be below 65536`);
|
|
4627
4827
|
const residencyList = server.shards?.get?.(shardOrResidencyList);
|
|
4628
4828
|
if (residencyList) {
|
|
4629
|
-
logger.trace?.(
|
|
4630
|
-
|
|
4829
|
+
logger.trace?.(
|
|
4830
|
+
`Shard ${shardOrResidencyList} mapped to ${residencyList.map((node) => (node as any).name).join(', ')}`
|
|
4831
|
+
);
|
|
4832
|
+
return residencyList.map((node) => (node as any).name);
|
|
4631
4833
|
}
|
|
4632
4834
|
throw new Error(`Shard ${shardOrResidencyList} is not defined`);
|
|
4633
4835
|
}
|
|
@@ -4651,9 +4853,9 @@ export function makeTable(options) {
|
|
|
4651
4853
|
function preCommitBlobsForRecordBefore(
|
|
4652
4854
|
write: any,
|
|
4653
4855
|
record: any,
|
|
4654
|
-
before?: () => Promise<void
|
|
4856
|
+
before?: () => Promise<void> | void,
|
|
4655
4857
|
saveInRecord?: boolean
|
|
4656
|
-
):
|
|
4858
|
+
): any {
|
|
4657
4859
|
const preCommit = startPreCommitBlobsForRecord(record, primaryStore.rootStore, saveInRecord);
|
|
4658
4860
|
if (preCommit) {
|
|
4659
4861
|
// track the blobs on the write so abort/skip paths can clean up the files if the commit doesn't reference them
|
|
@@ -4662,14 +4864,15 @@ export function makeTable(options) {
|
|
|
4662
4864
|
// them to finish and we return a new callback for the before phase of the commit
|
|
4663
4865
|
const callSources = before;
|
|
4664
4866
|
return callSources
|
|
4665
|
-
? async () => {
|
|
4867
|
+
? async (): Promise<any> => {
|
|
4666
4868
|
// if we are calling the sources first and waiting for blobs, do those in order
|
|
4667
|
-
|
|
4869
|
+
const result = callSources();
|
|
4870
|
+
if (result && (result as any).then) await result;
|
|
4668
4871
|
await preCommit.complete();
|
|
4669
4872
|
}
|
|
4670
4873
|
: () => preCommit.complete();
|
|
4671
4874
|
}
|
|
4672
|
-
return before;
|
|
4875
|
+
return before as any;
|
|
4673
4876
|
}
|
|
4674
4877
|
}
|
|
4675
4878
|
|
|
@@ -4687,6 +4890,20 @@ function noop() {
|
|
|
4687
4890
|
// prefetch callback
|
|
4688
4891
|
}
|
|
4689
4892
|
|
|
4893
|
+
/**
|
|
4894
|
+
* Recreate a computed "from" function from a stored expression string. This is used when a table
|
|
4895
|
+
* is loaded from metadata on a thread that hasn't loaded the GraphQL schema, so the computed
|
|
4896
|
+
* function needs to be reconstructed from the persisted expression.
|
|
4897
|
+
*/
|
|
4898
|
+
function createComputedFrom(computedFromExpression: string, attributesFallback?: any) {
|
|
4899
|
+
const script = new Script(
|
|
4900
|
+
attributesFallback
|
|
4901
|
+
? `function computed(attributes) { return function(record) { with(attributes) { with (record) { return ${computedFromExpression}; } } } } computed;`
|
|
4902
|
+
: `function computed() { return function(record) { with (record) { return ${computedFromExpression}; } } } computed;`
|
|
4903
|
+
);
|
|
4904
|
+
return script.runInThisContext()(attributesFallback);
|
|
4905
|
+
}
|
|
4906
|
+
|
|
4690
4907
|
const ENDS_WITH_TIMEZONE = /[+-][0-9]{2}:[0-9]{2}|[a-zA-Z]$/;
|
|
4691
4908
|
/**
|
|
4692
4909
|
* Coerce a string to the type defined by the attribute
|