@knowcode/doc-builder 1.8.2 â 1.8.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/.claude/settings.local.json +5 -1
- package/CHANGELOG.md +39 -3
- package/README.md +4 -4
- package/assets/css/notion-style.css +26 -0
- package/cli.js +9 -40
- package/debug-login.sql +30 -0
- package/html/README.html +27 -3
- package/html/auth.js +2 -2
- package/html/css/notion-style.css +26 -0
- package/html/documentation-index.html +27 -3
- package/html/guides/authentication-default-change.html +27 -3
- package/html/guides/authentication-guide.html +58 -45
- package/html/guides/claude-workflow-guide.html +27 -3
- package/html/guides/documentation-standards.html +27 -3
- package/html/guides/phosphor-icons-guide.html +27 -3
- package/html/guides/private-directory-authentication.html +59 -17
- package/html/guides/public-site-deployment.html +32 -9
- package/html/guides/search-engine-verification-guide.html +27 -3
- package/html/guides/seo-guide.html +27 -3
- package/html/guides/seo-optimization-guide.html +27 -3
- package/html/guides/troubleshooting-guide.html +27 -3
- package/html/guides/windows-setup-guide.html +27 -3
- package/html/index.html +27 -3
- package/html/js/auth.js +2 -2
- package/html/login.html +2 -2
- package/html/private/cache-control-anti-pattern.html +5 -5
- package/html/private/launch/README.html +5 -5
- package/html/private/launch/auth-cleanup-summary.html +5 -5
- package/html/private/launch/bubble-plugin-specification.html +5 -5
- package/html/private/launch/go-to-market-strategy.html +5 -5
- package/html/private/launch/launch-announcements.html +5 -5
- package/html/private/launch/vercel-deployment-auth-setup.html +27 -21
- package/html/private/next-steps-walkthrough.html +18 -45
- package/html/private/supabase-auth-implementation-completed.html +8 -8
- package/html/private/supabase-auth-implementation-plan.html +16 -33
- package/html/private/supabase-auth-integration-plan.html +34 -69
- package/html/private/supabase-auth-setup-guide.html +73 -84
- package/html/private/test-private-doc.html +5 -5
- package/html/private/user-management-tooling.html +9 -15
- package/html/sitemap.xml +44 -44
- package/html/vercel-cli-setup-guide.html +27 -3
- package/html/vercel-first-time-setup-guide.html +27 -3
- package/lib/config.js +3 -11
- package/lib/core-builder.js +7 -12
- package/lib/shared-auth-config.js +2 -10
- package/lib/supabase-auth.js +5 -11
- package/migrate-to-domain-auth.sql +47 -0
- package/package.json +1 -1
- package/setup-database-v2.sql +53 -0
- package/user-access-view.sql +49 -0
- package/user-management/README.md +9 -18
- package/user-management/add-users.sh +31 -11
package/package.json
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
-- Doc-builder Supabase Database Setup V2
|
|
2
|
+
-- Simplified schema using domains instead of site IDs
|
|
3
|
+
-- Run this in your Supabase SQL Editor
|
|
4
|
+
|
|
5
|
+
-- Drop old tables if migrating
|
|
6
|
+
-- DROP TABLE IF EXISTS docbuilder_access;
|
|
7
|
+
-- DROP TABLE IF EXISTS docbuilder_sites;
|
|
8
|
+
|
|
9
|
+
-- Single table for user access control
|
|
10
|
+
CREATE TABLE docbuilder_access (
|
|
11
|
+
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
12
|
+
domain TEXT NOT NULL,
|
|
13
|
+
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
14
|
+
PRIMARY KEY (user_id, domain)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
-- Create index for faster lookups
|
|
18
|
+
CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
|
|
19
|
+
|
|
20
|
+
-- Enable Row Level Security
|
|
21
|
+
ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
|
|
22
|
+
|
|
23
|
+
-- RLS Policy: Users can only see their own access
|
|
24
|
+
CREATE POLICY "Users see own access" ON docbuilder_access
|
|
25
|
+
FOR SELECT USING (user_id = auth.uid());
|
|
26
|
+
|
|
27
|
+
-- Example: Grant access to a user for a specific domain
|
|
28
|
+
-- INSERT INTO docbuilder_access (user_id, domain)
|
|
29
|
+
-- VALUES ('user-uuid-here', 'doc-builder-delta.vercel.app');
|
|
30
|
+
|
|
31
|
+
-- Example: Grant access to multiple users for a domain
|
|
32
|
+
-- INSERT INTO docbuilder_access (user_id, domain) VALUES
|
|
33
|
+
-- ('user-1-uuid', 'mydocs.vercel.app'),
|
|
34
|
+
-- ('user-2-uuid', 'mydocs.vercel.app'),
|
|
35
|
+
-- ('user-3-uuid', 'mydocs.vercel.app');
|
|
36
|
+
|
|
37
|
+
-- Example: Grant a user access to multiple domains
|
|
38
|
+
-- INSERT INTO docbuilder_access (user_id, domain) VALUES
|
|
39
|
+
-- ('user-uuid', 'docs.example.com'),
|
|
40
|
+
-- ('user-uuid', 'internal-docs.example.com'),
|
|
41
|
+
-- ('user-uuid', 'api-docs.example.com');
|
|
42
|
+
|
|
43
|
+
-- View all access for a domain (admin use)
|
|
44
|
+
-- SELECT u.email, da.created_at
|
|
45
|
+
-- FROM docbuilder_access da
|
|
46
|
+
-- JOIN auth.users u ON da.user_id = u.id
|
|
47
|
+
-- WHERE da.domain = 'mydocs.vercel.app';
|
|
48
|
+
|
|
49
|
+
-- Migration from old schema (if needed)
|
|
50
|
+
-- INSERT INTO docbuilder_access (user_id, domain)
|
|
51
|
+
-- SELECT da.user_id, ds.domain
|
|
52
|
+
-- FROM old_docbuilder_access da
|
|
53
|
+
-- JOIN docbuilder_sites ds ON da.site_id = ds.id;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
-- Create a view to easily see user access with email addresses
|
|
2
|
+
-- This makes it much easier to manage user access
|
|
3
|
+
|
|
4
|
+
-- Drop the view if it exists (to recreate with latest schema)
|
|
5
|
+
DROP VIEW IF EXISTS user_access_view;
|
|
6
|
+
|
|
7
|
+
-- Create the view joining docbuilder_access with auth.users
|
|
8
|
+
CREATE VIEW user_access_view AS
|
|
9
|
+
SELECT
|
|
10
|
+
u.email,
|
|
11
|
+
da.domain,
|
|
12
|
+
da.created_at as access_granted,
|
|
13
|
+
u.created_at as user_created,
|
|
14
|
+
u.last_sign_in_at,
|
|
15
|
+
u.id as user_id
|
|
16
|
+
FROM
|
|
17
|
+
docbuilder_access da
|
|
18
|
+
JOIN auth.users u ON da.user_id = u.id
|
|
19
|
+
ORDER BY
|
|
20
|
+
da.domain,
|
|
21
|
+
u.email;
|
|
22
|
+
|
|
23
|
+
-- Grant permissions to authenticated users to view their own records
|
|
24
|
+
GRANT SELECT ON user_access_view TO authenticated;
|
|
25
|
+
|
|
26
|
+
-- Example queries using the view:
|
|
27
|
+
|
|
28
|
+
-- 1. See all users for a specific domain
|
|
29
|
+
-- SELECT * FROM user_access_view WHERE domain = 'docs.example.com';
|
|
30
|
+
|
|
31
|
+
-- 2. See all domains a user has access to
|
|
32
|
+
-- SELECT * FROM user_access_view WHERE email = 'user@example.com';
|
|
33
|
+
|
|
34
|
+
-- 3. Count users per domain
|
|
35
|
+
-- SELECT domain, COUNT(*) as user_count
|
|
36
|
+
-- FROM user_access_view
|
|
37
|
+
-- GROUP BY domain
|
|
38
|
+
-- ORDER BY user_count DESC;
|
|
39
|
+
|
|
40
|
+
-- 4. Find users who haven't logged in recently
|
|
41
|
+
-- SELECT email, domain, last_sign_in_at
|
|
42
|
+
-- FROM user_access_view
|
|
43
|
+
-- WHERE last_sign_in_at < NOW() - INTERVAL '30 days'
|
|
44
|
+
-- OR last_sign_in_at IS NULL;
|
|
45
|
+
|
|
46
|
+
-- 5. Export all access for documentation
|
|
47
|
+
-- SELECT email, domain, access_granted
|
|
48
|
+
-- FROM user_access_view
|
|
49
|
+
-- ORDER BY domain, email;
|
|
@@ -217,10 +217,7 @@ Run the setup command:
|
|
|
217
217
|
|
|
218
218
|
### "Site not found"
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
./add-users.sh sites
|
|
223
|
-
```
|
|
220
|
+
With the new domain-based system, sites no longer need to be registered. Just use the domain directly when granting access.
|
|
224
221
|
|
|
225
222
|
### "User already exists"
|
|
226
223
|
|
|
@@ -232,29 +229,23 @@ The user already has access to this site. No action needed.
|
|
|
232
229
|
|
|
233
230
|
## đ Database Schema
|
|
234
231
|
|
|
235
|
-
The system uses
|
|
236
|
-
|
|
237
|
-
### docbuilder_sites
|
|
238
|
-
- `id` (UUID) - Primary key
|
|
239
|
-
- `domain` (TEXT) - Site URL without https://
|
|
240
|
-
- `name` (TEXT) - Display name
|
|
241
|
-
- `created_at` (TIMESTAMP)
|
|
232
|
+
The system uses a single table with domain-based access:
|
|
242
233
|
|
|
243
234
|
### docbuilder_access
|
|
244
235
|
- `user_id` (UUID) - References auth.users
|
|
245
|
-
- `
|
|
236
|
+
- `domain` (TEXT) - Site domain (e.g., docs.example.com)
|
|
246
237
|
- `created_at` (TIMESTAMP)
|
|
238
|
+
- Primary key on (user_id, domain)
|
|
247
239
|
|
|
248
240
|
## đ¯ Common Workflows
|
|
249
241
|
|
|
250
242
|
### Setting up a new documentation site
|
|
251
243
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
```
|
|
244
|
+
No site registration needed! Just add users with domain access:
|
|
245
|
+
```bash
|
|
246
|
+
./add-users.sh add my-docs.vercel.app user1@example.com
|
|
247
|
+
./add-users.sh add my-docs.vercel.app user2@example.com
|
|
248
|
+
```
|
|
258
249
|
|
|
259
250
|
### Onboarding multiple team members
|
|
260
251
|
|
|
@@ -18,8 +18,14 @@ NC='\033[0m' # No Color
|
|
|
18
18
|
# Configuration
|
|
19
19
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
20
20
|
CONFIG_FILE="$SCRIPT_DIR/.supabase-config"
|
|
21
|
+
ENV_FILE="$SCRIPT_DIR/.env"
|
|
21
22
|
PROJECT_ID="xcihhnfcitjrwbynxmka" # Default project ID
|
|
22
23
|
|
|
24
|
+
# Load .env file if exists
|
|
25
|
+
if [ -f "$ENV_FILE" ]; then
|
|
26
|
+
source "$ENV_FILE"
|
|
27
|
+
fi
|
|
28
|
+
|
|
23
29
|
# Load configuration if exists
|
|
24
30
|
if [ -f "$CONFIG_FILE" ]; then
|
|
25
31
|
source "$CONFIG_FILE"
|
|
@@ -209,7 +215,7 @@ execute_sql() {
|
|
|
209
215
|
|
|
210
216
|
# Method 1: Try using psql if DATABASE_URL is available
|
|
211
217
|
if [ ! -z "$DATABASE_URL" ]; then
|
|
212
|
-
local output=$(psql "$DATABASE_URL" -f "$temp_file" 2>&1)
|
|
218
|
+
local output=$(psql "$DATABASE_URL" -t -A -f "$temp_file" 2>&1)
|
|
213
219
|
local status=$?
|
|
214
220
|
rm "$temp_file"
|
|
215
221
|
|
|
@@ -219,15 +225,21 @@ execute_sql() {
|
|
|
219
225
|
fi
|
|
220
226
|
fi
|
|
221
227
|
|
|
222
|
-
# Method 2: Try
|
|
223
|
-
if command -v supabase &> /dev/null
|
|
224
|
-
|
|
225
|
-
local status
|
|
226
|
-
rm "$temp_file"
|
|
228
|
+
# Method 2: Try using supabase db dump to get connection details
|
|
229
|
+
if command -v supabase &> /dev/null; then
|
|
230
|
+
# Get database URL from supabase status
|
|
231
|
+
local db_url=$(supabase status --output json 2>/dev/null | grep -o '"db_url":"[^"]*' | cut -d'"' -f4)
|
|
227
232
|
|
|
228
|
-
if [
|
|
229
|
-
|
|
230
|
-
|
|
233
|
+
if [ ! -z "$db_url" ] && [ "$db_url" != "null" ]; then
|
|
234
|
+
# Try psql with the extracted URL
|
|
235
|
+
local output=$(psql "$db_url" -t -A -f "$temp_file" 2>&1)
|
|
236
|
+
local status=$?
|
|
237
|
+
rm "$temp_file"
|
|
238
|
+
|
|
239
|
+
if [ $status -eq 0 ]; then
|
|
240
|
+
echo "$output"
|
|
241
|
+
return 0
|
|
242
|
+
fi
|
|
231
243
|
fi
|
|
232
244
|
fi
|
|
233
245
|
|
|
@@ -257,9 +269,17 @@ create_user() {
|
|
|
257
269
|
# Check if user exists first
|
|
258
270
|
local check_sql="SELECT id, email FROM auth.users WHERE email = '$email';"
|
|
259
271
|
|
|
260
|
-
|
|
272
|
+
echo -e "${CYAN}Checking database for user...${NC}"
|
|
273
|
+
local result=$(execute_sql "$check_sql" 2>&1)
|
|
274
|
+
|
|
275
|
+
# Debug output
|
|
276
|
+
if [ ! -z "$DEBUG" ]; then
|
|
277
|
+
echo -e "${BLUE}[DEBUG] SQL Result:${NC}"
|
|
278
|
+
echo "$result"
|
|
279
|
+
fi
|
|
261
280
|
|
|
262
|
-
if
|
|
281
|
+
# Check if the result contains the email (case insensitive)
|
|
282
|
+
if echo "$result" | grep -qi "$email"; then
|
|
263
283
|
echo -e "${YELLOW}âšī¸ User already exists${NC}"
|
|
264
284
|
return 0
|
|
265
285
|
else
|