@cyguin/banner 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/.github/workflows/publish.yml +27 -0
- package/LICENSE +7 -0
- package/README.md +113 -0
- package/dist/adapters/postgres.d.mts +8 -0
- package/dist/adapters/postgres.d.ts +8 -0
- package/dist/adapters/postgres.js +8 -0
- package/dist/adapters/postgres.mjs +8 -0
- package/dist/adapters/sqlite.d.mts +8 -0
- package/dist/adapters/sqlite.d.ts +8 -0
- package/dist/adapters/sqlite.js +8 -0
- package/dist/adapters/sqlite.mjs +8 -0
- package/dist/chunk-3R4HB5JY.mjs +175 -0
- package/dist/chunk-ATHBJQGY.js +73 -0
- package/dist/chunk-EBO3CZXG.mjs +15 -0
- package/dist/chunk-GW7T5T6B.mjs +69 -0
- package/dist/chunk-LI5BSLUA.js +175 -0
- package/dist/chunk-MCKGQKYU.js +15 -0
- package/dist/chunk-PCYDRYYV.js +69 -0
- package/dist/chunk-Q3CIRMT7.js +37 -0
- package/dist/chunk-SQPUEELE.mjs +73 -0
- package/dist/chunk-UF2PO4UG.mjs +81 -0
- package/dist/chunk-UG6SXPV3.js +81 -0
- package/dist/chunk-YH77VFY5.mjs +37 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +20 -0
- package/dist/index.mjs +20 -0
- package/dist/next.d.mts +13 -0
- package/dist/next.d.ts +13 -0
- package/dist/next.js +7 -0
- package/dist/next.mjs +7 -0
- package/dist/react.d.mts +14 -0
- package/dist/react.d.ts +14 -0
- package/dist/react.js +7 -0
- package/dist/react.mjs +7 -0
- package/dist/types-pufIZ_FB.d.mts +14 -0
- package/dist/types-pufIZ_FB.d.ts +14 -0
- package/package.json +39 -0
- package/src/adapters/postgres.ts +77 -0
- package/src/adapters/sqlite.ts +84 -0
- package/src/components/ConsentBanner.tsx +186 -0
- package/src/components/index.ts +3 -0
- package/src/handlers/route.ts +51 -0
- package/src/index.ts +17 -0
- package/src/types.ts +18 -0
- package/tsconfig.json +18 -0
- package/tsup.config.ts +14 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
id-token: write
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: '20'
|
|
19
|
+
registry-url: 'https://registry.npmjs.org'
|
|
20
|
+
- name: Install dependencies
|
|
21
|
+
run: npm install --legacy-peer-deps
|
|
22
|
+
- name: Build
|
|
23
|
+
run: npm run build
|
|
24
|
+
- name: Publish
|
|
25
|
+
env:
|
|
26
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
27
|
+
run: npm publish --provenance --access public
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2026 cyguin.com
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# @cyguin/banner
|
|
2
|
+
|
|
3
|
+
Cookie consent and GDPR notice drop-in for Next.js. Stores consent decisions in DB for audit trail, renders a dismissible consent banner.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @cyguin/banner
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configure Adapter
|
|
12
|
+
|
|
13
|
+
### SQLite
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// lib/banner.ts
|
|
17
|
+
import { SQLiteAdapter } from '@cyguin/banner/adapters/sqlite'
|
|
18
|
+
|
|
19
|
+
export const bannerAdapter = SQLiteAdapter({ path: './data/banner.db' })
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Postgres
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// lib/banner.ts
|
|
26
|
+
import { PostgresAdapter } from '@cyguin/banner/adapters/postgres'
|
|
27
|
+
|
|
28
|
+
export const bannerAdapter = PostgresAdapter({
|
|
29
|
+
connectionString: process.env.DATABASE_URL!,
|
|
30
|
+
})
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Add API Route
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
// app/api/banner/[...cyguin]/route.ts
|
|
37
|
+
import { createBannerHandler } from '@cyguin/banner/next'
|
|
38
|
+
import { bannerAdapter } from '@/lib/banner'
|
|
39
|
+
|
|
40
|
+
export const GET = createBannerHandler({ adapter: bannerAdapter })
|
|
41
|
+
export const POST = createBannerHandler({ adapter: bannerAdapter })
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Drop In Component
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
// app/layout.tsx (or any page)
|
|
48
|
+
import { ConsentBanner } from '@cyguin/banner/react'
|
|
49
|
+
|
|
50
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
51
|
+
return (
|
|
52
|
+
<html>
|
|
53
|
+
<body>
|
|
54
|
+
{children}
|
|
55
|
+
<ConsentBanner
|
|
56
|
+
apiBase="/api/banner"
|
|
57
|
+
userId="user_123" // optional
|
|
58
|
+
theme="light" // or "dark"
|
|
59
|
+
onAccept={() => console.log('accepted')}
|
|
60
|
+
onReject={() => console.log('rejected')}
|
|
61
|
+
/>
|
|
62
|
+
</body>
|
|
63
|
+
</html>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Theming
|
|
69
|
+
|
|
70
|
+
The banner uses `--cyguin-*` CSS custom properties. Default is light.
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
// Dark theme
|
|
74
|
+
<ConsentBanner theme="dark" />
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Customise via CSS:
|
|
78
|
+
|
|
79
|
+
```css
|
|
80
|
+
.cyguin-banner {
|
|
81
|
+
--cyguin-accent: #ff6600;
|
|
82
|
+
--cyguin-radius: 0;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Exports
|
|
87
|
+
|
|
88
|
+
| Import | What |
|
|
89
|
+
|--------|------|
|
|
90
|
+
| `@cyguin/banner` | Types: `ConsentRecordData`, `ConsentDecision`, `BannerAdapter` |
|
|
91
|
+
| `@cyguin/banner/next` | `createBannerHandler` |
|
|
92
|
+
| `@cyguin/banner/react` | `ConsentBanner` |
|
|
93
|
+
| `@cyguin/banner/adapters/sqlite` | `SQLiteAdapter` |
|
|
94
|
+
| `@cyguin/banner/adapters/postgres` | `PostgresAdapter` |
|
|
95
|
+
|
|
96
|
+
## API
|
|
97
|
+
|
|
98
|
+
| Method | Route | Description |
|
|
99
|
+
|--------|-------|-------------|
|
|
100
|
+
| GET | `/api/banner/[...cyguin]` | Get current consent record for user |
|
|
101
|
+
| POST | `/api/banner/[...cyguin]` | Record consent decision |
|
|
102
|
+
|
|
103
|
+
## DB Schema
|
|
104
|
+
|
|
105
|
+
```sql
|
|
106
|
+
CREATE TABLE consent_records (
|
|
107
|
+
id TEXT PRIMARY KEY,
|
|
108
|
+
user_id TEXT,
|
|
109
|
+
decision TEXT NOT NULL,
|
|
110
|
+
categories TEXT NOT NULL DEFAULT '[]',
|
|
111
|
+
created_at INTEGER NOT NULL
|
|
112
|
+
);
|
|
113
|
+
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { B as BannerAdapter } from '../types-pufIZ_FB.mjs';
|
|
2
|
+
|
|
3
|
+
interface PostgresAdapterOptions {
|
|
4
|
+
connectionString: string;
|
|
5
|
+
}
|
|
6
|
+
declare function PostgresAdapter(options: PostgresAdapterOptions): BannerAdapter;
|
|
7
|
+
|
|
8
|
+
export { PostgresAdapter, type PostgresAdapterOptions };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { B as BannerAdapter } from '../types-pufIZ_FB.js';
|
|
2
|
+
|
|
3
|
+
interface PostgresAdapterOptions {
|
|
4
|
+
connectionString: string;
|
|
5
|
+
}
|
|
6
|
+
declare function PostgresAdapter(options: PostgresAdapterOptions): BannerAdapter;
|
|
7
|
+
|
|
8
|
+
export { PostgresAdapter, type PostgresAdapterOptions };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkATHBJQGYjs = require('../chunk-ATHBJQGY.js');
|
|
4
|
+
require('../chunk-PCYDRYYV.js');
|
|
5
|
+
require('../chunk-MCKGQKYU.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.PostgresAdapter = _chunkATHBJQGYjs.PostgresAdapter;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// src/components/ConsentBanner.tsx
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
function ConsentBanner({
|
|
5
|
+
apiBase = "/api/banner",
|
|
6
|
+
userId,
|
|
7
|
+
theme = "light",
|
|
8
|
+
className = "",
|
|
9
|
+
onAccept,
|
|
10
|
+
onReject
|
|
11
|
+
}) {
|
|
12
|
+
const [visible, setVisible] = useState(false);
|
|
13
|
+
const [loading, setLoading] = useState(true);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const checkConsent = async () => {
|
|
16
|
+
try {
|
|
17
|
+
const url = new URL(`${apiBase}/[...cyguin]`);
|
|
18
|
+
url.searchParams.set("cyguin", "");
|
|
19
|
+
if (userId) url.searchParams.set("userId", userId);
|
|
20
|
+
const res = await fetch(`${apiBase}/[...cyguin]${url.search}`);
|
|
21
|
+
if (res.ok) {
|
|
22
|
+
const data = await res.json();
|
|
23
|
+
if (data) {
|
|
24
|
+
setLoading(false);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
setVisible(true);
|
|
31
|
+
setLoading(false);
|
|
32
|
+
};
|
|
33
|
+
checkConsent();
|
|
34
|
+
}, [apiBase, userId]);
|
|
35
|
+
const handleDecision = async (decision) => {
|
|
36
|
+
try {
|
|
37
|
+
await fetch(`${apiBase}/[...cyguin]`, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: { "Content-Type": "application/json" },
|
|
40
|
+
body: JSON.stringify({ userId, decision, categories: [] })
|
|
41
|
+
});
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
setVisible(false);
|
|
45
|
+
if (decision === "accept") {
|
|
46
|
+
onAccept?.();
|
|
47
|
+
} else {
|
|
48
|
+
onReject?.();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
if (loading || !visible) return null;
|
|
52
|
+
return /* @__PURE__ */ jsxs(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
className: `cyguin-banner ${className}`,
|
|
56
|
+
"data-theme": theme,
|
|
57
|
+
role: "region",
|
|
58
|
+
"aria-label": "Cookie consent",
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ jsx("style", { children: `
|
|
61
|
+
.cyguin-banner {
|
|
62
|
+
--cyguin-bg: #ffffff;
|
|
63
|
+
--cyguin-bg-subtle: #f5f5f5;
|
|
64
|
+
--cyguin-border: #e5e5e5;
|
|
65
|
+
--cyguin-border-focus: #f5a800;
|
|
66
|
+
--cyguin-fg: #0a0a0a;
|
|
67
|
+
--cyguin-fg-muted: #888888;
|
|
68
|
+
--cyguin-accent: #f5a800;
|
|
69
|
+
--cyguin-accent-dark: #c47f00;
|
|
70
|
+
--cyguin-accent-fg: #0a0a0a;
|
|
71
|
+
--cyguin-radius: 6px;
|
|
72
|
+
--cyguin-shadow: 0 1px 4px rgba(0,0,0,0.08);
|
|
73
|
+
position: fixed;
|
|
74
|
+
bottom: 0;
|
|
75
|
+
left: 0;
|
|
76
|
+
right: 0;
|
|
77
|
+
z-index: 99999;
|
|
78
|
+
background: var(--cyguin-bg);
|
|
79
|
+
border-top: 1px solid var(--cyguin-border);
|
|
80
|
+
box-shadow: var(--cyguin-shadow);
|
|
81
|
+
padding: 16px 24px;
|
|
82
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
justify-content: space-between;
|
|
86
|
+
gap: 16px;
|
|
87
|
+
flex-wrap: wrap;
|
|
88
|
+
}
|
|
89
|
+
.cyguin-banner[data-theme="dark"] {
|
|
90
|
+
--cyguin-bg: #0a0a0a;
|
|
91
|
+
--cyguin-bg-subtle: #1a1a1a;
|
|
92
|
+
--cyguin-border: #2a2a2a;
|
|
93
|
+
--cyguin-border-focus: #f5a800;
|
|
94
|
+
--cyguin-fg: #f5f5f5;
|
|
95
|
+
--cyguin-fg-muted: #888888;
|
|
96
|
+
--cyguin-accent: #f5a800;
|
|
97
|
+
--cyguin-accent-dark: #c47f00;
|
|
98
|
+
--cyguin-accent-fg: #0a0a0a;
|
|
99
|
+
--cyguin-radius: 6px;
|
|
100
|
+
--cyguin-shadow: 0 1px 4px rgba(0,0,0,0.4);
|
|
101
|
+
}
|
|
102
|
+
.cyguin-banner__text {
|
|
103
|
+
color: var(--cyguin-fg);
|
|
104
|
+
font-size: 14px;
|
|
105
|
+
line-height: 1.5;
|
|
106
|
+
margin: 0;
|
|
107
|
+
flex: 1;
|
|
108
|
+
min-width: 200px;
|
|
109
|
+
}
|
|
110
|
+
.cyguin-banner__text a {
|
|
111
|
+
color: var(--cyguin-accent);
|
|
112
|
+
text-decoration: underline;
|
|
113
|
+
}
|
|
114
|
+
.cyguin-banner__actions {
|
|
115
|
+
display: flex;
|
|
116
|
+
gap: 8px;
|
|
117
|
+
flex-shrink: 0;
|
|
118
|
+
}
|
|
119
|
+
.cyguin-banner__btn {
|
|
120
|
+
padding: 8px 16px;
|
|
121
|
+
border-radius: var(--cyguin-radius);
|
|
122
|
+
font-size: 14px;
|
|
123
|
+
font-weight: 500;
|
|
124
|
+
cursor: pointer;
|
|
125
|
+
border: 1px solid transparent;
|
|
126
|
+
transition: background 0.15s, border-color 0.15s;
|
|
127
|
+
}
|
|
128
|
+
.cyguin-banner__btn--accept {
|
|
129
|
+
background: var(--cyguin-accent);
|
|
130
|
+
color: var(--cyguin-accent-fg);
|
|
131
|
+
border-color: var(--cyguin-accent);
|
|
132
|
+
}
|
|
133
|
+
.cyguin-banner__btn--accept:hover {
|
|
134
|
+
background: var(--cyguin-accent-dark);
|
|
135
|
+
border-color: var(--cyguin-accent-dark);
|
|
136
|
+
}
|
|
137
|
+
.cyguin-banner__btn--reject {
|
|
138
|
+
background: transparent;
|
|
139
|
+
color: var(--cyguin-fg-muted);
|
|
140
|
+
border-color: var(--cyguin-border);
|
|
141
|
+
}
|
|
142
|
+
.cyguin-banner__btn--reject:hover {
|
|
143
|
+
border-color: var(--cyguin-fg-muted);
|
|
144
|
+
color: var(--cyguin-fg);
|
|
145
|
+
}
|
|
146
|
+
` }),
|
|
147
|
+
/* @__PURE__ */ jsx("p", { className: "cyguin-banner__text", children: "We use cookies to improve your experience. By continuing to browse you agree to our cookie policy." }),
|
|
148
|
+
/* @__PURE__ */ jsxs("div", { className: "cyguin-banner__actions", children: [
|
|
149
|
+
/* @__PURE__ */ jsx(
|
|
150
|
+
"button",
|
|
151
|
+
{
|
|
152
|
+
className: "cyguin-banner__btn cyguin-banner__btn--reject",
|
|
153
|
+
onClick: () => handleDecision("reject"),
|
|
154
|
+
type: "button",
|
|
155
|
+
children: "Reject"
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
/* @__PURE__ */ jsx(
|
|
159
|
+
"button",
|
|
160
|
+
{
|
|
161
|
+
className: "cyguin-banner__btn cyguin-banner__btn--accept",
|
|
162
|
+
onClick: () => handleDecision("accept"),
|
|
163
|
+
type: "button",
|
|
164
|
+
children: "Accept"
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
] })
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export {
|
|
174
|
+
ConsentBanner
|
|
175
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkPCYDRYYVjs = require('./chunk-PCYDRYYV.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkMCKGQKYUjs = require('./chunk-MCKGQKYU.js');
|
|
7
|
+
|
|
8
|
+
// src/adapters/postgres.ts
|
|
9
|
+
function PostgresAdapter(options) {
|
|
10
|
+
let db;
|
|
11
|
+
try {
|
|
12
|
+
const postgres = _chunkMCKGQKYUjs.__require.call(void 0, "porsager/postgres");
|
|
13
|
+
db = postgres(options.connectionString);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new Error("porsager/postgres is required. Install with: npm install porsager/postgres");
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
async getConsent(userId) {
|
|
19
|
+
let result;
|
|
20
|
+
if (userId) {
|
|
21
|
+
result = await db`
|
|
22
|
+
SELECT * FROM consent_records
|
|
23
|
+
WHERE user_id = ${userId}
|
|
24
|
+
ORDER BY created_at DESC
|
|
25
|
+
LIMIT 1
|
|
26
|
+
`;
|
|
27
|
+
} else {
|
|
28
|
+
result = await db`
|
|
29
|
+
SELECT * FROM consent_records
|
|
30
|
+
ORDER BY created_at DESC
|
|
31
|
+
LIMIT 1
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
const row = result[0];
|
|
35
|
+
if (!row) return null;
|
|
36
|
+
return {
|
|
37
|
+
id: row.id,
|
|
38
|
+
userId: row.user_id,
|
|
39
|
+
decision: row.decision,
|
|
40
|
+
categories: row.categories,
|
|
41
|
+
createdAt: row.created_at
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
async recordConsent(userId, decision, categories) {
|
|
45
|
+
const { nanoid } = _chunkPCYDRYYVjs.require_nanoid.call(void 0, );
|
|
46
|
+
const id = nanoid();
|
|
47
|
+
const createdAt = Date.now();
|
|
48
|
+
const result = await db`
|
|
49
|
+
INSERT INTO consent_records (id, user_id, decision, categories, created_at)
|
|
50
|
+
VALUES (
|
|
51
|
+
${id},
|
|
52
|
+
${_nullishCoalesce(userId, () => ( null))},
|
|
53
|
+
${decision},
|
|
54
|
+
${categories},
|
|
55
|
+
${createdAt}
|
|
56
|
+
)
|
|
57
|
+
RETURNING *
|
|
58
|
+
`;
|
|
59
|
+
const row = result[0];
|
|
60
|
+
return {
|
|
61
|
+
id: row.id,
|
|
62
|
+
userId: row.user_id,
|
|
63
|
+
decision: row.decision,
|
|
64
|
+
categories: row.categories,
|
|
65
|
+
createdAt: row.created_at
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
exports.PostgresAdapter = PostgresAdapter;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
__require,
|
|
14
|
+
__commonJS
|
|
15
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__require
|
|
4
|
+
} from "./chunk-EBO3CZXG.mjs";
|
|
5
|
+
|
|
6
|
+
// node_modules/nanoid/url-alphabet/index.cjs
|
|
7
|
+
var require_url_alphabet = __commonJS({
|
|
8
|
+
"node_modules/nanoid/url-alphabet/index.cjs"(exports, module) {
|
|
9
|
+
"use strict";
|
|
10
|
+
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
11
|
+
module.exports = { urlAlphabet };
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// node_modules/nanoid/index.cjs
|
|
16
|
+
var require_nanoid = __commonJS({
|
|
17
|
+
"node_modules/nanoid/index.cjs"(exports, module) {
|
|
18
|
+
"use strict";
|
|
19
|
+
var crypto = __require("crypto");
|
|
20
|
+
var { urlAlphabet } = require_url_alphabet();
|
|
21
|
+
var POOL_SIZE_MULTIPLIER = 128;
|
|
22
|
+
var pool;
|
|
23
|
+
var poolOffset;
|
|
24
|
+
var fillPool = (bytes) => {
|
|
25
|
+
if (!pool || pool.length < bytes) {
|
|
26
|
+
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
|
|
27
|
+
crypto.randomFillSync(pool);
|
|
28
|
+
poolOffset = 0;
|
|
29
|
+
} else if (poolOffset + bytes > pool.length) {
|
|
30
|
+
crypto.randomFillSync(pool);
|
|
31
|
+
poolOffset = 0;
|
|
32
|
+
}
|
|
33
|
+
poolOffset += bytes;
|
|
34
|
+
};
|
|
35
|
+
var random = (bytes) => {
|
|
36
|
+
fillPool(bytes |= 0);
|
|
37
|
+
return pool.subarray(poolOffset - bytes, poolOffset);
|
|
38
|
+
};
|
|
39
|
+
var customRandom = (alphabet, defaultSize, getRandom) => {
|
|
40
|
+
let mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
|
|
41
|
+
let step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
|
|
42
|
+
return (size = defaultSize) => {
|
|
43
|
+
let id = "";
|
|
44
|
+
while (true) {
|
|
45
|
+
let bytes = getRandom(step);
|
|
46
|
+
let i = step;
|
|
47
|
+
while (i--) {
|
|
48
|
+
id += alphabet[bytes[i] & mask] || "";
|
|
49
|
+
if (id.length === size) return id;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
var customAlphabet = (alphabet, size = 21) => customRandom(alphabet, size, random);
|
|
55
|
+
var nanoid = (size = 21) => {
|
|
56
|
+
fillPool(size |= 0);
|
|
57
|
+
let id = "";
|
|
58
|
+
for (let i = poolOffset - size; i < poolOffset; i++) {
|
|
59
|
+
id += urlAlphabet[pool[i] & 63];
|
|
60
|
+
}
|
|
61
|
+
return id;
|
|
62
|
+
};
|
|
63
|
+
module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random };
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
require_nanoid
|
|
69
|
+
};
|