@worker-protocol/schemas 0.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/LICENSE +201 -0
- package/NOTICE +9 -0
- package/dist/index.d.ts +671 -0
- package/dist/index.js +1075 -0
- package/package.json +45 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The Zod objects that generate `schemas/`.
|
|
4
|
+
*
|
|
5
|
+
* Nothing here carries behaviour of its own. Every constraint below encodes a rule that
|
|
6
|
+
* `spec/` already states, and each one cites the rule id it encodes so that a conformance
|
|
7
|
+
* report can name the rule rather than the file. Where `spec/` has not decided something, the
|
|
8
|
+
* object here is deliberately permissive and says so — a schema that overstates is worse than
|
|
9
|
+
* one that admits a hole, because the schema is the normative artifact and prose defers to it.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The base every schema's `$id` is built on — and NO HOME HAS BEEN CHOSEN.
|
|
13
|
+
*
|
|
14
|
+
* `null` means each `$id` is the bare file name, which identifies a schema within this set and
|
|
15
|
+
* commits the project to no domain. Edition 0.1 is published and these packages are at 0.1.0, so
|
|
16
|
+
* the old justification — that nothing was published — has expired; the choice stands on what is
|
|
17
|
+
* left of it, which is that no home has been chosen and nothing consumes these by URL.
|
|
18
|
+
*
|
|
19
|
+
* A `$id` identifies; it does not have to resolve. Validation works whether or not anything is
|
|
20
|
+
* ever served at it, and relative `$ref`s between these schemas resolve against the document's
|
|
21
|
+
* own location exactly as they would against an absolute base.
|
|
22
|
+
*
|
|
23
|
+
* When a home is chosen, set this to something of the shape
|
|
24
|
+
* `https://<host>/worker-protocol/schemas` — namespaced under a path rather than hung off a
|
|
25
|
+
* domain root, so that a later move changes one segment and not the shape of every identifier.
|
|
26
|
+
* That is the only edit required: the host would then appear in each generated file on its own
|
|
27
|
+
* `$id` line and nowhere else, because every cross-schema `$ref` stays relative.
|
|
28
|
+
*/
|
|
29
|
+
export declare const SCHEMA_ID_BASE: string | null;
|
|
30
|
+
/**
|
|
31
|
+
* DESC-23 — the edition of worker-protocol these schemas encode.
|
|
32
|
+
*
|
|
33
|
+
* It is not this package's version and cannot be read off it. A package version is SemVer and
|
|
34
|
+
* describes the package; an edition is `MAJOR.MINOR` and describes the protocol, and the two move
|
|
35
|
+
* for different reasons — a Zod major, a type made more precise, a build fixed, none of which is a
|
|
36
|
+
* change to anything a Worker sends. `packages/README.md` carries that argument, including why the
|
|
37
|
+
* two numbers agreeing today is a coincidence rather than a rule.
|
|
38
|
+
*/
|
|
39
|
+
export declare const EDITION = "0.1";
|
|
40
|
+
/** The `$id` of one generated schema. A registry id is also its file name, plus `.json`. */
|
|
41
|
+
export declare const schemaId: (name: string) => string;
|
|
42
|
+
/**
|
|
43
|
+
* The registry the generator walks. A registry id becomes three things: the generated file name,
|
|
44
|
+
* the `$ref` other schemas point at — relative, so `capability-entry.json` and not a URL — and,
|
|
45
|
+
* once rewritten through `schemaId`, that file's own absolute `$id`.
|
|
46
|
+
*/
|
|
47
|
+
export declare const registry: z.core.$ZodRegistry<{
|
|
48
|
+
id: string;
|
|
49
|
+
}, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
50
|
+
/**
|
|
51
|
+
* DESC-8 — the closed enumeration of Capability names this edition defines. Normative, and the
|
|
52
|
+
* list a verifier checks an undotted name against. `spec/README.md`'s table is a reading aid.
|
|
53
|
+
*/
|
|
54
|
+
export declare const capabilityName: z.ZodEnum<{
|
|
55
|
+
actions: "actions";
|
|
56
|
+
activity: "activity";
|
|
57
|
+
alerts: "alerts";
|
|
58
|
+
events: "events";
|
|
59
|
+
health: "health";
|
|
60
|
+
metrics: "metrics";
|
|
61
|
+
nudges: "nudges";
|
|
62
|
+
tasks: "tasks";
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* DESC-14 — a name containing a `.` is the Worker's own and is never defined by this
|
|
66
|
+
* specification. The pattern asserts only what DESC-14 asserts: at least one dot, and no dot at
|
|
67
|
+
* either end. naming.md answers the rest of the syntax by adding nothing to it: nobody compares one
|
|
68
|
+
* Worker's vendor Capability against another's, so there is no collision for a longer name to
|
|
69
|
+
* prevent.
|
|
70
|
+
*/
|
|
71
|
+
export declare const vendorCapabilityName: z.ZodString;
|
|
72
|
+
/**
|
|
73
|
+
* NAME-7 — a name this protocol expects one party to match against a name that came from somewhere
|
|
74
|
+
* else: a Task type, a Skill, an event type.
|
|
75
|
+
*
|
|
76
|
+
* The pattern is at least three dot-separated labels — two or more for the DNS name in reverse
|
|
77
|
+
* label order, one or more for the local part — each a DNS label of lowercase letters, digits and
|
|
78
|
+
* hyphens, never starting or ending with a hyphen.
|
|
79
|
+
*
|
|
80
|
+
* Lowercase is asserted rather than left to taste, and it is the one part of this that is load-
|
|
81
|
+
* bearing rather than conventional. DNS is case-insensitive, so `Example.com` and `example.com`
|
|
82
|
+
* are one domain; NAME-1 compares names byte for byte, so `com.Example.x` and `com.example.x`
|
|
83
|
+
* would be two names for one thing. One spelling closes a trap the two rules open between them.
|
|
84
|
+
*
|
|
85
|
+
* NAME-8 — that the domain is one the minting team controls — has no schema witness and cannot
|
|
86
|
+
* have one. Nothing verifies domain ownership, which is why it recommends rather than binds.
|
|
87
|
+
*/
|
|
88
|
+
export declare const qualifiedName: z.ZodString;
|
|
89
|
+
/**
|
|
90
|
+
* DESC-12 — an address is an absolute `https` URL, or a relative reference resolved against the
|
|
91
|
+
* URL the Descriptor was read from.
|
|
92
|
+
*
|
|
93
|
+
* The pattern is the load-bearing part: `format` is an annotation in Draft 2020-12 unless a
|
|
94
|
+
* validator opts into format-assertion, so a schema that relied on `format: "uri-reference"`
|
|
95
|
+
* alone would assert nothing. This admits a string that either begins `https://` or carries no
|
|
96
|
+
* scheme at all, which is exactly the two cases DESC-12 names.
|
|
97
|
+
*/
|
|
98
|
+
export declare const address: z.ZodString;
|
|
99
|
+
/**
|
|
100
|
+
* DESC-22 — what a Worker declares about one Capability it implements.
|
|
101
|
+
*
|
|
102
|
+
* Loose on purpose, and the reason has changed since it was written. Every Capability file now
|
|
103
|
+
* defines its extension — `healthEntry`, `metricsEntry`, `actionsEntry`, `alertsEntry`,
|
|
104
|
+
* `activityEntry`, `nudgesEntry`, `tasksEntry`, `eventsEntry` — so this is no longer holding a door
|
|
105
|
+
* open for something unwritten.
|
|
106
|
+
* What keeps it loose is that `descriptor.json` still holds its entries as a record of THIS shape
|
|
107
|
+
* rather than binding each reserved name to its own, so closing it here would refuse every
|
|
108
|
+
* conformant Descriptor. Tightening that is a breaking change to the normative artifact and is
|
|
109
|
+
* listed in descriptor.md as the next edition's.
|
|
110
|
+
*/
|
|
111
|
+
export declare const capabilityEntry: z.ZodObject<{
|
|
112
|
+
version: z.ZodNumber;
|
|
113
|
+
address: z.ZodOptional<z.ZodString>;
|
|
114
|
+
}, z.core.$loose>;
|
|
115
|
+
/**
|
|
116
|
+
* HLTH-2 — the three values a health status takes, and the only three.
|
|
117
|
+
*
|
|
118
|
+
* `degraded` is the one that earns its place: `healthy` and `unhealthy` alone would force a Worker
|
|
119
|
+
* that works with one dependency down to lie in one direction or the other.
|
|
120
|
+
*/
|
|
121
|
+
export declare const healthStatus: z.ZodEnum<{
|
|
122
|
+
degraded: "degraded";
|
|
123
|
+
healthy: "healthy";
|
|
124
|
+
unhealthy: "unhealthy";
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* HLTH-2 — one named check.
|
|
128
|
+
*
|
|
129
|
+
* Loose on purpose: health.md records as open what a check carries beyond its status and detail —
|
|
130
|
+
* an observed value, a unit, a threshold — and closing this would answer that by accident.
|
|
131
|
+
*/
|
|
132
|
+
export declare const healthCheck: z.ZodObject<{
|
|
133
|
+
status: z.ZodEnum<{
|
|
134
|
+
degraded: "degraded";
|
|
135
|
+
healthy: "healthy";
|
|
136
|
+
unhealthy: "unhealthy";
|
|
137
|
+
}>;
|
|
138
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
139
|
+
}, z.core.$loose>;
|
|
140
|
+
/**
|
|
141
|
+
* HLTH-2 — the whole answer.
|
|
142
|
+
*
|
|
143
|
+
* Closed, unlike a check: HLTH-2 enumerates the envelope exhaustively and no open question asks
|
|
144
|
+
* for a third member. The check object inside is where the open question lives.
|
|
145
|
+
*
|
|
146
|
+
* `checks` is required and may be empty. A Worker with no dependency worth reporting answers `{}`
|
|
147
|
+
* rather than omitting the member, so that every reader parses one shape.
|
|
148
|
+
*/
|
|
149
|
+
export declare const health: z.ZodObject<{
|
|
150
|
+
status: z.ZodEnum<{
|
|
151
|
+
degraded: "degraded";
|
|
152
|
+
healthy: "healthy";
|
|
153
|
+
unhealthy: "unhealthy";
|
|
154
|
+
}>;
|
|
155
|
+
checks: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
156
|
+
status: z.ZodEnum<{
|
|
157
|
+
degraded: "degraded";
|
|
158
|
+
healthy: "healthy";
|
|
159
|
+
unhealthy: "unhealthy";
|
|
160
|
+
}>;
|
|
161
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, z.core.$loose>>;
|
|
163
|
+
}, z.core.$strict>;
|
|
164
|
+
/**
|
|
165
|
+
* HLTH-1 — the `health` Capability entry, which requires the address the shared entry leaves
|
|
166
|
+
* optional. This is the extension DESC-22 promises each Capability's own file will define, and it
|
|
167
|
+
* is the first one.
|
|
168
|
+
*/
|
|
169
|
+
export declare const healthEntry: z.ZodObject<{
|
|
170
|
+
version: z.ZodNumber;
|
|
171
|
+
address: z.ZodString;
|
|
172
|
+
}, z.core.$loose>;
|
|
173
|
+
/**
|
|
174
|
+
* DESC-1, DESC-2, DESC-6, DESC-22, DESC-23 — the document every Worker serves.
|
|
175
|
+
*
|
|
176
|
+
* Closed on purpose: the rules above enumerate what a Descriptor carries, and a new top-level
|
|
177
|
+
* member is what an edition is for (DESC-23). A Worker extends its entries, not its Descriptor.
|
|
178
|
+
*
|
|
179
|
+
* `strictObject`, not `object`, so that the Zod objects other packages consume and the JSON
|
|
180
|
+
* Schema generated from them agree about the same document. Zod's default object STRIPS an
|
|
181
|
+
* unknown key while the generated `additionalProperties: false` REJECTS it — a TypeScript
|
|
182
|
+
* consumer and a Python one would otherwise reach opposite verdicts on one Descriptor.
|
|
183
|
+
*/
|
|
184
|
+
/**
|
|
185
|
+
* TASK-31 — what a Worker declares about one Skill, which today is nothing.
|
|
186
|
+
*
|
|
187
|
+
* Empty and strict on purpose. A Skill carries no declaration yet, and the shape for *nothing yet*
|
|
188
|
+
* is the one an optional member can join without invalidating a document already written — which
|
|
189
|
+
* NAME-5 calls compatible. A list of names could only have grown by becoming this, and becoming
|
|
190
|
+
* this later would have cost every Worker that declared a Skill a rewrite.
|
|
191
|
+
*/
|
|
192
|
+
export declare const skillDeclaration: z.ZodObject<{
|
|
193
|
+
payload: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
194
|
+
produces: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
195
|
+
}, z.core.$strict>;
|
|
196
|
+
export declare const descriptor: z.ZodObject<{
|
|
197
|
+
id: z.ZodString;
|
|
198
|
+
edition: z.ZodString;
|
|
199
|
+
skills: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
200
|
+
payload: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
201
|
+
produces: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
202
|
+
}, z.core.$strict>>>;
|
|
203
|
+
capabilities: z.ZodRecord<z.ZodUnion<readonly [z.ZodEnum<{
|
|
204
|
+
actions: "actions";
|
|
205
|
+
activity: "activity";
|
|
206
|
+
alerts: "alerts";
|
|
207
|
+
events: "events";
|
|
208
|
+
health: "health";
|
|
209
|
+
metrics: "metrics";
|
|
210
|
+
nudges: "nudges";
|
|
211
|
+
tasks: "tasks";
|
|
212
|
+
}>, z.ZodString]>, z.ZodObject<{
|
|
213
|
+
version: z.ZodNumber;
|
|
214
|
+
address: z.ZodOptional<z.ZodString>;
|
|
215
|
+
}, z.core.$loose>>;
|
|
216
|
+
}, z.core.$strict>;
|
|
217
|
+
/**
|
|
218
|
+
* ENDP-25 — the closed code enumeration, split by the class each code carries.
|
|
219
|
+
*
|
|
220
|
+
* Every code names a condition some rule in `spec/` already states; none was invented to fill a
|
|
221
|
+
* gap. endpoints.md holds the other half of ENDP-26 — which status each code is answered with —
|
|
222
|
+
* because a status code is not in the body and no schema can assert it.
|
|
223
|
+
*/
|
|
224
|
+
export declare const rejectCodes: readonly ["malformed_request", "invalid_parameter", "unknown_filter", "unsupported_version", "idempotency_key_required", "unauthenticated", "forbidden", "not_found", "conflict", "idempotency_key_reused", "unprocessable_content", "schema_mismatch"];
|
|
225
|
+
export declare const retryCodes: readonly ["request_timeout", "rate_limited", "internal_error", "unavailable", "upstream_error", "upstream_timeout"];
|
|
226
|
+
/**
|
|
227
|
+
* ENDP-25, ENDP-26 — the envelope every response that is not a success carries.
|
|
228
|
+
*
|
|
229
|
+
* A union of two branches rather than one object with two independent fields, because ENDP-26
|
|
230
|
+
* says a code carries its class. Written as one object, `not_found` with a class of `retry` would
|
|
231
|
+
* validate cleanly and defeat the thing the class exists for. Written this way, the constraint
|
|
232
|
+
* holds in the Zod object and in the generated JSON alike, with no rule stated in only one of
|
|
233
|
+
* them.
|
|
234
|
+
*
|
|
235
|
+
* Each branch is loose: endpoints.md records as open whether the envelope carries structured
|
|
236
|
+
* detail beyond these three, and closing it here would answer that question by accident, in the
|
|
237
|
+
* artifact prose defers to.
|
|
238
|
+
*/
|
|
239
|
+
export declare const error: z.ZodUnion<readonly [z.ZodObject<{
|
|
240
|
+
code: z.ZodEnum<{
|
|
241
|
+
conflict: "conflict";
|
|
242
|
+
forbidden: "forbidden";
|
|
243
|
+
idempotency_key_required: "idempotency_key_required";
|
|
244
|
+
idempotency_key_reused: "idempotency_key_reused";
|
|
245
|
+
invalid_parameter: "invalid_parameter";
|
|
246
|
+
malformed_request: "malformed_request";
|
|
247
|
+
not_found: "not_found";
|
|
248
|
+
schema_mismatch: "schema_mismatch";
|
|
249
|
+
unauthenticated: "unauthenticated";
|
|
250
|
+
unknown_filter: "unknown_filter";
|
|
251
|
+
unprocessable_content: "unprocessable_content";
|
|
252
|
+
unsupported_version: "unsupported_version";
|
|
253
|
+
}>;
|
|
254
|
+
message: z.ZodString;
|
|
255
|
+
class: z.ZodLiteral<"reject">;
|
|
256
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
257
|
+
code: z.ZodEnum<{
|
|
258
|
+
internal_error: "internal_error";
|
|
259
|
+
rate_limited: "rate_limited";
|
|
260
|
+
request_timeout: "request_timeout";
|
|
261
|
+
unavailable: "unavailable";
|
|
262
|
+
upstream_error: "upstream_error";
|
|
263
|
+
upstream_timeout: "upstream_timeout";
|
|
264
|
+
}>;
|
|
265
|
+
message: z.ZodString;
|
|
266
|
+
class: z.ZodLiteral<"retry">;
|
|
267
|
+
}, z.core.$loose>]>;
|
|
268
|
+
/**
|
|
269
|
+
* ENDP-20, ENDP-21 — the envelope every surface that answers a list answers it in.
|
|
270
|
+
*
|
|
271
|
+
* Closed, unlike the error envelope, because ENDP-20 enumerates the envelope exhaustively and
|
|
272
|
+
* no open question asks for more. A surface that needs a third member is asking for a change to
|
|
273
|
+
* ENDP-20, which is a thing the register can see.
|
|
274
|
+
*/
|
|
275
|
+
export declare const page: z.ZodObject<{
|
|
276
|
+
items: z.ZodArray<z.ZodUnknown>;
|
|
277
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
278
|
+
}, z.core.$strict>;
|
|
279
|
+
/**
|
|
280
|
+
* MET-3 — the five periods a metric may accumulate over, and the only five.
|
|
281
|
+
*
|
|
282
|
+
* Closed because a console renders a period selector from what a metric declares, and an arbitrary
|
|
283
|
+
* duration would make that a free-text box. It is also where accumulation stops being a time
|
|
284
|
+
* series, which is the distinction this Capability rests on.
|
|
285
|
+
*/
|
|
286
|
+
export declare const metricGranularity: z.ZodEnum<{
|
|
287
|
+
day: "day";
|
|
288
|
+
hour: "hour";
|
|
289
|
+
month: "month";
|
|
290
|
+
week: "week";
|
|
291
|
+
year: "year";
|
|
292
|
+
}>;
|
|
293
|
+
/**
|
|
294
|
+
* MET-4 — one dimension a metric is broken down by, held under its name.
|
|
295
|
+
*
|
|
296
|
+
* `values` absent is the free case and is not the same as an empty list, which is why the minimum
|
|
297
|
+
* is 1: a dimension that declared no possible value could never be filtered to anything, and
|
|
298
|
+
* MET-17 would answer `400` for every value a caller sent.
|
|
299
|
+
*
|
|
300
|
+
* Declaring the set buys two different things, which is why metrics.md spends two rules on it:
|
|
301
|
+
* MET-17 refuses a value outside it, and MET-19 grants the dimension the right to be broken down
|
|
302
|
+
* by — a free dimension is filtered and never grouped, because nothing would bound the answer.
|
|
303
|
+
*/
|
|
304
|
+
/**
|
|
305
|
+
* MET-5, MET-16 — the characters a dimension name may use: what a query parameter needs, and no
|
|
306
|
+
* more. Shared between the declaration, the bucket and the `by` parameter so the three agree.
|
|
307
|
+
*/
|
|
308
|
+
export declare const DIMENSION_NAME: RegExp;
|
|
309
|
+
export declare const metricDimension: z.ZodObject<{
|
|
310
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
311
|
+
}, z.core.$strict>;
|
|
312
|
+
/**
|
|
313
|
+
* MET-21, MET-3, MET-4 — what a Worker declares about one metric.
|
|
314
|
+
*
|
|
315
|
+
* Closed: MET-3 and MET-4 enumerate the declaration, and no open question in metrics.md asks for
|
|
316
|
+
* another member of it. A member added later is what an edition is for, which is DESC-23.
|
|
317
|
+
*
|
|
318
|
+
* `dimensions` is required and may be empty, for the reason `checks` is in `health`: one shape for
|
|
319
|
+
* every reader, rather than a member whose absence and whose emptiness say the same thing.
|
|
320
|
+
*/
|
|
321
|
+
export declare const metricDeclaration: z.ZodObject<{
|
|
322
|
+
unit: z.ZodString;
|
|
323
|
+
additive: z.ZodBoolean;
|
|
324
|
+
granularities: z.ZodArray<z.ZodEnum<{
|
|
325
|
+
day: "day";
|
|
326
|
+
hour: "hour";
|
|
327
|
+
month: "month";
|
|
328
|
+
week: "week";
|
|
329
|
+
year: "year";
|
|
330
|
+
}>>;
|
|
331
|
+
dimensions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
332
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
333
|
+
}, z.core.$strict>>;
|
|
334
|
+
}, z.core.$strict>;
|
|
335
|
+
/**
|
|
336
|
+
* MET-6 — an IANA Time Zone Database name.
|
|
337
|
+
*
|
|
338
|
+
* The separator is written `[/]` rather than `\/` so the generated pattern carries no JavaScript
|
|
339
|
+
* escape. A regular expression literal cannot hold a bare `/` outside a character class, and `\/`
|
|
340
|
+
* is an escape ECMA-262 accepts and Java refuses outright — a runtime's fingerprint smuggled into
|
|
341
|
+
* the normative artifact, which is the same thing the generator strips a safe-integer bound for.
|
|
342
|
+
*
|
|
343
|
+
* The pattern refuses the common wrong answers — an offset like `-03:00`, an abbreviation like
|
|
344
|
+
* `ART` — and asserts nothing about whether the zone exists. No schema can check a name against
|
|
345
|
+
* a database that ships with the reader.
|
|
346
|
+
*/
|
|
347
|
+
export declare const timeZone: z.ZodString;
|
|
348
|
+
/**
|
|
349
|
+
* MET-1, MET-21, MET-6 — the `metrics` Capability entry.
|
|
350
|
+
*
|
|
351
|
+
* The address is required, as HLTH-1 requires it, because this Capability is answered over HTTP.
|
|
352
|
+
*/
|
|
353
|
+
export declare const metricsEntry: z.ZodObject<{
|
|
354
|
+
version: z.ZodNumber;
|
|
355
|
+
address: z.ZodString;
|
|
356
|
+
timeZone: z.ZodString;
|
|
357
|
+
publishes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
358
|
+
unit: z.ZodString;
|
|
359
|
+
additive: z.ZodBoolean;
|
|
360
|
+
granularities: z.ZodArray<z.ZodEnum<{
|
|
361
|
+
day: "day";
|
|
362
|
+
hour: "hour";
|
|
363
|
+
month: "month";
|
|
364
|
+
week: "week";
|
|
365
|
+
year: "year";
|
|
366
|
+
}>>;
|
|
367
|
+
dimensions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
368
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
369
|
+
}, z.core.$strict>>;
|
|
370
|
+
}, z.core.$strict>>;
|
|
371
|
+
}, z.core.$loose>;
|
|
372
|
+
/**
|
|
373
|
+
* An RFC 3339 instant carrying an offset — MET-13, TASK-28 and ALRT-3 all take one.
|
|
374
|
+
*
|
|
375
|
+
* `format` is an annotation in Draft 2020-12 unless a validator opts into format-assertion, so the
|
|
376
|
+
* pattern is what binds. It admits a wrong date — the 31st of February — because a regular
|
|
377
|
+
* expression that ruled those out would be unreadable, and a Worker that emits one has a bug no
|
|
378
|
+
* schema was going to find.
|
|
379
|
+
*/
|
|
380
|
+
export declare const INSTANT: RegExp;
|
|
381
|
+
/**
|
|
382
|
+
* MET-12, MET-13, MET-15, MET-19 — one bucket.
|
|
383
|
+
*
|
|
384
|
+
* Closed, and it carries no name, unit or granularity: MET-8 has the caller name the metric and,
|
|
385
|
+
* where there is a choice, the granularity, and MET-21 has it read the unit from the Descriptor
|
|
386
|
+
* before it calls. Repeating any of them here would be a second place for them to disagree.
|
|
387
|
+
*
|
|
388
|
+
* It carries no status and no judgment of any kind. metrics.md answers `how much` and stops: a
|
|
389
|
+
* Worker that decides one of its own numbers is wrong raises an Alert, and what is inside a
|
|
390
|
+
* Worker's settings is not a thing this surface has a view of.
|
|
391
|
+
*/
|
|
392
|
+
export declare const metricBucket: z.ZodObject<{
|
|
393
|
+
start: z.ZodString;
|
|
394
|
+
end: z.ZodString;
|
|
395
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
396
|
+
dimensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
397
|
+
}, z.core.$strict>;
|
|
398
|
+
/**
|
|
399
|
+
* MET-14 — what a read answers: the shared page envelope with its items narrowed, which is the
|
|
400
|
+
* narrowing ENDP-20 says each surface's own schema performs.
|
|
401
|
+
*/
|
|
402
|
+
export declare const metricPage: z.ZodObject<{
|
|
403
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
404
|
+
items: z.ZodArray<z.ZodObject<{
|
|
405
|
+
start: z.ZodString;
|
|
406
|
+
end: z.ZodString;
|
|
407
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
408
|
+
dimensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
409
|
+
}, z.core.$strict>>;
|
|
410
|
+
}, z.core.$strict>;
|
|
411
|
+
/**
|
|
412
|
+
* ACT-12 — the declaration ENDP-15 requires of an Action that takes an idempotency key.
|
|
413
|
+
*
|
|
414
|
+
* A union rather than one object with an optional member, on the same reasoning that makes `error`
|
|
415
|
+
* a union: written flat, `from: "input"` with no member named would validate cleanly and leave the
|
|
416
|
+
* Worker with nowhere to read the key from. The two branches make the half-set state unspellable.
|
|
417
|
+
*/
|
|
418
|
+
export declare const idempotencyDeclaration: z.ZodUnion<readonly [z.ZodObject<{
|
|
419
|
+
required: z.ZodBoolean;
|
|
420
|
+
from: z.ZodLiteral<"header">;
|
|
421
|
+
windowSeconds: z.ZodNumber;
|
|
422
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
423
|
+
required: z.ZodBoolean;
|
|
424
|
+
from: z.ZodLiteral<"input">;
|
|
425
|
+
member: z.ZodString;
|
|
426
|
+
windowSeconds: z.ZodNumber;
|
|
427
|
+
}, z.core.$strict>]>;
|
|
428
|
+
/**
|
|
429
|
+
* ACT-2, ACT-3, ACT-4 — what a Worker declares about one Action.
|
|
430
|
+
*
|
|
431
|
+
* Closed: these rules enumerate the declaration, and a member added later is what an edition is
|
|
432
|
+
* for. The schemas INSIDE it are the Worker's own and are not constrained here — this protocol has
|
|
433
|
+
* no data model, and an Action's input is exactly where that matters most.
|
|
434
|
+
*/
|
|
435
|
+
export declare const actionDeclaration: z.ZodObject<{
|
|
436
|
+
input: z.ZodObject<{}, z.core.$loose>;
|
|
437
|
+
result: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
438
|
+
completesWithinCall: z.ZodBoolean;
|
|
439
|
+
idempotency: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
440
|
+
required: z.ZodBoolean;
|
|
441
|
+
from: z.ZodLiteral<"header">;
|
|
442
|
+
windowSeconds: z.ZodNumber;
|
|
443
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
444
|
+
required: z.ZodBoolean;
|
|
445
|
+
from: z.ZodLiteral<"input">;
|
|
446
|
+
member: z.ZodString;
|
|
447
|
+
windowSeconds: z.ZodNumber;
|
|
448
|
+
}, z.core.$strict>]>>;
|
|
449
|
+
readAddress: z.ZodOptional<z.ZodString>;
|
|
450
|
+
}, z.core.$strict>;
|
|
451
|
+
/**
|
|
452
|
+
* ACT-16 — the `actions` Capability entry.
|
|
453
|
+
*
|
|
454
|
+
* The address is required, as HLTH-1 and MET-1 require it, because this Capability is answered
|
|
455
|
+
* over HTTP. One address for the Capability and a parameter naming the Action, which is the shape
|
|
456
|
+
* `metrics` already uses — actions.md argues the two alternatives down at length.
|
|
457
|
+
*/
|
|
458
|
+
export declare const actionsEntry: z.ZodObject<{
|
|
459
|
+
version: z.ZodNumber;
|
|
460
|
+
address: z.ZodString;
|
|
461
|
+
accepts: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
462
|
+
input: z.ZodObject<{}, z.core.$loose>;
|
|
463
|
+
result: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
464
|
+
completesWithinCall: z.ZodBoolean;
|
|
465
|
+
idempotency: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
466
|
+
required: z.ZodBoolean;
|
|
467
|
+
from: z.ZodLiteral<"header">;
|
|
468
|
+
windowSeconds: z.ZodNumber;
|
|
469
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
470
|
+
required: z.ZodBoolean;
|
|
471
|
+
from: z.ZodLiteral<"input">;
|
|
472
|
+
member: z.ZodString;
|
|
473
|
+
windowSeconds: z.ZodNumber;
|
|
474
|
+
}, z.core.$strict>]>>;
|
|
475
|
+
readAddress: z.ZodOptional<z.ZodString>;
|
|
476
|
+
}, z.core.$strict>>;
|
|
477
|
+
}, z.core.$loose>;
|
|
478
|
+
/**
|
|
479
|
+
* TASK-32 — one Task type a Worker raises.
|
|
480
|
+
*
|
|
481
|
+
* The Actions named here are the OWNER's own, declared in its `actions` entry: a Response is an
|
|
482
|
+
* Action posted into the owner, so the closed list is a list of names that entry holds.
|
|
483
|
+
*/
|
|
484
|
+
export declare const taskTypeDeclaration: z.ZodObject<{
|
|
485
|
+
payload: z.ZodObject<{}, z.core.$loose>;
|
|
486
|
+
answeredBy: z.ZodString;
|
|
487
|
+
}, z.core.$strict>;
|
|
488
|
+
/**
|
|
489
|
+
* TASK-27, TASK-32 — the `tasks` Capability entry.
|
|
490
|
+
*
|
|
491
|
+
* One address, and a read. The entry carried a second one a claim was posted to until the Claim
|
|
492
|
+
* lifecycle was withdrawn; `spec/tasks.md` holds the argument, and the short of it is that a lease
|
|
493
|
+
* over a unit of work is orchestration, which this specification names a non-goal.
|
|
494
|
+
*
|
|
495
|
+
* It carried a third thing until TASK-31 moved it: what the Worker ANSWERS, which is served at no
|
|
496
|
+
* address and is now `skills` on the Descriptor's root. What is left here is what the declared
|
|
497
|
+
* address actually answers instances of.
|
|
498
|
+
*/
|
|
499
|
+
export declare const tasksEntry: z.ZodObject<{
|
|
500
|
+
version: z.ZodNumber;
|
|
501
|
+
address: z.ZodString;
|
|
502
|
+
raises: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
503
|
+
payload: z.ZodObject<{}, z.core.$loose>;
|
|
504
|
+
answeredBy: z.ZodString;
|
|
505
|
+
}, z.core.$strict>>;
|
|
506
|
+
}, z.core.$loose>;
|
|
507
|
+
/**
|
|
508
|
+
* TASK-28 — one Task on the wire.
|
|
509
|
+
*
|
|
510
|
+
* It carries no status and nothing anybody declared about it. A Task exists while its condition
|
|
511
|
+
* holds (TASK-15) and disappears when it stops, so there is no state for a reader to interpret;
|
|
512
|
+
* what a reader needs is what it is, what would answer it, and how long it has been true.
|
|
513
|
+
*/
|
|
514
|
+
export declare const task: z.ZodObject<{
|
|
515
|
+
id: z.ZodString;
|
|
516
|
+
type: z.ZodString;
|
|
517
|
+
payload: z.ZodUnknown;
|
|
518
|
+
since: z.ZodString;
|
|
519
|
+
}, z.core.$strict>;
|
|
520
|
+
/** TASK-5 — what a read answers: the shared page envelope with its items narrowed to Tasks. */
|
|
521
|
+
export declare const taskPage: z.ZodObject<{
|
|
522
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
523
|
+
items: z.ZodArray<z.ZodObject<{
|
|
524
|
+
id: z.ZodString;
|
|
525
|
+
type: z.ZodString;
|
|
526
|
+
payload: z.ZodUnknown;
|
|
527
|
+
since: z.ZodString;
|
|
528
|
+
}, z.core.$strict>>;
|
|
529
|
+
}, z.core.$strict>;
|
|
530
|
+
/**
|
|
531
|
+
* ALRT-4 — the two severities, and the only two.
|
|
532
|
+
*
|
|
533
|
+
* The contrast with `healthStatus` is the argument rather than an inconsistency. `degraded` earns
|
|
534
|
+
* a third value there because a Worker working with one dependency down has a real state with no
|
|
535
|
+
* honest spelling in two. Here the only decision an operator takes is whether to look now, and a
|
|
536
|
+
* third value would be a place to hedge rather than a state anybody needed to express.
|
|
537
|
+
*/
|
|
538
|
+
export declare const alertSeverity: z.ZodEnum<{
|
|
539
|
+
critical: "critical";
|
|
540
|
+
warning: "warning";
|
|
541
|
+
}>;
|
|
542
|
+
/**
|
|
543
|
+
* ALRT-3 — one Alert.
|
|
544
|
+
*
|
|
545
|
+
* It carries no status and nothing anybody declared about it, for the reason a Task does not: an
|
|
546
|
+
* Alert exists while its condition holds and ends when it stops (ALRT-5), so there is no state for
|
|
547
|
+
* a reader to interpret and no dismissal for anyone to record.
|
|
548
|
+
*/
|
|
549
|
+
export declare const alert: z.ZodObject<{
|
|
550
|
+
id: z.ZodString;
|
|
551
|
+
severity: z.ZodEnum<{
|
|
552
|
+
critical: "critical";
|
|
553
|
+
warning: "warning";
|
|
554
|
+
}>;
|
|
555
|
+
since: z.ZodString;
|
|
556
|
+
summary: z.ZodString;
|
|
557
|
+
actions: z.ZodArray<z.ZodString>;
|
|
558
|
+
}, z.core.$strict>;
|
|
559
|
+
/** ALRT-2 — what a read answers: the page envelope with its items narrowed to Alerts. */
|
|
560
|
+
export declare const alertPage: z.ZodObject<{
|
|
561
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
562
|
+
items: z.ZodArray<z.ZodObject<{
|
|
563
|
+
id: z.ZodString;
|
|
564
|
+
severity: z.ZodEnum<{
|
|
565
|
+
critical: "critical";
|
|
566
|
+
warning: "warning";
|
|
567
|
+
}>;
|
|
568
|
+
since: z.ZodString;
|
|
569
|
+
summary: z.ZodString;
|
|
570
|
+
actions: z.ZodArray<z.ZodString>;
|
|
571
|
+
}, z.core.$strict>>;
|
|
572
|
+
}, z.core.$strict>;
|
|
573
|
+
/** NDG-2 — one nudge on the wire: a Task type, and nothing else. */
|
|
574
|
+
export declare const nudge: z.ZodObject<{
|
|
575
|
+
type: z.ZodString;
|
|
576
|
+
}, z.core.$strict>;
|
|
577
|
+
/** NDG-1 — the `nudges` Capability entry. The address is required: this is answered over HTTP. */
|
|
578
|
+
export declare const nudgesEntry: z.ZodObject<{
|
|
579
|
+
version: z.ZodNumber;
|
|
580
|
+
address: z.ZodString;
|
|
581
|
+
}, z.core.$loose>;
|
|
582
|
+
/** ALRT-1 — the `alerts` Capability entry. The address is required: this is answered over HTTP. */
|
|
583
|
+
export declare const alertsEntry: z.ZodObject<{
|
|
584
|
+
version: z.ZodNumber;
|
|
585
|
+
address: z.ZodString;
|
|
586
|
+
}, z.core.$loose>;
|
|
587
|
+
/**
|
|
588
|
+
* ACTV-4 — the three states an activity may be in, and the only three.
|
|
589
|
+
*
|
|
590
|
+
* Three rather than Alerts' two, on health's argument rather than alerts': a Worker that will run
|
|
591
|
+
* something at midnight and a Worker with four hundred items queued are both `not running`, and one
|
|
592
|
+
* word for both would make an operator unable to tell `backing up` from `waiting for its time`.
|
|
593
|
+
*/
|
|
594
|
+
export declare const activityState: z.ZodEnum<{
|
|
595
|
+
pending: "pending";
|
|
596
|
+
running: "running";
|
|
597
|
+
scheduled: "scheduled";
|
|
598
|
+
}>;
|
|
599
|
+
/**
|
|
600
|
+
* ACTV-3 — one activity.
|
|
601
|
+
*
|
|
602
|
+
* No type and no payload, deliberately: a payload with no declared schema is JSON nobody outside
|
|
603
|
+
* the Worker can validate or render, which is the blob alerts.md argues a protocol must not offer.
|
|
604
|
+
* The summary is for a person; the state is what a program acts on.
|
|
605
|
+
*/
|
|
606
|
+
export declare const activity: z.ZodObject<{
|
|
607
|
+
id: z.ZodString;
|
|
608
|
+
state: z.ZodEnum<{
|
|
609
|
+
pending: "pending";
|
|
610
|
+
running: "running";
|
|
611
|
+
scheduled: "scheduled";
|
|
612
|
+
}>;
|
|
613
|
+
since: z.ZodString;
|
|
614
|
+
summary: z.ZodString;
|
|
615
|
+
}, z.core.$strict>;
|
|
616
|
+
/** ACTV-2 — what a read answers: the page envelope with its items narrowed to activities. */
|
|
617
|
+
export declare const activityPage: z.ZodObject<{
|
|
618
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
619
|
+
items: z.ZodArray<z.ZodObject<{
|
|
620
|
+
id: z.ZodString;
|
|
621
|
+
state: z.ZodEnum<{
|
|
622
|
+
pending: "pending";
|
|
623
|
+
running: "running";
|
|
624
|
+
scheduled: "scheduled";
|
|
625
|
+
}>;
|
|
626
|
+
since: z.ZodString;
|
|
627
|
+
summary: z.ZodString;
|
|
628
|
+
}, z.core.$strict>>;
|
|
629
|
+
}, z.core.$strict>;
|
|
630
|
+
/** ACTV-1 — the `activity` Capability entry. The address is required: this is answered over HTTP. */
|
|
631
|
+
export declare const activityEntry: z.ZodObject<{
|
|
632
|
+
version: z.ZodNumber;
|
|
633
|
+
address: z.ZodString;
|
|
634
|
+
}, z.core.$loose>;
|
|
635
|
+
/**
|
|
636
|
+
* EVT-11 — where an event lands on the broker its entry declares.
|
|
637
|
+
*
|
|
638
|
+
* An object and not a string, because what a consumer needs in order to attach is not alike across
|
|
639
|
+
* brokers: a Kafka topic beside its bootstrap servers, an Event Hub inside a namespace, an SNS ARN
|
|
640
|
+
* with a region in it. One string would have made every consumer parse this Worker's own way of
|
|
641
|
+
* packing several facts into one, which is the work a catalog exists to remove.
|
|
642
|
+
*
|
|
643
|
+
* Open, and nothing here reads a key of it — the same move an Action's input already makes. What
|
|
644
|
+
* that costs is that two Workers on one broker may spell it differently; `spec/events.md` argues
|
|
645
|
+
* why a namespaced name would not have fixed it and convention is what does.
|
|
646
|
+
*/
|
|
647
|
+
export declare const eventDestination: z.ZodObject<{}, z.core.$loose>;
|
|
648
|
+
/** EVT-12, EVT-11 — one event type a Worker publishes. */
|
|
649
|
+
export declare const eventTypeDeclaration: z.ZodObject<{
|
|
650
|
+
data: z.ZodObject<{}, z.core.$loose>;
|
|
651
|
+
destination: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
652
|
+
}, z.core.$strict>;
|
|
653
|
+
/**
|
|
654
|
+
* EVT-11, EVT-12, EVT-8 — the `events` Capability entry.
|
|
655
|
+
*
|
|
656
|
+
* The one entry with NO address, which is the single reason DESC-22 leaves the address optional in
|
|
657
|
+
* the shared entry at all. An event travels over a broker this protocol declines to name, and a
|
|
658
|
+
* Worker with no HTTP surface for it would otherwise have had to invent a URL that does not exist.
|
|
659
|
+
*/
|
|
660
|
+
export declare const eventsEntry: z.ZodObject<{
|
|
661
|
+
version: z.ZodNumber;
|
|
662
|
+
address: z.ZodOptional<z.ZodString>;
|
|
663
|
+
broker: z.ZodString;
|
|
664
|
+
protocolBinding: z.ZodString;
|
|
665
|
+
destination: z.ZodObject<{}, z.core.$loose>;
|
|
666
|
+
publishes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
667
|
+
data: z.ZodObject<{}, z.core.$loose>;
|
|
668
|
+
destination: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
669
|
+
}, z.core.$strict>>;
|
|
670
|
+
republishWindowSeconds: z.ZodNumber;
|
|
671
|
+
}, z.core.$loose>;
|