stroid 0.1.2 → 0.1.4-beta.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/CHANGELOG.md +57 -10
- package/README.md +12 -10
- package/dist/async.d.ts +1 -1
- package/dist/async.js +22 -22
- package/dist/computed-types.d.ts +42 -0
- package/dist/computed-types.js +2 -0
- package/dist/computed.d.ts +15 -2
- package/dist/computed.js +11 -11
- package/dist/core.js +14 -14
- package/dist/devtools.d.ts +1 -1
- package/dist/devtools.js +1 -1
- package/dist/helpers.js +13 -13
- package/dist/index-internal.d.ts +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +24 -24
- package/dist/install.js +1 -1
- package/dist/persist.js +1 -1
- package/dist/psr.d.ts +38 -0
- package/dist/psr.js +19 -0
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.js +25 -25
- package/dist/runtime-admin.js +1 -1
- package/dist/runtime-patch.d.ts +29 -0
- package/dist/runtime-tools.d.ts +6 -1
- package/dist/runtime-tools.js +2 -2
- package/dist/selectors.js +1 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js +11 -11
- package/dist/store-registry.d.ts +5 -0
- package/dist/sync.js +1 -1
- package/dist/testing.js +17 -17
- package/dist/types.d.ts +1 -1
- package/package.json +40 -39
- package/dist/async.js.map +0 -1
- package/dist/computed.js.map +0 -1
- package/dist/core.js.map +0 -1
- package/dist/devtools.js.map +0 -1
- package/dist/feature.js.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/install.js.map +0 -1
- package/dist/persist.js.map +0 -1
- package/dist/react/index.js.map +0 -1
- package/dist/runtime-admin.js.map +0 -1
- package/dist/runtime-tools.js.map +0 -1
- package/dist/selectors.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/sync.js.map +0 -1
- package/dist/testing.js.map +0 -1
- package/dist/types/adapters/options.d.ts +0 -335
- package/dist/types/async/cache.d.ts +0 -39
- package/dist/types/async/clone.d.ts +0 -10
- package/dist/types/async/errors.d.ts +0 -3
- package/dist/types/async/fetch.d.ts +0 -37
- package/dist/types/async/inflight.d.ts +0 -13
- package/dist/types/async/rate.d.ts +0 -5
- package/dist/types/async/registry.d.ts +0 -116
- package/dist/types/async/request.d.ts +0 -11
- package/dist/types/async/retry.d.ts +0 -10
- package/dist/types/async.d.ts +0 -10
- package/dist/types/computed/computed-graph.d.ts +0 -29
- package/dist/types/computed/index.d.ts +0 -16
- package/dist/types/config.d.ts +0 -10
- package/dist/types/core/index.d.ts +0 -11
- package/dist/types/core/lifecycle-hooks.d.ts +0 -16
- package/dist/types/core/store-admin-impl.d.ts +0 -9
- package/dist/types/core/store-admin.d.ts +0 -9
- package/dist/types/core/store-core.d.ts +0 -13
- package/dist/types/core/store-create.d.ts +0 -16
- package/dist/types/core/store-hydrate-impl.d.ts +0 -35
- package/dist/types/core/store-hydrate.d.ts +0 -9
- package/dist/types/core/store-lifecycle/hooks.d.ts +0 -19
- package/dist/types/core/store-lifecycle/identity.d.ts +0 -23
- package/dist/types/core/store-lifecycle/registry.d.ts +0 -53
- package/dist/types/core/store-lifecycle/types.d.ts +0 -67
- package/dist/types/core/store-lifecycle/validation.d.ts +0 -53
- package/dist/types/core/store-name.d.ts +0 -28
- package/dist/types/core/store-notify.d.ts +0 -12
- package/dist/types/core/store-read.d.ts +0 -18
- package/dist/types/core/store-registry.d.ts +0 -108
- package/dist/types/core/store-replace-impl.d.ts +0 -11
- package/dist/types/core/store-replace.d.ts +0 -9
- package/dist/types/core/store-set-impl.d.ts +0 -13
- package/dist/types/core/store-set.d.ts +0 -9
- package/dist/types/core/store-shared/core.d.ts +0 -13
- package/dist/types/core/store-shared/notify.d.ts +0 -12
- package/dist/types/core/store-transaction.d.ts +0 -26
- package/dist/types/core/store-write-shared.d.ts +0 -19
- package/dist/types/core/store-write.d.ts +0 -13
- package/dist/types/features/feature-registry.d.ts +0 -91
- package/dist/types/features/lifecycle.d.ts +0 -40
- package/dist/types/index.d.ts +0 -17
- package/dist/types/integrations/query.d.ts +0 -8
- package/dist/types/internals/computed-order.d.ts +0 -3
- package/dist/types/internals/config.d.ts +0 -116
- package/dist/types/internals/diagnostics.d.ts +0 -21
- package/dist/types/internals/reporting.d.ts +0 -9
- package/dist/types/internals/store-admin.d.ts +0 -7
- package/dist/types/internals/store-ops.d.ts +0 -13
- package/dist/types/internals/test-reset.d.ts +0 -2
- package/dist/types/internals/write-context.d.ts +0 -15
- package/dist/types/notification/delivery.d.ts +0 -3
- package/dist/types/notification/index.d.ts +0 -10
- package/dist/types/notification/metrics.d.ts +0 -12
- package/dist/types/notification/priority.d.ts +0 -9
- package/dist/types/notification/scheduler.d.ts +0 -11
- package/dist/types/notification/snapshot.d.ts +0 -8
- package/dist/types/runtime-admin/index.d.ts +0 -2
- package/dist/types/runtime-tools/index.d.ts +0 -58
- package/dist/types/store.d.ts +0 -16
- package/dist/types/types/utility.d.ts +0 -17
- package/dist/types/utils/clone.d.ts +0 -4
- package/dist/types/utils/devfreeze.d.ts +0 -2
- package/dist/types/utils/hash.d.ts +0 -8
- package/dist/types/utils/path.d.ts +0 -5
- package/dist/types/utils/validation.d.ts +0 -14
- package/dist/types/utils.d.ts +0 -13
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
import type { TraceContext } from "../types/utility.js";
|
|
2
|
-
export type StoreValue = unknown;
|
|
3
|
-
export interface FeatureOptionsMap {
|
|
4
|
-
}
|
|
5
|
-
export type FeatureOptions = Partial<FeatureOptionsMap> & Record<string, unknown>;
|
|
6
|
-
export interface PersistDriver {
|
|
7
|
-
getItem?: (k: string) => string | null | Promise<string | null>;
|
|
8
|
-
setItem?: (k: string, v: string) => void | Promise<void>;
|
|
9
|
-
removeItem?: (k: string) => void | Promise<void>;
|
|
10
|
-
[key: string]: unknown;
|
|
11
|
-
}
|
|
12
|
-
export type StoreScope = "request" | "global" | "temp";
|
|
13
|
-
export type SnapshotMode = "deep" | "shallow" | "ref";
|
|
14
|
-
export type ValidateFn<State = StoreValue> = (next: State) => boolean | State;
|
|
15
|
-
export type SchemaValidateOption = {
|
|
16
|
-
safeParse: (value: unknown) => {
|
|
17
|
-
success: true;
|
|
18
|
-
data: unknown;
|
|
19
|
-
} | {
|
|
20
|
-
success: false;
|
|
21
|
-
error?: unknown;
|
|
22
|
-
};
|
|
23
|
-
} | {
|
|
24
|
-
parse: (value: unknown) => unknown;
|
|
25
|
-
} | {
|
|
26
|
-
validateSync: (value: unknown) => unknown;
|
|
27
|
-
} | {
|
|
28
|
-
isValidSync: (value: unknown) => boolean;
|
|
29
|
-
} | {
|
|
30
|
-
validate: (value: unknown) => unknown;
|
|
31
|
-
};
|
|
32
|
-
export type ValidateOption<State = StoreValue> = ValidateFn<State> | SchemaValidateOption;
|
|
33
|
-
export interface PersistOptions<State = StoreValue> {
|
|
34
|
-
driver?: PersistDriver;
|
|
35
|
-
storage?: PersistDriver;
|
|
36
|
-
key?: string;
|
|
37
|
-
serialize?: (v: unknown) => string;
|
|
38
|
-
deserialize?: (v: string) => unknown;
|
|
39
|
-
/**
|
|
40
|
-
* Optional encryption hook for persisted payloads.
|
|
41
|
-
*
|
|
42
|
-
* Default is identity (no encryption). Data is stored in plaintext.
|
|
43
|
-
*/
|
|
44
|
-
encrypt?: (v: string) => string;
|
|
45
|
-
/**
|
|
46
|
-
* Optional async encryption hook for persisted payloads.
|
|
47
|
-
*
|
|
48
|
-
* When provided, persistence will encrypt in the background and hydrate asynchronously.
|
|
49
|
-
*/
|
|
50
|
-
encryptAsync?: (v: string) => Promise<string>;
|
|
51
|
-
/**
|
|
52
|
-
* Optional decryption hook for persisted payloads.
|
|
53
|
-
*
|
|
54
|
-
* Default is identity (no encryption). Data is stored in plaintext.
|
|
55
|
-
*/
|
|
56
|
-
decrypt?: (v: string) => string;
|
|
57
|
-
/**
|
|
58
|
-
* Optional async decryption hook for persisted payloads.
|
|
59
|
-
*
|
|
60
|
-
* When provided, persistence will hydrate asynchronously after store creation.
|
|
61
|
-
*/
|
|
62
|
-
decryptAsync?: (v: string) => Promise<string>;
|
|
63
|
-
/**
|
|
64
|
-
* Explicitly allow plaintext persistence when encrypt/decrypt are identity.
|
|
65
|
-
*
|
|
66
|
-
* In production builds, plaintext persistence is blocked unless this is true.
|
|
67
|
-
*/
|
|
68
|
-
allowPlaintext?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Marks this store's persisted data as sensitive (secrets/PII).
|
|
71
|
-
*
|
|
72
|
-
* When `true`, stroid throws at store creation time unless a non-identity
|
|
73
|
-
* `encrypt` hook is provided.
|
|
74
|
-
*/
|
|
75
|
-
sensitiveData?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Maximum allowed persisted payload size (in characters).
|
|
78
|
-
* When exceeded, hydration is skipped and an error is reported.
|
|
79
|
-
*/
|
|
80
|
-
maxSize?: number;
|
|
81
|
-
/**
|
|
82
|
-
* Integrity check mode for persisted payloads.
|
|
83
|
-
* - "hash" (default): store and validate a checksum.
|
|
84
|
-
* - "none": skip checksum generation/validation.
|
|
85
|
-
* - "sha256": store a SHA-256 hash for stronger tamper detection (may be async in browsers).
|
|
86
|
-
*/
|
|
87
|
-
checksum?: "hash" | "none" | "sha256";
|
|
88
|
-
version?: number;
|
|
89
|
-
migrations?: Record<number, (state: State) => State>;
|
|
90
|
-
onMigrationFail?: "reset" | "keep" | ((state: unknown) => unknown);
|
|
91
|
-
onStorageCleared?: (info: {
|
|
92
|
-
name: string;
|
|
93
|
-
key: string;
|
|
94
|
-
reason: "clear" | "remove" | "missing";
|
|
95
|
-
}) => void;
|
|
96
|
-
}
|
|
97
|
-
export interface PersistConfig {
|
|
98
|
-
driver: PersistDriver;
|
|
99
|
-
key: string;
|
|
100
|
-
serialize: (v: unknown) => string;
|
|
101
|
-
deserialize: (v: string) => unknown;
|
|
102
|
-
encrypt: (v: string) => string;
|
|
103
|
-
decrypt: (v: string) => string;
|
|
104
|
-
encryptAsync?: (v: string) => Promise<string>;
|
|
105
|
-
decryptAsync?: (v: string) => Promise<string>;
|
|
106
|
-
allowPlaintext?: boolean;
|
|
107
|
-
sensitiveData?: boolean;
|
|
108
|
-
maxSize?: number;
|
|
109
|
-
checksum: "hash" | "none" | "sha256";
|
|
110
|
-
onMigrationFail?: "reset" | "keep" | ((state: unknown) => unknown);
|
|
111
|
-
onStorageCleared?: (info: {
|
|
112
|
-
name: string;
|
|
113
|
-
key: string;
|
|
114
|
-
reason: "clear" | "remove" | "missing";
|
|
115
|
-
}) => void;
|
|
116
|
-
}
|
|
117
|
-
export interface MiddlewareCtx {
|
|
118
|
-
action: string;
|
|
119
|
-
name: string;
|
|
120
|
-
prev: StoreValue;
|
|
121
|
-
next: StoreValue;
|
|
122
|
-
path: unknown;
|
|
123
|
-
correlationId?: string;
|
|
124
|
-
traceContext?: TraceContext;
|
|
125
|
-
}
|
|
126
|
-
export interface SyncOptions {
|
|
127
|
-
channel?: string;
|
|
128
|
-
maxPayloadBytes?: number;
|
|
129
|
-
/**
|
|
130
|
-
* Authentication policy for sync.
|
|
131
|
-
* - "strict": require authToken or verify (blocks sync if missing)
|
|
132
|
-
* - "insecure": allow unauthenticated sync (explicit opt-out)
|
|
133
|
-
*/
|
|
134
|
-
policy?: "strict" | "insecure";
|
|
135
|
-
/**
|
|
136
|
-
* Optional shared token for lightweight cross-tab authentication.
|
|
137
|
-
* When set, incoming sync messages without a matching token are rejected.
|
|
138
|
-
*/
|
|
139
|
-
authToken?: string;
|
|
140
|
-
/**
|
|
141
|
-
* Explicitly allow unauthenticated sync.
|
|
142
|
-
* Deprecated in favor of policy: "insecure".
|
|
143
|
-
*/
|
|
144
|
-
insecure?: boolean;
|
|
145
|
-
conflictResolver?: (args: {
|
|
146
|
-
local: StoreValue;
|
|
147
|
-
incoming: StoreValue;
|
|
148
|
-
localUpdated: number;
|
|
149
|
-
incomingUpdated: number;
|
|
150
|
-
}) => StoreValue | void;
|
|
151
|
-
/**
|
|
152
|
-
* Optional guard to prevent rapid feedback loops when sync updates trigger local reactions.
|
|
153
|
-
*
|
|
154
|
-
* - true: enable with a default window (100ms)
|
|
155
|
-
* - { windowMs }: customize the guard window in milliseconds
|
|
156
|
-
* - false: disable (default is enabled when sync is truthy)
|
|
157
|
-
*/
|
|
158
|
-
loopGuard?: boolean | {
|
|
159
|
-
windowMs?: number;
|
|
160
|
-
};
|
|
161
|
-
/**
|
|
162
|
-
* Optional checksum mode for sync payloads.
|
|
163
|
-
* - "hash" (default): include a checksum of the payload.
|
|
164
|
-
* - "none": skip checksum generation.
|
|
165
|
-
*/
|
|
166
|
-
checksum?: "hash" | "none";
|
|
167
|
-
/**
|
|
168
|
-
* Optional signer for sync payloads. The returned value is attached to the message as `auth`.
|
|
169
|
-
*/
|
|
170
|
-
sign?: (payload: SyncMessage) => unknown;
|
|
171
|
-
/**
|
|
172
|
-
* Optional verifier for incoming sync payloads.
|
|
173
|
-
* Return true to accept the message, false to reject it.
|
|
174
|
-
*/
|
|
175
|
-
verify?: (payload: SyncMessage) => boolean;
|
|
176
|
-
/**
|
|
177
|
-
* Optional resolver for updatedAt timestamps when conflicts are resolved.
|
|
178
|
-
*/
|
|
179
|
-
resolveUpdatedAt?: (args: {
|
|
180
|
-
localUpdated: number;
|
|
181
|
-
incomingUpdated: number | undefined;
|
|
182
|
-
now: number;
|
|
183
|
-
}) => number;
|
|
184
|
-
}
|
|
185
|
-
export type SyncMessage = {
|
|
186
|
-
v: number;
|
|
187
|
-
protocol: number;
|
|
188
|
-
type: "sync-request" | "sync-state";
|
|
189
|
-
name: string;
|
|
190
|
-
clock: number;
|
|
191
|
-
source: string;
|
|
192
|
-
updatedAt?: number;
|
|
193
|
-
data?: StoreValue;
|
|
194
|
-
checksum?: number | null;
|
|
195
|
-
auth?: unknown;
|
|
196
|
-
token?: string;
|
|
197
|
-
requestedAt?: number;
|
|
198
|
-
};
|
|
199
|
-
export interface DevtoolsOptions<State = StoreValue> {
|
|
200
|
-
enabled?: boolean;
|
|
201
|
-
historyLimit?: number;
|
|
202
|
-
redactor?: (state: State) => State;
|
|
203
|
-
}
|
|
204
|
-
export interface LifecycleOptions<State = StoreValue> {
|
|
205
|
-
middleware?: Array<(ctx: MiddlewareCtx) => StoreValue | void>;
|
|
206
|
-
onSet?: (prev: State, next: State) => void;
|
|
207
|
-
onReset?: (prev: State, next: State) => void;
|
|
208
|
-
onDelete?: (prev: State) => void;
|
|
209
|
-
onCreate?: (initial: State) => void;
|
|
210
|
-
}
|
|
211
|
-
export interface StoreOptions<State = StoreValue> {
|
|
212
|
-
scope?: StoreScope;
|
|
213
|
-
lazy?: boolean;
|
|
214
|
-
/**
|
|
215
|
-
* Allow `setStore(name, path, value)` to create missing **leaf** keys on object nodes.
|
|
216
|
-
*
|
|
217
|
-
* Default: `false` (strict path writes).
|
|
218
|
-
*
|
|
219
|
-
* Notes:
|
|
220
|
-
* - Does not expand arrays (out-of-bounds indices are still rejected).
|
|
221
|
-
* - Does not create missing intermediate objects for deep paths; define the shape up-front.
|
|
222
|
-
*/
|
|
223
|
-
pathCreate?: boolean;
|
|
224
|
-
validate?: ValidateOption<State>;
|
|
225
|
-
persist?: boolean | string | PersistOptions<State>;
|
|
226
|
-
devtools?: boolean | DevtoolsOptions<State>;
|
|
227
|
-
lifecycle?: LifecycleOptions<State>;
|
|
228
|
-
middleware?: Array<(ctx: MiddlewareCtx) => StoreValue | void>;
|
|
229
|
-
onSet?: (prev: State, next: State) => void;
|
|
230
|
-
onReset?: (prev: State, next: State) => void;
|
|
231
|
-
onDelete?: (prev: State) => void;
|
|
232
|
-
onCreate?: (initial: State) => void;
|
|
233
|
-
onError?: (err: string) => void;
|
|
234
|
-
/** @deprecated use validate instead */
|
|
235
|
-
validator?: (next: State) => boolean;
|
|
236
|
-
/** @deprecated use validate instead */
|
|
237
|
-
schema?: unknown;
|
|
238
|
-
migrations?: Record<number, (state: State) => State>;
|
|
239
|
-
version?: number;
|
|
240
|
-
redactor?: (state: State) => State;
|
|
241
|
-
historyLimit?: number;
|
|
242
|
-
allowSSRGlobalStore?: boolean;
|
|
243
|
-
sync?: boolean | SyncOptions;
|
|
244
|
-
/**
|
|
245
|
-
* Optional feature option bag for third-party plugins.
|
|
246
|
-
* Keys are plugin names, values are plugin-specific options.
|
|
247
|
-
*/
|
|
248
|
-
features?: FeatureOptions;
|
|
249
|
-
/**
|
|
250
|
-
* Snapshot cloning strategy used by subscriptions and selector snapshots.
|
|
251
|
-
*
|
|
252
|
-
* - "deep" (default): deep clone and dev-freeze snapshot values.
|
|
253
|
-
* - "shallow": shallow clone (top-level) only; nested references are shared.
|
|
254
|
-
* - "ref": return the live store reference (dev-freeze by default).
|
|
255
|
-
*/
|
|
256
|
-
snapshot?: SnapshotMode;
|
|
257
|
-
/**
|
|
258
|
-
* Safety policy for snapshot deliveries when using "ref" or "shallow" modes.
|
|
259
|
-
* - "warn": (default) log a warning in dev when mutation is detected.
|
|
260
|
-
* - "throw": throw an error in dev when mutation is detected.
|
|
261
|
-
* - "auto-clone": in dev, if a subscriber mutates a frozen snapshot, deliver a cloned
|
|
262
|
-
* snapshot to that subscriber so the mutation does not affect other subscribers or the store.
|
|
263
|
-
*/
|
|
264
|
-
snapshotSafety?: 'warn' | 'throw' | 'auto-clone';
|
|
265
|
-
}
|
|
266
|
-
export interface NormalizedOptions {
|
|
267
|
-
scope: StoreScope;
|
|
268
|
-
lazy: boolean;
|
|
269
|
-
pathCreate: boolean;
|
|
270
|
-
persist: PersistConfig | null;
|
|
271
|
-
devtools: boolean;
|
|
272
|
-
middleware: Array<(ctx: MiddlewareCtx) => StoreValue | void>;
|
|
273
|
-
onSet?: (prev: StoreValue, next: StoreValue) => void;
|
|
274
|
-
onReset?: (prev: StoreValue, next: StoreValue) => void;
|
|
275
|
-
onDelete?: (prev: StoreValue) => void;
|
|
276
|
-
onCreate?: (initial: StoreValue) => void;
|
|
277
|
-
onError?: (err: string) => void;
|
|
278
|
-
validate?: ValidateOption;
|
|
279
|
-
migrations: Record<number, (state: any) => any>;
|
|
280
|
-
version: number;
|
|
281
|
-
redactor?: (state: StoreValue) => StoreValue;
|
|
282
|
-
historyLimit: number;
|
|
283
|
-
allowSSRGlobalStore?: boolean;
|
|
284
|
-
sync?: boolean | SyncOptions;
|
|
285
|
-
features?: FeatureOptions;
|
|
286
|
-
snapshot: SnapshotMode;
|
|
287
|
-
/** normalized snapshotSafety value */
|
|
288
|
-
snapshotSafety?: 'warn' | 'throw' | 'auto-clone';
|
|
289
|
-
explicitPersist: boolean;
|
|
290
|
-
explicitSync: boolean;
|
|
291
|
-
explicitDevtools: boolean;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Resets the internal set of legacy options that have been warned
|
|
295
|
-
* about. Used for testing purposes to prevent warnings from leaking
|
|
296
|
-
* between tests.
|
|
297
|
-
*/
|
|
298
|
-
export declare const resetLegacyOptionDeprecationWarningsForTests: () => void;
|
|
299
|
-
/**
|
|
300
|
-
* Normalize persist options for a store.
|
|
301
|
-
*
|
|
302
|
-
* This function takes the raw persist options from a store and returns
|
|
303
|
-
* a normalized PersistConfig object. If the raw persist options are
|
|
304
|
-
* invalid, this function returns null.
|
|
305
|
-
*
|
|
306
|
-
* @template State
|
|
307
|
-
* @param {StoreOptions<State>["persist"]} persist - The raw persist options for the store.
|
|
308
|
-
* @param {string} name - The name of the store.
|
|
309
|
-
* @returns {PersistConfig | null} A normalized PersistConfig object, or null if the raw persist options are invalid.
|
|
310
|
-
*/
|
|
311
|
-
export declare const normalizePersistOptions: <State>(persist: StoreOptions<State>["persist"], name: string) => PersistConfig | null;
|
|
312
|
-
/**
|
|
313
|
-
* Collect deprecation warnings for a store options object.
|
|
314
|
-
*
|
|
315
|
-
* This function walks through the store options object and checks if any
|
|
316
|
-
* deprecated options are present. If a deprecated option is found, a
|
|
317
|
-
* warning message is added to the warnings array.
|
|
318
|
-
*
|
|
319
|
-
* The function returns an array of warning messages. If no deprecated
|
|
320
|
-
* options are found, an empty array is returned.
|
|
321
|
-
*
|
|
322
|
-
* @template State The type of the state stored in the store.
|
|
323
|
-
* @param option The store options object to check for deprecated options.
|
|
324
|
-
* @returns An array of warning messages for deprecated options. If no deprecated
|
|
325
|
-
* options are found, an empty array is returned.
|
|
326
|
-
*/
|
|
327
|
-
export declare const collectLegacyOptionDeprecationWarnings: <State>(option: StoreOptions<State>) => string[];
|
|
328
|
-
/**
|
|
329
|
-
* Normalize a store options object, merging default values and performing deprecation checks.
|
|
330
|
-
* @param option The store options object to normalize.
|
|
331
|
-
* @param name The name of the store.
|
|
332
|
-
* @param defaultSnapshotMode The default snapshot mode to use if none is specified.
|
|
333
|
-
* @returns A normalized store options object.
|
|
334
|
-
*/
|
|
335
|
-
export declare const normalizeStoreOptions: <State>(option: StoreOptions<State> | undefined, name: string, defaultSnapshotMode?: SnapshotMode) => NormalizedOptions;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module async-cache
|
|
3
|
-
*
|
|
4
|
-
* LAYER: Module
|
|
5
|
-
* OWNS: Module-level behavior and exports for async-cache.
|
|
6
|
-
*
|
|
7
|
-
* Consumers: Internal imports and public API.
|
|
8
|
-
*/
|
|
9
|
-
import { getActiveAsyncRegistry } from "../core/store-core.js";
|
|
10
|
-
export { getActiveAsyncRegistry } from "../core/store-core.js";
|
|
11
|
-
import type { WarnCategory, StoreCleanupKind } from "./registry.js";
|
|
12
|
-
export type { FetchOptions, AsyncStateSnapshot, AsyncStateAdapter, StoreCleanupKind } from "./registry.js";
|
|
13
|
-
export type FetchInput = string | Promise<unknown> | (() => string | Promise<unknown>);
|
|
14
|
-
export declare const MAX_CACHE_SLOTS_PER_STORE = 100;
|
|
15
|
-
export declare const MAX_INFLIGHT_SLOTS_PER_STORE = 100;
|
|
16
|
-
export declare const MAX_WARNED_ENTRIES = 1000;
|
|
17
|
-
export declare const getFetchRegistry: () => ReturnType<typeof getActiveAsyncRegistry>["fetchRegistry"];
|
|
18
|
-
export declare const getInflightRegistry: () => ReturnType<typeof getActiveAsyncRegistry>["inflight"];
|
|
19
|
-
export declare const getRequestVersionRegistry: () => ReturnType<typeof getActiveAsyncRegistry>["requestVersion"];
|
|
20
|
-
export declare const getCacheMeta: () => ReturnType<typeof getActiveAsyncRegistry>["cacheMeta"];
|
|
21
|
-
export declare const getRateWindowStartRegistry: () => ReturnType<typeof getActiveAsyncRegistry>["rateWindowStart"];
|
|
22
|
-
export declare const getRateCountRegistry: () => ReturnType<typeof getActiveAsyncRegistry>["rateCount"];
|
|
23
|
-
export declare const getRatePruneState: () => ReturnType<typeof getActiveAsyncRegistry>["ratePruneState"];
|
|
24
|
-
export declare const getRevalidateHandlers: () => ReturnType<typeof getActiveAsyncRegistry>["revalidateHandlers"];
|
|
25
|
-
export declare const getStoreCleanups: () => ReturnType<typeof getActiveAsyncRegistry>["storeCleanups"];
|
|
26
|
-
export declare const getWarnedOnce: () => ReturnType<typeof getActiveAsyncRegistry>["warnedOnce"];
|
|
27
|
-
export declare const getRevalidateKeys: () => ReturnType<typeof getActiveAsyncRegistry>["revalidateKeys"];
|
|
28
|
-
export declare const getAsyncMetrics: () => ReturnType<typeof getActiveAsyncRegistry>["asyncMetrics"];
|
|
29
|
-
export declare const markWarned: (set: Set<string>, key: string) => void;
|
|
30
|
-
export declare const warnOnce: (category: WarnCategory, key: string, onWarn: () => void) => void;
|
|
31
|
-
export declare const cleanupStoreCleanupsByKind: (kind: StoreCleanupKind) => void;
|
|
32
|
-
export declare const resetAsyncState: () => void;
|
|
33
|
-
export declare const shouldUseCache: (cacheSlot: string, ttl?: number) => boolean;
|
|
34
|
-
export declare const clearAsyncMeta: (name: string) => void;
|
|
35
|
-
export declare const pruneAsyncCache: (name: string) => void;
|
|
36
|
-
export declare const countInflightSlots: (name: string) => number;
|
|
37
|
-
export declare const registerStoreCleanup: (name: string, fn: () => void, kind?: StoreCleanupKind) => void;
|
|
38
|
-
export declare const unregisterStoreCleanup: (name: string, fn: () => void, kind?: StoreCleanupKind) => void;
|
|
39
|
-
export declare const ensureCleanupSubscription: (_name: string) => void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module async/clone
|
|
3
|
-
*
|
|
4
|
-
* LAYER: Async subsystem
|
|
5
|
-
* OWNS: Module-level behavior and exports for async/clone.
|
|
6
|
-
*
|
|
7
|
-
* Consumers: Internal imports and public API.
|
|
8
|
-
*/
|
|
9
|
-
import type { FetchOptions } from "./cache.js";
|
|
10
|
-
export declare const cloneAsyncResult: (value: unknown, mode: FetchOptions["cloneResult"]) => unknown;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const runAsyncHook: (name: string, label: "onSuccess" | "onError", fn: ((value: any) => void) | undefined, value: unknown) => void;
|
|
2
|
-
export declare const reportAsyncUsageError: (name: string, message: string, onError?: (message: string) => void) => null;
|
|
3
|
-
export declare const throwAsyncUsageError: (name: string, message: string, onError?: (message: string) => void) => never;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { StoreDefinition, StoreKey, StoreName } from "../core/store-lifecycle/types.js";
|
|
2
|
-
import { type FetchInput, type FetchOptions } from "./cache.js";
|
|
3
|
-
export declare function fetchStore<Name extends string, State>(name: StoreDefinition<Name, State>, urlOrRequest: FetchInput, options?: FetchOptions): Promise<unknown>;
|
|
4
|
-
export declare function fetchStore<Name extends string, State>(name: StoreKey<Name, State>, urlOrRequest: FetchInput, options?: FetchOptions): Promise<unknown>;
|
|
5
|
-
export declare function fetchStore<Name extends StoreName>(name: Name, urlOrRequest: FetchInput, options?: FetchOptions): Promise<unknown>;
|
|
6
|
-
export declare function refetchStore<Name extends string, State>(name: StoreDefinition<Name, State>): Promise<unknown>;
|
|
7
|
-
export declare function refetchStore<Name extends string, State>(name: StoreKey<Name, State>): Promise<unknown>;
|
|
8
|
-
export declare function refetchStore<Name extends StoreName>(name: Name): Promise<unknown>;
|
|
9
|
-
export declare function enableRevalidateOnFocus<Name extends string, State>(name: StoreDefinition<Name, State>, overrides?: Partial<FetchOptions> & {
|
|
10
|
-
debounceMs?: number;
|
|
11
|
-
maxConcurrent?: number;
|
|
12
|
-
staggerMs?: number;
|
|
13
|
-
priority?: "high" | "normal";
|
|
14
|
-
}): (() => void);
|
|
15
|
-
export declare function enableRevalidateOnFocus<Name extends string, State>(name: StoreKey<Name, State>, overrides?: Partial<FetchOptions> & {
|
|
16
|
-
debounceMs?: number;
|
|
17
|
-
maxConcurrent?: number;
|
|
18
|
-
staggerMs?: number;
|
|
19
|
-
priority?: "high" | "normal";
|
|
20
|
-
}): (() => void);
|
|
21
|
-
export declare function enableRevalidateOnFocus<Name extends StoreName>(name?: Name | "*", overrides?: Partial<FetchOptions> & {
|
|
22
|
-
debounceMs?: number;
|
|
23
|
-
maxConcurrent?: number;
|
|
24
|
-
staggerMs?: number;
|
|
25
|
-
priority?: "high" | "normal";
|
|
26
|
-
}): (() => void);
|
|
27
|
-
export declare const getAsyncMetrics: () => {
|
|
28
|
-
cacheHits: number;
|
|
29
|
-
cacheMisses: number;
|
|
30
|
-
dedupes: number;
|
|
31
|
-
requests: number;
|
|
32
|
-
failures: number;
|
|
33
|
-
avgMs: number;
|
|
34
|
-
lastMs: number;
|
|
35
|
-
};
|
|
36
|
-
export declare const _resetAsyncStateForTests: () => void;
|
|
37
|
-
export declare const cleanupAllRevalidateHandlers: () => void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { FetchOptions } from "./cache.js";
|
|
2
|
-
export type InflightEntry = {
|
|
3
|
-
promise: Promise<unknown>;
|
|
4
|
-
raw: Promise<unknown>;
|
|
5
|
-
transform?: FetchOptions["transform"];
|
|
6
|
-
};
|
|
7
|
-
export declare const isCurrentRequest: (cacheSlot: string, version: number) => boolean;
|
|
8
|
-
export declare const reserveRequestVersion: (cacheSlot: string) => number;
|
|
9
|
-
export declare const clearRequestVersion: (cacheSlot: string, version: number) => void;
|
|
10
|
-
export declare const setInflightEntry: (cacheSlot: string, entry: InflightEntry) => void;
|
|
11
|
-
export declare const clearInflightEntry: (cacheSlot: string) => void;
|
|
12
|
-
export declare const hasInflightEntry: (cacheSlot: string) => boolean;
|
|
13
|
-
export declare const tryDedupeRequest: (name: string, cacheSlot: string, transform: FetchOptions["transform"] | undefined, onError?: (message: string) => void) => Promise<unknown> | null | undefined;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const RATE_WINDOW_MS = 1000;
|
|
2
|
-
export declare const RATE_MAX = 100;
|
|
3
|
-
export declare const pruneRateCounters: (nowTs: number) => void;
|
|
4
|
-
export declare const scheduleRatePrune: (delayMs?: number) => void;
|
|
5
|
-
export declare const registerRateHit: (cacheSlot: string, nowTs: number) => boolean;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module async-registry
|
|
3
|
-
*
|
|
4
|
-
* LAYER: Module
|
|
5
|
-
* OWNS: Module-level behavior and exports for async-registry.
|
|
6
|
-
*
|
|
7
|
-
* Consumers: Internal imports and public API.
|
|
8
|
-
*/
|
|
9
|
-
import type { TraceContext } from "../types/utility.js";
|
|
10
|
-
export type AsyncStateSnapshot = {
|
|
11
|
-
data?: unknown;
|
|
12
|
-
loading: boolean;
|
|
13
|
-
error: string | null;
|
|
14
|
-
status: "idle" | "loading" | "success" | "error" | "aborted";
|
|
15
|
-
cached?: boolean;
|
|
16
|
-
revalidating?: boolean;
|
|
17
|
-
correlationId?: string;
|
|
18
|
-
traceContext?: TraceContext;
|
|
19
|
-
};
|
|
20
|
-
export type AsyncStateAdapter = (ctx: {
|
|
21
|
-
name: string;
|
|
22
|
-
prev: unknown;
|
|
23
|
-
next: AsyncStateSnapshot;
|
|
24
|
-
set: (value: unknown | ((draft: any) => void)) => void;
|
|
25
|
-
}) => void;
|
|
26
|
-
export type WarnCategory = "noSignal" | "shape" | "autoCreate" | "mutableResult";
|
|
27
|
-
export type StoreCleanupKind = "store" | "revalidate";
|
|
28
|
-
export type StoreCleanupBucket = Partial<Record<StoreCleanupKind, Set<() => void>>>;
|
|
29
|
-
export interface FetchOptions {
|
|
30
|
-
transform?: (result: unknown) => unknown;
|
|
31
|
-
onSuccess?: (data: unknown) => void;
|
|
32
|
-
onError?: (message: string) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Optional adapter to write async state into a custom store shape.
|
|
35
|
-
* When provided, default AsyncState writes are skipped.
|
|
36
|
-
*/
|
|
37
|
-
stateAdapter?: AsyncStateAdapter;
|
|
38
|
-
method?: string;
|
|
39
|
-
headers?: Record<string, string>;
|
|
40
|
-
body?: unknown;
|
|
41
|
-
ttl?: number;
|
|
42
|
-
staleWhileRevalidate?: boolean;
|
|
43
|
-
dedupe?: boolean;
|
|
44
|
-
retry?: number;
|
|
45
|
-
retryDelay?: number;
|
|
46
|
-
retryBackoff?: number;
|
|
47
|
-
signal?: AbortSignal;
|
|
48
|
-
cacheKey?: string;
|
|
49
|
-
responseType?: "auto" | "json" | "text" | "arrayBuffer" | "blob" | "formData";
|
|
50
|
-
/**
|
|
51
|
-
* Optional correlation ID for tracing async writes.
|
|
52
|
-
* When provided, it is propagated into store metadata and middleware context.
|
|
53
|
-
*/
|
|
54
|
-
correlationId?: string;
|
|
55
|
-
/**
|
|
56
|
-
* Optional trace context (e.g. OpenTelemetry).
|
|
57
|
-
*/
|
|
58
|
-
traceContext?: TraceContext;
|
|
59
|
-
/**
|
|
60
|
-
* Auto-create the backing store if missing.
|
|
61
|
-
* Defaults to the global config setting (true by default).
|
|
62
|
-
*/
|
|
63
|
-
autoCreate?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Clone strategy for transformed results.
|
|
66
|
-
* - "none" (default): store by reference.
|
|
67
|
-
* - "shallow": shallow clone objects/arrays.
|
|
68
|
-
* - "deep": deep clone objects/arrays.
|
|
69
|
-
*/
|
|
70
|
-
cloneResult?: "none" | "shallow" | "deep";
|
|
71
|
-
}
|
|
72
|
-
type InflightEntry = {
|
|
73
|
-
promise: Promise<unknown>;
|
|
74
|
-
raw: Promise<unknown>;
|
|
75
|
-
transform?: FetchOptions["transform"];
|
|
76
|
-
};
|
|
77
|
-
export type AsyncRegistry = {
|
|
78
|
-
fetchRegistry: Record<string, {
|
|
79
|
-
kind: "url";
|
|
80
|
-
url: string;
|
|
81
|
-
options: FetchOptions;
|
|
82
|
-
} | {
|
|
83
|
-
kind: "factory";
|
|
84
|
-
factory: () => string | Promise<unknown>;
|
|
85
|
-
options: FetchOptions;
|
|
86
|
-
}>;
|
|
87
|
-
inflight: Partial<Record<string, InflightEntry>>;
|
|
88
|
-
requestVersion: Record<string, number>;
|
|
89
|
-
cacheMeta: Record<string, {
|
|
90
|
-
timestamp: number;
|
|
91
|
-
expiresAt: number | null;
|
|
92
|
-
data: unknown;
|
|
93
|
-
}>;
|
|
94
|
-
rateWindowStart: Record<string, number>;
|
|
95
|
-
rateCount: Record<string, number>;
|
|
96
|
-
ratePruneState: {
|
|
97
|
-
lastAt: number;
|
|
98
|
-
};
|
|
99
|
-
ratePruneTimer: ReturnType<typeof setTimeout> | null;
|
|
100
|
-
warnedOnce: Map<WarnCategory, Set<string>>;
|
|
101
|
-
storeCleanups: Record<string, StoreCleanupBucket>;
|
|
102
|
-
revalidateKeys: Set<string>;
|
|
103
|
-
revalidateHandlers: Record<string, () => void>;
|
|
104
|
-
asyncMetrics: {
|
|
105
|
-
cacheHits: number;
|
|
106
|
-
cacheMisses: number;
|
|
107
|
-
dedupes: number;
|
|
108
|
-
requests: number;
|
|
109
|
-
failures: number;
|
|
110
|
-
avgMs: number;
|
|
111
|
-
lastMs: number;
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
export declare const createAsyncRegistry: () => AsyncRegistry;
|
|
115
|
-
export declare const resetAsyncRegistry: (registry: AsyncRegistry) => void;
|
|
116
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module async/request
|
|
3
|
-
*
|
|
4
|
-
* LAYER: Async subsystem
|
|
5
|
-
* OWNS: Module-level behavior and exports for async/request.
|
|
6
|
-
*
|
|
7
|
-
* Consumers: Internal imports and public API.
|
|
8
|
-
*/
|
|
9
|
-
import type { FetchOptions } from "./cache.js";
|
|
10
|
-
export declare const buildFetchOptions: (options: FetchOptions) => RequestInit;
|
|
11
|
-
export declare const parseResponseBody: (response: Response, responseType: FetchOptions["responseType"]) => Promise<unknown>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const MAX_RETRY_ATTEMPTS = 10;
|
|
2
|
-
export declare const MIN_RETRY_DELAY_MS = 10;
|
|
3
|
-
export declare const MAX_RETRY_DELAY_MS = 30000;
|
|
4
|
-
export declare const MAX_RETRY_BACKOFF = 8;
|
|
5
|
-
export declare const delay: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
6
|
-
export declare const normalizeRetryOptions: (name: string, retry: number, retryDelay: number, retryBackoff: number) => {
|
|
7
|
-
retry: number;
|
|
8
|
-
retryDelay: number;
|
|
9
|
-
retryBackoff: number;
|
|
10
|
-
};
|
package/dist/types/async.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module async
|
|
3
|
-
*
|
|
4
|
-
* LAYER: Async subsystem
|
|
5
|
-
* OWNS: Module-level behavior and exports for async.
|
|
6
|
-
*
|
|
7
|
-
* Consumers: Internal imports and public API.
|
|
8
|
-
*/
|
|
9
|
-
export type { FetchOptions, FetchInput, AsyncStateSnapshot, AsyncStateAdapter } from "./async/cache.js";
|
|
10
|
-
export { fetchStore, refetchStore, enableRevalidateOnFocus, getAsyncMetrics, _resetAsyncStateForTests, } from "./async/fetch.js";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module computed-graph
|
|
3
|
-
*
|
|
4
|
-
* LAYER: Module
|
|
5
|
-
* OWNS: Module-level behavior and exports for computed-graph.
|
|
6
|
-
*
|
|
7
|
-
* Consumers: Internal imports and public API.
|
|
8
|
-
*/
|
|
9
|
-
import { type ComputedEntry } from "../core/store-registry.js";
|
|
10
|
-
export declare const detectCycle: (name: string, deps: string[]) => string | null;
|
|
11
|
-
export declare const registerComputed: (name: string, deps: string[], compute: (...args: unknown[]) => unknown) => boolean;
|
|
12
|
-
export declare const unregisterComputed: (name: string) => void;
|
|
13
|
-
export declare const markStale: (name: string) => void;
|
|
14
|
-
export declare const isComputed: (name: string) => boolean;
|
|
15
|
-
export declare const getComputedEntry: (name: string) => ComputedEntry | undefined;
|
|
16
|
-
export declare const getTopoOrderedComputeds: (changedSources: string[]) => string[];
|
|
17
|
-
export declare const getFullComputedGraph: () => {
|
|
18
|
-
nodes: string[];
|
|
19
|
-
edges: Array<{
|
|
20
|
-
from: string;
|
|
21
|
-
to: string;
|
|
22
|
-
}>;
|
|
23
|
-
dependencies: Record<string, string[]>;
|
|
24
|
-
dependents: Record<string, string[]>;
|
|
25
|
-
};
|
|
26
|
-
export declare const getComputedDepsFor: (name: string) => {
|
|
27
|
-
deps: string[];
|
|
28
|
-
dependents: string[];
|
|
29
|
-
} | null;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import "../core/store-notify.js";
|
|
2
|
-
import type { StoreDefinition, StoreKey, StoreName, StateFor, StoreValue } from "../core/store-lifecycle/types.js";
|
|
3
|
-
export type ComputedOptions = {
|
|
4
|
-
autoDispose?: boolean;
|
|
5
|
-
onError?: (err: unknown) => void;
|
|
6
|
-
};
|
|
7
|
-
type DepHandle = StoreDefinition<string, StoreValue> | StoreKey<string, StoreValue>;
|
|
8
|
-
type DepValue<T> = T extends StoreDefinition<string, infer S> ? Readonly<S> | null : T extends StoreKey<string, infer S> ? Readonly<S> | null : T extends StoreName ? Readonly<StateFor<T>> | null : StoreValue | null;
|
|
9
|
-
export declare function createComputed<TResult, Deps extends readonly (StoreName | DepHandle)[]>(name: string, deps: Deps, compute: (...args: {
|
|
10
|
-
[K in keyof Deps]: DepValue<Deps[K]>;
|
|
11
|
-
}) => TResult, options?: ComputedOptions): StoreDefinition<string, TResult> | undefined;
|
|
12
|
-
export declare const invalidateComputed: (name: string) => void;
|
|
13
|
-
export declare const deleteComputed: (name: string) => void;
|
|
14
|
-
export declare const isComputedStore: (name: string) => boolean;
|
|
15
|
-
export declare const _resetComputedForTests: () => void;
|
|
16
|
-
export { getFullComputedGraph, getComputedDepsFor } from "./computed-graph.js";
|
package/dist/types/config.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module config
|
|
3
|
-
*
|
|
4
|
-
* LAYER: Public API
|
|
5
|
-
* OWNS: Module-level behavior and exports for config.
|
|
6
|
-
*
|
|
7
|
-
* Consumers: Internal imports and public API.
|
|
8
|
-
*/
|
|
9
|
-
export { configureStroid, resetConfig, registerMutatorProduce } from "./internals/config.js";
|
|
10
|
-
export type { LogSink, StroidConfig, FlushConfig, RevalidateOnFocusConfig, } from "./internals/config.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module core
|
|
3
|
-
*
|
|
4
|
-
* LAYER: Public API (minimal runtime)
|
|
5
|
-
* OWNS: Core store primitives only.
|
|
6
|
-
*
|
|
7
|
-
* Consumers: Bundle-size-sensitive consumers and explicit core usage.
|
|
8
|
-
*/
|
|
9
|
-
export { createStore } from "./store-create.js";
|
|
10
|
-
export { setStore, resetStore, deleteStore } from "./store-write.js";
|
|
11
|
-
export { getStore, hasStore } from "./store-read.js";
|