@nextblock-cms/db 0.0.1 → 0.0.2

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/server.es.js CHANGED
@@ -1,1161 +1,56 @@
1
- import { r as re, b as j, d as $, e as N, m as ie, f as V, g as Y, h as ne, n as se, j as oe, k as G, o as ue, l as le, a as de } from "./invariant-error-Df4RSFOM.mjs";
2
- import { getErrorMessage as I } from "@nextblock-monorepo/utils";
3
- var fe = {}, F;
4
- function pe() {
5
- if (F) return fe;
6
- throw F = 1, new Error(
1
+ import { createServerClient as c } from "@supabase/ssr";
2
+ import { cookies as l } from "next/headers";
3
+ import { createClient as u } from "@supabase/supabase-js";
4
+ var S = {}, a;
5
+ function _() {
6
+ if (a) return S;
7
+ throw a = 1, new Error(
7
8
  "This module cannot be imported from a Client Component module. It should only be used from a Server Component."
8
9
  );
9
10
  }
10
- pe();
11
- var M = {}, T = {}, U = {}, K;
12
- function he() {
13
- return K || (K = 1, function(y) {
14
- Object.defineProperty(y, "__esModule", {
15
- value: !0
16
- });
17
- function w(S, h) {
18
- for (var m in h) Object.defineProperty(S, m, {
19
- enumerable: !0,
20
- get: h[m]
21
- });
22
- }
23
- w(y, {
24
- MutableRequestCookiesAdapter: function() {
25
- return _;
26
- },
27
- ReadonlyRequestCookiesError: function() {
28
- return s;
29
- },
30
- RequestCookiesAdapter: function() {
31
- return i;
32
- },
33
- appendMutableCookies: function() {
34
- return E;
35
- },
36
- areCookiesMutableInCurrentPhase: function() {
37
- return x;
38
- },
39
- getModifiedCookieValues: function() {
40
- return c;
41
- },
42
- responseCookiesToRequestCookies: function() {
43
- return P;
44
- },
45
- wrapWithMutableAccessCheck: function() {
46
- return k;
47
- }
48
- });
49
- const d = re(), p = j(), g = $(), A = N();
50
- class s extends Error {
51
- constructor() {
52
- super("Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options");
53
- }
54
- static callable() {
55
- throw new s();
56
- }
57
- }
58
- class i {
59
- static seal(h) {
60
- return new Proxy(h, {
61
- get(m, b, R) {
62
- switch (b) {
63
- case "clear":
64
- case "delete":
65
- case "set":
66
- return s.callable;
67
- default:
68
- return p.ReflectAdapter.get(m, b, R);
69
- }
70
- }
71
- });
72
- }
73
- }
74
- const l = Symbol.for("next.mutated.cookies");
75
- function c(S) {
76
- const h = S[l];
77
- return !h || !Array.isArray(h) || h.length === 0 ? [] : h;
78
- }
79
- function E(S, h) {
80
- const m = c(h);
81
- if (m.length === 0)
82
- return !1;
83
- const b = new d.ResponseCookies(S), R = b.getAll();
84
- for (const o of m)
85
- b.set(o);
86
- for (const o of R)
87
- b.set(o);
88
- return !0;
89
- }
90
- class _ {
91
- static wrap(h, m) {
92
- const b = new d.ResponseCookies(new Headers());
93
- for (const a of h.getAll())
94
- b.set(a);
95
- let R = [];
96
- const o = /* @__PURE__ */ new Set(), e = () => {
97
- const a = g.workAsyncStorage.getStore();
98
- if (a && (a.pathWasRevalidated = !0), R = b.getAll().filter((t) => o.has(t.name)), m) {
99
- const t = [];
100
- for (const n of R) {
101
- const u = new d.ResponseCookies(new Headers());
102
- u.set(n), t.push(u.toString());
103
- }
104
- m(t);
105
- }
106
- }, r = new Proxy(b, {
107
- get(a, f, t) {
108
- switch (f) {
109
- // A special symbol to get the modified cookie values
110
- case l:
111
- return R;
112
- // TODO: Throw error if trying to set a cookie after the response
113
- // headers have been set.
114
- case "delete":
115
- return function(...n) {
116
- o.add(typeof n[0] == "string" ? n[0] : n[0].name);
117
- try {
118
- return a.delete(...n), r;
119
- } finally {
120
- e();
121
- }
122
- };
123
- case "set":
124
- return function(...n) {
125
- o.add(typeof n[0] == "string" ? n[0] : n[0].name);
126
- try {
127
- return a.set(...n), r;
128
- } finally {
129
- e();
130
- }
131
- };
132
- default:
133
- return p.ReflectAdapter.get(a, f, t);
134
- }
135
- }
136
- });
137
- return r;
138
- }
139
- }
140
- function k(S) {
141
- const h = new Proxy(S, {
142
- get(m, b, R) {
143
- switch (b) {
144
- case "delete":
145
- return function(...o) {
146
- return C("cookies().delete"), m.delete(...o), h;
147
- };
148
- case "set":
149
- return function(...o) {
150
- return C("cookies().set"), m.set(...o), h;
151
- };
152
- default:
153
- return p.ReflectAdapter.get(m, b, R);
154
- }
155
- }
156
- });
157
- return h;
158
- }
159
- function x(S) {
160
- return S.phase === "action";
161
- }
162
- function C(S) {
163
- const h = (0, A.getExpectedRequestStore)(S);
164
- if (!x(h))
165
- throw new s();
166
- }
167
- function P(S) {
168
- const h = new d.RequestCookies(new Headers());
169
- for (const m of S.getAll())
170
- h.set(m);
171
- return h;
172
- }
173
- }(U)), U;
174
- }
175
- var L = {}, J;
176
- function z() {
177
- return J || (J = 1, function(y) {
178
- Object.defineProperty(y, "__esModule", {
179
- value: !0
180
- }), Object.defineProperty(y, "createDedupedByCallsiteServerErrorLoggerDev", {
181
- enumerable: !0,
182
- get: function() {
183
- return l;
184
- }
185
- });
186
- const w = /* @__PURE__ */ p(ie());
187
- function d(c) {
188
- if (typeof WeakMap != "function") return null;
189
- var E = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new WeakMap();
190
- return (d = function(k) {
191
- return k ? _ : E;
192
- })(c);
193
- }
194
- function p(c, E) {
195
- if (c && c.__esModule)
196
- return c;
197
- if (c === null || typeof c != "object" && typeof c != "function")
198
- return {
199
- default: c
200
- };
201
- var _ = d(E);
202
- if (_ && _.has(c))
203
- return _.get(c);
204
- var k = {
205
- __proto__: null
206
- }, x = Object.defineProperty && Object.getOwnPropertyDescriptor;
207
- for (var C in c)
208
- if (C !== "default" && Object.prototype.hasOwnProperty.call(c, C)) {
209
- var P = x ? Object.getOwnPropertyDescriptor(c, C) : null;
210
- P && (P.get || P.set) ? Object.defineProperty(k, C, P) : k[C] = c[C];
211
- }
212
- return k.default = c, _ && _.set(c, k), k;
213
- }
214
- const g = {
215
- current: null
216
- }, A = typeof w.cache == "function" ? w.cache : (c) => c, s = process.env.__NEXT_DYNAMIC_IO ? console.error : console.warn, i = A(
217
- // eslint-disable-next-line @typescript-eslint/no-unused-vars -- cache key
218
- (c) => {
219
- try {
220
- s(g.current);
221
- } finally {
222
- g.current = null;
223
- }
224
- }
225
- );
226
- function l(c) {
227
- return function(..._) {
228
- const k = c(..._);
229
- if (process.env.NODE_ENV !== "production") {
230
- var x;
231
- const C = (x = new Error().stack) == null ? void 0 : x.split(`
232
- `);
233
- if (C === void 0 || C.length < 4)
234
- s(k);
235
- else {
236
- const P = C[4];
237
- g.current = k, i(P);
238
- }
239
- } else
240
- s(k);
241
- };
242
- }
243
- }(L)), L;
244
- }
245
- var Q;
246
- function be() {
247
- return Q || (Q = 1, function(y) {
248
- Object.defineProperty(y, "__esModule", {
249
- value: !0
250
- }), Object.defineProperty(y, "cookies", {
251
- enumerable: !0,
252
- get: function() {
253
- return x;
254
- }
255
- });
256
- const w = he(), d = re(), p = $(), g = N(), A = V(), s = Y(), i = ne(), l = z(), c = se(), E = oe(), _ = G(), k = j();
257
- function x() {
258
- const t = "cookies", n = p.workAsyncStorage.getStore(), u = g.workUnitAsyncStorage.getStore();
259
- if (n) {
260
- if (u && u.phase === "after" && !(0, E.isRequestAPICallableInsideAfter)())
261
- throw Object.defineProperty(new Error(
262
- // TODO(after): clarify that this only applies to pages?
263
- `Route ${n.route} used "cookies" inside "after(...)". This is not supported. If you need this data inside an "after" callback, use "cookies" outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after`
264
- ), "__NEXT_ERROR_CODE", {
265
- value: "E88",
266
- enumerable: !1,
267
- configurable: !0
268
- });
269
- if (n.forceStatic) {
270
- const v = C();
271
- return h(v);
272
- }
273
- if (u) {
274
- if (u.type === "cache")
275
- throw Object.defineProperty(new Error(`Route ${n.route} used "cookies" inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "cookies" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
276
- value: "E398",
277
- enumerable: !1,
278
- configurable: !0
279
- });
280
- if (u.type === "unstable-cache")
281
- throw Object.defineProperty(new Error(`Route ${n.route} used "cookies" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "cookies" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`), "__NEXT_ERROR_CODE", {
282
- value: "E157",
283
- enumerable: !1,
284
- configurable: !0
285
- });
286
- }
287
- if (n.dynamicShouldError)
288
- throw Object.defineProperty(new s.StaticGenBailoutError(`Route ${n.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`cookies\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
289
- value: "E549",
290
- enumerable: !1,
291
- configurable: !0
292
- });
293
- if (u)
294
- switch (u.type) {
295
- case "prerender":
296
- return S(u);
297
- case "prerender-client":
298
- const v = "`cookies`";
299
- throw Object.defineProperty(new _.InvariantError(`${v} must not be used within a client component. Next.js should be preventing ${v} from being included in client components statically, but did not in this case.`), "__NEXT_ERROR_CODE", {
300
- value: "E693",
301
- enumerable: !1,
302
- configurable: !0
303
- });
304
- case "prerender-ppr":
305
- (0, A.postponeWithTracking)(n.route, t, u.dynamicTracking);
306
- break;
307
- case "prerender-legacy":
308
- (0, A.throwToInterruptStaticGeneration)(t, n, u);
309
- break;
310
- }
311
- (0, A.trackDynamicDataInDynamicRender)(n, u);
312
- }
313
- const D = (0, g.getExpectedRequestStore)(t);
314
- let O;
315
- return (0, w.areCookiesMutableInCurrentPhase)(D) ? O = D.userspaceMutableCookies : O = D.cookies, process.env.NODE_ENV === "development" && !(n != null && n.isPrefetchRequest) ? process.env.__NEXT_DYNAMIC_IO ? b(O, n == null ? void 0 : n.route) : m(O, n == null ? void 0 : n.route) : h(O);
316
- }
317
- function C() {
318
- return w.RequestCookiesAdapter.seal(new d.RequestCookies(new Headers({})));
319
- }
320
- const P = /* @__PURE__ */ new WeakMap();
321
- function S(t) {
322
- const n = P.get(t);
323
- if (n)
324
- return n;
325
- const u = (0, i.makeHangingPromise)(t.renderSignal, "`cookies()`");
326
- return P.set(t, u), u;
327
- }
328
- function h(t) {
329
- const n = P.get(t);
330
- if (n)
331
- return n;
332
- const u = Promise.resolve(t);
333
- return P.set(t, u), Object.defineProperties(u, {
334
- [Symbol.iterator]: {
335
- value: t[Symbol.iterator] ? t[Symbol.iterator].bind(t) : (
336
- // We should remove this and unify our cookies types. We could just let this continue to throw lazily
337
- // but that's already a hard thing to debug so we may as well implement it consistently. The biggest problem with
338
- // implementing this in this way is the underlying cookie type is a ResponseCookie and not a RequestCookie and so it
339
- // has extra properties not available on RequestCookie instances.
340
- a.bind(t)
341
- )
342
- },
343
- size: {
344
- get() {
345
- return t.size;
346
- }
347
- },
348
- get: {
349
- value: t.get.bind(t)
350
- },
351
- getAll: {
352
- value: t.getAll.bind(t)
353
- },
354
- has: {
355
- value: t.has.bind(t)
356
- },
357
- set: {
358
- value: t.set.bind(t)
359
- },
360
- delete: {
361
- value: t.delete.bind(t)
362
- },
363
- clear: {
364
- value: (
365
- // @ts-expect-error clear is defined in RequestCookies implementation but not in the type
366
- typeof t.clear == "function" ? t.clear.bind(t) : (
367
- // We should remove this and unify our cookies types. We could just let this continue to throw lazily
368
- // but that's already a hard thing to debug so we may as well implement it consistently. The biggest problem with
369
- // implementing this in this way is the underlying cookie type is a ResponseCookie and not a RequestCookie and so it
370
- // has extra properties not available on RequestCookie instances.
371
- f.bind(t, u)
372
- )
373
- )
374
- },
375
- toString: {
376
- value: t.toString.bind(t)
377
- }
378
- }), u;
379
- }
380
- function m(t, n) {
381
- const u = P.get(t);
382
- if (u)
383
- return u;
384
- const D = new Promise((O) => (0, c.scheduleImmediate)(() => O(t)));
385
- return P.set(t, D), Object.defineProperties(D, {
386
- [Symbol.iterator]: {
387
- value: function() {
388
- return o(n, "`...cookies()` or similar iteration"), t[Symbol.iterator] ? t[Symbol.iterator].apply(t, arguments) : (
389
- // We should remove this and unify our cookies types. We could just let this continue to throw lazily
390
- // but that's already a hard thing to debug so we may as well implement it consistently. The biggest problem with
391
- // implementing this in this way is the underlying cookie type is a ResponseCookie and not a RequestCookie and so it
392
- // has extra properties not available on RequestCookie instances.
393
- a.call(t)
394
- );
395
- },
396
- writable: !1
397
- },
398
- size: {
399
- get() {
400
- return o(n, "`cookies().size`"), t.size;
401
- }
402
- },
403
- get: {
404
- value: function() {
405
- let v;
406
- return arguments.length === 0 ? v = "`cookies().get()`" : v = `\`cookies().get(${R(arguments[0])})\``, o(n, v), t.get.apply(t, arguments);
407
- },
408
- writable: !1
409
- },
410
- getAll: {
411
- value: function() {
412
- let v;
413
- return arguments.length === 0 ? v = "`cookies().getAll()`" : v = `\`cookies().getAll(${R(arguments[0])})\``, o(n, v), t.getAll.apply(t, arguments);
414
- },
415
- writable: !1
416
- },
417
- has: {
418
- value: function() {
419
- let v;
420
- return arguments.length === 0 ? v = "`cookies().has()`" : v = `\`cookies().has(${R(arguments[0])})\``, o(n, v), t.has.apply(t, arguments);
421
- },
422
- writable: !1
423
- },
424
- set: {
425
- value: function() {
426
- let v;
427
- if (arguments.length === 0)
428
- v = "`cookies().set()`";
429
- else {
430
- const q = arguments[0];
431
- q ? v = `\`cookies().set(${R(q)}, ...)\`` : v = "`cookies().set(...)`";
432
- }
433
- return o(n, v), t.set.apply(t, arguments);
434
- },
435
- writable: !1
436
- },
437
- delete: {
438
- value: function() {
439
- let O;
440
- return arguments.length === 0 ? O = "`cookies().delete()`" : arguments.length === 1 ? O = `\`cookies().delete(${R(arguments[0])})\`` : O = `\`cookies().delete(${R(arguments[0])}, ...)\``, o(n, O), t.delete.apply(t, arguments);
441
- },
442
- writable: !1
443
- },
444
- clear: {
445
- value: function() {
446
- return o(n, "`cookies().clear()`"), typeof t.clear == "function" ? t.clear.apply(t, arguments) : (
447
- // We should remove this and unify our cookies types. We could just let this continue to throw lazily
448
- // but that's already a hard thing to debug so we may as well implement it consistently. The biggest problem with
449
- // implementing this in this way is the underlying cookie type is a ResponseCookie and not a RequestCookie and so it
450
- // has extra properties not available on RequestCookie instances.
451
- f.call(t, D)
452
- );
453
- },
454
- writable: !1
455
- },
456
- toString: {
457
- value: function() {
458
- return o(n, "`cookies().toString()` or implicit casting"), t.toString.apply(t, arguments);
459
- },
460
- writable: !1
461
- }
462
- }), D;
463
- }
464
- function b(t, n) {
465
- const u = P.get(t);
466
- if (u)
467
- return u;
468
- const D = new Promise((v) => (0, c.scheduleImmediate)(() => v(t))), O = new Proxy(D, {
469
- get(v, q, ce) {
470
- switch (q) {
471
- case Symbol.iterator: {
472
- e(n, "`...cookies()` or similar iteration");
473
- break;
474
- }
475
- case "size":
476
- case "get":
477
- case "getAll":
478
- case "has":
479
- case "set":
480
- case "delete":
481
- case "clear":
482
- case "toString": {
483
- e(n, `\`cookies().${q}\``);
484
- break;
485
- }
486
- }
487
- return k.ReflectAdapter.get(v, q, ce);
488
- }
489
- });
490
- return P.set(t, O), O;
491
- }
492
- function R(t) {
493
- return typeof t == "object" && t !== null && typeof t.name == "string" ? `'${t.name}'` : typeof t == "string" ? `'${t}'` : "...";
494
- }
495
- function o(t, n) {
496
- const u = g.workUnitAsyncStorage.getStore();
497
- if (u && u.type === "request" && u.prerenderPhase === !0) {
498
- const D = u;
499
- (0, A.trackSynchronousRequestDataAccessInDev)(D);
500
- }
501
- e(t, n);
502
- }
503
- const e = (0, l.createDedupedByCallsiteServerErrorLoggerDev)(r);
504
- function r(t, n) {
505
- const u = t ? `Route "${t}" ` : "This route ";
506
- return Object.defineProperty(new Error(`${u}used ${n}. \`cookies()\` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis`), "__NEXT_ERROR_CODE", {
507
- value: "E223",
508
- enumerable: !1,
509
- configurable: !0
510
- });
511
- }
512
- function a() {
513
- return this.getAll().map((t) => [
514
- t.name,
515
- t
516
- ]).values();
517
- }
518
- function f(t) {
519
- for (const n of this.getAll())
520
- this.delete(n.name);
521
- return t;
522
- }
523
- }(T)), T;
524
- }
525
- var X = {}, W = {}, Z;
526
- function me() {
527
- return Z || (Z = 1, function(y) {
528
- Object.defineProperty(y, "__esModule", {
529
- value: !0
530
- });
531
- function w(A, s) {
532
- for (var i in s) Object.defineProperty(A, i, {
533
- enumerable: !0,
534
- get: s[i]
535
- });
536
- }
537
- w(y, {
538
- HeadersAdapter: function() {
539
- return g;
540
- },
541
- ReadonlyHeadersError: function() {
542
- return p;
543
- }
544
- });
545
- const d = j();
546
- class p extends Error {
547
- constructor() {
548
- super("Headers cannot be modified. Read more: https://nextjs.org/docs/app/api-reference/functions/headers");
549
- }
550
- static callable() {
551
- throw new p();
552
- }
553
- }
554
- class g extends Headers {
555
- constructor(s) {
556
- super(), this.headers = new Proxy(s, {
557
- get(i, l, c) {
558
- if (typeof l == "symbol")
559
- return d.ReflectAdapter.get(i, l, c);
560
- const E = l.toLowerCase(), _ = Object.keys(s).find((k) => k.toLowerCase() === E);
561
- if (!(typeof _ > "u"))
562
- return d.ReflectAdapter.get(i, _, c);
563
- },
564
- set(i, l, c, E) {
565
- if (typeof l == "symbol")
566
- return d.ReflectAdapter.set(i, l, c, E);
567
- const _ = l.toLowerCase(), k = Object.keys(s).find((x) => x.toLowerCase() === _);
568
- return d.ReflectAdapter.set(i, k ?? l, c, E);
569
- },
570
- has(i, l) {
571
- if (typeof l == "symbol") return d.ReflectAdapter.has(i, l);
572
- const c = l.toLowerCase(), E = Object.keys(s).find((_) => _.toLowerCase() === c);
573
- return typeof E > "u" ? !1 : d.ReflectAdapter.has(i, E);
574
- },
575
- deleteProperty(i, l) {
576
- if (typeof l == "symbol") return d.ReflectAdapter.deleteProperty(i, l);
577
- const c = l.toLowerCase(), E = Object.keys(s).find((_) => _.toLowerCase() === c);
578
- return typeof E > "u" ? !0 : d.ReflectAdapter.deleteProperty(i, E);
579
- }
580
- });
581
- }
582
- /**
583
- * Seals a Headers instance to prevent modification by throwing an error when
584
- * any mutating method is called.
585
- */
586
- static seal(s) {
587
- return new Proxy(s, {
588
- get(i, l, c) {
589
- switch (l) {
590
- case "append":
591
- case "delete":
592
- case "set":
593
- return p.callable;
594
- default:
595
- return d.ReflectAdapter.get(i, l, c);
596
- }
597
- }
598
- });
599
- }
600
- /**
601
- * Merges a header value into a string. This stores multiple values as an
602
- * array, so we need to merge them into a string.
603
- *
604
- * @param value a header value
605
- * @returns a merged header value (a string)
606
- */
607
- merge(s) {
608
- return Array.isArray(s) ? s.join(", ") : s;
609
- }
610
- /**
611
- * Creates a Headers instance from a plain object or a Headers instance.
612
- *
613
- * @param headers a plain object or a Headers instance
614
- * @returns a headers instance
615
- */
616
- static from(s) {
617
- return s instanceof Headers ? s : new g(s);
618
- }
619
- append(s, i) {
620
- const l = this.headers[s];
621
- typeof l == "string" ? this.headers[s] = [
622
- l,
623
- i
624
- ] : Array.isArray(l) ? l.push(i) : this.headers[s] = i;
625
- }
626
- delete(s) {
627
- delete this.headers[s];
628
- }
629
- get(s) {
630
- const i = this.headers[s];
631
- return typeof i < "u" ? this.merge(i) : null;
632
- }
633
- has(s) {
634
- return typeof this.headers[s] < "u";
635
- }
636
- set(s, i) {
637
- this.headers[s] = i;
638
- }
639
- forEach(s, i) {
640
- for (const [l, c] of this.entries())
641
- s.call(i, c, l, this);
642
- }
643
- *entries() {
644
- for (const s of Object.keys(this.headers)) {
645
- const i = s.toLowerCase(), l = this.get(i);
646
- yield [
647
- i,
648
- l
649
- ];
650
- }
651
- }
652
- *keys() {
653
- for (const s of Object.keys(this.headers))
654
- yield s.toLowerCase();
655
- }
656
- *values() {
657
- for (const s of Object.keys(this.headers))
658
- yield this.get(s);
659
- }
660
- [Symbol.iterator]() {
661
- return this.entries();
662
- }
663
- }
664
- }(W)), W;
665
- }
666
- var H;
667
- function ge() {
668
- return H || (H = 1, function(y) {
669
- Object.defineProperty(y, "__esModule", {
670
- value: !0
671
- }), Object.defineProperty(y, "headers", {
672
- enumerable: !0,
673
- get: function() {
674
- return k;
675
- }
676
- });
677
- const w = me(), d = $(), p = N(), g = V(), A = Y(), s = ne(), i = z(), l = se(), c = oe(), E = G(), _ = j();
678
- function k() {
679
- const e = d.workAsyncStorage.getStore(), r = p.workUnitAsyncStorage.getStore();
680
- if (e) {
681
- if (r && r.phase === "after" && !(0, c.isRequestAPICallableInsideAfter)())
682
- throw Object.defineProperty(new Error(`Route ${e.route} used "headers" inside "after(...)". This is not supported. If you need this data inside an "after" callback, use "headers" outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/after`), "__NEXT_ERROR_CODE", {
683
- value: "E367",
684
- enumerable: !1,
685
- configurable: !0
686
- });
687
- if (e.forceStatic) {
688
- const f = w.HeadersAdapter.seal(new Headers({}));
689
- return P(f);
690
- }
691
- if (r) {
692
- if (r.type === "cache")
693
- throw Object.defineProperty(new Error(`Route ${e.route} used "headers" inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "headers" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
694
- value: "E304",
695
- enumerable: !1,
696
- configurable: !0
697
- });
698
- if (r.type === "unstable-cache")
699
- throw Object.defineProperty(new Error(`Route ${e.route} used "headers" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "headers" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`), "__NEXT_ERROR_CODE", {
700
- value: "E127",
701
- enumerable: !1,
702
- configurable: !0
703
- });
704
- }
705
- if (e.dynamicShouldError)
706
- throw Object.defineProperty(new A.StaticGenBailoutError(`Route ${e.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`headers\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
707
- value: "E525",
708
- enumerable: !1,
709
- configurable: !0
710
- });
711
- if (r)
712
- switch (r.type) {
713
- case "prerender":
714
- return C(r);
715
- case "prerender-client":
716
- const f = "`headers`";
717
- throw Object.defineProperty(new E.InvariantError(`${f} must not be used within a client component. Next.js should be preventing ${f} from being included in client components statically, but did not in this case.`), "__NEXT_ERROR_CODE", {
718
- value: "E693",
719
- enumerable: !1,
720
- configurable: !0
721
- });
722
- case "prerender-ppr":
723
- (0, g.postponeWithTracking)(e.route, "headers", r.dynamicTracking);
724
- break;
725
- case "prerender-legacy":
726
- (0, g.throwToInterruptStaticGeneration)("headers", e, r);
727
- break;
728
- }
729
- (0, g.trackDynamicDataInDynamicRender)(e, r);
730
- }
731
- const a = (0, p.getExpectedRequestStore)("headers");
732
- return process.env.NODE_ENV === "development" && !(e != null && e.isPrefetchRequest) ? process.env.__NEXT_DYNAMIC_IO ? h(a.headers, e == null ? void 0 : e.route) : S(a.headers, e == null ? void 0 : e.route) : P(a.headers);
733
- }
734
- const x = /* @__PURE__ */ new WeakMap();
735
- function C(e) {
736
- const r = x.get(e);
737
- if (r)
738
- return r;
739
- const a = (0, s.makeHangingPromise)(e.renderSignal, "`headers()`");
740
- return x.set(e, a), a;
741
- }
742
- function P(e) {
743
- const r = x.get(e);
744
- if (r)
745
- return r;
746
- const a = Promise.resolve(e);
747
- return x.set(e, a), Object.defineProperties(a, {
748
- append: {
749
- value: e.append.bind(e)
750
- },
751
- delete: {
752
- value: e.delete.bind(e)
753
- },
754
- get: {
755
- value: e.get.bind(e)
756
- },
757
- has: {
758
- value: e.has.bind(e)
759
- },
760
- set: {
761
- value: e.set.bind(e)
762
- },
763
- getSetCookie: {
764
- value: e.getSetCookie.bind(e)
765
- },
766
- forEach: {
767
- value: e.forEach.bind(e)
768
- },
769
- keys: {
770
- value: e.keys.bind(e)
771
- },
772
- values: {
773
- value: e.values.bind(e)
774
- },
775
- entries: {
776
- value: e.entries.bind(e)
777
- },
778
- [Symbol.iterator]: {
779
- value: e[Symbol.iterator].bind(e)
780
- }
781
- }), a;
782
- }
783
- function S(e, r) {
784
- const a = x.get(e);
785
- if (a)
786
- return a;
787
- const f = new Promise((t) => (0, l.scheduleImmediate)(() => t(e)));
788
- return x.set(e, f), Object.defineProperties(f, {
789
- append: {
790
- value: function() {
791
- const n = `\`headers().append(${m(arguments[0])}, ...)\``;
792
- return b(r, n), e.append.apply(e, arguments);
793
- }
794
- },
795
- delete: {
796
- value: function() {
797
- const n = `\`headers().delete(${m(arguments[0])})\``;
798
- return b(r, n), e.delete.apply(e, arguments);
799
- }
800
- },
801
- get: {
802
- value: function() {
803
- const n = `\`headers().get(${m(arguments[0])})\``;
804
- return b(r, n), e.get.apply(e, arguments);
805
- }
806
- },
807
- has: {
808
- value: function() {
809
- const n = `\`headers().has(${m(arguments[0])})\``;
810
- return b(r, n), e.has.apply(e, arguments);
811
- }
812
- },
813
- set: {
814
- value: function() {
815
- const n = `\`headers().set(${m(arguments[0])}, ...)\``;
816
- return b(r, n), e.set.apply(e, arguments);
817
- }
818
- },
819
- getSetCookie: {
820
- value: function() {
821
- return b(r, "`headers().getSetCookie()`"), e.getSetCookie.apply(e, arguments);
822
- }
823
- },
824
- forEach: {
825
- value: function() {
826
- return b(r, "`headers().forEach(...)`"), e.forEach.apply(e, arguments);
827
- }
828
- },
829
- keys: {
830
- value: function() {
831
- return b(r, "`headers().keys()`"), e.keys.apply(e, arguments);
832
- }
833
- },
834
- values: {
835
- value: function() {
836
- return b(r, "`headers().values()`"), e.values.apply(e, arguments);
837
- }
838
- },
839
- entries: {
840
- value: function() {
841
- return b(r, "`headers().entries()`"), e.entries.apply(e, arguments);
842
- }
843
- },
844
- [Symbol.iterator]: {
845
- value: function() {
846
- return b(r, "`...headers()` or similar iteration"), e[Symbol.iterator].apply(e, arguments);
847
- }
848
- }
849
- }), f;
850
- }
851
- function h(e, r) {
852
- const a = x.get(e);
853
- if (a)
854
- return a;
855
- const f = new Promise((n) => (0, l.scheduleImmediate)(() => n(e))), t = new Proxy(f, {
856
- get(n, u, D) {
857
- switch (u) {
858
- case Symbol.iterator: {
859
- R(r, "`...headers()` or similar iteration");
860
- break;
861
- }
862
- case "append":
863
- case "delete":
864
- case "get":
865
- case "has":
866
- case "set":
867
- case "getSetCookie":
868
- case "forEach":
869
- case "keys":
870
- case "values":
871
- case "entries": {
872
- R(r, `\`headers().${u}\``);
873
- break;
874
- }
875
- }
876
- return _.ReflectAdapter.get(n, u, D);
877
- }
878
- });
879
- return x.set(e, t), t;
880
- }
881
- function m(e) {
882
- return typeof e == "string" ? `'${e}'` : "...";
883
- }
884
- function b(e, r) {
885
- const a = p.workUnitAsyncStorage.getStore();
886
- if (a && a.type === "request" && a.prerenderPhase === !0) {
887
- const f = a;
888
- (0, g.trackSynchronousRequestDataAccessInDev)(f);
889
- }
890
- R(e, r);
891
- }
892
- const R = (0, i.createDedupedByCallsiteServerErrorLoggerDev)(o);
893
- function o(e, r) {
894
- const a = e ? `Route "${e}" ` : "This route ";
895
- return Object.defineProperty(new Error(`${a}used ${r}. \`headers()\` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis`), "__NEXT_ERROR_CODE", {
896
- value: "E277",
897
- enumerable: !1,
898
- configurable: !0
899
- });
900
- }
901
- }(X)), X;
902
- }
903
- var B = {}, ee;
904
- function ve() {
905
- return ee || (ee = 1, function(y) {
906
- Object.defineProperty(y, "__esModule", {
907
- value: !0
908
- }), Object.defineProperty(y, "draftMode", {
909
- enumerable: !0,
910
- get: function() {
911
- return c;
912
- }
913
- });
914
- const w = N(), d = $(), p = V(), g = z(), A = Y(), s = ue(), i = G(), l = j();
915
- function c() {
916
- const o = "draftMode", e = d.workAsyncStorage.getStore(), r = w.workUnitAsyncStorage.getStore();
917
- switch ((!e || !r) && (0, w.throwForMissingRequestStore)(o), r.type) {
918
- case "request":
919
- return E(r.draftMode, e);
920
- case "cache":
921
- case "unstable-cache":
922
- const a = (0, w.getDraftModeProviderForCacheScope)(e, r);
923
- if (a)
924
- return E(a, e);
925
- // Otherwise, we fall through to providing an empty draft mode.
926
- // eslint-disable-next-line no-fallthrough
927
- case "prerender":
928
- case "prerender-client":
929
- case "prerender-ppr":
930
- case "prerender-legacy":
931
- return E(null, e);
932
- default:
933
- return r;
934
- }
935
- }
936
- function E(o, e) {
937
- const r = o ?? _, a = k.get(r);
938
- if (a)
939
- return a;
940
- let f;
941
- if (process.env.NODE_ENV === "development" && !(e != null && e.isPrefetchRequest)) {
942
- const t = e == null ? void 0 : e.route;
943
- if (process.env.__NEXT_DYNAMIC_IO)
944
- return P(o, t);
945
- f = C(o, t);
946
- } else {
947
- if (process.env.__NEXT_DYNAMIC_IO)
948
- return Promise.resolve(new S(o));
949
- f = x(o);
950
- }
951
- return k.set(r, f), f;
952
- }
953
- const _ = {}, k = /* @__PURE__ */ new WeakMap();
954
- function x(o) {
955
- const e = new S(o), r = Promise.resolve(e);
956
- return Object.defineProperty(r, "isEnabled", {
957
- get() {
958
- return e.isEnabled;
959
- },
960
- enumerable: !0,
961
- configurable: !0
962
- }), r.enable = e.enable.bind(e), r.disable = e.disable.bind(e), r;
963
- }
964
- function C(o, e) {
965
- const r = new S(o), a = Promise.resolve(r);
966
- return Object.defineProperty(a, "isEnabled", {
967
- get() {
968
- return h(e, "`draftMode().isEnabled`"), r.isEnabled;
969
- },
970
- enumerable: !0,
971
- configurable: !0
972
- }), Object.defineProperty(a, "enable", {
973
- value: function() {
974
- return h(e, "`draftMode().enable()`"), r.enable.apply(r, arguments);
975
- }
976
- }), Object.defineProperty(a, "disable", {
977
- value: function() {
978
- return h(e, "`draftMode().disable()`"), r.disable.apply(r, arguments);
979
- }
980
- }), a;
981
- }
982
- function P(o, e) {
983
- const r = new S(o), a = Promise.resolve(r);
984
- return new Proxy(a, {
985
- get(t, n, u) {
986
- switch (n) {
987
- case "isEnabled":
988
- m(e, `\`draftMode().${n}\``);
989
- break;
990
- case "enable":
991
- case "disable": {
992
- m(e, `\`draftMode().${n}()\``);
993
- break;
994
- }
995
- }
996
- return l.ReflectAdapter.get(t, n, u);
997
- }
998
- });
999
- }
1000
- class S {
1001
- constructor(e) {
1002
- this._provider = e;
1003
- }
1004
- get isEnabled() {
1005
- return this._provider !== null ? this._provider.isEnabled : !1;
1006
- }
1007
- enable() {
1008
- R("draftMode().enable()"), this._provider !== null && this._provider.enable();
1009
- }
1010
- disable() {
1011
- R("draftMode().disable()"), this._provider !== null && this._provider.disable();
1012
- }
1013
- }
1014
- function h(o, e) {
1015
- const r = w.workUnitAsyncStorage.getStore();
1016
- if (r && r.type === "request" && r.prerenderPhase === !0) {
1017
- const a = r;
1018
- (0, p.trackSynchronousRequestDataAccessInDev)(a);
1019
- }
1020
- m(o, e);
1021
- }
1022
- const m = (0, g.createDedupedByCallsiteServerErrorLoggerDev)(b);
1023
- function b(o, e) {
1024
- const r = o ? `Route "${o}" ` : "This route ";
1025
- return Object.defineProperty(new Error(`${r}used ${e}. \`draftMode()\` should be awaited before using its value. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis`), "__NEXT_ERROR_CODE", {
1026
- value: "E377",
1027
- enumerable: !1,
1028
- configurable: !0
1029
- });
1030
- }
1031
- function R(o) {
1032
- const e = d.workAsyncStorage.getStore(), r = w.workUnitAsyncStorage.getStore();
1033
- if (e) {
1034
- if (r) {
1035
- if (r.type === "cache")
1036
- throw Object.defineProperty(new Error(`Route ${e.route} used "${o}" inside "use cache". The enabled status of draftMode can be read in caches but you must not enable or disable draftMode inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache`), "__NEXT_ERROR_CODE", {
1037
- value: "E246",
1038
- enumerable: !1,
1039
- configurable: !0
1040
- });
1041
- if (r.type === "unstable-cache")
1042
- throw Object.defineProperty(new Error(`Route ${e.route} used "${o}" inside a function cached with "unstable_cache(...)". The enabled status of draftMode can be read in caches but you must not enable or disable draftMode inside a cache. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`), "__NEXT_ERROR_CODE", {
1043
- value: "E259",
1044
- enumerable: !1,
1045
- configurable: !0
1046
- });
1047
- if (r.phase === "after")
1048
- throw Object.defineProperty(new Error(`Route ${e.route} used "${o}" inside \`after\`. The enabled status of draftMode can be read inside \`after\` but you cannot enable or disable draftMode. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`), "__NEXT_ERROR_CODE", {
1049
- value: "E348",
1050
- enumerable: !1,
1051
- configurable: !0
1052
- });
1053
- }
1054
- if (e.dynamicShouldError)
1055
- throw Object.defineProperty(new A.StaticGenBailoutError(`Route ${e.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${o}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`), "__NEXT_ERROR_CODE", {
1056
- value: "E553",
1057
- enumerable: !1,
1058
- configurable: !0
1059
- });
1060
- if (r)
1061
- switch (r.type) {
1062
- case "prerender":
1063
- const a = Object.defineProperty(new Error(`Route ${e.route} used ${o} without first calling \`await connection()\`. See more info here: https://nextjs.org/docs/messages/next-prerender-sync-headers`), "__NEXT_ERROR_CODE", {
1064
- value: "E126",
1065
- enumerable: !1,
1066
- configurable: !0
1067
- });
1068
- (0, p.abortAndThrowOnSynchronousRequestDataAccess)(e.route, o, a, r);
1069
- break;
1070
- case "prerender-client":
1071
- const f = "`draftMode`";
1072
- throw Object.defineProperty(new i.InvariantError(`${f} must not be used within a client component. Next.js should be preventing ${f} from being included in client components statically, but did not in this case.`), "__NEXT_ERROR_CODE", {
1073
- value: "E693",
1074
- enumerable: !1,
1075
- configurable: !0
1076
- });
1077
- case "prerender-ppr":
1078
- (0, p.postponeWithTracking)(e.route, o, r.dynamicTracking);
1079
- break;
1080
- case "prerender-legacy":
1081
- r.revalidate = 0;
1082
- const t = Object.defineProperty(new s.DynamicServerError(`Route ${e.route} couldn't be rendered statically because it used \`${o}\`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error`), "__NEXT_ERROR_CODE", {
1083
- value: "E558",
1084
- enumerable: !1,
1085
- configurable: !0
1086
- });
1087
- throw e.dynamicUsageDescription = o, e.dynamicUsageStack = t.stack, t;
1088
- case "request":
1089
- process.env.NODE_ENV === "development" && (r.usedDynamic = !0);
1090
- break;
1091
- }
1092
- }
1093
- }
1094
- }(B)), B;
1095
- }
1096
- var te;
1097
- function _e() {
1098
- return te || (te = 1, M.cookies = be().cookies, M.headers = ge().headers, M.draftMode = ve().draftMode), M;
1099
- }
1100
- var ye = _e();
1101
- const ae = () => {
1102
- const y = ye.cookies(), w = process.env.NEXT_PUBLIC_SUPABASE_URL, d = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
1103
- if (!w || !d)
11
+ _();
12
+ const i = () => {
13
+ const o = l(), t = process.env.NEXT_PUBLIC_SUPABASE_URL, r = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
14
+ if (!t || !r)
1104
15
  throw new Error("Missing Supabase environment variables");
1105
- return le(
1106
- w,
1107
- d,
16
+ return c(
17
+ t,
18
+ r,
1108
19
  {
1109
20
  cookies: {
1110
- async get(p) {
1111
- var g;
1112
- try {
1113
- return (g = (await y).get(p)) == null ? void 0 : g.value;
1114
- } catch (A) {
1115
- throw console.error(`Supabase cookie operation 'get' failed. Error: ${I(A)}`), new Error("A server-side error occurred while handling user session.");
1116
- }
21
+ async get(e) {
22
+ var s;
23
+ return (s = (await o).get(e)) == null ? void 0 : s.value;
1117
24
  },
1118
- set(p, g, A) {
1119
- (async () => {
1120
- try {
1121
- (await y).set({ name: p, value: g, ...A });
1122
- } catch (s) {
1123
- throw console.error(`Supabase cookie operation 'set' failed. Error: ${I(s)}`), new Error("A server-side error occurred while handling user session.");
1124
- }
1125
- })();
25
+ set(e, n, s) {
26
+ o.set({ name: e, value: n, ...s });
1126
27
  },
1127
- remove(p, g) {
1128
- (async () => {
1129
- try {
1130
- (await y).set({ name: p, value: "", ...g });
1131
- } catch (A) {
1132
- throw console.error(`Supabase cookie operation 'remove' failed. Error: ${I(A)}`), new Error("A server-side error occurred while handling user session.");
1133
- }
1134
- })();
28
+ remove(e, n) {
29
+ o.set({ name: e, value: "", ...n });
1135
30
  }
1136
31
  }
1137
32
  }
1138
33
  );
1139
34
  };
1140
- async function ke(y) {
1141
- const w = ae(), { data: d, error: p } = await w.from("profiles").select("id, full_name, avatar_url, role, updated_at, username, website").eq("id", y).single();
1142
- return p || !d ? (console.error("Error fetching profile (server-side):", p == null ? void 0 : p.message), null) : d;
35
+ async function p(o) {
36
+ const t = i(), { data: r, error: e } = await t.from("profiles").select("id, full_name, avatar_url, role, updated_at, username, website").eq("id", o).single();
37
+ return e || !r ? (console.error("Error fetching profile (server-side):", e == null ? void 0 : e.message), null) : r;
1143
38
  }
1144
- async function Se() {
1145
- const y = ae(), { data: w, error: d } = await y.from("languages").select("id, code, name, is_default, is_active, created_at, updated_at").order("name", { ascending: !0 });
1146
- return d ? (console.error("Error fetching languages (server-side):", d.message), []) : w || [];
39
+ async function f() {
40
+ const o = i(), { 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
+ return r ? (console.error("Error fetching languages (server-side):", r.message), []) : t || [];
1147
42
  }
1148
- const Re = () => {
43
+ const g = () => {
1149
44
  if (!process.env.NEXT_PUBLIC_SUPABASE_URL || !process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY)
1150
45
  throw new Error("Supabase URL or Anon Key is missing for SSG client. Check .env.local");
1151
- return de(
46
+ return u(
1152
47
  process.env.NEXT_PUBLIC_SUPABASE_URL,
1153
48
  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY
1154
49
  );
1155
50
  };
1156
51
  export {
1157
- ae as createClient,
1158
- Se as getActiveLanguagesServerSide,
1159
- ke as getProfileWithRoleServerSide,
1160
- Re as getSsgSupabaseClient
52
+ i as createClient,
53
+ f as getActiveLanguagesServerSide,
54
+ p as getProfileWithRoleServerSide,
55
+ g as getSsgSupabaseClient
1161
56
  };