@tailor-platform/sdk 0.0.1 → 0.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.
- package/CHANGELOG.md +784 -0
- package/LICENSE +21 -0
- package/README.md +8 -41
- package/dist/auth-Di3vQUrT.mjs +743 -0
- package/dist/cli/api.d.mts +213 -0
- package/dist/cli/api.mjs +4 -0
- package/dist/cli/index.d.mts +3 -0
- package/dist/cli/index.mjs +996 -0
- package/dist/configure/index.d.mts +5 -0
- package/dist/configure/index.mjs +108 -0
- package/dist/index-D-0knE68.d.mts +232 -0
- package/dist/plugin-generated.d.ts +14 -0
- package/dist/token-PbgBrNwb.mjs +5498 -0
- package/dist/types-DSAthMLp.d.mts +1389 -0
- package/dist/utils/test/index.d.mts +40 -0
- package/dist/utils/test/index.mjs +63 -0
- package/docs/cli-reference.md +484 -0
- package/docs/configuration.md +132 -0
- package/docs/core-concepts.md +504 -0
- package/docs/quickstart.md +96 -0
- package/docs/testing.md +298 -0
- package/package.json +87 -8
- package/postinstall.mjs +87 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference path="./../../plugin-generated.d.ts" />
|
|
2
|
+
|
|
3
|
+
import { TailorDBType, TailorField, TailorUser } from "../../types-DSAthMLp.mjs";
|
|
4
|
+
import { output } from "../../index-D-0knE68.mjs";
|
|
5
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
|
+
|
|
7
|
+
//#region src/utils/test/index.d.ts
|
|
8
|
+
/** Represents an unauthenticated user in the Tailor platform. */
|
|
9
|
+
declare const unauthenticatedTailorUser: TailorUser;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a hook function that processes TailorDB type fields
|
|
12
|
+
* - Uses existing id from data if provided, otherwise generates UUID for id fields
|
|
13
|
+
* - Recursively processes nested types
|
|
14
|
+
* - Executes hooks.create for fields with create hooks
|
|
15
|
+
*
|
|
16
|
+
* @template T - The output type of the hook function
|
|
17
|
+
* @param type - TailorDB type definition
|
|
18
|
+
* @returns A function that transforms input data according to field hooks
|
|
19
|
+
*/
|
|
20
|
+
declare function createTailorDBHook<T extends TailorDBType<any, any>>(type: T): (data: unknown) => Partial<output<T>>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates the standard schema definition for lines-db
|
|
23
|
+
* This returns the first argument for defineSchema with the ~standard section
|
|
24
|
+
*
|
|
25
|
+
* @template T - The output type after validation
|
|
26
|
+
* @param schemaType - TailorDB field schema for validation
|
|
27
|
+
* @param hook - Hook function to transform data before validation
|
|
28
|
+
* @returns Schema object with ~standard section for defineSchema
|
|
29
|
+
*/
|
|
30
|
+
declare function createStandardSchema<T = Record<string, unknown>>(schemaType: TailorField<any, T>, hook: (data: unknown) => Partial<T>): {
|
|
31
|
+
readonly "~standard": {
|
|
32
|
+
readonly version: 1;
|
|
33
|
+
readonly vendor: "@tailor-platform/sdk";
|
|
34
|
+
readonly validate: (value: unknown) => StandardSchemaV1.FailureResult | {
|
|
35
|
+
value: T;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { createStandardSchema, createTailorDBHook, unauthenticatedTailorUser };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//#region src/utils/test/index.ts
|
|
2
|
+
/** Represents an unauthenticated user in the Tailor platform. */
|
|
3
|
+
const unauthenticatedTailorUser = {
|
|
4
|
+
id: "00000000-0000-0000-0000-000000000000",
|
|
5
|
+
type: "",
|
|
6
|
+
workspaceId: "00000000-0000-0000-0000-000000000000",
|
|
7
|
+
attributes: null,
|
|
8
|
+
attributeList: []
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Creates a hook function that processes TailorDB type fields
|
|
12
|
+
* - Uses existing id from data if provided, otherwise generates UUID for id fields
|
|
13
|
+
* - Recursively processes nested types
|
|
14
|
+
* - Executes hooks.create for fields with create hooks
|
|
15
|
+
*
|
|
16
|
+
* @template T - The output type of the hook function
|
|
17
|
+
* @param type - TailorDB type definition
|
|
18
|
+
* @returns A function that transforms input data according to field hooks
|
|
19
|
+
*/
|
|
20
|
+
function createTailorDBHook(type) {
|
|
21
|
+
return (data) => {
|
|
22
|
+
return Object.entries(type.fields).reduce((hooked, [key, value]) => {
|
|
23
|
+
const field = value;
|
|
24
|
+
if (key === "id") hooked[key] = (data && typeof data === "object" ? data[key] : void 0) ?? crypto.randomUUID();
|
|
25
|
+
else if (field.type === "nested") hooked[key] = createTailorDBHook({ fields: field.fields })(data[key]);
|
|
26
|
+
else if (field.metadata.hooks?.create) hooked[key] = field.metadata.hooks.create({
|
|
27
|
+
value: data[key],
|
|
28
|
+
data,
|
|
29
|
+
user: unauthenticatedTailorUser
|
|
30
|
+
});
|
|
31
|
+
else if (data && typeof data === "object") hooked[key] = data[key];
|
|
32
|
+
return hooked;
|
|
33
|
+
}, {});
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates the standard schema definition for lines-db
|
|
38
|
+
* This returns the first argument for defineSchema with the ~standard section
|
|
39
|
+
*
|
|
40
|
+
* @template T - The output type after validation
|
|
41
|
+
* @param schemaType - TailorDB field schema for validation
|
|
42
|
+
* @param hook - Hook function to transform data before validation
|
|
43
|
+
* @returns Schema object with ~standard section for defineSchema
|
|
44
|
+
*/
|
|
45
|
+
function createStandardSchema(schemaType, hook) {
|
|
46
|
+
return { "~standard": {
|
|
47
|
+
version: 1,
|
|
48
|
+
vendor: "@tailor-platform/sdk",
|
|
49
|
+
validate: (value) => {
|
|
50
|
+
const hooked = hook(value);
|
|
51
|
+
const result = schemaType.parse({
|
|
52
|
+
value: hooked,
|
|
53
|
+
data: hooked,
|
|
54
|
+
user: unauthenticatedTailorUser
|
|
55
|
+
});
|
|
56
|
+
if (result.issues) return result;
|
|
57
|
+
return { value: hooked };
|
|
58
|
+
}
|
|
59
|
+
} };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { createStandardSchema, createTailorDBHook, unauthenticatedTailorUser };
|
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
# CLI Reference
|
|
2
|
+
|
|
3
|
+
The Tailor Platform SDK provides a command-line interface for managing projects and workspaces.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
tailor-sdk <command> [options]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Common Options
|
|
12
|
+
|
|
13
|
+
The following options are available for most commands:
|
|
14
|
+
|
|
15
|
+
- `-e, --env-file` - Specify a custom environment file path
|
|
16
|
+
- `-v, --verbose` - Enable detailed logging output
|
|
17
|
+
|
|
18
|
+
## Environment Variables
|
|
19
|
+
|
|
20
|
+
You can use environment variables to configure workspace and authentication:
|
|
21
|
+
|
|
22
|
+
- `TAILOR_PLATFORM_WORKSPACE_ID` - Specify workspace ID for the `apply` command
|
|
23
|
+
- `TAILOR_PLATFORM_TOKEN` - Specify authentication token (alternative to using `login`)
|
|
24
|
+
- `TAILOR_PLATFORM_PROFILE` - Specify workspace profile name to use (combines user and workspace configuration)
|
|
25
|
+
- `TAILOR_PLATFORM_SDK_CONFIG_PATH` - Specify path to the SDK config file (alternative to using `--config` option)
|
|
26
|
+
|
|
27
|
+
## Commands
|
|
28
|
+
|
|
29
|
+
### init
|
|
30
|
+
|
|
31
|
+
Initialize a new project using create-sdk.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
tailor-sdk init [name] [options]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Arguments:**
|
|
38
|
+
|
|
39
|
+
- `name` - Project name
|
|
40
|
+
|
|
41
|
+
**Options:**
|
|
42
|
+
|
|
43
|
+
- `-t, --template` - Template name
|
|
44
|
+
|
|
45
|
+
### generate
|
|
46
|
+
|
|
47
|
+
Generate files using Tailor configuration.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
tailor-sdk generate [options]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Options:**
|
|
54
|
+
|
|
55
|
+
- `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
|
|
56
|
+
- `-w, --watch` - Watch for type/resolver changes and regenerate
|
|
57
|
+
|
|
58
|
+
### apply
|
|
59
|
+
|
|
60
|
+
Apply Tailor configuration to deploy your application.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
tailor-sdk apply [options]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Options:**
|
|
67
|
+
|
|
68
|
+
- `-w, --workspace-id` - ID of the workspace to apply the configuration to
|
|
69
|
+
- `-p, --profile` - Workspace profile to use
|
|
70
|
+
- `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
|
|
71
|
+
- `-d, --dryRun` - Run the command without making any changes
|
|
72
|
+
|
|
73
|
+
### show
|
|
74
|
+
|
|
75
|
+
Show information about the deployed application.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
tailor-sdk show [options]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Options:**
|
|
82
|
+
|
|
83
|
+
- `-w, --workspace-id` - ID of the workspace to show the application from
|
|
84
|
+
- `-p, --profile` - Workspace profile to use
|
|
85
|
+
- `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
|
|
86
|
+
- `-f, --format` - Output format: `table` or `json` (default: `table`)
|
|
87
|
+
|
|
88
|
+
### login
|
|
89
|
+
|
|
90
|
+
Login to Tailor Platform.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
tailor-sdk login
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### logout
|
|
97
|
+
|
|
98
|
+
Logout from Tailor Platform.
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
tailor-sdk logout
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### workspace
|
|
105
|
+
|
|
106
|
+
Manage Tailor Platform workspaces.
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
tailor-sdk workspace <subcommand> [options]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### workspace create
|
|
113
|
+
|
|
114
|
+
Create a new Tailor Platform workspace.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
tailor-sdk workspace create [options]
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Options:**
|
|
121
|
+
|
|
122
|
+
- `-n, --name` - Name of the workspace (required)
|
|
123
|
+
- `-r, --region` - Region of the workspace: `us-west` or `asia-northeast` (required)
|
|
124
|
+
- `-d, --delete-protection` - Enable delete protection for the workspace
|
|
125
|
+
- `-o, --organization-id` - Organization ID to associate the workspace with
|
|
126
|
+
- `-f, --folder-id` - Folder ID to associate the workspace with
|
|
127
|
+
- `-f, --format` - Output format: `table` or `json` (default: `table`)
|
|
128
|
+
|
|
129
|
+
#### workspace list
|
|
130
|
+
|
|
131
|
+
List all Tailor Platform workspaces.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
tailor-sdk workspace list [options]
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Options:**
|
|
138
|
+
|
|
139
|
+
- `-f, --format` - Output format: `table` or `json` (default: `table`)
|
|
140
|
+
|
|
141
|
+
#### workspace delete
|
|
142
|
+
|
|
143
|
+
Delete a Tailor Platform workspace.
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
tailor-sdk workspace delete [options]
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Options:**
|
|
150
|
+
|
|
151
|
+
- `-w, --workspace-id` - ID of the workspace to delete (required)
|
|
152
|
+
- `-y, --yes` - Skip confirmation prompt
|
|
153
|
+
|
|
154
|
+
### profile
|
|
155
|
+
|
|
156
|
+
Manage workspace profiles (user + workspace combinations).
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
tailor-sdk profile <subcommand> [options]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### profile create
|
|
163
|
+
|
|
164
|
+
Create a new profile.
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
tailor-sdk profile create <name> [options]
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Arguments:**
|
|
171
|
+
|
|
172
|
+
- `name` - Profile name (required)
|
|
173
|
+
|
|
174
|
+
**Options:**
|
|
175
|
+
|
|
176
|
+
- `-u, --user` - User email (required)
|
|
177
|
+
- `-w, --workspace-id` - Workspace ID (required)
|
|
178
|
+
- `-f, --format` - Output format: `table` or `json` (default: `table`)
|
|
179
|
+
|
|
180
|
+
#### profile list
|
|
181
|
+
|
|
182
|
+
List all profiles.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
tailor-sdk profile list [options]
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Options:**
|
|
189
|
+
|
|
190
|
+
- `-f, --format` - Output format: `table` or `json` (default: `table`)
|
|
191
|
+
|
|
192
|
+
#### profile update
|
|
193
|
+
|
|
194
|
+
Update profile properties.
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
tailor-sdk profile update <name> [options]
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Arguments:**
|
|
201
|
+
|
|
202
|
+
- `name` - Profile name (required)
|
|
203
|
+
|
|
204
|
+
**Options:**
|
|
205
|
+
|
|
206
|
+
- `-u, --user` - New user email
|
|
207
|
+
- `-w, --workspace-id` - New workspace ID
|
|
208
|
+
- `-f, --format` - Output format: `table` or `json` (default: `table`)
|
|
209
|
+
|
|
210
|
+
#### profile delete
|
|
211
|
+
|
|
212
|
+
Delete a profile.
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
tailor-sdk profile delete <name>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Arguments:**
|
|
219
|
+
|
|
220
|
+
- `name` - Profile name (required)
|
|
221
|
+
|
|
222
|
+
### user
|
|
223
|
+
|
|
224
|
+
Manage Tailor Platform users.
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
tailor-sdk user <subcommand> [options]
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
#### user current
|
|
231
|
+
|
|
232
|
+
Show current user.
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
tailor-sdk user current [options]
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### user list
|
|
239
|
+
|
|
240
|
+
List all users.
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
tailor-sdk user list [options]
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Options:**
|
|
247
|
+
|
|
248
|
+
- `-f, --format` - Output format: `table` or `json` (default: `table`)
|
|
249
|
+
|
|
250
|
+
#### user use
|
|
251
|
+
|
|
252
|
+
Set current user.
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
tailor-sdk user use <user>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Arguments:**
|
|
259
|
+
|
|
260
|
+
- `user` - User email (required)
|
|
261
|
+
|
|
262
|
+
#### user pat
|
|
263
|
+
|
|
264
|
+
Manage personal access tokens.
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
tailor-sdk user pat <subcommand> [options]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
When no subcommand is provided, defaults to `list`.
|
|
271
|
+
|
|
272
|
+
##### user pat list
|
|
273
|
+
|
|
274
|
+
List all personal access tokens.
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
tailor-sdk user pat list [options]
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Options:**
|
|
281
|
+
|
|
282
|
+
- `-f, --format` - Output format: `text` or `json` (default: `text`)
|
|
283
|
+
|
|
284
|
+
**Output (default):**
|
|
285
|
+
|
|
286
|
+
```
|
|
287
|
+
token-name-1: read/write
|
|
288
|
+
token-name-2: read
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**Output (`--format json`):**
|
|
292
|
+
|
|
293
|
+
```json
|
|
294
|
+
[
|
|
295
|
+
{ "name": "token-name-1", "scopes": ["read", "write"] },
|
|
296
|
+
{ "name": "token-name-2", "scopes": ["read"] }
|
|
297
|
+
]
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
##### user pat create
|
|
301
|
+
|
|
302
|
+
Create a new personal access token.
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
tailor-sdk user pat create <name> [options]
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Arguments:**
|
|
309
|
+
|
|
310
|
+
- `name` - Token name (required)
|
|
311
|
+
|
|
312
|
+
**Options:**
|
|
313
|
+
|
|
314
|
+
- `-w, --write` - Grant write permission (default: read-only)
|
|
315
|
+
- `-f, --format` - Output format: `text` or `json` (default: `text`)
|
|
316
|
+
|
|
317
|
+
**Output (default):**
|
|
318
|
+
|
|
319
|
+
```
|
|
320
|
+
Personal access token created successfully.
|
|
321
|
+
|
|
322
|
+
name: token-name
|
|
323
|
+
scopes: read/write
|
|
324
|
+
token: tpp_xxxxxxxxxxxxx
|
|
325
|
+
|
|
326
|
+
Please save this token in a secure location. You won't be able to see it again.
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**Output (`--format json`):**
|
|
330
|
+
|
|
331
|
+
```json
|
|
332
|
+
{ "name": "token-name", "scopes": ["read", "write"], "token": "eyJhbGc..." }
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
##### user pat delete
|
|
336
|
+
|
|
337
|
+
Delete a personal access token.
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
tailor-sdk user pat delete <name>
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
**Arguments:**
|
|
344
|
+
|
|
345
|
+
- `name` - Token name (required)
|
|
346
|
+
|
|
347
|
+
##### user pat update
|
|
348
|
+
|
|
349
|
+
Update a personal access token (delete and recreate).
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
tailor-sdk user pat update <name> [options]
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Arguments:**
|
|
356
|
+
|
|
357
|
+
- `name` - Token name (required)
|
|
358
|
+
|
|
359
|
+
**Options:**
|
|
360
|
+
|
|
361
|
+
- `-w, --write` - Grant write permission (if not specified, keeps read-only)
|
|
362
|
+
- `-f, --format` - Output format: `text` or `json` (default: `text`)
|
|
363
|
+
|
|
364
|
+
**Output (default):**
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
Personal access token updated successfully.
|
|
368
|
+
|
|
369
|
+
name: token-name
|
|
370
|
+
scopes: read/write
|
|
371
|
+
token: tpp_xxxxxxxxxxxxx
|
|
372
|
+
|
|
373
|
+
Please save this token in a secure location. You won't be able to see it again.
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
**Output (`--format json`):**
|
|
377
|
+
|
|
378
|
+
```json
|
|
379
|
+
{
|
|
380
|
+
"name": "token-name",
|
|
381
|
+
"scopes": ["read", "write"],
|
|
382
|
+
"token": "tpp_xxxxxxxxxxxxx"
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### tailordb
|
|
387
|
+
|
|
388
|
+
Manage TailorDB tables and data.
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
tailor-sdk tailordb <subcommand> [options]
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
#### tailordb truncate
|
|
395
|
+
|
|
396
|
+
Truncate (delete all records from) TailorDB tables.
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
tailor-sdk tailordb truncate [types...] [options]
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
**Arguments:**
|
|
403
|
+
|
|
404
|
+
- `types...` - Space-separated list of type names to truncate (optional)
|
|
405
|
+
|
|
406
|
+
**Options:**
|
|
407
|
+
|
|
408
|
+
- `-a, --all` - Truncate all tables in all namespaces
|
|
409
|
+
- `-n, --namespace` - Truncate all tables in the specified namespace
|
|
410
|
+
- `-y, --yes` - Skip confirmation prompt
|
|
411
|
+
- `-w, --workspace-id` - ID of the workspace
|
|
412
|
+
- `-p, --profile` - Workspace profile to use
|
|
413
|
+
- `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
|
|
414
|
+
|
|
415
|
+
**Usage Examples:**
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
# Truncate all tables in all namespaces (requires confirmation)
|
|
419
|
+
tailor-sdk tailordb truncate --all
|
|
420
|
+
|
|
421
|
+
# Truncate all tables in all namespaces (skip confirmation)
|
|
422
|
+
tailor-sdk tailordb truncate --all --yes
|
|
423
|
+
|
|
424
|
+
# Truncate all tables in a specific namespace
|
|
425
|
+
tailor-sdk tailordb truncate --namespace myNamespace
|
|
426
|
+
|
|
427
|
+
# Truncate specific types (namespace is auto-detected)
|
|
428
|
+
tailor-sdk tailordb truncate User Post Comment
|
|
429
|
+
|
|
430
|
+
# Truncate specific types with confirmation skipped
|
|
431
|
+
tailor-sdk tailordb truncate User Post --yes
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Notes:**
|
|
435
|
+
|
|
436
|
+
- You must specify exactly one of: `--all`, `--namespace`, or type names
|
|
437
|
+
- When truncating specific types, the namespace is automatically detected from your config
|
|
438
|
+
- Confirmation prompts vary based on the operation:
|
|
439
|
+
- `--all`: requires typing `truncate all`
|
|
440
|
+
- `--namespace`: requires typing `truncate <namespace-name>`
|
|
441
|
+
- Specific types: requires typing `yes`
|
|
442
|
+
- Use `--yes` flag to skip confirmation prompts (useful for scripts and CI/CD)
|
|
443
|
+
|
|
444
|
+
### machineuser
|
|
445
|
+
|
|
446
|
+
Manage machine users in your Tailor Platform application.
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
tailor-sdk machineuser <subcommand> [options]
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
#### machineuser list
|
|
453
|
+
|
|
454
|
+
List all machine users in the application.
|
|
455
|
+
|
|
456
|
+
```bash
|
|
457
|
+
tailor-sdk machineuser list [options]
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
**Options:**
|
|
461
|
+
|
|
462
|
+
- `-w, --workspace-id` - ID of the workspace
|
|
463
|
+
- `-p, --profile` - Workspace profile to use
|
|
464
|
+
- `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
|
|
465
|
+
- `-f, --format` - Output format: `table` or `json` (default: `table`)
|
|
466
|
+
|
|
467
|
+
#### machineuser token
|
|
468
|
+
|
|
469
|
+
Get an access token for a machine user.
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
tailor-sdk machineuser token <name> [options]
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
**Arguments:**
|
|
476
|
+
|
|
477
|
+
- `name` - Machine user name (required)
|
|
478
|
+
|
|
479
|
+
**Options:**
|
|
480
|
+
|
|
481
|
+
- `-w, --workspace-id` - ID of the workspace
|
|
482
|
+
- `-p, --profile` - Workspace profile to use
|
|
483
|
+
- `-c, --config` - Path to the SDK config file (default: `tailor.config.ts`)
|
|
484
|
+
- `-f, --format` - Output format: `table` or `json` (default: `table`)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
The SDK uses TypeScript for configuration files. By default, it uses `tailor.config.ts` in the project root. You can specify a different path using the `--config` option.
|
|
4
|
+
|
|
5
|
+
### Application Settings
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
name: "my-app",
|
|
10
|
+
cors: ["https://example.com", website.url],
|
|
11
|
+
allowedIPAddresses: ["192.168.1.0/24"],
|
|
12
|
+
disableIntrospection: false,
|
|
13
|
+
});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Name**: Set the application name.
|
|
17
|
+
|
|
18
|
+
**CORS**: Specify CORS settings as an array.
|
|
19
|
+
|
|
20
|
+
**Allowed IP Addresses**: Specify IP addresses allowed to access the application in CIDR format.
|
|
21
|
+
|
|
22
|
+
**Disable Introspection**: Disable GraphQL introspection. Default is `false`.
|
|
23
|
+
|
|
24
|
+
### Service Configuration
|
|
25
|
+
|
|
26
|
+
Specify glob patterns to load service files:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
export default defineConfig({
|
|
30
|
+
db: {
|
|
31
|
+
"my-db": {
|
|
32
|
+
files: ["db/**/*.ts"],
|
|
33
|
+
ignores: ["db/**/*.draft.ts"],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
resolver: {
|
|
37
|
+
"my-resolver": {
|
|
38
|
+
files: ["resolver/**/*.ts"],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
executor: {
|
|
42
|
+
files: ["executors/**/*.ts"],
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**files**: Glob patterns to match files. Required.
|
|
48
|
+
|
|
49
|
+
**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.
|
|
50
|
+
|
|
51
|
+
### Built-in IdP
|
|
52
|
+
|
|
53
|
+
Configure the Built-in IdP service using `defineIdp()`. The returned IdP object provides type-safe provider references via `idp.provider()` that can be used in Auth service configuration.
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { defineIdp } from "@tailor-platform/sdk";
|
|
57
|
+
|
|
58
|
+
const idp = defineIdp("my-idp", {
|
|
59
|
+
authorization: "loggedIn",
|
|
60
|
+
clients: ["my-client"],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export default defineConfig({
|
|
64
|
+
idp: [idp],
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**authorization**: User management permissions (`"insecure"`, `"loggedIn"`, or CEL expression).
|
|
69
|
+
|
|
70
|
+
**clients**: OAuth client names for the IdP.
|
|
71
|
+
|
|
72
|
+
### Auth Service
|
|
73
|
+
|
|
74
|
+
Configure Auth service using `defineAuth()`:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { defineAuth } from "@tailor-platform/sdk";
|
|
78
|
+
import { user } from "./tailordb/user";
|
|
79
|
+
|
|
80
|
+
const auth = defineAuth("my-auth", {
|
|
81
|
+
userProfile: {
|
|
82
|
+
type: user,
|
|
83
|
+
usernameField: "email",
|
|
84
|
+
attributes: { role: true },
|
|
85
|
+
},
|
|
86
|
+
machineUsers: {
|
|
87
|
+
"admin-machine-user": {
|
|
88
|
+
attributes: { role: "ADMIN" },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
oauth2Clients: {
|
|
92
|
+
"my-oauth2-client": {
|
|
93
|
+
redirectURIs: ["https://example.com/callback"],
|
|
94
|
+
grantTypes: ["authorization_code", "refresh_token"],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
idProvider: idp.provider("my-provider", "my-client"),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export default defineConfig({
|
|
101
|
+
auth,
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**userProfile**: Maps identities to TailorDB type with username field and attributes.
|
|
106
|
+
|
|
107
|
+
**machineUsers**: Service accounts with predefined attributes.
|
|
108
|
+
|
|
109
|
+
**oauth2Clients**: OAuth 2.0 clients with redirect URIs and grant types.
|
|
110
|
+
|
|
111
|
+
**idProvider**: External identity provider (OIDC, SAML, IDToken, or BuiltInIdP).
|
|
112
|
+
|
|
113
|
+
### Static Websites
|
|
114
|
+
|
|
115
|
+
Configure static website hosting using `defineStaticWebSite()`. The returned website object provides a type-safe `url` property that can be used in CORS settings and OAuth2 redirect URIs.
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { defineStaticWebSite } from "@tailor-platform/sdk";
|
|
119
|
+
|
|
120
|
+
const website = defineStaticWebSite("my-website", {
|
|
121
|
+
description: "My Static Website",
|
|
122
|
+
allowedIPAddresses: ["192.168.0.0/24"],
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export default defineConfig({
|
|
126
|
+
staticWebsites: [website],
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**description**: Description of the site.
|
|
131
|
+
|
|
132
|
+
**allowedIPAddresses**: List of IP addresses allowed to access the site in CIDR format.
|