@tailor-platform/create-sdk 2.0.0-next.1 → 2.0.0-next.11
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 +211 -0
- package/package.json +10 -9
- package/templates/executor/.oxlintrc.json +10 -1
- package/templates/executor/__dot__gitignore +1 -1
- package/templates/executor/package.json +11 -9
- 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/executor/src/generated/db.ts +3 -3
- package/templates/executor/tailor.d.ts +4 -2
- package/templates/generators/.oxlintrc.json +10 -1
- package/templates/generators/README.md +1 -1
- package/templates/generators/__dot__gitignore +1 -1
- package/templates/generators/package.json +14 -9
- 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/db.ts +3 -3
- package/templates/generators/src/generated/files.ts +5 -5
- package/templates/generators/src/resolver/getProduct.test.ts +31 -27
- 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/generators/tailor.d.ts +4 -2
- package/templates/hello-world/.oxlintrc.json +10 -1
- package/templates/hello-world/README.md +6 -6
- package/templates/hello-world/__dot__gitignore +1 -1
- package/templates/hello-world/package.json +10 -8
- package/templates/hello-world/src/db/user.ts +1 -1
- package/templates/hello-world/src/generated/kysely-tailordb.ts +1 -1
- package/templates/hello-world/tailor.d.ts +4 -2
- package/templates/inventory-management/.oxlintrc.json +10 -1
- package/templates/inventory-management/README.md +8 -8
- package/templates/inventory-management/__dot__gitignore +1 -1
- package/templates/inventory-management/package.json +10 -8
- 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/executor/checkInventory.ts +0 -1
- package/templates/inventory-management/src/generated/kysely-tailordb.ts +9 -9
- package/templates/inventory-management/src/resolver/registerOrder.ts +4 -2
- package/templates/inventory-management/tailor.d.ts +4 -2
- package/templates/multi-application/.oxlintrc.json +10 -1
- package/templates/multi-application/README.md +2 -2
- package/templates/multi-application/__dot__gitignore +1 -1
- package/templates/multi-application/apps/admin/db/adminNote.ts +2 -2
- package/templates/multi-application/apps/admin/tailor.config.ts +1 -1
- package/templates/multi-application/apps/user/db/user.ts +1 -1
- package/templates/multi-application/apps/user/tailor.config.ts +1 -1
- package/templates/multi-application/package.json +10 -8
- package/templates/resolver/.oxlintrc.json +10 -1
- package/templates/resolver/README.md +2 -2
- package/templates/resolver/__dot__gitignore +1 -1
- package/templates/resolver/package.json +11 -9
- package/templates/resolver/src/db/user.ts +1 -1
- package/templates/resolver/src/generated/db.ts +1 -1
- package/templates/resolver/src/resolver/add.test.ts +4 -3
- package/templates/resolver/src/resolver/incrementUserAge.test.ts +6 -5
- package/templates/resolver/src/resolver/showEnv.test.ts +2 -2
- package/templates/resolver/src/resolver/showUserInfo.test.ts +12 -9
- package/templates/resolver/src/resolver/showUserInfo.ts +3 -3
- package/templates/resolver/src/resolver/upsertUsers.test.ts +2 -2
- package/templates/resolver/tailor.d.ts +6 -4
- package/templates/static-web-site/.oxlintrc.json +10 -1
- package/templates/static-web-site/__dot__gitignore +1 -1
- package/templates/static-web-site/package.json +10 -8
- package/templates/static-web-site/src/db/user.ts +1 -1
- package/templates/static-web-site/tailor.d.ts +4 -2
- package/templates/tailordb/.oxlintrc.json +10 -1
- package/templates/tailordb/README.md +1 -1
- package/templates/tailordb/__dot__gitignore +1 -1
- package/templates/tailordb/package.json +11 -9
- 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/tailordb/src/generated/db.ts +3 -3
- package/templates/tailordb/tailor.d.ts +4 -2
- package/templates/workflow/.oxlintrc.json +10 -1
- package/templates/workflow/README.md +2 -2
- package/templates/workflow/__dot__gitignore +1 -1
- package/templates/workflow/e2e/globalSetup.ts +1 -1
- package/templates/workflow/e2e/workflow.test.ts +1 -1
- package/templates/workflow/package.json +12 -10
- package/templates/workflow/src/db/order.ts +1 -1
- package/templates/workflow/src/db/user.ts +1 -1
- package/templates/workflow/src/generated/db.ts +2 -2
- package/templates/workflow/src/resolver/resolveApproval.test.ts +18 -13
- package/templates/workflow/src/workflow/approval.test.ts +16 -11
- package/templates/workflow/src/workflow/approval.ts +2 -2
- package/templates/workflow/src/workflow/order-fulfillment.test.ts +30 -18
- package/templates/workflow/src/workflow/order-fulfillment.ts +3 -3
- package/templates/workflow/tailor.d.ts +4 -2
- package/templates/generators/src/seed/exec.mjs +0 -485
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
} from "@tailor-platform/sdk";
|
|
6
6
|
|
|
7
7
|
export const adminNote = db
|
|
8
|
-
.
|
|
8
|
+
.table("AdminNote", {
|
|
9
9
|
title: db.string(),
|
|
10
10
|
content: db.string(),
|
|
11
|
-
authorId: db.uuid().hooks({ create: ({
|
|
11
|
+
authorId: db.uuid().hooks({ create: ({ invoker }) => invoker?.id ?? crypto.randomUUID() }),
|
|
12
12
|
...db.fields.timestamps(),
|
|
13
13
|
})
|
|
14
14
|
// NOTE: This permits all operations for simplicity.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "multi-application",
|
|
3
|
+
"version": "0.0.0",
|
|
3
4
|
"private": true,
|
|
4
5
|
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"deploy": "pnpm run deploy:user && pnpm run deploy:admin",
|
|
7
|
-
"deploy:user": "tailor
|
|
8
|
-
"deploy:admin": "tailor
|
|
8
|
+
"deploy:user": "tailor deploy -c apps/user/tailor.config.ts",
|
|
9
|
+
"deploy:admin": "tailor deploy -c apps/admin/tailor.config.ts",
|
|
9
10
|
"format": "oxfmt --write .",
|
|
10
11
|
"format:check": "oxfmt --check .",
|
|
11
12
|
"lint": "oxlint --type-aware .",
|
|
@@ -13,11 +14,12 @@
|
|
|
13
14
|
"typecheck": "tsc --noEmit"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
|
-
"@tailor-platform/sdk": "2.0
|
|
17
|
-
"@
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"oxlint
|
|
21
|
-
"
|
|
17
|
+
"@tailor-platform/eslint-plugin-sdk": "0.2.0-next.1",
|
|
18
|
+
"@tailor-platform/sdk": "2.0.0-next.11",
|
|
19
|
+
"@types/node": "24.13.3",
|
|
20
|
+
"oxfmt": "0.61.0",
|
|
21
|
+
"oxlint": "1.76.0",
|
|
22
|
+
"oxlint-tsgolint": "7.0.2001",
|
|
23
|
+
"typescript": "6.0.3"
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
3
3
|
"plugins": ["typescript"],
|
|
4
|
+
"jsPlugins": [
|
|
5
|
+
{
|
|
6
|
+
"name": "tailor-sdk",
|
|
7
|
+
"specifier": "@tailor-platform/eslint-plugin-sdk"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
4
10
|
"categories": {
|
|
5
11
|
"correctness": "error"
|
|
6
12
|
},
|
|
7
13
|
"env": {
|
|
8
14
|
"builtin": true
|
|
9
15
|
},
|
|
10
|
-
"ignorePatterns": [".tailor
|
|
16
|
+
"ignorePatterns": [".tailor/", "src/generated/", "tailor.d.ts"],
|
|
11
17
|
"rules": {
|
|
18
|
+
"tailor-sdk/no-api-prefix-in-path-pattern": "warn",
|
|
19
|
+
"tailor-sdk/no-execute-script-arg-stringify": "warn",
|
|
20
|
+
"tailor-sdk/no-unconditional-permit": "warn",
|
|
12
21
|
"no-case-declarations": "error",
|
|
13
22
|
"no-empty": "error",
|
|
14
23
|
"no-fallthrough": "error",
|
|
@@ -8,11 +8,11 @@ Demonstrates all resolver patterns with comprehensive testing approaches.
|
|
|
8
8
|
- Database query resolver (Kysely with transactions)
|
|
9
9
|
- Database mutation resolver (dependency injection pattern)
|
|
10
10
|
- Environment variable access
|
|
11
|
-
-
|
|
11
|
+
- Caller and invoker context access
|
|
12
12
|
|
|
13
13
|
## Testing Approaches
|
|
14
14
|
|
|
15
|
-
1. **Direct `body()` call** - Simple resolvers with `
|
|
15
|
+
1. **Direct `body()` call** - Simple resolvers with explicit `caller` / `invoker` context values
|
|
16
16
|
2. **`tailor-runtime` environment + `mockTailordb`** - Database resolvers via `mockTailordb` from `@tailor-platform/sdk/vitest` (no `vi.stubGlobal` needed)
|
|
17
17
|
3. **Dependency injection** - Extract `DbOperations` interface for testability
|
|
18
18
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
node_modules/
|
|
2
|
-
.tailor
|
|
2
|
+
.tailor/
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resolver",
|
|
3
|
+
"version": "0.0.0",
|
|
3
4
|
"private": true,
|
|
4
5
|
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
|
-
"generate": "tailor
|
|
7
|
-
"deploy": "tailor
|
|
7
|
+
"generate": "tailor generate",
|
|
8
|
+
"deploy": "tailor deploy",
|
|
8
9
|
"test": "vitest --project unit",
|
|
9
10
|
"test:unit": "vitest --project unit",
|
|
10
11
|
"format": "oxfmt --write .",
|
|
@@ -14,12 +15,13 @@
|
|
|
14
15
|
"typecheck": "tsc --noEmit"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
|
-
"@tailor-platform/sdk": "2.0
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"oxlint
|
|
22
|
-
"
|
|
23
|
-
"
|
|
18
|
+
"@tailor-platform/eslint-plugin-sdk": "0.2.0-next.1",
|
|
19
|
+
"@tailor-platform/sdk": "2.0.0-next.11",
|
|
20
|
+
"@types/node": "24.13.3",
|
|
21
|
+
"oxfmt": "0.61.0",
|
|
22
|
+
"oxlint": "1.76.0",
|
|
23
|
+
"oxlint-tsgolint": "7.0.2001",
|
|
24
|
+
"typescript": "6.0.3",
|
|
25
|
+
"vitest": "4.1.10"
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { unauthenticatedTailorUser } from "@tailor-platform/sdk/test";
|
|
2
1
|
import { describe, expect, test } from "vitest";
|
|
3
2
|
import resolver from "./add";
|
|
4
3
|
|
|
@@ -6,7 +5,8 @@ describe("add resolver", () => {
|
|
|
6
5
|
test("adds two positive numbers", async () => {
|
|
7
6
|
const result = await resolver.body({
|
|
8
7
|
input: { left: 1, right: 2 },
|
|
9
|
-
|
|
8
|
+
caller: null,
|
|
9
|
+
invoker: null,
|
|
10
10
|
env: { appName: "Resolver Template", version: 1 },
|
|
11
11
|
});
|
|
12
12
|
expect(result).toBe(3);
|
|
@@ -15,7 +15,8 @@ describe("add resolver", () => {
|
|
|
15
15
|
test("handles negative numbers", async () => {
|
|
16
16
|
const result = await resolver.body({
|
|
17
17
|
input: { left: -5, right: 3 },
|
|
18
|
-
|
|
18
|
+
caller: null,
|
|
19
|
+
invoker: null,
|
|
19
20
|
env: { appName: "Resolver Template", version: 1 },
|
|
20
21
|
});
|
|
21
22
|
expect(result).toBe(-2);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { unauthenticatedTailorUser } from "@tailor-platform/sdk/test";
|
|
2
1
|
import { mockTailordb } from "@tailor-platform/sdk/vitest";
|
|
3
2
|
import { describe, expect, test } from "vitest";
|
|
4
3
|
import resolver from "./incrementUserAge";
|
|
@@ -6,7 +5,7 @@ import resolver from "./incrementUserAge";
|
|
|
6
5
|
describe("incrementUserAge resolver", () => {
|
|
7
6
|
test("increments user age", async () => {
|
|
8
7
|
using db = mockTailordb();
|
|
9
|
-
db.
|
|
8
|
+
db.enqueueRows(
|
|
10
9
|
[], // BEGIN
|
|
11
10
|
[{ age: 30 }], // SELECT
|
|
12
11
|
[], // UPDATE
|
|
@@ -15,7 +14,8 @@ describe("incrementUserAge resolver", () => {
|
|
|
15
14
|
|
|
16
15
|
const result = await resolver.body({
|
|
17
16
|
input: { email: "test@example.com" },
|
|
18
|
-
|
|
17
|
+
caller: null,
|
|
18
|
+
invoker: null,
|
|
19
19
|
env: { appName: "Resolver Template", version: 1 },
|
|
20
20
|
});
|
|
21
21
|
expect(result).toEqual({ oldAge: 30, newAge: 31 });
|
|
@@ -24,7 +24,7 @@ describe("incrementUserAge resolver", () => {
|
|
|
24
24
|
|
|
25
25
|
test("throws when user not found", async () => {
|
|
26
26
|
using db = mockTailordb();
|
|
27
|
-
db.
|
|
27
|
+
db.enqueueRows(
|
|
28
28
|
[], // BEGIN
|
|
29
29
|
[], // SELECT (empty)
|
|
30
30
|
[], // ROLLBACK
|
|
@@ -32,7 +32,8 @@ describe("incrementUserAge resolver", () => {
|
|
|
32
32
|
|
|
33
33
|
const result = resolver.body({
|
|
34
34
|
input: { email: "test@example.com" },
|
|
35
|
-
|
|
35
|
+
caller: null,
|
|
36
|
+
invoker: null,
|
|
36
37
|
env: { appName: "Resolver Template", version: 1 },
|
|
37
38
|
});
|
|
38
39
|
await expect(result).rejects.toThrowError(/no result/i);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { unauthenticatedTailorUser } from "@tailor-platform/sdk/test";
|
|
2
1
|
import { describe, expect, test } from "vitest";
|
|
3
2
|
import resolver from "./showEnv";
|
|
4
3
|
|
|
@@ -6,7 +5,8 @@ describe("showEnv resolver", () => {
|
|
|
6
5
|
test("returns environment variables", async () => {
|
|
7
6
|
const result = await resolver.body({
|
|
8
7
|
input: undefined as never,
|
|
9
|
-
|
|
8
|
+
caller: null,
|
|
9
|
+
invoker: null,
|
|
10
10
|
env: { appName: "Resolver Template", version: 1 },
|
|
11
11
|
});
|
|
12
12
|
expect(result).toEqual({ appName: "Resolver Template", version: 1 });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TailorPrincipal } from "@tailor-platform/sdk";
|
|
2
2
|
import { describe, expect, test } from "vitest";
|
|
3
3
|
import resolver from "./showUserInfo";
|
|
4
4
|
|
|
@@ -6,26 +6,29 @@ describe("showUserInfo resolver", () => {
|
|
|
6
6
|
test("returns default user info", async () => {
|
|
7
7
|
const result = await resolver.body({
|
|
8
8
|
input: undefined as never,
|
|
9
|
-
|
|
9
|
+
caller: null,
|
|
10
|
+
invoker: null,
|
|
10
11
|
env: { appName: "Resolver Template", version: 1 },
|
|
11
12
|
});
|
|
12
13
|
expect(result).toEqual({
|
|
13
|
-
userId:
|
|
14
|
-
userType:
|
|
15
|
-
workspaceId:
|
|
14
|
+
userId: "anonymous",
|
|
15
|
+
userType: "anonymous",
|
|
16
|
+
workspaceId: "",
|
|
16
17
|
});
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
test("returns custom user info", async () => {
|
|
20
|
-
const
|
|
21
|
-
...unauthenticatedTailorUser,
|
|
21
|
+
const customCaller = {
|
|
22
22
|
id: "user-123",
|
|
23
23
|
type: "machine_user" as const,
|
|
24
24
|
workspaceId: "ws-456",
|
|
25
|
-
|
|
25
|
+
attributes: { role: "admin" },
|
|
26
|
+
attributeList: [],
|
|
27
|
+
} satisfies TailorPrincipal;
|
|
26
28
|
const result = await resolver.body({
|
|
27
29
|
input: undefined as never,
|
|
28
|
-
|
|
30
|
+
caller: customCaller,
|
|
31
|
+
invoker: customCaller,
|
|
29
32
|
env: { appName: "Resolver Template", version: 1 },
|
|
30
33
|
});
|
|
31
34
|
expect(result).toEqual({
|
|
@@ -6,9 +6,9 @@ const resolver = createResolver({
|
|
|
6
6
|
operation: "query",
|
|
7
7
|
body: (context) => {
|
|
8
8
|
return {
|
|
9
|
-
userId: context.
|
|
10
|
-
userType: context.
|
|
11
|
-
workspaceId: context.
|
|
9
|
+
userId: context.caller?.id ?? "anonymous",
|
|
10
|
+
userType: context.caller?.type ?? "anonymous",
|
|
11
|
+
workspaceId: context.caller?.workspaceId ?? "",
|
|
12
12
|
};
|
|
13
13
|
},
|
|
14
14
|
output: t.object({
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { unauthenticatedTailorUser } from "@tailor-platform/sdk/test";
|
|
2
1
|
import { createKyselyMock } from "@tailor-platform/sdk/vitest";
|
|
3
2
|
import { describe, expect, test, vi } from "vitest";
|
|
4
3
|
import { getDB, type Namespace } from "../generated/db";
|
|
@@ -30,7 +29,8 @@ describe("upsertUsers resolver", () => {
|
|
|
30
29
|
{ name: "Existing", email: "exists@example.com", age: 41 },
|
|
31
30
|
],
|
|
32
31
|
},
|
|
33
|
-
|
|
32
|
+
caller: null,
|
|
33
|
+
invoker: null,
|
|
34
34
|
env: { appName: "Resolver Template", version: 1 },
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
// This file is auto-generated by @tailor-platform/sdk
|
|
2
2
|
// Do not edit this file manually
|
|
3
|
-
// Regenerated automatically when running 'tailor
|
|
3
|
+
// Regenerated automatically when running 'tailor deploy' or 'tailor generate'
|
|
4
4
|
|
|
5
5
|
declare module "@tailor-platform/sdk" {
|
|
6
|
-
interface
|
|
6
|
+
interface Attributes {
|
|
7
7
|
role: string;
|
|
8
8
|
}
|
|
9
9
|
interface AttributeList {
|
|
10
10
|
__tuple?: [];
|
|
11
11
|
}
|
|
12
12
|
interface Env {
|
|
13
|
-
appName:
|
|
14
|
-
version:
|
|
13
|
+
appName: string;
|
|
14
|
+
version: number;
|
|
15
15
|
}
|
|
16
16
|
interface MachineUserNameRegistry {
|
|
17
17
|
admin: true;
|
|
18
18
|
}
|
|
19
19
|
interface IdpNameRegistry {}
|
|
20
|
+
interface ConnectionNameRegistry {}
|
|
21
|
+
interface AIGatewayNameRegistry {}
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export {};
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
3
3
|
"plugins": ["typescript"],
|
|
4
|
+
"jsPlugins": [
|
|
5
|
+
{
|
|
6
|
+
"name": "tailor-sdk",
|
|
7
|
+
"specifier": "@tailor-platform/eslint-plugin-sdk"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
4
10
|
"categories": {
|
|
5
11
|
"correctness": "error"
|
|
6
12
|
},
|
|
7
13
|
"env": {
|
|
8
14
|
"builtin": true
|
|
9
15
|
},
|
|
10
|
-
"ignorePatterns": [".tailor
|
|
16
|
+
"ignorePatterns": [".tailor/", "src/generated/", "tailor.d.ts"],
|
|
11
17
|
"rules": {
|
|
18
|
+
"tailor-sdk/no-api-prefix-in-path-pattern": "warn",
|
|
19
|
+
"tailor-sdk/no-execute-script-arg-stringify": "warn",
|
|
20
|
+
"tailor-sdk/no-unconditional-permit": "warn",
|
|
12
21
|
"no-case-declarations": "error",
|
|
13
22
|
"no-empty": "error",
|
|
14
23
|
"no-fallthrough": "error",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
node_modules/
|
|
2
|
-
.tailor
|
|
2
|
+
.tailor/
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "static-web-site",
|
|
3
|
+
"version": "0.0.0",
|
|
3
4
|
"private": true,
|
|
4
5
|
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
|
-
"deploy": "tailor
|
|
7
|
-
"generate": "tailor
|
|
7
|
+
"deploy": "tailor deploy",
|
|
8
|
+
"generate": "tailor generate",
|
|
8
9
|
"format": "oxfmt --write .",
|
|
9
10
|
"format:check": "oxfmt --check .",
|
|
10
11
|
"lint": "oxlint --type-aware .",
|
|
@@ -12,11 +13,12 @@
|
|
|
12
13
|
"typecheck": "tsc --noEmit"
|
|
13
14
|
},
|
|
14
15
|
"devDependencies": {
|
|
15
|
-
"@tailor-platform/sdk": "2.0
|
|
16
|
-
"@
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"oxlint
|
|
20
|
-
"
|
|
16
|
+
"@tailor-platform/eslint-plugin-sdk": "0.2.0-next.1",
|
|
17
|
+
"@tailor-platform/sdk": "2.0.0-next.11",
|
|
18
|
+
"@types/node": "24.13.3",
|
|
19
|
+
"oxfmt": "0.61.0",
|
|
20
|
+
"oxlint": "1.76.0",
|
|
21
|
+
"oxlint-tsgolint": "7.0.2001",
|
|
22
|
+
"typescript": "6.0.3"
|
|
21
23
|
}
|
|
22
24
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// This file is auto-generated by @tailor-platform/sdk
|
|
2
2
|
// Do not edit this file manually
|
|
3
|
-
// Regenerated automatically when running 'tailor
|
|
3
|
+
// Regenerated automatically when running 'tailor deploy' or 'tailor generate'
|
|
4
4
|
|
|
5
5
|
declare module "@tailor-platform/sdk" {
|
|
6
|
-
interface
|
|
6
|
+
interface Attributes {
|
|
7
7
|
role: "ADMIN" | "MEMBER";
|
|
8
8
|
}
|
|
9
9
|
interface AttributeList {
|
|
@@ -16,6 +16,8 @@ declare module "@tailor-platform/sdk" {
|
|
|
16
16
|
interface IdpNameRegistry {
|
|
17
17
|
"my-idp": true;
|
|
18
18
|
}
|
|
19
|
+
interface ConnectionNameRegistry {}
|
|
20
|
+
interface AIGatewayNameRegistry {}
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export {};
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
3
3
|
"plugins": ["typescript"],
|
|
4
|
+
"jsPlugins": [
|
|
5
|
+
{
|
|
6
|
+
"name": "tailor-sdk",
|
|
7
|
+
"specifier": "@tailor-platform/eslint-plugin-sdk"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
4
10
|
"categories": {
|
|
5
11
|
"correctness": "error"
|
|
6
12
|
},
|
|
7
13
|
"env": {
|
|
8
14
|
"builtin": true
|
|
9
15
|
},
|
|
10
|
-
"ignorePatterns": [".tailor
|
|
16
|
+
"ignorePatterns": [".tailor/", "src/generated/", "tailor.d.ts"],
|
|
11
17
|
"rules": {
|
|
18
|
+
"tailor-sdk/no-api-prefix-in-path-pattern": "warn",
|
|
19
|
+
"tailor-sdk/no-execute-script-arg-stringify": "warn",
|
|
20
|
+
"tailor-sdk/no-unconditional-permit": "warn",
|
|
12
21
|
"no-case-declarations": "error",
|
|
13
22
|
"no-empty": "error",
|
|
14
23
|
"no-fallthrough": "error",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
node_modules/
|
|
2
|
-
.tailor
|
|
2
|
+
.tailor/
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailordb",
|
|
3
|
+
"version": "0.0.0",
|
|
3
4
|
"private": true,
|
|
4
5
|
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
|
-
"generate": "tailor
|
|
7
|
-
"deploy": "tailor
|
|
7
|
+
"generate": "tailor generate",
|
|
8
|
+
"deploy": "tailor deploy",
|
|
8
9
|
"test": "vitest --project unit",
|
|
9
10
|
"test:unit": "vitest --project unit",
|
|
10
11
|
"format": "oxfmt --write .",
|
|
@@ -14,12 +15,13 @@
|
|
|
14
15
|
"typecheck": "tsc --noEmit"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
|
-
"@tailor-platform/sdk": "2.0
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"oxlint
|
|
22
|
-
"
|
|
23
|
-
"
|
|
18
|
+
"@tailor-platform/eslint-plugin-sdk": "0.2.0-next.1",
|
|
19
|
+
"@tailor-platform/sdk": "2.0.0-next.11",
|
|
20
|
+
"@types/node": "24.13.3",
|
|
21
|
+
"oxfmt": "0.61.0",
|
|
22
|
+
"oxlint": "1.76.0",
|
|
23
|
+
"oxlint-tsgolint": "7.0.2001",
|
|
24
|
+
"typescript": "6.0.3",
|
|
25
|
+
"vitest": "4.1.10"
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -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);
|