@nextblock-cms/db 0.8.1 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +1 -1
- package/index.es.js +8 -78
- package/lib/media-actions.cjs.js +1 -0
- package/lib/media-actions.es.js +52 -0
- package/lib/package-validation.cjs.js +1 -0
- package/lib/package-validation.es.js +37 -0
- package/lib/supabase/client.cjs.js +1 -0
- package/lib/supabase/client.es.js +20 -0
- package/lib/supabase/server.cjs.js +1 -0
- package/lib/supabase/server.es.js +55 -0
- package/lib/supabase/ssg-client.cjs.js +1 -0
- package/lib/supabase/ssg-client.es.js +8 -0
- package/lib/supabase/types.cjs.js +1 -0
- package/lib/supabase/types.es.js +13 -0
- package/package.json +1 -1
- package/server.cjs.js +1 -1
- package/server.es.js +9 -51
- package/cache-Bb4TkKGq.js +0 -38
- package/cache-D0Q6YeSV.mjs +0 -10150
package/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./lib/supabase/client.cjs.js"),t=require("./lib/supabase/types.cjs.js"),i=require("./lib/media-actions.cjs.js");exports.createClient=e.createClient;exports.getActiveLanguagesClientSide=e.getActiveLanguagesClientSide;exports.getProfileWithRoleClientSide=e.getProfileWithRoleClientSide;exports.Constants=t.Constants;exports.recordMediaUpload=i.recordMediaUpload;
|
package/index.es.js
CHANGED
|
@@ -1,80 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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);
|
|
9
|
-
};
|
|
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;
|
|
13
|
-
}
|
|
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 || [];
|
|
17
|
-
}
|
|
18
|
-
const N = {
|
|
19
|
-
public: {
|
|
20
|
-
Enums: {
|
|
21
|
-
menu_location: ["HEADER", "FOOTER", "SIDEBAR"],
|
|
22
|
-
page_status: ["draft", "published", "archived"],
|
|
23
|
-
revision_type: ["snapshot", "diff"],
|
|
24
|
-
user_role: ["ADMIN", "WRITER", "USER"]
|
|
25
|
-
}
|
|
26
|
-
}
|
|
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
|
-
}
|
|
1
|
+
import { createClient as o, getActiveLanguagesClientSide as r, getProfileWithRoleClientSide as i } from "./lib/supabase/client.es.js";
|
|
2
|
+
import { Constants as l } from "./lib/supabase/types.es.js";
|
|
3
|
+
import { recordMediaUpload as d } from "./lib/media-actions.es.js";
|
|
74
4
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
5
|
+
l as Constants,
|
|
6
|
+
o as createClient,
|
|
7
|
+
r as getActiveLanguagesClientSide,
|
|
8
|
+
i as getProfileWithRoleClientSide,
|
|
9
|
+
d as recordMediaUpload
|
|
80
10
|
};
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,52 @@
|
|
|
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";
|
|
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.");
|
|
11
|
+
let i = e.r2Variants.find((r) => r.variantLabel === "original_avif") || e.r2Variants.find((r) => r.variantLabel === "xlarge_avif") || e.r2Variants[0] || e.originalImageDetails;
|
|
12
|
+
i || (i = e.originalImageDetails || {
|
|
13
|
+
objectKey: e.r2OriginalKey,
|
|
14
|
+
url: "",
|
|
15
|
+
width: 0,
|
|
16
|
+
height: 0,
|
|
17
|
+
fileType: "application/octet-stream",
|
|
18
|
+
sizeBytes: 0,
|
|
19
|
+
variantLabel: "fallback_original"
|
|
20
|
+
});
|
|
21
|
+
const u = [
|
|
22
|
+
...e.originalImageDetails && e.originalImageDetails.objectKey !== i.objectKey ? [e.originalImageDetails] : [],
|
|
23
|
+
...e.r2Variants
|
|
24
|
+
].filter((r, t, d) => t === d.findIndex((m) => m.objectKey === r.objectKey)), b = (r) => {
|
|
25
|
+
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));
|
|
27
|
+
}, h = e.description ?? (i.fileType?.startsWith("image/") || e.originalImageDetails?.fileType?.startsWith("image/") ? b(e.fileName) : null), p = {
|
|
28
|
+
uploader_id: c.id,
|
|
29
|
+
file_name: e.fileName,
|
|
30
|
+
object_key: i.objectKey,
|
|
31
|
+
file_path: i.objectKey,
|
|
32
|
+
folder: (() => {
|
|
33
|
+
const r = i.objectKey.match(/^(.*\/)?.*$/);
|
|
34
|
+
return r && r[1] ? r[1] : null;
|
|
35
|
+
})(),
|
|
36
|
+
file_type: i.fileType,
|
|
37
|
+
size_bytes: i.sizeBytes,
|
|
38
|
+
description: h,
|
|
39
|
+
width: i.width,
|
|
40
|
+
height: i.height,
|
|
41
|
+
variants: u,
|
|
42
|
+
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)
|
|
47
|
+
return { success: !0, data: I };
|
|
48
|
+
o("success", "/cms/media", "Media recorded successfully.");
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
w as recordMediaUpload
|
|
52
|
+
};
|
|
@@ -0,0 +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=_;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { createClient as c } from "./supabase/server.es.js";
|
|
3
|
+
import { unstable_cache as o } from "next/cache";
|
|
4
|
+
import { createClient as i } from "@supabase/supabase-js";
|
|
5
|
+
async function a(r, s) {
|
|
6
|
+
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;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
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);
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
v as verifyPackageOnline
|
|
37
|
+
};
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,20 @@
|
|
|
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);
|
|
7
|
+
};
|
|
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;
|
|
11
|
+
}
|
|
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 || [];
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
o as createClient,
|
|
18
|
+
_ as getActiveLanguagesClientSide,
|
|
19
|
+
i as getProfileWithRoleClientSide
|
|
20
|
+
};
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createServerClient as l } from "@supabase/ssr";
|
|
2
|
+
import { createClient as u } from "@supabase/supabase-js";
|
|
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.";
|
|
5
|
+
if (typeof window < "u")
|
|
6
|
+
throw new Error(f);
|
|
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 {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
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;
|
|
34
|
+
}
|
|
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 || [];
|
|
38
|
+
}
|
|
39
|
+
const _ = () => {
|
|
40
|
+
const e = process.env.NEXT_PUBLIC_SUPABASE_URL, r = process.env.SUPABASE_SERVICE_ROLE_KEY;
|
|
41
|
+
if (!e || !r)
|
|
42
|
+
throw new Error("Missing Supabase Service Role environment variables");
|
|
43
|
+
return u(e, r, {
|
|
44
|
+
auth: {
|
|
45
|
+
autoRefreshToken: !1,
|
|
46
|
+
persistSession: !1
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
c as createClient,
|
|
52
|
+
E as getActiveLanguagesServerSide,
|
|
53
|
+
m as getProfileWithRoleServerSide,
|
|
54
|
+
_ as getServiceRoleSupabaseClient
|
|
55
|
+
};
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +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);
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
r as getSsgSupabaseClient
|
|
8
|
+
};
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const s = {
|
|
2
|
+
public: {
|
|
3
|
+
Enums: {
|
|
4
|
+
menu_location: ["HEADER", "FOOTER", "SIDEBAR"],
|
|
5
|
+
page_status: ["draft", "published", "archived"],
|
|
6
|
+
revision_type: ["snapshot", "diff"],
|
|
7
|
+
user_role: ["ADMIN", "WRITER", "USER"]
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
s as Constants
|
|
13
|
+
};
|
package/package.json
CHANGED
package/server.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./lib/supabase/server.cjs.js"),i=require("./lib/supabase/ssg-client.cjs.js"),t=require("./lib/package-validation.cjs.js");exports.createClient=e.createClient;exports.getActiveLanguagesServerSide=e.getActiveLanguagesServerSide;exports.getProfileWithRoleServerSide=e.getProfileWithRoleServerSide;exports.getServiceRoleSupabaseClient=e.getServiceRoleSupabaseClient;exports.getSsgSupabaseClient=i.getSsgSupabaseClient;exports.verifyPackageOnline=t.verifyPackageOnline;
|
package/server.es.js
CHANGED
|
@@ -1,53 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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);
|
|
7
|
-
};
|
|
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
|
-
);
|
|
14
|
-
}
|
|
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);
|
|
45
|
-
}
|
|
1
|
+
import { createClient as t, getActiveLanguagesServerSide as i, getProfileWithRoleServerSide as a, getServiceRoleSupabaseClient as o } from "./lib/supabase/server.es.js";
|
|
2
|
+
import { getSsgSupabaseClient as S } from "./lib/supabase/ssg-client.es.js";
|
|
3
|
+
import { verifyPackageOnline as n } from "./lib/package-validation.es.js";
|
|
46
4
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
5
|
+
t as createClient,
|
|
6
|
+
i as getActiveLanguagesServerSide,
|
|
7
|
+
a as getProfileWithRoleServerSide,
|
|
8
|
+
o as getServiceRoleSupabaseClient,
|
|
9
|
+
S as getSsgSupabaseClient,
|
|
10
|
+
n as verifyPackageOnline
|
|
53
11
|
};
|