@tailor-platform/sdk 1.45.2 → 1.47.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 (82) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/{actor-BmxQeMFP.d.mts → actor-DhXSqWTW.d.mts} +2 -2
  3. package/dist/application-CN9Htzup.mjs +4 -0
  4. package/dist/{application-B4zVVNRS.mjs → application-TasSqBTD.mjs} +22 -41
  5. package/dist/application-TasSqBTD.mjs.map +1 -0
  6. package/dist/cli/index.mjs +101 -61
  7. package/dist/cli/index.mjs.map +1 -1
  8. package/dist/cli/lib.d.mts +13 -13
  9. package/dist/cli/lib.mjs +4 -4
  10. package/dist/cli/lib.mjs.map +1 -1
  11. package/dist/{client-BwXkoiMq.mjs → client-COfsXV69.mjs} +31 -120
  12. package/dist/client-COfsXV69.mjs.map +1 -0
  13. package/dist/{client-DTaArWQr.mjs → client-DYSkSLRr.mjs} +1 -1
  14. package/dist/configure/index.d.mts +4 -4
  15. package/dist/configure/index.mjs +4 -43
  16. package/dist/configure/index.mjs.map +1 -1
  17. package/dist/{crash-report-BUHzuzDn.mjs → crashreport-B8lVOx0U.mjs} +1 -1
  18. package/dist/{crash-report-CtYCva4d.mjs → crashreport-CKJwnWsX.mjs} +9 -9
  19. package/dist/crashreport-CKJwnWsX.mjs.map +1 -0
  20. package/dist/{index-DV-5OIEv.d.mts → index-BRvNi5q9.d.mts} +2 -2
  21. package/dist/{index-BBvPd9Uv.d.mts → index-BXyS7xKC.d.mts} +2 -2
  22. package/dist/{index-Dxe6alSZ.d.mts → index-BbOTbZFf.d.mts} +2 -2
  23. package/dist/{index-DUKJPEwq.d.mts → index-BoU_52Du.d.mts} +6 -6
  24. package/dist/{index-B5_4Tzm2.d.mts → index-iy-hNfGp.d.mts} +2 -2
  25. package/dist/{interceptor-CrcDfLPq.mjs → interceptor-CBsqEWDK.mjs} +1 -1
  26. package/dist/{interceptor-CrcDfLPq.mjs.map → interceptor-CBsqEWDK.mjs.map} +1 -1
  27. package/dist/mock-BP-9O5On.mjs +796 -0
  28. package/dist/mock-BP-9O5On.mjs.map +1 -0
  29. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  30. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  31. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  32. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  33. package/dist/plugin/index.d.mts +2 -2
  34. package/dist/{repl-editor-BlT2dFtm.mjs → repl-editor-CZpLlOBj.mjs} +1 -1
  35. package/dist/{repl-editor-BlT2dFtm.mjs.map → repl-editor-CZpLlOBj.mjs.map} +1 -1
  36. package/dist/{runtime-D97Ydu2S.mjs → runtime-DDYL2Zf1.mjs} +148 -70
  37. package/dist/runtime-DDYL2Zf1.mjs.map +1 -0
  38. package/dist/{service-CCgw66c6.mjs → service-obEU5gSM.mjs} +1 -1
  39. package/dist/{service-CCgw66c6.mjs.map → service-obEU5gSM.mjs.map} +1 -1
  40. package/dist/{tailor-db-field-Hx9OqPWY.d.mts → tailor-db-field-Bn8ZC5lK.d.mts} +1 -1
  41. package/dist/{schema-DBq6hr6h.mjs → tailordb-Bg9-TZj1.mjs} +42 -2
  42. package/dist/tailordb-Bg9-TZj1.mjs.map +1 -0
  43. package/dist/telemetry-21afNV9_.mjs +4 -0
  44. package/dist/{telemetry-DXitz4RH.mjs → telemetry-DcL8Fsm_.mjs} +1 -1
  45. package/dist/{telemetry-DXitz4RH.mjs.map → telemetry-DcL8Fsm_.mjs.map} +1 -1
  46. package/dist/utils/test/index.d.mts +13 -4
  47. package/dist/utils/test/index.mjs +12 -3
  48. package/dist/utils/test/index.mjs.map +1 -1
  49. package/dist/vitest/environment.d.mts +12 -0
  50. package/dist/vitest/environment.mjs +44 -0
  51. package/dist/vitest/environment.mjs.map +1 -0
  52. package/dist/vitest/index.d.mts +345 -0
  53. package/dist/vitest/index.mjs +350 -0
  54. package/dist/vitest/index.mjs.map +1 -0
  55. package/dist/vitest/setup.d.mts +64 -0
  56. package/dist/vitest/setup.mjs +141 -0
  57. package/dist/vitest/setup.mjs.map +1 -0
  58. package/dist/{workflow.generated-DFljpJh7.d.mts → workflow.generated-i7PK4fg-.d.mts} +2 -2
  59. package/docs/cli/application.md +19 -17
  60. package/docs/cli/crashreport.md +119 -0
  61. package/docs/cli/executor.md +9 -9
  62. package/docs/cli/function.md +5 -5
  63. package/docs/cli/setup.md +1 -0
  64. package/docs/cli/tailordb.md +1 -1
  65. package/docs/cli/workflow.md +8 -8
  66. package/docs/cli-reference.md +8 -8
  67. package/docs/quickstart.md +2 -2
  68. package/docs/services/auth.md +2 -2
  69. package/docs/services/secret.md +4 -4
  70. package/docs/services/tailordb-migration.md +10 -10
  71. package/docs/services/tailordb.md +44 -13
  72. package/docs/services/workflow.md +1 -1
  73. package/docs/testing.md +530 -243
  74. package/package.json +32 -6
  75. package/dist/application-B4zVVNRS.mjs.map +0 -1
  76. package/dist/application-BIzicxMA.mjs +0 -4
  77. package/dist/client-BwXkoiMq.mjs.map +0 -1
  78. package/dist/crash-report-CtYCva4d.mjs.map +0 -1
  79. package/dist/runtime-D97Ydu2S.mjs.map +0 -1
  80. package/dist/schema-DBq6hr6h.mjs.map +0 -1
  81. package/dist/telemetry-BvI1EgMG.mjs +0 -4
  82. package/docs/cli/crash-report.md +0 -118
@@ -43,10 +43,10 @@ Both `--env-file` and `--env-file-if-exists` can be specified multiple times and
43
43
 
44
44
  ```bash
45
45
  # Load .env (required) and .env.local (optional, if exists)
46
- tailor-sdk apply --env-file .env --env-file-if-exists .env.local
46
+ tailor-sdk deploy --env-file .env --env-file-if-exists .env.local
47
47
 
48
48
  # Load multiple files
49
- tailor-sdk apply --env-file .env --env-file .env.production
49
+ tailor-sdk deploy --env-file .env --env-file .env.production
50
50
  ```
51
51
 
52
52
  ## Environment Variables
@@ -99,7 +99,7 @@ Commands for managing Tailor Platform applications (work with `tailor.config.ts`
99
99
  | ----------------------------------------------- | ------------------------------------------------------------------- |
100
100
  | [init](./cli/application.md#init) | Initialize a new project using create-sdk. |
101
101
  | [generate](./cli/application.md#generate) | Generate files using Tailor configuration. |
102
- | [apply](./cli/application.md#apply) | Apply Tailor configuration to deploy your application. |
102
+ | [deploy](./cli/application.md#deploy) | Deploy your application by applying the Tailor configuration. |
103
103
  | [remove](./cli/application.md#remove) | Remove all resources managed by the application from the workspace. |
104
104
  | [show](./cli/application.md#show) | Show information about the deployed application. |
105
105
  | [open](./cli/application.md#open) | Open Tailor Platform Console. |
@@ -255,14 +255,14 @@ Commands for managing and deploying static websites.
255
255
  | [staticwebsite list](./cli/staticwebsite.md#staticwebsite-list) | List all static websites in a workspace. |
256
256
  | [staticwebsite get](./cli/staticwebsite.md#staticwebsite-get) | Get details of a specific static website. |
257
257
 
258
- ### [Crash Report Commands](./cli/crash-report.md)
258
+ ### [Crash Report Commands](./cli/crashreport.md)
259
259
 
260
260
  Commands for managing crash reports.
261
261
 
262
- | Command | Description |
263
- | ------------------------------------------------------------ | ---------------------------------------------- |
264
- | [crash-report list](./cli/crash-report.md#crash-report-list) | List local crash report files. |
265
- | [crash-report send](./cli/crash-report.md#crash-report-send) | Submit a crash report to help improve the SDK. |
262
+ | Command | Description |
263
+ | --------------------------------------------------------- | ---------------------------------------------- |
264
+ | [crashreport list](./cli/crashreport.md#crashreport-list) | List local crash report files. |
265
+ | [crashreport send](./cli/crashreport.md#crashreport-send) | Submit a crash report to help improve the SDK. |
266
266
 
267
267
  ### [Setup Commands](./cli/setup.md)
268
268
 
@@ -16,7 +16,7 @@ The SDK requires Node.js 22 or later. Install Node.js via your package manager b
16
16
 
17
17
  Alternatively, you can use [Bun](https://bun.sh/) as the runtime.
18
18
 
19
- > **Note:** Bun has a known issue with HTTP/2 connections that may cause intermittent failures during `apply` or `generate` commands ([bun#14249](https://github.com/oven-sh/bun/issues/14249), [bun#26719](https://github.com/oven-sh/bun/issues/26719)). If you encounter a connection error, retry the command.
19
+ > **Note:** Bun has a known issue with HTTP/2 connections that may cause intermittent failures during `deploy` or `generate` commands ([bun#14249](https://github.com/oven-sh/bun/issues/14249), [bun#26719](https://github.com/oven-sh/bun/issues/26719)). If you encounter a connection error, retry the command.
20
20
 
21
21
  ### Create an Example App
22
22
 
@@ -46,7 +46,7 @@ npx tailor-sdk workspace list
46
46
 
47
47
  ### Deploy Your App
48
48
 
49
- Run the apply command to deploy your project:
49
+ Run the deploy command to deploy your project:
50
50
 
51
51
  ```bash
52
52
  cd example-app
@@ -388,7 +388,7 @@ export const auth = defineAuth("my-auth", {
388
388
  });
389
389
  ```
390
390
 
391
- After `tailor-sdk apply`, authorize the connection:
391
+ After `tailor-sdk deploy`, authorize the connection:
392
392
 
393
393
  ```bash
394
394
  tailor-sdk authconnection authorize --name google-connection \
@@ -448,7 +448,7 @@ tailor-sdk authconnection list
448
448
  tailor-sdk authconnection revoke --name google-connection
449
449
  ```
450
450
 
451
- Connection creation is handled by `tailor-sdk apply` via the config.
451
+ Connection creation is handled by `tailor-sdk deploy` via the config.
452
452
 
453
453
  See [Auth Resource Commands](../cli/auth.md) for full CLI documentation.
454
454
 
@@ -34,11 +34,11 @@ Secrets are key-value pairs stored within a vault. Secret values are encrypted a
34
34
 
35
35
  ## Managing Secrets
36
36
 
37
- There are two ways to manage secrets: declaratively via `defineSecretManager()` in `tailor.config.ts`, or imperatively via the [CLI](#cli-management). Management is scoped per vault — **do not mix both approaches for the same vault**. When a vault is defined in config, the config becomes the source of truth: any secrets in that vault not present in the config will be deleted on `tailor-sdk apply`.
37
+ There are two ways to manage secrets: declaratively via `defineSecretManager()` in `tailor.config.ts`, or imperatively via the [CLI](#cli-management). Management is scoped per vault — **do not mix both approaches for the same vault**. When a vault is defined in config, the config becomes the source of truth: any secrets in that vault not present in the config will be deleted on `tailor-sdk deploy`.
38
38
 
39
39
  ### Declarative Configuration
40
40
 
41
- Define your secrets in `tailor.config.ts` using `defineSecretManager()`. Each key is a vault name, and its value is a record of secret names to their values. These values are deployed to each vault on `tailor-sdk apply`.
41
+ Define your secrets in `tailor.config.ts` using `defineSecretManager()`. Each key is a vault name, and its value is a record of secret names to their values. These values are deployed to each vault on `tailor-sdk deploy`.
42
42
 
43
43
  Since secret values should not be committed to source control, use environment variables:
44
44
 
@@ -87,7 +87,7 @@ When `ignoreNullishValues: true`:
87
87
  - Skipped secrets are shown in the deploy output for visibility
88
88
  - Secrets removed from the config entirely are still deleted (orphan cleanup)
89
89
 
90
- This allows you to set secret values once (e.g., via local `tailor-sdk apply` or the CLI) and then deploy from CI without needing the actual values in CI environment variables.
90
+ This allows you to set secret values once (e.g., via local `tailor-sdk deploy` or the CLI) and then deploy from CI without needing the actual values in CI environment variables.
91
91
 
92
92
  ## Using Secrets
93
93
 
@@ -175,7 +175,7 @@ At runtime, these references are replaced with the actual secret values.
175
175
 
176
176
  Use the CLI to manage vaults that are **not** defined in `defineSecretManager()`. If you attempt to modify a vault that is managed by the config, the CLI will show a warning and ask for confirmation. Once confirmed, the CLI releases the vault's ownership label so it is no longer managed by config.
177
177
 
178
- After ownership is released, the next `tailor-sdk apply` will treat the vault as an unmanaged resource and prompt for confirmation before taking any action on it.
178
+ After ownership is released, the next `tailor-sdk deploy` will treat the vault as an unmanaged resource and prompt for confirmation before taking any action on it.
179
179
 
180
180
  ### Create a Vault
181
181
 
@@ -12,7 +12,7 @@ For the CLI command reference, see [`tailordb migration`](../cli/tailordb.md#tai
12
12
 
13
13
  - **Local snapshot–based diff detection** — each migration is generated by diffing your current type definitions against the previous snapshot stored in `migrations/<NNNN>/`.
14
14
  - **Transaction-wrapped data migrations** — each `migrate.ts` script runs inside a database transaction on the platform; if the script throws, all changes in that migration roll back.
15
- - **Automatic execution during `apply`** — `tailor-sdk apply` detects pending migrations, runs the two-stage type update (pre-migration → script → post-migration), and updates the migration checkpoint label.
15
+ - **Automatic execution during `apply`** — `tailor-sdk deploy` detects pending migrations, runs the two-stage type update (pre-migration → script → post-migration), and updates the migration checkpoint label.
16
16
  - **Type-safe scripts** — the generated `db.ts` provides Kysely types that reflect the schema state **before** the migration runs, so transformations are written against the actual data shape.
17
17
 
18
18
  **Files in `migrations/`**
@@ -45,7 +45,7 @@ When you start with no `migrations/` directory:
45
45
  tailor-sdk tailordb migration generate
46
46
  ```
47
47
  This creates `migrations/0000/schema.json` from your current types.
48
- 4. Run `tailor-sdk apply`. The migration label is set to `0000` on the deployed namespace.
48
+ 4. Run `tailor-sdk deploy`. The migration label is set to `0000` on the deployed namespace.
49
49
 
50
50
  ### Adding migrations to an existing project
51
51
 
@@ -53,7 +53,7 @@ If you already have a deployed workspace whose schema matches your local type de
53
53
 
54
54
  1. Add the `migration` block to `tailor.config.ts`.
55
55
  2. Run `tailor-sdk tailordb migration generate` to create `0000/schema.json` from current local types.
56
- 3. Run `tailor-sdk apply`. Because remote schema already matches, no script runs; only the migration label is set.
56
+ 3. Run `tailor-sdk deploy`. Because remote schema already matches, no script runs; only the migration label is set.
57
57
 
58
58
  If your local types and remote schema have **diverged**, reconcile them before introducing migrations — either update local types to match remote, or accept that the first non-`0000` migration will reflect that gap.
59
59
 
@@ -109,7 +109,7 @@ A typical change cycle:
109
109
 
110
110
  4. **Apply.**
111
111
  ```bash
112
- tailor-sdk apply
112
+ tailor-sdk deploy
113
113
  ```
114
114
  The pre-migration phase relaxes the new field to optional, the script runs and populates values, then the post-migration phase enforces `required: true`.
115
115
 
@@ -210,7 +210,7 @@ The same pattern works for switching between scalar and array.
210
210
 
211
211
  ## Automatic Migration Execution
212
212
 
213
- When you run `tailor-sdk apply`, the SDK detects pending migrations (anything past the current `sdk-migration` label on the deployed namespace) and runs them in order before continuing with the rest of the apply.
213
+ When you run `tailor-sdk deploy`, the SDK detects pending migrations (anything past the current `sdk-migration` label on the deployed namespace) and runs them in order before continuing with the rest of the apply.
214
214
 
215
215
  ### Per-migration phases
216
216
 
@@ -243,7 +243,7 @@ Namespace: tailordb
243
243
  To bypass both checks (not recommended outside of recovery scenarios):
244
244
 
245
245
  ```bash
246
- tailor-sdk apply --no-schema-check
246
+ tailor-sdk deploy --no-schema-check
247
247
  ```
248
248
 
249
249
  ### Example output
@@ -299,7 +299,7 @@ Migration numbers are assigned sequentially, so two developers branching off the
299
299
 
300
300
  1. Run `migration generate --init` to start over from `0000`.
301
301
  2. Run `tailor-sdk tailordb migration set 0` against the deployed namespace.
302
- 3. Run `tailor-sdk apply` — the new `0000` becomes the baseline.
302
+ 3. Run `tailor-sdk deploy` — the new `0000` becomes the baseline.
303
303
 
304
304
  Coordinate this with your team because everyone else's local migrations will be invalidated.
305
305
 
@@ -315,7 +315,7 @@ After a failure:
315
315
 
316
316
  1. Read the `Logs:` block in the apply output to find the cause.
317
317
  2. Fix `migrate.ts` (or the data it depends on).
318
- 3. Re-run `tailor-sdk apply`. The same migration runs again because its label was never bumped.
318
+ 3. Re-run `tailor-sdk deploy`. The same migration runs again because its label was never bumped.
319
319
  4. If the pre-migration relaxation is causing problems for application code in the meantime, accept the temporary optionality or roll forward with a fix; do not try to manually re-tighten the schema, or you'll create remote drift.
320
320
 
321
321
  If a migration **succeeds in script** but the post-migration phase fails (rare; usually due to constraint violation that the script should have prevented), the situation is the same as above plus the data changes from the script are persisted. Investigate, fix, and re-run.
@@ -345,7 +345,7 @@ The machine user needs read/write access to every type the migration script touc
345
345
 
346
346
  If you see `No machine user available for migration execution`, either:
347
347
 
348
- - Add `machineUsers: { ... }` to your auth config and `tailor-sdk apply` it, or
348
+ - Add `machineUsers: { ... }` to your auth config and `tailor-sdk deploy` it, or
349
349
  - Set `migration.machineUser` to an existing machine user name in the db config.
350
350
 
351
351
  ## Multi-Namespace Coordination
@@ -409,7 +409,7 @@ For genuinely different schemas across environments, prefer separate workspaces
409
409
 
410
410
  **Cause:** Runtime error in your `migrate.ts`, a permission error from the machine user, or a constraint violation when post-migration tightens types.
411
411
 
412
- **Resolution:** Read the `Logs:` block. Fix the script or the data assumption it relies on, and re-run `tailor-sdk apply`. The label is not bumped on failure, so the same migration retries.
412
+ **Resolution:** Read the `Logs:` block. Fix the script or the data assumption it relies on, and re-run `tailor-sdk deploy`. The label is not bumped on failure, so the same migration retries.
413
413
 
414
414
  ### `migrate.ts` not found for a migration that needs one
415
415
 
@@ -62,18 +62,19 @@ db.type("User", "User in the system", {
62
62
 
63
63
  ## Field Types
64
64
 
65
- | Method | TailorDB | TypeScript |
66
- | ------------------------------- | -------- | -------------- |
67
- | `db.string()` | String | string |
68
- | `db.int()` | Integer | number |
69
- | `db.float()` | Float | number |
70
- | `db.bool()` | Boolean | boolean |
71
- | `db.date()` | Date | string |
72
- | `db.datetime()` | DateTime | string \| Date |
73
- | `db.time()` | Time | string |
74
- | `db.uuid()` | UUID | string |
75
- | [`db.enum()`](#enum-fields) | Enum | string |
76
- | [`db.object()`](#object-fields) | Nested | object |
65
+ | Method | TailorDB | TypeScript |
66
+ | --------------------------------- | -------- | -------------- |
67
+ | `db.string()` | String | string |
68
+ | `db.int()` | Integer | number |
69
+ | `db.float()` | Float | number |
70
+ | [`db.decimal()`](#decimal-fields) | Decimal | string |
71
+ | `db.bool()` | Boolean | boolean |
72
+ | `db.date()` | Date | string |
73
+ | `db.datetime()` | DateTime | string \| Date |
74
+ | `db.time()` | Time | string |
75
+ | `db.uuid()` | UUID | string |
76
+ | [`db.enum()`](#enum-fields) | Enum | string |
77
+ | [`db.object()`](#object-fields) | Nested | object |
77
78
 
78
79
  ### Optional and Array Fields
79
80
 
@@ -83,6 +84,36 @@ db.string({ array: true });
83
84
  db.string({ optional: true, array: true });
84
85
  ```
85
86
 
87
+ ### Decimal Fields
88
+
89
+ Decimal fields are stored as strings to preserve precision. The optional `scale`
90
+ parameter sets the number of digits after the decimal point and must be an
91
+ integer between 0 and 12. When `scale` is omitted, the platform default of 6 is
92
+ used.
93
+
94
+ ```typescript
95
+ // Default scale (6 decimal places)
96
+ db.decimal();
97
+
98
+ // Custom scale (2 decimal places)
99
+ db.decimal({ scale: 2 });
100
+
101
+ // Optional with custom scale
102
+ db.decimal({ scale: 4, optional: true });
103
+ ```
104
+
105
+ Values are rounded half-up to fit the configured scale before being stored.
106
+ Negative values follow the same rule based on absolute magnitude:
107
+
108
+ | Input | Scale | Stored |
109
+ | ------------- | ----- | ------------ |
110
+ | `"1.234"` | 2 | `"1.23"` |
111
+ | `"1.235"` | 2 | `"1.24"` |
112
+ | `"-1.235"` | 2 | `"-1.24"` |
113
+ | `"1.5"` | 0 | `"2"` |
114
+ | `"1.123456"` | 6 | `"1.123456"` |
115
+ | `"1.1234567"` | 6 | `"1.123457"` |
116
+
86
117
  ### Enum Fields
87
118
 
88
119
  ```typescript
@@ -589,6 +620,6 @@ db.type("User", {
589
620
 
590
621
  ## Migrations
591
622
 
592
- When you change a TailorDB type definition, the SDK can generate a migration that captures the diff and, for breaking changes, runs a data transformation script during `tailor-sdk apply`. See the [TailorDB Migrations guide](./tailordb-migration.md) for the full workflow, configuration, supported change types, team coordination, and troubleshooting.
623
+ When you change a TailorDB type definition, the SDK can generate a migration that captures the diff and, for breaking changes, runs a data transformation script during `tailor-sdk deploy`. See the [TailorDB Migrations guide](./tailordb-migration.md) for the full workflow, configuration, supported change types, team coordination, and troubleshooting.
593
624
 
594
625
  For the CLI command reference, see [`tailordb migration`](../cli/tailordb.md#tailordb-migration).
@@ -308,7 +308,7 @@ export default createResolver({
308
308
  });
309
309
  ```
310
310
 
311
- Wait points can be imported and used in any file (workflow jobs, resolvers, executors). For local testing, see [Testing Wait Points](../testing.md#testing-wait-points).
311
+ Wait points can be imported and used in any file (workflow jobs, resolvers, executors). For local testing, see [Jobs that wait on approval](../testing.md#jobs-that-wait-on-approval) in the testing guide.
312
312
 
313
313
  ## Retry Policy
314
314