@tailor-platform/create-sdk 1.19.0 → 1.21.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 +4 -0
- package/dist/index.js +7 -2
- package/package.json +1 -1
- package/templates/executor/README.md +32 -0
- package/templates/{testing → executor}/eslint.config.js +0 -5
- package/templates/executor/package.json +30 -0
- package/templates/executor/src/db/auditLog.ts +24 -0
- package/templates/executor/src/db/notification.ts +27 -0
- package/templates/executor/src/db/user.ts +22 -0
- package/templates/executor/src/executor/dailyCleanup.ts +16 -0
- package/templates/executor/src/executor/externalWebhook.ts +18 -0
- package/templates/executor/src/executor/onDataProcessed.ts +26 -0
- package/templates/executor/src/executor/onIdpUserCreated.ts +19 -0
- package/templates/executor/src/executor/onIdpUserDeleted.ts +19 -0
- package/templates/executor/src/executor/onIdpUserUpdated.ts +19 -0
- package/templates/executor/src/executor/onTokenIssued.ts +19 -0
- package/templates/executor/src/executor/onTokenRefreshed.ts +19 -0
- package/templates/executor/src/executor/onTokenRevoked.ts +19 -0
- package/templates/executor/src/executor/onUserCreated.ts +23 -0
- package/templates/executor/src/executor/onUserDeleted.ts +22 -0
- package/templates/executor/src/executor/onUserUpdated.ts +22 -0
- package/templates/executor/src/executor/shared.test.ts +36 -0
- package/templates/executor/src/executor/shared.ts +13 -0
- package/templates/executor/src/generated/db.ts +59 -0
- package/templates/executor/src/resolver/processData.ts +22 -0
- package/templates/executor/src/workflow/cleanup.ts +13 -0
- package/templates/executor/tailor.config.ts +40 -0
- package/templates/executor/vitest.config.ts +15 -0
- package/templates/generators/.oxfmtrc.json +3 -0
- package/templates/generators/.oxlintrc.json +197 -0
- package/templates/generators/.prettierignore +1 -0
- package/templates/generators/.prettierrc +1 -0
- package/templates/generators/README.md +30 -0
- package/templates/generators/__dot__gitignore +3 -0
- package/templates/generators/eslint.config.js +24 -0
- package/templates/generators/package.json +30 -0
- package/templates/generators/src/db/category.ts +25 -0
- package/templates/generators/src/db/order.ts +38 -0
- package/templates/generators/src/db/product.ts +34 -0
- package/templates/generators/src/db/user.ts +26 -0
- package/templates/generators/src/generated/db.ts +68 -0
- package/templates/generators/src/generated/enums.ts +39 -0
- package/templates/generators/src/generated/files.ts +51 -0
- package/templates/generators/src/resolver/getProduct.test.ts +92 -0
- package/templates/generators/src/resolver/getProduct.ts +53 -0
- package/templates/generators/src/seed/data/Category.jsonl +0 -0
- package/templates/generators/src/seed/data/Category.schema.ts +23 -0
- package/templates/generators/src/seed/data/Order.jsonl +0 -0
- package/templates/generators/src/seed/data/Order.schema.ts +21 -0
- package/templates/generators/src/seed/data/Product.jsonl +0 -0
- package/templates/generators/src/seed/data/Product.schema.ts +23 -0
- package/templates/generators/src/seed/data/User.jsonl +0 -0
- package/templates/generators/src/seed/data/User.schema.ts +20 -0
- package/templates/generators/src/seed/exec.mjs +419 -0
- package/templates/generators/tailor.config.ts +36 -0
- package/templates/generators/tsconfig.json +16 -0
- package/templates/generators/vitest.config.ts +15 -0
- package/templates/hello-world/package.json +1 -1
- package/templates/inventory-management/package.json +1 -1
- package/templates/inventory-management/user-defined.d.ts +15 -0
- package/templates/multi-application/package.json +1 -1
- package/templates/resolver/.oxfmtrc.json +3 -0
- package/templates/resolver/.oxlintrc.json +197 -0
- package/templates/resolver/.prettierrc +1 -0
- package/templates/resolver/README.md +31 -0
- package/templates/resolver/__dot__gitignore +3 -0
- package/templates/resolver/eslint.config.js +24 -0
- package/templates/resolver/package.json +30 -0
- package/templates/resolver/src/resolver/add.test.ts +23 -0
- package/templates/{testing/src/resolver/mockTailordb.test.ts → resolver/src/resolver/queryUser.test.ts} +5 -6
- package/templates/{testing/src/resolver/mockTailordb.ts → resolver/src/resolver/queryUser.ts} +0 -5
- package/templates/resolver/src/resolver/showEnv.test.ts +14 -0
- package/templates/resolver/src/resolver/showEnv.ts +19 -0
- package/templates/resolver/src/resolver/showUserInfo.test.ts +37 -0
- package/templates/resolver/src/resolver/showUserInfo.ts +21 -0
- package/templates/{testing/src/resolver/wrapTailordb.test.ts → resolver/src/resolver/updateUser.test.ts} +3 -5
- package/templates/{testing/src/resolver/wrapTailordb.ts → resolver/src/resolver/updateUser.ts} +0 -5
- package/templates/resolver/tailor.config.ts +26 -0
- package/templates/resolver/tsconfig.json +16 -0
- package/templates/resolver/user-defined.d.ts +18 -0
- package/templates/resolver/vitest.config.ts +15 -0
- package/templates/static-web-site/.oxfmtrc.json +3 -0
- package/templates/static-web-site/.oxlintrc.json +197 -0
- package/templates/static-web-site/.prettierrc +1 -0
- package/templates/static-web-site/README.md +21 -0
- package/templates/static-web-site/__dot__gitignore +3 -0
- package/templates/static-web-site/eslint.config.js +24 -0
- package/templates/static-web-site/package.json +27 -0
- package/templates/static-web-site/public/callback.html +34 -0
- package/templates/static-web-site/public/index.html +55 -0
- package/templates/static-web-site/public/style.css +62 -0
- package/templates/static-web-site/src/db/user.ts +22 -0
- package/templates/static-web-site/tailor.config.ts +55 -0
- package/templates/static-web-site/tsconfig.json +16 -0
- package/templates/tailordb/.oxfmtrc.json +3 -0
- package/templates/tailordb/.oxlintrc.json +197 -0
- package/templates/tailordb/.prettierrc +1 -0
- package/templates/tailordb/README.md +29 -0
- package/templates/tailordb/__dot__gitignore +3 -0
- package/templates/tailordb/eslint.config.js +24 -0
- package/templates/tailordb/package.json +30 -0
- package/templates/tailordb/src/db/category.ts +15 -0
- package/templates/tailordb/src/db/comment.ts +26 -0
- package/templates/tailordb/src/db/permission.ts +43 -0
- package/templates/tailordb/src/db/task.test.ts +41 -0
- package/templates/tailordb/src/db/task.ts +58 -0
- package/templates/tailordb/src/db/user.ts +19 -0
- package/templates/tailordb/src/generated/db.ts +75 -0
- package/templates/tailordb/tailor.config.ts +26 -0
- package/templates/tailordb/tsconfig.json +16 -0
- package/templates/tailordb/user-defined.d.ts +15 -0
- package/templates/tailordb/vitest.config.ts +15 -0
- package/templates/workflow/.oxfmtrc.json +3 -0
- package/templates/workflow/.oxlintrc.json +197 -0
- package/templates/workflow/.prettierrc +1 -0
- package/templates/workflow/README.md +25 -0
- package/templates/workflow/__dot__gitignore +3 -0
- package/templates/{testing → workflow}/e2e/globalSetup.ts +5 -5
- package/templates/workflow/e2e/resolver.test.ts +90 -0
- package/templates/workflow/e2e/workflow.test.ts +31 -0
- package/templates/workflow/eslint.config.js +24 -0
- package/templates/{testing → workflow}/package.json +3 -2
- package/templates/workflow/src/db/order.ts +22 -0
- package/templates/workflow/src/db/user.ts +22 -0
- package/templates/workflow/src/generated/db.ts +48 -0
- package/templates/workflow/src/resolver/incrementAge.ts +40 -0
- package/templates/workflow/src/workflow/order-fulfillment.test.ts +148 -0
- package/templates/workflow/src/workflow/order-fulfillment.ts +69 -0
- package/templates/{testing/src/workflow/wrapTailordb.test.ts → workflow/src/workflow/sync-profile.test.ts} +1 -1
- package/templates/{testing → workflow}/tailor.config.ts +1 -1
- package/templates/workflow/tsconfig.json +16 -0
- package/templates/workflow/user-defined.d.ts +15 -0
- package/templates/testing/README.md +0 -130
- package/templates/testing/e2e/resolver.test.ts +0 -57
- package/templates/testing/e2e/workflow.test.ts +0 -47
- package/templates/testing/src/resolver/simple.test.ts +0 -14
- package/templates/testing/src/workflow/simple.test.ts +0 -88
- package/templates/testing/src/workflow/simple.ts +0 -36
- package/templates/testing/src/workflow/trigger.test.ts +0 -104
- /package/templates/{testing → executor}/.oxfmtrc.json +0 -0
- /package/templates/{testing → executor}/.oxlintrc.json +0 -0
- /package/templates/{testing → executor}/.prettierrc +0 -0
- /package/templates/{testing → executor}/__dot__gitignore +0 -0
- /package/templates/{testing → executor}/tsconfig.json +0 -0
- /package/templates/{testing → resolver}/src/db/user.ts +0 -0
- /package/templates/{testing → resolver}/src/generated/db.ts +0 -0
- /package/templates/{testing/src/resolver/simple.ts → resolver/src/resolver/add.ts} +0 -0
- /package/templates/{testing/src/workflow/wrapTailordb.ts → workflow/src/workflow/sync-profile.ts} +0 -0
- /package/templates/{testing → workflow}/vitest.config.ts +0 -0
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This test file demonstrates how to test workflows using the .trigger() method.
|
|
3
|
-
*
|
|
4
|
-
* Key features:
|
|
5
|
-
* - Use vi.stubEnv() with WORKFLOW_TEST_ENV_KEY / WORKFLOW_TEST_USER_KEY to set environment variables
|
|
6
|
-
* - Use vi.spyOn() to mock dependent jobs
|
|
7
|
-
* - Call .trigger() on jobs/workflows directly
|
|
8
|
-
*/
|
|
9
|
-
import {
|
|
10
|
-
WORKFLOW_TEST_ENV_KEY,
|
|
11
|
-
WORKFLOW_TEST_USER_KEY,
|
|
12
|
-
unauthenticatedTailorUser,
|
|
13
|
-
} from "@tailor-platform/sdk/test";
|
|
14
|
-
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
15
|
-
import workflow, { addNumbers, calculate, getUserInfo, multiplyNumbers } from "./simple";
|
|
16
|
-
|
|
17
|
-
describe("workflow trigger tests", () => {
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
vi.unstubAllEnvs();
|
|
20
|
-
vi.restoreAllMocks();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe("unit tests with .body()", () => {
|
|
24
|
-
test("addNumbers.body() adds two numbers", () => {
|
|
25
|
-
const result = addNumbers.body(
|
|
26
|
-
{ a: 2, b: 3 },
|
|
27
|
-
{
|
|
28
|
-
env: {},
|
|
29
|
-
user: unauthenticatedTailorUser,
|
|
30
|
-
},
|
|
31
|
-
);
|
|
32
|
-
expect(result).toBe(5);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("multiplyNumbers.body() multiplies two numbers", () => {
|
|
36
|
-
const result = multiplyNumbers.body(
|
|
37
|
-
{ x: 4, y: 5 },
|
|
38
|
-
{
|
|
39
|
-
env: {},
|
|
40
|
-
user: unauthenticatedTailorUser,
|
|
41
|
-
},
|
|
42
|
-
);
|
|
43
|
-
expect(result).toBe(20);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test("calculate.body() with mocked dependent jobs", async () => {
|
|
47
|
-
// Mock the trigger methods for dependent jobs
|
|
48
|
-
vi.spyOn(addNumbers, "trigger").mockResolvedValue(5);
|
|
49
|
-
vi.spyOn(multiplyNumbers, "trigger").mockResolvedValue(10);
|
|
50
|
-
|
|
51
|
-
const result = await calculate.body(
|
|
52
|
-
{ a: 2, b: 3 },
|
|
53
|
-
{
|
|
54
|
-
env: {},
|
|
55
|
-
user: unauthenticatedTailorUser,
|
|
56
|
-
},
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
expect(addNumbers.trigger).toHaveBeenCalledWith({ a: 2, b: 3 });
|
|
60
|
-
expect(multiplyNumbers.trigger).toHaveBeenCalledWith({ x: 5, y: 2 });
|
|
61
|
-
expect(result).toBe(10);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe("workflow tests", () => {
|
|
66
|
-
test("workflow.mainJob.body() with mocked dependent jobs", async () => {
|
|
67
|
-
// Mock the trigger methods for dependent jobs
|
|
68
|
-
vi.spyOn(addNumbers, "trigger").mockResolvedValue(7);
|
|
69
|
-
vi.spyOn(multiplyNumbers, "trigger").mockResolvedValue(21);
|
|
70
|
-
|
|
71
|
-
const result = await workflow.mainJob.body(
|
|
72
|
-
{ a: 3, b: 4 },
|
|
73
|
-
{
|
|
74
|
-
env: {},
|
|
75
|
-
user: unauthenticatedTailorUser,
|
|
76
|
-
},
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
expect(addNumbers.trigger).toHaveBeenCalledWith({ a: 3, b: 4 });
|
|
80
|
-
expect(multiplyNumbers.trigger).toHaveBeenCalledWith({ x: 7, y: 3 });
|
|
81
|
-
expect(result).toBe(21);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test("workflow.trigger() executes all jobs (integration)", async () => {
|
|
85
|
-
// stubEnv ensures all dependent jobs' .trigger() calls use the same env
|
|
86
|
-
vi.stubEnv(WORKFLOW_TEST_ENV_KEY, JSON.stringify({ NODE_ENV: "test" }));
|
|
87
|
-
|
|
88
|
-
// No mocking - all jobs execute their actual body functions
|
|
89
|
-
const result = await workflow.mainJob.trigger({ a: 3, b: 4 });
|
|
90
|
-
|
|
91
|
-
// (3 + 4) * 3 = 21
|
|
92
|
-
expect(result).toBe(21);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test("getUserInfo.trigger() uses mocked user", async () => {
|
|
96
|
-
// stubEnv with WORKFLOW_TEST_USER_KEY to inject a custom user into .trigger() calls
|
|
97
|
-
const customUser = { ...unauthenticatedTailorUser, id: "user-abc", workspaceId: "ws-xyz" };
|
|
98
|
-
vi.stubEnv(WORKFLOW_TEST_USER_KEY, JSON.stringify(customUser));
|
|
99
|
-
|
|
100
|
-
const result = await getUserInfo.trigger();
|
|
101
|
-
expect(result).toEqual({ userId: "user-abc", workspaceId: "ws-xyz" });
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/templates/{testing/src/workflow/wrapTailordb.ts → workflow/src/workflow/sync-profile.ts}
RENAMED
|
File without changes
|
|
File without changes
|