@voltro/plugin-cdc-out 0.70.0 → 0.71.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 (3) hide show
  1. package/CHANGELOG.md +1341 -111
  2. package/dist/index.js +111 -70
  3. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -429,6 +429,7 @@ var x = class extends i.TaggedError()("CdcConfigError", { message: i.String }) {
429
429
  "store:changes:read",
430
430
  "store:write",
431
431
  "inspect:read",
432
+ "inspect:write",
432
433
  ...[...ve].map((e) => `network:outbound:${e}`)
433
434
  ], be = [
434
435
  "pending",
@@ -547,78 +548,118 @@ var x = class extends i.TaggedError()("CdcConfigError", { message: i.String }) {
547
548
  bindDataStore: (e) => {
548
549
  D.current = e, $();
549
550
  },
550
- inspectEndpoints: [{
551
- method: "GET",
552
- path: "/sinks",
553
- description: "Configured sinks + per-pipe outbox counts and delivery stats.",
554
- handler: () => t.tryPromise(async () => {
555
- let e = D.current;
556
- return {
557
- kind: "json",
558
- data: {
559
- sinks: await Promise.all([...S.values()].map(async ({ config: t, enginePipe: n }) => {
560
- let r = e === null ? {
561
- pending: 0,
562
- delivering: 0,
563
- delivered: 0,
564
- dead: 0
565
- } : await xe(e, n.key);
566
- return {
567
- table: t.table,
568
- sink: t.sink.name,
569
- pipe: n.key,
570
- ...r,
571
- failed: r.dead,
572
- lastDeliveryAtMs: n.stats.lastDeliveryAtMs
573
- };
574
- })),
575
- handoff: {
576
- leader: w.isLeader,
577
- seeded: K,
578
- awaitingSeed: X.length,
579
- buffered: R.size,
580
- pending: R.pendingCount(),
581
- dropped: R.droppedPending + Z,
582
- windowMs: b,
583
- dedupWindowMs: y
551
+ inspectEndpoints: [
552
+ {
553
+ method: "GET",
554
+ path: "/sinks",
555
+ description: "Configured sinks + per-pipe outbox counts and delivery stats.",
556
+ handler: () => t.tryPromise(async () => {
557
+ let e = D.current;
558
+ return {
559
+ kind: "json",
560
+ data: {
561
+ sinks: await Promise.all([...S.values()].map(async ({ config: t, enginePipe: n }) => {
562
+ let r = e === null ? {
563
+ pending: 0,
564
+ delivering: 0,
565
+ delivered: 0,
566
+ dead: 0
567
+ } : await xe(e, n.key);
568
+ return {
569
+ table: t.table,
570
+ sink: t.sink.name,
571
+ pipe: n.key,
572
+ ...r,
573
+ failed: r.dead,
574
+ lastDeliveryAtMs: n.stats.lastDeliveryAtMs
575
+ };
576
+ })),
577
+ handoff: {
578
+ leader: w.isLeader,
579
+ seeded: K,
580
+ awaitingSeed: X.length,
581
+ buffered: R.size,
582
+ pending: R.pendingCount(),
583
+ dropped: R.droppedPending + Z,
584
+ windowMs: b,
585
+ dedupWindowMs: y
586
+ }
584
587
  }
588
+ };
589
+ })
590
+ },
591
+ {
592
+ method: "GET",
593
+ path: "/dead-letter",
594
+ description: "Outbox rows that exhausted maxAttempts (newest first, capped at 100).",
595
+ handler: () => t.tryPromise(async () => {
596
+ let e = D.current;
597
+ return e === null ? {
598
+ kind: "json",
599
+ data: { rows: [] }
600
+ } : {
601
+ kind: "json",
602
+ data: { rows: (await e.query({
603
+ table: C,
604
+ predicate: c(d("status", "dead"), m("pipe", [...S.values()].map((e) => e.enginePipe.key))),
605
+ order: [{
606
+ column: "id",
607
+ direction: "desc"
608
+ }],
609
+ take: 100,
610
+ skip: void 0,
611
+ projection: void 0
612
+ })).map((e) => ({
613
+ deliveryKey: e.id,
614
+ pipe: e.pipe,
615
+ table: e.sourceTable,
616
+ op: e.op,
617
+ key: e.key,
618
+ attempts: e.attempts,
619
+ lastError: e.lastError,
620
+ createdAt: e.createdAt
621
+ })) }
622
+ };
623
+ })
624
+ },
625
+ {
626
+ method: "POST",
627
+ path: "/dead-letter/retry",
628
+ description: "Re-enqueue one confirmed dead delivery in this plugin instance with its original delivery key.",
629
+ handler: (e) => t.tryPromise(async () => {
630
+ let t;
631
+ try {
632
+ t = JSON.parse(e.body ?? "");
633
+ } catch {
634
+ return {
635
+ kind: "json",
636
+ status: 400,
637
+ data: { error: "Invalid JSON." }
638
+ };
585
639
  }
586
- };
587
- })
588
- }, {
589
- method: "GET",
590
- path: "/dead-letter",
591
- description: "Outbox rows that exhausted maxAttempts (newest first, capped at 100).",
592
- handler: () => t.tryPromise(async () => {
593
- let e = D.current;
594
- return e === null ? {
595
- kind: "json",
596
- data: { rows: [] }
597
- } : {
598
- kind: "json",
599
- data: { rows: (await e.query({
600
- table: C,
601
- predicate: d("status", "dead"),
602
- order: [{
603
- column: "id",
604
- direction: "desc"
605
- }],
606
- take: 100,
607
- skip: void 0,
608
- projection: void 0
609
- })).map((e) => ({
610
- deliveryKey: e.id,
611
- pipe: e.pipe,
612
- table: e.sourceTable,
613
- op: e.op,
614
- key: e.key,
615
- attempts: e.attempts,
616
- lastError: e.lastError,
617
- createdAt: e.createdAt
618
- })) }
619
- };
620
- })
621
- }],
640
+ if (typeof t != "object" || !t || !("deliveryKey" in t) || typeof t.deliveryKey != "string" || t.deliveryKey.length === 0 || !("confirm" in t) || t.confirm !== !0) return {
641
+ kind: "json",
642
+ status: 400,
643
+ data: { error: "A delivery key and explicit confirmation are required." }
644
+ };
645
+ let n = D.current;
646
+ return n === null ? {
647
+ kind: "json",
648
+ status: 503,
649
+ data: { error: "Store unavailable." }
650
+ } : {
651
+ kind: "json",
652
+ data: { accepted: await n.updateMany(C, {
653
+ status: "pending",
654
+ attempts: 0,
655
+ nextAttemptAt: /* @__PURE__ */ new Date(),
656
+ claimedBy: null,
657
+ claimedAt: null
658
+ }, { where: c(d("id", t.deliveryKey), d("status", "dead"), m("pipe", [...S.values()].map((e) => e.enginePipe.key))) }) === 1 }
659
+ };
660
+ })
661
+ }
662
+ ],
622
663
  onChangeEvent: (e) => {
623
664
  let n = S.get(e.table);
624
665
  if (n === void 0) return t.void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-cdc-out",
3
- "version": "0.70.0",
3
+ "version": "0.71.1",
4
4
  "description": "Declarative reverse-ETL: mirror framework table changes outward to external sinks (webhook, Kafka via @voltro/plugin-queue's kafkaSink, plus a CdcSink interface for custom sinks) through a durable outbox — ordered per pipe, at-least-once from enqueue, retried with backoff, dead-lettered.",
5
5
  "keywords": [
6
6
  "voltro",
@@ -33,8 +33,8 @@
33
33
  "node": ">=24.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "@voltro/database": "0.70.0",
37
- "@voltro/protocol": "0.70.0"
36
+ "@voltro/database": "0.71.1",
37
+ "@voltro/protocol": "0.71.1"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "effect": "^3.22.1"