@tailor-platform/sdk 1.2.6 → 1.3.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 +57 -0
- package/dist/cli/index.mjs +554 -13
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +1 -1
- package/dist/cli/lib.mjs +1 -1
- package/dist/config-BmQRlW1j.mjs.map +1 -1
- package/dist/configure/index.d.mts +2 -2
- package/dist/{index-Cf3uhB_7.d.mts → index-ByDQH56l.d.mts} +33 -4
- package/dist/{list-WMFoshbx.mjs → list-BCl3ViG0.mjs} +53 -26
- package/dist/list-BCl3ViG0.mjs.map +1 -0
- package/dist/{src-BhwQdist.mjs → src-Bhwd-tei.mjs} +2 -2
- package/dist/{src-BhwQdist.mjs.map → src-Bhwd-tei.mjs.map} +1 -1
- package/dist/{types-D2rYkxav.d.mts → types-22f0o6xW.d.mts} +10 -9
- package/dist/utils/test/index.d.mts +2 -2
- package/docs/cli/application.md +129 -0
- package/docs/cli-reference.md +26 -9
- package/docs/services/auth.md +5 -0
- package/docs/services/executor.md +6 -0
- package/docs/services/idp.md +13 -1
- package/docs/services/resolver.md +6 -0
- package/docs/services/staticwebsite.md +12 -1
- package/docs/services/tailordb.md +126 -7
- package/docs/services/workflow.md +8 -0
- package/package.json +26 -13
- package/dist/list-WMFoshbx.mjs.map +0 -1
|
@@ -16,6 +16,12 @@ For the official Tailor Platform documentation, see [Static Website Guide](https
|
|
|
16
16
|
|
|
17
17
|
Configure static website hosting using `defineStaticWebSite()`:
|
|
18
18
|
|
|
19
|
+
**Definition Rules:**
|
|
20
|
+
|
|
21
|
+
- **Multiple websites allowed**: You can define multiple static websites in your config file
|
|
22
|
+
- **Configuration location**: Define in `tailor.config.ts` and add to the `staticWebsites` array
|
|
23
|
+
- **Uniqueness**: Website names must be unique across all static websites
|
|
24
|
+
|
|
19
25
|
```typescript
|
|
20
26
|
import { defineStaticWebSite, defineConfig } from "@tailor-platform/sdk";
|
|
21
27
|
|
|
@@ -23,8 +29,13 @@ const website = defineStaticWebSite("my-website", {
|
|
|
23
29
|
description: "My Static Website",
|
|
24
30
|
});
|
|
25
31
|
|
|
32
|
+
// You can define multiple static websites
|
|
33
|
+
const adminWebsite = defineStaticWebSite("admin-website", {
|
|
34
|
+
description: "Admin Dashboard",
|
|
35
|
+
});
|
|
36
|
+
|
|
26
37
|
export default defineConfig({
|
|
27
|
-
staticWebsites: [website],
|
|
38
|
+
staticWebsites: [website, adminWebsite], // Add all websites to the array
|
|
28
39
|
});
|
|
29
40
|
```
|
|
30
41
|
|
|
@@ -18,15 +18,30 @@ For the official Tailor Platform documentation, see [TailorDB Guide](https://doc
|
|
|
18
18
|
|
|
19
19
|
Define TailorDB Types in files matching glob patterns specified in `tailor.config.ts`.
|
|
20
20
|
|
|
21
|
+
**Definition Rules:**
|
|
22
|
+
|
|
23
|
+
- **Multiple types per file**: You can define multiple TailorDB types in a single file
|
|
24
|
+
- **Export method**: Use named exports (`export const`)
|
|
25
|
+
- **Export both value and type**: Always export both the runtime value and TypeScript type
|
|
26
|
+
- **Uniqueness**: Type names must be unique across all TailorDB files
|
|
27
|
+
|
|
21
28
|
```typescript
|
|
22
29
|
import { db } from "@tailor-platform/sdk";
|
|
23
30
|
|
|
31
|
+
// Export both value and type
|
|
24
32
|
export const user = db.type("User", {
|
|
25
33
|
name: db.string(),
|
|
26
34
|
email: db.string().unique(),
|
|
27
35
|
age: db.int(),
|
|
28
36
|
...db.fields.timestamps(),
|
|
29
37
|
});
|
|
38
|
+
export type user = typeof user;
|
|
39
|
+
|
|
40
|
+
// You can define multiple types in the same file
|
|
41
|
+
export const role = db.type("Role", {
|
|
42
|
+
name: db.string().unique(),
|
|
43
|
+
});
|
|
44
|
+
export type role = typeof role;
|
|
30
45
|
```
|
|
31
46
|
|
|
32
47
|
Specify plural form by passing an array as first argument:
|
|
@@ -190,26 +205,130 @@ type User {
|
|
|
190
205
|
|
|
191
206
|
### Hooks
|
|
192
207
|
|
|
193
|
-
Add hooks to execute functions during data creation or update:
|
|
208
|
+
Add hooks to execute functions during data creation or update. Hooks receive three arguments:
|
|
209
|
+
|
|
210
|
+
- `value`: User input if provided, otherwise existing value on update or null on create
|
|
211
|
+
- `data`: Entire record data (for accessing other field values)
|
|
212
|
+
- `user`: User performing the operation
|
|
213
|
+
|
|
214
|
+
#### Field-level Hooks
|
|
215
|
+
|
|
216
|
+
Set hooks directly on individual fields:
|
|
194
217
|
|
|
195
218
|
```typescript
|
|
196
|
-
db.
|
|
197
|
-
create: () =>
|
|
198
|
-
update: () =>
|
|
219
|
+
db.string().hooks({
|
|
220
|
+
create: ({ user }) => user.id,
|
|
221
|
+
update: ({ value }) => value,
|
|
199
222
|
});
|
|
200
223
|
```
|
|
201
224
|
|
|
202
|
-
|
|
225
|
+
**Note:** When setting hooks at the field level, the `data` argument type is `unknown` since the field doesn't know about other fields in the type. Use type-level hooks if you need to access other fields with type safety.
|
|
226
|
+
|
|
227
|
+
#### Type-level Hooks
|
|
228
|
+
|
|
229
|
+
Set hooks for multiple fields at once using `db.type().hooks()`:
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
export const customer = db
|
|
233
|
+
.type("Customer", {
|
|
234
|
+
firstName: db.string(),
|
|
235
|
+
lastName: db.string(),
|
|
236
|
+
fullName: db.string(),
|
|
237
|
+
})
|
|
238
|
+
.hooks({
|
|
239
|
+
fullName: {
|
|
240
|
+
create: ({ data }) => `${data.firstName} ${data.lastName}`,
|
|
241
|
+
update: ({ data }) => `${data.firstName} ${data.lastName}`,
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**⚠️ Important:** Field-level and type-level hooks cannot coexist on the same field. TypeScript will prevent this at compile time:
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
// ❌ Compile error - cannot set hooks on the same field twice
|
|
250
|
+
export const user = db
|
|
251
|
+
.type("User", {
|
|
252
|
+
name: db.string().hooks({ create: ({ data }) => data.firstName }), // Field-level
|
|
253
|
+
})
|
|
254
|
+
.hooks({
|
|
255
|
+
name: { create: ({ data }) => data.lastName }, // Type-level - ERROR
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// ✅ Correct - set hooks on different fields
|
|
259
|
+
export const user = db
|
|
260
|
+
.type("User", {
|
|
261
|
+
firstName: db.string().hooks({ create: () => "John" }), // Field-level on firstName
|
|
262
|
+
lastName: db.string(),
|
|
263
|
+
})
|
|
264
|
+
.hooks({
|
|
265
|
+
lastName: { create: () => "Doe" }, // Type-level on lastName
|
|
266
|
+
});
|
|
267
|
+
```
|
|
203
268
|
|
|
204
269
|
### Validation
|
|
205
270
|
|
|
271
|
+
Add validation rules to fields. Validators receive three arguments (executed after hooks):
|
|
272
|
+
|
|
273
|
+
- `value`: Field value after hook transformation
|
|
274
|
+
- `data`: Entire record data after hook transformations (for accessing other field values)
|
|
275
|
+
- `user`: User performing the operation
|
|
276
|
+
|
|
277
|
+
Validators return `true` for success, `false` for failure. Use array form `[validator, errorMessage]` for custom error messages.
|
|
278
|
+
|
|
279
|
+
#### Field-level Validation
|
|
280
|
+
|
|
281
|
+
Set validators directly on individual fields:
|
|
282
|
+
|
|
206
283
|
```typescript
|
|
207
284
|
db.string().validate(
|
|
208
|
-
({ value }) => value.
|
|
209
|
-
[({ value }) => value.length
|
|
285
|
+
({ value }) => value.includes("@"),
|
|
286
|
+
[({ value }) => value.length >= 5, "Email must be at least 5 characters"],
|
|
210
287
|
);
|
|
211
288
|
```
|
|
212
289
|
|
|
290
|
+
#### Type-level Validation
|
|
291
|
+
|
|
292
|
+
Set validators for multiple fields at once using `db.type().validate()`:
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
export const user = db
|
|
296
|
+
.type("User", {
|
|
297
|
+
name: db.string(),
|
|
298
|
+
email: db.string(),
|
|
299
|
+
})
|
|
300
|
+
.validate({
|
|
301
|
+
name: [({ value }) => value.length > 5, "Name must be longer than 5 characters"],
|
|
302
|
+
email: [
|
|
303
|
+
({ value }) => value.includes("@"),
|
|
304
|
+
[({ value }) => value.length >= 5, "Email must be at least 5 characters"],
|
|
305
|
+
],
|
|
306
|
+
});
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**⚠️ Important:** Field-level and type-level validation cannot coexist on the same field. TypeScript will prevent this at compile time:
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
// ❌ Compile error - cannot set validation on the same field twice
|
|
313
|
+
export const user = db
|
|
314
|
+
.type("User", {
|
|
315
|
+
name: db.string().validate(({ value }) => value.length > 0), // Field-level
|
|
316
|
+
})
|
|
317
|
+
.validate({
|
|
318
|
+
name: [({ value }) => value.length < 100, "Too long"], // Type-level - ERROR
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// ✅ Correct - set validation on different fields
|
|
322
|
+
export const user = db
|
|
323
|
+
.type("User", {
|
|
324
|
+
name: db.string().validate(({ value }) => value.length > 0), // Field-level on name
|
|
325
|
+
email: db.string(),
|
|
326
|
+
})
|
|
327
|
+
.validate({
|
|
328
|
+
email: [({ value }) => value.includes("@"), "Invalid email"], // Type-level on email
|
|
329
|
+
});
|
|
330
|
+
```
|
|
331
|
+
|
|
213
332
|
### Vector Search
|
|
214
333
|
|
|
215
334
|
```typescript
|
|
@@ -18,6 +18,14 @@ For the official Tailor Platform documentation, see [Workflow Guide](https://doc
|
|
|
18
18
|
|
|
19
19
|
All workflow components must follow these rules:
|
|
20
20
|
|
|
21
|
+
**Definition Rules:**
|
|
22
|
+
|
|
23
|
+
- **One workflow + multiple jobs per file**: Each file can define multiple jobs (named exports) and one workflow (default export)
|
|
24
|
+
- **Workflow export method**: Must use `export default`
|
|
25
|
+
- **Job export method**: Must use named exports (`export const`)
|
|
26
|
+
- **Job name uniqueness**: Job names must be unique across the entire project (not just within one file)
|
|
27
|
+
- **mainJob required**: Every workflow must specify a `mainJob`
|
|
28
|
+
|
|
21
29
|
| Rule | Description |
|
|
22
30
|
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
23
31
|
| `createWorkflow` result must be default export | Workflow files must export the workflow as default |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@bufbuild/protobuf": "2.10.2",
|
|
44
44
|
"@connectrpc/connect": "2.1.1",
|
|
45
45
|
"@connectrpc/connect-node": "2.1.1",
|
|
46
|
-
"@oxc-project/types": "0.
|
|
46
|
+
"@oxc-project/types": "0.108.0",
|
|
47
47
|
"@standard-schema/spec": "1.1.0",
|
|
48
48
|
"@urql/core": "6.0.1",
|
|
49
49
|
"chalk": "5.6.2",
|
|
@@ -59,15 +59,16 @@
|
|
|
59
59
|
"multiline-ts": "4.0.1",
|
|
60
60
|
"open": "11.0.0",
|
|
61
61
|
"ora": "9.0.0",
|
|
62
|
-
"oxc-parser": "0.
|
|
62
|
+
"oxc-parser": "0.108.0",
|
|
63
63
|
"p-limit": "7.2.0",
|
|
64
|
+
"pathe": "2.0.3",
|
|
64
65
|
"pkg-types": "2.3.0",
|
|
65
|
-
"rolldown": "1.0.0-beta.
|
|
66
|
+
"rolldown": "1.0.0-beta.60",
|
|
66
67
|
"std-env": "3.10.0",
|
|
67
68
|
"table": "6.9.0",
|
|
68
69
|
"ts-cron-validator": "1.1.5",
|
|
69
70
|
"tsx": "4.21.0",
|
|
70
|
-
"type-fest": "5.
|
|
71
|
+
"type-fest": "5.4.1",
|
|
71
72
|
"xdg-basedir": "5.1.0",
|
|
72
73
|
"zod": "4.3.5"
|
|
73
74
|
},
|
|
@@ -77,21 +78,33 @@
|
|
|
77
78
|
"@toiroakr/lines-db": "0.6.1",
|
|
78
79
|
"@types/madge": "5.0.3",
|
|
79
80
|
"@types/mime-types": "3.0.1",
|
|
80
|
-
"@types/node": "24.10.
|
|
81
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
82
|
-
"@vitest/coverage-v8": "4.0.
|
|
81
|
+
"@types/node": "24.10.9",
|
|
82
|
+
"@typescript/native-preview": "7.0.0-dev.20260116.1",
|
|
83
|
+
"@vitest/coverage-v8": "4.0.17",
|
|
83
84
|
"cross-env": "10.1.0",
|
|
84
85
|
"eslint": "9.39.2",
|
|
85
86
|
"eslint-plugin-jsdoc": "62.0.0",
|
|
86
|
-
"eslint-plugin-oxlint": "1.
|
|
87
|
+
"eslint-plugin-oxlint": "1.39.0",
|
|
87
88
|
"globals": "17.0.0",
|
|
88
|
-
"oxlint": "1.
|
|
89
|
-
"oxlint-tsgolint": "0.11.
|
|
89
|
+
"oxlint": "1.39.0",
|
|
90
|
+
"oxlint-tsgolint": "0.11.1",
|
|
90
91
|
"sonda": "0.10.1",
|
|
91
92
|
"tsdown": "0.19.0",
|
|
92
93
|
"typescript": "5.9.3",
|
|
93
|
-
"typescript-eslint": "8.
|
|
94
|
-
"vitest": "4.0.
|
|
94
|
+
"typescript-eslint": "8.53.0",
|
|
95
|
+
"vitest": "4.0.17"
|
|
96
|
+
},
|
|
97
|
+
"peerDependencies": {
|
|
98
|
+
"@liam-hq/cli": "*",
|
|
99
|
+
"serve": "*"
|
|
100
|
+
},
|
|
101
|
+
"peerDependenciesMeta": {
|
|
102
|
+
"@liam-hq/cli": {
|
|
103
|
+
"optional": true
|
|
104
|
+
},
|
|
105
|
+
"serve": {
|
|
106
|
+
"optional": true
|
|
107
|
+
}
|
|
95
108
|
},
|
|
96
109
|
"scripts": {
|
|
97
110
|
"test": "vitest",
|