@nextblock-cms/db 0.19.0 → 0.19.1

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./supabase/server.cjs.js"),v=require("next/cache"),c=require("@nextblock-cms/utils/server");async function j(e,a){const o=_.createClient(),{data:{user:n},error:u}=await o.auth.getUser();if(u||!n)return a?{error:"User not authenticated for media record."}:c.encodedRedirect("error","/cms/media","User not authenticated for media record.");const{data:d}=await o.from("profiles").select("role").eq("id",n.id).single();if(!d||!["ADMIN","WRITER"].includes(d.role))return a?{error:"Forbidden: Insufficient permissions to record media."}:c.encodedRedirect("error","/cms/media","Forbidden: Insufficient permissions to record media.");let i=e.r2Variants.find(r=>r.variantLabel==="original_avif")||e.r2Variants.find(r=>r.variantLabel==="xlarge_avif")||e.r2Variants[0]||e.originalImageDetails;i||(i=e.originalImageDetails||{objectKey:e.r2OriginalKey,url:"",width:0,height:0,fileType:"application/octet-stream",sizeBytes:0,variantLabel:"fallback_original"});const g=[...e.originalImageDetails&&e.originalImageDetails.objectKey!==i.objectKey?[e.originalImageDetails]:[],...e.r2Variants].filter((r,t,l)=>t===l.findIndex(m=>m.objectKey===r.objectKey)),b=r=>{const t=r.lastIndexOf(".");return(t>0?r.substring(0,t):r).replace(/[-+_\\]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w+/g,f=>f.charAt(0).toUpperCase()+f.slice(1))},h=e.description??(i.fileType?.startsWith("image/")||e.originalImageDetails?.fileType?.startsWith("image/")?b(e.fileName):null),p={uploader_id:n.id,file_name:e.fileName,object_key:i.objectKey,file_path:i.objectKey,folder:(()=>{const r=i.objectKey.match(/^(.*\/)?.*$/);return r&&r[1]?r[1]:null})(),file_type:i.fileType,size_bytes:i.sizeBytes,description:h,width:i.width,height:i.height,variants:g,blur_data_url:e.blurDataUrl||null},{data:I,error:s}=await o.from("media").insert(p).select().single();if(s)return console.error("Error recording media upload:",s),a?{error:`Failed to record media: ${s.message}`}:c.encodedRedirect("error","/cms/media",`Failed to record media: ${s.message}`);if(v.revalidatePath("/cms/media"),a)return{success:!0,data:I};c.encodedRedirect("success","/cms/media","Media recorded successfully.")}exports.recordMediaUpload=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./supabase/server.cjs.js"),_=require("next/cache"),o=require("@nextblock-cms/utils/server");async function j(e,a){const n=e.actorUserId,d=n?g.getServiceRoleSupabaseClient():g.createClient();let s;if(n)s=n;else{const{data:{user:r},error:t}=await d.auth.getUser();if(t||!r)return a?{error:"User not authenticated for media record."}:o.encodedRedirect("error","/cms/media","User not authenticated for media record.");s=r.id}const{data:l}=await d.from("profiles").select("role").eq("id",s).single();if(!l||!["ADMIN","WRITER"].includes(l.role))return a?{error:"Forbidden: Insufficient permissions to record media."}:o.encodedRedirect("error","/cms/media","Forbidden: Insufficient permissions to record media.");let i=e.r2Variants.find(r=>r.variantLabel==="original_avif")||e.r2Variants.find(r=>r.variantLabel==="xlarge_avif")||e.r2Variants[0]||e.originalImageDetails;i||(i=e.originalImageDetails||{objectKey:e.r2OriginalKey,url:"",width:0,height:0,fileType:"application/octet-stream",sizeBytes:0,variantLabel:"fallback_original"});const b=[...e.originalImageDetails&&e.originalImageDetails.objectKey!==i.objectKey?[e.originalImageDetails]:[],...e.r2Variants].filter((r,t,m)=>t===m.findIndex(f=>f.objectKey===r.objectKey)),h=r=>{const t=r.lastIndexOf(".");return(t>0?r.substring(0,t):r).replace(/[-+_\\]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w+/g,u=>u.charAt(0).toUpperCase()+u.slice(1))},p=e.description??(i.fileType?.startsWith("image/")||e.originalImageDetails?.fileType?.startsWith("image/")?h(e.fileName):null),I={uploader_id:s,file_name:e.fileName,object_key:i.objectKey,file_path:i.objectKey,folder:(()=>{const r=i.objectKey.match(/^(.*\/)?.*$/);return r&&r[1]?r[1]:null})(),file_type:i.fileType,size_bytes:i.sizeBytes,description:p,width:i.width,height:i.height,variants:b,blur_data_url:e.blurDataUrl||null},{data:v,error:c}=await d.from("media").insert(I).select().single();if(c)return console.error("Error recording media upload:",c),a?{error:`Failed to record media: ${c.message}`}:o.encodedRedirect("error","/cms/media",`Failed to record media: ${c.message}`);if(_.revalidatePath("/cms/media"),a)return{success:!0,data:v};o.encodedRedirect("success","/cms/media","Media recorded successfully.")}exports.recordMediaUpload=j;
@@ -1,13 +1,20 @@
1
- import { createClient as _ } from "./supabase/server.es.js";
2
- import { revalidatePath as j } from "next/cache";
3
- import { encodedRedirect as o } from "@nextblock-cms/utils/server";
1
+ import { getServiceRoleSupabaseClient as _, createClient as j } from "./supabase/server.es.js";
2
+ import { revalidatePath as v } from "next/cache";
3
+ import { encodedRedirect as n } from "@nextblock-cms/utils/server";
4
4
  async function w(e, a) {
5
- const n = _(), { data: { user: c }, error: g } = await n.auth.getUser();
6
- if (g || !c)
7
- return a ? { error: "User not authenticated for media record." } : o("error", "/cms/media", "User not authenticated for media record.");
8
- const { data: l } = await n.from("profiles").select("role").eq("id", c.id).single();
9
- if (!l || !["ADMIN", "WRITER"].includes(l.role))
10
- return a ? { error: "Forbidden: Insufficient permissions to record media." } : o("error", "/cms/media", "Forbidden: Insufficient permissions to record media.");
5
+ const c = e.actorUserId, l = c ? _() : j();
6
+ let s;
7
+ if (c)
8
+ s = c;
9
+ else {
10
+ const { data: { user: r }, error: t } = await l.auth.getUser();
11
+ if (t || !r)
12
+ return a ? { error: "User not authenticated for media record." } : n("error", "/cms/media", "User not authenticated for media record.");
13
+ s = r.id;
14
+ }
15
+ const { data: d } = await l.from("profiles").select("role").eq("id", s).single();
16
+ if (!d || !["ADMIN", "WRITER"].includes(d.role))
17
+ return a ? { error: "Forbidden: Insufficient permissions to record media." } : n("error", "/cms/media", "Forbidden: Insufficient permissions to record media.");
11
18
  let i = e.r2Variants.find((r) => r.variantLabel === "original_avif") || e.r2Variants.find((r) => r.variantLabel === "xlarge_avif") || e.r2Variants[0] || e.originalImageDetails;
12
19
  i || (i = e.originalImageDetails || {
13
20
  objectKey: e.r2OriginalKey,
@@ -21,11 +28,13 @@ async function w(e, a) {
21
28
  const u = [
22
29
  ...e.originalImageDetails && e.originalImageDetails.objectKey !== i.objectKey ? [e.originalImageDetails] : [],
23
30
  ...e.r2Variants
24
- ].filter((r, t, d) => t === d.findIndex((m) => m.objectKey === r.objectKey)), b = (r) => {
31
+ ].filter(
32
+ (r, t, m) => t === m.findIndex((f) => f.objectKey === r.objectKey)
33
+ ), b = (r) => {
25
34
  const t = r.lastIndexOf(".");
26
- return (t > 0 ? r.substring(0, t) : r).replace(/[-+_\\]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w+/g, (f) => f.charAt(0).toUpperCase() + f.slice(1));
35
+ return (t > 0 ? r.substring(0, t) : r).replace(/[-+_\\]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w+/g, (g) => g.charAt(0).toUpperCase() + g.slice(1));
27
36
  }, h = e.description ?? (i.fileType?.startsWith("image/") || e.originalImageDetails?.fileType?.startsWith("image/") ? b(e.fileName) : null), p = {
28
- uploader_id: c.id,
37
+ uploader_id: s,
29
38
  file_name: e.fileName,
30
39
  object_key: i.objectKey,
31
40
  file_path: i.objectKey,
@@ -40,12 +49,12 @@ async function w(e, a) {
40
49
  height: i.height,
41
50
  variants: u,
42
51
  blur_data_url: e.blurDataUrl || null
43
- }, { data: I, error: s } = await n.from("media").insert(p).select().single();
44
- if (s)
45
- return console.error("Error recording media upload:", s), a ? { error: `Failed to record media: ${s.message}` } : o("error", "/cms/media", `Failed to record media: ${s.message}`);
46
- if (j("/cms/media"), a)
52
+ }, { data: I, error: o } = await l.from("media").insert(p).select().single();
53
+ if (o)
54
+ return console.error("Error recording media upload:", o), a ? { error: `Failed to record media: ${o.message}` } : n("error", "/cms/media", `Failed to record media: ${o.message}`);
55
+ if (v("/cms/media"), a)
47
56
  return { success: !0, data: I };
48
- o("success", "/cms/media", "Media recorded successfully.");
57
+ n("success", "/cms/media", "Media recorded successfully.");
49
58
  }
50
59
  export {
51
60
  w as recordMediaUpload
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("server-only");const c=require("./supabase/server.cjs.js"),i=require("next/cache"),o=require("@supabase/supabase-js");async function a(r,s){try{const{data:e,error:t}=await s.from("package_activations").select("status").eq("package_id",r).single();return t||!e?!1:e.status==="active"}catch(e){return console.error(`Error verifying package ${r}:`,e),!1}}const u=i.unstable_cache(async r=>{const s=process.env.NEXT_PUBLIC_SUPABASE_URL,e=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;if(!s||!e)return!1;const t=o.createClient(s,e,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}});return a(r,t)},["package-activation"],{revalidate:60});async function _(r,s){if(s)return a(r,s);const e=process.env.NEXT_PUBLIC_SUPABASE_URL,t=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;if(e&&t)return u(r);const n=await c.createClient();return a(r,n)}exports.verifyPackageOnline=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("server-only");const A=require("./supabase/server.cjs.js"),E=require("next/cache"),_=require("@supabase/supabase-js"),c="package-activation";function l(e){if(typeof e!="string"||!e.trim())return null;const r=e.trim(),t=/(?:z|[+-]\d{2}:?\d{2})$/i.test(r),n=Date.parse(t?r:`${r.replace(" ","T")}Z`);return Number.isFinite(n)?n:null}function i(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const r=e,t=r.nextblock&&typeof r.nextblock=="object"&&!Array.isArray(r.nextblock)?r.nextblock:null,n=[t?.expiration,t?.trial_ends_at,r.expiration].map(l).filter(s=>s!==null);return n.length>0?Math.min(...n):null}function o(e,r=Date.now()){if(e.status!=="active")return!1;const t=i(e.meta);return t===null||t>r}async function a(e,r){try{const{data:t,error:n}=await r.from("package_activations").select("status, meta").eq("package_id",e).eq("status","active").limit(5);return n||!Array.isArray(t)?!1:t.some(s=>o(s))}catch(t){return console.error(`Error verifying package ${e}:`,t),!1}}const S=E.unstable_cache(async e=>{const r=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL,t=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.SUPABASE_SECRET_KEY||process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY||process.env.SUPABASE_ANON_KEY||process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY||process.env.SUPABASE_PUBLISHABLE_KEY;if(!r||!t)return!1;const n=_.createClient(r,t,{auth:{persistSession:!1,autoRefreshToken:!1,detectSessionInUrl:!1}});return a(e,n)},["package-activation"],{revalidate:60,tags:[c]});async function u(e,r){if(r)return a(e,r);const t=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL,n=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.SUPABASE_SECRET_KEY||process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY||process.env.SUPABASE_ANON_KEY||process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY||process.env.SUPABASE_PUBLISHABLE_KEY;if(t&&n)return S(e);const s=await A.createClient();return a(e,s)}exports.PACKAGE_ACTIVATION_CACHE_TAG=c;exports.isPackageActivationRowValid=o;exports.resolvePackageActivationExpiry=i;exports.verifyPackageOnline=u;
@@ -2,36 +2,62 @@ import "server-only";
2
2
  import { createClient as c } from "./supabase/server.es.js";
3
3
  import { unstable_cache as o } from "next/cache";
4
4
  import { createClient as i } from "@supabase/supabase-js";
5
- async function a(r, s) {
5
+ const A = "package-activation";
6
+ function E(e) {
7
+ if (typeof e != "string" || !e.trim())
8
+ return null;
9
+ const r = e.trim(), t = /(?:z|[+-]\d{2}:?\d{2})$/i.test(r), n = Date.parse(t ? r : `${r.replace(" ", "T")}Z`);
10
+ return Number.isFinite(n) ? n : null;
11
+ }
12
+ function _(e) {
13
+ if (!e || typeof e != "object" || Array.isArray(e))
14
+ return null;
15
+ const r = e, t = r.nextblock && typeof r.nextblock == "object" && !Array.isArray(r.nextblock) ? r.nextblock : null, n = [t?.expiration, t?.trial_ends_at, r.expiration].map(E).filter((s) => s !== null);
16
+ return n.length > 0 ? Math.min(...n) : null;
17
+ }
18
+ function l(e, r = Date.now()) {
19
+ if (e.status !== "active")
20
+ return !1;
21
+ const t = _(e.meta);
22
+ return t === null || t > r;
23
+ }
24
+ async function a(e, r) {
6
25
  try {
7
- const { data: e, error: t } = await s.from("package_activations").select("status").eq("package_id", r).single();
8
- return t || !e ? !1 : e.status === "active";
9
- } catch (e) {
10
- return console.error(`Error verifying package ${r}:`, e), !1;
26
+ const { data: t, error: n } = await r.from("package_activations").select("status, meta").eq("package_id", e).eq("status", "active").limit(5);
27
+ return n || !Array.isArray(t) ? !1 : t.some((s) => l(s));
28
+ } catch (t) {
29
+ return console.error(`Error verifying package ${e}:`, t), !1;
11
30
  }
12
31
  }
13
- const _ = o(async (r) => {
14
- const s = process.env.NEXT_PUBLIC_SUPABASE_URL, e = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
15
- if (!s || !e)
16
- return !1;
17
- const t = i(s, e, {
18
- auth: {
19
- persistSession: !1,
20
- autoRefreshToken: !1,
21
- detectSessionInUrl: !1
22
- }
23
- });
24
- return a(r, t);
25
- }, ["package-activation"], { revalidate: 60 });
26
- async function v(r, s) {
27
- if (s)
28
- return a(r, s);
29
- const e = process.env.NEXT_PUBLIC_SUPABASE_URL, t = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
30
- if (e && t)
31
- return _(r);
32
- const n = await c();
33
- return a(r, n);
32
+ const S = o(
33
+ async (e) => {
34
+ const r = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, t = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY;
35
+ if (!r || !t)
36
+ return !1;
37
+ const n = i(r, t, {
38
+ auth: {
39
+ persistSession: !1,
40
+ autoRefreshToken: !1,
41
+ detectSessionInUrl: !1
42
+ }
43
+ });
44
+ return a(e, n);
45
+ },
46
+ ["package-activation"],
47
+ { revalidate: 60, tags: [A] }
48
+ );
49
+ async function U(e, r) {
50
+ if (r)
51
+ return a(e, r);
52
+ const t = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, n = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY;
53
+ if (t && n)
54
+ return S(e);
55
+ const s = await c();
56
+ return a(e, s);
34
57
  }
35
58
  export {
36
- v as verifyPackageOnline
59
+ A as PACKAGE_ACTIVATION_CACHE_TAG,
60
+ l as isPackageActivationRowValid,
61
+ _ as resolvePackageActivationExpiry,
62
+ U as verifyPackageOnline
37
63
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@supabase/ssr"),n=()=>{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 i.createBrowserClient(e,t)};async function s(e,t){const{data:r,error:a}=await e.from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id",t).single();return a||!r?null:r}async function o(){const e=n(),{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||[]}exports.createClient=n;exports.getActiveLanguagesClientSide=o;exports.getProfileWithRoleClientSide=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@supabase/ssr"),t=()=>{const r=typeof window<"u"?window.__NEXTBLOCK_PUBLIC_ENV__:void 0,n=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL||r?.url,e=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY||process.env.SUPABASE_ANON_KEY||process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY||process.env.SUPABASE_PUBLISHABLE_KEY||r?.anonKey;if(!n||!e)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: ${!!n}, ANON_KEY_IS_SET: ${!!e}`);return s.createBrowserClient(n,e)};async function a(r,n){const{data:e,error:i}=await r.from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id",n).single();return i||!e?null:e}async function o(){const r=t(),{data:n,error:e}=await r.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name",{ascending:!0});return e?[]:n||[]}exports.createClient=t;exports.getActiveLanguagesClientSide=o;exports.getProfileWithRoleClientSide=a;
@@ -1,20 +1,22 @@
1
- import { createBrowserClient as a } from "@supabase/ssr";
2
- const o = () => {
3
- const e = process.env.NEXT_PUBLIC_SUPABASE_URL, r = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
4
- if (!e || !r)
5
- 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: ${!!r}`);
6
- return a(e, r);
1
+ import { createBrowserClient as o } from "@supabase/ssr";
2
+ const a = () => {
3
+ const n = typeof window < "u" ? window.__NEXTBLOCK_PUBLIC_ENV__ : void 0, r = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL || n?.url, e = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY || n?.anonKey;
4
+ if (!r || !e)
5
+ throw new Error(
6
+ `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: ${!!r}, ANON_KEY_IS_SET: ${!!e}`
7
+ );
8
+ return o(r, e);
7
9
  };
8
- async function i(e, r) {
9
- const { data: t, error: n } = await e.from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id", r).single();
10
- return n || !t ? null : t;
10
+ async function _(n, r) {
11
+ const { data: e, error: t } = await n.from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id", r).single();
12
+ return t || !e ? null : e;
11
13
  }
12
- async function _() {
13
- const e = o(), { data: r, error: t } = await e.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name", { ascending: !0 });
14
- return t ? [] : r || [];
14
+ async function i() {
15
+ const n = a(), { data: r, error: e } = await n.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name", { ascending: !0 });
16
+ return e ? [] : r || [];
15
17
  }
16
18
  export {
17
- o as createClient,
18
- _ as getActiveLanguagesClientSide,
19
- i as getProfileWithRoleClientSide
19
+ a as createClient,
20
+ i as getActiveLanguagesClientSide,
21
+ _ as getProfileWithRoleClientSide
20
22
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@supabase/ssr"),u=require("@supabase/supabase-js"),c=require("next/headers"),S="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(S);const i=()=>{const e=process.env.NEXT_PUBLIC_SUPABASE_URL,r=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;if(!e||!r)throw new Error("Missing Supabase environment variables");return l.createServerClient(e,r,{cookies:{getAll:async()=>{try{return(await c.cookies()).getAll()}catch{return[]}},setAll:async t=>{try{const s=await c.cookies();for(const{name:n,value:a,options:o}of t)a&&a.length>0?s.set({name:n,value:a,...o}):o&&Object.keys(o).length>0?s.delete({name:n,...o}):s.delete(n)}catch{}}}})};async function d(e){const r=i(),{data:t,error:s}=await r.from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id",e).single();return s||!t?(console.error("Error fetching profile (server-side):",s?.message),null):t}async function f(){const e=i(),{data:r,error:t}=await e.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name",{ascending:!0});return t?(console.error("Error fetching languages (server-side):",t.message),[]):r||[]}const g=()=>{const e=process.env.NEXT_PUBLIC_SUPABASE_URL,r=process.env.SUPABASE_SERVICE_ROLE_KEY;if(!e||!r)throw new Error("Missing Supabase Service Role environment variables");return u.createClient(e,r,{auth:{autoRefreshToken:!1,persistSession:!1}})};exports.createClient=i;exports.getActiveLanguagesServerSide=f;exports.getProfileWithRoleServerSide=d;exports.getServiceRoleSupabaseClient=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@supabase/ssr"),S=require("@supabase/supabase-js"),c=require("next/headers"),u="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(u);const i=()=>{const e=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL||"https://dummy.supabase.co",r=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY||process.env.SUPABASE_ANON_KEY||process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY||process.env.SUPABASE_PUBLISHABLE_KEY||"dummy-anon-key";return l.createServerClient(e,r,{cookies:{getAll:async()=>{try{return(await c.cookies()).getAll()}catch{return[]}},setAll:async s=>{try{const t=await c.cookies();for(const{name:n,value:a,options:o}of s)a&&a.length>0?t.set({name:n,value:a,...o}):o&&Object.keys(o).length>0?t.delete({name:n,...o}):t.delete(n)}catch{}}}})};async function E(e){const r=i(),{data:s,error:t}=await r.from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id",e).single();return t||!s?(console.error("Error fetching profile (server-side):",t?.message),null):s}async function d(){const e=i(),{data:r,error:s}=await e.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name",{ascending:!0});return s?(console.error("Error fetching languages (server-side):",s.message),[]):r||[]}const p=()=>{const e=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL,r=process.env.SUPABASE_SERVICE_ROLE_KEY||process.env.SUPABASE_SECRET_KEY;if(!e||!r)throw new Error("Missing Supabase Service Role environment variables");return S.createClient(e,r,{auth:{autoRefreshToken:!1,persistSession:!1}})};exports.createClient=i;exports.getActiveLanguagesServerSide=d;exports.getProfileWithRoleServerSide=E;exports.getServiceRoleSupabaseClient=p;
@@ -1,46 +1,48 @@
1
1
  import { createServerClient as l } from "@supabase/ssr";
2
- import { createClient as u } from "@supabase/supabase-js";
2
+ import { createClient as S } from "@supabase/supabase-js";
3
3
  import { cookies as i } from "next/headers";
4
- const f = "This module cannot be imported from a Client Component module. It should only be used from a Server Component.";
4
+ const u = "This module cannot be imported from a Client Component module. It should only be used from a Server Component.";
5
5
  if (typeof window < "u")
6
- throw new Error(f);
6
+ throw new Error(u);
7
7
  const c = () => {
8
- const e = process.env.NEXT_PUBLIC_SUPABASE_URL, r = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
9
- if (!e || !r)
10
- throw new Error("Missing Supabase environment variables");
11
- return l(e, r, {
12
- cookies: {
13
- getAll: async () => {
14
- try {
15
- return (await i()).getAll();
16
- } catch {
17
- return [];
18
- }
19
- },
20
- setAll: async (t) => {
21
- try {
22
- const o = await i();
23
- for (const { name: n, value: a, options: s } of t)
24
- 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);
25
- } catch {
8
+ const e = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL || "https://dummy.supabase.co", r = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY || "dummy-anon-key";
9
+ return l(
10
+ e,
11
+ r,
12
+ {
13
+ cookies: {
14
+ getAll: async () => {
15
+ try {
16
+ return (await i()).getAll();
17
+ } catch {
18
+ return [];
19
+ }
20
+ },
21
+ setAll: async (o) => {
22
+ try {
23
+ const s = await i();
24
+ for (const { name: n, value: a, options: t } of o)
25
+ a && a.length > 0 ? s.set({ name: n, value: a, ...t }) : t && Object.keys(t).length > 0 ? s.delete({ name: n, ...t }) : s.delete(n);
26
+ } catch {
27
+ }
26
28
  }
27
29
  }
28
30
  }
29
- });
31
+ );
30
32
  };
31
- async function m(e) {
32
- const r = c(), { data: t, error: o } = await r.from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id", e).single();
33
- return o || !t ? (console.error("Error fetching profile (server-side):", o?.message), null) : t;
33
+ async function f(e) {
34
+ const r = c(), { data: o, error: s } = await r.from("profiles").select("id, full_name, avatar_url, role, updated_at, website").eq("id", e).single();
35
+ return s || !o ? (console.error("Error fetching profile (server-side):", s?.message), null) : o;
34
36
  }
35
- async function E() {
36
- const e = c(), { data: r, error: t } = await e.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name", { ascending: !0 });
37
- return t ? (console.error("Error fetching languages (server-side):", t.message), []) : r || [];
37
+ async function d() {
38
+ const e = c(), { data: r, error: o } = await e.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name", { ascending: !0 });
39
+ return o ? (console.error("Error fetching languages (server-side):", o.message), []) : r || [];
38
40
  }
39
- const _ = () => {
40
- const e = process.env.NEXT_PUBLIC_SUPABASE_URL, r = process.env.SUPABASE_SERVICE_ROLE_KEY;
41
+ const A = () => {
42
+ const e = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, r = process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.SUPABASE_SECRET_KEY;
41
43
  if (!e || !r)
42
44
  throw new Error("Missing Supabase Service Role environment variables");
43
- return u(e, r, {
45
+ return S(e, r, {
44
46
  auth: {
45
47
  autoRefreshToken: !1,
46
48
  persistSession: !1
@@ -49,7 +51,7 @@ const _ = () => {
49
51
  };
50
52
  export {
51
53
  c as createClient,
52
- E as getActiveLanguagesServerSide,
53
- m as getProfileWithRoleServerSide,
54
- _ as getServiceRoleSupabaseClient
54
+ d as getActiveLanguagesServerSide,
55
+ f as getProfileWithRoleServerSide,
56
+ A as getServiceRoleSupabaseClient
55
57
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@supabase/supabase-js"),t=()=>{const e=process.env.NEXT_PUBLIC_SUPABASE_URL||"https://dummy.supabase.co",s=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."),n.createClient(e,s)};exports.getSsgSupabaseClient=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@supabase/supabase-js"),r=()=>{const e=process.env.NEXT_PUBLIC_SUPABASE_URL||process.env.SUPABASE_URL,s=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY||process.env.SUPABASE_ANON_KEY||process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY||process.env.SUPABASE_PUBLISHABLE_KEY,n=e||"https://dummy.supabase.co",t=s||"dummy-key";return(!e||!s)&&console.warn("Supabase URL or Anon Key is missing for SSG client. Returning dummy client to prevent build crash."),o.createClient(n,t)};exports.getSsgSupabaseClient=r;
@@ -1,8 +1,8 @@
1
- import { createClient as n } from "@supabase/supabase-js";
2
- const r = () => {
3
- const e = process.env.NEXT_PUBLIC_SUPABASE_URL || "https://dummy.supabase.co", s = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || "dummy-key";
4
- 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."), n(e, s);
1
+ import { createClient as r } from "@supabase/supabase-js";
2
+ const S = () => {
3
+ const e = process.env.NEXT_PUBLIC_SUPABASE_URL || process.env.SUPABASE_URL, s = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || process.env.SUPABASE_ANON_KEY || process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY, n = e || "https://dummy.supabase.co", o = s || "dummy-key";
4
+ return (!e || !s) && console.warn("Supabase URL or Anon Key is missing for SSG client. Returning dummy client to prevent build crash."), r(n, o);
5
5
  };
6
6
  export {
7
- r as getSsgSupabaseClient
7
+ S as getSsgSupabaseClient
8
8
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t={public:{Enums:{menu_location:["HEADER","FOOTER","SIDEBAR"],page_status:["draft","published","archived"],revision_type:["snapshot","diff"],user_role:["ADMIN","WRITER","USER"]}}};exports.Constants=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={public:{Enums:{approval_status:["pending","approved","denied"],interaction_type:["review","comment"],menu_location:["HEADER","FOOTER","SIDEBAR"],page_status:["draft","published","archived"],revision_type:["snapshot","diff"],user_role:["ADMIN","WRITER","USER"]}}};exports.Constants=e;
@@ -1,6 +1,8 @@
1
- const s = {
1
+ const e = {
2
2
  public: {
3
3
  Enums: {
4
+ approval_status: ["pending", "approved", "denied"],
5
+ interaction_type: ["review", "comment"],
4
6
  menu_location: ["HEADER", "FOOTER", "SIDEBAR"],
5
7
  page_status: ["draft", "published", "archived"],
6
8
  revision_type: ["snapshot", "diff"],
@@ -9,5 +11,5 @@ const s = {
9
11
  }
10
12
  };
11
13
  export {
12
- s as Constants
14
+ e as Constants
13
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextblock-cms/db",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
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 t=require("./lib/supabase/server.cjs.js"),n=require("./lib/supabase/ssg-client.cjs.js"),i=require("./lib/package-validation.cjs.js"),e=require("./lib/secret-crypto.cjs.js"),r=require("./lib/config-resolve.cjs.js");exports.createClient=t.createClient;exports.getActiveLanguagesServerSide=t.getActiveLanguagesServerSide;exports.getProfileWithRoleServerSide=t.getProfileWithRoleServerSide;exports.getServiceRoleSupabaseClient=t.getServiceRoleSupabaseClient;exports.getSsgSupabaseClient=n.getSsgSupabaseClient;exports.verifyPackageOnline=i.verifyPackageOnline;exports.SECRET_ENVELOPE_ALGORITHM=e.SECRET_ENVELOPE_ALGORITHM;exports.SECRET_ENVELOPE_VERSION=e.SECRET_ENVELOPE_VERSION;exports.decryptSecret=e.decryptSecret;exports.decryptWithEnvKey=e.decryptWithEnvKey;exports.encryptSecret=e.encryptSecret;exports.encryptWithEnvKey=e.encryptWithEnvKey;exports.getMaskedSecret=e.getMaskedSecret;exports.getSecretEnvelopeStatus=e.getSecretEnvelopeStatus;exports.hasSecretEncryptionKey=e.hasSecretEncryptionKey;exports.isEncryptedSecretEnvelope=e.isEncryptedSecretEnvelope;exports.requireSecretEncryptionKey=e.requireSecretEncryptionKey;exports.resolveSecretEncryptionKey=e.resolveSecretEncryptionKey;exports.tryDecryptWithEnvKey=e.tryDecryptWithEnvKey;exports.isSandboxEnvironment=r.isSandboxEnvironment;exports.resolveConfigValue=r.resolveConfigValue;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./lib/supabase/server.cjs.js"),n=require("./lib/supabase/ssg-client.cjs.js"),r=require("./lib/package-validation.cjs.js"),e=require("./lib/secret-crypto.cjs.js"),i=require("./lib/config-resolve.cjs.js");exports.createClient=t.createClient;exports.getActiveLanguagesServerSide=t.getActiveLanguagesServerSide;exports.getProfileWithRoleServerSide=t.getProfileWithRoleServerSide;exports.getServiceRoleSupabaseClient=t.getServiceRoleSupabaseClient;exports.getSsgSupabaseClient=n.getSsgSupabaseClient;exports.PACKAGE_ACTIVATION_CACHE_TAG=r.PACKAGE_ACTIVATION_CACHE_TAG;exports.isPackageActivationRowValid=r.isPackageActivationRowValid;exports.resolvePackageActivationExpiry=r.resolvePackageActivationExpiry;exports.verifyPackageOnline=r.verifyPackageOnline;exports.SECRET_ENVELOPE_ALGORITHM=e.SECRET_ENVELOPE_ALGORITHM;exports.SECRET_ENVELOPE_VERSION=e.SECRET_ENVELOPE_VERSION;exports.decryptSecret=e.decryptSecret;exports.decryptWithEnvKey=e.decryptWithEnvKey;exports.encryptSecret=e.encryptSecret;exports.encryptWithEnvKey=e.encryptWithEnvKey;exports.getMaskedSecret=e.getMaskedSecret;exports.getSecretEnvelopeStatus=e.getSecretEnvelopeStatus;exports.hasSecretEncryptionKey=e.hasSecretEncryptionKey;exports.isEncryptedSecretEnvelope=e.isEncryptedSecretEnvelope;exports.requireSecretEncryptionKey=e.requireSecretEncryptionKey;exports.resolveSecretEncryptionKey=e.resolveSecretEncryptionKey;exports.tryDecryptWithEnvKey=e.tryDecryptWithEnvKey;exports.isSandboxEnvironment=i.isSandboxEnvironment;exports.resolveConfigValue=i.resolveConfigValue;
package/server.es.js CHANGED
@@ -1,28 +1,31 @@
1
- import { createClient as t, getActiveLanguagesServerSide as n, getProfileWithRoleServerSide as o, getServiceRoleSupabaseClient as i } from "./lib/supabase/server.es.js";
1
+ import { createClient as r, getActiveLanguagesServerSide as i, getProfileWithRoleServerSide as n, getServiceRoleSupabaseClient as o } from "./lib/supabase/server.es.js";
2
2
  import { getSsgSupabaseClient as E } from "./lib/supabase/ssg-client.es.js";
3
- import { verifyPackageOnline as p } from "./lib/package-validation.es.js";
4
- import { SECRET_ENVELOPE_ALGORITHM as a, SECRET_ENVELOPE_VERSION as v, decryptSecret as l, decryptWithEnvKey as g, encryptSecret as s, encryptWithEnvKey as f, getMaskedSecret as d, getSecretEnvelopeStatus as m, hasSecretEncryptionKey as u, isEncryptedSecretEnvelope as x, requireSecretEncryptionKey as C, resolveSecretEncryptionKey as K, tryDecryptWithEnvKey as R } from "./lib/secret-crypto.es.js";
5
- import { isSandboxEnvironment as O, resolveConfigValue as L } from "./lib/config-resolve.es.js";
3
+ import { PACKAGE_ACTIVATION_CACHE_TAG as S, isPackageActivationRowValid as p, resolvePackageActivationExpiry as y, verifyPackageOnline as v } from "./lib/package-validation.es.js";
4
+ import { SECRET_ENVELOPE_ALGORITHM as g, SECRET_ENVELOPE_VERSION as s, decryptSecret as A, decryptWithEnvKey as C, encryptSecret as d, encryptWithEnvKey as f, getMaskedSecret as x, getSecretEnvelopeStatus as K, hasSecretEncryptionKey as P, isEncryptedSecretEnvelope as R, requireSecretEncryptionKey as _, resolveSecretEncryptionKey as m, tryDecryptWithEnvKey as u } from "./lib/secret-crypto.es.js";
5
+ import { isSandboxEnvironment as T, resolveConfigValue as V } from "./lib/config-resolve.es.js";
6
6
  export {
7
- a as SECRET_ENVELOPE_ALGORITHM,
8
- v as SECRET_ENVELOPE_VERSION,
9
- t as createClient,
10
- l as decryptSecret,
11
- g as decryptWithEnvKey,
12
- s as encryptSecret,
7
+ S as PACKAGE_ACTIVATION_CACHE_TAG,
8
+ g as SECRET_ENVELOPE_ALGORITHM,
9
+ s as SECRET_ENVELOPE_VERSION,
10
+ r as createClient,
11
+ A as decryptSecret,
12
+ C as decryptWithEnvKey,
13
+ d as encryptSecret,
13
14
  f as encryptWithEnvKey,
14
- n as getActiveLanguagesServerSide,
15
- d as getMaskedSecret,
16
- o as getProfileWithRoleServerSide,
17
- m as getSecretEnvelopeStatus,
18
- i as getServiceRoleSupabaseClient,
15
+ i as getActiveLanguagesServerSide,
16
+ x as getMaskedSecret,
17
+ n as getProfileWithRoleServerSide,
18
+ K as getSecretEnvelopeStatus,
19
+ o as getServiceRoleSupabaseClient,
19
20
  E as getSsgSupabaseClient,
20
- u as hasSecretEncryptionKey,
21
- x as isEncryptedSecretEnvelope,
22
- O as isSandboxEnvironment,
23
- C as requireSecretEncryptionKey,
24
- L as resolveConfigValue,
25
- K as resolveSecretEncryptionKey,
26
- R as tryDecryptWithEnvKey,
27
- p as verifyPackageOnline
21
+ P as hasSecretEncryptionKey,
22
+ R as isEncryptedSecretEnvelope,
23
+ p as isPackageActivationRowValid,
24
+ T as isSandboxEnvironment,
25
+ _ as requireSecretEncryptionKey,
26
+ V as resolveConfigValue,
27
+ y as resolvePackageActivationExpiry,
28
+ m as resolveSecretEncryptionKey,
29
+ u as tryDecryptWithEnvKey,
30
+ v as verifyPackageOnline
28
31
  };