@shipeasy/openapi 1.5.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 -17
- package/dist/index.js +253 -2458
- package/dist/index.js.map +1 -0
- package/dist/node-context.d.ts +85 -0
- package/dist/node-context.js +110 -0
- 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 +37 -21
- 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/resources/alert-rules.d.ts +0 -50
- package/dist/resources/alert-rules.js +0 -75
- package/dist/resources/configs.d.ts +0 -681
- package/dist/resources/configs.js +0 -509
- 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/index.d.ts +0 -2749
- package/dist/resources/index.js +0 -2391
- package/dist/resources/killswitches.d.ts +0 -436
- package/dist/resources/killswitches.js +0 -514
- 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
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/api/admin/search:
|
|
2
|
+
get:
|
|
3
|
+
operationId: searchResources
|
|
4
|
+
summary: Search project resources
|
|
5
|
+
description: |-
|
|
6
|
+
Universal substring search across the project's primary resources — feature gates, experiments, dynamic configs, killswitches, metrics, and team members. Matches the trimmed `q` against each resource's immutable `name` and its human title/display name (members match on display name or email), newest-first, capped per resource family so one noisy type can't crowd out the rest.
|
|
7
|
+
|
|
8
|
+
Returns a flat, ranked-by-type list of hits (members first); an empty or whitespace-only `q` returns no hits. Each hit carries a project-relative `href` that deep-links to the row.
|
|
9
|
+
|
|
10
|
+
**Use case:** Back a command-palette / quick-switcher in the dashboard, or look up the id of a resource by a fragment of its name before driving another API call.
|
|
11
|
+
tags:
|
|
12
|
+
- Projects
|
|
13
|
+
parameters:
|
|
14
|
+
- $ref: ../components/parameters.yaml#/ProjectId
|
|
15
|
+
- name: q
|
|
16
|
+
in: query
|
|
17
|
+
required: false
|
|
18
|
+
description: Search query. Matched as a case-insensitive substring against each resource's `name` and title/display name. Trimmed; empty returns no hits.
|
|
19
|
+
schema:
|
|
20
|
+
type: string
|
|
21
|
+
responses:
|
|
22
|
+
"200":
|
|
23
|
+
description: Search project resources
|
|
24
|
+
content:
|
|
25
|
+
application/json:
|
|
26
|
+
schema:
|
|
27
|
+
$ref: ../components/schemas/search.yaml#/SearchResponse
|
|
28
|
+
example:
|
|
29
|
+
hits:
|
|
30
|
+
- type: member
|
|
31
|
+
id: ana@example.com
|
|
32
|
+
name: Ana Ng
|
|
33
|
+
title: ana@example.com
|
|
34
|
+
href: /team
|
|
35
|
+
- type: gate
|
|
36
|
+
id: gat_01j7w7m9q4hxbf6npe6s9zr3vc
|
|
37
|
+
name: checkout_v2
|
|
38
|
+
title: Checkout v2
|
|
39
|
+
href: /gates?open=gat_01j7w7m9q4hxbf6npe6s9zr3vc
|
|
40
|
+
- type: experiment
|
|
41
|
+
id: exp_01j7w7m9q4hxbf6npe6s9zr3vd
|
|
42
|
+
name: checkout_button_color
|
|
43
|
+
title: Checkout button colour test
|
|
44
|
+
href: /experiments?open=exp_01j7w7m9q4hxbf6npe6s9zr3vd
|
|
45
|
+
"400":
|
|
46
|
+
$ref: ../components/responses.yaml#/BadRequest
|
|
47
|
+
"401":
|
|
48
|
+
$ref: ../components/responses.yaml#/Unauthorized
|
|
49
|
+
"403":
|
|
50
|
+
$ref: ../components/responses.yaml#/Forbidden
|
|
51
|
+
"404":
|
|
52
|
+
$ref: ../components/responses.yaml#/NotFound
|
|
53
|
+
"409":
|
|
54
|
+
$ref: ../components/responses.yaml#/Conflict
|
|
55
|
+
"422":
|
|
56
|
+
$ref: ../components/responses.yaml#/UnprocessableEntity
|
|
57
|
+
x-error-codes:
|
|
58
|
+
- BAD_REQUEST
|
|
59
|
+
- UNAUTHORIZED
|
|
60
|
+
- FORBIDDEN
|
|
61
|
+
x-cli:
|
|
62
|
+
name: search
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/api/admin/universes:
|
|
2
|
+
get:
|
|
3
|
+
operationId: listUniverses
|
|
4
|
+
summary: List universes
|
|
5
|
+
description: |-
|
|
6
|
+
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.
|
|
7
|
+
|
|
8
|
+
**Use case:** Snapshot every universe in the project — for example to audit which `unit_type` and `holdout_range` are in use before launching a new experiment.
|
|
9
|
+
tags:
|
|
10
|
+
- Universes
|
|
11
|
+
parameters:
|
|
12
|
+
- $ref: ../components/parameters.yaml#/ProjectId
|
|
13
|
+
- $ref: ../components/parameters.yaml#/PaginationLimit
|
|
14
|
+
- $ref: ../components/parameters.yaml#/PaginationCursor
|
|
15
|
+
responses:
|
|
16
|
+
"200":
|
|
17
|
+
description: List universes
|
|
18
|
+
content:
|
|
19
|
+
application/json:
|
|
20
|
+
schema:
|
|
21
|
+
$ref: ../components/schemas/universes.yaml#/ListUniversesResponse
|
|
22
|
+
example:
|
|
23
|
+
data:
|
|
24
|
+
- id: uni_01j7w8a1b2c3d4e5f6g7h8i9j0
|
|
25
|
+
name: primary_users
|
|
26
|
+
unitType: user_id
|
|
27
|
+
holdoutRange:
|
|
28
|
+
- 9500
|
|
29
|
+
- 9999
|
|
30
|
+
createdAt: 2026-04-12T10:14:08.000Z
|
|
31
|
+
next_cursor: null
|
|
32
|
+
"400":
|
|
33
|
+
$ref: ../components/responses.yaml#/BadRequest
|
|
34
|
+
"401":
|
|
35
|
+
$ref: ../components/responses.yaml#/Unauthorized
|
|
36
|
+
"403":
|
|
37
|
+
$ref: ../components/responses.yaml#/Forbidden
|
|
38
|
+
"404":
|
|
39
|
+
$ref: ../components/responses.yaml#/NotFound
|
|
40
|
+
"409":
|
|
41
|
+
$ref: ../components/responses.yaml#/Conflict
|
|
42
|
+
"422":
|
|
43
|
+
$ref: ../components/responses.yaml#/UnprocessableEntity
|
|
44
|
+
x-error-codes:
|
|
45
|
+
- BAD_REQUEST
|
|
46
|
+
- UNAUTHORIZED
|
|
47
|
+
- FORBIDDEN
|
|
48
|
+
x-cli:
|
|
49
|
+
name: list
|
|
50
|
+
post:
|
|
51
|
+
operationId: createUniverse
|
|
52
|
+
summary: Create a universe
|
|
53
|
+
description: |-
|
|
54
|
+
Creates a new universe. Only `name` is required — `unit_type` defaults to `user_id` and `holdout_range` defaults to `null` (no holdout).
|
|
55
|
+
|
|
56
|
+
Returns `409` if `name` already exists in the project. Returns `403` if you supply `holdout_range` on a plan below Pro.
|
|
57
|
+
|
|
58
|
+
**Use cases**
|
|
59
|
+
|
|
60
|
+
- **Default universe** — `{ "name": "primary_users" }`. Per-user randomisation, no holdout.
|
|
61
|
+
- **Reserved holdout** — supply `holdout_range` to carve out a measurement slice excluded from all experiments.
|
|
62
|
+
- **Account-level** — `unit_type: 'account_id'` so multi-seat accounts see one consistent variant.
|
|
63
|
+
tags:
|
|
64
|
+
- Universes
|
|
65
|
+
parameters:
|
|
66
|
+
- $ref: ../components/parameters.yaml#/ProjectId
|
|
67
|
+
requestBody:
|
|
68
|
+
required: true
|
|
69
|
+
content:
|
|
70
|
+
application/json:
|
|
71
|
+
schema:
|
|
72
|
+
$ref: ../components/schemas/universes.yaml#/CreateUniverseRequest
|
|
73
|
+
examples:
|
|
74
|
+
minimal:
|
|
75
|
+
summary: Minimal — name only
|
|
76
|
+
description: Smallest valid body. Creates a `user_id`-keyed universe with no holdout.
|
|
77
|
+
value:
|
|
78
|
+
name: primary_users
|
|
79
|
+
holdout:
|
|
80
|
+
summary: Holdout — reserve 5% for measurement
|
|
81
|
+
description: Reserves buckets 9500–9999 (5% of callers) as the holdout. Pro plan or higher.
|
|
82
|
+
value:
|
|
83
|
+
name: primary_users
|
|
84
|
+
holdout_range:
|
|
85
|
+
- 9500
|
|
86
|
+
- 9999
|
|
87
|
+
accountLevel:
|
|
88
|
+
summary: Account-level randomisation
|
|
89
|
+
description: "Bucket whole accounts together via `unit_type: 'account_id'`."
|
|
90
|
+
value:
|
|
91
|
+
name: saas_accounts
|
|
92
|
+
unit_type: account_id
|
|
93
|
+
responses:
|
|
94
|
+
"201":
|
|
95
|
+
description: Create a universe
|
|
96
|
+
content:
|
|
97
|
+
application/json:
|
|
98
|
+
schema:
|
|
99
|
+
$ref: ../components/schemas/universes.yaml#/CreateUniverseResponse
|
|
100
|
+
example:
|
|
101
|
+
id: uni_01j7w8a1b2c3d4e5f6g7h8i9j0
|
|
102
|
+
name: primary_users
|
|
103
|
+
"400":
|
|
104
|
+
$ref: ../components/responses.yaml#/BadRequest
|
|
105
|
+
"401":
|
|
106
|
+
$ref: ../components/responses.yaml#/Unauthorized
|
|
107
|
+
"403":
|
|
108
|
+
$ref: ../components/responses.yaml#/Forbidden
|
|
109
|
+
"404":
|
|
110
|
+
$ref: ../components/responses.yaml#/NotFound
|
|
111
|
+
"409":
|
|
112
|
+
$ref: ../components/responses.yaml#/Conflict
|
|
113
|
+
"422":
|
|
114
|
+
$ref: ../components/responses.yaml#/UnprocessableEntity
|
|
115
|
+
x-error-codes:
|
|
116
|
+
- BAD_REQUEST
|
|
117
|
+
- UNAUTHORIZED
|
|
118
|
+
- FORBIDDEN
|
|
119
|
+
- PLAN_REQUIRED
|
|
120
|
+
- ALREADY_EXISTS
|
|
121
|
+
- VALIDATION
|
|
122
|
+
x-cli:
|
|
123
|
+
name: create
|
|
124
|
+
positional:
|
|
125
|
+
- name
|
|
126
|
+
/api/admin/universes/{id}:
|
|
127
|
+
patch:
|
|
128
|
+
operationId: updateUniverse
|
|
129
|
+
summary: Update a universe
|
|
130
|
+
description: |-
|
|
131
|
+
Partial update. Only `holdout_range` is mutable — `name` and `unit_type` are immutable after create.
|
|
132
|
+
|
|
133
|
+
Pass `"holdout_range": null` to remove an existing holdout.
|
|
134
|
+
|
|
135
|
+
**Use cases**
|
|
136
|
+
|
|
137
|
+
- **Adjust holdout** — change the reserved measurement slice without recreating experiments.
|
|
138
|
+
- **Remove holdout** — `{ "holdout_range": null }`.
|
|
139
|
+
tags:
|
|
140
|
+
- Universes
|
|
141
|
+
parameters:
|
|
142
|
+
- $ref: ../components/parameters.yaml#/ProjectId
|
|
143
|
+
- name: id
|
|
144
|
+
in: path
|
|
145
|
+
required: true
|
|
146
|
+
description: Stable opaque universe id (`uni_…`) or the universe's `name`.
|
|
147
|
+
schema:
|
|
148
|
+
type: string
|
|
149
|
+
requestBody:
|
|
150
|
+
required: true
|
|
151
|
+
content:
|
|
152
|
+
application/json:
|
|
153
|
+
schema:
|
|
154
|
+
$ref: ../components/schemas/universes.yaml#/UpdateUniverseRequest
|
|
155
|
+
examples:
|
|
156
|
+
setHoldout:
|
|
157
|
+
summary: Set holdout — reserve 5%
|
|
158
|
+
description: Reserve buckets 9500–9999 as the holdout. Pro plan or higher.
|
|
159
|
+
value:
|
|
160
|
+
holdout_range:
|
|
161
|
+
- 9500
|
|
162
|
+
- 9999
|
|
163
|
+
removeHoldout:
|
|
164
|
+
summary: Remove holdout
|
|
165
|
+
description: Disable the holdout entirely.
|
|
166
|
+
value:
|
|
167
|
+
holdout_range: null
|
|
168
|
+
responses:
|
|
169
|
+
"200":
|
|
170
|
+
description: Update a universe
|
|
171
|
+
content:
|
|
172
|
+
application/json:
|
|
173
|
+
schema:
|
|
174
|
+
$ref: ../components/schemas/universes.yaml#/UpdateUniverseResponse
|
|
175
|
+
example:
|
|
176
|
+
id: uni_01j7w8a1b2c3d4e5f6g7h8i9j0
|
|
177
|
+
"400":
|
|
178
|
+
$ref: ../components/responses.yaml#/BadRequest
|
|
179
|
+
"401":
|
|
180
|
+
$ref: ../components/responses.yaml#/Unauthorized
|
|
181
|
+
"403":
|
|
182
|
+
$ref: ../components/responses.yaml#/Forbidden
|
|
183
|
+
"404":
|
|
184
|
+
$ref: ../components/responses.yaml#/NotFound
|
|
185
|
+
"409":
|
|
186
|
+
$ref: ../components/responses.yaml#/Conflict
|
|
187
|
+
"422":
|
|
188
|
+
$ref: ../components/responses.yaml#/UnprocessableEntity
|
|
189
|
+
x-error-codes:
|
|
190
|
+
- BAD_REQUEST
|
|
191
|
+
- UNAUTHORIZED
|
|
192
|
+
- FORBIDDEN
|
|
193
|
+
- PLAN_REQUIRED
|
|
194
|
+
- NOT_FOUND
|
|
195
|
+
- VALIDATION
|
|
196
|
+
x-cli:
|
|
197
|
+
name: update
|
|
198
|
+
positional:
|
|
199
|
+
- id
|
|
200
|
+
delete:
|
|
201
|
+
operationId: deleteUniverse
|
|
202
|
+
summary: Delete a universe
|
|
203
|
+
description: |-
|
|
204
|
+
Soft-deletes the universe. Returns `409` if any non-archived experiment still references it — archive those experiments first.
|
|
205
|
+
|
|
206
|
+
**Use case:** Tear down a universe after every experiment that used it has been archived.
|
|
207
|
+
tags:
|
|
208
|
+
- Universes
|
|
209
|
+
parameters:
|
|
210
|
+
- $ref: ../components/parameters.yaml#/ProjectId
|
|
211
|
+
- name: id
|
|
212
|
+
in: path
|
|
213
|
+
required: true
|
|
214
|
+
description: Stable opaque universe id (`uni_…`) or the universe's `name`.
|
|
215
|
+
schema:
|
|
216
|
+
type: string
|
|
217
|
+
responses:
|
|
218
|
+
"200":
|
|
219
|
+
description: Delete a universe
|
|
220
|
+
content:
|
|
221
|
+
application/json:
|
|
222
|
+
schema:
|
|
223
|
+
$ref: ../components/schemas/universes.yaml#/DeleteUniverseResponse
|
|
224
|
+
example:
|
|
225
|
+
ok: true
|
|
226
|
+
"400":
|
|
227
|
+
$ref: ../components/responses.yaml#/BadRequest
|
|
228
|
+
"401":
|
|
229
|
+
$ref: ../components/responses.yaml#/Unauthorized
|
|
230
|
+
"403":
|
|
231
|
+
$ref: ../components/responses.yaml#/Forbidden
|
|
232
|
+
"404":
|
|
233
|
+
$ref: ../components/responses.yaml#/NotFound
|
|
234
|
+
"409":
|
|
235
|
+
$ref: ../components/responses.yaml#/Conflict
|
|
236
|
+
"422":
|
|
237
|
+
$ref: ../components/responses.yaml#/UnprocessableEntity
|
|
238
|
+
x-error-codes:
|
|
239
|
+
- BAD_REQUEST
|
|
240
|
+
- UNAUTHORIZED
|
|
241
|
+
- FORBIDDEN
|
|
242
|
+
- NOT_FOUND
|
|
243
|
+
- REFERENCED_IN_USE
|
|
244
|
+
x-cli:
|
|
245
|
+
name: archive
|
|
246
|
+
positional:
|
|
247
|
+
- id
|
|
@@ -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
|
-
};
|