@tailor-platform/create-sdk 1.66.1 → 2.0.0-next.1
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 +3 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/executor/package.json +1 -1
- package/templates/generators/package.json +1 -1
- package/templates/hello-world/package.json +1 -1
- package/templates/inventory-management/package.json +1 -1
- package/templates/inventory-management/src/executor/checkInventory.ts +1 -2
- package/templates/multi-application/package.json +1 -1
- package/templates/resolver/package.json +1 -1
- package/templates/static-web-site/package.json +1 -1
- package/templates/tailordb/package.json +1 -1
- package/templates/workflow/README.md +1 -1
- package/templates/workflow/e2e/workflow.test.ts +1 -2
- package/templates/workflow/package.json +2 -2
- package/templates/workflow/src/workflow/order-fulfillment.test.ts +10 -9
- package/templates/workflow/src/workflow/order-fulfillment.ts +4 -4
- package/templates/workflow/vitest.config.ts +1 -0
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ const templateHints = {
|
|
|
23
23
|
workflow: "Workflow patterns with job chaining and testing",
|
|
24
24
|
executor: "Executor trigger types (record, resolver, schedule, webhook)",
|
|
25
25
|
"static-web-site": "Static website with auth and IdP integration",
|
|
26
|
-
generators: "Built-in
|
|
26
|
+
generators: "Built-in generation plugins: kysely, enums, files, seed"
|
|
27
27
|
};
|
|
28
28
|
const validateName = (name) => {
|
|
29
29
|
if (!name) return "Project name is required.";
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createExecutor, recordUpdatedTrigger } from "@tailor-platform/sdk";
|
|
2
2
|
import { inventory } from "../db/inventory";
|
|
3
|
-
import config from "../../tailor.config";
|
|
4
3
|
import { getDB } from "../generated/kysely-tailordb";
|
|
5
4
|
|
|
6
5
|
export default createExecutor({
|
|
@@ -22,6 +21,6 @@ export default createExecutor({
|
|
|
22
21
|
})
|
|
23
22
|
.execute();
|
|
24
23
|
},
|
|
25
|
-
|
|
24
|
+
authInvoker: "manager",
|
|
26
25
|
},
|
|
27
26
|
});
|
|
@@ -7,7 +7,7 @@ Demonstrates workflow patterns with job chaining, trigger testing, and dependenc
|
|
|
7
7
|
- Workflow with multiple jobs (`createWorkflow`, `createWorkflowJob`)
|
|
8
8
|
- Job chaining via `.trigger()`
|
|
9
9
|
- Database operations in workflow jobs (DI pattern)
|
|
10
|
-
- Integration testing with `
|
|
10
|
+
- Integration testing with `runWorkflowLocally()`
|
|
11
11
|
|
|
12
12
|
## Getting Started
|
|
13
13
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { describe, expect, test } from "vitest";
|
|
3
3
|
import { startWorkflow } from "@tailor-platform/sdk/cli";
|
|
4
|
-
import config from "../tailor.config";
|
|
5
4
|
import userProfileSyncWorkflow from "../src/workflow/sync-profile";
|
|
6
5
|
|
|
7
6
|
describe("workflow", () => {
|
|
@@ -11,7 +10,7 @@ describe("workflow", () => {
|
|
|
11
10
|
|
|
12
11
|
const { executionId, wait } = await startWorkflow({
|
|
13
12
|
workflow: userProfileSyncWorkflow,
|
|
14
|
-
authInvoker:
|
|
13
|
+
authInvoker: "admin",
|
|
15
14
|
arg: {
|
|
16
15
|
name: "workflow-test-user",
|
|
17
16
|
email: testEmail,
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"typecheck": "tsc --noEmit"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@tailor-platform/sdk": "
|
|
18
|
+
"@tailor-platform/sdk": "2.0.0-next.1",
|
|
19
19
|
"@types/node": "24.13.2",
|
|
20
|
-
"graphql": "16.14.
|
|
20
|
+
"graphql": "16.14.2",
|
|
21
21
|
"graphql-request": "7.4.0",
|
|
22
22
|
"oxfmt": "0.54.0",
|
|
23
23
|
"oxlint": "1.69.0",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runWorkflowLocally } from "@tailor-platform/sdk/vitest";
|
|
1
2
|
import { describe, expect, test, vi } from "vitest";
|
|
2
3
|
import workflow, {
|
|
3
4
|
fulfillOrder,
|
|
@@ -43,16 +44,16 @@ describe("order fulfillment workflow", () => {
|
|
|
43
44
|
|
|
44
45
|
describe("orchestration tests with mocked triggers", () => {
|
|
45
46
|
test("fulfillOrder chains all jobs", async () => {
|
|
46
|
-
using _validateSpy = vi.spyOn(validateOrder, "trigger").
|
|
47
|
+
using _validateSpy = vi.spyOn(validateOrder, "trigger").mockReturnValue({
|
|
47
48
|
valid: true,
|
|
48
49
|
orderId: "order-1",
|
|
49
50
|
});
|
|
50
|
-
using _paymentSpy = vi.spyOn(processPayment, "trigger").
|
|
51
|
+
using _paymentSpy = vi.spyOn(processPayment, "trigger").mockReturnValue({
|
|
51
52
|
transactionId: "txn-order-1",
|
|
52
53
|
amount: 100,
|
|
53
54
|
status: "completed" as const,
|
|
54
55
|
});
|
|
55
|
-
using _confirmSpy = vi.spyOn(sendConfirmation, "trigger").
|
|
56
|
+
using _confirmSpy = vi.spyOn(sendConfirmation, "trigger").mockReturnValue({
|
|
56
57
|
orderId: "order-1",
|
|
57
58
|
transactionId: "txn-order-1",
|
|
58
59
|
confirmed: true,
|
|
@@ -81,16 +82,16 @@ describe("order fulfillment workflow", () => {
|
|
|
81
82
|
});
|
|
82
83
|
|
|
83
84
|
test("workflow.mainJob.body() chains all jobs", async () => {
|
|
84
|
-
using _validateSpy = vi.spyOn(validateOrder, "trigger").
|
|
85
|
+
using _validateSpy = vi.spyOn(validateOrder, "trigger").mockReturnValue({
|
|
85
86
|
valid: true,
|
|
86
87
|
orderId: "order-2",
|
|
87
88
|
});
|
|
88
|
-
using _paymentSpy = vi.spyOn(processPayment, "trigger").
|
|
89
|
+
using _paymentSpy = vi.spyOn(processPayment, "trigger").mockReturnValue({
|
|
89
90
|
transactionId: "txn-order-2",
|
|
90
91
|
amount: 200,
|
|
91
92
|
status: "completed" as const,
|
|
92
93
|
});
|
|
93
|
-
using _confirmSpy = vi.spyOn(sendConfirmation, "trigger").
|
|
94
|
+
using _confirmSpy = vi.spyOn(sendConfirmation, "trigger").mockReturnValue({
|
|
94
95
|
orderId: "order-2",
|
|
95
96
|
transactionId: "txn-order-2",
|
|
96
97
|
confirmed: true,
|
|
@@ -107,9 +108,9 @@ describe("order fulfillment workflow", () => {
|
|
|
107
108
|
});
|
|
108
109
|
});
|
|
109
110
|
|
|
110
|
-
describe("integration tests with
|
|
111
|
-
test("
|
|
112
|
-
const result = await workflow
|
|
111
|
+
describe("integration tests with runWorkflowLocally()", () => {
|
|
112
|
+
test("runWorkflowLocally() executes all jobs", async () => {
|
|
113
|
+
const result = await runWorkflowLocally(workflow, {
|
|
113
114
|
orderId: "order-3",
|
|
114
115
|
amount: 300,
|
|
115
116
|
});
|
|
@@ -34,8 +34,8 @@ export const sendConfirmation = createWorkflowJob({
|
|
|
34
34
|
|
|
35
35
|
export const fulfillOrder = createWorkflowJob({
|
|
36
36
|
name: "fulfill-order",
|
|
37
|
-
body:
|
|
38
|
-
const validation =
|
|
37
|
+
body: (input: { orderId: string; amount: number }) => {
|
|
38
|
+
const validation = validateOrder.trigger({
|
|
39
39
|
orderId: input.orderId,
|
|
40
40
|
amount: input.amount,
|
|
41
41
|
});
|
|
@@ -44,12 +44,12 @@ export const fulfillOrder = createWorkflowJob({
|
|
|
44
44
|
throw new Error("Order validation failed");
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const payment =
|
|
47
|
+
const payment = processPayment.trigger({
|
|
48
48
|
orderId: input.orderId,
|
|
49
49
|
amount: input.amount,
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
const confirmation =
|
|
52
|
+
const confirmation = sendConfirmation.trigger({
|
|
53
53
|
orderId: input.orderId,
|
|
54
54
|
transactionId: payment.transactionId,
|
|
55
55
|
});
|