@tailor-platform/create-sdk 2.0.0-next.3 → 2.0.0-next.5
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 +29 -0
- package/package.json +6 -6
- package/templates/executor/package.json +5 -5
- package/templates/executor/src/db/auditLog.ts +1 -1
- package/templates/executor/src/db/notification.ts +1 -1
- package/templates/executor/src/db/user.ts +1 -1
- package/templates/generators/package.json +5 -5
- package/templates/generators/src/db/category.ts +1 -1
- package/templates/generators/src/db/order.ts +1 -1
- package/templates/generators/src/db/product.ts +1 -1
- package/templates/generators/src/db/user.ts +1 -1
- package/templates/generators/src/generated/files.ts +1 -1
- package/templates/generators/src/seed/data/Order.schema.ts +2 -2
- package/templates/generators/src/seed/data/Product.schema.ts +2 -2
- package/templates/generators/src/seed/data/User.schema.ts +2 -2
- package/templates/hello-world/package.json +4 -4
- package/templates/hello-world/src/db/user.ts +1 -1
- package/templates/inventory-management/package.json +4 -4
- package/templates/inventory-management/src/db/category.ts +1 -1
- package/templates/inventory-management/src/db/contact.ts +1 -1
- package/templates/inventory-management/src/db/inventory.ts +2 -2
- package/templates/inventory-management/src/db/notification.ts +1 -1
- package/templates/inventory-management/src/db/order.ts +1 -1
- package/templates/inventory-management/src/db/orderItem.ts +12 -8
- package/templates/inventory-management/src/db/product.ts +1 -1
- package/templates/inventory-management/src/db/user.ts +1 -1
- package/templates/inventory-management/src/generated/kysely-tailordb.ts +1 -1
- package/templates/inventory-management/src/resolver/registerOrder.ts +3 -1
- package/templates/multi-application/apps/admin/db/adminNote.ts +1 -1
- package/templates/multi-application/apps/user/db/user.ts +1 -1
- package/templates/multi-application/package.json +4 -4
- package/templates/resolver/package.json +5 -5
- package/templates/resolver/src/db/user.ts +1 -1
- package/templates/static-web-site/package.json +4 -4
- package/templates/static-web-site/src/db/user.ts +1 -1
- package/templates/tailordb/README.md +1 -1
- package/templates/tailordb/package.json +5 -5
- package/templates/tailordb/src/db/category.ts +1 -1
- package/templates/tailordb/src/db/comment.ts +4 -2
- package/templates/tailordb/src/db/task.ts +19 -27
- package/templates/tailordb/src/db/user.ts +1 -1
- package/templates/workflow/package.json +6 -6
- package/templates/workflow/src/db/order.ts +1 -1
- package/templates/workflow/src/db/user.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @tailor-platform/create-sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.0-next.5
|
|
4
|
+
|
|
5
|
+
## 2.0.0-next.4
|
|
6
|
+
|
|
7
|
+
### Major Changes
|
|
8
|
+
|
|
9
|
+
- [#1693](https://github.com/tailor-platform/sdk/pull/1693) [`4751214`](https://github.com/tailor-platform/sdk/commit/4751214c0923e094a844f9ce322279a47e871075) Thanks [@dqn](https://github.com/dqn)! - Rename the TailorDB schema builder from `db.type()` to `db.table()`.
|
|
10
|
+
|
|
11
|
+
Update TailorDB definitions:
|
|
12
|
+
|
|
13
|
+
```diff
|
|
14
|
+
import { db } from "@tailor-platform/sdk";
|
|
15
|
+
|
|
16
|
+
-export const user = db.type("User", {
|
|
17
|
+
+export const user = db.table("User", {
|
|
18
|
+
name: db.string(),
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- [#1704](https://github.com/tailor-platform/sdk/pull/1704) [`9c81d9c`](https://github.com/tailor-platform/sdk/commit/9c81d9c18b1d29b3e9307ea17fe54c8ce55f4dda) Thanks [@dqn](https://github.com/dqn)! - Remove flat value and default exports from `@tailor-platform/sdk/runtime/*` subpath modules. Import each subpath through its self-named namespace export instead, for example `import { iconv } from "@tailor-platform/sdk/runtime/iconv"`.
|
|
25
|
+
|
|
26
|
+
The aggregate `@tailor-platform/sdk/runtime` entry remains named-only, and its deprecated `file.deleteFile` alias is removed in favor of `file.delete`. The v2 codemod rewrites straightforward namespace-star subpath imports, flat named value imports, and aggregate `file.deleteFile` calls to the new namespace-object style.
|
|
27
|
+
|
|
28
|
+
`TailorContextAPI` and `TailorWorkflowAPI` now describe the SDK wrapper objects. Code that types the platform-provided `globalThis.tailor.context` or `globalThis.tailor.workflow` objects directly must use `PlatformContextAPI` or `PlatformWorkflowAPI` instead.
|
|
29
|
+
|
|
3
30
|
## 2.0.0-next.3
|
|
4
31
|
|
|
5
32
|
### Major Changes
|
|
@@ -61,6 +88,8 @@
|
|
|
61
88
|
|
|
62
89
|
## 1.71.0
|
|
63
90
|
|
|
91
|
+
## 1.75.0
|
|
92
|
+
|
|
64
93
|
## 1.74.1
|
|
65
94
|
|
|
66
95
|
## 1.74.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/create-sdk",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.5",
|
|
4
4
|
"description": "A CLI tool to quickly create a new Tailor Platform SDK project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
],
|
|
18
18
|
"type": "module",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@clack/prompts": "1.
|
|
20
|
+
"@clack/prompts": "1.7.0",
|
|
21
21
|
"execa": "9.6.1",
|
|
22
22
|
"picocolors": "1.1.1",
|
|
23
23
|
"pkg-types": "2.3.1",
|
|
24
|
-
"politty": "0.11.
|
|
24
|
+
"politty": "0.11.2",
|
|
25
25
|
"zod": "4.4.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/node": "24.13.
|
|
28
|
+
"@types/node": "24.13.3",
|
|
29
29
|
"eslint-plugin-zod": "4.7.0",
|
|
30
|
-
"oxlint": "1.
|
|
30
|
+
"oxlint": "1.73.0",
|
|
31
31
|
"oxlint-tsgolint": "0.24.0",
|
|
32
|
-
"tsdown": "0.22.
|
|
32
|
+
"tsdown": "0.22.4",
|
|
33
33
|
"typescript": "6.0.3"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"typecheck": "tsc --noEmit"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@tailor-platform/sdk": "2.0.0-next.
|
|
19
|
-
"@types/node": "24.13.
|
|
20
|
-
"oxfmt": "0.
|
|
21
|
-
"oxlint": "1.
|
|
18
|
+
"@tailor-platform/sdk": "2.0.0-next.5",
|
|
19
|
+
"@types/node": "24.13.3",
|
|
20
|
+
"oxfmt": "0.58.0",
|
|
21
|
+
"oxlint": "1.73.0",
|
|
22
22
|
"oxlint-tsgolint": "0.24.0",
|
|
23
23
|
"typescript": "6.0.3",
|
|
24
|
-
"vitest": "4.1.
|
|
24
|
+
"vitest": "4.1.10"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { db } from "@tailor-platform/sdk";
|
|
2
2
|
|
|
3
3
|
export const auditLog = db
|
|
4
|
-
.
|
|
4
|
+
.table("AuditLog", "Records system events for auditing", {
|
|
5
5
|
action: db.string(),
|
|
6
6
|
entityType: db.string(),
|
|
7
7
|
entityId: db.uuid(),
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"typecheck": "tsc --noEmit"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@tailor-platform/sdk": "2.0.0-next.
|
|
19
|
-
"@types/node": "24.13.
|
|
20
|
-
"oxfmt": "0.
|
|
21
|
-
"oxlint": "1.
|
|
18
|
+
"@tailor-platform/sdk": "2.0.0-next.5",
|
|
19
|
+
"@types/node": "24.13.3",
|
|
20
|
+
"oxfmt": "0.58.0",
|
|
21
|
+
"oxlint": "1.73.0",
|
|
22
22
|
"oxlint-tsgolint": "0.24.0",
|
|
23
23
|
"typescript": "6.0.3",
|
|
24
|
-
"vitest": "4.1.
|
|
24
|
+
"vitest": "4.1.10"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -4,8 +4,8 @@ import { createTailorDBHook, createStandardSchema } from "@tailor-platform/sdk/t
|
|
|
4
4
|
import { order } from "../../db/order";
|
|
5
5
|
|
|
6
6
|
const schemaType = t.object({
|
|
7
|
-
...order.pickFields(["id"
|
|
8
|
-
...order.omitFields(["id"
|
|
7
|
+
...order.pickFields(["id"], { optional: true }),
|
|
8
|
+
...order.omitFields(["id"]),
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
const hook = createTailorDBHook(order);
|
|
@@ -4,8 +4,8 @@ import { createTailorDBHook, createStandardSchema } from "@tailor-platform/sdk/t
|
|
|
4
4
|
import { product } from "../../db/product";
|
|
5
5
|
|
|
6
6
|
const schemaType = t.object({
|
|
7
|
-
...product.pickFields(["id"
|
|
8
|
-
...product.omitFields(["id"
|
|
7
|
+
...product.pickFields(["id"], { optional: true }),
|
|
8
|
+
...product.omitFields(["id"]),
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
const hook = createTailorDBHook(product);
|
|
@@ -4,8 +4,8 @@ import { createTailorDBHook, createStandardSchema } from "@tailor-platform/sdk/t
|
|
|
4
4
|
import { user } from "../../db/user";
|
|
5
5
|
|
|
6
6
|
const schemaType = t.object({
|
|
7
|
-
...user.pickFields(["id"
|
|
8
|
-
...user.omitFields(["id"
|
|
7
|
+
...user.pickFields(["id"], { optional: true }),
|
|
8
|
+
...user.omitFields(["id"]),
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
const hook = createTailorDBHook(user);
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"typecheck": "tsc --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@tailor-platform/sdk": "2.0.0-next.
|
|
17
|
-
"@types/node": "24.13.
|
|
18
|
-
"oxfmt": "0.
|
|
19
|
-
"oxlint": "1.
|
|
16
|
+
"@tailor-platform/sdk": "2.0.0-next.5",
|
|
17
|
+
"@types/node": "24.13.3",
|
|
18
|
+
"oxfmt": "0.58.0",
|
|
19
|
+
"oxlint": "1.73.0",
|
|
20
20
|
"oxlint-tsgolint": "0.24.0",
|
|
21
21
|
"typescript": "6.0.3"
|
|
22
22
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "@tailor-platform/sdk";
|
|
6
6
|
|
|
7
7
|
export const user = db
|
|
8
|
-
.
|
|
8
|
+
.table("User", {
|
|
9
9
|
name: db.string().description("Name of the user"),
|
|
10
10
|
email: db.string().unique().description("Email address of the user"),
|
|
11
11
|
role: db.enum(["MANAGER", "STAFF"]),
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"typecheck": "tsc --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@tailor-platform/sdk": "2.0.0-next.
|
|
17
|
-
"@types/node": "24.13.
|
|
18
|
-
"oxfmt": "0.
|
|
19
|
-
"oxlint": "1.
|
|
16
|
+
"@tailor-platform/sdk": "2.0.0-next.5",
|
|
17
|
+
"@types/node": "24.13.3",
|
|
18
|
+
"oxfmt": "0.58.0",
|
|
19
|
+
"oxlint": "1.73.0",
|
|
20
20
|
"oxlint-tsgolint": "0.24.0",
|
|
21
21
|
"typescript": "6.0.3"
|
|
22
22
|
}
|
|
@@ -2,7 +2,7 @@ import { db } from "@tailor-platform/sdk";
|
|
|
2
2
|
import { gqlPermissionManager, permissionManager } from "./common/permission";
|
|
3
3
|
|
|
4
4
|
export const category = db
|
|
5
|
-
.
|
|
5
|
+
.table("Category", {
|
|
6
6
|
name: db.string().description("Name of the category").unique(),
|
|
7
7
|
description: db.string({ optional: true }).description("Description of the category"),
|
|
8
8
|
...db.fields.timestamps(),
|
|
@@ -2,7 +2,7 @@ import { db } from "@tailor-platform/sdk";
|
|
|
2
2
|
import { gqlPermissionManager, permissionManager } from "./common/permission";
|
|
3
3
|
|
|
4
4
|
export const contact = db
|
|
5
|
-
.
|
|
5
|
+
.table("Contact", {
|
|
6
6
|
name: db.string().description("Name of the contact"),
|
|
7
7
|
email: db.string().unique().description("Email address of the contact"),
|
|
8
8
|
phone: db.string({ optional: true }).description("Phone number of the contact"),
|
|
@@ -3,7 +3,7 @@ import { gqlPermissionLoggedIn, permissionLoggedIn } from "./common/permission";
|
|
|
3
3
|
import { product } from "./product";
|
|
4
4
|
|
|
5
5
|
export const inventory = db
|
|
6
|
-
.
|
|
6
|
+
.table("Inventory", {
|
|
7
7
|
productId: db
|
|
8
8
|
.uuid()
|
|
9
9
|
.description("ID of the product")
|
|
@@ -11,7 +11,7 @@ export const inventory = db
|
|
|
11
11
|
quantity: db
|
|
12
12
|
.int()
|
|
13
13
|
.description("Quantity of the product in inventory")
|
|
14
|
-
.validate(({ value }) => value
|
|
14
|
+
.validate(({ value }) => (value < 0 ? "Quantity must be non-negative" : undefined)),
|
|
15
15
|
...db.fields.timestamps(),
|
|
16
16
|
})
|
|
17
17
|
.permission(permissionLoggedIn)
|
|
@@ -2,7 +2,7 @@ import { db } from "@tailor-platform/sdk";
|
|
|
2
2
|
import { loggedIn, managerRole, permissionManager } from "./common/permission";
|
|
3
3
|
|
|
4
4
|
export const notification = db
|
|
5
|
-
.
|
|
5
|
+
.table("Notification", {
|
|
6
6
|
message: db.string().description("Notification message"),
|
|
7
7
|
...db.fields.timestamps(),
|
|
8
8
|
})
|
|
@@ -3,7 +3,7 @@ import { contact } from "./contact";
|
|
|
3
3
|
import { gqlPermissionLoggedIn, permissionLoggedIn } from "./common/permission";
|
|
4
4
|
|
|
5
5
|
export const order = db
|
|
6
|
-
.
|
|
6
|
+
.table("Order", {
|
|
7
7
|
name: db.string().description("Name of the order"),
|
|
8
8
|
description: db.string({ optional: true }).description("Description of the order"),
|
|
9
9
|
orderDate: db.datetime().description("Date of the order"),
|
|
@@ -4,7 +4,7 @@ import { product } from "./product";
|
|
|
4
4
|
import { gqlPermissionLoggedIn, permissionLoggedIn } from "./common/permission";
|
|
5
5
|
|
|
6
6
|
export const orderItem = db
|
|
7
|
-
.
|
|
7
|
+
.table("OrderItem", {
|
|
8
8
|
orderId: db
|
|
9
9
|
.uuid()
|
|
10
10
|
.description("ID of the order")
|
|
@@ -16,19 +16,23 @@ export const orderItem = db
|
|
|
16
16
|
quantity: db
|
|
17
17
|
.int()
|
|
18
18
|
.description("Quantity of the product")
|
|
19
|
-
.validate(({ value }) => value
|
|
19
|
+
.validate(({ value }) => (value < 0 ? "Quantity must be non-negative" : undefined)),
|
|
20
20
|
unitPrice: db
|
|
21
21
|
.float()
|
|
22
22
|
.description("Unit price of the product")
|
|
23
|
-
.validate(({ value }) => value
|
|
24
|
-
totalPrice: db.float(
|
|
23
|
+
.validate(({ value }) => (value < 0 ? "Unit price must be non-negative" : undefined)),
|
|
24
|
+
totalPrice: db.float().default(0).description("Total price of the order item"),
|
|
25
25
|
...db.fields.timestamps(),
|
|
26
26
|
})
|
|
27
27
|
.hooks({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
28
|
+
create: ({ input }) => ({
|
|
29
|
+
totalPrice: (input?.quantity ?? 0) * (input?.unitPrice ?? 0),
|
|
30
|
+
}),
|
|
31
|
+
update: ({ input, oldRecord }) => ({
|
|
32
|
+
totalPrice:
|
|
33
|
+
(input?.quantity ?? oldRecord?.quantity ?? 0) *
|
|
34
|
+
(input?.unitPrice ?? oldRecord?.unitPrice ?? 0),
|
|
35
|
+
}),
|
|
32
36
|
})
|
|
33
37
|
.permission(permissionLoggedIn)
|
|
34
38
|
.gqlPermission(gqlPermissionLoggedIn);
|
|
@@ -3,7 +3,7 @@ import { category } from "./category";
|
|
|
3
3
|
import { gqlPermissionManager, permissionManager } from "./common/permission";
|
|
4
4
|
|
|
5
5
|
export const product = db
|
|
6
|
-
.
|
|
6
|
+
.table("Product", {
|
|
7
7
|
name: db.string().description("Name of the product"),
|
|
8
8
|
description: db.string({ optional: true }).description("Description of the product"),
|
|
9
9
|
categoryId: db
|
|
@@ -2,7 +2,7 @@ import { db } from "@tailor-platform/sdk";
|
|
|
2
2
|
import { gqlPermissionManager, permissionManager } from "./common/permission";
|
|
3
3
|
|
|
4
4
|
export const user = db
|
|
5
|
-
.
|
|
5
|
+
.table("User", {
|
|
6
6
|
name: db.string().description("Name of the user"),
|
|
7
7
|
email: db.string().unique().description("Email address of the user"),
|
|
8
8
|
role: db.enum(["MANAGER", "STAFF"]),
|
|
@@ -5,7 +5,9 @@ import { type DB, getDB } from "../generated/kysely-tailordb";
|
|
|
5
5
|
|
|
6
6
|
const input = {
|
|
7
7
|
order: t.object(order.omitFields(["id", "createdAt", "updatedAt"])),
|
|
8
|
-
items: t.object(orderItem.omitFields(["id", "createdAt", "updatedAt"]), {
|
|
8
|
+
items: t.object(orderItem.omitFields(["id", "createdAt", "updatedAt", "totalPrice"]), {
|
|
9
|
+
array: true,
|
|
10
|
+
}),
|
|
9
11
|
};
|
|
10
12
|
interface Input {
|
|
11
13
|
order: t.infer<typeof input.order>;
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"typecheck": "tsc --noEmit"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@tailor-platform/sdk": "2.0.0-next.
|
|
18
|
-
"@types/node": "24.13.
|
|
19
|
-
"oxfmt": "0.
|
|
20
|
-
"oxlint": "1.
|
|
17
|
+
"@tailor-platform/sdk": "2.0.0-next.5",
|
|
18
|
+
"@types/node": "24.13.3",
|
|
19
|
+
"oxfmt": "0.58.0",
|
|
20
|
+
"oxlint": "1.73.0",
|
|
21
21
|
"oxlint-tsgolint": "0.24.0",
|
|
22
22
|
"typescript": "6.0.3"
|
|
23
23
|
}
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"typecheck": "tsc --noEmit"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@tailor-platform/sdk": "2.0.0-next.
|
|
19
|
-
"@types/node": "24.13.
|
|
20
|
-
"oxfmt": "0.
|
|
21
|
-
"oxlint": "1.
|
|
18
|
+
"@tailor-platform/sdk": "2.0.0-next.5",
|
|
19
|
+
"@types/node": "24.13.3",
|
|
20
|
+
"oxfmt": "0.58.0",
|
|
21
|
+
"oxlint": "1.73.0",
|
|
22
22
|
"oxlint-tsgolint": "0.24.0",
|
|
23
23
|
"typescript": "6.0.3",
|
|
24
|
-
"vitest": "4.1.
|
|
24
|
+
"vitest": "4.1.10"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"typecheck": "tsc --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@tailor-platform/sdk": "2.0.0-next.
|
|
17
|
-
"@types/node": "24.13.
|
|
18
|
-
"oxfmt": "0.
|
|
19
|
-
"oxlint": "1.
|
|
16
|
+
"@tailor-platform/sdk": "2.0.0-next.5",
|
|
17
|
+
"@types/node": "24.13.3",
|
|
18
|
+
"oxfmt": "0.58.0",
|
|
19
|
+
"oxlint": "1.73.0",
|
|
20
20
|
"oxlint-tsgolint": "0.24.0",
|
|
21
21
|
"typescript": "6.0.3"
|
|
22
22
|
}
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"typecheck": "tsc --noEmit"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@tailor-platform/sdk": "2.0.0-next.
|
|
19
|
-
"@types/node": "24.13.
|
|
20
|
-
"oxfmt": "0.
|
|
21
|
-
"oxlint": "1.
|
|
18
|
+
"@tailor-platform/sdk": "2.0.0-next.5",
|
|
19
|
+
"@types/node": "24.13.3",
|
|
20
|
+
"oxfmt": "0.58.0",
|
|
21
|
+
"oxlint": "1.73.0",
|
|
22
22
|
"oxlint-tsgolint": "0.24.0",
|
|
23
23
|
"typescript": "6.0.3",
|
|
24
|
-
"vitest": "4.1.
|
|
24
|
+
"vitest": "4.1.10"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -2,7 +2,7 @@ import { db } from "@tailor-platform/sdk";
|
|
|
2
2
|
import { allPermission, allGqlPermission } from "./permission";
|
|
3
3
|
|
|
4
4
|
export const category = db
|
|
5
|
-
.
|
|
5
|
+
.table("Category", "Task category with hierarchical structure", {
|
|
6
6
|
name: db.string(),
|
|
7
7
|
description: db.string({ optional: true }),
|
|
8
8
|
parentCategoryId: db.uuid({ optional: true }).relation({
|
|
@@ -4,8 +4,10 @@ import { task } from "./task";
|
|
|
4
4
|
import { user } from "./user";
|
|
5
5
|
|
|
6
6
|
export const comment = db
|
|
7
|
-
.
|
|
8
|
-
body: db
|
|
7
|
+
.table("Comment", "A comment on a task", {
|
|
8
|
+
body: db
|
|
9
|
+
.string()
|
|
10
|
+
.validate(({ value }) => (value.length < 1 ? "Comment must not be empty" : undefined)),
|
|
9
11
|
taskId: db.uuid().relation({
|
|
10
12
|
type: "n-1",
|
|
11
13
|
toward: { type: task },
|
|
@@ -4,13 +4,11 @@ import { rolePermission, roleGqlPermission } from "./permission";
|
|
|
4
4
|
import { user } from "./user";
|
|
5
5
|
|
|
6
6
|
export const task = db
|
|
7
|
-
.
|
|
8
|
-
title: db
|
|
9
|
-
|
|
10
|
-
.
|
|
11
|
-
|
|
12
|
-
[({ value }) => value.length <= 200, "Title must be at most 200 characters"],
|
|
13
|
-
),
|
|
7
|
+
.table("Task", "A task with comprehensive features", {
|
|
8
|
+
title: db.string().validate(
|
|
9
|
+
({ value }) => (value.length >= 3 ? undefined : "Title must be at least 3 characters"),
|
|
10
|
+
({ value }) => (value.length <= 200 ? undefined : "Title must be at most 200 characters"),
|
|
11
|
+
),
|
|
14
12
|
description: db.string({ optional: true }),
|
|
15
13
|
status: db.enum([
|
|
16
14
|
{ value: "TODO", description: "Not started" },
|
|
@@ -18,12 +16,10 @@ export const task = db
|
|
|
18
16
|
{ value: "DONE", description: "Completed" },
|
|
19
17
|
{ value: "CANCELLED", description: "No longer needed" },
|
|
20
18
|
]),
|
|
21
|
-
priority: db
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
[({ value }) => value <= 4, "Priority must be at most 4"],
|
|
26
|
-
),
|
|
19
|
+
priority: db.int().validate(
|
|
20
|
+
({ value }) => (value >= 0 ? undefined : "Priority must be non-negative"),
|
|
21
|
+
({ value }) => (value <= 4 ? undefined : "Priority must be at most 4"),
|
|
22
|
+
),
|
|
27
23
|
dueDate: db.datetime({ optional: true }),
|
|
28
24
|
assigneeId: db.uuid({ optional: true }).relation({
|
|
29
25
|
type: "n-1",
|
|
@@ -33,26 +29,22 @@ export const task = db
|
|
|
33
29
|
type: "n-1",
|
|
34
30
|
toward: { type: category },
|
|
35
31
|
}),
|
|
36
|
-
isArchived: db
|
|
32
|
+
isArchived: db
|
|
33
|
+
.bool()
|
|
34
|
+
.description("Whether the task is archived")
|
|
35
|
+
.hooks({
|
|
36
|
+
create: () => false,
|
|
37
|
+
}),
|
|
37
38
|
...db.fields.timestamps(),
|
|
38
39
|
})
|
|
39
|
-
.hooks({
|
|
40
|
-
isArchived: {
|
|
41
|
-
create: () => false,
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
40
|
.indexes(
|
|
45
41
|
{ fields: ["status", "priority"], unique: false },
|
|
46
42
|
{ fields: ["assigneeId", "status"], unique: false, name: "task_assignee_status_idx" },
|
|
47
43
|
)
|
|
48
|
-
.validate({
|
|
49
|
-
status
|
|
50
|
-
(
|
|
51
|
-
|
|
52
|
-
return !(value === "DONE" && d.dueDate === null);
|
|
53
|
-
},
|
|
54
|
-
"Completed tasks must have a due date",
|
|
55
|
-
],
|
|
44
|
+
.validate(({ newRecord }, issues) => {
|
|
45
|
+
if (newRecord.status === "DONE" && !newRecord.dueDate) {
|
|
46
|
+
issues("status", "Completed tasks must have a due date");
|
|
47
|
+
}
|
|
56
48
|
})
|
|
57
49
|
.permission(rolePermission)
|
|
58
50
|
.gqlPermission(roleGqlPermission);
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"typecheck": "tsc --noEmit"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@tailor-platform/sdk": "2.0.0-next.
|
|
20
|
-
"@types/node": "24.13.
|
|
21
|
-
"graphql": "17.0.
|
|
19
|
+
"@tailor-platform/sdk": "2.0.0-next.5",
|
|
20
|
+
"@types/node": "24.13.3",
|
|
21
|
+
"graphql": "17.0.2",
|
|
22
22
|
"graphql-request": "7.4.0",
|
|
23
|
-
"oxfmt": "0.
|
|
24
|
-
"oxlint": "1.
|
|
23
|
+
"oxfmt": "0.58.0",
|
|
24
|
+
"oxlint": "1.73.0",
|
|
25
25
|
"oxlint-tsgolint": "0.24.0",
|
|
26
26
|
"typescript": "6.0.3",
|
|
27
|
-
"vitest": "4.1.
|
|
27
|
+
"vitest": "4.1.10"
|
|
28
28
|
}
|
|
29
29
|
}
|