@redocly/client-generator 0.8.1 → 0.9.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 (170) hide show
  1. package/README.md +2 -0
  2. package/eject-assets/generators/cli/docs.ts +1 -1
  3. package/eject-assets/generators/cli/engine-source.ts +1 -1
  4. package/eject-assets/generators/cli/index.ts +12 -3
  5. package/eject-assets/generators/cli/render.ts +21 -8
  6. package/eject-assets/generators/go/client.ts +1 -1
  7. package/eject-assets/generators/go/descriptor.ts +1 -1
  8. package/eject-assets/generators/go/index.ts +27 -11
  9. package/eject-assets/generators/go/models.ts +1 -1
  10. package/eject-assets/generators/go/naming.ts +1 -1
  11. package/eject-assets/generators/go/operations.ts +1 -1
  12. package/eject-assets/generators/go/pagination.ts +1 -1
  13. package/eject-assets/generators/go/types.ts +1 -1
  14. package/eject-assets/generators/java/client.ts +1 -1
  15. package/eject-assets/generators/java/descriptor.ts +1 -1
  16. package/eject-assets/generators/java/index.ts +15 -7
  17. package/eject-assets/generators/java/models.ts +1 -1
  18. package/eject-assets/generators/java/naming.ts +1 -1
  19. package/eject-assets/generators/java/operations.ts +1 -1
  20. package/eject-assets/generators/java/pagination.ts +1 -1
  21. package/eject-assets/generators/java/types.ts +1 -1
  22. package/eject-assets/generators/mock/faker.ts +1 -1
  23. package/eject-assets/generators/mock/index.ts +2 -2
  24. package/eject-assets/generators/mock/render.ts +1 -1
  25. package/eject-assets/generators/mock/sample.ts +1 -1
  26. package/eject-assets/generators/mock/values.ts +1 -1
  27. package/eject-assets/generators/php/client.ts +1 -1
  28. package/eject-assets/generators/php/descriptor.ts +1 -1
  29. package/eject-assets/generators/php/index.ts +31 -13
  30. package/eject-assets/generators/php/models.ts +1 -1
  31. package/eject-assets/generators/php/naming.ts +1 -1
  32. package/eject-assets/generators/php/operations.ts +1 -1
  33. package/eject-assets/generators/php/pagination.ts +1 -1
  34. package/eject-assets/generators/php/types.ts +1 -1
  35. package/eject-assets/generators/python/client.ts +1 -1
  36. package/eject-assets/generators/python/descriptor.ts +1 -1
  37. package/eject-assets/generators/python/index.ts +36 -17
  38. package/eject-assets/generators/python/models.ts +1 -1
  39. package/eject-assets/generators/python/naming.ts +1 -1
  40. package/eject-assets/generators/python/operations.ts +1 -1
  41. package/eject-assets/generators/python/pagination.ts +1 -1
  42. package/eject-assets/generators/python/types.ts +1 -1
  43. package/eject-assets/generators/swr/index.ts +4 -3
  44. package/eject-assets/generators/swr/render.ts +4 -3
  45. package/eject-assets/generators/tanstack-query/index.ts +4 -3
  46. package/eject-assets/generators/tanstack-query/render.ts +4 -2
  47. package/eject-assets/generators/transformers/index.ts +2 -2
  48. package/eject-assets/generators/transformers/render.ts +1 -1
  49. package/eject-assets/generators/typescript/banner.ts +1 -1
  50. package/eject-assets/generators/typescript/client.ts +1 -1
  51. package/eject-assets/generators/typescript/descriptor.ts +1 -1
  52. package/eject-assets/generators/typescript/index.ts +2 -2
  53. package/eject-assets/generators/typescript/inline-runtime.ts +1 -1
  54. package/eject-assets/generators/typescript/operation-signature.ts +1 -1
  55. package/eject-assets/generators/typescript/operation-types.ts +1 -1
  56. package/eject-assets/generators/typescript/operations.ts +1 -1
  57. package/eject-assets/generators/typescript/response-headers.ts +1 -1
  58. package/eject-assets/generators/typescript/type-guards.ts +1 -1
  59. package/eject-assets/generators/typescript/types.ts +1 -1
  60. package/eject-assets/generators/zod/index.ts +2 -2
  61. package/eject-assets/generators/zod/schemas.ts +1 -1
  62. package/eject-assets/skills/go-generator/SKILL.md +19 -0
  63. package/eject-assets/skills/php-generator/SKILL.md +16 -1
  64. package/eject-assets/skills/python-generator/SKILL.md +15 -0
  65. package/lib/contracts/typescript.d.ts +2 -1
  66. package/lib/contracts/typescript.d.ts.map +1 -1
  67. package/lib/contracts/typescript.js +15 -8
  68. package/lib/contracts/typescript.js.map +1 -1
  69. package/lib/findings.d.ts +9 -0
  70. package/lib/findings.d.ts.map +1 -0
  71. package/lib/findings.js +43 -0
  72. package/lib/findings.js.map +1 -0
  73. package/lib/generators/cli/index.d.ts.map +1 -1
  74. package/lib/generators/cli/index.js +2 -1
  75. package/lib/generators/cli/index.js.map +1 -1
  76. package/lib/generators/cli/render.d.ts +2 -1
  77. package/lib/generators/cli/render.d.ts.map +1 -1
  78. package/lib/generators/cli/render.js +15 -7
  79. package/lib/generators/cli/render.js.map +1 -1
  80. package/lib/generators/go/index.d.ts.map +1 -1
  81. package/lib/generators/go/index.js +18 -11
  82. package/lib/generators/go/index.js.map +1 -1
  83. package/lib/generators/java/index.d.ts.map +1 -1
  84. package/lib/generators/java/index.js +6 -3
  85. package/lib/generators/java/index.js.map +1 -1
  86. package/lib/generators/meta.d.ts.map +1 -1
  87. package/lib/generators/meta.js +18 -5
  88. package/lib/generators/meta.js.map +1 -1
  89. package/lib/generators/options.d.ts.map +1 -1
  90. package/lib/generators/options.js +7 -2
  91. package/lib/generators/options.js.map +1 -1
  92. package/lib/generators/php/index.d.ts.map +1 -1
  93. package/lib/generators/php/index.js +22 -13
  94. package/lib/generators/php/index.js.map +1 -1
  95. package/lib/generators/python/index.d.ts.map +1 -1
  96. package/lib/generators/python/index.js +27 -17
  97. package/lib/generators/python/index.js.map +1 -1
  98. package/lib/generators/resolve.d.ts.map +1 -1
  99. package/lib/generators/resolve.js +7 -2
  100. package/lib/generators/resolve.js.map +1 -1
  101. package/lib/generators/swr/index.d.ts.map +1 -1
  102. package/lib/generators/swr/index.js +2 -1
  103. package/lib/generators/swr/index.js.map +1 -1
  104. package/lib/generators/swr/render.d.ts +2 -1
  105. package/lib/generators/swr/render.d.ts.map +1 -1
  106. package/lib/generators/swr/render.js +1 -1
  107. package/lib/generators/swr/render.js.map +1 -1
  108. package/lib/generators/tanstack-query/index.d.ts.map +1 -1
  109. package/lib/generators/tanstack-query/index.js +2 -1
  110. package/lib/generators/tanstack-query/index.js.map +1 -1
  111. package/lib/generators/tanstack-query/render.d.ts +2 -1
  112. package/lib/generators/tanstack-query/render.d.ts.map +1 -1
  113. package/lib/generators/tanstack-query/render.js +1 -1
  114. package/lib/generators/tanstack-query/render.js.map +1 -1
  115. package/lib/generators/types.d.ts +7 -0
  116. package/lib/generators/types.d.ts.map +1 -1
  117. package/lib/generators/typescript/telemetry/telemetry.js +3 -1
  118. package/lib/generators/typescript/telemetry/telemetry.js.map +1 -1
  119. package/lib/index.d.ts +1 -1
  120. package/lib/index.d.ts.map +1 -1
  121. package/lib/index.js.map +1 -1
  122. package/lib/intermediate-representation/build.d.ts.map +1 -1
  123. package/lib/intermediate-representation/build.js +18 -5
  124. package/lib/intermediate-representation/build.js.map +1 -1
  125. package/lib/intermediate-representation/sanitize-identifiers.d.ts.map +1 -1
  126. package/lib/intermediate-representation/sanitize-identifiers.js +4 -4
  127. package/lib/intermediate-representation/sanitize-identifiers.js.map +1 -1
  128. package/lib/pagination.d.ts.map +1 -1
  129. package/lib/pagination.js +7 -2
  130. package/lib/pagination.js.map +1 -1
  131. package/lib/pipeline.d.ts.map +1 -1
  132. package/lib/pipeline.js +23 -5
  133. package/lib/pipeline.js.map +1 -1
  134. package/lib/reserved-names.d.ts.map +1 -1
  135. package/lib/reserved-names.js +6 -0
  136. package/lib/reserved-names.js.map +1 -1
  137. package/lib/runtime-sources/go-telemetry.d.ts +3 -0
  138. package/lib/runtime-sources/go-telemetry.d.ts.map +1 -0
  139. package/lib/runtime-sources/go-telemetry.js +10 -0
  140. package/lib/runtime-sources/go-telemetry.js.map +1 -0
  141. package/lib/runtime-sources/go.d.ts +1 -1
  142. package/lib/runtime-sources/go.d.ts.map +1 -1
  143. package/lib/runtime-sources/go.js +1 -1
  144. package/lib/runtime-sources/go.js.map +1 -1
  145. package/lib/runtime-sources/php-telemetry.d.ts +3 -0
  146. package/lib/runtime-sources/php-telemetry.d.ts.map +1 -0
  147. package/lib/runtime-sources/php-telemetry.js +4 -0
  148. package/lib/runtime-sources/php-telemetry.js.map +1 -0
  149. package/lib/runtime-sources/php.d.ts +1 -1
  150. package/lib/runtime-sources/php.d.ts.map +1 -1
  151. package/lib/runtime-sources/php.js +1 -1
  152. package/lib/runtime-sources/php.js.map +1 -1
  153. package/lib/runtime-sources/python-telemetry.d.ts +2 -0
  154. package/lib/runtime-sources/python-telemetry.d.ts.map +1 -0
  155. package/lib/runtime-sources/python-telemetry.js +3 -0
  156. package/lib/runtime-sources/python-telemetry.js.map +1 -0
  157. package/lib/runtime-sources/python.d.ts +1 -1
  158. package/lib/runtime-sources/python.js +1 -1
  159. package/lib/runtime-sources/python.js.map +1 -1
  160. package/lib/runtime-sources/telemetry.d.ts +1 -1
  161. package/lib/runtime-sources/telemetry.d.ts.map +1 -1
  162. package/lib/runtime-sources/telemetry.js +1 -1
  163. package/lib/runtime-sources/telemetry.js.map +1 -1
  164. package/lib/runtime-sources.d.ts +3 -0
  165. package/lib/runtime-sources.d.ts.map +1 -1
  166. package/lib/runtime-sources.js +3 -0
  167. package/lib/runtime-sources.js.map +1 -1
  168. package/lib/types.d.ts +22 -0
  169. package/lib/types.d.ts.map +1 -1
  170. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -10,6 +10,8 @@
10
10
 
11
11
  import {
12
12
  type CodeSample,
13
+ GENERATOR_VERSION,
14
+ type GeneratedFile,
13
15
  type Generator,
14
16
  type GeneratorOptionsSchema,
15
17
  identifierFor,
@@ -19,7 +21,10 @@ import {
19
21
  securityRequirements,
20
22
  } from '@redocly/client-generator';
21
23
  import { PythonPrinter } from '@redocly/client-generator/printers/python';
22
- import { PYTHON_RUNTIME_SOURCES } from '@redocly/client-generator/runtime-sources';
24
+ import {
25
+ PYTHON_RUNTIME_SOURCES,
26
+ PYTHON_TELEMETRY_SOURCE,
27
+ } from '@redocly/client-generator/runtime-sources';
23
28
 
24
29
  import { writeClientClass, writePythonServers } from './client.ts';
25
30
  import { paginationSpec, pythonLiteral } from './descriptor.ts';
@@ -29,7 +34,7 @@ import {
29
34
  renderPythonModels,
30
35
  type PythonModels,
31
36
  } from './models.ts';
32
- import { operationIdents, PY } from './naming.ts';
37
+ import { naming, operationIdents, PY } from './naming.ts';
33
38
 
34
39
  export { renderPythonModels, type PythonModels } from './models.ts';
35
40
  export { pythonType } from './types.ts';
@@ -165,20 +170,34 @@ export const pythonGenerator: Generator = ({
165
170
  writeClientClass(printer, model, errorMode, true, paginationSpecs, serverUrl, dateType);
166
171
 
167
172
  const entry = { path: pythonModulePath(output.path), content: printer.toString() };
168
- if (emit.runtime !== 'module') return [entry];
169
- // The runtime modules, verbatim except the package-relative imports: the flat
170
- // sibling layout has no package, so `from ._x` becomes the sibling `from _x`.
173
+ const files: GeneratedFile[] = [entry];
171
174
  const header = banner.map((line) => `# ${line}`).join('\n');
172
- const dir = pythonModulePath(output.path).replace(/[^\\/]+$/, '');
173
- const runtimeFiles = Object.entries(PYTHON_RUNTIME_SOURCES).map(([name, source]) => ({
174
- path: `${dir}${name}`,
175
- content: `${header}\n\n${source
176
- .split('\n')
177
- .map((line) => (line.startsWith('from ._') ? line.replace('from ._', 'from _') : line))
178
- .join('\n')
179
- .trim()}\n`,
180
- }));
181
- return [entry, ...runtimeFiles];
175
+ if (emit.runtime === 'module') {
176
+ // The runtime modules, verbatim except the package-relative imports: the flat
177
+ // sibling layout has no package, so `from ._x` becomes the sibling `from _x`.
178
+ const dir = entry.path.replace(/[^\\/]+$/, '');
179
+ for (const [name, source] of Object.entries(PYTHON_RUNTIME_SOURCES)) {
180
+ files.push({
181
+ path: `${dir}${name}`,
182
+ content: `${header}\n\n${source
183
+ .split('\n')
184
+ .map((line) => (line.startsWith('from ._') ? line.replace('from ._', 'from _') : line))
185
+ .join('\n')
186
+ .trim()}\n`,
187
+ });
188
+ }
189
+ }
190
+ if (emit.telemetry === 'on') {
191
+ const telemetrySource = PYTHON_TELEMETRY_SOURCE.replace(
192
+ 'GENERATOR_VERSION = "dev"',
193
+ () => `GENERATOR_VERSION = ${naming.string(GENERATOR_VERSION)}`
194
+ );
195
+ files.push({
196
+ path: entry.path.replace(/\.py$/, '_telemetry.py'),
197
+ content: `${header}\n\n${telemetrySource.trim()}\n`,
198
+ });
199
+ }
200
+ return files;
182
201
  };
183
202
 
184
203
  /** One idiomatic Python call per operation — feeds `x-codeSamples` for docs. */
@@ -247,5 +266,5 @@ export default {
247
266
  "argsStyle": "inputs follow the target language's own idiom",
248
267
  "importExt": "the generated file has no relative imports"
249
268
  },
250
- requiresGenerator: '^0.8.1',
269
+ requiresGenerator: '^0.9.0',
251
270
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "python" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "python" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator python --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "swr" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "swr" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator swr --update`.
@@ -19,8 +19,9 @@ import { renderSwrModule } from './render.ts';
19
19
  * multi-file barrel at the output anchor either way. Emits nothing when there are
20
20
  * no operations.
21
21
  */
22
- export const swrGenerator: Generator = ({ model, output, banner, emit }) => {
22
+ export const swrGenerator: Generator = ({ model, output, banner, emit, reportFinding }) => {
23
23
  const content = renderSwrModule(model, {
24
+ reportFinding,
24
25
  sdkModule: `./${output.stem}.${emit.importExt ?? 'js'}`,
25
26
  });
26
27
  if (content === '') return [];
@@ -33,5 +34,5 @@ export default {
33
34
  run: swrGenerator,
34
35
  requires: ["typescript"],
35
36
  errorModes: ["throw"],
36
- requiresGenerator: '^0.8.1',
37
+ requiresGenerator: '^0.9.0',
37
38
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "swr" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "swr" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator swr --update`.
@@ -12,7 +12,7 @@
12
12
  // `swr`/`swr/mutation` are the consumer's peer; the sdk stays dependency-free.
13
13
  // Source-text templates throughout.
14
14
 
15
- import type { ApiModel, OperationModel } from '@redocly/client-generator';
15
+ import type { ApiModel, GeneratorInput, OperationModel } from '@redocly/client-generator';
16
16
  import {
17
17
  hasInputs,
18
18
  isQuery,
@@ -24,6 +24,7 @@ import {
24
24
  import { pascalCase } from '@redocly/client-generator/printers/typescript';
25
25
 
26
26
  export type SwrOptions = {
27
+ reportFinding: GeneratorInput['reportFinding'];
27
28
  /** Import specifier for the sdk entry the operation functions/types live in. */
28
29
  sdkModule: string;
29
30
  /** How the sdk function takes its inputs — must match the generated client. */
@@ -31,7 +32,7 @@ export type SwrOptions = {
31
32
 
32
33
  /** Render the full SWR module source. `''` when there are no wrappable operations. */
33
34
  export function renderSwrModule(model: ApiModel, opts: SwrOptions): string {
34
- const ops = wrappableOperations(model, 'swr');
35
+ const ops = wrappableOperations(model, 'swr', opts.reportFinding);
35
36
  if (ops.length === 0) return '';
36
37
  const hasQuery = ops.some(isQuery);
37
38
  const hasMutation = ops.some((op) => !isQuery(op));
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "tanstack-query" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "tanstack-query" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator tanstack-query --update`.
@@ -23,8 +23,9 @@ import { renderTanstackModule } from './render.ts';
23
23
  * no operations.
24
24
  */
25
25
  export function tanstackQueryGenerator(framework: 'react' | 'vue' | 'svelte' | 'solid'): Generator {
26
- return ({ model, output, banner, emit, pagination }) => {
26
+ return ({ model, output, banner, emit, pagination, reportFinding }) => {
27
27
  const content = renderTanstackModule(model, {
28
+ reportFinding,
28
29
  argsStyle: emit.argsStyle ?? 'grouped',
29
30
  sdkModule: `./${output.stem}.${emit.importExt ?? 'js'}`,
30
31
  framework,
@@ -44,5 +45,5 @@ export default {
44
45
  run: tanstackQueryGenerator('react'),
45
46
  requires: ["typescript"],
46
47
  errorModes: ["throw"],
47
- requiresGenerator: '^0.8.1',
48
+ requiresGenerator: '^0.9.0',
48
49
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "tanstack-query" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "tanstack-query" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator tanstack-query --update`.
@@ -20,6 +20,7 @@
20
20
 
21
21
  import {
22
22
  type ApiModel,
23
+ type GeneratorInput,
23
24
  type ModelPagination,
24
25
  type OperationModel,
25
26
  type PaginationSpec,
@@ -38,6 +39,7 @@ import {
38
39
  } from '@redocly/client-generator/printers/typescript';
39
40
 
40
41
  export type TanstackOptions = {
42
+ reportFinding: GeneratorInput['reportFinding'];
41
43
  /** Import specifier for the sdk entry the `client` instance and types live in. */
42
44
  sdkModule: string;
43
45
  /** TanStack adapter to import the option helpers from (`@tanstack/${framework}-query`). */
@@ -53,7 +55,7 @@ export type TanstackOptions = {
53
55
 
54
56
  /** Render the full TanStack Query module source. `''` when there are no wrappable operations. */
55
57
  export function renderTanstackModule(model: ApiModel, opts: TanstackOptions): string {
56
- const ops = wrappableOperations(model, 'tanstack-query');
58
+ const ops = wrappableOperations(model, 'tanstack-query', opts.reportFinding);
57
59
  if (ops.length === 0) return '';
58
60
  const pagination = opts.pagination ?? new Map();
59
61
  const source = [
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "transformers" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "transformers" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator transformers --update`.
@@ -42,5 +42,5 @@ export default {
42
42
  run: transformersGenerator,
43
43
  requires: ["typescript"],
44
44
  dateTypes: ["Date"],
45
- requiresGenerator: '^0.8.1',
45
+ requiresGenerator: '^0.9.0',
46
46
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "transformers" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "transformers" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator transformers --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -123,5 +123,5 @@ export default {
123
123
  run: typescriptGenerator,
124
124
  sample: typescriptSample,
125
125
  docs: typescriptDocs,
126
- requiresGenerator: '^0.8.1',
126
+ requiresGenerator: '^0.9.0',
127
127
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "typescript" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "typescript" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator typescript --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "zod" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "zod" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator zod --update`.
@@ -28,5 +28,5 @@ export const zodGenerator: Generator = ({ model, output, banner }) => {
28
28
  export default {
29
29
  name: 'zod',
30
30
  run: zodGenerator,
31
- requiresGenerator: '^0.8.1',
31
+ requiresGenerator: '^0.9.0',
32
32
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.8.1 — the built-in "zod" generator.
1
+ // Ejected from @redocly/client-generator@0.9.0 — the built-in "zod" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator zod --update`.
@@ -90,6 +90,25 @@ runtime. Go ≥ 1.21, standard library only — zero dependencies.
90
90
  and embedded at prepare time.
91
91
  Under `--runtime module` it is written as a same-package `runtime.go` beside the client,
92
92
  whose import block then lists only the packages its own body uses.
93
+ - **`OnSettled` sees every sent call once.** `send()` calls each `Middleware.OnSettled` after
94
+ the last attempt with a `SettledCall`: the operation id, the final response (body unread)
95
+ or the error, the attempt count, and the duration from the first attempt to the end of the
96
+ `OnResponse` hooks on the final response. A timeout is a `*TimeoutError`; a cancelled or
97
+ expired caller context is an error that wraps `context.Canceled` or
98
+ `context.DeadlineExceeded`. A call whose body cannot be encoded or read does not reach it,
99
+ and a request that `http.NewRequestWithContext` cannot build settles with 1 attempt.
100
+ - **Telemetry is opt-in at generation time.** With `client.telemetry: on` the generator also
101
+ writes `telemetry.go` (from `telemetry/telemetry.go` in this folder, embedded at prepare
102
+ time) beside the client, in both runtime modes, with the client's package clause and the
103
+ generator version baked in. The client file does not change. The application registers
104
+ `NewUsageTelemetry(UsageTelemetryOptions{...}).Middleware()` and calls `Flush(ctx)` before
105
+ it exits, because Go has no exit hook. An SDK owner calls `Register()` instead, in an `init`
106
+ function, which adds the middleware to `registeredMiddleware` of the runtime, so `send` runs
107
+ it for every client; `FlushUsageTelemetry(ctx)` then flushes each registered instance. The
108
+ runtime declares `registeredMiddleware` in both modes, so the client file stays the same.
109
+ Its exported names are reserved for every SDK, and
110
+ every unexported name starts with `usageTelemetry`, because the file shares the package
111
+ with the model types and the runtime.
93
112
  - Authored ONLY with the neutral toolkit — the dogfooding guard fails otherwise.
94
113
 
95
114
  - **It documents itself.** With `client.docs` (or `--docs`), the `docs` hook writes
@@ -91,7 +91,7 @@ extension — zero Composer dependencies. The namespace derives from the API tit
91
91
  runtime sorts it out (`multipartBody` / `binaryBody`): a stream `resource` is uploaded
92
92
  by curl in chunks (`CURLOPT_UPLOAD` + `CURLOPT_INFILE`, the method kept by
93
93
  `CURLOPT_CUSTOMREQUEST`), never read into a string, in exactly one attempt, whatever
94
- the retry policy says (the default is three attempts for any method), because a
94
+ the retry policy says, because a
95
95
  consumed stream cannot be replayed. `CURLOPT_INFILESIZE` is set only when the stream is
96
96
  seekable AND `fstat` returns an array (the bytes left from the current position);
97
97
  `php://input`, pipes, and wrappers without `stream_stat` go chunked. A `string` body of
@@ -108,6 +108,21 @@ extension — zero Composer dependencies. The namespace derives from the API tit
108
108
  at prepare time. `curl_close` is never called (deprecated since PHP 8.5, no-op since 8.0).
109
109
  Under `--runtime module` it is written as a `runtime.php` the client `require_once`s,
110
110
  with its namespace rewritten to the client's so one namespace spans both files.
111
+ - **`onSettled` sees every sent call once.** `send()` calls each `Config->onSettled` callable,
112
+ then each `Config::$registeredOnSettled` callable, after the retry loop with `operationId`, `status` (0 without a response), `timedOut`,
113
+ `attempts`, and `durationMs`, before it throws or returns. Every hook runs. The first hook
114
+ error is thrown for a successful call; on a failed call, the original error wins and the
115
+ hook error goes to `error_log`. SSE streams open outside `send()`, so they reach no hook.
116
+ - **Telemetry is opt-in at generation time.** With `client.telemetry: on` the generator also
117
+ writes `<client>.telemetry.php` (from `telemetry/telemetry.php` in this folder, embedded at prepare
118
+ time) beside the client, in both runtime modes, with the client's namespace and the
119
+ generator version baked in. The client file does not change. The application requires it
120
+ and passes `new UsageTelemetry(...)` in `Config->onSettled`. An SDK owner calls `register()`
121
+ instead, which adds the instance to `Config::$registeredOnSettled`, so every client counts its
122
+ calls; `UsageTelemetry::flushRegistered()` flushes each registered instance. PHP has no timers: a call that
123
+ finds its window elapsed sends it first, and a shutdown function sends the open window.
124
+ Constants live on the class, because OPcache preloading drops file-level constants. The
125
+ class name is reserved for every SDK, because the file shares the namespace with the models.
111
126
  - Authored ONLY with the neutral toolkit — the dogfooding guard fails otherwise.
112
127
 
113
128
  ## Migrating from a service-based SDK
@@ -109,6 +109,21 @@ One self-contained `<stem>.py`: typed dataclass models, a sync `Client` and an a
109
109
  time — generator code never builds runtime logic from templates.
110
110
  Under `--runtime module` the same sources are written as sibling `_*.py` files instead
111
111
  (package-relative imports become sibling imports; the client star-imports each module).
112
+ - **`on_settled` sees every sent call once.** Both `send()` and `send_async()` call each
113
+ middleware's `on_settled(context, call)` after the last attempt, where `call` holds the final
114
+ `response` or the `error`, `attempts`, and `duration_ms` (from the first attempt to the end
115
+ of the `on_response` hooks). A timeout is `ApiTimeoutError`; a cancelled async call is
116
+ `asyncio.CancelledError`. A call that fails in `on_request` does not reach it. Every hook
117
+ runs; on a successful call the first hook exception fails the call, and on a failed call
118
+ the original error wins. SSE streams open outside `send()`, so they reach no middleware.
119
+ - **Telemetry is opt-in at generation time.** With `client.telemetry: on` the generator also
120
+ writes `<module>_telemetry.py` (from `telemetry/telemetry.py` in this folder, embedded at
121
+ prepare time) beside the client, in both runtime modes, with the generator version baked
122
+ in. The client file does not change. The module imports nothing from the client; the
123
+ application passes `telemetry(sdk_name=..., sdk_version=..., client=...)` in the client's
124
+ `middleware`, and the open window is sent at interpreter exit.
125
+ A timeout of the caller, such as `asyncio.wait_for`, cancels the task like any cancel, so
126
+ it counts as `aborted`; only the client's own `timeout` counts as `timeout`.
112
127
  - Authored ONLY with the neutral toolkit (`Printer`, naming, schema, pagination helpers) —
113
128
  the dogfooding guard fails otherwise.
114
129
 
@@ -1,3 +1,4 @@
1
+ import type { GeneratorInput } from '../generators/types.js';
1
2
  import type { ApiModel, OperationModel } from '../intermediate-representation/model.js';
2
3
  /**
3
4
  * The operations a wrapper generator can wrap, with skips reported to the user under
@@ -10,7 +11,7 @@ import type { ApiModel, OperationModel } from '../intermediate-representation/mo
10
11
  * so the import would resolve to the schema (a wrong/broken type). The sdk function still
11
12
  * works; renaming the schema or the operation restores the wrapper.
12
13
  */
13
- export declare function wrappableOperations(model: ApiModel, label: string): OperationModel[];
14
+ export declare function wrappableOperations(model: ApiModel, label: string, reportFinding: GeneratorInput['reportFinding']): OperationModel[];
14
15
  /** Query operations are the safe, cacheable methods. Everything else is a mutation. */
15
16
  export declare function isQuery(op: OperationModel): boolean;
16
17
  /** Whether the operation has any inputs — i.e. a `<Op>Variables` type exists in the sdk. */
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../src/contracts/typescript.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAExF;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB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AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAExD;AAED;;;;;;mFAMmF;AACnF,wBAAgB,WAAW,CAAC,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAQzF;AAED;wFACwF;AACxF,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,cAAc,EAAE,EACrB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,OAAO,GAChB,MAAM,CAMR;AAKD,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,kBAAkB,GACxB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC"}
@@ -3,7 +3,6 @@
3
3
  // edge (`swr`, `tanstack-query`, and `cli` require `typescript`): duplicating these
4
4
  // answers in each wrapper would put the SDK's calling convention in several places,
5
5
  // which is exactly the drift this module exists to prevent.
6
- import { logger } from '@redocly/openapi-core';
7
6
  import { operationSignature } from '../generators/typescript/operation-signature.js';
8
7
  /**
9
8
  * The operations a wrapper generator can wrap, with skips reported to the user under
@@ -16,20 +15,28 @@ import { operationSignature } from '../generators/typescript/operation-signature
16
15
  * so the import would resolve to the schema (a wrong/broken type). The sdk function still
17
16
  * works; renaming the schema or the operation restores the wrapper.
18
17
  */
19
- export function wrappableOperations(model, label) {
18
+ export function wrappableOperations(model, label, reportFinding) {
20
19
  const all = model.services.flatMap((s) => s.operations);
21
20
  const sse = all.filter((op) => op.sse !== undefined);
22
21
  if (sse.length > 0) {
23
- logger.warn(`generate-client: ${label} skipped ${sse.length} server-sent-events operation(s) — iterate the sdk's exported async generators directly: ${sse
24
- .map((op) => op.name)
25
- .join(', ')}.\n`);
22
+ reportFinding({
23
+ kind: 'operation-skipped',
24
+ message: `${label} skipped ${sse.length} server-sent-events operation(s) — iterate the sdk's exported async generators directly: ${sse
25
+ .map((op) => op.name)
26
+ .join(', ')}.`,
27
+ operations: sse.map((operation) => operation.specName ?? operation.name),
28
+ });
26
29
  }
27
30
  const schemaNames = new Set(model.schemas.map((s) => s.name));
28
31
  const clashing = all.filter((op) => op.sse === undefined && collides(op, schemaNames));
29
32
  if (clashing.length > 0) {
30
- logger.warn(`generate-client: ${label} skipped ${clashing.length} operation(s) whose variables type name collides with a schema — rename the schema or the operation: ${clashing
31
- .map((op) => op.name)
32
- .join(', ')}.\n`);
33
+ reportFinding({
34
+ kind: 'operation-skipped',
35
+ message: `${label} skipped ${clashing.length} operation(s) whose variables type name collides with a schema — rename the schema or the operation: ${clashing
36
+ .map((op) => op.name)
37
+ .join(', ')}.`,
38
+ operations: clashing.map((operation) => operation.specName ?? operation.name),
39
+ });
33
40
  }
34
41
  return all.filter((op) => op.sse === undefined && !collides(op, schemaNames));
35
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../src/contracts/typescript.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,iFAAiF;AACjF,oFAAoF;AACpF,oFAAoF;AACpF,4DAA4D;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AAGrF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAe,EAAE,KAAa;IAChE,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACxD,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC;IACrD,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnB,MAAM,CAAC,IAAI,CACT,oBAAoB,KAAK,YAAY,GAAG,CAAC,MAAM,4FAA4F,GAA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B,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClF,OAAO,YAAY,UAAU,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC;AACvE,CAAC;AAED,mFAAmF;AACnF,4EAA4E;AAC5E,qFAAqF;AACrF,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAEnB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import type { GenerateClientFinding } from './types.js';
3
+ export declare const findingListener: AsyncLocalStorage<((finding: GenerateClientFinding) => void) | undefined>;
4
+ /**
5
+ * Logs the finding as a warning and passes it to the `onFinding` listener of the run.
6
+ * Throws on a value without the documented shape: a custom generator can pass anything.
7
+ */
8
+ export declare function reportFinding(finding: GenerateClientFinding): void;
9
+ //# sourceMappingURL=findings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findings.d.ts","sourceRoot":"","sources":["../src/findings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,KAAK,EACV,qBAAqB,EAGtB,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,eAAe,2EAA8D,CAAC;AAc3F;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAUlE"}
@@ -0,0 +1,43 @@
1
+ import { isPlainObject, logger } from '@redocly/openapi-core';
2
+ import { AsyncLocalStorage } from 'node:async_hooks';
3
+ import { inspect } from 'node:util';
4
+ // The listener of the `generateClient` call that is running. The warnings come from deep in the
5
+ // pipeline, so the listener travels with the async context instead of through every call.
6
+ export const findingListener = new AsyncLocalStorage();
7
+ // A record, so the type checker reports a kind that is missing here.
8
+ const FINDING_KINDS = {
9
+ 'operation-skipped': true,
10
+ 'name-changed': true,
11
+ 'option-ignored': true,
12
+ 'generator-replaced': true,
13
+ 'description-ignored': true,
14
+ 'undocumented-header': true,
15
+ 'browser-unsupported': true,
16
+ 'command-shadowed': true,
17
+ };
18
+ /**
19
+ * Logs the finding as a warning and passes it to the `onFinding` listener of the run.
20
+ * Throws on a value without the documented shape: a custom generator can pass anything.
21
+ */
22
+ export function reportFinding(finding) {
23
+ if (!isFinding(finding)) {
24
+ throw new Error(`invalid finding ${inspect(finding)}: a finding is { kind, message, operations }, with a known kind and the operation IDs as strings.`);
25
+ }
26
+ logger.warn(`generate-client: ${finding.message}\n`);
27
+ // A custom generator can pass more keys, and the report holds only the documented ones.
28
+ const { kind, message, operations } = finding;
29
+ findingListener.getStore()?.({ kind, message, operations });
30
+ }
31
+ function isFinding(value) {
32
+ if (!isPlainObject(value)) {
33
+ return false;
34
+ }
35
+ const { kind, message, operations } = value;
36
+ if (typeof kind !== 'string' || !Object.hasOwn(FINDING_KINDS, kind)) {
37
+ return false;
38
+ }
39
+ return (typeof message === 'string' &&
40
+ Array.isArray(operations) &&
41
+ operations.every((operation) => typeof operation === 'string'));
42
+ }
43
+ //# sourceMappingURL=findings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findings.js","sourceRoot":"","sources":["../src/findings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,gGAAgG;AAChG,0FAA0F;AAC1F,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,iBAAiB,EAAsC,CAAC;AAE3F,qEAAqE;AACrE,MAAM,aAAa,GAA4C;I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AC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EAEd,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AAOnC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,SAmB1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,EAAE,SAQrB,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,aAAa,GAAG,UAAU,GAAG,SAAS,CAkBxF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/generators/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EAEd,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AAOnC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,SA4B1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,OAAO,EAAE,SAQrB,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,aAAa,GAAG,UAAU,GAAG,SAAS,CAkBxF"}