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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +76 -23
  2. package/README.zh-CN.md +66 -19
  3. package/dist/commands.cjs +1 -1
  4. package/dist/commands.cjs.map +1 -1
  5. package/dist/commands.d.cts +131 -61
  6. package/dist/commands.d.ts +131 -61
  7. package/dist/commands.es.js +117 -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 +92 -42
  63. package/dist/dsl/descriptor.d.ts +92 -42
  64. package/dist/dsl/descriptor.es.js +36 -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 +33 -95
  141. package/dist/manifest.d.ts +33 -95
  142. package/dist/manifest.es.js +12 -7
  143. package/dist/manifest.es.js.map +1 -1
  144. package/dist/manifestTypes.d.cts +193 -0
  145. package/dist/manifestTypes.d.ts +193 -0
  146. package/dist/problem.cjs +1 -1
  147. package/dist/problem.cjs.map +1 -1
  148. package/dist/problem.d.cts +76 -111
  149. package/dist/problem.d.ts +76 -111
  150. package/dist/problem.es.js +45 -78
  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 +67 -18
  189. package/dist/wait.d.ts +67 -18
  190. package/dist/wait.es.js +59 -12
  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 +100 -50
  195. package/dist/wire.d.ts +100 -50
  196. package/dist/wire.es.js +17 -6
  197. package/dist/wire.es.js.map +1 -1
  198. package/package.json +26 -7
@@ -1 +1 @@
1
- {"version":3,"file":"wire.es.js","names":["Stage"],"sources":["../src/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\nimport type { TextNumbers } from './exactJson.js';\n\n/**\n * The wire model of a Wow 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 * Which numbers of its states, events and commands are read and written\n * as their exact text (review R4-Q, Q-9): the `int64`, `bigint` and\n * `decimal` fields of its Manifest, as wow-generator writes them.\n */\n readonly textNumbers?: AggregateTextNumbers;\n}\n\n/** The numbers of an aggregate type kept as their exact text ({@link TextNumbers}). */\nexport interface AggregateTextNumbers {\n /** Those of its state. */\n readonly state?: TextNumbers;\n /** Those of each event's body, by the event's name as the server sends it. */\n readonly events?: Readonly<Record<string, TextNumbers>>;\n /** Those of each command's body, by the command's name. */\n readonly commands?: Readonly<Record<string, TextNumbers>>;\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: under its current name, upgraded to its latest revision. The `events` query gives\n * every stored event so, however old its record, and leaves out the events its aggregate retired, so a generated\n * `<Aggregate>Event` union, with {@link SystemEvent}, covers each event it returns.\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 /** Null when the stream has none (`Scope.NONE`). */\n readonly ownerId?: string | null;\n readonly spaceId?: string | null;\n /** Null for an anonymous caller (decision D163). */\n readonly operator?: Operator | null;\n readonly events: readonly E[];\n}\n\n/**\n * The fields of an event stream record a query names (decision D235): its\n * system fields and `events`, the array an `elementMatch` filter and an\n * aggregation's `elements` reach an event through, by the event's own\n * `name`, `revision` and `body.*`.\n */\nexport type EventStreamField =\n | 'aggregateId'\n | 'tenantId'\n | 'version'\n | 'commitTime'\n | 'commandId'\n | 'requestId'\n | 'commandType'\n | 'ownerId'\n | 'spaceId'\n | 'operator'\n | 'operator.id'\n | 'operator.tenantId'\n | 'operator.crossScope'\n | 'events';\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":";AAoEA,IAAaA,IAAQ;CAEnB,UAAU;CAEV,WAAW;CAEX,SAAS;AACX"}
1
+ {"version":3,"file":"wire.es.js","names":["Stage","FunctionKind","CommandResultStatus"],"sources":["../src/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\nimport type { TextNumbers } from './exactJson.js';\n\n/**\n * The wire model of a Wow 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 * Which numbers of its states, events and commands are read and written\n * as their exact text (review R4-Q, Q-9): the `int64`, `bigint` and\n * `decimal` fields of its Manifest, as wow-generator writes them.\n */\n readonly textNumbers?: AggregateTextNumbers;\n}\n\n/** The numbers of an aggregate type kept as their exact text ({@link TextNumbers}). */\nexport interface AggregateTextNumbers {\n /** Those of its state. */\n readonly state?: TextNumbers;\n /** Those of each event's body, by the event's name as the server sends it. */\n readonly events?: Readonly<Record<string, TextNumbers>>;\n /** Those of each command's body, by the command's name. */\n readonly commands?: Readonly<Record<string, TextNumbers>>;\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/**\n * The aggregate a command names: an {@link AggregateRef} whose `id` is null\n * while admission has not chosen it, as for a creation that leaves its id to\n * the server and was refused before one was chosen. The Kotlin client holds\n * such an id as `AggregateRef.UNASSIGNED`.\n */\nexport interface CommandRef {\n readonly type: AggregateType;\n readonly tenantId: string;\n readonly id: string | null;\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: 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. */\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: 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 /**\n * The stage; a server newer than this client may answer one it does not\n * list.\n */\n readonly stage: Stage | (string & {});\n readonly context?: string | null;\n readonly subscription?: string | null;\n}\n\n/** The kind of function that produced a result. */\nexport const FunctionKind = {\n /** The aggregate's command function. */\n COMMAND: 'command',\n /** A projection. */\n PROJECT: 'project',\n /** An event handler that reacts. */\n REACT: 'react',\n /** A saga. */\n SAGA: 'saga',\n /** The snapshot subscription. */\n SNAPSHOT: 'snapshot',\n /** A reservation. */\n RESERVATION: 'reservation',\n /** A timer. */\n TIMERS: 'timers',\n} as const;\n\n/** A {@link FunctionKind} value. */\nexport type FunctionKind = (typeof FunctionKind)[keyof typeof FunctionKind];\n\n/** Who produced a result: a function of `kind` in `context`. */\nexport interface FunctionInfo {\n /**\n * The kind; a server newer than this client may answer one it does not\n * list.\n */\n readonly kind: FunctionKind | (string & {});\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 const CommandResultStatus = {\n /** The command reached the hop. */\n SUCCEEDED: 'succeeded',\n /** The domain or admission refused the command. */\n REJECTED: 'rejected',\n /** A technical failure stopped the command. */\n FAILED: 'failed',\n} as const;\n\n/** A {@link CommandResultStatus} value. */\nexport type CommandResultStatus =\n (typeof CommandResultStatus)[keyof typeof CommandResultStatus];\n\n/**\n * The command a request named before a transformer turned it into the one\n * that ran.\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: 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 /** The aggregate: a result that succeeded always names its id. */\n readonly ref: AggregateRef;\n readonly hop: Hop;\n readonly function: FunctionInfo;\n /**\n * The status; a server newer than this client may answer one it does not\n * list, which did not succeed as far as this client knows.\n */\n readonly status: CommandResultStatus | (string & {});\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/**\n * A result that may not have succeeded, as a rejection or a problem carries\n * it (`CommandRejectedError.result`, `WowProblemError.result`): a command\n * refused before an aggregate id was decided names none\n * ({@link CommandRef}). The Kotlin client has no type of its own\n * for it: its `CommandResult.ref` holds such an id as\n * `AggregateRef.UNASSIGNED`.\n *\n * @typeParam R - The results' type.\n */\nexport interface RefusedResult<R = Record<string, unknown>> extends Omit<\n CommandResult<R>,\n 'ref'\n> {\n readonly ref: CommandRef;\n}\n\n/** The tags of an aggregate: names to values. */\nexport type Tags = Readonly<Record<string, readonly string[]>>;\n\n/**\n * An event as Wow reads it now: under its current name, upgraded to its latest revision. Kotlin's `CommittedEvent`. The `events` query gives\n * every stored event so, however old its record, and leaves out the events its aggregate retired, so a generated\n * `<Aggregate>Event` union, with {@link SystemEvent}, covers each event it returns.\n *\n * @typeParam N - The event's name.\n * @typeParam B - The event's body.\n */\nexport interface CommittedEvent<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`: 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: CommandRef;\n readonly commandType: string;\n readonly command: string;\n}\n\n/** The body of `wow.ScheduleCancelled`. */\nexport interface ScheduleCancelled {\n readonly key: string;\n}\n\n/**\n * The system events the kernel gives every aggregate:\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 | CommittedEvent<\n 'wow.lifecycle.AggregateDeleted',\n Readonly<Record<string, never>>\n >\n | CommittedEvent<\n 'wow.lifecycle.AggregateRestored',\n Readonly<Record<string, never>>\n >\n | CommittedEvent<'wow.lifecycle.OwnerTransferred', OwnerTransferred>\n | CommittedEvent<'wow.lifecycle.SpaceTransferred', SpaceTransferred>\n | CommittedEvent<'wow.lifecycle.TagsApplied', TagsApplied>\n | CommittedEvent<'wow.ScheduleSet', ScheduleSet>\n | CommittedEvent<'wow.ScheduleCancelled', ScheduleCancelled>;\n\n/**\n * One commit of a state trace: 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<\n S = unknown,\n E extends CommittedEvent = CommittedEvent,\n> {\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<\n S = unknown,\n E extends CommittedEvent = CommittedEvent,\n> {\n readonly ref: AggregateRef;\n readonly commits: readonly CommitView<S, E>[];\n}\n\n/**\n * An aggregate's latest committed state, as a record of the `snapshot` query\n * model and as `GET /{context}/{aggregate}/{id}/state` answer it: the\n * aggregate's system fields and its state. Kotlin's `Snapshot`.\n *\n * @typeParam S - The state's type.\n */\nexport interface Snapshot<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.\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`. */\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: one commit of one\n * aggregate and its events. Kotlin's `EventStream`.\n *\n * @typeParam E - The events' type.\n */\nexport interface EventStream<E extends CommittedEvent = CommittedEvent> {\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 /** Null when the stream has none (`Scope.NONE`). */\n readonly ownerId?: string | null;\n readonly spaceId?: string | null;\n /** Null for an anonymous caller (decision D163). */\n readonly operator?: Operator | null;\n readonly events: readonly E[];\n}\n\n/**\n * The fields of an event stream record a query names: its\n * system fields and `events`, the array an `elementMatch` filter and an\n * aggregation's `elements` reach an event through, by the event's own\n * `name`, `revision` and `body.*`.\n */\nexport type EventStreamField =\n | 'aggregateId'\n | 'tenantId'\n | 'version'\n | 'commitTime'\n | 'commandId'\n | 'requestId'\n | 'commandType'\n | 'ownerId'\n | 'spaceId'\n | 'operator'\n | 'operator.id'\n | 'operator.tenantId'\n | 'operator.crossScope'\n | 'events';\n\n/** How an aggregate belongs to its callers. */\nexport type Ownership = 'owner' | 'tenant';\n\n/** One dataset of `GET /wow/dataset`. */\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":";AAgFA,IAAaA,IAAQ;CAEnB,UAAU;CAEV,WAAW;CAEX,SAAS;AACX,GAqBaC,IAAe;CAE1B,SAAS;CAET,SAAS;CAET,OAAO;CAEP,MAAM;CAEN,UAAU;CAEV,aAAa;CAEb,QAAQ;AACV,GAyCaC,IAAsB;CAEjC,WAAW;CAEX,UAAU;CAEV,QAAQ;AACV"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahoo-wang/wow-client",
3
- "version": "10.0.0-alpha.5",
3
+ "version": "10.0.0-alpha.7",
4
4
  "description": "TypeScript client for Wow (https://github.com/Ahoo-Wang/Wow): commands with their waits and event streams, state reads, snapshot, event and dataset queries, the Manifest and RFC 9457 problems, and the query DSL, built on Fetcher.",
5
5
  "keywords": [
6
6
  "wow",
@@ -53,6 +53,26 @@
53
53
  "default": "./dist/dsl.cjs"
54
54
  }
55
55
  },
56
+ "./testing": {
57
+ "import": {
58
+ "types": "./dist/testing.d.ts",
59
+ "default": "./dist/testing.es.js"
60
+ },
61
+ "require": {
62
+ "types": "./dist/testing.d.cts",
63
+ "default": "./dist/testing.cjs"
64
+ }
65
+ },
66
+ "./routes": {
67
+ "import": {
68
+ "types": "./dist/routes.d.ts",
69
+ "default": "./dist/routes.es.js"
70
+ },
71
+ "require": {
72
+ "types": "./dist/routes.d.cts",
73
+ "default": "./dist/routes.cjs"
74
+ }
75
+ },
56
76
  "./package.json": "./package.json"
57
77
  },
58
78
  "files": [
@@ -71,17 +91,16 @@
71
91
  "@eslint/js": "^10.0.1",
72
92
  "@microsoft/api-extractor": "^7.59.4",
73
93
  "@types/node": "^26.6.5",
74
- "@vitest/coverage-v8": "4.1.11",
75
- "@vitest/ui": "^4.1.11",
94
+ "@vitest/coverage-v8": "4.1.12",
95
+ "@vitest/ui": "^4.1.12",
76
96
  "eslint": "^10.13.0",
77
97
  "globals": "^17.13.0",
78
- "prettier": "3.9.9",
79
98
  "typescript": "~6.0.3",
80
- "typescript-eslint": "^8.71.1",
99
+ "typescript-eslint": "^8.72.0",
81
100
  "unplugin-dts": "1.1.2",
82
- "vite": "8.3.4",
101
+ "vite": "8.3.5",
83
102
  "vite-bundle-analyzer": "^1.3.9",
84
- "vitest": "^4.1.11"
103
+ "vitest": "^4.1.12"
85
104
  },
86
105
  "scripts": {
87
106
  "build": "vite build && pnpm test:package",