@zappie/verify 0.0.0-stage → 0.1.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/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +55 -2
- package/dist/category-page-UBHOB5IN.js +21 -0
- package/dist/category-page-UBHOB5IN.js.map +1 -0
- package/dist/chunk-WUWUDCYO.js +485 -0
- package/dist/chunk-WUWUDCYO.js.map +1 -0
- package/dist/debug-C3UDGUED.js +78 -0
- package/dist/debug-C3UDGUED.js.map +1 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +4049 -0
- package/dist/index.js.map +1 -0
- package/dist/quote-client-6XJJHITL.js +253 -0
- package/dist/quote-client-6XJJHITL.js.map +1 -0
- package/dist/search-YIHT6CXN.js +32 -0
- package/dist/search-YIHT6CXN.js.map +1 -0
- package/dist/selected-menu-3GCAICBQ.js +79 -0
- package/dist/selected-menu-3GCAICBQ.js.map +1 -0
- package/dist/store-KIO5RCZO.js +120 -0
- package/dist/store-KIO5RCZO.js.map +1 -0
- package/package.json +49 -3
- package/schema/verify-report.v1.json +104 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../sdk/src/errors.ts","../../sdk/src/internal/digest.ts","../../sdk/src/money.ts","../../sdk/src/internal/money-math.ts","../../sdk/src/transport/mappers.ts"],"sourcesContent":["/** Stable public error codes. */\nexport type ZappieErrorCode =\n | \"network_error\"\n | \"timeout\"\n | \"rate_limited\"\n | \"unauthorized\"\n | \"forbidden_origin\"\n | \"not_found\"\n | \"store_not_found\"\n | \"branch_not_found\"\n | \"item_not_found\"\n | \"cart_invalid\"\n | \"invalid_request\"\n | \"version_unsupported\"\n | \"server_error\";\nconst codes: readonly string[] = [\n \"network_error\",\n \"timeout\",\n \"rate_limited\",\n \"unauthorized\",\n \"forbidden_origin\",\n \"not_found\",\n \"store_not_found\",\n \"branch_not_found\",\n \"item_not_found\",\n \"cart_invalid\",\n \"invalid_request\",\n \"version_unsupported\",\n \"server_error\",\n];\n/** Context attached to an SDK failure. */\nexport type ErrorDetails = {\n status?: number;\n param?: string;\n docUrl?: string;\n requestId?: string;\n retryable?: boolean;\n cause?: unknown;\n};\n/** An SDK error you can handle by its stable code. */\nexport class ZappieError extends Error {\n readonly status?: number;\n readonly param?: string;\n readonly docUrl: string;\n readonly requestId?: string;\n readonly retryable: boolean;\n constructor(\n readonly code: ZappieErrorCode,\n message: string,\n details: ErrorDetails = {},\n ) {\n super(message, { cause: details.cause });\n this.name = \"ZappieError\";\n if (details.status !== undefined) {\n this.status = details.status;\n }\n if (details.param !== undefined) {\n this.param = details.param;\n }\n if (details.requestId !== undefined) {\n this.requestId = details.requestId;\n }\n this.docUrl = details.docUrl ?? `https://docs.zappie.ai/errors#${code}`;\n this.retryable =\n details.retryable ??\n [\"network_error\", \"timeout\", \"rate_limited\", \"server_error\"].includes(\n code,\n );\n }\n}\n/** Check whether a thrown value is a ZappieError. */\nexport function isZappieError(error: unknown): error is ZappieError {\n return error instanceof ZappieError;\n}\nexport function asError(error: unknown): ZappieError {\n return isZappieError(error)\n ? error\n : new ZappieError(\"network_error\", \"The storefront request failed\", {\n cause: error,\n });\n}\nexport function wireError(\n value: unknown,\n status: number,\n requestId?: string,\n): ZappieError {\n const envelope =\n value && typeof value === \"object\"\n ? (value as Record<string, unknown>)\n : {};\n const e =\n envelope.error && typeof envelope.error === \"object\"\n ? (envelope.error as Record<string, unknown>)\n : {};\n const fallback =\n status === 401\n ? \"unauthorized\"\n : status === 403\n ? \"forbidden_origin\"\n : status === 404\n ? \"not_found\"\n : status === 429\n ? \"rate_limited\"\n : status >= 500\n ? \"server_error\"\n : \"invalid_request\";\n const known = typeof e.code === \"string\" && codes.includes(e.code);\n const code = known\n ? (e.code as ZappieErrorCode)\n : e.code\n ? \"server_error\"\n : fallback;\n const message =\n typeof e.message === \"string\" ? e.message : \"The storefront request failed\";\n return new ZappieError(\n code,\n !known && e.code ? `${String(e.code)}: ${message}` : message,\n {\n status,\n ...(requestId ? { requestId } : {}),\n ...(typeof e.param === \"string\" ? { param: e.param } : {}),\n ...(typeof e.doc_url === \"string\" ? { docUrl: e.doc_url } : {}),\n },\n );\n}\n","/** Payload digests avoid putting notes, addresses or credentials in request headers. */\nexport async function payloadKey(payload: string): Promise<string> {\n const digest = await globalThis.crypto.subtle.digest(\n \"SHA-256\",\n new TextEncoder().encode(payload),\n );\n return Array.from(new Uint8Array(digest), (byte) =>\n byte.toString(16).padStart(2, \"0\"),\n ).join(\"\");\n}\n","import { ZappieError } from \"./errors\";\ndeclare const MoneyBrand: unique symbol;\n/** A normalized ISO 4217 currency code. */\nexport type Currency = string;\n// Minor-unit digits match the API, which scales amount_minor with\n// github.com/bojanz/currency v1.2.0 (pkg/currency.Digits). Intl differs for COP,\n// HUF, IDR, PKR and RSD, so it only presents the amount. Unlisted codes use 2.\nconst ZERO_DIGIT_CURRENCIES =\n \" AFN ALL BIF CLP DJF GNF IQD IRR ISK JPY KMF KPW KRW LAK LBP MGA MMK PYG RSD RWF SLL SOS SYP UGX UYI VND VUV XAF XOF XPF YER \";\nconst THREE_DIGIT_CURRENCIES = \" BHD JOD KWD LYD OMR TND \";\nconst FOUR_DIGIT_CURRENCIES = \" CLF UYW \";\n// API codes that Intl.supportedValuesOf(\"currency\") doesn't list.\nconst API_ONLY_CURRENCIES = \" BOV CHE CHW CLF COU MXV USN UYI UYW VED \";\nconst contains = (codes: string, currency: string) =>\n codes.includes(` ${currency} `);\nlet intlCurrencies: Set<string> | undefined;\nfunction isCurrency(code: string): boolean {\n if (!/^[A-Z]{3}$/.test(code)) {\n return false;\n }\n if (typeof Intl.supportedValuesOf !== \"function\") {\n return true;\n }\n intlCurrencies ??= new Set(Intl.supportedValuesOf(\"currency\"));\n return contains(API_ONLY_CURRENCIES, code) || intlCurrencies.has(code);\n}\nfunction currencyDigits(currency: Currency): number {\n if (contains(ZERO_DIGIT_CURRENCIES, currency)) {\n return 0;\n }\n if (contains(THREE_DIGIT_CURRENCIES, currency)) {\n return 3;\n }\n return contains(FOUR_DIGIT_CURRENCIES, currency) ? 4 : 2;\n}\n/** A frozen amount in safe integer minor units. Create it with money(). */\nexport type Money = {\n readonly amountMinor: number;\n readonly currency: Currency;\n readonly [MoneyBrand]: true;\n};\n/** Validate an amount in minor units and freeze it without rounding. */\nexport function money(amountMinor: number, currency: Currency): Money {\n const normalized =\n typeof currency === \"string\" ? currency.trim().toUpperCase() : \"\";\n if (!Number.isSafeInteger(amountMinor) || !isCurrency(normalized)) {\n throw new ZappieError(\n \"invalid_request\",\n \"Money requires safe integer minor units and a valid ISO 4217 currency\",\n );\n }\n return Object.freeze({ amountMinor, currency: normalized }) as Money;\n}\n/** Currency presentation options. */\nexport type MoneyFormatOptions = {\n showZeroDecimals?: boolean;\n compact?: boolean;\n sign?: \"auto\" | \"always\";\n};\n/** Format amounts for display. Use server quotes for final prices. */\nexport interface Formatters {\n money(value: Money, opts?: MoneyFormatOptions): string;\n}\n/** Format money with currency-specific minor units and locale defaults. */\nexport const format: Formatters = {\n money(value, opts = {}) {\n const normalized = money(value.amountMinor, value.currency);\n const locale = normalized.currency === \"NGN\" ? \"en-NG\" : \"en\";\n const digits = currencyDigits(normalized.currency);\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: normalized.currency,\n currencyDisplay: \"narrowSymbol\",\n minimumFractionDigits:\n opts.showZeroDecimals || normalized.amountMinor % 10 ** digits !== 0\n ? digits\n : 0,\n maximumFractionDigits: digits,\n notation: opts.compact ? \"compact\" : \"standard\",\n signDisplay: opts.sign ?? \"auto\",\n }).format(normalized.amountMinor / 10 ** digits);\n },\n};\n","import { ZappieError } from \"../errors\";\nimport type { Money } from \"../money\";\nimport { money } from \"../money\";\nexport function sumMoney(values: readonly Money[], zero: Money): Money {\n let amount = zero.amountMinor;\n for (const value of values) {\n if (value.currency !== zero.currency) {\n throw new ZappieError(\n \"invalid_request\",\n \"Cannot combine different currencies\",\n );\n }\n amount = money(amount + value.amountMinor, zero.currency).amountMinor;\n }\n return money(amount, zero.currency);\n}\nexport function multiplyMoney(value: Money, quantity: number): Money {\n if (!Number.isSafeInteger(quantity)) {\n throw new ZappieError(\n \"invalid_request\",\n \"Money requires an integer quantity\",\n );\n }\n return money(value.amountMinor * quantity, value.currency);\n}\n","import { ZappieError } from \"../errors\";\nimport type {\n Item,\n Menu,\n MenuSchedule,\n OpeningTime,\n OptionGroup,\n Variant,\n} from \"../models\";\nimport type { Currency, Money } from \"../money\";\nimport { money } from \"../money\";\n/** A value newer than this SDK; the item that carries it is shown as unavailable. */\nclass UnsupportedValue extends Error {}\nexport function record(value: unknown): Record<string, unknown> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new ZappieError(\"server_error\", \"Invalid storefront response object\");\n }\n return value as Record<string, unknown>;\n}\nexport function text(value: unknown): string {\n if (typeof value !== \"string\") {\n throw new ZappieError(\"server_error\", \"Invalid storefront response string\");\n }\n return value;\n}\nexport function list(value: unknown): unknown[] {\n if (!Array.isArray(value)) {\n throw new ZappieError(\"server_error\", \"Invalid storefront response list\");\n }\n return value;\n}\nfunction number(value: unknown): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n throw new ZappieError(\"server_error\", \"Invalid storefront response number\");\n }\n return value;\n}\nfunction nonnegative(value: unknown): number {\n const result = number(value);\n if (result < 0) {\n throw new ZappieError(\n \"server_error\",\n \"Negative selection or quantity bound\",\n );\n }\n return result;\n}\nfunction bounds(value: unknown): { min: number; max?: number } {\n const input = record(value);\n const min = nonnegative(input.min);\n if (input.max == null) {\n return { min };\n }\n const max = nonnegative(input.max);\n if (max < min) {\n throw new ZappieError(\n \"server_error\",\n \"Maximum quantity is below its minimum\",\n );\n }\n return { min, max };\n}\nexport const isString = (value: unknown): value is string =>\n typeof value === \"string\";\nexport const isBoolean = (value: unknown): value is boolean =>\n typeof value === \"boolean\";\n/** `{ [key]: value }` when the value passes the guard, otherwise `{}`, for optional wire fields. */\nexport function opt<K extends string, T>(\n key: K,\n value: unknown,\n is: (value: unknown) => value is T,\n): { [P in K]?: T } {\n return is(value) ? ({ [key]: value } as { [P in K]?: T }) : {};\n}\nexport function mapMoney(value: unknown): Money {\n const v = record(value);\n return money(\n number(v.amount_minor ?? v.amountMinor),\n text(v.currency) as Currency,\n );\n}\nexport function hours(value: unknown): OpeningTime[] {\n return list(value ?? []).map((slot) => {\n const v = record(slot);\n const day = number(v.day);\n if (!Number.isInteger(day) || day < 0 || day > 6) {\n throw new ZappieError(\"server_error\", \"Invalid opening day\");\n }\n return {\n day: day as OpeningTime[\"day\"],\n opens: text(v.opens ?? v.open ?? v.start),\n closes: text(v.closes ?? v.close ?? v.end),\n ...opt(\"disabled\", v.disabled, isBoolean),\n };\n });\n}\nfunction schedule(value: unknown): MenuSchedule | undefined {\n if (value === undefined) {\n return undefined;\n }\n const v = record(value);\n return {\n openingTimes: hours(v.opening_times ?? v.openingTimes ?? v.hours ?? []),\n ...opt(\"preorder\", v.preorder, isBoolean),\n ...(v.preorder_notice_hours !== undefined\n ? { preorderNoticeHours: number(v.preorder_notice_hours) }\n : {}),\n ...(v.preorder_max_days !== undefined\n ? { preorderMaxDays: number(v.preorder_max_days) }\n : {}),\n };\n}\nfunction mapGroup(value: unknown): OptionGroup {\n const g = record(value);\n const selection = record(g.selection ?? { min: g.min ?? 0, max: g.max });\n const isAttribute = g.is_attribute === true;\n const kind = text(g.kind ?? \"select\");\n if (![\"select\", \"text\", \"number\", \"date\", \"time\", \"toggle\"].includes(kind)) {\n throw new UnsupportedValue(`option input kind \"${kind}\"`);\n }\n return {\n id: text(g.id),\n name: text(g.name),\n kind: kind as OptionGroup[\"kind\"],\n required:\n typeof g.required === \"boolean\" ? g.required : number(selection.min) > 0,\n selection: bounds(selection),\n isAttribute,\n choices: list(g.choices ?? []).map((raw) => {\n const c = record(raw);\n const price = mapMoney(c.price);\n return {\n id: text(c.id),\n name: text(c.name),\n price: isAttribute ? money(0, price.currency) : price,\n ...(isAttribute && c.price_hint !== undefined\n ? { priceHint: mapMoney(c.price_hint) }\n : {}),\n isAvailable: (c.is_available ?? c.available) === true,\n ...(c.quantity ? { quantity: bounds(c.quantity) } : {}),\n };\n }),\n ...opt(\"helpText\", g.help_text, isString),\n ...(g.input\n ? {\n input: {\n ...(record(g.input).max_length !== undefined\n ? { maxLength: number(record(g.input).max_length) }\n : {}),\n ...(typeof record(g.input).placeholder === \"string\"\n ? { placeholder: text(record(g.input).placeholder) }\n : {}),\n },\n }\n : {}),\n ...opt(\"isAvailable\", g.is_available, isBoolean),\n ...opt(\"isInformational\", g.is_informational, isBoolean),\n ...(g.conditions\n ? {\n conditions: list(g.conditions).map((raw) => {\n const c = record(raw);\n const count = c.count ? record(c.count) : undefined;\n if (count && ![\"eq\", \"gte\", \"lte\"].includes(text(count.op))) {\n throw new UnsupportedValue(\n `option count operator \"${text(count.op)}\"`,\n );\n }\n if (\n c.match !== undefined &&\n c.match !== \"any\" &&\n c.match !== \"all\"\n ) {\n throw new UnsupportedValue(\n `option match operator \"${String(c.match)}\"`,\n );\n }\n if (c.set_required != null && typeof c.set_required !== \"boolean\") {\n throw new ZappieError(\n \"server_error\",\n \"Invalid conditional required flag\",\n );\n }\n return {\n groupId: text(c.group_id),\n choiceIds: list(c.choice_ids ?? []).map(text),\n match: c.match === \"all\" ? (\"all\" as const) : (\"any\" as const),\n ...(count\n ? {\n count: {\n op: text(count.op) as \"eq\" | \"gte\" | \"lte\",\n value: nonnegative(count.value),\n },\n }\n : {}),\n ...(c.set_required !== undefined\n ? { setRequired: c.set_required as boolean | null }\n : {}),\n ...(c.set_min !== undefined\n ? { setMin: c.set_min === null ? null : nonnegative(c.set_min) }\n : {}),\n ...(c.set_max !== undefined\n ? { setMax: c.set_max === null ? null : nonnegative(c.set_max) }\n : {}),\n };\n }),\n }\n : {}),\n };\n}\nfunction mapPromo(value: unknown): NonNullable<Item[\"promo\"]> {\n const p = record(value);\n return { name: text(p.name) };\n}\nexport function mapItem(value: unknown): Item {\n const v = record(value);\n const id = text(v.id);\n const optionGroups: OptionGroup[] = [];\n let unsupported = false;\n for (const raw of list(v.option_groups ?? [])) {\n try {\n optionGroups.push(mapGroup(raw));\n } catch (error) {\n if (!(error instanceof UnsupportedValue)) {\n throw error;\n }\n unsupported = true;\n console.warn(\n `Zappie item ${id} uses an ${error.message} this SDK can't validate; it is shown as unavailable`,\n );\n }\n }\n const variants = list(v.variants).map((raw) => {\n const x = record(raw);\n return {\n id: text(x.id),\n attributeChoices: Object.fromEntries(\n Object.entries(record(x.attribute_choices ?? {})).map(([k, v]) => [\n k,\n text(v),\n ]),\n ),\n price: mapMoney(x.price),\n ...opt(\"lowStock\", x.low_stock, isBoolean),\n isAvailable: !unsupported && (x.is_available ?? x.available) === true,\n };\n });\n if (!variants.length) {\n throw new ZappieError(\n \"server_error\",\n \"An item must carry at least one exact variant\",\n );\n }\n const quantity = record(\n v.quantity ?? { min: 1, step: 1, max: v.max_quantity },\n );\n const step = number(quantity.step);\n if (\n step <= 0 ||\n new Set(variants.map((variant) => variant.id)).size !== variants.length\n ) {\n throw new ZappieError(\n \"server_error\",\n \"Invalid quantity step or duplicate variant identity\",\n );\n }\n return {\n ...(v.placements !== undefined\n ? {\n placements: list(v.placements).map((raw) => {\n const placement = record(raw);\n return {\n menuId: text(placement.menu_id),\n categoryId: text(placement.category_id),\n };\n }),\n }\n : {}),\n id,\n name: text(v.name),\n images: list(v.images ?? []).map(text),\n price: mapMoney(v.price),\n isAvailable: !unsupported && (v.is_available ?? v.available) === true,\n quantity: { ...bounds(quantity), step },\n variants: variants as [Variant, ...Variant[]],\n optionGroups,\n tags: list(v.tags ?? []).map(text),\n ...opt(\"stockLabel\", v.stock_label, isString),\n ...(v.promo !== undefined ? { promo: mapPromo(v.promo) } : {}),\n ...opt(\"description\", v.description, isString),\n ...(v.compare_at_price\n ? { compareAtPrice: mapMoney(v.compare_at_price) }\n : {}),\n };\n}\nexport function mapMenu(value: unknown, branchId: string): Menu {\n const v = record(value);\n const sources = list(v.menus ?? [v]);\n if (\n v.completeness !== undefined &&\n v.completeness !== \"partial\" &&\n v.completeness !== \"complete\"\n ) {\n throw new ZappieError(\"server_error\", \"Invalid catalogue completeness\");\n }\n const categories = new Map<string, Menu[\"categories\"][number]>();\n const menus = sources.map((raw) => {\n const m = record(raw);\n if (\n (m.placement_count !== undefined &&\n (!Number.isSafeInteger(m.placement_count) ||\n Number(m.placement_count) < 0)) ||\n (m.paginated !== undefined && typeof m.paginated !== \"boolean\")\n ) {\n throw new ZappieError(\"server_error\", \"Invalid menu loading metadata\");\n }\n const categoryIds = list(m.categories ?? []).map((rawCategory) => {\n const c = record(rawCategory);\n const id = text(c.id);\n const previous = categories.get(id);\n const itemIds = [\n ...new Set([\n ...(previous?.itemIds ?? []),\n ...list(c.item_ids ?? []).map(text),\n ]),\n ];\n categories.set(id, {\n id,\n name: text(c.name),\n itemIds,\n ...opt(\"description\", c.description, isString),\n });\n return id;\n });\n const s = schedule(m.schedule);\n return {\n id: text(m.id),\n name: text(m.name),\n categoryIds,\n ...(m.placement_count !== undefined\n ? { placementCount: m.placement_count as number }\n : {}),\n ...opt(\"paginated\", m.paginated, isBoolean),\n ...(s ? { schedule: s } : {}),\n ...opt(\"infoBanner\", m.info_banner, isString),\n };\n });\n const items = Object.fromEntries(\n Object.entries(record(v.items)).map(([id, item]) => {\n const mapped = mapItem(item);\n if (mapped.id !== id) {\n throw new ZappieError(\n \"server_error\",\n \"Item map key does not match its identity\",\n );\n }\n return [id, mapped];\n }),\n );\n if (v.branch_id !== undefined && v.branch_id !== branchId) {\n throw new ZappieError(\"server_error\", \"Menu branch mismatch\");\n }\n return {\n id: menus.length === 1 ? menus[0]!.id : `branch:${branchId}`,\n branchId,\n ...(v.completeness === \"partial\"\n ? { completeness: \"partial\" as const }\n : {}),\n name: menus.length === 1 ? menus[0]!.name : \"Catalogue\",\n version: text(v.menu_version ?? v.version),\n categories: [...categories.values()],\n items,\n menus,\n ...(menus.length === 1 && menus[0]!.schedule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L,MAAM,MAAM,WAAW,IAAI,MAAM,CAAC,EAAG,OAAO;AAAA,IAC5C,SAAS,KAAK,EAAE,gBAAgB,EAAE,OAAO;AAAA,IACzC,YAAY,CAAC,GAAG,WAAW,OAAO,CAAC;AAAA,IACnC;AAAA,IACA;AAAA,IACA,GAAI,MAAM,WAAW,KAAK,MAAM,CAAC,EAAG,WAChC,EAAE,UAAU,MAAM,CAAC,EAAG,SAAS,IAC/B,CAAC;AAAA,EACP;AACF;","names":["codes","v"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// ../sdk/src/debug.ts
|
|
2
|
+
var VERSION = typeof __ZAPPIE_SDK_VERSION__ === "string" ? __ZAPPIE_SDK_VERSION__ : "0.0.0-development";
|
|
3
|
+
function installDebug(client) {
|
|
4
|
+
if (typeof window === "undefined" || client.mode !== "test") {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const events = [];
|
|
8
|
+
let quote;
|
|
9
|
+
const emit = (name, detail) => {
|
|
10
|
+
const event = { name, detail, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
11
|
+
events.push(event);
|
|
12
|
+
window.dispatchEvent(new CustomEvent("zappie:event", { detail: event }));
|
|
13
|
+
};
|
|
14
|
+
globalThis.__zappieEmit = emit;
|
|
15
|
+
window.__zappie = {
|
|
16
|
+
version: VERSION,
|
|
17
|
+
store: client.config.store,
|
|
18
|
+
async catalogue() {
|
|
19
|
+
await client.cart.hydrate();
|
|
20
|
+
const branch = (await client.store.get()).branches.find(
|
|
21
|
+
(value) => value.id === client.cart.getSnapshot().branchId
|
|
22
|
+
);
|
|
23
|
+
return { branch, menu: await client.menu.get({ branch: branch.id }) };
|
|
24
|
+
},
|
|
25
|
+
cart: Object.assign(() => client.cart.getSnapshot(), {
|
|
26
|
+
async inject(input) {
|
|
27
|
+
await client.cart.hydrate();
|
|
28
|
+
if (input.lines.length > 100 || input.lines.some(
|
|
29
|
+
(line) => !Number.isInteger(line.quantity ?? 1) || (line.quantity ?? 1) < 1 || (line.quantity ?? 1) > 99
|
|
30
|
+
)) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
"Use up to 100 cart lines with whole quantities from 1 to 99."
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const snapshot = client.cart.getSnapshot();
|
|
36
|
+
const value = {
|
|
37
|
+
v: 1,
|
|
38
|
+
menuVersion: client._internal.cartCatalogue().version,
|
|
39
|
+
updatedAt: Date.now(),
|
|
40
|
+
fulfilment: snapshot.fulfilment,
|
|
41
|
+
promoCode: snapshot.promoCode,
|
|
42
|
+
lines: input.lines.map((line, index) => ({
|
|
43
|
+
...line,
|
|
44
|
+
id: `debug_${index}`,
|
|
45
|
+
name: line.itemId,
|
|
46
|
+
quantity: line.quantity ?? 1,
|
|
47
|
+
choices: (line.choices ?? []).map((choice) => ({
|
|
48
|
+
...choice,
|
|
49
|
+
quantity: choice.quantity ?? 1
|
|
50
|
+
})),
|
|
51
|
+
inputs: line.inputs ?? {},
|
|
52
|
+
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
53
|
+
}))
|
|
54
|
+
};
|
|
55
|
+
const scope = client.config.cart?.storageScope;
|
|
56
|
+
(client.config.storage ?? window.localStorage).setItem(
|
|
57
|
+
`zappie:cart:v1:${client.config.store}:${snapshot.branchId}${scope ? `:${scope}` : ""}`,
|
|
58
|
+
JSON.stringify(value)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
quote: () => quote,
|
|
63
|
+
events
|
|
64
|
+
};
|
|
65
|
+
client.on("add_to_cart", (detail) => emit("add_to_cart", detail));
|
|
66
|
+
client.cart.subscribe(() => {
|
|
67
|
+
const state = client.cart.state;
|
|
68
|
+
const next = "quote" in state ? state.quote : void 0;
|
|
69
|
+
if (next && next !== quote) {
|
|
70
|
+
quote = next;
|
|
71
|
+
emit("quote", next);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
installDebug
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=debug-C3UDGUED.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../sdk/src/debug.ts"],"sourcesContent":["import type { StoredLine } from \"./cart/storage\";\nimport type { CartLineInput, Quote } from \"./cart/types\";\nimport type { Zappie } from \"./client\";\nimport type { Branch, Menu } from \"./models\";\n\n// Inline like VERSION in index.ts: tsup fills in the version from package.json.\ndeclare const __ZAPPIE_SDK_VERSION__: string | undefined;\nconst VERSION =\n typeof __ZAPPIE_SDK_VERSION__ === \"string\"\n ? __ZAPPIE_SDK_VERSION__\n : \"0.0.0-development\";\n\nexport type DebugEvent = {\n name: string;\n detail: unknown;\n at: string;\n};\n\nexport type ZappieDebug = {\n version: string;\n store: string;\n /** Read this cart's branch and full menu through its client. */\n catalogue(): Promise<{ menu: Menu; branch: Branch }>;\n cart: (() => ReturnType<Zappie[\"cart\"][\"getSnapshot\"]>) & {\n /**\n * Save test cart lines for the next reload. Reload to reconcile them with today's menu.\n * Your unitPrice is only a local estimate, like a price edited in browser storage.\n * The server re-prices every line and never trusts this estimate.\n */\n inject(input: {\n lines: (CartLineInput & Pick<StoredLine, \"unitPrice\">)[];\n }): Promise<void>;\n };\n quote: () => Quote | undefined;\n events: DebugEvent[];\n};\n\ndeclare global {\n interface Window {\n __zappie?: ZappieDebug;\n }\n // On globalThis so the lazy checkout and customer entries can reach it\n // with the shortest possible call; in a browser it is window's.\n var __zappieEmit: ((name: string, detail: unknown) => void) | undefined;\n}\n\nexport function installDebug(client: Zappie) {\n if (typeof window === \"undefined\" || client.mode !== \"test\") {\n return;\n }\n const events: DebugEvent[] = [];\n let quote: Quote | undefined;\n const emit = (name: string, detail: unknown) => {\n const event = { name, detail, at: new Date().toISOString() };\n events.push(event);\n window.dispatchEvent(new CustomEvent(\"zappie:event\", { detail: event }));\n };\n globalThis.__zappieEmit = emit;\n window.__zappie = {\n version: VERSION,\n store: client.config.store,\n async catalogue() {\n await client.cart.hydrate();\n const branch = (await client.store.get()).branches.find(\n (value) => value.id === client.cart.getSnapshot().branchId,\n )!;\n return { branch, menu: await client.menu.get({ branch: branch.id }) };\n },\n cart: Object.assign(() => client.cart.getSnapshot(), {\n async inject(input: {\n lines: (CartLineInput & Pick<StoredLine, \"unitPrice\">)[];\n }) {\n await client.cart.hydrate();\n if (\n input.lines.length > 100 ||\n input.lines.some(\n (line) =>\n !Number.isInteger(line.quantity ?? 1) ||\n (line.quantity ?? 1) < 1 ||\n (line.quantity ?? 1) > 99,\n )\n ) {\n throw new Error(\n \"Use up to 100 cart lines with whole quantities from 1 to 99.\",\n );\n }\n const snapshot = client.cart.getSnapshot();\n const value = {\n v: 1,\n menuVersion: client._internal.cartCatalogue()!.version,\n updatedAt: Date.now(),\n fulfilment: snapshot.fulfilment,\n promoCode: snapshot.promoCode,\n lines: input.lines.map((line, index) => ({\n ...line,\n id: `debug_${index}`,\n name: line.itemId,\n quantity: line.quantity ?? 1,\n choices: (line.choices ?? []).map((choice) => ({\n ...choice,\n quantity: choice.quantity ?? 1,\n })),\n inputs: line.inputs ?? {},\n addedAt: new Date().toISOString(),\n })),\n };\n const scope = client.config.cart?.storageScope;\n (client.config.storage ?? window.localStorage).setItem(\n `zappie:cart:v1:${client.config.store}:${snapshot.branchId}${scope ? `:${scope}` : \"\"}`,\n JSON.stringify(value),\n );\n },\n }),\n quote: () => quote,\n events,\n };\n client.on(\"add_to_cart\", (detail) => emit(\"add_to_cart\", detail));\n client.cart.subscribe(() => {\n const state = client.cart.state;\n const next = \"quote\" in state ? state.quote : undefined;\n if (next && next !== quote) {\n quote = next;\n emit(\"quote\", next);\n }\n });\n}\n"],"mappings":";AAOA,IAAM,UACJ,OAAO,2BAA2B,WAC9B,yBACA;AAoCC,SAAS,aAAa,QAAgB;AAC3C,MAAI,OAAO,WAAW,eAAe,OAAO,SAAS,QAAQ;AAC3D;AAAA,EACF;AACA,QAAM,SAAuB,CAAC;AAC9B,MAAI;AACJ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,MAAM,KAAK;AAAA,YACX,UAAU,KAAK,YAAY;AAAA,YAC3B,UAAU,KAAK,WAAW,CAAC,GAAG,IAAI,CAAC,YAAY;AAAA,cAC7C,GAAG;AAAA,cACH,UAAU,OAAO,YAAY;AAAA,YAC/B,EAAE;AAAA,YACF,QAAQ,KAAK,UAAU,CAAC;AAAA,YACxB,UAAS,oBAAI,KAAK,GAAE,YAAY;AAAA,UAClC,EAAE;AAAA,QACJ;AACA,cAAM,QAAQ,OAAO,OAAO,MAAM;AAClC,SAAC,OAAO,OAAO,WAAW,OAAO,cAAc;AAAA,UAC7C,kBAAkB,OAAO,OAAO,KAAK,IAAI,SAAS,QAAQ,GAAG,QAAQ,IAAI,KAAK,KAAK,EAAE;AAAA,UACrF,KAAK,UAAU,KAAK;AAAA,QACtB;AAAA,MACF;AAAA,IACF,CAAC;AAAA,IACD,OAAO,MAAM;AAAA,IACb;AAAA,EACF;AACA,SAAO,GAAG,eAAe,CAAC,WAAW,KAAK,eAAe,MAAM,CAAC;AAChE,SAAO,KAAK,UAAU,MAAM;AAC1B,UAAM,QAAQ,OAAO,KAAK;AAC1B,UAAM,OAAO,WAAW,QAAQ,MAAM,QAAQ;AAC9C,QAAI,QAAQ,SAAS,OAAO;AAC1B,cAAQ;AACR,WAAK,SAAS,IAAI;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
type Viewport = {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
};
|
|
5
|
+
type PackageManager = "pnpm" | "npm" | "yarn" | "bun";
|
|
6
|
+
type CheckResult = {
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
result: "passed" | "failed" | "skipped";
|
|
10
|
+
durationMs: number;
|
|
11
|
+
viewport?: string;
|
|
12
|
+
retried?: boolean;
|
|
13
|
+
error?: {
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
hint: string;
|
|
17
|
+
};
|
|
18
|
+
artifacts?: {
|
|
19
|
+
screenshot?: string;
|
|
20
|
+
trace?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
type VerifyReport = {
|
|
24
|
+
schema: "https://zappie.ai/schemas/verify-report.v1.json";
|
|
25
|
+
id: string;
|
|
26
|
+
suite: "standard" | "extended";
|
|
27
|
+
target: {
|
|
28
|
+
url: string;
|
|
29
|
+
origin: string;
|
|
30
|
+
store: string;
|
|
31
|
+
siteId?: string;
|
|
32
|
+
deploymentId?: string;
|
|
33
|
+
};
|
|
34
|
+
environment: {
|
|
35
|
+
runner: "build-worker" | "sandbox" | "cli" | "ci";
|
|
36
|
+
verifyVersion: string;
|
|
37
|
+
sdkVersion: string;
|
|
38
|
+
browser: string;
|
|
39
|
+
};
|
|
40
|
+
startedAt: string;
|
|
41
|
+
durationMs: number;
|
|
42
|
+
result: "passed" | "failed" | "error";
|
|
43
|
+
summary: {
|
|
44
|
+
passed: number;
|
|
45
|
+
failed: number;
|
|
46
|
+
skipped: number;
|
|
47
|
+
};
|
|
48
|
+
checks: CheckResult[];
|
|
49
|
+
metrics: {
|
|
50
|
+
menuJsKbGz?: number;
|
|
51
|
+
lcpMs?: number;
|
|
52
|
+
cls?: number;
|
|
53
|
+
};
|
|
54
|
+
signature?: string;
|
|
55
|
+
};
|
|
56
|
+
type VerifyOptions = {
|
|
57
|
+
url: string;
|
|
58
|
+
store: string;
|
|
59
|
+
key: string;
|
|
60
|
+
suite: "standard" | "extended";
|
|
61
|
+
siteId?: string;
|
|
62
|
+
deploymentId?: string;
|
|
63
|
+
only?: string[];
|
|
64
|
+
viewports?: Viewport[];
|
|
65
|
+
artifactsDir?: string;
|
|
66
|
+
timeoutMs?: number;
|
|
67
|
+
signal?: AbortSignal;
|
|
68
|
+
onProgress?: (event: {
|
|
69
|
+
id: string;
|
|
70
|
+
status: "running" | "passed" | "failed" | "skipped";
|
|
71
|
+
}) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Answer `/_zappie/view` with 204, as Zappie's site host does on hosting.
|
|
74
|
+
* Set it for a local preview, which has no site host, so the page-view
|
|
75
|
+
* beacon doesn't fail the routes check. Never set it for a deployed URL.
|
|
76
|
+
*/
|
|
77
|
+
standInForPlatform?: boolean;
|
|
78
|
+
signingKey?: string;
|
|
79
|
+
runner?: VerifyReport["environment"]["runner"];
|
|
80
|
+
};
|
|
81
|
+
type VerifyProjectOptions = Omit<VerifyOptions, "url" | "store" | "runner"> & {
|
|
82
|
+
cwd: string;
|
|
83
|
+
url?: string;
|
|
84
|
+
store?: string;
|
|
85
|
+
packageManager: PackageManager;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
declare class VerifyError extends Error {
|
|
89
|
+
readonly code: string;
|
|
90
|
+
readonly hint: string;
|
|
91
|
+
constructor(code: string, message: string, hint: string);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare function verifyProject(options: VerifyProjectOptions): Promise<VerifyReport>;
|
|
95
|
+
|
|
96
|
+
declare function printSummary(report: VerifyReport): string;
|
|
97
|
+
|
|
98
|
+
declare function verify(options: VerifyOptions): Promise<VerifyReport>;
|
|
99
|
+
|
|
100
|
+
export { type CheckResult, type PackageManager, VerifyError, type VerifyOptions, type VerifyProjectOptions, type VerifyReport, printSummary, verify, verifyProject };
|