@nextblock-cms/db 0.0.3 → 0.0.4
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/package.json +1 -1
- package/server.cjs.js +1 -1
- package/server.es.js +19 -24
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 i=require("@supabase/ssr"),c=require("next/headers"),u=require("@supabase/supabase-js"),l="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(l);const a=()=>{const t=c.cookies(),s=process.env.NEXT_PUBLIC_SUPABASE_URL,r=process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;if(!s||!r)throw new Error("Missing Supabase environment variables");return i.createServerClient(s,r,{cookies:{async get(e){var n;return(n=(await t).get(e))==null?void 0:n.value},set(e,o,n){t.set({name:e,value:o,...n})},remove(e,o){t.set({name:e,value:"",...o})}}})};async function S(t){const s=a(),{data:r,error:e}=await s.from("profiles").select("id, full_name, avatar_url, role, updated_at, username, website").eq("id",t).single();return e||!r?(console.error("Error fetching profile (server-side):",e==null?void 0:e.message),null):r}async function d(){const t=a(),{data:s,error:r}=await t.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name",{ascending:!0});return r?(console.error("Error fetching languages (server-side):",r.message),[]):s||[]}const _=()=>{if(!process.env.NEXT_PUBLIC_SUPABASE_URL||!process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY)throw new Error("Supabase URL or Anon Key is missing for SSG client. Check .env.local");return u.createClient(process.env.NEXT_PUBLIC_SUPABASE_URL,process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY)};exports.createClient=a;exports.getActiveLanguagesServerSide=d;exports.getProfileWithRoleServerSide=S;exports.getSsgSupabaseClient=_;
|
package/server.es.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import { createServerClient as
|
|
2
|
-
import { cookies as
|
|
3
|
-
import { createClient as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
_();
|
|
12
|
-
const i = () => {
|
|
13
|
-
const o = l(), t = process.env.NEXT_PUBLIC_SUPABASE_URL, r = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
1
|
+
import { createServerClient as i } from "@supabase/ssr";
|
|
2
|
+
import { cookies as c } from "next/headers";
|
|
3
|
+
import { createClient as l } from "@supabase/supabase-js";
|
|
4
|
+
const u = "This module cannot be imported from a Client Component module. It should only be used from a Server Component.";
|
|
5
|
+
if (typeof window < "u")
|
|
6
|
+
throw new Error(u);
|
|
7
|
+
const a = () => {
|
|
8
|
+
const o = c(), t = process.env.NEXT_PUBLIC_SUPABASE_URL, r = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
|
14
9
|
if (!t || !r)
|
|
15
10
|
throw new Error("Missing Supabase environment variables");
|
|
16
|
-
return
|
|
11
|
+
return i(
|
|
17
12
|
t,
|
|
18
13
|
r,
|
|
19
14
|
{
|
|
@@ -32,25 +27,25 @@ const i = () => {
|
|
|
32
27
|
}
|
|
33
28
|
);
|
|
34
29
|
};
|
|
35
|
-
async function
|
|
36
|
-
const t =
|
|
30
|
+
async function m(o) {
|
|
31
|
+
const t = a(), { data: r, error: e } = await t.from("profiles").select("id, full_name, avatar_url, role, updated_at, username, website").eq("id", o).single();
|
|
37
32
|
return e || !r ? (console.error("Error fetching profile (server-side):", e == null ? void 0 : e.message), null) : r;
|
|
38
33
|
}
|
|
39
|
-
async function
|
|
40
|
-
const o =
|
|
34
|
+
async function p() {
|
|
35
|
+
const o = a(), { data: t, error: r } = await o.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name", { ascending: !0 });
|
|
41
36
|
return r ? (console.error("Error fetching languages (server-side):", r.message), []) : t || [];
|
|
42
37
|
}
|
|
43
|
-
const
|
|
38
|
+
const f = () => {
|
|
44
39
|
if (!process.env.NEXT_PUBLIC_SUPABASE_URL || !process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY)
|
|
45
40
|
throw new Error("Supabase URL or Anon Key is missing for SSG client. Check .env.local");
|
|
46
|
-
return
|
|
41
|
+
return l(
|
|
47
42
|
process.env.NEXT_PUBLIC_SUPABASE_URL,
|
|
48
43
|
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
|
|
49
44
|
);
|
|
50
45
|
};
|
|
51
46
|
export {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
a as createClient,
|
|
48
|
+
p as getActiveLanguagesServerSide,
|
|
49
|
+
m as getProfileWithRoleServerSide,
|
|
50
|
+
f as getSsgSupabaseClient
|
|
56
51
|
};
|