@wazootech/worlds-sdk 0.11.5 → 0.11.6

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.
@@ -1,5 +1,5 @@
1
1
  import { DataFactory } from "@wazootech/sparql-engine/data-model";
2
- import { h as hashQuad } from "./quad-store-oBgXOONP.js";
2
+ import { h as hashQuad } from "./quad-store-CT8YQQky.js";
3
3
  // src/client/search-index/build-search-result-id.ts
4
4
  const { literal, namedNode, quad: createQuad, defaultGraph } = DataFactory;
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { _ as isTextualLiteral, h as hashQuad } from "./quad-store-oBgXOONP.js";
1
+ import { _ as isTextualLiteral, h as hashQuad } from "./quad-store-CT8YQQky.js";
2
2
  // src/client/search-index/quad-chunker/chunk-quads.ts
3
3
  /**
4
4
  * chunkQuads filters literal payload candidates from a collection of RDF Quads
@@ -1,6 +1,6 @@
1
- import { $ as ImportRequest, X as ExportRequest, Z as ExportResponse, ct as ProvenanceQueryResponse, ot as ProvenanceQueryHandler, st as ProvenanceQueryRequest, tt as QuadStoreInterface } from "./mod-CH7Hc3EE.js";
2
- import { c as SparqlRequest, i as SparqlResponse, s as SparqlEngineInterface } from "./mod-C_Is4DOx.js";
3
- import { C as ReindexResponse, D as SearchRequest, O as SearchResponse, S as ReindexRequest, w as SearchIndexInterface } from "./mod-CfzcRVcL.js";
1
+ import { $ as ImportRequest, X as ExportRequest, Z as ExportResponse, ct as ProvenanceQueryResponse, ot as ProvenanceQueryHandler, st as ProvenanceQueryRequest, tt as QuadStoreInterface } from "./mod-aUvsYiTJ.js";
2
+ import { c as SparqlRequest, i as SparqlResponse, s as SparqlEngineInterface } from "./mod-Q0-ml33V.js";
3
+ import { C as ReindexResponse, D as SearchRequest, O as SearchResponse, S as ReindexRequest, w as SearchIndexInterface } from "./mod-Du9mzmwt.js";
4
4
  /**
5
5
  * WorldsSdkInterface is the public contract for the Worlds SDK.
6
6
  */
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { t as EmbeddingService } from "./embedding-service-DebRMVmn.js";
2
2
  import { t as FakeEmbeddingService } from "./mod-Dmrdrb03.js";
3
- import { n as WorldsSdkInterface, r as WorldsSdkOptions, t as WorldsSdk } from "./client-B1oktOm6.js";
4
- import { $ as ImportRequest, A as fromRdfjsTerm, B as QuadFilter, C as getFormat, D as fromRdfjsQuad, E as Quad, F as HexastoreIndexDescriptor, G as isImportCommit, H as PatchableStore, I as hashQuad, J as RdfjsStoreLike, K as isReplaceImportCommit, L as hashQuads, M as QuadRowReader, N as quadFromRow, O as toRdfjsQuad, P as HEXASTORE_INDEXES, Q as ImportMode, R as isTextualLiteral, S as exportQuadsResponse, T as parseQuads, U as TransactionContext, V as filterQuads, W as deduplicateBuffers, X as ExportRequest, Y as Patch, Z as ExportResponse, _ as createRdfjsStoreCommitHandler, a as preparePatch, at as ProvenanceListQuery, b as awaitDrainRemoveMatches, c as TransactionalRdfjsStore, ct as ProvenanceQueryResponse, d as RdfjsExportSource, dt as ProvenanceRecordInput, et as ImportSource, f as exportFromRdfjsStore, ft as ProvenanceRecordType, g as TransactionOptions, h as Transaction, i as computeNovelQuads, it as ProvenanceHistory, j as toRdfjsTerm, k as Term, l as TransactionalRdfjsStoreOptions, lt as ProvenanceQueryResult, m as MatchFunction, n as PreparedPatch, nt as InMemoryProvenanceStore, o as selectNovelQuads, ot as ProvenanceQueryHandler, p as importViaTransaction, pt as ProvenanceStore, q as RdfjsEventSource, r as SelectNovelQuadsOptions, rt as ImportProvenance, s as ReadonlyStore, st as ProvenanceQueryRequest, t as NovelQuads, tt as QuadStoreInterface, u as ImportViaTransactionOptions, ut as ProvenanceRecord, v as FORMATS, w as materializeImportQuads, x as collectQuadsFromStream, y as RdfFormat, z as QuadCriteria } from "./mod-CH7Hc3EE.js";
5
- import { a as SparqlSelectResults, c as SparqlRequest, i as SparqlResponse, n as SparqlBinding, o as SparqlValue, r as SparqlConstructResults, s as SparqlEngineInterface, t as SparqlAskResults } from "./mod-C_Is4DOx.js";
6
- import { A as DEFAULT_RRF_K, C as ReindexResponse, D as SearchRequest, E as SearchMode, M as normalizeRrfScore, O as SearchResponse, S as ReindexRequest, T as SearchIndexOnImport, _ as extractRdfLocalLabel, a as RebuildSearchIndexResult, b as BuildSearchResultIdOptions, c as PreparedCommit, d as PlanSearchIndexingOptions, f as SearchIndexPlan, g as buildChunkFtsValue, h as DEFAULT_LABEL_PREDICATES, i as RebuildSearchIndexOptions, j as SearchScoreType, k as SearchResult, l as prepareCommit, m as BuildChunkFtsValueOptions, n as RebuildPage, o as rebuildSearchIndex, p as planSearchIndexing, r as RebuildScope, s as PrepareCommitOptions, t as ChunkRebuildDriver, u as DEFAULT_SEARCH_INDEX_ON_IMPORT, v as formatPredicatePhrase, w as SearchIndexInterface, x as buildSearchResultId, y as resolveLabelPredicates } from "./mod-CfzcRVcL.js";
3
+ import { n as WorldsSdkInterface, r as WorldsSdkOptions, t as WorldsSdk } from "./client-DHhpNpi6.js";
4
+ import { $ as ImportRequest, A as fromRdfjsTerm, B as QuadFilter, C as getFormat, D as fromRdfjsQuad, E as Quad, F as HexastoreIndexDescriptor, G as isImportCommit, H as PatchableStore, I as hashQuad, J as RdfjsStoreLike, K as isReplaceImportCommit, L as hashQuads, M as QuadRowReader, N as quadFromRow, O as toRdfjsQuad, P as HEXASTORE_INDEXES, Q as ImportMode, R as isTextualLiteral, S as exportQuadsResponse, T as parseQuads, U as TransactionContext, V as filterQuads, W as deduplicateBuffers, X as ExportRequest, Y as Patch, Z as ExportResponse, _ as createRdfjsStoreCommitHandler, a as preparePatch, at as ProvenanceListQuery, b as awaitDrainRemoveMatches, c as TransactionalRdfjsStore, ct as ProvenanceQueryResponse, d as RdfjsExportSource, dt as ProvenanceRecordInput, et as ImportSource, f as exportFromRdfjsStore, ft as ProvenanceRecordType, g as TransactionOptions, h as Transaction, i as computeNovelQuads, it as ProvenanceHistory, j as toRdfjsTerm, k as Term, l as TransactionalRdfjsStoreOptions, lt as ProvenanceQueryResult, m as MatchFunction, n as PreparedPatch, nt as InMemoryProvenanceStore, o as selectNovelQuads, ot as ProvenanceQueryHandler, p as importViaTransaction, pt as ProvenanceStore, q as RdfjsEventSource, r as SelectNovelQuadsOptions, rt as ImportProvenance, s as ReadonlyStore, st as ProvenanceQueryRequest, t as NovelQuads, tt as QuadStoreInterface, u as ImportViaTransactionOptions, ut as ProvenanceRecord, v as FORMATS, w as materializeImportQuads, x as collectQuadsFromStream, y as RdfFormat, z as QuadCriteria } from "./mod-aUvsYiTJ.js";
5
+ import { a as SparqlSelectResults, c as SparqlRequest, i as SparqlResponse, n as SparqlBinding, o as SparqlValue, r as SparqlConstructResults, s as SparqlEngineInterface, t as SparqlAskResults } from "./mod-Q0-ml33V.js";
6
+ import { A as DEFAULT_RRF_K, C as ReindexResponse, D as SearchRequest, E as SearchMode, M as normalizeRrfScore, O as SearchResponse, S as ReindexRequest, T as SearchIndexOnImport, _ as extractRdfLocalLabel, a as RebuildSearchIndexResult, b as BuildSearchResultIdOptions, c as PreparedCommit, d as PlanSearchIndexingOptions, f as SearchIndexPlan, g as buildChunkFtsValue, h as DEFAULT_LABEL_PREDICATES, i as RebuildSearchIndexOptions, j as SearchScoreType, k as SearchResult, l as prepareCommit, m as BuildChunkFtsValueOptions, n as RebuildPage, o as rebuildSearchIndex, p as planSearchIndexing, r as RebuildScope, s as PrepareCommitOptions, t as ChunkRebuildDriver, u as DEFAULT_SEARCH_INDEX_ON_IMPORT, v as formatPredicatePhrase, w as SearchIndexInterface, x as buildSearchResultId, y as resolveLabelPredicates } from "./mod-Du9mzmwt.js";
7
7
  import { a as ChunkRowPayload, c as chunkQuads, i as chunkAndEmbedQuads, n as ChunkAndEmbedResult, o as Document, r as EmbeddedChunk, s as TextSplitterInterface, t as ChunkAndEmbedOptions } from "./mod-CHiiyEER.js";
8
8
  export { BuildChunkFtsValueOptions, BuildSearchResultIdOptions, ChunkAndEmbedOptions, ChunkAndEmbedResult, ChunkRebuildDriver, ChunkRowPayload, DEFAULT_LABEL_PREDICATES, DEFAULT_RRF_K, DEFAULT_SEARCH_INDEX_ON_IMPORT, Document, EmbeddedChunk, EmbeddingService, ExportRequest, ExportResponse, FORMATS, FakeEmbeddingService, HEXASTORE_INDEXES, HexastoreIndexDescriptor, ImportMode, ImportProvenance, ImportRequest, ImportSource, ImportViaTransactionOptions, InMemoryProvenanceStore, MatchFunction, NovelQuads, Patch, PatchableStore, PlanSearchIndexingOptions, PrepareCommitOptions, PreparedCommit, PreparedPatch, ProvenanceHistory, ProvenanceListQuery, ProvenanceQueryHandler, ProvenanceQueryRequest, ProvenanceQueryResponse, ProvenanceQueryResult, ProvenanceRecord, ProvenanceRecordInput, ProvenanceRecordType, ProvenanceStore, Quad, QuadCriteria, QuadFilter, QuadRowReader, QuadStoreInterface, RdfFormat, RdfjsEventSource, RdfjsExportSource, RdfjsStoreLike, ReadonlyStore, RebuildPage, RebuildScope, RebuildSearchIndexOptions, RebuildSearchIndexResult, ReindexRequest, ReindexResponse, SearchIndexInterface, SearchIndexOnImport, SearchIndexPlan, SearchMode, SearchRequest, SearchResponse, SearchResult, SearchScoreType, SelectNovelQuadsOptions, type SparqlAskResults, type SparqlBinding, type SparqlConstructResults, type SparqlEngineInterface, type SparqlRequest, type SparqlResponse, type SparqlSelectResults, type SparqlValue, Term, TextSplitterInterface, Transaction, TransactionContext, TransactionOptions, TransactionalRdfjsStore, TransactionalRdfjsStoreOptions, WorldsSdk, WorldsSdkInterface, WorldsSdkOptions, awaitDrainRemoveMatches, buildChunkFtsValue, buildSearchResultId, chunkAndEmbedQuads, chunkQuads, collectQuadsFromStream, computeNovelQuads, createRdfjsStoreCommitHandler, deduplicateBuffers, exportFromRdfjsStore, exportQuadsResponse, extractRdfLocalLabel, filterQuads, formatPredicatePhrase, fromRdfjsQuad, fromRdfjsTerm, getFormat, hashQuad, hashQuads, importViaTransaction, isImportCommit, isReplaceImportCommit, isTextualLiteral, materializeImportQuads, normalizeRrfScore, parseQuads, planSearchIndexing, prepareCommit, preparePatch, quadFromRow, rebuildSearchIndex, resolveLabelPredicates, selectNovelQuads, toRdfjsQuad, toRdfjsTerm };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { t as WorldsSdk } from "./client-BWh0UAM0.js";
2
- import { S as InMemoryProvenanceStore, _ as isTextualLiteral, a as Transaction, b as isImportCommit, c as importViaTransaction, d as quadFromRow, f as fromRdfjsTerm, g as hashQuads, h as hashQuad, i as TransactionalRdfjsStore, l as fromRdfjsQuad, m as HEXASTORE_INDEXES, n as preparePatch, o as createRdfjsStoreCommitHandler, p as toRdfjsTerm, r as selectNovelQuads, s as exportFromRdfjsStore, t as computeNovelQuads, u as toRdfjsQuad, v as filterQuads, x as isReplaceImportCommit, y as deduplicateBuffers } from "./quad-store-oBgXOONP.js";
2
+ import { S as InMemoryProvenanceStore, _ as isTextualLiteral, a as Transaction, b as isImportCommit, c as importViaTransaction, d as quadFromRow, f as fromRdfjsTerm, g as hashQuads, h as hashQuad, i as TransactionalRdfjsStore, l as fromRdfjsQuad, m as HEXASTORE_INDEXES, n as preparePatch, o as createRdfjsStoreCommitHandler, p as toRdfjsTerm, r as selectNovelQuads, s as exportFromRdfjsStore, t as computeNovelQuads, u as toRdfjsQuad, v as filterQuads, x as isReplaceImportCommit, y as deduplicateBuffers } from "./quad-store-CT8YQQky.js";
3
3
  import { a as getFormat, i as exportQuadsResponse, n as awaitDrainRemoveMatches, o as materializeImportQuads, r as collectQuadsFromStream, s as parseQuads, t as FORMATS } from "./rdf-formats-C2znopLM.js";
4
- import { t as buildSearchResultId } from "./build-search-result-id-DPlgkWyi.js";
4
+ import { t as buildSearchResultId } from "./build-search-result-id-owYEv-UZ.js";
5
5
  import { DEFAULT_LABEL_PREDICATES, DEFAULT_RRF_K, DEFAULT_SEARCH_INDEX_ON_IMPORT, buildChunkFtsValue, extractRdfLocalLabel, formatPredicatePhrase, normalizeRrfScore, planSearchIndexing, prepareCommit, rebuildSearchIndex, resolveLabelPredicates } from "./search-index.js";
6
- import { n as chunkQuads, t as chunkAndEmbedQuads } from "./chunk-and-embed-BlB2v4-2.js";
6
+ import { n as chunkQuads, t as chunkAndEmbedQuads } from "./chunk-and-embed-CNYO49kB.js";
7
7
  import { FakeEmbeddingService } from "./embedding-service.js";
8
8
  import "./quad-chunker.js";
9
9
  export { DEFAULT_LABEL_PREDICATES, DEFAULT_RRF_K, DEFAULT_SEARCH_INDEX_ON_IMPORT, FORMATS, FakeEmbeddingService, HEXASTORE_INDEXES, InMemoryProvenanceStore, Transaction, TransactionalRdfjsStore, WorldsSdk, awaitDrainRemoveMatches, buildChunkFtsValue, buildSearchResultId, chunkAndEmbedQuads, chunkQuads, collectQuadsFromStream, computeNovelQuads, createRdfjsStoreCommitHandler, deduplicateBuffers, exportFromRdfjsStore, exportQuadsResponse, extractRdfLocalLabel, filterQuads, formatPredicatePhrase, fromRdfjsQuad, fromRdfjsTerm, getFormat, hashQuad, hashQuads, importViaTransaction, isImportCommit, isReplaceImportCommit, isTextualLiteral, materializeImportQuads, normalizeRrfScore, parseQuads, planSearchIndexing, prepareCommit, preparePatch, quadFromRow, rebuildSearchIndex, resolveLabelPredicates, selectNovelQuads, toRdfjsQuad, toRdfjsTerm };
package/dist/memory.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * store), so the @wazootech/worlds-sdk/testing harness and every backend's phase-4
7
7
  * parity suite can run against a zero-dependency in-memory reference.
8
8
  */
9
- import { t as WorldsSdk } from "./client-B1oktOm6.js";
9
+ import { t as WorldsSdk } from "./client-DHhpNpi6.js";
10
10
  /**
11
11
  * createMemoryWorldsSdk builds a portable in-memory WorldsSdk backed by the Wazoo
12
12
  * engine's MemoryStore (the in-memory baseline, per the durable-backend map's
package/dist/memory.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as WorldsSdk } from "./client-BWh0UAM0.js";
2
- import { r as RdfjsSearchIndex, t as RdfjsQuadStore } from "./rdfjs-DodYvbzF.js";
2
+ import { r as RdfjsSearchIndex, t as RdfjsQuadStore } from "./rdfjs-CN2lccto.js";
3
3
  import { MemoryStore, WazooSparqlEngine } from "@wazootech/sparql-engine";
4
4
  // src/memory/create-memory-sdk.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { B as QuadFilter, U as TransactionContext, Y as Patch, n as PreparedPatch, t as NovelQuads } from "./mod-CH7Hc3EE.js";
1
+ import { B as QuadFilter, U as TransactionContext, Y as Patch, n as PreparedPatch, t as NovelQuads } from "./mod-aUvsYiTJ.js";
2
2
  import { a as ChunkRowPayload, r as EmbeddedChunk, t as ChunkAndEmbedOptions } from "./mod-CHiiyEER.js";
3
3
  import * as rdfjs from "@rdfjs/types";
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { SparqlAskResults, SparqlBinding, SparqlConstructResults, SparqlRequest as SparqlRequest$1, SparqlResponse, SparqlResponse as SparqlResponse$1, SparqlSelectResults, SparqlValue } from "@wazootech/sparql-engine";
2
- import { rt as ImportProvenance } from "./mod-CH7Hc3EE.js";
2
+ import { rt as ImportProvenance } from "./mod-aUvsYiTJ.js";
3
3
  /**
4
4
  * SparqlRequest is the engine's request plus what the SDK needs to say about an
5
5
  * update.
@@ -273,6 +273,10 @@ declare function isImportCommit(context?: TransactionContext): boolean;
273
273
  declare function isReplaceImportCommit(context?: TransactionContext): boolean;
274
274
  /**
275
275
  * deduplicateBuffers removes quads that appear in both insert and delete buffers.
276
+ *
277
+ * @deprecated The two buffers don't say which operation came last, so this can
278
+ * lose a delete or an insert. Transaction keeps the last operation on each quad
279
+ * and no longer calls this function.
276
280
  */
277
281
  declare function deduplicateBuffers(insertBuffer: rdfjs.Quad[], deleteBuffer: rdfjs.Quad[]): void;
278
282
  /**
@@ -462,20 +466,21 @@ type MatchFunction = (subject?: rdfjs.Term | null, predicate?: rdfjs.Term | null
462
466
  * TransactionOptions configures the handlers used when a transaction commits.
463
467
  */
464
468
  interface TransactionOptions {
465
- /** commit persists the deduplicated patch. */
469
+ /** commit persists the net patch: the last operation on each quad. */
466
470
  commit?: (patch: Patch, context?: TransactionContext) => Promise<void>;
467
471
  /** fallbackCommit runs when commit is omitted. */
468
472
  fallbackCommit?: (patch: Patch, context?: TransactionContext) => Promise<void>;
469
473
  }
470
474
  /**
471
- * Transaction collects mutations natively before flushing them as a deduplicated Patch.
475
+ * Transaction collects mutations natively before flushing them as one Patch. The
476
+ * last operation on a quad wins, whether or not the quad is stored.
472
477
  * It deeply implements the mutation boundary for an rdfjs.Store, providing rich bulk
473
478
  * ingestion without requiring wrapper classes.
474
479
  */
475
480
  declare class Transaction {
476
481
  private readonly options;
477
- private insertBuffer;
478
- private deleteBuffer;
482
+ /** changes are the buffered operations in the order they were made. */
483
+ private changes;
479
484
  constructor(options: TransactionOptions);
480
485
  /** add buffers a single quad for insertion on the next commit. */
481
486
  add(quad: rdfjs.Quad): this;
@@ -497,7 +502,7 @@ declare class Transaction {
497
502
  removeMatches(match: MatchFunction, subject?: rdfjs.Term | null, predicate?: rdfjs.Term | null, object?: rdfjs.Term | null, graph?: rdfjs.Term | null): EventEmitter;
498
503
  /** deleteGraph buffers all quads in the named graph for deletion on commit. */
499
504
  deleteGraph(match: MatchFunction, graph: rdfjs.Term | string): EventEmitter;
500
- /** commit deduplicates buffers and persists through the configured commitHandler. */
505
+ /** commit persists the net patch through the configured commitHandler. */
501
506
  commit(context?: TransactionContext): Promise<void>;
502
507
  /** rollback discards any uncommitted insertions and deletions. */
503
508
  rollback(): void;
@@ -1 +1 @@
1
- export { t as chunkAndEmbedQuads, n as chunkQuads } from "./chunk-and-embed-BlB2v4-2.js";
1
+ export { t as chunkAndEmbedQuads, n as chunkQuads } from "./chunk-and-embed-CNYO49kB.js";
@@ -1,5 +1,5 @@
1
1
  import { i as exportQuadsResponse, o as materializeImportQuads, r as collectQuadsFromStream } from "./rdf-formats-C2znopLM.js";
2
- import { sha256Hex } from "@wazootech/sparql-engine/term";
2
+ import { sha256Hex, termKey } from "@wazootech/sparql-engine/term";
3
3
  import { DataFactory } from "@wazootech/sparql-engine/data-model";
4
4
  import { EventEmitter } from "node:events";
5
5
  // src/client/quad-store/provenance/in-memory-provenance-store.ts
@@ -90,6 +90,10 @@ function isReplaceImportCommit(context) {
90
90
  }
91
91
  /**
92
92
  * deduplicateBuffers removes quads that appear in both insert and delete buffers.
93
+ *
94
+ * @deprecated The two buffers don't say which operation came last, so this can
95
+ * lose a delete or an insert. Transaction keeps the last operation on each quad
96
+ * and no longer calls this function.
93
97
  */
94
98
  function deduplicateBuffers(insertBuffer, deleteBuffer) {
95
99
  const removeFromInsert = [];
@@ -611,6 +615,32 @@ async function exportFromRdfjsStore(rdfjsStore, request) {
611
615
  const quads = await collectQuadsFromStream(stream);
612
616
  return await exportQuadsResponse(quads, request);
613
617
  }
618
+ // src/client/quad-store/net-patch.ts
619
+ /**
620
+ * buildNetPatch turns operations, in the order they were made, into the patch
621
+ * with the same result. The last operation on a quad wins, whether or not the
622
+ * store holds it, so no quad is in both halves of the patch.
623
+ */
624
+ function buildNetPatch(changes) {
625
+ const net = changes.some(({ insert }) => insert !== changes[0].insert) ? [...lastChanges(changes).values()] : changes;
626
+ return {
627
+ insertions: net.filter(({ insert }) => insert).map(({ quad }) => quad),
628
+ deletions: net.filter(({ insert }) => !insert).map(({ quad }) => quad)
629
+ };
630
+ }
631
+ /** lastChanges maps each quad's key to the last operation on it. */
632
+ function lastChanges(changes) {
633
+ return new Map(changes.map((change) => [quadKey(change.quad), change]));
634
+ }
635
+ /** quadKey identifies a quad by its four terms. */
636
+ function quadKey(quad) {
637
+ return JSON.stringify([
638
+ quad.subject,
639
+ quad.predicate,
640
+ quad.object,
641
+ quad.graph
642
+ ].map(termKey));
643
+ }
614
644
  // src/client/quad-store/rdfjs-store-commit-handler.ts
615
645
  /**
616
646
  * createRdfjsStoreCommitHandler returns a commit function that applies Patches
@@ -641,20 +671,24 @@ function createRdfjsStoreCommitHandler(store) {
641
671
  // src/client/quad-store/transaction.ts
642
672
  const { namedNode } = DataFactory;
643
673
  /**
644
- * Transaction collects mutations natively before flushing them as a deduplicated Patch.
674
+ * Transaction collects mutations natively before flushing them as one Patch. The
675
+ * last operation on a quad wins, whether or not the quad is stored.
645
676
  * It deeply implements the mutation boundary for an rdfjs.Store, providing rich bulk
646
677
  * ingestion without requiring wrapper classes.
647
678
  */
648
679
  var Transaction = class {
649
680
  options;
650
- insertBuffer = [];
651
- deleteBuffer = [];
681
+ /** changes are the buffered operations in the order they were made. */
682
+ changes = [];
652
683
  constructor(options) {
653
684
  this.options = options;
654
685
  }
655
686
  /** add buffers a single quad for insertion on the next commit. */
656
687
  add(quad) {
657
- this.insertBuffer.push(quad);
688
+ this.changes.push({
689
+ quad,
690
+ insert: true
691
+ });
658
692
  return this;
659
693
  }
660
694
  /** addQuad buffers a single quad for insertion on the next commit. */
@@ -663,17 +697,20 @@ var Transaction = class {
663
697
  }
664
698
  /** addQuads buffers multiple quads for insertion on the next commit. */
665
699
  addQuads(quads) {
666
- for (const quad of quads) this.insertBuffer.push(quad);
700
+ for (const quad of quads) this.add(quad);
667
701
  return this;
668
702
  }
669
703
  /** removeQuads buffers multiple quads for deletion on the next commit. */
670
704
  removeQuads(quads) {
671
- for (const quad of quads) this.deleteBuffer.push(quad);
705
+ for (const quad of quads) this.delete(quad);
672
706
  return this;
673
707
  }
674
708
  /** delete buffers a single quad for deletion on the next commit. */
675
709
  delete(quad) {
676
- this.deleteBuffer.push(quad);
710
+ this.changes.push({
711
+ quad,
712
+ insert: false
713
+ });
677
714
  return this;
678
715
  }
679
716
  /** removeQuad buffers a single quad for deletion on the next commit. */
@@ -682,29 +719,25 @@ var Transaction = class {
682
719
  }
683
720
  /** import consumes an RDF/JS stream, buffering all quads for later commit. */
684
721
  import(stream) {
685
- return bridgeStreamToBuffer(stream, this.insertBuffer);
722
+ return bridgeStream(stream, (quad) => this.add(quad));
686
723
  }
687
724
  /** remove consumes a stream and buffers all quads from it for deletion on commit. */
688
725
  remove(stream) {
689
- return bridgeStreamToBuffer(stream, this.deleteBuffer);
726
+ return bridgeStream(stream, (quad) => this.delete(quad));
690
727
  }
691
728
  /** removeMatches buffers all quads matching the given quad pattern for deletion on commit. */
692
729
  removeMatches(match, subject, predicate, object, graph) {
693
- return bridgeStreamToBuffer(match(subject, predicate, object, graph), this.deleteBuffer);
730
+ return bridgeStream(match(subject, predicate, object, graph), (quad) => this.delete(quad));
694
731
  }
695
732
  /** deleteGraph buffers all quads in the named graph for deletion on commit. */
696
733
  deleteGraph(match, graph) {
697
734
  const graphTerm = typeof graph === "string" ? namedNode(graph) : graph;
698
735
  return this.removeMatches(match, null, null, null, graphTerm);
699
736
  }
700
- /** commit deduplicates buffers and persists through the configured commitHandler. */
737
+ /** commit persists the net patch through the configured commitHandler. */
701
738
  async commit(context) {
702
- deduplicateBuffers(this.insertBuffer, this.deleteBuffer);
703
- if (this.insertBuffer.length === 0 && this.deleteBuffer.length === 0) return;
704
- const patch = {
705
- insertions: this.insertBuffer,
706
- deletions: this.deleteBuffer
707
- };
739
+ if (this.changes.length === 0) return;
740
+ const patch = buildNetPatch(this.changes);
708
741
  if (this.options.commit) await this.options.commit(patch, context);
709
742
  else if (this.options.fallbackCommit) await this.options.fallbackCommit(patch, context);
710
743
  this.clearBuffer();
@@ -714,17 +747,16 @@ var Transaction = class {
714
747
  this.clearBuffer();
715
748
  }
716
749
  clearBuffer() {
717
- this.insertBuffer = [];
718
- this.deleteBuffer = [];
750
+ this.changes = [];
719
751
  }
720
752
  };
721
753
  /**
722
- * bridgeStreamToBuffer connects an RDF/JS quad stream to a target buffer array.
754
+ * bridgeStream passes every quad of an RDF/JS stream to `receive`.
723
755
  */
724
- function bridgeStreamToBuffer(stream, targetBuffer) {
756
+ function bridgeStream(stream, receive) {
725
757
  const emitter = new EventEmitter();
726
758
  stream.on("data", (quad) => {
727
- targetBuffer.push(quad);
759
+ receive(quad);
728
760
  });
729
761
  stream.on("end", () => {
730
762
  emitter.emit("end");
@@ -1,2 +1,2 @@
1
- import { $ as ImportRequest, A as fromRdfjsTerm, B as QuadFilter, C as getFormat, D as fromRdfjsQuad, E as Quad, F as HexastoreIndexDescriptor, G as isImportCommit, H as PatchableStore, I as hashQuad, J as RdfjsStoreLike, K as isReplaceImportCommit, L as hashQuads, M as QuadRowReader, N as quadFromRow, O as toRdfjsQuad, P as HEXASTORE_INDEXES, Q as ImportMode, R as isTextualLiteral, S as exportQuadsResponse, T as parseQuads, U as TransactionContext, V as filterQuads, W as deduplicateBuffers, X as ExportRequest, Y as Patch, Z as ExportResponse, _ as createRdfjsStoreCommitHandler, a as preparePatch, at as ProvenanceListQuery, b as awaitDrainRemoveMatches, c as TransactionalRdfjsStore, ct as ProvenanceQueryResponse, d as RdfjsExportSource, dt as ProvenanceRecordInput, et as ImportSource, f as exportFromRdfjsStore, ft as ProvenanceRecordType, g as TransactionOptions, h as Transaction, i as computeNovelQuads, it as ProvenanceHistory, j as toRdfjsTerm, k as Term, l as TransactionalRdfjsStoreOptions, lt as ProvenanceQueryResult, m as MatchFunction, n as PreparedPatch, nt as InMemoryProvenanceStore, o as selectNovelQuads, ot as ProvenanceQueryHandler, p as importViaTransaction, pt as ProvenanceStore, q as RdfjsEventSource, r as SelectNovelQuadsOptions, rt as ImportProvenance, s as ReadonlyStore, st as ProvenanceQueryRequest, t as NovelQuads, tt as QuadStoreInterface, u as ImportViaTransactionOptions, ut as ProvenanceRecord, v as FORMATS, w as materializeImportQuads, x as collectQuadsFromStream, y as RdfFormat, z as QuadCriteria } from "./mod-CH7Hc3EE.js";
1
+ import { $ as ImportRequest, A as fromRdfjsTerm, B as QuadFilter, C as getFormat, D as fromRdfjsQuad, E as Quad, F as HexastoreIndexDescriptor, G as isImportCommit, H as PatchableStore, I as hashQuad, J as RdfjsStoreLike, K as isReplaceImportCommit, L as hashQuads, M as QuadRowReader, N as quadFromRow, O as toRdfjsQuad, P as HEXASTORE_INDEXES, Q as ImportMode, R as isTextualLiteral, S as exportQuadsResponse, T as parseQuads, U as TransactionContext, V as filterQuads, W as deduplicateBuffers, X as ExportRequest, Y as Patch, Z as ExportResponse, _ as createRdfjsStoreCommitHandler, a as preparePatch, at as ProvenanceListQuery, b as awaitDrainRemoveMatches, c as TransactionalRdfjsStore, ct as ProvenanceQueryResponse, d as RdfjsExportSource, dt as ProvenanceRecordInput, et as ImportSource, f as exportFromRdfjsStore, ft as ProvenanceRecordType, g as TransactionOptions, h as Transaction, i as computeNovelQuads, it as ProvenanceHistory, j as toRdfjsTerm, k as Term, l as TransactionalRdfjsStoreOptions, lt as ProvenanceQueryResult, m as MatchFunction, n as PreparedPatch, nt as InMemoryProvenanceStore, o as selectNovelQuads, ot as ProvenanceQueryHandler, p as importViaTransaction, pt as ProvenanceStore, q as RdfjsEventSource, r as SelectNovelQuadsOptions, rt as ImportProvenance, s as ReadonlyStore, st as ProvenanceQueryRequest, t as NovelQuads, tt as QuadStoreInterface, u as ImportViaTransactionOptions, ut as ProvenanceRecord, v as FORMATS, w as materializeImportQuads, x as collectQuadsFromStream, y as RdfFormat, z as QuadCriteria } from "./mod-aUvsYiTJ.js";
2
2
  export { ExportRequest, ExportResponse, FORMATS, HEXASTORE_INDEXES, HexastoreIndexDescriptor, ImportMode, ImportProvenance, ImportRequest, ImportSource, ImportViaTransactionOptions, InMemoryProvenanceStore, MatchFunction, NovelQuads, Patch, PatchableStore, PreparedPatch, ProvenanceHistory, ProvenanceListQuery, ProvenanceQueryHandler, ProvenanceQueryRequest, ProvenanceQueryResponse, ProvenanceQueryResult, ProvenanceRecord, ProvenanceRecordInput, ProvenanceRecordType, ProvenanceStore, Quad, QuadCriteria, QuadFilter, QuadRowReader, QuadStoreInterface, RdfFormat, RdfjsEventSource, RdfjsExportSource, RdfjsStoreLike, ReadonlyStore, SelectNovelQuadsOptions, Term, Transaction, TransactionContext, TransactionOptions, TransactionalRdfjsStore, TransactionalRdfjsStoreOptions, awaitDrainRemoveMatches, collectQuadsFromStream, computeNovelQuads, createRdfjsStoreCommitHandler, deduplicateBuffers, exportFromRdfjsStore, exportQuadsResponse, filterQuads, fromRdfjsQuad, fromRdfjsTerm, getFormat, hashQuad, hashQuads, importViaTransaction, isImportCommit, isReplaceImportCommit, isTextualLiteral, materializeImportQuads, parseQuads, preparePatch, quadFromRow, selectNovelQuads, toRdfjsQuad, toRdfjsTerm };
@@ -1,3 +1,3 @@
1
- import { S as InMemoryProvenanceStore, _ as isTextualLiteral, a as Transaction, b as isImportCommit, c as importViaTransaction, d as quadFromRow, f as fromRdfjsTerm, g as hashQuads, h as hashQuad, i as TransactionalRdfjsStore, l as fromRdfjsQuad, m as HEXASTORE_INDEXES, n as preparePatch, o as createRdfjsStoreCommitHandler, p as toRdfjsTerm, r as selectNovelQuads, s as exportFromRdfjsStore, t as computeNovelQuads, u as toRdfjsQuad, v as filterQuads, x as isReplaceImportCommit, y as deduplicateBuffers } from "./quad-store-oBgXOONP.js";
1
+ import { S as InMemoryProvenanceStore, _ as isTextualLiteral, a as Transaction, b as isImportCommit, c as importViaTransaction, d as quadFromRow, f as fromRdfjsTerm, g as hashQuads, h as hashQuad, i as TransactionalRdfjsStore, l as fromRdfjsQuad, m as HEXASTORE_INDEXES, n as preparePatch, o as createRdfjsStoreCommitHandler, p as toRdfjsTerm, r as selectNovelQuads, s as exportFromRdfjsStore, t as computeNovelQuads, u as toRdfjsQuad, v as filterQuads, x as isReplaceImportCommit, y as deduplicateBuffers } from "./quad-store-CT8YQQky.js";
2
2
  import { a as getFormat, i as exportQuadsResponse, n as awaitDrainRemoveMatches, o as materializeImportQuads, r as collectQuadsFromStream, s as parseQuads, t as FORMATS } from "./rdf-formats-C2znopLM.js";
3
3
  export { FORMATS, HEXASTORE_INDEXES, InMemoryProvenanceStore, Transaction, TransactionalRdfjsStore, awaitDrainRemoveMatches, collectQuadsFromStream, computeNovelQuads, createRdfjsStoreCommitHandler, deduplicateBuffers, exportFromRdfjsStore, exportQuadsResponse, filterQuads, fromRdfjsQuad, fromRdfjsTerm, getFormat, hashQuad, hashQuads, importViaTransaction, isImportCommit, isReplaceImportCommit, isTextualLiteral, materializeImportQuads, parseQuads, preparePatch, quadFromRow, selectNovelQuads, toRdfjsQuad, toRdfjsTerm };
@@ -1,6 +1,6 @@
1
- import { t as buildSearchResultId } from "./build-search-result-id-DPlgkWyi.js";
1
+ import { t as buildSearchResultId } from "./build-search-result-id-owYEv-UZ.js";
2
2
  import { r as collectQuadsFromStream } from "./rdf-formats-C2znopLM.js";
3
- import { S as InMemoryProvenanceStore, _ as isTextualLiteral, a as Transaction, c as importViaTransaction, h as hashQuad, o as createRdfjsStoreCommitHandler, s as exportFromRdfjsStore, v as filterQuads } from "./quad-store-oBgXOONP.js";
3
+ import { S as InMemoryProvenanceStore, _ as isTextualLiteral, a as Transaction, c as importViaTransaction, h as hashQuad, o as createRdfjsStoreCommitHandler, s as exportFromRdfjsStore, v as filterQuads } from "./quad-store-CT8YQQky.js";
4
4
  import { MemoryStore } from "@wazootech/sparql-engine";
5
5
  // src/rdfjs/rdfjs-search-index.ts
6
6
  /**
package/dist/rdfjs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ReindexResponse, D as SearchRequest, O as SearchResponse, S as ReindexRequest, w as SearchIndexInterface } from "./mod-CfzcRVcL.js";
2
- import { $ as ImportRequest, J as RdfjsStoreLike, U as TransactionContext, X as ExportRequest, Y as Patch, Z as ExportResponse, ct as ProvenanceQueryResponse, pt as ProvenanceStore, st as ProvenanceQueryRequest, tt as QuadStoreInterface } from "./mod-CH7Hc3EE.js";
1
+ import { C as ReindexResponse, D as SearchRequest, O as SearchResponse, S as ReindexRequest, w as SearchIndexInterface } from "./mod-Du9mzmwt.js";
2
+ import { $ as ImportRequest, J as RdfjsStoreLike, U as TransactionContext, X as ExportRequest, Y as Patch, Z as ExportResponse, ct as ProvenanceQueryResponse, pt as ProvenanceStore, st as ProvenanceQueryRequest, tt as QuadStoreInterface } from "./mod-aUvsYiTJ.js";
3
3
  import * as rdfjs from "@rdfjs/types";
4
4
  /**
5
5
  * RdfjsSearchIndex is the implementation of SearchIndexInterface that uses an RDF/JS store.
package/dist/rdfjs.js CHANGED
@@ -1 +1 @@
1
- export { t as RdfjsQuadStore, r as RdfjsSearchIndex, n as recordPatchProvenance } from "./rdfjs-DodYvbzF.js";
1
+ export { t as RdfjsQuadStore, r as RdfjsSearchIndex, n as recordPatchProvenance } from "./rdfjs-CN2lccto.js";
@@ -1,2 +1,2 @@
1
- import { A as DEFAULT_RRF_K, C as ReindexResponse, D as SearchRequest, E as SearchMode, M as normalizeRrfScore, O as SearchResponse, S as ReindexRequest, T as SearchIndexOnImport, _ as extractRdfLocalLabel, a as RebuildSearchIndexResult, b as BuildSearchResultIdOptions, c as PreparedCommit, d as PlanSearchIndexingOptions, f as SearchIndexPlan, g as buildChunkFtsValue, h as DEFAULT_LABEL_PREDICATES, i as RebuildSearchIndexOptions, j as SearchScoreType, k as SearchResult, l as prepareCommit, m as BuildChunkFtsValueOptions, n as RebuildPage, o as rebuildSearchIndex, p as planSearchIndexing, r as RebuildScope, s as PrepareCommitOptions, t as ChunkRebuildDriver, u as DEFAULT_SEARCH_INDEX_ON_IMPORT, v as formatPredicatePhrase, w as SearchIndexInterface, x as buildSearchResultId, y as resolveLabelPredicates } from "./mod-CfzcRVcL.js";
1
+ import { A as DEFAULT_RRF_K, C as ReindexResponse, D as SearchRequest, E as SearchMode, M as normalizeRrfScore, O as SearchResponse, S as ReindexRequest, T as SearchIndexOnImport, _ as extractRdfLocalLabel, a as RebuildSearchIndexResult, b as BuildSearchResultIdOptions, c as PreparedCommit, d as PlanSearchIndexingOptions, f as SearchIndexPlan, g as buildChunkFtsValue, h as DEFAULT_LABEL_PREDICATES, i as RebuildSearchIndexOptions, j as SearchScoreType, k as SearchResult, l as prepareCommit, m as BuildChunkFtsValueOptions, n as RebuildPage, o as rebuildSearchIndex, p as planSearchIndexing, r as RebuildScope, s as PrepareCommitOptions, t as ChunkRebuildDriver, u as DEFAULT_SEARCH_INDEX_ON_IMPORT, v as formatPredicatePhrase, w as SearchIndexInterface, x as buildSearchResultId, y as resolveLabelPredicates } from "./mod-Du9mzmwt.js";
2
2
  export { BuildChunkFtsValueOptions, BuildSearchResultIdOptions, ChunkRebuildDriver, DEFAULT_LABEL_PREDICATES, DEFAULT_RRF_K, DEFAULT_SEARCH_INDEX_ON_IMPORT, PlanSearchIndexingOptions, PrepareCommitOptions, PreparedCommit, RebuildPage, RebuildScope, RebuildSearchIndexOptions, RebuildSearchIndexResult, ReindexRequest, ReindexResponse, SearchIndexInterface, SearchIndexOnImport, SearchIndexPlan, SearchMode, SearchRequest, SearchResponse, SearchResult, SearchScoreType, buildChunkFtsValue, buildSearchResultId, extractRdfLocalLabel, formatPredicatePhrase, normalizeRrfScore, planSearchIndexing, prepareCommit, rebuildSearchIndex, resolveLabelPredicates };
@@ -1,6 +1,6 @@
1
- import { t as buildSearchResultId } from "./build-search-result-id-DPlgkWyi.js";
2
- import { b as isImportCommit, g as hashQuads, n as preparePatch, r as selectNovelQuads, v as filterQuads, x as isReplaceImportCommit } from "./quad-store-oBgXOONP.js";
3
- import { t as chunkAndEmbedQuads } from "./chunk-and-embed-BlB2v4-2.js";
1
+ import { t as buildSearchResultId } from "./build-search-result-id-owYEv-UZ.js";
2
+ import { b as isImportCommit, g as hashQuads, n as preparePatch, r as selectNovelQuads, v as filterQuads, x as isReplaceImportCommit } from "./quad-store-CT8YQQky.js";
3
+ import { t as chunkAndEmbedQuads } from "./chunk-and-embed-CNYO49kB.js";
4
4
  // src/client/search-index/search-chunk-fts.ts
5
5
  /**
6
6
  * buildChunkFtsValue composes space-separated discovery tokens for FTS and semantic indexing.
package/dist/shacl.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { J as RdfjsStoreLike, U as TransactionContext, Y as Patch } from "./mod-CH7Hc3EE.js";
1
+ import { J as RdfjsStoreLike, U as TransactionContext, Y as Patch } from "./mod-aUvsYiTJ.js";
2
2
  import * as rdfjs from "@rdfjs/types";
3
3
  /** SHAPES_GRAPH is the named graph that holds a world's SHACL shapes. */
4
4
  export declare const SHAPES_GRAPH = "https://wazoo.dev/ns/worlds#shapes";
package/dist/shacl.js CHANGED
@@ -1,4 +1,4 @@
1
- import { x as isReplaceImportCommit } from "./quad-store-oBgXOONP.js";
1
+ import { x as isReplaceImportCommit } from "./quad-store-CT8YQQky.js";
2
2
  import { r as collectQuadsFromStream } from "./rdf-formats-C2znopLM.js";
3
3
  import { RE2JS } from "re2js";
4
4
  import { DataFactory } from "@wazootech/sparql-engine/data-model";
@@ -187,15 +187,23 @@ const FLAGS = {
187
187
  s: RE2JS.DOTALL,
188
188
  m: RE2JS.MULTILINE
189
189
  };
190
+ /** MAX_PATTERN_LENGTH is how many characters a pattern may have. */
191
+ const MAX_PATTERN_LENGTH = 4e3;
192
+ /**
193
+ * MAX_PATTERN_STEPS is how large a compiled pattern may be. Matching takes up to
194
+ * this many steps for each character of the text, and `a{500}` alone has 500.
195
+ */
196
+ const MAX_PATTERN_STEPS = 1e3;
190
197
  /**
191
198
  * compilePattern prepares an `sh:pattern` for matching in time that grows with
192
199
  * the length of the text only. JavaScript's own matcher can take hours on a short
193
200
  * text with a pattern such as `^(a+)+$`, and nothing can interrupt it. In return,
194
201
  * look-ahead, look-behind and back-references are not supported.
195
202
  *
196
- * @throws when the pattern or a flag isn't supported.
203
+ * @throws when the pattern is too large, or when it or a flag isn't supported.
197
204
  */
198
205
  function compilePattern(pattern, flags = "") {
206
+ if (pattern.length > MAX_PATTERN_LENGTH) throw new Error("it is too long");
199
207
  let options = 0;
200
208
  for (const flag of flags) {
201
209
  const option = FLAGS[flag];
@@ -203,6 +211,7 @@ function compilePattern(pattern, flags = "") {
203
211
  options |= option;
204
212
  }
205
213
  const compiled = RE2JS.compile(RE2JS.translateRegExp(pattern), options);
214
+ if (compiled.programSize() > MAX_PATTERN_STEPS) throw new Error("it is too complex");
206
215
  return (text) => compiled.matcher(text).find();
207
216
  }
208
217
  // src/shacl/shape-graph.ts
@@ -1,2 +1,2 @@
1
- import { a as SparqlSelectResults, c as SparqlRequest, i as SparqlResponse, n as SparqlBinding, o as SparqlValue, r as SparqlConstructResults, s as SparqlEngineInterface, t as SparqlAskResults } from "./mod-C_Is4DOx.js";
1
+ import { a as SparqlSelectResults, c as SparqlRequest, i as SparqlResponse, n as SparqlBinding, o as SparqlValue, r as SparqlConstructResults, s as SparqlEngineInterface, t as SparqlAskResults } from "./mod-Q0-ml33V.js";
2
2
  export type { SparqlAskResults, SparqlBinding, SparqlConstructResults, SparqlEngineInterface, SparqlRequest, SparqlResponse, SparqlSelectResults, SparqlValue };
package/dist/testing.d.ts CHANGED
@@ -13,11 +13,11 @@
13
13
  * `createMemoryWorldsSdk` as the portable reference; `@wazootech/worlds-sqlite` is the
14
14
  * durable source of truth for SQLite-family behavior.
15
15
  */
16
- import { D as SearchRequest, T as SearchIndexOnImport } from "./mod-CfzcRVcL.js";
17
- import { o as SparqlValue } from "./mod-C_Is4DOx.js";
18
- import { n as WorldsSdkInterface } from "./client-B1oktOm6.js";
16
+ import { D as SearchRequest, T as SearchIndexOnImport } from "./mod-Du9mzmwt.js";
17
+ import { o as SparqlValue } from "./mod-Q0-ml33V.js";
18
+ import { n as WorldsSdkInterface } from "./client-DHhpNpi6.js";
19
19
  import * as rdfjs from "@rdfjs/types";
20
- import { U as TransactionContext, Y as Patch } from "./mod-CH7Hc3EE.js";
20
+ import { U as TransactionContext, Y as Patch } from "./mod-aUvsYiTJ.js";
21
21
  import { t as EmbeddingService } from "./embedding-service-DebRMVmn.js";
22
22
  /**
23
23
  * Parity fixtures are the shared corpus every durable backend runs in its
@@ -51,6 +51,8 @@ export interface ParitySearchCase {
51
51
  export interface ParitySparqlCase {
52
52
  /** name identifies the case in the parity report. */
53
53
  name: string;
54
+ /** update is an optional SPARQL update both Sdks run before the query. */
55
+ update?: string;
54
56
  /** query is the SPARQL query executed against both Sdks. */
55
57
  query: string;
56
58
  /** expected is the hand-authored result both Sdks must satisfy. */
package/dist/testing.js CHANGED
@@ -1,7 +1,39 @@
1
- import { h as hashQuad } from "./quad-store-oBgXOONP.js";
1
+ import { h as hashQuad } from "./quad-store-CT8YQQky.js";
2
2
  import { o as materializeImportQuads } from "./rdf-formats-C2znopLM.js";
3
3
  import { DataFactory } from "n3";
4
4
  import { FakeEmbeddingService } from "./embedding-service.js";
5
+ // src/testing/parity-update-order.ts
6
+ const stored = "<urn:alice> <urn:likes> \"sailing\"";
7
+ const missing = "<urn:alice> <urn:likes> \"rowing\"";
8
+ /** lastOperationWins expects one update request to leave its last operation's result. */
9
+ function lastOperationWins(name, update, fact, present) {
10
+ return {
11
+ name,
12
+ update,
13
+ query: `ASK { ${fact} }`,
14
+ expected: {
15
+ kind: "ask",
16
+ boolean: present
17
+ }
18
+ };
19
+ }
20
+ /**
21
+ * updateOrderWorld changes one fact more than once in a single update request.
22
+ * A backend that buffers the request into one patch must keep the last
23
+ * operation, whether or not the fact was stored before.
24
+ */
25
+ const updateOrderWorld = {
26
+ name: "updateOrderWorld",
27
+ nquads: `${stored} .`,
28
+ totalQuads: 1,
29
+ sparql: [
30
+ lastOperationWins("insert then delete removes a stored fact", `INSERT DATA { ${stored} } ; DELETE DATA { ${stored} }`, stored, false),
31
+ lastOperationWins("insert then delete leaves a missing fact missing", `INSERT DATA { ${missing} } ; DELETE DATA { ${missing} }`, missing, false),
32
+ lastOperationWins("delete then insert keeps a stored fact", `DELETE DATA { ${stored} } ; INSERT DATA { ${stored} }`, stored, true),
33
+ lastOperationWins("delete then insert adds a missing fact", `DELETE DATA { ${missing} } ; INSERT DATA { ${missing} }`, missing, true),
34
+ lastOperationWins("the last of three operations wins", `DELETE DATA { ${stored} } ; INSERT DATA { ${stored} } ; DELETE DATA { ${stored} }`, stored, false)
35
+ ]
36
+ };
5
37
  // src/testing/parity-fixtures.ts
6
38
  const XSD = "http://www.w3.org/2001/XMLSchema#";
7
39
  /**
@@ -261,7 +293,8 @@ const parityCorpus = {
261
293
  typedLiteralsWorld,
262
294
  rdfStarWorld,
263
295
  chunkBoundaryWorld,
264
- emptyWorld
296
+ emptyWorld,
297
+ updateOrderWorld
265
298
  ],
266
299
  replaceCases: [replaceModeCase]
267
300
  };
@@ -409,6 +442,10 @@ async function checkSparqlCase(fixtureName, options, nquads, sparqlCase, failure
409
442
  const cand = await options.candidate();
410
443
  await importNquads(ref, nquads);
411
444
  await importNquads(cand, nquads);
445
+ if (sparqlCase.update) {
446
+ await ref.sparql({ query: sparqlCase.update });
447
+ await cand.sparql({ query: sparqlCase.update });
448
+ }
412
449
  const refResponse = await ref.sparql({ query: sparqlCase.query });
413
450
  const candResponse = await cand.sparql({ query: sparqlCase.query });
414
451
  checkSparqlAgainstExpectation(fixtureName, sparqlCase.name, "reference", refResponse, sparqlCase.expected, failures);
package/dist/wazoo.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { n as WorldsSdkInterface } from "./client-B1oktOm6.js";
1
+ import { n as WorldsSdkInterface } from "./client-DHhpNpi6.js";
2
2
  import { Client } from "@wazootech/worlds-client";
3
- import { $ as ImportRequest, X as ExportRequest, Z as ExportResponse, tt as QuadStoreInterface } from "./mod-CH7Hc3EE.js";
4
- import { C as ReindexResponse, D as SearchRequest, O as SearchResponse, S as ReindexRequest, w as SearchIndexInterface } from "./mod-CfzcRVcL.js";
5
- import { c as SparqlRequest, i as SparqlResponse, s as SparqlEngineInterface } from "./mod-C_Is4DOx.js";
3
+ import { $ as ImportRequest, X as ExportRequest, Z as ExportResponse, tt as QuadStoreInterface } from "./mod-aUvsYiTJ.js";
4
+ import { C as ReindexResponse, D as SearchRequest, O as SearchResponse, S as ReindexRequest, w as SearchIndexInterface } from "./mod-Du9mzmwt.js";
5
+ import { c as SparqlRequest, i as SparqlResponse, s as SparqlEngineInterface } from "./mod-Q0-ml33V.js";
6
6
  /**
7
7
  * CreateWazooSdkOptions configures the remote Worlds SDK client.
8
8
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wazootech/worlds-sdk",
3
- "version": "0.11.5",
3
+ "version": "0.11.6",
4
4
  "description": "Give an agent a knowledge graph it can search and query with SPARQL: in memory, on a Worlds storage package such as SQLite or Postgres, or on the hosted Worlds API.",
5
5
  "keywords": [
6
6
  "wazoo",