@zappie/sdk 0.1.3 → 0.1.5
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 +12 -0
- package/README.md +1 -0
- package/dist/cart/branch.d.ts +26 -0
- package/dist/cart/branch.js +79 -0
- package/dist/cart/branch.js.map +7 -0
- package/dist/cart/index.js +6 -1
- package/dist/cart/index.js.map +2 -2
- package/dist/cart/item.d.ts +3 -2
- package/dist/cart/quote-client.js +48 -3
- package/dist/cart/quote-client.js.map +2 -2
- package/dist/cart/quote-response.js +27 -0
- package/dist/cart/quote-response.js.map +3 -3
- package/dist/cart/quote.d.ts +8 -3
- package/dist/cart/storage.js +1 -1
- package/dist/cart/storage.js.map +2 -2
- package/dist/cart/wire.js +1 -0
- package/dist/cart/wire.js.map +2 -2
- package/dist/{client-BctSrEhO.d.ts → client-Bm2cCYea.d.ts} +17 -342
- package/dist/client.js +4 -2
- package/dist/client.js.map +2 -2
- package/dist/config.js.map +2 -2
- package/dist/debug.d.ts +3 -2
- package/dist/debug.js +1 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/dist/integrations/index.d.ts +39 -0
- package/dist/integrations/index.js +78 -0
- package/dist/integrations/index.js.map +7 -0
- package/dist/internal.d.ts +3 -3
- package/dist/{models-Dj-VkdU1.d.ts → models-Rg5kQUkv.d.ts} +26 -0
- package/dist/persist/catalogue.d.ts +3 -2
- package/dist/react/index.d.ts +3 -2
- package/dist/server/index.d.ts +4 -2
- package/dist/testing/index.d.ts +4 -2
- package/dist/transport/category-page.d.ts +1 -1
- package/dist/transport/mappers.js +20 -0
- package/dist/transport/mappers.js.map +2 -2
- package/dist/transport/quote-body.js +24 -0
- package/dist/transport/quote-body.js.map +7 -0
- package/dist/transport/rest.js +10 -2
- package/dist/transport/rest.js.map +2 -2
- package/dist/transport/search.d.ts +3 -2
- package/dist/transport/selected-menu.d.ts +3 -2
- package/dist/transport/store.d.ts +2 -2
- package/dist/transport/store.js +14 -1
- package/dist/transport/store.js.map +3 -3
- package/dist/types-CuDvfW9g.d.ts +380 -0
- package/package.json +9 -1
package/dist/client.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/client.ts"],
|
|
4
|
-
"sourcesContent": ["import { createCart } from \"./cart\";\nimport { createWorkingSet } from \"./cart/working-set\";\nimport type { ZappieConfig } from \"./config\";\nimport { API_VERSION, validateConfig } from \"./config\";\nimport { ZappieError } from \"./errors\";\nimport { Cache } from \"./internal/cache\";\nimport type { ZappieEvents } from \"./internal/emitter\";\nimport { createEmitter } from \"./internal/emitter\";\nimport type { Branch, CategoryPage, Item, Menu, Store } from \"./models\";\nimport { format } from \"./money\";\nimport { RestTransport } from \"./transport/rest\";\nimport type { MenuVersion, SearchPage } from \"./transport/types\";\n/** Optional branch selection and cancellation for resource reads. */\nexport type ReadOptions = { branch?: string; signal?: AbortSignal };\n/** Read-only store resource. */\nexport interface StoreResource {\n get(opts?: { signal?: AbortSignal }): Promise<Store>;\n peek(): Store | undefined;\n}\n/** Read-only branch catalogue and item resources. */\nexport interface MenuResource {\n search(\n query: string,\n opts?: ReadOptions & { cursor?: string },\n ): Promise<SearchPage>;\n get(opts?: ReadOptions & { metadataOnly?: boolean }): Promise<Menu>;\n page(\n menuId: string,\n categoryId: string,\n opts?: ReadOptions & { cursor?: string },\n ): Promise<CategoryPage>;\n peek(branch?: string): Menu | undefined;\n version(opts?: ReadOptions): Promise<MenuVersion>;\n item(id: string, opts?: ReadOptions): Promise<Item>;\n hydrate(menu: Menu): void;\n}\n/** A storefront client and its isolated resource state. */\nexport type Zappie = ReturnType<typeof buildClient>;\nexport function buildClient(input: ZappieConfig, secret = false) {\n const mode = validateConfig(input, secret);\n const config = Object.freeze({\n ...input,\n version: input.version ?? API_VERSION,\n telemetry: input.telemetry ?? true,\n });\n const transport =\n input.transport ??\n new RestTransport({\n ...(input.baseUrl ? { baseUrl: input.baseUrl } : {}),\n ...(input.fetch ? { fetch: input.fetch } : {}),\n });\n const events = createEmitter();\n const cache = new Cache((error) => events.emit(\"error\", { error }));\n const ctx = (signal?: AbortSignal) => ({\n key: config.key,\n version: config.version,\n ...(signal ? { signal } : {}),\n });\n const store: StoreResource = {\n get: (opts = {}) =>\n cache.get(\n \"store\",\n async (signal) => ({ value: await transport.getStore(ctx(signal)) }),\n opts.signal,\n ),\n peek: () => cache.snapshot<Store>(\"store\").value,\n };\n const resolveBranch = (value: Store, requested?: string): Branch => {\n const selected = requested ?? config.branch;\n const branch = selected\n ? value.branches.find((b) => b.id === selected || b.slug === selected)\n : (value.branches.find((b) => b.isDefault) ?? value.branches[0]);\n if (!branch) {\n throw new ZappieError(\n \"branch_not_found\",\n \"No matching storefront branch\",\n { param: \"branch\" },\n );\n }\n return branch;\n };\n let hydratedBranch: string | undefined;\n const branchKey = (requested?: string) => {\n const value = store.peek();\n if (value) {\n return resolveBranch(value, requested).id;\n }\n // A slug can't be resolved without the store. A hydrated menu is the configured\n // branch's, so a read for that branch (by slug or id) uses it rather than missing.\n const selected = requested ?? config.branch;\n if (\n hydratedBranch &&\n (selected === undefined ||\n selected === config.branch ||\n selected === hydratedBranch)\n ) {\n return hydratedBranch;\n }\n return selected ?? \"default\";\n };\n const menuKey = (requested?: string) => `menu:${branchKey(requested)}`;\n const menu: MenuResource = {\n async search(query, opts = {}) {\n if (!transport.search) {\n throw new ZappieError(\n \"invalid_request\",\n \"Transport does not support search\",\n );\n }\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.search({\n ...ctx(opts.signal),\n branchId: branch.id,\n query,\n ...(opts.cursor ? { cursor: opts.cursor } : {}),\n });\n },\n async get(opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return cache.get<Menu>(\n `menu:${branch.id}${opts.metadataOnly ? \":partial\" : \"\"}`,\n async (signal, entry) => {\n const response = await transport.getMenu({\n ...ctx(signal),\n branchId: branch.id,\n ...(opts.metadataOnly ? { metadataOnly: true } : {}),\n ...(entry.etag ? { ifNoneMatch: entry.etag } : {}),\n });\n if (\"notModified\" in response) {\n if (!entry.value) {\n throw new ZappieError(\n \"server_error\",\n \"Received 304 without a cached menu\",\n );\n }\n return {\n value: entry.value,\n ...((response.etag ?? entry.etag)\n ? { etag: response.etag ?? entry.etag }\n : {}),\n };\n }\n if (!opts.metadataOnly && response.menu.completeness === \"partial\") {\n throw new ZappieError(\n \"server_error\",\n \"Partial catalogue cannot satisfy a complete read\",\n );\n }\n if (response.menu.branchId !== branch.id) {\n throw new ZappieError(\n \"server_error\",\n \"Menu belongs to a different branch\",\n );\n }\n return {\n value: response.menu,\n etag: response.etag ?? response.menu.version,\n onStored: () => {\n if (\n entry.value &&\n entry.value.version !== response.menu.version\n ) {\n events.emit(\"menu:updated\", {\n branchId: branch.id,\n version: response.menu.version,\n });\n }\n },\n };\n },\n opts.signal,\n );\n },\n peek: (branch) =>\n cache.snapshot<Menu>(menuKey(branch)).value ??\n cache.snapshot<Menu>(`${menuKey(branch)}:partial`).value,\n async page(menuId, categoryId, opts = {}) {\n if (!transport.getCategoryPage) {\n throw new ZappieError(\n \"invalid_request\",\n \"Transport does not support category pages\",\n );\n }\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.getCategoryPage({\n ...ctx(opts.signal),\n branchId: branch.id,\n menuId,\n categoryId,\n ...(opts.cursor ? { cursor: opts.cursor } : {}),\n });\n },\n async version(opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.getMenuVersion({\n ...ctx(opts.signal),\n branchId: branch.id,\n });\n },\n async item(id, opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n if (\n !menu.peek(branch.id) ||\n menu.peek(branch.id)?.completeness === \"partial\"\n ) {\n await menu.get({ ...opts, metadataOnly: true });\n }\n return readItem(id, branch.id, false, opts.signal);\n },\n hydrate(value) {\n hydratedBranch ??= value.branchId;\n const previous = cache.snapshot<Menu>(`menu:${value.branchId}`).value;\n cache.set(\n `menu:${value.branchId}${value.completeness === \"partial\" ? \":partial\" : \"\"}`,\n value,\n value.version,\n );\n if (previous && previous.version !== value.version) {\n events.emit(\"menu:updated\", {\n branchId: value.branchId,\n version: value.version,\n });\n }\n },\n };\n const itemValues = new Map<string, Item>();\n const peekItem = (id: string, branch: string) =>\n itemValues.get(`${branch}:${id}`);\n const readItem = async (\n id: string,\n branch: string,\n fresh = false,\n signal?: AbortSignal,\n ) => {\n const complete = cache.snapshot<Menu>(`menu:${branch}`).value;\n if (!fresh && complete && Object.hasOwn(complete.items, id)) {\n return complete.items[id]!;\n }\n const load = (requestSignal = signal) =>\n transport.getItem({\n ...ctx(requestSignal),\n branchId: branch,\n itemId: id,\n });\n try {\n const value = fresh\n ? await load()\n : await cache.get(\n `item:${branch}:${id}`,\n async (requestSignal) => ({ value: await load(requestSignal) }),\n signal,\n );\n if (fresh) {\n cache.set(`item:${branch}:${id}`, value);\n }\n itemValues.set(`${branch}:${id}`, value);\n return value;\n } catch (error) {\n if ((error as { code?: string }).code === \"item_not_found\") {\n itemValues.delete(`${branch}:${id}`);\n cache.set(`item:${branch}:${id}`, undefined);\n }\n throw error;\n }\n };\n const workingSet = createWorkingSet({\n menu,\n store,\n transport,\n context: ctx,\n peekItem,\n readItem,\n });\n const { cart, setLegacyReader, cartCatalogue } = createCart({\n workingSet,\n config,\n menu,\n store,\n transport,\n context: ctx,\n events,\n });\n return Object.freeze({\n cart,\n config,\n mode,\n store,\n menu,\n format,\n on: events.on,\n _internal: {\n cartCatalogue,\n setLegacyReader,\n transport,\n cache,\n emit: events.emit,\n menuKey,\n hydrateStore: (value: Store) => cache.set(\"store\", value),\n },\n });\n}\n/** Create a client with your publishable key. Requests start when you read a resource. */\nexport function createZappie(config: ZappieConfig) {\n const client = buildClient(config);\n if (client.mode === \"test\" && typeof window !== \"undefined\") {\n void import(\"./debug\").then(({ installDebug }) => installDebug(client));\n }\n return client;\n}\nexport type { ZappieEvents };\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AAEjC,SAAS,aAAa,sBAAsB;AAC5C,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AAEtB,SAAS,qBAAqB;AAE9B,SAAS,cAAc;AACvB,SAAS,qBAAqB;
|
|
4
|
+
"sourcesContent": ["import { createCart } from \"./cart\";\nimport { createWorkingSet } from \"./cart/working-set\";\nimport type { ZappieConfig } from \"./config\";\nimport { API_VERSION, validateConfig } from \"./config\";\nimport { ZappieError } from \"./errors\";\nimport { Cache } from \"./internal/cache\";\nimport type { ZappieEvents } from \"./internal/emitter\";\nimport { createEmitter } from \"./internal/emitter\";\nimport type { Branch, CategoryPage, Item, Menu, Store } from \"./models\";\nimport { format } from \"./money\";\nimport { RestTransport } from \"./transport/rest\";\nimport type { MenuVersion, SearchPage } from \"./transport/types\";\n/** A catalogue fulfilment mode accepted by menu reads. */\nexport type MenuFulfilment = \"delivery\" | \"pickup\" | \"dineIn\";\n/** Optional branch selection and cancellation for resource reads. */\nexport type ReadOptions = { branch?: string; signal?: AbortSignal };\n/** Optional branch and fulfilment selection for catalogue reads. */\nexport type MenuReadOptions = ReadOptions & { fulfilment?: MenuFulfilment };\n/** Read-only store resource. */\nexport interface StoreResource {\n get(opts?: { signal?: AbortSignal }): Promise<Store>;\n peek(): Store | undefined;\n}\n/** Read-only branch catalogue and item resources. */\nexport interface MenuResource {\n search(\n query: string,\n opts?: ReadOptions & { cursor?: string },\n ): Promise<SearchPage>;\n get(opts?: MenuReadOptions & { metadataOnly?: boolean }): Promise<Menu>;\n page(\n menuId: string,\n categoryId: string,\n opts?: ReadOptions & { cursor?: string },\n ): Promise<CategoryPage>;\n peek(branch?: string): Menu | undefined;\n version(opts?: MenuReadOptions): Promise<MenuVersion>;\n item(id: string, opts?: ReadOptions): Promise<Item>;\n hydrate(menu: Menu): void;\n}\n/** A storefront client and its isolated resource state. */\nexport type Zappie = ReturnType<typeof buildClient>;\nexport function buildClient(input: ZappieConfig, secret = false) {\n const mode = validateConfig(input, secret);\n const config = Object.freeze({\n ...input,\n version: input.version ?? API_VERSION,\n telemetry: input.telemetry ?? true,\n });\n const transport =\n input.transport ??\n new RestTransport({\n ...(input.baseUrl ? { baseUrl: input.baseUrl } : {}),\n ...(input.fetch ? { fetch: input.fetch } : {}),\n });\n const events = createEmitter();\n const cache = new Cache((error) => events.emit(\"error\", { error }));\n const ctx = (signal?: AbortSignal) => ({\n key: config.key,\n version: config.version,\n ...(signal ? { signal } : {}),\n });\n const store: StoreResource = {\n get: (opts = {}) =>\n cache.get(\n \"store\",\n async (signal) => ({ value: await transport.getStore(ctx(signal)) }),\n opts.signal,\n ),\n peek: () => cache.snapshot<Store>(\"store\").value,\n };\n const resolveBranch = (value: Store, requested?: string): Branch => {\n const selected = requested ?? config.branch;\n const branch = selected\n ? value.branches.find((b) => b.id === selected || b.slug === selected)\n : (value.branches.find((b) => b.isDefault) ?? value.branches[0]);\n if (!branch) {\n throw new ZappieError(\n \"branch_not_found\",\n \"No matching storefront branch\",\n { param: \"branch\" },\n );\n }\n return branch;\n };\n let hydratedBranch: string | undefined;\n const branchKey = (requested?: string) => {\n const value = store.peek();\n if (value) {\n return resolveBranch(value, requested).id;\n }\n // A slug can't be resolved without the store. A hydrated menu is the configured\n // branch's, so a read for that branch (by slug or id) uses it rather than missing.\n const selected = requested ?? config.branch;\n if (\n hydratedBranch &&\n (selected === undefined ||\n selected === config.branch ||\n selected === hydratedBranch)\n ) {\n return hydratedBranch;\n }\n return selected ?? \"default\";\n };\n const menuKey = (requested?: string) => `menu:${branchKey(requested)}`;\n const menu: MenuResource = {\n async search(query, opts = {}) {\n if (!transport.search) {\n throw new ZappieError(\n \"invalid_request\",\n \"Transport does not support search\",\n );\n }\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.search({\n ...ctx(opts.signal),\n branchId: branch.id,\n query,\n ...(opts.cursor ? { cursor: opts.cursor } : {}),\n });\n },\n async get(opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return cache.get<Menu>(\n `${menuKey(branch.id)}${opts.fulfilment ? `:${opts.fulfilment}` : \"\"}${opts.metadataOnly ? \":partial\" : \"\"}`,\n async (signal, entry) => {\n const response = await transport.getMenu({\n ...ctx(signal),\n branchId: branch.id,\n fulfilment: opts.fulfilment,\n ...(opts.metadataOnly ? { metadataOnly: true } : {}),\n ...(entry.etag ? { ifNoneMatch: entry.etag } : {}),\n });\n if (\"notModified\" in response) {\n if (!entry.value) {\n throw new ZappieError(\n \"server_error\",\n \"Received 304 without a cached menu\",\n );\n }\n return {\n value: entry.value,\n ...((response.etag ?? entry.etag)\n ? { etag: response.etag ?? entry.etag }\n : {}),\n };\n }\n if (!opts.metadataOnly && response.menu.completeness === \"partial\") {\n throw new ZappieError(\n \"server_error\",\n \"Partial catalogue cannot satisfy a complete read\",\n );\n }\n if (response.menu.branchId !== branch.id) {\n throw new ZappieError(\n \"server_error\",\n \"Menu belongs to a different branch\",\n );\n }\n return {\n value: response.menu,\n etag: response.etag ?? response.menu.version,\n onStored: () => {\n if (\n entry.value &&\n entry.value.version !== response.menu.version\n ) {\n events.emit(\"menu:updated\", {\n branchId: branch.id,\n version: response.menu.version,\n });\n }\n },\n };\n },\n opts.signal,\n );\n },\n peek: (branch) =>\n cache.snapshot<Menu>(menuKey(branch)).value ??\n cache.snapshot<Menu>(`${menuKey(branch)}:partial`).value,\n async page(menuId, categoryId, opts = {}) {\n if (!transport.getCategoryPage) {\n throw new ZappieError(\n \"invalid_request\",\n \"Transport does not support category pages\",\n );\n }\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.getCategoryPage({\n ...ctx(opts.signal),\n branchId: branch.id,\n menuId,\n categoryId,\n ...(opts.cursor ? { cursor: opts.cursor } : {}),\n });\n },\n async version(opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n return transport.getMenuVersion({\n ...ctx(opts.signal),\n branchId: branch.id,\n fulfilment: opts.fulfilment,\n });\n },\n async item(id, opts = {}) {\n const branch = resolveBranch(await store.get(opts), opts.branch);\n if (\n !menu.peek(branch.id) ||\n menu.peek(branch.id)?.completeness === \"partial\"\n ) {\n await menu.get({ ...opts, metadataOnly: true });\n }\n return readItem(id, branch.id, false, opts.signal);\n },\n hydrate(value) {\n hydratedBranch ??= value.branchId;\n const previous = cache.snapshot<Menu>(`menu:${value.branchId}`).value;\n cache.set(\n `menu:${value.branchId}${value.completeness === \"partial\" ? \":partial\" : \"\"}`,\n value,\n value.version,\n );\n if (previous && previous.version !== value.version) {\n events.emit(\"menu:updated\", {\n branchId: value.branchId,\n version: value.version,\n });\n }\n },\n };\n const itemValues = new Map<string, Item>();\n const peekItem = (id: string, branch: string) =>\n itemValues.get(`${branch}:${id}`);\n const readItem = async (\n id: string,\n branch: string,\n fresh = false,\n signal?: AbortSignal,\n ) => {\n const complete = cache.snapshot<Menu>(`menu:${branch}`).value;\n if (!fresh && complete && Object.hasOwn(complete.items, id)) {\n return complete.items[id]!;\n }\n const load = (requestSignal = signal) =>\n transport.getItem({\n ...ctx(requestSignal),\n branchId: branch,\n itemId: id,\n });\n try {\n const value = fresh\n ? await load()\n : await cache.get(\n `item:${branch}:${id}`,\n async (requestSignal) => ({ value: await load(requestSignal) }),\n signal,\n );\n if (fresh) {\n cache.set(`item:${branch}:${id}`, value);\n }\n itemValues.set(`${branch}:${id}`, value);\n return value;\n } catch (error) {\n if ((error as { code?: string }).code === \"item_not_found\") {\n itemValues.delete(`${branch}:${id}`);\n cache.set(`item:${branch}:${id}`, undefined);\n }\n throw error;\n }\n };\n const workingSet = createWorkingSet({\n menu,\n store,\n transport,\n context: ctx,\n peekItem,\n readItem,\n });\n const { cart, setLegacyReader, cartCatalogue } = createCart({\n workingSet,\n config,\n menu,\n store,\n transport,\n context: ctx,\n events,\n });\n return Object.freeze({\n cart,\n config,\n mode,\n store,\n menu,\n format,\n on: events.on,\n _internal: {\n cartCatalogue,\n setLegacyReader,\n transport,\n cache,\n emit: events.emit,\n menuKey,\n hydrateStore: (value: Store) => cache.set(\"store\", value),\n },\n });\n}\n/** Create a client with your publishable key. Requests start when you read a resource. */\nexport function createZappie(config: ZappieConfig) {\n const client = buildClient(config);\n if (client.mode === \"test\" && typeof window !== \"undefined\") {\n void import(\"./debug\").then(({ installDebug }) => installDebug(client));\n }\n return client;\n}\nexport type { ZappieEvents };\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB;AAEjC,SAAS,aAAa,sBAAsB;AAC5C,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AAEtB,SAAS,qBAAqB;AAE9B,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAgCvB,SAAS,YAAY,OAAqB,SAAS,OAAO;AAC/D,QAAM,OAAO,eAAe,OAAO,MAAM;AACzC,QAAM,SAAS,OAAO,OAAO;AAAA,IAC3B,GAAG;AAAA,IACH,SAAS,MAAM,WAAW;AAAA,IAC1B,WAAW,MAAM,aAAa;AAAA,EAChC,CAAC;AACD,QAAM,YACJ,MAAM,aACN,IAAI,cAAc;AAAA,IAChB,GAAI,MAAM,UAAU,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;AAAA,IAClD,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;AAAA,EAC9C,CAAC;AACH,QAAM,SAAS,cAAc;AAC7B,QAAM,QAAQ,IAAI,MAAM,CAAC,UAAU,OAAO,KAAK,SAAS,EAAE,MAAM,CAAC,CAAC;AAClE,QAAM,MAAM,CAAC,YAA0B;AAAA,IACrC,KAAK,OAAO;AAAA,IACZ,SAAS,OAAO;AAAA,IAChB,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,EAC7B;AACA,QAAM,QAAuB;AAAA,IAC3B,KAAK,CAAC,OAAO,CAAC,MACZ,MAAM;AAAA,MACJ;AAAA,MACA,OAAO,YAAY,EAAE,OAAO,MAAM,UAAU,SAAS,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AACvC,aAAO;AAAA,IACT,SAAS,OAAO;AACd,UAAK,MAA4B,SAAS,kBAAkB;AAC1D,mBAAW,OAAO,GAAG,MAAM,IAAI,EAAE,EAAE;AACnC,cAAM,IAAI,QAAQ,MAAM,IAAI,EAAE,IAAI,MAAS;AAAA,MAC7C;AACA,YAAM;AAAA,IACR;AAAA,EACF;AACA,QAAM,aAAa,iBAAiB;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,EAAE,MAAM,iBAAiB,cAAc,IAAI,WAAW;AAAA,IAC1D;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EACF,CAAC;AACD,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,IAAI,OAAO;AAAA,IACX,WAAW;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,OAAO;AAAA,MACb;AAAA,MACA,cAAc,CAAC,UAAiB,MAAM,IAAI,SAAS,KAAK;AAAA,IAC1D;AAAA,EACF,CAAC;AACH;AAEO,SAAS,aAAa,QAAsB;AACjD,QAAM,SAAS,YAAY,MAAM;AACjC,MAAI,OAAO,SAAS,UAAU,OAAO,WAAW,aAAa;AAC3D,SAAK,OAAO,YAAS,EAAE,KAAK,CAAC,EAAE,aAAa,MAAM,aAAa,MAAM,CAAC;AAAA,EACxE;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/config.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/config.ts"],
|
|
4
|
-
"sourcesContent": ["import { ZappieError } from \"./errors\";\nimport type { Transport } from \"./transport/types\";\n/** Release-pinned REST contract version, independent of the package version. */\nexport const API_VERSION = \"2026-10-01\";\n/** A storage adapter you can supply to save carts. */\nexport interface StorageLike {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n /** Provide length and key to let the SDK remove expired carts for this store. */\n readonly length?: number;\n key?(index: number): string | null;\n}\n/** Settings for your storefront client. Each client keeps its own credentials and caches. */\nexport type ZappieConfig = {\n store: string;\n key: string;\n branch?: string;\n transport?: Transport;\n baseUrl?: string;\n version?: string;\n fetch?: typeof fetch;\n storage?: StorageLike;\n telemetry?: boolean;\n cart?: { ttl?: number; storageScope?: string };\n};\nexport function validateConfig(config: ZappieConfig, secret = false) {\n if (!config.store?.trim()) {\n throw new ZappieError(\"invalid_request\", \"A storefront slug is required\");\n }\n if (secret && typeof window !== \"undefined\") {\n throw new ZappieError(\n \"invalid_request\",\n \"Secret keys cannot be used in a browser\",\n );\n }\n const pattern = secret ? /^sk_(test|live)_.+$/ : /^pk_(test|live)_.+$/;\n const match = pattern.exec(config.key);\n if (!match) {\n throw new ZappieError(\n \"invalid_request\",\n secret\n ? \"A secret sk_test_ or sk_live_ key is required\"\n : \"Use a publishable pk_test_ or pk_live_ key; secret keys are never accepted by createZappie\",\n );\n }\n return match[1] as \"test\" | \"live\";\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,mBAAmB;AAGrB,IAAM,cAAc;
|
|
4
|
+
"sourcesContent": ["import { ZappieError } from \"./errors\";\nimport type { Transport } from \"./transport/types\";\n/** Release-pinned REST contract version, independent of the package version. */\nexport const API_VERSION = \"2026-10-01\";\n/** A storage adapter you can supply to save carts. */\nexport interface StorageLike {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n /** Provide length and key to let the SDK remove expired carts for this store. */\n readonly length?: number;\n key?(index: number): string | null;\n}\n/** Settings for your storefront client. Each client keeps its own credentials and caches. */\nexport type ZappieConfig = {\n store: string;\n key: string;\n branch?: string;\n transport?: Transport;\n baseUrl?: string;\n version?: string;\n fetch?: typeof fetch;\n /** Route cart quotes through the same-origin customer channel when set. */\n customerBase?: string;\n storage?: StorageLike;\n telemetry?: boolean;\n cart?: { ttl?: number; storageScope?: string };\n};\nexport function validateConfig(config: ZappieConfig, secret = false) {\n if (!config.store?.trim()) {\n throw new ZappieError(\"invalid_request\", \"A storefront slug is required\");\n }\n if (secret && typeof window !== \"undefined\") {\n throw new ZappieError(\n \"invalid_request\",\n \"Secret keys cannot be used in a browser\",\n );\n }\n const pattern = secret ? /^sk_(test|live)_.+$/ : /^pk_(test|live)_.+$/;\n const match = pattern.exec(config.key);\n if (!match) {\n throw new ZappieError(\n \"invalid_request\",\n secret\n ? \"A secret sk_test_ or sk_live_ key is required\"\n : \"Use a publishable pk_test_ or pk_live_ key; secret keys are never accepted by createZappie\",\n );\n }\n return match[1] as \"test\" | \"live\";\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,mBAAmB;AAGrB,IAAM,cAAc;AAyBpB,SAAS,eAAe,QAAsB,SAAS,OAAO;AACnE,MAAI,CAAC,OAAO,OAAO,KAAK,GAAG;AACzB,UAAM,IAAI,YAAY,mBAAmB,+BAA+B;AAAA,EAC1E;AACA,MAAI,UAAU,OAAO,WAAW,aAAa;AAC3C,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,QAAM,UAAU,SAAS,wBAAwB;AACjD,QAAM,QAAQ,QAAQ,KAAK,OAAO,GAAG;AACrC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,MACA,SACI,kDACA;AAAA,IACN;AAAA,EACF;AACA,SAAO,MAAM,CAAC;AAChB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/debug.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { M as Money, a as Menu, B as Branch } from './models-
|
|
1
|
+
import { b as CartLineInput, a as Quote } from './types-CuDvfW9g.js';
|
|
2
|
+
import { M as Money, a as Menu, B as Branch } from './models-Rg5kQUkv.js';
|
|
3
|
+
import { Z as Zappie } from './client-Bm2cCYea.js';
|
|
3
4
|
|
|
4
5
|
type StoredLine = CartLineInput & {
|
|
5
6
|
id: string;
|
package/dist/debug.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { T as Transport, R as RequestCtx,
|
|
2
|
-
export { A as API_VERSION,
|
|
3
|
-
import { S as Store, C as CategoryPage, I as Item, O as OptionGroup, M as Money, a as Menu, B as Branch } from './models-
|
|
4
|
-
export { b as Category, c as Choice, d as Currency, F as Formatters, e as Fulfilment, f as MenuSchedule, g as MenuSection, h as MoneyFormatOptions, i as OpeningTime, j as OptionCondition, P as PaymentMethodKind, k as SpecialHours, V as Variant, l as format, m as money } from './models-
|
|
1
|
+
import { T as Transport, R as RequestCtx, f as MenuFulfilment, g as MenuResponse, h as SelectedMenuRequest, i as SelectedMenuResponse, j as SearchRequest, k as SearchPage, l as MenuVersion, a as ZappieError } from './client-Bm2cCYea.js';
|
|
2
|
+
export { A as API_VERSION, E as ErrorDetails, m as MenuReadOptions, M as MenuResource, n as ReadOptions, S as StorageLike, c as StoreResource, Z as Zappie, b as ZappieClientOptions, b as ZappieConfig, e as ZappieErrorCode, d as ZappieEvents, o as createZappie, p as isZappieError } from './client-Bm2cCYea.js';
|
|
3
|
+
import { S as Store, C as CategoryPage, I as Item, O as OptionGroup, M as Money, a as Menu, B as Branch } from './models-Rg5kQUkv.js';
|
|
4
|
+
export { b as Category, c as Choice, d as Currency, F as Formatters, e as Fulfilment, f as MenuSchedule, g as MenuSection, h as MoneyFormatOptions, i as OpeningTime, j as OptionCondition, P as PaymentMethodKind, k as SpecialHours, V as Variant, l as format, m as money } from './models-Rg5kQUkv.js';
|
|
5
|
+
import { Q as QuoteRequest, g as WireQuote, f as CartIssue, b as CartLineInput, C as CartLine } from './types-CuDvfW9g.js';
|
|
6
|
+
export { h as CartFix, c as CartFulfilment, i as CartIssueCode, d as CartModule, j as CartSnapshot, e as CartState, k as CartSyncAdapter, l as CartSyncDocument, D as DeliveryAddress, a as Quote, m as WireFix, W as WireFulfilment, n as WireIssue, o as WireLine, p as WireMoney } from './types-CuDvfW9g.js';
|
|
5
7
|
|
|
6
8
|
/** REST connection options. A custom fetch can provide tracing or mock responses. */
|
|
7
9
|
type RestTransportOptions = {
|
|
@@ -21,6 +23,7 @@ declare class RestTransport implements Transport {
|
|
|
21
23
|
branchId: string;
|
|
22
24
|
ifNoneMatch?: string;
|
|
23
25
|
metadataOnly?: boolean;
|
|
26
|
+
fulfilment?: MenuFulfilment;
|
|
24
27
|
}): Promise<MenuResponse>;
|
|
25
28
|
getSelectedMenu(ctx: SelectedMenuRequest): Promise<SelectedMenuResponse>;
|
|
26
29
|
search(ctx: SearchRequest): Promise<SearchPage>;
|
|
@@ -32,6 +35,7 @@ declare class RestTransport implements Transport {
|
|
|
32
35
|
}): Promise<CategoryPage>;
|
|
33
36
|
getMenuVersion(ctx: RequestCtx & {
|
|
34
37
|
branchId: string;
|
|
38
|
+
fulfilment?: MenuFulfilment;
|
|
35
39
|
}): Promise<MenuVersion>;
|
|
36
40
|
getItem(ctx: RequestCtx & {
|
|
37
41
|
branchId: string;
|
|
@@ -81,4 +85,4 @@ declare function validateLine(item: Item | undefined, raw: CartLineInput, ctx: {
|
|
|
81
85
|
/** The installed @zappie/sdk version. */
|
|
82
86
|
declare const VERSION: string;
|
|
83
87
|
|
|
84
|
-
export { Branch, CartIssue, CartLine, CartLineInput, CategoryPage, Item, Menu, MenuResponse, MenuVersion, Money, OptionGroup, QuoteRequest, RequestCtx, RestTransport, type RestTransportOptions, SearchPage, SearchRequest, Store, Transport, VERSION, WireQuote, ZappieCartError, ZappieError, estimateUnitPrice, previewItem, resolveSourceMenu, validateLine };
|
|
88
|
+
export { Branch, CartIssue, CartLine, CartLineInput, CategoryPage, Item, Menu, MenuFulfilment, MenuResponse, MenuVersion, Money, OptionGroup, QuoteRequest, RequestCtx, RestTransport, type RestTransportOptions, SearchPage, SearchRequest, Store, Transport, VERSION, WireQuote, ZappieCartError, ZappieError, estimateUnitPrice, previewItem, resolveSourceMenu, validateLine };
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { previewItem } from "./cart/preview.js";
|
|
|
10
10
|
import { estimateUnitPrice } from "./cart/price.js";
|
|
11
11
|
import { resolveSourceMenu } from "./cart/source-menu.js";
|
|
12
12
|
import { validateLine } from "./cart/validate.js";
|
|
13
|
-
var VERSION = true ? "0.1.
|
|
13
|
+
var VERSION = true ? "0.1.5" : "0.0.0-development";
|
|
14
14
|
export {
|
|
15
15
|
API_VERSION,
|
|
16
16
|
RestTransport,
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["// tsup replaces __ZAPPIE_SDK_VERSION__ with package.json's version. Source run\n// without a build, as in a plain Node script, gets the development label.\n// Kept inline, not in a shared module, so the core chunks don't split differently.\ndeclare const __ZAPPIE_SDK_VERSION__: string | undefined;\n\n/** The installed @zappie/sdk version. */\nexport const VERSION: string =\n typeof __ZAPPIE_SDK_VERSION__ === \"string\"\n ? __ZAPPIE_SDK_VERSION__\n : \"0.0.0-development\";\nexport { createZappie } from \"./client\";\nexport type {\n MenuResource,\n ReadOptions,\n StoreResource,\n Zappie,\n ZappieEvents,\n} from \"./client\";\nexport { API_VERSION } from \"./config\";\nexport type {\n StorageLike,\n ZappieConfig as ZappieClientOptions,\n ZappieConfig,\n} from \"./config\";\nexport { ZappieError, isZappieError } from \"./errors\";\nexport type { ErrorDetails, ZappieErrorCode } from \"./errors\";\nexport * from \"./models\";\nexport { format, money } from \"./money\";\nexport type { Currency, Formatters, Money, MoneyFormatOptions } from \"./money\";\nexport { RestTransport } from \"./transport/rest\";\nexport type { RestTransportOptions } from \"./transport/rest\";\nexport type {\n MenuResponse,\n MenuVersion,\n RequestCtx,\n SearchPage,\n SearchRequest,\n Transport,\n} from \"./transport/types\";\n\nexport { ZappieCartError } from \"./cart/errors\";\nexport { previewItem } from \"./cart/preview\";\nexport { estimateUnitPrice } from \"./cart/price\";\nexport { resolveSourceMenu } from \"./cart/source-menu\";\nexport type * from \"./cart/types\";\nexport { validateLine } from \"./cart/validate\";\n"],
|
|
5
|
-
"mappings": ";AAUA,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["// tsup replaces __ZAPPIE_SDK_VERSION__ with package.json's version. Source run\n// without a build, as in a plain Node script, gets the development label.\n// Kept inline, not in a shared module, so the core chunks don't split differently.\ndeclare const __ZAPPIE_SDK_VERSION__: string | undefined;\n\n/** The installed @zappie/sdk version. */\nexport const VERSION: string =\n typeof __ZAPPIE_SDK_VERSION__ === \"string\"\n ? __ZAPPIE_SDK_VERSION__\n : \"0.0.0-development\";\nexport { createZappie } from \"./client\";\nexport type {\n MenuFulfilment,\n MenuReadOptions,\n MenuResource,\n ReadOptions,\n StoreResource,\n Zappie,\n ZappieEvents,\n} from \"./client\";\nexport { API_VERSION } from \"./config\";\nexport type {\n StorageLike,\n ZappieConfig as ZappieClientOptions,\n ZappieConfig,\n} from \"./config\";\nexport { ZappieError, isZappieError } from \"./errors\";\nexport type { ErrorDetails, ZappieErrorCode } from \"./errors\";\nexport * from \"./models\";\nexport { format, money } from \"./money\";\nexport type { Currency, Formatters, Money, MoneyFormatOptions } from \"./money\";\nexport { RestTransport } from \"./transport/rest\";\nexport type { RestTransportOptions } from \"./transport/rest\";\nexport type {\n MenuResponse,\n MenuVersion,\n RequestCtx,\n SearchPage,\n SearchRequest,\n Transport,\n} from \"./transport/types\";\n\nexport { ZappieCartError } from \"./cart/errors\";\nexport { previewItem } from \"./cart/preview\";\nexport { estimateUnitPrice } from \"./cart/price\";\nexport { resolveSourceMenu } from \"./cart/source-menu\";\nexport type * from \"./cart/types\";\nexport { validateLine } from \"./cart/validate\";\n"],
|
|
5
|
+
"mappings": ";AAUA,SAAS,oBAAoB;AAU7B,SAAS,mBAAmB;AAM5B,SAAS,aAAa,qBAAqB;AAE3C,cAAc;AACd,SAAS,QAAQ,aAAa;AAE9B,SAAS,qBAAqB;AAW9B,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAElC,SAAS,oBAAoB;AAzCtB,IAAM,UACX,OACI,UACA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { R as RequestCtx } from '../client-Bm2cCYea.js';
|
|
2
|
+
import '../models-Rg5kQUkv.js';
|
|
3
|
+
import '../types-CuDvfW9g.js';
|
|
4
|
+
|
|
5
|
+
/** Public tracking IDs. Your app decides when consent allows it to load scripts. */
|
|
6
|
+
type Integrations = {
|
|
7
|
+
googleAnalytics?: {
|
|
8
|
+
measurementId: string;
|
|
9
|
+
};
|
|
10
|
+
metaPixel?: {
|
|
11
|
+
pixelId: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
/** A backend that supplies public tracking IDs without loading scripts. */
|
|
15
|
+
type IntegrationsTransport = {
|
|
16
|
+
getIntegrations(ctx: RequestCtx): Promise<Integrations>;
|
|
17
|
+
};
|
|
18
|
+
/** Credentials and optional connection settings for the integrations read. */
|
|
19
|
+
type IntegrationsOptions = {
|
|
20
|
+
key: string;
|
|
21
|
+
baseUrl?: string;
|
|
22
|
+
version?: string;
|
|
23
|
+
fetch?: typeof fetch;
|
|
24
|
+
transport?: IntegrationsTransport;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Create a client that reads public tracking IDs. It never loads tracking scripts.
|
|
28
|
+
* Import this entry when your app needs the IDs, then apply your consent policy.
|
|
29
|
+
*/
|
|
30
|
+
declare function createIntegrations(options: IntegrationsOptions): {
|
|
31
|
+
/** Read enabled integrations. An absent integration has no public ID to use. */
|
|
32
|
+
get(read?: {
|
|
33
|
+
signal?: AbortSignal;
|
|
34
|
+
}): Promise<Integrations>;
|
|
35
|
+
};
|
|
36
|
+
/** The integrations read returned by createIntegrations. */
|
|
37
|
+
type IntegrationsClient = ReturnType<typeof createIntegrations>;
|
|
38
|
+
|
|
39
|
+
export { type Integrations, type IntegrationsClient, type IntegrationsOptions, type IntegrationsTransport, createIntegrations };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/integrations/index.ts
|
|
2
|
+
import { requestWithRetry } from "../internal/customer-http.js";
|
|
3
|
+
import {
|
|
4
|
+
API_VERSION,
|
|
5
|
+
RestTransport,
|
|
6
|
+
validateConfig,
|
|
7
|
+
ZappieError
|
|
8
|
+
} from "../places/sdk.js";
|
|
9
|
+
function createIntegrations(options) {
|
|
10
|
+
validateConfig({ store: "integrations", key: options.key });
|
|
11
|
+
const base = new RestTransport(options).baseUrl;
|
|
12
|
+
return {
|
|
13
|
+
/** Read enabled integrations. An absent integration has no public ID to use. */
|
|
14
|
+
async get(read = {}) {
|
|
15
|
+
const ctx = {
|
|
16
|
+
key: options.key,
|
|
17
|
+
version: options.version ?? API_VERSION,
|
|
18
|
+
...read
|
|
19
|
+
};
|
|
20
|
+
if (options.transport) {
|
|
21
|
+
return options.transport.getIntegrations(ctx);
|
|
22
|
+
}
|
|
23
|
+
const response = await requestWithRetry(
|
|
24
|
+
options.fetch ?? ((input, init) => globalThis.fetch(input, init)),
|
|
25
|
+
`${base}/store/integrations`,
|
|
26
|
+
{
|
|
27
|
+
redirect: "manual",
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${ctx.key}`,
|
|
30
|
+
"Zappie-Version": ctx.version
|
|
31
|
+
},
|
|
32
|
+
...read
|
|
33
|
+
},
|
|
34
|
+
"Could not read storefront integrations"
|
|
35
|
+
);
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
throw new ZappieError(
|
|
38
|
+
"server_error",
|
|
39
|
+
"Could not read storefront integrations",
|
|
40
|
+
{ status: response.status }
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const value = await response.json();
|
|
44
|
+
const record = (value2) => {
|
|
45
|
+
if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) {
|
|
46
|
+
throw new ZappieError(
|
|
47
|
+
"server_error",
|
|
48
|
+
"Invalid storefront integrations"
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return value2;
|
|
52
|
+
};
|
|
53
|
+
const raw = record(value);
|
|
54
|
+
const id = (value2, key) => {
|
|
55
|
+
const result = record(value2)[key];
|
|
56
|
+
if (typeof result !== "string" || !result) {
|
|
57
|
+
throw new ZappieError(
|
|
58
|
+
"server_error",
|
|
59
|
+
"Invalid storefront integration ID"
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
...raw.google_analytics != null ? {
|
|
66
|
+
googleAnalytics: {
|
|
67
|
+
measurementId: id(raw.google_analytics, "measurement_id")
|
|
68
|
+
}
|
|
69
|
+
} : {},
|
|
70
|
+
...raw.meta_pixel != null ? { metaPixel: { pixelId: id(raw.meta_pixel, "pixel_id") } } : {}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
createIntegrations
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/integrations/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { requestWithRetry } from \"../internal/customer-http\";\nimport {\n API_VERSION,\n RestTransport,\n validateConfig,\n ZappieError,\n} from \"../places/sdk\";\nimport type { RequestCtx } from \"../transport/types\";\n\n/** Public tracking IDs. Your app decides when consent allows it to load scripts. */\nexport type Integrations = {\n googleAnalytics?: { measurementId: string };\n metaPixel?: { pixelId: string };\n};\n\n/** A backend that supplies public tracking IDs without loading scripts. */\nexport type IntegrationsTransport = {\n getIntegrations(ctx: RequestCtx): Promise<Integrations>;\n};\n\n/** Credentials and optional connection settings for the integrations read. */\nexport type IntegrationsOptions = {\n key: string;\n baseUrl?: string;\n version?: string;\n fetch?: typeof fetch;\n transport?: IntegrationsTransport;\n};\n\n/**\n * Create a client that reads public tracking IDs. It never loads tracking scripts.\n * Import this entry when your app needs the IDs, then apply your consent policy.\n */\nexport function createIntegrations(options: IntegrationsOptions) {\n validateConfig({ store: \"integrations\", key: options.key });\n const base = new RestTransport(options).baseUrl;\n return {\n /** Read enabled integrations. An absent integration has no public ID to use. */\n async get(read: { signal?: AbortSignal } = {}): Promise<Integrations> {\n const ctx = {\n key: options.key,\n version: options.version ?? API_VERSION,\n ...read,\n };\n if (options.transport) {\n return options.transport.getIntegrations(ctx);\n }\n const response = await requestWithRetry(\n options.fetch ?? ((input, init) => globalThis.fetch(input, init)),\n `${base}/store/integrations`,\n {\n redirect: \"manual\",\n headers: {\n Authorization: `Bearer ${ctx.key}`,\n \"Zappie-Version\": ctx.version,\n },\n ...read,\n },\n \"Could not read storefront integrations\",\n );\n if (!response.ok) {\n throw new ZappieError(\n \"server_error\",\n \"Could not read storefront integrations\",\n { status: response.status },\n );\n }\n const value: unknown = await response.json();\n const record = (value: unknown): Record<string, unknown> => {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new ZappieError(\n \"server_error\",\n \"Invalid storefront integrations\",\n );\n }\n return value as Record<string, unknown>;\n };\n const raw = record(value);\n const id = (value: unknown, key: string): string => {\n const result = record(value)[key];\n if (typeof result !== \"string\" || !result) {\n throw new ZappieError(\n \"server_error\",\n \"Invalid storefront integration ID\",\n );\n }\n return result;\n };\n return {\n ...(raw.google_analytics != null\n ? {\n googleAnalytics: {\n measurementId: id(raw.google_analytics, \"measurement_id\"),\n },\n }\n : {}),\n ...(raw.meta_pixel != null\n ? { metaPixel: { pixelId: id(raw.meta_pixel, \"pixel_id\") } }\n : {}),\n };\n },\n };\n}\n\n/** The integrations read returned by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AAClD,cAAM,SAAS,OAAOA,MAAK,EAAE,GAAG;AAChC,YAAI,OAAO,WAAW,YAAY,CAAC,QAAQ;AACzC,gBAAM,IAAI;AAAA,YACR;AAAA,YACA;AAAA,UACF;AAAA,QACF;AACA,eAAO;AAAA,MACT;AACA,aAAO;AAAA,QACL,GAAI,IAAI,oBAAoB,OACxB;AAAA,UACE,iBAAiB;AAAA,YACf,eAAe,GAAG,IAAI,kBAAkB,gBAAgB;AAAA,UAC1D;AAAA,QACF,IACA,CAAC;AAAA,QACL,GAAI,IAAI,cAAc,OAClB,EAAE,WAAW,EAAE,SAAS,GAAG,IAAI,YAAY,UAAU,EAAE,EAAE,IACzD,CAAC;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["value"]
|
|
7
|
+
}
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { v as validateConfig } from './client-
|
|
3
|
-
import './models-
|
|
1
|
+
import { c as CartFulfilment, W as WireFulfilment } from './types-CuDvfW9g.js';
|
|
2
|
+
export { v as validateConfig } from './client-Bm2cCYea.js';
|
|
3
|
+
import './models-Rg5kQUkv.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Convert a cart fulfilment selection to the API field names used by quotes and checkout.
|
|
@@ -47,6 +47,16 @@ type SpecialHours = {
|
|
|
47
47
|
};
|
|
48
48
|
/** Branch details, opening hours and fulfilment options. */
|
|
49
49
|
type Branch = {
|
|
50
|
+
/** Currency used for this branch's prices. */
|
|
51
|
+
currency?: Currency;
|
|
52
|
+
/** Country code for the branch address. */
|
|
53
|
+
country?: string;
|
|
54
|
+
/** Delivery regions and their quoted base fees. */
|
|
55
|
+
deliveryRegions?: {
|
|
56
|
+
id: string;
|
|
57
|
+
name: string;
|
|
58
|
+
fee: Money;
|
|
59
|
+
}[];
|
|
50
60
|
id: string;
|
|
51
61
|
slug: string;
|
|
52
62
|
name: string;
|
|
@@ -79,6 +89,18 @@ type Branch = {
|
|
|
79
89
|
};
|
|
80
90
|
/** Public storefront identity and branch directory. */
|
|
81
91
|
type Store = {
|
|
92
|
+
/** Search and sharing settings. Absent when the store has no site settings. */
|
|
93
|
+
seo?: {
|
|
94
|
+
titlePattern: string;
|
|
95
|
+
description: string;
|
|
96
|
+
shareImageUrl: string;
|
|
97
|
+
searchConsoleToken: string;
|
|
98
|
+
hidden: boolean;
|
|
99
|
+
redirects: {
|
|
100
|
+
from: string;
|
|
101
|
+
to: string;
|
|
102
|
+
}[];
|
|
103
|
+
};
|
|
82
104
|
id: string;
|
|
83
105
|
slug: string;
|
|
84
106
|
name: string;
|
|
@@ -105,6 +127,8 @@ type MenuSchedule = {
|
|
|
105
127
|
};
|
|
106
128
|
/** A source menu retained when the branch exposes several menus. */
|
|
107
129
|
type MenuSection = {
|
|
130
|
+
/** Fulfilment modes returned for this source menu. */
|
|
131
|
+
fulfilment?: string[];
|
|
108
132
|
/** Placement count before you load items. Omitted when unknown. */
|
|
109
133
|
placementCount?: number;
|
|
110
134
|
paginated?: boolean;
|
|
@@ -146,6 +170,8 @@ type Variant = {
|
|
|
146
170
|
};
|
|
147
171
|
/** Item details and choices, with at least one exact variant. */
|
|
148
172
|
type Item = {
|
|
173
|
+
/** Fulfilment modes returned for this item. */
|
|
174
|
+
fulfilment?: string[];
|
|
149
175
|
/** Exact source placements returned by targeted item reads. */
|
|
150
176
|
placements?: {
|
|
151
177
|
menuId: string;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import '../models-
|
|
1
|
+
export { q as CATALOGUE_MAX_AGE_MS, r as CATALOGUE_MAX_BYTES, s as CatalogueScope, t as SavedCatalogue, u as catalogueDigest, w as catalogueKey, x as createCatalogueStorage, y as createSavedCatalogue } from '../client-Bm2cCYea.js';
|
|
2
|
+
import '../models-Rg5kQUkv.js';
|
|
3
|
+
import '../types-CuDvfW9g.js';
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { VERSION } from '../index.js';
|
|
2
|
-
import { I as Item, a as Menu, S as Store, M as Money } from '../models-
|
|
3
|
-
import {
|
|
2
|
+
import { I as Item, a as Menu, S as Store, M as Money } from '../models-Rg5kQUkv.js';
|
|
3
|
+
import { a as ZappieError, Z as Zappie } from '../client-Bm2cCYea.js';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import { ReactNode } from 'react';
|
|
6
|
+
import { d as CartModule, C as CartLine, c as CartFulfilment, e as CartState, f as CartIssue } from '../types-CuDvfW9g.js';
|
|
6
7
|
|
|
7
8
|
/** Subscribe to storefront identity and branch-directory data. */
|
|
8
9
|
declare function useStore(): {
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { a as Menu, F as Formatters, S as Store } from '../models-
|
|
2
|
-
import {
|
|
1
|
+
import { a as Menu, F as Formatters, S as Store } from '../models-Rg5kQUkv.js';
|
|
2
|
+
import { a as ZappieError, b as ZappieConfig, T as Transport, S as StorageLike, c as StoreResource, M as MenuResource, d as ZappieEvents, C as Cache } from '../client-Bm2cCYea.js';
|
|
3
3
|
export { VERSION } from '../index.js';
|
|
4
|
+
import { d as CartModule, b as CartLineInput } from '../types-CuDvfW9g.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* A URL string, URL object or Request you can parse as a storefront route.
|
|
@@ -210,6 +211,7 @@ declare function createZappieServer({ secretKey, ...config }: ZappieServerConfig
|
|
|
210
211
|
transport?: Transport;
|
|
211
212
|
baseUrl?: string;
|
|
212
213
|
fetch?: typeof fetch;
|
|
214
|
+
customerBase?: string;
|
|
213
215
|
storage?: StorageLike;
|
|
214
216
|
cart?: {
|
|
215
217
|
ttl?: number;
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { T as Transport,
|
|
2
|
-
import { S as Store, a as Menu, F as Formatters } from '../models-
|
|
1
|
+
import { T as Transport, e as ZappieErrorCode, S as StorageLike, c as StoreResource, M as MenuResource, d as ZappieEvents, C as Cache } from '../client-Bm2cCYea.js';
|
|
2
|
+
import { S as Store, a as Menu, F as Formatters } from '../models-Rg5kQUkv.js';
|
|
3
3
|
export { VERSION } from '../index.js';
|
|
4
|
+
import { d as CartModule, b as CartLineInput } from '../types-CuDvfW9g.js';
|
|
4
5
|
|
|
5
6
|
/** Store and branch menus supplied to the deterministic mock transport. */
|
|
6
7
|
type MockFixtures = {
|
|
@@ -24,6 +25,7 @@ declare function createMockZappie(input: MockFixtures, opts?: MockOptions): Read
|
|
|
24
25
|
transport?: Transport;
|
|
25
26
|
baseUrl?: string;
|
|
26
27
|
fetch?: typeof fetch;
|
|
28
|
+
customerBase?: string;
|
|
27
29
|
storage?: StorageLike;
|
|
28
30
|
cart?: {
|
|
29
31
|
ttl?: number;
|
|
@@ -248,6 +248,7 @@ function mapItem(value) {
|
|
|
248
248
|
variants,
|
|
249
249
|
optionGroups,
|
|
250
250
|
tags: list(v.tags ?? []).map(text),
|
|
251
|
+
...v.fulfilment !== void 0 ? { fulfilment: list(v.fulfilment).map(text) } : {},
|
|
251
252
|
...opt("stockLabel", v.stock_label, isString),
|
|
252
253
|
...v.promo !== void 0 ? { promo: mapPromo(v.promo) } : {},
|
|
253
254
|
...opt("description", v.description, isString),
|
|
@@ -288,6 +289,7 @@ function mapMenu(value, branchId) {
|
|
|
288
289
|
id: text(m.id),
|
|
289
290
|
name: text(m.name),
|
|
290
291
|
categoryIds,
|
|
292
|
+
...m.fulfilment !== void 0 ? { fulfilment: list(m.fulfilment).map(text) } : {},
|
|
291
293
|
...m.placement_count !== void 0 ? { placementCount: m.placement_count } : {},
|
|
292
294
|
...opt("paginated", m.paginated, isBoolean),
|
|
293
295
|
...s ? { schedule: s } : {},
|
|
@@ -321,6 +323,23 @@ function mapMenu(value, branchId) {
|
|
|
321
323
|
...menus.length === 1 && menus[0].schedule ? { schedule: menus[0].schedule } : {}
|
|
322
324
|
};
|
|
323
325
|
}
|
|
326
|
+
function mapSeo(value) {
|
|
327
|
+
const seo = record(value);
|
|
328
|
+
if (typeof seo.hidden !== "boolean") {
|
|
329
|
+
throw new ZappieError("server_error", "Invalid store search visibility");
|
|
330
|
+
}
|
|
331
|
+
return {
|
|
332
|
+
titlePattern: text(seo.title_pattern),
|
|
333
|
+
description: text(seo.description),
|
|
334
|
+
shareImageUrl: text(seo.share_image_url),
|
|
335
|
+
searchConsoleToken: text(seo.search_console_token),
|
|
336
|
+
hidden: seo.hidden,
|
|
337
|
+
redirects: list(seo.redirects).map((raw) => {
|
|
338
|
+
const redirect = record(raw);
|
|
339
|
+
return { from: text(redirect.from), to: text(redirect.to) };
|
|
340
|
+
})
|
|
341
|
+
};
|
|
342
|
+
}
|
|
324
343
|
export {
|
|
325
344
|
hours,
|
|
326
345
|
isBoolean,
|
|
@@ -329,6 +348,7 @@ export {
|
|
|
329
348
|
mapItem,
|
|
330
349
|
mapMenu,
|
|
331
350
|
mapMoney,
|
|
351
|
+
mapSeo,
|
|
332
352
|
opt,
|
|
333
353
|
record,
|
|
334
354
|
text
|