@tailor-platform/sdk 1.70.1 → 1.71.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 (38) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/{authconnection-BIYzEh2p.d.mts → authconnection-CqfaJfrC.d.mts} +8 -15
  3. package/dist/{authconnection-Ds2Ahpum.mjs → authconnection-D7lsvsKY.mjs} +2 -2
  4. package/dist/authconnection-D7lsvsKY.mjs.map +1 -0
  5. package/dist/cli/index.mjs +1 -1
  6. package/dist/cli/lib.d.mts +7 -6
  7. package/dist/cli/lib.mjs +1 -1
  8. package/dist/completion/zsh-worker.zsh +1 -1
  9. package/dist/configure/index.d.mts +5 -4
  10. package/dist/configure/index.mjs.map +1 -1
  11. package/dist/{index-C-vsbx27.d.mts → index-BDBU7x-i.d.mts} +2 -2
  12. package/dist/{index-dKNk8hjo.d.mts → index-BSlv_YrG.d.mts} +2 -2
  13. package/dist/{index-BAEaAqmz.d.mts → index-BzGqTY5x.d.mts} +16 -4
  14. package/dist/{index-CKI0eZP6.d.mts → index-D3_Au3wu.d.mts} +2 -2
  15. package/dist/{index-CrqOgUF2.d.mts → index-DtFRlrww.d.mts} +2 -2
  16. package/dist/{index-DESLU9kI.d.mts → index-jeE3UvF2.d.mts} +2 -2
  17. package/dist/mock-wf5qeZLi.mjs.map +1 -1
  18. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  19. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  20. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  21. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  22. package/dist/runtime/authconnection.d.mts +1 -1
  23. package/dist/runtime/authconnection.mjs +1 -1
  24. package/dist/runtime/globals.d.mts +1 -1
  25. package/dist/runtime/index.d.mts +2 -2
  26. package/dist/runtime/index.mjs +1 -1
  27. package/dist/{runtime-BpHVwifd.mjs → runtime-Cd375HD-.mjs} +23 -10
  28. package/dist/runtime-Cd375HD-.mjs.map +1 -0
  29. package/dist/{types-Dynq4AJv.d.mts → types-aqnqTCfO.d.mts} +4 -342
  30. package/dist/types-v_ErzNUF.d.mts +345 -0
  31. package/dist/utils/test/index.d.mts +2 -2
  32. package/dist/vitest/index.d.mts +4 -3
  33. package/dist/{workflow.generated-DJULCuRr.d.mts → workflow.generated-Da1zECDw.d.mts} +3 -2
  34. package/docs/services/auth.md +10 -8
  35. package/docs/testing.md +1 -1
  36. package/package.json +1 -1
  37. package/dist/authconnection-Ds2Ahpum.mjs.map +0 -1
  38. package/dist/runtime-BpHVwifd.mjs.map +0 -1
@@ -0,0 +1,345 @@
1
+ import { o as TailorEnv } from "./types-DTcZ2Yax.mjs";
2
+ import { C as FieldMetadata, D as TailorField, F as output, O as TailorFieldType, m as TailorDBInstance, x as DefinedFieldMetadata } from "./types-rj8YJcEe.mjs";
3
+ import { IsAny, JsonObject, JsonValue } from "type-fest";
4
+
5
+ //#region src/types/auth-connection.generated.d.ts
6
+ type AuthConnectionOAuth2Config = {
7
+ /** OAuth2 provider URL */providerUrl: string; /** OAuth2 issuer URL */
8
+ issuerUrl: string; /** OAuth2 client ID */
9
+ clientId: string; /** OAuth2 client secret */
10
+ clientSecret: string; /** OAuth2 authorization endpoint override */
11
+ authUrl?: string | undefined; /** OAuth2 token endpoint override */
12
+ tokenUrl?: string | undefined;
13
+ };
14
+ type AuthConnectionConfig = {
15
+ type: "oauth2";
16
+ providerUrl: string;
17
+ issuerUrl: string;
18
+ clientId: string;
19
+ clientSecret: string;
20
+ authUrl?: string | undefined;
21
+ tokenUrl?: string | undefined;
22
+ };
23
+ //#endregion
24
+ //#region src/types/auth.generated.d.ts
25
+ type AuthInvokerObject = {
26
+ /** Auth namespace */namespace: string; /** Machine user name for authentication */
27
+ machineUserName: string;
28
+ };
29
+ type AuthInvoker = AuthInvokerObject;
30
+ type OIDC = {
31
+ /** Identity provider name */name: string;
32
+ kind: "OIDC"; /** OAuth2 client ID */
33
+ clientID: string; /** OAuth2 client secret */
34
+ clientSecret: {
35
+ vaultName: string;
36
+ secretKey: string;
37
+ }; /** OIDC provider URL */
38
+ providerURL: string; /** OIDC issuer URL (defaults to providerURL) */
39
+ issuerURL?: string | undefined; /** JWT claim to use as username */
40
+ usernameClaim?: string | undefined;
41
+ };
42
+ type SAML = {
43
+ /** Identity provider name */name: string;
44
+ kind: "SAML"; /** Enable signing of SAML requests */
45
+ enableSignRequest: boolean; /** URL to fetch SAML metadata (mutually exclusive with rawMetadata) */
46
+ metadataURL?: string | undefined; /** Raw SAML metadata XML (mutually exclusive with metadataURL) */
47
+ rawMetadata?: string | undefined; /** URL to redirect to when SAML ACS receives a response with an empty RelayState. */
48
+ defaultRedirectURL?: string | undefined;
49
+ };
50
+ type IDToken = {
51
+ /** Identity provider name */name: string;
52
+ kind: "IDToken"; /** ID token provider URL */
53
+ providerURL: string; /** Client ID for ID token validation */
54
+ clientID: string; /** ID token issuer URL */
55
+ issuerURL?: string | undefined; /** JWT claim to use as username */
56
+ usernameClaim?: string | undefined;
57
+ };
58
+ type BuiltinIdP = {
59
+ /** Identity provider name */name: string;
60
+ kind: "BuiltInIdP"; /** IdP namespace */
61
+ namespace: string; /** OAuth2 client name in the IdP */
62
+ clientName: string;
63
+ };
64
+ type IdProvider = OIDC | SAML | IDToken | BuiltinIdP;
65
+ type OAuth2ClientInput = {
66
+ /** Allowed redirect URIs */redirectURIs: (`https://${string}` | `http://${string}` | `${string}:url` | `${string}:url/${string}`)[]; /** Client description */
67
+ description?: string | undefined; /** Allowed OAuth2 grant types */
68
+ grantTypes?: ("authorization_code" | "refresh_token")[] | undefined; /** OAuth2 client type */
69
+ clientType?: "confidential" | "public" | "browser" | undefined; /** Access token lifetime in seconds (60-86400) */
70
+ accessTokenLifetimeSeconds?: number | undefined; /** Refresh token lifetime in seconds (60-604800) */
71
+ refreshTokenLifetimeSeconds?: number | undefined; /** Require DPoP (Demonstrating Proof-of-Possession) for token requests */
72
+ requireDpop?: boolean | undefined;
73
+ };
74
+ type OAuth2Client = {
75
+ /** Allowed OAuth2 grant types */grantTypes: ("authorization_code" | "refresh_token")[]; /** Allowed redirect URIs */
76
+ redirectURIs: (`https://${string}` | `http://${string}` | `${string}:url` | `${string}:url/${string}`)[]; /** Access token lifetime in seconds (60-86400) */
77
+ accessTokenLifetimeSeconds: {
78
+ seconds: bigint;
79
+ nanos: number;
80
+ } | undefined; /** Refresh token lifetime in seconds (60-604800) */
81
+ refreshTokenLifetimeSeconds: {
82
+ seconds: bigint;
83
+ nanos: number;
84
+ } | undefined; /** Client description */
85
+ description?: string | undefined; /** OAuth2 client type */
86
+ clientType?: "confidential" | "public" | "browser" | undefined; /** Require DPoP (Demonstrating Proof-of-Possession) for token requests */
87
+ requireDpop?: boolean | undefined;
88
+ };
89
+ type SCIMAuthorization = {
90
+ /** SCIM authorization type */type: "oauth2" | "bearer"; /** Bearer token secret (required for bearer type) */
91
+ bearerSecret?: {
92
+ vaultName: string;
93
+ secretKey: string;
94
+ } | undefined;
95
+ };
96
+ type SCIMAttribute = {
97
+ /** Attribute data type */type: "string" | "number" | "boolean" | "datetime" | "complex"; /** Attribute name */
98
+ name: string; /** Attribute description */
99
+ description?: string | undefined; /** Attribute mutability */
100
+ mutability?: "readOnly" | "readWrite" | "writeOnly" | undefined; /** Whether the attribute is required */
101
+ required?: boolean | undefined; /** Whether the attribute can have multiple values */
102
+ multiValued?: boolean | undefined; /** Uniqueness constraint */
103
+ uniqueness?: "none" | "server" | "global" | undefined; /** List of canonical values */
104
+ canonicalValues?: string[] | null | undefined;
105
+ subAttributes?: SCIMAttribute[] | null | undefined;
106
+ };
107
+ type SCIMAttributeMapping = {
108
+ /** TailorDB field name to map to */tailorDBField: string; /** SCIM attribute path */
109
+ scimPath: string;
110
+ };
111
+ type SCIMResource = {
112
+ /** SCIM resource name */name: string; /** TailorDB namespace for the resource */
113
+ tailorDBNamespace: string; /** TailorDB type name for the resource */
114
+ tailorDBType: string; /** Core SCIM schema definition */
115
+ coreSchema: {
116
+ /** SCIM resource name */name: string;
117
+ attributes: {
118
+ type: "string" | "number" | "boolean" | "datetime" | "complex"; /** SCIM resource name */
119
+ name: string;
120
+ description?: string | undefined;
121
+ mutability?: "readOnly" | "readWrite" | "writeOnly" | undefined;
122
+ required?: boolean | undefined;
123
+ multiValued?: boolean | undefined;
124
+ uniqueness?: "none" | "server" | "global" | undefined;
125
+ canonicalValues?: string[] | null | undefined;
126
+ subAttributes?: any[] | null | undefined;
127
+ }[];
128
+ }; /** Attribute mapping configuration */
129
+ attributeMapping: {
130
+ tailorDBField: string;
131
+ scimPath: string;
132
+ }[];
133
+ };
134
+ type SCIMConfig = {
135
+ /** Machine user name for SCIM operations */machineUserName: string; /** SCIM authorization configuration */
136
+ authorization: {
137
+ type: "oauth2" | "bearer";
138
+ bearerSecret?: {
139
+ vaultName: string;
140
+ secretKey: string;
141
+ } | undefined;
142
+ }; /** SCIM resource definitions */
143
+ resources: {
144
+ name: string;
145
+ tailorDBNamespace: string;
146
+ tailorDBType: string;
147
+ coreSchema: {
148
+ name: string;
149
+ attributes: {
150
+ type: "string" | "number" | "boolean" | "datetime" | "complex";
151
+ name: string;
152
+ description?: string | undefined;
153
+ mutability?: "readOnly" | "readWrite" | "writeOnly" | undefined;
154
+ required?: boolean | undefined;
155
+ multiValued?: boolean | undefined;
156
+ uniqueness?: "none" | "server" | "global" | undefined;
157
+ canonicalValues?: string[] | null | undefined;
158
+ subAttributes?: any[] | null | undefined;
159
+ }[];
160
+ };
161
+ attributeMapping: {
162
+ tailorDBField: string;
163
+ scimPath: string;
164
+ }[];
165
+ }[];
166
+ };
167
+ type TenantProvider = {
168
+ /** TailorDB namespace for the tenant type */namespace: string; /** TailorDB type name for tenants */
169
+ type: string; /** Field used as the tenant signature */
170
+ signatureField: string;
171
+ };
172
+ //#endregion
173
+ //#region src/configure/services/auth/types.d.ts
174
+ type OAuth2ClientGrantType = OAuth2Client["grantTypes"][number];
175
+ type SCIMAttributeType = SCIMAttribute["type"];
176
+ type AuthInvokerWithName<M extends string> = Omit<AuthInvoker, "machineUserName"> & {
177
+ machineUserName: M;
178
+ };
179
+ /** Result of retrieving a connection token at runtime. */
180
+ type AuthConnectionTokenResult = {
181
+ access_token: string;
182
+ };
183
+ type ValueOperand = string | boolean | string[] | boolean[];
184
+ type AuthAttributeValue = ValueOperand | null | undefined;
185
+ type UserFieldKeys<User extends TailorDBInstance> = keyof output<User> & string;
186
+ type FieldDefined<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = User["fields"][Key] extends {
187
+ _defined: infer Defined;
188
+ } ? Defined : never;
189
+ type FieldOutput<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = output<User>[Key];
190
+ type FieldIsRequired<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = undefined extends FieldOutput<User, Key> ? false : true;
191
+ type FieldIsOfType<User extends TailorDBInstance, Key extends UserFieldKeys<User>, Type extends string> = FieldDefined<User, Key> extends {
192
+ type: Type;
193
+ } ? true : false;
194
+ type FieldIsArray<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
195
+ array: true;
196
+ } ? true : false;
197
+ type FieldIsUnique<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
198
+ unique: true;
199
+ } ? true : false;
200
+ type FieldSupportsValueOperand<User extends TailorDBInstance, Key extends UserFieldKeys<User>> = FieldOutput<User, Key> extends ValueOperand | null | undefined ? true : false;
201
+ type UsernameFieldKey<User extends TailorDBInstance> = IsAny<User> extends true ? string : { [K in UserFieldKeys<User>]: FieldIsRequired<User, K> extends true ? FieldIsOfType<User, K, "string"> extends true ? FieldIsArray<User, K> extends true ? never : FieldIsUnique<User, K> extends true ? K : never : never : never }[UserFieldKeys<User>];
202
+ type UserAttributeKey<User extends TailorDBInstance> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldSupportsValueOperand<User, K> extends true ? FieldIsOfType<User, K, "datetime" | "date" | "time"> extends true ? never : K : never }[UserFieldKeys<User>];
203
+ type UserAttributeListKey<User extends TailorDBInstance> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldIsOfType<User, K, "uuid"> extends true ? FieldIsArray<User, K> extends true ? never : K : never }[UserFieldKeys<User>];
204
+ type UserAttributeMap<User extends TailorDBInstance> = { [K in UserAttributeKey<User>]?: true };
205
+ type DisallowExtraKeys<T, Allowed extends PropertyKey> = T & { [K in Exclude<keyof T, Allowed>]: never };
206
+ type AttributeListValue<User extends TailorDBInstance, Key extends UserAttributeListKey<User>> = Key extends keyof output<User> ? output<User>[Key] : never;
207
+ type AttributeListToTuple<User extends TailorDBInstance, AttributeList extends readonly UserAttributeListKey<User>[]> = { [Index in keyof AttributeList]: AttributeList[Index] extends UserAttributeListKey<User> ? AttributeListValue<User, AttributeList[Index]> : never };
208
+ type AttributeMapSelectedKeys<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User>> = Extract<{ [K in keyof AttributeMap]-?: undefined extends AttributeMap[K] ? never : K }[keyof AttributeMap], UserAttributeKey<User>>;
209
+ type UserProfile<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[]> = {
210
+ /**
211
+ * TailorDB namespace where the user type is defined.
212
+ *
213
+ * Usually auto-resolved, so you don't need to specify this.
214
+ * Required only when multiple TailorDBs exist and the type is in an external TailorDB.
215
+ */
216
+ namespace?: string;
217
+ type: User;
218
+ usernameField: UsernameFieldKey<User>;
219
+ attributes?: DisallowExtraKeys<AttributeMap, UserAttributeKey<User>>;
220
+ attributeList?: AttributeList;
221
+ };
222
+ type MachineUserAttributeFields = Record<string, TailorField<DefinedFieldMetadata, unknown, FieldMetadata, TailorFieldType>>;
223
+ type TailorFieldOutputValue<Field> = Field extends TailorField<DefinedFieldMetadata, infer Output, FieldMetadata, TailorFieldType> ? Output : never;
224
+ type MachineUserAttributeValues<Fields extends MachineUserAttributeFields> = { [K in keyof Fields]: TailorFieldOutputValue<Fields[K]> extends ValueOperand | null | undefined ? TailorFieldOutputValue<Fields[K]> : never };
225
+ type MachineUserFromAttributes<Fields extends MachineUserAttributeFields> = (keyof Fields extends never ? {
226
+ attributes?: never;
227
+ } : {
228
+ attributes: DisallowExtraKeys<MachineUserAttributeValues<Fields>, keyof Fields>;
229
+ }) & {
230
+ attributeList?: string[];
231
+ };
232
+ type MachineUser<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User> = UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[] = [], MachineUserAttributes extends MachineUserAttributeFields | undefined = undefined> = IsAny<MachineUserAttributes> extends true ? IsAny<User> extends true ? {
233
+ attributes: Record<string, AuthAttributeValue>;
234
+ attributeList?: string[];
235
+ } : (AttributeMapSelectedKeys<User, AttributeMap> extends never ? {
236
+ attributes?: never;
237
+ } : {
238
+ attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap>>]?: never };
239
+ }) & ([] extends AttributeList ? {
240
+ attributeList?: never;
241
+ } : {
242
+ attributeList: AttributeListToTuple<User, AttributeList>;
243
+ }) : [MachineUserAttributes] extends [MachineUserAttributeFields] ? MachineUserFromAttributes<MachineUserAttributes> : IsAny<User> extends true ? {
244
+ attributes: Record<string, AuthAttributeValue>;
245
+ attributeList?: string[];
246
+ } : (AttributeMapSelectedKeys<User, AttributeMap> extends never ? {
247
+ attributes?: never;
248
+ } : {
249
+ attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap>>]?: never };
250
+ }) & ([] extends AttributeList ? {
251
+ attributeList?: never;
252
+ } : {
253
+ attributeList: AttributeListToTuple<User, AttributeList>;
254
+ });
255
+ /** Upstream OAuth provider that federated a login through the Built-in IdP. */
256
+ type FederatedIdentityProvider = "google" | "microsoft";
257
+ /**
258
+ * Profile claims forwarded from the upstream OAuth provider's ID token.
259
+ *
260
+ * Commonly present claims are typed; any other claim the provider issues is
261
+ * forwarded as-is and reachable through the index signature. Availability
262
+ * varies by provider (e.g. Microsoft does not issue `picture`).
263
+ */
264
+ type FederatedIdentityClaims = {
265
+ name?: string;
266
+ given_name?: string;
267
+ family_name?: string;
268
+ picture?: string;
269
+ locale?: string;
270
+ [claim: string]: JsonValue | undefined;
271
+ };
272
+ /**
273
+ * The upstream identity that federated this login, populated when a user signs
274
+ * in through a Built-in IdP OAuth provider (Google or Microsoft).
275
+ *
276
+ * Available on {@link BeforeLoginClaims.federated_identity}; `undefined` for
277
+ * password logins.
278
+ */
279
+ type FederatedIdentity = {
280
+ provider: FederatedIdentityProvider;
281
+ claims: FederatedIdentityClaims;
282
+ };
283
+ /**
284
+ * Token claims passed to the {@link BeforeLoginHook} handler. Carries the IdP's
285
+ * own claims (e.g. `sub`, `email`) plus, for federated logins, the upstream
286
+ * provider's profile under {@link BeforeLoginClaims.federated_identity}.
287
+ */
288
+ type BeforeLoginClaims = JsonObject & {
289
+ /** Present only for federated (Google/Microsoft) logins; `undefined` for password logins. */federated_identity?: FederatedIdentity;
290
+ };
291
+ type BeforeLoginHookArgs = {
292
+ claims: BeforeLoginClaims;
293
+ idpConfigName: string; /** Environment variables defined in `defineConfig({ env })`. */
294
+ env: TailorEnv;
295
+ };
296
+ type BeforeLoginHook<MachineUserNames extends string> = {
297
+ handler(args: BeforeLoginHookArgs): Promise<void>;
298
+ invoker: NoInfer<MachineUserNames>;
299
+ };
300
+ type AuthHooks<MachineUserNames extends string> = {
301
+ beforeLogin?: BeforeLoginHook<MachineUserNames>;
302
+ };
303
+ type AuthServiceInput<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[], MachineUserNames extends string, MachineUserAttributes extends MachineUserAttributeFields | undefined = MachineUserAttributeFields | undefined, ConnectionNames extends string = string> = {
304
+ hooks?: AuthHooks<MachineUserNames>;
305
+ userProfile?: UserProfile<User, AttributeMap, AttributeList>;
306
+ machineUserAttributes?: MachineUserAttributes;
307
+ machineUsers?: Record<MachineUserNames, MachineUser<User, AttributeMap, AttributeList, MachineUserAttributes>>;
308
+ oauth2Clients?: Record<string, OAuth2ClientInput>;
309
+ idProvider?: IdProvider;
310
+ scim?: SCIMConfig;
311
+ tenantProvider?: TenantProvider;
312
+ connections?: Record<ConnectionNames, AuthConnectionConfig>;
313
+ publishSessionEvents?: boolean;
314
+ };
315
+ declare const authDefinitionBrand: unique symbol;
316
+ type AuthDefinitionBrand = {
317
+ readonly [authDefinitionBrand]: true;
318
+ };
319
+ type ConnectionNames<Config> = Config extends {
320
+ connections?: Record<infer K, unknown>;
321
+ } ? K & string : string;
322
+ type DefinedAuth<Name extends string, Config, MachineUserNames extends string> = Config & {
323
+ name: Name;
324
+ /**
325
+ * @deprecated Pass the machine user name directly as a string instead, e.g. `authInvoker: "machine-user-name"`.
326
+ * Using this function pulls config-layer (Node-only) dependencies into runtime bundles.
327
+ */
328
+ invoker<M extends MachineUserNames>(machineUser: M): AuthInvokerWithName<M>;
329
+ /**
330
+ * @deprecated Use `authconnection.getConnectionToken(...)` from `@tailor-platform/sdk/runtime` instead.
331
+ * Importing `auth` from `tailor.config.ts` into runtime files pulls config-layer (Node-only)
332
+ * dependencies into the bundle.
333
+ */
334
+ getConnectionToken<C extends ConnectionNames<Config>>(connectionName: C): Promise<AuthConnectionTokenResult>;
335
+ } & AuthDefinitionBrand;
336
+ type AuthExternalConfig = {
337
+ name: string;
338
+ external: true;
339
+ };
340
+ type AuthServiceInputLoose = AuthServiceInput<any, any, any, string, any>;
341
+ type AuthOwnConfig = DefinedAuth<string, AuthServiceInputLoose, string>;
342
+ type AuthConfig = AuthOwnConfig | AuthExternalConfig;
343
+ //#endregion
344
+ export { SCIMConfig as A, OAuth2Client as C, SCIMAttribute as D, SAML as E, TenantProvider as M, AuthConnectionConfig as N, SCIMAttributeMapping as O, AuthConnectionOAuth2Config as P, IdProvider as S, OIDC as T, UsernameFieldKey as _, AuthServiceInput as a, BuiltinIdP as b, DefinedAuth as c, FederatedIdentityProvider as d, OAuth2ClientGrantType as f, UserAttributeMap as g, UserAttributeListKey as h, AuthOwnConfig as i, SCIMResource as j, SCIMAuthorization as k, FederatedIdentity as l, UserAttributeKey as m, AuthConnectionTokenResult as n, BeforeLoginClaims as o, SCIMAttributeType as p, AuthExternalConfig as r, BeforeLoginHookArgs as s, AuthConfig as t, FederatedIdentityClaims as u, ValueOperand as v, OAuth2ClientInput as w, IDToken as x, AuthInvoker as y };
345
+ //# sourceMappingURL=types-v_ErzNUF.d.mts.map
@@ -1,6 +1,6 @@
1
1
  import { s as TailorInvoker } from "../../types-DTcZ2Yax.mjs";
2
- import { j as TailorDBType } from "../../workflow.generated-DJULCuRr.mjs";
3
- import { Et as WORKFLOW_TEST_ENV_KEY, It as TailorField, n as output } from "../../index-BAEaAqmz.mjs";
2
+ import { j as TailorDBType } from "../../workflow.generated-Da1zECDw.mjs";
3
+ import { Et as WORKFLOW_TEST_ENV_KEY, Rt as TailorField, n as output } from "../../index-BzGqTY5x.mjs";
4
4
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
5
 
6
6
  //#region src/utils/test/mock.d.ts
@@ -1,6 +1,7 @@
1
1
  import { o as TailorEnv } from "../types-DTcZ2Yax.mjs";
2
2
  import { Kysely, OperationNode, OperationNodeKind, Transaction } from "kysely";
3
3
  import { Mock } from "vitest";
4
+ import { AuthConnectionTokenResult, ConnectionName } from "@tailor-platform/sdk";
4
5
  import { Plugin } from "vitest/config";
5
6
 
6
7
  //#region src/vitest/mock.d.ts
@@ -41,7 +42,7 @@ interface SecretCall {
41
42
  names?: readonly string[];
42
43
  }
43
44
  interface AuthConnectionCall {
44
- connectionName: string;
45
+ connectionName: ConnectionName;
45
46
  }
46
47
  interface IdpCall {
47
48
  method: string;
@@ -241,8 +242,8 @@ declare function mockSecretmanager(): {
241
242
  * ```
242
243
  */
243
244
  declare function mockAuthconnection(): {
244
- /** The `getConnectionToken` `vi.fn`. */getConnectionToken: Mock<(connectionName: string) => Promise<any>>;
245
- setTokens(value: Record<string, unknown>): void;
245
+ /** The `getConnectionToken` `vi.fn`. */getConnectionToken: Mock<(connectionName: ConnectionName) => Promise<AuthConnectionTokenResult>>;
246
+ setTokens(value: Partial<Record<ConnectionName, AuthConnectionTokenResult>>): void;
246
247
  readonly calls: AuthConnectionCall[];
247
248
  reset(): void;
248
249
  } & Disposable;
@@ -1,6 +1,7 @@
1
1
  import { c as TailorUser, i as InferredAttributeMap } from "./types-DTcZ2Yax.mjs";
2
2
  import { A as Validators, E as FieldValidateInput, F as output, O as TailorFieldType, P as TypeLevelError, S as EnumValue, T as FieldOutput, a as Hooks, g as TailorDBType$1, h as TailorDBServiceInput, i as Hook, j as InferFieldsOutput, k as TailorToTs, l as RelationType, n as DefinedDBFieldMetadata, o as IndexDef, p as TailorDBField$1, r as ExcludeNestedDBFields, t as DBFieldMetadata, u as SerialConfig, v as TypeFeatures, w as FieldOptions } from "./types-rj8YJcEe.mjs";
3
- import { it as BuiltinIdP, o as PluginConfigs, z as AuthConfig } from "./types-Dynq4AJv.mjs";
3
+ import { b as BuiltinIdP, t as AuthConfig } from "./types-v_ErzNUF.mjs";
4
+ import { o as PluginConfigs } from "./types-aqnqTCfO.mjs";
4
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
5
6
 
6
7
  //#region src/configure/types/field.d.ts
@@ -1344,4 +1345,4 @@ type ConcurrencyPolicy = {
1344
1345
  };
1345
1346
  //#endregion
1346
1347
  export { TailorDBInstance as A, IdPInput as C, TailorAnyDBField as D, AIGatewayInput as E, TailorTypePermission as F, unsafeAllowAllGqlPermission as I, unsafeAllowAllTypePermission as L, db as M, PermissionCondition as N, TailorAnyDBType as O, TailorTypeGqlPermission as P, AllowedValues as R, IdPGqlOperationsInput as S, AIGatewayDefinitionBrand as T, IdPConfig as _, ExecutorServiceConfig as a, IdPEmailConfig as b, ResolverServiceConfig as c, WorkflowServiceInput as d, StaticWebsiteConfig as f, SecretsDefinitionBrand as g, SecretsConfig as h, AppConfig as i, TailorDBType as j, TailorDBField as k, ResolverServiceInput as l, StaticWebsiteInput as m, RetryPolicy as n, ExecutorServiceInput as o, StaticWebsiteDefinitionBrand as p, HttpAdapterConfigInput as r, ResolverExternalConfig as s, ConcurrencyPolicy as t, WorkflowServiceConfig as u, IdPExternalConfig as v, AIGatewayConfig as w, IdPGqlOperations as x, IdpDefinitionBrand as y, AllowedValuesOutput as z };
1347
- //# sourceMappingURL=workflow.generated-DJULCuRr.d.mts.map
1348
+ //# sourceMappingURL=workflow.generated-Da1zECDw.d.mts.map
@@ -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 `apply`) after defining new machine users to refresh it.
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 `tailor.authconnection.getConnectionToken()`.
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
- ### `auth.getConnectionToken()`
432
+ ### Retrieving Connection Tokens
433
433
 
434
- `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:
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 { auth } from "../tailor.config";
437
+ import { authconnection } from "@tailor-platform/sdk/runtime";
438
438
 
439
439
  // In a resolver, executor, or workflow:
440
- const tokens = await auth.getConnectionToken("google-connection");
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
- // auth.getConnectionToken("unknown"); // Type error — only "google-connection" is allowed
445
+ // authconnection.getConnectionToken("unknown"); // Type error — only "google-connection" is allowed
446
446
  ```
447
447
 
448
- When `connections` is not defined, `getConnectionToken()` accepts any string. This supports connections managed entirely via the CLI.
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", expires_in: 3600 },
188
+ google: { access_token: "ya29.xxx" },
189
189
  });
190
190
 
191
191
  const token = await tailor.authconnection.getConnectionToken("google");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.70.1",
3
+ "version": "1.71.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -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"}