@tailor-platform/sdk 1.27.0 → 1.28.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.
- package/CHANGELOG.md +6 -0
- package/dist/cli/index.mjs +101 -3
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.mjs +1 -1
- package/dist/{query-CgGbAmUg.mjs → query-WYq8RvYp.mjs} +2 -2
- package/dist/{query-CgGbAmUg.mjs.map → query-WYq8RvYp.mjs.map} +1 -1
- package/docs/cli/secret.md +16 -14
- package/docs/configuration.md +19 -0
- package/docs/services/secret.md +81 -0
- package/package.json +1 -1
package/docs/cli/secret.md
CHANGED
|
@@ -243,13 +243,14 @@ tailor-sdk secret create [options]
|
|
|
243
243
|
|
|
244
244
|
**Options**
|
|
245
245
|
|
|
246
|
-
| Option | Alias | Description
|
|
247
|
-
| ------------------------------- | ----- |
|
|
248
|
-
| `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID
|
|
249
|
-
| `--profile <PROFILE>` | `-p` | Workspace profile
|
|
250
|
-
| `--vault-name <VAULT_NAME>` | `-V` | Vault name
|
|
251
|
-
| `--name <NAME>` | `-n` | Secret name
|
|
252
|
-
| `--value <VALUE>` | `-v` | Secret value
|
|
246
|
+
| Option | Alias | Description | Required | Default | Env |
|
|
247
|
+
| ------------------------------- | ----- | ------------------------- | -------- | ------- | ------------------------------ |
|
|
248
|
+
| `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
|
|
249
|
+
| `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
|
|
250
|
+
| `--vault-name <VAULT_NAME>` | `-V` | Vault name | Yes | - | - |
|
|
251
|
+
| `--name <NAME>` | `-n` | Secret name | Yes | - | - |
|
|
252
|
+
| `--value <VALUE>` | `-v` | Secret value | Yes | - | - |
|
|
253
|
+
| `--yes` | `-y` | Skip confirmation prompts | No | `false` | - |
|
|
253
254
|
|
|
254
255
|
<!-- politty:command:secret create:options:end -->
|
|
255
256
|
|
|
@@ -284,13 +285,14 @@ tailor-sdk secret update [options]
|
|
|
284
285
|
|
|
285
286
|
**Options**
|
|
286
287
|
|
|
287
|
-
| Option | Alias | Description
|
|
288
|
-
| ------------------------------- | ----- |
|
|
289
|
-
| `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID
|
|
290
|
-
| `--profile <PROFILE>` | `-p` | Workspace profile
|
|
291
|
-
| `--vault-name <VAULT_NAME>` | `-V` | Vault name
|
|
292
|
-
| `--name <NAME>` | `-n` | Secret name
|
|
293
|
-
| `--value <VALUE>` | `-v` | Secret value
|
|
288
|
+
| Option | Alias | Description | Required | Default | Env |
|
|
289
|
+
| ------------------------------- | ----- | ------------------------- | -------- | ------- | ------------------------------ |
|
|
290
|
+
| `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
|
|
291
|
+
| `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
|
|
292
|
+
| `--vault-name <VAULT_NAME>` | `-V` | Vault name | Yes | - | - |
|
|
293
|
+
| `--name <NAME>` | `-n` | Secret name | Yes | - | - |
|
|
294
|
+
| `--value <VALUE>` | `-v` | Secret value | Yes | - | - |
|
|
295
|
+
| `--yes` | `-y` | Skip confirmation prompts | No | `false` | - |
|
|
294
296
|
|
|
295
297
|
<!-- politty:command:secret update:options:end -->
|
|
296
298
|
|
package/docs/configuration.md
CHANGED
|
@@ -145,6 +145,25 @@ export default defineConfig({
|
|
|
145
145
|
});
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
+
### Secret Manager
|
|
149
|
+
|
|
150
|
+
Configure secrets using `defineSecretManager()`. See [Secret Manager](./services/secret.md) for full documentation.
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { defineSecretManager } from "@tailor-platform/sdk";
|
|
154
|
+
|
|
155
|
+
export const secrets = defineSecretManager({
|
|
156
|
+
"api-keys": {
|
|
157
|
+
"stripe-secret-key": process.env.STRIPE_SECRET_KEY!,
|
|
158
|
+
"sendgrid-api-key": process.env.SENDGRID_API_KEY!,
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
export default defineConfig({
|
|
163
|
+
secrets,
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
148
167
|
### Environment Variables
|
|
149
168
|
|
|
150
169
|
Define environment variables that can be accessed in resolvers, executors, and workflows:
|
package/docs/services/secret.md
CHANGED
|
@@ -32,8 +32,85 @@ workspace/
|
|
|
32
32
|
|
|
33
33
|
Secrets are key-value pairs stored within a vault. Secret values are encrypted at rest and only accessible at runtime by authorized services.
|
|
34
34
|
|
|
35
|
+
## Managing Secrets
|
|
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`.
|
|
38
|
+
|
|
39
|
+
### Declarative Configuration
|
|
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`.
|
|
42
|
+
|
|
43
|
+
Since secret values should not be committed to source control, use environment variables:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { defineConfig, defineSecretManager } from "@tailor-platform/sdk";
|
|
47
|
+
|
|
48
|
+
export const secrets = defineSecretManager({
|
|
49
|
+
"api-keys": {
|
|
50
|
+
"stripe-secret-key": process.env.STRIPE_SECRET_KEY!,
|
|
51
|
+
"sendgrid-api-key": process.env.SENDGRID_API_KEY!,
|
|
52
|
+
},
|
|
53
|
+
database: {
|
|
54
|
+
"analytics-connection-string": process.env.ANALYTICS_DB_URL!,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export default defineConfig({
|
|
59
|
+
name: "my-app",
|
|
60
|
+
secrets,
|
|
61
|
+
// ...other config
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The exported `secrets` object provides type-safe `get()` and `getAll()` methods for runtime access from resolvers, executors, and workflows.
|
|
66
|
+
|
|
35
67
|
## Using Secrets
|
|
36
68
|
|
|
69
|
+
### Runtime Access with `get()` / `getAll()`
|
|
70
|
+
|
|
71
|
+
Use the `secrets` object exported from `tailor.config.ts` to retrieve secret values at runtime. The vault and secret names are fully type-checked based on the `defineSecretManager()` configuration.
|
|
72
|
+
|
|
73
|
+
#### `get(vault, secret)`
|
|
74
|
+
|
|
75
|
+
Retrieves a single secret value.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { createResolver } from "@tailor-platform/sdk";
|
|
79
|
+
import { secrets } from "../tailor.config";
|
|
80
|
+
|
|
81
|
+
export default createResolver({
|
|
82
|
+
name: "call-stripe",
|
|
83
|
+
// ...
|
|
84
|
+
operation: async ({ input }) => {
|
|
85
|
+
const apiKey = await secrets.get("api-keys", "stripe-secret-key");
|
|
86
|
+
// Use apiKey to call the Stripe API
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### `getAll(vault, secrets)`
|
|
92
|
+
|
|
93
|
+
Retrieves multiple secret values at once from the same vault.
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { createResolver } from "@tailor-platform/sdk";
|
|
97
|
+
import { secrets } from "../tailor.config";
|
|
98
|
+
|
|
99
|
+
export default createResolver({
|
|
100
|
+
name: "send-notification",
|
|
101
|
+
// ...
|
|
102
|
+
operation: async ({ input }) => {
|
|
103
|
+
const [apiKey, webhookSecret] = await secrets.getAll("api-keys", [
|
|
104
|
+
"sendgrid-api-key",
|
|
105
|
+
"stripe-secret-key",
|
|
106
|
+
]);
|
|
107
|
+
// Use the retrieved secrets
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Both methods return `Promise<string | undefined>` (or an array of them for `getAll`).
|
|
113
|
+
|
|
37
114
|
### In Webhook Operations
|
|
38
115
|
|
|
39
116
|
Reference secrets in webhook headers using the vault/key syntax:
|
|
@@ -71,6 +148,10 @@ At runtime, these references are replaced with the actual secret values.
|
|
|
71
148
|
|
|
72
149
|
## CLI Management
|
|
73
150
|
|
|
151
|
+
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.
|
|
152
|
+
|
|
153
|
+
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.
|
|
154
|
+
|
|
74
155
|
### Create a Vault
|
|
75
156
|
|
|
76
157
|
```bash
|