@ahoo-wang/wow-generator 9.9.0 → 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-CU1TGcUI.js +2407 -0
- 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 +15 -0
- package/dist/emitters/manifestClients.d.ts +15 -0
- 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/input/parsers.d.cts +13 -0
- package/dist/input/parsers.d.ts +13 -0
- package/dist/manifest/analyze.d.cts +148 -0
- package/dist/manifest/analyze.d.ts +148 -0
- package/dist/manifest/document.d.cts +89 -0
- package/dist/manifest/document.d.ts +89 -0
- 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 +19 -11
- package/dist/pipeline/codeGenerator.d.ts +19 -11
- package/package.json +8 -8
- package/dist/analysis/aggregates.d.cts +0 -21
- package/dist/analysis/aggregates.d.ts +0 -21
- package/dist/codeGenerator-BMyiC0tW.cjs +0 -23
- package/dist/codeGenerator-BMyiC0tW.cjs.map +0 -1
- package/dist/codeGenerator-CsWf0pZy.js +0 -2572
- package/dist/codeGenerator-CsWf0pZy.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-64WQvLq1.js +0 -103
- package/dist/program-64WQvLq1.js.map +0 -1
- package/dist/program-DWjbTSVJ.cjs +0 -10
- package/dist/program-DWjbTSVJ.cjs.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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The part of a Wow V10 service Manifest (`GET /wow/manifest`, or the
|
|
3
|
+
* merged `manifest.json` of the build; decisions D73, D74) the generator
|
|
4
|
+
* reads. Members it does not read are left out; a Manifest carries more.
|
|
5
|
+
*/
|
|
6
|
+
export interface ManifestDocument {
|
|
7
|
+
readonly format: number;
|
|
8
|
+
readonly service?: {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly version?: string;
|
|
11
|
+
};
|
|
12
|
+
readonly contexts: readonly ManifestContext[];
|
|
13
|
+
readonly errors?: readonly ManifestError[];
|
|
14
|
+
readonly $defs?: Readonly<Record<string, JsonSchema>>;
|
|
15
|
+
}
|
|
16
|
+
/** A bounded context of the Manifest. */
|
|
17
|
+
export interface ManifestContext {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly description?: string;
|
|
20
|
+
readonly aggregates?: readonly ManifestAggregate[];
|
|
21
|
+
readonly subscriptions?: readonly {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
}[];
|
|
24
|
+
readonly errors?: readonly ManifestError[];
|
|
25
|
+
}
|
|
26
|
+
/** An aggregate of a bounded context. */
|
|
27
|
+
export interface ManifestAggregate {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly description?: string;
|
|
30
|
+
readonly state: {
|
|
31
|
+
readonly schema: string;
|
|
32
|
+
};
|
|
33
|
+
readonly snapshot?: {
|
|
34
|
+
readonly enabled?: boolean;
|
|
35
|
+
};
|
|
36
|
+
readonly commands?: readonly ManifestCommand[];
|
|
37
|
+
readonly events?: readonly ManifestEvent[];
|
|
38
|
+
readonly lifecycle?: readonly string[];
|
|
39
|
+
readonly queries?: readonly {
|
|
40
|
+
readonly model: string;
|
|
41
|
+
}[];
|
|
42
|
+
readonly ownership?: string;
|
|
43
|
+
}
|
|
44
|
+
/** A command of an aggregate. */
|
|
45
|
+
export interface ManifestCommand {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly schema: string;
|
|
48
|
+
readonly creation?: string;
|
|
49
|
+
readonly produces?: readonly string[];
|
|
50
|
+
readonly routes?: readonly {
|
|
51
|
+
readonly method: string;
|
|
52
|
+
readonly path: string;
|
|
53
|
+
}[];
|
|
54
|
+
readonly mounted?: boolean;
|
|
55
|
+
readonly description?: string;
|
|
56
|
+
}
|
|
57
|
+
/** An event of an aggregate. */
|
|
58
|
+
export interface ManifestEvent {
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly revision?: number;
|
|
61
|
+
readonly schema: string;
|
|
62
|
+
}
|
|
63
|
+
/** An error code of the Manifest. */
|
|
64
|
+
export interface ManifestError {
|
|
65
|
+
readonly code: string;
|
|
66
|
+
readonly status: number;
|
|
67
|
+
readonly description?: string;
|
|
68
|
+
}
|
|
69
|
+
/** A JSON Schema 2020-12 of `$defs`, as the Manifest writes them. */
|
|
70
|
+
export type JsonSchema = Readonly<Record<string, unknown>>;
|
|
71
|
+
/** The Manifest format the generator reads (decision D59). */
|
|
72
|
+
export declare const MANIFEST_FORMAT = 1;
|
|
73
|
+
/** The `$defs` key a schema reference points to, or undefined for another. */
|
|
74
|
+
export declare function schemaKey(ref: string): string | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Whether a parsed document is a Wow Manifest rather than an OpenAPI one: an
|
|
77
|
+
* object with a numeric `format` and a `contexts` array, and no `openapi`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isManifestDocument(document: unknown): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Checks that a document is a Manifest of the format the generator reads,
|
|
82
|
+
* with the members it needs.
|
|
83
|
+
*
|
|
84
|
+
* @param document - The parsed document
|
|
85
|
+
* @param source - Where it came from, for messages
|
|
86
|
+
* @throws GeneratorError of kind `input` for another format, and of kind
|
|
87
|
+
* `specification` for a Manifest that misses what it needs
|
|
88
|
+
*/
|
|
89
|
+
export declare function validateManifest(document: unknown, source: string): ManifestDocument;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The part of a Wow V10 service Manifest (`GET /wow/manifest`, or the
|
|
3
|
+
* merged `manifest.json` of the build; decisions D73, D74) the generator
|
|
4
|
+
* reads. Members it does not read are left out; a Manifest carries more.
|
|
5
|
+
*/
|
|
6
|
+
export interface ManifestDocument {
|
|
7
|
+
readonly format: number;
|
|
8
|
+
readonly service?: {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly version?: string;
|
|
11
|
+
};
|
|
12
|
+
readonly contexts: readonly ManifestContext[];
|
|
13
|
+
readonly errors?: readonly ManifestError[];
|
|
14
|
+
readonly $defs?: Readonly<Record<string, JsonSchema>>;
|
|
15
|
+
}
|
|
16
|
+
/** A bounded context of the Manifest. */
|
|
17
|
+
export interface ManifestContext {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly description?: string;
|
|
20
|
+
readonly aggregates?: readonly ManifestAggregate[];
|
|
21
|
+
readonly subscriptions?: readonly {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
}[];
|
|
24
|
+
readonly errors?: readonly ManifestError[];
|
|
25
|
+
}
|
|
26
|
+
/** An aggregate of a bounded context. */
|
|
27
|
+
export interface ManifestAggregate {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly description?: string;
|
|
30
|
+
readonly state: {
|
|
31
|
+
readonly schema: string;
|
|
32
|
+
};
|
|
33
|
+
readonly snapshot?: {
|
|
34
|
+
readonly enabled?: boolean;
|
|
35
|
+
};
|
|
36
|
+
readonly commands?: readonly ManifestCommand[];
|
|
37
|
+
readonly events?: readonly ManifestEvent[];
|
|
38
|
+
readonly lifecycle?: readonly string[];
|
|
39
|
+
readonly queries?: readonly {
|
|
40
|
+
readonly model: string;
|
|
41
|
+
}[];
|
|
42
|
+
readonly ownership?: string;
|
|
43
|
+
}
|
|
44
|
+
/** A command of an aggregate. */
|
|
45
|
+
export interface ManifestCommand {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly schema: string;
|
|
48
|
+
readonly creation?: string;
|
|
49
|
+
readonly produces?: readonly string[];
|
|
50
|
+
readonly routes?: readonly {
|
|
51
|
+
readonly method: string;
|
|
52
|
+
readonly path: string;
|
|
53
|
+
}[];
|
|
54
|
+
readonly mounted?: boolean;
|
|
55
|
+
readonly description?: string;
|
|
56
|
+
}
|
|
57
|
+
/** An event of an aggregate. */
|
|
58
|
+
export interface ManifestEvent {
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly revision?: number;
|
|
61
|
+
readonly schema: string;
|
|
62
|
+
}
|
|
63
|
+
/** An error code of the Manifest. */
|
|
64
|
+
export interface ManifestError {
|
|
65
|
+
readonly code: string;
|
|
66
|
+
readonly status: number;
|
|
67
|
+
readonly description?: string;
|
|
68
|
+
}
|
|
69
|
+
/** A JSON Schema 2020-12 of `$defs`, as the Manifest writes them. */
|
|
70
|
+
export type JsonSchema = Readonly<Record<string, unknown>>;
|
|
71
|
+
/** The Manifest format the generator reads (decision D59). */
|
|
72
|
+
export declare const MANIFEST_FORMAT = 1;
|
|
73
|
+
/** The `$defs` key a schema reference points to, or undefined for another. */
|
|
74
|
+
export declare function schemaKey(ref: string): string | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Whether a parsed document is a Wow Manifest rather than an OpenAPI one: an
|
|
77
|
+
* object with a numeric `format` and a `contexts` array, and no `openapi`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isManifestDocument(document: unknown): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Checks that a document is a Manifest of the format the generator reads,
|
|
82
|
+
* with the members it needs.
|
|
83
|
+
*
|
|
84
|
+
* @param document - The parsed document
|
|
85
|
+
* @param source - Where it came from, for messages
|
|
86
|
+
* @throws GeneratorError of kind `input` for another format, and of kind
|
|
87
|
+
* `specification` for a Manifest that misses what it needs
|
|
88
|
+
*/
|
|
89
|
+
export declare function validateManifest(document: unknown, source: string): ManifestDocument;
|
|
@@ -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.
|
|
@@ -58,4 +59,11 @@ export declare class CodeGenerator {
|
|
|
58
59
|
* ```
|
|
59
60
|
*/
|
|
60
61
|
generate(): Promise<GenerationResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Generates the clients of a Wow V10 service from its Manifest (decision
|
|
64
|
+
* D74, roadmap 5a.3): the types of its schemas, and for each aggregate its
|
|
65
|
+
* command, query and state clients on `@ahoo-wang/wow-client`. The
|
|
66
|
+
* configuration's API clients are an OpenAPI document's and do not apply.
|
|
67
|
+
*/
|
|
68
|
+
private generateFromManifest;
|
|
61
69
|
}
|
|
@@ -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.
|
|
@@ -58,4 +59,11 @@ export declare class CodeGenerator {
|
|
|
58
59
|
* ```
|
|
59
60
|
*/
|
|
60
61
|
generate(): Promise<GenerationResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Generates the clients of a Wow V10 service from its Manifest (decision
|
|
64
|
+
* D74, roadmap 5a.3): the types of its schemas, and for each aggregate its
|
|
65
|
+
* command, query and state clients on `@ahoo-wang/wow-client`. The
|
|
66
|
+
* configuration's API clients are an OpenAPI document's and do not apply.
|
|
67
|
+
*/
|
|
68
|
+
private generateFromManifest;
|
|
61
69
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahoo-wang/wow-generator",
|
|
3
|
-
"version": "
|
|
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": "~
|
|
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": "~
|
|
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;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { OpenApiDocument } from '../openapi/document.js';
|
|
2
|
-
import { WowModel } from '../wow/model.js';
|
|
3
|
-
import { AggregateModel, ModelDeclaration } from './model.js';
|
|
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;
|