@fayz-ai/sdk 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +2 -2
  2. package/dist/ai-builder.js +1 -1
  3. package/dist/{chunk-2YJXKDHO.js → chunk-6UZOXHGJ.js} +11 -6
  4. package/dist/chunk-6UZOXHGJ.js.map +1 -0
  5. package/dist/{chunk-V4GWI7WH.js → chunk-7UXTYT6I.js} +65 -4
  6. package/dist/chunk-7UXTYT6I.js.map +1 -0
  7. package/dist/{chunk-7XM4LONE.js → chunk-BJFMBVMP.js} +2 -2
  8. package/dist/chunk-BJFMBVMP.js.map +1 -0
  9. package/dist/chunk-HA5O3CW7.js +181 -0
  10. package/dist/chunk-HA5O3CW7.js.map +1 -0
  11. package/dist/chunk-VRUPJGFZ.js +135 -0
  12. package/dist/chunk-VRUPJGFZ.js.map +1 -0
  13. package/dist/deprecations.d.ts +98 -0
  14. package/dist/deprecations.d.ts.map +1 -0
  15. package/dist/deprecations.js +3 -0
  16. package/dist/deprecations.js.map +1 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +5 -4
  20. package/dist/release-channels.js +1 -1
  21. package/dist/shop.d.ts +32 -0
  22. package/dist/shop.d.ts.map +1 -1
  23. package/dist/shop.js +2 -1
  24. package/dist/supported-surface.d.ts +8 -1
  25. package/dist/supported-surface.d.ts.map +1 -1
  26. package/dist/supported-surface.js +1 -1
  27. package/dist/vite.d.ts +30 -1
  28. package/dist/vite.d.ts.map +1 -1
  29. package/dist/vite.js +10 -2
  30. package/dist/vite.js.map +1 -1
  31. package/package.json +7 -14
  32. package/dist/chunk-2YJXKDHO.js.map +0 -1
  33. package/dist/chunk-7XM4LONE.js.map +0 -1
  34. package/dist/chunk-GQPVDQEB.js +0 -135
  35. package/dist/chunk-GQPVDQEB.js.map +0 -1
  36. package/dist/chunk-V4GWI7WH.js.map +0 -1
  37. package/src/agent.test.ts +0 -114
  38. package/src/agent.ts +0 -335
  39. package/src/ai-builder.ts +0 -115
  40. package/src/app-params.ts +0 -69
  41. package/src/client.test.ts +0 -176
  42. package/src/client.ts +0 -229
  43. package/src/index.ts +0 -94
  44. package/src/release-channels.json +0 -103
  45. package/src/release-channels.test.ts +0 -41
  46. package/src/release-channels.ts +0 -41
  47. package/src/runtime.test.ts +0 -123
  48. package/src/runtime.ts +0 -211
  49. package/src/shop.test.ts +0 -114
  50. package/src/shop.ts +0 -1118
  51. package/src/supported-surface.json +0 -40
  52. package/src/supported-surface.ts +0 -33
  53. package/src/types.ts +0 -67
  54. package/src/vite.ts +0 -121
package/README.md CHANGED
@@ -38,7 +38,7 @@ const { rows, total } = await fayz.data.listRows({
38
38
  ```
39
39
 
40
40
  ## Part of the Fayz SDK
41
- The foundation client beneath `@fayz-ai/core`, `@fayz-ai/saas`, and every Fayz plugin.
41
+ The foundation client beneath `@fayz-ai/core`, `@fayz-ai/admin`, and every Fayz plugin.
42
42
 
43
43
  ## Roadmap & contributing
44
- Built and evolving in the open. See the [Fayz SDK roadmap](../../docs/ROADMAP.md#sdk) for current gaps, missing features, and good first issues.
44
+ Built and evolving in the open. See the [Fayz SDK roadmap](../../docs/platform/ROADMAP.md#sdk) for current gaps, missing features, and good first issues.
@@ -1,3 +1,3 @@
1
- export { AI_BUILDER_REQUEST_CLASSES, AI_BUILDER_REQUEST_CLASS_IDS, isAllowedRequestClass } from './chunk-7XM4LONE.js';
1
+ export { AI_BUILDER_REQUEST_CLASSES, AI_BUILDER_REQUEST_CLASS_IDS, isAllowedRequestClass } from './chunk-BJFMBVMP.js';
2
2
  //# sourceMappingURL=ai-builder.js.map
3
3
  //# sourceMappingURL=ai-builder.js.map
@@ -1,17 +1,19 @@
1
1
  // src/supported-surface.json
2
2
  var supported_surface_default = {
3
3
  surfaceVersion: 1,
4
- description: "Packages a generated Fayz app may depend on. fayz doctor warns on any app dependency outside this list. See docs/ARCHITECTURE.md (boundary model).",
4
+ description: "Packages a generated Fayz app may depend on. fayz doctor warns on any app dependency outside this list. See docs/platform/ARCHITECTURE.md (boundary model).",
5
5
  tiers: {
6
- stable: "semver-tracked, supported public API"
6
+ stable: "semver-tracked, supported public API",
7
+ deprecated: "still resolves and still builds, but is scheduled for removal \u2014 see deprecations.json for the replacement and the removeIn version"
7
8
  },
8
9
  supported: {
10
+ "@fayz-ai/admin": "stable",
9
11
  "@fayz-ai/auth": "stable",
10
12
  "@fayz-ai/core": "stable",
11
13
  "@fayz-ai/courses": "stable",
12
14
  "@fayz-ai/db": "stable",
13
15
  "@fayz-ai/portal": "stable",
14
- "@fayz-ai/saas": "stable",
16
+ "@fayz-ai/saas": "deprecated",
15
17
  "@fayz-ai/sdk": "stable",
16
18
  "@fayz-ai/shop": "stable",
17
19
  "@fayz-ai/storefront": "stable",
@@ -52,7 +54,10 @@ function isSupportedPackage(packageName) {
52
54
  if (!packageName.startsWith("@fayz-ai/")) return true;
53
55
  return packageName in surface.supported;
54
56
  }
57
+ function isDeprecatedPackage(packageName) {
58
+ return surface.supported[packageName] === "deprecated";
59
+ }
55
60
 
56
- export { getInternalPackages, getSupportedPackages, isSupportedPackage, surface };
57
- //# sourceMappingURL=chunk-2YJXKDHO.js.map
58
- //# sourceMappingURL=chunk-2YJXKDHO.js.map
61
+ export { getInternalPackages, getSupportedPackages, isDeprecatedPackage, isSupportedPackage, surface };
62
+ //# sourceMappingURL=chunk-6UZOXHGJ.js.map
63
+ //# sourceMappingURL=chunk-6UZOXHGJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/supported-surface.json","../src/supported-surface.ts"],"names":[],"mappings":";AAAA,IAAA,yBAAA,GAAA;AAAA,EACE,cAAA,EAAkB,CAAA;AAAA,EAClB,WAAA,EAAe,6JAAA;AAAA,EACf,KAAA,EAAS;AAAA,IACP,MAAA,EAAU,sCAAA;AAAA,IACV,UAAA,EAAc;AAAA,GAChB;AAAA,EACA,SAAA,EAAa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S,mBAAmB,WAAA,EAA8B;AAC/D,EAAA,IAAI,CAAC,WAAA,CAAY,UAAA,CAAW,WAAW,GAAG,OAAO,IAAA;AACjD,EAAA,OAAO,eAAe,OAAA,CAAQ,SAAA;AAChC;AAQO,SAAS,oBAAoB,WAAA,EAA8B;AAChE,EAAA,OAAO,OAAA,CAAQ,SAAA,CAAU,WAAW,CAAA,KAAM,YAAA;AAC5C","file":"chunk-6UZOXHGJ.js","sourcesContent":["{\n \"surfaceVersion\": 1,\n \"description\": \"Packages a generated Fayz app may depend on. fayz doctor warns on any app dependency outside this list. See docs/platform/ARCHITECTURE.md (boundary model).\",\n \"tiers\": {\n \"stable\": \"semver-tracked, supported public API\",\n \"deprecated\": \"still resolves and still builds, but is scheduled for removal — see deprecations.json for the replacement and the removeIn version\"\n },\n \"supported\": {\n \"@fayz-ai/admin\": \"stable\",\n \"@fayz-ai/auth\": \"stable\",\n \"@fayz-ai/core\": \"stable\",\n \"@fayz-ai/courses\": \"stable\",\n \"@fayz-ai/db\": \"stable\",\n \"@fayz-ai/portal\": \"stable\",\n \"@fayz-ai/saas\": \"deprecated\",\n \"@fayz-ai/sdk\": \"stable\",\n \"@fayz-ai/shop\": \"stable\",\n \"@fayz-ai/storefront\": \"stable\",\n \"@fayz-ai/ui\": \"stable\",\n \"@fayz-ai/plugin-agenda\": \"stable\",\n \"@fayz-ai/plugin-automations\": \"stable\",\n \"@fayz-ai/plugin-conversations\": \"stable\",\n \"@fayz-ai/plugin-courses\": \"stable\",\n \"@fayz-ai/plugin-crm\": \"stable\",\n \"@fayz-ai/plugin-dashboard\": \"stable\",\n \"@fayz-ai/plugin-financial\": \"stable\",\n \"@fayz-ai/plugin-forms\": \"stable\",\n \"@fayz-ai/plugin-inventory\": \"stable\",\n \"@fayz-ai/plugin-marketing\": \"stable\",\n \"@fayz-ai/plugin-menu\": \"stable\",\n \"@fayz-ai/plugin-orders\": \"stable\",\n \"@fayz-ai/plugin-reports\": \"stable\",\n \"@fayz-ai/plugin-reputation\": \"stable\",\n \"@fayz-ai/plugin-shop\": \"stable\",\n \"@fayz-ai/plugin-sites\": \"stable\",\n \"@fayz-ai/plugin-tables\": \"stable\",\n \"@fayz-ai/plugin-tasks\": \"stable\"\n },\n \"internal\": [\n \"@fayz-ai/app-runtime\"\n ]\n}\n","import supportedSurface from './supported-surface.json'\n\nexport type FayzPackageTier = 'stable' | 'deprecated'\n\nexport interface FayzSupportedSurface {\n surfaceVersion: number\n supported: Record<string, FayzPackageTier>\n internal: string[]\n}\n\nconst surface = supportedSurface as unknown as FayzSupportedSurface\n\n/** Every package a generated Fayz app is allowed to depend on (the public surface). */\nexport function getSupportedPackages(): string[] {\n return Object.keys(surface.supported)\n}\n\n/** Packages that exist but are NOT part of the public surface (deprecated/internal). */\nexport function getInternalPackages(): string[] {\n return [...surface.internal]\n}\n\n/**\n * True when `packageName` is part of the supported public surface. Used by\n * `fayz doctor` to warn (never fail) when an app depends on something off-surface.\n * Non-Fayz packages (no `@fayz-ai/` prefix) are out of scope and return true.\n */\nexport function isSupportedPackage(packageName: string): boolean {\n if (!packageName.startsWith('@fayz-ai/')) return true\n return packageName in surface.supported\n}\n\n/**\n * True when `packageName` is on the surface but scheduled for removal. Such a\n * package still builds — `fayz doctor` reports it as a migration to do, not as\n * a boundary violation. The replacement and removal version live in\n * `deprecations.json`.\n */\nexport function isDeprecatedPackage(packageName: string): boolean {\n return surface.supported[packageName] === 'deprecated'\n}\n\nexport { surface as fayzSupportedSurface }\n"]}
@@ -1,3 +1,5 @@
1
+ import { resetDeprecationWarnings, warnDeprecated } from './chunk-HA5O3CW7.js';
2
+
1
3
  // src/shop.ts
2
4
  var _accessTokenResolver = null;
3
5
  function setShopAccessTokenResolver(resolver) {
@@ -23,12 +25,22 @@ function nowIso() {
23
25
  function productMetadataKey(kind, value) {
24
26
  return `${kind}:${value.toLowerCase()}`;
25
27
  }
28
+ var PRODUCT_METADATA_OVERLAY_DEPRECATION = "shop.provider.productMetadata";
29
+ function resetProductMetadataOverlayDeprecationWarning() {
30
+ resetDeprecationWarnings();
31
+ }
26
32
  function buildProductMetadataOverlay(overlays) {
27
33
  const map = /* @__PURE__ */ new Map();
28
34
  for (const overlay of overlays ?? []) {
29
35
  if (overlay.sku) map.set(productMetadataKey("sku", overlay.sku), overlay.metadata);
30
36
  if (overlay.slug) map.set(productMetadataKey("slug", overlay.slug), overlay.metadata);
31
37
  }
38
+ if (map.size > 0) {
39
+ warnDeprecated(
40
+ PRODUCT_METADATA_OVERLAY_DEPRECATION,
41
+ `${map.size} product(s) overlaid \u2014`
42
+ );
43
+ }
32
44
  return map;
33
45
  }
34
46
  function asUuid(value) {
@@ -292,6 +304,49 @@ function createFayzShopProvider(options) {
292
304
  async deleteProductImage() {
293
305
  throw new FayzShopError("Product image deletes require the Fayz admin/broker API.", 501);
294
306
  },
307
+ /**
308
+ * Option axes + variants from the 0028 tables (spine M5) — the read that
309
+ * replaces the productMetadata overlay as the source of product options.
310
+ * Anon reads are already scoped by the storefront RLS (active variants of
311
+ * publicly readable products only).
312
+ */
313
+ async getProductVariants(productId) {
314
+ if (!asUuid(productId)) return { options: [], variants: [] };
315
+ const optionsQuery = new URLSearchParams();
316
+ optionsQuery.set("product_id", `eq.${productId}`);
317
+ optionsQuery.set("order", "position.asc");
318
+ const variantsQuery = new URLSearchParams();
319
+ variantsQuery.set("product_id", `eq.${productId}`);
320
+ variantsQuery.set("status", "eq.active");
321
+ variantsQuery.set("order", "position.asc");
322
+ const [optionRows, variantRows] = await Promise.all([
323
+ request(
324
+ "plg_shop_product_options",
325
+ { query: optionsQuery }
326
+ ),
327
+ request("plg_shop_product_variants", { query: variantsQuery })
328
+ ]);
329
+ return {
330
+ options: (optionRows ?? []).map((row) => ({
331
+ id: row.id,
332
+ name: row.name,
333
+ values: Array.isArray(row.values) ? row.values.map(String) : [],
334
+ position: row.position ?? 0
335
+ })),
336
+ variants: (variantRows ?? []).map((row) => ({
337
+ id: row.id,
338
+ productId: row.product_id,
339
+ options: row.options && typeof row.options === "object" ? row.options : {},
340
+ sku: row.sku ?? null,
341
+ price: row.price == null ? null : Number(row.price),
342
+ compareAtPrice: row.compare_at_price == null ? null : Number(row.compare_at_price),
343
+ inventoryCount: row.inventory_count ?? 0,
344
+ position: row.position ?? 0,
345
+ status: row.status ?? "active",
346
+ imageId: row.image_id ?? null
347
+ }))
348
+ };
349
+ },
295
350
  async listCategories() {
296
351
  const productQuery = tenantQuery();
297
352
  productQuery.set("select", "metadata");
@@ -419,8 +474,13 @@ function createFayzShopProvider(options) {
419
474
  method: "POST",
420
475
  body: JSON.stringify({
421
476
  p_tenant_id: input.tenantId ?? storeId,
477
+ // variant_id per line (0029): the RPC prices + decrements the variant
478
+ // when present. Pre-0029 servers ignore unknown jsonb keys, so lines
479
+ // stay compatible; p_metadata is a NAMED argument and is only sent
480
+ // when something contributed (unknown named args are rejected).
422
481
  p_items: input.items.map((line) => ({
423
482
  product_id: line.productId,
483
+ variant_id: asUuid(line.variantId) ?? void 0,
424
484
  quantity: line.quantity,
425
485
  options_label: line.optionsLabel ?? null
426
486
  })),
@@ -446,7 +506,8 @@ function createFayzShopProvider(options) {
446
506
  label: input.shippingAddress.label ?? null
447
507
  } : null,
448
508
  p_payment_method: input.paymentMethod ?? null,
449
- p_notes: input.notes ?? null
509
+ p_notes: input.notes ?? null,
510
+ ...input.metadata !== void 0 ? { p_metadata: input.metadata } : {}
450
511
  })
451
512
  });
452
513
  const order = await this.getOrder(orderId);
@@ -764,6 +825,6 @@ function createBrokerShopProvider(options) {
764
825
  };
765
826
  }
766
827
 
767
- export { FayzShopError, createFayzShopProvider, setShopAccessTokenResolver };
768
- //# sourceMappingURL=chunk-V4GWI7WH.js.map
769
- //# sourceMappingURL=chunk-V4GWI7WH.js.map
828
+ export { FayzShopError, PRODUCT_METADATA_OVERLAY_DEPRECATION, createFayzShopProvider, resetProductMetadataOverlayDeprecationWarning, setShopAccessTokenResolver };
829
+ //# sourceMappingURL=chunk-7UXTYT6I.js.map
830
+ //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AA;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-7UXTYT6I.js","sourcesContent":["import { resetDeprecationWarnings, warnDeprecated } from './deprecations'\n\nexport interface FayzShopProviderOptions {\n supabaseUrl?: string\n publishableKey?: string\n storeId?: 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\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 created_at?: string | null\n updated_at?: string | 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 created_at?: string | null\n updated_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 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 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 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 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 fetcher = options.fetcher ?? fetch\n const key = options.publishableKey\n const storeId = options.storeId\n const productMetadataOverlay = buildProductMetadataOverlay(options.productMetadata)\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 }>>('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 })),\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 query.set('select', '*,items:plg_shop_order_items(*)')\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 const query = singleById(id)\n query.set('select', '*,items:plg_shop_order_items(*)')\n // Anon storefronts have no table grant at all — the direct read throws\n // (401) rather than returning empty, so it must not short-circuit the\n // RPC fallback below.\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 // Anon storefronts can't SELECT plg_shop_orders (RLS); the order uuid acts\n // as the read capability through the whitelisted RPC.\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 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 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 }\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 }\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 async quoteShipping(postalCode: string, subtotal: number) {\n const digits = (postalCode || '').replace(/\\D/g, '')\n if (digits.length !== 8) return []\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 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"]}
@@ -80,5 +80,5 @@ function isAllowedRequestClass(id) {
80
80
  }
81
81
 
82
82
  export { AI_BUILDER_REQUEST_CLASSES, AI_BUILDER_REQUEST_CLASS_IDS, isAllowedRequestClass };
83
- //# sourceMappingURL=chunk-7XM4LONE.js.map
84
- //# sourceMappingURL=chunk-7XM4LONE.js.map
83
+ //# sourceMappingURL=chunk-BJFMBVMP.js.map
84
+ //# sourceMappingURL=chunk-BJFMBVMP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ai-builder.ts"],"names":[],"mappings":";AA4BO,IAAM,0BAAA,GAAsF;AAAA,EACjG,UAAA,EAAY;AAAA,IACV,EAAA,EAAI,UAAA;AAAA,IACJ,KAAA,EAAO,UAAA;AAAA,IACP,KAAA,EAAO,KAAA;AAAA,IACP,UAAA,EAAY,IAAA;AAAA,IACZ,SAAA,EAAW,KAAA;AAAA,IACX,WAAA,EAAa,KAAA;AAAA,IACb,WAAA,EACE,iMAAA;AAAA,IACF,QAAA,EAAU;AAAA,MACR,qCAAA;AAAA,MACA,qDAAA;AAAA,MACA;AAAA;AACF,GACF;AAAA,EACA,eAAA,EAAiB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A,+DAAA;AAAA,MACA;AAAA;AACF;AAEJ;AAEO,IAAM,+BAA+B,MAAA,CAAO,IAAA;AAAA,EACjD;AACF;AAGO,SAAS,sBAAsB,EAAA,EAAoC;AACxE,EAAA,OAAO,EAAA,KAAO,gBAAA;AAChB","file":"chunk-BJFMBVMP.js","sourcesContent":["// The AI Builder request taxonomy — the contract the platform's request\n// classifier targets. The classifier itself lives in the `fayz` platform repo;\n// this is the canonical source of truth for the request classes and the\n// architecture layer each is allowed to touch (docs/platform/ARCHITECTURE.md).\n\n/** Ownership layer a request may modify. */\nexport type FayzLayer = 'app' | 'plugin-config' | 'private-extension' | 'platform' | 'none'\n\nexport type AiBuilderRequestClass =\n | 'app-edit'\n | 'plugin-config'\n | 'private-extension'\n | 'platform-or-plugin-upgrade'\n | 'unsafe-blocked'\n\nexport interface AiBuilderRequestClassDef {\n id: AiBuilderRequestClass\n label: string\n /** Which ownership layer this class is allowed to modify. */\n layer: FayzLayer\n /** Who may perform it. */\n editableBy: 'ai' | 'partner' | 'fayz' | 'none'\n needsCode: boolean\n needsDeploy: boolean\n description: string\n examples: string[]\n}\n\nexport const AI_BUILDER_REQUEST_CLASSES: Record<AiBuilderRequestClass, AiBuilderRequestClassDef> = {\n 'app-edit': {\n id: 'app-edit',\n label: 'App edit',\n layer: 'app',\n editableBy: 'ai',\n needsCode: false,\n needsDeploy: false,\n description:\n 'Change the generated app: pages, routes, layout, theme, copy, blocks, slots. Manifest-level edits (ladder 1–4) need no code; custom components/pages (ladder 5–6) are app-owned code.',\n examples: [\n 'Change the brand color and headline',\n 'Add a new landing page with a hero and product grid',\n 'Reorder dashboard cards',\n ],\n },\n 'plugin-config': {\n id: 'plugin-config',\n label: 'Plugin config',\n layer: 'plugin-config',\n editableBy: 'ai',\n needsCode: false,\n needsDeploy: false,\n description:\n 'Configure an installed plugin as manifest data: enabled modules, fields, statuses, rules, feature flags, labels, currency.',\n examples: [\n 'Enable the reconciliation module in financial',\n 'Add a \"VIP\" status to clients',\n 'Turn on delivery pricing in the menu',\n ],\n },\n 'private-extension': {\n id: 'private-extension',\n label: 'Private extension',\n layer: 'private-extension',\n editableBy: 'partner',\n needsCode: true,\n needsDeploy: true,\n description:\n 'Add new business behaviour as an app-local plugin (own entities, data, migrations, AI tools, connectors). The sanctioned partner/Silvio path — scaffold with `fayz create plugin`. See CUSTOMIZATION.md.',\n examples: [\n 'Build a loyalty-points engine with its own table',\n 'Add a custom importer for a legacy ERP',\n 'Integrate a provider Fayz does not support yet (adapter)',\n ],\n },\n 'platform-or-plugin-upgrade': {\n id: 'platform-or-plugin-upgrade',\n label: 'Platform / plugin upgrade',\n layer: 'platform',\n editableBy: 'fayz',\n needsCode: true,\n needsDeploy: true,\n description:\n 'Change owned by Fayz: bump SDK/plugin versions, run manifest/DB migrations, evolve an engine. Not editable from a generated app.',\n examples: [\n 'Upgrade @fayz-ai/core across the fleet',\n 'Migrate manifests v2 → v3',\n 'Add a capability to an official plugin',\n ],\n },\n 'unsafe-blocked': {\n id: 'unsafe-blocked',\n label: 'Unsafe / blocked',\n layer: 'none',\n editableBy: 'none',\n needsCode: false,\n needsDeploy: false,\n description:\n 'Requests that would break the boundary and must be refused or rerouted: mutating SDK/runtime/plugin internals, forking an SDK page, importing a provider SDK directly into app code, or bypassing tenancy/permissions/security.',\n examples: [\n 'Edit the code inside @fayz-ai/plugin-crm',\n 'Copy an SDK page into the app and modify it',\n 'Call the Supabase client directly from a storefront component',\n 'Disable row-level security for a tenant',\n ],\n },\n}\n\nexport const AI_BUILDER_REQUEST_CLASS_IDS = Object.keys(\n AI_BUILDER_REQUEST_CLASSES,\n) as AiBuilderRequestClass[]\n\n/** True when a request class is permitted (anything but unsafe-blocked). */\nexport function isAllowedRequestClass(id: AiBuilderRequestClass): boolean {\n return id !== 'unsafe-blocked'\n}\n"]}
@@ -0,0 +1,181 @@
1
+ // src/deprecations.json
2
+ var deprecations_default = {
3
+ registryVersion: 1,
4
+ policy: {
5
+ minMinorsBeforeRemoval: 2,
6
+ summary: "Nothing is removed without a shim, and the deprecation is enumerable (spine I10). A deprecation is ANNOUNCED in a minor release and REMOVED no earlier than two minor releases later, so a store always has one whole release in which both the old and the new input work. Every shim's warning names its replacement (I2). Every row here carries a codemod id; a codemod that cannot be safe refuses and names the decision a human must make."
7
+ },
8
+ deprecations: [
9
+ {
10
+ id: "admin.package.saas",
11
+ package: "@fayz-ai/saas",
12
+ surface: "package-name",
13
+ title: "the @fayz-ai/saas package name",
14
+ deprecatedIn: "0.10.0",
15
+ removeIn: "0.12.0",
16
+ replacement: "@fayz-ai/admin \u2014 same exports, same subpaths (/ui, /db, /org, /billing, /permissions), renamed because the package is the admin surface (shell, CRUD engine, org, billing, permissions), not the business model",
17
+ shim: "packages/saas is now a thin package that re-exports @fayz-ai/admin, so an app that has not migrated builds and runs unchanged. What it costs is a second package in the graph and one console warning per entry point per session. It ships no implementation, so there is no behaviour to drift.",
18
+ where: ["packages/saas/src/index.ts", "packages/saas/package.json", "packages/sdk/src/vite.ts"],
19
+ detect: "The app's package.json depends on @fayz-ai/saas, or any file under src/ imports from '@fayz-ai/saas'.",
20
+ codemod: "admin.saas-package-rename",
21
+ reference: "packages/saas/README.md"
22
+ },
23
+ {
24
+ id: "shop.provider.productMetadata",
25
+ package: "@fayz-ai/sdk",
26
+ surface: "provider-option",
27
+ title: "createFayzShopProvider({ productMetadata })",
28
+ deprecatedIn: "0.9.0",
29
+ removeIn: "0.11.0",
30
+ replacement: "product variants \u2014 plg_shop_product_variants, read through products.bySlug / getProductVariants (admin > product > variants)",
31
+ shim: "The overlay is still merged into each product's metadata for DISPLAY, so a store passing it keeps rendering. What it no longer does is define the option axes checkout sells: 0028 variants are the sellable unit and 0029 prices and names an order line from them. An axis that exists only in the overlay renders a picker that resolves to no variant.",
32
+ where: ["packages/sdk/src/shop.ts", "packages/storefront/src/data/product-options.ts"],
33
+ detect: "The app passes `productMetadata` to createFayzShopProvider (usually src/config/shop.ts), or the running provider warns once per session.",
34
+ codemod: "shop.product-metadata-overlay",
35
+ reference: "docs/storefront/storefront-architecture-spine.md (M5), docs/storefront/storefront-contract.md"
36
+ },
37
+ {
38
+ id: "storefront.commerce.discounts",
39
+ package: "@fayz-ai/storefront",
40
+ surface: "document-field",
41
+ title: "config.discounts / commerce.discounts (percent coupon codes)",
42
+ deprecatedIn: "0.9.0",
43
+ removeIn: "0.11.0",
44
+ replacement: "promotions.promotions \u2014 a rule-engine Promotion with an eligibility rule on `code` and a percentage application method (spine M6, I8)",
45
+ shim: "The provider still honours the legacy path: every `{code, percent}` entry is translated by storefrontDiscountToPromotion and evaluated by the ONE rule engine, so the money is identical. What the legacy shape cannot express is everything the engine exists for \u2014 buy-N-get-M, tiers, minimum subtotal, product/category scoping, automatic application.",
46
+ where: [
47
+ "packages/shop/src/rules/adapter.ts",
48
+ "packages/storefront/src/hooks/use-discount-validator.ts",
49
+ "packages/storefront/src/document/sections.ts"
50
+ ],
51
+ detect: "commerce.discounts is present in the Store Document (config.discounts in a config-derived document).",
52
+ codemod: "commerce.discounts-to-promotions",
53
+ reference: "docs/storefront/storefront-architecture-spine.md (M6, I8), docs/storefront/storefront-contract.md"
54
+ },
55
+ {
56
+ id: "shop.inventory.directCountWrite",
57
+ package: "@fayz-ai/shop",
58
+ surface: "sql-column-write",
59
+ title: "direct writes to plg_shop_product_variants.inventory_count (and plg_shop_products.inventory_count)",
60
+ deprecatedIn: "0.9.0",
61
+ removeIn: "0.11.0",
62
+ replacement: "insert a plg_shop_stock_movements row (receipt / adjustment / loss / count) \u2014 the ledger is the truth and inventory_count is its mirror",
63
+ shim: "0036 turns a direct write to a VARIANT count into an `adjustment` movement with reason `legacy_write`, and 0037 forwards a write to the PRODUCT count to that product's default variant the same way. Both RAISE a WARNING. The quantities are exact; the taxonomy is not \u2014 the shim is told a number changed and never why, so a sale arriving this way is recorded as an adjustment with no order_id.",
64
+ where: [
65
+ "packages/shop/migrations/0036_inventory_count_mirror.sql",
66
+ "packages/shop/migrations/0037_default_variant.sql"
67
+ ],
68
+ signals: [
69
+ "DEPRECATED (I10): direct write to plg_shop_product_variants.inventory_count",
70
+ "DEPRECATED (I10): direct write to plg_shop_products.inventory_count"
71
+ ],
72
+ detect: "Not visible in a store's repo: it is a property of the callers writing to a pool. Count the `legacy_write` reason in plg_shop_stock_movements \u2014 that count IS the migration backlog.",
73
+ codemod: "shop.inventory-count-write",
74
+ reference: "docs/storefront/inventory-model.md \xA76, \xA79 step 3"
75
+ },
76
+ {
77
+ id: "shop.placeOrder.variantless",
78
+ package: "@fayz-ai/shop",
79
+ surface: "sql-code-path",
80
+ title: "the variantless leg of shop_place_order",
81
+ deprecatedIn: "0.9.0",
82
+ removeIn: "0.11.0",
83
+ replacement: "every product gets a default variant (migration 0037), and the variant is the universal sellable unit \u2014 the order line resolves a variant and the sale reaches the ledger",
84
+ shim: "0039 keeps the leg: a line whose product has no variant at all still sells, guarded against the product-level inventory_count exactly as before 0034. It emits one enumerable NOTICE per order naming the products that took it, so the deprecation is countable rather than silent. Such a sale does NOT reach the stock ledger, so it answers none of the questions inventory-model.md \xA70 exists for.",
85
+ where: ["packages/shop/migrations/0039_place_order_ledger.sql"],
86
+ signals: ["shop_place_order: DEPRECATED variantless stock path used for"],
87
+ detect: "Not visible in a store's repo: it is pool state. Its exit condition is in 0039's header \u2014 the count of products with no variant must read 0 on every pool.",
88
+ codemod: "shop.place-order-variantless",
89
+ reference: "docs/storefront/inventory-model.md \xA710 q6, packages/shop/migrations/0039_place_order_ledger.sql (header)"
90
+ },
91
+ {
92
+ id: "storefront.backend.supabaseUrl",
93
+ package: "@fayz-ai/storefront",
94
+ surface: "document-field",
95
+ title: "config.supabaseUrl / backend.supabaseUrl",
96
+ deprecatedIn: "0.9.0",
97
+ removeIn: "0.11.0",
98
+ replacement: "auth.supabase.url",
99
+ shim: "The legacy field still rides in the backend section so an old config round-trips losslessly, and hydrateStoreDocument still sets config.supabaseUrl from it.",
100
+ where: ["packages/storefront/src/document/sections.ts", "packages/storefront/src/document/round-trip.ts"],
101
+ detect: "backend.supabaseUrl is present in the Store Document.",
102
+ codemod: "backend.supabase-to-auth",
103
+ reference: "docs/storefront/storefront-contract.md"
104
+ },
105
+ {
106
+ id: "storefront.backend.supabaseAnonKey",
107
+ package: "@fayz-ai/storefront",
108
+ surface: "document-field",
109
+ title: "config.supabaseAnonKey / backend.supabaseAnonKey",
110
+ deprecatedIn: "0.9.0",
111
+ removeIn: "0.11.0",
112
+ replacement: "auth.supabase.anonKey",
113
+ shim: "The legacy field still rides in the backend section so an old config round-trips losslessly, and hydrateStoreDocument still sets config.supabaseAnonKey from it.",
114
+ where: ["packages/storefront/src/document/sections.ts", "packages/storefront/src/document/round-trip.ts"],
115
+ detect: "backend.supabaseAnonKey is present in the Store Document.",
116
+ codemod: "backend.supabase-to-auth",
117
+ reference: "docs/storefront/storefront-contract.md"
118
+ }
119
+ ]
120
+ };
121
+
122
+ // src/deprecations.ts
123
+ var table = deprecations_default;
124
+ var fayzDeprecationPolicy = table.policy;
125
+ function listDeprecations() {
126
+ return table.deprecations.map((row) => ({ ...row, where: [...row.where], signals: row.signals ? [...row.signals] : void 0 }));
127
+ }
128
+ function getDeprecation(id) {
129
+ const row = table.deprecations.find((entry) => entry.id === id);
130
+ if (!row) {
131
+ throw new Error(
132
+ `Unknown deprecation id "${id}". Valid: ${table.deprecations.map((entry) => entry.id).join(", ")}`
133
+ );
134
+ }
135
+ return row;
136
+ }
137
+ function hasDeprecation(id) {
138
+ return table.deprecations.some((entry) => entry.id === id);
139
+ }
140
+ function deprecationsForCodemod(codemod) {
141
+ return table.deprecations.filter((entry) => entry.codemod === codemod);
142
+ }
143
+ function listDeprecationCodemods() {
144
+ return [...new Set(table.deprecations.map((entry) => entry.codemod))];
145
+ }
146
+ function deprecationMessage(id, context) {
147
+ const row = getDeprecation(id);
148
+ const where = context ? ` ${context}` : "";
149
+ return `DEPRECATED (${row.id}):${where} ${row.title} is deprecated since ${row.deprecatedIn} and is REMOVED in ${row.removeIn}. Use instead: ${row.replacement}. Migrate with \`fayz upgrade\` (codemod ${row.codemod}).`;
150
+ }
151
+ var warned = /* @__PURE__ */ new Set();
152
+ function warnDeprecated(id, context) {
153
+ if (warned.has(id)) return false;
154
+ warned.add(id);
155
+ console.warn(deprecationMessage(id, context));
156
+ return true;
157
+ }
158
+ function resetDeprecationWarnings() {
159
+ warned.clear();
160
+ }
161
+ function minorOf(version) {
162
+ const [major = "0", minor = "0"] = version.split(".");
163
+ return { major: Number(major), minor: Number(minor) };
164
+ }
165
+ function isDeprecationShimmed(id, version) {
166
+ const row = getDeprecation(id);
167
+ const at = minorOf(version);
168
+ const gone = minorOf(row.removeIn);
169
+ if (at.major !== gone.major) return at.major < gone.major;
170
+ return at.minor < gone.minor;
171
+ }
172
+ function deprecationWindowMinors(row) {
173
+ const from = minorOf(row.deprecatedIn);
174
+ const to = minorOf(row.removeIn);
175
+ if (to.major > from.major) return Number.POSITIVE_INFINITY;
176
+ return to.minor - from.minor;
177
+ }
178
+
179
+ export { deprecationMessage, deprecationWindowMinors, deprecationsForCodemod, fayzDeprecationPolicy, getDeprecation, hasDeprecation, isDeprecationShimmed, listDeprecationCodemods, listDeprecations, resetDeprecationWarnings, table, warnDeprecated };
180
+ //# sourceMappingURL=chunk-HA5O3CW7.js.map
181
+ //# sourceMappingURL=chunk-HA5O3CW7.js.map