@tailor-platform/sdk 1.33.2 → 1.34.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 (40) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/application-CLKuNo-l.mjs +4 -0
  3. package/dist/{application-CYPU-WIc.mjs → application-CluuzA0-.mjs} +18 -2
  4. package/dist/application-CluuzA0-.mjs.map +1 -0
  5. package/dist/cli/index.mjs +291 -40
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.d.mts +6 -6
  8. package/dist/cli/lib.mjs +3 -3
  9. package/dist/{client-ea1w8SmG.mjs → client-BmQP4kKS.mjs} +1 -1
  10. package/dist/{client-CYGsf3Zl.mjs → client-CA2NM_4R.mjs} +10 -2
  11. package/dist/{client-CYGsf3Zl.mjs.map → client-CA2NM_4R.mjs.map} +1 -1
  12. package/dist/configure/index.d.mts +4 -5
  13. package/dist/configure/index.mjs +3 -0
  14. package/dist/configure/index.mjs.map +1 -1
  15. package/dist/{crash-report-CbueUPaP.mjs → crash-report-Bd2T8BhU.mjs} +1 -1
  16. package/dist/{crash-report-OXafT1iS.mjs → crash-report-CPkI2-cp.mjs} +2 -2
  17. package/dist/{crash-report-OXafT1iS.mjs.map → crash-report-CPkI2-cp.mjs.map} +1 -1
  18. package/dist/{index-DlivLpTN.d.mts → index--9iVDOXn.d.mts} +7 -8
  19. package/dist/{index-mAV9kYJA.d.mts → index-D4pBPp65.d.mts} +2 -2
  20. package/dist/{index-0H-YH8Ya.d.mts → index-DTJkkO-t.d.mts} +2 -2
  21. package/dist/{index-BM2SqNfO.d.mts → index-niQ9Qblw.d.mts} +2 -2
  22. package/dist/{index-BU6fmwJC.d.mts → index-qVqjEYnr.d.mts} +2 -2
  23. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  24. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  25. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  26. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  27. package/dist/plugin/index.d.mts +1 -2
  28. package/dist/{plugin-DQqzlulP.d.mts → plugin-D8hKE6rZ.d.mts} +59 -3
  29. package/dist/{runtime-CxDrzUC0.mjs → runtime-8G74KN_M.mjs} +286 -52
  30. package/dist/runtime-8G74KN_M.mjs.map +1 -0
  31. package/dist/utils/test/index.d.mts +2 -2
  32. package/dist/{workflow.generated-u9MgzqbM.d.mts → workflow.generated-DMt8PNVd.d.mts} +2 -2
  33. package/docs/cli/auth.md +162 -1
  34. package/docs/cli-reference.md +9 -6
  35. package/docs/services/auth.md +115 -0
  36. package/package.json +1 -1
  37. package/dist/application-CYPU-WIc.mjs.map +0 -1
  38. package/dist/application-dnB8CQiT.mjs +0 -4
  39. package/dist/env-BvIWsJxg.d.mts +0 -30
  40. package/dist/runtime-CxDrzUC0.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { H as TailorDBType, nt as TailorField } from "../../plugin-DQqzlulP.mjs";
3
- import { et as WORKFLOW_TEST_ENV_KEY, n as output } from "../../index-DlivLpTN.mjs";
2
+ import { U as TailorDBType, rt as TailorField } from "../../plugin-D8hKE6rZ.mjs";
3
+ import { et as WORKFLOW_TEST_ENV_KEY, n as output } from "../../index--9iVDOXn.mjs";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
5
 
6
6
  //#region src/utils/test/mock.d.ts
@@ -1,5 +1,5 @@
1
1
  /// <reference types="@tailor-platform/function-types" />
2
- import { At as BuiltinIdP, S as TailorDBServiceInput, T as AuthConfig } from "./plugin-DQqzlulP.mjs";
2
+ import { Pt as BuiltinIdP, S as TailorDBServiceInput, T as AuthConfig } from "./plugin-D8hKE6rZ.mjs";
3
3
 
4
4
  //#region src/types/idp.generated.d.ts
5
5
  /**
@@ -203,4 +203,4 @@ type RetryPolicy = {
203
203
  };
204
204
  //#endregion
205
205
  export { IdPEmailConfig as _, ResolverExternalConfig as a, IdPInput as b, WorkflowServiceConfig as c, defineStaticWebSite as d, SecretsConfig as f, IdpDefinitionBrand as g, IdPExternalConfig as h, ExecutorServiceInput as i, WorkflowServiceInput as l, IdPConfig as m, AppConfig as n, ResolverServiceConfig as o, defineSecretManager as p, ExecutorServiceConfig as r, ResolverServiceInput as s, RetryPolicy as t, StaticWebsiteConfig as u, IdPGqlOperations as v, IdPGqlOperationsInput as y };
206
- //# sourceMappingURL=workflow.generated-u9MgzqbM.d.mts.map
206
+ //# sourceMappingURL=workflow.generated-DMt8PNVd.d.mts.map
package/docs/cli/auth.md CHANGED
@@ -1,6 +1,167 @@
1
1
  # Auth Resource Commands
2
2
 
3
- Commands for managing Auth service resources (machine users and OAuth2 clients).
3
+ Commands for managing Auth service resources (auth connections, machine users, and OAuth2 clients).
4
+
5
+ <!-- politty:command:authconnection:heading:start -->
6
+
7
+ ## authconnection
8
+
9
+ <!-- politty:command:authconnection:heading:end -->
10
+
11
+ <!-- politty:command:authconnection:description:start -->
12
+
13
+ Manage auth connections.
14
+
15
+ <!-- politty:command:authconnection:description:end -->
16
+
17
+ <!-- politty:command:authconnection:usage:start -->
18
+
19
+ **Usage**
20
+
21
+ ```
22
+ tailor-sdk authconnection [command]
23
+ ```
24
+
25
+ <!-- politty:command:authconnection:usage:end -->
26
+
27
+ <!-- politty:command:authconnection:subcommands:start -->
28
+
29
+ **Commands**
30
+
31
+ | Command | Description |
32
+ | ------------------------------------------------------- | --------------------------------------------- |
33
+ | [`authconnection authorize`](#authconnection-authorize) | Authorize an auth connection via OAuth2 flow. |
34
+ | [`authconnection list`](#authconnection-list) | List all auth connections. |
35
+ | [`authconnection revoke`](#authconnection-revoke) | Revoke an auth connection. |
36
+
37
+ <!-- politty:command:authconnection:subcommands:end -->
38
+
39
+ <!-- politty:command:authconnection:global-options-link:start -->
40
+
41
+ See [Global Options](../cli-reference.md#global-options) for options available to all commands.
42
+
43
+ <!-- politty:command:authconnection:global-options-link:end -->
44
+ <!-- politty:command:authconnection authorize:heading:start -->
45
+
46
+ ### authconnection authorize
47
+
48
+ <!-- politty:command:authconnection authorize:heading:end -->
49
+
50
+ <!-- politty:command:authconnection authorize:description:start -->
51
+
52
+ Authorize an auth connection via OAuth2 flow.
53
+
54
+ <!-- politty:command:authconnection authorize:description:end -->
55
+
56
+ <!-- politty:command:authconnection authorize:usage:start -->
57
+
58
+ **Usage**
59
+
60
+ ```
61
+ tailor-sdk authconnection authorize [options]
62
+ ```
63
+
64
+ <!-- politty:command:authconnection authorize:usage:end -->
65
+
66
+ <!-- politty:command:authconnection authorize:options:start -->
67
+
68
+ **Options**
69
+
70
+ | Option | Alias | Description | Required | Default | Env |
71
+ | ------------------------------- | ----- | ------------------------------------------ | -------- | ------------------------ | ------------------------------ |
72
+ | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
73
+ | `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
74
+ | `--name <NAME>` | `-n` | Auth connection name | Yes | - | - |
75
+ | `--scopes <SCOPES>` | - | OAuth2 scopes to request (comma-separated) | No | `"openid,profile,email"` | - |
76
+ | `--port <PORT>` | - | Local callback server port | No | `8080` | - |
77
+ | `--no-browser` | - | Don't open browser automatically | No | `false` | - |
78
+
79
+ <!-- politty:command:authconnection authorize:options:end -->
80
+
81
+ <!-- politty:command:authconnection authorize:global-options-link:start -->
82
+
83
+ See [Global Options](../cli-reference.md#global-options) for options available to all commands.
84
+
85
+ <!-- politty:command:authconnection authorize:global-options-link:end -->
86
+
87
+ <!-- politty:command:authconnection list:heading:start -->
88
+
89
+ ### authconnection list
90
+
91
+ <!-- politty:command:authconnection list:heading:end -->
92
+
93
+ <!-- politty:command:authconnection list:description:start -->
94
+
95
+ List all auth connections.
96
+
97
+ <!-- politty:command:authconnection list:description:end -->
98
+
99
+ <!-- politty:command:authconnection list:usage:start -->
100
+
101
+ **Usage**
102
+
103
+ ```
104
+ tailor-sdk authconnection list [options]
105
+ ```
106
+
107
+ <!-- politty:command:authconnection list:usage:end -->
108
+
109
+ <!-- politty:command:authconnection list:options:start -->
110
+
111
+ **Options**
112
+
113
+ | Option | Alias | Description | Required | Default | Env |
114
+ | ------------------------------- | ----- | ----------------- | -------- | ------- | ------------------------------ |
115
+ | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
116
+ | `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
117
+
118
+ <!-- politty:command:authconnection list:options:end -->
119
+
120
+ <!-- politty:command:authconnection list:global-options-link:start -->
121
+
122
+ See [Global Options](../cli-reference.md#global-options) for options available to all commands.
123
+
124
+ <!-- politty:command:authconnection list:global-options-link:end -->
125
+ <!-- politty:command:authconnection revoke:heading:start -->
126
+
127
+ ### authconnection revoke
128
+
129
+ <!-- politty:command:authconnection revoke:heading:end -->
130
+
131
+ <!-- politty:command:authconnection revoke:description:start -->
132
+
133
+ Revoke an auth connection.
134
+
135
+ <!-- politty:command:authconnection revoke:description:end -->
136
+
137
+ <!-- politty:command:authconnection revoke:usage:start -->
138
+
139
+ **Usage**
140
+
141
+ ```
142
+ tailor-sdk authconnection revoke [options]
143
+ ```
144
+
145
+ <!-- politty:command:authconnection revoke:usage:end -->
146
+
147
+ <!-- politty:command:authconnection revoke:options:start -->
148
+
149
+ **Options**
150
+
151
+ | Option | Alias | Description | Required | Default | Env |
152
+ | ------------------------------- | ----- | ------------------------- | -------- | ------- | ------------------------------ |
153
+ | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | No | - | `TAILOR_PLATFORM_WORKSPACE_ID` |
154
+ | `--profile <PROFILE>` | `-p` | Workspace profile | No | - | `TAILOR_PLATFORM_PROFILE` |
155
+ | `--name <NAME>` | `-n` | Auth connection name | Yes | - | - |
156
+ | `--yes` | `-y` | Skip confirmation prompts | No | `false` | - |
157
+
158
+ <!-- politty:command:authconnection revoke:options:end -->
159
+
160
+ <!-- politty:command:authconnection revoke:global-options-link:start -->
161
+
162
+ See [Global Options](../cli-reference.md#global-options) for options available to all commands.
163
+
164
+ <!-- politty:command:authconnection revoke:global-options-link:end -->
4
165
 
5
166
  <!-- politty:command:machineuser:heading:start -->
6
167
 
@@ -175,12 +175,15 @@ Commands for managing workspaces and profiles.
175
175
 
176
176
  Commands for managing Auth service resources.
177
177
 
178
- | Command | Description |
179
- | ---------------------------------------------------- | -------------------------------------------------------- |
180
- | [machineuser list](./cli/auth.md#machineuser-list) | List all machine users in the application. |
181
- | [machineuser token](./cli/auth.md#machineuser-token) | Get an access token for a machine user. |
182
- | [oauth2client list](./cli/auth.md#oauth2client-list) | List all OAuth2 clients in the application. |
183
- | [oauth2client get](./cli/auth.md#oauth2client-get) | Get OAuth2 client credentials (including client secret). |
178
+ | Command | Description |
179
+ | ------------------------------------------------------------------ | -------------------------------------------------------- |
180
+ | [authconnection authorize](./cli/auth.md#authconnection-authorize) | Authorize an auth connection via OAuth2 flow. |
181
+ | [authconnection list](./cli/auth.md#authconnection-list) | List all auth connections. |
182
+ | [authconnection revoke](./cli/auth.md#authconnection-revoke) | Revoke an auth connection. |
183
+ | [machineuser list](./cli/auth.md#machineuser-list) | List all machine users in the application. |
184
+ | [machineuser token](./cli/auth.md#machineuser-token) | Get an access token for a machine user. |
185
+ | [oauth2client list](./cli/auth.md#oauth2client-list) | List all OAuth2 clients in the application. |
186
+ | [oauth2client get](./cli/auth.md#oauth2client-get) | Get OAuth2 client credentials (including client secret). |
184
187
 
185
188
  ### [Workflow Commands](./cli/workflow.md)
186
189
 
@@ -10,6 +10,7 @@ Auth provides:
10
10
  - Machine users for service-to-service authentication
11
11
  - OAuth 2.0 client configuration
12
12
  - Identity provider integration
13
+ - Auth connections for external OAuth2 provider integration
13
14
 
14
15
  For the official Tailor Platform documentation, see [Auth Guide](https://docs.tailor.tech/guides/auth/overview).
15
16
 
@@ -47,6 +48,15 @@ const auth = defineAuth("my-auth", {
47
48
  grantTypes: ["authorization_code", "refresh_token"],
48
49
  },
49
50
  },
51
+ connections: {
52
+ "google-connection": {
53
+ type: "oauth2",
54
+ providerUrl: "https://accounts.google.com",
55
+ issuerUrl: "https://accounts.google.com",
56
+ clientId: process.env.GOOGLE_CLIENT_ID!,
57
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
58
+ },
59
+ },
50
60
  idProvider: idp.provider("my-provider", "my-client"),
51
61
  });
52
62
 
@@ -341,6 +351,106 @@ idProvider: idp.provider("my-provider", "my-client"),
341
351
 
342
352
  See [IdP](./idp.md) for configuring identity providers.
343
353
 
354
+ ## Auth Connections
355
+
356
+ Auth connections enable OAuth2 authentication with external providers (Google, Microsoft 365, QuickBooks, etc.) for application-to-application flows. Functions can access connection tokens at runtime via `tailor.authconnection.getConnectionToken()`.
357
+
358
+ For the official Tailor Platform documentation, see [AuthConnection Guide](https://docs.tailor.tech/guides/auth/authconnection).
359
+
360
+ ### Setup Flow
361
+
362
+ Setting up an auth connection requires two steps:
363
+
364
+ 1. **Create** the connection (registers the OAuth2 provider credentials)
365
+ 2. **Authorize** the connection (runs the OAuth2 flow to obtain and store tokens)
366
+
367
+ Both steps are needed regardless of whether you manage connections via config or CLI.
368
+
369
+ ### Configuration
370
+
371
+ Define connections in `defineAuth()`:
372
+
373
+ ```typescript
374
+ import { defineAuth } from "@tailor-platform/sdk";
375
+
376
+ export const auth = defineAuth("my-auth", {
377
+ // ... other auth config
378
+ connections: {
379
+ "google-connection": {
380
+ type: "oauth2",
381
+ providerUrl: "https://accounts.google.com",
382
+ issuerUrl: "https://accounts.google.com",
383
+ clientId: process.env.GOOGLE_CLIENT_ID!,
384
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
385
+ },
386
+ },
387
+ });
388
+ ```
389
+
390
+ After `tailor-sdk apply`, authorize the connection:
391
+
392
+ ```bash
393
+ tailor-sdk authconnection authorize --name google-connection \
394
+ --scopes "openid,profile,email"
395
+ ```
396
+
397
+ The authorize command opens a browser for the OAuth2 flow. The authorization code is sent to the platform, which exchanges it for tokens using the client secret registered in the connection config.
398
+
399
+ ### Connection Config Fields
400
+
401
+ | Field | Type | Required | Description |
402
+ | -------------- | -------- | -------- | ------------------------------------------- |
403
+ | `type` | `string` | Yes | Connection type. Currently only `"oauth2"`. |
404
+ | `providerUrl` | `string` | Yes | OAuth2 provider URL. |
405
+ | `issuerUrl` | `string` | Yes | OAuth2 issuer URL for JWT validation. |
406
+ | `clientId` | `string` | Yes | OAuth2 client ID. |
407
+ | `clientSecret` | `string` | Yes | OAuth2 client secret. |
408
+ | `authUrl` | `string` | No | Override for the authorization endpoint. |
409
+ | `tokenUrl` | `string` | No | Override for the token endpoint. |
410
+
411
+ ### Change Detection
412
+
413
+ The SDK uses hash-based change detection for connection configs. Only connections whose configuration has changed since the last `apply` are updated (revoked and recreated). Deleting the `.tailor-sdk/` directory forces all connections to be re-sent.
414
+
415
+ ### `auth.getConnectionToken()`
416
+
417
+ `auth.getConnectionToken()` retrieves connection tokens at runtime by calling `tailor.authconnection.getConnectionToken()` internally. When `connections` is defined in `defineAuth()`, the connection name is type-checked and autocompleted against the defined keys:
418
+
419
+ ```typescript
420
+ import { auth } from "../tailor.config";
421
+
422
+ // In a resolver, executor, or workflow:
423
+ const tokens = await auth.getConnectionToken("google-connection");
424
+ const response = await fetch("https://www.googleapis.com/...", {
425
+ headers: { Authorization: `Bearer ${tokens.access_token}` },
426
+ });
427
+
428
+ // auth.getConnectionToken("unknown"); // Type error — only "google-connection" is allowed
429
+ ```
430
+
431
+ When `connections` is not defined, `getConnectionToken()` accepts any string. This supports connections managed entirely via the CLI.
432
+
433
+ See [Built-in Interfaces](https://docs.tailor.tech/guides/function/builtin-interfaces.html#auth-connection) for the full runtime API.
434
+
435
+ ### CLI Management
436
+
437
+ Auth connections can also be managed via the CLI:
438
+
439
+ ```bash
440
+ # Authorize (opens browser for OAuth2 flow)
441
+ tailor-sdk authconnection authorize --name google-connection
442
+
443
+ # List all connections
444
+ tailor-sdk authconnection list
445
+
446
+ # Revoke a connection
447
+ tailor-sdk authconnection revoke --name google-connection
448
+ ```
449
+
450
+ Connection creation is handled by `tailor-sdk apply` via the config.
451
+
452
+ See [Auth Resource Commands](../cli/auth.md) for full CLI documentation.
453
+
344
454
  ## Before Login Hook
345
455
 
346
456
  Run custom logic before a user logs in. This is useful for JIT (Just-In-Time) user provisioning — automatically creating or updating user records when a user authenticates for the first time.
@@ -379,6 +489,11 @@ export const auth = defineAuth("my-auth", {
379
489
  Manage Auth resources using the CLI:
380
490
 
381
491
  ```bash
492
+ # Auth connections
493
+ tailor-sdk authconnection authorize --name <name>
494
+ tailor-sdk authconnection list
495
+ tailor-sdk authconnection revoke --name <name>
496
+
382
497
  # List machine users
383
498
  tailor-sdk machineuser list
384
499
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.33.2",
3
+ "version": "1.34.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {