typespec-http-zod 0.28.0 → 0.30.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/src/api.d.ts +43 -0
- package/dist/src/api.js +342 -57
- package/dist/src/constraints.d.ts +15 -0
- package/dist/src/constraints.js +46 -12
- package/dist/src/lib.d.ts +37 -1
- package/dist/src/lib.js +80 -0
- package/dist/src/literal.d.ts +27 -0
- package/dist/src/literal.js +33 -0
- package/dist/src/registry.js +30 -7
- package/dist/src/results.js +2 -1
- package/dist/src/types.js +34 -10
- package/dist/src/uri-template.d.ts +0 -12
- package/dist/src/uri-template.js +3 -2
- package/dist/src/zod.d.ts +78 -0
- package/dist/src/zod.js +366 -35
- package/package.json +1 -1
package/dist/src/api.d.ts
CHANGED
|
@@ -48,6 +48,12 @@ export { EmitterOptionsSchema, type EmitterOptions } from "./lib.js";
|
|
|
48
48
|
* independently.
|
|
49
49
|
*/
|
|
50
50
|
export { jsDocComment, objectKey } from "./zod.js";
|
|
51
|
+
/**
|
|
52
|
+
* And the same for a VALUE written into emitted code: a string, enum value or media type as a literal
|
|
53
|
+
* whose source is ASCII. Spec text outside ASCII is the case, and a sibling emitter spelling it with a
|
|
54
|
+
* bare `JSON.stringify` writes the character itself into a file its consumer commits.
|
|
55
|
+
*/
|
|
56
|
+
export { literal } from "./literal.js";
|
|
51
57
|
export declare function beginBanner(hint: string | undefined): void;
|
|
52
58
|
/**
|
|
53
59
|
* The status a row registers: the first non-error status the operation declares.
|
|
@@ -238,6 +244,32 @@ export interface EmittedRoute {
|
|
|
238
244
|
* `unsupported`: no segment router can split it.
|
|
239
245
|
*/
|
|
240
246
|
readonly pathSegments: readonly EmittedPathSegment[];
|
|
247
|
+
/**
|
|
248
|
+
* **The path parameters whose validator undoes an RFC 6570 expansion**, by wire name.
|
|
249
|
+
*
|
|
250
|
+
* For these, the path validator's field is `z.preprocess(<decode>, <value schema>)`: it takes the
|
|
251
|
+
* TEXT of the segment a router extracts - `primitive.a` for `{.param}` - and hands on the value,
|
|
252
|
+
* `a`. A caller already holding the value, such as a tool call or a service-binding request, must
|
|
253
|
+
* validate it against the value schema, `pathSchema.shape[name].out`: through the decoder, the value
|
|
254
|
+
* `a` is refused as not the expansion the route declares, and a value that happens to start with
|
|
255
|
+
* the route's literal is rewritten without an error. Decided by the same rule the validator is
|
|
256
|
+
* built by: a prefix or suffix in the segment, the `.` or `;` operator, or a parameter that is not
|
|
257
|
+
* a scalar. Empty when there is none, never `undefined`.
|
|
258
|
+
*/
|
|
259
|
+
readonly decodedPathParameters: readonly string[];
|
|
260
|
+
/**
|
|
261
|
+
* Every pair of inputs a handler would be handed under ONE key - `@header("x")` beside
|
|
262
|
+
* `@query("x")`, two `@query("x")`, a `@path id` beside a `@header("id")`, a parameter named as
|
|
263
|
+
* the body is. Empty for almost every operation.
|
|
264
|
+
*
|
|
265
|
+
* **A server emitter spreads the parameter groups into one input, so the later group's value
|
|
266
|
+
* silently replaced the earlier one**, after each had been validated against its own schema.
|
|
267
|
+
* `@typespec/http` refuses only a path and a query parameter of one name. The handler input has
|
|
268
|
+
* one value per key and cannot carry both, so a server should not mount such an operation; this
|
|
269
|
+
* package reports it as `shared-input-key`, and states the key as both declarations at once. See
|
|
270
|
+
* {@link SharedInputKey}.
|
|
271
|
+
*/
|
|
272
|
+
readonly sharedInputKeys: readonly SharedInputKey[];
|
|
241
273
|
/**
|
|
242
274
|
* A query string written into the route itself, as the pairs it spells:
|
|
243
275
|
* `/items?fixed=true{¶m}` carries `[["fixed", "true"]]`. It identifies the route as much as
|
|
@@ -420,6 +452,17 @@ export interface EmittedRoute {
|
|
|
420
452
|
*/
|
|
421
453
|
readonly security: readonly SecurityRequirement[];
|
|
422
454
|
}
|
|
455
|
+
/** Where a value reaches a handler's input from. */
|
|
456
|
+
export type InputLocation = "path" | "query" | "header" | "cookie" | "body";
|
|
457
|
+
/** Two inputs a handler would be handed under one key. See {@link EmittedRoute.sharedInputKeys}. */
|
|
458
|
+
export interface SharedInputKey {
|
|
459
|
+
/** The key both arrive under, as the input spells it. */
|
|
460
|
+
readonly key: string;
|
|
461
|
+
/** Where the input declared first comes from. */
|
|
462
|
+
readonly first: InputLocation;
|
|
463
|
+
/** Where the input declared second comes from. */
|
|
464
|
+
readonly second: InputLocation;
|
|
465
|
+
}
|
|
423
466
|
export declare function collectRoutes(program: Program, registry: SchemaRegistry, service: HttpService): EmittedRoute[];
|
|
424
467
|
/** Whether emitted source references `name` as an identifier rather than as part of a longer one. */
|
|
425
468
|
export declare function referencedIn(source: string, name: string): boolean;
|