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

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 +19 -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,1069 +0,0 @@
1
- "use strict";
2
- /**
3
- * QuintQuerySource - IQuerySource implementation for QuintStore
4
- *
5
- * This implements Comunica's IQuerySource interface to enable proper FILTER pushdown.
6
- * Unlike RDF.Store.match() which only receives 4 terms, IQuerySource.queryBindings()
7
- * receives the full SPARQL algebra including FILTER expressions.
8
- *
9
- * Design:
10
- * - Delegates filter extraction to FilterPushdownExtractor
11
- * - Delegates pattern building to PatternBuilder
12
- * - Delegates in-memory evaluation to ExpressionEvaluator
13
- * - Coordinates these components to execute queries efficiently
14
- */
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.QuintQuerySource = void 0;
17
- const asynciterator_1 = require("asynciterator");
18
- const sparqlalgebrajs_1 = require("sparqlalgebrajs");
19
- const rdf_data_factory_1 = require("rdf-data-factory");
20
- const FilterPushdownExtractor_1 = require("./FilterPushdownExtractor");
21
- const PatternBuilder_1 = require("./PatternBuilder");
22
- const ExpressionEvaluator_1 = require("./ExpressionEvaluator");
23
- const AlgebraUtils_1 = require("./AlgebraUtils");
24
- const serialization_1 = require("../quint/serialization");
25
- const dataFactory = new rdf_data_factory_1.DataFactory();
26
- /**
27
- * QuintQuerySource implements IQuerySource for QuintStore
28
- *
29
- * Key features:
30
- * 1. Declares support for FILTER operations via getSelectorShape()
31
- * 2. Receives full SPARQL algebra in queryBindings() including FILTERs
32
- * 3. Extracts filter conditions and pushes them down to QuintStore
33
- * 4. Applies security filters (ACL) unconditionally
34
- * 5. Tree-based evaluation for remaining non-pushdownable expressions
35
- */
36
- class QuintQuerySource {
37
- constructor(store, options) {
38
- this.store = store;
39
- this.referenceValue = store; // Reference for source identification
40
- this.debug = options.debug ?? false;
41
- this.bindingsFactory = options.bindingsFactory;
42
- this.getSecurityFilters = options.getSecurityFilters;
43
- this.getOptimizeParams = options.getOptimizeParams;
44
- this.getFilterExpression = options.getFilterExpression;
45
- // Initialize delegate components
46
- this.filterExtractor = new FilterPushdownExtractor_1.FilterPushdownExtractor();
47
- this.patternBuilder = new PatternBuilder_1.PatternBuilder(this.getSecurityFilters);
48
- this.expressionEvaluator = new ExpressionEvaluator_1.ExpressionEvaluator(store, this.patternBuilder, this.extractPatternAndFilter.bind(this));
49
- }
50
- /**
51
- * Declare the operations this source supports
52
- *
53
- * We support:
54
- * - Basic quad patterns (for simple queries)
55
- * - FILTER operations (for filter pushdown)
56
- * - BGP operations (for multi-pattern queries)
57
- * - joinBindings: allows Comunica to push JOIN operations down to us
58
- *
59
- * The joinBindings support enables ActorRdfJoinMultiBindSource to push
60
- * multiple patterns to us efficiently, using SQL JOINs instead of
61
- * Comunica's nested loop approach.
62
- */
63
- async getSelectorShape(_context) {
64
- // Check if store supports compound queries
65
- const supportsCompound = !!this.store.getCompound;
66
- return {
67
- type: 'disjunction',
68
- children: [
69
- // Support basic patterns with joinBindings
70
- {
71
- type: 'operation',
72
- operation: {
73
- operationType: 'pattern',
74
- pattern: {
75
- type: 'pattern',
76
- subject: dataFactory.variable('s'),
77
- predicate: dataFactory.variable('p'),
78
- object: dataFactory.variable('o'),
79
- graph: dataFactory.variable('g'),
80
- },
81
- },
82
- variablesOptional: [
83
- dataFactory.variable('s'),
84
- dataFactory.variable('p'),
85
- dataFactory.variable('o'),
86
- dataFactory.variable('g'),
87
- ],
88
- // Allow Comunica to push join bindings to us
89
- ...(supportsCompound ? { joinBindings: true } : {}),
90
- },
91
- // Support BGP operations (multi-pattern queries)
92
- {
93
- type: 'operation',
94
- operation: {
95
- operationType: 'type',
96
- type: sparqlalgebrajs_1.Algebra.types.BGP,
97
- },
98
- ...(supportsCompound ? { joinBindings: true } : {}),
99
- },
100
- // Support FILTER operations
101
- {
102
- type: 'operation',
103
- operation: {
104
- operationType: 'type',
105
- type: sparqlalgebrajs_1.Algebra.types.FILTER,
106
- },
107
- ...(supportsCompound ? { joinBindings: true } : {}),
108
- },
109
- // Support JOIN operations (for receiving compound queries from Comunica)
110
- {
111
- type: 'operation',
112
- operation: {
113
- operationType: 'type',
114
- type: sparqlalgebrajs_1.Algebra.types.JOIN,
115
- },
116
- ...(supportsCompound ? { joinBindings: true } : {}),
117
- },
118
- ],
119
- };
120
- }
121
- /**
122
- * Query bindings - main entry point for SPARQL queries
123
- *
124
- * When Comunica's ActorRdfJoinMultiBindSource selects us for a join operation,
125
- * it passes options.joinBindings containing bindings from the first pattern.
126
- * We need to use these bindings to filter our query results efficiently.
127
- */
128
- queryBindings(operation, _context, options) {
129
- if (this.debug) {
130
- console.log(`[QuintQuerySource] queryBindings() called with operation type: ${operation.type}`);
131
- console.log(`[QuintQuerySource] Has joinBindings: ${!!options?.joinBindings}`);
132
- console.log(`[QuintQuerySource] Has filterBindings: ${!!options?.filterBindings}`);
133
- // Log operation structure
134
- if (operation.type === 'join' && operation.input) {
135
- console.log(`[QuintQuerySource] JOIN inputs: ${operation.input?.length || 0}`);
136
- }
137
- }
138
- // Wrap async execution in an iterator using wrap()
139
- const variables = this.getVariablesFromOperation(operation);
140
- const resultIterator = (0, asynciterator_1.wrap)(this.executeQuery(operation, options).then(results => results));
141
- // Add metadata for Comunica
142
- // Variables must be in format { variable: Variable, canBeUndef: boolean }
143
- const variablesMetadata = variables.map(v => ({ variable: v, canBeUndef: false }));
144
- resultIterator.setProperty('metadata', {
145
- state: { invalidate: () => { }, invalid: false, addInvalidateListener: () => { } },
146
- cardinality: { type: 'estimate', value: Number.POSITIVE_INFINITY },
147
- variables: variablesMetadata,
148
- });
149
- return resultIterator;
150
- }
151
- /**
152
- * Execute query and return bindings
153
- *
154
- * If options.joinBindings is provided, we need to:
155
- * 1. Collect bindings from the stream (these are from the first pattern in the JOIN)
156
- * 2. Extract variable values that overlap with our patterns
157
- * 3. Use those values as IN conditions in our query
158
- * 4. JOIN the results with the incoming bindings
159
- */
160
- async executeQuery(operation, options) {
161
- // Handle joinBindings from Comunica (bind join)
162
- if (options?.joinBindings && this.store.getCompound) {
163
- return this.executeBindJoin(operation, options.joinBindings);
164
- }
165
- const { pattern, patterns, filter } = this.extractPatternAndFilter(operation);
166
- // Check if we can use compound query (multiple patterns with same subject variable)
167
- if (patterns && patterns.length > 1 && this.store.getCompound) {
168
- const compoundResult = await this.tryCompoundQuery(patterns, filter, operation);
169
- if (compoundResult) {
170
- return compoundResult;
171
- }
172
- // Compound query not applicable (e.g. inverse patterns with different subject vars).
173
- // Fall back to per-pattern execution with in-memory hash join.
174
- const multiResult = await this.executeMultiPatternJoin(patterns, filter);
175
- if (multiResult) {
176
- return multiResult;
177
- }
178
- }
179
- const variables = (0, AlgebraUtils_1.extractVariables)(pattern);
180
- // Try to get pre-extracted filter expressions for variables in this pattern
181
- let combinedFilter = filter;
182
- if (this.getFilterExpression && !filter) {
183
- // Check if any variable in the pattern has a pre-extracted filter
184
- for (const variable of variables) {
185
- const preExtractedFilter = this.getFilterExpression(variable.value);
186
- if (preExtractedFilter) {
187
- if (this.debug) {
188
- console.log(`[QuintQuerySource] Found pre-extracted filter for ?${variable.value}`);
189
- }
190
- if (combinedFilter) {
191
- // Combine with AND
192
- combinedFilter = {
193
- type: 'expression',
194
- expressionType: 'operator',
195
- operator: '&&',
196
- args: [combinedFilter, preExtractedFilter],
197
- };
198
- }
199
- else {
200
- combinedFilter = preExtractedFilter;
201
- }
202
- }
203
- }
204
- }
205
- // Extract pushdownable filters
206
- let pushdownFilters = {};
207
- let remainder = combinedFilter;
208
- let orBranches;
209
- let orNonPushdownBranches;
210
- if (combinedFilter) {
211
- const result = this.filterExtractor.extractPushdownFilters(combinedFilter, pattern);
212
- pushdownFilters = result.filters;
213
- remainder = result.remainder;
214
- orBranches = result.orBranches;
215
- orNonPushdownBranches = result.orNonPushdownBranches;
216
- }
217
- if (this.debug) {
218
- console.log(`[QuintQuerySource] Pushdown filters:`, JSON.stringify(pushdownFilters, null, 2));
219
- console.log(`[QuintQuerySource] OR branches:`, orBranches?.length || 0);
220
- console.log(`[QuintQuerySource] OR non-pushdown branches:`, orNonPushdownBranches?.length || 0);
221
- console.log(`[QuintQuerySource] Has remainder:`, remainder !== null);
222
- }
223
- // Get query options
224
- // NOTE: Comunica handles OFFSET, we only pass limit to QuintStore
225
- // If there's an offset, we need to fetch limit + offset records
226
- // and let Comunica skip the first `offset` records
227
- const optimizeParams = this.getOptimizeParams();
228
- const queryOptions = {};
229
- if (optimizeParams?.limit) {
230
- // Fetch enough records for Comunica to apply offset
231
- queryOptions.limit = optimizeParams.limit + (optimizeParams.offset || 0);
232
- }
233
- // Don't pass offset to QuintStore - Comunica handles it
234
- // 处理 ORDER BY 下推
235
- if (optimizeParams?.order) {
236
- // 直接使用已映射的 order
237
- queryOptions.order = optimizeParams.order;
238
- }
239
- else if (optimizeParams?.orderVarName) {
240
- // 通过 pattern 分析变量绑定位置
241
- const orderField = this.findVariableBinding(optimizeParams.orderVarName, pattern);
242
- if (orderField) {
243
- queryOptions.order = [orderField];
244
- if (this.debug) {
245
- console.log(`[QuintQuerySource] ORDER BY ?${optimizeParams.orderVarName} -> ${orderField} (via pattern analysis)`);
246
- }
247
- }
248
- }
249
- if (optimizeParams?.reverse)
250
- queryOptions.reverse = optimizeParams.reverse;
251
- let results;
252
- // Handle OR branches (union semantics)
253
- if (orBranches && orBranches.length > 0) {
254
- results = await this.executeOrBranches(pattern, variables, orBranches, orNonPushdownBranches, queryOptions);
255
- if (this.debug) {
256
- console.log(`[QuintQuerySource] OR pushdown branches returned ${results.length} unique results`);
257
- }
258
- }
259
- else if (Object.keys(pushdownFilters).length > 0) {
260
- // Build pattern with pushdown filters
261
- const quintPattern = this.patternBuilder.buildQuintPattern(pattern, pushdownFilters);
262
- const quads = await this.store.get(quintPattern, queryOptions);
263
- results = this.quadsToBindings(quads, variables, pattern);
264
- if (this.debug) {
265
- console.log(`[QuintQuerySource] Pushdown query returned ${results.length} results`);
266
- }
267
- }
268
- else {
269
- // No pushdown, get all matching quads
270
- const quintPattern = this.patternBuilder.buildBasePattern(pattern);
271
- const quads = await this.store.get(quintPattern, queryOptions);
272
- results = this.quadsToBindings(quads, variables, pattern);
273
- if (this.debug) {
274
- console.log(`[QuintQuerySource] Base query returned ${results.length} results`);
275
- }
276
- }
277
- // NOTE: We don't apply in-memory filter for pre-extracted filters
278
- // because Comunica will handle the final filtering after JOIN
279
- // Only apply remainder if it's from the original operation's filter
280
- if (remainder && filter) {
281
- results = await this.expressionEvaluator.evaluateFilterTree(remainder, results, pattern);
282
- if (this.debug) {
283
- console.log(`[QuintQuerySource] After in-memory filter: ${results.length} results`);
284
- }
285
- }
286
- return results;
287
- }
288
- /**
289
- * Execute a bind join: use incoming bindings to filter our query
290
- *
291
- * This is called when Comunica's ActorRdfJoinMultiBindSource pushes bindings to us.
292
- * We use SQL IN clause to efficiently query only the rows matching the incoming bindings.
293
- */
294
- async executeBindJoin(operation, joinBindings) {
295
- // Collect all incoming bindings
296
- const incomingBindings = [];
297
- for await (const binding of joinBindings.bindings) {
298
- incomingBindings.push(binding);
299
- }
300
- if (this.debug) {
301
- console.log(`[QuintQuerySource] executeBindJoin: received ${incomingBindings.length} bindings`);
302
- }
303
- if (incomingBindings.length === 0) {
304
- return [];
305
- }
306
- // Extract patterns from the operation
307
- const { pattern, patterns, filter } = this.extractPatternAndFilter(operation);
308
- const allPatterns = patterns || [pattern];
309
- // Find overlapping variables between incoming bindings and our patterns
310
- // These are the JOIN keys
311
- const incomingVars = new Set();
312
- const firstBinding = incomingBindings[0];
313
- for (const key of firstBinding.keys()) {
314
- incomingVars.add(key.value);
315
- }
316
- // Find which pattern variables overlap with incoming bindings
317
- // Typically this would be the subject variable
318
- const patternVars = new Map();
319
- for (let i = 0; i < allPatterns.length; i++) {
320
- const p = allPatterns[i];
321
- if (p.subject?.termType === 'Variable' && incomingVars.has(p.subject.value)) {
322
- patternVars.set(p.subject.value, { patternIdx: i, field: 'subject' });
323
- }
324
- if (p.predicate?.termType === 'Variable' && incomingVars.has(p.predicate.value)) {
325
- patternVars.set(p.predicate.value, { patternIdx: i, field: 'predicate' });
326
- }
327
- if (p.object?.termType === 'Variable' && incomingVars.has(p.object.value)) {
328
- patternVars.set(p.object.value, { patternIdx: i, field: 'object' });
329
- }
330
- if (p.graph?.termType === 'Variable' && incomingVars.has(p.graph.value)) {
331
- patternVars.set(p.graph.value, { patternIdx: i, field: 'graph' });
332
- }
333
- }
334
- if (this.debug) {
335
- console.log(`[QuintQuerySource] Overlapping variables:`, [...patternVars.keys()]);
336
- }
337
- if (patternVars.size === 0) {
338
- // No overlapping variables - just execute normally and return cartesian product
339
- // This shouldn't happen in typical use cases
340
- const results = await this.executeQuery(operation);
341
- return this.cartesianJoin(incomingBindings, results);
342
- }
343
- // Use the first overlapping variable as the join key
344
- const [joinVarName, joinInfo] = [...patternVars.entries()][0];
345
- // Collect unique values for the join variable from incoming bindings
346
- const joinValues = new Set();
347
- for (const binding of incomingBindings) {
348
- const term = binding.get(dataFactory.variable(joinVarName));
349
- if (term) {
350
- joinValues.add(term.value);
351
- }
352
- }
353
- if (this.debug) {
354
- console.log(`[QuintQuerySource] Join variable: ?${joinVarName}, ${joinValues.size} unique values`);
355
- }
356
- // Build compound query with IN filter on join variable
357
- if (allPatterns.length > 1) {
358
- // Multiple patterns - use compound query
359
- return this.executeBindJoinCompound(allPatterns, filter, joinVarName, joinInfo.field, [...joinValues], incomingBindings);
360
- }
361
- else {
362
- // Single pattern - use simple query with IN filter
363
- return this.executeBindJoinSimple(pattern, filter, joinVarName, joinInfo.field, [...joinValues], incomingBindings);
364
- }
365
- }
366
- /**
367
- * Execute bind join for a single pattern using IN filter
368
- */
369
- async executeBindJoinSimple(pattern, filter, joinVarName, joinField, joinValues, incomingBindings) {
370
- const variables = (0, AlgebraUtils_1.extractVariables)(pattern);
371
- // Build pattern with IN filter for join values
372
- let pushdownFilters = {};
373
- if (filter) {
374
- const result = this.filterExtractor.extractPushdownFilters(filter, pattern);
375
- pushdownFilters = result.filters;
376
- }
377
- // Add IN filter for join values
378
- pushdownFilters[joinField] = {
379
- ...pushdownFilters[joinField],
380
- $in: joinValues,
381
- };
382
- const quintPattern = this.patternBuilder.buildQuintPattern(pattern, pushdownFilters);
383
- const quads = await this.store.get(quintPattern);
384
- const queryResults = this.quadsToBindings(quads, variables, pattern);
385
- if (this.debug) {
386
- console.log(`[QuintQuerySource] Bind join simple: ${queryResults.length} results from DB`);
387
- }
388
- // Join with incoming bindings
389
- return this.hashJoin(incomingBindings, queryResults, joinVarName);
390
- }
391
- /**
392
- * Execute bind join for multiple patterns using compound query
393
- */
394
- async executeBindJoinCompound(patterns, filter, joinVarName, joinField, joinValues, incomingBindings) {
395
- // Build QuintPattern for each pattern
396
- const quintPatterns = [];
397
- const filtersByPattern = this.distributeFiltersToPatterns(filter, patterns);
398
- for (let i = 0; i < patterns.length; i++) {
399
- const pattern = patterns[i];
400
- const patternFilters = filtersByPattern.get(i) || {};
401
- // Add IN filter for join values on the first pattern
402
- if (i === 0) {
403
- patternFilters[joinField] = {
404
- ...patternFilters[joinField],
405
- $in: joinValues,
406
- };
407
- }
408
- const quintPattern = this.patternBuilder.buildQuintPattern(pattern, patternFilters);
409
- quintPatterns.push(quintPattern);
410
- }
411
- // Build compound pattern
412
- const compound = {
413
- patterns: quintPatterns,
414
- joinOn: joinField,
415
- select: this.buildSelectForPatterns(patterns),
416
- };
417
- const results = await this.store.getCompound(compound);
418
- const queryResults = this.compoundResultsToBindings(results, patterns);
419
- if (this.debug) {
420
- console.log(`[QuintQuerySource] Bind join compound: ${queryResults.length} results from DB`);
421
- }
422
- // Join with incoming bindings
423
- return this.hashJoin(incomingBindings, queryResults, joinVarName);
424
- }
425
- /**
426
- * Hash join two binding sets on a common variable
427
- */
428
- hashJoin(left, right, joinVarName) {
429
- // Build hash table on right side
430
- const rightIndex = new Map();
431
- const joinVar = dataFactory.variable(joinVarName);
432
- for (const binding of right) {
433
- const term = binding.get(joinVar);
434
- if (term) {
435
- const key = term.value;
436
- if (!rightIndex.has(key)) {
437
- rightIndex.set(key, []);
438
- }
439
- rightIndex.get(key).push(binding);
440
- }
441
- }
442
- // Probe with left side
443
- const results = [];
444
- for (const leftBinding of left) {
445
- const term = leftBinding.get(joinVar);
446
- if (term) {
447
- const key = term.value;
448
- const matches = rightIndex.get(key);
449
- if (matches) {
450
- for (const rightBinding of matches) {
451
- // Merge bindings
452
- const merged = this.mergeBindings(leftBinding, rightBinding);
453
- if (merged) {
454
- results.push(merged);
455
- }
456
- }
457
- }
458
- }
459
- }
460
- return results;
461
- }
462
- /**
463
- * Merge two bindings, returning null if they conflict
464
- */
465
- mergeBindings(left, right) {
466
- const entries = [];
467
- // Add all from left
468
- for (const key of left.keys()) {
469
- const term = left.get(key);
470
- if (term) {
471
- entries.push([key, term]);
472
- }
473
- }
474
- // Add from right, checking for conflicts
475
- for (const key of right.keys()) {
476
- const rightTerm = right.get(key);
477
- const leftTerm = left.get(key);
478
- if (rightTerm) {
479
- if (leftTerm) {
480
- // Both have this variable - must match
481
- if (leftTerm.value !== rightTerm.value || leftTerm.termType !== rightTerm.termType) {
482
- return null; // Conflict
483
- }
484
- // Same value, already in entries
485
- }
486
- else {
487
- // Only right has it
488
- entries.push([key, rightTerm]);
489
- }
490
- }
491
- }
492
- return this.bindingsFactory.bindings(entries);
493
- }
494
- /**
495
- * Cartesian product of two binding sets
496
- */
497
- cartesianJoin(left, right) {
498
- const results = [];
499
- for (const l of left) {
500
- for (const r of right) {
501
- const merged = this.mergeBindings(l, r);
502
- if (merged) {
503
- results.push(merged);
504
- }
505
- }
506
- }
507
- return results;
508
- }
509
- /**
510
- * Execute OR branches with union semantics
511
- */
512
- async executeOrBranches(pattern, variables, orBranches, orNonPushdownBranches, queryOptions) {
513
- const seen = new Set();
514
- const results = [];
515
- // Execute each pushdownable branch
516
- for (const branchFilters of orBranches) {
517
- const quintPattern = this.patternBuilder.buildQuintPattern(pattern, branchFilters);
518
- const quads = await this.store.get(quintPattern, queryOptions);
519
- const bindings = this.quadsToBindings(quads, variables, pattern);
520
- for (const binding of bindings) {
521
- const key = this.expressionEvaluator.getBindingKey(binding);
522
- if (!seen.has(key)) {
523
- seen.add(key);
524
- results.push(binding);
525
- }
526
- }
527
- }
528
- // Handle non-pushdownable OR branches
529
- if (orNonPushdownBranches && orNonPushdownBranches.length > 0) {
530
- // Get base results without filter for in-memory evaluation
531
- const quintPattern = this.patternBuilder.buildBasePattern(pattern);
532
- const quads = await this.store.get(quintPattern, queryOptions);
533
- const candidates = this.quadsToBindings(quads, variables, pattern);
534
- // Evaluate each non-pushdownable branch
535
- for (const branchExpr of orNonPushdownBranches) {
536
- const branchResults = await this.expressionEvaluator.evaluateFilterTree(branchExpr, candidates, pattern);
537
- for (const binding of branchResults) {
538
- const key = this.expressionEvaluator.getBindingKey(binding);
539
- if (!seen.has(key)) {
540
- seen.add(key);
541
- results.push(binding);
542
- }
543
- }
544
- }
545
- }
546
- return results;
547
- }
548
- /**
549
- * Try to execute a compound query for multiple patterns joined by same subject
550
- * Returns null if compound query is not applicable
551
- */
552
- async tryCompoundQuery(patterns, filter, _operation) {
553
- // Check if all patterns share the same subject variable
554
- const subjectVars = patterns.map(p => p.subject?.termType === 'Variable' ? p.subject.value : null);
555
- const uniqueSubjectVars = [...new Set(subjectVars.filter(v => v !== null))];
556
- if (uniqueSubjectVars.length !== 1) {
557
- // Not all patterns share the same subject variable
558
- if (this.debug) {
559
- console.log(`[QuintQuerySource] Cannot use compound query: different subject variables`, subjectVars);
560
- }
561
- return null;
562
- }
563
- const joinVar = uniqueSubjectVars[0];
564
- if (this.debug) {
565
- console.log(`[QuintQuerySource] Using compound query with ${patterns.length} patterns, joined on ?${joinVar}`);
566
- }
567
- // Build QuintPattern for each pattern, including filter conditions
568
- const quintPatterns = [];
569
- const filtersByPattern = this.distributeFiltersToPatterns(filter, patterns);
570
- for (let i = 0; i < patterns.length; i++) {
571
- const pattern = patterns[i];
572
- const patternFilters = filtersByPattern.get(i) || {};
573
- const quintPattern = this.patternBuilder.buildQuintPattern(pattern, patternFilters);
574
- quintPatterns.push(quintPattern);
575
- }
576
- // Build compound pattern
577
- const compound = {
578
- patterns: quintPatterns,
579
- joinOn: 'subject',
580
- select: this.buildSelectForPatterns(patterns),
581
- };
582
- // Execute compound query
583
- const optimizeParams = this.getOptimizeParams();
584
- const queryOptions = {};
585
- if (optimizeParams?.limit) {
586
- queryOptions.limit = optimizeParams.limit + (optimizeParams.offset || 0);
587
- }
588
- const results = await this.store.getCompound(compound, queryOptions);
589
- // Convert CompoundResult to Bindings
590
- return this.compoundResultsToBindings(results, patterns);
591
- }
592
- /**
593
- * Execute multiple patterns individually and hash-join results on shared variables.
594
- * Used when compound query is not applicable (e.g. inverse patterns with different subject vars).
595
- */
596
- async executeMultiPatternJoin(patterns, filter = null) {
597
- if (!patterns || patterns.length < 2)
598
- return null;
599
- if (this.debug) {
600
- console.log(`[QuintQuerySource] executeMultiPatternJoin: ${patterns.length} patterns, hasFilter=${!!filter}`);
601
- }
602
- // If there's a FILTER like ?subject = <uri>, extract the bound value
603
- // so we can push it down to individual pattern queries
604
- const filterBindings = this.extractFilterBindings(filter);
605
- // Execute each pattern individually and collect bindings
606
- const patternBindings = [];
607
- for (let i = 0; i < patterns.length; i++) {
608
- const p = patterns[i];
609
- const vars = (0, AlgebraUtils_1.extractVariables)(p);
610
- // Try to apply filter bindings to this pattern
611
- let quintPattern;
612
- const pushdown = {};
613
- if (filterBindings) {
614
- // Check if any variable in this pattern matches a filter binding
615
- for (const [varName, termValue] of Object.entries(filterBindings)) {
616
- if (p.subject?.termType === 'Variable' && p.subject.value === varName) {
617
- pushdown['subject'] = { $eq: termValue };
618
- }
619
- else if (p.object?.termType === 'Variable' && p.object.value === varName) {
620
- pushdown['object'] = { $eq: termValue };
621
- }
622
- }
623
- }
624
- if (Object.keys(pushdown).length > 0) {
625
- quintPattern = this.patternBuilder.buildQuintPattern(p, pushdown);
626
- }
627
- else {
628
- quintPattern = this.patternBuilder.buildBasePattern(p);
629
- }
630
- const quads = await this.store.get(quintPattern);
631
- const bindings = this.quadsToBindings(quads, vars, p);
632
- if (this.debug) {
633
- console.log(`[QuintQuerySource] Pattern ${i}: ${bindings.length} results, vars=[${vars.map(v => v.value)}]`);
634
- }
635
- patternBindings.push(bindings);
636
- }
637
- // Iteratively hash-join all pattern results
638
- let result = patternBindings[0];
639
- for (let i = 1; i < patternBindings.length; i++) {
640
- result = this.hashJoinBindings(result, patternBindings[i]);
641
- if (this.debug) {
642
- console.log(`[QuintQuerySource] After join with pattern ${i}: ${result.length} results`);
643
- }
644
- if (result.length === 0)
645
- break;
646
- }
647
- // Apply remaining in-memory filter if needed
648
- if (filter && result.length > 0) {
649
- result = await this.expressionEvaluator.evaluateFilterTree(filter, result, patterns[0]);
650
- }
651
- return result;
652
- }
653
- /**
654
- * Extract simple equality bindings from a FILTER expression.
655
- * E.g. FILTER(?subject = <uri>) -> { subject: "uri" }
656
- */
657
- extractFilterBindings(filter) {
658
- if (!filter)
659
- return null;
660
- const bindings = {};
661
- const extract = (expr) => {
662
- if (!expr)
663
- return;
664
- if (expr.expressionType === 'operator' && expr.operator === '=') {
665
- const args = expr.args || [];
666
- if (args.length === 2) {
667
- let varName = null;
668
- let value = null;
669
- for (const arg of args) {
670
- if (arg.expressionType === 'term' && arg.term?.termType === 'Variable') {
671
- varName = arg.term.value;
672
- }
673
- else if (arg.expressionType === 'term' && arg.term?.termType === 'NamedNode') {
674
- value = arg.term.value;
675
- }
676
- }
677
- if (varName && value) {
678
- bindings[varName] = value;
679
- }
680
- }
681
- }
682
- else if (expr.expressionType === 'operator' && expr.operator === '&&') {
683
- for (const arg of (expr.args || [])) {
684
- extract(arg);
685
- }
686
- }
687
- };
688
- extract(filter);
689
- return Object.keys(bindings).length > 0 ? bindings : null;
690
- }
691
- /**
692
- * Hash-join two binding arrays on all shared variables.
693
- */
694
- hashJoinBindings(left, right) {
695
- if (left.length === 0 || right.length === 0)
696
- return [];
697
- // Find shared variables
698
- const leftVars = new Set();
699
- for (const k of left[0].keys())
700
- leftVars.add(k.value);
701
- const rightVars = new Set();
702
- for (const k of right[0].keys())
703
- rightVars.add(k.value);
704
- const sharedVars = [...leftVars].filter(v => rightVars.has(v));
705
- if (sharedVars.length === 0) {
706
- // No shared variables — cartesian product
707
- return this.cartesianJoin(left, right);
708
- }
709
- // Build hash index on right side using shared vars as key
710
- const rightIndex = new Map();
711
- for (const binding of right) {
712
- const key = sharedVars.map(v => {
713
- const t = binding.get(dataFactory.variable(v));
714
- return t ? t.value : '';
715
- }).join('\0');
716
- if (!rightIndex.has(key))
717
- rightIndex.set(key, []);
718
- rightIndex.get(key).push(binding);
719
- }
720
- // Probe with left side
721
- const results = [];
722
- for (const leftBinding of left) {
723
- const key = sharedVars.map(v => {
724
- const t = leftBinding.get(dataFactory.variable(v));
725
- return t ? t.value : '';
726
- }).join('\0');
727
- const matches = rightIndex.get(key);
728
- if (matches) {
729
- for (const rightBinding of matches) {
730
- const merged = this.mergeBindings(leftBinding, rightBinding);
731
- if (merged)
732
- results.push(merged);
733
- }
734
- }
735
- }
736
- return results;
737
- }
738
- /**
739
- * Distribute filter conditions to their respective patterns
740
- * Returns a map of pattern index -> PushdownFilters
741
- */
742
- distributeFiltersToPatterns(filter, patterns) {
743
- const result = new Map();
744
- if (!filter)
745
- return result;
746
- // Build a map of variable name to pattern index
747
- const varToPatternIdx = new Map();
748
- for (let i = 0; i < patterns.length; i++) {
749
- const p = patterns[i];
750
- if (p.object?.termType === 'Variable') {
751
- varToPatternIdx.set(p.object.value, i);
752
- }
753
- }
754
- // Extract filters and distribute them
755
- for (let i = 0; i < patterns.length; i++) {
756
- const patternResult = this.filterExtractor.extractPushdownFilters(filter, patterns[i]);
757
- if (Object.keys(patternResult.filters).length > 0) {
758
- result.set(i, patternResult.filters);
759
- }
760
- }
761
- return result;
762
- }
763
- /**
764
- * Build SELECT clause config for patterns
765
- */
766
- buildSelectForPatterns(patterns) {
767
- const select = [];
768
- for (let i = 0; i < patterns.length; i++) {
769
- const p = patterns[i];
770
- // Select object if it's a variable
771
- if (p.object?.termType === 'Variable') {
772
- select.push({
773
- pattern: i,
774
- field: 'object',
775
- alias: `p${i}_${p.object.value}`,
776
- });
777
- }
778
- // Select predicate if it's a variable
779
- if (p.predicate?.termType === 'Variable') {
780
- select.push({
781
- pattern: i,
782
- field: 'predicate',
783
- alias: `p${i}_${p.predicate.value}`,
784
- });
785
- }
786
- // Select graph if it's a variable
787
- if (p.graph?.termType === 'Variable') {
788
- select.push({
789
- pattern: i,
790
- field: 'graph',
791
- alias: `p${i}_${p.graph.value}`,
792
- });
793
- }
794
- }
795
- return select;
796
- }
797
- /**
798
- * Convert CompoundResult array to Bindings array
799
- */
800
- compoundResultsToBindings(results, patterns) {
801
- // Collect all variables from all patterns
802
- const variables = [];
803
- const varNames = new Set();
804
- for (const p of patterns) {
805
- if (p.subject?.termType === 'Variable' && !varNames.has(p.subject.value)) {
806
- variables.push(p.subject);
807
- varNames.add(p.subject.value);
808
- }
809
- if (p.predicate?.termType === 'Variable' && !varNames.has(p.predicate.value)) {
810
- variables.push(p.predicate);
811
- varNames.add(p.predicate.value);
812
- }
813
- if (p.object?.termType === 'Variable' && !varNames.has(p.object.value)) {
814
- variables.push(p.object);
815
- varNames.add(p.object.value);
816
- }
817
- if (p.graph?.termType === 'Variable' && !varNames.has(p.graph.value)) {
818
- variables.push(p.graph);
819
- varNames.add(p.graph.value);
820
- }
821
- }
822
- return results.map(result => {
823
- const entries = [];
824
- for (const v of variables) {
825
- const varName = v.value;
826
- // Check if this is the join variable (subject)
827
- if (patterns[0].subject?.termType === 'Variable' &&
828
- patterns[0].subject.value === varName) {
829
- // Use joinValue for subject
830
- const term = dataFactory.namedNode(result.joinValue);
831
- entries.push([v, term]);
832
- continue;
833
- }
834
- // Look for the variable in bindings
835
- for (let i = 0; i < patterns.length; i++) {
836
- const p = patterns[i];
837
- if (p.object?.termType === 'Variable' && p.object.value === varName) {
838
- const alias = `p${i}_${varName}`;
839
- const value = result.bindings[alias];
840
- if (value !== undefined) {
841
- // Deserialize the value
842
- const term = this.deserializeValue(value);
843
- entries.push([v, term]);
844
- break;
845
- }
846
- }
847
- if (p.predicate?.termType === 'Variable' && p.predicate.value === varName) {
848
- const alias = `p${i}_${varName}`;
849
- const value = result.bindings[alias];
850
- if (value !== undefined) {
851
- const term = dataFactory.namedNode(value);
852
- entries.push([v, term]);
853
- break;
854
- }
855
- }
856
- if (p.graph?.termType === 'Variable' && p.graph.value === varName) {
857
- const alias = `p${i}_${varName}`;
858
- const value = result.bindings[alias];
859
- if (value !== undefined) {
860
- const term = dataFactory.namedNode(value);
861
- entries.push([v, term]);
862
- break;
863
- }
864
- }
865
- }
866
- }
867
- return this.bindingsFactory.bindings(entries);
868
- });
869
- }
870
- /**
871
- * Deserialize a value from storage format to RDF Term
872
- * Uses the same deserialization logic as QuintStore
873
- */
874
- deserializeValue(value) {
875
- return (0, serialization_1.deserializeObject)(value);
876
- }
877
- /**
878
- * Convert quads to bindings based on pattern variables
879
- */
880
- quadsToBindings(quads, variables, pattern) {
881
- if (this.debug) {
882
- console.log(`[QuintQuerySource] quadsToBindings: ${quads.length} quads, ${variables.length} variables`);
883
- console.log(`[QuintQuerySource] Variables:`, variables.map(v => v.value));
884
- console.log(`[QuintQuerySource] Pattern:`, {
885
- subject: pattern.subject?.termType === 'Variable' ? `?${pattern.subject.value}` : pattern.subject?.value,
886
- predicate: pattern.predicate?.termType === 'Variable' ? `?${pattern.predicate.value}` : pattern.predicate?.value,
887
- object: pattern.object?.termType === 'Variable' ? `?${pattern.object.value}` : pattern.object?.value,
888
- graph: pattern.graph?.termType === 'Variable' ? `?${pattern.graph.value}` : pattern.graph?.value || pattern.graph?.termType,
889
- });
890
- }
891
- return quads.map(quad => {
892
- const entries = [];
893
- for (const v of variables) {
894
- const term = this.getTermForVariable(v, quad, pattern);
895
- if (term) {
896
- entries.push([v, term]);
897
- }
898
- }
899
- if (this.debug && entries.length !== variables.length) {
900
- console.log(`[QuintQuerySource] Warning: only ${entries.length} of ${variables.length} variables bound`);
901
- }
902
- return this.bindingsFactory.bindings(entries);
903
- });
904
- }
905
- /**
906
- * Get the term from quad that matches the variable position in pattern
907
- */
908
- getTermForVariable(variable, quad, pattern) {
909
- const varName = variable.value;
910
- // Check which position in the pattern this variable is in
911
- if (pattern.subject?.termType === 'Variable' && pattern.subject.value === varName) {
912
- return quad.subject;
913
- }
914
- if (pattern.predicate?.termType === 'Variable' && pattern.predicate.value === varName) {
915
- return quad.predicate;
916
- }
917
- if (pattern.object?.termType === 'Variable' && pattern.object.value === varName) {
918
- return quad.object;
919
- }
920
- if (pattern.graph?.termType === 'Variable' && pattern.graph.value === varName) {
921
- return quad.graph;
922
- }
923
- return null;
924
- }
925
- /**
926
- * Extract BGP pattern and filter from operation
927
- * Returns either a single pattern or multiple patterns (from BGP or JOIN)
928
- */
929
- extractPatternAndFilter(operation) {
930
- let pattern = null;
931
- let patterns;
932
- let filter = null;
933
- // Walk the algebra tree to find pattern(s) and filter
934
- sparqlalgebrajs_1.Util.recurseOperation(operation, {
935
- [sparqlalgebrajs_1.Algebra.types.JOIN]: (op) => {
936
- // JOIN contains multiple patterns - extract them all
937
- if (op.input && op.input.length > 0) {
938
- const extractedPatterns = [];
939
- for (const input of op.input) {
940
- if (input.type === sparqlalgebrajs_1.Algebra.types.PATTERN) {
941
- extractedPatterns.push(input);
942
- }
943
- else {
944
- // Recurse into nested operation to find patterns
945
- const nested = this.extractPatternAndFilter(input);
946
- if (nested.patterns) {
947
- extractedPatterns.push(...nested.patterns);
948
- }
949
- else if (nested.pattern) {
950
- extractedPatterns.push(nested.pattern);
951
- }
952
- // Also collect filter from nested operations
953
- if (nested.filter && !filter) {
954
- filter = nested.filter;
955
- }
956
- }
957
- }
958
- if (extractedPatterns.length > 0) {
959
- patterns = extractedPatterns;
960
- if (!pattern) {
961
- pattern = patterns[0];
962
- }
963
- }
964
- }
965
- return false; // Don't recurse further
966
- },
967
- [sparqlalgebrajs_1.Algebra.types.BGP]: (op) => {
968
- // BGP contains multiple patterns - this is what we want for compound queries
969
- if (op.patterns && op.patterns.length > 0) {
970
- patterns = op.patterns;
971
- if (!pattern) {
972
- pattern = patterns[0];
973
- }
974
- }
975
- return false; // Don't recurse into individual patterns
976
- },
977
- [sparqlalgebrajs_1.Algebra.types.PATTERN]: (op) => {
978
- if (!pattern)
979
- pattern = op;
980
- return false;
981
- },
982
- [sparqlalgebrajs_1.Algebra.types.FILTER]: (op) => {
983
- filter = op.expression;
984
- return true; // Continue to find pattern inside filter
985
- },
986
- });
987
- if (!pattern) {
988
- // Create empty pattern if none found
989
- pattern = {
990
- type: 'pattern',
991
- subject: dataFactory.variable('s'),
992
- predicate: dataFactory.variable('p'),
993
- object: dataFactory.variable('o'),
994
- graph: dataFactory.defaultGraph(),
995
- };
996
- }
997
- return { pattern, patterns, filter };
998
- }
999
- /**
1000
- * Get variables from operation
1001
- */
1002
- getVariablesFromOperation(operation) {
1003
- const { pattern, patterns } = this.extractPatternAndFilter(operation);
1004
- if (patterns && patterns.length > 1) {
1005
- // Collect variables from all patterns
1006
- const allVars = [];
1007
- const seen = new Set();
1008
- for (const p of patterns) {
1009
- for (const v of (0, AlgebraUtils_1.extractVariables)(p)) {
1010
- if (!seen.has(v.value)) {
1011
- seen.add(v.value);
1012
- allVars.push(v);
1013
- }
1014
- }
1015
- }
1016
- return allVars;
1017
- }
1018
- return (0, AlgebraUtils_1.extractVariables)(pattern);
1019
- }
1020
- // ============================================================
1021
- // Required IQuerySource Methods
1022
- // ============================================================
1023
- queryQuads(operation, _context) {
1024
- const { pattern } = this.extractPatternAndFilter(operation);
1025
- const quintPattern = this.patternBuilder.buildBasePattern(pattern);
1026
- const resultIterator = (0, asynciterator_1.wrap)(this.store.get(quintPattern));
1027
- resultIterator.setProperty('metadata', {
1028
- state: { invalidate: () => { }, invalid: false, addInvalidateListener: () => { } },
1029
- cardinality: { type: 'estimate', value: Number.POSITIVE_INFINITY },
1030
- });
1031
- return resultIterator;
1032
- }
1033
- async queryBoolean(operation, _context) {
1034
- const { pattern } = this.extractPatternAndFilter(operation.input);
1035
- const quintPattern = this.patternBuilder.buildBasePattern(pattern);
1036
- const results = await this.store.get(quintPattern, { limit: 1 });
1037
- return results.length > 0;
1038
- }
1039
- queryVoid(_operation, _context) {
1040
- throw new Error('queryVoid is not implemented');
1041
- }
1042
- /**
1043
- * 在 pattern 中查找变量绑定到哪个位置
1044
- *
1045
- * 例如:{ ?s <http://schema.org/name> ?name }
1046
- * - ?s 绑定到 subject
1047
- * - ?name 绑定到 object
1048
- */
1049
- findVariableBinding(varName, pattern) {
1050
- if (pattern.subject?.termType === 'Variable' && pattern.subject.value === varName) {
1051
- return 'subject';
1052
- }
1053
- if (pattern.predicate?.termType === 'Variable' && pattern.predicate.value === varName) {
1054
- return 'predicate';
1055
- }
1056
- if (pattern.object?.termType === 'Variable' && pattern.object.value === varName) {
1057
- return 'object';
1058
- }
1059
- if (pattern.graph?.termType === 'Variable' && pattern.graph.value === varName) {
1060
- return 'graph';
1061
- }
1062
- return null;
1063
- }
1064
- toString() {
1065
- return `QuintQuerySource(${this.store.constructor.name})`;
1066
- }
1067
- }
1068
- exports.QuintQuerySource = QuintQuerySource;
1069
- //# sourceMappingURL=QuintQuerySource.js.map