@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
@@ -1,17 +1,17 @@
1
- export interface BunBuild {
1
+ export type BunBuild = {
2
2
  module(specifier: string, load: () => {
3
3
  exports: Record<string, unknown>;
4
4
  loader: "object";
5
5
  }): void;
6
- }
7
- export interface BunPlugin {
6
+ };
7
+ export type BunPlugin = {
8
8
  name: string;
9
9
  setup(build: BunBuild): void | Promise<void>;
10
- }
10
+ };
11
11
  /** The slice of the `Bun` global the loader uses. */
12
- export interface BunLike {
12
+ export type BunLike = {
13
13
  plugin(plugin: BunPlugin): void;
14
- }
14
+ };
15
15
  type Importer = (url: string) => Promise<Record<string, unknown>>;
16
16
  /**
17
17
  * Bun's `onResolve` never sees the imports a runtime-loaded config makes; `build.module` does. The config's import of
@@ -9,7 +9,7 @@ export function registerNodeHook(specifier, selfUrl, register = module.registerH
9
9
  return register({
10
10
  resolve(imported, context, nextResolve) {
11
11
  if (imported === specifier)
12
- return { url: selfUrl, shortCircuit: true };
12
+ return { shortCircuit: true, url: selfUrl };
13
13
  return nextResolve(imported, context);
14
14
  },
15
15
  });
@@ -1,20 +1,18 @@
1
1
  import type { InstallgenConfig } from "./define-config.ts";
2
2
  import { type BunLike } from "./hooks/bun.ts";
3
3
  import { type RegisterHooks } from "./hooks/node.ts";
4
- /** The specifier an installgen config imports `defineConfig` from, resolved to the running package. */
5
- export declare const INSTALLERS_SPECIFIER = "@workerstack/clients/installers";
6
4
  export declare const CONFIG_FILES: readonly ["installgen.config.ts", "installgen.config.mts", "installgen.config.js", "installgen.config.mjs"];
7
- export interface RuntimeInfo {
5
+ export type RuntimeInfo = {
8
6
  runtime: "node" | "bun";
9
7
  /** `process.versions.node`; Bun reports the Node version it implements. */
10
8
  nodeVersion: string;
11
9
  bun?: BunLike;
12
- }
10
+ };
13
11
  export declare function detectRuntime(scope?: {
14
12
  Bun?: BunLike;
15
13
  }, nodeVersion?: string): RuntimeInfo;
16
14
  type Importer = (url: string) => Promise<Record<string, unknown>>;
17
- export interface LoadOptions {
15
+ export type LoadOptions = {
18
16
  cwd: string;
19
17
  /** `-c`: relative to `cwd`. */
20
18
  configPath?: string | undefined;
@@ -24,11 +22,11 @@ export interface LoadOptions {
24
22
  importModule?: Importer;
25
23
  /** Node's `module.registerHooks`. */
26
24
  registerHooks?: RegisterHooks;
27
- }
28
- export interface LoadedConfig {
25
+ };
26
+ export type LoadedConfig = {
29
27
  path: string;
30
28
  config: InstallgenConfig;
31
- }
29
+ };
32
30
  /** Whether Node `version` imports a `.ts` module natively: from 22.18, and on 23 from 23.6. */
33
31
  export declare function stripsTypes(version: string): boolean;
34
32
  export declare function loadConfig(options: LoadOptions): Promise<LoadedConfig>;
@@ -13,7 +13,7 @@ import { InstallgenError } from "../errors.js";
13
13
  import { registerBunHook } from "./hooks/bun.js";
14
14
  import { registerNodeHook } from "./hooks/node.js";
15
15
  /** The specifier an installgen config imports `defineConfig` from, resolved to the running package. */
16
- export const INSTALLERS_SPECIFIER = "@workerstack/clients/installers";
16
+ const INSTALLERS_SPECIFIER = "@workerstack/clients/installers";
17
17
  export const CONFIG_FILES = [
18
18
  "installgen.config.ts",
19
19
  "installgen.config.mts",
@@ -21,9 +21,9 @@ export const CONFIG_FILES = [
21
21
  "installgen.config.mjs",
22
22
  ];
23
23
  export function detectRuntime(scope = globalThis, nodeVersion = process.versions.node) {
24
- return scope.Bun ? { runtime: "bun", nodeVersion, bun: scope.Bun } : { runtime: "node", nodeVersion };
24
+ return scope.Bun ? { bun: scope.Bun, nodeVersion, runtime: "bun" } : { nodeVersion, runtime: "node" };
25
25
  }
26
- /* Node strips types from .ts without a flag from 22.18, and on 23 from 23.6 */
26
+ // Node strips types from .ts without a flag from 22.18, and on 23 from 23.6
27
27
  const CJS_SYNTAX = /Unexpected token 'export'|Cannot use import statement outside a module/;
28
28
  function find(cwd, configPath) {
29
29
  if (configPath !== undefined) {
@@ -70,10 +70,10 @@ export async function loadConfig(options) {
70
70
  const ext = extname(path);
71
71
  const { runtime } = options;
72
72
  const importModule = options.importModule ?? ((url) => import(__rewriteRelativeImportExtension(url)));
73
- /* the sibling entry in this module's own form: index.ts from a checkout's source, index.js from an install */
73
+ // the sibling entry in this module's own form: index.ts from a checkout's source, index.js from an install
74
74
  const selfUrl = options.selfUrl ?? new URL(`../index${extname(new URL(import.meta.url).pathname)}`, import.meta.url).href;
75
75
  assertStripsTypes(runtime, ext);
76
- /* Bun's plugin stays for the process; Node's hook goes once the config is imported */
76
+ // Bun's plugin stays for the process; Node's hook goes once the config is imported
77
77
  let hook;
78
78
  if (runtime.bun)
79
79
  await registerBunHook(runtime.bun, INSTALLERS_SPECIFIER, selfUrl, importModule);
@@ -90,8 +90,7 @@ export async function loadConfig(options) {
90
90
  hook?.deregister();
91
91
  }
92
92
  const config = mod.default;
93
- if (typeof config !== "object" || config === null) {
93
+ if (typeof config !== "object" || config === null)
94
94
  throw new InstallgenError(`${path} has no default export; write \`export default defineConfig({ ... })\``);
95
- }
96
- return { path, config: config };
95
+ return { config: config, path };
97
96
  }
@@ -1,4 +1,3 @@
1
- import { type InstallgenConfig, type Platform } from "./define-config.ts";
1
+ import { type InstallgenConfig } from "./define-config.ts";
2
2
  import type { ResolvedConfig } from "./types.ts";
3
- export declare const ALL_PLATFORMS: readonly Platform[];
4
3
  export declare function resolveConfig(input: InstallgenConfig): ResolvedConfig;
@@ -1,6 +1,6 @@
1
1
  import { InstallgenError } from "../errors.js";
2
2
  import { TAG_SENTINEL, VERSION_SENTINEL, tagToken, versionToken, } from "./define-config.js";
3
- export const ALL_PLATFORMS = [
3
+ const ALL_PLATFORMS = [
4
4
  "linux/amd64",
5
5
  "linux/arm64",
6
6
  "darwin/amd64",
@@ -11,12 +11,12 @@ export const ALL_PLATFORMS = [
11
11
  const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
12
12
  const ENV_PREFIX = /^[A-Z_][A-Z0-9_]*$/;
13
13
  const TAG_PREFIX = /^[A-Za-z0-9._-]*$/;
14
- /* Each segment of installDir after ~/: rendered into sh and ps1 paths and shell profile lines */
14
+ // Each segment of installDir after ~/: rendered into sh and ps1 paths and shell profile lines
15
15
  const DIR_SEGMENT = /^[A-Za-z0-9._ -]+$/;
16
16
  const SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*:/;
17
17
  const LOOPBACK = ["127.0.0.1", "localhost", "[::1]"];
18
18
  const MANGLED = /installgen(version|tag)/;
19
- /* the issuer of the OIDC token a GitHub Actions run signs with */
19
+ // the issuer of the OIDC token a GitHub Actions run signs with
20
20
  const GITHUB_ACTIONS_ISSUER = "https://token.actions.githubusercontent.com";
21
21
  const fail = (message) => {
22
22
  throw new InstallgenError(message);
@@ -52,25 +52,25 @@ function checkUrl(field, url) {
52
52
  return fail(`config.${field} must be an https URL (http is allowed only on loopback), got ${JSON.stringify(url)}`);
53
53
  }
54
54
  function checkRelative(field, path) {
55
- if (path === "" || path.startsWith("/") || SCHEME.test(path)) {
55
+ if (path === "" || path.startsWith("/") || SCHEME.test(path))
56
56
  fail(`config.${field} must be a path relative to baseUrl, got ${JSON.stringify(path)}`);
57
- }
58
57
  }
59
58
  function noSentinel(field, value) {
60
- if (value?.includes(VERSION_SENTINEL) || value?.includes(TAG_SENTINEL)) {
59
+ if (value?.includes(VERSION_SENTINEL) || value?.includes(TAG_SENTINEL))
61
60
  fail(`config.${field} cannot hold a version or tag token; only path functions can`);
62
- }
63
61
  }
64
62
  /** Splits on the exact sentinels; a sentinel a string method rewrote is still recognizable in a literal piece. */
65
63
  function split(field, platform, path) {
66
64
  const segments = [];
67
65
  for (const piece of path.split(new RegExp(`(${VERSION_SENTINEL}|${TAG_SENTINEL})`))) {
68
- if (piece === VERSION_SENTINEL)
66
+ if (piece === VERSION_SENTINEL) {
69
67
  segments.push({ kind: "version" });
70
- else if (piece === TAG_SENTINEL)
68
+ }
69
+ else if (piece === TAG_SENTINEL) {
71
70
  segments.push({ kind: "tag" });
71
+ }
72
72
  else if (piece !== "") {
73
- if (MANGLED.test(piece.toLowerCase().replace(/[^a-z0-9]/g, ""))) {
73
+ if (MANGLED.test(piece.toLowerCase().replaceAll(/[^a-z0-9]/g, ""))) {
74
74
  fail(`config.${field} for ${platform} returned a mangled version or tag token (${JSON.stringify(path)}); ` +
75
75
  "interpolate it as-is, without string methods");
76
76
  }
@@ -79,7 +79,7 @@ function split(field, platform, path) {
79
79
  }
80
80
  return segments;
81
81
  }
82
- /* A certificate identity is matched, never fetched: https only, loopback included */
82
+ // A certificate identity is matched, never fetched: https only, loopback included
83
83
  function checkIdentity(field, identity) {
84
84
  let parsed;
85
85
  try {
@@ -88,9 +88,8 @@ function checkIdentity(field, identity) {
88
88
  catch {
89
89
  // reported below
90
90
  }
91
- if (parsed?.protocol !== "https:" || parsed.host === "") {
91
+ if (parsed?.protocol !== "https:" || parsed.host === "")
92
92
  fail(`config.${field} must return an https URL, got ${JSON.stringify(identity)}`);
93
- }
94
93
  }
95
94
  function evaluate(field, fn, ctx, check = checkRelative) {
96
95
  const out = fn(ctx);
@@ -115,7 +114,7 @@ function signatureOf(config, signed) {
115
114
  noSentinel("signature.issuer", issuer);
116
115
  if (!checkUrl("signature.issuer", issuer))
117
116
  fail(`config.signature.issuer must be an https URL, got ${JSON.stringify(issuer)}`);
118
- return { identity, bundlePath, issuer };
117
+ return { bundlePath, identity, issuer };
119
118
  }
120
119
  function formatOf(asset) {
121
120
  const tail = asset.toLowerCase();
@@ -135,9 +134,8 @@ function platformsOf(config) {
135
134
  fail("config.platforms must list at least one platform");
136
135
  const seen = new Set();
137
136
  for (const p of value) {
138
- if (!ALL_PLATFORMS.includes(p)) {
137
+ if (!ALL_PLATFORMS.includes(p))
139
138
  fail(`config.platforms has unknown platform ${JSON.stringify(p)}; use one of ${ALL_PLATFORMS.join(", ")}`);
140
- }
141
139
  if (seen.has(p))
142
140
  fail(`config.platforms lists ${p} twice`);
143
141
  seen.add(p);
@@ -146,14 +144,14 @@ function platformsOf(config) {
146
144
  }
147
145
  const key = (segments) => segments.map((s) => (s.kind === "literal" ? `L${s.value}` : s.kind)).join("\0");
148
146
  const osOf = (platform) => platform.split("/")[0];
149
- /* GoReleaser universal_binaries: one asset serves both macOS architectures */
147
+ // GoReleaser universal_binaries: one asset serves both macOS architectures
150
148
  const universal = (a, b) => osOf(a) === "darwin" && osOf(b) === "darwin";
151
149
  function pathFunctionsOf(config) {
152
150
  const assetPath = required(func(config, "assetPath"), "assetPath", "a function");
153
151
  const checksumsPath = func(config, "checksumsPath");
154
152
  const signature = signatureOf(config, checksumsPath !== undefined);
155
153
  const binaryInArchive = func(config, "binaryInArchive");
156
- return { assetPath, checksumsPath, signature, binaryInArchive };
154
+ return { assetPath, binaryInArchive, checksumsPath, signature };
157
155
  }
158
156
  function tagPrefixOf(config) {
159
157
  const tagPrefix = string(config, "tagPrefix") ?? "v";
@@ -172,7 +170,7 @@ function installDirOf(config, name) {
172
170
  return installDir;
173
171
  }
174
172
  function envPrefixOf(config, name) {
175
- const derived = name.toUpperCase().replace(/[^A-Z0-9]/g, "_");
173
+ const derived = name.toUpperCase().replaceAll(/[^A-Z0-9]/g, "_");
176
174
  const envPrefix = string(config, "envPrefix") ?? (/^[0-9]/.test(derived) ? `_${derived}` : derived);
177
175
  if (!ENV_PREFIX.test(envPrefix))
178
176
  fail(`config.envPrefix must match ${ENV_PREFIX.source}, got ${JSON.stringify(envPrefix)}`);
@@ -186,7 +184,7 @@ function outDirOf(config) {
186
184
  }
187
185
  function scriptUrlsOf(config, baseUrl) {
188
186
  if (config.scriptUrls === undefined)
189
- return { sh: `${baseUrl}/install.sh`, ps1: `${baseUrl}/install.ps1` };
187
+ return { ps1: `${baseUrl}/install.ps1`, sh: `${baseUrl}/install.sh` };
190
188
  if (typeof config.scriptUrls !== "object" || config.scriptUrls === null)
191
189
  fail("config.scriptUrls must be an object");
192
190
  const urls = config.scriptUrls;
@@ -194,7 +192,7 @@ function scriptUrlsOf(config, baseUrl) {
194
192
  const ps1 = required(string(urls, "ps1"), "scriptUrls.ps1", "a string");
195
193
  checkUrl("scriptUrls.sh", sh);
196
194
  checkUrl("scriptUrls.ps1", ps1);
197
- return { sh, ps1 };
195
+ return { ps1, sh };
198
196
  }
199
197
  /** The settings after the path functions, validated in the order a config's errors are reported. */
200
198
  function settingsOf(config, name, baseUrl) {
@@ -219,10 +217,9 @@ function settingsOf(config, name, baseUrl) {
219
217
  ["outDir", outDir],
220
218
  ["scriptUrls.sh", scriptUrls.sh],
221
219
  ["scriptUrls.ps1", scriptUrls.ps1],
222
- ]) {
220
+ ])
223
221
  noSentinel(field, value);
224
- }
225
- return { latestPath, tagPrefix, installDir, envPrefix, modifyPath, message, outDir, scriptUrls };
222
+ return { envPrefix, installDir, latestPath, message, modifyPath, outDir, scriptUrls, tagPrefix };
226
223
  }
227
224
  function resolveSignature(signature, ctx, checksumsRaw) {
228
225
  const platform = `${ctx.os}/${ctx.arch}`;
@@ -238,30 +235,28 @@ function resolveSignature(signature, ctx, checksumsRaw) {
238
235
  }
239
236
  function resolvePlatform(platform, fns, assets) {
240
237
  const [os, arch] = platform.split("/");
241
- const ctx = { version: versionToken, tag: tagToken, os, arch };
238
+ const ctx = { arch, os, tag: tagToken, version: versionToken };
242
239
  const assetRaw = evaluate("assetPath", fns.assetPath, ctx);
243
240
  const asset = split("assetPath", platform, assetRaw);
244
- if (asset.every((s) => s.kind === "literal")) {
241
+ if (asset.every((s) => s.kind === "literal"))
245
242
  fail(`config.assetPath for ${platform} must contain the version or tag token, got ${JSON.stringify(assetRaw)}`);
246
- }
247
243
  const prior = assets.get(key(asset));
248
- if (prior !== undefined && !universal(prior, platform)) {
244
+ if (prior !== undefined && !universal(prior, platform))
249
245
  fail(`config.assetPath gives ${prior} and ${platform} the same asset ${JSON.stringify(assetRaw)}`);
250
- }
251
246
  assets.set(key(asset), platform);
252
247
  const checksumsRaw = fns.checksumsPath && evaluate("checksumsPath", fns.checksumsPath, { ...ctx, asset: assetRaw });
253
248
  const signature = fns.signature && checksumsRaw !== undefined
254
249
  ? resolveSignature(fns.signature, { ...ctx, asset: assetRaw }, checksumsRaw)
255
250
  : undefined;
256
251
  return {
257
- platform,
258
- os,
259
252
  arch,
260
253
  asset,
261
- format: formatOf(assetRaw),
254
+ binaryInArchive: fns.binaryInArchive && split("binaryInArchive", platform, evaluate("binaryInArchive", fns.binaryInArchive, ctx)),
262
255
  checksums: checksumsRaw === undefined ? undefined : split("checksumsPath", platform, checksumsRaw),
256
+ format: formatOf(assetRaw),
257
+ os,
258
+ platform,
263
259
  signature,
264
- binaryInArchive: fns.binaryInArchive && split("binaryInArchive", platform, evaluate("binaryInArchive", fns.binaryInArchive, ctx)),
265
260
  };
266
261
  }
267
262
  export function resolveConfig(input) {
@@ -9,12 +9,12 @@ export type Segment = {
9
9
  readonly kind: "tag";
10
10
  };
11
11
  export type Format = "tar.gz" | "zip" | "raw";
12
- export interface ResolvedSignature {
12
+ export type ResolvedSignature = {
13
13
  readonly bundle: readonly Segment[];
14
14
  readonly identity: readonly Segment[];
15
15
  readonly issuer: string;
16
- }
17
- export interface ResolvedPlatform {
16
+ };
17
+ export type ResolvedPlatform = {
18
18
  readonly platform: Platform;
19
19
  readonly os: Os;
20
20
  readonly arch: Arch;
@@ -23,8 +23,8 @@ export interface ResolvedPlatform {
23
23
  readonly checksums: readonly Segment[] | undefined;
24
24
  readonly signature: ResolvedSignature | undefined;
25
25
  readonly binaryInArchive: readonly Segment[] | undefined;
26
- }
27
- export interface ResolvedConfig {
26
+ };
27
+ export type ResolvedConfig = {
28
28
  readonly name: string;
29
29
  /** No trailing slash. */
30
30
  readonly baseUrl: string;
@@ -42,4 +42,4 @@ export interface ResolvedConfig {
42
42
  };
43
43
  readonly outDir: string;
44
44
  readonly platforms: readonly ResolvedPlatform[];
45
- }
45
+ };
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +1,6 @@
1
- /*
2
- * Literals are single-quoted, where neither shell expands anything; the tokens become the scripts' own variables.
3
- * sh: `$version` / `$tag`. ps1: `$ver` / `$tag` (PowerShell names are case-insensitive, so `$version` would be the
4
- * `-Version` parameter).
5
- */
1
+ // Literals are single-quoted, where neither shell expands anything; the tokens become the scripts' own variables.
2
+ // sh: `$version` / `$tag`. ps1: `$ver` / `$tag` (PowerShell names are case-insensitive, so `$version` would be the
3
+ // `-Version` parameter).
6
4
  /** One sh word: adjacent quoted pieces, so no separator is needed. */
7
5
  export function shWord(segments) {
8
6
  if (segments.length === 0)
@@ -1,20 +1,20 @@
1
1
  import type { ResolvedConfig } from "../config/types.ts";
2
2
  /** How `generateInstallers` renders beyond the config itself. */
3
- export interface RenderOptions {
3
+ export type RenderOptions = {
4
4
  /** Baked in as the version to install when neither the argument nor `<PREFIX>_VERSION` names one. */
5
5
  defaultVersion?: string | undefined;
6
- }
7
- export interface Templates {
6
+ };
7
+ export type Templates = {
8
8
  sh: string;
9
9
  ps1: string;
10
- }
10
+ };
11
11
  /** The scripts a config needs: each is absent when none of its platforms needs that script. */
12
- export interface Rendered {
12
+ export type Rendered = {
13
13
  /** `install.sh`, for the linux and darwin platforms; served for `curl -fsSL <url> | sh`. */
14
14
  sh?: string;
15
15
  /** `install.ps1`, for the windows platforms; served for `irm <url> | iex`. */
16
16
  ps1?: string;
17
- }
17
+ };
18
18
  export declare function readTemplates(): Templates;
19
19
  /** The value of each `@@KEY@@` in install.sh and install.ps1, already quoted for its shell. */
20
20
  export declare function placeholders(resolved: ResolvedConfig, options: RenderOptions): {
@@ -1,14 +1,14 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { InstallgenError } from "../errors.js";
3
3
  import { psLiteral, psString, shLiteral, shWord } from "./quote.js";
4
- /* The scripts validate the same pattern at install time, after stripping the tag prefix */
4
+ // The scripts validate the same pattern at install time, after stripping the tag prefix
5
5
  const VERSION = /^[A-Za-z0-9._+-]+$/;
6
- /* in non-unicode mode an astral character is two surrogates, both in this range */
6
+ // in non-unicode mode an astral character is two surrogates, both in this range
7
7
  const NON_ASCII = /[\u0080-\uffff]/;
8
8
  const PLACEHOLDER = /@@([A-Z0-9_]+)@@/g;
9
9
  const readTemplate = (file) => readFileSync(new URL(`../../../assets/installers/templates/${file}`, import.meta.url), "utf8");
10
10
  export function readTemplates() {
11
- return { sh: readTemplate("install.sh"), ps1: readTemplate("install.ps1") };
11
+ return { ps1: readTemplate("install.ps1"), sh: readTemplate("install.sh") };
12
12
  }
13
13
  function ascii(field, value) {
14
14
  if (value !== undefined && NON_ASCII.test(value)) {
@@ -65,26 +65,6 @@ export function placeholders(resolved, options) {
65
65
  const defaultVersion = options.defaultVersion ?? "";
66
66
  const message = resolved.message ?? "";
67
67
  return {
68
- sh: {
69
- NAME: shLiteral(resolved.name),
70
- ENV_PREFIX: resolved.envPrefix,
71
- BASE_URL: shLiteral(resolved.baseUrl),
72
- LATEST_URL: shLiteral(latestUrl),
73
- DEFAULT_VERSION: shLiteral(defaultVersion),
74
- TAG_PREFIX: shLiteral(resolved.tagPrefix),
75
- INSTALL_DIR: `"$HOME"${shLiteral(`/${resolved.installDir}`)}`,
76
- INSTALL_DIR_DISPLAY: shLiteral(`~/${resolved.installDir}`),
77
- MODIFY_PATH: resolved.modifyPath ? "1" : "0",
78
- MESSAGE: shLiteral(message),
79
- SH_URL: shLiteral(resolved.scriptUrls.sh),
80
- /* with no Windows build there is no install.ps1 to point Git Bash users at */
81
- PS1_URL: shLiteral(windows.length > 0 ? resolved.scriptUrls.ps1 : ""),
82
- CURL_FLAGS: resolved.https ? "--proto '=https' --tlsv1.2" : "",
83
- WGET_FLAGS: shLiteral(resolved.https ? "--https-only" : ""),
84
- /* a case pattern list */
85
- PLATFORMS: unix.map((p) => shLiteral(p.platform)).join(" | "),
86
- PLATFORM_CASES: unix.map(shCase).join("\n"),
87
- },
88
68
  ps1: {
89
69
  NAME: psLiteral(resolved.name),
90
70
  ENV_PREFIX: resolved.envPrefix,
@@ -92,8 +72,8 @@ export function placeholders(resolved, options) {
92
72
  LATEST_URL: psLiteral(latestUrl),
93
73
  DEFAULT_VERSION: psLiteral(defaultVersion),
94
74
  TAG_PREFIX: psLiteral(resolved.tagPrefix),
95
- /* $env:USERPROFILE is unset on non-Windows pwsh and in some service contexts, and a literal \ is a filename
96
- * character off Windows: Combine(params string[]) (.NET 4, so 5.1 too) joins with the native separator */
75
+ // $env:USERPROFILE is unset on non-Windows pwsh and in some service contexts, and a literal \ is a filename
76
+ // character off Windows: Combine(params string[]) (.NET 4, so 5.1 too) joins with the native separator
97
77
  INSTALL_DIR: `[IO.Path]::Combine([string[]](@([Environment]::GetFolderPath('UserProfile')) + @(${resolved.installDir
98
78
  .split("/")
99
79
  .map(psLiteral)
@@ -106,10 +86,30 @@ export function placeholders(resolved, options) {
106
86
  PLATFORMS: `@(${windows.map((p) => psLiteral(p.platform)).join(", ")})`,
107
87
  PLATFORM_CASES: windows.map(psCase).join("\n"),
108
88
  },
89
+ sh: {
90
+ NAME: shLiteral(resolved.name),
91
+ ENV_PREFIX: resolved.envPrefix,
92
+ BASE_URL: shLiteral(resolved.baseUrl),
93
+ LATEST_URL: shLiteral(latestUrl),
94
+ DEFAULT_VERSION: shLiteral(defaultVersion),
95
+ TAG_PREFIX: shLiteral(resolved.tagPrefix),
96
+ INSTALL_DIR: `"$HOME"${shLiteral(`/${resolved.installDir}`)}`,
97
+ INSTALL_DIR_DISPLAY: shLiteral(`~/${resolved.installDir}`),
98
+ MODIFY_PATH: resolved.modifyPath ? "1" : "0",
99
+ MESSAGE: shLiteral(message),
100
+ SH_URL: shLiteral(resolved.scriptUrls.sh),
101
+ // with no Windows build there is no install.ps1 to point Git Bash users at
102
+ PS1_URL: shLiteral(windows.length > 0 ? resolved.scriptUrls.ps1 : ""),
103
+ CURL_FLAGS: resolved.https ? "--proto '=https' --tlsv1.2" : "",
104
+ WGET_FLAGS: shLiteral(resolved.https ? "--https-only" : ""),
105
+ // a case pattern list
106
+ PLATFORMS: unix.map((p) => shLiteral(p.platform)).join(" | "),
107
+ PLATFORM_CASES: unix.map(shCase).join("\n"),
108
+ },
109
109
  };
110
110
  }
111
111
  function fill(file, template, values) {
112
- const out = template.replace(PLACEHOLDER, (_match, key) => {
112
+ const out = template.replaceAll(PLACEHOLDER, (_match, key) => {
113
113
  const value = values[key];
114
114
  if (value === undefined)
115
115
  throw new InstallgenError(`unknown placeholder @@${key}@@ in ${file}`);
@@ -1,15 +1,15 @@
1
1
  /** Rows like the installers': a mark, a label, a value. Marks and color on a TTY; plain `+`, `x`, `!` otherwise. */
2
- export interface Ui {
2
+ export type Ui = {
3
3
  ok(label: string, value: string): void;
4
4
  bad(label: string, value: string): void;
5
5
  info(text: string): void;
6
6
  warn(text: string): void;
7
7
  error(text: string): void;
8
- }
9
- export interface UiIo {
8
+ };
9
+ export type UiIo = {
10
10
  stdout(text: string): void;
11
11
  stderr(text: string): void;
12
12
  isTTY: boolean;
13
13
  env: Record<string, string | undefined>;
14
- }
14
+ };
15
15
  export declare function createUi(io: UiIo): Ui;
@@ -3,12 +3,12 @@ const row = (glyph, label, value) => `${glyph} ${label.padEnd(13)} ${value}\n`;
3
3
  export function createUi(io) {
4
4
  const color = io.isTTY && !io.env.NO_COLOR;
5
5
  const paint = (code, text) => (color ? `${ESC}[${code}m${text}${ESC}[0m` : text);
6
- const mark = { ok: io.isTTY ? "✓" : "+", bad: io.isTTY ? "✗" : "x" };
6
+ const mark = { bad: io.isTTY ? "✗" : "x", ok: io.isTTY ? "✓" : "+" };
7
7
  return {
8
- ok: (label, value) => io.stdout(row(paint(32, mark.ok), label, value)),
9
8
  bad: (label, value) => io.stdout(row(paint(31, mark.bad), label, value)),
9
+ error: (text) => io.stderr(`${paint(31, io.isTTY ? `${mark.bad} error:` : "error:")} ${text}\n`),
10
10
  info: (text) => io.stdout(`${text}\n`),
11
+ ok: (label, value) => io.stdout(row(paint(32, mark.ok), label, value)),
11
12
  warn: (text) => io.stderr(`${paint(33, "warning:")} ${text}\n`),
12
- error: (text) => io.stderr(`${paint(31, io.isTTY ? `${mark.bad} error:` : "error:")} ${text}\n`),
13
13
  };
14
14
  }
@@ -2,16 +2,16 @@ import { type IR, type IRAuth } from "./model.ts";
2
2
  type Json = Record<string, unknown>;
3
3
  /** An OpenAPI document as gen reads it: plain JSON. */
4
4
  /** A server: its URL template and the defaults of its variables. */
5
- export type OpenApiServer = {
5
+ type OpenApiServer = {
6
6
  readonly url: string;
7
7
  readonly variables?: Readonly<Record<string, {
8
8
  readonly default?: string;
9
9
  }>>;
10
10
  };
11
11
  export type OpenApiDocument = {
12
- readonly components?: Readonly<Record<string, Readonly<Record<string, unknown>>>> & {
12
+ readonly components?: (Readonly<Record<string, Readonly<Record<string, unknown>>>> & {
13
13
  readonly schemas?: Readonly<Record<string, Json>>;
14
- };
14
+ }) | undefined;
15
15
  readonly info?: Readonly<Record<string, unknown>>;
16
16
  readonly openapi: string;
17
17
  readonly paths?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
package/dist/ir/build.js CHANGED
@@ -4,8 +4,9 @@
4
4
  * document's info, and the webhooks it sends. Reads the document alone; gen never reaches into core (H2).
5
5
  */
6
6
  import { compareCodeUnits, pascalWords } from "../emit/shared/lang.js";
7
- import { schemaToIR } from "./schema.js";
7
+ import {} from "./model.js";
8
8
  import { buildResourceTree } from "./resource-tree.js";
9
+ import { schemaToIR } from "./schema.js";
9
10
  import { eventOf, extensionsOf, paramsOf, parseOpenApiPath, requestBodies, responsesOf, } from "./slots.js";
10
11
  import { websocketMessagesOf } from "./streams.js";
11
12
  const METHODS = ["get", "post", "put", "patch", "delete", "head", "options"];
@@ -108,10 +109,12 @@ function explicitOperations(doc, options, seen) {
108
109
  const op = item[method];
109
110
  const id = op.operationId;
110
111
  const site = { components, item, method, path };
111
- if (id === undefined)
112
+ if (id === undefined) {
112
113
  unnamed.push([op, site]);
113
- else if (seen.has(id) && onDuplicate === "throw")
114
+ }
115
+ else if (seen.has(id) && onDuplicate === "throw") {
114
116
  throw new Error(`Duplicate operationId: "${id}"`);
117
+ }
115
118
  else {
116
119
  const final = seen.has(id) ? free(`${id}${pascalWords(method)}`, (c) => seen.has(c)) : id;
117
120
  seen.add(final);
@@ -123,7 +126,7 @@ function explicitOperations(doc, options, seen) {
123
126
  }
124
127
  /** A server URL with each declared `{variable}` replaced by its default; an undeclared one is left as written. */
125
128
  function serverUrl({ url, variables = {} }) {
126
- return url.replace(/\{([^{}]*)\}/g, (whole, name) => variables[name]?.default ?? whole);
129
+ return url.replaceAll(/\{([^{}]*)\}/g, (whole, name) => variables[name]?.default ?? whole);
127
130
  }
128
131
  /** The IR of `doc`; an explicit id always keeps its name, a derived one takes what is left. */
129
132
  export function toIR(doc, options = {}) {
@@ -136,7 +139,7 @@ export function toIR(doc, options = {}) {
136
139
  }
137
140
  const seen = new Set();
138
141
  const { operations, unnamed } = explicitOperations(doc, options, seen);
139
- /* derived ids after explicit ones, clear of explicit ids and of their namespaces */
142
+ // derived ids after explicit ones, clear of explicit ids and of their namespaces
140
143
  const roots = new Set(operations.map(({ id }) => id.split(".")[0]));
141
144
  for (const [op, site] of options.deriveOperationIds === true ? unnamed : []) {
142
145
  const id = free(deriveOperationId(site.method, site.path), (c) => seen.has(c) || roots.has(c));
package/dist/ir/load.js CHANGED
@@ -63,18 +63,16 @@ function appOf(mod, ref, name) {
63
63
  const which = name === undefined ? "no `app` or `default` export" : `no export ${JSON.stringify(name)}`;
64
64
  throw new Error(`--app ${ref}: ${which} that is a backend app (name one as <module>#<export>)`);
65
65
  }
66
- /* Node: jiti, its one module cache shared by the app and its document, so both see one core module (its GRAPH symbol) */
66
+ // Node: jiti, its one module cache shared by the app and its document, so both see one core module (its GRAPH symbol)
67
67
  async function jitiImporter(path, alias) {
68
68
  const { createJiti } = await import("jiti");
69
69
  const jiti = createJiti(path, { alias, fsCache: false, interopDefault: true });
70
70
  return (specifier) => jiti.import(specifier);
71
71
  }
72
- /*
73
- * Bun: its own import, never jiti, which there retries a module that threw through its Babel (evaluating it twice),
74
- * whose Error.prepareStackTrace hook then breaks Bun's captureStackTrace on a non-Error (Vite's follow-redirects), and
75
- * whose native mode ignores the aliases (bit 20). A checkout's aliases hold by the backend-source condition instead:
76
- * each must resolve to its source, never to an unbuilt or stale dist/.
77
- */
72
+ // Bun: its own import, never jiti, which there retries a module that threw through its Babel (evaluating it twice),
73
+ // whose Error.prepareStackTrace hook then breaks Bun's captureStackTrace on a non-Error (Vite's follow-redirects), and
74
+ // whose native mode ignores the aliases (bit 20). A checkout's aliases hold by the backend-source condition instead:
75
+ // each must resolve to its source, never to an unbuilt or stale dist/.
78
76
  function bunImporter(bun, path, aliases, ref) {
79
77
  const from = dirname(path);
80
78
  for (const [specifier, source] of Object.entries(aliases)) {
@@ -83,10 +81,11 @@ function bunImporter(bun, path, aliases, ref) {
83
81
  resolved = bun.resolveSync(specifier, from);
84
82
  }
85
83
  catch {
86
- /* unresolvable without the condition (a checkout has no dist/): refused below, as one resolved elsewhere */
84
+ // unresolvable without the condition (a checkout has no dist/): refused below, as one resolved elsewhere
87
85
  }
88
- if (resolved !== realpathSync(source))
86
+ if (resolved !== realpathSync(source)) {
89
87
  throw new Error(`--app ${ref}: ${specifier} is a checkout, read from its source only under the backend-source condition: start Bun with --conditions=backend-source`);
88
+ }
90
89
  }
91
90
  return (specifier) => import(__rewriteRelativeImportExtension(pathToFileURL(bun.resolveSync(specifier, from)).href));
92
91
  }
@@ -101,7 +100,7 @@ export async function loadAppDocument(ref, cwd) {
101
100
  throw new Error(`--app ${ref}: no ${CORE} is installed where ${relative(cwd, path)} resolves it`);
102
101
  const bun = globalThis.Bun;
103
102
  const aliases = sourceAliases(root);
104
- /* Bun resolves core's own imports under the backend-source condition, through core's package.json */
103
+ // Bun resolves core's own imports under the backend-source condition, through core's package.json
105
104
  const load = bun === undefined
106
105
  ? await jitiImporter(path, { ...aliases.exports, ...aliases.imports })
107
106
  : bunImporter(bun, path, aliases.exports, ref);
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export type IRScalarType = "boolean" | "integer" | "null" | "number" | "string";
6
6
  /** A value's constraint keywords as the spec states them (bit 19 c): a string's, a number's, an array's. */
7
- export type IRBounds = {
7
+ type IRBounds = {
8
8
  minLength?: number;
9
9
  maxLength?: number;
10
10
  pattern?: string;
@@ -220,3 +220,4 @@ export type IR = {
220
220
  /** every webhook, by name in code-unit order */
221
221
  webhooks: IRWebhook[];
222
222
  };
223
+ export {};