@tailor-platform/create-sdk 1.2.0 → 1.2.2
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 +9 -0
- package/package.json +5 -3
- package/templates/hello-world/.oxfmtrc.json +3 -0
- package/templates/hello-world/.oxlintrc.json +197 -0
- package/templates/hello-world/eslint.config.js +2 -0
- package/templates/hello-world/package.json +9 -6
- package/templates/inventory-management/.oxfmtrc.json +3 -0
- package/templates/inventory-management/.oxlintrc.json +203 -0
- package/templates/inventory-management/eslint.config.js +2 -0
- package/templates/inventory-management/package.json +9 -6
- package/templates/inventory-management/src/db/category.ts +1 -3
- package/templates/inventory-management/src/db/common/permission.ts +1 -5
- package/templates/inventory-management/src/db/contact.ts +2 -6
- package/templates/inventory-management/src/db/order.ts +1 -3
- package/templates/inventory-management/src/db/orderItem.ts +1 -3
- package/templates/inventory-management/src/db/product.ts +1 -3
- package/templates/inventory-management/src/executor/checkInventory.ts +1 -2
- package/templates/inventory-management/src/resolver/registerOrder.ts +2 -8
- package/templates/inventory-management/tailor.config.ts +1 -5
- package/templates/multi-application/.oxfmtrc.json +3 -0
- package/templates/multi-application/.oxlintrc.json +197 -0
- package/templates/multi-application/eslint.config.js +2 -0
- package/templates/multi-application/package.json +9 -6
- package/templates/testing/.oxfmtrc.json +3 -0
- package/templates/testing/.oxlintrc.json +197 -0
- package/templates/testing/e2e/workflow.test.ts +32 -40
- package/templates/testing/eslint.config.js +2 -0
- package/templates/testing/package.json +9 -6
- package/templates/testing/src/resolver/mockTailordb.test.ts +1 -9
- package/templates/testing/src/resolver/wrapTailordb.test.ts +5 -15
- package/templates/testing/src/resolver/wrapTailordb.ts +3 -11
- package/templates/testing/src/workflow/wrapTailordb.test.ts +6 -13
- package/templates/testing/src/workflow/wrapTailordb.ts +2 -9
- package/templates/testing/tailor.config.ts +1 -5
- package/templates/hello-world/.prettierignore +0 -1
- package/templates/inventory-management/.prettierignore +0 -2
- package/templates/multi-application/.prettierignore +0 -1
- package/templates/testing/.prettierignore +0 -2
|
@@ -6,12 +6,9 @@ describe("decrementUserAge resolver", () => {
|
|
|
6
6
|
// Mock database operations
|
|
7
7
|
const dbOperations = {
|
|
8
8
|
transaction: vi.fn(
|
|
9
|
-
async (fn: (ops: DbOperations) => Promise<unknown>) =>
|
|
10
|
-
await fn(dbOperations),
|
|
9
|
+
async (fn: (ops: DbOperations) => Promise<unknown>) => await fn(dbOperations),
|
|
11
10
|
),
|
|
12
|
-
getUser: vi
|
|
13
|
-
.fn()
|
|
14
|
-
.mockResolvedValue({ email: "test@example.com", age: 30 }),
|
|
11
|
+
getUser: vi.fn().mockResolvedValue({ email: "test@example.com", age: 30 }),
|
|
15
12
|
updateUser: vi.fn(),
|
|
16
13
|
} as DbOperations;
|
|
17
14
|
|
|
@@ -19,10 +16,7 @@ describe("decrementUserAge resolver", () => {
|
|
|
19
16
|
|
|
20
17
|
expect(result).toEqual({ oldAge: 30, newAge: 29 });
|
|
21
18
|
expect(dbOperations.transaction).toHaveBeenCalledTimes(1);
|
|
22
|
-
expect(dbOperations.getUser).toHaveBeenCalledExactlyOnceWith(
|
|
23
|
-
"test@example.com",
|
|
24
|
-
true,
|
|
25
|
-
);
|
|
19
|
+
expect(dbOperations.getUser).toHaveBeenCalledExactlyOnceWith("test@example.com", true);
|
|
26
20
|
expect(dbOperations.updateUser).toHaveBeenCalledExactlyOnceWith(
|
|
27
21
|
expect.objectContaining({
|
|
28
22
|
age: 29,
|
|
@@ -34,8 +28,7 @@ describe("decrementUserAge resolver", () => {
|
|
|
34
28
|
// Mock database operations
|
|
35
29
|
const dbOperations = {
|
|
36
30
|
transaction: vi.fn(
|
|
37
|
-
async (fn: (ops: DbOperations) => Promise<unknown>) =>
|
|
38
|
-
await fn(dbOperations),
|
|
31
|
+
async (fn: (ops: DbOperations) => Promise<unknown>) => await fn(dbOperations),
|
|
39
32
|
),
|
|
40
33
|
getUser: vi.fn().mockRejectedValue(new Error("User not found")),
|
|
41
34
|
updateUser: vi.fn(),
|
|
@@ -44,10 +37,7 @@ describe("decrementUserAge resolver", () => {
|
|
|
44
37
|
const result = decrementUserAge("test@example.com", dbOperations);
|
|
45
38
|
|
|
46
39
|
expect(dbOperations.transaction).toHaveBeenCalledTimes(1);
|
|
47
|
-
expect(dbOperations.getUser).toHaveBeenCalledExactlyOnceWith(
|
|
48
|
-
"test@example.com",
|
|
49
|
-
true,
|
|
50
|
-
);
|
|
40
|
+
expect(dbOperations.getUser).toHaveBeenCalledExactlyOnceWith("test@example.com", true);
|
|
51
41
|
await expect(result).rejects.toThrowError();
|
|
52
42
|
});
|
|
53
43
|
});
|
|
@@ -5,18 +5,13 @@ import { getDB, type DB, type Namespace } from "../generated/db";
|
|
|
5
5
|
export interface DbOperations {
|
|
6
6
|
transaction: <T>(fn: (ops: DbOperations) => Promise<T>) => Promise<T>;
|
|
7
7
|
|
|
8
|
-
getUser: (
|
|
9
|
-
email: string,
|
|
10
|
-
forUpdate: boolean,
|
|
11
|
-
) => Promise<Selectable<Namespace["main-db"]["User"]>>;
|
|
8
|
+
getUser: (email: string, forUpdate: boolean) => Promise<Selectable<Namespace["main-db"]["User"]>>;
|
|
12
9
|
updateUser: (user: Selectable<Namespace["main-db"]["User"]>) => Promise<void>;
|
|
13
10
|
}
|
|
14
11
|
|
|
15
12
|
function createDbOperations(db: DB<"main-db">): DbOperations {
|
|
16
13
|
return {
|
|
17
|
-
transaction: async <T>(
|
|
18
|
-
fn: (ops: DbOperations) => Promise<T>,
|
|
19
|
-
): Promise<T> => {
|
|
14
|
+
transaction: async <T>(fn: (ops: DbOperations) => Promise<T>): Promise<T> => {
|
|
20
15
|
return await db.transaction().execute(async (trx) => {
|
|
21
16
|
const dbOperations = createDbOperations(trx);
|
|
22
17
|
return await fn(dbOperations);
|
|
@@ -40,10 +35,7 @@ function createDbOperations(db: DB<"main-db">): DbOperations {
|
|
|
40
35
|
};
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
export async function decrementUserAge(
|
|
44
|
-
email: string,
|
|
45
|
-
dbOperations: DbOperations,
|
|
46
|
-
) {
|
|
38
|
+
export async function decrementUserAge(email: string, dbOperations: DbOperations) {
|
|
47
39
|
return await dbOperations.transaction(async (ops) => {
|
|
48
40
|
// Select user
|
|
49
41
|
const user = await ops.getUser(email, true);
|
|
@@ -26,9 +26,7 @@ describe("syncUserProfile workflow", () => {
|
|
|
26
26
|
created: true,
|
|
27
27
|
profile: { name: "New User", email: "new@example.com", age: 25 },
|
|
28
28
|
});
|
|
29
|
-
expect(dbOperations.getUser).toHaveBeenCalledExactlyOnceWith(
|
|
30
|
-
"new@example.com",
|
|
31
|
-
);
|
|
29
|
+
expect(dbOperations.getUser).toHaveBeenCalledExactlyOnceWith("new@example.com");
|
|
32
30
|
expect(dbOperations.createUser).toHaveBeenCalledExactlyOnceWith({
|
|
33
31
|
name: "New User",
|
|
34
32
|
email: "new@example.com",
|
|
@@ -61,16 +59,11 @@ describe("syncUserProfile workflow", () => {
|
|
|
61
59
|
created: false,
|
|
62
60
|
profile: { name: "Updated Name", email: "existing@example.com", age: 31 },
|
|
63
61
|
});
|
|
64
|
-
expect(dbOperations.getUser).toHaveBeenCalledExactlyOnceWith(
|
|
65
|
-
"existing@example.com",
|
|
66
|
-
);
|
|
62
|
+
expect(dbOperations.getUser).toHaveBeenCalledExactlyOnceWith("existing@example.com");
|
|
67
63
|
expect(dbOperations.createUser).not.toHaveBeenCalled();
|
|
68
|
-
expect(dbOperations.updateUser).toHaveBeenCalledExactlyOnceWith(
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
age: 31,
|
|
73
|
-
},
|
|
74
|
-
);
|
|
64
|
+
expect(dbOperations.updateUser).toHaveBeenCalledExactlyOnceWith("existing@example.com", {
|
|
65
|
+
name: "Updated Name",
|
|
66
|
+
age: 31,
|
|
67
|
+
});
|
|
75
68
|
});
|
|
76
69
|
});
|
|
@@ -18,20 +18,13 @@ export interface SyncResult {
|
|
|
18
18
|
export interface DbOperations {
|
|
19
19
|
getUser: (email: string) => Promise<User | undefined>;
|
|
20
20
|
createUser: (input: UserProfile) => Promise<User>;
|
|
21
|
-
updateUser: (
|
|
22
|
-
email: string,
|
|
23
|
-
input: Omit<UserProfile, "email">,
|
|
24
|
-
) => Promise<void>;
|
|
21
|
+
updateUser: (email: string, input: Omit<UserProfile, "email">) => Promise<void>;
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
function createDbOperations(db: DB<"main-db">): DbOperations {
|
|
28
25
|
return {
|
|
29
26
|
getUser: async (email: string) => {
|
|
30
|
-
return await db
|
|
31
|
-
.selectFrom("User")
|
|
32
|
-
.where("email", "=", email)
|
|
33
|
-
.selectAll()
|
|
34
|
-
.executeTakeFirst();
|
|
27
|
+
return await db.selectFrom("User").where("email", "=", email).selectAll().executeTakeFirst();
|
|
35
28
|
},
|
|
36
29
|
createUser: async (input: UserProfile) => {
|
|
37
30
|
return await db
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pnpm-lock.yaml
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pnpm-lock.yaml
|