@procedures/mongo 0.33.0 → 0.35.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +34 -5
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/index.d.ts +3 -3
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/procedures/collections.create.d.ts.map +1 -1
  9. package/dist/procedures/collections.create.js +5 -5
  10. package/dist/procedures/collections.create.js.map +1 -1
  11. package/dist/procedures/collections.drop.d.ts.map +1 -1
  12. package/dist/procedures/collections.drop.js +5 -5
  13. package/dist/procedures/collections.drop.js.map +1 -1
  14. package/dist/procedures/collections.list.d.ts.map +1 -1
  15. package/dist/procedures/collections.list.js +4 -4
  16. package/dist/procedures/collections.list.js.map +1 -1
  17. package/dist/procedures/collections.stats.d.ts.map +1 -1
  18. package/dist/procedures/collections.stats.js +4 -4
  19. package/dist/procedures/collections.stats.js.map +1 -1
  20. package/dist/procedures/database.info.d.ts.map +1 -1
  21. package/dist/procedures/database.info.js +4 -4
  22. package/dist/procedures/database.info.js.map +1 -1
  23. package/dist/procedures/database.ping.d.ts.map +1 -1
  24. package/dist/procedures/database.ping.js +4 -4
  25. package/dist/procedures/database.ping.js.map +1 -1
  26. package/dist/procedures/documents.aggregate.d.ts.map +1 -1
  27. package/dist/procedures/documents.aggregate.js +5 -5
  28. package/dist/procedures/documents.aggregate.js.map +1 -1
  29. package/dist/procedures/documents.bulk.d.ts.map +1 -1
  30. package/dist/procedures/documents.bulk.js +3 -3
  31. package/dist/procedures/documents.bulk.js.map +1 -1
  32. package/dist/procedures/documents.count.d.ts.map +1 -1
  33. package/dist/procedures/documents.count.js +5 -5
  34. package/dist/procedures/documents.count.js.map +1 -1
  35. package/dist/procedures/documents.delete.d.ts.map +1 -1
  36. package/dist/procedures/documents.delete.js +3 -3
  37. package/dist/procedures/documents.delete.js.map +1 -1
  38. package/dist/procedures/documents.distinct.d.ts.map +1 -1
  39. package/dist/procedures/documents.distinct.js +5 -5
  40. package/dist/procedures/documents.distinct.js.map +1 -1
  41. package/dist/procedures/documents.explain.d.ts.map +1 -1
  42. package/dist/procedures/documents.explain.js +3 -3
  43. package/dist/procedures/documents.explain.js.map +1 -1
  44. package/dist/procedures/documents.find.d.ts.map +1 -1
  45. package/dist/procedures/documents.find.js +3 -3
  46. package/dist/procedures/documents.find.js.map +1 -1
  47. package/dist/procedures/documents.get.d.ts.map +1 -1
  48. package/dist/procedures/documents.get.js +3 -3
  49. package/dist/procedures/documents.get.js.map +1 -1
  50. package/dist/procedures/documents.insert.d.ts.map +1 -1
  51. package/dist/procedures/documents.insert.js +5 -5
  52. package/dist/procedures/documents.insert.js.map +1 -1
  53. package/dist/procedures/documents.update.d.ts.map +1 -1
  54. package/dist/procedures/documents.update.js +3 -3
  55. package/dist/procedures/documents.update.js.map +1 -1
  56. package/dist/procedures/indexes.create.d.ts.map +1 -1
  57. package/dist/procedures/indexes.create.js +5 -5
  58. package/dist/procedures/indexes.create.js.map +1 -1
  59. package/dist/procedures/indexes.drop.d.ts.map +1 -1
  60. package/dist/procedures/indexes.drop.js +5 -5
  61. package/dist/procedures/indexes.drop.js.map +1 -1
  62. package/dist/procedures/indexes.list.d.ts.map +1 -1
  63. package/dist/procedures/indexes.list.js +4 -4
  64. package/dist/procedures/indexes.list.js.map +1 -1
  65. package/dist/procedures/watch.d.ts.map +1 -1
  66. package/dist/procedures/watch.js +3 -3
  67. package/dist/procedures/watch.js.map +1 -1
  68. package/dist/storage/document-storage.d.ts +177 -8
  69. package/dist/storage/document-storage.d.ts.map +1 -1
  70. package/dist/storage/document-storage.js +383 -72
  71. package/dist/storage/document-storage.js.map +1 -1
  72. package/dist/storage/index.d.ts +3 -3
  73. package/dist/storage/index.d.ts.map +1 -1
  74. package/dist/storage/index.js +2 -1
  75. package/dist/storage/index.js.map +1 -1
  76. package/dist/storage/materializer.d.ts +27 -12
  77. package/dist/storage/materializer.d.ts.map +1 -1
  78. package/dist/storage/materializer.js +37 -15
  79. package/dist/storage/materializer.js.map +1 -1
  80. package/package.json +3 -3
  81. package/src/index.ts +11 -3
  82. package/src/procedures/collections.create.ts +5 -9
  83. package/src/procedures/collections.drop.ts +5 -9
  84. package/src/procedures/collections.list.ts +4 -8
  85. package/src/procedures/collections.stats.ts +4 -8
  86. package/src/procedures/database.info.ts +4 -8
  87. package/src/procedures/database.ping.ts +4 -8
  88. package/src/procedures/documents.aggregate.ts +5 -9
  89. package/src/procedures/documents.bulk.ts +3 -5
  90. package/src/procedures/documents.count.ts +5 -9
  91. package/src/procedures/documents.delete.ts +3 -5
  92. package/src/procedures/documents.distinct.ts +5 -9
  93. package/src/procedures/documents.explain.ts +3 -5
  94. package/src/procedures/documents.find.ts +2 -5
  95. package/src/procedures/documents.get.ts +2 -5
  96. package/src/procedures/documents.insert.ts +5 -9
  97. package/src/procedures/documents.update.ts +3 -5
  98. package/src/procedures/indexes.create.ts +5 -9
  99. package/src/procedures/indexes.drop.ts +5 -9
  100. package/src/procedures/indexes.list.ts +4 -8
  101. package/src/procedures/watch.ts +3 -5
  102. package/src/storage/document-storage.ts +441 -71
  103. package/src/storage/index.ts +11 -3
  104. package/src/storage/materializer.ts +54 -22
@@ -8,7 +8,6 @@ import {
8
8
  type Effects,
9
9
  type Procedure,
10
10
  type ProcedureContext,
11
- zodAdapter,
12
11
  } from "@procedures/client";
13
12
  import { collectionFor, copyScope, type ScopeInput } from "../scope.js";
14
13
  import { described, documentObject, scopeFields } from "./input-schemas.js";
@@ -86,8 +85,7 @@ const findInputSchema = described<FindInput>(
86
85
  limit: z.number().int().min(1).optional().describe("The number of documents on a page"),
87
86
  })
88
87
  );
89
- const findOutputSchema = zodAdapter<FindOutput>(
90
- z.looseObject({
88
+ const findOutputSchema: z.ZodType<FindOutput> = z.looseObject({
91
89
  documents: z.array(z.record(z.string(), z.unknown())).describe("The documents of the page"),
92
90
  pagination: z.looseObject({
93
91
  page: z.number().describe("The page, from 1"),
@@ -97,8 +95,7 @@ const findOutputSchema = zodAdapter<FindOutput>(
97
95
  hasNext: z.boolean().describe("True when a next page exists"),
98
96
  hasPrev: z.boolean().describe("True when a previous page exists"),
99
97
  }).describe("The page of the result"),
100
- })
101
- );
98
+ });
102
99
 
103
100
  export const findProcedure: Procedure<
104
101
  FindInput,
@@ -8,7 +8,6 @@ import {
8
8
  type Effects,
9
9
  type Procedure,
10
10
  type ProcedureContext,
11
- zodAdapter,
12
11
  } from "@procedures/client";
13
12
  import { collectionFor, copyScope, type ScopeInput } from "../scope.js";
14
13
  import { described, idTypeField, scopeFields } from "./input-schemas.js";
@@ -70,11 +69,9 @@ const getInputSchema = described<GetInput>(
70
69
  idType: idTypeField(),
71
70
  })
72
71
  );
73
- const getOutputSchema = zodAdapter<GetOutput>(
74
- z.looseObject({
72
+ const getOutputSchema: z.ZodType<GetOutput> = z.looseObject({
75
73
  document: z.record(z.string(), z.unknown()).nullable().describe("The document, or null when no document has the id"),
76
- })
77
- );
74
+ });
78
75
 
79
76
  export const getProcedure: Procedure<
80
77
  GetInput,
@@ -3,7 +3,7 @@
3
3
  * Insert one or more documents
4
4
  */
5
5
 
6
- import { createProcedure, zodAdapter, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
6
+ import { createProcedure, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
7
7
  import { collectionFor, type ScopeInput } from "../scope.js";
8
8
  import { scopeFields, documentObject } from "./input-schemas.js";
9
9
  import { z } from "zod";
@@ -22,21 +22,17 @@ interface InsertOutput {
22
22
  }
23
23
 
24
24
  // Schemas
25
- const insertInputSchema = zodAdapter<InsertInput>(
26
- z.object({
25
+ const insertInputSchema: z.ZodType<InsertInput> = z.object({
27
26
  ...scopeFields(),
28
27
  documents: z
29
28
  .union([documentObject(), z.array(documentObject())])
30
29
  .describe("One document, or a list of documents"),
31
- })
32
- );
33
- const insertOutputSchema = zodAdapter<InsertOutput>(
34
- z.looseObject({
30
+ });
31
+ const insertOutputSchema: z.ZodType<InsertOutput> = z.looseObject({
35
32
  acknowledged: z.boolean().describe("True when the server confirmed the write"),
36
33
  insertedIds: z.array(z.string()).describe("The ids of the new documents, as text"),
37
34
  insertedCount: z.number().describe("The number of new documents"),
38
- })
39
- );
35
+ });
40
36
 
41
37
  export const insertProcedure: Procedure<
42
38
  InsertInput,
@@ -3,7 +3,7 @@
3
3
  * Update documents matching a filter
4
4
  */
5
5
 
6
- import { createProcedure, type Effects, type Procedure, type ProcedureContext, zodAdapter } from "@procedures/client";
6
+ import { createProcedure, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
7
7
  import { collectionFor } from "../scope.js";
8
8
  import { described, documentObject, scopeFields, targetFields } from "./input-schemas.js";
9
9
  import { z } from "zod";
@@ -53,15 +53,13 @@ const updateInputSchema = described<UpdateInput>(
53
53
  upsert: z.boolean().optional().describe("Insert a document when none matches"),
54
54
  })
55
55
  );
56
- const updateOutputSchema = zodAdapter<UpdateOutput>(
57
- z.looseObject({
56
+ const updateOutputSchema: z.ZodType<UpdateOutput> = z.looseObject({
58
57
  acknowledged: z.boolean().describe("True when the server confirmed the write"),
59
58
  matchedCount: z.number().describe("The number of documents that matched"),
60
59
  modifiedCount: z.number().describe("The number of documents that changed"),
61
60
  upsertedId: z.string().nullable().describe("The id of the new document of an upsert, as text, or null"),
62
61
  upsertedCount: z.number().describe("The number of documents that an upsert made"),
63
- })
64
- );
62
+ });
65
63
 
66
64
  export const updateProcedure: Procedure<
67
65
  UpdateInput,
@@ -3,7 +3,7 @@
3
3
  * Create an index on a collection
4
4
  */
5
5
 
6
- import { createProcedure, zodAdapter, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
6
+ import { createProcedure, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
7
7
  import { collectionFor, type ScopeInput } from "../scope.js";
8
8
  import { scopeFields } from "./input-schemas.js";
9
9
  import { z } from "zod";
@@ -22,8 +22,7 @@ interface CreateIndexOutput {
22
22
  }
23
23
 
24
24
  // Schemas
25
- const createIndexInputSchema = zodAdapter<CreateIndexInput>(
26
- z.object({
25
+ const createIndexInputSchema: z.ZodType<CreateIndexInput> = z.object({
27
26
  ...scopeFields(),
28
27
  keys: z
29
28
  .record(z.string(), z.union([z.literal(1), z.literal(-1), z.literal("text"), z.literal("2dsphere")]))
@@ -36,14 +35,11 @@ const createIndexInputSchema = zodAdapter<CreateIndexInput>(
36
35
  })
37
36
  .optional()
38
37
  .describe("The options of the index"),
39
- })
40
- );
41
- const createIndexOutputSchema = zodAdapter<CreateIndexOutput>(
42
- z.looseObject({
38
+ });
39
+ const createIndexOutputSchema: z.ZodType<CreateIndexOutput> = z.looseObject({
43
40
  acknowledged: z.boolean().describe("True when the server confirmed the write"),
44
41
  indexName: z.string().describe("The name of the new index"),
45
- })
46
- );
42
+ });
47
43
 
48
44
  export const createIndexProcedure: Procedure<
49
45
  CreateIndexInput,
@@ -3,7 +3,7 @@
3
3
  * Drop an index from a collection
4
4
  */
5
5
 
6
- import { createProcedure, zodAdapter, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
6
+ import { createProcedure, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
7
7
  import { collectionFor, type ScopeInput } from "../scope.js";
8
8
  import { scopeFields } from "./input-schemas.js";
9
9
  import { z } from "zod";
@@ -18,17 +18,13 @@ interface DropIndexOutput {
18
18
  }
19
19
 
20
20
  // Schemas
21
- const dropIndexInputSchema = zodAdapter<DropIndexInput>(
22
- z.object({
21
+ const dropIndexInputSchema: z.ZodType<DropIndexInput> = z.object({
23
22
  ...scopeFields(),
24
23
  indexName: z.string().min(1).describe("The name of the index to drop"),
25
- })
26
- );
27
- const dropIndexOutputSchema = zodAdapter<DropIndexOutput>(
28
- z.looseObject({
24
+ });
25
+ const dropIndexOutputSchema: z.ZodType<DropIndexOutput> = z.looseObject({
29
26
  acknowledged: z.boolean().describe("True when the server confirmed the write"),
30
- })
31
- );
27
+ });
32
28
 
33
29
  export const dropIndexProcedure: Procedure<
34
30
  DropIndexInput,
@@ -3,7 +3,7 @@
3
3
  * List indexes on a collection
4
4
  */
5
5
 
6
- import { createProcedure, zodAdapter, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
6
+ import { createProcedure, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
7
7
  import { collectionFor, type ScopeInput } from "../scope.js";
8
8
  import { scopeFields } from "./input-schemas.js";
9
9
  import { z } from "zod";
@@ -18,11 +18,8 @@ interface ListIndexesOutput {
18
18
  }
19
19
 
20
20
  // Schemas
21
- const listIndexesInputSchema = zodAdapter<ListIndexesInput>(
22
- z.object({ ...scopeFields() })
23
- );
24
- const listIndexesOutputSchema = zodAdapter<ListIndexesOutput>(
25
- z.looseObject({
21
+ const listIndexesInputSchema: z.ZodType<ListIndexesInput> = z.object({ ...scopeFields() });
22
+ const listIndexesOutputSchema: z.ZodType<ListIndexesOutput> = z.looseObject({
26
23
  indexes: z
27
24
  .array(
28
25
  z.looseObject({
@@ -33,8 +30,7 @@ const listIndexesOutputSchema = zodAdapter<ListIndexesOutput>(
33
30
  })
34
31
  )
35
32
  .describe("The indexes of the collection"),
36
- })
37
- );
33
+ });
38
34
 
39
35
  export const listIndexesProcedure: Procedure<
40
36
  ListIndexesInput,
@@ -7,7 +7,7 @@
7
7
  * needs a replica set or a sharded cluster: a server without one refuses it.
8
8
  */
9
9
 
10
- import { createProcedure, zodAdapter, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
10
+ import { createProcedure, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
11
11
  import type { ChangeStream, ChangeStreamOptions, Document } from "mongodb";
12
12
  import { z } from "zod";
13
13
  import { collectionFor, databaseFor, copyScope, SCOPE_FIELDS, type ScopeInput } from "../scope.js";
@@ -149,8 +149,7 @@ const watchInputSchema = described<WatchInput>(
149
149
  resumeAfter: z.string().min(1).optional().describe("The resume token of an earlier change: the stream starts after it"),
150
150
  })
151
151
  );
152
- const watchOutputSchema = zodAdapter<WatchChange>(
153
- z.looseObject({
152
+ const watchOutputSchema: z.ZodType<WatchChange> = z.looseObject({
154
153
  operationType: z.string().describe("insert, update, replace, delete, drop, rename, dropDatabase or invalidate"),
155
154
  ns: z.looseObject({ db: z.string(), coll: z.string().optional() }).optional().describe("The database and the collection of the change"),
156
155
  documentKey: z.record(z.string(), z.unknown()).optional().describe("The _id of the changed document"),
@@ -158,8 +157,7 @@ const watchOutputSchema = zodAdapter<WatchChange>(
158
157
  updateDescription: z.record(z.string(), z.unknown()).optional().describe("The changed and removed fields of an update"),
159
158
  wallTime: z.string().optional().describe("The time of the change on the server (ISO 8601), from MongoDB 6.0"),
160
159
  resumeToken: z.string().describe("The resume token of the change: resumeAfter takes it"),
161
- })
162
- );
160
+ });
163
161
 
164
162
  export const watchProcedure: Procedure<
165
163
  WatchInput,