@shipeasy/openapi 1.0.0 → 1.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/dist/index.d.ts +9 -7
- package/dist/index.js +484 -2665
- package/dist/resources/alert-rules.d.ts +48 -0
- package/dist/resources/alert-rules.js +66 -0
- package/dist/resources/configs.d.ts +6 -2
- package/dist/resources/configs.js +67 -2375
- package/dist/resources/experiments.d.ts +88 -2
- package/dist/resources/experiments.js +138 -98
- package/dist/resources/gates.d.ts +51 -8
- package/dist/resources/gates.js +102 -70
- package/dist/resources/index.d.ts +156 -10
- package/dist/resources/index.js +483 -2664
- package/dist/resources/killswitches.d.ts +6 -2
- package/dist/resources/killswitches.js +113 -2412
- package/dist/resources/universes.d.ts +7 -4
- package/dist/resources/universes.js +30 -20
- package/dist/schemas/alert-rules.d.ts +43 -0
- package/dist/schemas/alert-rules.js +27 -0
- package/dist/schemas/configs.d.ts +154 -0
- package/dist/schemas/configs.js +134 -0
- package/dist/schemas/constants.d.ts +6 -0
- package/dist/schemas/constants.js +7 -0
- package/dist/schemas/experiments.d.ts +245 -0
- package/dist/schemas/experiments.js +216 -0
- package/dist/schemas/folder.d.ts +10 -0
- package/dist/schemas/folder.js +8 -0
- package/dist/schemas/gates.d.ts +304 -0
- package/dist/schemas/gates.js +172 -0
- package/dist/schemas/index.d.ts +11 -0
- package/dist/schemas/index.js +729 -0
- package/dist/schemas/killswitches.d.ts +110 -0
- package/dist/schemas/killswitches.js +226 -0
- package/dist/schemas/metric-name.d.ts +5 -0
- package/dist/schemas/metric-name.js +6 -0
- package/dist/schemas/pagination.d.ts +37 -0
- package/dist/schemas/pagination.js +44 -0
- package/dist/schemas/universes.d.ts +35 -0
- package/dist/schemas/universes.js +55 -0
- package/package.json +13 -10
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { GateCreateInput, GateUpdateInput } from '
|
|
3
|
-
|
|
4
|
-
import { PageQuery, Page } from '@shipeasy/core/pagination';
|
|
2
|
+
import { GateCreateInput, GateUpdateInput } from '../schemas/gates.js';
|
|
3
|
+
import { PageQuery, Page } from '../schemas/pagination.js';
|
|
5
4
|
import { Transport } from '../transport.js';
|
|
6
5
|
|
|
7
6
|
/** Gate row as returned by `GET /api/admin/gates`. Booleans come back as 0/1 from D1. */
|
|
@@ -67,12 +66,13 @@ declare const gatesResource: {
|
|
|
67
66
|
readonly create: z.ZodObject<{
|
|
68
67
|
title: z.ZodOptional<z.ZodString>;
|
|
69
68
|
description: z.ZodOptional<z.ZodString>;
|
|
70
|
-
folder: z.ZodOptional<z.ZodString
|
|
69
|
+
folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
70
|
group: z.ZodOptional<z.ZodString>;
|
|
72
71
|
owner_email: z.ZodOptional<z.ZodString>;
|
|
73
72
|
name: z.ZodString;
|
|
74
73
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
75
74
|
rollout_pct: z.ZodDefault<z.ZodNumber>;
|
|
75
|
+
rollout_percent: z.ZodOptional<z.ZodNumber>;
|
|
76
76
|
rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
77
77
|
attr: z.ZodString;
|
|
78
78
|
op: z.ZodEnum<{
|
|
@@ -86,6 +86,10 @@ declare const gatesResource: {
|
|
|
86
86
|
lte: "lte";
|
|
87
87
|
contains: "contains";
|
|
88
88
|
regex: "regex";
|
|
89
|
+
semver_gt: "semver_gt";
|
|
90
|
+
semver_gte: "semver_gte";
|
|
91
|
+
semver_lt: "semver_lt";
|
|
92
|
+
semver_lte: "semver_lte";
|
|
89
93
|
}>;
|
|
90
94
|
value: z.ZodUnknown;
|
|
91
95
|
}, z.core.$strip>>>;
|
|
@@ -112,6 +116,10 @@ declare const gatesResource: {
|
|
|
112
116
|
lte: "lte";
|
|
113
117
|
contains: "contains";
|
|
114
118
|
regex: "regex";
|
|
119
|
+
semver_gt: "semver_gt";
|
|
120
|
+
semver_gte: "semver_gte";
|
|
121
|
+
semver_lt: "semver_lt";
|
|
122
|
+
semver_lte: "semver_lte";
|
|
115
123
|
}>;
|
|
116
124
|
value: z.ZodUnknown;
|
|
117
125
|
}, z.core.$strip>>>;
|
|
@@ -130,10 +138,11 @@ declare const gatesResource: {
|
|
|
130
138
|
readonly update: z.ZodObject<{
|
|
131
139
|
title: z.ZodOptional<z.ZodString>;
|
|
132
140
|
description: z.ZodOptional<z.ZodString>;
|
|
133
|
-
folder: z.ZodOptional<z.ZodString
|
|
141
|
+
folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
134
142
|
group: z.ZodOptional<z.ZodString>;
|
|
135
143
|
owner_email: z.ZodOptional<z.ZodString>;
|
|
136
144
|
rollout_pct: z.ZodOptional<z.ZodNumber>;
|
|
145
|
+
rollout_percent: z.ZodOptional<z.ZodNumber>;
|
|
137
146
|
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
138
147
|
attr: z.ZodString;
|
|
139
148
|
op: z.ZodEnum<{
|
|
@@ -147,6 +156,10 @@ declare const gatesResource: {
|
|
|
147
156
|
lte: "lte";
|
|
148
157
|
contains: "contains";
|
|
149
158
|
regex: "regex";
|
|
159
|
+
semver_gt: "semver_gt";
|
|
160
|
+
semver_gte: "semver_gte";
|
|
161
|
+
semver_lt: "semver_lt";
|
|
162
|
+
semver_lte: "semver_lte";
|
|
150
163
|
}>;
|
|
151
164
|
value: z.ZodUnknown;
|
|
152
165
|
}, z.core.$strip>>>;
|
|
@@ -173,6 +186,10 @@ declare const gatesResource: {
|
|
|
173
186
|
lte: "lte";
|
|
174
187
|
contains: "contains";
|
|
175
188
|
regex: "regex";
|
|
189
|
+
semver_gt: "semver_gt";
|
|
190
|
+
semver_gte: "semver_gte";
|
|
191
|
+
semver_lt: "semver_lt";
|
|
192
|
+
semver_lte: "semver_lte";
|
|
176
193
|
}>;
|
|
177
194
|
value: z.ZodUnknown;
|
|
178
195
|
}, z.core.$strip>>>;
|
|
@@ -227,6 +244,10 @@ declare const gatesResource: {
|
|
|
227
244
|
lte: "lte";
|
|
228
245
|
contains: "contains";
|
|
229
246
|
regex: "regex";
|
|
247
|
+
semver_gt: "semver_gt";
|
|
248
|
+
semver_gte: "semver_gte";
|
|
249
|
+
semver_lt: "semver_lt";
|
|
250
|
+
semver_lte: "semver_lte";
|
|
230
251
|
}>;
|
|
231
252
|
value: z.ZodUnknown;
|
|
232
253
|
}, z.core.$strip>>>;
|
|
@@ -258,6 +279,10 @@ declare const gatesResource: {
|
|
|
258
279
|
lte: "lte";
|
|
259
280
|
contains: "contains";
|
|
260
281
|
regex: "regex";
|
|
282
|
+
semver_gt: "semver_gt";
|
|
283
|
+
semver_gte: "semver_gte";
|
|
284
|
+
semver_lt: "semver_lt";
|
|
285
|
+
semver_lte: "semver_lte";
|
|
261
286
|
}>;
|
|
262
287
|
value: z.ZodUnknown;
|
|
263
288
|
}, z.core.$strip>>>;
|
|
@@ -315,12 +340,13 @@ declare const gatesResource: {
|
|
|
315
340
|
readonly request: z.ZodObject<{
|
|
316
341
|
title: z.ZodOptional<z.ZodString>;
|
|
317
342
|
description: z.ZodOptional<z.ZodString>;
|
|
318
|
-
folder: z.ZodOptional<z.ZodString
|
|
343
|
+
folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
319
344
|
group: z.ZodOptional<z.ZodString>;
|
|
320
345
|
owner_email: z.ZodOptional<z.ZodString>;
|
|
321
346
|
name: z.ZodString;
|
|
322
347
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
323
348
|
rollout_pct: z.ZodDefault<z.ZodNumber>;
|
|
349
|
+
rollout_percent: z.ZodOptional<z.ZodNumber>;
|
|
324
350
|
rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
325
351
|
attr: z.ZodString;
|
|
326
352
|
op: z.ZodEnum<{
|
|
@@ -334,6 +360,10 @@ declare const gatesResource: {
|
|
|
334
360
|
lte: "lte";
|
|
335
361
|
contains: "contains";
|
|
336
362
|
regex: "regex";
|
|
363
|
+
semver_gt: "semver_gt";
|
|
364
|
+
semver_gte: "semver_gte";
|
|
365
|
+
semver_lt: "semver_lt";
|
|
366
|
+
semver_lte: "semver_lte";
|
|
337
367
|
}>;
|
|
338
368
|
value: z.ZodUnknown;
|
|
339
369
|
}, z.core.$strip>>>;
|
|
@@ -360,6 +390,10 @@ declare const gatesResource: {
|
|
|
360
390
|
lte: "lte";
|
|
361
391
|
contains: "contains";
|
|
362
392
|
regex: "regex";
|
|
393
|
+
semver_gt: "semver_gt";
|
|
394
|
+
semver_gte: "semver_gte";
|
|
395
|
+
semver_lt: "semver_lt";
|
|
396
|
+
semver_lte: "semver_lte";
|
|
363
397
|
}>;
|
|
364
398
|
value: z.ZodUnknown;
|
|
365
399
|
}, z.core.$strip>>>;
|
|
@@ -475,10 +509,11 @@ declare const gatesResource: {
|
|
|
475
509
|
readonly request: z.ZodObject<{
|
|
476
510
|
title: z.ZodOptional<z.ZodString>;
|
|
477
511
|
description: z.ZodOptional<z.ZodString>;
|
|
478
|
-
folder: z.ZodOptional<z.ZodString
|
|
512
|
+
folder: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
479
513
|
group: z.ZodOptional<z.ZodString>;
|
|
480
514
|
owner_email: z.ZodOptional<z.ZodString>;
|
|
481
515
|
rollout_pct: z.ZodOptional<z.ZodNumber>;
|
|
516
|
+
rollout_percent: z.ZodOptional<z.ZodNumber>;
|
|
482
517
|
rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
483
518
|
attr: z.ZodString;
|
|
484
519
|
op: z.ZodEnum<{
|
|
@@ -492,6 +527,10 @@ declare const gatesResource: {
|
|
|
492
527
|
lte: "lte";
|
|
493
528
|
contains: "contains";
|
|
494
529
|
regex: "regex";
|
|
530
|
+
semver_gt: "semver_gt";
|
|
531
|
+
semver_gte: "semver_gte";
|
|
532
|
+
semver_lt: "semver_lt";
|
|
533
|
+
semver_lte: "semver_lte";
|
|
495
534
|
}>;
|
|
496
535
|
value: z.ZodUnknown;
|
|
497
536
|
}, z.core.$strip>>>;
|
|
@@ -518,6 +557,10 @@ declare const gatesResource: {
|
|
|
518
557
|
lte: "lte";
|
|
519
558
|
contains: "contains";
|
|
520
559
|
regex: "regex";
|
|
560
|
+
semver_gt: "semver_gt";
|
|
561
|
+
semver_gte: "semver_gte";
|
|
562
|
+
semver_lt: "semver_lt";
|
|
563
|
+
semver_lte: "semver_lte";
|
|
521
564
|
}>;
|
|
522
565
|
value: z.ZodUnknown;
|
|
523
566
|
}, z.core.$strip>>>;
|
|
@@ -667,4 +710,4 @@ declare const gatesResource: {
|
|
|
667
710
|
}];
|
|
668
711
|
};
|
|
669
712
|
|
|
670
|
-
export { type Gate, type GatesClient, gatesClient, gatesResource };
|
|
713
|
+
export { type Gate, GateCreateInput, GateUpdateInput, type GatesClient, gatesClient, gatesResource };
|
package/dist/resources/gates.js
CHANGED
|
@@ -1,132 +1,164 @@
|
|
|
1
1
|
// src/resources/gates.ts
|
|
2
|
+
import { z as z3 } from "zod";
|
|
3
|
+
|
|
4
|
+
// src/schemas/gates.ts
|
|
2
5
|
import { z as z2 } from "zod";
|
|
3
6
|
|
|
4
|
-
//
|
|
7
|
+
// src/schemas/folder.ts
|
|
5
8
|
import { z } from "zod";
|
|
6
|
-
var
|
|
7
|
-
|
|
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/gates.ts
|
|
14
|
+
var gateRuleSchema = z2.object({
|
|
15
|
+
attr: z2.string().min(1).describe(
|
|
8
16
|
"Attribute key on the evaluation context (e.g. `country`, `plan`, `email`). Matched case-sensitively against `Shipeasy.checkGate(user, name)` input."
|
|
9
17
|
),
|
|
10
|
-
op:
|
|
11
|
-
"
|
|
18
|
+
op: z2.enum([
|
|
19
|
+
"eq",
|
|
20
|
+
"neq",
|
|
21
|
+
"in",
|
|
22
|
+
"not_in",
|
|
23
|
+
"gt",
|
|
24
|
+
"gte",
|
|
25
|
+
"lt",
|
|
26
|
+
"lte",
|
|
27
|
+
"contains",
|
|
28
|
+
"regex",
|
|
29
|
+
"semver_gt",
|
|
30
|
+
"semver_gte",
|
|
31
|
+
"semver_lt",
|
|
32
|
+
"semver_lte"
|
|
33
|
+
]).describe(
|
|
34
|
+
"Comparison operator. Equality: `eq`/`neq`. Set membership: `in`/`not_in` (value is an array). Numeric order: `gt`/`gte`/`lt`/`lte`. Semver order: `semver_gt`/`semver_gte`/`semver_lt`/`semver_lte` (value is a dotted version like `4.2.0`). String: `contains` (substring), `regex` (JS-flavour pattern, value is the pattern string)."
|
|
12
35
|
),
|
|
13
|
-
value:
|
|
14
|
-
"Operand. Shape depends on `op`: scalar for `eq/neq/gt/gte/lt/lte/contains
|
|
36
|
+
value: z2.unknown().describe(
|
|
37
|
+
"Operand. Shape depends on `op`: scalar for `eq/neq/gt/gte/lt/lte/contains/semver_*`; array of scalars for `in/not_in`; string pattern for `regex`."
|
|
15
38
|
)
|
|
16
39
|
}).describe(
|
|
17
40
|
"Single targeting predicate. A gate's `rules` array is evaluated with AND semantics; use the gatekeeper `stack` for OR / fall-through logic."
|
|
18
41
|
);
|
|
19
|
-
var gateNameSchema =
|
|
20
|
-
|
|
42
|
+
var gateNameSchema = z2.string().regex(
|
|
43
|
+
/^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?)?$/,
|
|
44
|
+
"lowercase, digits, _/-; optional folder.name shape"
|
|
45
|
+
).max(128).describe(
|
|
46
|
+
"Stable gate key used by SDKs (`Shipeasy.checkGate(user, '<name>')`). Single segment or `folder.name`. Lowercase letters, digits, `_` or `-`; max 128 chars. Immutable after create \u2014 rename = delete + recreate."
|
|
21
47
|
);
|
|
22
|
-
var stackedConditionSchema =
|
|
23
|
-
id:
|
|
48
|
+
var stackedConditionSchema = z2.object({
|
|
49
|
+
id: z2.string().min(1).describe(
|
|
24
50
|
"Client-supplied stable id for the stack entry (used for React keys, audit diffs)."
|
|
25
51
|
),
|
|
26
|
-
type:
|
|
27
|
-
name:
|
|
28
|
-
fromTemplate:
|
|
52
|
+
type: z2.literal("condition").describe("Discriminator. `condition` = rule-based predicate sub-gate."),
|
|
53
|
+
name: z2.string().optional().describe("Human label shown in the dashboard."),
|
|
54
|
+
fromTemplate: z2.string().nullable().optional().describe(
|
|
29
55
|
"Id of the project template this entry was seeded from, or `null` if hand-authored."
|
|
30
56
|
),
|
|
31
|
-
pass:
|
|
32
|
-
rules:
|
|
33
|
-
locked:
|
|
57
|
+
pass: z2.enum(["all", "any"]).optional().describe("Combinator across `rules`. `all` = AND (default), `any` = OR."),
|
|
58
|
+
rules: z2.array(gateRuleSchema).default([]).describe("Predicates evaluated under `pass`. Empty array = match nothing."),
|
|
59
|
+
locked: z2.boolean().optional().describe("If `true`, dashboard hides edit controls (e.g. the trailing public-floor entry).")
|
|
34
60
|
}).describe(
|
|
35
61
|
"Rule-based sub-gate. When matched, evaluation short-circuits and the gate returns `true` for the current caller."
|
|
36
62
|
);
|
|
37
|
-
var stackedRolloutSchema =
|
|
38
|
-
id:
|
|
39
|
-
type:
|
|
40
|
-
name:
|
|
41
|
-
fromTemplate:
|
|
42
|
-
rolloutPct:
|
|
63
|
+
var stackedRolloutSchema = z2.object({
|
|
64
|
+
id: z2.string().min(1).describe("Client-supplied stable id for the stack entry."),
|
|
65
|
+
type: z2.literal("rollout").describe("Discriminator. `rollout` = percentage-bucket sub-gate."),
|
|
66
|
+
name: z2.string().optional().describe("Human label shown in the dashboard."),
|
|
67
|
+
fromTemplate: z2.string().nullable().optional().describe("Source template id, or `null`."),
|
|
68
|
+
rolloutPct: z2.number().int().min(0).max(1e4).describe(
|
|
43
69
|
"Bucket size in basis points (0\u201310000 = 0%\u2013100%). `5000` = 50%, `100` = 1%, allows sub-1% precision."
|
|
44
70
|
),
|
|
45
|
-
bucketBy:
|
|
71
|
+
bucketBy: z2.string().optional().describe(
|
|
46
72
|
"Attribute used to hash the caller into a bucket. Defaults to `user.userID`. Use e.g. `accountID` to bucket whole accounts together."
|
|
47
73
|
),
|
|
48
|
-
salt:
|
|
74
|
+
salt: z2.string().optional().describe(
|
|
49
75
|
"Per-entry hash salt. Defaults to the gate's salt. Set explicitly to keep two rollouts independent or correlated across gates."
|
|
50
76
|
),
|
|
51
|
-
locked:
|
|
77
|
+
locked: z2.boolean().optional().describe("If `true`, dashboard hides edit controls.")
|
|
52
78
|
}).describe(
|
|
53
79
|
"Percentage-rollout sub-gate. Hashes `bucketBy` (default `userID`) with `salt` and returns `true` for `rolloutPct/10000` fraction of callers."
|
|
54
80
|
);
|
|
55
|
-
var stackedGateEntrySchema =
|
|
81
|
+
var stackedGateEntrySchema = z2.discriminatedUnion("type", [stackedConditionSchema, stackedRolloutSchema]).describe(
|
|
56
82
|
"One entry in the ordered gatekeeper stack. Evaluated top-to-bottom; first matching entry decides. Mix `condition` and `rollout` entries to express `internal-only` + `1% beta` + `50% public` in a single gate."
|
|
57
83
|
);
|
|
58
84
|
var gateMetadataFields = {
|
|
59
|
-
title:
|
|
60
|
-
description:
|
|
61
|
-
folder:
|
|
62
|
-
|
|
63
|
-
)
|
|
64
|
-
group: z.string().max(64).optional().describe("Group label for dashboard organisation (e.g. team or product area)."),
|
|
65
|
-
owner_email: z.string().max(190).optional().describe("Owner contact. Displayed verbatim; not used for auth.")
|
|
85
|
+
title: z2.string().max(140).optional().describe("Human-readable title shown in the dashboard. Free-form, no key format constraint."),
|
|
86
|
+
description: z2.string().max(2e3).optional().describe("Long-form description / runbook. Markdown is rendered in the dashboard."),
|
|
87
|
+
folder: folderSchema,
|
|
88
|
+
group: z2.string().max(64).optional().describe("Group label for dashboard organisation (e.g. team or product area)."),
|
|
89
|
+
owner_email: z2.string().max(190).optional().describe("Owner contact. Displayed verbatim; not used for auth.")
|
|
66
90
|
};
|
|
67
|
-
var gateMetadataPatchSchema =
|
|
68
|
-
var gateCreateSchema =
|
|
91
|
+
var gateMetadataPatchSchema = z2.object(gateMetadataFields);
|
|
92
|
+
var gateCreateSchema = z2.object({
|
|
69
93
|
name: gateNameSchema,
|
|
70
|
-
enabled:
|
|
94
|
+
enabled: z2.boolean().default(true).describe(
|
|
71
95
|
"Master switch. Defaults to `true`. Set `false` to create the gate disabled (evaluates to `false` regardless of rules/rollout); flip on via `POST /{id}/enable` or PATCH."
|
|
72
96
|
),
|
|
73
|
-
rollout_pct:
|
|
74
|
-
"Initial rollout in basis points (0\u201310000 = 0%\u2013100%). Use `0` to create the gate dark and ramp via PATCH after deploy validation."
|
|
97
|
+
rollout_pct: z2.number().int().min(0).max(1e4).default(0).describe(
|
|
98
|
+
"Initial rollout in **basis points** (0\u201310000 = 0%\u2013100%) \u2014 `100` here means **1%**, not 100%. Use `rollout_percent` (0\u2013100) below if you'd rather think in percent. Use `0` to create the gate dark and ramp via PATCH after deploy validation."
|
|
75
99
|
),
|
|
76
|
-
|
|
100
|
+
rollout_percent: z2.number().min(0).max(100).optional().describe(
|
|
101
|
+
"Initial rollout as a **percentage** (0\u2013100, fractional ok). Friendlier alias for `rollout_pct`; converted internally to basis points (e.g. `100` here = 10000 bp = 100%). If both `rollout_pct` and `rollout_percent` are set, `rollout_percent` wins."
|
|
102
|
+
),
|
|
103
|
+
rules: z2.array(gateRuleSchema).default([]).describe(
|
|
77
104
|
"Targeting predicates. AND-combined. If non-empty, the gate returns `true` only for callers that satisfy every rule **and** fall under `rollout_pct`."
|
|
78
105
|
),
|
|
79
|
-
salt:
|
|
106
|
+
salt: z2.string().min(1).max(64).optional().describe(
|
|
80
107
|
"Hash salt for percentage bucketing. Auto-generated if omitted. Provide explicitly to keep a gate's buckets stable across delete/recreate. **Immutable after create** \u2014 there is no PATCH for `salt` because changing it would re-bucket every caller."
|
|
81
108
|
),
|
|
82
|
-
stack:
|
|
109
|
+
stack: z2.array(stackedGateEntrySchema).nullable().optional().describe(
|
|
83
110
|
"Optional gatekeeper stack. When provided, takes precedence over `rules` + `rollout_pct` at evaluation time. Omit (or pass `null`) for a flat gate."
|
|
84
111
|
),
|
|
85
112
|
...gateMetadataFields
|
|
86
113
|
}).describe(
|
|
87
114
|
"Body for `POST /api/admin/gates`. At minimum supply `name`; everything else has sensible defaults."
|
|
88
115
|
);
|
|
89
|
-
var gateUpdateSchema =
|
|
90
|
-
rollout_pct:
|
|
91
|
-
|
|
116
|
+
var gateUpdateSchema = z2.object({
|
|
117
|
+
rollout_pct: z2.number().int().min(0).max(1e4).optional().describe(
|
|
118
|
+
"New rollout in **basis points** (0\u201310000 = 0%\u2013100%) \u2014 `100` here means **1%**. Use `rollout_percent` (0\u2013100) below for percent. Omit both to leave unchanged."
|
|
119
|
+
),
|
|
120
|
+
rollout_percent: z2.number().min(0).max(100).optional().describe(
|
|
121
|
+
"New rollout as a **percentage** (0\u2013100). Friendlier alias for `rollout_pct`; converted internally. Wins over `rollout_pct` if both are supplied. Omit both to leave unchanged."
|
|
122
|
+
),
|
|
123
|
+
rules: z2.array(gateRuleSchema).optional().describe(
|
|
92
124
|
"Replaces the rule list wholesale. To add a value to an `in` rule, send the full new `rules` array with the augmented `value` (e.g. previous `['US','CA']` \u2192 `['US','CA','GB']`)."
|
|
93
125
|
),
|
|
94
|
-
enabled:
|
|
126
|
+
enabled: z2.boolean().optional().describe(
|
|
95
127
|
"Master switch. `false` makes the gate evaluate to `false` for every caller regardless of `rollout_pct`, `rules`, or `stack` \u2014 use as kill switch."
|
|
96
128
|
),
|
|
97
|
-
stack:
|
|
129
|
+
stack: z2.array(stackedGateEntrySchema).nullable().optional().describe(
|
|
98
130
|
"Replaces the gatekeeper stack wholesale. Send `null` to revert to flat `rules` + `rollout_pct` evaluation."
|
|
99
131
|
),
|
|
100
132
|
...gateMetadataFields
|
|
101
133
|
}).describe(
|
|
102
134
|
"Body for `PATCH /api/admin/gates/{id}`. Partial \u2014 only supplied fields change. Array fields (`rules`, `stack`) replace, not merge."
|
|
103
135
|
);
|
|
104
|
-
var gateResponseSchema =
|
|
105
|
-
id:
|
|
136
|
+
var gateResponseSchema = z2.object({
|
|
137
|
+
id: z2.string().describe("Stable opaque gate id (`gat_\u2026`)."),
|
|
106
138
|
name: gateNameSchema,
|
|
107
139
|
/** D1 stores enabled as 0/1; clients see either form. */
|
|
108
|
-
enabled:
|
|
140
|
+
enabled: z2.union([z2.boolean(), z2.number().int().min(0).max(1)]).describe("Master switch. Returned as `1`/`0` from D1; treat truthy as enabled."),
|
|
109
141
|
/** Rollout percentage in basis points (0–10000 = 0%–100%). */
|
|
110
|
-
rolloutPct:
|
|
111
|
-
rules:
|
|
112
|
-
salt:
|
|
113
|
-
title:
|
|
114
|
-
description:
|
|
115
|
-
folder:
|
|
116
|
-
groupName:
|
|
117
|
-
ownerEmail:
|
|
118
|
-
stack:
|
|
119
|
-
updatedAt:
|
|
142
|
+
rolloutPct: z2.number().int().min(0).max(1e4).describe("Current rollout in basis points (0\u201310000)."),
|
|
143
|
+
rules: z2.array(gateRuleSchema).optional(),
|
|
144
|
+
salt: z2.string().optional().describe("Hash salt used for percentage bucketing."),
|
|
145
|
+
title: z2.string().nullable().optional(),
|
|
146
|
+
description: z2.string().nullable().optional(),
|
|
147
|
+
folder: z2.string().nullable().optional(),
|
|
148
|
+
groupName: z2.string().nullable().optional().describe("Group label (note: `groupName` in response, `group` in request)."),
|
|
149
|
+
ownerEmail: z2.string().nullable().optional().describe("Owner email (note: `ownerEmail` in response, `owner_email` in request)."),
|
|
150
|
+
stack: z2.array(stackedGateEntrySchema).nullable().optional(),
|
|
151
|
+
updatedAt: z2.string().describe("ISO-8601 timestamp of last mutation.")
|
|
120
152
|
});
|
|
121
|
-
var gateCreateResponseSchema =
|
|
122
|
-
id:
|
|
153
|
+
var gateCreateResponseSchema = z2.object({
|
|
154
|
+
id: z2.string().describe("Newly assigned gate id (`gat_\u2026`)."),
|
|
123
155
|
name: gateNameSchema
|
|
124
156
|
});
|
|
125
|
-
var gateUpdateResponseSchema =
|
|
126
|
-
var gateDeleteResponseSchema =
|
|
127
|
-
var gateToggleResponseSchema =
|
|
128
|
-
id:
|
|
129
|
-
enabled:
|
|
157
|
+
var gateUpdateResponseSchema = z2.object({ id: z2.string().describe("Gate id that was updated.") }).describe("Update returns only the id \u2014 re-fetch via `GET /api/admin/gates` for the full row.");
|
|
158
|
+
var gateDeleteResponseSchema = z2.object({ ok: z2.literal(true) });
|
|
159
|
+
var gateToggleResponseSchema = z2.object({
|
|
160
|
+
id: z2.string(),
|
|
161
|
+
enabled: z2.boolean()
|
|
130
162
|
});
|
|
131
163
|
|
|
132
164
|
// src/transport.ts
|
|
@@ -140,9 +172,9 @@ var ApiError = class extends Error {
|
|
|
140
172
|
};
|
|
141
173
|
|
|
142
174
|
// src/resources/gates.ts
|
|
143
|
-
var gateListResponseSchema =
|
|
144
|
-
data:
|
|
145
|
-
next_cursor:
|
|
175
|
+
var gateListResponseSchema = z3.object({
|
|
176
|
+
data: z3.array(gateResponseSchema),
|
|
177
|
+
next_cursor: z3.string().nullable()
|
|
146
178
|
});
|
|
147
179
|
var BASE = "/api/admin/gates";
|
|
148
180
|
function gatesClient(t) {
|