@tailor-platform/sdk 1.4.2 → 1.6.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/dist/application-D5kzHyuG.mjs +5 -0
  3. package/dist/{list-QT92XcP3.mjs → application-D9mwb5eH.mjs} +2349 -11656
  4. package/dist/application-D9mwb5eH.mjs.map +1 -0
  5. package/dist/auth-0Zh4xp4z.mjs +772 -0
  6. package/dist/auth-0Zh4xp4z.mjs.map +1 -0
  7. package/dist/cli/index.mjs +247 -26
  8. package/dist/cli/index.mjs.map +1 -1
  9. package/dist/cli/lib.d.mts +292 -20
  10. package/dist/cli/lib.mjs +4 -3
  11. package/dist/cli/lib.mjs.map +1 -1
  12. package/dist/configure/index.d.mts +3 -3
  13. package/dist/configure/index.mjs +40 -5
  14. package/dist/configure/index.mjs.map +1 -1
  15. package/dist/{index-lDsl6VDv.d.mts → index-C_yeYBC8.d.mts} +45 -10
  16. package/dist/{types-BWzDv7TK.d.mts → index-k5hWCs5L.d.mts} +885 -861
  17. package/dist/{jiti-31_Wx1yz.mjs → jiti-SMSW3TA0.mjs} +1 -1
  18. package/dist/{jiti-31_Wx1yz.mjs.map → jiti-SMSW3TA0.mjs.map} +1 -1
  19. package/dist/job-8XfvLyxH.mjs +21 -0
  20. package/dist/job-8XfvLyxH.mjs.map +1 -0
  21. package/dist/list-C_lrs5OC.mjs +11935 -0
  22. package/dist/list-C_lrs5OC.mjs.map +1 -0
  23. package/dist/{src-Bhwd-tei.mjs → src-qLXX6nub.mjs} +1 -1
  24. package/dist/{src-Bhwd-tei.mjs.map → src-qLXX6nub.mjs.map} +1 -1
  25. package/dist/utils/test/index.d.mts +4 -3
  26. package/dist/utils/test/index.mjs +3 -1
  27. package/dist/utils/test/index.mjs.map +1 -1
  28. package/docs/cli/application.md +23 -187
  29. package/docs/cli/tailordb.md +621 -0
  30. package/docs/cli-reference.md +31 -15
  31. package/docs/services/auth.md +35 -1
  32. package/docs/testing.md +81 -0
  33. package/package.json +11 -1
  34. package/dist/config-CBpYlVa-.mjs +0 -664
  35. package/dist/config-CBpYlVa-.mjs.map +0 -1
  36. package/dist/list-QT92XcP3.mjs.map +0 -1
@@ -0,0 +1,621 @@
1
+ # TailorDB Commands
2
+
3
+ Commands for managing TailorDB tables, data, and schema migrations.
4
+
5
+ ## tailordb truncate
6
+
7
+ Truncate (delete all records from) TailorDB tables.
8
+
9
+ ```bash
10
+ tailor-sdk tailordb truncate [types...] [options]
11
+ ```
12
+
13
+ **Arguments:**
14
+
15
+ - `types...` - Space-separated list of type names to truncate (optional)
16
+
17
+ **Options:**
18
+
19
+ - `-a, --all` - Truncate all tables in all namespaces
20
+ - `-n, --namespace` - Truncate all tables in the specified namespace
21
+ - `-y, --yes` - Skip confirmation prompt
22
+ - `-w, --workspace-id` - ID of the workspace
23
+ - `-p, --profile` - Workspace profile to use
24
+ - `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
25
+
26
+ **Usage Examples:**
27
+
28
+ ```bash
29
+ # Truncate all tables in all namespaces (requires confirmation)
30
+ tailor-sdk tailordb truncate --all
31
+
32
+ # Truncate all tables in all namespaces (skip confirmation)
33
+ tailor-sdk tailordb truncate --all --yes
34
+
35
+ # Truncate all tables in a specific namespace
36
+ tailor-sdk tailordb truncate --namespace myNamespace
37
+
38
+ # Truncate specific types (namespace is auto-detected)
39
+ tailor-sdk tailordb truncate User Post Comment
40
+
41
+ # Truncate specific types with confirmation skipped
42
+ tailor-sdk tailordb truncate User Post --yes
43
+ ```
44
+
45
+ **Notes:**
46
+
47
+ - You must specify exactly one of: `--all`, `--namespace`, or type names
48
+ - When truncating specific types, the namespace is automatically detected from your config
49
+ - Confirmation prompts vary based on the operation:
50
+ - `--all`: requires typing `truncate all`
51
+ - `--namespace`: requires typing `truncate <namespace-name>`
52
+ - Specific types: requires typing `yes`
53
+ - Use `--yes` flag to skip confirmation prompts (useful for scripts and CI/CD)
54
+
55
+ ## tailordb migration
56
+
57
+ Manage TailorDB schema migrations. Migrations allow you to safely evolve your database schema with data transformations.
58
+
59
+ ```bash
60
+ tailor-sdk tailordb migration <subcommand> [options]
61
+ ```
62
+
63
+ ### Overview
64
+
65
+ The migration system detects field-level schema differences between your local type definitions and the previous snapshot, then generates migration files to safely apply those changes with data transformations.
66
+
67
+ **Key Features:**
68
+
69
+ - **Local snapshot-based diff detection** between current types and previous migration snapshot
70
+ - **Transaction-wrapped data migrations** for atomicity - all changes commit or rollback together
71
+ - **Automatic execution during apply** - pending migrations run as part of `tailor-sdk apply`
72
+ - **TypeScript migration scripts** - type-safe data transformations using Kysely
73
+
74
+ ### tailordb migration generate
75
+
76
+ Generate migration files by detecting schema differences between current local types and the previous migration snapshot.
77
+
78
+ ```bash
79
+ tailor-sdk tailordb migration generate [options]
80
+ ```
81
+
82
+ **Options:**
83
+
84
+ - `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
85
+ - `-n, --name` - Optional description for the migration
86
+ - `-y, --yes` - Skip confirmation prompts
87
+ - `--init` - Delete existing migrations and start fresh
88
+
89
+ **Usage Examples:**
90
+
91
+ ```bash
92
+ # Generate migration for all schema changes
93
+ tailor-sdk tailordb migration generate
94
+
95
+ # Generate with a description
96
+ tailor-sdk tailordb migration generate --name "add email field to user"
97
+
98
+ # Generate without confirmation prompts
99
+ tailor-sdk tailordb migration generate --yes
100
+
101
+ # Delete existing migrations and start fresh (with confirmation)
102
+ tailor-sdk tailordb migration generate --init
103
+
104
+ # Delete existing migrations and start fresh (skip confirmation)
105
+ tailor-sdk tailordb migration generate --init --yes
106
+ ```
107
+
108
+ **Generated Files:**
109
+
110
+ Each migration creates a directory in the migrations folder with a 4-digit sequential number:
111
+
112
+ | File | Description |
113
+ | ------------------ | -------------------------------------------------- |
114
+ | `0000/schema.json` | Initial schema snapshot (first migration only) |
115
+ | `XXXX/diff.json` | Schema diff from previous snapshot |
116
+ | `XXXX/migrate.ts` | Data migration script (only when breaking changes) |
117
+ | `XXXX/db.ts` | Generated Kysely types for the migration script |
118
+
119
+ **Migration Script Structure:**
120
+
121
+ ```typescript
122
+ import type { Transaction } from "./db";
123
+
124
+ export async function main(trx: Transaction): Promise<void> {
125
+ // Your data migration logic here
126
+ // All operations use the transaction object (trx)
127
+ await trx.updateTable("User").set({ newField: "default value" }).execute();
128
+ }
129
+ ```
130
+
131
+ The `db.ts` file contains Kysely Transaction types that reflect the schema state **before** the migration runs. This ensures type-safe data transformations based on the actual database structure at that point in time.
132
+
133
+ The `main` function receives a Kysely transaction object. All database operations should use this `trx` object to ensure atomicity - if any operation fails, all changes are rolled back.
134
+
135
+ **Editor Integration:**
136
+
137
+ If the `EDITOR` environment variable is set, the generated script file will automatically open in your preferred editor:
138
+
139
+ ```bash
140
+ export EDITOR=vim
141
+ tailor-sdk tailordb migration generate
142
+ # → After generation, vim opens XXXX/migrate.ts
143
+ ```
144
+
145
+ ### tailordb migration set
146
+
147
+ Manually set the migration checkpoint to a specific number. This is useful for skipping failed migrations or resetting migration state.
148
+
149
+ ```bash
150
+ tailor-sdk tailordb migration set <number> [options]
151
+ ```
152
+
153
+ **Arguments:**
154
+
155
+ - `number` - Migration number to set (e.g., `0001` or `1`)
156
+
157
+ **Options:**
158
+
159
+ - `-n, --namespace` - Target TailorDB namespace (required if multiple exist)
160
+ - `-y, --yes` - Skip confirmation prompt
161
+ - `-w, --workspace-id` - ID of the workspace
162
+ - `-p, --profile` - Workspace profile to use
163
+ - `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
164
+
165
+ **Usage Examples:**
166
+
167
+ ```bash
168
+ # Set migration checkpoint to 0001 (with confirmation)
169
+ tailor-sdk tailordb migration set 1
170
+
171
+ # Set migration checkpoint without confirmation
172
+ tailor-sdk tailordb migration set 1 --yes
173
+
174
+ # Set for specific namespace
175
+ tailor-sdk tailordb migration set 2 --namespace tailordb
176
+
177
+ # Reset to initial state (all migrations become pending)
178
+ tailor-sdk tailordb migration set 0 --yes
179
+ ```
180
+
181
+ **Warning:**
182
+
183
+ Setting the migration checkpoint changes which migrations will be executed on next apply:
184
+
185
+ - **Forward** (e.g., 0001 → 0003): Skips migrations 0002 and 0003
186
+ - **Backward** (e.g., 0003 → 0001): Migrations 0002 and 0003 become pending and will re-execute
187
+
188
+ The command always displays a warning and requires confirmation unless `--yes` is specified.
189
+
190
+ ### tailordb migration status
191
+
192
+ Show the current migration status for TailorDB namespaces, including applied and pending migrations.
193
+
194
+ ```bash
195
+ tailor-sdk tailordb migration status [options]
196
+ ```
197
+
198
+ **Options:**
199
+
200
+ - `-n, --namespace` - Show status for specific namespace only
201
+ - `-w, --workspace-id` - ID of the workspace
202
+ - `-p, --profile` - Workspace profile to use
203
+ - `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
204
+
205
+ **Usage Examples:**
206
+
207
+ ```bash
208
+ # Show status for all namespaces
209
+ tailor-sdk tailordb migration status
210
+
211
+ # Show status for specific namespace
212
+ tailor-sdk tailordb migration status --namespace tailordb
213
+ ```
214
+
215
+ **Example Output:**
216
+
217
+ ```
218
+ Namespace: tailordb
219
+ Current migration: 0001
220
+ Pending migrations:
221
+ - 0002: Add email field to user
222
+ - 0003: Remove deprecated status field
223
+ ```
224
+
225
+ ## Configuration
226
+
227
+ Configure migrations in `tailor.config.ts`:
228
+
229
+ ```typescript
230
+ export default defineConfig({
231
+ name: "my-app",
232
+ db: {
233
+ tailordb: {
234
+ files: ["./tailordb/*.ts"],
235
+ migration: {
236
+ directory: "./migrations",
237
+ // Optional: specify machine user for migration script execution
238
+ // If not specified, the first machine user from auth.machineUsers is used
239
+ machineUser: "admin-machine-user",
240
+ },
241
+ },
242
+ },
243
+ });
244
+ ```
245
+
246
+ ### Configuration Options
247
+
248
+ | Option | Type | Description |
249
+ | ----------------------- | -------- | ------------------------------------------------------------------------------------------------------------------ |
250
+ | `files` | string[] | Glob patterns for TailorDB type definition files |
251
+ | `ignores` | string[] | Glob patterns to ignore |
252
+ | `migration.directory` | string | Directory path for migration files |
253
+ | `migration.machineUser` | string | Machine user name for migration script execution (optional, defaults to first machine user from auth.machineUsers) |
254
+
255
+ ### Machine User Selection
256
+
257
+ When executing migration scripts, the system selects a machine user in the following priority:
258
+
259
+ 1. **Explicit configuration**: `migration.machineUser` in db config
260
+ 2. **Auto-selection**: First machine user from `auth.machineUsers`
261
+
262
+ The machine user being used is logged during migration execution.
263
+
264
+ ## Migration Directory Structure
265
+
266
+ Migrations use a directory-based structure with 4-digit sequential numbering:
267
+
268
+ ```
269
+ migrations/
270
+ ├── 0000/ # Initial schema (number 0)
271
+ │ └── schema.json # Full schema snapshot
272
+ ├── 0001/ # First change
273
+ │ ├── diff.json # Schema diff
274
+ │ ├── migrate.ts # Migration script (if breaking changes)
275
+ │ └── db.ts # Kysely types (if breaking changes)
276
+ ├── 0002/ # Second change
277
+ │ └── diff.json
278
+ └── ...
279
+ ```
280
+
281
+ - `0000` - Initial schema snapshot (always starts at 0)
282
+ - `0001` - First schema change
283
+ - `0002` - Second schema change, etc.
284
+
285
+ ## Supported Schema Changes
286
+
287
+ | Change Type | Breaking? | Migration Script | Notes |
288
+ | ------------------------------- | --------- | ---------------- | --------------------------------------------- |
289
+ | Add optional field | No | No | Schema change only |
290
+ | Add required field | Yes | Yes | Script populates default values |
291
+ | Remove field | No | No | Schema change only - data is preserved |
292
+ | Change optional→required | Yes | Yes | Script sets defaults for null values |
293
+ | Change required→optional | No | No | Schema change only |
294
+ | Add index | No | No | Schema change only |
295
+ | Remove index | No | No | Schema change only |
296
+ | Add unique constraint | Yes | Yes | Script must resolve duplicate values |
297
+ | Remove unique constraint | No | No | Schema change only |
298
+ | Add enum value | No | No | Schema change only |
299
+ | Remove enum value | Yes | Yes | Script migrates records with removed values |
300
+ | Add type | No | No | Schema change only |
301
+ | Remove type | No | No | Schema change only - data is preserved |
302
+ | Change field type | - | - | **Not supported** - requires 3-step migration |
303
+ | Change array to single value | - | - | **Not supported** - requires 3-step migration |
304
+ | Change single value to array | - | - | **Not supported** - requires 3-step migration |
305
+ | Change foreign key relationship | Yes | Yes | Script updates existing references |
306
+
307
+ ### Unsupported Schema Changes
308
+
309
+ The following changes require a 3-step migration process:
310
+
311
+ #### Field Type Change
312
+
313
+ Field type changes (e.g., `string` → `integer`) are not directly supported. Use this migration strategy:
314
+
315
+ 1. **Migration 1**: Add a new field with the desired type (e.g., `fieldName_new`) and migrate data
316
+ 2. **Migration 2**: Remove the old field
317
+ 3. **Migration 3**: Add the field with the original name and new type, migrate data from temporary field, then remove temporary field
318
+
319
+ #### Array Property Change
320
+
321
+ Changing between single value and array (e.g., `array: false` → `array: true`) is not directly supported. Use the same 3-step migration strategy as field type changes.
322
+
323
+ ## Example Workflow
324
+
325
+ 1. **Modify your type definition:**
326
+
327
+ ```typescript
328
+ // tailordb/user.ts
329
+ export const user = db.type("User", {
330
+ name: db.string(),
331
+ email: db.string(), // ← New required field
332
+ ...db.fields.timestamps(),
333
+ });
334
+ ```
335
+
336
+ 2. **Generate migration:**
337
+
338
+ ```bash
339
+ tailor-sdk tailordb migration generate
340
+ # Output: Generated migration 0001
341
+ # Diff file: ./migrations/0001/diff.json
342
+ # Migration script: ./migrations/0001/migrate.ts
343
+ # DB types: ./migrations/0001/db.ts
344
+ ```
345
+
346
+ 3. **Edit the migration script** (`0001/migrate.ts`):
347
+
348
+ ```typescript
349
+ import type { Transaction } from "./db";
350
+
351
+ export async function main(trx: Transaction): Promise<void> {
352
+ await trx
353
+ .updateTable("User")
354
+ .set({ email: "default@example.com" })
355
+ .where("email", "is", null)
356
+ .execute();
357
+ }
358
+ ```
359
+
360
+ 4. **Apply migration:**
361
+ ```bash
362
+ tailor-sdk apply
363
+ # Migrations are automatically executed during apply
364
+ ```
365
+
366
+ ## Automatic Migration Execution
367
+
368
+ When running `tailor-sdk apply`, pending migration scripts are automatically executed as part of the deployment process.
369
+
370
+ ### How It Works
371
+
372
+ 1. **Pending Migration Detection**: Identifies migration scripts that haven't been executed yet
373
+ 2. **Two-Stage Type Update**: For breaking changes (required fields, type changes):
374
+ - **Pre-Migration**: New fields are added as `optional` first
375
+ - **Script Execution**: Migration scripts run to populate data
376
+ - **Post-Migration**: Fields are changed to `required`, deletions are applied
377
+
378
+ ### Execution Flow
379
+
380
+ ```
381
+ tailor-sdk apply
382
+
383
+ ├── Detect Pending Migrations
384
+
385
+ ├── [If pending migrations exist]
386
+ │ ├── Pre-Migration: Add fields as optional
387
+ │ ├── Execute Migration Scripts (TestExecScript API)
388
+ │ └── Post-Migration: Apply required, deletions
389
+
390
+ └── Continue with normal apply flow
391
+ ```
392
+
393
+ ### Requirements for Automatic Migration
394
+
395
+ 1. **Migrations configured**: `migrations` path set in db config
396
+ 2. **Auth configured**: Auth service with machine users
397
+ 3. **Kysely generator**: `@tailor-platform/kysely-type` generator configured
398
+
399
+ ### Schema Verification
400
+
401
+ By default, `tailor-sdk apply` performs two schema verifications:
402
+
403
+ 1. **Local schema check**: Ensures local type definitions match the migration snapshot
404
+ 2. **Remote schema check**: Ensures remote schema matches the expected state based on migration history
405
+
406
+ If remote schema drift is detected, you'll see an error like:
407
+
408
+ ```
409
+ ✖ Remote schema drift detected:
410
+ Namespace: tailordb
411
+ Remote migration: 0007
412
+ Differences:
413
+ Type 'User':
414
+ - Field 'email': required: remote=false, expected=true
415
+
416
+ ℹ This may indicate:
417
+ - Another developer applied different migrations
418
+ - Manual schema changes were made directly
419
+ - Migration history is out of sync
420
+
421
+ ℹ Use '--no-schema-check' to skip this check (not recommended).
422
+ ```
423
+
424
+ ### Skipping Schema Check
425
+
426
+ To skip both local and remote schema verification (not recommended for production):
427
+
428
+ ```bash
429
+ tailor-sdk apply --no-schema-check
430
+ ```
431
+
432
+ **Warning:** Skipping schema checks may result in applying migrations to an inconsistent state.
433
+
434
+ ### Example Output
435
+
436
+ ```
437
+ ℹ Found 2 pending migration(s) to execute.
438
+ ℹ Executing 2 pending migration(s)...
439
+ ℹ Using machine user: admin-machine-user
440
+
441
+ ✔ Migration tailordb/0002 completed successfully
442
+ ✔ Migration tailordb/0003 completed successfully
443
+
444
+ ✔ All migrations completed successfully.
445
+ ✔ Successfully applied changes.
446
+ ```
447
+
448
+ ## Troubleshooting
449
+
450
+ ### Remote schema drift detected
451
+
452
+ **Cause:** The remote schema doesn't match the expected state based on migration history. This can happen when:
453
+
454
+ - Another developer applied different migrations
455
+ - Schema was changed manually outside of migrations
456
+ - Migration history is out of sync
457
+
458
+ **Solution:**
459
+
460
+ 1. **Check migration status**: Run `tailor-sdk tailordb migration status` to see current state
461
+ 2. **Sync with team**: Ensure all team members have the same migration files
462
+ 3. **Reset if needed**: Use `tailor-sdk tailordb migration set <number>` to reset migration checkpoint
463
+ 4. **Force apply** (use with caution): Use `--no-schema-check` to skip verification
464
+
465
+ ### "Machine user not found"
466
+
467
+ **Cause:** Specified machine user doesn't exist in auth configuration.
468
+
469
+ **Solution:**
470
+
471
+ 1. Check available users: The error message lists available machine users
472
+ 2. Add machine user to your auth config:
473
+ ```typescript
474
+ machineUsers: {
475
+ "your-user-name": {
476
+ attributes: { role: "ADMIN" },
477
+ },
478
+ }
479
+ ```
480
+ 3. Run `tailor-sdk apply` to deploy the auth config
481
+ 4. Retry migration
482
+
483
+ ### Migration script execution fails
484
+
485
+ **Cause:** Runtime error in your data migration logic.
486
+
487
+ **Solution:**
488
+
489
+ 1. Check the error message for the failing query/operation
490
+ 2. Test your script logic locally if possible
491
+ 3. Fix the script
492
+ 4. Apply again: `tailor-sdk apply`
493
+
494
+ ## tailordb erd (beta)
495
+
496
+ Generate ERD artifacts for TailorDB namespaces using [Liam ERD](https://liambx.com/erd).
497
+
498
+ ```bash
499
+ tailor-sdk tailordb erd <subcommand> [options]
500
+ ```
501
+
502
+ **Notes:**
503
+
504
+ - This command is a beta feature and may introduce breaking changes in future releases
505
+ - `@liam-hq/cli` is required for `export`, `serve`, and `deploy`
506
+ - `serve` is required only for `tailordb erd serve`
507
+
508
+ Install dependencies:
509
+
510
+ ```bash
511
+ npm i -D @liam-hq/cli serve
512
+ # OR
513
+ yarn add -D @liam-hq/cli serve
514
+ # OR
515
+ pnpm add -D @liam-hq/cli serve
516
+ ```
517
+
518
+ ### tailordb erd export
519
+
520
+ Export Liam ERD dist from applied TailorDB schema.
521
+
522
+ ```bash
523
+ tailor-sdk tailordb erd export [options]
524
+ ```
525
+
526
+ **Options:**
527
+
528
+ - `-n, --namespace` - TailorDB namespace name (optional - exports all namespaces with erdSite if omitted)
529
+ - `-o, --output` - Output directory path for tbls-compatible ERD JSON (writes to `<outputDir>/<namespace>/schema.json`) (default: `.tailor-sdk/erd`)
530
+ - `-j, --json` - Output as JSON
531
+ - `-w, --workspace-id` - ID of the workspace
532
+ - `-p, --profile` - Workspace profile to use
533
+ - `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
534
+ - `-e, --env-file` - Path to the environment file
535
+
536
+ **Usage Examples:**
537
+
538
+ ```bash
539
+ # Export ERD for all namespaces with erdSite configured
540
+ tailor-sdk tailordb erd export
541
+
542
+ # Export ERD for a specific namespace
543
+ tailor-sdk tailordb erd export --namespace myNamespace
544
+
545
+ # Export ERD with custom output directory
546
+ tailor-sdk tailordb erd export --output ./my-erd
547
+
548
+ # Export ERD with JSON output
549
+ tailor-sdk tailordb erd export --json
550
+ ```
551
+
552
+ ### tailordb erd serve
553
+
554
+ Generate and serve ERD locally (liam build + `serve dist`).
555
+
556
+ ```bash
557
+ tailor-sdk tailordb erd serve [options]
558
+ ```
559
+
560
+ **Options:**
561
+
562
+ - `-n, --namespace` - TailorDB namespace name (uses first namespace with erdSite if not specified)
563
+ - `-w, --workspace-id` - ID of the workspace
564
+ - `-p, --profile` - Workspace profile to use
565
+ - `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
566
+ - `-e, --env-file` - Path to the environment file
567
+
568
+ **Usage Examples:**
569
+
570
+ ```bash
571
+ # Serve ERD for the first namespace with erdSite configured
572
+ tailor-sdk tailordb erd serve
573
+
574
+ # Serve ERD for a specific namespace
575
+ tailor-sdk tailordb erd serve --namespace myNamespace
576
+ ```
577
+
578
+ ### tailordb erd deploy
579
+
580
+ Deploy ERD static website for TailorDB namespace(s).
581
+
582
+ ```bash
583
+ tailor-sdk tailordb erd deploy [options]
584
+ ```
585
+
586
+ **Options:**
587
+
588
+ - `-n, --namespace` - TailorDB namespace name (optional - deploys all namespaces with erdSite if omitted)
589
+ - `-j, --json` - Output as JSON
590
+ - `-w, --workspace-id` - ID of the workspace
591
+ - `-p, --profile` - Workspace profile to use
592
+ - `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
593
+ - `-e, --env-file` - Path to the environment file
594
+
595
+ **Usage Examples:**
596
+
597
+ ```bash
598
+ # Deploy ERD for all namespaces with erdSite configured
599
+ tailor-sdk tailordb erd deploy
600
+
601
+ # Deploy ERD for a specific namespace
602
+ tailor-sdk tailordb erd deploy --namespace myNamespace
603
+
604
+ # Deploy ERD with JSON output
605
+ tailor-sdk tailordb erd deploy --json
606
+ ```
607
+
608
+ **Notes:**
609
+
610
+ - Requires `erdSite` to be configured in `tailor.config.ts` for each namespace you want to deploy
611
+ - Example config:
612
+ ```typescript
613
+ export default defineConfig({
614
+ db: {
615
+ myNamespace: {
616
+ // ... table definitions
617
+ erdSite: "my-erd-site-name",
618
+ },
619
+ },
620
+ });
621
+ ```
@@ -43,13 +43,14 @@ tailor-sdk apply --env-file .env --env-file .env.production
43
43
 
44
44
  You can use environment variables to configure workspace and authentication:
45
45
 
46
- | Variable | Description |
47
- | --------------------------------- | --------------------------------------------------- |
48
- | `TAILOR_PLATFORM_WORKSPACE_ID` | Workspace ID for deployment commands |
49
- | `TAILOR_PLATFORM_TOKEN` | Authentication token (alternative to `login`) |
50
- | `TAILOR_TOKEN` | **Deprecated.** Use `TAILOR_PLATFORM_TOKEN` instead |
51
- | `TAILOR_PLATFORM_PROFILE` | Workspace profile name |
52
- | `TAILOR_PLATFORM_SDK_CONFIG_PATH` | Path to SDK config file |
46
+ | Variable | Description |
47
+ | --------------------------------- | ------------------------------------------------------------ |
48
+ | `TAILOR_PLATFORM_WORKSPACE_ID` | Workspace ID for deployment commands |
49
+ | `TAILOR_PLATFORM_TOKEN` | Authentication token (alternative to `login`) |
50
+ | `TAILOR_TOKEN` | **Deprecated.** Use `TAILOR_PLATFORM_TOKEN` instead |
51
+ | `TAILOR_PLATFORM_PROFILE` | Workspace profile name |
52
+ | `TAILOR_PLATFORM_SDK_CONFIG_PATH` | Path to SDK config file |
53
+ | `EDITOR` | Editor to open generated files (e.g., `vim`, `code`, `nano`) |
53
54
 
54
55
  ### Authentication Token Priority
55
56
 
@@ -74,14 +75,29 @@ Workspace ID resolution follows this priority order:
74
75
 
75
76
  Commands for managing Tailor Platform applications (work with `tailor.config.ts`).
76
77
 
77
- | Command | Description |
78
- | ----------------------------------------------------------- | --------------------------------- |
79
- | [init](./cli/application.md#init) | Initialize a new project |
80
- | [generate](./cli/application.md#generate) | Generate files from configuration |
81
- | [apply](./cli/application.md#apply) | Deploy application to workspace |
82
- | [remove](./cli/application.md#remove) | Remove application from workspace |
83
- | [show](./cli/application.md#show) | Show deployed application info |
84
- | [tailordb truncate](./cli/application.md#tailordb-truncate) | Truncate TailorDB tables |
78
+ | Command | Description |
79
+ | ----------------------------------------- | --------------------------------- |
80
+ | [init](./cli/application.md#init) | Initialize a new project |
81
+ | [generate](./cli/application.md#generate) | Generate files from configuration |
82
+ | [apply](./cli/application.md#apply) | Deploy application to workspace |
83
+ | [remove](./cli/application.md#remove) | Remove application from workspace |
84
+ | [show](./cli/application.md#show) | Show deployed application info |
85
+
86
+ ### [TailorDB Commands](./cli/tailordb.md)
87
+
88
+ Commands for managing TailorDB tables, data, and schema migrations.
89
+
90
+ | Command | Description |
91
+ | ---------------------------------------------------------------------------- | ------------------------------------------------ |
92
+ | [tailordb truncate](./cli/tailordb.md#tailordb-truncate) | Truncate TailorDB tables |
93
+ | [tailordb migration generate](./cli/tailordb.md#tailordb-migration-generate) | Generate migration files from schema snapshot |
94
+ | [tailordb migration set](./cli/tailordb.md#tailordb-migration-set) | Set migration checkpoint manually |
95
+ | [tailordb migration status](./cli/tailordb.md#tailordb-migration-status) | Show migration status |
96
+ | [tailordb erd export](./cli/tailordb.md#tailordb-erd-export) | Export ERD artifacts from TailorDB schema (beta) |
97
+ | [tailordb erd serve](./cli/tailordb.md#tailordb-erd-serve) | Serve ERD locally (beta) |
98
+ | [tailordb erd deploy](./cli/tailordb.md#tailordb-erd-deploy) | Deploy ERD static website (beta) |
99
+
100
+ Note: Migration scripts are automatically executed during `tailor-sdk apply`. See [Automatic Migration Execution](./cli/tailordb.md#automatic-migration-execution) for details.
85
101
 
86
102
  ### [User & Auth Commands](./cli/user.md)
87
103