@distilled.cloud/core 0.30.3 → 1.0.0-rc.10

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 (216) hide show
  1. package/LICENSE +201 -0
  2. package/lib/api.d.ts +165 -0
  3. package/lib/api.d.ts.map +1 -0
  4. package/lib/api.js +190 -0
  5. package/lib/api.js.map +1 -0
  6. package/lib/category.d.ts +4 -4
  7. package/lib/category.js +4 -4
  8. package/lib/codegen/boolean-string-enums.d.ts +36 -0
  9. package/lib/codegen/boolean-string-enums.d.ts.map +1 -0
  10. package/lib/codegen/boolean-string-enums.js +94 -0
  11. package/lib/codegen/boolean-string-enums.js.map +1 -0
  12. package/lib/codegen/boolean-string-enums.test.d.ts +2 -0
  13. package/lib/codegen/boolean-string-enums.test.d.ts.map +1 -0
  14. package/lib/codegen/boolean-string-enums.test.js +147 -0
  15. package/lib/codegen/boolean-string-enums.test.js.map +1 -0
  16. package/lib/codegen/cli.d.ts +79 -0
  17. package/lib/codegen/cli.d.ts.map +1 -0
  18. package/lib/codegen/cli.js +149 -0
  19. package/lib/codegen/cli.js.map +1 -0
  20. package/lib/codegen/emit.d.ts +125 -0
  21. package/lib/codegen/emit.d.ts.map +1 -0
  22. package/lib/codegen/emit.js +101 -0
  23. package/lib/codegen/emit.js.map +1 -0
  24. package/lib/codegen/format.d.ts +23 -0
  25. package/lib/codegen/format.d.ts.map +1 -0
  26. package/lib/codegen/format.js +28 -0
  27. package/lib/codegen/format.js.map +1 -0
  28. package/lib/codegen/generator.d.ts +334 -0
  29. package/lib/codegen/generator.d.ts.map +1 -0
  30. package/lib/codegen/generator.js +813 -0
  31. package/lib/codegen/generator.js.map +1 -0
  32. package/lib/codegen/graph.d.ts +36 -0
  33. package/lib/codegen/graph.d.ts.map +1 -0
  34. package/lib/codegen/graph.js +136 -0
  35. package/lib/codegen/graph.js.map +1 -0
  36. package/lib/codegen/graphql-client.d.ts +62 -0
  37. package/lib/codegen/graphql-client.d.ts.map +1 -0
  38. package/lib/codegen/graphql-client.js +294 -0
  39. package/lib/codegen/graphql-client.js.map +1 -0
  40. package/lib/codegen/graphql-client.test.d.ts +2 -0
  41. package/lib/codegen/graphql-client.test.d.ts.map +1 -0
  42. package/lib/codegen/graphql-client.test.js +311 -0
  43. package/lib/codegen/graphql-client.test.js.map +1 -0
  44. package/lib/codegen/graphql.d.ts +207 -0
  45. package/lib/codegen/graphql.d.ts.map +1 -0
  46. package/lib/codegen/graphql.js +799 -0
  47. package/lib/codegen/graphql.js.map +1 -0
  48. package/lib/codegen/members.d.ts +25 -0
  49. package/lib/codegen/members.d.ts.map +1 -0
  50. package/lib/codegen/members.js +55 -0
  51. package/lib/codegen/members.js.map +1 -0
  52. package/lib/codegen/naming.d.ts +29 -0
  53. package/lib/codegen/naming.d.ts.map +1 -0
  54. package/lib/codegen/naming.js +74 -0
  55. package/lib/codegen/naming.js.map +1 -0
  56. package/lib/codegen/openapi-cli.d.ts +52 -0
  57. package/lib/codegen/openapi-cli.d.ts.map +1 -0
  58. package/lib/codegen/openapi-cli.js +109 -0
  59. package/lib/codegen/openapi-cli.js.map +1 -0
  60. package/lib/codegen/openapi.d.ts +178 -0
  61. package/lib/codegen/openapi.d.ts.map +1 -0
  62. package/lib/codegen/openapi.js +1377 -0
  63. package/lib/codegen/openapi.js.map +1 -0
  64. package/lib/codegen/operations.d.ts +24 -0
  65. package/lib/codegen/operations.d.ts.map +1 -0
  66. package/lib/codegen/operations.js +56 -0
  67. package/lib/codegen/operations.js.map +1 -0
  68. package/lib/codegen/pagination.d.ts +39 -0
  69. package/lib/codegen/pagination.d.ts.map +1 -0
  70. package/lib/codegen/pagination.js +33 -0
  71. package/lib/codegen/pagination.js.map +1 -0
  72. package/lib/codegen/patches.d.ts +65 -0
  73. package/lib/codegen/patches.d.ts.map +1 -0
  74. package/lib/codegen/patches.js +236 -0
  75. package/lib/codegen/patches.js.map +1 -0
  76. package/lib/codegen/patches.test.d.ts +2 -0
  77. package/lib/codegen/patches.test.d.ts.map +1 -0
  78. package/lib/codegen/patches.test.js +105 -0
  79. package/lib/codegen/patches.test.js.map +1 -0
  80. package/lib/codegen/prelude.d.ts +15 -0
  81. package/lib/codegen/prelude.d.ts.map +1 -0
  82. package/lib/codegen/prelude.js +60 -0
  83. package/lib/codegen/prelude.js.map +1 -0
  84. package/lib/codegen/proto.d.ts +121 -0
  85. package/lib/codegen/proto.d.ts.map +1 -0
  86. package/lib/codegen/proto.js +962 -0
  87. package/lib/codegen/proto.js.map +1 -0
  88. package/lib/codegen/rewrite-operation-ids.d.ts +131 -0
  89. package/lib/codegen/rewrite-operation-ids.d.ts.map +1 -0
  90. package/lib/codegen/rewrite-operation-ids.js +1079 -0
  91. package/lib/codegen/rewrite-operation-ids.js.map +1 -0
  92. package/lib/codegen/rewrite-operation-ids.test.d.ts +2 -0
  93. package/lib/codegen/rewrite-operation-ids.test.d.ts.map +1 -0
  94. package/lib/codegen/rewrite-operation-ids.test.js +533 -0
  95. package/lib/codegen/rewrite-operation-ids.test.js.map +1 -0
  96. package/lib/codegen/spec-path.d.ts +16 -0
  97. package/lib/codegen/spec-path.d.ts.map +1 -0
  98. package/lib/codegen/spec-path.js +101 -0
  99. package/lib/codegen/spec-path.js.map +1 -0
  100. package/lib/error-category.d.ts +28 -0
  101. package/lib/error-category.d.ts.map +1 -0
  102. package/lib/error-category.js +46 -0
  103. package/lib/error-category.js.map +1 -0
  104. package/lib/errors.d.ts +1 -0
  105. package/lib/errors.d.ts.map +1 -1
  106. package/lib/errors.js +18 -13
  107. package/lib/errors.js.map +1 -1
  108. package/lib/graphql.d.ts +284 -0
  109. package/lib/graphql.d.ts.map +1 -0
  110. package/lib/graphql.fixture.d.ts +249 -0
  111. package/lib/graphql.fixture.d.ts.map +1 -0
  112. package/lib/graphql.fixture.js +240 -0
  113. package/lib/graphql.fixture.js.map +1 -0
  114. package/lib/graphql.js +718 -0
  115. package/lib/graphql.js.map +1 -0
  116. package/lib/graphql.test.d.ts +2 -0
  117. package/lib/graphql.test.d.ts.map +1 -0
  118. package/lib/graphql.test.js +780 -0
  119. package/lib/graphql.test.js.map +1 -0
  120. package/lib/graphql.types.d.ts +2 -0
  121. package/lib/graphql.types.d.ts.map +1 -0
  122. package/lib/graphql.types.js +45 -0
  123. package/lib/graphql.types.js.map +1 -0
  124. package/lib/json-patch.d.ts +30 -30
  125. package/lib/json-patch.d.ts.map +1 -1
  126. package/lib/json-patch.js +73 -107
  127. package/lib/json-patch.js.map +1 -1
  128. package/lib/pagination.d.ts +77 -51
  129. package/lib/pagination.d.ts.map +1 -1
  130. package/lib/pagination.js +162 -94
  131. package/lib/pagination.js.map +1 -1
  132. package/lib/protocol-http.d.ts +74 -0
  133. package/lib/protocol-http.d.ts.map +1 -0
  134. package/lib/protocol-http.js +590 -0
  135. package/lib/protocol-http.js.map +1 -0
  136. package/lib/protocol-http.test.d.ts +2 -0
  137. package/lib/protocol-http.test.d.ts.map +1 -0
  138. package/lib/protocol-http.test.js +88 -0
  139. package/lib/protocol-http.test.js.map +1 -0
  140. package/lib/protocol-rest.d.ts +134 -0
  141. package/lib/protocol-rest.d.ts.map +1 -0
  142. package/lib/protocol-rest.js +256 -0
  143. package/lib/protocol-rest.js.map +1 -0
  144. package/lib/retry.d.ts +8 -2
  145. package/lib/retry.d.ts.map +1 -1
  146. package/lib/retry.js +22 -16
  147. package/lib/retry.js.map +1 -1
  148. package/lib/schema.d.ts +8 -9
  149. package/lib/schema.d.ts.map +1 -1
  150. package/lib/schema.js +8 -9
  151. package/lib/schema.js.map +1 -1
  152. package/lib/trait.d.ts +174 -0
  153. package/lib/trait.d.ts.map +1 -0
  154. package/lib/trait.js +123 -0
  155. package/lib/trait.js.map +1 -0
  156. package/package.json +24 -78
  157. package/src/api.ts +460 -0
  158. package/src/category.ts +4 -4
  159. package/src/codegen/boolean-string-enums.test.ts +168 -0
  160. package/src/codegen/boolean-string-enums.ts +106 -0
  161. package/src/codegen/cli.ts +285 -0
  162. package/src/codegen/emit.ts +203 -0
  163. package/src/codegen/format.ts +47 -0
  164. package/src/codegen/generator.ts +1283 -0
  165. package/src/codegen/graph.ts +151 -0
  166. package/src/codegen/graphql-client.test.ts +386 -0
  167. package/src/codegen/graphql-client.ts +419 -0
  168. package/src/codegen/graphql.ts +1217 -0
  169. package/src/codegen/members.ts +71 -0
  170. package/src/codegen/naming.ts +86 -0
  171. package/src/codegen/openapi-cli.ts +182 -0
  172. package/src/codegen/openapi.ts +1689 -0
  173. package/src/codegen/operations.ts +76 -0
  174. package/src/codegen/pagination.ts +71 -0
  175. package/src/codegen/patches.test.ts +130 -0
  176. package/src/codegen/patches.ts +291 -0
  177. package/src/codegen/prelude.ts +70 -0
  178. package/src/codegen/proto.ts +1128 -0
  179. package/src/codegen/rewrite-operation-ids.test.ts +563 -0
  180. package/src/codegen/rewrite-operation-ids.ts +1206 -0
  181. package/src/codegen/spec-path.ts +115 -0
  182. package/src/error-category.ts +84 -0
  183. package/src/errors.ts +22 -25
  184. package/src/graphql.fixture.ts +371 -0
  185. package/src/graphql.test.ts +974 -0
  186. package/src/graphql.ts +1321 -0
  187. package/src/graphql.types.ts +185 -0
  188. package/src/json-patch.ts +95 -122
  189. package/src/pagination.ts +217 -146
  190. package/src/protocol-http.test.ts +107 -0
  191. package/src/protocol-http.ts +735 -0
  192. package/src/protocol-rest.ts +391 -0
  193. package/src/retry.ts +21 -22
  194. package/src/schema.ts +9 -10
  195. package/src/trait.ts +274 -0
  196. package/README.md +0 -30
  197. package/lib/client.d.ts +0 -167
  198. package/lib/client.d.ts.map +0 -1
  199. package/lib/client.js +0 -659
  200. package/lib/client.js.map +0 -1
  201. package/lib/schemas.d.ts +0 -60
  202. package/lib/schemas.d.ts.map +0 -1
  203. package/lib/schemas.js +0 -79
  204. package/lib/schemas.js.map +0 -1
  205. package/lib/sensitive.d.ts +0 -71
  206. package/lib/sensitive.d.ts.map +0 -1
  207. package/lib/sensitive.js +0 -96
  208. package/lib/sensitive.js.map +0 -1
  209. package/lib/traits.d.ts +0 -421
  210. package/lib/traits.d.ts.map +0 -1
  211. package/lib/traits.js +0 -737
  212. package/lib/traits.js.map +0 -1
  213. package/src/client.ts +0 -1177
  214. package/src/schemas.ts +0 -128
  215. package/src/sensitive.ts +0 -119
  216. package/src/traits.ts +0 -996
@@ -0,0 +1,105 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { mkdtempSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { FINALIZED_KEY, danglingTargets, finalizeConvert, syncServiceOperations, } from "./patches.js";
6
+ const model = () => ({
7
+ smithy: "2.0",
8
+ shapes: {
9
+ "ns#Svc": {
10
+ type: "service",
11
+ operations: [{ target: "ns#AppsList" }, { target: "ns#AppsGet" }],
12
+ },
13
+ "ns#AppsList": {
14
+ type: "operation",
15
+ input: { target: "ns#AppsListRequest" },
16
+ output: { target: "smithy.api#Unit" },
17
+ },
18
+ "ns#AppsListRequest": { type: "structure", members: {} },
19
+ "ns#AppsGet": {
20
+ type: "operation",
21
+ input: { target: "smithy.api#Unit" },
22
+ output: { target: "smithy.api#Unit" },
23
+ },
24
+ },
25
+ });
26
+ const scaffold = (patches) => {
27
+ const root = mkdtempSync(join(tmpdir(), "finalize-"));
28
+ mkdirSync(join(root, ".generated-specs"));
29
+ writeFileSync(join(root, ".generated-specs", "svc.json"), JSON.stringify(model()));
30
+ if (patches) {
31
+ mkdirSync(join(root, "patches", "svc"), { recursive: true });
32
+ writeFileSync(join(root, "patches", "svc", "a.json"), JSON.stringify(patches));
33
+ }
34
+ return root;
35
+ };
36
+ const read = (root) => JSON.parse(readFileSync(join(root, ".generated-specs", "svc.json"), "utf8"));
37
+ describe("finalizeConvert", () => {
38
+ test("renames, syncs the service list, stamps the marker", async () => {
39
+ const root = scaffold();
40
+ await finalizeConvert({ root });
41
+ const m = read(root);
42
+ expect(Object.keys(m.shapes).sort()).toEqual(["ns#Svc", "ns#ListApps", "ns#ListAppsRequest", "ns#GetApp"].sort());
43
+ expect(m.shapes["ns#Svc"].operations).toEqual([
44
+ { target: "ns#ListApps" },
45
+ { target: "ns#GetApp" },
46
+ ]);
47
+ expect(m.metadata[FINALIZED_KEY]).toBe(true);
48
+ });
49
+ test("refuses a second pass", async () => {
50
+ const root = scaffold();
51
+ await finalizeConvert({ root });
52
+ await expect(finalizeConvert({ root })).rejects.toThrow(/already finalized/);
53
+ });
54
+ test("applies Smithy patches and repairs the service list after a move", async () => {
55
+ const root = scaffold({
56
+ patches: [
57
+ { op: "move", from: "/shapes/ns#AppsGet", path: "/shapes/ns#FetchApp" },
58
+ ],
59
+ });
60
+ await finalizeConvert({ root });
61
+ const m = read(root);
62
+ expect(m.shapes["ns#FetchApp"]).toBeDefined();
63
+ expect(m.shapes["ns#Svc"].operations.map((o) => o.target)).toEqual([
64
+ "ns#ListApps",
65
+ "ns#FetchApp",
66
+ ]);
67
+ });
68
+ test("fails on a stale patch pointer by default", async () => {
69
+ const root = scaffold({
70
+ patches: [{ op: "remove", path: "/shapes/ns#Missing" }],
71
+ });
72
+ await expect(finalizeConvert({ root })).rejects.toThrow(/failed/);
73
+ });
74
+ test("fails on dangling targets and leaves the model unstamped", async () => {
75
+ const root = scaffold({
76
+ patches: [
77
+ {
78
+ op: "replace",
79
+ path: "/shapes/ns#AppsList/output/target",
80
+ value: "ns#Nope",
81
+ },
82
+ ],
83
+ });
84
+ await expect(finalizeConvert({ root })).rejects.toThrow(/do not exist/);
85
+ expect(read(root).metadata?.[FINALIZED_KEY]).toBeUndefined();
86
+ });
87
+ });
88
+ describe("danglingTargets", () => {
89
+ test("ignores prelude ids", () => {
90
+ expect(danglingTargets(model())).toEqual([]);
91
+ });
92
+ });
93
+ describe("syncServiceOperations", () => {
94
+ test("drops missing and appends unlisted, keeping order", () => {
95
+ const m = model();
96
+ delete m.shapes["ns#AppsGet"];
97
+ m.shapes["ns#Zed"] = { type: "operation" };
98
+ expect(syncServiceOperations(m)).toBe(1);
99
+ expect(m.shapes["ns#Svc"].operations).toEqual([
100
+ { target: "ns#AppsList" },
101
+ { target: "ns#Zed" },
102
+ ]);
103
+ });
104
+ });
105
+ //# sourceMappingURL=patches.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patches.test.js","sourceRoot":"","sources":["../../src/codegen/patches.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAEtB,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,CAAC;IACnB,MAAM,EAAE,KAAK;IACb,MAAM,EAAE;QACN,QAAQ,EAAE;YACR,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;SAClE;QACD,aAAa,EAAE;YACb,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE,MAAM,EAAE,oBAAoB,EAAE;YACvC,MAAM,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE;SACtC;QACD,oBAAoB,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE;QACxD,YAAY,EAAE;YACZ,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE;YACpC,MAAM,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE;SACtC;KACF;CACF,CAAC,CAAC;AAEH,MAAM,QAAQ,GAAG,CAAC,OAAiC,EAAE,EAA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,CAAC,CAAC;QACtC,CAAC,CAAC,MAAc,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;QACpD,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzC,MAAM,CAAE,CAAC,CAAC,MAAc,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;YACrD,EAAE,MAAM,EAAE,aAAa,EAAE;YACzB,EAAE,MAAM,EAAE,QAAQ,EAAE;SACrB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /** Prelude shape → schema expression (JSON-wire flavor). */
2
+ export declare const JSON_PRELUDE: Record<string, string>;
3
+ /** TypeScript type for each prelude shape, mirroring {@link JSON_PRELUDE}. */
4
+ export declare const TS_JSON_PRELUDE: Record<string, string>;
5
+ /**
6
+ * Schema reference resolver: prelude shapes map through the prelude table,
7
+ * forward references (including into cycles) wrap in `S.suspend`.
8
+ */
9
+ export declare const makeSchemaRef: (prelude: Record<string, string>, indexOf: ReadonlyMap<string, number>) => ((target: string, selfIdx: number) => string);
10
+ /**
11
+ * TypeScript type reference resolver. Named shapes all get an emitted
12
+ * interface / type alias, so forward references are always fine.
13
+ */
14
+ export declare const makeTsRef: (tsPrelude: Record<string, string>) => ((target: string) => string);
15
+ //# sourceMappingURL=prelude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prelude.d.ts","sourceRoot":"","sources":["../../src/codegen/prelude.ts"],"names":[],"mappings":"AAYA,4DAA4D;AAC5D,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAa/C,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAalD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,YAEb,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WACtB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,KACnC,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAQ9C,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,SAAS,cACR,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAEa,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Smithy prelude scalar baselines + reference resolvers for the SDK
3
+ * generators (dev-time only).
4
+ *
5
+ * The JSON flavor maps timestamps/blobs to plain strings — the baseline for
6
+ * SDKs whose wire format is JSON-over-docs (cloudflare). Generators with
7
+ * richer models (AWS) emit real timestamp/blob schemas themselves and only
8
+ * fall back here for untyped scalars.
9
+ */
10
+ import { isPrelude, local } from "./naming.js";
11
+ import { isForwardRef } from "./graph.js";
12
+ /** Prelude shape → schema expression (JSON-wire flavor). */
13
+ export const JSON_PRELUDE = {
14
+ String: "S.String",
15
+ Boolean: "S.Boolean",
16
+ Double: "S.Number",
17
+ Float: "S.Number",
18
+ Integer: "S.Number",
19
+ Long: "S.Number",
20
+ BigInteger: "S.Number",
21
+ BigDecimal: "S.Number",
22
+ Timestamp: "S.String",
23
+ Blob: "S.String",
24
+ Document: "S.Unknown",
25
+ Unit: "S.Struct({})",
26
+ };
27
+ /** TypeScript type for each prelude shape, mirroring {@link JSON_PRELUDE}. */
28
+ export const TS_JSON_PRELUDE = {
29
+ String: "string",
30
+ Boolean: "boolean",
31
+ Double: "number",
32
+ Float: "number",
33
+ Integer: "number",
34
+ Long: "number",
35
+ BigInteger: "number",
36
+ BigDecimal: "number",
37
+ Timestamp: "string",
38
+ Blob: "string",
39
+ Document: "unknown",
40
+ Unit: "{}",
41
+ };
42
+ /**
43
+ * Schema reference resolver: prelude shapes map through the prelude table,
44
+ * forward references (including into cycles) wrap in `S.suspend`.
45
+ */
46
+ export const makeSchemaRef = (prelude, indexOf) => (target, selfIdx) => {
47
+ if (isPrelude(target))
48
+ return prelude[local(target)] ?? "S.Unknown";
49
+ const name = local(target);
50
+ if (isForwardRef(indexOf, target, selfIdx)) {
51
+ return `S.suspend(() => ${name})`;
52
+ }
53
+ return name;
54
+ };
55
+ /**
56
+ * TypeScript type reference resolver. Named shapes all get an emitted
57
+ * interface / type alias, so forward references are always fine.
58
+ */
59
+ export const makeTsRef = (tsPrelude) => (target) => isPrelude(target) ? (tsPrelude[local(target)] ?? "unknown") : local(target);
60
+ //# sourceMappingURL=prelude.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prelude.js","sourceRoot":"","sources":["../../src/codegen/prelude.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,4DAA4D;AAC5D,MAAM,CAAC,MAAM,YAAY,GAA2B;IAClD,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,WAAW;IACpB,MAAM,EAAE,UAAU;IAClB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,UAAU;IAChB,UAAU,EAAE,UAAU;IACtB,UAAU,EAAE,UAAU;IACtB,SAAS,EAAE,UAAU;IACrB,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,WAAW;IACrB,IAAI,EAAE,cAAc;CACrB,CAAC;AAEF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,eAAe,GAA2B;IACrD,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,QAAQ;IACnB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,SAAS;IACnB,IAAI,EAAE,IAAI;CACX,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,CACE,OAA+B,EAC/B,OAAoC,EACW,EAAE,CACnD,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;IAClB,IAAI,SAAS,CAAC,MAAM,CAAC;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,WAAW,CAAC;IACpE,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,IAAI,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAC3C,OAAO,mBAAmB,IAAI,GAAG,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEJ;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GACpB,CAAC,SAAiC,EAAgC,EAAE,CACpE,CAAC,MAAM,EAAE,EAAE,CACT,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Proto3 → Smithy 2.0 JSON converter (dev-time only, provider-agnostic).
3
+ *
4
+ * Turns one or more `.proto` files (a package of messages, enums, and gRPC
5
+ * services) into the same Smithy JSON model shape the other spec converters
6
+ * produce (`{ smithy: "2.0", metadata, shapes }`), so a proto-sourced
7
+ * provider flows through the shared `generateService` compiler.
8
+ *
9
+ * Mapping (proto3 JSON encoding on the wire):
10
+ *
11
+ * • each selected unary `rpc` → a Smithy operation, `POST /<package>.<Service>/<Method>`
12
+ * • request/response messages → structures; members are camelCase (proto3 JSON)
13
+ * • `repeated` → list, `map<k,v>` → map (JSON object keys are strings)
14
+ * • `oneof` fields flatten onto the parent (proto3 JSON is untagged)
15
+ * • enums → string enums (proto3 JSON emits the name)
16
+ * • 64-bit integers → `smithy.api#String` (proto3 JSON encodes them as strings)
17
+ * • `bytes` → `smithy.api#Blob` (base64 on the JSON wire)
18
+ * • `google.protobuf.Empty` I/O → `smithy.api#Unit`
19
+ * • streaming RPCs are skipped by default (they are not request/response POSTs)
20
+ *
21
+ * The converter does not speak binary protobuf. Generated SDKs send proto3
22
+ * JSON at the gRPC method path — Connect-JSON / grpc-JSON transcoding shape.
23
+ */
24
+ export declare const PRELUDE: {
25
+ readonly String: "smithy.api#String";
26
+ readonly Boolean: "smithy.api#Boolean";
27
+ readonly Integer: "smithy.api#Integer";
28
+ readonly Long: "smithy.api#Long";
29
+ readonly Float: "smithy.api#Float";
30
+ readonly Double: "smithy.api#Double";
31
+ readonly Timestamp: "smithy.api#Timestamp";
32
+ readonly Blob: "smithy.api#Blob";
33
+ readonly Document: "smithy.api#Document";
34
+ readonly Unit: "smithy.api#Unit";
35
+ };
36
+ export interface ProtoField {
37
+ readonly name: string;
38
+ readonly type: string;
39
+ readonly repeated: boolean;
40
+ readonly optional: boolean;
41
+ readonly mapKey?: string;
42
+ readonly mapValue?: string;
43
+ readonly jsonName?: string;
44
+ readonly deprecated: boolean;
45
+ readonly documentation?: string;
46
+ }
47
+ export interface ProtoEnumValue {
48
+ readonly name: string;
49
+ readonly number: number;
50
+ readonly deprecated: boolean;
51
+ readonly documentation?: string;
52
+ }
53
+ export interface ProtoEnum {
54
+ readonly name: string;
55
+ readonly fullName: string;
56
+ readonly values: ProtoEnumValue[];
57
+ readonly documentation?: string;
58
+ }
59
+ export interface ProtoMessage {
60
+ readonly name: string;
61
+ readonly fullName: string;
62
+ readonly fields: ProtoField[];
63
+ readonly messages: ProtoMessage[];
64
+ readonly enums: ProtoEnum[];
65
+ readonly documentation?: string;
66
+ }
67
+ export interface ProtoRpc {
68
+ readonly name: string;
69
+ readonly requestType: string;
70
+ readonly responseType: string;
71
+ readonly requestStream: boolean;
72
+ readonly responseStream: boolean;
73
+ readonly deprecated: boolean;
74
+ readonly documentation?: string;
75
+ }
76
+ export interface ProtoService {
77
+ readonly name: string;
78
+ readonly fullName: string;
79
+ readonly rpcs: ProtoRpc[];
80
+ readonly documentation?: string;
81
+ }
82
+ export interface ProtoFile {
83
+ readonly filename: string;
84
+ readonly package: string;
85
+ readonly syntax: string;
86
+ readonly imports: string[];
87
+ readonly messages: ProtoMessage[];
88
+ readonly enums: ProtoEnum[];
89
+ readonly services: ProtoService[];
90
+ }
91
+ export interface ProtoConvertOptions {
92
+ readonly files: readonly ProtoFile[];
93
+ readonly namespace: string;
94
+ readonly serviceName: string;
95
+ readonly serviceTitle?: string;
96
+ readonly serviceDocumentation?: string;
97
+ readonly serviceVersion?: string;
98
+ /** Fully-qualified proto service (`modal.client.ModalClient`). */
99
+ readonly protoService: string;
100
+ /** Keep only these RPC names. Default: every unary RPC. */
101
+ readonly rpcNames?: ReadonlySet<string>;
102
+ readonly skipStreaming?: boolean;
103
+ readonly skipDeprecated?: boolean;
104
+ }
105
+ export interface ProtoConvertResult {
106
+ readonly model: {
107
+ smithy: "2.0";
108
+ metadata: Record<string, unknown>;
109
+ shapes: Record<string, any>;
110
+ };
111
+ readonly converted: number;
112
+ readonly skippedStreaming: number;
113
+ readonly skippedDeprecated: number;
114
+ readonly shapeCount: number;
115
+ }
116
+ /** Parse a proto3 source file into an AST. */
117
+ export declare const parseProto: (text: string, filename?: string) => ProtoFile;
118
+ /** Leading PascalCase token of an RPC name (`AppCreate` → `App`). */
119
+ export declare const rpcGroupName: (rpcName: string) => string;
120
+ export declare const convertProtoToSmithy: (options: ProtoConvertOptions) => ProtoConvertResult;
121
+ //# sourceMappingURL=proto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proto.d.ts","sourceRoot":"","sources":["../../src/codegen/proto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAQH,eAAO,MAAM,OA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