@procedures/mongo 0.0.0-stage → 0.2.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 (150) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1322 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/connection.d.ts +93 -0
  6. package/dist/connection.d.ts.map +1 -0
  7. package/dist/connection.js +147 -0
  8. package/dist/connection.js.map +1 -0
  9. package/dist/index.d.ts +34 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +45 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/module.d.ts +26 -0
  14. package/dist/module.d.ts.map +1 -0
  15. package/dist/module.js +66 -0
  16. package/dist/module.js.map +1 -0
  17. package/dist/procedures/collections.create.d.ts +21 -0
  18. package/dist/procedures/collections.create.d.ts.map +1 -0
  19. package/dist/procedures/collections.create.js +46 -0
  20. package/dist/procedures/collections.create.js.map +1 -0
  21. package/dist/procedures/collections.drop.d.ts +20 -0
  22. package/dist/procedures/collections.drop.d.ts.map +1 -0
  23. package/dist/procedures/collections.drop.js +40 -0
  24. package/dist/procedures/collections.drop.js.map +1 -0
  25. package/dist/procedures/collections.list.d.ts +17 -0
  26. package/dist/procedures/collections.list.d.ts.map +1 -0
  27. package/dist/procedures/collections.list.js +34 -0
  28. package/dist/procedures/collections.list.js.map +1 -0
  29. package/dist/procedures/collections.stats.d.ts +16 -0
  30. package/dist/procedures/collections.stats.d.ts.map +1 -0
  31. package/dist/procedures/collections.stats.js +41 -0
  32. package/dist/procedures/collections.stats.js.map +1 -0
  33. package/dist/procedures/database.info.d.ts +16 -0
  34. package/dist/procedures/database.info.d.ts.map +1 -0
  35. package/dist/procedures/database.info.js +41 -0
  36. package/dist/procedures/database.info.js.map +1 -0
  37. package/dist/procedures/database.ping.d.ts +18 -0
  38. package/dist/procedures/database.ping.d.ts.map +1 -0
  39. package/dist/procedures/database.ping.js +34 -0
  40. package/dist/procedures/database.ping.js.map +1 -0
  41. package/dist/procedures/documents.aggregate.d.ts +20 -0
  42. package/dist/procedures/documents.aggregate.d.ts.map +1 -0
  43. package/dist/procedures/documents.aggregate.js +43 -0
  44. package/dist/procedures/documents.aggregate.js.map +1 -0
  45. package/dist/procedures/documents.count.d.ts +19 -0
  46. package/dist/procedures/documents.count.d.ts.map +1 -0
  47. package/dist/procedures/documents.count.js +32 -0
  48. package/dist/procedures/documents.count.js.map +1 -0
  49. package/dist/procedures/documents.delete.d.ts +18 -0
  50. package/dist/procedures/documents.delete.d.ts.map +1 -0
  51. package/dist/procedures/documents.delete.js +34 -0
  52. package/dist/procedures/documents.delete.js.map +1 -0
  53. package/dist/procedures/documents.find.d.ts +24 -0
  54. package/dist/procedures/documents.find.d.ts.map +1 -0
  55. package/dist/procedures/documents.find.js +106 -0
  56. package/dist/procedures/documents.find.js.map +1 -0
  57. package/dist/procedures/documents.get.d.ts +21 -0
  58. package/dist/procedures/documents.get.d.ts.map +1 -0
  59. package/dist/procedures/documents.get.js +57 -0
  60. package/dist/procedures/documents.get.js.map +1 -0
  61. package/dist/procedures/documents.insert.d.ts +22 -0
  62. package/dist/procedures/documents.insert.d.ts.map +1 -0
  63. package/dist/procedures/documents.insert.js +58 -0
  64. package/dist/procedures/documents.insert.js.map +1 -0
  65. package/dist/procedures/documents.update.d.ts +27 -0
  66. package/dist/procedures/documents.update.d.ts.map +1 -0
  67. package/dist/procedures/documents.update.js +64 -0
  68. package/dist/procedures/documents.update.js.map +1 -0
  69. package/dist/procedures/index.d.ts +21 -0
  70. package/dist/procedures/index.d.ts.map +1 -0
  71. package/dist/procedures/index.js +26 -0
  72. package/dist/procedures/index.js.map +1 -0
  73. package/dist/procedures/indexes.create.d.ts +21 -0
  74. package/dist/procedures/indexes.create.d.ts.map +1 -0
  75. package/dist/procedures/indexes.create.js +48 -0
  76. package/dist/procedures/indexes.create.js.map +1 -0
  77. package/dist/procedures/indexes.drop.d.ts +18 -0
  78. package/dist/procedures/indexes.drop.d.ts.map +1 -0
  79. package/dist/procedures/indexes.drop.js +33 -0
  80. package/dist/procedures/indexes.drop.js.map +1 -0
  81. package/dist/procedures/indexes.list.d.ts +18 -0
  82. package/dist/procedures/indexes.list.d.ts.map +1 -0
  83. package/dist/procedures/indexes.list.js +43 -0
  84. package/dist/procedures/indexes.list.js.map +1 -0
  85. package/dist/procedures/input-schemas.d.ts +45 -0
  86. package/dist/procedures/input-schemas.d.ts.map +1 -0
  87. package/dist/procedures/input-schemas.js +52 -0
  88. package/dist/procedures/input-schemas.js.map +1 -0
  89. package/dist/procedures/schema.d.ts +2 -0
  90. package/dist/procedures/schema.d.ts.map +1 -0
  91. package/dist/procedures/schema.js +2 -0
  92. package/dist/procedures/schema.js.map +1 -0
  93. package/dist/procedures/target.d.ts +44 -0
  94. package/dist/procedures/target.d.ts.map +1 -0
  95. package/dist/procedures/target.js +98 -0
  96. package/dist/procedures/target.js.map +1 -0
  97. package/dist/procedures.types.d.ts +129 -0
  98. package/dist/procedures.types.d.ts.map +1 -0
  99. package/dist/procedures.types.js +24 -0
  100. package/dist/procedures.types.js.map +1 -0
  101. package/dist/register.d.ts +7 -0
  102. package/dist/register.d.ts.map +1 -0
  103. package/dist/register.js +9 -0
  104. package/dist/register.js.map +1 -0
  105. package/dist/scope.d.ts +33 -0
  106. package/dist/scope.d.ts.map +1 -0
  107. package/dist/scope.js +52 -0
  108. package/dist/scope.js.map +1 -0
  109. package/dist/storage/index.d.ts +6 -0
  110. package/dist/storage/index.d.ts.map +1 -0
  111. package/dist/storage/index.js +5 -0
  112. package/dist/storage/index.js.map +1 -0
  113. package/dist/storage/mongo-storage.d.ts +50 -0
  114. package/dist/storage/mongo-storage.d.ts.map +1 -0
  115. package/dist/storage/mongo-storage.js +109 -0
  116. package/dist/storage/mongo-storage.js.map +1 -0
  117. package/dist/types.d.ts +239 -0
  118. package/dist/types.d.ts.map +1 -0
  119. package/dist/types.js +58 -0
  120. package/dist/types.js.map +1 -0
  121. package/package.json +84 -3
  122. package/src/connection.ts +198 -0
  123. package/src/index.ts +159 -0
  124. package/src/module.ts +71 -0
  125. package/src/procedures/collections.create.ts +72 -0
  126. package/src/procedures/collections.drop.ts +66 -0
  127. package/src/procedures/collections.list.ts +56 -0
  128. package/src/procedures/collections.stats.ts +60 -0
  129. package/src/procedures/database.info.ts +61 -0
  130. package/src/procedures/database.ping.ts +57 -0
  131. package/src/procedures/documents.aggregate.ts +72 -0
  132. package/src/procedures/documents.count.ts +55 -0
  133. package/src/procedures/documents.delete.ts +57 -0
  134. package/src/procedures/documents.find.ts +151 -0
  135. package/src/procedures/documents.get.ts +102 -0
  136. package/src/procedures/documents.insert.ts +86 -0
  137. package/src/procedures/documents.update.ts +96 -0
  138. package/src/procedures/index.ts +30 -0
  139. package/src/procedures/indexes.create.ts +74 -0
  140. package/src/procedures/indexes.drop.ts +56 -0
  141. package/src/procedures/indexes.list.ts +67 -0
  142. package/src/procedures/input-schemas.ts +63 -0
  143. package/src/procedures/schema.ts +1 -0
  144. package/src/procedures/target.ts +123 -0
  145. package/src/procedures.types.ts +162 -0
  146. package/src/register.ts +11 -0
  147. package/src/scope.ts +69 -0
  148. package/src/storage/index.ts +6 -0
  149. package/src/storage/mongo-storage.ts +151 -0
  150. package/src/types.ts +337 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.insert.js","sourceRoot":"","sources":["../../src/procedures/documents.insert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAuD,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAsB,MAAM,aAAa,CAAC;AAcjD,UAAU;AACV,MAAM,iBAAiB,GAAG,UAAU,CACl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C,KAAK,CAAC,SAAS,CAAC,CAAC;IAEtB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO;YACL,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,EAAE;YACf,aAAa,EAAE,CAAC;SACjB,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC;QACpD,OAAO;YACL,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACxC,aAAa,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3C,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACjD,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;QAC1D,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC;AACJ,CAAC,CAAC;KACD,KAAK,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Procedure: mongo.documents.update
3
+ * Update documents matching a filter
4
+ */
5
+ import { type Effects, type Procedure } from "@procedures/client";
6
+ import type { DocumentUpdate } from "../types.js";
7
+ import { type TargetInput } from "./target.js";
8
+ /** The input: exactly one of `id` or `filter`, the update, and the scope fields. */
9
+ interface UpdateInput extends TargetInput {
10
+ /** Update operations */
11
+ update: DocumentUpdate;
12
+ /** Insert if not found */
13
+ upsert?: boolean;
14
+ }
15
+ interface UpdateOutput {
16
+ acknowledged: boolean;
17
+ matchedCount: number;
18
+ modifiedCount: number;
19
+ upsertedId: string | null;
20
+ upsertedCount: number;
21
+ }
22
+ export declare const updateProcedure: Procedure<UpdateInput, UpdateOutput, {
23
+ description: string;
24
+ effects?: Effects;
25
+ }>;
26
+ export type { UpdateInput, UpdateOutput };
27
+ //# sourceMappingURL=documents.update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.update.d.ts","sourceRoot":"","sources":["../../src/procedures/documents.update.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAmB,KAAK,OAAO,EAAE,KAAK,SAAS,EAAqC,MAAM,oBAAoB,CAAC;AAItH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAA2C,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAGxF,oFAAoF;AACpF,UAAU,WAAY,SAAQ,WAAW;IACvC,wBAAwB;IACxB,MAAM,EAAE,cAAc,CAAC;IACvB,0BAA0B;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,YAAY;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;CACvB;AAsCD,eAAO,MAAM,eAAe,EAAE,SAAS,CACrC,WAAW,EACX,YAAY,EACZ;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAyBlC,CAAC;AAEX,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Procedure: mongo.documents.update
3
+ * Update documents matching a filter
4
+ */
5
+ import { createProcedure, zodAdapter } from "@procedures/client";
6
+ import { collectionFor } from "../scope.js";
7
+ import { described, documentObject, scopeFields, targetFields } from "./input-schemas.js";
8
+ import { z } from "zod";
9
+ import { parseTarget, targetFilter, upsertFilter } from "./target.js";
10
+ function parseUpdateInput(data) {
11
+ const procedure = "mongo.documents.update";
12
+ const { target, raw } = parseTarget(procedure, data, ["update", "upsert"]);
13
+ const update = raw["update"];
14
+ if (typeof update !== "object" || update === null) {
15
+ throw new Error(`${procedure}: update must be an object (or a pipeline array)`);
16
+ }
17
+ const result = { ...target, update: update };
18
+ const upsert = raw["upsert"];
19
+ if (upsert !== undefined) {
20
+ if (typeof upsert !== "boolean")
21
+ throw new Error(`${procedure}: upsert must be a boolean`);
22
+ result.upsert = upsert;
23
+ }
24
+ return result;
25
+ }
26
+ // Schemas
27
+ const updateInputSchema = described(parseUpdateInput, z.object({
28
+ ...scopeFields(),
29
+ ...targetFields(),
30
+ update: documentObject().describe("The update operations, for example { $set: { status: \"done\" } }"),
31
+ upsert: z.boolean().optional().describe("Insert a document when none matches"),
32
+ }));
33
+ const updateOutputSchema = zodAdapter(z.looseObject({
34
+ acknowledged: z.boolean().describe("True when the server confirmed the write"),
35
+ matchedCount: z.number().describe("The number of documents that matched"),
36
+ modifiedCount: z.number().describe("The number of documents that changed"),
37
+ upsertedId: z.string().nullable().describe("The id of the new document of an upsert, as text, or null"),
38
+ upsertedCount: z.number().describe("The number of documents that an upsert made"),
39
+ }));
40
+ export const updateProcedure = createProcedure()
41
+ .path(["mongo", "documents", "update"])
42
+ .input(updateInputSchema)
43
+ .output(updateOutputSchema)
44
+ .meta({
45
+ description: "Update documents matching a filter",
46
+ effects: { reads: ["mongo", "network"], writes: ["mongo", "network"] },
47
+ })
48
+ .handler(async (input, ctx) => {
49
+ const { collection } = await collectionFor(input, ctx);
50
+ const upsert = input.upsert ?? false;
51
+ const filter = upsert ? await upsertFilter(collection, input) : targetFilter(input);
52
+ const result = input.multi
53
+ ? await collection.updateMany(filter, input.update, { upsert })
54
+ : await collection.updateOne(filter, input.update, { upsert });
55
+ return {
56
+ acknowledged: result.acknowledged,
57
+ matchedCount: result.matchedCount,
58
+ modifiedCount: result.modifiedCount,
59
+ upsertedId: result.upsertedId ? String(result.upsertedId) : null,
60
+ upsertedCount: result.upsertedCount,
61
+ };
62
+ })
63
+ .build();
64
+ //# sourceMappingURL=documents.update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.update.js","sourceRoot":"","sources":["../../src/procedures/documents.update.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAuD,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAoB,MAAM,aAAa,CAAC;AAmBxF,SAAS,gBAAgB,CAAC,IAAa;IACrC,MAAM,SAAS,GAAG,wBAAwB,CAAC;IAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3E,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,kDAAkD,CAAC,CAAC;IAClF,CAAC;IACD,MAAM,MAAM,GAAgB,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,MAAwB,EAAE,CAAC;IAC5E,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,IAAI,OAAO,MAAM,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,4BAA4B,CAAC,CA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AAC,EAAE;CACvE,CAAC;KACD,OAAO,CAAC,KAAK,EAAE,KAAkB,EAAE,GAAqB,EAAE,EAAE;IAC3D,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC;IACrC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,YAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAEpF,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK;QACxB,CAAC,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC;QAC/D,CAAC,CAAC,MAAM,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACjE,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI;QAChE,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC;AACJ,CAAC,CAAC;KACD,KAAK,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Procedure Barrel Export
3
+ */
4
+ export { pingProcedure } from "./database.ping.js";
5
+ export { infoProcedure } from "./database.info.js";
6
+ export { listProcedure } from "./collections.list.js";
7
+ export { createCollectionProcedure } from "./collections.create.js";
8
+ export { dropProcedure } from "./collections.drop.js";
9
+ export { statsProcedure } from "./collections.stats.js";
10
+ export { findProcedure } from "./documents.find.js";
11
+ export { getProcedure } from "./documents.get.js";
12
+ export { insertProcedure } from "./documents.insert.js";
13
+ export { updateProcedure } from "./documents.update.js";
14
+ export { deleteProcedure } from "./documents.delete.js";
15
+ export { countProcedure } from "./documents.count.js";
16
+ export { aggregateProcedure } from "./documents.aggregate.js";
17
+ export { listIndexesProcedure } from "./indexes.list.js";
18
+ export { createIndexProcedure } from "./indexes.create.js";
19
+ export { dropIndexProcedure } from "./indexes.drop.js";
20
+ export { schema } from "./schema.js";
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/procedures/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Procedure Barrel Export
3
+ */
4
+ // Database procedures
5
+ export { pingProcedure } from "./database.ping.js";
6
+ export { infoProcedure } from "./database.info.js";
7
+ // Collection procedures
8
+ export { listProcedure } from "./collections.list.js";
9
+ export { createCollectionProcedure } from "./collections.create.js";
10
+ export { dropProcedure } from "./collections.drop.js";
11
+ export { statsProcedure } from "./collections.stats.js";
12
+ // Document procedures
13
+ export { findProcedure } from "./documents.find.js";
14
+ export { getProcedure } from "./documents.get.js";
15
+ export { insertProcedure } from "./documents.insert.js";
16
+ export { updateProcedure } from "./documents.update.js";
17
+ export { deleteProcedure } from "./documents.delete.js";
18
+ export { countProcedure } from "./documents.count.js";
19
+ export { aggregateProcedure } from "./documents.aggregate.js";
20
+ // Index procedures
21
+ export { listIndexesProcedure } from "./indexes.list.js";
22
+ export { createIndexProcedure } from "./indexes.create.js";
23
+ export { dropIndexProcedure } from "./indexes.drop.js";
24
+ // Schema helper
25
+ export { schema } from "./schema.js";
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/procedures/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,sBAAsB;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,wBAAwB;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,sBAAsB;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,mBAAmB;AACnB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,gBAAgB;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Procedure: mongo.indexes.create
3
+ * Create an index on a collection
4
+ */
5
+ import { type Effects, type Procedure } from "@procedures/client";
6
+ import { type ScopeInput } from "../scope.js";
7
+ import { type IndexSpec, type IndexOptions } from "../types.js";
8
+ interface CreateIndexInput extends ScopeInput {
9
+ keys: IndexSpec;
10
+ options?: IndexOptions | undefined;
11
+ }
12
+ interface CreateIndexOutput {
13
+ acknowledged: boolean;
14
+ indexName: string;
15
+ }
16
+ export declare const createIndexProcedure: Procedure<CreateIndexInput, CreateIndexOutput, {
17
+ description: string;
18
+ effects?: Effects;
19
+ }>;
20
+ export type { CreateIndexInput, CreateIndexOutput };
21
+ //# sourceMappingURL=indexes.create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexes.create.d.ts","sourceRoot":"","sources":["../../src/procedures/indexes.create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,KAAK,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAI7D,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhE,UAAU,gBAAiB,SAAQ,UAAU;IAC3C,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACpC;AAED,UAAU,iBAAiB;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AA0BD,eAAO,MAAM,oBAAoB,EAAE,SAAS,CAC1C,gBAAgB,EAChB,iBAAiB,EACjB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAqBlC,CAAC;AAEX,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Procedure: mongo.indexes.create
3
+ * Create an index on a collection
4
+ */
5
+ import { createProcedure, zodAdapter } from "@procedures/client";
6
+ import { collectionFor } from "../scope.js";
7
+ import { scopeFields } from "./input-schemas.js";
8
+ import { z } from "zod";
9
+ import {} from "../types.js";
10
+ // Schemas
11
+ const createIndexInputSchema = zodAdapter(z.object({
12
+ ...scopeFields(),
13
+ keys: z
14
+ .record(z.string(), z.union([z.literal(1), z.literal(-1), z.literal("text"), z.literal("2dsphere")]))
15
+ .describe('The fields of the index and their order: 1, -1, "text" or "2dsphere"'),
16
+ options: z
17
+ .looseObject({
18
+ name: z.string().optional().describe("The name of the index"),
19
+ unique: z.boolean().optional().describe("A unique index"),
20
+ sparse: z.boolean().optional().describe("A sparse index"),
21
+ })
22
+ .optional()
23
+ .describe("The options of the index"),
24
+ }));
25
+ const createIndexOutputSchema = zodAdapter(z.looseObject({
26
+ acknowledged: z.boolean().describe("True when the server confirmed the write"),
27
+ indexName: z.string().describe("The name of the new index"),
28
+ }));
29
+ export const createIndexProcedure = createProcedure()
30
+ .path(["mongo", "indexes", "create"])
31
+ .input(createIndexInputSchema)
32
+ .output(createIndexOutputSchema)
33
+ .meta({
34
+ description: "Create an index on a collection",
35
+ // A second call with the same keys and options keeps the existing index
36
+ effects: { reads: ["mongo", "network"], writes: ["mongo", "network"], destructive: false, idempotent: true },
37
+ })
38
+ .handler(async (input, ctx) => {
39
+ const { collection } = await collectionFor(input, ctx);
40
+ // The schema leaves out an option that the input does not give: no option is undefined at run time
41
+ const indexName = await collection.createIndex(input.keys, input.options);
42
+ return {
43
+ acknowledged: true,
44
+ indexName,
45
+ };
46
+ })
47
+ .build();
48
+ //# sourceMappingURL=indexes.create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexes.create.js","sourceRoot":"","sources":["../../src/procedures/indexes.create.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAuD,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAqC,MAAM,aAAa,CAAC;AAahE,UAAU;AACV,MAAM,sBAAsB,GAAG,UAAU,CACvC,CAAC,CAAC,MAAM,CAAC;IACP,GAAG,WAAW,EAAE;IAChB,IAAI,EAAE,CAAC;SACJ,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;SACpG,QAAQ,CAAC,sEAAsE,CAAC;IACnF,OAAO,EAAE,CAAC;SACP,WAAW,CAAC;QACX,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ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CAAC,OAA2C,CAAC,CAAC;IAE9G,OAAO;QACL,YAAY,EAAE,IAAI;QAClB,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;KACD,KAAK,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Procedure: mongo.indexes.drop
3
+ * Drop an index from a collection
4
+ */
5
+ import { type Effects, type Procedure } from "@procedures/client";
6
+ import { type ScopeInput } from "../scope.js";
7
+ interface DropIndexInput extends ScopeInput {
8
+ indexName: string;
9
+ }
10
+ interface DropIndexOutput {
11
+ acknowledged: boolean;
12
+ }
13
+ export declare const dropIndexProcedure: Procedure<DropIndexInput, DropIndexOutput, {
14
+ description: string;
15
+ effects?: Effects;
16
+ }>;
17
+ export type { DropIndexInput, DropIndexOutput };
18
+ //# sourceMappingURL=indexes.drop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexes.drop.d.ts","sourceRoot":"","sources":["../../src/procedures/indexes.drop.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,KAAK,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAK7D,UAAU,cAAe,SAAQ,UAAU;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,eAAe;IACvB,YAAY,EAAE,OAAO,CAAC;CACvB;AAeD,eAAO,MAAM,kBAAkB,EAAE,SAAS,CACxC,cAAc,EACd,eAAe,EACf;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAkBlC,CAAC;AAEX,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Procedure: mongo.indexes.drop
3
+ * Drop an index from a collection
4
+ */
5
+ import { createProcedure, zodAdapter } from "@procedures/client";
6
+ import { collectionFor } from "../scope.js";
7
+ import { scopeFields } from "./input-schemas.js";
8
+ import { z } from "zod";
9
+ // Schemas
10
+ const dropIndexInputSchema = zodAdapter(z.object({
11
+ ...scopeFields(),
12
+ indexName: z.string().min(1).describe("The name of the index to drop"),
13
+ }));
14
+ const dropIndexOutputSchema = zodAdapter(z.looseObject({
15
+ acknowledged: z.boolean().describe("True when the server confirmed the write"),
16
+ }));
17
+ export const dropIndexProcedure = createProcedure()
18
+ .path(["mongo", "indexes", "drop"])
19
+ .input(dropIndexInputSchema)
20
+ .output(dropIndexOutputSchema)
21
+ .meta({
22
+ description: "Drop an index from a collection",
23
+ effects: { reads: ["mongo", "network"], writes: ["mongo", "network"] },
24
+ })
25
+ .handler(async (input, ctx) => {
26
+ const { collection } = await collectionFor(input, ctx);
27
+ await collection.dropIndex(input.indexName);
28
+ return {
29
+ acknowledged: true,
30
+ };
31
+ })
32
+ .build();
33
+ //# sourceMappingURL=indexes.drop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexes.drop.js","sourceRoot":"","sources":["../../src/procedures/indexes.drop.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAuD,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,UAAU;AACV,MAAM,oBAAoB,GAAG,UAAU,CACrC,CAAC,CAAC,MAAM,CAAC;IACP,GAAG,WAAW,EAAE;IAChB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC;CACvE,CAAC,CACH,CAAC;AACF,MAAM,qBAAqB,GAAG,UAAU,CACtC,CAAC,CAAC,WAAW,CAAC;IACZ,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;CAC/E,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAI3B,eAAe,EAAE;KAClB,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;KAClC,KAAK,CAAC,oBAAoB,CAAC;KAC3B,MAAM,CAAC,qBAAqB,CAAC;KAC7B,IAAI,CAAC;IACJ,WAAW,EAAE,iCAAiC;IAC9C,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;CACvE,CAAC;KACD,OAAO,CAAC,KAAK,EAAE,KAAqB,EAAE,GAAqB,EAAE,EAAE;IAC9D,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAEvD,MAAM,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAE5C,OAAO;QACL,YAAY,EAAE,IAAI;KACnB,CAAC;AACJ,CAAC,CAAC;KACD,KAAK,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Procedure: mongo.indexes.list
3
+ * List indexes on a collection
4
+ */
5
+ import { type Effects, type Procedure } from "@procedures/client";
6
+ import { type ScopeInput } from "../scope.js";
7
+ import { type IndexInfo } from "../types.js";
8
+ /** The input: only the scope fields. */
9
+ type ListIndexesInput = ScopeInput;
10
+ interface ListIndexesOutput {
11
+ indexes: IndexInfo[];
12
+ }
13
+ export declare const listIndexesProcedure: Procedure<ListIndexesInput, ListIndexesOutput, {
14
+ description: string;
15
+ effects?: Effects;
16
+ }>;
17
+ export type { ListIndexesInput, ListIndexesOutput };
18
+ //# sourceMappingURL=indexes.list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexes.list.d.ts","sourceRoot":"","sources":["../../src/procedures/indexes.list.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,KAAK,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAG7D,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,wCAAwC;AACxC,KAAK,gBAAgB,GAAG,UAAU,CAAC;AAEnC,UAAU,iBAAiB;IACzB,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB;AAqBD,eAAO,MAAM,oBAAoB,EAAE,SAAS,CAC1C,gBAAgB,EAChB,iBAAiB,EACjB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAuBlC,CAAC;AAEX,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Procedure: mongo.indexes.list
3
+ * List indexes on a collection
4
+ */
5
+ import { createProcedure, zodAdapter } from "@procedures/client";
6
+ import { collectionFor } from "../scope.js";
7
+ import { scopeFields } from "./input-schemas.js";
8
+ import { z } from "zod";
9
+ import {} from "../types.js";
10
+ // Schemas
11
+ const listIndexesInputSchema = zodAdapter(z.object({ ...scopeFields() }));
12
+ const listIndexesOutputSchema = zodAdapter(z.looseObject({
13
+ indexes: z
14
+ .array(z.looseObject({
15
+ name: z.string().describe("The index name"),
16
+ key: z.record(z.string(), z.union([z.number(), z.string()])).describe("The fields of the index and their kind (1, -1, \"text\", \"hashed\")"),
17
+ unique: z.boolean().optional().describe("True for a unique index"),
18
+ sparse: z.boolean().optional().describe("True for a sparse index"),
19
+ }))
20
+ .describe("The indexes of the collection"),
21
+ }));
22
+ export const listIndexesProcedure = createProcedure()
23
+ .path(["mongo", "indexes", "list"])
24
+ .input(listIndexesInputSchema)
25
+ .output(listIndexesOutputSchema)
26
+ .meta({
27
+ description: "List indexes on a collection",
28
+ effects: { reads: ["mongo", "network"], writes: [] },
29
+ })
30
+ .handler(async (input, ctx) => {
31
+ const { collection } = await collectionFor(input, ctx);
32
+ const indexes = await collection.listIndexes().toArray();
33
+ return {
34
+ indexes: indexes.map((idx) => ({
35
+ name: idx.name,
36
+ key: idx.key,
37
+ unique: idx.unique,
38
+ sparse: idx.sparse,
39
+ })),
40
+ };
41
+ })
42
+ .build();
43
+ //# sourceMappingURL=indexes.list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexes.list.js","sourceRoot":"","sources":["../../src/procedures/indexes.list.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAuD,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAkB,MAAM,aAAa,CAAC;AAU7C,UAAU;AACV,MAAM,sBAAsB,GAAG,UAAU,CACvC,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,WAAW,EAAE,EAAE,CAAC,CAC/B,CAAC;AACF,MAAM,uBAAuB,GAAG,UAAU,CACxC,CAAC,CAAC,WAAW,CAAC;IACZ,OAAO,EAAE,CAAC;SACP,KAAK,CACJ,CAAC,CAAC,WAAW,CAAC;QACZ,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAC3C,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sEAAsE,CAAC;QAC7I,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;QAClE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;KACnE,CAAC,CACH;SACA,QAAQ,CAAC,+BAA+B,CAAC;CAC7C,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAI7B,eAAe,EAAE;KAClB,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;KAClC,KAAK,CAAC,sBAAsB,CAAC;KAC7B,MAAM,CAAC,uBAAuB,CAAC;KAC/B,IAAI,CAAC;IACJ,WAAW,EAAE,8BAA8B;IAC3C,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;CACrD,CAAC;KACD,OAAO,CAAC,KAAK,EAAE,KAAuB,EAAE,GAAqB,EAAE,EAAE;IAChE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAEvD,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;IAEzD,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAC7B,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,GAAG,EAAE,GAAG,CAAC,GAAG;YACZ,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,MAAM,EAAE,GAAG,CAAC,MAAM;SACnB,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC,CAAC;KACD,KAAK,EAAE,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The shared fields of the mongo input schemas (roadmap 2.1).
3
+ *
4
+ * Each `mongo.*` tool describes its fields, so Claude and `mark --help` know them. Before, most
5
+ * tools had a pass-through schema: the tool list showed no fields, and a field name with a
6
+ * typing error reached the handler.
7
+ *
8
+ * A write (`update`, `delete`) and `find`/`get` keep their own parse functions: they check the
9
+ * target rules of deep dive DATA-4 (exactly one of `id` or `filter`, an unknown field is an
10
+ * error, an empty filter needs `confirm`). `described()` gives such a function the JSON Schema of
11
+ * a zod object that names the same fields.
12
+ */
13
+ import { z } from "zod";
14
+ import { type ZodLikeSchema } from "@procedures/client";
15
+ /** The fields that select the database and the collection. */
16
+ export declare function scopeFields(): {
17
+ collection: z.ZodOptional<z.ZodString>;
18
+ database: z.ZodOptional<z.ZodString>;
19
+ };
20
+ /** A MongoDB document or a filter: an object with any fields. */
21
+ export declare function documentObject(): z.ZodRecord<z.ZodString, z.ZodUnknown>;
22
+ /** The fields that select the documents of a write: one `id`, or a `filter`. */
23
+ export declare function targetFields(): {
24
+ filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
25
+ id: z.ZodOptional<z.ZodString>;
26
+ idType: z.ZodOptional<z.ZodEnum<{
27
+ auto: "auto";
28
+ objectId: "objectId";
29
+ string: "string";
30
+ }>>;
31
+ multi: z.ZodOptional<z.ZodBoolean>;
32
+ confirm: z.ZodOptional<z.ZodBoolean>;
33
+ };
34
+ /** How to read a string id. */
35
+ export declare function idTypeField(): z.ZodOptional<z.ZodEnum<{
36
+ auto: "auto";
37
+ objectId: "objectId";
38
+ string: "string";
39
+ }>>;
40
+ /**
41
+ * A schema whose validation is a parse function, and whose JSON Schema is the one of a zod object
42
+ * that names the same fields.
43
+ */
44
+ export declare function described<T>(parse: (data: unknown) => T, fields: z.ZodObject): ZodLikeSchema<T>;
45
+ //# sourceMappingURL=input-schemas.d.ts.map
@@ -0,0 +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,CAAC;AACxB,OAAO,EAA4B,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;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CAAC,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,CAE/F"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The shared fields of the mongo input schemas (roadmap 2.1).
3
+ *
4
+ * Each `mongo.*` tool describes its fields, so Claude and `mark --help` know them. Before, most
5
+ * tools had a pass-through schema: the tool list showed no fields, and a field name with a
6
+ * typing error reached the handler.
7
+ *
8
+ * A write (`update`, `delete`) and `find`/`get` keep their own parse functions: they check the
9
+ * target rules of deep dive DATA-4 (exactly one of `id` or `filter`, an unknown field is an
10
+ * error, an empty filter needs `confirm`). `described()` gives such a function the JSON Schema of
11
+ * a zod object that names the same fields.
12
+ */
13
+ import { z } from "zod";
14
+ import { jsonSchemaOf, zodAdapter } from "@procedures/client";
15
+ /** The fields that select the database and the collection. */
16
+ export function scopeFields() {
17
+ return {
18
+ collection: z.string().min(1).optional().describe("The collection name. It takes the place of metadata.collection."),
19
+ database: z.string().min(1).optional().describe("The database name (default: the database of the connection)"),
20
+ };
21
+ }
22
+ /** A MongoDB document or a filter: an object with any fields. */
23
+ export function documentObject() {
24
+ return z.record(z.string(), z.unknown());
25
+ }
26
+ /** The fields that select the documents of a write: one `id`, or a `filter`. */
27
+ export function targetFields() {
28
+ return {
29
+ filter: documentObject()
30
+ .optional()
31
+ .describe("The filter of the documents (give exactly one of id or filter). An empty filter needs confirm: true."),
32
+ id: z.string().min(1).optional().describe("The id of one document (the alternative to filter)"),
33
+ idType: idTypeField(),
34
+ multi: z.boolean().optional().describe("Change every matching document, not only the first one"),
35
+ confirm: z.boolean().optional().describe("Set to true to use an empty filter, which matches every document"),
36
+ };
37
+ }
38
+ /** How to read a string id. */
39
+ export function idTypeField() {
40
+ return z
41
+ .enum(["auto", "objectId", "string"])
42
+ .optional()
43
+ .describe('How to read the id: "auto" (the default: an ObjectId or a string), "objectId" or "string"');
44
+ }
45
+ /**
46
+ * A schema whose validation is a parse function, and whose JSON Schema is the one of a zod object
47
+ * that names the same fields.
48
+ */
49
+ export function described(parse, fields) {
50
+ return Object.assign(zodAdapter({ parse }), { "~jsonSchema": jsonSchemaOf(fields) });
51
+ }
52
+ //# sourceMappingURL=input-schemas.js.map
@@ -0,0 +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,UAAU,EAAsB,MAAM,oBAAoB,CAAC;AAElF,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,sGAAsG,CAAC;QACnH,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;QAC/F,MAAM,EAAE,WAAW,EAAE;QACrB,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wDAAwD,CAAC;QAChG,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kEAAkE,CAAC;KAC7G,CAAC;AACJ,CAAC;AAED,+BAA+B;AAC/B,MAAM,UAAU,WAAW;IACzB,OAAO,CAAC;SACL,IAAI,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;SACpC,QAAQ,EAAE;SACV,QAAQ,CAAC,2FAA2F,CAAC,CAAC;AAC3G,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAI,KAA2B,EAAE,MAAmB;IAC3E,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAI,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { outputSchema as schema } from "@procedures/client";
2
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/procedures/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { outputSchema as schema } from "@procedures/client";
2
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/procedures/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The target of a write: one document by `id`, or the documents that match a `filter`.
3
+ *
4
+ * Before, a call without `id` and `filter` used the filter `{}`, and the field name of
5
+ * `find`/`count` (`query`) was ignored: `delete { query, multi: true }` emptied the
6
+ * collection (deep dive DATA-4). Now a write needs exactly one target, an unknown field is an
7
+ * error, and an empty filter needs `confirm: true`.
8
+ */
9
+ import { type Collection, type Document } from "mongodb";
10
+ import { type DocumentQuery, type IdType } from "../types.js";
11
+ import { type ScopeInput } from "../scope.js";
12
+ /** The fields of a write target. */
13
+ export interface TargetInput extends ScopeInput {
14
+ /** The filter of the documents to change. An empty filter needs `confirm: true`. */
15
+ filter?: DocumentQuery;
16
+ /** The ID of one document (the alternative to `filter`). */
17
+ id?: string;
18
+ /** How to read the ID (default: "auto", which matches an ObjectId or a string). */
19
+ idType?: IdType;
20
+ /** Change all matching documents, not only the first one. */
21
+ multi?: boolean;
22
+ /** Set to true to use an empty filter (it matches every document). */
23
+ confirm?: boolean;
24
+ }
25
+ /**
26
+ * This function reads and checks the target fields of a write input.
27
+ * `extraFields` are the other fields that the procedure accepts.
28
+ */
29
+ export declare function parseTarget(procedure: string, data: unknown, extraFields?: readonly string[]): {
30
+ target: TargetInput;
31
+ raw: Record<string, unknown>;
32
+ };
33
+ /** The filter of a target. */
34
+ export declare function targetFilter(target: TargetInput): Document;
35
+ /**
36
+ * The filter of an upsert by ID. It names one exact `_id`.
37
+ *
38
+ * In the "auto" mode the ID filter is `$or` of the ObjectId and the string form. MongoDB cannot
39
+ * take an `_id` from `$or`, so each upsert inserted a new document with a new ID (deep dive
40
+ * DATA-15). This function uses the `_id` of the existing document, or the ObjectId form when no
41
+ * document matches.
42
+ */
43
+ export declare function upsertFilter(collection: Collection<Document>, target: TargetInput): Promise<Document>;
44
+ //# sourceMappingURL=target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../src/procedures/target.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAY,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAA2B,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAEvE,oCAAoC;AACpC,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC7C,oFAAoF;IACpF,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,4DAA4D;IAC5D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAeD;;;GAGG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,OAAO,EACb,WAAW,GAAE,SAAS,MAAM,EAAO,GAClC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAsDvD;AAED,8BAA8B;AAC9B,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,CAE1D;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAK3G"}