@delta-base/core 1.3.6 → 1.5.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
@@ -81,8 +81,44 @@ declare namespace EventBusAPI {
81
81
  earliest: "earliest";
82
82
  }>>>;
83
83
  }, z.core.$strip>;
84
+ const ReplayRequestSchema: z.ZodObject<{
85
+ fromGlobalPosition: z.ZodOptional<z.ZodNumber>;
86
+ fromCreatedAt: z.ZodOptional<z.ZodString>;
87
+ toGlobalPosition: z.ZodOptional<z.ZodNumber>;
88
+ toCreatedAt: z.ZodOptional<z.ZodString>;
89
+ eventTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
90
+ }, z.core.$strip>;
91
+ const ReplayStatusResponseSchema: z.ZodObject<{
92
+ inProgress: z.ZodBoolean;
93
+ startPosition: z.ZodNullable<z.ZodNumber>;
94
+ targetPosition: z.ZodNullable<z.ZodNumber>;
95
+ currentPosition: z.ZodNumber;
96
+ processedCount: z.ZodNumber;
97
+ estimatedEvents: z.ZodNumber;
98
+ startedAt: z.ZodNullable<z.ZodString>;
99
+ }, z.core.$strip>;
100
+ const UpdateSubscriptionRequestSchema: z.ZodObject<{
101
+ eventFilter: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodString, z.ZodString, z.ZodString]>, z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodString, z.ZodString, z.ZodString]>>]>>;
102
+ subscriberConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
103
+ retryPolicy: z.ZodOptional<z.ZodObject<{
104
+ strategy: z.ZodEnum<{
105
+ fixed: "fixed";
106
+ exponential: "exponential";
107
+ linear: "linear";
108
+ }>;
109
+ maxAttempts: z.ZodNumber;
110
+ initialDelayMs: z.ZodNumber;
111
+ maxDelayMs: z.ZodNumber;
112
+ multiplier: z.ZodOptional<z.ZodNumber>;
113
+ jitterPercent: z.ZodOptional<z.ZodNumber>;
114
+ }, z.core.$strip>>;
115
+ status: z.ZodOptional<z.ZodEnum<{
116
+ ACTIVE: "ACTIVE";
117
+ SUSPENDED: "SUSPENDED";
118
+ }>>;
119
+ }, z.core.$strip>;
84
120
  const SubscriptionResponseSchema: z.ZodObject<{
85
- subscriptionId: z.ZodString;
121
+ subscriberId: z.ZodString;
86
122
  status: z.ZodEnum<{
87
123
  ACTIVE: "ACTIVE";
88
124
  SUSPENDED: "SUSPENDED";
@@ -98,7 +134,6 @@ declare namespace EventBusAPI {
98
134
  }, z.core.$strip>>;
99
135
  eventStoreName: z.ZodString;
100
136
  eventFilter: z.ZodString;
101
- subscriberId: z.ZodString;
102
137
  subscriberType: z.ZodEnum<{
103
138
  durable_object: "durable_object";
104
139
  webhook: "webhook";
@@ -106,6 +141,7 @@ declare namespace EventBusAPI {
106
141
  cloudflare_workflow: "cloudflare_workflow";
107
142
  websocket: "websocket";
108
143
  }>;
144
+ subscriberConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
109
145
  createdAt: z.ZodString;
110
146
  updatedAt: z.ZodString;
111
147
  lastProcessedEventGlobalPosition: z.ZodOptional<z.ZodNumber>;
@@ -114,7 +150,7 @@ declare namespace EventBusAPI {
114
150
  }, z.core.$strip>;
115
151
  const SubscriptionListResponseSchema: z.ZodObject<{
116
152
  subscriptions: z.ZodArray<z.ZodObject<{
117
- subscriptionId: z.ZodString;
153
+ subscriberId: z.ZodString;
118
154
  status: z.ZodEnum<{
119
155
  ACTIVE: "ACTIVE";
120
156
  SUSPENDED: "SUSPENDED";
@@ -130,7 +166,6 @@ declare namespace EventBusAPI {
130
166
  }, z.core.$strip>>;
131
167
  eventStoreName: z.ZodString;
132
168
  eventFilter: z.ZodString;
133
- subscriberId: z.ZodString;
134
169
  subscriberType: z.ZodEnum<{
135
170
  durable_object: "durable_object";
136
171
  webhook: "webhook";
@@ -138,6 +173,7 @@ declare namespace EventBusAPI {
138
173
  cloudflare_workflow: "cloudflare_workflow";
139
174
  websocket: "websocket";
140
175
  }>;
176
+ subscriberConfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
141
177
  createdAt: z.ZodString;
142
178
  updatedAt: z.ZodString;
143
179
  lastProcessedEventGlobalPosition: z.ZodOptional<z.ZodNumber>;
@@ -222,11 +258,10 @@ declare namespace EventBusAPI {
222
258
  };
223
259
  };
224
260
  output: {
225
- subscriptionId: string;
261
+ subscriberId: string;
226
262
  status: "ACTIVE" | "SUSPENDED" | "ERROR" | "INITIALIZING" | "DELETED";
227
263
  eventStoreName: string;
228
264
  eventFilter: string;
229
- subscriberId: string;
230
265
  subscriberType: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket";
231
266
  createdAt: string;
232
267
  updatedAt: string;
@@ -236,6 +271,9 @@ declare namespace EventBusAPI {
236
271
  retryCount?: number | undefined;
237
272
  nextRetryAt?: string | undefined;
238
273
  } | undefined;
274
+ subscriberConfig?: {
275
+ [x: string]: any;
276
+ } | undefined;
239
277
  lastProcessedEventGlobalPosition?: number | undefined;
240
278
  isExistingSubscription?: boolean | undefined;
241
279
  message?: string | undefined;
@@ -533,12 +571,12 @@ declare namespace EventBusAPI {
533
571
  };
534
572
  };
535
573
  } & {
536
- "/event-stores/:eventStoreName/subscriptions/:subscriptionId": {
574
+ "/event-stores/:eventStoreName/subscriptions/:subscriberId": {
537
575
  $delete: {
538
576
  input: {
539
577
  param: {
540
578
  eventStoreName: string;
541
- subscriptionId: string;
579
+ subscriberId: string;
542
580
  };
543
581
  };
544
582
  output: {
@@ -554,7 +592,7 @@ declare namespace EventBusAPI {
554
592
  input: {
555
593
  param: {
556
594
  eventStoreName: string;
557
- subscriptionId: string;
595
+ subscriberId: string;
558
596
  };
559
597
  };
560
598
  output: {
@@ -570,7 +608,7 @@ declare namespace EventBusAPI {
570
608
  input: {
571
609
  param: {
572
610
  eventStoreName: string;
573
- subscriptionId: string;
611
+ subscriberId: string;
574
612
  };
575
613
  };
576
614
  output: {
@@ -586,7 +624,7 @@ declare namespace EventBusAPI {
586
624
  input: {
587
625
  param: {
588
626
  eventStoreName: string;
589
- subscriptionId: string;
627
+ subscriberId: string;
590
628
  };
591
629
  };
592
630
  output: {
@@ -680,11 +718,10 @@ declare namespace EventBusAPI {
680
718
  };
681
719
  output: {
682
720
  subscriptions: {
683
- subscriptionId: string;
721
+ subscriberId: string;
684
722
  status: "ACTIVE" | "SUSPENDED" | "ERROR" | "INITIALIZING" | "DELETED";
685
723
  eventStoreName: string;
686
724
  eventFilter: string;
687
- subscriberId: string;
688
725
  subscriberType: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket";
689
726
  createdAt: string;
690
727
  updatedAt: string;
@@ -694,6 +731,9 @@ declare namespace EventBusAPI {
694
731
  retryCount?: number | undefined;
695
732
  nextRetryAt?: string | undefined;
696
733
  } | undefined;
734
+ subscriberConfig?: {
735
+ [x: string]: any;
736
+ } | undefined;
697
737
  lastProcessedEventGlobalPosition?: number | undefined;
698
738
  isExistingSubscription?: boolean | undefined;
699
739
  message?: string | undefined;
@@ -705,20 +745,19 @@ declare namespace EventBusAPI {
705
745
  };
706
746
  };
707
747
  } & {
708
- "/event-stores/:eventStoreName/subscriptions/:subscriptionId": {
748
+ "/event-stores/:eventStoreName/subscriptions/:subscriberId": {
709
749
  $get: {
710
750
  input: {
711
751
  param: {
712
752
  eventStoreName: string;
713
- subscriptionId: string;
753
+ subscriberId: string;
714
754
  };
715
755
  };
716
756
  output: {
717
- subscriptionId: string;
757
+ subscriberId: string;
718
758
  status: "ACTIVE" | "SUSPENDED" | "ERROR" | "INITIALIZING" | "DELETED";
719
759
  eventStoreName: string;
720
760
  eventFilter: string;
721
- subscriberId: string;
722
761
  subscriberType: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket";
723
762
  createdAt: string;
724
763
  updatedAt: string;
@@ -728,6 +767,9 @@ declare namespace EventBusAPI {
728
767
  retryCount?: number | undefined;
729
768
  nextRetryAt?: string | undefined;
730
769
  } | undefined;
770
+ subscriberConfig?: {
771
+ [x: string]: any;
772
+ } | undefined;
731
773
  lastProcessedEventGlobalPosition?: number | undefined;
732
774
  isExistingSubscription?: boolean | undefined;
733
775
  message?: string | undefined;
@@ -738,7 +780,7 @@ declare namespace EventBusAPI {
738
780
  input: {
739
781
  param: {
740
782
  eventStoreName: string;
741
- subscriptionId: string;
783
+ subscriberId: string;
742
784
  };
743
785
  };
744
786
  output: {
@@ -754,7 +796,7 @@ declare namespace EventBusAPI {
754
796
  input: {
755
797
  param: {
756
798
  eventStoreName: string;
757
- subscriptionId: string;
799
+ subscriberId: string;
758
800
  };
759
801
  };
760
802
  output: {
@@ -770,7 +812,7 @@ declare namespace EventBusAPI {
770
812
  input: {
771
813
  param: {
772
814
  eventStoreName: string;
773
- subscriptionId: string;
815
+ subscriberId: string;
774
816
  };
775
817
  };
776
818
  output: {
@@ -784,238 +826,705 @@ declare namespace EventBusAPI {
784
826
  status: 500;
785
827
  };
786
828
  };
787
- }, "/">;
788
- }
789
-
790
- declare namespace EventStoreAPI {
791
- const EventSchema: z.ZodObject<{
792
- streamId: z.ZodString;
793
- streamPosition: z.ZodNumber;
794
- globalPosition: z.ZodNumber;
795
- eventId: z.ZodString;
796
- type: z.ZodString;
797
- data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
798
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
799
- schemaVersion: z.ZodString;
800
- transactionId: z.ZodString;
801
- createdAt: z.ZodString;
802
- }, z.core.$strip>;
803
- export const AppendEventsRequestSchema: z.ZodObject<{
804
- events: z.ZodArray<z.ZodObject<{
805
- type: z.ZodString;
806
- data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
807
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
808
- }, z.core.$strip>>;
809
- options: z.ZodOptional<z.ZodObject<{
810
- expectedStreamVersion: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
811
- }, z.core.$strip>>;
812
- }, z.core.$strip>;
813
- export const AppendEventsResponseSchema: z.ZodObject<{
814
- success: z.ZodBoolean;
815
- nextExpectedStreamVersion: z.ZodNumber;
816
- eventsWritten: z.ZodNumber;
817
- }, z.core.$strip>;
818
- export const VersionConflictErrorSchema: z.ZodObject<{
819
- error: z.ZodLiteral<"Version conflict">;
820
- details: z.ZodString;
821
- currentVersion: z.ZodNumber;
822
- expectedVersion: z.ZodNumber;
823
- }, z.core.$strip>;
824
- export const ValidationErrorSchema: z.ZodObject<{
825
- error: z.ZodLiteral<"Invalid request body">;
826
- details: z.ZodArray<z.ZodObject<{
827
- code: z.ZodString;
828
- message: z.ZodString;
829
- path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
830
- }, z.core.$strip>>;
831
- }, z.core.$strip>;
832
- export const OrganizationNotFoundErrorSchema: z.ZodObject<{
833
- error: z.ZodLiteral<"UNAUTHORIZED">;
834
- message: z.ZodLiteral<"Unauthorized: Organization ID not found in authentication context">;
835
- }, z.core.$strip>;
836
- export const AppendEventsErrorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
837
- error: z.ZodLiteral<"Version conflict">;
838
- details: z.ZodString;
839
- currentVersion: z.ZodNumber;
840
- expectedVersion: z.ZodNumber;
841
- }, z.core.$strip>, z.ZodObject<{
842
- error: z.ZodLiteral<"Invalid request body">;
843
- details: z.ZodArray<z.ZodObject<{
844
- code: z.ZodString;
845
- message: z.ZodString;
846
- path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
847
- }, z.core.$strip>>;
848
- }, z.core.$strip>], "error">;
849
- export const ReadStreamOptionsSchema: z.ZodObject<{
850
- expectedStreamVersion: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
851
- }, z.core.$strip>;
852
- export const ReadStreamResponseSchema: z.ZodObject<{
853
- events: z.ZodArray<z.ZodObject<{
854
- streamId: z.ZodString;
855
- streamPosition: z.ZodNumber;
856
- globalPosition: z.ZodNumber;
857
- eventId: z.ZodString;
858
- type: z.ZodString;
859
- data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
860
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
861
- schemaVersion: z.ZodString;
862
- transactionId: z.ZodString;
863
- createdAt: z.ZodString;
864
- }, z.core.$strip>>;
865
- currentStreamVersion: z.ZodNumber;
866
- }, z.core.$strip>;
867
- export const QueryEventsParamsSchema: z.ZodObject<{
868
- streamId: z.ZodOptional<z.ZodString>;
869
- type: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
870
- eventId: z.ZodOptional<z.ZodString>;
871
- transactionId: z.ZodOptional<z.ZodString>;
872
- fromPosition: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
873
- toPosition: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
874
- fromDate: z.ZodOptional<z.ZodISODateTime>;
875
- toDate: z.ZodOptional<z.ZodString>;
876
- phase: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
877
- includeArchived: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<boolean, string>>, z.ZodBoolean>>;
878
- limit: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
879
- offset: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
880
- sortBy: z.ZodOptional<z.ZodEnum<{
881
- streamPosition: "streamPosition";
882
- globalPosition: "globalPosition";
883
- createdAt: "createdAt";
884
- }>>;
885
- sortDirection: z.ZodOptional<z.ZodEnum<{
886
- asc: "asc";
887
- desc: "desc";
888
- }>>;
889
- includeCount: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<boolean, string>>, z.ZodBoolean>>;
890
- }, z.core.$strip>;
891
- export const QueryStreamsParamsSchema: z.ZodObject<{
892
- streamId: z.ZodOptional<z.ZodString>;
893
- streamType: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
894
- streamIdPattern: z.ZodOptional<z.ZodString>;
895
- minPosition: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
896
- maxPosition: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
897
- fromDate: z.ZodOptional<z.ZodISODateTime>;
898
- toDate: z.ZodOptional<z.ZodISODateTime>;
899
- includeArchived: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<boolean, string>>, z.ZodBoolean>>;
900
- includeMetadata: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<boolean, string>>, z.ZodBoolean>>;
901
- limit: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
902
- offset: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
903
- sortBy: z.ZodOptional<z.ZodEnum<{
904
- streamId: "streamId";
905
- streamPosition: "streamPosition";
906
- createdAt: "createdAt";
907
- updatedAt: "updatedAt";
908
- }>>;
909
- sortDirection: z.ZodOptional<z.ZodEnum<{
910
- asc: "asc";
911
- desc: "desc";
912
- }>>;
913
- includeCount: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<boolean, string>>, z.ZodBoolean>>;
914
- }, z.core.$strip>;
915
- const PaginationSchema: z.ZodObject<{
916
- limit: z.ZodNumber;
917
- offset: z.ZodNumber;
918
- total: z.ZodOptional<z.ZodNumber>;
919
- hasMore: z.ZodBoolean;
920
- }, z.core.$strip>;
921
- export const QueryEventsResponseSchema: z.ZodObject<{
922
- events: z.ZodArray<z.ZodObject<{
923
- streamId: z.ZodString;
924
- streamPosition: z.ZodNumber;
925
- globalPosition: z.ZodNumber;
926
- eventId: z.ZodString;
927
- type: z.ZodString;
928
- data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
929
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
930
- schemaVersion: z.ZodString;
931
- transactionId: z.ZodString;
932
- createdAt: z.ZodString;
933
- }, z.core.$strip>>;
934
- pagination: z.ZodObject<{
935
- limit: z.ZodNumber;
936
- offset: z.ZodNumber;
937
- total: z.ZodOptional<z.ZodNumber>;
938
- hasMore: z.ZodBoolean;
939
- }, z.core.$strip>;
940
- }, z.core.$strip>;
941
- export const StreamSchema: z.ZodObject<{
942
- streamId: z.ZodString;
943
- streamPosition: z.ZodNumber;
944
- streamType: z.ZodString;
945
- streamMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
946
- isArchived: z.ZodBoolean;
947
- lastArchivedPosition: z.ZodNumber;
948
- createdAt: z.ZodString;
949
- updatedAt: z.ZodString;
950
- }, z.core.$strip>;
951
- export const QueryStreamsResponseSchema: z.ZodObject<{
952
- streams: z.ZodArray<z.ZodObject<{
953
- streamId: z.ZodString;
954
- streamPosition: z.ZodNumber;
955
- streamType: z.ZodString;
956
- streamMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
957
- isArchived: z.ZodBoolean;
958
- lastArchivedPosition: z.ZodNumber;
959
- createdAt: z.ZodString;
960
- updatedAt: z.ZodString;
961
- }, z.core.$strip>>;
962
- pagination: z.ZodObject<{
963
- limit: z.ZodNumber;
964
- offset: z.ZodNumber;
965
- total: z.ZodOptional<z.ZodNumber>;
966
- hasMore: z.ZodBoolean;
967
- }, z.core.$strip>;
968
- }, z.core.$strip>;
969
- export type QueryEventsParams = z.infer<typeof QueryEventsParamsSchema>;
970
- export type QueryStreamsParams = z.infer<typeof QueryStreamsParamsSchema>;
971
- export type QueryEventsResponse = {
972
- events: z.infer<typeof EventSchema>[];
973
- pagination: z.infer<typeof PaginationSchema>;
974
- };
975
- export type QueryStreamsResponse = z.infer<typeof QueryStreamsResponseSchema>;
976
- export type Stream = z.infer<typeof StreamSchema>;
977
- export type ReadEvent = z.infer<typeof EventSchema>;
978
- export const routes: OpenAPIHono<{
979
- Bindings: Env;
980
- Variables: {
981
- orgId: string;
982
- };
983
- }, {
984
- "/event-stores/:eventStoreName/streams/:streamId": {
985
- $post: {
829
+ } & {
830
+ "/event-stores/:eventStoreName/subscriptions/:subscriberId": {
831
+ $patch: {
986
832
  input: {
987
833
  param: {
988
834
  eventStoreName: string;
989
- streamId: string;
835
+ subscriberId: string;
990
836
  };
991
837
  } & {
992
838
  json: {
993
- events: {
994
- type: string;
995
- data: Record<string, unknown>;
996
- metadata?: Record<string, unknown> | undefined;
997
- }[];
998
- options?: {
999
- expectedStreamVersion?: string | number | undefined;
839
+ eventFilter?: string | string[] | undefined;
840
+ subscriberConfig?: Record<string, unknown> | undefined;
841
+ retryPolicy?: {
842
+ strategy: "fixed" | "exponential" | "linear";
843
+ maxAttempts: number;
844
+ initialDelayMs: number;
845
+ maxDelayMs: number;
846
+ multiplier?: number | undefined;
847
+ jitterPercent?: number | undefined;
1000
848
  } | undefined;
849
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
1001
850
  };
1002
851
  };
1003
852
  output: {
1004
- success: boolean;
1005
- nextExpectedStreamVersion: number;
1006
- eventsWritten: number;
1007
- };
1008
- outputFormat: "json";
1009
- status: 200;
1010
- } | {
1011
- input: {
1012
- param: {
1013
- eventStoreName: string;
1014
- streamId: string;
1015
- };
1016
- } & {
1017
- json: {
1018
- events: {
853
+ subscriberId: string;
854
+ status: "ACTIVE" | "SUSPENDED" | "ERROR" | "INITIALIZING" | "DELETED";
855
+ eventStoreName: string;
856
+ eventFilter: string;
857
+ subscriberType: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket";
858
+ createdAt: string;
859
+ updatedAt: string;
860
+ statusDetails?: {
861
+ lastError?: string | undefined;
862
+ lastErrorAt?: string | undefined;
863
+ retryCount?: number | undefined;
864
+ nextRetryAt?: string | undefined;
865
+ } | undefined;
866
+ subscriberConfig?: {
867
+ [x: string]: any;
868
+ } | undefined;
869
+ lastProcessedEventGlobalPosition?: number | undefined;
870
+ isExistingSubscription?: boolean | undefined;
871
+ message?: string | undefined;
872
+ };
873
+ outputFormat: "json";
874
+ status: 200;
875
+ } | {
876
+ input: {
877
+ param: {
878
+ eventStoreName: string;
879
+ subscriberId: string;
880
+ };
881
+ } & {
882
+ json: {
883
+ eventFilter?: string | string[] | undefined;
884
+ subscriberConfig?: Record<string, unknown> | undefined;
885
+ retryPolicy?: {
886
+ strategy: "fixed" | "exponential" | "linear";
887
+ maxAttempts: number;
888
+ initialDelayMs: number;
889
+ maxDelayMs: number;
890
+ multiplier?: number | undefined;
891
+ jitterPercent?: number | undefined;
892
+ } | undefined;
893
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
894
+ };
895
+ };
896
+ output: {
897
+ error: string;
898
+ message: string;
899
+ details?: {
900
+ [x: string]: any;
901
+ } | undefined;
902
+ };
903
+ outputFormat: "json";
904
+ status: 400;
905
+ } | {
906
+ input: {
907
+ param: {
908
+ eventStoreName: string;
909
+ subscriberId: string;
910
+ };
911
+ } & {
912
+ json: {
913
+ eventFilter?: string | string[] | undefined;
914
+ subscriberConfig?: Record<string, unknown> | undefined;
915
+ retryPolicy?: {
916
+ strategy: "fixed" | "exponential" | "linear";
917
+ maxAttempts: number;
918
+ initialDelayMs: number;
919
+ maxDelayMs: number;
920
+ multiplier?: number | undefined;
921
+ jitterPercent?: number | undefined;
922
+ } | undefined;
923
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
924
+ };
925
+ };
926
+ output: {
927
+ error: string;
928
+ message: string;
929
+ details?: {
930
+ [x: string]: any;
931
+ } | undefined;
932
+ };
933
+ outputFormat: "json";
934
+ status: 401;
935
+ } | {
936
+ input: {
937
+ param: {
938
+ eventStoreName: string;
939
+ subscriberId: string;
940
+ };
941
+ } & {
942
+ json: {
943
+ eventFilter?: string | string[] | undefined;
944
+ subscriberConfig?: Record<string, unknown> | undefined;
945
+ retryPolicy?: {
946
+ strategy: "fixed" | "exponential" | "linear";
947
+ maxAttempts: number;
948
+ initialDelayMs: number;
949
+ maxDelayMs: number;
950
+ multiplier?: number | undefined;
951
+ jitterPercent?: number | undefined;
952
+ } | undefined;
953
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
954
+ };
955
+ };
956
+ output: {
957
+ error: string;
958
+ message: string;
959
+ details?: {
960
+ [x: string]: any;
961
+ } | undefined;
962
+ };
963
+ outputFormat: "json";
964
+ status: 404;
965
+ } | {
966
+ input: {
967
+ param: {
968
+ eventStoreName: string;
969
+ subscriberId: string;
970
+ };
971
+ } & {
972
+ json: {
973
+ eventFilter?: string | string[] | undefined;
974
+ subscriberConfig?: Record<string, unknown> | undefined;
975
+ retryPolicy?: {
976
+ strategy: "fixed" | "exponential" | "linear";
977
+ maxAttempts: number;
978
+ initialDelayMs: number;
979
+ maxDelayMs: number;
980
+ multiplier?: number | undefined;
981
+ jitterPercent?: number | undefined;
982
+ } | undefined;
983
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
984
+ };
985
+ };
986
+ output: {
987
+ error: string;
988
+ message: string;
989
+ details?: {
990
+ [x: string]: any;
991
+ } | undefined;
992
+ };
993
+ outputFormat: "json";
994
+ status: 500;
995
+ } | {
996
+ input: {
997
+ param: {
998
+ eventStoreName: string;
999
+ subscriberId: string;
1000
+ };
1001
+ } & {
1002
+ json: {
1003
+ eventFilter?: string | string[] | undefined;
1004
+ subscriberConfig?: Record<string, unknown> | undefined;
1005
+ retryPolicy?: {
1006
+ strategy: "fixed" | "exponential" | "linear";
1007
+ maxAttempts: number;
1008
+ initialDelayMs: number;
1009
+ maxDelayMs: number;
1010
+ multiplier?: number | undefined;
1011
+ jitterPercent?: number | undefined;
1012
+ } | undefined;
1013
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
1014
+ };
1015
+ };
1016
+ output: {
1017
+ error: string;
1018
+ message: string;
1019
+ details?: {
1020
+ [x: string]: any;
1021
+ } | undefined;
1022
+ };
1023
+ outputFormat: "json";
1024
+ status: 409;
1025
+ };
1026
+ };
1027
+ } & {
1028
+ "/event-stores/:eventStoreName/subscriptions/:subscriberId/replay": {
1029
+ $post: {
1030
+ input: {
1031
+ param: {
1032
+ eventStoreName: string;
1033
+ subscriberId: string;
1034
+ };
1035
+ } & {
1036
+ json: {
1037
+ fromGlobalPosition?: number | undefined;
1038
+ fromCreatedAt?: string | undefined;
1039
+ toGlobalPosition?: number | undefined;
1040
+ toCreatedAt?: string | undefined;
1041
+ eventTypes?: string[] | undefined;
1042
+ };
1043
+ };
1044
+ output: {
1045
+ error: string;
1046
+ message: string;
1047
+ details?: {
1048
+ [x: string]: any;
1049
+ } | undefined;
1050
+ };
1051
+ outputFormat: "json";
1052
+ status: 400;
1053
+ } | {
1054
+ input: {
1055
+ param: {
1056
+ eventStoreName: string;
1057
+ subscriberId: string;
1058
+ };
1059
+ } & {
1060
+ json: {
1061
+ fromGlobalPosition?: number | undefined;
1062
+ fromCreatedAt?: string | undefined;
1063
+ toGlobalPosition?: number | undefined;
1064
+ toCreatedAt?: string | undefined;
1065
+ eventTypes?: string[] | undefined;
1066
+ };
1067
+ };
1068
+ output: {
1069
+ error: string;
1070
+ message: string;
1071
+ details?: {
1072
+ [x: string]: any;
1073
+ } | undefined;
1074
+ };
1075
+ outputFormat: "json";
1076
+ status: 401;
1077
+ } | {
1078
+ input: {
1079
+ param: {
1080
+ eventStoreName: string;
1081
+ subscriberId: string;
1082
+ };
1083
+ } & {
1084
+ json: {
1085
+ fromGlobalPosition?: number | undefined;
1086
+ fromCreatedAt?: string | undefined;
1087
+ toGlobalPosition?: number | undefined;
1088
+ toCreatedAt?: string | undefined;
1089
+ eventTypes?: string[] | undefined;
1090
+ };
1091
+ };
1092
+ output: {
1093
+ error: string;
1094
+ message: string;
1095
+ details?: {
1096
+ [x: string]: any;
1097
+ } | undefined;
1098
+ };
1099
+ outputFormat: "json";
1100
+ status: 404;
1101
+ } | {
1102
+ input: {
1103
+ param: {
1104
+ eventStoreName: string;
1105
+ subscriberId: string;
1106
+ };
1107
+ } & {
1108
+ json: {
1109
+ fromGlobalPosition?: number | undefined;
1110
+ fromCreatedAt?: string | undefined;
1111
+ toGlobalPosition?: number | undefined;
1112
+ toCreatedAt?: string | undefined;
1113
+ eventTypes?: string[] | undefined;
1114
+ };
1115
+ };
1116
+ output: {
1117
+ error: string;
1118
+ message: string;
1119
+ details?: {
1120
+ [x: string]: any;
1121
+ } | undefined;
1122
+ };
1123
+ outputFormat: "json";
1124
+ status: 500;
1125
+ } | {
1126
+ input: {
1127
+ param: {
1128
+ eventStoreName: string;
1129
+ subscriberId: string;
1130
+ };
1131
+ } & {
1132
+ json: {
1133
+ fromGlobalPosition?: number | undefined;
1134
+ fromCreatedAt?: string | undefined;
1135
+ toGlobalPosition?: number | undefined;
1136
+ toCreatedAt?: string | undefined;
1137
+ eventTypes?: string[] | undefined;
1138
+ };
1139
+ };
1140
+ output: {
1141
+ error: string;
1142
+ message: string;
1143
+ details?: {
1144
+ [x: string]: any;
1145
+ } | undefined;
1146
+ };
1147
+ outputFormat: "json";
1148
+ status: 409;
1149
+ } | {
1150
+ input: {
1151
+ param: {
1152
+ eventStoreName: string;
1153
+ subscriberId: string;
1154
+ };
1155
+ } & {
1156
+ json: {
1157
+ fromGlobalPosition?: number | undefined;
1158
+ fromCreatedAt?: string | undefined;
1159
+ toGlobalPosition?: number | undefined;
1160
+ toCreatedAt?: string | undefined;
1161
+ eventTypes?: string[] | undefined;
1162
+ };
1163
+ };
1164
+ output: {
1165
+ message: string;
1166
+ fromPosition: number;
1167
+ estimatedEvents: number;
1168
+ };
1169
+ outputFormat: "json";
1170
+ status: 202;
1171
+ };
1172
+ };
1173
+ } & {
1174
+ "/event-stores/:eventStoreName/subscriptions/:subscriberId/replay": {
1175
+ $get: {
1176
+ input: {
1177
+ param: {
1178
+ eventStoreName: string;
1179
+ subscriberId: string;
1180
+ };
1181
+ };
1182
+ output: {
1183
+ error: string;
1184
+ message: string;
1185
+ details?: {
1186
+ [x: string]: any;
1187
+ } | undefined;
1188
+ };
1189
+ outputFormat: "json";
1190
+ status: 401;
1191
+ } | {
1192
+ input: {
1193
+ param: {
1194
+ eventStoreName: string;
1195
+ subscriberId: string;
1196
+ };
1197
+ };
1198
+ output: {
1199
+ error: string;
1200
+ message: string;
1201
+ details?: {
1202
+ [x: string]: any;
1203
+ } | undefined;
1204
+ };
1205
+ outputFormat: "json";
1206
+ status: 404;
1207
+ } | {
1208
+ input: {
1209
+ param: {
1210
+ eventStoreName: string;
1211
+ subscriberId: string;
1212
+ };
1213
+ };
1214
+ output: {
1215
+ error: string;
1216
+ message: string;
1217
+ details?: {
1218
+ [x: string]: any;
1219
+ } | undefined;
1220
+ };
1221
+ outputFormat: "json";
1222
+ status: 500;
1223
+ } | {
1224
+ input: {
1225
+ param: {
1226
+ eventStoreName: string;
1227
+ subscriberId: string;
1228
+ };
1229
+ };
1230
+ output: {
1231
+ inProgress: boolean;
1232
+ startPosition: number | null;
1233
+ targetPosition: number | null;
1234
+ currentPosition: number;
1235
+ processedCount: number;
1236
+ estimatedEvents: number;
1237
+ startedAt: string | null;
1238
+ };
1239
+ outputFormat: "json";
1240
+ status: 200;
1241
+ };
1242
+ };
1243
+ }, "/">;
1244
+ }
1245
+
1246
+ declare namespace EventStoreAPI {
1247
+ const EventSchema: z.ZodObject<{
1248
+ streamId: z.ZodString;
1249
+ streamPosition: z.ZodNumber;
1250
+ globalPosition: z.ZodNumber;
1251
+ eventId: z.ZodString;
1252
+ type: z.ZodString;
1253
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1254
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1255
+ schemaVersion: z.ZodString;
1256
+ transactionId: z.ZodString;
1257
+ createdAt: z.ZodString;
1258
+ }, z.core.$strip>;
1259
+ export const AppendEventsRequestSchema: z.ZodObject<{
1260
+ events: z.ZodArray<z.ZodObject<{
1261
+ type: z.ZodString;
1262
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1263
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1264
+ }, z.core.$strip>>;
1265
+ options: z.ZodOptional<z.ZodObject<{
1266
+ expectedStreamVersion: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
1267
+ }, z.core.$strip>>;
1268
+ }, z.core.$strip>;
1269
+ export const AppendEventsResponseSchema: z.ZodObject<{
1270
+ success: z.ZodBoolean;
1271
+ nextExpectedStreamVersion: z.ZodNumber;
1272
+ eventsWritten: z.ZodNumber;
1273
+ }, z.core.$strip>;
1274
+ export const VersionConflictErrorSchema: z.ZodObject<{
1275
+ error: z.ZodLiteral<"Version conflict">;
1276
+ details: z.ZodString;
1277
+ currentVersion: z.ZodNumber;
1278
+ expectedVersion: z.ZodNumber;
1279
+ }, z.core.$strip>;
1280
+ export const ValidationErrorSchema: z.ZodObject<{
1281
+ error: z.ZodLiteral<"Invalid request body">;
1282
+ details: z.ZodArray<z.ZodObject<{
1283
+ code: z.ZodString;
1284
+ message: z.ZodString;
1285
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1286
+ }, z.core.$strip>>;
1287
+ }, z.core.$strip>;
1288
+ export const OrganizationNotFoundErrorSchema: z.ZodObject<{
1289
+ error: z.ZodLiteral<"UNAUTHORIZED">;
1290
+ message: z.ZodLiteral<"Unauthorized: Organization ID not found in authentication context">;
1291
+ }, z.core.$strip>;
1292
+ export const AppendEventsErrorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1293
+ error: z.ZodLiteral<"Version conflict">;
1294
+ details: z.ZodString;
1295
+ currentVersion: z.ZodNumber;
1296
+ expectedVersion: z.ZodNumber;
1297
+ }, z.core.$strip>, z.ZodObject<{
1298
+ error: z.ZodLiteral<"Invalid request body">;
1299
+ details: z.ZodArray<z.ZodObject<{
1300
+ code: z.ZodString;
1301
+ message: z.ZodString;
1302
+ path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
1303
+ }, z.core.$strip>>;
1304
+ }, z.core.$strip>], "error">;
1305
+ export const ReadStreamOptionsSchema: z.ZodObject<{
1306
+ expectedStreamVersion: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
1307
+ }, z.core.$strip>;
1308
+ export const ReadStreamResponseSchema: z.ZodObject<{
1309
+ events: z.ZodArray<z.ZodObject<{
1310
+ streamId: z.ZodString;
1311
+ streamPosition: z.ZodNumber;
1312
+ globalPosition: z.ZodNumber;
1313
+ eventId: z.ZodString;
1314
+ type: z.ZodString;
1315
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1316
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1317
+ schemaVersion: z.ZodString;
1318
+ transactionId: z.ZodString;
1319
+ createdAt: z.ZodString;
1320
+ }, z.core.$strip>>;
1321
+ currentStreamVersion: z.ZodNumber;
1322
+ }, z.core.$strip>;
1323
+ export const QueryEventsParamsSchema: z.ZodObject<{
1324
+ streamId: z.ZodOptional<z.ZodString>;
1325
+ type: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1326
+ eventId: z.ZodOptional<z.ZodString>;
1327
+ transactionId: z.ZodOptional<z.ZodString>;
1328
+ fromPosition: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
1329
+ toPosition: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
1330
+ fromDate: z.ZodOptional<z.ZodISODateTime>;
1331
+ toDate: z.ZodOptional<z.ZodString>;
1332
+ phase: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
1333
+ includeArchived: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<boolean, string>>, z.ZodBoolean>>;
1334
+ limit: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
1335
+ offset: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
1336
+ sortBy: z.ZodOptional<z.ZodEnum<{
1337
+ streamPosition: "streamPosition";
1338
+ globalPosition: "globalPosition";
1339
+ createdAt: "createdAt";
1340
+ }>>;
1341
+ sortDirection: z.ZodOptional<z.ZodEnum<{
1342
+ asc: "asc";
1343
+ desc: "desc";
1344
+ }>>;
1345
+ includeCount: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<boolean, string>>, z.ZodBoolean>>;
1346
+ }, z.core.$strip>;
1347
+ export const QueryStreamsParamsSchema: z.ZodObject<{
1348
+ streamId: z.ZodOptional<z.ZodString>;
1349
+ streamType: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1350
+ streamIdPattern: z.ZodOptional<z.ZodString>;
1351
+ minPosition: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
1352
+ maxPosition: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
1353
+ fromDate: z.ZodOptional<z.ZodISODateTime>;
1354
+ toDate: z.ZodOptional<z.ZodISODateTime>;
1355
+ includeArchived: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<boolean, string>>, z.ZodBoolean>>;
1356
+ includeMetadata: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<boolean, string>>, z.ZodBoolean>>;
1357
+ limit: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
1358
+ offset: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>>;
1359
+ sortBy: z.ZodOptional<z.ZodEnum<{
1360
+ streamId: "streamId";
1361
+ streamPosition: "streamPosition";
1362
+ createdAt: "createdAt";
1363
+ updatedAt: "updatedAt";
1364
+ }>>;
1365
+ sortDirection: z.ZodOptional<z.ZodEnum<{
1366
+ asc: "asc";
1367
+ desc: "desc";
1368
+ }>>;
1369
+ includeCount: z.ZodOptional<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<boolean, string>>, z.ZodBoolean>>;
1370
+ }, z.core.$strip>;
1371
+ const PaginationSchema: z.ZodObject<{
1372
+ limit: z.ZodNumber;
1373
+ offset: z.ZodNumber;
1374
+ total: z.ZodOptional<z.ZodNumber>;
1375
+ hasMore: z.ZodBoolean;
1376
+ }, z.core.$strip>;
1377
+ export const QueryEventsResponseSchema: z.ZodObject<{
1378
+ events: z.ZodArray<z.ZodObject<{
1379
+ streamId: z.ZodString;
1380
+ streamPosition: z.ZodNumber;
1381
+ globalPosition: z.ZodNumber;
1382
+ eventId: z.ZodString;
1383
+ type: z.ZodString;
1384
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1385
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1386
+ schemaVersion: z.ZodString;
1387
+ transactionId: z.ZodString;
1388
+ createdAt: z.ZodString;
1389
+ }, z.core.$strip>>;
1390
+ pagination: z.ZodObject<{
1391
+ limit: z.ZodNumber;
1392
+ offset: z.ZodNumber;
1393
+ total: z.ZodOptional<z.ZodNumber>;
1394
+ hasMore: z.ZodBoolean;
1395
+ }, z.core.$strip>;
1396
+ }, z.core.$strip>;
1397
+ export const StreamSchema: z.ZodObject<{
1398
+ streamId: z.ZodString;
1399
+ streamPosition: z.ZodNumber;
1400
+ streamType: z.ZodString;
1401
+ streamMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1402
+ isArchived: z.ZodBoolean;
1403
+ lastArchivedPosition: z.ZodNumber;
1404
+ createdAt: z.ZodString;
1405
+ updatedAt: z.ZodString;
1406
+ }, z.core.$strip>;
1407
+ export const QueryStreamsResponseSchema: z.ZodObject<{
1408
+ streams: z.ZodArray<z.ZodObject<{
1409
+ streamId: z.ZodString;
1410
+ streamPosition: z.ZodNumber;
1411
+ streamType: z.ZodString;
1412
+ streamMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1413
+ isArchived: z.ZodBoolean;
1414
+ lastArchivedPosition: z.ZodNumber;
1415
+ createdAt: z.ZodString;
1416
+ updatedAt: z.ZodString;
1417
+ }, z.core.$strip>>;
1418
+ pagination: z.ZodObject<{
1419
+ limit: z.ZodNumber;
1420
+ offset: z.ZodNumber;
1421
+ total: z.ZodOptional<z.ZodNumber>;
1422
+ hasMore: z.ZodBoolean;
1423
+ }, z.core.$strip>;
1424
+ }, z.core.$strip>;
1425
+ export const OutboxDlqEntrySchema: z.ZodObject<{
1426
+ id: z.ZodNumber;
1427
+ streamId: z.ZodString;
1428
+ streamPosition: z.ZodNumber;
1429
+ globalPosition: z.ZodNumber;
1430
+ messageId: z.ZodString;
1431
+ messageType: z.ZodString;
1432
+ messageData: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1433
+ messageMetadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1434
+ messageSchemaVersion: z.ZodString;
1435
+ transactionId: z.ZodString;
1436
+ totalAttempts: z.ZodNumber;
1437
+ lastError: z.ZodNullable<z.ZodString>;
1438
+ dlqReason: z.ZodEnum<{
1439
+ max_publish_retries: "max_publish_retries";
1440
+ eventbus_unreachable: "eventbus_unreachable";
1441
+ manual: "manual";
1442
+ subscriber_deleted: "subscriber_deleted";
1443
+ }>;
1444
+ originalCreatedAt: z.ZodString;
1445
+ movedToDlqAt: z.ZodString;
1446
+ }, z.core.$strip>;
1447
+ export const OutboxDlqListResponseSchema: z.ZodObject<{
1448
+ entries: z.ZodArray<z.ZodObject<{
1449
+ id: z.ZodNumber;
1450
+ streamId: z.ZodString;
1451
+ streamPosition: z.ZodNumber;
1452
+ globalPosition: z.ZodNumber;
1453
+ messageId: z.ZodString;
1454
+ messageType: z.ZodString;
1455
+ messageData: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1456
+ messageMetadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1457
+ messageSchemaVersion: z.ZodString;
1458
+ transactionId: z.ZodString;
1459
+ totalAttempts: z.ZodNumber;
1460
+ lastError: z.ZodNullable<z.ZodString>;
1461
+ dlqReason: z.ZodEnum<{
1462
+ max_publish_retries: "max_publish_retries";
1463
+ eventbus_unreachable: "eventbus_unreachable";
1464
+ manual: "manual";
1465
+ subscriber_deleted: "subscriber_deleted";
1466
+ }>;
1467
+ originalCreatedAt: z.ZodString;
1468
+ movedToDlqAt: z.ZodString;
1469
+ }, z.core.$strip>>;
1470
+ pagination: z.ZodObject<{
1471
+ limit: z.ZodNumber;
1472
+ offset: z.ZodNumber;
1473
+ total: z.ZodOptional<z.ZodNumber>;
1474
+ hasMore: z.ZodBoolean;
1475
+ }, z.core.$strip>;
1476
+ }, z.core.$strip>;
1477
+ export type QueryEventsParams = z.infer<typeof QueryEventsParamsSchema>;
1478
+ export type QueryStreamsParams = z.infer<typeof QueryStreamsParamsSchema>;
1479
+ export type QueryEventsResponse = {
1480
+ events: z.infer<typeof EventSchema>[];
1481
+ pagination: z.infer<typeof PaginationSchema>;
1482
+ };
1483
+ export type QueryStreamsResponse = z.infer<typeof QueryStreamsResponseSchema>;
1484
+ export type Stream = z.infer<typeof StreamSchema>;
1485
+ export type ReadEvent = z.infer<typeof EventSchema>;
1486
+ export type OutboxDlqListResponse = z.infer<typeof OutboxDlqListResponseSchema>;
1487
+ export const routes: OpenAPIHono<{
1488
+ Bindings: Env;
1489
+ Variables: {
1490
+ orgId: string;
1491
+ };
1492
+ }, {
1493
+ "/event-stores/:eventStoreName/streams/:streamId": {
1494
+ $post: {
1495
+ input: {
1496
+ param: {
1497
+ eventStoreName: string;
1498
+ streamId: string;
1499
+ };
1500
+ } & {
1501
+ json: {
1502
+ events: {
1503
+ type: string;
1504
+ data: Record<string, unknown>;
1505
+ metadata?: Record<string, unknown> | undefined;
1506
+ }[];
1507
+ options?: {
1508
+ expectedStreamVersion?: string | number | undefined;
1509
+ } | undefined;
1510
+ };
1511
+ };
1512
+ output: {
1513
+ success: boolean;
1514
+ nextExpectedStreamVersion: number;
1515
+ eventsWritten: number;
1516
+ };
1517
+ outputFormat: "json";
1518
+ status: 200;
1519
+ } | {
1520
+ input: {
1521
+ param: {
1522
+ eventStoreName: string;
1523
+ streamId: string;
1524
+ };
1525
+ } & {
1526
+ json: {
1527
+ events: {
1019
1528
  type: string;
1020
1529
  data: Record<string, unknown>;
1021
1530
  metadata?: Record<string, unknown> | undefined;
@@ -1617,6 +2126,178 @@ declare namespace EventStoreAPI {
1617
2126
  status: 200;
1618
2127
  };
1619
2128
  };
2129
+ } & {
2130
+ "/event-stores/:eventStoreName/outbox-dlq": {
2131
+ $get: {
2132
+ input: {
2133
+ param: {
2134
+ eventStoreName: string;
2135
+ };
2136
+ } & {
2137
+ query: {
2138
+ limit?: string | undefined;
2139
+ offset?: string | undefined;
2140
+ };
2141
+ };
2142
+ output: {
2143
+ error: "UNAUTHORIZED";
2144
+ message: "Unauthorized: Organization ID not found in authentication context";
2145
+ };
2146
+ outputFormat: "json";
2147
+ status: 401;
2148
+ } | {
2149
+ input: {
2150
+ param: {
2151
+ eventStoreName: string;
2152
+ };
2153
+ } & {
2154
+ query: {
2155
+ limit?: string | undefined;
2156
+ offset?: string | undefined;
2157
+ };
2158
+ };
2159
+ output: {
2160
+ entries: {
2161
+ id: number;
2162
+ streamId: string;
2163
+ streamPosition: number;
2164
+ globalPosition: number;
2165
+ messageId: string;
2166
+ messageType: string;
2167
+ messageData: {
2168
+ [x: string]: hono_utils_types.JSONValue;
2169
+ };
2170
+ messageMetadata: {
2171
+ [x: string]: hono_utils_types.JSONValue;
2172
+ };
2173
+ messageSchemaVersion: string;
2174
+ transactionId: string;
2175
+ totalAttempts: number;
2176
+ lastError: string | null;
2177
+ dlqReason: "max_publish_retries" | "eventbus_unreachable" | "manual" | "subscriber_deleted";
2178
+ originalCreatedAt: string;
2179
+ movedToDlqAt: string;
2180
+ }[];
2181
+ pagination: {
2182
+ limit: number;
2183
+ offset: number;
2184
+ hasMore: boolean;
2185
+ total?: number | undefined;
2186
+ };
2187
+ };
2188
+ outputFormat: "json";
2189
+ status: 200;
2190
+ };
2191
+ };
2192
+ } & {
2193
+ "/event-stores/:eventStoreName/outbox-dlq/:entryId/retry": {
2194
+ $post: {
2195
+ input: {
2196
+ param: {
2197
+ eventStoreName: string;
2198
+ entryId: string;
2199
+ };
2200
+ };
2201
+ output: {
2202
+ error: "UNAUTHORIZED";
2203
+ message: "Unauthorized: Organization ID not found in authentication context";
2204
+ };
2205
+ outputFormat: "json";
2206
+ status: 401;
2207
+ } | {
2208
+ input: {
2209
+ param: {
2210
+ eventStoreName: string;
2211
+ entryId: string;
2212
+ };
2213
+ };
2214
+ output: {
2215
+ success: boolean;
2216
+ entryId: number;
2217
+ };
2218
+ outputFormat: "json";
2219
+ status: 200;
2220
+ } | {
2221
+ input: {
2222
+ param: {
2223
+ eventStoreName: string;
2224
+ entryId: string;
2225
+ };
2226
+ };
2227
+ output: {
2228
+ error: "Not found";
2229
+ };
2230
+ outputFormat: "json";
2231
+ status: 404;
2232
+ };
2233
+ };
2234
+ } & {
2235
+ "/event-stores/:eventStoreName/outbox-dlq/retry-all": {
2236
+ $post: {
2237
+ input: {
2238
+ param: {
2239
+ eventStoreName: string;
2240
+ };
2241
+ };
2242
+ output: {
2243
+ error: "UNAUTHORIZED";
2244
+ message: "Unauthorized: Organization ID not found in authentication context";
2245
+ };
2246
+ outputFormat: "json";
2247
+ status: 401;
2248
+ } | {
2249
+ input: {
2250
+ param: {
2251
+ eventStoreName: string;
2252
+ };
2253
+ };
2254
+ output: {
2255
+ success: boolean;
2256
+ count: number;
2257
+ };
2258
+ outputFormat: "json";
2259
+ status: 200;
2260
+ };
2261
+ };
2262
+ } & {
2263
+ "/event-stores/:eventStoreName/outbox-dlq/:entryId": {
2264
+ $delete: {
2265
+ input: {
2266
+ param: {
2267
+ eventStoreName: string;
2268
+ entryId: string;
2269
+ };
2270
+ };
2271
+ output: {};
2272
+ outputFormat: string;
2273
+ status: 204;
2274
+ } | {
2275
+ input: {
2276
+ param: {
2277
+ eventStoreName: string;
2278
+ entryId: string;
2279
+ };
2280
+ };
2281
+ output: {
2282
+ error: "UNAUTHORIZED";
2283
+ message: "Unauthorized: Organization ID not found in authentication context";
2284
+ };
2285
+ outputFormat: "json";
2286
+ status: 401;
2287
+ } | {
2288
+ input: {
2289
+ param: {
2290
+ eventStoreName: string;
2291
+ entryId: string;
2292
+ };
2293
+ };
2294
+ output: {
2295
+ error: "Not found";
2296
+ };
2297
+ outputFormat: "json";
2298
+ status: 404;
2299
+ };
2300
+ };
1620
2301
  }, "/">;
1621
2302
  export { };
1622
2303
  }
@@ -2340,6 +3021,16 @@ declare namespace WebSocketsAPI {
2340
3021
  }, "/">;
2341
3022
  }
2342
3023
 
3024
+ type RetryStrategy = 'exponential' | 'linear' | 'fixed';
3025
+ interface RetryPolicy {
3026
+ strategy: RetryStrategy;
3027
+ maxAttempts: number;
3028
+ initialDelayMs: number;
3029
+ maxDelayMs: number;
3030
+ multiplier?: number;
3031
+ jitterPercent?: number;
3032
+ }
3033
+
2343
3034
  type WildcardPattern = '*' | `${string}.*` | `*.${string}` | `${string}.*${string}`;
2344
3035
  type EventType = string;
2345
3036
  type EventFilter = EventType | EventType[] | WildcardPattern;
@@ -2396,9 +3087,6 @@ type SubscriberTypeConfig = {
2396
3087
  type: SubscriberType.WebSocket;
2397
3088
  config: WebSocketConfig;
2398
3089
  };
2399
- interface Env$1 {
2400
- [key: string]: DurableObjectNamespace | Workflow;
2401
- }
2402
3090
  interface EventMessage {
2403
3091
  event_id: string;
2404
3092
  event_type: string;
@@ -2416,6 +3104,8 @@ interface SubscriptionListOptions {
2416
3104
  eventFilter?: string;
2417
3105
  limit?: number;
2418
3106
  offset?: number;
3107
+ /** When true (default), hides platform-internal subscriptions (e.g. ws-manager). */
3108
+ hideInternal?: boolean;
2419
3109
  }
2420
3110
  declare enum SubscriptionStatus {
2421
3111
  ACTIVE = "ACTIVE",
@@ -2440,11 +3130,11 @@ interface StatusDetails {
2440
3130
  };
2441
3131
  }
2442
3132
  interface Subscription {
2443
- id: string;
2444
- eventFilter: string;
2445
3133
  subscriberId: string;
3134
+ eventFilter: string;
2446
3135
  subscriberType: SubscriberType;
2447
3136
  subscriberConfig: string;
3137
+ subscriberDoId?: string | null;
2448
3138
  status: SubscriptionStatus;
2449
3139
  statusDetails?: StatusDetails;
2450
3140
  lastProcessedEventGlobalPosition: number;
@@ -2456,7 +3146,7 @@ interface SubscriptionResult {
2456
3146
  isExistingSubscription: boolean;
2457
3147
  message: string;
2458
3148
  }
2459
- declare class EventBusDurableObject extends DurableObject<Env$1> {
3149
+ declare class EventBusDurableObject extends DurableObject<Env> {
2460
3150
  private readonly BATCH_SIZE;
2461
3151
  private readonly RETRY_DELAY_HOURS;
2462
3152
  /** Maximum messages to process per subscriber per batch (for round-robin fairness) */
@@ -2477,16 +3167,18 @@ declare class EventBusDurableObject extends DurableObject<Env$1> {
2477
3167
  * @private
2478
3168
  */
2479
3169
  private formatDateToISO;
3170
+ constructor(state: DurableObjectState, env: Env);
3171
+ private initializeTables;
3172
+ private ensureSubscriberDoColumn;
2480
3173
  /**
2481
- * Converts ISO 8601 date string to SQLite DATETIME format for query comparisons
2482
- * This ensures backward compatibility with existing data stored in SQLite format
2483
- * @param isoDate - ISO 8601 date string like "2025-12-02T05:00:00.000Z"
2484
- * @returns SQLite DATETIME format string like "2025-12-02 05:00:00"
2485
- * @private
3174
+ * Migrates old subscriptions table schema (id INTEGER PK + UNIQUE(event_filter, subscriber_id))
3175
+ * to new schema (subscriber_id TEXT PK). This is needed because ON CONFLICT(subscriber_id)
3176
+ * requires subscriber_id to be a PK or have a UNIQUE constraint on its own.
3177
+ *
3178
+ * Old DOs created before this migration have the old schema due to CREATE TABLE IF NOT EXISTS
3179
+ * being a no-op when the table already exists.
2486
3180
  */
2487
- private formatDateToSQLite;
2488
- constructor(state: DurableObjectState, env: Env$1);
2489
- private initializeTables;
3181
+ private migrateSubscriptionsPrimaryKey;
2490
3182
  initialize(eventStoreID: string): void;
2491
3183
  /**
2492
3184
  * Ensures the event bus has been initialized
@@ -2494,6 +3186,7 @@ declare class EventBusDurableObject extends DurableObject<Env$1> {
2494
3186
  * @private
2495
3187
  */
2496
3188
  private ensureInitialized;
3189
+ private getEventStoreId;
2497
3190
  /**
2498
3191
  * Check if a webhook subscription with the same configuration already exists
2499
3192
  * @param eventFilter - The event filter pattern to match
@@ -2513,10 +3206,17 @@ declare class EventBusDurableObject extends DurableObject<Env$1> {
2513
3206
  subscribe(eventFilter: EventFilter, subscriberId: string, subscription: SubscriberTypeConfig, initialPosition?: InitialPosition): Promise<SubscriptionResult>;
2514
3207
  private validateSubscriberConfig;
2515
3208
  private updateSubscriptionStatus;
3209
+ private initializeSubscriberDurableObject;
2516
3210
  unsubscribe(subscriberId: string): Promise<void>;
3211
+ updateSubscription(subscriberId: string, updates: {
3212
+ eventFilter?: string;
3213
+ subscriberConfig?: Record<string, unknown>;
3214
+ retryPolicy?: RetryPolicy;
3215
+ status?: 'ACTIVE' | 'SUSPENDED';
3216
+ }): Promise<Subscription>;
2517
3217
  getSubscriptions(options?: SubscriptionListOptions): Promise<Subscription[]>;
2518
3218
  getSubscriptionsCount(options?: Omit<SubscriptionListOptions, 'limit' | 'offset'>): Promise<number>;
2519
- getSubscription(id: string): Promise<Subscription | null>;
3219
+ getSubscription(subscriberId: string): Promise<Subscription | null>;
2520
3220
  publish(events: {
2521
3221
  event_id: string;
2522
3222
  event_type: string;
@@ -2529,6 +3229,14 @@ declare class EventBusDurableObject extends DurableObject<Env$1> {
2529
3229
  transaction_id: string;
2530
3230
  created: string;
2531
3231
  }[]): Promise<void>;
3232
+ /**
3233
+ * Coordinates fetching events for replay from EventStoreDO
3234
+ * @param fromGlobalPosition - The global position to start fetching from
3235
+ * @param limit - Maximum number of events to fetch
3236
+ * @param eventFilter - Optional event type filter (supports wildcards)
3237
+ * @returns Array of events for replay
3238
+ */
3239
+ getEventsForReplay(fromGlobalPosition: number, limit: number, eventFilter?: string): Promise<EventMessage[]>;
2532
3240
  private getMatchingSubscriptions;
2533
3241
  private requestDelivery;
2534
3242
  private processOutboxBatch;
@@ -2578,6 +3286,67 @@ declare class EventBusDurableObject extends DurableObject<Env$1> {
2578
3286
  pending_messages: number;
2579
3287
  };
2580
3288
  private validateEventFilter;
3289
+ /**
3290
+ * Validates the subscriber ID format.
3291
+ * Must be 1-128 characters, alphanumeric with hyphens and underscores only.
3292
+ * This is compatible with nanoid() default output (A-Za-z0-9_-) and
3293
+ * is URL-safe (no percent-encoding needed in path segments).
3294
+ * @param subscriberId - The subscriber ID to validate
3295
+ * @throws ValidationError if the subscriber ID is invalid
3296
+ * @private
3297
+ */
3298
+ private validateSubscriberId;
3299
+ /**
3300
+ * Checks that the subscriber ID is not already in use with a different event filter.
3301
+ * Enforces subscriber ID uniqueness within an event bus — each subscriber ID
3302
+ * maps to exactly one subscription. Re-subscribing with the same (subscriberId, eventFilter)
3303
+ * pair is allowed (idempotent upsert).
3304
+ * @param subscriberId - The subscriber ID to check
3305
+ * @param eventFilter - The event filter for the new subscription
3306
+ * @throws ValidationError if the subscriber ID is already in use with a different event filter
3307
+ * @private
3308
+ */
3309
+ private ensureSubscriberIdUnique;
3310
+ /**
3311
+ * Migrates all unmigrated subscriptions to SubscriberDOs.
3312
+ * This method is idempotent - running it multiple times is safe.
3313
+ */
3314
+ migrateAllSubscriptions(): Promise<{
3315
+ subscriptionsMigrated: number;
3316
+ outboxEntriesMoved: number;
3317
+ }>;
3318
+ /**
3319
+ * Gets migration status for this EventBusDO
3320
+ */
3321
+ getMigrationStatus(): Promise<{
3322
+ totalSubscriptions: number;
3323
+ migratedCount: number;
3324
+ legacyCount: number;
3325
+ legacyOutboxCount: number;
3326
+ }>;
3327
+ /**
3328
+ * Checks how many SubscriberDOs still need event_store_id backfilled.
3329
+ * Queries each SubscriberDO's config to check if event_store_id is set.
3330
+ */
3331
+ getBackfillStatus(): Promise<{
3332
+ total: number;
3333
+ backfilled: number;
3334
+ pending: number;
3335
+ complete: boolean;
3336
+ }>;
3337
+ /**
3338
+ * Backfills event_store_id on all SubscriberDOs for this EventBusDO.
3339
+ * Idempotent — safe to run multiple times. Calls setEventStoreId()
3340
+ * on each SubscriberDO that has a subscriber_do_id.
3341
+ */
3342
+ backfillEventStoreIds(): Promise<{
3343
+ updated: number;
3344
+ failed: number;
3345
+ }>;
3346
+ /**
3347
+ * Reconstructs an EventMessage from a subscriptions_outbox row
3348
+ */
3349
+ private reconstructEventFromOutbox;
2581
3350
  }
2582
3351
 
2583
3352
  /**
@@ -2652,6 +3421,32 @@ type QueryStreamsResult = {
2652
3421
  hasMore: boolean;
2653
3422
  };
2654
3423
  };
3424
+ type OutboxDlqEntry = {
3425
+ id: number;
3426
+ streamId: string;
3427
+ streamPosition: number;
3428
+ globalPosition: number;
3429
+ messageId: string;
3430
+ messageType: string;
3431
+ messageData: Record<string, unknown>;
3432
+ messageMetadata: Record<string, unknown>;
3433
+ messageSchemaVersion: string;
3434
+ transactionId: string;
3435
+ totalAttempts: number;
3436
+ lastError: string | null;
3437
+ dlqReason: 'max_publish_retries' | 'eventbus_unreachable' | 'manual' | 'subscriber_deleted';
3438
+ originalCreatedAt: string;
3439
+ movedToDlqAt: string;
3440
+ };
3441
+ type OutboxDlqResult = {
3442
+ entries: OutboxDlqEntry[];
3443
+ pagination: {
3444
+ limit: number;
3445
+ offset: number;
3446
+ total: number;
3447
+ hasMore: boolean;
3448
+ };
3449
+ };
2655
3450
  /**
2656
3451
  * A durable object implementation of an event store.
2657
3452
  * Handles event persistence, archiving, and event bus integration.
@@ -2735,11 +3530,29 @@ declare class EventStoreDurableObject extends DurableObject<Env> {
2735
3530
  */
2736
3531
  getEventStoreId(): string;
2737
3532
  /**
2738
- * Queries events based on filtering parameters
2739
- * @param params - Query parameters for filtering events
2740
- * @returns Promise resolving to filtered events and optional count
3533
+ * Queries events based on filtering parameters
3534
+ * @param params - Query parameters for filtering events
3535
+ * @returns Promise resolving to filtered events and optional count
3536
+ */
3537
+ queryEvents(params?: EventsQueryParams): Promise<QueryEventsResult>;
3538
+ /**
3539
+ * Gets events for replay starting from a specific global position
3540
+ * @param fromGlobalPosition - The global position to start fetching from
3541
+ * @param limit - Maximum number of events to fetch
3542
+ * @param eventFilter - Optional event type filter (supports wildcards like "orders.*")
3543
+ * @returns Array of events for replay
3544
+ */
3545
+ getEventsForReplay(fromGlobalPosition: number, limit: number, eventFilter?: string): Promise<EventMessage[]>;
3546
+ /**
3547
+ * Resolves an ISO datetime to the nearest global position at or after that time.
3548
+ * Returns 0 if no events exist at or after the given datetime.
3549
+ */
3550
+ resolveCreatedAtToPosition(createdAt: string): number;
3551
+ /**
3552
+ * Returns the maximum global position across all non-archived events.
3553
+ * Returns 0 if no events exist.
2741
3554
  */
2742
- queryEvents(params?: EventsQueryParams): Promise<QueryEventsResult>;
3555
+ getHeadPosition(): number;
2743
3556
  /**
2744
3557
  * Queries streams based on filtering parameters
2745
3558
  * @param params - Query parameters for filtering streams
@@ -2775,6 +3588,7 @@ declare class EventStoreDurableObject extends DurableObject<Env> {
2775
3588
  * @private
2776
3589
  */
2777
3590
  private mapRowToEvent;
3591
+ private mapRowToOutboxDlqEntry;
2778
3592
  /**
2779
3593
  * Gets the current version of a stream
2780
3594
  * @param streamId - The stream to get the version for
@@ -2836,6 +3650,13 @@ declare class EventStoreDurableObject extends DurableObject<Env> {
2836
3650
  * @private
2837
3651
  */
2838
3652
  private processPendingEventBusMessages;
3653
+ listOutboxDlq(options?: {
3654
+ limit?: number;
3655
+ offset?: number;
3656
+ }): Promise<OutboxDlqResult>;
3657
+ retryOutboxDlqEntry(entryId: number): Promise<boolean>;
3658
+ retryAllOutboxDlq(): Promise<number>;
3659
+ deleteOutboxDlqEntry(entryId: number): Promise<boolean>;
2839
3660
  /**
2840
3661
  * Gets the current database size in bytes (consistent with EventBusDO)
2841
3662
  * @returns Database size in bytes
@@ -3088,6 +3909,106 @@ declare class EventStoreManagerDurableObject extends DurableObject<Env> {
3088
3909
  }>;
3089
3910
  }
3090
3911
 
3912
+ interface SubscriberInitConfig {
3913
+ subscriberId: string;
3914
+ eventStoreId: string;
3915
+ subscriberType: SubscriberType;
3916
+ subscriberConfig: SubscriberTypeConfig['config'];
3917
+ eventFilter: string;
3918
+ retryPolicy: RetryPolicy;
3919
+ }
3920
+ interface ReplayOptions {
3921
+ fromGlobalPosition?: number;
3922
+ fromCreatedAt?: string;
3923
+ toGlobalPosition?: number;
3924
+ toCreatedAt?: string;
3925
+ eventTypes?: string[];
3926
+ }
3927
+ interface ReplayStatus {
3928
+ inProgress: boolean;
3929
+ startPosition: number | null;
3930
+ targetPosition: number | null;
3931
+ currentPosition: number;
3932
+ processedCount: number;
3933
+ estimatedEvents: number;
3934
+ startedAt: string | null;
3935
+ }
3936
+ type SubscriberStatus = 'ACTIVE' | 'PAUSED' | 'ERROR';
3937
+ declare class SubscriberDurableObject extends DurableObject<Env> {
3938
+ private readonly BATCH_SIZE;
3939
+ private readonly MAX_BATCHES_PER_ALARM;
3940
+ private readonly REPLAY_BATCH_SIZE;
3941
+ private readonly REPLAY_DELAY_MS;
3942
+ private isAlarmActive;
3943
+ private isSchedulingAlarm;
3944
+ sql: SqlStorage;
3945
+ constructor(state: DurableObjectState, env: Env);
3946
+ private initializeTables;
3947
+ /**
3948
+ * Handles schema migrations for existing SubscriberDOs.
3949
+ * Uses PRAGMA table_info to detect missing columns and adds them.
3950
+ * This runs in blockConcurrencyWhile so it's safe on every wake.
3951
+ */
3952
+ private migrateSchema;
3953
+ private ensureConfigColumn;
3954
+ private ensureCursorColumn;
3955
+ initialize(config: SubscriberInitConfig): void;
3956
+ /**
3957
+ * Returns whether this subscriber has event_store_id set in its config.
3958
+ * Used by the backfill status check.
3959
+ */
3960
+ hasEventStoreId(): boolean;
3961
+ /**
3962
+ * Sets the event store ID for this subscriber.
3963
+ * Used by backfill migration for existing DOs that were created
3964
+ * before event_store_id was added to the config table.
3965
+ */
3966
+ setEventStoreId(eventStoreId: string): void;
3967
+ setCursor(position: number): void;
3968
+ replay(options: ReplayOptions): Promise<void>;
3969
+ /**
3970
+ * Resolves an ISO datetime to the nearest global position at or after that time.
3971
+ */
3972
+ private resolveCreatedAtToPosition;
3973
+ /**
3974
+ * Fetches the current head (max) global position from EventStoreDO.
3975
+ */
3976
+ private fetchHeadPosition;
3977
+ getReplayStatus(): ReplayStatus;
3978
+ private getSubscriberId;
3979
+ private completeReplay;
3980
+ enqueue(events: EventMessage[]): Promise<void>;
3981
+ /**
3982
+ * Internal enqueue that inserts events without replay guard logic.
3983
+ * Used by both public enqueue() and processReplayBatch().
3984
+ */
3985
+ private enqueueInternal;
3986
+ private isReplayInProgress;
3987
+ private requestAlarm;
3988
+ private getConfigRow;
3989
+ private getSubscriberStatus;
3990
+ private getRetryPolicy;
3991
+ private getSubscriberConfig;
3992
+ updateStatus(status: SubscriberStatus, _error?: string): void;
3993
+ private getReadyOutboxBatch;
3994
+ private getNextAlarmTime;
3995
+ private scheduleNextAlarm;
3996
+ private reconstructEvent;
3997
+ private markEventDelivered;
3998
+ private moveToDlq;
3999
+ private updateRetryState;
4000
+ private deliverEvent;
4001
+ alarm(): Promise<void>;
4002
+ /**
4003
+ * Fetches and enqueues the next batch of replay events.
4004
+ * @returns The number of events fetched in this batch (0 means replay fetching is done).
4005
+ */
4006
+ private processReplayBatch;
4007
+ private getEventStoreId;
4008
+ private getEventFilter;
4009
+ private scheduleReplayAlarm;
4010
+ }
4011
+
3091
4012
  interface ConnectionListOptions {
3092
4013
  limit?: number;
3093
4014
  offset?: number;
@@ -4204,6 +5125,178 @@ declare const routes: hono_hono_base.HonoBase<{
4204
5125
  status: 200;
4205
5126
  };
4206
5127
  };
5128
+ } & {
5129
+ "/event-stores/:eventStoreName/outbox-dlq": {
5130
+ $get: {
5131
+ input: {
5132
+ param: {
5133
+ eventStoreName: string;
5134
+ };
5135
+ } & {
5136
+ query: {
5137
+ limit?: string | undefined;
5138
+ offset?: string | undefined;
5139
+ };
5140
+ };
5141
+ output: {
5142
+ error: "UNAUTHORIZED";
5143
+ message: "Unauthorized: Organization ID not found in authentication context";
5144
+ };
5145
+ outputFormat: "json";
5146
+ status: 401;
5147
+ } | {
5148
+ input: {
5149
+ param: {
5150
+ eventStoreName: string;
5151
+ };
5152
+ } & {
5153
+ query: {
5154
+ limit?: string | undefined;
5155
+ offset?: string | undefined;
5156
+ };
5157
+ };
5158
+ output: {
5159
+ entries: {
5160
+ id: number;
5161
+ streamId: string;
5162
+ streamPosition: number;
5163
+ globalPosition: number;
5164
+ messageId: string;
5165
+ messageType: string;
5166
+ messageData: {
5167
+ [x: string]: hono_utils_types.JSONValue;
5168
+ };
5169
+ messageMetadata: {
5170
+ [x: string]: hono_utils_types.JSONValue;
5171
+ };
5172
+ messageSchemaVersion: string;
5173
+ transactionId: string;
5174
+ totalAttempts: number;
5175
+ lastError: string | null;
5176
+ dlqReason: "max_publish_retries" | "eventbus_unreachable" | "manual" | "subscriber_deleted";
5177
+ originalCreatedAt: string;
5178
+ movedToDlqAt: string;
5179
+ }[];
5180
+ pagination: {
5181
+ limit: number;
5182
+ offset: number;
5183
+ hasMore: boolean;
5184
+ total?: number | undefined;
5185
+ };
5186
+ };
5187
+ outputFormat: "json";
5188
+ status: 200;
5189
+ };
5190
+ };
5191
+ } & {
5192
+ "/event-stores/:eventStoreName/outbox-dlq/:entryId/retry": {
5193
+ $post: {
5194
+ input: {
5195
+ param: {
5196
+ eventStoreName: string;
5197
+ entryId: string;
5198
+ };
5199
+ };
5200
+ output: {
5201
+ error: "UNAUTHORIZED";
5202
+ message: "Unauthorized: Organization ID not found in authentication context";
5203
+ };
5204
+ outputFormat: "json";
5205
+ status: 401;
5206
+ } | {
5207
+ input: {
5208
+ param: {
5209
+ eventStoreName: string;
5210
+ entryId: string;
5211
+ };
5212
+ };
5213
+ output: {
5214
+ success: boolean;
5215
+ entryId: number;
5216
+ };
5217
+ outputFormat: "json";
5218
+ status: 200;
5219
+ } | {
5220
+ input: {
5221
+ param: {
5222
+ eventStoreName: string;
5223
+ entryId: string;
5224
+ };
5225
+ };
5226
+ output: {
5227
+ error: "Not found";
5228
+ };
5229
+ outputFormat: "json";
5230
+ status: 404;
5231
+ };
5232
+ };
5233
+ } & {
5234
+ "/event-stores/:eventStoreName/outbox-dlq/retry-all": {
5235
+ $post: {
5236
+ input: {
5237
+ param: {
5238
+ eventStoreName: string;
5239
+ };
5240
+ };
5241
+ output: {
5242
+ error: "UNAUTHORIZED";
5243
+ message: "Unauthorized: Organization ID not found in authentication context";
5244
+ };
5245
+ outputFormat: "json";
5246
+ status: 401;
5247
+ } | {
5248
+ input: {
5249
+ param: {
5250
+ eventStoreName: string;
5251
+ };
5252
+ };
5253
+ output: {
5254
+ success: boolean;
5255
+ count: number;
5256
+ };
5257
+ outputFormat: "json";
5258
+ status: 200;
5259
+ };
5260
+ };
5261
+ } & {
5262
+ "/event-stores/:eventStoreName/outbox-dlq/:entryId": {
5263
+ $delete: {
5264
+ input: {
5265
+ param: {
5266
+ eventStoreName: string;
5267
+ entryId: string;
5268
+ };
5269
+ };
5270
+ output: {};
5271
+ outputFormat: string;
5272
+ status: 204;
5273
+ } | {
5274
+ input: {
5275
+ param: {
5276
+ eventStoreName: string;
5277
+ entryId: string;
5278
+ };
5279
+ };
5280
+ output: {
5281
+ error: "UNAUTHORIZED";
5282
+ message: "Unauthorized: Organization ID not found in authentication context";
5283
+ };
5284
+ outputFormat: "json";
5285
+ status: 401;
5286
+ } | {
5287
+ input: {
5288
+ param: {
5289
+ eventStoreName: string;
5290
+ entryId: string;
5291
+ };
5292
+ };
5293
+ output: {
5294
+ error: "Not found";
5295
+ };
5296
+ outputFormat: "json";
5297
+ status: 404;
5298
+ };
5299
+ };
4207
5300
  }, "/api"> | hono_types.MergeSchemaPath<{
4208
5301
  "/event-stores/:eventStoreName/subscribe": {
4209
5302
  $post: {
@@ -4270,11 +5363,10 @@ declare const routes: hono_hono_base.HonoBase<{
4270
5363
  };
4271
5364
  };
4272
5365
  output: {
4273
- subscriptionId: string;
5366
+ subscriberId: string;
4274
5367
  status: "ACTIVE" | "SUSPENDED" | "ERROR" | "INITIALIZING" | "DELETED";
4275
5368
  eventStoreName: string;
4276
5369
  eventFilter: string;
4277
- subscriberId: string;
4278
5370
  subscriberType: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket";
4279
5371
  createdAt: string;
4280
5372
  updatedAt: string;
@@ -4284,12 +5376,87 @@ declare const routes: hono_hono_base.HonoBase<{
4284
5376
  retryCount?: number | undefined;
4285
5377
  nextRetryAt?: string | undefined;
4286
5378
  } | undefined;
5379
+ subscriberConfig?: {
5380
+ [x: string]: any;
5381
+ } | undefined;
4287
5382
  lastProcessedEventGlobalPosition?: number | undefined;
4288
5383
  isExistingSubscription?: boolean | undefined;
4289
5384
  message?: string | undefined;
4290
5385
  };
4291
5386
  outputFormat: "json";
4292
- status: 200;
5387
+ status: 200;
5388
+ } | {
5389
+ input: {
5390
+ param: {
5391
+ eventStoreName: string;
5392
+ };
5393
+ } & {
5394
+ json: {
5395
+ eventFilter: string | string[];
5396
+ subscriber: {
5397
+ type: "durable_object";
5398
+ config: {
5399
+ namespace: string;
5400
+ id: string;
5401
+ retryPolicy?: {
5402
+ maxAttempts: number;
5403
+ backoffMinutes: number;
5404
+ } | undefined;
5405
+ };
5406
+ } | {
5407
+ type: "webhook";
5408
+ config: {
5409
+ url: string;
5410
+ retryPolicy?: {
5411
+ maxAttempts: number;
5412
+ backoffMinutes: number;
5413
+ } | undefined;
5414
+ headers?: Record<string, string> | undefined;
5415
+ timeoutMs?: number | undefined;
5416
+ };
5417
+ } | {
5418
+ type: "queue";
5419
+ config: {
5420
+ queueName: string;
5421
+ retryPolicy?: {
5422
+ maxAttempts: number;
5423
+ backoffMinutes: number;
5424
+ } | undefined;
5425
+ region?: string | undefined;
5426
+ batchSize?: number | undefined;
5427
+ };
5428
+ } | {
5429
+ type: "cloudflare_workflow";
5430
+ config: {
5431
+ bindingName: string;
5432
+ retryPolicy?: {
5433
+ maxAttempts: number;
5434
+ backoffMinutes: number;
5435
+ } | undefined;
5436
+ };
5437
+ } | {
5438
+ type: "websocket";
5439
+ config: {
5440
+ managerId: string;
5441
+ retryPolicy?: {
5442
+ maxAttempts: number;
5443
+ backoffMinutes: number;
5444
+ } | undefined;
5445
+ };
5446
+ };
5447
+ subscriberId?: string | undefined;
5448
+ initialPosition?: "latest" | "earliest" | undefined;
5449
+ };
5450
+ };
5451
+ output: {
5452
+ error: string;
5453
+ message: string;
5454
+ details?: {
5455
+ [x: string]: any;
5456
+ } | undefined;
5457
+ };
5458
+ outputFormat: "json";
5459
+ status: 400;
4293
5460
  } | {
4294
5461
  input: {
4295
5462
  param: {
@@ -4361,7 +5528,7 @@ declare const routes: hono_hono_base.HonoBase<{
4361
5528
  } | undefined;
4362
5529
  };
4363
5530
  outputFormat: "json";
4364
- status: 400;
5531
+ status: 401;
4365
5532
  } | {
4366
5533
  input: {
4367
5534
  param: {
@@ -4433,7 +5600,7 @@ declare const routes: hono_hono_base.HonoBase<{
4433
5600
  } | undefined;
4434
5601
  };
4435
5602
  outputFormat: "json";
4436
- status: 401;
5603
+ status: 404;
4437
5604
  } | {
4438
5605
  input: {
4439
5606
  param: {
@@ -4505,68 +5672,330 @@ declare const routes: hono_hono_base.HonoBase<{
4505
5672
  } | undefined;
4506
5673
  };
4507
5674
  outputFormat: "json";
4508
- status: 404;
5675
+ status: 500;
5676
+ };
5677
+ };
5678
+ } & {
5679
+ "/event-stores/:eventStoreName/subscriptions/:subscriberId": {
5680
+ $delete: {
5681
+ input: {
5682
+ param: {
5683
+ eventStoreName: string;
5684
+ subscriberId: string;
5685
+ };
5686
+ };
5687
+ output: {
5688
+ error: string;
5689
+ message: string;
5690
+ details?: {
5691
+ [x: string]: any;
5692
+ } | undefined;
5693
+ };
5694
+ outputFormat: "json";
5695
+ status: 401;
5696
+ } | {
5697
+ input: {
5698
+ param: {
5699
+ eventStoreName: string;
5700
+ subscriberId: string;
5701
+ };
5702
+ };
5703
+ output: {
5704
+ error: string;
5705
+ message: string;
5706
+ details?: {
5707
+ [x: string]: any;
5708
+ } | undefined;
5709
+ };
5710
+ outputFormat: "json";
5711
+ status: 404;
5712
+ } | {
5713
+ input: {
5714
+ param: {
5715
+ eventStoreName: string;
5716
+ subscriberId: string;
5717
+ };
5718
+ };
5719
+ output: {
5720
+ error: string;
5721
+ message: string;
5722
+ details?: {
5723
+ [x: string]: any;
5724
+ } | undefined;
5725
+ };
5726
+ outputFormat: "json";
5727
+ status: 500;
5728
+ } | {
5729
+ input: {
5730
+ param: {
5731
+ eventStoreName: string;
5732
+ subscriberId: string;
5733
+ };
5734
+ };
5735
+ output: {
5736
+ success: boolean;
5737
+ message: string;
5738
+ };
5739
+ outputFormat: "json";
5740
+ status: 200;
5741
+ };
5742
+ };
5743
+ } & {
5744
+ "/event-stores/:eventStoreName/subscriptions": {
5745
+ $get: {
5746
+ input: {
5747
+ param: {
5748
+ eventStoreName: string;
5749
+ };
5750
+ } & {
5751
+ query: {
5752
+ subscriberType?: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket" | undefined;
5753
+ eventFilter?: string | undefined;
5754
+ limit?: string | undefined;
5755
+ offset?: string | undefined;
5756
+ };
5757
+ };
5758
+ output: {
5759
+ error: string;
5760
+ message: string;
5761
+ details?: {
5762
+ [x: string]: any;
5763
+ } | undefined;
5764
+ };
5765
+ outputFormat: "json";
5766
+ status: 401;
5767
+ } | {
5768
+ input: {
5769
+ param: {
5770
+ eventStoreName: string;
5771
+ };
5772
+ } & {
5773
+ query: {
5774
+ subscriberType?: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket" | undefined;
5775
+ eventFilter?: string | undefined;
5776
+ limit?: string | undefined;
5777
+ offset?: string | undefined;
5778
+ };
5779
+ };
5780
+ output: {
5781
+ error: string;
5782
+ message: string;
5783
+ details?: {
5784
+ [x: string]: any;
5785
+ } | undefined;
5786
+ };
5787
+ outputFormat: "json";
5788
+ status: 404;
5789
+ } | {
5790
+ input: {
5791
+ param: {
5792
+ eventStoreName: string;
5793
+ };
5794
+ } & {
5795
+ query: {
5796
+ subscriberType?: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket" | undefined;
5797
+ eventFilter?: string | undefined;
5798
+ limit?: string | undefined;
5799
+ offset?: string | undefined;
5800
+ };
5801
+ };
5802
+ output: {
5803
+ error: string;
5804
+ message: string;
5805
+ details?: {
5806
+ [x: string]: any;
5807
+ } | undefined;
5808
+ };
5809
+ outputFormat: "json";
5810
+ status: 500;
5811
+ } | {
5812
+ input: {
5813
+ param: {
5814
+ eventStoreName: string;
5815
+ };
5816
+ } & {
5817
+ query: {
5818
+ subscriberType?: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket" | undefined;
5819
+ eventFilter?: string | undefined;
5820
+ limit?: string | undefined;
5821
+ offset?: string | undefined;
5822
+ };
5823
+ };
5824
+ output: {
5825
+ subscriptions: {
5826
+ subscriberId: string;
5827
+ status: "ACTIVE" | "SUSPENDED" | "ERROR" | "INITIALIZING" | "DELETED";
5828
+ eventStoreName: string;
5829
+ eventFilter: string;
5830
+ subscriberType: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket";
5831
+ createdAt: string;
5832
+ updatedAt: string;
5833
+ statusDetails?: {
5834
+ lastError?: string | undefined;
5835
+ lastErrorAt?: string | undefined;
5836
+ retryCount?: number | undefined;
5837
+ nextRetryAt?: string | undefined;
5838
+ } | undefined;
5839
+ subscriberConfig?: {
5840
+ [x: string]: any;
5841
+ } | undefined;
5842
+ lastProcessedEventGlobalPosition?: number | undefined;
5843
+ isExistingSubscription?: boolean | undefined;
5844
+ message?: string | undefined;
5845
+ }[];
5846
+ totalCount: number;
5847
+ };
5848
+ outputFormat: "json";
5849
+ status: 200;
5850
+ };
5851
+ };
5852
+ } & {
5853
+ "/event-stores/:eventStoreName/subscriptions/:subscriberId": {
5854
+ $get: {
5855
+ input: {
5856
+ param: {
5857
+ eventStoreName: string;
5858
+ subscriberId: string;
5859
+ };
5860
+ };
5861
+ output: {
5862
+ subscriberId: string;
5863
+ status: "ACTIVE" | "SUSPENDED" | "ERROR" | "INITIALIZING" | "DELETED";
5864
+ eventStoreName: string;
5865
+ eventFilter: string;
5866
+ subscriberType: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket";
5867
+ createdAt: string;
5868
+ updatedAt: string;
5869
+ statusDetails?: {
5870
+ lastError?: string | undefined;
5871
+ lastErrorAt?: string | undefined;
5872
+ retryCount?: number | undefined;
5873
+ nextRetryAt?: string | undefined;
5874
+ } | undefined;
5875
+ subscriberConfig?: {
5876
+ [x: string]: any;
5877
+ } | undefined;
5878
+ lastProcessedEventGlobalPosition?: number | undefined;
5879
+ isExistingSubscription?: boolean | undefined;
5880
+ message?: string | undefined;
5881
+ };
5882
+ outputFormat: "json";
5883
+ status: 200;
5884
+ } | {
5885
+ input: {
5886
+ param: {
5887
+ eventStoreName: string;
5888
+ subscriberId: string;
5889
+ };
5890
+ };
5891
+ output: {
5892
+ error: string;
5893
+ message: string;
5894
+ details?: {
5895
+ [x: string]: any;
5896
+ } | undefined;
5897
+ };
5898
+ outputFormat: "json";
5899
+ status: 401;
5900
+ } | {
5901
+ input: {
5902
+ param: {
5903
+ eventStoreName: string;
5904
+ subscriberId: string;
5905
+ };
5906
+ };
5907
+ output: {
5908
+ error: string;
5909
+ message: string;
5910
+ details?: {
5911
+ [x: string]: any;
5912
+ } | undefined;
5913
+ };
5914
+ outputFormat: "json";
5915
+ status: 404;
5916
+ } | {
5917
+ input: {
5918
+ param: {
5919
+ eventStoreName: string;
5920
+ subscriberId: string;
5921
+ };
5922
+ };
5923
+ output: {
5924
+ error: string;
5925
+ message: string;
5926
+ details?: {
5927
+ [x: string]: any;
5928
+ } | undefined;
5929
+ };
5930
+ outputFormat: "json";
5931
+ status: 500;
5932
+ };
5933
+ };
5934
+ } & {
5935
+ "/event-stores/:eventStoreName/subscriptions/:subscriberId": {
5936
+ $patch: {
5937
+ input: {
5938
+ param: {
5939
+ eventStoreName: string;
5940
+ subscriberId: string;
5941
+ };
5942
+ } & {
5943
+ json: {
5944
+ eventFilter?: string | string[] | undefined;
5945
+ subscriberConfig?: Record<string, unknown> | undefined;
5946
+ retryPolicy?: {
5947
+ strategy: "fixed" | "exponential" | "linear";
5948
+ maxAttempts: number;
5949
+ initialDelayMs: number;
5950
+ maxDelayMs: number;
5951
+ multiplier?: number | undefined;
5952
+ jitterPercent?: number | undefined;
5953
+ } | undefined;
5954
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
5955
+ };
5956
+ };
5957
+ output: {
5958
+ subscriberId: string;
5959
+ status: "ACTIVE" | "SUSPENDED" | "ERROR" | "INITIALIZING" | "DELETED";
5960
+ eventStoreName: string;
5961
+ eventFilter: string;
5962
+ subscriberType: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket";
5963
+ createdAt: string;
5964
+ updatedAt: string;
5965
+ statusDetails?: {
5966
+ lastError?: string | undefined;
5967
+ lastErrorAt?: string | undefined;
5968
+ retryCount?: number | undefined;
5969
+ nextRetryAt?: string | undefined;
5970
+ } | undefined;
5971
+ subscriberConfig?: {
5972
+ [x: string]: any;
5973
+ } | undefined;
5974
+ lastProcessedEventGlobalPosition?: number | undefined;
5975
+ isExistingSubscription?: boolean | undefined;
5976
+ message?: string | undefined;
5977
+ };
5978
+ outputFormat: "json";
5979
+ status: 200;
4509
5980
  } | {
4510
5981
  input: {
4511
5982
  param: {
4512
5983
  eventStoreName: string;
5984
+ subscriberId: string;
4513
5985
  };
4514
5986
  } & {
4515
5987
  json: {
4516
- eventFilter: string | string[];
4517
- subscriber: {
4518
- type: "durable_object";
4519
- config: {
4520
- namespace: string;
4521
- id: string;
4522
- retryPolicy?: {
4523
- maxAttempts: number;
4524
- backoffMinutes: number;
4525
- } | undefined;
4526
- };
4527
- } | {
4528
- type: "webhook";
4529
- config: {
4530
- url: string;
4531
- retryPolicy?: {
4532
- maxAttempts: number;
4533
- backoffMinutes: number;
4534
- } | undefined;
4535
- headers?: Record<string, string> | undefined;
4536
- timeoutMs?: number | undefined;
4537
- };
4538
- } | {
4539
- type: "queue";
4540
- config: {
4541
- queueName: string;
4542
- retryPolicy?: {
4543
- maxAttempts: number;
4544
- backoffMinutes: number;
4545
- } | undefined;
4546
- region?: string | undefined;
4547
- batchSize?: number | undefined;
4548
- };
4549
- } | {
4550
- type: "cloudflare_workflow";
4551
- config: {
4552
- bindingName: string;
4553
- retryPolicy?: {
4554
- maxAttempts: number;
4555
- backoffMinutes: number;
4556
- } | undefined;
4557
- };
4558
- } | {
4559
- type: "websocket";
4560
- config: {
4561
- managerId: string;
4562
- retryPolicy?: {
4563
- maxAttempts: number;
4564
- backoffMinutes: number;
4565
- } | undefined;
4566
- };
4567
- };
4568
- subscriberId?: string | undefined;
4569
- initialPosition?: "latest" | "earliest" | undefined;
5988
+ eventFilter?: string | string[] | undefined;
5989
+ subscriberConfig?: Record<string, unknown> | undefined;
5990
+ retryPolicy?: {
5991
+ strategy: "fixed" | "exponential" | "linear";
5992
+ maxAttempts: number;
5993
+ initialDelayMs: number;
5994
+ maxDelayMs: number;
5995
+ multiplier?: number | undefined;
5996
+ jitterPercent?: number | undefined;
5997
+ } | undefined;
5998
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
4570
5999
  };
4571
6000
  };
4572
6001
  output: {
@@ -4577,16 +6006,26 @@ declare const routes: hono_hono_base.HonoBase<{
4577
6006
  } | undefined;
4578
6007
  };
4579
6008
  outputFormat: "json";
4580
- status: 500;
4581
- };
4582
- };
4583
- } & {
4584
- "/event-stores/:eventStoreName/subscriptions/:subscriptionId": {
4585
- $delete: {
6009
+ status: 400;
6010
+ } | {
4586
6011
  input: {
4587
6012
  param: {
4588
6013
  eventStoreName: string;
4589
- subscriptionId: string;
6014
+ subscriberId: string;
6015
+ };
6016
+ } & {
6017
+ json: {
6018
+ eventFilter?: string | string[] | undefined;
6019
+ subscriberConfig?: Record<string, unknown> | undefined;
6020
+ retryPolicy?: {
6021
+ strategy: "fixed" | "exponential" | "linear";
6022
+ maxAttempts: number;
6023
+ initialDelayMs: number;
6024
+ maxDelayMs: number;
6025
+ multiplier?: number | undefined;
6026
+ jitterPercent?: number | undefined;
6027
+ } | undefined;
6028
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
4590
6029
  };
4591
6030
  };
4592
6031
  output: {
@@ -4602,7 +6041,21 @@ declare const routes: hono_hono_base.HonoBase<{
4602
6041
  input: {
4603
6042
  param: {
4604
6043
  eventStoreName: string;
4605
- subscriptionId: string;
6044
+ subscriberId: string;
6045
+ };
6046
+ } & {
6047
+ json: {
6048
+ eventFilter?: string | string[] | undefined;
6049
+ subscriberConfig?: Record<string, unknown> | undefined;
6050
+ retryPolicy?: {
6051
+ strategy: "fixed" | "exponential" | "linear";
6052
+ maxAttempts: number;
6053
+ initialDelayMs: number;
6054
+ maxDelayMs: number;
6055
+ multiplier?: number | undefined;
6056
+ jitterPercent?: number | undefined;
6057
+ } | undefined;
6058
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
4606
6059
  };
4607
6060
  };
4608
6061
  output: {
@@ -4618,7 +6071,21 @@ declare const routes: hono_hono_base.HonoBase<{
4618
6071
  input: {
4619
6072
  param: {
4620
6073
  eventStoreName: string;
4621
- subscriptionId: string;
6074
+ subscriberId: string;
6075
+ };
6076
+ } & {
6077
+ json: {
6078
+ eventFilter?: string | string[] | undefined;
6079
+ subscriberConfig?: Record<string, unknown> | undefined;
6080
+ retryPolicy?: {
6081
+ strategy: "fixed" | "exponential" | "linear";
6082
+ maxAttempts: number;
6083
+ initialDelayMs: number;
6084
+ maxDelayMs: number;
6085
+ multiplier?: number | undefined;
6086
+ jitterPercent?: number | undefined;
6087
+ } | undefined;
6088
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
4622
6089
  };
4623
6090
  };
4624
6091
  output: {
@@ -4634,30 +6101,73 @@ declare const routes: hono_hono_base.HonoBase<{
4634
6101
  input: {
4635
6102
  param: {
4636
6103
  eventStoreName: string;
4637
- subscriptionId: string;
6104
+ subscriberId: string;
6105
+ };
6106
+ } & {
6107
+ json: {
6108
+ eventFilter?: string | string[] | undefined;
6109
+ subscriberConfig?: Record<string, unknown> | undefined;
6110
+ retryPolicy?: {
6111
+ strategy: "fixed" | "exponential" | "linear";
6112
+ maxAttempts: number;
6113
+ initialDelayMs: number;
6114
+ maxDelayMs: number;
6115
+ multiplier?: number | undefined;
6116
+ jitterPercent?: number | undefined;
6117
+ } | undefined;
6118
+ status?: "ACTIVE" | "SUSPENDED" | undefined;
4638
6119
  };
4639
6120
  };
4640
6121
  output: {
4641
- success: boolean;
6122
+ error: string;
4642
6123
  message: string;
6124
+ details?: {
6125
+ [x: string]: any;
6126
+ } | undefined;
4643
6127
  };
4644
6128
  outputFormat: "json";
4645
- status: 200;
6129
+ status: 409;
4646
6130
  };
4647
6131
  };
4648
6132
  } & {
4649
- "/event-stores/:eventStoreName/subscriptions": {
4650
- $get: {
6133
+ "/event-stores/:eventStoreName/subscriptions/:subscriberId/replay": {
6134
+ $post: {
4651
6135
  input: {
4652
6136
  param: {
4653
6137
  eventStoreName: string;
6138
+ subscriberId: string;
4654
6139
  };
4655
6140
  } & {
4656
- query: {
4657
- subscriberType?: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket" | undefined;
4658
- eventFilter?: string | undefined;
4659
- limit?: string | undefined;
4660
- offset?: string | undefined;
6141
+ json: {
6142
+ fromGlobalPosition?: number | undefined;
6143
+ fromCreatedAt?: string | undefined;
6144
+ toGlobalPosition?: number | undefined;
6145
+ toCreatedAt?: string | undefined;
6146
+ eventTypes?: string[] | undefined;
6147
+ };
6148
+ };
6149
+ output: {
6150
+ error: string;
6151
+ message: string;
6152
+ details?: {
6153
+ [x: string]: any;
6154
+ } | undefined;
6155
+ };
6156
+ outputFormat: "json";
6157
+ status: 400;
6158
+ } | {
6159
+ input: {
6160
+ param: {
6161
+ eventStoreName: string;
6162
+ subscriberId: string;
6163
+ };
6164
+ } & {
6165
+ json: {
6166
+ fromGlobalPosition?: number | undefined;
6167
+ fromCreatedAt?: string | undefined;
6168
+ toGlobalPosition?: number | undefined;
6169
+ toCreatedAt?: string | undefined;
6170
+ eventTypes?: string[] | undefined;
4661
6171
  };
4662
6172
  };
4663
6173
  output: {
@@ -4673,13 +6183,15 @@ declare const routes: hono_hono_base.HonoBase<{
4673
6183
  input: {
4674
6184
  param: {
4675
6185
  eventStoreName: string;
6186
+ subscriberId: string;
4676
6187
  };
4677
6188
  } & {
4678
- query: {
4679
- subscriberType?: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket" | undefined;
4680
- eventFilter?: string | undefined;
4681
- limit?: string | undefined;
4682
- offset?: string | undefined;
6189
+ json: {
6190
+ fromGlobalPosition?: number | undefined;
6191
+ fromCreatedAt?: string | undefined;
6192
+ toGlobalPosition?: number | undefined;
6193
+ toCreatedAt?: string | undefined;
6194
+ eventTypes?: string[] | undefined;
4683
6195
  };
4684
6196
  };
4685
6197
  output: {
@@ -4695,13 +6207,15 @@ declare const routes: hono_hono_base.HonoBase<{
4695
6207
  input: {
4696
6208
  param: {
4697
6209
  eventStoreName: string;
6210
+ subscriberId: string;
4698
6211
  };
4699
6212
  } & {
4700
- query: {
4701
- subscriberType?: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket" | undefined;
4702
- eventFilter?: string | undefined;
4703
- limit?: string | undefined;
4704
- offset?: string | undefined;
6213
+ json: {
6214
+ fromGlobalPosition?: number | undefined;
6215
+ fromCreatedAt?: string | undefined;
6216
+ toGlobalPosition?: number | undefined;
6217
+ toCreatedAt?: string | undefined;
6218
+ eventTypes?: string[] | undefined;
4705
6219
  };
4706
6220
  };
4707
6221
  output: {
@@ -4717,76 +6231,57 @@ declare const routes: hono_hono_base.HonoBase<{
4717
6231
  input: {
4718
6232
  param: {
4719
6233
  eventStoreName: string;
6234
+ subscriberId: string;
4720
6235
  };
4721
6236
  } & {
4722
- query: {
4723
- subscriberType?: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket" | undefined;
4724
- eventFilter?: string | undefined;
4725
- limit?: string | undefined;
4726
- offset?: string | undefined;
6237
+ json: {
6238
+ fromGlobalPosition?: number | undefined;
6239
+ fromCreatedAt?: string | undefined;
6240
+ toGlobalPosition?: number | undefined;
6241
+ toCreatedAt?: string | undefined;
6242
+ eventTypes?: string[] | undefined;
4727
6243
  };
4728
6244
  };
4729
6245
  output: {
4730
- subscriptions: {
4731
- subscriptionId: string;
4732
- status: "ACTIVE" | "SUSPENDED" | "ERROR" | "INITIALIZING" | "DELETED";
4733
- eventStoreName: string;
4734
- eventFilter: string;
4735
- subscriberId: string;
4736
- subscriberType: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket";
4737
- createdAt: string;
4738
- updatedAt: string;
4739
- statusDetails?: {
4740
- lastError?: string | undefined;
4741
- lastErrorAt?: string | undefined;
4742
- retryCount?: number | undefined;
4743
- nextRetryAt?: string | undefined;
4744
- } | undefined;
4745
- lastProcessedEventGlobalPosition?: number | undefined;
4746
- isExistingSubscription?: boolean | undefined;
4747
- message?: string | undefined;
4748
- }[];
4749
- totalCount: number;
6246
+ error: string;
6247
+ message: string;
6248
+ details?: {
6249
+ [x: string]: any;
6250
+ } | undefined;
4750
6251
  };
4751
6252
  outputFormat: "json";
4752
- status: 200;
4753
- };
4754
- };
4755
- } & {
4756
- "/event-stores/:eventStoreName/subscriptions/:subscriptionId": {
4757
- $get: {
6253
+ status: 409;
6254
+ } | {
4758
6255
  input: {
4759
6256
  param: {
4760
6257
  eventStoreName: string;
4761
- subscriptionId: string;
6258
+ subscriberId: string;
6259
+ };
6260
+ } & {
6261
+ json: {
6262
+ fromGlobalPosition?: number | undefined;
6263
+ fromCreatedAt?: string | undefined;
6264
+ toGlobalPosition?: number | undefined;
6265
+ toCreatedAt?: string | undefined;
6266
+ eventTypes?: string[] | undefined;
4762
6267
  };
4763
6268
  };
4764
6269
  output: {
4765
- subscriptionId: string;
4766
- status: "ACTIVE" | "SUSPENDED" | "ERROR" | "INITIALIZING" | "DELETED";
4767
- eventStoreName: string;
4768
- eventFilter: string;
4769
- subscriberId: string;
4770
- subscriberType: "durable_object" | "webhook" | "queue" | "cloudflare_workflow" | "websocket";
4771
- createdAt: string;
4772
- updatedAt: string;
4773
- statusDetails?: {
4774
- lastError?: string | undefined;
4775
- lastErrorAt?: string | undefined;
4776
- retryCount?: number | undefined;
4777
- nextRetryAt?: string | undefined;
4778
- } | undefined;
4779
- lastProcessedEventGlobalPosition?: number | undefined;
4780
- isExistingSubscription?: boolean | undefined;
4781
- message?: string | undefined;
6270
+ message: string;
6271
+ fromPosition: number;
6272
+ estimatedEvents: number;
4782
6273
  };
4783
6274
  outputFormat: "json";
4784
- status: 200;
4785
- } | {
6275
+ status: 202;
6276
+ };
6277
+ };
6278
+ } & {
6279
+ "/event-stores/:eventStoreName/subscriptions/:subscriberId/replay": {
6280
+ $get: {
4786
6281
  input: {
4787
6282
  param: {
4788
6283
  eventStoreName: string;
4789
- subscriptionId: string;
6284
+ subscriberId: string;
4790
6285
  };
4791
6286
  };
4792
6287
  output: {
@@ -4802,7 +6297,7 @@ declare const routes: hono_hono_base.HonoBase<{
4802
6297
  input: {
4803
6298
  param: {
4804
6299
  eventStoreName: string;
4805
- subscriptionId: string;
6300
+ subscriberId: string;
4806
6301
  };
4807
6302
  };
4808
6303
  output: {
@@ -4818,7 +6313,7 @@ declare const routes: hono_hono_base.HonoBase<{
4818
6313
  input: {
4819
6314
  param: {
4820
6315
  eventStoreName: string;
4821
- subscriptionId: string;
6316
+ subscriberId: string;
4822
6317
  };
4823
6318
  };
4824
6319
  output: {
@@ -4830,6 +6325,24 @@ declare const routes: hono_hono_base.HonoBase<{
4830
6325
  };
4831
6326
  outputFormat: "json";
4832
6327
  status: 500;
6328
+ } | {
6329
+ input: {
6330
+ param: {
6331
+ eventStoreName: string;
6332
+ subscriberId: string;
6333
+ };
6334
+ };
6335
+ output: {
6336
+ inProgress: boolean;
6337
+ startPosition: number | null;
6338
+ targetPosition: number | null;
6339
+ currentPosition: number;
6340
+ processedCount: number;
6341
+ estimatedEvents: number;
6342
+ startedAt: string | null;
6343
+ };
6344
+ outputFormat: "json";
6345
+ status: 200;
4833
6346
  };
4834
6347
  };
4835
6348
  }, "/api"> | hono_types.MergeSchemaPath<{
@@ -5011,7 +6524,7 @@ declare const routes: hono_hono_base.HonoBase<{
5011
6524
  status: 200;
5012
6525
  };
5013
6526
  };
5014
- }, "/api">) & {
6527
+ }, "/api"> | hono_types.MergeSchemaPath<{}, "/">) & {
5015
6528
  "/api/reference": {
5016
6529
  $get: {
5017
6530
  input: {};
@@ -5021,7 +6534,13 @@ declare const routes: hono_hono_base.HonoBase<{
5021
6534
  };
5022
6535
  };
5023
6536
  }, "/">;
6537
+ /**
6538
+ * Get the OpenAPI specification for the platform API.
6539
+ * This is used by documentation generators to extract the API schema at build time.
6540
+ * @returns The OpenAPI 3.0 specification object
6541
+ */
6542
+ declare function getOpenAPISpec(): Record<string, unknown>;
5024
6543
 
5025
6544
  type AppType = typeof routes;
5026
6545
 
5027
- export { type AppType, type BaseSubscriberConfig, type CloudflareWorkflowConfig, type DurableObjectConfig, EventBusAPI, EventBusDurableObject, type EventFilter, EventStoreAPI, EventStoreDurableObject, EventStoreManagerDurableObject, type EventType, ManagementAPI, type QueueConfig, SubscriberType, WebSocketManagerDurableObject, WebSocketsAPI, type WebhookConfig, type WildcardPattern, routes as default };
6546
+ export { type AppType, type BaseSubscriberConfig, type CloudflareWorkflowConfig, type DurableObjectConfig, EventBusAPI, EventBusDurableObject, type EventFilter, EventStoreAPI, EventStoreDurableObject, EventStoreManagerDurableObject, type EventType, ManagementAPI, type QueueConfig, SubscriberDurableObject, SubscriberType, WebSocketManagerDurableObject, WebSocketsAPI, type WebhookConfig, type WildcardPattern, routes as default, getOpenAPISpec };