@nextblock-cms/db 0.0.4 → 0.0.5
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 +28 -31
- package/lib/supabase/client.d.ts +1 -1
- package/lib/supabase/server.d.ts +1 -1
- package/package.json +1 -1
- package/server.cjs.js +1 -1
- package/server.d.ts +2 -9
- package/server.es.js +31 -34
- package/ssg-client-CiaENGEv.js +1 -0
- package/ssg-client-DgUYZgPq.mjs +8 -0
package/index.cjs.js
CHANGED
|
@@ -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("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;
|
package/index.es.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { createBrowserClient as
|
|
2
|
-
import { NextResponse as
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
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
5
|
const e = process.env.NEXT_PUBLIC_SUPABASE_URL, r = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
6
6
|
if (!e || !r)
|
|
7
7
|
throw new Error(
|
|
8
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
9
|
);
|
|
10
|
-
return
|
|
10
|
+
return u(e, r);
|
|
11
11
|
};
|
|
12
|
-
async function
|
|
13
|
-
const { data:
|
|
14
|
-
return s || !
|
|
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;
|
|
15
15
|
}
|
|
16
|
-
async function
|
|
17
|
-
const e =
|
|
18
|
-
return
|
|
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 || [];
|
|
19
19
|
}
|
|
20
|
-
const
|
|
20
|
+
const f = async (e) => {
|
|
21
21
|
try {
|
|
22
|
-
let r =
|
|
22
|
+
let r = n.next({
|
|
23
23
|
request: {
|
|
24
24
|
headers: e.headers
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
27
|
+
const t = process.env.NEXT_PUBLIC_SUPABASE_URL, s = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
28
|
+
if (!t || !s)
|
|
29
29
|
throw new Error("Missing Supabase environment variables");
|
|
30
|
-
const i = await
|
|
31
|
-
|
|
30
|
+
const i = await _(
|
|
31
|
+
t,
|
|
32
32
|
s,
|
|
33
33
|
{
|
|
34
34
|
cookies: {
|
|
@@ -38,27 +38,24 @@ const B = async (e) => {
|
|
|
38
38
|
setAll(c) {
|
|
39
39
|
c.forEach(
|
|
40
40
|
({ name: a, value: o }) => e.cookies.set(a, o)
|
|
41
|
-
), r =
|
|
41
|
+
), r = n.next({
|
|
42
42
|
request: e
|
|
43
43
|
}), c.forEach(
|
|
44
|
-
({ name: a, value: o, options:
|
|
44
|
+
({ name: a, value: o, options: l }) => r.cookies.set(a, o, l)
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
).auth.getUser();
|
|
50
|
-
return e.nextUrl.pathname.startsWith("/protected") && i.error ?
|
|
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
51
|
} catch {
|
|
52
|
-
return
|
|
52
|
+
return n.next({
|
|
53
53
|
request: {
|
|
54
54
|
headers: e.headers
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
},
|
|
59
|
-
process.env.NEXT_PUBLIC_SUPABASE_URL,
|
|
60
|
-
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
|
|
61
|
-
), L = {
|
|
58
|
+
}, g = {
|
|
62
59
|
public: {
|
|
63
60
|
Enums: {
|
|
64
61
|
menu_location: ["HEADER", "FOOTER", "SIDEBAR"],
|
|
@@ -69,10 +66,10 @@ const B = async (e) => {
|
|
|
69
66
|
}
|
|
70
67
|
};
|
|
71
68
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
69
|
+
g as Constants,
|
|
70
|
+
p as createClient,
|
|
71
|
+
U as getActiveLanguagesClientSide,
|
|
72
|
+
S as getProfileWithRoleClientSide,
|
|
73
|
+
N as getSsgSupabaseClient,
|
|
74
|
+
f as updateSession
|
|
78
75
|
};
|
package/lib/supabase/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { SupabaseClient } from '@supabase/supabase-js';
|
|
|
2
2
|
import { Database } from './types';
|
|
3
3
|
type Profile = Database['public']['Tables']['profiles']['Row'];
|
|
4
4
|
type Language = Database['public']['Tables']['languages']['Row'];
|
|
5
|
-
export declare const createClient: () => SupabaseClient<any, "public", any>;
|
|
5
|
+
export declare const createClient: () => SupabaseClient<any, "public", "public", any, any>;
|
|
6
6
|
export declare function getProfileWithRoleClientSide(supabase: SupabaseClient, // Accept the client instance
|
|
7
7
|
userId: string): Promise<Profile | null>;
|
|
8
8
|
export declare function getActiveLanguagesClientSide(): Promise<Language[]>;
|
package/lib/supabase/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Database } from './types';
|
|
2
2
|
type Profile = Database['public']['Tables']['profiles']['Row'];
|
|
3
3
|
type Language = Database['public']['Tables']['languages']['Row'];
|
|
4
|
-
export declare const createClient: () => import('@supabase/supabase-js').SupabaseClient<any, "public", any>;
|
|
4
|
+
export declare const createClient: () => import('@supabase/supabase-js').SupabaseClient<any, "public", "public", any, any>;
|
|
5
5
|
export declare function getProfileWithRoleServerSide(userId: string): Promise<Profile | null>;
|
|
6
6
|
export declare function getActiveLanguagesServerSide(): Promise<Language[]>;
|
|
7
7
|
export {};
|
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 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 n=()=>{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:a,value:s,options:i}of e)s&&s.length>0?o.set({name:a,value:s,...i}):o.delete({name:a,...i})}catch{}}}})};async function g(r){const t=n(),{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 S(){const r=n(),{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=n;exports.getActiveLanguagesServerSide=S;exports.getProfileWithRoleServerSide=g;
|
package/server.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type Profile = Database['public']['Tables']['profiles']['Row'];
|
|
4
|
-
type Language = Database['public']['Tables']['languages']['Row'];
|
|
5
|
-
export declare const createClient: () => SupabaseClient<any, "public", any>;
|
|
6
|
-
export declare function getProfileWithRoleServerSide(userId: string): Promise<Profile | null>;
|
|
7
|
-
export declare function getActiveLanguagesServerSide(): Promise<Language[]>;
|
|
8
|
-
export declare const getSsgSupabaseClient: () => SupabaseClient;
|
|
9
|
-
export {};
|
|
1
|
+
export * from './lib/supabase/server';
|
|
2
|
+
export { getSsgSupabaseClient } from './lib/supabase/ssg-client';
|
package/server.es.js
CHANGED
|
@@ -1,51 +1,48 @@
|
|
|
1
|
-
import { createServerClient as
|
|
2
|
-
import { cookies as
|
|
3
|
-
import {
|
|
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
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
6
|
throw new Error(u);
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
7
|
+
const c = () => {
|
|
8
|
+
const r = process.env.NEXT_PUBLIC_SUPABASE_URL, o = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
9
|
+
if (!r || !o)
|
|
10
10
|
throw new Error("Missing Supabase environment variables");
|
|
11
|
-
return
|
|
12
|
-
t,
|
|
11
|
+
return l(
|
|
13
12
|
r,
|
|
13
|
+
o,
|
|
14
14
|
{
|
|
15
15
|
cookies: {
|
|
16
|
-
async
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
getAll: async () => {
|
|
17
|
+
try {
|
|
18
|
+
return (await i()).getAll();
|
|
19
|
+
} catch {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
22
|
},
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
setAll: async (e) => {
|
|
24
|
+
try {
|
|
25
|
+
const t = await i();
|
|
26
|
+
for (const { name: a, value: n, options: s } of e)
|
|
27
|
+
n && n.length > 0 ? t.set({ name: a, value: n, ...s }) : t.delete({ name: a, ...s });
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
);
|
|
29
34
|
};
|
|
30
|
-
async function
|
|
31
|
-
const
|
|
32
|
-
return
|
|
35
|
+
async function p(r) {
|
|
36
|
+
const o = c(), { data: e, error: t } = await o.from("profiles").select("id, full_name, avatar_url, role, updated_at, username, website").eq("id", r).single();
|
|
37
|
+
return t || !e ? (console.error("Error fetching profile (server-side):", t?.message), null) : e;
|
|
33
38
|
}
|
|
34
|
-
async function
|
|
35
|
-
const
|
|
36
|
-
return
|
|
39
|
+
async function m() {
|
|
40
|
+
const r = c(), { data: o, 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), []) : o || [];
|
|
37
42
|
}
|
|
38
|
-
const f = () => {
|
|
39
|
-
if (!process.env.NEXT_PUBLIC_SUPABASE_URL || !process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY)
|
|
40
|
-
throw new Error("Supabase URL or Anon Key is missing for SSG client. Check .env.local");
|
|
41
|
-
return l(
|
|
42
|
-
process.env.NEXT_PUBLIC_SUPABASE_URL,
|
|
43
|
-
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
43
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
c as createClient,
|
|
45
|
+
m as getActiveLanguagesServerSide,
|
|
46
|
+
p as getProfileWithRoleServerSide,
|
|
47
|
+
_ as getSsgSupabaseClient
|
|
51
48
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("@supabase/supabase-js"),s=()=>!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. Check .env.local"),{}):e.createClient(process.env.NEXT_PUBLIC_SUPABASE_URL,process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY);exports.getSsgSupabaseClient=s;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createClient as e } from "@supabase/supabase-js";
|
|
2
|
+
const n = () => !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. Check .env.local"), {}) : e(
|
|
3
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL,
|
|
4
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
|
|
5
|
+
);
|
|
6
|
+
export {
|
|
7
|
+
n as g
|
|
8
|
+
};
|