@nextblock-cms/db 0.2.29 → 0.8.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 (75) hide show
  1. package/cache-Bb4TkKGq.js +38 -0
  2. package/cache-D0Q6YeSV.mjs +10150 -0
  3. package/index.cjs.js +1 -1
  4. package/index.es.js +66 -61
  5. package/package.json +1 -1
  6. package/server.cjs.js +1 -1
  7. package/server.es.js +48 -43
  8. package/supabase/config.toml +330 -319
  9. package/supabase/functions/import_map.json +6 -0
  10. package/supabase/functions/nextblock-migration-ingest/index.d.ts +1 -0
  11. package/supabase/functions/nextblock-migration-ingest/index.js +519 -0
  12. package/supabase/functions/nextblock-migration-ingest/index.js.map +7 -0
  13. package/supabase/functions/nextblock-migration-ingest/index.ts +646 -0
  14. package/supabase/migrations/00000000000000_setup_foundation_and_enums.sql +40 -0
  15. package/supabase/migrations/00000000000001_setup_cms_core.sql +124 -0
  16. package/supabase/migrations/00000000000002_setup_content_tables.sql +138 -0
  17. package/supabase/migrations/00000000000003_setup_catalog_and_licensing.sql +160 -0
  18. package/supabase/migrations/00000000000004_setup_fulfillment_shipping_taxes_and_currencies.sql +797 -0
  19. package/supabase/migrations/00000000000005_setup_functions_and_triggers.sql +767 -0
  20. package/supabase/migrations/00000000000006_setup_rls_and_grants.sql +872 -0
  21. package/supabase/migrations/00000000000007_setup_indexes.sql +158 -0
  22. package/supabase/migrations/00000000000008_seed_platform_defaults.sql +155 -0
  23. package/supabase/migrations/00000000000009_seed_translations.sql +801 -0
  24. package/supabase/migrations/00000000000010_seed_content_scaffold.sql +1088 -0
  25. package/supabase/migrations/00000000000011_setup_cortex_ai_settings.sql +81 -0
  26. package/supabase/migrations/00000000000012_setup_commerce_coupons.sql +275 -0
  27. package/supabase/migrations/00000000000013_setup_cortex_ai_db_mutation_audit.sql +47 -0
  28. package/supabase/migrations/00000000000014_setup_content_drafts.sql +119 -0
  29. package/supabase/migrations/00000000000015_setup_product_drafts.sql +97 -0
  30. package/supabase/migrations/00000000000016_add_feature_image_to_pages.sql +8 -0
  31. package/supabase/migrations/00000000000017_add_product_blocks.sql +118 -0
  32. package/supabase/migrations/00000000000018_setup_bot_protection_settings.sql +77 -0
  33. package/supabase/migrations/00000000000019_add_product_categories.sql +64 -0
  34. package/supabase/migrations/00000000000020_add_category_translations.sql +10 -0
  35. package/supabase/migrations/00000000000021_migrate_hero_blocks_to_sections.sql +29 -0
  36. package/supabase/migrations/00000000000022_seed_cortex_ai_guide_post.sql +184 -0
  37. package/supabase/migrations/00000000000023_setup_custom_block_definitions.sql +183 -0
  38. package/supabase/migrations/00000000000024_setup_ucp_cart_sessions.sql +72 -0
  39. package/supabase/migrations/00000000000025_add_sale_schedule_columns.sql +406 -0
  40. package/supabase/migrations/00000000000026_seed_on_sale_translation.sql +9 -0
  41. package/supabase/migrations/00000000000027_setup_privacy_and_mfa.sql +479 -0
  42. package/supabase/migrations/00000000000028_clear_advisor_warnings.sql +93 -0
  43. package/supabase/migrations/00000000000029_refresh_setup_article.sql +252 -0
  44. package/supabase/templates/confirmation.html +54 -0
  45. package/supabase/templates/email_change.html +53 -0
  46. package/supabase/templates/invite.html +53 -0
  47. package/supabase/templates/magic_link.html +53 -0
  48. package/supabase/templates/reauthentication.html +45 -0
  49. package/supabase/templates/recovery.html +54 -0
  50. package/index.d.ts +0 -4
  51. package/lib/supabase/client.d.ts +0 -9
  52. package/lib/supabase/middleware.d.ts +0 -2
  53. package/lib/supabase/server.d.ts +0 -7
  54. package/lib/supabase/ssg-client.d.ts +0 -2
  55. package/lib/supabase/types.d.ts +0 -635
  56. package/server.d.ts +0 -2
  57. package/ssg-client-CiaENGEv.js +0 -1
  58. package/ssg-client-DgUYZgPq.mjs +0 -8
  59. package/supabase/migrations/00000000000000_setup_extensions_and_roles.sql +0 -54
  60. package/supabase/migrations/00000000000001_setup_site_settings.sql +0 -19
  61. package/supabase/migrations/00000000000002_setup_profiles.sql +0 -87
  62. package/supabase/migrations/00000000000003_setup_languages.sql +0 -43
  63. package/supabase/migrations/00000000000004_setup_media.sql +0 -54
  64. package/supabase/migrations/00000000000005_setup_posts.sql +0 -56
  65. package/supabase/migrations/00000000000006_setup_pages.sql +0 -51
  66. package/supabase/migrations/00000000000007_setup_blocks.sql +0 -47
  67. package/supabase/migrations/00000000000008_setup_navigation.sql +0 -51
  68. package/supabase/migrations/00000000000009_setup_logos.sql +0 -13
  69. package/supabase/migrations/00000000000010_setup_translations.sql +0 -29
  70. package/supabase/migrations/00000000000011_setup_revisions.sql +0 -38
  71. package/supabase/migrations/00000000000012_setup_rls_policies.sql +0 -239
  72. package/supabase/migrations/00000000000013_seed_data.sql +0 -149
  73. package/supabase/migrations/00000000000014_seed_homepage_blocks.sql +0 -661
  74. package/supabase/migrations/00000000000015_seed_how_it_works.sql +0 -89
  75. package/supabase/migrations/00000000000016_sandbox_setup.sql +0 -834
package/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@supabase/ssr"),s=require("next/server"),_=require("./ssg-client-CiaENGEv.js"),u=()=>{const e=process.env.NEXT_PUBLIC_SUPABASE_URL,t=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;if(!e||!t)throw new Error(`CRITICAL: Supabase URL or Anon Key is missing. Please ensure NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are set in your production environment. URL_IS_SET: ${!!e}, ANON_KEY_IS_SET: ${!!t}`);return l.createBrowserClient(e,t)};async function d(e,t){const{data:r,error:n}=await e.from("profiles").select("id, full_name, avatar_url, role, updated_at, username, website").eq("id",t).single();return n||!r?null:r}async function S(){const e=u(),{data:t,error:r}=await e.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name",{ascending:!0});return r?[]:t||[]}const E=async e=>{try{let t=s.NextResponse.next({request:{headers:e.headers}});const r=process.env.NEXT_PUBLIC_SUPABASE_URL,n=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;if(!r||!n)throw new Error("Missing Supabase environment variables");const i=await l.createServerClient(r,n,{cookies:{getAll(){return e.cookies.getAll()},setAll(c){c.forEach(({name:a,value:o})=>e.cookies.set(a,o)),t=s.NextResponse.next({request:e}),c.forEach(({name:a,value:o,options:p})=>t.cookies.set(a,o,p))}}}).auth.getUser();return e.nextUrl.pathname.startsWith("/protected")&&i.error?s.NextResponse.redirect(new URL("/sign-in",e.url)):e.nextUrl.pathname==="/"&&!i.error?s.NextResponse.redirect(new URL("/protected",e.url)):t}catch{return s.NextResponse.next({request:{headers:e.headers}})}},A={public:{Enums:{menu_location:["HEADER","FOOTER","SIDEBAR"],page_status:["draft","published","archived"],revision_type:["snapshot","diff"],user_role:["ADMIN","WRITER","USER"]}}};exports.getSsgSupabaseClient=_.getSsgSupabaseClient;exports.Constants=A;exports.createClient=u;exports.getActiveLanguagesClientSide=S;exports.getProfileWithRoleClientSide=d;exports.updateSession=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("@supabase/ssr"),m=require("./cache-Bb4TkKGq.js"),c=require("@nextblock-cms/utils/server"),g=()=>{const e=process.env.NEXT_PUBLIC_SUPABASE_URL,i=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;if(!e||!i)throw new Error(`CRITICAL: Supabase URL or Anon Key is missing. Please ensure NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are set in your production environment. URL_IS_SET: ${!!e}, ANON_KEY_IS_SET: ${!!i}`);return A.createBrowserClient(e,i)};async function S(e,i){const{data:a,error:s}=await e.from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id",i).single();return s||!a?null:a}async function U(){const e=g(),{data:i,error:a}=await e.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name",{ascending:!0});return a?[]:i||[]}const v={public:{Enums:{menu_location:["HEADER","FOOTER","SIDEBAR"],page_status:["draft","published","archived"],revision_type:["snapshot","diff"],user_role:["ADMIN","WRITER","USER"]}}};async function R(e,i){const a=m.createClient(),{data:{user:s},error:_}=await a.auth.getUser();if(_||!s)return i?{error:"User not authenticated for media record."}:c.encodedRedirect("error","/cms/media","User not authenticated for media record.");const{data:l}=await a.from("profiles").select("role").eq("id",s.id).single();if(!l||!["ADMIN","WRITER"].includes(l.role))return i?{error:"Forbidden: Insufficient permissions to record media."}:c.encodedRedirect("error","/cms/media","Forbidden: Insufficient permissions to record media.");let t=e.r2Variants.find(r=>r.variantLabel==="original_avif")||e.r2Variants.find(r=>r.variantLabel==="xlarge_avif")||e.r2Variants[0]||e.originalImageDetails;t||(t=e.originalImageDetails||{objectKey:e.r2OriginalKey,url:"",width:0,height:0,fileType:"application/octet-stream",sizeBytes:0,variantLabel:"fallback_original"});const p=[...e.originalImageDetails&&e.originalImageDetails.objectKey!==t.objectKey?[e.originalImageDetails]:[],...e.r2Variants].filter((r,n,d)=>n===d.findIndex(u=>u.objectKey===r.objectKey)),b=r=>{const n=r.lastIndexOf(".");return(n>0?r.substring(0,n):r).replace(/[-+_\\]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w+/g,f=>f.charAt(0).toUpperCase()+f.slice(1))},h=e.description??(t.fileType?.startsWith("image/")||e.originalImageDetails?.fileType?.startsWith("image/")?b(e.fileName):null),E={uploader_id:s.id,file_name:e.fileName,object_key:t.objectKey,file_path:t.objectKey,folder:(()=>{const r=t.objectKey.match(/^(.*\/)?.*$/);return r&&r[1]?r[1]:null})(),file_type:t.fileType,size_bytes:t.sizeBytes,description:h,width:t.width,height:t.height,variants:p,blur_data_url:e.blurDataUrl||null},{data:I,error:o}=await a.from("media").insert(E).select().single();if(o)return console.error("Error recording media upload:",o),i?{error:`Failed to record media: ${o.message}`}:c.encodedRedirect("error","/cms/media",`Failed to record media: ${o.message}`);if(m.cacheExports.revalidatePath("/cms/media"),i)return{success:!0,data:I};c.encodedRedirect("success","/cms/media","Media recorded successfully.")}exports.Constants=v;exports.createClient=g;exports.getActiveLanguagesClientSide=U;exports.getProfileWithRoleClientSide=S;exports.recordMediaUpload=R;
package/index.es.js CHANGED
@@ -1,61 +1,21 @@
1
- import { createBrowserClient as u, createServerClient as _ } from "@supabase/ssr";
2
- import { NextResponse as n } from "next/server";
3
- import { g as N } from "./ssg-client-DgUYZgPq.mjs";
4
- const p = () => {
5
- const e = process.env.NEXT_PUBLIC_SUPABASE_URL, r = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
6
- if (!e || !r)
7
- throw new Error(
8
- `CRITICAL: Supabase URL or Anon Key is missing. Please ensure NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are set in your production environment. URL_IS_SET: ${!!e}, ANON_KEY_IS_SET: ${!!r}`
9
- );
10
- return u(e, r);
1
+ import { createBrowserClient as E } from "@supabase/ssr";
2
+ import { c as I, a as A } from "./cache-D0Q6YeSV.mjs";
3
+ import { encodedRedirect as c } from "@nextblock-cms/utils/server";
4
+ const U = () => {
5
+ const e = process.env.NEXT_PUBLIC_SUPABASE_URL, i = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
6
+ if (!e || !i)
7
+ throw new Error(`CRITICAL: Supabase URL or Anon Key is missing. Please ensure NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_ANON_KEY are set in your production environment. URL_IS_SET: ${!!e}, ANON_KEY_IS_SET: ${!!i}`);
8
+ return E(e, i);
11
9
  };
12
- async function S(e, r) {
13
- const { data: t, error: s } = await e.from("profiles").select("id, full_name, avatar_url, role, updated_at, username, website").eq("id", r).single();
14
- return s || !t ? null : t;
10
+ async function T(e, i) {
11
+ const { data: a, error: s } = await e.from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id", i).single();
12
+ return s || !a ? null : a;
15
13
  }
16
- async function U() {
17
- const e = p(), { data: r, error: t } = await e.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name", { ascending: !0 });
18
- return t ? [] : r || [];
14
+ async function K() {
15
+ const e = U(), { data: i, error: a } = await e.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name", { ascending: !0 });
16
+ return a ? [] : i || [];
19
17
  }
20
- const f = async (e) => {
21
- try {
22
- let r = n.next({
23
- request: {
24
- headers: e.headers
25
- }
26
- });
27
- const t = process.env.NEXT_PUBLIC_SUPABASE_URL, s = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
28
- if (!t || !s)
29
- throw new Error("Missing Supabase environment variables");
30
- const i = await _(
31
- t,
32
- s,
33
- {
34
- cookies: {
35
- getAll() {
36
- return e.cookies.getAll();
37
- },
38
- setAll(c) {
39
- c.forEach(
40
- ({ name: a, value: o }) => e.cookies.set(a, o)
41
- ), r = n.next({
42
- request: e
43
- }), c.forEach(
44
- ({ name: a, value: o, options: l }) => r.cookies.set(a, o, l)
45
- );
46
- }
47
- }
48
- }
49
- ).auth.getUser();
50
- return e.nextUrl.pathname.startsWith("/protected") && i.error ? n.redirect(new URL("/sign-in", e.url)) : e.nextUrl.pathname === "/" && !i.error ? n.redirect(new URL("/protected", e.url)) : r;
51
- } catch {
52
- return n.next({
53
- request: {
54
- headers: e.headers
55
- }
56
- });
57
- }
58
- }, g = {
18
+ const N = {
59
19
  public: {
60
20
  Enums: {
61
21
  menu_location: ["HEADER", "FOOTER", "SIDEBAR"],
@@ -65,11 +25,56 @@ const f = async (e) => {
65
25
  }
66
26
  }
67
27
  };
28
+ async function w(e, i) {
29
+ const a = I(), { data: { user: s }, error: m } = await a.auth.getUser();
30
+ if (m || !s)
31
+ return i ? { error: "User not authenticated for media record." } : c("error", "/cms/media", "User not authenticated for media record.");
32
+ const { data: l } = await a.from("profiles").select("role").eq("id", s.id).single();
33
+ if (!l || !["ADMIN", "WRITER"].includes(l.role))
34
+ return i ? { error: "Forbidden: Insufficient permissions to record media." } : c("error", "/cms/media", "Forbidden: Insufficient permissions to record media.");
35
+ let t = e.r2Variants.find((r) => r.variantLabel === "original_avif") || e.r2Variants.find((r) => r.variantLabel === "xlarge_avif") || e.r2Variants[0] || e.originalImageDetails;
36
+ t || (t = e.originalImageDetails || {
37
+ objectKey: e.r2OriginalKey,
38
+ url: "",
39
+ width: 0,
40
+ height: 0,
41
+ fileType: "application/octet-stream",
42
+ sizeBytes: 0,
43
+ variantLabel: "fallback_original"
44
+ });
45
+ const _ = [
46
+ ...e.originalImageDetails && e.originalImageDetails.objectKey !== t.objectKey ? [e.originalImageDetails] : [],
47
+ ...e.r2Variants
48
+ ].filter((r, n, d) => n === d.findIndex((u) => u.objectKey === r.objectKey)), g = (r) => {
49
+ const n = r.lastIndexOf(".");
50
+ return (n > 0 ? r.substring(0, n) : r).replace(/[-+_\\]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w+/g, (f) => f.charAt(0).toUpperCase() + f.slice(1));
51
+ }, p = e.description ?? (t.fileType?.startsWith("image/") || e.originalImageDetails?.fileType?.startsWith("image/") ? g(e.fileName) : null), b = {
52
+ uploader_id: s.id,
53
+ file_name: e.fileName,
54
+ object_key: t.objectKey,
55
+ file_path: t.objectKey,
56
+ folder: (() => {
57
+ const r = t.objectKey.match(/^(.*\/)?.*$/);
58
+ return r && r[1] ? r[1] : null;
59
+ })(),
60
+ file_type: t.fileType,
61
+ size_bytes: t.sizeBytes,
62
+ description: p,
63
+ width: t.width,
64
+ height: t.height,
65
+ variants: _,
66
+ blur_data_url: e.blurDataUrl || null
67
+ }, { data: h, error: o } = await a.from("media").insert(b).select().single();
68
+ if (o)
69
+ return console.error("Error recording media upload:", o), i ? { error: `Failed to record media: ${o.message}` } : c("error", "/cms/media", `Failed to record media: ${o.message}`);
70
+ if (A.revalidatePath("/cms/media"), i)
71
+ return { success: !0, data: h };
72
+ c("success", "/cms/media", "Media recorded successfully.");
73
+ }
68
74
  export {
69
- g as Constants,
70
- p as createClient,
71
- U as getActiveLanguagesClientSide,
72
- S as getProfileWithRoleClientSide,
73
- N as getSsgSupabaseClient,
74
- f as updateSession
75
+ N as Constants,
76
+ U as createClient,
77
+ K as getActiveLanguagesClientSide,
78
+ T as getProfileWithRoleClientSide,
79
+ w as recordMediaUpload
75
80
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextblock-cms/db",
3
- "version": "0.2.29",
3
+ "version": "0.8.0",
4
4
  "main": "index.cjs.js",
5
5
  "module": "index.es.js",
6
6
  "types": "index.d.ts",
package/server.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@supabase/ssr"),c=require("next/headers"),u=require("./ssg-client-CiaENGEv.js"),d="This module cannot be imported from a Client Component module. It should only be used from a Server Component.";if(typeof window<"u")throw new Error(d);const i=()=>{const r=process.env.NEXT_PUBLIC_SUPABASE_URL,t=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;if(!r||!t)throw new Error("Missing Supabase environment variables");return l.createServerClient(r,t,{cookies:{getAll:async()=>{try{return(await c.cookies()).getAll()}catch{return[]}},setAll:async e=>{try{const o=await c.cookies();for(const{name:n,value:a,options:s}of e)a&&a.length>0?o.set({name:n,value:a,...s}):s&&Object.keys(s).length>0?o.delete({name:n,...s}):o.delete(n)}catch{}}}})};async function g(r){const t=i(),{data:e,error:o}=await t.from("profiles").select("id, full_name, avatar_url, role, updated_at, username, website").eq("id",r).single();return o||!e?(console.error("Error fetching profile (server-side):",o?.message),null):e}async function f(){const r=i(),{data:t,error:e}=await r.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name",{ascending:!0});return e?(console.error("Error fetching languages (server-side):",e.message),[]):t||[]}exports.getSsgSupabaseClient=u.getSsgSupabaseClient;exports.createClient=i;exports.getActiveLanguagesServerSide=f;exports.getProfileWithRoleServerSide=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./cache-Bb4TkKGq.js"),o=require("@supabase/supabase-js"),u=()=>{const e=process.env.NEXT_PUBLIC_SUPABASE_URL||"https://dummy.supabase.co",r=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY||"dummy-key";return(!process.env.NEXT_PUBLIC_SUPABASE_URL||!process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY)&&console.warn("Supabase URL or Anon Key is missing for SSG client. Returning dummy client to prevent build crash."),o.createClient(e,r)};var S={},i;function l(){if(i)return S;throw i=1,new Error("This module cannot be imported from a Client Component module. It should only be used from a Server Component.")}l();async function a(e,r){try{const{data:t,error:s}=await r.from("package_activations").select("status").eq("package_id",e).single();return s||!t?!1:t.status==="active"}catch(t){return console.error(`Error verifying package ${e}:`,t),!1}}const v=n.cacheExports.unstable_cache(async e=>{const r=process.env.NEXT_PUBLIC_SUPABASE_URL,t=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;if(!r||!t)return!1;const s=o.createClient(r,t,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}});return a(e,s)},["package-activation"],{revalidate:60});async function _(e,r){if(r)return a(e,r);const t=process.env.NEXT_PUBLIC_SUPABASE_URL,s=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;if(t&&s)return v(e);const c=await n.createClient();return a(e,c)}exports.createClient=n.createClient;exports.getActiveLanguagesServerSide=n.getActiveLanguagesServerSide;exports.getProfileWithRoleServerSide=n.getProfileWithRoleServerSide;exports.getServiceRoleSupabaseClient=n.getServiceRoleSupabaseClient;exports.getSsgSupabaseClient=u;exports.verifyPackageOnline=_;
package/server.es.js CHANGED
@@ -1,48 +1,53 @@
1
- import { createServerClient as l } from "@supabase/ssr";
2
- import { cookies as i } from "next/headers";
3
- import { g as _ } from "./ssg-client-DgUYZgPq.mjs";
4
- const u = "This module cannot be imported from a Client Component module. It should only be used from a Server Component.";
5
- if (typeof window < "u")
6
- throw new Error(u);
7
- const c = () => {
8
- const r = process.env.NEXT_PUBLIC_SUPABASE_URL, t = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
9
- if (!r || !t)
10
- throw new Error("Missing Supabase environment variables");
11
- return l(
12
- r,
13
- t,
14
- {
15
- cookies: {
16
- getAll: async () => {
17
- try {
18
- return (await i()).getAll();
19
- } catch {
20
- return [];
21
- }
22
- },
23
- setAll: async (e) => {
24
- try {
25
- const o = await i();
26
- for (const { name: s, value: a, options: n } of e)
27
- a && a.length > 0 ? o.set({ name: s, value: a, ...n }) : n && Object.keys(n).length > 0 ? o.delete({ name: s, ...n }) : o.delete(s);
28
- } catch {
29
- }
30
- }
31
- }
32
- }
33
- );
1
+ import { a as i, c as u } from "./cache-D0Q6YeSV.mjs";
2
+ import { g as P, b as y, d as m } from "./cache-D0Q6YeSV.mjs";
3
+ import { createClient as o } from "@supabase/supabase-js";
4
+ const p = () => {
5
+ const e = process.env.NEXT_PUBLIC_SUPABASE_URL || "https://dummy.supabase.co", r = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || "dummy-key";
6
+ return (!process.env.NEXT_PUBLIC_SUPABASE_URL || !process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY) && console.warn("Supabase URL or Anon Key is missing for SSG client. Returning dummy client to prevent build crash."), o(e, r);
34
7
  };
35
- async function p(r) {
36
- const t = c(), { data: e, error: o } = await t.from("profiles").select("id, full_name, avatar_url, role, updated_at, username, website").eq("id", r).single();
37
- return o || !e ? (console.error("Error fetching profile (server-side):", o?.message), null) : e;
8
+ var S = {}, a;
9
+ function _() {
10
+ if (a) return S;
11
+ throw a = 1, new Error(
12
+ "This module cannot be imported from a Client Component module. It should only be used from a Server Component."
13
+ );
38
14
  }
39
- async function g() {
40
- const r = c(), { data: t, error: e } = await r.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name", { ascending: !0 });
41
- return e ? (console.error("Error fetching languages (server-side):", e.message), []) : t || [];
15
+ _();
16
+ async function t(e, r) {
17
+ try {
18
+ const { data: s, error: n } = await r.from("package_activations").select("status").eq("package_id", e).single();
19
+ return n || !s ? !1 : s.status === "active";
20
+ } catch (s) {
21
+ return console.error(`Error verifying package ${e}:`, s), !1;
22
+ }
23
+ }
24
+ const l = i.unstable_cache(async (e) => {
25
+ const r = process.env.NEXT_PUBLIC_SUPABASE_URL, s = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
26
+ if (!r || !s)
27
+ return !1;
28
+ const n = o(r, s, {
29
+ auth: {
30
+ persistSession: !1,
31
+ autoRefreshToken: !1,
32
+ detectSessionInUrl: !1
33
+ }
34
+ });
35
+ return t(e, n);
36
+ }, ["package-activation"], { revalidate: 60 });
37
+ async function f(e, r) {
38
+ if (r)
39
+ return t(e, r);
40
+ const s = process.env.NEXT_PUBLIC_SUPABASE_URL, n = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
41
+ if (s && n)
42
+ return l(e);
43
+ const c = await u();
44
+ return t(e, c);
42
45
  }
43
46
  export {
44
- c as createClient,
45
- g as getActiveLanguagesServerSide,
46
- p as getProfileWithRoleServerSide,
47
- _ as getSsgSupabaseClient
47
+ u as createClient,
48
+ P as getActiveLanguagesServerSide,
49
+ y as getProfileWithRoleServerSide,
50
+ m as getServiceRoleSupabaseClient,
51
+ p as getSsgSupabaseClient,
52
+ f as verifyPackageOnline
48
53
  };