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
@@ -9,54 +9,58 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _DurabilityFanout_instances, _DurabilityFanout_engine, _DurabilityFanout_routing, _DurabilityFanout_targets, _DurabilityFanout_policies, _DurabilityFanout_dlq, _DurabilityFanout_maxBatchSize, _DurabilityFanout_batchDelayMs, _DurabilityFanout_lifecycle, _DurabilityFanout_emit, _DurabilityFanout_running, _DurabilityFanout_pending, _DurabilityFanout_firstAttemptAt, _DurabilityFanout_runDue, _DurabilityFanout_runTarget, _DurabilityFanout_postpone, _DurabilityFanout_deliver, _DurabilityFanout_ackUnsettled, _DurabilityFanout_message, _DurabilityFanout_remove, _DurabilityFanout_removeDelivery, _DurabilityFanout_retry, _DurabilityFanout_deadLetter, _DurabilityFanout_emitTerminal, _DurabilityFanout_transaction, _DurabilityFanout_pendingCount, _DurabilityFanout_adjustPending, _DurabilityFanout_listDue, _DurabilityFanout_deadline;
13
- import { z } from 'zod';
14
- import { traceFunction, traceMethods } from './dev.js';
15
- import { DurableRetryPolicyError, FanoutEnqueueError, FanoutSettlementError, FanoutTimeoutError, reportFailure, serializeError, } from './errors.js';
16
- import { createLifecycleHooks, } from './lifecycle.js';
17
- import { RoutingLoad } from './load.js';
18
- import { createMemoize, deleteMemos, deleteMemosOfDroppedTable, } from './memoize.js';
19
- import { durabilityFanoutMigrations, durabilityMemoMigrations, migrateCapability, } from './migrations.js';
20
- import { assertPositiveInteger, createPolicyResolver, methodOptionsSchema, } from './policy.js';
21
- import { engineFor, } from './scheduler.js';
22
- import { deserialize, serialize } from './serialization.js';
23
- import { claimAttempt, deleteAttempt, updateAttempt, } from './storage.js';
24
- const fanoutMessageRowSchema = z.object({
25
- key: z.string(),
26
- id: z.string(),
27
- payload: z.string(),
28
- targets: z.string(),
29
- remaining: z.number().int().nonnegative(),
30
- seq: z.number().int().nonnegative(),
31
- created_at: z.number().int().nonnegative(),
32
- generation_id: z.string(),
12
+ var _DurabilityFanout_instances, _DurabilityFanout_engine, _DurabilityFanout_channel, _DurabilityFanout_table, _DurabilityFanout_routing, _DurabilityFanout_targets, _DurabilityFanout_policies, _DurabilityFanout_dlq, _DurabilityFanout_maxBatchSize, _DurabilityFanout_batchDelayMs, _DurabilityFanout_lifecycle, _DurabilityFanout_emit, _DurabilityFanout_running, _DurabilityFanout_pending, _DurabilityFanout_firstAttemptAt, _DurabilityFanout_runDue, _DurabilityFanout_runTarget, _DurabilityFanout_postpone, _DurabilityFanout_deliver, _DurabilityFanout_ackUnsettled, _DurabilityFanout_message, _DurabilityFanout_remove, _DurabilityFanout_removeDelivery, _DurabilityFanout_retry, _DurabilityFanout_deadLetter, _DurabilityFanout_emitTerminal, _DurabilityFanout_transaction, _DurabilityFanout_pendingCount, _DurabilityFanout_adjustPending, _DurabilityFanout_listDue, _DurabilityFanout_deadline;
13
+ import * as v from 'valibot';
14
+ import { traceFunction, traceMethods } from '../dev.js';
15
+ import { DurableRetryPolicyError, FanoutEnqueueError, FanoutSettlementError, FanoutTimeoutError, reportFailure, serializeError, } from '../errors.js';
16
+ import { createLifecycleHooks, } from '../lifecycle.js';
17
+ import { RoutingLoad, } from '../routing/load.js';
18
+ import { createMemoize, deleteMemos, deleteMemosOfDroppedTable, } from '../memoize/index.js';
19
+ import { durabilityFanoutMigrations } from './migrations.js';
20
+ import { durabilityMemoMigrations } from '../memoize/migrations.js';
21
+ import { migrateCapability } from '../migrations.js';
22
+ import { assertPositiveInteger, createPolicyResolver, methodOptionsSchema, } from '../policy.js';
23
+ import { assertChannel, defaultChannel, engineFor, } from '../scheduler/index.js';
24
+ import { deserialize, serialize } from '../serialization.js';
25
+ import { claimAttempt, deleteAttempt, updateAttempt, } from '../storage.js';
26
+ const fanoutMessageRowSchema = v.object({
27
+ key: v.string(),
28
+ id: v.string(),
29
+ payload: v.string(),
30
+ targets: v.string(),
31
+ remaining: v.pipe(v.number(), v.safeInteger(), v.minValue(0)),
32
+ seq: v.pipe(v.number(), v.safeInteger(), v.minValue(0)),
33
+ created_at: v.pipe(v.number(), v.safeInteger(), v.minValue(0)),
34
+ generation_id: v.string(),
33
35
  });
34
- const deliveryRowSchema = z.object({
35
- id: z.string(),
36
- message_key: z.string(),
37
- target_id: z.string(),
38
- seq: z.number().int().nonnegative(),
39
- status: z.literal('pending'),
40
- phase: z.enum(['delivery', 'dead_letter']),
41
- attempt: z.number().int().nonnegative(),
42
- next_attempt_at: z.number().int().nonnegative(),
43
- last_error: z.string().nullable(),
44
- last_error_name: z.string().nullable(),
45
- created_at: z.number().int().nonnegative(),
46
- generation_id: z.string(),
47
- dead_lettered_at: z.number().int().nonnegative().nullable(),
48
- dead_letter_reason: z.enum(['explicit', 'exhausted']).nullable(),
36
+ const deliveryRowSchema = v.object({
37
+ id: v.string(),
38
+ message_key: v.string(),
39
+ target_id: v.string(),
40
+ seq: v.pipe(v.number(), v.safeInteger(), v.minValue(0)),
41
+ status: v.literal('pending'),
42
+ phase: v.picklist(['delivery', 'dead_letter']),
43
+ attempt: v.pipe(v.number(), v.safeInteger(), v.minValue(0)),
44
+ next_attempt_at: v.pipe(v.number(), v.safeInteger(), v.minValue(0)),
45
+ last_error: v.nullable(v.string()),
46
+ last_error_name: v.nullable(v.string()),
47
+ created_at: v.pipe(v.number(), v.safeInteger(), v.minValue(0)),
48
+ generation_id: v.string(),
49
+ dead_lettered_at: v.nullable(v.pipe(v.number(), v.safeInteger(), v.minValue(0))),
50
+ dead_letter_reason: v.nullable(v.picklist(['explicit', 'exhausted'])),
49
51
  });
50
52
  const deliveriesTable = {
51
53
  name: 'durability_fanout_deliveries',
52
54
  key: 'id',
53
55
  };
54
- const countRowSchema = z.object({ count: z.number().int().nonnegative() });
55
- const seqRowSchema = z.object({ seq: z.number().int().nonnegative() });
56
- const readManifest = (sql, key) => fanoutMessageRowSchema
57
- .optional()
58
- .parse(sql
59
- .exec('SELECT * FROM durability_fanout_messages WHERE key = ?', key)
56
+ const countRowSchema = v.object({
57
+ count: v.pipe(v.number(), v.safeInteger(), v.minValue(0)),
58
+ });
59
+ const seqRowSchema = v.object({
60
+ seq: v.pipe(v.number(), v.safeInteger(), v.minValue(0)),
61
+ });
62
+ const readManifest = (sql, channel, key) => v.parse(v.optional(fanoutMessageRowSchema), sql
63
+ .exec('SELECT * FROM durability_fanout_messages WHERE channel = ? AND key = ?', channel, key)
60
64
  .toArray()[0]);
61
65
  const attemptOf = (row) => ({
62
66
  key: row.id,
@@ -80,6 +84,8 @@ export class DurabilityFanout {
80
84
  constructor(config) {
81
85
  _DurabilityFanout_instances.add(this);
82
86
  _DurabilityFanout_engine.set(this, void 0);
87
+ _DurabilityFanout_channel.set(this, void 0);
88
+ _DurabilityFanout_table.set(this, void 0);
83
89
  _DurabilityFanout_routing.set(this, void 0);
84
90
  _DurabilityFanout_targets.set(this, void 0);
85
91
  _DurabilityFanout_policies.set(this, void 0);
@@ -96,6 +102,8 @@ export class DurabilityFanout {
96
102
  * may leave it wrong, so it is discarded and recounted on the next read.
97
103
  */
98
104
  _DurabilityFanout_pending.set(this, void 0);
105
+ __classPrivateFieldSet(this, _DurabilityFanout_channel, assertChannel('DurabilityFanout', config.channel ?? defaultChannel), "f");
106
+ __classPrivateFieldSet(this, _DurabilityFanout_table, { ...deliveriesTable, channel: __classPrivateFieldGet(this, _DurabilityFanout_channel, "f") }, "f");
99
107
  __classPrivateFieldSet(this, _DurabilityFanout_maxBatchSize, config.maxBatchSize ?? 10, "f");
100
108
  assertPositiveInteger('maxBatchSize', __classPrivateFieldGet(this, _DurabilityFanout_maxBatchSize, "f"));
101
109
  __classPrivateFieldSet(this, _DurabilityFanout_batchDelayMs, config.batchDelayMs ?? 0, "f");
@@ -122,8 +130,10 @@ export class DurabilityFanout {
122
130
  __classPrivateFieldSet(this, _DurabilityFanout_emit, __classPrivateFieldGet(this, _DurabilityFanout_lifecycle, "f").emit, "f");
123
131
  __classPrivateFieldGet(this, _DurabilityFanout_engine, "f").migrateSchema('fanout', durabilityFanoutMigrations);
124
132
  __classPrivateFieldGet(this, _DurabilityFanout_engine, "f").migrateSchema('memos', durabilityMemoMigrations);
125
- __classPrivateFieldGet(this, _DurabilityFanout_engine, "f").register({
126
- table: deliveriesTable,
133
+ __classPrivateFieldGet(this, _DurabilityFanout_engine, "f").registerChannel({
134
+ table: __classPrivateFieldGet(this, _DurabilityFanout_table, "f"),
135
+ channel: __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"),
136
+ helper: 'DurabilityFanout',
127
137
  runDue: () => __classPrivateFieldGet(this, _DurabilityFanout_instances, "m", _DurabilityFanout_runDue).call(this),
128
138
  });
129
139
  }
@@ -187,7 +197,7 @@ export class DurabilityFanout {
187
197
  registered = await __classPrivateFieldGet(this, _DurabilityFanout_instances, "m", _DurabilityFanout_transaction).call(this, (sql) => {
188
198
  const claims = [];
189
199
  for (const entry of entries) {
190
- const existing = readManifest(sql, entry.key);
200
+ const existing = readManifest(sql, __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"), entry.key);
191
201
  if (existing) {
192
202
  if (existing.id !== entry.id ||
193
203
  existing.payload !== entry.payload ||
@@ -196,7 +206,7 @@ export class DurabilityFanout {
196
206
  }
197
207
  continue;
198
208
  }
199
- const { seq } = seqRowSchema.parse(sql
209
+ const { seq } = v.parse(seqRowSchema, sql
200
210
  .exec(`UPDATE durability_fanout_seq
201
211
  SET next_seq = next_seq + 1
202
212
  WHERE id = 1
@@ -211,9 +221,9 @@ export class DurabilityFanout {
211
221
  generation_id: crypto.randomUUID(),
212
222
  };
213
223
  sql.exec(`INSERT INTO durability_fanout_messages
214
- (key, id, payload, targets, remaining, seq, created_at,
215
- generation_id)
216
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, message.key, message.id, message.payload, message.targets, message.remaining, message.seq, message.created_at, message.generation_id);
224
+ (channel, key, id, payload, targets, remaining, seq,
225
+ created_at, generation_id)
226
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"), message.key, message.id, message.payload, message.targets, message.remaining, message.seq, message.created_at, message.generation_id);
217
227
  for (const target of targets) {
218
228
  const row = {
219
229
  id: JSON.stringify([entry.key, target]),
@@ -233,11 +243,11 @@ export class DurabilityFanout {
233
243
  };
234
244
  const inserted = sql
235
245
  .exec(`INSERT INTO durability_fanout_deliveries
236
- (id, message_key, target_id, seq, status, phase, attempt,
237
- next_attempt_at, created_at, generation_id)
238
- VALUES (?, ?, ?, ?, 'pending', 'delivery', 0, ?, ?, ?)
239
- ON CONFLICT(id) DO NOTHING
240
- RETURNING id`, row.id, row.message_key, row.target_id, row.seq, row.next_attempt_at, row.created_at, row.generation_id)
246
+ (channel, id, message_key, target_id, seq, status, phase,
247
+ attempt, next_attempt_at, created_at, generation_id)
248
+ VALUES (?, ?, ?, ?, ?, 'pending', 'delivery', 0, ?, ?, ?)
249
+ ON CONFLICT(channel, id) DO NOTHING
250
+ RETURNING id`, __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"), row.id, row.message_key, row.target_id, row.seq, row.next_attempt_at, row.created_at, row.generation_id)
241
251
  .toArray().length > 0;
242
252
  if (!inserted) {
243
253
  throw new Error('Fanout manifest and delivery state disagree');
@@ -283,18 +293,17 @@ export class DurabilityFanout {
283
293
  return { success: true, value: entries.map(({ id }) => id), load };
284
294
  }
285
295
  }
286
- _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_routing = new WeakMap(), _DurabilityFanout_targets = new WeakMap(), _DurabilityFanout_policies = new WeakMap(), _DurabilityFanout_dlq = new WeakMap(), _DurabilityFanout_maxBatchSize = new WeakMap(), _DurabilityFanout_batchDelayMs = new WeakMap(), _DurabilityFanout_lifecycle = new WeakMap(), _DurabilityFanout_emit = new WeakMap(), _DurabilityFanout_running = new WeakMap(), _DurabilityFanout_pending = new WeakMap(), _DurabilityFanout_instances = new WeakSet(), _DurabilityFanout_firstAttemptAt = function _DurabilityFanout_firstAttemptAt(createdAt) {
296
+ _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_channel = new WeakMap(), _DurabilityFanout_table = new WeakMap(), _DurabilityFanout_routing = new WeakMap(), _DurabilityFanout_targets = new WeakMap(), _DurabilityFanout_policies = new WeakMap(), _DurabilityFanout_dlq = new WeakMap(), _DurabilityFanout_maxBatchSize = new WeakMap(), _DurabilityFanout_batchDelayMs = new WeakMap(), _DurabilityFanout_lifecycle = new WeakMap(), _DurabilityFanout_emit = new WeakMap(), _DurabilityFanout_running = new WeakMap(), _DurabilityFanout_pending = new WeakMap(), _DurabilityFanout_instances = new WeakSet(), _DurabilityFanout_firstAttemptAt = function _DurabilityFanout_firstAttemptAt(createdAt) {
287
297
  if (__classPrivateFieldGet(this, _DurabilityFanout_batchDelayMs, "f") === 0) {
288
298
  return createdAt;
289
299
  }
290
300
  return Math.ceil(createdAt / __classPrivateFieldGet(this, _DurabilityFanout_batchDelayMs, "f")) * __classPrivateFieldGet(this, _DurabilityFanout_batchDelayMs, "f");
291
301
  }, _DurabilityFanout_runDue = async function _DurabilityFanout_runDue() {
292
- const targets = z
293
- .object({ target_id: z.string() })
294
- .array()
295
- .parse(__classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql
302
+ const targets = v
303
+ .parse(v.array(v.object({ target_id: v.string() })), __classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql
296
304
  .exec(`SELECT DISTINCT target_id FROM durability_fanout_deliveries
297
- ORDER BY target_id`)
305
+ WHERE channel = ?
306
+ ORDER BY target_id`, __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"))
298
307
  .toArray())
299
308
  .map((row) => row.target_id);
300
309
  // Each target advances independently; a missing or slow target cannot hide
@@ -329,7 +338,7 @@ _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_routing = new WeakMa
329
338
  const exhausted = [];
330
339
  const deadline = Date.now() + policy.attemptTimeoutMs;
331
340
  for (const row of due) {
332
- const message = readManifest(sql, row.message_key);
341
+ const message = readManifest(sql, __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"), row.message_key);
333
342
  if (!message || message.generation_id !== row.generation_id) {
334
343
  throw new Error('Fanout delivery is missing its message manifest');
335
344
  }
@@ -338,7 +347,7 @@ _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_routing = new WeakMa
338
347
  exhausted.push({ row, message });
339
348
  continue;
340
349
  }
341
- const attempt = claimAttempt(sql, deliveriesTable, row.id, row.generation_id, policy.maxAttempts, deadline);
350
+ const attempt = claimAttempt(sql, __classPrivateFieldGet(this, _DurabilityFanout_table, "f"), row.id, row.generation_id, policy.maxAttempts, deadline);
342
351
  if (attempt === undefined) {
343
352
  continue;
344
353
  }
@@ -360,7 +369,7 @@ _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_routing = new WeakMa
360
369
  }, _DurabilityFanout_postpone = async function _DurabilityFanout_postpone(rows) {
361
370
  await __classPrivateFieldGet(this, _DurabilityFanout_instances, "m", _DurabilityFanout_transaction).call(this, (sql) => {
362
371
  for (const row of rows) {
363
- updateAttempt(sql, deliveriesTable, attemptOf(row), 'next_attempt_at = ?', Date.now() + infrastructureRetryMs);
372
+ updateAttempt(sql, __classPrivateFieldGet(this, _DurabilityFanout_table, "f"), attemptOf(row), 'next_attempt_at = ?', Date.now() + infrastructureRetryMs);
364
373
  }
365
374
  });
366
375
  }, _DurabilityFanout_deliver = async function _DurabilityFanout_deliver(target, claims, policy) {
@@ -448,10 +457,9 @@ _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_routing = new WeakMa
448
457
  if (!state.finished) {
449
458
  continue;
450
459
  }
451
- const current = deliveryRowSchema
452
- .optional()
453
- .parse(__classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql
454
- .exec('SELECT * FROM durability_fanout_deliveries WHERE id = ?', state.claim.row.id)
460
+ const current = v.parse(v.optional(deliveryRowSchema), __classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql
461
+ .exec(`SELECT * FROM durability_fanout_deliveries
462
+ WHERE channel = ? AND id = ?`, __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"), state.claim.row.id)
455
463
  .toArray()[0]);
456
464
  if (!current ||
457
465
  current.generation_id !== state.claim.row.generation_id ||
@@ -530,7 +538,7 @@ _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_routing = new WeakMa
530
538
  body: deserialize(message.payload),
531
539
  enqueuedAt: message.created_at,
532
540
  attempt: row.attempt,
533
- memoize: createMemoize(__classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql, deliveriesTable, attemptOf(row)),
541
+ memoize: createMemoize(__classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql, __classPrivateFieldGet(this, _DurabilityFanout_table, "f"), attemptOf(row)),
534
542
  ack: traceFunction('DurabilityFanoutMessage.ack', () => settle('ack', async () => {
535
543
  await __classPrivateFieldGet(this, _DurabilityFanout_instances, "m", _DurabilityFanout_remove).call(this, row);
536
544
  __classPrivateFieldGet(this, _DurabilityFanout_emit, "f").call(this, {
@@ -560,16 +568,16 @@ _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_routing = new WeakMa
560
568
  }
561
569
  });
562
570
  }, _DurabilityFanout_removeDelivery = function _DurabilityFanout_removeDelivery(sql, row) {
563
- if (!deleteAttempt(sql, deliveriesTable, attemptOf(row))) {
571
+ if (!deleteAttempt(sql, __classPrivateFieldGet(this, _DurabilityFanout_table, "f"), attemptOf(row))) {
564
572
  return false;
565
573
  }
566
- deleteMemos(sql, deliveriesTable, row.id);
574
+ deleteMemos(sql, __classPrivateFieldGet(this, _DurabilityFanout_table, "f"), row.id);
567
575
  __classPrivateFieldGet(this, _DurabilityFanout_instances, "m", _DurabilityFanout_adjustPending).call(this, -1);
568
576
  sql.exec(`UPDATE durability_fanout_messages
569
577
  SET remaining = remaining - 1
570
- WHERE key = ?`, row.message_key);
578
+ WHERE channel = ? AND key = ?`, __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"), row.message_key);
571
579
  sql.exec(`DELETE FROM durability_fanout_messages
572
- WHERE key = ? AND remaining = 0`, row.message_key);
580
+ WHERE channel = ? AND key = ? AND remaining = 0`, __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"), row.message_key);
573
581
  return true;
574
582
  }, _DurabilityFanout_retry = async function _DurabilityFanout_retry(claim, policy, override, error, startedAt) {
575
583
  const { row } = claim;
@@ -593,7 +601,7 @@ _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_routing = new WeakMa
593
601
  return;
594
602
  }
595
603
  await __classPrivateFieldGet(this, _DurabilityFanout_instances, "m", _DurabilityFanout_transaction).call(this, (sql) => {
596
- const updated = updateAttempt(sql, deliveriesTable, attemptOf(row), 'next_attempt_at = ?, last_error = ?, last_error_name = ?', nextAttemptAt, error.message, error.name);
604
+ const updated = updateAttempt(sql, __classPrivateFieldGet(this, _DurabilityFanout_table, "f"), attemptOf(row), 'next_attempt_at = ?, last_error = ?, last_error_name = ?', nextAttemptAt, error.message, error.name);
597
605
  if (!updated) {
598
606
  throw new FanoutSettlementError(row.id);
599
607
  }
@@ -625,7 +633,7 @@ _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_routing = new WeakMa
625
633
  // Persist intent BEFORE external I/O: eviction or timeout must never turn
626
634
  // a terminal decision into another consumer delivery.
627
635
  await __classPrivateFieldGet(this, _DurabilityFanout_instances, "m", _DurabilityFanout_transaction).call(this, (sql) => {
628
- const updated = updateAttempt(sql, deliveriesTable, attemptOf(row), `phase = 'dead_letter', dead_lettered_at = ?, dead_letter_reason = ?,
636
+ const updated = updateAttempt(sql, __classPrivateFieldGet(this, _DurabilityFanout_table, "f"), attemptOf(row), `phase = 'dead_letter', dead_lettered_at = ?, dead_letter_reason = ?,
629
637
  next_attempt_at = ?, last_error = ?, last_error_name = ?`, timestamp, reason, Date.now() + infrastructureRetryMs, error?.message ?? null, error?.name ?? null);
630
638
  if (!updated) {
631
639
  throw new FanoutSettlementError(row.id);
@@ -670,9 +678,9 @@ _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_routing = new WeakMa
670
678
  throw error;
671
679
  }
672
680
  }, _DurabilityFanout_pendingCount = function _DurabilityFanout_pendingCount() {
673
- __classPrivateFieldSet(this, _DurabilityFanout_pending, __classPrivateFieldGet(this, _DurabilityFanout_pending, "f") ?? countRowSchema.parse(__classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql
681
+ __classPrivateFieldSet(this, _DurabilityFanout_pending, __classPrivateFieldGet(this, _DurabilityFanout_pending, "f") ?? v.parse(countRowSchema, __classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql
674
682
  .exec(`SELECT COUNT(*) AS count FROM durability_fanout_deliveries
675
- WHERE status = 'pending'`)
683
+ WHERE channel = ? AND status = 'pending'`, __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"))
676
684
  .toArray()[0]).count, "f");
677
685
  return __classPrivateFieldGet(this, _DurabilityFanout_pending, "f");
678
686
  }, _DurabilityFanout_adjustPending = function _DurabilityFanout_adjustPending(delta) {
@@ -680,22 +688,22 @@ _DurabilityFanout_engine = new WeakMap(), _DurabilityFanout_routing = new WeakMa
680
688
  __classPrivateFieldSet(this, _DurabilityFanout_pending, __classPrivateFieldGet(this, _DurabilityFanout_pending, "f") + delta, "f");
681
689
  }
682
690
  }, _DurabilityFanout_listDue = function _DurabilityFanout_listDue(target, now) {
683
- const first = deliveryRowSchema.array().parse(__classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql
691
+ const first = v.parse(v.array(deliveryRowSchema), __classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql
684
692
  .exec(`SELECT * FROM durability_fanout_deliveries
685
- WHERE target_id = ? AND phase = 'delivery' AND status = 'pending'
686
- AND attempt = 0 AND next_attempt_at <= ?
693
+ WHERE channel = ? AND target_id = ? AND phase = 'delivery'
694
+ AND status = 'pending' AND attempt = 0 AND next_attempt_at <= ?
687
695
  ORDER BY seq ASC
688
- LIMIT ?`, target, now, __classPrivateFieldGet(this, _DurabilityFanout_maxBatchSize, "f"))
696
+ LIMIT ?`, __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"), target, now, __classPrivateFieldGet(this, _DurabilityFanout_maxBatchSize, "f"))
689
697
  .toArray());
690
698
  if (first.length >= __classPrivateFieldGet(this, _DurabilityFanout_maxBatchSize, "f")) {
691
699
  return first;
692
700
  }
693
- const retries = deliveryRowSchema.array().parse(__classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql
701
+ const retries = v.parse(v.array(deliveryRowSchema), __classPrivateFieldGet(this, _DurabilityFanout_engine, "f").sql
694
702
  .exec(`SELECT * FROM durability_fanout_deliveries
695
- WHERE target_id = ? AND status = 'pending'
703
+ WHERE channel = ? AND target_id = ? AND status = 'pending'
696
704
  AND attempt > 0 AND next_attempt_at <= ?
697
705
  ORDER BY seq ASC
698
- LIMIT ?`, target, now, __classPrivateFieldGet(this, _DurabilityFanout_maxBatchSize, "f") - first.length)
706
+ LIMIT ?`, __classPrivateFieldGet(this, _DurabilityFanout_channel, "f"), target, now, __classPrivateFieldGet(this, _DurabilityFanout_maxBatchSize, "f") - first.length)
699
707
  .toArray());
700
708
  return [...first, ...retries];
701
709
  }, _DurabilityFanout_deadline = async function _DurabilityFanout_deadline(run, timeoutMs) {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Ordered SQLite migrations for fanout manifests and deliveries. Applied
3
+ * automatically on construction.
4
+ */
5
+ export declare const durabilityFanoutMigrations: {
6
+ name: string;
7
+ up: string;
8
+ down: string;
9
+ }[];
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Ordered SQLite migrations for fanout manifests and deliveries. Applied
3
+ * automatically on construction.
4
+ */
5
+ export const durabilityFanoutMigrations = [
6
+ {
7
+ name: 'durability_0005_create_fanout',
8
+ up: `
9
+ CREATE TABLE IF NOT EXISTS durability_fanout_messages (
10
+ key TEXT PRIMARY KEY,
11
+ id TEXT NOT NULL,
12
+ payload TEXT NOT NULL,
13
+ targets TEXT NOT NULL,
14
+ remaining INTEGER NOT NULL,
15
+ seq INTEGER NOT NULL,
16
+ created_at INTEGER NOT NULL,
17
+ generation_id TEXT NOT NULL
18
+ );
19
+ CREATE TABLE IF NOT EXISTS durability_fanout_deliveries (
20
+ id TEXT PRIMARY KEY,
21
+ message_key TEXT NOT NULL,
22
+ target_id TEXT NOT NULL,
23
+ seq INTEGER NOT NULL,
24
+ status TEXT NOT NULL CHECK (status IN ('pending')),
25
+ phase TEXT NOT NULL CHECK (phase IN ('delivery', 'dead_letter')),
26
+ attempt INTEGER NOT NULL DEFAULT 0,
27
+ next_attempt_at INTEGER NOT NULL,
28
+ last_error TEXT,
29
+ last_error_name TEXT,
30
+ created_at INTEGER NOT NULL,
31
+ generation_id TEXT NOT NULL,
32
+ dead_lettered_at INTEGER,
33
+ dead_letter_reason TEXT CHECK (dead_letter_reason IN ('explicit', 'exhausted'))
34
+ );
35
+ CREATE INDEX IF NOT EXISTS durability_fanout_deliveries_due_idx
36
+ ON durability_fanout_deliveries
37
+ (target_id, phase, status, attempt, seq, next_attempt_at);
38
+ CREATE INDEX IF NOT EXISTS durability_fanout_deliveries_pending_idx
39
+ ON durability_fanout_deliveries (phase, status, next_attempt_at);
40
+ CREATE INDEX IF NOT EXISTS durability_fanout_deliveries_created_idx
41
+ ON durability_fanout_deliveries (created_at);
42
+ CREATE TABLE IF NOT EXISTS durability_fanout_seq (
43
+ id INTEGER PRIMARY KEY CHECK (id = 1),
44
+ next_seq INTEGER NOT NULL
45
+ );
46
+ INSERT OR IGNORE INTO durability_fanout_seq (id, next_seq) VALUES (1, 0);
47
+ `,
48
+ down: `
49
+ DROP INDEX IF EXISTS durability_fanout_deliveries_due_idx;
50
+ DROP INDEX IF EXISTS durability_fanout_deliveries_pending_idx;
51
+ DROP INDEX IF EXISTS durability_fanout_deliveries_created_idx;
52
+ DROP TABLE IF EXISTS durability_fanout_deliveries;
53
+ DROP TABLE IF EXISTS durability_fanout_messages;
54
+ DROP TABLE IF EXISTS durability_fanout_seq;
55
+ `,
56
+ },
57
+ {
58
+ name: 'durability_0017_fanout_channels',
59
+ up: `
60
+ ALTER TABLE durability_fanout_messages
61
+ RENAME TO durability_fanout_messages_before_channels;
62
+ CREATE TABLE durability_fanout_messages (
63
+ key TEXT NOT NULL,
64
+ id TEXT NOT NULL,
65
+ payload TEXT NOT NULL,
66
+ targets TEXT NOT NULL,
67
+ remaining INTEGER NOT NULL,
68
+ seq INTEGER NOT NULL,
69
+ created_at INTEGER NOT NULL,
70
+ generation_id TEXT NOT NULL,
71
+ channel TEXT NOT NULL DEFAULT 'default',
72
+ PRIMARY KEY (channel, key)
73
+ );
74
+ INSERT INTO durability_fanout_messages
75
+ (key, id, payload, targets, remaining, seq, created_at,
76
+ generation_id, channel)
77
+ SELECT key, id, payload, targets, remaining, seq, created_at,
78
+ generation_id, 'default'
79
+ FROM durability_fanout_messages_before_channels;
80
+ DROP TABLE durability_fanout_messages_before_channels;
81
+
82
+ ALTER TABLE durability_fanout_deliveries
83
+ RENAME TO durability_fanout_deliveries_before_channels;
84
+ CREATE TABLE durability_fanout_deliveries (
85
+ id TEXT NOT NULL,
86
+ message_key TEXT NOT NULL,
87
+ target_id TEXT NOT NULL,
88
+ seq INTEGER NOT NULL,
89
+ status TEXT NOT NULL CHECK (status IN ('pending')),
90
+ phase TEXT NOT NULL CHECK (phase IN ('delivery', 'dead_letter')),
91
+ attempt INTEGER NOT NULL DEFAULT 0,
92
+ next_attempt_at INTEGER NOT NULL,
93
+ last_error TEXT,
94
+ last_error_name TEXT,
95
+ created_at INTEGER NOT NULL,
96
+ generation_id TEXT NOT NULL,
97
+ dead_lettered_at INTEGER,
98
+ dead_letter_reason TEXT CHECK (dead_letter_reason IN ('explicit', 'exhausted')),
99
+ channel TEXT NOT NULL DEFAULT 'default',
100
+ PRIMARY KEY (channel, id)
101
+ );
102
+ INSERT INTO durability_fanout_deliveries
103
+ (id, message_key, target_id, seq, status, phase, attempt,
104
+ next_attempt_at, last_error, last_error_name, created_at,
105
+ generation_id, dead_lettered_at, dead_letter_reason, channel)
106
+ SELECT id, message_key, target_id, seq, status, phase, attempt,
107
+ next_attempt_at, last_error, last_error_name, created_at,
108
+ generation_id, dead_lettered_at, dead_letter_reason, 'default'
109
+ FROM durability_fanout_deliveries_before_channels;
110
+ DROP TABLE durability_fanout_deliveries_before_channels;
111
+ CREATE INDEX durability_fanout_deliveries_due_idx
112
+ ON durability_fanout_deliveries
113
+ (channel, target_id, phase, status, attempt, seq, next_attempt_at);
114
+ CREATE INDEX durability_fanout_deliveries_pending_idx
115
+ ON durability_fanout_deliveries (phase, status, next_attempt_at);
116
+ CREATE INDEX durability_fanout_deliveries_created_idx
117
+ ON durability_fanout_deliveries (created_at);
118
+ CREATE INDEX durability_fanout_deliveries_channel_pending_idx
119
+ ON durability_fanout_deliveries (channel, status, next_attempt_at);
120
+ `,
121
+ down: `
122
+ CREATE TABLE durability_fanout_channel_guard (
123
+ channel TEXT CONSTRAINT cannot_downgrade_nondefault_channels CHECK (channel = 'default')
124
+ );
125
+ INSERT INTO durability_fanout_channel_guard
126
+ SELECT DISTINCT channel FROM durability_fanout_messages
127
+ UNION SELECT DISTINCT channel FROM durability_fanout_deliveries;
128
+ DROP TABLE durability_fanout_channel_guard;
129
+
130
+ ALTER TABLE durability_fanout_messages
131
+ RENAME TO durability_fanout_messages_with_channels;
132
+ CREATE TABLE durability_fanout_messages (
133
+ key TEXT PRIMARY KEY,
134
+ id TEXT NOT NULL,
135
+ payload TEXT NOT NULL,
136
+ targets TEXT NOT NULL,
137
+ remaining INTEGER NOT NULL,
138
+ seq INTEGER NOT NULL,
139
+ created_at INTEGER NOT NULL,
140
+ generation_id TEXT NOT NULL
141
+ );
142
+ INSERT INTO durability_fanout_messages
143
+ SELECT key, id, payload, targets, remaining, seq, created_at,
144
+ generation_id
145
+ FROM durability_fanout_messages_with_channels;
146
+ DROP TABLE durability_fanout_messages_with_channels;
147
+
148
+ ALTER TABLE durability_fanout_deliveries
149
+ RENAME TO durability_fanout_deliveries_with_channels;
150
+ CREATE TABLE durability_fanout_deliveries (
151
+ id TEXT PRIMARY KEY,
152
+ message_key TEXT NOT NULL,
153
+ target_id TEXT NOT NULL,
154
+ seq INTEGER NOT NULL,
155
+ status TEXT NOT NULL CHECK (status IN ('pending')),
156
+ phase TEXT NOT NULL CHECK (phase IN ('delivery', 'dead_letter')),
157
+ attempt INTEGER NOT NULL DEFAULT 0,
158
+ next_attempt_at INTEGER NOT NULL,
159
+ last_error TEXT,
160
+ last_error_name TEXT,
161
+ created_at INTEGER NOT NULL,
162
+ generation_id TEXT NOT NULL,
163
+ dead_lettered_at INTEGER,
164
+ dead_letter_reason TEXT CHECK (dead_letter_reason IN ('explicit', 'exhausted'))
165
+ );
166
+ INSERT INTO durability_fanout_deliveries
167
+ SELECT id, message_key, target_id, seq, status, phase, attempt,
168
+ next_attempt_at, last_error, last_error_name, created_at,
169
+ generation_id, dead_lettered_at, dead_letter_reason
170
+ FROM durability_fanout_deliveries_with_channels;
171
+ DROP TABLE durability_fanout_deliveries_with_channels;
172
+ CREATE INDEX durability_fanout_deliveries_due_idx
173
+ ON durability_fanout_deliveries
174
+ (target_id, phase, status, attempt, seq, next_attempt_at);
175
+ CREATE INDEX durability_fanout_deliveries_pending_idx
176
+ ON durability_fanout_deliveries (phase, status, next_attempt_at);
177
+ CREATE INDEX durability_fanout_deliveries_created_idx
178
+ ON durability_fanout_deliveries (created_at);
179
+ `,
180
+ },
181
+ ];
@@ -1,4 +1,4 @@
1
- import type { SerializedError } from './errors.js';
1
+ import type { SerializedError } from '../errors.js';
2
2
  /**
3
3
  * One message as handed to a storage destination. Archive and dead-letter
4
4
  * writes share this envelope; only `failure` distinguishes them.
package/dist/index.d.ts CHANGED
@@ -1,13 +1,18 @@
1
- export { Durability, type DurabilityConfig, type DurabilityConstructor, type DurabilityOptions, type DurableCall, type DurableHandler, type DurableOperation, type DurableOperationResult, type DurabilityOperationEvent, type HandlerMap, } from './durability.js';
2
- export { DurabilityAlarms, type DurabilityAlarmsConfig, type DurabilityAlarmsConstructor, type DurabilityAlarmsOptions, type DurabilityAlarmEvent, type DurableAlarmHandler, type DurableAlarmInfo, type DurableNamedAlarm, } from './durability-alarms.js';
3
- export { maxMemoBytes, maxMemosPerRecord, type DurableMemoize, } from './memoize.js';
4
- export { DurabilityFanout, type DurabilityFanoutConfig, type DurabilityFanoutEvent, type DurabilityFanoutMessage, type FanoutInput, type FanoutTarget, type FanoutEnqueueOptions, } from './fanout.js';
5
- export { DurabilityLog, maxLogBytes, type DurabilityLogConfig, type LogAppendInput, type LogColdStorage, type LogLease, type LogLeaseOptions, type LogPage, type LogReadOptions, type LogRecord, type LogRetention, type LogSegment, type LogBounds, } from './log.js';
6
- export { RoutingLoad, type EnqueueResult, type LoadSnapshot, type ProcessingLoad, } from './load.js';
7
- export type { MessageWrite, StoredMessage } from './stored-message.js';
8
- export { DurabilityScheduler, type AlarmRetryInfo, type DurabilityContext, type DurabilitySchedulerConfig, type DurabilitySchedulerOptions, type SchedulerAttachment, } from './scheduler.js';
1
+ export { Durability, type DurabilityConfig, type DurabilityConstructor, type DurabilityOptions, type DurableCall, type DurableHandler, type DurableOperation, type DurableOperationResult, type DurabilityOperationEvent, type HandlerMap, } from './operations/index.js';
2
+ export { DurabilityAlarms, type DurabilityAlarmsConfig, type DurabilityAlarmsConstructor, type DurabilityAlarmsOptions, type DurabilityAlarmEvent, type DurableAlarmHandler, type DurableAlarmInfo, type DurableNamedAlarm, } from './alarms/index.js';
3
+ export { maxMemoBytes, maxMemosPerRecord, type DurableMemoize, } from './memoize/index.js';
4
+ export { DurabilityFanout, type DurabilityFanoutConfig, type DurabilityFanoutEvent, type DurabilityFanoutMessage, type FanoutInput, type FanoutTarget, type FanoutEnqueueOptions, } from './fanout/index.js';
5
+ export { DurabilityLog, maxLogBytes, type DurabilityLogConfig, type LogAppendInput, type LogColdStorage, type LogLease, type LogLeaseOptions, type LogPage, type LogReadOptions, type LogRecord, type LogRetention, type LogSegment, type LogBounds, } from './log/index.js';
6
+ export { RoutingLoad, type EnqueueResult, type LoadSnapshot, type ProcessingLoad, } from './routing/load.js';
7
+ export type { MessageWrite, StoredMessage } from './fanout/stored-message.js';
8
+ export { DurabilityScheduler, type AlarmRetryInfo, type DurabilityContext, type DurabilitySchedulerConfig, type DurabilitySchedulerOptions, type SchedulerAttachment, } from './scheduler/index.js';
9
9
  export { DuplicateDurableCallError, DuplicateDurablePayloadError, DurableAlarmTimeoutError, DurableAttemptsExhaustedError, DurableAttemptTimeoutError, DurableResultSerializationError, DurableRetryPolicyError, DurableMemoLimitError, DurableMemoSerializationError, NonRetryableError, FanoutTimeoutError, FanoutSettlementError, FanoutEnqueueError, LogAppendError, LogLeaseError, LogTruncatedError, RoutingError, } from './errors.js';
10
10
  export type { DurabilityLifecycleEvent, LifecycleHook } from './lifecycle.js';
11
- export { durabilityNamedAlarmMigrations, durabilityOperationMigrations, durabilityFanoutMigrations, durabilityLogLeaseMigrations, durabilityLogMigrations, durabilityMemoMigrations, migrate, type DurabilityMigrationResult, type MigrateOptions, type MigrationCapability, } from './migrations.js';
11
+ export { durabilityNamedAlarmMigrations } from './alarms/migrations.js';
12
+ export { durabilityOperationMigrations } from './operations/migrations.js';
13
+ export { durabilityFanoutMigrations } from './fanout/migrations.js';
14
+ export { durabilityLogLeaseMigrations, durabilityLogMigrations, } from './log/migrations.js';
15
+ export { durabilityMemoMigrations } from './memoize/migrations.js';
16
+ export { migrate, type DurabilityMigrationResult, type MigrateOptions, type MigrationCapability, } from './migrations.js';
12
17
  export type { DurableMigrations } from '@durability/storage';
13
18
  export type { DurabilityAlarmMethodOptions, DurabilityMethodOptions, DurabilityRetryOptions, } from './policy.js';
package/dist/index.js CHANGED
@@ -1,9 +1,14 @@
1
- export { Durability, } from './durability.js';
2
- export { DurabilityAlarms, } from './durability-alarms.js';
3
- export { maxMemoBytes, maxMemosPerRecord, } from './memoize.js';
4
- export { DurabilityFanout, } from './fanout.js';
5
- export { DurabilityLog, maxLogBytes, } from './log.js';
6
- export { RoutingLoad, } from './load.js';
7
- export { DurabilityScheduler, } from './scheduler.js';
1
+ export { Durability, } from './operations/index.js';
2
+ export { DurabilityAlarms, } from './alarms/index.js';
3
+ export { maxMemoBytes, maxMemosPerRecord, } from './memoize/index.js';
4
+ export { DurabilityFanout, } from './fanout/index.js';
5
+ export { DurabilityLog, maxLogBytes, } from './log/index.js';
6
+ export { RoutingLoad, } from './routing/load.js';
7
+ export { DurabilityScheduler, } from './scheduler/index.js';
8
8
  export { DuplicateDurableCallError, DuplicateDurablePayloadError, DurableAlarmTimeoutError, DurableAttemptsExhaustedError, DurableAttemptTimeoutError, DurableResultSerializationError, DurableRetryPolicyError, DurableMemoLimitError, DurableMemoSerializationError, NonRetryableError, FanoutTimeoutError, FanoutSettlementError, FanoutEnqueueError, LogAppendError, LogLeaseError, LogTruncatedError, RoutingError, } from './errors.js';
9
- export { durabilityNamedAlarmMigrations, durabilityOperationMigrations, durabilityFanoutMigrations, durabilityLogLeaseMigrations, durabilityLogMigrations, durabilityMemoMigrations, migrate, } from './migrations.js';
9
+ export { durabilityNamedAlarmMigrations } from './alarms/migrations.js';
10
+ export { durabilityOperationMigrations } from './operations/migrations.js';
11
+ export { durabilityFanoutMigrations } from './fanout/migrations.js';
12
+ export { durabilityLogLeaseMigrations, durabilityLogMigrations, } from './log/migrations.js';
13
+ export { durabilityMemoMigrations } from './memoize/migrations.js';
14
+ export { migrate, } from './migrations.js';