@workerstack/clients 1.0.0-rc.29 → 1.0.0-rc.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/README.md +373 -14
  2. package/assets/installers/examples/github.config.ts +17 -19
  3. package/assets/installers/examples/goreleaser.config.ts +16 -18
  4. package/assets/installers/examples/raw.config.ts +13 -15
  5. package/bin/clients.js +87 -66
  6. package/bin/installgen.js +19 -10
  7. package/dist/cli.d.ts +4 -4
  8. package/dist/cli.js +18 -12
  9. package/dist/emit/cli/channels.d.ts +2 -2
  10. package/dist/emit/cli/channels.js +18 -13
  11. package/dist/emit/cli/commands.d.ts +1 -1
  12. package/dist/emit/cli/commands.js +14 -8
  13. package/dist/emit/cli/discovery.d.ts +0 -6
  14. package/dist/emit/cli/discovery.js +9 -7
  15. package/dist/emit/cli/flags.d.ts +1 -3
  16. package/dist/emit/cli/flags.js +11 -5
  17. package/dist/emit/cli/install.d.ts +0 -8
  18. package/dist/emit/cli/install.js +3 -3
  19. package/dist/emit/cli/layout.d.ts +1 -1
  20. package/dist/emit/cli/layout.js +13 -10
  21. package/dist/emit/cli/module.d.ts +6 -6
  22. package/dist/emit/cli/module.js +10 -10
  23. package/dist/emit/cli/release.d.ts +0 -11
  24. package/dist/emit/cli/release.js +4 -4
  25. package/dist/emit/cli/skills.js +3 -3
  26. package/dist/emit/csharp/errors.js +4 -4
  27. package/dist/emit/csharp/json.js +8 -8
  28. package/dist/emit/csharp/realtime.js +3 -3
  29. package/dist/emit/csharp/sdk-answer.js +4 -4
  30. package/dist/emit/csharp/sdk-body.js +8 -6
  31. package/dist/emit/csharp/sdk-client.d.ts +3 -3
  32. package/dist/emit/csharp/sdk-client.js +2 -2
  33. package/dist/emit/csharp/sdk-csproj.d.ts +7 -9
  34. package/dist/emit/csharp/sdk-csproj.js +10 -10
  35. package/dist/emit/csharp/sdk-doc.js +1 -1
  36. package/dist/emit/csharp/sdk-method.d.ts +0 -1
  37. package/dist/emit/csharp/sdk-method.js +10 -6
  38. package/dist/emit/csharp/sdk-plan.js +0 -1
  39. package/dist/emit/csharp/sdk.js +3 -3
  40. package/dist/emit/csharp/sse.d.ts +0 -2
  41. package/dist/emit/csharp/sse.js +7 -7
  42. package/dist/emit/csharp/transport.js +7 -7
  43. package/dist/emit/csharp/types-enum.js +3 -1
  44. package/dist/emit/csharp/types-messages.js +3 -3
  45. package/dist/emit/csharp/types-names.js +10 -12
  46. package/dist/emit/csharp/types-record.js +3 -3
  47. package/dist/emit/csharp/types-union.d.ts +1 -1
  48. package/dist/emit/csharp/types.d.ts +0 -1
  49. package/dist/emit/csharp/types.js +3 -3
  50. package/dist/emit/csharp/ws.js +2 -2
  51. package/dist/emit/go/errors.js +1 -1
  52. package/dist/emit/go/http.js +2 -2
  53. package/dist/emit/go/module-path.js +2 -2
  54. package/dist/emit/go/sdk-answer.js +1 -1
  55. package/dist/emit/go/sdk-body.js +11 -7
  56. package/dist/emit/go/sdk-client.js +1 -1
  57. package/dist/emit/go/sdk-method.js +2 -2
  58. package/dist/emit/go/sdk-mirror.js +2 -2
  59. package/dist/emit/go/sdk-opts.d.ts +0 -2
  60. package/dist/emit/go/sdk-opts.js +3 -3
  61. package/dist/emit/go/sdk.d.ts +1 -1
  62. package/dist/emit/go/sdk.js +9 -9
  63. package/dist/emit/go/sse.js +1 -1
  64. package/dist/emit/go/types-names.js +5 -0
  65. package/dist/emit/go/types-struct.d.ts +2 -1
  66. package/dist/emit/go/types-struct.js +1 -1
  67. package/dist/emit/go/types.js +9 -9
  68. package/dist/emit/go/ws.js +6 -6
  69. package/dist/emit/java/gradle.d.ts +7 -9
  70. package/dist/emit/java/gradle.js +8 -8
  71. package/dist/emit/java/json.js +1 -1
  72. package/dist/emit/java/layout-ast.js +1 -1
  73. package/dist/emit/java/layout-decl.js +5 -4
  74. package/dist/emit/java/layout-doc.js +13 -7
  75. package/dist/emit/java/layout-dot.js +1 -1
  76. package/dist/emit/java/layout-strings.js +4 -5
  77. package/dist/emit/java/layout-types.js +7 -5
  78. package/dist/emit/java/layout-visitor.js +4 -3
  79. package/dist/emit/java/layout.js +5 -4
  80. package/dist/emit/java/models-names.js +5 -4
  81. package/dist/emit/java/models-record.d.ts +0 -1
  82. package/dist/emit/java/models-record.js +3 -3
  83. package/dist/emit/java/models-union.d.ts +1 -1
  84. package/dist/emit/java/models-union.js +1 -1
  85. package/dist/emit/java/models.d.ts +1 -2
  86. package/dist/emit/java/models.js +25 -16
  87. package/dist/emit/java/realtime.d.ts +5 -17
  88. package/dist/emit/java/realtime.js +1 -1
  89. package/dist/emit/java/sdk-client.d.ts +6 -6
  90. package/dist/emit/java/sdk-client.js +1 -1
  91. package/dist/emit/java/sdk-decl.js +2 -2
  92. package/dist/emit/java/sdk-errors.js +1 -1
  93. package/dist/emit/java/sdk-headers.js +2 -2
  94. package/dist/emit/java/sdk-mirror.js +2 -2
  95. package/dist/emit/java/sdk-models.d.ts +1 -1
  96. package/dist/emit/java/sdk-models.js +7 -7
  97. package/dist/emit/java/sdk-op.d.ts +1 -10
  98. package/dist/emit/java/sdk-op.js +8 -8
  99. package/dist/emit/java/sdk-params.d.ts +5 -5
  100. package/dist/emit/java/sdk-params.js +3 -2
  101. package/dist/emit/java/sdk-plan.js +0 -1
  102. package/dist/emit/java/sdk.d.ts +1 -1
  103. package/dist/emit/java/sdk.js +14 -13
  104. package/dist/emit/java/sse.d.ts +2 -4
  105. package/dist/emit/java/sse.js +6 -6
  106. package/dist/emit/java/ws.d.ts +2 -2
  107. package/dist/emit/java/ws.js +3 -4
  108. package/dist/emit/mcp/annotations.js +8 -4
  109. package/dist/emit/mcp/files.js +9 -9
  110. package/dist/emit/mcp/mounted.js +2 -2
  111. package/dist/emit/mcp/output-schema.js +3 -3
  112. package/dist/emit/mcp/registry.d.ts +0 -2
  113. package/dist/emit/mcp/registry.js +5 -4
  114. package/dist/emit/mcp/runtime.js +2 -2
  115. package/dist/emit/mcp/schema.js +22 -11
  116. package/dist/emit/mcp/server.d.ts +7 -7
  117. package/dist/emit/mcp/server.js +7 -6
  118. package/dist/emit/mcp/tools.js +7 -6
  119. package/dist/emit/python/errors.js +3 -3
  120. package/dist/emit/python/realtime.js +2 -2
  121. package/dist/emit/python/sdk-answer.d.ts +3 -7
  122. package/dist/emit/python/sdk-answer.js +2 -2
  123. package/dist/emit/python/sdk-body.js +4 -5
  124. package/dist/emit/python/sdk-client.js +5 -5
  125. package/dist/emit/python/sdk-doc.js +2 -2
  126. package/dist/emit/python/sdk-method.js +5 -5
  127. package/dist/emit/python/sdk-plan.js +0 -1
  128. package/dist/emit/python/sdk-pyproject.d.ts +0 -2
  129. package/dist/emit/python/sdk-pyproject.js +8 -8
  130. package/dist/emit/python/sdk.d.ts +1 -1
  131. package/dist/emit/python/sdk.js +7 -7
  132. package/dist/emit/python/sse.d.ts +0 -2
  133. package/dist/emit/python/sse.js +2 -2
  134. package/dist/emit/python/transport.js +4 -4
  135. package/dist/emit/python/types-dict.d.ts +2 -2
  136. package/dist/emit/python/types-dict.js +1 -1
  137. package/dist/emit/python/types-names.js +2 -2
  138. package/dist/emit/python/types-union.js +1 -1
  139. package/dist/emit/python/types.js +3 -3
  140. package/dist/emit/python/ws.d.ts +2 -5
  141. package/dist/emit/python/ws.js +4 -4
  142. package/dist/emit/rust/errors.js +3 -3
  143. package/dist/emit/rust/http.js +4 -4
  144. package/dist/emit/rust/realtime.js +2 -2
  145. package/dist/emit/rust/sdk-body.js +8 -5
  146. package/dist/emit/rust/sdk-cargo.d.ts +16 -18
  147. package/dist/emit/rust/sdk-cargo.js +12 -12
  148. package/dist/emit/rust/sdk-client.d.ts +1 -1
  149. package/dist/emit/rust/sdk-client.js +3 -3
  150. package/dist/emit/rust/sdk-method.js +2 -2
  151. package/dist/emit/rust/sdk-opts.d.ts +2 -1
  152. package/dist/emit/rust/sdk-opts.js +2 -2
  153. package/dist/emit/rust/sdk-plan.js +0 -1
  154. package/dist/emit/rust/sdk.d.ts +1 -1
  155. package/dist/emit/rust/sdk.js +5 -5
  156. package/dist/emit/rust/sse.d.ts +0 -5
  157. package/dist/emit/rust/sse.js +2 -2
  158. package/dist/emit/rust/types-names.js +3 -3
  159. package/dist/emit/rust/types-struct.js +1 -1
  160. package/dist/emit/rust/types-union.d.ts +1 -1
  161. package/dist/emit/rust/types.js +7 -5
  162. package/dist/emit/rust/ws.d.ts +0 -11
  163. package/dist/emit/rust/ws.js +5 -5
  164. package/dist/emit/shared/escape.js +17 -17
  165. package/dist/emit/shared/format.js +1 -1
  166. package/dist/emit/shared/gofmt.js +1 -1
  167. package/dist/emit/shared/lang.js +10 -10
  168. package/dist/emit/shared/literals.d.ts +5 -0
  169. package/dist/emit/shared/literals.js +8 -0
  170. package/dist/emit/shared/metadata.d.ts +0 -6
  171. package/dist/emit/shared/metadata.js +8 -7
  172. package/dist/emit/shared/ruff.js +1 -1
  173. package/dist/emit/shared/rustfmt.js +1 -1
  174. package/dist/emit/shared/type-emitter.js +37 -20
  175. package/dist/emit/shared/unknown-type.constants.d.ts +2 -0
  176. package/dist/emit/shared/unknown-type.constants.js +2 -0
  177. package/dist/emit/ts/http.d.ts +0 -2
  178. package/dist/emit/ts/http.js +4 -4
  179. package/dist/emit/ts/package.d.ts +14 -12
  180. package/dist/emit/ts/package.js +9 -8
  181. package/dist/emit/ts/route-tree.js +2 -2
  182. package/dist/emit/ts/sdk-types-preamble.d.ts +1 -1
  183. package/dist/emit/ts/sdk-types-preamble.js +2 -2
  184. package/dist/emit/ts/sdk-types.js +11 -11
  185. package/dist/emit/ts/sdk.js +4 -4
  186. package/dist/emit/ts/service-map.d.ts +2 -1
  187. package/dist/emit/ts/tanstack-query.js +6 -6
  188. package/dist/emit/ts/type-gen.js +31 -18
  189. package/dist/emit/ts/webhooks.d.ts +0 -2
  190. package/dist/emit/ts/webhooks.js +3 -3
  191. package/dist/extract/chain.js +5 -4
  192. package/dist/extract/extract.js +5 -5
  193. package/dist/extract/serialize.d.ts +0 -2
  194. package/dist/extract/serialize.js +14 -15
  195. package/dist/extract/walk.js +15 -12
  196. package/dist/gen/args.js +9 -5
  197. package/dist/gen/formatters.js +5 -3
  198. package/dist/gen/shipped.js +2 -2
  199. package/dist/gen/targets.d.ts +2 -4
  200. package/dist/gen/targets.js +8 -4
  201. package/dist/gen/write.js +4 -2
  202. package/dist/index.js +2 -2
  203. package/dist/installers/cli.d.ts +4 -4
  204. package/dist/installers/cli.js +24 -24
  205. package/dist/installers/commands/build.d.ts +4 -4
  206. package/dist/installers/commands/build.js +2 -3
  207. package/dist/installers/commands/check.d.ts +2 -2
  208. package/dist/installers/commands/check.js +11 -10
  209. package/dist/installers/commands/init.d.ts +2 -2
  210. package/dist/installers/commands/init.js +1 -2
  211. package/dist/installers/config/define-config.d.ts +16 -16
  212. package/dist/installers/config/define-config.js +1 -1
  213. package/dist/installers/config/hooks/bun.d.ts +6 -6
  214. package/dist/installers/config/hooks/node.js +1 -1
  215. package/dist/installers/config/load.d.ts +6 -8
  216. package/dist/installers/config/load.js +7 -8
  217. package/dist/installers/config/resolve.d.ts +1 -2
  218. package/dist/installers/config/resolve.js +28 -33
  219. package/dist/installers/config/types.d.ts +6 -6
  220. package/dist/installers/config/types.js +0 -1
  221. package/dist/installers/render/quote.js +3 -5
  222. package/dist/installers/render/render.d.ts +6 -6
  223. package/dist/installers/render/render.js +26 -26
  224. package/dist/installers/ui.d.ts +4 -4
  225. package/dist/installers/ui.js +3 -3
  226. package/dist/ir/build.d.ts +3 -3
  227. package/dist/ir/build.js +8 -5
  228. package/dist/ir/load.js +9 -10
  229. package/dist/ir/model.d.ts +2 -1
  230. package/dist/ir/model.js +0 -1
  231. package/dist/ir/resolve-refs.js +2 -2
  232. package/dist/ir/resource-tree.js +2 -1
  233. package/dist/ir/route-tree-intern.js +1 -1
  234. package/dist/ir/schema.js +3 -3
  235. package/dist/ir/sdk-model.js +3 -3
  236. package/dist/ir/slots.js +13 -8
  237. package/dist/ir/streams.js +1 -1
  238. package/dist/release/bootstrap.d.ts +3 -3
  239. package/dist/release/bootstrap.js +7 -7
  240. package/dist/release/bump-args.js +4 -4
  241. package/dist/release/bump-command.d.ts +1 -1
  242. package/dist/release/bump-command.js +9 -10
  243. package/dist/release/bump.d.ts +5 -4
  244. package/dist/release/bump.js +2 -2
  245. package/dist/release/cli.d.ts +4 -4
  246. package/dist/release/cli.js +4 -4
  247. package/dist/release/codegen.js +1 -1
  248. package/dist/release/digest.js +5 -7
  249. package/dist/release/git.js +5 -8
  250. package/dist/release/load.js +3 -3
  251. package/dist/release/manifest.js +9 -10
  252. package/dist/release/oasdiff.d.ts +10 -15
  253. package/dist/release/oasdiff.js +5 -6
  254. package/dist/release/registries.d.ts +0 -11
  255. package/dist/release/registries.js +17 -17
  256. package/dist/release/release-state.d.ts +16 -13
  257. package/dist/release/release-workflow.js +5 -7
  258. package/dist/release/repo-settings.d.ts +2 -1
  259. package/dist/release/spec-gate.d.ts +0 -2
  260. package/dist/release/spec-gate.js +6 -10
  261. package/dist/release/sync-command.d.ts +2 -2
  262. package/dist/release/sync-command.js +1 -1
  263. package/dist/release/sync-tree.js +9 -13
  264. package/dist/release/sync.d.ts +6 -6
  265. package/dist/release/sync.js +12 -13
  266. package/dist/release/types.d.ts +22 -22
  267. package/dist/release/types.js +0 -1
  268. package/dist/release/version-files.d.ts +3 -4
  269. package/dist/release/version-files.js +4 -5
  270. package/dist/runtime/.oxfmtrc.jsonc +8 -0
  271. package/dist/runtime/mcp/files.ts +1 -1
  272. package/dist/runtime/mcp/http.ts +6 -2
  273. package/dist/runtime/mcp/listen.ts +1 -1
  274. package/dist/runtime/mcp/mount.ts +2 -2
  275. package/dist/runtime/mcp/protocol.ts +1 -1
  276. package/dist/runtime/ts-tanstack-query/query.ts +0 -2
  277. package/package.json +10 -7
  278. package/dist/emit/cli/index.d.ts +0 -1
  279. package/dist/emit/cli/index.js +0 -1
  280. package/dist/emit/csharp/index.d.ts +0 -1
  281. package/dist/emit/csharp/index.js +0 -1
  282. package/dist/emit/go/index.d.ts +0 -1
  283. package/dist/emit/go/index.js +0 -1
  284. package/dist/emit/java/index.d.ts +0 -2
  285. package/dist/emit/java/index.js +0 -2
  286. package/dist/emit/mcp/index.d.ts +0 -3
  287. package/dist/emit/mcp/index.js +0 -3
  288. package/dist/emit/python/index.d.ts +0 -1
  289. package/dist/emit/python/index.js +0 -1
  290. package/dist/emit/rust/index.d.ts +0 -1
  291. package/dist/emit/rust/index.js +0 -1
@@ -7,9 +7,9 @@ import { methodDoc } from "./sdk-doc.js";
7
7
  import { sseStream } from "./sse.js";
8
8
  import { csTypeOf } from "./types.js";
9
9
  import { wsStream } from "./ws.js";
10
- /* the method's own parameters: a spec param that takes one of these names is claimed as `…2` */
11
- export const METHOD_LOCALS = ["body", "cancellationToken", "headersInto", "idempotencyKey", "options"];
12
- /* each stream's answer, its own fields, and the declared params its resume channels carry (the fold) */
10
+ // the method's own parameters: a spec param that takes one of these names is claimed as `…2`
11
+ const METHOD_LOCALS = ["body", "cancellationToken", "headersInto", "idempotencyKey", "options"];
12
+ // each stream's answer, its own fields, and the declared params its resume channels carry (the fold)
13
13
  const STREAMS = {
14
14
  realtime: realtimeStream,
15
15
  sse: sseStream,
@@ -44,7 +44,10 @@ function paramsOf(op, scope, at, stream) {
44
44
  /** A parameter: its declaration, then its name. */
45
45
  const one = (decl, ident) => ({ decl: `${decl} ${ident}`, ident });
46
46
  /** An optional parameter, defaulting to `fallback`. */
47
- const optional = (decl, ident, fallback = "null") => ({ decl: `${decl} ${ident} = ${fallback}`, ident });
47
+ const optional = (decl, ident, fallback = "null") => ({
48
+ decl: `${decl} ${ident} = ${fallback}`,
49
+ ident,
50
+ });
48
51
  /**
49
52
  * The parameters, each its declaration and its name, in C#4's order, the response-header holder after the
50
53
  * idempotency key, then a stream's fields.
@@ -103,7 +106,7 @@ function methodLines(parts, spell) {
103
106
  ` _t.${run}(${parts.field}, new(${call(parts, spell)}), ${args.join(", ")});`,
104
107
  ];
105
108
  }
106
- /* an SSE twin's <returns>: the open stream is its Ok, an error status opening it its Err */
109
+ // an SSE twin's <returns>: the open stream is its Ok, an error status opening it its Err
107
110
  const SAFE_STREAM = "Ok with the open stream, or Err with the opening answer's error status. No timeout bounds it after that, and a drop or an event that does not decode is the stream's own exception; the token, leaving await foreach or DisposeAsync ends it.";
108
111
  /**
109
112
  * The `client.Safe` twin's lines: the signature restated, answering `Task<Result<T>>` (`Task<Result>` for no body)
@@ -114,12 +117,13 @@ function twinLines(parts, spell) {
114
117
  const [returns] = parts.answer.render(spell);
115
118
  const sig = `${signature(parts, spell).join(", ")})`;
116
119
  const idents = parameters(parts, spell).map(({ ident }) => ident);
117
- if (parts.op.stream === "ws" || parts.op.stream === "realtime")
120
+ if (parts.op.stream === "ws" || parts.op.stream === "realtime") {
118
121
  return [
119
122
  ...methodDoc(parts.op, true, parts.stream?.returns),
120
123
  ` public ${returns} ${parts.name}(${sig} =>`,
121
124
  ` _n.${parts.name}(${idents.join(", ")});`,
122
125
  ];
126
+ }
123
127
  const safe = returns === "Task" ? "Task<Result>" : `Task<Result<${returns.slice("Task<".length, -1)}>>`;
124
128
  const sent = idents.map((ident) => (ident === "options" ? "_o" : ident));
125
129
  return [
@@ -1 +0,0 @@
1
- export {};
@@ -12,17 +12,17 @@
12
12
  import { toIR } from "../../ir/build.js";
13
13
  import { sdkModel } from "../../ir/sdk-model.js";
14
14
  import { compareCodeUnits, csTypeName } from "../shared/lang.js";
15
+ import { packageOn } from "../shared/metadata.js";
15
16
  import { renameNotice } from "../shared/mirror.js";
16
17
  import { csharpErrorKeys } from "./errors.js";
17
18
  import { jsonContext, runtimeOf, strictConverters, typeInfoNames } from "./json.js";
18
19
  import { clientDecls } from "./sdk-client.js";
19
20
  import { csproj, EDITORCONFIG, packageMetadata, validateClientName, validatePackageId, validateRootNamespace, validateVersion, } from "./sdk-csproj.js";
20
- import { packageOn } from "../shared/metadata.js";
21
21
  import { docLines } from "./sdk-doc.js";
22
22
  import { runtimeFiles } from "./transport.js";
23
23
  import { usings } from "./types-names.js";
24
24
  import { csTopLevel, csTypeContext, declares } from "./types.js";
25
- /* the marker every .cs file opens with; never `<auto-generated`, which the format gate and the analyzers skip (Q4) */
25
+ // the marker every .cs file opens with; never `<auto-generated`, which the format gate and the analyzers skip (Q4)
26
26
  const MARKER = "// @generated by clients. DO NOT EDIT.";
27
27
  /** The options validated, each default filled in, and the client's and its context's class names. */
28
28
  function identity(options) {
@@ -60,7 +60,7 @@ function emitCSharp(document, options, shipped) {
60
60
  const at = csTypeContext(ir, [id.client, id.context]);
61
61
  const components = componentDecls(ir, at);
62
62
  const errorKey = csharpErrorKeys(model, at);
63
- /* every component emitted under another name is noticed, as the mirror's rename is */
63
+ // every component emitted under another name is noticed, as the mirror's rename is
64
64
  const notices = [...at.names.renamed].map(([name, renamed]) => renameNotice("csharp", {
65
65
  because: `"${csTypeName(name)}" is a name the SDK's runtime, the BCL or another declaration holds`,
66
66
  name,
@@ -1,6 +1,4 @@
1
1
  import { type CsStream } from "./sdk-answer.ts";
2
- /** The header the SSE and realtime dials resume an event stream with. */
3
- export declare const LAST_EVENT_ID = "Last-Event-ID";
4
2
  /** Whether a declared param is the Last-Event-ID header (any casing), the resume channel an SSE dial sends. */
5
3
  export declare const isLastEventIdHeader: (name: string, where: string) => boolean;
6
4
  /** The SSE operation's answer, its one field and its `<returns>` text. */
@@ -5,20 +5,20 @@ import { eventType } from "./sdk-answer.js";
5
5
  import { docLines } from "./sdk-doc.js";
6
6
  import { csTypeOf } from "./types.js";
7
7
  /** The header the SSE and realtime dials resume an event stream with. */
8
- export const LAST_EVENT_ID = "Last-Event-ID";
8
+ const LAST_EVENT_ID = "Last-Event-ID";
9
9
  /** The resume cursor's event id, which the SSE method takes. */
10
10
  const LAST_EVENT_ID_FIELD = { ident: "lastEventId", type: "string?" };
11
11
  /** Whether a declared param is the Last-Event-ID header (any casing), the resume channel an SSE dial sends. */
12
12
  export const isLastEventIdHeader = (name, where) => where === "header" && name.toLowerCase() === LAST_EVENT_ID.toLowerCase();
13
- /* the names a nested record never takes: the members, and the types the decode spells */
13
+ // the names a nested record never takes: the members, and the types the decode spells
14
14
  const TAKEN = [
15
- /* a nested record's members */
15
+ // a nested record's members
16
16
  "Data",
17
17
  "Event",
18
18
  "Id",
19
19
  "Retry",
20
20
  "Of",
21
- /* every record's */
21
+ // every record's
22
22
  "Deconstruct",
23
23
  "EqualityContract",
24
24
  "Equals",
@@ -28,7 +28,7 @@ const TAKEN = [
28
28
  "MemberwiseClone",
29
29
  "PrintMembers",
30
30
  "ToString",
31
- /* the decode's */
31
+ // the decode's
32
32
  "JsonSerializerOptions",
33
33
  "JsonTypeInfo",
34
34
  "SseEvent",
@@ -51,13 +51,13 @@ function namedEvents(op, events, env) {
51
51
  at.unlisted.add(name);
52
52
  const typed = events.map(({ data, name: event }) => {
53
53
  const json = isJsonEventData(data, at.names.resolve);
54
- /* the decode throws on null, so the data is never null */
54
+ // the decode throws on null, so the data is never null
55
55
  const type = json ? csTypeOf(data, { ...at, fieldName: event, parentName: op.id }).replace(/\?$/, "") : "string";
56
56
  if (json)
57
57
  at.serialized.add(type);
58
58
  return { data: type, event, json };
59
59
  });
60
- /* a type a record's data spells would be shadowed by a nested record of its name */
60
+ // a type a record's data spells would be shadowed by a nested record of its name
61
61
  const spelled = typed.flatMap(({ data }) => data.split(/\W+/).filter((word) => word !== ""));
62
62
  const reserved = new Set([...TAKEN, ...spelled, name, "Unknown"]);
63
63
  const scope = new NameScope(reserved);
@@ -7,9 +7,9 @@
7
7
  */
8
8
  import { readFileSync } from "node:fs";
9
9
  import { compareCodeUnits } from "../shared/lang.js";
10
- /* every SDK: the HTTP runtime (config, errors and envelopes, bodies, auth, hooks, log, redirects and the strip
11
- * handler, stale tracking, the exchange, its wire readers and the transport), the safe result, the strict JSON
12
- * converters, the encoders, and the SSE parser and its EventStream */
10
+ // every SDK: the HTTP runtime (config, errors and envelopes, bodies, auth, hooks, log, redirects and the strip
11
+ // handler, stale tracking, the exchange, its wire readers and the transport), the safe result, the strict JSON
12
+ // converters, the encoders, and the SSE parser and its EventStream
13
13
  const CORE = [
14
14
  "Auth",
15
15
  "Body",
@@ -33,9 +33,9 @@ const CORE = [
33
33
  "Transport",
34
34
  "Wire",
35
35
  ];
36
- /* a WebSocket or realtime operation: the socket, its own HTTP/1.1 upgrade, and the socket of declared messages */
36
+ // a WebSocket or realtime operation: the socket, its own HTTP/1.1 upgrade, and the socket of declared messages
37
37
  const WS = ["Ws", "WsDial", "WsTyped"];
38
- /* a realtime operation: the adapters, the resumable connection and its loop, and the three transports */
38
+ // a realtime operation: the adapters, the resumable connection and its loop, and the three transports
39
39
  const REALTIME = [
40
40
  "Adapters",
41
41
  "Realtime",
@@ -44,9 +44,9 @@ const REALTIME = [
44
44
  "TransportSse",
45
45
  "TransportWs",
46
46
  ];
47
- /* the one line each committed file holds, swapped for the SDK's namespace */
47
+ // the one line each committed file holds, swapped for the SDK's namespace
48
48
  const NAMESPACE = /^namespace Http\.Runtime;$/m;
49
- /* a top-level type at column 0: its modifiers, its kind, its name (type parameters after it are not part of it) */
49
+ // a top-level type at column 0: its modifiers, its kind, its name (type parameters after it are not part of it)
50
50
  const TOP_LEVEL = /^(?:(?:public|internal|file|sealed|abstract|static|readonly|partial|unsafe)\s+)*(?:record\s+struct|record\s+class|class|record|struct|enum|interface)\s+([A-Za-z_]\w*)/gm;
51
51
  /** The runtime file names an SDK with `features` ships, `.cs` included, in code-unit order. */
52
52
  export function runtimeFileNames(features) {
@@ -59,5 +59,7 @@ function intEnumDecl(name, values, at) {
59
59
  /** The enum `name` of the string or integer enum `ir`. */
60
60
  export function enumDecl(name, ir, at) {
61
61
  const values = enumValues(ir);
62
- return ir.type === "string" ? stringEnumDecl(name, values, at) : intEnumDecl(name, values, at);
62
+ return ir.type === "string"
63
+ ? stringEnumDecl(name, values, at)
64
+ : intEnumDecl(name, values, at);
63
65
  }
@@ -3,7 +3,7 @@ import { csString } from "../shared/escape.js";
3
3
  import { csTypeName, NameScope } from "../shared/lang.js";
4
4
  import { docLines } from "./sdk-doc.js";
5
5
  import { csTypeOf } from "./types.js";
6
- /* the names a nested record never takes: its members, every record's, and the types its converter spells */
6
+ // the names a nested record never takes: its members, every record's, and the types its converter spells
7
7
  const TAKEN = [
8
8
  "Value",
9
9
  "Raw",
@@ -33,7 +33,7 @@ function nestedOf(name, dispatch, parent, at) {
33
33
  at.serialized.add(type);
34
34
  return [{ type, value }];
35
35
  });
36
- /* a type a member spells would be shadowed by a nested record of its name */
36
+ // a type a member spells would be shadowed by a nested record of its name
37
37
  const spelled = members.flatMap(({ type }) => type.split(/\W+/).filter((word) => word !== ""));
38
38
  const reserved = new Set([...TAKEN, ...spelled, name]);
39
39
  const scope = new NameScope(reserved);
@@ -87,7 +87,7 @@ function writeLines(name, nested, read) {
87
87
  function keyedType(op, dispatch, side, at) {
88
88
  const read = side === "Send";
89
89
  const name = at.names.claim(`${csTypeName(op.id)}${read ? "Inbound" : "Outbound"}`);
90
- /* claimed before its body: what the members hoist comes after it */
90
+ // claimed before its body: what the members hoist comes after it
91
91
  at.decls.set(name, "");
92
92
  const nested = nestedOf(name, dispatch, `${op.id}.${side}`, at);
93
93
  const converter = at.names.claim(`${name}Converter`);
@@ -1,7 +1,7 @@
1
1
  import { irResolver } from "../../ir/schema.js";
2
2
  import { compareCodeUnits, csTypeName, NameScope } from "../shared/lang.js";
3
3
  import { runtimeFiles, runtimeTypeNames } from "./transport.js";
4
- /* the BCL names emitted text spells unqualified, by the namespace a `using` brings them from (§4.7) */
4
+ // the BCL names emitted text spells unqualified, by the namespace a `using` brings them from (§4.7)
5
5
  export const BCL = {
6
6
  System: ["Action", "Exception", "Func", "IDisposable", "Object", "String", "TimeSpan", "Type"],
7
7
  "System.Collections.Generic": ["IDictionary", "IReadOnlyDictionary", "IReadOnlyList"],
@@ -30,10 +30,8 @@ export const BCL = {
30
30
  "System.Threading": ["CancellationToken"],
31
31
  "System.Threading.Tasks": ["Task"],
32
32
  };
33
- /*
34
- * the BCL names the vendored runtime spells unqualified (as a type or by static access) and emitted text never does:
35
- * the emitted types share the runtime's namespace (Fb2), so each is reserved, never a `using`
36
- */
33
+ // the BCL names the vendored runtime spells unqualified (as a type or by static access) and emitted text never does:
34
+ // the emitted types share the runtime's namespace (Fb2), so each is reserved, never a `using`
37
35
  export const RUNTIME_BCL = [
38
36
  "Array",
39
37
  "BrotliStream",
@@ -96,7 +94,7 @@ export const RUNTIME_BCL = [
96
94
  "StringBuilder",
97
95
  "StringComparer",
98
96
  "StringComparison",
99
- /* System.Threading's, also a runtime property: the scan cannot tell `Timeout.InfiniteTimeSpan` (CS0117) from it */
97
+ // System.Threading's, also a runtime property: the scan cannot tell `Timeout.InfiniteTimeSpan` (CS0117) from it
100
98
  "Timeout",
101
99
  "UnicodeCategory",
102
100
  "Uri",
@@ -110,7 +108,7 @@ export const RUNTIME_BCL = [
110
108
  "WebSocketMessageType",
111
109
  "WebSocketState",
112
110
  ];
113
- /* the attributes emitted text spells without their `Attribute` suffix: the suffixed name is taken too */
111
+ // the attributes emitted text spells without their `Attribute` suffix: the suffixed name is taken too
114
112
  const ATTRIBUTES = [
115
113
  "JsonConverter",
116
114
  "JsonExtensionData",
@@ -126,7 +124,7 @@ const reserved = (taken) => [
126
124
  ...Object.values(BCL).flat(),
127
125
  ...RUNTIME_BCL,
128
126
  ...ATTRIBUTES.map((name) => `${name}Attribute`),
129
- /* the static class of the API's error keys (errors.ts), declared beside the types when any key is */
127
+ // the static class of the API's error keys (errors.ts), declared beside the types when any key is
130
128
  "ErrorKey",
131
129
  "System",
132
130
  ...taken,
@@ -162,7 +160,7 @@ export function irNames(schemas, taken, declares) {
162
160
  hoisted.set(key, name);
163
161
  return name;
164
162
  },
165
- /* a ref reaches here only for a declared component: `alias` answers for every other one */
163
+ // a ref reaches here only for a declared component: `alias` answers for every other one
166
164
  ref: (name) => components.get(name),
167
165
  renamed,
168
166
  resolve: irResolver(schemas),
@@ -170,9 +168,9 @@ export function irNames(schemas, taken, declares) {
170
168
  }
171
169
  /** `code` without its string and char literals and comments: the text that spells names. */
172
170
  const codeOf = (code) => code
173
- .replace(/"(?:[^"\\\n]|\\.)*"/g, '""')
174
- .replace(/'(?:[^'\\\n]|\\.)'/g, "''")
175
- .replace(/\/\/.*$/gm, "");
171
+ .replaceAll(/"(?:[^"\\\n]|\\.)*"/g, '""')
172
+ .replaceAll(/'(?:[^'\\\n]|\\.)'/g, "''")
173
+ .replaceAll(/\/\/.*$/gm, "");
176
174
  /** The `using` lines `code` needs: each namespace one of whose BCL names it spells as a type, in code-unit order. */
177
175
  export function usings(code) {
178
176
  const text = codeOf(code);
@@ -1,6 +1,6 @@
1
1
  import { csString } from "../shared/escape.js";
2
2
  import { compareCodeUnits, csTypeName, NameScope } from "../shared/lang.js";
3
- /* every member name a record property collides with (CS0102, CS0108, CS8859, CS8874), and the name its attributes spell in an expression */
3
+ // every member name a record property collides with (CS0102, CS0108, CS8859, CS8874), and the name its attributes spell in an expression
4
4
  export const RECORD_MEMBERS = [
5
5
  "Clone",
6
6
  "EqualityContract",
@@ -12,7 +12,7 @@ export const RECORD_MEMBERS = [
12
12
  "PrintMembers",
13
13
  "ToString",
14
14
  ];
15
- /* a required nullable member is written even when null; an unset tri-state or open value is not written */
15
+ // a required nullable member is written even when null; an unset tri-state or open value is not written
16
16
  const NEVER = "[JsonIgnore(Condition = JsonIgnoreCondition.Never)]";
17
17
  const UNSET = "[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]";
18
18
  /** One property's lines, unindented: its attributes, then `public <type> <name> { get; init; }`. */
@@ -25,7 +25,7 @@ function propertyLines(field, name, member, at) {
25
25
  return [key, UNSET, `public ${type} ${name} { get; init; }`];
26
26
  if (!type.endsWith("?"))
27
27
  return [key, `public ${type}? ${name} { get; init; }`];
28
- /* OptConverter reads T through the context: it must list T */
28
+ // OptConverter reads T through the context: it must list T
29
29
  at.serialized.add(type);
30
30
  return [key, `[JsonConverter(typeof(OptConverter<${type}>))]`, UNSET, `public Opt<${type}> ${name} { get; init; }`];
31
31
  }
@@ -11,7 +11,7 @@ type Of<K extends IRSchema["kind"]> = Extract<IRSchema, {
11
11
  kind: K;
12
12
  }>;
13
13
  /** Declares `schema` once under `names.hoist(key, base)`; its name. */
14
- export type Declare = (schema: IRSchema, key: string, base: string) => string;
14
+ type Declare = (schema: IRSchema, key: string, base: string) => string;
15
15
  /** What a union's declaration reaches: the context, its members' types, and the hoist. */
16
16
  export type UnionScope = {
17
17
  at: CsTypeContext;
@@ -7,7 +7,6 @@
7
7
  */
8
8
  import type { IR, IRSchema } from "../../ir/model.ts";
9
9
  import { type CsTypeNames } from "./types-names.ts";
10
- export type { CsTypeNames } from "./types-names.ts";
11
10
  /** Where a type is being written, the declarations it hoists, the names, and what the JSON context gathers. */
12
11
  export type CsTypeContext = {
13
12
  parentName: string;
@@ -5,7 +5,7 @@ import { fieldsOf, isOpen, recordDecl } from "./types-record.js";
5
5
  import { isLiteral, unionDecl } from "./types-union.js";
6
6
  export const JSON_ELEMENT = "JsonElement";
7
7
  const MAP = "IReadOnlyDictionary<string, ";
8
- /* deeper than this, a schema is any JSON value */
8
+ // deeper than this, a schema is any JSON value
9
9
  const MAX_DEPTH = 12;
10
10
  const SCALARS = {
11
11
  boolean: "bool",
@@ -45,7 +45,7 @@ export function declares(ir) {
45
45
  function declare(ir, at, key, base) {
46
46
  const name = at.names.hoist(key, base);
47
47
  if (!at.decls.has(name)) {
48
- /* claimed before its body: what the body hoists in turn comes after it */
48
+ // claimed before its body: what the body hoists in turn comes after it
49
49
  at.decls.set(name, "");
50
50
  at.decls.set(name, csTopLevel(name, ir, at));
51
51
  }
@@ -98,7 +98,7 @@ const USES = {
98
98
  ref: refUse,
99
99
  scalar: (ir, at) => (isEnum(ir) ? hoist(ir, at) : SCALARS[ir.type]),
100
100
  tuple: () => `IReadOnlyList<${JSON_ELEMENT}>`,
101
- /* a union in use position is any JSON value; a component union is declared (Fb7) */
101
+ // a union in use position is any JSON value; a component union is declared (Fb7)
102
102
  union: () => JSON_ELEMENT,
103
103
  unknown: () => JSON_ELEMENT,
104
104
  };
@@ -1,10 +1,10 @@
1
- import { JSON_ELEMENT } from "./types.js";
2
1
  import { messageType, valueHandlers } from "./types-messages.js";
2
+ import { JSON_ELEMENT } from "./types.js";
3
3
  /** The subprotocols a WebSocket dial offers. */
4
4
  const PROTOCOLS = { ident: "protocols", type: "IReadOnlyList<string>?" };
5
5
  /** The resume cursor's token, which the WebSocket method takes. */
6
6
  const RECONNECT_TOKEN = { ident: "reconnectToken", type: "string?" };
7
- /* the typed socket, and its own events: a member whose On<Value> one of them names gets none */
7
+ // the typed socket, and its own events: a member whose On<Value> one of them names gets none
8
8
  const READER = { base: "TypedWebSocket", handlers: ["OnMessage", "OnClose", "OnError"], receiver: "socket" };
9
9
  /** Whether a declared param is the `reconnect_token` query param, the resume channel a socket dial sends. */
10
10
  export const isReconnectToken = (name, where) => where === "query" && name === "reconnect_token";
@@ -5,7 +5,7 @@ import { goTopLevel } from "./types.js";
5
5
  /** Every declared key's schema (the first operation's to declare one), keys in code-unit order. */
6
6
  function declaredKeys(model) {
7
7
  const declared = model.ops.flatMap((op) => Object.entries(op.ir.extensions.errors ?? {}));
8
- /* reversed, so a key ends on its first declaration */
8
+ // reversed, so a key ends on its first declaration
9
9
  const first = new Map(declared.toReversed().map(([key, { schema }]) => [key, schema]));
10
10
  return [...first].sort(([a], [b]) => compareCodeUnits(a, b));
11
11
  }
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { readFileSync } from "node:fs";
8
8
  import { compareCodeUnits } from "../shared/lang.js";
9
- /* every SDK: config, request, auth, redirects, errors, SSE, invalidation */
9
+ // every SDK: config, request, auth, redirects, errors, SSE, invalidation
10
10
  const CORE = [
11
11
  "auth",
12
12
  "body",
@@ -27,7 +27,7 @@ const CORE = [
27
27
  "stale",
28
28
  "stream",
29
29
  ];
30
- /* a WebSocket operation; realtime adds the resumable transports on top of it */
30
+ // a WebSocket operation; realtime adds the resumable transports on top of it
31
31
  const WS = ["ws"];
32
32
  const REALTIME = ["realtime", "realtime_loop", "transport", "transport_longpoll", "transport_sse"];
33
33
  /** The runtime file names an SDK with `features` ships, in code-unit order. */
@@ -6,9 +6,9 @@
6
6
  * so the two can never disagree.
7
7
  */
8
8
  import { checked, SEMVER } from "../shared/metadata.js";
9
- /* a dotted domain, then path elements (Go's module.CheckPath, less its rarely used characters) */
9
+ // a dotted domain, then path elements (Go's module.CheckPath, less its rarely used characters)
10
10
  const MODULE_PATH = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+(?:\/[A-Za-z0-9_~-](?:[A-Za-z0-9._~-]*[A-Za-z0-9_~-])?)*$/;
11
- /* a last element Go reads as a major version suffix, and the ones it takes */
11
+ // a last element Go reads as a major version suffix, and the ones it takes
12
12
  const SUFFIX = /\/v[\d.]+$/;
13
13
  const MAJOR = /\/v(?:[2-9]|[1-9]\d+)$/;
14
14
  /** `modulePath` with the major suffix `version` gives from v2 on, each refused unless Go would take it. */
@@ -1,6 +1,6 @@
1
1
  /** The runtime call's arguments: the ctx, the client's config, the call, each of `extra`, then the per-call options. */
2
2
  export const sendArgs = (client, ...extra) => ["ctx", `${client}.cfg`, "c", ...extra, "reqOpts"].join(", ");
3
- /* an operation answering without a body */
3
+ // an operation answering without a body
4
4
  const NO_BODY_SHAPE = {
5
5
  fail: "err",
6
6
  returns: "error",
@@ -1,9 +1,9 @@
1
1
  import { goString, lineComment } from "../shared/escape.js";
2
2
  import { goExported, NameScope } from "../shared/lang.js";
3
3
  import { goTypeOf } from "./types.js";
4
- /* a body sent as it is: nothing to encode first */
4
+ // a body sent as it is: nothing to encode first
5
5
  const NO_LINES = () => [];
6
- /* a text part's Go type by its scalar type (v0 codegen-go.ts:382-391); any other schema is sent as a string */
6
+ // a text part's Go type by its scalar type (v0 codegen-go.ts:382-391); any other schema is sent as a string
7
7
  const PART_SCALARS = {
8
8
  boolean: "bool",
9
9
  integer: "int64",
@@ -15,7 +15,7 @@ const PART_SCALARS = {
15
15
  const appended = (indent, part) => `${indent}fields = append(fields, ${part})`;
16
16
  /** The field of `part` named `name` on the body `local`: a list repeats the part, an unset value sends none. */
17
17
  function partField(part, name, local, at) {
18
- /* the IR gives every part its schema (ir/slots.ts partsOf, sdk-model bodyOf) */
18
+ // the IR gives every part its schema (ir/slots.ts partsOf, sdk-model bodyOf)
19
19
  const schema = at.names.resolve(part.schema);
20
20
  const list = schema.kind === "array";
21
21
  const item = schema.kind === "array" ? at.names.resolve(schema.items) : schema;
@@ -64,13 +64,17 @@ export function goBody(op, body, env) {
64
64
  const type = goTypeOf(body.schema, { ...env.at, fieldName: "Body", parentName: op.id });
65
65
  return { lines: NO_LINES, send: `jsonBody(${local})`, type };
66
66
  }
67
- case "form":
67
+ case "form": {
68
68
  return { lines: NO_LINES, send: `formBody(${local})`, type: "url.Values" };
69
- case "binary":
69
+ }
70
+ case "binary": {
70
71
  return { lines: NO_LINES, send: `readerBody(${local}, ${contentType})`, type: "io.Reader" };
71
- case "text":
72
+ }
73
+ case "text": {
72
74
  return { lines: NO_LINES, send: `rawBody([]byte(${local}), ${contentType})`, type: "string" };
73
- case "multipart":
75
+ }
76
+ case "multipart": {
74
77
  return multipartBody(op, body.parts, env);
78
+ }
75
79
  }
76
80
  }
@@ -4,7 +4,7 @@ import { compareCodeUnits, goExported, NameScope } from "../shared/lang.js";
4
4
  import { MIRROR, mirrorNotice } from "../shared/mirror.js";
5
5
  import { goMethod } from "./sdk-method.js";
6
6
  import { twinLines, twinLiteral, twinTypeLines, twinTypes } from "./sdk-mirror.js";
7
- /* the mirror as Go spells it, Client's method: goExported(MIRROR) */
7
+ // the mirror as Go spells it, Client's method: goExported(MIRROR)
8
8
  const SAFE = "Safe";
9
9
  /**
10
10
  * A member's name in `members`, `segment` exported; at the root (`path` empty) one spelled like the mirror is
@@ -3,11 +3,11 @@ import { goString, lineComment } from "../shared/escape.js";
3
3
  import { goExported, goLocal, NameScope } from "../shared/lang.js";
4
4
  import { shapeOf } from "./sdk-answer.js";
5
5
  import { goBody } from "./sdk-body.js";
6
- import { optsDecl, optsFields, optsLines, responseHeaders } from "./sdk-opts.js";
6
+ import { optsDecl, optsFields, optsLines, responseHeaders, } from "./sdk-opts.js";
7
7
  import { sseStream } from "./sse.js";
8
8
  import { goTypeOf } from "./types.js";
9
9
  import { socketStream } from "./ws.js";
10
- /* the receiver, the method's own locals and the unexported runtime names its body calls: a path param never shadows one */
10
+ // the receiver, the method's own locals and the unexported runtime names its body calls: a path param never shadows one
11
11
  const METHOD_LOCALS = [
12
12
  "c",
13
13
  "call",
@@ -1,3 +1,4 @@
1
+ import { lineComment } from "../shared/escape.js";
1
2
  /**
2
3
  * The Go SDK's safe mirror, `Client.Safe()` (bit 21 i3): a twin struct per resource struct, each method a field of its
3
4
  * name holding the normal method value under a generic wrapper that answers a `Result`. The field's type is a generic
@@ -6,8 +7,7 @@
6
7
  * wrapper (`call<n>`, `none<n>`, `stream<n>`), so a twin spells its types once and the one request path runs.
7
8
  */
8
9
  import { compareCodeUnits } from "../shared/lang.js";
9
- import { lineComment } from "../shared/escape.js";
10
- /* each kind's type and wrapper base names: none shares call's type, a connection needs no wrapper */
10
+ // each kind's type and wrapper base names: none shares call's type, a connection needs no wrapper
11
11
  const TWIN_NAMES = {
12
12
  call: ["Call", "call"],
13
13
  conn: ["Conn", null],
@@ -30,8 +30,6 @@ export type GoResponseHeaders = {
30
30
  readonly type: string;
31
31
  readonly fields: Readonly<Record<string, string>>;
32
32
  };
33
- /** Whether `op`'s Opts carry `IdempotencyKey`: an idempotent operation that answers once. */
34
- export declare const takesIdempotencyKey: (op: SdkOp) => boolean;
35
33
  /**
36
34
  * `<Op>Opts`'s param fields: each query param, then each header param, sent unless unset; a param
37
35
  * `stream` carries has none.
@@ -2,12 +2,12 @@ import { goString, lineComment } from "../shared/escape.js";
2
2
  import { compareCodeUnits, goExported, NameScope } from "../shared/lang.js";
3
3
  import { isNilable } from "./types-codec.js";
4
4
  import { goTypeOf } from "./types.js";
5
- /* the Opts field an idempotent operation's caller sets its Idempotency-Key through */
5
+ // the Opts field an idempotent operation's caller sets its Idempotency-Key through
6
6
  const IDEMPOTENCY_KEY = "IdempotencyKey";
7
7
  /** A value's Go type when it may be absent: as is where nil already means unset (H4), else a pointer. */
8
8
  const optional = (type, required) => (required || isNilable(type) ? type : `*${type}`);
9
9
  /** Whether `op`'s Opts carry `IdempotencyKey`: an idempotent operation that answers once. */
10
- export const takesIdempotencyKey = (op) => op.idempotent && op.stream === null;
10
+ const takesIdempotencyKey = (op) => op.idempotent && op.stream === null;
11
11
  /**
12
12
  * `<Op>Opts`'s param fields: each query param, then each header param, sent unless unset; a param
13
13
  * `stream` carries has none.
@@ -65,7 +65,7 @@ function declaredHeaders(op) {
65
65
  .filter((status) => /^2(?:\d\d|XX)$/i.test(status))
66
66
  .sort(compareCodeUnits)
67
67
  .flatMap((status) => op.ir.responses[status].headers ?? []);
68
- /* reversed, so the first spelling of a name is the one its key ends on */
68
+ // reversed, so the first spelling of a name is the one its key ends on
69
69
  const first = new Map(all.toReversed().map((header) => [header.name.toLowerCase(), header]));
70
70
  return [...first.values()].sort((a, b) => compareCodeUnits(a.name, b.name));
71
71
  }
@@ -14,7 +14,7 @@ export type GeneratedGoSdk = {
14
14
  readonly packages: readonly PackageIdentity[];
15
15
  };
16
16
  export declare const WEBSOCKET = "github.com/coder/websocket v1.8.15";
17
- export declare const WEBSOCKET_SUM: string[];
17
+ export declare const WEBSOCKET_SUM: readonly string[];
18
18
  /** String and rune literals and line comments: text an import check must not read as code (the CLI's cmd files too). */
19
19
  export declare const NOT_CODE: RegExp;
20
20
  /** The Go SDK module for `document`, by file name, and its notices. */
@@ -9,22 +9,22 @@
9
9
  import { toIR } from "../../ir/build.js";
10
10
  import { sdkModel } from "../../ir/sdk-model.js";
11
11
  import { lineComment } from "../shared/escape.js";
12
- import { packageOn } from "../shared/metadata.js";
13
12
  import { compareCodeUnits } from "../shared/lang.js";
13
+ import { packageOn } from "../shared/metadata.js";
14
14
  import { goErrorKeys } from "./errors.js";
15
15
  import { needsWebSocket, runtimeFiles } from "./http.js";
16
16
  import { goModulePath } from "./module-path.js";
17
17
  import { clientDecls } from "./sdk-client.js";
18
18
  import { goTopLevel, goTypeContext } from "./types.js";
19
- /* the marker gopls and linters read, apart from the package doc by a blank line */
19
+ // the marker gopls and linters read, apart from the package doc by a blank line
20
20
  const MARKER = "// Code generated by clients. DO NOT EDIT.";
21
- /* the WebSocket library and its go.sum lines, as the Go checksum database has them; the CLI's module requires them too */
21
+ // the WebSocket library and its go.sum lines, as the Go checksum database has them; the CLI's module requires them too
22
22
  export const WEBSOCKET = "github.com/coder/websocket v1.8.15";
23
23
  export const WEBSOCKET_SUM = [
24
24
  `${WEBSOCKET} h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNUA=`,
25
25
  `${WEBSOCKET}/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=`,
26
26
  ];
27
- /* what client.go may import, each only when its code uses it */
27
+ // what client.go may import, each only when its code uses it
28
28
  const CLIENT_IMPORTS = [
29
29
  ["context", "context"],
30
30
  ["json", "encoding/json"],
@@ -37,7 +37,7 @@ const CLIENT_IMPORTS = [
37
37
  export const NOT_CODE = /"(?:[^"\\\n]|\\.)*"|`[^`]*`|'(?:[^'\\\n]|\\.)*'|\/\/[^\n]*/g;
38
38
  /** A `.go` file of package `sdk` holding `decls`, importing each of `imports` (`[name, path]`) its code uses. */
39
39
  function goFile(decls, imports) {
40
- const code = decls.replace(NOT_CODE, "");
40
+ const code = decls.replaceAll(NOT_CODE, "");
41
41
  const used = imports.filter(([name]) => new RegExp(`\\b${name}\\.`).test(code)).map(([, path]) => `\t"${path}"`);
42
42
  const block = used.length === 0 ? "" : `import (\n${used.join("\n")}\n)\n\n`;
43
43
  return `${MARKER}\n\npackage sdk\n\n${block}${decls}\n`;
@@ -70,7 +70,7 @@ function emitGo(document, options) {
70
70
  const ir = toIR(document, { deriveOperationIds: true });
71
71
  const model = sdkModel(ir);
72
72
  const at = goTypeContext(ir);
73
- /* components first: the client's hoisted types then land beside them */
73
+ // components first: the client's hoisted types then land beside them
74
74
  const components = componentDecls(ir, at);
75
75
  const ops = model.opsById;
76
76
  const notices = [];
@@ -83,9 +83,6 @@ function emitGo(document, options) {
83
83
  };
84
84
  const modulePath = goModulePath(options.modulePath ?? "example.com/sdk", options.version);
85
85
  return {
86
- notices,
87
- packages: [packageOn("go", modulePath, options.version)],
88
- plans: client.plans,
89
86
  files: {
90
87
  ...runtimeFiles(features),
91
88
  ...moduleFiles(modulePath, needsWebSocket(features)),
@@ -95,6 +92,9 @@ function emitGo(document, options) {
95
92
  ["json", "encoding/json"],
96
93
  ]),
97
94
  },
95
+ notices,
96
+ packages: [packageOn("go", modulePath, options.version)],
97
+ plans: client.plans,
98
98
  };
99
99
  }
100
100
  /** The Go SDK module for `document`, by file name, and its notices. */