@shipeasy/openapi 1.6.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +37 -0
  2. package/dist/chunk-EPLLHLZN.js +1616 -0
  3. package/dist/chunk-EPLLHLZN.js.map +1 -0
  4. package/dist/chunk-SPH5HWCD.js +3326 -0
  5. package/dist/chunk-SPH5HWCD.js.map +1 -0
  6. package/dist/client-pVkoo3Bf.d.ts +11186 -0
  7. package/dist/client.d.ts +1 -0
  8. package/dist/client.js +215 -0
  9. package/dist/client.js.map +1 -0
  10. package/dist/custom.d.ts +64 -0
  11. package/dist/custom.js +292 -0
  12. package/dist/custom.js.map +1 -0
  13. package/dist/index.d.ts +29 -41
  14. package/dist/index.js +258 -4375
  15. package/dist/index.js.map +1 -0
  16. package/dist/node-context.d.ts +81 -33
  17. package/dist/node-context.js +98 -44
  18. package/dist/node-context.js.map +1 -0
  19. package/dist/schemas.d.ts +7920 -0
  20. package/dist/schemas.js +1083 -0
  21. package/dist/schemas.js.map +1 -0
  22. package/openapi.json +15297 -3044
  23. package/openapi.yaml +13979 -0
  24. package/package.json +33 -26
  25. package/spec/components/errors.yaml +53 -0
  26. package/spec/components/parameters.yaml +24 -0
  27. package/spec/components/responses.yaml +107 -0
  28. package/spec/components/schemas/alert-rules.yaml +175 -0
  29. package/spec/components/schemas/attributes.yaml +157 -0
  30. package/spec/components/schemas/common.yaml +87 -0
  31. package/spec/components/schemas/configs.yaml +371 -0
  32. package/spec/components/schemas/connectors.yaml +593 -0
  33. package/spec/components/schemas/errors-api.yaml +209 -0
  34. package/spec/components/schemas/events.yaml +321 -0
  35. package/spec/components/schemas/experiments.yaml +865 -0
  36. package/spec/components/schemas/gate-templates.yaml +198 -0
  37. package/spec/components/schemas/gates.yaml +890 -0
  38. package/spec/components/schemas/i18n.yaml +478 -0
  39. package/spec/components/schemas/keys.yaml +186 -0
  40. package/spec/components/schemas/killswitches.yaml +309 -0
  41. package/spec/components/schemas/metrics.yaml +547 -0
  42. package/spec/components/schemas/ops.yaml +1011 -0
  43. package/spec/components/schemas/projects.yaml +222 -0
  44. package/spec/components/schemas/search.yaml +46 -0
  45. package/spec/components/schemas/universes.yaml +127 -0
  46. package/spec/openapi.yaml +348 -0
  47. package/spec/paths/alert-rules.yaml +250 -0
  48. package/spec/paths/attributes.yaml +261 -0
  49. package/spec/paths/configs.yaml +744 -0
  50. package/spec/paths/connectors.yaml +748 -0
  51. package/spec/paths/errors.yaml +382 -0
  52. package/spec/paths/events.yaml +366 -0
  53. package/spec/paths/experiments.yaml +777 -0
  54. package/spec/paths/gate-templates.yaml +263 -0
  55. package/spec/paths/gates.yaml +451 -0
  56. package/spec/paths/i18n.yaml +544 -0
  57. package/spec/paths/keys.yaml +181 -0
  58. package/spec/paths/killswitches.yaml +557 -0
  59. package/spec/paths/metrics.yaml +302 -0
  60. package/spec/paths/ops.yaml +446 -0
  61. package/spec/paths/projects.yaml +210 -0
  62. package/spec/paths/search.yaml +62 -0
  63. package/spec/paths/universes.yaml +247 -0
  64. package/dist/operations/attributes.d.ts +0 -33
  65. package/dist/operations/attributes.js +0 -16
  66. package/dist/operations/cli-adapter.d.ts +0 -35
  67. package/dist/operations/cli-adapter.js +0 -91
  68. package/dist/operations/coerce.d.ts +0 -32
  69. package/dist/operations/coerce.js +0 -53
  70. package/dist/operations/configs.d.ts +0 -28
  71. package/dist/operations/configs.js +0 -119
  72. package/dist/operations/docs.d.ts +0 -37
  73. package/dist/operations/docs.js +0 -39
  74. package/dist/operations/events.d.ts +0 -28
  75. package/dist/operations/events.js +0 -121
  76. package/dist/operations/experiments.d.ts +0 -28
  77. package/dist/operations/experiments.js +0 -280
  78. package/dist/operations/gates.d.ts +0 -28
  79. package/dist/operations/gates.js +0 -132
  80. package/dist/operations/i18n.d.ts +0 -28
  81. package/dist/operations/i18n.js +0 -121
  82. package/dist/operations/index.d.ts +0 -63
  83. package/dist/operations/index.js +0 -1751
  84. package/dist/operations/killswitches.d.ts +0 -28
  85. package/dist/operations/killswitches.js +0 -126
  86. package/dist/operations/mcp-adapter.d.ts +0 -35
  87. package/dist/operations/mcp-adapter.js +0 -94
  88. package/dist/operations/metrics.d.ts +0 -30
  89. package/dist/operations/metrics.js +0 -114
  90. package/dist/operations/ops.d.ts +0 -28
  91. package/dist/operations/ops.js +0 -313
  92. package/dist/operations/projects.d.ts +0 -28
  93. package/dist/operations/projects.js +0 -36
  94. package/dist/operations/sdk-docs.d.ts +0 -28
  95. package/dist/operations/sdk-docs.js +0 -160
  96. package/dist/operations/types.d.ts +0 -138
  97. package/dist/operations/types.js +0 -9
  98. package/dist/operations/universes.d.ts +0 -28
  99. package/dist/operations/universes.js +0 -93
  100. package/dist/operations/util.d.ts +0 -33
  101. package/dist/operations/util.js +0 -9
  102. package/dist/resources/alert-rules.d.ts +0 -50
  103. package/dist/resources/alert-rules.js +0 -75
  104. package/dist/resources/attributes.d.ts +0 -19
  105. package/dist/resources/attributes.js +0 -10
  106. package/dist/resources/configs.d.ts +0 -681
  107. package/dist/resources/configs.js +0 -509
  108. package/dist/resources/events.d.ts +0 -61
  109. package/dist/resources/events.js +0 -42
  110. package/dist/resources/experiments.d.ts +0 -849
  111. package/dist/resources/experiments.js +0 -707
  112. package/dist/resources/gates.d.ts +0 -808
  113. package/dist/resources/gates.js +0 -522
  114. package/dist/resources/i18n.d.ts +0 -84
  115. package/dist/resources/i18n.js +0 -60
  116. package/dist/resources/index.d.ts +0 -2767
  117. package/dist/resources/index.js +0 -2563
  118. package/dist/resources/killswitches.d.ts +0 -436
  119. package/dist/resources/killswitches.js +0 -514
  120. package/dist/resources/metrics.d.ts +0 -54
  121. package/dist/resources/metrics.js +0 -40
  122. package/dist/resources/ops.d.ts +0 -88
  123. package/dist/resources/ops.js +0 -36
  124. package/dist/resources/projects.d.ts +0 -54
  125. package/dist/resources/projects.js +0 -14
  126. package/dist/resources/universes.d.ts +0 -185
  127. package/dist/resources/universes.js +0 -234
  128. package/dist/schemas/alert-rules.d.ts +0 -65
  129. package/dist/schemas/alert-rules.js +0 -37
  130. package/dist/schemas/configs.d.ts +0 -154
  131. package/dist/schemas/configs.js +0 -134
  132. package/dist/schemas/constants.d.ts +0 -6
  133. package/dist/schemas/constants.js +0 -7
  134. package/dist/schemas/experiments.d.ts +0 -229
  135. package/dist/schemas/experiments.js +0 -221
  136. package/dist/schemas/folder.d.ts +0 -10
  137. package/dist/schemas/folder.js +0 -8
  138. package/dist/schemas/gates.d.ts +0 -386
  139. package/dist/schemas/gates.js +0 -190
  140. package/dist/schemas/index.d.ts +0 -11
  141. package/dist/schemas/index.js +0 -762
  142. package/dist/schemas/killswitches.d.ts +0 -110
  143. package/dist/schemas/killswitches.js +0 -226
  144. package/dist/schemas/metric-name.d.ts +0 -5
  145. package/dist/schemas/metric-name.js +0 -6
  146. package/dist/schemas/pagination.d.ts +0 -37
  147. package/dist/schemas/pagination.js +0 -44
  148. package/dist/schemas/universes.d.ts +0 -35
  149. package/dist/schemas/universes.js +0 -55
  150. package/dist/transport.d.ts +0 -30
  151. package/dist/transport.js +0 -44
@@ -1,138 +0,0 @@
1
- import { AdminClient } from '../resources/index.js';
2
- import 'zod/v4/core';
3
- import 'zod';
4
- import '../resources/attributes.js';
5
- import '../transport.js';
6
- import '../resources/i18n.js';
7
- import '../resources/projects.js';
8
- import '../resources/ops.js';
9
- import '../resources/events.js';
10
- import '../resources/metrics.js';
11
- import '../resources/alert-rules.js';
12
- import '../schemas/alert-rules.js';
13
- import '../resources/killswitches.js';
14
- import '../schemas/killswitches.js';
15
- import '../schemas/pagination.js';
16
- import '../resources/universes.js';
17
- import '../schemas/universes.js';
18
- import '../resources/configs.js';
19
- import '../schemas/configs.js';
20
- import '../resources/experiments.js';
21
- import '../schemas/experiments.js';
22
- import '../resources/gates.js';
23
- import '../schemas/gates.js';
24
-
25
- /**
26
- * Operation registry — the single source of truth that drives BOTH
27
- * `@shipeasy/cli` (commander subcommands) and `@shipeasy/mcp` (MCP tools),
28
- * plus their generated docs.
29
- *
30
- * Today each surface is hand-maintained: the CLI hand-builds commander
31
- * commands in `packages/cli/src/commands/*`, the MCP server hand-writes tool
32
- * JSON Schemas in `packages/mcp/src/tools/schema.ts` and a 60-branch dispatch
33
- * in `server.ts`, and the percent→basis-points + `JSON.parse(rules)` mapping
34
- * is written *identically* in both. An Operation collapses that into one
35
- * definition: the params describe the ergonomic facade once, `run` performs
36
- * the facade→wire mapping once, and the adapters in this folder project it
37
- * onto each surface.
38
- */
39
- /** Param value kinds. `json` arrives as a JSON string on both surfaces and is parsed by the framework. */
40
- type ParamType = "string" | "number" | "boolean" | "json";
41
- interface Param {
42
- /** Field name — also the CLI flag (`--<name>`) or positional, and the MCP property key. */
43
- name: string;
44
- type: ParamType;
45
- /** Shown in CLI `--help`, the MCP tool input schema, and generated docs. */
46
- description: string;
47
- required?: boolean;
48
- /** CLI only: render as a positional `<name>` argument instead of a `--flag`. Ignored by MCP. */
49
- positional?: boolean;
50
- /** Restrict to a fixed set (MCP `enum`, CLI validated in coercion). */
51
- enum?: string[];
52
- }
53
- interface OpExample {
54
- /** Why you'd run this. */
55
- note?: string;
56
- /** A copy-pasteable command line. */
57
- run: string;
58
- }
59
- /** Coerced facade input handed to `run` — keys are param names, values coerced by `ParamType`. */
60
- type OpInput = Record<string, unknown>;
61
- interface Operation<O = unknown> {
62
- /**
63
- * Command-path segments BEFORE the verb, e.g. `["release", "flags"]`.
64
- * This is the exact CLI nesting; nested resources just add segments
65
- * (`["release", "experiments", "universes"]`). Drives grouping + naming.
66
- */
67
- group: string[];
68
- /**
69
- * The verb, e.g. `create`. Authored ONCE — every surface name derives from
70
- * `group` + `name` so they can never drift:
71
- * id = `release.flags.create` (opId — `.`-joined)
72
- * CLI = `release flags create` (opCli — space-joined, the real invocation)
73
- * MCP = `release_flags_create` (opMcpName — `_`-joined; MCP names can't have spaces)
74
- */
75
- name: string;
76
- /** True for writes — the CLI/MCP adapter enforces `.shipeasy` binding before running. */
77
- mutates: boolean;
78
- /** One-liner — CLI `.description()` and the docs heading. */
79
- summary: string;
80
- /** Long-form — the MCP tool `description` and the docs body. */
81
- description: string;
82
- params: Param[];
83
- examples?: OpExample[];
84
- /**
85
- * The single source of behaviour: coerced facade input → typed AdminClient
86
- * call → raw data. Returns data (never prints) so every surface can format
87
- * it its own way (CLI table, MCP JSON envelope, …).
88
- */
89
- run: (client: AdminClient, input: OpInput) => Promise<O>;
90
- }
91
- /**
92
- * Structural subset of commander's `Command`. The CLI adapter targets this so
93
- * `@shipeasy/openapi` never has to depend on `commander` — commander's real
94
- * `Command` satisfies it.
95
- */
96
- interface CommandLike {
97
- command(nameAndArgs: string): CommandLike;
98
- description(text: string): CommandLike;
99
- option(flags: string, description?: string, defaultValue?: unknown): CommandLike;
100
- action(fn: (...args: unknown[]) => void | Promise<void>): CommandLike;
101
- }
102
- /** Everything the CLI surface injects so the adapter stays free of process/chalk/IO. */
103
- interface CliContext {
104
- /** Resolve the typed admin client; `mutates` triggers the `requireBinding` guard. */
105
- getClient: (o: {
106
- mutates: boolean;
107
- projectOverride?: string;
108
- }) => AdminClient;
109
- /** Print machine output (`--json`). */
110
- printJson: (data: unknown) => void;
111
- /** Print human output for a successful op (table / one-liner). */
112
- printResult: (op: Operation, data: unknown, input: OpInput) => void;
113
- /** Terminal error handler (prints + exits). */
114
- onError: (e: unknown) => void;
115
- }
116
- type Named = Pick<Operation, "group" | "name">;
117
- /** Stable id, e.g. `release.flags.create`. */
118
- declare const opId: (op: Named) => string;
119
- /** MCP tool name, e.g. `release_flags_create` — the CLI path with `_` for each space. */
120
- declare const opMcpName: (op: Named) => string;
121
- /** CLI invocation, e.g. `release flags create` (full command path). */
122
- declare const opCli: (op: Named) => string;
123
- /** Plain MCP `Tool` shape — structurally compatible with `@modelcontextprotocol/sdk`'s `Tool`. */
124
- interface McpTool {
125
- name: string;
126
- description: string;
127
- inputSchema: {
128
- type: "object";
129
- required?: string[];
130
- properties: Record<string, {
131
- type: string;
132
- description?: string;
133
- enum?: string[];
134
- }>;
135
- };
136
- }
137
-
138
- export { type CliContext, type CommandLike, type McpTool, type OpExample, type OpInput, type Operation, type Param, type ParamType, opCli, opId, opMcpName };
@@ -1,9 +0,0 @@
1
- // src/operations/types.ts
2
- var opId = (op) => [...op.group, op.name].join(".");
3
- var opMcpName = (op) => [...op.group, op.name].join("_");
4
- var opCli = (op) => [...op.group, op.name].join(" ");
5
- export {
6
- opCli,
7
- opId,
8
- opMcpName
9
- };
@@ -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 universeOperations: Operation[];
27
-
28
- export { universeOperations };
@@ -1,93 +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/util.ts
12
- var str = (i, k) => i[k] === void 0 ? void 0 : i[k];
13
-
14
- // src/operations/universes.ts
15
- var GROUP = ["release", "experiments", "universes"];
16
- function parseHoldout(raw) {
17
- if (raw === void 0 || raw === "" || raw === "null") return null;
18
- const [lo, hi] = raw.split(",").map((s) => Number(s.trim()));
19
- if (!Number.isFinite(lo) || !Number.isFinite(hi)) {
20
- throw new ApiError("holdout must be 'lo,hi' integers in [0,9999]", 400);
21
- }
22
- return [lo, hi];
23
- }
24
- var universeOperations = [
25
- {
26
- group: GROUP,
27
- name: "list",
28
- mutates: false,
29
- summary: "List universes",
30
- description: "Return every experiment universe (allocation %, holdout %).",
31
- params: [],
32
- examples: [{ run: "shipeasy release experiments universes list" }],
33
- run: (client) => client.universes.listAll()
34
- },
35
- {
36
- group: GROUP,
37
- name: "create",
38
- mutates: true,
39
- summary: "Create a universe",
40
- description: "Create an experiment universe (container + optional holdout).",
41
- params: [
42
- { name: "name", type: "string", description: "Universe name.", required: true, positional: true },
43
- { name: "unitType", type: "string", description: "Unit type (e.g. user_id, account_id). Defaults to user_id." },
44
- { name: "holdout", type: "string", description: "Holdout range as 'lo,hi' (0\u20139999); omit for no holdout." }
45
- ],
46
- examples: [
47
- { note: "Default user_id unit, no holdout", run: "shipeasy release experiments universes create web" },
48
- { note: "Holdout 0\u2013999, keyed on account_id", run: "shipeasy release experiments universes create web --unit-type account_id --holdout 0,999" }
49
- ],
50
- run: (client, i) => client.universes.create({
51
- name: i.name,
52
- unit_type: str(i, "unitType") ?? "user_id",
53
- holdout_range: parseHoldout(str(i, "holdout"))
54
- })
55
- },
56
- {
57
- group: GROUP,
58
- name: "update",
59
- mutates: true,
60
- summary: "Update a universe's holdout range",
61
- description: "Update the holdout range. Pass 'null' to clear the holdout.",
62
- params: [
63
- { name: "name", type: "string", description: "Universe name.", required: true, positional: true },
64
- { name: "holdout", type: "string", description: "Holdout range as 'lo,hi' (0\u20139999), or 'null' to clear." }
65
- ],
66
- examples: [
67
- { note: "Set a 5% holdout", run: "shipeasy release experiments universes update web --holdout 0,499" },
68
- { note: "Clear the holdout", run: "shipeasy release experiments universes update web --holdout null" }
69
- ],
70
- run: async (client, i) => {
71
- const x = await client.universes.resolve(i.name);
72
- const patch = i.holdout === void 0 ? {} : { holdout_range: parseHoldout(str(i, "holdout")) };
73
- return client.universes.update(x.id, patch);
74
- }
75
- },
76
- {
77
- group: GROUP,
78
- name: "archive",
79
- mutates: true,
80
- summary: "Archive a universe",
81
- description: "Archive (soft-delete) a universe by name.",
82
- params: [{ name: "name", type: "string", description: "Universe name.", required: true, positional: true }],
83
- examples: [{ run: "shipeasy release experiments universes archive web" }],
84
- run: async (client, i) => {
85
- const x = await client.universes.resolve(i.name);
86
- await client.universes.delete(x.id);
87
- return { ok: true, archived: i.name };
88
- }
89
- }
90
- ];
91
- export {
92
- universeOperations
93
- };
@@ -1,33 +0,0 @@
1
- import { 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
- /** Read a coerced number param (already `Number()`-ed by the framework), or undefined. */
27
- declare const num: (i: OpInput, k: string) => number | undefined;
28
- /** Read a string param, or undefined. */
29
- declare const str: (i: OpInput, k: string) => string | undefined;
30
- /** Read a boolean param, or undefined. */
31
- declare const bool: (i: OpInput, k: string) => boolean | undefined;
32
-
33
- export { bool, num, str };
@@ -1,9 +0,0 @@
1
- // src/operations/util.ts
2
- var num = (i, k) => i[k] === void 0 ? void 0 : i[k];
3
- var str = (i, k) => i[k] === void 0 ? void 0 : i[k];
4
- var bool = (i, k) => i[k] === void 0 ? void 0 : i[k];
5
- export {
6
- bool,
7
- num,
8
- str
9
- };
@@ -1,50 +0,0 @@
1
- import { z } from 'zod';
2
- import { NotificationTarget, alertRuleCreateSchema, alertRuleUpdateSchema } from '../schemas/alert-rules.js';
3
- import { Transport } from '../transport.js';
4
-
5
- type AlertRuleCreateInput = z.input<typeof alertRuleCreateSchema>;
6
- type AlertRuleUpdateInput = z.input<typeof alertRuleUpdateSchema>;
7
- /**
8
- * One metric-threshold alert rule. The cron evaluates `agg(metric)` over the
9
- * trailing `windowHours` and raises an alert at `severity` when the value
10
- * `comparator` `threshold` holds.
11
- *
12
- * `metricId` is fixed at create time — there is no update path for it (the
13
- * metric also pins the aggregation). Tune `threshold`/`comparator`/
14
- * `windowHours`/`severity`/`name`/`enabled` instead, or delete + recreate to
15
- * repoint the rule at a different metric.
16
- */
17
- interface AlertRule {
18
- id: string;
19
- name: string;
20
- metricId: string;
21
- metricName: string | null;
22
- comparator: "gt" | "gte" | "lt" | "lte";
23
- threshold: number;
24
- windowHours: number;
25
- severity: "danger" | "warn" | "info";
26
- enabled: boolean;
27
- /** Delivery target for this rule's alert; null = use project default. */
28
- notify: NotificationTarget | null;
29
- createdAt: string;
30
- updatedAt: string;
31
- }
32
- interface AlertRulesClient {
33
- /** All alert rules for the bound project (the list endpoint is not paginated). */
34
- list(): Promise<AlertRule[]>;
35
- /** Resolve a rule by exact id, unique id-prefix, or exact (unique) name. */
36
- resolve(idOrName: string): Promise<AlertRule>;
37
- create(input: AlertRuleCreateInput): Promise<{
38
- id: string;
39
- }>;
40
- /** Patch tunable knobs. `metricId` is rejected by the schema (immutable). */
41
- update(id: string, input: AlertRuleUpdateInput): Promise<{
42
- id: string;
43
- }>;
44
- delete(id: string): Promise<{
45
- ok: true;
46
- }>;
47
- }
48
- declare function alertRulesClient(t: Transport): AlertRulesClient;
49
-
50
- export { type AlertRule, type AlertRuleCreateInput, type AlertRuleUpdateInput, type AlertRulesClient, alertRulesClient };
@@ -1,75 +0,0 @@
1
- // src/schemas/alert-rules.ts
2
- import { z } from "zod";
3
- var ALERT_COMPARATORS = ["gt", "gte", "lt", "lte"];
4
- var ALERT_SEVERITIES = ["danger", "warn", "info"];
5
- var notificationTargetSchema = z.object({
6
- slackChannel: z.object({
7
- id: z.string().min(1).describe("Slack channel id (e.g. C0123ABCD)."),
8
- name: z.string().min(1).describe("Slack channel name (without the leading #).")
9
- }).nullish().describe("Slack channel to post this rule's alert to. Requires a Slack connector."),
10
- email: z.string().email().nullish().describe("Email address to notify for this rule (overrides the default recipient).")
11
- }).strict();
12
- var alertRuleCreateSchema = z.object({
13
- name: z.string().min(1).max(120).describe("Human label for the rule, shown on the alert and the rules list."),
14
- metricId: z.string().min(1).describe("Id of the metric to evaluate."),
15
- comparator: z.enum(ALERT_COMPARATORS).describe("How the metric value is compared to the threshold (gt/gte/lt/lte)."),
16
- threshold: z.number().finite().describe("Threshold the metric value is compared against."),
17
- windowHours: z.number().int().min(1).max(720).default(24).describe("Lookback window (hours) the metric is aggregated over. 1\u2013720."),
18
- severity: z.enum(ALERT_SEVERITIES).default("warn").describe("Severity of the raised alert."),
19
- enabled: z.boolean().default(true).describe("Whether the rule is evaluated by the cron."),
20
- notify: notificationTargetSchema.nullish().describe("Where to deliver this rule's alert (Slack channel and/or email target).")
21
- }).strict();
22
- var alertRuleUpdateSchema = z.object({
23
- name: z.string().min(1).max(120),
24
- comparator: z.enum(ALERT_COMPARATORS),
25
- threshold: z.number().finite(),
26
- windowHours: z.number().int().min(1).max(720),
27
- severity: z.enum(ALERT_SEVERITIES),
28
- enabled: z.boolean(),
29
- notify: notificationTargetSchema.nullish()
30
- }).partial().strict();
31
-
32
- // src/transport.ts
33
- var ApiError = class extends Error {
34
- constructor(message, status) {
35
- super(message);
36
- this.status = status;
37
- this.name = "ApiError";
38
- }
39
- status;
40
- };
41
-
42
- // src/resources/alert-rules.ts
43
- var BASE = "/api/admin/alert-rules";
44
- function alertRulesClient(t) {
45
- async function list() {
46
- return t.request("GET", BASE);
47
- }
48
- async function resolve(idOrName) {
49
- const all = await list();
50
- const byId = all.find((r) => r.id === idOrName);
51
- if (byId) return byId;
52
- const byPrefix = all.filter((r) => r.id.startsWith(idOrName));
53
- if (byPrefix.length === 1) return byPrefix[0];
54
- if (byPrefix.length > 1)
55
- throw new ApiError(`Alert rule id prefix '${idOrName}' is ambiguous`, 400);
56
- const byName = all.filter((r) => r.name === idOrName);
57
- if (byName.length === 1) return byName[0];
58
- if (byName.length > 1)
59
- throw new ApiError(
60
- `Alert rule name '${idOrName}' is ambiguous \u2014 pass an id instead`,
61
- 400
62
- );
63
- throw new ApiError(`Alert rule '${idOrName}' not found`, 404);
64
- }
65
- return {
66
- list,
67
- resolve,
68
- create: (input) => t.request("POST", BASE, alertRuleCreateSchema.parse(input)),
69
- update: (id, input) => t.request("PATCH", `${BASE}/${id}`, alertRuleUpdateSchema.parse(input)),
70
- delete: (id) => t.request("DELETE", `${BASE}/${id}`)
71
- };
72
- }
73
- export {
74
- alertRulesClient
75
- };
@@ -1,19 +0,0 @@
1
- import { Transport } from '../transport.js';
2
-
3
- /**
4
- * Targeting attributes — the auto-inferred user-attribute schema the dashboard
5
- * surfaces for gate/experiment targeting. Read-only; this exists so the typed
6
- * `attributes list` op can replace the `attributes` kind of the old MCP-only
7
- * "generic read" (`list_resources`), which is being deleted (see doc 21 §A4.3).
8
- */
9
- interface Attribute {
10
- name: string;
11
- type?: string;
12
- [key: string]: unknown;
13
- }
14
- interface AttributesClient {
15
- list(): Promise<Attribute[]>;
16
- }
17
- declare function attributesClient(t: Transport): AttributesClient;
18
-
19
- export { type Attribute, type AttributesClient, attributesClient };
@@ -1,10 +0,0 @@
1
- // src/resources/attributes.ts
2
- var BASE = "/api/admin/attributes";
3
- function attributesClient(t) {
4
- return {
5
- list: () => t.request("GET", BASE)
6
- };
7
- }
8
- export {
9
- attributesClient
10
- };