@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.
- package/lib/media-actions.cjs.js +1 -1
- package/lib/media-actions.es.js +26 -17
- package/lib/package-validation.cjs.js +1 -1
- package/lib/package-validation.es.js +53 -27
- package/lib/supabase/client.cjs.js +1 -1
- package/lib/supabase/client.es.js +17 -15
- package/lib/supabase/server.cjs.js +1 -1
- package/lib/supabase/server.es.js +36 -34
- package/lib/supabase/ssg-client.cjs.js +1 -1
- package/lib/supabase/ssg-client.es.js +5 -5
- package/lib/supabase/types.cjs.js +1 -1
- package/lib/supabase/types.es.js +4 -2
- package/package.json +1 -1
- package/server.cjs.js +1 -1
- package/server.es.js +26 -23
package/lib/media-actions.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 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;
|
package/lib/media-actions.es.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { revalidatePath as
|
|
3
|
-
import { encodedRedirect as
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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(
|
|
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, (
|
|
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:
|
|
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:
|
|
44
|
-
if (
|
|
45
|
-
return console.error("Error recording media upload:",
|
|
46
|
-
if (
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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:
|
|
8
|
-
return
|
|
9
|
-
} catch (
|
|
10
|
-
return console.error(`Error verifying package ${
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
if (!
|
|
5
|
-
throw new Error(
|
|
6
|
-
|
|
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
|
|
9
|
-
const { data:
|
|
10
|
-
return
|
|
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
|
|
14
|
-
return
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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"),
|
|
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
|
|
2
|
+
import { createClient as S } from "@supabase/supabase-js";
|
|
3
3
|
import { cookies as i } from "next/headers";
|
|
4
|
-
const
|
|
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(
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
32
|
-
const r = c(), { data:
|
|
33
|
-
return
|
|
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
|
|
36
|
-
const e = c(), { data: r, error:
|
|
37
|
-
return
|
|
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
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
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
|
|
2
|
-
const
|
|
3
|
-
const e = process.env.NEXT_PUBLIC_SUPABASE_URL || "https://dummy.supabase.co",
|
|
4
|
-
return (!
|
|
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
|
-
|
|
7
|
+
S as getSsgSupabaseClient
|
|
8
8
|
};
|
|
@@ -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={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;
|
package/lib/supabase/types.es.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
const
|
|
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
|
-
|
|
14
|
+
e as Constants
|
|
13
15
|
};
|
package/package.json
CHANGED
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"),
|
|
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
|
|
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 {
|
|
4
|
-
import { SECRET_ENVELOPE_ALGORITHM as
|
|
5
|
-
import { isSandboxEnvironment as
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
};
|