@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/client.js ADDED
@@ -0,0 +1,71 @@
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/client.ts
21
+ var client_exports = {};
22
+ __export(client_exports, {
23
+ createBrowserClient: () => createBrowserClient
24
+ });
25
+ module.exports = __toCommonJS(client_exports);
26
+ var import_ssr = require("@supabase/ssr");
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 getSupabasePublishableKey() {
37
+ return requireEnv(
38
+ process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY,
39
+ "NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY"
40
+ );
41
+ }
42
+ function getTrustedDomains() {
43
+ return requireEnv(
44
+ process.env.NEXT_PUBLIC_FREQUENCY_TRUSTED_DOMAINS,
45
+ "NEXT_PUBLIC_FREQUENCY_TRUSTED_DOMAINS"
46
+ ).split(",").filter(Boolean);
47
+ }
48
+
49
+ // src/lib/cookies.ts
50
+ function deriveCookieDomain(hostname, allowedDomains) {
51
+ if (!(allowedDomains == null ? void 0 : allowedDomains.length)) return void 0;
52
+ for (const domain of allowedDomains) {
53
+ if (hostname === domain || hostname.endsWith(`.${domain}`)) {
54
+ return `.${domain}`;
55
+ }
56
+ }
57
+ return void 0;
58
+ }
59
+
60
+ // src/lib/client.ts
61
+ function createBrowserClient() {
62
+ const cookieDomain = typeof window !== "undefined" ? deriveCookieDomain(window.location.hostname, getTrustedDomains()) : void 0;
63
+ const cookieOptions = cookieDomain ? { domain: cookieDomain } : void 0;
64
+ return (0, import_ssr.createBrowserClient)(getSupabaseUrl(), getSupabasePublishableKey(), {
65
+ cookieOptions
66
+ });
67
+ }
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ createBrowserClient
71
+ });
@@ -0,0 +1,8 @@
1
+ import {
2
+ createBrowserClient
3
+ } from "./chunk-XVKANJTF.mjs";
4
+ import "./chunk-WSYTHCA2.mjs";
5
+ import "./chunk-FBSO6HPC.mjs";
6
+ export {
7
+ createBrowserClient
8
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * IMPORTANT: Each getter must use a literal `process.env.NEXT_PUBLIC_*`
3
+ * access — Next.js statically replaces these at build time.
4
+ * Dynamic access like `process.env[key]` won't be inlined and will be
5
+ * undefined in client/edge bundles.
6
+ */
7
+ declare function getSupabaseUrl(): string;
8
+ declare function getSupabasePublishableKey(): string;
9
+ declare function getSupabaseServiceRoleKey(): string;
10
+ declare function getTrustedDomains(): string[];
11
+
12
+ export { getSupabasePublishableKey, getSupabaseServiceRoleKey, getSupabaseUrl, getTrustedDomains };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * IMPORTANT: Each getter must use a literal `process.env.NEXT_PUBLIC_*`
3
+ * access — Next.js statically replaces these at build time.
4
+ * Dynamic access like `process.env[key]` won't be inlined and will be
5
+ * undefined in client/edge bundles.
6
+ */
7
+ declare function getSupabaseUrl(): string;
8
+ declare function getSupabasePublishableKey(): string;
9
+ declare function getSupabaseServiceRoleKey(): string;
10
+ declare function getTrustedDomains(): string[];
11
+
12
+ export { getSupabasePublishableKey, getSupabaseServiceRoleKey, getSupabaseUrl, getTrustedDomains };
package/dist/config.js ADDED
@@ -0,0 +1,57 @@
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/config.ts
21
+ var config_exports = {};
22
+ __export(config_exports, {
23
+ getSupabasePublishableKey: () => getSupabasePublishableKey,
24
+ getSupabaseServiceRoleKey: () => getSupabaseServiceRoleKey,
25
+ getSupabaseUrl: () => getSupabaseUrl,
26
+ getTrustedDomains: () => getTrustedDomains
27
+ });
28
+ module.exports = __toCommonJS(config_exports);
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 getSupabasePublishableKey() {
37
+ return requireEnv(
38
+ process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY,
39
+ "NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY"
40
+ );
41
+ }
42
+ function getSupabaseServiceRoleKey() {
43
+ return requireEnv(process.env.SUPABASE_SERVICE_ROLE_KEY, "SUPABASE_SERVICE_ROLE_KEY");
44
+ }
45
+ function getTrustedDomains() {
46
+ return requireEnv(
47
+ process.env.NEXT_PUBLIC_FREQUENCY_TRUSTED_DOMAINS,
48
+ "NEXT_PUBLIC_FREQUENCY_TRUSTED_DOMAINS"
49
+ ).split(",").filter(Boolean);
50
+ }
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ getSupabasePublishableKey,
54
+ getSupabaseServiceRoleKey,
55
+ getSupabaseUrl,
56
+ getTrustedDomains
57
+ });
@@ -0,0 +1,12 @@
1
+ import {
2
+ getSupabasePublishableKey,
3
+ getSupabaseServiceRoleKey,
4
+ getSupabaseUrl,
5
+ getTrustedDomains
6
+ } from "./chunk-WSYTHCA2.mjs";
7
+ export {
8
+ getSupabasePublishableKey,
9
+ getSupabaseServiceRoleKey,
10
+ getSupabaseUrl,
11
+ getTrustedDomains
12
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Given a hostname and a list of allowed root domains, return the
3
+ * matching root domain prefixed with '.' for use as a cookie domain.
4
+ * Returns undefined if no match (falls back to default browser behavior).
5
+ */
6
+ declare function deriveCookieDomain(hostname: string, allowedDomains?: string[]): string | undefined;
7
+
8
+ export { deriveCookieDomain };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Given a hostname and a list of allowed root domains, return the
3
+ * matching root domain prefixed with '.' for use as a cookie domain.
4
+ * Returns undefined if no match (falls back to default browser behavior).
5
+ */
6
+ declare function deriveCookieDomain(hostname: string, allowedDomains?: string[]): string | undefined;
7
+
8
+ export { deriveCookieDomain };
@@ -0,0 +1,38 @@
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/cookies.ts
21
+ var cookies_exports = {};
22
+ __export(cookies_exports, {
23
+ deriveCookieDomain: () => deriveCookieDomain
24
+ });
25
+ module.exports = __toCommonJS(cookies_exports);
26
+ function deriveCookieDomain(hostname, allowedDomains) {
27
+ if (!(allowedDomains == null ? void 0 : allowedDomains.length)) return void 0;
28
+ for (const domain of allowedDomains) {
29
+ if (hostname === domain || hostname.endsWith(`.${domain}`)) {
30
+ return `.${domain}`;
31
+ }
32
+ }
33
+ return void 0;
34
+ }
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ deriveCookieDomain
38
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ deriveCookieDomain
3
+ } from "./chunk-FBSO6HPC.mjs";
4
+ export {
5
+ deriveCookieDomain
6
+ };
@@ -0,0 +1,6 @@
1
+ export { createBrowserClient } from './client.mjs';
2
+ export { createServerClient } from './server.mjs';
3
+ export { createAdminClient } from './admin.mjs';
4
+ export { prefixTable } from './prefix.mjs';
5
+ export { Database } from './types.mjs';
6
+ import '@supabase/supabase-js';
@@ -0,0 +1,6 @@
1
+ export { createBrowserClient } from './client.js';
2
+ export { createServerClient } from './server.js';
3
+ export { createAdminClient } from './admin.js';
4
+ export { prefixTable } from './prefix.js';
5
+ export { Database } from './types.js';
6
+ import '@supabase/supabase-js';
package/dist/index.js ADDED
@@ -0,0 +1,118 @@
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/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ createAdminClient: () => createAdminClient,
24
+ createBrowserClient: () => createBrowserClient,
25
+ createServerClient: () => createServerClient,
26
+ prefixTable: () => prefixTable
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
29
+
30
+ // src/lib/client.ts
31
+ var import_ssr = require("@supabase/ssr");
32
+
33
+ // src/lib/config.ts
34
+ function requireEnv(value, name) {
35
+ if (value == null) throw new Error(`Missing env var: ${name}`);
36
+ return value;
37
+ }
38
+ function getSupabaseUrl() {
39
+ return requireEnv(process.env.NEXT_PUBLIC_SUPABASE_URL, "NEXT_PUBLIC_SUPABASE_URL");
40
+ }
41
+ function getSupabasePublishableKey() {
42
+ return requireEnv(
43
+ process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY,
44
+ "NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY"
45
+ );
46
+ }
47
+ function getSupabaseServiceRoleKey() {
48
+ return requireEnv(process.env.SUPABASE_SERVICE_ROLE_KEY, "SUPABASE_SERVICE_ROLE_KEY");
49
+ }
50
+ function getTrustedDomains() {
51
+ return requireEnv(
52
+ process.env.NEXT_PUBLIC_FREQUENCY_TRUSTED_DOMAINS,
53
+ "NEXT_PUBLIC_FREQUENCY_TRUSTED_DOMAINS"
54
+ ).split(",").filter(Boolean);
55
+ }
56
+
57
+ // src/lib/cookies.ts
58
+ function deriveCookieDomain(hostname, allowedDomains) {
59
+ if (!(allowedDomains == null ? void 0 : allowedDomains.length)) return void 0;
60
+ for (const domain of allowedDomains) {
61
+ if (hostname === domain || hostname.endsWith(`.${domain}`)) {
62
+ return `.${domain}`;
63
+ }
64
+ }
65
+ return void 0;
66
+ }
67
+
68
+ // src/lib/client.ts
69
+ function createBrowserClient() {
70
+ const cookieDomain = typeof window !== "undefined" ? deriveCookieDomain(window.location.hostname, getTrustedDomains()) : void 0;
71
+ const cookieOptions = cookieDomain ? { domain: cookieDomain } : void 0;
72
+ return (0, import_ssr.createBrowserClient)(getSupabaseUrl(), getSupabasePublishableKey(), {
73
+ cookieOptions
74
+ });
75
+ }
76
+
77
+ // src/lib/server.ts
78
+ var import_ssr2 = require("@supabase/ssr");
79
+ var import_headers = require("next/headers");
80
+ async function createServerClient(hostname) {
81
+ const cookieStore = await (0, import_headers.cookies)();
82
+ const cookieDomain = hostname ? deriveCookieDomain(hostname, getTrustedDomains()) : void 0;
83
+ const cookieOptions = cookieDomain ? { domain: cookieDomain } : void 0;
84
+ return (0, import_ssr2.createServerClient)(getSupabaseUrl(), getSupabasePublishableKey(), {
85
+ cookieOptions,
86
+ cookies: {
87
+ getAll() {
88
+ return cookieStore.getAll();
89
+ },
90
+ setAll(cookiesToSet) {
91
+ try {
92
+ cookiesToSet.forEach(({ name, value, options }) => cookieStore.set(name, value, options));
93
+ } catch (e) {
94
+ }
95
+ }
96
+ }
97
+ });
98
+ }
99
+
100
+ // src/lib/admin.ts
101
+ var import_supabase_js = require("@supabase/supabase-js");
102
+ function createAdminClient() {
103
+ return (0, import_supabase_js.createClient)(getSupabaseUrl(), getSupabaseServiceRoleKey(), {
104
+ auth: { autoRefreshToken: false, persistSession: false }
105
+ });
106
+ }
107
+
108
+ // src/prefix.ts
109
+ function prefixTable(app, table) {
110
+ return `${app}_${table}`;
111
+ }
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ createAdminClient,
115
+ createBrowserClient,
116
+ createServerClient,
117
+ prefixTable
118
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,20 @@
1
+ import {
2
+ createBrowserClient
3
+ } from "./chunk-XVKANJTF.mjs";
4
+ import {
5
+ createServerClient
6
+ } from "./chunk-XGXPBKIL.mjs";
7
+ import {
8
+ createAdminClient
9
+ } from "./chunk-V36326XB.mjs";
10
+ import "./chunk-WSYTHCA2.mjs";
11
+ import "./chunk-FBSO6HPC.mjs";
12
+ import {
13
+ prefixTable
14
+ } from "./chunk-AXVGA3LK.mjs";
15
+ export {
16
+ createAdminClient,
17
+ createBrowserClient,
18
+ createServerClient,
19
+ prefixTable
20
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Prefix a table name with an app identifier.
3
+ *
4
+ * Usage:
5
+ * prefixTable('okrs', 'objectives') // => 'okrs_objectives'
6
+ * prefixTable('stories', 'items') // => 'stories_items'
7
+ */
8
+ declare function prefixTable(app: string, table: string): string;
9
+
10
+ export { prefixTable };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Prefix a table name with an app identifier.
3
+ *
4
+ * Usage:
5
+ * prefixTable('okrs', 'objectives') // => 'okrs_objectives'
6
+ * prefixTable('stories', 'items') // => 'stories_items'
7
+ */
8
+ declare function prefixTable(app: string, table: string): string;
9
+
10
+ export { prefixTable };
package/dist/prefix.js ADDED
@@ -0,0 +1,32 @@
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/prefix.ts
21
+ var prefix_exports = {};
22
+ __export(prefix_exports, {
23
+ prefixTable: () => prefixTable
24
+ });
25
+ module.exports = __toCommonJS(prefix_exports);
26
+ function prefixTable(app, table) {
27
+ return `${app}_${table}`;
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ prefixTable
32
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ prefixTable
3
+ } from "./chunk-AXVGA3LK.mjs";
4
+ export {
5
+ prefixTable
6
+ };