@tailor-platform/sdk 0.17.0 → 0.18.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.
@@ -1,11 +1,11 @@
1
1
  /// <reference path="./user-defined.d.ts" />
2
2
 
3
- import * as zod34 from "zod";
3
+ import * as zod0 from "zod";
4
4
  import { z } from "zod";
5
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
6
  import * as type_fest0 from "type-fest";
7
7
  import { IsAny, NonEmptyObject } from "type-fest";
8
- import * as zod_v4_core50 from "zod/v4/core";
8
+ import * as zod_v4_core0 from "zod/v4/core";
9
9
 
10
10
  //#region src/configure/types/helpers.d.ts
11
11
  type Prettify<T> = { [K in keyof T as string extends K ? never : K]: T[K] } & {};
@@ -439,6 +439,14 @@ declare const OAuth2ClientSchema: z.ZodObject<{
439
439
  grantTypes: z.ZodDefault<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"authorization_code">, z.ZodLiteral<"refresh_token">]>>>;
440
440
  redirectURIs: z.ZodArray<z.ZodUnion<readonly [z.ZodTemplateLiteral<`https://${string}`>, z.ZodTemplateLiteral<`http://${string}`>, z.ZodTemplateLiteral<`${string}:url`>, z.ZodTemplateLiteral<`${string}:url/${string}`>]>>;
441
441
  clientType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"confidential">, z.ZodLiteral<"public">, z.ZodLiteral<"browser">]>>;
442
+ accessTokenLifetimeSeconds: z.ZodPipe<z.ZodOptional<z.ZodNumber>, z.ZodTransform<{
443
+ seconds: bigint;
444
+ nanos: number;
445
+ } | undefined, number | undefined>>;
446
+ refreshTokenLifetimeSeconds: z.ZodPipe<z.ZodOptional<z.ZodNumber>, z.ZodTransform<{
447
+ seconds: bigint;
448
+ nanos: number;
449
+ } | undefined, number | undefined>>;
442
450
  }, z.core.$strip>;
443
451
  declare const SCIMAuthorizationSchema: z.ZodObject<{
444
452
  type: z.ZodUnion<readonly [z.ZodLiteral<"oauth2">, z.ZodLiteral<"bearer">]>;
@@ -533,7 +541,7 @@ type IDToken = z.output<typeof IDTokenSchema>;
533
541
  type BuiltinIdP = z.output<typeof BuiltinIdPSchema>;
534
542
  type IdProviderConfig = z.output<typeof IdProviderSchema>;
535
543
  type OAuth2ClientGrantType = z.output<typeof OAuth2ClientGrantTypeSchema>;
536
- type OAuth2Client = z.output<typeof OAuth2ClientSchema>;
544
+ type OAuth2ClientInput = z.input<typeof OAuth2ClientSchema>;
537
545
  type SCIMAuthorization = z.output<typeof SCIMAuthorizationSchema>;
538
546
  type SCIMAttributeType = z.output<typeof SCIMAttributeTypeSchema>;
539
547
  type SCIMAttribute = z.output<typeof SCIMAttributeSchema>;
@@ -588,7 +596,7 @@ type MachineUser<User extends TailorDBInstance, AttributeMap extends UserAttribu
588
596
  type AuthServiceInput<User extends TailorDBInstance, AttributeMap extends UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[], MachineUserNames extends string> = {
589
597
  userProfile?: UserProfile<User, AttributeMap, AttributeList>;
590
598
  machineUsers?: Record<MachineUserNames, MachineUser<User, AttributeMap, AttributeList>>;
591
- oauth2Clients?: Record<string, OAuth2Client>;
599
+ oauth2Clients?: Record<string, OAuth2ClientInput>;
592
600
  idProvider?: IdProviderConfig;
593
601
  scim?: SCIMConfig;
594
602
  tenantProvider?: TenantProviderConfig;
@@ -631,7 +639,7 @@ declare function defineAuth<const Name extends string, const User extends Tailor
631
639
  } : {
632
640
  attributeList: { [Index in keyof AttributeList]: AttributeList[Index] extends UserAttributeListKey<User> ? AttributeList[Index] extends infer T ? T extends AttributeList[Index] ? T extends keyof output<User> ? output<User>[T] : never : never : never : never };
633
641
  })> | undefined;
634
- readonly oauth2Clients?: Record<string, OAuth2Client>;
642
+ readonly oauth2Clients?: Record<string, OAuth2ClientInput>;
635
643
  readonly idProvider?: IdProviderConfig;
636
644
  readonly scim?: SCIMConfig;
637
645
  readonly tenantProvider?: TenantProviderConfig;
@@ -1349,12 +1357,12 @@ declare function defineGenerators(...configs: GeneratorConfig[]): (["@tailor-pla
1349
1357
  }] | {
1350
1358
  id: string;
1351
1359
  description: string;
1352
- processType: zod_v4_core50.$InferInnerFunctionType<zod_v4_core50.$ZodFunctionArgs, zod_v4_core50.$ZodFunctionOut>;
1353
- processResolver: zod_v4_core50.$InferInnerFunctionType<zod_v4_core50.$ZodFunctionArgs, zod_v4_core50.$ZodFunctionOut>;
1354
- processExecutor: zod_v4_core50.$InferInnerFunctionType<zod_v4_core50.$ZodFunctionArgs, zod_v4_core50.$ZodFunctionOut>;
1355
- aggregate: zod_v4_core50.$InferInnerFunctionType<zod_v4_core50.$ZodFunctionArgs, zod34.ZodAny>;
1356
- processTailorDBNamespace?: zod_v4_core50.$InferInnerFunctionType<zod_v4_core50.$ZodFunctionArgs, zod_v4_core50.$ZodFunctionOut> | undefined;
1357
- processResolverNamespace?: zod_v4_core50.$InferInnerFunctionType<zod_v4_core50.$ZodFunctionArgs, zod_v4_core50.$ZodFunctionOut> | undefined;
1360
+ processType: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut>;
1361
+ processResolver: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut>;
1362
+ processExecutor: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut>;
1363
+ aggregate: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod0.ZodAny>;
1364
+ processTailorDBNamespace?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1365
+ processResolverNamespace?: zod_v4_core0.$InferInnerFunctionType<zod_v4_core0.$ZodFunctionArgs, zod_v4_core0.$ZodFunctionOut> | undefined;
1358
1366
  })[];
1359
1367
  //#endregion
1360
1368
  //#region src/parser/service/executor/schema.d.ts
@@ -1492,5 +1500,5 @@ type WorkflowOperation = z.infer<typeof WorkflowOperationSchema>;
1492
1500
  type Executor = z.infer<typeof ExecutorSchema>;
1493
1501
  type ExecutorInput = z.input<typeof ExecutorSchema>;
1494
1502
  //#endregion
1495
- export { AllowedValues, AllowedValuesOutput, AppConfig, ArrayFieldOutput, AttributeList$1 as AttributeList, AttributeMap$1 as AttributeMap, AuthConfig, AuthExternalConfig, AuthInvoker$1 as AuthInvoker, AuthOwnConfig, type AuthServiceInput, type BuiltinIdP, CodeGeneratorBase, Executor, ExecutorInput, ExecutorServiceConfig, ExecutorServiceInput, FieldMetadata, FieldOptions, FieldOutput, FunctionOperation, Generator, GqlOperation, type IDToken, IdPConfig, IdPExternalConfig, type IdProviderConfig, IncomingWebhookTrigger, InferFieldsOutput, JsonCompatible, type OAuth2Client, type OAuth2ClientGrantType, type OIDC, PermissionCondition, QueryType, RecordTrigger, Resolver, ResolverExecutedTrigger, ResolverExternalConfig, ResolverInput, ResolverServiceConfig, ResolverServiceInput, type SAML, type SCIMAttribute, type SCIMAttributeMapping, type SCIMAttributeType, type SCIMAuthorization, type SCIMConfig, type SCIMResource, ScheduleTriggerInput, StaticWebsiteConfig, TailorDBField, TailorDBInstance, TailorDBType, TailorDBTypeConfig, TailorField, TailorTypeGqlPermission, TailorTypePermission, TailorUser, type TenantProviderConfig, type UserAttributeKey, type UserAttributeListKey, type UserAttributeMap, type UsernameFieldKey, type ValueOperand, WebhookOperation, WorkflowOperation, WorkflowServiceConfig, WorkflowServiceInput, db, defineAuth, defineConfig, defineGenerators, defineIdp, defineStaticWebSite, output, unauthenticatedTailorUser, unsafeAllowAllGqlPermission, unsafeAllowAllTypePermission };
1496
- //# sourceMappingURL=types-Da_WnvA0.d.mts.map
1503
+ export { AllowedValues, AllowedValuesOutput, AppConfig, ArrayFieldOutput, AttributeList$1 as AttributeList, AttributeMap$1 as AttributeMap, AuthConfig, AuthExternalConfig, AuthInvoker$1 as AuthInvoker, AuthOwnConfig, type AuthServiceInput, type BuiltinIdP, CodeGeneratorBase, Executor, ExecutorInput, ExecutorServiceConfig, ExecutorServiceInput, FieldMetadata, FieldOptions, FieldOutput, FunctionOperation, Generator, GqlOperation, type IDToken, IdPConfig, IdPExternalConfig, type IdProviderConfig, IncomingWebhookTrigger, InferFieldsOutput, JsonCompatible, type OAuth2ClientGrantType, OAuth2ClientInput, type OIDC, PermissionCondition, QueryType, RecordTrigger, Resolver, ResolverExecutedTrigger, ResolverExternalConfig, ResolverInput, ResolverServiceConfig, ResolverServiceInput, type SAML, type SCIMAttribute, type SCIMAttributeMapping, type SCIMAttributeType, type SCIMAuthorization, type SCIMConfig, type SCIMResource, ScheduleTriggerInput, StaticWebsiteConfig, TailorDBField, TailorDBInstance, TailorDBType, TailorDBTypeConfig, TailorField, TailorTypeGqlPermission, TailorTypePermission, TailorUser, type TenantProviderConfig, type UserAttributeKey, type UserAttributeListKey, type UserAttributeMap, type UsernameFieldKey, type ValueOperand, WebhookOperation, WorkflowOperation, WorkflowServiceConfig, WorkflowServiceInput, db, defineAuth, defineConfig, defineGenerators, defineIdp, defineStaticWebSite, output, unauthenticatedTailorUser, unsafeAllowAllGqlPermission, unsafeAllowAllTypePermission };
1504
+ //# sourceMappingURL=types-DgaCdTug.d.mts.map
@@ -1,7 +1,7 @@
1
1
  /// <reference path="./../../user-defined.d.ts" />
2
2
 
3
- import { TailorDBType, TailorField } from "../../types-Da_WnvA0.mjs";
4
- import { output } from "../../index-Bin7-j3v.mjs";
3
+ import { TailorDBType, TailorField } from "../../types-DgaCdTug.mjs";
4
+ import { output } from "../../index-BWqIQ4iC.mjs";
5
5
  import { StandardSchemaV1 } from "@standard-schema/spec";
6
6
 
7
7
  //#region src/utils/test/index.d.ts
@@ -62,6 +62,32 @@ export default defineConfig({
62
62
 
63
63
  **ignores**: Glob patterns to exclude files. Optional. By default, `**/*.test.ts` and `**/*.spec.ts` are automatically ignored. If you explicitly specify `ignores`, the default patterns will not be applied. Use `ignores: []` to include all files including test files.
64
64
 
65
+ ### External Resources
66
+
67
+ You can reference resources managed by Terraform or other SDK projects to include them in your application's subgraph. External resources are not deployed by this project but can be used for shared access across multiple applications.
68
+
69
+ ```typescript
70
+ export default defineConfig({
71
+ name: "my-app",
72
+ db: {
73
+ "shared-db": { external: true },
74
+ },
75
+ resolver: {
76
+ "my-resolver": { external: true },
77
+ },
78
+ auth: { name: "shared-auth", external: true },
79
+ idp: [{ name: "shared-idp", external: true }],
80
+ });
81
+ ```
82
+
83
+ **external**: Set to `true` to reference an external resource. The resource must already exist and be managed by another project (e.g., Terraform or another SDK application).
84
+
85
+ When using external resources:
86
+
87
+ - The resource itself is not deployed by this project
88
+ - The resource must be deployed and available before referencing it
89
+ - You can combine external resources with locally-defined resources
90
+
65
91
  ### Built-in IdP
66
92
 
67
93
  Configure the Built-in IdP service using `defineIdp()`. See [IdP](./services/idp.md) for full documentation.
@@ -53,16 +53,29 @@ Maps authenticated identities to a TailorDB type:
53
53
  ```typescript
54
54
  userProfile: {
55
55
  type: user, // TailorDB type for user records
56
- usernameField: "email", // Field used as username
56
+ usernameField: "email", // Field used as username (must be unique)
57
57
  attributes: {
58
58
  role: true, // Enable 'role' as a user attribute
59
59
  },
60
60
  },
61
61
  ```
62
62
 
63
+ Example TailorDB type for user profile:
64
+
65
+ ```typescript
66
+ // tailordb/user.ts
67
+ import { db } from "@tailor-platform/sdk";
68
+
69
+ export const user = db.type("User", {
70
+ email: db.string().unique(), // usernameField must have unique constraint
71
+ role: db.enum(["admin", "user"]),
72
+ ...db.fields.timestamps(),
73
+ });
74
+ ```
75
+
63
76
  **type**: The TailorDB type that stores user records.
64
77
 
65
- **usernameField**: The field in the TailorDB type used as the username.
78
+ **usernameField**: The field in the TailorDB type used as the username. This field must have a unique constraint (`.unique()`) since it is used to uniquely identify users.
66
79
 
67
80
  **attributes**: Specifies which fields from the TailorDB type are used as user attributes. Set to `true` to enable a field. Enabled attributes must be assigned values in all machine user definitions.
68
81
 
@@ -175,6 +188,8 @@ oauth2Clients: {
175
188
  ],
176
189
  description: "My OAuth2 client",
177
190
  grantTypes: ["authorization_code", "refresh_token"],
191
+ accessTokenLifetimeSeconds: 3600, // 1 hour
192
+ refreshTokenLifetimeSeconds: 604800, // 7 days
178
193
  },
179
194
  },
180
195
  ```
@@ -188,6 +203,10 @@ oauth2Clients: {
188
203
  - `authorization_code` - Standard OAuth 2.0 authorization code flow
189
204
  - `refresh_token` - Allow refreshing access tokens
190
205
 
206
+ **accessTokenLifetimeSeconds**: Optional access token lifetime in seconds. Minimum: 60 seconds, Maximum: 86400 seconds (1 day). If not specified, uses platform default.
207
+
208
+ **refreshTokenLifetimeSeconds**: Optional refresh token lifetime in seconds. Minimum: 60 seconds, Maximum: 604800 seconds (7 days). If not specified, uses platform default.
209
+
191
210
  Get OAuth2 client credentials using the CLI:
192
211
 
193
212
  ```bash
@@ -282,6 +282,8 @@ db.type("User", {
282
282
 
283
283
  Configure Permission and GQLPermission. For details, see the [TailorDB Permission documentation](https://docs.tailor.tech/guides/tailordb/permission).
284
284
 
285
+ **Important**: Following the secure-by-default principle, all operations are denied if permissions are not configured. You must explicitly grant permissions for each operation (create, read, update, delete).
286
+
285
287
  ```typescript
286
288
  db.type("User", {
287
289
  name: db.string(),
@@ -302,4 +304,22 @@ db.type("User", {
302
304
  ]);
303
305
  ```
304
306
 
305
- Following the secure-by-default principle, all operations are denied if permissions are not configured.
307
+ #### Development/Test Helpers
308
+
309
+ For local development, prototyping, or testing, the SDK provides helper constants that grant full access without conditions:
310
+
311
+ ```typescript
312
+ import {
313
+ db,
314
+ unsafeAllowAllTypePermission,
315
+ unsafeAllowAllGqlPermission,
316
+ } from "@tailor-platform/sdk";
317
+
318
+ db.type("User", {
319
+ name: db.string(),
320
+ })
321
+ .permission(unsafeAllowAllTypePermission)
322
+ .gqlPermission(unsafeAllowAllGqlPermission);
323
+ ```
324
+
325
+ **Warning**: Do not use `unsafeAllowAllTypePermission` or `unsafeAllowAllGqlPermission` in production environments as they effectively disable authorization checks.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/configure/index.mjs",
@@ -40,7 +40,7 @@
40
40
  "types": "./dist/configure/index.d.mts",
41
41
  "dependencies": {
42
42
  "@badgateway/oauth2-client": "3.3.1",
43
- "@bufbuild/protobuf": "2.10.1",
43
+ "@bufbuild/protobuf": "2.10.2",
44
44
  "@connectrpc/connect": "2.1.1",
45
45
  "@connectrpc/connect-node": "2.1.1",
46
46
  "@standard-schema/spec": "1.0.0",
@@ -51,7 +51,7 @@
51
51
  "confbox": "0.2.2",
52
52
  "consola": "3.4.2",
53
53
  "date-fns": "4.1.0",
54
- "es-toolkit": "1.42.0",
54
+ "es-toolkit": "1.43.0",
55
55
  "inflection": "3.0.2",
56
56
  "madge": "8.0.0",
57
57
  "multiline-ts": "4.0.1",
@@ -69,12 +69,12 @@
69
69
  "zod": "4.1.13"
70
70
  },
71
71
  "devDependencies": {
72
- "@eslint/js": "9.39.1",
72
+ "@eslint/js": "9.39.2",
73
73
  "@tailor-platform/function-types": "0.8.0",
74
74
  "@types/madge": "5.0.3",
75
- "@types/node": "22.19.2",
75
+ "@types/node": "22.19.3",
76
76
  "cross-env": "10.1.0",
77
- "eslint": "9.39.1",
77
+ "eslint": "9.39.2",
78
78
  "eslint-plugin-jsdoc": "61.5.0",
79
79
  "globals": "16.5.0",
80
80
  "sonda": "0.10.1",