@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,509 +0,0 @@
|
|
|
1
|
-
// src/resources/configs.ts
|
|
2
|
-
import { z as z3 } from "zod";
|
|
3
|
-
|
|
4
|
-
// src/schemas/configs.ts
|
|
5
|
-
import { z as z2 } from "zod";
|
|
6
|
-
|
|
7
|
-
// src/schemas/constants.ts
|
|
8
|
-
var CONFIG_ENVS = ["dev", "staging", "prod"];
|
|
9
|
-
var CONFIG_KINDS = ["config", "killswitch"];
|
|
10
|
-
|
|
11
|
-
// src/schemas/folder.ts
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
var folderSchema = z.string().max(256).regex(/^[a-zA-Z0-9_-]+$/, "Folder must be alphanumeric, `_` or `-` (no `/`).").nullable().optional().describe(
|
|
14
|
-
"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."
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
// src/schemas/configs.ts
|
|
18
|
-
var SEGMENT = /^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?$/;
|
|
19
|
-
var RESERVED_FOLDER = "_default";
|
|
20
|
-
var configNameSchema = z2.string().max(128).refine(
|
|
21
|
-
(s) => {
|
|
22
|
-
const parts = s.split(".");
|
|
23
|
-
if (parts.length !== 2) return false;
|
|
24
|
-
return parts.every((p, i) => p === RESERVED_FOLDER && i === 0 ? true : SEGMENT.test(p));
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
message: "Must be `folder.name` \u2014 exactly two lowercase segments separated by a dot (e.g. `pricing.tiers`)."
|
|
28
|
-
}
|
|
29
|
-
).describe(
|
|
30
|
-
"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."
|
|
31
|
-
);
|
|
32
|
-
var configKindSchema = z2.enum(CONFIG_KINDS);
|
|
33
|
-
var configEnvSchema = z2.enum(CONFIG_ENVS).describe("Target environment. One of the project's configured envs (`dev`, `stage`, `prod`).");
|
|
34
|
-
var jsonSchemaSchema = z2.record(z2.string(), z2.unknown()).refine((s) => s.type === "object", { message: "Top-level schema type must be 'object'" }).describe(
|
|
35
|
-
"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."
|
|
36
|
-
);
|
|
37
|
-
var initialValuesSchema = z2.union([z2.unknown(), z2.record(configEnvSchema, z2.unknown())]).describe(
|
|
38
|
-
"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."
|
|
39
|
-
);
|
|
40
|
-
var configCreateSchema = z2.object({
|
|
41
|
-
name: configNameSchema,
|
|
42
|
-
description: z2.string().max(512).optional().describe("Optional free-form description shown in the dashboard. Max 512 chars."),
|
|
43
|
-
folder: folderSchema,
|
|
44
|
-
schema: jsonSchemaSchema,
|
|
45
|
-
value: initialValuesSchema.optional()
|
|
46
|
-
}).describe("Body for `POST /api/admin/configs`. `name` + `schema` required.");
|
|
47
|
-
var configUpdateSchema = z2.object({
|
|
48
|
-
schema: jsonSchemaSchema.optional().describe(
|
|
49
|
-
"Replacement schema. When supplied, the new schema is validated against every published value before it lands."
|
|
50
|
-
),
|
|
51
|
-
value: z2.unknown().optional().describe(
|
|
52
|
-
"Flat value applied to **every** env. Publishes a new version per env. To target one env, use `PUT /{id}/drafts` then `POST /{id}/publish`."
|
|
53
|
-
),
|
|
54
|
-
folder: folderSchema
|
|
55
|
-
}).describe(
|
|
56
|
-
"Body for `PATCH /api/admin/configs/{id}`. Partial \u2014 only supplied fields change. `value` republishes on every env."
|
|
57
|
-
);
|
|
58
|
-
var configSchemaUpdateSchema = z2.object({ schema: jsonSchemaSchema }).describe("Schema-only update. Does not bump value versions or rebuild KV.");
|
|
59
|
-
var configDraftUpsertSchema = z2.object({
|
|
60
|
-
env: configEnvSchema,
|
|
61
|
-
value: z2.unknown().describe("Draft value to stage on `env`. Validated against the config's current schema.")
|
|
62
|
-
}).describe(
|
|
63
|
-
"Body for `PUT /api/admin/configs/{id}/drafts`. Stages a value for a single env without publishing."
|
|
64
|
-
);
|
|
65
|
-
var configPublishSchema = z2.object({ env: configEnvSchema }).describe(
|
|
66
|
-
"Body for `POST /api/admin/configs/{id}/publish` and `DELETE /api/admin/configs/{id}/drafts`. Names the target env."
|
|
67
|
-
);
|
|
68
|
-
var configEnvPublishedSchema = z2.object({
|
|
69
|
-
version: z2.number().int().describe("Monotonically increasing version per env."),
|
|
70
|
-
publishedAt: z2.string().describe("ISO-8601 publish timestamp."),
|
|
71
|
-
publishedBy: z2.string().describe("Email/id of the actor who published this version.")
|
|
72
|
-
});
|
|
73
|
-
var configDraftSummarySchema = z2.object({
|
|
74
|
-
updatedAt: z2.string().describe("ISO-8601 last-edit timestamp on the draft."),
|
|
75
|
-
authorEmail: z2.string().describe("Email/id of the actor who last edited the draft."),
|
|
76
|
-
baseVersion: z2.number().int().describe("Published version the draft was forked from.")
|
|
77
|
-
});
|
|
78
|
-
var configResponseSchema = z2.object({
|
|
79
|
-
id: z2.string().describe("Stable opaque config id (`cfg_\u2026`)."),
|
|
80
|
-
name: configNameSchema,
|
|
81
|
-
description: z2.string().nullable(),
|
|
82
|
-
schema: jsonSchemaSchema,
|
|
83
|
-
updatedAt: z2.string().describe("ISO-8601 timestamp of last mutation."),
|
|
84
|
-
envs: z2.record(configEnvSchema, configEnvPublishedSchema).describe("Per-env latest published version metadata."),
|
|
85
|
-
drafts: z2.record(configEnvSchema, configDraftSummarySchema).describe("Per-env active drafts (if any)."),
|
|
86
|
-
values: z2.record(configEnvSchema, z2.unknown()).optional().describe("Per-env latest published values (only returned by `GET /{id}`, not list)."),
|
|
87
|
-
draftValues: z2.record(configEnvSchema, z2.unknown()).optional().describe("Per-env draft values (only returned by `GET /{id}`).")
|
|
88
|
-
});
|
|
89
|
-
var configCreateResponseSchema = z2.object({
|
|
90
|
-
id: z2.string().describe("Newly assigned config id."),
|
|
91
|
-
name: configNameSchema
|
|
92
|
-
});
|
|
93
|
-
var configUpdateResponseSchema = z2.object({
|
|
94
|
-
id: z2.string().describe("Config id that was updated.")
|
|
95
|
-
});
|
|
96
|
-
var configDeleteResponseSchema = z2.object({ ok: z2.literal(true) });
|
|
97
|
-
var configDraftSaveResponseSchema = z2.object({
|
|
98
|
-
id: z2.string(),
|
|
99
|
-
env: configEnvSchema,
|
|
100
|
-
baseVersion: z2.number().int().describe("Published version the draft is based on."),
|
|
101
|
-
updatedAt: z2.string()
|
|
102
|
-
});
|
|
103
|
-
var configDraftDiscardResponseSchema = z2.object({ ok: z2.literal(true) });
|
|
104
|
-
var configPublishResponseSchema = z2.object({
|
|
105
|
-
id: z2.string(),
|
|
106
|
-
env: configEnvSchema,
|
|
107
|
-
version: z2.number().int().describe("Newly published version on `env`.")
|
|
108
|
-
});
|
|
109
|
-
var configActivityEntrySchema = z2.object({
|
|
110
|
-
id: z2.string(),
|
|
111
|
-
action: z2.string().describe("Audit action (e.g. `config.create`, `config.publish`)."),
|
|
112
|
-
actorEmail: z2.string(),
|
|
113
|
-
actorType: z2.enum(["user", "cli", "system"]),
|
|
114
|
-
payload: z2.unknown().nullable(),
|
|
115
|
-
createdAt: z2.string().describe("ISO-8601 timestamp.")
|
|
116
|
-
});
|
|
117
|
-
var configActivityResponseSchema = z2.array(configActivityEntrySchema).describe("Recent audit rows for one config, newest first.");
|
|
118
|
-
|
|
119
|
-
// src/transport.ts
|
|
120
|
-
var ApiError = class extends Error {
|
|
121
|
-
constructor(message, status) {
|
|
122
|
-
super(message);
|
|
123
|
-
this.status = status;
|
|
124
|
-
this.name = "ApiError";
|
|
125
|
-
}
|
|
126
|
-
status;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// src/resources/configs.ts
|
|
130
|
-
var configListResponseSchema = z3.object({
|
|
131
|
-
data: z3.array(configResponseSchema),
|
|
132
|
-
next_cursor: z3.string().nullable()
|
|
133
|
-
});
|
|
134
|
-
var BASE = "/api/admin/configs";
|
|
135
|
-
function configsClient(t) {
|
|
136
|
-
async function list(opts = {}) {
|
|
137
|
-
const query = {};
|
|
138
|
-
if (opts.limit !== void 0) query.limit = String(opts.limit);
|
|
139
|
-
if (opts.cursor) query.cursor = opts.cursor;
|
|
140
|
-
return t.request("GET", BASE, void 0, query);
|
|
141
|
-
}
|
|
142
|
-
async function listAll() {
|
|
143
|
-
const out = [];
|
|
144
|
-
let cursor;
|
|
145
|
-
do {
|
|
146
|
-
const page = await list({ limit: 500, cursor });
|
|
147
|
-
out.push(...page.data);
|
|
148
|
-
cursor = page.next_cursor ?? void 0;
|
|
149
|
-
} while (cursor);
|
|
150
|
-
return out;
|
|
151
|
-
}
|
|
152
|
-
async function resolve(idOrName) {
|
|
153
|
-
try {
|
|
154
|
-
return await t.request("GET", `${BASE}/${idOrName}`);
|
|
155
|
-
} catch (err) {
|
|
156
|
-
if (!(err instanceof ApiError) || err.status !== 404) throw err;
|
|
157
|
-
}
|
|
158
|
-
const all = await listAll();
|
|
159
|
-
const found = all.find((c) => c.name === idOrName);
|
|
160
|
-
if (!found) throw new ApiError(`Config '${idOrName}' not found`, 404);
|
|
161
|
-
return found;
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
list,
|
|
165
|
-
listAll,
|
|
166
|
-
resolve,
|
|
167
|
-
get: (id) => t.request("GET", `${BASE}/${id}`),
|
|
168
|
-
create: (input) => t.request("POST", BASE, configCreateSchema.parse(input)),
|
|
169
|
-
update: (id, input) => t.request("PATCH", `${BASE}/${id}`, configUpdateSchema.parse(input)),
|
|
170
|
-
delete: (id) => t.request("DELETE", `${BASE}/${id}`),
|
|
171
|
-
saveDraft: (id, input) => t.request("PUT", `${BASE}/${id}/drafts`, configDraftUpsertSchema.parse(input)),
|
|
172
|
-
discardDraft: (id, input) => t.request("DELETE", `${BASE}/${id}/drafts`, configPublishSchema.parse(input)),
|
|
173
|
-
publish: (id, input) => t.request("POST", `${BASE}/${id}/publish`, configPublishSchema.parse(input)),
|
|
174
|
-
activity: (id, limit) => t.request(
|
|
175
|
-
"GET",
|
|
176
|
-
`${BASE}/${id}/activity`,
|
|
177
|
-
void 0,
|
|
178
|
-
limit ? { limit: String(limit) } : void 0
|
|
179
|
-
)
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
var SAMPLE_CFG = {
|
|
183
|
-
id: "cfg_01j7wae5h6j7k8l9m0n1p2q3r4",
|
|
184
|
-
name: "pricing.tiers",
|
|
185
|
-
description: "Pricing tier definitions consumed by the checkout flow.",
|
|
186
|
-
schema: {
|
|
187
|
-
type: "object",
|
|
188
|
-
properties: {
|
|
189
|
-
tiers: { type: "array", items: { type: "object" } }
|
|
190
|
-
},
|
|
191
|
-
required: ["tiers"]
|
|
192
|
-
},
|
|
193
|
-
updatedAt: "2026-05-09T18:22:11.000Z",
|
|
194
|
-
envs: {
|
|
195
|
-
dev: { version: 5, publishedAt: "2026-05-09T18:22:11.000Z", publishedBy: "ana@example.com" },
|
|
196
|
-
stage: { version: 4, publishedAt: "2026-05-08T11:05:22.000Z", publishedBy: "ana@example.com" },
|
|
197
|
-
prod: { version: 4, publishedAt: "2026-05-08T11:05:22.000Z", publishedBy: "ana@example.com" }
|
|
198
|
-
},
|
|
199
|
-
drafts: {
|
|
200
|
-
dev: {
|
|
201
|
-
updatedAt: "2026-05-10T09:31:00.000Z",
|
|
202
|
-
authorEmail: "bo@example.com",
|
|
203
|
-
baseVersion: 5
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
var configsResource = {
|
|
208
|
-
name: "configs",
|
|
209
|
-
basePath: BASE,
|
|
210
|
-
describeOne: "config",
|
|
211
|
-
describeMany: "configs",
|
|
212
|
-
tag: {
|
|
213
|
-
name: "Configs",
|
|
214
|
-
description: [
|
|
215
|
-
"Dynamic configs: JSON-Schema-validated structured values delivered to SDKs and editable per environment with a draft/publish workflow.",
|
|
216
|
-
"",
|
|
217
|
-
"**Identity.** Each config is keyed by `name` in `folder.name` form (e.g. `pricing.tiers`). Immutable after create.",
|
|
218
|
-
"",
|
|
219
|
-
"**Schema-first.** Every config carries a JSON Schema (draft 2020-12, top-level `type: 'object'`). Every published value is validated against it.",
|
|
220
|
-
"",
|
|
221
|
-
"**Drafts \u2192 publish.** Per-env edits go through `PUT /{id}/drafts` (stages a value) then `POST /{id}/publish` (promotes to a new version). The flat `PATCH /{id}` republishes on **every** env in one shot \u2014 bypassing drafts.",
|
|
222
|
-
"",
|
|
223
|
-
"**Versioning.** Each publish bumps the per-env `version` monotonically. SDKs deliver the latest published version for each env."
|
|
224
|
-
].join("\n")
|
|
225
|
-
},
|
|
226
|
-
schemas: {
|
|
227
|
-
create: configCreateSchema,
|
|
228
|
-
update: configUpdateSchema,
|
|
229
|
-
saveDraft: configDraftUpsertSchema,
|
|
230
|
-
publish: configPublishSchema
|
|
231
|
-
},
|
|
232
|
-
actions: [
|
|
233
|
-
{ name: "publish", description: "Publish a config draft for an env" },
|
|
234
|
-
{ name: "saveDraft", description: "Save a draft value for an env" },
|
|
235
|
-
{ name: "discardDraft", description: "Discard a draft for an env" }
|
|
236
|
-
],
|
|
237
|
-
endpoints: [
|
|
238
|
-
{
|
|
239
|
-
operationId: "listConfigs",
|
|
240
|
-
method: "GET",
|
|
241
|
-
path: "",
|
|
242
|
-
summary: "List dynamic configs",
|
|
243
|
-
description: "Returns a single page of configs ordered by `updated_at desc, id desc`. Each row includes the latest published `version` per env and any active drafts.",
|
|
244
|
-
response: configListResponseSchema,
|
|
245
|
-
examples: { response: { data: [SAMPLE_CFG], next_cursor: null } },
|
|
246
|
-
useCase: "Snapshot every config in the project \u2014 e.g. CI check that asserts no env is stuck on a stale default or that every config has a published value on prod."
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
operationId: "getConfig",
|
|
250
|
-
method: "GET",
|
|
251
|
-
path: "/{id}",
|
|
252
|
-
summary: "Get one config",
|
|
253
|
-
description: "Returns config metadata plus the latest published values per env and any active draft values. Use this to fetch the JSON the editor renders.",
|
|
254
|
-
pathParams: { id: "Stable opaque config id (`cfg_\u2026`) or the config's `name`." },
|
|
255
|
-
response: configResponseSchema,
|
|
256
|
-
examples: {
|
|
257
|
-
response: {
|
|
258
|
-
...SAMPLE_CFG,
|
|
259
|
-
values: {
|
|
260
|
-
dev: { tiers: [{ name: "free" }, { name: "pro" }] },
|
|
261
|
-
stage: { tiers: [{ name: "free" }, { name: "pro" }] },
|
|
262
|
-
prod: { tiers: [{ name: "free" }, { name: "pro" }] }
|
|
263
|
-
},
|
|
264
|
-
draftValues: {
|
|
265
|
-
dev: { tiers: [{ name: "free" }, { name: "pro" }, { name: "enterprise" }] }
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
useCase: "Fetch one config's current published values and any in-flight drafts."
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
operationId: "createConfig",
|
|
273
|
-
method: "POST",
|
|
274
|
-
path: "",
|
|
275
|
-
summary: "Create a dynamic config",
|
|
276
|
-
description: [
|
|
277
|
-
"Creates a new config with the given `schema`. The initial `value` (or an empty object) is published as version 1 on **every** env.",
|
|
278
|
-
"",
|
|
279
|
-
"Returns `409` if `name` already exists in the project, `400` if `value` doesn't validate against `schema`."
|
|
280
|
-
].join("\n"),
|
|
281
|
-
successStatus: 201,
|
|
282
|
-
request: configCreateSchema,
|
|
283
|
-
response: configCreateResponseSchema,
|
|
284
|
-
examples: {
|
|
285
|
-
requestExamples: {
|
|
286
|
-
minimal: {
|
|
287
|
-
summary: "Minimal \u2014 name + schema",
|
|
288
|
-
description: "Smallest valid body. Initial value defaults to `{}` on every env.",
|
|
289
|
-
value: {
|
|
290
|
-
name: "pricing.tiers",
|
|
291
|
-
schema: {
|
|
292
|
-
type: "object",
|
|
293
|
-
properties: { tiers: { type: "array" } },
|
|
294
|
-
required: ["tiers"]
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
seededValue: {
|
|
299
|
-
summary: "Seeded \u2014 schema + initial value",
|
|
300
|
-
description: "Seed the same JSON object on every env at version 1.",
|
|
301
|
-
value: {
|
|
302
|
-
name: "pricing.tiers",
|
|
303
|
-
description: "Pricing tier definitions consumed by checkout.",
|
|
304
|
-
schema: {
|
|
305
|
-
type: "object",
|
|
306
|
-
properties: { tiers: { type: "array" } },
|
|
307
|
-
required: ["tiers"]
|
|
308
|
-
},
|
|
309
|
-
value: { tiers: [{ name: "free" }, { name: "pro" }] }
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
perEnvSeed: {
|
|
313
|
-
summary: "Per-env seed",
|
|
314
|
-
description: "Pass a `{ env: value }` map to seed different initial values per env.",
|
|
315
|
-
value: {
|
|
316
|
-
name: "pricing.tiers",
|
|
317
|
-
schema: {
|
|
318
|
-
type: "object",
|
|
319
|
-
properties: { tiers: { type: "array" } },
|
|
320
|
-
required: ["tiers"]
|
|
321
|
-
},
|
|
322
|
-
value: {
|
|
323
|
-
dev: { tiers: [{ name: "free" }, { name: "pro" }, { name: "enterprise" }] },
|
|
324
|
-
stage: { tiers: [{ name: "free" }, { name: "pro" }] },
|
|
325
|
-
prod: { tiers: [{ name: "free" }, { name: "pro" }] }
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
},
|
|
330
|
-
response: { id: "cfg_01j7wae5h6j7k8l9m0n1p2q3r4", name: "pricing.tiers" }
|
|
331
|
-
},
|
|
332
|
-
useCase: [
|
|
333
|
-
"- **Minimal create** \u2014 `name` + `schema`. Initial value defaults to `{}`.",
|
|
334
|
-
"- **Seeded create** \u2014 supply a flat `value` to publish the same object on every env.",
|
|
335
|
-
"- **Per-env seed** \u2014 supply a `{ env: value }` map for different per-env starting values."
|
|
336
|
-
].join("\n")
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
operationId: "updateConfig",
|
|
340
|
-
method: "PATCH",
|
|
341
|
-
path: "/{id}",
|
|
342
|
-
summary: "Update a dynamic config",
|
|
343
|
-
description: [
|
|
344
|
-
"Partial update. When `value` is supplied it is **republished on every env** (new version per env). When `schema` is supplied it replaces the current schema; every existing value is re-validated.",
|
|
345
|
-
"",
|
|
346
|
-
"For env-scoped edits, use the draft/publish flow (`PUT /{id}/drafts` then `POST /{id}/publish`) instead."
|
|
347
|
-
].join("\n"),
|
|
348
|
-
pathParams: { id: "Stable opaque config id." },
|
|
349
|
-
request: configUpdateSchema,
|
|
350
|
-
response: configUpdateResponseSchema,
|
|
351
|
-
examples: {
|
|
352
|
-
requestExamples: {
|
|
353
|
-
flatValue: {
|
|
354
|
-
summary: "Flat value \u2014 republish on every env",
|
|
355
|
-
description: "Sets the same JSON object as a new version on dev/stage/prod.",
|
|
356
|
-
value: { value: { tiers: [{ name: "free" }, { name: "pro" }] } }
|
|
357
|
-
},
|
|
358
|
-
schemaOnly: {
|
|
359
|
-
summary: "Schema-only update",
|
|
360
|
-
description: "Replaces the schema. Existing values must still validate or the update fails.",
|
|
361
|
-
value: {
|
|
362
|
-
schema: {
|
|
363
|
-
type: "object",
|
|
364
|
-
properties: {
|
|
365
|
-
tiers: { type: "array" },
|
|
366
|
-
trial_days: { type: "integer" }
|
|
367
|
-
},
|
|
368
|
-
required: ["tiers"]
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
response: { id: "cfg_01j7wae5h6j7k8l9m0n1p2q3r4" }
|
|
374
|
-
},
|
|
375
|
-
useCase: [
|
|
376
|
-
'- **Republish flat value** \u2014 `{ "value": {\u2026} }` sets the same value on every env.',
|
|
377
|
-
'- **Schema migration** \u2014 `{ "schema": {\u2026} }` replaces the schema; existing values are re-validated.',
|
|
378
|
-
"- **Env-scoped edits** \u2014 use `PUT /{id}/drafts` + `POST /{id}/publish` instead of PATCH."
|
|
379
|
-
].join("\n")
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
operationId: "deleteConfig",
|
|
383
|
-
method: "DELETE",
|
|
384
|
-
path: "/{id}",
|
|
385
|
-
summary: "Delete a dynamic config",
|
|
386
|
-
description: "Soft-deletes the config and rebuilds the project's flags KV blob.",
|
|
387
|
-
pathParams: { id: "Stable opaque config id." },
|
|
388
|
-
response: configDeleteResponseSchema,
|
|
389
|
-
examples: { response: { ok: true } },
|
|
390
|
-
useCase: "Tear down a config after its consumers have stopped reading it."
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
operationId: "saveConfigDraft",
|
|
394
|
-
method: "PUT",
|
|
395
|
-
path: "/{id}/drafts",
|
|
396
|
-
summary: "Save a draft value",
|
|
397
|
-
description: [
|
|
398
|
-
"Stages a value for one env without publishing. The draft is validated against the config's current schema and stored alongside the `baseVersion` it was forked from.",
|
|
399
|
-
"",
|
|
400
|
-
"Saving over an existing draft overwrites it. Use `POST /{id}/publish` to promote it to a new published version."
|
|
401
|
-
].join("\n"),
|
|
402
|
-
pathParams: { id: "Stable opaque config id." },
|
|
403
|
-
request: configDraftUpsertSchema,
|
|
404
|
-
response: configDraftSaveResponseSchema,
|
|
405
|
-
examples: {
|
|
406
|
-
requestExamples: {
|
|
407
|
-
stageDev: {
|
|
408
|
-
summary: "Stage a dev draft",
|
|
409
|
-
description: "Stages a new value on dev without touching stage/prod.",
|
|
410
|
-
value: {
|
|
411
|
-
env: "dev",
|
|
412
|
-
value: { tiers: [{ name: "free" }, { name: "pro" }, { name: "enterprise" }] }
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
},
|
|
416
|
-
response: {
|
|
417
|
-
id: "cfg_01j7wae5h6j7k8l9m0n1p2q3r4",
|
|
418
|
-
env: "dev",
|
|
419
|
-
baseVersion: 5,
|
|
420
|
-
updatedAt: "2026-05-10T09:31:00.000Z"
|
|
421
|
-
}
|
|
422
|
-
},
|
|
423
|
-
useCase: "Iterate on a config value on dev without affecting prod \u2014 preview in staging, then publish."
|
|
424
|
-
},
|
|
425
|
-
{
|
|
426
|
-
operationId: "discardConfigDraft",
|
|
427
|
-
method: "DELETE",
|
|
428
|
-
path: "/{id}/drafts",
|
|
429
|
-
summary: "Discard a draft",
|
|
430
|
-
description: "Drops the in-flight draft on one env. Published values are unaffected.",
|
|
431
|
-
pathParams: { id: "Stable opaque config id." },
|
|
432
|
-
request: configPublishSchema,
|
|
433
|
-
response: configDraftDiscardResponseSchema,
|
|
434
|
-
examples: {
|
|
435
|
-
requestExamples: {
|
|
436
|
-
discardDev: {
|
|
437
|
-
summary: "Discard the dev draft",
|
|
438
|
-
description: "Drops the staged dev draft without publishing.",
|
|
439
|
-
value: { env: "dev" }
|
|
440
|
-
}
|
|
441
|
-
},
|
|
442
|
-
response: { ok: true }
|
|
443
|
-
},
|
|
444
|
-
useCase: "Abandon an in-progress draft after deciding not to ship it."
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
operationId: "publishConfigDraft",
|
|
448
|
-
method: "POST",
|
|
449
|
-
path: "/{id}/publish",
|
|
450
|
-
summary: "Publish a draft",
|
|
451
|
-
description: [
|
|
452
|
-
"Promotes the staged draft on one env to a new published version. The draft must still validate against the current schema.",
|
|
453
|
-
"",
|
|
454
|
-
"Returns `404` if there is no draft for the given env."
|
|
455
|
-
].join("\n"),
|
|
456
|
-
pathParams: { id: "Stable opaque config id." },
|
|
457
|
-
request: configPublishSchema,
|
|
458
|
-
response: configPublishResponseSchema,
|
|
459
|
-
examples: {
|
|
460
|
-
requestExamples: {
|
|
461
|
-
publishDev: {
|
|
462
|
-
summary: "Publish the dev draft",
|
|
463
|
-
description: "Promotes the dev draft to a new published version on dev.",
|
|
464
|
-
value: { env: "dev" }
|
|
465
|
-
},
|
|
466
|
-
publishProd: {
|
|
467
|
-
summary: "Publish to prod",
|
|
468
|
-
description: "Promotes the prod draft after staging signed off.",
|
|
469
|
-
value: { env: "prod" }
|
|
470
|
-
}
|
|
471
|
-
},
|
|
472
|
-
response: { id: "cfg_01j7wae5h6j7k8l9m0n1p2q3r4", env: "dev", version: 6 }
|
|
473
|
-
},
|
|
474
|
-
useCase: "Ship a staged change once you've validated it on a lower env."
|
|
475
|
-
},
|
|
476
|
-
{
|
|
477
|
-
operationId: "listConfigActivity",
|
|
478
|
-
method: "GET",
|
|
479
|
-
path: "/{id}/activity",
|
|
480
|
-
summary: "List config activity",
|
|
481
|
-
description: "Returns recent audit rows for one config (create, update, draft.save, publish, delete) ordered newest first. Use the `limit` query parameter to cap the result (1\u2013100, default 20).",
|
|
482
|
-
pathParams: { id: "Stable opaque config id." },
|
|
483
|
-
queryParams: {
|
|
484
|
-
limit: {
|
|
485
|
-
schema: z3.coerce.number().int().min(1).max(100).default(20),
|
|
486
|
-
description: "Max rows to return (1\u2013100). Defaults to 20."
|
|
487
|
-
}
|
|
488
|
-
},
|
|
489
|
-
response: configActivityResponseSchema,
|
|
490
|
-
examples: {
|
|
491
|
-
response: [
|
|
492
|
-
{
|
|
493
|
-
id: "act_01j7waf01a2b3c4d5e6f7g8h9i",
|
|
494
|
-
action: "config.publish",
|
|
495
|
-
actorEmail: "ana@example.com",
|
|
496
|
-
actorType: "user",
|
|
497
|
-
payload: { env: "dev", version: 6 },
|
|
498
|
-
createdAt: "2026-05-10T09:31:42.000Z"
|
|
499
|
-
}
|
|
500
|
-
]
|
|
501
|
-
},
|
|
502
|
-
useCase: "Render the activity panel in the config editor or drive a slack notification on publish events."
|
|
503
|
-
}
|
|
504
|
-
]
|
|
505
|
-
};
|
|
506
|
-
export {
|
|
507
|
-
configsClient,
|
|
508
|
-
configsResource
|
|
509
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Transport } from '../transport.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Event catalog — the registry of event names (and their typed properties) that
|
|
5
|
-
* metric queries reference. `/collect` auto-discovers unknown names as
|
|
6
|
-
* `pending` rows; `approve` promotes them to usable. Property `name:type`
|
|
7
|
-
* parsing is a CLI/MCP facade concern; the resource takes the already-parsed
|
|
8
|
-
* `properties` array.
|
|
9
|
-
*/
|
|
10
|
-
interface EventProperty {
|
|
11
|
-
name: string;
|
|
12
|
-
type: "string" | "number" | "boolean";
|
|
13
|
-
required: boolean;
|
|
14
|
-
description?: string;
|
|
15
|
-
}
|
|
16
|
-
interface CatalogEvent {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
folder: string | null;
|
|
20
|
-
description: string | null;
|
|
21
|
-
properties: EventProperty[];
|
|
22
|
-
pending: number;
|
|
23
|
-
createdAt: string;
|
|
24
|
-
[key: string]: unknown;
|
|
25
|
-
}
|
|
26
|
-
interface EventCreateInput {
|
|
27
|
-
name: string;
|
|
28
|
-
folder?: string | null;
|
|
29
|
-
description?: string;
|
|
30
|
-
properties?: EventProperty[];
|
|
31
|
-
}
|
|
32
|
-
interface EventUpdateInput {
|
|
33
|
-
folder?: string | null;
|
|
34
|
-
description?: string;
|
|
35
|
-
/** Replaces the full property set (no merge). */
|
|
36
|
-
properties?: EventProperty[];
|
|
37
|
-
}
|
|
38
|
-
interface EventsClient {
|
|
39
|
-
list(): Promise<CatalogEvent[]>;
|
|
40
|
-
get(id: string): Promise<CatalogEvent>;
|
|
41
|
-
create(input: EventCreateInput): Promise<{
|
|
42
|
-
id: string;
|
|
43
|
-
name: string;
|
|
44
|
-
}>;
|
|
45
|
-
update(id: string, input: EventUpdateInput): Promise<{
|
|
46
|
-
id: string;
|
|
47
|
-
}>;
|
|
48
|
-
/** Promote a pending (auto-discovered) event so metrics can query it. */
|
|
49
|
-
approve(id: string, input?: EventUpdateInput): Promise<{
|
|
50
|
-
id: string;
|
|
51
|
-
}>;
|
|
52
|
-
/** Soft-delete (the user-facing verb is `archive`). */
|
|
53
|
-
delete(id: string): Promise<{
|
|
54
|
-
ok: true;
|
|
55
|
-
}>;
|
|
56
|
-
/** Resolve by exact id, unique id-prefix, or exact (unique) name. */
|
|
57
|
-
resolve(idOrName: string): Promise<CatalogEvent>;
|
|
58
|
-
}
|
|
59
|
-
declare function eventsClient(t: Transport): EventsClient;
|
|
60
|
-
|
|
61
|
-
export { type CatalogEvent, type EventCreateInput, type EventProperty, type EventUpdateInput, type EventsClient, eventsClient };
|
package/dist/resources/events.js
DELETED
|
@@ -1,42 +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/events.ts
|
|
12
|
-
var BASE = "/api/admin/events";
|
|
13
|
-
function eventsClient(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((e) => e.id === idOrName);
|
|
20
|
-
if (byId) return byId;
|
|
21
|
-
const byPrefix = all.filter((e) => e.id.startsWith(idOrName));
|
|
22
|
-
if (byPrefix.length === 1) return byPrefix[0];
|
|
23
|
-
if (byPrefix.length > 1) throw new ApiError(`Event id prefix '${idOrName}' is ambiguous`, 400);
|
|
24
|
-
const byName = all.filter((e) => e.name === idOrName);
|
|
25
|
-
if (byName.length === 1) return byName[0];
|
|
26
|
-
if (byName.length > 1)
|
|
27
|
-
throw new ApiError(`Event name '${idOrName}' is ambiguous \u2014 pass an id`, 400);
|
|
28
|
-
throw new ApiError(`Event '${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
|
-
update: (id, input) => t.request("PATCH", `${BASE}/${id}`, input),
|
|
36
|
-
approve: (id, input = {}) => t.request("POST", `${BASE}/${id}/approve`, input),
|
|
37
|
-
delete: (id) => t.request("DELETE", `${BASE}/${id}`)
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export {
|
|
41
|
-
eventsClient
|
|
42
|
-
};
|