@worker-protocol/hono 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.
@@ -0,0 +1,483 @@
1
+ import { type RouteConfig, z } from "@hono/zod-openapi";
2
+ /** ENDP-5 — on every protocol response, whatever it says. */
3
+ export declare const RESPONSE_HEADERS: {
4
+ readonly "Worker-Protocol-Edition": {
5
+ readonly description: string;
6
+ readonly required: true;
7
+ readonly schema: {
8
+ readonly type: "string";
9
+ readonly pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$";
10
+ };
11
+ };
12
+ readonly "Worker-Protocol-Capability-Version": {
13
+ readonly description: string;
14
+ readonly required: true;
15
+ readonly schema: {
16
+ readonly type: "integer";
17
+ readonly minimum: 1;
18
+ };
19
+ };
20
+ };
21
+ export declare const readDescriptor: {
22
+ method: "get";
23
+ path: "/.well-known/worker-protocol";
24
+ summary: string;
25
+ description: string;
26
+ request: {
27
+ headers: z.ZodObject<{
28
+ "Worker-Protocol-Capability-Version": z.ZodOptional<z.ZodCoercedNumber<unknown>>;
29
+ }, z.core.$strip>;
30
+ };
31
+ responses: {
32
+ 200: {
33
+ description: string;
34
+ headers: {
35
+ readonly "Worker-Protocol-Edition": {
36
+ readonly description: string;
37
+ readonly required: true;
38
+ readonly schema: {
39
+ readonly type: "string";
40
+ readonly pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$";
41
+ };
42
+ };
43
+ readonly "Worker-Protocol-Capability-Version": {
44
+ readonly description: string;
45
+ readonly required: true;
46
+ readonly schema: {
47
+ readonly type: "integer";
48
+ readonly minimum: 1;
49
+ };
50
+ };
51
+ };
52
+ content?: {
53
+ "application/json": {
54
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
55
+ };
56
+ } | undefined;
57
+ };
58
+ };
59
+ } & {
60
+ getRoutingPath(): "/.well-known/worker-protocol";
61
+ };
62
+ export declare const pollHealth: {
63
+ method: "get";
64
+ path: "/";
65
+ summary: string;
66
+ description: string;
67
+ request: {
68
+ headers: z.ZodObject<{
69
+ "Worker-Protocol-Capability-Version": z.ZodOptional<z.ZodCoercedNumber<unknown>>;
70
+ }, z.core.$strip>;
71
+ };
72
+ responses: {
73
+ 200: {
74
+ description: string;
75
+ headers: {
76
+ readonly "Worker-Protocol-Edition": {
77
+ readonly description: string;
78
+ readonly required: true;
79
+ readonly schema: {
80
+ readonly type: "string";
81
+ readonly pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$";
82
+ };
83
+ };
84
+ readonly "Worker-Protocol-Capability-Version": {
85
+ readonly description: string;
86
+ readonly required: true;
87
+ readonly schema: {
88
+ readonly type: "integer";
89
+ readonly minimum: 1;
90
+ };
91
+ };
92
+ };
93
+ content?: {
94
+ "application/json": {
95
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
96
+ };
97
+ } | undefined;
98
+ };
99
+ };
100
+ } & {
101
+ getRoutingPath(): "/";
102
+ };
103
+ export declare const readMetric: {
104
+ method: "get";
105
+ path: "/";
106
+ summary: string;
107
+ description: string;
108
+ request: {
109
+ query: z.ZodObject<{
110
+ metric: z.ZodString;
111
+ granularity: z.ZodOptional<z.ZodEnum<{
112
+ day: "day";
113
+ hour: "hour";
114
+ month: "month";
115
+ week: "week";
116
+ year: "year";
117
+ }>>;
118
+ from: z.ZodOptional<z.ZodString>;
119
+ to: z.ZodOptional<z.ZodString>;
120
+ by: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodString>>, unknown>;
121
+ dimensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
122
+ cursor: z.ZodOptional<z.ZodString>;
123
+ }, z.core.$strip>;
124
+ headers: z.ZodObject<{
125
+ "Worker-Protocol-Capability-Version": z.ZodOptional<z.ZodCoercedNumber<unknown>>;
126
+ }, z.core.$strip>;
127
+ };
128
+ responses: {
129
+ 200: {
130
+ description: string;
131
+ headers: {
132
+ readonly "Worker-Protocol-Edition": {
133
+ readonly description: string;
134
+ readonly required: true;
135
+ readonly schema: {
136
+ readonly type: "string";
137
+ readonly pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$";
138
+ };
139
+ };
140
+ readonly "Worker-Protocol-Capability-Version": {
141
+ readonly description: string;
142
+ readonly required: true;
143
+ readonly schema: {
144
+ readonly type: "integer";
145
+ readonly minimum: 1;
146
+ };
147
+ };
148
+ };
149
+ content?: {
150
+ "application/json": {
151
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
152
+ };
153
+ } | undefined;
154
+ };
155
+ };
156
+ } & {
157
+ getRoutingPath(): "/";
158
+ };
159
+ export declare const performAction: {
160
+ method: "post";
161
+ path: "/";
162
+ summary: string;
163
+ description: string;
164
+ request: {
165
+ query: z.ZodObject<{
166
+ action: z.ZodString;
167
+ }, z.core.$strip>;
168
+ headers: z.ZodObject<{
169
+ "Idempotency-Key": z.ZodOptional<z.ZodString>;
170
+ "Worker-Protocol-Capability-Version": z.ZodOptional<z.ZodCoercedNumber<unknown>>;
171
+ }, z.core.$strip>;
172
+ body: {
173
+ required: true;
174
+ description: string;
175
+ content: {
176
+ "application/json": {
177
+ schema: never;
178
+ };
179
+ };
180
+ };
181
+ };
182
+ responses: {
183
+ 200: {
184
+ description: string;
185
+ headers: {
186
+ readonly "Worker-Protocol-Edition": {
187
+ readonly description: string;
188
+ readonly required: true;
189
+ readonly schema: {
190
+ readonly type: "string";
191
+ readonly pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$";
192
+ };
193
+ };
194
+ readonly "Worker-Protocol-Capability-Version": {
195
+ readonly description: string;
196
+ readonly required: true;
197
+ readonly schema: {
198
+ readonly type: "integer";
199
+ readonly minimum: 1;
200
+ };
201
+ };
202
+ };
203
+ content?: {
204
+ "application/json": {
205
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
206
+ };
207
+ } | undefined;
208
+ };
209
+ 204: {
210
+ description: string;
211
+ headers: {
212
+ readonly "Worker-Protocol-Edition": {
213
+ readonly description: string;
214
+ readonly required: true;
215
+ readonly schema: {
216
+ readonly type: "string";
217
+ readonly pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$";
218
+ };
219
+ };
220
+ readonly "Worker-Protocol-Capability-Version": {
221
+ readonly description: string;
222
+ readonly required: true;
223
+ readonly schema: {
224
+ readonly type: "integer";
225
+ readonly minimum: 1;
226
+ };
227
+ };
228
+ };
229
+ content?: {
230
+ "application/json": {
231
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
232
+ };
233
+ } | undefined;
234
+ };
235
+ 202: {
236
+ description: string;
237
+ headers: {
238
+ readonly "Worker-Protocol-Edition": {
239
+ readonly description: string;
240
+ readonly required: true;
241
+ readonly schema: {
242
+ readonly type: "string";
243
+ readonly pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$";
244
+ };
245
+ };
246
+ readonly "Worker-Protocol-Capability-Version": {
247
+ readonly description: string;
248
+ readonly required: true;
249
+ readonly schema: {
250
+ readonly type: "integer";
251
+ readonly minimum: 1;
252
+ };
253
+ };
254
+ };
255
+ content?: {
256
+ "application/json": {
257
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
258
+ };
259
+ } | undefined;
260
+ };
261
+ };
262
+ } & {
263
+ getRoutingPath(): "/";
264
+ };
265
+ export declare const readTasks: {
266
+ method: "get";
267
+ path: "/";
268
+ summary: string;
269
+ description: string;
270
+ request: {
271
+ query: z.ZodObject<{
272
+ type: z.ZodOptional<z.ZodString>;
273
+ cursor: z.ZodOptional<z.ZodString>;
274
+ }, z.core.$strip>;
275
+ headers: z.ZodObject<{
276
+ "Worker-Protocol-Capability-Version": z.ZodOptional<z.ZodCoercedNumber<unknown>>;
277
+ }, z.core.$strip>;
278
+ };
279
+ responses: {
280
+ 200: {
281
+ description: string;
282
+ headers: {
283
+ readonly "Worker-Protocol-Edition": {
284
+ readonly description: string;
285
+ readonly required: true;
286
+ readonly schema: {
287
+ readonly type: "string";
288
+ readonly pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$";
289
+ };
290
+ };
291
+ readonly "Worker-Protocol-Capability-Version": {
292
+ readonly description: string;
293
+ readonly required: true;
294
+ readonly schema: {
295
+ readonly type: "integer";
296
+ readonly minimum: 1;
297
+ };
298
+ };
299
+ };
300
+ content?: {
301
+ "application/json": {
302
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
303
+ };
304
+ } | undefined;
305
+ };
306
+ };
307
+ } & {
308
+ getRoutingPath(): "/";
309
+ };
310
+ export declare const takeNudge: {
311
+ method: "post";
312
+ path: "/";
313
+ summary: string;
314
+ description: string;
315
+ request: {
316
+ headers: z.ZodObject<{
317
+ "Worker-Protocol-Capability-Version": z.ZodOptional<z.ZodCoercedNumber<unknown>>;
318
+ }, z.core.$strip>;
319
+ body: {
320
+ required: true;
321
+ description: string;
322
+ content: {
323
+ "application/json": {
324
+ schema: never;
325
+ };
326
+ };
327
+ };
328
+ };
329
+ responses: {
330
+ 204: {
331
+ description: string;
332
+ headers: {
333
+ readonly "Worker-Protocol-Edition": {
334
+ readonly description: string;
335
+ readonly required: true;
336
+ readonly schema: {
337
+ readonly type: "string";
338
+ readonly pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$";
339
+ };
340
+ };
341
+ readonly "Worker-Protocol-Capability-Version": {
342
+ readonly description: string;
343
+ readonly required: true;
344
+ readonly schema: {
345
+ readonly type: "integer";
346
+ readonly minimum: 1;
347
+ };
348
+ };
349
+ };
350
+ content?: {
351
+ "application/json": {
352
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
353
+ };
354
+ } | undefined;
355
+ };
356
+ };
357
+ } & {
358
+ getRoutingPath(): "/";
359
+ };
360
+ export declare const readAlerts: {
361
+ method: "get";
362
+ path: "/";
363
+ summary: string;
364
+ description: string;
365
+ request: {
366
+ query: z.ZodObject<{
367
+ cursor: z.ZodOptional<z.ZodString>;
368
+ }, z.core.$strip>;
369
+ headers: z.ZodObject<{
370
+ "Worker-Protocol-Capability-Version": z.ZodOptional<z.ZodCoercedNumber<unknown>>;
371
+ }, z.core.$strip>;
372
+ };
373
+ responses: {
374
+ 200: {
375
+ description: string;
376
+ headers: {
377
+ readonly "Worker-Protocol-Edition": {
378
+ readonly description: string;
379
+ readonly required: true;
380
+ readonly schema: {
381
+ readonly type: "string";
382
+ readonly pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$";
383
+ };
384
+ };
385
+ readonly "Worker-Protocol-Capability-Version": {
386
+ readonly description: string;
387
+ readonly required: true;
388
+ readonly schema: {
389
+ readonly type: "integer";
390
+ readonly minimum: 1;
391
+ };
392
+ };
393
+ };
394
+ content?: {
395
+ "application/json": {
396
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
397
+ };
398
+ } | undefined;
399
+ };
400
+ };
401
+ } & {
402
+ getRoutingPath(): "/";
403
+ };
404
+ export declare const readActivity: {
405
+ method: "get";
406
+ path: "/";
407
+ summary: string;
408
+ description: string;
409
+ request: {
410
+ query: z.ZodObject<{
411
+ cursor: z.ZodOptional<z.ZodString>;
412
+ }, z.core.$strip>;
413
+ headers: z.ZodObject<{
414
+ "Worker-Protocol-Capability-Version": z.ZodOptional<z.ZodCoercedNumber<unknown>>;
415
+ }, z.core.$strip>;
416
+ };
417
+ responses: {
418
+ 200: {
419
+ description: string;
420
+ headers: {
421
+ readonly "Worker-Protocol-Edition": {
422
+ readonly description: string;
423
+ readonly required: true;
424
+ readonly schema: {
425
+ readonly type: "string";
426
+ readonly pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$";
427
+ };
428
+ };
429
+ readonly "Worker-Protocol-Capability-Version": {
430
+ readonly description: string;
431
+ readonly required: true;
432
+ readonly schema: {
433
+ readonly type: "integer";
434
+ readonly minimum: 1;
435
+ };
436
+ };
437
+ };
438
+ content?: {
439
+ "application/json": {
440
+ schema: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
441
+ };
442
+ } | undefined;
443
+ };
444
+ };
445
+ } & {
446
+ getRoutingPath(): "/";
447
+ };
448
+ export type Surface = {
449
+ /** The generated file, without `.json`. */
450
+ document: string;
451
+ /** The Capability, or `descriptor` for the one route this protocol fixes. */
452
+ capability: string;
453
+ /**
454
+ * The server variable this document is served under — which is a *declared address* and never a
455
+ * path. ENDP-1 says no reader assembles an address, so a generated client is constructed with
456
+ * one read from the Descriptor and resolved per DESC-12, and concatenates nothing.
457
+ */
458
+ server: {
459
+ variable: string;
460
+ rule: string;
461
+ description: string;
462
+ };
463
+ title: string;
464
+ description: string;
465
+ /** The route this document describes: one declared address, one operation. */
466
+ route: RouteConfig;
467
+ };
468
+ export declare const SURFACES: Surface[];
469
+ /**
470
+ * What this file deliberately does not describe.
471
+ *
472
+ * - **`events`.** It has no address: it travels over a broker this protocol declines to name, which
473
+ * is the one case DESC-22 leaves the shared entry's address optional for. There is no call to
474
+ * describe, and inventing a document for it would be the artifact claiming a surface the
475
+ * specification refuses to fix.
476
+ * - **Anything whose shape is the Worker's own.** An Action's input and result, a Task's payload, an
477
+ * event's data. Each is a JSON Schema a Worker declares in its Descriptor. A Worker that mounts
478
+ * these routes and asks its own app for a document gets them in it, because that document is
479
+ * generated from that Worker's routes and not from this file.
480
+ * - **A dimension named as a query parameter.** MET-16 spells a dimension into a parameter of its
481
+ * own name, and those names are the Worker's. `dimensions` above is the OpenAPI shape for that
482
+ * and never travels under its own name.
483
+ */