@vercel/board 0.16.0 → 0.18.0
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.
- package/README.md +27 -27
- package/dist/{a2-C41hD8SF.mjs → a2-ChRLRupa.mjs} +969 -25
- package/dist/access.d.mts +1 -1
- package/dist/access.mjs +3 -3
- package/dist/{actors-DjMeZpnU.mjs → actors-BOamkEuz.mjs} +3 -73
- package/dist/attempts-CLG840Oj.mjs +20 -0
- package/dist/{auth-COzc09sn.mjs → auth-Drg9FiC2.mjs} +225 -2
- package/dist/backend-B-SJ7p6p.d.mts +680 -0
- package/dist/backend-a2/contract.d.mts +873 -2
- package/dist/backend-a2/contract.mjs +2 -2
- package/dist/backend-a2/scheduler-local.d.mts +1 -1
- package/dist/backend-a2/scheduler-local.mjs +1 -1
- package/dist/backend-a2/scheduler-qstash.d.mts +78 -1
- package/dist/backend-a2/scheduler-qstash.mjs +521 -1
- package/dist/backend-a2/scheduler-vercel.d.mts +37 -1
- package/dist/backend-a2/scheduler-vercel.mjs +203 -1
- package/dist/backend-a2/store-memory.d.mts +2 -2
- package/dist/backend-a2/store-memory.mjs +3 -3
- package/dist/backend-a2/store-postgres.d.mts +1 -1
- package/dist/backend-a2/store-postgres.mjs +2850 -2
- package/dist/backend-a2/store-redis-http.d.mts +1 -1
- package/dist/backend-a2/store-redis-http.mjs +490 -2
- package/dist/backend-a2/store-redis.d.mts +10 -2
- package/dist/backend-a2/store-redis.mjs +51 -2
- package/dist/backend-a2/store-sqlite.d.mts +1 -1
- package/dist/backend-a2/store-sqlite.mjs +3 -3
- package/dist/backend-a2.d.mts +2706 -3
- package/dist/backend-a2.mjs +1 -1
- package/dist/{backend-http-Bid7RIpC.d.mts → backend-http-7cNb8nJI.d.mts} +10 -3
- package/dist/{backend-http-0roEmjl0.mjs → backend-http-CMlL3yq3.mjs} +2 -2
- package/dist/{backend-http-BVRno-ca.mjs → backend-http-Ddzd5kTS.mjs} +32 -3
- package/dist/backend-http.d.mts +1 -1
- package/dist/backend-http.mjs +1 -1
- package/dist/backend-http.node.d.mts +1 -1
- package/dist/backend-http.node.mjs +1 -1
- package/dist/{chat-provider-XCnQlxq6.d.mts → chat-provider-DNJQyajS.d.mts} +16 -4
- package/dist/{chat-provider-jFSeyNmB.mjs → chat-provider-YHy-WbrB.mjs} +15 -9
- package/dist/cli.mjs +30 -10
- package/dist/{client-DGDPaN7U.mjs → client-BA-J7usH.mjs} +10 -2
- package/dist/{conformance-DRR23YNy.mjs → conformance-CT5EeHeC.mjs} +5 -2
- package/dist/conformance.d.mts +1 -1
- package/dist/conformance.mjs +1 -1
- package/dist/{engine-Bir5s8ts.mjs → engine-D0oBUBEK.mjs} +249 -163
- package/dist/events-CewD4kw7.mjs +75 -0
- package/dist/{exports-Dvc1o52I.mjs → exports-CgjfMrQ-.mjs} +35 -32
- package/dist/exports-ZsgjzEnM.d.mts +4 -0
- package/dist/external-BV_cUncs.mjs +151 -0
- package/dist/folds-CRYY14kc.d.mts +534 -0
- package/dist/{reducers-mUPFuFJV.mjs → folds-Dyjput8M.mjs} +6 -73
- package/dist/ids-C6AYo1bu.mjs +31 -0
- package/dist/index.d.mts +4 -4
- package/dist/{index.default-Bkg77Pxn.mjs → index.default-C5Cpz3sa.mjs} +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.node.d.mts +4 -4
- package/dist/index.node.mjs +3 -3
- package/dist/inspect/app.js +31 -31
- package/dist/inspect/engine.js +5 -5
- package/dist/internal-CvsrprnU-CRY89I-b.mjs +203 -0
- package/dist/{local-Cr_dSjvs.mjs → local-DhkrAqPP.mjs} +1 -1
- package/dist/mentions-CB6ShY4R.mjs +72 -0
- package/dist/{targets-yM5JBUgr.mjs → middleware-CqaCwucP.mjs} +1 -33
- package/dist/platform-B4TnJtWu-CwcTyKg2.mjs +32 -0
- package/dist/{project-CFiArraX.mjs → project-DMDST9kl.mjs} +1 -1
- package/dist/{provider-BGjz-mDa.d.mts → provider-B0b9Qxw4.d.mts} +170 -40
- package/dist/provider-B3DpYSDq.mjs +220 -0
- package/dist/redis-tables-DN9PfIDi.mjs +3897 -0
- package/dist/reducer-CYPHsSmd-BQIfozGi.d.mts +170 -0
- package/dist/reducer-CjmvZSAb-D_OSISmj.mjs +74 -0
- package/dist/{contract-CuJmlrhw.mjs → reducers-BFmIXilu.mjs} +260 -287
- package/dist/retryable-lazy-DZWmHpii-Bye-W8q7.mjs +19 -0
- package/dist/scheduler-task-X1SToDjP-BVoWuInI.mjs +69 -0
- package/dist/{serve-BsOOc-6_.mjs → serve-BGYw0uNL.mjs} +5 -5
- package/dist/{server-jwPY7_wi.mjs → server-DPxBSogx.mjs} +4 -4
- package/dist/server-DtFrWxi3-Boa6gdWO.mjs +3602 -0
- package/dist/server-qgez0Xny-D5mLfqFQ.d.mts +385 -0
- package/dist/{serving-BNbzc96L.mjs → serving-CNkgUPW1.mjs} +1 -1
- package/dist/session-clear-wHd5GCpZ-BnKSxReK.mjs +51 -0
- package/dist/{sql-DbiEnqM0.mjs → sql-U9WTxrwJ.mjs} +2 -2
- package/dist/{sqlite-db-Cbj03vmp.mjs → sqlite-db-Ds4majtT.mjs} +1 -1
- package/dist/store-D0MhBvg6-4Z2L0Kqd.d.mts +530 -0
- package/dist/store-N8PXxDAS-BWBgzBHp.mjs +5 -0
- package/dist/store-codec-DwrWlgQx-CYxGW0aD.mjs +61 -0
- package/dist/store-memory-Bas9Uq5C.mjs +872 -0
- package/dist/store-memory-ZLiZbH3R.mjs +2 -0
- package/dist/store-polling-BZt2Rf3D-BiEM6_HB.mjs +148 -0
- package/dist/store-presence-polling-JuAy2Ck2-CYpuK75X.mjs +109 -0
- package/dist/store-sqlite-BmwL3pUR.mjs +2 -0
- package/dist/store-sqlite-CxxPCcCT.mjs +1053 -0
- package/dist/stream-buffer-DrTyiIuo-BKy-vI14.mjs +53 -0
- package/dist/sync-github.d.mts +24 -17
- package/dist/sync-github.mjs +89 -22
- package/dist/sync-kapso.d.mts +15 -13
- package/dist/sync-kapso.mjs +17 -14
- package/dist/sync-linear.d.mts +219 -0
- package/dist/sync-linear.mjs +311 -0
- package/dist/sync-slack.d.mts +12 -17
- package/dist/sync-slack.mjs +54 -42
- package/dist/sync.chat.d.mts +1 -1
- package/dist/sync.chat.mjs +1 -1
- package/dist/sync.d.mts +3 -3
- package/dist/sync.mjs +5 -4
- package/dist/targets-C-wdR5wP.mjs +33 -0
- package/dist/{tokens-DKLn5P9B.mjs → tokens-DhuzKzAl.mjs} +1 -1
- package/dist/{types-BHCjTZdB.d.mts → types-8yq2VnKI.d.mts} +2 -2
- package/dist/{users-Dls7_ANV.mjs → users-yryHKFMo.mjs} +2 -2
- package/dist/{watch-spec-W0c7ypHJ.mjs → watchers-hash-RLtnSF-t.mjs} +233 -28
- package/docs/01-board/01-mounting.md +1 -1
- package/docs/02-sync/01-overview.md +72 -48
- package/docs/02-sync/02-functions.md +398 -0
- package/docs/02-sync/03-slack.md +30 -25
- package/docs/02-sync/04-github.md +62 -26
- package/docs/02-sync/05-whatsapp.md +23 -19
- package/docs/02-sync/06-providers.md +60 -27
- package/docs/02-sync/07-linear.md +129 -0
- package/docs/03-guides/04-triage.md +1 -1
- package/docs/04-reference/01-cli.md +26 -6
- package/docs/04-reference/02-board.md +18 -5
- package/docs/04-reference/03-http.md +5 -2
- package/docs/04-reference/05-conformance.md +1 -1
- package/docs/index.md +5 -10
- package/package.json +31 -6
- package/dist/a2-D24cvwpN.d.mts +0 -3359
- package/dist/access-CJU2-vaa.mjs +0 -226
- package/dist/attempts-Bxp9KgPf.mjs +0 -919
- package/dist/exports-DLiE7fLY.d.mts +0 -4
- package/dist/provider-CuewcDNZ.mjs +0 -205
- package/dist/redis-tables-B35vv4CZ.mjs +0 -842
- package/dist/reducers-B_vUGQRp.d.mts +0 -1172
- package/dist/watchers-hash-CLjsa6od.mjs +0 -225
- package/docs/02-sync/02-callbacks.md +0 -265
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/experimental-a2@0.22.0_@upstash+qstash@2.12.0_@vercel+queue@0.7.0_ai@7.0.130_zod@4.6.5__52060f00b21aecfab049c27fa3abd2f9/node_modules/experimental-a2/dist/reducer-CYPHsSmd.d.ts
|
|
2
|
+
//#region src/standard-schema.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The Standard Schema interface, vendored per the spec's guidance
|
|
5
|
+
* (https://standardschema.dev — the interface is designed to be copied
|
|
6
|
+
* into libraries rather than depended on). Types only; nothing here
|
|
7
|
+
* exists at runtime.
|
|
8
|
+
*/
|
|
9
|
+
/** The Standard Schema interface. */
|
|
10
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
11
|
+
/** The Standard Schema properties. */
|
|
12
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
13
|
+
}
|
|
14
|
+
declare namespace StandardSchemaV1 {
|
|
15
|
+
/** The Standard Schema properties interface. */
|
|
16
|
+
export interface Props<Input = unknown, Output = Input> {
|
|
17
|
+
/** The version number of the standard. */
|
|
18
|
+
readonly version: 1;
|
|
19
|
+
/** The vendor name of the schema library. */
|
|
20
|
+
readonly vendor: string;
|
|
21
|
+
/** Validates unknown input values. */
|
|
22
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
23
|
+
/** Inferred types associated with the schema. */
|
|
24
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
25
|
+
}
|
|
26
|
+
/** The result interface of the validate function. */
|
|
27
|
+
export type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
28
|
+
/** The result interface if validation succeeds. */
|
|
29
|
+
export interface SuccessResult<Output> {
|
|
30
|
+
/** The typed output value. */
|
|
31
|
+
readonly value: Output;
|
|
32
|
+
/** The non-existent issues. */
|
|
33
|
+
readonly issues?: undefined;
|
|
34
|
+
}
|
|
35
|
+
/** The result interface if validation fails. */
|
|
36
|
+
export interface FailureResult {
|
|
37
|
+
/** The issues of failed validation. */
|
|
38
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
39
|
+
}
|
|
40
|
+
/** The issue interface of the failure output. */
|
|
41
|
+
export interface Issue {
|
|
42
|
+
/** The error message of the issue. */
|
|
43
|
+
readonly message: string;
|
|
44
|
+
/** The path of the issue, if any. */
|
|
45
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
46
|
+
}
|
|
47
|
+
/** The path segment interface of the issue. */
|
|
48
|
+
export interface PathSegment {
|
|
49
|
+
/** The key representing a path segment. */
|
|
50
|
+
readonly key: PropertyKey;
|
|
51
|
+
}
|
|
52
|
+
/** The Standard Schema types interface. */
|
|
53
|
+
export interface Types<Input = unknown, Output = Input> {
|
|
54
|
+
/** The input type of the schema. */
|
|
55
|
+
readonly input: Input;
|
|
56
|
+
/** The output type of the schema. */
|
|
57
|
+
readonly output: Output;
|
|
58
|
+
}
|
|
59
|
+
/** Infers the input type of a Standard Schema. */
|
|
60
|
+
export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
61
|
+
/** Infers the output type of a Standard Schema. */
|
|
62
|
+
export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/contract.d.ts
|
|
66
|
+
/** The event vocabulary shape: event name → payload schema. */
|
|
67
|
+
type EventDefs = Record<string, StandardSchemaV1>;
|
|
68
|
+
/** The presence vocabulary shape: field name → value schema. */
|
|
69
|
+
type PresenceDefs = Record<string, StandardSchemaV1>;
|
|
70
|
+
/** One event of a contract, narrowed to type `K`. */
|
|
71
|
+
type ContractEvent<D extends EventDefs, K extends keyof D & string = keyof D & string> = { [T in keyof D & string]: {
|
|
72
|
+
id: string;
|
|
73
|
+
type: T;
|
|
74
|
+
payload: StandardSchemaV1.InferOutput<D[T]>;
|
|
75
|
+
index: number;
|
|
76
|
+
sessionId: string;
|
|
77
|
+
createdAt: Date;
|
|
78
|
+
}; }[K];
|
|
79
|
+
/** Input to `append`/`push`, typed against the contract's schemas. */
|
|
80
|
+
type AppendInput<D extends EventDefs> = { [T in keyof D & string]: {
|
|
81
|
+
type: T;
|
|
82
|
+
payload: StandardSchemaV1.InferInput<D[T]>;
|
|
83
|
+
id?: string;
|
|
84
|
+
}; }[keyof D & string];
|
|
85
|
+
type EventBatchFactory<D extends EventDefs> = <const E extends readonly AppendInput<D>[]>(...events: E) => E;
|
|
86
|
+
/**
|
|
87
|
+
* One presence update: a participant's changed fields (`null` marks a
|
|
88
|
+
* cleared one), stamped with the sender's stream frontier (`seen`).
|
|
89
|
+
* This is what `stream({ presence: true })` interleaves with events.
|
|
90
|
+
*/
|
|
91
|
+
type PresencePatch<P extends PresenceDefs = PresenceDefs> = {
|
|
92
|
+
participant: string;
|
|
93
|
+
values: { [F in keyof P & string]?: StandardSchemaV1.InferOutput<P[F]> | null; };
|
|
94
|
+
seen: number;
|
|
95
|
+
at: Date;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The replicated ephemeral map: participant → field → latest value,
|
|
99
|
+
* last-writer-wins per field. Never stored in the log; how long a
|
|
100
|
+
* value stays painted is view logic, decided at render time against
|
|
101
|
+
* `at`.
|
|
102
|
+
*/
|
|
103
|
+
type PresenceMap<P extends PresenceDefs = PresenceDefs> = {
|
|
104
|
+
[participant: string]: { [F in keyof P & string]?: {
|
|
105
|
+
value: StandardSchemaV1.InferOutput<P[F]>;
|
|
106
|
+
seen: number;
|
|
107
|
+
at: Date;
|
|
108
|
+
}; };
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* The one item a presence stream yields before live patches: the
|
|
112
|
+
* current pruned map, per-field stamps exact. Discriminate
|
|
113
|
+
* structurally (`'snapshot' in item`).
|
|
114
|
+
*/
|
|
115
|
+
type PresenceSnapshot<P extends PresenceDefs = PresenceDefs> = {
|
|
116
|
+
snapshot: PresenceMap<P>;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Intersect into a surface type to add `Members` only when the
|
|
120
|
+
* contract declares presence fields — on presence-less contracts the
|
|
121
|
+
* members do not exist, a type error rather than a runtime throw.
|
|
122
|
+
*/
|
|
123
|
+
type WithPresence<P extends PresenceDefs, Members> = keyof P extends never ? unknown : Members;
|
|
124
|
+
type Contract<D extends EventDefs = EventDefs, P extends PresenceDefs = Record<never, never>, R = RegisteredReducer<D, P> | undefined> = {
|
|
125
|
+
/** Identity — prefixes storage keys and queue messages. */
|
|
126
|
+
readonly name: string;
|
|
127
|
+
/** The vocabulary. */
|
|
128
|
+
readonly events: Readonly<D>;
|
|
129
|
+
/** The presence vocabulary — empty unless declared. */
|
|
130
|
+
readonly presence: Readonly<P>;
|
|
131
|
+
/** Preserve literal types for a consumer-returned event batch. */
|
|
132
|
+
readonly batch: EventBatchFactory<D>;
|
|
133
|
+
readonly reducer: R;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* A pure fold over a session's events — `(state, event) => state` —
|
|
137
|
+
* published inline in a contract or built with `reducer(options).fold(fn)`.
|
|
138
|
+
*
|
|
139
|
+
* The name is the reducer's identity. Cached folds (server snapshots,
|
|
140
|
+
* the browser cache) are keyed by it, which makes it the invalidation
|
|
141
|
+
* knob too: changed the fold's logic? Change the name. Snapshots under
|
|
142
|
+
* the old name are ignored and the next read refolds from raw events.
|
|
143
|
+
* See docs/contract/02-state.mdx.
|
|
144
|
+
*/
|
|
145
|
+
type Reducer<D extends EventDefs = EventDefs, S = unknown, P extends PresenceDefs = Record<never, never>> = {
|
|
146
|
+
/** Identity and cache key. Rename when the fold's logic changes. */
|
|
147
|
+
readonly name: string;
|
|
148
|
+
/** The contract's vocabulary — types every event in the fold. */
|
|
149
|
+
readonly events: Readonly<D>;
|
|
150
|
+
/**
|
|
151
|
+
* The contract's presence vocabulary — carried because the reducer
|
|
152
|
+
* is the client's typed handle on the contract. The fold never sees
|
|
153
|
+
* presence.
|
|
154
|
+
*/
|
|
155
|
+
readonly presence: Readonly<P>;
|
|
156
|
+
readonly fold: (state: S, event: ContractEvent<D>) => S;
|
|
157
|
+
readonly initialState: S;
|
|
158
|
+
/**
|
|
159
|
+
* When present: `initialState` was validated against it at
|
|
160
|
+
* definition, and any cached fold a2 rehydrates (server snapshots,
|
|
161
|
+
* the browser cache) is checked against it — failing snapshots are
|
|
162
|
+
* discarded and refolded, catching shape drift a stale name can't.
|
|
163
|
+
*/
|
|
164
|
+
readonly stateSchema: StandardSchemaV1<unknown, S> | undefined;
|
|
165
|
+
};
|
|
166
|
+
type RegisteredReducer<D extends EventDefs, P extends PresenceDefs> = Omit<Reducer<D, unknown, P>, "fold"> & {
|
|
167
|
+
readonly fold: (state: never, event: never) => unknown;
|
|
168
|
+
};
|
|
169
|
+
//#endregion
|
|
170
|
+
export { PresenceDefs as a, PresenceSnapshot as c, WithPresence as d, EventDefs as i, Reducer as l, Contract as n, PresenceMap as o, ContractEvent as r, PresencePatch as s, AppendInput as t, RegisteredReducer as u };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { a as isSessionCleared } from "./session-clear-wHd5GCpZ-BnKSxReK.mjs";
|
|
2
|
+
//#region ../../node_modules/.pnpm/experimental-a2@0.22.0_@upstash+qstash@2.12.0_@vercel+queue@0.7.0_ai@7.0.130_zod@4.6.5__52060f00b21aecfab049c27fa3abd2f9/node_modules/experimental-a2/dist/reducer-CjmvZSAb.js
|
|
3
|
+
/**
|
|
4
|
+
* Run a Standard Schema validator, requiring a synchronous result.
|
|
5
|
+
* Validators must be synchronous (specs/a2-api.md §1) — an async one is
|
|
6
|
+
* a definition bug, rejected at definition time where possible and here
|
|
7
|
+
* as a backstop. `what` names the schema in error messages, e.g.
|
|
8
|
+
* "event 'created'" or "the stateSchema".
|
|
9
|
+
*/
|
|
10
|
+
function validateSync(schema, value, what) {
|
|
11
|
+
const result = schema["~standard"].validate(value);
|
|
12
|
+
if (result instanceof Promise) throw new TypeError(`the schema for ${what} is asynchronous — a2 schemas must validate synchronously`);
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Probe a schema to reject always-async validators early. The probe
|
|
17
|
+
* value is deliberately garbage — we only care whether the result is a
|
|
18
|
+
* Promise, not whether it passes.
|
|
19
|
+
*/
|
|
20
|
+
function assertSyncSchema(schema, what) {
|
|
21
|
+
const probe = Symbol("a2.schema-probe");
|
|
22
|
+
const result = schema["~standard"].validate(probe);
|
|
23
|
+
if (result instanceof Promise) {
|
|
24
|
+
result.catch(() => {});
|
|
25
|
+
throw new TypeError(`the schema for ${what} is asynchronous — a2 schemas must validate synchronously`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A fresh copy of a reducer's seed, so a fold that mutates in place
|
|
30
|
+
* cannot corrupt the shared `initialState`. Non-cloneable seeds
|
|
31
|
+
* (functions, class instances, proxies) fall back to the original.
|
|
32
|
+
*/
|
|
33
|
+
function cloneInitial(initial) {
|
|
34
|
+
try {
|
|
35
|
+
return structuredClone(initial);
|
|
36
|
+
} catch {
|
|
37
|
+
return initial;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const markerFolds = /* @__PURE__ */ new WeakSet();
|
|
41
|
+
/** One fold step; a clear marker resets to the seed on server and client alike. */
|
|
42
|
+
function foldEvent(source, state, event) {
|
|
43
|
+
if (!isSessionCleared(event)) return source.fold(state, event);
|
|
44
|
+
return markerFolds.has(source.fold) ? source.fold(state, event) : cloneInitial(source.initialState);
|
|
45
|
+
}
|
|
46
|
+
/** Internal — shared validation for inline and standalone reducer definitions. */
|
|
47
|
+
function makeReducerBuilder(events, presence, options) {
|
|
48
|
+
const { name } = options;
|
|
49
|
+
if (typeof name !== "string" || name.length === 0) throw new TypeError("reducer name must be a non-empty string — it identifies the reducer and keys cached snapshots");
|
|
50
|
+
let initialState = options.initialState;
|
|
51
|
+
if (options.stateSchema) {
|
|
52
|
+
const result = validateSync(options.stateSchema, options.initialState, "the stateSchema");
|
|
53
|
+
if (result.issues) throw new TypeError(`reducer initialState does not match its stateSchema: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
54
|
+
initialState = result.value;
|
|
55
|
+
const restored = validateSync(options.stateSchema, initialState, "the stateSchema");
|
|
56
|
+
if (restored.issues || JSON.stringify(restored.value) !== JSON.stringify(initialState)) throw new TypeError("stateSchema must accept and preserve its own output so snapshots can be restored");
|
|
57
|
+
}
|
|
58
|
+
return { fold(fold) {
|
|
59
|
+
if (typeof fold !== "function") throw new TypeError("reducer fold must be a function");
|
|
60
|
+
return {
|
|
61
|
+
name,
|
|
62
|
+
events,
|
|
63
|
+
presence,
|
|
64
|
+
fold,
|
|
65
|
+
initialState,
|
|
66
|
+
stateSchema: options.stateSchema
|
|
67
|
+
};
|
|
68
|
+
} };
|
|
69
|
+
}
|
|
70
|
+
function reducer(options) {
|
|
71
|
+
return makeReducerBuilder(options.contract.events, options.contract.presence, options);
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { reducer as a, makeReducerBuilder as i, cloneInitial as n, validateSync as o, foldEvent as r, assertSyncSchema as t };
|