@ahoo-wang/wow-generator 10.0.0-alpha.3 → 10.0.0-alpha.4
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.
- package/README.md +99 -62
- package/README.zh-CN.md +85 -48
- package/dist/analysis/analyze.d.cts +5 -8
- package/dist/analysis/analyze.d.ts +5 -8
- package/dist/analysis/apiClients.d.cts +3 -4
- package/dist/analysis/apiClients.d.ts +3 -4
- package/dist/analysis/clientNames.d.cts +0 -20
- package/dist/analysis/clientNames.d.ts +0 -20
- package/dist/analysis/model.d.cts +2 -102
- package/dist/analysis/model.d.ts +2 -102
- package/dist/analysis/modelInfo.d.cts +12 -3
- package/dist/analysis/modelInfo.d.ts +12 -3
- package/dist/analysis/models.d.cts +3 -11
- package/dist/analysis/models.d.ts +3 -11
- package/dist/api/configuration.d.cts +1 -5
- package/dist/api/configuration.d.ts +1 -5
- package/dist/cli/program.d.cts +0 -5
- package/dist/cli/program.d.ts +0 -5
- package/dist/cli.cjs +9 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +102 -3
- package/dist/cli.js.map +1 -1
- package/dist/{codeGenerator-CXBTLKZP.js → codeGenerator-CU1TGcUI.js} +716 -1327
- package/dist/codeGenerator-CU1TGcUI.js.map +1 -0
- package/dist/codeGenerator-DzI0zCgM.cjs +27 -0
- package/dist/codeGenerator-DzI0zCgM.cjs.map +1 -0
- package/dist/emit/imports.d.cts +0 -9
- package/dist/emit/imports.d.ts +0 -9
- package/dist/emitters/decorators.d.cts +3 -18
- package/dist/emitters/decorators.d.ts +3 -18
- package/dist/emitters/emit.d.cts +2 -3
- package/dist/emitters/emit.d.ts +2 -3
- package/dist/emitters/manifestClients.d.cts +3 -3
- package/dist/emitters/manifestClients.d.ts +3 -3
- package/dist/emitters/models.d.cts +1 -1
- package/dist/emitters/models.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/input/configuration.d.cts +2 -4
- package/dist/input/configuration.d.ts +2 -4
- package/dist/manifest/analyze.d.cts +18 -2
- package/dist/manifest/analyze.d.ts +18 -2
- package/dist/naming/modelInfo.d.cts +1 -2
- package/dist/naming/modelInfo.d.ts +1 -2
- package/dist/naming/paths.d.cts +0 -5
- package/dist/naming/paths.d.ts +0 -5
- package/dist/output/outputStore.d.cts +2 -6
- package/dist/output/outputStore.d.ts +2 -6
- package/dist/pipeline/codeGenerator.d.cts +13 -12
- package/dist/pipeline/codeGenerator.d.ts +13 -12
- package/package.json +8 -8
- package/dist/analysis/aggregates.d.cts +0 -21
- package/dist/analysis/aggregates.d.ts +0 -21
- package/dist/codeGenerator-Ba5Cz8XW.cjs +0 -31
- package/dist/codeGenerator-Ba5Cz8XW.cjs.map +0 -1
- package/dist/codeGenerator-CXBTLKZP.js.map +0 -1
- package/dist/emitters/commandClients.d.cts +0 -14
- package/dist/emitters/commandClients.d.ts +0 -14
- package/dist/emitters/queryClients.d.cts +0 -11
- package/dist/emitters/queryClients.d.ts +0 -11
- package/dist/fetcherGeneratorCli.cjs +0 -3
- package/dist/fetcherGeneratorCli.cjs.map +0 -1
- package/dist/fetcherGeneratorCli.d.cts +0 -8
- package/dist/fetcherGeneratorCli.d.ts +0 -8
- package/dist/fetcherGeneratorCli.js +0 -6
- package/dist/fetcherGeneratorCli.js.map +0 -1
- package/dist/program-BnfzUfUQ.cjs +0 -10
- package/dist/program-BnfzUfUQ.cjs.map +0 -1
- package/dist/program-CU0GCZqM.js +0 -103
- package/dist/program-CU0GCZqM.js.map +0 -1
- package/dist/wow/conventions.d.cts +0 -154
- package/dist/wow/conventions.d.ts +0 -154
- package/dist/wow/model.d.cts +0 -116
- package/dist/wow/model.d.ts +0 -116
- package/dist/wow/resolveWowModel.d.cts +0 -21
- package/dist/wow/resolveWowModel.d.ts +0 -21
package/dist/emit/imports.d.cts
CHANGED
|
@@ -38,12 +38,3 @@ export declare function modelModuleSpecifier(module: ModuleBuilder, outputDir: s
|
|
|
38
38
|
* @returns A specifier starting with `./` or `../` and ending with `.js`
|
|
39
39
|
*/
|
|
40
40
|
export declare function relativeModuleSpecifier(fromDirectory: string, targetFilePath: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Imports a bounded context's alias constant into a generated file.
|
|
43
|
-
*
|
|
44
|
-
* @param module - The importing module
|
|
45
|
-
* @param outputDir - The output directory
|
|
46
|
-
* @param contextAlias - The bounded context alias
|
|
47
|
-
* @param declarationName - The name of the alias constant
|
|
48
|
-
*/
|
|
49
|
-
export declare function addImportBoundedContext(module: ModuleBuilder, outputDir: string, contextAlias: string, declarationName: string): readonly NamedImport[];
|
package/dist/emit/imports.d.ts
CHANGED
|
@@ -38,12 +38,3 @@ export declare function modelModuleSpecifier(module: ModuleBuilder, outputDir: s
|
|
|
38
38
|
* @returns A specifier starting with `./` or `../` and ending with `.js`
|
|
39
39
|
*/
|
|
40
40
|
export declare function relativeModuleSpecifier(fromDirectory: string, targetFilePath: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Imports a bounded context's alias constant into a generated file.
|
|
43
|
-
*
|
|
44
|
-
* @param module - The importing module
|
|
45
|
-
* @param outputDir - The output directory
|
|
46
|
-
* @param contextAlias - The bounded context alias
|
|
47
|
-
* @param declarationName - The name of the alias constant
|
|
48
|
-
*/
|
|
49
|
-
export declare function addImportBoundedContext(module: ModuleBuilder, outputDir: string, contextAlias: string, declarationName: string): readonly NamedImport[];
|
|
@@ -20,13 +20,6 @@ export declare const STRING_RETURN_TYPE: MethodReturnType;
|
|
|
20
20
|
* Metadata configuration for stream result extraction.
|
|
21
21
|
*/
|
|
22
22
|
export declare const STREAM_RESULT_EXTRACTOR_METADATA = "{\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n}";
|
|
23
|
-
/**
|
|
24
|
-
* The endpoint options of a streaming command client, imported from
|
|
25
|
-
* `@ahoo-wang/wow-client`: `Accept: text/event-stream` and a result
|
|
26
|
-
* extractor that errors the stream with a `WowError` when the server sends an
|
|
27
|
-
* error event instead of passing the event on as a result.
|
|
28
|
-
*/
|
|
29
|
-
export declare const COMMAND_STREAM_ENDPOINT_METADATA = "COMMAND_STREAM_ENDPOINT";
|
|
30
23
|
export declare function addImportFetcher(module: ModuleBuilder): void;
|
|
31
24
|
/**
|
|
32
25
|
* Adds the necessary imports for decorator functionality to a module.
|
|
@@ -51,23 +44,15 @@ export declare function addImportDecorator(module: ModuleBuilder): void;
|
|
|
51
44
|
*/
|
|
52
45
|
export declare function createDecoratorClass(className: string, module: ModuleBuilder, apiArgs?: string[], typeParameters?: string[], extendsClass?: string): ClassDeclarationStructure;
|
|
53
46
|
/**
|
|
54
|
-
* Adds the ApiMetadataCapable interface implementation and constructor to a class declaration
|
|
55
|
-
*
|
|
56
|
-
* With defaults, the constructor merges what the caller passes over them, so
|
|
57
|
-
* `new CartCommandClient({ fetcher })` keeps the bounded context's base path:
|
|
47
|
+
* Adds the ApiMetadataCapable interface implementation and constructor to a class declaration:
|
|
58
48
|
*
|
|
59
49
|
* ```typescript
|
|
60
|
-
* readonly apiMetadata
|
|
61
|
-
* constructor(apiMetadata?: ApiMetadata) {
|
|
62
|
-
* this.apiMetadata = { ...DEFAULT_COMMAND_CLIENT_OPTIONS, ...apiMetadata };
|
|
63
|
-
* }
|
|
50
|
+
* constructor(public readonly apiMetadata?: ApiMetadata) {}
|
|
64
51
|
* ```
|
|
65
52
|
*
|
|
66
53
|
* @param classDeclaration - The class declaration to modify
|
|
67
|
-
* @param defaults - Object literal entries the constructor starts from, such
|
|
68
|
-
* as `...DEFAULT_COMMAND_CLIENT_OPTIONS` or `basePath: X`; none by default
|
|
69
54
|
*/
|
|
70
|
-
export declare function addApiMetadataCtor(classDeclaration: ClassDeclarationStructure
|
|
55
|
+
export declare function addApiMetadataCtor(classDeclaration: ClassDeclarationStructure): void;
|
|
71
56
|
/**
|
|
72
57
|
* The decorator of an HTTP method: its name, but `del` for `delete`, a
|
|
73
58
|
* reserved word.
|
|
@@ -20,13 +20,6 @@ export declare const STRING_RETURN_TYPE: MethodReturnType;
|
|
|
20
20
|
* Metadata configuration for stream result extraction.
|
|
21
21
|
*/
|
|
22
22
|
export declare const STREAM_RESULT_EXTRACTOR_METADATA = "{\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n}";
|
|
23
|
-
/**
|
|
24
|
-
* The endpoint options of a streaming command client, imported from
|
|
25
|
-
* `@ahoo-wang/wow-client`: `Accept: text/event-stream` and a result
|
|
26
|
-
* extractor that errors the stream with a `WowError` when the server sends an
|
|
27
|
-
* error event instead of passing the event on as a result.
|
|
28
|
-
*/
|
|
29
|
-
export declare const COMMAND_STREAM_ENDPOINT_METADATA = "COMMAND_STREAM_ENDPOINT";
|
|
30
23
|
export declare function addImportFetcher(module: ModuleBuilder): void;
|
|
31
24
|
/**
|
|
32
25
|
* Adds the necessary imports for decorator functionality to a module.
|
|
@@ -51,23 +44,15 @@ export declare function addImportDecorator(module: ModuleBuilder): void;
|
|
|
51
44
|
*/
|
|
52
45
|
export declare function createDecoratorClass(className: string, module: ModuleBuilder, apiArgs?: string[], typeParameters?: string[], extendsClass?: string): ClassDeclarationStructure;
|
|
53
46
|
/**
|
|
54
|
-
* Adds the ApiMetadataCapable interface implementation and constructor to a class declaration
|
|
55
|
-
*
|
|
56
|
-
* With defaults, the constructor merges what the caller passes over them, so
|
|
57
|
-
* `new CartCommandClient({ fetcher })` keeps the bounded context's base path:
|
|
47
|
+
* Adds the ApiMetadataCapable interface implementation and constructor to a class declaration:
|
|
58
48
|
*
|
|
59
49
|
* ```typescript
|
|
60
|
-
* readonly apiMetadata
|
|
61
|
-
* constructor(apiMetadata?: ApiMetadata) {
|
|
62
|
-
* this.apiMetadata = { ...DEFAULT_COMMAND_CLIENT_OPTIONS, ...apiMetadata };
|
|
63
|
-
* }
|
|
50
|
+
* constructor(public readonly apiMetadata?: ApiMetadata) {}
|
|
64
51
|
* ```
|
|
65
52
|
*
|
|
66
53
|
* @param classDeclaration - The class declaration to modify
|
|
67
|
-
* @param defaults - Object literal entries the constructor starts from, such
|
|
68
|
-
* as `...DEFAULT_COMMAND_CLIENT_OPTIONS` or `basePath: X`; none by default
|
|
69
54
|
*/
|
|
70
|
-
export declare function addApiMetadataCtor(classDeclaration: ClassDeclarationStructure
|
|
55
|
+
export declare function addApiMetadataCtor(classDeclaration: ClassDeclarationStructure): void;
|
|
71
56
|
/**
|
|
72
57
|
* The decorator of an HTTP method: its name, but `del` for `delete`, a
|
|
73
58
|
* reserved word.
|
package/dist/emitters/emit.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { GenerationModel } from '../analysis/model.cjs';
|
|
2
2
|
import { EmitTarget } from './target.cjs';
|
|
3
3
|
/**
|
|
4
|
-
* Describes every file of a generation to its module: the
|
|
5
|
-
*
|
|
6
|
-
* clients. Nothing reaches a source file until the modules are built.
|
|
4
|
+
* Describes every file of a generation to its module: the models, then the
|
|
5
|
+
* API clients. Nothing reaches a source file until the modules are built.
|
|
7
6
|
*
|
|
8
7
|
* The order is the one the files have always been written in, so the
|
|
9
8
|
* imports of a module, and the aliases a name clash gives them, come out
|
package/dist/emitters/emit.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { GenerationModel } from '../analysis/model.js';
|
|
2
2
|
import { EmitTarget } from './target.js';
|
|
3
3
|
/**
|
|
4
|
-
* Describes every file of a generation to its module: the
|
|
5
|
-
*
|
|
6
|
-
* clients. Nothing reaches a source file until the modules are built.
|
|
4
|
+
* Describes every file of a generation to its module: the models, then the
|
|
5
|
+
* API clients. Nothing reaches a source file until the modules are built.
|
|
7
6
|
*
|
|
8
7
|
* The order is the one the files have always been written in, so the
|
|
9
8
|
* imports of a module, and the aliases a name clash gives them, come out
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ModuleSet } from '../emit/moduleBuilder.cjs';
|
|
2
2
|
import { ManifestModel } from '../manifest/analyze.cjs';
|
|
3
|
-
/** The entry of the
|
|
4
|
-
export declare const
|
|
3
|
+
/** The entry of the client every generated module imports from. */
|
|
4
|
+
export declare const WOW_CLIENT = "@ahoo-wang/wow-client";
|
|
5
5
|
/**
|
|
6
6
|
* Describes every file a Manifest generates to its module (decision D74,
|
|
7
7
|
* roadmap 5a.3): the types of each bounded context, its error codes and wait
|
|
8
8
|
* helpers, and the aggregate, command and query clients of each aggregate,
|
|
9
|
-
* all on `@ahoo-wang/wow-client
|
|
9
|
+
* all on `@ahoo-wang/wow-client`.
|
|
10
10
|
*
|
|
11
11
|
* @param model - What the Manifest generates
|
|
12
12
|
* @param modules - The modules of the run
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ModuleSet } from '../emit/moduleBuilder.js';
|
|
2
2
|
import { ManifestModel } from '../manifest/analyze.js';
|
|
3
|
-
/** The entry of the
|
|
4
|
-
export declare const
|
|
3
|
+
/** The entry of the client every generated module imports from. */
|
|
4
|
+
export declare const WOW_CLIENT = "@ahoo-wang/wow-client";
|
|
5
5
|
/**
|
|
6
6
|
* Describes every file a Manifest generates to its module (decision D74,
|
|
7
7
|
* roadmap 5a.3): the types of each bounded context, its error codes and wait
|
|
8
8
|
* helpers, and the aggregate, command and query clients of each aggregate,
|
|
9
|
-
* all on `@ahoo-wang/wow-client
|
|
9
|
+
* all on `@ahoo-wang/wow-client`.
|
|
10
10
|
*
|
|
11
11
|
* @param model - What the Manifest generates
|
|
12
12
|
* @param modules - The modules of the run
|
|
@@ -30,7 +30,7 @@ export declare function emitModel(declaration: ModelDeclaration, target: EmitTar
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function uniqueEnumMemberNames(values: readonly string[]): Map<string, string>;
|
|
32
32
|
/** The model a {@link ModelEmitter} writes. */
|
|
33
|
-
export type ModelSource = Pick<ModelDeclaration, 'key' | 'info' | 'schema'
|
|
33
|
+
export type ModelSource = Pick<ModelDeclaration, 'key' | 'info' | 'schema'>;
|
|
34
34
|
/**
|
|
35
35
|
* Writes one model into a module: the declaration its schema calls for,
|
|
36
36
|
* with the model's doc comment.
|
|
@@ -30,7 +30,7 @@ export declare function emitModel(declaration: ModelDeclaration, target: EmitTar
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function uniqueEnumMemberNames(values: readonly string[]): Map<string, string>;
|
|
32
32
|
/** The model a {@link ModelEmitter} writes. */
|
|
33
|
-
export type ModelSource = Pick<ModelDeclaration, 'key' | 'info' | 'schema'
|
|
33
|
+
export type ModelSource = Pick<ModelDeclaration, 'key' | 'info' | 'schema'>;
|
|
34
34
|
/**
|
|
35
35
|
* Writes one model into a module: the declaration its schema calls for,
|
|
36
36
|
* with the model's doc comment.
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./codeGenerator-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./codeGenerator-DzI0zCgM.cjs");exports.CodeGenerator=e.t,exports.ConsoleLogger=e.i,exports.DEFAULT_CONFIG_PATH=e.c,exports.EXIT_CODES=e.o,exports.GeneratorError=e.s,exports.SilentLogger=e.a;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as CodeGenerator, i as ConsoleLogger, c as DEFAULT_CONFIG_PATH, o as EXIT_CODES, s as GeneratorError, a as SilentLogger } from "./codeGenerator-
|
|
1
|
+
export { t as CodeGenerator, i as ConsoleLogger, c as DEFAULT_CONFIG_PATH, o as EXIT_CODES, s as GeneratorError, a as SilentLogger } from "./codeGenerator-CU1TGcUI.js";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GeneratorConfiguration } from '../api/configuration.cjs';
|
|
2
2
|
import { Logger } from '../api/logger.cjs';
|
|
3
3
|
import { LoadResourceOptions } from './resources.cjs';
|
|
4
|
-
export declare const LEGACY_CONFIG_PATH = "./fetcher-generator.config.json";
|
|
5
4
|
/**
|
|
6
5
|
* A configuration, and the warnings reading it gave: keys the generator does
|
|
7
6
|
* not read, an empty file.
|
|
@@ -23,9 +22,8 @@ export interface ResolvedConfiguration extends LoadedConfiguration {
|
|
|
23
22
|
* Finds and loads the generator configuration.
|
|
24
23
|
*
|
|
25
24
|
* A path the caller names has to exist. Without one the generator reads
|
|
26
|
-
* {@link DEFAULT_CONFIG_PATH},
|
|
27
|
-
*
|
|
28
|
-
* the defaults when neither exists.
|
|
25
|
+
* {@link DEFAULT_CONFIG_PATH}, and generates with the defaults when it does
|
|
26
|
+
* not exist.
|
|
29
27
|
*
|
|
30
28
|
* @param configPath - The path or URL the caller named, if any
|
|
31
29
|
* @param logger - Receives what was read, at `debug`
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GeneratorConfiguration } from '../api/configuration.js';
|
|
2
2
|
import { Logger } from '../api/logger.js';
|
|
3
3
|
import { LoadResourceOptions } from './resources.js';
|
|
4
|
-
export declare const LEGACY_CONFIG_PATH = "./fetcher-generator.config.json";
|
|
5
4
|
/**
|
|
6
5
|
* A configuration, and the warnings reading it gave: keys the generator does
|
|
7
6
|
* not read, an empty file.
|
|
@@ -23,9 +22,8 @@ export interface ResolvedConfiguration extends LoadedConfiguration {
|
|
|
23
22
|
* Finds and loads the generator configuration.
|
|
24
23
|
*
|
|
25
24
|
* A path the caller names has to exist. Without one the generator reads
|
|
26
|
-
* {@link DEFAULT_CONFIG_PATH},
|
|
27
|
-
*
|
|
28
|
-
* the defaults when neither exists.
|
|
25
|
+
* {@link DEFAULT_CONFIG_PATH}, and generates with the defaults when it does
|
|
26
|
+
* not exist.
|
|
29
27
|
*
|
|
30
28
|
* @param configPath - The path or URL the caller named, if any
|
|
31
29
|
* @param logger - Receives what was read, at `debug`
|
|
@@ -22,6 +22,14 @@ export interface TypeModel {
|
|
|
22
22
|
/** The type names it refers to. */
|
|
23
23
|
readonly references: readonly string[];
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The numbers of a value read and written as their exact text, as
|
|
27
|
+
* `@ahoo-wang/wow-client`'s `TextNumbers` holds them: `true` at such a number,
|
|
28
|
+
* else its members' marks by name, `'*'` for every item or map value.
|
|
29
|
+
*/
|
|
30
|
+
export type TextNumbersModel = true | {
|
|
31
|
+
readonly [member: string]: TextNumbersModel;
|
|
32
|
+
};
|
|
25
33
|
/** A command of an aggregate client. */
|
|
26
34
|
export interface CommandModel {
|
|
27
35
|
readonly name: string;
|
|
@@ -44,6 +52,8 @@ export interface CommandModel {
|
|
|
44
52
|
readonly produces: readonly string[];
|
|
45
53
|
/** What the command's class says it is, as the Manifest describes it. */
|
|
46
54
|
readonly description?: string;
|
|
55
|
+
/** Its body has exact numbers, under `textNumbers.commands` of its aggregate. */
|
|
56
|
+
readonly bodyNumbers?: boolean;
|
|
47
57
|
}
|
|
48
58
|
/** A lifecycle command an aggregate lists. */
|
|
49
59
|
export interface LifecycleModel {
|
|
@@ -55,10 +65,10 @@ export interface LifecycleModel {
|
|
|
55
65
|
/**
|
|
56
66
|
* The body's type, or undefined for a command without one: the type
|
|
57
67
|
* generated from the Manifest's `$defs` entry of the command's name when it
|
|
58
|
-
* holds one (`bodyGenerated`), else `@ahoo-wang/wow-client
|
|
68
|
+
* holds one (`bodyGenerated`), else `@ahoo-wang/wow-client`'s.
|
|
59
69
|
*/
|
|
60
70
|
readonly bodyType?: string;
|
|
61
|
-
/** The body's type is generated from the Manifest, not `@ahoo-wang/wow-client
|
|
71
|
+
/** The body's type is generated from the Manifest, not `@ahoo-wang/wow-client`'s. */
|
|
62
72
|
readonly bodyGenerated?: boolean;
|
|
63
73
|
/** What the Manifest's schema of the body says the command does. */
|
|
64
74
|
readonly description?: string;
|
|
@@ -91,6 +101,12 @@ export interface AggregateModel {
|
|
|
91
101
|
}[];
|
|
92
102
|
readonly lifecycle: readonly LifecycleModel[];
|
|
93
103
|
readonly queryModels: readonly string[];
|
|
104
|
+
/** The exact numbers of its state, events (by wire name) and commands; none when it has none. */
|
|
105
|
+
readonly textNumbers?: {
|
|
106
|
+
readonly state?: TextNumbersModel;
|
|
107
|
+
readonly events?: Readonly<Record<string, TextNumbersModel>>;
|
|
108
|
+
readonly commands?: Readonly<Record<string, TextNumbersModel>>;
|
|
109
|
+
};
|
|
94
110
|
}
|
|
95
111
|
/** A bounded context and what its modules declare. */
|
|
96
112
|
export interface ContextModel {
|
|
@@ -22,6 +22,14 @@ export interface TypeModel {
|
|
|
22
22
|
/** The type names it refers to. */
|
|
23
23
|
readonly references: readonly string[];
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The numbers of a value read and written as their exact text, as
|
|
27
|
+
* `@ahoo-wang/wow-client`'s `TextNumbers` holds them: `true` at such a number,
|
|
28
|
+
* else its members' marks by name, `'*'` for every item or map value.
|
|
29
|
+
*/
|
|
30
|
+
export type TextNumbersModel = true | {
|
|
31
|
+
readonly [member: string]: TextNumbersModel;
|
|
32
|
+
};
|
|
25
33
|
/** A command of an aggregate client. */
|
|
26
34
|
export interface CommandModel {
|
|
27
35
|
readonly name: string;
|
|
@@ -44,6 +52,8 @@ export interface CommandModel {
|
|
|
44
52
|
readonly produces: readonly string[];
|
|
45
53
|
/** What the command's class says it is, as the Manifest describes it. */
|
|
46
54
|
readonly description?: string;
|
|
55
|
+
/** Its body has exact numbers, under `textNumbers.commands` of its aggregate. */
|
|
56
|
+
readonly bodyNumbers?: boolean;
|
|
47
57
|
}
|
|
48
58
|
/** A lifecycle command an aggregate lists. */
|
|
49
59
|
export interface LifecycleModel {
|
|
@@ -55,10 +65,10 @@ export interface LifecycleModel {
|
|
|
55
65
|
/**
|
|
56
66
|
* The body's type, or undefined for a command without one: the type
|
|
57
67
|
* generated from the Manifest's `$defs` entry of the command's name when it
|
|
58
|
-
* holds one (`bodyGenerated`), else `@ahoo-wang/wow-client
|
|
68
|
+
* holds one (`bodyGenerated`), else `@ahoo-wang/wow-client`'s.
|
|
59
69
|
*/
|
|
60
70
|
readonly bodyType?: string;
|
|
61
|
-
/** The body's type is generated from the Manifest, not `@ahoo-wang/wow-client
|
|
71
|
+
/** The body's type is generated from the Manifest, not `@ahoo-wang/wow-client`'s. */
|
|
62
72
|
readonly bodyGenerated?: boolean;
|
|
63
73
|
/** What the Manifest's schema of the body says the command does. */
|
|
64
74
|
readonly description?: string;
|
|
@@ -91,6 +101,12 @@ export interface AggregateModel {
|
|
|
91
101
|
}[];
|
|
92
102
|
readonly lifecycle: readonly LifecycleModel[];
|
|
93
103
|
readonly queryModels: readonly string[];
|
|
104
|
+
/** The exact numbers of its state, events (by wire name) and commands; none when it has none. */
|
|
105
|
+
readonly textNumbers?: {
|
|
106
|
+
readonly state?: TextNumbersModel;
|
|
107
|
+
readonly events?: Readonly<Record<string, TextNumbersModel>>;
|
|
108
|
+
readonly commands?: Readonly<Record<string, TextNumbersModel>>;
|
|
109
|
+
};
|
|
94
110
|
}
|
|
95
111
|
/** A bounded context and what its modules declare. */
|
|
96
112
|
export interface ContextModel {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Named } from '@ahoo-wang/wow-client';
|
|
2
1
|
/**
|
|
3
2
|
* Where a generated declaration lives: its name, and the directory under the
|
|
4
3
|
* output directory whose `types.ts` declares it, or the package it is
|
|
5
4
|
* imported from (a path starting with `@`).
|
|
6
5
|
*/
|
|
7
|
-
export interface ModelInfo
|
|
6
|
+
export interface ModelInfo {
|
|
8
7
|
name: string;
|
|
9
8
|
path: string;
|
|
10
9
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Named } from '@ahoo-wang/wow-client';
|
|
2
1
|
/**
|
|
3
2
|
* Where a generated declaration lives: its name, and the directory under the
|
|
4
3
|
* output directory whose `types.ts` declares it, or the package it is
|
|
5
4
|
* imported from (a path starting with `@`).
|
|
6
5
|
*/
|
|
7
|
-
export interface ModelInfo
|
|
6
|
+
export interface ModelInfo {
|
|
8
7
|
name: string;
|
|
9
8
|
path: string;
|
|
10
9
|
}
|
package/dist/naming/paths.d.cts
CHANGED
|
@@ -20,8 +20,3 @@ export declare const MODEL_FILE_NAME = "types.ts";
|
|
|
20
20
|
export declare function modelFilePath(model: {
|
|
21
21
|
readonly path: string;
|
|
22
22
|
}): string;
|
|
23
|
-
/**
|
|
24
|
-
* The file that declares a bounded context's alias constant, relative to the
|
|
25
|
-
* output directory.
|
|
26
|
-
*/
|
|
27
|
-
export declare function boundedContextFilePath(contextAlias: string): string;
|
package/dist/naming/paths.d.ts
CHANGED
|
@@ -20,8 +20,3 @@ export declare const MODEL_FILE_NAME = "types.ts";
|
|
|
20
20
|
export declare function modelFilePath(model: {
|
|
21
21
|
readonly path: string;
|
|
22
22
|
}): string;
|
|
23
|
-
/**
|
|
24
|
-
* The file that declares a bounded context's alias constant, relative to the
|
|
25
|
-
* output directory.
|
|
26
|
-
*/
|
|
27
|
-
export declare function boundedContextFilePath(contextAlias: string): string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Project, SourceFile } from 'ts-morph';
|
|
2
2
|
/** The manifest that records the files a generation wrote, and their hashes. */
|
|
3
3
|
export declare const GENERATION_MANIFEST = ".wow-generator.json";
|
|
4
|
-
export declare const LEGACY_GENERATION_MANIFEST = ".fetcher-generator.json";
|
|
5
4
|
/**
|
|
6
5
|
* The version of the manifest format this generator reads and writes. A
|
|
7
6
|
* change a reader of this version would misread bumps it; see section 3 of
|
|
@@ -30,17 +29,14 @@ export declare class OutputStore {
|
|
|
30
29
|
private readonly outputDir;
|
|
31
30
|
/** The files of the last run, with the hash each was written with. */
|
|
32
31
|
private readonly previous;
|
|
33
|
-
/** A pre-Wow manifest to delete once the new one is written. */
|
|
34
|
-
private readonly legacyManifest;
|
|
35
32
|
/** The files this run writes, by absolute path. */
|
|
36
33
|
private readonly written;
|
|
37
34
|
/** Files of the last run this run does not write and may remove. */
|
|
38
35
|
private readonly stale;
|
|
39
36
|
private constructor();
|
|
40
37
|
/**
|
|
41
|
-
* Reads the manifest of an output directory
|
|
42
|
-
*
|
|
43
|
-
* writes its files afresh.
|
|
38
|
+
* Reads the manifest of an output directory and takes the files it names
|
|
39
|
+
* out of the project: a run writes its files afresh.
|
|
44
40
|
*
|
|
45
41
|
* @param project - The project the run writes into
|
|
46
42
|
* @param outputDir - The output directory, absolute or relative to the
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Project, SourceFile } from 'ts-morph';
|
|
2
2
|
/** The manifest that records the files a generation wrote, and their hashes. */
|
|
3
3
|
export declare const GENERATION_MANIFEST = ".wow-generator.json";
|
|
4
|
-
export declare const LEGACY_GENERATION_MANIFEST = ".fetcher-generator.json";
|
|
5
4
|
/**
|
|
6
5
|
* The version of the manifest format this generator reads and writes. A
|
|
7
6
|
* change a reader of this version would misread bumps it; see section 3 of
|
|
@@ -30,17 +29,14 @@ export declare class OutputStore {
|
|
|
30
29
|
private readonly outputDir;
|
|
31
30
|
/** The files of the last run, with the hash each was written with. */
|
|
32
31
|
private readonly previous;
|
|
33
|
-
/** A pre-Wow manifest to delete once the new one is written. */
|
|
34
|
-
private readonly legacyManifest;
|
|
35
32
|
/** The files this run writes, by absolute path. */
|
|
36
33
|
private readonly written;
|
|
37
34
|
/** Files of the last run this run does not write and may remove. */
|
|
38
35
|
private readonly stale;
|
|
39
36
|
private constructor();
|
|
40
37
|
/**
|
|
41
|
-
* Reads the manifest of an output directory
|
|
42
|
-
*
|
|
43
|
-
* writes its files afresh.
|
|
38
|
+
* Reads the manifest of an output directory and takes the files it names
|
|
39
|
+
* out of the project: a run writes its files afresh.
|
|
44
40
|
*
|
|
45
41
|
* @param project - The project the run writes into
|
|
46
42
|
* @param outputDir - The output directory, absolute or relative to the
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GenerationResult, GeneratorOptions } from '../api/options.cjs';
|
|
2
2
|
/**
|
|
3
|
-
* Main code generator class that orchestrates the generation of TypeScript code
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Main code generator class that orchestrates the generation of TypeScript code
|
|
4
|
+
* from a Wow Manifest or an OpenAPI document. A Manifest generates the typed
|
|
5
|
+
* clients of a Wow service on `@ahoo-wang/wow-client`; an OpenAPI
|
|
6
|
+
* document generates its models and Fetcher decorator API clients.
|
|
6
7
|
*
|
|
7
8
|
* @example
|
|
8
9
|
* ```typescript
|
|
@@ -31,16 +32,16 @@ export declare class CodeGenerator {
|
|
|
31
32
|
*/
|
|
32
33
|
constructor(options: GeneratorOptions);
|
|
33
34
|
/**
|
|
34
|
-
* Generates TypeScript code from the
|
|
35
|
+
* Generates TypeScript code from the input document:
|
|
35
36
|
*
|
|
36
|
-
* 1. reads the generator configuration, then the document
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
37
|
+
* 1. reads the generator configuration, then the document; a Manifest goes
|
|
38
|
+
* to `generateFromManifest`, an OpenAPI document is checked for
|
|
39
|
+
* dangling references;
|
|
40
|
+
* 2. decides what the document generates (`analysis/`);
|
|
41
|
+
* 3. writes every module once (`emitters/`), then the index files;
|
|
42
|
+
* 4. formats, organises and types the imports, and checks the output
|
|
42
43
|
* compiles (`finalize/`);
|
|
43
|
-
*
|
|
44
|
+
* 5. writes the files, removes the stale ones of the last run and records
|
|
44
45
|
* the manifest (`output/`).
|
|
45
46
|
*
|
|
46
47
|
* Every warning is logged as it arises, and counted.
|
|
@@ -61,7 +62,7 @@ export declare class CodeGenerator {
|
|
|
61
62
|
/**
|
|
62
63
|
* Generates the clients of a Wow V10 service from its Manifest (decision
|
|
63
64
|
* D74, roadmap 5a.3): the types of its schemas, and for each aggregate its
|
|
64
|
-
* command, query and state clients on `@ahoo-wang/wow-client
|
|
65
|
+
* command, query and state clients on `@ahoo-wang/wow-client`. The
|
|
65
66
|
* configuration's API clients are an OpenAPI document's and do not apply.
|
|
66
67
|
*/
|
|
67
68
|
private generateFromManifest;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { GenerationResult, GeneratorOptions } from '../api/options.js';
|
|
2
2
|
/**
|
|
3
|
-
* Main code generator class that orchestrates the generation of TypeScript code
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Main code generator class that orchestrates the generation of TypeScript code
|
|
4
|
+
* from a Wow Manifest or an OpenAPI document. A Manifest generates the typed
|
|
5
|
+
* clients of a Wow service on `@ahoo-wang/wow-client`; an OpenAPI
|
|
6
|
+
* document generates its models and Fetcher decorator API clients.
|
|
6
7
|
*
|
|
7
8
|
* @example
|
|
8
9
|
* ```typescript
|
|
@@ -31,16 +32,16 @@ export declare class CodeGenerator {
|
|
|
31
32
|
*/
|
|
32
33
|
constructor(options: GeneratorOptions);
|
|
33
34
|
/**
|
|
34
|
-
* Generates TypeScript code from the
|
|
35
|
+
* Generates TypeScript code from the input document:
|
|
35
36
|
*
|
|
36
|
-
* 1. reads the generator configuration, then the document
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
37
|
+
* 1. reads the generator configuration, then the document; a Manifest goes
|
|
38
|
+
* to `generateFromManifest`, an OpenAPI document is checked for
|
|
39
|
+
* dangling references;
|
|
40
|
+
* 2. decides what the document generates (`analysis/`);
|
|
41
|
+
* 3. writes every module once (`emitters/`), then the index files;
|
|
42
|
+
* 4. formats, organises and types the imports, and checks the output
|
|
42
43
|
* compiles (`finalize/`);
|
|
43
|
-
*
|
|
44
|
+
* 5. writes the files, removes the stale ones of the last run and records
|
|
44
45
|
* the manifest (`output/`).
|
|
45
46
|
*
|
|
46
47
|
* Every warning is logged as it arises, and counted.
|
|
@@ -61,7 +62,7 @@ export declare class CodeGenerator {
|
|
|
61
62
|
/**
|
|
62
63
|
* Generates the clients of a Wow V10 service from its Manifest (decision
|
|
63
64
|
* D74, roadmap 5a.3): the types of its schemas, and for each aggregate its
|
|
64
|
-
* command, query and state clients on `@ahoo-wang/wow-client
|
|
65
|
+
* command, query and state clients on `@ahoo-wang/wow-client`. The
|
|
65
66
|
* configuration's API clients are an OpenAPI document's and do not apply.
|
|
66
67
|
*/
|
|
67
68
|
private generateFromManifest;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahoo-wang/wow-generator",
|
|
3
|
-
"version": "10.0.0-alpha.
|
|
4
|
-
"description": "Generates
|
|
3
|
+
"version": "10.0.0-alpha.4",
|
|
4
|
+
"description": "Generates the typed TypeScript clients of a Wow service from its Manifest, and TypeScript models and Fetcher decorator clients from any OpenAPI 3 document (https://github.com/Ahoo-Wang/Wow).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wow",
|
|
7
7
|
"wow-generator",
|
|
8
|
+
"manifest",
|
|
8
9
|
"cqrs",
|
|
9
10
|
"ddd",
|
|
10
11
|
"openapi",
|
|
@@ -38,8 +39,7 @@
|
|
|
38
39
|
"module": "./dist/index.js",
|
|
39
40
|
"types": "./dist/index.d.ts",
|
|
40
41
|
"bin": {
|
|
41
|
-
"wow-generator": "./dist/cli.js"
|
|
42
|
-
"fetcher-generator": "./dist/fetcherGeneratorCli.js"
|
|
42
|
+
"wow-generator": "./dist/cli.js"
|
|
43
43
|
},
|
|
44
44
|
"exports": {
|
|
45
45
|
".": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@ahoo-wang/fetcher": "^5.1.5 || ^6.0.0",
|
|
65
65
|
"@ahoo-wang/fetcher-decorator": "^5.1.5 || ^6.0.0",
|
|
66
66
|
"@ahoo-wang/fetcher-eventstream": "^5.1.5 || ^6.0.0",
|
|
67
|
-
"@ahoo-wang/wow-client": "~10.0.0-alpha.
|
|
67
|
+
"@ahoo-wang/wow-client": "~10.0.0-alpha.4"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"ts-morph": "^28.0.0",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@types/node": "^26.6.5",
|
|
81
81
|
"@vitest/coverage-v8": "4.1.11",
|
|
82
82
|
"@vitest/ui": "^4.1.11",
|
|
83
|
-
"eslint": "^10.
|
|
83
|
+
"eslint": "^10.13.0",
|
|
84
84
|
"eslint-plugin-import-x": "^4.17.1",
|
|
85
85
|
"globals": "^17.13.0",
|
|
86
86
|
"prettier": "3.9.9",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"vite": "8.3.4",
|
|
91
91
|
"vite-bundle-analyzer": "^1.3.9",
|
|
92
92
|
"vitest": "^4.1.11",
|
|
93
|
-
"@ahoo-wang/wow-client": "~10.0.0-alpha.
|
|
93
|
+
"@ahoo-wang/wow-client": "~10.0.0-alpha.4"
|
|
94
94
|
},
|
|
95
95
|
"scripts": {
|
|
96
96
|
"build": "vite build && pnpm test:package",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"lint": "eslint . --fix",
|
|
102
102
|
"clean": "rm -rf dist",
|
|
103
103
|
"analyze": "npx vite-bundle-analyzer -p auto",
|
|
104
|
-
"generate": "node dist/cli.js generate -i test/
|
|
104
|
+
"generate": "node dist/cli.js generate -i test/manifests/eshop-ordering.json -o test-output -t tsconfig.json",
|
|
105
105
|
"test:no-coverage": "vitest run --coverage.enabled=false --testTimeout=15000 && pnpm test:type",
|
|
106
106
|
"bench": "node scripts/bench.mjs"
|
|
107
107
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { OpenApiDocument } from '../openapi/document.cjs';
|
|
2
|
-
import { WowModel } from '../wow/model.cjs';
|
|
3
|
-
import { AggregateModel, ModelDeclaration } from './model.cjs';
|
|
4
|
-
/**
|
|
5
|
-
* The command and query clients of every aggregate that has state and query
|
|
6
|
-
* fields, by bounded context in the order the Wow metadata lists them.
|
|
7
|
-
*/
|
|
8
|
-
export declare function analyzeAggregates(document: OpenApiDocument, wow: WowModel): AggregateModel[];
|
|
9
|
-
/**
|
|
10
|
-
* Fails when a command's type would take a name its module or its package
|
|
11
|
-
* already holds: the alias of another command, a command body the client
|
|
12
|
-
* imports, or a model of the aggregate's package, which the package's index
|
|
13
|
-
* exports beside it. `Foo` and `FooCommand` as two commands of one aggregate
|
|
14
|
-
* do this: `Foo`'s alias is `FooCommand`, the other's body.
|
|
15
|
-
*
|
|
16
|
-
* @param aggregates - The aggregates, as analysed
|
|
17
|
-
* @param models - The models of the document
|
|
18
|
-
* @throws GeneratorError naming the command, the model it collides with and
|
|
19
|
-
* the schemas to rename
|
|
20
|
-
*/
|
|
21
|
-
export declare function assertCommandTypeNamesFree(aggregates: readonly AggregateModel[], models: readonly ModelDeclaration[]): void;
|