@tailor-platform/sdk 1.60.2 → 1.60.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.
@@ -13,6 +13,8 @@ For service-specific documentation, see:
13
13
  - [Static Website](./services/staticwebsite.md) - Static file hosting
14
14
  - [Secret Manager](./services/secret.md) - Secure credential storage
15
15
 
16
+ To deploy the same config to multiple workspaces with per-environment values, see [Multi-Environment Configuration](./multi-environment.md).
17
+
16
18
  ### Application Settings
17
19
 
18
20
  ```typescript
@@ -0,0 +1,74 @@
1
+ # Multi-Environment Configuration
2
+
3
+ A project typically runs in more than one environment — for example, each developer's own workspace, a staging workspace, and a production workspace. The SDK has no separate "environment" concept: an environment is a workspace you deploy to, and all environments share the same `tailor.config.ts`. This guide shows how to switch the deployment target and how to vary configuration values per environment.
4
+
5
+ The auto-managed `id` in `defineConfig()` identifies the application, not an environment. Keep the same committed `id` when deploying the same config to multiple workspaces; see [Application Settings](./configuration.md#application-settings).
6
+
7
+ ## Selecting the target workspace
8
+
9
+ Deployment commands resolve the target workspace from, in priority order, the `--workspace-id` (`-w`) option, the `TAILOR_PLATFORM_WORKSPACE_ID` environment variable, and the active profile. See [Workspace ID Priority](./cli-reference.md#workspace-id-priority).
10
+
11
+ For one-off commands, pass the workspace explicitly:
12
+
13
+ ```bash
14
+ tailor-sdk deploy -w <staging-workspace-id>
15
+ ```
16
+
17
+ For environments you switch between regularly, create a named profile per environment with the [profile commands](./cli/workspace.md#profile-create) and select it with `--profile` (`-p`) or `TAILOR_PLATFORM_PROFILE`:
18
+
19
+ ```bash
20
+ tailor-sdk profile create staging -u you@example.com -w <staging-workspace-id>
21
+ tailor-sdk profile create production -u you@example.com -w <production-workspace-id> --permission read
22
+
23
+ tailor-sdk deploy -p staging
24
+ ```
25
+
26
+ Profiles are created with `write` permission by default. The production profile above opts into `--permission read`, which blocks write commands such as `deploy` while the profile is active — a guard against deploying to production by accident. To deploy to production deliberately, pass the workspace explicitly with `-w` without selecting the profile — the guard applies only while a profile is selected via `-p` or `TAILOR_PLATFORM_PROFILE` — or use a separate profile created with `write` permission.
27
+
28
+ ## Varying config values per environment
29
+
30
+ `tailor.config.ts` is a TypeScript module evaluated locally each time an SDK command loads it, so any value can branch on `process.env`. If the config also defines an auth before-login hook, mind the `process.env` caveat in [Environment Variables](./configuration.md#environment-variables). Keep one env file per environment and load it with the global [`--env-file`](./cli-reference.md#environment-file-loading) option:
31
+
32
+ ```ini
33
+ # .env.production
34
+ APP_ENV=production
35
+ LOG_LEVEL=WARN
36
+ ```
37
+
38
+ ```bash
39
+ tailor-sdk deploy -w <production-workspace-id> --env-file .env.production
40
+ ```
41
+
42
+ ```typescript
43
+ export default defineConfig({
44
+ name: "my-app",
45
+ logLevel: process.env.LOG_LEVEL ?? "DEBUG",
46
+ });
47
+ ```
48
+
49
+ Variables already set in your shell are not overwritten by env files, and later files override earlier ones — see [Environment File Loading](./cli-reference.md#environment-file-loading).
50
+
51
+ ## Passing environment values to application code
52
+
53
+ `process.env` is only available while the config is evaluated locally; deployed resolvers, executors, workflow jobs, auth hooks, and migration scripts cannot read it. To make a value available at runtime, forward it through `env` in `defineConfig()`:
54
+
55
+ ```typescript
56
+ export default defineConfig({
57
+ name: "my-app",
58
+ env: {
59
+ appEnv: process.env.APP_ENV ?? "development",
60
+ },
61
+ });
62
+ ```
63
+
64
+ See [Environment Variables](./configuration.md#environment-variables) for how `env` values reach each code location. For sensitive values such as API keys, use [Secret Manager](./services/secret.md) instead and supply the per-environment value via `process.env` the same way.
65
+
66
+ ## Settings that belong to a single environment
67
+
68
+ Some settings reference resources that can exist in only one environment at a time. The static website [customDomains](./services/staticwebsite.md#customdomains) option is an example: a domain is globally unique, so the same `customDomains` value cannot be deployed from two workspaces. Set such values only in the environment that owns the resource:
69
+
70
+ ```typescript
71
+ defineStaticWebSite("my-website", {
72
+ customDomains: process.env.APP_ENV === "production" ? ["app.example.com"] : undefined,
73
+ });
74
+ ```
@@ -74,6 +74,8 @@ defineStaticWebSite("my-website", {
74
74
 
75
75
  After deploying, use `tailor-sdk staticwebsite domain get <domain>` to check domain status and retrieve the CNAME targets required for DNS configuration.
76
76
 
77
+ A domain can be associated with only one workspace at a time. To set custom domains only in the workspace that owns the domain, see [Multi-Environment Configuration](../multi-environment.md#settings-that-belong-to-a-single-environment).
78
+
77
79
  ## Type-safe URL References
78
80
 
79
81
  The returned website object provides a `url` property that resolves to the actual URL at deployment time. Use this for type-safe configuration:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.60.2",
3
+ "version": "1.60.3",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {