@tailor-platform/sdk 0.17.0 → 0.18.1
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 +22 -0
- package/dist/cli/api.d.mts +32 -32
- package/dist/cli/api.mjs +2 -2
- package/dist/cli/api.mjs.map +1 -1
- package/dist/cli/index.mjs +343 -14
- package/dist/cli/index.mjs.map +1 -1
- package/dist/configure/index.d.mts +3 -3
- package/dist/{index-Bin7-j3v.d.mts → index-Ba6ekRxa.d.mts} +2 -2
- package/dist/job-CL8myeqs.mjs.map +1 -1
- package/dist/{resume-B2ba5opn.mjs → resume-8Y9mmXHa.mjs} +87 -157
- package/dist/{resume-B2ba5opn.mjs.map → resume-8Y9mmXHa.mjs.map} +1 -1
- package/dist/{types-Da_WnvA0.d.mts → types-Dz5wcR2h.d.mts} +13 -5
- package/dist/utils/test/index.d.mts +2 -2
- package/docs/cli-reference.md +10 -0
- package/docs/configuration.md +26 -0
- package/docs/services/auth.md +21 -2
- package/docs/services/tailordb.md +21 -1
- package/package.json +9 -6
|
@@ -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
|
|
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,
|
|
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,
|
|
642
|
+
readonly oauth2Clients?: Record<string, OAuth2ClientInput>;
|
|
635
643
|
readonly idProvider?: IdProviderConfig;
|
|
636
644
|
readonly scim?: SCIMConfig;
|
|
637
645
|
readonly tenantProvider?: TenantProviderConfig;
|
|
@@ -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
|
|
1496
|
-
//# sourceMappingURL=types-
|
|
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-Dz5wcR2h.d.mts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference path="./../../user-defined.d.ts" />
|
|
2
2
|
|
|
3
|
-
import { TailorDBType, TailorField } from "../../types-
|
|
4
|
-
import { output } from "../../index-
|
|
3
|
+
import { TailorDBType, TailorField } from "../../types-Dz5wcR2h.mjs";
|
|
4
|
+
import { output } from "../../index-Ba6ekRxa.mjs";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
6
|
|
|
7
7
|
//#region src/utils/test/index.d.ts
|
package/docs/cli-reference.md
CHANGED
|
@@ -105,3 +105,13 @@ Commands for managing secrets and vaults.
|
|
|
105
105
|
| [secret update](./cli/secret.md#secret-update) | Update a secret |
|
|
106
106
|
| [secret list](./cli/secret.md#secret-list) | List secrets in a vault |
|
|
107
107
|
| [secret delete](./cli/secret.md#secret-delete) | Delete a secret |
|
|
108
|
+
|
|
109
|
+
### [Static Website Commands](./cli/staticwebsite.md)
|
|
110
|
+
|
|
111
|
+
Commands for managing and deploying static websites.
|
|
112
|
+
|
|
113
|
+
| Command | Description |
|
|
114
|
+
| ------------------------------------------------------------------- | ---------------------------------------------------- |
|
|
115
|
+
| [staticwebsite deploy](./cli/staticwebsite.md#staticwebsite-deploy) | Deploy a static website from a local build directory |
|
|
116
|
+
| [staticwebsite list](./cli/staticwebsite.md#staticwebsite-list) | List static websites in a workspace |
|
|
117
|
+
| [staticwebsite get](./cli/staticwebsite.md#staticwebsite-get) | Get details of a static website |
|
package/docs/configuration.md
CHANGED
|
@@ -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.
|
package/docs/services/auth.md
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
3
|
+
"version": "0.18.1",
|
|
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.
|
|
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,14 +51,16 @@
|
|
|
51
51
|
"confbox": "0.2.2",
|
|
52
52
|
"consola": "3.4.2",
|
|
53
53
|
"date-fns": "4.1.0",
|
|
54
|
-
"es-toolkit": "1.
|
|
54
|
+
"es-toolkit": "1.43.0",
|
|
55
55
|
"inflection": "3.0.2",
|
|
56
56
|
"madge": "8.0.0",
|
|
57
|
+
"mime-types": "^3.0.2",
|
|
57
58
|
"multiline-ts": "4.0.1",
|
|
58
59
|
"open": "10.2.0",
|
|
59
60
|
"ora": "9.0.0",
|
|
60
61
|
"oxc-parser": "0.98.0",
|
|
61
62
|
"pkg-types": "2.3.0",
|
|
63
|
+
"p-limit": "4.0.0",
|
|
62
64
|
"rolldown": "1.0.0-beta.41",
|
|
63
65
|
"table": "6.9.0",
|
|
64
66
|
"ts-cron-validator": "1.1.5",
|
|
@@ -69,12 +71,13 @@
|
|
|
69
71
|
"zod": "4.1.13"
|
|
70
72
|
},
|
|
71
73
|
"devDependencies": {
|
|
72
|
-
"@eslint/js": "9.39.
|
|
74
|
+
"@eslint/js": "9.39.2",
|
|
73
75
|
"@tailor-platform/function-types": "0.8.0",
|
|
74
76
|
"@types/madge": "5.0.3",
|
|
75
|
-
"@types/
|
|
77
|
+
"@types/mime-types": "^3.0.1",
|
|
78
|
+
"@types/node": "22.19.3",
|
|
76
79
|
"cross-env": "10.1.0",
|
|
77
|
-
"eslint": "9.39.
|
|
80
|
+
"eslint": "9.39.2",
|
|
78
81
|
"eslint-plugin-jsdoc": "61.5.0",
|
|
79
82
|
"globals": "16.5.0",
|
|
80
83
|
"sonda": "0.10.1",
|