@shipeasy/openapi 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/index.d.ts +9 -7
  2. package/dist/index.js +504 -2672
  3. package/dist/resources/alert-rules.d.ts +48 -0
  4. package/dist/resources/alert-rules.js +66 -0
  5. package/dist/resources/configs.d.ts +6 -2
  6. package/dist/resources/configs.js +67 -2375
  7. package/dist/resources/experiments.d.ts +100 -2
  8. package/dist/resources/experiments.js +158 -105
  9. package/dist/resources/gates.d.ts +51 -8
  10. package/dist/resources/gates.js +102 -70
  11. package/dist/resources/index.d.ts +166 -10
  12. package/dist/resources/index.js +503 -2671
  13. package/dist/resources/killswitches.d.ts +6 -2
  14. package/dist/resources/killswitches.js +113 -2412
  15. package/dist/resources/universes.d.ts +7 -4
  16. package/dist/resources/universes.js +30 -20
  17. package/dist/schemas/alert-rules.d.ts +43 -0
  18. package/dist/schemas/alert-rules.js +27 -0
  19. package/dist/schemas/configs.d.ts +154 -0
  20. package/dist/schemas/configs.js +134 -0
  21. package/dist/schemas/constants.d.ts +6 -0
  22. package/dist/schemas/constants.js +7 -0
  23. package/dist/schemas/experiments.d.ts +245 -0
  24. package/dist/schemas/experiments.js +216 -0
  25. package/dist/schemas/folder.d.ts +10 -0
  26. package/dist/schemas/folder.js +8 -0
  27. package/dist/schemas/gates.d.ts +304 -0
  28. package/dist/schemas/gates.js +172 -0
  29. package/dist/schemas/index.d.ts +11 -0
  30. package/dist/schemas/index.js +729 -0
  31. package/dist/schemas/killswitches.d.ts +110 -0
  32. package/dist/schemas/killswitches.js +226 -0
  33. package/dist/schemas/metric-name.d.ts +5 -0
  34. package/dist/schemas/metric-name.js +6 -0
  35. package/dist/schemas/pagination.d.ts +37 -0
  36. package/dist/schemas/pagination.js +44 -0
  37. package/dist/schemas/universes.d.ts +35 -0
  38. package/dist/schemas/universes.js +55 -0
  39. package/openapi.json +1257 -228
  40. package/package.json +13 -10
@@ -0,0 +1,48 @@
1
+ import { z } from 'zod';
2
+ import { 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
+ createdAt: string;
28
+ updatedAt: string;
29
+ }
30
+ interface AlertRulesClient {
31
+ /** All alert rules for the bound project (the list endpoint is not paginated). */
32
+ list(): Promise<AlertRule[]>;
33
+ /** Resolve a rule by exact id, unique id-prefix, or exact (unique) name. */
34
+ resolve(idOrName: string): Promise<AlertRule>;
35
+ create(input: AlertRuleCreateInput): Promise<{
36
+ id: string;
37
+ }>;
38
+ /** Patch tunable knobs. `metricId` is rejected by the schema (immutable). */
39
+ update(id: string, input: AlertRuleUpdateInput): Promise<{
40
+ id: string;
41
+ }>;
42
+ delete(id: string): Promise<{
43
+ ok: true;
44
+ }>;
45
+ }
46
+ declare function alertRulesClient(t: Transport): AlertRulesClient;
47
+
48
+ export { type AlertRule, type AlertRuleCreateInput, type AlertRuleUpdateInput, type AlertRulesClient, alertRulesClient };
@@ -0,0 +1,66 @@
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 alertRuleCreateSchema = z.object({
6
+ name: z.string().min(1).max(120).describe("Human label for the rule, shown on the alert and the rules list."),
7
+ metricId: z.string().min(1).describe("Id of the metric to evaluate."),
8
+ comparator: z.enum(ALERT_COMPARATORS).describe("How the metric value is compared to the threshold (gt/gte/lt/lte)."),
9
+ threshold: z.number().finite().describe("Threshold the metric value is compared against."),
10
+ windowHours: z.number().int().min(1).max(720).default(24).describe("Lookback window (hours) the metric is aggregated over. 1\u2013720."),
11
+ severity: z.enum(ALERT_SEVERITIES).default("warn").describe("Severity of the raised alert."),
12
+ enabled: z.boolean().default(true).describe("Whether the rule is evaluated by the cron.")
13
+ }).strict();
14
+ var alertRuleUpdateSchema = z.object({
15
+ name: z.string().min(1).max(120),
16
+ comparator: z.enum(ALERT_COMPARATORS),
17
+ threshold: z.number().finite(),
18
+ windowHours: z.number().int().min(1).max(720),
19
+ severity: z.enum(ALERT_SEVERITIES),
20
+ enabled: z.boolean()
21
+ }).partial().strict();
22
+
23
+ // src/transport.ts
24
+ var ApiError = class extends Error {
25
+ constructor(message, status) {
26
+ super(message);
27
+ this.status = status;
28
+ this.name = "ApiError";
29
+ }
30
+ status;
31
+ };
32
+
33
+ // src/resources/alert-rules.ts
34
+ var BASE = "/api/admin/alert-rules";
35
+ function alertRulesClient(t) {
36
+ async function list() {
37
+ return t.request("GET", BASE);
38
+ }
39
+ async function resolve(idOrName) {
40
+ const all = await list();
41
+ const byId = all.find((r) => r.id === idOrName);
42
+ if (byId) return byId;
43
+ const byPrefix = all.filter((r) => r.id.startsWith(idOrName));
44
+ if (byPrefix.length === 1) return byPrefix[0];
45
+ if (byPrefix.length > 1)
46
+ throw new ApiError(`Alert rule id prefix '${idOrName}' is ambiguous`, 400);
47
+ const byName = all.filter((r) => r.name === idOrName);
48
+ if (byName.length === 1) return byName[0];
49
+ if (byName.length > 1)
50
+ throw new ApiError(
51
+ `Alert rule name '${idOrName}' is ambiguous \u2014 pass an id instead`,
52
+ 400
53
+ );
54
+ throw new ApiError(`Alert rule '${idOrName}' not found`, 404);
55
+ }
56
+ return {
57
+ list,
58
+ resolve,
59
+ create: (input) => t.request("POST", BASE, alertRuleCreateSchema.parse(input)),
60
+ update: (id, input) => t.request("PATCH", `${BASE}/${id}`, alertRuleUpdateSchema.parse(input)),
61
+ delete: (id) => t.request("DELETE", `${BASE}/${id}`)
62
+ };
63
+ }
64
+ export {
65
+ alertRulesClient
66
+ };
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { configCreateSchema, configUpdateSchema, configDraftUpsertSchema, configPublishSchema } from '@shipeasy/core/schemas/configs';
3
- import { PageQuery, Page } from '@shipeasy/core/pagination';
2
+ import { configCreateSchema, configUpdateSchema, configDraftUpsertSchema, configPublishSchema } from '../schemas/configs.js';
3
+ import { PageQuery, Page } from '../schemas/pagination.js';
4
4
  import { Transport } from '../transport.js';
5
5
 
6
6
  /** Use input types so callers can omit fields the server defaults. */
@@ -57,6 +57,7 @@ declare const configsResource: {
57
57
  readonly create: z.ZodObject<{
58
58
  name: z.ZodString;
59
59
  description: z.ZodOptional<z.ZodString>;
60
+ folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
60
61
  schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
61
62
  value: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnknown, z.ZodRecord<z.ZodEnum<{
62
63
  dev: "dev";
@@ -67,6 +68,7 @@ declare const configsResource: {
67
68
  readonly update: z.ZodObject<{
68
69
  schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
69
70
  value: z.ZodOptional<z.ZodUnknown>;
71
+ folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
70
72
  }, z.core.$strip>;
71
73
  readonly saveDraft: z.ZodObject<{
72
74
  env: z.ZodEnum<{
@@ -319,6 +321,7 @@ declare const configsResource: {
319
321
  readonly request: z.ZodObject<{
320
322
  name: z.ZodString;
321
323
  description: z.ZodOptional<z.ZodString>;
324
+ folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
322
325
  schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
323
326
  value: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnknown, z.ZodRecord<z.ZodEnum<{
324
327
  dev: "dev";
@@ -432,6 +435,7 @@ declare const configsResource: {
432
435
  readonly request: z.ZodObject<{
433
436
  schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
434
437
  value: z.ZodOptional<z.ZodUnknown>;
438
+ folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
435
439
  }, z.core.$strip>;
436
440
  readonly response: z.ZodObject<{
437
441
  id: z.ZodString;