@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,88 +0,0 @@
1
- import { Transport } from '../transport.js';
2
-
3
- /**
4
- * Operational queue — the unified feedback table of bug reports, feature
5
- * requests, and auto-filed error/alert tickets, over `/api/admin/feedback`.
6
- * One resource covers list/get/create/update/link-pr plus the `notify`
7
- * escalation bell (`/api/admin/notifications`) and the Slack channel reader
8
- * (`/api/admin/slack/channels`) used to resolve alert-rule targets.
9
- *
10
- * Item handles are either the per-project number (`7`) or the full id; the
11
- * admin API resolves either, so callers pass the handle straight through.
12
- */
13
- type OpsType = "bug" | "feature_request" | "error" | "alert";
14
- type OpsStatus = "open" | "triaged" | "in_progress" | "ready_for_qa" | "resolved" | "wont_fix";
15
- type OpsPriority = "nice_to_have" | "medium" | "high" | "critical";
16
- interface OpsItem {
17
- id: string;
18
- number: number | null;
19
- type: string;
20
- title: string;
21
- status: string;
22
- priority: string | null;
23
- sourceRef?: string | null;
24
- createdAt: string;
25
- [key: string]: unknown;
26
- }
27
- interface OpsListQuery {
28
- type?: OpsType | "all";
29
- status?: OpsStatus | "all";
30
- limit?: number;
31
- }
32
- interface OpsCreateInput {
33
- /** Only `bug` / `feature_request` are user-fileable; error/alert are auto-filed. */
34
- type: "bug" | "feature_request";
35
- title: string;
36
- body?: string;
37
- priority?: OpsPriority;
38
- stepsToReproduce?: string;
39
- pageUrl?: string;
40
- }
41
- interface OpsUpdateInput {
42
- status?: OpsStatus;
43
- priority?: OpsPriority;
44
- }
45
- interface OpsNotifyInput {
46
- title: string;
47
- summary: string;
48
- steps?: string[];
49
- href?: string;
50
- dedupeKey?: string;
51
- }
52
- interface SlackChannel {
53
- id: string;
54
- name: string;
55
- isPrivate?: boolean;
56
- }
57
- interface SlackChannelsResponse {
58
- connected: boolean;
59
- channels: SlackChannel[];
60
- }
61
- interface OpsClient {
62
- list(query?: OpsListQuery): Promise<OpsItem[]>;
63
- get(handle: string): Promise<OpsItem>;
64
- /** File a bug or feature request. Fires project connectors (GitHub/Slack). */
65
- create(input: OpsCreateInput): Promise<{
66
- id: string;
67
- number?: number | null;
68
- }>;
69
- update(handle: string, input: OpsUpdateInput): Promise<{
70
- id: string;
71
- }>;
72
- linkPr(handle: string, input: {
73
- prNumber: number | null;
74
- prUrl?: string;
75
- }): Promise<{
76
- id: string;
77
- }>;
78
- /** Raise a 'needs your attention' bell notification (create-only, idempotent on dedupeKey). */
79
- notify(input: OpsNotifyInput): Promise<{
80
- dedupeKey: string;
81
- dispatched: boolean;
82
- }>;
83
- /** The project's Slack channels — used to resolve alert-rule `--slack-channel`. */
84
- channels(): Promise<SlackChannelsResponse>;
85
- }
86
- declare function opsClient(t: Transport): OpsClient;
87
-
88
- export { type OpsClient, type OpsCreateInput, type OpsItem, type OpsListQuery, type OpsNotifyInput, type OpsPriority, type OpsStatus, type OpsType, type OpsUpdateInput, type SlackChannel, type SlackChannelsResponse, opsClient };
@@ -1,36 +0,0 @@
1
- // src/resources/ops.ts
2
- var FEEDBACK = "/api/admin/feedback";
3
- var NOTIFY = "/api/admin/notifications";
4
- var CREATE_PATH = {
5
- bug: "/api/admin/bugs",
6
- feature_request: "/api/admin/feature-requests"
7
- };
8
- function itemPath(handle) {
9
- return `${FEEDBACK}/${encodeURIComponent(handle)}`;
10
- }
11
- function opsClient(t) {
12
- return {
13
- list: (query = {}) => {
14
- const q = {};
15
- if (query.type) q.type = query.type;
16
- if (query.status) q.status = query.status;
17
- if (query.limit !== void 0) q.limit = String(query.limit);
18
- return t.request("GET", FEEDBACK, void 0, q);
19
- },
20
- get: (handle) => t.request("GET", itemPath(handle)),
21
- create: ({ type, ...body }) => t.request("POST", CREATE_PATH[type], body),
22
- update: (handle, input) => t.request("PATCH", itemPath(handle), input),
23
- linkPr: (handle, input) => t.request("POST", `${itemPath(handle)}/link-pr`, input),
24
- notify: (input) => t.request("POST", NOTIFY, {
25
- title: input.title,
26
- summary: input.summary,
27
- steps: input.steps ?? [],
28
- ...input.href ? { href: input.href } : {},
29
- ...input.dedupeKey ? { dedupeKey: input.dedupeKey } : {}
30
- }),
31
- channels: () => t.request("GET", "/api/admin/slack/channels")
32
- };
33
- }
34
- export {
35
- opsClient
36
- };
@@ -1,54 +0,0 @@
1
- import { Transport } from '../transport.js';
2
-
3
- /**
4
- * Projects — find-or-create by domain (`upsert`) and the auth-resolved current
5
- * project (`current`). The `.shipeasy` write that `bind`/`upsert --bind`
6
- * performs is a CONSUMER side-effect layered on top of these calls (it touches
7
- * the filesystem); it never lives in the resource, so this stays worker-safe.
8
- */
9
- interface UpsertResult {
10
- id: string;
11
- name: string;
12
- domain: string | null;
13
- owner_email: string;
14
- created: boolean;
15
- }
16
- /**
17
- * The project the caller's auth header resolves to. The server reads the
18
- * project from the credential — there is no id parameter — so `current` works
19
- * with nothing but the session, which is what makes a registry-driven `whoami`
20
- * possible.
21
- */
22
- interface CurrentProject {
23
- id: string;
24
- name: string;
25
- domain: string | null;
26
- ownerEmail: string;
27
- plan: "free" | "paid";
28
- status: "active" | "inactive";
29
- subscriptionStatus: string;
30
- billingInterval: "monthly" | "annual";
31
- currentPeriodEnd: string | null;
32
- trialEndsAt: string | null;
33
- cancelAtPeriodEnd: number;
34
- moduleTranslations: boolean | number;
35
- moduleConfigs: boolean | number;
36
- moduleGates: boolean | number;
37
- moduleExperiments: boolean | number;
38
- moduleFeedback: boolean | number;
39
- createdAt: string;
40
- updatedAt: string;
41
- [key: string]: unknown;
42
- }
43
- interface ProjectsClient {
44
- /** Find-or-create a project by domain (idempotent). */
45
- upsert(input: {
46
- domain: string;
47
- name?: string;
48
- }): Promise<UpsertResult>;
49
- /** The project the auth header resolves to (no id needed). */
50
- current(): Promise<CurrentProject>;
51
- }
52
- declare function projectsClient(t: Transport): ProjectsClient;
53
-
54
- export { type CurrentProject, type ProjectsClient, type UpsertResult, projectsClient };
@@ -1,14 +0,0 @@
1
- // src/resources/projects.ts
2
- var BASE = "/api/admin/projects";
3
- function projectsClient(t) {
4
- return {
5
- upsert: (input) => t.request("POST", `${BASE}/upsert`, {
6
- domain: input.domain,
7
- ...input.name ? { name: input.name } : {}
8
- }),
9
- current: () => t.request("GET", `${BASE}/current`)
10
- };
11
- }
12
- export {
13
- projectsClient
14
- };
@@ -1,185 +0,0 @@
1
- import { z } from 'zod';
2
- import { UniverseCreateInput, UniverseUpdateInput } from '../schemas/universes.js';
3
- import { PageQuery, Page } from '../schemas/pagination.js';
4
- import { Transport } from '../transport.js';
5
-
6
- interface Universe {
7
- id: string;
8
- name: string;
9
- unitType: string;
10
- holdoutRange: [number, number] | null;
11
- allocationPct?: number;
12
- holdoutPct?: number;
13
- updatedAt?: string;
14
- }
15
- interface UniversesClient {
16
- list(opts?: Partial<PageQuery>): Promise<Page<Universe>>;
17
- listAll(): Promise<Universe[]>;
18
- resolve(idOrName: string): Promise<Universe>;
19
- create(input: UniverseCreateInput): Promise<Universe>;
20
- update(id: string, input: UniverseUpdateInput): Promise<Universe>;
21
- delete(id: string): Promise<{
22
- ok: true;
23
- }>;
24
- }
25
- declare function universesClient(t: Transport): UniversesClient;
26
- declare const universesResource: {
27
- readonly name: "universes";
28
- readonly basePath: "/api/admin/universes";
29
- readonly describeOne: "universe";
30
- readonly describeMany: "universes";
31
- readonly tag: {
32
- readonly name: "Universes";
33
- readonly description: string;
34
- };
35
- readonly schemas: {
36
- readonly create: z.ZodObject<{
37
- name: z.ZodString;
38
- folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
39
- unit_type: z.ZodDefault<z.ZodString>;
40
- holdout_range: z.ZodDefault<z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
41
- }, z.core.$strip>;
42
- readonly update: z.ZodObject<{
43
- folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
44
- holdout_range: z.ZodOptional<z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
45
- }, z.core.$strip>;
46
- };
47
- readonly actions: readonly [];
48
- readonly endpoints: readonly [{
49
- readonly operationId: "listUniverses";
50
- readonly method: "GET";
51
- readonly path: "";
52
- readonly summary: "List universes";
53
- readonly description: "Returns a single page of universes ordered by `created_at desc, id desc`. The universes table has no `updated_at`, so this list is keyed on creation time.";
54
- readonly response: z.ZodObject<{
55
- data: z.ZodArray<z.ZodObject<{
56
- id: z.ZodString;
57
- name: z.ZodString;
58
- unitType: z.ZodString;
59
- holdoutRange: z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
60
- createdAt: z.ZodString;
61
- }, z.core.$strip>>;
62
- next_cursor: z.ZodNullable<z.ZodString>;
63
- }, z.core.$strip>;
64
- readonly examples: {
65
- readonly response: {
66
- readonly data: readonly [{
67
- readonly id: "uni_01j7w8a1b2c3d4e5f6g7h8i9j0";
68
- readonly name: "primary_users";
69
- readonly unitType: "user_id";
70
- readonly holdoutRange: readonly [9500, 9999];
71
- readonly createdAt: "2026-04-12T10:14:08.000Z";
72
- }];
73
- readonly next_cursor: null;
74
- };
75
- };
76
- readonly useCase: "Snapshot every universe in the project — for example to audit which `unit_type` and `holdout_range` are in use before launching a new experiment.";
77
- }, {
78
- readonly operationId: "createUniverse";
79
- readonly method: "POST";
80
- readonly path: "";
81
- readonly summary: "Create a universe";
82
- readonly description: string;
83
- readonly successStatus: 201;
84
- readonly request: z.ZodObject<{
85
- name: z.ZodString;
86
- folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
87
- unit_type: z.ZodDefault<z.ZodString>;
88
- holdout_range: z.ZodDefault<z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
89
- }, z.core.$strip>;
90
- readonly response: z.ZodObject<{
91
- id: z.ZodString;
92
- name: z.ZodString;
93
- }, z.core.$strip>;
94
- readonly examples: {
95
- readonly requestExamples: {
96
- readonly minimal: {
97
- readonly summary: "Minimal — name only";
98
- readonly description: "Smallest valid body. Creates a `user_id`-keyed universe with no holdout.";
99
- readonly value: {
100
- readonly name: "primary_users";
101
- };
102
- };
103
- readonly holdout: {
104
- readonly summary: "Holdout — reserve 5% for measurement";
105
- readonly description: "Reserves buckets 9500–9999 (5% of callers) as the holdout. Pro plan or higher.";
106
- readonly value: {
107
- readonly name: "primary_users";
108
- readonly holdout_range: readonly [9500, 9999];
109
- };
110
- };
111
- readonly accountLevel: {
112
- readonly summary: "Account-level randomisation";
113
- readonly description: "Bucket whole accounts together via `unit_type: 'account_id'`.";
114
- readonly value: {
115
- readonly name: "saas_accounts";
116
- readonly unit_type: "account_id";
117
- };
118
- };
119
- };
120
- readonly response: {
121
- readonly id: "uni_01j7w8a1b2c3d4e5f6g7h8i9j0";
122
- readonly name: "primary_users";
123
- };
124
- };
125
- readonly useCase: string;
126
- }, {
127
- readonly operationId: "updateUniverse";
128
- readonly method: "PATCH";
129
- readonly path: "/{id}";
130
- readonly summary: "Update a universe";
131
- readonly description: string;
132
- readonly pathParams: {
133
- readonly id: "Stable opaque universe id (`uni_…`).";
134
- };
135
- readonly request: z.ZodObject<{
136
- folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
137
- holdout_range: z.ZodOptional<z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
138
- }, z.core.$strip>;
139
- readonly response: z.ZodObject<{
140
- id: z.ZodString;
141
- }, z.core.$strip>;
142
- readonly examples: {
143
- readonly requestExamples: {
144
- readonly setHoldout: {
145
- readonly summary: "Set holdout — reserve 5%";
146
- readonly description: "Reserve buckets 9500–9999 as the holdout. Pro plan or higher.";
147
- readonly value: {
148
- readonly holdout_range: readonly [9500, 9999];
149
- };
150
- };
151
- readonly removeHoldout: {
152
- readonly summary: "Remove holdout";
153
- readonly description: "Disable the holdout entirely.";
154
- readonly value: {
155
- readonly holdout_range: null;
156
- };
157
- };
158
- };
159
- readonly response: {
160
- readonly id: "uni_01j7w8a1b2c3d4e5f6g7h8i9j0";
161
- };
162
- };
163
- readonly useCase: string;
164
- }, {
165
- readonly operationId: "deleteUniverse";
166
- readonly method: "DELETE";
167
- readonly path: "/{id}";
168
- readonly summary: "Delete a universe";
169
- readonly description: "Soft-deletes the universe. Returns `409` if any non-archived experiment still references it — archive those experiments first.";
170
- readonly pathParams: {
171
- readonly id: "Stable opaque universe id.";
172
- };
173
- readonly response: z.ZodObject<{
174
- ok: z.ZodLiteral<true>;
175
- }, z.core.$strip>;
176
- readonly examples: {
177
- readonly response: {
178
- readonly ok: true;
179
- };
180
- };
181
- readonly useCase: "Tear down a universe after every experiment that used it has been archived.";
182
- }];
183
- };
184
-
185
- export { type Universe, UniverseCreateInput, UniverseUpdateInput, type UniversesClient, universesClient, universesResource };
@@ -1,234 +0,0 @@
1
- // src/resources/universes.ts
2
- import { z as z3 } from "zod";
3
-
4
- // src/schemas/universes.ts
5
- import { z as z2 } from "zod";
6
-
7
- // src/schemas/folder.ts
8
- import { z } from "zod";
9
- var folderSchema = z.string().max(256).regex(/^[a-zA-Z0-9_-]+$/, "Folder must be alphanumeric, `_` or `-` (no `/`).").nullable().optional().describe(
10
- "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."
11
- );
12
-
13
- // src/schemas/universes.ts
14
- var universeNameSchema = z2.string().regex(/^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?)?$/).max(128).describe(
15
- "Stable universe key. Single segment or `folder.name`. Lowercase letters, digits, `_` or `-`; max 128 chars. Immutable after create."
16
- );
17
- var holdoutRangeSchema = z2.tuple([z2.number().int().min(0).max(9999), z2.number().int().min(0).max(9999)]).refine(([lo, hi]) => lo <= hi, "lo must be <= hi").nullable().describe(
18
- "Inclusive `[lo, hi]` bucket range (0\u20139999) reserved as the **holdout** \u2014 callers hashed into this slice are excluded from every experiment in the universe. `null` disables the holdout. Pro plan or higher required."
19
- );
20
- var universeCreateSchema = z2.object({
21
- name: universeNameSchema,
22
- folder: folderSchema,
23
- unit_type: z2.string().default("user_id").describe(
24
- "Unit of randomisation. Typically `user_id`. Use `account_id` to keep whole accounts in the same group across an experiment."
25
- ),
26
- holdout_range: holdoutRangeSchema.default(null)
27
- }).describe("Body for `POST /api/admin/universes`. Only `name` is required.");
28
- var universeUpdateSchema = z2.object({
29
- folder: folderSchema,
30
- holdout_range: holdoutRangeSchema.optional()
31
- }).describe(
32
- "Body for `PATCH /api/admin/universes/{id}`. Only `holdout_range` is mutable \u2014 name and unit_type are immutable after create."
33
- );
34
- var universeResponseSchema = z2.object({
35
- id: z2.string().describe("Stable opaque universe id."),
36
- name: universeNameSchema,
37
- unitType: z2.string().describe("Unit of randomisation. Snake-case in request (`unit_type`), camelCase in response."),
38
- holdoutRange: z2.tuple([z2.number(), z2.number()]).nullable().describe("Reserved holdout bucket range, or `null` if none."),
39
- createdAt: z2.string().describe("ISO-8601 timestamp of creation.")
40
- });
41
- var universeCreateResponseSchema = z2.object({
42
- id: z2.string().describe("Newly assigned universe id."),
43
- name: universeNameSchema
44
- });
45
- var universeUpdateResponseSchema = z2.object({
46
- id: z2.string().describe("Universe id that was updated.")
47
- });
48
- var universeDeleteResponseSchema = z2.object({ ok: z2.literal(true) });
49
-
50
- // src/transport.ts
51
- var ApiError = class extends Error {
52
- constructor(message, status) {
53
- super(message);
54
- this.status = status;
55
- this.name = "ApiError";
56
- }
57
- status;
58
- };
59
-
60
- // src/resources/universes.ts
61
- var universeListResponseSchema = z3.object({
62
- data: z3.array(universeResponseSchema),
63
- next_cursor: z3.string().nullable()
64
- });
65
- var BASE = "/api/admin/universes";
66
- function universesClient(t) {
67
- async function list(opts = {}) {
68
- const query = {};
69
- if (opts.limit !== void 0) query.limit = String(opts.limit);
70
- if (opts.cursor) query.cursor = opts.cursor;
71
- return t.request("GET", BASE, void 0, query);
72
- }
73
- async function listAll() {
74
- const out = [];
75
- let cursor;
76
- do {
77
- const page = await list({ limit: 500, cursor });
78
- out.push(...page.data);
79
- cursor = page.next_cursor ?? void 0;
80
- } while (cursor);
81
- return out;
82
- }
83
- async function resolve(idOrName) {
84
- const all = await listAll();
85
- const found = all.find((u) => u.id === idOrName) ?? all.find((u) => u.name === idOrName);
86
- if (!found) throw new ApiError(`Universe '${idOrName}' not found`, 404);
87
- return found;
88
- }
89
- return {
90
- list,
91
- listAll,
92
- resolve,
93
- create: (input) => t.request("POST", BASE, universeCreateSchema.parse(input)),
94
- update: (id, input) => t.request("PATCH", `${BASE}/${id}`, universeUpdateSchema.parse(input)),
95
- delete: (id) => t.request("DELETE", `${BASE}/${id}`)
96
- };
97
- }
98
- var universesResource = {
99
- name: "universes",
100
- basePath: BASE,
101
- describeOne: "universe",
102
- describeMany: "universes",
103
- tag: {
104
- name: "Universes",
105
- description: [
106
- "Universes: the shared bucketing space all experiments draw from.",
107
- "",
108
- "**Identity.** Each universe is keyed by a stable `name` (a-z, 0-9, `_`/`-`, max 64 chars). Experiments reference it via `universe: '<name>'`. The name is immutable.",
109
- "",
110
- "**Unit of randomisation.** `unit_type` selects the attribute hashed into a 0\u20139999 bucket \u2014 default `user_id` for per-user randomisation, `account_id` to keep a whole account in the same group.",
111
- "",
112
- "**Holdout.** `holdout_range` is an inclusive `[lo, hi]` bucket range (0\u20139999) reserved for measurement \u2014 callers hashed into the holdout are excluded from every experiment in the universe. Pro plan or higher.",
113
- "",
114
- "**Deletion.** Blocked while any non-archived experiment references the universe \u2014 archive those first."
115
- ].join("\n")
116
- },
117
- schemas: {
118
- create: universeCreateSchema,
119
- update: universeUpdateSchema
120
- },
121
- actions: [],
122
- endpoints: [
123
- {
124
- operationId: "listUniverses",
125
- method: "GET",
126
- path: "",
127
- summary: "List universes",
128
- description: "Returns a single page of universes ordered by `created_at desc, id desc`. The universes table has no `updated_at`, so this list is keyed on creation time.",
129
- response: universeListResponseSchema,
130
- examples: {
131
- response: {
132
- data: [
133
- {
134
- id: "uni_01j7w8a1b2c3d4e5f6g7h8i9j0",
135
- name: "primary_users",
136
- unitType: "user_id",
137
- holdoutRange: [9500, 9999],
138
- createdAt: "2026-04-12T10:14:08.000Z"
139
- }
140
- ],
141
- next_cursor: null
142
- }
143
- },
144
- useCase: "Snapshot every universe in the project \u2014 for example to audit which `unit_type` and `holdout_range` are in use before launching a new experiment."
145
- },
146
- {
147
- operationId: "createUniverse",
148
- method: "POST",
149
- path: "",
150
- summary: "Create a universe",
151
- description: [
152
- "Creates a new universe. Only `name` is required \u2014 `unit_type` defaults to `user_id` and `holdout_range` defaults to `null` (no holdout).",
153
- "",
154
- "Returns `409` if `name` already exists in the project. Returns `403` if you supply `holdout_range` on a plan below Pro."
155
- ].join("\n"),
156
- successStatus: 201,
157
- request: universeCreateSchema,
158
- response: universeCreateResponseSchema,
159
- examples: {
160
- requestExamples: {
161
- minimal: {
162
- summary: "Minimal \u2014 name only",
163
- description: "Smallest valid body. Creates a `user_id`-keyed universe with no holdout.",
164
- value: { name: "primary_users" }
165
- },
166
- holdout: {
167
- summary: "Holdout \u2014 reserve 5% for measurement",
168
- description: "Reserves buckets 9500\u20139999 (5% of callers) as the holdout. Pro plan or higher.",
169
- value: { name: "primary_users", holdout_range: [9500, 9999] }
170
- },
171
- accountLevel: {
172
- summary: "Account-level randomisation",
173
- description: "Bucket whole accounts together via `unit_type: 'account_id'`.",
174
- value: { name: "saas_accounts", unit_type: "account_id" }
175
- }
176
- },
177
- response: { id: "uni_01j7w8a1b2c3d4e5f6g7h8i9j0", name: "primary_users" }
178
- },
179
- useCase: [
180
- '- **Default universe** \u2014 `{ "name": "primary_users" }`. Per-user randomisation, no holdout.',
181
- "- **Reserved holdout** \u2014 supply `holdout_range` to carve out a measurement slice excluded from all experiments.",
182
- "- **Account-level** \u2014 `unit_type: 'account_id'` so multi-seat accounts see one consistent variant."
183
- ].join("\n")
184
- },
185
- {
186
- operationId: "updateUniverse",
187
- method: "PATCH",
188
- path: "/{id}",
189
- summary: "Update a universe",
190
- description: [
191
- "Partial update. Only `holdout_range` is mutable \u2014 `name` and `unit_type` are immutable after create.",
192
- "",
193
- 'Pass `"holdout_range": null` to remove an existing holdout.'
194
- ].join("\n"),
195
- pathParams: { id: "Stable opaque universe id (`uni_\u2026`)." },
196
- request: universeUpdateSchema,
197
- response: universeUpdateResponseSchema,
198
- examples: {
199
- requestExamples: {
200
- setHoldout: {
201
- summary: "Set holdout \u2014 reserve 5%",
202
- description: "Reserve buckets 9500\u20139999 as the holdout. Pro plan or higher.",
203
- value: { holdout_range: [9500, 9999] }
204
- },
205
- removeHoldout: {
206
- summary: "Remove holdout",
207
- description: "Disable the holdout entirely.",
208
- value: { holdout_range: null }
209
- }
210
- },
211
- response: { id: "uni_01j7w8a1b2c3d4e5f6g7h8i9j0" }
212
- },
213
- useCase: [
214
- "- **Adjust holdout** \u2014 change the reserved measurement slice without recreating experiments.",
215
- '- **Remove holdout** \u2014 `{ "holdout_range": null }`.'
216
- ].join("\n")
217
- },
218
- {
219
- operationId: "deleteUniverse",
220
- method: "DELETE",
221
- path: "/{id}",
222
- summary: "Delete a universe",
223
- description: "Soft-deletes the universe. Returns `409` if any non-archived experiment still references it \u2014 archive those experiments first.",
224
- pathParams: { id: "Stable opaque universe id." },
225
- response: universeDeleteResponseSchema,
226
- examples: { response: { ok: true } },
227
- useCase: "Tear down a universe after every experiment that used it has been archived."
228
- }
229
- ]
230
- };
231
- export {
232
- universesClient,
233
- universesResource
234
- };
@@ -1,65 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- declare const ALERT_COMPARATORS: readonly ["gt", "gte", "lt", "lte"];
4
- declare const ALERT_SEVERITIES: readonly ["danger", "warn", "info"];
5
- declare const notificationTargetSchema: z.ZodObject<{
6
- slackChannel: z.ZodOptional<z.ZodNullable<z.ZodObject<{
7
- id: z.ZodString;
8
- name: z.ZodString;
9
- }, z.core.$strip>>>;
10
- email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
- }, z.core.$strict>;
12
- type NotificationTarget = z.infer<typeof notificationTargetSchema>;
13
- declare const alertRuleCreateSchema: z.ZodObject<{
14
- name: z.ZodString;
15
- metricId: z.ZodString;
16
- comparator: z.ZodEnum<{
17
- gt: "gt";
18
- gte: "gte";
19
- lt: "lt";
20
- lte: "lte";
21
- }>;
22
- threshold: z.ZodNumber;
23
- windowHours: z.ZodDefault<z.ZodNumber>;
24
- severity: z.ZodDefault<z.ZodEnum<{
25
- danger: "danger";
26
- warn: "warn";
27
- info: "info";
28
- }>>;
29
- enabled: z.ZodDefault<z.ZodBoolean>;
30
- notify: z.ZodOptional<z.ZodNullable<z.ZodObject<{
31
- slackChannel: z.ZodOptional<z.ZodNullable<z.ZodObject<{
32
- id: z.ZodString;
33
- name: z.ZodString;
34
- }, z.core.$strip>>>;
35
- email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
- }, z.core.$strict>>>;
37
- }, z.core.$strict>;
38
- declare const alertRuleUpdateSchema: z.ZodObject<{
39
- name: z.ZodOptional<z.ZodString>;
40
- comparator: z.ZodOptional<z.ZodEnum<{
41
- gt: "gt";
42
- gte: "gte";
43
- lt: "lt";
44
- lte: "lte";
45
- }>>;
46
- threshold: z.ZodOptional<z.ZodNumber>;
47
- windowHours: z.ZodOptional<z.ZodNumber>;
48
- severity: z.ZodOptional<z.ZodEnum<{
49
- danger: "danger";
50
- warn: "warn";
51
- info: "info";
52
- }>>;
53
- enabled: z.ZodOptional<z.ZodBoolean>;
54
- notify: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodObject<{
55
- slackChannel: z.ZodOptional<z.ZodNullable<z.ZodObject<{
56
- id: z.ZodString;
57
- name: z.ZodString;
58
- }, z.core.$strip>>>;
59
- email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
60
- }, z.core.$strict>>>>;
61
- }, z.core.$strict>;
62
- type AlertRuleCreate = z.infer<typeof alertRuleCreateSchema>;
63
- type AlertRuleUpdate = z.infer<typeof alertRuleUpdateSchema>;
64
-
65
- export { ALERT_COMPARATORS, ALERT_SEVERITIES, type AlertRuleCreate, type AlertRuleUpdate, type NotificationTarget, alertRuleCreateSchema, alertRuleUpdateSchema, notificationTargetSchema };