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

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 (233) hide show
  1. package/README.md +8 -5
  2. package/README.zh-CN.md +4 -3
  3. package/dist/commands.cjs +1 -1
  4. package/dist/commands.cjs.map +1 -1
  5. package/dist/commands.d.cts +9 -13
  6. package/dist/commands.d.ts +9 -13
  7. package/dist/commands.es.js +60 -54
  8. package/dist/commands.es.js.map +1 -1
  9. package/dist/dsl/aggregation/admit.cjs +1 -1
  10. package/dist/dsl/aggregation/admit.cjs.map +1 -1
  11. package/dist/dsl/aggregation/admit.es.js +73 -69
  12. package/dist/dsl/aggregation/admit.es.js.map +1 -1
  13. package/dist/dsl/aggregation/aliases.cjs +2 -0
  14. package/dist/dsl/aggregation/aliases.cjs.map +1 -0
  15. package/dist/dsl/aggregation/aliases.d.cts +2 -0
  16. package/dist/dsl/aggregation/aliases.d.ts +2 -0
  17. package/dist/dsl/aggregation/aliases.es.js +13 -0
  18. package/dist/dsl/aggregation/aliases.es.js.map +1 -0
  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 +17 -243
  22. package/dist/dsl/aggregation/builders.d.ts +17 -243
  23. package/dist/dsl/aggregation/builders.es.js +36 -171
  24. package/dist/dsl/aggregation/builders.es.js.map +1 -1
  25. package/dist/dsl/aggregation/derived.cjs +1 -1
  26. package/dist/dsl/aggregation/derived.cjs.map +1 -1
  27. package/dist/dsl/aggregation/derived.d.cts +123 -1
  28. package/dist/dsl/aggregation/derived.d.ts +123 -1
  29. package/dist/dsl/aggregation/derived.es.js +43 -28
  30. package/dist/dsl/aggregation/derived.es.js.map +1 -1
  31. package/dist/dsl/aggregation/groups.cjs +2 -0
  32. package/dist/dsl/aggregation/groups.cjs.map +1 -0
  33. package/dist/dsl/aggregation/groups.d.cts +325 -0
  34. package/dist/dsl/aggregation/groups.d.ts +325 -0
  35. package/dist/dsl/aggregation/groups.es.js +80 -0
  36. package/dist/dsl/aggregation/groups.es.js.map +1 -0
  37. package/dist/dsl/aggregation/having.cjs +1 -1
  38. package/dist/dsl/aggregation/having.cjs.map +1 -1
  39. package/dist/dsl/aggregation/having.d.cts +63 -1
  40. package/dist/dsl/aggregation/having.d.ts +63 -1
  41. package/dist/dsl/aggregation/having.es.js +33 -30
  42. package/dist/dsl/aggregation/having.es.js.map +1 -1
  43. package/dist/dsl/aggregation/index.d.cts +4 -2
  44. package/dist/dsl/aggregation/index.d.ts +4 -2
  45. package/dist/dsl/aggregation/metrics.cjs +2 -0
  46. package/dist/dsl/aggregation/metrics.cjs.map +1 -0
  47. package/dist/dsl/aggregation/metrics.d.cts +279 -0
  48. package/dist/dsl/aggregation/metrics.d.ts +279 -0
  49. package/dist/dsl/aggregation/metrics.es.js +75 -0
  50. package/dist/dsl/aggregation/metrics.es.js.map +1 -0
  51. package/dist/dsl/aggregation/types.cjs +1 -1
  52. package/dist/dsl/aggregation/types.cjs.map +1 -1
  53. package/dist/dsl/aggregation/types.d.cts +4 -524
  54. package/dist/dsl/aggregation/types.d.ts +4 -524
  55. package/dist/dsl/aggregation/types.es.js +5 -25
  56. package/dist/dsl/aggregation/types.es.js.map +1 -1
  57. package/dist/dsl/cursorQuery.cjs +1 -1
  58. package/dist/dsl/cursorQuery.cjs.map +1 -1
  59. package/dist/dsl/cursorQuery.d.cts +18 -7
  60. package/dist/dsl/cursorQuery.d.ts +18 -7
  61. package/dist/dsl/cursorQuery.es.js +13 -12
  62. package/dist/dsl/cursorQuery.es.js.map +1 -1
  63. package/dist/dsl/descriptor.cjs +1 -1
  64. package/dist/dsl/descriptor.cjs.map +1 -1
  65. package/dist/dsl/descriptor.d.cts +24 -379
  66. package/dist/dsl/descriptor.d.ts +24 -379
  67. package/dist/dsl/descriptor.es.js +6 -32
  68. package/dist/dsl/descriptor.es.js.map +1 -1
  69. package/dist/dsl/fieldDescriptor.cjs +2 -0
  70. package/dist/dsl/fieldDescriptor.cjs.map +1 -0
  71. package/dist/dsl/fieldDescriptor.d.cts +246 -0
  72. package/dist/dsl/fieldDescriptor.d.ts +246 -0
  73. package/dist/dsl/fieldDescriptor.es.js +24 -0
  74. package/dist/dsl/fieldDescriptor.es.js.map +1 -0
  75. package/dist/dsl/filter/builders.cjs +1 -1
  76. package/dist/dsl/filter/builders.cjs.map +1 -1
  77. package/dist/dsl/filter/builders.d.cts +7 -949
  78. package/dist/dsl/filter/builders.d.ts +7 -949
  79. package/dist/dsl/filter/builders.es.js +14 -285
  80. package/dist/dsl/filter/builders.es.js.map +1 -1
  81. package/dist/dsl/filter/expressionFilter.cjs +2 -0
  82. package/dist/dsl/filter/expressionFilter.cjs.map +1 -0
  83. package/dist/dsl/filter/expressionFilter.d.cts +35 -0
  84. package/dist/dsl/filter/expressionFilter.d.ts +35 -0
  85. package/dist/dsl/filter/expressionFilter.es.js +18 -0
  86. package/dist/dsl/filter/expressionFilter.es.js.map +1 -0
  87. package/dist/dsl/filter/fieldFilters.cjs +2 -0
  88. package/dist/dsl/filter/fieldFilters.cjs.map +1 -0
  89. package/dist/dsl/filter/fieldFilters.d.cts +297 -0
  90. package/dist/dsl/filter/fieldFilters.d.ts +297 -0
  91. package/dist/dsl/filter/fieldFilters.es.js +110 -0
  92. package/dist/dsl/filter/fieldFilters.es.js.map +1 -0
  93. package/dist/dsl/filter/index.d.cts +2 -1
  94. package/dist/dsl/filter/index.d.ts +2 -1
  95. package/dist/dsl/filter/logicalFilters.cjs +2 -0
  96. package/dist/dsl/filter/logicalFilters.cjs.map +1 -0
  97. package/dist/dsl/filter/logicalFilters.d.cts +109 -0
  98. package/dist/dsl/filter/logicalFilters.d.ts +109 -0
  99. package/dist/dsl/filter/logicalFilters.es.js +36 -0
  100. package/dist/dsl/filter/logicalFilters.es.js.map +1 -0
  101. package/dist/dsl/filter/metadataFilters.cjs +2 -0
  102. package/dist/dsl/filter/metadataFilters.cjs.map +1 -0
  103. package/dist/dsl/filter/metadataFilters.d.cts +132 -0
  104. package/dist/dsl/filter/metadataFilters.d.ts +132 -0
  105. package/dist/dsl/filter/metadataFilters.es.js +56 -0
  106. package/dist/dsl/filter/metadataFilters.es.js.map +1 -0
  107. package/dist/dsl/filter/operator.cjs +1 -1
  108. package/dist/dsl/filter/operator.cjs.map +1 -1
  109. package/dist/dsl/filter/operator.d.cts +11 -9
  110. package/dist/dsl/filter/operator.d.ts +11 -9
  111. package/dist/dsl/filter/operator.es.js +1 -1
  112. package/dist/dsl/filter/operator.es.js.map +1 -1
  113. package/dist/dsl/filter/searchFilter.cjs +2 -0
  114. package/dist/dsl/filter/searchFilter.cjs.map +1 -0
  115. package/dist/dsl/filter/searchFilter.d.cts +39 -0
  116. package/dist/dsl/filter/searchFilter.d.ts +39 -0
  117. package/dist/dsl/filter/searchFilter.es.js +19 -0
  118. package/dist/dsl/filter/searchFilter.es.js.map +1 -0
  119. package/dist/dsl/filter/timeFilters.cjs +2 -0
  120. package/dist/dsl/filter/timeFilters.cjs.map +1 -0
  121. package/dist/dsl/filter/timeFilters.d.cts +290 -0
  122. package/dist/dsl/filter/timeFilters.d.ts +290 -0
  123. package/dist/dsl/filter/timeFilters.es.js +89 -0
  124. package/dist/dsl/filter/timeFilters.es.js.map +1 -0
  125. package/dist/dsl/filter/types.d.cts +4 -14
  126. package/dist/dsl/filter/types.d.ts +4 -14
  127. package/dist/dsl/filter/validate.cjs +1 -1
  128. package/dist/dsl/filter/validate.cjs.map +1 -1
  129. package/dist/dsl/filter/validate.d.cts +2 -4
  130. package/dist/dsl/filter/validate.d.ts +2 -4
  131. package/dist/dsl/filter/validate.es.js +25 -31
  132. package/dist/dsl/filter/validate.es.js.map +1 -1
  133. package/dist/dsl/queryErrorCodes.cjs +1 -1
  134. package/dist/dsl/queryErrorCodes.cjs.map +1 -1
  135. package/dist/dsl/queryErrorCodes.d.cts +0 -2
  136. package/dist/dsl/queryErrorCodes.d.ts +0 -2
  137. package/dist/dsl/queryErrorCodes.es.js +0 -1
  138. package/dist/dsl/queryErrorCodes.es.js.map +1 -1
  139. package/dist/dsl/queryFilter.cjs +2 -0
  140. package/dist/dsl/queryFilter.cjs.map +1 -0
  141. package/dist/dsl/queryFilter.d.cts +3 -0
  142. package/dist/dsl/queryFilter.d.ts +3 -0
  143. package/dist/dsl/queryFilter.es.js +9 -0
  144. package/dist/dsl/queryFilter.es.js.map +1 -0
  145. package/dist/dsl/queryable.cjs +1 -1
  146. package/dist/dsl/queryable.cjs.map +1 -1
  147. package/dist/dsl/queryable.es.js +12 -16
  148. package/dist/dsl/queryable.es.js.map +1 -1
  149. package/dist/dsl/semanticTypes.cjs +2 -0
  150. package/dist/dsl/semanticTypes.cjs.map +1 -0
  151. package/dist/dsl/semanticTypes.d.cts +128 -0
  152. package/dist/dsl/semanticTypes.d.ts +128 -0
  153. package/dist/dsl/semanticTypes.es.js +13 -0
  154. package/dist/dsl/semanticTypes.es.js.map +1 -0
  155. package/dist/dsl.cjs +1 -1
  156. package/dist/dsl.d.cts +2 -0
  157. package/dist/dsl.d.ts +2 -0
  158. package/dist/dsl.es.js +14 -8
  159. package/dist/exactJson.cjs +2 -2
  160. package/dist/exactJson.cjs.map +1 -1
  161. package/dist/exactJson.d.cts +41 -16
  162. package/dist/exactJson.d.ts +41 -16
  163. package/dist/exactJson.es.js +104 -102
  164. package/dist/exactJson.es.js.map +1 -1
  165. package/dist/frameworkErrors.cjs.map +1 -1
  166. package/dist/frameworkErrors.d.cts +5 -5
  167. package/dist/frameworkErrors.d.ts +5 -5
  168. package/dist/frameworkErrors.es.js.map +1 -1
  169. package/dist/http.cjs +1 -1
  170. package/dist/http.cjs.map +1 -1
  171. package/dist/http.d.cts +29 -9
  172. package/dist/http.d.ts +29 -9
  173. package/dist/http.es.js +24 -19
  174. package/dist/http.es.js.map +1 -1
  175. package/dist/index.cjs +1 -1
  176. package/dist/index.d.cts +3 -3
  177. package/dist/index.d.ts +3 -3
  178. package/dist/index.es.js +12 -12
  179. package/dist/manifest.cjs +1 -1
  180. package/dist/manifest.cjs.map +1 -1
  181. package/dist/manifest.d.cts +30 -2
  182. package/dist/manifest.d.ts +30 -2
  183. package/dist/manifest.es.js +34 -6
  184. package/dist/manifest.es.js.map +1 -1
  185. package/dist/manifestTypes.d.cts +21 -4
  186. package/dist/manifestTypes.d.ts +21 -4
  187. package/dist/queries.cjs +1 -1
  188. package/dist/queries.cjs.map +1 -1
  189. package/dist/queries.d.cts +18 -8
  190. package/dist/queries.d.ts +18 -8
  191. package/dist/queries.es.js +46 -35
  192. package/dist/queries.es.js.map +1 -1
  193. package/dist/routes.cjs +1 -1
  194. package/dist/routes.cjs.map +1 -1
  195. package/dist/routes.d.cts +16 -3
  196. package/dist/routes.d.ts +16 -3
  197. package/dist/routes.es.js +24 -25
  198. package/dist/routes.es.js.map +1 -1
  199. package/dist/state.cjs +1 -1
  200. package/dist/state.cjs.map +1 -1
  201. package/dist/state.d.cts +21 -19
  202. package/dist/state.d.ts +21 -19
  203. package/dist/state.es.js +27 -22
  204. package/dist/state.es.js.map +1 -1
  205. package/dist/streams.cjs +1 -1
  206. package/dist/streams.cjs.map +1 -1
  207. package/dist/streams.d.cts +14 -7
  208. package/dist/streams.d.ts +14 -7
  209. package/dist/streams.es.js +65 -50
  210. package/dist/streams.es.js.map +1 -1
  211. package/dist/testing/wire.cjs +1 -1
  212. package/dist/testing/wire.cjs.map +1 -1
  213. package/dist/testing/wire.es.js +1 -1
  214. package/dist/testing/wire.es.js.map +1 -1
  215. package/dist/wait.cjs +1 -1
  216. package/dist/wait.cjs.map +1 -1
  217. package/dist/wait.d.cts +18 -5
  218. package/dist/wait.d.ts +18 -5
  219. package/dist/wait.es.js +36 -34
  220. package/dist/wait.es.js.map +1 -1
  221. package/dist/wire.cjs +1 -1
  222. package/dist/wire.cjs.map +1 -1
  223. package/dist/wire.d.cts +76 -31
  224. package/dist/wire.d.ts +76 -31
  225. package/dist/wire.es.js +1 -3
  226. package/dist/wire.es.js.map +1 -1
  227. package/package.json +5 -5
  228. package/dist/dsl/filter/datePattern.cjs +0 -2
  229. package/dist/dsl/filter/datePattern.cjs.map +0 -1
  230. package/dist/dsl/filter/datePattern.d.cts +0 -8
  231. package/dist/dsl/filter/datePattern.d.ts +0 -8
  232. package/dist/dsl/filter/datePattern.es.js +0 -96
  233. package/dist/dsl/filter/datePattern.es.js.map +0 -1
package/dist/wire.d.ts CHANGED
@@ -23,6 +23,11 @@ export interface AggregateTextNumbers {
23
23
  readonly events?: Readonly<Record<string, TextNumbers>>;
24
24
  /** Those of each command's body, by the command's name. */
25
25
  readonly commands?: Readonly<Record<string, TextNumbers>>;
26
+ /**
27
+ * Those of its access attributes, by name: the integer ones, which a record
28
+ * keeps as a `Long` (`int64`).
29
+ */
30
+ readonly access?: TextNumbers;
26
31
  }
27
32
  /** One aggregate: its type, its tenant and its id. */
28
33
  export interface AggregateRef {
@@ -54,7 +59,7 @@ export interface Scope {
54
59
  export interface Operator {
55
60
  readonly id: string;
56
61
  readonly tenantId: string;
57
- readonly crossScope: boolean;
62
+ readonly actedElsewhere: boolean;
58
63
  }
59
64
  /** How far a command has come. */
60
65
  export declare const Stage: {
@@ -70,7 +75,10 @@ export type Stage = (typeof Stage)[keyof typeof Stage];
70
75
  /**
71
76
  * One hop of a wait chain: a stage, in a context (the
72
77
  * command's own when absent), of a subscription when the stage is
73
- * `handled`. The snapshot is the subscription named `snapshot`.
78
+ * `handled`. The snapshot is the subscription named `wow.snapshot`
79
+ * (`SNAPSHOT_SUBSCRIPTION`), which a `Wow-Wait` header writes `snapshot`;
80
+ * the store the snapshot queries read is `wow.queryable`
81
+ * (`QUERYABLE_SUBSCRIPTION`), written `queryable`.
74
82
  */
75
83
  export interface Hop {
76
84
  /**
@@ -91,12 +99,11 @@ export declare const FunctionKind: {
91
99
  readonly REACT: "react";
92
100
  /** A saga. */
93
101
  readonly SAGA: "saga";
94
- /** The snapshot subscription. */
95
- readonly SNAPSHOT: "snapshot";
96
- /** A reservation. */
97
- readonly RESERVATION: "reservation";
98
- /** A timer. */
99
- readonly TIMERS: "timers";
102
+ /**
103
+ * A built-in subscription of Wow's, such as the one that writes snapshots:
104
+ * its `processor` and `name` say which.
105
+ */
106
+ readonly SYSTEM: "system";
100
107
  };
101
108
  /** A {@link FunctionKind} value. */
102
109
  export type FunctionKind = (typeof FunctionKind)[keyof typeof FunctionKind];
@@ -213,8 +220,34 @@ export interface CommandResult<R = Record<string, unknown>> {
213
220
  export interface RefusedResult<R = Record<string, unknown>> extends Omit<CommandResult<R>, 'ref'> {
214
221
  readonly ref: CommandRef;
215
222
  }
216
- /** The tags of an aggregate: names to values. */
217
- export type Tags = Readonly<Record<string, readonly string[]>>;
223
+ /**
224
+ * An access attribute's value as a record carries it: a single attribute's
225
+ * value or null, a multiple one's values, distinct and sorted. An integer is
226
+ * a `Long` on the server: wow-generator types it `string` and marks it to be
227
+ * read as its exact text ({@link AggregateTextNumbers.access}).
228
+ */
229
+ export type AccessValue = string | number | boolean | null | readonly (string | number | boolean)[];
230
+ /**
231
+ * A record's access attributes by name, as the aggregate declares them
232
+ * (`@Access` on its state, the Manifest's `access`): a generated client types
233
+ * them as an `<Aggregate>Access` interface instead.
234
+ */
235
+ export type AccessValues = Readonly<Record<string, AccessValue>>;
236
+ /**
237
+ * The access attributes of an aggregate that declares none: a record's
238
+ * `access` is then empty, and a query names no `access.<name>`.
239
+ */
240
+ export type NoAccess = Readonly<Record<never, never>>;
241
+ /**
242
+ * The `access` of an event stream: the aggregate's current owner and space
243
+ * beside its declared access attributes `A`.
244
+ */
245
+ export type StreamAccess<A = AccessValues> = A & {
246
+ readonly owner?: string | null;
247
+ readonly space?: string | null;
248
+ };
249
+ /** The `access.<name>` field paths of the access attributes `A`. */
250
+ export type AccessField<A> = `access.${keyof A & string}`;
218
251
  /**
219
252
  * An event as Wow reads it now: under its current name, upgraded to its latest revision. Kotlin's `CommittedEvent`. The `events` query gives
220
253
  * every stored event so, however old its record, and leaves out the events its aggregate retired, so a generated
@@ -236,23 +269,19 @@ export interface OwnerTransferred {
236
269
  export interface SpaceTransferred {
237
270
  readonly spaceId: string;
238
271
  }
239
- /** The body of `wow.lifecycle.TagsApplied`: the aggregate's tags now. */
240
- export interface TagsApplied {
241
- readonly tags: Tags;
242
- }
243
272
  /**
244
- * The body of `wow.ScheduleSet`: the aggregate set its
273
+ * The body of `wow.schedule.ScheduleSet`: the aggregate set its
245
274
  * schedule `key`, to send `target` the command of type `commandType`
246
- * (`command` its JSON text) as `rule` says.
275
+ * (`command` its body, a JSON object) as `rule` says.
247
276
  */
248
277
  export interface ScheduleSet {
249
278
  readonly key: string;
250
279
  readonly rule: ScheduleRule;
251
280
  readonly target: CommandRef;
252
281
  readonly commandType: string;
253
- readonly command: string;
282
+ readonly command: Readonly<Record<string, unknown>>;
254
283
  }
255
- /** The body of `wow.ScheduleCancelled`. */
284
+ /** The body of `wow.schedule.ScheduleCancelled`. */
256
285
  export interface ScheduleCancelled {
257
286
  readonly key: string;
258
287
  }
@@ -262,15 +291,16 @@ export interface ScheduleCancelled {
262
291
  * stream carry them beside the aggregate's own events, so the event union
263
292
  * `wow-generator` writes for an aggregate includes this one.
264
293
  */
265
- export type SystemEvent = CommittedEvent<'wow.lifecycle.AggregateDeleted', Readonly<Record<string, never>>> | CommittedEvent<'wow.lifecycle.AggregateRestored', Readonly<Record<string, never>>> | CommittedEvent<'wow.lifecycle.OwnerTransferred', OwnerTransferred> | CommittedEvent<'wow.lifecycle.SpaceTransferred', SpaceTransferred> | CommittedEvent<'wow.lifecycle.TagsApplied', TagsApplied> | CommittedEvent<'wow.ScheduleSet', ScheduleSet> | CommittedEvent<'wow.ScheduleCancelled', ScheduleCancelled>;
294
+ export type SystemEvent = CommittedEvent<'wow.lifecycle.AggregateDeleted', Readonly<Record<string, never>>> | CommittedEvent<'wow.lifecycle.AggregateRestored', Readonly<Record<string, never>>> | CommittedEvent<'wow.lifecycle.OwnerTransferred', OwnerTransferred> | CommittedEvent<'wow.lifecycle.SpaceTransferred', SpaceTransferred> | CommittedEvent<'wow.schedule.ScheduleSet', ScheduleSet> | CommittedEvent<'wow.schedule.ScheduleCancelled', ScheduleCancelled>;
266
295
  /**
267
296
  * One commit of a state trace: the events of a version and the
268
297
  * aggregate after it.
269
298
  *
270
299
  * @typeParam S - The state's type.
271
300
  * @typeParam E - The events' type.
301
+ * @typeParam A - The aggregate's access attributes.
272
302
  */
273
- export interface CommitView<S = unknown, E extends CommittedEvent = CommittedEvent> {
303
+ export interface CommitView<S = unknown, E extends CommittedEvent = CommittedEvent, A = AccessValues> {
274
304
  readonly version: number;
275
305
  /** When it was committed, in epoch milliseconds. */
276
306
  readonly commitTime: number;
@@ -280,7 +310,8 @@ export interface CommitView<S = unknown, E extends CommittedEvent = CommittedEve
280
310
  readonly events: readonly E[];
281
311
  readonly scope: Scope;
282
312
  readonly deleted: boolean;
283
- readonly tags: Tags;
313
+ /** Its declared access attributes after the commit. */
314
+ readonly access: A;
284
315
  readonly state: S;
285
316
  readonly operator?: Operator | null;
286
317
  }
@@ -288,9 +319,9 @@ export interface CommitView<S = unknown, E extends CommittedEvent = CommittedEve
288
319
  * What `GET /{context}/{aggregate}/{id}/state/trace` answers: the aggregate
289
320
  * and its commits in version order.
290
321
  */
291
- export interface StateTrace<S = unknown, E extends CommittedEvent = CommittedEvent> {
322
+ export interface StateTrace<S = unknown, E extends CommittedEvent = CommittedEvent, A = AccessValues> {
292
323
  readonly ref: AggregateRef;
293
- readonly commits: readonly CommitView<S, E>[];
324
+ readonly commits: readonly CommitView<S, E, A>[];
294
325
  }
295
326
  /**
296
327
  * An aggregate's latest committed state, as a record of the `snapshot` query
@@ -298,15 +329,20 @@ export interface StateTrace<S = unknown, E extends CommittedEvent = CommittedEve
298
329
  * aggregate's system fields and its state. Kotlin's `Snapshot`.
299
330
  *
300
331
  * @typeParam S - The state's type.
332
+ * @typeParam A - The aggregate's access attributes.
301
333
  */
302
- export interface Snapshot<S = unknown> {
334
+ export interface Snapshot<S = unknown, A = AccessValues> {
303
335
  readonly tenantId: string;
304
336
  readonly aggregateId: string;
305
337
  readonly version: number;
306
338
  readonly ownerId: string | null;
307
339
  readonly spaceId: string | null;
308
340
  readonly deleted: boolean;
309
- readonly tags: Tags;
341
+ /**
342
+ * Its declared access attributes. A snapshot written before an attribute
343
+ * was declared lacks it.
344
+ */
345
+ readonly access: A;
310
346
  /** The first commit's time, in epoch milliseconds. */
311
347
  readonly firstEventTime: number;
312
348
  /** The last commit's time, in epoch milliseconds. */
@@ -326,7 +362,7 @@ export interface Snapshot<S = unknown> {
326
362
  * The system fields of a snapshot record a query can filter, sort and
327
363
  * project on; a state field is `state.<path>`.
328
364
  */
329
- 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';
365
+ export type SnapshotSystemField = 'tenantId' | 'aggregateId' | 'version' | 'ownerId' | 'spaceId' | 'deleted' | 'access' | 'firstEventTime' | 'lastEventTime' | 'operator' | 'operator.id' | 'operator.tenantId' | 'operator.actedElsewhere' | 'firstOperator' | 'firstOperator.id' | 'firstOperator.tenantId' | 'firstOperator.actedElsewhere' | 'schedules';
330
366
  /** A schedule rule of a snapshot's `schedules`. */
331
367
  export interface ScheduleRule {
332
368
  /** The rule's type: `at`, `after`, `cron`, … */
@@ -338,8 +374,9 @@ export interface ScheduleRule {
338
374
  * aggregate and its events. Kotlin's `EventStream`.
339
375
  *
340
376
  * @typeParam E - The events' type.
377
+ * @typeParam A - The aggregate's declared access attributes.
341
378
  */
342
- export interface EventStream<E extends CommittedEvent = CommittedEvent> {
379
+ export interface EventStream<E extends CommittedEvent = CommittedEvent, A = AccessValues> {
343
380
  readonly aggregateId: string;
344
381
  readonly tenantId: string;
345
382
  readonly version: number;
@@ -353,15 +390,23 @@ export interface EventStream<E extends CommittedEvent = CommittedEvent> {
353
390
  readonly spaceId?: string | null;
354
391
  /** Null for an anonymous caller (decision D163). */
355
392
  readonly operator?: Operator | null;
393
+ /**
394
+ * The aggregate's current access attributes, its owner and space among
395
+ * them, kept current as they change (decision D390); null while the stream
396
+ * is not stamped (appended before the log recorded them, or imported
397
+ * without them).
398
+ */
399
+ readonly access?: StreamAccess<A> | null;
356
400
  readonly events: readonly E[];
357
401
  }
358
402
  /**
359
403
  * The fields of an event stream record a query names: its
360
- * system fields and `events`, the array an `elementMatch` filter and an
361
- * aggregation's `elements` reach an event through, by the event's own
362
- * `name`, `revision` and `body.*`.
404
+ * system fields, `access` and its built-in `owner` and `space` (a declared
405
+ * attribute is an {@link AccessField}), and `events`, the array an
406
+ * `elementMatch` filter and an aggregation's `elements` reach an event
407
+ * through, by the event's own `name`, `revision` and `body.*`.
363
408
  */
364
- export type EventStreamField = 'aggregateId' | 'tenantId' | 'version' | 'commitTime' | 'commandId' | 'requestId' | 'commandType' | 'ownerId' | 'spaceId' | 'operator' | 'operator.id' | 'operator.tenantId' | 'operator.crossScope' | 'events';
409
+ export type EventStreamField = 'aggregateId' | 'tenantId' | 'version' | 'commitTime' | 'commandId' | 'requestId' | 'commandType' | 'ownerId' | 'spaceId' | 'operator' | 'operator.id' | 'operator.tenantId' | 'operator.actedElsewhere' | 'access' | 'access.owner' | 'access.space' | 'events';
365
410
  /** How an aggregate belongs to its callers. */
366
411
  export type Ownership = 'owner' | 'tenant';
367
412
  /** One dataset of `GET /wow/dataset`. */
package/dist/wire.es.js CHANGED
@@ -8,9 +8,7 @@ var e = {
8
8
  PROJECT: "project",
9
9
  REACT: "react",
10
10
  SAGA: "saga",
11
- SNAPSHOT: "snapshot",
12
- RESERVATION: "reservation",
13
- TIMERS: "timers"
11
+ SYSTEM: "system"
14
12
  }, n = {
15
13
  SUCCEEDED: "succeeded",
16
14
  REJECTED: "rejected",
@@ -1 +1 @@
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"}
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 * Those of its access attributes, by name: the integer ones, which a record\n * keeps as a `Long` (`int64`).\n */\n readonly access?: 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 actedElsewhere: 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 `wow.snapshot`\n * (`SNAPSHOT_SUBSCRIPTION`), which a `Wow-Wait` header writes `snapshot`;\n * the store the snapshot queries read is `wow.queryable`\n * (`QUERYABLE_SUBSCRIPTION`), written `queryable`.\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 /**\n * A built-in subscription of Wow's, such as the one that writes snapshots:\n * its `processor` and `name` say which.\n */\n SYSTEM: 'system',\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/**\n * An access attribute's value as a record carries it: a single attribute's\n * value or null, a multiple one's values, distinct and sorted. An integer is\n * a `Long` on the server: wow-generator types it `string` and marks it to be\n * read as its exact text ({@link AggregateTextNumbers.access}).\n */\nexport type AccessValue =\n string | number | boolean | null | readonly (string | number | boolean)[];\n\n/**\n * A record's access attributes by name, as the aggregate declares them\n * (`@Access` on its state, the Manifest's `access`): a generated client types\n * them as an `<Aggregate>Access` interface instead.\n */\nexport type AccessValues = Readonly<Record<string, AccessValue>>;\n\n/**\n * The access attributes of an aggregate that declares none: a record's\n * `access` is then empty, and a query names no `access.<name>`.\n */\nexport type NoAccess = Readonly<Record<never, never>>;\n\n/**\n * The `access` of an event stream: the aggregate's current owner and space\n * beside its declared access attributes `A`.\n */\nexport type StreamAccess<A = AccessValues> = A & {\n readonly owner?: string | null;\n readonly space?: string | null;\n};\n\n/** The `access.<name>` field paths of the access attributes `A`. */\nexport type AccessField<A> = `access.${keyof A & 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/**\n * The body of `wow.schedule.ScheduleSet`: the aggregate set its\n * schedule `key`, to send `target` the command of type `commandType`\n * (`command` its body, a JSON object) 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: Readonly<Record<string, unknown>>;\n}\n\n/** The body of `wow.schedule.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.schedule.ScheduleSet', ScheduleSet>\n | CommittedEvent<'wow.schedule.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 * @typeParam A - The aggregate's access attributes.\n */\nexport interface CommitView<\n S = unknown,\n E extends CommittedEvent = CommittedEvent,\n A = AccessValues,\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 /** Its declared access attributes after the commit. */\n readonly access: A;\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 A = AccessValues,\n> {\n readonly ref: AggregateRef;\n readonly commits: readonly CommitView<S, E, A>[];\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 * @typeParam A - The aggregate's access attributes.\n */\nexport interface Snapshot<S = unknown, A = AccessValues> {\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 /**\n * Its declared access attributes. A snapshot written before an attribute\n * was declared lacks it.\n */\n readonly access: A;\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 | 'access'\n | 'firstEventTime'\n | 'lastEventTime'\n | 'operator'\n | 'operator.id'\n | 'operator.tenantId'\n | 'operator.actedElsewhere'\n | 'firstOperator'\n | 'firstOperator.id'\n | 'firstOperator.tenantId'\n | 'firstOperator.actedElsewhere'\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 * @typeParam A - The aggregate's declared access attributes.\n */\nexport interface EventStream<\n E extends CommittedEvent = CommittedEvent,\n A = AccessValues,\n> {\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 /**\n * The aggregate's current access attributes, its owner and space among\n * them, kept current as they change (decision D390); null while the stream\n * is not stamped (appended before the log recorded them, or imported\n * without them).\n */\n readonly access?: StreamAccess<A> | null;\n readonly events: readonly E[];\n}\n\n/**\n * The fields of an event stream record a query names: its\n * system fields, `access` and its built-in `owner` and `space` (a declared\n * attribute is an {@link AccessField}), and `events`, the array an\n * `elementMatch` filter and an aggregation's `elements` reach an event\n * through, by the event's own `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.actedElsewhere'\n | 'access'\n | 'access.owner'\n | 'access.space'\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":";AAqFA,IAAaA,IAAQ;CAEnB,UAAU;CAEV,WAAW;CAEX,SAAS;AACX,GAwBaC,IAAe;CAE1B,SAAS;CAET,SAAS;CAET,OAAO;CAEP,MAAM;CAKN,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.7",
3
+ "version": "10.0.0-beta.2",
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",
@@ -89,14 +89,14 @@
89
89
  "@ahoo-wang/fetcher": "^6.0.1",
90
90
  "@ahoo-wang/fetcher-eventstream": "^6.0.1",
91
91
  "@eslint/js": "^10.0.1",
92
- "@microsoft/api-extractor": "^7.59.4",
93
- "@types/node": "^26.6.5",
92
+ "@microsoft/api-extractor": "^7.60.1",
93
+ "@types/node": "^26.6.6",
94
94
  "@vitest/coverage-v8": "4.1.12",
95
95
  "@vitest/ui": "^4.1.12",
96
- "eslint": "^10.13.0",
96
+ "eslint": "^10.14.0",
97
97
  "globals": "^17.13.0",
98
98
  "typescript": "~6.0.3",
99
- "typescript-eslint": "^8.72.0",
99
+ "typescript-eslint": "^8.72.1",
100
100
  "unplugin-dts": "1.1.2",
101
101
  "vite": "8.3.5",
102
102
  "vite-bundle-analyzer": "^1.3.9",
@@ -1,2 +0,0 @@
1
- function e(e){return[...e].every(e=>{let t=e.charCodeAt(0);return t>=9&&t<=13||t>=28&&t<=31||/^[\p{Zs}\p{Zl}\p{Zp}]$/u.test(e)})}var t={G:5,u:19,y:19,Q:5,q:5,M:5,L:5,D:3,d:2,F:1,E:5,e:5,c:[1,3,4,5],a:1,B:[1,4,5],h:2,H:2,k:2,K:2,m:2,s:2,S:9,A:19,n:19,N:19,V:[2],v:[1,4],z:4,O:[1,4],X:5,x:5,Z:5,W:1,w:2,Y:1/0,g:19};function n(e,n,r){let i=t[n];if(!(typeof i==`number`?r<=i:i?.includes(r)===!0))throw TypeError(`datePattern is invalid: [${e}].`)}function r(e,t){return e!==void 0&&(`uyDFdhHkKmsSgAnNWwY`.includes(e)||e===`c`&&t===1||`eMLQq`.includes(e)&&t<=2)}function i(t){if(typeof t!=`string`||e(t))throw TypeError(`datePattern cannot be blank.`);let i=!1,a=0;for(let e=0;e<t.length;e++){let o=t[e];if(o===`'`)t[e+1]===`'`?e++:i=!i;else if(!i){if(/[A-Za-z]/.test(o)){let i=o,a=e+1;for(;t[a]===i;)a++;let s=a-e,c=!1;if(i===`p`){if(c=!0,i=t[a],!i||!/[A-Za-z]/.test(i))throw TypeError(`datePattern is invalid: [${t}].`);let e=a++;for(;t[a]===i;)a++;s=a-e}if(n(t,i,s),c&&r(i,s)){let e=t[a],n=a;for(;n<t.length&&t[n]===e;)n++;if(r(e,n-a))throw TypeError(`datePattern is invalid: [${t}].`)}e=a-1}else if(o===`[`)a++;else if(o===`]`){if(a===0)throw TypeError(`datePattern is invalid: [${t}].`);a--}else if(`{}#`.includes(o))throw TypeError(`datePattern is invalid: [${t}].`)}}if(i)throw TypeError(`datePattern is invalid: [${t}].`)}exports.validateDatePattern=i;
2
- //# sourceMappingURL=datePattern.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"datePattern.cjs","names":["isKotlinBlank","value","code","character","DATE_PATTERN_COUNTS","validateDatePatternLetter","allowed","letter","count","pattern","isNumericDatePatternLetter","validateDatePattern","quoted","optionalDepth","index","end","padded","fieldStart","nextLetter","nextEnd"],"sources":["../../../src/dsl/filter/datePattern.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// Internal: not re-exported by filter/index.ts. The pattern syntax of\n// `java.time.format.DateTimeFormatter`, as far as `datePattern` is checked\n// before it reaches the server.\n\n/**\n * Kotlin's `String.isBlank()`: every character is `Char.isWhitespace()`,\n * which is Java's `isWhitespace` or `isSpaceChar` — the Unicode separators\n * (Zs, Zl, Zp) plus the controls U+0009–U+000D and U+001C–U+001F.\n * `String.trim()` is not the same set: it strips U+FEFF, which Kotlin keeps as\n * a literal, and keeps U+001C–U+001F, which Kotlin counts as blank.\n */\nfunction isKotlinBlank(value: string): boolean {\n return [...value].every(character => {\n const code = character.charCodeAt(0);\n return (\n (code >= 0x09 && code <= 0x0d) ||\n (code >= 0x1c && code <= 0x1f) ||\n /^[\\p{Zs}\\p{Zl}\\p{Zp}]$/u.test(character)\n );\n });\n}\n\n/** The repeat counts each pattern letter accepts. */\nconst DATE_PATTERN_COUNTS: Readonly<\n Record<string, number | readonly number[]>\n> = {\n G: 5,\n u: 19,\n y: 19,\n Q: 5,\n q: 5,\n M: 5,\n L: 5,\n D: 3,\n d: 2,\n F: 1,\n E: 5,\n e: 5,\n c: [1, 3, 4, 5],\n a: 1,\n B: [1, 4, 5],\n h: 2,\n H: 2,\n k: 2,\n K: 2,\n m: 2,\n s: 2,\n S: 9,\n A: 19,\n n: 19,\n N: 19,\n V: [2],\n v: [1, 4],\n z: 4,\n O: [1, 4],\n X: 5,\n x: 5,\n Z: 5,\n W: 1,\n w: 2,\n Y: Number.POSITIVE_INFINITY,\n g: 19,\n};\n\nfunction validateDatePatternLetter(\n pattern: string,\n letter: string,\n count: number,\n): void {\n const allowed = DATE_PATTERN_COUNTS[letter];\n const valid =\n typeof allowed === 'number'\n ? count <= allowed\n : allowed?.includes(count) === true;\n if (!valid) {\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n }\n}\n\nfunction isNumericDatePatternLetter(\n letter: string | undefined,\n count: number,\n): boolean {\n return (\n letter !== undefined &&\n ('uyDFdhHkKmsSgAnNWwY'.includes(letter) ||\n (letter === 'c' && count === 1) ||\n ('eMLQq'.includes(letter) && count <= 2))\n );\n}\n\n/**\n * Refuses a `datePattern` Wow refuses: a blank one (blank as Kotlin counts\n * it), and one `DateTimeFormatter.ofPattern` would refuse — an unknown letter\n * or repeat count, an unclosed quote, a `]` without its `[`, a reserved\n * character, or a padded numeric field followed directly by another numeric\n * field. `test/dsl/datePattern.test.ts` holds this to a corpus the JVM judged.\n */\nexport function validateDatePattern(pattern: string): void {\n if (typeof pattern !== 'string' || isKotlinBlank(pattern)) {\n throw new TypeError('datePattern cannot be blank.');\n }\n let quoted = false;\n let optionalDepth = 0;\n for (let index = 0; index < pattern.length; index++) {\n const character = pattern[index];\n if (character === \"'\") {\n if (pattern[index + 1] === \"'\") {\n index++;\n } else {\n quoted = !quoted;\n }\n continue;\n }\n if (quoted) continue;\n if (/[A-Za-z]/.test(character)) {\n let letter = character;\n let end = index + 1;\n while (pattern[end] === letter) end++;\n let count = end - index;\n let padded = false;\n if (letter === 'p') {\n padded = true;\n letter = pattern[end];\n if (!letter || !/[A-Za-z]/.test(letter)) {\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n }\n const fieldStart = end++;\n while (pattern[end] === letter) end++;\n count = end - fieldStart;\n }\n validateDatePatternLetter(pattern, letter, count);\n if (padded && isNumericDatePatternLetter(letter, count)) {\n const nextLetter = pattern[end];\n let nextEnd = end;\n while (nextEnd < pattern.length && pattern[nextEnd] === nextLetter)\n nextEnd++;\n if (isNumericDatePatternLetter(nextLetter, nextEnd - end)) {\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n }\n }\n index = end - 1;\n } else if (character === '[') {\n optionalDepth++;\n } else if (character === ']') {\n if (optionalDepth === 0)\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n optionalDepth--;\n } else if ('{}#'.includes(character)) {\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n }\n }\n if (quoted) {\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n }\n}\n"],"mappings":"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"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Refuses a `datePattern` Wow refuses: a blank one (blank as Kotlin counts
3
- * it), and one `DateTimeFormatter.ofPattern` would refuse — an unknown letter
4
- * or repeat count, an unclosed quote, a `]` without its `[`, a reserved
5
- * character, or a padded numeric field followed directly by another numeric
6
- * field. `test/dsl/datePattern.test.ts` holds this to a corpus the JVM judged.
7
- */
8
- export declare function validateDatePattern(pattern: string): void;
@@ -1,8 +0,0 @@
1
- /**
2
- * Refuses a `datePattern` Wow refuses: a blank one (blank as Kotlin counts
3
- * it), and one `DateTimeFormatter.ofPattern` would refuse — an unknown letter
4
- * or repeat count, an unclosed quote, a `]` without its `[`, a reserved
5
- * character, or a padded numeric field followed directly by another numeric
6
- * field. `test/dsl/datePattern.test.ts` holds this to a corpus the JVM judged.
7
- */
8
- export declare function validateDatePattern(pattern: string): void;
@@ -1,96 +0,0 @@
1
- // src/dsl/filter/datePattern.ts
2
- function e(e) {
3
- return [...e].every((e) => {
4
- let t = e.charCodeAt(0);
5
- return t >= 9 && t <= 13 || t >= 28 && t <= 31 || /^[\p{Zs}\p{Zl}\p{Zp}]$/u.test(e);
6
- });
7
- }
8
- var t = {
9
- G: 5,
10
- u: 19,
11
- y: 19,
12
- Q: 5,
13
- q: 5,
14
- M: 5,
15
- L: 5,
16
- D: 3,
17
- d: 2,
18
- F: 1,
19
- E: 5,
20
- e: 5,
21
- c: [
22
- 1,
23
- 3,
24
- 4,
25
- 5
26
- ],
27
- a: 1,
28
- B: [
29
- 1,
30
- 4,
31
- 5
32
- ],
33
- h: 2,
34
- H: 2,
35
- k: 2,
36
- K: 2,
37
- m: 2,
38
- s: 2,
39
- S: 9,
40
- A: 19,
41
- n: 19,
42
- N: 19,
43
- V: [2],
44
- v: [1, 4],
45
- z: 4,
46
- O: [1, 4],
47
- X: 5,
48
- x: 5,
49
- Z: 5,
50
- W: 1,
51
- w: 2,
52
- Y: Infinity,
53
- g: 19
54
- };
55
- function n(e, n, r) {
56
- let i = t[n];
57
- if (!(typeof i == "number" ? r <= i : i?.includes(r) === !0)) throw TypeError(`datePattern is invalid: [${e}].`);
58
- }
59
- function r(e, t) {
60
- return e !== void 0 && ("uyDFdhHkKmsSgAnNWwY".includes(e) || e === "c" && t === 1 || "eMLQq".includes(e) && t <= 2);
61
- }
62
- function i(t) {
63
- if (typeof t != "string" || e(t)) throw TypeError("datePattern cannot be blank.");
64
- let i = !1, a = 0;
65
- for (let e = 0; e < t.length; e++) {
66
- let o = t[e];
67
- if (o === "'") t[e + 1] === "'" ? e++ : i = !i;
68
- else if (!i) {
69
- if (/[A-Za-z]/.test(o)) {
70
- let i = o, a = e + 1;
71
- for (; t[a] === i;) a++;
72
- let s = a - e, c = !1;
73
- if (i === "p") {
74
- if (c = !0, i = t[a], !i || !/[A-Za-z]/.test(i)) throw TypeError(`datePattern is invalid: [${t}].`);
75
- let e = a++;
76
- for (; t[a] === i;) a++;
77
- s = a - e;
78
- }
79
- if (n(t, i, s), c && r(i, s)) {
80
- let e = t[a], n = a;
81
- for (; n < t.length && t[n] === e;) n++;
82
- if (r(e, n - a)) throw TypeError(`datePattern is invalid: [${t}].`);
83
- }
84
- e = a - 1;
85
- } else if (o === "[") a++;
86
- else if (o === "]") {
87
- if (a === 0) throw TypeError(`datePattern is invalid: [${t}].`);
88
- a--;
89
- } else if ("{}#".includes(o)) throw TypeError(`datePattern is invalid: [${t}].`);
90
- }
91
- }
92
- if (i) throw TypeError(`datePattern is invalid: [${t}].`);
93
- }
94
- export { i as validateDatePattern };
95
-
96
- //# sourceMappingURL=datePattern.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"datePattern.es.js","names":["isKotlinBlank","value","code","character","DATE_PATTERN_COUNTS","validateDatePatternLetter","allowed","letter","count","pattern","isNumericDatePatternLetter","validateDatePattern","quoted","optionalDepth","index","end","padded","fieldStart","nextLetter","nextEnd"],"sources":["../../../src/dsl/filter/datePattern.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// Internal: not re-exported by filter/index.ts. The pattern syntax of\n// `java.time.format.DateTimeFormatter`, as far as `datePattern` is checked\n// before it reaches the server.\n\n/**\n * Kotlin's `String.isBlank()`: every character is `Char.isWhitespace()`,\n * which is Java's `isWhitespace` or `isSpaceChar` — the Unicode separators\n * (Zs, Zl, Zp) plus the controls U+0009–U+000D and U+001C–U+001F.\n * `String.trim()` is not the same set: it strips U+FEFF, which Kotlin keeps as\n * a literal, and keeps U+001C–U+001F, which Kotlin counts as blank.\n */\nfunction isKotlinBlank(value: string): boolean {\n return [...value].every(character => {\n const code = character.charCodeAt(0);\n return (\n (code >= 0x09 && code <= 0x0d) ||\n (code >= 0x1c && code <= 0x1f) ||\n /^[\\p{Zs}\\p{Zl}\\p{Zp}]$/u.test(character)\n );\n });\n}\n\n/** The repeat counts each pattern letter accepts. */\nconst DATE_PATTERN_COUNTS: Readonly<\n Record<string, number | readonly number[]>\n> = {\n G: 5,\n u: 19,\n y: 19,\n Q: 5,\n q: 5,\n M: 5,\n L: 5,\n D: 3,\n d: 2,\n F: 1,\n E: 5,\n e: 5,\n c: [1, 3, 4, 5],\n a: 1,\n B: [1, 4, 5],\n h: 2,\n H: 2,\n k: 2,\n K: 2,\n m: 2,\n s: 2,\n S: 9,\n A: 19,\n n: 19,\n N: 19,\n V: [2],\n v: [1, 4],\n z: 4,\n O: [1, 4],\n X: 5,\n x: 5,\n Z: 5,\n W: 1,\n w: 2,\n Y: Number.POSITIVE_INFINITY,\n g: 19,\n};\n\nfunction validateDatePatternLetter(\n pattern: string,\n letter: string,\n count: number,\n): void {\n const allowed = DATE_PATTERN_COUNTS[letter];\n const valid =\n typeof allowed === 'number'\n ? count <= allowed\n : allowed?.includes(count) === true;\n if (!valid) {\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n }\n}\n\nfunction isNumericDatePatternLetter(\n letter: string | undefined,\n count: number,\n): boolean {\n return (\n letter !== undefined &&\n ('uyDFdhHkKmsSgAnNWwY'.includes(letter) ||\n (letter === 'c' && count === 1) ||\n ('eMLQq'.includes(letter) && count <= 2))\n );\n}\n\n/**\n * Refuses a `datePattern` Wow refuses: a blank one (blank as Kotlin counts\n * it), and one `DateTimeFormatter.ofPattern` would refuse — an unknown letter\n * or repeat count, an unclosed quote, a `]` without its `[`, a reserved\n * character, or a padded numeric field followed directly by another numeric\n * field. `test/dsl/datePattern.test.ts` holds this to a corpus the JVM judged.\n */\nexport function validateDatePattern(pattern: string): void {\n if (typeof pattern !== 'string' || isKotlinBlank(pattern)) {\n throw new TypeError('datePattern cannot be blank.');\n }\n let quoted = false;\n let optionalDepth = 0;\n for (let index = 0; index < pattern.length; index++) {\n const character = pattern[index];\n if (character === \"'\") {\n if (pattern[index + 1] === \"'\") {\n index++;\n } else {\n quoted = !quoted;\n }\n continue;\n }\n if (quoted) continue;\n if (/[A-Za-z]/.test(character)) {\n let letter = character;\n let end = index + 1;\n while (pattern[end] === letter) end++;\n let count = end - index;\n let padded = false;\n if (letter === 'p') {\n padded = true;\n letter = pattern[end];\n if (!letter || !/[A-Za-z]/.test(letter)) {\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n }\n const fieldStart = end++;\n while (pattern[end] === letter) end++;\n count = end - fieldStart;\n }\n validateDatePatternLetter(pattern, letter, count);\n if (padded && isNumericDatePatternLetter(letter, count)) {\n const nextLetter = pattern[end];\n let nextEnd = end;\n while (nextEnd < pattern.length && pattern[nextEnd] === nextLetter)\n nextEnd++;\n if (isNumericDatePatternLetter(nextLetter, nextEnd - end)) {\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n }\n }\n index = end - 1;\n } else if (character === '[') {\n optionalDepth++;\n } else if (character === ']') {\n if (optionalDepth === 0)\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n optionalDepth--;\n } else if ('{}#'.includes(character)) {\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n }\n }\n if (quoted) {\n throw new TypeError(`datePattern is invalid: [${pattern}].`);\n }\n}\n"],"mappings":"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"}