@distilled.cloud/core 1.0.0-rc.2 → 1.0.0-rc.20
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/lib/_bundle/aws.js +2 -0
- package/lib/_bundle/aws.js.map +1 -0
- package/lib/_bundle/base.js +5 -0
- package/lib/_bundle/base.js.map +1 -0
- package/lib/_bundle/graphql.js +3 -0
- package/lib/_bundle/graphql.js.map +1 -0
- package/lib/_bundle/grpc.js +2 -0
- package/lib/_bundle/grpc.js.map +1 -0
- package/lib/_bundle/rest.js +2 -0
- package/lib/_bundle/rest.js.map +1 -0
- package/lib/_bundle/xml.js +4 -0
- package/lib/_bundle/xml.js.map +1 -0
- package/lib/annotations.d.ts +17 -0
- package/lib/annotations.d.ts.map +1 -0
- package/lib/annotations.js +2 -0
- package/lib/annotations.js.map +1 -0
- package/lib/api.d.ts +174 -18
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +1 -178
- package/lib/category.d.ts +4 -4
- package/lib/category.d.ts.map +1 -1
- package/lib/category.js +1 -280
- package/lib/chunks.d.ts +3 -0
- package/lib/chunks.d.ts.map +1 -0
- package/lib/chunks.js +1 -0
- package/lib/config.d.ts +68 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +1 -0
- package/lib/crypto.d.ts +76 -0
- package/lib/crypto.d.ts.map +1 -0
- package/lib/crypto.js +1 -0
- package/lib/error-category.d.ts +1 -1
- package/lib/error-category.d.ts.map +1 -1
- package/lib/error-category.js +1 -46
- package/lib/errors.d.ts +64 -72
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -186
- package/lib/graphql.d.ts +403 -0
- package/lib/graphql.d.ts.map +1 -0
- package/lib/graphql.js +1 -0
- package/lib/graphql.types.d.ts +12 -0
- package/lib/graphql.types.d.ts.map +1 -0
- package/lib/graphql.types.js +1 -0
- package/lib/grpc-transport-cloudflare-http2.d.ts +7 -0
- package/lib/grpc-transport-cloudflare-http2.d.ts.map +1 -0
- package/lib/grpc-transport-cloudflare-http2.js +6 -0
- package/lib/grpc-transport-cloudflare-http2.js.map +1 -0
- package/lib/grpc-transport-cloudflare-sockets.d.ts +7 -0
- package/lib/grpc-transport-cloudflare-sockets.d.ts.map +1 -0
- package/lib/grpc-transport-cloudflare-sockets.js +5 -0
- package/lib/grpc-transport-cloudflare-sockets.js.map +1 -0
- package/lib/grpc-transport-node-http2.d.ts +19 -0
- package/lib/grpc-transport-node-http2.d.ts.map +1 -0
- package/lib/grpc-transport-node-http2.js +2 -0
- package/lib/grpc-transport-node-http2.js.map +1 -0
- package/lib/grpc-transport.d.ts +76 -0
- package/lib/grpc-transport.d.ts.map +1 -0
- package/lib/grpc-transport.js +1 -0
- package/lib/hpack.d.ts +34 -0
- package/lib/hpack.d.ts.map +1 -0
- package/lib/hpack.js +2 -0
- package/lib/hpack.js.map +1 -0
- package/lib/index.d.ts +32 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +17 -0
- package/lib/pagination.d.ts +101 -24
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +1 -182
- package/lib/plain-values.d.ts +10 -0
- package/lib/plain-values.d.ts.map +1 -0
- package/lib/plain-values.js +2 -0
- package/lib/plain-values.js.map +1 -0
- package/lib/protobuf.d.ts +92 -0
- package/lib/protobuf.d.ts.map +1 -0
- package/lib/protobuf.js +1 -0
- package/lib/protocol-grpc.d.ts +86 -0
- package/lib/protocol-grpc.d.ts.map +1 -0
- package/lib/protocol-grpc.js +1 -0
- package/lib/protocol-http.d.ts +102 -23
- package/lib/protocol-http.d.ts.map +1 -1
- package/lib/protocol-http.js +1 -554
- package/lib/protocol-rest.d.ts +120 -50
- package/lib/protocol-rest.d.ts.map +1 -1
- package/lib/protocol-rest.js +1 -242
- package/lib/query.d.ts +29 -0
- package/lib/query.d.ts.map +1 -0
- package/lib/query.js +1 -0
- package/lib/response-validation-strict.d.ts +48 -0
- package/lib/response-validation-strict.d.ts.map +1 -0
- package/lib/response-validation-strict.js +1 -0
- package/lib/response-validation.d.ts +86 -0
- package/lib/response-validation.d.ts.map +1 -0
- package/lib/response-validation.js +1 -0
- package/lib/retry-after.d.ts +3 -3
- package/lib/retry-after.d.ts.map +1 -1
- package/lib/retry-after.js +1 -112
- package/lib/retry.d.ts +48 -29
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -210
- package/lib/schema-lite-impl.d.ts +158 -0
- package/lib/schema-lite-impl.d.ts.map +1 -0
- package/lib/schema-lite-impl.js +1 -0
- package/lib/schema-lite-typed.d.ts +41 -0
- package/lib/schema-lite-typed.d.ts.map +1 -0
- package/lib/schema-lite-typed.js +1 -0
- package/lib/schema-lite.d.ts +40 -0
- package/lib/schema-lite.d.ts.map +1 -0
- package/lib/schema-lite.js +1 -0
- package/lib/schema.d.ts +21 -7
- package/lib/schema.d.ts.map +1 -1
- package/lib/schema.js +1 -48
- package/lib/sdk-error.d.ts +27 -0
- package/lib/sdk-error.d.ts.map +1 -0
- package/lib/sdk-error.js +1 -0
- package/lib/sensitive.d.ts +28 -0
- package/lib/sensitive.d.ts.map +1 -0
- package/lib/sensitive.js +2 -0
- package/lib/sensitive.js.map +1 -0
- package/lib/telemetry-debug.d.ts +6 -0
- package/lib/telemetry-debug.d.ts.map +1 -0
- package/lib/telemetry-debug.js +2 -0
- package/lib/telemetry-debug.js.map +1 -0
- package/lib/telemetry-hooks.d.ts +32 -0
- package/lib/telemetry-hooks.d.ts.map +1 -0
- package/lib/telemetry-hooks.js +2 -0
- package/lib/telemetry-hooks.js.map +1 -0
- package/lib/telemetry-host-rules.d.ts +23 -0
- package/lib/telemetry-host-rules.d.ts.map +1 -0
- package/lib/telemetry-host-rules.js +2 -0
- package/lib/telemetry-host-rules.js.map +1 -0
- package/lib/telemetry-lambda-context.d.ts +17 -0
- package/lib/telemetry-lambda-context.d.ts.map +1 -0
- package/lib/telemetry-lambda-context.js +2 -0
- package/lib/telemetry-lambda-context.js.map +1 -0
- package/lib/telemetry-message-context.d.ts +52 -0
- package/lib/telemetry-message-context.d.ts.map +1 -0
- package/lib/telemetry-message-context.js +2 -0
- package/lib/telemetry-message-context.js.map +1 -0
- package/lib/telemetry-metrics.d.ts +6 -0
- package/lib/telemetry-metrics.d.ts.map +1 -0
- package/lib/telemetry-metrics.js +2 -0
- package/lib/telemetry-metrics.js.map +1 -0
- package/lib/telemetry-name-template.d.ts +13 -0
- package/lib/telemetry-name-template.d.ts.map +1 -0
- package/lib/telemetry-name-template.js +2 -0
- package/lib/telemetry-name-template.js.map +1 -0
- package/lib/telemetry-stream.d.ts +11 -0
- package/lib/telemetry-stream.d.ts.map +1 -0
- package/lib/telemetry-stream.js +2 -0
- package/lib/telemetry-stream.js.map +1 -0
- package/lib/telemetry-xray.d.ts +28 -0
- package/lib/telemetry-xray.d.ts.map +1 -0
- package/lib/telemetry-xray.js +2 -0
- package/lib/telemetry-xray.js.map +1 -0
- package/lib/telemetry.d.ts +288 -0
- package/lib/telemetry.d.ts.map +1 -0
- package/lib/telemetry.js +3 -0
- package/lib/telemetry.js.map +1 -0
- package/lib/trait.d.ts +71 -20
- package/lib/trait.d.ts.map +1 -1
- package/lib/trait.js +1 -107
- package/lib/unknown-error.d.ts +18 -0
- package/lib/unknown-error.d.ts.map +1 -0
- package/lib/unknown-error.js +1 -0
- package/lib/xml.d.ts +44 -0
- package/lib/xml.d.ts.map +1 -0
- package/lib/xml.js +1 -0
- package/package.json +13 -13
- package/src/annotations.ts +53 -0
- package/src/api.ts +1370 -200
- package/src/category.ts +76 -106
- package/src/chunks.ts +30 -0
- package/src/config.ts +245 -0
- package/src/crypto.ts +202 -0
- package/src/error-category.ts +16 -29
- package/src/errors.ts +75 -75
- package/src/graphql.ts +1778 -0
- package/src/graphql.types.ts +105 -0
- package/src/grpc-transport-cloudflare-http2.ts +494 -0
- package/src/grpc-transport-cloudflare-sockets.ts +299 -0
- package/src/grpc-transport-node-http2.ts +234 -0
- package/src/grpc-transport.ts +118 -0
- package/src/hpack.ts +331 -0
- package/src/index.ts +31 -0
- package/src/pagination.ts +368 -94
- package/src/plain-values.ts +41 -0
- package/src/protobuf.ts +1332 -0
- package/src/protocol-grpc.ts +641 -0
- package/src/protocol-http.ts +622 -322
- package/src/protocol-rest.ts +440 -227
- package/src/query.ts +39 -0
- package/src/response-validation-strict.ts +327 -0
- package/src/response-validation.ts +161 -0
- package/src/retry-after.ts +7 -13
- package/src/retry.ts +96 -110
- package/src/schema-lite-impl.ts +550 -0
- package/src/schema-lite-typed.ts +44 -0
- package/src/schema-lite.ts +44 -0
- package/src/schema.ts +259 -15
- package/src/sdk-error.ts +33 -0
- package/src/sensitive.ts +154 -0
- package/src/telemetry-debug.ts +179 -0
- package/src/telemetry-hooks.ts +33 -0
- package/src/telemetry-host-rules.ts +39 -0
- package/src/telemetry-lambda-context.ts +46 -0
- package/src/telemetry-message-context.ts +170 -0
- package/src/telemetry-metrics.ts +69 -0
- package/src/telemetry-name-template.ts +26 -0
- package/src/telemetry-stream.ts +100 -0
- package/src/telemetry-xray.ts +66 -0
- package/src/telemetry.ts +832 -0
- package/src/trait.ts +106 -67
- package/src/unknown-error.ts +38 -0
- package/src/xml.ts +346 -0
- package/lib/api.js.map +0 -1
- package/lib/category.js.map +0 -1
- package/lib/codegen/cli.d.ts +0 -29
- package/lib/codegen/cli.d.ts.map +0 -1
- package/lib/codegen/cli.js +0 -165
- package/lib/codegen/cli.js.map +0 -1
- package/lib/codegen/emit.d.ts +0 -129
- package/lib/codegen/emit.d.ts.map +0 -1
- package/lib/codegen/emit.js +0 -105
- package/lib/codegen/emit.js.map +0 -1
- package/lib/codegen/format.d.ts +0 -23
- package/lib/codegen/format.d.ts.map +0 -1
- package/lib/codegen/format.js +0 -28
- package/lib/codegen/format.js.map +0 -1
- package/lib/codegen/generator.d.ts +0 -334
- package/lib/codegen/generator.d.ts.map +0 -1
- package/lib/codegen/generator.js +0 -691
- package/lib/codegen/generator.js.map +0 -1
- package/lib/codegen/graph.d.ts +0 -36
- package/lib/codegen/graph.d.ts.map +0 -1
- package/lib/codegen/graph.js +0 -136
- package/lib/codegen/graph.js.map +0 -1
- package/lib/codegen/members.d.ts +0 -25
- package/lib/codegen/members.d.ts.map +0 -1
- package/lib/codegen/members.js +0 -55
- package/lib/codegen/members.js.map +0 -1
- package/lib/codegen/naming.d.ts +0 -29
- package/lib/codegen/naming.d.ts.map +0 -1
- package/lib/codegen/naming.js +0 -74
- package/lib/codegen/naming.js.map +0 -1
- package/lib/codegen/openapi-cli.d.ts +0 -38
- package/lib/codegen/openapi-cli.d.ts.map +0 -1
- package/lib/codegen/openapi-cli.js +0 -107
- package/lib/codegen/openapi-cli.js.map +0 -1
- package/lib/codegen/openapi.d.ts +0 -115
- package/lib/codegen/openapi.d.ts.map +0 -1
- package/lib/codegen/openapi.js +0 -1220
- package/lib/codegen/openapi.js.map +0 -1
- package/lib/codegen/operations.d.ts +0 -24
- package/lib/codegen/operations.d.ts.map +0 -1
- package/lib/codegen/operations.js +0 -56
- package/lib/codegen/operations.js.map +0 -1
- package/lib/codegen/pagination.d.ts +0 -39
- package/lib/codegen/pagination.d.ts.map +0 -1
- package/lib/codegen/pagination.js +0 -33
- package/lib/codegen/pagination.js.map +0 -1
- package/lib/codegen/prelude.d.ts +0 -15
- package/lib/codegen/prelude.d.ts.map +0 -1
- package/lib/codegen/prelude.js +0 -60
- package/lib/codegen/prelude.js.map +0 -1
- package/lib/error-category.js.map +0 -1
- package/lib/errors.js.map +0 -1
- package/lib/json-patch.d.ts +0 -44
- package/lib/json-patch.d.ts.map +0 -1
- package/lib/json-patch.js +0 -174
- package/lib/json-patch.js.map +0 -1
- package/lib/pagination.js.map +0 -1
- package/lib/protocol-http.js.map +0 -1
- package/lib/protocol-rest.js.map +0 -1
- package/lib/retry-after.js.map +0 -1
- package/lib/retry.js.map +0 -1
- package/lib/schema.js.map +0 -1
- package/lib/trait.js.map +0 -1
- package/src/codegen/cli.ts +0 -268
- package/src/codegen/emit.ts +0 -207
- package/src/codegen/format.ts +0 -47
- package/src/codegen/generator.ts +0 -1153
- package/src/codegen/graph.ts +0 -151
- package/src/codegen/members.ts +0 -71
- package/src/codegen/naming.ts +0 -86
- package/src/codegen/openapi-cli.ts +0 -166
- package/src/codegen/openapi.ts +0 -1450
- package/src/codegen/operations.ts +0 -76
- package/src/codegen/pagination.ts +0 -71
- package/src/codegen/prelude.ts +0 -70
- package/src/json-patch.ts +0 -222
package/lib/trait.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const annotationMetaSymbol: unique symbol;
|
|
2
|
-
type Annotatable = {
|
|
2
|
+
export type Annotatable = {
|
|
3
3
|
annotate(annotations: any): Annotatable;
|
|
4
4
|
};
|
|
5
5
|
export interface Annotation {
|
|
@@ -15,12 +15,12 @@ export interface Annotation {
|
|
|
15
15
|
* Build a pipeable schema annotation carrying `value` under `sym`. Exported
|
|
16
16
|
* so SDK packages can define their own protocol traits (e.g. cloudflare's
|
|
17
17
|
* envelope traits, aws's smithy traits) with the same mechanics as the
|
|
18
|
-
* generic ones here. Keys may be symbols or plain strings
|
|
18
|
+
* generic ones here. Keys may be symbols or plain strings -- effect Schema
|
|
19
19
|
* annotation dictionaries accept both.
|
|
20
20
|
*/
|
|
21
21
|
export declare function makeAnnotation<T>(sym: symbol | string, value: T): Annotation;
|
|
22
22
|
/**
|
|
23
|
-
* Combine several annotations into one
|
|
23
|
+
* Combine several annotations into one -- needed where only a single
|
|
24
24
|
* annotations object can be supplied (e.g. the second argument of
|
|
25
25
|
* `S.Class`).
|
|
26
26
|
*/
|
|
@@ -33,7 +33,7 @@ export interface HttpTrait {
|
|
|
33
33
|
readonly code?: number;
|
|
34
34
|
/**
|
|
35
35
|
* Request body encoding. Default is JSON; `"multipart"` sends
|
|
36
|
-
* multipart/form-data
|
|
36
|
+
* multipart/form-data -- body members become form parts (objects
|
|
37
37
|
* JSON-encoded) and members marked `FormDataFile()` append their files.
|
|
38
38
|
* `"form-urlencoded"` sends application/x-www-form-urlencoded with
|
|
39
39
|
* Stripe-style bracket notation for nested objects and arrays (see
|
|
@@ -50,7 +50,7 @@ export interface HttpTrait {
|
|
|
50
50
|
/**
|
|
51
51
|
* Explicit `Accept` for the operation, when the API serves more than one
|
|
52
52
|
* response media type. Atlas pins an API version this way (e.g.
|
|
53
|
-
* `application/vnd.atlas.2024-05-30+json`
|
|
53
|
+
* `application/vnd.atlas.2024-05-30+json` -- `application/json` alone is a
|
|
54
54
|
* 406). Protocols that don't read it fall back to their own default.
|
|
55
55
|
*/
|
|
56
56
|
readonly accept?: string;
|
|
@@ -65,6 +65,11 @@ export declare const Http: (trait: HttpTrait) => Annotation;
|
|
|
65
65
|
export declare const labelSymbol: unique symbol;
|
|
66
66
|
/** Bind a member to a `{name}` placeholder in the operation's URI template. */
|
|
67
67
|
export declare const Label: (name?: string) => Annotation;
|
|
68
|
+
export declare const labelEncodingSymbol: unique symbol;
|
|
69
|
+
/** Preserve selected RFC 3986 pchar delimiters inside a single URI label. */
|
|
70
|
+
export declare const LabelEncoding: (options: {
|
|
71
|
+
readonly preserve: string;
|
|
72
|
+
}) => Annotation;
|
|
68
73
|
export declare const responseCodeSymbol: unique symbol;
|
|
69
74
|
export declare const ResponseCode: () => Annotation;
|
|
70
75
|
export declare const headerSymbol: unique symbol;
|
|
@@ -73,11 +78,18 @@ export declare const bodySymbol: unique symbol;
|
|
|
73
78
|
export declare const Body: (name?: string) => Annotation;
|
|
74
79
|
export declare const querySymbol: unique symbol;
|
|
75
80
|
export declare const Query: (name?: string) => Annotation;
|
|
81
|
+
export declare const commaDelimitedSymbol: unique symbol;
|
|
82
|
+
/**
|
|
83
|
+
* Sends a list-valued `Query` member as ONE comma-separated parameter
|
|
84
|
+
* (`?state=running,paused`) instead of one parameter per item -- OpenAPI's
|
|
85
|
+
* `style: form, explode: false`. Takes the trait value the codegen inlines.
|
|
86
|
+
*/
|
|
87
|
+
export declare const CommaDelimited: (_trait?: unknown) => Annotation;
|
|
76
88
|
export declare const deepQuerySymbol: unique symbol;
|
|
77
89
|
/**
|
|
78
90
|
* Binds a struct-valued input member to a family of DOTTED query parameters:
|
|
79
91
|
* `{ account: { id, name } }` with `DeepQuery("account")` serializes as
|
|
80
|
-
* `?account.id
|
|
92
|
+
* `?account.id=...&account.name=...` (null/undefined entries skipped). This is
|
|
81
93
|
* how several list endpoints model their filters on the wire (e.g.
|
|
82
94
|
* Cloudflare zones list `account.id` / `account.name`) while the TS surface
|
|
83
95
|
* keeps the nested-object shape (v0 parity).
|
|
@@ -86,10 +98,21 @@ export declare const DeepQuery: (name?: string) => Annotation;
|
|
|
86
98
|
export declare const httpBodySymbol: unique symbol;
|
|
87
99
|
/**
|
|
88
100
|
* Marks the input member whose value IS the entire request body (raw arrays/
|
|
89
|
-
* scalars
|
|
101
|
+
* scalars -- e.g. endpoints that POST a bare JSON array). Mirrors
|
|
90
102
|
* `smithy.api#httpPayload`.
|
|
91
103
|
*/
|
|
92
104
|
export declare const HttpBody: () => Annotation;
|
|
105
|
+
export declare const stringEncodedSymbol: unique symbol;
|
|
106
|
+
/**
|
|
107
|
+
* Marks a member the API only accepts as the STRING spelling of its value --
|
|
108
|
+
* `true` travels as `"true"`, `3` as `"3"` -- while the TS surface keeps the
|
|
109
|
+
* natural type (e.g. Cloudflare's multipart `validation_enabled`, which the
|
|
110
|
+
* docs model as the enum `"true" | "false"`). The protocol stringifies body
|
|
111
|
+
* members on encode, element-wise for lists; `null` is left alone. Query and
|
|
112
|
+
* header bindings already serialize their values as strings, so the trait is
|
|
113
|
+
* documentation there.
|
|
114
|
+
*/
|
|
115
|
+
export declare const StringEncoded: () => Annotation;
|
|
93
116
|
export declare const formDataFileSymbol: unique symbol;
|
|
94
117
|
/**
|
|
95
118
|
* Marks an input member holding `File`/`Blob` parts for a multipart upload
|
|
@@ -99,7 +122,7 @@ export declare const formDataFileSymbol: unique symbol;
|
|
|
99
122
|
export declare const FormDataFile: () => Annotation;
|
|
100
123
|
export declare const keyDictionarySymbol: unique symbol;
|
|
101
124
|
/**
|
|
102
|
-
* Deep TS-name
|
|
125
|
+
* Deep TS-name->wire-name key dictionary for members whose full structure is
|
|
103
126
|
* not modeled (opaque `Document` content). The protocol renames any matching
|
|
104
127
|
* key at any depth on encode (and the reverse on decode); keys not in the
|
|
105
128
|
* dictionary pass through verbatim.
|
|
@@ -113,38 +136,66 @@ export declare const keyDictionarySymbol: unique symbol;
|
|
|
113
136
|
export type KeyDictionaryEntries = Record<string, string | ReadonlyArray<string>>;
|
|
114
137
|
export declare const KeyDictionary: (dict: KeyDictionaryEntries) => Annotation;
|
|
115
138
|
export declare const unionCasesSymbol: unique symbol;
|
|
139
|
+
/**
|
|
140
|
+
* The literal member every case of a union fixes to its own value -- what the
|
|
141
|
+
* docs call the resource `type` or the action `id`. `values[i]` is the value
|
|
142
|
+
* case `i` carries.
|
|
143
|
+
*/
|
|
144
|
+
export interface UnionDiscriminator {
|
|
145
|
+
readonly key: string;
|
|
146
|
+
readonly values: ReadonlyArray<string>;
|
|
147
|
+
}
|
|
116
148
|
/**
|
|
117
149
|
* Marks an opaque schema standing in for a discriminated union of object
|
|
118
150
|
* cases, carrying each case's TS-facing key set. For APIs that return every
|
|
119
151
|
* case's keys with `null` for the inactive ones, the protocol uses these key
|
|
120
152
|
* sets to pick the active case and drop the others, so consumers' `"key" in
|
|
121
153
|
* value` discrimination works.
|
|
154
|
+
*
|
|
155
|
+
* Key sets alone cannot tell apart cases that share them -- the 41 resource
|
|
156
|
+
* kinds of `resource_tagging`, the 34 page-rule actions -- so when the union
|
|
157
|
+
* has a discriminator the protocol reads the case off it and only falls back
|
|
158
|
+
* to key-set scoring for a value whose tag is missing or unknown.
|
|
122
159
|
*/
|
|
123
|
-
export declare const UnionCases: (cases: ReadonlyArray<ReadonlyArray<string
|
|
160
|
+
export declare const UnionCases: (cases: ReadonlyArray<ReadonlyArray<string>>, discriminator?: UnionDiscriminator) => Annotation;
|
|
124
161
|
export declare const errorMatchersSymbol: unique symbol;
|
|
162
|
+
/** Exact text, or the conjunction of substring and regular-expression constraints. */
|
|
163
|
+
export type ErrorTextMatcher = string | {
|
|
164
|
+
readonly includes?: string;
|
|
165
|
+
readonly matches?: string;
|
|
166
|
+
};
|
|
125
167
|
/**
|
|
126
|
-
* One wire-matching rule
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
* `
|
|
168
|
+
* One wire-matching rule. All supplied constraints must match; separate
|
|
169
|
+
* matchers on a class are alternatives. Empty matchers match nothing.
|
|
170
|
+
*
|
|
171
|
+
* `body` maps RFC 6901 JSON Pointers to scalar constraints. For example,
|
|
172
|
+
* `{ "/success": false, "/result/status": "error" }`. Strings also accept
|
|
173
|
+
* `includes` / `matches`. Missing fields never match, including against null.
|
|
174
|
+
* The empty pointer addresses the entire body; array indices are supported.
|
|
175
|
+
* Header names are case-insensitive; their value constraints are case-sensitive.
|
|
176
|
+
* Each body path and header adds one specificity point, like code/status/message.
|
|
177
|
+
* Protocols evaluate these rules only after identifying a failed response.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* { status: 200, body: { "/success": false, "/result/status": "error" } }
|
|
182
|
+
* { status: 409, headers: { "x-error-type": { includes: "Conflict" } } }
|
|
183
|
+
* ```
|
|
131
184
|
*/
|
|
132
185
|
export interface ErrorMatcher {
|
|
133
186
|
readonly code?: number;
|
|
134
187
|
readonly status?: number;
|
|
135
|
-
readonly message?:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
};
|
|
188
|
+
readonly message?: ErrorTextMatcher;
|
|
189
|
+
readonly body?: Readonly<Record<string, ErrorTextMatcher | number | boolean | null>>;
|
|
190
|
+
readonly headers?: Readonly<Record<string, ErrorTextMatcher>>;
|
|
139
191
|
}
|
|
140
192
|
/**
|
|
141
193
|
* Stamp wire-matching rules onto a generated error class. Protocols consult
|
|
142
194
|
* these to decide which of an operation's declared error classes a failed
|
|
143
195
|
* response should surface as (most specific matcher wins; ties break by
|
|
144
|
-
* declaration order
|
|
196
|
+
* declaration order -- see `matchTypedError` in `core/protocol-http`).
|
|
145
197
|
*/
|
|
146
198
|
export declare const applyErrorMatchers: <C>(cls: C, matchers: ReadonlyArray<ErrorMatcher>) => C;
|
|
147
199
|
/** Read the matchers stamped on an error class, if any. */
|
|
148
200
|
export declare const getErrorMatchers: (cls: unknown) => ReadonlyArray<ErrorMatcher> | undefined;
|
|
149
|
-
export {};
|
|
150
201
|
//# sourceMappingURL=trait.d.ts.map
|
package/lib/trait.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trait.d.ts","sourceRoot":"","sources":["../src/trait.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,eAEhC,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"trait.d.ts","sourceRoot":"","sources":["../src/trait.ts"],"names":[],"mappings":"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"}
|
package/lib/trait.js
CHANGED
|
@@ -1,107 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
/**
|
|
3
|
-
* Build a pipeable schema annotation carrying `value` under `sym`. Exported
|
|
4
|
-
* so SDK packages can define their own protocol traits (e.g. cloudflare's
|
|
5
|
-
* envelope traits, aws's smithy traits) with the same mechanics as the
|
|
6
|
-
* generic ones here. Keys may be symbols or plain strings — effect Schema
|
|
7
|
-
* annotation dictionaries accept both.
|
|
8
|
-
*/
|
|
9
|
-
export function makeAnnotation(sym, value) {
|
|
10
|
-
const fn = (schema) => schema.annotate({ [sym]: value });
|
|
11
|
-
fn[annotationMetaSymbol] = [{ symbol: sym, value }];
|
|
12
|
-
fn[sym] = value;
|
|
13
|
-
return fn;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Combine several annotations into one — needed where only a single
|
|
17
|
-
* annotations object can be supplied (e.g. the second argument of
|
|
18
|
-
* `S.Class`).
|
|
19
|
-
*/
|
|
20
|
-
export function all(...annotations) {
|
|
21
|
-
const entries = [];
|
|
22
|
-
const raw = {};
|
|
23
|
-
for (const a of annotations) {
|
|
24
|
-
for (const entry of a[annotationMetaSymbol]) {
|
|
25
|
-
entries.push(entry);
|
|
26
|
-
raw[entry.symbol] = entry.value;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const fn = (schema) => schema.annotate(raw);
|
|
30
|
-
fn[annotationMetaSymbol] = entries;
|
|
31
|
-
for (const { symbol: sym, value } of entries) {
|
|
32
|
-
fn[sym] = value;
|
|
33
|
-
}
|
|
34
|
-
return fn;
|
|
35
|
-
}
|
|
36
|
-
export const httpSymbol = Symbol.for("@distilled.cloud/core/http");
|
|
37
|
-
/**
|
|
38
|
-
* Operation-level HTTP binding: the request method + URI template. Stamped on
|
|
39
|
-
* the input schema so the protocol can build the request line. URI `{labels}`
|
|
40
|
-
* are filled from members marked with `Label()`.
|
|
41
|
-
*/
|
|
42
|
-
export const Http = (trait) => makeAnnotation(httpSymbol, trait);
|
|
43
|
-
export const labelSymbol = Symbol.for("@distilled.cloud/core/http/label");
|
|
44
|
-
/** Bind a member to a `{name}` placeholder in the operation's URI template. */
|
|
45
|
-
export const Label = (name) => makeAnnotation(labelSymbol, name ?? true);
|
|
46
|
-
export const responseCodeSymbol = Symbol.for("@distilled.cloud/core/http/response-code");
|
|
47
|
-
export const ResponseCode = () => makeAnnotation(responseCodeSymbol, true);
|
|
48
|
-
export const headerSymbol = Symbol.for("@distilled.cloud/core/http/header");
|
|
49
|
-
export const Header = (name) => makeAnnotation(headerSymbol, name ?? true);
|
|
50
|
-
export const bodySymbol = Symbol.for("@distilled.cloud/core/http/body");
|
|
51
|
-
export const Body = (name) => makeAnnotation(bodySymbol, name ?? true);
|
|
52
|
-
export const querySymbol = Symbol.for("@distilled.cloud/core/http/query");
|
|
53
|
-
export const Query = (name) => makeAnnotation(querySymbol, name ?? true);
|
|
54
|
-
export const deepQuerySymbol = Symbol.for("@distilled.cloud/core/http/deep-query");
|
|
55
|
-
/**
|
|
56
|
-
* Binds a struct-valued input member to a family of DOTTED query parameters:
|
|
57
|
-
* `{ account: { id, name } }` with `DeepQuery("account")` serializes as
|
|
58
|
-
* `?account.id=…&account.name=…` (null/undefined entries skipped). This is
|
|
59
|
-
* how several list endpoints model their filters on the wire (e.g.
|
|
60
|
-
* Cloudflare zones list `account.id` / `account.name`) while the TS surface
|
|
61
|
-
* keeps the nested-object shape (v0 parity).
|
|
62
|
-
*/
|
|
63
|
-
export const DeepQuery = (name) => makeAnnotation(deepQuerySymbol, name ?? true);
|
|
64
|
-
export const httpBodySymbol = Symbol.for("@distilled.cloud/core/http-body");
|
|
65
|
-
/**
|
|
66
|
-
* Marks the input member whose value IS the entire request body (raw arrays/
|
|
67
|
-
* scalars — e.g. endpoints that POST a bare JSON array). Mirrors
|
|
68
|
-
* `smithy.api#httpPayload`.
|
|
69
|
-
*/
|
|
70
|
-
export const HttpBody = () => makeAnnotation(httpBodySymbol, true);
|
|
71
|
-
export const formDataFileSymbol = Symbol.for("@distilled.cloud/core/form-data-file");
|
|
72
|
-
/**
|
|
73
|
-
* Marks an input member holding `File`/`Blob` parts for a multipart upload
|
|
74
|
-
* (`Http({ contentType: "multipart" })`). Each file is appended to the form
|
|
75
|
-
* under its own filename.
|
|
76
|
-
*/
|
|
77
|
-
export const FormDataFile = () => makeAnnotation(formDataFileSymbol, true);
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region Generic JSON traits
|
|
80
|
-
export const keyDictionarySymbol = Symbol.for("@distilled.cloud/core/key-dictionary");
|
|
81
|
-
export const KeyDictionary = (dict) => makeAnnotation(keyDictionarySymbol, dict);
|
|
82
|
-
export const unionCasesSymbol = Symbol.for("@distilled.cloud/core/union-cases");
|
|
83
|
-
/**
|
|
84
|
-
* Marks an opaque schema standing in for a discriminated union of object
|
|
85
|
-
* cases, carrying each case's TS-facing key set. For APIs that return every
|
|
86
|
-
* case's keys with `null` for the inactive ones, the protocol uses these key
|
|
87
|
-
* sets to pick the active case and drop the others, so consumers' `"key" in
|
|
88
|
-
* value` discrimination works.
|
|
89
|
-
*/
|
|
90
|
-
export const UnionCases = (cases) => makeAnnotation(unionCasesSymbol, cases);
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region Error matcher traits
|
|
93
|
-
export const errorMatchersSymbol = Symbol.for("@distilled.cloud/core/error-matchers");
|
|
94
|
-
/**
|
|
95
|
-
* Stamp wire-matching rules onto a generated error class. Protocols consult
|
|
96
|
-
* these to decide which of an operation's declared error classes a failed
|
|
97
|
-
* response should surface as (most specific matcher wins; ties break by
|
|
98
|
-
* declaration order — see `matchTypedError` in `core/protocol-http`).
|
|
99
|
-
*/
|
|
100
|
-
export const applyErrorMatchers = (cls, matchers) => {
|
|
101
|
-
cls[errorMatchersSymbol] = matchers;
|
|
102
|
-
return cls;
|
|
103
|
-
};
|
|
104
|
-
/** Read the matchers stamped on an error class, if any. */
|
|
105
|
-
export const getErrorMatchers = (cls) => cls?.[errorMatchersSymbol];
|
|
106
|
-
//#endregion
|
|
107
|
-
//# sourceMappingURL=trait.js.map
|
|
1
|
+
export { trait$Body as Body, trait$CommaDelimited as CommaDelimited, trait$DeepQuery as DeepQuery, trait$FormDataFile as FormDataFile, trait$Header as Header, trait$Http as Http, trait$HttpBody as HttpBody, trait$KeyDictionary as KeyDictionary, trait$Label as Label, trait$LabelEncoding as LabelEncoding, trait$Query as Query, trait$ResponseCode as ResponseCode, trait$StringEncoded as StringEncoded, trait$UnionCases as UnionCases, trait$all as all, trait$annotationMetaSymbol as annotationMetaSymbol, trait$applyErrorMatchers as applyErrorMatchers, trait$bodySymbol as bodySymbol, trait$commaDelimitedSymbol as commaDelimitedSymbol, trait$deepQuerySymbol as deepQuerySymbol, trait$errorMatchersSymbol as errorMatchersSymbol, trait$formDataFileSymbol as formDataFileSymbol, trait$getErrorMatchers as getErrorMatchers, trait$headerSymbol as headerSymbol, trait$httpBodySymbol as httpBodySymbol, trait$httpSymbol as httpSymbol, trait$keyDictionarySymbol as keyDictionarySymbol, trait$labelEncodingSymbol as labelEncodingSymbol, trait$labelSymbol as labelSymbol, trait$makeAnnotation as makeAnnotation, trait$querySymbol as querySymbol, trait$responseCodeSymbol as responseCodeSymbol, trait$stringEncodedSymbol as stringEncodedSymbol, trait$unionCasesSymbol as unionCasesSymbol } from "./_bundle/base.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const UnknownErrorFields: {
|
|
2
|
+
/** HTTP status of the response that carried the failure. */
|
|
3
|
+
status: import("effect/Schema").Number;
|
|
4
|
+
/** The provider's machine-readable error code, when the response has one. */
|
|
5
|
+
code: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
6
|
+
/** The provider's error message, when the response has one. */
|
|
7
|
+
message: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
8
|
+
/** Parsed JSON body, or the raw text when the body wasn't JSON. */
|
|
9
|
+
body: import("effect/Schema").Unknown;
|
|
10
|
+
};
|
|
11
|
+
/** The values of {@link UnknownErrorFields}. */
|
|
12
|
+
export interface UnknownErrorProps {
|
|
13
|
+
readonly status: number;
|
|
14
|
+
readonly code?: string | undefined;
|
|
15
|
+
readonly message?: string | undefined;
|
|
16
|
+
readonly body: unknown;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=unknown-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unknown-error.d.ts","sourceRoot":"","sources":["../src/unknown-error.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,kBAAkB;IAC7B,4DAA4D;IAC5D,MAAM;IACN,6EAA6E;IAC7E,IAAI;IACJ,+DAA+D;IAC/D,OAAO;IACP,mEAAmE;IACnE,IAAI;CACL,CAAC;AAEF,gDAAgD;AAChD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { unknown_error$UnknownErrorFields as UnknownErrorFields } from "./_bundle/base.js";
|
package/lib/xml.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
export type XmlValue = string | XmlObject | XmlValue[];
|
|
3
|
+
export interface XmlObject {
|
|
4
|
+
[name: string]: XmlValue;
|
|
5
|
+
}
|
|
6
|
+
declare const XmlParseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
7
|
+
readonly _tag: "XmlParseError";
|
|
8
|
+
} & Readonly<A>;
|
|
9
|
+
export declare class XmlParseError extends /*@__PURE__*/ XmlParseError_base<{
|
|
10
|
+
readonly message: string;
|
|
11
|
+
/** UTF-16 offset in the original input; line and column are one-based. */
|
|
12
|
+
readonly offset: number;
|
|
13
|
+
readonly line: number;
|
|
14
|
+
readonly column: number;
|
|
15
|
+
}> {
|
|
16
|
+
}
|
|
17
|
+
export interface XmlParseOptions {
|
|
18
|
+
/** Maximum open elements, including the root. Defaults to 256. */
|
|
19
|
+
readonly maxDepth?: number;
|
|
20
|
+
/** Maximum input length in UTF-16 code units. Defaults to 64 Mi. */
|
|
21
|
+
readonly maxLength?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse DTD-free XML 1.0. Values remain strings;
|
|
25
|
+
* repeated children become arrays, attributes use @_ and mixed text uses #text.
|
|
26
|
+
* Names are preserved verbatim (no namespace resolution). Comments and PIs are
|
|
27
|
+
* ignored. Text whitespace is preserved, except layout-only text in containers.
|
|
28
|
+
* Empty HTTP bodies produce {}. This is not a DOM or a validating DTD processor.
|
|
29
|
+
* Throws XmlParseError for malformed input or exceeded limits.
|
|
30
|
+
* The iterative scanner allocates no Effects while traversing the document.
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseXmlSync(xml: string, options?: XmlParseOptions): XmlObject;
|
|
33
|
+
/** Parse XML lazily, reporting malformed documents in the typed error channel. */
|
|
34
|
+
export declare const parseXml: (xml: string, options?: XmlParseOptions) => Effect.Effect<XmlObject, XmlParseError>;
|
|
35
|
+
/**
|
|
36
|
+
* Escape special XML characters in a string.
|
|
37
|
+
*/
|
|
38
|
+
export declare const escapeXml: (s: string) => string;
|
|
39
|
+
/**
|
|
40
|
+
* Wrap content in an XML tag with optional xmlns attribute.
|
|
41
|
+
*/
|
|
42
|
+
export declare const wrapTag: (tag: string, content: string, xmlns?: string) => string;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=xml.d.ts.map
|
package/lib/xml.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml.d.ts","sourceRoot":"","sources":["../src/xml.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,EAAE,CAAC;AACvD,MAAM,WAAW,SAAS;IACxB,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;CAC1B;;;;AAED,qBAAa,aACX,SAAQ,aAAa,CAAC,mBAAkC;IACtD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;CAAG;AAEP,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAmCD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,SAAS,CAyOlF;AAED,kFAAkF;AAClF,eAAO,MAAM,QAAQ,QACd,MAAM,YACD,eAAe,KACxB,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,CAiBrC,CAAC;AAUL;;GAEG;AACH,eAAO,MAAM,SAAS,MAAO,MAAM,KAAG,MAAqD,CAAC;AAM5F;;GAEG;AACH,eAAO,MAAM,OAAO,QAAS,MAAM,WAAW,MAAM,UAAU,MAAM,KAAG,MACM,CAAC"}
|
package/lib/xml.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { xml$XmlParseError as XmlParseError, xml$escapeXml as escapeXml, xml$parseXml as parseXml, xml$parseXmlSync as parseXmlSync, xml$wrapTag as wrapTag } from "./_bundle/xml.js";
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/core",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.20",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"repository": {
|
|
5
6
|
"type": "git",
|
|
6
7
|
"url": "https://github.com/alchemy-run/distilled",
|
|
7
8
|
"directory": "packages/core"
|
|
8
9
|
},
|
|
9
|
-
"license": "Apache-2.0",
|
|
10
|
-
"type": "module",
|
|
11
|
-
"sideEffects": false,
|
|
12
10
|
"files": [
|
|
13
11
|
"lib",
|
|
14
12
|
"src"
|
|
15
13
|
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./lib/index.d.ts",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"worker": "./src/index.ts",
|
|
21
21
|
"import": "./lib/index.js"
|
|
22
22
|
},
|
|
23
|
+
"./_bundle/*": "./lib/_bundle/*.js",
|
|
23
24
|
"./*": {
|
|
24
25
|
"types": "./lib/*.d.ts",
|
|
25
26
|
"bun": "./src/*.ts",
|
|
@@ -27,16 +28,15 @@
|
|
|
27
28
|
"import": "./lib/*.js"
|
|
28
29
|
}
|
|
29
30
|
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"build": "tsc -b"
|
|
32
|
-
},
|
|
33
31
|
"devDependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"effect": ">=4.0.0-beta.102 || >=4.0.0"
|
|
32
|
+
"@types/node": "26.6.5",
|
|
33
|
+
"effect": "^4.1.2",
|
|
34
|
+
"vitest": "^5.0.4"
|
|
38
35
|
},
|
|
39
36
|
"peerDependencies": {
|
|
40
|
-
"effect": "
|
|
37
|
+
"effect": "^4.1.2"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsrs -b"
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading schema annotations through the wrappers a generated schema has:
|
|
3
|
+
* Suspend, encodings, and `S.optional` / nullable unions. Shared by the
|
|
4
|
+
* protocols (via `./protocol-http.ts`) and by `./telemetry.ts`, which
|
|
5
|
+
* derives span facts from the same annotations.
|
|
6
|
+
*/
|
|
7
|
+
import type * as AST from "effect/SchemaAST";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Marks a response schema whose entire value is the response body (see
|
|
11
|
+
* `RawResponseRoot` in `./protocol-rest.ts`).
|
|
12
|
+
*/
|
|
13
|
+
export const rawResponseRootSymbol = /*@__PURE__*/ Symbol.for(
|
|
14
|
+
"@distilled.cloud/core/raw-response-root",
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const getProps = (ast: AST.AST): readonly AST.PropertySignature[] => {
|
|
18
|
+
if (ast._tag === "Objects") return ast.propertySignatures;
|
|
19
|
+
if (ast._tag === "Suspend") return getProps(ast.thunk());
|
|
20
|
+
if (ast.encoding && ast.encoding.length > 0) return getProps(ast.encoding[0]!.to);
|
|
21
|
+
return [];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const getAnn = (ast: AST.AST, symbol: symbol): unknown => {
|
|
25
|
+
const direct = (ast.annotations as Record<symbol, unknown> | undefined)?.[symbol];
|
|
26
|
+
if (direct !== undefined) return direct;
|
|
27
|
+
if (ast._tag === "Suspend") return getAnn(ast.thunk(), symbol);
|
|
28
|
+
if (ast.encoding && ast.encoding.length > 0) return getAnn(ast.encoding[0]!.to, symbol);
|
|
29
|
+
// S.optional -> Union[self, Undefined]; descend into the single real member.
|
|
30
|
+
if (ast._tag === "Union") {
|
|
31
|
+
const real = (ast as AST.Union).types.filter(
|
|
32
|
+
(t) => t._tag !== "Undefined" && !(t._tag === "Literal" && (t as any).literal === null),
|
|
33
|
+
);
|
|
34
|
+
if (real.length === 1) return getAnn(real[0]!, symbol);
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** Resolve wrappers to the real node: Suspend, encoding, optional/null unions. */
|
|
40
|
+
export const resolveNode = (ast: AST.AST): AST.AST => {
|
|
41
|
+
if (ast._tag === "Suspend") return resolveNode(ast.thunk());
|
|
42
|
+
if (ast.encoding && ast.encoding.length > 0) return resolveNode(ast.encoding[0]!.to);
|
|
43
|
+
if (ast._tag === "Union") {
|
|
44
|
+
const real = (ast as AST.Union).types.filter(
|
|
45
|
+
(t) =>
|
|
46
|
+
t._tag !== "Undefined" &&
|
|
47
|
+
t._tag !== "Null" &&
|
|
48
|
+
!(t._tag === "Literal" && (t as any).literal === null),
|
|
49
|
+
);
|
|
50
|
+
if (real.length === 1) return resolveNode(real[0]!);
|
|
51
|
+
}
|
|
52
|
+
return ast;
|
|
53
|
+
};
|