@12-apps/marketplace 1.3.0 → 1.4.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/ADOPTING.md +47 -0
- package/README.md +71 -0
- package/dist/99food/index.d.ts +33 -2
- package/dist/99food/index.js +34 -2
- package/dist/99food/index.js.map +1 -1
- package/dist/{adapter-0l_EmuJA.d.ts → adapter-B8QtQ2RA.d.ts} +126 -3
- package/dist/{chunk-AYYBRQJV.js → chunk-DPCZVN2C.js} +43 -3
- package/dist/chunk-DPCZVN2C.js.map +1 -0
- package/dist/{chunk-XUAFXNOH.js → chunk-EBAIZQPB.js} +395 -4
- package/dist/chunk-EBAIZQPB.js.map +1 -0
- package/dist/{chunk-RVBTARIY.js → chunk-SZRZTLVU.js} +1 -1
- package/dist/chunk-SZRZTLVU.js.map +1 -0
- package/dist/{engine-CZsP8KWd.d.ts → engine-o5cm54vC.d.ts} +242 -2
- package/dist/hono/index.d.ts +2 -2
- package/dist/hono/index.js +2 -2
- package/dist/ifood/index.d.ts +14 -2
- package/dist/ifood/index.js +164 -1
- package/dist/ifood/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +300 -3
- package/dist/index.js.map +1 -1
- package/dist/manifest/server.d.ts +4 -2
- package/dist/manifest/server.js +2 -2
- package/dist/rappi/index.d.ts +15 -2
- package/dist/rappi/index.js +56 -2
- package/dist/rappi/index.js.map +1 -1
- package/dist/server/index.d.ts +18 -7
- package/dist/server/index.js +4 -2
- package/package.json +1 -1
- package/prisma/marketplace.prisma +67 -1
- package/prisma/migrations/20261113230000_marketplace_store_pause/migration.sql +70 -0
- package/src/99food/index.ts +10 -0
- package/src/99food/pause.ts +56 -0
- package/src/core/adapter.ts +12 -2
- package/src/core/engine.ts +37 -0
- package/src/core/pause-job.ts +381 -0
- package/src/core/pause-port.ts +110 -0
- package/src/core/pause-retired.ts +139 -0
- package/src/core/pause-store.ts +151 -0
- package/src/core/pause-sweep.ts +148 -0
- package/src/core/pause.ts +316 -0
- package/src/core/ports.ts +11 -0
- package/src/ifood/index.ts +4 -0
- package/src/ifood/pause.ts +257 -0
- package/src/index.ts +24 -0
- package/src/rappi/index.ts +11 -0
- package/src/rappi/outbound.ts +2 -2
- package/src/rappi/pause.ts +98 -0
- package/src/server/index.ts +1 -0
- package/src/server/jobs.ts +64 -4
- package/dist/chunk-AYYBRQJV.js.map +0 -1
- package/dist/chunk-RVBTARIY.js.map +0 -1
- package/dist/chunk-XUAFXNOH.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AvailabilityRetryError,
|
|
2
3
|
CATALOGUE_GIVE_UP_MS,
|
|
3
4
|
CATALOGUE_ROW_SELECT,
|
|
4
5
|
CATALOGUE_STALE_MS,
|
|
5
6
|
CLAIM_SELECT,
|
|
6
7
|
CatalogueRetryError,
|
|
7
8
|
FetchOrderRetryError,
|
|
9
|
+
MARKETPLACE_AVAILABILITY_JOB,
|
|
8
10
|
MARKETPLACE_CATALOGUE_JOB,
|
|
9
11
|
MARKETPLACE_FETCH_ORDER_JOB,
|
|
10
12
|
MARKETPLACE_OUTBOUND_JOB,
|
|
@@ -15,6 +17,8 @@ import {
|
|
|
15
17
|
OUTBOUND_STALE_MS,
|
|
16
18
|
OutboundRetryError,
|
|
17
19
|
PROVIDER_ID_PATTERN,
|
|
20
|
+
STORE_PAUSE_LEASE_MS,
|
|
21
|
+
availabilityDedupeKey,
|
|
18
22
|
awaitOrderBody,
|
|
19
23
|
cancelAcceptance,
|
|
20
24
|
catalogueConnection,
|
|
@@ -23,10 +27,13 @@ import {
|
|
|
23
27
|
connectionMerchantId,
|
|
24
28
|
createAdapterRegistry,
|
|
25
29
|
deferInboxEvent,
|
|
30
|
+
enqueueAvailability,
|
|
26
31
|
enqueueCatalogue,
|
|
27
32
|
enqueueOutbound,
|
|
28
33
|
expireLapsedAcceptances,
|
|
29
34
|
failCancellationRequest,
|
|
35
|
+
hasPauseTable,
|
|
36
|
+
holdsSomething,
|
|
30
37
|
ingestMarketplaceOrder,
|
|
31
38
|
listMarketplaceIntegrations,
|
|
32
39
|
listMarketplaceMenuLinks,
|
|
@@ -36,7 +43,9 @@ import {
|
|
|
36
43
|
merchantMismatch,
|
|
37
44
|
notPendingProblem,
|
|
38
45
|
outboundDedupeKey,
|
|
46
|
+
pauseTable,
|
|
39
47
|
planCancellation,
|
|
48
|
+
readPause,
|
|
40
49
|
recordInboxEvent,
|
|
41
50
|
refusalData,
|
|
42
51
|
requestData,
|
|
@@ -45,6 +54,7 @@ import {
|
|
|
45
54
|
resolveIngestionTarget,
|
|
46
55
|
resolveReason,
|
|
47
56
|
resolveTenantByMerchant,
|
|
57
|
+
runAvailability,
|
|
48
58
|
runCatalogue,
|
|
49
59
|
runFetchOrder,
|
|
50
60
|
runOutbound,
|
|
@@ -55,14 +65,14 @@ import {
|
|
|
55
65
|
tellCancellationFailed,
|
|
56
66
|
upsertLink,
|
|
57
67
|
viewOf
|
|
58
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-EBAIZQPB.js";
|
|
59
69
|
import {
|
|
60
70
|
stableUuid
|
|
61
71
|
} from "./chunk-M2V4RFMA.js";
|
|
62
72
|
import {
|
|
63
73
|
answered,
|
|
64
74
|
outboundResultOf
|
|
65
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-SZRZTLVU.js";
|
|
66
76
|
import {
|
|
67
77
|
__name
|
|
68
78
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -498,6 +508,284 @@ async function readCatalogueDocument(ctx, input) {
|
|
|
498
508
|
}
|
|
499
509
|
__name(readCatalogueDocument, "readCatalogueDocument");
|
|
500
510
|
|
|
511
|
+
// src/core/pause.ts
|
|
512
|
+
async function liveConnections(ctx, clientId) {
|
|
513
|
+
const db = await ctx.ports.db();
|
|
514
|
+
return await db.marketplaceIntegration.findMany({
|
|
515
|
+
where: { clientId, enabled: true, archivedAt: null },
|
|
516
|
+
select: { provider: true, externalMerchantId: true, credentials: true },
|
|
517
|
+
orderBy: { provider: "asc" }
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
__name(liveConnections, "liveConnections");
|
|
521
|
+
var isConnected = /* @__PURE__ */ __name((row) => row.credentials !== "" && Boolean(row.externalMerchantId), "isConnected");
|
|
522
|
+
function validTimeZone(timeZone) {
|
|
523
|
+
try {
|
|
524
|
+
new Intl.DateTimeFormat("en-US", { timeZone });
|
|
525
|
+
return timeZone !== "";
|
|
526
|
+
} catch {
|
|
527
|
+
return false;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
__name(validTimeZone, "validTimeZone");
|
|
531
|
+
function alreadyAsked(row, until) {
|
|
532
|
+
if (!row || row.wanted !== "PAUSED") return false;
|
|
533
|
+
if (row.state !== "PAUSING" && row.state !== "PAUSED") return false;
|
|
534
|
+
return row.until !== null && row.until.getTime() === until.getTime();
|
|
535
|
+
}
|
|
536
|
+
__name(alreadyAsked, "alreadyAsked");
|
|
537
|
+
async function askPause(ctx, input, provider) {
|
|
538
|
+
const existing = await readPause(ctx, input.clientId, provider);
|
|
539
|
+
if (alreadyAsked(existing, input.until)) return "unchanged";
|
|
540
|
+
const table = pauseTable(await ctx.ports.db());
|
|
541
|
+
const data = {
|
|
542
|
+
wanted: "PAUSED",
|
|
543
|
+
state: "PAUSING",
|
|
544
|
+
until: input.until,
|
|
545
|
+
reason: input.reason,
|
|
546
|
+
timeZone: input.timeZone,
|
|
547
|
+
requestedAt: input.now,
|
|
548
|
+
// No key is minted here: the job writes one just before its call, so a
|
|
549
|
+
// resume that lands first knows nothing of ours can stand there. A key
|
|
550
|
+
// still in doubt stays on the row (its create may have landed).
|
|
551
|
+
failureCode: null,
|
|
552
|
+
failureDetail: null,
|
|
553
|
+
failedAt: null
|
|
554
|
+
};
|
|
555
|
+
await table.upsert({
|
|
556
|
+
where: { clientId_provider: { clientId: input.clientId, provider } },
|
|
557
|
+
create: { clientId: input.clientId, provider, ...data },
|
|
558
|
+
update: data
|
|
559
|
+
});
|
|
560
|
+
const payload = { clientId: input.clientId, provider };
|
|
561
|
+
await enqueueAvailability(ctx, payload, availabilityDedupeKey(payload, input.now));
|
|
562
|
+
return "queued";
|
|
563
|
+
}
|
|
564
|
+
__name(askPause, "askPause");
|
|
565
|
+
async function pauseStore(ctx, input) {
|
|
566
|
+
const now = input.now ?? ctx.ports.clock.now();
|
|
567
|
+
if (input.until.getTime() <= now.getTime()) return { kind: "invalid", code: "UNTIL_NOT_FUTURE" };
|
|
568
|
+
if (!validTimeZone(input.timeZone)) return { kind: "invalid", code: "TIME_ZONE_INVALID" };
|
|
569
|
+
pauseTable(await ctx.ports.db());
|
|
570
|
+
const full = { ...input, now };
|
|
571
|
+
const marketplaces = [];
|
|
572
|
+
for (const connection of await liveConnections(ctx, input.clientId)) {
|
|
573
|
+
const adapter = ctx.registry.get(connection.provider);
|
|
574
|
+
let outcome;
|
|
575
|
+
if (!adapter?.availability) outcome = "unsupported";
|
|
576
|
+
else if (!isConnected(connection)) outcome = "not-connected";
|
|
577
|
+
else outcome = await askPause(ctx, full, connection.provider);
|
|
578
|
+
marketplaces.push({ provider: connection.provider, outcome });
|
|
579
|
+
}
|
|
580
|
+
if (marketplaces.some((entry) => entry.outcome === "queued")) ctx.ports.publishChanged(input.clientId);
|
|
581
|
+
return { kind: "ok", marketplaces };
|
|
582
|
+
}
|
|
583
|
+
__name(pauseStore, "pauseStore");
|
|
584
|
+
async function askResume(ctx, read, now) {
|
|
585
|
+
let row = read;
|
|
586
|
+
for (let tries = 0; row && tries < 3; tries += 1) {
|
|
587
|
+
if (resumeAsked(row)) return "unchanged";
|
|
588
|
+
const outcome = await writeResume(ctx, row, now);
|
|
589
|
+
if (outcome !== null) return outcome;
|
|
590
|
+
row = await readPause(ctx, read.clientId, read.provider);
|
|
591
|
+
}
|
|
592
|
+
return row ? forceResume(ctx, row, now) : "unchanged";
|
|
593
|
+
}
|
|
594
|
+
__name(askResume, "askResume");
|
|
595
|
+
async function forceResume(ctx, row, now) {
|
|
596
|
+
const table = pauseTable(await ctx.ports.db());
|
|
597
|
+
await table.updateMany({
|
|
598
|
+
where: { id: row.id },
|
|
599
|
+
data: { wanted: "OPEN", state: "RESUMING", requestedAt: now, failureCode: null, failureDetail: null, failedAt: null }
|
|
600
|
+
});
|
|
601
|
+
const payload = { clientId: row.clientId, provider: row.provider };
|
|
602
|
+
await enqueueAvailability(ctx, payload, availabilityDedupeKey(payload, now));
|
|
603
|
+
return "queued";
|
|
604
|
+
}
|
|
605
|
+
__name(forceResume, "forceResume");
|
|
606
|
+
function resumeAsked(row) {
|
|
607
|
+
if (row.wanted !== "OPEN") return false;
|
|
608
|
+
return row.state === "RESUMING" || row.state === "OPEN" && !holdsSomething(row);
|
|
609
|
+
}
|
|
610
|
+
__name(resumeAsked, "resumeAsked");
|
|
611
|
+
async function writeResume(ctx, row, now) {
|
|
612
|
+
const held = holdsSomething(row) || row.state === "PAUSING";
|
|
613
|
+
const table = pauseTable(await ctx.ports.db());
|
|
614
|
+
const moved = await table.updateMany({
|
|
615
|
+
where: { id: row.id, attemptKey: row.attemptKey },
|
|
616
|
+
data: {
|
|
617
|
+
wanted: "OPEN",
|
|
618
|
+
state: held ? "RESUMING" : "OPEN",
|
|
619
|
+
requestedAt: now,
|
|
620
|
+
failureCode: null,
|
|
621
|
+
failureDetail: null,
|
|
622
|
+
failedAt: null,
|
|
623
|
+
...held ? {} : { resumedAt: now }
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
if (moved.count === 0) return null;
|
|
627
|
+
if (!held) return "open";
|
|
628
|
+
const payload = { clientId: row.clientId, provider: row.provider };
|
|
629
|
+
await enqueueAvailability(ctx, payload, availabilityDedupeKey(payload, now));
|
|
630
|
+
return "queued";
|
|
631
|
+
}
|
|
632
|
+
__name(writeResume, "writeResume");
|
|
633
|
+
async function resumeStore(ctx, input) {
|
|
634
|
+
const now = input.now ?? ctx.ports.clock.now();
|
|
635
|
+
const table = pauseTable(await ctx.ports.db());
|
|
636
|
+
const rows = await table.findMany({
|
|
637
|
+
where: { clientId: input.clientId },
|
|
638
|
+
orderBy: { provider: "asc" }
|
|
639
|
+
});
|
|
640
|
+
const marketplaces = [];
|
|
641
|
+
for (const row of rows) marketplaces.push({ provider: row.provider, outcome: await askResume(ctx, row, now) });
|
|
642
|
+
if (marketplaces.some((entry) => entry.outcome !== "unchanged")) ctx.ports.publishChanged(input.clientId);
|
|
643
|
+
return { marketplaces };
|
|
644
|
+
}
|
|
645
|
+
__name(resumeStore, "resumeStore");
|
|
646
|
+
var NEVER_ASKED = {
|
|
647
|
+
state: "OPEN",
|
|
648
|
+
wanted: "OPEN",
|
|
649
|
+
until: null,
|
|
650
|
+
sentUntil: null,
|
|
651
|
+
failureCode: null,
|
|
652
|
+
failureDetail: null,
|
|
653
|
+
pausedAt: null,
|
|
654
|
+
resumedAt: null,
|
|
655
|
+
updatedAt: null
|
|
656
|
+
};
|
|
657
|
+
function viewOf2(ctx, provider, connection, row) {
|
|
658
|
+
const availability = ctx.registry.get(provider)?.availability;
|
|
659
|
+
const recorded = row ? {
|
|
660
|
+
state: row.state,
|
|
661
|
+
wanted: row.wanted,
|
|
662
|
+
until: row.until,
|
|
663
|
+
sentUntil: row.sentUntil,
|
|
664
|
+
failureCode: row.failureCode,
|
|
665
|
+
failureDetail: row.failureDetail,
|
|
666
|
+
pausedAt: row.pausedAt,
|
|
667
|
+
resumedAt: row.resumedAt,
|
|
668
|
+
updatedAt: row.updatedAt
|
|
669
|
+
} : NEVER_ASKED;
|
|
670
|
+
return {
|
|
671
|
+
provider,
|
|
672
|
+
supported: availability !== void 0,
|
|
673
|
+
kind: availability?.kind ?? null,
|
|
674
|
+
connected: connection !== void 0 && isConnected(connection),
|
|
675
|
+
...recorded
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
__name(viewOf2, "viewOf");
|
|
679
|
+
async function availabilityState(ctx, clientId) {
|
|
680
|
+
const db = await ctx.ports.db();
|
|
681
|
+
const connections = await liveConnections(ctx, clientId);
|
|
682
|
+
const rows = db.marketplaceStorePause ? await db.marketplaceStorePause.findMany({ where: { clientId } }) : [];
|
|
683
|
+
const byProvider = new Map(rows.map((row) => [row.provider, row]));
|
|
684
|
+
const views = connections.map(
|
|
685
|
+
(connection) => viewOf2(ctx, connection.provider, connection, byProvider.get(connection.provider))
|
|
686
|
+
);
|
|
687
|
+
const live = new Set(connections.map((connection) => connection.provider));
|
|
688
|
+
for (const row of rows) {
|
|
689
|
+
if (!live.has(row.provider) && holdsSomething(row)) views.push(viewOf2(ctx, row.provider, void 0, row));
|
|
690
|
+
}
|
|
691
|
+
return views;
|
|
692
|
+
}
|
|
693
|
+
__name(availabilityState, "availabilityState");
|
|
694
|
+
|
|
695
|
+
// src/core/pause-sweep.ts
|
|
696
|
+
var sweepKey = /* @__PURE__ */ __name((row, now) => availabilityDedupeKey({ clientId: row.clientId, provider: row.provider }, row.requestedAt, `:sweep:${now.getTime()}`), "sweepKey");
|
|
697
|
+
async function requeue(ctx, rows, now) {
|
|
698
|
+
let queued = 0;
|
|
699
|
+
for (const row of rows) {
|
|
700
|
+
if (await enqueueAvailability(ctx, { clientId: row.clientId, provider: row.provider }, sweepKey(row, now))) queued += 1;
|
|
701
|
+
}
|
|
702
|
+
return queued;
|
|
703
|
+
}
|
|
704
|
+
__name(requeue, "requeue");
|
|
705
|
+
async function expire(ctx, now) {
|
|
706
|
+
const table = pauseTable(await ctx.ports.db());
|
|
707
|
+
const rows = await table.findMany({
|
|
708
|
+
where: { wanted: "PAUSED", state: { in: ["PAUSING", "PAUSED", "FAILED"] }, until: { lt: now } }
|
|
709
|
+
});
|
|
710
|
+
let expired = 0;
|
|
711
|
+
for (const row of rows) {
|
|
712
|
+
const held = holdsSomething(row);
|
|
713
|
+
const moved = await table.updateMany({
|
|
714
|
+
where: { id: row.id, wanted: "PAUSED", until: row.until },
|
|
715
|
+
data: { wanted: "OPEN", state: held ? "RESUMING" : "OPEN", requestedAt: now, failureCode: null, failureDetail: null, failedAt: null }
|
|
716
|
+
});
|
|
717
|
+
if (moved.count === 0) continue;
|
|
718
|
+
expired += 1;
|
|
719
|
+
ctx.ports.publishChanged(row.clientId);
|
|
720
|
+
if (held) await requeue(ctx, [{ ...row, requestedAt: now }], now);
|
|
721
|
+
}
|
|
722
|
+
return expired;
|
|
723
|
+
}
|
|
724
|
+
__name(expire, "expire");
|
|
725
|
+
async function giveUp(ctx, cutoff, now) {
|
|
726
|
+
const table = pauseTable(await ctx.ports.db());
|
|
727
|
+
let failed = 0;
|
|
728
|
+
for (const [state, code] of [["PAUSING", "PAUSE_UNANSWERED"], ["RESUMING", "RESUME_UNANSWERED"]]) {
|
|
729
|
+
const moved = await table.updateMany({
|
|
730
|
+
where: { state, requestedAt: { lt: cutoff } },
|
|
731
|
+
data: { state: "FAILED", failureCode: code, failureDetail: null, failedAt: now }
|
|
732
|
+
});
|
|
733
|
+
failed += moved.count;
|
|
734
|
+
}
|
|
735
|
+
return failed;
|
|
736
|
+
}
|
|
737
|
+
__name(giveUp, "giveUp");
|
|
738
|
+
async function retryFailedResumes(ctx, stale, cutoff) {
|
|
739
|
+
const table = pauseTable(await ctx.ports.db());
|
|
740
|
+
const rows = await table.findMany({
|
|
741
|
+
where: { state: "FAILED", wanted: "OPEN", failedAt: { lt: stale }, requestedAt: { gte: cutoff } }
|
|
742
|
+
});
|
|
743
|
+
const retried = [];
|
|
744
|
+
for (const row of rows.filter(holdsSomething)) {
|
|
745
|
+
const moved = await table.updateMany({ where: { id: row.id, state: "FAILED", wanted: "OPEN" }, data: { state: "RESUMING" } });
|
|
746
|
+
if (moved.count > 0) retried.push(row);
|
|
747
|
+
}
|
|
748
|
+
return retried;
|
|
749
|
+
}
|
|
750
|
+
__name(retryFailedResumes, "retryFailedResumes");
|
|
751
|
+
async function reopenOrphans(ctx, stale) {
|
|
752
|
+
const table = pauseTable(await ctx.ports.db());
|
|
753
|
+
const rows = await table.findMany({
|
|
754
|
+
where: {
|
|
755
|
+
state: "OPEN",
|
|
756
|
+
wanted: "OPEN",
|
|
757
|
+
requestedAt: { lt: stale },
|
|
758
|
+
OR: [{ attemptKey: { not: null } }, { externalId: { not: null } }, { sentUntil: { not: null } }, { retiredExternalIds: { not: null } }]
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
const reopened = [];
|
|
762
|
+
for (const row of rows) {
|
|
763
|
+
const moved = await table.updateMany({ where: { id: row.id, state: "OPEN", wanted: "OPEN" }, data: { state: "RESUMING" } });
|
|
764
|
+
if (moved.count > 0) reopened.push(row);
|
|
765
|
+
}
|
|
766
|
+
return reopened;
|
|
767
|
+
}
|
|
768
|
+
__name(reopenOrphans, "reopenOrphans");
|
|
769
|
+
async function sweepAvailability(ctx, now) {
|
|
770
|
+
const db = await ctx.ports.db();
|
|
771
|
+
if (!hasPauseTable(db)) return { expired: 0, requeued: 0, givenUp: 0 };
|
|
772
|
+
const table = pauseTable(db);
|
|
773
|
+
const stale = new Date(now.getTime() - OUTBOUND_STALE_MS);
|
|
774
|
+
const cutoff = new Date(now.getTime() - OUTBOUND_GIVE_UP_MS);
|
|
775
|
+
const expired = await expire(ctx, now);
|
|
776
|
+
const givenUp = await giveUp(ctx, cutoff, now);
|
|
777
|
+
const waiting = await table.findMany({
|
|
778
|
+
where: { state: { in: ["PAUSING", "RESUMING"] }, requestedAt: { lt: stale, gte: cutoff } }
|
|
779
|
+
});
|
|
780
|
+
const retired = await table.findMany({ where: { state: "PAUSED", retiredExternalIds: { not: null } } });
|
|
781
|
+
const failedResumes = await retryFailedResumes(ctx, stale, cutoff);
|
|
782
|
+
const orphans = await reopenOrphans(ctx, stale);
|
|
783
|
+
const requeued = await requeue(ctx, [...waiting, ...retired, ...failedResumes, ...orphans], now);
|
|
784
|
+
if (givenUp > 0) ctx.ports.logger.error(`marketplace.availability-sweep: gave up on ${givenUp} store pause ask(s).`);
|
|
785
|
+
return { expired, requeued, givenUp };
|
|
786
|
+
}
|
|
787
|
+
__name(sweepAvailability, "sweepAvailability");
|
|
788
|
+
|
|
501
789
|
// src/core/pipeline.ts
|
|
502
790
|
function normalizeEvent(ctx, provider, payload) {
|
|
503
791
|
return ctx.registry.get(provider)?.normalize(payload) ?? null;
|
|
@@ -696,15 +984,22 @@ function createMarketplaceEngine(config) {
|
|
|
696
984
|
withdraw: /* @__PURE__ */ __name((input) => withdrawFromCatalogue(ctx, input), "withdraw"),
|
|
697
985
|
catalogueState: /* @__PURE__ */ __name((input) => readCatalogueState(ctx, input), "catalogueState"),
|
|
698
986
|
catalogueDocument: /* @__PURE__ */ __name((input) => readCatalogueDocument(ctx, input), "catalogueDocument"),
|
|
699
|
-
runCatalogue: /* @__PURE__ */ __name((payload, attempt) => runCatalogue(ctx, payload, attempt), "runCatalogue")
|
|
987
|
+
runCatalogue: /* @__PURE__ */ __name((payload, attempt) => runCatalogue(ctx, payload, attempt), "runCatalogue"),
|
|
988
|
+
pauseStore: /* @__PURE__ */ __name((input) => pauseStore(ctx, input), "pauseStore"),
|
|
989
|
+
resumeStore: /* @__PURE__ */ __name((input) => resumeStore(ctx, input), "resumeStore"),
|
|
990
|
+
availabilityState: /* @__PURE__ */ __name((clientId) => availabilityState(ctx, clientId), "availabilityState"),
|
|
991
|
+
runAvailability: /* @__PURE__ */ __name((payload, attempt) => runAvailability(ctx, payload, attempt), "runAvailability"),
|
|
992
|
+
sweepAvailability: /* @__PURE__ */ __name((now) => sweepAvailability(ctx, now ?? ports.clock.now()), "sweepAvailability")
|
|
700
993
|
};
|
|
701
994
|
}
|
|
702
995
|
__name(createMarketplaceEngine, "createMarketplaceEngine");
|
|
703
996
|
export {
|
|
997
|
+
AvailabilityRetryError,
|
|
704
998
|
CATALOGUE_GIVE_UP_MS,
|
|
705
999
|
CATALOGUE_STALE_MS,
|
|
706
1000
|
CatalogueRetryError,
|
|
707
1001
|
FetchOrderRetryError,
|
|
1002
|
+
MARKETPLACE_AVAILABILITY_JOB,
|
|
708
1003
|
MARKETPLACE_CATALOGUE_JOB,
|
|
709
1004
|
MARKETPLACE_FETCH_ORDER_JOB,
|
|
710
1005
|
MARKETPLACE_OUTBOUND_JOB,
|
|
@@ -713,7 +1008,9 @@ export {
|
|
|
713
1008
|
OUTBOUND_STALE_MS,
|
|
714
1009
|
OutboundRetryError,
|
|
715
1010
|
PROVIDER_ID_PATTERN,
|
|
1011
|
+
STORE_PAUSE_LEASE_MS,
|
|
716
1012
|
answered,
|
|
1013
|
+
availabilityDedupeKey,
|
|
717
1014
|
catalogueDedupeKey,
|
|
718
1015
|
createAdapterRegistry,
|
|
719
1016
|
createMarketplaceEngine,
|