@knowcode/doc-builder 1.8.1 → 1.8.3

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 (46) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +4 -4
  3. package/cli.js +9 -40
  4. package/html/README.html +3 -3
  5. package/html/auth.js +2 -2
  6. package/html/documentation-index.html +3 -3
  7. package/html/guides/authentication-default-change.html +3 -3
  8. package/html/guides/authentication-guide.html +41 -49
  9. package/html/guides/claude-workflow-guide.html +3 -3
  10. package/html/guides/documentation-standards.html +3 -3
  11. package/html/guides/phosphor-icons-guide.html +3 -3
  12. package/html/guides/private-directory-authentication.html +51 -26
  13. package/html/guides/public-site-deployment.html +8 -9
  14. package/html/guides/search-engine-verification-guide.html +3 -3
  15. package/html/guides/seo-guide.html +3 -3
  16. package/html/guides/seo-optimization-guide.html +3 -3
  17. package/html/guides/troubleshooting-guide.html +3 -3
  18. package/html/guides/windows-setup-guide.html +3 -3
  19. package/html/index.html +3 -3
  20. package/html/js/auth.js +2 -2
  21. package/html/login.html +2 -2
  22. package/html/private/cache-control-anti-pattern.html +5 -4
  23. package/html/private/launch/README.html +5 -4
  24. package/html/private/launch/auth-cleanup-summary.html +5 -4
  25. package/html/private/launch/bubble-plugin-specification.html +5 -4
  26. package/html/private/launch/go-to-market-strategy.html +5 -4
  27. package/html/private/launch/launch-announcements.html +5 -4
  28. package/html/private/launch/vercel-deployment-auth-setup.html +27 -20
  29. package/html/private/next-steps-walkthrough.html +18 -44
  30. package/html/private/supabase-auth-implementation-completed.html +8 -7
  31. package/html/private/supabase-auth-implementation-plan.html +16 -32
  32. package/html/private/supabase-auth-integration-plan.html +34 -68
  33. package/html/private/supabase-auth-setup-guide.html +73 -83
  34. package/html/private/test-private-doc.html +5 -4
  35. package/html/private/user-management-tooling.html +581 -0
  36. package/html/sitemap.xml +49 -43
  37. package/html/vercel-cli-setup-guide.html +3 -3
  38. package/html/vercel-first-time-setup-guide.html +3 -3
  39. package/lib/config.js +6 -15
  40. package/lib/core-builder.js +3 -4
  41. package/lib/shared-auth-config.js +13 -0
  42. package/lib/supabase-auth.js +5 -11
  43. package/package.json +1 -1
  44. package/setup-database-v2.sql +53 -0
  45. package/user-management/README.md +16 -21
  46. package/user-management/add-users.sh +37 -11
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:20:52.442Z",
102
- "dateModified": "2025-07-26T10:20:52.442Z",
101
+ "datePublished": "2025-07-26T11:11:45.929Z",
102
+ "dateModified": "2025-07-26T11:11:45.929Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/private/supabase-auth-setup-guide.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.0">Last updated: Jul 26, 2025, 10:20 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144
 
@@ -223,7 +223,8 @@
223
223
  <a href="/private/supabase-auth-implementation-plan.html" class="nav-item" data-tooltip="Supabase Auth Implementation Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Implementation Plan</a>
224
224
  <a href="/private/supabase-auth-integration-plan.html" class="nav-item" data-tooltip="Supabase Authentication Integration Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Integration Plan</a>
225
225
  <a href="/private/supabase-auth-setup-guide.html" class="nav-item active" data-tooltip="@knowcode/doc-builder supports enterprise-grade authentication through Supabase."><i class="fas fa-file-alt"></i> Supabase Auth Setup Guide</a>
226
- <a href="/private/test-private-doc.html" class="nav-item" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a></div></div>
226
+ <a href="/private/test-private-doc.html" class="nav-item" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a>
227
+ <a href="/private/user-management-tooling.html" class="nav-item" data-tooltip="The user management system is a set of tools designed to manage user access to Supabase-authenticated documentation sites built with."><i class="fas fa-file-alt"></i> User Management Tooling</a></div></div>
227
228
  <div class="nav-section" data-level="2">
228
229
  <a class="nav-title collapsible" href="/private/launch/README.html" data-target="nav-private-launch-2" >
229
230
  <i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Launch
@@ -248,10 +249,11 @@
248
249
  <p>@knowcode/doc-builder supports enterprise-grade authentication through Supabase. This provides:</p>
249
250
  <ul>
250
251
  <li><strong>Secure authentication</strong> with industry-standard security practices</li>
251
- <li><strong>Multi-site support</strong> - one account can access multiple documentation sites</li>
252
+ <li><strong>Domain-based access</strong> - automatic authentication based on site domain</li>
252
253
  <li><strong>User management</strong> through CLI commands</li>
253
254
  <li><strong>Password reset</strong> functionality built-in</li>
254
255
  <li><strong>Enterprise features</strong> like audit logging and access control</li>
256
+ <li><strong>Zero configuration</strong> - built-in credentials (v1.8.2+)</li>
255
257
  </ul>
256
258
  <h2>Prerequisites</h2>
257
259
  <ol>
@@ -271,41 +273,30 @@
271
273
  <p>Wait for the project to be created (usually 1-2 minutes).</p>
272
274
  <h2>Step 2: Create Database Tables</h2>
273
275
  <p>In your Supabase dashboard, go to <strong>SQL Editor</strong> and run this SQL:</p>
274
- <pre><code class="language-sql">-- Table 1: Documentation sites
275
- CREATE TABLE docbuilder_sites (
276
- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
277
- domain TEXT UNIQUE NOT NULL,
278
- name TEXT NOT NULL,
279
- created_at TIMESTAMPTZ DEFAULT NOW()
280
- );
281
-
282
- -- Table 2: User access mapping
276
+ <pre><code class="language-sql">-- Single table for user access control (simplified!)
283
277
  CREATE TABLE docbuilder_access (
284
278
  user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
285
- site_id UUID REFERENCES docbuilder_sites(id) ON DELETE CASCADE,
279
+ domain TEXT NOT NULL,
286
280
  created_at TIMESTAMPTZ DEFAULT NOW(),
287
- PRIMARY KEY (user_id, site_id)
281
+ PRIMARY KEY (user_id, domain)
288
282
  );
289
283
 
284
+ -- Create index for faster lookups
285
+ CREATE INDEX idx_docbuilder_access_domain ON docbuilder_access(domain);
286
+
290
287
  -- Enable Row Level Security
291
- ALTER TABLE docbuilder_sites ENABLE ROW LEVEL SECURITY;
292
288
  ALTER TABLE docbuilder_access ENABLE ROW LEVEL SECURITY;
293
289
 
294
- -- RLS Policy: Users can only see sites they have access to
295
- CREATE POLICY &quot;Users see accessible sites&quot; ON docbuilder_sites
296
- FOR SELECT USING (
297
- EXISTS (
298
- SELECT 1 FROM docbuilder_access
299
- WHERE site_id = docbuilder_sites.id
300
- AND user_id = auth.uid()
301
- )
302
- );
303
-
304
- -- RLS Policy: Users can see their own access
290
+ -- RLS Policy: Users can only see their own access
305
291
  CREATE POLICY &quot;Users see own access&quot; ON docbuilder_access
306
292
  FOR SELECT USING (user_id = auth.uid());
307
293
  </code></pre>
308
- <h2>Step 3: Get Supabase Credentials</h2>
294
+ <h2>Step 3: Configure Authentication (Automatic in v1.8.2+)</h2>
295
+ <p>As of version 1.8.2, Supabase credentials are automatically configured! You have two options:</p>
296
+ <h3>Option 1: Use Built-in Credentials (Recommended)</h3>
297
+ <p>Simply create a <code>docs/private/</code> directory or set <code>authentication: &#39;supabase&#39;</code> in your config. The system will automatically use the shared authentication database.</p>
298
+ <h3>Option 2: Use Custom Supabase Project</h3>
299
+ <p>If you want to use your own Supabase project:</p>
309
300
  <ol>
310
301
  <li>In your Supabase dashboard, go to <strong>Settings</strong> → <strong>API</strong></li>
311
302
  <li>Copy these values:<ul>
@@ -316,16 +307,20 @@ CREATE POLICY &quot;Users see own access&quot; ON docbuilder_access
316
307
  </ol>
317
308
  <p><i class="ph ph-warning-circle" aria-label="warning"></i> <strong>Never share your service role key</strong> - only use the anon/public key for doc-builder.</p>
318
309
  <h2>Step 4: Initialize Authentication</h2>
319
- <p>Run the initialization command in your documentation project:</p>
320
- <pre><code class="language-bash">npx @knowcode/doc-builder auth:init
310
+ <h3>Option 1: Automatic Setup (v1.8.2+)</h3>
311
+ <p>Just create a config file or use the <code>--preset</code> flag:</p>
312
+ <pre><code class="language-javascript">// doc-builder.config.js
313
+ module.exports = {
314
+ siteName: &#39;My Documentation&#39;,
315
+
316
+ features: {
317
+ authentication: &#39;supabase&#39;
318
+ }
319
+ // No auth config needed - uses built-in credentials!
320
+ };
321
321
  </code></pre>
322
- <p>This will prompt you for:</p>
323
- <ul>
324
- <li>Your Supabase project URL</li>
325
- <li>Your Supabase anonymous key </li>
326
- <li>A name for your documentation site</li>
327
- </ul>
328
- <p>It creates a <code>doc-builder.config.js</code> file like this:</p>
322
+ <h3>Option 2: Custom Supabase Project</h3>
323
+ <p>If using your own Supabase project:</p>
329
324
  <pre><code class="language-javascript">module.exports = {
330
325
  siteName: &#39;My Documentation&#39;,
331
326
 
@@ -335,24 +330,13 @@ CREATE POLICY &quot;Users see own access&quot; ON docbuilder_access
335
330
 
336
331
  auth: {
337
332
  supabaseUrl: &#39;https://xxx.supabase.co&#39;,
338
- supabaseAnonKey: &#39;eyJ...&#39;,
339
- siteId: &#39;&#39; // Will be set in next step
333
+ supabaseAnonKey: &#39;eyJ...&#39;
334
+ // No siteId needed - uses domain automatically!
340
335
  }
341
336
  };
342
337
  </code></pre>
343
- <h2>Step 5: Add Your Site to Database</h2>
344
- <h3>Option A: Using SQL (Recommended)</h3>
345
- <p>In Supabase SQL Editor, run:</p>
346
- <pre><code class="language-sql">INSERT INTO docbuilder_sites (domain, name)
347
- VALUES (&#39;docs.yourcompany.com&#39;, &#39;Company Documentation&#39;)
348
- RETURNING id;
349
- </code></pre>
350
- <p>Copy the returned ID and update your config file&#39;s <code>siteId</code> field.</p>
351
- <h3>Option B: Using CLI (Coming Soon)</h3>
352
- <pre><code class="language-bash">npx @knowcode/doc-builder auth:add-site \
353
- --domain docs.yourcompany.com \
354
- --name &quot;Company Documentation&quot;
355
- </code></pre>
338
+ <h2>Step 5: No Site Registration Needed!</h2>
339
+ <p>The new domain-based system eliminates the need for site registration. The system automatically uses the current domain (e.g., <code>docs.example.com</code>) as the access key. Just grant users access to your domain in the next step.</p>
356
340
  <h2>Step 6: Create Your First User</h2>
357
341
  <h3>Method 1: Through Supabase Dashboard</h3>
358
342
  <ol>
@@ -366,14 +350,23 @@ RETURNING id;
366
350
  <p>Users can sign up when they visit your documentation site and try to log in.</p>
367
351
  <h2>Step 7: Grant User Access</h2>
368
352
  <h3>Using SQL:</h3>
369
- <pre><code class="language-sql">-- Replace with actual user ID and site ID
370
- INSERT INTO docbuilder_access (user_id, site_id)
371
- VALUES (&#39;user-uuid-here&#39;, &#39;site-uuid-here&#39;);
353
+ <pre><code class="language-sql">-- Grant access by domain (no site ID needed!)
354
+ INSERT INTO docbuilder_access (user_id, domain)
355
+ VALUES (
356
+ (SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;),
357
+ &#39;docs.yourcompany.com&#39;
358
+ );
359
+
360
+ -- Grant access to multiple domains
361
+ INSERT INTO docbuilder_access (user_id, domain) VALUES
362
+ ((SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;), &#39;docs.yourcompany.com&#39;),
363
+ ((SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;), &#39;staging-docs.yourcompany.com&#39;),
364
+ ((SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;), &#39;localhost:3000&#39;);
372
365
  </code></pre>
373
366
  <h3>Using CLI (Coming Soon):</h3>
374
367
  <pre><code class="language-bash">npx @knowcode/doc-builder auth:grant \
375
368
  --email user@example.com \
376
- --site-id your-site-uuid
369
+ --domain docs.yourcompany.com
377
370
  </code></pre>
378
371
  <h2>Step 8: Build and Deploy</h2>
379
372
  <pre><code class="language-bash"># Build with Supabase authentication
@@ -385,55 +378,52 @@ npx @knowcode/doc-builder deploy
385
378
  <p>Your documentation site now has secure authentication! <i class="ph ph-confetti" aria-label="party"></i></p>
386
379
  <h2>User Management</h2>
387
380
  <h3>List Users with Access</h3>
388
- <pre><code class="language-sql">SELECT u.email, da.created_at as granted_at
381
+ <pre><code class="language-sql">-- List all users for a specific domain
382
+ SELECT u.email, da.created_at as granted_at
389
383
  FROM docbuilder_access da
390
384
  JOIN auth.users u ON u.id = da.user_id
391
- WHERE da.site_id = &#39;your-site-id&#39;;
385
+ WHERE da.domain = &#39;docs.yourcompany.com&#39;;
392
386
  </code></pre>
393
387
  <h3>Revoke Access</h3>
394
- <pre><code class="language-sql">DELETE FROM docbuilder_access
388
+ <pre><code class="language-sql">-- Remove access for a specific domain
389
+ DELETE FROM docbuilder_access
395
390
  WHERE user_id = (SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;)
396
- AND site_id = &#39;your-site-id&#39;;
391
+ AND domain = &#39;docs.yourcompany.com&#39;;
397
392
  </code></pre>
398
393
  <h3>Reset User Password</h3>
399
394
  <p>Users can reset their own passwords through the login page &quot;Forgot Password&quot; link.</p>
400
395
  <h2>Environment Variables (Optional)</h2>
401
- <p>For better security, use environment variables:</p>
396
+ <p>For better security with custom Supabase projects, use environment variables:</p>
402
397
  <pre><code class="language-bash"># .env
403
398
  SUPABASE_URL=https://xxx.supabase.co
404
399
  SUPABASE_ANON_KEY=eyJ...
405
- DOC_SITE_ID=your-site-uuid
406
400
  </code></pre>
407
401
  <p>Update your config:</p>
408
402
  <pre><code class="language-javascript">module.exports = {
409
403
  auth: {
410
404
  supabaseUrl: process.env.SUPABASE_URL,
411
- supabaseAnonKey: process.env.SUPABASE_ANON_KEY,
412
- siteId: process.env.DOC_SITE_ID
405
+ supabaseAnonKey: process.env.SUPABASE_ANON_KEY
406
+ // No siteId needed - uses domain automatically!
413
407
  }
414
408
  };
415
409
  </code></pre>
416
410
  <h2>Multi-Site Setup</h2>
417
- <p>To use one Supabase project for multiple documentation sites:</p>
411
+ <p>The domain-based system makes multi-site setup incredibly simple:</p>
418
412
  <ol>
419
- <li>Add each site to the database:</li>
420
- </ol>
421
- <pre><code class="language-sql">INSERT INTO docbuilder_sites (domain, name) VALUES
422
- (&#39;docs.product1.com&#39;, &#39;Product 1 Docs&#39;),
423
- (&#39;internal.company.com&#39;, &#39;Internal Docs&#39;),
424
- (&#39;api.company.com&#39;, &#39;API Documentation&#39;);
425
- </code></pre>
426
- <ol start="2">
427
- <li><p>Create separate config files for each site with different <code>siteId</code> values</p>
413
+ <li><p><strong>No site registration needed</strong> - Each domain is automatically recognized</p>
428
414
  </li>
429
- <li><p>Grant users access to specific sites:</p>
415
+ <li><p><strong>Grant users access to multiple domains</strong>:</p>
430
416
  </li>
431
417
  </ol>
432
- <pre><code class="language-sql">-- User can access both Product 1 and Internal docs
433
- INSERT INTO docbuilder_access (user_id, site_id) VALUES
434
- (&#39;user-uuid&#39;, &#39;product1-site-uuid&#39;),
435
- (&#39;user-uuid&#39;, &#39;internal-site-uuid&#39;);
418
+ <pre><code class="language-sql">-- User can access multiple documentation sites
419
+ INSERT INTO docbuilder_access (user_id, domain) VALUES
420
+ ((SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;), &#39;docs.product1.com&#39;),
421
+ ((SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;), &#39;internal.company.com&#39;),
422
+ ((SELECT id FROM auth.users WHERE email = &#39;user@example.com&#39;), &#39;api.company.com&#39;);
436
423
  </code></pre>
424
+ <ol start="3">
425
+ <li><strong>Same configuration for all sites</strong> - Just deploy to different domains!</li>
426
+ </ol>
437
427
  <h2>Security Features</h2>
438
428
  <h3>What Supabase Provides</h3>
439
429
  <ul>
@@ -448,8 +438,8 @@ INSERT INTO docbuilder_access (user_id, site_id) VALUES
448
438
  <h3>Row Level Security</h3>
449
439
  <p>All data access is protected by RLS policies:</p>
450
440
  <ul>
451
- <li>Users can only see sites they have access to</li>
452
441
  <li>Users can only see their own access records</li>
442
+ <li>Domain-based access is automatically enforced</li>
453
443
  <li>No way to access other users&#39; data</li>
454
444
  </ul>
455
445
  <h2>Troubleshooting</h2>
@@ -462,8 +452,8 @@ INSERT INTO docbuilder_access (user_id, site_id) VALUES
462
452
  <h3>Users Can&#39;t Access Site</h3>
463
453
  <ul>
464
454
  <li>Verify the user exists in <code>auth.users</code> table</li>
465
- <li>Check that user has access in <code>docbuilder_access</code> table </li>
466
- <li>Confirm the <code>site_id</code> matches your config</li>
455
+ <li>Check that user has access in <code>docbuilder_access</code> table for the correct domain</li>
456
+ <li>Confirm the domain in the database matches your deployment URL</li>
467
457
  </ul>
468
458
  <h3>Login Page Not Working</h3>
469
459
  <ul>
@@ -98,8 +98,8 @@
98
98
  "name": "Knowcode Ltd",
99
99
  "url": "https://knowcode.tech"
100
100
  },
101
- "datePublished": "2025-07-26T10:20:52.443Z",
102
- "dateModified": "2025-07-26T10:20:52.443Z",
101
+ "datePublished": "2025-07-26T11:11:45.930Z",
102
+ "dateModified": "2025-07-26T11:11:45.930Z",
103
103
  "mainEntityOfPage": {
104
104
  "@type": "WebPage",
105
105
  "@id": "https://doc-builder-delta.vercel.app/private/test-private-doc.html"
@@ -138,7 +138,7 @@
138
138
 
139
139
  <div class="header-actions">
140
140
  <div class="deployment-info">
141
- <span class="deployment-date" title="Built with doc-builder v1.8.0">Last updated: Jul 26, 2025, 10:20 AM UTC</span>
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.2">Last updated: Jul 26, 2025, 11:11 AM UTC</span>
142
142
  </div>
143
143
 
144
144
 
@@ -223,7 +223,8 @@
223
223
  <a href="/private/supabase-auth-implementation-plan.html" class="nav-item" data-tooltip="Supabase Auth Implementation Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Implementation Plan</a>
224
224
  <a href="/private/supabase-auth-integration-plan.html" class="nav-item" data-tooltip="Supabase Authentication Integration Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Integration Plan</a>
225
225
  <a href="/private/supabase-auth-setup-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder supports enterprise-grade authentication through Supabase."><i class="fas fa-file-alt"></i> Supabase Auth Setup Guide</a>
226
- <a href="/private/test-private-doc.html" class="nav-item active" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a></div></div>
226
+ <a href="/private/test-private-doc.html" class="nav-item active" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a>
227
+ <a href="/private/user-management-tooling.html" class="nav-item" data-tooltip="The user management system is a set of tools designed to manage user access to Supabase-authenticated documentation sites built with."><i class="fas fa-file-alt"></i> User Management Tooling</a></div></div>
227
228
  <div class="nav-section" data-level="2">
228
229
  <a class="nav-title collapsible" href="/private/launch/README.html" data-target="nav-private-launch-2" >
229
230
  <i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Launch