@ahoo-wang/wow-generator 9.8.0 → 10.0.0-alpha.3

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 (40) hide show
  1. package/README.md +2 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dist/cli/program.d.cts +7 -0
  4. package/dist/cli/program.d.ts +7 -0
  5. package/dist/cli.cjs +1 -1
  6. package/dist/cli.cjs.map +1 -1
  7. package/dist/cli.js +3 -93
  8. package/dist/cli.js.map +1 -1
  9. package/dist/codeGenerator-Ba5Cz8XW.cjs +31 -0
  10. package/dist/codeGenerator-Ba5Cz8XW.cjs.map +1 -0
  11. package/dist/{codeGenerator-CsWf0pZy.js → codeGenerator-CXBTLKZP.js} +1059 -613
  12. package/dist/codeGenerator-CXBTLKZP.js.map +1 -0
  13. package/dist/emitters/manifestClients.d.cts +15 -0
  14. package/dist/emitters/manifestClients.d.ts +15 -0
  15. package/dist/fetcherGeneratorCli.cjs +3 -0
  16. package/dist/fetcherGeneratorCli.cjs.map +1 -0
  17. package/dist/fetcherGeneratorCli.d.cts +8 -0
  18. package/dist/fetcherGeneratorCli.d.ts +8 -0
  19. package/dist/fetcherGeneratorCli.js +6 -0
  20. package/dist/fetcherGeneratorCli.js.map +1 -0
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.cts +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/input/parsers.d.cts +13 -0
  26. package/dist/input/parsers.d.ts +13 -0
  27. package/dist/manifest/analyze.d.cts +132 -0
  28. package/dist/manifest/analyze.d.ts +132 -0
  29. package/dist/manifest/document.d.cts +89 -0
  30. package/dist/manifest/document.d.ts +89 -0
  31. package/dist/pipeline/codeGenerator.d.cts +7 -0
  32. package/dist/pipeline/codeGenerator.d.ts +7 -0
  33. package/dist/program-BnfzUfUQ.cjs +10 -0
  34. package/dist/program-BnfzUfUQ.cjs.map +1 -0
  35. package/dist/program-CU0GCZqM.js +103 -0
  36. package/dist/program-CU0GCZqM.js.map +1 -0
  37. package/package.json +5 -5
  38. package/dist/codeGenerator-BMyiC0tW.cjs +0 -23
  39. package/dist/codeGenerator-BMyiC0tW.cjs.map +0 -1
  40. package/dist/codeGenerator-CsWf0pZy.js.map +0 -1
@@ -0,0 +1,15 @@
1
+ import { ModuleSet } from '../emit/moduleBuilder.cjs';
2
+ import { ManifestModel } from '../manifest/analyze.cjs';
3
+ /** The entry of the V10 client every generated module imports from. */
4
+ export declare const V10_CLIENT = "@ahoo-wang/wow-client/v10";
5
+ /**
6
+ * Describes every file a Manifest generates to its module (decision D74,
7
+ * roadmap 5a.3): the types of each bounded context, its error codes and wait
8
+ * helpers, and the aggregate, command and query clients of each aggregate,
9
+ * all on `@ahoo-wang/wow-client/v10`.
10
+ *
11
+ * @param model - What the Manifest generates
12
+ * @param modules - The modules of the run
13
+ * @param outputDir - The output directory
14
+ */
15
+ export declare function emitManifestGeneration(model: ManifestModel, modules: ModuleSet, outputDir: string): void;
@@ -0,0 +1,15 @@
1
+ import { ModuleSet } from '../emit/moduleBuilder.js';
2
+ import { ManifestModel } from '../manifest/analyze.js';
3
+ /** The entry of the V10 client every generated module imports from. */
4
+ export declare const V10_CLIENT = "@ahoo-wang/wow-client/v10";
5
+ /**
6
+ * Describes every file a Manifest generates to its module (decision D74,
7
+ * roadmap 5a.3): the types of each bounded context, its error codes and wait
8
+ * helpers, and the aggregate, command and query clients of each aggregate,
9
+ * all on `@ahoo-wang/wow-client/v10`.
10
+ *
11
+ * @param model - What the Manifest generates
12
+ * @param modules - The modules of the run
13
+ * @param outputDir - The output directory
14
+ */
15
+ export declare function emitManifestGeneration(model: ManifestModel, modules: ModuleSet, outputDir: string): void;
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ const e=require("./program-BnfzUfUQ.cjs");process.stderr.write(`${e.t}\n`),e.r();
3
+ //# sourceMappingURL=fetcherGeneratorCli.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcherGeneratorCli.cjs","names":["DEPRECATED_BIN_NOTICE","runCLI","require_program"],"sources":["../src/fetcherGeneratorCli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * The `fetcher-generator` bin: the CLI under the name it had in fetcher. It\n * says on stderr that the name is deprecated, then runs as `wow-generator`;\n * stdout stays the same, so `fetcher-generator --version` still prints only\n * the version.\n */\n\nimport { DEPRECATED_BIN_NOTICE, runCLI } from './cli/program';\n\n// compat(fetcher): the `fetcher-generator` bin of package.json; delete this\n// file and that bin entry in v10.\nprocess.stderr.write(`${DEPRECATED_BIN_NOTICE}\\n`);\nvoid runCLI();\n"],"mappings":";0CAaA,QAAQ,OAAO,MAAM,GAAGA,EAAAA,EAAsB,GAAG,EAC5CC,EAAAA,EAAO"}
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The `fetcher-generator` bin: the CLI under the name it had in fetcher. It
4
+ * says on stderr that the name is deprecated, then runs as `wow-generator`;
5
+ * stdout stays the same, so `fetcher-generator --version` still prints only
6
+ * the version.
7
+ */
8
+ export {};
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The `fetcher-generator` bin: the CLI under the name it had in fetcher. It
4
+ * says on stderr that the name is deprecated, then runs as `wow-generator`;
5
+ * stdout stays the same, so `fetcher-generator --version` still prints only
6
+ * the version.
7
+ */
8
+ export {};
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ import { r as e, t } from "./program-CU0GCZqM.js";
3
+ process.stderr.write(`${t}\n`), e();
4
+ //#endregion
5
+
6
+ //# sourceMappingURL=fetcherGeneratorCli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcherGeneratorCli.js","names":["runCLI","DEPRECATED_BIN_NOTICE"],"sources":["../src/fetcherGeneratorCli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * The `fetcher-generator` bin: the CLI under the name it had in fetcher. It\n * says on stderr that the name is deprecated, then runs as `wow-generator`;\n * stdout stays the same, so `fetcher-generator --version` still prints only\n * the version.\n */\n\nimport { DEPRECATED_BIN_NOTICE, runCLI } from './cli/program';\n\n// compat(fetcher): the `fetcher-generator` bin of package.json; delete this\n// file and that bin entry in v10.\nprocess.stderr.write(`${DEPRECATED_BIN_NOTICE}\\n`);\nvoid runCLI();\n"],"mappings":";;AAaA,QAAQ,OAAO,MAAM,GAAGC,EAAsB,GAAG,GAC5CD,EAAO"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./codeGenerator-BMyiC0tW.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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./codeGenerator-Ba5Cz8XW.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.d.cts CHANGED
@@ -4,5 +4,5 @@ export type { GeneratorErrorKind } from './api/errors.cjs';
4
4
  export { EXIT_CODES, GeneratorError } from './api/errors.cjs';
5
5
  export type { ConsoleLoggerOptions, LogLevel, Logger } from './api/logger.cjs';
6
6
  export { ConsoleLogger, SilentLogger } from './api/logger.cjs';
7
- export type { GenerationResult, GeneratorOptions } from './api/options.cjs';
7
+ export type { GenerationResult, GeneratorOptions, SchemaDocs, } from './api/options.cjs';
8
8
  export { CodeGenerator } from './pipeline/codeGenerator.cjs';
package/dist/index.d.ts CHANGED
@@ -4,5 +4,5 @@ export type { GeneratorErrorKind } from './api/errors.js';
4
4
  export { EXIT_CODES, GeneratorError } from './api/errors.js';
5
5
  export type { ConsoleLoggerOptions, LogLevel, Logger } from './api/logger.js';
6
6
  export { ConsoleLogger, SilentLogger } from './api/logger.js';
7
- export type { GenerationResult, GeneratorOptions } from './api/options.js';
7
+ export type { GenerationResult, GeneratorOptions, SchemaDocs, } from './api/options.js';
8
8
  export { CodeGenerator } from './pipeline/codeGenerator.js';
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-CsWf0pZy.js";
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-CXBTLKZP.js";
@@ -13,6 +13,19 @@ import { LoadResourceOptions } from './resources.cjs';
13
13
  * @returns The parsed document; `paths` is an empty object when it has none
14
14
  */
15
15
  export declare function parseOpenAPI(inputPath: string, options?: LoadResourceOptions): Promise<OpenAPI>;
16
+ /**
17
+ * Loads and parses the input document, an OpenAPI 3 document or a Wow
18
+ * Manifest, without checking which it is.
19
+ *
20
+ * Every failure is a {@link GeneratorError} of kind `input` whose message
21
+ * names the document: it cannot be read or fetched, or it is neither JSON
22
+ * nor YAML.
23
+ *
24
+ * @param inputPath - The path or http(s) URL of the document
25
+ * @param options - Headers and timeout for an http(s) document
26
+ * @returns The parsed document
27
+ */
28
+ export declare function loadDocument(inputPath: string, options?: LoadResourceOptions): Promise<unknown>;
16
29
  /**
17
30
  * Checks that a parsed document is an OpenAPI 3 document the generator reads.
18
31
  *
@@ -13,6 +13,19 @@ import { LoadResourceOptions } from './resources.js';
13
13
  * @returns The parsed document; `paths` is an empty object when it has none
14
14
  */
15
15
  export declare function parseOpenAPI(inputPath: string, options?: LoadResourceOptions): Promise<OpenAPI>;
16
+ /**
17
+ * Loads and parses the input document, an OpenAPI 3 document or a Wow
18
+ * Manifest, without checking which it is.
19
+ *
20
+ * Every failure is a {@link GeneratorError} of kind `input` whose message
21
+ * names the document: it cannot be read or fetched, or it is neither JSON
22
+ * nor YAML.
23
+ *
24
+ * @param inputPath - The path or http(s) URL of the document
25
+ * @param options - Headers and timeout for an http(s) document
26
+ * @returns The parsed document
27
+ */
28
+ export declare function loadDocument(inputPath: string, options?: LoadResourceOptions): Promise<unknown>;
16
29
  /**
17
30
  * Checks that a parsed document is an OpenAPI 3 document the generator reads.
18
31
  *
@@ -0,0 +1,132 @@
1
+ import { ManifestDocument } from './document.cjs';
2
+ /** A property of a generated interface. */
3
+ export interface PropertyModel {
4
+ /** As written in the interface: quoted when it is no identifier. */
5
+ readonly name: string;
6
+ readonly type: string;
7
+ readonly optional: boolean;
8
+ readonly description?: string;
9
+ }
10
+ /** A type declared for a schema of `$defs`. */
11
+ export interface TypeModel {
12
+ /** The `$defs` key. */
13
+ readonly key: string;
14
+ readonly name: string;
15
+ /** The file it is declared in, relative to the output directory. */
16
+ readonly file: string;
17
+ readonly description?: string;
18
+ /** An interface's properties, or undefined for a type alias. */
19
+ readonly properties?: readonly PropertyModel[];
20
+ /** A type alias's type; or, for an interface, its index signature's. */
21
+ readonly type?: string;
22
+ /** The type names it refers to. */
23
+ readonly references: readonly string[];
24
+ }
25
+ /** A command of an aggregate client. */
26
+ export interface CommandModel {
27
+ readonly name: string;
28
+ readonly method: string;
29
+ /** The `PATHS` member of its route by id, and of its route without one. */
30
+ readonly byIdPath?: {
31
+ readonly member: string;
32
+ readonly path: string;
33
+ };
34
+ readonly unaddressedPath?: {
35
+ readonly member: string;
36
+ readonly path: string;
37
+ };
38
+ /** The body's type name, or undefined when its schema is unknown. */
39
+ readonly bodyType: string;
40
+ /** The body may be left out: its schema requires nothing. */
41
+ readonly bodyOptional: boolean;
42
+ readonly creation: string;
43
+ readonly mounted: boolean;
44
+ readonly produces: readonly string[];
45
+ /** What the command's class says it is, as the Manifest describes it. */
46
+ readonly description?: string;
47
+ }
48
+ /** A lifecycle command an aggregate lists. */
49
+ export interface LifecycleModel {
50
+ /** `wow.lifecycle.DeleteAggregate`, … */
51
+ readonly name: string;
52
+ /** The `LifecycleCommands` member. */
53
+ readonly member: string;
54
+ readonly method: string;
55
+ /**
56
+ * The body's type, or undefined for a command without one: the type
57
+ * generated from the Manifest's `$defs` entry of the command's name when it
58
+ * holds one (`bodyGenerated`), else `@ahoo-wang/wow-client/v10`'s.
59
+ */
60
+ readonly bodyType?: string;
61
+ /** The body's type is generated from the Manifest, not `@ahoo-wang/wow-client/v10`'s. */
62
+ readonly bodyGenerated?: boolean;
63
+ /** What the Manifest's schema of the body says the command does. */
64
+ readonly description?: string;
65
+ }
66
+ /** An aggregate and its clients. */
67
+ export interface AggregateModel {
68
+ readonly context: string;
69
+ readonly name: string;
70
+ readonly description?: string;
71
+ /** The type-name prefix: `Product`. */
72
+ readonly typeName: string;
73
+ /** The directory of its modules, relative to the output directory. */
74
+ readonly directory: string;
75
+ readonly ownership: string;
76
+ readonly snapshot: boolean;
77
+ readonly stateType: string;
78
+ readonly stateFields: readonly string[];
79
+ readonly commands: readonly CommandModel[];
80
+ readonly events: readonly {
81
+ /** The name the Manifest declares: `ProductCreated`. */
82
+ readonly name: string;
83
+ /**
84
+ * The event type the server names it by on the wire (08-data-protocols §2):
85
+ * `context.aggregate.EventName`, or the declared name when it is already
86
+ * qualified.
87
+ */
88
+ readonly wireName: string;
89
+ readonly revision: number;
90
+ readonly type: string;
91
+ }[];
92
+ readonly lifecycle: readonly LifecycleModel[];
93
+ readonly queryModels: readonly string[];
94
+ }
95
+ /** A bounded context and what its modules declare. */
96
+ export interface ContextModel {
97
+ readonly name: string;
98
+ readonly description?: string;
99
+ /** The type-name prefix: `EshopCatalog`. */
100
+ readonly typeName: string;
101
+ /** The constant prefix: `ESHOP_CATALOG`. */
102
+ readonly constantName: string;
103
+ readonly directory: string;
104
+ readonly errors: readonly {
105
+ readonly member: string;
106
+ readonly code: string;
107
+ readonly status: number;
108
+ readonly description?: string;
109
+ }[];
110
+ readonly subscriptions: readonly string[];
111
+ readonly aggregates: readonly AggregateModel[];
112
+ }
113
+ /** What a Manifest generates, decided before anything is written. */
114
+ export interface ManifestModel {
115
+ readonly service?: string;
116
+ readonly types: readonly TypeModel[];
117
+ readonly contexts: readonly ContextModel[];
118
+ }
119
+ /**
120
+ * Decides what a Manifest generates: a `types.ts` per bounded context with
121
+ * the types of the schemas its aggregates reach (a schema two contexts reach
122
+ * is declared in the first), a `boundedContext.ts` with its error codes and
123
+ * wait helpers, and for each aggregate its `aggregate.ts`,
124
+ * `commandClient.ts` and `queryClient.ts`.
125
+ *
126
+ * @param manifest - The Manifest
127
+ * @returns The model and the warnings it raised
128
+ */
129
+ export declare function analyzeManifest(manifest: ManifestDocument): {
130
+ model: ManifestModel;
131
+ warnings: string[];
132
+ };
@@ -0,0 +1,132 @@
1
+ import { ManifestDocument } from './document.js';
2
+ /** A property of a generated interface. */
3
+ export interface PropertyModel {
4
+ /** As written in the interface: quoted when it is no identifier. */
5
+ readonly name: string;
6
+ readonly type: string;
7
+ readonly optional: boolean;
8
+ readonly description?: string;
9
+ }
10
+ /** A type declared for a schema of `$defs`. */
11
+ export interface TypeModel {
12
+ /** The `$defs` key. */
13
+ readonly key: string;
14
+ readonly name: string;
15
+ /** The file it is declared in, relative to the output directory. */
16
+ readonly file: string;
17
+ readonly description?: string;
18
+ /** An interface's properties, or undefined for a type alias. */
19
+ readonly properties?: readonly PropertyModel[];
20
+ /** A type alias's type; or, for an interface, its index signature's. */
21
+ readonly type?: string;
22
+ /** The type names it refers to. */
23
+ readonly references: readonly string[];
24
+ }
25
+ /** A command of an aggregate client. */
26
+ export interface CommandModel {
27
+ readonly name: string;
28
+ readonly method: string;
29
+ /** The `PATHS` member of its route by id, and of its route without one. */
30
+ readonly byIdPath?: {
31
+ readonly member: string;
32
+ readonly path: string;
33
+ };
34
+ readonly unaddressedPath?: {
35
+ readonly member: string;
36
+ readonly path: string;
37
+ };
38
+ /** The body's type name, or undefined when its schema is unknown. */
39
+ readonly bodyType: string;
40
+ /** The body may be left out: its schema requires nothing. */
41
+ readonly bodyOptional: boolean;
42
+ readonly creation: string;
43
+ readonly mounted: boolean;
44
+ readonly produces: readonly string[];
45
+ /** What the command's class says it is, as the Manifest describes it. */
46
+ readonly description?: string;
47
+ }
48
+ /** A lifecycle command an aggregate lists. */
49
+ export interface LifecycleModel {
50
+ /** `wow.lifecycle.DeleteAggregate`, … */
51
+ readonly name: string;
52
+ /** The `LifecycleCommands` member. */
53
+ readonly member: string;
54
+ readonly method: string;
55
+ /**
56
+ * The body's type, or undefined for a command without one: the type
57
+ * generated from the Manifest's `$defs` entry of the command's name when it
58
+ * holds one (`bodyGenerated`), else `@ahoo-wang/wow-client/v10`'s.
59
+ */
60
+ readonly bodyType?: string;
61
+ /** The body's type is generated from the Manifest, not `@ahoo-wang/wow-client/v10`'s. */
62
+ readonly bodyGenerated?: boolean;
63
+ /** What the Manifest's schema of the body says the command does. */
64
+ readonly description?: string;
65
+ }
66
+ /** An aggregate and its clients. */
67
+ export interface AggregateModel {
68
+ readonly context: string;
69
+ readonly name: string;
70
+ readonly description?: string;
71
+ /** The type-name prefix: `Product`. */
72
+ readonly typeName: string;
73
+ /** The directory of its modules, relative to the output directory. */
74
+ readonly directory: string;
75
+ readonly ownership: string;
76
+ readonly snapshot: boolean;
77
+ readonly stateType: string;
78
+ readonly stateFields: readonly string[];
79
+ readonly commands: readonly CommandModel[];
80
+ readonly events: readonly {
81
+ /** The name the Manifest declares: `ProductCreated`. */
82
+ readonly name: string;
83
+ /**
84
+ * The event type the server names it by on the wire (08-data-protocols §2):
85
+ * `context.aggregate.EventName`, or the declared name when it is already
86
+ * qualified.
87
+ */
88
+ readonly wireName: string;
89
+ readonly revision: number;
90
+ readonly type: string;
91
+ }[];
92
+ readonly lifecycle: readonly LifecycleModel[];
93
+ readonly queryModels: readonly string[];
94
+ }
95
+ /** A bounded context and what its modules declare. */
96
+ export interface ContextModel {
97
+ readonly name: string;
98
+ readonly description?: string;
99
+ /** The type-name prefix: `EshopCatalog`. */
100
+ readonly typeName: string;
101
+ /** The constant prefix: `ESHOP_CATALOG`. */
102
+ readonly constantName: string;
103
+ readonly directory: string;
104
+ readonly errors: readonly {
105
+ readonly member: string;
106
+ readonly code: string;
107
+ readonly status: number;
108
+ readonly description?: string;
109
+ }[];
110
+ readonly subscriptions: readonly string[];
111
+ readonly aggregates: readonly AggregateModel[];
112
+ }
113
+ /** What a Manifest generates, decided before anything is written. */
114
+ export interface ManifestModel {
115
+ readonly service?: string;
116
+ readonly types: readonly TypeModel[];
117
+ readonly contexts: readonly ContextModel[];
118
+ }
119
+ /**
120
+ * Decides what a Manifest generates: a `types.ts` per bounded context with
121
+ * the types of the schemas its aggregates reach (a schema two contexts reach
122
+ * is declared in the first), a `boundedContext.ts` with its error codes and
123
+ * wait helpers, and for each aggregate its `aggregate.ts`,
124
+ * `commandClient.ts` and `queryClient.ts`.
125
+ *
126
+ * @param manifest - The Manifest
127
+ * @returns The model and the warnings it raised
128
+ */
129
+ export declare function analyzeManifest(manifest: ManifestDocument): {
130
+ model: ManifestModel;
131
+ warnings: string[];
132
+ };
@@ -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;
@@ -58,4 +58,11 @@ export declare class CodeGenerator {
58
58
  * ```
59
59
  */
60
60
  generate(): Promise<GenerationResult>;
61
+ /**
62
+ * Generates the clients of a Wow V10 service from its Manifest (decision
63
+ * 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/v10`. The
65
+ * configuration's API clients are an OpenAPI document's and do not apply.
66
+ */
67
+ private generateFromManifest;
61
68
  }
@@ -58,4 +58,11 @@ export declare class CodeGenerator {
58
58
  * ```
59
59
  */
60
60
  generate(): Promise<GenerationResult>;
61
+ /**
62
+ * Generates the clients of a Wow V10 service from its Manifest (decision
63
+ * 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/v10`. The
65
+ * configuration's API clients are an OpenAPI document's and do not apply.
66
+ */
67
+ private generateFromManifest;
61
68
  }
@@ -0,0 +1,10 @@
1
+ const e=require("./codeGenerator-Ba5Cz8XW.cjs");let t=require("path"),n=require("commander");var r=`10.0.0-alpha.3`;function i(e){if(!e)return!1;let t;try{t=new URL(e)}catch{return!0}return/^[a-z]:$/i.test(t.protocol)?!0:t.protocol===`http:`||t.protocol===`https:`}function a(t=[]){let n={};for(let r of t){let t=r.indexOf(`:`),i=t>0?r.slice(0,t).trim():``;if(!i)throw new e.s(`input`,`Invalid --header "${r}": expected "Name: value".`);n[i]=r.slice(t+1).trim()}return n}function o(t){if(t===void 0)return;let n=Number(t);if(!Number.isInteger(n)||n<=0)throw new e.s(`input`,`Invalid --timeout "${t}": expected a positive number of milliseconds.`);return n}function s(t){if(t===void 0||t===`summary`)return`summary`;if(t===`full`)return`full`;throw new e.s(`input`,`Invalid --schema-docs "${t}": expected "summary" or "full".`)}function c(e){return e.verbose?`verbose`:e.quiet?`quiet`:`normal`}function l(t,n,r){if(n instanceof e.s)return t.error(n.message),r&&n.cause!==void 0&&t.error(`Caused by:`,n.cause),n.exitCode;let i=n instanceof Error?n.message:String(n);return t.error(`Code generation failed: ${i}`),r?t.error(``,n):t.error(`Rerun with --verbose for the stack trace, and report it at https://github.com/Ahoo-Wang/Wow/issues if the input is valid.`),e.o.internal}async function u(n,u=new e.i({level:c(n)}),d={}){if(!i(n.input))return u.error(`Invalid input "${n.input}": expected a file path or an http(s) URL.`),e.o.input;try{u.debug(`wow-generator v${r}`);let i={...d,inputPath:n.input,outputDir:n.output,configPath:n.config,tsConfigFilePath:n.tsConfigFilePath,headers:a(n.header),timeoutMs:o(n.timeout),schemaDocs:s(n.schemaDocs),logger:u},c=await new e.t(i).generate(),l=c.warnings?`, ${c.warnings} warning${c.warnings===1?``:`s`}`:``,f=c.configPath?` with ${(0,t.relative)(process.cwd(),c.configPath)||c.configPath}`:``;return u.info(`Generated ${c.files.length} files into ${n.output}${f}${l}`),n.strict&&c.warnings>0?(u.error(`--strict: the run logged ${c.warnings} warning${c.warnings===1?``:`s`}.`),e.o.specification):e.o.success}catch(t){return d[e.n]?.aborted?e.o.interrupted:l(u,t,!!n.verbose)}}async function d(t){let n=new AbortController;process.once(`SIGINT`,()=>{console.error(`Generation interrupted by user`),n.abort()}),process.exitCode=await u(t,void 0,{[e.n]:n.signal})}var f=`
2
+ Exit codes:
3
+ ${e.o.success} generated; or --help, help or --version printed
4
+ ${e.o.internal} internal error; rerun with --verbose for the stack trace
5
+ ${e.o.input} input or usage: unreadable, unfetchable or not OpenAPI 3.x; an invalid option
6
+ ${e.o.configuration} configuration: cannot be read, parsed or validated
7
+ ${e.o.specification} specification: cannot be generated, or --strict and the run had warnings
8
+ ${e.o.output} output: the manifest, a path outside the output, or a failed write
9
+ ${e.o.interrupted} interrupted (Ctrl-C)`,p=`fetcher-generator is deprecated and will be removed in v10; run wow-generator instead.`;function m(e,t=[]){return[...t,e]}function h(t=n.program){return t.exitOverride(),t.name(`wow-generator`).description(`OpenAPI Specification TypeScript code generator for Wow`).version(r,`-v, --version`),t.command(`generate`).description(`Generate TypeScript code from an OpenAPI specification or a Wow V10 Manifest`).requiredOption(`-i, --input <file>`,`Input OpenAPI specification or Wow Manifest (GET /wow/manifest) file path or URL (http/https)`).option(`-o, --output <path>`,`Output directory path`,`src/generated`).option(`-c, --config <file>`,`Configuration file path (default: ${e.c})`).option(`-t, --ts-config-file-path <file>`,`TypeScript configuration file path`).option(`-H, --header <header>`,`Request header for an http(s) input or configuration, as "Name: value"; repeatable`,m).option(`--timeout <ms>`,`Milliseconds before fetching an http(s) input is abandoned (default: ${e.r})`).option(`--schema-docs <mode>`,`What model doc comments carry: "summary" (title, description, constraints) or "full" (also the JSON schema)`,`summary`).option(`--strict`,`Exit with code 4 when the run logs a warning`).option(`--verbose`,`Log every step, and the stack trace of a failure`).option(`--quiet`,`Log only warnings and errors`).addHelpText(`after`,f).action(d),t}function g(t){return t.exitCode===0?e.o.success:e.o.input}async function _(e,t=h()){try{e===void 0?await t.parseAsync():await t.parseAsync(e,{from:`user`})}catch(e){if(!(e instanceof n.CommanderError))throw e;process.exitCode=g(e)}}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return p}});
10
+ //# sourceMappingURL=program-BnfzUfUQ.cjs.map