@undefineds.co/xpod 0.2.45 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (414) hide show
  1. package/dist/agents/AgentExecutorFactory.js +12 -13
  2. package/dist/agents/AgentExecutorFactory.js.map +1 -1
  3. package/dist/agents/config/agent-meta-schema.d.ts +31 -3
  4. package/dist/agents/config/agent-meta-schema.js +37 -3
  5. package/dist/agents/config/agent-meta-schema.js.map +1 -1
  6. package/dist/agents/config/index.d.ts +5 -5
  7. package/dist/agents/config/index.js +7 -6
  8. package/dist/agents/config/index.js.map +1 -1
  9. package/dist/agents/config/parse-agent-instructions.d.ts +12 -0
  10. package/dist/agents/config/parse-agent-instructions.js +23 -0
  11. package/dist/agents/config/parse-agent-instructions.js.map +1 -0
  12. package/dist/agents/config/resolve.d.ts +7 -12
  13. package/dist/agents/config/resolve.js +272 -156
  14. package/dist/agents/config/resolve.js.map +1 -1
  15. package/dist/agents/config/types.d.ts +33 -36
  16. package/dist/agents/config/types.js +4 -4
  17. package/dist/agents/config/types.js.map +1 -1
  18. package/dist/agents/index.d.ts +2 -7
  19. package/dist/agents/index.js +4 -14
  20. package/dist/agents/index.js.map +1 -1
  21. package/dist/agents/types.d.ts +2 -2
  22. package/dist/agents/types.js.map +1 -1
  23. package/dist/ai/service/CredentialReaderImpl.js +9 -14
  24. package/dist/ai/service/CredentialReaderImpl.js.map +1 -1
  25. package/dist/api/ApiServer.d.ts +7 -0
  26. package/dist/api/ApiServer.js +5 -1
  27. package/dist/api/ApiServer.js.map +1 -1
  28. package/dist/api/chatkit/default-agent.js +1 -1
  29. package/dist/api/chatkit/default-agent.js.map +1 -1
  30. package/dist/api/chatkit/index.d.ts +8 -0
  31. package/dist/api/chatkit/index.js +15 -1
  32. package/dist/api/chatkit/index.js.map +1 -1
  33. package/dist/api/chatkit/pod-store.d.ts +80 -17
  34. package/dist/api/chatkit/pod-store.js +816 -162
  35. package/dist/api/chatkit/pod-store.js.map +1 -1
  36. package/dist/api/chatkit/runtime/AcpAgentRuntime.d.ts +41 -0
  37. package/dist/api/chatkit/runtime/AcpAgentRuntime.js +573 -0
  38. package/dist/api/chatkit/runtime/AcpAgentRuntime.js.map +1 -0
  39. package/dist/api/chatkit/runtime/CodexRuntimeProjector.d.ts +27 -0
  40. package/dist/api/chatkit/runtime/CodexRuntimeProjector.js +157 -0
  41. package/dist/api/chatkit/runtime/CodexRuntimeProjector.js.map +1 -0
  42. package/dist/api/chatkit/schema.d.ts +53 -133
  43. package/dist/api/chatkit/schema.js +11 -175
  44. package/dist/api/chatkit/schema.js.map +1 -1
  45. package/dist/api/chatkit/service.d.ts +15 -9
  46. package/dist/api/chatkit/service.js +82 -234
  47. package/dist/api/chatkit/service.js.map +1 -1
  48. package/dist/api/chatkit/store.d.ts +35 -3
  49. package/dist/api/chatkit/store.js +157 -3
  50. package/dist/api/chatkit/store.js.map +1 -1
  51. package/dist/api/chatkit/types.d.ts +16 -2
  52. package/dist/api/chatkit/types.js +24 -5
  53. package/dist/api/chatkit/types.js.map +1 -1
  54. package/dist/api/container/common.js +59 -2
  55. package/dist/api/container/common.js.map +1 -1
  56. package/dist/api/container/index.js +15 -0
  57. package/dist/api/container/index.js.map +1 -1
  58. package/dist/api/container/routes.js +11 -0
  59. package/dist/api/container/routes.js.map +1 -1
  60. package/dist/api/container/types.d.ts +26 -0
  61. package/dist/api/container/types.js.map +1 -1
  62. package/dist/api/handlers/InngestHandler.d.ts +11 -0
  63. package/dist/api/handlers/InngestHandler.js +19 -0
  64. package/dist/api/handlers/InngestHandler.js.map +1 -0
  65. package/dist/api/handlers/RunHandler.d.ts +7 -0
  66. package/dist/api/handlers/RunHandler.js +169 -0
  67. package/dist/api/handlers/RunHandler.js.map +1 -0
  68. package/dist/api/handlers/index.d.ts +1 -0
  69. package/dist/api/handlers/index.js +1 -0
  70. package/dist/api/handlers/index.js.map +1 -1
  71. package/dist/api/models/namespaces.d.ts +2 -2
  72. package/dist/api/models/namespaces.js +1 -4
  73. package/dist/api/models/namespaces.js.map +1 -1
  74. package/dist/api/runs/AgentRuntimeTypes.d.ts +83 -0
  75. package/dist/api/runs/AgentRuntimeTypes.js +3 -0
  76. package/dist/api/runs/AgentRuntimeTypes.js.map +1 -0
  77. package/dist/api/runs/EmbeddedInngestService.d.ts +47 -0
  78. package/dist/api/runs/EmbeddedInngestService.js +203 -0
  79. package/dist/api/runs/EmbeddedInngestService.js.map +1 -0
  80. package/dist/api/runs/InngestRunExecutionBackend.d.ts +416 -0
  81. package/dist/api/runs/InngestRunExecutionBackend.js +225 -0
  82. package/dist/api/runs/InngestRunExecutionBackend.js.map +1 -0
  83. package/dist/api/runs/ManagedRunWorker.d.ts +52 -0
  84. package/dist/api/runs/ManagedRunWorker.js +452 -0
  85. package/dist/api/runs/ManagedRunWorker.js.map +1 -0
  86. package/dist/api/runs/PiAgentRuntimeDriver.d.ts +66 -0
  87. package/dist/api/runs/PiAgentRuntimeDriver.js +614 -0
  88. package/dist/api/runs/PiAgentRuntimeDriver.js.map +1 -0
  89. package/dist/api/runs/PiAgentRuntimeWorker.d.ts +1 -0
  90. package/dist/api/runs/PiAgentRuntimeWorker.js +33 -0
  91. package/dist/api/runs/PiAgentRuntimeWorker.js.map +1 -0
  92. package/dist/api/runs/RunAuthContextRegistry.d.ts +19 -0
  93. package/dist/api/runs/RunAuthContextRegistry.js +59 -0
  94. package/dist/api/runs/RunAuthContextRegistry.js.map +1 -0
  95. package/dist/api/runs/RunExecutionBackend.d.ts +57 -0
  96. package/dist/api/runs/RunExecutionBackend.js +3 -0
  97. package/dist/api/runs/RunExecutionBackend.js.map +1 -0
  98. package/dist/api/runs/RunStateCenter.d.ts +82 -0
  99. package/dist/api/runs/RunStateCenter.js +665 -0
  100. package/dist/api/runs/RunStateCenter.js.map +1 -0
  101. package/dist/api/runs/schema.d.ts +55 -0
  102. package/dist/api/runs/schema.js +14 -0
  103. package/dist/api/runs/schema.js.map +1 -0
  104. package/dist/api/runs/store.d.ts +105 -0
  105. package/dist/api/runs/store.js +116 -0
  106. package/dist/api/runs/store.js.map +1 -0
  107. package/dist/api/runtime.d.ts +2 -0
  108. package/dist/api/runtime.js +40 -1
  109. package/dist/api/runtime.js.map +1 -1
  110. package/dist/api/service/VectorStoreService.d.ts +1 -0
  111. package/dist/api/service/VectorStoreService.js +27 -34
  112. package/dist/api/service/VectorStoreService.js.map +1 -1
  113. package/dist/api/service/provider-registry.d.ts +1 -1
  114. package/dist/api/service/provider-registry.js +1 -1
  115. package/dist/api/service/provider-registry.js.map +1 -1
  116. package/dist/api/tasks/InngestTaskScheduler.d.ts +751 -0
  117. package/dist/api/tasks/InngestTaskScheduler.js +209 -0
  118. package/dist/api/tasks/InngestTaskScheduler.js.map +1 -0
  119. package/dist/api/tasks/TaskAuthBinding.d.ts +68 -0
  120. package/dist/api/tasks/TaskAuthBinding.js +162 -0
  121. package/dist/api/tasks/TaskAuthBinding.js.map +1 -0
  122. package/dist/api/tasks/TaskMaterializer.d.ts +55 -0
  123. package/dist/api/tasks/TaskMaterializer.js +452 -0
  124. package/dist/api/tasks/TaskMaterializer.js.map +1 -0
  125. package/dist/api/tasks/TaskService.d.ts +57 -0
  126. package/dist/api/tasks/TaskService.js +235 -0
  127. package/dist/api/tasks/TaskService.js.map +1 -0
  128. package/dist/api/tasks/index.d.ts +6 -0
  129. package/dist/api/tasks/index.js +25 -0
  130. package/dist/api/tasks/index.js.map +1 -0
  131. package/dist/api/tasks/schema.d.ts +23 -0
  132. package/dist/api/tasks/schema.js +8 -0
  133. package/dist/api/tasks/schema.js.map +1 -0
  134. package/dist/api/tasks/store.d.ts +40 -0
  135. package/dist/api/tasks/store.js +34 -0
  136. package/dist/api/tasks/store.js.map +1 -0
  137. package/dist/api/workspace/types.d.ts +3 -0
  138. package/dist/api/workspace/types.js +23 -0
  139. package/dist/api/workspace/types.js.map +1 -0
  140. package/dist/cli/commands/config.d.ts +8 -7
  141. package/dist/cli/commands/config.js +72 -48
  142. package/dist/cli/commands/config.js.map +1 -1
  143. package/dist/cli/commands/login.d.ts +10 -8
  144. package/dist/cli/commands/login.js +84 -84
  145. package/dist/cli/commands/login.js.map +1 -1
  146. package/dist/cli/index.js +3 -124
  147. package/dist/cli/index.js.map +1 -1
  148. package/dist/http/search/SearchHttpHandler.js +13 -18
  149. package/dist/http/search/SearchHttpHandler.js.map +1 -1
  150. package/dist/storage/vector/VectorIndexingListener.js +13 -18
  151. package/dist/storage/vector/VectorIndexingListener.js.map +1 -1
  152. package/dist/vocab/index.d.ts +2 -6
  153. package/dist/vocab/index.js +2 -6
  154. package/dist/vocab/index.js.map +1 -1
  155. package/dist/vocab/udfs.d.ts +12 -0
  156. package/dist/vocab/udfs.js +12 -0
  157. package/dist/vocab/udfs.js.map +1 -1
  158. package/node_modules/@undefineds.co/drizzle-solid/README.md +52 -24
  159. package/node_modules/@undefineds.co/drizzle-solid/README.zh-CN.md +30 -24
  160. package/node_modules/@undefineds.co/drizzle-solid/dist/core/discovery/types.d.ts +6 -2
  161. package/node_modules/@undefineds.co/drizzle-solid/dist/core/discovery/types.d.ts.map +1 -1
  162. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-executor.d.ts +1 -0
  163. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-executor.d.ts.map +1 -1
  164. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-executor.js +43 -10
  165. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-executor.js.map +1 -1
  166. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-strategy.d.ts.map +1 -1
  167. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-strategy.js +1 -0
  168. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-strategy.js.map +1 -1
  169. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/pod-executor.d.ts +5 -0
  170. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/pod-executor.d.ts.map +1 -1
  171. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/pod-executor.js +44 -13
  172. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/pod-executor.js.map +1 -1
  173. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/sparql-strategy.d.ts +1 -0
  174. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/sparql-strategy.d.ts.map +1 -1
  175. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/sparql-strategy.js +21 -2
  176. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/sparql-strategy.js.map +1 -1
  177. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/types.d.ts +1 -0
  178. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/types.d.ts.map +1 -1
  179. package/node_modules/@undefineds.co/drizzle-solid/dist/core/expressions.d.ts +1 -1
  180. package/node_modules/@undefineds.co/drizzle-solid/dist/core/expressions.d.ts.map +1 -1
  181. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-database.d.ts +76 -41
  182. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-database.d.ts.map +1 -1
  183. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-database.js +443 -114
  184. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-database.js.map +1 -1
  185. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-dialect.d.ts +28 -1
  186. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-dialect.d.ts.map +1 -1
  187. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-dialect.js +142 -31
  188. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-dialect.js.map +1 -1
  189. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-session.d.ts +3 -0
  190. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-session.d.ts.map +1 -1
  191. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-session.js +84 -6
  192. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-session.js.map +1 -1
  193. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/insert-query-builder.d.ts +3 -0
  194. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/insert-query-builder.d.ts.map +1 -1
  195. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/insert-query-builder.js +29 -9
  196. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/insert-query-builder.js.map +1 -1
  197. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/select-query-builder.d.ts +2 -8
  198. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/select-query-builder.d.ts.map +1 -1
  199. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/select-query-builder.js +19 -51
  200. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/select-query-builder.js.map +1 -1
  201. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/types.d.ts +1 -0
  202. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/types.d.ts.map +1 -1
  203. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-conditions.d.ts +2 -2
  204. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-conditions.d.ts.map +1 -1
  205. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-where-policy.js +6 -6
  206. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-where-policy.js.map +1 -1
  207. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-reference.d.ts +4 -4
  208. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-reference.d.ts.map +1 -1
  209. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-reference.js +56 -23
  210. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-reference.js.map +1 -1
  211. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-resolver/base-resolver.d.ts +14 -10
  212. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-resolver/base-resolver.d.ts.map +1 -1
  213. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-resolver/base-resolver.js +55 -23
  214. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-resolver/base-resolver.js.map +1 -1
  215. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-resolver/document-resolver.d.ts +3 -3
  216. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-resolver/document-resolver.js +6 -6
  217. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-resolver/document-resolver.js.map +1 -1
  218. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-resolver/fragment-resolver.d.ts +3 -3
  219. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-resolver/fragment-resolver.js +4 -4
  220. package/node_modules/@undefineds.co/drizzle-solid/dist/core/resource-resolver/fragment-resolver.js.map +1 -1
  221. package/node_modules/@undefineds.co/drizzle-solid/dist/core/runtime/pod-runtime.d.ts.map +1 -1
  222. package/node_modules/@undefineds.co/drizzle-solid/dist/core/runtime/pod-runtime.js +33 -8
  223. package/node_modules/@undefineds.co/drizzle-solid/dist/core/runtime/pod-runtime.js.map +1 -1
  224. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/defs.d.ts +11 -2
  225. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/defs.d.ts.map +1 -1
  226. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/factories.d.ts.map +1 -1
  227. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/factories.js +3 -2
  228. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/factories.js.map +1 -1
  229. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/pod-table.d.ts +13 -8
  230. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/pod-table.d.ts.map +1 -1
  231. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/pod-table.js +24 -22
  232. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/pod-table.js.map +1 -1
  233. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/solid-schema.d.ts +3 -0
  234. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/solid-schema.d.ts.map +1 -1
  235. package/node_modules/@undefineds.co/drizzle-solid/dist/core/schema/solid-schema.js.map +1 -1
  236. package/node_modules/@undefineds.co/drizzle-solid/dist/core/subject/resolver.d.ts +3 -2
  237. package/node_modules/@undefineds.co/drizzle-solid/dist/core/subject/resolver.d.ts.map +1 -1
  238. package/node_modules/@undefineds.co/drizzle-solid/dist/core/subject/resolver.js +28 -14
  239. package/node_modules/@undefineds.co/drizzle-solid/dist/core/subject/resolver.js.map +1 -1
  240. package/node_modules/@undefineds.co/drizzle-solid/dist/core/triple/handlers/inline.d.ts.map +1 -1
  241. package/node_modules/@undefineds.co/drizzle-solid/dist/core/triple/handlers/inline.js +3 -2
  242. package/node_modules/@undefineds.co/drizzle-solid/dist/core/triple/handlers/inline.js.map +1 -1
  243. package/node_modules/@undefineds.co/drizzle-solid/dist/core/uri/resolver.d.ts +9 -9
  244. package/node_modules/@undefineds.co/drizzle-solid/dist/core/uri/resolver.d.ts.map +1 -1
  245. package/node_modules/@undefineds.co/drizzle-solid/dist/core/uri/resolver.js +56 -22
  246. package/node_modules/@undefineds.co/drizzle-solid/dist/core/uri/resolver.js.map +1 -1
  247. package/node_modules/@undefineds.co/drizzle-solid/dist/driver.d.ts +9 -1
  248. package/node_modules/@undefineds.co/drizzle-solid/dist/driver.d.ts.map +1 -1
  249. package/node_modules/@undefineds.co/drizzle-solid/dist/driver.js +2 -0
  250. package/node_modules/@undefineds.co/drizzle-solid/dist/driver.js.map +1 -1
  251. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/discovery/types.d.ts +6 -2
  252. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/discovery/types.d.ts.map +1 -1
  253. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-executor.d.ts +1 -0
  254. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-executor.d.ts.map +1 -1
  255. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-executor.js +43 -10
  256. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-executor.js.map +1 -1
  257. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-strategy.d.ts.map +1 -1
  258. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-strategy.js +1 -0
  259. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-strategy.js.map +1 -1
  260. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/pod-executor.d.ts +5 -0
  261. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/pod-executor.d.ts.map +1 -1
  262. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/pod-executor.js +44 -13
  263. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/pod-executor.js.map +1 -1
  264. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/sparql-strategy.d.ts +1 -0
  265. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/sparql-strategy.d.ts.map +1 -1
  266. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/sparql-strategy.js +21 -2
  267. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/sparql-strategy.js.map +1 -1
  268. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/types.d.ts +1 -0
  269. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/types.d.ts.map +1 -1
  270. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/expressions.d.ts +1 -1
  271. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/expressions.d.ts.map +1 -1
  272. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-database.d.ts +76 -41
  273. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-database.d.ts.map +1 -1
  274. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-database.js +443 -114
  275. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-database.js.map +1 -1
  276. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-dialect.d.ts +28 -1
  277. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-dialect.d.ts.map +1 -1
  278. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-dialect.js +142 -31
  279. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-dialect.js.map +1 -1
  280. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-session.d.ts +3 -0
  281. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-session.d.ts.map +1 -1
  282. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-session.js +84 -6
  283. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-session.js.map +1 -1
  284. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/insert-query-builder.d.ts +3 -0
  285. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/insert-query-builder.d.ts.map +1 -1
  286. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/insert-query-builder.js +29 -9
  287. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/insert-query-builder.js.map +1 -1
  288. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/select-query-builder.d.ts +2 -8
  289. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/select-query-builder.d.ts.map +1 -1
  290. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/select-query-builder.js +19 -51
  291. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/select-query-builder.js.map +1 -1
  292. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/types.d.ts +1 -0
  293. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/types.d.ts.map +1 -1
  294. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-conditions.d.ts +2 -2
  295. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-conditions.d.ts.map +1 -1
  296. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-where-policy.js +6 -6
  297. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-where-policy.js.map +1 -1
  298. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-reference.d.ts +4 -4
  299. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-reference.d.ts.map +1 -1
  300. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-reference.js +56 -23
  301. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-reference.js.map +1 -1
  302. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-resolver/base-resolver.d.ts +14 -10
  303. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-resolver/base-resolver.d.ts.map +1 -1
  304. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-resolver/base-resolver.js +55 -23
  305. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-resolver/base-resolver.js.map +1 -1
  306. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-resolver/document-resolver.d.ts +3 -3
  307. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-resolver/document-resolver.js +6 -6
  308. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-resolver/document-resolver.js.map +1 -1
  309. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-resolver/fragment-resolver.d.ts +3 -3
  310. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-resolver/fragment-resolver.js +4 -4
  311. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/resource-resolver/fragment-resolver.js.map +1 -1
  312. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/runtime/pod-runtime.d.ts.map +1 -1
  313. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/runtime/pod-runtime.js +33 -8
  314. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/runtime/pod-runtime.js.map +1 -1
  315. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/defs.d.ts +11 -2
  316. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/defs.d.ts.map +1 -1
  317. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/factories.d.ts.map +1 -1
  318. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/factories.js +3 -2
  319. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/factories.js.map +1 -1
  320. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/pod-table.d.ts +13 -8
  321. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/pod-table.d.ts.map +1 -1
  322. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/pod-table.js +24 -22
  323. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/pod-table.js.map +1 -1
  324. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/solid-schema.d.ts +3 -0
  325. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/solid-schema.d.ts.map +1 -1
  326. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/schema/solid-schema.js.map +1 -1
  327. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/subject/resolver.d.ts +3 -2
  328. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/subject/resolver.d.ts.map +1 -1
  329. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/subject/resolver.js +28 -14
  330. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/subject/resolver.js.map +1 -1
  331. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/triple/handlers/inline.d.ts.map +1 -1
  332. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/triple/handlers/inline.js +3 -2
  333. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/triple/handlers/inline.js.map +1 -1
  334. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/uri/resolver.d.ts +9 -9
  335. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/uri/resolver.d.ts.map +1 -1
  336. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/uri/resolver.js +56 -22
  337. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/uri/resolver.js.map +1 -1
  338. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/driver.d.ts +9 -1
  339. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/driver.d.ts.map +1 -1
  340. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/driver.js +2 -0
  341. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/driver.js.map +1 -1
  342. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/pod.d.ts +16 -2
  343. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/pod.d.ts.map +1 -1
  344. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/utils/find-by-iri.js +1 -1
  345. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/utils/find-by-iri.js.map +1 -1
  346. package/node_modules/@undefineds.co/drizzle-solid/dist/pod.d.ts +16 -2
  347. package/node_modules/@undefineds.co/drizzle-solid/dist/pod.d.ts.map +1 -1
  348. package/node_modules/@undefineds.co/drizzle-solid/dist/utils/find-by-iri.js +1 -1
  349. package/node_modules/@undefineds.co/drizzle-solid/dist/utils/find-by-iri.js.map +1 -1
  350. package/node_modules/@undefineds.co/drizzle-solid/package.json +1 -1
  351. package/package.json +9 -3
  352. package/dist/agents/AgentManager.d.ts +0 -116
  353. package/dist/agents/AgentManager.js +0 -290
  354. package/dist/agents/AgentManager.js.map +0 -1
  355. package/dist/agents/IndexAgent.d.ts +0 -70
  356. package/dist/agents/IndexAgent.js +0 -417
  357. package/dist/agents/IndexAgent.js.map +0 -1
  358. package/dist/agents/config/parse-agent-md.d.ts +0 -33
  359. package/dist/agents/config/parse-agent-md.js +0 -75
  360. package/dist/agents/config/parse-agent-md.js.map +0 -1
  361. package/dist/agents/schema/agent-config.d.ts +0 -2
  362. package/dist/agents/schema/agent-config.js +0 -32
  363. package/dist/agents/schema/agent-config.js.map +0 -1
  364. package/dist/agents/schema/create-agent-schema.d.ts +0 -25
  365. package/dist/agents/schema/create-agent-schema.js +0 -35
  366. package/dist/agents/schema/create-agent-schema.js.map +0 -1
  367. package/dist/api/chatkit/runtime/PtyThreadRuntime.d.ts +0 -127
  368. package/dist/api/chatkit/runtime/PtyThreadRuntime.js +0 -791
  369. package/dist/api/chatkit/runtime/PtyThreadRuntime.js.map +0 -1
  370. package/dist/cli/lib/agent-session.d.ts +0 -37
  371. package/dist/cli/lib/agent-session.js +0 -211
  372. package/dist/cli/lib/agent-session.js.map +0 -1
  373. package/dist/cli/lib/ensure-ai-credentials.d.ts +0 -13
  374. package/dist/cli/lib/ensure-ai-credentials.js +0 -40
  375. package/dist/cli/lib/ensure-ai-credentials.js.map +0 -1
  376. package/dist/cli/lib/model-manager.d.ts +0 -37
  377. package/dist/cli/lib/model-manager.js +0 -251
  378. package/dist/cli/lib/model-manager.js.map +0 -1
  379. package/dist/cli/lib/oauth-credential-manager.d.ts +0 -37
  380. package/dist/cli/lib/oauth-credential-manager.js +0 -129
  381. package/dist/cli/lib/oauth-credential-manager.js.map +0 -1
  382. package/dist/cli/lib/oauth-providers/codebuddy.d.ts +0 -25
  383. package/dist/cli/lib/oauth-providers/codebuddy.js +0 -69
  384. package/dist/cli/lib/oauth-providers/codebuddy.js.map +0 -1
  385. package/dist/cli/lib/oauth-providers/index.d.ts +0 -12
  386. package/dist/cli/lib/oauth-providers/index.js +0 -23
  387. package/dist/cli/lib/oauth-providers/index.js.map +0 -1
  388. package/dist/cli/lib/pi-optional.d.ts +0 -84
  389. package/dist/cli/lib/pi-optional.js +0 -35
  390. package/dist/cli/lib/pi-optional.js.map +0 -1
  391. package/dist/cli/lib/pod-ai-config.d.ts +0 -26
  392. package/dist/cli/lib/pod-ai-config.js +0 -99
  393. package/dist/cli/lib/pod-ai-config.js.map +0 -1
  394. package/dist/cli/lib/pod-thread-store.d.ts +0 -57
  395. package/dist/cli/lib/pod-thread-store.js +0 -312
  396. package/dist/cli/lib/pod-thread-store.js.map +0 -1
  397. package/dist/cli/lib/secretary-prompt.d.ts +0 -6
  398. package/dist/cli/lib/secretary-prompt.js +0 -85
  399. package/dist/cli/lib/secretary-prompt.js.map +0 -1
  400. package/dist/task/DrizzleTaskQueue.d.ts +0 -56
  401. package/dist/task/DrizzleTaskQueue.js +0 -171
  402. package/dist/task/DrizzleTaskQueue.js.map +0 -1
  403. package/dist/task/TaskExecutor.d.ts +0 -82
  404. package/dist/task/TaskExecutor.js +0 -198
  405. package/dist/task/TaskExecutor.js.map +0 -1
  406. package/dist/task/index.d.ts +0 -10
  407. package/dist/task/index.js +0 -20
  408. package/dist/task/index.js.map +0 -1
  409. package/dist/task/schema.d.ts +0 -53
  410. package/dist/task/schema.js +0 -71
  411. package/dist/task/schema.js.map +0 -1
  412. package/dist/task/types.d.ts +0 -186
  413. package/dist/task/types.js +0 -12
  414. package/dist/task/types.js.map +0 -1
@@ -5,6 +5,7 @@ import { inArray } from './query-conditions.js';
5
5
  import { NotificationsClient } from './notifications/index.js';
6
6
  import { FederatedQueryExecutor } from './federated/index.js';
7
7
  import { parsePodResourceRef } from './resource-reference.js';
8
+ import { Parser } from 'n3';
8
9
  function isRecord(value) {
9
10
  return typeof value === 'object' && value !== null;
10
11
  }
@@ -22,7 +23,6 @@ function isBaseRelativeSubjectId(value) {
22
23
  return false;
23
24
  }
24
25
  return (value.startsWith('#') ||
25
- value.includes('/') ||
26
26
  value.includes('#') ||
27
27
  /\.(ttl|jsonld|json)(?:#|$)/i.test(value));
28
28
  }
@@ -32,6 +32,13 @@ function isTimeLocatorKey(key) {
32
32
  function parseTemplateVariableField(token) {
33
33
  return token.split('|').map((part) => part.trim()).filter(Boolean)[0] ?? token;
34
34
  }
35
+ function escapeSparqlString(value) {
36
+ return value
37
+ .replace(/\\/g, '\\\\')
38
+ .replace(/"/g, '\\"')
39
+ .replace(/\n/g, '\\n')
40
+ .replace(/\r/g, '\\r');
41
+ }
35
42
  function hasTimeLocatorContext(locator) {
36
43
  return locator.createdAt !== undefined
37
44
  || locator.created_at !== undefined
@@ -180,21 +187,24 @@ export class PodDatabase {
180
187
  return rows.length > 0 ? rows[0] : null;
181
188
  }
182
189
  getLocatorTemplate(table) {
183
- return table.getSubjectTemplate?.() ?? table.config?.subjectTemplate ?? '{id}';
190
+ return table.getSubjectTemplate?.() ?? table.config?.subjectTemplate;
184
191
  }
185
192
  getRequiredLocatorKeys(table) {
186
193
  const template = this.getLocatorTemplate(table);
194
+ if (!template) {
195
+ return ['id'];
196
+ }
187
197
  const keys = Array.from(template.matchAll(/\{([^}]+)\}/g))
188
198
  .map((match) => parseTemplateVariableField(match[1]))
189
199
  .filter((key) => key !== 'index');
190
200
  return Array.from(new Set(keys));
191
201
  }
192
- resolveResourceTargetIri(table, target, methodName) {
202
+ resolveResourceTargetIri(resource, target, methodName) {
193
203
  if (typeof target === 'string') {
194
204
  if (isAbsoluteIri(target)) {
195
205
  return target;
196
206
  }
197
- return this.resolveLocatorSubject(table, { id: target }, methodName);
207
+ return this.resolveLocatorSubject(resource, { id: target }, methodName);
198
208
  }
199
209
  if (!isRecord(target) || Array.isArray(target)) {
200
210
  throw new Error(`${methodName} requires a resource IRI, base-relative id, row, or locator object`);
@@ -203,9 +213,9 @@ export class PodDatabase {
203
213
  if (knownIri) {
204
214
  return knownIri;
205
215
  }
206
- return this.resolveLocatorSubject(table, target, methodName);
216
+ return this.resolveLocatorSubject(resource, target, methodName);
207
217
  }
208
- resolveLocatorSubject(table, locator, methodName) {
218
+ resolveLocatorSubject(resource, locator, methodName) {
209
219
  if (!isRecord(locator) || Array.isArray(locator)) {
210
220
  throw new Error(`${methodName} requires a locator object`);
211
221
  }
@@ -216,11 +226,8 @@ export class PodDatabase {
216
226
  if (typeof idValue === 'string' && isAbsoluteIri(idValue)) {
217
227
  throw new Error(`${methodName} does not accept a full IRI in locator.id. Use ${this.getIriAlternative(methodName)} instead.`);
218
228
  }
219
- const resolver = this.dialect.getResolver(table);
220
- if (typeof idValue === 'string' && isBaseRelativeSubjectId(idValue)) {
221
- return resolver.resolveSubject(table, locator);
222
- }
223
- const requiredKeys = this.getRequiredLocatorKeys(table);
229
+ const requiredKeys = this.getRequiredLocatorKeys(resource);
230
+ const resolver = this.dialect.getResolver(resource);
224
231
  const hasTimeContext = hasTimeLocatorContext(locator);
225
232
  const missingKeys = requiredKeys.filter((key) => {
226
233
  if (locator[key] !== undefined && locator[key] !== null) {
@@ -228,112 +235,392 @@ export class PodDatabase {
228
235
  }
229
236
  return !(hasTimeContext && isTimeLocatorKey(key));
230
237
  });
238
+ if (typeof idValue === 'string' && isBaseRelativeSubjectId(idValue)) {
239
+ const nonIdRequiredKeys = requiredKeys.filter((key) => key !== 'id');
240
+ if (idValue.startsWith('#') && nonIdRequiredKeys.length > 0) {
241
+ const template = this.getLocatorTemplate(resource) ?? '<exact-id>';
242
+ throw new Error(`${methodName} requires a complete locator for subjectTemplate '${template}'. ` +
243
+ `Missing [${nonIdRequiredKeys.join(', ')}]. ` +
244
+ `Use a base-relative resource id that includes every storage slot.`);
245
+ }
246
+ return resolver.resolveSubject(resource, locator);
247
+ }
231
248
  if (missingKeys.length > 0) {
232
- const template = this.getLocatorTemplate(table);
249
+ const template = this.getLocatorTemplate(resource) ?? '<exact-id>';
233
250
  throw new Error(`${methodName} requires a complete locator for subjectTemplate '${template}'. ` +
234
251
  `Missing [${missingKeys.join(', ')}]. ` +
235
252
  `Use ${this.getIriAlternative(methodName)} when you already have a full IRI.`);
236
253
  }
237
- return resolver.resolveSubject(table, locator);
254
+ return resolver.resolveSubject(resource, locator);
255
+ }
256
+ resolveIdSubject(resource, id, methodName) {
257
+ if (!id || typeof id !== 'string') {
258
+ throw new Error(`${methodName} requires a valid base-relative resource id string`);
259
+ }
260
+ if (isAbsoluteIri(id)) {
261
+ throw new Error(`${methodName} requires a base-relative resource id. Use ${this.getIriAlternative(methodName)} for full IRIs.`);
262
+ }
263
+ const template = this.getLocatorTemplate(resource) ?? '<exact-id>';
264
+ const missingNonIdKeys = this.getRequiredLocatorKeys(resource).filter((key) => key !== 'id');
265
+ const resolver = this.dialect.getResolver(resource);
266
+ if (isBaseRelativeSubjectId(id)) {
267
+ if (id.startsWith('#') && missingNonIdKeys.length > 0) {
268
+ throw new Error(`${methodName} requires a base-relative resource id for subjectTemplate '${template}', got local fragment id '${id}'. ` +
269
+ `Missing [${missingNonIdKeys.join(', ')}]. ` +
270
+ `Use a base-relative id that includes every storage slot.`);
271
+ }
272
+ return resolver.resolveSubject(resource, { id: id.startsWith('#') ? id.slice(1) : id });
273
+ }
274
+ if (missingNonIdKeys.length > 0) {
275
+ throw new Error(`${methodName} requires a base-relative resource id for subjectTemplate '${template}', got local id '${id}'. ` +
276
+ `Missing [${missingNonIdKeys.join(', ')}]. ` +
277
+ `Use a base-relative id that includes every storage slot.`);
278
+ }
279
+ return resolver.resolveSubject(resource, { id });
280
+ }
281
+ warnFindByLocatorDeprecation() {
282
+ if (PodDatabase.findByLocatorDeprecationWarned) {
283
+ return;
284
+ }
285
+ PodDatabase.findByLocatorDeprecationWarned = true;
286
+ console.warn('[drizzle-solid] findByLocator(resource, locator) is deprecated and will be removed in a future release. ' +
287
+ 'Use findById(resource, id) for base-relative resource ids, findByResource(resource, target) for generic exact targets, ' +
288
+ 'or findByIri(resource, iri) for full IRIs.');
238
289
  }
239
290
  getIriAlternative(methodName) {
240
291
  if (methodName === 'resolveLocatorIri' || methodName === 'resolveLocatorId') {
241
292
  return 'the full IRI directly';
242
293
  }
243
- if (methodName === 'findByResource') {
244
- return 'findByIri(table, iri)';
294
+ if (methodName === 'findById' || methodName === 'findByResource') {
295
+ return 'findByIri(resource, iri)';
245
296
  }
246
- if (methodName === 'updateByResource') {
247
- return 'updateByIri(table, iri, data)';
297
+ if (methodName === 'updateById' || methodName === 'updateByResource') {
298
+ return 'updateByIri(resource, iri, data)';
248
299
  }
249
- if (methodName === 'deleteByResource') {
250
- return 'deleteByIri(table, iri)';
300
+ if (methodName === 'deleteById' || methodName === 'deleteByResource') {
301
+ return 'deleteByIri(resource, iri)';
251
302
  }
252
- return `${methodName.replace('Locator', 'Iri')}(table, iri)`;
303
+ return `${methodName.replace('Locator', 'Iri')}(resource, iri)`;
253
304
  }
254
- resolveLocatorIri(table, locator) {
255
- return this.resolveLocatorSubject(table, locator, 'resolveLocatorIri');
305
+ resolveLocatorIri(resource, locator) {
306
+ return this.resolveLocatorSubject(resource, locator, 'resolveLocatorIri');
256
307
  }
257
- resolveLocatorId(table, locator) {
258
- const iri = this.resolveLocatorSubject(table, locator, 'resolveLocatorId');
259
- return this.dialect.getResolver(table).parseId(table, iri);
308
+ resolveLocatorId(resource, locator) {
309
+ const iri = this.resolveLocatorSubject(resource, locator, 'resolveLocatorId');
310
+ return this.resolveBaseRelativeResourceId(resource, iri);
260
311
  }
261
- resolveResourceIri(table, target) {
262
- return this.resolveResourceTargetIri(table, target, 'resolveResourceIri');
312
+ resolveResourceIri(resource, target) {
313
+ return this.resolveResourceTargetIri(resource, target, 'resolveResourceIri');
263
314
  }
264
- resolveResourceId(table, target) {
265
- const iri = this.resolveResourceTargetIri(table, target, 'resolveResourceId');
266
- return parsePodResourceRef(table, iri)?.resourceId ?? this.dialect.getResolver(table).parseId(table, iri);
315
+ resolveResourceId(resource, target) {
316
+ const iri = this.resolveResourceTargetIri(resource, target, 'resolveResourceId');
317
+ return this.resolveBaseRelativeResourceId(resource, iri);
267
318
  }
268
- resolveRelationIri(table, target) {
269
- return this.resolveResourceTargetIri(table, target, 'resolveRelationIri');
319
+ resolveRelationIri(resource, target) {
320
+ return this.resolveResourceTargetIri(resource, target, 'resolveRelationIri');
270
321
  }
271
- resolveRowIri(table, row) {
322
+ resolveRowIri(resource, row) {
272
323
  if (!isRecord(row) || Array.isArray(row)) {
273
324
  throw new Error('resolveRowIri requires a row object');
274
325
  }
275
- return getKnownRowIri(row) ?? this.resolveLocatorSubject(table, row, 'resolveRowIri');
326
+ return getKnownRowIri(row) ?? this.resolveLocatorSubject(resource, row, 'resolveRowIri');
276
327
  }
277
- resolveRowId(table, row) {
328
+ resolveRowId(resource, row) {
278
329
  if (!isRecord(row) || Array.isArray(row)) {
279
330
  throw new Error('resolveRowId requires a row object');
280
331
  }
281
- const iri = getKnownRowIri(row) ?? this.resolveLocatorSubject(table, row, 'resolveRowId');
282
- return this.dialect.getResolver(table).parseId(table, iri);
332
+ const iri = getKnownRowIri(row) ?? this.resolveLocatorSubject(resource, row, 'resolveRowId');
333
+ return this.resolveBaseRelativeResourceId(resource, iri);
334
+ }
335
+ resolveBaseRelativeResourceId(resource, iri) {
336
+ return parsePodResourceRef(resource, iri)?.resourceId ?? this.dialect.getResolver(resource).parseId(resource, iri);
283
337
  }
284
- async findByLocator(table, locator) {
285
- const iri = this.resolveLocatorSubject(table, locator, 'findByLocator');
286
- return await this.findByIri(table, iri);
338
+ needsShortIdSubjectLookup(resource, id) {
339
+ if (!id || typeof id !== 'string' || isAbsoluteIri(id) || isBaseRelativeSubjectId(id)) {
340
+ return false;
341
+ }
342
+ return this.getRequiredLocatorKeys(resource).some((key) => key !== 'id');
287
343
  }
288
- async findByResource(table, target) {
289
- const iri = this.resolveResourceTargetIri(table, target, 'findByResource');
290
- return await this.findByIri(table, iri);
344
+ buildShortIdSubjectSuffix(resource, id) {
345
+ const template = this.getLocatorTemplate(resource) ?? '<exact-id>';
346
+ const matches = Array.from(template.matchAll(/\{([^}]+)\}/g));
347
+ let idMatchIndex = -1;
348
+ for (let index = matches.length - 1; index >= 0; index--) {
349
+ if (parseTemplateVariableField(matches[index][1]) === 'id') {
350
+ idMatchIndex = index;
351
+ break;
352
+ }
353
+ }
354
+ if (idMatchIndex < 0) {
355
+ return id;
356
+ }
357
+ const idMatch = matches[idMatchIndex];
358
+ const previousMatch = matches[idMatchIndex - 1];
359
+ const previousEnd = previousMatch?.index === undefined
360
+ ? 0
361
+ : previousMatch.index + previousMatch[0].length;
362
+ const idStart = idMatch.index ?? 0;
363
+ const idEnd = idStart + idMatch[0].length;
364
+ return `${template.slice(previousEnd, idStart)}${id}${template.slice(idEnd)}`;
365
+ }
366
+ resolveShortIdLookupSource(resource) {
367
+ const dialectWithResolver = this.dialect;
368
+ if (typeof dialectWithResolver.resolveTableResource === 'function') {
369
+ const descriptor = dialectWithResolver.resolveTableResource(resource);
370
+ if (descriptor.mode === 'sparql' && descriptor.endpoint) {
371
+ return { kind: 'sparql', resourceUrl: descriptor.endpoint, descriptor };
372
+ }
373
+ }
374
+ return null;
291
375
  }
292
- async findByIri(table, iri) {
376
+ extractSubjectFromLookupRow(row) {
377
+ if (!isRecord(row)) {
378
+ return null;
379
+ }
380
+ const value = row.subject ?? row.s ?? row['?subject'] ?? row['?s'];
381
+ if (typeof value === 'string') {
382
+ return value;
383
+ }
384
+ if (hasStringValue(value)) {
385
+ return value.value;
386
+ }
387
+ return null;
388
+ }
389
+ subjectMatchesShortId(resource, subject, id, suffix) {
390
+ const ref = parsePodResourceRef(resource, subject);
391
+ if (ref) {
392
+ return ref.templateValues.id === id;
393
+ }
394
+ return subject.endsWith(suffix);
395
+ }
396
+ getIndexedSubject(resource, id) {
397
+ const dialect = this.dialect;
398
+ if (typeof dialect.lookupIndexedResourceSubject !== 'function') {
399
+ return null;
400
+ }
401
+ return dialect.lookupIndexedResourceSubject(resource, id);
402
+ }
403
+ async lookupSubjectIriByShortId(resource, id, methodName) {
404
+ const source = this.resolveShortIdLookupSource(resource);
405
+ if (!source) {
406
+ const template = this.getLocatorTemplate(resource) ?? '<exact-id>';
407
+ throw new Error(`${methodName} cannot resolve short id '${id}' for subjectTemplate '${template}' ` +
408
+ `because no resource query source is available.`);
409
+ }
410
+ const suffix = this.buildShortIdSubjectSuffix(resource, id);
411
+ const containsNeedle = id;
412
+ const matchClause = resource.config?.type
413
+ ? `?subject ?typePredicate ?typeObject .
414
+ FILTER(?typePredicate = <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> && ?typeObject = <${resource.config.type}> && CONTAINS(STR(?subject), "${escapeSparqlString(containsNeedle)}"))`
415
+ : `?subject ?predicate ?object .
416
+ FILTER(CONTAINS(STR(?subject), "${escapeSparqlString(containsNeedle)}"))`;
417
+ const query = {
418
+ type: 'SELECT',
419
+ query: `SELECT DISTINCT ?subject WHERE {
420
+ ${matchClause}
421
+ }
422
+ LIMIT 50`,
423
+ prefixes: {},
424
+ };
425
+ const rows = source.kind === 'sparql'
426
+ ? await this.dialect.executeOnResource(source.resourceUrl, query, source.descriptor)
427
+ : await this.dialect.getSPARQLExecutor().queryContainer(source.resourceUrl, query);
428
+ const subjects = Array.from(new Set(rows
429
+ .map((row) => this.extractSubjectFromLookupRow(row))
430
+ .filter((value) => Boolean(value))
431
+ .filter((value) => this.subjectMatchesShortId(resource, value, id, suffix))));
432
+ if (subjects.length > 1) {
433
+ throw new Error(`${methodName} found multiple resources for short id '${id}' in '${resource.config?.name ?? 'resource'}'. ` +
434
+ `Use a base-relative resource id or full IRI to disambiguate.`);
435
+ }
436
+ return subjects[0] ?? this.getIndexedSubject(resource, id);
437
+ }
438
+ async resolveIdSubjectForExactOperation(resource, id, methodName) {
439
+ if (this.needsShortIdSubjectLookup(resource, id)) {
440
+ return await this.lookupSubjectIriByShortId(resource, id, methodName);
441
+ }
442
+ return this.resolveIdSubject(resource, id, methodName);
443
+ }
444
+ async findById(resource, id) {
445
+ const iri = await this.resolveIdSubjectForExactOperation(resource, id, 'findById');
446
+ if (!iri) {
447
+ return null;
448
+ }
449
+ return await this.findByIri(resource, iri);
450
+ }
451
+ async findByLocator(resource, locator) {
452
+ this.warnFindByLocatorDeprecation();
453
+ const iri = this.resolveLocatorSubject(resource, locator, 'findByLocator');
454
+ return await this.findByIri(resource, iri);
455
+ }
456
+ async findByResource(resource, target) {
457
+ if (typeof target === 'string' && this.needsShortIdSubjectLookup(resource, target)) {
458
+ return await this.findById(resource, target);
459
+ }
460
+ const iri = this.resolveResourceTargetIri(resource, target, 'findByResource');
461
+ return await this.findByIri(resource, iri);
462
+ }
463
+ async findByIri(resource, iri) {
293
464
  if (!iri || typeof iri !== 'string') {
294
465
  throw new Error('findByIri requires a valid IRI string');
295
466
  }
296
- const exactRead = await this.findByIriViaExactSparql(table, iri);
467
+ const exactRead = await this.findByIriViaExactResource(resource, iri);
297
468
  if (exactRead !== undefined) {
298
469
  return exactRead;
299
470
  }
300
- // 保持原始表上下文,让 subjectTemplate/base 反解保持一致。
301
- // whereByIri() 已经会把 SELECT 精确定位到目标资源,不需要把表重绑到具体文档。
471
+ // Keep the original resource context so subjectTemplate/base decoding stays stable.
472
+ // whereByIri() already pins SELECT to the concrete resource IRI.
302
473
  const rows = await this.session
303
474
  .select()
304
- .from(table)
475
+ .from(resource)
305
476
  .whereByIri(iri)
306
477
  .limit(1);
307
478
  return rows[0] ?? null;
308
479
  }
309
- getColumnPredicate(table, column) {
310
- return column.options?.predicate ?? column.getPredicate?.(table.config.namespace);
480
+ getColumnPredicate(resource, column) {
481
+ return column.options?.predicate ?? column.getPredicate?.(resource.config.namespace);
311
482
  }
312
- async findByIriViaExactSparql(table, iri) {
313
- if (!isPodTable(table)) {
483
+ async findByIriViaExactResource(resource, iri) {
484
+ if (!isPodTable(resource)) {
314
485
  return undefined;
315
486
  }
316
- if (typeof this.dialect.resolveTableResource !== 'function'
317
- || typeof this.dialect.executeOnResource !== 'function') {
487
+ const documentUrl = this.parseIri(iri).documentUrl;
488
+ const directRows = await this.readPredicateObjectRowsFromDocument(documentUrl, iri);
489
+ if (directRows === null) {
490
+ return null;
491
+ }
492
+ if (directRows !== undefined) {
493
+ const mapped = this.mapPredicateObjectRows(resource, iri, directRows);
494
+ if (mapped !== undefined) {
495
+ return mapped;
496
+ }
497
+ }
498
+ if (typeof this.dialect.executeOnResource !== 'function') {
318
499
  return undefined;
319
500
  }
320
- const documentUrl = this.parseIri(iri).documentUrl;
321
- const descriptor = this.dialect.resolveTableResource(table);
322
501
  const query = {
323
502
  type: 'SELECT',
324
503
  query: `SELECT ?p ?o WHERE { <${iri}> ?p ?o . }`,
325
504
  prefixes: {}
326
505
  };
327
- const rows = descriptor.mode === 'sparql'
328
- ? await this.dialect.executeOnResource(documentUrl, query, descriptor)
329
- : await this.dialect.executeOnResource(documentUrl, query);
330
- const mapped = this.mapPredicateObjectRows(table, iri, rows);
331
- if (mapped) {
506
+ // Exact-target reads already know the concrete Pod document. Do not route
507
+ // through a collection sidecar SPARQL endpoint such as /.data/chat/-/sparql.
508
+ let rows;
509
+ try {
510
+ rows = await this.dialect.executeOnResource(documentUrl, query);
511
+ }
512
+ catch (error) {
513
+ if (this.isMissingExactResourceError(error)) {
514
+ return undefined;
515
+ }
516
+ throw error;
517
+ }
518
+ const mapped = this.mapPredicateObjectRows(resource, iri, rows);
519
+ if (mapped !== undefined) {
332
520
  return mapped;
333
521
  }
334
- return null;
522
+ return undefined;
523
+ }
524
+ async readPredicateObjectRowsFromDocument(documentUrl, iri) {
525
+ const getAuthenticatedFetch = this.dialect.getAuthenticatedFetch;
526
+ if (typeof getAuthenticatedFetch !== 'function') {
527
+ return undefined;
528
+ }
529
+ let response;
530
+ try {
531
+ response = await getAuthenticatedFetch.call(this.dialect)(documentUrl, {
532
+ method: 'GET',
533
+ headers: {
534
+ Accept: 'text/turtle, application/ld+json;q=0.8, */*;q=0.1',
535
+ },
536
+ });
537
+ }
538
+ catch (error) {
539
+ if (this.isMissingExactResourceError(error)) {
540
+ return null;
541
+ }
542
+ return undefined;
543
+ }
544
+ if (response.status === 404) {
545
+ return null;
546
+ }
547
+ if (!response.ok) {
548
+ return undefined;
549
+ }
550
+ const contentType = response.headers.get('content-type') ?? '';
551
+ if (contentType
552
+ && !contentType.includes('text/turtle')
553
+ && !contentType.includes('application/n-triples')
554
+ && !contentType.includes('application/trig')
555
+ && !contentType.includes('application/ld+json')) {
556
+ return undefined;
557
+ }
558
+ const body = await response.text();
559
+ if (!body.trim()) {
560
+ return null;
561
+ }
562
+ try {
563
+ const parser = new Parser({
564
+ baseIRI: documentUrl,
565
+ format: contentType.includes('application/n-triples') ? 'N-Triples' : 'text/turtle',
566
+ });
567
+ const quads = parser.parse(body);
568
+ return quads
569
+ .filter((quad) => quad.subject.termType === 'NamedNode' && quad.subject.value === iri)
570
+ .map((quad) => ({
571
+ p: quad.predicate.value,
572
+ o: this.convertRdfTermToValue(quad.object),
573
+ }));
574
+ }
575
+ catch {
576
+ return undefined;
577
+ }
578
+ }
579
+ convertRdfTermToValue(term) {
580
+ if (term.termType === 'NamedNode') {
581
+ return term.value;
582
+ }
583
+ if (term.termType === 'BlankNode') {
584
+ return `_:${term.value}`;
585
+ }
586
+ if (term.termType !== 'Literal') {
587
+ return term.value;
588
+ }
589
+ const datatypeIri = term.datatype?.value ?? '';
590
+ if (datatypeIri.includes('#integer') || datatypeIri.includes('#int')) {
591
+ return parseInt(term.value, 10);
592
+ }
593
+ if (datatypeIri.includes('#decimal') || datatypeIri.includes('#double')) {
594
+ return parseFloat(term.value);
595
+ }
596
+ if (datatypeIri.includes('#boolean')) {
597
+ return term.value === 'true';
598
+ }
599
+ if (datatypeIri.includes('#dateTime')) {
600
+ return new Date(term.value);
601
+ }
602
+ if (datatypeIri.includes('#json')) {
603
+ try {
604
+ return JSON.parse(term.value);
605
+ }
606
+ catch {
607
+ return term.value;
608
+ }
609
+ }
610
+ return term.value;
611
+ }
612
+ isMissingExactResourceError(error) {
613
+ if (!isRecord(error)) {
614
+ return false;
615
+ }
616
+ const status = error.status ?? error.statusCode;
617
+ if (status === 404) {
618
+ return true;
619
+ }
620
+ const message = error.message;
621
+ return typeof message === 'string' && /\b(?:HTTP status )?404\b/.test(message);
335
622
  }
336
- mapPredicateObjectRows(table, iri, rows) {
623
+ mapPredicateObjectRows(resource, iri, rows) {
337
624
  if (!Array.isArray(rows) || rows.length === 0) {
338
625
  return null;
339
626
  }
@@ -342,12 +629,13 @@ export class PodDatabase {
342
629
  '@id': iri,
343
630
  uri: iri,
344
631
  };
345
- const derivedId = this.extractIdFromIri(table, iri);
632
+ const derivedId = this.extractIdFromIri(resource, iri);
346
633
  if (derivedId !== undefined) {
347
634
  row.id = derivedId;
348
635
  }
349
636
  let hasType = false;
350
637
  let hasAnyMappedPredicate = false;
638
+ let hasUnhydratedInlineObject = false;
351
639
  for (const result of rows) {
352
640
  if (!isRecord(result)) {
353
641
  continue;
@@ -358,14 +646,14 @@ export class PodDatabase {
358
646
  continue;
359
647
  }
360
648
  if (predicate === 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
361
- && object === table.config.type) {
649
+ && object === resource.config.type) {
362
650
  hasType = true;
363
651
  }
364
- for (const [key, column] of Object.entries(table.columns ?? {})) {
652
+ for (const [key, column] of Object.entries(resource.columns ?? {})) {
365
653
  if (column._virtualId) {
366
654
  continue;
367
655
  }
368
- const columnPredicate = this.getColumnPredicate(table, column);
656
+ const columnPredicate = this.getColumnPredicate(resource, column);
369
657
  if (!columnPredicate || columnPredicate === '@id' || columnPredicate !== predicate) {
370
658
  continue;
371
659
  }
@@ -377,25 +665,37 @@ export class PodDatabase {
377
665
  else if (row[key] === undefined) {
378
666
  row[key] = object;
379
667
  }
668
+ if ((column.dataType === 'object' || column.dataType === 'json')
669
+ && typeof object === 'string'
670
+ && isAbsoluteIri(object)) {
671
+ hasUnhydratedInlineObject = true;
672
+ }
380
673
  hasAnyMappedPredicate = true;
381
674
  }
382
675
  }
383
676
  if (!hasType && !hasAnyMappedPredicate) {
384
677
  return null;
385
678
  }
679
+ if (hasUnhydratedInlineObject) {
680
+ return undefined;
681
+ }
386
682
  return row;
387
683
  }
388
- extractIdFromIri(table, iri) {
684
+ extractIdFromIri(resource, iri) {
685
+ const resourceId = parsePodResourceRef(resource, iri)?.resourceId;
686
+ if (resourceId) {
687
+ return resourceId;
688
+ }
389
689
  try {
390
- const parsedId = this.dialect.getResolver(table).parseId(table, iri);
690
+ const parsedId = this.dialect.getResolver(resource).parseId(resource, iri);
391
691
  if (parsedId) {
392
692
  return parsedId;
393
693
  }
394
694
  }
395
695
  catch {
396
- // Fall through to conservative legacy parsing for non-standard tables.
696
+ // Fall through to conservative legacy parsing for non-standard resources.
397
697
  }
398
- const template = table.getSubjectTemplate?.() ?? table.config?.subjectTemplate;
698
+ const template = resource.getSubjectTemplate?.() ?? resource.config?.subjectTemplate;
399
699
  if (!template) {
400
700
  return undefined;
401
701
  }
@@ -431,7 +731,7 @@ export class PodDatabase {
431
731
  /**
432
732
  * 通过完整 IRI 订阅单个实体的变更
433
733
  *
434
- * @param table - 表定义
734
+ * @param resource - Resource definition used to decode schema and subject shape.
435
735
  * @param iri - 完整 IRI,本地或远程
436
736
  * @param options - 订阅选项
437
737
  * @returns 取消订阅函数
@@ -458,7 +758,7 @@ export class PodDatabase {
458
758
  * unsubscribe()
459
759
  * ```
460
760
  */
461
- async subscribeByIri(table, iri, options) {
761
+ async subscribeByIri(resource, iri, options) {
462
762
  if (!iri || typeof iri !== 'string') {
463
763
  throw new Error('subscribeByIri requires a valid IRI string');
464
764
  }
@@ -483,7 +783,7 @@ export class PodDatabase {
483
783
  try {
484
784
  if (event.type === 'Update') {
485
785
  // 重新获取数据
486
- const data = await this.findByIri(table, iri);
786
+ const data = await this.findByIri(resource, iri);
487
787
  if (data) {
488
788
  await options.onUpdate(data);
489
789
  }
@@ -501,7 +801,7 @@ export class PodDatabase {
501
801
  // 返回取消订阅函数
502
802
  return () => subscription.unsubscribe();
503
803
  }
504
- async updateByIri(table, iri, data) {
804
+ async updateByIri(resource, iri, data) {
505
805
  if (!iri || typeof iri !== 'string') {
506
806
  throw new Error('updateByIri requires a valid IRI string');
507
807
  }
@@ -511,24 +811,34 @@ export class PodDatabase {
511
811
  const updateData = data;
512
812
  // 使用 whereByIri 内部方法进行更新
513
813
  await this.session
514
- .update(table)
814
+ .update(resource)
515
815
  .set(updateData)
516
816
  .whereByIri(iri);
517
817
  // 返回更新后的数据
518
- return await this.findByIri(table, iri);
818
+ return await this.findByIri(resource, iri);
819
+ }
820
+ async updateById(resource, id, data) {
821
+ const iri = await this.resolveIdSubjectForExactOperation(resource, id, 'updateById');
822
+ if (!iri) {
823
+ return null;
824
+ }
825
+ return await this.updateByIri(resource, iri, data);
519
826
  }
520
- async updateByLocator(table, locator, data) {
521
- const iri = this.resolveLocatorSubject(table, locator, 'updateByLocator');
522
- return await this.updateByIri(table, iri, data);
827
+ async updateByLocator(resource, locator, data) {
828
+ const iri = this.resolveLocatorSubject(resource, locator, 'updateByLocator');
829
+ return await this.updateByIri(resource, iri, data);
523
830
  }
524
- async updateByResource(table, target, data) {
525
- const iri = this.resolveResourceTargetIri(table, target, 'updateByResource');
526
- return await this.updateByIri(table, iri, data);
831
+ async updateByResource(resource, target, data) {
832
+ if (typeof target === 'string' && this.needsShortIdSubjectLookup(resource, target)) {
833
+ return await this.updateById(resource, target, data);
834
+ }
835
+ const iri = this.resolveResourceTargetIri(resource, target, 'updateByResource');
836
+ return await this.updateByIri(resource, iri, data);
527
837
  }
528
838
  /**
529
839
  * 通过完整 IRI 删除单个实体
530
840
  *
531
- * @param table - 表定义
841
+ * @param resource - Resource definition used to decode schema and subject shape.
532
842
  * @param iri - 完整 IRI
533
843
  * @returns 是否删除成功
534
844
  *
@@ -540,7 +850,7 @@ export class PodDatabase {
540
850
  * )
541
851
  * ```
542
852
  */
543
- async deleteByIri(table, iri) {
853
+ async deleteByIri(resource, iri) {
544
854
  if (!iri || typeof iri !== 'string') {
545
855
  throw new Error('deleteByIri requires a valid IRI string');
546
856
  }
@@ -548,23 +858,37 @@ export class PodDatabase {
548
858
  throw new Error(`deleteByIri requires an absolute IRI, got: ${iri}`);
549
859
  }
550
860
  // 先检查实体是否存在
551
- const existing = await this.findByIri(table, iri);
861
+ const existing = await this.findByIri(resource, iri);
552
862
  if (!existing) {
553
863
  return false;
554
864
  }
555
865
  // 使用 whereByIri 内部方法进行删除
556
866
  await this.session
557
- .delete(table)
867
+ .delete(resource)
558
868
  .whereByIri(iri);
559
869
  return true;
560
870
  }
561
- async deleteByLocator(table, locator) {
562
- const iri = this.resolveLocatorSubject(table, locator, 'deleteByLocator');
563
- return await this.deleteByIri(table, iri);
871
+ async deleteById(resource, id) {
872
+ const iri = await this.resolveIdSubjectForExactOperation(resource, id, 'deleteById');
873
+ if (!iri) {
874
+ return false;
875
+ }
876
+ return await this.deleteByIri(resource, iri);
564
877
  }
565
- async deleteByResource(table, target) {
566
- const iri = this.resolveResourceTargetIri(table, target, 'deleteByResource');
567
- return await this.deleteByIri(table, iri);
878
+ /**
879
+ * @deprecated Use deleteById(resource, id), deleteByResource(resource, target), or deleteByIri(resource, iri).
880
+ * This locator-shaped exact delete will be removed in a future release.
881
+ */
882
+ async deleteByLocator(resource, locator) {
883
+ const iri = this.resolveLocatorSubject(resource, locator, 'deleteByLocator');
884
+ return await this.deleteByIri(resource, iri);
885
+ }
886
+ async deleteByResource(resource, target) {
887
+ if (typeof target === 'string' && this.needsShortIdSubjectLookup(resource, target)) {
888
+ return await this.deleteById(resource, target);
889
+ }
890
+ const iri = this.resolveResourceTargetIri(resource, target, 'deleteByResource');
891
+ return await this.deleteByIri(resource, iri);
568
892
  }
569
893
  // 事务支持
570
894
  async transaction(transaction) {
@@ -604,9 +928,9 @@ export class PodDatabase {
604
928
  return await this.dialect.disconnect();
605
929
  }
606
930
  /**
607
- * 订阅表/资源的变化通知
931
+ * 订阅资源的变化通知
608
932
  *
609
- * @param table - 要订阅的表(会订阅其容器或资源)
933
+ * @param resource - 要订阅的 resource(会订阅其容器或文档)
610
934
  * @param options - 订阅选项,支持按类型分开的回调
611
935
  * @returns 订阅句柄,可用于取消订阅
612
936
  *
@@ -633,7 +957,7 @@ export class PodDatabase {
633
957
  * subscription.unsubscribe();
634
958
  * ```
635
959
  */
636
- async subscribe(table, options) {
960
+ async subscribe(resource, options) {
637
961
  // 懒初始化 NotificationsClient
638
962
  if (!this.notificationsClient) {
639
963
  const authenticatedFetch = this.dialect.getAuthenticatedFetch();
@@ -642,8 +966,8 @@ export class PodDatabase {
642
966
  };
643
967
  this.notificationsClient = new NotificationsClient(authenticatedFetch, config);
644
968
  }
645
- // 获取表的资源 URL(容器或文件),支持 iri 覆盖
646
- const topic = this.resolveTableTopic(table, options.iri);
969
+ // 获取 resource URL(容器或文件),支持 iri 覆盖
970
+ const topic = this.resolveResourceTopic(resource, options.iri);
647
971
  // 将 TableSubscribeOptions 转换为底层 SubscribeOptions
648
972
  const subscribeOptions = {
649
973
  channel: options.channel,
@@ -686,11 +1010,11 @@ export class PodDatabase {
686
1010
  return this.notificationsClient.subscribe(topic, subscribeOptions);
687
1011
  }
688
1012
  /**
689
- * 解析表对应的订阅主题 URL
690
- * @param table 表定义
1013
+ * 解析 resource 对应的订阅主题 URL
1014
+ * @param resource Resource definition
691
1015
  * @param iriOverride 可选的 IRI 覆盖(用于订阅其他 Pod 的资源)
692
1016
  */
693
- resolveTableTopic(table, iriOverride) {
1017
+ resolveResourceTopic(resource, iriOverride) {
694
1018
  // 如果提供了 iri 覆盖,直接使用
695
1019
  if (iriOverride) {
696
1020
  if (!iriOverride.startsWith('http://') && !iriOverride.startsWith('https://')) {
@@ -698,7 +1022,7 @@ export class PodDatabase {
698
1022
  }
699
1023
  return iriOverride;
700
1024
  }
701
- const base = table.config.base || '';
1025
+ const base = resource.config.base || '';
702
1026
  // 如果 base 已经是绝对 URL,直接使用
703
1027
  if (base.startsWith('http://') || base.startsWith('https://')) {
704
1028
  return base;
@@ -1063,13 +1387,13 @@ export class PodDatabase {
1063
1387
  const schemaEntries = (this.schema && typeof this.schema === 'object')
1064
1388
  ? Object.entries(this.schema)
1065
1389
  : [];
1066
- const tableMap = new Map();
1390
+ const resourceMap = new Map();
1067
1391
  for (const [key, value] of schemaEntries) {
1068
1392
  if (isPodTable(value)) {
1069
- tableMap.set(key, value);
1393
+ resourceMap.set(key, value);
1070
1394
  }
1071
1395
  }
1072
- const createHelper = (_tableName, table) => {
1396
+ const createHelper = (_resourceName, resource) => {
1073
1397
  const createLazy = (executor) => {
1074
1398
  let promise = null;
1075
1399
  const run = () => {
@@ -1112,7 +1436,7 @@ export class PodDatabase {
1112
1436
  };
1113
1437
  const executeFindMany = async (options) => {
1114
1438
  this.clearFederatedErrors();
1115
- let builder = this.session.select().from(table);
1439
+ let builder = this.session.select().from(resource);
1116
1440
  if (options?.where) {
1117
1441
  builder = builder.where(options.where);
1118
1442
  }
@@ -1130,7 +1454,7 @@ export class PodDatabase {
1130
1454
  }
1131
1455
  let rows = await builder;
1132
1456
  if (options?.with && Object.keys(options.with).length > 0) {
1133
- rows = await this.eagerLoadWith(rows, table, options.with, tableMap);
1457
+ rows = await this.eagerLoadWith(rows, resource, options.with, resourceMap);
1134
1458
  }
1135
1459
  const columns = options?.columns;
1136
1460
  if (columns) {
@@ -1145,7 +1469,7 @@ export class PodDatabase {
1145
1469
  }
1146
1470
  let rows = [row];
1147
1471
  if (options?.with && Object.keys(options.with).length > 0) {
1148
- rows = await this.eagerLoadWith(rows, table, options.with, tableMap);
1472
+ rows = await this.eagerLoadWith(rows, resource, options.with, resourceMap);
1149
1473
  }
1150
1474
  const columns = options?.columns;
1151
1475
  if (columns) {
@@ -1161,12 +1485,16 @@ export class PodDatabase {
1161
1485
  const rows = await executeFindMany({ where: options?.where, columns: undefined, limit: undefined, offset: undefined });
1162
1486
  return rows.length;
1163
1487
  });
1164
- const createFindByLocator = () => (locator, options) => createLazy(async () => await applyExactOptions(await this.findByLocator(table, locator), options));
1165
- const createFindByIri = () => (iri, options) => createLazy(async () => await applyExactOptions(await this.findByIri(table, iri), options));
1166
- const createFindByResource = () => (target, options) => createLazy(async () => await applyExactOptions(await this.findByResource(table, target), options));
1488
+ const createFindByLocator = () => (locator, options) => createLazy(async () => await applyExactOptions(await this.findByLocator(resource, locator), options));
1489
+ const createFindById = () => (id, options) => createLazy(async () => await applyExactOptions(await this.findById(resource, id), options));
1490
+ const createFindByIri = () => (iri, options) => createLazy(async () => await applyExactOptions(await this.findByIri(resource, iri), options));
1491
+ const createFindByResource = () => (target, options) => createLazy(async () => await applyExactOptions(await this.findByResource(resource, target), options));
1492
+ const find = (target, options) => createFindByResource()(target, options);
1167
1493
  return {
1168
1494
  findMany,
1169
1495
  findFirst,
1496
+ find,
1497
+ findById: createFindById(),
1170
1498
  findByLocator: createFindByLocator(),
1171
1499
  findByIri: createFindByIri(),
1172
1500
  findByResource: createFindByResource(),
@@ -1179,9 +1507,9 @@ export class PodDatabase {
1179
1507
  if (typeof prop !== 'string') {
1180
1508
  return undefined;
1181
1509
  }
1182
- const table = tableMap.get(prop);
1183
- if (table) {
1184
- return createHelper(prop, table);
1510
+ const resource = resourceMap.get(prop);
1511
+ if (resource) {
1512
+ return createHelper(prop, resource);
1185
1513
  }
1186
1514
  return undefined;
1187
1515
  }
@@ -1496,4 +1824,5 @@ export class PodDatabase {
1496
1824
  }
1497
1825
  _a = entityKind;
1498
1826
  PodDatabase[_a] = 'PodDatabase';
1827
+ PodDatabase.findByLocatorDeprecationWarned = false;
1499
1828
  //# sourceMappingURL=pod-database.js.map