@12-apps/marketplace 1.19.1 → 1.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADOPTING.md +61 -0
- package/dist/99food/index.d.ts +2 -2
- package/dist/{adapter-ZpAWKoCk.d.ts → adapter-lXWwuQQh.d.ts} +1 -1
- package/dist/{chunk-RS2QKQ6S.js → chunk-C2MFGZ3H.js} +2 -2
- package/dist/{chunk-S2ISELNJ.js → chunk-T6A46MH3.js} +52 -43
- package/dist/chunk-T6A46MH3.js.map +1 -0
- package/dist/{client-DpEq0yXb.d.ts → client-CSHcYu3w.d.ts} +1 -1
- package/dist/{engine-CaiVufoP.d.ts → engine-DH7H8m0B.d.ts} +1 -1
- package/dist/hono/index.d.ts +2 -2
- package/dist/hono/index.js +2 -2
- package/dist/ifood/index.d.ts +365 -2
- package/dist/ifood/index.js +509 -9
- package/dist/ifood/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/keeta/index.d.ts +2 -2
- package/dist/manifest/server.d.ts +2 -2
- package/dist/manifest/server.js +2 -2
- package/dist/rappi/index.d.ts +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +2 -2
- package/package.json +1 -1
- package/src/core/acknowledge.ts +16 -1
- package/src/core/order-fetch-marks.ts +9 -2
- package/src/ifood/courier.ts +4 -3
- package/src/ifood/index.ts +49 -0
- package/src/ifood/shipping-address.ts +190 -0
- package/src/ifood/shipping-events.ts +126 -0
- package/src/ifood/shipping-orders.ts +213 -0
- package/src/ifood/shipping-wire.ts +274 -0
- package/src/ifood/shipping.ts +184 -0
- package/dist/chunk-S2ISELNJ.js.map +0 -1
- /package/dist/{chunk-RS2QKQ6S.js.map → chunk-C2MFGZ3H.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ar as MarketplaceDeliveredBy, aI as NormalizedLineOption, aA as MarketplaceLinkAttemptDelegate, av as MarketplaceDisputeDelegate, z as CatalogueItem, y as CatalogueImage, b0 as LogisticsPorts, b1 as LogisticsOrderPort, a as NormalizedMarketplaceOrder, N as NormalizedEvent, aV as StatusStep, j as NormalizedCourierEvent, an as MarketplaceCourierFacts, al as MarketplaceCourierAnswer, aS as PickupCodeValidation, au as MarketplaceDisputeChange, aw as MarketplaceHttp, ah as MarketplaceAppCredentialsPort, c as MarketplaceAdapter, ae as LogisticsStep, az as MarketplaceLifecycle, ao as MarketplaceCourierStep, Z as DeliveryCodeAnswer, p as MarketplaceProvider, aq as MarketplaceCredentials, W as CatalogueWarningCode, aT as PresenceProbe, q as CancellationReason, ac as LinkedMerchant, a2 as DisputeFailureCode, a3 as DisputeItem, _ as DisputeAlternative, a5 as DisputeReason, a4 as DisputeOutcome, am as MarketplaceCourierEngine, b2 as MarketplaceLogisticsEngine, aP as OutboundOrderRef, b as CatalogueMenuOptions, I as CatalogueReadResult } from './adapter-lXWwuQQh.js';
|
|
2
2
|
|
|
3
3
|
/** What the engine tells the host about the order a lifecycle event names. */
|
|
4
4
|
interface MarketplaceLifecycleFacts {
|
package/dist/hono/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hono, Context } from 'hono';
|
|
2
2
|
import { ApiMarketplace, MarketplaceApiConfig, MarketplaceActor } from '../server/index.js';
|
|
3
|
-
import '../engine-
|
|
4
|
-
import '../adapter-
|
|
3
|
+
import '../engine-DH7H8m0B.js';
|
|
4
|
+
import '../adapter-lXWwuQQh.js';
|
|
5
5
|
import '@12-apps/wiring';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
package/dist/hono/index.js
CHANGED
package/dist/ifood/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as NormalizedEvent, a as NormalizedMarketplaceOrder, A as AdapterCallContext, F as FetchOrderResult, d as PushCatalogue, e as CatalogueItemOut, f as CatalogueReader, g as MarketplaceLinking, h as MarketplaceAppLinking, i as MarketplaceCourierApi, j as NormalizedCourierEvent, M as MarketplaceAvailability, S as StorePauseRequest, k as StorePauseResult, l as StorePauseRef, O as OutboundResult, m as MarketplaceLogistics, c as MarketplaceAdapter } from '../adapter-
|
|
1
|
+
import { N as NormalizedEvent, a as NormalizedMarketplaceOrder, A as AdapterCallContext, F as FetchOrderResult, d as PushCatalogue, e as CatalogueItemOut, f as CatalogueReader, g as MarketplaceLinking, h as MarketplaceAppLinking, i as MarketplaceCourierApi, j as NormalizedCourierEvent, M as MarketplaceAvailability, S as StorePauseRequest, k as StorePauseResult, l as StorePauseRef, O as OutboundResult, m as MarketplaceLogistics, n as MarketplaceCourierTracking, o as OrderCancellationReason, c as MarketplaceAdapter } from '../adapter-lXWwuQQh.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The words the iFood adapter needs from its host, and nothing else.
|
|
@@ -188,6 +188,369 @@ declare function ifoodLogisticsVerifyDeliveryCode(ctx: AdapterCallContext, exter
|
|
|
188
188
|
*/
|
|
189
189
|
declare const IFOOD_LOGISTICS: MarketplaceLogistics;
|
|
190
190
|
|
|
191
|
+
/**
|
|
192
|
+
* The wire half every iFood SHIPPING call shares (FUT-5667, FUT-5666): the
|
|
193
|
+
* base URL, the token, the idempotency key and how an answer reads. The calls
|
|
194
|
+
* themselves are `./shipping.ts` and `./shipping-orders.ts`.
|
|
195
|
+
*
|
|
196
|
+
* Read off iFood's Shipping guides on 2026-12-04, each page's markdown source:
|
|
197
|
+
*
|
|
198
|
+
* - https://developer.ifood.com.br/pt-BR/docs/food/guides/modules/shipping/endpoints
|
|
199
|
+
* - https://developer.ifood.com.br/pt-BR/docs/food/guides/modules/shipping/inside
|
|
200
|
+
* - https://developer.ifood.com.br/pt-BR/docs/food/guides/modules/shipping/outside
|
|
201
|
+
* - https://developer.ifood.com.br/pt-BR/docs/food/guides/modules/shipping/homologacao
|
|
202
|
+
* - https://developer.ifood.com.br/pt-BR/docs/food/guides/modules/shipping/best-practices-troubleshooting/boas-praticas-e-troubleshooting
|
|
203
|
+
*
|
|
204
|
+
* Which app: Shipping is a module of the store's PDV (Delivery) app, the one
|
|
205
|
+
* whose token carries the `shipping` scope for the stores that authorized it.
|
|
206
|
+
* The context is used as the host hands it, a linked store's grant included,
|
|
207
|
+
* unlike the Logistics module's own app (`./logistics.ts`).
|
|
208
|
+
*
|
|
209
|
+
* Tests never reach iFood: the HTTP client is the host's port.
|
|
210
|
+
*/
|
|
211
|
+
declare const IFOOD_SHIPPING_API = "https://merchant-api.ifood.com.br/shipping/v1.0";
|
|
212
|
+
/**
|
|
213
|
+
* The Shipping homologation's token rule: "Renove tokens antes do vencimento
|
|
214
|
+
* (recomendado: 5 minutos antes)". A Shipping call renews a cached token this
|
|
215
|
+
* close to its expiry; outside the window the cached one is used.
|
|
216
|
+
*/
|
|
217
|
+
declare const IFOOD_SHIPPING_TOKEN_REFRESH_AHEAD_MS: number;
|
|
218
|
+
/**
|
|
219
|
+
* Every error code the Shipping guides document for a 400 (and the address
|
|
220
|
+
* answers' 409s). Anything else iFood names is read as `UNKNOWN`, so a code a
|
|
221
|
+
* host branches on is always one of these.
|
|
222
|
+
*/
|
|
223
|
+
declare const IFOOD_SHIPPING_ERROR_CODES: readonly ["BadRequest", "BadRequestCustomer", "BadRequestMerchant", "DeliveryDistanceTooHigh", "OffOpeningHours", "OriginNotFound", "ServiceAreaMismatch", "HighDemand", "MerchantStatusAvailability", "MerchantEasyDeliveryDisabled", "InvalidPaymentMethods", "SaturatedOfflinePayment", "NRELimitExceeded", "UnavailableFleet", "PaymentMethodNotFound", "PaymentTotalInvalid", "OrderNotFound", "OrderWithoutSafeDelivery", "ChangeAddressOperationConflict", "ChangeAddressOperationNotStarted", "MaxDistanceHigherThanAllowed", "RegionMismatch"];
|
|
224
|
+
type IfoodShippingErrorCode = (typeof IFOOD_SHIPPING_ERROR_CODES)[number] | "UNKNOWN";
|
|
225
|
+
/** A call refused here, before reaching iFood: nothing was sent. */
|
|
226
|
+
interface IfoodShippingInvalid {
|
|
227
|
+
kind: "invalid";
|
|
228
|
+
reason: "IDEMPOTENCY_KEY" | "QUOTE_EXPIRED" | "COORDINATES" | "CUSTOMER_NAME" | "CUSTOMER_PHONE" | "ADDRESS" | "ADDRESS_TOO_FAR" | "MERCHANT_FEE" | "PREPARATION_TIME" | "ITEMS" | "DISPLAY_ID" | "CANCELLATION_CODE" | "CANCELLATION_REASON";
|
|
229
|
+
}
|
|
230
|
+
/** How a Shipping call can fail. */
|
|
231
|
+
type IfoodShippingFailure =
|
|
232
|
+
/** A documented "not now / not here" answer: iFood's code, and whether the guides say to try again later. */
|
|
233
|
+
{
|
|
234
|
+
kind: "unavailable";
|
|
235
|
+
status: number;
|
|
236
|
+
code: IfoodShippingErrorCode;
|
|
237
|
+
transient: boolean;
|
|
238
|
+
}
|
|
239
|
+
/** Any other final 4xx. The message names the status and code only: an answer body can echo a customer. */
|
|
240
|
+
| {
|
|
241
|
+
kind: "refused";
|
|
242
|
+
status: number;
|
|
243
|
+
message: string;
|
|
244
|
+
own?: true;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Nothing was changed, ask again (with backoff): a read answered 408, 425,
|
|
248
|
+
* 429 or 5xx, a POST answered 425, 429 or 503, a lost read, a lost token grant.
|
|
249
|
+
*/
|
|
250
|
+
| {
|
|
251
|
+
kind: "retry";
|
|
252
|
+
reason: string;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* A state-changing request was SENT and may have been applied: no answer
|
|
256
|
+
* came back, or a POST was answered 408, 500, 502, 504 (or another 5xx but
|
|
257
|
+
* 503). Never retried blindly; a retry goes with the SAME idempotency key.
|
|
258
|
+
*/
|
|
259
|
+
| {
|
|
260
|
+
kind: "uncertain";
|
|
261
|
+
reason: string;
|
|
262
|
+
} | IfoodShippingInvalid;
|
|
263
|
+
/** A state-changing call iFood took (2xx). Its outcome arrives as an event. */
|
|
264
|
+
interface IfoodShippingRequested {
|
|
265
|
+
kind: "requested";
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* How long to wait before an attempt (1-based) of a call that answered
|
|
269
|
+
* `retry`: the best-practices guide's table, 2x with jitter (immediate, 1 s,
|
|
270
|
+
* 2 s, 4 s, 8 s, each plus under a second), at most 5 attempts. Null: stop.
|
|
271
|
+
* The host's job schedules it; the client never sleeps.
|
|
272
|
+
*/
|
|
273
|
+
declare function ifoodShippingRetryDelayMs(attempt: number, random?: () => number): number | null;
|
|
274
|
+
|
|
275
|
+
/** One way the courier can be paid at the door, as the quote lists it. */
|
|
276
|
+
interface IfoodShippingPaymentMethod {
|
|
277
|
+
/** CREDIT, DEBIT or CASH. */
|
|
278
|
+
method: string;
|
|
279
|
+
/** OFFLINE: paid at the door. */
|
|
280
|
+
paymentType: string;
|
|
281
|
+
brand: string | null;
|
|
282
|
+
liability: string | null;
|
|
283
|
+
}
|
|
284
|
+
/** iFood's quote, money in cents. Valid until `expiresAt` (about 24 h); a later request is refused. */
|
|
285
|
+
interface IfoodShippingQuote {
|
|
286
|
+
/** The `quoteId` a request or an order names. */
|
|
287
|
+
id: string;
|
|
288
|
+
expiresAt: Date;
|
|
289
|
+
createdAt: Date | null;
|
|
290
|
+
distanceMeters: number | null;
|
|
291
|
+
/** The preparation time iFood suggests, in seconds. Only the off-platform quote states one. */
|
|
292
|
+
preparationTimeSeconds: number | null;
|
|
293
|
+
grossCents: number;
|
|
294
|
+
discountCents: number;
|
|
295
|
+
/** Only the off-platform quote states a raise; 0 otherwise. */
|
|
296
|
+
raiseCents: number;
|
|
297
|
+
/** What the store pays: `gross - discount + raise`, as iFood states it. */
|
|
298
|
+
netCents: number;
|
|
299
|
+
deliveryTimeSeconds: {
|
|
300
|
+
min: number | null;
|
|
301
|
+
max: number | null;
|
|
302
|
+
};
|
|
303
|
+
paymentMethods: IfoodShippingPaymentMethod[];
|
|
304
|
+
}
|
|
305
|
+
type IfoodShippingQuoteResult = {
|
|
306
|
+
kind: "quote";
|
|
307
|
+
quote: IfoodShippingQuote;
|
|
308
|
+
} | IfoodShippingFailure;
|
|
309
|
+
/**
|
|
310
|
+
* `GET /shipping/v1.0/orders/{orderId}/deliveryAvailabilities`: the quote for
|
|
311
|
+
* an order placed on the iFood platform (FUT-5666). Its 400 codes are the
|
|
312
|
+
* `inside` guide's list.
|
|
313
|
+
*/
|
|
314
|
+
declare function ifoodShippingQuoteForOrder(ctx: AdapterCallContext, externalOrderId: string): Promise<IfoodShippingQuoteResult>;
|
|
315
|
+
/**
|
|
316
|
+
* `GET /shipping/v1.0/merchants/{merchantId}/deliveryAvailabilities?latitude&longitude`:
|
|
317
|
+
* the quote for a door, for an order placed off the platform (FUT-5667).
|
|
318
|
+
*/
|
|
319
|
+
declare function ifoodShippingQuoteForAddress(ctx: AdapterCallContext, merchantId: string, point: {
|
|
320
|
+
latitude: number;
|
|
321
|
+
longitude: number;
|
|
322
|
+
}): Promise<IfoodShippingQuoteResult>;
|
|
323
|
+
/** The quote a request names. */
|
|
324
|
+
interface IfoodShippingQuoteRef {
|
|
325
|
+
id: string;
|
|
326
|
+
expiresAt: Date;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* `POST /shipping/v1.0/orders/{orderId}/requestDriver {quoteId}` (FUT-5666):
|
|
330
|
+
* 202, then `REQUEST_DRIVER_SUCCESS` or `REQUEST_DRIVER_FAILED` as an event.
|
|
331
|
+
* An expired quote is never sent ("Solicitar após é inválido").
|
|
332
|
+
*/
|
|
333
|
+
declare function ifoodRequestDriver(ctx: AdapterCallContext, input: {
|
|
334
|
+
externalOrderId: string;
|
|
335
|
+
quote: IfoodShippingQuoteRef;
|
|
336
|
+
idempotencyKey: string;
|
|
337
|
+
}): Promise<IfoodShippingRequested | IfoodShippingFailure>;
|
|
338
|
+
/**
|
|
339
|
+
* `POST /shipping/v1.0/orders/{orderId}/cancelRequestDriver`, no body: only
|
|
340
|
+
* before a courier accepts, free and irreversible. The outcome is
|
|
341
|
+
* `DELIVERY_CANCELLATION_REQUEST_ACCEPTED` or `..._REJECTED` (the courier had
|
|
342
|
+
* accepted: the order's own cancellation applies then).
|
|
343
|
+
*/
|
|
344
|
+
declare function ifoodCancelRequestDriver(ctx: AdapterCallContext, input: {
|
|
345
|
+
externalOrderId: string;
|
|
346
|
+
idempotencyKey: string;
|
|
347
|
+
}): Promise<IfoodShippingRequested | IfoodShippingFailure>;
|
|
348
|
+
type IfoodShippingTrackingResult = {
|
|
349
|
+
kind: "tracking";
|
|
350
|
+
tracking: MarketplaceCourierTracking;
|
|
351
|
+
}
|
|
352
|
+
/** 404: no courier assigned yet ("Nunca consultar tracking antes de REQUEST_DRIVER_SUCCESS"). */
|
|
353
|
+
| {
|
|
354
|
+
kind: "notYet";
|
|
355
|
+
} | IfoodShippingFailure;
|
|
356
|
+
/**
|
|
357
|
+
* `GET /shipping/v1.0/orders/{orderId}/tracking`, for either kind of order
|
|
358
|
+
* (the off-platform order by the id its creation answered). At most once per
|
|
359
|
+
* 30 s, which is the caller's schedule.
|
|
360
|
+
*/
|
|
361
|
+
declare function ifoodShippingTracking(ctx: AdapterCallContext, orderId: string): Promise<IfoodShippingTrackingResult>;
|
|
362
|
+
|
|
363
|
+
/** A delivery address, as the order and an address change carry it. */
|
|
364
|
+
interface IfoodShippingAddress {
|
|
365
|
+
/** 8 digits once sent; anything else in it is dropped. Not sent with a change request. */
|
|
366
|
+
postalCode: string;
|
|
367
|
+
/** Required on an order; optional on a change request. */
|
|
368
|
+
streetNumber: string;
|
|
369
|
+
/** At most 50 characters. */
|
|
370
|
+
streetName: string;
|
|
371
|
+
/** At most 50 characters. */
|
|
372
|
+
complement?: string;
|
|
373
|
+
/** At most 70 characters. */
|
|
374
|
+
reference?: string;
|
|
375
|
+
/** At most 50 characters. */
|
|
376
|
+
neighborhood: string;
|
|
377
|
+
/** 2 to 50 characters. */
|
|
378
|
+
city: string;
|
|
379
|
+
/** Two letters, e.g. SP. */
|
|
380
|
+
state: string;
|
|
381
|
+
/** Two letters, e.g. BR. */
|
|
382
|
+
country: string;
|
|
383
|
+
latitude: number;
|
|
384
|
+
longitude: number;
|
|
385
|
+
}
|
|
386
|
+
/** An address answer iFood refused: no change pending, another pending, too far, or another region. */
|
|
387
|
+
type IfoodAddressChangeResult = IfoodShippingRequested | {
|
|
388
|
+
kind: "address-change-refused";
|
|
389
|
+
status: number;
|
|
390
|
+
code: IfoodShippingErrorCode;
|
|
391
|
+
} | IfoodShippingFailure;
|
|
392
|
+
/** `POST …/userConfirmAddress`: the customer confirmed the original address. */
|
|
393
|
+
declare function ifoodShippingConfirmAddress(ctx: AdapterCallContext, orderId: string, idempotencyKey: string): Promise<IfoodAddressChangeResult>;
|
|
394
|
+
/** iFood's limit on a changed address: "máximo 500m da coordenada original". */
|
|
395
|
+
declare const IFOOD_SHIPPING_ADDRESS_CHANGE_MAX_METERS = 500;
|
|
396
|
+
/**
|
|
397
|
+
* `POST …/deliveryAddressChangeRequest`: a change asked through the
|
|
398
|
+
* integrator's own screen. Its body has no postal code and an optional street
|
|
399
|
+
* number. Given the `original` point, a move past 500 m is refused here,
|
|
400
|
+
* before iFood would (`MaxDistanceHigherThanAllowed`).
|
|
401
|
+
*/
|
|
402
|
+
declare function ifoodShippingRequestAddressChange(ctx: AdapterCallContext, orderId: string, address: IfoodShippingAddress, idempotencyKey: string, original?: {
|
|
403
|
+
latitude: number;
|
|
404
|
+
longitude: number;
|
|
405
|
+
}): Promise<IfoodAddressChangeResult>;
|
|
406
|
+
/** `POST …/acceptDeliveryAddressChange` (200): within 15 minutes of the request, or iFood rejects it. */
|
|
407
|
+
declare function ifoodShippingAcceptAddressChange(ctx: AdapterCallContext, orderId: string, idempotencyKey: string): Promise<IfoodAddressChangeResult>;
|
|
408
|
+
/** `POST …/denyDeliveryAddressChange` (202). */
|
|
409
|
+
declare function ifoodShippingDenyAddressChange(ctx: AdapterCallContext, orderId: string, idempotencyKey: string): Promise<IfoodAddressChangeResult>;
|
|
410
|
+
/** iFood's confidence in the delivery. */
|
|
411
|
+
type IfoodSafeDeliveryScore = "LOW" | "MODERATE" | "HIGH" | "VERY_HIGH";
|
|
412
|
+
type IfoodSafeDeliveryResult = {
|
|
413
|
+
kind: "score";
|
|
414
|
+
score: IfoodSafeDeliveryScore;
|
|
415
|
+
rules: Record<string, boolean>;
|
|
416
|
+
}
|
|
417
|
+
/** 400 `OrderWithoutSafeDelivery`: the order has no score. */
|
|
418
|
+
| {
|
|
419
|
+
kind: "none";
|
|
420
|
+
} | IfoodShippingFailure;
|
|
421
|
+
/** `GET /shipping/v1.0/orders/{orderId}/safeDelivery`. */
|
|
422
|
+
declare function ifoodShippingSafeDelivery(ctx: AdapterCallContext, orderId: string): Promise<IfoodSafeDeliveryResult>;
|
|
423
|
+
|
|
424
|
+
/** One line of the order. Money in cents. */
|
|
425
|
+
interface IfoodShippingItem {
|
|
426
|
+
id: string;
|
|
427
|
+
name: string;
|
|
428
|
+
externalCode?: string;
|
|
429
|
+
quantity: number;
|
|
430
|
+
unitPriceCents: number;
|
|
431
|
+
/** The line's complements, in total. */
|
|
432
|
+
optionsPriceCents: number;
|
|
433
|
+
}
|
|
434
|
+
/** What creating an order on demand takes. Money in cents. */
|
|
435
|
+
interface IfoodShippingOrderInput {
|
|
436
|
+
customer: {
|
|
437
|
+
name: string;
|
|
438
|
+
/** A Brazilian phone with its area code, in any punctuation, country code optional. Required. */
|
|
439
|
+
phone: string;
|
|
440
|
+
};
|
|
441
|
+
delivery: {
|
|
442
|
+
/** `merchantFee`: the delivery fee the store charged its customer. */
|
|
443
|
+
merchantFeeCents: number;
|
|
444
|
+
/** When iFood allocates the courier, in seconds; 0 or absent is at once. */
|
|
445
|
+
preparationTimeSeconds?: number;
|
|
446
|
+
quote: IfoodShippingQuoteRef;
|
|
447
|
+
address: IfoodShippingAddress;
|
|
448
|
+
};
|
|
449
|
+
items: IfoodShippingItem[];
|
|
450
|
+
/** A short id iFood shows, at most 4 characters. */
|
|
451
|
+
displayId?: string;
|
|
452
|
+
}
|
|
453
|
+
type IfoodShippingCreateResult =
|
|
454
|
+
/** 202: the order exists at iFood and a courier is being allocated. `trackingUrl` is null unless https. */
|
|
455
|
+
{
|
|
456
|
+
kind: "created";
|
|
457
|
+
id: string;
|
|
458
|
+
trackingUrl: string | null;
|
|
459
|
+
} | IfoodShippingFailure;
|
|
460
|
+
/**
|
|
461
|
+
* `POST /shipping/v1.0/merchants/{merchantId}/orders`: registers the order
|
|
462
|
+
* and starts the courier search; 202 `{id, trackingUrl}`. "Se a entrega não
|
|
463
|
+
* for viável, o pedido não será criado." A create whose answer was lost, or a
|
|
464
|
+
* 2xx without an id, is `uncertain`: the delivery may exist, so it is retried
|
|
465
|
+
* only with the same `idempotencyKey`, never as a new one.
|
|
466
|
+
*/
|
|
467
|
+
declare function ifoodShippingCreateOrder(ctx: AdapterCallContext, merchantId: string, input: IfoodShippingOrderInput, idempotencyKey: string): Promise<IfoodShippingCreateResult>;
|
|
468
|
+
type IfoodShippingReasonsResult = {
|
|
469
|
+
kind: "reasons";
|
|
470
|
+
reasons: OrderCancellationReason[];
|
|
471
|
+
}
|
|
472
|
+
/** 204: the order can no longer be cancelled (the courier left with it, or it is over). */
|
|
473
|
+
| {
|
|
474
|
+
kind: "not-cancellable";
|
|
475
|
+
} | IfoodShippingFailure;
|
|
476
|
+
/** `GET /shipping/v1.0/orders/{orderId}/cancellationReasons`: `[{cancelCodeId, description}]`, never hard-coded. */
|
|
477
|
+
declare function ifoodShippingCancellationReasons(ctx: AdapterCallContext, orderId: string): Promise<IfoodShippingReasonsResult>;
|
|
478
|
+
/**
|
|
479
|
+
* `POST /shipping/v1.0/orders/{orderId}/cancel {reason, cancellationCode}`:
|
|
480
|
+
* 202, then `CANCELLED` or `CANCELLATION_REQUEST_FAILED` (e.g. the courier
|
|
481
|
+
* already left) as an event.
|
|
482
|
+
*/
|
|
483
|
+
declare function ifoodShippingCancel(ctx: AdapterCallContext, orderId: string, input: {
|
|
484
|
+
code: string;
|
|
485
|
+
reason: string;
|
|
486
|
+
}, idempotencyKey: string): Promise<IfoodShippingRequested | IfoodShippingFailure>;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* The Shipping events iFood's stream carries (FUT-5667, FUT-5666), read off
|
|
490
|
+
* the `inside` and `outside` Shipping guides and the Order module's events page
|
|
491
|
+
* (https://developer.ifood.com.br/pt-BR/docs/food/guides/modules/order/events),
|
|
492
|
+
* 2026-12-04. The stream, its polling every 30 s, the acknowledgement and the
|
|
493
|
+
* deduplication by event id are the engine's existing ones; this only reads an
|
|
494
|
+
* event the host already has.
|
|
495
|
+
*
|
|
496
|
+
* `salesChannel` tells the two kinds apart: `POS` for an order placed off the
|
|
497
|
+
* platform, `IFOOD` for one placed on it. It is returned as it came; the host
|
|
498
|
+
* filters.
|
|
499
|
+
*
|
|
500
|
+
* `DELIVERY_DROP_CODE_REQUESTED` carries the customer's code in
|
|
501
|
+
* `metadata.CODE`; it is NOT read: the code stays on iFood's tracking page,
|
|
502
|
+
* and never reaches a result a log could print.
|
|
503
|
+
*/
|
|
504
|
+
/** The Shipping events that carry nothing past the order and the time. */
|
|
505
|
+
declare const IFOOD_SHIPPING_EVENT_TYPES: readonly ["REQUEST_DRIVER", "REQUEST_DRIVER_SUCCESS", "REQUEST_DRIVER_FAILED", "DELIVERY_DROP_CODE_REQUESTED", "DELIVERY_IN_TRANSIT", "DELIVERY_CONCLUDED", "DELIVERY_CANCELLED", "DELIVERY_CANCELLATION_REQUESTED", "DELIVERY_CANCELLATION_REQUEST_ACCEPTED", "DELIVERY_CANCELLATION_REQUEST_REJECTED", "CANCELLATION_REQUESTED", "CANCELLED", "DELIVERY_ADDRESS_CHANGE_USER_CONFIRMED", "DELIVERY_ADDRESS_CHANGE_ACCEPTED"];
|
|
506
|
+
type IfoodShippingEventType = (typeof IFOOD_SHIPPING_EVENT_TYPES)[number];
|
|
507
|
+
/** The address a change request names. */
|
|
508
|
+
interface IfoodShippingEventAddress {
|
|
509
|
+
streetName: string | null;
|
|
510
|
+
streetNumber: string | null;
|
|
511
|
+
complement: string | null;
|
|
512
|
+
reference: string | null;
|
|
513
|
+
neighborhood: string | null;
|
|
514
|
+
city: string | null;
|
|
515
|
+
state: string | null;
|
|
516
|
+
country: string | null;
|
|
517
|
+
latitude: number | null;
|
|
518
|
+
longitude: number | null;
|
|
519
|
+
}
|
|
520
|
+
interface EventBase {
|
|
521
|
+
eventId: string;
|
|
522
|
+
orderId: string;
|
|
523
|
+
salesChannel: string | null;
|
|
524
|
+
at: Date | null;
|
|
525
|
+
}
|
|
526
|
+
type IfoodShippingEvent = (EventBase & {
|
|
527
|
+
type: IfoodShippingEventType;
|
|
528
|
+
}) | (EventBase & {
|
|
529
|
+
type: "DELIVERY_ADDRESS_CHANGE_REQUESTED";
|
|
530
|
+
address: IfoodShippingEventAddress;
|
|
531
|
+
})
|
|
532
|
+
/**
|
|
533
|
+
* The order's cancel failed; `reason` is iFood's code from
|
|
534
|
+
* `metadata.CANCELLATION_REQUEST_FAILED_REASON` (e.g.
|
|
535
|
+
* `ACCOUNT_IS_NOT_LINKED_TO_THE_STORE`), a code, never customer data.
|
|
536
|
+
*/
|
|
537
|
+
| (EventBase & {
|
|
538
|
+
type: "CANCELLATION_REQUEST_FAILED";
|
|
539
|
+
reason: string | null;
|
|
540
|
+
})
|
|
541
|
+
/** `action` is `region-mismatch` when iFood denied it itself. */
|
|
542
|
+
| (EventBase & {
|
|
543
|
+
type: "DELIVERY_ADDRESS_CHANGE_DENIED";
|
|
544
|
+
action: string | null;
|
|
545
|
+
})
|
|
546
|
+
/** The `ASSIGN_DRIVER` family, read by the courier reader (FUT-5665). */
|
|
547
|
+
| (EventBase & {
|
|
548
|
+
type: "COURIER";
|
|
549
|
+
courier: NormalizedCourierEvent;
|
|
550
|
+
});
|
|
551
|
+
/** A Shipping event, or null for any other event, or one with no id or order. */
|
|
552
|
+
declare function readIfoodShippingEvent(payload: unknown): IfoodShippingEvent | null;
|
|
553
|
+
|
|
191
554
|
/**
|
|
192
555
|
* `@12-apps/marketplace/ifood` — iFood, as one adapter on the engine.
|
|
193
556
|
*
|
|
@@ -217,4 +580,4 @@ interface IfoodAdapterConfig {
|
|
|
217
580
|
*/
|
|
218
581
|
declare function createIfoodAdapter(config: IfoodAdapterConfig): MarketplaceAdapter;
|
|
219
582
|
|
|
220
|
-
export { IFOOD_APPS_PORTAL_URL, IFOOD_APP_LINKING, IFOOD_AVAILABILITY, IFOOD_CANCELLATION_ANSWER_WINDOW_MS, IFOOD_CATALOGUE, IFOOD_CATALOGUE_READER, IFOOD_COURIER, IFOOD_IMAGE_BASE_URL, IFOOD_LINKING, IFOOD_LOGISTICS, IFOOD_LOGISTICS_STEPS, IFOOD_LOGISTICS_VEHICLES, IFOOD_PROVIDER, IFOOD_REASON_CODES, type IfoodAdapterConfig, type IfoodAdapterCopy, type IfoodDeliveryCodeResult, type IfoodLogisticsDriver, type IfoodLogisticsInvalid, type IfoodLogisticsStep, type IfoodLogisticsVehicle, type IfoodReasonCode, createIfoodAdapter, ifoodAddressLine, ifoodFetchOrder, ifoodItemBody, ifoodItemId, ifoodLocalTime, ifoodLogisticsAssignDriver, ifoodLogisticsStep, ifoodLogisticsStepsTo, ifoodLogisticsVerifyDeliveryCode, ifoodPause, ifoodProductId, ifoodResume, normalizeIfoodEvent, readIfoodCourierEvent, readIfoodOrder, readIfoodPresence, verifyIfoodSignature };
|
|
583
|
+
export { IFOOD_APPS_PORTAL_URL, IFOOD_APP_LINKING, IFOOD_AVAILABILITY, IFOOD_CANCELLATION_ANSWER_WINDOW_MS, IFOOD_CATALOGUE, IFOOD_CATALOGUE_READER, IFOOD_COURIER, IFOOD_IMAGE_BASE_URL, IFOOD_LINKING, IFOOD_LOGISTICS, IFOOD_LOGISTICS_STEPS, IFOOD_LOGISTICS_VEHICLES, IFOOD_PROVIDER, IFOOD_REASON_CODES, IFOOD_SHIPPING_ADDRESS_CHANGE_MAX_METERS, IFOOD_SHIPPING_API, IFOOD_SHIPPING_ERROR_CODES, IFOOD_SHIPPING_EVENT_TYPES, IFOOD_SHIPPING_TOKEN_REFRESH_AHEAD_MS, type IfoodAdapterConfig, type IfoodAdapterCopy, type IfoodAddressChangeResult, type IfoodDeliveryCodeResult, type IfoodLogisticsDriver, type IfoodLogisticsInvalid, type IfoodLogisticsStep, type IfoodLogisticsVehicle, type IfoodReasonCode, type IfoodSafeDeliveryResult, type IfoodSafeDeliveryScore, type IfoodShippingAddress, type IfoodShippingCreateResult, type IfoodShippingErrorCode, type IfoodShippingEvent, type IfoodShippingEventAddress, type IfoodShippingEventType, type IfoodShippingFailure, type IfoodShippingInvalid, type IfoodShippingItem, type IfoodShippingOrderInput, type IfoodShippingPaymentMethod, type IfoodShippingQuote, type IfoodShippingQuoteRef, type IfoodShippingQuoteResult, type IfoodShippingReasonsResult, type IfoodShippingRequested, type IfoodShippingTrackingResult, createIfoodAdapter, ifoodAddressLine, ifoodCancelRequestDriver, ifoodFetchOrder, ifoodItemBody, ifoodItemId, ifoodLocalTime, ifoodLogisticsAssignDriver, ifoodLogisticsStep, ifoodLogisticsStepsTo, ifoodLogisticsVerifyDeliveryCode, ifoodPause, ifoodProductId, ifoodRequestDriver, ifoodResume, ifoodShippingAcceptAddressChange, ifoodShippingCancel, ifoodShippingCancellationReasons, ifoodShippingConfirmAddress, ifoodShippingCreateOrder, ifoodShippingDenyAddressChange, ifoodShippingQuoteForAddress, ifoodShippingQuoteForOrder, ifoodShippingRequestAddressChange, ifoodShippingRetryDelayMs, ifoodShippingSafeDelivery, ifoodShippingTracking, normalizeIfoodEvent, readIfoodCourierEvent, readIfoodOrder, readIfoodPresence, readIfoodShippingEvent, verifyIfoodSignature };
|