@12-apps/marketplace 1.13.0 → 1.15.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 +258 -3
- package/README.md +27 -2
- package/dist/99food/index.d.ts +2 -2
- package/dist/99food/index.js +3 -3
- package/dist/{adapter-CQ4QiZPi.d.ts → adapter-CjVdMhZ2.d.ts} +177 -4
- package/dist/{chunk-CEWTV2TC.js → chunk-B4DYPQFE.js} +657 -251
- package/dist/chunk-B4DYPQFE.js.map +1 -0
- package/dist/{chunk-4J2KJ3ZW.js → chunk-BTKVZAJI.js} +1 -1
- package/dist/chunk-BTKVZAJI.js.map +1 -0
- package/dist/{chunk-BD7DS3XM.js → chunk-E4XJXHUK.js} +20 -1
- package/dist/chunk-E4XJXHUK.js.map +1 -0
- package/dist/{chunk-W57TITU4.js → chunk-FQI56NGC.js} +53 -6
- package/dist/chunk-FQI56NGC.js.map +1 -0
- package/dist/chunk-H2VQRD3B.js +16 -0
- package/dist/chunk-H2VQRD3B.js.map +1 -0
- package/dist/{chunk-NFJQQWG4.js → chunk-TRUK5ZBE.js} +12 -4
- package/dist/chunk-TRUK5ZBE.js.map +1 -0
- package/dist/{client-CCSnylou.d.ts → client-DgzCkl8u.d.ts} +1 -1
- package/dist/{engine-1KlJ_8jK.d.ts → engine-BSLdhAGC.d.ts} +134 -3
- package/dist/hono/index.d.ts +2 -2
- package/dist/hono/index.js +3 -2
- package/dist/hono/index.js.map +1 -1
- package/dist/ifood/index.d.ts +13 -3
- package/dist/ifood/index.js +219 -29
- package/dist/ifood/index.js.map +1 -1
- package/dist/index.d.ts +29 -5
- package/dist/index.js +59 -7
- package/dist/index.js.map +1 -1
- package/dist/keeta/index.d.ts +2 -2
- package/dist/keeta/index.js +3 -3
- package/dist/manifest/server.d.ts +4 -2
- package/dist/manifest/server.js +3 -2
- package/dist/manifest/server.js.map +1 -1
- package/dist/rappi/index.d.ts +1 -1
- package/dist/rappi/index.js +2 -2
- package/dist/server/index.d.ts +14 -5
- package/dist/server/index.js +3 -2
- package/package.json +1 -1
- package/prisma/marketplace.prisma +17 -3
- package/prisma/migrations/20261202120000_marketplace_ifood_conformity/migration.sql +25 -0
- package/src/core/acceptance.ts +12 -6
- package/src/core/acknowledge.ts +189 -0
- package/src/core/adapter.ts +74 -1
- package/src/core/cancellation.ts +10 -6
- package/src/core/conformity.ts +63 -0
- package/src/core/engine.ts +3 -2
- package/src/core/ingest.ts +7 -0
- package/src/core/link-store.ts +2 -4
- package/src/core/marketplace-confirmed.ts +229 -0
- package/src/core/order-reasons.ts +119 -0
- package/src/core/order-types.ts +8 -0
- package/src/core/outbound.ts +5 -1
- package/src/core/payload-read.ts +24 -0
- package/src/core/pipeline.ts +27 -1
- package/src/core/ports.ts +2 -0
- package/src/core/registry.ts +28 -2
- package/src/core/state.ts +10 -0
- package/src/core/status-job.ts +86 -3
- package/src/core/types.ts +117 -2
- package/src/ifood/index.ts +27 -4
- package/src/ifood/normalize.ts +38 -5
- package/src/ifood/order-details.ts +120 -0
- package/src/ifood/outbound.ts +131 -27
- package/src/index.ts +24 -0
- package/src/open-delivery/normalize.ts +9 -0
- package/src/server/jobs.ts +57 -4
- package/src/server/webhook.ts +27 -4
- package/dist/chunk-4J2KJ3ZW.js.map +0 -1
- package/dist/chunk-BD7DS3XM.js.map +0 -1
- package/dist/chunk-CEWTV2TC.js.map +0 -1
- package/dist/chunk-NFJQQWG4.js.map +0 -1
- package/dist/chunk-W57TITU4.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as AcceptanceDecision, a as AcceptanceStatus, b as
|
|
2
|
-
import { c as MarketplaceAdapter, l as MarketplaceProvider, m as CancellationReason } from './adapter-
|
|
3
|
-
export { A as AdapterCallContext, n as AdapterGrant, o as AdapterTokenCache, p as CancellationOutcome, q as CancellationRequestInput, r as CatalogueCallContext, s as CatalogueFailure, t as CatalogueImage, u as CatalogueItem, e as CatalogueItemOut, v as CatalogueItemRef, C as CatalogueMenuEntry, b as CatalogueMenuOptions, w as CataloguePublishResult, x as CatalogueReadContext, y as CatalogueReadNotice, z as CatalogueReadRefusalCode, B as CatalogueReadResult, D as CatalogueReadWarning, E as CatalogueReadWarningCode, f as CatalogueReader, G as CatalogueSnapshot, H as CatalogueSnapshotCategory, I as CatalogueSnapshotItem, J as CatalogueSnapshotOption, K as CatalogueSnapshotOptionGroup, L as CatalogueStoredImage, Q as CatalogueWarningCode, R as CourierTrackingCallResult, T as CourierTrackingResult, F as FetchOrderResult, U as LinkCallContext, V as LinkCode, W as LinkGrant, X as LinkResult, Y as LinkedMerchant, Z as MarketplaceAppCredentialsPort, M as MarketplaceAvailability,
|
|
1
|
+
export { A as AcceptanceDecision, a as AcceptanceStatus, b as AcknowledgeJobPayload, c as AcknowledgeOutcome, d as AcknowledgeRetryError, e as AvailabilityJobPayload, f as AvailabilityOutcome, g as AvailabilityRetryError, h as AvailabilitySweepResult, B as BulkProblem, i as BulkProblemCode, j as BulkResult, C as CancellationFailureReason, k as CancellationReasonsJobPayload, l as CancellationReasonsOutcome, m as CancellationReasonsRetryError, n as CancellationStatus, o as CatalogueAction, p as CatalogueActionResult, q as CatalogueDocumentResult, r as CatalogueFailedAction, s as CatalogueFailureCode, t as CatalogueJobPayload, u as CatalogueOutcome, v as CataloguePublicationView, w as CataloguePublishInput, x as CatalogueRefusalCode, y as CatalogueRetryError, z as CatalogueStatus, D as CatalogueTarget, E as DecideManyResult, F as DecidedRow, G as DecisionInput, H as DecisionProblem, I as DecisionProblemCode, J as DecisionResult, K as DeliveryOutcome, L as ExpirySweepResult, M as FetchOrderJobPayload, N as FetchOrderOutcome, O as FetchOrderRetryError, P as InformStatusInput, Q as IngestResult, R as IngestSettings, S as IngestionTarget, T as IntegrationRowInput, U as LinkFailure, V as LinkFinished, W as LinkPendingView, X as LinkRefusalCode, Y as MARKETPLACE_ACKNOWLEDGE_JOB, Z as MARKETPLACE_AVAILABILITY_JOB, _ as MARKETPLACE_CANCELLATION_REASONS_JOB, $ as MARKETPLACE_CATALOGUE_JOB, a0 as MARKETPLACE_FETCH_ORDER_JOB, a1 as MARKETPLACE_OUTBOUND_JOB, a2 as MarketplaceAdmission, a3 as MarketplaceAdmissionRequest, a4 as MarketplaceAdmissionResult, a5 as MarketplaceAuditEntry, a6 as MarketplaceAuditPort, a7 as MarketplaceAuthMode, a8 as MarketplaceCataloguePort, a9 as MarketplaceClockPort, aa as MarketplaceConformityEngine, ab as MarketplaceDb, ac as MarketplaceEngine, ad as MarketplaceEngineConfig, ae as MarketplaceEnqueuePort, af as MarketplaceIntegrationView, ag as MarketplaceLifecycleAnswer, ah as MarketplaceLifecycleFacts, ai as MarketplaceLogger, aj as MarketplaceMenuLinkView, ak as MarketplaceOrderPort, al as MarketplaceOrderState, am as MarketplaceOrderSummary, an as MarketplacePorts, ao as MarketplaceRefusal, ap as MarketplaceSecretsPort, aq as MenuLinkRowInput, ar as OUTBOUND_GIVE_UP_MS, as as OUTBOUND_STALE_MS, at as OutboundAction, au as OutboundAttempt, av as OutboundJobPayload, aw as OutboundOutcome, ax as OutboundRetryError, ay as OutboundSweepResult, az as PauseOutcome, aA as PauseStoreInput, aB as PauseStoreResult, aC as PendingAcceptance, aD as PendingInboxEvent, aE as ResolvedOrderLine, aF as ResumeOutcome, aG as STORE_PAUSE_LEASE_MS, aH as SaveMarketplaceIntegrationInput, aI as StoreAvailabilityView, aJ as StorePauseFailureCode, aK as StorePauseState, aL as StorePauseWanted, aM as availabilityDedupeKey, aN as catalogueDedupeKey, aO as createMarketplaceEngine, aP as outboundDedupeKey } from './engine-BSLdhAGC.js';
|
|
2
|
+
import { c as MarketplaceAdapter, l as MarketplaceProvider, m as CancellationReason } from './adapter-CjVdMhZ2.js';
|
|
3
|
+
export { A as AdapterCallContext, n as AdapterGrant, o as AdapterTokenCache, p as CancellationOutcome, q as CancellationRequestInput, r as CatalogueCallContext, s as CatalogueFailure, t as CatalogueImage, u as CatalogueItem, e as CatalogueItemOut, v as CatalogueItemRef, C as CatalogueMenuEntry, b as CatalogueMenuOptions, w as CataloguePublishResult, x as CatalogueReadContext, y as CatalogueReadNotice, z as CatalogueReadRefusalCode, B as CatalogueReadResult, D as CatalogueReadWarning, E as CatalogueReadWarningCode, f as CatalogueReader, G as CatalogueSnapshot, H as CatalogueSnapshotCategory, I as CatalogueSnapshotItem, J as CatalogueSnapshotOption, K as CatalogueSnapshotOptionGroup, L as CatalogueStoredImage, Q as CatalogueWarningCode, R as CourierTrackingCallResult, T as CourierTrackingResult, F as FetchOrderResult, U as LinkCallContext, V as LinkCode, W as LinkGrant, X as LinkResult, Y as LinkedMerchant, Z as MarketplaceAcknowledgement, _ as MarketplaceAppCredentialsPort, M as MarketplaceAvailability, $ as MarketplaceCapabilities, a0 as MarketplaceCatalogue, a1 as MarketplaceCourier, a2 as MarketplaceCourierAnswer, h as MarketplaceCourierApi, a3 as MarketplaceCourierEngine, a4 as MarketplaceCourierFacts, a5 as MarketplaceCourierStep, a6 as MarketplaceCourierTracking, a7 as MarketplaceCourierVehicle, a8 as MarketplaceCredentials, a9 as MarketplaceDeliveredBy, aa as MarketplaceDiscountSponsor, ab as MarketplaceHttp, ac as MarketplaceHttpRequest, ad as MarketplaceHttpResponse, ae as MarketplaceLifecycle, af as MarketplaceLinkAttemptDelegate, g as MarketplaceLinking, ag as MarketplaceOrderType, ah as MarketplacePaymentMethod, ai as NormalizedAddress, aj as NormalizedBuyer, i as NormalizedCourierEvent, N as NormalizedEvent, ak as NormalizedLineOption, a as NormalizedMarketplaceOrder, al as NormalizedOrderDiscount, am as NormalizedOrderFee, an as NormalizedOrderLine, ao as NormalizedPaymentMethod, ap as NormalizedPayments, aq as OrderCancellationReason, ar as OrderCancellationReasonsResult, as as OutboundOrderRef, O as OutboundResult, at as PROVIDER_ID_PATTERN, au as PickupCodeCallResult, av as PickupCodeValidation, aw as PresenceProbe, P as PullCatalogue, d as PushCatalogue, ax as StatusFacts, ay as StatusStep, k as StorePauseRef, S as StorePauseRequest, j as StorePauseResult, az as ValidatePickupCodeInput, aA as answered, aB as centsFromMajor, aC as normalizedLineTotalCents, aD as outboundResultOf, aE as tokenGrantResultOf } from './adapter-CjVdMhZ2.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The adapter registry: the ONE place a provider id becomes a marketplace.
|
|
@@ -32,7 +32,9 @@ declare function createAdapterRegistry(adapters: readonly MarketplaceAdapter[]):
|
|
|
32
32
|
* named none — the adapter's first. `null` when the code is not one of the
|
|
33
33
|
* adapter's, which a caller answers as a refusal of the whole request.
|
|
34
34
|
*/
|
|
35
|
-
declare function resolveReason(adapter: MarketplaceAdapter, code: string | null | undefined
|
|
35
|
+
declare function resolveReason(adapter: MarketplaceAdapter, code: string | null | undefined,
|
|
36
|
+
/** The order's own list (`cancellation_reasons`, FUT-5984); absent or unread: the static one. */
|
|
37
|
+
stored?: unknown): CancellationReason | null;
|
|
36
38
|
/**
|
|
37
39
|
* The reason a host should preselect: the adapter's "item unavailable" reason
|
|
38
40
|
* when the order cannot be covered, else its first. The SHORTAGE is the
|
|
@@ -73,6 +75,28 @@ declare class MarketplaceMerchantTakenError extends Error {
|
|
|
73
75
|
constructor(provider: string, merchantId: string);
|
|
74
76
|
}
|
|
75
77
|
|
|
78
|
+
/**
|
|
79
|
+
* The store accepted an order in the marketplace's own app (FUT-5653: iFood's
|
|
80
|
+
* CFM from its tablet or Gestor de Pedidos). The owner's decision (2026-12-02):
|
|
81
|
+
* the order is accepted here too, through the SAME admit as an aceite on the
|
|
82
|
+
* Quadro (`order.admit`: the stock ask), with no confirm sent back (the
|
|
83
|
+
* marketplace has it), and is never expired by our clock afterwards.
|
|
84
|
+
*
|
|
85
|
+
* In order:
|
|
86
|
+
* 1. no acceptance yet (the PLACED's fetch still running): DEFERRED, and
|
|
87
|
+
* applied right after that order's ingest, or by the expiry sweep before it
|
|
88
|
+
* would expire it;
|
|
89
|
+
* 2. not AWAITING (an ACCEPTED one is our own confirm's echo): IGNORED;
|
|
90
|
+
* 3. `confirmed_at` stamped on the AWAITING row: the marketplace has the
|
|
91
|
+
* acceptance, so the clock never expires it and no confirm is ever sent;
|
|
92
|
+
* 4. with no cancellation request standing, the host admits it and the row is
|
|
93
|
+
* claimed AWAITING → ACCEPTED in one transaction, then `onAccepted`. A
|
|
94
|
+
* refused admit leaves it AWAITING for a person, whose aceite then goes
|
|
95
|
+
* through `decide` as ever.
|
|
96
|
+
*/
|
|
97
|
+
/** The reason a confirmation that outran its order waits under. */
|
|
98
|
+
declare const CONFIRMED_BEFORE_ORDER = "confirmed before its order";
|
|
99
|
+
|
|
76
100
|
/**
|
|
77
101
|
* The outbound sweep's catalogue half (FUT-4768): nothing the store switched
|
|
78
102
|
* on or off is lost, and nothing waits forever on "sending".
|
|
@@ -87,4 +111,4 @@ declare const CATALOGUE_STALE_MS: number;
|
|
|
87
111
|
/** Past this, the marketplace is not going to answer this ask. */
|
|
88
112
|
declare const CATALOGUE_GIVE_UP_MS: number;
|
|
89
113
|
|
|
90
|
-
export { type AdapterRegistry, CATALOGUE_GIVE_UP_MS, CATALOGUE_STALE_MS, CancellationReason, MarketplaceAdapter, MarketplaceAdapterRegistrationError, MarketplaceMerchantTakenError, MarketplaceProvider, createAdapterRegistry, resolveReason, stableUuid, suggestReason };
|
|
114
|
+
export { type AdapterRegistry, CATALOGUE_GIVE_UP_MS, CATALOGUE_STALE_MS, CONFIRMED_BEFORE_ORDER, CancellationReason, MarketplaceAdapter, MarketplaceAdapterRegistrationError, MarketplaceMerchantTakenError, MarketplaceProvider, createAdapterRegistry, resolveReason, stableUuid, suggestReason };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AcknowledgeRetryError,
|
|
2
3
|
AvailabilityRetryError,
|
|
3
4
|
CANCELLED_BEFORE_INGEST_REASON,
|
|
4
5
|
CATALOGUE_GIVE_UP_MS,
|
|
5
6
|
CATALOGUE_ROW_SELECT,
|
|
6
7
|
CATALOGUE_STALE_MS,
|
|
7
8
|
CLAIM_SELECT,
|
|
9
|
+
CONFIRMED_BEFORE_ORDER,
|
|
10
|
+
CancellationReasonsRetryError,
|
|
8
11
|
CatalogueRetryError,
|
|
9
12
|
FetchOrderRetryError,
|
|
13
|
+
MARKETPLACE_ACKNOWLEDGE_JOB,
|
|
10
14
|
MARKETPLACE_AVAILABILITY_JOB,
|
|
15
|
+
MARKETPLACE_CANCELLATION_REASONS_JOB,
|
|
11
16
|
MARKETPLACE_CATALOGUE_JOB,
|
|
12
17
|
MARKETPLACE_FETCH_ORDER_JOB,
|
|
13
18
|
MARKETPLACE_OUTBOUND_JOB,
|
|
@@ -18,9 +23,9 @@ import {
|
|
|
18
23
|
OUTBOUND_GIVE_UP_MS,
|
|
19
24
|
OUTBOUND_STALE_MS,
|
|
20
25
|
OutboundRetryError,
|
|
21
|
-
PROVIDER_ID_PATTERN,
|
|
22
26
|
STORE_PAUSE_LEASE_MS,
|
|
23
27
|
appCredentialsOf,
|
|
28
|
+
applyMarketplaceConfirmation,
|
|
24
29
|
availabilityDedupeKey,
|
|
25
30
|
awaitOrderBody,
|
|
26
31
|
cacheLinkToken,
|
|
@@ -32,6 +37,7 @@ import {
|
|
|
32
37
|
connectionMerchantId,
|
|
33
38
|
createAdapterRegistry,
|
|
34
39
|
deferInboxEvent,
|
|
40
|
+
enqueueAcknowledge,
|
|
35
41
|
enqueueAvailability,
|
|
36
42
|
enqueueCatalogue,
|
|
37
43
|
enqueueOutbound,
|
|
@@ -55,9 +61,11 @@ import {
|
|
|
55
61
|
outboundDedupeKey,
|
|
56
62
|
pauseTable,
|
|
57
63
|
planCancellation,
|
|
64
|
+
readOrderReasons,
|
|
58
65
|
readOutboundConnection,
|
|
59
66
|
readPause,
|
|
60
67
|
readStatusRows,
|
|
68
|
+
reasonsForOrder,
|
|
61
69
|
recordInboxEvent,
|
|
62
70
|
refusalData,
|
|
63
71
|
requestData,
|
|
@@ -66,7 +74,9 @@ import {
|
|
|
66
74
|
resolveIngestionTarget,
|
|
67
75
|
resolveReason,
|
|
68
76
|
resolveTenantByMerchant,
|
|
77
|
+
runAcknowledge,
|
|
69
78
|
runAvailability,
|
|
79
|
+
runCancellationReasons,
|
|
70
80
|
runCatalogue,
|
|
71
81
|
runFetchOrder,
|
|
72
82
|
runOutbound,
|
|
@@ -75,16 +85,22 @@ import {
|
|
|
75
85
|
settleInboxEvent,
|
|
76
86
|
statusDedupeKey,
|
|
77
87
|
statusTable,
|
|
88
|
+
storedReasons,
|
|
78
89
|
suggestReason,
|
|
90
|
+
sweepAcknowledgements,
|
|
79
91
|
sweepOutbound,
|
|
80
92
|
tellCancellationFailed,
|
|
81
93
|
upsertLink,
|
|
82
94
|
validatePickupCode,
|
|
83
95
|
viewOf
|
|
84
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-B4DYPQFE.js";
|
|
85
97
|
import {
|
|
86
98
|
centsFromMajor
|
|
87
99
|
} from "./chunk-WN2EK4KX.js";
|
|
100
|
+
import {
|
|
101
|
+
PROVIDER_ID_PATTERN,
|
|
102
|
+
normalizedLineTotalCents
|
|
103
|
+
} from "./chunk-H2VQRD3B.js";
|
|
88
104
|
import {
|
|
89
105
|
stableUuid
|
|
90
106
|
} from "./chunk-M2V4RFMA.js";
|
|
@@ -92,7 +108,7 @@ import {
|
|
|
92
108
|
answered,
|
|
93
109
|
outboundResultOf,
|
|
94
110
|
tokenGrantResultOf
|
|
95
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-BTKVZAJI.js";
|
|
96
112
|
import {
|
|
97
113
|
__name
|
|
98
114
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -753,6 +769,28 @@ function courierEngine(ctx) {
|
|
|
753
769
|
}
|
|
754
770
|
__name(courierEngine, "courierEngine");
|
|
755
771
|
|
|
772
|
+
// src/core/conformity.ts
|
|
773
|
+
function conformityEngine(ctx) {
|
|
774
|
+
return {
|
|
775
|
+
answerStatus: /* @__PURE__ */ __name((provider) => ctx.registry.get(provider)?.capabilities.webhookAnswerStatus ?? 200, "answerStatus"),
|
|
776
|
+
presence: /* @__PURE__ */ __name((provider, payload) => ctx.registry.get(provider)?.presence?.(payload) ?? null, "presence"),
|
|
777
|
+
signedByApp: /* @__PURE__ */ __name(async (provider, rawBody, signature) => {
|
|
778
|
+
const adapter = ctx.registry.has(provider) ? ctx.registry.get(provider) : null;
|
|
779
|
+
if (!adapter || signature === null) return false;
|
|
780
|
+
for (const environment of ["PRODUCTION", "SANDBOX"]) {
|
|
781
|
+
const app = await appCredentialsOf(ctx, provider, environment);
|
|
782
|
+
if (app && adapter.verifySignature(rawBody, signature, app.webhookSecret || app.clientSecret)) return true;
|
|
783
|
+
}
|
|
784
|
+
return false;
|
|
785
|
+
}, "signedByApp"),
|
|
786
|
+
orderReasons: /* @__PURE__ */ __name((clientId, orderId) => readOrderReasons(ctx, clientId, orderId), "orderReasons"),
|
|
787
|
+
runAcknowledge: /* @__PURE__ */ __name((payload, attempt) => runAcknowledge(ctx, payload, attempt), "runAcknowledge"),
|
|
788
|
+
sweepAcknowledgements: /* @__PURE__ */ __name(() => sweepAcknowledgements(ctx), "sweepAcknowledgements"),
|
|
789
|
+
runCancellationReasons: /* @__PURE__ */ __name((payload, attempt) => runCancellationReasons(ctx, payload, attempt), "runCancellationReasons")
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
__name(conformityEngine, "conformityEngine");
|
|
793
|
+
|
|
756
794
|
// src/core/linking.ts
|
|
757
795
|
var refused2 = /* @__PURE__ */ __name((code, status = null, message = null) => ({
|
|
758
796
|
kind: "refused",
|
|
@@ -1268,6 +1306,7 @@ async function processDelivery(ctx, input) {
|
|
|
1268
1306
|
const { clientId, event, settings } = input;
|
|
1269
1307
|
const record = await recordInboxEvent(ctx, { clientId, event, payload: input.payload });
|
|
1270
1308
|
if (!record.fresh) return { kind: "duplicate" };
|
|
1309
|
+
await enqueueAcknowledge(ctx, { clientId, provider: event.provider, inboxId: record.id });
|
|
1271
1310
|
if (!clientId || !settings) {
|
|
1272
1311
|
const reason = clientId ? "integration is not enabled" : "no tenant claims this merchant";
|
|
1273
1312
|
if (clientId) await deferInboxEvent(ctx, record.id, reason);
|
|
@@ -1313,11 +1352,16 @@ async function applyEvent(ctx, inboxId, clientId, event, settings, now) {
|
|
|
1313
1352
|
await awaitOrderBody(ctx, clientId, inboxId);
|
|
1314
1353
|
return { kind: "awaitingOrder" };
|
|
1315
1354
|
}
|
|
1316
|
-
const followed = await
|
|
1355
|
+
const followed = await followMarketplace(ctx, inboxId, clientId, event, settings);
|
|
1317
1356
|
if (followed) return followed;
|
|
1318
1357
|
return ingestOrIgnore(ctx, inboxId, clientId, event, settings, now);
|
|
1319
1358
|
}
|
|
1320
1359
|
__name(applyEvent, "applyEvent");
|
|
1360
|
+
async function followMarketplace(ctx, inboxId, clientId, event, settings) {
|
|
1361
|
+
const confirmed = await applyMarketplaceConfirmation(ctx, inboxId, clientId, event);
|
|
1362
|
+
return confirmed ?? followCourierAndLifecycle(ctx, inboxId, clientId, event, settings);
|
|
1363
|
+
}
|
|
1364
|
+
__name(followMarketplace, "followMarketplace");
|
|
1321
1365
|
async function ingestOrIgnore(ctx, inboxId, clientId, event, settings, now) {
|
|
1322
1366
|
if (!event.order) {
|
|
1323
1367
|
const reason = `no order body on ${event.eventType}`;
|
|
@@ -1392,7 +1436,8 @@ async function readOrderStates(ctx, clientId, orderIds) {
|
|
|
1392
1436
|
confirmFailedAt: true,
|
|
1393
1437
|
cancellationStatus: true,
|
|
1394
1438
|
cancellationReasonCode: true,
|
|
1395
|
-
cancellationFailureReason: true
|
|
1439
|
+
cancellationFailureReason: true,
|
|
1440
|
+
cancellationReasons: true
|
|
1396
1441
|
}
|
|
1397
1442
|
});
|
|
1398
1443
|
return new Map(
|
|
@@ -1409,7 +1454,8 @@ async function readOrderStates(ctx, clientId, orderIds) {
|
|
|
1409
1454
|
cancellation: row.cancellationStatus,
|
|
1410
1455
|
cancellationReasonCode: row.cancellationReasonCode,
|
|
1411
1456
|
cancellationFailure: row.cancellationFailureReason,
|
|
1412
|
-
appUrl: adapter ? adapter.appLink(row) : null
|
|
1457
|
+
appUrl: adapter ? adapter.appLink(row) : null,
|
|
1458
|
+
cancellationReasons: adapter && storedReasons(row.cancellationReasons) !== null ? reasonsForOrder(adapter, row.cancellationReasons) : null
|
|
1413
1459
|
};
|
|
1414
1460
|
return [row.orderId, state];
|
|
1415
1461
|
})
|
|
@@ -1473,7 +1519,7 @@ function createMarketplaceEngine(config) {
|
|
|
1473
1519
|
runOutbound: /* @__PURE__ */ __name((payload, attempt) => runOutbound(ctx, payload, attempt), "runOutbound"),
|
|
1474
1520
|
runFetchOrder: /* @__PURE__ */ __name((payload, attempt) => runFetchOrder(ctx, payload, attempt), "runFetchOrder"),
|
|
1475
1521
|
informStatus: /* @__PURE__ */ __name((input) => informStatus(ctx, input), "informStatus"),
|
|
1476
|
-
...courierEngine(ctx),
|
|
1522
|
+
...{ ...courierEngine(ctx), ...conformityEngine(ctx) },
|
|
1477
1523
|
// Null too when the host bound no catalogue port: nothing could be published.
|
|
1478
1524
|
catalogueMode: /* @__PURE__ */ __name((provider) => ports.catalogue ? registry.get(provider)?.catalogue?.mode ?? null : null, "catalogueMode"),
|
|
1479
1525
|
publish: /* @__PURE__ */ __name((input) => publishToCatalogue(ctx, input), "publish"),
|
|
@@ -1491,12 +1537,17 @@ function createMarketplaceEngine(config) {
|
|
|
1491
1537
|
}
|
|
1492
1538
|
__name(createMarketplaceEngine, "createMarketplaceEngine");
|
|
1493
1539
|
export {
|
|
1540
|
+
AcknowledgeRetryError,
|
|
1494
1541
|
AvailabilityRetryError,
|
|
1495
1542
|
CATALOGUE_GIVE_UP_MS,
|
|
1496
1543
|
CATALOGUE_STALE_MS,
|
|
1544
|
+
CONFIRMED_BEFORE_ORDER,
|
|
1545
|
+
CancellationReasonsRetryError,
|
|
1497
1546
|
CatalogueRetryError,
|
|
1498
1547
|
FetchOrderRetryError,
|
|
1548
|
+
MARKETPLACE_ACKNOWLEDGE_JOB,
|
|
1499
1549
|
MARKETPLACE_AVAILABILITY_JOB,
|
|
1550
|
+
MARKETPLACE_CANCELLATION_REASONS_JOB,
|
|
1500
1551
|
MARKETPLACE_CATALOGUE_JOB,
|
|
1501
1552
|
MARKETPLACE_FETCH_ORDER_JOB,
|
|
1502
1553
|
MARKETPLACE_OUTBOUND_JOB,
|
|
@@ -1513,6 +1564,7 @@ export {
|
|
|
1513
1564
|
centsFromMajor,
|
|
1514
1565
|
createAdapterRegistry,
|
|
1515
1566
|
createMarketplaceEngine,
|
|
1567
|
+
normalizedLineTotalCents,
|
|
1516
1568
|
outboundDedupeKey,
|
|
1517
1569
|
outboundResultOf,
|
|
1518
1570
|
resolveReason,
|