@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.
Files changed (76) hide show
  1. package/README.md +99 -62
  2. package/README.zh-CN.md +85 -48
  3. package/dist/analysis/analyze.d.cts +5 -8
  4. package/dist/analysis/analyze.d.ts +5 -8
  5. package/dist/analysis/apiClients.d.cts +3 -4
  6. package/dist/analysis/apiClients.d.ts +3 -4
  7. package/dist/analysis/clientNames.d.cts +0 -20
  8. package/dist/analysis/clientNames.d.ts +0 -20
  9. package/dist/analysis/model.d.cts +2 -102
  10. package/dist/analysis/model.d.ts +2 -102
  11. package/dist/analysis/modelInfo.d.cts +12 -3
  12. package/dist/analysis/modelInfo.d.ts +12 -3
  13. package/dist/analysis/models.d.cts +3 -11
  14. package/dist/analysis/models.d.ts +3 -11
  15. package/dist/api/configuration.d.cts +1 -5
  16. package/dist/api/configuration.d.ts +1 -5
  17. package/dist/cli/program.d.cts +0 -5
  18. package/dist/cli/program.d.ts +0 -5
  19. package/dist/cli.cjs +9 -1
  20. package/dist/cli.cjs.map +1 -1
  21. package/dist/cli.js +102 -3
  22. package/dist/cli.js.map +1 -1
  23. package/dist/{codeGenerator-CXBTLKZP.js → codeGenerator-CU1TGcUI.js} +716 -1327
  24. package/dist/codeGenerator-CU1TGcUI.js.map +1 -0
  25. package/dist/codeGenerator-DzI0zCgM.cjs +27 -0
  26. package/dist/codeGenerator-DzI0zCgM.cjs.map +1 -0
  27. package/dist/emit/imports.d.cts +0 -9
  28. package/dist/emit/imports.d.ts +0 -9
  29. package/dist/emitters/decorators.d.cts +3 -18
  30. package/dist/emitters/decorators.d.ts +3 -18
  31. package/dist/emitters/emit.d.cts +2 -3
  32. package/dist/emitters/emit.d.ts +2 -3
  33. package/dist/emitters/manifestClients.d.cts +3 -3
  34. package/dist/emitters/manifestClients.d.ts +3 -3
  35. package/dist/emitters/models.d.cts +1 -1
  36. package/dist/emitters/models.d.ts +1 -1
  37. package/dist/index.cjs +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/input/configuration.d.cts +2 -4
  40. package/dist/input/configuration.d.ts +2 -4
  41. package/dist/manifest/analyze.d.cts +18 -2
  42. package/dist/manifest/analyze.d.ts +18 -2
  43. package/dist/naming/modelInfo.d.cts +1 -2
  44. package/dist/naming/modelInfo.d.ts +1 -2
  45. package/dist/naming/paths.d.cts +0 -5
  46. package/dist/naming/paths.d.ts +0 -5
  47. package/dist/output/outputStore.d.cts +2 -6
  48. package/dist/output/outputStore.d.ts +2 -6
  49. package/dist/pipeline/codeGenerator.d.cts +13 -12
  50. package/dist/pipeline/codeGenerator.d.ts +13 -12
  51. package/package.json +8 -8
  52. package/dist/analysis/aggregates.d.cts +0 -21
  53. package/dist/analysis/aggregates.d.ts +0 -21
  54. package/dist/codeGenerator-Ba5Cz8XW.cjs +0 -31
  55. package/dist/codeGenerator-Ba5Cz8XW.cjs.map +0 -1
  56. package/dist/codeGenerator-CXBTLKZP.js.map +0 -1
  57. package/dist/emitters/commandClients.d.cts +0 -14
  58. package/dist/emitters/commandClients.d.ts +0 -14
  59. package/dist/emitters/queryClients.d.cts +0 -11
  60. package/dist/emitters/queryClients.d.ts +0 -11
  61. package/dist/fetcherGeneratorCli.cjs +0 -3
  62. package/dist/fetcherGeneratorCli.cjs.map +0 -1
  63. package/dist/fetcherGeneratorCli.d.cts +0 -8
  64. package/dist/fetcherGeneratorCli.d.ts +0 -8
  65. package/dist/fetcherGeneratorCli.js +0 -6
  66. package/dist/fetcherGeneratorCli.js.map +0 -1
  67. package/dist/program-BnfzUfUQ.cjs +0 -10
  68. package/dist/program-BnfzUfUQ.cjs.map +0 -1
  69. package/dist/program-CU0GCZqM.js +0 -103
  70. package/dist/program-CU0GCZqM.js.map +0 -1
  71. package/dist/wow/conventions.d.cts +0 -154
  72. package/dist/wow/conventions.d.ts +0 -154
  73. package/dist/wow/model.d.cts +0 -116
  74. package/dist/wow/model.d.ts +0 -116
  75. package/dist/wow/resolveWowModel.d.cts +0 -21
  76. package/dist/wow/resolveWowModel.d.ts +0 -21
@@ -1,116 +0,0 @@
1
- import { HTTPMethod, Operation, Parameter, Tag } from '@ahoo-wang/fetcher-openapi';
2
- import { AliasAggregate, Named } from '@ahoo-wang/wow-client';
3
- import { KeySchema } from '../openapi/components.cjs';
4
- export interface CommandDefinition extends Named {
5
- /**
6
- * The name of the command
7
- */
8
- name: string;
9
- /**
10
- * The HTTP method for the command
11
- */
12
- method: HTTPMethod;
13
- /**
14
- * The endpoint path for the command
15
- */
16
- path: string;
17
- /**
18
- * The path parameters for the command
19
- */
20
- pathParameters: Parameter[];
21
- summary?: string;
22
- description?: string;
23
- /**
24
- * The schema for the command body
25
- */
26
- schema: KeySchema;
27
- operation: Operation;
28
- }
29
- export interface EventDefinition extends Named {
30
- /**
31
- * The name of the event
32
- */
33
- name: string;
34
- /**
35
- * The title of the event
36
- */
37
- title: string;
38
- /**
39
- * The schema for the event body
40
- */
41
- schema: KeySchema;
42
- }
43
- export interface TagAliasAggregate extends AliasAggregate {
44
- tag: Tag;
45
- }
46
- /**
47
- * Complete definition of an aggregate including its commands, events, and state schemas.
48
- */
49
- export interface AggregateDefinition {
50
- /** The aggregate metadata with tag and alias information */
51
- aggregate: TagAliasAggregate;
52
- /**
53
- * The aggregate's route segment, which is its name unless the aggregate
54
- * sets a resource name: `sales-order` for the aggregate `order`.
55
- */
56
- resourceName: string;
57
- /**
58
- * The schema for the aggregate root state
59
- */
60
- state: KeySchema;
61
- /**
62
- * The fields schema for aggregate queries
63
- */
64
- fields: KeySchema;
65
- /**
66
- * Map of command names to command definitions
67
- */
68
- commands: Map<string, CommandDefinition>;
69
- /**
70
- * Map of event names to event definitions
71
- */
72
- events: Map<string, EventDefinition>;
73
- }
74
- /**
75
- * Map of context aliases to sets of aggregate definitions
76
- */
77
- export type BoundedContextAggregates = Map<string, Set<AggregateDefinition>>;
78
- /**
79
- * The doc comment the Wow metadata lends a schema: a command body takes its
80
- * operation's summary and description where it has none of its own, an event
81
- * body the title of its domain event. It holds every field the metadata
82
- * sets, in the order it sets them, so a model's doc reads the schema with
83
- * these over it the way it read the document the old resolver changed in
84
- * place: a field the schema lacks comes last, and an `undefined` one is left
85
- * out. The document itself is never changed.
86
- */
87
- export type SchemaDocOverride = Readonly<Partial<Record<'title' | 'description', string | undefined>>>;
88
- /** What the Wow metadata of a document says, read without changing it. */
89
- export interface WowModel {
90
- /** The bounded context the document names (`info.x-wow-context-alias`). */
91
- readonly contextAlias?: string;
92
- /** The aggregates that have state and query fields, by context alias. */
93
- readonly contexts: BoundedContextAggregates;
94
- /**
95
- * The tags of every aggregate that exposes a Wow route, resolved or not.
96
- * Their operations belong to command and query clients, not to API clients.
97
- */
98
- readonly aggregateTags: ReadonlySet<string>;
99
- /** The doc comments the metadata lends schemas, by component key. */
100
- readonly schemaDocOverrides: ReadonlyMap<string, SchemaDocOverride>;
101
- /** Aggregates and commands skipped for missing metadata, a warning each. */
102
- readonly warnings: readonly string[];
103
- }
104
- /**
105
- * Tells whether the document comes from a Wow service: it names its bounded
106
- * context, or it has aggregates.
107
- */
108
- export declare function isWowDocument(wow: Pick<WowModel, 'contextAlias' | 'aggregateTags'>): boolean;
109
- /**
110
- * A schema as a model's doc reads it: the schema with the doc comment the
111
- * Wow metadata lends it over it.
112
- *
113
- * @param schema - The schema, left unchanged
114
- * @param override - What the metadata lends it, if anything
115
- */
116
- export declare function withDocOverride<T extends object>(schema: T, override: SchemaDocOverride | undefined): T;
@@ -1,116 +0,0 @@
1
- import { HTTPMethod, Operation, Parameter, Tag } from '@ahoo-wang/fetcher-openapi';
2
- import { AliasAggregate, Named } from '@ahoo-wang/wow-client';
3
- import { KeySchema } from '../openapi/components.js';
4
- export interface CommandDefinition extends Named {
5
- /**
6
- * The name of the command
7
- */
8
- name: string;
9
- /**
10
- * The HTTP method for the command
11
- */
12
- method: HTTPMethod;
13
- /**
14
- * The endpoint path for the command
15
- */
16
- path: string;
17
- /**
18
- * The path parameters for the command
19
- */
20
- pathParameters: Parameter[];
21
- summary?: string;
22
- description?: string;
23
- /**
24
- * The schema for the command body
25
- */
26
- schema: KeySchema;
27
- operation: Operation;
28
- }
29
- export interface EventDefinition extends Named {
30
- /**
31
- * The name of the event
32
- */
33
- name: string;
34
- /**
35
- * The title of the event
36
- */
37
- title: string;
38
- /**
39
- * The schema for the event body
40
- */
41
- schema: KeySchema;
42
- }
43
- export interface TagAliasAggregate extends AliasAggregate {
44
- tag: Tag;
45
- }
46
- /**
47
- * Complete definition of an aggregate including its commands, events, and state schemas.
48
- */
49
- export interface AggregateDefinition {
50
- /** The aggregate metadata with tag and alias information */
51
- aggregate: TagAliasAggregate;
52
- /**
53
- * The aggregate's route segment, which is its name unless the aggregate
54
- * sets a resource name: `sales-order` for the aggregate `order`.
55
- */
56
- resourceName: string;
57
- /**
58
- * The schema for the aggregate root state
59
- */
60
- state: KeySchema;
61
- /**
62
- * The fields schema for aggregate queries
63
- */
64
- fields: KeySchema;
65
- /**
66
- * Map of command names to command definitions
67
- */
68
- commands: Map<string, CommandDefinition>;
69
- /**
70
- * Map of event names to event definitions
71
- */
72
- events: Map<string, EventDefinition>;
73
- }
74
- /**
75
- * Map of context aliases to sets of aggregate definitions
76
- */
77
- export type BoundedContextAggregates = Map<string, Set<AggregateDefinition>>;
78
- /**
79
- * The doc comment the Wow metadata lends a schema: a command body takes its
80
- * operation's summary and description where it has none of its own, an event
81
- * body the title of its domain event. It holds every field the metadata
82
- * sets, in the order it sets them, so a model's doc reads the schema with
83
- * these over it the way it read the document the old resolver changed in
84
- * place: a field the schema lacks comes last, and an `undefined` one is left
85
- * out. The document itself is never changed.
86
- */
87
- export type SchemaDocOverride = Readonly<Partial<Record<'title' | 'description', string | undefined>>>;
88
- /** What the Wow metadata of a document says, read without changing it. */
89
- export interface WowModel {
90
- /** The bounded context the document names (`info.x-wow-context-alias`). */
91
- readonly contextAlias?: string;
92
- /** The aggregates that have state and query fields, by context alias. */
93
- readonly contexts: BoundedContextAggregates;
94
- /**
95
- * The tags of every aggregate that exposes a Wow route, resolved or not.
96
- * Their operations belong to command and query clients, not to API clients.
97
- */
98
- readonly aggregateTags: ReadonlySet<string>;
99
- /** The doc comments the metadata lends schemas, by component key. */
100
- readonly schemaDocOverrides: ReadonlyMap<string, SchemaDocOverride>;
101
- /** Aggregates and commands skipped for missing metadata, a warning each. */
102
- readonly warnings: readonly string[];
103
- }
104
- /**
105
- * Tells whether the document comes from a Wow service: it names its bounded
106
- * context, or it has aggregates.
107
- */
108
- export declare function isWowDocument(wow: Pick<WowModel, 'contextAlias' | 'aggregateTags'>): boolean;
109
- /**
110
- * A schema as a model's doc reads it: the schema with the doc comment the
111
- * Wow metadata lends it over it.
112
- *
113
- * @param schema - The schema, left unchanged
114
- * @param override - What the metadata lends it, if anything
115
- */
116
- export declare function withDocOverride<T extends object>(schema: T, override: SchemaDocOverride | undefined): T;
@@ -1,21 +0,0 @@
1
- import { OpenApiDocument } from '../openapi/document.cjs';
2
- import { WowModel } from './model.cjs';
3
- /**
4
- * Reads the Wow metadata of a document: its bounded context, and each
5
- * aggregate its tags name with the aggregate's commands, events, state,
6
- * query fields and route segment.
7
- *
8
- * An aggregate needs its state (`snapshot_state.single`) and its query fields
9
- * (`snapshot.count`) to generate clients; one that lacks either is left out
10
- * with a warning, and so is a command whose body is not a component schema.
11
- *
12
- * It is a pure function: the document is left as it was. The doc comments the
13
- * metadata lends command and event bodies are in
14
- * {@link WowModel.schemaDocOverrides}.
15
- *
16
- * @param document - The document
17
- * @returns The Wow model, and the warnings to log
18
- * @throws GeneratorError (`specification`) when an aggregate's Wow metadata
19
- * is malformed, or a command's response references form a cycle
20
- */
21
- export declare function resolveWowModel(document: OpenApiDocument): WowModel;
@@ -1,21 +0,0 @@
1
- import { OpenApiDocument } from '../openapi/document.js';
2
- import { WowModel } from './model.js';
3
- /**
4
- * Reads the Wow metadata of a document: its bounded context, and each
5
- * aggregate its tags name with the aggregate's commands, events, state,
6
- * query fields and route segment.
7
- *
8
- * An aggregate needs its state (`snapshot_state.single`) and its query fields
9
- * (`snapshot.count`) to generate clients; one that lacks either is left out
10
- * with a warning, and so is a command whose body is not a component schema.
11
- *
12
- * It is a pure function: the document is left as it was. The doc comments the
13
- * metadata lends command and event bodies are in
14
- * {@link WowModel.schemaDocOverrides}.
15
- *
16
- * @param document - The document
17
- * @returns The Wow model, and the warnings to log
18
- * @throws GeneratorError (`specification`) when an aggregate's Wow metadata
19
- * is malformed, or a command's response references form a cycle
20
- */
21
- export declare function resolveWowModel(document: OpenApiDocument): WowModel;