Skip to content

Commit d7e0689

Browse files
Update SDK pages
1 parent 0d6d1d5 commit d7e0689

4 files changed

Lines changed: 21 additions & 33 deletions

File tree

docs/sdk/services/auth.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ Get a machine user token using the CLI:
256256
tailor-sdk machineuser token <name>
257257
```
258258

259-
### Using auth.invoker()
259+
### Specifying a machine user invoker
260260

261-
The `auth.invoker()` method creates a type-safe reference to a machine user for use in workflow triggers. This specifies which machine user's permissions should be used when executing the workflow.
261+
Resolvers, executors, and `workflow.trigger()` accept an `authInvoker` option that chooses which machine user runs the operation. Pass the machine user name as a plain string — it is type-narrowed to the names you registered in `machineUsers`.
262262

263263
```typescript
264264
// tailor.config.ts
@@ -275,7 +275,6 @@ export const auth = defineAuth("my-auth", {
275275
```typescript
276276
// resolvers/trigger-workflow.ts
277277
import { createResolver, t } from "@tailor-platform/sdk";
278-
import { auth } from "../tailor.config";
279278
import myWorkflow from "../workflows/my-workflow";
280279

281280
export default createResolver({
@@ -288,7 +287,7 @@ export default createResolver({
288287
// Trigger workflow with machine user permissions
289288
const workflowRunId = await myWorkflow.trigger(
290289
{ id: input.id },
291-
{ authInvoker: auth.invoker("admin-machine-user") },
290+
{ authInvoker: "admin-machine-user" },
292291
);
293292
return { workflowRunId };
294293
},
@@ -298,7 +297,9 @@ export default createResolver({
298297
});
299298
```
300299

301-
The `invoker()` method is type-safe and only accepts machine user names defined in the auth configuration.
300+
Type narrowing is provided by the generated `tailor.d.ts` (the `MachineUserNameRegistry` interface). Run `tailor-sdk generate` (or `apply`) after defining new machine users to refresh it.
301+
302+
> **Deprecated:** The `auth.invoker("<name>")` helper is still available for backward compatibility. Prefer the string form — it does not require importing `auth` from `tailor.config.ts` into runtime files, avoiding bundling config-layer (Node-only) dependencies.
302303
303304
## OAuth 2.0 Clients
304305

docs/sdk/services/executor.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,31 +294,24 @@ createExecutor({
294294

295295
### Authentication for Operations
296296

297-
GraphQL and Workflow operations can specify an `authInvoker` to execute with machine user credentials:
297+
GraphQL and Workflow operations can specify an `authInvoker` to execute with machine user credentials. Pass the machine user name as a plain string — it is type-narrowed to the names defined in your auth config:
298298

299299
```typescript
300-
import { defineAuth, createExecutor, scheduleTrigger } from "@tailor-platform/sdk";
301-
302-
const auth = defineAuth("my-auth", {
303-
// ... auth configuration
304-
machineUsers: {
305-
"batch-processor": {
306-
attributes: { role: "ADMIN" },
307-
},
308-
},
309-
});
300+
import { createExecutor, scheduleTrigger } from "@tailor-platform/sdk";
310301

311302
export default createExecutor({
312303
name: "scheduled-cleanup",
313304
trigger: scheduleTrigger({ cron: "0 0 * * *" }),
314305
operation: {
315306
kind: "graphql",
316307
query: `mutation { cleanupOldRecords { count } }`,
317-
authInvoker: auth.invoker("batch-processor"),
308+
authInvoker: "batch-processor",
318309
},
319310
});
320311
```
321312

313+
> **Deprecated:** `auth.invoker("batch-processor")` still works, but is deprecated. Prefer the string form to avoid importing config-layer modules into runtime files.
314+
322315
## Event Payloads
323316

324317
Each trigger type provides specific context data in the callback functions.

docs/sdk/services/resolver.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -350,19 +350,10 @@ createResolver({
350350

351351
## Authentication
352352

353-
Specify an `authInvoker` to execute the resolver with machine user credentials:
353+
Specify an `authInvoker` to execute the resolver with machine user credentials. Pass the machine user name as a plain string — it is type-narrowed to the names you defined in your auth config:
354354

355355
```typescript
356-
import { defineAuth, createResolver, t } from "@tailor-platform/sdk";
357-
358-
const auth = defineAuth("my-auth", {
359-
// ... auth configuration
360-
machineUsers: {
361-
"batch-processor": {
362-
attributes: { role: "ADMIN" },
363-
},
364-
},
365-
});
356+
import { createResolver, t } from "@tailor-platform/sdk";
366357

367358
export default createResolver({
368359
name: "adminQuery",
@@ -372,10 +363,12 @@ export default createResolver({
372363
// Executes as "batch-processor" machine user
373364
return { result: "ok" };
374365
},
375-
authInvoker: auth.invoker("batch-processor"),
366+
authInvoker: "batch-processor",
376367
});
377368
```
378369

379-
The `authInvoker` option accepts the return value of `auth.invoker()`, which specifies the auth namespace and machine user name.
370+
The machine user name is looked up in the auth service configured on your app (`machineUsers` in `defineAuth`). The namespace is resolved automatically — no need to import `auth` from `tailor.config.ts` in resolver files.
371+
372+
> **Deprecated:** `auth.invoker("batch-processor")` still works, but is deprecated. Importing `auth` into runtime files pulls config-layer (Node-only) dependencies into the bundle.
380373
381374
**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.

docs/sdk/services/workflow.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,10 @@ export default createWorkflow({
227227
You can start a workflow execution from a resolver using `workflow.trigger()`.
228228

229229
- `workflow.trigger(args, options?)` returns a workflow run ID (`Promise<string>`).
230-
- To run with machine-user permissions, pass `{ authInvoker: auth.invoker("<machine-user>") }`.
230+
- To run with machine-user permissions, pass `{ authInvoker: "<machine-user>" }`. The name is type-narrowed to the machine users defined in your auth config.
231231

232232
```typescript
233233
import { createResolver, t } from "@tailor-platform/sdk";
234-
import { auth } from "../tailor.config";
235234
import orderProcessingWorkflow from "../workflows/order-processing";
236235

237236
export default createResolver({
@@ -244,7 +243,7 @@ export default createResolver({
244243
body: async ({ input }) => {
245244
const workflowRunId = await orderProcessingWorkflow.trigger(
246245
{ orderId: input.orderId, customerId: input.customerId },
247-
{ authInvoker: auth.invoker("manager-machine-user") },
246+
{ authInvoker: "manager-machine-user" },
248247
);
249248

250249
return { workflowRunId };
@@ -255,6 +254,8 @@ export default createResolver({
255254
});
256255
```
257256

257+
> **Deprecated:** `auth.invoker("manager-machine-user")` still works but is deprecated. Using the string form avoids importing `auth` into runtime code.
258+
258259
See the full working example in the repository: [example/resolvers/triggerWorkflow.ts](../../../../example/resolvers/triggerWorkflow.ts).
259260

260261
## File Organization

0 commit comments

Comments
 (0)