@durable-streams/state 0.2.9 → 0.3.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.
package/dist/index.d.cts CHANGED
@@ -1,315 +1,2 @@
1
- import { Collection, Collection as Collection$1, SyncConfig, and, avg, coalesce, concat, count, createCollection, createLiveQueryCollection, createOptimisticAction, createOptimisticAction as createOptimisticAction$1, createTransaction, deepEquals, eq, gt, gte, ilike, inArray, isNull, isUndefined, like, localOnlyCollectionOptions, lt, lte, max, min, not, or, queryOnce, sum, toArray } from "@tanstack/db";
2
- import { StandardSchemaV1 } from "@standard-schema/spec";
3
- import { DurableStream, DurableStreamOptions, JsonBatch, LiveMode } from "@durable-streams/client";
4
-
5
- //#region src/types.d.ts
6
- /**
7
- * Operation types for change events
8
- */
9
- /**
10
- * Operation types for change events
11
- */
12
- type Operation = `insert` | `update` | `delete` | `upsert`;
13
- /**
14
- * A generic value type supporting primitives, arrays, and objects
15
- */
16
- type Value<Extensions = never> = string | number | boolean | bigint | null | Array<Value<Extensions>> | {
17
- [key: string]: Value<Extensions>;
18
- } | Extensions;
19
- /**
20
- * A row is a record of values
21
- */
22
- type Row<Extensions = never> = Record<string, Value<Extensions>>;
23
- /**
24
- * Headers for change messages
25
- */
26
- type ChangeHeaders = {
27
- operation: Operation;
28
- txid?: string;
29
- timestamp?: string;
30
- from?: string;
31
- offset?: string;
32
- };
33
- /**
34
- * A change event represents a state change event (insert/update/delete)
35
- */
36
- type ChangeEvent<T = unknown> = {
37
- type: string;
38
- key: string;
39
- value?: T;
40
- old_value?: T;
41
- headers: ChangeHeaders;
42
- };
43
- /**
44
- * Control event types for stream management
45
- */
46
- type ControlEvent = {
47
- headers: {
48
- control: `snapshot-start` | `snapshot-end` | `reset`;
49
- offset?: string;
50
- };
51
- };
52
- /**
53
- * A state event is either a change event or a control event
54
- */
55
- type StateEvent<T = unknown> = ChangeEvent<T> | ControlEvent;
56
- /**
57
- * Type guard to check if an event is a change event
58
- */
59
- declare function isChangeEvent<T = unknown>(event: StateEvent<T>): event is ChangeEvent<T>;
60
- /**
61
- * Type guard to check if an event is a control event
62
- */
63
- declare function isControlEvent<T = unknown>(event: StateEvent<T>): event is ControlEvent;
64
-
65
- //#endregion
66
- //#region src/materialized-state.d.ts
67
- /**
68
- * MaterializedState maintains an in-memory view of state from change events.
69
- *
70
- * It organizes data by type, where each type contains a map of key -> value.
71
- * This supports multi-type streams where different entity types can coexist.
72
- */
73
- declare class MaterializedState {
74
- private data;
75
- constructor();
76
- /**
77
- * Apply a single change event to update the materialized state
78
- */
79
- apply(event: ChangeEvent): void;
80
- /**
81
- * Apply a batch of change events
82
- */
83
- applyBatch(events: Array<ChangeEvent>): void;
84
- /**
85
- * Get a specific value by type and key
86
- */
87
- get<T = unknown>(type: string, key: string): T | undefined;
88
- /**
89
- * Get all entries for a specific type
90
- */
91
- getType(type: string): Map<string, unknown>;
92
- /**
93
- * Clear all state
94
- */
95
- clear(): void;
96
- /**
97
- * Get the number of types in the state
98
- */
99
- get typeCount(): number;
100
- /**
101
- * Get all type names
102
- */
103
- get types(): Array<string>;
104
- }
105
-
106
- //#endregion
107
- //#region src/stream-db.d.ts
108
- /**
109
- * Definition for a single collection in the stream state
110
- */
111
- interface CollectionDefinition<T = unknown> {
112
- /** Standard Schema for validating values */
113
- schema: StandardSchemaV1<T>;
114
- /** The type field value in change events that map to this collection */
115
- type: string;
116
- /** The property name in T that serves as the primary key */
117
- primaryKey: string;
118
- }
119
- /**
120
- * Helper methods for creating change events for a collection
121
- */
122
- interface CollectionEventHelpers<T> {
123
- /**
124
- * Create an insert change event
125
- */
126
- insert: (params: {
127
- key?: string;
128
- value: T;
129
- headers?: Omit<Record<string, string>, `operation`>;
130
- }) => ChangeEvent<T>;
131
- /**
132
- * Create an update change event
133
- */
134
- update: (params: {
135
- key?: string;
136
- value: T;
137
- oldValue?: T;
138
- headers?: Omit<Record<string, string>, `operation`>;
139
- }) => ChangeEvent<T>;
140
- /**
141
- * Create a delete change event
142
- */
143
- delete: (params: {
144
- key?: string;
145
- oldValue?: T;
146
- headers?: Omit<Record<string, string>, `operation`>;
147
- }) => ChangeEvent<T>;
148
- /**
149
- * Create an upsert change event (insert or update)
150
- */
151
- upsert: (params: {
152
- key?: string;
153
- value: T;
154
- headers?: Omit<Record<string, string>, `operation`>;
155
- }) => ChangeEvent<T>;
156
- }
157
- /**
158
- * Collection definition enhanced with event creation helpers
159
- */
160
- type CollectionWithHelpers<T = unknown> = CollectionDefinition<T> & CollectionEventHelpers<T>;
161
- /**
162
- * Stream state definition containing all collections
163
- */
164
- type StreamStateDefinition = Record<string, CollectionDefinition>;
165
- /**
166
- * Stream state schema with helper methods for creating change events
167
- */
168
- type StateSchema<T extends Record<string, CollectionDefinition>> = { [K in keyof T]: CollectionWithHelpers<T[K] extends CollectionDefinition<infer U> ? U : unknown> };
169
- /**
170
- * Definition for a single action that can be passed to createOptimisticAction
171
- */
172
- interface ActionDefinition<TParams = any, TContext = any> {
173
- onMutate: (params: TParams) => void;
174
- mutationFn: (params: TParams, context: TContext) => Promise<any>;
175
- }
176
- /**
177
- * Factory function for creating actions with access to db and stream context
178
- */
179
- type ActionFactory<TDef extends StreamStateDefinition, TActions extends Record<string, ActionDefinition<any>>> = (context: {
180
- db: StreamDB<TDef>;
181
- stream: DurableStream;
182
- }) => TActions;
183
- /**
184
- * Map action definitions to callable action functions
185
- */
186
- type ActionMap<TActions extends Record<string, ActionDefinition<any>>> = { [K in keyof TActions]: ReturnType<typeof createOptimisticAction$1<any>> };
187
- /**
188
- * Options for creating a stream DB
189
- */
190
- interface CreateStreamDBOptions<TDef extends StreamStateDefinition = StreamStateDefinition, TActions extends Record<string, ActionDefinition<any>> = Record<string, never>> {
191
- /** Options for creating a new durable stream. Ignored when `stream` is provided. */
192
- streamOptions?: DurableStreamOptions;
193
- /** Pre-existing DurableStream instance to reuse (avoids creating a second connection). */
194
- stream?: DurableStream;
195
- /** Live read mode used by the StreamDB consumer. Defaults to true. */
196
- live?: LiveMode;
197
- /** The stream state definition */
198
- state: TDef;
199
- /** Optional factory function to create actions with db and stream context */
200
- actions?: ActionFactory<TDef, TActions>;
201
- /** Called for every ChangeEvent as it flows through the stream consumer. */
202
- onEvent?: (event: ChangeEvent) => void;
203
- /**
204
- * Called once per consumed stream batch before items are dispatched.
205
- * Useful when external consumers need batch metadata available during
206
- * downstream collection/effect processing.
207
- */
208
- onBeforeBatch?: (batch: JsonBatch<StateEvent>) => void;
209
- /**
210
- * Called once per consumed stream batch after items have been dispatched.
211
- * Useful for tracking safe offsets for external ack/lease protocols.
212
- */
213
- onBatch?: (batch: JsonBatch<StateEvent>) => void;
214
- }
215
- /**
216
- * Extract the value type from a CollectionDefinition
217
- */
218
- type ExtractCollectionType<T extends CollectionDefinition> = T extends CollectionDefinition<infer U> ? U : unknown;
219
- /**
220
- * Map collection definitions to TanStack DB Collection types
221
- */
222
- type CollectionMap<TDef extends StreamStateDefinition> = { [K in keyof TDef]: Collection$1<ExtractCollectionType<TDef[K]> & object, string> };
223
- /**
224
- * The StreamDB interface - provides typed access to collections
225
- */
226
- type StreamDB<TDef extends StreamStateDefinition> = {
227
- collections: CollectionMap<TDef>;
228
- } & StreamDBMethods;
229
- /**
230
- * StreamDB with actions
231
- */
232
- type StreamDBWithActions<TDef extends StreamStateDefinition, TActions extends Record<string, ActionDefinition<any>>> = StreamDB<TDef> & {
233
- actions: ActionMap<TActions>;
234
- };
235
- /**
236
- * Utility methods available on StreamDB
237
- */
238
- interface StreamDBUtils {
239
- /**
240
- * Wait for a specific transaction ID to be synced through the stream
241
- * @param txid The transaction ID to wait for (UUID string)
242
- * @param timeout Optional timeout in milliseconds (defaults to 5000ms)
243
- * @returns Promise that resolves when the txid is synced
244
- */
245
- awaitTxId: (txid: string, timeout?: number) => Promise<void>;
246
- }
247
- /**
248
- * Methods available on a StreamDB instance
249
- */
250
- interface StreamDBMethods {
251
- /**
252
- * The underlying DurableStream instance
253
- */
254
- stream: DurableStream;
255
- /**
256
- * Current stream offset (tracks the last consumed position).
257
- */
258
- readonly offset: string;
259
- /**
260
- * Preload all collections by consuming the stream until up-to-date
261
- */
262
- preload: () => Promise<void>;
263
- /**
264
- * Close the stream connection and cleanup
265
- */
266
- close: () => void;
267
- /**
268
- * Utility methods for advanced stream operations
269
- */
270
- utils: StreamDBUtils;
271
- }
272
- /**
273
- * Build a TanStack collection id for a StreamDB collection.
274
- *
275
- * Collection ids must be unique per source stream, not just per schema key,
276
- * otherwise joining the same collection name from two different streams can
277
- * collapse to one logical source inside TanStack DB.
278
- */
279
- declare function getStreamDBCollectionId(streamUrl: string, collectionName: string): string;
280
- /**
281
- * Create a state schema definition with typed collections and event helpers
282
- */
283
- declare function createStateSchema<T extends Record<string, CollectionDefinition>>(collections: T): StateSchema<T>;
284
- /**
285
- * Create a stream-backed database with TanStack DB collections
286
- *
287
- * This function is synchronous - it creates the stream handle and collections
288
- * but does not start the stream connection. Call `db.preload()` to connect
289
- * and sync initial data.
290
- *
291
- * @example
292
- * ```typescript
293
- * const stateSchema = createStateSchema({
294
- * users: { schema: userSchema, type: "user", primaryKey: "id" },
295
- * messages: { schema: messageSchema, type: "message", primaryKey: "id" },
296
- * })
297
- *
298
- * // Create a stream DB (synchronous - stream is created lazily on preload)
299
- * const db = createStreamDB({
300
- * streamOptions: {
301
- * url: "https://api.example.com/streams/my-stream",
302
- * contentType: "application/json",
303
- * },
304
- * state: stateSchema,
305
- * })
306
- *
307
- * // preload() creates the stream and loads initial data
308
- * await db.preload()
309
- * const user = await db.collections.users.get("123")
310
- * ```
311
- */
312
- declare function createStreamDB<TDef extends StreamStateDefinition, TActions extends Record<string, ActionDefinition<any>> = Record<string, never>>(options: CreateStreamDBOptions<TDef, TActions>): TActions extends Record<string, never> ? StreamDB<TDef> : StreamDBWithActions<TDef, TActions>;
313
-
314
- //#endregion
315
- export { ActionDefinition, ActionFactory, ActionMap, ChangeEvent, ChangeHeaders, Collection, CollectionDefinition, CollectionEventHelpers, CollectionWithHelpers, ControlEvent, CreateStreamDBOptions, MaterializedState, Operation, Row, StateEvent, StateSchema, StreamDB, StreamDBMethods, StreamDBUtils, StreamDBWithActions, StreamStateDefinition, SyncConfig, Value, and, avg, coalesce, concat, count, createCollection, createLiveQueryCollection, createOptimisticAction, createStateSchema, createStreamDB, createTransaction, deepEquals, eq, getStreamDBCollectionId, gt, gte, ilike, inArray, isChangeEvent, isControlEvent, isNull, isUndefined, like, localOnlyCollectionOptions, lt, lte, max, min, not, or, queryOnce, sum, toArray };
1
+ import { ChangeEvent, ChangeHeaders, CollectionDefinition, CollectionEventHelpers, CollectionWithHelpers, ControlEvent, MaterializedState, Operation, Row, StateEvent, StateSchema, StreamStateDefinition, Value, createStateSchema, isChangeEvent, isControlEvent } from "./index-CqdIsdQy.cjs";
2
+ export { ChangeEvent, ChangeHeaders, CollectionDefinition, CollectionEventHelpers, CollectionWithHelpers, ControlEvent, MaterializedState, Operation, Row, StateEvent, StateSchema, StreamStateDefinition, Value, createStateSchema, isChangeEvent, isControlEvent };
package/dist/index.d.ts CHANGED
@@ -1,315 +1,2 @@
1
- import { Collection, Collection as Collection$1, SyncConfig, and, avg, coalesce, concat, count, createCollection, createLiveQueryCollection, createOptimisticAction, createOptimisticAction as createOptimisticAction$1, createTransaction, deepEquals, eq, gt, gte, ilike, inArray, isNull, isUndefined, like, localOnlyCollectionOptions, lt, lte, max, min, not, or, queryOnce, sum, toArray } from "@tanstack/db";
2
- import { DurableStream, DurableStreamOptions, JsonBatch, LiveMode } from "@durable-streams/client";
3
- import { StandardSchemaV1 } from "@standard-schema/spec";
4
-
5
- //#region src/types.d.ts
6
- /**
7
- * Operation types for change events
8
- */
9
- /**
10
- * Operation types for change events
11
- */
12
- type Operation = `insert` | `update` | `delete` | `upsert`;
13
- /**
14
- * A generic value type supporting primitives, arrays, and objects
15
- */
16
- type Value<Extensions = never> = string | number | boolean | bigint | null | Array<Value<Extensions>> | {
17
- [key: string]: Value<Extensions>;
18
- } | Extensions;
19
- /**
20
- * A row is a record of values
21
- */
22
- type Row<Extensions = never> = Record<string, Value<Extensions>>;
23
- /**
24
- * Headers for change messages
25
- */
26
- type ChangeHeaders = {
27
- operation: Operation;
28
- txid?: string;
29
- timestamp?: string;
30
- from?: string;
31
- offset?: string;
32
- };
33
- /**
34
- * A change event represents a state change event (insert/update/delete)
35
- */
36
- type ChangeEvent<T = unknown> = {
37
- type: string;
38
- key: string;
39
- value?: T;
40
- old_value?: T;
41
- headers: ChangeHeaders;
42
- };
43
- /**
44
- * Control event types for stream management
45
- */
46
- type ControlEvent = {
47
- headers: {
48
- control: `snapshot-start` | `snapshot-end` | `reset`;
49
- offset?: string;
50
- };
51
- };
52
- /**
53
- * A state event is either a change event or a control event
54
- */
55
- type StateEvent<T = unknown> = ChangeEvent<T> | ControlEvent;
56
- /**
57
- * Type guard to check if an event is a change event
58
- */
59
- declare function isChangeEvent<T = unknown>(event: StateEvent<T>): event is ChangeEvent<T>;
60
- /**
61
- * Type guard to check if an event is a control event
62
- */
63
- declare function isControlEvent<T = unknown>(event: StateEvent<T>): event is ControlEvent;
64
-
65
- //#endregion
66
- //#region src/materialized-state.d.ts
67
- /**
68
- * MaterializedState maintains an in-memory view of state from change events.
69
- *
70
- * It organizes data by type, where each type contains a map of key -> value.
71
- * This supports multi-type streams where different entity types can coexist.
72
- */
73
- declare class MaterializedState {
74
- private data;
75
- constructor();
76
- /**
77
- * Apply a single change event to update the materialized state
78
- */
79
- apply(event: ChangeEvent): void;
80
- /**
81
- * Apply a batch of change events
82
- */
83
- applyBatch(events: Array<ChangeEvent>): void;
84
- /**
85
- * Get a specific value by type and key
86
- */
87
- get<T = unknown>(type: string, key: string): T | undefined;
88
- /**
89
- * Get all entries for a specific type
90
- */
91
- getType(type: string): Map<string, unknown>;
92
- /**
93
- * Clear all state
94
- */
95
- clear(): void;
96
- /**
97
- * Get the number of types in the state
98
- */
99
- get typeCount(): number;
100
- /**
101
- * Get all type names
102
- */
103
- get types(): Array<string>;
104
- }
105
-
106
- //#endregion
107
- //#region src/stream-db.d.ts
108
- /**
109
- * Definition for a single collection in the stream state
110
- */
111
- interface CollectionDefinition<T = unknown> {
112
- /** Standard Schema for validating values */
113
- schema: StandardSchemaV1<T>;
114
- /** The type field value in change events that map to this collection */
115
- type: string;
116
- /** The property name in T that serves as the primary key */
117
- primaryKey: string;
118
- }
119
- /**
120
- * Helper methods for creating change events for a collection
121
- */
122
- interface CollectionEventHelpers<T> {
123
- /**
124
- * Create an insert change event
125
- */
126
- insert: (params: {
127
- key?: string;
128
- value: T;
129
- headers?: Omit<Record<string, string>, `operation`>;
130
- }) => ChangeEvent<T>;
131
- /**
132
- * Create an update change event
133
- */
134
- update: (params: {
135
- key?: string;
136
- value: T;
137
- oldValue?: T;
138
- headers?: Omit<Record<string, string>, `operation`>;
139
- }) => ChangeEvent<T>;
140
- /**
141
- * Create a delete change event
142
- */
143
- delete: (params: {
144
- key?: string;
145
- oldValue?: T;
146
- headers?: Omit<Record<string, string>, `operation`>;
147
- }) => ChangeEvent<T>;
148
- /**
149
- * Create an upsert change event (insert or update)
150
- */
151
- upsert: (params: {
152
- key?: string;
153
- value: T;
154
- headers?: Omit<Record<string, string>, `operation`>;
155
- }) => ChangeEvent<T>;
156
- }
157
- /**
158
- * Collection definition enhanced with event creation helpers
159
- */
160
- type CollectionWithHelpers<T = unknown> = CollectionDefinition<T> & CollectionEventHelpers<T>;
161
- /**
162
- * Stream state definition containing all collections
163
- */
164
- type StreamStateDefinition = Record<string, CollectionDefinition>;
165
- /**
166
- * Stream state schema with helper methods for creating change events
167
- */
168
- type StateSchema<T extends Record<string, CollectionDefinition>> = { [K in keyof T]: CollectionWithHelpers<T[K] extends CollectionDefinition<infer U> ? U : unknown> };
169
- /**
170
- * Definition for a single action that can be passed to createOptimisticAction
171
- */
172
- interface ActionDefinition<TParams = any, TContext = any> {
173
- onMutate: (params: TParams) => void;
174
- mutationFn: (params: TParams, context: TContext) => Promise<any>;
175
- }
176
- /**
177
- * Factory function for creating actions with access to db and stream context
178
- */
179
- type ActionFactory<TDef extends StreamStateDefinition, TActions extends Record<string, ActionDefinition<any>>> = (context: {
180
- db: StreamDB<TDef>;
181
- stream: DurableStream;
182
- }) => TActions;
183
- /**
184
- * Map action definitions to callable action functions
185
- */
186
- type ActionMap<TActions extends Record<string, ActionDefinition<any>>> = { [K in keyof TActions]: ReturnType<typeof createOptimisticAction$1<any>> };
187
- /**
188
- * Options for creating a stream DB
189
- */
190
- interface CreateStreamDBOptions<TDef extends StreamStateDefinition = StreamStateDefinition, TActions extends Record<string, ActionDefinition<any>> = Record<string, never>> {
191
- /** Options for creating a new durable stream. Ignored when `stream` is provided. */
192
- streamOptions?: DurableStreamOptions;
193
- /** Pre-existing DurableStream instance to reuse (avoids creating a second connection). */
194
- stream?: DurableStream;
195
- /** Live read mode used by the StreamDB consumer. Defaults to true. */
196
- live?: LiveMode;
197
- /** The stream state definition */
198
- state: TDef;
199
- /** Optional factory function to create actions with db and stream context */
200
- actions?: ActionFactory<TDef, TActions>;
201
- /** Called for every ChangeEvent as it flows through the stream consumer. */
202
- onEvent?: (event: ChangeEvent) => void;
203
- /**
204
- * Called once per consumed stream batch before items are dispatched.
205
- * Useful when external consumers need batch metadata available during
206
- * downstream collection/effect processing.
207
- */
208
- onBeforeBatch?: (batch: JsonBatch<StateEvent>) => void;
209
- /**
210
- * Called once per consumed stream batch after items have been dispatched.
211
- * Useful for tracking safe offsets for external ack/lease protocols.
212
- */
213
- onBatch?: (batch: JsonBatch<StateEvent>) => void;
214
- }
215
- /**
216
- * Extract the value type from a CollectionDefinition
217
- */
218
- type ExtractCollectionType<T extends CollectionDefinition> = T extends CollectionDefinition<infer U> ? U : unknown;
219
- /**
220
- * Map collection definitions to TanStack DB Collection types
221
- */
222
- type CollectionMap<TDef extends StreamStateDefinition> = { [K in keyof TDef]: Collection$1<ExtractCollectionType<TDef[K]> & object, string> };
223
- /**
224
- * The StreamDB interface - provides typed access to collections
225
- */
226
- type StreamDB<TDef extends StreamStateDefinition> = {
227
- collections: CollectionMap<TDef>;
228
- } & StreamDBMethods;
229
- /**
230
- * StreamDB with actions
231
- */
232
- type StreamDBWithActions<TDef extends StreamStateDefinition, TActions extends Record<string, ActionDefinition<any>>> = StreamDB<TDef> & {
233
- actions: ActionMap<TActions>;
234
- };
235
- /**
236
- * Utility methods available on StreamDB
237
- */
238
- interface StreamDBUtils {
239
- /**
240
- * Wait for a specific transaction ID to be synced through the stream
241
- * @param txid The transaction ID to wait for (UUID string)
242
- * @param timeout Optional timeout in milliseconds (defaults to 5000ms)
243
- * @returns Promise that resolves when the txid is synced
244
- */
245
- awaitTxId: (txid: string, timeout?: number) => Promise<void>;
246
- }
247
- /**
248
- * Methods available on a StreamDB instance
249
- */
250
- interface StreamDBMethods {
251
- /**
252
- * The underlying DurableStream instance
253
- */
254
- stream: DurableStream;
255
- /**
256
- * Current stream offset (tracks the last consumed position).
257
- */
258
- readonly offset: string;
259
- /**
260
- * Preload all collections by consuming the stream until up-to-date
261
- */
262
- preload: () => Promise<void>;
263
- /**
264
- * Close the stream connection and cleanup
265
- */
266
- close: () => void;
267
- /**
268
- * Utility methods for advanced stream operations
269
- */
270
- utils: StreamDBUtils;
271
- }
272
- /**
273
- * Build a TanStack collection id for a StreamDB collection.
274
- *
275
- * Collection ids must be unique per source stream, not just per schema key,
276
- * otherwise joining the same collection name from two different streams can
277
- * collapse to one logical source inside TanStack DB.
278
- */
279
- declare function getStreamDBCollectionId(streamUrl: string, collectionName: string): string;
280
- /**
281
- * Create a state schema definition with typed collections and event helpers
282
- */
283
- declare function createStateSchema<T extends Record<string, CollectionDefinition>>(collections: T): StateSchema<T>;
284
- /**
285
- * Create a stream-backed database with TanStack DB collections
286
- *
287
- * This function is synchronous - it creates the stream handle and collections
288
- * but does not start the stream connection. Call `db.preload()` to connect
289
- * and sync initial data.
290
- *
291
- * @example
292
- * ```typescript
293
- * const stateSchema = createStateSchema({
294
- * users: { schema: userSchema, type: "user", primaryKey: "id" },
295
- * messages: { schema: messageSchema, type: "message", primaryKey: "id" },
296
- * })
297
- *
298
- * // Create a stream DB (synchronous - stream is created lazily on preload)
299
- * const db = createStreamDB({
300
- * streamOptions: {
301
- * url: "https://api.example.com/streams/my-stream",
302
- * contentType: "application/json",
303
- * },
304
- * state: stateSchema,
305
- * })
306
- *
307
- * // preload() creates the stream and loads initial data
308
- * await db.preload()
309
- * const user = await db.collections.users.get("123")
310
- * ```
311
- */
312
- declare function createStreamDB<TDef extends StreamStateDefinition, TActions extends Record<string, ActionDefinition<any>> = Record<string, never>>(options: CreateStreamDBOptions<TDef, TActions>): TActions extends Record<string, never> ? StreamDB<TDef> : StreamDBWithActions<TDef, TActions>;
313
-
314
- //#endregion
315
- export { ActionDefinition, ActionFactory, ActionMap, ChangeEvent, ChangeHeaders, Collection, CollectionDefinition, CollectionEventHelpers, CollectionWithHelpers, ControlEvent, CreateStreamDBOptions, MaterializedState, Operation, Row, StateEvent, StateSchema, StreamDB, StreamDBMethods, StreamDBUtils, StreamDBWithActions, StreamStateDefinition, SyncConfig, Value, and, avg, coalesce, concat, count, createCollection, createLiveQueryCollection, createOptimisticAction, createStateSchema, createStreamDB, createTransaction, deepEquals, eq, getStreamDBCollectionId, gt, gte, ilike, inArray, isChangeEvent, isControlEvent, isNull, isUndefined, like, localOnlyCollectionOptions, lt, lte, max, min, not, or, queryOnce, sum, toArray };
1
+ import { ChangeEvent, ChangeHeaders, CollectionDefinition, CollectionEventHelpers, CollectionWithHelpers, ControlEvent, MaterializedState$1 as MaterializedState, Operation, Row, StateEvent, StateSchema, StreamStateDefinition, Value, createStateSchema$1 as createStateSchema, isChangeEvent$1 as isChangeEvent, isControlEvent$1 as isControlEvent } from "./index-D6Nak3Wl.js";
2
+ export { ChangeEvent, ChangeHeaders, CollectionDefinition, CollectionEventHelpers, CollectionWithHelpers, ControlEvent, MaterializedState, Operation, Row, StateEvent, StateSchema, StreamStateDefinition, Value, createStateSchema, isChangeEvent, isControlEvent };