durability 5.1.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +154 -21
  2. package/dist/{durability-alarms.d.ts → alarms/index.d.ts} +13 -5
  3. package/dist/{durability-alarms.js → alarms/index.js} +85 -74
  4. package/dist/alarms/migrations.d.ts +9 -0
  5. package/dist/alarms/migrations.js +133 -0
  6. package/dist/experimental.d.ts +10 -10
  7. package/dist/experimental.js +7 -7
  8. package/dist/{fanout.d.ts → fanout/index.d.ts} +13 -6
  9. package/dist/{fanout.js → fanout/index.js} +91 -83
  10. package/dist/fanout/migrations.d.ts +9 -0
  11. package/dist/fanout/migrations.js +181 -0
  12. package/dist/{stored-message.d.ts → fanout/stored-message.d.ts} +1 -1
  13. package/dist/index.d.ts +14 -9
  14. package/dist/index.js +13 -8
  15. package/dist/{log.d.ts → log/index.d.ts} +27 -20
  16. package/dist/{log.js → log/index.js} +200 -166
  17. package/dist/log/migrations.d.ts +18 -0
  18. package/dist/log/migrations.js +297 -0
  19. package/dist/{memoize.d.ts → memoize/index.d.ts} +1 -1
  20. package/dist/{memoize.js → memoize/index.js} +23 -21
  21. package/dist/memoize/migrations.d.ts +10 -0
  22. package/dist/memoize/migrations.js +21 -0
  23. package/dist/migrations.d.ts +0 -111
  24. package/dist/migrations.js +12 -628
  25. package/dist/{durability.d.ts → operations/index.d.ts} +13 -5
  26. package/dist/{durability.js → operations/index.js} +76 -70
  27. package/dist/operations/migrations.d.ts +10 -0
  28. package/dist/operations/migrations.js +150 -0
  29. package/dist/{outbox.d.ts → outbox/index.d.ts} +4 -4
  30. package/dist/{outbox.js → outbox/index.js} +35 -77
  31. package/dist/outbox/migrations.d.ts +9 -0
  32. package/dist/outbox/migrations.js +43 -0
  33. package/dist/policy.d.ts +19 -19
  34. package/dist/policy.js +13 -12
  35. package/dist/{routing-client.js → routing/client.js} +1 -1
  36. package/dist/{routing.d.ts → routing/index.d.ts} +3 -3
  37. package/dist/{routing.js → routing/index.js} +3 -3
  38. package/dist/{load.d.ts → routing/load.d.ts} +1 -1
  39. package/dist/{schedule.d.ts → schedule/index.d.ts} +16 -8
  40. package/dist/{schedule.js → schedule/index.js} +97 -83
  41. package/dist/schedule/migrations.d.ts +9 -0
  42. package/dist/schedule/migrations.js +118 -0
  43. package/dist/{scheduler.d.ts → scheduler/index.d.ts} +75 -25
  44. package/dist/{scheduler.js → scheduler/index.js} +308 -70
  45. package/dist/{semaphore-client.d.ts → semaphore/client.d.ts} +1 -1
  46. package/dist/{semaphore-client.js → semaphore/client.js} +8 -7
  47. package/dist/{semaphore.d.ts → semaphore/index.d.ts} +10 -10
  48. package/dist/{semaphore.js → semaphore/index.js} +7 -7
  49. package/dist/{semaphore-leases.d.ts → semaphore/leases.d.ts} +17 -6
  50. package/dist/{semaphore-leases.js → semaphore/leases.js} +28 -12
  51. package/dist/semaphore/migrations.d.ts +18 -0
  52. package/dist/semaphore/migrations.js +444 -0
  53. package/dist/semaphore/protocol.d.ts +451 -0
  54. package/dist/semaphore/protocol.js +114 -0
  55. package/dist/semaphore/queue-store.d.ts +107 -0
  56. package/dist/semaphore/queue-store.js +258 -0
  57. package/dist/{semaphore-queue.d.ts → semaphore/queue.d.ts} +15 -5
  58. package/dist/{semaphore-queue.js → semaphore/queue.js} +105 -46
  59. package/dist/{semaphore-server.d.ts → semaphore/server.d.ts} +12 -4
  60. package/dist/{semaphore-server.js → semaphore/server.js} +56 -28
  61. package/dist/semaphore/store.d.ts +53 -0
  62. package/dist/semaphore/store.js +107 -0
  63. package/dist/serialization.d.ts +5 -0
  64. package/dist/serialization.js +41 -16
  65. package/dist/{client.d.ts → socket/client.d.ts} +3 -3
  66. package/dist/{client.js → socket/client.js} +4 -4
  67. package/dist/{socket.d.ts → socket/index.d.ts} +15 -4
  68. package/dist/{socket.js → socket/index.js} +66 -20
  69. package/dist/socket/migrations.d.ts +9 -0
  70. package/dist/socket/migrations.js +57 -0
  71. package/dist/{socket-protocol.d.ts → socket/protocol.d.ts} +1 -1
  72. package/dist/storage.d.ts +4 -0
  73. package/dist/storage.js +22 -15
  74. package/dist/{topology-client.d.ts → topology/client.d.ts} +2 -2
  75. package/dist/{topology-client.js → topology/client.js} +3 -3
  76. package/dist/{topology.d.ts → topology/index.d.ts} +17 -7
  77. package/dist/{topology.js → topology/index.js} +106 -72
  78. package/dist/topology/migrations.d.ts +10 -0
  79. package/dist/topology/migrations.js +138 -0
  80. package/dist/topology/snapshot.d.ts +50 -0
  81. package/dist/topology/snapshot.js +38 -0
  82. package/dist/{tracker.d.ts → tracker/index.d.ts} +3 -3
  83. package/dist/{tracker.js → tracker/index.js} +9 -9
  84. package/package.json +11 -11
  85. package/dist/semaphore-protocol.d.ts +0 -231
  86. package/dist/semaphore-protocol.js +0 -106
  87. package/dist/semaphore-queue-store.d.ts +0 -95
  88. package/dist/semaphore-queue-store.js +0 -252
  89. package/dist/semaphore-store.d.ts +0 -43
  90. package/dist/semaphore-store.js +0 -108
  91. package/dist/topology-snapshot.d.ts +0 -70
  92. package/dist/topology-snapshot.js +0 -48
  93. /package/dist/{stored-message.js → fanout/stored-message.js} +0 -0
  94. /package/dist/{routing-client.d.ts → routing/client.d.ts} +0 -0
  95. /package/dist/{load.js → routing/load.js} +0 -0
  96. /package/dist/{socket-protocol.js → socket/protocol.js} +0 -0
  97. /package/dist/{tracked-source.d.ts → tracker/source.d.ts} +0 -0
  98. /package/dist/{tracked-source.js → tracker/source.js} +0 -0
@@ -1,27 +1,22 @@
1
- import { z } from 'zod';
2
- import { RoutingLoad, type EnqueueResult, type LoadSnapshot } from './load.js';
3
- import { type SchedulerAttachment } from './scheduler.js';
1
+ import * as v from 'valibot';
2
+ import { RoutingLoad, type EnqueueResult, type LoadSnapshot } from '../routing/load.js';
3
+ import { type SchedulerAttachment } from '../scheduler/index.js';
4
4
  /**
5
5
  * One in-flight or settled range of offsets held by a consumer. A range is
6
6
  * redelivered under a fresh `batch_id`, so an ack from a previous holder is
7
7
  * rejected rather than advancing a range someone else now owns.
8
8
  */
9
- declare const logLeaseRowSchema: z.ZodObject<{
10
- batch_id: z.ZodString;
11
- consumer: z.ZodString;
12
- first_offset: z.ZodNumber;
13
- last_offset: z.ZodNumber;
14
- state: z.ZodEnum<{
15
- pending: "pending";
16
- active: "active";
17
- acked: "acked";
18
- skipped: "skipped";
19
- }>;
20
- attempt: z.ZodNumber;
21
- expires_at: z.ZodNumber;
22
- created_at: z.ZodNumber;
23
- }, z.core.$strip>;
24
- export type LogLeaseRow = z.infer<typeof logLeaseRowSchema>;
9
+ declare const logLeaseRowSchema: v.ObjectSchema<{
10
+ readonly batch_id: v.StringSchema<undefined>;
11
+ readonly consumer: v.StringSchema<undefined>;
12
+ readonly first_offset: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
13
+ readonly last_offset: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
14
+ readonly state: v.PicklistSchema<["active", "pending", "acked", "skipped"], undefined>;
15
+ readonly attempt: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
16
+ readonly expires_at: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
17
+ readonly created_at: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
18
+ }, undefined>;
19
+ export type LogLeaseRow = v.InferOutput<typeof logLeaseRowSchema>;
25
20
  export type LogBounds = {
26
21
  /**
27
22
  * Lowest readable offset, counting flushed segments that can be rehydrated.
@@ -60,6 +55,12 @@ export type LogReadOptions = {
60
55
  };
61
56
  /** One contiguous run of records leaving the object, oldest first. */
62
57
  export type LogSegment<Body = unknown> = {
58
+ /**
59
+ * The log always supplies its channel. Optional for legacy callers that
60
+ * construct segments themselves; omitted means `default`. Shared external
61
+ * storage must include the channel in the location it writes to.
62
+ */
63
+ channel?: string;
63
64
  firstOffset: number;
64
65
  lastOffset: number;
65
66
  records: LogRecord<Body>[];
@@ -109,6 +110,12 @@ export type LogRetention = {
109
110
  maxBytes?: number;
110
111
  };
111
112
  export type DurabilityLogConfig<Body = unknown> = SchedulerAttachment & {
113
+ /**
114
+ * Partitions records, offsets, cursors, cold segments, and leases, so
115
+ * several logs share one object without seeing each other. Defaults to
116
+ * `default`; one instance per channel may attach to a scheduler.
117
+ */
118
+ channel?: string;
112
119
  /** Without retention the log grows until the object's storage limit. */
113
120
  retention?: LogRetention;
114
121
  cold?: LogColdStorage<Body>;
@@ -135,7 +142,7 @@ export declare const maxLogBytes = 1073741824;
135
142
  export declare class DurabilityLog<Body = unknown> {
136
143
  #private;
137
144
  constructor(config: DurabilityLogConfig<Body>);
138
- static migrate(context: Pick<DurableObjectState, 'storage'>, target?: string | null): import("./migrations.js").DurabilityMigrationResult;
145
+ static migrate(context: Pick<DurableObjectState, 'storage'>, target?: string | null): import("../migrations.js").DurabilityMigrationResult;
139
146
  /**
140
147
  * Appends the batch atomically. Definite input rejections return
141
148
  * success:false; storage and commit uncertainty throws, so a caller never