@tailor-platform/sdk 1.60.1 → 1.60.2
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 +8 -0
- package/dist/application-D4tRNn90.mjs +4 -0
- package/dist/{application-FnWOxBk7.mjs → application-pusdxz35.mjs} +185 -54
- package/dist/application-pusdxz35.mjs.map +1 -0
- package/dist/cli/index.mjs +2 -2
- package/dist/cli/lib.mjs +2 -2
- package/dist/{runtime-BvKGwZeF.mjs → runtime-CZpsV8vj.mjs} +16 -3
- package/dist/{runtime-BvKGwZeF.mjs.map → runtime-CZpsV8vj.mjs.map} +1 -1
- package/docs/configuration.md +34 -1
- package/docs/services/executor.md +3 -3
- package/docs/services/tailordb.md +1 -1
- package/package.json +1 -1
- package/dist/application-FnWOxBk7.mjs.map +0 -1
- package/dist/application-VOdgMtOD.mjs +0 -4
package/docs/configuration.md
CHANGED
|
@@ -105,6 +105,7 @@ When using external resources:
|
|
|
105
105
|
- The resource itself is not deployed by this project
|
|
106
106
|
- The resource must be deployed and available before referencing it
|
|
107
107
|
- You can combine external resources with locally-defined resources
|
|
108
|
+
- TailorDB type names must remain unique across local and external TailorDB namespaces; `deploy` checks external TailorDB type names before applying changes
|
|
108
109
|
- Destructive operations like `tailordb truncate` (and `seedPlugin`'s `seed:reset`) automatically exclude external resources to prevent accidental data loss in shared resources
|
|
109
110
|
|
|
110
111
|
### Built-in IdP
|
|
@@ -183,7 +184,7 @@ export default defineConfig({
|
|
|
183
184
|
|
|
184
185
|
### Environment Variables
|
|
185
186
|
|
|
186
|
-
|
|
187
|
+
Use `env` in `defineConfig()` for non-secret values that application code needs at runtime, such as environment names, feature flags, and public service URLs. Values must be strings, numbers, or booleans.
|
|
187
188
|
|
|
188
189
|
```typescript
|
|
189
190
|
export default defineConfig({
|
|
@@ -196,6 +197,32 @@ export default defineConfig({
|
|
|
196
197
|
});
|
|
197
198
|
```
|
|
198
199
|
|
|
200
|
+
`tailor.config.ts` runs locally when an SDK command loads the config. If values come from your shell or an env file, SDK commands can load them before config evaluation with the global [`--env-file`](./cli-reference.md#environment-file-loading) and `--env-file-if-exists` options:
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
export default defineConfig({
|
|
204
|
+
name: "my-app",
|
|
205
|
+
env: {
|
|
206
|
+
foo: Number(process.env.FOO ?? "1"),
|
|
207
|
+
bar: process.env.BAR ?? "hello",
|
|
208
|
+
baz: (process.env.BAZ ?? "true") === "true",
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
If the same config defines an auth before-login hook, make sure the config module can be evaluated without Node-only globals in the platform runtime. Avoid arbitrary `process.env` reads in that module; pass literal values, or values generated into a config module before deployment, and read them from the hook's `env` argument.
|
|
214
|
+
|
|
215
|
+
When the SDK deploys application code or runs detected service code with `function test-run`, it passes the resolved values as the `env` argument. Do not read `process.env` from deployed resolvers, executors, workflow jobs, auth hooks, or migration scripts; Node-side environment variables are not available there. Put sensitive values in [Secret Manager](./services/secret.md) instead of `env`.
|
|
216
|
+
|
|
217
|
+
| Code location | Runtime access |
|
|
218
|
+
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
219
|
+
| Resolver body | `body: ({ env }) => ...` |
|
|
220
|
+
| Executor callbacks | `body: ({ env }) => ...`, `url: ({ env }) => String(env.bar)`, `variables: ({ env }) => ({ enabled: env.baz })`, or similar callback args |
|
|
221
|
+
| Workflow job body | `body: (input, { env }) => ...` |
|
|
222
|
+
| Auth before-login hook | `handler: async ({ env }) => ...` |
|
|
223
|
+
| TailorDB migration script | `main(trx, { env }: MigrationContext)` |
|
|
224
|
+
| `function test-run` | Same `env` argument shape as the detected resolver, executor, or workflow job |
|
|
225
|
+
|
|
199
226
|
```typescript
|
|
200
227
|
// In resolvers
|
|
201
228
|
body: ({ input, env }) => {
|
|
@@ -226,6 +253,12 @@ hooks: {
|
|
|
226
253
|
invoker: "hook-invoker",
|
|
227
254
|
},
|
|
228
255
|
};
|
|
256
|
+
|
|
257
|
+
// In TailorDB migration scripts
|
|
258
|
+
export async function main(trx: Transaction, { env }: MigrationContext): Promise<void> {
|
|
259
|
+
if (!env.baz) return;
|
|
260
|
+
await trx.updateTable("User").set({ stage: env.bar }).execute();
|
|
261
|
+
}
|
|
229
262
|
```
|
|
230
263
|
|
|
231
264
|
### Workflow Service
|
|
@@ -212,14 +212,14 @@ Execute JavaScript/TypeScript functions:
|
|
|
212
212
|
createExecutor({
|
|
213
213
|
operation: {
|
|
214
214
|
kind: "function",
|
|
215
|
-
body: async ({ newRecord }) => {
|
|
216
|
-
console.log(
|
|
215
|
+
body: async ({ newRecord, env }) => {
|
|
216
|
+
console.log(`New record created in ${env.bar}:`, newRecord);
|
|
217
217
|
},
|
|
218
218
|
},
|
|
219
219
|
});
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
-
`function` and `jobFunction` `body` args include an `invoker` field: the principal running this function, overridden by `authInvoker` when set; `null` for anonymous calls. Other operation kinds (`graphql`, `webhook`, `workflow`) do not pass `invoker` into
|
|
222
|
+
Executor callbacks receive the trigger args, including `env` from `defineConfig({ env })`. `function` and `jobFunction` `body` args also include an `invoker` field: the principal running this function, overridden by `authInvoker` when set; `null` for anonymous calls. Other operation kinds (`graphql`, `webhook`, `workflow`) receive `env` through their callback args but do not pass `invoker` into those callbacks.
|
|
223
223
|
|
|
224
224
|
### Job Function Operation
|
|
225
225
|
|
|
@@ -23,7 +23,7 @@ Define TailorDB Types in files matching glob patterns specified in `tailor.confi
|
|
|
23
23
|
- **Multiple types per file**: You can define multiple TailorDB types in a single file
|
|
24
24
|
- **Export method**: Use named exports (`export const`)
|
|
25
25
|
- **Export both value and type**: Always export both the runtime value and TypeScript type
|
|
26
|
-
- **Uniqueness**: Type names must be unique across all TailorDB
|
|
26
|
+
- **Uniqueness**: Type names must be unique across all TailorDB namespaces in the application
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
29
|
import { db } from "@tailor-platform/sdk";
|