@delta-base/core 1.0.0 → 1.2.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/dist/index.d.ts CHANGED
@@ -1,16 +1,15 @@
1
1
  import * as hono_hono_base from 'hono/hono-base';
2
2
  import * as hono_utils_http_status from 'hono/utils/http-status';
3
3
  import * as hono_types from 'hono/types';
4
- import * as hono from 'hono';
5
4
  import { z, OpenAPIHono } from '@hono/zod-openapi';
6
5
  import { DurableObject } from 'cloudflare:workers';
7
6
 
8
7
  declare namespace ManagementAPI {
9
8
  const EventStoreSchema: z.ZodObject<{
10
- eventStoreID: z.ZodString;
9
+ eventStoreId: z.ZodString;
11
10
  eventStoreName: z.ZodString;
12
- eventStoreDurableObjectID: z.ZodString;
13
- eventBusDurableObjectID: z.ZodString;
11
+ eventStoreDurableObjectId: z.ZodString;
12
+ eventBusDurableObjectId: z.ZodString;
14
13
  description: z.ZodOptional<z.ZodString>;
15
14
  settings: z.ZodOptional<z.ZodObject<{
16
15
  retentionPeriodDays: z.ZodOptional<z.ZodNumber>;
@@ -24,22 +23,22 @@ declare namespace ManagementAPI {
24
23
  }>>;
25
24
  created: z.ZodString;
26
25
  }, "strip", z.ZodTypeAny, {
26
+ eventStoreId: string;
27
27
  created: string;
28
- eventStoreID: string;
29
28
  eventStoreName: string;
30
- eventStoreDurableObjectID: string;
31
- eventBusDurableObjectID: string;
29
+ eventStoreDurableObjectId: string;
30
+ eventBusDurableObjectId: string;
32
31
  description?: string | undefined;
33
32
  settings?: {
34
33
  retentionPeriodDays?: number | undefined;
35
34
  maxStreamSizeBytes?: number | undefined;
36
35
  } | undefined;
37
36
  }, {
37
+ eventStoreId: string;
38
38
  created: string;
39
- eventStoreID: string;
40
39
  eventStoreName: string;
41
- eventStoreDurableObjectID: string;
42
- eventBusDurableObjectID: string;
40
+ eventStoreDurableObjectId: string;
41
+ eventBusDurableObjectId: string;
43
42
  description?: string | undefined;
44
43
  settings?: {
45
44
  retentionPeriodDays?: number | undefined;
@@ -76,10 +75,10 @@ declare namespace ManagementAPI {
76
75
  }>;
77
76
  const EventStoreListResponseSchema: z.ZodObject<{
78
77
  eventStores: z.ZodArray<z.ZodObject<{
79
- eventStoreID: z.ZodString;
78
+ eventStoreId: z.ZodString;
80
79
  eventStoreName: z.ZodString;
81
- eventStoreDurableObjectID: z.ZodString;
82
- eventBusDurableObjectID: z.ZodString;
80
+ eventStoreDurableObjectId: z.ZodString;
81
+ eventBusDurableObjectId: z.ZodString;
83
82
  description: z.ZodOptional<z.ZodString>;
84
83
  settings: z.ZodOptional<z.ZodObject<{
85
84
  retentionPeriodDays: z.ZodOptional<z.ZodNumber>;
@@ -93,22 +92,22 @@ declare namespace ManagementAPI {
93
92
  }>>;
94
93
  created: z.ZodString;
95
94
  }, "strip", z.ZodTypeAny, {
95
+ eventStoreId: string;
96
96
  created: string;
97
- eventStoreID: string;
98
97
  eventStoreName: string;
99
- eventStoreDurableObjectID: string;
100
- eventBusDurableObjectID: string;
98
+ eventStoreDurableObjectId: string;
99
+ eventBusDurableObjectId: string;
101
100
  description?: string | undefined;
102
101
  settings?: {
103
102
  retentionPeriodDays?: number | undefined;
104
103
  maxStreamSizeBytes?: number | undefined;
105
104
  } | undefined;
106
105
  }, {
106
+ eventStoreId: string;
107
107
  created: string;
108
- eventStoreID: string;
109
108
  eventStoreName: string;
110
- eventStoreDurableObjectID: string;
111
- eventBusDurableObjectID: string;
109
+ eventStoreDurableObjectId: string;
110
+ eventBusDurableObjectId: string;
112
111
  description?: string | undefined;
113
112
  settings?: {
114
113
  retentionPeriodDays?: number | undefined;
@@ -119,11 +118,11 @@ declare namespace ManagementAPI {
119
118
  }, "strip", z.ZodTypeAny, {
120
119
  totalCount: number;
121
120
  eventStores: {
121
+ eventStoreId: string;
122
122
  created: string;
123
- eventStoreID: string;
124
123
  eventStoreName: string;
125
- eventStoreDurableObjectID: string;
126
- eventBusDurableObjectID: string;
124
+ eventStoreDurableObjectId: string;
125
+ eventBusDurableObjectId: string;
127
126
  description?: string | undefined;
128
127
  settings?: {
129
128
  retentionPeriodDays?: number | undefined;
@@ -133,11 +132,11 @@ declare namespace ManagementAPI {
133
132
  }, {
134
133
  totalCount: number;
135
134
  eventStores: {
135
+ eventStoreId: string;
136
136
  created: string;
137
- eventStoreID: string;
138
137
  eventStoreName: string;
139
- eventStoreDurableObjectID: string;
140
- eventBusDurableObjectID: string;
138
+ eventStoreDurableObjectId: string;
139
+ eventBusDurableObjectId: string;
141
140
  description?: string | undefined;
142
141
  settings?: {
143
142
  retentionPeriodDays?: number | undefined;
@@ -159,10 +158,10 @@ declare namespace ManagementAPI {
159
158
  totalSize: number;
160
159
  }>;
161
160
  const EventStoreDetailsResponseSchema: z.ZodObject<z.objectUtil.extendShape<{
162
- eventStoreID: z.ZodString;
161
+ eventStoreId: z.ZodString;
163
162
  eventStoreName: z.ZodString;
164
- eventStoreDurableObjectID: z.ZodString;
165
- eventBusDurableObjectID: z.ZodString;
163
+ eventStoreDurableObjectId: z.ZodString;
164
+ eventBusDurableObjectId: z.ZodString;
166
165
  description: z.ZodOptional<z.ZodString>;
167
166
  settings: z.ZodOptional<z.ZodObject<{
168
167
  retentionPeriodDays: z.ZodOptional<z.ZodNumber>;
@@ -200,40 +199,40 @@ declare namespace ManagementAPI {
200
199
  totalSize: number;
201
200
  }>>;
202
201
  }>, "strip", z.ZodTypeAny, {
202
+ eventStoreId: string;
203
203
  created: string;
204
- eventStoreID: string;
205
204
  eventStoreName: string;
206
- eventStoreDurableObjectID: string;
207
- eventBusDurableObjectID: string;
205
+ eventStoreDurableObjectId: string;
206
+ eventBusDurableObjectId: string;
208
207
  description?: string | undefined;
209
- settings?: {
210
- retentionPeriodDays?: number | undefined;
211
- maxStreamSizeBytes?: number | undefined;
212
- } | undefined;
213
208
  streams?: {
214
209
  count: number;
215
210
  totalEvents: number;
216
211
  } | undefined;
212
+ settings?: {
213
+ retentionPeriodDays?: number | undefined;
214
+ maxStreamSizeBytes?: number | undefined;
215
+ } | undefined;
217
216
  databaseSizes?: {
218
217
  eventStoreDatabaseSize: number;
219
218
  eventBusDatabaseSize: number;
220
219
  totalSize: number;
221
220
  } | undefined;
222
221
  }, {
222
+ eventStoreId: string;
223
223
  created: string;
224
- eventStoreID: string;
225
224
  eventStoreName: string;
226
- eventStoreDurableObjectID: string;
227
- eventBusDurableObjectID: string;
225
+ eventStoreDurableObjectId: string;
226
+ eventBusDurableObjectId: string;
228
227
  description?: string | undefined;
229
- settings?: {
230
- retentionPeriodDays?: number | undefined;
231
- maxStreamSizeBytes?: number | undefined;
232
- } | undefined;
233
228
  streams?: {
234
229
  count: number;
235
230
  totalEvents: number;
236
231
  } | undefined;
232
+ settings?: {
233
+ retentionPeriodDays?: number | undefined;
234
+ maxStreamSizeBytes?: number | undefined;
235
+ } | undefined;
237
236
  databaseSizes?: {
238
237
  eventStoreDatabaseSize: number;
239
238
  eventBusDatabaseSize: number;
@@ -259,19 +258,53 @@ declare namespace ManagementAPI {
259
258
  }
260
259
 
261
260
  declare namespace EventStoreAPI {
262
- const AppendEventsRequestSchema: z.ZodObject<{
261
+ const EventSchema: z.ZodObject<{
262
+ streamId: z.ZodString;
263
+ streamPosition: z.ZodNumber;
264
+ globalPosition: z.ZodNumber;
265
+ eventId: z.ZodString;
266
+ type: z.ZodString;
267
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
268
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
269
+ schemaVersion: z.ZodString;
270
+ transactionId: z.ZodString;
271
+ createdAt: z.ZodString;
272
+ }, "strip", z.ZodTypeAny, {
273
+ type: string;
274
+ createdAt: string;
275
+ data: Record<string, unknown>;
276
+ eventId: string;
277
+ streamPosition: number;
278
+ globalPosition: number;
279
+ streamId: string;
280
+ schemaVersion: string;
281
+ transactionId: string;
282
+ metadata?: Record<string, unknown> | undefined;
283
+ }, {
284
+ type: string;
285
+ createdAt: string;
286
+ data: Record<string, unknown>;
287
+ eventId: string;
288
+ streamPosition: number;
289
+ globalPosition: number;
290
+ streamId: string;
291
+ schemaVersion: string;
292
+ transactionId: string;
293
+ metadata?: Record<string, unknown> | undefined;
294
+ }>;
295
+ export const AppendEventsRequestSchema: z.ZodObject<{
263
296
  events: z.ZodArray<z.ZodObject<{
264
297
  type: z.ZodString;
265
- data: z.ZodRecord<z.ZodString, z.ZodAny>;
266
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
298
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
299
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
267
300
  }, "strip", z.ZodTypeAny, {
268
301
  type: string;
269
- data: Record<string, any>;
270
- metadata?: Record<string, any> | undefined;
302
+ data: Record<string, unknown>;
303
+ metadata?: Record<string, unknown> | undefined;
271
304
  }, {
272
305
  type: string;
273
- data: Record<string, any>;
274
- metadata?: Record<string, any> | undefined;
306
+ data: Record<string, unknown>;
307
+ metadata?: Record<string, unknown> | undefined;
275
308
  }>, "many">;
276
309
  options: z.ZodOptional<z.ZodObject<{
277
310
  expectedStreamVersion: z.ZodOptional<z.ZodNumber>;
@@ -283,8 +316,8 @@ declare namespace EventStoreAPI {
283
316
  }, "strip", z.ZodTypeAny, {
284
317
  events: {
285
318
  type: string;
286
- data: Record<string, any>;
287
- metadata?: Record<string, any> | undefined;
319
+ data: Record<string, unknown>;
320
+ metadata?: Record<string, unknown> | undefined;
288
321
  }[];
289
322
  options?: {
290
323
  expectedStreamVersion?: number | undefined;
@@ -292,14 +325,14 @@ declare namespace EventStoreAPI {
292
325
  }, {
293
326
  events: {
294
327
  type: string;
295
- data: Record<string, any>;
296
- metadata?: Record<string, any> | undefined;
328
+ data: Record<string, unknown>;
329
+ metadata?: Record<string, unknown> | undefined;
297
330
  }[];
298
331
  options?: {
299
332
  expectedStreamVersion?: number | undefined;
300
333
  } | undefined;
301
334
  }>;
302
- const AppendEventsResponseSchema: z.ZodObject<{
335
+ export const AppendEventsResponseSchema: z.ZodObject<{
303
336
  success: z.ZodBoolean;
304
337
  nextExpectedStreamVersion: z.ZodNumber;
305
338
  eventsWritten: z.ZodNumber;
@@ -312,7 +345,7 @@ declare namespace EventStoreAPI {
312
345
  nextExpectedStreamVersion: number;
313
346
  eventsWritten: number;
314
347
  }>;
315
- const VersionConflictErrorSchema: z.ZodObject<{
348
+ export const VersionConflictErrorSchema: z.ZodObject<{
316
349
  error: z.ZodLiteral<"Version conflict">;
317
350
  details: z.ZodString;
318
351
  currentVersion: z.ZodNumber;
@@ -328,7 +361,7 @@ declare namespace EventStoreAPI {
328
361
  currentVersion: number;
329
362
  expectedVersion: number;
330
363
  }>;
331
- const ValidationErrorSchema: z.ZodObject<{
364
+ export const ValidationErrorSchema: z.ZodObject<{
332
365
  error: z.ZodLiteral<"Invalid request body">;
333
366
  details: z.ZodArray<z.ZodObject<{
334
367
  code: z.ZodString;
@@ -358,7 +391,7 @@ declare namespace EventStoreAPI {
358
391
  path: (string | number)[];
359
392
  }[];
360
393
  }>;
361
- const AppendEventsErrorSchema: z.ZodDiscriminatedUnion<"error", [z.ZodObject<{
394
+ export const AppendEventsErrorSchema: z.ZodDiscriminatedUnion<"error", [z.ZodObject<{
362
395
  error: z.ZodLiteral<"Version conflict">;
363
396
  details: z.ZodString;
364
397
  currentVersion: z.ZodNumber;
@@ -403,126 +436,400 @@ declare namespace EventStoreAPI {
403
436
  path: (string | number)[];
404
437
  }[];
405
438
  }>]>;
406
- const ReadStreamOptionsSchema: z.ZodObject<{
407
- consistencyLevel: z.ZodOptional<z.ZodEnum<["eventual", "strong"]>>;
439
+ export const ReadStreamOptionsSchema: z.ZodObject<{
408
440
  expectedStreamVersion: z.ZodOptional<z.ZodNumber>;
409
441
  }, "strip", z.ZodTypeAny, {
410
442
  expectedStreamVersion?: number | undefined;
411
- consistencyLevel?: "eventual" | "strong" | undefined;
412
443
  }, {
413
444
  expectedStreamVersion?: number | undefined;
414
- consistencyLevel?: "eventual" | "strong" | undefined;
415
445
  }>;
416
- const EventWithMetadataSchema: z.ZodObject<z.objectUtil.extendShape<{
417
- type: z.ZodString;
418
- data: z.ZodRecord<z.ZodString, z.ZodAny>;
419
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
420
- }, {
421
- metadata: z.ZodOptional<z.ZodObject<{
422
- eventId: z.ZodString;
446
+ export const ReadStreamResponseSchema: z.ZodObject<{
447
+ events: z.ZodArray<z.ZodObject<{
448
+ streamId: z.ZodString;
423
449
  streamPosition: z.ZodNumber;
424
- streamName: z.ZodString;
425
450
  globalPosition: z.ZodNumber;
451
+ eventId: z.ZodString;
452
+ type: z.ZodString;
453
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
454
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
455
+ schemaVersion: z.ZodString;
456
+ transactionId: z.ZodString;
457
+ createdAt: z.ZodString;
426
458
  }, "strip", z.ZodTypeAny, {
459
+ type: string;
460
+ createdAt: string;
461
+ data: Record<string, unknown>;
427
462
  eventId: string;
428
463
  streamPosition: number;
429
- streamName: string;
430
464
  globalPosition: number;
465
+ streamId: string;
466
+ schemaVersion: string;
467
+ transactionId: string;
468
+ metadata?: Record<string, unknown> | undefined;
431
469
  }, {
470
+ type: string;
471
+ createdAt: string;
472
+ data: Record<string, unknown>;
432
473
  eventId: string;
433
474
  streamPosition: number;
434
- streamName: string;
435
475
  globalPosition: number;
436
- }>>;
437
- }>, "strip", z.ZodTypeAny, {
438
- type: string;
439
- data: Record<string, any>;
440
- metadata?: {
476
+ streamId: string;
477
+ schemaVersion: string;
478
+ transactionId: string;
479
+ metadata?: Record<string, unknown> | undefined;
480
+ }>, "many">;
481
+ currentStreamVersion: z.ZodNumber;
482
+ }, "strip", z.ZodTypeAny, {
483
+ events: {
484
+ type: string;
485
+ createdAt: string;
486
+ data: Record<string, unknown>;
441
487
  eventId: string;
442
488
  streamPosition: number;
443
- streamName: string;
444
489
  globalPosition: number;
445
- } | undefined;
490
+ streamId: string;
491
+ schemaVersion: string;
492
+ transactionId: string;
493
+ metadata?: Record<string, unknown> | undefined;
494
+ }[];
495
+ currentStreamVersion: number;
446
496
  }, {
447
- type: string;
448
- data: Record<string, any>;
449
- metadata?: {
497
+ events: {
498
+ type: string;
499
+ createdAt: string;
500
+ data: Record<string, unknown>;
450
501
  eventId: string;
451
502
  streamPosition: number;
452
- streamName: string;
453
503
  globalPosition: number;
454
- } | undefined;
504
+ streamId: string;
505
+ schemaVersion: string;
506
+ transactionId: string;
507
+ metadata?: Record<string, unknown> | undefined;
508
+ }[];
509
+ currentStreamVersion: number;
510
+ }>;
511
+ export const QueryEventsParamsSchema: z.ZodObject<{
512
+ streamId: z.ZodOptional<z.ZodString>;
513
+ type: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
514
+ eventId: z.ZodOptional<z.ZodString>;
515
+ transactionId: z.ZodOptional<z.ZodString>;
516
+ fromPosition: z.ZodOptional<z.ZodNumber>;
517
+ toPosition: z.ZodOptional<z.ZodNumber>;
518
+ fromDate: z.ZodOptional<z.ZodString>;
519
+ toDate: z.ZodOptional<z.ZodString>;
520
+ phase: z.ZodOptional<z.ZodNumber>;
521
+ includeArchived: z.ZodOptional<z.ZodBoolean>;
522
+ limit: z.ZodOptional<z.ZodNumber>;
523
+ offset: z.ZodOptional<z.ZodNumber>;
524
+ sortBy: z.ZodOptional<z.ZodEnum<["globalPosition", "createdAt", "streamPosition"]>>;
525
+ sortDirection: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
526
+ includeCount: z.ZodOptional<z.ZodBoolean>;
527
+ }, "strip", z.ZodTypeAny, {
528
+ type?: string | string[] | undefined;
529
+ limit?: number | undefined;
530
+ offset?: number | undefined;
531
+ eventId?: string | undefined;
532
+ streamId?: string | undefined;
533
+ transactionId?: string | undefined;
534
+ phase?: number | undefined;
535
+ fromPosition?: number | undefined;
536
+ toPosition?: number | undefined;
537
+ fromDate?: string | undefined;
538
+ toDate?: string | undefined;
539
+ includeArchived?: boolean | undefined;
540
+ sortBy?: "createdAt" | "streamPosition" | "globalPosition" | undefined;
541
+ sortDirection?: "asc" | "desc" | undefined;
542
+ includeCount?: boolean | undefined;
543
+ }, {
544
+ type?: string | string[] | undefined;
545
+ limit?: number | undefined;
546
+ offset?: number | undefined;
547
+ eventId?: string | undefined;
548
+ streamId?: string | undefined;
549
+ transactionId?: string | undefined;
550
+ phase?: number | undefined;
551
+ fromPosition?: number | undefined;
552
+ toPosition?: number | undefined;
553
+ fromDate?: string | undefined;
554
+ toDate?: string | undefined;
555
+ includeArchived?: boolean | undefined;
556
+ sortBy?: "createdAt" | "streamPosition" | "globalPosition" | undefined;
557
+ sortDirection?: "asc" | "desc" | undefined;
558
+ includeCount?: boolean | undefined;
559
+ }>;
560
+ export const QueryStreamsParamsSchema: z.ZodObject<{
561
+ streamId: z.ZodOptional<z.ZodString>;
562
+ streamType: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
563
+ streamIdPattern: z.ZodOptional<z.ZodString>;
564
+ minPosition: z.ZodOptional<z.ZodNumber>;
565
+ maxPosition: z.ZodOptional<z.ZodNumber>;
566
+ fromDate: z.ZodOptional<z.ZodString>;
567
+ toDate: z.ZodOptional<z.ZodString>;
568
+ includeArchived: z.ZodOptional<z.ZodBoolean>;
569
+ includeMetadata: z.ZodOptional<z.ZodBoolean>;
570
+ limit: z.ZodOptional<z.ZodNumber>;
571
+ offset: z.ZodOptional<z.ZodNumber>;
572
+ sortBy: z.ZodOptional<z.ZodEnum<["streamPosition", "createdAt", "updatedAt", "streamId"]>>;
573
+ sortDirection: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
574
+ includeCount: z.ZodOptional<z.ZodBoolean>;
575
+ }, "strip", z.ZodTypeAny, {
576
+ limit?: number | undefined;
577
+ offset?: number | undefined;
578
+ streamId?: string | undefined;
579
+ fromDate?: string | undefined;
580
+ toDate?: string | undefined;
581
+ includeArchived?: boolean | undefined;
582
+ sortBy?: "createdAt" | "updatedAt" | "streamPosition" | "streamId" | undefined;
583
+ sortDirection?: "asc" | "desc" | undefined;
584
+ includeCount?: boolean | undefined;
585
+ streamType?: string | string[] | undefined;
586
+ streamIdPattern?: string | undefined;
587
+ minPosition?: number | undefined;
588
+ maxPosition?: number | undefined;
589
+ includeMetadata?: boolean | undefined;
590
+ }, {
591
+ limit?: number | undefined;
592
+ offset?: number | undefined;
593
+ streamId?: string | undefined;
594
+ fromDate?: string | undefined;
595
+ toDate?: string | undefined;
596
+ includeArchived?: boolean | undefined;
597
+ sortBy?: "createdAt" | "updatedAt" | "streamPosition" | "streamId" | undefined;
598
+ sortDirection?: "asc" | "desc" | undefined;
599
+ includeCount?: boolean | undefined;
600
+ streamType?: string | string[] | undefined;
601
+ streamIdPattern?: string | undefined;
602
+ minPosition?: number | undefined;
603
+ maxPosition?: number | undefined;
604
+ includeMetadata?: boolean | undefined;
455
605
  }>;
456
- const ReadStreamResponseSchema: z.ZodObject<{
457
- events: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
606
+ const PaginationSchema: z.ZodObject<{
607
+ limit: z.ZodNumber;
608
+ offset: z.ZodNumber;
609
+ total: z.ZodOptional<z.ZodNumber>;
610
+ hasMore: z.ZodBoolean;
611
+ }, "strip", z.ZodTypeAny, {
612
+ limit: number;
613
+ offset: number;
614
+ hasMore: boolean;
615
+ total?: number | undefined;
616
+ }, {
617
+ limit: number;
618
+ offset: number;
619
+ hasMore: boolean;
620
+ total?: number | undefined;
621
+ }>;
622
+ export const QueryEventsResponseSchema: z.ZodObject<{
623
+ events: z.ZodArray<z.ZodObject<{
624
+ streamId: z.ZodString;
625
+ streamPosition: z.ZodNumber;
626
+ globalPosition: z.ZodNumber;
627
+ eventId: z.ZodString;
458
628
  type: z.ZodString;
459
- data: z.ZodRecord<z.ZodString, z.ZodAny>;
460
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
461
- }, {
462
- metadata: z.ZodOptional<z.ZodObject<{
463
- eventId: z.ZodString;
464
- streamPosition: z.ZodNumber;
465
- streamName: z.ZodString;
466
- globalPosition: z.ZodNumber;
467
- }, "strip", z.ZodTypeAny, {
468
- eventId: string;
469
- streamPosition: number;
470
- streamName: string;
471
- globalPosition: number;
472
- }, {
473
- eventId: string;
474
- streamPosition: number;
475
- streamName: string;
476
- globalPosition: number;
477
- }>>;
478
- }>, "strip", z.ZodTypeAny, {
629
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
630
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
631
+ schemaVersion: z.ZodString;
632
+ transactionId: z.ZodString;
633
+ createdAt: z.ZodString;
634
+ }, "strip", z.ZodTypeAny, {
479
635
  type: string;
480
- data: Record<string, any>;
481
- metadata?: {
482
- eventId: string;
483
- streamPosition: number;
484
- streamName: string;
485
- globalPosition: number;
486
- } | undefined;
636
+ createdAt: string;
637
+ data: Record<string, unknown>;
638
+ eventId: string;
639
+ streamPosition: number;
640
+ globalPosition: number;
641
+ streamId: string;
642
+ schemaVersion: string;
643
+ transactionId: string;
644
+ metadata?: Record<string, unknown> | undefined;
487
645
  }, {
488
646
  type: string;
489
- data: Record<string, any>;
490
- metadata?: {
491
- eventId: string;
492
- streamPosition: number;
493
- streamName: string;
494
- globalPosition: number;
495
- } | undefined;
647
+ createdAt: string;
648
+ data: Record<string, unknown>;
649
+ eventId: string;
650
+ streamPosition: number;
651
+ globalPosition: number;
652
+ streamId: string;
653
+ schemaVersion: string;
654
+ transactionId: string;
655
+ metadata?: Record<string, unknown> | undefined;
496
656
  }>, "many">;
497
- currentStreamVersion: z.ZodNumber;
657
+ pagination: z.ZodObject<{
658
+ limit: z.ZodNumber;
659
+ offset: z.ZodNumber;
660
+ total: z.ZodOptional<z.ZodNumber>;
661
+ hasMore: z.ZodBoolean;
662
+ }, "strip", z.ZodTypeAny, {
663
+ limit: number;
664
+ offset: number;
665
+ hasMore: boolean;
666
+ total?: number | undefined;
667
+ }, {
668
+ limit: number;
669
+ offset: number;
670
+ hasMore: boolean;
671
+ total?: number | undefined;
672
+ }>;
498
673
  }, "strip", z.ZodTypeAny, {
499
674
  events: {
500
675
  type: string;
501
- data: Record<string, any>;
502
- metadata?: {
503
- eventId: string;
504
- streamPosition: number;
505
- streamName: string;
506
- globalPosition: number;
507
- } | undefined;
676
+ createdAt: string;
677
+ data: Record<string, unknown>;
678
+ eventId: string;
679
+ streamPosition: number;
680
+ globalPosition: number;
681
+ streamId: string;
682
+ schemaVersion: string;
683
+ transactionId: string;
684
+ metadata?: Record<string, unknown> | undefined;
508
685
  }[];
509
- currentStreamVersion: number;
686
+ pagination: {
687
+ limit: number;
688
+ offset: number;
689
+ hasMore: boolean;
690
+ total?: number | undefined;
691
+ };
510
692
  }, {
511
693
  events: {
512
694
  type: string;
513
- data: Record<string, any>;
514
- metadata?: {
515
- eventId: string;
516
- streamPosition: number;
517
- streamName: string;
518
- globalPosition: number;
519
- } | undefined;
695
+ createdAt: string;
696
+ data: Record<string, unknown>;
697
+ eventId: string;
698
+ streamPosition: number;
699
+ globalPosition: number;
700
+ streamId: string;
701
+ schemaVersion: string;
702
+ transactionId: string;
703
+ metadata?: Record<string, unknown> | undefined;
520
704
  }[];
521
- currentStreamVersion: number;
705
+ pagination: {
706
+ limit: number;
707
+ offset: number;
708
+ hasMore: boolean;
709
+ total?: number | undefined;
710
+ };
522
711
  }>;
523
- const routes: OpenAPIHono<{
712
+ export const StreamSchema: z.ZodObject<{
713
+ streamId: z.ZodString;
714
+ streamPosition: z.ZodNumber;
715
+ streamType: z.ZodString;
716
+ streamMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
717
+ isArchived: z.ZodBoolean;
718
+ lastArchivedPosition: z.ZodNumber;
719
+ createdAt: z.ZodString;
720
+ updatedAt: z.ZodString;
721
+ }, "strip", z.ZodTypeAny, {
722
+ createdAt: string;
723
+ updatedAt: string;
724
+ streamPosition: number;
725
+ streamId: string;
726
+ streamType: string;
727
+ isArchived: boolean;
728
+ lastArchivedPosition: number;
729
+ streamMetadata?: Record<string, unknown> | undefined;
730
+ }, {
731
+ createdAt: string;
732
+ updatedAt: string;
733
+ streamPosition: number;
734
+ streamId: string;
735
+ streamType: string;
736
+ isArchived: boolean;
737
+ lastArchivedPosition: number;
738
+ streamMetadata?: Record<string, unknown> | undefined;
739
+ }>;
740
+ export const QueryStreamsResponseSchema: z.ZodObject<{
741
+ streams: z.ZodArray<z.ZodObject<{
742
+ streamId: z.ZodString;
743
+ streamPosition: z.ZodNumber;
744
+ streamType: z.ZodString;
745
+ streamMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
746
+ isArchived: z.ZodBoolean;
747
+ lastArchivedPosition: z.ZodNumber;
748
+ createdAt: z.ZodString;
749
+ updatedAt: z.ZodString;
750
+ }, "strip", z.ZodTypeAny, {
751
+ createdAt: string;
752
+ updatedAt: string;
753
+ streamPosition: number;
754
+ streamId: string;
755
+ streamType: string;
756
+ isArchived: boolean;
757
+ lastArchivedPosition: number;
758
+ streamMetadata?: Record<string, unknown> | undefined;
759
+ }, {
760
+ createdAt: string;
761
+ updatedAt: string;
762
+ streamPosition: number;
763
+ streamId: string;
764
+ streamType: string;
765
+ isArchived: boolean;
766
+ lastArchivedPosition: number;
767
+ streamMetadata?: Record<string, unknown> | undefined;
768
+ }>, "many">;
769
+ pagination: z.ZodObject<{
770
+ limit: z.ZodNumber;
771
+ offset: z.ZodNumber;
772
+ total: z.ZodOptional<z.ZodNumber>;
773
+ hasMore: z.ZodBoolean;
774
+ }, "strip", z.ZodTypeAny, {
775
+ limit: number;
776
+ offset: number;
777
+ hasMore: boolean;
778
+ total?: number | undefined;
779
+ }, {
780
+ limit: number;
781
+ offset: number;
782
+ hasMore: boolean;
783
+ total?: number | undefined;
784
+ }>;
785
+ }, "strip", z.ZodTypeAny, {
786
+ pagination: {
787
+ limit: number;
788
+ offset: number;
789
+ hasMore: boolean;
790
+ total?: number | undefined;
791
+ };
792
+ streams: {
793
+ createdAt: string;
794
+ updatedAt: string;
795
+ streamPosition: number;
796
+ streamId: string;
797
+ streamType: string;
798
+ isArchived: boolean;
799
+ lastArchivedPosition: number;
800
+ streamMetadata?: Record<string, unknown> | undefined;
801
+ }[];
802
+ }, {
803
+ pagination: {
804
+ limit: number;
805
+ offset: number;
806
+ hasMore: boolean;
807
+ total?: number | undefined;
808
+ };
809
+ streams: {
810
+ createdAt: string;
811
+ updatedAt: string;
812
+ streamPosition: number;
813
+ streamId: string;
814
+ streamType: string;
815
+ isArchived: boolean;
816
+ lastArchivedPosition: number;
817
+ streamMetadata?: Record<string, unknown> | undefined;
818
+ }[];
819
+ }>;
820
+ export type QueryEventsParams = z.infer<typeof QueryEventsParamsSchema>;
821
+ export type QueryStreamsParams = z.infer<typeof QueryStreamsParamsSchema>;
822
+ export type QueryEventsResponse = {
823
+ events: z.infer<typeof EventSchema>[];
824
+ pagination: z.infer<typeof PaginationSchema>;
825
+ };
826
+ export type QueryStreamsResponse = z.infer<typeof QueryStreamsResponseSchema>;
827
+ export type Stream = z.infer<typeof StreamSchema>;
828
+ export type ReadEvent = z.infer<typeof EventSchema>;
829
+ export const routes: OpenAPIHono<{
524
830
  Bindings: Env;
525
831
  }, {}, "/">;
832
+ export { };
526
833
  }
527
834
 
528
835
  declare namespace EventBusAPI {
@@ -1322,19 +1629,18 @@ type Event<EventType extends string = string, EventData extends DefaultRecord =
1322
1629
  type EventTypeOf<T extends Event> = T['type'];
1323
1630
  type EventDataOf<T extends Event> = T['data'];
1324
1631
  type EventMetaDataOf<T extends Event> = T['metadata'];
1325
- type CreateEventType<EventType extends string, EventData extends DefaultRecord, EventMetaData extends DefaultRecord | undefined> = Readonly<{
1326
- type: EventType;
1327
- data: EventData;
1328
- metadata?: EventMetaData;
1329
- }>;
1330
- type ReadEvent<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> & ReadEventMetadata = EventMetaDataOf<EventType> & ReadEventMetadata> = CreateEventType<EventTypeOf<EventType>, EventDataOf<EventType>, EventMetaDataType> & EventType & {
1331
- metadata: EventMetaDataType;
1332
- };
1333
- type ReadEventMetadata = Readonly<{
1334
- eventId: string;
1632
+ type ReadEvent<EventType extends Event = Event, EventMetaDataType extends EventMetaDataOf<EventType> = EventMetaDataOf<EventType>> = {
1633
+ type: EventTypeOf<EventType>;
1634
+ data: EventDataOf<EventType>;
1635
+ metadata?: EventMetaDataType;
1636
+ streamId: string;
1335
1637
  streamPosition: number;
1336
- streamName: string;
1337
- }>;
1638
+ globalPosition: number;
1639
+ eventId: string;
1640
+ schemaVersion: string;
1641
+ transactionId: string;
1642
+ createdAt: string;
1643
+ };
1338
1644
  type ExpectedStreamVersion<VersionType = DefaultStreamVersionType> = ExpectedStreamVersionWithValue<VersionType> | ExpectedStreamVersionGeneral;
1339
1645
  type ExpectedStreamVersionWithValue<VersionType = DefaultStreamVersionType> = Flavour<VersionType, 'StreamVersion'>;
1340
1646
  type ExpectedStreamVersionGeneral = Flavour<'STREAM_EXISTS' | 'STREAM_DOES_NOT_EXIST' | 'NO_CONCURRENCY_CHECK', 'StreamVersion'>;
@@ -1355,6 +1661,78 @@ type AppendToStreamOptions<StreamVersion = DefaultStreamVersionType> = {
1355
1661
  expectedStreamVersion?: ExpectedStreamVersion<StreamVersion>;
1356
1662
  };
1357
1663
 
1664
+ /**
1665
+ * Query parameters for filtering events
1666
+ */
1667
+ interface EventsQueryParams {
1668
+ streamId?: string;
1669
+ type?: string | string[];
1670
+ eventId?: string;
1671
+ transactionId?: string;
1672
+ fromPosition?: number;
1673
+ toPosition?: number;
1674
+ fromDate?: string;
1675
+ toDate?: string;
1676
+ phase?: number;
1677
+ includeArchived?: boolean;
1678
+ limit?: number;
1679
+ offset?: number;
1680
+ sortBy?: 'globalPosition' | 'createdAt' | 'streamPosition';
1681
+ sortDirection?: 'asc' | 'desc';
1682
+ includeCount?: boolean;
1683
+ }
1684
+ /**
1685
+ * Query parameters for filtering streams
1686
+ */
1687
+ interface StreamsQueryParams {
1688
+ streamId?: string;
1689
+ streamType?: string | string[];
1690
+ streamIdPattern?: string;
1691
+ minPosition?: number;
1692
+ maxPosition?: number;
1693
+ fromDate?: string;
1694
+ toDate?: string;
1695
+ includeArchived?: boolean;
1696
+ includeMetadata?: boolean;
1697
+ limit?: number;
1698
+ offset?: number;
1699
+ sortBy?: 'streamPosition' | 'createdAt' | 'updatedAt' | 'streamId';
1700
+ sortDirection?: 'asc' | 'desc';
1701
+ includeCount?: boolean;
1702
+ }
1703
+ /**
1704
+ * Result of a query events operation
1705
+ */
1706
+ type QueryEventsResult = {
1707
+ events: ReadEvent[];
1708
+ pagination: {
1709
+ limit: number;
1710
+ offset: number;
1711
+ total?: number;
1712
+ hasMore: boolean;
1713
+ };
1714
+ };
1715
+ /**
1716
+ * Result of a query streams operation
1717
+ */
1718
+ type QueryStreamsResult = {
1719
+ streams: Array<{
1720
+ streamId: string;
1721
+ streamPosition: number;
1722
+ streamType: string;
1723
+ streamMetadata: Record<string, unknown>;
1724
+ isArchived: boolean;
1725
+ lastArchivedPosition: number;
1726
+ createdAt: string;
1727
+ updatedAt: string;
1728
+ }>;
1729
+ pagination: {
1730
+ limit: number;
1731
+ offset: number;
1732
+ total?: number;
1733
+ hasMore: boolean;
1734
+ };
1735
+ };
1358
1736
  /**
1359
1737
  * A durable object implementation of an event store.
1360
1738
  * Handles event persistence, archiving, and event bus integration.
@@ -1418,6 +1796,25 @@ declare class EventStoreDurableObject extends DurableObject<Env> {
1418
1796
  * @returns The configured id of the event store
1419
1797
  */
1420
1798
  getEventStoreId(): string;
1799
+ /**
1800
+ * Queries events based on filtering parameters
1801
+ * @param params - Query parameters for filtering events
1802
+ * @returns Promise resolving to filtered events and optional count
1803
+ */
1804
+ queryEvents(params?: EventsQueryParams): Promise<QueryEventsResult>;
1805
+ /**
1806
+ * Queries streams based on filtering parameters
1807
+ * @param params - Query parameters for filtering streams
1808
+ * @returns Promise resolving to filtered streams and optional count
1809
+ */
1810
+ queryStreams(params?: StreamsQueryParams): Promise<QueryStreamsResult>;
1811
+ /**
1812
+ * Parses stream metadata from string to object
1813
+ * @param metadataStr - The metadata string to parse
1814
+ * @returns Parsed metadata object
1815
+ * @private
1816
+ */
1817
+ private parseStreamMetadata;
1421
1818
  /**
1422
1819
  * Maps a database row to an event object
1423
1820
  * @param row - The database row containing event data
@@ -1596,10 +1993,10 @@ declare class EventStoreManagerDurableObject extends DurableObject<Env> {
1596
1993
  retentionPeriodDays?: number;
1597
1994
  maxStreamSizeBytes?: number;
1598
1995
  }): Promise<{
1599
- eventStoreID: string;
1996
+ eventStoreId: string;
1600
1997
  eventStoreName: string;
1601
- eventStoreDurableObjectID: string;
1602
- eventBusDurableObjectID: string;
1998
+ eventStoreDurableObjectId: string;
1999
+ eventBusDurableObjectId: string;
1603
2000
  description?: string;
1604
2001
  settings?: {
1605
2002
  retentionPeriodDays?: number;
@@ -1610,10 +2007,10 @@ declare class EventStoreManagerDurableObject extends DurableObject<Env> {
1610
2007
  getEventStoreInfo(eventStoreId: string, options?: {
1611
2008
  includeDeleted?: boolean;
1612
2009
  }): {
1613
- eventStoreID: string;
2010
+ eventStoreId: string;
1614
2011
  eventStoreName: string;
1615
- eventStoreDurableObjectID: string;
1616
- eventBusDurableObjectID: string;
2012
+ eventStoreDurableObjectId: string;
2013
+ eventBusDurableObjectId: string;
1617
2014
  description?: string;
1618
2015
  settings?: {
1619
2016
  retentionPeriodDays?: number;
@@ -1627,10 +2024,10 @@ declare class EventStoreManagerDurableObject extends DurableObject<Env> {
1627
2024
  namePrefix?: string;
1628
2025
  }): Promise<{
1629
2026
  eventStores: Array<{
1630
- eventStoreID: string;
2027
+ eventStoreId: string;
1631
2028
  eventStoreName: string;
1632
- eventStoreDurableObjectID: string;
1633
- eventBusDurableObjectID: string;
2029
+ eventStoreDurableObjectId: string;
2030
+ eventBusDurableObjectId: string;
1634
2031
  description?: string;
1635
2032
  settings?: {
1636
2033
  retentionPeriodDays?: number;
@@ -1641,7 +2038,7 @@ declare class EventStoreManagerDurableObject extends DurableObject<Env> {
1641
2038
  totalCount: number;
1642
2039
  }>;
1643
2040
  getStreamStats(eventStoreId: string): Promise<{
1644
- count: number;
2041
+ totalStreams: number;
1645
2042
  totalEvents: number;
1646
2043
  }>;
1647
2044
  getDatabaseSizes(eventStoreId: string): Promise<{
@@ -1664,6 +2061,7 @@ declare class EventStoreManagerDurableObject extends DurableObject<Env> {
1664
2061
  updateEventStoreStats(eventStoreName: string, stats: {
1665
2062
  databaseSizeMB: number;
1666
2063
  totalEvents: number;
2064
+ totalStreams: number;
1667
2065
  archivedEvents: number;
1668
2066
  lastEventTimestamp?: string;
1669
2067
  }): Promise<void>;
@@ -1688,10 +2086,10 @@ declare class EventStoreManagerDurableObject extends DurableObject<Env> {
1688
2086
  maxStreamSizeBytes?: number;
1689
2087
  };
1690
2088
  }): Promise<{
1691
- eventStoreID: string;
2089
+ eventStoreId: string;
1692
2090
  eventStoreName: string;
1693
- eventStoreDurableObjectID: string;
1694
- eventBusDurableObjectID: string;
2091
+ eventStoreDurableObjectId: string;
2092
+ eventBusDurableObjectId: string;
1695
2093
  description?: string;
1696
2094
  settings?: {
1697
2095
  retentionPeriodDays?: number;
@@ -1734,12 +2132,13 @@ declare class WebSocketManagerDurableObject extends DurableObject<Env> {
1734
2132
  listConnections(options?: ConnectionListOptions): Promise<ConnectionListResult>;
1735
2133
  closeClientConnections(clientId: string, reason?: string): Promise<CloseConnectionResult>;
1736
2134
  private matchEventWithFilter;
1737
- deliverEventToClient(clientId: string, event: EventMessage): Promise<void>;
1738
2135
  broadcastEvent(event: EventMessage): Promise<void>;
1739
2136
  webSocketClose(ws: WebSocket, _code: number, reason: string, _wasClean: boolean): Promise<void>;
1740
2137
  }
1741
2138
 
1742
- declare const routes: hono_hono_base.HonoBase<hono.Env, hono_types.MergeSchemaPath<{}, "/api"> & {
2139
+ declare const routes: hono_hono_base.HonoBase<{
2140
+ Bindings: Env;
2141
+ }, hono_types.MergeSchemaPath<{}, "/api"> & {
1743
2142
  docs: {
1744
2143
  $get: {
1745
2144
  input: {};