@nextblock-cms/cortex 0.19.2 → 0.19.3

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.
@@ -350,14 +350,14 @@ function Bn(e) {
350
350
  success: !1
351
351
  };
352
352
  }
353
- function Mn(e) {
353
+ function qn(e) {
354
354
  return e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/\s+/g, " ").trim();
355
355
  }
356
356
  function ce(e, t) {
357
357
  return t.some((n) => e.includes(n));
358
358
  }
359
359
  function Oo(e) {
360
- const t = Mn(e), n = ce(t, ["add ", "insert ", "put ", "create "]), r = ce(t, [
360
+ const t = qn(e), n = ce(t, ["add ", "insert ", "put ", "create "]), r = ce(t, [
361
361
  "title",
362
362
  "heading",
363
363
  "description",
@@ -420,7 +420,7 @@ function E(e) {
420
420
  throw new Error("A Supabase service client is required to execute Cortex AI global tools.");
421
421
  return e.supabase;
422
422
  }
423
- function qn(e, t, n) {
423
+ function Mn(e, t, n) {
424
424
  let r;
425
425
  const o = new Promise((i) => {
426
426
  r = setTimeout(() => i(n()), t);
@@ -719,23 +719,23 @@ function Ft(e, t) {
719
719
  function Ze(e, t) {
720
720
  return t?.customBlockDefinitions?.find((n) => n.slug === e) ?? null;
721
721
  }
722
- function Me(e, t = /* @__PURE__ */ new Set(), n = 0) {
722
+ function qe(e, t = /* @__PURE__ */ new Set(), n = 0) {
723
723
  if (n > 12 || !e)
724
724
  return t;
725
725
  if (typeof e == "string")
726
726
  return t.add(e), t;
727
727
  if (Array.isArray(e)) {
728
728
  for (const r of e)
729
- Me(r, t, n + 1);
729
+ qe(r, t, n + 1);
730
730
  return t;
731
731
  }
732
732
  if (typeof e == "object")
733
733
  for (const [r, o] of Object.entries(e))
734
- (r === "block_type" || r === "blockType" || r === "anchorBlockType") && typeof o == "string" ? t.add(o) : o && typeof o == "object" && Me(o, t, n + 1);
734
+ (r === "block_type" || r === "blockType" || r === "anchorBlockType") && typeof o == "string" ? t.add(o) : o && typeof o == "object" && qe(o, t, n + 1);
735
735
  return t;
736
736
  }
737
737
  async function K(e, t) {
738
- return e?.customBlockDefinitions || !e?.supabase || ![...Me(t)].some((o) => !oe(o)) ? e : {
738
+ return e?.customBlockDefinitions || !e?.supabase || ![...qe(t)].some((o) => !oe(o)) ? e : {
739
739
  ...e,
740
740
  customBlockDefinitions: await vn(e.supabase)
741
741
  };
@@ -872,7 +872,7 @@ function Y(e) {
872
872
  function pt(e) {
873
873
  return typeof e == "string" ? e.trim().toLowerCase() : "";
874
874
  }
875
- function Mt(e) {
875
+ function qt(e) {
876
876
  return e.reduce((t, n) => t + 1 + (n.children?.length || 0), 0);
877
877
  }
878
878
  function de(e) {
@@ -913,7 +913,7 @@ async function Ue(e, t) {
913
913
  id: Number(i.id)
914
914
  };
915
915
  }
916
- async function qe(e) {
916
+ async function Me(e) {
917
917
  try {
918
918
  const { data: t, error: n } = await e.from("currencies").select("code, is_default, is_active").eq("is_active", !0);
919
919
  if (n)
@@ -1032,13 +1032,13 @@ async function cr(e) {
1032
1032
  pageId: Number(o.id)
1033
1033
  };
1034
1034
  }
1035
- async function qt(e) {
1035
+ async function Mt(e) {
1036
1036
  const t = await Q(e.supabase, e.languageCode), { data: n, error: r } = await e.supabase.from("navigation_items").select("id, parent_id").eq("menu_key", e.menuKey).eq("language_id", t.id);
1037
1037
  if (r)
1038
1038
  throw new Error(
1039
1039
  `Failed to inspect existing ${e.menuKey} navigation items: ${_(r)}`
1040
1040
  );
1041
- const o = Array.isArray(n) ? n : [], i = o.filter((d) => d.parent_id == null).length, a = Mt(e.items);
1041
+ const o = Array.isArray(n) ? n : [], i = o.filter((d) => d.parent_id == null).length, a = qt(e.items);
1042
1042
  jt({
1043
1043
  existingItemCount: o.length,
1044
1044
  existingTopLevelCount: i,
@@ -1095,7 +1095,7 @@ async function lr(e) {
1095
1095
  existingTopLevelCount: o.filter((i) => i.parent_id == null).length,
1096
1096
  languageCode: t.code,
1097
1097
  menuKey: e.menuKey,
1098
- replacementItemCount: Mt(e.items)
1098
+ replacementItemCount: qt(e.items)
1099
1099
  });
1100
1100
  }
1101
1101
  async function ur(e) {
@@ -1186,7 +1186,7 @@ function pr(e) {
1186
1186
  }
1187
1187
  function mr(e) {
1188
1188
  const t = x(e.field_type ?? e.fieldType ?? e.type ?? e.input_type).toLowerCase().replace(/\s+/g, "_"), n = x(e.label ?? e.name ?? e.placeholder).toLowerCase();
1189
- return ["email", "textarea", "select", "radio", "checkbox", "text"].includes(t) ? t : n.includes("email") ? "email" : n.includes("message") || n.includes("comment") || n.includes("details") ? "textarea" : "text";
1189
+ return ["email", "tel", "url", "number", "textarea", "select", "radio", "checkbox", "text"].includes(t) ? t : ["phone", "telephone", "phone_number", "mobile"].includes(t) ? "tel" : ["website", "link", "uri"].includes(t) ? "url" : ["numeric", "integer", "quantity"].includes(t) ? "number" : n.includes("email") || n.includes("courriel") ? "email" : n.includes("phone") || n.includes("téléphone") || n.includes("telephone") ? "tel" : n.includes("website") || n.includes("site web") ? "url" : n.includes("message") || n.includes("comment") || n.includes("details") ? "textarea" : "text";
1190
1190
  }
1191
1191
  function gr(e) {
1192
1192
  return (Array.isArray(e) && e.length > 0 ? e : [
@@ -1215,7 +1215,7 @@ const fr = /* @__PURE__ */ new Set(["none", "sm", "md", "lg", "xl"]), mt = /* @_
1215
1215
  function kr(e) {
1216
1216
  return typeof e == "string" && /^https?:\/\//i.test(e.trim());
1217
1217
  }
1218
- function q(e, t, n) {
1218
+ function M(e, t, n) {
1219
1219
  return typeof e == "string" && t.has(e) ? e : n;
1220
1220
  }
1221
1221
  function Ir(e) {
@@ -1234,9 +1234,9 @@ function Tr(e) {
1234
1234
  function gt(e) {
1235
1235
  if (!A(e))
1236
1236
  return { type: "none" };
1237
- const t = q(e.type, br, "none"), n = typeof e.min_height == "string" && e.min_height.trim() ? { min_height: e.min_height } : {};
1237
+ const t = M(e.type, br, "none"), n = typeof e.min_height == "string" && e.min_height.trim() ? { min_height: e.min_height } : {};
1238
1238
  if (t === "theme")
1239
- return { theme: q(e.theme, _r, "muted"), type: t, ...n };
1239
+ return { theme: M(e.theme, _r, "muted"), type: t, ...n };
1240
1240
  if (t === "solid")
1241
1241
  return typeof e.solid_color == "string" && e.solid_color.trim() ? { solid_color: e.solid_color, type: t, ...n } : { type: "none" };
1242
1242
  if (t === "gradient")
@@ -1247,7 +1247,7 @@ function gt(e) {
1247
1247
  image: {
1248
1248
  ...r,
1249
1249
  ...o ? { external_url: o } : {},
1250
- position: q(r.position, wr, "center"),
1250
+ position: M(r.position, wr, "center"),
1251
1251
  size: r.size === "contain" ? "contain" : "cover"
1252
1252
  },
1253
1253
  type: t,
@@ -1266,14 +1266,14 @@ function vr(e, t, n) {
1266
1266
  ...e,
1267
1267
  background: gt(e.background),
1268
1268
  column_blocks: a,
1269
- column_gap: q(e.column_gap, fr, "lg"),
1270
- container_type: q(e.container_type, hr, "container"),
1269
+ column_gap: M(e.column_gap, fr, "lg"),
1270
+ container_type: M(e.container_type, hr, "container"),
1271
1271
  padding: {
1272
- bottom: q(g.bottom, mt, "xl"),
1273
- top: q(g.top, mt, "xl")
1272
+ bottom: M(g.bottom, mt, "xl"),
1273
+ top: M(g.top, mt, "xl")
1274
1274
  },
1275
1275
  responsive_columns: { desktop: c, mobile: h, tablet: m },
1276
- vertical_alignment: q(
1276
+ vertical_alignment: M(
1277
1277
  e.vertical_alignment,
1278
1278
  yr,
1279
1279
  r ? "center" : "start"
@@ -1511,7 +1511,7 @@ async function Gt(e, t) {
1511
1511
  languageCode: n.languageCode,
1512
1512
  menuKey: "HEADER",
1513
1513
  supabase: r
1514
- }) : await qt({
1514
+ }) : await Mt({
1515
1515
  items: n.items,
1516
1516
  languageCode: n.languageCode,
1517
1517
  menuKey: "HEADER",
@@ -1543,7 +1543,7 @@ async function zt(e, t) {
1543
1543
  if (o)
1544
1544
  return o;
1545
1545
  let i = null;
1546
- if (n.links?.length && (i = await qt({
1546
+ if (n.links?.length && (i = await Mt({
1547
1547
  items: n.links,
1548
1548
  languageCode: n.languageCode,
1549
1549
  menuKey: "FOOTER",
@@ -1614,7 +1614,7 @@ async function Er(e, t) {
1614
1614
  }
1615
1615
  async function $r(e, t, n = $n) {
1616
1616
  const r = He.safeParse(e), o = r.success ? r.data.query : "";
1617
- return qn(
1617
+ return Mn(
1618
1618
  Er(e, t),
1619
1619
  n,
1620
1620
  () => ({
@@ -1740,8 +1740,8 @@ async function Ur(e, t) {
1740
1740
  throw new Error(`Failed to fetch ecommerce stats: ${_(w.error)}`);
1741
1741
  const I = Array.isArray(f) ? f : [], T = Array.isArray(b) ? b : [], k = yt(I), v = Array.isArray(w.data) ? w.data : null, $ = v ? yt(v) : null, F = {};
1742
1742
  for (const C of T) {
1743
- const P = Array.isArray(C.orders) ? C.orders[0] : C.orders, M = String(P?.currency || c || "unknown").toUpperCase();
1744
- F[M] = (F[M] ?? 0) + ne(C.quantity) * ne(C.price_at_purchase) / 100;
1743
+ const P = Array.isArray(C.orders) ? C.orders[0] : C.orders, q = String(P?.currency || c || "unknown").toUpperCase();
1744
+ F[q] = (F[q] ?? 0) + ne(C.quantity) * ne(C.price_at_purchase) / 100;
1745
1745
  }
1746
1746
  const ee = {
1747
1747
  currency: c ?? null,
@@ -1766,19 +1766,19 @@ async function Ur(e, t) {
1766
1766
  }), n.reportType === "products" || n.reportType === "revenue" || n.reportType === "general") {
1767
1767
  const C = {};
1768
1768
  for (const P of T) {
1769
- const M = Array.isArray(P.products) ? P.products[0] : P.products;
1770
- if (!M?.id)
1769
+ const q = Array.isArray(P.products) ? P.products[0] : P.products;
1770
+ if (!q?.id)
1771
1771
  continue;
1772
- const te = M.id;
1772
+ const te = q.id;
1773
1773
  C[te] || (C[te] = {
1774
1774
  id: te,
1775
1775
  quantity: 0,
1776
1776
  revenue: 0,
1777
- title: M.title,
1778
- type: M.product_type
1777
+ title: q.title,
1778
+ type: q.product_type
1779
1779
  }), C[te].quantity += ne(P.quantity), C[te].revenue += ne(P.quantity) * ne(P.price_at_purchase) / 100;
1780
1780
  }
1781
- ee.topProducts = Object.values(C).sort((P, M) => M.revenue - P.revenue).slice(0, 10);
1781
+ ee.topProducts = Object.values(C).sort((P, q) => q.revenue - P.revenue).slice(0, 10);
1782
1782
  }
1783
1783
  return {
1784
1784
  report: ee,
@@ -2391,7 +2391,7 @@ async function at(e, t) {
2391
2391
  translationGroupId: p.translation_group_id
2392
2392
  };
2393
2393
  }
2394
- function Mr(e, t) {
2394
+ function qr(e, t) {
2395
2395
  return (t || L(e) || "product").replace(/-/g, "").slice(0, 24).toUpperCase();
2396
2396
  }
2397
2397
  function Zt(e) {
@@ -2415,7 +2415,7 @@ function Zt(e) {
2415
2415
  }
2416
2416
  return n.data;
2417
2417
  }
2418
- function qr(e) {
2418
+ function Mr(e) {
2419
2419
  const t = (o) => !!(o && Array.isArray(o.content) && o.content.length > 0), n = Zt(e.description_json);
2420
2420
  if (t(n))
2421
2421
  return n;
@@ -2443,7 +2443,7 @@ async function en(e, t) {
2443
2443
  if (u.result)
2444
2444
  return u.result;
2445
2445
  const { createProduct: d, productSchema: l } = await Vn(), h = n.product_type === "digital" && n.payment_provider === "freemius" ? n.trial_period_days : 0, g = l.parse({
2446
- description_json: qr(n),
2446
+ description_json: Mr(n),
2447
2447
  freemius_plan_id: n.freemius_plan_id || "",
2448
2448
  freemius_product_id: n.freemius_product_id || "",
2449
2449
  is_taxable: n.is_taxable,
@@ -2458,7 +2458,7 @@ async function en(e, t) {
2458
2458
  sale_price: n.sale_price ?? null,
2459
2459
  sale_prices: n.sale_prices || {},
2460
2460
  short_description: n.short_description ?? "",
2461
- sku: n.sku || Mr(n.title, i),
2461
+ sku: n.sku || qr(n.title, i),
2462
2462
  slug: i,
2463
2463
  status: n.status,
2464
2464
  stock: n.stock,
@@ -2549,11 +2549,11 @@ async function Gr(e, t, n) {
2549
2549
  if (e === "price" || e === "sale_price") {
2550
2550
  if (t == null)
2551
2551
  return { [e]: null };
2552
- const r = await qe(n);
2552
+ const r = await Me(n);
2553
2553
  return { [e]: pe(Number(t), r) };
2554
2554
  }
2555
2555
  if (e === "prices" || e === "sale_prices") {
2556
- const r = await qe(n);
2556
+ const r = await Me(n);
2557
2557
  return { [e]: Zn(t, r) };
2558
2558
  }
2559
2559
  return e === "description_json" ? { description_json: Zt(t) } : { [e]: t };
@@ -3472,7 +3472,7 @@ async function uo(e, t) {
3472
3472
  provider: c.provider,
3473
3473
  query: n.query,
3474
3474
  success: !0,
3475
- usageGuidance: c.provider === "unsplash" ? 'Unsplash photos: keep them hotlinked (use `url` as external_url; never save an Unsplash photo to the media library) and attribute each one — copy the photo\'s attribution fields into the image content\'s `attribution` (photographer, photographerUrl, sourceUrl, downloadLocation, utmSource, provider "unsplash"). The site renders the "Photo by … on Unsplash" credit from `attribution` automatically, so do NOT also copy the credit into `caption` (leave caption empty unless you have a genuine descriptive caption).' : 'Set the image content\'s `attribution` (photographer, photographerUrl, sourceUrl, provider "pexels"). The site renders the "Photo by … on Pexels" credit from `attribution` automatically, so do NOT also copy the credit into `caption` (leave caption empty unless you have a genuine descriptive caption). Pexels attribution is appreciated but optional.'
3475
+ usageGuidance: c.provider === "unsplash" ? 'Unsplash photos: keep them hotlinked (use `url` as external_url; never save an Unsplash photo to the media library) and attribute each one — copy the photo\'s attribution fields into the image content\'s `attribution` (photographer, photographerUrl, sourceUrl, downloadLocation, utmSource, provider "unsplash"). The site renders the "Photo by … on Unsplash" credit from `attribution` automatically, so do NOT also copy the credit into `caption` (leave caption empty unless you have a genuine descriptive caption). Also copy the photo\'s `width` and `height` into the image content: the page then reserves the right space before the file loads instead of shifting.' : 'Set the image content\'s `attribution` (photographer, photographerUrl, sourceUrl, provider "pexels"). The site renders the "Photo by … on Pexels" credit from `attribution` automatically, so do NOT also copy the credit into `caption` (leave caption empty unless you have a genuine descriptive caption). Pexels attribution is appreciated but optional. Also copy each photo `width` and `height` into the image content: the page then reserves the right space before the file loads instead of shifting.'
3476
3476
  };
3477
3477
  } catch (u) {
3478
3478
  a = u;
@@ -3704,7 +3704,7 @@ async function yo(e, t) {
3704
3704
  if (p)
3705
3705
  throw new Error(`Could not clear the existing variants: ${_(p)}`);
3706
3706
  }
3707
- const d = await qe(r), l = Number(i.price) || 0, m = [];
3707
+ const d = await Me(r), l = Number(i.price) || 0, m = [];
3708
3708
  for (const p of n.variants) {
3709
3709
  const b = p.image ? await X(p.image, t, `${i.title} ${p.sku}`) : null, { data: y, error: w } = await r.from("product_variants").insert({
3710
3710
  main_media_id: b,
@@ -4182,7 +4182,7 @@ function Fo(e) {
4182
4182
  strict: !0
4183
4183
  }),
4184
4184
  search_stock_photos: S({
4185
- description: "Find relevant, free, high-quality stock photos (Unsplash/Pexels) for page imagery. Returns a list of photos each with a direct image `url`, `width`, `height`, `alt`, and `photographer`. Read-only, zero cost. Use the returned `url` directly as an image block's external_url or a section image background's image.external_url when building or revamping pages, so layouts show real photos instantly. Set orientation \"landscape\" for hero/section backgrounds.",
4185
+ description: "Find relevant, free, high-quality stock photos (Unsplash/Pexels) for page imagery. Returns a list of photos each with a direct image `url`, `width`, `height`, `alt`, and `photographer`. Read-only, zero cost. Use the returned `url` directly as an image block's external_url (copy `width` and `height` into the same image content, so the page does not shift while the photo loads) or a section image background's image.external_url when building or revamping pages, so layouts show real photos instantly. Set orientation \"landscape\" for hero/section backgrounds.",
4186
4186
  execute: (t) => uo(t, e),
4187
4187
  inputSchema: dn,
4188
4188
  strict: !0
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./zod-config.cjs.js");const t=require("zod"),u=["text","heading","image","button","posts_grid","video_embed","section","form","testimonial","product_grid","featured_product","cart","checkout","product_details"],z=t.z.enum(u),d=t.z.object({direction:t.z.string().optional(),stops:t.z.array(t.z.object({color:t.z.string(),position:t.z.number()})),type:t.z.enum(["linear","radial"])}),g=t.z.object({gradient:d.optional(),image:t.z.object({alt_text:t.z.string().optional(),blur_data_url:t.z.string().optional(),external_url:t.z.string().optional(),height:t.z.number().optional(),media_id:t.z.string().optional(),object_key:t.z.string().optional(),overlay:t.z.object({gradient:d,type:t.z.literal("gradient")}).optional(),position:t.z.enum(["center","top","bottom","left","right"]),quality:t.z.number().nullable().optional(),size:t.z.enum(["cover","contain"]),width:t.z.number().optional()}).optional(),min_height:t.z.string().optional(),solid_color:t.z.string().optional(),theme:t.z.enum(["primary","secondary","muted","accent","destructive"]).optional(),type:t.z.enum(["none","theme","solid","gradient","image"])}),p=t.z.string().regex(/^[a-z][a-z0-9-]*$/),b=t.z.object({block_type:t.z.union([z,p]),content:t.z.record(t.z.string(),t.z.any()),temp_id:t.z.string().optional()}),k=t.z.object({background:g,column_blocks:t.z.array(t.z.array(b))}),y=t.z.object({autoplay:t.z.boolean().optional(),background:g,column_blocks:t.z.array(t.z.array(b)),column_gap:t.z.enum(["none","sm","md","lg","xl"]),container_type:t.z.enum(["full-width","container","container-sm","container-lg","container-xl"]),is_hero:t.z.boolean().optional(),padding:t.z.object({bottom:t.z.enum(["none","sm","md","lg","xl"]),top:t.z.enum(["none","sm","md","lg","xl"])}),responsive_columns:t.z.object({desktop:t.z.union([t.z.literal(1),t.z.literal(2),t.z.literal(3),t.z.literal(4)]),mobile:t.z.union([t.z.literal(1),t.z.literal(2)]),tablet:t.z.union([t.z.literal(1),t.z.literal(2),t.z.literal(3)])}),slider:t.z.boolean().optional(),slides:t.z.array(k).optional(),timeframe:t.z.number().optional(),vertical_alignment:t.z.enum(["start","center","end","stretch"]).optional()}),f={button:t.z.object({position:t.z.enum(["left","center","right"]).optional(),size:t.z.enum(["default","sm","lg","full"]).optional(),text:t.z.string(),url:t.z.string(),variant:t.z.enum(["default","outline","secondary","ghost","link"]).optional()}),cart:t.z.object({}),checkout:t.z.object({}),featured_product:t.z.object({imagePosition:t.z.enum(["left","right"]).default("left"),productId:t.z.string().min(1),showBackground:t.z.boolean().default(!1)}),form:t.z.object({fields:t.z.array(t.z.object({field_type:t.z.enum(["text","email","textarea","select","radio","checkbox"]),is_required:t.z.boolean(),label:t.z.string(),options:t.z.array(t.z.object({label:t.z.string(),value:t.z.string()})).optional(),placeholder:t.z.string().optional(),temp_id:t.z.string()})),form_key:t.z.string().optional(),recipient_email:t.z.string().email().optional(),submit_button_text:t.z.string(),success_message:t.z.string()}),heading:t.z.object({level:t.z.union([t.z.literal(1),t.z.literal(2),t.z.literal(3),t.z.literal(4),t.z.literal(5),t.z.literal(6)]),textAlign:t.z.enum(["left","center","right","justify"]).optional(),textColor:t.z.union([t.z.enum(["foreground","primary","secondary","accent","muted","destructive","background"]),t.z.string().regex(/^(#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([^)]+\)|hsla?\([^)]+\))$/i,"Must be a hex, rgb(a) or hsl(a) colour")]).optional().describe("Prefer a theme token so the heading adapts to dark mode; use a CSS colour only when the brand requires an exact value"),text_content:t.z.string()}),image:t.z.object({alt_text:t.z.string().optional(),caption:t.z.string().optional(),external_url:t.z.string().nullable().optional(),height:t.z.number().nullable().optional(),media_id:t.z.string().nullable().optional(),object_key:t.z.string().nullable().optional(),width:t.z.number().nullable().optional()}),posts_grid:t.z.object({columns:t.z.number().min(1).max(6),postsPerPage:t.z.number().min(1).max(50),showPagination:t.z.boolean(),title:t.z.string().optional()}),product_details:t.z.object({}),product_grid:t.z.object({categoryId:t.z.string().optional(),categoryIds:t.z.array(t.z.string()).max(20).optional(),limit:t.z.number().min(0).max(48).default(6),productIds:t.z.array(t.z.string()).max(24).optional(),showPagination:t.z.boolean().default(!1),title:t.z.string().optional(),type:t.z.enum(["latest","category","manual"]).default("latest")}),section:y,testimonial:t.z.object({author_name:t.z.string().min(1),author_title:t.z.string().optional(),image_url:t.z.string().url().optional().or(t.z.literal("")),quote:t.z.string().min(1)}),text:t.z.object({html_content:t.z.string()}),video_embed:t.z.object({autoplay:t.z.boolean().optional(),controls:t.z.boolean().optional(),title:t.z.string().optional(),url:t.z.string()})};function _(o){return u.includes(o)}function j(o){return typeof o?.validateBlockContent=="function"?o.validateBlockContent:null}function x(o,n,a){const l=j(a);if(l)return l(o,n);const i=f[o].safeParse(n);return i.success?{errors:[],isValid:!0,warnings:[]}:{errors:i.error.issues.map(s=>{const e=s.path.join(".");return e?`${e}: ${s.message}`:s.message}),isValid:!1,warnings:[]}}function h(o){return Array.isArray(o.fields)?o.fields.filter(n=>!!n&&typeof n=="object"&&typeof n.key=="string"&&typeof n.type=="string"):[]}function B(o){return o==null||typeof o=="string"&&o.trim()===""||Array.isArray(o)&&o.length===0}function S(o,n){if(!n||typeof n!="object"||Array.isArray(n))return{errors:["content must be a JSON object of { field_key: value } pairs."],isValid:!1,warnings:[]};const a=h(o),l=new Set(a.map(e=>e.key)),i=[],s=[];for(const e of Object.keys(n))l.has(e)||i.push(`Unknown field "${e}" for custom block "${o.slug}". Known fields: ${[...l].join(", ")||"(none)"}.`);for(const e of a){const r=n[e.key];if(B(r)){e.required&&i.push(`Field "${e.key}" is required.`);continue}if(e.type==="text"||e.type==="rich-text"){if(typeof r!="string"){i.push(`Field "${e.key}" must be a string${e.type==="rich-text"?" of HTML":""}.`);continue}typeof e.max_length=="number"&&r.length>e.max_length&&i.push(`Field "${e.key}" exceeds its ${e.max_length}-character limit.`),typeof e.min_length=="number"&&r.length<e.min_length&&i.push(`Field "${e.key}" is shorter than its ${e.min_length}-character minimum.`);continue}if(e.type==="image_r2"){const c=r;(typeof r!="object"||Array.isArray(r)||typeof c.object_key!="string"||typeof c.url!="string")&&i.push(`Field "${e.key}" must be an uploaded image object with object_key and url (upload it with upload_media first) or null.`);continue}if(e.type==="db_relation"){const c=m=>typeof m=="string"||typeof m=="number";e.multiple?(!Array.isArray(r)||!r.every(c))&&i.push(`Field "${e.key}" must be an array of related record ids.`):c(r)||i.push(`Field "${e.key}" must be a single related record id.`);continue}s.push(`Field "${e.key}" has an unrecognised type "${String(e.type)}"; it was not validated.`)}return{errors:i,isValid:i.length===0,warnings:s}}async function C(o){const{data:n,error:a}=await o.from("custom_block_definitions").select("slug, name, fields");if(a)throw new Error(`Could not read the custom block definitions: ${typeof a=="object"&&a&&"message"in a?String(a.message):String(a)}`);return(Array.isArray(n)?n:[]).filter(l=>!!l&&typeof l.slug=="string")}exports.availableCortexAiBlockTypes=u;exports.cortexAiBlockTypeSchema=z;exports.customBlockSlugPatternSchema=p;exports.fallbackBlockSchemas=f;exports.isValidBlockType=_;exports.loadCustomBlockDefinitions=C;exports.readCustomBlockFields=h;exports.sectionBlockFallbackSchema=y;exports.validateCortexBlockContent=x;exports.validateCustomBlockInstanceContent=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./zod-config.cjs.js");const t=require("zod"),u=["text","heading","image","button","posts_grid","video_embed","section","form","testimonial","product_grid","featured_product","cart","checkout","product_details"],z=t.z.enum(u),d=t.z.object({direction:t.z.string().optional(),stops:t.z.array(t.z.object({color:t.z.string(),position:t.z.number()})),type:t.z.enum(["linear","radial"])}),g=t.z.object({gradient:d.optional(),image:t.z.object({alt_text:t.z.string().optional(),blur_data_url:t.z.string().optional(),external_url:t.z.string().optional(),height:t.z.number().optional(),media_id:t.z.string().optional(),object_key:t.z.string().optional(),overlay:t.z.object({gradient:d,type:t.z.literal("gradient")}).optional(),position:t.z.enum(["center","top","bottom","left","right"]),quality:t.z.number().nullable().optional(),size:t.z.enum(["cover","contain"]),width:t.z.number().optional()}).optional(),min_height:t.z.string().optional(),solid_color:t.z.string().optional(),theme:t.z.enum(["primary","secondary","muted","accent","destructive"]).optional(),type:t.z.enum(["none","theme","solid","gradient","image"])}),p=t.z.string().regex(/^[a-z][a-z0-9-]*$/),b=t.z.object({block_type:t.z.union([z,p]),content:t.z.record(t.z.string(),t.z.any()),temp_id:t.z.string().optional()}),k=t.z.object({background:g,column_blocks:t.z.array(t.z.array(b))}),y=t.z.object({autoplay:t.z.boolean().optional(),background:g,column_blocks:t.z.array(t.z.array(b)),column_gap:t.z.enum(["none","sm","md","lg","xl"]),container_type:t.z.enum(["full-width","container","container-sm","container-lg","container-xl"]),is_hero:t.z.boolean().optional(),padding:t.z.object({bottom:t.z.enum(["none","sm","md","lg","xl"]),top:t.z.enum(["none","sm","md","lg","xl"])}),responsive_columns:t.z.object({desktop:t.z.union([t.z.literal(1),t.z.literal(2),t.z.literal(3),t.z.literal(4)]),mobile:t.z.union([t.z.literal(1),t.z.literal(2)]),tablet:t.z.union([t.z.literal(1),t.z.literal(2),t.z.literal(3)])}),slider:t.z.boolean().optional(),slides:t.z.array(k).optional(),timeframe:t.z.number().optional(),vertical_alignment:t.z.enum(["start","center","end","stretch"]).optional()}),f={button:t.z.object({position:t.z.enum(["left","center","right"]).optional(),size:t.z.enum(["default","sm","lg","full"]).optional(),text:t.z.string(),url:t.z.string(),variant:t.z.enum(["default","outline","secondary","ghost","link"]).optional()}),cart:t.z.object({}),checkout:t.z.object({}),featured_product:t.z.object({imagePosition:t.z.enum(["left","right"]).default("left"),productId:t.z.string().min(1),showBackground:t.z.boolean().default(!1)}),form:t.z.object({fields:t.z.array(t.z.object({field_type:t.z.enum(["text","email","tel","url","number","textarea","select","radio","checkbox"]),is_required:t.z.boolean(),label:t.z.string(),options:t.z.array(t.z.object({label:t.z.string(),value:t.z.string()})).optional(),placeholder:t.z.string().optional(),temp_id:t.z.string()})),form_key:t.z.string().optional(),recipient_email:t.z.string().email().optional(),submit_button_text:t.z.string(),success_message:t.z.string()}),heading:t.z.object({level:t.z.union([t.z.literal(1),t.z.literal(2),t.z.literal(3),t.z.literal(4),t.z.literal(5),t.z.literal(6)]),textAlign:t.z.enum(["left","center","right","justify"]).optional(),textColor:t.z.union([t.z.enum(["foreground","primary","secondary","accent","muted","destructive","background"]),t.z.string().regex(/^(#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|rgba?\([^)]+\)|hsla?\([^)]+\))$/i,"Must be a hex, rgb(a) or hsl(a) colour")]).optional().describe("Prefer a theme token so the heading adapts to dark mode; use a CSS colour only when the brand requires an exact value"),text_content:t.z.string()}),image:t.z.object({alt_text:t.z.string().optional(),caption:t.z.string().optional(),external_url:t.z.string().nullable().optional(),height:t.z.number().nullable().optional(),media_id:t.z.string().nullable().optional(),object_key:t.z.string().nullable().optional(),width:t.z.number().nullable().optional()}),posts_grid:t.z.object({columns:t.z.number().min(1).max(6),postsPerPage:t.z.number().min(1).max(50),showPagination:t.z.boolean(),title:t.z.string().optional()}),product_details:t.z.object({}),product_grid:t.z.object({categoryId:t.z.string().optional(),categoryIds:t.z.array(t.z.string()).max(20).optional(),limit:t.z.number().min(0).max(48).default(6),productIds:t.z.array(t.z.string()).max(24).optional(),showPagination:t.z.boolean().default(!1),title:t.z.string().optional(),type:t.z.enum(["latest","category","manual"]).default("latest")}),section:y,testimonial:t.z.object({author_name:t.z.string().min(1),author_title:t.z.string().optional(),image_url:t.z.string().url().optional().or(t.z.literal("")),quote:t.z.string().min(1)}),text:t.z.object({html_content:t.z.string()}),video_embed:t.z.object({autoplay:t.z.boolean().optional(),controls:t.z.boolean().optional(),title:t.z.string().optional(),url:t.z.string()})};function _(o){return u.includes(o)}function j(o){return typeof o?.validateBlockContent=="function"?o.validateBlockContent:null}function x(o,n,a){const l=j(a);if(l)return l(o,n);const i=f[o].safeParse(n);return i.success?{errors:[],isValid:!0,warnings:[]}:{errors:i.error.issues.map(s=>{const e=s.path.join(".");return e?`${e}: ${s.message}`:s.message}),isValid:!1,warnings:[]}}function h(o){return Array.isArray(o.fields)?o.fields.filter(n=>!!n&&typeof n=="object"&&typeof n.key=="string"&&typeof n.type=="string"):[]}function B(o){return o==null||typeof o=="string"&&o.trim()===""||Array.isArray(o)&&o.length===0}function S(o,n){if(!n||typeof n!="object"||Array.isArray(n))return{errors:["content must be a JSON object of { field_key: value } pairs."],isValid:!1,warnings:[]};const a=h(o),l=new Set(a.map(e=>e.key)),i=[],s=[];for(const e of Object.keys(n))l.has(e)||i.push(`Unknown field "${e}" for custom block "${o.slug}". Known fields: ${[...l].join(", ")||"(none)"}.`);for(const e of a){const r=n[e.key];if(B(r)){e.required&&i.push(`Field "${e.key}" is required.`);continue}if(e.type==="text"||e.type==="rich-text"){if(typeof r!="string"){i.push(`Field "${e.key}" must be a string${e.type==="rich-text"?" of HTML":""}.`);continue}typeof e.max_length=="number"&&r.length>e.max_length&&i.push(`Field "${e.key}" exceeds its ${e.max_length}-character limit.`),typeof e.min_length=="number"&&r.length<e.min_length&&i.push(`Field "${e.key}" is shorter than its ${e.min_length}-character minimum.`);continue}if(e.type==="image_r2"){const c=r;(typeof r!="object"||Array.isArray(r)||typeof c.object_key!="string"||typeof c.url!="string")&&i.push(`Field "${e.key}" must be an uploaded image object with object_key and url (upload it with upload_media first) or null.`);continue}if(e.type==="db_relation"){const c=m=>typeof m=="string"||typeof m=="number";e.multiple?(!Array.isArray(r)||!r.every(c))&&i.push(`Field "${e.key}" must be an array of related record ids.`):c(r)||i.push(`Field "${e.key}" must be a single related record id.`);continue}s.push(`Field "${e.key}" has an unrecognised type "${String(e.type)}"; it was not validated.`)}return{errors:i,isValid:i.length===0,warnings:s}}async function C(o){const{data:n,error:a}=await o.from("custom_block_definitions").select("slug, name, fields");if(a)throw new Error(`Could not read the custom block definitions: ${typeof a=="object"&&a&&"message"in a?String(a.message):String(a)}`);return(Array.isArray(n)?n:[]).filter(l=>!!l&&typeof l.slug=="string")}exports.availableCortexAiBlockTypes=u;exports.cortexAiBlockTypeSchema=z;exports.customBlockSlugPatternSchema=p;exports.fallbackBlockSchemas=f;exports.isValidBlockType=_;exports.loadCustomBlockDefinitions=C;exports.readCustomBlockFields=h;exports.sectionBlockFallbackSchema=y;exports.validateCortexBlockContent=x;exports.validateCustomBlockInstanceContent=S;
@@ -93,7 +93,8 @@ const d = [
93
93
  form: t.object({
94
94
  fields: t.array(
95
95
  t.object({
96
- field_type: t.enum(["text", "email", "textarea", "select", "radio", "checkbox"]),
96
+ // Mirrors FormFieldSchema in apps/nextblock/lib/blocks/blockRegistry.ts.
97
+ field_type: t.enum(["text", "email", "tel", "url", "number", "textarea", "select", "radio", "checkbox"]),
97
98
  is_required: t.boolean(),
98
99
  label: t.string(),
99
100
  options: t.array(t.object({ label: t.string(), value: t.string() })).optional(),
@@ -1,5 +1,5 @@
1
- import { Database } from '../../../db/src/lib/supabase/types.ts';
2
- import { CustomBlockDefinition } from '../../../utils/src/lib/custom-blocks';
1
+ import { Database } from '@nextblock-cms/db/types';
2
+ import { CustomBlockDefinition } from '@nextblock-cms/utils/custom-blocks';
3
3
  import { CortexWidgetDefinition } from './cortex-widget-schema';
4
4
  export declare const CORTEX_WIDGET_DEFINITION_SELECT = "id, slug, name, description, fields, layout_schema, is_original";
5
5
  type CustomBlockDefinitionInsert = Database['public']['Tables']['custom_block_definitions']['Insert'];
@@ -1,4 +1,4 @@
1
- import { customBlockDefinitionCreateSchema } from '../../../utils/src/lib/custom-blocks';
1
+ import { customBlockDefinitionCreateSchema } from '@nextblock-cms/utils/custom-blocks';
2
2
  import { z } from './zod-config';
3
3
  export declare const CORTEX_WIDGET_ALLOWED_RELATION_TABLES: readonly ["pages", "posts", "products", "media", "categories", "profiles", "languages"];
4
4
  declare const htmlElementSchema: z.ZodEnum<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextblock-cms/cortex",
3
- "version": "0.19.2",
3
+ "version": "0.19.3",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -28,9 +28,9 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@ai-sdk/openai-compatible": "^2.0.42",
31
- "@nextblock-cms/db": "^0.19.2",
32
- "@nextblock-cms/ecommerce": "npm:@nextblock-cms/ecom@^0.19.2",
33
- "@nextblock-cms/utils": "^0.19.2",
31
+ "@nextblock-cms/db": "^0.19.3",
32
+ "@nextblock-cms/ecommerce": "npm:@nextblock-cms/ecom@^0.19.3",
33
+ "@nextblock-cms/utils": "^0.19.3",
34
34
  "ai": "^6.0.170",
35
35
  "zod": "^4.3.6"
36
36
  },