@12-apps/marketplace 1.7.0 → 1.9.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 +17 -0
- package/README.md +153 -3
- package/dist/99food/index.d.ts +30 -52
- package/dist/99food/index.js +62 -391
- package/dist/99food/index.js.map +1 -1
- package/dist/{adapter-DOjTak1H.d.ts → adapter-CYJzu1c9.d.ts} +45 -1
- package/dist/{chunk-YVUZHXUF.js → chunk-6N2HEV3U.js} +4 -4
- package/dist/chunk-6N2HEV3U.js.map +1 -0
- package/dist/{chunk-SJUKBCVO.js → chunk-BMCERPQX.js} +198 -12
- package/dist/chunk-BMCERPQX.js.map +1 -0
- package/dist/{chunk-L3DCOZUU.js → chunk-HEXLCTOG.js} +1 -1
- package/dist/chunk-HEXLCTOG.js.map +1 -0
- package/dist/{chunk-UYFYGGCS.js → chunk-NP4EYKPO.js} +3 -1
- package/dist/chunk-NP4EYKPO.js.map +1 -0
- package/dist/chunk-PYHNM47K.js +478 -0
- package/dist/chunk-PYHNM47K.js.map +1 -0
- package/dist/client-B4EQCRD_.d.ts +20 -0
- package/dist/{engine-DG1fg43Y.d.ts → engine-wmW-VuBL.d.ts} +107 -4
- package/dist/hono/index.d.ts +2 -2
- package/dist/hono/index.js +3 -3
- package/dist/ifood/index.d.ts +1 -1
- package/dist/ifood/index.js +29 -3
- package/dist/ifood/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +104 -7
- package/dist/index.js.map +1 -1
- package/dist/keeta/en-US.d.ts +19 -0
- package/dist/keeta/en-US.js +23 -0
- package/dist/keeta/en-US.js.map +1 -0
- package/dist/keeta/index.d.ts +253 -0
- package/dist/keeta/index.js +388 -0
- package/dist/keeta/index.js.map +1 -0
- package/dist/keeta/pt-BR.d.ts +23 -0
- package/dist/keeta/pt-BR.js +23 -0
- package/dist/keeta/pt-BR.js.map +1 -0
- package/dist/manifest/index.d.ts +3 -0
- package/dist/manifest/index.js +1 -1
- package/dist/manifest/server.d.ts +2 -2
- package/dist/manifest/server.js +3 -3
- package/dist/rappi/index.d.ts +7 -1
- package/dist/rappi/index.js +20 -3
- package/dist/rappi/index.js.map +1 -1
- package/dist/server/index.d.ts +6 -2
- package/dist/server/index.js +3 -3
- package/package.json +14 -2
- package/prisma/marketplace.prisma +45 -1
- package/prisma/migrations/20261126120000_marketplace_status_updates/migration.sql +60 -0
- package/src/99food/catalogue.ts +19 -89
- package/src/99food/copy.ts +4 -19
- package/src/99food/index.ts +29 -28
- package/src/99food/normalize.ts +11 -247
- package/src/99food/outbound.ts +29 -215
- package/src/99food/pause.ts +7 -22
- package/src/core/adapter.ts +41 -1
- package/src/core/bulk.ts +1 -1
- package/src/core/engine.ts +9 -0
- package/src/core/ingest.ts +6 -0
- package/src/core/integration.ts +17 -0
- package/src/core/lifecycle-port.ts +16 -0
- package/src/core/lifecycle.ts +133 -0
- package/src/core/outbound-queue.ts +24 -4
- package/src/core/outbound-sweep.ts +49 -5
- package/src/core/outbound.ts +11 -0
- package/src/core/pipeline.ts +22 -2
- package/src/core/ports.ts +39 -3
- package/src/core/status-inform.ts +51 -0
- package/src/core/status-job.ts +207 -0
- package/src/core/status-store.ts +85 -0
- package/src/core/types.ts +14 -0
- package/src/ifood/index.ts +7 -1
- package/src/ifood/normalize.ts +17 -0
- package/src/ifood/outbound.ts +35 -0
- package/src/index.ts +8 -1
- package/src/keeta/authorization.ts +226 -0
- package/src/keeta/copy.ts +27 -0
- package/src/keeta/en-US.ts +19 -0
- package/src/keeta/index.ts +162 -0
- package/src/keeta/merchant.ts +70 -0
- package/src/keeta/normalize.ts +131 -0
- package/src/keeta/outbound.ts +55 -0
- package/src/keeta/pt-BR.ts +23 -0
- package/src/keeta/signature.ts +85 -0
- package/src/open-delivery/client.ts +185 -0
- package/src/open-delivery/merchant.ts +126 -0
- package/src/open-delivery/normalize.ts +269 -0
- package/src/open-delivery/orders.ts +241 -0
- package/src/open-delivery/reasons.ts +26 -0
- package/src/rappi/index.ts +6 -1
- package/src/rappi/normalize.ts +6 -0
- package/src/rappi/outbound.ts +31 -2
- package/src/server/mcp.ts +2 -0
- package/src/server/webhook.ts +3 -1
- package/dist/chunk-L3DCOZUU.js.map +0 -1
- package/dist/chunk-SJUKBCVO.js.map +0 -1
- package/dist/chunk-UYFYGGCS.js.map +0 -1
- package/dist/chunk-YVUZHXUF.js.map +0 -1
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asString,
|
|
3
|
+
firstCents,
|
|
4
|
+
firstDate,
|
|
5
|
+
firstString,
|
|
6
|
+
pick,
|
|
7
|
+
toCents,
|
|
8
|
+
verifyHmacSha256Hex,
|
|
9
|
+
} from "../core/payload-read";
|
|
10
|
+
import type {
|
|
11
|
+
MarketplaceLifecycle,
|
|
12
|
+
MarketplaceDeliveredBy,
|
|
13
|
+
MarketplaceOrderType,
|
|
14
|
+
NormalizedAddress,
|
|
15
|
+
NormalizedEvent,
|
|
16
|
+
NormalizedMarketplaceOrder,
|
|
17
|
+
NormalizedOrderLine,
|
|
18
|
+
} from "../core/types";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The INBOUND half every Open Delivery adapter shares (Abrasel's standard;
|
|
22
|
+
* 99Food speaks v1.7.1, Keeta v1.5.0 with its own changes). Each reader takes
|
|
23
|
+
* the provider id the result is stamped with.
|
|
24
|
+
*
|
|
25
|
+
* Open Delivery splits what iFood sends at once: the webhook's `Event` names
|
|
26
|
+
* an order (`eventId`, `eventType`, `orderId`, `orderURL`, `createdAt`) and
|
|
27
|
+
* carries no body, and `GET /v1/orders/{orderId}` answers the `Order`. So
|
|
28
|
+
* there are two readers here: {@link normalizeOpenDeliveryEvent} for the
|
|
29
|
+
* webhook (a `CREATED` becomes `orderToFetch`), and
|
|
30
|
+
* {@link normalizeOpenDeliveryOrder} for what the engine's fetch job reads.
|
|
31
|
+
*
|
|
32
|
+
* Every shape below is the spec's (`components/schemas/Event`, `Order`,
|
|
33
|
+
* `Price`, `Address`), and every fixture in the tests is the spec's own
|
|
34
|
+
* example. Read defensively all the same: a missing field produces null, and
|
|
35
|
+
* only a missing order id refuses an event (it is the idempotency key).
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** The order exists and its body must be fetched. */
|
|
39
|
+
const CREATED = "CREATED";
|
|
40
|
+
/** The order is cancelled: the store's request was granted, or a mandatory cancellation. */
|
|
41
|
+
const CANCELLED = "CANCELLED";
|
|
42
|
+
/** The order left (DISPATCHED) and the order is finished (CONCLUDED): the lifecycle events (FUT-4653). */
|
|
43
|
+
const LIFECYCLE_OF: Readonly<Record<string, MarketplaceLifecycle>> = { DISPATCHED: "DISPATCHED", CONCLUDED: "CONCLUDED" };
|
|
44
|
+
/** The marketplace refused the store's own cancellation request. */
|
|
45
|
+
const CANCELLATION_REQUEST_DENIED = "CANCELLATION_REQUEST_DENIED";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Verify a delivery: Open Delivery's `X-App-Signature` is "a lowercased
|
|
49
|
+
* hexadecimal HMAC signature of the webhook HTTP request body, using the
|
|
50
|
+
* client secret as a key and SHA256 as the hash function". The key is the
|
|
51
|
+
* merchant app's CLIENT SECRET, so a store's connection keeps that same value
|
|
52
|
+
* as its webhook secret.
|
|
53
|
+
*
|
|
54
|
+
* Unlike iFood (whose secret is issued after certification), the key exists
|
|
55
|
+
* from the moment the store connects, so an unset secret REFUSES: an unsigned
|
|
56
|
+
* CANCELLED for a known order id would otherwise cancel it.
|
|
57
|
+
*/
|
|
58
|
+
export function verifyOpenDeliverySignature(
|
|
59
|
+
rawBody: string,
|
|
60
|
+
signature: string | null,
|
|
61
|
+
webhookSecret: string | null,
|
|
62
|
+
): boolean {
|
|
63
|
+
if (!webhookSecret) return false;
|
|
64
|
+
return verifyHmacSha256Hex(rawBody, signature, webhookSecret);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Normalize one webhook `Event`. Null only when it names no order.
|
|
69
|
+
*
|
|
70
|
+
* - `CREATED` announces an order: `orderToFetch`, the body is the fetch job's.
|
|
71
|
+
* - `CANCELLED` is a cancellation, whether the store asked for it or not.
|
|
72
|
+
* - `CANCELLATION_REQUEST_DENIED` refuses the store's request.
|
|
73
|
+
* - `DISPATCHED` and `CONCLUDED` are lifecycle events (FUT-4653): the engine
|
|
74
|
+
* asks the host to move the order forward, when the store follows them.
|
|
75
|
+
* - Everything else (`CONFIRMED`, `CANCELLATION_REQUESTED`, the
|
|
76
|
+
* consumer's `ORDER_CANCELLATION_REQUEST` handshake…) is understood and
|
|
77
|
+
* recorded, and acts on nothing: an IGNORED inbox row.
|
|
78
|
+
*
|
|
79
|
+
* The merchant is named by the `X-App-MerchantId` HEADER, not the body; the
|
|
80
|
+
* engine attributes a delivery by its URL's store slug, so it reads none.
|
|
81
|
+
*/
|
|
82
|
+
export function normalizeOpenDeliveryEventAs(provider: string, payload: unknown): NormalizedEvent | null {
|
|
83
|
+
const externalOrderId = firstString(payload, [["orderId"]]);
|
|
84
|
+
if (!externalOrderId) return null;
|
|
85
|
+
const eventType = (firstString(payload, [["eventType"]]) ?? "UNKNOWN").toUpperCase();
|
|
86
|
+
const cancelled = eventType === CANCELLED;
|
|
87
|
+
const denied = eventType === CANCELLATION_REQUEST_DENIED;
|
|
88
|
+
return {
|
|
89
|
+
provider,
|
|
90
|
+
// The spec's own event id. The fallback is deterministic so a redelivery
|
|
91
|
+
// still collides on the inbox's unique index.
|
|
92
|
+
eventId: firstString(payload, [["eventId"]]) ?? `${externalOrderId}:${eventType}`,
|
|
93
|
+
eventType,
|
|
94
|
+
externalMerchantId: null,
|
|
95
|
+
externalOrderId,
|
|
96
|
+
order: null,
|
|
97
|
+
orderToFetch: eventType === CREATED,
|
|
98
|
+
cancelled,
|
|
99
|
+
cancellationOutcome: cancelled ? "CONFIRMED" : denied ? "FAILED" : null,
|
|
100
|
+
...(LIFECYCLE_OF[eventType] ? { lifecycle: LIFECYCLE_OF[eventType] } : {}),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** A `Price` object (`{ value, currency }`) in cents. */
|
|
105
|
+
function priceCents(source: unknown, ...path: string[]): number | null {
|
|
106
|
+
return toCents(pick(source, ...path, "value"));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The note a kitchen reads: the chosen options (a pizza's halves are options)
|
|
111
|
+
* and the buyer's own instructions. The normalized line has no options of its
|
|
112
|
+
* own, and a flavour dropped from the ticket is food made wrong.
|
|
113
|
+
*/
|
|
114
|
+
function lineNote(item: unknown, fraction: string | null): string | null {
|
|
115
|
+
const rawOptions = pick(item, "options");
|
|
116
|
+
const options = (Array.isArray(rawOptions) ? rawOptions : [])
|
|
117
|
+
.map((option) => {
|
|
118
|
+
const name = asString(pick(option, "name"));
|
|
119
|
+
const quantity = Number(pick(option, "quantity") ?? 1);
|
|
120
|
+
return name && quantity > 1 ? `${quantity}x ${name}` : name;
|
|
121
|
+
})
|
|
122
|
+
.filter((name): name is string => name !== null);
|
|
123
|
+
const parts = [fraction, options.join(", ") || null, firstString(item, [["specialInstructions"]])];
|
|
124
|
+
const note = parts.filter((part): part is string => part !== null).join(" · ");
|
|
125
|
+
return note === "" ? null : note;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* What the buyer paid for the whole line, in cents. The spec's `totalPrice`
|
|
130
|
+
* ("quantity * (unitPrice + optionsPrice)") is the figure the order's
|
|
131
|
+
* `itemsPrice` is built from, and it wins whenever it is stated — its own
|
|
132
|
+
* example does not add up otherwise (unit 43, options 50, total 50).
|
|
133
|
+
*
|
|
134
|
+
* Without it: `unitPrice × quantity + optionsPrice`. ESTIMATED: the spec calls
|
|
135
|
+
* `optionsPrice` "the sum of the total prices of all options of the item", a
|
|
136
|
+
* LINE figure, so it is added once, never multiplied by the quantity or by a
|
|
137
|
+
* weight.
|
|
138
|
+
*/
|
|
139
|
+
function lineTotalCents(item: unknown, quantity: number): number {
|
|
140
|
+
const total = priceCents(item, "totalPrice");
|
|
141
|
+
if (total !== null) return total;
|
|
142
|
+
const unit = priceCents(item, "unitPrice") ?? 0;
|
|
143
|
+
return Math.round(unit * quantity) + (priceCents(item, "optionsPrice") ?? 0);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** The stated quantity (decimal for weighed units), 1 when absent or nonsense. */
|
|
147
|
+
function quantityOf(item: unknown): number {
|
|
148
|
+
const stated = Number(pick(item, "quantity") ?? 1);
|
|
149
|
+
return Number.isFinite(stated) && stated > 0 ? stated : 1;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Split a line total over a whole quantity so the lines add up to it EXACTLY:
|
|
154
|
+
* one row at `total / quantity` when it divides; otherwise `quantity - 1`
|
|
155
|
+
* units at the floor and one unit carrying the remainder, under the same SKU
|
|
156
|
+
* (R$ 10.00 over 3 is 3.33 × 2 + 3.34).
|
|
157
|
+
*/
|
|
158
|
+
function splitWhole(total: number, quantity: number): { quantity: number; unitPriceCents: number }[] {
|
|
159
|
+
const floor = Math.floor(total / quantity);
|
|
160
|
+
const remainder = total - floor * quantity;
|
|
161
|
+
if (remainder === 0) return [{ quantity, unitPriceCents: floor }];
|
|
162
|
+
const rest = quantity === 1 ? [] : [{ quantity: quantity - 1, unitPriceCents: floor }];
|
|
163
|
+
return [...rest, { quantity: 1, unitPriceCents: floor + remainder }];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* One `Order.items[]` entry → its lines, which always add up to the line's
|
|
168
|
+
* total ({@link lineTotalCents}). A whole quantity is split by
|
|
169
|
+
* {@link splitWhole}; a fractional one (500 g as `0.5 KG`) is one line at its
|
|
170
|
+
* total, the weight in the note.
|
|
171
|
+
*
|
|
172
|
+
* A line with no `externalCode` keys on the item id, then the name: an
|
|
173
|
+
* unmapped line is recoverable, a dropped one is not. ESTIMATED: whether the
|
|
174
|
+
* item id is stable across orders is not pinned by the spec; if it is per
|
|
175
|
+
* order, each such order adds an unmapped SKU row.
|
|
176
|
+
*/
|
|
177
|
+
function readLines(item: unknown): NormalizedOrderLine[] {
|
|
178
|
+
const name = firstString(item, [["name"]]);
|
|
179
|
+
const sku = firstString(item, [["externalCode"], ["id"]]) ?? name;
|
|
180
|
+
if (!sku) return [];
|
|
181
|
+
const quantity = quantityOf(item);
|
|
182
|
+
const whole = Number.isInteger(quantity);
|
|
183
|
+
const fraction = whole ? null : `${quantity} ${firstString(item, [["unit"]]) ?? ""}`.trim();
|
|
184
|
+
const total = lineTotalCents(item, quantity);
|
|
185
|
+
const parts = whole ? splitWhole(total, quantity) : [{ quantity: 1, unitPriceCents: total }];
|
|
186
|
+
const note = lineNote(item, fraction);
|
|
187
|
+
return parts.map((part) => ({ externalSku: sku, name: name ?? sku, ...part, note }));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** `DELIVERY` or `TAKEOUT`; `INDOOR` (eaten at the store) is neither, so unstated. */
|
|
191
|
+
function readOrderType(order: unknown): MarketplaceOrderType | null {
|
|
192
|
+
const stated = firstString(order, [["type"]])?.toUpperCase();
|
|
193
|
+
return stated === "DELIVERY" || stated === "TAKEOUT" ? stated : null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function readDeliveredBy(order: unknown): MarketplaceDeliveredBy | null {
|
|
197
|
+
const stated = firstString(order, [["delivery", "deliveredBy"]])?.toUpperCase();
|
|
198
|
+
return stated === "MERCHANT" || stated === "MARKETPLACE" ? stated : null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* `delivery.deliveryAddress`. The spec's schema says `street`, `number`,
|
|
203
|
+
* `district`; its own (commented) order example says `streetName`,
|
|
204
|
+
* `streetNumber`, `neighborhood`. Both are read. The state is ISO 3166-2 by
|
|
205
|
+
* recommendation (`BR-SP`), so the country prefix is dropped.
|
|
206
|
+
*/
|
|
207
|
+
function readAddress(order: unknown, missingStreetNumber: string): NormalizedAddress | null {
|
|
208
|
+
const raw = pick(order, "delivery", "deliveryAddress");
|
|
209
|
+
const street = firstString(raw, [["street"], ["streetName"]]);
|
|
210
|
+
if (street === null) return null;
|
|
211
|
+
return {
|
|
212
|
+
street,
|
|
213
|
+
number: firstString(raw, [["number"], ["streetNumber"]]) ?? missingStreetNumber,
|
|
214
|
+
neighborhood: firstString(raw, [["district"], ["neighborhood"]]) ?? "",
|
|
215
|
+
complement: firstString(raw, [["complement"]]),
|
|
216
|
+
reference: firstString(raw, [["reference"]]),
|
|
217
|
+
postalCode: firstString(raw, [["postalCode"]])?.replace(/\D/g, "") || null,
|
|
218
|
+
city: firstString(raw, [["city"]]),
|
|
219
|
+
state: firstString(raw, [["state"]])?.replace(/^[A-Z]{2}-/u, "") ?? null,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Normalize one `Order` (the answer of `GET /v1/orders/{orderId}`). Null when
|
|
225
|
+
* it carries no id or no line.
|
|
226
|
+
*
|
|
227
|
+
* The total is `total.orderAmount`, "the final value of the order (itemsPrice
|
|
228
|
+
* + otherFees - discounts)": the buyer's receipt, gross. Open Delivery's
|
|
229
|
+
* `Order` states NO commission field, so `commissionCents` is null ("did not
|
|
230
|
+
* say"), never 0; the marketplace's cut arrives with its statement.
|
|
231
|
+
*/
|
|
232
|
+
export function normalizeOpenDeliveryOrderAs(
|
|
233
|
+
provider: string,
|
|
234
|
+
order: unknown,
|
|
235
|
+
options: { missingStreetNumber: string },
|
|
236
|
+
): NormalizedMarketplaceOrder | null {
|
|
237
|
+
const externalOrderId = firstString(order, [["id"]]);
|
|
238
|
+
const rawItems = pick(order, "items");
|
|
239
|
+
const lines = (Array.isArray(rawItems) ? rawItems : [])
|
|
240
|
+
.flatMap(readLines);
|
|
241
|
+
if (!externalOrderId || lines.length === 0) return null;
|
|
242
|
+
return {
|
|
243
|
+
provider,
|
|
244
|
+
externalOrderId,
|
|
245
|
+
externalDisplayId: firstString(order, [["displayId"]]),
|
|
246
|
+
externalMerchantId: firstString(order, [["merchant", "id"]]),
|
|
247
|
+
buyer: {
|
|
248
|
+
externalId: firstString(order, [["customer", "id"]]),
|
|
249
|
+
name: firstString(order, [["customer", "name"]]),
|
|
250
|
+
phone: firstString(order, [["customer", "phone", "number"]]),
|
|
251
|
+
},
|
|
252
|
+
lines,
|
|
253
|
+
// The line sum is the FALLBACK: the stated total carries the fees and
|
|
254
|
+
// discounts the lines do not, and it is the number on the receipt.
|
|
255
|
+
totalCents:
|
|
256
|
+
firstCents(order, [["total", "orderAmount", "value"]]) ??
|
|
257
|
+
lines.reduce((sum, line) => sum + line.unitPriceCents * line.quantity, 0),
|
|
258
|
+
commissionCents: null,
|
|
259
|
+
deliveryDueAt: firstDate(order, [
|
|
260
|
+
["delivery", "estimatedDeliveryDateTime"],
|
|
261
|
+
["takeout", "takeoutDateTime"],
|
|
262
|
+
["schedule", "scheduledDateTimeEnd"],
|
|
263
|
+
]),
|
|
264
|
+
placedAt: firstDate(order, [["createdAt"]]) ?? new Date(),
|
|
265
|
+
orderType: readOrderType(order),
|
|
266
|
+
deliveredBy: readDeliveredBy(order),
|
|
267
|
+
deliveryAddress: readAddress(order, options.missingStreetNumber),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import {
|
|
2
|
+
answered,
|
|
3
|
+
outboundResultOf,
|
|
4
|
+
type AdapterCallContext,
|
|
5
|
+
type CancellationRequestInput,
|
|
6
|
+
type FetchOrderResult,
|
|
7
|
+
type MarketplaceHttpResponse,
|
|
8
|
+
type OutboundOrderRef,
|
|
9
|
+
type OutboundResult,
|
|
10
|
+
type StatusFacts,
|
|
11
|
+
} from "../core/adapter";
|
|
12
|
+
import type { NormalizedMarketplaceOrder } from "../core/types";
|
|
13
|
+
import { isStop, openDeliveryCall, type OpenDeliveryDialect, type OpenDeliveryStop } from "./client";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The ORDER calls every Open Delivery adapter shares: the order fetch,
|
|
17
|
+
* confirm, requestCancellation and the status steps. Paths, verbs, bodies and
|
|
18
|
+
* answers are the standard's (v1.7.1 and v1.5.0 agree on all of them); the
|
|
19
|
+
* job that calls these, its retries and what a failure shows are the
|
|
20
|
+
* engine's. What a marketplace does differently is an option here, set by its
|
|
21
|
+
* adapter folder. Tests never reach a marketplace: the HTTP client is the
|
|
22
|
+
* host's port, answered by a fake.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** One authenticated call to an order's resource. */
|
|
26
|
+
function callOrder(
|
|
27
|
+
ctx: AdapterCallContext,
|
|
28
|
+
dialect: OpenDeliveryDialect,
|
|
29
|
+
request: { method: "GET" | "POST"; externalOrderId: string; action: string | null; body?: unknown },
|
|
30
|
+
): Promise<MarketplaceHttpResponse | OpenDeliveryStop> {
|
|
31
|
+
const suffix = request.action === null ? "" : `/${request.action}`;
|
|
32
|
+
return openDeliveryCall(ctx, dialect, {
|
|
33
|
+
method: request.method,
|
|
34
|
+
path: `/v1/orders/${encodeURIComponent(request.externalOrderId)}${suffix}`,
|
|
35
|
+
...(request.body === undefined ? {} : { body: request.body }),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Whether a 422 answer's `CancellationError.cancellationStatus` says the order is already cancelled. */
|
|
40
|
+
function alreadyCancelled(response: MarketplaceHttpResponse): boolean {
|
|
41
|
+
if (response.status !== 422) return false;
|
|
42
|
+
try {
|
|
43
|
+
return (JSON.parse(response.body) as { cancellationStatus?: unknown }).cancellationStatus === "CANCELLED";
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** {@link answered} for a fetch: a call that never got an answer is a retry. */
|
|
50
|
+
async function fetched(call: () => Promise<FetchOrderResult>): Promise<FetchOrderResult> {
|
|
51
|
+
try {
|
|
52
|
+
return await call();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return { kind: "retry", reason: error instanceof Error ? error.message : String(error) };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** How a fetched `Order` becomes the engine's order. */
|
|
59
|
+
interface OpenDeliveryFetchOptions {
|
|
60
|
+
normalize(order: unknown): NormalizedMarketplaceOrder | null;
|
|
61
|
+
/**
|
|
62
|
+
* OPTIONAL. What the adapter does to the parsed `Order` before it is
|
|
63
|
+
* normalized (Keeta's encrypted fields). Never fails the fetch.
|
|
64
|
+
*/
|
|
65
|
+
prepare?(ctx: AdapterCallContext, order: unknown): Promise<unknown>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** `GET /v1/orders/{orderId}`: the order an event announced, normalized. A 404 is an expired order: refused. */
|
|
69
|
+
export function openDeliveryFetchOrder(
|
|
70
|
+
ctx: AdapterCallContext,
|
|
71
|
+
dialect: OpenDeliveryDialect,
|
|
72
|
+
order: { externalOrderId: string },
|
|
73
|
+
options: OpenDeliveryFetchOptions,
|
|
74
|
+
): Promise<FetchOrderResult> {
|
|
75
|
+
return fetched(async () => {
|
|
76
|
+
const response = await callOrder(ctx, dialect, { method: "GET", externalOrderId: order.externalOrderId, action: null });
|
|
77
|
+
if (isStop(response)) return response;
|
|
78
|
+
const result = outboundResultOf(response);
|
|
79
|
+
if (result.kind !== "accepted") return result;
|
|
80
|
+
let body: unknown;
|
|
81
|
+
try {
|
|
82
|
+
body = JSON.parse(response.body);
|
|
83
|
+
} catch {
|
|
84
|
+
return { kind: "refused", status: response.status, message: "the order is not JSON" };
|
|
85
|
+
}
|
|
86
|
+
const prepared = options.prepare ? await options.prepare(ctx, body) : body;
|
|
87
|
+
const normalized = options.normalize(prepared);
|
|
88
|
+
return normalized
|
|
89
|
+
? { kind: "order", order: normalized }
|
|
90
|
+
: { kind: "refused", status: response.status, message: "the order carries no id or no line" };
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* `POST /v1/orders/{orderId}/confirm` with the standard's `OrderConfirmed`:
|
|
96
|
+
* `orderExternalCode` (the host's own order id) and `createdAt`, plus the
|
|
97
|
+
* `preparationTime` in minutes when the store stated one. `createdAt` is sent
|
|
98
|
+
* as the moment of the confirmation: ESTIMATED (the standard describes it
|
|
99
|
+
* with the ORDER's creation text, a copy of another schema's).
|
|
100
|
+
*
|
|
101
|
+
* Every 422 is a refusal. It is the standard's generic `UnprocessableEntity`
|
|
102
|
+
* ("check if the instruction has not been sent before"), and its body cannot
|
|
103
|
+
* tell a duplicate from a cancelled order. So a retried confirm whose first
|
|
104
|
+
* answer was lost reads "not confirmed" with the app link (a false alarm a
|
|
105
|
+
* person dismisses on the marketplace), and a confirm the marketplace truly
|
|
106
|
+
* refused is never stamped confirmed.
|
|
107
|
+
*/
|
|
108
|
+
export function openDeliveryConfirm(
|
|
109
|
+
ctx: AdapterCallContext,
|
|
110
|
+
dialect: OpenDeliveryDialect,
|
|
111
|
+
order: OutboundOrderRef,
|
|
112
|
+
input: { preparationMinutes: number | null },
|
|
113
|
+
): Promise<OutboundResult> {
|
|
114
|
+
return answered(async () => {
|
|
115
|
+
const response = await callOrder(ctx, dialect, {
|
|
116
|
+
method: "POST",
|
|
117
|
+
externalOrderId: order.externalOrderId,
|
|
118
|
+
action: "confirm",
|
|
119
|
+
body: {
|
|
120
|
+
orderExternalCode: order.hostOrderCode,
|
|
121
|
+
createdAt: ctx.now.toISOString(),
|
|
122
|
+
...(input.preparationMinutes === null ? {} : { preparationTime: input.preparationMinutes }),
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
return isStop(response) ? response : outboundResultOf(response);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** The standard's limit on `outOfStockItems`. */
|
|
130
|
+
const MAX_OUT_OF_STOCK_ITEMS = 100;
|
|
131
|
+
|
|
132
|
+
/** How a marketplace reads `RequestCancelled.outOfStockItems`. */
|
|
133
|
+
interface OpenDeliveryCancellationOptions {
|
|
134
|
+
/**
|
|
135
|
+
* The offending SKUs (`externalCode`) are sent as `outOfStockItems` with an
|
|
136
|
+
* item-unavailable reason. False where the marketplace wants its own item
|
|
137
|
+
* uuids there, which the engine does not keep (99Food, v1.7.1).
|
|
138
|
+
*/
|
|
139
|
+
outOfStockAsSkus: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* `POST /v1/orders/{orderId}/requestCancellation` with the standard's
|
|
144
|
+
* `RequestCancelled`: `reason` (free text: the store's, else the label),
|
|
145
|
+
* `code` (one of the standard's codes) and `mode` (`MANUAL` or `AUTO`). 202
|
|
146
|
+
* means taken; the outcome is a later event. A 422 whose `cancellationStatus`
|
|
147
|
+
* is `CANCELLED` means the order is cancelled already, which is what the
|
|
148
|
+
* request wanted. A 400 is a malformed request (a bad id or body: ours); a
|
|
149
|
+
* 422 is the business answer and stays a refusal.
|
|
150
|
+
*/
|
|
151
|
+
export function openDeliveryRequestCancellation(
|
|
152
|
+
ctx: AdapterCallContext,
|
|
153
|
+
dialect: OpenDeliveryDialect,
|
|
154
|
+
order: OutboundOrderRef,
|
|
155
|
+
input: CancellationRequestInput,
|
|
156
|
+
options: OpenDeliveryCancellationOptions,
|
|
157
|
+
): Promise<OutboundResult> {
|
|
158
|
+
const skus =
|
|
159
|
+
options.outOfStockAsSkus && input.reason.itemUnavailable && input.offendingSkus.length > 0
|
|
160
|
+
? { outOfStockItems: input.offendingSkus.slice(0, MAX_OUT_OF_STOCK_ITEMS) }
|
|
161
|
+
: {};
|
|
162
|
+
return answered(async () => {
|
|
163
|
+
const response = await callOrder(ctx, dialect, {
|
|
164
|
+
method: "POST",
|
|
165
|
+
externalOrderId: order.externalOrderId,
|
|
166
|
+
action: "requestCancellation",
|
|
167
|
+
body: {
|
|
168
|
+
reason: input.text === "" ? input.reason.label : input.text,
|
|
169
|
+
code: input.reason.code,
|
|
170
|
+
mode: input.mode,
|
|
171
|
+
...skus,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
if (isStop(response)) return response;
|
|
175
|
+
if (alreadyCancelled(response)) return { kind: "accepted" };
|
|
176
|
+
const result = outboundResultOf(response);
|
|
177
|
+
return result.kind === "refused" && result.status === 400 ? { ...result, own: true } : result;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Which standard status call a step takes, for which kind of order. */
|
|
182
|
+
type StatusPath = (facts: StatusFacts) => { action: string; body?: unknown } | null;
|
|
183
|
+
|
|
184
|
+
/** The status calls a marketplace serves. */
|
|
185
|
+
interface OpenDeliveryStatusOptions {
|
|
186
|
+
/** A take-out's HANDED_OVER is `POST /v1/orders/{id}/pickedUp`. False where the marketplace has no take-out. */
|
|
187
|
+
takeoutPickedUp: boolean;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* The standard's status calls (FUT-4653):
|
|
192
|
+
*
|
|
193
|
+
* - READY: `POST /v1/orders/{id}/readyForPickup`, no body; 202. Every kind of order.
|
|
194
|
+
* - DISPATCHED: `POST /v1/orders/{id}/dispatch`, body `OrderDispatched`
|
|
195
|
+
* (`deliveryTrackingInfo` optional, sent empty). Only where the logistics
|
|
196
|
+
* is the merchant's.
|
|
197
|
+
* - HANDED_OVER: the merchant's bag `POST /v1/orders/{id}/delivered`; a
|
|
198
|
+
* take-out `POST /v1/orders/{id}/pickedUp` where the marketplace serves it.
|
|
199
|
+
* The marketplace's own fleet: none.
|
|
200
|
+
*
|
|
201
|
+
* The kind of order is `deliveredBy` (null: a take-out; ESTIMATED: an order
|
|
202
|
+
* that merely omits it reads as a take-out here).
|
|
203
|
+
*/
|
|
204
|
+
function statusPaths(options: OpenDeliveryStatusOptions): Readonly<Record<string, StatusPath>> {
|
|
205
|
+
return {
|
|
206
|
+
READY: () => ({ action: "readyForPickup" }),
|
|
207
|
+
DISPATCHED: (facts) => (facts.deliveredBy === "MERCHANT" ? { action: "dispatch", body: {} } : null),
|
|
208
|
+
HANDED_OVER: (facts) =>
|
|
209
|
+
facts.deliveredBy === "MERCHANT"
|
|
210
|
+
? { action: "delivered", body: {} }
|
|
211
|
+
: facts.deliveredBy === null && options.takeoutPickedUp
|
|
212
|
+
? { action: "pickedUp", body: {} }
|
|
213
|
+
: null,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** A marketplace's status half: whether a step is taken (offline), and the call that tells it. */
|
|
218
|
+
export function openDeliveryStatus(options: OpenDeliveryStatusOptions) {
|
|
219
|
+
const paths = statusPaths(options);
|
|
220
|
+
return {
|
|
221
|
+
supported: (facts: StatusFacts): boolean => paths[facts.step]?.(facts) != null,
|
|
222
|
+
inform(
|
|
223
|
+
ctx: AdapterCallContext,
|
|
224
|
+
dialect: OpenDeliveryDialect,
|
|
225
|
+
order: OutboundOrderRef,
|
|
226
|
+
facts: StatusFacts,
|
|
227
|
+
): Promise<OutboundResult | { kind: "unsupported" }> {
|
|
228
|
+
const path = paths[facts.step]?.(facts) ?? null;
|
|
229
|
+
if (path === null) return Promise.resolve({ kind: "unsupported" });
|
|
230
|
+
return answered(async () => {
|
|
231
|
+
const response = await callOrder(ctx, dialect, {
|
|
232
|
+
method: "POST",
|
|
233
|
+
externalOrderId: order.externalOrderId,
|
|
234
|
+
action: path.action,
|
|
235
|
+
...(path.body === undefined ? {} : { body: path.body }),
|
|
236
|
+
});
|
|
237
|
+
return isStop(response) ? response : outboundResultOf(response);
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cancellation codes a merchant may send, verbatim from Open Delivery's
|
|
3
|
+
* `RequestCancelled.code`: the same eleven in v1.7.1 and in Keeta's v1.5.0
|
|
4
|
+
* (its "códigos de cancelamento (v1.0.7+)"). Pinned by the standard, not
|
|
5
|
+
* estimated. The two codes only the marketplace sends
|
|
6
|
+
* (`CONSUMER_CANCELLATION_REQUESTED`, `OTHER_CANCELLATION_REASON`) are not a
|
|
7
|
+
* store's to choose and are left out.
|
|
8
|
+
*/
|
|
9
|
+
export const OPEN_DELIVERY_MERCHANT_REASON_CODES = [
|
|
10
|
+
"SYSTEMIC_ISSUES",
|
|
11
|
+
"DUPLICATE_APPLICATION",
|
|
12
|
+
"UNAVAILABLE_ITEM",
|
|
13
|
+
"RESTAURANT_WITHOUT_DELIVERY_PERSON",
|
|
14
|
+
"OUTDATED_MENU",
|
|
15
|
+
"ORDER_OUTSIDE_THE_DELIVERY_AREA",
|
|
16
|
+
"BLOCKED_CUSTOMER",
|
|
17
|
+
"OUTSIDE_DELIVERY_HOURS",
|
|
18
|
+
"INTERNAL_DIFFICULTIES_OF_THE_RESTAURANT",
|
|
19
|
+
"RISK_AREA",
|
|
20
|
+
"DELIVERY_PROBLEM",
|
|
21
|
+
] as const;
|
|
22
|
+
|
|
23
|
+
type OpenDeliveryMerchantReasonCode = (typeof OPEN_DELIVERY_MERCHANT_REASON_CODES)[number];
|
|
24
|
+
|
|
25
|
+
/** The one reason that means "an item is unavailable". */
|
|
26
|
+
export const OPEN_DELIVERY_ITEM_UNAVAILABLE: OpenDeliveryMerchantReasonCode = "UNAVAILABLE_ITEM";
|
package/src/rappi/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
verifyRappiSignature,
|
|
8
8
|
type RappiAmountUnit,
|
|
9
9
|
} from "./normalize";
|
|
10
|
-
import { rappiReject, rappiTake, type RappiBaseUrls } from "./outbound";
|
|
10
|
+
import { rappiInformStatus, rappiReject, rappiStatusSupported, rappiTake, type RappiBaseUrls } from "./outbound";
|
|
11
11
|
import { rappiAvailability } from "./pause";
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -148,6 +148,9 @@ export function createRappiAdapter(config: RappiAdapterConfig): MarketplaceAdapt
|
|
|
148
148
|
// `take/{cookingTime}`, in minutes.
|
|
149
149
|
confirmTakesPreparationTime: true,
|
|
150
150
|
cancellationAnswerWindowMs: RAPPI_CANCELLATION_ANSWER_WINDOW_MS,
|
|
151
|
+
// READY only, and ESTIMATED (see `./outbound.ts`). Rappi's normalizer maps no
|
|
152
|
+
// lifecycle event: its `event` values are undocumented (see `./normalize.ts`).
|
|
153
|
+
statusSteps: ["READY"],
|
|
151
154
|
},
|
|
152
155
|
normalize: (payload) => normalizeRappiEvent(payload, normalizeOptions),
|
|
153
156
|
readSignature: (header) => header(RAPPI_SIGNATURE_HEADER),
|
|
@@ -155,6 +158,8 @@ export function createRappiAdapter(config: RappiAdapterConfig): MarketplaceAdapt
|
|
|
155
158
|
cancellationReasons: () => reasons,
|
|
156
159
|
confirm: (ctx, order, input) => rappiTake(ctx, hosts, order, input),
|
|
157
160
|
requestCancellation: (ctx, order, input) => rappiReject(ctx, hosts, order, input),
|
|
161
|
+
statusSupported: rappiStatusSupported,
|
|
162
|
+
informStatus: (ctx, order, facts) => rappiInformStatus(ctx, hosts, order, facts),
|
|
158
163
|
appLink: () => config.portalUrl,
|
|
159
164
|
...(config.pauseByStoreSwitch ? { availability: rappiAvailability(hosts) } : {}),
|
|
160
165
|
};
|
package/src/rappi/normalize.ts
CHANGED
|
@@ -37,6 +37,12 @@ import type {
|
|
|
37
37
|
* else is recorded and IGNORED: a missed cancellation is visible in the inbox,
|
|
38
38
|
* a false one would cancel a live order.
|
|
39
39
|
*
|
|
40
|
+
* Rappi maps NO lifecycle event (FUT-4653: no `lifecycle` on any event it
|
|
41
|
+
* normalizes). ESTIMATED: the `event` values of ORDER_OTHER_EVENT are
|
|
42
|
+
* undocumented (https://dev-portal.rappi.com/, read 2026-11-25), so nothing
|
|
43
|
+
* here can name "dispatched" or "concluded" without guessing; such an event
|
|
44
|
+
* stays IGNORED, as before.
|
|
45
|
+
*
|
|
40
46
|
* Rappi payloads carry no event id, so the inbox key is derived from the
|
|
41
47
|
* order and the event, deterministic so a redelivery collides on the inbox's
|
|
42
48
|
* unique index.
|
package/src/rappi/outbound.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type MarketplaceHttpResponse,
|
|
8
8
|
type OutboundOrderRef,
|
|
9
9
|
type OutboundResult,
|
|
10
|
+
type StatusFacts,
|
|
10
11
|
} from "../core/adapter";
|
|
11
12
|
import { RAPPI_PROVIDER } from "./normalize";
|
|
12
13
|
|
|
@@ -110,12 +111,12 @@ export async function bearer(
|
|
|
110
111
|
async function putOrder(
|
|
111
112
|
ctx: AdapterCallContext,
|
|
112
113
|
hosts: RappiHosts,
|
|
113
|
-
request: { externalOrderId: string; action: string; body?: unknown },
|
|
114
|
+
request: { externalOrderId: string; action: string; body?: unknown; method?: "PUT" | "POST" },
|
|
114
115
|
): Promise<MarketplaceHttpResponse | Exclude<OutboundResult, { kind: "accepted" }>> {
|
|
115
116
|
const auth = await bearer(ctx, hosts);
|
|
116
117
|
if (!("token" in auth)) return auth;
|
|
117
118
|
const response = await ctx.http({
|
|
118
|
-
method: "PUT",
|
|
119
|
+
method: request.method ?? "PUT",
|
|
119
120
|
url: `${trimmed(hosts.api[ctx.environment])}/orders/${encodeURIComponent(request.externalOrderId)}/${request.action}`,
|
|
120
121
|
headers: {
|
|
121
122
|
"x-authorization": `Bearer ${auth.token}`,
|
|
@@ -181,3 +182,31 @@ export function rappiReject(
|
|
|
181
182
|
return "kind" in response ? response : outboundResultOf(response);
|
|
182
183
|
});
|
|
183
184
|
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* What Rappi is told per step (FUT-4653). READY only: `POST {api}/orders/{id}/ready-for-pickup`
|
|
188
|
+
* (Rappi's dev portal, https://dev-portal.rappi.com/, "Managing User Orders",
|
|
189
|
+
* read 2026-11-25), which the portal says is for a store on MANUAL
|
|
190
|
+
* notification (Rappi recommends Automatic): any other store's call may be
|
|
191
|
+
* refused, which ends FAILED and logged, never retried. ESTIMATED: the verb is
|
|
192
|
+
* POST in the portal while the other order calls here are PUT. No endpoint
|
|
193
|
+
* was found for DISPATCHED (Rappi's own couriers carry the order) nor for
|
|
194
|
+
* HANDED_OVER, so those are unsupported.
|
|
195
|
+
*/
|
|
196
|
+
export function rappiStatusSupported(facts: StatusFacts): boolean {
|
|
197
|
+
return facts.step === "READY";
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** Tell Rappi a step happened. `unsupported` for every step but READY. */
|
|
201
|
+
export function rappiInformStatus(
|
|
202
|
+
ctx: AdapterCallContext,
|
|
203
|
+
hosts: RappiHosts,
|
|
204
|
+
order: OutboundOrderRef,
|
|
205
|
+
facts: StatusFacts,
|
|
206
|
+
): Promise<OutboundResult | { kind: "unsupported" }> {
|
|
207
|
+
if (facts.step !== "READY") return Promise.resolve({ kind: "unsupported" });
|
|
208
|
+
return answered(async () => {
|
|
209
|
+
const response = await putOrder(ctx, hosts, { externalOrderId: order.externalOrderId, action: "ready-for-pickup", method: "POST" });
|
|
210
|
+
return "kind" in response ? response : outboundResultOf(response);
|
|
211
|
+
});
|
|
212
|
+
}
|
package/src/server/mcp.ts
CHANGED
|
@@ -72,6 +72,7 @@ const integrationUpsertInput = z.strictObject({
|
|
|
72
72
|
environment: environmentSchema.optional(),
|
|
73
73
|
externalMerchantId: z.string().trim().min(1).nullable().optional(),
|
|
74
74
|
autoAccept: z.boolean().optional(),
|
|
75
|
+
followStatus: z.boolean().optional(),
|
|
75
76
|
// Below a minute nothing human can answer in time; above an hour the
|
|
76
77
|
// deadline has stopped describing anything a marketplace would wait for.
|
|
77
78
|
ackSlaSeconds: z.number().int().min(60).max(3600).optional(),
|
|
@@ -186,6 +187,7 @@ const integrationSchema = z.object({
|
|
|
186
187
|
status: z.enum(["UNVERIFIED", "VERIFIED", "FAILED"]),
|
|
187
188
|
externalMerchantId: z.string().nullable(),
|
|
188
189
|
autoAccept: z.boolean(),
|
|
190
|
+
followStatus: z.boolean(),
|
|
189
191
|
ackSlaSeconds: z.number().int(),
|
|
190
192
|
connected: z.boolean(),
|
|
191
193
|
lastEventAt: z.string().nullable(),
|
package/src/server/webhook.ts
CHANGED
|
@@ -99,7 +99,9 @@ async function handleWebhook(config: MarketplaceApiConfig, request: WireRequest<
|
|
|
99
99
|
payload,
|
|
100
100
|
// A DISABLED connection still stores its deliveries and ingests nothing;
|
|
101
101
|
// the retry sweep ingests them if the store turns it back on.
|
|
102
|
-
settings: target.enabled
|
|
102
|
+
settings: target.enabled
|
|
103
|
+
? { autoAccept: target.autoAccept, ackSlaSeconds: target.ackSlaSeconds, followStatus: target.followStatus }
|
|
104
|
+
: null,
|
|
103
105
|
});
|
|
104
106
|
if (outcome.kind === "failed") {
|
|
105
107
|
return { status: 500, body: { received: true, error: outcome.reason } };
|