@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.
Files changed (1140) hide show
  1. package/README.md +11 -10
  2. package/agent/agent.ts +203 -0
  3. package/agent/loop.ts +205 -0
  4. package/agent/operations.ts +148 -0
  5. package/agent/session.ts +187 -0
  6. package/agent/tools/fsTools.ts +276 -0
  7. package/agent/tools/httpFetchTool.ts +112 -0
  8. package/agent/tools/scheduleTool.ts +68 -0
  9. package/agent/toolset.ts +43 -0
  10. package/agent/types.ts +85 -0
  11. package/bin/{BinObjects.js → BinObjects.ts} +4 -5
  12. package/bin/cliCredentials.ts +133 -0
  13. package/bin/cliOperations.ts +339 -0
  14. package/bin/copyDb.ts +10 -10
  15. package/bin/deployRenderer.ts +196 -0
  16. package/bin/{harper.js → harper.ts} +43 -19
  17. package/bin/{install.js → install.ts} +3 -3
  18. package/bin/lite.ts +2 -0
  19. package/bin/login.ts +134 -0
  20. package/bin/logout.ts +11 -0
  21. package/bin/mcp/client.ts +407 -0
  22. package/bin/mcp/doctor.ts +189 -0
  23. package/bin/mcp/index.ts +80 -0
  24. package/bin/mcp/options.ts +122 -0
  25. package/bin/mcp/printConfig.ts +89 -0
  26. package/bin/multipartBuilder.ts +74 -0
  27. package/bin/{restart.js → restart.ts} +27 -28
  28. package/bin/{run.js → run.ts} +41 -30
  29. package/bin/sseConsumer.ts +126 -0
  30. package/bin/{status.js → status.ts} +10 -10
  31. package/bin/{stop.js → stop.ts} +5 -5
  32. package/bin/upgrade.js +17 -24
  33. package/components/Application.ts +144 -18
  34. package/components/ApplicationScope.ts +2 -2
  35. package/components/ComponentV1.ts +2 -2
  36. package/components/EntryHandler.ts +159 -9
  37. package/components/OptionsWatcher.ts +75 -11
  38. package/components/Scope.ts +132 -18
  39. package/components/anthropic/index.ts +547 -0
  40. package/components/bedrock/index.ts +823 -0
  41. package/components/componentLoader.ts +64 -32
  42. package/components/deployLifecycle.ts +161 -0
  43. package/components/deploymentOperations.ts +173 -0
  44. package/components/deploymentRecorder.ts +427 -0
  45. package/components/deriveURLPath.ts +4 -4
  46. package/components/mcp/adapters/fastify.ts +87 -0
  47. package/components/mcp/adapters/harperHttp.ts +103 -0
  48. package/components/mcp/audit.ts +75 -0
  49. package/components/mcp/index.ts +134 -0
  50. package/components/mcp/jsonrpc.ts +134 -0
  51. package/components/mcp/lifecycle.ts +105 -0
  52. package/components/mcp/listChanged.ts +270 -0
  53. package/components/mcp/rateLimit.ts +217 -0
  54. package/components/mcp/resources.ts +607 -0
  55. package/components/mcp/session.ts +151 -0
  56. package/components/mcp/sessionRegistry.ts +140 -0
  57. package/components/mcp/toolRegistry.ts +294 -0
  58. package/components/mcp/tools/application.ts +761 -0
  59. package/components/mcp/tools/operations.ts +311 -0
  60. package/components/mcp/tools/schemas/derive.ts +356 -0
  61. package/components/mcp/tools/schemas/operationDescriptions.ts +241 -0
  62. package/components/mcp/tools/schemas/operations.ts +301 -0
  63. package/components/mcp/transport.ts +517 -0
  64. package/components/ollama/index.ts +316 -0
  65. package/components/openai/index.ts +563 -0
  66. package/components/operations.js +217 -60
  67. package/components/operationsValidation.js +12 -4
  68. package/components/packageComponent.ts +97 -29
  69. package/components/requestRestart.ts +17 -2
  70. package/components/status/crossThread.ts +14 -5
  71. package/components/status/errors.ts +1 -1
  72. package/config/RootConfigWatcher.ts +56 -2
  73. package/config/configUtils.js +29 -8
  74. package/config/harperConfigEnvVars.ts +1 -1
  75. package/config-root.schema.json +78 -4
  76. package/dataLayer/{CreateAttributeObject.js → CreateAttributeObject.ts} +4 -3
  77. package/dataLayer/{CreateTableObject.js → CreateTableObject.ts} +2 -1
  78. package/dataLayer/{DataLayerObjects.js → DataLayerObjects.ts} +17 -9
  79. package/dataLayer/{DeleteBeforeObject.js → DeleteBeforeObject.ts} +2 -1
  80. package/dataLayer/{DeleteObject.js → DeleteObject.ts} +3 -2
  81. package/dataLayer/{DropAttributeObject.js → DropAttributeObject.ts} +2 -1
  82. package/dataLayer/{GetBackupObject.js → GetBackupObject.ts} +3 -2
  83. package/dataLayer/{InsertObject.js → InsertObject.ts} +3 -2
  84. package/dataLayer/{ReadAuditLogObject.js → ReadAuditLogObject.ts} +3 -2
  85. package/dataLayer/{SQLSearch.js → SQLSearch.ts} +97 -43
  86. package/dataLayer/{SearchByConditionsObject.js → SearchByConditionsObject.ts} +5 -6
  87. package/dataLayer/{SearchByHashObject.js → SearchByHashObject.ts} +2 -1
  88. package/dataLayer/{SearchObject.js → SearchObject.ts} +2 -1
  89. package/dataLayer/{SqlSearchObject.js → SqlSearchObject.ts} +2 -1
  90. package/dataLayer/{UpdateObject.js → UpdateObject.ts} +3 -2
  91. package/dataLayer/{UpsertObject.js → UpsertObject.ts} +3 -2
  92. package/dataLayer/{bulkLoad.js → bulkLoad.ts} +40 -49
  93. package/dataLayer/{delete.js → delete.ts} +21 -26
  94. package/dataLayer/{export.js → export.ts} +22 -26
  95. package/dataLayer/{getBackup.js → getBackup.ts} +7 -9
  96. package/dataLayer/harperBridge/BridgeMethods.ts +102 -0
  97. package/dataLayer/harperBridge/ResourceBridge.ts +27 -26
  98. package/dataLayer/harperBridge/TableSizeObject.ts +1 -0
  99. package/dataLayer/harperBridge/bridgeUtility/insertUpdateValidate.js +4 -4
  100. package/dataLayer/harperBridge/{harperBridge.js → harperBridge.ts} +3 -3
  101. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.js +8 -6
  102. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.js +4 -4
  103. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateSchema.js +1 -1
  104. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateTable.js +6 -4
  105. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteAuditLogsBefore.js +5 -4
  106. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteRecords.js +4 -4
  107. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.js +6 -5
  108. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropSchema.js +5 -4
  109. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropTable.js +5 -5
  110. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbFlush.js +1 -1
  111. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetBackup.js +3 -3
  112. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByHash.js +1 -1
  113. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByValue.js +3 -2
  114. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbReadAuditLog.js +5 -5
  115. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.js +10 -8
  116. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByHash.js +1 -1
  117. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.js +4 -3
  118. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpdateRecords.js +3 -3
  119. package/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.js +6 -5
  120. package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.js +2 -1
  121. package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializeHashSearch.js +3 -2
  122. package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializePaths.js +2 -2
  123. package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCheckForNewAttributes.js +5 -4
  124. package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsAuditEnvironment.js +6 -3
  125. package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.ts +1 -1
  126. package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.js +4 -4
  127. package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbSearch.js +5 -5
  128. package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbWriteTransaction.js +4 -4
  129. package/dataLayer/{hdbInfoController.js → hdbInfoController.ts} +20 -26
  130. package/dataLayer/{insert.js → insert.ts} +24 -24
  131. package/dataLayer/{readAuditLog.js → readAuditLog.ts} +8 -10
  132. package/dataLayer/{schema.js → schema.ts} +32 -44
  133. package/dataLayer/{schemaDescribe.js → schemaDescribe.ts} +23 -26
  134. package/dataLayer/{search.js → search.ts} +9 -15
  135. package/dataLayer/{transaction.js → transaction.ts} +2 -5
  136. package/dataLayer/{update.js → update.ts} +19 -22
  137. package/dist/agent/agent.d.ts +35 -0
  138. package/dist/agent/agent.js +175 -0
  139. package/dist/agent/agent.js.map +1 -0
  140. package/dist/agent/loop.d.ts +34 -0
  141. package/dist/agent/loop.js +176 -0
  142. package/dist/agent/loop.js.map +1 -0
  143. package/dist/agent/operations.d.ts +17 -0
  144. package/dist/agent/operations.js +137 -0
  145. package/dist/agent/operations.js.map +1 -0
  146. package/dist/agent/session.d.ts +36 -0
  147. package/dist/agent/session.js +182 -0
  148. package/dist/agent/session.js.map +1 -0
  149. package/dist/agent/tools/fsTools.d.ts +19 -0
  150. package/dist/agent/tools/fsTools.js +286 -0
  151. package/dist/agent/tools/fsTools.js.map +1 -0
  152. package/dist/agent/tools/httpFetchTool.d.ts +9 -0
  153. package/dist/agent/tools/httpFetchTool.js +116 -0
  154. package/dist/agent/tools/httpFetchTool.js.map +1 -0
  155. package/dist/agent/tools/scheduleTool.d.ts +22 -0
  156. package/dist/agent/tools/scheduleTool.js +54 -0
  157. package/dist/agent/tools/scheduleTool.js.map +1 -0
  158. package/dist/agent/toolset.d.ts +24 -0
  159. package/dist/agent/toolset.js +33 -0
  160. package/dist/agent/toolset.js.map +1 -0
  161. package/dist/agent/types.d.ts +75 -0
  162. package/dist/agent/types.js +10 -0
  163. package/dist/agent/types.js.map +1 -0
  164. package/dist/bin/BinObjects.d.ts +2 -2
  165. package/dist/bin/BinObjects.js +6 -3
  166. package/dist/bin/BinObjects.js.map +1 -1
  167. package/dist/bin/cliCredentials.d.ts +27 -0
  168. package/dist/bin/cliCredentials.js +130 -0
  169. package/dist/bin/cliCredentials.js.map +1 -0
  170. package/dist/bin/cliOperations.d.ts +7 -7
  171. package/dist/bin/cliOperations.js +251 -37
  172. package/dist/bin/cliOperations.js.map +1 -1
  173. package/dist/bin/copyDb.js +16 -16
  174. package/dist/bin/copyDb.js.map +1 -1
  175. package/dist/bin/deployRenderer.d.ts +47 -0
  176. package/dist/bin/deployRenderer.js +185 -0
  177. package/dist/bin/deployRenderer.js.map +1 -0
  178. package/dist/bin/harper.d.ts +2 -1
  179. package/dist/bin/harper.js +87 -26
  180. package/dist/bin/harper.js.map +1 -1
  181. package/dist/bin/install.d.ts +1 -1
  182. package/dist/bin/install.js +41 -4
  183. package/dist/bin/install.js.map +1 -1
  184. package/dist/bin/lite.js +3 -4
  185. package/dist/bin/lite.js.map +1 -1
  186. package/dist/bin/login.d.ts +4 -0
  187. package/dist/bin/login.js +123 -0
  188. package/dist/bin/login.js.map +1 -0
  189. package/dist/bin/logout.d.ts +4 -0
  190. package/dist/bin/logout.js +16 -0
  191. package/dist/bin/logout.js.map +1 -0
  192. package/dist/bin/mcp/client.d.ts +34 -0
  193. package/dist/bin/mcp/client.js +395 -0
  194. package/dist/bin/mcp/client.js.map +1 -0
  195. package/dist/bin/mcp/doctor.d.ts +11 -0
  196. package/dist/bin/mcp/doctor.js +193 -0
  197. package/dist/bin/mcp/doctor.js.map +1 -0
  198. package/dist/bin/mcp/index.d.ts +10 -0
  199. package/dist/bin/mcp/index.js +81 -0
  200. package/dist/bin/mcp/index.js.map +1 -0
  201. package/dist/bin/mcp/options.d.ts +33 -0
  202. package/dist/bin/mcp/options.js +113 -0
  203. package/dist/bin/mcp/options.js.map +1 -0
  204. package/dist/bin/mcp/printConfig.d.ts +14 -0
  205. package/dist/bin/mcp/printConfig.js +85 -0
  206. package/dist/bin/mcp/printConfig.js.map +1 -0
  207. package/dist/bin/multipartBuilder.d.ts +26 -0
  208. package/dist/bin/multipartBuilder.js +55 -0
  209. package/dist/bin/multipartBuilder.js.map +1 -0
  210. package/dist/bin/restart.d.ts +3 -2
  211. package/dist/bin/restart.js +82 -45
  212. package/dist/bin/restart.js.map +1 -1
  213. package/dist/bin/run.d.ts +13 -9
  214. package/dist/bin/run.js +111 -65
  215. package/dist/bin/run.js.map +1 -1
  216. package/dist/bin/sseConsumer.d.ts +24 -0
  217. package/dist/bin/sseConsumer.js +127 -0
  218. package/dist/bin/sseConsumer.js.map +1 -0
  219. package/dist/bin/status.d.ts +1 -1
  220. package/dist/bin/status.js +48 -11
  221. package/dist/bin/status.js.map +1 -1
  222. package/dist/bin/stop.d.ts +1 -1
  223. package/dist/bin/stop.js +43 -6
  224. package/dist/bin/stop.js.map +1 -1
  225. package/dist/bin/upgrade.js +14 -22
  226. package/dist/bin/upgrade.js.map +1 -1
  227. package/dist/components/Application.d.ts +29 -17
  228. package/dist/components/Application.js +134 -28
  229. package/dist/components/Application.js.map +1 -1
  230. package/dist/components/ApplicationScope.js +2 -2
  231. package/dist/components/ComponentV1.d.ts +1 -1
  232. package/dist/components/ComponentV1.js +5 -5
  233. package/dist/components/ComponentV1.js.map +1 -1
  234. package/dist/components/EntryHandler.d.ts +26 -3
  235. package/dist/components/EntryHandler.js +153 -13
  236. package/dist/components/EntryHandler.js.map +1 -1
  237. package/dist/components/OptionsWatcher.d.ts +7 -2
  238. package/dist/components/OptionsWatcher.js +72 -10
  239. package/dist/components/OptionsWatcher.js.map +1 -1
  240. package/dist/components/Scope.d.ts +11 -6
  241. package/dist/components/Scope.js +112 -12
  242. package/dist/components/Scope.js.map +1 -1
  243. package/dist/components/anthropic/index.d.ts +40 -0
  244. package/dist/components/anthropic/index.js +428 -0
  245. package/dist/components/anthropic/index.js.map +1 -0
  246. package/dist/components/bedrock/index.d.ts +79 -0
  247. package/dist/components/bedrock/index.js +734 -0
  248. package/dist/components/bedrock/index.js.map +1 -0
  249. package/dist/components/componentLoader.d.ts +29 -0
  250. package/dist/components/componentLoader.js +65 -38
  251. package/dist/components/componentLoader.js.map +1 -1
  252. package/dist/components/deployLifecycle.d.ts +39 -0
  253. package/dist/components/deployLifecycle.js +156 -0
  254. package/dist/components/deployLifecycle.js.map +1 -0
  255. package/dist/components/deploymentOperations.d.ts +19 -0
  256. package/dist/components/deploymentOperations.js +185 -0
  257. package/dist/components/deploymentOperations.js.map +1 -0
  258. package/dist/components/deploymentRecorder.d.ts +97 -0
  259. package/dist/components/deploymentRecorder.js +425 -0
  260. package/dist/components/deploymentRecorder.js.map +1 -0
  261. package/dist/components/deriveURLPath.d.ts +2 -2
  262. package/dist/components/deriveURLPath.js +2 -2
  263. package/dist/components/deriveURLPath.js.map +1 -1
  264. package/dist/components/mcp/adapters/fastify.d.ts +35 -0
  265. package/dist/components/mcp/adapters/fastify.js +66 -0
  266. package/dist/components/mcp/adapters/fastify.js.map +1 -0
  267. package/dist/components/mcp/adapters/harperHttp.d.ts +38 -0
  268. package/dist/components/mcp/adapters/harperHttp.js +78 -0
  269. package/dist/components/mcp/adapters/harperHttp.js.map +1 -0
  270. package/dist/components/mcp/audit.d.ts +27 -0
  271. package/dist/components/mcp/audit.js +73 -0
  272. package/dist/components/mcp/audit.js.map +1 -0
  273. package/dist/components/mcp/index.d.ts +47 -0
  274. package/dist/components/mcp/index.js +109 -0
  275. package/dist/components/mcp/index.js.map +1 -0
  276. package/dist/components/mcp/jsonrpc.d.ts +71 -0
  277. package/dist/components/mcp/jsonrpc.js +93 -0
  278. package/dist/components/mcp/jsonrpc.js.map +1 -0
  279. package/dist/components/mcp/lifecycle.d.ts +69 -0
  280. package/dist/components/mcp/lifecycle.js +79 -0
  281. package/dist/components/mcp/lifecycle.js.map +1 -0
  282. package/dist/components/mcp/listChanged.d.ts +24 -0
  283. package/dist/components/mcp/listChanged.js +257 -0
  284. package/dist/components/mcp/listChanged.js.map +1 -0
  285. package/dist/components/mcp/rateLimit.d.ts +25 -0
  286. package/dist/components/mcp/rateLimit.js +226 -0
  287. package/dist/components/mcp/rateLimit.js.map +1 -0
  288. package/dist/components/mcp/resources.d.ts +90 -0
  289. package/dist/components/mcp/resources.js +526 -0
  290. package/dist/components/mcp/resources.js.map +1 -0
  291. package/dist/components/mcp/session.d.ts +36 -0
  292. package/dist/components/mcp/session.js +170 -0
  293. package/dist/components/mcp/session.js.map +1 -0
  294. package/dist/components/mcp/sessionRegistry.d.ts +63 -0
  295. package/dist/components/mcp/sessionRegistry.js +124 -0
  296. package/dist/components/mcp/sessionRegistry.js.map +1 -0
  297. package/dist/components/mcp/toolRegistry.d.ts +151 -0
  298. package/dist/components/mcp/toolRegistry.js +177 -0
  299. package/dist/components/mcp/toolRegistry.js.map +1 -0
  300. package/dist/components/mcp/tools/application.d.ts +72 -0
  301. package/dist/components/mcp/tools/application.js +660 -0
  302. package/dist/components/mcp/tools/application.js.map +1 -0
  303. package/dist/components/mcp/tools/operations.d.ts +23 -0
  304. package/dist/components/mcp/tools/operations.js +331 -0
  305. package/dist/components/mcp/tools/operations.js.map +1 -0
  306. package/dist/components/mcp/tools/schemas/derive.d.ts +50 -0
  307. package/dist/components/mcp/tools/schemas/derive.js +291 -0
  308. package/dist/components/mcp/tools/schemas/derive.js.map +1 -0
  309. package/dist/components/mcp/tools/schemas/operationDescriptions.d.ts +32 -0
  310. package/dist/components/mcp/tools/schemas/operationDescriptions.js +179 -0
  311. package/dist/components/mcp/tools/schemas/operationDescriptions.js.map +1 -0
  312. package/dist/components/mcp/tools/schemas/operations.d.ts +27 -0
  313. package/dist/components/mcp/tools/schemas/operations.js +299 -0
  314. package/dist/components/mcp/tools/schemas/operations.js.map +1 -0
  315. package/dist/components/mcp/transport.d.ts +38 -0
  316. package/dist/components/mcp/transport.js +467 -0
  317. package/dist/components/mcp/transport.js.map +1 -0
  318. package/dist/components/ollama/index.d.ts +46 -0
  319. package/dist/components/ollama/index.js +239 -0
  320. package/dist/components/ollama/index.js.map +1 -0
  321. package/dist/components/openai/index.d.ts +51 -0
  322. package/dist/components/openai/index.js +475 -0
  323. package/dist/components/openai/index.js.map +1 -0
  324. package/dist/components/operations.d.ts +6 -6
  325. package/dist/components/operations.js +205 -52
  326. package/dist/components/operations.js.map +1 -1
  327. package/dist/components/operationsValidation.d.ts +2 -2
  328. package/dist/components/operationsValidation.js +13 -4
  329. package/dist/components/operationsValidation.js.map +1 -1
  330. package/dist/components/packageComponent.d.ts +28 -6
  331. package/dist/components/packageComponent.js +87 -26
  332. package/dist/components/packageComponent.js.map +1 -1
  333. package/dist/components/requestRestart.d.ts +1 -0
  334. package/dist/components/requestRestart.js +12 -1
  335. package/dist/components/requestRestart.js.map +1 -1
  336. package/dist/components/status/crossThread.d.ts +5 -1
  337. package/dist/components/status/crossThread.js +12 -5
  338. package/dist/components/status/crossThread.js.map +1 -1
  339. package/dist/components/status/errors.js +7 -7
  340. package/dist/config/RootConfigWatcher.d.ts +3 -0
  341. package/dist/config/RootConfigWatcher.js +52 -1
  342. package/dist/config/RootConfigWatcher.js.map +1 -1
  343. package/dist/config/configUtils.js +31 -8
  344. package/dist/config/configUtils.js.map +1 -1
  345. package/dist/config/harperConfigEnvVars.js +1 -1
  346. package/dist/config/harperConfigEnvVars.js.map +1 -1
  347. package/dist/dataLayer/CreateAttributeObject.d.ts +3 -7
  348. package/dist/dataLayer/CreateAttributeObject.js +4 -3
  349. package/dist/dataLayer/CreateAttributeObject.js.map +1 -1
  350. package/dist/dataLayer/CreateTableObject.d.ts +2 -4
  351. package/dist/dataLayer/CreateTableObject.js +2 -1
  352. package/dist/dataLayer/CreateTableObject.js.map +1 -1
  353. package/dist/dataLayer/DataLayerObjects.d.ts +17 -16
  354. package/dist/dataLayer/DataLayerObjects.js +19 -5
  355. package/dist/dataLayer/DataLayerObjects.js.map +1 -1
  356. package/dist/dataLayer/DeleteBeforeObject.d.ts +3 -5
  357. package/dist/dataLayer/DeleteBeforeObject.js +2 -1
  358. package/dist/dataLayer/DeleteBeforeObject.js.map +1 -1
  359. package/dist/dataLayer/DeleteObject.d.ts +3 -7
  360. package/dist/dataLayer/DeleteObject.js +4 -3
  361. package/dist/dataLayer/DeleteObject.js.map +1 -1
  362. package/dist/dataLayer/DropAttributeObject.d.ts +2 -4
  363. package/dist/dataLayer/DropAttributeObject.js +2 -1
  364. package/dist/dataLayer/DropAttributeObject.js.map +1 -1
  365. package/dist/dataLayer/GetBackupObject.d.ts +3 -5
  366. package/dist/dataLayer/GetBackupObject.js +4 -3
  367. package/dist/dataLayer/GetBackupObject.js.map +1 -1
  368. package/dist/dataLayer/InsertObject.d.ts +3 -8
  369. package/dist/dataLayer/InsertObject.js +4 -3
  370. package/dist/dataLayer/InsertObject.js.map +1 -1
  371. package/dist/dataLayer/ReadAuditLogObject.d.ts +3 -7
  372. package/dist/dataLayer/ReadAuditLogObject.js +4 -3
  373. package/dist/dataLayer/ReadAuditLogObject.js.map +1 -1
  374. package/dist/dataLayer/SQLSearch.d.ts +68 -38
  375. package/dist/dataLayer/SQLSearch.js +140 -78
  376. package/dist/dataLayer/SQLSearch.js.map +1 -1
  377. package/dist/dataLayer/SearchByConditionsObject.d.ts +10 -58
  378. package/dist/dataLayer/SearchByConditionsObject.js +5 -7
  379. package/dist/dataLayer/SearchByConditionsObject.js.map +1 -1
  380. package/dist/dataLayer/SearchByHashObject.d.ts +3 -6
  381. package/dist/dataLayer/SearchByHashObject.js +2 -1
  382. package/dist/dataLayer/SearchByHashObject.js.map +1 -1
  383. package/dist/dataLayer/SearchObject.d.ts +3 -12
  384. package/dist/dataLayer/SearchObject.js +2 -1
  385. package/dist/dataLayer/SearchObject.js.map +1 -1
  386. package/dist/dataLayer/SqlSearchObject.d.ts +2 -4
  387. package/dist/dataLayer/SqlSearchObject.js +2 -1
  388. package/dist/dataLayer/SqlSearchObject.js.map +1 -1
  389. package/dist/dataLayer/UpdateObject.d.ts +3 -7
  390. package/dist/dataLayer/UpdateObject.js +4 -3
  391. package/dist/dataLayer/UpdateObject.js.map +1 -1
  392. package/dist/dataLayer/UpsertObject.d.ts +3 -7
  393. package/dist/dataLayer/UpsertObject.js +4 -3
  394. package/dist/dataLayer/UpsertObject.js.map +1 -1
  395. package/dist/dataLayer/bulkLoad.d.ts +4 -4
  396. package/dist/dataLayer/bulkLoad.js +122 -88
  397. package/dist/dataLayer/bulkLoad.js.map +1 -1
  398. package/dist/dataLayer/delete.d.ts +10 -11
  399. package/dist/dataLayer/delete.js +74 -39
  400. package/dist/dataLayer/delete.js.map +1 -1
  401. package/dist/dataLayer/export.d.ts +8 -8
  402. package/dist/dataLayer/export.js +90 -55
  403. package/dist/dataLayer/export.js.map +1 -1
  404. package/dist/dataLayer/getBackup.d.ts +4 -3
  405. package/dist/dataLayer/getBackup.js +43 -11
  406. package/dist/dataLayer/getBackup.js.map +1 -1
  407. package/dist/dataLayer/harperBridge/BridgeMethods.d.ts +39 -21
  408. package/dist/dataLayer/harperBridge/BridgeMethods.js +41 -20
  409. package/dist/dataLayer/harperBridge/BridgeMethods.js.map +1 -1
  410. package/dist/dataLayer/harperBridge/ResourceBridge.d.ts +2 -2
  411. package/dist/dataLayer/harperBridge/ResourceBridge.js +26 -25
  412. package/dist/dataLayer/harperBridge/ResourceBridge.js.map +1 -1
  413. package/dist/dataLayer/harperBridge/TableSizeObject.d.ts +1 -0
  414. package/dist/dataLayer/harperBridge/TableSizeObject.js.map +1 -1
  415. package/dist/dataLayer/harperBridge/bridgeUtility/insertUpdateValidate.d.ts +4 -4
  416. package/dist/dataLayer/harperBridge/bridgeUtility/insertUpdateValidate.js +4 -4
  417. package/dist/dataLayer/harperBridge/harperBridge.d.ts +2 -3
  418. package/dist/dataLayer/harperBridge/harperBridge.js +38 -4
  419. package/dist/dataLayer/harperBridge/harperBridge.js.map +1 -1
  420. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.d.ts +1 -2
  421. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.js +7 -6
  422. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.js.map +1 -1
  423. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.d.ts +1 -2
  424. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.js +4 -4
  425. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.js.map +1 -1
  426. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateSchema.js +1 -1
  427. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateSchema.js.map +1 -1
  428. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateTable.js +5 -4
  429. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateTable.js.map +1 -1
  430. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteAuditLogsBefore.d.ts +1 -2
  431. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteAuditLogsBefore.js +4 -4
  432. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteAuditLogsBefore.js.map +1 -1
  433. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteRecords.js +4 -4
  434. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.d.ts +1 -2
  435. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.js +5 -5
  436. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.js.map +1 -1
  437. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropSchema.js +4 -4
  438. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropSchema.js.map +1 -1
  439. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropTable.js +5 -5
  440. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropTable.js.map +1 -1
  441. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbFlush.js +1 -1
  442. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetBackup.js +3 -3
  443. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByHash.js +1 -1
  444. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByValue.js +2 -2
  445. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByValue.js.map +1 -1
  446. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbReadAuditLog.js +5 -5
  447. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.d.ts +1 -2
  448. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.js +8 -8
  449. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.js.map +1 -1
  450. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByHash.d.ts +1 -1
  451. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByHash.js +1 -1
  452. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.d.ts +1 -2
  453. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.js +3 -3
  454. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.js.map +1 -1
  455. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpdateRecords.js +3 -3
  456. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.d.ts +1 -2
  457. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.js +5 -5
  458. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.js.map +1 -1
  459. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.d.ts +1 -2
  460. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.js +1 -1
  461. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.js.map +1 -1
  462. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializeHashSearch.js +2 -2
  463. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializeHashSearch.js.map +1 -1
  464. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/initializePaths.js +2 -2
  465. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCheckForNewAttributes.js +4 -4
  466. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCheckForNewAttributes.js.map +1 -1
  467. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsAuditEnvironment.d.ts +1 -2
  468. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsAuditEnvironment.js +5 -3
  469. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsAuditEnvironment.js.map +1 -1
  470. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js +2 -2
  471. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.d.ts +1 -2
  472. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.js +4 -4
  473. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.js.map +1 -1
  474. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbSearch.js +5 -5
  475. package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbWriteTransaction.js +4 -4
  476. package/dist/dataLayer/hdbInfoController.d.ts +4 -8
  477. package/dist/dataLayer/hdbInfoController.js +66 -31
  478. package/dist/dataLayer/hdbInfoController.js.map +1 -1
  479. package/dist/dataLayer/insert.d.ts +14 -26
  480. package/dist/dataLayer/insert.js +63 -28
  481. package/dist/dataLayer/insert.js.map +1 -1
  482. package/dist/dataLayer/readAuditLog.d.ts +1 -3
  483. package/dist/dataLayer/readAuditLog.js +45 -13
  484. package/dist/dataLayer/readAuditLog.js.map +1 -1
  485. package/dist/dataLayer/schema.d.ts +10 -10
  486. package/dist/dataLayer/schema.js +124 -89
  487. package/dist/dataLayer/schema.js.map +1 -1
  488. package/dist/dataLayer/schemaDescribe.d.ts +4 -4
  489. package/dist/dataLayer/schemaDescribe.js +78 -41
  490. package/dist/dataLayer/schemaDescribe.js.map +1 -1
  491. package/dist/dataLayer/search.d.ts +4 -4
  492. package/dist/dataLayer/search.js +12 -13
  493. package/dist/dataLayer/search.js.map +1 -1
  494. package/dist/dataLayer/transaction.d.ts +1 -1
  495. package/dist/dataLayer/transaction.js +3 -4
  496. package/dist/dataLayer/transaction.js.map +1 -1
  497. package/dist/dataLayer/update.d.ts +2 -8
  498. package/dist/dataLayer/update.js +53 -18
  499. package/dist/dataLayer/update.js.map +1 -1
  500. package/dist/globals.d.ts +1 -1
  501. package/dist/globals.js +1 -0
  502. package/dist/globals.js.map +1 -1
  503. package/dist/index.d.ts +4 -0
  504. package/dist/index.js +4 -1
  505. package/dist/index.js.map +1 -1
  506. package/dist/json/systemSchema.json +65 -0
  507. package/dist/launchServiceScripts/launchHarperDB.d.ts +1 -0
  508. package/dist/launchServiceScripts/launchHarperDB.js +3 -0
  509. package/dist/launchServiceScripts/launchHarperDB.js.map +1 -0
  510. package/dist/launchServiceScripts/utility/checkNodeVersion.js +3 -0
  511. package/dist/launchServiceScripts/utility/checkNodeVersion.js.map +1 -1
  512. package/dist/resources/DatabaseTransaction.d.ts +14 -6
  513. package/dist/resources/DatabaseTransaction.js +39 -15
  514. package/dist/resources/DatabaseTransaction.js.map +1 -1
  515. package/dist/resources/ErrorResource.d.ts +1 -1
  516. package/dist/resources/ErrorResource.js +3 -1
  517. package/dist/resources/ErrorResource.js.map +1 -1
  518. package/dist/resources/LMDBTransaction.d.ts +10 -13
  519. package/dist/resources/LMDBTransaction.js +18 -7
  520. package/dist/resources/LMDBTransaction.js.map +1 -1
  521. package/dist/resources/RecordEncoder.d.ts +10 -12
  522. package/dist/resources/RecordEncoder.js +38 -38
  523. package/dist/resources/RecordEncoder.js.map +1 -1
  524. package/dist/resources/RequestTarget.d.ts +1 -0
  525. package/dist/resources/RequestTarget.js.map +1 -1
  526. package/dist/resources/Resource.d.ts +25 -5
  527. package/dist/resources/Resource.js +43 -10
  528. package/dist/resources/Resource.js.map +1 -1
  529. package/dist/resources/ResourceInterface.d.ts +24 -5
  530. package/dist/resources/ResourceInterface.js +20 -0
  531. package/dist/resources/ResourceInterface.js.map +1 -1
  532. package/dist/resources/Resources.d.ts +3 -4
  533. package/dist/resources/Resources.js +7 -6
  534. package/dist/resources/Resources.js.map +1 -1
  535. package/dist/resources/RocksIndexStore.js +3 -0
  536. package/dist/resources/RocksIndexStore.js.map +1 -1
  537. package/dist/resources/RocksTransactionLogStore.d.ts +1 -1
  538. package/dist/resources/RocksTransactionLogStore.js +10 -3
  539. package/dist/resources/RocksTransactionLogStore.js.map +1 -1
  540. package/dist/resources/Table.d.ts +76 -329
  541. package/dist/resources/Table.js +306 -116
  542. package/dist/resources/Table.js.map +1 -1
  543. package/dist/resources/analytics/metadata.d.ts +1 -0
  544. package/dist/resources/analytics/metadata.js +1 -0
  545. package/dist/resources/analytics/metadata.js.map +1 -1
  546. package/dist/resources/analytics/read.d.ts +8 -1
  547. package/dist/resources/analytics/read.js +69 -8
  548. package/dist/resources/analytics/read.js.map +1 -1
  549. package/dist/resources/analytics/write.d.ts +28 -0
  550. package/dist/resources/analytics/write.js +232 -20
  551. package/dist/resources/analytics/write.js.map +1 -1
  552. package/dist/resources/auditStore.d.ts +18 -13
  553. package/dist/resources/auditStore.js +16 -8
  554. package/dist/resources/auditStore.js.map +1 -1
  555. package/dist/resources/blob.d.ts +16 -27
  556. package/dist/resources/blob.js +8 -8
  557. package/dist/resources/blob.js.map +1 -1
  558. package/dist/resources/dataLoader.d.ts +1 -1
  559. package/dist/resources/dataLoader.js +13 -13
  560. package/dist/resources/databases.d.ts +17 -0
  561. package/dist/resources/databases.js +175 -59
  562. package/dist/resources/databases.js.map +1 -1
  563. package/dist/resources/graphql.d.ts +1 -7
  564. package/dist/resources/graphql.js +267 -173
  565. package/dist/resources/graphql.js.map +1 -1
  566. package/dist/resources/indexes/HierarchicalNavigableSmallWorld.d.ts +17 -1
  567. package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js +327 -59
  568. package/dist/resources/indexes/HierarchicalNavigableSmallWorld.js.map +1 -1
  569. package/dist/resources/indexes/vector.d.ts +1 -0
  570. package/dist/resources/indexes/vector.js +14 -0
  571. package/dist/resources/indexes/vector.js.map +1 -1
  572. package/dist/resources/jsonSchemaTypes.d.ts +60 -0
  573. package/dist/resources/jsonSchemaTypes.js +78 -0
  574. package/dist/resources/jsonSchemaTypes.js.map +1 -0
  575. package/dist/resources/loadEnv.d.ts +2 -5
  576. package/dist/resources/loadEnv.js +21 -18
  577. package/dist/resources/loadEnv.js.map +1 -1
  578. package/dist/resources/login.d.ts +2 -3
  579. package/dist/resources/login.js +5 -4
  580. package/dist/resources/login.js.map +1 -1
  581. package/dist/resources/models/Models.d.ts +45 -0
  582. package/dist/resources/models/Models.js +265 -0
  583. package/dist/resources/models/Models.js.map +1 -0
  584. package/dist/resources/models/TestBackend.d.ts +15 -0
  585. package/dist/resources/models/TestBackend.js +71 -0
  586. package/dist/resources/models/TestBackend.js.map +1 -0
  587. package/dist/resources/models/agentLoop.d.ts +125 -0
  588. package/dist/resources/models/agentLoop.js +746 -0
  589. package/dist/resources/models/agentLoop.js.map +1 -0
  590. package/dist/resources/models/analyticsTable.d.ts +65 -0
  591. package/dist/resources/models/analyticsTable.js +166 -0
  592. package/dist/resources/models/analyticsTable.js.map +1 -0
  593. package/dist/resources/models/backendHelpers.d.ts +57 -0
  594. package/dist/resources/models/backendHelpers.js +109 -0
  595. package/dist/resources/models/backendHelpers.js.map +1 -0
  596. package/dist/resources/models/backendRegistry.d.ts +36 -0
  597. package/dist/resources/models/backendRegistry.js +54 -0
  598. package/dist/resources/models/backendRegistry.js.map +1 -0
  599. package/dist/resources/models/bootstrap.d.ts +24 -0
  600. package/dist/resources/models/bootstrap.js +112 -0
  601. package/dist/resources/models/bootstrap.js.map +1 -0
  602. package/dist/resources/models/embedHook.d.ts +33 -0
  603. package/dist/resources/models/embedHook.js +127 -0
  604. package/dist/resources/models/embedHook.js.map +1 -0
  605. package/dist/resources/models/types.d.ts +301 -0
  606. package/dist/resources/models/types.js +11 -0
  607. package/dist/resources/models/types.js.map +1 -0
  608. package/dist/resources/openApi.js +74 -34
  609. package/dist/resources/openApi.js.map +1 -1
  610. package/dist/resources/replayLogs.js +7 -1
  611. package/dist/resources/replayLogs.js.map +1 -1
  612. package/dist/resources/replayLogsGuards.d.ts +9 -0
  613. package/dist/resources/replayLogsGuards.js +47 -0
  614. package/dist/resources/replayLogsGuards.js.map +1 -1
  615. package/dist/resources/roles.d.ts +1 -7
  616. package/dist/resources/roles.js +67 -71
  617. package/dist/resources/roles.js.map +1 -1
  618. package/dist/resources/search.d.ts +18 -1
  619. package/dist/resources/search.js +349 -140
  620. package/dist/resources/search.js.map +1 -1
  621. package/dist/resources/tracked.d.ts +1 -1
  622. package/dist/resources/tracked.js +23 -15
  623. package/dist/resources/tracked.js.map +1 -1
  624. package/dist/resources/transaction.d.ts +1 -1
  625. package/dist/resources/transaction.js +1 -1
  626. package/dist/resources/transaction.js.map +1 -1
  627. package/dist/resources/transactionBroadcast.d.ts +1 -1
  628. package/dist/resources/transactionBroadcast.js.map +1 -1
  629. package/dist/security/auth.d.ts +1 -5
  630. package/dist/security/auth.js +34 -25
  631. package/dist/security/auth.js.map +1 -1
  632. package/dist/security/certificateVerification/crlVerification.js +7 -1
  633. package/dist/security/certificateVerification/crlVerification.js.map +1 -1
  634. package/dist/security/cryptoHash.d.ts +2 -2
  635. package/dist/security/cryptoHash.js +37 -5
  636. package/dist/security/cryptoHash.js.map +1 -1
  637. package/dist/security/data_objects/PermissionAttributeResponseObject.d.ts +3 -4
  638. package/dist/security/data_objects/PermissionAttributeResponseObject.js +4 -1
  639. package/dist/security/data_objects/PermissionAttributeResponseObject.js.map +1 -1
  640. package/dist/security/data_objects/PermissionResponseObject.d.ts +9 -9
  641. package/dist/security/data_objects/PermissionResponseObject.js +15 -8
  642. package/dist/security/data_objects/PermissionResponseObject.js.map +1 -1
  643. package/dist/security/data_objects/PermissionTableResponseObject.d.ts +5 -6
  644. package/dist/security/data_objects/PermissionTableResponseObject.js +6 -1
  645. package/dist/security/data_objects/PermissionTableResponseObject.js.map +1 -1
  646. package/dist/security/fastifyAuth.d.ts +2 -2
  647. package/dist/security/fastifyAuth.js +131 -22
  648. package/dist/security/fastifyAuth.js.map +1 -1
  649. package/dist/security/impersonation.js +15 -15
  650. package/dist/security/jsLoader.js +18 -5
  651. package/dist/security/jsLoader.js.map +1 -1
  652. package/dist/security/keys.d.ts +45 -48
  653. package/dist/security/keys.js +160 -114
  654. package/dist/security/keys.js.map +1 -1
  655. package/dist/security/permissionsTranslator.js +2 -2
  656. package/dist/security/role.d.ts +5 -5
  657. package/dist/security/role.js +70 -35
  658. package/dist/security/role.js.map +1 -1
  659. package/dist/security/tokenAuthentication.d.ts +13 -0
  660. package/dist/security/tokenAuthentication.js +57 -27
  661. package/dist/security/tokenAuthentication.js.map +1 -1
  662. package/dist/security/user.js +74 -38
  663. package/dist/security/user.js.map +1 -1
  664. package/dist/server/DurableSubscriptionsSession.d.ts +4 -2
  665. package/dist/server/DurableSubscriptionsSession.js +71 -55
  666. package/dist/server/DurableSubscriptionsSession.js.map +1 -1
  667. package/dist/server/REST.d.ts +1 -8
  668. package/dist/server/REST.js +17 -16
  669. package/dist/server/REST.js.map +1 -1
  670. package/dist/server/Server.d.ts +23 -4
  671. package/dist/server/Server.js +1 -1
  672. package/dist/server/Server.js.map +1 -1
  673. package/dist/server/fastifyRoutes/helpers/getCORSOptions.js +1 -1
  674. package/dist/server/fastifyRoutes/helpers/getHeaderTimeoutConfig.js +1 -1
  675. package/dist/server/fastifyRoutes/helpers/getServerOptions.js +1 -1
  676. package/dist/server/fastifyRoutes.d.ts +1 -4
  677. package/dist/server/fastifyRoutes.js +34 -30
  678. package/dist/server/fastifyRoutes.js.map +1 -1
  679. package/dist/server/graphqlQuerying.d.ts +1 -1
  680. package/dist/server/graphqlQuerying.js +8 -7
  681. package/dist/server/graphqlQuerying.js.map +1 -1
  682. package/dist/server/http.d.ts +9 -4
  683. package/dist/server/http.js +523 -47
  684. package/dist/server/http.js.map +1 -1
  685. package/dist/server/itc/serverHandlers.js +66 -15
  686. package/dist/server/itc/serverHandlers.js.map +1 -1
  687. package/dist/server/jobs/JobObject.d.ts +3 -3
  688. package/dist/server/jobs/JobObject.js +53 -7
  689. package/dist/server/jobs/JobObject.js.map +1 -1
  690. package/dist/server/jobs/jobProcess.js +64 -24
  691. package/dist/server/jobs/jobProcess.js.map +1 -1
  692. package/dist/server/jobs/jobRunner.d.ts +7 -6
  693. package/dist/server/jobs/jobRunner.js +68 -30
  694. package/dist/server/jobs/jobRunner.js.map +1 -1
  695. package/dist/server/jobs/jobs.d.ts +18 -7
  696. package/dist/server/jobs/jobs.js +93 -61
  697. package/dist/server/jobs/jobs.js.map +1 -1
  698. package/dist/server/loadRootComponents.js +1 -1
  699. package/dist/server/middlewareChain.d.ts +80 -0
  700. package/dist/server/middlewareChain.js +252 -0
  701. package/dist/server/middlewareChain.js.map +1 -0
  702. package/dist/server/mqtt.d.ts +1 -8
  703. package/dist/server/mqtt.js +22 -17
  704. package/dist/server/mqtt.js.map +1 -1
  705. package/dist/server/nodeName.js +46 -13
  706. package/dist/server/nodeName.js.map +1 -1
  707. package/dist/server/operationsServer.d.ts +2 -2
  708. package/dist/server/operationsServer.js +106 -33
  709. package/dist/server/operationsServer.js.map +1 -1
  710. package/dist/server/serverHelpers/Headers.d.ts +4 -4
  711. package/dist/server/serverHelpers/Headers.js +2 -0
  712. package/dist/server/serverHelpers/Headers.js.map +1 -1
  713. package/dist/server/serverHelpers/JSONStream.d.ts +7 -1
  714. package/dist/server/serverHelpers/JSONStream.js +12 -3
  715. package/dist/server/serverHelpers/JSONStream.js.map +1 -1
  716. package/dist/server/serverHelpers/Request.d.ts +106 -8
  717. package/dist/server/serverHelpers/Request.js +370 -9
  718. package/dist/server/serverHelpers/Request.js.map +1 -1
  719. package/dist/server/serverHelpers/contentTypes.d.ts +1 -1
  720. package/dist/server/serverHelpers/contentTypes.js +36 -7
  721. package/dist/server/serverHelpers/contentTypes.js.map +1 -1
  722. package/dist/server/serverHelpers/multipartParser.d.ts +21 -0
  723. package/dist/server/serverHelpers/multipartParser.js +142 -0
  724. package/dist/server/serverHelpers/multipartParser.js.map +1 -0
  725. package/dist/server/serverHelpers/progressEmitter.d.ts +25 -0
  726. package/dist/server/serverHelpers/progressEmitter.js +103 -0
  727. package/dist/server/serverHelpers/progressEmitter.js.map +1 -0
  728. package/dist/server/serverHelpers/serverHandlers.d.ts +1 -1
  729. package/dist/server/serverHelpers/serverHandlers.js +38 -7
  730. package/dist/server/serverHelpers/serverHandlers.js.map +1 -1
  731. package/dist/server/serverHelpers/serverUtilities.d.ts +4 -2
  732. package/dist/server/serverHelpers/serverUtilities.js +97 -93
  733. package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
  734. package/dist/server/static.js +8 -5
  735. package/dist/server/static.js.map +1 -1
  736. package/dist/server/status/index.js +3 -3
  737. package/dist/server/storageReclamation.d.ts +10 -0
  738. package/dist/server/storageReclamation.js +68 -9
  739. package/dist/server/storageReclamation.js.map +1 -1
  740. package/dist/server/threads/itc.js +7 -4
  741. package/dist/server/threads/itc.js.map +1 -1
  742. package/dist/server/threads/manageThreads.d.ts +1 -1
  743. package/dist/server/threads/manageThreads.js +110 -26
  744. package/dist/server/threads/manageThreads.js.map +1 -1
  745. package/dist/server/threads/socketRouter.d.ts +0 -1
  746. package/dist/server/threads/socketRouter.js +8 -271
  747. package/dist/server/threads/socketRouter.js.map +1 -1
  748. package/dist/server/threads/threadServer.d.ts +1 -0
  749. package/dist/server/threads/threadServer.js +360 -118
  750. package/dist/server/threads/threadServer.js.map +1 -1
  751. package/dist/server/threads/workerProcessGuard.d.ts +42 -0
  752. package/dist/server/threads/workerProcessGuard.js +114 -0
  753. package/dist/server/threads/workerProcessGuard.js.map +1 -0
  754. package/dist/server/throttle.js +17 -0
  755. package/dist/server/throttle.js.map +1 -1
  756. package/dist/sqlTranslator/SelectValidator.d.ts +21 -24
  757. package/dist/sqlTranslator/SelectValidator.js +86 -47
  758. package/dist/sqlTranslator/SelectValidator.js.map +1 -1
  759. package/dist/sqlTranslator/alasqlFunctionImporter.d.ts +6 -2
  760. package/dist/sqlTranslator/alasqlFunctionImporter.js +40 -3
  761. package/dist/sqlTranslator/alasqlFunctionImporter.js.map +1 -1
  762. package/dist/sqlTranslator/deleteTranslator.d.ts +4 -7
  763. package/dist/sqlTranslator/deleteTranslator.js +48 -14
  764. package/dist/sqlTranslator/deleteTranslator.js.map +1 -1
  765. package/dist/sqlTranslator/index.d.ts +10 -9
  766. package/dist/sqlTranslator/index.js +69 -30
  767. package/dist/sqlTranslator/index.js.map +1 -1
  768. package/dist/sqlTranslator/sql_statement_bucket.d.ts +10 -10
  769. package/dist/sqlTranslator/sql_statement_bucket.js +55 -13
  770. package/dist/sqlTranslator/sql_statement_bucket.js.map +1 -1
  771. package/dist/upgrade/UpgradeObjects.d.ts +2 -3
  772. package/dist/upgrade/UpgradeObjects.js +37 -4
  773. package/dist/upgrade/UpgradeObjects.js.map +1 -1
  774. package/dist/upgrade/directives/5-1-0.d.ts +6 -0
  775. package/dist/upgrade/directives/5-1-0.js +114 -0
  776. package/dist/upgrade/directives/5-1-0.js.map +1 -0
  777. package/dist/upgrade/directives/directivesController.d.ts +10 -10
  778. package/dist/upgrade/directives/directivesController.js +52 -11
  779. package/dist/upgrade/directives/directivesController.js.map +1 -1
  780. package/dist/upgrade/directivesManager.d.ts +1 -1
  781. package/dist/upgrade/directivesManager.js +53 -18
  782. package/dist/upgrade/directivesManager.js.map +1 -1
  783. package/dist/upgrade/upgradePrompt.d.ts +2 -8
  784. package/dist/upgrade/upgradePrompt.js +55 -60
  785. package/dist/upgrade/upgradePrompt.js.map +1 -1
  786. package/dist/upgrade/upgradeUtilities.d.ts +1 -1
  787. package/dist/upgrade/upgradeUtilities.js +37 -5
  788. package/dist/upgrade/upgradeUtilities.js.map +1 -1
  789. package/dist/utility/OperationFunctionCaller.d.ts +1 -1
  790. package/dist/utility/OperationFunctionCaller.js +45 -10
  791. package/dist/utility/OperationFunctionCaller.js.map +1 -1
  792. package/dist/utility/assignCmdEnvVariables.d.ts +1 -2
  793. package/dist/utility/assignCmdEnvVariables.js +8 -4
  794. package/dist/utility/assignCmdEnvVariables.js.map +1 -1
  795. package/dist/utility/common_utils.d.ts +80 -77
  796. package/dist/utility/common_utils.js +140 -79
  797. package/dist/utility/common_utils.js.map +1 -1
  798. package/dist/utility/environment/environmentManager.d.ts +12 -11
  799. package/dist/utility/environment/environmentManager.js +75 -29
  800. package/dist/utility/environment/environmentManager.js.map +1 -1
  801. package/dist/utility/environment/systemInformation.d.ts +4 -0
  802. package/dist/utility/environment/systemInformation.js +27 -16
  803. package/dist/utility/environment/systemInformation.js.map +1 -1
  804. package/dist/utility/errors/commonErrors.d.ts +192 -168
  805. package/dist/utility/errors/commonErrors.js +49 -18
  806. package/dist/utility/errors/commonErrors.js.map +1 -1
  807. package/dist/utility/errors/hdbError.d.ts +37 -51
  808. package/dist/utility/errors/hdbError.js +65 -26
  809. package/dist/utility/errors/hdbError.js.map +1 -1
  810. package/dist/utility/expandEnvVar.d.ts +61 -0
  811. package/dist/utility/expandEnvVar.js +113 -0
  812. package/dist/utility/expandEnvVar.js.map +1 -0
  813. package/dist/utility/functions/geo.js +2 -2
  814. package/dist/utility/functions/sql/alaSQLExtension.js +1 -1
  815. package/dist/utility/globalSchema.d.ts +13 -4
  816. package/dist/utility/globalSchema.js +14 -11
  817. package/dist/utility/globalSchema.js.map +1 -1
  818. package/dist/utility/hdbTerms.d.ts +54 -1
  819. package/dist/utility/hdbTerms.js +54 -1
  820. package/dist/utility/hdbTerms.js.map +1 -1
  821. package/dist/utility/install/checkJWTTokensExist.js +1 -1
  822. package/dist/utility/install/installer.d.ts +9 -12
  823. package/dist/utility/install/installer.js +117 -54
  824. package/dist/utility/install/installer.js.map +1 -1
  825. package/dist/utility/installation.js +3 -3
  826. package/dist/utility/lmdb/DBIDefinition.d.ts +4 -4
  827. package/dist/utility/lmdb/DBIDefinition.js +5 -1
  828. package/dist/utility/lmdb/DBIDefinition.js.map +1 -1
  829. package/dist/utility/lmdb/DeleteRecordsResponseObject.d.ts +3 -6
  830. package/dist/utility/lmdb/DeleteRecordsResponseObject.js +2 -1
  831. package/dist/utility/lmdb/DeleteRecordsResponseObject.js.map +1 -1
  832. package/dist/utility/lmdb/InsertRecordsResponseObject.d.ts +3 -5
  833. package/dist/utility/lmdb/InsertRecordsResponseObject.js +2 -1
  834. package/dist/utility/lmdb/InsertRecordsResponseObject.js.map +1 -1
  835. package/dist/utility/lmdb/OpenDBIObject.d.ts +12 -15
  836. package/dist/utility/lmdb/OpenDBIObject.js +68 -6
  837. package/dist/utility/lmdb/OpenDBIObject.js.map +1 -1
  838. package/dist/utility/lmdb/OpenEnvironmentObject.d.ts +5 -8
  839. package/dist/utility/lmdb/OpenEnvironmentObject.js +52 -4
  840. package/dist/utility/lmdb/OpenEnvironmentObject.js.map +1 -1
  841. package/dist/utility/lmdb/UpdateRecordsResponseObject.d.ts +3 -6
  842. package/dist/utility/lmdb/UpdateRecordsResponseObject.js +2 -1
  843. package/dist/utility/lmdb/UpdateRecordsResponseObject.js.map +1 -1
  844. package/dist/utility/lmdb/UpsertRecordsResponseObject.d.ts +3 -5
  845. package/dist/utility/lmdb/UpsertRecordsResponseObject.js +2 -1
  846. package/dist/utility/lmdb/UpsertRecordsResponseObject.js.map +1 -1
  847. package/dist/utility/lmdb/cleanLMDBMap.d.ts +1 -1
  848. package/dist/utility/lmdb/cleanLMDBMap.js +44 -7
  849. package/dist/utility/lmdb/cleanLMDBMap.js.map +1 -1
  850. package/dist/utility/lmdb/commonUtility.d.ts +8 -9
  851. package/dist/utility/lmdb/commonUtility.js +46 -17
  852. package/dist/utility/lmdb/commonUtility.js.map +1 -1
  853. package/dist/utility/lmdb/deleteUtility.d.ts +2 -3
  854. package/dist/utility/lmdb/deleteUtility.js +51 -16
  855. package/dist/utility/lmdb/deleteUtility.js.map +1 -1
  856. package/dist/utility/lmdb/environmentUtility.d.ts +69 -36
  857. package/dist/utility/lmdb/environmentUtility.js +91 -51
  858. package/dist/utility/lmdb/environmentUtility.js.map +1 -1
  859. package/dist/utility/lmdb/searchCursorFunctions.d.ts +19 -19
  860. package/dist/utility/lmdb/searchCursorFunctions.js +46 -14
  861. package/dist/utility/lmdb/searchCursorFunctions.js.map +1 -1
  862. package/dist/utility/lmdb/searchUtility.d.ts +142 -73
  863. package/dist/utility/lmdb/searchUtility.js +91 -55
  864. package/dist/utility/lmdb/searchUtility.js.map +1 -1
  865. package/dist/utility/lmdb/terms.d.ts +34 -34
  866. package/dist/utility/lmdb/terms.js +12 -22
  867. package/dist/utility/lmdb/terms.js.map +1 -1
  868. package/dist/utility/lmdb/writeUtility.d.ts +3 -6
  869. package/dist/utility/lmdb/writeUtility.js +61 -28
  870. package/dist/utility/lmdb/writeUtility.js.map +1 -1
  871. package/dist/utility/logging/harper_logger.d.ts +87 -103
  872. package/dist/utility/logging/harper_logger.js +177 -82
  873. package/dist/utility/logging/harper_logger.js.map +1 -1
  874. package/dist/utility/logging/logRotator.d.ts +2 -10
  875. package/dist/utility/logging/logRotator.js +67 -32
  876. package/dist/utility/logging/logRotator.js.map +1 -1
  877. package/dist/utility/logging/logger.js +4 -4
  878. package/dist/utility/logging/readLog.d.ts +1 -1
  879. package/dist/utility/logging/readLog.js +54 -17
  880. package/dist/utility/logging/readLog.js.map +1 -1
  881. package/dist/utility/logging/transactionLog.d.ts +2 -2
  882. package/dist/utility/logging/transactionLog.js +51 -16
  883. package/dist/utility/logging/transactionLog.js.map +1 -1
  884. package/dist/utility/mount_hdb.d.ts +1 -2
  885. package/dist/utility/mount_hdb.js +54 -17
  886. package/dist/utility/mount_hdb.js.map +1 -1
  887. package/dist/utility/npmUtilities.d.ts +1 -1
  888. package/dist/utility/npmUtilities.js +54 -19
  889. package/dist/utility/npmUtilities.js.map +1 -1
  890. package/dist/utility/operation_authorization.d.ts +36 -9
  891. package/dist/utility/operation_authorization.js +135 -86
  892. package/dist/utility/operation_authorization.js.map +1 -1
  893. package/dist/utility/packageUtils.d.ts +0 -2
  894. package/dist/utility/packageUtils.js +7 -17
  895. package/dist/utility/packageUtils.js.map +1 -1
  896. package/dist/utility/password.js +2 -2
  897. package/dist/utility/processManagement/processManagement.js +2 -2
  898. package/dist/utility/processManagement/servicesConfig.js +1 -1
  899. package/dist/utility/signalling.d.ts +2 -2
  900. package/dist/utility/signalling.js +51 -16
  901. package/dist/utility/signalling.js.map +1 -1
  902. package/dist/utility/watcherFallback.d.ts +36 -0
  903. package/dist/utility/watcherFallback.js +73 -0
  904. package/dist/utility/watcherFallback.js.map +1 -0
  905. package/dist/validation/analyticsValidator.d.ts +1 -0
  906. package/dist/validation/analyticsValidator.js +80 -0
  907. package/dist/validation/analyticsValidator.js.map +1 -0
  908. package/dist/validation/bulkDeleteValidator.d.ts +1 -2
  909. package/dist/validation/bulkDeleteValidator.js +49 -11
  910. package/dist/validation/bulkDeleteValidator.js.map +1 -1
  911. package/dist/validation/check_permissions.d.ts +1 -2
  912. package/dist/validation/check_permissions.js +38 -3
  913. package/dist/validation/check_permissions.js.map +1 -1
  914. package/dist/validation/common_validators.d.ts +20 -20
  915. package/dist/validation/common_validators.js +62 -31
  916. package/dist/validation/common_validators.js.map +1 -1
  917. package/dist/validation/configValidator.d.ts +4 -4
  918. package/dist/validation/configValidator.js +189 -54
  919. package/dist/validation/configValidator.js.map +1 -1
  920. package/dist/validation/deleteValidator.d.ts +1 -2
  921. package/dist/validation/deleteValidator.js +49 -11
  922. package/dist/validation/deleteValidator.js.map +1 -1
  923. package/dist/validation/fileLoadValidator.d.ts +4 -4
  924. package/dist/validation/fileLoadValidator.js +67 -32
  925. package/dist/validation/fileLoadValidator.js.map +1 -1
  926. package/dist/validation/insertValidator.d.ts +1 -2
  927. package/dist/validation/insertValidator.js +48 -10
  928. package/dist/validation/insertValidator.js.map +1 -1
  929. package/dist/validation/installValidator.d.ts +2 -2
  930. package/dist/validation/installValidator.js +47 -10
  931. package/dist/validation/installValidator.js.map +1 -1
  932. package/dist/validation/readLogValidator.d.ts +1 -2
  933. package/dist/validation/readLogValidator.js +60 -22
  934. package/dist/validation/readLogValidator.js.map +1 -1
  935. package/dist/validation/role_validation.d.ts +3 -3
  936. package/dist/validation/role_validation.js +55 -19
  937. package/dist/validation/role_validation.js.map +1 -1
  938. package/dist/validation/schemaMetadataValidator.d.ts +3 -4
  939. package/dist/validation/schemaMetadataValidator.js +11 -12
  940. package/dist/validation/schemaMetadataValidator.js.map +1 -1
  941. package/dist/validation/searchValidator.d.ts +1 -2
  942. package/dist/validation/searchValidator.js +82 -43
  943. package/dist/validation/searchValidator.js.map +1 -1
  944. package/dist/validation/statusValidator.d.ts +1 -1
  945. package/dist/validation/transactionLogValidator.d.ts +3 -3
  946. package/dist/validation/transactionLogValidator.js +52 -17
  947. package/dist/validation/transactionLogValidator.js.map +1 -1
  948. package/dist/validation/user_validation.d.ts +3 -3
  949. package/dist/validation/user_validation.js +38 -6
  950. package/dist/validation/user_validation.js.map +1 -1
  951. package/dist/validation/validationWrapper.d.ts +3 -3
  952. package/dist/validation/validationWrapper.js +4 -5
  953. package/dist/validation/validationWrapper.js.map +1 -1
  954. package/index.ts +5 -0
  955. package/json/systemSchema.json +65 -0
  956. package/launchServiceScripts/utility/checkNodeVersion.js +2 -0
  957. package/package.json +38 -24
  958. package/resources/DESIGN.md +98 -0
  959. package/resources/DatabaseTransaction.ts +58 -30
  960. package/resources/ErrorResource.ts +2 -1
  961. package/resources/LMDBTransaction.ts +38 -29
  962. package/resources/RecordEncoder.ts +41 -39
  963. package/resources/RequestTarget.ts +2 -0
  964. package/resources/Resource.ts +96 -56
  965. package/resources/ResourceInterface.ts +44 -21
  966. package/resources/Resources.ts +8 -8
  967. package/resources/RocksIndexStore.ts +3 -0
  968. package/resources/RocksTransactionLogStore.ts +13 -4
  969. package/resources/Table.ts +440 -223
  970. package/resources/analytics/metadata.ts +1 -0
  971. package/resources/analytics/read.ts +99 -10
  972. package/resources/analytics/write.ts +240 -17
  973. package/resources/auditStore.ts +30 -19
  974. package/resources/blob.ts +53 -53
  975. package/resources/dataLoader.ts +4 -4
  976. package/resources/databases.ts +208 -74
  977. package/resources/graphql.ts +267 -165
  978. package/resources/indexes/HierarchicalNavigableSmallWorld.ts +310 -65
  979. package/resources/indexes/vector.ts +17 -0
  980. package/resources/jsonSchemaTypes.ts +102 -0
  981. package/resources/loadEnv.ts +21 -17
  982. package/resources/login.ts +5 -3
  983. package/resources/models/Models.ts +304 -0
  984. package/resources/models/TestBackend.ts +83 -0
  985. package/resources/models/agentLoop.ts +895 -0
  986. package/resources/models/analyticsTable.ts +199 -0
  987. package/resources/models/backendHelpers.ts +116 -0
  988. package/resources/models/backendRegistry.ts +66 -0
  989. package/resources/models/bootstrap.ts +135 -0
  990. package/resources/models/embedHook.ts +138 -0
  991. package/resources/models/types.ts +296 -0
  992. package/resources/openApi.ts +65 -31
  993. package/resources/replayLogs.ts +20 -9
  994. package/resources/replayLogsGuards.ts +45 -0
  995. package/resources/roles.ts +62 -67
  996. package/resources/search.ts +355 -135
  997. package/resources/tracked.ts +18 -9
  998. package/resources/transaction.ts +8 -8
  999. package/resources/transactionBroadcast.ts +3 -3
  1000. package/schema.graphql +7 -0
  1001. package/security/auth.ts +35 -26
  1002. package/security/certificateVerification/crlVerification.ts +11 -4
  1003. package/security/{cryptoHash.js → cryptoHash.ts} +3 -8
  1004. package/security/data_objects/{PermissionAttributeResponseObject.js → PermissionAttributeResponseObject.ts} +4 -4
  1005. package/security/data_objects/{PermissionResponseObject.js → PermissionResponseObject.ts} +12 -11
  1006. package/security/data_objects/{PermissionTableResponseObject.js → PermissionTableResponseObject.ts} +6 -4
  1007. package/security/{fastifyAuth.js → fastifyAuth.ts} +93 -20
  1008. package/security/impersonation.ts +3 -3
  1009. package/security/jsLoader.ts +22 -8
  1010. package/security/{keys.js → keys.ts} +113 -121
  1011. package/security/permissionsTranslator.js +2 -2
  1012. package/security/{role.js → role.ts} +26 -33
  1013. package/security/tokenAuthentication.ts +34 -7
  1014. package/security/user.ts +26 -22
  1015. package/server/DESIGN.md +139 -0
  1016. package/server/DurableSubscriptionsSession.ts +67 -50
  1017. package/server/REST.ts +120 -107
  1018. package/server/Server.ts +31 -12
  1019. package/server/fastifyRoutes/helpers/getCORSOptions.js +1 -1
  1020. package/server/fastifyRoutes/helpers/getHeaderTimeoutConfig.js +1 -1
  1021. package/server/fastifyRoutes/helpers/getServerOptions.js +1 -1
  1022. package/server/fastifyRoutes.ts +37 -33
  1023. package/server/graphqlQuerying.ts +6 -5
  1024. package/server/http.ts +517 -26
  1025. package/server/itc/serverHandlers.js +75 -14
  1026. package/server/jobs/{JobObject.js → JobObject.ts} +13 -6
  1027. package/server/jobs/{jobProcess.js → jobProcess.ts} +20 -16
  1028. package/server/jobs/{jobRunner.js → jobRunner.ts} +20 -21
  1029. package/server/jobs/{jobs.js → jobs.ts} +41 -44
  1030. package/server/loadRootComponents.js +1 -1
  1031. package/server/middlewareChain.ts +270 -0
  1032. package/server/mqtt.ts +35 -26
  1033. package/server/nodeName.ts +3 -1
  1034. package/server/operationsServer.ts +85 -10
  1035. package/server/serverHelpers/Headers.ts +10 -8
  1036. package/server/serverHelpers/JSONStream.ts +15 -5
  1037. package/server/serverHelpers/Request.ts +370 -13
  1038. package/server/serverHelpers/contentTypes.ts +42 -11
  1039. package/server/serverHelpers/multipartParser.ts +152 -0
  1040. package/server/serverHelpers/progressEmitter.ts +110 -0
  1041. package/server/serverHelpers/serverHandlers.js +43 -7
  1042. package/server/serverHelpers/serverUtilities.ts +40 -30
  1043. package/server/static.ts +9 -6
  1044. package/server/status/index.ts +2 -2
  1045. package/server/storageReclamation.ts +39 -2
  1046. package/server/threads/itc.js +7 -4
  1047. package/server/threads/manageThreads.js +100 -26
  1048. package/server/threads/socketRouter.ts +12 -275
  1049. package/server/threads/threadServer.js +345 -105
  1050. package/server/threads/workerProcessGuard.ts +93 -0
  1051. package/server/throttle.ts +18 -0
  1052. package/sqlTranslator/{SelectValidator.js → SelectValidator.ts} +41 -49
  1053. package/sqlTranslator/{alasqlFunctionImporter.js → alasqlFunctionImporter.ts} +5 -5
  1054. package/sqlTranslator/{deleteTranslator.js → deleteTranslator.ts} +13 -18
  1055. package/sqlTranslator/{index.js → index.ts} +30 -33
  1056. package/sqlTranslator/{sql_statement_bucket.js → sql_statement_bucket.ts} +49 -20
  1057. package/static/README.md +10 -9
  1058. package/static/defaultConfig.yaml +0 -1
  1059. package/studio/web/assets/{index-CybLScHg.js → index-Dqr9oVhe.js} +5 -5
  1060. package/studio/web/assets/index-Dqr9oVhe.js.map +1 -0
  1061. package/studio/web/assets/{index.lazy-DKx5-iXF.js → index.lazy-CpKcKb7M.js} +2 -2
  1062. package/studio/web/assets/{index.lazy-DKx5-iXF.js.map → index.lazy-CpKcKb7M.js.map} +1 -1
  1063. package/studio/web/assets/{profile-BOjes0Wl.js → profile-C1cujdsg.js} +2 -2
  1064. package/studio/web/assets/{profile-BOjes0Wl.js.map → profile-C1cujdsg.js.map} +1 -1
  1065. package/studio/web/assets/{status-EWKUIrjT.js → status-CTiIIQlY.js} +2 -2
  1066. package/studio/web/assets/{status-EWKUIrjT.js.map → status-CTiIIQlY.js.map} +1 -1
  1067. package/studio/web/index.html +1 -1
  1068. package/upgrade/{UpgradeObjects.js → UpgradeObjects.ts} +3 -6
  1069. package/upgrade/directives/5-1-0.ts +89 -0
  1070. package/upgrade/directives/{directivesController.js → directivesController.ts} +16 -16
  1071. package/upgrade/{directivesManager.js → directivesManager.ts} +7 -11
  1072. package/upgrade/{upgradePrompt.js → upgradePrompt.ts} +6 -54
  1073. package/upgrade/{upgradeUtilities.js → upgradeUtilities.ts} +3 -7
  1074. package/utility/{OperationFunctionCaller.js → OperationFunctionCaller.ts} +7 -7
  1075. package/utility/{assignCmdEnvVariables.js → assignCmdEnvVariables.ts} +6 -8
  1076. package/utility/{common_utils.js → common_utils.ts} +113 -139
  1077. package/utility/environment/{environmentManager.js → environmentManager.ts} +34 -33
  1078. package/utility/environment/systemInformation.ts +18 -4
  1079. package/utility/errors/{commonErrors.js → commonErrors.ts} +9 -9
  1080. package/utility/errors/{hdbError.js → hdbError.ts} +39 -45
  1081. package/utility/expandEnvVar.ts +110 -0
  1082. package/utility/functions/geo.js +2 -2
  1083. package/utility/functions/sql/alaSQLExtension.js +1 -1
  1084. package/utility/globalSchema.ts +30 -0
  1085. package/utility/hdbTerms.ts +54 -1
  1086. package/utility/install/checkJWTTokensExist.js +1 -1
  1087. package/utility/install/{installer.js → installer.ts} +66 -42
  1088. package/utility/installation.ts +2 -2
  1089. package/utility/lmdb/{DBIDefinition.js → DBIDefinition.ts} +4 -1
  1090. package/utility/lmdb/{DeleteRecordsResponseObject.js → DeleteRecordsResponseObject.ts} +2 -1
  1091. package/utility/lmdb/{InsertRecordsResponseObject.js → InsertRecordsResponseObject.ts} +2 -1
  1092. package/utility/lmdb/OpenDBIObject.ts +57 -0
  1093. package/utility/lmdb/{OpenEnvironmentObject.js → OpenEnvironmentObject.ts} +19 -6
  1094. package/utility/lmdb/{UpdateRecordsResponseObject.js → UpdateRecordsResponseObject.ts} +2 -1
  1095. package/utility/lmdb/{UpsertRecordsResponseObject.js → UpsertRecordsResponseObject.ts} +2 -1
  1096. package/utility/lmdb/{cleanLMDBMap.js → cleanLMDBMap.ts} +5 -5
  1097. package/utility/lmdb/{commonUtility.js → commonUtility.ts} +13 -21
  1098. package/utility/lmdb/{deleteUtility.js → deleteUtility.ts} +8 -12
  1099. package/utility/lmdb/{environmentUtility.js → environmentUtility.ts} +43 -52
  1100. package/utility/lmdb/{searchCursorFunctions.js → searchCursorFunctions.ts} +12 -26
  1101. package/utility/lmdb/{searchUtility.js → searchUtility.ts} +75 -64
  1102. package/utility/lmdb/{terms.js → terms.ts} +10 -23
  1103. package/utility/lmdb/{writeUtility.js → writeUtility.ts} +37 -22
  1104. package/utility/logging/{harper_logger.js → harper_logger.ts} +137 -90
  1105. package/utility/logging/{logRotator.js → logRotator.ts} +15 -18
  1106. package/utility/logging/logger.ts +1 -1
  1107. package/utility/logging/{readLog.js → readLog.ts} +19 -19
  1108. package/utility/logging/{transactionLog.js → transactionLog.ts} +10 -14
  1109. package/utility/{mount_hdb.js → mount_hdb.ts} +15 -16
  1110. package/utility/{npmUtilities.js → npmUtilities.ts} +14 -17
  1111. package/utility/{operation_authorization.js → operation_authorization.ts} +173 -124
  1112. package/utility/packageUtils.js +7 -16
  1113. package/utility/password.ts +1 -1
  1114. package/utility/processManagement/processManagement.js +2 -2
  1115. package/utility/processManagement/servicesConfig.js +1 -1
  1116. package/utility/{signalling.js → signalling.ts} +6 -11
  1117. package/utility/watcherFallback.ts +74 -0
  1118. package/validation/analyticsValidator.ts +44 -0
  1119. package/validation/{bulkDeleteValidator.js → bulkDeleteValidator.ts} +5 -5
  1120. package/validation/{check_permissions.js → check_permissions.ts} +3 -3
  1121. package/validation/{common_validators.js → common_validators.ts} +12 -24
  1122. package/validation/{configValidator.js → configValidator.ts} +114 -18
  1123. package/validation/{deleteValidator.js → deleteValidator.ts} +5 -5
  1124. package/validation/{fileLoadValidator.js → fileLoadValidator.ts} +12 -19
  1125. package/validation/{insertValidator.js → insertValidator.ts} +5 -5
  1126. package/validation/{installValidator.js → installValidator.ts} +8 -8
  1127. package/validation/{readLogValidator.js → readLogValidator.ts} +10 -10
  1128. package/validation/{role_validation.js → role_validation.ts} +26 -32
  1129. package/validation/{schemaMetadataValidator.js → schemaMetadataValidator.ts} +5 -11
  1130. package/validation/{searchValidator.js → searchValidator.ts} +12 -11
  1131. package/validation/statusValidator.ts +1 -1
  1132. package/validation/{transactionLogValidator.js → transactionLogValidator.ts} +4 -9
  1133. package/validation/{user_validation.js → user_validation.ts} +4 -10
  1134. package/validation/{validationWrapper.js → validationWrapper.ts} +3 -9
  1135. package/bin/cliOperations.js +0 -159
  1136. package/bin/lite.js +0 -5
  1137. package/dataLayer/harperBridge/BridgeMethods.js +0 -85
  1138. package/studio/web/assets/index-CybLScHg.js.map +0 -1
  1139. package/utility/globalSchema.js +0 -35
  1140. package/utility/lmdb/OpenDBIObject.js +0 -31
@@ -45,7 +45,8 @@ exports.EVICTED = exports.INVALIDATED = void 0;
45
45
  exports.makeTable = makeTable;
46
46
  exports.coerceType = coerceType;
47
47
  const hdbTerms_ts_1 = require("../utility/hdbTerms.js");
48
- const commonUtility_js_1 = require("../utility/lmdb/commonUtility.js");
48
+ const node_vm_1 = require("node:vm");
49
+ const commonUtility_ts_1 = require("../utility/lmdb/commonUtility.js");
49
50
  const nodeIdMapping_ts_1 = require("./nodeIdMapping.js");
50
51
  const lodash_1 = __importDefault(require("lodash"));
51
52
  const extended_iterable_1 = require("@harperfast/extended-iterable");
@@ -55,7 +56,7 @@ const when_ts_1 = require("../utility/when.js");
55
56
  const DatabaseTransaction_ts_1 = require("./DatabaseTransaction.js");
56
57
  const envMngr = __importStar(require("../utility/environment/environmentManager.js"));
57
58
  const transactionBroadcast_ts_1 = require("./transactionBroadcast.js");
58
- const hdbError_js_1 = require("../utility/errors/hdbError.js");
59
+ const hdbError_ts_1 = require("../utility/errors/hdbError.js");
59
60
  const signalling = __importStar(require("../utility/signalling.js"));
60
61
  const itc_js_1 = require("../server/threads/itc.js");
61
62
  const databases_ts_1 = require("./databases.js");
@@ -66,7 +67,8 @@ const transaction_ts_1 = require("./transaction.js");
66
67
  const ordered_binary_1 = require("ordered-binary");
67
68
  const manageThreads_js_1 = require("../server/threads/manageThreads.js");
68
69
  const auditStore_ts_1 = require("./auditStore.js");
69
- const common_utils_js_1 = require("../utility/common_utils.js");
70
+ const embedHook_ts_1 = require("./models/embedHook.js");
71
+ const common_utils_ts_1 = require("../utility/common_utils.js");
70
72
  const RecordEncoder_ts_1 = require("./RecordEncoder.js");
71
73
  const write_ts_1 = require("./analytics/write.js");
72
74
  const crdt_ts_1 = require("./crdt.js");
@@ -74,23 +76,26 @@ const Headers_ts_1 = require("../server/serverHelpers/Headers.js");
74
76
  const node_fs_1 = __importDefault(require("node:fs"));
75
77
  const blob_ts_1 = require("./blob.js");
76
78
  const storageReclamation_ts_1 = require("../server/storageReclamation.js");
77
- const harper_logger_js_1 = __importDefault(require("../utility/logging/harper_logger.js"));
79
+ const harper_logger_ts_1 = __importDefault(require("../utility/logging/harper_logger.js"));
78
80
  const throttle_ts_1 = require("../server/throttle.js");
79
81
  const rocksdb_js_1 = require("@harperfast/rocksdb-js");
80
82
  const LMDBTransaction_1 = require("./LMDBTransaction");
81
83
  const contentTypes_1 = require("../server/serverHelpers/contentTypes");
84
+ const jsonSchemaTypes_ts_1 = require("./jsonSchemaTypes.js");
82
85
  const { sortBy } = lodash_1.default;
83
86
  const { validateAttribute } = lmdbProcessRows_js_1.default;
84
87
  const NULL_WITH_TIMESTAMP = new Uint8Array(9);
85
88
  NULL_WITH_TIMESTAMP[8] = 0xc0; // null
86
89
  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
87
90
  const RECORD_PRUNING_INTERVAL = 60000; // one minute
91
+ const CACHEABLE_STATUS_CODES = new Set([200, 203, 204, 206, 300, 301, 308, 404, 405, 410, 414, 501]);
88
92
  envMngr.initSync();
89
93
  const LMDB_PREFETCH_WRITES = envMngr.get(hdbTerms_ts_1.CONFIG_PARAMS.STORAGE_PREFETCHWRITES);
90
94
  const LOCK_TIMEOUT = 10000;
91
- // True only for frozen plain/record objects (the immutable decoded records). Excludes Buffers,
92
- // TypedArrays, ArrayBuffers and primitives/null, which must not be shallow-copied via spread (that
93
- // would corrupt binary values). Used to decide when to copy-on-mutate before stamping a record.
95
+ // A frozen record we may need to copy-on-mutate before stamping it (records are immutable — decoded
96
+ // records are frozen and 5.2 record caching relies on it). Only plain/record objects qualify: never
97
+ // a Buffer/typed-array (spreading would corrupt the binary into a {0:.., 1:..} object) or a primitive
98
+ // (which reports as frozen and would spread into character/index keys).
94
99
  function isFrozenRecordObject(value) {
95
100
  return (value !== null &&
96
101
  typeof value === 'object' &&
@@ -121,17 +126,20 @@ const FULL_PERMISSIONS = {
121
126
  * Instances of the returned class are Resource instances, intended to provide a consistent view or transaction of the table
122
127
  * @param options
123
128
  */
129
+ // #section: setup-and-factory
124
130
  function makeTable(options) {
125
- const { primaryKey, indices, tableId, tableName, primaryStore, databasePath, databaseName, auditStore, schemaDefined, dbisDB: dbisDb, sealed, splitSegments, replicate, } = options;
131
+ const { primaryKey, indices, tableId, tableName, primaryStore, databasePath, databaseName, auditStore, schemaDefined, dbisDB: dbisDb, sealed, splitSegments, replicate, description, hidden, } = options;
126
132
  let { expirationMS: expirationMs, evictionMS: evictionMs, audit, trackDeletes } = options;
127
133
  evictionMs ??= 0;
128
- let { attributes } = options;
134
+ let { attributes, properties } = options;
129
135
  if (!attributes)
130
136
  attributes = [];
137
+ if (!properties)
138
+ properties = (0, jsonSchemaTypes_ts_1.projectAttributesToProperties)(attributes);
131
139
  const updateRecord = (0, RecordEncoder_ts_1.recordUpdater)(primaryStore, tableId, auditStore);
132
140
  let sourceLoad; // if a source has a load function (replicator), record it here
133
141
  let hasSourceGet;
134
- let primaryKeyAttribute = {};
142
+ let primaryKeyAttribute;
135
143
  let lastEvictionCompletion = Promise.resolve();
136
144
  let createdTimeProperty, updatedTimeProperty, expiresAtProperty;
137
145
  for (const attribute of attributes) {
@@ -201,6 +209,7 @@ function makeTable(options) {
201
209
  #version; // version of the record
202
210
  #entry; // the entry from the database
203
211
  #savingOperation; // operation for the record is currently being saved
212
+ // #section: static-config
204
213
  static name = tableName; // for display/debugging purposes
205
214
  static primaryStore = primaryStore;
206
215
  static auditStore = auditStore;
@@ -212,6 +221,11 @@ function makeTable(options) {
212
221
  static databasePath = databasePath;
213
222
  static databaseName = databaseName;
214
223
  static attributes = attributes;
224
+ static description = description;
225
+ static properties = properties;
226
+ static hidden = hidden;
227
+ static outputSchemas;
228
+ static mcp;
215
229
  static replicate = replicate;
216
230
  static sealed = sealed;
217
231
  static splitSegments = splitSegments ?? true;
@@ -219,6 +233,11 @@ function makeTable(options) {
219
233
  static updatedTimeProperty = updatedTimeProperty;
220
234
  static propertyResolvers;
221
235
  static userResolvers = {};
236
+ // `@embed` hook registry. `userSetEmbedders` records names set explicitly via
237
+ // `setEmbedAttribute` so a schema reload refreshes defaults without clobbering them.
238
+ static userEmbedders = {};
239
+ static userSetEmbedders = new Set();
240
+ static embedAttributes = attributes.filter((a) => a?.embed);
222
241
  static source;
223
242
  static getResidencyById;
224
243
  static get expirationMS() {
@@ -234,6 +253,7 @@ function makeTable(options) {
234
253
  * @param options
235
254
  * @returns
236
255
  */
256
+ // #section: resource-registry
237
257
  static sourcedFrom(source, options) {
238
258
  // define a source for retrieving invalidated entries for caching purposes
239
259
  if (options) {
@@ -478,7 +498,7 @@ function makeTable(options) {
478
498
  });
479
499
  if (txnInProgress)
480
500
  txnInProgress.committed = commitResolution;
481
- if (userRoleUpdate && commitResolution && !commitResolution?.waitingForUserChange) {
501
+ if (userRoleUpdate && commitResolution && !commitResolution.waitingForUserChange) {
482
502
  // if the user role changed, asynchronously signal the user change (but don't block this function)
483
503
  commitResolution.then(() => signalling.signalUserChange(new itc_js_1.UserEventMsg(process.pid)));
484
504
  commitResolution.waitingForUserChange = true; // only need to send one signal per transaction
@@ -554,7 +574,9 @@ function makeTable(options) {
554
574
  // return 504 (rather than 404) if there is no content and the cache-control header
555
575
  // dictates not to go to source
556
576
  if (!this.doesExist())
557
- throw new hdbError_js_1.ServerError('Entry is not cached', 504);
577
+ throw new hdbError_ts_1.ServerError('Entry is not cached', 504);
578
+ if (hasSourceGet && target)
579
+ target.loadedFromSource = false; // mark it as cached
558
580
  }
559
581
  else if (resourceOptions?.ensureLoaded) {
560
582
  const loadingFromSource = ensureLoadedFromSource(this.constructor.source, id, entry, request, this, target);
@@ -597,6 +619,7 @@ function makeTable(options) {
597
619
  });
598
620
  }
599
621
  }
622
+ // #section: lifecycle-admin
600
623
  static getNewId() {
601
624
  const type = primaryKeyAttribute?.type;
602
625
  // 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
@@ -882,6 +905,11 @@ function makeTable(options) {
882
905
  }
883
906
  signalling.signalSchemaChange(new itc_js_1.SchemaEventMsg(process.pid, hdbTerms_ts_1.OPERATIONS_ENUM.DROP_TABLE, databaseName, tableName));
884
907
  }
908
+ // #section: read-path
909
+ /**
910
+ * This retrieves the data of this resource.
911
+ * @param target - If included, is an identifier/query that specifies the requested target to retrieve and query
912
+ */
885
913
  get(target) {
886
914
  const constructor = this.constructor;
887
915
  if (typeof target === 'string' && constructor.loadAsInstance !== false)
@@ -920,13 +948,13 @@ function makeTable(options) {
920
948
  const id = requestTargetToId(target);
921
949
  checkValidId(id);
922
950
  let allowed = true;
923
- if (target.checkPermission) {
951
+ if (target?.checkPermission) {
924
952
  // requesting authorization verification
925
953
  allowed = this.allowRead(context.user, target, context);
926
954
  }
927
955
  return (0, when_ts_1.promiseNormalize)((0, when_ts_1.when)((0, when_ts_1.when)(allowed, (allowed) => {
928
956
  if (!allowed) {
929
- throw new hdbError_js_1.AccessViolation(context.user);
957
+ throw new hdbError_ts_1.AccessViolation(context.user);
930
958
  }
931
959
  const ensureLoaded = true;
932
960
  return loadLocalRecord(id, context, { transaction: readTxn, ensureLoaded }, false, (entry) => {
@@ -935,7 +963,7 @@ function makeTable(options) {
935
963
  // return 504 (rather than 404) if there is no content and the cache-control header
936
964
  // dictates not to go to source
937
965
  if (!entry?.value)
938
- throw new hdbError_js_1.ServerError('Entry is not cached', 504);
966
+ throw new hdbError_ts_1.ServerError('Entry is not cached', 504);
939
967
  }
940
968
  else if (ensureLoaded) {
941
969
  const loadingFromSource = ensureLoadedFromSource(constructor.source, id, entry, context, this, target);
@@ -975,6 +1003,7 @@ function makeTable(options) {
975
1003
  }
976
1004
  return undefined;
977
1005
  }
1006
+ // #section: authz-hooks
978
1007
  /**
979
1008
  * Determine if the user is allowed to get/read data from the current resource
980
1009
  */
@@ -1139,13 +1168,13 @@ function makeTable(options) {
1139
1168
  let allowed = true;
1140
1169
  if (target == undefined)
1141
1170
  throw new TypeError('Can not put a record without a target');
1142
- if (target.checkPermission) {
1171
+ if (target?.checkPermission) {
1143
1172
  // requesting authorization verification
1144
1173
  allowed = this.allowUpdate(context.user, updates, context);
1145
1174
  }
1146
1175
  return (0, when_ts_1.when)(allowed, (allowed) => {
1147
1176
  if (!allowed) {
1148
- throw new hdbError_js_1.AccessViolation(context.user);
1177
+ throw new hdbError_ts_1.AccessViolation(context.user);
1149
1178
  }
1150
1179
  let loading;
1151
1180
  if (!this.#entry && this.constructor.loadAsInstance === false) {
@@ -1154,31 +1183,33 @@ function makeTable(options) {
1154
1183
  }
1155
1184
  return (0, when_ts_1.when)(loading, () => {
1156
1185
  this.#changes = updates;
1157
- this._writeUpdate(id, this.#changes, false);
1158
- return this;
1186
+ // `when` awaits the embed hook (when `@embed` is active) before resolving,
1187
+ // so the caller's `save()` doesn't run before the write is staged.
1188
+ return (0, when_ts_1.when)(this._writeUpdate(id, this.#changes, false), () => this);
1159
1189
  });
1160
1190
  });
1161
1191
  }
1162
1192
  }
1163
- this._writeUpdate(id, this.#changes, fullUpdate);
1164
- return this;
1193
+ return (0, when_ts_1.when)(this._writeUpdate(id, this.#changes, fullUpdate), () => this);
1165
1194
  }
1166
1195
  /**
1167
1196
  * Save any changes into this instance to the current transaction
1168
1197
  */
1169
1198
  save() {
1170
1199
  if (this.#savingOperation) {
1171
- const transaction = txnForContext(this.getContext());
1172
- if (transaction.save) {
1173
- try {
1174
- return transaction.save(this.#savingOperation);
1175
- }
1176
- finally {
1177
- this.#savingOperation = null;
1178
- }
1200
+ try {
1201
+ return this.#saveOperation(this.#savingOperation);
1202
+ }
1203
+ finally {
1204
+ this.#savingOperation = null;
1179
1205
  }
1180
1206
  }
1181
1207
  }
1208
+ #saveOperation(operation) {
1209
+ const transaction = txnForContext(this.getContext());
1210
+ if (transaction.save)
1211
+ return transaction.save(operation) || operation.promise || operation.result;
1212
+ }
1182
1213
  addTo(property, value) {
1183
1214
  if (typeof value === 'number' || typeof value === 'bigint') {
1184
1215
  if (this.#savingOperation?.fullUpdate)
@@ -1225,7 +1256,7 @@ function makeTable(options) {
1225
1256
  }
1226
1257
  return (0, when_ts_1.when)(allowed, (allowed) => {
1227
1258
  if (!allowed) {
1228
- throw new hdbError_js_1.AccessViolation(context.user);
1259
+ throw new hdbError_ts_1.AccessViolation(context.user);
1229
1260
  }
1230
1261
  this._writeInvalidate(target ? requestTargetToId(target) : this.getId());
1231
1262
  });
@@ -1302,7 +1333,7 @@ function makeTable(options) {
1302
1333
  }
1303
1334
  logger_ts_1.logger.trace?.(`Relocating entry id: ${id}, timestamp: ${new Date(txnTime).toISOString()}`);
1304
1335
  updateRecord(id, newRecord, existingEntry, txnTime, metadata, audit, {
1305
- user: context.user,
1336
+ user: context?.user,
1306
1337
  residencyId: options.residencyId,
1307
1338
  nodeId: options.nodeId,
1308
1339
  viaNodeId: options?.viaNodeId,
@@ -1385,7 +1416,7 @@ function makeTable(options) {
1385
1416
  // RocksDB: eviction writes went directly into the raw transaction via options;
1386
1417
  // commit it directly, as DatabaseTransaction.commit() would abort it (no tracked writes).
1387
1418
  // Wrap in Promise.resolve so callers can rely on a thenable return regardless of engine.
1388
- return Promise.resolve(transaction.commit());
1419
+ return transaction.commit();
1389
1420
  }
1390
1421
  finally {
1391
1422
  if (!committed) {
@@ -1415,11 +1446,12 @@ function makeTable(options) {
1415
1446
  * Store the provided record data into the current resource. This is not written
1416
1447
  * until the corresponding transaction is committed.
1417
1448
  */
1449
+ // @ts-expect-error The implementation intentionally uses a different argument order for back-compat
1418
1450
  put(target, record) {
1419
1451
  if (record === undefined || record instanceof URLSearchParams) {
1420
- // legacy argument position, shift the arguments and go through the update method for back-compat
1421
- this.update(target, true);
1422
- return this.save();
1452
+ // legacy argument position, shift the arguments and go through the update method for back-compat.
1453
+ // `when` settles the embed hook before `save()` so the write is staged first.
1454
+ return (0, when_ts_1.when)(this.update(target, true), () => this.save());
1423
1455
  }
1424
1456
  else {
1425
1457
  let allowed = true;
@@ -1432,20 +1464,26 @@ function makeTable(options) {
1432
1464
  }
1433
1465
  return (0, when_ts_1.when)(allowed, (allowed) => {
1434
1466
  if (!allowed) {
1435
- throw new hdbError_js_1.AccessViolation(context.user);
1467
+ throw new hdbError_ts_1.AccessViolation(context.user);
1436
1468
  }
1437
1469
  // standard path, handle arrays as multiple updates, and otherwise do a direct update
1438
1470
  if (Array.isArray(record)) {
1439
- return Promise.all(record.map((element) => {
1471
+ // Capture each element's operation synchronously (before any async `@embed`
1472
+ // hook resolves): `#savingOperation` is a single field that parallel writes
1473
+ // would otherwise clobber, so a deferred `save()` would commit the wrong op
1474
+ // — e.g. one element's save running before a later element's vector is written.
1475
+ const writes = record.map((element) => {
1440
1476
  const id = element[primaryKey];
1441
- this._writeUpdate(id, element, true);
1442
- return this.save();
1443
- }));
1477
+ const writePromise = this._writeUpdate(id, element, true);
1478
+ const operation = this.#savingOperation;
1479
+ return (0, when_ts_1.when)(writePromise, () => this.#saveOperation(operation));
1480
+ });
1481
+ this.#savingOperation = null;
1482
+ return Promise.all(writes);
1444
1483
  }
1445
1484
  else {
1446
1485
  const id = requestTargetToId(target);
1447
- this._writeUpdate(id, record, true);
1448
- return this.save();
1486
+ return (0, when_ts_1.when)(this._writeUpdate(id, record, true), () => this.save());
1449
1487
  }
1450
1488
  });
1451
1489
  }
@@ -1468,7 +1506,7 @@ function makeTable(options) {
1468
1506
  }
1469
1507
  return (0, when_ts_1.when)(allowed, (allowed) => {
1470
1508
  if (!allowed) {
1471
- throw new hdbError_js_1.AccessViolation(context.user);
1509
+ throw new hdbError_ts_1.AccessViolation(context.user);
1472
1510
  }
1473
1511
  let id = requestTargetToId(target) ?? record[primaryKey];
1474
1512
  if (id === undefined) {
@@ -1478,19 +1516,21 @@ function makeTable(options) {
1478
1516
  else {
1479
1517
  const existing = primaryStore.getSync(id);
1480
1518
  if (existing) {
1481
- throw new hdbError_js_1.ClientError('Record already exists', 409);
1519
+ throw new hdbError_ts_1.ClientError('Record already exists', 409);
1482
1520
  }
1483
1521
  }
1484
- this._writeUpdate(id, record, true);
1485
- return record;
1522
+ // `_writeUpdate` may return a promise when an `@embed` directive
1523
+ // requires running an embedder before the per-write `commit(...)`
1524
+ // closure. `when()` passes through synchronous returns.
1525
+ return (0, when_ts_1.when)(this._writeUpdate(id, record, true), () => record);
1486
1526
  });
1487
1527
  }
1488
1528
  // @ts-expect-error The implementation handles the possibility of target and recordUpdate being swapped
1489
1529
  patch(target, recordUpdate) {
1490
1530
  if (recordUpdate === undefined || recordUpdate instanceof URLSearchParams) {
1491
- // legacy argument position, shift the arguments and go through the update method for back-compat
1492
- this.update(target, false);
1493
- return this.save();
1531
+ // legacy argument position, shift the arguments and go through the update method for back-compat.
1532
+ // `when` settles the embed hook before `save()` so the write is staged first.
1533
+ return (0, when_ts_1.when)(this.update(target, false), () => this.save());
1494
1534
  }
1495
1535
  else {
1496
1536
  // standard path, ensure there is no return object
@@ -1499,6 +1539,7 @@ function makeTable(options) {
1499
1539
  });
1500
1540
  }
1501
1541
  }
1542
+ // #section: write-path-internals
1502
1543
  // perform the actual write operation; this may come from a user request to write (put, post, etc.), or
1503
1544
  // a notification that a write has already occurred in the canonical data source, we need to update our
1504
1545
  // local copy
@@ -1623,6 +1664,23 @@ function makeTable(options) {
1623
1664
  // of the updates to the record to ensure consistency across the cluster
1624
1665
  // TODO: can the previous version be older, but even more previous version be newer?
1625
1666
  if (audit) {
1667
+ // A re-delivered out-of-order write (full-copy audit-replay re-delivers writes) must not have
1668
+ // its commutative ops re-folded. additionalAuditRefs is the record's own list of folded
1669
+ // out-of-order versions, read with read-your-writes consistency, so this skips the duplicate up
1670
+ // front — before the audit-log walk below, which can miss it: the walk stops at the depth cap, or
1671
+ // breaks early on a not-yet-visible audit entry, before reaching txnTime, and the keyed
1672
+ // transaction-log lookup it would otherwise use can lag a back-to-back re-delivery (that lag
1673
+ // silently double-applied the increment — #1137). This covers the re-delivery while the ref is
1674
+ // still on the record; a later in-order write rewrites the record and drops the ref (it survives
1675
+ // only as previousAdditionalAuditRefs on the audit log), so that case falls back to the
1676
+ // best-effort keyed lookup in the capped block below — see #1148. precedesExistingVersion(...)
1677
+ // === 0 is the identity tie: same version AND same node (the local node is id 0, so an undefined
1678
+ // options?.nodeId resolves to the same 0 the ref stored).
1679
+ if (existingEntry.additionalAuditRefs?.some((ref) => ref.version === txnTime &&
1680
+ precedesExistingVersion(txnTime, { version: txnTime, localTime: txnTime, key: id, nodeId: ref.nodeId }, options?.nodeId) === 0)) {
1681
+ write.skipped = true;
1682
+ return; // out-of-order write already folded into this record
1683
+ }
1626
1684
  // incremental CRDT updates are only available with audit logging on
1627
1685
  let localTime = existingEntry.localTime;
1628
1686
  let auditedVersion = existingEntry.version;
@@ -1733,8 +1791,12 @@ function makeTable(options) {
1733
1791
  // retained window are not layered in — but the authoritative full-copy record restores exact
1734
1792
  // convergence. Because we stopped before reaching txnTime, the inline duplicate detection in
1735
1793
  // the walk never ran; full-copy audit-replay re-delivers writes, and re-applying one would
1736
- // double-apply its commutative ops, so rule that out here with a single O(1) lookup at txnTime
1737
- // (RocksDB audit logs are keyed by version, and the cap is RocksDB-only).
1794
+ // double-apply its commutative ops. A re-delivered out-of-order write is already ruled out by
1795
+ // the additionalAuditRefs check at the top of this block; this keyed lookup is the best-effort
1796
+ // guard for the remaining case — a re-delivered write that was originally in-order (so it left
1797
+ // no ref) and is now deeper than the cap. It is best-effort because the transaction-log lookup
1798
+ // can intermittently miss an entry under load (tracked separately); the authoritative full-copy
1799
+ // record still restores exact convergence.
1738
1800
  logger_ts_1.logger.warn?.('Out-of-order audit reconciliation exceeded depth cap; reconciling against most recent updates only', {
1739
1801
  table: tableName,
1740
1802
  id,
@@ -1859,8 +1921,21 @@ function makeTable(options) {
1859
1921
  },
1860
1922
  };
1861
1923
  this.#savingOperation = write;
1862
- write.beforeIntermediate = preCommitBlobsForRecordBefore(write, recordUpdate);
1863
- return transaction.addWrite(write);
1924
+ // `@embed` hook must run before `addWrite` so the embedder's vector is on the
1925
+ // record when `commit` runs. (The txn `before` slot runs after commit, which
1926
+ // suits blob writes but not embedding, where the vector must be present at commit.)
1927
+ // Known limitation of this write-time placement (a validate-time alternative was
1928
+ // tried and reverted as a Harper-foreign pattern): the embedder sees this write's
1929
+ // payload, before table validation — so a write that later fails validation still
1930
+ // calls the backend, and a tracked-instance mutation (update(id,{}); row.source=…;
1931
+ // save()) that sets the source via accessors after update() won't re-embed. A
1932
+ // resource-layer re-embed is the proper fix; tracked as a follow-up.
1933
+ const embedBefore = (0, embedHook_ts_1.buildEmbedBefore)(recordUpdate, context, options, TableResource.embedAttributes, TableResource.userEmbedders);
1934
+ const proceed = () => {
1935
+ write.beforeIntermediate = preCommitBlobsForRecordBefore(write, recordUpdate);
1936
+ return transaction.addWrite(write);
1937
+ };
1938
+ return embedBefore ? embedBefore().then(proceed) : proceed();
1864
1939
  }
1865
1940
  async delete(target) {
1866
1941
  if (isSearchTarget(target)) {
@@ -1873,13 +1948,13 @@ function makeTable(options) {
1873
1948
  if (target) {
1874
1949
  let allowed = true;
1875
1950
  const context = this.getContext();
1876
- if (target.checkPermission) {
1951
+ if (target?.checkPermission) {
1877
1952
  // requesting authorization verification
1878
1953
  allowed = this.allowDelete(context.user, target, context);
1879
1954
  }
1880
1955
  return (0, when_ts_1.when)(allowed, (allowed) => {
1881
1956
  if (!allowed) {
1882
- throw new hdbError_js_1.AccessViolation(context.user);
1957
+ throw new hdbError_ts_1.AccessViolation(context.user);
1883
1958
  }
1884
1959
  const id = requestTargetToId(target);
1885
1960
  this._writeDelete(id);
@@ -1931,6 +2006,7 @@ function makeTable(options) {
1931
2006
  });
1932
2007
  return true;
1933
2008
  }
2009
+ // #section: search-query
1934
2010
  search(target) {
1935
2011
  const context = this.getContext();
1936
2012
  const txn = txnForContext(context);
@@ -1942,7 +2018,7 @@ function makeTable(options) {
1942
2018
  // requesting authorization verification
1943
2019
  const allowed = this.allowRead(context.user, target, context);
1944
2020
  if (!allowed) {
1945
- throw new hdbError_js_1.AccessViolation(context.user);
2021
+ throw new hdbError_ts_1.AccessViolation(context.user);
1946
2022
  }
1947
2023
  }
1948
2024
  if (context)
@@ -1985,18 +2061,39 @@ function makeTable(options) {
1985
2061
  condition.conditions = prepareConditions(condition.conditions, condition.operator);
1986
2062
  continue;
1987
2063
  }
2064
+ // Normalize `not_X` comparator forms passed in via structured queries.
2065
+ // The REST parser already does this, but programmatic callers may
2066
+ // pass `not_in`, `not_starts_with`, etc. directly.
2067
+ if (condition.comparator) {
2068
+ const resolved = (0, search_ts_1.resolveComparator)(condition.comparator);
2069
+ if (resolved.negated) {
2070
+ condition.comparator = resolved.comparator;
2071
+ condition.negated = true;
2072
+ }
2073
+ }
1988
2074
  const attribute_name = condition[0] ?? condition.attribute;
1989
- const attribute = attribute_name == null ? primaryKeyAttribute : (0, search_ts_1.findAttribute)(attributes, attribute_name);
2075
+ let attribute = attribute_name == null ? primaryKeyAttribute : (0, search_ts_1.findAttribute)(attributes, attribute_name);
2076
+ if (!attribute && Array.isArray(attribute_name) && attribute_name.length > 1) {
2077
+ // Plain JSON nested path: the leaf may not be declared in the
2078
+ // schema. Fall back to the root attribute so we can validate
2079
+ // existence without requiring the inner structure to be typed.
2080
+ attribute = (0, search_ts_1.findAttribute)(attributes, attribute_name[0]);
2081
+ }
1990
2082
  if (!attribute) {
1991
2083
  if (attribute_name != null && !target.allowConditionsOnDynamicAttributes)
1992
- throw (0, hdbError_js_1.handleHDBError)(new Error(), `${attribute_name} is not a defined attribute`, 404);
2084
+ throw (0, hdbError_ts_1.handleHDBError)(new Error(), `${attribute_name} is not a defined attribute`, 404);
1993
2085
  }
1994
2086
  else if (attribute.type || search_ts_1.COERCIBLE_OPERATORS[condition.comparator]) {
1995
- // Do auto-coercion or coercion as required by the attribute type
1996
- if (condition[1] === undefined)
1997
- condition.value = coerceTypedValues(condition.value, attribute);
1998
- else
1999
- condition[1] = coerceTypedValues(condition[1], attribute);
2087
+ // Do auto-coercion or coercion as required by the attribute type.
2088
+ // Skipped for nested paths into plain JSON — the root attribute's
2089
+ // type is not the leaf type, so coercion would be wrong.
2090
+ const isNestedPathRoot = Array.isArray(attribute_name) && attribute_name.length > 1 && !attribute.relationship;
2091
+ if (!isNestedPathRoot) {
2092
+ if (condition[1] === undefined)
2093
+ condition.value = coerceTypedValues(condition.value, attribute);
2094
+ else
2095
+ condition[1] = coerceTypedValues(condition[1], attribute);
2096
+ }
2000
2097
  }
2001
2098
  if (condition.chainedConditions) {
2002
2099
  if (condition.chainedConditions.length === 1 && (!condition.operator || condition.operator == 'and')) {
@@ -2021,7 +2118,7 @@ function makeTable(options) {
2021
2118
  }
2022
2119
  const isGe = lower.comparator === 'ge' || lower.comparator === 'greater_than_equal';
2023
2120
  const isLe = upper.comparator === 'le' || upper.comparator === 'less_than_equal';
2024
- condition.comparator = (isGe ? 'ge' : 'gt') + (isLe ? 'le' : 'lt');
2121
+ condition.comparator = ((isGe ? 'ge' : 'gt') + (isLe ? 'le' : 'lt'));
2025
2122
  condition.value = [lower.value, upper.value];
2026
2123
  }
2027
2124
  else
@@ -2061,7 +2158,7 @@ function makeTable(options) {
2061
2158
  if (operator !== 'or') {
2062
2159
  const attribute_name = sort.attribute;
2063
2160
  if (attribute_name == undefined)
2064
- throw new hdbError_js_1.ClientError('Sort requires an attribute');
2161
+ throw new hdbError_ts_1.ClientError('Sort requires an attribute');
2065
2162
  orderAlignedCondition = conditions.find((condition) => (0, search_ts_1.flattenKey)(condition.attribute) === (0, search_ts_1.flattenKey)(attribute_name));
2066
2163
  if (orderAlignedCondition) {
2067
2164
  // if there is a condition on the same attribute as the first sort, we can use it to align the sort
@@ -2070,14 +2167,14 @@ function makeTable(options) {
2070
2167
  else {
2071
2168
  const attribute = (0, search_ts_1.findAttribute)(attributes, attribute_name);
2072
2169
  if (!attribute)
2073
- throw (0, hdbError_js_1.handleHDBError)(new Error(), `${Array.isArray(attribute_name) ? attribute_name.join('.') : attribute_name} is not a defined attribute`, 404);
2170
+ throw (0, hdbError_ts_1.handleHDBError)(new Error(), `${Array.isArray(attribute_name) ? attribute_name.join('.') : attribute_name} is not a defined attribute`, 404);
2074
2171
  if (attribute.indexed) {
2075
2172
  // if it is indexed, we add a pseudo-condition to align with the natural sort order of the index
2076
2173
  orderAlignedCondition = { ...sort, comparator: 'sort' };
2077
2174
  conditions.push(orderAlignedCondition);
2078
2175
  }
2079
2176
  else if (conditions.length === 0 && !target.allowFullScan)
2080
- throw (0, hdbError_js_1.handleHDBError)(new Error(), `${Array.isArray(attribute_name) ? attribute_name.join('.') : attribute_name} is not indexed and not combined with any other conditions`, 404);
2177
+ throw (0, hdbError_ts_1.handleHDBError)(new Error(), `${Array.isArray(attribute_name) ? attribute_name.join('.') : attribute_name} is not indexed and not combined with any other conditions`, 404);
2081
2178
  }
2082
2179
  if (orderAlignedCondition)
2083
2180
  orderAlignedCondition.descending = Boolean(sort.descending);
@@ -2485,7 +2582,16 @@ function makeTable(options) {
2485
2582
  else {
2486
2583
  value = record[attribute_name];
2487
2584
  if (value && typeof value === 'object' && attribute_name !== attribute) {
2488
- value = TableResource.transformEntryForSelect(attribute.select || attribute, context, readTxn, null)({ value });
2585
+ const subTransform = TableResource.transformEntryForSelect(attribute.select || attribute, context, readTxn, null);
2586
+ // Plain JSON nested values: arrays project per-element so that
2587
+ // `select: [{ name: 'addresses', select: ['city'] }]` returns
2588
+ // `addresses: [{ city }, { city }]` rather than a single object.
2589
+ if (Array.isArray(value)) {
2590
+ value = value.map((item) => item && typeof item === 'object' ? subTransform({ value: item }) : item);
2591
+ }
2592
+ else if (!(value instanceof Date)) {
2593
+ value = subTransform({ value });
2594
+ }
2489
2595
  }
2490
2596
  }
2491
2597
  callback(value, attribute_name);
@@ -2524,7 +2630,7 @@ function makeTable(options) {
2524
2630
  }
2525
2631
  }
2526
2632
  else
2527
- throw new hdbError_js_1.ClientError('Invalid select' + select);
2633
+ throw new hdbError_ts_1.ClientError('Invalid select' + select);
2528
2634
  if (promises) {
2529
2635
  return Promise.all(promises).then(() => selected);
2530
2636
  }
@@ -2534,6 +2640,7 @@ function makeTable(options) {
2534
2640
  };
2535
2641
  return transform;
2536
2642
  }
2643
+ // #section: pub-sub
2537
2644
  async subscribe(request) {
2538
2645
  if (!auditStore)
2539
2646
  throw new Error('Can not subscribe to a table without an audit log');
@@ -2624,7 +2731,7 @@ function makeTable(options) {
2624
2731
  // a collection should retrieve all descendant ids
2625
2732
  if (startTime) {
2626
2733
  if (count)
2627
- throw new hdbError_js_1.ClientError('startTime and previousCount can not be combined for a table level subscription');
2734
+ throw new hdbError_ts_1.ClientError('startTime and previousCount can not be combined for a table level subscription');
2628
2735
  // start time specified, get the audit history for this time range. We drop real-time
2629
2736
  // messages during this loop because the snapshot:false cursor will pick them up itself.
2630
2737
  pendingRealTimeQueue = null;
@@ -2835,7 +2942,7 @@ function makeTable(options) {
2835
2942
  }
2836
2943
  })();
2837
2944
  result.catch((error) => {
2838
- harper_logger_js_1.default.error?.('Error in real-time subscription:', error);
2945
+ harper_logger_ts_1.default.error?.('Error in real-time subscription:', error);
2839
2946
  subscription.send(error);
2840
2947
  });
2841
2948
  function send(event) {
@@ -2872,13 +2979,13 @@ function makeTable(options) {
2872
2979
  else {
2873
2980
  let allowed = true;
2874
2981
  const context = this.getContext();
2875
- if (target.checkPermission) {
2982
+ if (target?.checkPermission) {
2876
2983
  // requesting authorization verification
2877
- allowed = this.allowCreate(context.user, message, context);
2984
+ allowed = this.allowDelete(context.user, target, context);
2878
2985
  }
2879
2986
  return (0, when_ts_1.when)(allowed, (allowed) => {
2880
2987
  if (!allowed) {
2881
- throw new hdbError_js_1.AccessViolation(context.user);
2988
+ throw new hdbError_ts_1.AccessViolation(context.user);
2882
2989
  }
2883
2990
  const id = requestTargetToId(target);
2884
2991
  this._writePublish(id, message, options);
@@ -2930,6 +3037,7 @@ function makeTable(options) {
2930
3037
  write.beforeIntermediate = preCommitBlobsForRecordBefore(write, message, undefined, true);
2931
3038
  transaction.addWrite(write);
2932
3039
  }
3040
+ // #section: validation
2933
3041
  validate(record, patch) {
2934
3042
  let validationErrors;
2935
3043
  const validateValue = (value, attribute, name) => {
@@ -3064,9 +3172,10 @@ function makeTable(options) {
3064
3172
  }
3065
3173
  }
3066
3174
  if (validationErrors) {
3067
- throw new hdbError_js_1.ClientError(validationErrors.join('. '));
3175
+ throw new hdbError_ts_1.ClientError(validationErrors.join('. '));
3068
3176
  }
3069
3177
  }
3178
+ // #section: stats-admin
3070
3179
  getUpdatedTime() {
3071
3180
  return this.#version;
3072
3181
  }
@@ -3074,9 +3183,9 @@ function makeTable(options) {
3074
3183
  const new_attributes = attributes.slice(0);
3075
3184
  for (const attribute of attributesToAdd) {
3076
3185
  if (!attribute.name)
3077
- throw new hdbError_js_1.ClientError('Attribute name is required');
3186
+ throw new hdbError_ts_1.ClientError('Attribute name is required');
3078
3187
  if (attribute.name.match(/[`/]/))
3079
- throw new hdbError_js_1.ClientError('Attribute names cannot include backticks or forward slashes');
3188
+ throw new hdbError_ts_1.ClientError('Attribute names cannot include backticks or forward slashes');
3080
3189
  validateAttribute(attribute.name);
3081
3190
  new_attributes.push(attribute);
3082
3191
  }
@@ -3189,6 +3298,18 @@ function makeTable(options) {
3189
3298
  * When attributes have been changed, we update the accessors that are assigned to this table
3190
3299
  */
3191
3300
  static updatedAttributes() {
3301
+ // Refresh on every call: schema reload mutates `attributes` in place, so the
3302
+ // class-construction snapshot would otherwise go stale.
3303
+ this.embedAttributes = this.attributes.filter((a) => a?.embed);
3304
+ // Drop registry entries for attributes that are no longer `@embed`, so a dropped
3305
+ // directive doesn't leave a stale embedder or block a default refresh on re-add.
3306
+ const embedNames = new Set(this.embedAttributes.map((a) => a.name));
3307
+ for (const name of Object.keys(this.userEmbedders))
3308
+ if (!embedNames.has(name))
3309
+ delete this.userEmbedders[name];
3310
+ for (const name of this.userSetEmbedders)
3311
+ if (!embedNames.has(name))
3312
+ this.userSetEmbedders.delete(name);
3192
3313
  propertyResolvers = this.propertyResolvers = {
3193
3314
  $id: (object, context, entry) => ({ value: entry.key }),
3194
3315
  $updatedtime: (object, context, entry) => entry.version,
@@ -3205,6 +3326,11 @@ function makeTable(options) {
3205
3326
  attribute.resolve = null; // reset this
3206
3327
  const relationship = attribute.relationship;
3207
3328
  const computed = attribute.computed;
3329
+ // Register the default embedder unless an author override is set. Sits outside
3330
+ // the resolver chain below so `@embed` fields still flow through auto-HNSW indexing.
3331
+ if (attribute.embed && !TableResource.userSetEmbedders.has(attribute.name)) {
3332
+ this.userEmbedders[attribute.name] = (0, embedHook_ts_1.createDefaultEmbedder)(attribute.embed);
3333
+ }
3208
3334
  if (relationship) {
3209
3335
  if (attribute.indexed) {
3210
3336
  console.error(`A relationship property can not be directly indexed, (but you may want to index the foreign key attribute)`);
@@ -3305,6 +3431,14 @@ function makeTable(options) {
3305
3431
  if (typeof computed.from === 'function') {
3306
3432
  this.setComputedAttribute(attribute.name, computed.from);
3307
3433
  }
3434
+ else if (attribute.computedFromExpression) {
3435
+ // build a fallback scope object with all attribute names set to undefined,
3436
+ // matching the behavior in graphql.ts to prevent ReferenceErrors
3437
+ const attributesFallback = {};
3438
+ for (const attr of this.attributes)
3439
+ attributesFallback[attr.name] = undefined;
3440
+ this.setComputedAttribute(attribute.name, createComputedFrom(attribute.computedFromExpression, attributesFallback));
3441
+ }
3308
3442
  propertyResolvers[attribute.name] = attribute.resolve = (object, context, entry) => {
3309
3443
  const value = typeof computed.from === 'string' ? object[computed.from] : object;
3310
3444
  const userResolver = this.userResolvers[attribute.name];
@@ -3358,6 +3492,7 @@ function makeTable(options) {
3358
3492
  }
3359
3493
  }
3360
3494
  }
3495
+ // #section: computed-history
3361
3496
  static setComputedAttribute(attribute_name, resolver) {
3362
3497
  const attribute = (0, search_ts_1.findAttribute)(attributes, attribute_name);
3363
3498
  if (!attribute) {
@@ -3370,6 +3505,25 @@ function makeTable(options) {
3370
3505
  }
3371
3506
  this.userResolvers[attribute_name] = resolver;
3372
3507
  }
3508
+ /**
3509
+ * Override the default embedder for an `@embed` attribute. Return the vector to
3510
+ * store at `attribute_name`. The embedder receives the write payload (the fields
3511
+ * present in the PUT/PATCH body), not the post-merge record, so multi-field
3512
+ * concatenation only works when all source fields are in the same write.
3513
+ */
3514
+ static setEmbedAttribute(attribute_name, embedder) {
3515
+ const attribute = (0, search_ts_1.findAttribute)(attributes, attribute_name);
3516
+ if (!attribute) {
3517
+ console.error(`The attribute "${attribute_name}" does not exist in the table "${tableName}"`);
3518
+ return;
3519
+ }
3520
+ if (!attribute.embed) {
3521
+ console.error(`The attribute "${attribute_name}" is not declared with @embed in the table "${tableName}"`);
3522
+ return;
3523
+ }
3524
+ this.userEmbedders[attribute_name] = embedder;
3525
+ this.userSetEmbedders.add(attribute_name);
3526
+ }
3373
3527
  static async deleteHistory(endTime = 0, cleanupDeletedRecords = false) {
3374
3528
  let completion;
3375
3529
  for (const auditRecord of auditStore.getRange({
@@ -3471,7 +3625,7 @@ function makeTable(options) {
3471
3625
  }
3472
3626
  }
3473
3627
  }, () => {
3474
- throw new hdbError_js_1.ServerError('Service unavailable, exceeded request queue limit for resolving cache record', 503);
3628
+ throw new hdbError_ts_1.ServerError('Service unavailable, exceeded request queue limit for resolving cache record', 503);
3475
3629
  });
3476
3630
  TableResource.updatedAttributes(); // on creation, update accessors as well
3477
3631
  if (expirationMs)
@@ -3501,8 +3655,8 @@ function makeTable(options) {
3501
3655
  hasChanges = true;
3502
3656
  const indexNulls = index.indexNulls;
3503
3657
  // determine what index values need to be removed and added
3504
- let valuesToAdd = (0, commonUtility_js_1.getIndexedValues)(value, indexNulls);
3505
- let valuesToRemove = (0, commonUtility_js_1.getIndexedValues)(existingValue, indexNulls);
3658
+ let valuesToAdd = (0, commonUtility_ts_1.getIndexedValues)(value, indexNulls);
3659
+ let valuesToRemove = (0, commonUtility_ts_1.getIndexedValues)(existingValue, indexNulls);
3506
3660
  let isLMDB = !!index.prefetch;
3507
3661
  if (valuesToRemove?.length > 0) {
3508
3662
  // put this in a conditional so we can do a faster version for new records
@@ -3546,19 +3700,21 @@ function makeTable(options) {
3546
3700
  function checkValidId(id) {
3547
3701
  switch (typeof id) {
3548
3702
  case 'number':
3703
+ if (isNaN(id))
3704
+ throw new hdbError_ts_1.ClientError('Invalid primary key of NaN', 400);
3549
3705
  return true;
3550
3706
  case 'string':
3551
3707
  if (id.length < 659)
3552
3708
  return true; // max number of characters that can't expand our key size limit
3553
3709
  if (id.length > MAX_KEY_BYTES) {
3554
3710
  // we can quickly determine this is too big
3555
- throw new Error('Primary key size is too large: ' + id.length);
3711
+ throw new hdbError_ts_1.ClientError('Primary key size is too large: ' + id.length, 400);
3556
3712
  }
3557
3713
  // 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
3558
3714
  break; // otherwise we have to test it, in this range, unicode characters could put it over the limit
3559
3715
  case 'object':
3560
3716
  if (id === null) {
3561
- throw new Error('Invalid primary key of null');
3717
+ throw new hdbError_ts_1.ClientError('Invalid primary key of null', 400);
3562
3718
  }
3563
3719
  break; // otherwise we have to test it
3564
3720
  case 'bigint':
@@ -3566,13 +3722,13 @@ function makeTable(options) {
3566
3722
  return true;
3567
3723
  break; // otherwise we have to test it
3568
3724
  default:
3569
- throw new Error('Invalid primary key type: ' + typeof id);
3725
+ throw new hdbError_ts_1.ClientError('Invalid primary key type: ' + typeof id, 400);
3570
3726
  }
3571
3727
  // otherwise it is difficult to determine if the key size is too large
3572
3728
  // without actually attempting to serialize it
3573
3729
  const length = (0, ordered_binary_1.writeKey)(id, TEST_WRITE_KEY_BUFFER, 0);
3574
3730
  if (length > MAX_KEY_BYTES)
3575
- throw new Error('Primary key size is too large: ' + id.length);
3731
+ throw new hdbError_ts_1.ClientError('Primary key size is too large: ' + id.length, 400);
3576
3732
  return true;
3577
3733
  }
3578
3734
  function requestTargetToId(target) {
@@ -3613,7 +3769,7 @@ function makeTable(options) {
3613
3769
  // skip recording reads for most system tables except hdb_analytics
3614
3770
  // we want to track analytics reads in licensing, etc.
3615
3771
  if (databaseName !== 'system' && (options.type === 'read' || !options.type)) {
3616
- harper_logger_js_1.default.trace?.('Recording db-read action for', `${databaseName}.${tableName}`);
3772
+ harper_logger_ts_1.default.trace?.('Recording db-read action for', `${databaseName}.${tableName}`);
3617
3773
  (0, write_ts_1.recordAction)(entry?.size ?? 1, 'db-read', tableName, null);
3618
3774
  }
3619
3775
  // we need to freeze entry records to ensure the integrity of the cache;
@@ -3744,6 +3900,11 @@ function makeTable(options) {
3744
3900
  }
3745
3901
  }
3746
3902
  function ensureLoadedFromSource(source, id, entry, context, resource, target) {
3903
+ if (context?.onlyIfCached) {
3904
+ if (!entry?.value)
3905
+ throw new hdbError_ts_1.ServerError('Entry is not cached', 504);
3906
+ return;
3907
+ }
3747
3908
  if (hasSourceGet) {
3748
3909
  let needsSourceData = false;
3749
3910
  if (context.noCache)
@@ -3774,11 +3935,9 @@ function makeTable(options) {
3774
3935
  return entry;
3775
3936
  });
3776
3937
  // if the resource defines a method for indicating if stale-while-revalidate is allowed for a record
3777
- if (context?.onlyIfCached || (entry?.value && resource?.allowStaleWhileRevalidate?.(entry, id))) {
3938
+ if (entry?.value && resource?.allowStaleWhileRevalidate?.(entry, id)) {
3778
3939
  // since we aren't waiting for it any errors won't propagate so we should at least log them
3779
3940
  loadingFromSource.catch((error) => logger_ts_1.logger.warn?.(error));
3780
- if (context?.onlyIfCached && !resource.doesExist())
3781
- throw new hdbError_js_1.ServerError('Entry is not cached', 504);
3782
3941
  return; // go ahead and return and let the current stale value be used while we re-validate
3783
3942
  }
3784
3943
  else
@@ -3830,7 +3989,7 @@ function makeTable(options) {
3830
3989
  } while (true);
3831
3990
  }
3832
3991
  else {
3833
- transaction = isRocksDB ? new DatabaseTransaction_ts_1.ImmediateTransaction(primaryStore) : new LMDBTransaction_1.ImmediateTransaction(primaryStore);
3992
+ transaction = (isRocksDB ? new DatabaseTransaction_ts_1.ImmediateTransaction(primaryStore) : new LMDBTransaction_1.ImmediateTransaction(primaryStore));
3834
3993
  if (context) {
3835
3994
  context.transaction = transaction;
3836
3995
  if (context.timestamp)
@@ -4035,16 +4194,15 @@ function makeTable(options) {
4035
4194
  throw new Error('Only objects can be cached and stored in tables');
4036
4195
  if (updatedRecord.status > 0 && updatedRecord.headers) {
4037
4196
  // if the source has a status code and headers, treat it as a response
4038
- if (updatedRecord.status >= 300) {
4039
- if (updatedRecord.status === 304) {
4040
- // revalidation of our current cached record
4041
- updatedRecord = existingRecord;
4042
- version = existingVersion;
4043
- }
4044
- else {
4045
- // if the source has an error status, we need to throw an error
4046
- throw new hdbError_js_1.ServerError(updatedRecord.body || 'Error from source', updatedRecord.status);
4047
- } // there are definitely more status codes to handle
4197
+ const status = updatedRecord.status;
4198
+ if (status === 304) {
4199
+ // revalidation of our current cached record
4200
+ updatedRecord = existingRecord;
4201
+ version = existingVersion;
4202
+ }
4203
+ else if (!CACHEABLE_STATUS_CODES.has(status)) {
4204
+ // non-cacheable status - propagate to client without caching
4205
+ throw new hdbError_ts_1.ServerError(updatedRecord.body || 'Error from source', status);
4048
4206
  }
4049
4207
  else {
4050
4208
  let headers;
@@ -4073,35 +4231,46 @@ function makeTable(options) {
4073
4231
  if (data !== undefined) {
4074
4232
  // we have structured data that we have parsed
4075
4233
  delete headers['content-type']; // don't store the content type if we have already parsed it
4076
- updatedRecord = {
4077
- headers,
4078
- data,
4079
- };
4234
+ updatedRecord = { headers, data };
4080
4235
  }
4081
4236
  else {
4082
- updatedRecord = {
4083
- headers,
4084
- body: createBlob(updatedRecord.body),
4085
- };
4237
+ updatedRecord = { headers, body: createBlob(updatedRecord.body) };
4086
4238
  }
4239
+ if (status !== 200)
4240
+ updatedRecord.status = status;
4087
4241
  }
4088
4242
  }
4089
4243
  if (typeof updatedRecord.toJSON === 'function')
4090
4244
  updatedRecord = updatedRecord.toJSON();
4091
4245
  // updatedRecord may still be a frozen record (e.g. a reused existingRecord); copy-on-mutate
4092
- // before stamping the primary key below (records are immutable — 5.2 record caching relies
4093
- // on it — so we must not write through the frozen object).
4246
+ // before stamping the primary key and created/updated times below (records are immutable —
4247
+ // 5.2 record caching relies on it — so we must not write through the frozen object).
4094
4248
  if (isFrozenRecordObject(updatedRecord))
4095
4249
  updatedRecord = { ...updatedRecord };
4096
4250
  if (primaryKey && updatedRecord[primaryKey] !== id)
4097
4251
  updatedRecord[primaryKey] = id;
4098
4252
  }
4099
4253
  resolved = true;
4100
- resolve({
4254
+ const resolvedEntry = {
4101
4255
  key: id,
4102
4256
  version,
4103
4257
  value: updatedRecord,
4104
- });
4258
+ expiresAt: sourceContext.expiresAt,
4259
+ metadataFlags: 0,
4260
+ size: 0,
4261
+ localTime: 0,
4262
+ nodeId: 0,
4263
+ residencyId: 0,
4264
+ };
4265
+ // Give the plain object the RecordObject prototype so getExpiresAt/getUpdatedTime
4266
+ // are available on the immediately-resolved entry. We mutate the prototype
4267
+ // in-place rather than copying so that the commit callback (which adds
4268
+ // createdAt/updatedAt to updatedRecord) is still reflected in the entry value.
4269
+ if (updatedRecord && updatedRecord.constructor === Object) {
4270
+ Object.setPrototypeOf(updatedRecord, primaryStore.encoder.structPrototype);
4271
+ RecordEncoder_ts_1.entryMap.set(updatedRecord, resolvedEntry);
4272
+ }
4273
+ resolve(resolvedEntry);
4105
4274
  }
4106
4275
  catch (error) {
4107
4276
  error.message += ` while resolving record ${id} for ${tableName}`;
@@ -4232,6 +4401,14 @@ function makeTable(options) {
4232
4401
  }
4233
4402
  },
4234
4403
  };
4404
+ // The cache-from-source write bypasses `_writeUpdate`, so wire the embed hook here
4405
+ // too (always the originating node). It runs after the client GET has resolved with
4406
+ // fresh source data, so it's a background commit: an embedder failure aborts the cache
4407
+ // write via the outer error handler (row re-embeds next read) and never reaches the
4408
+ // caller. Source-resolution errors are handled earlier, with the stale-data fallback.
4409
+ const embedBefore = (0, embedHook_ts_1.buildEmbedBefore)(updatedRecord, sourceContext, undefined, TableResource.embedAttributes, TableResource.userEmbedders);
4410
+ if (embedBefore)
4411
+ await embedBefore();
4235
4412
  sourceWrite.before = preCommitBlobsForRecordBefore(sourceWrite, updatedRecord);
4236
4413
  dbTxn.addWrite(sourceWrite);
4237
4414
  }), () => {
@@ -4254,9 +4431,9 @@ function makeTable(options) {
4254
4431
  if (context.user?.role?.permission?.super_user)
4255
4432
  return true;
4256
4433
  if (context.replicateTo)
4257
- throw new hdbError_js_1.ClientError('Can not specify replication parameters without super user permissions', 403);
4434
+ throw new hdbError_ts_1.ClientError('Can not specify replication parameters without super user permissions', 403);
4258
4435
  if (context.replicatedConfirmation)
4259
- throw new hdbError_js_1.ClientError('Can not specify replication confirmation without super user permissions', 403);
4436
+ throw new hdbError_ts_1.ClientError('Can not specify replication confirmation without super user permissions', 403);
4260
4437
  return true;
4261
4438
  }
4262
4439
  function scheduleCleanup(priority) {
@@ -4460,7 +4637,9 @@ function makeTable(options) {
4460
4637
  return callSources
4461
4638
  ? async () => {
4462
4639
  // if we are calling the sources first and waiting for blobs, do those in order
4463
- await callSources();
4640
+ const result = callSources();
4641
+ if (result && result.then)
4642
+ await result;
4464
4643
  await preCommit.complete();
4465
4644
  }
4466
4645
  : () => preCommit.complete();
@@ -4482,6 +4661,17 @@ function attributesAsObject(attribute_permissions, type) {
4482
4661
  function noop() {
4483
4662
  // prefetch callback
4484
4663
  }
4664
+ /**
4665
+ * Recreate a computed "from" function from a stored expression string. This is used when a table
4666
+ * is loaded from metadata on a thread that hasn't loaded the GraphQL schema, so the computed
4667
+ * function needs to be reconstructed from the persisted expression.
4668
+ */
4669
+ function createComputedFrom(computedFromExpression, attributesFallback) {
4670
+ const script = new node_vm_1.Script(attributesFallback
4671
+ ? `function computed(attributes) { return function(record) { with(attributes) { with (record) { return ${computedFromExpression}; } } } } computed;`
4672
+ : `function computed() { return function(record) { with (record) { return ${computedFromExpression}; } } } computed;`);
4673
+ return script.runInThisContext()(attributesFallback);
4674
+ }
4485
4675
  const ENDS_WITH_TIMEZONE = /[+-][0-9]{2}:[0-9]{2}|[a-zA-Z]$/;
4486
4676
  /**
4487
4677
  * Coerce a string to the type defined by the attribute
@@ -4516,7 +4706,7 @@ function coerceType(value, attribute) {
4516
4706
  case 'BigInt':
4517
4707
  return value === 'null' ? null : BigInt(value);
4518
4708
  case 'Boolean':
4519
- return (0, common_utils_js_1.autoCastBooleanStrict)(value);
4709
+ return (0, common_utils_ts_1.autoCastBooleanStrict)(value);
4520
4710
  case 'Date':
4521
4711
  if (isNaN(value)) {
4522
4712
  if (value === 'null')
@@ -4532,7 +4722,7 @@ function coerceType(value, attribute) {
4532
4722
  return new Date(+value); // epoch ms number
4533
4723
  case undefined:
4534
4724
  case 'Any':
4535
- return (0, common_utils_js_1.autoCast)(value);
4725
+ return (0, common_utils_ts_1.autoCast)(value);
4536
4726
  default:
4537
4727
  return value;
4538
4728
  }