@distilled.cloud/core 1.0.0-rc.15 → 1.0.0-rc.17

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 (318) hide show
  1. package/lib/_bundle/aws.js +2 -0
  2. package/lib/_bundle/aws.js.map +1 -0
  3. package/lib/_bundle/base.js +5 -0
  4. package/lib/_bundle/base.js.map +1 -0
  5. package/lib/_bundle/graphql.js +3 -0
  6. package/lib/_bundle/graphql.js.map +1 -0
  7. package/lib/_bundle/rest.js +2 -0
  8. package/lib/_bundle/rest.js.map +1 -0
  9. package/lib/_bundle/xml.js +4 -0
  10. package/lib/_bundle/xml.js.map +1 -0
  11. package/lib/api.d.ts +118 -13
  12. package/lib/api.d.ts.map +1 -1
  13. package/lib/api.js +1 -188
  14. package/lib/category.d.ts.map +1 -1
  15. package/lib/category.js +1 -278
  16. package/lib/chunks.d.ts +3 -0
  17. package/lib/chunks.d.ts.map +1 -0
  18. package/lib/chunks.js +1 -0
  19. package/lib/codegen/boolean-string-enums.js +36 -36
  20. package/lib/codegen/chunk.d.ts +7 -0
  21. package/lib/codegen/chunk.d.ts.map +1 -0
  22. package/lib/codegen/chunk.js +139 -0
  23. package/lib/codegen/chunk.js.map +1 -0
  24. package/lib/codegen/cli.d.ts.map +1 -1
  25. package/lib/codegen/cli.js +28 -14
  26. package/lib/codegen/cli.js.map +1 -1
  27. package/lib/codegen/datafy.d.ts +14 -0
  28. package/lib/codegen/datafy.d.ts.map +1 -0
  29. package/lib/codegen/datafy.js +853 -0
  30. package/lib/codegen/datafy.js.map +1 -0
  31. package/lib/codegen/dedupe.d.ts +5 -0
  32. package/lib/codegen/dedupe.d.ts.map +1 -0
  33. package/lib/codegen/dedupe.js +153 -0
  34. package/lib/codegen/dedupe.js.map +1 -0
  35. package/lib/codegen/emit.js +56 -56
  36. package/lib/codegen/format.js +18 -18
  37. package/lib/codegen/generated-at.js +29 -29
  38. package/lib/codegen/generator.d.ts.map +1 -1
  39. package/lib/codegen/generator.js +92 -84
  40. package/lib/codegen/generator.js.map +1 -1
  41. package/lib/codegen/graph.js +36 -36
  42. package/lib/codegen/graphql-client.d.ts +2 -0
  43. package/lib/codegen/graphql-client.d.ts.map +1 -1
  44. package/lib/codegen/graphql-client.js +55 -26
  45. package/lib/codegen/graphql-client.js.map +1 -1
  46. package/lib/codegen/graphql.js +113 -113
  47. package/lib/codegen/latin1.d.ts +3 -0
  48. package/lib/codegen/latin1.d.ts.map +1 -0
  49. package/lib/codegen/latin1.js +126 -0
  50. package/lib/codegen/latin1.js.map +1 -0
  51. package/lib/codegen/members.d.ts +7 -0
  52. package/lib/codegen/members.d.ts.map +1 -1
  53. package/lib/codegen/members.js +26 -19
  54. package/lib/codegen/members.js.map +1 -1
  55. package/lib/codegen/model-diff.js +6 -6
  56. package/lib/codegen/naming.js +19 -19
  57. package/lib/codegen/openapi-cli.js +15 -15
  58. package/lib/codegen/openapi.d.ts +17 -0
  59. package/lib/codegen/openapi.d.ts.map +1 -1
  60. package/lib/codegen/openapi.js +323 -169
  61. package/lib/codegen/openapi.js.map +1 -1
  62. package/lib/codegen/operations.js +14 -14
  63. package/lib/codegen/pagination.js +11 -11
  64. package/lib/codegen/patch-audit.js +57 -57
  65. package/lib/codegen/patches.js +79 -79
  66. package/lib/codegen/prelude.js +19 -19
  67. package/lib/codegen/privatize.d.ts +21 -0
  68. package/lib/codegen/privatize.d.ts.map +1 -0
  69. package/lib/codegen/privatize.js +176 -0
  70. package/lib/codegen/privatize.js.map +1 -0
  71. package/lib/codegen/proto.js +25 -25
  72. package/lib/codegen/pure.d.ts +6 -0
  73. package/lib/codegen/pure.d.ts.map +1 -0
  74. package/lib/codegen/pure.js +91 -0
  75. package/lib/codegen/pure.js.map +1 -0
  76. package/lib/codegen/rewrite-operation-ids.js +108 -108
  77. package/lib/codegen/spec-path.js +57 -57
  78. package/lib/codegen/table.d.ts +5 -0
  79. package/lib/codegen/table.d.ts.map +1 -0
  80. package/lib/codegen/table.js +249 -0
  81. package/lib/codegen/table.js.map +1 -0
  82. package/lib/config.d.ts +27 -0
  83. package/lib/config.d.ts.map +1 -0
  84. package/lib/config.js +1 -0
  85. package/lib/crypto.d.ts +76 -0
  86. package/lib/crypto.d.ts.map +1 -0
  87. package/lib/crypto.js +1 -0
  88. package/lib/debug.d.ts +2 -0
  89. package/lib/debug.d.ts.map +1 -0
  90. package/lib/debug.js +1 -0
  91. package/lib/error-category.d.ts +1 -1
  92. package/lib/error-category.d.ts.map +1 -1
  93. package/lib/error-category.js +1 -46
  94. package/lib/errors.d.ts +62 -62
  95. package/lib/errors.d.ts.map +1 -1
  96. package/lib/errors.js +1 -195
  97. package/lib/graphql.d.ts +31 -20
  98. package/lib/graphql.d.ts.map +1 -1
  99. package/lib/graphql.js +1 -1027
  100. package/lib/graphql.types.js +1 -5
  101. package/lib/index.d.ts +3 -2
  102. package/lib/index.d.ts.map +1 -1
  103. package/lib/index.js +1 -15
  104. package/lib/json-patch.d.ts +2 -2
  105. package/lib/json-patch.js +1 -226
  106. package/lib/json-patch.js.map +1 -1
  107. package/lib/pagination.d.ts +9 -25
  108. package/lib/pagination.d.ts.map +1 -1
  109. package/lib/pagination.js +1 -266
  110. package/lib/plain-values.d.ts +10 -0
  111. package/lib/plain-values.d.ts.map +1 -0
  112. package/lib/plain-values.js +2 -0
  113. package/lib/plain-values.js.map +1 -0
  114. package/lib/protocol-http.d.ts +50 -14
  115. package/lib/protocol-http.d.ts.map +1 -1
  116. package/lib/protocol-http.js +1 -639
  117. package/lib/protocol-rest.d.ts +38 -25
  118. package/lib/protocol-rest.d.ts.map +1 -1
  119. package/lib/protocol-rest.js +1 -267
  120. package/lib/query.js +1 -27
  121. package/lib/response-validation-strict.d.ts +48 -0
  122. package/lib/response-validation-strict.d.ts.map +1 -0
  123. package/lib/response-validation-strict.js +1 -0
  124. package/lib/response-validation.d.ts +43 -25
  125. package/lib/response-validation.d.ts.map +1 -1
  126. package/lib/response-validation.js +1 -76
  127. package/lib/retry-after.d.ts +3 -3
  128. package/lib/retry-after.js +1 -112
  129. package/lib/retry.d.ts +48 -29
  130. package/lib/retry.d.ts.map +1 -1
  131. package/lib/retry.js +1 -209
  132. package/lib/schema-lite-impl.d.ts +158 -0
  133. package/lib/schema-lite-impl.d.ts.map +1 -0
  134. package/lib/schema-lite-impl.js +1 -0
  135. package/lib/schema-lite-typed.d.ts +41 -0
  136. package/lib/schema-lite-typed.d.ts.map +1 -0
  137. package/lib/schema-lite-typed.js +2 -0
  138. package/lib/schema-lite-typed.js.map +1 -0
  139. package/lib/schema-lite.d.ts +40 -0
  140. package/lib/schema-lite.d.ts.map +1 -0
  141. package/lib/schema-lite.js +1 -0
  142. package/lib/schema.d.ts +20 -6
  143. package/lib/schema.d.ts.map +1 -1
  144. package/lib/schema.js +1 -48
  145. package/lib/testing.d.ts +3 -2
  146. package/lib/testing.d.ts.map +1 -1
  147. package/lib/testing.js +1 -40
  148. package/lib/testing.js.map +1 -1
  149. package/lib/trait.d.ts +13 -13
  150. package/lib/trait.d.ts.map +1 -1
  151. package/lib/trait.js +1 -131
  152. package/lib/xml.d.ts +1 -1
  153. package/lib/xml.d.ts.map +1 -1
  154. package/lib/xml.js +1 -311
  155. package/package.json +9 -7
  156. package/src/api.ts +1080 -180
  157. package/src/category.ts +33 -33
  158. package/src/chunks.ts +30 -0
  159. package/src/codegen/chunk.ts +147 -0
  160. package/src/codegen/cli.ts +27 -1
  161. package/src/codegen/datafy.ts +874 -0
  162. package/src/codegen/dedupe.ts +173 -0
  163. package/src/codegen/generator.ts +10 -3
  164. package/src/codegen/graphql-client.ts +49 -15
  165. package/src/codegen/latin1.ts +131 -0
  166. package/src/codegen/members.ts +8 -0
  167. package/src/codegen/openapi.ts +194 -3
  168. package/src/codegen/privatize.ts +200 -0
  169. package/src/codegen/pure.ts +94 -0
  170. package/src/codegen/table.ts +254 -0
  171. package/src/config.ts +216 -0
  172. package/src/crypto.ts +202 -0
  173. package/src/debug.ts +8 -0
  174. package/src/error-category.ts +2 -1
  175. package/src/errors.ts +65 -56
  176. package/src/graphql.ts +109 -62
  177. package/src/graphql.types.ts +9 -7
  178. package/src/index.ts +3 -2
  179. package/src/json-patch.ts +2 -2
  180. package/src/pagination.ts +37 -18
  181. package/src/plain-values.ts +41 -0
  182. package/src/protocol-http.ts +378 -145
  183. package/src/protocol-rest.ts +337 -169
  184. package/src/response-validation-strict.ts +327 -0
  185. package/src/response-validation.ts +101 -50
  186. package/src/retry-after.ts +3 -3
  187. package/src/retry.ts +94 -93
  188. package/src/schema-lite-impl.ts +550 -0
  189. package/src/schema-lite-typed.ts +44 -0
  190. package/src/schema-lite.ts +44 -0
  191. package/src/schema.ts +258 -14
  192. package/src/testing.ts +4 -2
  193. package/src/trait.ts +36 -28
  194. package/src/xml.ts +31 -17
  195. package/lib/api.js.map +0 -1
  196. package/lib/category.js.map +0 -1
  197. package/lib/codegen/boolean-string-enums.test.d.ts +0 -2
  198. package/lib/codegen/boolean-string-enums.test.d.ts.map +0 -1
  199. package/lib/codegen/boolean-string-enums.test.js +0 -275
  200. package/lib/codegen/boolean-string-enums.test.js.map +0 -1
  201. package/lib/codegen/defer-naming.test.d.ts +0 -2
  202. package/lib/codegen/defer-naming.test.d.ts.map +0 -1
  203. package/lib/codegen/defer-naming.test.js +0 -105
  204. package/lib/codegen/defer-naming.test.js.map +0 -1
  205. package/lib/codegen/generated-at.test.d.ts +0 -2
  206. package/lib/codegen/generated-at.test.d.ts.map +0 -1
  207. package/lib/codegen/generated-at.test.js +0 -81
  208. package/lib/codegen/generated-at.test.js.map +0 -1
  209. package/lib/codegen/generator.test.d.ts +0 -2
  210. package/lib/codegen/generator.test.d.ts.map +0 -1
  211. package/lib/codegen/generator.test.js +0 -121
  212. package/lib/codegen/generator.test.js.map +0 -1
  213. package/lib/codegen/graphql-client.test.d.ts +0 -2
  214. package/lib/codegen/graphql-client.test.d.ts.map +0 -1
  215. package/lib/codegen/graphql-client.test.js +0 -171
  216. package/lib/codegen/graphql-client.test.js.map +0 -1
  217. package/lib/codegen/openapi-binary.test.d.ts +0 -2
  218. package/lib/codegen/openapi-binary.test.d.ts.map +0 -1
  219. package/lib/codegen/openapi-binary.test.js +0 -67
  220. package/lib/codegen/openapi-binary.test.js.map +0 -1
  221. package/lib/codegen/patch-audit.test.d.ts +0 -2
  222. package/lib/codegen/patch-audit.test.d.ts.map +0 -1
  223. package/lib/codegen/patch-audit.test.js +0 -141
  224. package/lib/codegen/patch-audit.test.js.map +0 -1
  225. package/lib/codegen/patches.test.d.ts +0 -2
  226. package/lib/codegen/patches.test.d.ts.map +0 -1
  227. package/lib/codegen/patches.test.js +0 -155
  228. package/lib/codegen/patches.test.js.map +0 -1
  229. package/lib/codegen/protocol-imports.test.d.ts +0 -2
  230. package/lib/codegen/protocol-imports.test.d.ts.map +0 -1
  231. package/lib/codegen/protocol-imports.test.js +0 -36
  232. package/lib/codegen/protocol-imports.test.js.map +0 -1
  233. package/lib/codegen/rewrite-operation-ids.test.d.ts +0 -2
  234. package/lib/codegen/rewrite-operation-ids.test.d.ts.map +0 -1
  235. package/lib/codegen/rewrite-operation-ids.test.js +0 -451
  236. package/lib/codegen/rewrite-operation-ids.test.js.map +0 -1
  237. package/lib/codegen/untagged-unions.test.d.ts +0 -2
  238. package/lib/codegen/untagged-unions.test.d.ts.map +0 -1
  239. package/lib/codegen/untagged-unions.test.js +0 -80
  240. package/lib/codegen/untagged-unions.test.js.map +0 -1
  241. package/lib/error-category.js.map +0 -1
  242. package/lib/errors.js.map +0 -1
  243. package/lib/fixtures/xml/upstream-validator.json +0 -397
  244. package/lib/graphql.js.map +0 -1
  245. package/lib/graphql.test.d.ts +0 -2
  246. package/lib/graphql.test.d.ts.map +0 -1
  247. package/lib/graphql.test.js +0 -151
  248. package/lib/graphql.test.js.map +0 -1
  249. package/lib/graphql.types.js.map +0 -1
  250. package/lib/index.js.map +0 -1
  251. package/lib/json-patch.test.d.ts +0 -2
  252. package/lib/json-patch.test.d.ts.map +0 -1
  253. package/lib/json-patch.test.js +0 -65
  254. package/lib/json-patch.test.js.map +0 -1
  255. package/lib/pagination.js.map +0 -1
  256. package/lib/pagination.test.d.ts +0 -2
  257. package/lib/pagination.test.d.ts.map +0 -1
  258. package/lib/pagination.test.js +0 -131
  259. package/lib/pagination.test.js.map +0 -1
  260. package/lib/protocol-http.js.map +0 -1
  261. package/lib/protocol-http.test.d.ts +0 -2
  262. package/lib/protocol-http.test.d.ts.map +0 -1
  263. package/lib/protocol-http.test.js +0 -228
  264. package/lib/protocol-http.test.js.map +0 -1
  265. package/lib/protocol-rest.js.map +0 -1
  266. package/lib/protocol-rest.test.d.ts +0 -2
  267. package/lib/protocol-rest.test.d.ts.map +0 -1
  268. package/lib/protocol-rest.test.js +0 -498
  269. package/lib/protocol-rest.test.js.map +0 -1
  270. package/lib/query.js.map +0 -1
  271. package/lib/response-validation.js.map +0 -1
  272. package/lib/response-validation.test.d.ts +0 -2
  273. package/lib/response-validation.test.d.ts.map +0 -1
  274. package/lib/response-validation.test.js +0 -72
  275. package/lib/response-validation.test.js.map +0 -1
  276. package/lib/retry-after.js.map +0 -1
  277. package/lib/retry-after.test.d.ts +0 -2
  278. package/lib/retry-after.test.d.ts.map +0 -1
  279. package/lib/retry-after.test.js +0 -204
  280. package/lib/retry-after.test.js.map +0 -1
  281. package/lib/retry.js.map +0 -1
  282. package/lib/retry.test.d.ts +0 -2
  283. package/lib/retry.test.d.ts.map +0 -1
  284. package/lib/retry.test.js +0 -407
  285. package/lib/retry.test.js.map +0 -1
  286. package/lib/schema.js.map +0 -1
  287. package/lib/sdks.test.d.ts +0 -2
  288. package/lib/sdks.test.d.ts.map +0 -1
  289. package/lib/sdks.test.js +0 -76
  290. package/lib/sdks.test.js.map +0 -1
  291. package/lib/trait.js.map +0 -1
  292. package/lib/xml.js.map +0 -1
  293. package/lib/xml.test.d.ts +0 -2
  294. package/lib/xml.test.d.ts.map +0 -1
  295. package/lib/xml.test.js +0 -210
  296. package/lib/xml.test.js.map +0 -1
  297. package/src/codegen/boolean-string-enums.test.ts +0 -299
  298. package/src/codegen/defer-naming.test.ts +0 -113
  299. package/src/codegen/generated-at.test.ts +0 -89
  300. package/src/codegen/generator.test.ts +0 -137
  301. package/src/codegen/graphql-client.test.ts +0 -189
  302. package/src/codegen/openapi-binary.test.ts +0 -91
  303. package/src/codegen/patch-audit.test.ts +0 -160
  304. package/src/codegen/patches.test.ts +0 -188
  305. package/src/codegen/protocol-imports.test.ts +0 -39
  306. package/src/codegen/rewrite-operation-ids.test.ts +0 -472
  307. package/src/codegen/untagged-unions.test.ts +0 -85
  308. package/src/fixtures/xml/upstream-validator.json +0 -397
  309. package/src/graphql.test.ts +0 -198
  310. package/src/json-patch.test.ts +0 -77
  311. package/src/pagination.test.ts +0 -169
  312. package/src/protocol-http.test.ts +0 -276
  313. package/src/protocol-rest.test.ts +0 -703
  314. package/src/response-validation.test.ts +0 -89
  315. package/src/retry-after.test.ts +0 -267
  316. package/src/retry.test.ts +0 -566
  317. package/src/sdks.test.ts +0 -87
  318. package/src/xml.test.ts +0 -251
package/lib/trait.js CHANGED
@@ -1,131 +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 labelEncodingSymbol = Symbol.for("@distilled.cloud/core/http/label-encoding");
47
- /** Preserve selected RFC 3986 pchar delimiters inside a single URI label. */
48
- export const LabelEncoding = (options) => {
49
- if (!/^[!$&'()*+,;=:@]*$/.test(options.preserve)) {
50
- throw new TypeError("LabelEncoding can preserve only URI path-segment delimiters");
51
- }
52
- return makeAnnotation(labelEncodingSymbol, options.preserve);
53
- };
54
- export const responseCodeSymbol = Symbol.for("@distilled.cloud/core/http/response-code");
55
- export const ResponseCode = () => makeAnnotation(responseCodeSymbol, true);
56
- export const headerSymbol = Symbol.for("@distilled.cloud/core/http/header");
57
- export const Header = (name) => makeAnnotation(headerSymbol, name ?? true);
58
- export const bodySymbol = Symbol.for("@distilled.cloud/core/http/body");
59
- export const Body = (name) => makeAnnotation(bodySymbol, name ?? true);
60
- export const querySymbol = Symbol.for("@distilled.cloud/core/http/query");
61
- export const Query = (name) => makeAnnotation(querySymbol, name ?? true);
62
- export const deepQuerySymbol = Symbol.for("@distilled.cloud/core/http/deep-query");
63
- /**
64
- * Binds a struct-valued input member to a family of DOTTED query parameters:
65
- * `{ account: { id, name } }` with `DeepQuery("account")` serializes as
66
- * `?account.id=…&account.name=…` (null/undefined entries skipped). This is
67
- * how several list endpoints model their filters on the wire (e.g.
68
- * Cloudflare zones list `account.id` / `account.name`) while the TS surface
69
- * keeps the nested-object shape (v0 parity).
70
- */
71
- export const DeepQuery = (name) => makeAnnotation(deepQuerySymbol, name ?? true);
72
- export const httpBodySymbol = Symbol.for("@distilled.cloud/core/http-body");
73
- /**
74
- * Marks the input member whose value IS the entire request body (raw arrays/
75
- * scalars — e.g. endpoints that POST a bare JSON array). Mirrors
76
- * `smithy.api#httpPayload`.
77
- */
78
- export const HttpBody = () => makeAnnotation(httpBodySymbol, true);
79
- export const stringEncodedSymbol = Symbol.for("@distilled.cloud/core/http/string-encoded");
80
- /**
81
- * Marks a member the API only accepts as the STRING spelling of its value —
82
- * `true` travels as `"true"`, `3` as `"3"` — while the TS surface keeps the
83
- * natural type (e.g. Cloudflare's multipart `validation_enabled`, which the
84
- * docs model as the enum `"true" | "false"`). The protocol stringifies body
85
- * members on encode, element-wise for lists; `null` is left alone. Query and
86
- * header bindings already serialize their values as strings, so the trait is
87
- * documentation there.
88
- */
89
- export const StringEncoded = () => makeAnnotation(stringEncodedSymbol, true);
90
- export const formDataFileSymbol = Symbol.for("@distilled.cloud/core/form-data-file");
91
- /**
92
- * Marks an input member holding `File`/`Blob` parts for a multipart upload
93
- * (`Http({ contentType: "multipart" })`). Each file is appended to the form
94
- * under its own filename.
95
- */
96
- export const FormDataFile = () => makeAnnotation(formDataFileSymbol, true);
97
- //#endregion
98
- //#region Generic JSON traits
99
- export const keyDictionarySymbol = Symbol.for("@distilled.cloud/core/key-dictionary");
100
- export const KeyDictionary = (dict) => makeAnnotation(keyDictionarySymbol, dict);
101
- export const unionCasesSymbol = Symbol.for("@distilled.cloud/core/union-cases");
102
- /**
103
- * Marks an opaque schema standing in for a discriminated union of object
104
- * cases, carrying each case's TS-facing key set. For APIs that return every
105
- * case's keys with `null` for the inactive ones, the protocol uses these key
106
- * sets to pick the active case and drop the others, so consumers' `"key" in
107
- * value` discrimination works.
108
- *
109
- * Key sets alone cannot tell apart cases that share them — the 41 resource
110
- * kinds of `resource_tagging`, the 34 page-rule actions — so when the union
111
- * has a discriminator the protocol reads the case off it and only falls back
112
- * to key-set scoring for a value whose tag is missing or unknown.
113
- */
114
- export const UnionCases = (cases, discriminator) => makeAnnotation(unionCasesSymbol, discriminator ? { cases, discriminator } : { cases });
115
- //#endregion
116
- //#region Error matcher traits
117
- export const errorMatchersSymbol = Symbol.for("@distilled.cloud/core/error-matchers");
118
- /**
119
- * Stamp wire-matching rules onto a generated error class. Protocols consult
120
- * these to decide which of an operation's declared error classes a failed
121
- * response should surface as (most specific matcher wins; ties break by
122
- * declaration order — see `matchTypedError` in `core/protocol-http`).
123
- */
124
- export const applyErrorMatchers = (cls, matchers) => {
125
- cls[errorMatchersSymbol] = matchers;
126
- return cls;
127
- };
128
- /** Read the matchers stamped on an error class, if any. */
129
- export const getErrorMatchers = (cls) => cls?.[errorMatchersSymbol];
130
- //#endregion
131
- //# sourceMappingURL=trait.js.map
1
+ export { trait$Body as Body, 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$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";
package/lib/xml.d.ts CHANGED
@@ -6,7 +6,7 @@ export interface XmlObject {
6
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
7
  readonly _tag: "XmlParseError";
8
8
  } & Readonly<A>;
9
- export declare class XmlParseError extends XmlParseError_base<{
9
+ export declare class XmlParseError extends /*@__PURE__*/ XmlParseError_base<{
10
10
  readonly message: string;
11
11
  /** UTF-16 offset in the original input; line and column are one-based. */
12
12
  readonly offset: number;
package/lib/xml.d.ts.map CHANGED
@@ -1 +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,aAAc,SAAQ,mBAAkC;IACnE,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;AAEL,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAwBD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,SAAS,CAuOlF;AAED,kFAAkF;AAClF,eAAO,MAAM,QAAQ,QACd,MAAM,YACD,eAAe,KACxB,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,CAQrC,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"}
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,CAQrC,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 CHANGED
@@ -1,311 +1 @@
1
- import * as Data from "effect/Data";
2
- import * as Effect from "effect/Effect";
3
- export class XmlParseError extends Data.TaggedError("XmlParseError") {
4
- }
5
- // XML 1.0 (Fifth Edition) NameStartChar / NameChar, including astral names.
6
- const namePattern =
7
- // XML NameChar explicitly includes combining marks as individual code points.
8
- // eslint-disable-next-line no-misleading-character-class
9
- /[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}.\-0-9\u00B7\u0300-\u036F\u203F-\u2040]*/uy;
10
- const invalidCharacter =
11
- // XML 1.0 forbids these literal controls and unpaired surrogates.
12
- // eslint-disable-next-line no-control-regex
13
- /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/u;
14
- const xmlSpace = /^[\t\n\r ]*$/;
15
- const declarationPattern = /^xml[\t\n\r ]+version[\t\n\r ]*=[\t\n\r ]*(?:"1\.0"|'1\.0')(?:[\t\n\r ]+encoding[\t\n\r ]*=[\t\n\r ]*(?:"[A-Za-z][A-Za-z0-9._-]*"|'[A-Za-z][A-Za-z0-9._-]*'))?(?:[\t\n\r ]+standalone[\t\n\r ]*=[\t\n\r ]*(?:"(?:yes|no)"|'(?:yes|no)'))?[\t\n\r ]*$/;
16
- /**
17
- * Parse DTD-free XML 1.0. Values remain strings;
18
- * repeated children become arrays, attributes use @_ and mixed text uses #text.
19
- * Names are preserved verbatim (no namespace resolution). Comments and PIs are
20
- * ignored. Text whitespace is preserved, except layout-only text in containers.
21
- * Empty HTTP bodies produce {}. This is not a DOM or a validating DTD processor.
22
- * Throws XmlParseError for malformed input or exceeded limits.
23
- * The iterative scanner allocates no Effects while traversing the document.
24
- */
25
- export function parseXmlSync(xml, options = {}) {
26
- let pos = xml.charCodeAt(0) === 0xfeff ? 1 : 0;
27
- const start = pos;
28
- const maxDepth = options.maxDepth ?? 256;
29
- const maxLength = options.maxLength ?? 64 * 1024 * 1024;
30
- const stack = [];
31
- const document = Object.create(null);
32
- let hasRoot = false;
33
- function fail(message, offset = pos) {
34
- offset = Math.min(offset, xml.length);
35
- const lines = xml.slice(0, offset).split(/\r\n|[\r\n]/);
36
- const line = lines.length;
37
- const column = lines[line - 1].length + 1;
38
- throw new XmlParseError({
39
- message: `${message} at ${line}:${column}`,
40
- offset,
41
- line,
42
- column,
43
- });
44
- }
45
- if (!Number.isSafeInteger(maxDepth) || maxDepth < 1)
46
- fail("Invalid maxDepth");
47
- if (!Number.isSafeInteger(maxLength) || maxLength < 0)
48
- fail("Invalid maxLength");
49
- if (xml.length > maxLength)
50
- fail("XML input length limit exceeded", 0);
51
- const invalid = invalidCharacter.exec(xml);
52
- if (invalid)
53
- fail("Invalid XML character", invalid.index);
54
- if (xmlSpace.test(xml.slice(start)))
55
- return document;
56
- function skipSpace() {
57
- const before = pos;
58
- while (pos < xml.length) {
59
- const c = xml.charCodeAt(pos);
60
- if (c !== 32 && c !== 9 && c !== 10 && c !== 13)
61
- break;
62
- pos++;
63
- }
64
- return pos !== before;
65
- }
66
- function readName() {
67
- namePattern.lastIndex = pos;
68
- const match = namePattern.exec(xml);
69
- if (!match)
70
- fail("Expected XML name");
71
- pos = namePattern.lastIndex;
72
- return match[0];
73
- }
74
- function decode(raw, offset, attribute = false) {
75
- const parts = [];
76
- let from = 0;
77
- while (from < raw.length) {
78
- const amp = raw.indexOf("&", from);
79
- const end = amp < 0 ? raw.length : amp;
80
- const literal = raw.slice(from, end);
81
- parts.push(attribute ? literal.replace(/\r\n|[\t\r\n]/g, " ") : literal.replace(/\r\n?/g, "\n"));
82
- if (amp < 0)
83
- break;
84
- const semi = raw.indexOf(";", amp + 1);
85
- if (semi < 0)
86
- fail("Unterminated entity reference", offset + amp);
87
- const entity = raw.slice(amp + 1, semi);
88
- switch (entity) {
89
- case "amp":
90
- parts.push("&");
91
- break;
92
- case "lt":
93
- parts.push("<");
94
- break;
95
- case "gt":
96
- parts.push(">");
97
- break;
98
- case "quot":
99
- parts.push('"');
100
- break;
101
- case "apos":
102
- parts.push("'");
103
- break;
104
- default: {
105
- if (!/^#(?:[0-9]+|x[0-9a-fA-F]+)$/.test(entity)) {
106
- fail("Unknown or invalid entity reference", offset + amp);
107
- }
108
- const code = entity[1] === "x"
109
- ? Number.parseInt(entity.slice(2), 16)
110
- : Number.parseInt(entity.slice(1), 10);
111
- if (!(code === 9 ||
112
- code === 10 ||
113
- code === 13 ||
114
- (code >= 0x20 && code <= 0xd7ff) ||
115
- (code >= 0xe000 && code <= 0xfffd) ||
116
- (code >= 0x10000 && code <= 0x10ffff))) {
117
- fail("Invalid character reference", offset + amp);
118
- }
119
- parts.push(String.fromCodePoint(code));
120
- }
121
- }
122
- from = semi + 1;
123
- }
124
- return parts.join("");
125
- }
126
- function finish(element) {
127
- const text = element.text.join("");
128
- let value;
129
- if (!element.hasChildren && !element.hasAttributes) {
130
- value = text;
131
- }
132
- else {
133
- if (text && (!element.hasChildren || element.hasCdata || !xmlSpace.test(text))) {
134
- element.object["#text"] = text;
135
- }
136
- value = element.object;
137
- }
138
- const parent = stack[stack.length - 1];
139
- const target = parent ? parent.object : document;
140
- if (parent)
141
- parent.hasChildren = true;
142
- if (!Object.hasOwn(target, element.name))
143
- target[element.name] = value;
144
- else {
145
- const previous = target[element.name];
146
- if (Array.isArray(previous))
147
- previous.push(value);
148
- else
149
- target[element.name] = [previous, value];
150
- }
151
- }
152
- while (pos < xml.length) {
153
- if (xml[pos] !== "<") {
154
- const offset = pos;
155
- const next = xml.indexOf("<", pos);
156
- pos = next < 0 ? xml.length : next;
157
- const raw = xml.slice(offset, pos);
158
- const element = stack[stack.length - 1];
159
- if (!element) {
160
- if (!xmlSpace.test(raw))
161
- fail("Text outside root element", offset);
162
- }
163
- else {
164
- const cdataEnd = raw.indexOf("]]>");
165
- if (cdataEnd >= 0)
166
- fail("Unexpected CDATA terminator", offset + cdataEnd);
167
- element.text.push(decode(raw, offset));
168
- }
169
- continue;
170
- }
171
- if (xml.startsWith("<!--", pos)) {
172
- const end = xml.indexOf("-->", pos + 4);
173
- if (end < 0)
174
- fail("Unterminated comment");
175
- const comment = xml.slice(pos + 4, end);
176
- if (comment.includes("--") || comment.endsWith("-"))
177
- fail("Invalid comment");
178
- pos = end + 3;
179
- }
180
- else if (xml.startsWith("<![CDATA[", pos)) {
181
- const element = stack[stack.length - 1];
182
- if (!element)
183
- fail("CDATA outside root element");
184
- const end = xml.indexOf("]]>", pos + 9);
185
- if (end < 0)
186
- fail("Unterminated CDATA");
187
- element.text.push(xml.slice(pos + 9, end).replace(/\r\n?/g, "\n"));
188
- element.hasCdata = true;
189
- pos = end + 3;
190
- }
191
- else if (xml.startsWith("<?", pos)) {
192
- const offset = pos;
193
- pos += 2;
194
- const target = readName();
195
- if (!xml.startsWith("?>", pos) && !skipSpace())
196
- fail("Expected PI whitespace");
197
- const end = xml.indexOf("?>", pos);
198
- if (end < 0)
199
- fail("Unterminated processing instruction", offset);
200
- if (target.toLowerCase() === "xml") {
201
- if (offset !== start || !declarationPattern.test(xml.slice(offset + 2, end))) {
202
- fail("Invalid or misplaced XML declaration", offset);
203
- }
204
- }
205
- pos = end + 2;
206
- }
207
- else if (xml.startsWith("<!", pos)) {
208
- fail("DTDs and markup declarations are not supported");
209
- }
210
- else if (xml.startsWith("</", pos)) {
211
- pos += 2;
212
- const name = readName();
213
- skipSpace();
214
- if (xml[pos] !== ">")
215
- fail("Expected closing tag terminator");
216
- const element = stack.pop();
217
- if (!element || element.name !== name)
218
- fail("Mismatched closing tag");
219
- pos++;
220
- finish(element);
221
- }
222
- else {
223
- if (stack.length >= maxDepth)
224
- fail("XML depth limit exceeded");
225
- if (stack.length === 0) {
226
- if (hasRoot)
227
- fail("Multiple root elements");
228
- hasRoot = true;
229
- }
230
- pos++;
231
- const element = {
232
- name: readName(),
233
- object: Object.create(null),
234
- text: [],
235
- hasChildren: false,
236
- hasAttributes: false,
237
- hasCdata: false,
238
- };
239
- while (true) {
240
- const spaced = skipSpace();
241
- if (xml.startsWith("/>", pos)) {
242
- pos += 2;
243
- finish(element);
244
- break;
245
- }
246
- if (xml[pos] === ">") {
247
- pos++;
248
- stack.push(element);
249
- break;
250
- }
251
- if (!spaced)
252
- fail("Expected whitespace or tag terminator");
253
- const name = readName();
254
- const key = `@_${name}`;
255
- if (Object.hasOwn(element.object, key))
256
- fail("Duplicate attribute");
257
- skipSpace();
258
- if (xml[pos++] !== "=")
259
- fail("Expected attribute equals sign");
260
- skipSpace();
261
- const quote = xml[pos++];
262
- if (quote !== '"' && quote !== "'")
263
- fail("Expected quoted attribute");
264
- const end = xml.indexOf(quote, pos);
265
- if (end < 0)
266
- fail("Unterminated attribute");
267
- const raw = xml.slice(pos, end);
268
- if (raw.includes("<"))
269
- fail("Unescaped '<' in attribute");
270
- element.object[key] = decode(raw, pos, true);
271
- element.hasAttributes = true;
272
- pos = end + 1;
273
- }
274
- }
275
- }
276
- if (stack.length)
277
- fail("Unclosed element");
278
- if (!hasRoot)
279
- fail("Missing root element");
280
- return document;
281
- }
282
- /** Parse XML lazily, reporting malformed documents in the typed error channel. */
283
- export const parseXml = (xml, options) => Effect.suspend(() => {
284
- try {
285
- return Effect.succeed(parseXmlSync(xml, options));
286
- }
287
- catch (error) {
288
- if (error instanceof XmlParseError)
289
- return Effect.fail(error);
290
- throw error;
291
- }
292
- });
293
- const xmlEscapes = {
294
- "&": "&amp;",
295
- "<": "&lt;",
296
- ">": "&gt;",
297
- '"': "&quot;",
298
- "'": "&apos;",
299
- };
300
- /**
301
- * Escape special XML characters in a string.
302
- */
303
- export const escapeXml = (s) => s.replace(/[&<>"']/g, (c) => xmlEscapes[c]);
304
- // =============================================================================
305
- // XML Tag Helpers
306
- // =============================================================================
307
- /**
308
- * Wrap content in an XML tag with optional xmlns attribute.
309
- */
310
- export const wrapTag = (tag, content, xmlns) => `<${tag}${xmlns ? ` xmlns="${escapeXml(xmlns)}"` : ""}>${content}</${tag}>`;
311
- //# sourceMappingURL=xml.js.map
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/core",
3
- "version": "1.0.0-rc.15",
3
+ "version": "1.0.0-rc.17",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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",
@@ -28,15 +29,16 @@
28
29
  }
29
30
  },
30
31
  "devDependencies": {
31
- "@effect/platform-node": "^4.0.0",
32
- "@types/node": "26.2.0",
33
- "effect": "^4.0.0",
34
- "vitest": "^4.1.8"
32
+ "@effect/platform-node": "^4.0.5",
33
+ "@types/node": "26.6.5",
34
+ "effect": "^4.0.5",
35
+ "rolldown": "1.2.13",
36
+ "vitest": "^5.0.4"
35
37
  },
36
38
  "peerDependencies": {
37
- "effect": "^4.0.0"
39
+ "effect": "^4.0.5"
38
40
  },
39
41
  "scripts": {
40
- "build": "tsc -b"
42
+ "build": "tsrs -b"
41
43
  }
42
44
  }