@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.
- package/README.md +37 -0
- package/dist/chunk-643YSMLU.js +1616 -0
- package/dist/chunk-643YSMLU.js.map +1 -0
- package/dist/chunk-MRW3DJ57.js +3385 -0
- package/dist/chunk-MRW3DJ57.js.map +1 -0
- package/dist/client-K0ShmsC7.d.ts +11284 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +215 -0
- package/dist/client.js.map +1 -0
- package/dist/custom.d.ts +86 -0
- package/dist/custom.js +300 -0
- package/dist/custom.js.map +1 -0
- package/dist/index.d.ts +29 -41
- package/dist/index.js +258 -4375
- package/dist/index.js.map +1 -0
- package/dist/node-context.d.ts +81 -33
- package/dist/node-context.js +98 -44
- package/dist/node-context.js.map +1 -0
- package/dist/schemas.d.ts +7973 -0
- package/dist/schemas.js +1099 -0
- package/dist/schemas.js.map +1 -0
- package/openapi.json +15922 -3232
- package/openapi.yaml +14277 -0
- package/package.json +33 -26
- package/spec/components/errors.yaml +53 -0
- package/spec/components/parameters.yaml +32 -0
- package/spec/components/responses.yaml +122 -0
- package/spec/components/schemas/alert-rules.yaml +175 -0
- package/spec/components/schemas/attributes.yaml +157 -0
- package/spec/components/schemas/common.yaml +92 -0
- package/spec/components/schemas/configs.yaml +371 -0
- package/spec/components/schemas/connectors.yaml +587 -0
- package/spec/components/schemas/errors-api.yaml +209 -0
- package/spec/components/schemas/events.yaml +321 -0
- package/spec/components/schemas/experiments.yaml +865 -0
- package/spec/components/schemas/gate-templates.yaml +237 -0
- package/spec/components/schemas/gates.yaml +890 -0
- package/spec/components/schemas/i18n.yaml +478 -0
- package/spec/components/schemas/keys.yaml +186 -0
- package/spec/components/schemas/killswitches.yaml +309 -0
- package/spec/components/schemas/metrics.yaml +547 -0
- package/spec/components/schemas/ops.yaml +1013 -0
- package/spec/components/schemas/projects.yaml +222 -0
- package/spec/components/schemas/search.yaml +46 -0
- package/spec/components/schemas/universes.yaml +127 -0
- package/spec/openapi.yaml +367 -0
- package/spec/paths/alert-rules.yaml +258 -0
- package/spec/paths/attributes.yaml +272 -0
- package/spec/paths/configs.yaml +758 -0
- package/spec/paths/connectors.yaml +782 -0
- package/spec/paths/errors.yaml +382 -0
- package/spec/paths/events.yaml +380 -0
- package/spec/paths/experiments.yaml +803 -0
- package/spec/paths/gate-templates.yaml +267 -0
- package/spec/paths/gates.yaml +465 -0
- package/spec/paths/i18n.yaml +557 -0
- package/spec/paths/keys.yaml +182 -0
- package/spec/paths/killswitches.yaml +574 -0
- package/spec/paths/metrics.yaml +313 -0
- package/spec/paths/ops.yaml +446 -0
- package/spec/paths/projects.yaml +210 -0
- package/spec/paths/search.yaml +62 -0
- package/spec/paths/universes.yaml +255 -0
- package/dist/operations/attributes.d.ts +0 -33
- package/dist/operations/attributes.js +0 -16
- package/dist/operations/cli-adapter.d.ts +0 -35
- package/dist/operations/cli-adapter.js +0 -91
- package/dist/operations/coerce.d.ts +0 -32
- package/dist/operations/coerce.js +0 -53
- package/dist/operations/configs.d.ts +0 -28
- package/dist/operations/configs.js +0 -119
- package/dist/operations/docs.d.ts +0 -37
- package/dist/operations/docs.js +0 -39
- package/dist/operations/events.d.ts +0 -28
- package/dist/operations/events.js +0 -121
- package/dist/operations/experiments.d.ts +0 -28
- package/dist/operations/experiments.js +0 -280
- package/dist/operations/gates.d.ts +0 -28
- package/dist/operations/gates.js +0 -132
- package/dist/operations/i18n.d.ts +0 -28
- package/dist/operations/i18n.js +0 -121
- package/dist/operations/index.d.ts +0 -63
- package/dist/operations/index.js +0 -1751
- package/dist/operations/killswitches.d.ts +0 -28
- package/dist/operations/killswitches.js +0 -126
- package/dist/operations/mcp-adapter.d.ts +0 -35
- package/dist/operations/mcp-adapter.js +0 -94
- package/dist/operations/metrics.d.ts +0 -30
- package/dist/operations/metrics.js +0 -114
- package/dist/operations/ops.d.ts +0 -28
- package/dist/operations/ops.js +0 -313
- package/dist/operations/projects.d.ts +0 -28
- package/dist/operations/projects.js +0 -36
- package/dist/operations/sdk-docs.d.ts +0 -28
- package/dist/operations/sdk-docs.js +0 -160
- package/dist/operations/types.d.ts +0 -138
- package/dist/operations/types.js +0 -9
- package/dist/operations/universes.d.ts +0 -28
- package/dist/operations/universes.js +0 -93
- package/dist/operations/util.d.ts +0 -33
- package/dist/operations/util.js +0 -9
- package/dist/resources/alert-rules.d.ts +0 -50
- package/dist/resources/alert-rules.js +0 -75
- package/dist/resources/attributes.d.ts +0 -19
- package/dist/resources/attributes.js +0 -10
- package/dist/resources/configs.d.ts +0 -681
- package/dist/resources/configs.js +0 -509
- package/dist/resources/events.d.ts +0 -61
- package/dist/resources/events.js +0 -42
- package/dist/resources/experiments.d.ts +0 -849
- package/dist/resources/experiments.js +0 -707
- package/dist/resources/gates.d.ts +0 -808
- package/dist/resources/gates.js +0 -522
- package/dist/resources/i18n.d.ts +0 -84
- package/dist/resources/i18n.js +0 -60
- package/dist/resources/index.d.ts +0 -2767
- package/dist/resources/index.js +0 -2563
- package/dist/resources/killswitches.d.ts +0 -436
- package/dist/resources/killswitches.js +0 -514
- package/dist/resources/metrics.d.ts +0 -54
- package/dist/resources/metrics.js +0 -40
- package/dist/resources/ops.d.ts +0 -88
- package/dist/resources/ops.js +0 -36
- package/dist/resources/projects.d.ts +0 -54
- package/dist/resources/projects.js +0 -14
- package/dist/resources/universes.d.ts +0 -185
- package/dist/resources/universes.js +0 -234
- package/dist/schemas/alert-rules.d.ts +0 -65
- package/dist/schemas/alert-rules.js +0 -37
- package/dist/schemas/configs.d.ts +0 -154
- package/dist/schemas/configs.js +0 -134
- package/dist/schemas/constants.d.ts +0 -6
- package/dist/schemas/constants.js +0 -7
- package/dist/schemas/experiments.d.ts +0 -229
- package/dist/schemas/experiments.js +0 -221
- package/dist/schemas/folder.d.ts +0 -10
- package/dist/schemas/folder.js +0 -8
- package/dist/schemas/gates.d.ts +0 -386
- package/dist/schemas/gates.js +0 -190
- package/dist/schemas/index.d.ts +0 -11
- package/dist/schemas/index.js +0 -762
- package/dist/schemas/killswitches.d.ts +0 -110
- package/dist/schemas/killswitches.js +0 -226
- package/dist/schemas/metric-name.d.ts +0 -5
- package/dist/schemas/metric-name.js +0 -6
- package/dist/schemas/pagination.d.ts +0 -37
- package/dist/schemas/pagination.js +0 -44
- package/dist/schemas/universes.d.ts +0 -35
- package/dist/schemas/universes.js +0 -55
- package/dist/transport.d.ts +0 -30
- package/dist/transport.js +0 -44
|
@@ -1,514 +0,0 @@
|
|
|
1
|
-
// src/resources/killswitches.ts
|
|
2
|
-
import { z as z4 } from "zod";
|
|
3
|
-
|
|
4
|
-
// src/schemas/killswitches.ts
|
|
5
|
-
import { z as z3 } from "zod";
|
|
6
|
-
|
|
7
|
-
// src/schemas/configs.ts
|
|
8
|
-
import { z as z2 } from "zod";
|
|
9
|
-
|
|
10
|
-
// src/schemas/constants.ts
|
|
11
|
-
var CONFIG_ENVS = ["dev", "staging", "prod"];
|
|
12
|
-
var CONFIG_KINDS = ["config", "killswitch"];
|
|
13
|
-
|
|
14
|
-
// src/schemas/folder.ts
|
|
15
|
-
import { z } from "zod";
|
|
16
|
-
var folderSchema = z.string().max(256).regex(/^[a-zA-Z0-9_-]+$/, "Folder must be alphanumeric, `_` or `-` (no `/`).").nullable().optional().describe(
|
|
17
|
-
"Optional folder name used to group items in the dashboard. Part of the SDK lookup key: an item in folder `checkout` named `new-cart` is referenced as `checkout/new-cart` from the SDK."
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
// src/schemas/configs.ts
|
|
21
|
-
var SEGMENT = /^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?$/;
|
|
22
|
-
var RESERVED_FOLDER = "_default";
|
|
23
|
-
var configNameSchema = z2.string().max(128).refine(
|
|
24
|
-
(s) => {
|
|
25
|
-
const parts = s.split(".");
|
|
26
|
-
if (parts.length !== 2) return false;
|
|
27
|
-
return parts.every((p, i) => p === RESERVED_FOLDER && i === 0 ? true : SEGMENT.test(p));
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
message: "Must be `folder.name` \u2014 exactly two lowercase segments separated by a dot (e.g. `pricing.tiers`)."
|
|
31
|
-
}
|
|
32
|
-
).describe(
|
|
33
|
-
"Stable config key in `folder.name` form (two lowercase segments separated by a dot, e.g. `pricing.tiers`). Used by SDKs as `Shipeasy.getConfig('<name>')`. Immutable after create."
|
|
34
|
-
);
|
|
35
|
-
var configKindSchema = z2.enum(CONFIG_KINDS);
|
|
36
|
-
var configEnvSchema = z2.enum(CONFIG_ENVS).describe("Target environment. One of the project's configured envs (`dev`, `stage`, `prod`).");
|
|
37
|
-
var jsonSchemaSchema = z2.record(z2.string(), z2.unknown()).refine((s) => s.type === "object", { message: "Top-level schema type must be 'object'" }).describe(
|
|
38
|
-
"JSON Schema (draft 2020-12) describing the shape of the config value. Top-level `type` must be `'object'`; every published value is validated against this schema."
|
|
39
|
-
);
|
|
40
|
-
var initialValuesSchema = z2.union([z2.unknown(), z2.record(configEnvSchema, z2.unknown())]).describe(
|
|
41
|
-
"Initial config value. Either a single JSON object applied to every env, or a `{ env: value }` map seeding per-env values. Must match `schema`. Defaults to `{}` on every env when omitted."
|
|
42
|
-
);
|
|
43
|
-
var configCreateSchema = z2.object({
|
|
44
|
-
name: configNameSchema,
|
|
45
|
-
description: z2.string().max(512).optional().describe("Optional free-form description shown in the dashboard. Max 512 chars."),
|
|
46
|
-
folder: folderSchema,
|
|
47
|
-
schema: jsonSchemaSchema,
|
|
48
|
-
value: initialValuesSchema.optional()
|
|
49
|
-
}).describe("Body for `POST /api/admin/configs`. `name` + `schema` required.");
|
|
50
|
-
var configUpdateSchema = z2.object({
|
|
51
|
-
schema: jsonSchemaSchema.optional().describe(
|
|
52
|
-
"Replacement schema. When supplied, the new schema is validated against every published value before it lands."
|
|
53
|
-
),
|
|
54
|
-
value: z2.unknown().optional().describe(
|
|
55
|
-
"Flat value applied to **every** env. Publishes a new version per env. To target one env, use `PUT /{id}/drafts` then `POST /{id}/publish`."
|
|
56
|
-
),
|
|
57
|
-
folder: folderSchema
|
|
58
|
-
}).describe(
|
|
59
|
-
"Body for `PATCH /api/admin/configs/{id}`. Partial \u2014 only supplied fields change. `value` republishes on every env."
|
|
60
|
-
);
|
|
61
|
-
var configSchemaUpdateSchema = z2.object({ schema: jsonSchemaSchema }).describe("Schema-only update. Does not bump value versions or rebuild KV.");
|
|
62
|
-
var configDraftUpsertSchema = z2.object({
|
|
63
|
-
env: configEnvSchema,
|
|
64
|
-
value: z2.unknown().describe("Draft value to stage on `env`. Validated against the config's current schema.")
|
|
65
|
-
}).describe(
|
|
66
|
-
"Body for `PUT /api/admin/configs/{id}/drafts`. Stages a value for a single env without publishing."
|
|
67
|
-
);
|
|
68
|
-
var configPublishSchema = z2.object({ env: configEnvSchema }).describe(
|
|
69
|
-
"Body for `POST /api/admin/configs/{id}/publish` and `DELETE /api/admin/configs/{id}/drafts`. Names the target env."
|
|
70
|
-
);
|
|
71
|
-
var configEnvPublishedSchema = z2.object({
|
|
72
|
-
version: z2.number().int().describe("Monotonically increasing version per env."),
|
|
73
|
-
publishedAt: z2.string().describe("ISO-8601 publish timestamp."),
|
|
74
|
-
publishedBy: z2.string().describe("Email/id of the actor who published this version.")
|
|
75
|
-
});
|
|
76
|
-
var configDraftSummarySchema = z2.object({
|
|
77
|
-
updatedAt: z2.string().describe("ISO-8601 last-edit timestamp on the draft."),
|
|
78
|
-
authorEmail: z2.string().describe("Email/id of the actor who last edited the draft."),
|
|
79
|
-
baseVersion: z2.number().int().describe("Published version the draft was forked from.")
|
|
80
|
-
});
|
|
81
|
-
var configResponseSchema = z2.object({
|
|
82
|
-
id: z2.string().describe("Stable opaque config id (`cfg_\u2026`)."),
|
|
83
|
-
name: configNameSchema,
|
|
84
|
-
description: z2.string().nullable(),
|
|
85
|
-
schema: jsonSchemaSchema,
|
|
86
|
-
updatedAt: z2.string().describe("ISO-8601 timestamp of last mutation."),
|
|
87
|
-
envs: z2.record(configEnvSchema, configEnvPublishedSchema).describe("Per-env latest published version metadata."),
|
|
88
|
-
drafts: z2.record(configEnvSchema, configDraftSummarySchema).describe("Per-env active drafts (if any)."),
|
|
89
|
-
values: z2.record(configEnvSchema, z2.unknown()).optional().describe("Per-env latest published values (only returned by `GET /{id}`, not list)."),
|
|
90
|
-
draftValues: z2.record(configEnvSchema, z2.unknown()).optional().describe("Per-env draft values (only returned by `GET /{id}`).")
|
|
91
|
-
});
|
|
92
|
-
var configCreateResponseSchema = z2.object({
|
|
93
|
-
id: z2.string().describe("Newly assigned config id."),
|
|
94
|
-
name: configNameSchema
|
|
95
|
-
});
|
|
96
|
-
var configUpdateResponseSchema = z2.object({
|
|
97
|
-
id: z2.string().describe("Config id that was updated.")
|
|
98
|
-
});
|
|
99
|
-
var configDeleteResponseSchema = z2.object({ ok: z2.literal(true) });
|
|
100
|
-
var configDraftSaveResponseSchema = z2.object({
|
|
101
|
-
id: z2.string(),
|
|
102
|
-
env: configEnvSchema,
|
|
103
|
-
baseVersion: z2.number().int().describe("Published version the draft is based on."),
|
|
104
|
-
updatedAt: z2.string()
|
|
105
|
-
});
|
|
106
|
-
var configDraftDiscardResponseSchema = z2.object({ ok: z2.literal(true) });
|
|
107
|
-
var configPublishResponseSchema = z2.object({
|
|
108
|
-
id: z2.string(),
|
|
109
|
-
env: configEnvSchema,
|
|
110
|
-
version: z2.number().int().describe("Newly published version on `env`.")
|
|
111
|
-
});
|
|
112
|
-
var configActivityEntrySchema = z2.object({
|
|
113
|
-
id: z2.string(),
|
|
114
|
-
action: z2.string().describe("Audit action (e.g. `config.create`, `config.publish`)."),
|
|
115
|
-
actorEmail: z2.string(),
|
|
116
|
-
actorType: z2.enum(["user", "cli", "system"]),
|
|
117
|
-
payload: z2.unknown().nullable(),
|
|
118
|
-
createdAt: z2.string().describe("ISO-8601 timestamp.")
|
|
119
|
-
});
|
|
120
|
-
var configActivityResponseSchema = z2.array(configActivityEntrySchema).describe("Recent audit rows for one config, newest first.");
|
|
121
|
-
|
|
122
|
-
// src/schemas/killswitches.ts
|
|
123
|
-
var SWITCH_KEY_RE = /^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?$/;
|
|
124
|
-
var switchKeySchema = z3.string().max(64).regex(SWITCH_KEY_RE, {
|
|
125
|
-
message: "Switch keys must be lowercase, no dots."
|
|
126
|
-
}).describe(
|
|
127
|
-
"Single-segment switch key (lowercase letters, digits, `_`/`-`; no dots). Used as the nested switch entry inside a killswitch's `switches` map."
|
|
128
|
-
);
|
|
129
|
-
var killswitchValueSchema = z3.object({
|
|
130
|
-
value: z3.boolean().describe(
|
|
131
|
-
"Default boolean delivered when no `switches` entry matches the caller's switch key."
|
|
132
|
-
),
|
|
133
|
-
switches: z3.record(switchKeySchema, z3.boolean()).optional().describe(
|
|
134
|
-
"Per-switch overrides. When present, a matching key takes precedence over `value` on the client."
|
|
135
|
-
)
|
|
136
|
-
}).describe("Runtime killswitch payload returned to SDKs.");
|
|
137
|
-
var killswitchCreateSchema = z3.object({
|
|
138
|
-
name: configNameSchema.describe(
|
|
139
|
-
"Stable killswitch key in `folder.name` form (two lowercase segments separated by a dot \u2014 e.g. `payments.checkout`). Immutable after create."
|
|
140
|
-
),
|
|
141
|
-
description: z3.string().max(512).optional().describe("Optional free-form description shown in the dashboard. Max 512 chars."),
|
|
142
|
-
folder: folderSchema,
|
|
143
|
-
value: z3.boolean().optional().describe(
|
|
144
|
-
"Default value applied to every env at creation. Defaults to `false`. Use `true` to ship the killswitch pre-tripped."
|
|
145
|
-
),
|
|
146
|
-
switches: z3.record(switchKeySchema, z3.boolean()).optional().describe(
|
|
147
|
-
"Initial per-switch overrides applied to every env. Empty/omitted leaves the killswitch with only the flat `value`."
|
|
148
|
-
)
|
|
149
|
-
}).describe("Body for `POST /api/admin/killswitches`. Only `name` is required.");
|
|
150
|
-
var killswitchUpdateSchema = z3.object({
|
|
151
|
-
description: z3.string().max(512).nullish().describe("New description, or `null` to clear it. Max 512 chars."),
|
|
152
|
-
folder: folderSchema,
|
|
153
|
-
value: z3.boolean().optional().describe(
|
|
154
|
-
"Flat value applied to every env. Publishes a new version per env when set. Omit to leave values unchanged."
|
|
155
|
-
),
|
|
156
|
-
switches: z3.record(switchKeySchema, z3.boolean()).optional().describe(
|
|
157
|
-
"Replace the switches map wholesale on every env. To edit a single entry on a single env use `PUT /{id}/switch` instead."
|
|
158
|
-
)
|
|
159
|
-
}).describe(
|
|
160
|
-
"Body for `PATCH /api/admin/killswitches/{id}`. Partial \u2014 only supplied fields change. `switches` replaces wholesale (no merge)."
|
|
161
|
-
);
|
|
162
|
-
var killswitchSwitchSetSchema = z3.object({
|
|
163
|
-
env: configEnvSchema.describe("Target environment (`dev`/`stage`/`prod`)."),
|
|
164
|
-
switchKey: switchKeySchema.describe("Switch key to set."),
|
|
165
|
-
value: z3.boolean().describe("New boolean value for this `switchKey` on this `env`.")
|
|
166
|
-
}).describe(
|
|
167
|
-
"Body for `PUT /api/admin/killswitches/{id}/switch`. Sets or updates one switch entry on one env."
|
|
168
|
-
);
|
|
169
|
-
var killswitchValueSetSchema = z3.object({
|
|
170
|
-
env: configEnvSchema.describe("Target environment whose flat default flips."),
|
|
171
|
-
value: z3.boolean().describe("New flat default for this env. Existing switches carry forward unchanged.")
|
|
172
|
-
}).describe(
|
|
173
|
-
"Body for the killswitch quick-toggle. Sets the flat `value` on one env without touching its switches."
|
|
174
|
-
);
|
|
175
|
-
var killswitchSwitchUnsetSchema = z3.object({
|
|
176
|
-
env: configEnvSchema.describe("Target environment."),
|
|
177
|
-
switchKey: switchKeySchema.describe("Switch key to remove.")
|
|
178
|
-
}).describe(
|
|
179
|
-
"Body for `DELETE /api/admin/killswitches/{id}/switch`. Removes one switch entry from one env."
|
|
180
|
-
);
|
|
181
|
-
var killswitchEnvEntrySchema = z3.object({
|
|
182
|
-
value: z3.boolean().describe("Flat boolean published for this env."),
|
|
183
|
-
switches: z3.record(switchKeySchema, z3.boolean()).optional(),
|
|
184
|
-
version: z3.number().int().describe("Monotonically increasing version per env."),
|
|
185
|
-
publishedAt: z3.string().describe("ISO-8601 publish timestamp for this version.")
|
|
186
|
-
});
|
|
187
|
-
var killswitchResponseSchema = z3.object({
|
|
188
|
-
id: z3.string().describe("Stable opaque killswitch id."),
|
|
189
|
-
name: configNameSchema,
|
|
190
|
-
description: z3.string().nullable().describe("Free-form description or `null`."),
|
|
191
|
-
updatedAt: z3.string().describe("ISO-8601 timestamp of last mutation."),
|
|
192
|
-
envs: z3.record(configEnvSchema, killswitchEnvEntrySchema).describe("Per-env latest value, switches, version, and publish timestamp.")
|
|
193
|
-
});
|
|
194
|
-
var killswitchCreateResponseSchema = z3.object({
|
|
195
|
-
id: z3.string().describe("Newly assigned killswitch id."),
|
|
196
|
-
name: configNameSchema
|
|
197
|
-
});
|
|
198
|
-
var killswitchUpdateResponseSchema = z3.object({
|
|
199
|
-
id: z3.string().describe("Killswitch id that was updated.")
|
|
200
|
-
});
|
|
201
|
-
var killswitchDeleteResponseSchema = z3.object({ ok: z3.literal(true) });
|
|
202
|
-
var killswitchSwitchSetResponseSchema = z3.object({
|
|
203
|
-
id: z3.string(),
|
|
204
|
-
env: configEnvSchema,
|
|
205
|
-
switchKey: switchKeySchema,
|
|
206
|
-
value: z3.boolean()
|
|
207
|
-
});
|
|
208
|
-
var killswitchSwitchUnsetResponseSchema = z3.object({
|
|
209
|
-
id: z3.string(),
|
|
210
|
-
env: configEnvSchema,
|
|
211
|
-
switchKey: switchKeySchema,
|
|
212
|
-
removed: z3.boolean().describe("`true` if the entry existed and was removed, `false` if no-op.")
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
// src/transport.ts
|
|
216
|
-
var ApiError = class extends Error {
|
|
217
|
-
constructor(message, status) {
|
|
218
|
-
super(message);
|
|
219
|
-
this.status = status;
|
|
220
|
-
this.name = "ApiError";
|
|
221
|
-
}
|
|
222
|
-
status;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
// src/resources/killswitches.ts
|
|
226
|
-
var killswitchListResponseSchema = z4.object({
|
|
227
|
-
data: z4.array(killswitchResponseSchema),
|
|
228
|
-
next_cursor: z4.string().nullable()
|
|
229
|
-
});
|
|
230
|
-
var BASE = "/api/admin/killswitches";
|
|
231
|
-
function killswitchesClient(t) {
|
|
232
|
-
async function list(opts = {}) {
|
|
233
|
-
const query = {};
|
|
234
|
-
if (opts.limit !== void 0) query.limit = String(opts.limit);
|
|
235
|
-
if (opts.cursor) query.cursor = opts.cursor;
|
|
236
|
-
return t.request("GET", BASE, void 0, query);
|
|
237
|
-
}
|
|
238
|
-
async function listAll() {
|
|
239
|
-
const out = [];
|
|
240
|
-
let cursor;
|
|
241
|
-
do {
|
|
242
|
-
const page = await list({ limit: 500, cursor });
|
|
243
|
-
out.push(...page.data);
|
|
244
|
-
cursor = page.next_cursor ?? void 0;
|
|
245
|
-
} while (cursor);
|
|
246
|
-
return out;
|
|
247
|
-
}
|
|
248
|
-
async function resolve(idOrName) {
|
|
249
|
-
try {
|
|
250
|
-
return await t.request("GET", `${BASE}/${idOrName}`);
|
|
251
|
-
} catch (err) {
|
|
252
|
-
if (!(err instanceof ApiError) || err.status !== 404) throw err;
|
|
253
|
-
}
|
|
254
|
-
const all = await listAll();
|
|
255
|
-
const found = all.find((k) => k.name === idOrName);
|
|
256
|
-
if (!found) throw new ApiError(`Killswitch '${idOrName}' not found`, 404);
|
|
257
|
-
return found;
|
|
258
|
-
}
|
|
259
|
-
return {
|
|
260
|
-
list,
|
|
261
|
-
listAll,
|
|
262
|
-
resolve,
|
|
263
|
-
get: (id) => t.request("GET", `${BASE}/${id}`),
|
|
264
|
-
create: (input) => t.request("POST", BASE, killswitchCreateSchema.parse(input)),
|
|
265
|
-
update: (id, input) => t.request("PATCH", `${BASE}/${id}`, killswitchUpdateSchema.parse(input)),
|
|
266
|
-
delete: (id) => t.request("DELETE", `${BASE}/${id}`),
|
|
267
|
-
setSwitch: (id, input) => t.request("PUT", `${BASE}/${id}/switch`, killswitchSwitchSetSchema.parse(input)),
|
|
268
|
-
unsetSwitch: (id, input) => t.request("DELETE", `${BASE}/${id}/switch`, killswitchSwitchUnsetSchema.parse(input))
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
var SAMPLE_KS = {
|
|
272
|
-
id: "ksw_01j7w9d8h2k4m6n8p0q2r4s6t8",
|
|
273
|
-
name: "payments.checkout",
|
|
274
|
-
description: "Master kill for the checkout flow. Trip to fall back to the legacy provider.",
|
|
275
|
-
updatedAt: "2026-05-09T18:22:11.000Z",
|
|
276
|
-
envs: {
|
|
277
|
-
dev: { value: false, version: 3, publishedAt: "2026-05-09T18:22:11.000Z" },
|
|
278
|
-
stage: { value: false, version: 3, publishedAt: "2026-05-09T18:22:11.000Z" },
|
|
279
|
-
prod: {
|
|
280
|
-
value: false,
|
|
281
|
-
switches: { eu_region: true },
|
|
282
|
-
version: 5,
|
|
283
|
-
publishedAt: "2026-05-09T18:22:11.000Z"
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
var killswitchesResource = {
|
|
288
|
-
name: "killswitches",
|
|
289
|
-
basePath: BASE,
|
|
290
|
-
describeOne: "killswitch",
|
|
291
|
-
describeMany: "killswitches",
|
|
292
|
-
tag: {
|
|
293
|
-
name: "Killswitches",
|
|
294
|
-
description: [
|
|
295
|
-
"Killswitches: per-env boolean overrides for kill-style operational toggles. Optimised for incident response \u2014 no rules, no rollout, just a flat boolean (plus optional per-key overrides) versioned per environment.",
|
|
296
|
-
"",
|
|
297
|
-
"**Identity.** Each killswitch is keyed by `name` in `folder.name` form (e.g. `payments.checkout`). Immutable after create.",
|
|
298
|
-
"",
|
|
299
|
-
"**Per-env values.** Every killswitch stores one version stream per env (`dev`, `stage`, `prod`). A `PATCH` with `value`/`switches` applies to **every** env in one shot (publishes a new version per env). To touch a single env, use `PUT /{id}/switch` and friends.",
|
|
300
|
-
"",
|
|
301
|
-
"**Switches map.** Optional `switches: { key: bool }` overrides the flat `value` for specific named call sites \u2014 useful for region/feature-scoped kills.",
|
|
302
|
-
"",
|
|
303
|
-
"**Versioning.** Each publish (create, update, set-switch, unset-switch) bumps the per-env `version` monotonically. SDKs deliver the latest published version."
|
|
304
|
-
].join("\n")
|
|
305
|
-
},
|
|
306
|
-
schemas: {
|
|
307
|
-
create: killswitchCreateSchema,
|
|
308
|
-
update: killswitchUpdateSchema,
|
|
309
|
-
setSwitch: killswitchSwitchSetSchema,
|
|
310
|
-
unsetSwitch: killswitchSwitchUnsetSchema
|
|
311
|
-
},
|
|
312
|
-
actions: [
|
|
313
|
-
{ name: "setSwitch", description: "Set or update one switch entry on one env" },
|
|
314
|
-
{ name: "unsetSwitch", description: "Remove one switch entry from one env" }
|
|
315
|
-
],
|
|
316
|
-
endpoints: [
|
|
317
|
-
{
|
|
318
|
-
operationId: "listKillswitches",
|
|
319
|
-
method: "GET",
|
|
320
|
-
path: "",
|
|
321
|
-
summary: "List killswitches",
|
|
322
|
-
description: "Returns a single page of killswitches ordered by `updated_at desc, id desc`. Each row includes the latest published `value`/`switches`/`version` per env.",
|
|
323
|
-
response: killswitchListResponseSchema,
|
|
324
|
-
examples: { response: { data: [SAMPLE_KS], next_cursor: null } },
|
|
325
|
-
useCase: "Snapshot every killswitch in the project \u2014 e.g. to render an incident-response runbook listing every kill and its current trip state."
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
operationId: "getKillswitch",
|
|
329
|
-
method: "GET",
|
|
330
|
-
path: "/{id}",
|
|
331
|
-
summary: "Get one killswitch",
|
|
332
|
-
description: "Returns the killswitch metadata plus the latest published `value`/`switches`/`version` per env.",
|
|
333
|
-
pathParams: { id: "Stable opaque killswitch id (`ksw_\u2026`)." },
|
|
334
|
-
response: killswitchResponseSchema,
|
|
335
|
-
examples: { response: SAMPLE_KS },
|
|
336
|
-
useCase: "Fetch the current state of one killswitch \u2014 e.g. to verify a trip propagated before declaring an incident mitigated."
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
operationId: "createKillswitch",
|
|
340
|
-
method: "POST",
|
|
341
|
-
path: "",
|
|
342
|
-
summary: "Create a killswitch",
|
|
343
|
-
description: [
|
|
344
|
-
"Creates a new killswitch with `value` (default `false`) applied to **every** env at version 1.",
|
|
345
|
-
"",
|
|
346
|
-
"Returns `409` if `name` already exists in the project."
|
|
347
|
-
].join("\n"),
|
|
348
|
-
successStatus: 201,
|
|
349
|
-
request: killswitchCreateSchema,
|
|
350
|
-
response: killswitchCreateResponseSchema,
|
|
351
|
-
examples: {
|
|
352
|
-
requestExamples: {
|
|
353
|
-
minimal: {
|
|
354
|
-
summary: "Minimal \u2014 name only, untripped",
|
|
355
|
-
description: "Smallest valid body. Creates a killswitch with `value: false` on every env.",
|
|
356
|
-
value: { name: "payments.checkout" }
|
|
357
|
-
},
|
|
358
|
-
preTripped: {
|
|
359
|
-
summary: "Pre-tripped on create",
|
|
360
|
-
description: "Ship the killswitch already tripped (`value: true`) \u2014 useful when provisioning a kill ahead of a deploy you want to ship with the feature off.",
|
|
361
|
-
value: {
|
|
362
|
-
name: "payments.checkout",
|
|
363
|
-
description: "Master kill for the new checkout flow.",
|
|
364
|
-
value: true
|
|
365
|
-
}
|
|
366
|
-
},
|
|
367
|
-
withSwitches: {
|
|
368
|
-
summary: "With per-region switches",
|
|
369
|
-
description: "Seed a `switches` map so specific named call sites can be tripped independently of the flat `value`.",
|
|
370
|
-
value: {
|
|
371
|
-
name: "payments.checkout",
|
|
372
|
-
value: false,
|
|
373
|
-
switches: { eu_region: true, apac_region: false }
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
},
|
|
377
|
-
response: { id: "ksw_01j7w9d8h2k4m6n8p0q2r4s6t8", name: "payments.checkout" }
|
|
378
|
-
},
|
|
379
|
-
useCase: [
|
|
380
|
-
'- **Untripped create** \u2014 `{ "name": "payments.checkout" }`. Provision the kill ahead of an incident.',
|
|
381
|
-
'- **Pre-tripped** \u2014 `{ "value": true }` to ship the killswitch already engaged.',
|
|
382
|
-
"- **With switches** \u2014 seed `switches` to carve out per-region/per-tenant kills from day one."
|
|
383
|
-
].join("\n")
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
operationId: "updateKillswitch",
|
|
387
|
-
method: "PATCH",
|
|
388
|
-
path: "/{id}",
|
|
389
|
-
summary: "Update a killswitch",
|
|
390
|
-
description: [
|
|
391
|
-
"Partial update applied to **every** env. Setting `value`/`switches` publishes a new version per env. Description-only patches don't bump versions.",
|
|
392
|
-
"",
|
|
393
|
-
"To change a single switch on a single env, use `PUT /{id}/switch` instead."
|
|
394
|
-
].join("\n"),
|
|
395
|
-
pathParams: { id: "Stable opaque killswitch id." },
|
|
396
|
-
request: killswitchUpdateSchema,
|
|
397
|
-
response: killswitchUpdateResponseSchema,
|
|
398
|
-
examples: {
|
|
399
|
-
requestExamples: {
|
|
400
|
-
trip: {
|
|
401
|
-
summary: "Trip the killswitch on every env",
|
|
402
|
-
description: "Sets `value: true` on dev/stage/prod, bumping each env's version by one.",
|
|
403
|
-
value: { value: true }
|
|
404
|
-
},
|
|
405
|
-
untrip: {
|
|
406
|
-
summary: "Untrip on every env",
|
|
407
|
-
description: "Sets `value: false` on every env.",
|
|
408
|
-
value: { value: false }
|
|
409
|
-
},
|
|
410
|
-
replaceSwitches: {
|
|
411
|
-
summary: "Replace switches map",
|
|
412
|
-
description: "Replaces the per-key overrides wholesale on every env. Pass `{}` to clear.",
|
|
413
|
-
value: { switches: { eu_region: true, apac_region: true } }
|
|
414
|
-
},
|
|
415
|
-
updateDescription: {
|
|
416
|
-
summary: "Description-only update",
|
|
417
|
-
description: "Doesn't bump versions or trigger a republish \u2014 only metadata changes.",
|
|
418
|
-
value: { description: "Master kill \u2014 owner: payments-platform" }
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
response: { id: "ksw_01j7w9d8h2k4m6n8p0q2r4s6t8" }
|
|
422
|
-
},
|
|
423
|
-
useCase: [
|
|
424
|
-
'- **Trip everywhere** \u2014 `{ "value": true }`. Kills the feature across dev/stage/prod in one call.',
|
|
425
|
-
'- **Untrip everywhere** \u2014 `{ "value": false }`.',
|
|
426
|
-
"- **Replace switches** \u2014 send the full new map; per-key edits use `PUT /{id}/switch`.",
|
|
427
|
-
"- **Update description** \u2014 metadata-only patches don't bump versions."
|
|
428
|
-
].join("\n")
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
operationId: "deleteKillswitch",
|
|
432
|
-
method: "DELETE",
|
|
433
|
-
path: "/{id}",
|
|
434
|
-
summary: "Delete a killswitch",
|
|
435
|
-
description: "Soft-deletes the killswitch and rebuilds the project's flags KV blob so SDKs stop seeing it.",
|
|
436
|
-
pathParams: { id: "Stable opaque killswitch id." },
|
|
437
|
-
response: killswitchDeleteResponseSchema,
|
|
438
|
-
examples: { response: { ok: true } },
|
|
439
|
-
useCase: "Tear down a killswitch after the feature it protected has been removed."
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
operationId: "setKillswitchSwitch",
|
|
443
|
-
method: "PUT",
|
|
444
|
-
path: "/{id}/switch",
|
|
445
|
-
summary: "Set one switch entry",
|
|
446
|
-
description: [
|
|
447
|
-
"Sets or updates a single `switchKey` on a single `env`. Publishes one new version on that env only \u2014 other envs untouched.",
|
|
448
|
-
"",
|
|
449
|
-
"Use this for surgical per-env, per-key flips during incident response (e.g. trip `eu_region` on prod without touching the flat `value` or other envs)."
|
|
450
|
-
].join("\n"),
|
|
451
|
-
pathParams: { id: "Stable opaque killswitch id." },
|
|
452
|
-
request: killswitchSwitchSetSchema,
|
|
453
|
-
response: killswitchSwitchSetResponseSchema,
|
|
454
|
-
examples: {
|
|
455
|
-
requestExamples: {
|
|
456
|
-
tripRegion: {
|
|
457
|
-
summary: "Trip eu_region on prod",
|
|
458
|
-
description: "Sets `switches.eu_region = true` on prod only. Other envs and the flat `value` are unchanged.",
|
|
459
|
-
value: { env: "prod", switchKey: "eu_region", value: true }
|
|
460
|
-
},
|
|
461
|
-
untripRegion: {
|
|
462
|
-
summary: "Untrip eu_region on prod",
|
|
463
|
-
description: "Flip the same entry back off without removing it from the map.",
|
|
464
|
-
value: { env: "prod", switchKey: "eu_region", value: false }
|
|
465
|
-
}
|
|
466
|
-
},
|
|
467
|
-
response: {
|
|
468
|
-
id: "ksw_01j7w9d8h2k4m6n8p0q2r4s6t8",
|
|
469
|
-
env: "prod",
|
|
470
|
-
switchKey: "eu_region",
|
|
471
|
-
value: true
|
|
472
|
-
}
|
|
473
|
-
},
|
|
474
|
-
useCase: [
|
|
475
|
-
'- **Trip a region** \u2014 `{ "env": "prod", "switchKey": "eu_region", "value": true }`.',
|
|
476
|
-
"- **Untrip without removing** \u2014 same payload with `value: false`. To remove the entry entirely use `DELETE /{id}/switch`."
|
|
477
|
-
].join("\n")
|
|
478
|
-
},
|
|
479
|
-
{
|
|
480
|
-
operationId: "unsetKillswitchSwitch",
|
|
481
|
-
method: "DELETE",
|
|
482
|
-
path: "/{id}/switch",
|
|
483
|
-
summary: "Remove one switch entry",
|
|
484
|
-
description: [
|
|
485
|
-
"Removes a single `switchKey` from the `switches` map on a single `env`. Publishes a new version on that env.",
|
|
486
|
-
"",
|
|
487
|
-
"Returns `{ removed: false }` if the entry didn't exist (idempotent no-op)."
|
|
488
|
-
].join("\n"),
|
|
489
|
-
pathParams: { id: "Stable opaque killswitch id." },
|
|
490
|
-
request: killswitchSwitchUnsetSchema,
|
|
491
|
-
response: killswitchSwitchUnsetResponseSchema,
|
|
492
|
-
examples: {
|
|
493
|
-
requestExamples: {
|
|
494
|
-
removeRegion: {
|
|
495
|
-
summary: "Remove eu_region from prod",
|
|
496
|
-
description: "Drops the `eu_region` override on prod so the flat `value` applies again.",
|
|
497
|
-
value: { env: "prod", switchKey: "eu_region" }
|
|
498
|
-
}
|
|
499
|
-
},
|
|
500
|
-
response: {
|
|
501
|
-
id: "ksw_01j7w9d8h2k4m6n8p0q2r4s6t8",
|
|
502
|
-
env: "prod",
|
|
503
|
-
switchKey: "eu_region",
|
|
504
|
-
removed: true
|
|
505
|
-
}
|
|
506
|
-
},
|
|
507
|
-
useCase: "Clean up a per-region override after the incident is resolved so the flat `value` governs again."
|
|
508
|
-
}
|
|
509
|
-
]
|
|
510
|
-
};
|
|
511
|
-
export {
|
|
512
|
-
killswitchesClient,
|
|
513
|
-
killswitchesResource
|
|
514
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Transport } from '../transport.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Metric definitions — the event-backed queries that power tracking dashboards
|
|
5
|
-
* and experiment success/guardrail metrics. A metric pins one event, one
|
|
6
|
-
* aggregation, and (for sum/avg) a value path, expressed as the metric query
|
|
7
|
-
* DSL or its typed IR form.
|
|
8
|
-
*
|
|
9
|
-
* The admin endpoint accepts either `query` (the DSL string) or `query_ir`
|
|
10
|
-
* (the typed IR). The CLI's vendored DSL parser turns `--query` into IR
|
|
11
|
-
* client-side for an early error; the server validates either form, so the
|
|
12
|
-
* registry op can pass `query` straight through and stay worker-safe (no
|
|
13
|
-
* parser bundled into the shared registry).
|
|
14
|
-
*/
|
|
15
|
-
interface Metric {
|
|
16
|
-
id: string;
|
|
17
|
-
name: string;
|
|
18
|
-
folder: string | null;
|
|
19
|
-
eventName: string;
|
|
20
|
-
aggregation: string;
|
|
21
|
-
valuePath: string | null;
|
|
22
|
-
queryIr?: unknown;
|
|
23
|
-
[key: string]: unknown;
|
|
24
|
-
}
|
|
25
|
-
interface MetricCreateInput {
|
|
26
|
-
name: string;
|
|
27
|
-
event_name: string;
|
|
28
|
-
folder?: string | null;
|
|
29
|
-
winsorize_pct?: number;
|
|
30
|
-
min_detectable_effect?: number | null;
|
|
31
|
-
/** Metric query DSL string, e.g. `sum(purchase, amount)`. */
|
|
32
|
-
query?: string;
|
|
33
|
-
/** Typed IR form (alternative to `query`). */
|
|
34
|
-
query_ir?: unknown;
|
|
35
|
-
}
|
|
36
|
-
interface MetricsClient {
|
|
37
|
-
/** Every metric in the project (the list endpoint is not paginated). */
|
|
38
|
-
list(): Promise<Metric[]>;
|
|
39
|
-
/** Fetch one metric by its full id. */
|
|
40
|
-
get(id: string): Promise<Metric>;
|
|
41
|
-
/** Resolve by exact id, unique id-prefix, or exact (unique) name. */
|
|
42
|
-
resolve(idOrName: string): Promise<Metric>;
|
|
43
|
-
create(input: MetricCreateInput): Promise<{
|
|
44
|
-
id: string;
|
|
45
|
-
name: string;
|
|
46
|
-
}>;
|
|
47
|
-
/** Soft-delete (the user-facing verb is `archive`). */
|
|
48
|
-
delete(id: string): Promise<{
|
|
49
|
-
ok: true;
|
|
50
|
-
}>;
|
|
51
|
-
}
|
|
52
|
-
declare function metricsClient(t: Transport): MetricsClient;
|
|
53
|
-
|
|
54
|
-
export { type Metric, type MetricCreateInput, type MetricsClient, metricsClient };
|
|
@@ -1,40 +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/resources/metrics.ts
|
|
12
|
-
var BASE = "/api/admin/metrics";
|
|
13
|
-
function metricsClient(t) {
|
|
14
|
-
async function list() {
|
|
15
|
-
return t.request("GET", BASE);
|
|
16
|
-
}
|
|
17
|
-
async function resolve(idOrName) {
|
|
18
|
-
const all = await list();
|
|
19
|
-
const byId = all.find((m) => m.id === idOrName);
|
|
20
|
-
if (byId) return byId;
|
|
21
|
-
const byPrefix = all.filter((m) => m.id.startsWith(idOrName));
|
|
22
|
-
if (byPrefix.length === 1) return byPrefix[0];
|
|
23
|
-
if (byPrefix.length > 1) throw new ApiError(`Metric id prefix '${idOrName}' is ambiguous`, 400);
|
|
24
|
-
const byName = all.filter((m) => m.name === idOrName);
|
|
25
|
-
if (byName.length === 1) return byName[0];
|
|
26
|
-
if (byName.length > 1)
|
|
27
|
-
throw new ApiError(`Metric name '${idOrName}' is ambiguous \u2014 pass an id`, 400);
|
|
28
|
-
throw new ApiError(`Metric '${idOrName}' not found`, 404);
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
list,
|
|
32
|
-
resolve,
|
|
33
|
-
get: (id) => t.request("GET", `${BASE}/${id}`),
|
|
34
|
-
create: (input) => t.request("POST", BASE, input),
|
|
35
|
-
delete: (id) => t.request("DELETE", `${BASE}/${id}`)
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
metricsClient
|
|
40
|
-
};
|