@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.
- package/CHANGELOG.md +59 -0
- package/README.md +34 -5
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/procedures/collections.create.d.ts.map +1 -1
- package/dist/procedures/collections.create.js +5 -5
- package/dist/procedures/collections.create.js.map +1 -1
- package/dist/procedures/collections.drop.d.ts.map +1 -1
- package/dist/procedures/collections.drop.js +5 -5
- package/dist/procedures/collections.drop.js.map +1 -1
- package/dist/procedures/collections.list.d.ts.map +1 -1
- package/dist/procedures/collections.list.js +4 -4
- package/dist/procedures/collections.list.js.map +1 -1
- package/dist/procedures/collections.stats.d.ts.map +1 -1
- package/dist/procedures/collections.stats.js +4 -4
- package/dist/procedures/collections.stats.js.map +1 -1
- package/dist/procedures/database.info.d.ts.map +1 -1
- package/dist/procedures/database.info.js +4 -4
- package/dist/procedures/database.info.js.map +1 -1
- package/dist/procedures/database.ping.d.ts.map +1 -1
- package/dist/procedures/database.ping.js +4 -4
- package/dist/procedures/database.ping.js.map +1 -1
- package/dist/procedures/documents.aggregate.d.ts.map +1 -1
- package/dist/procedures/documents.aggregate.js +5 -5
- package/dist/procedures/documents.aggregate.js.map +1 -1
- package/dist/procedures/documents.bulk.d.ts.map +1 -1
- package/dist/procedures/documents.bulk.js +3 -3
- package/dist/procedures/documents.bulk.js.map +1 -1
- package/dist/procedures/documents.count.d.ts.map +1 -1
- package/dist/procedures/documents.count.js +5 -5
- package/dist/procedures/documents.count.js.map +1 -1
- package/dist/procedures/documents.delete.d.ts.map +1 -1
- package/dist/procedures/documents.delete.js +3 -3
- package/dist/procedures/documents.delete.js.map +1 -1
- package/dist/procedures/documents.distinct.d.ts.map +1 -1
- package/dist/procedures/documents.distinct.js +5 -5
- package/dist/procedures/documents.distinct.js.map +1 -1
- package/dist/procedures/documents.explain.d.ts.map +1 -1
- package/dist/procedures/documents.explain.js +3 -3
- package/dist/procedures/documents.explain.js.map +1 -1
- package/dist/procedures/documents.find.d.ts.map +1 -1
- package/dist/procedures/documents.find.js +3 -3
- package/dist/procedures/documents.find.js.map +1 -1
- package/dist/procedures/documents.get.d.ts.map +1 -1
- package/dist/procedures/documents.get.js +3 -3
- package/dist/procedures/documents.get.js.map +1 -1
- package/dist/procedures/documents.insert.d.ts.map +1 -1
- package/dist/procedures/documents.insert.js +5 -5
- package/dist/procedures/documents.insert.js.map +1 -1
- package/dist/procedures/documents.update.d.ts.map +1 -1
- package/dist/procedures/documents.update.js +3 -3
- package/dist/procedures/documents.update.js.map +1 -1
- package/dist/procedures/indexes.create.d.ts.map +1 -1
- package/dist/procedures/indexes.create.js +5 -5
- package/dist/procedures/indexes.create.js.map +1 -1
- package/dist/procedures/indexes.drop.d.ts.map +1 -1
- package/dist/procedures/indexes.drop.js +5 -5
- package/dist/procedures/indexes.drop.js.map +1 -1
- package/dist/procedures/indexes.list.d.ts.map +1 -1
- package/dist/procedures/indexes.list.js +4 -4
- package/dist/procedures/indexes.list.js.map +1 -1
- package/dist/procedures/watch.d.ts.map +1 -1
- package/dist/procedures/watch.js +3 -3
- package/dist/procedures/watch.js.map +1 -1
- package/dist/storage/document-storage.d.ts +177 -8
- package/dist/storage/document-storage.d.ts.map +1 -1
- package/dist/storage/document-storage.js +383 -72
- package/dist/storage/document-storage.js.map +1 -1
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +2 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/materializer.d.ts +27 -12
- package/dist/storage/materializer.d.ts.map +1 -1
- package/dist/storage/materializer.js +37 -15
- package/dist/storage/materializer.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +11 -3
- package/src/procedures/collections.create.ts +5 -9
- package/src/procedures/collections.drop.ts +5 -9
- package/src/procedures/collections.list.ts +4 -8
- package/src/procedures/collections.stats.ts +4 -8
- package/src/procedures/database.info.ts +4 -8
- package/src/procedures/database.ping.ts +4 -8
- package/src/procedures/documents.aggregate.ts +5 -9
- package/src/procedures/documents.bulk.ts +3 -5
- package/src/procedures/documents.count.ts +5 -9
- package/src/procedures/documents.delete.ts +3 -5
- package/src/procedures/documents.distinct.ts +5 -9
- package/src/procedures/documents.explain.ts +3 -5
- package/src/procedures/documents.find.ts +2 -5
- package/src/procedures/documents.get.ts +2 -5
- package/src/procedures/documents.insert.ts +5 -9
- package/src/procedures/documents.update.ts +3 -5
- package/src/procedures/indexes.create.ts +5 -9
- package/src/procedures/indexes.drop.ts +5 -9
- package/src/procedures/indexes.list.ts +4 -8
- package/src/procedures/watch.ts +3 -5
- package/src/storage/document-storage.ts +441 -71
- package/src/storage/index.ts +11 -3
- 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
|
|
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
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
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,
|
|
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
|
|
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,
|
|
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
|
|
22
|
-
|
|
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,
|
package/src/procedures/watch.ts
CHANGED
|
@@ -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,
|
|
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
|
|
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,
|