@ahoo-wang/wow-generator 9.2.0-rc.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 (116) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +177 -0
  3. package/README.zh-CN.md +149 -0
  4. package/dist/analysis/aggregates.d.cts +21 -0
  5. package/dist/analysis/aggregates.d.ts +21 -0
  6. package/dist/analysis/analyze.d.cts +18 -0
  7. package/dist/analysis/analyze.d.ts +18 -0
  8. package/dist/analysis/apiClients.d.cts +14 -0
  9. package/dist/analysis/apiClients.d.ts +14 -0
  10. package/dist/analysis/clientNames.d.cts +55 -0
  11. package/dist/analysis/clientNames.d.ts +55 -0
  12. package/dist/analysis/model.d.cts +212 -0
  13. package/dist/analysis/model.d.ts +212 -0
  14. package/dist/analysis/modelInfo.d.cts +23 -0
  15. package/dist/analysis/modelInfo.d.ts +23 -0
  16. package/dist/analysis/models.d.cts +17 -0
  17. package/dist/analysis/models.d.ts +17 -0
  18. package/dist/api/configuration.d.cts +30 -0
  19. package/dist/api/configuration.d.ts +30 -0
  20. package/dist/api/errors.d.cts +41 -0
  21. package/dist/api/errors.d.ts +41 -0
  22. package/dist/api/logger.d.cts +61 -0
  23. package/dist/api/logger.d.ts +61 -0
  24. package/dist/api/options.d.cts +47 -0
  25. package/dist/api/options.d.ts +47 -0
  26. package/dist/cli/program.d.cts +35 -0
  27. package/dist/cli/program.d.ts +35 -0
  28. package/dist/cli/runGenerate.d.cts +65 -0
  29. package/dist/cli/runGenerate.d.ts +65 -0
  30. package/dist/cli.cjs +3 -0
  31. package/dist/cli.cjs.map +1 -0
  32. package/dist/cli.d.cts +6 -0
  33. package/dist/cli.d.ts +6 -0
  34. package/dist/cli.js +98 -0
  35. package/dist/cli.js.map +1 -0
  36. package/dist/codeGenerator-DpDTDC4o.cjs +23 -0
  37. package/dist/codeGenerator-DpDTDC4o.cjs.map +1 -0
  38. package/dist/codeGenerator-kyY9eLML.js +2583 -0
  39. package/dist/codeGenerator-kyY9eLML.js.map +1 -0
  40. package/dist/emit/importRegistry.d.cts +50 -0
  41. package/dist/emit/importRegistry.d.ts +50 -0
  42. package/dist/emit/imports.d.cts +49 -0
  43. package/dist/emit/imports.d.ts +49 -0
  44. package/dist/emit/jsdoc.d.cts +38 -0
  45. package/dist/emit/jsdoc.d.ts +38 -0
  46. package/dist/emit/moduleBuilder.d.cts +80 -0
  47. package/dist/emit/moduleBuilder.d.ts +80 -0
  48. package/dist/emitters/apiClients.d.cts +10 -0
  49. package/dist/emitters/apiClients.d.ts +10 -0
  50. package/dist/emitters/commandClients.d.cts +14 -0
  51. package/dist/emitters/commandClients.d.ts +14 -0
  52. package/dist/emitters/decorators.d.cts +83 -0
  53. package/dist/emitters/decorators.d.ts +83 -0
  54. package/dist/emitters/emit.d.cts +15 -0
  55. package/dist/emitters/emit.d.ts +15 -0
  56. package/dist/emitters/indexFiles.d.cts +12 -0
  57. package/dist/emitters/indexFiles.d.ts +12 -0
  58. package/dist/emitters/models.d.cts +77 -0
  59. package/dist/emitters/models.d.ts +77 -0
  60. package/dist/emitters/queryClients.d.cts +11 -0
  61. package/dist/emitters/queryClients.d.ts +11 -0
  62. package/dist/emitters/target.d.cts +14 -0
  63. package/dist/emitters/target.d.ts +14 -0
  64. package/dist/finalize/finalize.d.cts +16 -0
  65. package/dist/finalize/finalize.d.ts +16 -0
  66. package/dist/finalize/typeOnlyImports.d.cts +13 -0
  67. package/dist/finalize/typeOnlyImports.d.ts +13 -0
  68. package/dist/finalize/verification.d.cts +14 -0
  69. package/dist/finalize/verification.d.ts +14 -0
  70. package/dist/index.cjs +1 -0
  71. package/dist/index.d.cts +8 -0
  72. package/dist/index.d.ts +8 -0
  73. package/dist/index.js +2 -0
  74. package/dist/input/configuration.d.cts +87 -0
  75. package/dist/input/configuration.d.ts +87 -0
  76. package/dist/input/parsers.d.cts +39 -0
  77. package/dist/input/parsers.d.ts +39 -0
  78. package/dist/input/resources.d.cts +36 -0
  79. package/dist/input/resources.d.ts +36 -0
  80. package/dist/naming/modelInfo.d.cts +10 -0
  81. package/dist/naming/modelInfo.d.ts +10 -0
  82. package/dist/naming/naming.d.cts +102 -0
  83. package/dist/naming/naming.d.ts +102 -0
  84. package/dist/naming/order.d.cts +2 -0
  85. package/dist/naming/order.d.ts +2 -0
  86. package/dist/naming/paths.d.cts +27 -0
  87. package/dist/naming/paths.d.ts +27 -0
  88. package/dist/openapi/components.d.cts +55 -0
  89. package/dist/openapi/components.d.ts +55 -0
  90. package/dist/openapi/document.d.cts +25 -0
  91. package/dist/openapi/document.d.ts +25 -0
  92. package/dist/openapi/operations.d.cts +78 -0
  93. package/dist/openapi/operations.d.ts +78 -0
  94. package/dist/openapi/references.d.cts +28 -0
  95. package/dist/openapi/references.d.ts +28 -0
  96. package/dist/openapi/responses.d.cts +44 -0
  97. package/dist/openapi/responses.d.ts +44 -0
  98. package/dist/openapi/schemas.d.cts +112 -0
  99. package/dist/openapi/schemas.d.ts +112 -0
  100. package/dist/output/outputStore.d.cts +92 -0
  101. package/dist/output/outputStore.d.ts +92 -0
  102. package/dist/pipeline/codeGenerator.d.cts +61 -0
  103. package/dist/pipeline/codeGenerator.d.ts +61 -0
  104. package/dist/pipeline/seams.d.cts +29 -0
  105. package/dist/pipeline/seams.d.ts +29 -0
  106. package/dist/types/typeResolver.d.cts +124 -0
  107. package/dist/types/typeResolver.d.ts +124 -0
  108. package/dist/version.d.cts +2 -0
  109. package/dist/version.d.ts +2 -0
  110. package/dist/wow/conventions.d.cts +154 -0
  111. package/dist/wow/conventions.d.ts +154 -0
  112. package/dist/wow/model.d.cts +116 -0
  113. package/dist/wow/model.d.ts +116 -0
  114. package/dist/wow/resolveWowModel.d.cts +21 -0
  115. package/dist/wow/resolveWowModel.d.ts +21 -0
  116. package/package.json +108 -0
@@ -0,0 +1,61 @@
1
+ import { GenerationResult, GeneratorOptions } from '../api/options.cjs';
2
+ /**
3
+ * Main code generator class that orchestrates the generation of TypeScript code from OpenAPI specifications.
4
+ * This class handles the entire code generation process, including parsing OpenAPI specs,
5
+ * resolving aggregates, generating models and clients, and formatting the output.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const generator = new CodeGenerator({
10
+ * inputPath: './openapi.yaml',
11
+ * outputDir: './generated',
12
+ * tsConfigFilePath: './tsconfig.json',
13
+ * logger: new ConsoleLogger({ level: 'verbose' }),
14
+ * });
15
+ * const { files } = await generator.generate();
16
+ * ```
17
+ */
18
+ export declare class CodeGenerator {
19
+ private readonly options;
20
+ private readonly project;
21
+ private readonly logger;
22
+ private readonly signal?;
23
+ /** The output of the last run, whose files the next run starts without. */
24
+ private output?;
25
+ /**
26
+ * Creates a new CodeGenerator instance with the specified options.
27
+ *
28
+ * @param options - Input, output, configuration and logging of the run.
29
+ * @throws GeneratorError of kind `configuration` if the TypeScript
30
+ * configuration cannot be read.
31
+ */
32
+ constructor(options: GeneratorOptions);
33
+ /**
34
+ * Generates TypeScript code from the OpenAPI specification:
35
+ *
36
+ * 1. reads the generator configuration, then the document, which it checks
37
+ * for dangling references;
38
+ * 2. reads the document's Wow model: bounded contexts and aggregates;
39
+ * 3. decides what the document generates (`analysis/`);
40
+ * 4. writes every module once (`emitters/`), then the index files;
41
+ * 5. formats, organises and types the imports, and checks the output
42
+ * compiles (`finalize/`);
43
+ * 6. writes the files, removes the stale ones of the last run and records
44
+ * the manifest (`output/`).
45
+ *
46
+ * Every warning is logged as it arises, and counted.
47
+ *
48
+ * @returns The files written, the configuration read and how many warnings
49
+ * the run logged.
50
+ * @throws GeneratorError when the document or the configuration cannot be
51
+ * read or understood, the document describes code that cannot compile, or
52
+ * the output cannot be written. A configuration is only optional at
53
+ * `DEFAULT_CONFIG_PATH`; one the caller named has to exist.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * await generator.generate();
58
+ * ```
59
+ */
60
+ generate(): Promise<GenerationResult>;
61
+ }
@@ -0,0 +1,61 @@
1
+ import { GenerationResult, GeneratorOptions } from '../api/options.js';
2
+ /**
3
+ * Main code generator class that orchestrates the generation of TypeScript code from OpenAPI specifications.
4
+ * This class handles the entire code generation process, including parsing OpenAPI specs,
5
+ * resolving aggregates, generating models and clients, and formatting the output.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const generator = new CodeGenerator({
10
+ * inputPath: './openapi.yaml',
11
+ * outputDir: './generated',
12
+ * tsConfigFilePath: './tsconfig.json',
13
+ * logger: new ConsoleLogger({ level: 'verbose' }),
14
+ * });
15
+ * const { files } = await generator.generate();
16
+ * ```
17
+ */
18
+ export declare class CodeGenerator {
19
+ private readonly options;
20
+ private readonly project;
21
+ private readonly logger;
22
+ private readonly signal?;
23
+ /** The output of the last run, whose files the next run starts without. */
24
+ private output?;
25
+ /**
26
+ * Creates a new CodeGenerator instance with the specified options.
27
+ *
28
+ * @param options - Input, output, configuration and logging of the run.
29
+ * @throws GeneratorError of kind `configuration` if the TypeScript
30
+ * configuration cannot be read.
31
+ */
32
+ constructor(options: GeneratorOptions);
33
+ /**
34
+ * Generates TypeScript code from the OpenAPI specification:
35
+ *
36
+ * 1. reads the generator configuration, then the document, which it checks
37
+ * for dangling references;
38
+ * 2. reads the document's Wow model: bounded contexts and aggregates;
39
+ * 3. decides what the document generates (`analysis/`);
40
+ * 4. writes every module once (`emitters/`), then the index files;
41
+ * 5. formats, organises and types the imports, and checks the output
42
+ * compiles (`finalize/`);
43
+ * 6. writes the files, removes the stale ones of the last run and records
44
+ * the manifest (`output/`).
45
+ *
46
+ * Every warning is logged as it arises, and counted.
47
+ *
48
+ * @returns The files written, the configuration read and how many warnings
49
+ * the run logged.
50
+ * @throws GeneratorError when the document or the configuration cannot be
51
+ * read or understood, the document describes code that cannot compile, or
52
+ * the output cannot be written. A configuration is only optional at
53
+ * `DEFAULT_CONFIG_PATH`; one the caller named has to exist.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * await generator.generate();
58
+ * ```
59
+ */
60
+ generate(): Promise<GenerationResult>;
61
+ }
@@ -0,0 +1,29 @@
1
+ import { Project } from 'ts-morph';
2
+ import { GeneratorOptions } from '../api/options.cjs';
3
+ /**
4
+ * Test seam: an option under this key hands a generator the ts-morph project
5
+ * to write into, such as an in-memory one, instead of one it reads from
6
+ * `tsConfigFilePath`. A symbol the package does not export, so it is no part
7
+ * of the public options. It lives apart from `CodeGenerator`, whose
8
+ * declaration therefore names neither it nor ts-morph, whose major version it
9
+ * would follow.
10
+ */
11
+ export declare const PROJECT_SEAM: unique symbol;
12
+ /**
13
+ * The CLI's seam: an option under this key stops a run when it aborts, as
14
+ * Ctrl-C does. A run stops at its next step; once it writes, it finishes
15
+ * writing its files and then stops without removing anything or recording
16
+ * the files in the manifest.
17
+ */
18
+ export declare const SIGNAL_SEAM: unique symbol;
19
+ /**
20
+ * What the package itself may hand a generator beyond its public options,
21
+ * each under a symbol it does not export.
22
+ */
23
+ export interface Seams {
24
+ readonly [PROJECT_SEAM]?: Project;
25
+ readonly [SIGNAL_SEAM]?: AbortSignal;
26
+ }
27
+ /** The options, with the {@link Seams} the package may add. */
28
+ export interface SeamOptions extends GeneratorOptions, Seams {
29
+ }
@@ -0,0 +1,29 @@
1
+ import { Project } from 'ts-morph';
2
+ import { GeneratorOptions } from '../api/options.js';
3
+ /**
4
+ * Test seam: an option under this key hands a generator the ts-morph project
5
+ * to write into, such as an in-memory one, instead of one it reads from
6
+ * `tsConfigFilePath`. A symbol the package does not export, so it is no part
7
+ * of the public options. It lives apart from `CodeGenerator`, whose
8
+ * declaration therefore names neither it nor ts-morph, whose major version it
9
+ * would follow.
10
+ */
11
+ export declare const PROJECT_SEAM: unique symbol;
12
+ /**
13
+ * The CLI's seam: an option under this key stops a run when it aborts, as
14
+ * Ctrl-C does. A run stops at its next step; once it writes, it finishes
15
+ * writing its files and then stops without removing anything or recording
16
+ * the files in the manifest.
17
+ */
18
+ export declare const SIGNAL_SEAM: unique symbol;
19
+ /**
20
+ * What the package itself may hand a generator beyond its public options,
21
+ * each under a symbol it does not export.
22
+ */
23
+ export interface Seams {
24
+ readonly [PROJECT_SEAM]?: Project;
25
+ readonly [SIGNAL_SEAM]?: AbortSignal;
26
+ }
27
+ /** The options, with the {@link Seams} the package may add. */
28
+ export interface SeamOptions extends GeneratorOptions, Seams {
29
+ }
@@ -0,0 +1,124 @@
1
+ import { Components, Reference, Schema } from '@ahoo-wang/fetcher-openapi';
2
+ import { ModelInfo } from '../naming/modelInfo.cjs';
3
+ import { MapSchema } from '../openapi/schemas.cjs';
4
+ /**
5
+ * Schema → TypeScript type expression, as pure functions.
6
+ *
7
+ * Every entry point takes a schema and a {@link TypeScope} - where the type
8
+ * is written - and returns a {@link ResolvedType}: the type's text, and the
9
+ * imports the module needs for it. Nothing is written; the caller applies the
10
+ * imports to its module (`ImportRegistry.apply`) before it resolves the next
11
+ * type, so a later reference sees the names and aliases an earlier one took.
12
+ */
13
+ /** An import a resolved type needs: a name, and the alias it goes by. */
14
+ export interface ImportRequest {
15
+ readonly moduleSpecifier: string;
16
+ readonly name: string;
17
+ readonly alias?: string;
18
+ }
19
+ /** A type expression, and the imports it needs. */
20
+ export interface ResolvedType {
21
+ readonly text: string;
22
+ readonly imports: readonly ImportRequest[];
23
+ }
24
+ /** The imports a module already holds, as the resolver reads them. */
25
+ export interface ImportLookup {
26
+ entries(): readonly ImportRequest[];
27
+ }
28
+ /**
29
+ * What stays the same for every type of one document: its components, how a
30
+ * component names its model, and the model names declared at each path.
31
+ */
32
+ export interface TypeContext {
33
+ readonly components?: Components;
34
+ /** The model a reference names. */
35
+ modelOf(reference: Reference): ModelInfo;
36
+ /** The models declared at a path, with their `EnumText` companions. */
37
+ namesAt(path: string): readonly string[];
38
+ }
39
+ /**
40
+ * How a document's component keys name models: `resolveModelInfo` and
41
+ * `resolveReferenceModelInfo` of `analysis/modelInfo.ts`.
42
+ */
43
+ export interface ModelNaming {
44
+ ofKey(key: string): ModelInfo;
45
+ ofReference(reference: Reference, components?: Components): ModelInfo;
46
+ }
47
+ /**
48
+ * Builds the context of a document. The model names of each path are read
49
+ * once, on first use, rather than from every component for every reference.
50
+ */
51
+ export declare function createTypeContext(components: Components | undefined, naming: ModelNaming): TypeContext;
52
+ /** Where a type is written. */
53
+ export interface TypeScope {
54
+ readonly context: TypeContext;
55
+ /**
56
+ * The declaration the type belongs to. An import never takes its name.
57
+ * With a `path`, it is a model: the models of that path are declared beside
58
+ * it, so a reference to one needs no import, and an import takes none of
59
+ * their names. Without, every referenced model is imported.
60
+ */
61
+ readonly owner: {
62
+ readonly name: string;
63
+ readonly path?: string;
64
+ };
65
+ /** The specifier the module imports a model by. */
66
+ specifierOf(model: ModelInfo): string;
67
+ /** The imports the module holds. */
68
+ readonly imports: ImportLookup;
69
+ }
70
+ /**
71
+ * Global names generated code relies on. A model imported under one of these
72
+ * names would shadow the global, so the import is aliased instead: a model
73
+ * named `Response` must not turn `Promise<Response>` into a promise of the
74
+ * model.
75
+ */
76
+ export declare const GLOBAL_TYPE_NAMES: readonly string[];
77
+ /**
78
+ * Chooses the intersection representation over an interface with an index
79
+ * signature.
80
+ *
81
+ * An interface may only carry a named property whose type is assignable to
82
+ * its index signature (TS2411). Every generated property is required, so
83
+ * only a clash that can be PROVEN off the schemas moves one - see
84
+ * {@link clashesWithIndexSignature}. Anything undecided keeps the interface,
85
+ * which is the only form that can reference itself through an index
86
+ * signature: an alias reaching itself through `Record` is circular (TS2456),
87
+ * which is what a dictionary of its own type would generate.
88
+ *
89
+ * @param schema - The object schema to represent
90
+ * @param components - The components a reference resolves against
91
+ * @returns True when the schema needs the intersection form
92
+ */
93
+ export declare function requiresAdditionalPropertiesIntersection(schema: Schema, components?: Components): boolean;
94
+ /**
95
+ * Renders a JSON value as a TypeScript literal type: a string in single
96
+ * quotes, escaped as ts-morph's printer escapes it, an array as a tuple, an
97
+ * object as an object type that no array matches.
98
+ *
99
+ * @param value - The value from the document
100
+ * @returns The literal type
101
+ */
102
+ export declare function resolveLiteral(value: unknown): string;
103
+ /**
104
+ * The type a schema generates.
105
+ *
106
+ * @param schema - The schema, or a reference to a component
107
+ * @param scope - Where the type is written
108
+ * @returns The type expression and the imports it needs
109
+ */
110
+ export declare function resolveType(schema: Schema | Reference, scope: TypeScope): ResolvedType;
111
+ /**
112
+ * The index signature an object schema's additional properties generate, as
113
+ * `[key: string]: T`, or `''` when it admits none beyond the ones it names.
114
+ */
115
+ export declare function resolveAdditionalProperties(schema: Schema, scope: TypeScope): ResolvedType;
116
+ /** The type of an object schema's additional properties; `any` when open. */
117
+ export declare function resolveAdditionalPropertyType(schema: Schema, scope: TypeScope): ResolvedType;
118
+ /**
119
+ * The type of a property an object schema requires without declaring it: its
120
+ * additional-property type, `never` when it admits none, else any JSON value.
121
+ */
122
+ export declare function resolveRequiredAdditionalPropertyType(schema: Schema, scope: TypeScope): ResolvedType;
123
+ /** The value type of a map schema; `any` when its values are open. */
124
+ export declare function resolveMapValueType(schema: MapSchema, scope: TypeScope): ResolvedType;
@@ -0,0 +1,124 @@
1
+ import { Components, Reference, Schema } from '@ahoo-wang/fetcher-openapi';
2
+ import { ModelInfo } from '../naming/modelInfo.js';
3
+ import { MapSchema } from '../openapi/schemas.js';
4
+ /**
5
+ * Schema → TypeScript type expression, as pure functions.
6
+ *
7
+ * Every entry point takes a schema and a {@link TypeScope} - where the type
8
+ * is written - and returns a {@link ResolvedType}: the type's text, and the
9
+ * imports the module needs for it. Nothing is written; the caller applies the
10
+ * imports to its module (`ImportRegistry.apply`) before it resolves the next
11
+ * type, so a later reference sees the names and aliases an earlier one took.
12
+ */
13
+ /** An import a resolved type needs: a name, and the alias it goes by. */
14
+ export interface ImportRequest {
15
+ readonly moduleSpecifier: string;
16
+ readonly name: string;
17
+ readonly alias?: string;
18
+ }
19
+ /** A type expression, and the imports it needs. */
20
+ export interface ResolvedType {
21
+ readonly text: string;
22
+ readonly imports: readonly ImportRequest[];
23
+ }
24
+ /** The imports a module already holds, as the resolver reads them. */
25
+ export interface ImportLookup {
26
+ entries(): readonly ImportRequest[];
27
+ }
28
+ /**
29
+ * What stays the same for every type of one document: its components, how a
30
+ * component names its model, and the model names declared at each path.
31
+ */
32
+ export interface TypeContext {
33
+ readonly components?: Components;
34
+ /** The model a reference names. */
35
+ modelOf(reference: Reference): ModelInfo;
36
+ /** The models declared at a path, with their `EnumText` companions. */
37
+ namesAt(path: string): readonly string[];
38
+ }
39
+ /**
40
+ * How a document's component keys name models: `resolveModelInfo` and
41
+ * `resolveReferenceModelInfo` of `analysis/modelInfo.ts`.
42
+ */
43
+ export interface ModelNaming {
44
+ ofKey(key: string): ModelInfo;
45
+ ofReference(reference: Reference, components?: Components): ModelInfo;
46
+ }
47
+ /**
48
+ * Builds the context of a document. The model names of each path are read
49
+ * once, on first use, rather than from every component for every reference.
50
+ */
51
+ export declare function createTypeContext(components: Components | undefined, naming: ModelNaming): TypeContext;
52
+ /** Where a type is written. */
53
+ export interface TypeScope {
54
+ readonly context: TypeContext;
55
+ /**
56
+ * The declaration the type belongs to. An import never takes its name.
57
+ * With a `path`, it is a model: the models of that path are declared beside
58
+ * it, so a reference to one needs no import, and an import takes none of
59
+ * their names. Without, every referenced model is imported.
60
+ */
61
+ readonly owner: {
62
+ readonly name: string;
63
+ readonly path?: string;
64
+ };
65
+ /** The specifier the module imports a model by. */
66
+ specifierOf(model: ModelInfo): string;
67
+ /** The imports the module holds. */
68
+ readonly imports: ImportLookup;
69
+ }
70
+ /**
71
+ * Global names generated code relies on. A model imported under one of these
72
+ * names would shadow the global, so the import is aliased instead: a model
73
+ * named `Response` must not turn `Promise<Response>` into a promise of the
74
+ * model.
75
+ */
76
+ export declare const GLOBAL_TYPE_NAMES: readonly string[];
77
+ /**
78
+ * Chooses the intersection representation over an interface with an index
79
+ * signature.
80
+ *
81
+ * An interface may only carry a named property whose type is assignable to
82
+ * its index signature (TS2411). Every generated property is required, so
83
+ * only a clash that can be PROVEN off the schemas moves one - see
84
+ * {@link clashesWithIndexSignature}. Anything undecided keeps the interface,
85
+ * which is the only form that can reference itself through an index
86
+ * signature: an alias reaching itself through `Record` is circular (TS2456),
87
+ * which is what a dictionary of its own type would generate.
88
+ *
89
+ * @param schema - The object schema to represent
90
+ * @param components - The components a reference resolves against
91
+ * @returns True when the schema needs the intersection form
92
+ */
93
+ export declare function requiresAdditionalPropertiesIntersection(schema: Schema, components?: Components): boolean;
94
+ /**
95
+ * Renders a JSON value as a TypeScript literal type: a string in single
96
+ * quotes, escaped as ts-morph's printer escapes it, an array as a tuple, an
97
+ * object as an object type that no array matches.
98
+ *
99
+ * @param value - The value from the document
100
+ * @returns The literal type
101
+ */
102
+ export declare function resolveLiteral(value: unknown): string;
103
+ /**
104
+ * The type a schema generates.
105
+ *
106
+ * @param schema - The schema, or a reference to a component
107
+ * @param scope - Where the type is written
108
+ * @returns The type expression and the imports it needs
109
+ */
110
+ export declare function resolveType(schema: Schema | Reference, scope: TypeScope): ResolvedType;
111
+ /**
112
+ * The index signature an object schema's additional properties generate, as
113
+ * `[key: string]: T`, or `''` when it admits none beyond the ones it names.
114
+ */
115
+ export declare function resolveAdditionalProperties(schema: Schema, scope: TypeScope): ResolvedType;
116
+ /** The type of an object schema's additional properties; `any` when open. */
117
+ export declare function resolveAdditionalPropertyType(schema: Schema, scope: TypeScope): ResolvedType;
118
+ /**
119
+ * The type of a property an object schema requires without declaring it: its
120
+ * additional-property type, `never` when it admits none, else any JSON value.
121
+ */
122
+ export declare function resolveRequiredAdditionalPropertyType(schema: Schema, scope: TypeScope): ResolvedType;
123
+ /** The value type of a map schema; `any` when its values are open. */
124
+ export declare function resolveMapValueType(schema: MapSchema, scope: TypeScope): ResolvedType;
@@ -0,0 +1,2 @@
1
+ /** The version of this package, as its package.json named it at build time. */
2
+ export declare const VERSION: string;
@@ -0,0 +1,2 @@
1
+ /** The version of this package, as its package.json named it at build time. */
2
+ export declare const VERSION: string;
@@ -0,0 +1,154 @@
1
+ import { OpenAPI, Tag } from '@ahoo-wang/fetcher-openapi';
2
+ import { AggregateDefinition, TagAliasAggregate } from './model.cjs';
3
+ /** The oldest Wow server whose OpenAPI metadata the generator reads fully. */
4
+ export declare const MINIMUM_WOW_VERSION = "8.10";
5
+ /** The `info` extension naming the bounded context the document serves. */
6
+ export declare const CONTEXT_ALIAS_EXTENSION = "x-wow-context-alias";
7
+ /** The bounded context a document names, if it is a Wow service's. */
8
+ export declare function contextAliasOf(openAPI: OpenAPI): string | undefined;
9
+ /**
10
+ * Reads an aggregate off a tag named `<contextAlias>.<aggregateName>`.
11
+ *
12
+ * @param tagName - The tag name
13
+ * @returns `[contextAlias, aggregateName]`, or null when the tag names no aggregate
14
+ */
15
+ export declare function isAliasAggregate(tagName: string): [string, string] | null;
16
+ /**
17
+ * The aggregate a tag names, or null when it names none.
18
+ *
19
+ * @param tag - The tag
20
+ */
21
+ export declare function tagToAggregate(tag: Tag): TagAliasAggregate | null;
22
+ /**
23
+ * The command an operation sends, read off its id
24
+ * `<contextAlias>.<aggregateName>.<command>`.
25
+ *
26
+ * @param operationId - The operation id
27
+ * @returns The command name, or null when the id has another shape
28
+ */
29
+ export declare function operationIdToCommandName(operationId?: string): string | null;
30
+ /** The operation that sends any command; it belongs to no aggregate. */
31
+ export declare const SEND_COMMAND_OPERATION_ID = "wow.command.send";
32
+ /** The response every command operation answers with. */
33
+ export declare const COMMAND_OK_RESPONSE_REF = "#/components/responses/wow.CommandOk";
34
+ /** The operation id suffix of the operation that loads an aggregate's state. */
35
+ export declare const STATE_OPERATION_SUFFIX = ".snapshot_state.single";
36
+ /** The operation id suffix of the operation that lists an aggregate's events. */
37
+ export declare const EVENTS_OPERATION_SUFFIX = ".event.list_query";
38
+ /** The operation id suffix of the operation that counts snapshots by a condition. */
39
+ export declare const FIELDS_OPERATION_SUFFIX = ".snapshot.count";
40
+ /** The request body extension naming an aggregate's query fields (Wow 8.11.1+). */
41
+ export declare const QUERY_FIELDS_EXTENSION = "x-wow-query-fields";
42
+ /**
43
+ * The route segment of an aggregate, read off one of its snapshot routes:
44
+ * `/tenant/{tenantId}/owner/{ownerId}/sales-order/snapshot/count` →
45
+ * `sales-order`. It differs from the aggregate name when the aggregate sets
46
+ * a resource name (`@AggregateRoute(resourceName = "sales-order")`).
47
+ */
48
+ export declare const SNAPSHOT_ROUTE: RegExp;
49
+ /**
50
+ * The suffixes of the types Wow derives from an aggregate's state; the
51
+ * wow-client generics stand for them, so they generate no model.
52
+ */
53
+ export declare const AGGREGATED_SCHEMA_SUFFIXES: readonly string[];
54
+ /**
55
+ * The names of the types Wow derives from an aggregate's state model.
56
+ *
57
+ * @param stateName - The name of the state model
58
+ */
59
+ export declare function aggregatedTypeNames(stateName: string): string[];
60
+ /**
61
+ * Tells whether a schema is Wow's own, which wow-client already declares, so
62
+ * it generates no model: every `wow.` schema but the paged lists and operator
63
+ * maps of the query API, the aggregated query and event stream types, and
64
+ * the types derived from an aggregate's state.
65
+ *
66
+ * @param schemaKey - The schema's component key
67
+ * @param modelName - The name of the model the schema would generate, read
68
+ * only when the key alone does not decide
69
+ * @param aggregatedNames - The names of the types derived from the aggregates' states
70
+ */
71
+ export declare function isWowSchema(schemaKey: string, modelName: () => string, aggregatedNames: ReadonlySet<string>): boolean;
72
+ /** Import path for the WOW framework types */
73
+ export declare const IMPORT_WOW_PATH = "@ahoo-wang/wow-client";
74
+ /**
75
+ * Import path for the deprecated Condition query model, which
76
+ * `@ahoo-wang/wow-client` keeps on its `/legacy` subpath for Wow 8.10 servers.
77
+ */
78
+ export declare const IMPORT_WOW_LEGACY_PATH = "@ahoo-wang/wow-client/legacy";
79
+ /** The mapped type names that `IMPORT_WOW_LEGACY_PATH` exports. */
80
+ export declare const WOW_LEGACY_TYPES: ReadonlySet<string>;
81
+ /** Mapping of OpenAPI schema keys to WOW framework types */
82
+ export declare const WOW_TYPE_MAPPING: {
83
+ 'wow.command.CommandResult': string;
84
+ 'wow.command.CommandResultArray': string;
85
+ 'wow.MessageHeaderSqlType': string;
86
+ 'wow.api.BindingError': string;
87
+ 'wow.api.DefaultErrorInfo': string;
88
+ 'wow.api.RecoverableType': string;
89
+ 'wow.api.command.DefaultDeleteAggregate': string;
90
+ 'wow.api.command.DefaultRecoverAggregate': string;
91
+ 'wow.api.abac.DefaultApplyResourceTags': string;
92
+ 'wow.api.messaging.FunctionInfoData': string;
93
+ 'wow.api.messaging.FunctionKind': string;
94
+ 'wow.api.modeling.AggregateId': string;
95
+ 'wow.api.query.Condition': string;
96
+ 'wow.api.query.ConditionOptions': string;
97
+ 'wow.api.query.ListQuery': string;
98
+ 'wow.api.query.Operator': string;
99
+ 'wow.api.query.PagedQuery': string;
100
+ 'wow.api.query.Pagination': string;
101
+ 'wow.api.query.Projection': string;
102
+ 'wow.api.query.Sort': string;
103
+ 'wow.api.query.Sort.Direction': string;
104
+ 'wow.api.query.DynamicDocument': string;
105
+ 'wow.api.query.DynamicDocumentArray': string;
106
+ 'wow.command.CommandStage': string;
107
+ 'wow.command.SimpleWaitSignal': string;
108
+ 'wow.configuration.Aggregate': string;
109
+ 'wow.configuration.BoundedContext': string;
110
+ 'wow.configuration.WowMetadata': string;
111
+ 'wow.modeling.DomainEvent': string;
112
+ 'wow.openapi.BatchResult': string;
113
+ 'wow.messaging.CompensationTarget': string;
114
+ };
115
+ /**
116
+ * The wow-client type a schema maps to, and the module that exports it.
117
+ *
118
+ * @param schemaKey - The schema's component key
119
+ * @param properties - The schema's properties, if the caller has the schema:
120
+ * a ListQuery or PagedQuery that carries `filter` is the filter model's
121
+ * @returns The type, or undefined when the schema is not one of Wow's own
122
+ */
123
+ export declare function wowTypeOf(schemaKey: string, properties?: Record<string, unknown>): {
124
+ name: string;
125
+ path: string;
126
+ } | undefined;
127
+ /**
128
+ * Tags whose operations generate no API client: Wow's own endpoints and
129
+ * Spring's actuator. The tags of aggregates are left out as well; their
130
+ * operations go to the command and query clients.
131
+ */
132
+ export declare const IGNORED_API_CLIENT_TAGS: ReadonlySet<string>;
133
+ /**
134
+ * The resource-attribution path parameters Wow's CoSec interceptor fills,
135
+ * which generated clients therefore leave out.
136
+ */
137
+ export declare const RESOURCE_ATTRIBUTION_PATH_PARAMETERS: readonly string[];
138
+ /** The route prefix of a tenant's resources (wow-client `ResourceAttributionPathSpec.TENANT`). */
139
+ export declare const TENANT_PATH_PREFIX = "/tenant/{tenantId}";
140
+ /** The route prefix of an owner's resources (wow-client `ResourceAttributionPathSpec.OWNER`). */
141
+ export declare const OWNER_PATH_PREFIX = "/owner/{ownerId}";
142
+ /**
143
+ * The resource attribution a query client of an aggregate uses, as the
144
+ * `ResourceAttributionPathSpec` member it generates: the prefix most of the
145
+ * aggregate's command routes start with, owner on a tie, none when no route
146
+ * starts with either.
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * // commands at /tenant/{tenantId}/users, /tenant/{tenantId}/orders and /owner/{ownerId}/profile
151
+ * inferPathSpecType(aggregate); // 'ResourceAttributionPathSpec.TENANT'
152
+ * ```
153
+ */
154
+ export declare function inferPathSpecType(aggregateDefinition: Pick<AggregateDefinition, 'commands'>): string;