@distilled.cloud/core 1.0.0-rc.14 → 1.0.0-rc.16

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 (312) hide show
  1. package/lib/api.d.ts +118 -13
  2. package/lib/api.d.ts.map +1 -1
  3. package/lib/api.js +755 -147
  4. package/lib/api.js.map +1 -1
  5. package/lib/category.d.ts.map +1 -1
  6. package/lib/category.js +146 -146
  7. package/lib/category.js.map +1 -1
  8. package/lib/chunks.d.ts +3 -0
  9. package/lib/chunks.d.ts.map +1 -0
  10. package/lib/chunks.js +11 -0
  11. package/lib/chunks.js.map +1 -0
  12. package/lib/codegen/boolean-string-enums.js +36 -36
  13. package/lib/codegen/chunk.d.ts +7 -0
  14. package/lib/codegen/chunk.d.ts.map +1 -0
  15. package/lib/codegen/chunk.js +139 -0
  16. package/lib/codegen/chunk.js.map +1 -0
  17. package/lib/codegen/cli.d.ts.map +1 -1
  18. package/lib/codegen/cli.js +28 -14
  19. package/lib/codegen/cli.js.map +1 -1
  20. package/lib/codegen/datafy.d.ts +14 -0
  21. package/lib/codegen/datafy.d.ts.map +1 -0
  22. package/lib/codegen/datafy.js +853 -0
  23. package/lib/codegen/datafy.js.map +1 -0
  24. package/lib/codegen/dedupe.d.ts +5 -0
  25. package/lib/codegen/dedupe.d.ts.map +1 -0
  26. package/lib/codegen/dedupe.js +153 -0
  27. package/lib/codegen/dedupe.js.map +1 -0
  28. package/lib/codegen/emit.js +56 -56
  29. package/lib/codegen/format.js +18 -18
  30. package/lib/codegen/generated-at.js +29 -29
  31. package/lib/codegen/generator.d.ts.map +1 -1
  32. package/lib/codegen/generator.js +92 -84
  33. package/lib/codegen/generator.js.map +1 -1
  34. package/lib/codegen/graph.js +36 -36
  35. package/lib/codegen/graphql-client.d.ts +2 -0
  36. package/lib/codegen/graphql-client.d.ts.map +1 -1
  37. package/lib/codegen/graphql-client.js +55 -26
  38. package/lib/codegen/graphql-client.js.map +1 -1
  39. package/lib/codegen/graphql.js +113 -113
  40. package/lib/codegen/latin1.d.ts +3 -0
  41. package/lib/codegen/latin1.d.ts.map +1 -0
  42. package/lib/codegen/latin1.js +126 -0
  43. package/lib/codegen/latin1.js.map +1 -0
  44. package/lib/codegen/members.d.ts +7 -0
  45. package/lib/codegen/members.d.ts.map +1 -1
  46. package/lib/codegen/members.js +26 -19
  47. package/lib/codegen/members.js.map +1 -1
  48. package/lib/codegen/model-diff.js +6 -6
  49. package/lib/codegen/naming.js +19 -19
  50. package/lib/codegen/openapi-cli.js +15 -15
  51. package/lib/codegen/openapi.d.ts +17 -0
  52. package/lib/codegen/openapi.d.ts.map +1 -1
  53. package/lib/codegen/openapi.js +323 -169
  54. package/lib/codegen/openapi.js.map +1 -1
  55. package/lib/codegen/operations.js +14 -14
  56. package/lib/codegen/pagination.js +11 -11
  57. package/lib/codegen/patch-audit.js +57 -57
  58. package/lib/codegen/patches.js +79 -79
  59. package/lib/codegen/prelude.js +19 -19
  60. package/lib/codegen/privatize.d.ts +21 -0
  61. package/lib/codegen/privatize.d.ts.map +1 -0
  62. package/lib/codegen/privatize.js +176 -0
  63. package/lib/codegen/privatize.js.map +1 -0
  64. package/lib/codegen/proto.js +25 -25
  65. package/lib/codegen/pure.d.ts +6 -0
  66. package/lib/codegen/pure.d.ts.map +1 -0
  67. package/lib/codegen/pure.js +91 -0
  68. package/lib/codegen/pure.js.map +1 -0
  69. package/lib/codegen/rewrite-operation-ids.js +108 -108
  70. package/lib/codegen/spec-path.js +57 -57
  71. package/lib/codegen/table.d.ts +5 -0
  72. package/lib/codegen/table.d.ts.map +1 -0
  73. package/lib/codegen/table.js +249 -0
  74. package/lib/codegen/table.js.map +1 -0
  75. package/lib/config.d.ts +27 -0
  76. package/lib/config.d.ts.map +1 -0
  77. package/lib/config.js +161 -0
  78. package/lib/config.js.map +1 -0
  79. package/lib/crypto.d.ts +76 -0
  80. package/lib/crypto.d.ts.map +1 -0
  81. package/lib/crypto.js +130 -0
  82. package/lib/crypto.js.map +1 -0
  83. package/lib/debug.d.ts +2 -0
  84. package/lib/debug.d.ts.map +1 -0
  85. package/lib/debug.js +8 -0
  86. package/lib/debug.js.map +1 -0
  87. package/lib/error-category.d.ts +1 -1
  88. package/lib/error-category.d.ts.map +1 -1
  89. package/lib/error-category.js +7 -6
  90. package/lib/error-category.js.map +1 -1
  91. package/lib/errors.d.ts +62 -62
  92. package/lib/errors.d.ts.map +1 -1
  93. package/lib/errors.js +117 -114
  94. package/lib/errors.js.map +1 -1
  95. package/lib/graphql.d.ts +31 -20
  96. package/lib/graphql.d.ts.map +1 -1
  97. package/lib/graphql.js +150 -119
  98. package/lib/graphql.js.map +1 -1
  99. package/lib/graphql.types.js +4 -3
  100. package/lib/graphql.types.js.map +1 -1
  101. package/lib/index.d.ts +3 -2
  102. package/lib/index.d.ts.map +1 -1
  103. package/lib/index.js +15 -14
  104. package/lib/index.js.map +1 -1
  105. package/lib/json-patch.d.ts +2 -2
  106. package/lib/json-patch.js +28 -28
  107. package/lib/pagination.d.ts +9 -25
  108. package/lib/pagination.d.ts.map +1 -1
  109. package/lib/pagination.js +95 -90
  110. package/lib/pagination.js.map +1 -1
  111. package/lib/plain-values.d.ts +10 -0
  112. package/lib/plain-values.d.ts.map +1 -0
  113. package/lib/plain-values.js +40 -0
  114. package/lib/plain-values.js.map +1 -0
  115. package/lib/protocol-http.d.ts +50 -14
  116. package/lib/protocol-http.d.ts.map +1 -1
  117. package/lib/protocol-http.js +351 -178
  118. package/lib/protocol-http.js.map +1 -1
  119. package/lib/protocol-rest.d.ts +38 -25
  120. package/lib/protocol-rest.d.ts.map +1 -1
  121. package/lib/protocol-rest.js +238 -130
  122. package/lib/protocol-rest.js.map +1 -1
  123. package/lib/query.js +16 -16
  124. package/lib/response-validation-strict.d.ts +48 -0
  125. package/lib/response-validation-strict.d.ts.map +1 -0
  126. package/lib/response-validation-strict.js +284 -0
  127. package/lib/response-validation-strict.js.map +1 -0
  128. package/lib/response-validation.d.ts +43 -25
  129. package/lib/response-validation.d.ts.map +1 -1
  130. package/lib/response-validation.js +112 -70
  131. package/lib/response-validation.js.map +1 -1
  132. package/lib/retry-after.d.ts +3 -3
  133. package/lib/retry-after.js +49 -49
  134. package/lib/retry.d.ts +48 -29
  135. package/lib/retry.d.ts.map +1 -1
  136. package/lib/retry.js +142 -154
  137. package/lib/retry.js.map +1 -1
  138. package/lib/schema-lite-impl.d.ts +158 -0
  139. package/lib/schema-lite-impl.d.ts.map +1 -0
  140. package/lib/schema-lite-impl.js +341 -0
  141. package/lib/schema-lite-impl.js.map +1 -0
  142. package/lib/schema-lite-typed.d.ts +41 -0
  143. package/lib/schema-lite-typed.d.ts.map +1 -0
  144. package/lib/schema-lite-typed.js +27 -0
  145. package/lib/schema-lite-typed.js.map +1 -0
  146. package/lib/schema-lite.d.ts +40 -0
  147. package/lib/schema-lite.d.ts.map +1 -0
  148. package/lib/schema-lite.js +31 -0
  149. package/lib/schema-lite.js.map +1 -0
  150. package/lib/schema.d.ts +20 -6
  151. package/lib/schema.d.ts.map +1 -1
  152. package/lib/schema.js +202 -30
  153. package/lib/schema.js.map +1 -1
  154. package/lib/testing.d.ts +3 -2
  155. package/lib/testing.d.ts.map +1 -1
  156. package/lib/testing.js +22 -21
  157. package/lib/testing.js.map +1 -1
  158. package/lib/trait.d.ts +13 -13
  159. package/lib/trait.d.ts.map +1 -1
  160. package/lib/trait.js +80 -80
  161. package/lib/trait.js.map +1 -1
  162. package/lib/xml.d.ts +1 -1
  163. package/lib/xml.d.ts.map +1 -1
  164. package/lib/xml.js +38 -26
  165. package/lib/xml.js.map +1 -1
  166. package/package.json +9 -7
  167. package/src/api.ts +1079 -180
  168. package/src/category.ts +33 -33
  169. package/src/chunks.ts +30 -0
  170. package/src/codegen/chunk.ts +147 -0
  171. package/src/codegen/cli.ts +27 -1
  172. package/src/codegen/datafy.ts +874 -0
  173. package/src/codegen/dedupe.ts +173 -0
  174. package/src/codegen/generator.ts +10 -3
  175. package/src/codegen/graphql-client.ts +49 -15
  176. package/src/codegen/latin1.ts +131 -0
  177. package/src/codegen/members.ts +8 -0
  178. package/src/codegen/openapi.ts +194 -3
  179. package/src/codegen/privatize.ts +200 -0
  180. package/src/codegen/pure.ts +94 -0
  181. package/src/codegen/table.ts +254 -0
  182. package/src/config.ts +216 -0
  183. package/src/crypto.ts +202 -0
  184. package/src/debug.ts +8 -0
  185. package/src/error-category.ts +2 -1
  186. package/src/errors.ts +65 -56
  187. package/src/graphql.ts +109 -62
  188. package/src/graphql.types.ts +9 -7
  189. package/src/index.ts +3 -2
  190. package/src/json-patch.ts +2 -2
  191. package/src/pagination.ts +37 -18
  192. package/src/plain-values.ts +41 -0
  193. package/src/protocol-http.ts +378 -145
  194. package/src/protocol-rest.ts +337 -169
  195. package/src/response-validation-strict.ts +327 -0
  196. package/src/response-validation.ts +101 -50
  197. package/src/retry-after.ts +3 -3
  198. package/src/retry.ts +94 -93
  199. package/src/schema-lite-impl.ts +550 -0
  200. package/src/schema-lite-typed.ts +44 -0
  201. package/src/schema-lite.ts +44 -0
  202. package/src/schema.ts +258 -14
  203. package/src/testing.ts +4 -2
  204. package/src/trait.ts +36 -28
  205. package/src/xml.ts +31 -17
  206. package/lib/codegen/boolean-string-enums.test.d.ts +0 -2
  207. package/lib/codegen/boolean-string-enums.test.d.ts.map +0 -1
  208. package/lib/codegen/boolean-string-enums.test.js +0 -275
  209. package/lib/codegen/boolean-string-enums.test.js.map +0 -1
  210. package/lib/codegen/defer-naming.test.d.ts +0 -2
  211. package/lib/codegen/defer-naming.test.d.ts.map +0 -1
  212. package/lib/codegen/defer-naming.test.js +0 -105
  213. package/lib/codegen/defer-naming.test.js.map +0 -1
  214. package/lib/codegen/generated-at.test.d.ts +0 -2
  215. package/lib/codegen/generated-at.test.d.ts.map +0 -1
  216. package/lib/codegen/generated-at.test.js +0 -81
  217. package/lib/codegen/generated-at.test.js.map +0 -1
  218. package/lib/codegen/generator.test.d.ts +0 -2
  219. package/lib/codegen/generator.test.d.ts.map +0 -1
  220. package/lib/codegen/generator.test.js +0 -121
  221. package/lib/codegen/generator.test.js.map +0 -1
  222. package/lib/codegen/graphql-client.test.d.ts +0 -2
  223. package/lib/codegen/graphql-client.test.d.ts.map +0 -1
  224. package/lib/codegen/graphql-client.test.js +0 -171
  225. package/lib/codegen/graphql-client.test.js.map +0 -1
  226. package/lib/codegen/openapi-binary.test.d.ts +0 -2
  227. package/lib/codegen/openapi-binary.test.d.ts.map +0 -1
  228. package/lib/codegen/openapi-binary.test.js +0 -67
  229. package/lib/codegen/openapi-binary.test.js.map +0 -1
  230. package/lib/codegen/patch-audit.test.d.ts +0 -2
  231. package/lib/codegen/patch-audit.test.d.ts.map +0 -1
  232. package/lib/codegen/patch-audit.test.js +0 -141
  233. package/lib/codegen/patch-audit.test.js.map +0 -1
  234. package/lib/codegen/patches.test.d.ts +0 -2
  235. package/lib/codegen/patches.test.d.ts.map +0 -1
  236. package/lib/codegen/patches.test.js +0 -155
  237. package/lib/codegen/patches.test.js.map +0 -1
  238. package/lib/codegen/protocol-imports.test.d.ts +0 -2
  239. package/lib/codegen/protocol-imports.test.d.ts.map +0 -1
  240. package/lib/codegen/protocol-imports.test.js +0 -36
  241. package/lib/codegen/protocol-imports.test.js.map +0 -1
  242. package/lib/codegen/rewrite-operation-ids.test.d.ts +0 -2
  243. package/lib/codegen/rewrite-operation-ids.test.d.ts.map +0 -1
  244. package/lib/codegen/rewrite-operation-ids.test.js +0 -451
  245. package/lib/codegen/rewrite-operation-ids.test.js.map +0 -1
  246. package/lib/codegen/untagged-unions.test.d.ts +0 -2
  247. package/lib/codegen/untagged-unions.test.d.ts.map +0 -1
  248. package/lib/codegen/untagged-unions.test.js +0 -80
  249. package/lib/codegen/untagged-unions.test.js.map +0 -1
  250. package/lib/fixtures/xml/upstream-validator.json +0 -397
  251. package/lib/graphql.test.d.ts +0 -2
  252. package/lib/graphql.test.d.ts.map +0 -1
  253. package/lib/graphql.test.js +0 -151
  254. package/lib/graphql.test.js.map +0 -1
  255. package/lib/json-patch.test.d.ts +0 -2
  256. package/lib/json-patch.test.d.ts.map +0 -1
  257. package/lib/json-patch.test.js +0 -65
  258. package/lib/json-patch.test.js.map +0 -1
  259. package/lib/pagination.test.d.ts +0 -2
  260. package/lib/pagination.test.d.ts.map +0 -1
  261. package/lib/pagination.test.js +0 -131
  262. package/lib/pagination.test.js.map +0 -1
  263. package/lib/protocol-http.test.d.ts +0 -2
  264. package/lib/protocol-http.test.d.ts.map +0 -1
  265. package/lib/protocol-http.test.js +0 -228
  266. package/lib/protocol-http.test.js.map +0 -1
  267. package/lib/protocol-rest.test.d.ts +0 -2
  268. package/lib/protocol-rest.test.d.ts.map +0 -1
  269. package/lib/protocol-rest.test.js +0 -498
  270. package/lib/protocol-rest.test.js.map +0 -1
  271. package/lib/response-validation.test.d.ts +0 -2
  272. package/lib/response-validation.test.d.ts.map +0 -1
  273. package/lib/response-validation.test.js +0 -72
  274. package/lib/response-validation.test.js.map +0 -1
  275. package/lib/retry-after.test.d.ts +0 -2
  276. package/lib/retry-after.test.d.ts.map +0 -1
  277. package/lib/retry-after.test.js +0 -204
  278. package/lib/retry-after.test.js.map +0 -1
  279. package/lib/retry.test.d.ts +0 -2
  280. package/lib/retry.test.d.ts.map +0 -1
  281. package/lib/retry.test.js +0 -407
  282. package/lib/retry.test.js.map +0 -1
  283. package/lib/sdks.test.d.ts +0 -2
  284. package/lib/sdks.test.d.ts.map +0 -1
  285. package/lib/sdks.test.js +0 -76
  286. package/lib/sdks.test.js.map +0 -1
  287. package/lib/xml.test.d.ts +0 -2
  288. package/lib/xml.test.d.ts.map +0 -1
  289. package/lib/xml.test.js +0 -210
  290. package/lib/xml.test.js.map +0 -1
  291. package/src/codegen/boolean-string-enums.test.ts +0 -299
  292. package/src/codegen/defer-naming.test.ts +0 -113
  293. package/src/codegen/generated-at.test.ts +0 -89
  294. package/src/codegen/generator.test.ts +0 -137
  295. package/src/codegen/graphql-client.test.ts +0 -189
  296. package/src/codegen/openapi-binary.test.ts +0 -91
  297. package/src/codegen/patch-audit.test.ts +0 -160
  298. package/src/codegen/patches.test.ts +0 -188
  299. package/src/codegen/protocol-imports.test.ts +0 -39
  300. package/src/codegen/rewrite-operation-ids.test.ts +0 -472
  301. package/src/codegen/untagged-unions.test.ts +0 -85
  302. package/src/fixtures/xml/upstream-validator.json +0 -397
  303. package/src/graphql.test.ts +0 -198
  304. package/src/json-patch.test.ts +0 -77
  305. package/src/pagination.test.ts +0 -169
  306. package/src/protocol-http.test.ts +0 -276
  307. package/src/protocol-rest.test.ts +0 -703
  308. package/src/response-validation.test.ts +0 -89
  309. package/src/retry-after.test.ts +0 -267
  310. package/src/retry.test.ts +0 -566
  311. package/src/sdks.test.ts +0 -87
  312. package/src/xml.test.ts +0 -251
@@ -0,0 +1,91 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+ import { parseAst } from "rolldown/parseAst";
22
+ const MARKER = "/*@__PURE__*/ ";
23
+ const ALREADY_MARKED = /\/\*\s*[@#]__PURE__\s*\*\/\s*$/;
24
+ const isNode = (value) => value !== null && typeof value === "object" && typeof value.type === "string";
25
+
26
+ const collectCalls = (node, out) => {
27
+ if (Array.isArray(node)) {
28
+ for (const child of node)
29
+ collectCalls(child, out);
30
+ return;
31
+ }
32
+ if (!isNode(node))
33
+ return;
34
+ switch (node.type) {
35
+ case "ArrowFunctionExpression":
36
+ case "FunctionExpression":
37
+ case "ClassBody":
38
+ return;
39
+ case "TSAsExpression":
40
+ case "TSSatisfiesExpression":
41
+ case "TSNonNullExpression":
42
+ collectCalls(node.expression, out);
43
+ return;
44
+ case "CallExpression": {
45
+ const callee = node.callee;
46
+ // An IIFE runs its body at import; leave it alone.
47
+ if (callee.type !== "ArrowFunctionExpression" && callee.type !== "FunctionExpression") {
48
+ out.add(callee.start);
49
+ }
50
+ break;
51
+ }
52
+ case "NewExpression":
53
+ out.add(node.start);
54
+ break;
55
+ }
56
+ for (const [key, value] of Object.entries(node)) {
57
+ if (key === "type" || key === "start" || key === "end")
58
+ continue;
59
+ if (value !== null && typeof value === "object")
60
+ collectCalls(value, out);
61
+ }
62
+ };
63
+
64
+
65
+
66
+
67
+ export const annotateNestedCalls = (code, filename = "generated.ts") => {
68
+ const program = parseAst(code, { sourceType: "module", lang: "ts" }, filename);
69
+ const positions = new Set();
70
+ for (let statement of program.body) {
71
+ if (statement.type === "ExportNamedDeclaration" && isNode(statement.declaration)) {
72
+ statement = statement.declaration;
73
+ }
74
+ if (statement.type === "VariableDeclaration") {
75
+ for (const declaration of statement.declarations) {
76
+ collectCalls(declaration.init, positions);
77
+ }
78
+ }
79
+ else if (statement.type === "ClassDeclaration") {
80
+ collectCalls(statement.superClass, positions);
81
+ }
82
+ }
83
+ let out = code;
84
+ for (const position of [...positions].sort((a, b) => b - a)) {
85
+ if (ALREADY_MARKED.test(out.slice(Math.max(0, position - 32), position)))
86
+ continue;
87
+ out = `${out.slice(0, position)}${MARKER}${out.slice(position)}`;
88
+ }
89
+ return out;
90
+ };
91
+ //# sourceMappingURL=pure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pure.js","sourceRoot":"","sources":["../../src/codegen/pure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,MAAM,GAAG,gBAAgB,CAAC;AAChC,MAAM,cAAc,GAAG,gCAAgC,CAAC;AAOxD,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE,CAC/C,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAQ,KAAc,CAAC,IAAI,KAAK,QAAQ,CAAC;AAE1F,gFAAgF;AAChF,MAAM,YAAY,GAAG,CAAC,IAAa,EAAE,GAAgB,EAAQ,EAAE;IAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,I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,CAAC,QAAQ,CAAC,EAAE,CAAC;IACnE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
@@ -1,21 +1,21 @@
1
- /** Verb spellings normalised on the way out. */
1
+
2
2
  const VERB_ALIAS = {
3
3
  show: "get",
4
4
  index: "list",
5
5
  retrieve: "get",
6
6
  };
7
- /**
8
- * Rails `index` is a verb only when it is the whole id or a whole `_`
9
- * segment (`index`, `Apps_index`). Joined into a camel id it is the noun
10
- * (`InfoIndex`, `IndexCreate`, `IndexDocument`).
11
- */
7
+
8
+
9
+
10
+
11
+
12
12
  const isIndexVerb = (raw) => raw.toLowerCase() === "index";
13
- /**
14
- * Unambiguous verbs. An id that STARTS with one is already verb-first and
15
- * is never reordered (`WatchPodList`, `InsertCalendarList`,
16
- * `BulkDeleteMessages`); one found in the middle of a resource name
17
- * (`Apps_getOrCreate`) marks the id as a compound we leave alone.
18
- */
13
+
14
+
15
+
16
+
17
+
18
+
19
19
  const STRONG_VERBS = new Set([
20
20
  "get",
21
21
  "list",
@@ -133,12 +133,12 @@ const STRONG_VERBS = new Set([
133
133
  "unflag",
134
134
  "unclaim",
135
135
  ]);
136
- /**
137
- * Words that act as the verb when they TRAIL a resource (`MachinesStart`,
138
- * `SecretkeysSet`, `JobsRun`) but are ordinary nouns when they lead
139
- * (`ReleaseGet`, `RequestGet`, `SetGet`, `CheckRunsList`). Includes every
140
- * strong verb.
141
- */
136
+
137
+
138
+
139
+
140
+
141
+
142
142
  const TRAILING_VERBS = new Set([
143
143
  ...STRONG_VERBS,
144
144
  "notify",
@@ -209,11 +209,11 @@ const TRAILING_VERBS = new Set([
209
209
  "login",
210
210
  "logout",
211
211
  ]);
212
- /**
213
- * Leading tokens that are verbs often enough that an id starting with one
214
- * is left as-is unless a STRONG verb trails it (`QueryCreate` →
215
- * `createQuery`, but `QueryRun` stays).
216
- */
212
+
213
+
214
+
215
+
216
+
217
217
  const WEAK_LEADING_VERBS = new Set([
218
218
  ...TRAILING_VERBS,
219
219
  "request",
@@ -276,7 +276,7 @@ const WEAK_LEADING_VERBS = new Set([
276
276
  "track",
277
277
  "log",
278
278
  ]);
279
- /** Compound tokens the naive split would leave as `Secretkeys`. */
279
+
280
280
  const TOKEN_ALIAS = {
281
281
  secretkeys: "SecretKeys",
282
282
  secretkey: "SecretKey",
@@ -317,10 +317,10 @@ const IRREGULAR_SINGULAR = {
317
317
  mice: "mouse",
318
318
  geese: "goose",
319
319
  };
320
- /**
321
- * Nouns whose plural and singular coincide, or product names that end in
322
- * `s`. Never trimmed.
323
- */
320
+
321
+
322
+
323
+
324
324
  const UNCOUNTABLE = new Set([
325
325
  "postgres",
326
326
  "redis",
@@ -468,27 +468,27 @@ const UNCOUNTABLE = new Set([
468
468
  "k8s",
469
469
  "kubeadm",
470
470
  ]);
471
- /** Certificate variants that sit in front of the resource noun. */
471
+
472
472
  const QUALIFIERS = new Set(["acme", "custom"]);
473
473
  export const operationNameKey = (ctx) => `${ctx.method.toUpperCase()} ${ctx.path}`;
474
- /** Resolve {@link OperationIdRewrite} against method+path, then operationId. */
474
+
475
475
  export const resolveOperationName = (rewrite, operationId, ctx) => {
476
476
  if (typeof rewrite === "function")
477
477
  return rewrite(operationId, ctx);
478
478
  return rewrite[operationNameKey(ctx)] ?? rewrite[operationId];
479
479
  };
480
- /** `foo` → `Foo`; all-caps tokens (`CSI`, `API`) keep their casing. */
480
+
481
481
  const pascalToken = (raw) => {
482
482
  const alias = TOKEN_ALIAS[raw.toLowerCase()];
483
483
  if (alias !== undefined)
484
484
  return alias;
485
485
  return raw.charAt(0).toUpperCase() + raw.slice(1);
486
486
  };
487
- /**
488
- * Conservative singular. Only strips a trailing `s` when the word is a
489
- * regular plural we are confident about; anything ambiguous is returned
490
- * unchanged, because `getAlia` is worse than `getAliases`.
491
- */
487
+
488
+
489
+
490
+
491
+
492
492
  export const singularize = (raw) => {
493
493
  const lower = raw.toLowerCase();
494
494
  const keepCase = (s) => raw[0] === raw[0]?.toUpperCase() ? s.charAt(0).toUpperCase() + s.slice(1) : s;
@@ -529,10 +529,10 @@ export const singularize = (raw) => {
529
529
  return raw.slice(0, -1);
530
530
  };
531
531
  const lowerFirst = (s) => s.length === 0 ? s : s.charAt(0).toLowerCase() + s.slice(1);
532
- /**
533
- * Split on `_`, `-`, `/` and camel boundaries. Acronym runs stay together
534
- * (`CSIDriver` → `CSI`, `Driver`; `APIGroup` → `API`, `Group`).
535
- */
532
+
533
+
534
+
535
+
536
536
  const splitIdent = (s) => {
537
537
  const parts = [];
538
538
  for (const chunk of s.split(/[_/\-.\s]+/).filter(Boolean)) {
@@ -550,15 +550,15 @@ const isStrongVerb = (raw) => STRONG_VERBS.has(raw.toLowerCase());
550
550
  const isTrailingVerb = (raw) => TRAILING_VERBS.has(raw.toLowerCase());
551
551
  const isWeakLeadingVerb = (raw) => WEAK_LEADING_VERBS.has(raw.toLowerCase());
552
552
  const alias = (raw) => VERB_ALIAS[raw.toLowerCase()] ?? raw.toLowerCase();
553
- /** `version`-like tokens (`V1`, `v1beta1`, `V2`) are never nouns to singularise. */
553
+
554
554
  const isVersionToken = (raw) => /^[vV]\d/.test(raw);
555
- /** Adverbs that sit between resource and verb: `HoldoutsPartialUpdate`. */
555
+
556
556
  const MODIFIERS = new Set(["partial", "bulk", "batch", "all", "many"]);
557
- /**
558
- * `verb + Resource + Object`. Only the resource (last noun before the verb)
559
- * is singularised, and only for non-list verbs (`getApp`, `listApps`,
560
- * `listMachineEvents`). Parent tokens keep their spelling.
561
- */
557
+
558
+
559
+
560
+
561
+
562
562
  const assemble = (verb, nouns, tail = []) => {
563
563
  // `App_Certificates_acme_create`: the qualifier trails the resource in
564
564
  // the id but reads better in front of it (`createAppAcmeCertificate`).
@@ -577,21 +577,21 @@ const assemble = (verb, nouns, tail = []) => {
577
577
  });
578
578
  return verb + shaped.join("") + tail.map(pascalToken).join("");
579
579
  };
580
- /**
581
- * Distilled SDK names are verbNoun (`listApps`, `getApp`, `createMachine`).
582
- *
583
- * - Already verb-first (`listSprites`, `GetObject`, `showContact`,
584
- * `WatchPodList`) stays, with `show`/`index`/`retrieve` aliased.
585
- * - Trailing action (`ConfigsList`, `PlansGet`, `ContainerCreate`,
586
- * `VirtualMachinesStart`, `ReleaseGet`) moves the verb first and
587
- * singularises the resource for non-list verbs.
588
- * - go-swagger / autorest `Apps_list`, `App_Certificates_show`,
589
- * `Machines_list_events`, `ServiceMembers_getMetrics`: the verb heads the
590
- * first `_` segment after the resource.
591
- * - Anything else (`AppGetOrCreate`, `VirtualMachines_createOrUpdate`,
592
- * `DnsRecordsBatch`, `accountById`) is returned unchanged apart from
593
- * lowerFirst. Use {@link OperationIdRewrite} for those.
594
- */
580
+
581
+
582
+
583
+
584
+
585
+
586
+
587
+
588
+
589
+
590
+
591
+
592
+
593
+
594
+
595
595
  export const toVerbNoun = (operationId) => {
596
596
  const trimmed = operationId.trim();
597
597
  if (trimmed === "")
@@ -691,16 +691,16 @@ const remapTargets = (node, mapping) => {
691
691
  }
692
692
  return out;
693
693
  };
694
- /**
695
- * `metadata` key of a model whose final names are deferred (the OpenAPI
696
- * converter's `deferNaming`): upstream shape id → final shape id.
697
- * `finalizeConvert` applies it after the Smithy patches and removes it.
698
- */
694
+
695
+
696
+
697
+
698
+
699
699
  export const RENAME_METADATA_KEY = "distilled.rename";
700
- /**
701
- * Apply and remove a model's deferred rename ({@link RENAME_METADATA_KEY}).
702
- * Returns how many shapes it renamed.
703
- */
700
+
701
+
702
+
703
+
704
704
  export const applyDeferredRename = (model) => {
705
705
  const rename = model.metadata?.[RENAME_METADATA_KEY];
706
706
  if (rename === undefined)
@@ -713,12 +713,12 @@ export const applyDeferredRename = (model) => {
713
713
  renameShapes(model, mapping);
714
714
  return mapping.size;
715
715
  };
716
- /**
717
- * Rename shapes by id and rewrite every `target` that points at a renamed
718
- * one, keeping the model's shape order. All renames happen at once, so a
719
- * mapping may swap names. Throws when a new id is already taken by a shape
720
- * that keeps its name, or two shapes would land on one id.
721
- */
716
+
717
+
718
+
719
+
720
+
721
+
722
722
  export const renameShapes = (model, mapping) => {
723
723
  const shapes = model.shapes ?? {};
724
724
  const nextShapes = {};
@@ -731,33 +731,33 @@ export const renameShapes = (model, mapping) => {
731
731
  }
732
732
  model.shapes = nextShapes;
733
733
  };
734
- /** Version prefixes and API roots that carry no meaning in a name. */
734
+
735
735
  const NOISE_SEGMENTS = new Set(["api", "rest", "v", "public"]);
736
736
  const isNoiseSegment = (seg) => {
737
737
  const lower = seg.toLowerCase();
738
738
  return NOISE_SEGMENTS.has(lower) || /^v\d+(\.\d+)*$/.test(lower);
739
739
  };
740
740
  const HTTP_METHOD_ID = /^(get|post|put|patch|delete|head|options)(?=$|[-_./]|[A-Z0-9])/i;
741
- /**
742
- * Whether an OpenAPI `operationId` carries no information beyond the
743
- * method and path: absent, or a mechanical restatement of the route such
744
- * as `get-api-card`, `post_v1_users_id`, `getApiV1AnnotationLayer`. A
745
- * hand-chosen id that merely starts with the method (`delete-artifact` for
746
- * `/repos/{owner}/{repo}/actions/artifacts/{id}`) is NOT mechanical — it
747
- * names a subset of the route on purpose — so the id must cover every
748
- * literal path segment, and every id token must come from the route.
749
- */
750
- /**
751
- * A stricter subclass of mechanical ids: nothing in the id was chosen by
752
- * a person. Either there is no id, or the id is the route spelled out —
753
- * `postV1AppsByAppIdPromote`, `get_v1_users_id`, `get-api-card`,
754
- * `getCustomerById`. Such names are derived from the route alone.
755
- *
756
- * A `By…` clause counts as verbatim only when it names a whole parameter
757
- * (`ByAppId` for `{appId}`) or is a bare `ById`. `get_webhook_by_token`
758
- * for `/webhooks/{webhook_id}/{webhook_token}` is a chosen
759
- * disambiguation, so its nouns are kept; likewise `deleteScheduledJob`.
760
- */
741
+
742
+
743
+
744
+
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+
759
+
760
+
761
761
  export const isVerbatimRouteId = (operationId, ctx) => {
762
762
  if (!operationId)
763
763
  return true;
@@ -797,7 +797,7 @@ export const isVerbatimRouteId = (operationId, ctx) => {
797
797
  return lengths.some((n) => n <= c.length && c.slice(n).every((t) => literal.has(t)));
798
798
  });
799
799
  };
800
- /** `activity/get-feeds` → `get-feeds`: a tag prefix is not part of the name. */
800
+
801
801
  const stripTag = (operationId) => operationId.includes("/") ? operationId.slice(operationId.lastIndexOf("/") + 1) : operationId;
802
802
  export const isMechanicalOperationId = (operationId, ctx) => {
803
803
  if (!operationId)
@@ -875,12 +875,12 @@ export const pathToVerbNoun = (ctx, hints = {}) => {
875
875
  const routeNoise = new Set(segments
876
876
  .filter((seg) => !isParam(seg) && isNoiseSegment(seg))
877
877
  .flatMap((seg) => splitIdent(seg).map((t) => t.toLowerCase())));
878
- /** Whole parameter names as token lists (`{appId}` → ["app","id"]). */
878
+
879
879
  const params = segments
880
880
  .flatMap((seg) => [...seg.matchAll(/\{([^}]+)\}/g)])
881
881
  .map((mm) => splitIdent(mm[1]).map((t) => t.toLowerCase()));
882
882
  const raw = splitIdent(rest);
883
- /** Longest whole parameter name starting at raw[at], else 0. */
883
+
884
884
  const matchParam = (at) => {
885
885
  let best = 0;
886
886
  for (const prm of params) {
@@ -893,7 +893,7 @@ export const pathToVerbNoun = (ctx, hints = {}) => {
893
893
  return best;
894
894
  };
895
895
  const tokens = [];
896
- /** Index in `tokens` of a noun that a parameter immediately follows. */
896
+
897
897
  const followedByParam = new Set();
898
898
  for (let i = 0; i < raw.length; i++) {
899
899
  const t = raw[i];
@@ -1014,12 +1014,12 @@ export const pathToVerbNoun = (ctx, hints = {}) => {
1014
1014
  });
1015
1015
  return verb + shaped.flat().join("");
1016
1016
  };
1017
- /**
1018
- * Rename operations (and every shape whose name starts with the operation
1019
- * name — `FooRequest`, `FooResponse`, `FooRequestBody`, `FooResponseItemsList`)
1020
- * in a Smithy model to verbNoun PascalCase. Mutates `model.shapes`.
1021
- * Colliding names keep the original id and are reported.
1022
- */
1017
+
1018
+
1019
+
1020
+
1021
+
1022
+
1023
1023
  export const verbNounSmithyModel = (model) => {
1024
1024
  const shapes = model.shapes ?? {};
1025
1025
  const mapping = new Map();
@@ -1,61 +1,61 @@
1
- /**
2
- * Spec path resolution — the seam between a production spec mirror and a
3
- * local working copy of one (dev-time only).
4
- *
5
- * Every SDK package reads its specs from `packages/<pkg>/specs/`. In
6
- * production that directory holds a submodule of the package's mirror
7
- * repository, `distilled-mirror/spec-mirror-<pkg>`, whose layout is fixed:
8
- *
9
- * packages/<pkg>/specs/spec-mirror-<pkg>/
10
- * ├── .meta/ fetch-specs.ts + its package.json
11
- * └── specs/ what the generator reads
12
- *
13
- * A contributor adding a provider cannot create that repository — it lives in
14
- * an org they have no write access to, and it is only created once the
15
- * `distilled-submodules` stack deploys on merge to main. So `pnpm specs:local
16
- * <pkg>` runs the same `fetch-specs.ts` into a gitignored directory shaped
17
- * exactly like the mirror:
18
- *
19
- * packages/<pkg>/specs/.local/
20
- * ├── .meta/
21
- * └── specs/
22
- *
23
- * Setting {@link LOCAL_ENV} then re-roots every spec read into it. Nothing in
24
- * the package's source changes — the `specPath` a `convert.ts` declares stays
25
- * the production one — so there is no `.local` reference that could be
26
- * committed by accident, and the switch is impossible to leave on: it lives
27
- * in the environment of one command, never in a file.
28
- *
29
- * The opt-in is deliberate rather than a fallback-when-missing. A silent
30
- * fallback would regenerate an SDK from a stale `.local` copy the moment a
31
- * submodule failed to check out, and the result — committed, formatted,
32
- * plausible — would be indistinguishable from a real regeneration.
33
- */
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
34
  import * as fs from "node:fs";
35
35
  import * as path from "node:path";
36
- /** Set to a non-empty value to read specs from `specs/.local` instead. */
36
+
37
37
  export const LOCAL_ENV = "DISTILLED_SPECS_LOCAL";
38
- /** The local working copy of a mirror, relative to a package root. */
38
+
39
39
  export const LOCAL_DIR = path.join("specs", ".local");
40
- /** Repository name of the mirror feeding `packages/<pkg>`. */
40
+
41
41
  export const mirrorRepositoryName = (pkg) => `spec-mirror-${pkg}`;
42
- /** Whether this process reads specs from `specs/.local`. */
42
+
43
43
  export const isLocalSpecs = () => (process.env[LOCAL_ENV] ?? "").trim() !== "";
44
44
  let announced = false;
45
- /**
46
- * The path within a mirror's `specs/` directory that `specPath` names.
47
- *
48
- * Spec paths take one of two shapes — `specs/<mirror>/specs/<tail>` for a
49
- * submodule and `specs/<tail>` for a committed file — and in both the tail is
50
- * everything after the LAST `specs` segment. That one rule covers the
51
- * submodule form, the committed form, the nested forms
52
- * (`specs/<mirror>/specs/models/<service>/...`) and the directory form
53
- * (`specs/<mirror>/specs`, whose tail is empty — the mirror's `specs/`
54
- * directory itself) without needing to know which it was handed.
55
- *
56
- * `undefined` means there is no `specs` segment at all, which local mode
57
- * cannot interpret.
58
- */
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
59
  const tailWithinSpecs = (specPath) => {
60
60
  const segments = specPath.split(/[/\\]/).filter((s) => s !== "" && s !== ".");
61
61
  const last = segments.lastIndexOf("specs");
@@ -63,12 +63,12 @@ const tailWithinSpecs = (specPath) => {
63
63
  return undefined;
64
64
  return segments.slice(last + 1).join(path.sep);
65
65
  };
66
- /**
67
- * Resolve a package-relative spec path to an absolute one.
68
- *
69
- * @param root absolute package root (`path.resolve(import.meta.dirname, "..")`)
70
- * @param specPath the production path, relative to `root` (or absolute)
71
- */
66
+
67
+
68
+
69
+
70
+
71
+
72
72
  export const resolveSpecPath = (root, specPath) => {
73
73
  const production = path.resolve(root, specPath);
74
74
  if (!isLocalSpecs() || path.isAbsolute(specPath))
@@ -0,0 +1,5 @@
1
+ export declare const tableSchemas: (code: string, filename?: string) => {
2
+ code: string;
3
+ tabled: number;
4
+ };
5
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/codegen/table.ts"],"names":[],"mappings":"AAuCA,eAAO,MAAM,YAAY,SACjB,MAAM,wBAEX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAmNhC,CAAC"}