@undefineds.co/xpod 0.2.45 → 0.3.0

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 +5 -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
@@ -41,6 +41,7 @@ const query_conditions_1 = require("./query-conditions");
41
41
  const notifications_1 = require("./notifications");
42
42
  const federated_1 = require("./federated");
43
43
  const resource_reference_1 = require("./resource-reference");
44
+ const n3_1 = require("n3");
44
45
  function isRecord(value) {
45
46
  return typeof value === 'object' && value !== null;
46
47
  }
@@ -58,7 +59,6 @@ function isBaseRelativeSubjectId(value) {
58
59
  return false;
59
60
  }
60
61
  return (value.startsWith('#') ||
61
- value.includes('/') ||
62
62
  value.includes('#') ||
63
63
  /\.(ttl|jsonld|json)(?:#|$)/i.test(value));
64
64
  }
@@ -68,6 +68,13 @@ function isTimeLocatorKey(key) {
68
68
  function parseTemplateVariableField(token) {
69
69
  return token.split('|').map((part) => part.trim()).filter(Boolean)[0] ?? token;
70
70
  }
71
+ function escapeSparqlString(value) {
72
+ return value
73
+ .replace(/\\/g, '\\\\')
74
+ .replace(/"/g, '\\"')
75
+ .replace(/\n/g, '\\n')
76
+ .replace(/\r/g, '\\r');
77
+ }
71
78
  function hasTimeLocatorContext(locator) {
72
79
  return locator.createdAt !== undefined
73
80
  || locator.created_at !== undefined
@@ -216,21 +223,24 @@ class PodDatabase {
216
223
  return rows.length > 0 ? rows[0] : null;
217
224
  }
218
225
  getLocatorTemplate(table) {
219
- return table.getSubjectTemplate?.() ?? table.config?.subjectTemplate ?? '{id}';
226
+ return table.getSubjectTemplate?.() ?? table.config?.subjectTemplate;
220
227
  }
221
228
  getRequiredLocatorKeys(table) {
222
229
  const template = this.getLocatorTemplate(table);
230
+ if (!template) {
231
+ return ['id'];
232
+ }
223
233
  const keys = Array.from(template.matchAll(/\{([^}]+)\}/g))
224
234
  .map((match) => parseTemplateVariableField(match[1]))
225
235
  .filter((key) => key !== 'index');
226
236
  return Array.from(new Set(keys));
227
237
  }
228
- resolveResourceTargetIri(table, target, methodName) {
238
+ resolveResourceTargetIri(resource, target, methodName) {
229
239
  if (typeof target === 'string') {
230
240
  if (isAbsoluteIri(target)) {
231
241
  return target;
232
242
  }
233
- return this.resolveLocatorSubject(table, { id: target }, methodName);
243
+ return this.resolveLocatorSubject(resource, { id: target }, methodName);
234
244
  }
235
245
  if (!isRecord(target) || Array.isArray(target)) {
236
246
  throw new Error(`${methodName} requires a resource IRI, base-relative id, row, or locator object`);
@@ -239,9 +249,9 @@ class PodDatabase {
239
249
  if (knownIri) {
240
250
  return knownIri;
241
251
  }
242
- return this.resolveLocatorSubject(table, target, methodName);
252
+ return this.resolveLocatorSubject(resource, target, methodName);
243
253
  }
244
- resolveLocatorSubject(table, locator, methodName) {
254
+ resolveLocatorSubject(resource, locator, methodName) {
245
255
  if (!isRecord(locator) || Array.isArray(locator)) {
246
256
  throw new Error(`${methodName} requires a locator object`);
247
257
  }
@@ -252,11 +262,8 @@ class PodDatabase {
252
262
  if (typeof idValue === 'string' && isAbsoluteIri(idValue)) {
253
263
  throw new Error(`${methodName} does not accept a full IRI in locator.id. Use ${this.getIriAlternative(methodName)} instead.`);
254
264
  }
255
- const resolver = this.dialect.getResolver(table);
256
- if (typeof idValue === 'string' && isBaseRelativeSubjectId(idValue)) {
257
- return resolver.resolveSubject(table, locator);
258
- }
259
- const requiredKeys = this.getRequiredLocatorKeys(table);
265
+ const requiredKeys = this.getRequiredLocatorKeys(resource);
266
+ const resolver = this.dialect.getResolver(resource);
260
267
  const hasTimeContext = hasTimeLocatorContext(locator);
261
268
  const missingKeys = requiredKeys.filter((key) => {
262
269
  if (locator[key] !== undefined && locator[key] !== null) {
@@ -264,112 +271,392 @@ class PodDatabase {
264
271
  }
265
272
  return !(hasTimeContext && isTimeLocatorKey(key));
266
273
  });
274
+ if (typeof idValue === 'string' && isBaseRelativeSubjectId(idValue)) {
275
+ const nonIdRequiredKeys = requiredKeys.filter((key) => key !== 'id');
276
+ if (idValue.startsWith('#') && nonIdRequiredKeys.length > 0) {
277
+ const template = this.getLocatorTemplate(resource) ?? '<exact-id>';
278
+ throw new Error(`${methodName} requires a complete locator for subjectTemplate '${template}'. ` +
279
+ `Missing [${nonIdRequiredKeys.join(', ')}]. ` +
280
+ `Use a base-relative resource id that includes every storage slot.`);
281
+ }
282
+ return resolver.resolveSubject(resource, locator);
283
+ }
267
284
  if (missingKeys.length > 0) {
268
- const template = this.getLocatorTemplate(table);
285
+ const template = this.getLocatorTemplate(resource) ?? '<exact-id>';
269
286
  throw new Error(`${methodName} requires a complete locator for subjectTemplate '${template}'. ` +
270
287
  `Missing [${missingKeys.join(', ')}]. ` +
271
288
  `Use ${this.getIriAlternative(methodName)} when you already have a full IRI.`);
272
289
  }
273
- return resolver.resolveSubject(table, locator);
290
+ return resolver.resolveSubject(resource, locator);
291
+ }
292
+ resolveIdSubject(resource, id, methodName) {
293
+ if (!id || typeof id !== 'string') {
294
+ throw new Error(`${methodName} requires a valid base-relative resource id string`);
295
+ }
296
+ if (isAbsoluteIri(id)) {
297
+ throw new Error(`${methodName} requires a base-relative resource id. Use ${this.getIriAlternative(methodName)} for full IRIs.`);
298
+ }
299
+ const template = this.getLocatorTemplate(resource) ?? '<exact-id>';
300
+ const missingNonIdKeys = this.getRequiredLocatorKeys(resource).filter((key) => key !== 'id');
301
+ const resolver = this.dialect.getResolver(resource);
302
+ if (isBaseRelativeSubjectId(id)) {
303
+ if (id.startsWith('#') && missingNonIdKeys.length > 0) {
304
+ throw new Error(`${methodName} requires a base-relative resource id for subjectTemplate '${template}', got local fragment id '${id}'. ` +
305
+ `Missing [${missingNonIdKeys.join(', ')}]. ` +
306
+ `Use a base-relative id that includes every storage slot.`);
307
+ }
308
+ return resolver.resolveSubject(resource, { id: id.startsWith('#') ? id.slice(1) : id });
309
+ }
310
+ if (missingNonIdKeys.length > 0) {
311
+ throw new Error(`${methodName} requires a base-relative resource id for subjectTemplate '${template}', got local id '${id}'. ` +
312
+ `Missing [${missingNonIdKeys.join(', ')}]. ` +
313
+ `Use a base-relative id that includes every storage slot.`);
314
+ }
315
+ return resolver.resolveSubject(resource, { id });
316
+ }
317
+ warnFindByLocatorDeprecation() {
318
+ if (PodDatabase.findByLocatorDeprecationWarned) {
319
+ return;
320
+ }
321
+ PodDatabase.findByLocatorDeprecationWarned = true;
322
+ console.warn('[drizzle-solid] findByLocator(resource, locator) is deprecated and will be removed in a future release. ' +
323
+ 'Use findById(resource, id) for base-relative resource ids, findByResource(resource, target) for generic exact targets, ' +
324
+ 'or findByIri(resource, iri) for full IRIs.');
274
325
  }
275
326
  getIriAlternative(methodName) {
276
327
  if (methodName === 'resolveLocatorIri' || methodName === 'resolveLocatorId') {
277
328
  return 'the full IRI directly';
278
329
  }
279
- if (methodName === 'findByResource') {
280
- return 'findByIri(table, iri)';
330
+ if (methodName === 'findById' || methodName === 'findByResource') {
331
+ return 'findByIri(resource, iri)';
281
332
  }
282
- if (methodName === 'updateByResource') {
283
- return 'updateByIri(table, iri, data)';
333
+ if (methodName === 'updateById' || methodName === 'updateByResource') {
334
+ return 'updateByIri(resource, iri, data)';
284
335
  }
285
- if (methodName === 'deleteByResource') {
286
- return 'deleteByIri(table, iri)';
336
+ if (methodName === 'deleteById' || methodName === 'deleteByResource') {
337
+ return 'deleteByIri(resource, iri)';
287
338
  }
288
- return `${methodName.replace('Locator', 'Iri')}(table, iri)`;
339
+ return `${methodName.replace('Locator', 'Iri')}(resource, iri)`;
289
340
  }
290
- resolveLocatorIri(table, locator) {
291
- return this.resolveLocatorSubject(table, locator, 'resolveLocatorIri');
341
+ resolveLocatorIri(resource, locator) {
342
+ return this.resolveLocatorSubject(resource, locator, 'resolveLocatorIri');
292
343
  }
293
- resolveLocatorId(table, locator) {
294
- const iri = this.resolveLocatorSubject(table, locator, 'resolveLocatorId');
295
- return this.dialect.getResolver(table).parseId(table, iri);
344
+ resolveLocatorId(resource, locator) {
345
+ const iri = this.resolveLocatorSubject(resource, locator, 'resolveLocatorId');
346
+ return this.resolveBaseRelativeResourceId(resource, iri);
296
347
  }
297
- resolveResourceIri(table, target) {
298
- return this.resolveResourceTargetIri(table, target, 'resolveResourceIri');
348
+ resolveResourceIri(resource, target) {
349
+ return this.resolveResourceTargetIri(resource, target, 'resolveResourceIri');
299
350
  }
300
- resolveResourceId(table, target) {
301
- const iri = this.resolveResourceTargetIri(table, target, 'resolveResourceId');
302
- return (0, resource_reference_1.parsePodResourceRef)(table, iri)?.resourceId ?? this.dialect.getResolver(table).parseId(table, iri);
351
+ resolveResourceId(resource, target) {
352
+ const iri = this.resolveResourceTargetIri(resource, target, 'resolveResourceId');
353
+ return this.resolveBaseRelativeResourceId(resource, iri);
303
354
  }
304
- resolveRelationIri(table, target) {
305
- return this.resolveResourceTargetIri(table, target, 'resolveRelationIri');
355
+ resolveRelationIri(resource, target) {
356
+ return this.resolveResourceTargetIri(resource, target, 'resolveRelationIri');
306
357
  }
307
- resolveRowIri(table, row) {
358
+ resolveRowIri(resource, row) {
308
359
  if (!isRecord(row) || Array.isArray(row)) {
309
360
  throw new Error('resolveRowIri requires a row object');
310
361
  }
311
- return getKnownRowIri(row) ?? this.resolveLocatorSubject(table, row, 'resolveRowIri');
362
+ return getKnownRowIri(row) ?? this.resolveLocatorSubject(resource, row, 'resolveRowIri');
312
363
  }
313
- resolveRowId(table, row) {
364
+ resolveRowId(resource, row) {
314
365
  if (!isRecord(row) || Array.isArray(row)) {
315
366
  throw new Error('resolveRowId requires a row object');
316
367
  }
317
- const iri = getKnownRowIri(row) ?? this.resolveLocatorSubject(table, row, 'resolveRowId');
318
- return this.dialect.getResolver(table).parseId(table, iri);
368
+ const iri = getKnownRowIri(row) ?? this.resolveLocatorSubject(resource, row, 'resolveRowId');
369
+ return this.resolveBaseRelativeResourceId(resource, iri);
370
+ }
371
+ resolveBaseRelativeResourceId(resource, iri) {
372
+ return (0, resource_reference_1.parsePodResourceRef)(resource, iri)?.resourceId ?? this.dialect.getResolver(resource).parseId(resource, iri);
319
373
  }
320
- async findByLocator(table, locator) {
321
- const iri = this.resolveLocatorSubject(table, locator, 'findByLocator');
322
- return await this.findByIri(table, iri);
374
+ needsShortIdSubjectLookup(resource, id) {
375
+ if (!id || typeof id !== 'string' || isAbsoluteIri(id) || isBaseRelativeSubjectId(id)) {
376
+ return false;
377
+ }
378
+ return this.getRequiredLocatorKeys(resource).some((key) => key !== 'id');
323
379
  }
324
- async findByResource(table, target) {
325
- const iri = this.resolveResourceTargetIri(table, target, 'findByResource');
326
- return await this.findByIri(table, iri);
380
+ buildShortIdSubjectSuffix(resource, id) {
381
+ const template = this.getLocatorTemplate(resource) ?? '<exact-id>';
382
+ const matches = Array.from(template.matchAll(/\{([^}]+)\}/g));
383
+ let idMatchIndex = -1;
384
+ for (let index = matches.length - 1; index >= 0; index--) {
385
+ if (parseTemplateVariableField(matches[index][1]) === 'id') {
386
+ idMatchIndex = index;
387
+ break;
388
+ }
389
+ }
390
+ if (idMatchIndex < 0) {
391
+ return id;
392
+ }
393
+ const idMatch = matches[idMatchIndex];
394
+ const previousMatch = matches[idMatchIndex - 1];
395
+ const previousEnd = previousMatch?.index === undefined
396
+ ? 0
397
+ : previousMatch.index + previousMatch[0].length;
398
+ const idStart = idMatch.index ?? 0;
399
+ const idEnd = idStart + idMatch[0].length;
400
+ return `${template.slice(previousEnd, idStart)}${id}${template.slice(idEnd)}`;
401
+ }
402
+ resolveShortIdLookupSource(resource) {
403
+ const dialectWithResolver = this.dialect;
404
+ if (typeof dialectWithResolver.resolveTableResource === 'function') {
405
+ const descriptor = dialectWithResolver.resolveTableResource(resource);
406
+ if (descriptor.mode === 'sparql' && descriptor.endpoint) {
407
+ return { kind: 'sparql', resourceUrl: descriptor.endpoint, descriptor };
408
+ }
409
+ }
410
+ return null;
327
411
  }
328
- async findByIri(table, iri) {
412
+ extractSubjectFromLookupRow(row) {
413
+ if (!isRecord(row)) {
414
+ return null;
415
+ }
416
+ const value = row.subject ?? row.s ?? row['?subject'] ?? row['?s'];
417
+ if (typeof value === 'string') {
418
+ return value;
419
+ }
420
+ if (hasStringValue(value)) {
421
+ return value.value;
422
+ }
423
+ return null;
424
+ }
425
+ subjectMatchesShortId(resource, subject, id, suffix) {
426
+ const ref = (0, resource_reference_1.parsePodResourceRef)(resource, subject);
427
+ if (ref) {
428
+ return ref.templateValues.id === id;
429
+ }
430
+ return subject.endsWith(suffix);
431
+ }
432
+ getIndexedSubject(resource, id) {
433
+ const dialect = this.dialect;
434
+ if (typeof dialect.lookupIndexedResourceSubject !== 'function') {
435
+ return null;
436
+ }
437
+ return dialect.lookupIndexedResourceSubject(resource, id);
438
+ }
439
+ async lookupSubjectIriByShortId(resource, id, methodName) {
440
+ const source = this.resolveShortIdLookupSource(resource);
441
+ if (!source) {
442
+ const template = this.getLocatorTemplate(resource) ?? '<exact-id>';
443
+ throw new Error(`${methodName} cannot resolve short id '${id}' for subjectTemplate '${template}' ` +
444
+ `because no resource query source is available.`);
445
+ }
446
+ const suffix = this.buildShortIdSubjectSuffix(resource, id);
447
+ const containsNeedle = id;
448
+ const matchClause = resource.config?.type
449
+ ? `?subject ?typePredicate ?typeObject .
450
+ FILTER(?typePredicate = <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> && ?typeObject = <${resource.config.type}> && CONTAINS(STR(?subject), "${escapeSparqlString(containsNeedle)}"))`
451
+ : `?subject ?predicate ?object .
452
+ FILTER(CONTAINS(STR(?subject), "${escapeSparqlString(containsNeedle)}"))`;
453
+ const query = {
454
+ type: 'SELECT',
455
+ query: `SELECT DISTINCT ?subject WHERE {
456
+ ${matchClause}
457
+ }
458
+ LIMIT 50`,
459
+ prefixes: {},
460
+ };
461
+ const rows = source.kind === 'sparql'
462
+ ? await this.dialect.executeOnResource(source.resourceUrl, query, source.descriptor)
463
+ : await this.dialect.getSPARQLExecutor().queryContainer(source.resourceUrl, query);
464
+ const subjects = Array.from(new Set(rows
465
+ .map((row) => this.extractSubjectFromLookupRow(row))
466
+ .filter((value) => Boolean(value))
467
+ .filter((value) => this.subjectMatchesShortId(resource, value, id, suffix))));
468
+ if (subjects.length > 1) {
469
+ throw new Error(`${methodName} found multiple resources for short id '${id}' in '${resource.config?.name ?? 'resource'}'. ` +
470
+ `Use a base-relative resource id or full IRI to disambiguate.`);
471
+ }
472
+ return subjects[0] ?? this.getIndexedSubject(resource, id);
473
+ }
474
+ async resolveIdSubjectForExactOperation(resource, id, methodName) {
475
+ if (this.needsShortIdSubjectLookup(resource, id)) {
476
+ return await this.lookupSubjectIriByShortId(resource, id, methodName);
477
+ }
478
+ return this.resolveIdSubject(resource, id, methodName);
479
+ }
480
+ async findById(resource, id) {
481
+ const iri = await this.resolveIdSubjectForExactOperation(resource, id, 'findById');
482
+ if (!iri) {
483
+ return null;
484
+ }
485
+ return await this.findByIri(resource, iri);
486
+ }
487
+ async findByLocator(resource, locator) {
488
+ this.warnFindByLocatorDeprecation();
489
+ const iri = this.resolveLocatorSubject(resource, locator, 'findByLocator');
490
+ return await this.findByIri(resource, iri);
491
+ }
492
+ async findByResource(resource, target) {
493
+ if (typeof target === 'string' && this.needsShortIdSubjectLookup(resource, target)) {
494
+ return await this.findById(resource, target);
495
+ }
496
+ const iri = this.resolveResourceTargetIri(resource, target, 'findByResource');
497
+ return await this.findByIri(resource, iri);
498
+ }
499
+ async findByIri(resource, iri) {
329
500
  if (!iri || typeof iri !== 'string') {
330
501
  throw new Error('findByIri requires a valid IRI string');
331
502
  }
332
- const exactRead = await this.findByIriViaExactSparql(table, iri);
503
+ const exactRead = await this.findByIriViaExactResource(resource, iri);
333
504
  if (exactRead !== undefined) {
334
505
  return exactRead;
335
506
  }
336
- // 保持原始表上下文,让 subjectTemplate/base 反解保持一致。
337
- // whereByIri() 已经会把 SELECT 精确定位到目标资源,不需要把表重绑到具体文档。
507
+ // Keep the original resource context so subjectTemplate/base decoding stays stable.
508
+ // whereByIri() already pins SELECT to the concrete resource IRI.
338
509
  const rows = await this.session
339
510
  .select()
340
- .from(table)
511
+ .from(resource)
341
512
  .whereByIri(iri)
342
513
  .limit(1);
343
514
  return rows[0] ?? null;
344
515
  }
345
- getColumnPredicate(table, column) {
346
- return column.options?.predicate ?? column.getPredicate?.(table.config.namespace);
516
+ getColumnPredicate(resource, column) {
517
+ return column.options?.predicate ?? column.getPredicate?.(resource.config.namespace);
347
518
  }
348
- async findByIriViaExactSparql(table, iri) {
349
- if (!isPodTable(table)) {
519
+ async findByIriViaExactResource(resource, iri) {
520
+ if (!isPodTable(resource)) {
350
521
  return undefined;
351
522
  }
352
- if (typeof this.dialect.resolveTableResource !== 'function'
353
- || typeof this.dialect.executeOnResource !== 'function') {
523
+ const documentUrl = this.parseIri(iri).documentUrl;
524
+ const directRows = await this.readPredicateObjectRowsFromDocument(documentUrl, iri);
525
+ if (directRows === null) {
526
+ return null;
527
+ }
528
+ if (directRows !== undefined) {
529
+ const mapped = this.mapPredicateObjectRows(resource, iri, directRows);
530
+ if (mapped !== undefined) {
531
+ return mapped;
532
+ }
533
+ }
534
+ if (typeof this.dialect.executeOnResource !== 'function') {
354
535
  return undefined;
355
536
  }
356
- const documentUrl = this.parseIri(iri).documentUrl;
357
- const descriptor = this.dialect.resolveTableResource(table);
358
537
  const query = {
359
538
  type: 'SELECT',
360
539
  query: `SELECT ?p ?o WHERE { <${iri}> ?p ?o . }`,
361
540
  prefixes: {}
362
541
  };
363
- const rows = descriptor.mode === 'sparql'
364
- ? await this.dialect.executeOnResource(documentUrl, query, descriptor)
365
- : await this.dialect.executeOnResource(documentUrl, query);
366
- const mapped = this.mapPredicateObjectRows(table, iri, rows);
367
- if (mapped) {
542
+ // Exact-target reads already know the concrete Pod document. Do not route
543
+ // through a collection sidecar SPARQL endpoint such as /.data/chat/-/sparql.
544
+ let rows;
545
+ try {
546
+ rows = await this.dialect.executeOnResource(documentUrl, query);
547
+ }
548
+ catch (error) {
549
+ if (this.isMissingExactResourceError(error)) {
550
+ return undefined;
551
+ }
552
+ throw error;
553
+ }
554
+ const mapped = this.mapPredicateObjectRows(resource, iri, rows);
555
+ if (mapped !== undefined) {
368
556
  return mapped;
369
557
  }
370
- return null;
558
+ return undefined;
559
+ }
560
+ async readPredicateObjectRowsFromDocument(documentUrl, iri) {
561
+ const getAuthenticatedFetch = this.dialect.getAuthenticatedFetch;
562
+ if (typeof getAuthenticatedFetch !== 'function') {
563
+ return undefined;
564
+ }
565
+ let response;
566
+ try {
567
+ response = await getAuthenticatedFetch.call(this.dialect)(documentUrl, {
568
+ method: 'GET',
569
+ headers: {
570
+ Accept: 'text/turtle, application/ld+json;q=0.8, */*;q=0.1',
571
+ },
572
+ });
573
+ }
574
+ catch (error) {
575
+ if (this.isMissingExactResourceError(error)) {
576
+ return null;
577
+ }
578
+ return undefined;
579
+ }
580
+ if (response.status === 404) {
581
+ return null;
582
+ }
583
+ if (!response.ok) {
584
+ return undefined;
585
+ }
586
+ const contentType = response.headers.get('content-type') ?? '';
587
+ if (contentType
588
+ && !contentType.includes('text/turtle')
589
+ && !contentType.includes('application/n-triples')
590
+ && !contentType.includes('application/trig')
591
+ && !contentType.includes('application/ld+json')) {
592
+ return undefined;
593
+ }
594
+ const body = await response.text();
595
+ if (!body.trim()) {
596
+ return null;
597
+ }
598
+ try {
599
+ const parser = new n3_1.Parser({
600
+ baseIRI: documentUrl,
601
+ format: contentType.includes('application/n-triples') ? 'N-Triples' : 'text/turtle',
602
+ });
603
+ const quads = parser.parse(body);
604
+ return quads
605
+ .filter((quad) => quad.subject.termType === 'NamedNode' && quad.subject.value === iri)
606
+ .map((quad) => ({
607
+ p: quad.predicate.value,
608
+ o: this.convertRdfTermToValue(quad.object),
609
+ }));
610
+ }
611
+ catch {
612
+ return undefined;
613
+ }
614
+ }
615
+ convertRdfTermToValue(term) {
616
+ if (term.termType === 'NamedNode') {
617
+ return term.value;
618
+ }
619
+ if (term.termType === 'BlankNode') {
620
+ return `_:${term.value}`;
621
+ }
622
+ if (term.termType !== 'Literal') {
623
+ return term.value;
624
+ }
625
+ const datatypeIri = term.datatype?.value ?? '';
626
+ if (datatypeIri.includes('#integer') || datatypeIri.includes('#int')) {
627
+ return parseInt(term.value, 10);
628
+ }
629
+ if (datatypeIri.includes('#decimal') || datatypeIri.includes('#double')) {
630
+ return parseFloat(term.value);
631
+ }
632
+ if (datatypeIri.includes('#boolean')) {
633
+ return term.value === 'true';
634
+ }
635
+ if (datatypeIri.includes('#dateTime')) {
636
+ return new Date(term.value);
637
+ }
638
+ if (datatypeIri.includes('#json')) {
639
+ try {
640
+ return JSON.parse(term.value);
641
+ }
642
+ catch {
643
+ return term.value;
644
+ }
645
+ }
646
+ return term.value;
647
+ }
648
+ isMissingExactResourceError(error) {
649
+ if (!isRecord(error)) {
650
+ return false;
651
+ }
652
+ const status = error.status ?? error.statusCode;
653
+ if (status === 404) {
654
+ return true;
655
+ }
656
+ const message = error.message;
657
+ return typeof message === 'string' && /\b(?:HTTP status )?404\b/.test(message);
371
658
  }
372
- mapPredicateObjectRows(table, iri, rows) {
659
+ mapPredicateObjectRows(resource, iri, rows) {
373
660
  if (!Array.isArray(rows) || rows.length === 0) {
374
661
  return null;
375
662
  }
@@ -378,12 +665,13 @@ class PodDatabase {
378
665
  '@id': iri,
379
666
  uri: iri,
380
667
  };
381
- const derivedId = this.extractIdFromIri(table, iri);
668
+ const derivedId = this.extractIdFromIri(resource, iri);
382
669
  if (derivedId !== undefined) {
383
670
  row.id = derivedId;
384
671
  }
385
672
  let hasType = false;
386
673
  let hasAnyMappedPredicate = false;
674
+ let hasUnhydratedInlineObject = false;
387
675
  for (const result of rows) {
388
676
  if (!isRecord(result)) {
389
677
  continue;
@@ -394,14 +682,14 @@ class PodDatabase {
394
682
  continue;
395
683
  }
396
684
  if (predicate === 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'
397
- && object === table.config.type) {
685
+ && object === resource.config.type) {
398
686
  hasType = true;
399
687
  }
400
- for (const [key, column] of Object.entries(table.columns ?? {})) {
688
+ for (const [key, column] of Object.entries(resource.columns ?? {})) {
401
689
  if (column._virtualId) {
402
690
  continue;
403
691
  }
404
- const columnPredicate = this.getColumnPredicate(table, column);
692
+ const columnPredicate = this.getColumnPredicate(resource, column);
405
693
  if (!columnPredicate || columnPredicate === '@id' || columnPredicate !== predicate) {
406
694
  continue;
407
695
  }
@@ -413,25 +701,37 @@ class PodDatabase {
413
701
  else if (row[key] === undefined) {
414
702
  row[key] = object;
415
703
  }
704
+ if ((column.dataType === 'object' || column.dataType === 'json')
705
+ && typeof object === 'string'
706
+ && isAbsoluteIri(object)) {
707
+ hasUnhydratedInlineObject = true;
708
+ }
416
709
  hasAnyMappedPredicate = true;
417
710
  }
418
711
  }
419
712
  if (!hasType && !hasAnyMappedPredicate) {
420
713
  return null;
421
714
  }
715
+ if (hasUnhydratedInlineObject) {
716
+ return undefined;
717
+ }
422
718
  return row;
423
719
  }
424
- extractIdFromIri(table, iri) {
720
+ extractIdFromIri(resource, iri) {
721
+ const resourceId = (0, resource_reference_1.parsePodResourceRef)(resource, iri)?.resourceId;
722
+ if (resourceId) {
723
+ return resourceId;
724
+ }
425
725
  try {
426
- const parsedId = this.dialect.getResolver(table).parseId(table, iri);
726
+ const parsedId = this.dialect.getResolver(resource).parseId(resource, iri);
427
727
  if (parsedId) {
428
728
  return parsedId;
429
729
  }
430
730
  }
431
731
  catch {
432
- // Fall through to conservative legacy parsing for non-standard tables.
732
+ // Fall through to conservative legacy parsing for non-standard resources.
433
733
  }
434
- const template = table.getSubjectTemplate?.() ?? table.config?.subjectTemplate;
734
+ const template = resource.getSubjectTemplate?.() ?? resource.config?.subjectTemplate;
435
735
  if (!template) {
436
736
  return undefined;
437
737
  }
@@ -467,7 +767,7 @@ class PodDatabase {
467
767
  /**
468
768
  * 通过完整 IRI 订阅单个实体的变更
469
769
  *
470
- * @param table - 表定义
770
+ * @param resource - Resource definition used to decode schema and subject shape.
471
771
  * @param iri - 完整 IRI,本地或远程
472
772
  * @param options - 订阅选项
473
773
  * @returns 取消订阅函数
@@ -494,7 +794,7 @@ class PodDatabase {
494
794
  * unsubscribe()
495
795
  * ```
496
796
  */
497
- async subscribeByIri(table, iri, options) {
797
+ async subscribeByIri(resource, iri, options) {
498
798
  if (!iri || typeof iri !== 'string') {
499
799
  throw new Error('subscribeByIri requires a valid IRI string');
500
800
  }
@@ -519,7 +819,7 @@ class PodDatabase {
519
819
  try {
520
820
  if (event.type === 'Update') {
521
821
  // 重新获取数据
522
- const data = await this.findByIri(table, iri);
822
+ const data = await this.findByIri(resource, iri);
523
823
  if (data) {
524
824
  await options.onUpdate(data);
525
825
  }
@@ -537,7 +837,7 @@ class PodDatabase {
537
837
  // 返回取消订阅函数
538
838
  return () => subscription.unsubscribe();
539
839
  }
540
- async updateByIri(table, iri, data) {
840
+ async updateByIri(resource, iri, data) {
541
841
  if (!iri || typeof iri !== 'string') {
542
842
  throw new Error('updateByIri requires a valid IRI string');
543
843
  }
@@ -547,24 +847,34 @@ class PodDatabase {
547
847
  const updateData = data;
548
848
  // 使用 whereByIri 内部方法进行更新
549
849
  await this.session
550
- .update(table)
850
+ .update(resource)
551
851
  .set(updateData)
552
852
  .whereByIri(iri);
553
853
  // 返回更新后的数据
554
- return await this.findByIri(table, iri);
854
+ return await this.findByIri(resource, iri);
855
+ }
856
+ async updateById(resource, id, data) {
857
+ const iri = await this.resolveIdSubjectForExactOperation(resource, id, 'updateById');
858
+ if (!iri) {
859
+ return null;
860
+ }
861
+ return await this.updateByIri(resource, iri, data);
555
862
  }
556
- async updateByLocator(table, locator, data) {
557
- const iri = this.resolveLocatorSubject(table, locator, 'updateByLocator');
558
- return await this.updateByIri(table, iri, data);
863
+ async updateByLocator(resource, locator, data) {
864
+ const iri = this.resolveLocatorSubject(resource, locator, 'updateByLocator');
865
+ return await this.updateByIri(resource, iri, data);
559
866
  }
560
- async updateByResource(table, target, data) {
561
- const iri = this.resolveResourceTargetIri(table, target, 'updateByResource');
562
- return await this.updateByIri(table, iri, data);
867
+ async updateByResource(resource, target, data) {
868
+ if (typeof target === 'string' && this.needsShortIdSubjectLookup(resource, target)) {
869
+ return await this.updateById(resource, target, data);
870
+ }
871
+ const iri = this.resolveResourceTargetIri(resource, target, 'updateByResource');
872
+ return await this.updateByIri(resource, iri, data);
563
873
  }
564
874
  /**
565
875
  * 通过完整 IRI 删除单个实体
566
876
  *
567
- * @param table - 表定义
877
+ * @param resource - Resource definition used to decode schema and subject shape.
568
878
  * @param iri - 完整 IRI
569
879
  * @returns 是否删除成功
570
880
  *
@@ -576,7 +886,7 @@ class PodDatabase {
576
886
  * )
577
887
  * ```
578
888
  */
579
- async deleteByIri(table, iri) {
889
+ async deleteByIri(resource, iri) {
580
890
  if (!iri || typeof iri !== 'string') {
581
891
  throw new Error('deleteByIri requires a valid IRI string');
582
892
  }
@@ -584,23 +894,37 @@ class PodDatabase {
584
894
  throw new Error(`deleteByIri requires an absolute IRI, got: ${iri}`);
585
895
  }
586
896
  // 先检查实体是否存在
587
- const existing = await this.findByIri(table, iri);
897
+ const existing = await this.findByIri(resource, iri);
588
898
  if (!existing) {
589
899
  return false;
590
900
  }
591
901
  // 使用 whereByIri 内部方法进行删除
592
902
  await this.session
593
- .delete(table)
903
+ .delete(resource)
594
904
  .whereByIri(iri);
595
905
  return true;
596
906
  }
597
- async deleteByLocator(table, locator) {
598
- const iri = this.resolveLocatorSubject(table, locator, 'deleteByLocator');
599
- return await this.deleteByIri(table, iri);
907
+ async deleteById(resource, id) {
908
+ const iri = await this.resolveIdSubjectForExactOperation(resource, id, 'deleteById');
909
+ if (!iri) {
910
+ return false;
911
+ }
912
+ return await this.deleteByIri(resource, iri);
600
913
  }
601
- async deleteByResource(table, target) {
602
- const iri = this.resolveResourceTargetIri(table, target, 'deleteByResource');
603
- return await this.deleteByIri(table, iri);
914
+ /**
915
+ * @deprecated Use deleteById(resource, id), deleteByResource(resource, target), or deleteByIri(resource, iri).
916
+ * This locator-shaped exact delete will be removed in a future release.
917
+ */
918
+ async deleteByLocator(resource, locator) {
919
+ const iri = this.resolveLocatorSubject(resource, locator, 'deleteByLocator');
920
+ return await this.deleteByIri(resource, iri);
921
+ }
922
+ async deleteByResource(resource, target) {
923
+ if (typeof target === 'string' && this.needsShortIdSubjectLookup(resource, target)) {
924
+ return await this.deleteById(resource, target);
925
+ }
926
+ const iri = this.resolveResourceTargetIri(resource, target, 'deleteByResource');
927
+ return await this.deleteByIri(resource, iri);
604
928
  }
605
929
  // 事务支持
606
930
  async transaction(transaction) {
@@ -640,9 +964,9 @@ class PodDatabase {
640
964
  return await this.dialect.disconnect();
641
965
  }
642
966
  /**
643
- * 订阅表/资源的变化通知
967
+ * 订阅资源的变化通知
644
968
  *
645
- * @param table - 要订阅的表(会订阅其容器或资源)
969
+ * @param resource - 要订阅的 resource(会订阅其容器或文档)
646
970
  * @param options - 订阅选项,支持按类型分开的回调
647
971
  * @returns 订阅句柄,可用于取消订阅
648
972
  *
@@ -669,7 +993,7 @@ class PodDatabase {
669
993
  * subscription.unsubscribe();
670
994
  * ```
671
995
  */
672
- async subscribe(table, options) {
996
+ async subscribe(resource, options) {
673
997
  // 懒初始化 NotificationsClient
674
998
  if (!this.notificationsClient) {
675
999
  const authenticatedFetch = this.dialect.getAuthenticatedFetch();
@@ -678,8 +1002,8 @@ class PodDatabase {
678
1002
  };
679
1003
  this.notificationsClient = new notifications_1.NotificationsClient(authenticatedFetch, config);
680
1004
  }
681
- // 获取表的资源 URL(容器或文件),支持 iri 覆盖
682
- const topic = this.resolveTableTopic(table, options.iri);
1005
+ // 获取 resource URL(容器或文件),支持 iri 覆盖
1006
+ const topic = this.resolveResourceTopic(resource, options.iri);
683
1007
  // 将 TableSubscribeOptions 转换为底层 SubscribeOptions
684
1008
  const subscribeOptions = {
685
1009
  channel: options.channel,
@@ -722,11 +1046,11 @@ class PodDatabase {
722
1046
  return this.notificationsClient.subscribe(topic, subscribeOptions);
723
1047
  }
724
1048
  /**
725
- * 解析表对应的订阅主题 URL
726
- * @param table 表定义
1049
+ * 解析 resource 对应的订阅主题 URL
1050
+ * @param resource Resource definition
727
1051
  * @param iriOverride 可选的 IRI 覆盖(用于订阅其他 Pod 的资源)
728
1052
  */
729
- resolveTableTopic(table, iriOverride) {
1053
+ resolveResourceTopic(resource, iriOverride) {
730
1054
  // 如果提供了 iri 覆盖,直接使用
731
1055
  if (iriOverride) {
732
1056
  if (!iriOverride.startsWith('http://') && !iriOverride.startsWith('https://')) {
@@ -734,7 +1058,7 @@ class PodDatabase {
734
1058
  }
735
1059
  return iriOverride;
736
1060
  }
737
- const base = table.config.base || '';
1061
+ const base = resource.config.base || '';
738
1062
  // 如果 base 已经是绝对 URL,直接使用
739
1063
  if (base.startsWith('http://') || base.startsWith('https://')) {
740
1064
  return base;
@@ -1099,13 +1423,13 @@ class PodDatabase {
1099
1423
  const schemaEntries = (this.schema && typeof this.schema === 'object')
1100
1424
  ? Object.entries(this.schema)
1101
1425
  : [];
1102
- const tableMap = new Map();
1426
+ const resourceMap = new Map();
1103
1427
  for (const [key, value] of schemaEntries) {
1104
1428
  if (isPodTable(value)) {
1105
- tableMap.set(key, value);
1429
+ resourceMap.set(key, value);
1106
1430
  }
1107
1431
  }
1108
- const createHelper = (_tableName, table) => {
1432
+ const createHelper = (_resourceName, resource) => {
1109
1433
  const createLazy = (executor) => {
1110
1434
  let promise = null;
1111
1435
  const run = () => {
@@ -1148,7 +1472,7 @@ class PodDatabase {
1148
1472
  };
1149
1473
  const executeFindMany = async (options) => {
1150
1474
  this.clearFederatedErrors();
1151
- let builder = this.session.select().from(table);
1475
+ let builder = this.session.select().from(resource);
1152
1476
  if (options?.where) {
1153
1477
  builder = builder.where(options.where);
1154
1478
  }
@@ -1166,7 +1490,7 @@ class PodDatabase {
1166
1490
  }
1167
1491
  let rows = await builder;
1168
1492
  if (options?.with && Object.keys(options.with).length > 0) {
1169
- rows = await this.eagerLoadWith(rows, table, options.with, tableMap);
1493
+ rows = await this.eagerLoadWith(rows, resource, options.with, resourceMap);
1170
1494
  }
1171
1495
  const columns = options?.columns;
1172
1496
  if (columns) {
@@ -1181,7 +1505,7 @@ class PodDatabase {
1181
1505
  }
1182
1506
  let rows = [row];
1183
1507
  if (options?.with && Object.keys(options.with).length > 0) {
1184
- rows = await this.eagerLoadWith(rows, table, options.with, tableMap);
1508
+ rows = await this.eagerLoadWith(rows, resource, options.with, resourceMap);
1185
1509
  }
1186
1510
  const columns = options?.columns;
1187
1511
  if (columns) {
@@ -1197,12 +1521,16 @@ class PodDatabase {
1197
1521
  const rows = await executeFindMany({ where: options?.where, columns: undefined, limit: undefined, offset: undefined });
1198
1522
  return rows.length;
1199
1523
  });
1200
- const createFindByLocator = () => (locator, options) => createLazy(async () => await applyExactOptions(await this.findByLocator(table, locator), options));
1201
- const createFindByIri = () => (iri, options) => createLazy(async () => await applyExactOptions(await this.findByIri(table, iri), options));
1202
- const createFindByResource = () => (target, options) => createLazy(async () => await applyExactOptions(await this.findByResource(table, target), options));
1524
+ const createFindByLocator = () => (locator, options) => createLazy(async () => await applyExactOptions(await this.findByLocator(resource, locator), options));
1525
+ const createFindById = () => (id, options) => createLazy(async () => await applyExactOptions(await this.findById(resource, id), options));
1526
+ const createFindByIri = () => (iri, options) => createLazy(async () => await applyExactOptions(await this.findByIri(resource, iri), options));
1527
+ const createFindByResource = () => (target, options) => createLazy(async () => await applyExactOptions(await this.findByResource(resource, target), options));
1528
+ const find = (target, options) => createFindByResource()(target, options);
1203
1529
  return {
1204
1530
  findMany,
1205
1531
  findFirst,
1532
+ find,
1533
+ findById: createFindById(),
1206
1534
  findByLocator: createFindByLocator(),
1207
1535
  findByIri: createFindByIri(),
1208
1536
  findByResource: createFindByResource(),
@@ -1215,9 +1543,9 @@ class PodDatabase {
1215
1543
  if (typeof prop !== 'string') {
1216
1544
  return undefined;
1217
1545
  }
1218
- const table = tableMap.get(prop);
1219
- if (table) {
1220
- return createHelper(prop, table);
1546
+ const resource = resourceMap.get(prop);
1547
+ if (resource) {
1548
+ return createHelper(prop, resource);
1221
1549
  }
1222
1550
  return undefined;
1223
1551
  }
@@ -1533,4 +1861,5 @@ class PodDatabase {
1533
1861
  exports.PodDatabase = PodDatabase;
1534
1862
  _a = drizzle_orm_1.entityKind;
1535
1863
  PodDatabase[_a] = 'PodDatabase';
1864
+ PodDatabase.findByLocatorDeprecationWarned = false;
1536
1865
  //# sourceMappingURL=pod-database.js.map