@shipeasy/openapi 1.6.0 → 2.1.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 (151) hide show
  1. package/README.md +37 -0
  2. package/dist/chunk-EPLLHLZN.js +1616 -0
  3. package/dist/chunk-EPLLHLZN.js.map +1 -0
  4. package/dist/chunk-SPH5HWCD.js +3326 -0
  5. package/dist/chunk-SPH5HWCD.js.map +1 -0
  6. package/dist/client-pVkoo3Bf.d.ts +11186 -0
  7. package/dist/client.d.ts +1 -0
  8. package/dist/client.js +215 -0
  9. package/dist/client.js.map +1 -0
  10. package/dist/custom.d.ts +64 -0
  11. package/dist/custom.js +292 -0
  12. package/dist/custom.js.map +1 -0
  13. package/dist/index.d.ts +29 -41
  14. package/dist/index.js +258 -4375
  15. package/dist/index.js.map +1 -0
  16. package/dist/node-context.d.ts +81 -33
  17. package/dist/node-context.js +98 -44
  18. package/dist/node-context.js.map +1 -0
  19. package/dist/schemas.d.ts +7920 -0
  20. package/dist/schemas.js +1083 -0
  21. package/dist/schemas.js.map +1 -0
  22. package/openapi.json +15297 -3044
  23. package/openapi.yaml +13979 -0
  24. package/package.json +33 -26
  25. package/spec/components/errors.yaml +53 -0
  26. package/spec/components/parameters.yaml +24 -0
  27. package/spec/components/responses.yaml +107 -0
  28. package/spec/components/schemas/alert-rules.yaml +175 -0
  29. package/spec/components/schemas/attributes.yaml +157 -0
  30. package/spec/components/schemas/common.yaml +87 -0
  31. package/spec/components/schemas/configs.yaml +371 -0
  32. package/spec/components/schemas/connectors.yaml +593 -0
  33. package/spec/components/schemas/errors-api.yaml +209 -0
  34. package/spec/components/schemas/events.yaml +321 -0
  35. package/spec/components/schemas/experiments.yaml +865 -0
  36. package/spec/components/schemas/gate-templates.yaml +198 -0
  37. package/spec/components/schemas/gates.yaml +890 -0
  38. package/spec/components/schemas/i18n.yaml +478 -0
  39. package/spec/components/schemas/keys.yaml +186 -0
  40. package/spec/components/schemas/killswitches.yaml +309 -0
  41. package/spec/components/schemas/metrics.yaml +547 -0
  42. package/spec/components/schemas/ops.yaml +1011 -0
  43. package/spec/components/schemas/projects.yaml +222 -0
  44. package/spec/components/schemas/search.yaml +46 -0
  45. package/spec/components/schemas/universes.yaml +127 -0
  46. package/spec/openapi.yaml +348 -0
  47. package/spec/paths/alert-rules.yaml +250 -0
  48. package/spec/paths/attributes.yaml +261 -0
  49. package/spec/paths/configs.yaml +744 -0
  50. package/spec/paths/connectors.yaml +748 -0
  51. package/spec/paths/errors.yaml +382 -0
  52. package/spec/paths/events.yaml +366 -0
  53. package/spec/paths/experiments.yaml +777 -0
  54. package/spec/paths/gate-templates.yaml +263 -0
  55. package/spec/paths/gates.yaml +451 -0
  56. package/spec/paths/i18n.yaml +544 -0
  57. package/spec/paths/keys.yaml +181 -0
  58. package/spec/paths/killswitches.yaml +557 -0
  59. package/spec/paths/metrics.yaml +302 -0
  60. package/spec/paths/ops.yaml +446 -0
  61. package/spec/paths/projects.yaml +210 -0
  62. package/spec/paths/search.yaml +62 -0
  63. package/spec/paths/universes.yaml +247 -0
  64. package/dist/operations/attributes.d.ts +0 -33
  65. package/dist/operations/attributes.js +0 -16
  66. package/dist/operations/cli-adapter.d.ts +0 -35
  67. package/dist/operations/cli-adapter.js +0 -91
  68. package/dist/operations/coerce.d.ts +0 -32
  69. package/dist/operations/coerce.js +0 -53
  70. package/dist/operations/configs.d.ts +0 -28
  71. package/dist/operations/configs.js +0 -119
  72. package/dist/operations/docs.d.ts +0 -37
  73. package/dist/operations/docs.js +0 -39
  74. package/dist/operations/events.d.ts +0 -28
  75. package/dist/operations/events.js +0 -121
  76. package/dist/operations/experiments.d.ts +0 -28
  77. package/dist/operations/experiments.js +0 -280
  78. package/dist/operations/gates.d.ts +0 -28
  79. package/dist/operations/gates.js +0 -132
  80. package/dist/operations/i18n.d.ts +0 -28
  81. package/dist/operations/i18n.js +0 -121
  82. package/dist/operations/index.d.ts +0 -63
  83. package/dist/operations/index.js +0 -1751
  84. package/dist/operations/killswitches.d.ts +0 -28
  85. package/dist/operations/killswitches.js +0 -126
  86. package/dist/operations/mcp-adapter.d.ts +0 -35
  87. package/dist/operations/mcp-adapter.js +0 -94
  88. package/dist/operations/metrics.d.ts +0 -30
  89. package/dist/operations/metrics.js +0 -114
  90. package/dist/operations/ops.d.ts +0 -28
  91. package/dist/operations/ops.js +0 -313
  92. package/dist/operations/projects.d.ts +0 -28
  93. package/dist/operations/projects.js +0 -36
  94. package/dist/operations/sdk-docs.d.ts +0 -28
  95. package/dist/operations/sdk-docs.js +0 -160
  96. package/dist/operations/types.d.ts +0 -138
  97. package/dist/operations/types.js +0 -9
  98. package/dist/operations/universes.d.ts +0 -28
  99. package/dist/operations/universes.js +0 -93
  100. package/dist/operations/util.d.ts +0 -33
  101. package/dist/operations/util.js +0 -9
  102. package/dist/resources/alert-rules.d.ts +0 -50
  103. package/dist/resources/alert-rules.js +0 -75
  104. package/dist/resources/attributes.d.ts +0 -19
  105. package/dist/resources/attributes.js +0 -10
  106. package/dist/resources/configs.d.ts +0 -681
  107. package/dist/resources/configs.js +0 -509
  108. package/dist/resources/events.d.ts +0 -61
  109. package/dist/resources/events.js +0 -42
  110. package/dist/resources/experiments.d.ts +0 -849
  111. package/dist/resources/experiments.js +0 -707
  112. package/dist/resources/gates.d.ts +0 -808
  113. package/dist/resources/gates.js +0 -522
  114. package/dist/resources/i18n.d.ts +0 -84
  115. package/dist/resources/i18n.js +0 -60
  116. package/dist/resources/index.d.ts +0 -2767
  117. package/dist/resources/index.js +0 -2563
  118. package/dist/resources/killswitches.d.ts +0 -436
  119. package/dist/resources/killswitches.js +0 -514
  120. package/dist/resources/metrics.d.ts +0 -54
  121. package/dist/resources/metrics.js +0 -40
  122. package/dist/resources/ops.d.ts +0 -88
  123. package/dist/resources/ops.js +0 -36
  124. package/dist/resources/projects.d.ts +0 -54
  125. package/dist/resources/projects.js +0 -14
  126. package/dist/resources/universes.d.ts +0 -185
  127. package/dist/resources/universes.js +0 -234
  128. package/dist/schemas/alert-rules.d.ts +0 -65
  129. package/dist/schemas/alert-rules.js +0 -37
  130. package/dist/schemas/configs.d.ts +0 -154
  131. package/dist/schemas/configs.js +0 -134
  132. package/dist/schemas/constants.d.ts +0 -6
  133. package/dist/schemas/constants.js +0 -7
  134. package/dist/schemas/experiments.d.ts +0 -229
  135. package/dist/schemas/experiments.js +0 -221
  136. package/dist/schemas/folder.d.ts +0 -10
  137. package/dist/schemas/folder.js +0 -8
  138. package/dist/schemas/gates.d.ts +0 -386
  139. package/dist/schemas/gates.js +0 -190
  140. package/dist/schemas/index.d.ts +0 -11
  141. package/dist/schemas/index.js +0 -762
  142. package/dist/schemas/killswitches.d.ts +0 -110
  143. package/dist/schemas/killswitches.js +0 -226
  144. package/dist/schemas/metric-name.d.ts +0 -5
  145. package/dist/schemas/metric-name.js +0 -6
  146. package/dist/schemas/pagination.d.ts +0 -37
  147. package/dist/schemas/pagination.js +0 -44
  148. package/dist/schemas/universes.d.ts +0 -35
  149. package/dist/schemas/universes.js +0 -55
  150. package/dist/transport.d.ts +0 -30
  151. package/dist/transport.js +0 -44
@@ -0,0 +1,62 @@
1
+ /api/admin/search:
2
+ get:
3
+ operationId: searchResources
4
+ summary: Search project resources
5
+ description: |-
6
+ Universal substring search across the project's primary resources — feature gates, experiments, dynamic configs, killswitches, metrics, and team members. Matches the trimmed `q` against each resource's immutable `name` and its human title/display name (members match on display name or email), newest-first, capped per resource family so one noisy type can't crowd out the rest.
7
+
8
+ Returns a flat, ranked-by-type list of hits (members first); an empty or whitespace-only `q` returns no hits. Each hit carries a project-relative `href` that deep-links to the row.
9
+
10
+ **Use case:** Back a command-palette / quick-switcher in the dashboard, or look up the id of a resource by a fragment of its name before driving another API call.
11
+ tags:
12
+ - Projects
13
+ parameters:
14
+ - $ref: ../components/parameters.yaml#/ProjectId
15
+ - name: q
16
+ in: query
17
+ required: false
18
+ description: Search query. Matched as a case-insensitive substring against each resource's `name` and title/display name. Trimmed; empty returns no hits.
19
+ schema:
20
+ type: string
21
+ responses:
22
+ "200":
23
+ description: Search project resources
24
+ content:
25
+ application/json:
26
+ schema:
27
+ $ref: ../components/schemas/search.yaml#/SearchResponse
28
+ example:
29
+ hits:
30
+ - type: member
31
+ id: ana@example.com
32
+ name: Ana Ng
33
+ title: ana@example.com
34
+ href: /team
35
+ - type: gate
36
+ id: gat_01j7w7m9q4hxbf6npe6s9zr3vc
37
+ name: checkout_v2
38
+ title: Checkout v2
39
+ href: /gates?open=gat_01j7w7m9q4hxbf6npe6s9zr3vc
40
+ - type: experiment
41
+ id: exp_01j7w7m9q4hxbf6npe6s9zr3vd
42
+ name: checkout_button_color
43
+ title: Checkout button colour test
44
+ href: /experiments?open=exp_01j7w7m9q4hxbf6npe6s9zr3vd
45
+ "400":
46
+ $ref: ../components/responses.yaml#/BadRequest
47
+ "401":
48
+ $ref: ../components/responses.yaml#/Unauthorized
49
+ "403":
50
+ $ref: ../components/responses.yaml#/Forbidden
51
+ "404":
52
+ $ref: ../components/responses.yaml#/NotFound
53
+ "409":
54
+ $ref: ../components/responses.yaml#/Conflict
55
+ "422":
56
+ $ref: ../components/responses.yaml#/UnprocessableEntity
57
+ x-error-codes:
58
+ - BAD_REQUEST
59
+ - UNAUTHORIZED
60
+ - FORBIDDEN
61
+ x-cli:
62
+ name: search
@@ -0,0 +1,247 @@
1
+ /api/admin/universes:
2
+ get:
3
+ operationId: listUniverses
4
+ summary: List universes
5
+ description: |-
6
+ Returns a single page of universes ordered by `created_at desc, id desc`. The universes table has no `updated_at`, so this list is keyed on creation time.
7
+
8
+ **Use case:** Snapshot every universe in the project — for example to audit which `unit_type` and `holdout_range` are in use before launching a new experiment.
9
+ tags:
10
+ - Universes
11
+ parameters:
12
+ - $ref: ../components/parameters.yaml#/ProjectId
13
+ - $ref: ../components/parameters.yaml#/PaginationLimit
14
+ - $ref: ../components/parameters.yaml#/PaginationCursor
15
+ responses:
16
+ "200":
17
+ description: List universes
18
+ content:
19
+ application/json:
20
+ schema:
21
+ $ref: ../components/schemas/universes.yaml#/ListUniversesResponse
22
+ example:
23
+ data:
24
+ - id: uni_01j7w8a1b2c3d4e5f6g7h8i9j0
25
+ name: primary_users
26
+ unitType: user_id
27
+ holdoutRange:
28
+ - 9500
29
+ - 9999
30
+ createdAt: 2026-04-12T10:14:08.000Z
31
+ next_cursor: null
32
+ "400":
33
+ $ref: ../components/responses.yaml#/BadRequest
34
+ "401":
35
+ $ref: ../components/responses.yaml#/Unauthorized
36
+ "403":
37
+ $ref: ../components/responses.yaml#/Forbidden
38
+ "404":
39
+ $ref: ../components/responses.yaml#/NotFound
40
+ "409":
41
+ $ref: ../components/responses.yaml#/Conflict
42
+ "422":
43
+ $ref: ../components/responses.yaml#/UnprocessableEntity
44
+ x-error-codes:
45
+ - BAD_REQUEST
46
+ - UNAUTHORIZED
47
+ - FORBIDDEN
48
+ x-cli:
49
+ name: list
50
+ post:
51
+ operationId: createUniverse
52
+ summary: Create a universe
53
+ description: |-
54
+ Creates a new universe. Only `name` is required — `unit_type` defaults to `user_id` and `holdout_range` defaults to `null` (no holdout).
55
+
56
+ Returns `409` if `name` already exists in the project. Returns `403` if you supply `holdout_range` on a plan below Pro.
57
+
58
+ **Use cases**
59
+
60
+ - **Default universe** — `{ "name": "primary_users" }`. Per-user randomisation, no holdout.
61
+ - **Reserved holdout** — supply `holdout_range` to carve out a measurement slice excluded from all experiments.
62
+ - **Account-level** — `unit_type: 'account_id'` so multi-seat accounts see one consistent variant.
63
+ tags:
64
+ - Universes
65
+ parameters:
66
+ - $ref: ../components/parameters.yaml#/ProjectId
67
+ requestBody:
68
+ required: true
69
+ content:
70
+ application/json:
71
+ schema:
72
+ $ref: ../components/schemas/universes.yaml#/CreateUniverseRequest
73
+ examples:
74
+ minimal:
75
+ summary: Minimal — name only
76
+ description: Smallest valid body. Creates a `user_id`-keyed universe with no holdout.
77
+ value:
78
+ name: primary_users
79
+ holdout:
80
+ summary: Holdout — reserve 5% for measurement
81
+ description: Reserves buckets 9500–9999 (5% of callers) as the holdout. Pro plan or higher.
82
+ value:
83
+ name: primary_users
84
+ holdout_range:
85
+ - 9500
86
+ - 9999
87
+ accountLevel:
88
+ summary: Account-level randomisation
89
+ description: "Bucket whole accounts together via `unit_type: 'account_id'`."
90
+ value:
91
+ name: saas_accounts
92
+ unit_type: account_id
93
+ responses:
94
+ "201":
95
+ description: Create a universe
96
+ content:
97
+ application/json:
98
+ schema:
99
+ $ref: ../components/schemas/universes.yaml#/CreateUniverseResponse
100
+ example:
101
+ id: uni_01j7w8a1b2c3d4e5f6g7h8i9j0
102
+ name: primary_users
103
+ "400":
104
+ $ref: ../components/responses.yaml#/BadRequest
105
+ "401":
106
+ $ref: ../components/responses.yaml#/Unauthorized
107
+ "403":
108
+ $ref: ../components/responses.yaml#/Forbidden
109
+ "404":
110
+ $ref: ../components/responses.yaml#/NotFound
111
+ "409":
112
+ $ref: ../components/responses.yaml#/Conflict
113
+ "422":
114
+ $ref: ../components/responses.yaml#/UnprocessableEntity
115
+ x-error-codes:
116
+ - BAD_REQUEST
117
+ - UNAUTHORIZED
118
+ - FORBIDDEN
119
+ - PLAN_REQUIRED
120
+ - ALREADY_EXISTS
121
+ - VALIDATION
122
+ x-cli:
123
+ name: create
124
+ positional:
125
+ - name
126
+ /api/admin/universes/{id}:
127
+ patch:
128
+ operationId: updateUniverse
129
+ summary: Update a universe
130
+ description: |-
131
+ Partial update. Only `holdout_range` is mutable — `name` and `unit_type` are immutable after create.
132
+
133
+ Pass `"holdout_range": null` to remove an existing holdout.
134
+
135
+ **Use cases**
136
+
137
+ - **Adjust holdout** — change the reserved measurement slice without recreating experiments.
138
+ - **Remove holdout** — `{ "holdout_range": null }`.
139
+ tags:
140
+ - Universes
141
+ parameters:
142
+ - $ref: ../components/parameters.yaml#/ProjectId
143
+ - name: id
144
+ in: path
145
+ required: true
146
+ description: Stable opaque universe id (`uni_…`) or the universe's `name`.
147
+ schema:
148
+ type: string
149
+ requestBody:
150
+ required: true
151
+ content:
152
+ application/json:
153
+ schema:
154
+ $ref: ../components/schemas/universes.yaml#/UpdateUniverseRequest
155
+ examples:
156
+ setHoldout:
157
+ summary: Set holdout — reserve 5%
158
+ description: Reserve buckets 9500–9999 as the holdout. Pro plan or higher.
159
+ value:
160
+ holdout_range:
161
+ - 9500
162
+ - 9999
163
+ removeHoldout:
164
+ summary: Remove holdout
165
+ description: Disable the holdout entirely.
166
+ value:
167
+ holdout_range: null
168
+ responses:
169
+ "200":
170
+ description: Update a universe
171
+ content:
172
+ application/json:
173
+ schema:
174
+ $ref: ../components/schemas/universes.yaml#/UpdateUniverseResponse
175
+ example:
176
+ id: uni_01j7w8a1b2c3d4e5f6g7h8i9j0
177
+ "400":
178
+ $ref: ../components/responses.yaml#/BadRequest
179
+ "401":
180
+ $ref: ../components/responses.yaml#/Unauthorized
181
+ "403":
182
+ $ref: ../components/responses.yaml#/Forbidden
183
+ "404":
184
+ $ref: ../components/responses.yaml#/NotFound
185
+ "409":
186
+ $ref: ../components/responses.yaml#/Conflict
187
+ "422":
188
+ $ref: ../components/responses.yaml#/UnprocessableEntity
189
+ x-error-codes:
190
+ - BAD_REQUEST
191
+ - UNAUTHORIZED
192
+ - FORBIDDEN
193
+ - PLAN_REQUIRED
194
+ - NOT_FOUND
195
+ - VALIDATION
196
+ x-cli:
197
+ name: update
198
+ positional:
199
+ - id
200
+ delete:
201
+ operationId: deleteUniverse
202
+ summary: Delete a universe
203
+ description: |-
204
+ Soft-deletes the universe. Returns `409` if any non-archived experiment still references it — archive those experiments first.
205
+
206
+ **Use case:** Tear down a universe after every experiment that used it has been archived.
207
+ tags:
208
+ - Universes
209
+ parameters:
210
+ - $ref: ../components/parameters.yaml#/ProjectId
211
+ - name: id
212
+ in: path
213
+ required: true
214
+ description: Stable opaque universe id (`uni_…`) or the universe's `name`.
215
+ schema:
216
+ type: string
217
+ responses:
218
+ "200":
219
+ description: Delete a universe
220
+ content:
221
+ application/json:
222
+ schema:
223
+ $ref: ../components/schemas/universes.yaml#/DeleteUniverseResponse
224
+ example:
225
+ ok: true
226
+ "400":
227
+ $ref: ../components/responses.yaml#/BadRequest
228
+ "401":
229
+ $ref: ../components/responses.yaml#/Unauthorized
230
+ "403":
231
+ $ref: ../components/responses.yaml#/Forbidden
232
+ "404":
233
+ $ref: ../components/responses.yaml#/NotFound
234
+ "409":
235
+ $ref: ../components/responses.yaml#/Conflict
236
+ "422":
237
+ $ref: ../components/responses.yaml#/UnprocessableEntity
238
+ x-error-codes:
239
+ - BAD_REQUEST
240
+ - UNAUTHORIZED
241
+ - FORBIDDEN
242
+ - NOT_FOUND
243
+ - REFERENCED_IN_USE
244
+ x-cli:
245
+ name: archive
246
+ positional:
247
+ - id
@@ -1,33 +0,0 @@
1
- import { Operation } from './types.js';
2
- import '../resources/index.js';
3
- import 'zod/v4/core';
4
- import 'zod';
5
- import '../resources/attributes.js';
6
- import '../transport.js';
7
- import '../resources/i18n.js';
8
- import '../resources/projects.js';
9
- import '../resources/ops.js';
10
- import '../resources/events.js';
11
- import '../resources/metrics.js';
12
- import '../resources/alert-rules.js';
13
- import '../schemas/alert-rules.js';
14
- import '../resources/killswitches.js';
15
- import '../schemas/killswitches.js';
16
- import '../schemas/pagination.js';
17
- import '../resources/universes.js';
18
- import '../schemas/universes.js';
19
- import '../resources/configs.js';
20
- import '../schemas/configs.js';
21
- import '../resources/experiments.js';
22
- import '../schemas/experiments.js';
23
- import '../resources/gates.js';
24
- import '../schemas/gates.js';
25
-
26
- /**
27
- * Attribute operations — `attributes …`. One read-only op so the typed
28
- * `attributes_list` MCP tool replaces the `attributes` kind of the deleted
29
- * generic-read path (doc 21 §A4.3).
30
- */
31
- declare const attributeOperations: Operation[];
32
-
33
- export { attributeOperations };
@@ -1,16 +0,0 @@
1
- // src/operations/attributes.ts
2
- var attributeOperations = [
3
- {
4
- group: ["attributes"],
5
- name: "list",
6
- mutates: false,
7
- summary: "List targeting attributes",
8
- description: "List the auto-inferred user-attribute schema available for gate/experiment targeting.",
9
- params: [],
10
- examples: [{ run: "shipeasy attributes list" }],
11
- run: (client) => client.attributes.list()
12
- }
13
- ];
14
- export {
15
- attributeOperations
16
- };
@@ -1,35 +0,0 @@
1
- import { CommandLike, Operation, CliContext } from './types.js';
2
- import '../resources/index.js';
3
- import 'zod/v4/core';
4
- import 'zod';
5
- import '../resources/attributes.js';
6
- import '../transport.js';
7
- import '../resources/i18n.js';
8
- import '../resources/projects.js';
9
- import '../resources/ops.js';
10
- import '../resources/events.js';
11
- import '../resources/metrics.js';
12
- import '../resources/alert-rules.js';
13
- import '../schemas/alert-rules.js';
14
- import '../resources/killswitches.js';
15
- import '../schemas/killswitches.js';
16
- import '../schemas/pagination.js';
17
- import '../resources/universes.js';
18
- import '../schemas/universes.js';
19
- import '../resources/configs.js';
20
- import '../schemas/configs.js';
21
- import '../resources/experiments.js';
22
- import '../schemas/experiments.js';
23
- import '../resources/gates.js';
24
- import '../schemas/gates.js';
25
-
26
- /**
27
- * Mount every operation as a commander subcommand under `group`. The CLI passes
28
- * its own commander `Command` (which satisfies `CommandLike`) and a `CliContext`
29
- * carrying the bits `@shipeasy/openapi` must not own (client resolution, table
30
- * formatting, process.exit). Replaces the per-command hand-wiring in
31
- * `packages/cli/src/commands/*`.
32
- */
33
- declare function mountOperations(group: CommandLike, ops: Operation[], ctx: CliContext): void;
34
-
35
- export { mountOperations };
@@ -1,91 +0,0 @@
1
- // src/transport.ts
2
- var ApiError = class extends Error {
3
- constructor(message, status) {
4
- super(message);
5
- this.status = status;
6
- this.name = "ApiError";
7
- }
8
- status;
9
- };
10
-
11
- // src/operations/coerce.ts
12
- function coerceValue(param, raw) {
13
- if (raw === void 0 || raw === null) return void 0;
14
- switch (param.type) {
15
- case "number": {
16
- const n = typeof raw === "number" ? raw : Number(raw);
17
- if (!Number.isFinite(n)) throw new ApiError(`--${param.name} must be a number`, 400);
18
- return n;
19
- }
20
- case "boolean":
21
- return raw === true || raw === "true" || raw === "1";
22
- case "json":
23
- if (typeof raw !== "string") return raw;
24
- try {
25
- return JSON.parse(raw);
26
- } catch {
27
- throw new ApiError(`--${param.name} must be valid JSON`, 400);
28
- }
29
- case "string":
30
- default: {
31
- const s = String(raw);
32
- if (param.enum && !param.enum.includes(s)) {
33
- throw new ApiError(`--${param.name} must be one of: ${param.enum.join(", ")}`, 400);
34
- }
35
- return s;
36
- }
37
- }
38
- }
39
- function coerceInput(op, raw) {
40
- const out = {};
41
- for (const param of op.params) {
42
- const value = coerceValue(param, raw[param.name]);
43
- if (value === void 0) {
44
- if (param.required) throw new ApiError(`${param.name} is required`, 400);
45
- continue;
46
- }
47
- out[param.name] = value;
48
- }
49
- return out;
50
- }
51
-
52
- // src/operations/cli-adapter.ts
53
- var toKebab = (s) => s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
54
- function commandSignature(op) {
55
- const positionals = op.params.filter((p) => p.positional).map((p) => p.required === false ? `[${p.name}]` : `<${p.name}>`);
56
- return [op.name, ...positionals].join(" ");
57
- }
58
- function mountOperations(group, ops, ctx) {
59
- for (const op of ops) {
60
- const positionals = op.params.filter((p) => p.positional);
61
- const flags = op.params.filter((p) => !p.positional);
62
- const cmd = group.command(commandSignature(op)).description(op.summary);
63
- for (const p of flags) {
64
- cmd.option(`--${toKebab(p.name)} <value>`, p.description);
65
- }
66
- cmd.option("--json", "Output as JSON");
67
- cmd.option("--project <id>", "Project ID override");
68
- cmd.action(async (...argv) => {
69
- try {
70
- const opts = argv.find((a) => a && typeof a === "object" && !Array.isArray(a)) ?? {};
71
- const raw = { ...opts };
72
- positionals.forEach((p, i) => {
73
- raw[p.name] = argv[i];
74
- });
75
- const input = coerceInput(op, raw);
76
- const client = ctx.getClient({
77
- mutates: op.mutates,
78
- projectOverride: opts.project
79
- });
80
- const data = await op.run(client, input);
81
- if (opts.json) ctx.printJson(data);
82
- else ctx.printResult(op, data, input);
83
- } catch (e) {
84
- ctx.onError(e);
85
- }
86
- });
87
- }
88
- }
89
- export {
90
- mountOperations
91
- };
@@ -1,32 +0,0 @@
1
- import { Operation, OpInput } from './types.js';
2
- import '../resources/index.js';
3
- import 'zod/v4/core';
4
- import 'zod';
5
- import '../resources/attributes.js';
6
- import '../transport.js';
7
- import '../resources/i18n.js';
8
- import '../resources/projects.js';
9
- import '../resources/ops.js';
10
- import '../resources/events.js';
11
- import '../resources/metrics.js';
12
- import '../resources/alert-rules.js';
13
- import '../schemas/alert-rules.js';
14
- import '../resources/killswitches.js';
15
- import '../schemas/killswitches.js';
16
- import '../schemas/pagination.js';
17
- import '../resources/universes.js';
18
- import '../schemas/universes.js';
19
- import '../resources/configs.js';
20
- import '../schemas/configs.js';
21
- import '../resources/experiments.js';
22
- import '../schemas/experiments.js';
23
- import '../resources/gates.js';
24
- import '../schemas/gates.js';
25
-
26
- /**
27
- * Build the coerced facade input `run` expects from a raw key→value bag
28
- * (commander's merged args+opts, or MCP's `arguments`). Enforces `required`.
29
- */
30
- declare function coerceInput(op: Operation, raw: Record<string, unknown>): OpInput;
31
-
32
- export { coerceInput };
@@ -1,53 +0,0 @@
1
- // src/transport.ts
2
- var ApiError = class extends Error {
3
- constructor(message, status) {
4
- super(message);
5
- this.status = status;
6
- this.name = "ApiError";
7
- }
8
- status;
9
- };
10
-
11
- // src/operations/coerce.ts
12
- function coerceValue(param, raw) {
13
- if (raw === void 0 || raw === null) return void 0;
14
- switch (param.type) {
15
- case "number": {
16
- const n = typeof raw === "number" ? raw : Number(raw);
17
- if (!Number.isFinite(n)) throw new ApiError(`--${param.name} must be a number`, 400);
18
- return n;
19
- }
20
- case "boolean":
21
- return raw === true || raw === "true" || raw === "1";
22
- case "json":
23
- if (typeof raw !== "string") return raw;
24
- try {
25
- return JSON.parse(raw);
26
- } catch {
27
- throw new ApiError(`--${param.name} must be valid JSON`, 400);
28
- }
29
- case "string":
30
- default: {
31
- const s = String(raw);
32
- if (param.enum && !param.enum.includes(s)) {
33
- throw new ApiError(`--${param.name} must be one of: ${param.enum.join(", ")}`, 400);
34
- }
35
- return s;
36
- }
37
- }
38
- }
39
- function coerceInput(op, raw) {
40
- const out = {};
41
- for (const param of op.params) {
42
- const value = coerceValue(param, raw[param.name]);
43
- if (value === void 0) {
44
- if (param.required) throw new ApiError(`${param.name} is required`, 400);
45
- continue;
46
- }
47
- out[param.name] = value;
48
- }
49
- return out;
50
- }
51
- export {
52
- coerceInput
53
- };
@@ -1,28 +0,0 @@
1
- import { Operation } from './types.js';
2
- import '../resources/index.js';
3
- import 'zod/v4/core';
4
- import 'zod';
5
- import '../resources/attributes.js';
6
- import '../transport.js';
7
- import '../resources/i18n.js';
8
- import '../resources/projects.js';
9
- import '../resources/ops.js';
10
- import '../resources/events.js';
11
- import '../resources/metrics.js';
12
- import '../resources/alert-rules.js';
13
- import '../schemas/alert-rules.js';
14
- import '../resources/killswitches.js';
15
- import '../schemas/killswitches.js';
16
- import '../schemas/pagination.js';
17
- import '../resources/universes.js';
18
- import '../schemas/universes.js';
19
- import '../resources/configs.js';
20
- import '../schemas/configs.js';
21
- import '../resources/experiments.js';
22
- import '../schemas/experiments.js';
23
- import '../resources/gates.js';
24
- import '../schemas/gates.js';
25
-
26
- declare const configOperations: Operation[];
27
-
28
- export { configOperations };