@shipeasy/openapi 1.6.0 → 2.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 (151) hide show
  1. package/README.md +37 -0
  2. package/dist/chunk-643YSMLU.js +1616 -0
  3. package/dist/chunk-643YSMLU.js.map +1 -0
  4. package/dist/chunk-MRW3DJ57.js +3385 -0
  5. package/dist/chunk-MRW3DJ57.js.map +1 -0
  6. package/dist/client-K0ShmsC7.d.ts +11284 -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 +86 -0
  11. package/dist/custom.js +300 -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 +7973 -0
  20. package/dist/schemas.js +1099 -0
  21. package/dist/schemas.js.map +1 -0
  22. package/openapi.json +15922 -3232
  23. package/openapi.yaml +14277 -0
  24. package/package.json +33 -26
  25. package/spec/components/errors.yaml +53 -0
  26. package/spec/components/parameters.yaml +32 -0
  27. package/spec/components/responses.yaml +122 -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 +92 -0
  31. package/spec/components/schemas/configs.yaml +371 -0
  32. package/spec/components/schemas/connectors.yaml +587 -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 +237 -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 +1013 -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 +367 -0
  47. package/spec/paths/alert-rules.yaml +258 -0
  48. package/spec/paths/attributes.yaml +272 -0
  49. package/spec/paths/configs.yaml +758 -0
  50. package/spec/paths/connectors.yaml +782 -0
  51. package/spec/paths/errors.yaml +382 -0
  52. package/spec/paths/events.yaml +380 -0
  53. package/spec/paths/experiments.yaml +803 -0
  54. package/spec/paths/gate-templates.yaml +267 -0
  55. package/spec/paths/gates.yaml +465 -0
  56. package/spec/paths/i18n.yaml +557 -0
  57. package/spec/paths/keys.yaml +182 -0
  58. package/spec/paths/killswitches.yaml +574 -0
  59. package/spec/paths/metrics.yaml +313 -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 +255 -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,255 @@
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
+ - $ref: ../components/parameters.yaml#/Q
16
+ responses:
17
+ "200":
18
+ description: List universes
19
+ content:
20
+ application/json:
21
+ schema:
22
+ $ref: ../components/schemas/universes.yaml#/ListUniversesResponse
23
+ example:
24
+ data:
25
+ - id: uni_01j7w8a1b2c3d4e5f6g7h8i9j0
26
+ name: primary_users
27
+ unitType: user_id
28
+ holdoutRange:
29
+ - 9500
30
+ - 9999
31
+ createdAt: 2026-04-12T10:14:08.000Z
32
+ next_cursor: null
33
+ "400":
34
+ $ref: ../components/responses.yaml#/BadRequest
35
+ "401":
36
+ $ref: ../components/responses.yaml#/Unauthorized
37
+ "403":
38
+ $ref: ../components/responses.yaml#/Forbidden
39
+ "404":
40
+ $ref: ../components/responses.yaml#/NotFound
41
+ "409":
42
+ $ref: ../components/responses.yaml#/Conflict
43
+ "422":
44
+ $ref: ../components/responses.yaml#/UnprocessableEntity
45
+ x-error-codes:
46
+ - BAD_REQUEST
47
+ - UNAUTHORIZED
48
+ - FORBIDDEN
49
+ x-cli:
50
+ name: list
51
+ post:
52
+ operationId: createUniverse
53
+ summary: Create a universe
54
+ description: |-
55
+ Creates a new universe. Only `name` is required — `unit_type` defaults to `user_id` and `holdout_range` defaults to `null` (no holdout).
56
+
57
+ Returns `409` if `name` already exists in the project. Returns `403` if you supply `holdout_range` on a plan below Pro.
58
+
59
+ **Use cases**
60
+
61
+ - **Default universe** — `{ "name": "primary_users" }`. Per-user randomisation, no holdout.
62
+ - **Reserved holdout** — supply `holdout_range` to carve out a measurement slice excluded from all experiments.
63
+ - **Account-level** — `unit_type: 'account_id'` so multi-seat accounts see one consistent variant.
64
+ tags:
65
+ - Universes
66
+ parameters:
67
+ - $ref: ../components/parameters.yaml#/ProjectId
68
+ requestBody:
69
+ required: true
70
+ content:
71
+ application/json:
72
+ schema:
73
+ $ref: ../components/schemas/universes.yaml#/CreateUniverseRequest
74
+ examples:
75
+ minimal:
76
+ summary: Minimal — name only
77
+ description: Smallest valid body. Creates a `user_id`-keyed universe with no holdout.
78
+ value:
79
+ name: primary_users
80
+ holdout:
81
+ summary: Holdout — reserve 5% for measurement
82
+ description: Reserves buckets 9500–9999 (5% of callers) as the holdout. Pro plan or higher.
83
+ value:
84
+ name: primary_users
85
+ holdout_range:
86
+ - 9500
87
+ - 9999
88
+ accountLevel:
89
+ summary: Account-level randomisation
90
+ description: "Bucket whole accounts together via `unit_type: 'account_id'`."
91
+ value:
92
+ name: saas_accounts
93
+ unit_type: account_id
94
+ responses:
95
+ "201":
96
+ description: Create a universe
97
+ content:
98
+ application/json:
99
+ schema:
100
+ $ref: ../components/schemas/universes.yaml#/CreateUniverseResponse
101
+ example:
102
+ id: uni_01j7w8a1b2c3d4e5f6g7h8i9j0
103
+ name: primary_users
104
+ links:
105
+ UpdateUniverse:
106
+ operationId: updateUniverse
107
+ parameters: { id: $response.body#/id }
108
+ DeleteUniverse:
109
+ operationId: deleteUniverse
110
+ parameters: { id: $response.body#/id }
111
+ "400":
112
+ $ref: ../components/responses.yaml#/BadRequest
113
+ "401":
114
+ $ref: ../components/responses.yaml#/Unauthorized
115
+ "403":
116
+ $ref: ../components/responses.yaml#/Forbidden
117
+ "404":
118
+ $ref: ../components/responses.yaml#/NotFound
119
+ "409":
120
+ $ref: ../components/responses.yaml#/Conflict
121
+ "422":
122
+ $ref: ../components/responses.yaml#/UnprocessableEntity
123
+ x-error-codes:
124
+ - BAD_REQUEST
125
+ - UNAUTHORIZED
126
+ - FORBIDDEN
127
+ - PLAN_REQUIRED
128
+ - ALREADY_EXISTS
129
+ - VALIDATION
130
+ x-cli:
131
+ name: create
132
+ positional:
133
+ - name
134
+ /api/admin/universes/{id}:
135
+ patch:
136
+ operationId: updateUniverse
137
+ summary: Update a universe
138
+ description: |-
139
+ Partial update. Only `holdout_range` is mutable — `name` and `unit_type` are immutable after create.
140
+
141
+ Pass `"holdout_range": null` to remove an existing holdout.
142
+
143
+ **Use cases**
144
+
145
+ - **Adjust holdout** — change the reserved measurement slice without recreating experiments.
146
+ - **Remove holdout** — `{ "holdout_range": null }`.
147
+ tags:
148
+ - Universes
149
+ parameters:
150
+ - $ref: ../components/parameters.yaml#/ProjectId
151
+ - name: id
152
+ in: path
153
+ required: true
154
+ description: Stable opaque universe id (`uni_…`) or the universe's `name`.
155
+ schema:
156
+ $ref: ../components/schemas/common.yaml#/ResourceId
157
+ requestBody:
158
+ required: true
159
+ content:
160
+ application/json:
161
+ schema:
162
+ $ref: ../components/schemas/universes.yaml#/UpdateUniverseRequest
163
+ examples:
164
+ setHoldout:
165
+ summary: Set holdout — reserve 5%
166
+ description: Reserve buckets 9500–9999 as the holdout. Pro plan or higher.
167
+ value:
168
+ holdout_range:
169
+ - 9500
170
+ - 9999
171
+ removeHoldout:
172
+ summary: Remove holdout
173
+ description: Disable the holdout entirely.
174
+ value:
175
+ holdout_range: null
176
+ responses:
177
+ "200":
178
+ description: Update a universe
179
+ content:
180
+ application/json:
181
+ schema:
182
+ $ref: ../components/schemas/universes.yaml#/UpdateUniverseResponse
183
+ example:
184
+ id: uni_01j7w8a1b2c3d4e5f6g7h8i9j0
185
+ "400":
186
+ $ref: ../components/responses.yaml#/BadRequest
187
+ "401":
188
+ $ref: ../components/responses.yaml#/Unauthorized
189
+ "403":
190
+ $ref: ../components/responses.yaml#/Forbidden
191
+ "404":
192
+ $ref: ../components/responses.yaml#/NotFound
193
+ "409":
194
+ $ref: ../components/responses.yaml#/Conflict
195
+ "422":
196
+ $ref: ../components/responses.yaml#/UnprocessableEntity
197
+ x-error-codes:
198
+ - BAD_REQUEST
199
+ - UNAUTHORIZED
200
+ - FORBIDDEN
201
+ - PLAN_REQUIRED
202
+ - NOT_FOUND
203
+ - VALIDATION
204
+ x-cli:
205
+ name: update
206
+ positional:
207
+ - id
208
+ delete:
209
+ operationId: deleteUniverse
210
+ summary: Delete a universe
211
+ description: |-
212
+ Soft-deletes the universe. Returns `409` if any non-archived experiment still references it — archive those experiments first.
213
+
214
+ **Use case:** Tear down a universe after every experiment that used it has been archived.
215
+ tags:
216
+ - Universes
217
+ parameters:
218
+ - $ref: ../components/parameters.yaml#/ProjectId
219
+ - name: id
220
+ in: path
221
+ required: true
222
+ description: Stable opaque universe id (`uni_…`) or the universe's `name`.
223
+ schema:
224
+ $ref: ../components/schemas/common.yaml#/ResourceId
225
+ responses:
226
+ "200":
227
+ description: Delete a universe
228
+ content:
229
+ application/json:
230
+ schema:
231
+ $ref: ../components/schemas/universes.yaml#/DeleteUniverseResponse
232
+ example:
233
+ ok: true
234
+ "400":
235
+ $ref: ../components/responses.yaml#/BadRequest
236
+ "401":
237
+ $ref: ../components/responses.yaml#/Unauthorized
238
+ "403":
239
+ $ref: ../components/responses.yaml#/Forbidden
240
+ "404":
241
+ $ref: ../components/responses.yaml#/NotFound
242
+ "409":
243
+ $ref: ../components/responses.yaml#/Conflict
244
+ "422":
245
+ $ref: ../components/responses.yaml#/UnprocessableEntity
246
+ x-error-codes:
247
+ - BAD_REQUEST
248
+ - UNAUTHORIZED
249
+ - FORBIDDEN
250
+ - NOT_FOUND
251
+ - REFERENCED_IN_USE
252
+ x-cli:
253
+ name: archive
254
+ positional:
255
+ - 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 };