@rotorsoft/act 1.32.30 → 1.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +0 -1
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/@types/act.d.ts +96 -385
  4. package/dist/@types/act.d.ts.map +1 -1
  5. package/dist/@types/adapters/in-memory-store.d.ts.map +1 -1
  6. package/dist/@types/builders/act-builder.d.ts +2 -115
  7. package/dist/@types/builders/act-builder.d.ts.map +1 -1
  8. package/dist/@types/builders/builder-utils.d.ts +1 -1
  9. package/dist/@types/builders/builder-utils.d.ts.map +1 -1
  10. package/dist/@types/builders/event-builder.d.ts +5 -5
  11. package/dist/@types/builders/event-builder.d.ts.map +1 -1
  12. package/dist/@types/builders/merge.d.ts +1 -1
  13. package/dist/@types/builders/merge.d.ts.map +1 -1
  14. package/dist/@types/builders/projection-builder.d.ts +2 -144
  15. package/dist/@types/builders/projection-builder.d.ts.map +1 -1
  16. package/dist/@types/builders/slice-builder.d.ts +2 -71
  17. package/dist/@types/builders/slice-builder.d.ts.map +1 -1
  18. package/dist/@types/builders/state-builder.d.ts +2 -376
  19. package/dist/@types/builders/state-builder.d.ts.map +1 -1
  20. package/dist/@types/config.d.ts +6 -43
  21. package/dist/@types/config.d.ts.map +1 -1
  22. package/dist/@types/csv.d.ts +1 -15
  23. package/dist/@types/csv.d.ts.map +1 -1
  24. package/dist/@types/index.d.ts +0 -1
  25. package/dist/@types/index.d.ts.map +1 -1
  26. package/dist/@types/internal/autoclose-policy.d.ts +1 -59
  27. package/dist/@types/internal/autoclose-policy.d.ts.map +1 -1
  28. package/dist/@types/internal/autoclose-reaction.d.ts +1 -2
  29. package/dist/@types/internal/autoclose-reaction.d.ts.map +1 -1
  30. package/dist/@types/internal/autoclose-window.d.ts +1 -1
  31. package/dist/@types/internal/autoclose-window.d.ts.map +1 -1
  32. package/dist/@types/internal/circuit-breaker.d.ts +1 -2
  33. package/dist/@types/internal/circuit-breaker.d.ts.map +1 -1
  34. package/dist/@types/{builders/build-classify.d.ts → internal/classify.d.ts} +2 -15
  35. package/dist/@types/internal/classify.d.ts.map +1 -0
  36. package/dist/@types/internal/close-cycle.d.ts.map +1 -1
  37. package/dist/@types/internal/config.d.ts +2 -42
  38. package/dist/@types/internal/config.d.ts.map +1 -1
  39. package/dist/@types/internal/correlate-cycle.d.ts +1 -1
  40. package/dist/@types/internal/correlate-cycle.d.ts.map +1 -1
  41. package/dist/@types/internal/{correlator.d.ts → correlation-id.d.ts} +1 -1
  42. package/dist/@types/internal/correlation-id.d.ts.map +1 -0
  43. package/dist/@types/internal/defer-config.d.ts.map +1 -1
  44. package/dist/@types/internal/drain-cycle.d.ts +1 -1
  45. package/dist/@types/internal/drain-cycle.d.ts.map +1 -1
  46. package/dist/@types/internal/{drain.d.ts → drain-ops.d.ts} +1 -1
  47. package/dist/@types/internal/drain-ops.d.ts.map +1 -0
  48. package/dist/@types/internal/event-sourcing.d.ts +1 -8
  49. package/dist/@types/internal/event-sourcing.d.ts.map +1 -1
  50. package/dist/@types/internal/{sensitive.d.ts → pii.d.ts} +4 -71
  51. package/dist/@types/internal/pii.d.ts.map +1 -0
  52. package/dist/@types/internal/projection-fold.d.ts +1 -2
  53. package/dist/@types/internal/projection-fold.d.ts.map +1 -1
  54. package/dist/@types/internal/{close-signal.d.ts → reaction-dispatch.d.ts} +47 -2
  55. package/dist/@types/internal/reaction-dispatch.d.ts.map +1 -0
  56. package/dist/@types/internal/report-once.d.ts +1 -1
  57. package/dist/@types/internal/settle.d.ts +21 -12
  58. package/dist/@types/internal/settle.d.ts.map +1 -1
  59. package/dist/@types/internal/tracing.d.ts +3 -3
  60. package/dist/@types/internal/tracing.d.ts.map +1 -1
  61. package/dist/@types/ports.d.ts +3 -43
  62. package/dist/@types/ports.d.ts.map +1 -1
  63. package/dist/@types/scoped.d.ts +1 -6
  64. package/dist/@types/scoped.d.ts.map +1 -1
  65. package/dist/@types/sensitive.d.ts +56 -0
  66. package/dist/@types/sensitive.d.ts.map +1 -0
  67. package/dist/@types/test/index.d.ts +1 -0
  68. package/dist/@types/test/index.d.ts.map +1 -1
  69. package/dist/@types/test/sandbox.d.ts +2 -26
  70. package/dist/@types/test/sandbox.d.ts.map +1 -1
  71. package/dist/@types/types/act.d.ts +214 -0
  72. package/dist/@types/types/act.d.ts.map +1 -0
  73. package/dist/@types/types/action.d.ts +69 -2
  74. package/dist/@types/types/action.d.ts.map +1 -1
  75. package/dist/@types/types/builders.d.ts +721 -0
  76. package/dist/@types/types/builders.d.ts.map +1 -0
  77. package/dist/@types/types/errors.d.ts +31 -1
  78. package/dist/@types/types/errors.d.ts.map +1 -1
  79. package/dist/@types/types/index.d.ts +38 -0
  80. package/dist/@types/types/index.d.ts.map +1 -1
  81. package/dist/@types/types/ports.d.ts +20 -18
  82. package/dist/@types/types/ports.d.ts.map +1 -1
  83. package/dist/@types/types/reaction.d.ts +11 -1
  84. package/dist/@types/types/reaction.d.ts.map +1 -1
  85. package/dist/@types/types/sandbox.d.ts +31 -0
  86. package/dist/@types/types/sandbox.d.ts.map +1 -0
  87. package/dist/@types/types/schemas.d.ts +12 -17
  88. package/dist/@types/types/schemas.d.ts.map +1 -1
  89. package/dist/chunk-NNWP65YM.cjs +264 -0
  90. package/dist/chunk-NNWP65YM.cjs.map +1 -0
  91. package/dist/{chunk-X3MMQIIP.js → chunk-NYH6FNTM.js} +174 -22
  92. package/dist/chunk-NYH6FNTM.js.map +1 -0
  93. package/dist/{chunk-HHKLVRR4.js → chunk-TJ4JRRUR.js} +38 -57
  94. package/dist/chunk-TJ4JRRUR.js.map +1 -0
  95. package/dist/chunk-YKL44PYX.cjs +1233 -0
  96. package/dist/chunk-YKL44PYX.cjs.map +1 -0
  97. package/dist/index.cjs +1954 -3440
  98. package/dist/index.cjs.map +1 -1
  99. package/dist/index.js +911 -1063
  100. package/dist/index.js.map +1 -1
  101. package/dist/test/index.cjs +16 -1113
  102. package/dist/test/index.cjs.map +1 -1
  103. package/dist/test/index.js +2 -2
  104. package/dist/test/index.js.map +1 -1
  105. package/dist/types/index.cjs +58 -276
  106. package/dist/types/index.cjs.map +1 -1
  107. package/dist/types/index.js +15 -1
  108. package/package.json +2 -2
  109. package/dist/@types/builders/build-classify.d.ts.map +0 -1
  110. package/dist/@types/builders/builder-base.d.ts +0 -70
  111. package/dist/@types/builders/builder-base.d.ts.map +0 -1
  112. package/dist/@types/builders/reaction-builder.d.ts +0 -55
  113. package/dist/@types/builders/reaction-builder.d.ts.map +0 -1
  114. package/dist/@types/internal/close-signal.d.ts.map +0 -1
  115. package/dist/@types/internal/correlator.d.ts.map +0 -1
  116. package/dist/@types/internal/defer-signal.d.ts +0 -32
  117. package/dist/@types/internal/defer-signal.d.ts.map +0 -1
  118. package/dist/@types/internal/drain.d.ts.map +0 -1
  119. package/dist/@types/internal/index.d.ts +0 -38
  120. package/dist/@types/internal/index.d.ts.map +0 -1
  121. package/dist/@types/internal/sensitive.d.ts.map +0 -1
  122. package/dist/chunk-HHKLVRR4.js.map +0 -1
  123. package/dist/chunk-X3MMQIIP.js.map +0 -1
@@ -1,378 +1,5 @@
1
- /**
2
- * @module state-builder
3
- * @category Builders
4
- *
5
- * Fluent interface for defining a strongly-typed state machine using Zod schemas.
6
- */
7
- import type { ZodType } from "zod";
8
- import { type AutoclosePolicy } from "../internal/index.js";
9
- import type { ActionHandler, ActionOptions, Actor, AutocloseArchiver, Committed, Invariant, PatchHandlers, Schema, Schemas, Snapshot, State, ZodTypes } from "../types/index.js";
10
- /**
11
- * Builder interface for defining a state with event sourcing.
12
- *
13
- * Provides a fluent API to configure the initial state, event types,
14
- * and event handlers (reducers) before moving to action configuration.
15
- *
16
- * @template TState - State schema type
17
- * @template TName - State name literal type
18
- *
19
- * @see {@link state} for usage examples
20
- * @see {@link ActionBuilder} for action configuration
21
- */
22
- export type StateBuilder<TState extends Schema, TName extends string = string> = {
23
- /**
24
- * Defines the initial state for new state instances.
25
- *
26
- * The init function is called when a new stream is created (first event).
27
- * It can accept initial data or return a default state.
28
- *
29
- * @param init - Function returning the initial state
30
- * @returns A builder with `.emits()` to declare event types
31
- *
32
- * @example
33
- * ```typescript
34
- * .init(() => ({ count: 0, created: new Date() }))
35
- * ```
36
- */
37
- init: (init: () => Readonly<TState>) => {
38
- /**
39
- * Declares the event types that this state can emit.
40
- *
41
- * Events represent facts that have happened - they should be named in past tense.
42
- * Each event is defined with a Zod schema for type safety and runtime validation.
43
- *
44
- * @template TEvents - Event schemas type
45
- * @param events - Object mapping event names to Zod schemas
46
- * @returns An ActionBuilder (with optional `.patch()` to override specific reducers)
47
- *
48
- * @example
49
- * ```typescript
50
- * .emits({
51
- * Incremented: z.object({ amount: z.number() }),
52
- * Decremented: z.object({ amount: z.number() }),
53
- * Reset: z.object({})
54
- * })
55
- * ```
56
- */
57
- emits: <TEvents extends Schemas>(events: ZodTypes<TEvents>) => ActionBuilder<TState, TEvents, {}, TName> & {
58
- /**
59
- * Overrides specific event reducers. Events without a custom patch
60
- * default to passthrough: `({ data }) => data` (event data merges
61
- * into state).
62
- *
63
- * @param patch - Partial map of event names to patch handler functions
64
- * @returns An ActionBuilder for defining actions
65
- *
66
- * @example Only override the events that need custom logic
67
- * ```typescript
68
- * .emits({ TicketOpened, TicketClosed, TicketResolved })
69
- * .patch({
70
- * TicketOpened: ({ data }) => {
71
- * const { message, messageId, userId, ...other } = data;
72
- * return { ...other, userId, messages: { [messageId]: { ... } } };
73
- * },
74
- * })
75
- * // TicketClosed and TicketResolved use passthrough
76
- * ```
77
- */
78
- patch: (patch: Partial<PatchHandlers<TState, TEvents>>) => ActionBuilder<TState, TEvents, {}, TName>;
79
- };
80
- };
81
- };
82
- /** Helper: a single-key record mapping a state name to its Zod schema. */
83
- type StateEntry<TKey extends string = string, TState extends Schema = Schema> = {
84
- [P in TKey]: ZodType<TState>;
85
- };
86
- /** Helper: a single-key record mapping an action name to its Zod schema. */
87
- type ActionEntry<TKey extends string = string, TNewActions extends Schema = Schema> = {
88
- [P in TKey]: ZodType<TNewActions>;
89
- };
90
- /**
91
- * Builder interface for defining actions (commands) on a state.
92
- *
93
- * Actions represent user/system intents to modify state. Each action is validated
94
- * against a schema, can have business rule invariants, and must emit one or more events.
95
- *
96
- * @template TState - State schema type
97
- * @template TEvents - Event schemas type
98
- * @template TActions - Action schemas type
99
- * @template TName - State name literal type
100
- * @template TSnap - `true` once `.snap(...)` has been called. Gates the
101
- * `.autocloses({ keep })` rolling-window option — a windowed close is
102
- * meaningless without snapshots, so `keep` only typechecks after
103
- * `.snap` in the chain.
104
- *
105
- * @see {@link state} for complete usage examples
106
- */
107
- export type ActionBuilder<TState extends Schema, TEvents extends Schemas, TActions extends Schemas, TName extends string = string, TSnap extends boolean = false> = {
108
- /**
109
- * Defines an action (command) that can be executed on this state.
110
- *
111
- * Actions represent intents to change state - they should be named in imperative form
112
- * (e.g., "CreateUser", "IncrementCounter", "PlaceOrder"). Actions are validated against
113
- * their schema and must emit at least one event.
114
- *
115
- * Pass a `{ ActionName: schema }` record — use shorthand `{ ActionName }`
116
- * when the variable name matches the action name. The key becomes the
117
- * action name, the value the Zod schema.
118
- *
119
- * Pass an optional second argument to declare a per-action retry
120
- * policy — the orchestrator retries this action on
121
- * {@link ConcurrencyError} up to `maxRetries` extra times, applying
122
- * `backoff` between attempts when set. Omit the argument to keep the
123
- * current single-attempt behavior (`ConcurrencyError` surfaces on
124
- * first conflict).
125
- *
126
- * @template TKey - Action name (string literal type)
127
- * @template TNewActions - Action payload schema type
128
- * @param entry - Single-key record `{ ActionName: schema }`
129
- * @param options - Optional per-action retry policy
130
- * ({@link ActionOptions}).
131
- * @returns An object with `.given()` and `.emit()` for further configuration
132
- *
133
- * @example Simple action without invariants
134
- * ```typescript
135
- * .on({ increment: z.object({ by: z.number() }) })
136
- * .emit((action) => ["Incremented", { amount: action.by }])
137
- * ```
138
- */
139
- on: <TKey extends string, TNewActions extends Schema>(entry: ActionEntry<TKey, TNewActions>, options?: ActionOptions) => {
140
- /**
141
- * Adds business rule invariants that must hold before the action can execute.
142
- *
143
- * Invariants are checked after loading the current state but before emitting
144
- * events. Each invariant pairs a `description` with a `valid(state, actor?)`
145
- * predicate — when a predicate returns `false`, the action throws
146
- * `InvariantError` carrying the description. All invariants must pass for
147
- * the action to succeed.
148
- *
149
- * @param rules - Array of {@link Invariant} objects (`{ description, valid }`)
150
- * @returns An object with `.emit()` to finalize the action
151
- *
152
- * @example
153
- * ```typescript
154
- * .given([
155
- * { description: "Must be active", valid: (state) => state.status === "active" },
156
- * { description: "Must be the owner", valid: (state, actor) => state.ownerId === actor?.id }
157
- * ])
158
- * ```
159
- */
160
- given: (rules: Invariant<TState>[]) => {
161
- /**
162
- * Defines the action handler that emits events.
163
- *
164
- * The handler receives the action payload and current state snapshot,
165
- * and must return one or more events to emit. Events are applied to state
166
- * via the patch handlers defined earlier.
167
- *
168
- * Pass a string event name for passthrough: the action payload becomes
169
- * the event data directly.
170
- *
171
- * @param handler - Function that returns events to emit, or event name string for passthrough
172
- * @returns The ActionBuilder for chaining more actions
173
- *
174
- * @example Custom handler
175
- * ```typescript
176
- * .emit((action, snapshot) => {
177
- * const newBalance = snapshot.state.balance + action.amount;
178
- * return ["Deposited", { amount: action.amount, newBalance }];
179
- * })
180
- * ```
181
- */
182
- emit: {
183
- /** Custom handler — receives `(action, snapshot)` and returns one
184
- * or more `[EventName, data]` tuples (or `undefined`). */
185
- (handler: ActionHandler<TState, TEvents, {
186
- [P in TKey]: TNewActions;
187
- }, TKey>): ActionBuilder<TState, TEvents, TActions & {
188
- [P in TKey]: TNewActions;
189
- }, TName, TSnap>;
190
- /** Passthrough — the action payload becomes the event data
191
- * directly. Must reference an event declared in `.emits()`. */
192
- (event_name: keyof TEvents & string): ActionBuilder<TState, TEvents, TActions & {
193
- [P in TKey]: TNewActions;
194
- }, TName, TSnap>;
195
- };
196
- };
197
- /**
198
- * Defines the action handler that emits events. Same two overloads as
199
- * the post-`.given()` form above:
200
- *
201
- * - **Function** — receives `(action, snapshot)` and returns one or
202
- * more `[EventName, data]` tuples (or `undefined`).
203
- * - **String** — passthrough: the action payload becomes the event
204
- * data directly. Must reference an event declared in `.emits()`.
205
- *
206
- * The two overloads are kept separate (rather than merged into a
207
- * `handler | string` union) so that TS contextual typing of the
208
- * function alternative isn't degraded by considering the string
209
- * branch — under the union form `TState` could collapse to its
210
- * `Schema` constraint inside the callback.
211
- *
212
- * @example Passthrough (action payload = event data)
213
- * ```typescript
214
- * .emit("Incremented")
215
- * ```
216
- */
217
- emit: {
218
- (handler: ActionHandler<TState, TEvents, {
219
- [P in TKey]: TNewActions;
220
- }, TKey>): ActionBuilder<TState, TEvents, TActions & {
221
- [P in TKey]: TNewActions;
222
- }, TName, TSnap>;
223
- (event_name: keyof TEvents & string): ActionBuilder<TState, TEvents, TActions & {
224
- [P in TKey]: TNewActions;
225
- }, TName, TSnap>;
226
- };
227
- };
228
- /**
229
- * Defines a snapshotting strategy to optimize state reconstruction.
230
- *
231
- * Snapshots store the current state at a point in time, allowing faster state loading
232
- * by avoiding replaying all events from the beginning. The snap function is called
233
- * after each event is applied and should return `true` when a snapshot should be taken.
234
- *
235
- * @param snap - Predicate function that returns true when a snapshot should be taken
236
- * @returns The ActionBuilder for chaining
237
- *
238
- * @example Snapshot every 10 events
239
- * ```typescript
240
- * .snap((snapshot) => snapshot.patches >= 10)
241
- * ```
242
- */
243
- snap: (snap: (snapshot: Snapshot<TState, TEvents>) => boolean) => ActionBuilder<TState, TEvents, TActions, TName, true>;
244
- /**
245
- * Declares the disclosure predicate for `sensitive(...)`-marked event
246
- * fields. Gates external reads: returning `true` allows the actor to see
247
- * plaintext on the event; returning `false` substitutes `"[REDACTED]"`.
248
- * When absent, the framework default-denies on every external read —
249
- * fail-safe.
250
- *
251
- * One predicate per state. A second `.discloses(...)` call replaces the
252
- * first (same shape as snapshots being state-level, not per-event).
253
- *
254
- * The predicate receives the full event including merged PII so it can
255
- * branch on the payload itself (e.g.
256
- * `event.data.ownerId === actor.id`). Reducers, projections, and
257
- * reactions are unaffected — they follow separate visibility rules.
258
- *
259
- * @param disclose - Predicate `(event, actor) => boolean`. `true` =
260
- * plaintext, `false` = `"[REDACTED]"` substitution.
261
- * @returns The ActionBuilder for chaining.
262
- *
263
- * @example Owner-or-admin disclosure
264
- * ```typescript
265
- * state({ User: userSchema })
266
- * .init(() => ({ ... }))
267
- * .emits({ UserRegistered: z.object({ email: sensitive(z.string()) }) })
268
- * .discloses((event, actor) =>
269
- * actor.id === event.stream || actor.roles?.includes("admin"))
270
- * ```
271
- */
272
- discloses: (disclose: (event: Committed<TEvents, keyof TEvents & string>, actor: Actor) => boolean) => ActionBuilder<TState, TEvents, TActions, TName, TSnap>;
273
- /**
274
- * Declares the online close predicate for this state. The
275
- * orchestrator's autoclose cycle iterates the state's streams once
276
- * per tick and calls the predicate per candidate; truthy results are
277
- * scheduled for atomic truncate-and-seed via `Store.truncate` on the
278
- * next batch.
279
- *
280
- * One predicate per state. A second `.autocloses(...)` call replaces
281
- * the first (same shape as `.snap` / `.discloses` — state-level, not
282
- * per-event). Absent → the state opts out of online close entirely;
283
- * the cycle skips it and pays zero per-tick cost for it.
284
- *
285
- * Pass a declarative {@link AutoclosePolicy} object literal covering the
286
- * three operational pressure points (`after`, `is`, `reaches`). Top-level
287
- * fields combine with AND; an optional `or: {...}` block opens an
288
- * alternative OR path. Validated via Zod at build time; misconfiguration
289
- * throws before `act().build()` completes.
290
- *
291
- * Under the hood this compiles to a synthesized reaction that runs
292
- * on a per-aggregate synthetic stream: it defers to `head.created + the
293
- * policy's min after` while the cooldown holds and closes the stream once
294
- * the policy matches. There is no background sweep.
295
- *
296
- * **The function-predicate form was removed.** `.autocloses` no
297
- * longer accepts `(stream, head, count) => boolean`; an opaque predicate has
298
- * no derivable due-time or terminal event to react to. For conditions the
299
- * declarative form can't express, call `app.close(...)` from your own logic.
300
- *
301
- * @param policy The declarative {@link AutoclosePolicy} bag.
302
- * @returns The ActionBuilder for chaining.
303
- *
304
- * @example Declarative — cooldown after terminal (a Ticket closes
305
- * 90 days after resolution).
306
- * ```typescript
307
- * .autocloses({ is: "TicketResolved", after: { days: 90 } })
308
- * ```
309
- */
310
- autocloses: (policy: [TSnap] extends [true] ? AutoclosePolicy : Omit<AutoclosePolicy, "keep"> & {
311
- /** Rolling-window retention requires `.snap(...)` earlier in
312
- * the builder chain — a windowed close prunes behind a real
313
- * snapshot, so a state that never snapshots has nothing to
314
- * prune behind. */
315
- keep?: never;
316
- }) => ActionBuilder<TState, TEvents, TActions, TName, TSnap>;
317
- /**
318
- * Declares the archiver the online close cycle runs **before**
319
- * truncating a stream this state's `.autocloses(...)` predicate
320
- * accepted. Hosts use it to write events to durable storage (S3,
321
- * an analytics warehouse, cold tier) before the tombstone lands,
322
- * so the truncate doesn't lose history that the operator still
323
- * needs.
324
- *
325
- * Threads into `CloseTarget.archive` via the same plumbing
326
- * `app.close({ stream, archive })` already uses — the cycle holds
327
- * the stream's guard while the archiver runs, and a thrown
328
- * archiver leaves the stream guarded but un-truncated. No partial
329
- * truncate state, no data loss. It is not retried automatically;
330
- * `app.close([{ stream, archive }])` resumes the guarded stream.
331
- *
332
- * One archiver per state. A second `.archives(...)` call replaces
333
- * the first (same shape as `.snap` / `.discloses` /
334
- * `.autocloses`). Absent → the cycle truncates without an archive
335
- * step.
336
- *
337
- * @param archive `(stream, head) => Promise<void>`. Runs while
338
- * the stream is locked against new writes; the truncate runs
339
- * immediately after a successful resolve.
340
- * @returns The ActionBuilder for chaining.
341
- *
342
- * @example Archive to S3 before truncate.
343
- * ```typescript
344
- * state({ Ticket: ticketSchema })
345
- * .emits({ TicketOpened, TicketResolved })
346
- * // ...
347
- * .autocloses({ is: "TicketResolved" })
348
- * .archives(async (stream) => {
349
- * const events = await loadEvents(stream);
350
- * await s3.upload(`tickets/${stream}.jsonl`, events);
351
- * })
352
- * ```
353
- */
354
- archives: (archive: AutocloseArchiver<TEvents>) => ActionBuilder<TState, TEvents, TActions, TName, TSnap>;
355
- /**
356
- * Finalizes and builds the state definition.
357
- *
358
- * Call this method after defining all actions, invariants, and patches to create
359
- * the complete State object that can be registered with Act.
360
- *
361
- * @returns The complete strongly-typed State definition
362
- *
363
- * @example
364
- * ```typescript
365
- * const Counter = state({ Counter: schema })
366
- * .init(() => ({ count: 0 }))
367
- * .emits({ Incremented: z.object({ amount: z.number() }) })
368
- * .patch({ Incremented: ({ data }, state) => ({ count: state.count + data.amount }) })
369
- * .on({ increment: z.object({ by: z.number() }) })
370
- * .emit((action) => ["Incremented", { amount: action.by }])
371
- * .build(); // Returns State<TState, TEvents, TActions, TName>
372
- * ```
373
- */
374
- build: () => State<TState, TEvents, TActions, TName>;
375
- };
1
+ import type { StateBuilder, StateEntry } from "../types/builders.js";
2
+ import type { Schema } from "../types/index.js";
376
3
  /**
377
4
  * Creates a new state definition with event sourcing capabilities.
378
5
  *
@@ -417,5 +44,4 @@ export type ActionBuilder<TState extends Schema, TEvents extends Schemas, TActio
417
44
  * @see {@link https://rotorsoft.github.io/act-root/docs/examples/calculator | Calculator Example}
418
45
  */
419
46
  export declare function state<TName extends string, TState extends Schema>(entry: StateEntry<TName, TState>): StateBuilder<TState, TName>;
420
- export {};
421
47
  //# sourceMappingURL=state-builder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/state-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,KAAK,EACL,iBAAiB,EAEjB,SAAS,EAET,SAAS,EAET,aAAa,EACb,MAAM,EACN,OAAO,EACP,QAAQ,EACR,KAAK,EACL,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,CACtB,MA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CG;AACH,wBAAgB,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,EAC/D,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,GAC/B,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAmD7B"}
1
+ {"version":3,"file":"state-builder.d.ts","sourceRoot":"","sources":["../../../src/builders/state-builder.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAGV,YAAY,EACZ,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAYV,MAAM,EAKP,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,EAC/D,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,GAC/B,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAmD7B"}
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { type ActOptions, type AutocloseConfig, type Config } from "./types/index.js";
2
3
  /**
3
4
  * Zod schema for validating package.json metadata.
4
5
  * @internal
@@ -14,48 +15,6 @@ export declare const PackageSchema: z.ZodObject<{
14
15
  license: z.ZodOptional<z.ZodString>;
15
16
  dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
16
17
  }, z.core.$strip>;
17
- /**
18
- * Type representing the validated package.json metadata.
19
- *
20
- * @internal
21
- */
22
- export type Package = z.infer<typeof PackageSchema>;
23
- /**
24
- * Zod schema for the full Act Framework configuration object.
25
- * Includes package metadata, environment, logging, and timing options.
26
- * @internal
27
- */
28
- declare const BaseSchema: z.ZodObject<{
29
- name: z.ZodString;
30
- version: z.ZodString;
31
- description: z.ZodOptional<z.ZodString>;
32
- author: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodObject<{
33
- name: z.ZodString;
34
- email: z.ZodOptional<z.ZodString>;
35
- }, z.core.$strip>>, z.ZodString]>>;
36
- license: z.ZodOptional<z.ZodString>;
37
- dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
38
- env: z.ZodEnum<{
39
- development: "development";
40
- production: "production";
41
- staging: "staging";
42
- test: "test";
43
- }>;
44
- logLevel: z.ZodEnum<{
45
- debug: "debug";
46
- error: "error";
47
- fatal: "fatal";
48
- info: "info";
49
- trace: "trace";
50
- warn: "warn";
51
- }>;
52
- logSingleLine: z.ZodBoolean;
53
- sleepMs: z.ZodNumber;
54
- }, z.core.$strip>;
55
- /**
56
- * Type representing the validated Act Framework configuration object.
57
- */
58
- export type Config = z.infer<typeof BaseSchema>;
59
18
  /**
60
19
  * Gets the current Act Framework configuration.
61
20
  *
@@ -88,5 +47,9 @@ export type Config = z.infer<typeof BaseSchema>;
88
47
  * @see {@link Config} for configuration type
89
48
  */
90
49
  export declare const config: () => Config;
91
- export {};
50
+ /**
51
+ * Validates and defaults the autoclose knobs of `ActOptions`, the way
52
+ * `act().build()` does. Throws `ZodError` on an out-of-range value.
53
+ */
54
+ export declare function resolveAutocloseConfig(options: ActOptions | undefined): AutocloseConfig;
92
55
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;iBAWxB,CAAC;AAEH;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAsDpD;;;;GAIG;AACH,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKd,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAsBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,MAAM,QAAO,MAwBzB,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,MAAM,EAMZ,MAAM,kBAAkB,CAAC;AAG1B;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;iBAWK,CAAC;AAsFhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,MAAM,QAAO,MAwBzB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,UAAU,GAAG,SAAS,GAC9B,eAAe,CAEjB"}
@@ -15,21 +15,7 @@
15
15
  * implemented — `CsvFile` is a transfer-only primitive, not a
16
16
  * store you'd run an Act app against.
17
17
  */
18
- import type { Committed, EventSink, EventSource, Query, Schemas } from "./types/action.js";
19
- /**
20
- * Construct a {@link CsvFile} from either a filesystem path (for
21
- * reading and/or writing through the OS) or an in-memory blob (a
22
- * pre-loaded CSV string, used by the inspector when a CSV arrives
23
- * over the wire via tRPC).
24
- *
25
- * Both modes share the same on-disk format, so the same blob shape
26
- * can be round-tripped through the transfer pipeline.
27
- */
28
- export type CsvFileOptions = {
29
- path: string;
30
- } | {
31
- blob: string;
32
- };
18
+ import type { Committed, CsvFileOptions, EventSink, EventSource, Query, Schemas } from "./types/action.js";
33
19
  export declare class CsvFile implements EventSource, EventSink {
34
20
  private readonly path;
35
21
  private readonly blob;
@@ -1 +1 @@
1
- {"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../src/csv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,KAAK,EACL,OAAO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AAC,KAAK,EAAE,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,IAAI,EAChD,OAAO,CAAC,EAAE,KAAK,GACd,OAAO,CAAC,MAAM,CAAC,CAsCjB;IAEK,OAAO,CACX,MAAM,EAAE,CACN,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,KACpE,OAAO,CAAC,IAAI,CAAC,GACjB,OAAO,CAAC,IAAI,CAAC,CA6Bf;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAK7B;CACF"}
@@ -9,7 +9,6 @@ export * from "./adapters/index.js";
9
9
  export * from "./builders/index.js";
10
10
  export * from "./config.js";
11
11
  export * from "./csv.js";
12
- export { DeferSignal } from "./internal/index.js";
13
12
  export * from "./ports.js";
14
13
  export * from "./types/index.js";
15
14
  export * from "./utils.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB;;;;GAIG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AAIzB,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB;;;;GAIG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
@@ -6,68 +6,11 @@
6
6
  * then, not on the first cycle. Semantics and examples:
7
7
  * docs/docs/guides/close-policies.md.
8
8
  */
9
- import { z } from "zod";
10
- import type { AutoclosePredicate, Schemas } from "../types/action.js";
9
+ import type { AutoclosePolicy, AutoclosePredicate, Schemas } from "../types/action.js";
11
10
  /** The `Date` that lies `days` after `date`. */
12
11
  export declare function days_after(date: Date, days: number): Date;
13
12
  /** The `Date` that lies `days` in the past. */
14
13
  export declare function days_before_now(days: number): Date;
15
- /**
16
- * Zod schema for the declarative {@link AutoclosePolicy} bag.
17
- * Internal `const` per the config-validation-schema standard (CLAUDE.md
18
- * "Config-validation schemas") — the public surface is the inferred
19
- * {@link AutoclosePolicy} type and the `.autocloses({...})` overload,
20
- * never this schema. `.strict()` rejects unknown keys so typos surface
21
- * at build instead of being silently ignored.
22
- */
23
- declare const AutoclosePolicySchema: z.ZodObject<{
24
- after: z.ZodOptional<z.ZodObject<{
25
- days: z.ZodNumber;
26
- }, z.core.$strip>>;
27
- is: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodReadonly<z.ZodArray<z.ZodString>>]>>;
28
- reaches: z.ZodOptional<z.ZodNumber>;
29
- or: z.ZodOptional<z.ZodObject<{
30
- after: z.ZodOptional<z.ZodObject<{
31
- days: z.ZodNumber;
32
- }, z.core.$strip>>;
33
- is: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodReadonly<z.ZodArray<z.ZodString>>]>>;
34
- reaches: z.ZodOptional<z.ZodNumber>;
35
- }, z.core.$strict>>;
36
- keep: z.ZodOptional<z.ZodObject<{
37
- days: z.ZodNumber;
38
- }, z.core.$strip>>;
39
- }, z.core.$strict>;
40
- /**
41
- * Declarative close-policy options consumed by `.autocloses({...})`.
42
- * Top-level fields are AND-combined; the optional `or` block opens an
43
- * alternative OR-path. Omitted fields contribute nothing — they do
44
- * not mean "match everything."
45
- *
46
- * @property after - Close when `head.created` is at least the resolved
47
- * window in the past. Days are the close surface's only unit;
48
- * fractional `days` cover sub-day cooldowns (`{ days: 1/24 }` is one
49
- * hour) without introducing another denomination.
50
- * @property is - Close when `head.name` matches. String for the
51
- * single-terminal-event case (the most common); `readonly string[]`
52
- * for multi-terminal states (`Order: Shipped | Delivered |
53
- * Cancelled`).
54
- * @property reaches - Close when the stream's event count is `>= N`
55
- * (inclusive — fires the moment the threshold is reached).
56
- * @property or - Alternative OR-path. When present, the policy fires
57
- * if EITHER the top-level AND group matches OR any field inside
58
- * `or` matches. Used for safety-net backstops layered onto a
59
- * primary cooldown policy (e.g. *"(Resolved AND 90 days) OR reaches
60
- * 10k"*). Nested `or` inside `or` rejects at build time.
61
- * @property keep - Rolling-window retention, **independent** of
62
- * the terminate fields: while the stream stays open, prune events
63
- * older than `now − keep` behind the closest safe snapshot via a
64
- * windowed close. Does not participate in the AND group or the `or`
65
- * block — a policy may terminate, prune, or both. Requires
66
- * `.snap(...)` earlier in the builder chain (type-gated) and a
67
- * window of at least one day — the close cycle is low-cadence
68
- * housekeeping, never sub-day realtime.
69
- */
70
- export type AutoclosePolicy = z.infer<typeof AutoclosePolicySchema>;
71
14
  /**
72
15
  * Compile a declarative {@link AutoclosePolicy} into an
73
16
  * {@link AutoclosePredicate}. The state-builder's
@@ -118,5 +61,4 @@ export declare function policy_min_after_days(options: AutoclosePolicy): number
118
61
  */
119
62
  export declare function policy_keep_days(options: AutoclosePolicy): number | undefined;
120
63
  export declare function compile_autoclose_policy(options: AutoclosePolicy): AutoclosePredicate<Schemas>;
121
- export {};
122
64
  //# sourceMappingURL=autoclose-policy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"autoclose-policy.d.ts","sourceRoot":"","sources":["../../../src/internal/autoclose-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,oB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,CAMpB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAG7E;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,eAAe,GACvB,kBAAkB,CAAC,OAAO,CAAC,CAiC7B"}
@@ -12,8 +12,7 @@
12
12
  * registry is complete once the builder finishes; the orchestrator never
13
13
  * mutates it.
14
14
  */
15
- import type { Registry, SchemaRegister, Schemas, State } from "../types/index.js";
16
- import { type AutocloseConfig } from "./config.js";
15
+ import type { AutocloseConfig, Registry, SchemaRegister, Schemas, State } from "../types/index.js";
17
16
  /**
18
17
  * Inject one synthesized autoclose reaction per `.autocloses(...)` state
19
18
  * into the registry's event registers. The handler resolves ports at call
@@ -1 +1 @@
1
- {"version":3,"file":"autoclose-reaction.d.ts","sourceRoot":"","sources":["../../../src/internal/autoclose-reaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAEV,QAAQ,EACR,cAAc,EACd,OAAO,EACP,KAAK,EACN,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAE,KAAK,eAAe,EAAuB,MAAM,aAAa,CAAC;AAYxE;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,EAC3C,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,EAExB,QAAQ,EAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,EACjD,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACjD;;;;;;GAMG;AACH,WAAW,EAAE,MAAM,eAAe,CAAC,iBAAiB,CAAC,GACpD,IAAI,CAkHN"}
1
+ {"version":3,"file":"autoclose-reaction.d.ts","sourceRoot":"","sources":["../../../src/internal/autoclose-reaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EACV,eAAe,EAEf,QAAQ,EACR,cAAc,EACd,OAAO,EACP,KAAK,EACN,MAAM,mBAAmB,CAAC;AAgB3B;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,SAAS,cAAc,CAAC,QAAQ,CAAC,EAC3C,OAAO,SAAS,OAAO,EACvB,QAAQ,SAAS,OAAO,EAExB,QAAQ,EAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,EACjD,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACjD;;;;;;GAMG;AACH,WAAW,EAAE,MAAM,eAAe,CAAC,iBAAiB,CAAC,GACpD,IAAI,CAkHN"}
@@ -2,7 +2,7 @@
2
2
  * Off-hours window math for autoclose — hour-in-zone, DST-gap handling, and
3
3
  * "next time the window opens".
4
4
  */
5
- import type { AutocloseConfig } from "./config.js";
5
+ import type { AutocloseConfig } from "../types/index.js";
6
6
  /**
7
7
  * The current hour `[0, 23]` in the given IANA time zone, DST-correct
8
8
  * via `Intl`. Split out so the window check can be unit-tested without
@@ -1 +1 @@
1
- {"version":3,"file":"autoclose-window.d.ts","sourceRoot":"","sources":["../../../src/internal/autoclose-window.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOhE;AAkCD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,eAAe,CAAC,iBAAiB,CAAC,EAC1C,GAAG,EAAE,IAAI,GACR,OAAO,CAOT;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,WAAW,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC,EACvD,GAAG,EAAE,IAAI,GACR,IAAI,CAoBN"}
1
+ {"version":3,"file":"autoclose-window.d.ts","sourceRoot":"","sources":["../../../src/internal/autoclose-window.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOhE;AAkCD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,eAAe,CAAC,iBAAiB,CAAC,EAC1C,GAAG,EAAE,IAAI,GACR,OAAO,CAOT;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,WAAW,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC,EACvD,GAAG,EAAE,IAAI,GACR,IAAI,CAoBN"}
@@ -15,9 +15,8 @@
15
15
  * Time is passed in (`now`) rather than read from the clock so the state
16
16
  * machine is deterministic under test.
17
17
  */
18
+ import type { CircuitState } from "../types/index.js";
18
19
  import type { CircuitBreakerConfig } from "./config.js";
19
- /** Circuit breaker state. */
20
- export type CircuitState = "closed" | "open" | "half-open";
21
20
  /**
22
21
  * Side-effect hooks the orchestrator wires into the breaker so consumers
23
22
  * (drain / settle / autoclose) don't each thread their own callbacks.
@@ -1 +1 @@
1
- {"version":3,"file":"circuit-breaker.d.ts","sourceRoot":"","sources":["../../../src/internal/circuit-breaker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,6BAA6B;AAC7B,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAE3D;;;GAGG;AACH,MAAM,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