@procedures/mongo 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +6 -9
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/index.d.ts +1 -1
  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/module.d.ts +7 -1
  9. package/dist/module.d.ts.map +1 -1
  10. package/dist/module.js +9 -1
  11. package/dist/module.js.map +1 -1
  12. package/dist/procedures/collections.create.d.ts +2 -1
  13. package/dist/procedures/collections.create.d.ts.map +1 -1
  14. package/dist/procedures/collections.create.js +4 -1
  15. package/dist/procedures/collections.create.js.map +1 -1
  16. package/dist/procedures/collections.drop.d.ts +2 -1
  17. package/dist/procedures/collections.drop.d.ts.map +1 -1
  18. package/dist/procedures/collections.drop.js +5 -1
  19. package/dist/procedures/collections.drop.js.map +1 -1
  20. package/dist/procedures/collections.list.d.ts +2 -1
  21. package/dist/procedures/collections.list.d.ts.map +1 -1
  22. package/dist/procedures/collections.list.js +4 -1
  23. package/dist/procedures/collections.list.js.map +1 -1
  24. package/dist/procedures/collections.stats.d.ts +2 -1
  25. package/dist/procedures/collections.stats.d.ts.map +1 -1
  26. package/dist/procedures/collections.stats.js +4 -1
  27. package/dist/procedures/collections.stats.js.map +1 -1
  28. package/dist/procedures/database.info.d.ts +2 -1
  29. package/dist/procedures/database.info.d.ts.map +1 -1
  30. package/dist/procedures/database.info.js +4 -1
  31. package/dist/procedures/database.info.js.map +1 -1
  32. package/dist/procedures/database.ping.d.ts +2 -1
  33. package/dist/procedures/database.ping.d.ts.map +1 -1
  34. package/dist/procedures/database.ping.js +4 -1
  35. package/dist/procedures/database.ping.js.map +1 -1
  36. package/dist/procedures/documents.aggregate.d.ts +2 -1
  37. package/dist/procedures/documents.aggregate.d.ts.map +1 -1
  38. package/dist/procedures/documents.aggregate.js +5 -1
  39. package/dist/procedures/documents.aggregate.js.map +1 -1
  40. package/dist/procedures/documents.count.d.ts +2 -1
  41. package/dist/procedures/documents.count.d.ts.map +1 -1
  42. package/dist/procedures/documents.count.js +4 -1
  43. package/dist/procedures/documents.count.js.map +1 -1
  44. package/dist/procedures/documents.delete.d.ts +2 -1
  45. package/dist/procedures/documents.delete.d.ts.map +1 -1
  46. package/dist/procedures/documents.delete.js +4 -1
  47. package/dist/procedures/documents.delete.js.map +1 -1
  48. package/dist/procedures/documents.find.d.ts +2 -1
  49. package/dist/procedures/documents.find.d.ts.map +1 -1
  50. package/dist/procedures/documents.find.js +4 -1
  51. package/dist/procedures/documents.find.js.map +1 -1
  52. package/dist/procedures/documents.get.d.ts +2 -1
  53. package/dist/procedures/documents.get.d.ts.map +1 -1
  54. package/dist/procedures/documents.get.js +4 -1
  55. package/dist/procedures/documents.get.js.map +1 -1
  56. package/dist/procedures/documents.insert.d.ts +2 -1
  57. package/dist/procedures/documents.insert.d.ts.map +1 -1
  58. package/dist/procedures/documents.insert.js +4 -1
  59. package/dist/procedures/documents.insert.js.map +1 -1
  60. package/dist/procedures/documents.update.d.ts +2 -1
  61. package/dist/procedures/documents.update.d.ts.map +1 -1
  62. package/dist/procedures/documents.update.js +4 -1
  63. package/dist/procedures/documents.update.js.map +1 -1
  64. package/dist/procedures/indexes.create.d.ts +2 -1
  65. package/dist/procedures/indexes.create.d.ts.map +1 -1
  66. package/dist/procedures/indexes.create.js +5 -1
  67. package/dist/procedures/indexes.create.js.map +1 -1
  68. package/dist/procedures/indexes.drop.d.ts +2 -1
  69. package/dist/procedures/indexes.drop.d.ts.map +1 -1
  70. package/dist/procedures/indexes.drop.js +4 -1
  71. package/dist/procedures/indexes.drop.js.map +1 -1
  72. package/dist/procedures/indexes.list.d.ts +2 -1
  73. package/dist/procedures/indexes.list.d.ts.map +1 -1
  74. package/dist/procedures/indexes.list.js +4 -1
  75. package/dist/procedures/indexes.list.js.map +1 -1
  76. package/dist/register.d.ts +3 -4
  77. package/dist/register.d.ts.map +1 -1
  78. package/dist/register.js +4 -9
  79. package/dist/register.js.map +1 -1
  80. package/package.json +3 -4
  81. package/src/index.ts +1 -1
  82. package/src/module.ts +10 -1
  83. package/src/procedures/collections.create.ts +6 -3
  84. package/src/procedures/collections.drop.ts +7 -3
  85. package/src/procedures/collections.list.ts +6 -3
  86. package/src/procedures/collections.stats.ts +6 -3
  87. package/src/procedures/database.info.ts +6 -3
  88. package/src/procedures/database.ping.ts +6 -3
  89. package/src/procedures/documents.aggregate.ts +7 -3
  90. package/src/procedures/documents.count.ts +6 -3
  91. package/src/procedures/documents.delete.ts +6 -3
  92. package/src/procedures/documents.find.ts +6 -2
  93. package/src/procedures/documents.get.ts +6 -2
  94. package/src/procedures/documents.insert.ts +6 -3
  95. package/src/procedures/documents.update.ts +6 -3
  96. package/src/procedures/indexes.create.ts +7 -3
  97. package/src/procedures/indexes.drop.ts +6 -3
  98. package/src/procedures/indexes.list.ts +6 -3
  99. package/src/register.ts +4 -10
@@ -3,7 +3,7 @@
3
3
  * Count documents matching a filter
4
4
  */
5
5
 
6
- import { createProcedure, zodAdapter, type Procedure, type ProcedureContext } from "@procedures/client";
6
+ import { createProcedure, zodAdapter, 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";
@@ -34,12 +34,15 @@ const countOutputSchema = zodAdapter<CountOutput>(
34
34
  export const countProcedure: Procedure<
35
35
  CountInput,
36
36
  CountOutput,
37
- { description: string }
37
+ { description: string; effects?: Effects }
38
38
  > = createProcedure()
39
39
  .path(["mongo", "documents", "count"])
40
40
  .input(countInputSchema)
41
41
  .output(countOutputSchema)
42
- .meta({ description: "Count documents matching a filter" })
42
+ .meta({
43
+ description: "Count documents matching a filter",
44
+ effects: { reads: ["mongo", "network"], writes: [] },
45
+ })
43
46
  .handler(async (input: CountInput, ctx: ProcedureContext) => {
44
47
  const { collection } = await collectionFor(input, ctx);
45
48
 
@@ -3,7 +3,7 @@
3
3
  * Delete documents matching a filter
4
4
  */
5
5
 
6
- import { createProcedure, type Procedure, type ProcedureContext, zodAdapter } from "@procedures/client";
6
+ import { createProcedure, type Effects, type Procedure, type ProcedureContext, zodAdapter } 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";
@@ -33,12 +33,15 @@ const deleteOutputSchema = zodAdapter<DeleteOutput>(
33
33
  export const deleteProcedure: Procedure<
34
34
  DeleteInput,
35
35
  DeleteOutput,
36
- { description: string }
36
+ { description: string; effects?: Effects }
37
37
  > = createProcedure()
38
38
  .path(["mongo", "documents", "delete"])
39
39
  .input(deleteInputSchema)
40
40
  .output(deleteOutputSchema)
41
- .meta({ description: "Delete documents matching a filter" })
41
+ .meta({
42
+ description: "Delete documents matching a filter",
43
+ effects: { reads: ["mongo", "network"], writes: ["mongo", "network"] },
44
+ })
42
45
  .handler(async (input: DeleteInput, ctx: ProcedureContext) => {
43
46
  const { collection } = await collectionFor(input, ctx);
44
47
  const filter = targetFilter(input);
@@ -5,6 +5,7 @@
5
5
 
6
6
  import {
7
7
  createProcedure,
8
+ type Effects,
8
9
  type Procedure,
9
10
  type ProcedureContext,
10
11
  zodAdapter,
@@ -102,12 +103,15 @@ const findOutputSchema = zodAdapter<FindOutput>(
102
103
  export const findProcedure: Procedure<
103
104
  FindInput,
104
105
  FindOutput,
105
- { description: string }
106
+ { description: string; effects?: Effects }
106
107
  > = createProcedure()
107
108
  .path(["mongo", "documents", "find"])
108
109
  .input(findInputSchema)
109
110
  .output(findOutputSchema)
110
- .meta({ description: "Find documents with pagination and filtering" })
111
+ .meta({
112
+ description: "Find documents with pagination and filtering",
113
+ effects: { reads: ["mongo", "network"], writes: [] },
114
+ })
111
115
  .handler(async (input: FindInput, ctx: ProcedureContext) => {
112
116
  const { collection } = await collectionFor(input, ctx);
113
117
 
@@ -5,6 +5,7 @@
5
5
 
6
6
  import {
7
7
  createProcedure,
8
+ type Effects,
8
9
  type Procedure,
9
10
  type ProcedureContext,
10
11
  zodAdapter,
@@ -78,12 +79,15 @@ const getOutputSchema = zodAdapter<GetOutput>(
78
79
  export const getProcedure: Procedure<
79
80
  GetInput,
80
81
  GetOutput,
81
- { description: string }
82
+ { description: string; effects?: Effects }
82
83
  > = createProcedure()
83
84
  .path(["mongo", "documents", "get"])
84
85
  .input(getInputSchema)
85
86
  .output(getOutputSchema)
86
- .meta({ description: "Get a single document by ID" })
87
+ .meta({
88
+ description: "Get a single document by ID",
89
+ effects: { reads: ["mongo", "network"], writes: [] },
90
+ })
87
91
  .handler(async (input: GetInput, ctx: ProcedureContext) => {
88
92
  const { collection } = await collectionFor(input, ctx);
89
93
 
@@ -3,7 +3,7 @@
3
3
  * Insert one or more documents
4
4
  */
5
5
 
6
- import { createProcedure, zodAdapter, type Procedure, type ProcedureContext } from "@procedures/client";
6
+ import { createProcedure, zodAdapter, 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";
@@ -41,12 +41,15 @@ const insertOutputSchema = zodAdapter<InsertOutput>(
41
41
  export const insertProcedure: Procedure<
42
42
  InsertInput,
43
43
  InsertOutput,
44
- { description: string }
44
+ { description: string; effects?: Effects }
45
45
  > = createProcedure()
46
46
  .path(["mongo", "documents", "insert"])
47
47
  .input(insertInputSchema)
48
48
  .output(insertOutputSchema)
49
- .meta({ description: "Insert one or more documents" })
49
+ .meta({
50
+ description: "Insert one or more documents",
51
+ effects: { reads: ["mongo", "network"], writes: ["mongo", "network"], destructive: false },
52
+ })
50
53
  .handler(async (input: InsertInput, ctx: ProcedureContext) => {
51
54
  const { collection } = await collectionFor(input, ctx);
52
55
 
@@ -3,7 +3,7 @@
3
3
  * Update documents matching a filter
4
4
  */
5
5
 
6
- import { createProcedure, type Procedure, type ProcedureContext, zodAdapter } from "@procedures/client";
6
+ import { createProcedure, type Effects, type Procedure, type ProcedureContext, zodAdapter } 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";
@@ -66,12 +66,15 @@ const updateOutputSchema = zodAdapter<UpdateOutput>(
66
66
  export const updateProcedure: Procedure<
67
67
  UpdateInput,
68
68
  UpdateOutput,
69
- { description: string }
69
+ { description: string; effects?: Effects }
70
70
  > = createProcedure()
71
71
  .path(["mongo", "documents", "update"])
72
72
  .input(updateInputSchema)
73
73
  .output(updateOutputSchema)
74
- .meta({ description: "Update documents matching a filter" })
74
+ .meta({
75
+ description: "Update documents matching a filter",
76
+ effects: { reads: ["mongo", "network"], writes: ["mongo", "network"] },
77
+ })
75
78
  .handler(async (input: UpdateInput, ctx: ProcedureContext) => {
76
79
  const { collection } = await collectionFor(input, ctx);
77
80
  const upsert = input.upsert ?? false;
@@ -3,7 +3,7 @@
3
3
  * Create an index on a collection
4
4
  */
5
5
 
6
- import { createProcedure, zodAdapter, type Procedure, type ProcedureContext } from "@procedures/client";
6
+ import { createProcedure, zodAdapter, 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";
@@ -48,12 +48,16 @@ const createIndexOutputSchema = zodAdapter<CreateIndexOutput>(
48
48
  export const createIndexProcedure: Procedure<
49
49
  CreateIndexInput,
50
50
  CreateIndexOutput,
51
- { description: string }
51
+ { description: string; effects?: Effects }
52
52
  > = createProcedure()
53
53
  .path(["mongo", "indexes", "create"])
54
54
  .input(createIndexInputSchema)
55
55
  .output(createIndexOutputSchema)
56
- .meta({ description: "Create an index on a collection" })
56
+ .meta({
57
+ description: "Create an index on a collection",
58
+ // A second call with the same keys and options keeps the existing index
59
+ effects: { reads: ["mongo", "network"], writes: ["mongo", "network"], destructive: false, idempotent: true },
60
+ })
57
61
  .handler(async (input: CreateIndexInput, ctx: ProcedureContext) => {
58
62
  const { collection } = await collectionFor(input, ctx);
59
63
 
@@ -3,7 +3,7 @@
3
3
  * Drop an index from a collection
4
4
  */
5
5
 
6
- import { createProcedure, zodAdapter, type Procedure, type ProcedureContext } from "@procedures/client";
6
+ import { createProcedure, zodAdapter, 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";
@@ -33,12 +33,15 @@ const dropIndexOutputSchema = zodAdapter<DropIndexOutput>(
33
33
  export const dropIndexProcedure: Procedure<
34
34
  DropIndexInput,
35
35
  DropIndexOutput,
36
- { description: string }
36
+ { description: string; effects?: Effects }
37
37
  > = createProcedure()
38
38
  .path(["mongo", "indexes", "drop"])
39
39
  .input(dropIndexInputSchema)
40
40
  .output(dropIndexOutputSchema)
41
- .meta({ description: "Drop an index from a collection" })
41
+ .meta({
42
+ description: "Drop an index from a collection",
43
+ effects: { reads: ["mongo", "network"], writes: ["mongo", "network"] },
44
+ })
42
45
  .handler(async (input: DropIndexInput, ctx: ProcedureContext) => {
43
46
  const { collection } = await collectionFor(input, ctx);
44
47
 
@@ -3,7 +3,7 @@
3
3
  * List indexes on a collection
4
4
  */
5
5
 
6
- import { createProcedure, zodAdapter, type Procedure, type ProcedureContext } from "@procedures/client";
6
+ import { createProcedure, zodAdapter, 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";
@@ -39,12 +39,15 @@ const listIndexesOutputSchema = zodAdapter<ListIndexesOutput>(
39
39
  export const listIndexesProcedure: Procedure<
40
40
  ListIndexesInput,
41
41
  ListIndexesOutput,
42
- { description: string }
42
+ { description: string; effects?: Effects }
43
43
  > = createProcedure()
44
44
  .path(["mongo", "indexes", "list"])
45
45
  .input(listIndexesInputSchema)
46
46
  .output(listIndexesOutputSchema)
47
- .meta({ description: "List indexes on a collection" })
47
+ .meta({
48
+ description: "List indexes on a collection",
49
+ effects: { reads: ["mongo", "network"], writes: [] },
50
+ })
48
51
  .handler(async (input: ListIndexesInput, ctx: ProcedureContext) => {
49
52
  const { collection } = await collectionFor(input, ctx);
50
53
 
package/src/register.ts CHANGED
@@ -1,17 +1,11 @@
1
1
  /**
2
- * Importing this file registers the procedures of @procedures/mongo in the global registry
3
- * (DECISIONS-2026-10, "Every package root registers its procedures"). The procedures as data
4
- * are in `module.ts`, which registers nothing: a host with its own registry uses that one.
2
+ * Importing this file registers the procedures of @procedures/mongo, and of the modules that it
3
+ * requires, in the global registry: `import "@procedures/mongo/register"`. The package root and the
4
+ * `./module` entry register nothing (ARCHITECTURE-PROPOSALS-2026-10, P9).
5
5
  */
6
6
 
7
- import { registerProcedures } from "@procedures/client";
8
- import { mongoModule } from "./module.js";
7
+ import { registerMongoProcedures } from "./module.js";
9
8
 
10
9
  export * from "./module.js";
11
10
 
12
- export function registerMongoProcedures(): void {
13
- registerProcedures(mongoModule.procedures);
14
- }
15
-
16
- // Auto-register when this module is loaded
17
11
  registerMongoProcedures();