@tailor-platform/sdk 1.26.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/application-CBJFUKrU.mjs +4701 -0
  3. package/dist/application-CBJFUKrU.mjs.map +1 -0
  4. package/dist/application-WyZetOky.mjs +11 -0
  5. package/dist/cli/index.mjs +240 -33
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.d.mts +6 -6
  8. package/dist/cli/lib.mjs +10 -8
  9. package/dist/cli/lib.mjs.map +1 -1
  10. package/dist/client-C2_wgujH.mjs +6 -0
  11. package/dist/{application-D9xahQRQ.mjs → client-bTbnbQbB.mjs} +8 -4877
  12. package/dist/{application-D9xahQRQ.mjs.map → client-bTbnbQbB.mjs.map} +1 -1
  13. package/dist/configure/index.d.mts +4 -4
  14. package/dist/crash-report-Cot_9Esm.mjs +6 -0
  15. package/dist/crash-report-Ju8cQF-l.mjs +414 -0
  16. package/dist/crash-report-Ju8cQF-l.mjs.map +1 -0
  17. package/dist/{enum-constants-6uK0VI_s.mjs → enum-constants-D1nfn0qD.mjs} +1 -1
  18. package/dist/{enum-constants-6uK0VI_s.mjs.map → enum-constants-D1nfn0qD.mjs.map} +1 -1
  19. package/dist/{env-CSsVESbH.d.mts → env-BuMbIknz.d.mts} +2 -2
  20. package/dist/{file-utils-2T9w20FP.mjs → file-utils-Bctuzn3x.mjs} +1 -1
  21. package/dist/{file-utils-2T9w20FP.mjs.map → file-utils-Bctuzn3x.mjs.map} +1 -1
  22. package/dist/{index-DgRShBpu.d.mts → index-B0Lrzywd.d.mts} +2 -2
  23. package/dist/{index-BtYPY8ya.d.mts → index-CbnLNm14.d.mts} +2 -2
  24. package/dist/{index-DkJbItB-.d.mts → index-CyapgSFI.d.mts} +2 -2
  25. package/dist/{index-BKy-OC5C.d.mts → index-D1AM_02Y.d.mts} +2 -2
  26. package/dist/{index-BJg0DTbR.d.mts → index-cD9sQLTh.d.mts} +15 -15
  27. package/dist/{interceptor-BPiIBTk_.mjs → interceptor-B0d_GrI5.mjs} +1 -1
  28. package/dist/{interceptor-BPiIBTk_.mjs.map → interceptor-B0d_GrI5.mjs.map} +1 -1
  29. package/dist/{kysely-type-cMNbsQ6k.mjs → kysely-type-B_IecdK9.mjs} +1 -1
  30. package/dist/{kysely-type-cMNbsQ6k.mjs.map → kysely-type-B_IecdK9.mjs.map} +1 -1
  31. package/dist/logger-CqezTedh.mjs +181 -0
  32. package/dist/logger-CqezTedh.mjs.map +1 -0
  33. package/dist/{package-json-CVUv8Y9T.mjs → package-json-D3x2nBPB.mjs} +1 -1
  34. package/dist/{package-json-CVUv8Y9T.mjs.map → package-json-D3x2nBPB.mjs.map} +1 -1
  35. package/dist/package-json-DHfTiUCS.mjs +4 -0
  36. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  37. package/dist/plugin/builtin/enum-constants/index.mjs +1 -1
  38. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  39. package/dist/plugin/builtin/file-utils/index.mjs +1 -1
  40. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  41. package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
  42. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  43. package/dist/plugin/builtin/seed/index.mjs +1 -1
  44. package/dist/plugin/index.d.mts +2 -2
  45. package/dist/{plugin-B1hNwcCC.d.mts → plugin-D3a0-qe0.d.mts} +6 -2
  46. package/dist/{query-B8ml6ClT.mjs → query-WYq8RvYp.mjs} +10 -7
  47. package/dist/query-WYq8RvYp.mjs.map +1 -0
  48. package/dist/{seed-CCVRLibh.mjs → seed-CWkIDWMb.mjs} +1 -1
  49. package/dist/{seed-CCVRLibh.mjs.map → seed-CWkIDWMb.mjs.map} +1 -1
  50. package/dist/{telemetry-DDQZRqHK.mjs → telemetry-BevrwWwF.mjs} +1 -1
  51. package/dist/{telemetry-0w8OupuQ.mjs → telemetry-VvNfsyEE.mjs} +2 -2
  52. package/dist/{telemetry-0w8OupuQ.mjs.map → telemetry-VvNfsyEE.mjs.map} +1 -1
  53. package/dist/utils/test/index.d.mts +2 -2
  54. package/dist/{workflow.generated-Bm4b8hEk.d.mts → workflow.generated-BsgIlrH-.d.mts} +2 -2
  55. package/docs/cli/crash-report.md +107 -0
  56. package/docs/cli/secret.md +16 -14
  57. package/docs/cli-reference.md +11 -0
  58. package/docs/configuration.md +19 -0
  59. package/docs/services/resolver.md +32 -0
  60. package/docs/services/secret.md +81 -0
  61. package/package.json +1 -1
  62. package/dist/application-CxH6Yp54.mjs +0 -9
  63. package/dist/package-json-Bj76LPsV.mjs +0 -4
  64. package/dist/query-B8ml6ClT.mjs.map +0 -1
@@ -275,3 +275,35 @@ createResolver({
275
275
  // ...
276
276
  });
277
277
  ```
278
+
279
+ ## Authentication
280
+
281
+ Specify an `authInvoker` to execute the resolver with machine user credentials:
282
+
283
+ ```typescript
284
+ import { defineAuth, createResolver, t } from "@tailor-platform/sdk";
285
+
286
+ const auth = defineAuth("my-auth", {
287
+ // ... auth configuration
288
+ machineUsers: {
289
+ "batch-processor": {
290
+ attributes: { role: "ADMIN" },
291
+ },
292
+ },
293
+ });
294
+
295
+ export default createResolver({
296
+ name: "adminQuery",
297
+ operation: "query",
298
+ output: t.object({ result: t.string() }),
299
+ body: async () => {
300
+ // Executes as "batch-processor" machine user
301
+ return { result: "ok" };
302
+ },
303
+ authInvoker: auth.invoker("batch-processor"),
304
+ });
305
+ ```
306
+
307
+ The `authInvoker` option accepts the return value of `auth.invoker()`, which specifies the auth namespace and machine user name.
308
+
309
+ **Note:** `authInvoker` controls the permissions for database operations and other platform actions, but the `user` object passed to the `body` function still reflects the original caller who invoked the resolver.
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.26.0",
3
+ "version": "1.28.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,9 +0,0 @@
1
- import "./chunk-Cz-A8uMR.mjs";
2
- import "./brand-GZnI4eYb.mjs";
3
- import { n as generatePluginFilesIfNeeded, r as loadApplication, t as defineApplication } from "./application-D9xahQRQ.mjs";
4
- import "./package-json-CVUv8Y9T.mjs";
5
- import "./seed-CCVRLibh.mjs";
6
- import "./file-utils-2T9w20FP.mjs";
7
- import "./kysely-type-cMNbsQ6k.mjs";
8
-
9
- export { defineApplication };
@@ -1,4 +0,0 @@
1
- import "./chunk-Cz-A8uMR.mjs";
2
- import { t as readPackageJson } from "./package-json-CVUv8Y9T.mjs";
3
-
4
- export { readPackageJson };