@procedures/mongo 0.15.0 → 0.15.1

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/dist/index.d.ts CHANGED
@@ -35,4 +35,6 @@ export * from "./procedures/index.js";
35
35
  export type { Db, Collection, Document, ObjectId, Filter, UpdateFilter, FindOptions, AggregateOptions, } from "mongodb";
36
36
  export { ViewMaterializer, identityPartition, partitionTargetId, viewFilter, VIEW_GENERATION_FIELD, VIEW_HASH_FIELD } from "./storage/index.js";
37
37
  export type { MaterializedView, MaterializedViewStatus, ViewMaterializerOptions, ViewPartitionOf, ViewPipelineScope, ViewTargetId } from "./storage/index.js";
38
+ export { MongoViewStorage } from "./storage/index.js";
39
+ export type { MongoViewStorageOptions } from "./storage/index.js";
38
40
  //# sourceMappingURL=index.d.ts.map
@@ -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,E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AiB,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,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
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,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HANGED
@@ -46,4 +46,6 @@ export { registerMongoProcedures, procedures } from "./module.js";
46
46
  export * from "./procedures/index.js";
47
47
  // Materialized views driven by change streams (Graph's split plan, P4)
48
48
  export { ViewMaterializer, identityPartition, partitionTargetId, viewFilter, VIEW_GENERATION_FIELD, VIEW_HASH_FIELD } from "./storage/index.js";
49
+ // A read-only storage of a view for the collection procedures: one generation for each read (roadmap CLI-38)
50
+ export { MongoViewStorage } from "./storage/index.js";
49
51
  //# sourceMappingURL=index.js.map
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,EAAE,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE3F,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;AAg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@ -9,4 +9,6 @@ export { BLOCKED_PIPELINE_OPERATORS, ALLOWED_PIPELINE_STAGES, DEFAULT_PIPELINE_L
9
9
  export type { PipelineLimits, PipelineScope } from "./pipeline-scope.js";
10
10
  export { ViewMaterializer, identityPartition, partitionTargetId, viewFilter, VIEW_GENERATION_FIELD, VIEW_HASH_FIELD } from "./materializer.js";
11
11
  export type { MaterializedView, MaterializedViewStatus, ViewMaterializerOptions, ViewPartitionOf, ViewPipelineScope, ViewTargetId } from "./materializer.js";
12
+ export { MongoViewStorage } from "./view-storage.js";
13
+ export type { MongoViewStorageOptions } from "./view-storage.js";
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAChF,YAAY,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/I,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,eAAe,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAChF,YAAY,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/I,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,eAAe,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE7J,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,YAAY,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -6,4 +6,6 @@ export { MongoDocumentStorage, selectorPrefilter } from "./document-storage.js";
6
6
  export { BLOCKED_PIPELINE_OPERATORS, ALLOWED_PIPELINE_STAGES, DEFAULT_PIPELINE_LIMITS, assertNoBlockedOperators, boundPipeline, cutResults, isTimeLimitError, scopePipeline, } from "./pipeline-scope.js";
7
7
  // Materialized views driven by change streams (Graph's split plan, P4)
8
8
  export { ViewMaterializer, identityPartition, partitionTargetId, viewFilter, VIEW_GENERATION_FIELD, VIEW_HASH_FIELD } from "./materializer.js";
9
+ // A read-only storage of a view for the collection procedures: one generation for each read (roadmap CLI-38)
10
+ export { MongoViewStorage } from "./view-storage.js";
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,uEAAuE;AACvE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,uEAAuE;AACvE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE/I,6GAA6G;AAC7G,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * `MongoViewStorage`: the rows of one materialized view as a read-only `CollectionStorage`
3
+ * (roadmap CLI-38). The collection procedures can then serve a view, and each reader of them gets
4
+ * one whole generation.
5
+ *
6
+ * A `ViewMaterializer` writes a big rebuild as a new generation in groups. Then it changes the
7
+ * generation in the status of the view. During the rebuild, the target has the rows of two
8
+ * generations, and a plain query reads both. This storage reads the status of the view one time
9
+ * for each operation, and reads only the rows of that generation (`viewFilter`). Thus `get`,
10
+ * `getAll`, `find`, `changes` and the other reads of the procedures do not mix two generations.
11
+ *
12
+ * - The key of a row is the `_id` of the row in the result of the pipeline. It must be a text.
13
+ * - The value of a row is the row of the result: its `_id` and its fields, without the fields of
14
+ * the materializer (the partition, `_viewGen` and `_viewHash`).
15
+ * - The storage has no change log. The procedure `changes` thus gives all the rows of the current
16
+ * generation.
17
+ * - A read that starts before a change of generation ends on the previous generation. The
18
+ * materializer keeps its rows for `generationGrace`, so a read must end in that time.
19
+ * - Before the first pass of the view, and without the view document, the storage has no row.
20
+ * - Only the materializer writes a target. Each write of this storage rejects with `FORBIDDEN`.
21
+ */
22
+ import type { Db, Document } from "mongodb";
23
+ import type { CollectionStorage, StorageMetadata } from "@procedures/collections";
24
+ import { type ViewTargetId } from "./materializer.js";
25
+ /** The options of a `MongoViewStorage`. Give the same names as to the `ViewMaterializer` of the view. */
26
+ export interface MongoViewStorageOptions {
27
+ /** The `_id` of the document of the view. The document names the partition and the target. */
28
+ view: string;
29
+ /** The database of the views and of the target. The default is the database of the default connection, for each operation. */
30
+ db?: (() => Db | Promise<Db>) | undefined;
31
+ /** The collection of the view documents (default `_aggregations`). */
32
+ views?: string | undefined;
33
+ /** The field of a document that names its partition (default `_part`). */
34
+ partitionField?: string | undefined;
35
+ /** The field of a view document that keeps its status (default `_materializerStatus`). */
36
+ statusField?: string | undefined;
37
+ /**
38
+ * The stored `_id` of a row from its key, the partition and the generation (default
39
+ * `partitionTargetId`). It is the option `targetId` of the materializer. `get`, `has` and
40
+ * `getBatch` find a row with it.
41
+ */
42
+ targetId?: ViewTargetId | undefined;
43
+ /**
44
+ * The `_id` of the row in the result, from its stored `_id`. It reverses `targetId`. The default
45
+ * reads the field `id` of the form of `partitionTargetId`.
46
+ */
47
+ rowIdOf?: ((storedId: unknown) => unknown) | undefined;
48
+ }
49
+ /**
50
+ * A read-only `CollectionStorage` over the target of one materialized view (roadmap CLI-38). Each
51
+ * read gives the rows of the current generation of the view only.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const server = new ProcedureServer({ collections: { totals: new MongoViewStorage({ view: "totals", db: () => db }) } });
56
+ * server.registerCollectionProcedures("totals");
57
+ * ```
58
+ */
59
+ export declare class MongoViewStorage<T = Document> implements CollectionStorage<T> {
60
+ private readonly options;
61
+ private readonly viewsName;
62
+ private readonly partitionField;
63
+ private readonly statusField;
64
+ private readonly targetId;
65
+ private readonly rowIdOf;
66
+ private closed;
67
+ constructor(options: MongoViewStorageOptions);
68
+ /**
69
+ * The current generation of the view: one read of the view document. Each read of the storage
70
+ * uses one generation, so it gives the rows of one generation only. The result is undefined
71
+ * before the first pass of the view, or without the view document.
72
+ */
73
+ private current;
74
+ /** The stored `_id` of a key in a generation. */
75
+ private storedId;
76
+ /** The key and the value of a stored row. A row whose `_id` is not a text cannot have a key. */
77
+ private decode;
78
+ /** The rows of the current generation, in the order of their stored `_id`. */
79
+ private entriesOf;
80
+ get(id: string): Promise<T | undefined>;
81
+ getAll(): Promise<T[]>;
82
+ getEntries(): Promise<Array<[string, T]>>;
83
+ getIds(): Promise<string[]>;
84
+ find(predicate: (item: T) => boolean): Promise<T[]>;
85
+ has(id: string): Promise<boolean>;
86
+ size(): Promise<number>;
87
+ getBatch(ids: string[]): Promise<Map<string, T>>;
88
+ private readOnly;
89
+ set(_id: string, _value: T): Promise<void>;
90
+ setBatch(_items: Array<[string, T]>): Promise<void>;
91
+ delete(_id: string): Promise<boolean>;
92
+ deleteBatch(_ids: string[]): Promise<number>;
93
+ clear(): Promise<void>;
94
+ /** This method closes the storage. After it, each operation rejects, and a second `close()` does nothing. */
95
+ close(): Promise<void>;
96
+ private checkOpen;
97
+ getMetadata(): Promise<StorageMetadata>;
98
+ }
99
+ //# sourceMappingURL=view-storage.d.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O,CAAC,MAAM,CAAC,CAEjD;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAMD,6GAA6G;IACvG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED,OAAO,CAAC,SAAS;IAIX,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC,CAE5C;CACF"}
@@ -0,0 +1,189 @@
1
+ /**
2
+ * `MongoViewStorage`: the rows of one materialized view as a read-only `CollectionStorage`
3
+ * (roadmap CLI-38). The collection procedures can then serve a view, and each reader of them gets
4
+ * one whole generation.
5
+ *
6
+ * A `ViewMaterializer` writes a big rebuild as a new generation in groups. Then it changes the
7
+ * generation in the status of the view. During the rebuild, the target has the rows of two
8
+ * generations, and a plain query reads both. This storage reads the status of the view one time
9
+ * for each operation, and reads only the rows of that generation (`viewFilter`). Thus `get`,
10
+ * `getAll`, `find`, `changes` and the other reads of the procedures do not mix two generations.
11
+ *
12
+ * - The key of a row is the `_id` of the row in the result of the pipeline. It must be a text.
13
+ * - The value of a row is the row of the result: its `_id` and its fields, without the fields of
14
+ * the materializer (the partition, `_viewGen` and `_viewHash`).
15
+ * - The storage has no change log. The procedure `changes` thus gives all the rows of the current
16
+ * generation.
17
+ * - A read that starts before a change of generation ends on the previous generation. The
18
+ * materializer keeps its rows for `generationGrace`, so a read must end in that time.
19
+ * - Before the first pass of the view, and without the view document, the storage has no row.
20
+ * - Only the materializer writes a target. Each write of this storage rejects with `FORBIDDEN`.
21
+ */
22
+ import { ensureConnection } from "../connection.js";
23
+ import { partitionTargetId, viewFilter, VIEW_GENERATION_FIELD, VIEW_HASH_FIELD } from "./materializer.js";
24
+ /** The `_id` of a row in the result, from the stored `_id` of `partitionTargetId`. */
25
+ function defaultRowId(storedId) {
26
+ return typeof storedId === "object" && storedId !== null && "id" in storedId ? storedId.id : storedId;
27
+ }
28
+ /**
29
+ * A read-only `CollectionStorage` over the target of one materialized view (roadmap CLI-38). Each
30
+ * read gives the rows of the current generation of the view only.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const server = new ProcedureServer({ collections: { totals: new MongoViewStorage({ view: "totals", db: () => db }) } });
35
+ * server.registerCollectionProcedures("totals");
36
+ * ```
37
+ */
38
+ export class MongoViewStorage {
39
+ options;
40
+ viewsName;
41
+ partitionField;
42
+ statusField;
43
+ targetId;
44
+ rowIdOf;
45
+ closed = false;
46
+ constructor(options) {
47
+ if (typeof options.view !== "string" || options.view === "")
48
+ throw new Error("A MongoViewStorage needs the _id of its view");
49
+ this.options = options;
50
+ this.viewsName = options.views ?? "_aggregations";
51
+ this.partitionField = options.partitionField ?? "_part";
52
+ this.statusField = options.statusField ?? "_materializerStatus";
53
+ this.targetId = options.targetId ?? partitionTargetId;
54
+ this.rowIdOf = options.rowIdOf ?? defaultRowId;
55
+ }
56
+ // ===========================================================================
57
+ // The generation of a read
58
+ // ===========================================================================
59
+ /**
60
+ * The current generation of the view: one read of the view document. Each read of the storage
61
+ * uses one generation, so it gives the rows of one generation only. The result is undefined
62
+ * before the first pass of the view, or without the view document.
63
+ */
64
+ async current() {
65
+ this.checkOpen();
66
+ const db = this.options.db ? await this.options.db() : (await ensureConnection()).getDb();
67
+ const view = (await db.collection(this.viewsName).findOne({ _id: this.options.view }));
68
+ if (!view || typeof view.targetCollection !== "string")
69
+ return undefined;
70
+ const partition = view[this.partitionField];
71
+ const generation = view[this.statusField]?.generation;
72
+ if (typeof partition !== "string" || !generation)
73
+ return undefined;
74
+ return {
75
+ target: db.collection(view.targetCollection),
76
+ filter: viewFilter(view, { partitionField: this.partitionField, statusField: this.statusField }),
77
+ partition,
78
+ generation,
79
+ };
80
+ }
81
+ /** The stored `_id` of a key in a generation. */
82
+ storedId(id, generation) {
83
+ return this.targetId(id, generation.partition, generation.generation);
84
+ }
85
+ /** The key and the value of a stored row. A row whose `_id` is not a text cannot have a key. */
86
+ decode(doc) {
87
+ const { _id: storedId, [this.partitionField]: _partition, [VIEW_GENERATION_FIELD]: _generation, [VIEW_HASH_FIELD]: _hash, ...content } = doc;
88
+ const id = this.rowIdOf(storedId);
89
+ if (typeof id !== "string") {
90
+ throw new Error(`A row of the view ${this.options.view} has an _id that is not a text: give each row of its result a text _id`);
91
+ }
92
+ const value = { _id: id, ...content };
93
+ return [id, value];
94
+ }
95
+ /** The rows of the current generation, in the order of their stored `_id`. */
96
+ async entriesOf(extra) {
97
+ const generation = await this.current();
98
+ if (!generation)
99
+ return [];
100
+ const docs = await generation.target
101
+ .find({ ...generation.filter, ...extra })
102
+ .sort({ _id: 1 })
103
+ .toArray();
104
+ return docs.map((doc) => this.decode(doc));
105
+ }
106
+ // ===========================================================================
107
+ // Reads
108
+ // ===========================================================================
109
+ async get(id) {
110
+ const generation = await this.current();
111
+ if (!generation)
112
+ return undefined;
113
+ const doc = await generation.target.findOne({ ...generation.filter, _id: this.storedId(id, generation) });
114
+ return doc ? this.decode(doc)[1] : undefined;
115
+ }
116
+ async getAll() {
117
+ return (await this.entriesOf()).map(([, value]) => value);
118
+ }
119
+ async getEntries() {
120
+ return this.entriesOf();
121
+ }
122
+ async getIds() {
123
+ return (await this.entriesOf()).map(([id]) => id);
124
+ }
125
+ async find(predicate) {
126
+ return (await this.getAll()).filter(predicate);
127
+ }
128
+ async has(id) {
129
+ const generation = await this.current();
130
+ if (!generation)
131
+ return false;
132
+ return (await generation.target.countDocuments({ ...generation.filter, _id: this.storedId(id, generation) }, { limit: 1 })) > 0;
133
+ }
134
+ async size() {
135
+ const generation = await this.current();
136
+ if (!generation)
137
+ return 0;
138
+ return generation.target.countDocuments(generation.filter);
139
+ }
140
+ async getBatch(ids) {
141
+ const result = new Map();
142
+ const generation = await this.current();
143
+ if (!generation || ids.length === 0)
144
+ return result;
145
+ const byId = new Map(await this.entriesOf({ _id: { $in: ids.map((id) => this.storedId(id, generation)) } }));
146
+ // The order of the ids of the call
147
+ for (const id of ids)
148
+ if (byId.has(id))
149
+ result.set(id, byId.get(id));
150
+ return result;
151
+ }
152
+ // ===========================================================================
153
+ // Writes: only the materializer writes a target
154
+ // ===========================================================================
155
+ readOnly() {
156
+ this.checkOpen();
157
+ return Promise.reject(Object.assign(new Error(`The view ${this.options.view} is read-only: only its materializer writes its target`), { code: "FORBIDDEN", retryable: false }));
158
+ }
159
+ async set(_id, _value) {
160
+ return this.readOnly();
161
+ }
162
+ async setBatch(_items) {
163
+ return this.readOnly();
164
+ }
165
+ async delete(_id) {
166
+ return this.readOnly();
167
+ }
168
+ async deleteBatch(_ids) {
169
+ return this.readOnly();
170
+ }
171
+ async clear() {
172
+ return this.readOnly();
173
+ }
174
+ // ===========================================================================
175
+ // The life of the storage
176
+ // ===========================================================================
177
+ /** This method closes the storage. After it, each operation rejects, and a second `close()` does nothing. */
178
+ async close() {
179
+ this.closed = true;
180
+ }
181
+ checkOpen() {
182
+ if (this.closed)
183
+ throw new Error(`The MongoViewStorage of the view ${this.options.view} is closed`);
184
+ }
185
+ async getMetadata() {
186
+ return { type: "custom", size: await this.size(), stats: { view: this.options.view } };
187
+ }
188
+ }
189
+ //# sourceMappingURL=view-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-storage.js","sourceRoot":"","sources":["../../src/storage/view-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,qBAAqB,EAAE,eAAe,EAAyE,MAAM,mBAAmB,CAAC;AAmCjL,sFAAsF;AACtF,SAAS,YAAY,CAAC,QAAiB;IACrC,OAAO,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,IAAI,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAE,QAA4B,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC7H,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,gBAAgB;IACV,OAAO,CAA0B;IACjC,SAAS,CAAS;IAClB,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GAA6G;IAC7G,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAEO,SAAS;QACf,IAAI,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,CAAC,OAAO,CAAC,IAAI,YAAY,CAAC,CAAC;IACtG,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;IACzF,CAAC;CACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@procedures/mongo",
4
- "version": "0.15.0",
4
+ "version": "0.15.1",
5
5
  "description": "MongoDB as typed procedures: documents, bulk writes, distinct, explain, collections, indexes, aggregation, change streams and database info, with safe update and delete targets.",
6
6
  "keywords": [
7
7
  "mongodb",
@@ -72,8 +72,8 @@
72
72
  "procedures": "./dist/register.js"
73
73
  },
74
74
  "dependencies": {
75
- "@procedures/client": "0.15.0",
76
- "@procedures/collections": "0.15.0",
75
+ "@procedures/client": "0.15.1",
76
+ "@procedures/collections": "0.15.1",
77
77
  "mongodb": "^7.0.0",
78
78
  "zod": "^4.6.5"
79
79
  },
package/src/index.ts CHANGED
@@ -182,3 +182,6 @@ export type {
182
182
  // Materialized views driven by change streams (Graph's split plan, P4)
183
183
  export { ViewMaterializer, identityPartition, partitionTargetId, viewFilter, VIEW_GENERATION_FIELD, VIEW_HASH_FIELD } from "./storage/index.js";
184
184
  export type { MaterializedView, MaterializedViewStatus, ViewMaterializerOptions, ViewPartitionOf, ViewPipelineScope, ViewTargetId } from "./storage/index.js";
185
+ // A read-only storage of a view for the collection procedures: one generation for each read (roadmap CLI-38)
186
+ export { MongoViewStorage } from "./storage/index.js";
187
+ export type { MongoViewStorageOptions } from "./storage/index.js";
@@ -20,3 +20,6 @@ export type { PipelineLimits, PipelineScope } from "./pipeline-scope.js";
20
20
  // Materialized views driven by change streams (Graph's split plan, P4)
21
21
  export { ViewMaterializer, identityPartition, partitionTargetId, viewFilter, VIEW_GENERATION_FIELD, VIEW_HASH_FIELD } from "./materializer.js";
22
22
  export type { MaterializedView, MaterializedViewStatus, ViewMaterializerOptions, ViewPartitionOf, ViewPipelineScope, ViewTargetId } from "./materializer.js";
23
+ // A read-only storage of a view for the collection procedures: one generation for each read (roadmap CLI-38)
24
+ export { MongoViewStorage } from "./view-storage.js";
25
+ export type { MongoViewStorageOptions } from "./view-storage.js";