@tailor-platform/sdk 1.7.0 → 1.8.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 (41) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{application-Ba2B5A-w.mjs → application-HIu5peO4.mjs} +44 -14
  3. package/dist/application-HIu5peO4.mjs.map +1 -0
  4. package/dist/application-ViV4dYwI.mjs +4 -0
  5. package/dist/cli/index.mjs +46 -47
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.d.mts +8 -7
  8. package/dist/cli/lib.mjs +2 -3
  9. package/dist/cli/lib.mjs.map +1 -1
  10. package/dist/configure/index.d.mts +3 -3
  11. package/dist/configure/index.mjs +778 -2
  12. package/dist/configure/index.mjs.map +1 -1
  13. package/dist/{index-BSrVjiPg.d.mts → index-BwJ7-efr.d.mts} +73 -29
  14. package/dist/{index-DraFftyF.d.mts → index-Dkm2qwmF.d.mts} +142 -180
  15. package/dist/{jiti-SMSW3TA0.mjs → jiti-ygK9KoRA.mjs} +1 -1
  16. package/dist/{jiti-SMSW3TA0.mjs.map → jiti-ygK9KoRA.mjs.map} +1 -1
  17. package/dist/{job-8XfvLyxH.mjs → job-l-pIR9IY.mjs} +1 -1
  18. package/dist/{job-8XfvLyxH.mjs.map → job-l-pIR9IY.mjs.map} +1 -1
  19. package/dist/{list-DArHhlnw.mjs → list-D1K7WwpV.mjs} +96 -48
  20. package/dist/list-D1K7WwpV.mjs.map +1 -0
  21. package/dist/{src-qLXX6nub.mjs → src-CG8kJBI9.mjs} +1 -1
  22. package/dist/{src-qLXX6nub.mjs.map → src-CG8kJBI9.mjs.map} +1 -1
  23. package/dist/utils/test/index.d.mts +2 -2
  24. package/dist/utils/test/index.mjs +1 -1
  25. package/docs/cli/application.md +114 -35
  26. package/docs/cli/auth.md +101 -44
  27. package/docs/cli/executor.md +65 -33
  28. package/docs/cli/secret.md +133 -51
  29. package/docs/cli/staticwebsite.md +78 -41
  30. package/docs/cli/tailordb.md +227 -155
  31. package/docs/cli/user.md +164 -66
  32. package/docs/cli/workflow.md +132 -73
  33. package/docs/cli/workspace.md +126 -45
  34. package/docs/generator/custom.md +2 -2
  35. package/docs/services/auth.md +88 -1
  36. package/package.json +3 -1
  37. package/dist/application-Ba2B5A-w.mjs.map +0 -1
  38. package/dist/application-C_MQabII.mjs +0 -5
  39. package/dist/auth-Co6vu1MY.mjs +0 -779
  40. package/dist/auth-Co6vu1MY.mjs.map +0 -1
  41. package/dist/list-DArHhlnw.mjs.map +0 -1
@@ -2,123 +2,204 @@
2
2
 
3
3
  Commands for managing workspaces and profiles.
4
4
 
5
+ <!-- politty:command:workspace:start -->
6
+
5
7
  ## workspace
6
8
 
7
9
  Manage Tailor Platform workspaces.
8
10
 
9
- ```bash
10
- tailor-sdk workspace <subcommand> [options]
11
+ **Usage**
12
+
11
13
  ```
14
+ tailor-sdk workspace [command]
15
+ ```
16
+
17
+ **Commands**
18
+
19
+ | Command | Description |
20
+ | --------------------------------------- | --------------------------------------- |
21
+ | [`workspace create`](#workspace-create) | Create a new Tailor Platform workspace. |
22
+ | [`workspace delete`](#workspace-delete) | Delete a Tailor Platform workspace. |
23
+ | [`workspace list`](#workspace-list) | List all Tailor Platform workspaces. |
24
+
25
+ <!-- politty:command:workspace:end -->
26
+ <!-- politty:command:workspace create:start -->
12
27
 
13
28
  ### workspace create
14
29
 
15
30
  Create a new Tailor Platform workspace.
16
31
 
17
- ```bash
32
+ **Usage**
33
+
34
+ ```
18
35
  tailor-sdk workspace create [options]
19
36
  ```
20
37
 
21
- **Options:**
38
+ **Options**
22
39
 
23
- - `-n, --name` - Name of the workspace (required)
24
- - `-r, --region` - Region of the workspace: `us-west` or `asia-northeast` (required)
25
- - `-d, --delete-protection` - Enable delete protection for the workspace
26
- - `-o, --organization-id` - Organization ID to associate the workspace with
27
- - `-f, --folder-id` - Folder ID to associate the workspace with
28
- - `-p, --profile-name` - Profile name to create (optional)
29
- - `--profile-user` - User email for the profile (defaults to current user)
30
- - `-j, --json` - Output as JSON
40
+ | Option | Alias | Description | Default |
41
+ | ------------------------------------- | ----- | ----------------------------------------------------- | ------- |
42
+ | `--json` | `-j` | Output as JSON | `false` |
43
+ | `--name <NAME>` | `-n` | Workspace name | - |
44
+ | `--region <REGION>` | `-r` | Workspace region (us-west, asia-northeast) | - |
45
+ | `--delete-protection` | `-d` | Enable delete protection | `false` |
46
+ | `--organization-id <ORGANIZATION_ID>` | `-o` | Organization ID to workspace associate with | - |
47
+ | `--folder-id <FOLDER_ID>` | `-f` | Folder ID to workspace associate with | - |
48
+ | `--profile-name <PROFILE_NAME>` | `-p` | Profile name to create | - |
49
+ | `--profile-user <PROFILE_USER>` | - | User email for the profile (defaults to current user) | - |
50
+
51
+ <!-- politty:command:workspace create:end -->
52
+ <!-- politty:command:workspace list:start -->
31
53
 
32
54
  ### workspace list
33
55
 
34
56
  List all Tailor Platform workspaces.
35
57
 
36
- ```bash
58
+ **Usage**
59
+
60
+ ```
37
61
  tailor-sdk workspace list [options]
38
62
  ```
39
63
 
40
- **Options:**
64
+ **Options**
65
+
66
+ | Option | Alias | Description | Default |
67
+ | ----------------- | ----- | ------------------------------------ | ------- |
68
+ | `--json` | `-j` | Output as JSON | `false` |
69
+ | `--limit <LIMIT>` | `-l` | Maximum number of workspaces to list | - |
41
70
 
42
- - `-j, --json` - Output as JSON
43
- - `-l, --limit <number>` - Maximum number of workspaces to list (positive integer)
71
+ <!-- politty:command:workspace list:end -->
72
+ <!-- politty:command:workspace delete:start -->
44
73
 
45
74
  ### workspace delete
46
75
 
47
76
  Delete a Tailor Platform workspace.
48
77
 
49
- ```bash
78
+ **Usage**
79
+
80
+ ```
50
81
  tailor-sdk workspace delete [options]
51
82
  ```
52
83
 
53
- **Options:**
84
+ **Options**
54
85
 
55
- - `-w, --workspace-id` - ID of the workspace to delete (required)
56
- - `-y, --yes` - Skip confirmation prompt
86
+ | Option | Alias | Description | Default |
87
+ | ------------------------------- | ----- | ------------------------- | ------- |
88
+ | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | - |
89
+ | `--yes` | `-y` | Skip confirmation prompts | `false` |
90
+
91
+ <!-- politty:command:workspace delete:end -->
92
+ <!-- politty:command:profile:start -->
57
93
 
58
94
  ## profile
59
95
 
60
96
  Manage workspace profiles (user + workspace combinations).
61
97
 
62
- ```bash
63
- tailor-sdk profile <subcommand> [options]
98
+ **Usage**
99
+
64
100
  ```
101
+ tailor-sdk profile [command]
102
+ ```
103
+
104
+ **Commands**
105
+
106
+ | Command | Description |
107
+ | ----------------------------------- | -------------------------- |
108
+ | [`profile create`](#profile-create) | Create a new profile. |
109
+ | [`profile delete`](#profile-delete) | Delete a profile. |
110
+ | [`profile list`](#profile-list) | List all profiles. |
111
+ | [`profile update`](#profile-update) | Update profile properties. |
112
+
113
+ <!-- politty:command:profile:end -->
114
+ <!-- politty:command:profile create:start -->
65
115
 
66
116
  ### profile create
67
117
 
68
118
  Create a new profile.
69
119
 
70
- ```bash
71
- tailor-sdk profile create <name> [options]
120
+ **Usage**
121
+
122
+ ```
123
+ tailor-sdk profile create [options] <name>
72
124
  ```
73
125
 
74
- **Arguments:**
126
+ **Arguments**
75
127
 
76
- - `name` - Profile name (required)
128
+ | Argument | Description | Required |
129
+ | -------- | ------------ | -------- |
130
+ | `name` | Profile name | Yes |
77
131
 
78
- **Options:**
132
+ **Options**
79
133
 
80
- - `-u, --user` - User email (required)
81
- - `-w, --workspace-id` - Workspace ID (required)
82
- - `-j, --json` - Output as JSON
134
+ | Option | Alias | Description | Default |
135
+ | ------------------------------- | ----- | -------------- | ------- |
136
+ | `--json` | `-j` | Output as JSON | `false` |
137
+ | `--user <USER>` | `-u` | User email | - |
138
+ | `--workspace-id <WORKSPACE_ID>` | `-w` | Workspace ID | - |
139
+
140
+ <!-- politty:command:profile create:end -->
141
+ <!-- politty:command:profile list:start -->
83
142
 
84
143
  ### profile list
85
144
 
86
145
  List all profiles.
87
146
 
88
- ```bash
147
+ **Usage**
148
+
149
+ ```
89
150
  tailor-sdk profile list [options]
90
151
  ```
91
152
 
92
- **Options:**
153
+ **Options**
154
+
155
+ | Option | Alias | Description | Default |
156
+ | -------- | ----- | -------------- | ------- |
157
+ | `--json` | `-j` | Output as JSON | `false` |
93
158
 
94
- - `-j, --json` - Output as JSON
159
+ <!-- politty:command:profile list:end -->
160
+ <!-- politty:command:profile update:start -->
95
161
 
96
162
  ### profile update
97
163
 
98
164
  Update profile properties.
99
165
 
100
- ```bash
101
- tailor-sdk profile update <name> [options]
166
+ **Usage**
167
+
168
+ ```
169
+ tailor-sdk profile update [options] <name>
102
170
  ```
103
171
 
104
- **Arguments:**
172
+ **Arguments**
105
173
 
106
- - `name` - Profile name (required)
174
+ | Argument | Description | Required |
175
+ | -------- | ------------ | -------- |
176
+ | `name` | Profile name | Yes |
107
177
 
108
- **Options:**
178
+ **Options**
109
179
 
110
- - `-u, --user` - New user email
111
- - `-w, --workspace-id` - New workspace ID
112
- - `-j, --json` - Output as JSON
180
+ | Option | Alias | Description | Default |
181
+ | ------------------------------- | ----- | ---------------- | ------- |
182
+ | `--json` | `-j` | Output as JSON | `false` |
183
+ | `--user <USER>` | `-u` | New user email | - |
184
+ | `--workspace-id <WORKSPACE_ID>` | `-w` | New workspace ID | - |
185
+
186
+ <!-- politty:command:profile update:end -->
187
+ <!-- politty:command:profile delete:start -->
113
188
 
114
189
  ### profile delete
115
190
 
116
191
  Delete a profile.
117
192
 
118
- ```bash
119
- tailor-sdk profile delete <name>
193
+ **Usage**
194
+
120
195
  ```
196
+ tailor-sdk profile delete [options] <name>
197
+ ```
198
+
199
+ **Arguments**
121
200
 
122
- **Arguments:**
201
+ | Argument | Description | Required |
202
+ | -------- | ------------ | -------- |
203
+ | `name` | Profile name | Yes |
123
204
 
124
- - `name` - Profile name (required)
205
+ <!-- politty:command:profile delete:end -->
@@ -13,7 +13,7 @@ interface CodeGenerator<T, R, E, Ts, Rs> {
13
13
 
14
14
  // Process individual items
15
15
  processType(args: {
16
- type: ParsedTailorDBType;
16
+ type: TailorDBType;
17
17
  namespace: string;
18
18
  source: { filePath: string; exportName: string };
19
19
  }): T | Promise<T>;
@@ -110,7 +110,7 @@ export const generators = defineGenerators(
110
110
 
111
111
  ## Available Input Data
112
112
 
113
- ### ParsedTailorDBType
113
+ ### TailorDBType
114
114
 
115
115
  Contains full type information including:
116
116
 
@@ -86,7 +86,53 @@ export const user = db.type("User", {
86
86
 
87
87
  **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.
88
88
 
89
- **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.
89
+ **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. Only fields with ValueOperand types (string, boolean, string[], boolean[]) can be used as attributes. The `id` field and datetime/date/time types are excluded.
90
+
91
+ ## Attribute List
92
+
93
+ In addition to `attributes` (key-value map), you can configure `attributeList` to expose UUID-type fields as an ordered list. This is useful for referencing related records by their IDs.
94
+
95
+ ```typescript
96
+ userProfile: {
97
+ type: user,
98
+ usernameField: "email",
99
+ attributes: { role: true },
100
+ attributeList: ["organizationId", "teamId"],
101
+ },
102
+ ```
103
+
104
+ **attributeList**: An array of field names from the TailorDB type. These fields will be exposed as an ordered list of UUIDs. Only UUID-type fields (non-array) can be included in the attribute list.
105
+
106
+ Example TailorDB type with UUID fields for attribute list:
107
+
108
+ ```typescript
109
+ // tailordb/user.ts
110
+ import { db } from "@tailor-platform/sdk";
111
+
112
+ export const user = db.type("User", {
113
+ email: db.string().unique(),
114
+ role: db.enum(["admin", "user"]),
115
+ organizationId: db.uuid(), // Can be used in attributeList
116
+ teamId: db.uuid(), // Can be used in attributeList
117
+ ...db.fields.timestamps(),
118
+ });
119
+ ```
120
+
121
+ The `attributeList` values are accessible via `user.attributeList` as a tuple:
122
+
123
+ ```typescript
124
+ // In a resolver
125
+ body: (context) => {
126
+ const [organizationId, teamId] = context.user.attributeList;
127
+ },
128
+
129
+ // In TailorDB hooks
130
+ .hooks({
131
+ field: {
132
+ create: ({ user }) => user.attributeList[0], // First UUID from list
133
+ },
134
+ })
135
+ ```
90
136
 
91
137
  ## Machine User Attributes (without userProfile)
92
138
 
@@ -140,6 +186,36 @@ machineUsers: {
140
186
  body: (context) => {
141
187
  const role = context.user.attributes?.role;
142
188
  },
189
+ ```
190
+
191
+ **attributeList**: Values for fields enabled in `userProfile.attributeList`. Must be an array of valid UUIDs in the same order as declared in userProfile:
192
+
193
+ ```typescript
194
+ // userProfile with attributeList
195
+ userProfile: {
196
+ type: user,
197
+ usernameField: "email",
198
+ attributes: { role: true },
199
+ attributeList: ["organizationId", "teamId"],
200
+ },
201
+ machineUsers: {
202
+ "admin-machine-user": {
203
+ attributes: { role: "ADMIN" },
204
+ attributeList: [
205
+ "550e8400-e29b-41d4-a716-446655440000",
206
+ "7c9e6679-7425-40de-944b-e07fc1f90ae7",
207
+ ],
208
+ },
209
+ },
210
+ ```
211
+
212
+ These values are accessible via `user.attributeList`:
213
+
214
+ ```typescript
215
+ // In a resolver
216
+ body: (context) => {
217
+ const [organizationId, teamId] = context.user.attributeList;
218
+ },
143
219
 
144
220
  // In TailorDB hooks
145
221
  .hooks({
@@ -284,3 +360,14 @@ tailor-sdk oauth2client get <name>
284
360
  ```
285
361
 
286
362
  See [Auth Resource Commands](../cli/auth.md) for full documentation.
363
+
364
+ ## SDK vs Platform Naming
365
+
366
+ > **Note for Platform developers**: The SDK uses different names than the underlying Platform API for user attributes:
367
+ >
368
+ > | SDK | Platform API | Description |
369
+ > | --------------- | --------------- | -------------------------------- |
370
+ > | `attributes` | `attribute_map` | Key-value map of user attributes |
371
+ > | `attributeList` | `attributes` | Ordered list of UUID values |
372
+ >
373
+ > This mapping is handled automatically by the SDK. If you're reading Platform documentation or API responses, be aware of this naming difference.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -121,6 +121,8 @@
121
121
  "test:unit": "vitest --project=unit",
122
122
  "test:e2e": "vitest --project=e2e",
123
123
  "test:coverage": "vitest --coverage",
124
+ "docs:check": "vitest run --project=unit src/cli/docs.test.ts",
125
+ "docs:update": "POLITTY_DOCS_UPDATE=true vitest run --project=unit src/cli/docs.test.ts",
124
126
  "build": "tsdown && cross-env FORCE_CREATE=1 node postinstall.mjs",
125
127
  "lint": "oxlint --type-aware . && eslint --cache .",
126
128
  "lint:fix": "oxlint --type-aware . --fix && eslint --cache . --fix",