@undefineds.co/xpod 0.3.75 → 0.4.0-rc.140

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 (362) hide show
  1. package/bin/xpod.js +43 -8
  2. package/config/bun.json +45 -48
  3. package/config/cloud.json +13 -90
  4. package/config/components-ignore.json +0 -1
  5. package/config/local.json +111 -63
  6. package/config/resolver.json +4 -2
  7. package/config/terminal.json +4 -1
  8. package/config/xpod.base.json +16 -8
  9. package/config/xpod.json +51 -54
  10. package/dist/acceptance/PublicCloudSemanticConformance.d.ts +4 -0
  11. package/dist/acceptance/PublicCloudSemanticConformance.js +214 -0
  12. package/dist/acceptance/QleverSearchConformance.d.ts +39 -0
  13. package/dist/acceptance/QleverSearchConformance.js +686 -0
  14. package/dist/acceptance/QleverSemanticConformance.d.ts +3 -0
  15. package/dist/acceptance/QleverSemanticConformance.js +178 -0
  16. package/dist/acceptance/RdfSemanticConformance.d.ts +114 -0
  17. package/dist/acceptance/RdfSemanticConformance.js +307 -0
  18. package/dist/acceptance/run-installed-qlever-conformance.d.ts +12 -0
  19. package/dist/acceptance/run-installed-qlever-conformance.js +87 -0
  20. package/dist/acceptance/run-installed-rdf-conformance.d.ts +12 -0
  21. package/dist/acceptance/run-installed-rdf-conformance.js +88 -0
  22. package/dist/ai/service/EmbeddingProviderError.d.ts +7 -0
  23. package/dist/ai/service/EmbeddingProviderError.js +42 -0
  24. package/dist/api/ai-gateway/connect/index.js +5 -2
  25. package/dist/api/auth/AuthContext.d.ts +5 -0
  26. package/dist/api/auth/AuthContext.js +10 -0
  27. package/dist/api/container/common.js +20 -1
  28. package/dist/api/container/rdf.d.ts +1 -0
  29. package/dist/api/container/rdf.js +43 -4
  30. package/dist/api/container/types.d.ts +4 -0
  31. package/dist/api/runs/InngestRunExecutionBackend.d.ts +2 -2
  32. package/dist/api/runs/PiAgentRuntimeDriver.d.ts +2 -0
  33. package/dist/api/runs/PiAgentRuntimeDriver.js +1 -0
  34. package/dist/api/runs/RdfRunContextRetriever.d.ts +8 -0
  35. package/dist/api/runs/RdfRunContextRetriever.js +23 -1
  36. package/dist/api/runtime.js +20 -6
  37. package/dist/api/service/RdfSearchIndexingService.d.ts +37 -3
  38. package/dist/api/service/RdfSearchIndexingService.js +130 -18
  39. package/dist/api/service/RdfSearchIndexingSolidFsSyncer.d.ts +8 -0
  40. package/dist/api/service/RdfSearchIndexingSolidFsSyncer.js +102 -15
  41. package/dist/api/service/RdfSearchReconciliationWorker.d.ts +76 -0
  42. package/dist/api/service/RdfSearchReconciliationWorker.js +294 -0
  43. package/dist/api/tasks/InngestTaskScheduler.d.ts +4 -4
  44. package/dist/components/components.jsonld +9 -12
  45. package/dist/components/context.jsonld +227 -348
  46. package/dist/document/MarkdownRetrievalPointProjector.d.ts +33 -0
  47. package/dist/document/MarkdownRetrievalPointProjector.js +196 -0
  48. package/dist/document/MarkdownRetrievalPointProjector.jsonld +135 -0
  49. package/dist/document/ReaderMaterialization.d.ts +34 -0
  50. package/dist/document/ReaderMaterialization.js +3 -0
  51. package/dist/document/ReaderMaterialization.jsonld +151 -0
  52. package/dist/document/ReaderMaterializationRepository.d.ts +27 -0
  53. package/dist/document/ReaderMaterializationRepository.js +400 -0
  54. package/dist/document/ReaderMaterializationRepository.jsonld +84 -0
  55. package/dist/document/index.d.ts +3 -1
  56. package/dist/document/index.js +3 -1
  57. package/dist/http/SubgraphSparqlHttpHandler.js +34 -54
  58. package/dist/http/search/SearchHttpHandler.js +14 -12
  59. package/dist/http/terminal/TerminalHttpHandler.d.ts +3 -0
  60. package/dist/http/terminal/TerminalHttpHandler.js +1 -0
  61. package/dist/http/terminal/TerminalHttpHandler.jsonld +11 -0
  62. package/dist/identity/drizzle/DrizzleIndexedStorage.js +19 -39
  63. package/dist/identity/drizzle/db.d.ts +1 -0
  64. package/dist/identity/drizzle/db.js +35 -0
  65. package/dist/index.d.ts +9 -17
  66. package/dist/index.js +14 -22
  67. package/dist/provision/ProvisionPodCreator.d.ts +1 -1
  68. package/dist/provision/ProvisionPodCreator.js +4 -3
  69. package/dist/search/RdfSearchIntentSink.d.ts +17 -0
  70. package/dist/search/RdfSearchIntentSink.js +46 -0
  71. package/dist/search/RdfSearchIntentSink.jsonld +47 -0
  72. package/dist/search/RdfSearchReconciliationRepository.d.ts +81 -0
  73. package/dist/search/RdfSearchReconciliationRepository.js +771 -0
  74. package/dist/solidfs/LocalRdfAuthorityRecoveryInitializer.d.ts +15 -0
  75. package/dist/solidfs/LocalRdfAuthorityRecoveryInitializer.js +48 -0
  76. package/dist/solidfs/LocalRdfAuthorityRecoveryInitializer.jsonld +99 -0
  77. package/dist/solidfs/RdfIndexSolidFsSyncer.js +22 -4
  78. package/dist/solidfs/SolidFsSyncJournal.d.ts +7 -1
  79. package/dist/solidfs/SolidFsSyncJournal.js +20 -5
  80. package/dist/solidfs/SolidFsSyncJournal.jsonld +43 -0
  81. package/dist/solidfs/index.d.ts +1 -0
  82. package/dist/solidfs/index.js +1 -0
  83. package/dist/storage/SparqlUpdateResourceStore.js +3 -3
  84. package/dist/storage/accessors/MixDataAccessor.d.ts +21 -29
  85. package/dist/storage/accessors/MixDataAccessor.js +182 -399
  86. package/dist/storage/accessors/MixDataAccessor.jsonld +109 -87
  87. package/dist/storage/accessors/SolidRdfDataAccessor.d.ts +12 -8
  88. package/dist/storage/accessors/SolidRdfDataAccessor.js +189 -59
  89. package/dist/storage/accessors/SolidRdfDataAccessor.jsonld +14 -29
  90. package/dist/storage/rdf/LocalQleverNativeSparqlClient.d.ts +55 -0
  91. package/dist/storage/rdf/LocalQleverNativeSparqlClient.js +519 -0
  92. package/dist/storage/rdf/LocalQleverNativeSparqlClient.jsonld +314 -0
  93. package/dist/storage/rdf/PostgresRdfEngine.d.ts +3 -1
  94. package/dist/storage/rdf/PostgresRdfEngine.js +111 -74
  95. package/dist/storage/rdf/PostgresRdfEngine.jsonld +12 -22
  96. package/dist/storage/rdf/PostgresRdfSchemaValidation.d.ts +8 -0
  97. package/dist/storage/rdf/PostgresRdfSchemaValidation.js +82 -0
  98. package/dist/storage/rdf/PostgresRdfTextIndex.d.ts +6 -3
  99. package/dist/storage/rdf/PostgresRdfTextIndex.js +158 -80
  100. package/dist/storage/rdf/PostgresRdfTextIndex.jsonld +16 -4
  101. package/dist/storage/rdf/PostgresRdfVectorIndex.d.ts +4 -5
  102. package/dist/storage/rdf/PostgresRdfVectorIndex.js +124 -120
  103. package/dist/storage/rdf/PostgresRdfVectorIndex.jsonld +14 -18
  104. package/dist/storage/rdf/QleverSparqlEngine.d.ts +35 -0
  105. package/dist/storage/rdf/QleverSparqlEngine.js +185 -0
  106. package/dist/storage/rdf/QleverSparqlEngine.jsonld +70 -0
  107. package/dist/storage/rdf/Rdf3xIndex.js +20 -16
  108. package/dist/storage/rdf/RdfAccessScope.d.ts +4 -0
  109. package/dist/storage/rdf/RdfAccessScope.js +74 -9
  110. package/dist/storage/rdf/RdfAccessScope.jsonld +16 -0
  111. package/dist/storage/rdf/RdfEngineRdfJsSource.d.ts +14 -0
  112. package/dist/storage/rdf/RdfEngineRdfJsSource.js +179 -0
  113. package/dist/storage/rdf/RdfQuadIndex.d.ts +13 -14
  114. package/dist/storage/rdf/RdfQuadIndex.js +286 -99
  115. package/dist/storage/rdf/RdfQuadIndex.jsonld +10 -22
  116. package/dist/storage/rdf/RdfQueryExecutor.js +10 -4
  117. package/dist/storage/rdf/RdfQuerySparqlEngine.d.ts +33 -0
  118. package/dist/storage/rdf/RdfQuerySparqlEngine.js +215 -0
  119. package/dist/storage/rdf/RdfQuerySparqlEngine.jsonld +78 -0
  120. package/dist/storage/rdf/RdfSparqlAdapter.d.ts +0 -4
  121. package/dist/storage/rdf/RdfSparqlAdapter.js +75 -173
  122. package/dist/storage/rdf/RdfSparqlBoundary.d.ts +37 -0
  123. package/dist/storage/rdf/RdfSparqlBoundary.js +247 -0
  124. package/dist/storage/rdf/RdfSparqlSerialization.d.ts +3 -0
  125. package/dist/storage/rdf/RdfSparqlSerialization.js +19 -0
  126. package/dist/storage/rdf/RdfSqliteConnection.d.ts +7 -0
  127. package/dist/storage/rdf/RdfSqliteConnection.js +23 -0
  128. package/dist/storage/rdf/RdfTermDictionary.d.ts +0 -8
  129. package/dist/storage/rdf/RdfTermDictionary.js +0 -136
  130. package/dist/storage/rdf/RdfTermDictionary.jsonld +0 -32
  131. package/dist/storage/rdf/RdfTermSemantics.d.ts +6 -0
  132. package/dist/storage/rdf/RdfTermSemantics.js +29 -0
  133. package/dist/storage/rdf/RdfTextIndex.d.ts +5 -6
  134. package/dist/storage/rdf/RdfTextIndex.js +187 -115
  135. package/dist/storage/rdf/RdfTextIndex.jsonld +10 -14
  136. package/dist/storage/rdf/RdfVectorIndex.d.ts +4 -4
  137. package/dist/storage/rdf/RdfVectorIndex.js +156 -233
  138. package/dist/storage/rdf/RdfVectorIndex.jsonld +10 -14
  139. package/dist/storage/rdf/SolidRdfEngine.d.ts +16 -21
  140. package/dist/storage/rdf/SolidRdfEngine.js +28 -308
  141. package/dist/storage/rdf/SolidRdfEngine.jsonld +26 -148
  142. package/dist/storage/rdf/XpodComunicaQueryEngine.d.ts +10 -0
  143. package/dist/storage/rdf/XpodComunicaQueryEngine.js +72 -0
  144. package/dist/storage/rdf/index.d.ts +7 -6
  145. package/dist/storage/rdf/index.js +17 -12
  146. package/dist/storage/rdf/models-benchmark.d.ts +5 -1
  147. package/dist/storage/rdf/models-benchmark.js +17 -19
  148. package/dist/storage/rdf/types.d.ts +68 -6
  149. package/dist/storage/rdf/types.jsonld +69 -0
  150. package/dist/storage/sparql/SubgraphQueryEngine.d.ts +13 -7
  151. package/dist/storage/sparql/SubgraphQueryEngine.js +6 -6
  152. package/dist/storage/vector/index.d.ts +0 -1
  153. package/dist/storage/vector/index.js +0 -1
  154. package/dist/terminal/AclPermissionService.d.ts +4 -5
  155. package/dist/terminal/AclPermissionService.js +55 -75
  156. package/dist/terminal/TerminalSessionManager.d.ts +3 -2
  157. package/dist/terminal/TerminalSessionManager.js +3 -3
  158. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-executor.d.ts +1 -0
  159. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-executor.d.ts.map +1 -1
  160. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-executor.js +29 -26
  161. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/ldp-executor.js.map +1 -1
  162. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/sparql-strategy.d.ts.map +1 -1
  163. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/sparql-strategy.js +9 -4
  164. package/node_modules/@undefineds.co/drizzle-solid/dist/core/execution/sparql-strategy.js.map +1 -1
  165. package/node_modules/@undefineds.co/drizzle-solid/dist/core/notifications/notifications-client.d.ts +1 -0
  166. package/node_modules/@undefineds.co/drizzle-solid/dist/core/notifications/notifications-client.d.ts.map +1 -1
  167. package/node_modules/@undefineds.co/drizzle-solid/dist/core/notifications/notifications-client.js +6 -3
  168. package/node_modules/@undefineds.co/drizzle-solid/dist/core/notifications/notifications-client.js.map +1 -1
  169. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-database.js +3 -3
  170. package/node_modules/@undefineds.co/drizzle-solid/dist/core/pod-database.js.map +1 -1
  171. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/select-query-builder.d.ts +6 -0
  172. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/select-query-builder.d.ts.map +1 -1
  173. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/select-query-builder.js +13 -3
  174. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-builders/select-query-builder.js.map +1 -1
  175. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-where-policy.d.ts +1 -0
  176. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-where-policy.d.ts.map +1 -1
  177. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-where-policy.js +31 -0
  178. package/node_modules/@undefineds.co/drizzle-solid/dist/core/query-where-policy.js.map +1 -1
  179. package/node_modules/@undefineds.co/drizzle-solid/dist/core/sparql/builder/expression-builder.d.ts.map +1 -1
  180. package/node_modules/@undefineds.co/drizzle-solid/dist/core/sparql/builder/expression-builder.js +5 -0
  181. package/node_modules/@undefineds.co/drizzle-solid/dist/core/sparql/builder/expression-builder.js.map +1 -1
  182. package/node_modules/@undefineds.co/drizzle-solid/dist/core/sparql-executor.d.ts +1 -0
  183. package/node_modules/@undefineds.co/drizzle-solid/dist/core/sparql-executor.d.ts.map +1 -1
  184. package/node_modules/@undefineds.co/drizzle-solid/dist/core/sparql-executor.js +45 -0
  185. package/node_modules/@undefineds.co/drizzle-solid/dist/core/sparql-executor.js.map +1 -1
  186. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-executor.d.ts +1 -0
  187. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-executor.d.ts.map +1 -1
  188. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-executor.js +29 -26
  189. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/ldp-executor.js.map +1 -1
  190. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/sparql-strategy.d.ts.map +1 -1
  191. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/sparql-strategy.js +9 -4
  192. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/execution/sparql-strategy.js.map +1 -1
  193. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/notifications/notifications-client.d.ts +1 -0
  194. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/notifications/notifications-client.d.ts.map +1 -1
  195. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/notifications/notifications-client.js +6 -3
  196. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/notifications/notifications-client.js.map +1 -1
  197. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-database.js +3 -3
  198. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/pod-database.js.map +1 -1
  199. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/select-query-builder.d.ts +6 -0
  200. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/select-query-builder.d.ts.map +1 -1
  201. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/select-query-builder.js +14 -4
  202. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-builders/select-query-builder.js.map +1 -1
  203. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-where-policy.d.ts +1 -0
  204. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-where-policy.d.ts.map +1 -1
  205. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-where-policy.js +30 -0
  206. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/query-where-policy.js.map +1 -1
  207. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/sparql/builder/expression-builder.d.ts.map +1 -1
  208. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/sparql/builder/expression-builder.js +5 -0
  209. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/sparql/builder/expression-builder.js.map +1 -1
  210. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/sparql-executor.d.ts +1 -0
  211. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/sparql-executor.d.ts.map +1 -1
  212. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/sparql-executor.js +45 -0
  213. package/node_modules/@undefineds.co/drizzle-solid/dist/esm/core/sparql-executor.js.map +1 -1
  214. package/node_modules/@undefineds.co/drizzle-solid/package.json +5 -4
  215. package/package.json +22 -8
  216. package/static/app/assets/{index-36TJKN-3.js → index-BikOyGPu.js} +34 -34
  217. package/static/app/assets/inrupt-smoke.js +2 -2
  218. package/static/app/assets/main.css +1 -1
  219. package/static/app/assets/main.js +11 -11
  220. package/static/auth-callback/assets/{AiConfigContext-BvBdu_A3.js → AiConfigContext-iQ74JmRZ.js} +1 -1
  221. package/static/auth-callback/assets/{AiConfigPage-BpDw4jco.js → AiConfigPage-BBDKE1gJ.js} +1 -1
  222. package/static/auth-callback/assets/{DocumentProcessingPanel-BmZ_jzRr.js → DocumentProcessingPanel-D9NntIEK.js} +1 -1
  223. package/static/auth-callback/assets/{IndexLifecyclePanel-BfQBjN4z.js → IndexLifecyclePanel-BG07yBdA.js} +1 -1
  224. package/static/auth-callback/assets/{IndexSubjectPanel-BlsnatPt.js → IndexSubjectPanel-B-bUnU3G.js} +1 -1
  225. package/static/auth-callback/assets/{ModelAssignmentsPanel-KA6Mdndz.js → ModelAssignmentsPanel-C7I-Nqy-.js} +1 -1
  226. package/static/auth-callback/assets/{ModelsPage-C7jymyIY.js → ModelsPage-C2hxyrmI.js} +1 -1
  227. package/static/auth-callback/assets/{NetworkPage-k2ShktNm.js → NetworkPage-IGIc2q1Y.js} +1 -1
  228. package/static/auth-callback/assets/{PaneListHeader-mLMe_dvU.js → PaneListHeader-CebuPl_g.js} +1 -1
  229. package/static/auth-callback/assets/{SearchIndexingPanel-CqV9um_t.js → SearchIndexingPanel-6HnZSg00.js} +1 -1
  230. package/static/auth-callback/assets/{StatusSubjectPanel-BgMBTbr2.js → StatusSubjectPanel-votxBkr5.js} +1 -1
  231. package/static/auth-callback/assets/{StatusWorkspace-zbSyhdG2.js → StatusWorkspace-Cksl61zX.js} +1 -1
  232. package/static/auth-callback/assets/{SystemSettingsPage-CtW79nW6.js → SystemSettingsPage-CKZFUaZT.js} +1 -1
  233. package/static/auth-callback/assets/{SystemSettingsSubjectPanel-ZOPKYUtZ.js → SystemSettingsSubjectPanel-pzfUcCf4.js} +1 -1
  234. package/static/auth-callback/assets/{activity-BQ-CQE3O.js → activity-DQL6kZHZ.js} +1 -1
  235. package/static/auth-callback/assets/auth-callback-B_s8Ye5Z.css +1 -0
  236. package/static/auth-callback/assets/{auth-callback-Htr_CB_g.js → auth-callback-BxQMd_Mc.js} +39 -39
  237. package/static/auth-callback/assets/{badge-D5SGTJeO.js → badge-DvW4LUHH.js} +1 -1
  238. package/static/auth-callback/assets/{download-DK183Ldo.js → download-Cx_uaCR1.js} +1 -1
  239. package/static/auth-callback/assets/{external-link-LDHy_4bn.js → external-link-D6L6ExH1.js} +1 -1
  240. package/static/auth-callback/assets/{index-BWrvgHqK.js → index-BAS_hxGu.js} +1 -1
  241. package/static/auth-callback/assets/{index-2WmlePQ9.js → index-BmBjpCoD.js} +1 -1
  242. package/static/auth-callback/assets/{index-browser-DUd4E4-x.js → index-browser-pdn4D3M4.js} +1 -1
  243. package/static/auth-callback/assets/{key-round-ibX79Kr-.js → key-round-BTBzOggq.js} +1 -1
  244. package/static/auth-callback/assets/{rotate-ccw-B2_VMaiX.js → rotate-ccw-eV7Cx8sB.js} +1 -1
  245. package/static/auth-callback/assets/{skeleton-F4nrpycc.js → skeleton-Bg4GYgBM.js} +1 -1
  246. package/static/auth-callback/assets/{waypoints-DImIq93f.js → waypoints-CJbydf0B.js} +1 -1
  247. package/static/auth-callback/assets/{workspace-layout-IVCSYU21.js → workspace-layout-C6Hh8Xf-.js} +1 -1
  248. package/static/auth-callback/auth-callback.html +2 -2
  249. package/static/dashboard/assets/{AiConfigContext-cjjfYTo9.js → AiConfigContext-BkJj28vK.js} +1 -1
  250. package/static/dashboard/assets/{AiConfigPage-CO0DSD_j.js → AiConfigPage-Cs9B4uyp.js} +1 -1
  251. package/static/dashboard/assets/{DocumentProcessingPanel-DMGnH8Oj.js → DocumentProcessingPanel-BBWmM7mS.js} +1 -1
  252. package/static/dashboard/assets/{IndexLifecyclePanel-DSkIOCL5.js → IndexLifecyclePanel-D5xGTT_i.js} +1 -1
  253. package/static/dashboard/assets/{IndexSubjectPanel-qWN_DbAp.js → IndexSubjectPanel-d-mjDthn.js} +1 -1
  254. package/static/dashboard/assets/{ModelAssignmentsPanel-DCf83uM3.js → ModelAssignmentsPanel-C-OLNbqf.js} +1 -1
  255. package/static/dashboard/assets/{ModelsPage-CMnvSrl5.js → ModelsPage-CBrLjuUn.js} +1 -1
  256. package/static/dashboard/assets/{NetworkPage-C8Gkwclb.js → NetworkPage-BlYk8L1z.js} +1 -1
  257. package/static/dashboard/assets/{PaneListHeader-BtU_8cDK.js → PaneListHeader-A5oZJQC0.js} +1 -1
  258. package/static/dashboard/assets/{SearchIndexingPanel-DEn12pNU.js → SearchIndexingPanel-Bs1j8ZP2.js} +1 -1
  259. package/static/dashboard/assets/{StatusSubjectPanel-B1_ILg2d.js → StatusSubjectPanel-Qao3orvi.js} +1 -1
  260. package/static/dashboard/assets/{StatusWorkspace-BG6nMNCo.js → StatusWorkspace-rDM0yDtk.js} +1 -1
  261. package/static/dashboard/assets/{SystemSettingsPage-BnWYIXaM.js → SystemSettingsPage-FPRPkKaR.js} +1 -1
  262. package/static/dashboard/assets/{SystemSettingsSubjectPanel-C_mYVPWb.js → SystemSettingsSubjectPanel-CjlJAxnX.js} +1 -1
  263. package/static/dashboard/assets/{activity-DYJ7PdRl.js → activity-CJ5K6hYC.js} +1 -1
  264. package/static/dashboard/assets/{badge-BIaZco1P.js → badge-L-NMOi1P.js} +1 -1
  265. package/static/dashboard/assets/dashboard-B_s8Ye5Z.css +1 -0
  266. package/static/dashboard/assets/{dashboard-Dl40_MEa.js → dashboard-DyjAyYxx.js} +34 -34
  267. package/static/dashboard/assets/{download-By16k9VK.js → download-Bi4u5K5B.js} +1 -1
  268. package/static/dashboard/assets/{external-link-B92xOG_d.js → external-link-jmhLDfvT.js} +1 -1
  269. package/static/dashboard/assets/{index-BajZpJ48.js → index-BoaGJBxf.js} +1 -1
  270. package/static/dashboard/assets/{index-wsVPom_x.js → index-C22TAEi4.js} +1 -1
  271. package/static/dashboard/assets/{key-round-Clo5FOwA.js → key-round-Dk1VmMrn.js} +1 -1
  272. package/static/dashboard/assets/{rotate-ccw-smWSfi1L.js → rotate-ccw-DIfLsSwi.js} +1 -1
  273. package/static/dashboard/assets/{skeleton-BrTaGeJw.js → skeleton-BGPJMHb-.js} +1 -1
  274. package/static/dashboard/assets/{waypoints-DGPQInE7.js → waypoints-CY53egpu.js} +1 -1
  275. package/static/dashboard/assets/{workspace-layout-CPU4XRmb.js → workspace-layout-CoHkcx70.js} +1 -1
  276. package/static/dashboard/dashboard.html +2 -2
  277. package/static/settings/assets/{AiConfigContext-CT29_OyW.js → AiConfigContext-BcEPlEJe.js} +1 -1
  278. package/static/settings/assets/{AiConfigPage-WIE95S28.js → AiConfigPage-D-t3ZUhg.js} +1 -1
  279. package/static/settings/assets/{DocumentProcessingPanel-KG8Sq999.js → DocumentProcessingPanel-m2SasiMO.js} +1 -1
  280. package/static/settings/assets/{IndexLifecyclePanel-iKvtHDXY.js → IndexLifecyclePanel-BNmAvx8V.js} +1 -1
  281. package/static/settings/assets/{IndexSubjectPanel-BQdSCkk4.js → IndexSubjectPanel-C5-L2AcW.js} +1 -1
  282. package/static/settings/assets/{ModelAssignmentsPanel-P8QcVB0F.js → ModelAssignmentsPanel-Cfpkf02Y.js} +1 -1
  283. package/static/settings/assets/{ModelsPage-UZkZGqor.js → ModelsPage-DZrACwVN.js} +1 -1
  284. package/static/settings/assets/{NetworkPage-Dcpcvg15.js → NetworkPage-BlrGGfqL.js} +1 -1
  285. package/static/settings/assets/{PaneListHeader--gHtZws5.js → PaneListHeader-C3TCs1RI.js} +1 -1
  286. package/static/settings/assets/{SearchIndexingPanel-DdgJSJYQ.js → SearchIndexingPanel-Cyp3CUzX.js} +1 -1
  287. package/static/settings/assets/{StatusSubjectPanel-UOxp_XVL.js → StatusSubjectPanel-gRkb8WEX.js} +1 -1
  288. package/static/settings/assets/{StatusWorkspace-CPNXuD12.js → StatusWorkspace-Dptx4Ec2.js} +1 -1
  289. package/static/settings/assets/{SystemSettingsPage-B6ySeVPw.js → SystemSettingsPage-BWgGUQbs.js} +1 -1
  290. package/static/settings/assets/{SystemSettingsSubjectPanel-I7zWmpiI.js → SystemSettingsSubjectPanel-VflUvpgC.js} +1 -1
  291. package/static/settings/assets/{activity-CFhmzahP.js → activity-D7iNhTkQ.js} +1 -1
  292. package/static/settings/assets/{badge-BBdUc5B-.js → badge-DO0r_RT4.js} +1 -1
  293. package/static/settings/assets/{download-WJE9-yxQ.js → download-CsJlNSbd.js} +1 -1
  294. package/static/settings/assets/{external-link-RKoYyCp_.js → external-link-BCR7SHme.js} +1 -1
  295. package/static/settings/assets/{index-Bq2o0Bif.js → index-Cgq16ekN.js} +1 -1
  296. package/static/settings/assets/{index-DvxneI5O.js → index-SrhQvcrU.js} +1 -1
  297. package/static/settings/assets/{index-browser-Qmo6EsFT.js → index-browser-THpcMCnz.js} +1 -1
  298. package/static/settings/assets/{key-round-r-D9sQUK.js → key-round-Dd3jk1BT.js} +1 -1
  299. package/static/settings/assets/{rotate-ccw-D3IIhbPH.js → rotate-ccw-tiL14i1d.js} +1 -1
  300. package/static/settings/assets/settings-B_s8Ye5Z.css +1 -0
  301. package/static/settings/assets/{settings-D8oDBXWg.js → settings-CVLDPejo.js} +34 -34
  302. package/static/settings/assets/{skeleton-DrL4RQuw.js → skeleton-DBxLuNgU.js} +1 -1
  303. package/static/settings/assets/{waypoints-C5sRhpJw.js → waypoints-DS3e3hv7.js} +1 -1
  304. package/static/settings/assets/{workspace-layout-B4ALmWsM.js → workspace-layout-mucrxyTK.js} +1 -1
  305. package/static/settings/settings.html +2 -2
  306. package/config/search.json +0 -66
  307. package/dist/document/HeadingChunker.jsonld +0 -41
  308. package/dist/security/secret-cell/DeploymentRootKeyProvider.jsonld +0 -124
  309. package/dist/security/secret-cell/SecretCellVault.jsonld +0 -207
  310. package/dist/storage/PostgresDerivedIndexJournal.d.ts +0 -47
  311. package/dist/storage/PostgresDerivedIndexJournal.js +0 -408
  312. package/dist/storage/PostgresDerivedIndexJournal.jsonld +0 -303
  313. package/dist/storage/RdfDerivedIndexingListener.d.ts +0 -32
  314. package/dist/storage/RdfDerivedIndexingListener.js +0 -135
  315. package/dist/storage/RdfDerivedIndexingListener.jsonld +0 -228
  316. package/dist/storage/accessors/QuadstoreSparqlDataAccessor.d.ts +0 -148
  317. package/dist/storage/accessors/QuadstoreSparqlDataAccessor.js +0 -436
  318. package/dist/storage/accessors/QuadstoreSparqlDataAccessor.jsonld +0 -172
  319. package/dist/storage/accessors/QuintStoreSparqlDataAccessor.d.ts +0 -102
  320. package/dist/storage/accessors/QuintStoreSparqlDataAccessor.js +0 -474
  321. package/dist/storage/accessors/QuintStoreSparqlDataAccessor.jsonld +0 -192
  322. package/dist/storage/rdf/RdfSparqlAdapter.jsonld +0 -486
  323. package/dist/storage/rdf/ShadowRdfQuintStore.d.ts +0 -59
  324. package/dist/storage/rdf/ShadowRdfQuintStore.js +0 -216
  325. package/dist/storage/rdf/ShadowRdfQuintStore.jsonld +0 -312
  326. package/dist/storage/rdf/SolidRdfSparqlEngine.d.ts +0 -107
  327. package/dist/storage/rdf/SolidRdfSparqlEngine.js +0 -1117
  328. package/dist/storage/rdf/SolidRdfSparqlEngine.jsonld +0 -312
  329. package/dist/storage/sparql/AlgebraUtils.d.ts +0 -48
  330. package/dist/storage/sparql/AlgebraUtils.js +0 -118
  331. package/dist/storage/sparql/CompatibilitySparqlEngine.d.ts +0 -37
  332. package/dist/storage/sparql/CompatibilitySparqlEngine.js +0 -96
  333. package/dist/storage/sparql/CompatibilitySparqlEngine.jsonld +0 -123
  334. package/dist/storage/sparql/CompatibilitySparqlEngineImpl.d.ts +0 -36
  335. package/dist/storage/sparql/CompatibilitySparqlEngineImpl.js +0 -124
  336. package/dist/storage/sparql/ComunicaOptimizedEngine.d.ts +0 -59
  337. package/dist/storage/sparql/ComunicaOptimizedEngine.js +0 -254
  338. package/dist/storage/sparql/ComunicaQuintEngine.d.ts +0 -143
  339. package/dist/storage/sparql/ComunicaQuintEngine.js +0 -781
  340. package/dist/storage/sparql/ExpressionEvaluator.d.ts +0 -54
  341. package/dist/storage/sparql/ExpressionEvaluator.js +0 -340
  342. package/dist/storage/sparql/FilterPushdownExtractor.d.ts +0 -74
  343. package/dist/storage/sparql/FilterPushdownExtractor.js +0 -421
  344. package/dist/storage/sparql/OptimizedQuadstoreEngine.d.ts +0 -65
  345. package/dist/storage/sparql/OptimizedQuadstoreEngine.js +0 -327
  346. package/dist/storage/sparql/OptimizedQuadstoreSource.d.ts +0 -46
  347. package/dist/storage/sparql/OptimizedQuadstoreSource.js +0 -118
  348. package/dist/storage/sparql/PatternBuilder.d.ts +0 -41
  349. package/dist/storage/sparql/PatternBuilder.js +0 -118
  350. package/dist/storage/sparql/QueryOptimizer.d.ts +0 -125
  351. package/dist/storage/sparql/QueryOptimizer.js +0 -375
  352. package/dist/storage/sparql/QuintEngine.d.ts +0 -92
  353. package/dist/storage/sparql/QuintEngine.js +0 -150
  354. package/dist/storage/sparql/QuintQuerySource.d.ts +0 -241
  355. package/dist/storage/sparql/QuintQuerySource.js +0 -1069
  356. package/dist/storage/sparql/SimpleSparqlExecutor.d.ts +0 -40
  357. package/dist/storage/sparql/SimpleSparqlExecutor.js +0 -131
  358. package/dist/storage/vector/VectorIndexingListener.d.ts +0 -114
  359. package/dist/storage/vector/VectorIndexingListener.js +0 -346
  360. package/static/auth-callback/assets/auth-callback-rWdEQY5f.css +0 -1
  361. package/static/dashboard/assets/dashboard-rWdEQY5f.css +0 -1
  362. package/static/settings/assets/settings-rWdEQY5f.css +0 -1
@@ -1,1117 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SolidRdfSparqlEngine = void 0;
4
- const asynciterator_1 = require("asynciterator");
5
- const node_crypto_1 = require("node:crypto");
6
- const rdf_data_factory_1 = require("rdf-data-factory");
7
- const n3_1 = require("n3");
8
- const RdfSparqlAdapter_1 = require("./RdfSparqlAdapter");
9
- const RdfAccessScope_1 = require("./RdfAccessScope");
10
- const rdfDataFactory = new rdf_data_factory_1.DataFactory();
11
- const RDF_TYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
12
- const DCT_CREATED = 'http://purl.org/dc/terms/created';
13
- const DCT_TITLE = 'http://purl.org/dc/terms/title';
14
- const SIOC_HAS_CONTAINER = 'http://rdfs.org/sioc/ns#has_container';
15
- const SIOC_HAS_MEMBER = 'http://rdfs.org/sioc/ns#has_member';
16
- const SIOC_HAS_PARENT = 'http://rdfs.org/sioc/ns#has_parent';
17
- const SIOC_THREAD = 'http://rdfs.org/sioc/ns#Thread';
18
- const MEETING_MESSAGE = 'http://www.w3.org/ns/pim/meeting#Message';
19
- const MEETING_LONG_CHAT = 'http://www.w3.org/ns/pim/meeting#LongChat';
20
- const FOAF_AGENT = 'http://xmlns.com/foaf/0.1/Agent';
21
- const VCARD_INDIVIDUAL = 'http://www.w3.org/2006/vcard/ns#Individual';
22
- const SCHEMA_CREATIVE_WORK = 'http://schema.org/CreativeWork';
23
- const SCHEMA_PROPERTY_VALUE = 'http://schema.org/PropertyValue';
24
- const UDFS_TASK = 'https://undefineds.co/ns#Task';
25
- const UDFS_RUN = 'https://undefineds.co/ns#Run';
26
- const UDFS_RUN_STEP = 'https://undefineds.co/ns#RunStep';
27
- const UDFS_SCHEDULE = 'https://undefineds.co/ns#Schedule';
28
- const UDFS_SESSION = 'https://undefineds.co/ns#Session';
29
- const UDFS_ISSUE = 'https://undefineds.co/ns#Issue';
30
- const UDFS_LAST_MESSAGE = 'https://undefineds.co/ns#lastMessage';
31
- const UDFS_STATUS = 'https://undefineds.co/ns#status';
32
- const UDFS_MESSAGE_STATUS = 'https://undefineds.co/ns#messageStatus';
33
- const UDFS_WORKSPACE = 'https://undefineds.co/ns#workspace';
34
- const UDFS_RUN_RELATION = 'https://undefineds.co/ns#run';
35
- const UDFS_TASK_RELATION = 'https://undefineds.co/ns#task';
36
- const UDFS_IN_THREAD = 'https://undefineds.co/ns#inThread';
37
- const UDFS_NEXT_RUN_AT = 'https://undefineds.co/ns#nextRunAt';
38
- const UDFS_LEASE_OWNER = 'https://undefineds.co/ns#leaseOwner';
39
- const UDFS_SESSION_STATUS = 'https://undefineds.co/ns#sessionStatus';
40
- const UDFS_CONVERSATION = 'https://undefineds.co/ns#conversation';
41
- const UDFS_TOKEN_USAGE = 'https://undefineds.co/ns#tokenUsage';
42
- const UDFS_PRIORITY = 'https://undefineds.co/ns#priority';
43
- const UDFS_SCORE = 'https://undefineds.co/ns#score';
44
- const XPOD_AI_PROVIDER = 'https://vocab.xpod.dev/ai#Provider';
45
- const XPOD_AI_MODEL = 'https://vocab.xpod.dev/ai#Model';
46
- const XPOD_AI_IS_PROVIDED_BY = 'https://vocab.xpod.dev/ai#isProvidedBy';
47
- const XPOD_CREDENTIAL = 'https://vocab.xpod.dev/credential#Credential';
48
- const XPOD_CREDENTIAL_PROVIDER = 'https://vocab.xpod.dev/credential#provider';
49
- const XPOD_CREDENTIAL_FAIL_COUNT = 'https://vocab.xpod.dev/credential#failCount';
50
- const PRODUCT_VIEW_MATERIALIZED_VERSION = 'v1';
51
- const SETTINGS_RESOURCE_TYPE_VIEWS = new Map([
52
- [XPOD_AI_PROVIDER, 'ai-providers'],
53
- [XPOD_AI_MODEL, 'ai-models'],
54
- [XPOD_CREDENTIAL, 'credentials'],
55
- ]);
56
- const PRODUCT_RESOURCE_TYPE_VIEWS = new Map([
57
- [MEETING_LONG_CHAT, 'chats'],
58
- [MEETING_MESSAGE, 'messages'],
59
- [SIOC_THREAD, 'threads'],
60
- [UDFS_TASK, 'tasks'],
61
- [UDFS_RUN, 'runs'],
62
- [UDFS_RUN_STEP, 'run-steps'],
63
- [UDFS_SCHEDULE, 'schedules'],
64
- [UDFS_SESSION, 'sessions'],
65
- [UDFS_ISSUE, 'issues'],
66
- [FOAF_AGENT, 'agents'],
67
- [VCARD_INDIVIDUAL, 'contacts'],
68
- [SCHEMA_CREATIVE_WORK, 'favorites'],
69
- [SCHEMA_PROPERTY_VALUE, 'settings'],
70
- ]);
71
- const PRODUCT_RELATION_PREDICATE_VIEWS = new Map([
72
- [DCT_CREATED, 'created-timeline'],
73
- [DCT_TITLE, 'title-hydration'],
74
- [SIOC_HAS_PARENT, 'threads-by-chat'],
75
- [UDFS_LAST_MESSAGE, 'chat-latest-message'],
76
- [UDFS_STATUS, 'status-index'],
77
- [UDFS_MESSAGE_STATUS, 'message-status-index'],
78
- [UDFS_WORKSPACE, 'runs-by-workspace'],
79
- [UDFS_RUN_RELATION, 'steps-by-run'],
80
- [UDFS_TASK_RELATION, 'runs-by-task'],
81
- [UDFS_IN_THREAD, 'runs-by-thread'],
82
- [UDFS_NEXT_RUN_AT, 'schedules-by-due-time'],
83
- [UDFS_LEASE_OWNER, 'runs-by-lease-owner'],
84
- [UDFS_SESSION_STATUS, 'sessions-by-status'],
85
- ]);
86
- class SolidRdfSparqlEngine {
87
- constructor(rdfEngine, fallback, shadowStore, enablePrimary = true, onFallback, autoMaterializeProductViews = true) {
88
- this.adapter = new RdfSparqlAdapter_1.RdfSparqlAdapter();
89
- this.operationCounts = new Map();
90
- this.rdfEngine = rdfEngine;
91
- this.fallback = fallback;
92
- this.shadowStore = shadowStore;
93
- this.enablePrimary = enablePrimary;
94
- this.onFallback = onFallback;
95
- this.autoMaterializeProductViews = autoMaterializeProductViews;
96
- }
97
- async queryBindings(query, basePath, accessScope) {
98
- await this.ensureReady();
99
- if (!this.enablePrimary) {
100
- return this.fallbackWith('queryBindings', 'primary disabled', (fallback) => fallback.queryBindings(query, basePath, accessScope), accessScope);
101
- }
102
- const start = Date.now();
103
- try {
104
- const native = await this.executeNativeSelectPrimary(query, basePath, 'queryBindings', start, accessScope);
105
- if (native) {
106
- return this.bindingsStream(native.result, native.variables);
107
- }
108
- const compiled = this.adapter.compile(query, basePath);
109
- if (compiled.queryType !== 'SELECT') {
110
- return this.fallbackWith('queryBindings', `compiled ${compiled.queryType} cannot produce bindings`, (fallback) => fallback.queryBindings(query, basePath, accessScope), accessScope);
111
- }
112
- const selectedQuery = this.applyMaterializedQuerySelector('queryBindings', compiled.query);
113
- const result = await this.rdfEngine.query((0, RdfAccessScope_1.applyRdfAccessScope)(selectedQuery, accessScope));
114
- this.recordPrimary('queryBindings', start, result);
115
- return this.bindingsStream(result, compiled.variables);
116
- }
117
- catch (error) {
118
- if (error instanceof RdfSparqlAdapter_1.DisabledSparqlFeatureError) {
119
- throw error;
120
- }
121
- return this.fallbackWith('queryBindings', fallbackReason(error), (fallback) => fallback.queryBindings(query, basePath, accessScope), accessScope, error);
122
- }
123
- }
124
- async queryBoolean(query, basePath, accessScope) {
125
- await this.ensureReady();
126
- if (!this.enablePrimary) {
127
- return this.fallbackWith('queryBoolean', 'primary disabled', (fallback) => fallback.queryBoolean(query, basePath, accessScope), accessScope);
128
- }
129
- const start = Date.now();
130
- try {
131
- const native = await this.executeNativeBooleanPrimary(query, basePath, 'queryBoolean', start, accessScope);
132
- if (native !== undefined) {
133
- return native;
134
- }
135
- const compiled = this.adapter.compile(query, basePath);
136
- if (compiled.queryType !== 'ASK') {
137
- return this.fallbackWith('queryBoolean', `compiled ${compiled.queryType} cannot produce boolean`, (fallback) => fallback.queryBoolean(query, basePath, accessScope), accessScope);
138
- }
139
- const selectedQuery = this.applyMaterializedQuerySelector('queryBoolean', compiled.query);
140
- const result = await this.rdfEngine.query((0, RdfAccessScope_1.applyRdfAccessScope)(selectedQuery, accessScope));
141
- this.recordPrimary('queryBoolean', start, result);
142
- return result.bindings.length > 0;
143
- }
144
- catch (error) {
145
- if (error instanceof RdfSparqlAdapter_1.DisabledSparqlFeatureError) {
146
- throw error;
147
- }
148
- return this.fallbackWith('queryBoolean', fallbackReason(error), (fallback) => fallback.queryBoolean(query, basePath, accessScope), accessScope, error);
149
- }
150
- }
151
- async queryQuads(query, basePath, accessScope) {
152
- await this.ensureReady();
153
- if (!this.enablePrimary) {
154
- return this.fallbackWith('queryQuads', 'primary disabled', (fallback) => fallback.queryQuads(query, basePath, accessScope), accessScope);
155
- }
156
- const start = Date.now();
157
- try {
158
- const quads = await this.executeQuadsPrimary(query, basePath, 'queryQuads', start, accessScope);
159
- return new asynciterator_1.ArrayIterator(quads);
160
- }
161
- catch (error) {
162
- if (error instanceof RdfSparqlAdapter_1.DisabledSparqlFeatureError) {
163
- throw error;
164
- }
165
- return this.fallbackWith('queryQuads', fallbackReason(error), (fallback) => fallback.queryQuads(query, basePath, accessScope), accessScope, error);
166
- }
167
- }
168
- async queryVoid(query, basePath, accessScope, options) {
169
- await this.ensureReady();
170
- if (!this.enablePrimary) {
171
- return this.fallbackWith('queryVoid', 'primary disabled', (fallback) => fallback.queryVoid(query, basePath, accessScope, options), accessScope);
172
- }
173
- const start = Date.now();
174
- try {
175
- const native = await this.executeNativeVoidPrimary(query, basePath, 'queryVoid', start, accessScope, options);
176
- if (native) {
177
- return undefined;
178
- }
179
- const delta = this.adapter.compileUpdateDelta(query, basePath, {
180
- defaultGraph: implicitUpdateDefaultGraph(basePath),
181
- });
182
- let deletedRows = 0;
183
- let computedDeletes = 0;
184
- let computedInserts = 0;
185
- for (const operation of delta.operations) {
186
- if (operation.type === 'delete') {
187
- this.assertUpdateQuadsAllowedByAccessScope(operation.quads, basePath, accessScope);
188
- deletedRows += (await this.rdfEngine.applyDelta(operation.quads.map(quadToPattern), [])).deletedRows;
189
- }
190
- else if (operation.type === 'insert') {
191
- this.assertUpdateQuadsAllowedByAccessScope(operation.quads, basePath, accessScope);
192
- await this.rdfEngine.applyDelta([], operation.quads);
193
- }
194
- else if (operation.type === 'insertDeleteWhere') {
195
- const result = await this.rdfEngine.query((0, RdfAccessScope_1.applyRdfAccessScope)(operation.query, accessScope));
196
- const deletes = this.adapter.materializeDeleteWhere(operation.deletes, result.bindings);
197
- const inserts = this.adapter.materializeDeleteWhere(operation.inserts, result.bindings);
198
- this.assertUpdateQuadsAllowedByAccessScope([...deletes, ...inserts], basePath, accessScope);
199
- computedDeletes += deletes.length;
200
- computedInserts += inserts.length;
201
- deletedRows += (await this.rdfEngine.applyDelta(deletes.map(quadToPattern), inserts)).deletedRows;
202
- }
203
- else if (operation.type === 'insertWhere') {
204
- const result = await this.rdfEngine.query((0, RdfAccessScope_1.applyRdfAccessScope)(operation.query, accessScope));
205
- const inserts = this.adapter.materializeDeleteWhere(operation.inserts, result.bindings);
206
- this.assertUpdateQuadsAllowedByAccessScope(inserts, basePath, accessScope);
207
- computedInserts += inserts.length;
208
- await this.rdfEngine.applyDelta([], inserts);
209
- }
210
- else {
211
- const result = await this.rdfEngine.query((0, RdfAccessScope_1.applyRdfAccessScope)(operation.query, accessScope));
212
- const quads = this.adapter.materializeDeleteWhere(operation.template, result.bindings);
213
- this.assertUpdateQuadsAllowedByAccessScope(quads, basePath, accessScope);
214
- computedDeletes += quads.length;
215
- deletedRows += (await this.rdfEngine.applyDelta(quads.map(quadToPattern), [])).deletedRows;
216
- }
217
- }
218
- this.recordPrimary('queryVoid', start, {
219
- bindings: [],
220
- metrics: {
221
- engine: 'solid-rdf',
222
- plan: ['UpdateDelta', `delete:${delta.deletes.length + computedDeletes}`, `deletedRows:${deletedRows}`, `insert:${delta.inserts.length + computedInserts}`],
223
- scannedRows: delta.deletes.length + computedDeletes + delta.inserts.length + computedInserts,
224
- joinedRows: 0,
225
- returnedRows: 0,
226
- durationMs: Date.now() - start,
227
- indexChoices: ['update-delta'],
228
- filtersApplied: 0,
229
- filtersPushedDown: 0,
230
- },
231
- });
232
- return undefined;
233
- }
234
- catch (error) {
235
- if (error instanceof RdfSparqlAdapter_1.DisabledSparqlFeatureError) {
236
- throw error;
237
- }
238
- return this.fallbackWith('queryVoid', fallbackReason(error), (fallback) => fallback.queryVoid(query, basePath, accessScope, options), accessScope, error);
239
- }
240
- }
241
- async constructGraph(graph, basePath, accessScope) {
242
- await this.ensureReady();
243
- if (!this.enablePrimary) {
244
- return this.fallbackWith('constructGraph', 'primary disabled', (fallback) => fallback.constructGraph(graph, basePath, accessScope), accessScope);
245
- }
246
- if (!graph.startsWith(basePath) || (accessScope && !(0, RdfAccessScope_1.rdfAccessGraphAllowed)(graph, accessScope))) {
247
- return new asynciterator_1.ArrayIterator([]);
248
- }
249
- const start = Date.now();
250
- try {
251
- const quads = await this.executeConstructPrimary(`
252
- CONSTRUCT { ?s ?p ?o }
253
- WHERE { GRAPH <${escapeIri(graph)}> { ?s ?p ?o } }
254
- `, basePath, 'constructGraph', start, accessScope);
255
- return new asynciterator_1.ArrayIterator(quads);
256
- }
257
- catch (error) {
258
- if (error instanceof RdfSparqlAdapter_1.DisabledSparqlFeatureError) {
259
- throw error;
260
- }
261
- return this.fallbackWith('constructGraph', fallbackReason(error), (fallback) => fallback.constructGraph(graph, basePath, accessScope), accessScope, error);
262
- }
263
- }
264
- async listGraphs(basePath, accessScope) {
265
- await this.ensureReady();
266
- if (!this.enablePrimary) {
267
- return this.fallbackWith('listGraphs', 'primary disabled', (fallback) => fallback.listGraphs(basePath, accessScope), accessScope);
268
- }
269
- const start = Date.now();
270
- try {
271
- const result = await this.executeSelectPrimary(`
272
- SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } }
273
- `, basePath, 'listGraphs', start, accessScope);
274
- const graphs = new Set();
275
- for (const binding of result.bindings) {
276
- const graph = binding.g;
277
- if (graph?.termType === 'NamedNode') {
278
- graphs.add(graph.value);
279
- }
280
- }
281
- return (0, RdfAccessScope_1.filterRdfAccessGraphs)(graphs, accessScope);
282
- }
283
- catch (error) {
284
- if (error instanceof RdfSparqlAdapter_1.DisabledSparqlFeatureError) {
285
- throw error;
286
- }
287
- return this.fallbackWith('listGraphs', fallbackReason(error), (fallback) => fallback.listGraphs(basePath, accessScope), accessScope, error);
288
- }
289
- }
290
- async close() {
291
- await this.rdfEngine.close();
292
- await this.fallback?.close();
293
- }
294
- getMetrics() {
295
- const operationCounts = [...this.operationCounts.entries()]
296
- .map(([operation, counts]) => operationCountSnapshot(operation, counts))
297
- .sort((left, right) => left.operation.localeCompare(right.operation));
298
- const primaryCount = operationCounts.reduce((sum, counts) => sum + counts.primaryCount, 0);
299
- const fallbackCount = operationCounts.reduce((sum, counts) => sum + counts.fallbackCount, 0);
300
- const totalCount = primaryCount + fallbackCount;
301
- return {
302
- primaryCount,
303
- fallbackCount,
304
- totalCount,
305
- fallbackRate: ratio(fallbackCount, totalCount),
306
- operationCounts,
307
- lastPrimary: this.lastPrimary,
308
- lastFallback: this.lastFallback,
309
- };
310
- }
311
- assertFallbackBudget(budget = {}) {
312
- const snapshot = this.getMetrics();
313
- const maxFallbackRate = budget.maxFallbackRate ?? 0;
314
- const maxFallbackCount = budget.maxFallbackCount ?? 0;
315
- const operationSet = budget.operations ? new Set(budget.operations) : undefined;
316
- const counts = operationSet
317
- ? snapshot.operationCounts.filter((count) => operationSet.has(count.operation))
318
- : snapshot.operationCounts;
319
- const primaryCount = counts.reduce((sum, count) => sum + count.primaryCount, 0);
320
- const fallbackCount = counts.reduce((sum, count) => sum + count.fallbackCount, 0);
321
- const totalCount = primaryCount + fallbackCount;
322
- const fallbackRate = ratio(fallbackCount, totalCount);
323
- if (fallbackCount <= maxFallbackCount && fallbackRate <= maxFallbackRate) {
324
- return;
325
- }
326
- const scope = operationSet ? ` for ${[...operationSet].join(',')}` : '';
327
- const reason = snapshot.lastFallback ? `; last fallback ${snapshot.lastFallback.operation}: ${snapshot.lastFallback.reason}` : '';
328
- throw new Error(`SolidRdfSparql fallback budget exceeded${scope}: ${fallbackCount}/${totalCount} (${fallbackRate}) > count ${maxFallbackCount}, rate ${maxFallbackRate}${reason}`);
329
- }
330
- resetMetrics() {
331
- this.operationCounts.clear();
332
- this.lastPrimary = undefined;
333
- this.lastFallback = undefined;
334
- }
335
- bindingsStream(result, variables) {
336
- const projectedVariables = variables.length > 0
337
- ? variables
338
- : inferVariables(result.bindings);
339
- const rows = result.bindings.map((binding) => this.bindings(binding, projectedVariables));
340
- const iterator = new asynciterator_1.ArrayIterator(rows);
341
- iterator.metadata = async () => ({
342
- variables: projectedVariables.map((variableName) => rdfDataFactory.variable(variableName)),
343
- });
344
- return iterator;
345
- }
346
- applyMaterializedQuerySelector(operation, query) {
347
- if (query.cache?.materialized || !this.autoMaterializeProductViews) {
348
- return query;
349
- }
350
- const materialized = defaultMaterializedQuerySelector(operation, query);
351
- if (!materialized) {
352
- return query;
353
- }
354
- return {
355
- ...query,
356
- cache: {
357
- ...query.cache,
358
- materialized,
359
- },
360
- };
361
- }
362
- bindings(binding, variables) {
363
- const entries = variables
364
- .map((variableName) => {
365
- const term = binding[variableName];
366
- return term ? [rdfDataFactory.variable(variableName), term] : null;
367
- })
368
- .filter((entry) => entry !== null);
369
- return new RdfBindings(entries);
370
- }
371
- async fallbackWith(operation, reason, run, accessScope, cause) {
372
- const embeddedReason = embeddedUnsupportedReason(reason);
373
- if (cause instanceof RdfSparqlAdapter_1.NativeSparqlExecutionError) {
374
- throw cause;
375
- }
376
- const inherited = cause instanceof RdfSparqlAdapter_1.UnsupportedSparqlQueryError
377
- ? {
378
- code: cause.code,
379
- capability: cause.capability,
380
- hint: cause.hint,
381
- correction: cause.correction,
382
- }
383
- : undefined;
384
- if ((0, RdfAccessScope_1.isRestrictiveRdfAccessScope)(accessScope)) {
385
- throw new RdfSparqlAdapter_1.UnsupportedSparqlQueryError(`Embedded SPARQL engine cannot execute ${operation} inside ACL/ACR-restricted scope: ${embeddedReason}`, inherited);
386
- }
387
- if (!this.fallback) {
388
- throw new RdfSparqlAdapter_1.UnsupportedSparqlQueryError(`Embedded SPARQL engine cannot execute ${operation}: ${embeddedReason}`, inherited);
389
- }
390
- this.onFallback?.({ operation, reason });
391
- const start = Date.now();
392
- try {
393
- return await run(this.fallback);
394
- }
395
- finally {
396
- this.recordFallback(operation, reason, Date.now() - start);
397
- }
398
- }
399
- async ensureReady() {
400
- if (this.shadowStore) {
401
- await this.shadowStore.open();
402
- }
403
- }
404
- async executeSelectPrimary(query, basePath, operation, start, accessScope) {
405
- const native = await this.executeNativeSelectPrimary(query, basePath, operation, start, accessScope);
406
- if (native) {
407
- return native.result;
408
- }
409
- const compiled = this.adapter.compile(query, basePath);
410
- if (compiled.queryType !== 'SELECT') {
411
- throw new RdfSparqlAdapter_1.UnsupportedSparqlQueryError(`compiled ${compiled.queryType} cannot produce bindings`);
412
- }
413
- const result = await this.rdfEngine.query((0, RdfAccessScope_1.applyRdfAccessScope)(compiled.query, accessScope));
414
- this.recordPrimary(operation, start, result);
415
- return result;
416
- }
417
- assertUpdateQuadsAllowedByAccessScope(quads, basePath, accessScope) {
418
- if (!isWriteAccessScope(accessScope) || !(0, RdfAccessScope_1.isRestrictiveRdfAccessScope)(accessScope)) {
419
- return;
420
- }
421
- for (const quad of quads) {
422
- const graph = quad.graph.termType === 'DefaultGraph' ? basePath : quad.graph.value;
423
- if (!(0, RdfAccessScope_1.rdfAccessGraphAllowed)(graph, accessScope)) {
424
- throw new RdfSparqlAdapter_1.UnsupportedSparqlQueryError(`Embedded SPARQL engine cannot execute queryVoid: update target graph is outside the authorized RDF access scope: ${graph}`, {
425
- capability: 'sparql.update.access_scope',
426
- hint: 'Authorize the target graph for this write, or split the update so each write target is inside the granted graph scope.',
427
- });
428
- }
429
- }
430
- }
431
- async executeConstructPrimary(query, basePath, operation, start, accessScope) {
432
- const native = await this.executeNativeGraphPrimary(query, basePath, operation, start, accessScope);
433
- if (native) {
434
- return native;
435
- }
436
- const compiled = this.adapter.compile(query, basePath);
437
- if (compiled.queryType !== 'CONSTRUCT' || !compiled.constructTemplate) {
438
- throw new RdfSparqlAdapter_1.UnsupportedSparqlQueryError(`compiled ${compiled.queryType} cannot produce quads`);
439
- }
440
- const result = await this.rdfEngine.query((0, RdfAccessScope_1.applyRdfAccessScope)(compiled.query, accessScope));
441
- const quads = this.adapter.materializeConstruct(compiled.constructTemplate, result.bindings, rdfDataFactory.defaultGraph());
442
- this.recordPrimary(operation, start, {
443
- ...result,
444
- bindings: [],
445
- metrics: {
446
- ...result.metrics,
447
- returnedRows: quads.length,
448
- plan: [...result.metrics.plan, 'Construct'],
449
- },
450
- });
451
- return quads;
452
- }
453
- async executeQuadsPrimary(query, basePath, operation, start, accessScope) {
454
- const native = await this.executeNativeGraphPrimary(query, basePath, operation, start, accessScope);
455
- if (native) {
456
- return native;
457
- }
458
- const compiled = this.adapter.compile(query, basePath);
459
- if (compiled.queryType === 'CONSTRUCT' && compiled.constructTemplate) {
460
- const result = await this.rdfEngine.query((0, RdfAccessScope_1.applyRdfAccessScope)(compiled.query, accessScope));
461
- const quads = this.adapter.materializeConstruct(compiled.constructTemplate, result.bindings, rdfDataFactory.defaultGraph());
462
- this.recordPrimary(operation, start, {
463
- ...result,
464
- bindings: [],
465
- metrics: {
466
- ...result.metrics,
467
- returnedRows: quads.length,
468
- plan: [...result.metrics.plan, 'Construct'],
469
- },
470
- });
471
- return quads;
472
- }
473
- if (compiled.queryType === 'DESCRIBE' && compiled.describeTargets) {
474
- return this.executeDescribePrimary(compiled.query, compiled.describeTargets, basePath, operation, start, accessScope);
475
- }
476
- throw new RdfSparqlAdapter_1.UnsupportedSparqlQueryError(`compiled ${compiled.queryType} cannot produce quads`);
477
- }
478
- async executeDescribePrimary(query, targets, basePath, operation, start, accessScope) {
479
- const seed = await this.rdfEngine.query((0, RdfAccessScope_1.applyRdfAccessScope)(query, accessScope));
480
- const quads = [];
481
- const seen = new Set();
482
- for (const target of targets) {
483
- for (const binding of seed.bindings) {
484
- const subject = resolveQueryTerm(target, binding);
485
- if (!subject || subject.termType !== 'NamedNode') {
486
- continue;
487
- }
488
- const describe = await this.rdfEngine.query((0, RdfAccessScope_1.applyRdfAccessScope)({
489
- patterns: [
490
- {
491
- subject,
492
- predicate: { variable: 'p' },
493
- object: { variable: 'o' },
494
- graph: { $startsWith: basePath },
495
- },
496
- ],
497
- select: ['p', 'o'],
498
- }, accessScope));
499
- for (const row of describe.bindings) {
500
- const predicate = row.p;
501
- const object = row.o;
502
- if (predicate?.termType !== 'NamedNode' || !isQuadObjectTerm(object)) {
503
- continue;
504
- }
505
- const quad = rdfDataFactory.quad(subject, predicate, object, rdfDataFactory.defaultGraph());
506
- const key = [quad.subject, quad.predicate, quad.object, quad.graph].map((term) => (0, n3_1.termToId)(term)).join('\u001f');
507
- if (!seen.has(key)) {
508
- seen.add(key);
509
- quads.push(quad);
510
- }
511
- }
512
- }
513
- }
514
- this.recordPrimary(operation, start, {
515
- bindings: [],
516
- metrics: {
517
- ...seed.metrics,
518
- returnedRows: quads.length,
519
- plan: [...seed.metrics.plan, 'Describe'],
520
- },
521
- });
522
- return quads;
523
- }
524
- async executeNativeVoidPrimary(query, basePath, operation, start, accessScope, options) {
525
- const envelope = await this.runNativeSparql(query, basePath, operation, 'application/sparql-results+json', accessScope, options);
526
- if (!envelope) {
527
- return false;
528
- }
529
- this.recordPrimary(operation, start, {
530
- bindings: [],
531
- metrics: nativeSparqlMetrics(envelope, 0, Date.now() - start),
532
- });
533
- return true;
534
- }
535
- async executeNativeSelectPrimary(query, basePath, operation, start, accessScope) {
536
- const envelope = await this.runNativeSparql(query, basePath, operation, 'application/sparql-results+json', accessScope);
537
- if (!envelope) {
538
- return undefined;
539
- }
540
- const parsed = parseNativeSparqlJsonResult(envelope, Date.now() - start);
541
- if (!parsed.result) {
542
- throw new RdfSparqlAdapter_1.UnsupportedSparqlQueryError('native SPARQL result did not contain SELECT bindings');
543
- }
544
- this.recordPrimary(operation, start, parsed.result);
545
- return {
546
- result: parsed.result,
547
- variables: parsed.variables,
548
- };
549
- }
550
- async executeNativeBooleanPrimary(query, basePath, operation, start, accessScope) {
551
- const envelope = await this.runNativeSparql(query, basePath, operation, 'application/sparql-results+json', accessScope);
552
- if (!envelope) {
553
- return undefined;
554
- }
555
- const parsed = parseNativeSparqlJsonResult(envelope, Date.now() - start);
556
- if (parsed.boolean === undefined) {
557
- throw new RdfSparqlAdapter_1.UnsupportedSparqlQueryError('native SPARQL result did not contain ASK boolean');
558
- }
559
- const result = {
560
- bindings: parsed.boolean ? [{}] : [],
561
- metrics: nativeSparqlMetrics(envelope, parsed.boolean ? 1 : 0, Date.now() - start),
562
- };
563
- this.recordPrimary(operation, start, result);
564
- return parsed.boolean;
565
- }
566
- async executeNativeGraphPrimary(query, basePath, operation, start, accessScope) {
567
- const envelope = await this.runNativeSparql(query, basePath, operation, 'application/n-triples', accessScope);
568
- if (!envelope) {
569
- return undefined;
570
- }
571
- const quads = parseNativeGraphResult(envelope);
572
- this.recordPrimary(operation, start, {
573
- bindings: [],
574
- metrics: nativeSparqlMetrics(envelope, quads.length, Date.now() - start),
575
- });
576
- return quads;
577
- }
578
- async runNativeSparql(query, basePath, operation, acceptMediaType, accessScope, options) {
579
- if (typeof this.rdfEngine.sparqlQuery !== 'function') {
580
- return undefined;
581
- }
582
- this.adapter.assertServerOwnedNativeQuery(query, basePath);
583
- const result = await this.rdfEngine.sparqlQuery(query, {
584
- basePath,
585
- operation,
586
- acceptMediaType,
587
- accessScope,
588
- ...(options?.loadDocument ? { loadDocument: options.loadDocument } : {}),
589
- });
590
- if (result.status === 'ok') {
591
- return result;
592
- }
593
- if (result.status === 'error') {
594
- throw new RdfSparqlAdapter_1.NativeSparqlExecutionError(result.error || 'native SPARQL engine returned error status');
595
- }
596
- return undefined;
597
- }
598
- recordPrimary(operation, start, result) {
599
- const durationMs = Date.now() - start;
600
- const counts = this.countsFor(operation);
601
- counts.primaryCount += 1;
602
- counts.primaryDurationMs += durationMs;
603
- this.lastPrimary = {
604
- operation,
605
- durationMs,
606
- scannedRows: result.metrics.scannedRows,
607
- returnedRows: result.metrics.returnedRows,
608
- plan: result.metrics.plan,
609
- indexChoices: result.metrics.indexChoices,
610
- nativeProfile: result.metrics.nativeProfile,
611
- };
612
- }
613
- recordFallback(operation, reason, durationMs) {
614
- const counts = this.countsFor(operation);
615
- counts.fallbackCount += 1;
616
- counts.fallbackDurationMs += durationMs;
617
- this.lastFallback = {
618
- operation,
619
- reason,
620
- durationMs,
621
- };
622
- }
623
- countsFor(operation) {
624
- const existing = this.operationCounts.get(operation);
625
- if (existing) {
626
- return existing;
627
- }
628
- const created = {
629
- primaryCount: 0,
630
- fallbackCount: 0,
631
- primaryDurationMs: 0,
632
- fallbackDurationMs: 0,
633
- };
634
- this.operationCounts.set(operation, created);
635
- return created;
636
- }
637
- }
638
- exports.SolidRdfSparqlEngine = SolidRdfSparqlEngine;
639
- function parseNativeSparqlJsonResult(envelope, durationMs) {
640
- const payload = JSON.parse(envelope.body);
641
- const variables = payload.head?.vars ?? [];
642
- if (typeof payload.boolean === 'boolean') {
643
- return { variables, boolean: payload.boolean };
644
- }
645
- const bindings = (payload.results?.bindings ?? []).map((row) => nativeSparqlBindingRow(row));
646
- return {
647
- variables,
648
- result: {
649
- bindings,
650
- metrics: nativeSparqlMetrics(envelope, bindings.length, durationMs),
651
- },
652
- };
653
- }
654
- function nativeSparqlBindingRow(row) {
655
- const binding = {};
656
- for (const [variable, value] of Object.entries(row)) {
657
- const term = nativeSparqlJsonTerm(value);
658
- if (term) {
659
- binding[variable] = term;
660
- }
661
- }
662
- return binding;
663
- }
664
- function nativeSparqlJsonTerm(value) {
665
- if (!value || typeof value !== 'object') {
666
- return undefined;
667
- }
668
- const term = value;
669
- if (typeof term.value !== 'string') {
670
- return undefined;
671
- }
672
- if (term.type === 'uri') {
673
- return rdfDataFactory.namedNode(term.value);
674
- }
675
- if (term.type === 'bnode') {
676
- return rdfDataFactory.blankNode(term.value);
677
- }
678
- if (term.type === 'literal' || term.type === 'typed-literal') {
679
- if (term['xml:lang']) {
680
- return rdfDataFactory.literal(term.value, term['xml:lang']);
681
- }
682
- if (term.datatype) {
683
- return rdfDataFactory.literal(term.value, rdfDataFactory.namedNode(term.datatype));
684
- }
685
- return rdfDataFactory.literal(term.value);
686
- }
687
- return undefined;
688
- }
689
- function parseNativeGraphResult(envelope) {
690
- const mediaType = envelope.mediaType.toLowerCase();
691
- const parser = new n3_1.Parser({
692
- format: mediaType.includes('n-quads')
693
- ? 'N-Quads'
694
- : mediaType.includes('turtle')
695
- ? 'Turtle'
696
- : 'N-Triples',
697
- });
698
- return parser.parse(envelope.body);
699
- }
700
- function nativeSparqlMetrics(envelope, returnedRows, durationMs) {
701
- const profile = envelope.profile && typeof envelope.profile === 'object'
702
- ? envelope.profile
703
- : undefined;
704
- const root = profile?.root && typeof profile.root === 'object'
705
- ? profile.root
706
- : undefined;
707
- const rootKind = typeof root?.kind === 'string' ? root.kind : undefined;
708
- const descriptor = typeof root?.descriptor === 'string' ? root.descriptor : undefined;
709
- const profiledRows = typeof root?.outputRows === 'number' && Number.isFinite(root.outputRows)
710
- ? root.outputRows
711
- : returnedRows;
712
- return {
713
- engine: 'solid-rdf',
714
- plan: ['NativeSparql', envelope.mediaType, ...(rootKind ? [`Native:${rootKind}`] : [])],
715
- nativeProfile: envelope.profile,
716
- scannedRows: profiledRows,
717
- joinedRows: returnedRows,
718
- returnedRows,
719
- durationMs,
720
- indexChoices: ['native-sparql', ...(descriptor ? [descriptor] : [])],
721
- filtersApplied: 0,
722
- filtersPushedDown: 0,
723
- };
724
- }
725
- class RdfBindings extends Map {
726
- constructor(entries) {
727
- super(entries);
728
- this.byName = new Map();
729
- for (const [variable, term] of entries) {
730
- this.byName.set(variable.value, term);
731
- }
732
- }
733
- get(key) {
734
- if (typeof key === 'string') {
735
- return this.byName.get(key);
736
- }
737
- return this.byName.get(key.value) ?? super.get(key);
738
- }
739
- has(key) {
740
- if (typeof key === 'string') {
741
- return this.byName.has(key);
742
- }
743
- return this.byName.has(key.value) || super.has(key);
744
- }
745
- }
746
- function inferVariables(bindings) {
747
- const names = new Set();
748
- for (const binding of bindings) {
749
- for (const name of Object.keys(binding)) {
750
- names.add(name);
751
- }
752
- }
753
- return [...names];
754
- }
755
- function resolveQueryTerm(term, binding) {
756
- if (term && typeof term === 'object' && 'variable' in term) {
757
- return binding[term.variable];
758
- }
759
- return term;
760
- }
761
- function isQuadObjectTerm(term) {
762
- return Boolean(term
763
- && term.termType !== 'Variable'
764
- && term.termType !== 'DefaultGraph'
765
- && term.termType !== 'Quad');
766
- }
767
- function isWriteAccessScope(scope) {
768
- return Boolean(scope
769
- && (scope.mode === RdfAccessScope_1.RdfAccessMode.APPEND
770
- || scope.mode === RdfAccessScope_1.RdfAccessMode.DELETE
771
- || scope.mode === RdfAccessScope_1.RdfAccessMode.WRITE));
772
- }
773
- function fallbackReason(error) {
774
- if (error instanceof RdfSparqlAdapter_1.UnsupportedSparqlQueryError) {
775
- return error.message;
776
- }
777
- if (error instanceof Error) {
778
- return error.message;
779
- }
780
- return String(error);
781
- }
782
- function embeddedUnsupportedReason(reason) {
783
- return reason
784
- .replace(/\s+fallback to compatibility engine\b/gi, ' is not supported by the embedded RDF engine')
785
- .replace(/\bis handled by the compatibility engine\b/gi, 'is not supported by the embedded RDF engine');
786
- }
787
- function operationCountSnapshot(operation, counts) {
788
- const totalCount = counts.primaryCount + counts.fallbackCount;
789
- return {
790
- operation,
791
- primaryCount: counts.primaryCount,
792
- fallbackCount: counts.fallbackCount,
793
- totalCount,
794
- fallbackRate: ratio(counts.fallbackCount, totalCount),
795
- primaryDurationMs: counts.primaryDurationMs,
796
- fallbackDurationMs: counts.fallbackDurationMs,
797
- };
798
- }
799
- function ratio(numerator, denominator) {
800
- return denominator === 0 ? 0 : numerator / denominator;
801
- }
802
- function defaultMaterializedQuerySelector(operation, query) {
803
- if (operation !== 'queryBindings') {
804
- return undefined;
805
- }
806
- if (hasSearchSources(query)) {
807
- return undefined;
808
- }
809
- return statsProductViewMaterializedResult(query)
810
- ?? threadHistoryMaterializedResult(query)
811
- ?? settingsProductViewMaterializedResult(query)
812
- ?? agentContextMaterializedResult(query)
813
- ?? stableProductViewMaterializedResult(query);
814
- }
815
- function statsProductViewMaterializedResult(query) {
816
- const view = statsProductView(query);
817
- if (!view) {
818
- return undefined;
819
- }
820
- return {
821
- key: `models/stats/${view}/${shortHash(stableQueryFingerprint(query))}`,
822
- version: PRODUCT_VIEW_MATERIALIZED_VERSION,
823
- };
824
- }
825
- function statsProductView(query) {
826
- if (!hasStatsShape(query) || !hasProductGraphScope(query)) {
827
- return undefined;
828
- }
829
- const predicates = new Set();
830
- const hasType = new Set();
831
- for (const pattern of query.patterns) {
832
- const predicate = namedNodeValue(pattern.predicate);
833
- if (!predicate) {
834
- continue;
835
- }
836
- predicates.add(predicate);
837
- if (predicate === RDF_TYPE) {
838
- const type = namedNodeValue(pattern.object);
839
- if (type) {
840
- hasType.add(type);
841
- }
842
- }
843
- }
844
- if (predicates.has(XPOD_AI_IS_PROVIDED_BY) && predicates.has(XPOD_CREDENTIAL_PROVIDER)) {
845
- return predicates.has(XPOD_CREDENTIAL_FAIL_COUNT)
846
- ? 'provider-credential-failures'
847
- : 'provider-credential-counts';
848
- }
849
- if (predicates.has(SIOC_HAS_CONTAINER) || predicates.has(SIOC_HAS_MEMBER)) {
850
- return predicates.has(UDFS_SCORE)
851
- ? 'message-score-by-thread'
852
- : 'message-count-by-thread';
853
- }
854
- if (predicates.has(UDFS_STATUS) && predicates.has(UDFS_PRIORITY)) {
855
- return 'run-priority-summary';
856
- }
857
- const views = new Set();
858
- for (const type of hasType) {
859
- const view = SETTINGS_RESOURCE_TYPE_VIEWS.get(type) ?? PRODUCT_RESOURCE_TYPE_VIEWS.get(type);
860
- if (view) {
861
- views.add(view);
862
- }
863
- }
864
- for (const predicate of predicates) {
865
- const view = PRODUCT_RELATION_PREDICATE_VIEWS.get(predicate);
866
- if (view) {
867
- views.add(view);
868
- }
869
- }
870
- if (views.size === 0) {
871
- return undefined;
872
- }
873
- return `${[...views].sort().join('+')}-${statsAggregateKind(query)}`;
874
- }
875
- function hasStatsShape(query) {
876
- return queryAggregates(query).length > 0
877
- || (query.groupBy?.length ?? 0) > 0
878
- || (query.having?.length ?? 0) > 0;
879
- }
880
- function statsAggregateKind(query) {
881
- const aggregates = queryAggregates(query);
882
- const aggregateKind = aggregates.every((aggregate) => aggregate.type === 'count')
883
- ? 'counts'
884
- : 'numeric-summary';
885
- return (query.groupBy?.length ?? 0) > 0 ? `grouped-${aggregateKind}` : aggregateKind;
886
- }
887
- function queryAggregates(query) {
888
- return query.aggregates && query.aggregates.length > 0
889
- ? query.aggregates
890
- : query.aggregate
891
- ? [query.aggregate]
892
- : [];
893
- }
894
- function threadHistoryMaterializedResult(query) {
895
- const threadIri = threadHistoryQueryThreadIri(query);
896
- if (!threadIri) {
897
- return undefined;
898
- }
899
- return {
900
- key: `chatkit/thread-history/${shortHash(threadIri)}/${shortHash(stableQueryFingerprint(query))}`,
901
- version: PRODUCT_VIEW_MATERIALIZED_VERSION,
902
- };
903
- }
904
- function threadHistoryQueryThreadIri(query) {
905
- for (const pattern of query.patterns) {
906
- const predicate = namedNodeValue(pattern.predicate);
907
- if (predicate !== SIOC_HAS_CONTAINER && predicate !== SIOC_HAS_MEMBER) {
908
- continue;
909
- }
910
- const object = namedNodeValue(pattern.object);
911
- if (object) {
912
- return object;
913
- }
914
- }
915
- return undefined;
916
- }
917
- function settingsProductViewMaterializedResult(query) {
918
- const view = settingsProductView(query);
919
- if (!view) {
920
- return undefined;
921
- }
922
- return {
923
- key: `models/settings/${view}/${shortHash(stableQueryFingerprint(query))}`,
924
- version: PRODUCT_VIEW_MATERIALIZED_VERSION,
925
- };
926
- }
927
- function settingsProductView(query) {
928
- const typeViews = new Set();
929
- let hasModelProviderLink = false;
930
- let hasCredentialProviderLink = false;
931
- for (const pattern of query.patterns) {
932
- const predicate = namedNodeValue(pattern.predicate);
933
- if (predicate === RDF_TYPE) {
934
- const typeView = SETTINGS_RESOURCE_TYPE_VIEWS.get(namedNodeValue(pattern.object) ?? '');
935
- if (typeView) {
936
- typeViews.add(typeView);
937
- }
938
- continue;
939
- }
940
- if (predicate === XPOD_AI_IS_PROVIDED_BY) {
941
- hasModelProviderLink = true;
942
- continue;
943
- }
944
- if (predicate === XPOD_CREDENTIAL_PROVIDER) {
945
- hasCredentialProviderLink = true;
946
- }
947
- }
948
- if (hasModelProviderLink && hasCredentialProviderLink) {
949
- return 'provider-model-credentials';
950
- }
951
- if (typeViews.size === 0) {
952
- return undefined;
953
- }
954
- return [...typeViews].sort().join('+');
955
- }
956
- function agentContextMaterializedResult(query) {
957
- const view = agentContextProductView(query);
958
- if (!view) {
959
- return undefined;
960
- }
961
- return {
962
- key: `models/agent-context/${view}/${shortHash(stableQueryFingerprint(query))}`,
963
- version: PRODUCT_VIEW_MATERIALIZED_VERSION,
964
- };
965
- }
966
- function agentContextProductView(query) {
967
- if (!query.patterns.some(isProductGraphScoped)) {
968
- return undefined;
969
- }
970
- const types = new Set();
971
- const predicates = new Set();
972
- for (const pattern of query.patterns) {
973
- const predicate = namedNodeValue(pattern.predicate);
974
- if (!predicate) {
975
- continue;
976
- }
977
- predicates.add(predicate);
978
- if (predicate === RDF_TYPE) {
979
- const type = namedNodeValue(pattern.object);
980
- if (type) {
981
- types.add(type);
982
- }
983
- }
984
- }
985
- if (types.has(UDFS_SESSION)
986
- && types.has(MEETING_LONG_CHAT)
987
- && types.has(SIOC_THREAD)
988
- && predicates.has(UDFS_SESSION_STATUS)
989
- && predicates.has(UDFS_CONVERSATION)
990
- && predicates.has(UDFS_IN_THREAD)) {
991
- return predicates.has(UDFS_TOKEN_USAGE)
992
- ? 'active-session-thread-usage'
993
- : 'active-session-thread-hydration';
994
- }
995
- return undefined;
996
- }
997
- function stableProductViewMaterializedResult(query) {
998
- const view = stableProductView(query);
999
- if (!view) {
1000
- return undefined;
1001
- }
1002
- return {
1003
- key: `models/product-views/${view}/${shortHash(stableQueryFingerprint(query))}`,
1004
- version: PRODUCT_VIEW_MATERIALIZED_VERSION,
1005
- };
1006
- }
1007
- function stableProductView(query) {
1008
- const views = new Set();
1009
- for (const pattern of query.patterns) {
1010
- const predicate = namedNodeValue(pattern.predicate);
1011
- if (predicate === RDF_TYPE) {
1012
- const typeView = PRODUCT_RESOURCE_TYPE_VIEWS.get(namedNodeValue(pattern.object) ?? '');
1013
- if (typeView) {
1014
- views.add(typeView);
1015
- }
1016
- continue;
1017
- }
1018
- const predicateView = isProductGraphScoped(pattern)
1019
- ? PRODUCT_RELATION_PREDICATE_VIEWS.get(predicate ?? '')
1020
- : undefined;
1021
- if (predicateView) {
1022
- views.add(predicateView);
1023
- }
1024
- }
1025
- if (views.size === 0) {
1026
- return undefined;
1027
- }
1028
- return [...views].sort().join('+');
1029
- }
1030
- function hasSearchSources(query) {
1031
- return (query.textSearch?.length ?? 0) > 0
1032
- || (query.vectorSearch?.length ?? 0) > 0;
1033
- }
1034
- function isProductGraphScoped(pattern) {
1035
- const graph = namedNodeValue(pattern.graph) ?? graphPrefixValue(pattern.graph);
1036
- return Boolean(graph && isProductGraphPath(graph));
1037
- }
1038
- function hasProductGraphScope(query) {
1039
- if (query.patterns.some(isProductGraphScoped)) {
1040
- return true;
1041
- }
1042
- const graphVariables = new Set(query.patterns
1043
- .map((pattern) => variableValue(pattern.graph))
1044
- .filter((variable) => Boolean(variable)));
1045
- if (graphVariables.size === 0) {
1046
- return false;
1047
- }
1048
- return (query.filters ?? []).some((filter) => (graphVariables.has(filter.variable)
1049
- && filter.operator === '$startsWith'
1050
- && filter.operand === 'stringValue'
1051
- && typeof filter.value === 'string'
1052
- && isProductGraphPath(filter.value)));
1053
- }
1054
- function isProductGraphPath(graph) {
1055
- return graph.includes('/.data/chat/')
1056
- || graph.includes('/.data/task/')
1057
- || graph.includes('/.data/sessions/')
1058
- || graph.includes('/.data/agents/')
1059
- || graph.includes('/.data/approvals/')
1060
- || graph.includes('/.data/audits/')
1061
- || graph.includes('/.data/issues/')
1062
- || graph.includes('/settings/');
1063
- }
1064
- function graphPrefixValue(term) {
1065
- if (!term || typeof term !== 'object' || 'variable' in term || 'termType' in term) {
1066
- return undefined;
1067
- }
1068
- return '$startsWith' in term && typeof term.$startsWith === 'string'
1069
- ? term.$startsWith
1070
- : undefined;
1071
- }
1072
- function namedNodeValue(term) {
1073
- if (!term || typeof term !== 'object' || 'variable' in term || !('termType' in term)) {
1074
- return undefined;
1075
- }
1076
- return term.termType === 'NamedNode' ? term.value : undefined;
1077
- }
1078
- function variableValue(term) {
1079
- if (!term || typeof term !== 'object' || !('variable' in term)) {
1080
- return undefined;
1081
- }
1082
- return term.variable;
1083
- }
1084
- function stableQueryFingerprint(query) {
1085
- const { cache: _cache, ...rest } = query;
1086
- return stableStringify(rest);
1087
- }
1088
- function stableStringify(value) {
1089
- if (value === null || typeof value !== 'object') {
1090
- return JSON.stringify(value);
1091
- }
1092
- if (Array.isArray(value)) {
1093
- return `[${value.map((entry) => stableStringify(entry)).join(',')}]`;
1094
- }
1095
- const entries = Object.entries(value)
1096
- .filter(([, entry]) => typeof entry !== 'function' && entry !== undefined)
1097
- .sort(([left], [right]) => left.localeCompare(right));
1098
- return `{${entries.map(([key, entry]) => `${JSON.stringify(key)}:${stableStringify(entry)}`).join(',')}}`;
1099
- }
1100
- function shortHash(value) {
1101
- return (0, node_crypto_1.createHash)('sha256').update(value).digest('hex').slice(0, 16);
1102
- }
1103
- function implicitUpdateDefaultGraph(basePath) {
1104
- return basePath.endsWith('/') ? undefined : basePath;
1105
- }
1106
- function quadToPattern(quad) {
1107
- return {
1108
- graph: quad.graph,
1109
- subject: quad.subject,
1110
- predicate: quad.predicate,
1111
- object: quad.object,
1112
- };
1113
- }
1114
- function escapeIri(value) {
1115
- return value.replace(/[<>"{}|^`\\]/g, (char) => encodeURIComponent(char));
1116
- }
1117
- //# sourceMappingURL=SolidRdfSparqlEngine.js.map