@fayz-ai/sdk 0.11.0 → 0.15.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/dist/chunk-M5CVCRIL.js +135 -0
- package/dist/chunk-M5CVCRIL.js.map +1 -0
- package/dist/{chunk-5D2B7R3U.js → chunk-QLTIO3QK.js} +76 -8
- package/dist/chunk-QLTIO3QK.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/lib/app-shell-pwa.d.ts +13 -0
- package/dist/lib/app-shell-pwa.d.ts.map +1 -0
- package/dist/lib/boot-skeleton.d.ts +21 -8
- package/dist/lib/boot-skeleton.d.ts.map +1 -1
- package/dist/lib/dedupe-fetch.d.ts.map +1 -1
- package/dist/release-channels.js +1 -1
- package/dist/release-channels.json +93 -93
- package/dist/shop.d.ts +29 -1
- package/dist/shop.d.ts.map +1 -1
- package/dist/shop.js +1 -1
- package/dist/vite.d.ts +10 -0
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +299 -29
- package/dist/vite.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-5D2B7R3U.js.map +0 -1
- package/dist/chunk-U7SC2YFQ.js +0 -135
- package/dist/chunk-U7SC2YFQ.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/dedupe-fetch.ts","../src/shop.ts"],"names":["hit","options","row"],"mappings":";;;AAWA,IAAM,YAAA,GAAe;AAAA,EACnB,eAAA;AAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,gBAAA;AAAA;AAAA,EACA,iBAAA;AAAA,EACA,OAAA;AAAA;AAAA,EACA,YAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA,cAAA;AAAA;AAAA,EACA,eAAA;AAAA;AAAA;AAAA;AAAA,EAIA;AACF,CAAA;AAuBA,IAAI,SAAA,GAAY,CAAA;AAChB,IAAM,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sD,GAAG,CAAA;AAAA,IACnF,CAAA;AAAA,IACA,MAAM,aAAA,GAAgB;AACpB,MAAA,MAAM,IAAI,aAAA,CAAc,mDAAA,EAAqD,GAAG,CAAA;AAAA,IAClF,CAAA;AAAA,IACA,MAAM,WAAA,GAAc;AAClB,MAAA,MAAM,IAAI,aAAA,CAAc,mDAAA,EAAqD,GAAG,CAAA;AAAA,IAClF,CAAA;AAAA,IACA,MAAM,cAAA,GAAiB;AACrB,MAAA,MAAM,IAAI,aAAA,CAAc,oDAAA,EAAsD,GAAG,CAAA;AAAA,IACnF,CAAA;AAAA,IACA,MAAM,cAAA,GAAiB;AACrB,MAAA,MAAM,IAAI,aAAA,CAAc,oDAAA,EAAsD,GAAG,CAAA;AAAA,IACnF,CAAA;AAAA,IACA,MAAM,cAAA,GAAiB;AACrB,MAAA,MAAM,IAAI,aAAA,CAAc,qDAAA,EAAuD,GAAG,CAAA;AAAA,IACpF;AAAA,GACF;AACF","file":"chunk-QLTIO3QK.js","sourcesContent":["/**\n * Request de-duplication at the transport boundary: while a GET is in flight,\n * an identical GET joins it instead of opening a second connection.\n *\n * Above the transport it is already too late — by the time two components have\n * called `list()`, there are two requests. Nothing is cached (the entry dies\n * when the response settles), so this cannot serve stale data: the TTL cache in\n * @fayz-ai/core decides whether to ask, this decides what one question costs.\n */\n\n/** Headers that change the response body, so they belong in the key. */\nconst DEFAULT_VARY = [\n 'authorization', // a different user sees different rows under RLS\n 'apikey',\n 'accept',\n 'accept-profile', // PostgREST schema selector\n 'content-profile',\n 'range', // pagination window\n 'range-unit',\n 'prefer', // count=exact changes Content-Range\n 'x-fayz-store', // storefront tenant scope\n 'x-fayz-tenant',\n // The active unit. Load-bearing, not decorative: two reads of the SAME url\n // under different units are different questions, and without this line the\n // second one joins the first and a franchisee is handed another unit's rows.\n 'x-fayz-unit',\n]\n\nexport interface DedupeFetchOptions {\n /** Extra request headers that make two same-URL reads different. */\n varyHeaders?: string[]\n /** Called when a request joined one already in flight. For diagnostics. */\n onCollapse?: (key: string) => void\n}\n\nexport interface DedupeStats {\n /** Requests that never reached the network because they joined another. */\n collapsed: number\n /** Requests currently in flight and joinable. */\n inFlight: number\n}\n\ninterface BufferedResponse {\n status: number\n statusText: string\n headers: [string, string][]\n body: ArrayBuffer\n}\n\nlet collapsed = 0\nconst flights = new Map<string, Promise<BufferedResponse>>()\n\nexport function getDedupeStats(): DedupeStats {\n return { collapsed, inFlight: flights.size }\n}\n\n/** Test seam — drops in-flight bookkeeping and the counter. */\nexport function resetDedupeStats(): void {\n collapsed = 0\n flights.clear()\n}\n\nfunction headerValue(headers: HeadersInit | undefined, name: string): string {\n if (!headers) return ''\n if (headers instanceof Headers) return headers.get(name) ?? ''\n if (Array.isArray(headers)) {\n const hit = headers.find(([k]) => k.toLowerCase() === name)\n return hit?.[1] ?? ''\n }\n const hit = Object.entries(headers).find(([k]) => k.toLowerCase() === name)\n return hit ? String(hit[1]) : ''\n}\n\n/** 204/205/304 and HEAD must not carry a body — constructing one throws. */\nfunction bodylessStatus(status: number): boolean {\n return status === 204 || status === 205 || status === 304\n}\n\nexport function createDedupedFetch(\n // Wrapped rather than passed by reference: a detached `fetch` loses its\n // receiver, which some runtimes reject as an illegal invocation.\n baseFetch: typeof fetch = (...args) => fetch(...args),\n options: DedupeFetchOptions = {},\n): typeof fetch {\n const vary = [...DEFAULT_VARY, ...(options.varyHeaders ?? []).map((h) => h.toLowerCase())]\n\n return async function dedupedFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {\n const method = (init?.method ?? (input instanceof Request ? input.method : 'GET')).toUpperCase()\n const url = typeof input === 'string' ? input : input instanceof URL ? input.toString() : input.url\n\n // Writes are never shared; a Request body may be a one-shot stream, and an\n // abort signal belongs to one caller — cancelling a shared flight would\n // break every other caller waiting on it.\n //\n // These are escape hatches, so it matters that they stay shut for the reads\n // that actually run: supabase-js passes a string URL and `signal: undefined`\n // (present as a key, falsy as a value). If that ever changes, sharing turns\n // itself off in silence — `admin/test/data/client-dedupe.test.ts` pins it so\n // the change reports itself. The fix then is to join the flight with a\n // per-caller signal and abort only when every joined caller has, NOT to drop\n // the guard: one component unmounting must never cancel another's data.\n if ((method !== 'GET' && method !== 'HEAD') || init?.signal || input instanceof Request) {\n return baseFetch(input as RequestInfo, init)\n }\n\n const key = [method, url, ...vary.map((h) => headerValue(init?.headers, h))].join('\\n')\n\n let flight = flights.get(key)\n if (flight) {\n collapsed++\n options.onCollapse?.(key)\n } else {\n flight = (async () => {\n const res = await baseFetch(input as RequestInfo, init)\n return {\n status: res.status,\n statusText: res.statusText,\n headers: [...res.headers.entries()],\n // Buffered so each caller can be handed its own Response: a body can\n // only be read once, and `clone()` on a consumed response throws.\n body: bodylessStatus(res.status) || method === 'HEAD' ? new ArrayBuffer(0) : await res.arrayBuffer(),\n }\n })()\n flights.set(key, flight)\n // Settled means \"no longer joinable\" — including failures, so a rejected\n // flight never poisons the next attempt.\n void flight.catch(() => {}).finally(() => flights.delete(key))\n }\n\n const buffered = await flight\n const hasBody = !bodylessStatus(buffered.status) && method !== 'HEAD'\n return new Response(hasBody ? buffered.body.slice(0) : null, {\n status: buffered.status,\n statusText: buffered.statusText,\n headers: buffered.headers,\n })\n }\n}\n","import { resetDeprecationWarnings, warnDeprecated } from './deprecations'\nimport { createDedupedFetch } from './lib/dedupe-fetch'\n\nexport interface FayzShopProviderOptions {\n supabaseUrl?: string\n publishableKey?: string\n storeId?: string\n /**\n * Where the pool's edge functions live. Defaults to `${supabaseUrl}/functions/v1`,\n * which is right in every deployed environment.\n *\n * It exists for the one case that default cannot serve: a function under\n * development runs on the developer's machine (`supabase functions serve`),\n * and it has to be the LOCAL copy that runs, because a deployed function\n * cannot reach a platform API on localhost — and tunnelling the credential\n * broker onto the public internet to work around that is not a trade anyone\n * should make for a dev loop.\n */\n functionsUrl?: string\n apiBaseUrl?: string\n projectId?: string\n mode?: 'broker' | 'supabase'\n productMetadata?: FayzShopProductMetadataOverlay[]\n fetcher?: typeof fetch\n}\n\n/**\n * The signed-in shopper's access token, when there is one.\n *\n * PostgREST decides who you are from the Authorization bearer, and this client\n * used to send the publishable key unconditionally — so every request arrived\n * as `anon` even with a customer logged in. auth.uid() was therefore always\n * null, which is why shop_resolve_customer never linked auth_user_id (0 of 519\n * customers in the pool) and why the self-read policy on public.addresses could\n * never match a row.\n *\n * A module-level resolver rather than a per-app option on purpose: the wiring\n * is done once by initStorefrontRuntime, so a storefront cannot forget it and\n * silently fall back to anonymous. Mirrors setShopTenantResolver in plugin-shop.\n */\ntype AccessTokenResolver = () => string | null | undefined\n\nlet _accessTokenResolver: AccessTokenResolver | null = null\n\nexport function setShopAccessTokenResolver(resolver: AccessTokenResolver | null): void {\n _accessTokenResolver = resolver\n}\n\n/**\n * The connector's own budget, restated here because this package cannot import\n * the definition that declares it. Keep the two in step — see\n * MELHOR_ENVIO_LATENCY_BUDGET_MS for why it is 2500 and not the 1000 it was\n * guessed at: a real carrier round trip costs ~610ms before anything of ours,\n * so a one-second budget aborted every genuine quote and quietly turned the\n * feature off.\n */\nconst CARRIER_QUOTE_BUDGET_MS = 2500\n\n/**\n * Joins the quote to the service inside a single option id.\n *\n * A colon would collide with nothing today and with a carrier's own id format\n * eventually; `::` is not a character sequence Melhor Envio emits.\n */\nconst CARRIER_OPTION_SEPARATOR = '::'\n\n/**\n * Declared here rather than imported, like ShippingQuoteOption below: this\n * package is the storefront's only dependency and must not drag @fayz-ai/shop\n * into a published-mode install. The shape is asserted against the real\n * provider by the fleet typecheck.\n */\ninterface PaymentChargeResult {\n state: 'pending' | 'paid' | 'refunded' | 'failed' | 'unopened'\n orderId: string\n reference?: string | null\n charge?: { emv: string; qrcodeBase64: string | null; qrcodeUrl: string | null; expiresAt: string } | null\n providerStatus?: string | null\n}\n\n/** Same reason as PaymentChargeResult: declared, not imported. */\ninterface CheckoutSessionInput {\n items: Array<{ productId: string; variantId?: string | null; quantity: number; optionsLabel?: string | null }>\n customer: { name?: string | null; email: string; document?: string | null }\n shippingAddress?: Record<string, unknown> | null\n discountCode?: string | null\n paymentMethod?: string\n /** O adquirente que deve cobrar. Ausente cai na AbacatePay. */\n provider?: string | null\n /** Para onde o adquirente devolve o comprador que pagou fora da loja. */\n returnUrl?: string | null\n /** Em vez de cobrar agora, devolve um link para o lojista mandar ao cliente. */\n asLink?: boolean\n}\n\ninterface CheckoutSession {\n sessionId: string\n total: number\n charge: { emv: string; qrcodeBase64: string | null; qrcodeUrl: string | null; expiresAt: string } | null\n state: 'open' | 'paid' | 'failed' | 'expired'\n /** Quem abriu esta cobrança — devolvido para que a consulta bata na função certa. */\n provider?: string | null\n /** A página do adquirente: o link que se manda, e para onde o cartão vai. */\n paymentUrl?: string | null\n /** O que foi realmente aberto, quando difere do que o comprador pediu. */\n method?: string | null\n}\n\ninterface CheckoutSettlement {\n state: 'open' | 'paid' | 'failed' | 'expired' | 'unknown'\n orderId?: string | null\n reason?: string | null\n}\n\n/**\n * Which edge function charges for which acquirer — declared locally for the same\n * reason `ShippingQuoteOption` below is: @fayz-ai/sdk depends on nothing, and\n * this package is the storefront's only dependency.\n *\n * The canonical table is `@fayz-ai/shop`'s `data/checkout-gateways.ts`, and this\n * is the second copy rather than a shared import. What keeps them honest is that\n * a divergence is visible where it costs: a slug here with no pair there is a\n * checkout that opens a charge the admin cannot settle, and the reverse is a\n * storefront that offers no QR for a gateway the store has connected. Add an\n * acquirer to BOTH.\n */\nconst CHECKOUT_GATEWAYS: Record<string, { open: string; settle: string; link: boolean }> = {\n abacatepay: { open: 'shop-checkout-open', settle: 'shop-checkout-settle', link: false },\n vindi: { open: 'vindi-checkout-open', settle: 'vindi-checkout-settle', link: true },\n}\n\n/** The pair for an acquirer, or null when it cannot take money online here. */\nfunction checkoutGateway(provider: string | null | undefined) {\n const slug = String(provider ?? '').trim()\n if (!slug) return null\n return CHECKOUT_GATEWAYS[slug] ?? null\n}\n\n/** The subset of `ShippingQuoteOption` this package produces, declared locally\n * because @fayz-ai/sdk depends on nothing — see quoteShipping. */\ninterface ShippingQuoteOption {\n zoneId: string\n name: string\n carrier?: string\n rate: number\n baseRate: number\n freeAbove?: number | null\n etaMinDays?: number\n etaMaxDays?: number\n free: boolean\n}\n\n/**\n * What is in the cart, for the box the carrier prices.\n *\n * A resolver rather than an argument because the call site that matters —\n * `delivery.store.resolve(postalCode, subtotal)` — has been passing a postcode\n * and a subtotal since before any carrier existed, and every storefront in the\n * wild calls it that way. Wiring it here is done once by the runtime, exactly\n * like setShopAccessTokenResolver above.\n *\n * Unset is a supported state: the quote function falls back to the store's\n * package defaults, which is what makes the first quote work for a catalogue\n * nobody has measured yet.\n */\nexport interface ShippingQuoteItem {\n quantity: number\n weight?: number | null\n /** As the merchant typed it ('kg', 'g', 'lb'). The function converts; until\n * FAY-1407 it assumed kg, so a catalogue measured in grams quoted parcels a\n * thousand times too heavy. */\n weightUnit?: string | null\n /** Centimetres. The column names carry the unit, so there is no second one. */\n height?: number | null\n width?: number | null\n length?: number | null\n /**\n * A embalagem que o LOJISTA escolheu para este produto (0047). Quando vem\n * preenchida ela manda: a escolha dele não é uma sugestão para o algoritmo\n * que procura a menor caixa em que o carrinho cabe.\n */\n packageId?: string | null\n /** False keeps the line out of the box entirely — and a cart where every\n * line is false never reaches a carrier. */\n isPhysical?: boolean\n // Identity, only so the function can name the line that has no measurements\n // in its log. \"Algum produto sem medida\" is not something a merchant can act\n // on; \"Camiseta GG\" is.\n productId?: string\n variantId?: string\n name?: string\n sku?: string | null\n}\n\ntype ShippingItemsResolver = () => ShippingQuoteItem[]\n\nlet _shippingItemsResolver: ShippingItemsResolver | null = null\n\nexport function setShopShippingItemsResolver(resolver: ShippingItemsResolver | null): void {\n _shippingItemsResolver = resolver\n}\n\n/**\n * \"A loja quer que a gente pergunte a um gateway?\"\n *\n * A resposta é do LOJISTA (`StoreSettings.carrierQuotes`) e vive no navegador,\n * que já carrega a política no boot. Este pacote não a lê sozinho — daí o mesmo\n * encaixe do carrinho: quem monta a vitrine registra o resolvedor.\n *\n * `undefined` = não decidido, e não decidido pergunta (é como sempre foi).\n * `false` é a escolha explícita de quem calcula pelas próprias faixas: enquanto\n * ninguém lia isto, marcar \"eu mesmo calculo\" não mudava NADA no checkout, e a\n * cotação da transportadora continuava ganhando das faixas dela.\n */\ntype CarrierQuotesResolver = () => boolean | undefined\n\nlet _carrierQuotesResolver: CarrierQuotesResolver | null = null\n\nexport function setShopCarrierQuotesResolver(resolver: CarrierQuotesResolver | null): void {\n _carrierQuotesResolver = resolver\n}\n\nfunction mayAskCarrier(): boolean {\n try {\n return _carrierQuotesResolver?.() !== false\n } catch {\n return true\n }\n}\n\nfunction getCartItemsForQuote(): ShippingQuoteItem[] {\n try {\n return _shippingItemsResolver?.() ?? []\n } catch {\n return []\n }\n}\n\n/**\n * A cart that has lines and not one of them ships.\n *\n * An EMPTY list is not this: it is either an empty cart or a storefront that\n * never installed the resolver, and both must keep quoting the way they do\n * today — the product page asks for a price before anything is added.\n */\nfunction cartIsFullyDigital(items: ShippingQuoteItem[]): boolean {\n return items.length > 0 && items.every((item) => item.isPhysical === false)\n}\n\nexport interface FayzShopProductMetadataOverlay {\n sku?: string | null\n slug?: string | null\n metadata: Record<string, unknown>\n}\n\nexport type FayzShopProductStatus = 'draft' | 'active' | 'archived'\nexport type FayzShopOrderStatus = 'open' | 'archived' | 'cancelled'\nexport type FayzShopFinancialStatus = 'pending' | 'paid' | 'partially_paid' | 'refunded' | 'partially_refunded' | 'voided'\nexport type FayzShopFulfillmentStatus = 'unfulfilled' | 'partially_fulfilled' | 'fulfilled'\n\nexport interface FayzShopListProductsOptions {\n status?: FayzShopProductStatus\n categoryId?: string\n search?: string\n slug?: string\n limit?: number\n offset?: number\n orderBy?: 'name' | 'price' | 'created_at' | 'sort_order'\n order?: 'asc' | 'desc'\n}\n\nexport interface FayzShopListOrdersOptions {\n status?: FayzShopOrderStatus\n financialStatus?: FayzShopFinancialStatus\n fulfillmentStatus?: FayzShopFulfillmentStatus\n customerId?: string\n customerEmail?: string\n search?: string\n limit?: number\n offset?: number\n}\n\nexport interface FayzShopListCustomersOptions {\n search?: string\n limit?: number\n offset?: number\n}\n\nexport interface FayzShopListDiscountsOptions {\n status?: string\n type?: string\n search?: string\n limit?: number\n offset?: number\n}\n\ninterface ProductImageRow {\n id: string\n product_id: string\n url: string\n alt_text?: string | null\n sort_order?: number | null\n is_primary?: boolean | null\n created_at?: string | null\n}\n\ninterface ProductRow {\n id: string\n tenant_id: string\n name: string\n slug?: string | null\n description?: string | null\n price?: number | null\n compare_at_price?: number | null\n currency?: string | null\n status?: FayzShopProductStatus | null\n inventory_count?: number | null\n sku?: string | null\n sort_order?: number | null\n metadata?: Record<string, unknown> | null\n images?: ProductImageRow[] | null\n category_id?: string | null\n category?: { name?: string | null } | null\n is_physical?: boolean | null\n weight?: number | null\n weight_unit?: string | null\n height_cm?: number | string | null\n width_cm?: number | string | null\n length_cm?: number | string | null\n created_at?: string | null\n updated_at?: string | null\n}\n\n/** PostgREST hands `numeric` back as a string. Null stays null: \"not measured\"\n * is the state the packing code degrades on, and 0 would read as measured. */\nconst numOrNull = (value: unknown): number | null => {\n if (value == null || value === '') return null\n const n = Number(value)\n return Number.isFinite(n) ? n : null\n}\n\ninterface StoreCategoryMetadata {\n id?: string | null\n name?: string | null\n slug?: string | null\n description?: string | null\n imageUrl?: string | null\n sortOrder?: number | null\n}\n\ninterface CategoryRow {\n id: string\n tenant_id?: string | null\n name: string\n slug?: string | null\n description?: string | null\n parent_id?: string | null\n sort_order?: number | null\n image_url?: string | null\n created_at?: string | null\n}\n\ninterface OrderItemRow {\n id: string\n order_id: string\n product_id?: string | null\n name: string\n sku?: string | null\n quantity?: number | null\n unit_price?: number | null\n total?: number | null\n image_url?: string | null\n}\n\ninterface OrderRow {\n id: string\n tenant_id: string\n order_number?: number | null\n status?: FayzShopOrderStatus | null\n financial_status?: FayzShopFinancialStatus | null\n fulfillment_status?: FayzShopFulfillmentStatus | null\n currency?: string | null\n subtotal?: number | null\n tax_total?: number | null\n discount_total?: number | null\n shipping_total?: number | null\n total?: number | null\n customer_id?: string | null\n customer_name?: string | null\n customer_email?: string | null\n discount_code?: string | null\n notes?: string | null\n shipping_address?: Record<string, string | undefined> | null\n payment_method_kind?: string | null\n paid_at?: string | null\n items?: OrderItemRow[] | null\n /** Only from shop_get_order (0052) — the list endpoints do not carry it. */\n shipments?: OrderShipmentRow[] | null\n created_at?: string | null\n updated_at?: string | null\n}\n\n/** One non-cancelled shipment, as the buyer's own window returns it. */\ninterface OrderShipmentRow {\n id: string\n status?: string | null\n carrier?: string | null\n tracking_code?: string | null\n tracking_url?: string | null\n shipped_at?: string | null\n estimated_delivery_at?: string | null\n delivered_at?: string | null\n}\n\n/** One row of shop_quote_shipping's result set. */\ninterface ShippingQuoteRow {\n zone_id: string\n name: string\n carrier: string | null\n rate: number | string | null\n base_rate: number | string | null\n free_above: number | string | null\n eta_min_days: number | null\n eta_max_days: number | null\n free: boolean | null\n}\n\n/** public.addresses, as PostgREST returns it. */\ninterface AddressRow {\n id: string\n label: string | null\n recipient: string | null\n phone: string | null\n postal_code: string | null\n street: string | null\n number: string | null\n complement: string | null\n district: string | null\n city: string | null\n state: string | null\n country: string | null\n is_default: boolean | null\n}\n\ninterface CustomerRow {\n id: string\n tenant_id: string\n first_name: string\n last_name?: string | null\n email?: string | null\n phone?: string | null\n document?: string | null\n notes?: string | null\n orders_count?: number | null\n total_spent?: number | null\n created_at?: string | null\n updated_at?: string | null\n}\n\ninterface DiscountRow {\n id: string\n tenant_id: string\n title: string\n code?: string | null\n type: string\n method?: string | null\n value?: number | null\n usage_limit?: number | null\n once_per_customer?: boolean | null\n starts_at?: string | null\n ends_at?: string | null\n status?: string | null\n times_used?: number | null\n created_at?: string | null\n updated_at?: string | null\n}\n\nexport class FayzShopError extends Error {\n constructor(\n message: string,\n readonly status: number,\n readonly responseBody?: unknown,\n ) {\n super(message)\n this.name = 'FayzShopError'\n }\n}\n\nfunction normalizeBaseUrl(url: string): string {\n return url.replace(/\\/+$/, '')\n}\n\nfunction slugify(name: string): string {\n return name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')\n}\n\nfunction nowIso(): string {\n return new Date().toISOString()\n}\n\nfunction present<T>(value: T | null | undefined, fallback: T): T {\n return value == null ? fallback : value\n}\n\nfunction productMetadataKey(kind: 'sku' | 'slug', value: string): string {\n return `${kind}:${value.toLowerCase()}`\n}\n\n/** The registry id this shim answers to. */\nexport const PRODUCT_METADATA_OVERLAY_DEPRECATION = 'shop.provider.productMetadata'\n\n/** Test seam — re-arms the once-per-session overlay deprecation warning. */\nexport function resetProductMetadataOverlayDeprecationWarning(): void {\n resetDeprecationWarnings()\n}\n\nfunction buildProductMetadataOverlay(overlays: FayzShopProductMetadataOverlay[] | undefined) {\n const map = new Map<string, Record<string, unknown>>()\n for (const overlay of overlays ?? []) {\n if (overlay.sku) map.set(productMetadataKey('sku', overlay.sku), overlay.metadata)\n if (overlay.slug) map.set(productMetadataKey('slug', overlay.slug), overlay.metadata)\n }\n // I10 deprecation shim (spine M5/M10): the overlay still renders, but it is\n // no longer the source of product options — the variant tables are (0028;\n // read through getProductVariants / products.bySlug). The message is BUILT\n // FROM the registry row, so the warning and the row it documents cannot\n // drift, and the replacement is named by construction (I2). Logged once, not\n // per request, so the signal survives without burying everything else.\n if (map.size > 0) {\n warnDeprecated(\n PRODUCT_METADATA_OVERLAY_DEPRECATION,\n `${map.size} product(s) overlaid —`,\n )\n }\n return map\n}\n\nfunction asUuid(value: string | null | undefined): string | null {\n if (!value) return null\n return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value)\n ? value\n : null\n}\n\nfunction rowToImage(row: ProductImageRow) {\n return {\n id: row.id,\n productId: row.product_id,\n url: row.url,\n altText: row.alt_text ?? null,\n sortOrder: row.sort_order ?? 0,\n isPrimary: row.is_primary ?? false,\n createdAt: row.created_at ?? nowIso(),\n }\n}\n\nfunction getProductMetadata(row: ProductRow, overlay?: Map<string, Record<string, unknown>>): Record<string, unknown> {\n const metadata = row.metadata ?? {}\n const bySlug = overlay?.get(productMetadataKey('slug', row.slug ?? slugify(row.name)))\n const bySku = row.sku ? overlay?.get(productMetadataKey('sku', row.sku)) : undefined\n return { ...(bySlug ?? {}), ...(bySku ?? {}), ...metadata }\n}\n\nfunction getStoreCategory(row: ProductRow, overlay?: Map<string, Record<string, unknown>>): StoreCategoryMetadata | null {\n const raw = getProductMetadata(row, overlay).fayzStoreCategory\n return raw && typeof raw === 'object' ? raw as StoreCategoryMetadata : null\n}\n\nfunction rowToProduct(row: ProductRow, overlay?: Map<string, Record<string, unknown>>) {\n const metadata = getProductMetadata(row, overlay)\n const storeCategory = getStoreCategory(row, overlay)\n return {\n id: row.id,\n tenantId: row.tenant_id,\n name: row.name,\n slug: row.slug ?? slugify(row.name),\n description: row.description ?? null,\n price: row.price ?? 0,\n compareAtPrice: row.compare_at_price ?? null,\n currency: row.currency ?? 'BRL',\n status: row.status ?? 'active',\n inventoryCount: row.inventory_count ?? 0,\n sku: row.sku ?? null,\n sortOrder: row.sort_order ?? 0,\n metadata,\n images: Array.isArray(row.images) ? row.images.map(rowToImage) : [],\n categoryId: storeCategory?.id ?? row.category_id ?? null,\n categoryName: storeCategory?.name ?? row.category?.name ?? null,\n isPhysical: row.is_physical ?? true,\n weight: row.weight ?? null,\n weightUnit: row.weight_unit ?? 'kg',\n heightCm: numOrNull(row.height_cm),\n widthCm: numOrNull(row.width_cm),\n lengthCm: numOrNull(row.length_cm),\n createdAt: row.created_at ?? nowIso(),\n updatedAt: row.updated_at ?? row.created_at ?? nowIso(),\n }\n}\n\nfunction rowToCategory(row: CategoryRow) {\n return {\n id: row.id,\n tenantId: row.tenant_id ?? 'global',\n name: row.name,\n slug: row.slug ?? slugify(row.name),\n description: row.description ?? null,\n parentId: row.parent_id ?? null,\n sortOrder: row.sort_order ?? 0,\n imageUrl: row.image_url ?? null,\n createdAt: row.created_at ?? nowIso(),\n }\n}\n\nfunction storeCategoryToCategory(category: StoreCategoryMetadata, tenantId: string) {\n const name = category.name ?? 'Category'\n return {\n id: category.id ?? slugify(name),\n tenantId,\n name,\n slug: category.slug ?? slugify(name),\n description: category.description ?? null,\n parentId: null,\n sortOrder: category.sortOrder ?? 0,\n imageUrl: category.imageUrl ?? null,\n createdAt: nowIso(),\n }\n}\n\nfunction deriveStoreCategories(products: ProductRow[], tenantId: string) {\n const categories = new Map<string, ReturnType<typeof storeCategoryToCategory>>()\n for (const product of products) {\n const category = getStoreCategory(product)\n if (!category?.name && !category?.id) continue\n const mapped = storeCategoryToCategory(category, tenantId)\n categories.set(mapped.id, mapped)\n }\n return [...categories.values()].sort((a, b) => a.sortOrder - b.sortOrder || a.name.localeCompare(b.name))\n}\n\nfunction rowToOrder(row: OrderRow) {\n return {\n id: row.id,\n tenantId: row.tenant_id,\n orderNumber: row.order_number ?? 0,\n status: row.status ?? 'open',\n financialStatus: row.financial_status ?? 'pending',\n fulfillmentStatus: row.fulfillment_status ?? 'unfulfilled',\n currency: row.currency ?? 'BRL',\n subtotal: row.subtotal ?? 0,\n taxTotal: row.tax_total ?? 0,\n discountTotal: row.discount_total ?? 0,\n shippingTotal: row.shipping_total ?? 0,\n total: row.total ?? 0,\n customerId: row.customer_id ?? null,\n customerName: row.customer_name ?? null,\n customerEmail: row.customer_email ?? null,\n discountCode: row.discount_code ?? null,\n notes: row.notes ?? null,\n shippingAddress: row.shipping_address ?? null,\n paymentMethodKind: row.payment_method_kind ?? null,\n paidAt: row.paid_at ?? null,\n items: Array.isArray(row.items) ? row.items.map(rowToOrderItem) : [],\n // Absent on the list endpoints, so [] means \"not asked for\" as much as\n // \"nothing shipped\". The page that shows tracking reads a single order.\n shipments: Array.isArray(row.shipments)\n ? row.shipments.map((shipment) => ({\n id: shipment.id,\n status: shipment.status ?? 'pending',\n carrier: shipment.carrier ?? null,\n trackingCode: shipment.tracking_code ?? null,\n trackingUrl: shipment.tracking_url ?? null,\n shippedAt: shipment.shipped_at ?? null,\n estimatedDeliveryAt: shipment.estimated_delivery_at ?? null,\n deliveredAt: shipment.delivered_at ?? null,\n }))\n : [],\n createdAt: row.created_at ?? nowIso(),\n updatedAt: row.updated_at ?? row.created_at ?? nowIso(),\n }\n}\n\nfunction rowToOrderItem(row: OrderItemRow) {\n return {\n id: row.id,\n orderId: row.order_id,\n productId: row.product_id ?? null,\n name: row.name,\n sku: row.sku ?? null,\n quantity: row.quantity ?? 0,\n unitPrice: row.unit_price ?? 0,\n total: row.total ?? 0,\n imageUrl: row.image_url ?? null,\n }\n}\n\nfunction rowToCustomer(row: CustomerRow) {\n return {\n id: row.id,\n tenantId: row.tenant_id,\n firstName: row.first_name,\n lastName: row.last_name ?? '',\n email: row.email ?? null,\n phone: row.phone ?? null,\n document: row.document ?? null,\n notes: row.notes ?? null,\n ordersCount: row.orders_count ?? 0,\n totalSpent: row.total_spent ?? 0,\n createdAt: row.created_at ?? nowIso(),\n updatedAt: row.updated_at ?? row.created_at ?? nowIso(),\n }\n}\n\nfunction rowToDiscount(row: DiscountRow) {\n return {\n id: row.id,\n tenantId: row.tenant_id,\n title: row.title,\n code: row.code ?? null,\n type: row.type,\n method: row.method ?? 'code',\n value: row.value ?? 0,\n usageLimit: row.usage_limit ?? null,\n oncePerCustomer: row.once_per_customer ?? false,\n startsAt: row.starts_at ?? nowIso(),\n endsAt: row.ends_at ?? null,\n status: row.status ?? 'active',\n timesUsed: row.times_used ?? 0,\n createdAt: row.created_at ?? nowIso(),\n updatedAt: row.updated_at ?? row.created_at ?? nowIso(),\n }\n}\n\nfunction updateOrderPayload(input: {\n status?: FayzShopOrderStatus\n financialStatus?: FayzShopFinancialStatus\n fulfillmentStatus?: FayzShopFulfillmentStatus\n notes?: string\n}) {\n const updates: Record<string, unknown> = {}\n if (input.status !== undefined) updates.status = input.status\n if (input.financialStatus !== undefined) updates.financial_status = input.financialStatus\n if (input.fulfillmentStatus !== undefined) updates.fulfillment_status = input.fulfillmentStatus\n if (input.notes !== undefined) updates.notes = input.notes\n return updates\n}\n\nexport function createFayzShopProvider(options: FayzShopProviderOptions) {\n if (options.mode === 'broker' || options.apiBaseUrl || options.projectId) {\n return createBrokerShopProvider(options)\n }\n\n if (!options.supabaseUrl || !options.publishableKey || !options.storeId) {\n throw new FayzShopError('Fayz Shop provider requires either broker apiBaseUrl/projectId or legacy supabaseUrl/publishableKey/storeId.', 400)\n }\n\n const baseUrl = `${normalizeBaseUrl(options.supabaseUrl)}/rest/v1`\n const functionsUrl = options.functionsUrl\n ? normalizeBaseUrl(options.functionsUrl)\n : `${normalizeBaseUrl(options.supabaseUrl)}/functions/v1`\n // A storefront home mounts several blocks off the same catalogue query.\n const fetcher = createDedupedFetch(options.fetcher ?? fetch)\n const key = options.publishableKey\n const storeId = options.storeId\n const productMetadataOverlay = buildProductMetadataOverlay(options.productMetadata)\n\n /**\n * Ask the store's carrier, under the connector's declared budget.\n *\n * Returns `null` when the carrier did not answer — the signal to fall back to\n * the zones — and an array when it did, INCLUDING an empty one. The\n * distinction is the whole contract; see `quoteShipping`.\n *\n * No credential travels here and none comes back. The function holds it, and\n * the storefront never learns the carrier's URL, let alone its token.\n */\n async function quoteFromCarrier(\n postalCode: string,\n subtotal: number,\n ): Promise<ShippingQuoteOption[] | null> {\n const abort = new AbortController()\n const timer = setTimeout(() => abort.abort(), CARRIER_QUOTE_BUDGET_MS)\n try {\n const response = await (options.fetcher ?? fetch)(`${functionsUrl}/shop-shipping-quote`, {\n method: 'POST',\n signal: abort.signal,\n headers: { apikey: key, Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },\n body: JSON.stringify({ tenantId: storeId, postalCode, subtotal, items: getCartItemsForQuote() }),\n })\n // A store with no carrier connected answers 404 here, every time a\n // shopper types a postcode. That is the ordinary case, not an error.\n if (!response.ok) return null\n\n const body = await response.json() as {\n quoteId?: string | null\n options?: Array<{\n service_id: string; name: string; carrier?: string; price: number\n eta_min_days?: number | null; eta_max_days?: number | null\n }>\n }\n\n const rows = body.options ?? []\n if (rows.length === 0) return []\n if (!body.quoteId) return null\n\n return rows.map((row) => ({\n // Carries the quote it came from, so a selection can name both without\n // the storefront having to hold a second piece of state.\n zoneId: `${body.quoteId}${CARRIER_OPTION_SEPARATOR}${row.service_id}`,\n name: row.name,\n carrier: row.carrier,\n rate: Number(row.price ?? 0),\n baseRate: Number(row.price ?? 0),\n // A carrier price has no free-above rule of ours to re-derive.\n freeAbove: null,\n etaMinDays: row.eta_min_days ?? undefined,\n etaMaxDays: row.eta_max_days ?? undefined,\n free: false,\n }))\n } catch {\n // Aborted, offline, malformed — all the same to the shopper, who gets the\n // zone price instead of an error. FAY-1301: freight never blocks a sale.\n return null\n } finally {\n clearTimeout(timer)\n }\n }\n\n /**\n * One shape for both payment calls, and one rule about failure: a store with\n * no acquirer connected must read as `unopened`, never as an error. That case\n * is the ordinary one for most stores, and an exception there would turn the\n * confirmation page into a crash for everybody who does not charge online.\n */\n async function callPaymentFunction(\n slug: string,\n body: Record<string, unknown>,\n ): Promise<PaymentChargeResult> {\n const orderId = String(body.orderId ?? '')\n try {\n const response = await (options.fetcher ?? fetch)(`${functionsUrl}/${slug}`, {\n method: 'POST',\n headers: { apikey: key, Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },\n body: JSON.stringify({ tenantId: storeId, ...body }),\n })\n const payload = await response.json().catch(() => null) as\n | (PaymentChargeResult & { error?: string; code?: string })\n | null\n\n if (!response.ok || !payload?.state) {\n // The provider's own refusals still reach the caller — \"sem CPF\" and\n // \"pedido já pago\" are things the page must be able to say.\n return {\n state: 'unopened',\n orderId,\n providerStatus: payload?.code ?? `http_${response.status}`,\n }\n }\n return { ...payload, orderId: payload.orderId ?? orderId }\n } catch {\n return { state: 'unopened', orderId, providerStatus: 'unreachable' }\n }\n }\n\n async function request<T>(table: string, init: RequestInit & { query?: URLSearchParams } = {}): Promise<T> {\n const query = init.query?.toString()\n const response = await fetcher(`${baseUrl}/${table}${query ? `?${query}` : ''}`, {\n ...init,\n headers: {\n apikey: key,\n // Declares which store this read is for. Until 0020 tenant isolation was\n // a client-side convention (a tenant_id filter the caller could simply\n // omit, returning every merchant's catalogue); the RLS policy now reads\n // this header, so the scope is enforced server-side.\n 'x-fayz-store': storeId,\n // The shopper's JWT when signed in, the publishable key otherwise. The\n // apikey header stays the publishable key either way — Supabase uses it\n // to route the project, not to authenticate.\n Authorization: `Bearer ${_accessTokenResolver?.() || key}`,\n ...(init.body ? { 'Content-Type': 'application/json', Prefer: 'return=representation' } : {}),\n ...init.headers,\n },\n })\n const text = await response.text()\n let body: unknown\n try {\n body = text ? JSON.parse(text) : undefined\n } catch {\n body = text\n }\n if (!response.ok) {\n const message = typeof body === 'object' && body\n ? String((body as { message?: unknown; error?: unknown }).message ?? (body as { error?: unknown }).error ?? `Fayz Shop request failed with status ${response.status}`)\n : `Fayz Shop request failed with status ${response.status}`\n throw new FayzShopError(message, response.status, body)\n }\n return body as T\n }\n\n const tenantQuery = () => {\n const query = new URLSearchParams()\n query.set('tenant_id', `eq.${storeId}`)\n return query\n }\n\n const singleById = (id: string) => {\n const query = tenantQuery()\n query.set('id', `eq.${id}`)\n query.set('limit', '1')\n return query\n }\n\n return {\n async listProducts(options?: FayzShopListProductsOptions) {\n const query = tenantQuery()\n query.set('select', '*,images:plg_shop_product_images(*),category:plg_shop_categories(name)')\n if (options?.status) query.set('status', `eq.${options.status}`)\n if (options?.slug) query.set('slug', `eq.${options.slug}`)\n if (options?.search) query.set('name', `ilike.*${options.search}*`)\n query.set('order', `${options?.orderBy ?? 'sort_order'}.${options?.order ?? 'asc'}`)\n if (options?.limit) query.set('limit', String(options.limit))\n if (options?.offset) query.set('offset', String(options.offset))\n const products = (await request<ProductRow[]>('plg_shop_products', { query })).map((row) => rowToProduct(row, productMetadataOverlay))\n return options?.categoryId ? products.filter((product) => product.categoryId === options.categoryId) : products\n },\n async getProduct(id: string) {\n // Cart lines can carry non-uuid ids (mock catalog, or a cart persisted in\n // an earlier mock-mode session). PostgREST would 400 on `id=eq.p-05`\n // (invalid uuid), so treat any non-uuid id as \"not found\" instead.\n if (!asUuid(id)) return null\n const query = singleById(id)\n query.set('select', '*,images:plg_shop_product_images(*),category:plg_shop_categories(name)')\n const rows = await request<ProductRow[]>('plg_shop_products', { query })\n return rows[0] ? rowToProduct(rows[0], productMetadataOverlay) : null\n },\n async createProduct() {\n throw new FayzShopError('Product writes require the Fayz admin/broker API.', 501)\n },\n async updateProduct() {\n throw new FayzShopError('Product writes require the Fayz admin/broker API.', 501)\n },\n async deleteProduct() {\n throw new FayzShopError('Product writes require the Fayz admin/broker API.', 501)\n },\n async uploadProductImage() {\n throw new FayzShopError('Product image uploads require the Fayz admin/broker API.', 501)\n },\n async deleteProductImage() {\n throw new FayzShopError('Product image deletes require the Fayz admin/broker API.', 501)\n },\n /**\n * Option axes + variants from the 0028 tables (spine M5) — the read that\n * replaces the productMetadata overlay as the source of product options.\n * Anon reads are already scoped by the storefront RLS (active variants of\n * publicly readable products only).\n */\n async getProductVariants(productId: string) {\n if (!asUuid(productId)) return { options: [], variants: [] }\n const optionsQuery = new URLSearchParams()\n optionsQuery.set('product_id', `eq.${productId}`)\n optionsQuery.set('order', 'position.asc')\n const variantsQuery = new URLSearchParams()\n variantsQuery.set('product_id', `eq.${productId}`)\n variantsQuery.set('status', 'eq.active')\n variantsQuery.set('order', 'position.asc')\n const [optionRows, variantRows] = await Promise.all([\n request<Array<{ id: string; name: string; values?: unknown; position?: number | null }>>(\n 'plg_shop_product_options',\n { query: optionsQuery },\n ),\n request<Array<{\n id: string\n product_id: string\n options?: Record<string, string> | null\n sku?: string | null\n price?: number | string | null\n compare_at_price?: number | string | null\n inventory_count?: number | null\n position?: number | null\n status?: string | null\n image_id?: string | null\n weight?: number | string | null\n weight_unit?: string | null\n height_cm?: number | string | null\n width_cm?: number | string | null\n length_cm?: number | string | null\n }>>('plg_shop_product_variants', { query: variantsQuery }),\n ])\n return {\n options: (optionRows ?? []).map((row) => ({\n id: row.id,\n name: row.name,\n values: Array.isArray(row.values) ? row.values.map(String) : [],\n position: row.position ?? 0,\n })),\n variants: (variantRows ?? []).map((row) => ({\n id: row.id,\n productId: row.product_id,\n options: row.options && typeof row.options === 'object' ? row.options : {},\n sku: row.sku ?? null,\n price: row.price == null ? null : Number(row.price),\n compareAtPrice: row.compare_at_price == null ? null : Number(row.compare_at_price),\n inventoryCount: row.inventory_count ?? 0,\n position: row.position ?? 0,\n status: (row.status ?? 'active') as 'active' | 'archived',\n imageId: row.image_id ?? null,\n // Null inherits the product's, the way `price` has since 0028.\n weight: numOrNull(row.weight),\n weightUnit: row.weight_unit ?? null,\n heightCm: numOrNull(row.height_cm),\n widthCm: numOrNull(row.width_cm),\n lengthCm: numOrNull(row.length_cm),\n })),\n }\n },\n async listCategories() {\n const productQuery = tenantQuery()\n productQuery.set('select', 'metadata')\n productQuery.set('order', 'sort_order.asc')\n const products = await request<ProductRow[]>('plg_shop_products', { query: productQuery })\n const storeCategories = deriveStoreCategories(products, storeId)\n if (storeCategories.length > 0) return storeCategories\n\n const query = new URLSearchParams()\n query.set('select', '*')\n query.set('order', 'sort_order.asc')\n return (await request<CategoryRow[]>('plg_shop_categories', { query })).map(rowToCategory)\n },\n async createCategory() {\n throw new FayzShopError('Category writes require the Fayz admin/broker API.', 501)\n },\n async updateCategory() {\n throw new FayzShopError('Category writes require the Fayz admin/broker API.', 501)\n },\n async deleteCategory() {\n throw new FayzShopError('Category deletes require the Fayz admin/broker API.', 501)\n },\n async listOrders(options?: FayzShopListOrdersOptions) {\n const query = tenantQuery()\n // Os envios entram na LISTA, e só o estado deles: é o que separa \"enviado\"\n // de \"entregue\" na coluna de entrega. Sem isto a fila do lojista dizia\n // \"enviado\" para sempre, mesmo com a encomenda já na mão do cliente.\n query.set('select', '*,items:plg_shop_order_items(*),shipments:fulfillments(status,delivered_at)')\n if (options?.status) query.set('status', `eq.${options.status}`)\n if (options?.financialStatus) query.set('financial_status', `eq.${options.financialStatus}`)\n if (options?.fulfillmentStatus) query.set('fulfillment_status', `eq.${options.fulfillmentStatus}`)\n if (options?.customerId) query.set('customer_id', `eq.${options.customerId}`)\n if (options?.customerEmail) query.set('customer_email', `eq.${options.customerEmail}`)\n if (options?.search) query.set('or', `(customer_name.ilike.*${options.search}*,customer_email.ilike.*${options.search}*)`)\n query.set('order', 'created_at.desc')\n if (options?.limit) query.set('limit', String(options.limit))\n if (options?.offset) query.set('offset', String(options.offset))\n // Anon storefronts have no table grant (RLS restricts plg_shop_orders reads to\n // `authenticated` users linked via auth.uid) — direct read 401s. RLS can also\n // just filter every row out silently (200 OK + []) instead of 401ing, so an\n // empty result here doesn't mean \"no orders\" either — both cases must fall\n // back to the customer-uuid-capability RPC, same pattern as getOrder's\n // shop_get_order. This is what made \"Minhas compras\" empty after a guest\n // checkout — the order was there, the read just wasn't allowed (or silently\n // filtered), and only the throw case used to be handled.\n let rows: OrderRow[] = []\n try {\n rows = await request<OrderRow[]>('plg_shop_orders', { query })\n } catch (error) {\n if (!options?.customerId) throw error\n }\n if (rows.length || !options?.customerId) return rows.map(rowToOrder)\n // Only the customer-scoped query has an RPC counterpart: shop_list_orders\n // treats the customer uuid as the read capability, exactly like\n // shop_get_order treats the order uuid. Any other filter combination has\n // no anon-safe equivalent, so the original error (if any) stands.\n const rpcRows = await request<OrderRow[]>('rpc/shop_list_orders', {\n method: 'POST',\n body: JSON.stringify({ p_customer_id: options.customerId, p_limit: options.limit ?? 50 }),\n })\n return (rpcRows ?? []).map(rowToOrder)\n },\n async getOrder(id: string) {\n // O caminho do COMPRADOR é a RPC, e ele vem primeiro quando não há sessão.\n // Antes a leitura direta da tabela era sempre tentada e sempre devolvia\n // 401 para o anônimo (sem grant nenhum): uma ida e volta garantidamente\n // perdida na página mais aberta da loja, e um erro vermelho no console em\n // toda visita — que é o ruído sob o qual um erro de verdade se esconde.\n const signedIn = !!_accessTokenResolver?.()\n const viaRpc = async () => {\n try {\n const row = await request<OrderRow | null>('rpc/shop_get_order', {\n method: 'POST',\n body: JSON.stringify({ p_order_id: id }),\n })\n return row ? rowToOrder(row) : null\n } catch {\n return null\n }\n }\n\n if (!signedIn) return await viaRpc()\n\n const query = singleById(id)\n query.set('select', '*,items:plg_shop_order_items(*)')\n let rows: OrderRow[] = []\n try {\n rows = await request<OrderRow[]>('plg_shop_orders', { query })\n } catch {\n /* fall through to shop_get_order */\n }\n if (rows[0]) return rowToOrder(rows[0])\n // Membro da loja sem linha visível cai na mesma porta do comprador: o uuid\n // do pedido é a capacidade de leitura.\n try {\n return await viaRpc()\n } catch {\n return null\n }\n },\n async confirmPayment(id: string, reference?: string) {\n // Mock/dev payment seam: anon has no UPDATE grant on plg_shop_orders,\n // so the pending->paid transition goes through the whitelisted RPC\n // (order uuid = capability, same contract as shop_get_order).\n const row = await request<OrderRow | null>('rpc/shop_confirm_payment', {\n method: 'POST',\n body: JSON.stringify({ p_order_id: id, p_reference: reference ?? null }),\n })\n return row ? rowToOrder(row) : null\n },\n /**\n * Opens the charge, or reports what the acquirer says about it.\n *\n * Both go through the pool's own functions, for the same reason\n * `quoteFromCarrier` does: the credential is redeemed server-side and the\n * storefront never learns the acquirer's URL, let alone its token. Neither\n * call carries an amount — the function reads it off the order row, so a\n * tampered body buys nothing.\n *\n * A store with no acquirer connected answers 404, which surfaces as\n * `unopened`: the page then simply shows the order as pending, which is the\n * behaviour every store had before this existed.\n */\n async openCharge(orderId: string, method: 'pix' = 'pix') {\n return await callPaymentFunction('shop-checkout-pay', { orderId, method })\n },\n async paymentState(orderId: string) {\n return await callPaymentFunction('shop-payment-status', { orderId })\n },\n /**\n * Open a charge for a cart that is NOT yet an order.\n *\n * Nothing about money leaves the browser: the function re-prices every line\n * from the catalogue, so the total that comes back is the store's, not the\n * caller's. `sessionId` is the only handle, and it neither reads nor pays on\n * its own — `settleCheckoutSession` is what turns it into an order, and only\n * after the acquirer says the money is in.\n */\n /**\n * Remember the contact details of whoever is signed in.\n *\n * Called when the buyer leaves the contact step rather than when an order\n * completes: an abandoned checkout teaches the store nothing, and the person\n * who most needs their phone remembered is the one who did not finish. The\n * function decides which columns may be written and to whose row — a shopper\n * is not a tenant member, so there is no policy that would let this be a\n * plain UPDATE, and RLS could not narrow one to two columns anyway.\n */\n async saveCustomerContact(input: { phone?: string | null; document?: string | null }): Promise<void> {\n try {\n await request<unknown>('rpc/shop_save_customer_contact', {\n method: 'POST',\n body: JSON.stringify({\n p_tenant_id: storeId,\n p_phone: input.phone ?? null,\n p_document: input.document ?? null,\n }),\n })\n } catch {\n // Never blocking: failing to remember a phone must not stop a purchase.\n }\n },\n async openCheckoutSession(input: CheckoutSessionInput): Promise<CheckoutSession> {\n // Which door to knock on. Absent falls back to AbacatePay, which is where\n // every caller was when there was one gateway; an acquirer with no pair of\n // functions is refused here rather than by a function that would answer\n // about somebody else's transaction.\n const provider = String(input.provider ?? '').trim() || 'abacatepay'\n const gateway = checkoutGateway(provider)\n if (!gateway) {\n throw new FayzShopError('Esta loja ainda não recebe pagamento online.', 404)\n }\n const body = JSON.stringify({\n tenantId: storeId,\n items: input.items.map((item) => ({\n productId: item.productId,\n optionsLabel: item.optionsLabel ?? null,\n quantity: item.quantity,\n })),\n customer: input.customer,\n shippingAddress: input.shippingAddress ?? null,\n discountCode: input.discountCode ?? null,\n // O que o comprador escolheu, no vocabulário da loja. Quem traduz para\n // o número do adquirente é a função, do lado de lá, onde também mora a\n // lista do que o lojista habilitou.\n method: input.paymentMethod ?? null,\n // Para onde o adquirente devolve quem pagou fora daqui. A função confere\n // este endereço contra a origem de quem pediu: é uma URL que entregamos\n // a terceiro, e terceiro nenhum redireciona comprador nosso para onde\n // quiser.\n returnUrl: input.returnUrl ?? null,\n asLink: input.asLink === true,\n })\n // A dead function, an offline shopper and a blocked request all throw the\n // same bare TypeError here, and its message (\"Failed to fetch\") was being\n // painted on the payment step in English. Whatever broke, what the buyer\n // needs is the same sentence and the retry button next to it.\n const response = await (options.fetcher ?? fetch)(`${functionsUrl}/${gateway.open}`, {\n method: 'POST',\n headers: { apikey: key, Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },\n body,\n }).catch(() => {\n throw new FayzShopError('Não conseguimos falar com o pagamento agora. Tente de novo.', 0)\n })\n const payload = await response.json().catch(() => null) as\n | { sessionId?: string; brCode?: string; brCodeBase64?: string | null\n qrCodeUrl?: string | null\n expiresAt?: string; total?: number; error?: string; code?: string\n method?: CheckoutSession['method']\n redirectUrl?: string | null; paymentUrl?: string | null }\n | null\n // Unlike `openCharge`, a failure here is NOT swallowed into a soft state:\n // this call is the buyer pressing \"pagar\", and a silent null would leave\n // them staring at a spinner for a charge that was never opened.\n if (!response.ok || !payload?.sessionId) {\n // A store with no acquirer connected 404s here, and so does a pool where\n // the function was never deployed — both are \"this store cannot charge\",\n // and neither should reach the buyer as the gateway's English.\n const fallback = response.status === 404\n ? 'Esta loja ainda não recebe pagamento online.'\n : 'Não conseguimos abrir a cobrança agora.'\n throw new FayzShopError(payload?.error ?? fallback, response.status, payload)\n }\n return {\n sessionId: payload.sessionId,\n total: Number(payload.total ?? 0),\n state: 'open',\n provider,\n method: payload.method ?? input.paymentMethod ?? null,\n // A página do adquirente: o link que o lojista manda e o endereço para\n // onde o comprador de cartão é levado. São a mesma coisa vista de dois\n // lugares — quem chama decide se copia ou se vai.\n paymentUrl: payload.redirectUrl ?? payload.paymentUrl ?? null,\n charge: payload.brCode\n ? {\n emv: payload.brCode,\n // O tipo promete base64 PURO, e a AbacatePay manda com o\n // `data:image/png;base64,` já embutido (a AppMax mandava sem).\n // Sem tirar aqui, a tela prefixava de novo e o QR não aparecia —\n // um <img> com src inválido, silencioso.\n qrcodeBase64: (payload.brCodeBase64 ?? '').replace(/^data:image\\/\\w+;base64,/u, '') || null,\n // Vindi hosts the QR instead of inlining it, so the image arrives\n // as an https URL to an SVG. It travels beside the base64 rather\n // than inside it: the two cannot be told apart at the point of use\n // without guessing at the string, and drawing either as the other\n // is a silently broken <img> in front of someone trying to pay.\n qrcodeUrl: String(payload.qrCodeUrl ?? '').trim() || null,\n expiresAt: payload.expiresAt ?? '',\n }\n : null,\n }\n },\n /**\n * Ask whether the money landed. Called on a timer, so a network blip must\n * read as \"still waiting\" (`unknown`) and never as a payment that failed —\n * one wrong `failed` here throws away a cart the buyer already paid for.\n */\n async settleCheckoutSession(\n sessionId: string,\n provider?: string | null,\n chargeToken?: string | null,\n ): Promise<CheckoutSettlement> {\n // The gateway that OPENED the session, handed back by openCheckoutSession.\n // Re-reading it from settings would let a merchant who switched acquirer\n // mid-checkout have the new gateway asked about the old one's transaction.\n const gateway = checkoutGateway(String(provider ?? '').trim() || 'abacatepay')\n if (!gateway) return { state: 'unknown' }\n try {\n const response = await (options.fetcher ?? fetch)(`${functionsUrl}/${gateway.settle}`, {\n method: 'POST',\n headers: { apikey: key, Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },\n // `chargeToken` é PISTA, nunca afirmação: o adquirente pendura o token\n // na volta do comprador, e o servidor confere com ele antes de aceitar.\n // Serve para fechar a compra na hora em vez de esperar o webhook.\n body: JSON.stringify({ tenantId: storeId, sessionId, ...(chargeToken ? { chargeToken } : {}) }),\n })\n const payload = await response.json().catch(() => null) as\n | { state?: CheckoutSettlement['state']; orderId?: string | null; reason?: string | null }\n | null\n if (!response.ok || !payload?.state) return { state: 'unknown' }\n return {\n state: payload.state,\n orderId: payload.orderId ?? null,\n reason: payload.reason ?? null,\n }\n } catch {\n return { state: 'unknown' }\n }\n },\n /**\n * The merchant's policy, as the shopper's browser is allowed to see it.\n *\n * Without this the settings screens wrote to a table nobody read on this\n * side: StorefrontConfigHost skips the overlay when the provider has no\n * such method, so the checkout kept offering whatever the app declared at\n * build time — a store that turned boleto off still showed boleto.\n *\n * Through the RPC, never the table: plg_shop_settings is closed to anon on\n * purpose and shop_store_settings() is the narrow window (storefront\n * columns only, published stores only). A failure answers null, which is\n * \"no policy\" — the declared config stands and the store still sells.\n */\n async getPublicStoreSettings() {\n let row: Record<string, unknown> | null = null\n try {\n const body = await request<Record<string, unknown>[] | Record<string, unknown> | null>(\n 'rpc/shop_store_settings',\n { method: 'POST', body: JSON.stringify({ p_tenant_id: storeId }) },\n )\n row = Array.isArray(body) ? body[0] ?? null : body ?? null\n } catch {\n return null\n }\n if (!row) return null\n\n const bool = (v: unknown): boolean | undefined => (v == null ? undefined : Boolean(v))\n // Empty is UNDECIDED, not \"offer nothing\" (0045). A store that saved a\n // section it does not use must not lose the checkout it never touched.\n const methods = Array.isArray(row.payment_methods) && row.payment_methods.length > 0\n ? (row.payment_methods as string[])\n : undefined\n const fields = row.checkout_fields && typeof row.checkout_fields === 'object'\n && Object.keys(row.checkout_fields as object).length > 0\n ? row.checkout_fields\n : undefined\n\n return {\n currency: (row.currency as string) ?? undefined,\n locale: (row.locale as string) ?? undefined,\n showOutOfStock: bool(row.show_out_of_stock),\n paymentMethods: methods,\n paymentProvider: (row.payment_provider as string) ?? undefined,\n guestCheckout: bool(row.guest_checkout),\n requireConfirmedEmail: bool(row.require_confirmed_email),\n marketingOptIn: bool(row.marketing_opt_in),\n discountsEnabled: bool(row.discounts_enabled),\n checkoutFields: fields,\n carrierQuotes: bool(row.carrier_quotes),\n }\n },\n /**\n * Dispatch by hand.\n *\n * All three are SECURITY DEFINER RPCs that check store membership\n * themselves — the browser cannot ship someone else's order by holding its\n * id, which is why these are not table writes.\n */\n async validateDiscountCode(code: string, subtotal?: number) {\n const row = await request<{\n valid?: boolean; code?: string | null; type?: string | null\n value?: number | null; reason?: string | null\n } | null>('rpc/shop_validate_discount', {\n method: 'POST',\n body: JSON.stringify({ p_tenant_id: storeId, p_code: code, p_subtotal: subtotal ?? 0 }),\n })\n return {\n valid: !!row?.valid,\n code: row?.code ?? null,\n type: (row?.type ?? null) as 'percentage' | 'fixed_amount' | null,\n value: Number(row?.value ?? 0),\n reason: row?.reason ?? undefined,\n }\n },\n async cancelOrder(orderId: string, reason?: string) {\n const row = await request<OrderRow | null>('rpc/shop_cancel_order', {\n method: 'POST',\n body: JSON.stringify({ p_order_id: orderId, p_reason: reason?.trim() || null }),\n })\n return row ? rowToOrder(row) : null\n },\n async createFulfillment(input: {\n orderId: string\n carrier?: string\n trackingCode?: string\n locationId?: string\n notes?: string\n items?: Array<{ orderItemId: string; quantity: number }>\n }) {\n return await request<string>('rpc/shop_create_fulfillment', {\n method: 'POST',\n body: JSON.stringify({\n p_order_id: input.orderId,\n p_location_id: asUuid(input.locationId ?? undefined),\n p_carrier: input.carrier?.trim() || null,\n p_tracking: input.trackingCode?.trim() || null,\n // snake_case inside the jsonb: the RPC reads `order_item_id`.\n p_items: input.items?.length\n ? input.items.map((line) => ({ order_item_id: line.orderItemId, quantity: line.quantity }))\n : null,\n p_notes: input.notes?.trim() || null,\n }),\n })\n },\n async shipFulfillment(id: string, input: { trackingCode?: string; trackingUrl?: string; carrier?: string }) {\n await request<null>('rpc/shop_ship_fulfillment', {\n method: 'POST',\n body: JSON.stringify({\n p_fulfillment_id: id,\n p_tracking: input.trackingCode?.trim() || null,\n p_tracking_url: input.trackingUrl?.trim() || null,\n p_carrier: input.carrier?.trim() || null,\n }),\n })\n },\n /** Chegou. Só o lojista sabe disso — nenhum provedor nos avisa hoje. */\n async deliverFulfillment(id: string, deliveredAt?: string) {\n await request<null>('rpc/shop_deliver_fulfillment', {\n method: 'POST',\n body: JSON.stringify({ p_fulfillment_id: id, p_delivered_at: deliveredAt ?? null }),\n })\n },\n async cancelFulfillment(id: string, note?: string) {\n await request<null>('rpc/shop_cancel_fulfillment', {\n method: 'POST',\n body: JSON.stringify({ p_fulfillment_id: id, p_note: note?.trim() || null }),\n })\n },\n async createOrder(input: {\n customerId?: string\n customerName?: string\n customerEmail?: string\n currency?: string\n notes?: string\n discountCode?: string\n discountTotal?: number\n shippingTotal?: number\n items: Array<{ productId?: string; name: string; sku?: string; quantity: number; unitPrice: number; imageUrl?: string }>\n }) {\n const subtotal = input.items.reduce((sum, item) => sum + item.quantity * item.unitPrice, 0)\n const discountTotal = input.discountTotal ?? 0\n const shippingTotal = input.shippingTotal ?? 0\n const total = Math.round((subtotal - discountTotal + shippingTotal) * 100) / 100\n const [order] = await request<OrderRow[]>('plg_shop_orders', {\n method: 'POST',\n body: JSON.stringify({\n tenant_id: storeId,\n customer_id: input.customerId ?? null,\n customer_name: input.customerName ?? null,\n customer_email: input.customerEmail ?? null,\n currency: input.currency ?? 'BRL',\n notes: input.notes ?? null,\n subtotal,\n discount_total: discountTotal,\n shipping_total: shippingTotal,\n discount_code: input.discountCode ?? null,\n total,\n status: 'open',\n financial_status: 'pending',\n fulfillment_status: 'unfulfilled',\n }),\n })\n if (!order) throw new FayzShopError('Order insert did not return a row.', 500)\n if (input.items.length) {\n await request<OrderItemRow[]>('plg_shop_order_items', {\n method: 'POST',\n body: JSON.stringify(input.items.map((item) => ({\n order_id: order.id,\n product_id: asUuid(item.productId),\n name: item.name,\n sku: item.sku ?? null,\n quantity: item.quantity,\n unit_price: item.unitPrice,\n total: item.quantity * item.unitPrice,\n image_url: item.imageUrl ?? null,\n }))),\n })\n }\n return this.getOrder(order.id)\n },\n async updateOrder(id: string, input: Parameters<typeof updateOrderPayload>[0]) {\n await request<OrderRow[]>('plg_shop_orders', {\n method: 'PATCH',\n query: singleById(id),\n body: JSON.stringify(updateOrderPayload(input)),\n })\n return this.getOrder(id)\n },\n async placeOrder(input: {\n tenantId?: string\n customerId?: string\n customer?: { name?: string; email?: string }\n currency?: string\n notes?: string\n discountCode?: string\n shippingTotal?: number\n /** Structured delivery address; frozen on the order and saved to the\n * customer's address book by the RPC. */\n shippingAddress?: {\n postalCode: string\n street: string\n number?: string\n complement?: string\n district?: string\n city: string\n state: string\n country?: string\n recipient?: string\n phone?: string\n label?: string\n /** CPF/CNPJ, digits only. Not an address field — it rides here because\n * shop_place_order's signature cannot grow one without a DROP; 0050's\n * trigger lifts it to plg_shop_orders.customer_document. */\n document?: string\n }\n paymentMethod?: 'pix' | 'credit_card' | 'debit_card' | 'boleto' | 'cash' | 'other'\n metadata?: Record<string, unknown>\n items: Array<{ productId: string; variantId?: string; quantity: number; optionsLabel?: string }>\n }) {\n // Trusted placement: the shop_place_order SECURITY DEFINER RPC re-reads\n // prices, validates discount/stock and writes order+items atomically.\n // Direct INSERTs are blocked for anon by RLS on the shared FayzApi.\n const orderId = await request<string>('rpc/shop_place_order', {\n method: 'POST',\n body: JSON.stringify({\n p_tenant_id: input.tenantId ?? storeId,\n // variant_id per line (0029): the RPC prices + decrements the variant\n // when present. Pre-0029 servers ignore unknown jsonb keys, so lines\n // stay compatible; p_metadata is a NAMED argument and is only sent\n // when something contributed (unknown named args are rejected).\n p_items: input.items.map((line) => ({\n product_id: line.productId,\n variant_id: asUuid(line.variantId) ?? undefined,\n quantity: line.quantity,\n options_label: line.optionsLabel ?? null,\n })),\n p_customer_id: asUuid(input.customerId ?? undefined),\n p_customer_name: input.customer?.name ?? null,\n p_customer_email: input.customer?.email ?? null,\n p_currency: input.currency ?? 'BRL',\n p_discount_code: input.discountCode ?? null,\n p_shipping_total: input.shippingTotal ?? 0,\n // snake_case keys on purpose: the RPC freezes this jsonb onto the\n // order and public.addresses uses these exact column names.\n p_shipping_address: input.shippingAddress\n ? {\n postal_code: input.shippingAddress.postalCode,\n street: input.shippingAddress.street,\n number: input.shippingAddress.number ?? null,\n complement: input.shippingAddress.complement ?? null,\n district: input.shippingAddress.district ?? null,\n city: input.shippingAddress.city,\n state: input.shippingAddress.state,\n country: input.shippingAddress.country ?? 'BR',\n recipient: input.shippingAddress.recipient ?? null,\n phone: input.shippingAddress.phone ?? null,\n label: input.shippingAddress.label ?? null,\n // Not an address field — see ShippingAddressInput.document. The\n // 0050 trigger lifts it to a column and deletes it from here.\n document: input.shippingAddress.document ?? null,\n }\n : null,\n p_payment_method: input.paymentMethod ?? null,\n p_notes: input.notes ?? null,\n ...(input.metadata !== undefined ? { p_metadata: input.metadata } : {}),\n }),\n })\n const order = await this.getOrder(orderId)\n if (!order) throw new FayzShopError('Order was placed but could not be read back.', 500)\n return order\n },\n async listCustomers(options?: FayzShopListCustomersOptions) {\n const query = tenantQuery()\n query.set('select', '*')\n query.set('order', 'first_name.asc')\n if (options?.search) query.set('or', `(first_name.ilike.*${options.search}*,last_name.ilike.*${options.search}*,email.ilike.*${options.search}*)`)\n if (options?.limit) query.set('limit', String(options.limit))\n if (options?.offset) query.set('offset', String(options.offset))\n return (await request<CustomerRow[]>('plg_shop_customers', { query })).map(rowToCustomer)\n },\n async getCustomer(id: string) {\n const rows = await request<CustomerRow[]>('plg_shop_customers', { query: singleById(id) })\n return rows[0] ? rowToCustomer(rows[0]) : null\n },\n async resolveCustomer(input: { email: string; name?: string }) {\n const row = await request<CustomerRow | CustomerRow[]>('rpc/shop_resolve_customer', {\n method: 'POST',\n body: JSON.stringify({\n p_tenant_id: storeId,\n p_email: input.email,\n p_name: input.name ?? null,\n }),\n })\n const customer = Array.isArray(row) ? row[0] : row\n if (!customer) throw new FayzShopError('shop_resolve_customer returned no row.', 500)\n return rowToCustomer(customer)\n },\n /**\n * The carrier first, our own zones when it does not answer in time.\n *\n * This is `createShippingQuoter` (packages/shop/src/providers/shipping.ts)\n * by hand, and the duplication is deliberate: this package declares NO\n * dependencies, which is what lets a storefront pull the client without\n * dragging the admin stack in behind it. Importing the primitive for twelve\n * lines would trade that for tidiness. The semantics are copied exactly and\n * both are worth restating —\n *\n * the budget is the connector's (1s, `onFailure: 'degrade'`), because a\n * shopper staring at \"calculando\" abandons faster than they accept a\n * slightly wrong price; and\n *\n * an EMPTY provider answer is an ANSWER, not a failure. A carrier that\n * does not serve a postcode has told us something, and falling back to\n * the zones there would quote a van that does not go to São Paulo.\n */\n async quoteShipping(postalCode: string, subtotal: number) {\n const digits = (postalCode || '').replace(/\\D/g, '')\n if (digits.length !== 8) return []\n\n // Nothing in this cart is delivered. No carrier is asked and no zone is\n // consulted: a store selling downloads has an address book, not a\n // delivery area, and a zone price shown for an e-book is money charged\n // for a van that never leaves.\n if (cartIsFullyDigital(getCartItemsForQuote())) return []\n\n const zones = async (): Promise<ShippingQuoteOption[]> => {\n const rows = await request<ShippingQuoteRow[]>('rpc/shop_quote_shipping', {\n method: 'POST',\n body: JSON.stringify({\n p_tenant_id: storeId,\n p_postal_code: digits,\n p_subtotal: subtotal,\n }),\n })\n return (rows ?? []).map((row) => ({\n zoneId: row.zone_id,\n name: row.name,\n carrier: row.carrier ?? undefined,\n rate: Number(row.rate ?? 0),\n baseRate: Number(row.base_rate ?? row.rate ?? 0),\n freeAbove: row.free_above == null ? null : Number(row.free_above),\n etaMinDays: row.eta_min_days ?? undefined,\n etaMaxDays: row.eta_max_days ?? undefined,\n free: Boolean(row.free),\n }))\n }\n\n // A loja que calcula sozinha não consulta gateway nenhum, mesmo com um\n // conectado — que é exatamente o que a tela promete.\n const carrier = mayAskCarrier() ? await quoteFromCarrier(digits, subtotal) : null\n // `null` is \"the carrier did not answer\" — a timeout, a refusal, no\n // connection at all. `[]` is \"it answered: nobody serves this address.\"\n return carrier ?? (await zones())\n },\n\n /**\n * Record which option the shopper picked, server-side.\n *\n * It sends a SERVICE, never a price: the row it points at was written by\n * the quote function minutes ago, so the worst a tampered call achieves is\n * choosing a different option the carrier actually offered — which is what\n * the radio buttons are for. shop_place_order reads the stored price.\n */\n async selectShippingOption(optionId: string) {\n const [quoteId, serviceId] = String(optionId ?? '').split(CARRIER_OPTION_SEPARATOR)\n if (!quoteId || !serviceId) return false\n try {\n return Boolean(await request<boolean>('rpc/shop_select_shipping_quote', {\n method: 'POST',\n body: JSON.stringify({ p_quote_id: quoteId, p_service_id: serviceId }),\n }))\n } catch {\n // The cheapest option stands in when nothing was selected, so a failed\n // selection is a shopper charged less than they picked — never more.\n return false\n }\n },\n async listCustomerAddresses(customerId: string) {\n if (!asUuid(customerId)) return []\n const query = new URLSearchParams()\n query.set('select', 'id,label,recipient,phone,postal_code,street,number,complement,district,city,state,country,is_default')\n query.set('owner_type', 'eq.shop_customer')\n query.set('owner_id', `eq.${customerId}`)\n query.set('order', 'is_default.desc,created_at.desc')\n // RLS (addresses_self_read) is the real filter — it matches only rows\n // whose customer is linked to auth.uid(). An anonymous or mismatched\n // caller gets [] rather than an error, so guest checkout just sees an\n // empty address book instead of a failure it cannot act on.\n const rows = await request<AddressRow[]>('addresses', { query }).catch(() => [] as AddressRow[])\n return rows.map((row) => ({\n id: row.id,\n label: row.label ?? undefined,\n recipient: row.recipient ?? undefined,\n phone: row.phone ?? undefined,\n postalCode: row.postal_code ?? '',\n street: row.street ?? '',\n number: row.number ?? undefined,\n complement: row.complement ?? undefined,\n district: row.district ?? undefined,\n city: row.city ?? '',\n state: row.state ?? '',\n country: row.country ?? undefined,\n isDefault: row.is_default ?? false,\n }))\n },\n async createCustomer(input: { firstName: string; lastName?: string; email?: string; phone?: string; notes?: string }) {\n const [customer] = await request<CustomerRow[]>('plg_shop_customers', {\n method: 'POST',\n body: JSON.stringify({\n tenant_id: storeId,\n first_name: input.firstName,\n last_name: input.lastName ?? '',\n email: input.email ?? null,\n phone: input.phone ?? null,\n notes: input.notes ?? null,\n }),\n })\n if (!customer) throw new FayzShopError('Customer insert did not return a row.', 500)\n return rowToCustomer(customer)\n },\n async updateCustomer(id: string, input: { firstName?: string; lastName?: string; email?: string | null; phone?: string | null; notes?: string | null }) {\n const updates: Record<string, unknown> = {}\n if (input.firstName !== undefined) updates.first_name = input.firstName\n if (input.lastName !== undefined) updates.last_name = input.lastName\n if (input.email !== undefined) updates.email = input.email\n if (input.phone !== undefined) updates.phone = input.phone\n if (input.notes !== undefined) updates.notes = input.notes\n const [customer] = await request<CustomerRow[]>('plg_shop_customers', {\n method: 'PATCH',\n query: singleById(id),\n body: JSON.stringify(updates),\n })\n if (!customer) throw new FayzShopError('Customer update did not return a row.', 500)\n return rowToCustomer(customer)\n },\n async deleteCustomer(id: string) {\n await request<unknown>('plg_shop_customers', { method: 'DELETE', query: singleById(id) })\n },\n async listDiscounts(options?: FayzShopListDiscountsOptions) {\n const query = tenantQuery()\n query.set('select', '*')\n query.set('order', 'created_at.desc')\n if (options?.status) query.set('status', `eq.${options.status}`)\n if (options?.type) query.set('type', `eq.${options.type}`)\n if (options?.search) query.set('title', `ilike.*${options.search}*`)\n if (options?.limit) query.set('limit', String(options.limit))\n if (options?.offset) query.set('offset', String(options.offset))\n return (await request<DiscountRow[]>('plg_shop_discounts', { query })).map(rowToDiscount)\n },\n async getDiscount(id: string) {\n const rows = await request<DiscountRow[]>('plg_shop_discounts', { query: singleById(id) })\n return rows[0] ? rowToDiscount(rows[0]) : null\n },\n async createDiscount() {\n throw new FayzShopError('Discount writes require the Fayz admin/broker API.', 501)\n },\n async updateDiscount() {\n throw new FayzShopError('Discount writes require the Fayz admin/broker API.', 501)\n },\n async deleteDiscount() {\n throw new FayzShopError('Discount deletes require the Fayz admin/broker API.', 501)\n },\n }\n}\n\nfunction appendQuery(url: string, values: Record<string, string | number | undefined>): string {\n const query = new URLSearchParams()\n for (const [key, value] of Object.entries(values)) {\n if (value !== undefined) query.set(key, String(value))\n }\n const serialized = query.toString()\n return serialized ? `${url}?${serialized}` : url\n}\n\nfunction normalizeBrokerProduct(product: Record<string, unknown>, overlay?: Map<string, Record<string, unknown>>) {\n const category = product.category && typeof product.category === 'object'\n ? product.category as Record<string, unknown>\n : null\n const row = {\n id: product.id as string,\n tenant_id: product.tenantId as string,\n name: product.name as string,\n slug: product.slug as string | undefined,\n description: product.description as string | null | undefined,\n price: product.price as number | null | undefined,\n compare_at_price: product.compareAtPrice as number | null | undefined,\n currency: product.currency as string | null | undefined,\n status: product.status as FayzShopProductStatus | null | undefined,\n inventory_count: product.inventoryCount as number | null | undefined,\n sku: product.sku as string | null | undefined,\n sort_order: product.sortOrder as number | null | undefined,\n metadata: product.metadata as Record<string, unknown> | null | undefined,\n images: Array.isArray(product.images)\n ? product.images.map((image): ProductImageRow => {\n const row = image as Record<string, unknown>\n return {\n id: String(row.id ?? ''),\n product_id: String(row.productId ?? product.id ?? ''),\n url: String(row.url ?? ''),\n alt_text: (row.altText as string | null | undefined) ?? null,\n sort_order: (row.sortOrder as number | null | undefined) ?? 0,\n is_primary: (row.isPrimary as boolean | null | undefined) ?? false,\n created_at: (row.createdAt as string | null | undefined) ?? null,\n }\n })\n : [],\n category_id: (product.categoryId ?? category?.id) as string | null | undefined,\n category: category ? { name: category.name as string | null | undefined } : null,\n is_physical: product.isPhysical as boolean | null | undefined,\n weight: product.weight as number | null | undefined,\n weight_unit: product.weightUnit as string | null | undefined,\n created_at: product.createdAt as string | null | undefined,\n updated_at: product.updatedAt as string | null | undefined,\n } satisfies ProductRow\n return rowToProduct(row, overlay)\n}\n\nfunction normalizeBrokerCategory(category: Record<string, unknown>) {\n return {\n id: category.id as string,\n tenantId: (category.tenantId as string | undefined) ?? 'global',\n name: category.name as string,\n slug: (category.slug as string | undefined) ?? slugify(category.name as string),\n description: (category.description as string | null | undefined) ?? null,\n parentId: (category.parentId as string | null | undefined) ?? null,\n sortOrder: (category.sortOrder as number | null | undefined) ?? 0,\n imageUrl: (category.imageUrl as string | null | undefined) ?? null,\n createdAt: (category.createdAt as string | null | undefined) ?? nowIso(),\n }\n}\n\nfunction createBrokerShopProvider(options: FayzShopProviderOptions) {\n if (!options.apiBaseUrl || !options.projectId) {\n throw new FayzShopError('Fayz Shop broker mode requires apiBaseUrl and projectId.', 400)\n }\n\n const fetcher = options.fetcher ?? fetch\n const apiBaseUrl = normalizeBaseUrl(options.apiBaseUrl)\n const projectId = encodeURIComponent(options.projectId)\n const productMetadataOverlay = buildProductMetadataOverlay(options.productMetadata)\n\n async function request<T>(path: string, init: RequestInit = {}): Promise<T> {\n const response = await fetcher(`${apiBaseUrl}/public/projects/${projectId}/shop${path}`, init)\n const text = await response.text()\n let body: unknown\n try {\n body = text ? JSON.parse(text) : undefined\n } catch {\n body = text\n }\n if (!response.ok) {\n const message = typeof body === 'object' && body\n ? String((body as { message?: unknown; error?: unknown }).message ?? (body as { error?: unknown }).error ?? `Fayz Shop broker request failed with status ${response.status}`)\n : `Fayz Shop broker request failed with status ${response.status}`\n throw new FayzShopError(message, response.status, body)\n }\n return body as T\n }\n\n return {\n async listProducts(options?: FayzShopListProductsOptions) {\n if (options?.slug) {\n const product = await this.getProduct(options.slug)\n return product ? [product] : []\n }\n\n const response = await request<{ products?: Array<Record<string, unknown>> }>(appendQuery('/products', {\n status: options?.status,\n categoryId: options?.categoryId,\n search: options?.search,\n limit: options?.limit,\n offset: options?.offset,\n orderBy: options?.orderBy,\n order: options?.order,\n }))\n return (response.products ?? []).map((product) => normalizeBrokerProduct(product, productMetadataOverlay))\n },\n async getProduct(id: string) {\n const response = await request<{ product?: Record<string, unknown> | null }>(`/products/${encodeURIComponent(id)}`)\n return response.product ? normalizeBrokerProduct(response.product, productMetadataOverlay) : null\n },\n async createProduct() {\n throw new FayzShopError('Product writes require the Fayz admin/broker API.', 501)\n },\n async updateProduct() {\n throw new FayzShopError('Product writes require the Fayz admin/broker API.', 501)\n },\n async deleteProduct() {\n throw new FayzShopError('Product writes require the Fayz admin/broker API.', 501)\n },\n async uploadProductImage() {\n throw new FayzShopError('Product image uploads require the Fayz admin/broker API.', 501)\n },\n async deleteProductImage() {\n throw new FayzShopError('Product image deletes require the Fayz admin/broker API.', 501)\n },\n async listCategories() {\n const response = await request<{ categories?: Array<Record<string, unknown>> }>('/categories')\n return (response.categories ?? []).map(normalizeBrokerCategory)\n },\n async createCategory() {\n throw new FayzShopError('Category writes require the Fayz admin/broker API.', 501)\n },\n async updateCategory() {\n throw new FayzShopError('Category writes require the Fayz admin/broker API.', 501)\n },\n async deleteCategory() {\n throw new FayzShopError('Category deletes require the Fayz admin/broker API.', 501)\n },\n async listOrders() {\n throw new FayzShopError('Order reads require the Fayz admin/broker API.', 501)\n },\n async getOrder() {\n throw new FayzShopError('Order reads require the Fayz admin/broker API.', 501)\n },\n async createOrder() {\n throw new FayzShopError('Order writes require the Fayz admin/broker API.', 501)\n },\n async updateOrder() {\n throw new FayzShopError('Order writes require the Fayz admin/broker API.', 501)\n },\n async placeOrder() {\n throw new FayzShopError('Order placement requires the Fayz admin/broker API.', 501)\n },\n async listCustomers() {\n throw new FayzShopError('Customer reads require the Fayz admin/broker API.', 501)\n },\n async getCustomer() {\n throw new FayzShopError('Customer reads require the Fayz admin/broker API.', 501)\n },\n async createCustomer() {\n throw new FayzShopError('Customer writes require the Fayz admin/broker API.', 501)\n },\n async updateCustomer() {\n throw new FayzShopError('Customer writes require the Fayz admin/broker API.', 501)\n },\n async deleteCustomer() {\n throw new FayzShopError('Customer writes require the Fayz admin/broker API.', 501)\n },\n async listDiscounts() {\n throw new FayzShopError('Discount reads require the Fayz admin/broker API.', 501)\n },\n async getDiscount() {\n throw new FayzShopError('Discount reads require the Fayz admin/broker API.', 501)\n },\n async createDiscount() {\n throw new FayzShopError('Discount writes require the Fayz admin/broker API.', 501)\n },\n async updateDiscount() {\n throw new FayzShopError('Discount writes require the Fayz admin/broker API.', 501)\n },\n async deleteDiscount() {\n throw new FayzShopError('Discount deletes require the Fayz admin/broker API.', 501)\n },\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { appParams, resolveAppParams } from './app-params';
|
|
2
|
+
export { fayzPlatformOrigin } from './lib/platform-url';
|
|
2
3
|
export { createDedupedFetch, getDedupeStats, resetDedupeStats } from './lib/dedupe-fetch';
|
|
3
4
|
export type { DedupeFetchOptions, DedupeStats } from './lib/dedupe-fetch';
|
|
4
5
|
export { createFayzClient, fayz, FayzApiError } from './client';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,kB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B,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,eAAe,GAChB,MAAM,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { fayzPackageVersionSets, resolveFayzPackageDependencies, resolveFayzPackageVersion, resolveFayzPackageVersions } from './chunk-
|
|
1
|
+
export { fayzPackageVersionSets, resolveFayzPackageDependencies, resolveFayzPackageVersion, resolveFayzPackageVersions } from './chunk-M5CVCRIL.js';
|
|
2
2
|
export { surface as fayzSupportedSurface, getInternalPackages, getSupportedPackages, isSupportedPackage } from './chunk-6UZOXHGJ.js';
|
|
3
3
|
export { AI_BUILDER_REQUEST_CLASSES, AI_BUILDER_REQUEST_CLASS_IDS, isAllowedRequestClass } from './chunk-BJFMBVMP.js';
|
|
4
4
|
export { FayzApiError, createFayzClient, fayz } from './chunk-UWOQAD5A.js';
|
|
5
5
|
export { FayzRuntimeError, createFayzRuntimeClient } from './chunk-FRIOW6KW.js';
|
|
6
6
|
export { appParams, resolveAppParams } from './chunk-YGX37DT3.js';
|
|
7
7
|
export { FayzAgentError, createFayzAgentClient } from './chunk-LSBVNW75.js';
|
|
8
|
-
export { FayzShopError, createDedupedFetch, createFayzShopProvider, getDedupeStats, resetDedupeStats } from './chunk-
|
|
8
|
+
export { FayzShopError, createDedupedFetch, createFayzShopProvider, getDedupeStats, resetDedupeStats } from './chunk-QLTIO3QK.js';
|
|
9
9
|
export { deprecationMessage, deprecationWindowMinors, deprecationsForCodemod, fayzDeprecationPolicy, table as fayzDeprecationRegistry, getDeprecation, hasDeprecation, isDeprecationShimmed, listDeprecationCodemods, listDeprecations, resetDeprecationWarnings, warnDeprecated } from './chunk-HA5O3CW7.js';
|
|
10
10
|
|
|
11
11
|
// src/lib/platform-url.ts
|
|
@@ -310,6 +310,6 @@ function createFayzRuntimeTokenSource(options) {
|
|
|
310
310
|
return source;
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
export { ConnectorCredentialSinkError, ConnectorOAuthError, ConnectorOAuthStarterMissingError, FayzRuntimeTokenError, createFayzConnectorCredentialSink, createFayzConnectorOAuthStarter, createFayzRuntimeTokenSource, fayzConnectorOAuth, getConnectorCredentialSink, getConnectorOAuthStarter, setConnectorCredentialSink, setConnectorOAuthStarter, startConnectorOAuth };
|
|
313
|
+
export { ConnectorCredentialSinkError, ConnectorOAuthError, ConnectorOAuthStarterMissingError, FayzRuntimeTokenError, createFayzConnectorCredentialSink, createFayzConnectorOAuthStarter, createFayzRuntimeTokenSource, fayzConnectorOAuth, fayzPlatformOrigin, getConnectorCredentialSink, getConnectorOAuthStarter, setConnectorCredentialSink, setConnectorOAuthStarter, startConnectorOAuth };
|
|
314
314
|
//# sourceMappingURL=index.js.map
|
|
315
315
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
export interface AppShellPwaOptions {
|
|
3
|
+
/** Install name. Default: the app's package.json name, de-scoped and titled. */
|
|
4
|
+
name?: string;
|
|
5
|
+
/** Home-screen label, ideally ≤12 chars. Default: derived from `name`. */
|
|
6
|
+
shortName?: string;
|
|
7
|
+
/** Browser chrome / icon color. Default: the boot screen's neutral rail. */
|
|
8
|
+
themeColor?: string;
|
|
9
|
+
/** Splash background while the app boots. Default: the boot screen's page. */
|
|
10
|
+
backgroundColor?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function appShellPwa(root: string, opts?: AppShellPwaOptions): Plugin;
|
|
13
|
+
//# sourceMappingURL=app-shell-pwa.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-shell-pwa.d.ts","sourceRoot":"","sources":["../../src/lib/app-shell-pwa.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAqBlC,MAAM,WAAW,kBAAkB;IACjC,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,8EAA8E;IAC9E,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AA+ND,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,kBAAuB,GAAG,MAAM,CAyE/E"}
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
2
|
export interface BootSkeletonOptions {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* 'admin' additionally seeds the app's stored palette tokens (sidebar) into
|
|
5
|
+
* the document before React paints, so the console's rail mounts in its own
|
|
6
|
+
* color; 'page' skips that; 'none' injects nothing. Both visible surfaces
|
|
7
|
+
* paint the same background-colored screen. Default: 'admin' when the app
|
|
8
|
+
* depends on @fayz-ai/admin or @fayz-ai/saas and not on @fayz-ai/storefront,
|
|
9
|
+
* 'page' otherwise.
|
|
8
10
|
*/
|
|
9
|
-
surface?: 'admin' | 'none';
|
|
10
|
-
/**
|
|
11
|
+
surface?: 'admin' | 'page' | 'none';
|
|
12
|
+
/** @deprecated The boot screen paints the theme background, not the rail.
|
|
13
|
+
* Accepted and ignored. */
|
|
11
14
|
sidebar?: string;
|
|
12
|
-
/**
|
|
13
|
-
* no page background on it any more. Accepted and ignored. */
|
|
15
|
+
/** Boot background, light mode. */
|
|
14
16
|
background?: string;
|
|
17
|
+
/** Boot background, dark mode. */
|
|
18
|
+
backgroundDark?: string;
|
|
15
19
|
}
|
|
16
20
|
/** localStorage key the admin writes its resolved palette to, so the NEXT boot
|
|
17
21
|
* paints in the app's own colors instead of the neutral default. */
|
|
18
22
|
export declare const BOOT_THEME_STORAGE_KEY = "fayz:boot-theme";
|
|
23
|
+
/** localStorage key the admin theme store writes the chosen mode to
|
|
24
|
+
* ('light' | 'dark' | 'system', default 'light'). Duplicated as a literal on
|
|
25
|
+
* both sides — see persistBootPalette in packages/admin/src/theme/utils.ts:
|
|
26
|
+
* the app runtime must not depend on the build-tool package, and this file
|
|
27
|
+
* must not depend on the admin package. */
|
|
28
|
+
export declare const THEME_MODE_STORAGE_KEY = "saas-core:theme-mode";
|
|
29
|
+
/** The same thing under @fayz-ai/ui's own theme store, which is what a
|
|
30
|
+
* storefront or member app runs (packages/ui/src/stores/theme.store.ts). */
|
|
31
|
+
export declare const UI_THEME_MODE_STORAGE_KEY = "fayz-ui:theme-mode";
|
|
19
32
|
export declare function fayzBootSkeleton(root: string, opts?: BootSkeletonOptions): Plugin;
|
|
20
33
|
//# sourceMappingURL=boot-skeleton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot-skeleton.d.ts","sourceRoot":"","sources":["../../src/lib/boot-skeleton.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"boot-skeleton.d.ts","sourceRoot":"","sources":["../../src/lib/boot-skeleton.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAyBlC,MAAM,WAAW,mBAAmB;IAClC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;IACnC;gCAC4B;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,kCAAkC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED;qEACqE;AACrE,eAAO,MAAM,sBAAsB,oBAAoB,CAAA;AAEvD;;;;4CAI4C;AAC5C,eAAO,MAAM,sBAAsB,yBAAyB,CAAA;AAE5D;6EAC6E;AAC7E,eAAO,MAAM,yBAAyB,uBAAuB,CAAA;AAuI7D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,mBAAwB,GAAG,MAAM,CAgCrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dedupe-fetch.d.ts","sourceRoot":"","sources":["../../src/lib/dedupe-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"dedupe-fetch.d.ts","sourceRoot":"","sources":["../../src/lib/dedupe-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoBH,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC;AAED,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAA;IACjB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAA;CACjB;AAYD,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAkBD,wBAAgB,kBAAkB,CAGhC,SAAS,GAAE,OAAO,KAAmC,EACrD,OAAO,GAAE,kBAAuB,GAC/B,OAAO,KAAK,CAsDd"}
|
package/dist/release-channels.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { fayzPackageVersionSets, resolveFayzPackageDependencies, resolveFayzPackageVersion, resolveFayzPackageVersions } from './chunk-
|
|
1
|
+
export { fayzPackageVersionSets, resolveFayzPackageDependencies, resolveFayzPackageVersion, resolveFayzPackageVersions } from './chunk-M5CVCRIL.js';
|
|
2
2
|
//# sourceMappingURL=release-channels.js.map
|
|
3
3
|
//# sourceMappingURL=release-channels.js.map
|