@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.
Files changed (291) hide show
  1. package/LICENSE +201 -0
  2. package/lib/_bundle/aws.js +2 -0
  3. package/lib/_bundle/aws.js.map +1 -0
  4. package/lib/_bundle/base.js +5 -0
  5. package/lib/_bundle/base.js.map +1 -0
  6. package/lib/_bundle/graphql.js +3 -0
  7. package/lib/_bundle/graphql.js.map +1 -0
  8. package/lib/_bundle/grpc.js +2 -0
  9. package/lib/_bundle/grpc.js.map +1 -0
  10. package/lib/_bundle/rest.js +2 -0
  11. package/lib/_bundle/rest.js.map +1 -0
  12. package/lib/_bundle/xml.js +4 -0
  13. package/lib/_bundle/xml.js.map +1 -0
  14. package/lib/annotations.d.ts +17 -0
  15. package/lib/annotations.d.ts.map +1 -0
  16. package/lib/annotations.js +2 -0
  17. package/lib/annotations.js.map +1 -0
  18. package/lib/api.d.ts +174 -18
  19. package/lib/api.d.ts.map +1 -1
  20. package/lib/api.js +1 -178
  21. package/lib/category.d.ts +4 -4
  22. package/lib/category.d.ts.map +1 -1
  23. package/lib/category.js +1 -280
  24. package/lib/chunks.d.ts +3 -0
  25. package/lib/chunks.d.ts.map +1 -0
  26. package/lib/chunks.js +1 -0
  27. package/lib/config.d.ts +68 -0
  28. package/lib/config.d.ts.map +1 -0
  29. package/lib/config.js +1 -0
  30. package/lib/crypto.d.ts +76 -0
  31. package/lib/crypto.d.ts.map +1 -0
  32. package/lib/crypto.js +1 -0
  33. package/lib/error-category.d.ts +1 -1
  34. package/lib/error-category.d.ts.map +1 -1
  35. package/lib/error-category.js +1 -46
  36. package/lib/errors.d.ts +64 -72
  37. package/lib/errors.d.ts.map +1 -1
  38. package/lib/errors.js +1 -186
  39. package/lib/graphql.d.ts +403 -0
  40. package/lib/graphql.d.ts.map +1 -0
  41. package/lib/graphql.js +1 -0
  42. package/lib/graphql.types.d.ts +12 -0
  43. package/lib/graphql.types.d.ts.map +1 -0
  44. package/lib/graphql.types.js +1 -0
  45. package/lib/grpc-transport-cloudflare-http2.d.ts +7 -0
  46. package/lib/grpc-transport-cloudflare-http2.d.ts.map +1 -0
  47. package/lib/grpc-transport-cloudflare-http2.js +6 -0
  48. package/lib/grpc-transport-cloudflare-http2.js.map +1 -0
  49. package/lib/grpc-transport-cloudflare-sockets.d.ts +7 -0
  50. package/lib/grpc-transport-cloudflare-sockets.d.ts.map +1 -0
  51. package/lib/grpc-transport-cloudflare-sockets.js +5 -0
  52. package/lib/grpc-transport-cloudflare-sockets.js.map +1 -0
  53. package/lib/grpc-transport-node-http2.d.ts +19 -0
  54. package/lib/grpc-transport-node-http2.d.ts.map +1 -0
  55. package/lib/grpc-transport-node-http2.js +2 -0
  56. package/lib/grpc-transport-node-http2.js.map +1 -0
  57. package/lib/grpc-transport.d.ts +76 -0
  58. package/lib/grpc-transport.d.ts.map +1 -0
  59. package/lib/grpc-transport.js +1 -0
  60. package/lib/hpack.d.ts +34 -0
  61. package/lib/hpack.d.ts.map +1 -0
  62. package/lib/hpack.js +2 -0
  63. package/lib/hpack.js.map +1 -0
  64. package/lib/index.d.ts +32 -0
  65. package/lib/index.d.ts.map +1 -0
  66. package/lib/index.js +17 -0
  67. package/lib/pagination.d.ts +101 -24
  68. package/lib/pagination.d.ts.map +1 -1
  69. package/lib/pagination.js +1 -182
  70. package/lib/plain-values.d.ts +10 -0
  71. package/lib/plain-values.d.ts.map +1 -0
  72. package/lib/plain-values.js +2 -0
  73. package/lib/plain-values.js.map +1 -0
  74. package/lib/protobuf.d.ts +92 -0
  75. package/lib/protobuf.d.ts.map +1 -0
  76. package/lib/protobuf.js +1 -0
  77. package/lib/protocol-grpc.d.ts +86 -0
  78. package/lib/protocol-grpc.d.ts.map +1 -0
  79. package/lib/protocol-grpc.js +1 -0
  80. package/lib/protocol-http.d.ts +102 -23
  81. package/lib/protocol-http.d.ts.map +1 -1
  82. package/lib/protocol-http.js +1 -554
  83. package/lib/protocol-rest.d.ts +120 -50
  84. package/lib/protocol-rest.d.ts.map +1 -1
  85. package/lib/protocol-rest.js +1 -242
  86. package/lib/query.d.ts +29 -0
  87. package/lib/query.d.ts.map +1 -0
  88. package/lib/query.js +1 -0
  89. package/lib/response-validation-strict.d.ts +48 -0
  90. package/lib/response-validation-strict.d.ts.map +1 -0
  91. package/lib/response-validation-strict.js +1 -0
  92. package/lib/response-validation.d.ts +86 -0
  93. package/lib/response-validation.d.ts.map +1 -0
  94. package/lib/response-validation.js +1 -0
  95. package/lib/retry-after.d.ts +3 -3
  96. package/lib/retry-after.d.ts.map +1 -1
  97. package/lib/retry-after.js +1 -112
  98. package/lib/retry.d.ts +48 -29
  99. package/lib/retry.d.ts.map +1 -1
  100. package/lib/retry.js +1 -210
  101. package/lib/schema-lite-impl.d.ts +158 -0
  102. package/lib/schema-lite-impl.d.ts.map +1 -0
  103. package/lib/schema-lite-impl.js +1 -0
  104. package/lib/schema-lite-typed.d.ts +41 -0
  105. package/lib/schema-lite-typed.d.ts.map +1 -0
  106. package/lib/schema-lite-typed.js +1 -0
  107. package/lib/schema-lite.d.ts +40 -0
  108. package/lib/schema-lite.d.ts.map +1 -0
  109. package/lib/schema-lite.js +1 -0
  110. package/lib/schema.d.ts +21 -7
  111. package/lib/schema.d.ts.map +1 -1
  112. package/lib/schema.js +1 -48
  113. package/lib/sdk-error.d.ts +27 -0
  114. package/lib/sdk-error.d.ts.map +1 -0
  115. package/lib/sdk-error.js +1 -0
  116. package/lib/sensitive.d.ts +28 -0
  117. package/lib/sensitive.d.ts.map +1 -0
  118. package/lib/sensitive.js +2 -0
  119. package/lib/sensitive.js.map +1 -0
  120. package/lib/telemetry-debug.d.ts +6 -0
  121. package/lib/telemetry-debug.d.ts.map +1 -0
  122. package/lib/telemetry-debug.js +2 -0
  123. package/lib/telemetry-debug.js.map +1 -0
  124. package/lib/telemetry-hooks.d.ts +32 -0
  125. package/lib/telemetry-hooks.d.ts.map +1 -0
  126. package/lib/telemetry-hooks.js +2 -0
  127. package/lib/telemetry-hooks.js.map +1 -0
  128. package/lib/telemetry-host-rules.d.ts +23 -0
  129. package/lib/telemetry-host-rules.d.ts.map +1 -0
  130. package/lib/telemetry-host-rules.js +2 -0
  131. package/lib/telemetry-host-rules.js.map +1 -0
  132. package/lib/telemetry-lambda-context.d.ts +17 -0
  133. package/lib/telemetry-lambda-context.d.ts.map +1 -0
  134. package/lib/telemetry-lambda-context.js +2 -0
  135. package/lib/telemetry-lambda-context.js.map +1 -0
  136. package/lib/telemetry-message-context.d.ts +52 -0
  137. package/lib/telemetry-message-context.d.ts.map +1 -0
  138. package/lib/telemetry-message-context.js +2 -0
  139. package/lib/telemetry-message-context.js.map +1 -0
  140. package/lib/telemetry-metrics.d.ts +6 -0
  141. package/lib/telemetry-metrics.d.ts.map +1 -0
  142. package/lib/telemetry-metrics.js +2 -0
  143. package/lib/telemetry-metrics.js.map +1 -0
  144. package/lib/telemetry-name-template.d.ts +13 -0
  145. package/lib/telemetry-name-template.d.ts.map +1 -0
  146. package/lib/telemetry-name-template.js +2 -0
  147. package/lib/telemetry-name-template.js.map +1 -0
  148. package/lib/telemetry-stream.d.ts +11 -0
  149. package/lib/telemetry-stream.d.ts.map +1 -0
  150. package/lib/telemetry-stream.js +2 -0
  151. package/lib/telemetry-stream.js.map +1 -0
  152. package/lib/telemetry-xray.d.ts +28 -0
  153. package/lib/telemetry-xray.d.ts.map +1 -0
  154. package/lib/telemetry-xray.js +2 -0
  155. package/lib/telemetry-xray.js.map +1 -0
  156. package/lib/telemetry.d.ts +288 -0
  157. package/lib/telemetry.d.ts.map +1 -0
  158. package/lib/telemetry.js +3 -0
  159. package/lib/telemetry.js.map +1 -0
  160. package/lib/trait.d.ts +71 -20
  161. package/lib/trait.d.ts.map +1 -1
  162. package/lib/trait.js +1 -107
  163. package/lib/unknown-error.d.ts +18 -0
  164. package/lib/unknown-error.d.ts.map +1 -0
  165. package/lib/unknown-error.js +1 -0
  166. package/lib/xml.d.ts +44 -0
  167. package/lib/xml.d.ts.map +1 -0
  168. package/lib/xml.js +1 -0
  169. package/package.json +13 -13
  170. package/src/annotations.ts +53 -0
  171. package/src/api.ts +1370 -200
  172. package/src/category.ts +76 -106
  173. package/src/chunks.ts +30 -0
  174. package/src/config.ts +245 -0
  175. package/src/crypto.ts +202 -0
  176. package/src/error-category.ts +16 -29
  177. package/src/errors.ts +75 -75
  178. package/src/graphql.ts +1778 -0
  179. package/src/graphql.types.ts +105 -0
  180. package/src/grpc-transport-cloudflare-http2.ts +494 -0
  181. package/src/grpc-transport-cloudflare-sockets.ts +299 -0
  182. package/src/grpc-transport-node-http2.ts +234 -0
  183. package/src/grpc-transport.ts +118 -0
  184. package/src/hpack.ts +331 -0
  185. package/src/index.ts +31 -0
  186. package/src/pagination.ts +368 -94
  187. package/src/plain-values.ts +41 -0
  188. package/src/protobuf.ts +1332 -0
  189. package/src/protocol-grpc.ts +641 -0
  190. package/src/protocol-http.ts +622 -322
  191. package/src/protocol-rest.ts +440 -227
  192. package/src/query.ts +39 -0
  193. package/src/response-validation-strict.ts +327 -0
  194. package/src/response-validation.ts +161 -0
  195. package/src/retry-after.ts +7 -13
  196. package/src/retry.ts +96 -110
  197. package/src/schema-lite-impl.ts +550 -0
  198. package/src/schema-lite-typed.ts +44 -0
  199. package/src/schema-lite.ts +44 -0
  200. package/src/schema.ts +259 -15
  201. package/src/sdk-error.ts +33 -0
  202. package/src/sensitive.ts +154 -0
  203. package/src/telemetry-debug.ts +179 -0
  204. package/src/telemetry-hooks.ts +33 -0
  205. package/src/telemetry-host-rules.ts +39 -0
  206. package/src/telemetry-lambda-context.ts +46 -0
  207. package/src/telemetry-message-context.ts +170 -0
  208. package/src/telemetry-metrics.ts +69 -0
  209. package/src/telemetry-name-template.ts +26 -0
  210. package/src/telemetry-stream.ts +100 -0
  211. package/src/telemetry-xray.ts +66 -0
  212. package/src/telemetry.ts +832 -0
  213. package/src/trait.ts +106 -67
  214. package/src/unknown-error.ts +38 -0
  215. package/src/xml.ts +346 -0
  216. package/lib/api.js.map +0 -1
  217. package/lib/category.js.map +0 -1
  218. package/lib/codegen/cli.d.ts +0 -29
  219. package/lib/codegen/cli.d.ts.map +0 -1
  220. package/lib/codegen/cli.js +0 -165
  221. package/lib/codegen/cli.js.map +0 -1
  222. package/lib/codegen/emit.d.ts +0 -129
  223. package/lib/codegen/emit.d.ts.map +0 -1
  224. package/lib/codegen/emit.js +0 -105
  225. package/lib/codegen/emit.js.map +0 -1
  226. package/lib/codegen/format.d.ts +0 -23
  227. package/lib/codegen/format.d.ts.map +0 -1
  228. package/lib/codegen/format.js +0 -28
  229. package/lib/codegen/format.js.map +0 -1
  230. package/lib/codegen/generator.d.ts +0 -334
  231. package/lib/codegen/generator.d.ts.map +0 -1
  232. package/lib/codegen/generator.js +0 -691
  233. package/lib/codegen/generator.js.map +0 -1
  234. package/lib/codegen/graph.d.ts +0 -36
  235. package/lib/codegen/graph.d.ts.map +0 -1
  236. package/lib/codegen/graph.js +0 -136
  237. package/lib/codegen/graph.js.map +0 -1
  238. package/lib/codegen/members.d.ts +0 -25
  239. package/lib/codegen/members.d.ts.map +0 -1
  240. package/lib/codegen/members.js +0 -55
  241. package/lib/codegen/members.js.map +0 -1
  242. package/lib/codegen/naming.d.ts +0 -29
  243. package/lib/codegen/naming.d.ts.map +0 -1
  244. package/lib/codegen/naming.js +0 -74
  245. package/lib/codegen/naming.js.map +0 -1
  246. package/lib/codegen/openapi-cli.d.ts +0 -38
  247. package/lib/codegen/openapi-cli.d.ts.map +0 -1
  248. package/lib/codegen/openapi-cli.js +0 -107
  249. package/lib/codegen/openapi-cli.js.map +0 -1
  250. package/lib/codegen/openapi.d.ts +0 -115
  251. package/lib/codegen/openapi.d.ts.map +0 -1
  252. package/lib/codegen/openapi.js +0 -1220
  253. package/lib/codegen/openapi.js.map +0 -1
  254. package/lib/codegen/operations.d.ts +0 -24
  255. package/lib/codegen/operations.d.ts.map +0 -1
  256. package/lib/codegen/operations.js +0 -56
  257. package/lib/codegen/operations.js.map +0 -1
  258. package/lib/codegen/pagination.d.ts +0 -39
  259. package/lib/codegen/pagination.d.ts.map +0 -1
  260. package/lib/codegen/pagination.js +0 -33
  261. package/lib/codegen/pagination.js.map +0 -1
  262. package/lib/codegen/prelude.d.ts +0 -15
  263. package/lib/codegen/prelude.d.ts.map +0 -1
  264. package/lib/codegen/prelude.js +0 -60
  265. package/lib/codegen/prelude.js.map +0 -1
  266. package/lib/error-category.js.map +0 -1
  267. package/lib/errors.js.map +0 -1
  268. package/lib/json-patch.d.ts +0 -44
  269. package/lib/json-patch.d.ts.map +0 -1
  270. package/lib/json-patch.js +0 -174
  271. package/lib/json-patch.js.map +0 -1
  272. package/lib/pagination.js.map +0 -1
  273. package/lib/protocol-http.js.map +0 -1
  274. package/lib/protocol-rest.js.map +0 -1
  275. package/lib/retry-after.js.map +0 -1
  276. package/lib/retry.js.map +0 -1
  277. package/lib/schema.js.map +0 -1
  278. package/lib/trait.js.map +0 -1
  279. package/src/codegen/cli.ts +0 -268
  280. package/src/codegen/emit.ts +0 -207
  281. package/src/codegen/format.ts +0 -47
  282. package/src/codegen/generator.ts +0 -1153
  283. package/src/codegen/graph.ts +0 -151
  284. package/src/codegen/members.ts +0 -71
  285. package/src/codegen/naming.ts +0 -86
  286. package/src/codegen/openapi-cli.ts +0 -166
  287. package/src/codegen/openapi.ts +0 -1450
  288. package/src/codegen/operations.ts +0 -76
  289. package/src/codegen/pagination.ts +0 -71
  290. package/src/codegen/prelude.ts +0 -70
  291. 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 — effect Schema
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 — needed where only a single
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 — body members become form parts (objects
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` — `application/json` alone is a
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=…&account.name=…` (null/undefined entries skipped). This is
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 — e.g. endpoints that POST a bare JSON array). Mirrors
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→wire-name key dictionary for members whose full structure is
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>>) => Annotation;
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 for a typed error class. A matcher matches a wire
127
- * failure when every present field matches: `code` equals the wire error's
128
- * code, `status` equals the HTTP status, and `message` either equals the
129
- * error message (string form) or satisfies `includes` (substring) /
130
- * `matches` (regex). A matcher with no fields matches nothing.
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?: string | {
136
- readonly includes?: string;
137
- readonly matches?: string;
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 — see `matchTypedError` in `core/protocol-http`).
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
@@ -1 +1 @@
1
- {"version":3,"file":"trait.d.ts","sourceRoot":"","sources":["../src/trait.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,eAEhC,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,QAAQ,CAAC,WAAW,EAAE,GAAG,GAAG,WAAW,CAAC;CACzC,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACtC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,EAAE,KAAK,CAAC;QACrC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;QACxB,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC,CAAC;IACH,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,UAAU,CAM5E;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,GAAG,WAAW,EAAE,UAAU,EAAE,GAAG,UAAU,CAe5D;AAOD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EACX,KAAK,GACL,MAAM,GACN,KAAK,GACL,OAAO,GACP,QAAQ,GACR,MAAM,GACN,SAAS,CAAC;IACd,wFAAwF;IACxF,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,iBAAiB,CAAC;IACvD;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,C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M,GAAG;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAElG;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;IACrF,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;CAC/D;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,OAAO,CAAC,YAAY,aAAa,CAAC,YAAY,CAAC,KAAG,CAGrF,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,gBAAgB,QAAS,OAAO,KAAG,aAAa,CAAC,YAAY,CAAC,GAAG,SACzC,CAAC"}
package/lib/trait.js CHANGED
@@ -1,107 +1 @@
1
- export const annotationMetaSymbol = Symbol.for("@distilled.cloud/core/annotation-meta");
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
@@ -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.2",
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
- "@effect/platform-bun": ">=4.0.0-beta.102 || >=4.0.0",
35
- "@types/bun": "latest",
36
- "@types/node": "latest",
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": ">=4.0.0-beta.102 || >=4.0.0"
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
+ };