@frequencyads/db 0.1.0

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/dist/admin.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/admin.ts
21
+ var admin_exports = {};
22
+ __export(admin_exports, {
23
+ createAdminClient: () => createAdminClient
24
+ });
25
+ module.exports = __toCommonJS(admin_exports);
26
+ var import_supabase_js = require("@supabase/supabase-js");
27
+
28
+ // src/lib/config.ts
29
+ function requireEnv(value, name) {
30
+ if (value == null) throw new Error(`Missing env var: ${name}`);
31
+ return value;
32
+ }
33
+ function getSupabaseUrl() {
34
+ return requireEnv(process.env.NEXT_PUBLIC_SUPABASE_URL, "NEXT_PUBLIC_SUPABASE_URL");
35
+ }
36
+ function getSupabaseServiceRoleKey() {
37
+ return requireEnv(process.env.SUPABASE_SERVICE_ROLE_KEY, "SUPABASE_SERVICE_ROLE_KEY");
38
+ }
39
+
40
+ // src/lib/admin.ts
41
+ function createAdminClient() {
42
+ return (0, import_supabase_js.createClient)(getSupabaseUrl(), getSupabaseServiceRoleKey(), {
43
+ auth: { autoRefreshToken: false, persistSession: false }
44
+ });
45
+ }
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ createAdminClient
49
+ });
package/dist/admin.mjs ADDED
@@ -0,0 +1,7 @@
1
+ import {
2
+ createAdminClient
3
+ } from "./chunk-V36326XB.mjs";
4
+ import "./chunk-WSYTHCA2.mjs";
5
+ export {
6
+ createAdminClient
7
+ };
@@ -0,0 +1,8 @@
1
+ // src/prefix.ts
2
+ function prefixTable(app, table) {
3
+ return `${app}_${table}`;
4
+ }
5
+
6
+ export {
7
+ prefixTable
8
+ };
@@ -0,0 +1,14 @@
1
+ // src/lib/cookies.ts
2
+ function deriveCookieDomain(hostname, allowedDomains) {
3
+ if (!(allowedDomains == null ? void 0 : allowedDomains.length)) return void 0;
4
+ for (const domain of allowedDomains) {
5
+ if (hostname === domain || hostname.endsWith(`.${domain}`)) {
6
+ return `.${domain}`;
7
+ }
8
+ }
9
+ return void 0;
10
+ }
11
+
12
+ export {
13
+ deriveCookieDomain
14
+ };
@@ -0,0 +1,16 @@
1
+ import {
2
+ getSupabaseServiceRoleKey,
3
+ getSupabaseUrl
4
+ } from "./chunk-WSYTHCA2.mjs";
5
+
6
+ // src/lib/admin.ts
7
+ import { createClient } from "@supabase/supabase-js";
8
+ function createAdminClient() {
9
+ return createClient(getSupabaseUrl(), getSupabaseServiceRoleKey(), {
10
+ auth: { autoRefreshToken: false, persistSession: false }
11
+ });
12
+ }
13
+
14
+ export {
15
+ createAdminClient
16
+ };
@@ -0,0 +1,30 @@
1
+ // src/lib/config.ts
2
+ function requireEnv(value, name) {
3
+ if (value == null) throw new Error(`Missing env var: ${name}`);
4
+ return value;
5
+ }
6
+ function getSupabaseUrl() {
7
+ return requireEnv(process.env.NEXT_PUBLIC_SUPABASE_URL, "NEXT_PUBLIC_SUPABASE_URL");
8
+ }
9
+ function getSupabasePublishableKey() {
10
+ return requireEnv(
11
+ process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY,
12
+ "NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY"
13
+ );
14
+ }
15
+ function getSupabaseServiceRoleKey() {
16
+ return requireEnv(process.env.SUPABASE_SERVICE_ROLE_KEY, "SUPABASE_SERVICE_ROLE_KEY");
17
+ }
18
+ function getTrustedDomains() {
19
+ return requireEnv(
20
+ process.env.NEXT_PUBLIC_FREQUENCY_TRUSTED_DOMAINS,
21
+ "NEXT_PUBLIC_FREQUENCY_TRUSTED_DOMAINS"
22
+ ).split(",").filter(Boolean);
23
+ }
24
+
25
+ export {
26
+ getSupabaseUrl,
27
+ getSupabasePublishableKey,
28
+ getSupabaseServiceRoleKey,
29
+ getTrustedDomains
30
+ };
@@ -0,0 +1,35 @@
1
+ import {
2
+ getSupabasePublishableKey,
3
+ getSupabaseUrl,
4
+ getTrustedDomains
5
+ } from "./chunk-WSYTHCA2.mjs";
6
+ import {
7
+ deriveCookieDomain
8
+ } from "./chunk-FBSO6HPC.mjs";
9
+
10
+ // src/lib/server.ts
11
+ import { createServerClient as createSupabaseServerClient } from "@supabase/ssr";
12
+ import { cookies } from "next/headers";
13
+ async function createServerClient(hostname) {
14
+ const cookieStore = await cookies();
15
+ const cookieDomain = hostname ? deriveCookieDomain(hostname, getTrustedDomains()) : void 0;
16
+ const cookieOptions = cookieDomain ? { domain: cookieDomain } : void 0;
17
+ return createSupabaseServerClient(getSupabaseUrl(), getSupabasePublishableKey(), {
18
+ cookieOptions,
19
+ cookies: {
20
+ getAll() {
21
+ return cookieStore.getAll();
22
+ },
23
+ setAll(cookiesToSet) {
24
+ try {
25
+ cookiesToSet.forEach(({ name, value, options }) => cookieStore.set(name, value, options));
26
+ } catch (e) {
27
+ }
28
+ }
29
+ }
30
+ });
31
+ }
32
+
33
+ export {
34
+ createServerClient
35
+ };
@@ -0,0 +1,22 @@
1
+ import {
2
+ getSupabasePublishableKey,
3
+ getSupabaseUrl,
4
+ getTrustedDomains
5
+ } from "./chunk-WSYTHCA2.mjs";
6
+ import {
7
+ deriveCookieDomain
8
+ } from "./chunk-FBSO6HPC.mjs";
9
+
10
+ // src/lib/client.ts
11
+ import { createBrowserClient as createSupabaseBrowserClient } from "@supabase/ssr";
12
+ function createBrowserClient() {
13
+ const cookieDomain = typeof window !== "undefined" ? deriveCookieDomain(window.location.hostname, getTrustedDomains()) : void 0;
14
+ const cookieOptions = cookieDomain ? { domain: cookieDomain } : void 0;
15
+ return createSupabaseBrowserClient(getSupabaseUrl(), getSupabasePublishableKey(), {
16
+ cookieOptions
17
+ });
18
+ }
19
+
20
+ export {
21
+ createBrowserClient
22
+ };