@knowcode/doc-builder 1.7.4 → 1.7.6

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.
Files changed (71) hide show
  1. package/.claude/settings.local.json +6 -1
  2. package/CHANGELOG.md +50 -0
  3. package/README.md +47 -7
  4. package/RELEASE-NOTES-1.7.5.md +64 -0
  5. package/add-user-clive.sql +35 -0
  6. package/add-user-lindsay-fixed.sql +85 -0
  7. package/add-user-lindsay.sql +68 -0
  8. package/add-user-pmorgan.sql +35 -0
  9. package/add-user-robbie.sql +35 -0
  10. package/add-wru-users.sql +105 -0
  11. package/cli.js +223 -8
  12. package/grant-access.sql +15 -0
  13. package/html/README.html +14 -4
  14. package/html/auth.js +97 -0
  15. package/html/documentation-index.html +14 -4
  16. package/html/guides/authentication-default-change.html +302 -0
  17. package/html/guides/authentication-guide.html +32 -14
  18. package/html/guides/cache-control-anti-pattern.html +361 -0
  19. package/html/guides/claude-workflow-guide.html +14 -4
  20. package/html/guides/documentation-standards.html +14 -4
  21. package/html/guides/next-steps-walkthrough.html +638 -0
  22. package/html/guides/phosphor-icons-guide.html +14 -4
  23. package/html/guides/public-site-deployment.html +363 -0
  24. package/html/guides/search-engine-verification-guide.html +14 -4
  25. package/html/guides/seo-guide.html +14 -4
  26. package/html/guides/seo-optimization-guide.html +14 -4
  27. package/html/guides/supabase-auth-implementation-plan.html +543 -0
  28. package/html/guides/supabase-auth-integration-plan.html +671 -0
  29. package/html/guides/supabase-auth-setup-guide.html +498 -0
  30. package/html/guides/troubleshooting-guide.html +14 -4
  31. package/html/guides/vercel-deployment-auth-setup.html +337 -0
  32. package/html/guides/windows-setup-guide.html +14 -4
  33. package/html/index.html +14 -4
  34. package/html/launch/README.html +14 -4
  35. package/html/launch/bubble-plugin-specification.html +14 -4
  36. package/html/launch/go-to-market-strategy.html +14 -4
  37. package/html/launch/launch-announcements.html +14 -4
  38. package/html/login.html +102 -0
  39. package/html/logout.html +18 -0
  40. package/html/sitemap.xml +69 -21
  41. package/html/vercel-cli-setup-guide.html +14 -4
  42. package/html/vercel-first-time-setup-guide.html +14 -4
  43. package/lib/config.js +33 -29
  44. package/lib/core-builder.js +142 -88
  45. package/lib/supabase-auth.js +295 -0
  46. package/manage-users.sql +191 -0
  47. package/package.json +2 -1
  48. package/public-config.js +22 -0
  49. package/public-html/404.html +115 -0
  50. package/public-html/README.html +149 -0
  51. package/public-html/css/notion-style.css +2036 -0
  52. package/public-html/index.html +149 -0
  53. package/public-html/js/main.js +1485 -0
  54. package/quick-test-commands.md +40 -0
  55. package/recordings/Screenshot 2025-07-24 at 18.22.01.png +0 -0
  56. package/setup-database.sql +41 -0
  57. package/test-auth-config.js +17 -0
  58. package/test-docs/README.md +39 -0
  59. package/test-html/404.html +115 -0
  60. package/test-html/README.html +172 -0
  61. package/test-html/auth.js +97 -0
  62. package/test-html/css/notion-style.css +2036 -0
  63. package/test-html/index.html +172 -0
  64. package/test-html/js/auth.js +97 -0
  65. package/test-html/js/main.js +1485 -0
  66. package/test-html/login.html +102 -0
  67. package/test-html/logout.html +18 -0
  68. package/update-domain.sql +9 -0
  69. package/view-all-users.sql +40 -0
  70. package/wru-auth-config.js +17 -0
  71. /package/{assets → public-html}/js/auth.js +0 -0
@@ -29,7 +29,12 @@
29
29
  "Bash(mkdir:*)",
30
30
  "Bash(cp:*)",
31
31
  "Bash(./publish.sh)",
32
- "Bash(mv:*)"
32
+ "Bash(mv:*)",
33
+ "WebFetch(domain:convert-to-markdown.vercel.app)",
34
+ "Bash(pkill:*)",
35
+ "Bash(curl:*)",
36
+ "Bash(./cli.js build:*)",
37
+ "Bash(./cli.js deploy:*)"
33
38
  ],
34
39
  "deny": []
35
40
  }
package/CHANGELOG.md CHANGED
@@ -5,6 +5,56 @@ All notable changes to @knowcode/doc-builder will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.7.6] - 2025-07-25
9
+
10
+ ### Added
11
+ - **Attachment Support**: Automatically copy Excel files, PDFs, and other attachments to deployment
12
+ - New configuration option `features.attachments` (enabled by default)
13
+ - Configurable `attachmentTypes` array for supported file extensions
14
+ - `--no-attachments` flag for build and deploy commands to disable attachment copying
15
+ - Support for preserving directory structure when copying attachments
16
+ - Comprehensive file type support including:
17
+ - Documents: PDF, Excel, Word, PowerPoint, CSV, RTF
18
+ - Archives: ZIP, TAR, GZ, 7Z, RAR
19
+ - Images: PNG, JPG, JPEG, GIF, SVG, WEBP, ICO, BMP
20
+ - Data files: JSON, XML, YAML, YML, TOML
21
+ - Media: MP4, MP3, WAV, AVI, MOV
22
+
23
+ ### How it Works
24
+ - During build, doc-builder scans for attachment files in your docs directory
25
+ - Files with supported extensions are automatically copied to the output directory
26
+ - Directory structure is preserved (e.g., `docs/data/report.xlsx` → `html/data/report.xlsx`)
27
+ - Links in markdown files to these attachments will work seamlessly in the deployed site
28
+ - Feature is enabled by default but can be disabled with `--no-attachments` flag
29
+
30
+ ### Configuration
31
+ ```javascript
32
+ features: {
33
+ attachments: true // Enable/disable attachment copying
34
+ },
35
+ attachmentTypes: [
36
+ '.pdf', '.xlsx', '.docx', // ... etc
37
+ ]
38
+ ```
39
+
40
+ ## [1.7.5] - 2025-07-25
41
+
42
+ ### Changed
43
+ - **BREAKING**: Authentication is now disabled by default in all configurations
44
+ - Changed default `authentication: false` in both defaultConfig and notionInspiredPreset
45
+ - Public documentation sites now work out of the box without configuration
46
+ - Authentication must be explicitly enabled with `authentication: 'supabase'`
47
+
48
+ ### Added
49
+ - `--no-auth` flag for build command to override authentication settings
50
+ - `--no-auth` flag for deploy command to override authentication settings
51
+ - Documentation for public site deployment workflows
52
+ - Migration guide for authentication changes
53
+
54
+ ### Improved
55
+ - Simplified createDefaultConfig to only prompt for Supabase authentication
56
+ - Better alignment with common use case of public documentation
57
+
8
58
  ## [1.7.4] - 2025-07-24
9
59
 
10
60
  ### Fixed
package/README.md CHANGED
@@ -72,11 +72,12 @@ This aligns perfectly with our mission: beautiful documentation should be access
72
72
 
73
73
  ### 🎯 Advanced Features
74
74
  - 🔍 **SEO Optimized** - Meta tags & structured data
75
- - 🔐 **Authentication** - Password protection
75
+ - 🔐 **Optional Auth** - Supabase authentication (opt-in)
76
76
  - 📊 **Mermaid Diagrams** - Built-in diagram support
77
77
  - 🌙 **Dark Mode** - Automatic theme switching
78
78
  - ☁️ **Vercel Deploy** - One-command deployment
79
79
  - ✅ **Google Verification** - Search Console ready
80
+ - 📎 **Attachment Support** - Excel, PDF & more deploy with docs
80
81
 
81
82
  </td>
82
83
  </tr>
@@ -210,20 +211,56 @@ module.exports = {
210
211
 
211
212
  // Features
212
213
  features: {
213
- authentication: true,
214
+ authentication: 'supabase', // or false for no auth
214
215
  changelog: true,
215
216
  mermaid: true,
216
- darkMode: true
217
+ darkMode: true,
218
+ attachments: true // Copy PDFs, Excel files, etc. (default: true)
217
219
  },
218
220
 
219
- // Authentication
221
+ // Supabase Authentication
220
222
  auth: {
221
- username: 'admin',
222
- password: 'secret'
223
+ supabaseUrl: process.env.SUPABASE_URL,
224
+ supabaseAnonKey: process.env.SUPABASE_ANON_KEY,
225
+ siteId: process.env.DOC_SITE_ID
223
226
  }
224
227
  };
225
228
  ```
226
229
 
230
+ ### 🔐 Authentication Setup
231
+
232
+ For secure documentation sites, use Supabase authentication:
233
+
234
+ ```bash
235
+ # Initialize authentication
236
+ npx @knowcode/doc-builder auth:init
237
+
238
+ # Add your site to database
239
+ npx @knowcode/doc-builder auth:add-site --domain docs.example.com --name "My Docs"
240
+
241
+ # Grant user access
242
+ npx @knowcode/doc-builder auth:grant --email user@example.com --site-id xxx
243
+ ```
244
+
245
+ See the [Supabase Authentication Guide](docs/guides/supabase-auth-setup-guide.md) for complete setup instructions.
246
+
247
+ ### 📎 Attachment Support
248
+
249
+ doc-builder automatically copies attachment files (Excel, PDF, images, etc.) to your deployment:
250
+
251
+ - **Enabled by default** - No configuration needed
252
+ - **Preserves directory structure** - Files maintain their relative paths
253
+ - **Supported file types**:
254
+ - Documents: `.pdf`, `.doc`, `.docx`, `.xls`, `.xlsx`, `.csv`, `.ppt`, `.pptx`
255
+ - Images: `.png`, `.jpg`, `.jpeg`, `.gif`, `.svg`, `.webp`
256
+ - Archives: `.zip`, `.tar`, `.gz`, `.7z`, `.rar`
257
+ - Data files: `.json`, `.xml`, `.yaml`, `.yml`
258
+ - And more...
259
+
260
+ **Example**: If you have `docs/data/report.xlsx`, it will be copied to `html/data/report.xlsx` and links like `[Download Report](data/report.xlsx)` will work perfectly.
261
+
262
+ To disable attachment copying, use the `--no-attachments` flag with build or deploy commands.
263
+
227
264
  ## 📋 Commands Overview
228
265
 
229
266
  <table>
@@ -273,13 +310,14 @@ Options:
273
310
  -i, --input <dir> Input directory (default: docs)
274
311
  -o, --output <dir> Output directory (default: html)
275
312
  --preset <preset> Use a preset configuration
276
- --no-auth Disable authentication
277
313
  --no-changelog Disable changelog generation
314
+ --no-attachments Disable copying of attachment files
278
315
 
279
316
  Examples:
280
317
  doc-builder build # Build with defaults
281
318
  doc-builder build --input docs --output dist
282
319
  doc-builder build --preset notion-inspired
320
+ doc-builder build --no-attachments # Build without copying PDFs, Excel files, etc.
283
321
  ```
284
322
  </details>
285
323
 
@@ -294,11 +332,13 @@ Options:
294
332
  --no-prod Deploy as preview
295
333
  --force Force without confirmation
296
334
  --production-url <url> Override production URL
335
+ --no-attachments Disable copying of attachment files
297
336
 
298
337
  Examples:
299
338
  doc-builder deploy # Deploy to production
300
339
  doc-builder deploy --no-prod # Deploy as preview
301
340
  doc-builder deploy --production-url my-docs.vercel.app
341
+ doc-builder deploy --no-attachments # Deploy without attachment files
302
342
  ```
303
343
  </details>
304
344
 
@@ -0,0 +1,64 @@
1
+ # Release Notes - v1.7.5
2
+
3
+ ## 🎉 Major Change: Authentication is Now Optional by Default!
4
+
5
+ Starting with v1.7.5, @knowcode/doc-builder defaults to creating **public documentation sites** without authentication. This aligns with the most common use case and makes it even easier to get started.
6
+
7
+ ### What's New
8
+
9
+ #### 🔓 No Authentication by Default
10
+ - Documentation sites are now public by default
11
+ - No configuration needed for public docs
12
+ - Authentication must be explicitly enabled when needed
13
+
14
+ #### 🚀 New CLI Flags
15
+ - `--no-auth` flag for both build and deploy commands
16
+ - Override any authentication settings in your config
17
+ - Perfect for quick public deployments
18
+
19
+ ### Examples
20
+
21
+ ```bash
22
+ # Deploy public documentation (default behavior)
23
+ npx @knowcode/doc-builder deploy
24
+
25
+ # Force public deployment even if config has auth
26
+ npx @knowcode/doc-builder deploy --no-auth
27
+
28
+ # Enable authentication in config
29
+ # doc-builder.config.js
30
+ module.exports = {
31
+ features: {
32
+ authentication: 'supabase' // Explicitly enable
33
+ }
34
+ };
35
+ ```
36
+
37
+ ### Migration Guide
38
+
39
+ #### If you want PUBLIC documentation:
40
+ No changes needed! Your sites are now public by default.
41
+
42
+ #### If you want PRIVATE documentation:
43
+ Add this to your config:
44
+ ```javascript
45
+ features: {
46
+ authentication: 'supabase'
47
+ }
48
+ ```
49
+
50
+ ### Why This Change?
51
+
52
+ - Most documentation should be publicly accessible
53
+ - Reduces friction for new users
54
+ - Makes the tool more intuitive
55
+ - Authentication becomes an intentional choice
56
+
57
+ ### Full Changelog
58
+
59
+ - **Changed**: Authentication disabled by default in all configurations
60
+ - **Added**: `--no-auth` flags for build and deploy commands
61
+ - **Improved**: Simplified configuration prompts
62
+ - **Docs**: Added public site deployment guide
63
+
64
+ This is a breaking change, but one that makes the tool simpler and more aligned with common use cases.
@@ -0,0 +1,35 @@
1
+ -- =====================================================
2
+ -- ADD SINGLE USER: clive@hyperforma.co.uk
3
+ -- Site: https://wru-bid-analysis.vercel.app/
4
+ -- =====================================================
5
+
6
+ -- STEP 1: Check if clive@hyperforma.co.uk exists
7
+ SELECT email, id, created_at, last_sign_in_at
8
+ FROM auth.users
9
+ WHERE email = 'clive@hyperforma.co.uk';
10
+
11
+ -- If NO RESULTS above, create the user:
12
+ -- 1. Go to: https://supabase.com/dashboard/project/xcihhnfcitjrwbynxmka/auth/users
13
+ -- 2. Click "Invite user"
14
+ -- 3. Enter: clive@hyperforma.co.uk
15
+ -- 4. Click "Send invitation"
16
+
17
+ -- STEP 2: After user is created, grant access
18
+ INSERT INTO docbuilder_access (user_id, site_id)
19
+ VALUES (
20
+ (SELECT id FROM auth.users WHERE email = 'clive@hyperforma.co.uk'),
21
+ '4d8a53bf-dcdd-48c0-98e0-cd1451518735'
22
+ )
23
+ ON CONFLICT (user_id, site_id) DO NOTHING;
24
+
25
+ -- STEP 3: Verify access was granted
26
+ SELECT
27
+ u.email,
28
+ u.id as user_id,
29
+ da.created_at as access_granted,
30
+ ds.domain as site_domain
31
+ FROM docbuilder_access da
32
+ JOIN auth.users u ON u.id = da.user_id
33
+ JOIN docbuilder_sites ds ON ds.id = da.site_id
34
+ WHERE u.email = 'clive@hyperforma.co.uk'
35
+ AND da.site_id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
@@ -0,0 +1,85 @@
1
+ -- =====================================================
2
+ -- ADD SINGLE USER: lindsay@knowcode.tech
3
+ -- Site: https://wru-bid-analysis.vercel.app/
4
+ -- =====================================================
5
+
6
+ -- STEP 1: Update domain (only run once - you've already done this)
7
+ -- UPDATE docbuilder_sites
8
+ -- SET domain = 'wru-bid-analysis.vercel.app',
9
+ -- name = 'WRU Bid Analysis Documentation'
10
+ -- WHERE id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
11
+
12
+ -- =====================================================
13
+ -- STEP 2: CHECK IF USER EXISTS (RUN THIS FIRST!)
14
+ -- =====================================================
15
+ SELECT email, id, created_at
16
+ FROM auth.users
17
+ WHERE email = 'lindsay@knowcode.tech';
18
+
19
+ -- ⚠️ IF THE ABOVE QUERY RETURNS NO ROWS, YOU MUST CREATE THE USER FIRST!
20
+
21
+ -- =====================================================
22
+ -- STEP 3: CREATE USER IN SUPABASE (if not exists)
23
+ -- =====================================================
24
+ -- Go to: https://supabase.com/dashboard/project/xcihhnfcitjrwbynxmka/auth/users
25
+ -- 1. Click the "Invite user" button
26
+ -- 2. Enter email: lindsay@knowcode.tech
27
+ -- 3. Click "Send invitation"
28
+ -- 4. User will receive email to set password
29
+ -- 5. WAIT for user to appear in the auth.users table before continuing!
30
+
31
+ -- =====================================================
32
+ -- STEP 4: VERIFY USER NOW EXISTS
33
+ -- =====================================================
34
+ -- Run this again to get the user ID:
35
+ SELECT email, id
36
+ FROM auth.users
37
+ WHERE email = 'lindsay@knowcode.tech';
38
+
39
+ -- Copy the ID from above (it will look like: 123e4567-e89b-12d3-a456-426614174000)
40
+
41
+ -- =====================================================
42
+ -- STEP 5: GRANT ACCESS (only after user exists!)
43
+ -- =====================================================
44
+ -- Option A: If Step 4 returned a user, run this:
45
+ INSERT INTO docbuilder_access (user_id, site_id)
46
+ SELECT
47
+ u.id,
48
+ '4d8a53bf-dcdd-48c0-98e0-cd1451518735'
49
+ FROM auth.users u
50
+ WHERE u.email = 'lindsay@knowcode.tech'
51
+ AND EXISTS (
52
+ SELECT 1 FROM auth.users WHERE email = 'lindsay@knowcode.tech'
53
+ );
54
+
55
+ -- Option B: If you have the user ID from Step 4, use it directly:
56
+ -- INSERT INTO docbuilder_access (user_id, site_id)
57
+ -- VALUES (
58
+ -- 'paste-user-id-here',
59
+ -- '4d8a53bf-dcdd-48c0-98e0-cd1451518735'
60
+ -- );
61
+
62
+ -- =====================================================
63
+ -- STEP 6: VERIFY ACCESS WAS GRANTED
64
+ -- =====================================================
65
+ SELECT
66
+ u.email,
67
+ u.id as user_id,
68
+ da.created_at as access_granted
69
+ FROM docbuilder_access da
70
+ JOIN auth.users u ON u.id = da.user_id
71
+ WHERE u.email = 'lindsay@knowcode.tech';
72
+
73
+ -- =====================================================
74
+ -- TROUBLESHOOTING
75
+ -- =====================================================
76
+ -- If you still get errors, check:
77
+ -- 1. Does the user exist?
78
+ SELECT COUNT(*) as user_exists FROM auth.users WHERE email = 'lindsay@knowcode.tech';
79
+
80
+ -- 2. Do they already have access?
81
+ SELECT COUNT(*) as has_access
82
+ FROM docbuilder_access da
83
+ JOIN auth.users u ON u.id = da.user_id
84
+ WHERE u.email = 'lindsay@knowcode.tech'
85
+ AND da.site_id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
@@ -0,0 +1,68 @@
1
+ -- =====================================================
2
+ -- ADD SINGLE USER: lindsay@knowcode.tech
3
+ -- Site: https://wru-bid-analysis.vercel.app/
4
+ -- =====================================================
5
+
6
+ -- STEP 1: Update domain (only run once)
7
+ UPDATE docbuilder_sites
8
+ SET domain = 'wru-bid-analysis.vercel.app',
9
+ name = 'WRU Bid Analysis Documentation'
10
+ WHERE id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
11
+
12
+ -- Verify domain is correct
13
+ SELECT id, domain, name FROM docbuilder_sites
14
+ WHERE id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
15
+
16
+ -- =====================================================
17
+ -- STEP 2: Check if lindsay@knowcode.tech exists
18
+ -- =====================================================
19
+ SELECT email, id, created_at, last_sign_in_at
20
+ FROM auth.users
21
+ WHERE email = 'lindsay@knowcode.tech';
22
+
23
+ -- If NO RESULTS above, create the user:
24
+ -- 1. Go to: https://supabase.com/dashboard/project/xcihhnfcitjrwbynxmka/auth/users
25
+ -- 2. Click "Invite user"
26
+ -- 3. Enter: lindsay@knowcode.tech
27
+ -- 4. Click "Send invitation"
28
+
29
+ -- =====================================================
30
+ -- STEP 3: After user is created, grant access
31
+ -- =====================================================
32
+ -- Run this AFTER the user exists in Supabase
33
+ INSERT INTO docbuilder_access (user_id, site_id)
34
+ VALUES (
35
+ (SELECT id FROM auth.users WHERE email = 'lindsay@knowcode.tech'),
36
+ '4d8a53bf-dcdd-48c0-98e0-cd1451518735'
37
+ )
38
+ ON CONFLICT (user_id, site_id) DO NOTHING;
39
+
40
+ -- =====================================================
41
+ -- STEP 4: Verify access was granted
42
+ -- =====================================================
43
+ SELECT
44
+ u.email,
45
+ u.id as user_id,
46
+ da.created_at as access_granted,
47
+ ds.domain as site_domain
48
+ FROM docbuilder_access da
49
+ JOIN auth.users u ON u.id = da.user_id
50
+ JOIN docbuilder_sites ds ON ds.id = da.site_id
51
+ WHERE u.email = 'lindsay@knowcode.tech'
52
+ AND da.site_id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
53
+
54
+ -- Should show:
55
+ -- email: lindsay@knowcode.tech
56
+ -- access_granted: (timestamp)
57
+ -- site_domain: wru-bid-analysis.vercel.app
58
+
59
+ -- =====================================================
60
+ -- TROUBLESHOOTING
61
+ -- =====================================================
62
+ -- If access wasn't granted, check for errors:
63
+ SELECT id, email FROM auth.users WHERE email = 'lindsay@knowcode.tech';
64
+
65
+ -- If user can't log in after getting access:
66
+ -- 1. Clear browser cache
67
+ -- 2. Check they're using correct URL: https://wru-bid-analysis.vercel.app/
68
+ -- 3. Verify they set their password from invite email
@@ -0,0 +1,35 @@
1
+ -- =====================================================
2
+ -- ADD SINGLE USER: pmorgan@wru.cymru
3
+ -- Site: https://wru-bid-analysis.vercel.app/
4
+ -- =====================================================
5
+
6
+ -- STEP 1: Check if pmorgan@wru.cymru exists
7
+ SELECT email, id, created_at, last_sign_in_at
8
+ FROM auth.users
9
+ WHERE email = 'pmorgan@wru.cymru';
10
+
11
+ -- If NO RESULTS above, create the user:
12
+ -- 1. Go to: https://supabase.com/dashboard/project/xcihhnfcitjrwbynxmka/auth/users
13
+ -- 2. Click "Invite user"
14
+ -- 3. Enter: pmorgan@wru.cymru
15
+ -- 4. Click "Send invitation"
16
+
17
+ -- STEP 2: After user is created, grant access
18
+ INSERT INTO docbuilder_access (user_id, site_id)
19
+ VALUES (
20
+ (SELECT id FROM auth.users WHERE email = 'pmorgan@wru.cymru'),
21
+ '4d8a53bf-dcdd-48c0-98e0-cd1451518735'
22
+ )
23
+ ON CONFLICT (user_id, site_id) DO NOTHING;
24
+
25
+ -- STEP 3: Verify access was granted
26
+ SELECT
27
+ u.email,
28
+ u.id as user_id,
29
+ da.created_at as access_granted,
30
+ ds.domain as site_domain
31
+ FROM docbuilder_access da
32
+ JOIN auth.users u ON u.id = da.user_id
33
+ JOIN docbuilder_sites ds ON ds.id = da.site_id
34
+ WHERE u.email = 'pmorgan@wru.cymru'
35
+ AND da.site_id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
@@ -0,0 +1,35 @@
1
+ -- =====================================================
2
+ -- ADD SINGLE USER: robbie.macintosh@marbledropper.com
3
+ -- Site: https://wru-bid-analysis.vercel.app/
4
+ -- =====================================================
5
+
6
+ -- STEP 1: Check if robbie.macintosh@marbledropper.com exists
7
+ SELECT email, id, created_at, last_sign_in_at
8
+ FROM auth.users
9
+ WHERE email = 'robbie.macintosh@marbledropper.com';
10
+
11
+ -- If NO RESULTS above, create the user:
12
+ -- 1. Go to: https://supabase.com/dashboard/project/xcihhnfcitjrwbynxmka/auth/users
13
+ -- 2. Click "Invite user"
14
+ -- 3. Enter: robbie.macintosh@marbledropper.com
15
+ -- 4. Click "Send invitation"
16
+
17
+ -- STEP 2: After user is created, grant access
18
+ INSERT INTO docbuilder_access (user_id, site_id)
19
+ VALUES (
20
+ (SELECT id FROM auth.users WHERE email = 'robbie.macintosh@marbledropper.com'),
21
+ '4d8a53bf-dcdd-48c0-98e0-cd1451518735'
22
+ )
23
+ ON CONFLICT (user_id, site_id) DO NOTHING;
24
+
25
+ -- STEP 3: Verify access was granted
26
+ SELECT
27
+ u.email,
28
+ u.id as user_id,
29
+ da.created_at as access_granted,
30
+ ds.domain as site_domain
31
+ FROM docbuilder_access da
32
+ JOIN auth.users u ON u.id = da.user_id
33
+ JOIN docbuilder_sites ds ON ds.id = da.site_id
34
+ WHERE u.email = 'robbie.macintosh@marbledropper.com'
35
+ AND da.site_id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
@@ -0,0 +1,105 @@
1
+ -- =====================================================
2
+ -- ADD USERS TO WRU BID ANALYSIS DOCUMENTATION
3
+ -- Site: https://wru-bid-analysis.vercel.app/
4
+ -- Date: 2025-07-25
5
+ -- =====================================================
6
+
7
+ -- STEP 1: Update the domain to match your Vercel deployment
8
+ UPDATE docbuilder_sites
9
+ SET domain = 'wru-bid-analysis.vercel.app',
10
+ name = 'WRU Bid Analysis Documentation'
11
+ WHERE id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
12
+
13
+ -- Verify the domain update
14
+ SELECT id, domain, name FROM docbuilder_sites
15
+ WHERE id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
16
+
17
+ -- =====================================================
18
+ -- STEP 2: CHECK IF USERS EXIST
19
+ -- =====================================================
20
+ -- Run this first to see which users already exist
21
+ SELECT email, id, created_at
22
+ FROM auth.users
23
+ WHERE email IN (
24
+ 'pmorgan@wru.cymru',
25
+ 'clive@hyperforma.co.uk',
26
+ 'robbie.macintosh@marbledropper.com',
27
+ 'lindsay@knowcode.tech'
28
+ );
29
+
30
+ -- =====================================================
31
+ -- IMPORTANT: CREATE MISSING USERS FIRST!
32
+ -- =====================================================
33
+ -- For any users that don't exist above:
34
+ -- 1. Go to Supabase Dashboard: https://supabase.com/dashboard/project/xcihhnfcitjrwbynxmka
35
+ -- 2. Navigate to Authentication → Users
36
+ -- 3. Click "Invite user"
37
+ -- 4. Enter each missing email address
38
+ -- 5. They'll receive an email to set their password
39
+
40
+ -- =====================================================
41
+ -- STEP 3: GRANT ACCESS TO ALL USERS
42
+ -- =====================================================
43
+ -- Run this after all users have been created
44
+ WITH users_to_add AS (
45
+ SELECT email FROM (VALUES
46
+ ('pmorgan@wru.cymru'),
47
+ ('clive@hyperforma.co.uk'),
48
+ ('robbie.macintosh@marbledropper.com'),
49
+ ('lindsay@knowcode.tech')
50
+ ) AS t(email)
51
+ )
52
+ INSERT INTO docbuilder_access (user_id, site_id)
53
+ SELECT u.id, '4d8a53bf-dcdd-48c0-98e0-cd1451518735'
54
+ FROM auth.users u
55
+ JOIN users_to_add ua ON u.email = ua.email
56
+ WHERE NOT EXISTS (
57
+ -- This prevents duplicate entries if someone already has access
58
+ SELECT 1 FROM docbuilder_access
59
+ WHERE user_id = u.id AND site_id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735'
60
+ );
61
+
62
+ -- =====================================================
63
+ -- STEP 4: VERIFY ACCESS WAS GRANTED
64
+ -- =====================================================
65
+ -- Check who now has access to the site
66
+ SELECT
67
+ u.email,
68
+ u.created_at as user_created,
69
+ da.created_at as access_granted,
70
+ CASE
71
+ WHEN u.last_sign_in_at IS NULL THEN 'Never logged in'
72
+ ELSE 'Has logged in'
73
+ END as login_status
74
+ FROM docbuilder_access da
75
+ JOIN auth.users u ON u.id = da.user_id
76
+ WHERE da.site_id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735'
77
+ ORDER BY da.created_at DESC;
78
+
79
+ -- =====================================================
80
+ -- TROUBLESHOOTING
81
+ -- =====================================================
82
+
83
+ -- If someone can't log in, check if they exist:
84
+ SELECT * FROM auth.users WHERE email = 'user@example.com';
85
+
86
+ -- If someone still can't access after login, verify their access:
87
+ SELECT * FROM docbuilder_access
88
+ WHERE user_id = (SELECT id FROM auth.users WHERE email = 'user@example.com')
89
+ AND site_id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
90
+
91
+ -- To remove a user's access:
92
+ -- DELETE FROM docbuilder_access
93
+ -- WHERE user_id = (SELECT id FROM auth.users WHERE email = 'user@example.com')
94
+ -- AND site_id = '4d8a53bf-dcdd-48c0-98e0-cd1451518735';
95
+
96
+ -- =====================================================
97
+ -- USERS BEING ADDED:
98
+ -- =====================================================
99
+ -- 1. pmorgan@wru.cymru
100
+ -- 2. clive@hyperforma.co.uk
101
+ -- 3. robbie.macintosh@marbledropper.com
102
+ -- 4. lindsay@knowcode.tech
103
+ --
104
+ -- Site URL: https://wru-bid-analysis.vercel.app/
105
+ -- Site ID: 4d8a53bf-dcdd-48c0-98e0-cd1451518735