@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.
- package/README.md +37 -0
- package/dist/chunk-EPLLHLZN.js +1616 -0
- package/dist/chunk-EPLLHLZN.js.map +1 -0
- package/dist/chunk-SPH5HWCD.js +3326 -0
- package/dist/chunk-SPH5HWCD.js.map +1 -0
- package/dist/client-pVkoo3Bf.d.ts +11186 -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 +64 -0
- package/dist/custom.js +292 -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 +7920 -0
- package/dist/schemas.js +1083 -0
- package/dist/schemas.js.map +1 -0
- package/openapi.json +15297 -3044
- package/openapi.yaml +13979 -0
- package/package.json +33 -26
- package/spec/components/errors.yaml +53 -0
- package/spec/components/parameters.yaml +24 -0
- package/spec/components/responses.yaml +107 -0
- package/spec/components/schemas/alert-rules.yaml +175 -0
- package/spec/components/schemas/attributes.yaml +157 -0
- package/spec/components/schemas/common.yaml +87 -0
- package/spec/components/schemas/configs.yaml +371 -0
- package/spec/components/schemas/connectors.yaml +593 -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 +198 -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 +1011 -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 +348 -0
- package/spec/paths/alert-rules.yaml +250 -0
- package/spec/paths/attributes.yaml +261 -0
- package/spec/paths/configs.yaml +744 -0
- package/spec/paths/connectors.yaml +748 -0
- package/spec/paths/errors.yaml +382 -0
- package/spec/paths/events.yaml +366 -0
- package/spec/paths/experiments.yaml +777 -0
- package/spec/paths/gate-templates.yaml +263 -0
- package/spec/paths/gates.yaml +451 -0
- package/spec/paths/i18n.yaml +544 -0
- package/spec/paths/keys.yaml +181 -0
- package/spec/paths/killswitches.yaml +557 -0
- package/spec/paths/metrics.yaml +302 -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 +247 -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,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 killswitchOperations: Operation[];
|
|
27
|
-
|
|
28
|
-
export { killswitchOperations };
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// src/operations/util.ts
|
|
2
|
-
var str = (i, k) => i[k] === void 0 ? void 0 : i[k];
|
|
3
|
-
var bool = (i, k) => i[k] === void 0 ? void 0 : i[k];
|
|
4
|
-
|
|
5
|
-
// src/operations/killswitches.ts
|
|
6
|
-
var GROUP = ["release", "killswitch"];
|
|
7
|
-
var ENVS = ["dev", "staging", "prod"];
|
|
8
|
-
var killswitchOperations = [
|
|
9
|
-
{
|
|
10
|
-
group: GROUP,
|
|
11
|
-
name: "list",
|
|
12
|
-
mutates: false,
|
|
13
|
-
summary: "List all kill switches",
|
|
14
|
-
description: "Return every kill switch with its per-env default value and switch count.",
|
|
15
|
-
params: [],
|
|
16
|
-
examples: [{ run: "shipeasy release killswitch list" }],
|
|
17
|
-
run: (client) => client.killswitches.listAll()
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
group: GROUP,
|
|
21
|
-
name: "create",
|
|
22
|
-
mutates: true,
|
|
23
|
-
summary: "Create a kill switch",
|
|
24
|
-
description: "Create a kill switch (a static `{ value, switches }` config shipped in the flags KV blob). Name must be `folder.name`. Switches take precedence over `value` for that switch_key.",
|
|
25
|
-
params: [
|
|
26
|
-
{ name: "name", type: "string", description: "`folder.name` \u2014 two lowercase segments.", required: true, positional: true },
|
|
27
|
-
{ name: "description", type: "string", description: "Optional description." },
|
|
28
|
-
{ name: "value", type: "boolean", description: "Default value (true|false). Defaults to false." },
|
|
29
|
-
{ name: "switches", type: "json", description: "JSON object of { switch_key: bool }; takes precedence over value." }
|
|
30
|
-
],
|
|
31
|
-
examples: [
|
|
32
|
-
{ note: "Default OFF", run: "shipeasy release killswitch create payments.stripe-gateway" },
|
|
33
|
-
{ note: "Pre-seed per-key switches", run: `shipeasy release killswitch create payments.stripe-gateway --switches '{"refunds":true,"payouts":false}'` }
|
|
34
|
-
],
|
|
35
|
-
run: (client, i) => client.killswitches.create({
|
|
36
|
-
name: i.name,
|
|
37
|
-
description: str(i, "description"),
|
|
38
|
-
value: bool(i, "value") ?? false,
|
|
39
|
-
switches: i.switches
|
|
40
|
-
})
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
group: GROUP,
|
|
44
|
-
name: "update",
|
|
45
|
-
mutates: true,
|
|
46
|
-
summary: "Update a kill switch's default value, switches map, or description",
|
|
47
|
-
description: "Patch a kill switch. `switches` replaces the map wholesale; pass an empty description to clear it.",
|
|
48
|
-
params: [
|
|
49
|
-
{ name: "name", type: "string", description: "Kill switch name.", required: true, positional: true },
|
|
50
|
-
{ name: "value", type: "boolean", description: "Default value (true|false)." },
|
|
51
|
-
{ name: "switches", type: "json", description: "JSON { switch_key: bool } \u2014 replaces wholesale." },
|
|
52
|
-
{ name: "description", type: "string", description: "Description (empty string clears it)." }
|
|
53
|
-
],
|
|
54
|
-
examples: [{ note: "Flip the default ON", run: "shipeasy release killswitch update payments.stripe-gateway --value true" }],
|
|
55
|
-
run: async (client, i) => {
|
|
56
|
-
const k = await client.killswitches.resolve(i.name);
|
|
57
|
-
const patch = {};
|
|
58
|
-
if (i.value !== void 0) patch.value = i.value;
|
|
59
|
-
if (i.switches !== void 0) patch.switches = i.switches;
|
|
60
|
-
if (i.description !== void 0) patch.description = i.description === "" ? null : i.description;
|
|
61
|
-
return client.killswitches.update(k.id, patch);
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
group: GROUP,
|
|
66
|
-
name: "set",
|
|
67
|
-
mutates: true,
|
|
68
|
-
summary: "Set one switch entry on one env",
|
|
69
|
-
description: "Set or update a single named switch on one environment (default `prod`), leaving the rest untouched.",
|
|
70
|
-
params: [
|
|
71
|
-
{ name: "name", type: "string", description: "Kill switch name.", required: true, positional: true },
|
|
72
|
-
{ name: "switchKey", type: "string", description: "Switch key to set.", required: true, positional: true },
|
|
73
|
-
{ name: "value", type: "boolean", description: "true|false.", required: true, positional: true },
|
|
74
|
-
{ name: "env", type: "string", description: `Env: ${ENVS.join(" | ")} (default prod).`, enum: ENVS }
|
|
75
|
-
],
|
|
76
|
-
examples: [
|
|
77
|
-
{ note: "Kill refunds in prod", run: "shipeasy release killswitch set payments.stripe-gateway refunds true" },
|
|
78
|
-
{ note: "Target staging instead", run: "shipeasy release killswitch set payments.stripe-gateway refunds true --env staging" }
|
|
79
|
-
],
|
|
80
|
-
run: async (client, i) => {
|
|
81
|
-
const k = await client.killswitches.resolve(i.name);
|
|
82
|
-
return client.killswitches.setSwitch(k.id, {
|
|
83
|
-
env: str(i, "env") ?? "prod",
|
|
84
|
-
switchKey: i.switchKey,
|
|
85
|
-
value: i.value
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
group: GROUP,
|
|
91
|
-
name: "unset",
|
|
92
|
-
mutates: true,
|
|
93
|
-
summary: "Remove one switch entry from one env",
|
|
94
|
-
description: "Remove a single named switch from one environment (default `prod`), reverting it to the default.",
|
|
95
|
-
params: [
|
|
96
|
-
{ name: "name", type: "string", description: "Kill switch name.", required: true, positional: true },
|
|
97
|
-
{ name: "switchKey", type: "string", description: "Switch key to remove.", required: true, positional: true },
|
|
98
|
-
{ name: "env", type: "string", description: `Env: ${ENVS.join(" | ")} (default prod).`, enum: ENVS }
|
|
99
|
-
],
|
|
100
|
-
examples: [{ run: "shipeasy release killswitch unset payments.stripe-gateway refunds" }],
|
|
101
|
-
run: async (client, i) => {
|
|
102
|
-
const k = await client.killswitches.resolve(i.name);
|
|
103
|
-
return client.killswitches.unsetSwitch(k.id, {
|
|
104
|
-
env: str(i, "env") ?? "prod",
|
|
105
|
-
switchKey: i.switchKey
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
group: GROUP,
|
|
111
|
-
name: "archive",
|
|
112
|
-
mutates: true,
|
|
113
|
-
summary: "Archive a kill switch",
|
|
114
|
-
description: "Archive (soft-delete) a kill switch by name.",
|
|
115
|
-
params: [{ name: "name", type: "string", description: "Kill switch name.", required: true, positional: true }],
|
|
116
|
-
examples: [{ run: "shipeasy release killswitch archive payments.stripe-gateway" }],
|
|
117
|
-
run: async (client, i) => {
|
|
118
|
-
const k = await client.killswitches.resolve(i.name);
|
|
119
|
-
await client.killswitches.delete(k.id);
|
|
120
|
-
return { ok: true, archived: i.name };
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
];
|
|
124
|
-
export {
|
|
125
|
-
killswitchOperations
|
|
126
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { AdminClient } from '../resources/index.js';
|
|
2
|
-
import { Operation, McpTool } from './types.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
|
-
/** Project the registry onto the MCP `tools/list` catalog — one tool per operation. */
|
|
27
|
-
declare function operationsToMcpTools(ops: Operation[]): McpTool[];
|
|
28
|
-
/**
|
|
29
|
-
* Build the `tools/call` dispatch map keyed by MCP tool name. Each entry
|
|
30
|
-
* coerces the raw `arguments` and runs the op against the admin client —
|
|
31
|
-
* replacing the hand-written 60-branch if/else in `mcp/src/server.ts`.
|
|
32
|
-
*/
|
|
33
|
-
declare function operationsToDispatch(ops: Operation[]): Record<string, (client: AdminClient, args: Record<string, unknown>) => Promise<unknown>>;
|
|
34
|
-
|
|
35
|
-
export { operationsToDispatch, operationsToMcpTools };
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// src/transport.ts
|
|
2
|
-
var ApiError = class extends Error {
|
|
3
|
-
constructor(message, status) {
|
|
4
|
-
super(message);
|
|
5
|
-
this.status = status;
|
|
6
|
-
this.name = "ApiError";
|
|
7
|
-
}
|
|
8
|
-
status;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// src/operations/coerce.ts
|
|
12
|
-
function coerceValue(param, raw) {
|
|
13
|
-
if (raw === void 0 || raw === null) return void 0;
|
|
14
|
-
switch (param.type) {
|
|
15
|
-
case "number": {
|
|
16
|
-
const n = typeof raw === "number" ? raw : Number(raw);
|
|
17
|
-
if (!Number.isFinite(n)) throw new ApiError(`--${param.name} must be a number`, 400);
|
|
18
|
-
return n;
|
|
19
|
-
}
|
|
20
|
-
case "boolean":
|
|
21
|
-
return raw === true || raw === "true" || raw === "1";
|
|
22
|
-
case "json":
|
|
23
|
-
if (typeof raw !== "string") return raw;
|
|
24
|
-
try {
|
|
25
|
-
return JSON.parse(raw);
|
|
26
|
-
} catch {
|
|
27
|
-
throw new ApiError(`--${param.name} must be valid JSON`, 400);
|
|
28
|
-
}
|
|
29
|
-
case "string":
|
|
30
|
-
default: {
|
|
31
|
-
const s = String(raw);
|
|
32
|
-
if (param.enum && !param.enum.includes(s)) {
|
|
33
|
-
throw new ApiError(`--${param.name} must be one of: ${param.enum.join(", ")}`, 400);
|
|
34
|
-
}
|
|
35
|
-
return s;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function coerceInput(op, raw) {
|
|
40
|
-
const out = {};
|
|
41
|
-
for (const param of op.params) {
|
|
42
|
-
const value = coerceValue(param, raw[param.name]);
|
|
43
|
-
if (value === void 0) {
|
|
44
|
-
if (param.required) throw new ApiError(`${param.name} is required`, 400);
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
out[param.name] = value;
|
|
48
|
-
}
|
|
49
|
-
return out;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/operations/types.ts
|
|
53
|
-
var opMcpName = (op) => [...op.group, op.name].join("_");
|
|
54
|
-
|
|
55
|
-
// src/operations/mcp-adapter.ts
|
|
56
|
-
function jsonType(t) {
|
|
57
|
-
switch (t) {
|
|
58
|
-
case "number":
|
|
59
|
-
return "number";
|
|
60
|
-
case "boolean":
|
|
61
|
-
return "boolean";
|
|
62
|
-
case "json":
|
|
63
|
-
case "string":
|
|
64
|
-
default:
|
|
65
|
-
return "string";
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function operationsToMcpTools(ops) {
|
|
69
|
-
return ops.map((op) => {
|
|
70
|
-
const properties = {};
|
|
71
|
-
const required = [];
|
|
72
|
-
for (const p of op.params) {
|
|
73
|
-
properties[p.name] = { type: jsonType(p.type), description: p.description };
|
|
74
|
-
if (p.enum) properties[p.name].enum = p.enum;
|
|
75
|
-
if (p.required) required.push(p.name);
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
name: opMcpName(op),
|
|
79
|
-
description: op.description,
|
|
80
|
-
inputSchema: { type: "object", ...required.length ? { required } : {}, properties }
|
|
81
|
-
};
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
function operationsToDispatch(ops) {
|
|
85
|
-
const map = {};
|
|
86
|
-
for (const op of ops) {
|
|
87
|
-
map[opMcpName(op)] = async (client, args) => op.run(client, coerceInput(op, args ?? {}));
|
|
88
|
-
}
|
|
89
|
-
return map;
|
|
90
|
-
}
|
|
91
|
-
export {
|
|
92
|
-
operationsToDispatch,
|
|
93
|
-
operationsToMcpTools
|
|
94
|
-
};
|
|
@@ -1,30 +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
|
-
/** The metric query DSL grammar — the single source for `metrics grammar` on every surface. */
|
|
27
|
-
declare const METRIC_GRAMMAR = "Shipeasy metric query DSL\n=========================\n\nQuery := AggFunc \"(\" Selector (\",\" Identifier)? \")\" GroupBy?\nAggFunc := count_users | count | sum | avg | min | max | unique |\n p50 | p75 | p90 | p95 | p99 | p999 |\n retention_<N>d (N in 1..90)\nSelector := Identifier (\"{\" Filter (\",\" Filter)* \",\"? \"}\")?\nFilter := Identifier MatchOp StringLiteral\nMatchOp := \"=\" | \"!=\" | \"=~\" | \"!~\"\nStringLiteral := double-quoted, supports \\\" and \\\\\nGroupBy := (\"by\" | \"without\") \"(\" Identifier (\",\" Identifier)* \",\"? \")\"\n\nExamples\n--------\n count_users(checkout_completed)\n sum(purchase{country=\"US\"}, amount)\n p99(req_dur{route=~\"/api/.*\"}, ms) by (route, status)\n retention_7d(session_start)\n avg(req_dur{tier!=\"free\"}, ms) without (region)\n\nNotes\n-----\n- One event selector per query (no formulas).\n- \"count\" maps to count_events (per-row count); \"count_users\" is uniq-by-user.\n- For experiments, \"by (label)\" is ignored \u2014 per-user reducer is applied.\n- Filter values must be quoted strings, even for numeric labels (they are coerced).\n- Filter labels and value labels must be declared on the source event.\n";
|
|
28
|
-
declare const metricOperations: Operation[];
|
|
29
|
-
|
|
30
|
-
export { METRIC_GRAMMAR, metricOperations };
|
|
@@ -1,114 +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
|
-
|
|
5
|
-
// src/operations/metrics.ts
|
|
6
|
-
var GROUP = ["metrics"];
|
|
7
|
-
var METRIC_GRAMMAR = `Shipeasy metric query DSL
|
|
8
|
-
=========================
|
|
9
|
-
|
|
10
|
-
Query := AggFunc "(" Selector ("," Identifier)? ")" GroupBy?
|
|
11
|
-
AggFunc := count_users | count | sum | avg | min | max | unique |
|
|
12
|
-
p50 | p75 | p90 | p95 | p99 | p999 |
|
|
13
|
-
retention_<N>d (N in 1..90)
|
|
14
|
-
Selector := Identifier ("{" Filter ("," Filter)* ","? "}")?
|
|
15
|
-
Filter := Identifier MatchOp StringLiteral
|
|
16
|
-
MatchOp := "=" | "!=" | "=~" | "!~"
|
|
17
|
-
StringLiteral := double-quoted, supports \\" and \\\\
|
|
18
|
-
GroupBy := ("by" | "without") "(" Identifier ("," Identifier)* ","? ")"
|
|
19
|
-
|
|
20
|
-
Examples
|
|
21
|
-
--------
|
|
22
|
-
count_users(checkout_completed)
|
|
23
|
-
sum(purchase{country="US"}, amount)
|
|
24
|
-
p99(req_dur{route=~"/api/.*"}, ms) by (route, status)
|
|
25
|
-
retention_7d(session_start)
|
|
26
|
-
avg(req_dur{tier!="free"}, ms) without (region)
|
|
27
|
-
|
|
28
|
-
Notes
|
|
29
|
-
-----
|
|
30
|
-
- One event selector per query (no formulas).
|
|
31
|
-
- "count" maps to count_events (per-row count); "count_users" is uniq-by-user.
|
|
32
|
-
- For experiments, "by (label)" is ignored \u2014 per-user reducer is applied.
|
|
33
|
-
- Filter values must be quoted strings, even for numeric labels (they are coerced).
|
|
34
|
-
- Filter labels and value labels must be declared on the source event.
|
|
35
|
-
`;
|
|
36
|
-
var metricOperations = [
|
|
37
|
-
{
|
|
38
|
-
group: GROUP,
|
|
39
|
-
name: "grammar",
|
|
40
|
-
mutates: false,
|
|
41
|
-
summary: "Print the metric query DSL grammar",
|
|
42
|
-
description: "Return the full metric query DSL grammar \u2014 aggregation functions, event selectors, label filters, and group-by. A pure op: it ignores the client and never hits the API.",
|
|
43
|
-
params: [],
|
|
44
|
-
examples: [{ run: "shipeasy metrics grammar" }],
|
|
45
|
-
run: async () => ({ grammar: METRIC_GRAMMAR })
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
group: GROUP,
|
|
49
|
-
name: "list",
|
|
50
|
-
mutates: false,
|
|
51
|
-
summary: "List all metrics",
|
|
52
|
-
description: "Return every metric in the project (name, folder, source event, aggregation).",
|
|
53
|
-
params: [],
|
|
54
|
-
examples: [{ run: "shipeasy metrics list" }],
|
|
55
|
-
run: (client) => client.metrics.list()
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
group: GROUP,
|
|
59
|
-
name: "show",
|
|
60
|
-
mutates: false,
|
|
61
|
-
summary: "Show one metric",
|
|
62
|
-
description: "Resolve a metric by id, id-prefix, or name and return its full detail.",
|
|
63
|
-
params: [{ name: "metric", type: "string", description: "Metric id or name.", required: true, positional: true }],
|
|
64
|
-
examples: [{ run: "shipeasy metrics show checkouts" }],
|
|
65
|
-
run: (client, i) => client.metrics.resolve(i.metric)
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
group: GROUP,
|
|
69
|
-
name: "create",
|
|
70
|
-
mutates: true,
|
|
71
|
-
summary: "Create a metric",
|
|
72
|
-
description: "Create an event-backed metric. Pass the query as the DSL string (`query`) or the typed IR form (`queryIr`). `event` must match the event the query references. Run `metrics grammar` for the DSL syntax.",
|
|
73
|
-
params: [
|
|
74
|
-
{ name: "name", type: "string", description: "Metric name.", required: true, positional: true },
|
|
75
|
-
{ name: "event", type: "string", description: "Source event name (must equal the query's event).", required: true },
|
|
76
|
-
{ name: "query", type: "string", description: "Query DSL string, e.g. 'sum(purchase, amount)'." },
|
|
77
|
-
{ name: "queryIr", type: "json", description: "Typed IR JSON (alternative to query)." },
|
|
78
|
-
{ name: "folder", type: "string", description: "Folder to file the metric under." },
|
|
79
|
-
{ name: "winsorize", type: "number", description: "Winsorize percentile (1\u201399). Defaults to 99." },
|
|
80
|
-
{ name: "mde", type: "number", description: "Min detectable effect (0\u20131)." }
|
|
81
|
-
],
|
|
82
|
-
examples: [
|
|
83
|
-
{ note: "Unique users who completed checkout", run: "shipeasy metrics create checkouts --event checkout_completed --query 'count_users(checkout_completed)'" },
|
|
84
|
-
{ note: "p99 latency grouped by route", run: `shipeasy metrics create api-latency --event req_dur --query 'p99(req_dur{route=~"/api/.*"}, ms) by (route)'` }
|
|
85
|
-
],
|
|
86
|
-
run: (client, i) => client.metrics.create({
|
|
87
|
-
name: i.name,
|
|
88
|
-
event_name: i.event,
|
|
89
|
-
folder: str(i, "folder") ?? null,
|
|
90
|
-
winsorize_pct: num(i, "winsorize") ?? 99,
|
|
91
|
-
min_detectable_effect: num(i, "mde") ?? null,
|
|
92
|
-
...i.query ? { query: i.query } : {},
|
|
93
|
-
...i.queryIr ? { query_ir: i.queryIr } : {}
|
|
94
|
-
})
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
group: GROUP,
|
|
98
|
-
name: "archive",
|
|
99
|
-
mutates: true,
|
|
100
|
-
summary: "Archive a metric",
|
|
101
|
-
description: "Archive (soft-delete) a metric by id or name.",
|
|
102
|
-
params: [{ name: "metric", type: "string", description: "Metric id or name.", required: true, positional: true }],
|
|
103
|
-
examples: [{ run: "shipeasy metrics archive checkouts" }],
|
|
104
|
-
run: async (client, i) => {
|
|
105
|
-
const m = await client.metrics.resolve(i.metric);
|
|
106
|
-
await client.metrics.delete(m.id);
|
|
107
|
-
return { ok: true, archived: m.name };
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
];
|
|
111
|
-
export {
|
|
112
|
-
METRIC_GRAMMAR,
|
|
113
|
-
metricOperations
|
|
114
|
-
};
|
package/dist/operations/ops.d.ts
DELETED
|
@@ -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 opsOperations: Operation[];
|
|
27
|
-
|
|
28
|
-
export { opsOperations };
|