@sdk-it/typescript 0.46.11 → 0.47.0

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 (60) hide show
  1. package/README.md +79 -12
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1399 -1538
  5. package/dist/index.js.map +4 -4
  6. package/dist/lib/agent/ai-sdk.d.ts +2 -1
  7. package/dist/lib/agent/ai-sdk.d.ts.map +1 -1
  8. package/dist/lib/agent/openai-agents.d.ts +2 -1
  9. package/dist/lib/agent/openai-agents.d.ts.map +1 -1
  10. package/dist/lib/client-name.d.ts +16 -0
  11. package/dist/lib/client-name.d.ts.map +1 -0
  12. package/dist/lib/client.d.ts +25 -1
  13. package/dist/lib/client.d.ts.map +1 -1
  14. package/dist/lib/emitters/interface.d.ts +4 -2
  15. package/dist/lib/emitters/interface.d.ts.map +1 -1
  16. package/dist/lib/emitters/snippet.d.ts.map +1 -1
  17. package/dist/lib/emitters/zod.d.ts +13 -3
  18. package/dist/lib/emitters/zod.d.ts.map +1 -1
  19. package/dist/lib/folder-index.d.ts +7 -0
  20. package/dist/lib/folder-index.d.ts.map +1 -0
  21. package/dist/lib/generate.d.ts +28 -3
  22. package/dist/lib/generate.d.ts.map +1 -1
  23. package/dist/lib/generator.d.ts +28 -29
  24. package/dist/lib/generator.d.ts.map +1 -1
  25. package/dist/lib/group-identifier.d.ts +7 -0
  26. package/dist/lib/group-identifier.d.ts.map +1 -0
  27. package/dist/lib/import-utilities.d.ts.map +1 -1
  28. package/dist/lib/input-schema-name.d.ts +4 -0
  29. package/dist/lib/input-schema-name.d.ts.map +1 -0
  30. package/dist/lib/model-name.d.ts +7 -0
  31. package/dist/lib/model-name.d.ts.map +1 -0
  32. package/dist/lib/module-file.d.ts +7 -0
  33. package/dist/lib/module-file.d.ts.map +1 -0
  34. package/dist/lib/one-module.d.ts +57 -0
  35. package/dist/lib/one-module.d.ts.map +1 -0
  36. package/dist/lib/options.d.ts +4 -6
  37. package/dist/lib/options.d.ts.map +1 -1
  38. package/dist/lib/readme/prop.emitter.d.ts +4 -4
  39. package/dist/lib/readme/prop.emitter.d.ts.map +1 -1
  40. package/dist/lib/readme/readme.d.ts.map +1 -1
  41. package/dist/lib/references.d.ts +43 -0
  42. package/dist/lib/references.d.ts.map +1 -0
  43. package/dist/lib/root-exports.d.ts +6 -0
  44. package/dist/lib/root-exports.d.ts.map +1 -0
  45. package/dist/lib/sdk.d.ts +17 -27
  46. package/dist/lib/sdk.d.ts.map +1 -1
  47. package/dist/lib/security.d.ts +2 -3
  48. package/dist/lib/security.d.ts.map +1 -1
  49. package/dist/lib/server-urls.d.ts.map +1 -1
  50. package/dist/lib/status-map.d.ts +2 -2
  51. package/dist/lib/status-map.d.ts.map +1 -1
  52. package/dist/lib/typescript-snippet.d.ts +4 -8
  53. package/dist/lib/typescript-snippet.d.ts.map +1 -1
  54. package/package.json +19 -6
  55. package/dist/lib/pagination-emit.d.ts +0 -3
  56. package/dist/lib/pagination-emit.d.ts.map +0 -1
  57. package/dist/lib/response-shape.d.ts +0 -22
  58. package/dist/lib/response-shape.d.ts.map +0 -1
  59. package/dist/lib/style.d.ts +0 -4
  60. package/dist/lib/style.d.ts.map +0 -1
@@ -1,3 +1,4 @@
1
1
  import { type IR } from '@sdk-it/spec';
2
- export declare function generateAISDKTools(ir: IR): string;
2
+ import { type MakeImportFn } from '../import-utilities.ts';
3
+ export declare function generateAISDKTools(ir: IR, makeImport: MakeImportFn): string;
3
4
  //# sourceMappingURL=ai-sdk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-sdk.d.ts","sourceRoot":"","sources":["../../../src/lib/agent/ai-sdk.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EAAE,EAIR,MAAM,cAAc,CAAC;AAEtB,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,UA4CxC"}
1
+ {"version":3,"file":"ai-sdk.d.ts","sources":["../../../src/lib/agent/ai-sdk.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EAAE,EAQR,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,YAAY,UAqClE"}
@@ -1,3 +1,4 @@
1
1
  import { type IR } from '@sdk-it/spec';
2
- export declare function generateOpenAIAgentTools(spec: IR): string;
2
+ import { type MakeImportFn } from '../import-utilities.ts';
3
+ export declare function generateOpenAIAgentTools(spec: IR, makeImport: MakeImportFn): string;
3
4
  //# sourceMappingURL=openai-agents.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai-agents.d.ts","sourceRoot":"","sources":["../../../src/lib/agent/openai-agents.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EAAE,EAIR,MAAM,cAAc,CAAC;AAEtB,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,EAAE,UAgBhD"}
1
+ {"version":3,"file":"openai-agents.d.ts","sources":["../../../src/lib/agent/openai-agents.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAAE,EAQR,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,YAAY,UAgB1E"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The name a generated SDK builds its exports from (`create<Name>`,
3
+ * `<Name>Client`, the default instance `<name>`): `name` in PascalCase.
4
+ * Throws a TypeError, naming `name`, when that is not a TypeScript identifier,
5
+ * the default instance would be a reserved word, or a name built from it is
6
+ * one the SDK already declares or exports (`Request` makes the default
7
+ * instance `request`, which the SDK root exports).
8
+ */
9
+ export declare function clientName(name: string): string;
10
+ /**
11
+ * Throws the TypeError of `clientName` when a name built from `pascal`, the
12
+ * client name `name` gives, is one of `taken`: names that come from the spec,
13
+ * such as the input schemas the SDK root exports (`listItemsSchema`).
14
+ */
15
+ export declare function refuseTakenNames(name: string, pascal: string, taken: ReadonlySet<string>): void;
16
+ //# sourceMappingURL=client-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-name.d.ts","sources":["../../src/lib/client-name.ts"],"names":[],"mappings":"AAwEA;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAe/C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,QAQ3B"}
@@ -1,4 +1,28 @@
1
+ import { type References } from './references.ts';
1
2
  import type { Spec } from './sdk.ts';
2
- declare const _default: (spec: Omit<Spec, "operations">) => string;
3
+ type ClientSpec = Omit<Spec, 'operations' | 'makeImport'>;
4
+ /** Names the generated client module exports at the SDK root besides its models. */
5
+ export declare function clientExports(name: string): string[];
6
+ /** The names a client named `name` declares and exports from the SDK root. */
7
+ export declare function clientNamedExports(name: string): string[];
8
+ /** The module bindings `clientDeclarations` declares besides `clientNamedExports`. */
9
+ export declare const clientDeclarationBindings: string[];
10
+ /** Every name `clientDeclarations` can declare for a client named `name`. */
11
+ export declare function clientDeclaredNames(name: string): string[];
12
+ /** The runtime functions the SDK root exports from the client module. */
13
+ export declare const clientRuntimeExports: string[];
14
+ /** The runtime types the SDK root exports when the spec names security schemes. */
15
+ export declare function clientRuntimeTypeExports(spec: ClientSpec): never[] | readonly ["SecurityContext", "SecurityCredential", "SecurityCredentialProvider", "SecurityCredentialValue"];
16
+ /**
17
+ * The spec-specific part of a generated SDK's client: its servers and security
18
+ * as an `api` over the endpoint table `routes`, a `create<Name>(settings)`
19
+ * factory over @sdk-it/runtime's Client, and a default instance when the spec
20
+ * names at most one server.
21
+ */
22
+ export declare function clientDeclarations(spec: ClientSpec, refs: References, routes: string): string;
23
+ /** The module bindings client.ts makes besides `clientDeclarations`: zod, its imports and re-exports. */
24
+ export declare const clientFileBindings: string[];
3
25
  export default _default;
26
+ /** The client.ts file of a multi-file SDK. */
27
+ declare function _default(spec: Omit<Spec, 'operations'>): string;
4
28
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;yBAErB,MAAM,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC;AAA9C,wBAiME"}
1
+ {"version":3,"file":"client.d.ts","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,UAAU,EAGhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAIrC,KAAK,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,CAAC,CAAC;AA4B1D,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,YAQzC;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,YAE9C;AAED,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,UAKrC,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,YAE/C;AAED,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,UAAyB,CAAC;AAE3D,mFAAmF;AACnF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,UAAU,yHAExD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,UAqBf;AAYD,yGAAyG;AACzG,eAAO,MAAM,kBAAkB,UAM9B,CAAC;AAOF,wBAqBE;AAtBF,8CAA8C;0BAC9B,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC"}
@@ -1,8 +1,10 @@
1
1
  import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';
2
- import { type IR } from '@sdk-it/spec';
2
+ import { type OpenAPIDocument } from '@sdk-it/core';
3
+ import type { ModelNamer } from '../model-name.ts';
4
+ import type { References } from '../references.ts';
3
5
  export declare class TypeScriptEmitter {
4
6
  #private;
5
- constructor(spec: IR);
7
+ constructor(spec: OpenAPIDocument, modelName: ModelNamer, refs: References);
6
8
  object(schema: SchemaObject, _required?: boolean): string;
7
9
  /**
8
10
  * Convert a basic type (string | number | boolean | object | array, etc.) to TypeScript
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/lib/emitters/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAUvE,OAAO,EAAE,KAAK,EAAE,EAAkC,MAAM,cAAc,CAAC;AAEvE,qBAAa,iBAAiB;;gBAGhB,IAAI,EAAE,EAAE;IAOpB,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,UAAQ,GAAG,MAAM;IA0CvD;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,UAAQ,GAAG,MAAM;IAgCpE,KAAK,CAAC,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,GAAG,MAAM;IAM1D,KAAK,CACH,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,EAC3C,QAAQ,EAAE,OAAO,GAChB,MAAM;IA8BT,KAAK,CACH,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,EAC3C,QAAQ,EAAE,OAAO,GAChB,MAAM;IAIT,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,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OAAO,CAGjE;IAEM,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAIzC;IAEM,MAAM,CAAC,WAAW,EAAE,YAAY,GAAG,eAAe,GAAG,OAAO,CA+DlE;CACF"}
@@ -1,21 +1,31 @@
1
1
  import type { ReferenceObject, SchemaObject } from 'openapi3-ts/oas31';
2
2
  import { type OpenAPIDocument } from '@sdk-it/core';
3
- type OnRefCallback = (ref: string, content: string) => void;
3
+ import type { ModelNamer } from '../model-name.ts';
4
+ import type { References } from '../references.ts';
5
+ /** Zod source and the shared schemas it names. */
6
+ export interface EmittedZod {
7
+ zod: string;
8
+ /** The names of the shared schemas `zod` references. */
9
+ references: ReadonlySet<string>;
10
+ }
11
+ type OnRefCallback = (ref: string, schema: EmittedZod) => void;
4
12
  /**
5
13
  * Convert an OpenAPI (JSON Schema style) object into a Zod schema string,
6
14
  */
7
15
  export declare class ZodEmitter {
8
16
  #private;
9
- constructor(spec: OpenAPIDocument, onRef?: OnRefCallback);
17
+ constructor(spec: OpenAPIDocument, modelName: ModelNamer, refs: References, onRef?: OnRefCallback);
10
18
  /**
11
19
  * Convert a basic type (string | number | boolean | object | array, etc.) to Zod.
12
20
  * We'll also handle .optional() if needed.
13
21
  */
14
22
  normal(type: string, schema: SchemaObject, required?: boolean, nullable?: boolean): string;
23
+ /** `schema` as zod source, with the shared schemas that source references. */
24
+ emit(schema: SchemaObject | ReferenceObject, required: boolean): EmittedZod;
15
25
  allOf(schemas: (SchemaObject | ReferenceObject)[], required: boolean): string;
16
26
  anyOf(schemas: (SchemaObject | ReferenceObject)[], required: boolean): string;
17
27
  oneOf(schemas: (SchemaObject | ReferenceObject)[], required: boolean): string;
18
- enum(type: string, values: any[]): string;
28
+ enum(values: any[]): string;
19
29
  /**
20
30
  * Handle a `string` schema with possible format keywords (JSON Schema).
21
31
  */
@@ -1 +1 @@
1
- {"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../../src/lib/emitters/zod.ts"],"names":[],"mappings":"A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B,CAAC;AAEnD,kDAAkD;AAClD,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACjC;AAED,KAAK,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;AAE/D;;GAEG;AACH,qBAAa,UAAU;;IASrB,YACE,IAAI,EAAE,eAAe,EACrB,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,UAAU,EAChB,KAAK,CAAC,EAAE,aAAa,EAMtB;IA0DD;;;OAGG;IACH,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,YAAY,EACpB,QAAQ,UAAQ,EAChB,QAAQ,UAAQ,GACf,MAAM,CA8BR;IAkCD,8EAA8E;IAC9E,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,EAAE,QAAQ,EAAE,OAAO,GAAG,UAAU,CAQ1E;IASD,KAAK,CAAC,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UASnE;IAED,KAAK,CAAC,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAMnE;IAED,KAAK,CAAC,OAAO,EAAE,CAAC,YAAY,GAAG,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAQnE;IAED,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,UAWjB;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAqFnC;IA+CD,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,eAAe,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CA+ExE;CACF"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The index.ts files of an SDK whose source files are `paths` (relative to the
3
+ * SDK source root). `contentOf` gives the content of an index.ts the SDK does
4
+ * not generate, such as one a user added to a subfolder.
5
+ */
6
+ export declare function indexFiles(paths: Iterable<string>, contentOf: (path: string) => string | undefined, useTsExtension: boolean): Record<string, string>;
7
+ //# sourceMappingURL=folder-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folder-index.d.ts","sources":["../../src/lib/folder-index.ts"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EACvB,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC/C,cAAc,EAAE,OAAO,GACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBxB"}
@@ -1,9 +1,34 @@
1
1
  import { type OpenAPIDocument } from '@sdk-it/core';
2
- import { type MakeImportFn } from './import-utilities.ts';
2
+ import { type PaginationConfig } from '@sdk-it/spec';
3
+ import { type ModuleSpan } from './one-module.ts';
3
4
  import type { TypeScriptGeneratorOptions } from './options.ts';
4
- import type { Operation } from './sdk.ts';
5
+ export type { ModuleSpan } from './one-module.ts';
6
+ export interface RenderOptions {
7
+ name: string;
8
+ useTsExtension: boolean;
9
+ pagination?: PaginationConfig | false;
10
+ agentTools?: 'ai-sdk' | 'openai-agents';
11
+ }
12
+ /**
13
+ * The SDK's source files, keyed by path relative to the SDK source root,
14
+ * index files included. Reads and writes nothing on disk.
15
+ */
16
+ export declare function render(openapi: OpenAPIDocument, options: RenderOptions): Promise<Record<string, string>>;
17
+ export interface ModuleOptions {
18
+ name: string;
19
+ }
20
+ /**
21
+ * The SDK as one TypeScript module that carries the runtime source, for hosts
22
+ * that load a spec as a module (a content mapper, a bundler plugin, a loader).
23
+ * It exports what the SDK root of `render()` exports. `spans` maps the names
24
+ * the module declares to where the document declares them. Reads and writes
25
+ * nothing on disk.
26
+ */
27
+ export declare function renderModule(openapi: OpenAPIDocument, options: ModuleOptions): Promise<{
28
+ text: string;
29
+ spans: ModuleSpan[];
30
+ }>;
5
31
  export declare function generate(openapi: OpenAPIDocument, settings: TypeScriptGeneratorOptions): Promise<{
6
32
  packageName: string;
7
33
  }>;
8
- export declare function toInputs(operationsSet: Record<string, Operation[]>, commonZod: Map<string, string>, makeImport: MakeImportFn): any;
9
34
  //# sourceMappingURL=generate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/lib/generate.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,eAAe,EAA2B,MAAM,cAAc,CAAC;AA8B7E,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAK/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAQ1C,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,0BAA0B,GACnC,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CA+QlC;AAiED,wBAAgB,QAAQ,CACtB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,EAC1C,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,UAAU,EAAE,YAAY,OAsDzB"}
1
+ {"version":3,"file":"generate.d.ts","sources":["../../src/lib/generate.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,cAAc,CAAC;AAOtB,OAAO,EAEL,KAAK,gBAAgB,EAMtB,MAAM,cAAc,CAAC;AAmBtB,OAAO,EACL,KAAK,UAAU,EAGhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAO/D,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAAC;IACtC,UAAU,CAAC,EAAE,QAAQ,GAAG,eAAe,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAsB,MAAM,CAC1B,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAEjC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,EAAE,CAAA;CAAE,CAAC,CAkDhD;AA2DD,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,0BAA0B,GACnC,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAsIlC"}
@@ -1,39 +1,38 @@
1
- import type { SchemaObject } from 'openapi3-ts/oas31';
2
- import { type IR, type TunedOperationObject } from '@sdk-it/spec';
3
- import { type OperationInput } from './sdk.ts';
4
- import type { Style } from './style.ts';
5
- export interface NamedImport {
6
- name: string;
7
- alias?: string;
8
- isTypeOnly: boolean;
9
- }
10
- export interface Import {
11
- isTypeOnly: boolean;
12
- moduleSpecifier: string;
13
- defaultImport: string | undefined;
14
- namedImports: NamedImport[];
15
- namespaceImport: string | undefined;
16
- }
1
+ import { type IR } from '@sdk-it/spec';
2
+ import { type EmittedZod } from './emitters/zod.ts';
3
+ import type { ModelNamer } from './model-name.ts';
4
+ import { type References } from './references.ts';
5
+ import { type Operation } from './sdk.ts';
6
+ /**
7
+ * A spec's operations as code: per group, its routes (with their input
8
+ * schemas) and endpoint entries, and the shared zod schemas the inputs
9
+ * reference, each after the ones it uses.
10
+ */
11
+ export declare function operationFragments(config: {
12
+ spec: IR;
13
+ modelName: ModelNamer;
14
+ /** How shared zod schemas name model types. */
15
+ zodRefs: References;
16
+ /** How endpoint entries name what they use. */
17
+ endpointRefs: References;
18
+ }): {
19
+ groups: Record<string, Operation[]>;
20
+ commonZod: Map<string, EmittedZod>;
21
+ endpoints: Record<string, string[]>;
22
+ };
17
23
  export declare function generateCode(config: {
18
24
  /**
19
25
  * No support for jsdoc in vscode
20
26
  * @issue https://github.com/microsoft/TypeScript/issues/38106
21
27
  */
22
28
  spec: IR;
23
- style: Style;
24
29
  makeImport: (module: string) => string;
30
+ modelName: ModelNamer;
25
31
  }): {
26
- groups: Record<string, import("./sdk.ts").Operation[]>;
27
- commonZod: Map<string, string>;
28
- endpoints: any;
29
- };
30
- export declare function buildInput(spec: IR, operation: TunedOperationObject): {
31
- inputs: Record<string, OperationInput>;
32
- outgoingContentType: "json" | "text" | "empty" | "xml" | "urlencoded" | "formdata";
33
- ct: string;
34
- };
35
- export declare function operationSchema(ir: IR, operation: TunedOperationObject, type: string): SchemaObject & {
36
- required: string[];
37
- properties: {};
32
+ groups: Record<string, Operation[]>;
33
+ commonZod: Map<string, EmittedZod>;
34
+ endpoints: {
35
+ [x: string]: string;
36
+ };
38
37
  };
39
38
  //# sourceMappingURL=generator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/lib/generator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,YAAY,EACb,MAAM,mBAAmB,CAAC;AAW3B,OAAO,EACL,KAAK,EAAE,EACP,KAAK,oBAAoB,EAE1B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,UAAU,CAAC;AACtE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAwCxC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MA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AAE;IACnC;;;OAGG;IACH,IAAI,EAAE,EAAE,CAAC;IACT,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,SAAS,EAAE,UAAU,CAAC;CACvB;;;;;;EAiDA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The identifier a group (operation tag) gets in generated code. camelcase
3
+ * drops the leading `_` that keeps a digit-leading tag like `_2fa` a valid
4
+ * identifier, so the tag is sanitized again afterwards.
5
+ */
6
+ export declare function groupIdentifier(group: string): string;
7
+ //# sourceMappingURL=group-identifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-identifier.d.ts","sources":["../../src/lib/group-identifier.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,UAE5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"import-utilities.d.ts","sourceRoot":"","sources":["../../src/lib/import-utilities.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,YAsBhD;AAED,MAAM,WAAW,MAAM;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AACD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,YAenD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,YAe/D;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,eAAe,EAAE,MAAM,KAAK,MAAM,CAAC"}
1
+ {"version":3,"file":"import-utilities.d.ts","sources":["../../src/lib/import-utilities.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,YAsBhD;AAED,MAAM,WAAW,MAAM;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AACD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,YAenD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,YAe/D;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,eAAe,EAAE,MAAM,KAAK,MAAM,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { type OperationInput } from '@sdk-it/spec';
2
+ /** The name the generated `inputs` module exports `input`'s schema under: `uploadFileSchema`, or `uploadFileFormdataSchema` for a variant. */
3
+ export declare function inputSchemaName(operationId: string, input: OperationInput): string;
4
+ //# sourceMappingURL=input-schema-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-schema-name.d.ts","sources":["../../src/lib/input-schema-name.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAa,MAAM,cAAc,CAAC;AAE9D,8IAA8I;AAC9I,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,UAEzE"}
@@ -0,0 +1,7 @@
1
+ export type ModelNamer = (schemaName: string) => string;
2
+ /**
3
+ * Names model types so that none shadows a runtime or client export of the SDK
4
+ * root (a trailing `_` is appended), and no two schemas share one.
5
+ */
6
+ export declare function createModelNamer(clientName: string): ModelNamer;
7
+ //# sourceMappingURL=model-name.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-name.d.ts","sources":["../../src/lib/model-name.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;AAExD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAkB/D"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The file name (without extension) of a generated module. A module named
3
+ * `index` would collide with its folder's barrel, so it gets a trailing `-`,
4
+ * the way spinalcase renders the namer's trailing `_`.
5
+ */
6
+ export declare function moduleFileName(name: string): string;
7
+ //# sourceMappingURL=module-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-file.d.ts","sources":["../../src/lib/module-file.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,UAG1C"}
@@ -0,0 +1,57 @@
1
+ import type { EmittedZod } from './emitters/zod.ts';
2
+ import type { References } from './references.ts';
3
+ /**
4
+ * The names a one-module SDK uses: spec names as declared, and runtime names
5
+ * and globals as marks that `assembleModule` resolves once it knows which spec
6
+ * names take a runtime name or shadow a global; a located name is marked with
7
+ * its location (`@` and the location JSON, then the name). Generated code never
8
+ * contains a NUL character (JSON.stringify escapes it), so a mark cannot collide.
9
+ */
10
+ export declare const moduleReferences: References;
11
+ /**
12
+ * A range of a one-module SDK's text (UTF-16 offsets, `end` exclusive) that
13
+ * names what the OpenAPI document declares at `location` (RFC 6901 reference
14
+ * tokens, unescaped): an endpoint key, a model, create<Name>, the default
15
+ * instance.
16
+ */
17
+ export interface ModuleSpan {
18
+ start: number;
19
+ end: number;
20
+ location: readonly string[];
21
+ }
22
+ export interface ModuleParts {
23
+ /** Shared zod schemas by name, each after the ones it uses. */
24
+ commonZod: Map<string, EmittedZod>;
25
+ inputs: {
26
+ name: string;
27
+ zod: string;
28
+ }[];
29
+ /** `location` is where the document declares the model, when it does. */
30
+ models: {
31
+ typeName: string;
32
+ doc: string;
33
+ type: string;
34
+ location: readonly string[] | undefined;
35
+ }[];
36
+ /** Endpoint entries (`"GET /pets": {…}`) of the table the client reads as `__routes`. */
37
+ endpoints: string[];
38
+ /** The client declarations over `__routes`. */
39
+ client: string;
40
+ /** The names `client` declares. */
41
+ clientNames: readonly string[];
42
+ /** Runtime functions and types the SDK root exports besides the response and parser ones. */
43
+ runtimeExports: readonly string[];
44
+ runtimeTypeExports: readonly string[];
45
+ }
46
+ /**
47
+ * The SDK as one module text: the runtime, then the spec's shared schemas,
48
+ * inputs, models, endpoint table and client, each after what it uses.
49
+ * Runtime and spec share one scope, and spec names win: a runtime binding a
50
+ * spec name takes is renamed `__<name>`, and a global a spec name shadows is
51
+ * read as `globalThis.<name>`.
52
+ */
53
+ export declare function assembleModule(parts: ModuleParts): {
54
+ text: string;
55
+ spans: ModuleSpan[];
56
+ };
57
+ //# sourceMappingURL=one-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"one-module.d.ts","sources":["../../src/lib/one-module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,UAO9B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACnC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACxC,yEAAyE;IACzE,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;KACzC,EAAE,CAAC;IACJ,yFAAyF;IACzF,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,6FAA6F;IAC7F,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB,CAoEA"}
@@ -1,18 +1,16 @@
1
1
  import { npmRunPathEnv } from 'npm-run-path';
2
- import { type ReadFolderFn, type Writer } from '@sdk-it/core/file-system.js';
2
+ import { type Writer } from '@sdk-it/core/file-system.js';
3
3
  import type { PaginationConfig } from '@sdk-it/spec';
4
- import type { Style } from './style.ts';
5
4
  export interface TypeScriptGeneratorOptions {
6
5
  agentTools?: 'ai-sdk' | 'openai-agents';
7
6
  readme?: boolean | string;
8
- style?: Style;
9
7
  output: string;
10
8
  useTsExtension?: boolean;
11
- name?: string;
12
- packageName?: string;
9
+ name: string;
10
+ /** The npm name of the generated package: package.json's name, and the name the README installs and imports. */
11
+ packageName: string;
13
12
  pagination?: PaginationConfig | false;
14
13
  writer?: Writer;
15
- readFolder?: ReadFolderFn;
16
14
  /**
17
15
  * full: generate a full project including package.json and tsconfig.json. useful for monorepo/workspaces
18
16
  * minimal: generate only the client sdk
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/lib/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,0BAA0B;IACzC,UAAU,CAAC,EAAE,QAAQ,GAAG,eAAe,CAAC;IACxC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;KACvC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
1
+ {"version":3,"file":"options.d.ts","sources":["../../src/lib/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,WAAW,0BAA0B;IACzC,UAAU,CAAC,EAAE,QAAQ,GAAG,eAAe,CAAC;IACxC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,gHAAgH;IAChH,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;KACvC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -1,4 +1,4 @@
1
- import type { ReferenceObject, RequestBodyObject, SchemaObject } from 'openapi3-ts/oas31';
1
+ import type { ParameterObject, ReferenceObject, RequestBodyObject, SchemaObject } from 'openapi3-ts/oas31';
2
2
  import { type OpenAPIDocument } from '@sdk-it/core';
3
3
  /**
4
4
  * PropEmitter handles converting OpenAPI schemas to Markdown documentation
@@ -10,9 +10,9 @@ export declare class PropEmitter {
10
10
  * Handle schemas by resolving references and delegating to appropriate handler
11
11
  */
12
12
  handle(schemaOrRef: SchemaObject | ReferenceObject): string[];
13
- /**
14
- * Process a request body and return markdown documentation
15
- */
13
+ /** The documentation of a request body, one block per content type. */
16
14
  requestBody(requestBody: RequestBodyObject): string[];
15
+ /** A table of the operation's path, query, header and cookie parameters. */
16
+ parameters(parameters: readonly ParameterObject[]): string[];
17
17
  }
18
18
  //# sourceMappingURL=prop.emitter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prop.emitter.d.ts","sourceRoot":"","sources":["../../../src/lib/readme/prop.emitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,cAAc,CAAC;AAGtE;;GAEG;AACH,qBAAa,WAAW;;gBAGV,IAAI,EAAE,eAAe;IAiPjC;;OAEG;IACI,MAAM,CAAC,WAAW,EAAE,YAAY,GAAG,eAAe,GAAG,MAAM,EAAE;IA4DpE;;OAEG;IACH,WAAW,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM,EAAE;CAmCtD"}
1
+ {"version":3,"file":"prop.emitter.d.ts","sources":["../../../src/lib/readme/prop.emitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,cAAc,CAAC;AAGtE;;GAEG;AACH,qBAAa,WAAW;;IAGtB,YAAY,IAAI,EAAE,eAAe,EAEhC;IA+OD;;OAEG;IACI,MAAM,CAAC,WAAW,EAAE,YAAY,GAAG,eAAe,GAAG,MAAM,EAAE,CA0DnE;IAED,uEAAuE;IACvE,WAAW,CAAC,WAAW,EAAE,iBAAiB,GAAG,MAAM,EAAE,CA2BpD;IAED,4EAA4E;IAC5E,UAAU,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,EAAE,CA0B3D;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"readme.d.ts","sourceRoot":"","sources":["../../../src/lib/readme/readme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,EAAoB,MAAM,cAAc,CAAC;AAIzD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,UA+HtD"}
1
+ {"version":3,"file":"readme.d.ts","sources":["../../../src/lib/readme/readme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,EAAqC,MAAM,cAAc,CAAC;AAI1E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,UA6ItD"}
@@ -0,0 +1,43 @@
1
+ import type { RequestEncoding } from '@sdk-it/spec';
2
+ /** The runtime declarations that emitted code refers to, besides the response classes. */
3
+ export type RuntimeName = RequestEncoding | 'toRequest' | 'Dispatcher' | 'fetchType' | 'Interceptor' | 'chunked' | 'buffered' | 'sse' | 'bodyless' | 'SSEListener' | 'Client' | 'ClientSettings' | 'EndpointsOf' | 'createClient' | 'stringCredentialSchema' | 'basicCredentialSchema' | 'mutualTlsCredentialSchema';
4
+ /** The globals that emitted code refers to. */
5
+ export type EmittedGlobal = 'Blob' | 'Date' | 'Record' | 'AbortSignal' | 'ReadableStream';
6
+ /**
7
+ * How emitted code names a declaration that another part of the SDK makes.
8
+ * A multi-file SDK reaches other files through the namespace imports each file
9
+ * makes (`models.Pet`, `pets.listPetsSchema`, `http.Ok`); a one-module SDK
10
+ * declares everything in one scope.
11
+ */
12
+ export interface References {
13
+ /** A model type, by its TypeScript name. */
14
+ model(typeName: string): string;
15
+ /** The schema const of an operation input in `group`. */
16
+ input(group: string, schemaName: string): string;
17
+ /** A declaration of the runtime's response module: a class (`Ok`, `NotFound`, `APIError`, …) or `RangeStatus`. */
18
+ status(className: string): string;
19
+ runtime(name: RuntimeName): string;
20
+ global(name: EmittedGlobal): string;
21
+ /**
22
+ * `text`, which names what the OpenAPI document declares at `location`
23
+ * (RFC 6901 reference tokens, unescaped).
24
+ */
25
+ located(text: string, location: readonly string[]): string;
26
+ }
27
+ /**
28
+ * The names a file of the multi-file SDK uses. Each file imports models as
29
+ * `modelNamespace` (`models` from a model file, `outputs` from an endpoint
30
+ * file), the response classes as `http` and other runtime declarations by name.
31
+ */
32
+ export declare function fileReferences(modelNamespace: 'models' | 'outputs'): References;
33
+ /**
34
+ * The names an inputs file of the multi-file SDK uses. It imports the shared
35
+ * schemas it uses by name, and a shared schema may take a global's name
36
+ * (`Date`), so a global is a mark that `inputGlobals` resolves once the shared
37
+ * schemas are known. Generated code never contains a NUL character
38
+ * (JSON.stringify escapes it), so a mark cannot collide.
39
+ */
40
+ export declare const inputFileReferences: References;
41
+ /** `text` with each global mark of `inputFileReferences` read as `globalThis.<name>` when a shared schema takes the name. */
42
+ export declare function inputGlobals(text: string, schemaNames: ReadonlySet<string>): string;
43
+ //# sourceMappingURL=references.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"references.d.ts","sources":["../../src/lib/references.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,0FAA0F;AAC1F,MAAM,MAAM,WAAW,GACnB,eAAe,GACf,WAAW,GACX,YAAY,GACZ,WAAW,GACX,aAAa,GACb,SAAS,GACT,UAAU,GACV,KAAK,GACL,UAAU,GACV,aAAa,GACb,QAAQ,GACR,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,wBAAwB,GACxB,uBAAuB,GACvB,2BAA2B,CAAC;AAEhC,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GACvB,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,aAAa,GAAG,gBAAgB,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,4CAA4C;IAC5C,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,yDAAyD;IACzD,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IACjD,kHAAkH;IAClH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC;IACnC,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;IACpC;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC;CAC5D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,cAAc,EAAE,QAAQ,GAAG,SAAS,GACnC,UAAU,CASZ;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAGjC,CAAC;AAEF,6HAA6H;AAC7H,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,UAI1E"}
@@ -0,0 +1,6 @@
1
+ import { type DeclaredBinding } from 'runtime-module';
2
+ /** The runtime files whose exports the SDK root re-exports: the response classes, ParseError and parseInput. */
3
+ export declare const rootRuntimeFiles: string[];
4
+ /** The runtime declarations the SDK root re-exports. */
5
+ export declare const runtimeRootExports: DeclaredBinding[];
6
+ //# sourceMappingURL=root-exports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root-exports.d.ts","sources":["../../src/lib/root-exports.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE/D,gHAAgH;AAChH,eAAO,MAAM,gBAAgB,UAAyC,CAAC;AAEvE,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,mBAK9B,CAAC"}
package/dist/lib/sdk.d.ts CHANGED
@@ -1,18 +1,8 @@
1
1
  import { type OpenAPISecuritySchemeObject } from '@sdk-it/core';
2
- import { type TunedOperationObject, type TunedResponseObject } from '@sdk-it/spec';
2
+ import { type OperationInput, type TunedOperationObject, type TunedResponseObject } from '@sdk-it/spec';
3
3
  import { type MakeImportFn } from './import-utilities.ts';
4
- export type Parser = 'chunked' | 'buffered' | 'sse' | 'bodyless';
5
- export interface SdkConfig {
6
- /**
7
- * The name of the sdk client
8
- */
9
- name: string;
10
- packageName?: string;
11
- options?: Record<string, unknown>;
12
- emptyBodyAsNull?: boolean;
13
- stripBodyFromGetAndHead?: boolean;
14
- output: string;
15
- }
4
+ import type { ModelNamer } from './model-name.ts';
5
+ import type { References } from './references.ts';
16
6
  export interface Spec {
17
7
  name: string;
18
8
  securitySchemes: Record<string, OpenAPISecuritySchemeObject>;
@@ -20,26 +10,26 @@ export interface Spec {
20
10
  operations: Record<string, Operation[]>;
21
11
  makeImport: MakeImportFn;
22
12
  }
23
- export interface OperationInput {
24
- in: string;
25
- schema: string;
13
+ /** One way a client sends an operation: the key it is exposed under and the input it takes. */
14
+ export interface OperationRoute {
15
+ endpoint: string;
16
+ /** The name the `inputs` module exports the input schema under. */
17
+ schemaName: string;
18
+ /** The input schema as zod source. */
19
+ zod: string;
20
+ /** The names of the shared schemas `zod` references. */
21
+ references: ReadonlySet<string>;
22
+ input: OperationInput;
26
23
  }
27
24
  export interface Operation {
28
25
  method: string;
29
26
  path: string;
30
27
  operationId: string;
31
- schemas: Record<string, string>;
32
- inputs: Record<string, OperationInput>;
33
- outgoingContentType?: string;
28
+ /** The preferred input first, then its variants. */
29
+ inputs: OperationRoute[];
34
30
  }
35
- export declare function toEndpoint(groupName: string, specOperation: TunedOperationObject, operation: Operation): {
31
+ export declare function toEndpoint(groupName: string, specOperation: TunedOperationObject, operation: Operation, modelName: ModelNamer, refs: References): {
36
32
  schemas: string[];
37
33
  };
38
- export declare function toHttpOutput(status: string, response: TunedResponseObject): string;
39
- export declare function inputToPath(operation: TunedOperationObject, inputs: Record<string, OperationInput>): {
40
- inputHeaders: string[];
41
- inputQuery: string[];
42
- inputBody: string[];
43
- inputParams: string[];
44
- };
34
+ export declare function toHttpOutput(status: string, response: TunedResponseObject, modelName: ModelNamer, refs: References): string;
45
35
  //# sourceMappingURL=sdk.d.ts.map