@ahoo-wang/wow-client 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 (177) hide show
  1. package/dist/client/query/dataset/datasetDescriptorEndpoint.cjs +2 -0
  2. package/dist/client/query/dataset/datasetDescriptorEndpoint.cjs.map +1 -0
  3. package/dist/client/query/dataset/datasetDescriptorEndpoint.d.cts +8 -0
  4. package/dist/client/query/dataset/datasetDescriptorEndpoint.d.ts +8 -0
  5. package/dist/client/query/dataset/datasetDescriptorEndpoint.es.js +34 -0
  6. package/dist/client/query/dataset/datasetDescriptorEndpoint.es.js.map +1 -0
  7. package/dist/client/query/dataset/datasetDirectoryClient.cjs +2 -0
  8. package/dist/client/query/dataset/datasetDirectoryClient.cjs.map +1 -0
  9. package/dist/client/query/dataset/datasetDirectoryClient.d.cts +29 -0
  10. package/dist/client/query/dataset/datasetDirectoryClient.d.ts +29 -0
  11. package/dist/client/query/dataset/datasetDirectoryClient.es.js +25 -0
  12. package/dist/client/query/dataset/datasetDirectoryClient.es.js.map +1 -0
  13. package/dist/client/query/dataset/datasetQueryApi.d.cts +40 -0
  14. package/dist/client/query/dataset/datasetQueryApi.d.ts +40 -0
  15. package/dist/client/query/dataset/datasetQueryClient.cjs +2 -0
  16. package/dist/client/query/dataset/datasetQueryClient.cjs.map +1 -0
  17. package/dist/client/query/dataset/datasetQueryClient.d.cts +57 -0
  18. package/dist/client/query/dataset/datasetQueryClient.d.ts +57 -0
  19. package/dist/client/query/dataset/datasetQueryClient.es.js +154 -0
  20. package/dist/client/query/dataset/datasetQueryClient.es.js.map +1 -0
  21. package/dist/client/query/dataset/endpointPaths.cjs +2 -0
  22. package/dist/client/query/dataset/endpointPaths.cjs.map +1 -0
  23. package/dist/client/query/dataset/endpointPaths.d.cts +9 -0
  24. package/dist/client/query/dataset/endpointPaths.d.ts +9 -0
  25. package/dist/client/query/dataset/endpointPaths.es.js +14 -0
  26. package/dist/client/query/dataset/endpointPaths.es.js.map +1 -0
  27. package/dist/client/query/dataset/index.d.cts +3 -0
  28. package/dist/client/query/dataset/index.d.ts +3 -0
  29. package/dist/client/query/event/eventStreamQueryApi.d.cts +1 -1
  30. package/dist/client/query/event/eventStreamQueryApi.d.ts +1 -1
  31. package/dist/client/query/event/eventStreamQueryClient.cjs.map +1 -1
  32. package/dist/client/query/event/eventStreamQueryClient.d.cts +4 -1
  33. package/dist/client/query/event/eventStreamQueryClient.d.ts +4 -1
  34. package/dist/client/query/event/eventStreamQueryClient.es.js.map +1 -1
  35. package/dist/client/query/event/index.d.cts +0 -1
  36. package/dist/client/query/event/index.d.ts +0 -1
  37. package/dist/client/query/index.d.cts +1 -0
  38. package/dist/client/query/index.d.ts +1 -0
  39. package/dist/client/query/snapshot/index.d.cts +0 -1
  40. package/dist/client/query/snapshot/index.d.ts +0 -1
  41. package/dist/client/query/snapshot/snapshotQueryApi.d.cts +1 -1
  42. package/dist/client/query/snapshot/snapshotQueryApi.d.ts +1 -1
  43. package/dist/client/query/snapshot/snapshotQueryClient.cjs.map +1 -1
  44. package/dist/client/query/snapshot/snapshotQueryClient.d.cts +4 -1
  45. package/dist/client/query/snapshot/snapshotQueryClient.d.ts +4 -1
  46. package/dist/client/query/snapshot/snapshotQueryClient.es.js.map +1 -1
  47. package/dist/client/routing.cjs.map +1 -1
  48. package/dist/client/routing.d.cts +2 -2
  49. package/dist/client/routing.d.ts +2 -2
  50. package/dist/client/routing.es.js.map +1 -1
  51. package/dist/dsl/aggregation/admit.cjs +1 -1
  52. package/dist/dsl/aggregation/admit.cjs.map +1 -1
  53. package/dist/dsl/aggregation/admit.es.js +84 -65
  54. package/dist/dsl/aggregation/admit.es.js.map +1 -1
  55. package/dist/dsl/aggregation/builders.cjs +1 -1
  56. package/dist/dsl/aggregation/builders.cjs.map +1 -1
  57. package/dist/dsl/aggregation/builders.d.cts +16 -4
  58. package/dist/dsl/aggregation/builders.d.ts +16 -4
  59. package/dist/dsl/aggregation/builders.es.js +89 -78
  60. package/dist/dsl/aggregation/builders.es.js.map +1 -1
  61. package/dist/dsl/aggregation/derived.cjs +1 -1
  62. package/dist/dsl/aggregation/derived.cjs.map +1 -1
  63. package/dist/dsl/aggregation/derived.d.cts +32 -1
  64. package/dist/dsl/aggregation/derived.d.ts +32 -1
  65. package/dist/dsl/aggregation/derived.es.js +23 -1
  66. package/dist/dsl/aggregation/derived.es.js.map +1 -1
  67. package/dist/dsl/aggregation/types.cjs +1 -1
  68. package/dist/dsl/aggregation/types.cjs.map +1 -1
  69. package/dist/dsl/aggregation/types.d.cts +112 -7
  70. package/dist/dsl/aggregation/types.d.ts +112 -7
  71. package/dist/dsl/aggregation/types.es.js +19 -12
  72. package/dist/dsl/aggregation/types.es.js.map +1 -1
  73. package/dist/dsl/descriptor.cjs +1 -1
  74. package/dist/dsl/descriptor.cjs.map +1 -1
  75. package/dist/dsl/descriptor.d.cts +23 -1
  76. package/dist/dsl/descriptor.d.ts +23 -1
  77. package/dist/dsl/descriptor.es.js +2 -1
  78. package/dist/dsl/descriptor.es.js.map +1 -1
  79. package/dist/dsl.cjs +1 -1
  80. package/dist/dsl.d.cts +2 -2
  81. package/dist/dsl.d.ts +2 -2
  82. package/dist/dsl.es.js +13 -13
  83. package/dist/error/headers.cjs.map +1 -1
  84. package/dist/error/headers.d.cts +3 -2
  85. package/dist/error/headers.d.ts +3 -2
  86. package/dist/error/headers.es.js.map +1 -1
  87. package/dist/error/queryErrorCodes.cjs +1 -1
  88. package/dist/error/queryErrorCodes.cjs.map +1 -1
  89. package/dist/error/queryErrorCodes.d.cts +7 -0
  90. package/dist/error/queryErrorCodes.d.ts +7 -0
  91. package/dist/error/queryErrorCodes.es.js +2 -1
  92. package/dist/error/queryErrorCodes.es.js.map +1 -1
  93. package/dist/index.cjs +1 -1
  94. package/dist/index.es.js +35 -33
  95. package/dist/model/domainEventStream.cjs.map +1 -0
  96. package/dist/{client/query/event → model}/domainEventStream.d.cts +5 -1
  97. package/dist/{client/query/event → model}/domainEventStream.d.ts +5 -1
  98. package/dist/{client/query/event → model}/domainEventStream.es.js +1 -1
  99. package/dist/model/domainEventStream.es.js.map +1 -0
  100. package/dist/model/index.d.cts +2 -0
  101. package/dist/model/index.d.ts +2 -0
  102. package/dist/model/snapshot.cjs.map +1 -0
  103. package/dist/{client/query/snapshot → model}/snapshot.d.cts +3 -1
  104. package/dist/{client/query/snapshot → model}/snapshot.d.ts +3 -1
  105. package/dist/{client/query/snapshot → model}/snapshot.es.js +1 -1
  106. package/dist/model/snapshot.es.js.map +1 -0
  107. package/dist/transport/eventStreams.cjs +1 -1
  108. package/dist/transport/eventStreams.cjs.map +1 -1
  109. package/dist/transport/eventStreams.d.cts +3 -1
  110. package/dist/transport/eventStreams.d.ts +3 -1
  111. package/dist/transport/eventStreams.es.js +7 -4
  112. package/dist/transport/eventStreams.es.js.map +1 -1
  113. package/dist/v10/commands.cjs +2 -0
  114. package/dist/v10/commands.cjs.map +1 -0
  115. package/dist/v10/commands.d.cts +105 -0
  116. package/dist/v10/commands.d.ts +105 -0
  117. package/dist/v10/commands.es.js +68 -0
  118. package/dist/v10/commands.es.js.map +1 -0
  119. package/dist/v10/http.cjs +2 -0
  120. package/dist/v10/http.cjs.map +1 -0
  121. package/dist/v10/http.d.cts +87 -0
  122. package/dist/v10/http.d.ts +87 -0
  123. package/dist/v10/http.es.js +73 -0
  124. package/dist/v10/http.es.js.map +1 -0
  125. package/dist/v10/index.d.cts +19 -0
  126. package/dist/v10/index.d.ts +19 -0
  127. package/dist/v10/manifest.cjs +2 -0
  128. package/dist/v10/manifest.cjs.map +1 -0
  129. package/dist/v10/manifest.d.cts +109 -0
  130. package/dist/v10/manifest.d.ts +109 -0
  131. package/dist/v10/manifest.es.js +14 -0
  132. package/dist/v10/manifest.es.js.map +1 -0
  133. package/dist/v10/problem.cjs +2 -0
  134. package/dist/v10/problem.cjs.map +1 -0
  135. package/dist/v10/problem.d.cts +164 -0
  136. package/dist/v10/problem.d.ts +164 -0
  137. package/dist/v10/problem.es.js +119 -0
  138. package/dist/v10/problem.es.js.map +1 -0
  139. package/dist/v10/queries.cjs +2 -0
  140. package/dist/v10/queries.cjs.map +1 -0
  141. package/dist/v10/queries.d.cts +136 -0
  142. package/dist/v10/queries.d.ts +136 -0
  143. package/dist/v10/queries.es.js +88 -0
  144. package/dist/v10/queries.es.js.map +1 -0
  145. package/dist/v10/state.cjs +2 -0
  146. package/dist/v10/state.cjs.map +1 -0
  147. package/dist/v10/state.d.cts +53 -0
  148. package/dist/v10/state.d.ts +53 -0
  149. package/dist/v10/state.es.js +51 -0
  150. package/dist/v10/state.es.js.map +1 -0
  151. package/dist/v10/streams.cjs +2 -0
  152. package/dist/v10/streams.cjs.map +1 -0
  153. package/dist/v10/streams.d.cts +14 -0
  154. package/dist/v10/streams.d.ts +14 -0
  155. package/dist/v10/streams.es.js +22 -0
  156. package/dist/v10/streams.es.js.map +1 -0
  157. package/dist/v10/wait.cjs +2 -0
  158. package/dist/v10/wait.cjs.map +1 -0
  159. package/dist/v10/wait.d.cts +61 -0
  160. package/dist/v10/wait.d.ts +61 -0
  161. package/dist/v10/wait.es.js +44 -0
  162. package/dist/v10/wait.es.js.map +1 -0
  163. package/dist/v10/wire.cjs +2 -0
  164. package/dist/v10/wire.cjs.map +1 -0
  165. package/dist/v10/wire.d.cts +301 -0
  166. package/dist/v10/wire.d.ts +301 -0
  167. package/dist/v10/wire.es.js +10 -0
  168. package/dist/v10/wire.es.js.map +1 -0
  169. package/dist/v10.cjs +1 -0
  170. package/dist/v10.es.js +9 -0
  171. package/package.json +12 -2
  172. package/dist/client/query/event/domainEventStream.cjs.map +0 -1
  173. package/dist/client/query/event/domainEventStream.es.js.map +0 -1
  174. package/dist/client/query/snapshot/snapshot.cjs.map +0 -1
  175. package/dist/client/query/snapshot/snapshot.es.js.map +0 -1
  176. /package/dist/{client/query/event → model}/domainEventStream.cjs +0 -0
  177. /package/dist/{client/query/snapshot → model}/snapshot.cjs +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.cjs","names":["Stage"],"sources":["../../src/v10/wire.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\n/**\n * The wire model of a Wow V10 service: what its routes answer, as the server\n * writes it (`wow-api`'s `CommandResult`, the edge's state views, the query\n * records). Types and wire values only.\n */\n\n/** An aggregate type: its bounded context and its name. */\nexport interface AggregateType {\n readonly context: string;\n readonly name: string;\n}\n\n/** One aggregate: its type, its tenant and its id. */\nexport interface AggregateRef {\n readonly type: AggregateType;\n readonly tenantId: string;\n readonly id: string;\n}\n\n/** The owner and the space an aggregate belongs to, beside its tenant. */\nexport interface Scope {\n readonly ownerId?: string | null;\n readonly spaceId?: string | null;\n}\n\n/**\n * Who sent a command (decision D163): the opaque id of the authenticated\n * subject, its own tenant, and whether it acted in another tenant or scope.\n * Resolve the id to a display name in the application, never from Wow.\n */\nexport interface Operator {\n readonly id: string;\n readonly tenantId: string;\n readonly crossScope: boolean;\n}\n\n/** How far a command has come (decision D61). */\nexport const Stage = {\n /** The command passed admission. */\n ACCEPTED: 'ACCEPTED',\n /** The command's events are appended to the log. */\n COMMITTED: 'COMMITTED',\n /** A named subscription has handled the commit. */\n HANDLED: 'HANDLED',\n} as const;\n\n/** A {@link Stage} value. */\nexport type Stage = (typeof Stage)[keyof typeof Stage];\n\n/**\n * One hop of a wait chain (decision D62): a stage, in a context (the\n * command's own when absent), of a subscription when the stage is\n * `HANDLED`. The snapshot is the subscription named `snapshot`.\n */\nexport interface Hop {\n readonly stage: Stage;\n readonly context?: string | null;\n readonly subscription?: string | null;\n}\n\n/** The kind of function that produced a result. */\nexport type FunctionKind =\n | 'COMMAND'\n | 'PROJECT'\n | 'REACT'\n | 'SAGA'\n | 'SNAPSHOT'\n | 'RESERVATION'\n | 'TIMERS';\n\n/** Who produced a result: a function of `kind` in `context`. */\nexport interface FunctionInfo {\n readonly kind: FunctionKind;\n readonly context: string;\n readonly processor: string;\n readonly name: string;\n}\n\n/** A field-level validation error. */\nexport interface Violation {\n /** The path of the field, or the query part, that broke the rule. */\n readonly path: string;\n /** The rule's code, such as `NotBlank` or `UNKNOWN_FIELD`. */\n readonly code: string;\n /** A human-readable message. */\n readonly message: string;\n}\n\n/** Why a command was rejected or failed. */\nexport interface ErrorInfo {\n /** A framework code (`wow.*`) or the domain's own. */\n readonly code: string;\n readonly message: string;\n readonly violations?: readonly Violation[];\n /**\n * The rejection's structured data (decision D211), which a problem\n * writes as its extension members.\n */\n readonly extensions?: Readonly<Record<string, unknown>>;\n}\n\n/** How a command ended at a hop. */\nexport type CommandResultStatus = 'SUCCEEDED' | 'REJECTED' | 'FAILED';\n\n/**\n * The command a request named before a transformer turned it into the one\n * that ran (decision D182).\n */\nexport interface TransformedFrom {\n /** The full type name, `context.aggregate.Command`. */\n readonly command: string;\n readonly aggregateId?: string | null;\n}\n\n/**\n * The one outward result of a command (design 08 §7): what it reached at one\n * hop of its wait chain. A command route answers the last one; its event\n * stream sends one per hop.\n *\n * A chain can end before its plan does (decision D212): a hop, such as a\n * saga's that sent no command (a declined payment, say), leaves nothing to\n * reach the later hops. Its result is then the last one, at that hop with its\n * own status, `chainEnded` and the hops not reached in `pending`; a server\n * before D212 sends neither, so read them as `false` and empty when absent.\n *\n * @typeParam R - The shape of `results`, what the command's decide function\n * answered with.\n */\nexport interface CommandResult<R = Record<string, unknown>> {\n readonly format: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly correlationId: string;\n readonly ref: AggregateRef;\n readonly hop: Hop;\n readonly function: FunctionInfo;\n readonly status: CommandResultStatus;\n /** The aggregate's version after the commit, or the unchanged one. */\n readonly version?: number | null;\n /** The request was already committed: it was not decided again. */\n readonly duplicate: boolean;\n /** Set when `status` is `REJECTED` or `FAILED`. */\n readonly error?: ErrorInfo | null;\n readonly results: R;\n /** On a saga's hop, the ids of the commands it derived. */\n readonly derived: readonly string[];\n /** When it was produced, in epoch milliseconds. */\n readonly signalTime: number;\n readonly transformedFrom?: TransformedFrom | null;\n /**\n * The chain ended at this hop before its plan did (decision D212): the\n * hops in `pending` will not come.\n */\n readonly chainEnded?: boolean;\n /** When `chainEnded`, the hops of the plan not reached, in order. */\n readonly pending?: readonly Hop[];\n}\n\n/** The tags of an aggregate: names to values. */\nexport type Tags = Readonly<Record<string, readonly string[]>>;\n\n/**\n * An aggregate's state at a version (decision D40), as\n * `GET /{context}/{aggregate}/{id}/state` answers it.\n *\n * @typeParam S - The state's type.\n */\nexport interface StateView<S = unknown> {\n readonly ref: AggregateRef;\n readonly version: number;\n readonly scope: Scope;\n readonly deleted: boolean;\n readonly tags: Tags;\n readonly state: S;\n}\n\n/**\n * An event as Wow reads it now, upgraded to its latest revision.\n *\n * @typeParam N - The event's name.\n * @typeParam B - The event's body.\n */\nexport interface EventView<N extends string = string, B = unknown> {\n readonly name: N;\n readonly revision: number;\n readonly body: B;\n}\n\n/** The body of `wow.lifecycle.OwnerTransferred`: the aggregate's new owner. */\nexport interface OwnerTransferred {\n readonly ownerId: string;\n}\n\n/** The body of `wow.lifecycle.SpaceTransferred`: the aggregate's new space. */\nexport interface SpaceTransferred {\n readonly spaceId: string;\n}\n\n/** The body of `wow.lifecycle.TagsApplied`: the aggregate's tags now. */\nexport interface TagsApplied {\n readonly tags: Tags;\n}\n\n/**\n * The body of `wow.ScheduleSet` (decision D198): the aggregate set its\n * schedule `key`, to send `target` the command of type `commandType`\n * (`command` its JSON text) as `rule` says.\n */\nexport interface ScheduleSet {\n readonly key: string;\n readonly rule: ScheduleRule;\n readonly target: AggregateRef;\n readonly commandType: string;\n readonly command: string;\n}\n\n/** The body of `wow.ScheduleCancelled` (decision D198). */\nexport interface ScheduleCancelled {\n readonly key: string;\n}\n\n/**\n * The system events the kernel gives every aggregate (decisions D113, D198):\n * the lifecycle events and the schedule events. A state trace and an event\n * stream carry them beside the aggregate's own events, so the event union\n * `wow-generator` writes for an aggregate includes this one.\n */\nexport type SystemEvent =\n | EventView<'wow.lifecycle.AggregateDeleted', Readonly<Record<string, never>>>\n | EventView<\n 'wow.lifecycle.AggregateRestored',\n Readonly<Record<string, never>>\n >\n | EventView<'wow.lifecycle.OwnerTransferred', OwnerTransferred>\n | EventView<'wow.lifecycle.SpaceTransferred', SpaceTransferred>\n | EventView<'wow.lifecycle.TagsApplied', TagsApplied>\n | EventView<'wow.ScheduleSet', ScheduleSet>\n | EventView<'wow.ScheduleCancelled', ScheduleCancelled>;\n\n/**\n * One commit of a state trace (decision D40): the events of a version and the\n * aggregate after it.\n *\n * @typeParam S - The state's type.\n * @typeParam E - The events' type.\n */\nexport interface CommitView<S = unknown, E extends EventView = EventView> {\n readonly version: number;\n /** When it was committed, in epoch milliseconds. */\n readonly commitTime: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly commandType: string;\n readonly events: readonly E[];\n readonly scope: Scope;\n readonly deleted: boolean;\n readonly tags: Tags;\n readonly state: S;\n readonly operator?: Operator | null;\n}\n\n/**\n * What `GET /{context}/{aggregate}/{id}/state/trace` answers: the aggregate\n * and its commits in version order.\n */\nexport interface StateTrace<S = unknown, E extends EventView = EventView> {\n readonly ref: AggregateRef;\n readonly commits: readonly CommitView<S, E>[];\n}\n\n/**\n * A record of the `snapshot` query model (decisions D128, D163): the\n * aggregate's system fields and its state.\n *\n * @typeParam S - The state's type.\n */\nexport interface SnapshotRecord<S = unknown> {\n readonly tenantId: string;\n readonly aggregateId: string;\n readonly version: number;\n readonly ownerId: string | null;\n readonly spaceId: string | null;\n readonly deleted: boolean;\n readonly tags: Tags;\n /** The first commit's time, in epoch milliseconds. */\n readonly firstEventTime: number;\n /** The last commit's time, in epoch milliseconds. */\n readonly lastEventTime: number;\n /** Who sent the last command; null for an anonymous caller. */\n readonly operator: Operator | null;\n /** Who created the aggregate; null for an anonymous caller. */\n readonly firstOperator: Operator | null;\n /**\n * The schedules the aggregate keeps (decision D198): each rule, `{type,\n * ...}`, by its key; absent from a server before 6.8c.\n */\n readonly schedules?: Readonly<Record<string, ScheduleRule>>;\n readonly state: S;\n}\n\n/**\n * The system fields of a snapshot record a query can filter, sort and\n * project on; a state field is `state.<path>`.\n */\nexport type SnapshotSystemField =\n | 'tenantId'\n | 'aggregateId'\n | 'version'\n | 'ownerId'\n | 'spaceId'\n | 'deleted'\n | 'tags'\n | 'firstEventTime'\n | 'lastEventTime'\n | 'operator'\n | 'operator.id'\n | 'operator.tenantId'\n | 'operator.crossScope'\n | 'firstOperator'\n | 'firstOperator.id'\n | 'firstOperator.tenantId'\n | 'firstOperator.crossScope'\n | 'schedules';\n\n/** A schedule rule of a snapshot's `schedules` (decision D198). */\nexport interface ScheduleRule {\n /** The rule's type: `at`, `after`, `cron`, … */\n readonly type: string;\n readonly [property: string]: unknown;\n}\n\n/**\n * A record of the `events` query model (decision D131): one commit of one\n * aggregate and its events.\n *\n * @typeParam E - The events' type.\n */\nexport interface EventStreamRecord<E extends EventView = EventView> {\n readonly aggregateId: string;\n readonly tenantId: string;\n readonly version: number;\n /** When it was committed, in epoch milliseconds. */\n readonly commitTime: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly commandType: string;\n readonly ownerId?: string;\n readonly spaceId?: string;\n readonly operator?: Operator;\n readonly events: readonly E[];\n}\n\n/** The fields of an event stream record a query can filter and sort on. */\nexport type EventStreamField =\n 'aggregateId' | 'tenantId' | 'version' | 'commitTime';\n\n/** How an aggregate belongs to its callers (decision D189). */\nexport type Ownership = 'OWNER' | 'TENANT';\n\n/** One dataset of `GET /wow/dataset` (decision D145). */\nexport interface DatasetEntry {\n /** `{context}.{dataset}`. */\n readonly name: string;\n readonly context: string;\n readonly dataset: string;\n readonly title?: string | null;\n /** The path of its query route. */\n readonly path: string;\n}\n"],"mappings":"AAkDA,IAAaA,EAAQ,CAEnB,SAAU,WAEV,UAAW,YAEX,QAAS,SACX"}
@@ -0,0 +1,301 @@
1
+ /**
2
+ * The wire model of a Wow V10 service: what its routes answer, as the server
3
+ * writes it (`wow-api`'s `CommandResult`, the edge's state views, the query
4
+ * records). Types and wire values only.
5
+ */
6
+ /** An aggregate type: its bounded context and its name. */
7
+ export interface AggregateType {
8
+ readonly context: string;
9
+ readonly name: string;
10
+ }
11
+ /** One aggregate: its type, its tenant and its id. */
12
+ export interface AggregateRef {
13
+ readonly type: AggregateType;
14
+ readonly tenantId: string;
15
+ readonly id: string;
16
+ }
17
+ /** The owner and the space an aggregate belongs to, beside its tenant. */
18
+ export interface Scope {
19
+ readonly ownerId?: string | null;
20
+ readonly spaceId?: string | null;
21
+ }
22
+ /**
23
+ * Who sent a command (decision D163): the opaque id of the authenticated
24
+ * subject, its own tenant, and whether it acted in another tenant or scope.
25
+ * Resolve the id to a display name in the application, never from Wow.
26
+ */
27
+ export interface Operator {
28
+ readonly id: string;
29
+ readonly tenantId: string;
30
+ readonly crossScope: boolean;
31
+ }
32
+ /** How far a command has come (decision D61). */
33
+ export declare const Stage: {
34
+ /** The command passed admission. */
35
+ readonly ACCEPTED: "ACCEPTED";
36
+ /** The command's events are appended to the log. */
37
+ readonly COMMITTED: "COMMITTED";
38
+ /** A named subscription has handled the commit. */
39
+ readonly HANDLED: "HANDLED";
40
+ };
41
+ /** A {@link Stage} value. */
42
+ export type Stage = (typeof Stage)[keyof typeof Stage];
43
+ /**
44
+ * One hop of a wait chain (decision D62): a stage, in a context (the
45
+ * command's own when absent), of a subscription when the stage is
46
+ * `HANDLED`. The snapshot is the subscription named `snapshot`.
47
+ */
48
+ export interface Hop {
49
+ readonly stage: Stage;
50
+ readonly context?: string | null;
51
+ readonly subscription?: string | null;
52
+ }
53
+ /** The kind of function that produced a result. */
54
+ export type FunctionKind = 'COMMAND' | 'PROJECT' | 'REACT' | 'SAGA' | 'SNAPSHOT' | 'RESERVATION' | 'TIMERS';
55
+ /** Who produced a result: a function of `kind` in `context`. */
56
+ export interface FunctionInfo {
57
+ readonly kind: FunctionKind;
58
+ readonly context: string;
59
+ readonly processor: string;
60
+ readonly name: string;
61
+ }
62
+ /** A field-level validation error. */
63
+ export interface Violation {
64
+ /** The path of the field, or the query part, that broke the rule. */
65
+ readonly path: string;
66
+ /** The rule's code, such as `NotBlank` or `UNKNOWN_FIELD`. */
67
+ readonly code: string;
68
+ /** A human-readable message. */
69
+ readonly message: string;
70
+ }
71
+ /** Why a command was rejected or failed. */
72
+ export interface ErrorInfo {
73
+ /** A framework code (`wow.*`) or the domain's own. */
74
+ readonly code: string;
75
+ readonly message: string;
76
+ readonly violations?: readonly Violation[];
77
+ /**
78
+ * The rejection's structured data (decision D211), which a problem
79
+ * writes as its extension members.
80
+ */
81
+ readonly extensions?: Readonly<Record<string, unknown>>;
82
+ }
83
+ /** How a command ended at a hop. */
84
+ export type CommandResultStatus = 'SUCCEEDED' | 'REJECTED' | 'FAILED';
85
+ /**
86
+ * The command a request named before a transformer turned it into the one
87
+ * that ran (decision D182).
88
+ */
89
+ export interface TransformedFrom {
90
+ /** The full type name, `context.aggregate.Command`. */
91
+ readonly command: string;
92
+ readonly aggregateId?: string | null;
93
+ }
94
+ /**
95
+ * The one outward result of a command (design 08 §7): what it reached at one
96
+ * hop of its wait chain. A command route answers the last one; its event
97
+ * stream sends one per hop.
98
+ *
99
+ * A chain can end before its plan does (decision D212): a hop, such as a
100
+ * saga's that sent no command (a declined payment, say), leaves nothing to
101
+ * reach the later hops. Its result is then the last one, at that hop with its
102
+ * own status, `chainEnded` and the hops not reached in `pending`; a server
103
+ * before D212 sends neither, so read them as `false` and empty when absent.
104
+ *
105
+ * @typeParam R - The shape of `results`, what the command's decide function
106
+ * answered with.
107
+ */
108
+ export interface CommandResult<R = Record<string, unknown>> {
109
+ readonly format: number;
110
+ readonly commandId: string;
111
+ readonly requestId: string;
112
+ readonly correlationId: string;
113
+ readonly ref: AggregateRef;
114
+ readonly hop: Hop;
115
+ readonly function: FunctionInfo;
116
+ readonly status: CommandResultStatus;
117
+ /** The aggregate's version after the commit, or the unchanged one. */
118
+ readonly version?: number | null;
119
+ /** The request was already committed: it was not decided again. */
120
+ readonly duplicate: boolean;
121
+ /** Set when `status` is `REJECTED` or `FAILED`. */
122
+ readonly error?: ErrorInfo | null;
123
+ readonly results: R;
124
+ /** On a saga's hop, the ids of the commands it derived. */
125
+ readonly derived: readonly string[];
126
+ /** When it was produced, in epoch milliseconds. */
127
+ readonly signalTime: number;
128
+ readonly transformedFrom?: TransformedFrom | null;
129
+ /**
130
+ * The chain ended at this hop before its plan did (decision D212): the
131
+ * hops in `pending` will not come.
132
+ */
133
+ readonly chainEnded?: boolean;
134
+ /** When `chainEnded`, the hops of the plan not reached, in order. */
135
+ readonly pending?: readonly Hop[];
136
+ }
137
+ /** The tags of an aggregate: names to values. */
138
+ export type Tags = Readonly<Record<string, readonly string[]>>;
139
+ /**
140
+ * An aggregate's state at a version (decision D40), as
141
+ * `GET /{context}/{aggregate}/{id}/state` answers it.
142
+ *
143
+ * @typeParam S - The state's type.
144
+ */
145
+ export interface StateView<S = unknown> {
146
+ readonly ref: AggregateRef;
147
+ readonly version: number;
148
+ readonly scope: Scope;
149
+ readonly deleted: boolean;
150
+ readonly tags: Tags;
151
+ readonly state: S;
152
+ }
153
+ /**
154
+ * An event as Wow reads it now, upgraded to its latest revision.
155
+ *
156
+ * @typeParam N - The event's name.
157
+ * @typeParam B - The event's body.
158
+ */
159
+ export interface EventView<N extends string = string, B = unknown> {
160
+ readonly name: N;
161
+ readonly revision: number;
162
+ readonly body: B;
163
+ }
164
+ /** The body of `wow.lifecycle.OwnerTransferred`: the aggregate's new owner. */
165
+ export interface OwnerTransferred {
166
+ readonly ownerId: string;
167
+ }
168
+ /** The body of `wow.lifecycle.SpaceTransferred`: the aggregate's new space. */
169
+ export interface SpaceTransferred {
170
+ readonly spaceId: string;
171
+ }
172
+ /** The body of `wow.lifecycle.TagsApplied`: the aggregate's tags now. */
173
+ export interface TagsApplied {
174
+ readonly tags: Tags;
175
+ }
176
+ /**
177
+ * The body of `wow.ScheduleSet` (decision D198): the aggregate set its
178
+ * schedule `key`, to send `target` the command of type `commandType`
179
+ * (`command` its JSON text) as `rule` says.
180
+ */
181
+ export interface ScheduleSet {
182
+ readonly key: string;
183
+ readonly rule: ScheduleRule;
184
+ readonly target: AggregateRef;
185
+ readonly commandType: string;
186
+ readonly command: string;
187
+ }
188
+ /** The body of `wow.ScheduleCancelled` (decision D198). */
189
+ export interface ScheduleCancelled {
190
+ readonly key: string;
191
+ }
192
+ /**
193
+ * The system events the kernel gives every aggregate (decisions D113, D198):
194
+ * the lifecycle events and the schedule events. A state trace and an event
195
+ * stream carry them beside the aggregate's own events, so the event union
196
+ * `wow-generator` writes for an aggregate includes this one.
197
+ */
198
+ export type SystemEvent = EventView<'wow.lifecycle.AggregateDeleted', Readonly<Record<string, never>>> | EventView<'wow.lifecycle.AggregateRestored', Readonly<Record<string, never>>> | EventView<'wow.lifecycle.OwnerTransferred', OwnerTransferred> | EventView<'wow.lifecycle.SpaceTransferred', SpaceTransferred> | EventView<'wow.lifecycle.TagsApplied', TagsApplied> | EventView<'wow.ScheduleSet', ScheduleSet> | EventView<'wow.ScheduleCancelled', ScheduleCancelled>;
199
+ /**
200
+ * One commit of a state trace (decision D40): the events of a version and the
201
+ * aggregate after it.
202
+ *
203
+ * @typeParam S - The state's type.
204
+ * @typeParam E - The events' type.
205
+ */
206
+ export interface CommitView<S = unknown, E extends EventView = EventView> {
207
+ readonly version: number;
208
+ /** When it was committed, in epoch milliseconds. */
209
+ readonly commitTime: number;
210
+ readonly commandId: string;
211
+ readonly requestId: string;
212
+ readonly commandType: string;
213
+ readonly events: readonly E[];
214
+ readonly scope: Scope;
215
+ readonly deleted: boolean;
216
+ readonly tags: Tags;
217
+ readonly state: S;
218
+ readonly operator?: Operator | null;
219
+ }
220
+ /**
221
+ * What `GET /{context}/{aggregate}/{id}/state/trace` answers: the aggregate
222
+ * and its commits in version order.
223
+ */
224
+ export interface StateTrace<S = unknown, E extends EventView = EventView> {
225
+ readonly ref: AggregateRef;
226
+ readonly commits: readonly CommitView<S, E>[];
227
+ }
228
+ /**
229
+ * A record of the `snapshot` query model (decisions D128, D163): the
230
+ * aggregate's system fields and its state.
231
+ *
232
+ * @typeParam S - The state's type.
233
+ */
234
+ export interface SnapshotRecord<S = unknown> {
235
+ readonly tenantId: string;
236
+ readonly aggregateId: string;
237
+ readonly version: number;
238
+ readonly ownerId: string | null;
239
+ readonly spaceId: string | null;
240
+ readonly deleted: boolean;
241
+ readonly tags: Tags;
242
+ /** The first commit's time, in epoch milliseconds. */
243
+ readonly firstEventTime: number;
244
+ /** The last commit's time, in epoch milliseconds. */
245
+ readonly lastEventTime: number;
246
+ /** Who sent the last command; null for an anonymous caller. */
247
+ readonly operator: Operator | null;
248
+ /** Who created the aggregate; null for an anonymous caller. */
249
+ readonly firstOperator: Operator | null;
250
+ /**
251
+ * The schedules the aggregate keeps (decision D198): each rule, `{type,
252
+ * ...}`, by its key; absent from a server before 6.8c.
253
+ */
254
+ readonly schedules?: Readonly<Record<string, ScheduleRule>>;
255
+ readonly state: S;
256
+ }
257
+ /**
258
+ * The system fields of a snapshot record a query can filter, sort and
259
+ * project on; a state field is `state.<path>`.
260
+ */
261
+ export type SnapshotSystemField = 'tenantId' | 'aggregateId' | 'version' | 'ownerId' | 'spaceId' | 'deleted' | 'tags' | 'firstEventTime' | 'lastEventTime' | 'operator' | 'operator.id' | 'operator.tenantId' | 'operator.crossScope' | 'firstOperator' | 'firstOperator.id' | 'firstOperator.tenantId' | 'firstOperator.crossScope' | 'schedules';
262
+ /** A schedule rule of a snapshot's `schedules` (decision D198). */
263
+ export interface ScheduleRule {
264
+ /** The rule's type: `at`, `after`, `cron`, … */
265
+ readonly type: string;
266
+ readonly [property: string]: unknown;
267
+ }
268
+ /**
269
+ * A record of the `events` query model (decision D131): one commit of one
270
+ * aggregate and its events.
271
+ *
272
+ * @typeParam E - The events' type.
273
+ */
274
+ export interface EventStreamRecord<E extends EventView = EventView> {
275
+ readonly aggregateId: string;
276
+ readonly tenantId: string;
277
+ readonly version: number;
278
+ /** When it was committed, in epoch milliseconds. */
279
+ readonly commitTime: number;
280
+ readonly commandId: string;
281
+ readonly requestId: string;
282
+ readonly commandType: string;
283
+ readonly ownerId?: string;
284
+ readonly spaceId?: string;
285
+ readonly operator?: Operator;
286
+ readonly events: readonly E[];
287
+ }
288
+ /** The fields of an event stream record a query can filter and sort on. */
289
+ export type EventStreamField = 'aggregateId' | 'tenantId' | 'version' | 'commitTime';
290
+ /** How an aggregate belongs to its callers (decision D189). */
291
+ export type Ownership = 'OWNER' | 'TENANT';
292
+ /** One dataset of `GET /wow/dataset` (decision D145). */
293
+ export interface DatasetEntry {
294
+ /** `{context}.{dataset}`. */
295
+ readonly name: string;
296
+ readonly context: string;
297
+ readonly dataset: string;
298
+ readonly title?: string | null;
299
+ /** The path of its query route. */
300
+ readonly path: string;
301
+ }
@@ -0,0 +1,301 @@
1
+ /**
2
+ * The wire model of a Wow V10 service: what its routes answer, as the server
3
+ * writes it (`wow-api`'s `CommandResult`, the edge's state views, the query
4
+ * records). Types and wire values only.
5
+ */
6
+ /** An aggregate type: its bounded context and its name. */
7
+ export interface AggregateType {
8
+ readonly context: string;
9
+ readonly name: string;
10
+ }
11
+ /** One aggregate: its type, its tenant and its id. */
12
+ export interface AggregateRef {
13
+ readonly type: AggregateType;
14
+ readonly tenantId: string;
15
+ readonly id: string;
16
+ }
17
+ /** The owner and the space an aggregate belongs to, beside its tenant. */
18
+ export interface Scope {
19
+ readonly ownerId?: string | null;
20
+ readonly spaceId?: string | null;
21
+ }
22
+ /**
23
+ * Who sent a command (decision D163): the opaque id of the authenticated
24
+ * subject, its own tenant, and whether it acted in another tenant or scope.
25
+ * Resolve the id to a display name in the application, never from Wow.
26
+ */
27
+ export interface Operator {
28
+ readonly id: string;
29
+ readonly tenantId: string;
30
+ readonly crossScope: boolean;
31
+ }
32
+ /** How far a command has come (decision D61). */
33
+ export declare const Stage: {
34
+ /** The command passed admission. */
35
+ readonly ACCEPTED: "ACCEPTED";
36
+ /** The command's events are appended to the log. */
37
+ readonly COMMITTED: "COMMITTED";
38
+ /** A named subscription has handled the commit. */
39
+ readonly HANDLED: "HANDLED";
40
+ };
41
+ /** A {@link Stage} value. */
42
+ export type Stage = (typeof Stage)[keyof typeof Stage];
43
+ /**
44
+ * One hop of a wait chain (decision D62): a stage, in a context (the
45
+ * command's own when absent), of a subscription when the stage is
46
+ * `HANDLED`. The snapshot is the subscription named `snapshot`.
47
+ */
48
+ export interface Hop {
49
+ readonly stage: Stage;
50
+ readonly context?: string | null;
51
+ readonly subscription?: string | null;
52
+ }
53
+ /** The kind of function that produced a result. */
54
+ export type FunctionKind = 'COMMAND' | 'PROJECT' | 'REACT' | 'SAGA' | 'SNAPSHOT' | 'RESERVATION' | 'TIMERS';
55
+ /** Who produced a result: a function of `kind` in `context`. */
56
+ export interface FunctionInfo {
57
+ readonly kind: FunctionKind;
58
+ readonly context: string;
59
+ readonly processor: string;
60
+ readonly name: string;
61
+ }
62
+ /** A field-level validation error. */
63
+ export interface Violation {
64
+ /** The path of the field, or the query part, that broke the rule. */
65
+ readonly path: string;
66
+ /** The rule's code, such as `NotBlank` or `UNKNOWN_FIELD`. */
67
+ readonly code: string;
68
+ /** A human-readable message. */
69
+ readonly message: string;
70
+ }
71
+ /** Why a command was rejected or failed. */
72
+ export interface ErrorInfo {
73
+ /** A framework code (`wow.*`) or the domain's own. */
74
+ readonly code: string;
75
+ readonly message: string;
76
+ readonly violations?: readonly Violation[];
77
+ /**
78
+ * The rejection's structured data (decision D211), which a problem
79
+ * writes as its extension members.
80
+ */
81
+ readonly extensions?: Readonly<Record<string, unknown>>;
82
+ }
83
+ /** How a command ended at a hop. */
84
+ export type CommandResultStatus = 'SUCCEEDED' | 'REJECTED' | 'FAILED';
85
+ /**
86
+ * The command a request named before a transformer turned it into the one
87
+ * that ran (decision D182).
88
+ */
89
+ export interface TransformedFrom {
90
+ /** The full type name, `context.aggregate.Command`. */
91
+ readonly command: string;
92
+ readonly aggregateId?: string | null;
93
+ }
94
+ /**
95
+ * The one outward result of a command (design 08 §7): what it reached at one
96
+ * hop of its wait chain. A command route answers the last one; its event
97
+ * stream sends one per hop.
98
+ *
99
+ * A chain can end before its plan does (decision D212): a hop, such as a
100
+ * saga's that sent no command (a declined payment, say), leaves nothing to
101
+ * reach the later hops. Its result is then the last one, at that hop with its
102
+ * own status, `chainEnded` and the hops not reached in `pending`; a server
103
+ * before D212 sends neither, so read them as `false` and empty when absent.
104
+ *
105
+ * @typeParam R - The shape of `results`, what the command's decide function
106
+ * answered with.
107
+ */
108
+ export interface CommandResult<R = Record<string, unknown>> {
109
+ readonly format: number;
110
+ readonly commandId: string;
111
+ readonly requestId: string;
112
+ readonly correlationId: string;
113
+ readonly ref: AggregateRef;
114
+ readonly hop: Hop;
115
+ readonly function: FunctionInfo;
116
+ readonly status: CommandResultStatus;
117
+ /** The aggregate's version after the commit, or the unchanged one. */
118
+ readonly version?: number | null;
119
+ /** The request was already committed: it was not decided again. */
120
+ readonly duplicate: boolean;
121
+ /** Set when `status` is `REJECTED` or `FAILED`. */
122
+ readonly error?: ErrorInfo | null;
123
+ readonly results: R;
124
+ /** On a saga's hop, the ids of the commands it derived. */
125
+ readonly derived: readonly string[];
126
+ /** When it was produced, in epoch milliseconds. */
127
+ readonly signalTime: number;
128
+ readonly transformedFrom?: TransformedFrom | null;
129
+ /**
130
+ * The chain ended at this hop before its plan did (decision D212): the
131
+ * hops in `pending` will not come.
132
+ */
133
+ readonly chainEnded?: boolean;
134
+ /** When `chainEnded`, the hops of the plan not reached, in order. */
135
+ readonly pending?: readonly Hop[];
136
+ }
137
+ /** The tags of an aggregate: names to values. */
138
+ export type Tags = Readonly<Record<string, readonly string[]>>;
139
+ /**
140
+ * An aggregate's state at a version (decision D40), as
141
+ * `GET /{context}/{aggregate}/{id}/state` answers it.
142
+ *
143
+ * @typeParam S - The state's type.
144
+ */
145
+ export interface StateView<S = unknown> {
146
+ readonly ref: AggregateRef;
147
+ readonly version: number;
148
+ readonly scope: Scope;
149
+ readonly deleted: boolean;
150
+ readonly tags: Tags;
151
+ readonly state: S;
152
+ }
153
+ /**
154
+ * An event as Wow reads it now, upgraded to its latest revision.
155
+ *
156
+ * @typeParam N - The event's name.
157
+ * @typeParam B - The event's body.
158
+ */
159
+ export interface EventView<N extends string = string, B = unknown> {
160
+ readonly name: N;
161
+ readonly revision: number;
162
+ readonly body: B;
163
+ }
164
+ /** The body of `wow.lifecycle.OwnerTransferred`: the aggregate's new owner. */
165
+ export interface OwnerTransferred {
166
+ readonly ownerId: string;
167
+ }
168
+ /** The body of `wow.lifecycle.SpaceTransferred`: the aggregate's new space. */
169
+ export interface SpaceTransferred {
170
+ readonly spaceId: string;
171
+ }
172
+ /** The body of `wow.lifecycle.TagsApplied`: the aggregate's tags now. */
173
+ export interface TagsApplied {
174
+ readonly tags: Tags;
175
+ }
176
+ /**
177
+ * The body of `wow.ScheduleSet` (decision D198): the aggregate set its
178
+ * schedule `key`, to send `target` the command of type `commandType`
179
+ * (`command` its JSON text) as `rule` says.
180
+ */
181
+ export interface ScheduleSet {
182
+ readonly key: string;
183
+ readonly rule: ScheduleRule;
184
+ readonly target: AggregateRef;
185
+ readonly commandType: string;
186
+ readonly command: string;
187
+ }
188
+ /** The body of `wow.ScheduleCancelled` (decision D198). */
189
+ export interface ScheduleCancelled {
190
+ readonly key: string;
191
+ }
192
+ /**
193
+ * The system events the kernel gives every aggregate (decisions D113, D198):
194
+ * the lifecycle events and the schedule events. A state trace and an event
195
+ * stream carry them beside the aggregate's own events, so the event union
196
+ * `wow-generator` writes for an aggregate includes this one.
197
+ */
198
+ export type SystemEvent = EventView<'wow.lifecycle.AggregateDeleted', Readonly<Record<string, never>>> | EventView<'wow.lifecycle.AggregateRestored', Readonly<Record<string, never>>> | EventView<'wow.lifecycle.OwnerTransferred', OwnerTransferred> | EventView<'wow.lifecycle.SpaceTransferred', SpaceTransferred> | EventView<'wow.lifecycle.TagsApplied', TagsApplied> | EventView<'wow.ScheduleSet', ScheduleSet> | EventView<'wow.ScheduleCancelled', ScheduleCancelled>;
199
+ /**
200
+ * One commit of a state trace (decision D40): the events of a version and the
201
+ * aggregate after it.
202
+ *
203
+ * @typeParam S - The state's type.
204
+ * @typeParam E - The events' type.
205
+ */
206
+ export interface CommitView<S = unknown, E extends EventView = EventView> {
207
+ readonly version: number;
208
+ /** When it was committed, in epoch milliseconds. */
209
+ readonly commitTime: number;
210
+ readonly commandId: string;
211
+ readonly requestId: string;
212
+ readonly commandType: string;
213
+ readonly events: readonly E[];
214
+ readonly scope: Scope;
215
+ readonly deleted: boolean;
216
+ readonly tags: Tags;
217
+ readonly state: S;
218
+ readonly operator?: Operator | null;
219
+ }
220
+ /**
221
+ * What `GET /{context}/{aggregate}/{id}/state/trace` answers: the aggregate
222
+ * and its commits in version order.
223
+ */
224
+ export interface StateTrace<S = unknown, E extends EventView = EventView> {
225
+ readonly ref: AggregateRef;
226
+ readonly commits: readonly CommitView<S, E>[];
227
+ }
228
+ /**
229
+ * A record of the `snapshot` query model (decisions D128, D163): the
230
+ * aggregate's system fields and its state.
231
+ *
232
+ * @typeParam S - The state's type.
233
+ */
234
+ export interface SnapshotRecord<S = unknown> {
235
+ readonly tenantId: string;
236
+ readonly aggregateId: string;
237
+ readonly version: number;
238
+ readonly ownerId: string | null;
239
+ readonly spaceId: string | null;
240
+ readonly deleted: boolean;
241
+ readonly tags: Tags;
242
+ /** The first commit's time, in epoch milliseconds. */
243
+ readonly firstEventTime: number;
244
+ /** The last commit's time, in epoch milliseconds. */
245
+ readonly lastEventTime: number;
246
+ /** Who sent the last command; null for an anonymous caller. */
247
+ readonly operator: Operator | null;
248
+ /** Who created the aggregate; null for an anonymous caller. */
249
+ readonly firstOperator: Operator | null;
250
+ /**
251
+ * The schedules the aggregate keeps (decision D198): each rule, `{type,
252
+ * ...}`, by its key; absent from a server before 6.8c.
253
+ */
254
+ readonly schedules?: Readonly<Record<string, ScheduleRule>>;
255
+ readonly state: S;
256
+ }
257
+ /**
258
+ * The system fields of a snapshot record a query can filter, sort and
259
+ * project on; a state field is `state.<path>`.
260
+ */
261
+ export type SnapshotSystemField = 'tenantId' | 'aggregateId' | 'version' | 'ownerId' | 'spaceId' | 'deleted' | 'tags' | 'firstEventTime' | 'lastEventTime' | 'operator' | 'operator.id' | 'operator.tenantId' | 'operator.crossScope' | 'firstOperator' | 'firstOperator.id' | 'firstOperator.tenantId' | 'firstOperator.crossScope' | 'schedules';
262
+ /** A schedule rule of a snapshot's `schedules` (decision D198). */
263
+ export interface ScheduleRule {
264
+ /** The rule's type: `at`, `after`, `cron`, … */
265
+ readonly type: string;
266
+ readonly [property: string]: unknown;
267
+ }
268
+ /**
269
+ * A record of the `events` query model (decision D131): one commit of one
270
+ * aggregate and its events.
271
+ *
272
+ * @typeParam E - The events' type.
273
+ */
274
+ export interface EventStreamRecord<E extends EventView = EventView> {
275
+ readonly aggregateId: string;
276
+ readonly tenantId: string;
277
+ readonly version: number;
278
+ /** When it was committed, in epoch milliseconds. */
279
+ readonly commitTime: number;
280
+ readonly commandId: string;
281
+ readonly requestId: string;
282
+ readonly commandType: string;
283
+ readonly ownerId?: string;
284
+ readonly spaceId?: string;
285
+ readonly operator?: Operator;
286
+ readonly events: readonly E[];
287
+ }
288
+ /** The fields of an event stream record a query can filter and sort on. */
289
+ export type EventStreamField = 'aggregateId' | 'tenantId' | 'version' | 'commitTime';
290
+ /** How an aggregate belongs to its callers (decision D189). */
291
+ export type Ownership = 'OWNER' | 'TENANT';
292
+ /** One dataset of `GET /wow/dataset` (decision D145). */
293
+ export interface DatasetEntry {
294
+ /** `{context}.{dataset}`. */
295
+ readonly name: string;
296
+ readonly context: string;
297
+ readonly dataset: string;
298
+ readonly title?: string | null;
299
+ /** The path of its query route. */
300
+ readonly path: string;
301
+ }
@@ -0,0 +1,10 @@
1
+ //#region src/v10/wire.ts
2
+ var e = {
3
+ ACCEPTED: "ACCEPTED",
4
+ COMMITTED: "COMMITTED",
5
+ HANDLED: "HANDLED"
6
+ };
7
+ //#endregion
8
+ export { e as Stage };
9
+
10
+ //# sourceMappingURL=wire.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.es.js","names":["Stage"],"sources":["../../src/v10/wire.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\n/**\n * The wire model of a Wow V10 service: what its routes answer, as the server\n * writes it (`wow-api`'s `CommandResult`, the edge's state views, the query\n * records). Types and wire values only.\n */\n\n/** An aggregate type: its bounded context and its name. */\nexport interface AggregateType {\n readonly context: string;\n readonly name: string;\n}\n\n/** One aggregate: its type, its tenant and its id. */\nexport interface AggregateRef {\n readonly type: AggregateType;\n readonly tenantId: string;\n readonly id: string;\n}\n\n/** The owner and the space an aggregate belongs to, beside its tenant. */\nexport interface Scope {\n readonly ownerId?: string | null;\n readonly spaceId?: string | null;\n}\n\n/**\n * Who sent a command (decision D163): the opaque id of the authenticated\n * subject, its own tenant, and whether it acted in another tenant or scope.\n * Resolve the id to a display name in the application, never from Wow.\n */\nexport interface Operator {\n readonly id: string;\n readonly tenantId: string;\n readonly crossScope: boolean;\n}\n\n/** How far a command has come (decision D61). */\nexport const Stage = {\n /** The command passed admission. */\n ACCEPTED: 'ACCEPTED',\n /** The command's events are appended to the log. */\n COMMITTED: 'COMMITTED',\n /** A named subscription has handled the commit. */\n HANDLED: 'HANDLED',\n} as const;\n\n/** A {@link Stage} value. */\nexport type Stage = (typeof Stage)[keyof typeof Stage];\n\n/**\n * One hop of a wait chain (decision D62): a stage, in a context (the\n * command's own when absent), of a subscription when the stage is\n * `HANDLED`. The snapshot is the subscription named `snapshot`.\n */\nexport interface Hop {\n readonly stage: Stage;\n readonly context?: string | null;\n readonly subscription?: string | null;\n}\n\n/** The kind of function that produced a result. */\nexport type FunctionKind =\n | 'COMMAND'\n | 'PROJECT'\n | 'REACT'\n | 'SAGA'\n | 'SNAPSHOT'\n | 'RESERVATION'\n | 'TIMERS';\n\n/** Who produced a result: a function of `kind` in `context`. */\nexport interface FunctionInfo {\n readonly kind: FunctionKind;\n readonly context: string;\n readonly processor: string;\n readonly name: string;\n}\n\n/** A field-level validation error. */\nexport interface Violation {\n /** The path of the field, or the query part, that broke the rule. */\n readonly path: string;\n /** The rule's code, such as `NotBlank` or `UNKNOWN_FIELD`. */\n readonly code: string;\n /** A human-readable message. */\n readonly message: string;\n}\n\n/** Why a command was rejected or failed. */\nexport interface ErrorInfo {\n /** A framework code (`wow.*`) or the domain's own. */\n readonly code: string;\n readonly message: string;\n readonly violations?: readonly Violation[];\n /**\n * The rejection's structured data (decision D211), which a problem\n * writes as its extension members.\n */\n readonly extensions?: Readonly<Record<string, unknown>>;\n}\n\n/** How a command ended at a hop. */\nexport type CommandResultStatus = 'SUCCEEDED' | 'REJECTED' | 'FAILED';\n\n/**\n * The command a request named before a transformer turned it into the one\n * that ran (decision D182).\n */\nexport interface TransformedFrom {\n /** The full type name, `context.aggregate.Command`. */\n readonly command: string;\n readonly aggregateId?: string | null;\n}\n\n/**\n * The one outward result of a command (design 08 §7): what it reached at one\n * hop of its wait chain. A command route answers the last one; its event\n * stream sends one per hop.\n *\n * A chain can end before its plan does (decision D212): a hop, such as a\n * saga's that sent no command (a declined payment, say), leaves nothing to\n * reach the later hops. Its result is then the last one, at that hop with its\n * own status, `chainEnded` and the hops not reached in `pending`; a server\n * before D212 sends neither, so read them as `false` and empty when absent.\n *\n * @typeParam R - The shape of `results`, what the command's decide function\n * answered with.\n */\nexport interface CommandResult<R = Record<string, unknown>> {\n readonly format: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly correlationId: string;\n readonly ref: AggregateRef;\n readonly hop: Hop;\n readonly function: FunctionInfo;\n readonly status: CommandResultStatus;\n /** The aggregate's version after the commit, or the unchanged one. */\n readonly version?: number | null;\n /** The request was already committed: it was not decided again. */\n readonly duplicate: boolean;\n /** Set when `status` is `REJECTED` or `FAILED`. */\n readonly error?: ErrorInfo | null;\n readonly results: R;\n /** On a saga's hop, the ids of the commands it derived. */\n readonly derived: readonly string[];\n /** When it was produced, in epoch milliseconds. */\n readonly signalTime: number;\n readonly transformedFrom?: TransformedFrom | null;\n /**\n * The chain ended at this hop before its plan did (decision D212): the\n * hops in `pending` will not come.\n */\n readonly chainEnded?: boolean;\n /** When `chainEnded`, the hops of the plan not reached, in order. */\n readonly pending?: readonly Hop[];\n}\n\n/** The tags of an aggregate: names to values. */\nexport type Tags = Readonly<Record<string, readonly string[]>>;\n\n/**\n * An aggregate's state at a version (decision D40), as\n * `GET /{context}/{aggregate}/{id}/state` answers it.\n *\n * @typeParam S - The state's type.\n */\nexport interface StateView<S = unknown> {\n readonly ref: AggregateRef;\n readonly version: number;\n readonly scope: Scope;\n readonly deleted: boolean;\n readonly tags: Tags;\n readonly state: S;\n}\n\n/**\n * An event as Wow reads it now, upgraded to its latest revision.\n *\n * @typeParam N - The event's name.\n * @typeParam B - The event's body.\n */\nexport interface EventView<N extends string = string, B = unknown> {\n readonly name: N;\n readonly revision: number;\n readonly body: B;\n}\n\n/** The body of `wow.lifecycle.OwnerTransferred`: the aggregate's new owner. */\nexport interface OwnerTransferred {\n readonly ownerId: string;\n}\n\n/** The body of `wow.lifecycle.SpaceTransferred`: the aggregate's new space. */\nexport interface SpaceTransferred {\n readonly spaceId: string;\n}\n\n/** The body of `wow.lifecycle.TagsApplied`: the aggregate's tags now. */\nexport interface TagsApplied {\n readonly tags: Tags;\n}\n\n/**\n * The body of `wow.ScheduleSet` (decision D198): the aggregate set its\n * schedule `key`, to send `target` the command of type `commandType`\n * (`command` its JSON text) as `rule` says.\n */\nexport interface ScheduleSet {\n readonly key: string;\n readonly rule: ScheduleRule;\n readonly target: AggregateRef;\n readonly commandType: string;\n readonly command: string;\n}\n\n/** The body of `wow.ScheduleCancelled` (decision D198). */\nexport interface ScheduleCancelled {\n readonly key: string;\n}\n\n/**\n * The system events the kernel gives every aggregate (decisions D113, D198):\n * the lifecycle events and the schedule events. A state trace and an event\n * stream carry them beside the aggregate's own events, so the event union\n * `wow-generator` writes for an aggregate includes this one.\n */\nexport type SystemEvent =\n | EventView<'wow.lifecycle.AggregateDeleted', Readonly<Record<string, never>>>\n | EventView<\n 'wow.lifecycle.AggregateRestored',\n Readonly<Record<string, never>>\n >\n | EventView<'wow.lifecycle.OwnerTransferred', OwnerTransferred>\n | EventView<'wow.lifecycle.SpaceTransferred', SpaceTransferred>\n | EventView<'wow.lifecycle.TagsApplied', TagsApplied>\n | EventView<'wow.ScheduleSet', ScheduleSet>\n | EventView<'wow.ScheduleCancelled', ScheduleCancelled>;\n\n/**\n * One commit of a state trace (decision D40): the events of a version and the\n * aggregate after it.\n *\n * @typeParam S - The state's type.\n * @typeParam E - The events' type.\n */\nexport interface CommitView<S = unknown, E extends EventView = EventView> {\n readonly version: number;\n /** When it was committed, in epoch milliseconds. */\n readonly commitTime: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly commandType: string;\n readonly events: readonly E[];\n readonly scope: Scope;\n readonly deleted: boolean;\n readonly tags: Tags;\n readonly state: S;\n readonly operator?: Operator | null;\n}\n\n/**\n * What `GET /{context}/{aggregate}/{id}/state/trace` answers: the aggregate\n * and its commits in version order.\n */\nexport interface StateTrace<S = unknown, E extends EventView = EventView> {\n readonly ref: AggregateRef;\n readonly commits: readonly CommitView<S, E>[];\n}\n\n/**\n * A record of the `snapshot` query model (decisions D128, D163): the\n * aggregate's system fields and its state.\n *\n * @typeParam S - The state's type.\n */\nexport interface SnapshotRecord<S = unknown> {\n readonly tenantId: string;\n readonly aggregateId: string;\n readonly version: number;\n readonly ownerId: string | null;\n readonly spaceId: string | null;\n readonly deleted: boolean;\n readonly tags: Tags;\n /** The first commit's time, in epoch milliseconds. */\n readonly firstEventTime: number;\n /** The last commit's time, in epoch milliseconds. */\n readonly lastEventTime: number;\n /** Who sent the last command; null for an anonymous caller. */\n readonly operator: Operator | null;\n /** Who created the aggregate; null for an anonymous caller. */\n readonly firstOperator: Operator | null;\n /**\n * The schedules the aggregate keeps (decision D198): each rule, `{type,\n * ...}`, by its key; absent from a server before 6.8c.\n */\n readonly schedules?: Readonly<Record<string, ScheduleRule>>;\n readonly state: S;\n}\n\n/**\n * The system fields of a snapshot record a query can filter, sort and\n * project on; a state field is `state.<path>`.\n */\nexport type SnapshotSystemField =\n | 'tenantId'\n | 'aggregateId'\n | 'version'\n | 'ownerId'\n | 'spaceId'\n | 'deleted'\n | 'tags'\n | 'firstEventTime'\n | 'lastEventTime'\n | 'operator'\n | 'operator.id'\n | 'operator.tenantId'\n | 'operator.crossScope'\n | 'firstOperator'\n | 'firstOperator.id'\n | 'firstOperator.tenantId'\n | 'firstOperator.crossScope'\n | 'schedules';\n\n/** A schedule rule of a snapshot's `schedules` (decision D198). */\nexport interface ScheduleRule {\n /** The rule's type: `at`, `after`, `cron`, … */\n readonly type: string;\n readonly [property: string]: unknown;\n}\n\n/**\n * A record of the `events` query model (decision D131): one commit of one\n * aggregate and its events.\n *\n * @typeParam E - The events' type.\n */\nexport interface EventStreamRecord<E extends EventView = EventView> {\n readonly aggregateId: string;\n readonly tenantId: string;\n readonly version: number;\n /** When it was committed, in epoch milliseconds. */\n readonly commitTime: number;\n readonly commandId: string;\n readonly requestId: string;\n readonly commandType: string;\n readonly ownerId?: string;\n readonly spaceId?: string;\n readonly operator?: Operator;\n readonly events: readonly E[];\n}\n\n/** The fields of an event stream record a query can filter and sort on. */\nexport type EventStreamField =\n 'aggregateId' | 'tenantId' | 'version' | 'commitTime';\n\n/** How an aggregate belongs to its callers (decision D189). */\nexport type Ownership = 'OWNER' | 'TENANT';\n\n/** One dataset of `GET /wow/dataset` (decision D145). */\nexport interface DatasetEntry {\n /** `{context}.{dataset}`. */\n readonly name: string;\n readonly context: string;\n readonly dataset: string;\n readonly title?: string | null;\n /** The path of its query route. */\n readonly path: string;\n}\n"],"mappings":";AAkDA,IAAaA,IAAQ;CAEnB,UAAU;CAEV,WAAW;CAEX,SAAS;AACX"}