@procedures/mongo 0.33.0 → 0.34.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 +26 -0
- package/dist/.tsbuildinfo +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/package.json +3 -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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Run an aggregation pipeline
|
|
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";
|
|
@@ -25,8 +25,7 @@ interface AggregateOutput {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Schemas
|
|
28
|
-
const aggregateInputSchema
|
|
29
|
-
z.object({
|
|
28
|
+
const aggregateInputSchema: z.ZodType<AggregateInput> = z.object({
|
|
30
29
|
...scopeFields(),
|
|
31
30
|
pipeline: z.array(documentObject()).describe("The aggregation stages, in order (for example [{ $match: {...} }, { $group: {...} }])"),
|
|
32
31
|
options: z
|
|
@@ -36,13 +35,10 @@ const aggregateInputSchema = zodAdapter<AggregateInput>(
|
|
|
36
35
|
})
|
|
37
36
|
.optional()
|
|
38
37
|
.describe("The options of the aggregation"),
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const aggregateOutputSchema = zodAdapter<AggregateOutput>(
|
|
42
|
-
z.looseObject({
|
|
38
|
+
});
|
|
39
|
+
const aggregateOutputSchema: z.ZodType<AggregateOutput> = z.looseObject({
|
|
43
40
|
results: z.array(z.record(z.string(), z.unknown())).describe("The documents that the pipeline gave"),
|
|
44
|
-
})
|
|
45
|
-
);
|
|
41
|
+
});
|
|
46
42
|
|
|
47
43
|
/** The stages that write to a collection. A read-only procedure refuses them (CAP-2). */
|
|
48
44
|
const WRITING_STAGES = ["$out", "$merge"];
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* of an update or a delete needs `confirm: true`, and an unknown field is an error.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { createProcedure,
|
|
13
|
+
import { createProcedure, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
|
|
14
14
|
import type { AnyBulkWriteOperation, Document } from "mongodb";
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
import { collectionFor, copyScope, SCOPE_FIELDS, type ScopeInput } from "../scope.js";
|
|
@@ -148,8 +148,7 @@ const bulkInputSchema = described<BulkInput>(
|
|
|
148
148
|
confirm: z.boolean().optional().describe("Set to true to use an empty filter, which matches every document, in an update or a delete"),
|
|
149
149
|
})
|
|
150
150
|
);
|
|
151
|
-
const bulkOutputSchema
|
|
152
|
-
z.looseObject({
|
|
151
|
+
const bulkOutputSchema: z.ZodType<BulkOutput> = z.looseObject({
|
|
153
152
|
ok: z.boolean().describe("True when the server confirmed the writes"),
|
|
154
153
|
insertedCount: z.number().describe("The number of inserted documents"),
|
|
155
154
|
matchedCount: z.number().describe("The number of documents that the updates matched"),
|
|
@@ -158,8 +157,7 @@ const bulkOutputSchema = zodAdapter<BulkOutput>(
|
|
|
158
157
|
upsertedCount: z.number().describe("The number of documents that an upsert made"),
|
|
159
158
|
insertedIds: z.record(z.string(), z.string()).describe("The ids of the inserted documents, as text, by the index of their operation"),
|
|
160
159
|
upsertedIds: z.record(z.string(), z.string()).describe("The ids of the upserted documents, as text, by the index of their operation"),
|
|
161
|
-
})
|
|
162
|
-
);
|
|
160
|
+
});
|
|
163
161
|
|
|
164
162
|
export const bulkProcedure: Procedure<
|
|
165
163
|
BulkInput,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Count documents matching a filter
|
|
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";
|
|
@@ -19,17 +19,13 @@ interface CountOutput {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// Schemas
|
|
22
|
-
const countInputSchema
|
|
23
|
-
z.object({
|
|
22
|
+
const countInputSchema: z.ZodType<CountInput> = z.object({
|
|
24
23
|
...scopeFields(),
|
|
25
24
|
query: documentObject().optional().describe("The filter of the documents to count (default: all documents)"),
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const countOutputSchema = zodAdapter<CountOutput>(
|
|
29
|
-
z.looseObject({
|
|
25
|
+
});
|
|
26
|
+
const countOutputSchema: z.ZodType<CountOutput> = z.looseObject({
|
|
30
27
|
count: z.number().describe("The number of documents that match"),
|
|
31
|
-
})
|
|
32
|
-
);
|
|
28
|
+
});
|
|
33
29
|
|
|
34
30
|
export const countProcedure: Procedure<
|
|
35
31
|
CountInput,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Delete 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, scopeFields, targetFields } from "./input-schemas.js";
|
|
9
9
|
import { z } from "zod";
|
|
@@ -23,12 +23,10 @@ const deleteInputSchema = described<DeleteInput>(
|
|
|
23
23
|
(data: unknown) => parseTarget("mongo.documents.delete", data).target,
|
|
24
24
|
z.object({ ...scopeFields(), ...targetFields() })
|
|
25
25
|
);
|
|
26
|
-
const deleteOutputSchema
|
|
27
|
-
z.looseObject({
|
|
26
|
+
const deleteOutputSchema: z.ZodType<DeleteOutput> = z.looseObject({
|
|
28
27
|
acknowledged: z.boolean().describe("True when the server confirmed the write"),
|
|
29
28
|
deletedCount: z.number().describe("The number of deleted documents"),
|
|
30
|
-
})
|
|
31
|
-
);
|
|
29
|
+
});
|
|
32
30
|
|
|
33
31
|
export const deleteProcedure: Procedure<
|
|
34
32
|
DeleteInput,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* The distinct values of one field in the documents that match a filter
|
|
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,18 +22,14 @@ interface DistinctOutput {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// Schemas
|
|
25
|
-
const distinctInputSchema
|
|
26
|
-
z.object({
|
|
25
|
+
const distinctInputSchema: z.ZodType<DistinctInput> = z.object({
|
|
27
26
|
...scopeFields(),
|
|
28
27
|
field: z.string().min(1).describe('The field, with dots for an embedded field (for example "address.city")'),
|
|
29
28
|
query: documentObject().optional().describe("The filter of the documents (default: all documents)"),
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
const distinctOutputSchema = zodAdapter<DistinctOutput>(
|
|
33
|
-
z.looseObject({
|
|
29
|
+
});
|
|
30
|
+
const distinctOutputSchema: z.ZodType<DistinctOutput> = z.looseObject({
|
|
34
31
|
values: z.array(z.unknown()).describe("The distinct values of the field. An array field gives each of its elements."),
|
|
35
|
-
})
|
|
36
|
-
);
|
|
32
|
+
});
|
|
37
33
|
|
|
38
34
|
export const distinctProcedure: Procedure<
|
|
39
35
|
DistinctInput,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* the verbosity `executionStats` runs the plan.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { createProcedure,
|
|
10
|
+
import { createProcedure, type Effects, type Procedure, type ProcedureContext } from "@procedures/client";
|
|
11
11
|
import type { Document, ExplainVerbosityLike, FindOptions } from "mongodb";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
import { collectionFor, copyScope, SCOPE_FIELDS, type ScopeInput } from "../scope.js";
|
|
@@ -108,12 +108,10 @@ const explainInputSchema = described<ExplainInput>(
|
|
|
108
108
|
.describe("queryPlanner (the default): the plan only. executionStats and allPlansExecution also run the plan."),
|
|
109
109
|
})
|
|
110
110
|
);
|
|
111
|
-
const explainOutputSchema
|
|
112
|
-
z.looseObject({
|
|
111
|
+
const explainOutputSchema: z.ZodType<ExplainOutput> = z.looseObject({
|
|
113
112
|
operation: z.enum(["find", "aggregate"]).describe("The operation that the server explained"),
|
|
114
113
|
plan: z.record(z.string(), z.unknown()).describe("The explain document of the server (queryPlanner, and executionStats with that verbosity)"),
|
|
115
|
-
})
|
|
116
|
-
);
|
|
114
|
+
});
|
|
117
115
|
|
|
118
116
|
export const explainProcedure: Procedure<
|
|
119
117
|
ExplainInput,
|
|
@@ -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,
|