@12-apps/marketplace 1.16.0 → 1.18.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.
Files changed (79) hide show
  1. package/ADOPTING.md +185 -0
  2. package/dist/99food/index.d.ts +2 -2
  3. package/dist/99food/index.js +2 -2
  4. package/dist/{adapter-CjVdMhZ2.d.ts → adapter-ZpAWKoCk.d.ts} +300 -3
  5. package/dist/{chunk-TRUK5ZBE.js → chunk-3B5EULS6.js} +2 -2
  6. package/dist/{chunk-DJIMUEHT.js → chunk-BLHZ3MRB.js} +79 -7
  7. package/dist/chunk-BLHZ3MRB.js.map +1 -0
  8. package/dist/{chunk-SGOTN5PX.js → chunk-LO7OKO6V.js} +45 -4
  9. package/dist/chunk-LO7OKO6V.js.map +1 -0
  10. package/dist/{chunk-TICWLBSA.js → chunk-MDEIRGNL.js} +1372 -823
  11. package/dist/chunk-MDEIRGNL.js.map +1 -0
  12. package/dist/{chunk-H2VQRD3B.js → chunk-Q5RMVNU5.js} +1 -1
  13. package/dist/chunk-Q5RMVNU5.js.map +1 -0
  14. package/dist/{chunk-BTKVZAJI.js → chunk-ZT6TZTLD.js} +1 -1
  15. package/dist/chunk-ZT6TZTLD.js.map +1 -0
  16. package/dist/{client-DgzCkl8u.d.ts → client-DpEq0yXb.d.ts} +1 -1
  17. package/dist/{engine-DSRj7qnC.d.ts → engine-DRRhAjZK.d.ts} +566 -293
  18. package/dist/hono/index.d.ts +2 -2
  19. package/dist/hono/index.js +4 -4
  20. package/dist/ifood/index.d.ts +14 -2
  21. package/dist/ifood/index.js +406 -120
  22. package/dist/ifood/index.js.map +1 -1
  23. package/dist/index.d.ts +21 -4
  24. package/dist/index.js +453 -43
  25. package/dist/index.js.map +1 -1
  26. package/dist/keeta/index.d.ts +2 -2
  27. package/dist/keeta/index.js +2 -2
  28. package/dist/manifest/index.d.ts +78 -0
  29. package/dist/manifest/index.js +1 -1
  30. package/dist/manifest/server.d.ts +6 -2
  31. package/dist/manifest/server.js +4 -4
  32. package/dist/rappi/index.d.ts +1 -1
  33. package/dist/rappi/index.js +1 -1
  34. package/dist/server/index.d.ts +93 -7
  35. package/dist/server/index.js +4 -4
  36. package/package.json +1 -1
  37. package/prisma/marketplace.prisma +70 -2
  38. package/prisma/migrations/20261203180000_marketplace_app_link_check/migration.sql +14 -0
  39. package/prisma/migrations/20261203190000_marketplace_disputes/migration.sql +96 -0
  40. package/prisma/migrations/20261203200000_marketplace_status_logistics_steps/migration.sql +12 -0
  41. package/src/core/adapter.ts +14 -2
  42. package/src/core/app-linking.ts +396 -0
  43. package/src/core/delivery-code.ts +119 -0
  44. package/src/core/dispute-engine.ts +32 -0
  45. package/src/core/dispute-job.ts +142 -0
  46. package/src/core/dispute-port.ts +133 -0
  47. package/src/core/dispute-store.ts +203 -0
  48. package/src/core/disputes.ts +263 -0
  49. package/src/core/engine.ts +12 -55
  50. package/src/core/integration.ts +3 -1
  51. package/src/core/link-engine.ts +176 -0
  52. package/src/core/link-store.ts +15 -0
  53. package/src/core/linking-port.ts +35 -1
  54. package/src/core/linking.ts +8 -0
  55. package/src/core/logistics.ts +388 -0
  56. package/src/core/outbound-queue.ts +6 -1
  57. package/src/core/outbound-sweep.ts +19 -6
  58. package/src/core/outbound.ts +4 -5
  59. package/src/core/pipeline.ts +14 -4
  60. package/src/core/ports.ts +20 -2
  61. package/src/core/status-job.ts +3 -0
  62. package/src/core/status-store.ts +2 -1
  63. package/src/core/types.ts +10 -0
  64. package/src/ifood/app-linking.ts +119 -0
  65. package/src/ifood/disputes.ts +209 -0
  66. package/src/ifood/index.ts +15 -1
  67. package/src/ifood/logistics.ts +38 -0
  68. package/src/ifood/normalize.ts +14 -1
  69. package/src/index.ts +44 -0
  70. package/src/server/jobs.ts +51 -3
  71. package/src/server/link-routes.ts +56 -4
  72. package/src/server/mcp-link.ts +44 -2
  73. package/src/server/mcp.ts +2 -1
  74. package/dist/chunk-BTKVZAJI.js.map +0 -1
  75. package/dist/chunk-DJIMUEHT.js.map +0 -1
  76. package/dist/chunk-H2VQRD3B.js.map +0 -1
  77. package/dist/chunk-SGOTN5PX.js.map +0 -1
  78. package/dist/chunk-TICWLBSA.js.map +0 -1
  79. /package/dist/{chunk-TRUK5ZBE.js.map → chunk-3B5EULS6.js.map} +0 -0
package/dist/index.js CHANGED
@@ -9,11 +9,14 @@ import {
9
9
  CONFIRMED_BEFORE_ORDER,
10
10
  CancellationReasonsRetryError,
11
11
  CatalogueRetryError,
12
+ DisputeAnswerRetryError,
12
13
  FetchOrderRetryError,
14
+ LOGISTICS_STEPS,
13
15
  MARKETPLACE_ACKNOWLEDGE_JOB,
14
16
  MARKETPLACE_AVAILABILITY_JOB,
15
17
  MARKETPLACE_CANCELLATION_REASONS_JOB,
16
18
  MARKETPLACE_CATALOGUE_JOB,
19
+ MARKETPLACE_DISPUTE_ANSWER_JOB,
17
20
  MARKETPLACE_FETCH_ORDER_JOB,
18
21
  MARKETPLACE_OUTBOUND_JOB,
19
22
  MarketplaceAdapterRegistrationError,
@@ -24,7 +27,9 @@ import {
24
27
  OUTBOUND_STALE_MS,
25
28
  OutboundRetryError,
26
29
  STORE_PAUSE_LEASE_MS,
30
+ answerDispute,
27
31
  appCredentialsOf,
32
+ applyDisputeEvent,
28
33
  applyMarketplaceConfirmation,
29
34
  availabilityDedupeKey,
30
35
  awaitOrderBody,
@@ -37,6 +42,7 @@ import {
37
42
  connectionMerchantId,
38
43
  createAdapterRegistry,
39
44
  deferInboxEvent,
45
+ disputeView,
40
46
  enqueueAcknowledge,
41
47
  enqueueAvailability,
42
48
  enqueueCatalogue,
@@ -53,6 +59,8 @@ import {
53
59
  listMarketplaceMenuLinks,
54
60
  listPendingAcceptances,
55
61
  listRetryableInboxEvents,
62
+ logisticsCallContext,
63
+ logisticsEngine,
56
64
  markCancelledBeforeIngest,
57
65
  merchantHeldElsewhere,
58
66
  merchantMismatch,
@@ -61,6 +69,7 @@ import {
61
69
  outboundDedupeKey,
62
70
  pauseTable,
63
71
  planCancellation,
72
+ readDisputes,
64
73
  readOrderReasons,
65
74
  readOutboundConnection,
66
75
  readPause,
@@ -78,9 +87,11 @@ import {
78
87
  runAvailability,
79
88
  runCancellationReasons,
80
89
  runCatalogue,
90
+ runDisputeAnswer,
81
91
  runFetchOrder,
82
92
  runOutbound,
83
93
  saveMarketplaceIntegration,
94
+ sealAppLink,
84
95
  sealLink,
85
96
  settleInboxEvent,
86
97
  statusDedupeKey,
@@ -93,14 +104,14 @@ import {
93
104
  upsertLink,
94
105
  validatePickupCode,
95
106
  viewOf
96
- } from "./chunk-TICWLBSA.js";
107
+ } from "./chunk-MDEIRGNL.js";
97
108
  import {
98
109
  centsFromMajor
99
110
  } from "./chunk-WN2EK4KX.js";
100
111
  import {
101
112
  PROVIDER_ID_PATTERN,
102
113
  normalizedLineTotalCents
103
- } from "./chunk-H2VQRD3B.js";
114
+ } from "./chunk-Q5RMVNU5.js";
104
115
  import {
105
116
  stableUuid
106
117
  } from "./chunk-M2V4RFMA.js";
@@ -108,16 +119,81 @@ import {
108
119
  answered,
109
120
  outboundResultOf,
110
121
  tokenGrantResultOf
111
- } from "./chunk-BTKVZAJI.js";
122
+ } from "./chunk-ZT6TZTLD.js";
112
123
  import {
113
124
  __name
114
125
  } from "./chunk-7QVYU63E.js";
115
126
 
127
+ // src/core/delivery-code.ts
128
+ var CODE_BEFORE_ORDER = "delivery code request before its order";
129
+ var HELD_SELECT = {
130
+ orderId: true,
131
+ provider: true,
132
+ status: true,
133
+ deliveredBy: true,
134
+ externalOrderId: true,
135
+ externalDisplayId: true,
136
+ createdAt: true
137
+ };
138
+ async function applyDeliveryCodeRequest(ctx, inboxId, clientId, event) {
139
+ const hook = ctx.ports.order.onDeliveryCodeRequested;
140
+ if (!event.deliveryCodeRequested || !hook || !event.externalOrderId) return null;
141
+ const db = await ctx.ports.db();
142
+ const held = await db.marketplaceAcceptance.findFirst({
143
+ where: { clientId, provider: event.provider, externalOrderId: event.externalOrderId },
144
+ select: HELD_SELECT
145
+ });
146
+ if (!held) {
147
+ await deferInboxEvent(ctx, inboxId, CODE_BEFORE_ORDER);
148
+ return { kind: "ignored", reason: CODE_BEFORE_ORDER };
149
+ }
150
+ if (held.status !== "ACCEPTED") {
151
+ const reason = `the order is ${held.status}, not ACCEPTED`;
152
+ await settleInboxEvent(ctx, inboxId, "IGNORED", reason);
153
+ return { kind: "ignored", reason };
154
+ }
155
+ await hook.call(ctx.ports.order, clientId, held.orderId);
156
+ await settleInboxEvent(ctx, inboxId, "PROCESSED");
157
+ ctx.ports.publishChanged(clientId);
158
+ return { kind: "deliveryCodeRequested", orderId: held.orderId };
159
+ }
160
+ __name(applyDeliveryCodeRequest, "applyDeliveryCodeRequest");
161
+ async function verifyDeliveryCode(ctx, input) {
162
+ try {
163
+ const db = await ctx.ports.db();
164
+ const held = await db.marketplaceAcceptance.findFirst({
165
+ where: { clientId: input.clientId, orderId: input.orderId },
166
+ select: HELD_SELECT
167
+ });
168
+ if (!held) return { kind: "UNAVAILABLE", reason: "no marketplace order" };
169
+ if (held.deliveredBy !== "MERCHANT") return { kind: "UNAVAILABLE", reason: "the store does not carry this order" };
170
+ const logistics = ctx.registry.get(held.provider)?.logistics;
171
+ if (!logistics?.verifyDeliveryCode) return { kind: "UNAVAILABLE", reason: "the marketplace checks no delivery code" };
172
+ const call = await logisticsCallContext(ctx, input.clientId, held.provider);
173
+ if (typeof call === "string") return { kind: "UNAVAILABLE", reason: call };
174
+ const ref = {
175
+ externalOrderId: held.externalOrderId,
176
+ externalDisplayId: held.externalDisplayId,
177
+ hostOrderCode: held.orderId,
178
+ placedAt: held.createdAt
179
+ };
180
+ return await logistics.verifyDeliveryCode(call, ref, input.code);
181
+ } catch (error) {
182
+ ctx.ports.logger.warn(`delivery code for order ${input.orderId} not checked: ${error instanceof Error ? error.message : String(error)}`);
183
+ return { kind: "UNAVAILABLE", reason: "the check failed" };
184
+ }
185
+ }
186
+ __name(verifyDeliveryCode, "verifyDeliveryCode");
187
+ function deliveryCodeEngine(ctx) {
188
+ return { verifyDeliveryCode: /* @__PURE__ */ __name((input) => verifyDeliveryCode(ctx, input), "verifyDeliveryCode") };
189
+ }
190
+ __name(deliveryCodeEngine, "deliveryCodeEngine");
191
+
116
192
  // src/core/bulk.ts
117
- function duplicates(rows, keyOf2, list, field) {
193
+ function duplicates(rows, keyOf3, list, field) {
118
194
  const seen = /* @__PURE__ */ new Set();
119
195
  return rows.flatMap((row, index) => {
120
- const key = keyOf2(row);
196
+ const key = keyOf3(row);
121
197
  if (!seen.has(key)) {
122
198
  seen.add(key);
123
199
  return [];
@@ -331,7 +407,7 @@ function requestOnly(ctx, plan) {
331
407
  __name(requestOnly, "requestOnly");
332
408
  async function admitAndClaim(ctx, clientId, planned, validateOnly) {
333
409
  await ctx.ports.transaction(async (tx) => {
334
- const refused3 = [];
410
+ const refused4 = [];
335
411
  for (const one of planned) {
336
412
  const admission = one.input.decision === "ACCEPT" ? one.input.admission ?? {} : {};
337
413
  const answer = await ctx.ports.order.admit({
@@ -343,18 +419,18 @@ async function admitAndClaim(ctx, clientId, planned, validateOnly) {
343
419
  });
344
420
  if (!answer.admitted) {
345
421
  const host = { code: answer.code, message: answer.message, details: answer.details };
346
- refused3.push({ path: ["decisions", one.index], code: "HOST_REFUSED", host });
422
+ refused4.push({ path: ["decisions", one.index], code: "HOST_REFUSED", host });
347
423
  }
348
424
  }
349
- if (refused3.length > 0) throw new Rollback(refused3);
425
+ if (refused4.length > 0) throw new Rollback(refused4);
350
426
  for (const one of planned) {
351
427
  const claimed = await tx.marketplaceAcceptance.updateMany({
352
428
  where: { orderId: one.input.orderId, clientId, status: "AWAITING", ...NO_STANDING_REQUEST },
353
429
  data: one.data
354
430
  });
355
- if (claimed.count === 0) refused3.push({ path: ["decisions", one.index, "orderId"], code: "CONFLICT" });
431
+ if (claimed.count === 0) refused4.push({ path: ["decisions", one.index, "orderId"], code: "CONFLICT" });
356
432
  }
357
- if (refused3.length > 0) throw new Rollback(refused3);
433
+ if (refused4.length > 0) throw new Rollback(refused4);
358
434
  if (validateOnly) throw new Rollback(null);
359
435
  });
360
436
  }
@@ -791,14 +867,273 @@ function conformityEngine(ctx) {
791
867
  }
792
868
  __name(conformityEngine, "conformityEngine");
793
869
 
794
- // src/core/linking.ts
870
+ // src/core/app-linking.ts
871
+ var ATTEMPT_MINUTES = 30;
872
+ var CHECK_EVERY_SECONDS = 30;
795
873
  var refused2 = /* @__PURE__ */ __name((code, status = null, message = null) => ({
796
874
  kind: "refused",
797
875
  code,
798
876
  status,
799
877
  message
800
878
  }), "refused");
801
- var pendingOf = /* @__PURE__ */ __name((row) => ({
879
+ var keyOf = /* @__PURE__ */ __name((clientId, provider) => ({ clientId_provider: { clientId, provider } }), "keyOf");
880
+ var environmentOf = /* @__PURE__ */ __name((value) => value === "SANDBOX" ? "SANDBOX" : "PRODUCTION", "environmentOf");
881
+ function hasAppLinking(ctx, provider) {
882
+ return ctx.registry.get(provider)?.appLinking !== void 0;
883
+ }
884
+ __name(hasAppLinking, "hasAppLinking");
885
+ async function readyOf(ctx, provider, environment) {
886
+ const linking = ctx.registry.get(provider)?.appLinking;
887
+ if (!linking) return null;
888
+ const attempts = (await ctx.ports.db()).marketplaceLinkAttempt;
889
+ if (!attempts) return null;
890
+ const app = await appCredentialsOf(ctx, provider, environment);
891
+ if (!app) return null;
892
+ const call = { http: ctx.ports.http, credentials: app, environment, now: ctx.ports.clock.now(), tokens: ctx.tokens };
893
+ return { linking, attempts, call, environment };
894
+ }
895
+ __name(readyOf, "readyOf");
896
+ var pendingOf = /* @__PURE__ */ __name((linking, row) => ({
897
+ portalUrl: linking.portalUrl,
898
+ expiresAt: row.expiresAt,
899
+ seenAt: row.seenAt ?? null,
900
+ checkedAt: row.checkedAt ?? null
901
+ }), "pendingOf");
902
+ var isLive = /* @__PURE__ */ __name((row, now) => row !== null && row.expiresAt.getTime() > now.getTime(), "isLive");
903
+ var renewed = /* @__PURE__ */ __name((now) => new Date(now.getTime() + ATTEMPT_MINUTES * 6e4), "renewed");
904
+ async function liveAttempt(ready, clientId, provider) {
905
+ const row = await ready.attempts.findUnique({ where: keyOf(clientId, provider) });
906
+ return isLive(row, ready.call.now) ? row : null;
907
+ }
908
+ __name(liveAttempt, "liveAttempt");
909
+ async function takenAmong(db, clientId, provider, ids) {
910
+ const held = await heldBy(db, provider, ids);
911
+ return new Set([...held].flatMap(([merchantId, holder]) => holder === clientId ? [] : [merchantId]));
912
+ }
913
+ __name(takenAmong, "takenAmong");
914
+ async function listFor(ctx, ready, input) {
915
+ const listed = await ready.linking.merchants(ready.call);
916
+ if (listed.kind === "retry") return listed;
917
+ if (listed.kind === "refused") return refused2("MARKETPLACE_REFUSED", listed.status, listed.message);
918
+ const taken = await takenAmong(await ctx.ports.db(), input.clientId, input.provider, listed.value.map((merchant) => merchant.id));
919
+ const judged = listed.value.map((merchant) => ({ ...merchant, taken: taken.has(merchant.id) }));
920
+ if (!input.addresses) return judged;
921
+ return withAddresses(ready, judged);
922
+ }
923
+ __name(listFor, "listFor");
924
+ var ADDRESS_CONCURRENCY = 4;
925
+ async function withAddresses(ready, judged) {
926
+ const out = judged.map((merchant) => ({ ...merchant, address: null }));
927
+ const queue2 = out.filter((merchant) => merchant.taken !== true);
928
+ const worker = /* @__PURE__ */ __name(async () => {
929
+ for (let next = queue2.shift(); next; next = queue2.shift()) {
930
+ const answer = await ready.linking.address(ready.call, next.id).catch(() => null);
931
+ next.address = answer?.kind === "ok" ? answer.value : null;
932
+ }
933
+ }, "worker");
934
+ await Promise.all(Array.from({ length: ADDRESS_CONCURRENCY }, worker));
935
+ return out;
936
+ }
937
+ __name(withAddresses, "withAddresses");
938
+ var pickable = /* @__PURE__ */ __name((merchants) => merchants.some((merchant) => merchant.taken !== true), "pickable");
939
+ async function stamp(ready, row, canPick, renew2) {
940
+ const now = ready.call.now;
941
+ const seen = row.seenAt ?? (canPick ? now : null);
942
+ const data = { checkedAt: now, seenAt: seen, ...renew2 ? { expiresAt: renewed(now) } : {} };
943
+ await ready.attempts.updateMany?.({ where: { clientId: row.clientId, provider: row.provider, verifier: row.verifier }, data });
944
+ return { ...row, ...data };
945
+ }
946
+ __name(stamp, "stamp");
947
+ async function appLinkState(ctx, input) {
948
+ const ready = await readyOf(ctx, input.provider, input.environment ?? "PRODUCTION");
949
+ if (!ready) return { available: false, pending: null };
950
+ const row = await liveAttempt(ready, input.clientId, input.provider);
951
+ if (!row) return { available: true, pending: null };
952
+ const stale = row.seenAt == null && (row.checkedAt == null || ready.call.now.getTime() - row.checkedAt.getTime() >= CHECK_EVERY_SECONDS * 1e3);
953
+ const listed = stale ? await listFor(ctx, ready, { ...input, addresses: false }) : null;
954
+ const checked = Array.isArray(listed) ? await stamp(ready, row, pickable(listed), true) : await renew(ready, row);
955
+ return { available: true, pending: pendingOf(ready.linking, checked) };
956
+ }
957
+ __name(appLinkState, "appLinkState");
958
+ async function renew(ready, row) {
959
+ const data = { expiresAt: renewed(ready.call.now) };
960
+ await ready.attempts.updateMany?.({ where: { clientId: row.clientId, provider: row.provider, verifier: row.verifier }, data });
961
+ return { ...row, ...data };
962
+ }
963
+ __name(renew, "renew");
964
+ async function startAppLink(ctx, input) {
965
+ const environment = input.environment ?? "PRODUCTION";
966
+ const ready = await readyOf(ctx, input.provider, environment);
967
+ if (!ready) return refused2("UNAVAILABLE");
968
+ const portal = ready.linking.portalUrl;
969
+ const row = {
970
+ environment,
971
+ // No secret travels in a centralized link: the column keeps a fresh nonce, so each attempt tells itself from a later one.
972
+ verifier: ctx.ports.secrets.seal(`app-link:${globalThis.crypto.randomUUID()}`),
973
+ userCode: "",
974
+ verificationUrl: portal,
975
+ verificationUrlComplete: portal,
976
+ expiresAt: renewed(ready.call.now),
977
+ seenAt: null,
978
+ checkedAt: null
979
+ };
980
+ await ready.attempts.upsert({
981
+ where: keyOf(input.clientId, input.provider),
982
+ create: { clientId: input.clientId, provider: input.provider, ...row },
983
+ update: row
984
+ });
985
+ return { kind: "started", pending: pendingOf(ready.linking, { clientId: input.clientId, provider: input.provider, ...row }) };
986
+ }
987
+ __name(startAppLink, "startAppLink");
988
+ async function checkAppLink(ctx, input) {
989
+ const attempts = (await ctx.ports.db()).marketplaceLinkAttempt;
990
+ const stored = attempts ? await attempts.findUnique({ where: keyOf(input.clientId, input.provider) }) : null;
991
+ const environment = input.environment ?? environmentOf(stored?.environment);
992
+ const ready = await readyOf(ctx, input.provider, environment);
993
+ if (!ready) return refused2("UNAVAILABLE");
994
+ const merchants = await listFor(ctx, ready, { ...input, addresses: true });
995
+ if (!Array.isArray(merchants)) return merchants;
996
+ const row = isLive(stored, ready.call.now) ? await stamp(ready, stored, pickable(merchants), true) : null;
997
+ return { kind: "checked", pending: row ? pendingOf(ready.linking, row) : null, merchants };
998
+ }
999
+ __name(checkAppLink, "checkAppLink");
1000
+ async function cancelAppLink(ctx, input) {
1001
+ const attempts = (await ctx.ports.db()).marketplaceLinkAttempt;
1002
+ await attempts?.deleteMany({ where: { clientId: input.clientId, provider: input.provider } });
1003
+ }
1004
+ __name(cancelAppLink, "cancelAppLink");
1005
+ async function sweepAppLinks(ctx, input = {}) {
1006
+ const attempts = (await ctx.ports.db()).marketplaceLinkAttempt;
1007
+ if (!attempts?.findMany) return { seen: [], waiting: 0 };
1008
+ const now = ctx.ports.clock.now();
1009
+ const rows = await dueAttempts(attempts, now);
1010
+ const seen = [];
1011
+ for (const group of groupByApp(rows).values()) seen.push(...await sweepGroup(ctx, group));
1012
+ for (const store of seen) ctx.ports.publishLinkSeen?.(store.clientId, store.provider);
1013
+ if (!input.half && rows.length > seen.length) await queueHalfPass(ctx, now);
1014
+ return { seen, waiting: rows.length - seen.length };
1015
+ }
1016
+ __name(sweepAppLinks, "sweepAppLinks");
1017
+ async function dueAttempts(attempts, now) {
1018
+ const due = new Date(now.getTime() - CHECK_EVERY_SECONDS * 1e3);
1019
+ return await attempts.findMany({
1020
+ where: { expiresAt: { gte: now }, seenAt: null, OR: [{ checkedAt: null }, { checkedAt: { lt: due } }] },
1021
+ orderBy: { expiresAt: "asc" },
1022
+ take: SWEEP_BATCH
1023
+ });
1024
+ }
1025
+ __name(dueAttempts, "dueAttempts");
1026
+ function groupByApp(rows) {
1027
+ const groups = /* @__PURE__ */ new Map();
1028
+ for (const row of rows) {
1029
+ const key = `${row.provider}:${environmentOf(row.environment)}`;
1030
+ groups.set(key, [...groups.get(key) ?? [], row]);
1031
+ }
1032
+ return groups;
1033
+ }
1034
+ __name(groupByApp, "groupByApp");
1035
+ async function sweepGroup(ctx, group) {
1036
+ const first = group[0];
1037
+ const ready = await readyOf(ctx, first.provider, environmentOf(first.environment));
1038
+ const listed = ready ? await ready.linking.merchants(ready.call) : null;
1039
+ if (!ready || listed?.kind !== "ok") return [];
1040
+ const held = await heldBy(await ctx.ports.db(), first.provider, listed.value.map((merchant) => merchant.id));
1041
+ const anyFree = listed.value.some((merchant) => !held.has(merchant.id));
1042
+ const holders = new Set(held.values());
1043
+ const seen = [];
1044
+ for (const row of group) {
1045
+ const checked = await stamp(ready, row, anyFree || holders.has(row.clientId), false);
1046
+ if (checked.seenAt) seen.push({ clientId: row.clientId, provider: row.provider });
1047
+ }
1048
+ return seen;
1049
+ }
1050
+ __name(sweepGroup, "sweepGroup");
1051
+ var MARKETPLACE_LINK_CHECK_JOB = "marketplace.link-check";
1052
+ async function queueHalfPass(ctx, now) {
1053
+ const minute = Math.floor(now.getTime() / 6e4);
1054
+ const outcome = await ctx.ports.enqueue.enqueue(MARKETPLACE_LINK_CHECK_JOB, { half: true }, {
1055
+ dedupeKey: `${MARKETPLACE_LINK_CHECK_JOB}:${minute}`,
1056
+ delayMs: CHECK_EVERY_SECONDS * 1e3
1057
+ });
1058
+ if (!outcome.enqueued) ctx.ports.logger.warn(`${MARKETPLACE_LINK_CHECK_JOB}: the half-minute pass was not queued (${outcome.reason ?? "no reason"})`);
1059
+ }
1060
+ __name(queueHalfPass, "queueHalfPass");
1061
+ var SWEEP_BATCH = 200;
1062
+ async function heldBy(db, provider, ids) {
1063
+ if (ids.length === 0) return /* @__PURE__ */ new Map();
1064
+ const rows = await db.marketplaceIntegration.findMany({
1065
+ where: { provider, externalMerchantId: { in: [...ids] }, archivedAt: null },
1066
+ select: { clientId: true, externalMerchantId: true }
1067
+ });
1068
+ return new Map(rows.flatMap((row) => row.externalMerchantId ? [[row.externalMerchantId, row.clientId]] : []));
1069
+ }
1070
+ __name(heldBy, "heldBy");
1071
+ async function savePick(ctx, input, environment) {
1072
+ const now = ctx.ports.clock.now();
1073
+ await ctx.ports.transaction(async (db) => {
1074
+ const existing = await db.marketplaceIntegration.findUnique({
1075
+ where: keyOf(input.clientId, input.provider),
1076
+ select: { archivedAt: true }
1077
+ });
1078
+ const data = {
1079
+ credentials: sealAppLink(ctx),
1080
+ authMode: "LINKED",
1081
+ environment,
1082
+ status: "VERIFIED",
1083
+ lastVerifiedAt: now,
1084
+ archivedAt: null,
1085
+ externalMerchantId: input.merchantId
1086
+ };
1087
+ await db.marketplaceIntegration.upsert({
1088
+ where: keyOf(input.clientId, input.provider),
1089
+ create: { clientId: input.clientId, provider: input.provider, ackSlaSeconds: ctx.ports.defaultAckSlaSeconds, enabled: true, ...data },
1090
+ update: data
1091
+ });
1092
+ if (existing?.archivedAt) {
1093
+ await ctx.ports.audit.record(
1094
+ { clientId: input.clientId, actorId: input.actorId, action: "marketplace.integration.unarchive", provider: input.provider, reason: "linked again", at: now },
1095
+ db
1096
+ );
1097
+ }
1098
+ await db.marketplaceLinkAttempt?.deleteMany({ where: { clientId: input.clientId, provider: input.provider } });
1099
+ });
1100
+ }
1101
+ __name(savePick, "savePick");
1102
+ async function selectAppMerchant(ctx, input) {
1103
+ const attempts = (await ctx.ports.db()).marketplaceLinkAttempt;
1104
+ const stored = attempts ? await attempts.findUnique({ where: keyOf(input.clientId, input.provider) }) : null;
1105
+ const environment = environmentOf(stored?.environment);
1106
+ const ready = await readyOf(ctx, input.provider, environment);
1107
+ if (!ready) return refused2("UNAVAILABLE");
1108
+ const merchants = await listFor(ctx, ready, { ...input, addresses: false });
1109
+ if (!Array.isArray(merchants)) return merchants;
1110
+ const merchant = merchants.find((candidate) => candidate.id === input.merchantId);
1111
+ if (!merchant) return refused2("UNKNOWN_MERCHANT");
1112
+ if (merchant.taken) return refused2("MERCHANT_TAKEN");
1113
+ const pick = { clientId: input.clientId, provider: input.provider, merchantId: input.merchantId, actorId: input.actorId ?? null };
1114
+ const taken = await guardMerchantClaim(ctx, pick, () => savePick(ctx, pick, environment)).then(
1115
+ () => false,
1116
+ (error) => {
1117
+ if (error instanceof MarketplaceMerchantTakenError || isUniqueViolation(error)) return true;
1118
+ throw error;
1119
+ }
1120
+ );
1121
+ if (taken) return refused2("MERCHANT_TAKEN");
1122
+ ctx.ports.publishChanged(input.clientId);
1123
+ const [view] = await listMarketplaceIntegrations(ctx, input.clientId, { providers: [input.provider] });
1124
+ if (!view) throw new Error(`The ${input.provider} connection of ${input.clientId} was not saved.`);
1125
+ return { kind: "selected", integration: view };
1126
+ }
1127
+ __name(selectAppMerchant, "selectAppMerchant");
1128
+
1129
+ // src/core/linking.ts
1130
+ var refused3 = /* @__PURE__ */ __name((code, status = null, message = null) => ({
1131
+ kind: "refused",
1132
+ code,
1133
+ status,
1134
+ message
1135
+ }), "refused");
1136
+ var pendingOf2 = /* @__PURE__ */ __name((row) => ({
802
1137
  userCode: row.userCode,
803
1138
  verificationUrl: row.verificationUrl,
804
1139
  verificationUrlComplete: row.verificationUrlComplete,
@@ -814,22 +1149,22 @@ async function linkingOf(ctx, provider, environment) {
814
1149
  return { linking, attempts, call: { http: ctx.ports.http, credentials: app, environment, now: ctx.ports.clock.now() } };
815
1150
  }
816
1151
  __name(linkingOf, "linkingOf");
817
- var keyOf = /* @__PURE__ */ __name((clientId, provider) => ({ clientId_provider: { clientId, provider } }), "keyOf");
1152
+ var keyOf2 = /* @__PURE__ */ __name((clientId, provider) => ({ clientId_provider: { clientId, provider } }), "keyOf");
818
1153
  async function linkState(ctx, input) {
819
1154
  const ready = await linkingOf(ctx, input.provider, input.environment ?? "PRODUCTION");
820
1155
  if (!ready) return { available: false, pending: null };
821
- const row = await ready.attempts.findUnique({ where: keyOf(input.clientId, input.provider) });
1156
+ const row = await ready.attempts.findUnique({ where: keyOf2(input.clientId, input.provider) });
822
1157
  const live = row && row.expiresAt.getTime() > ctx.ports.clock.now().getTime();
823
- return { available: true, pending: live ? pendingOf(row) : null };
1158
+ return { available: true, pending: live ? pendingOf2(row) : null };
824
1159
  }
825
1160
  __name(linkState, "linkState");
826
1161
  async function startLink(ctx, input) {
827
1162
  const environment = input.environment ?? "PRODUCTION";
828
1163
  const ready = await linkingOf(ctx, input.provider, environment);
829
- if (!ready) return refused2("UNAVAILABLE");
1164
+ if (!ready) return refused3("UNAVAILABLE");
830
1165
  const answer = await ready.linking.requestCode(ready.call);
831
1166
  if (answer.kind === "retry") return answer;
832
- if (answer.kind === "refused") return refused2("MARKETPLACE_REFUSED", answer.status, answer.message);
1167
+ if (answer.kind === "refused") return refused3("MARKETPLACE_REFUSED", answer.status, answer.message);
833
1168
  const code = answer.value;
834
1169
  const row = {
835
1170
  environment,
@@ -840,11 +1175,11 @@ async function startLink(ctx, input) {
840
1175
  expiresAt: new Date(ready.call.now.getTime() + code.expiresInSeconds * 1e3)
841
1176
  };
842
1177
  await ready.attempts.upsert({
843
- where: keyOf(input.clientId, input.provider),
1178
+ where: keyOf2(input.clientId, input.provider),
844
1179
  create: { clientId: input.clientId, provider: input.provider, ...row },
845
1180
  update: row
846
1181
  });
847
- return { kind: "started", pending: pendingOf(row) };
1182
+ return { kind: "started", pending: pendingOf2(row) };
848
1183
  }
849
1184
  __name(startLink, "startLink");
850
1185
  async function chooseMerchant(db, input, merchants, current) {
@@ -859,7 +1194,7 @@ async function saveLink(ctx, input, link) {
859
1194
  const credentials = sealLink(ctx, link.refreshToken);
860
1195
  await ctx.ports.transaction(async (db) => {
861
1196
  const existing = await db.marketplaceIntegration.findUnique({
862
- where: keyOf(input.clientId, input.provider),
1197
+ where: keyOf2(input.clientId, input.provider),
863
1198
  select: { archivedAt: true, externalMerchantId: true }
864
1199
  });
865
1200
  const data = {
@@ -873,7 +1208,7 @@ async function saveLink(ctx, input, link) {
873
1208
  ...input.enabled === void 0 ? {} : { enabled: input.enabled }
874
1209
  };
875
1210
  await db.marketplaceIntegration.upsert({
876
- where: keyOf(input.clientId, input.provider),
1211
+ where: keyOf2(input.clientId, input.provider),
877
1212
  create: { clientId: input.clientId, provider: input.provider, ackSlaSeconds: ctx.ports.defaultAckSlaSeconds, ...data },
878
1213
  update: data
879
1214
  });
@@ -917,9 +1252,9 @@ async function finishLink(ctx, input) {
917
1252
  const { ready, environment, verifier, sealedVerifier } = opened;
918
1253
  const exchanged = await ready.linking.exchange(ready.call, { authorizationCode: input.authorizationCode.trim(), verifier });
919
1254
  if (exchanged.kind === "retry") return exchanged;
920
- if (exchanged.kind === "refused") return refused2("CODE_REFUSED", exchanged.status, exchanged.message);
1255
+ if (exchanged.kind === "refused") return refused3("CODE_REFUSED", exchanged.status, exchanged.message);
921
1256
  const grant = exchanged.value;
922
- if (grant.refreshToken === null) return refused2("CODE_REFUSED", null, "the marketplace answered no refresh token");
1257
+ if (grant.refreshToken === null) return refused3("CODE_REFUSED", null, "the marketplace answered no refresh token");
923
1258
  const listed = await ready.linking.merchants(ready.call, { accessToken: grant.accessToken });
924
1259
  const merchants = listed.kind === "ok" ? listed.value : null;
925
1260
  if (listed.kind !== "ok") {
@@ -933,38 +1268,38 @@ async function finishLink(ctx, input) {
933
1268
  __name(finishLink, "finishLink");
934
1269
  async function openAttempt(ctx, input) {
935
1270
  const attempts = (await ctx.ports.db()).marketplaceLinkAttempt;
936
- if (!attempts) return refused2("UNAVAILABLE");
937
- const attempt = await attempts.findUnique({ where: keyOf(input.clientId, input.provider) });
938
- if (!attempt) return refused2("NO_LINK_IN_PROGRESS");
1271
+ if (!attempts) return refused3("UNAVAILABLE");
1272
+ const attempt = await attempts.findUnique({ where: keyOf2(input.clientId, input.provider) });
1273
+ if (!attempt) return refused3("NO_LINK_IN_PROGRESS");
939
1274
  const environment = attempt.environment === "SANDBOX" ? "SANDBOX" : "PRODUCTION";
940
1275
  const ready = await linkingOf(ctx, input.provider, environment);
941
- if (!ready) return refused2("UNAVAILABLE");
942
- if (attempt.expiresAt.getTime() <= ready.call.now.getTime()) return refused2("LINK_EXPIRED");
1276
+ if (!ready) return refused3("UNAVAILABLE");
1277
+ if (attempt.expiresAt.getTime() <= ready.call.now.getTime()) return refused3("LINK_EXPIRED");
943
1278
  return { ready, environment, verifier: ctx.ports.secrets.open(attempt.verifier), sealedVerifier: attempt.verifier };
944
1279
  }
945
1280
  __name(openAttempt, "openAttempt");
946
1281
  async function grantCall(ctx, clientId, provider) {
947
1282
  const views = await listMarketplaceIntegrations(ctx, clientId, { providers: [provider] });
948
- if (views[0]?.authMode !== "LINKED") return refused2("NOT_LINKED");
1283
+ if (views[0]?.authMode !== "LINKED") return refused3("NOT_LINKED");
949
1284
  const connection = await readOutboundConnection(ctx, clientId, provider).catch(() => null);
950
- if (!connection?.grant) return refused2("UNAVAILABLE");
1285
+ if (!connection?.grant) return refused3("UNAVAILABLE");
951
1286
  const token = await connection.grant.accessToken();
952
1287
  if ("token" in token) {
953
1288
  const call = { http: ctx.ports.http, credentials: connection.credentials, environment: connection.environment, now: ctx.ports.clock.now() };
954
1289
  return { call, accessToken: token.token };
955
1290
  }
956
1291
  if (token.kind === "retry") return token;
957
- return token.kind === "refused" ? refused2("NOT_LINKED", token.status, token.message) : refused2("NOT_LINKED");
1292
+ return token.kind === "refused" ? refused3("NOT_LINKED", token.status, token.message) : refused3("NOT_LINKED");
958
1293
  }
959
1294
  __name(grantCall, "grantCall");
960
1295
  async function grantMerchants(ctx, clientId, provider) {
961
1296
  const linking = ctx.registry.get(provider)?.linking;
962
- if (!linking) return refused2("UNAVAILABLE");
1297
+ if (!linking) return refused3("UNAVAILABLE");
963
1298
  const granted = await grantCall(ctx, clientId, provider);
964
1299
  if ("kind" in granted) return granted;
965
1300
  const listed = await linking.merchants(granted.call, { accessToken: granted.accessToken });
966
1301
  if (listed.kind === "ok") return listed.value;
967
- return listed.kind === "retry" ? listed : refused2("MARKETPLACE_REFUSED", listed.status, listed.message);
1302
+ return listed.kind === "retry" ? listed : refused3("MARKETPLACE_REFUSED", listed.status, listed.message);
968
1303
  }
969
1304
  __name(grantMerchants, "grantMerchants");
970
1305
  async function linkedMerchants(ctx, input) {
@@ -975,9 +1310,9 @@ __name(linkedMerchants, "linkedMerchants");
975
1310
  async function selectLinkedMerchant(ctx, input) {
976
1311
  const merchants = await grantMerchants(ctx, input.clientId, input.provider);
977
1312
  if (!Array.isArray(merchants)) return merchants;
978
- if (!merchants.some((merchant) => merchant.id === input.merchantId)) return refused2("UNKNOWN_MERCHANT");
1313
+ if (!merchants.some((merchant) => merchant.id === input.merchantId)) return refused3("UNKNOWN_MERCHANT");
979
1314
  const db = await ctx.ports.db();
980
- if (await merchantHeldElsewhere(db, input.clientId, input.provider, input.merchantId)) return refused2("MERCHANT_TAKEN");
1315
+ if (await merchantHeldElsewhere(db, input.clientId, input.provider, input.merchantId)) return refused3("MERCHANT_TAKEN");
981
1316
  const write = /* @__PURE__ */ __name(() => db.marketplaceIntegration.updateMany({
982
1317
  where: { clientId: input.clientId, provider: input.provider, authMode: "LINKED", archivedAt: null },
983
1318
  data: { externalMerchantId: input.merchantId }
@@ -989,12 +1324,81 @@ async function selectLinkedMerchant(ctx, input) {
989
1324
  throw error;
990
1325
  }
991
1326
  );
992
- if (taken) return refused2("MERCHANT_TAKEN");
1327
+ if (taken) return refused3("MERCHANT_TAKEN");
993
1328
  ctx.ports.publishChanged(input.clientId);
994
1329
  return { kind: "selected", integration: await viewOf2(ctx, input.clientId, input.provider) };
995
1330
  }
996
1331
  __name(selectLinkedMerchant, "selectLinkedMerchant");
997
1332
 
1333
+ // src/core/link-engine.ts
1334
+ var appPendingView = /* @__PURE__ */ __name((pending) => ({
1335
+ userCode: "",
1336
+ verificationUrl: pending.portalUrl,
1337
+ verificationUrlComplete: pending.portalUrl,
1338
+ expiresAt: pending.expiresAt,
1339
+ mode: "app",
1340
+ seenAt: pending.seenAt,
1341
+ checkedAt: pending.checkedAt
1342
+ }), "appPendingView");
1343
+ var NO_CODE = {
1344
+ kind: "refused",
1345
+ code: "UNAVAILABLE",
1346
+ status: null,
1347
+ message: "this marketplace links without a code"
1348
+ };
1349
+ function linkEngine(ctx) {
1350
+ const app = /* @__PURE__ */ __name((provider) => hasAppLinking(ctx, provider), "app");
1351
+ return {
1352
+ linkState: /* @__PURE__ */ __name(async (input) => {
1353
+ if (!app(input.provider)) return linkState(ctx, input);
1354
+ const state = await appLinkState(ctx, input);
1355
+ return {
1356
+ available: state.available,
1357
+ pending: state.pending ? appPendingView(state.pending) : null
1358
+ };
1359
+ }, "linkState"),
1360
+ startLink: /* @__PURE__ */ __name(async (input) => {
1361
+ if (!app(input.provider)) return startLink(ctx, input);
1362
+ const started = await startAppLink(ctx, input);
1363
+ return started.kind === "started" ? { kind: "started", pending: appPendingView(started.pending) } : started;
1364
+ }, "startLink"),
1365
+ finishLink: /* @__PURE__ */ __name((input) => app(input.provider) ? Promise.resolve(NO_CODE) : finishLink(ctx, input), "finishLink"),
1366
+ linkedMerchants: /* @__PURE__ */ __name(async (input) => {
1367
+ if (!app(input.provider)) return linkedMerchants(ctx, input);
1368
+ const checked = await checkAppLink(ctx, input);
1369
+ return checked.kind === "checked" ? { kind: "listed", merchants: checked.merchants } : checked;
1370
+ }, "linkedMerchants"),
1371
+ selectLinkedMerchant: /* @__PURE__ */ __name((input) => app(input.provider) ? selectAppMerchant(ctx, input) : selectLinkedMerchant(ctx, input), "selectLinkedMerchant"),
1372
+ checkLink: /* @__PURE__ */ __name(async (input) => {
1373
+ if (!app(input.provider))
1374
+ return {
1375
+ kind: "refused",
1376
+ code: "UNAVAILABLE",
1377
+ status: null,
1378
+ message: null
1379
+ };
1380
+ const checked = await checkAppLink(ctx, input);
1381
+ return checked.kind === "checked" ? {
1382
+ ...checked,
1383
+ pending: checked.pending ? appPendingView(checked.pending) : null
1384
+ } : checked;
1385
+ }, "checkLink"),
1386
+ cancelLink: /* @__PURE__ */ __name((input) => cancelAppLink(ctx, input), "cancelLink"),
1387
+ sweepLinks: /* @__PURE__ */ __name((input) => sweepAppLinks(ctx, input), "sweepLinks")
1388
+ };
1389
+ }
1390
+ __name(linkEngine, "linkEngine");
1391
+
1392
+ // src/core/dispute-engine.ts
1393
+ function disputeEngine(ctx) {
1394
+ return {
1395
+ disputes: /* @__PURE__ */ __name((input) => readDisputes(ctx, input), "disputes"),
1396
+ answerDispute: /* @__PURE__ */ __name((input) => answerDispute(ctx, input), "answerDispute"),
1397
+ runDisputeAnswer: /* @__PURE__ */ __name((payload, attempt) => runDisputeAnswer(ctx, payload, attempt), "runDisputeAnswer")
1398
+ };
1399
+ }
1400
+ __name(disputeEngine, "disputeEngine");
1401
+
998
1402
  // src/core/status-inform.ts
999
1403
  async function informStatus(ctx, input) {
1000
1404
  const payload = { clientId: input.clientId, orderId: input.orderId, action: "status", step: input.step, claimKey: String(input.at.getTime()) };
@@ -1358,8 +1762,12 @@ async function applyEvent(ctx, inboxId, clientId, event, settings, now) {
1358
1762
  }
1359
1763
  __name(applyEvent, "applyEvent");
1360
1764
  async function followMarketplace(ctx, inboxId, clientId, event, settings) {
1765
+ const disputed = await applyDisputeEvent(ctx, inboxId, clientId, event);
1766
+ if (disputed) return disputed;
1361
1767
  const confirmed = await applyMarketplaceConfirmation(ctx, inboxId, clientId, event);
1362
- return confirmed ?? followCourierAndLifecycle(ctx, inboxId, clientId, event, settings);
1768
+ if (confirmed) return confirmed;
1769
+ const codeRequested = await applyDeliveryCodeRequest(ctx, inboxId, clientId, event);
1770
+ return codeRequested ?? followCourierAndLifecycle(ctx, inboxId, clientId, event, settings);
1363
1771
  }
1364
1772
  __name(followMarketplace, "followMarketplace");
1365
1773
  async function ingestOrIgnore(ctx, inboxId, clientId, event, settings, now) {
@@ -1495,11 +1903,6 @@ function createMarketplaceEngine(config) {
1495
1903
  async () => saveMarketplaceIntegration(ctx, input, await ports.db())
1496
1904
  ), "saveIntegration"),
1497
1905
  upsertIntegrations: /* @__PURE__ */ __name((input) => upsertIntegrations(ctx, input), "upsertIntegrations"),
1498
- linkState: /* @__PURE__ */ __name((input) => linkState(ctx, input), "linkState"),
1499
- startLink: /* @__PURE__ */ __name((input) => startLink(ctx, input), "startLink"),
1500
- finishLink: /* @__PURE__ */ __name((input) => finishLink(ctx, input), "finishLink"),
1501
- linkedMerchants: /* @__PURE__ */ __name((input) => linkedMerchants(ctx, input), "linkedMerchants"),
1502
- selectLinkedMerchant: /* @__PURE__ */ __name((input) => selectLinkedMerchant(ctx, input), "selectLinkedMerchant"),
1503
1906
  menuLinks: /* @__PURE__ */ __name((input) => listMarketplaceMenuLinks(ctx, input), "menuLinks"),
1504
1907
  upsertMenuLinks: /* @__PURE__ */ __name((input) => upsertMenuLinks(ctx, input), "upsertMenuLinks"),
1505
1908
  setMenuLink: /* @__PURE__ */ __name(async ({ clientId, ...row }) => {
@@ -1519,7 +1922,7 @@ function createMarketplaceEngine(config) {
1519
1922
  runOutbound: /* @__PURE__ */ __name((payload, attempt) => runOutbound(ctx, payload, attempt), "runOutbound"),
1520
1923
  runFetchOrder: /* @__PURE__ */ __name((payload, attempt) => runFetchOrder(ctx, payload, attempt), "runFetchOrder"),
1521
1924
  informStatus: /* @__PURE__ */ __name((input) => informStatus(ctx, input), "informStatus"),
1522
- ...{ ...courierEngine(ctx), ...conformityEngine(ctx) },
1925
+ ...{ ...courierEngine(ctx), ...conformityEngine(ctx), ...linkEngine(ctx), ...disputeEngine(ctx), ...logisticsEngine(ctx), ...deliveryCodeEngine(ctx) },
1523
1926
  // Null too when the host bound no catalogue port: nothing could be published.
1524
1927
  catalogueMode: /* @__PURE__ */ __name((provider) => ports.catalogue ? registry.get(provider)?.catalogue?.mode ?? null : null, "catalogueMode"),
1525
1928
  publish: /* @__PURE__ */ __name((input) => publishToCatalogue(ctx, input), "publish"),
@@ -1544,12 +1947,18 @@ export {
1544
1947
  CONFIRMED_BEFORE_ORDER,
1545
1948
  CancellationReasonsRetryError,
1546
1949
  CatalogueRetryError,
1950
+ DisputeAnswerRetryError,
1547
1951
  FetchOrderRetryError,
1952
+ ATTEMPT_MINUTES as LINK_ATTEMPT_MINUTES,
1953
+ CHECK_EVERY_SECONDS as LINK_CHECK_EVERY_SECONDS,
1954
+ LOGISTICS_STEPS,
1548
1955
  MARKETPLACE_ACKNOWLEDGE_JOB,
1549
1956
  MARKETPLACE_AVAILABILITY_JOB,
1550
1957
  MARKETPLACE_CANCELLATION_REASONS_JOB,
1551
1958
  MARKETPLACE_CATALOGUE_JOB,
1959
+ MARKETPLACE_DISPUTE_ANSWER_JOB,
1552
1960
  MARKETPLACE_FETCH_ORDER_JOB,
1961
+ MARKETPLACE_LINK_CHECK_JOB,
1553
1962
  MARKETPLACE_OUTBOUND_JOB,
1554
1963
  MarketplaceAdapterRegistrationError,
1555
1964
  MarketplaceMerchantTakenError,
@@ -1564,6 +1973,7 @@ export {
1564
1973
  centsFromMajor,
1565
1974
  createAdapterRegistry,
1566
1975
  createMarketplaceEngine,
1976
+ disputeView,
1567
1977
  normalizedLineTotalCents,
1568
1978
  outboundDedupeKey,
1569
1979
  outboundResultOf,