@12-apps/marketplace 1.8.0 → 1.10.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 +27 -1
- package/README.md +103 -9
- package/dist/99food/index.d.ts +30 -54
- package/dist/99food/index.js +60 -418
- package/dist/99food/index.js.map +1 -1
- package/dist/{chunk-BMCERPQX.js → chunk-2BA2EHNF.js} +16 -6
- package/dist/chunk-2BA2EHNF.js.map +1 -0
- package/dist/chunk-PYHNM47K.js +478 -0
- package/dist/chunk-PYHNM47K.js.map +1 -0
- package/dist/{chunk-6N2HEV3U.js → chunk-WVZ2IXFH.js} +3 -3
- package/dist/{chunk-NP4EYKPO.js → chunk-ZO4S3LF4.js} +5 -3
- package/dist/chunk-ZO4S3LF4.js.map +1 -0
- package/dist/client-B4EQCRD_.d.ts +20 -0
- package/dist/{engine-wmW-VuBL.d.ts → engine-DK3iV_Kk.d.ts} +91 -60
- package/dist/hono/index.d.ts +1 -1
- package/dist/hono/index.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -6
- 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 +4 -1
- package/dist/manifest/index.js +1 -1
- package/dist/manifest/server.d.ts +1 -1
- package/dist/manifest/server.js +3 -3
- package/dist/server/index.d.ts +6 -2
- package/dist/server/index.js +3 -3
- package/package.json +14 -2
- package/prisma/marketplace.prisma +6 -0
- package/prisma/migrations/20261126230000_marketplace_menu_link_variation/migration.sql +11 -0
- package/src/99food/catalogue.ts +19 -89
- package/src/99food/copy.ts +4 -19
- package/src/99food/index.ts +28 -33
- package/src/99food/normalize.ts +11 -253
- package/src/99food/outbound.ts +29 -270
- package/src/99food/pause.ts +7 -22
- package/src/core/bulk.ts +34 -7
- package/src/core/ingest.ts +2 -1
- package/src/core/menu-links.ts +36 -6
- package/src/core/order-types.ts +74 -0
- package/src/core/ports.ts +23 -65
- package/src/index.ts +2 -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/server/mcp.ts +7 -2
- package/dist/chunk-BMCERPQX.js.map +0 -1
- package/dist/chunk-NP4EYKPO.js.map +0 -1
- /package/dist/{chunk-6N2HEV3U.js.map → chunk-WVZ2IXFH.js.map} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The Keeta adapter's en-US pack: the same reasons, in English. */
|
|
2
|
+
declare const KEETA_ADAPTER_COPY_EN_US: {
|
|
3
|
+
readonly reasonLabels: {
|
|
4
|
+
readonly SYSTEMIC_ISSUES: "System problems";
|
|
5
|
+
readonly DUPLICATE_APPLICATION: "Duplicate order";
|
|
6
|
+
readonly UNAVAILABLE_ITEM: "Item unavailable";
|
|
7
|
+
readonly RESTAURANT_WITHOUT_DELIVERY_PERSON: "No courier available";
|
|
8
|
+
readonly OUTDATED_MENU: "Menu out of date";
|
|
9
|
+
readonly ORDER_OUTSIDE_THE_DELIVERY_AREA: "Outside the delivery area";
|
|
10
|
+
readonly BLOCKED_CUSTOMER: "Blocked customer";
|
|
11
|
+
readonly OUTSIDE_DELIVERY_HOURS: "Outside delivery hours";
|
|
12
|
+
readonly INTERNAL_DIFFICULTIES_OF_THE_RESTAURANT: "Internal difficulties";
|
|
13
|
+
readonly RISK_AREA: "Risk area";
|
|
14
|
+
readonly DELIVERY_PROBLEM: "Delivery problem";
|
|
15
|
+
};
|
|
16
|
+
readonly missingStreetNumber: "no number";
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { KEETA_ADAPTER_COPY_EN_US };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "../chunk-7QVYU63E.js";
|
|
2
|
+
|
|
3
|
+
// src/keeta/en-US.ts
|
|
4
|
+
var KEETA_ADAPTER_COPY_EN_US = {
|
|
5
|
+
reasonLabels: {
|
|
6
|
+
SYSTEMIC_ISSUES: "System problems",
|
|
7
|
+
DUPLICATE_APPLICATION: "Duplicate order",
|
|
8
|
+
UNAVAILABLE_ITEM: "Item unavailable",
|
|
9
|
+
RESTAURANT_WITHOUT_DELIVERY_PERSON: "No courier available",
|
|
10
|
+
OUTDATED_MENU: "Menu out of date",
|
|
11
|
+
ORDER_OUTSIDE_THE_DELIVERY_AREA: "Outside the delivery area",
|
|
12
|
+
BLOCKED_CUSTOMER: "Blocked customer",
|
|
13
|
+
OUTSIDE_DELIVERY_HOURS: "Outside delivery hours",
|
|
14
|
+
INTERNAL_DIFFICULTIES_OF_THE_RESTAURANT: "Internal difficulties",
|
|
15
|
+
RISK_AREA: "Risk area",
|
|
16
|
+
DELIVERY_PROBLEM: "Delivery problem"
|
|
17
|
+
},
|
|
18
|
+
missingStreetNumber: "no number"
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
KEETA_ADAPTER_COPY_EN_US
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=en-US.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/keeta/en-US.ts"],"sourcesContent":["import type { KeetaAdapterCopy } from \"./copy\";\n\n/** The Keeta adapter's en-US pack: the same reasons, in English. */\nexport const KEETA_ADAPTER_COPY_EN_US = {\n reasonLabels: {\n SYSTEMIC_ISSUES: \"System problems\",\n DUPLICATE_APPLICATION: \"Duplicate order\",\n UNAVAILABLE_ITEM: \"Item unavailable\",\n RESTAURANT_WITHOUT_DELIVERY_PERSON: \"No courier available\",\n OUTDATED_MENU: \"Menu out of date\",\n ORDER_OUTSIDE_THE_DELIVERY_AREA: \"Outside the delivery area\",\n BLOCKED_CUSTOMER: \"Blocked customer\",\n OUTSIDE_DELIVERY_HOURS: \"Outside delivery hours\",\n INTERNAL_DIFFICULTIES_OF_THE_RESTAURANT: \"Internal difficulties\",\n RISK_AREA: \"Risk area\",\n DELIVERY_PROBLEM: \"Delivery problem\",\n },\n missingStreetNumber: \"no number\",\n} as const satisfies KeetaAdapterCopy;\n"],"mappings":";;;AAGO,IAAM,2BAA2B;AAAA,EACtC,cAAc;AAAA,IACZ,iBAAiB;AAAA,IACjB,uBAAuB;AAAA,IACvB,kBAAkB;AAAA,IAClB,oCAAoC;AAAA,IACpC,eAAe;AAAA,IACf,iCAAiC;AAAA,IACjC,kBAAkB;AAAA,IAClB,wBAAwB;AAAA,IACxB,yCAAyC;AAAA,IACzC,WAAW;AAAA,IACX,kBAAkB;AAAA,EACpB;AAAA,EACA,qBAAqB;AACvB;","names":[]}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { A as AdapterCallContext, N as NormalizedEvent, a as NormalizedMarketplaceOrder, c as MarketplaceAdapter } from '../adapter-CYJzu1c9.js';
|
|
2
|
+
import { a as OpenDeliveryStop, O as OpenDeliveryApiBaseUrls } from '../client-B4EQCRD_.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Keeta's MERCHANT AUTHORIZATION, automated from the software (Keeta's
|
|
6
|
+
* "Autorização Self-serve do Merchant", read 2026-11-26 at
|
|
7
|
+
* https://api-docs.mykeeta.com/apis/opendelivery/merchant-self-serve-authorization).
|
|
8
|
+
* Not on the adapter port: connecting a store is the host's flow, and these
|
|
9
|
+
* are the calls it is built from.
|
|
10
|
+
*
|
|
11
|
+
* 1. {@link KeetaAuthorization.authorizationUrl}: `GET
|
|
12
|
+
* /oauth/authorization/url?clientId=&redirectUri=` (no token: a token
|
|
13
|
+
* needs at least one authorized store), the link the merchant opens.
|
|
14
|
+
* 2. The merchant authorizes; Keeta redirects to `redirectUri` with `authId`
|
|
15
|
+
* (and `state`, `appId`, `timestamp`), and POSTs the authorization webhook
|
|
16
|
+
* ({@link normalizeKeetaAuthorizationEvent}: `opType` 1 added, 2 revoked).
|
|
17
|
+
* 3. {@link KeetaAuthorization.authorizedShops}: `GET
|
|
18
|
+
* /oauth/authorized/{authId}/merchantInfo?pageNum=&pageSize=` lists the
|
|
19
|
+
* stores of that authorization (Keeta's ids, names, addresses, time zones).
|
|
20
|
+
* 4. The host maps a Keeta store to its own, then
|
|
21
|
+
* {@link KeetaAuthorization.onboard}: `PUT /v1/merchantOnboarding?merchantId=`
|
|
22
|
+
* binds the SOFTWARE's merchant id (the connection's `externalMerchantId`)
|
|
23
|
+
* to `keetaMerchantId` and registers the `GET /v1/merchant` URL and the
|
|
24
|
+
* orders webhook. "Without onboarding there are no order events"; sending
|
|
25
|
+
* it again for the same id REPLACES the mapping. Answer 201.
|
|
26
|
+
*
|
|
27
|
+
* ESTIMATED: the JSON answer the authorization webhook wants ("200 within
|
|
28
|
+
* ~5 s, with JSON containing `code` and `message`": the values are not
|
|
29
|
+
* given, {@link KEETA_AUTHORIZATION_WEBHOOK_ANSWER} sends 0 and "success").
|
|
30
|
+
*/
|
|
31
|
+
/** What the authorization webhook is answered with, 200, within ~5 s. ESTIMATED values. */
|
|
32
|
+
declare const KEETA_AUTHORIZATION_WEBHOOK_ANSWER: {
|
|
33
|
+
readonly code: 0;
|
|
34
|
+
readonly message: "success";
|
|
35
|
+
};
|
|
36
|
+
/** One authorization change Keeta reported (event 1301 added, 1302 revoked). */
|
|
37
|
+
interface KeetaAuthorizationEvent {
|
|
38
|
+
authId: string;
|
|
39
|
+
change: "AUTHORIZED" | "REVOKED";
|
|
40
|
+
/** Keeta's store id (an integer on the wire, text here). */
|
|
41
|
+
shopId: string;
|
|
42
|
+
shopName: string | null;
|
|
43
|
+
/** The application's id. */
|
|
44
|
+
clientId: string | null;
|
|
45
|
+
at: Date | null;
|
|
46
|
+
}
|
|
47
|
+
/** Read the authorization webhook's body (`WebhookNotification`). Null when it names no authorization or store. */
|
|
48
|
+
declare function normalizeKeetaAuthorizationEvent(payload: unknown): KeetaAuthorizationEvent | null;
|
|
49
|
+
/** One store of an authorization, as `merchantInfo` lists it. */
|
|
50
|
+
interface KeetaAuthorizedShop {
|
|
51
|
+
/** Keeta's store id: the `keetaMerchantId` the onboarding takes. */
|
|
52
|
+
id: string;
|
|
53
|
+
name: string | null;
|
|
54
|
+
address: string | null;
|
|
55
|
+
latitude: number | null;
|
|
56
|
+
longitude: number | null;
|
|
57
|
+
timeZone: string | null;
|
|
58
|
+
}
|
|
59
|
+
/** One page of an authorization's stores. */
|
|
60
|
+
interface KeetaAuthorizedShops {
|
|
61
|
+
brandId: string | null;
|
|
62
|
+
brandName: string | null;
|
|
63
|
+
shops: KeetaAuthorizedShop[];
|
|
64
|
+
page: {
|
|
65
|
+
pageNum: number;
|
|
66
|
+
totalPage: number;
|
|
67
|
+
totalCount: number;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** What the host registers for one store at onboarding. */
|
|
71
|
+
interface KeetaOnboarding {
|
|
72
|
+
/** The SOFTWARE's merchant id: the connection's `externalMerchantId`, the `Merchant.id` the host serves. */
|
|
73
|
+
merchantId: string;
|
|
74
|
+
/** Keeta's store id, from `authorizedShops` or Keeta's portal. */
|
|
75
|
+
keetaMerchantId: number;
|
|
76
|
+
/** Where Keeta reads this store's `GET /v1/merchant` (one URL per store), and its key if it wants one. */
|
|
77
|
+
merchantDocument?: {
|
|
78
|
+
url: string;
|
|
79
|
+
apiKey?: string;
|
|
80
|
+
};
|
|
81
|
+
/** The engine's webhook for this store: `…/webhooks/marketplace/:tenantSlug/KEETA`. */
|
|
82
|
+
ordersWebhookUrl?: string;
|
|
83
|
+
}
|
|
84
|
+
type KeetaAuthorizationResult<T> = {
|
|
85
|
+
kind: "ok";
|
|
86
|
+
value: T;
|
|
87
|
+
} | OpenDeliveryStop;
|
|
88
|
+
/** The self-serve authorization calls, bound to Keeta's dialect. */
|
|
89
|
+
interface KeetaAuthorization {
|
|
90
|
+
authorizationUrl(ctx: AdapterCallContext, input: {
|
|
91
|
+
redirectUri?: string;
|
|
92
|
+
}): Promise<KeetaAuthorizationResult<string>>;
|
|
93
|
+
authorizedShops(ctx: AdapterCallContext, input: {
|
|
94
|
+
authId: string;
|
|
95
|
+
pageNum?: number;
|
|
96
|
+
pageSize?: number;
|
|
97
|
+
}): Promise<KeetaAuthorizationResult<KeetaAuthorizedShops>>;
|
|
98
|
+
onboard(ctx: AdapterCallContext, input: KeetaOnboarding): Promise<KeetaAuthorizationResult<true>>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The words the Keeta adapter needs from its host, and nothing else.
|
|
103
|
+
*
|
|
104
|
+
* Required and defaultless, like every copy port in this repo: the adapter
|
|
105
|
+
* ships no language of its own. Two packs sit beside it (`./pt-BR`,
|
|
106
|
+
* `./en-US`); a host passes one by hand, or its own.
|
|
107
|
+
*/
|
|
108
|
+
/**
|
|
109
|
+
* The cancellation codes a merchant may send: Keeta's "códigos de
|
|
110
|
+
* cancelamento (v1.0.7+)", the same eleven as Open Delivery's
|
|
111
|
+
* (`../open-delivery/reasons.ts`). Keeta still accepts its legacy codes
|
|
112
|
+
* (`INSUFFICIENT_DISHES`, `SUSPENSION_OF_BUSINESS`, `INSUFFICIENT_MANPOWER`,
|
|
113
|
+
* `OTHERS`) and recommends the new ones, so only the new ones are offered.
|
|
114
|
+
*/
|
|
115
|
+
declare const KEETA_REASON_CODES: readonly ["SYSTEMIC_ISSUES", "DUPLICATE_APPLICATION", "UNAVAILABLE_ITEM", "RESTAURANT_WITHOUT_DELIVERY_PERSON", "OUTDATED_MENU", "ORDER_OUTSIDE_THE_DELIVERY_AREA", "BLOCKED_CUSTOMER", "OUTSIDE_DELIVERY_HOURS", "INTERNAL_DIFFICULTIES_OF_THE_RESTAURANT", "RISK_AREA", "DELIVERY_PROBLEM"];
|
|
116
|
+
type KeetaReasonCode = (typeof KEETA_REASON_CODES)[number];
|
|
117
|
+
interface KeetaAdapterCopy {
|
|
118
|
+
/** One label per reason code. Sent as the request's `reason` text when the store wrote none. */
|
|
119
|
+
reasonLabels: Readonly<Record<KeetaReasonCode, string>>;
|
|
120
|
+
/** What an address with no street number (or an encrypted one Keeta would not reveal) says instead. */
|
|
121
|
+
missingStreetNumber: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Keeta's Open Delivery DIALECT. Keeta follows Open Delivery v1.5.0 with
|
|
126
|
+
* changes of its own, and "the definitions of this document prevail"
|
|
127
|
+
* (https://api-docs.mykeeta.com/apis/opendelivery/general-info, read
|
|
128
|
+
* 2026-11-26). The calls are `../open-delivery/`'s; this file says how Keeta
|
|
129
|
+
* takes them:
|
|
130
|
+
*
|
|
131
|
+
* - Token: `POST /oauth/token` with a JSON body `{ client_id, client_secret,
|
|
132
|
+
* grant_type: "app_level_token" }` (v1.0.9's name for the standard's
|
|
133
|
+
* `client_credentials`, which stays accepted for integrations already
|
|
134
|
+
* certified). The token is the APPLICATION's: one for every store that
|
|
135
|
+
* authorized it, so the cache key (provider, environment, client id) is
|
|
136
|
+
* right as it is. Answer `{ access_token, token_type, expires_in }`; no
|
|
137
|
+
* refresh token in this mode.
|
|
138
|
+
* - Every request, the grant included, carries `X-App-Signature`
|
|
139
|
+
* (`./signature.ts`), and every JSON body is RFC 8785 canonical.
|
|
140
|
+
*/
|
|
141
|
+
/** Where Keeta serves Open Delivery, per environment. */
|
|
142
|
+
type KeetaApiBaseUrls = OpenDeliveryApiBaseUrls;
|
|
143
|
+
/**
|
|
144
|
+
* The documented server (`servers[0]` of Keeta's `openapi.json`). ESTIMATED
|
|
145
|
+
* for SANDBOX: Keeta documents one host, and a test application (its own
|
|
146
|
+
* client id and secret, its test stores) is what makes a session a test one.
|
|
147
|
+
*/
|
|
148
|
+
declare const KEETA_API_BASE_URL = "https://open.mykeeta.com/api/open/opendelivery";
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The Keeta adapter's INBOUND half: Open Delivery's readers
|
|
152
|
+
* (`../open-delivery/normalize.ts`) stamped with Keeta's provider id, plus
|
|
153
|
+
* the one thing Keeta's `Order` does that the standard's does not: personal
|
|
154
|
+
* data arrives ENCRYPTED.
|
|
155
|
+
*
|
|
156
|
+
* Events (Keeta's order guide, read 2026-11-26): `CREATED` → fetch;
|
|
157
|
+
* `CANCELLED` (with a JSON-string `metadata` carrying `reason` and `code`) →
|
|
158
|
+
* cancelled; `DISPATCHED`, `CONCLUDED` → lifecycle. Keeta has NO
|
|
159
|
+
* `CANCELLATION_REQUEST_DENIED`: a store's request that Keeta does not grant
|
|
160
|
+
* produces no event, so it ends TIMEOUT at the adapter's answer window. The
|
|
161
|
+
* rest (`CONFIRMED`, `READY_FOR_PICKUP`, `PICKUP_ONGOING`,
|
|
162
|
+
* `RIDER_ARRIVED_AT_STORE`, `ORDER_COLLECTED`, `DELIVERED`,
|
|
163
|
+
* `CANCELLATION_REQUESTED`, `USER_REFUND_REQUEST`, `REFUNDED`,
|
|
164
|
+
* `REFUND_FAILED`, `RECOMMENDED_PREPARATION_START`) are recorded and IGNORED.
|
|
165
|
+
*/
|
|
166
|
+
/** The provider id Keeta is registered under. Uppercase: the column's CHECK holds that shape. */
|
|
167
|
+
declare const KEETA_PROVIDER = "KEETA";
|
|
168
|
+
/** Normalize one webhook `Event`. Null only when it names no order. */
|
|
169
|
+
declare function normalizeKeetaEvent(payload: unknown): NormalizedEvent | null;
|
|
170
|
+
/** Normalize one `Order`, after {@link revealKeetaOrder}. Null when it carries no id or no line. */
|
|
171
|
+
declare function normalizeKeetaOrder(order: unknown, options: {
|
|
172
|
+
missingStreetNumber: string;
|
|
173
|
+
}): NormalizedMarketplaceOrder | null;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Keeta's `X-App-Signature`, both directions (read 2026-11-26 at
|
|
177
|
+
* https://api-docs.mykeeta.com/apis/opendelivery/signature-calculation and its
|
|
178
|
+
* three sub-pages, and the `newEvent` and webhook guide pages).
|
|
179
|
+
*
|
|
180
|
+
* OUTBOUND — every request the software sends Keeta, the token grant
|
|
181
|
+
* included, carries it (Keeta's change to Open Delivery: a token alone is not
|
|
182
|
+
* enough, so an intercepted token cannot be replayed):
|
|
183
|
+
*
|
|
184
|
+
* - the string is the URL without its query, then `&key=value` for each
|
|
185
|
+
* query parameter sorted by key (a null value is `key=`), then `&` and the
|
|
186
|
+
* body when there is one: an empty body, a blank one or `{}` is left out,
|
|
187
|
+
* and so is its `&`;
|
|
188
|
+
* - the body is compact JSON canonicalized by RFC 8785 (JCS), and the SAME
|
|
189
|
+
* string is sent;
|
|
190
|
+
* - HMAC-SHA256 of the string (UTF-8), keyed by the application's
|
|
191
|
+
* `client_secret`, encoded Base64.
|
|
192
|
+
*
|
|
193
|
+
* INBOUND — a webhook Keeta sends (`POST /v1/newEvent`, and the
|
|
194
|
+
* authorization webhook) is signed "HMAC-SHA256 of the body, with the
|
|
195
|
+
* client_secret as key, in Base64".
|
|
196
|
+
*
|
|
197
|
+
* ESTIMATED:
|
|
198
|
+
* - query values are signed DECODED (the reference implementations take them
|
|
199
|
+
* from a map, before any URL encoding); only the self-serve authorization
|
|
200
|
+
* calls send a query, and only `redirectUri` can hold a character encoding
|
|
201
|
+
* changes;
|
|
202
|
+
* - the inbound signature covers the raw body bytes as received, with no URL
|
|
203
|
+
* prefix (the pages say "the body");
|
|
204
|
+
* - the authorization webhook's header uses the same Base64 HMAC (its schema
|
|
205
|
+
* says only "SHA256 hash of the request body, using the client secret as the
|
|
206
|
+
* key").
|
|
207
|
+
*/
|
|
208
|
+
/**
|
|
209
|
+
* RFC 8785 (JCS) for the JSON this adapter sends: object keys sorted by
|
|
210
|
+
* UTF-16 code units, no whitespace, strings and numbers as ECMAScript's
|
|
211
|
+
* `JSON.stringify` writes them (which is what JCS specifies). `undefined`
|
|
212
|
+
* members are dropped, as `JSON.stringify` drops them.
|
|
213
|
+
*/
|
|
214
|
+
declare function canonicalJson(value: unknown): string;
|
|
215
|
+
/** The `X-App-Signature` of one outbound request. */
|
|
216
|
+
declare function keetaRequestSignature(url: string, body: string | undefined, clientSecret: string): string;
|
|
217
|
+
/**
|
|
218
|
+
* Verify a webhook Keeta sent: Base64 HMAC-SHA256 of the raw body, keyed by
|
|
219
|
+
* the application's client secret, which a connection stores as its webhook
|
|
220
|
+
* secret. The key exists from the moment the store connects, so an unset
|
|
221
|
+
* secret REFUSES: an unsigned CANCELLED for a known order id would otherwise
|
|
222
|
+
* cancel it. Compared in constant time.
|
|
223
|
+
*/
|
|
224
|
+
declare function verifyKeetaSignature(rawBody: string, signature: string | null, webhookSecret: string | null): boolean;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* How long Keeta may take to answer a cancellation request. ESTIMATED: Keeta
|
|
228
|
+
* names none, and sends no event for a refusal, so past this the request is
|
|
229
|
+
* failed as TIMEOUT. Keeta's own clock is 5 minutes for the acceptance.
|
|
230
|
+
*/
|
|
231
|
+
declare const KEETA_CANCELLATION_ANSWER_WINDOW_MS: number;
|
|
232
|
+
/** Where "open it on Keeta" goes by default: the Merchant Portal (Keeta names no per-order link). */
|
|
233
|
+
declare const KEETA_PORTAL_URL = "https://merchant.mykeeta.com/";
|
|
234
|
+
interface KeetaAdapterConfig {
|
|
235
|
+
/** The words the adapter needs: reason labels and the missing-number text. Required. */
|
|
236
|
+
copy: KeetaAdapterCopy;
|
|
237
|
+
/** OPTIONAL. Where Keeta serves Open Delivery, per environment. Default: the documented server for both. https only. */
|
|
238
|
+
apiBaseUrl?: KeetaApiBaseUrls;
|
|
239
|
+
/** OPTIONAL. Where "open it on Keeta" goes. Default: the Merchant Portal. https only. */
|
|
240
|
+
portalUrl?: string;
|
|
241
|
+
/**
|
|
242
|
+
* OPTIONAL, off by default. Offer the store pause (FUT-4851) through
|
|
243
|
+
* `merchantStatus`, a store-wide switch with no id: a store the owner also
|
|
244
|
+
* closed by hand on Keeta during the kitchen's pause is opened with it.
|
|
245
|
+
*/
|
|
246
|
+
pauseByStoreSwitch?: boolean;
|
|
247
|
+
}
|
|
248
|
+
/** Build the Keeta adapter. Its reasons are static: a dialog never waits on Keeta. */
|
|
249
|
+
declare function createKeetaAdapter(config: KeetaAdapterConfig): MarketplaceAdapter;
|
|
250
|
+
/** The self-serve merchant authorization calls (`./authorization.ts`), for the same base URLs as the adapter. */
|
|
251
|
+
declare function createKeetaAuthorization(config?: Pick<KeetaAdapterConfig, "apiBaseUrl">): KeetaAuthorization;
|
|
252
|
+
|
|
253
|
+
export { KEETA_API_BASE_URL, KEETA_AUTHORIZATION_WEBHOOK_ANSWER, KEETA_CANCELLATION_ANSWER_WINDOW_MS, KEETA_PORTAL_URL, KEETA_PROVIDER, KEETA_REASON_CODES, type KeetaAdapterConfig, type KeetaAdapterCopy, type KeetaApiBaseUrls, type KeetaAuthorization, type KeetaAuthorizationEvent, type KeetaAuthorizationResult, type KeetaAuthorizedShop, type KeetaAuthorizedShops, type KeetaOnboarding, type KeetaReasonCode, canonicalJson, createKeetaAdapter, createKeetaAuthorization, keetaRequestSignature, normalizeKeetaAuthorizationEvent, normalizeKeetaEvent, normalizeKeetaOrder, verifyKeetaSignature };
|