@ahoo-wang/wow-client 10.0.0-alpha.6 → 10.0.0-beta.1

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 (198) hide show
  1. package/README.md +77 -23
  2. package/README.zh-CN.md +67 -19
  3. package/dist/commands.cjs +1 -1
  4. package/dist/commands.cjs.map +1 -1
  5. package/dist/commands.d.cts +134 -61
  6. package/dist/commands.d.ts +134 -61
  7. package/dist/commands.es.js +129 -59
  8. package/dist/commands.es.js.map +1 -1
  9. package/dist/developmentCaller.cjs +2 -0
  10. package/dist/developmentCaller.cjs.map +1 -0
  11. package/dist/developmentCaller.d.cts +61 -0
  12. package/dist/developmentCaller.d.ts +61 -0
  13. package/dist/developmentCaller.es.js +26 -0
  14. package/dist/developmentCaller.es.js.map +1 -0
  15. package/dist/dsl/aggregation/admit.cjs +1 -1
  16. package/dist/dsl/aggregation/admit.cjs.map +1 -1
  17. package/dist/dsl/aggregation/admit.es.js +93 -93
  18. package/dist/dsl/aggregation/admit.es.js.map +1 -1
  19. package/dist/dsl/aggregation/builders.cjs +1 -1
  20. package/dist/dsl/aggregation/builders.cjs.map +1 -1
  21. package/dist/dsl/aggregation/builders.d.cts +20 -20
  22. package/dist/dsl/aggregation/builders.d.ts +20 -20
  23. package/dist/dsl/aggregation/builders.es.js +88 -88
  24. package/dist/dsl/aggregation/builders.es.js.map +1 -1
  25. package/dist/dsl/aggregation/derived.cjs.map +1 -1
  26. package/dist/dsl/aggregation/derived.d.cts +8 -8
  27. package/dist/dsl/aggregation/derived.d.ts +8 -8
  28. package/dist/dsl/aggregation/derived.es.js +1 -2
  29. package/dist/dsl/aggregation/derived.es.js.map +1 -1
  30. package/dist/dsl/aggregation/expressionTrees.cjs.map +1 -1
  31. package/dist/dsl/aggregation/expressionTrees.es.js +1 -2
  32. package/dist/dsl/aggregation/having.cjs +1 -1
  33. package/dist/dsl/aggregation/having.cjs.map +1 -1
  34. package/dist/dsl/aggregation/having.d.cts +12 -12
  35. package/dist/dsl/aggregation/having.d.ts +12 -12
  36. package/dist/dsl/aggregation/having.es.js +33 -33
  37. package/dist/dsl/aggregation/having.es.js.map +1 -1
  38. package/dist/dsl/aggregation/sort.cjs.map +1 -1
  39. package/dist/dsl/aggregation/sort.es.js +1 -2
  40. package/dist/dsl/aggregation/types.cjs +1 -1
  41. package/dist/dsl/aggregation/types.cjs.map +1 -1
  42. package/dist/dsl/aggregation/types.d.cts +69 -69
  43. package/dist/dsl/aggregation/types.d.ts +69 -69
  44. package/dist/dsl/aggregation/types.es.js +15 -16
  45. package/dist/dsl/aggregation/types.es.js.map +1 -1
  46. package/dist/dsl/constantName.cjs +2 -0
  47. package/dist/dsl/constantName.cjs.map +1 -0
  48. package/dist/dsl/constantName.d.cts +9 -0
  49. package/dist/dsl/constantName.d.ts +9 -0
  50. package/dist/dsl/constantName.es.js +7 -0
  51. package/dist/dsl/constantName.es.js.map +1 -0
  52. package/dist/dsl/cursorQuery.cjs.map +1 -1
  53. package/dist/dsl/cursorQuery.es.js +1 -2
  54. package/dist/dsl/deletionState.cjs +1 -1
  55. package/dist/dsl/deletionState.cjs.map +1 -1
  56. package/dist/dsl/deletionState.d.cts +3 -3
  57. package/dist/dsl/deletionState.d.ts +3 -3
  58. package/dist/dsl/deletionState.es.js +2 -3
  59. package/dist/dsl/deletionState.es.js.map +1 -1
  60. package/dist/dsl/descriptor.cjs +1 -1
  61. package/dist/dsl/descriptor.cjs.map +1 -1
  62. package/dist/dsl/descriptor.d.cts +99 -42
  63. package/dist/dsl/descriptor.d.ts +99 -42
  64. package/dist/dsl/descriptor.es.js +37 -29
  65. package/dist/dsl/descriptor.es.js.map +1 -1
  66. package/dist/dsl/field.cjs.map +1 -1
  67. package/dist/dsl/field.es.js +1 -2
  68. package/dist/dsl/filter/builders.cjs +1 -1
  69. package/dist/dsl/filter/builders.cjs.map +1 -1
  70. package/dist/dsl/filter/builders.d.cts +53 -53
  71. package/dist/dsl/filter/builders.d.ts +53 -53
  72. package/dist/dsl/filter/builders.es.js +111 -111
  73. package/dist/dsl/filter/builders.es.js.map +1 -1
  74. package/dist/dsl/filter/datePattern.cjs.map +1 -1
  75. package/dist/dsl/filter/datePattern.es.js +1 -2
  76. package/dist/dsl/filter/operator.cjs +1 -1
  77. package/dist/dsl/filter/operator.cjs.map +1 -1
  78. package/dist/dsl/filter/operator.d.cts +57 -57
  79. package/dist/dsl/filter/operator.d.ts +57 -57
  80. package/dist/dsl/filter/operator.es.js +4 -5
  81. package/dist/dsl/filter/operator.es.js.map +1 -1
  82. package/dist/dsl/filter/scope.cjs +1 -1
  83. package/dist/dsl/filter/scope.cjs.map +1 -1
  84. package/dist/dsl/filter/scope.es.js +12 -12
  85. package/dist/dsl/filter/scope.es.js.map +1 -1
  86. package/dist/dsl/filter/validate.cjs +1 -1
  87. package/dist/dsl/filter/validate.cjs.map +1 -1
  88. package/dist/dsl/filter/validate.es.js +23 -23
  89. package/dist/dsl/filter/validate.es.js.map +1 -1
  90. package/dist/dsl/pagination.cjs.map +1 -1
  91. package/dist/dsl/pagination.es.js +1 -2
  92. package/dist/dsl/projection.cjs.map +1 -1
  93. package/dist/dsl/projection.d.cts +1 -1
  94. package/dist/dsl/projection.d.ts +1 -1
  95. package/dist/dsl/projection.es.js +1 -2
  96. package/dist/dsl/projection.es.js.map +1 -1
  97. package/dist/dsl/queryErrorCodes.cjs +1 -1
  98. package/dist/dsl/queryErrorCodes.cjs.map +1 -1
  99. package/dist/dsl/queryErrorCodes.d.cts +59 -48
  100. package/dist/dsl/queryErrorCodes.d.ts +59 -48
  101. package/dist/dsl/queryErrorCodes.es.js +51 -50
  102. package/dist/dsl/queryErrorCodes.es.js.map +1 -1
  103. package/dist/dsl/queryable.cjs +1 -1
  104. package/dist/dsl/queryable.cjs.map +1 -1
  105. package/dist/dsl/queryable.d.cts +25 -21
  106. package/dist/dsl/queryable.d.ts +25 -21
  107. package/dist/dsl/queryable.es.js +5 -5
  108. package/dist/dsl/queryable.es.js.map +1 -1
  109. package/dist/dsl/sort.cjs +1 -1
  110. package/dist/dsl/sort.cjs.map +1 -1
  111. package/dist/dsl/sort.d.cts +2 -2
  112. package/dist/dsl/sort.d.ts +2 -2
  113. package/dist/dsl/sort.es.js +4 -5
  114. package/dist/dsl/sort.es.js.map +1 -1
  115. package/dist/dsl.cjs +1 -1
  116. package/dist/dsl.es.js +3 -3
  117. package/dist/exactJson.cjs.map +1 -1
  118. package/dist/exactJson.d.cts +4 -4
  119. package/dist/exactJson.d.ts +4 -4
  120. package/dist/exactJson.es.js +1 -2
  121. package/dist/exactJson.es.js.map +1 -1
  122. package/dist/frameworkErrors.cjs +2 -0
  123. package/dist/frameworkErrors.cjs.map +1 -0
  124. package/dist/frameworkErrors.d.cts +121 -0
  125. package/dist/frameworkErrors.d.ts +121 -0
  126. package/dist/frameworkErrors.es.js +95 -0
  127. package/dist/frameworkErrors.es.js.map +1 -0
  128. package/dist/http.cjs +1 -1
  129. package/dist/http.cjs.map +1 -1
  130. package/dist/http.d.cts +4 -7
  131. package/dist/http.d.ts +4 -7
  132. package/dist/http.es.js +12 -20
  133. package/dist/http.es.js.map +1 -1
  134. package/dist/index.cjs +1 -1
  135. package/dist/index.d.cts +9 -7
  136. package/dist/index.d.ts +9 -7
  137. package/dist/index.es.js +11 -9
  138. package/dist/manifest.cjs +1 -1
  139. package/dist/manifest.cjs.map +1 -1
  140. package/dist/manifest.d.cts +37 -95
  141. package/dist/manifest.d.ts +37 -95
  142. package/dist/manifest.es.js +12 -7
  143. package/dist/manifest.es.js.map +1 -1
  144. package/dist/manifestTypes.d.cts +195 -0
  145. package/dist/manifestTypes.d.ts +195 -0
  146. package/dist/problem.cjs +1 -1
  147. package/dist/problem.cjs.map +1 -1
  148. package/dist/problem.d.cts +76 -115
  149. package/dist/problem.d.ts +76 -115
  150. package/dist/problem.es.js +45 -80
  151. package/dist/problem.es.js.map +1 -1
  152. package/dist/queries.cjs +1 -1
  153. package/dist/queries.cjs.map +1 -1
  154. package/dist/queries.d.cts +28 -51
  155. package/dist/queries.d.ts +28 -51
  156. package/dist/queries.es.js +49 -40
  157. package/dist/queries.es.js.map +1 -1
  158. package/dist/routes.cjs +2 -0
  159. package/dist/routes.cjs.map +1 -0
  160. package/dist/routes.d.cts +49 -0
  161. package/dist/routes.d.ts +49 -0
  162. package/dist/routes.es.js +33 -0
  163. package/dist/routes.es.js.map +1 -0
  164. package/dist/state.cjs +1 -1
  165. package/dist/state.cjs.map +1 -1
  166. package/dist/state.d.cts +56 -11
  167. package/dist/state.d.ts +56 -11
  168. package/dist/state.es.js +56 -21
  169. package/dist/state.es.js.map +1 -1
  170. package/dist/streams.cjs +1 -1
  171. package/dist/streams.cjs.map +1 -1
  172. package/dist/streams.d.cts +17 -13
  173. package/dist/streams.d.ts +17 -13
  174. package/dist/streams.es.js +50 -50
  175. package/dist/streams.es.js.map +1 -1
  176. package/dist/testing/wire.cjs +2 -0
  177. package/dist/testing/wire.cjs.map +1 -0
  178. package/dist/testing/wire.d.cts +29 -0
  179. package/dist/testing/wire.d.ts +29 -0
  180. package/dist/testing/wire.es.js +88 -0
  181. package/dist/testing/wire.es.js.map +1 -0
  182. package/dist/testing.cjs +1 -0
  183. package/dist/testing.d.cts +12 -0
  184. package/dist/testing.d.ts +12 -0
  185. package/dist/testing.es.js +3 -0
  186. package/dist/wait.cjs +1 -1
  187. package/dist/wait.cjs.map +1 -1
  188. package/dist/wait.d.cts +68 -19
  189. package/dist/wait.d.ts +68 -19
  190. package/dist/wait.es.js +61 -14
  191. package/dist/wait.es.js.map +1 -1
  192. package/dist/wire.cjs +1 -1
  193. package/dist/wire.cjs.map +1 -1
  194. package/dist/wire.d.cts +101 -50
  195. package/dist/wire.d.ts +101 -50
  196. package/dist/wire.es.js +17 -6
  197. package/dist/wire.es.js.map +1 -1
  198. package/package.json +23 -3
@@ -1,105 +1,47 @@
1
1
  import { RequestOptions, WowClientOptions } from './http.cjs';
2
- import { Ownership } from './wire.cjs';
3
- /** A route of the Manifest: a method and a path, `{id}` the aggregate id. */
4
- export interface RouteManifest {
5
- readonly method: string;
6
- readonly path: string;
7
- }
2
+ import { AggregateManifest, CommandManifest, ContextManifest, Manifest, ServiceRouteManifest } from './manifestTypes.cjs';
3
+ export type * from './manifestTypes.cjs';
8
4
  /** Whether a command creates its aggregate. */
9
- export type Creation = 'NONE' | 'REQUIRED' | 'ALLOWED';
10
- /** A command of an aggregate (decisions D104, D176, D182). */
11
- export interface CommandManifest {
12
- readonly name: string;
13
- readonly aliases?: readonly string[];
14
- /** `#/$defs/<key>`. */
15
- readonly schema: string;
16
- readonly creation?: Creation;
17
- readonly produces?: readonly string[];
18
- readonly routes?: readonly RouteManifest[];
19
- readonly mounted?: boolean;
20
- readonly transformsTo?: readonly string[];
21
- }
22
- /** An event of an aggregate and its revision. */
23
- export interface EventManifest {
24
- readonly name: string;
25
- readonly aliases?: readonly string[];
26
- readonly revision?: number;
27
- readonly schema: string;
28
- }
29
- /** A query model of an aggregate: `snapshot` or `events` (decision D128). */
30
- export interface QueryManifest {
31
- readonly model: string;
32
- readonly routes?: readonly RouteManifest[];
33
- }
34
- /** An aggregate of a bounded context. */
35
- export interface AggregateManifest {
36
- readonly name: string;
37
- readonly description?: string;
38
- readonly state: {
39
- readonly schema: string;
40
- readonly fingerprint?: string;
41
- };
42
- readonly snapshot?: {
43
- readonly enabled?: boolean;
44
- };
45
- readonly commands?: readonly CommandManifest[];
46
- readonly events?: readonly EventManifest[];
47
- readonly lifecycle?: readonly string[];
48
- readonly queries?: readonly QueryManifest[];
49
- readonly schedules?: readonly string[];
50
- readonly ownership?: Ownership;
51
- }
52
- /** A subscription of a bounded context (design 04 §1). */
53
- export interface SubscriptionManifest {
54
- /** `processor.function`, as a `handled` hop names it. */
55
- readonly name: string;
56
- readonly kind: 'PROJECTION' | 'REACTOR' | 'SAGA';
57
- readonly source: {
58
- readonly context?: string;
59
- readonly aggregates?: readonly string[];
60
- readonly events?: readonly string[];
61
- };
62
- readonly derives?: readonly string[];
63
- readonly rejected?: readonly string[];
64
- readonly committed?: readonly string[];
65
- readonly [property: string]: unknown;
66
- }
67
- /** An error code and the HTTP status it is answered with. */
68
- export interface ErrorManifest {
69
- readonly code: string;
70
- readonly status: number;
71
- readonly description?: string;
72
- }
73
- /** A bounded context of the Manifest. */
74
- export interface ContextManifest {
75
- readonly name: string;
76
- readonly description?: string;
77
- readonly aggregates?: readonly AggregateManifest[];
78
- readonly subscriptions?: readonly SubscriptionManifest[];
79
- readonly published?: readonly {
80
- readonly aggregate: string;
81
- readonly topic: string;
82
- readonly includeState?: boolean;
83
- }[];
84
- readonly errors?: readonly ErrorManifest[];
85
- }
5
+ export type Creation = CommandManifest['creation'];
86
6
  /**
87
- * A service's Manifest (decisions D17, D73–D76): its contexts, aggregates,
88
- * commands, events, routes and error codes, and the JSON Schemas they refer
89
- * to under `$defs`. `wow-generator` generates typed clients from it.
7
+ * A command as a {@link RoutingManifest} lists it: its name, former names and
8
+ * routes, and the property of its body that names its aggregate, for a command
9
+ * whose body does (`idProperty`).
90
10
  */
91
- export interface Manifest {
92
- readonly format: number;
93
- readonly service?: {
94
- readonly name: string;
95
- readonly version?: string;
96
- };
97
- readonly contexts: readonly ContextManifest[];
98
- readonly errors?: readonly ErrorManifest[];
99
- readonly $defs?: Readonly<Record<string, unknown>>;
11
+ export type RoutingCommand = Pick<CommandManifest, 'name' | 'routes'> & Partial<Pick<CommandManifest, 'aliases' | 'idProperty'>>;
12
+ /** A service route as a {@link RoutingManifest} lists it: its name and its route. */
13
+ export type RoutingServiceRoute = Pick<ServiceRouteManifest, 'name' | 'route'>;
14
+ /**
15
+ * What a `CommandClient` reads of a Manifest to send a command: each
16
+ * context's aggregates and their commands with their routes, and the context's
17
+ * own system commands; and what a `ServiceRoutes` reads to call a service
18
+ * route: the context's routes. A whole {@link Manifest} is one; a generated
19
+ * client carries its service's as data (`manifest.ts`), with no schema.
20
+ */
21
+ export interface RoutingManifest extends Pick<Manifest, 'format' | 'requires'> {
22
+ readonly contexts: readonly (Pick<ContextManifest, 'name'> & {
23
+ readonly aggregates?: readonly (Pick<AggregateManifest, 'name'> & {
24
+ readonly commands?: readonly RoutingCommand[];
25
+ })[];
26
+ readonly commands?: readonly RoutingCommand[];
27
+ readonly routes?: readonly RoutingServiceRoute[];
28
+ })[];
100
29
  }
101
30
  /** The format of the Manifest this client reads. */
102
31
  export declare const MANIFEST_FORMAT = 1;
32
+ /**
33
+ * The markers of a Manifest's `requires` this client understands, as the
34
+ * Kotlin reader's `ManifestFeatures`: none yet.
35
+ */
36
+ export declare const MANIFEST_FEATURES: ReadonlySet<string>;
37
+ /**
38
+ * Checks that this client can read `manifest`: its format, and every marker it
39
+ * requires.
40
+ *
41
+ * @param manifest - The Manifest
42
+ * @throws TypeError naming what this client does not understand
43
+ */
44
+ export declare function checkManifest<M extends RoutingManifest>(manifest: M): M;
103
45
  /**
104
46
  * The service's Manifest, `GET /wow/manifest`, authorized as any API.
105
47
  *
@@ -1,105 +1,47 @@
1
1
  import { RequestOptions, WowClientOptions } from './http.js';
2
- import { Ownership } from './wire.js';
3
- /** A route of the Manifest: a method and a path, `{id}` the aggregate id. */
4
- export interface RouteManifest {
5
- readonly method: string;
6
- readonly path: string;
7
- }
2
+ import { AggregateManifest, CommandManifest, ContextManifest, Manifest, ServiceRouteManifest } from './manifestTypes.js';
3
+ export type * from './manifestTypes.js';
8
4
  /** Whether a command creates its aggregate. */
9
- export type Creation = 'NONE' | 'REQUIRED' | 'ALLOWED';
10
- /** A command of an aggregate (decisions D104, D176, D182). */
11
- export interface CommandManifest {
12
- readonly name: string;
13
- readonly aliases?: readonly string[];
14
- /** `#/$defs/<key>`. */
15
- readonly schema: string;
16
- readonly creation?: Creation;
17
- readonly produces?: readonly string[];
18
- readonly routes?: readonly RouteManifest[];
19
- readonly mounted?: boolean;
20
- readonly transformsTo?: readonly string[];
21
- }
22
- /** An event of an aggregate and its revision. */
23
- export interface EventManifest {
24
- readonly name: string;
25
- readonly aliases?: readonly string[];
26
- readonly revision?: number;
27
- readonly schema: string;
28
- }
29
- /** A query model of an aggregate: `snapshot` or `events` (decision D128). */
30
- export interface QueryManifest {
31
- readonly model: string;
32
- readonly routes?: readonly RouteManifest[];
33
- }
34
- /** An aggregate of a bounded context. */
35
- export interface AggregateManifest {
36
- readonly name: string;
37
- readonly description?: string;
38
- readonly state: {
39
- readonly schema: string;
40
- readonly fingerprint?: string;
41
- };
42
- readonly snapshot?: {
43
- readonly enabled?: boolean;
44
- };
45
- readonly commands?: readonly CommandManifest[];
46
- readonly events?: readonly EventManifest[];
47
- readonly lifecycle?: readonly string[];
48
- readonly queries?: readonly QueryManifest[];
49
- readonly schedules?: readonly string[];
50
- readonly ownership?: Ownership;
51
- }
52
- /** A subscription of a bounded context (design 04 §1). */
53
- export interface SubscriptionManifest {
54
- /** `processor.function`, as a `handled` hop names it. */
55
- readonly name: string;
56
- readonly kind: 'PROJECTION' | 'REACTOR' | 'SAGA';
57
- readonly source: {
58
- readonly context?: string;
59
- readonly aggregates?: readonly string[];
60
- readonly events?: readonly string[];
61
- };
62
- readonly derives?: readonly string[];
63
- readonly rejected?: readonly string[];
64
- readonly committed?: readonly string[];
65
- readonly [property: string]: unknown;
66
- }
67
- /** An error code and the HTTP status it is answered with. */
68
- export interface ErrorManifest {
69
- readonly code: string;
70
- readonly status: number;
71
- readonly description?: string;
72
- }
73
- /** A bounded context of the Manifest. */
74
- export interface ContextManifest {
75
- readonly name: string;
76
- readonly description?: string;
77
- readonly aggregates?: readonly AggregateManifest[];
78
- readonly subscriptions?: readonly SubscriptionManifest[];
79
- readonly published?: readonly {
80
- readonly aggregate: string;
81
- readonly topic: string;
82
- readonly includeState?: boolean;
83
- }[];
84
- readonly errors?: readonly ErrorManifest[];
85
- }
5
+ export type Creation = CommandManifest['creation'];
86
6
  /**
87
- * A service's Manifest (decisions D17, D73–D76): its contexts, aggregates,
88
- * commands, events, routes and error codes, and the JSON Schemas they refer
89
- * to under `$defs`. `wow-generator` generates typed clients from it.
7
+ * A command as a {@link RoutingManifest} lists it: its name, former names and
8
+ * routes, and the property of its body that names its aggregate, for a command
9
+ * whose body does (`idProperty`).
90
10
  */
91
- export interface Manifest {
92
- readonly format: number;
93
- readonly service?: {
94
- readonly name: string;
95
- readonly version?: string;
96
- };
97
- readonly contexts: readonly ContextManifest[];
98
- readonly errors?: readonly ErrorManifest[];
99
- readonly $defs?: Readonly<Record<string, unknown>>;
11
+ export type RoutingCommand = Pick<CommandManifest, 'name' | 'routes'> & Partial<Pick<CommandManifest, 'aliases' | 'idProperty'>>;
12
+ /** A service route as a {@link RoutingManifest} lists it: its name and its route. */
13
+ export type RoutingServiceRoute = Pick<ServiceRouteManifest, 'name' | 'route'>;
14
+ /**
15
+ * What a `CommandClient` reads of a Manifest to send a command: each
16
+ * context's aggregates and their commands with their routes, and the context's
17
+ * own system commands; and what a `ServiceRoutes` reads to call a service
18
+ * route: the context's routes. A whole {@link Manifest} is one; a generated
19
+ * client carries its service's as data (`manifest.ts`), with no schema.
20
+ */
21
+ export interface RoutingManifest extends Pick<Manifest, 'format' | 'requires'> {
22
+ readonly contexts: readonly (Pick<ContextManifest, 'name'> & {
23
+ readonly aggregates?: readonly (Pick<AggregateManifest, 'name'> & {
24
+ readonly commands?: readonly RoutingCommand[];
25
+ })[];
26
+ readonly commands?: readonly RoutingCommand[];
27
+ readonly routes?: readonly RoutingServiceRoute[];
28
+ })[];
100
29
  }
101
30
  /** The format of the Manifest this client reads. */
102
31
  export declare const MANIFEST_FORMAT = 1;
32
+ /**
33
+ * The markers of a Manifest's `requires` this client understands, as the
34
+ * Kotlin reader's `ManifestFeatures`: none yet.
35
+ */
36
+ export declare const MANIFEST_FEATURES: ReadonlySet<string>;
37
+ /**
38
+ * Checks that this client can read `manifest`: its format, and every marker it
39
+ * requires.
40
+ *
41
+ * @param manifest - The Manifest
42
+ * @throws TypeError naming what this client does not understand
43
+ */
44
+ export declare function checkManifest<M extends RoutingManifest>(manifest: M): M;
103
45
  /**
104
46
  * The service's Manifest, `GET /wow/manifest`, authorized as any API.
105
47
  *
@@ -1,14 +1,19 @@
1
1
  import { json as e, send as t } from "./http.es.js";
2
- //#region src/manifest.ts
3
- var n = 1;
4
- async function r(n = {}, r) {
5
- return e(await t(n, {
2
+ // src/manifest.ts
3
+ var n = 1, r = /* @__PURE__ */ new Set();
4
+ function i(e) {
5
+ if (e.format !== 1) throw TypeError(`The Manifest is of format ${e.format}; this client reads format 1.`);
6
+ let t = (e.requires ?? []).filter((e) => !r.has(e));
7
+ if (t.length > 0) throw TypeError(`The Manifest requires ${t.join(", ")}, which this client does not understand: use a newer @ahoo-wang/wow-client.`);
8
+ return e;
9
+ }
10
+ async function a(n = {}, r) {
11
+ return i(await e(await t(n, {
6
12
  method: "GET",
7
13
  path: "/wow/manifest",
8
14
  options: r
9
- }));
15
+ })));
10
16
  }
11
- //#endregion
12
- export { n as MANIFEST_FORMAT, r as fetchManifest };
17
+ export { r as MANIFEST_FEATURES, n as MANIFEST_FORMAT, i as checkManifest, a as fetchManifest };
13
18
 
14
19
  //# sourceMappingURL=manifest.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.es.js","names":["MANIFEST_FORMAT","fetchManifest","json","send","client"],"sources":["../src/manifest.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n json,\n type RequestOptions,\n send,\n type WowClientOptions,\n} from './http.js';\nimport type { Ownership } from './wire.js';\n\n/** A route of the Manifest: a method and a path, `{id}` the aggregate id. */\nexport interface RouteManifest {\n readonly method: string;\n readonly path: string;\n}\n\n/** Whether a command creates its aggregate. */\nexport type Creation = 'NONE' | 'REQUIRED' | 'ALLOWED';\n\n/** A command of an aggregate (decisions D104, D176, D182). */\nexport interface CommandManifest {\n readonly name: string;\n readonly aliases?: readonly string[];\n /** `#/$defs/<key>`. */\n readonly schema: string;\n readonly creation?: Creation;\n readonly produces?: readonly string[];\n readonly routes?: readonly RouteManifest[];\n readonly mounted?: boolean;\n readonly transformsTo?: readonly string[];\n}\n\n/** An event of an aggregate and its revision. */\nexport interface EventManifest {\n readonly name: string;\n readonly aliases?: readonly string[];\n readonly revision?: number;\n readonly schema: string;\n}\n\n/** A query model of an aggregate: `snapshot` or `events` (decision D128). */\nexport interface QueryManifest {\n readonly model: string;\n readonly routes?: readonly RouteManifest[];\n}\n\n/** An aggregate of a bounded context. */\nexport interface AggregateManifest {\n readonly name: string;\n readonly description?: string;\n readonly state: { readonly schema: string; readonly fingerprint?: string };\n readonly snapshot?: { readonly enabled?: boolean };\n readonly commands?: readonly CommandManifest[];\n readonly events?: readonly EventManifest[];\n readonly lifecycle?: readonly string[];\n readonly queries?: readonly QueryManifest[];\n readonly schedules?: readonly string[];\n readonly ownership?: Ownership;\n}\n\n/** A subscription of a bounded context (design 04 §1). */\nexport interface SubscriptionManifest {\n /** `processor.function`, as a `handled` hop names it. */\n readonly name: string;\n readonly kind: 'PROJECTION' | 'REACTOR' | 'SAGA';\n readonly source: {\n readonly context?: string;\n readonly aggregates?: readonly string[];\n readonly events?: readonly string[];\n };\n readonly derives?: readonly string[];\n readonly rejected?: readonly string[];\n readonly committed?: readonly string[];\n readonly [property: string]: unknown;\n}\n\n/** An error code and the HTTP status it is answered with. */\nexport interface ErrorManifest {\n readonly code: string;\n readonly status: number;\n readonly description?: string;\n}\n\n/** A bounded context of the Manifest. */\nexport interface ContextManifest {\n readonly name: string;\n readonly description?: string;\n readonly aggregates?: readonly AggregateManifest[];\n readonly subscriptions?: readonly SubscriptionManifest[];\n readonly published?: readonly {\n readonly aggregate: string;\n readonly topic: string;\n readonly includeState?: boolean;\n }[];\n readonly errors?: readonly ErrorManifest[];\n}\n\n/**\n * A service's Manifest (decisions D17, D73–D76): its contexts, aggregates,\n * commands, events, routes and error codes, and the JSON Schemas they refer\n * to under `$defs`. `wow-generator` generates typed clients from it.\n */\nexport interface Manifest {\n readonly format: number;\n readonly service?: { readonly name: string; readonly version?: string };\n readonly contexts: readonly ContextManifest[];\n readonly errors?: readonly ErrorManifest[];\n readonly $defs?: Readonly<Record<string, unknown>>;\n}\n\n/** The format of the Manifest this client reads. */\nexport const MANIFEST_FORMAT = 1;\n\n/**\n * The service's Manifest, `GET /wow/manifest`, authorized as any API.\n *\n * @param client - How the service is reached\n * @param options - Headers and cancellation\n */\nexport async function fetchManifest(\n client: WowClientOptions = {},\n options?: RequestOptions,\n): Promise<Manifest> {\n return json<Manifest>(\n await send(client, { method: 'GET', path: '/wow/manifest', options }),\n );\n}\n"],"mappings":";;AA0HA,IAAaA,IAAkB;AAQ/B,eAAsBC,EACpB,IAA2B,CAAC,GAC5B,GACmB;CACnB,OAAOC,EACL,MAAMC,EAAKC,GAAQ;EAAE,QAAQ;EAAO,MAAM;EAAiB;CAAQ,CAAC,CACtE;AACF"}
1
+ {"version":3,"file":"manifest.es.js","names":["MANIFEST_FORMAT","MANIFEST_FEATURES","checkManifest","manifest","unknown","marker","fetchManifest","json","send","client"],"sources":["../src/manifest.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n json,\n type RequestOptions,\n send,\n type WowClientOptions,\n} from './http.js';\nimport type {\n AggregateManifest,\n CommandManifest,\n ContextManifest,\n Manifest,\n ServiceRouteManifest,\n} from './manifestTypes.js';\n\nexport type * from './manifestTypes.js';\n\n/** Whether a command creates its aggregate. */\nexport type Creation = CommandManifest['creation'];\n\n/**\n * A command as a {@link RoutingManifest} lists it: its name, former names and\n * routes, and the property of its body that names its aggregate, for a command\n * whose body does (`idProperty`).\n */\nexport type RoutingCommand = Pick<CommandManifest, 'name' | 'routes'> &\n Partial<Pick<CommandManifest, 'aliases' | 'idProperty'>>;\n\n/** A service route as a {@link RoutingManifest} lists it: its name and its route. */\nexport type RoutingServiceRoute = Pick<ServiceRouteManifest, 'name' | 'route'>;\n\n/**\n * What a `CommandClient` reads of a Manifest to send a command: each\n * context's aggregates and their commands with their routes, and the context's\n * own system commands; and what a `ServiceRoutes` reads to call a service\n * route: the context's routes. A whole {@link Manifest} is one; a generated\n * client carries its service's as data (`manifest.ts`), with no schema.\n */\nexport interface RoutingManifest extends Pick<Manifest, 'format' | 'requires'> {\n readonly contexts: readonly (Pick<ContextManifest, 'name'> & {\n readonly aggregates?: readonly (Pick<AggregateManifest, 'name'> & {\n readonly commands?: readonly RoutingCommand[];\n })[];\n readonly commands?: readonly RoutingCommand[];\n readonly routes?: readonly RoutingServiceRoute[];\n })[];\n}\n\n/** The format of the Manifest this client reads. */\nexport const MANIFEST_FORMAT = 1;\n\n/**\n * The markers of a Manifest's `requires` this client understands, as the\n * Kotlin reader's `ManifestFeatures`: none yet.\n */\nexport const MANIFEST_FEATURES: ReadonlySet<string> = new Set<string>();\n\n/**\n * Checks that this client can read `manifest`: its format, and every marker it\n * requires.\n *\n * @param manifest - The Manifest\n * @throws TypeError naming what this client does not understand\n */\nexport function checkManifest<M extends RoutingManifest>(manifest: M): M {\n if (manifest.format !== MANIFEST_FORMAT) {\n throw new TypeError(\n `The Manifest is of format ${manifest.format}; this client reads format ${MANIFEST_FORMAT}.`,\n );\n }\n const unknown = (manifest.requires ?? []).filter(\n marker => !MANIFEST_FEATURES.has(marker),\n );\n if (unknown.length > 0) {\n throw new TypeError(\n `The Manifest requires ${unknown.join(', ')}, which this client does not understand: use a newer @ahoo-wang/wow-client.`,\n );\n }\n return manifest;\n}\n\n/**\n * The service's Manifest, `GET /wow/manifest`, authorized as any API.\n *\n * @param client - How the service is reached\n * @param options - Headers and cancellation\n */\nexport async function fetchManifest(\n client: WowClientOptions = {},\n options?: RequestOptions,\n): Promise<Manifest> {\n return checkManifest(\n await json<Manifest>(\n await send(client, { method: 'GET', path: '/wow/manifest', options }),\n ),\n );\n}\n"],"mappings":";;AA6DA,IAAaA,IAAkB,GAMlBC,oBAAyC,IAAI,IAAY;AAStE,SAAgBC,EAAyC,GAAgB;CACvE,IAAIC,EAAS,WAAA,GACX,MAAU,UACR,6BAA6BA,EAAS,OAAO,8BAC/C;CAEF,IAAMC,KAAWD,EAAS,YAAY,CAAC,EAAA,CAAG,QACxC,MAAU,CAACF,EAAkB,IAAII,CAAM,CACzC;CACA,IAAID,EAAQ,SAAS,GACnB,MAAU,UACR,yBAAyBA,EAAQ,KAAK,IAAI,EAAE,4EAC9C;CAEF,OAAOD;AACT;AAQA,eAAsBG,EACpB,IAA2B,CAAC,GAC5B,GACmB;CACnB,OAAOJ,EACL,MAAMK,EACJ,MAAMC,EAAKC,GAAQ;EAAE,QAAQ;EAAO,MAAM;EAAiB;CAAQ,CAAC,CACtE,CACF;AACF"}
@@ -0,0 +1,195 @@
1
+ /** A service's Manifest, or a module's fragment (without service), format 1. */
2
+ export interface Manifest {
3
+ /** The format of the Manifest. */
4
+ readonly format: number;
5
+ /** The markers a reader must understand to read the Manifest. */
6
+ readonly requires?: readonly string[];
7
+ readonly service?: ServiceManifest;
8
+ readonly contexts: readonly ContextManifest[];
9
+ /** The framework's error codes and their HTTP statuses. */
10
+ readonly errors: readonly ErrorManifest[];
11
+ /** The JSON Schema 2020-12 of every payload, by key. */
12
+ readonly $defs: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
13
+ }
14
+ /** The service a merged Manifest describes; a fragment has none. */
15
+ export interface ServiceManifest {
16
+ readonly name: string;
17
+ readonly version?: string;
18
+ }
19
+ /** A bounded context: its aggregates, subscriptions, published streams, error codes and job commands. */
20
+ export interface ContextManifest {
21
+ /** The bounded context's name: lower case words joined by hyphens. */
22
+ readonly name: string;
23
+ readonly description?: string;
24
+ readonly aggregates: readonly AggregateManifest[];
25
+ readonly subscriptions: readonly SubscriptionManifest[];
26
+ readonly published: readonly PublishedManifest[];
27
+ /** The context's own error codes. */
28
+ readonly errors: readonly ErrorManifest[];
29
+ /** The context's own system commands: its job commands. */
30
+ readonly commands?: readonly CommandManifest[];
31
+ /** The context's service routes, whose handlers are its own code. */
32
+ readonly routes?: readonly ServiceRouteManifest[];
33
+ }
34
+ /** A service route: a route whose handler is the service's own code, its parameters and schemas. */
35
+ export interface ServiceRouteManifest {
36
+ /** The route's name in its context: its identity and its client's method. */
37
+ readonly name: string;
38
+ readonly route: RouteManifest;
39
+ readonly parameters?: readonly RouteParameterManifest[];
40
+ /** An inline JSON Schema: a $ref into $defs, or an array of one. */
41
+ readonly request?: unknown;
42
+ /** An inline JSON Schema: a $ref into $defs, or an array of one. */
43
+ readonly response?: unknown;
44
+ /** The codes the route refuses with, entries of the context's errors. */
45
+ readonly errors?: readonly string[];
46
+ readonly description?: string;
47
+ readonly deprecated?: boolean;
48
+ }
49
+ /** A path variable or query parameter of a service route, and its scalar schema. */
50
+ export interface RouteParameterManifest {
51
+ readonly name: string;
52
+ /** Where the parameter is read from. */
53
+ readonly in: 'path' | 'query' | (string & {});
54
+ /** An inline JSON Schema of a scalar. */
55
+ readonly schema: unknown;
56
+ readonly required: boolean;
57
+ }
58
+ /** An aggregate type: its state, snapshots, commands, events and query models. */
59
+ export interface AggregateManifest {
60
+ readonly name: string;
61
+ readonly description?: string;
62
+ readonly state: StateManifest;
63
+ readonly snapshot: SnapshotManifest;
64
+ readonly commands: readonly CommandManifest[];
65
+ readonly events: readonly EventManifest[];
66
+ readonly queries: readonly QueryManifest[];
67
+ /** The commands the aggregate schedules. */
68
+ readonly schedules?: readonly string[];
69
+ /** Who owns an aggregate; owner when absent. */
70
+ readonly ownership?: 'owner' | 'tenant' | (string & {});
71
+ /** The events the aggregate no longer produces. */
72
+ readonly retired?: readonly string[];
73
+ /** Where an aggregate's id comes from; assigned when absent. */
74
+ readonly idSource?: 'assigned' | 'owner' | (string & {});
75
+ }
76
+ /** An aggregate's state: its schema, the fingerprint of its shape and, in a contract, its view. */
77
+ export interface StateManifest {
78
+ /** #/$defs/<key> */
79
+ readonly schema: string;
80
+ readonly fingerprint?: string;
81
+ readonly view?: string;
82
+ }
83
+ /** Whether an aggregate keeps snapshots, and the revision of their state. */
84
+ export interface SnapshotManifest {
85
+ readonly enabled: boolean;
86
+ readonly stateRevision?: number;
87
+ }
88
+ /** A query model of an aggregate (snapshot, events) and its routes. */
89
+ export interface QueryManifest {
90
+ readonly model: string;
91
+ readonly routes: readonly RouteManifest[];
92
+ }
93
+ /** A command of an aggregate or a context, and the routes that send it. */
94
+ export interface CommandManifest {
95
+ readonly name: string;
96
+ /** The command's former names. */
97
+ readonly aliases: readonly string[];
98
+ /** #/$defs/<key> */
99
+ readonly schema: string;
100
+ /** Whether the command creates its aggregate. */
101
+ readonly creation: 'none' | 'required' | 'allowed' | (string & {});
102
+ /** The events the command produces, when the module says. */
103
+ readonly produces?: readonly string[];
104
+ readonly routes: readonly RouteManifest[];
105
+ readonly mounted?: boolean;
106
+ /** A system command (wow.*): a lifecycle command, a rebuild or a job command. */
107
+ readonly system?: boolean;
108
+ readonly transformsTo?: readonly string[];
109
+ /** The property of the command's body that holds its aggregate's id. */
110
+ readonly idProperty?: string;
111
+ readonly description?: string;
112
+ }
113
+ /** An event of an aggregate and its revision. */
114
+ export interface EventManifest {
115
+ readonly name: string;
116
+ /** The event's former names. */
117
+ readonly aliases: readonly string[];
118
+ readonly revision: number;
119
+ /** #/$defs/<key> */
120
+ readonly schema: string;
121
+ readonly description?: string;
122
+ }
123
+ /** A route of the edge: a method and a path, {id} the aggregate id. */
124
+ export interface RouteManifest {
125
+ readonly method: string;
126
+ readonly path: string;
127
+ }
128
+ /** An error code, the HTTP status it is answered with, and what a retry may do. */
129
+ export interface ErrorManifest {
130
+ readonly code: string;
131
+ readonly status: number;
132
+ readonly description?: string;
133
+ /** What a retry may do, as a problem of the code says: none when left out. */
134
+ readonly retry?: 'none' | 'same-request' | 'new-request' | (string & {});
135
+ /** The seconds to wait before a retry, the problem's Retry-After; given with retry. */
136
+ readonly retryAfter?: number;
137
+ }
138
+ /** A stream a context publishes of an aggregate's events, and its topic. */
139
+ export interface PublishedManifest {
140
+ readonly aggregate: string;
141
+ readonly topic: string;
142
+ readonly includeState: boolean;
143
+ }
144
+ /** A subscription of a bounded context: what it reads and what its handler derives. */
145
+ export interface SubscriptionManifest {
146
+ /** processor.function */
147
+ readonly name: string;
148
+ readonly kind: 'projection' | 'reactor' | 'saga' | (string & {});
149
+ readonly source: SourceManifest;
150
+ readonly function: FunctionManifest;
151
+ readonly derives?: readonly string[];
152
+ readonly rejected?: readonly string[];
153
+ readonly committed?: readonly string[];
154
+ readonly calls?: readonly string[];
155
+ readonly start?: 'beginning' | 'end' | 'join' | (string & {});
156
+ readonly schedules?: readonly string[];
157
+ readonly retry?: RetryManifest;
158
+ readonly job?: JobManifest;
159
+ }
160
+ /** What a subscription reads: a context, aggregate types and events. */
161
+ export interface SourceManifest {
162
+ readonly context?: string;
163
+ readonly aggregates: readonly string[];
164
+ readonly events: readonly string[];
165
+ readonly eventSchemas?: readonly string[];
166
+ readonly nullableState?: boolean;
167
+ }
168
+ /** The handler function of a subscription. */
169
+ export interface FunctionManifest {
170
+ readonly kind: 'command' | 'project' | 'react' | 'saga' | (string & {});
171
+ readonly context: string;
172
+ readonly processor: string;
173
+ readonly name: string;
174
+ }
175
+ /** A subscription's retry budget. */
176
+ export interface RetryManifest {
177
+ readonly maxAttempts?: number;
178
+ readonly initialBackoff?: string;
179
+ readonly maxBackoff?: string;
180
+ readonly timeout?: string;
181
+ readonly recoverable?: readonly string[];
182
+ readonly unrecoverable?: readonly string[];
183
+ readonly systemic?: readonly string[];
184
+ readonly multiplier?: number;
185
+ }
186
+ /** The scheduled job a subscription runs. */
187
+ export interface JobManifest {
188
+ readonly name: string;
189
+ readonly cron: string;
190
+ readonly zone: string;
191
+ /** Who the job runs for. */
192
+ readonly scope: 'system' | 'tenant' | 'sharded' | (string & {});
193
+ /** What the job does with the slots it missed. */
194
+ readonly misfire: 'coalesce' | 'catch-up' | (string & {});
195
+ }