@ahoo-wang/wow-generator 10.0.0-alpha.5 → 10.0.0-alpha.7

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.
@@ -2,9 +2,11 @@ import { ModuleSet } from '../emit/moduleBuilder.cjs';
2
2
  import { ManifestModel } from '../manifest/analyze.cjs';
3
3
  /** The entry of the client every generated module imports from. */
4
4
  export declare const WOW_CLIENT = "@ahoo-wang/wow-client";
5
+ /** The entry of the service routes' client. */
6
+ export declare const WOW_CLIENT_ROUTES = "@ahoo-wang/wow-client/routes";
5
7
  /**
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
+ * Describes every file a Manifest generates to its module: the types of each
9
+ * bounded context, its error codes and wait
8
10
  * helpers, and the aggregate, command and query clients of each aggregate,
9
11
  * all on `@ahoo-wang/wow-client`.
10
12
  *
@@ -2,9 +2,11 @@ import { ModuleSet } from '../emit/moduleBuilder.js';
2
2
  import { ManifestModel } from '../manifest/analyze.js';
3
3
  /** The entry of the client every generated module imports from. */
4
4
  export declare const WOW_CLIENT = "@ahoo-wang/wow-client";
5
+ /** The entry of the service routes' client. */
6
+ export declare const WOW_CLIENT_ROUTES = "@ahoo-wang/wow-client/routes";
5
7
  /**
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
+ * Describes every file a Manifest generates to its module: the types of each
9
+ * bounded context, its error codes and wait
8
10
  * helpers, and the aggregate, command and query clients of each aggregate,
9
11
  * all on `@ahoo-wang/wow-client`.
10
12
  *
package/dist/index.cjs CHANGED
@@ -1 +1 @@
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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./codeGenerator-C0dKAKl6.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-CU1TGcUI.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-Bouc_Ad8.js";
@@ -34,15 +34,20 @@ export type TextNumbersModel = true | {
34
34
  export interface CommandModel {
35
35
  readonly name: string;
36
36
  readonly method: string;
37
- /** The `PATHS` member of its route by id, and of its route without one. */
37
+ /** Its routes, as the Manifest lists them: the client sends it by them. */
38
+ readonly routes: readonly Route[];
39
+ /** Its route by id, and its route without one. */
38
40
  readonly byIdPath?: {
39
- readonly member: string;
40
41
  readonly path: string;
41
42
  };
42
43
  readonly unaddressedPath?: {
43
- readonly member: string;
44
44
  readonly path: string;
45
45
  };
46
+ /**
47
+ * Of an aggregate whose id is its owner's, the method that sends it by no id
48
+ * to the caller's own aggregate (`addItemOwn`); `method` then sends it by id.
49
+ */
50
+ readonly ownMethod?: string;
46
51
  /** The body's type name, or undefined when its schema is unknown. */
47
52
  readonly bodyType: string;
48
53
  /** The body may be left out: its schema requires nothing. */
@@ -55,6 +60,11 @@ export interface CommandModel {
55
60
  /** Its body has exact numbers, under `textNumbers.commands` of its aggregate. */
56
61
  readonly bodyNumbers?: boolean;
57
62
  }
63
+ /** A route of the Manifest: a method and a path, `{id}` the aggregate id. */
64
+ export interface Route {
65
+ readonly method: string;
66
+ readonly path: string;
67
+ }
58
68
  /** A lifecycle command an aggregate lists. */
59
69
  export interface LifecycleModel {
60
70
  /** `wow.lifecycle.DeleteAggregate`, … */
@@ -62,6 +72,13 @@ export interface LifecycleModel {
62
72
  /** The `LifecycleCommands` member. */
63
73
  readonly member: string;
64
74
  readonly method: string;
75
+ /** Its routes, as the Manifest lists them. */
76
+ readonly routes: readonly Route[];
77
+ /**
78
+ * Of an aggregate whose id is its owner's, the method that sends it by no id
79
+ * to the caller's own aggregate (`deleteAggregateOwn`).
80
+ */
81
+ readonly ownMethod?: string;
65
82
  /**
66
83
  * The body's type, or undefined for a command without one: the type
67
84
  * generated from the Manifest's `$defs` entry of the command's name when it
@@ -83,6 +100,11 @@ export interface AggregateModel {
83
100
  /** The directory of its modules, relative to the output directory. */
84
101
  readonly directory: string;
85
102
  readonly ownership: string;
103
+ /**
104
+ * Where its id comes from: `assigned`, or `owner` for one whose id is its
105
+ * owner's, whose commands and state read also go by no id to the caller's own.
106
+ */
107
+ readonly idSource: string;
86
108
  readonly snapshot: boolean;
87
109
  readonly stateType: string;
88
110
  readonly stateFields: readonly string[];
@@ -118,13 +140,34 @@ export interface ContextModel {
118
140
  readonly constantName: string;
119
141
  readonly directory: string;
120
142
  readonly errors: readonly {
121
- readonly member: string;
122
143
  readonly code: string;
123
144
  readonly status: number;
124
145
  readonly description?: string;
125
146
  }[];
126
147
  readonly subscriptions: readonly string[];
127
148
  readonly aggregates: readonly AggregateModel[];
149
+ /** Its service routes, in the Manifest's order. */
150
+ readonly routes: readonly ServiceRouteModel[];
151
+ }
152
+ /** A parameter of a service route: a path variable or a query parameter, and its TypeScript type. */
153
+ export interface RouteParameterModel {
154
+ readonly name: string;
155
+ readonly location: 'path' | 'query';
156
+ readonly type: string;
157
+ readonly required: boolean;
158
+ }
159
+ /** A service route: its name, where it is served, its parameters and the types of its body and its answer. */
160
+ export interface ServiceRouteModel {
161
+ readonly name: string;
162
+ readonly method: string;
163
+ readonly path: string;
164
+ readonly description?: string;
165
+ readonly deprecated: boolean;
166
+ readonly parameters: readonly RouteParameterModel[];
167
+ /** The body's type; absent when the route takes none. */
168
+ readonly requestType?: string;
169
+ /** The answer's type; absent when the route answers `204 No Content`. */
170
+ readonly responseType?: string;
128
171
  }
129
172
  /** What a Manifest generates, decided before anything is written. */
130
173
  export interface ManifestModel {
@@ -34,15 +34,20 @@ export type TextNumbersModel = true | {
34
34
  export interface CommandModel {
35
35
  readonly name: string;
36
36
  readonly method: string;
37
- /** The `PATHS` member of its route by id, and of its route without one. */
37
+ /** Its routes, as the Manifest lists them: the client sends it by them. */
38
+ readonly routes: readonly Route[];
39
+ /** Its route by id, and its route without one. */
38
40
  readonly byIdPath?: {
39
- readonly member: string;
40
41
  readonly path: string;
41
42
  };
42
43
  readonly unaddressedPath?: {
43
- readonly member: string;
44
44
  readonly path: string;
45
45
  };
46
+ /**
47
+ * Of an aggregate whose id is its owner's, the method that sends it by no id
48
+ * to the caller's own aggregate (`addItemOwn`); `method` then sends it by id.
49
+ */
50
+ readonly ownMethod?: string;
46
51
  /** The body's type name, or undefined when its schema is unknown. */
47
52
  readonly bodyType: string;
48
53
  /** The body may be left out: its schema requires nothing. */
@@ -55,6 +60,11 @@ export interface CommandModel {
55
60
  /** Its body has exact numbers, under `textNumbers.commands` of its aggregate. */
56
61
  readonly bodyNumbers?: boolean;
57
62
  }
63
+ /** A route of the Manifest: a method and a path, `{id}` the aggregate id. */
64
+ export interface Route {
65
+ readonly method: string;
66
+ readonly path: string;
67
+ }
58
68
  /** A lifecycle command an aggregate lists. */
59
69
  export interface LifecycleModel {
60
70
  /** `wow.lifecycle.DeleteAggregate`, … */
@@ -62,6 +72,13 @@ export interface LifecycleModel {
62
72
  /** The `LifecycleCommands` member. */
63
73
  readonly member: string;
64
74
  readonly method: string;
75
+ /** Its routes, as the Manifest lists them. */
76
+ readonly routes: readonly Route[];
77
+ /**
78
+ * Of an aggregate whose id is its owner's, the method that sends it by no id
79
+ * to the caller's own aggregate (`deleteAggregateOwn`).
80
+ */
81
+ readonly ownMethod?: string;
65
82
  /**
66
83
  * The body's type, or undefined for a command without one: the type
67
84
  * generated from the Manifest's `$defs` entry of the command's name when it
@@ -83,6 +100,11 @@ export interface AggregateModel {
83
100
  /** The directory of its modules, relative to the output directory. */
84
101
  readonly directory: string;
85
102
  readonly ownership: string;
103
+ /**
104
+ * Where its id comes from: `assigned`, or `owner` for one whose id is its
105
+ * owner's, whose commands and state read also go by no id to the caller's own.
106
+ */
107
+ readonly idSource: string;
86
108
  readonly snapshot: boolean;
87
109
  readonly stateType: string;
88
110
  readonly stateFields: readonly string[];
@@ -118,13 +140,34 @@ export interface ContextModel {
118
140
  readonly constantName: string;
119
141
  readonly directory: string;
120
142
  readonly errors: readonly {
121
- readonly member: string;
122
143
  readonly code: string;
123
144
  readonly status: number;
124
145
  readonly description?: string;
125
146
  }[];
126
147
  readonly subscriptions: readonly string[];
127
148
  readonly aggregates: readonly AggregateModel[];
149
+ /** Its service routes, in the Manifest's order. */
150
+ readonly routes: readonly ServiceRouteModel[];
151
+ }
152
+ /** A parameter of a service route: a path variable or a query parameter, and its TypeScript type. */
153
+ export interface RouteParameterModel {
154
+ readonly name: string;
155
+ readonly location: 'path' | 'query';
156
+ readonly type: string;
157
+ readonly required: boolean;
158
+ }
159
+ /** A service route: its name, where it is served, its parameters and the types of its body and its answer. */
160
+ export interface ServiceRouteModel {
161
+ readonly name: string;
162
+ readonly method: string;
163
+ readonly path: string;
164
+ readonly description?: string;
165
+ readonly deprecated: boolean;
166
+ readonly parameters: readonly RouteParameterModel[];
167
+ /** The body's type; absent when the route takes none. */
168
+ readonly requestType?: string;
169
+ /** The answer's type; absent when the route answers `204 No Content`. */
170
+ readonly responseType?: string;
128
171
  }
129
172
  /** What a Manifest generates, decided before anything is written. */
130
173
  export interface ManifestModel {
@@ -1,74 +1,24 @@
1
+ import { AggregateManifest, CommandManifest, ContextManifest, ErrorManifest, EventManifest, Manifest } from '@ahoo-wang/wow-client';
1
2
  /**
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.
3
+ * A Wow V10 service Manifest (`GET /wow/manifest`, or the merged
4
+ * `manifest.json` of the build), typed as `@ahoo-wang/wow-client` types it:
5
+ * generated from the Manifest's own JSON Schema, so the generator reads the
6
+ * format as it is.
5
7
  */
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
- }
8
+ export type ManifestDocument = Manifest;
16
9
  /** 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
- }
10
+ export type ManifestContext = ContextManifest;
26
11
  /** 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
- }
12
+ export type ManifestAggregate = AggregateManifest;
44
13
  /** 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
- }
14
+ export type ManifestCommand = CommandManifest;
57
15
  /** An event of an aggregate. */
58
- export interface ManifestEvent {
59
- readonly name: string;
60
- readonly revision?: number;
61
- readonly schema: string;
62
- }
16
+ export type ManifestEvent = EventManifest;
63
17
  /** An error code of the Manifest. */
64
- export interface ManifestError {
65
- readonly code: string;
66
- readonly status: number;
67
- readonly description?: string;
68
- }
18
+ export type ManifestError = ErrorManifest;
69
19
  /** A JSON Schema 2020-12 of `$defs`, as the Manifest writes them. */
70
20
  export type JsonSchema = Readonly<Record<string, unknown>>;
71
- /** The Manifest format the generator reads (decision D59). */
21
+ /** The Manifest format the generator reads. */
72
22
  export declare const MANIFEST_FORMAT = 1;
73
23
  /** The `$defs` key a schema reference points to, or undefined for another. */
74
24
  export declare function schemaKey(ref: string): string | undefined;
@@ -1,74 +1,24 @@
1
+ import { AggregateManifest, CommandManifest, ContextManifest, ErrorManifest, EventManifest, Manifest } from '@ahoo-wang/wow-client';
1
2
  /**
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.
3
+ * A Wow V10 service Manifest (`GET /wow/manifest`, or the merged
4
+ * `manifest.json` of the build), typed as `@ahoo-wang/wow-client` types it:
5
+ * generated from the Manifest's own JSON Schema, so the generator reads the
6
+ * format as it is.
5
7
  */
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
- }
8
+ export type ManifestDocument = Manifest;
16
9
  /** 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
- }
10
+ export type ManifestContext = ContextManifest;
26
11
  /** 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
- }
12
+ export type ManifestAggregate = AggregateManifest;
44
13
  /** 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
- }
14
+ export type ManifestCommand = CommandManifest;
57
15
  /** An event of an aggregate. */
58
- export interface ManifestEvent {
59
- readonly name: string;
60
- readonly revision?: number;
61
- readonly schema: string;
62
- }
16
+ export type ManifestEvent = EventManifest;
63
17
  /** An error code of the Manifest. */
64
- export interface ManifestError {
65
- readonly code: string;
66
- readonly status: number;
67
- readonly description?: string;
68
- }
18
+ export type ManifestError = ErrorManifest;
69
19
  /** A JSON Schema 2020-12 of `$defs`, as the Manifest writes them. */
70
20
  export type JsonSchema = Readonly<Record<string, unknown>>;
71
- /** The Manifest format the generator reads (decision D59). */
21
+ /** The Manifest format the generator reads. */
72
22
  export declare const MANIFEST_FORMAT = 1;
73
23
  /** The `$defs` key a schema reference points to, or undefined for another. */
74
24
  export declare function schemaKey(ref: string): string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahoo-wang/wow-generator",
3
- "version": "10.0.0-alpha.5",
3
+ "version": "10.0.0-alpha.7",
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",
@@ -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.5"
67
+ "@ahoo-wang/wow-client": "~10.0.0-alpha.7"
68
68
  },
69
69
  "dependencies": {
70
70
  "ts-morph": "^28.0.0",
@@ -78,19 +78,19 @@
78
78
  "@ahoo-wang/fetcher-openapi": "^6.0.1",
79
79
  "@eslint/js": "^10.0.1",
80
80
  "@types/node": "^26.6.5",
81
- "@vitest/coverage-v8": "4.1.11",
82
- "@vitest/ui": "^4.1.11",
81
+ "@vitest/coverage-v8": "4.1.12",
82
+ "@vitest/ui": "^4.1.12",
83
83
  "eslint": "^10.13.0",
84
84
  "eslint-plugin-import-x": "^4.17.1",
85
85
  "globals": "^17.13.0",
86
- "prettier": "3.9.9",
86
+ "prettier": "3.9.10",
87
87
  "typescript": "~6.0.3",
88
- "typescript-eslint": "^8.71.1",
88
+ "typescript-eslint": "^8.72.0",
89
89
  "unplugin-dts": "1.1.2",
90
- "vite": "8.3.4",
90
+ "vite": "8.3.5",
91
91
  "vite-bundle-analyzer": "^1.3.9",
92
- "vitest": "^4.1.11",
93
- "@ahoo-wang/wow-client": "~10.0.0-alpha.5"
92
+ "vitest": "^4.1.12",
93
+ "@ahoo-wang/wow-client": "~10.0.0-alpha.7"
94
94
  },
95
95
  "scripts": {
96
96
  "build": "vite build && pnpm test:package",