@procedures/mongo 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +27 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/module.d.ts +2 -2
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +4 -5
- package/dist/module.js.map +1 -1
- package/dist/procedures/input-schemas.d.ts.map +1 -1
- package/dist/procedures/input-schemas.js +29 -2
- package/dist/procedures/input-schemas.js.map +1 -1
- package/dist/storage/document-storage.d.ts +162 -3
- package/dist/storage/document-storage.d.ts.map +1 -1
- package/dist/storage/document-storage.js +325 -7
- package/dist/storage/document-storage.js.map +1 -1
- package/dist/storage/index.d.ts +3 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +3 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/materializer.d.ts.map +1 -1
- package/dist/storage/materializer.js +7 -0
- package/dist/storage/materializer.js.map +1 -1
- package/dist/storage/own-writes.d.ts +51 -0
- package/dist/storage/own-writes.d.ts.map +1 -0
- package/dist/storage/own-writes.js +130 -0
- package/dist/storage/own-writes.js.map +1 -0
- package/dist/storage/storage-hints.d.ts +230 -0
- package/dist/storage/storage-hints.d.ts.map +1 -0
- package/dist/storage/storage-hints.js +876 -0
- package/dist/storage/storage-hints.js.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +4 -0
- package/src/module.ts +5 -5
- package/src/procedures/input-schemas.ts +29 -2
- package/src/storage/document-storage.ts +394 -7
- package/src/storage/index.ts +4 -0
- package/src/storage/materializer.ts +7 -0
- package/src/storage/own-writes.ts +157 -0
- package/src/storage/storage-hints.ts +971 -0
package/dist/index.d.ts
CHANGED
|
@@ -26,8 +26,10 @@ export type { ScopeInput } from "./scope.js";
|
|
|
26
26
|
export { hasCollection, requireCollection, getBaseMeta, } from "./types.js";
|
|
27
27
|
export type { MongoProcedures, ProcedureInput, ProcedureOutput, PingInput, PingOutput, InfoInput, ListCollectionsInput, ListCollectionsOutput, CreateCollectionInput, CreateCollectionOutput, DropCollectionInput, DropCollectionOutput, StatsInput, FindInput, FindOutput, GetInput, GetOutput, InsertInput, InsertOutput, UpdateInput, UpdateOutput, DeleteInput, DeleteOutput, CountInput, CountOutput, AggregateInput, AggregateOutput, DistinctInput, DistinctOutput, BulkInput, BulkOutput, ExplainInput, ExplainOutput, WatchInput, WatchChange, ListIndexesInput, ListIndexesOutput, CreateIndexInput, CreateIndexOutput, DropIndexInput, DropIndexOutput, } from "./procedures.types.js";
|
|
28
28
|
export type { PaginationInput, PaginationOutput, SortOrder, SortSpec, DocumentId, BaseDocument, MongoDocument, DocumentQuery, DocumentUpdate, BaseMeta, CollectionMeta, BulkInsertOne, BulkUpdateOne, BulkUpdateMany, BulkDeleteOne, BulkDeleteMany, BulkOperation, BulkWriteResult, IndexSpec, IndexOptions, IndexInfo, CollectionOptions, CollectionStats, DatabaseInfo, AggregationStage, AggregationOptions, } from "./types.js";
|
|
29
|
-
export { MongoStorage, MongoDocumentStorage, selectorPrefilter, DOCUMENT_STORAGE_FIELDS, TOMBSTONE_FIELD, DEFAULT_STORED_FORM, decodeStoredDocument, } from "./storage/index.js";
|
|
29
|
+
export { MongoStorage, MongoDocumentStorage, selectorPrefilter, DOCUMENT_STORAGE_FIELDS, TOMBSTONE_FIELD, DEFAULT_STORED_FORM, decodeStoredDocument, versionOfStored, } from "./storage/index.js";
|
|
30
30
|
export type { MongoStorageOptions, MongoDocumentStorageOptions, SelectorPrefilterOptions, StoredForm, DecodeStoredDocumentOptions, StoredDocumentEntry } from "./storage/index.js";
|
|
31
|
+
export { watchStorageChanges, storageChangeOf } from "./storage/index.js";
|
|
32
|
+
export type { StorageChange, StorageChangeHint, StorageChangesWatch, StorageHintPublisher, WatchStorageChangesOptions } from "./storage/index.js";
|
|
31
33
|
export { BLOCKED_PIPELINE_OPERATORS, ALLOWED_PIPELINE_STAGES, DEFAULT_PIPELINE_LIMITS, assertNoBlockedOperators, boundPipeline, cutResults, isTimeLimitError, scopePipeline, } from "./storage/index.js";
|
|
32
34
|
export type { PipelineLimits, PipelineScope } from "./storage/index.js";
|
|
33
35
|
export { registerMongoProcedures, procedures } from "./module.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH,OAAO,EACL,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM7C,OAAO,EAEL,aAAa,EACb,iBAAiB,EACjB,WAAW,GACZ,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,eAAe,EACf,cAAc,EACd,eAAe,EAEf,SAAS,EACT,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,SAAS,EACT,UAAU,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAEV,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,QAAQ,EAER,UAAU,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EAEd,QAAQ,EACR,cAAc,EAEd,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,eAAe,EAEf,SAAS,EACT,YAAY,EACZ,SAAS,EAET,iBAAiB,EACjB,eAAe,EAEf,YAAY,EAEZ,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAMpB,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH,OAAO,EACL,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM7C,OAAO,EAEL,aAAa,EACb,iBAAiB,EACjB,WAAW,GACZ,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,eAAe,EACf,cAAc,EACd,eAAe,EAEf,SAAS,EACT,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,UAAU,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UA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xE,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMlE,cAAc,uBAAuB,CAAC;AAMtC,YAAY,EACV,EAAE,EACF,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,WAAW,EACX,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChJ,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,eAAe,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjL,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,9 @@ hasCollection, requireCollection, getBaseMeta, } from "./types.js";
|
|
|
33
33
|
// =============================================================================
|
|
34
34
|
// Storage (CollectionStorage implementation)
|
|
35
35
|
// =============================================================================
|
|
36
|
-
export { MongoStorage, MongoDocumentStorage, selectorPrefilter, DOCUMENT_STORAGE_FIELDS, TOMBSTONE_FIELD, DEFAULT_STORED_FORM, decodeStoredDocument, } from "./storage/index.js";
|
|
36
|
+
export { MongoStorage, MongoDocumentStorage, selectorPrefilter, DOCUMENT_STORAGE_FIELDS, TOMBSTONE_FIELD, DEFAULT_STORED_FORM, decodeStoredDocument, versionOfStored, } from "./storage/index.js";
|
|
37
|
+
// The change hints of a storage collection from its change stream (roadmap CLI-77)
|
|
38
|
+
export { watchStorageChanges, storageChangeOf } from "./storage/index.js";
|
|
37
39
|
// The guard of an aggregation pipeline over shared collections, and its limits (Graph's split plan, P3)
|
|
38
40
|
export { BLOCKED_PIPELINE_OPERATORS, ALLOWED_PIPELINE_STAGES, DEFAULT_PIPELINE_LIMITS, assertNoBlockedOperators, boundPipeline, cutResults, isTimeLimitError, scopePipeline, } from "./storage/index.js";
|
|
39
41
|
// =============================================================================
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,gFAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF,OAAO,EACL,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAKzB,gFAAgF;AAChF,QAAQ;AACR,gFAAgF;AAEhF,OAAO;AACL,cAAc;AACd,aAAa,EACb,iBAAiB,EACjB,WAAW,GACZ,MAAM,YAAY,CAAC;AAqFpB,gFAAgF;AAChF,6CAA6C;AAC7C,gFAAgF;AAEhF,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,gFAAgF;AAChF,wBAAwB;AACxB,gFAAgF;AAEhF,OAAO,EACL,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAKzB,gFAAgF;AAChF,QAAQ;AACR,gFAAgF;AAEhF,OAAO;AACL,cAAc;AACd,aAAa,EACb,iBAAiB,EACjB,WAAW,GACZ,MAAM,YAAY,CAAC;AAqFpB,gFAAgF;AAChF,6CAA6C;AAC7C,gFAAgF;AAEhF,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAE5B,mFAAmF;AACnF,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1E,wGAAwG;AACxG,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAG5B,gFAAgF;AAChF,yBAAyB;AACzB,gFAAgF;AAEhF,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAElE,gFAAgF;AAChF,sDAAsD;AACtD,gFAAgF;AAEhF,cAAc,uBAAuB,CAAC;AAgBtC,uEAAuE;AACvE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEhJ,6GAA6G;AAC7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/module.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Registers MongoDB procedures with the client system.
|
|
7
7
|
* This file is referenced by package.json's client.procedures field.
|
|
8
8
|
*/
|
|
9
|
-
import { type AnyProcedure, type ProcedureModule, type
|
|
9
|
+
import { type AnyProcedure, type ProcedureModule, type PackageDefinition } from "@procedures/client";
|
|
10
10
|
/**
|
|
11
11
|
* All MongoDB procedures
|
|
12
12
|
*/
|
|
@@ -22,5 +22,5 @@ export default mongoModule;
|
|
|
22
22
|
* a registry. The default is the global registry. Importing this file registers nothing: the
|
|
23
23
|
* `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
24
24
|
*/
|
|
25
|
-
export declare
|
|
25
|
+
export declare const registerMongoProcedures: PackageDefinition["register"];
|
|
26
26
|
//# sourceMappingURL=module.d.ts.map
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiB,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAwBpH;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,YAAY,EA0B7C,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,eAAqC,CAAC;eAEjD,WAAW;AAE1B;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAAiB,CAAC,UAAU,CAAyB,CAAC"}
|
package/dist/module.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Registers MongoDB procedures with the client system.
|
|
7
7
|
* This file is referenced by package.json's client.procedures field.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { definePackage } from "@procedures/client";
|
|
10
10
|
// Import all procedures
|
|
11
11
|
import { pingProcedure } from "./procedures/database.ping.js";
|
|
12
12
|
import { infoProcedure } from "./procedures/database.info.js";
|
|
@@ -58,18 +58,17 @@ export const procedures = [
|
|
|
58
58
|
// Change streams
|
|
59
59
|
watchProcedure,
|
|
60
60
|
];
|
|
61
|
+
const mongoPackage = definePackage("@procedures/mongo", [...procedures]);
|
|
61
62
|
/**
|
|
62
63
|
* The module of this package, for `createRegistry()`: its procedures as data. Importing this
|
|
63
64
|
* file registers nothing. (`register.ts` registers the same procedures in the global registry.)
|
|
64
65
|
*/
|
|
65
|
-
export const mongoModule =
|
|
66
|
+
export const mongoModule = mongoPackage.module;
|
|
66
67
|
export default mongoModule;
|
|
67
68
|
/**
|
|
68
69
|
* This function registers the procedures of @procedures/mongo, and of the modules that it requires, in
|
|
69
70
|
* a registry. The default is the global registry. Importing this file registers nothing: the
|
|
70
71
|
* `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
|
|
71
72
|
*/
|
|
72
|
-
export
|
|
73
|
-
registerModules(registry, [mongoModule]);
|
|
74
|
-
}
|
|
73
|
+
export const registerMongoProcedures = mongoPackage.register;
|
|
75
74
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAmE,MAAM,oBAAoB,CAAC;AAEpH,wBAAwB;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAA4B;IACjD,WAAW;IACX,aAAa;IACb,aAAa;IACb,cAAc;IACd,aAAa;IACb,yBAAyB;IACzB,aAAa;IACb,cAAc;IACd,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,eAAe;IACf,eAAe;IACf,eAAe;IACf,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,aAAa;IACb,gBAAgB;IAChB,UAAU;IACV,oBAAoB;IACpB,oBAAoB;IACpB,kBAAkB;IAClB,iBAAiB;IACjB,cAAc;CACf,CAAC;AAEF,MAAM,YAAY,GAAsB,aAAa,CAAC,mBAAmB,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;AAE5F;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAoB,YAAY,CAAC,MAAM,CAAC;AAEhE,eAAe,WAAW,CAAC;AAE3B;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAkC,YAAY,CAAC,QAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-schemas.d.ts","sourceRoot":"","sources":["../../src/procedures/input-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,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AE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC,CAKhH;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,CA6B/F"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* a zod object that names the same fields.
|
|
12
12
|
*/
|
|
13
13
|
import { z } from "zod";
|
|
14
|
-
import { jsonSchemaOf,
|
|
14
|
+
import { jsonSchemaOf, typed } from "@procedures/client";
|
|
15
15
|
/** The fields that select the database and the collection. */
|
|
16
16
|
export function scopeFields() {
|
|
17
17
|
return {
|
|
@@ -47,6 +47,33 @@ export function idTypeField() {
|
|
|
47
47
|
* that names the same fields.
|
|
48
48
|
*/
|
|
49
49
|
export function described(parse, fields) {
|
|
50
|
-
|
|
50
|
+
const safeParse = (data) => {
|
|
51
|
+
try {
|
|
52
|
+
return { success: true, data: parse(data) };
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
const err = error;
|
|
56
|
+
const message = err.message ?? "Validation failed";
|
|
57
|
+
// A plain Error has no issues: its message is the one issue
|
|
58
|
+
const issues = err.issues ?? err.errors;
|
|
59
|
+
return { success: false, error: { message, issues: issues && issues.length > 0 ? issues : [{ message }] } };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// typed<T>() gives the type and the shape. The parse function replaces its pass-through validation
|
|
63
|
+
const schema = typed();
|
|
64
|
+
return Object.assign(schema, {
|
|
65
|
+
parse: (data) => parse(data),
|
|
66
|
+
safeParse,
|
|
67
|
+
"~standard": {
|
|
68
|
+
...schema["~standard"],
|
|
69
|
+
validate: (value) => {
|
|
70
|
+
const result = safeParse(value);
|
|
71
|
+
return result.success
|
|
72
|
+
? { value: result.data }
|
|
73
|
+
: { issues: (result.error.issues ?? []).map((issue) => ({ message: issue.message, path: issue.path })) };
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
"~jsonSchema": jsonSchemaOf(fields),
|
|
77
|
+
});
|
|
51
78
|
}
|
|
52
79
|
//# sourceMappingURL=input-schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-schemas.js","sourceRoot":"","sources":["../../src/procedures/input-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"input-schemas.js","sourceRoot":"","sources":["../../src/procedures/input-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,KAAK,EAAsB,MAAM,oBAAoB,CAAC;AAE7E,8DAA8D;AAC9D,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iEAAiE,CAAC;QACpH,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6DAA6D,CAAC;KAC/G,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,cAAc;IAC5B,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,YAAY;IAO1B,OAAO;QACL,MAAM,EAAE,cAAc,EAAE;aACrB,QAAQ,EAAE;aACV,QAAQ,CAAC,sGA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EAAE,CAAC;QAC9G,CAAC;IACH,CAAC,CAAC;IACF,mGAAmG;IACnG,MAAM,MAAM,GAAG,KAAK,EAAK,CAAC;IAC1B,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3B,KAAK,EAAE,CAAC,IAAa,EAAK,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;QACxC,SAAS;QACT,WAAW,EAAE;YACX,GAAG,MAAM,CAAC,WAAW,CAAC;YACtB,QAAQ,EAAE,CAAC,KAAc,EAAE,EAAE;gBAC3B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;gBAChC,OAAO,MAAM,CAAC,OAAO;oBACnB,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE;oBACxB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;YAC7G,CAAC;SACF;QACD,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC;KACpC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
* false } }`, so it does not see that writer. On a replica set, the test and the write are one
|
|
91
91
|
* transaction, and this case does not occur.
|
|
92
92
|
*/
|
|
93
|
-
import type
|
|
93
|
+
import { type Db, type Document, type MongoClient } from "mongodb";
|
|
94
94
|
import { type CollectionStorage, type StorageBatchWriteOptions, type StorageChanges, type StorageItemWriteOptions, type StorageMetadata, type StoragePatch, type StorageQueryOptions, type StorageQueryPolicy, type StorageSelector, type StorageWriteOptions } from "@procedures/collections";
|
|
95
95
|
import { type Duration } from "@procedures/client";
|
|
96
96
|
import { type PipelineLimits } from "./pipeline-scope.js";
|
|
@@ -220,6 +220,98 @@ export interface StoredDocumentEntry<T> {
|
|
|
220
220
|
* ```
|
|
221
221
|
*/
|
|
222
222
|
export declare function decodeStoredDocument<T = Document>(doc: Document, options?: DecodeStoredDocumentOptions): StoredDocumentEntry<T> | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* This function gives the version of a raw stored document of a `MongoDocumentStorage`: the
|
|
225
|
+
* version that `storage.versionOf(id)` gives for the same document (roadmap CLI-77). The storage
|
|
226
|
+
* uses it too, so the two never differ.
|
|
227
|
+
*
|
|
228
|
+
* - The version is the sequence number of the last write through the storage (`_seq`), as text.
|
|
229
|
+
* - A document without `_seq` (an old document, or one that a raw replace wrote) has the version `0`.
|
|
230
|
+
* - A tombstone, a value that is not a plain object, and a document whose id neither `idOf` nor
|
|
231
|
+
* `_key` tells give `undefined`: they are no items, as for `decodeStoredDocument`.
|
|
232
|
+
*
|
|
233
|
+
* @param doc - The stored document, for example the `fullDocument` of a change event
|
|
234
|
+
* @param form - The stored form of the storage, for example `storage.form` (default `DEFAULT_STORED_FORM`)
|
|
235
|
+
* @param partition - The partition of the document. The default is `form.partitionOf(doc)`.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* const version = versionOfStored(change.fullDocument, notes.form); // the same as await notes.versionOf(id)
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
export declare function versionOfStored(doc: Document, form?: StoredForm, partition?: string): string | undefined;
|
|
243
|
+
/**
|
|
244
|
+
* The parts of a storage that `watchStorageChanges` reads (roadmap CLI-77). The package does not
|
|
245
|
+
* export this type: it is for the modules of the storage.
|
|
246
|
+
*/
|
|
247
|
+
export interface StorageChangeSource {
|
|
248
|
+
/** The database of the storage. */
|
|
249
|
+
db(): Promise<Db>;
|
|
250
|
+
/** The MongoDB collection of the items. */
|
|
251
|
+
collection: string;
|
|
252
|
+
/** The collection of the sequence counters. */
|
|
253
|
+
counters: string;
|
|
254
|
+
/** The stored form. */
|
|
255
|
+
form: StoredForm;
|
|
256
|
+
/** The partition of the storage, or undefined for the storage of the whole collection. */
|
|
257
|
+
partition: string | undefined;
|
|
258
|
+
/** This method adopts a raw write (D39): see `RawStorageWrite`. */
|
|
259
|
+
adopt(raw: RawStorageWrite): Promise<RawAdoption>;
|
|
260
|
+
/**
|
|
261
|
+
* This method adopts several raw writes: the writes of each partition take one block of numbers.
|
|
262
|
+
* A partition whose writes fail gives `{ error }` for each of its writes.
|
|
263
|
+
*/
|
|
264
|
+
adoptAll(raws: readonly RawStorageWrite[]): Promise<RawAdoptionResult[]>;
|
|
265
|
+
/**
|
|
266
|
+
* One page of the documents without `_seq` (the sweep of the raw writes), in the order of `_id`,
|
|
267
|
+
* after the `_id` of `after` (from the start without it).
|
|
268
|
+
*/
|
|
269
|
+
rawDocuments(after: {
|
|
270
|
+
readonly id: unknown;
|
|
271
|
+
} | undefined, limit: number): Promise<Document[]>;
|
|
272
|
+
/** The stored documents of these stored `_id`s: the watcher adopts a raw write again after a full queue or a failure. */
|
|
273
|
+
storedDocuments(ids: readonly unknown[]): Promise<Document[]>;
|
|
274
|
+
/**
|
|
275
|
+
* The partitions that the storage knows: each partition with a floor document in the counters
|
|
276
|
+
* (the first write of a storage and each prune write one), and each partition of
|
|
277
|
+
* `forPartition()` in this process. It rejects when the counters cannot be read.
|
|
278
|
+
*/
|
|
279
|
+
partitions(): Promise<Array<string | undefined>>;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* A raw write of the collection (D39): a change event of a document that the storage did not write.
|
|
283
|
+
* The storage adopts it: one conditional write gives the document a new `_seq` through the path of
|
|
284
|
+
* each write (the transaction, or the watermark and the late move), so `changes(since)` has it.
|
|
285
|
+
*
|
|
286
|
+
* - The filter is the stored `_id` and the `_seq` that the event saw (or no `_seq`): when the
|
|
287
|
+
* document changed since (a later adoption, or a write of the storage), the adoption does
|
|
288
|
+
* nothing. Thus one adoption wins.
|
|
289
|
+
* - The adoption sets `_seq`, and the storage fields and partition fields that the document does
|
|
290
|
+
* not have: from the image before the change, else from the stored `_id` (`form.idOf()`,
|
|
291
|
+
* `form.partitionOf()`). It never changes a field of the item.
|
|
292
|
+
* - A hard delete (no `after`) needs the image before the change: the adoption inserts a tombstone
|
|
293
|
+
* with a new `_seq`, and the insert fails when the `_id` exists again.
|
|
294
|
+
* - The numbers of an adoption are never noted as numbers of this process: its change event is
|
|
295
|
+
* the hint of the raw write.
|
|
296
|
+
*/
|
|
297
|
+
export interface RawStorageWrite {
|
|
298
|
+
/** The stored `_id` of the document (`documentKey._id`). */
|
|
299
|
+
readonly storedId: unknown;
|
|
300
|
+
/** The `_seq` of the state that the event saw, or undefined for a document without `_seq`. */
|
|
301
|
+
readonly seq: number | undefined;
|
|
302
|
+
/** The document after the write, or undefined for a hard delete. */
|
|
303
|
+
readonly after?: Document | undefined;
|
|
304
|
+
/** The image of the document before the change, when the collection keeps it (`changeStreamPreAndPostImages`). */
|
|
305
|
+
readonly before?: Document | undefined;
|
|
306
|
+
}
|
|
307
|
+
/** The result of an adoption: `adopted`, `lost` (the document changed since: another adoption or write won), or `unknown` (no image and no stored `_id` tells the id and the partition). */
|
|
308
|
+
export type RawAdoption = "adopted" | "lost" | "unknown";
|
|
309
|
+
/** The result of one raw write of `adoptAll()`: a `RawAdoption`, or the error of the write of its partition. */
|
|
310
|
+
export type RawAdoptionResult = RawAdoption | {
|
|
311
|
+
readonly error: unknown;
|
|
312
|
+
};
|
|
313
|
+
/** This function gives the parts of a storage that `watchStorageChanges` reads. The package does not export it. */
|
|
314
|
+
export declare function storageChangeSource<T>(storage: MongoDocumentStorage<T>): StorageChangeSource;
|
|
223
315
|
/** The options of `selectorPrefilter`. */
|
|
224
316
|
export interface SelectorPrefilterOptions {
|
|
225
317
|
/**
|
|
@@ -263,6 +355,8 @@ export declare class MongoDocumentStorage<T> implements CollectionStorage<T> {
|
|
|
263
355
|
/** The fields that only the storage writes: its fields and the partition fields. */
|
|
264
356
|
private readonly reserved;
|
|
265
357
|
private indexes;
|
|
358
|
+
/** True after this storage wrote (or found) the floor document of its partition (roadmap O66). A failed write leaves it false. */
|
|
359
|
+
private floorNoted;
|
|
266
360
|
private closed;
|
|
267
361
|
constructor(options: MongoDocumentStorageOptions<T>, partitions?: Map<string, MongoDocumentStorage<T>>);
|
|
268
362
|
/** The storage of a partition of the same collection. It gives the same storage for the same partition. */
|
|
@@ -316,7 +410,8 @@ export declare class MongoDocumentStorage<T> implements CollectionStorage<T> {
|
|
|
316
410
|
/**
|
|
317
411
|
* This method takes numbers and writes with them. On a replica set, the two are one
|
|
318
412
|
* transaction. Else the numbers stay pending until the write ends, and a late write moves its
|
|
319
|
-
* documents to new numbers.
|
|
413
|
+
* documents to new numbers. With `own` false (an adoption of a raw write, D39), a watcher of this
|
|
414
|
+
* process does not take the numbers as its own.
|
|
320
415
|
*/
|
|
321
416
|
private withNumbers;
|
|
322
417
|
/**
|
|
@@ -326,6 +421,22 @@ export declare class MongoDocumentStorage<T> implements CollectionStorage<T> {
|
|
|
326
421
|
private watermark;
|
|
327
422
|
/** The id of the document of the oldest kept change of the partition. */
|
|
328
423
|
private floorId;
|
|
424
|
+
/**
|
|
425
|
+
* This method writes the floor document of the partition once for this storage, before its first
|
|
426
|
+
* write (roadmap O66). Then `knownPartitions()` of each process finds the partition, also without
|
|
427
|
+
* a prune, and a gap of `watchStorageChanges()` sends it a reset hint.
|
|
428
|
+
*
|
|
429
|
+
* - The floor `0` is neutral: `getChangesSince` gives a full result only for a version below the
|
|
430
|
+
* floor, and a version is never below `0`. A missing floor document also reads as `0`. So the
|
|
431
|
+
* document changes no result of the change log.
|
|
432
|
+
* - `$setOnInsert` writes only a new document: a floor of a prune (`$max`) stays as it is.
|
|
433
|
+
* - A duplicate key (another process inserted the same document first) is a success.
|
|
434
|
+
* - The upsert runs in the queue of the writes, before the task, so never in the transaction of
|
|
435
|
+
* `withNumbers()`: it adds no write conflict to the transaction of the user, and a transaction
|
|
436
|
+
* that tries again does not write it again.
|
|
437
|
+
* - A failure does not fail the write of the user. The flag stays false, so the next write tries again.
|
|
438
|
+
*/
|
|
439
|
+
private noteFloor;
|
|
329
440
|
/** This method drops the oldest tombstones of the partition over the limit, and keeps the floor of the log. */
|
|
330
441
|
private pruneTombstones;
|
|
331
442
|
/** The ids of stored documents, in their order. A document that does not tell its id is left out. */
|
|
@@ -356,7 +467,8 @@ export declare class MongoDocumentStorage<T> implements CollectionStorage<T> {
|
|
|
356
467
|
}>;
|
|
357
468
|
/**
|
|
358
469
|
* The version of an item: the sequence number of its last write, or undefined for a missing id.
|
|
359
|
-
* An item without a write through the storage (no `_seq`) has the version `0`.
|
|
470
|
+
* An item without a write through the storage (no `_seq`) has the version `0`. It is the version
|
|
471
|
+
* of `versionOfStored()` of the stored document (roadmap CLI-77): the two share one rule.
|
|
360
472
|
*/
|
|
361
473
|
versionOf(id: string): Promise<string | undefined>;
|
|
362
474
|
getChangesSince(since?: string): Promise<StorageChanges<T>>;
|
|
@@ -380,6 +492,53 @@ export declare class MongoDocumentStorage<T> implements CollectionStorage<T> {
|
|
|
380
492
|
* collection. With preconditions, it tests them first (roadmap CLI-16).
|
|
381
493
|
*/
|
|
382
494
|
private tombstone;
|
|
495
|
+
/**
|
|
496
|
+
* This method adopts a raw write: one conditional write through the path of each write gives the
|
|
497
|
+
* document a new `_seq` (see `RawStorageWrite`). It is for `watchStorageChanges()`, and it is no
|
|
498
|
+
* general setter of `_seq`.
|
|
499
|
+
*/
|
|
500
|
+
private adoptRaw;
|
|
501
|
+
/**
|
|
502
|
+
* This method adopts several raw writes. The writes of each partition take one block of numbers
|
|
503
|
+
* through the path of each write. A number of a write that does not win stays unused.
|
|
504
|
+
*/
|
|
505
|
+
private adoptRawAll;
|
|
506
|
+
/** The adoption of raw writes of this partition, with one block of numbers. */
|
|
507
|
+
private adoptGroup;
|
|
508
|
+
/** A raw hard delete: a tombstone with the id and the partition of the image before the change. */
|
|
509
|
+
private adoptDelete;
|
|
510
|
+
/** A raw insert, replace or update: one conditional write on the exact state of the event. */
|
|
511
|
+
private adoptWrite;
|
|
512
|
+
/** One page of the documents without `_seq`, in the order of `_id` (the sweep of `watchStorageChanges()`). */
|
|
513
|
+
private rawDocuments;
|
|
514
|
+
/** The stored documents of these stored `_id`s, for the adoptions that `watchStorageChanges()` does again. */
|
|
515
|
+
private storedDocuments;
|
|
516
|
+
/**
|
|
517
|
+
* The storage of the partition of a raw write and the id of its document, or undefined when
|
|
518
|
+
* neither the documents of the event nor the stored `_id` tell them. The partition comes from
|
|
519
|
+
* `form.partitionOf()` of the image before the change, else of the document after the write,
|
|
520
|
+
* else of the stored `_id` (the order of `storageChangeOf()`). The document must not have a
|
|
521
|
+
* partition field with another value.
|
|
522
|
+
*/
|
|
523
|
+
private adoptionTarget;
|
|
524
|
+
/** True when each partition field of a document has the value of this partition, or is absent (a raw replace can drop it). */
|
|
525
|
+
private holds;
|
|
526
|
+
/**
|
|
527
|
+
* The storage fields and the partition fields that a raw write took from the document, for the
|
|
528
|
+
* adoption to set again. No field of the item is in it.
|
|
529
|
+
*
|
|
530
|
+
* - The partition fields of this partition that the document does not have.
|
|
531
|
+
* - `_key` (with `_kid`) of the image before the change. Without the image, `_key` only when
|
|
532
|
+
* `form.idOf()` does not tell the id, with `_kid`: the item keeps its `_id`, as a document from
|
|
533
|
+
* outside the storage.
|
|
534
|
+
* - `_ord` of the image before the change, else `0`, the place of a document without `_ord`
|
|
535
|
+
* (the rule of the old documents).
|
|
536
|
+
* - The names of `_kpf` of the image before the change that the document has with the value of
|
|
537
|
+
* the partition.
|
|
538
|
+
*/
|
|
539
|
+
private restoredFields;
|
|
540
|
+
/** The partitions that the storage knows: the floor documents of the counters (of the first writes and of the prunes), and the storages of `forPartition()`. */
|
|
541
|
+
private knownPartitions;
|
|
383
542
|
/**
|
|
384
543
|
* The preconditions of a write (roadmap CLI-16), after a check of their ids. A storage without
|
|
385
544
|
* `versionOf` throws a `TypeError` before the write starts.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-storage.d.ts","sourceRoot":"","sources":["../../src/storage/document-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AAIH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"document-storage.d.ts","sourceRoot":"","sources":["../../src/storage/document-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AAIH,OAAO,EAAyE,KAAK,EAAE,EAAE,KAAK,QAAQ,EAAe,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AACvJ,OAAO,EAML,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAEzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAoB,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAGrE,OAAO,EAAqE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAe7H,mEAAmE;AACnE,eAAO,MAAM,SAAS,WAAW,CAAC;AAElC;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAA+E,CAAC;AAErI,8HAA8H;AAC9H,eAAO,MAAM,eAAe,EAAE,OAAc,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7D,kHAAkH;IAClH,IAAI,CAAC,QAAQ,EAAE,OAA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