@tailor-platform/sdk 1.70.1 → 1.72.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 +32 -0
- package/dist/{authconnection-BIYzEh2p.d.mts → authconnection-CqfaJfrC.d.mts} +8 -15
- package/dist/{authconnection-Ds2Ahpum.mjs → authconnection-D7lsvsKY.mjs} +2 -2
- package/dist/authconnection-D7lsvsKY.mjs.map +1 -0
- package/dist/cli/index.mjs +781 -185
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +7 -6
- package/dist/cli/lib.mjs +1 -1
- package/dist/completion/zsh-worker.zsh +124 -25
- package/dist/configure/index.d.mts +5 -4
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{index-C-vsbx27.d.mts → index-BDBU7x-i.d.mts} +2 -2
- package/dist/{index-dKNk8hjo.d.mts → index-BSlv_YrG.d.mts} +2 -2
- package/dist/{index-BAEaAqmz.d.mts → index-BzGqTY5x.d.mts} +16 -4
- package/dist/{index-CKI0eZP6.d.mts → index-D3_Au3wu.d.mts} +2 -2
- package/dist/{index-CrqOgUF2.d.mts → index-DtFRlrww.d.mts} +2 -2
- package/dist/{index-DESLU9kI.d.mts → index-jeE3UvF2.d.mts} +2 -2
- package/dist/mock-wf5qeZLi.mjs.map +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/runtime/authconnection.d.mts +1 -1
- package/dist/runtime/authconnection.mjs +1 -1
- package/dist/runtime/globals.d.mts +1 -1
- package/dist/runtime/index.d.mts +2 -2
- package/dist/runtime/index.mjs +1 -1
- package/dist/{runtime-BpHVwifd.mjs → runtime-Cd375HD-.mjs} +23 -10
- package/dist/runtime-Cd375HD-.mjs.map +1 -0
- package/dist/{types-Dynq4AJv.d.mts → types-aqnqTCfO.d.mts} +4 -342
- package/dist/types-v_ErzNUF.d.mts +345 -0
- package/dist/utils/test/index.d.mts +2 -2
- package/dist/vitest/index.d.mts +4 -3
- package/dist/{workflow.generated-DJULCuRr.d.mts → workflow.generated-Da1zECDw.d.mts} +3 -2
- package/docs/cli/setup.md +129 -19
- package/docs/cli-reference.md +9 -4
- package/docs/services/auth.md +10 -8
- package/docs/testing.md +1 -1
- package/package.json +1 -1
- package/dist/authconnection-Ds2Ahpum.mjs.map +0 -1
- package/dist/runtime-BpHVwifd.mjs.map +0 -1
package/docs/services/auth.md
CHANGED
|
@@ -308,7 +308,7 @@ export default createResolver({
|
|
|
308
308
|
});
|
|
309
309
|
```
|
|
310
310
|
|
|
311
|
-
Type narrowing is provided by the generated `tailor.d.ts` (the `MachineUserNameRegistry` interface). Run `tailor-sdk generate` (or `
|
|
311
|
+
Type narrowing is provided by the generated `tailor.d.ts` (the `MachineUserNameRegistry` interface). Run `tailor-sdk generate` (or `deploy`) after defining new machine users to refresh it.
|
|
312
312
|
|
|
313
313
|
> **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.
|
|
314
314
|
|
|
@@ -365,7 +365,7 @@ See [IdP](./idp.md) for configuring identity providers.
|
|
|
365
365
|
|
|
366
366
|
## Auth Connections
|
|
367
367
|
|
|
368
|
-
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 `
|
|
368
|
+
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 `authconnection.getConnectionToken()` (from `@tailor-platform/sdk/runtime`).
|
|
369
369
|
|
|
370
370
|
For the official Tailor Platform documentation, see [AuthConnection Guide](https://docs.tailor.tech/guides/auth/authconnection).
|
|
371
371
|
|
|
@@ -429,23 +429,25 @@ The authorize command opens a browser for the OAuth2 flow. The authorization cod
|
|
|
429
429
|
| `authUrl` | `string` | No | Override for the authorization endpoint. |
|
|
430
430
|
| `tokenUrl` | `string` | No | Override for the token endpoint. |
|
|
431
431
|
|
|
432
|
-
###
|
|
432
|
+
### Retrieving Connection Tokens
|
|
433
433
|
|
|
434
|
-
`
|
|
434
|
+
Use `authconnection.getConnectionToken()` from `@tailor-platform/sdk/runtime` to retrieve connection tokens at runtime. The connection name is type-checked and autocompleted against the connections defined in `defineAuth()`'s `connections`:
|
|
435
435
|
|
|
436
436
|
```typescript
|
|
437
|
-
import {
|
|
437
|
+
import { authconnection } from "@tailor-platform/sdk/runtime";
|
|
438
438
|
|
|
439
439
|
// In a resolver, executor, or workflow:
|
|
440
|
-
const tokens = await
|
|
440
|
+
const tokens = await authconnection.getConnectionToken("google-connection");
|
|
441
441
|
const response = await fetch("https://www.googleapis.com/...", {
|
|
442
442
|
headers: { Authorization: `Bearer ${tokens.access_token}` },
|
|
443
443
|
});
|
|
444
444
|
|
|
445
|
-
//
|
|
445
|
+
// authconnection.getConnectionToken("unknown"); // Type error — only "google-connection" is allowed
|
|
446
446
|
```
|
|
447
447
|
|
|
448
|
-
|
|
448
|
+
Type narrowing is provided by the generated `tailor.d.ts` (the `ConnectionNameRegistry` interface). Run `tailor-sdk generate` (or `deploy`) after defining new connections to refresh it. Before the first generate, or when `connections` is not defined in `defineAuth()`, `getConnectionToken()` accepts any string — this also supports connections managed entirely via the CLI.
|
|
449
|
+
|
|
450
|
+
> **Deprecated:** `auth.getConnectionToken("<name>")` still works, but is deprecated. Importing `auth` from `tailor.config.ts` into runtime files pulls config-layer (Node-only) dependencies into the bundle.
|
|
449
451
|
|
|
450
452
|
See [Built-in Interfaces](https://docs.tailor.tech/guides/function/builtin-interfaces.html#auth-connection) for the full runtime API.
|
|
451
453
|
|
package/docs/testing.md
CHANGED
|
@@ -185,7 +185,7 @@ import { mockAuthconnection } from "@tailor-platform/sdk/vitest";
|
|
|
185
185
|
test("returns configured token", async () => {
|
|
186
186
|
using ac = mockAuthconnection();
|
|
187
187
|
ac.setTokens({
|
|
188
|
-
google: { access_token: "ya29.xxx"
|
|
188
|
+
google: { access_token: "ya29.xxx" },
|
|
189
189
|
});
|
|
190
190
|
|
|
191
191
|
const token = await tailor.authconnection.getConnectionToken("google");
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authconnection-Ds2Ahpum.mjs","names":[],"sources":["../src/runtime/authconnection.ts"],"sourcesContent":["/**\n * Auth connection utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.authconnection` runtime API.\n * At runtime this delegates to `globalThis.tailor.authconnection`. Use\n * `mockAuthconnection` from `@tailor-platform/sdk/vitest` to mock in unit tests.\n * @example\n * import { authconnection } from \"@tailor-platform/sdk/runtime\";\n *\n * const token = await authconnection.getConnectionToken(\"my-connection\");\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Platform API surface for `tailor.authconnection`. Describes the shape the\n * platform runtime injects on `globalThis.tailor.authconnection`.\n *\n * Each method below is also re-exported as a top-level named export from this\n * module so callers can either `import * as authconnection from\n * \"@tailor-platform/sdk/runtime/authconnection\"` or pick individual methods.\n */\nexport interface TailorAuthconnectionAPI {\n /**\n * Returns the access token for the given auth connection.\n * @param connectionName - Auth connection name as defined in tailor.config\n * @returns Token payload (provider-specific shape)\n */\n getConnectionToken(connectionName: string): Promise<any>;\n}\n\nconst api = (): TailorAuthconnectionAPI =>\n (globalThis as { tailor: { authconnection: TailorAuthconnectionAPI } }).tailor.authconnection;\n\n/**\n * See {@link TailorAuthconnectionAPI.getConnectionToken}.\n * @param args - Forwarded to {@link TailorAuthconnectionAPI.getConnectionToken}\n * @returns Token payload (provider-specific shape)\n */\nexport const getConnectionToken: TailorAuthconnectionAPI[\"getConnectionToken\"] = (...args) =>\n api().getConnectionToken(...args);\n"],"mappings":";;;;;AA+BA,MAAM,YACH,WAAuE,OAAO;;;;;;AAOjF,MAAa,sBAAqE,GAAG,SACnF,IAAI,CAAC,CAAC,mBAAmB,GAAG,IAAI"}
|