@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
|
@@ -32,7 +32,7 @@ export interface Namespace {
|
|
|
32
32
|
isInternal: boolean;
|
|
33
33
|
}>;
|
|
34
34
|
createdAt: Generated<Timestamp>;
|
|
35
|
-
updatedAt: Timestamp
|
|
35
|
+
updatedAt: Generated<Timestamp>;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
Task: {
|
|
@@ -46,7 +46,7 @@ export interface Namespace {
|
|
|
46
46
|
categoryId: string | null;
|
|
47
47
|
isArchived: Generated<boolean>;
|
|
48
48
|
createdAt: Generated<Timestamp>;
|
|
49
|
-
updatedAt: Timestamp
|
|
49
|
+
updatedAt: Generated<Timestamp>;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
User: {
|
|
@@ -56,7 +56,7 @@ export interface Namespace {
|
|
|
56
56
|
role: "ADMIN" | "MEMBER" | "VIEWER";
|
|
57
57
|
bio: string | null;
|
|
58
58
|
createdAt: Generated<Timestamp>;
|
|
59
|
-
updatedAt: Timestamp
|
|
59
|
+
updatedAt: Generated<Timestamp>;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -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: string;
|
|
8
8
|
}
|
|
9
9
|
interface AttributeList {
|
|
@@ -15,6 +15,8 @@ declare module "@tailor-platform/sdk" {
|
|
|
15
15
|
viewer: true;
|
|
16
16
|
}
|
|
17
17
|
interface IdpNameRegistry {}
|
|
18
|
+
interface ConnectionNameRegistry {}
|
|
19
|
+
interface AIGatewayNameRegistry {}
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
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,11 +1,11 @@
|
|
|
1
1
|
# Workflow Template
|
|
2
2
|
|
|
3
|
-
Demonstrates workflow patterns with job chaining,
|
|
3
|
+
Demonstrates workflow patterns with job chaining, start testing, and dependency injection.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- Workflow with multiple jobs (`createWorkflow`, `createWorkflowJob`)
|
|
8
|
-
- Job chaining via `.
|
|
8
|
+
- Job chaining via `.start()`
|
|
9
9
|
- Database operations in workflow jobs (DI pattern)
|
|
10
10
|
- Integration testing with `runWorkflowLocally()`
|
|
11
11
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
node_modules/
|
|
2
|
-
.tailor
|
|
2
|
+
.tailor/
|
|
@@ -55,7 +55,7 @@ export async function setup(project: TestProject): Promise<void> {
|
|
|
55
55
|
process.env.TAILOR_PLATFORM_WORKSPACE_ID = createdWorkspace.id;
|
|
56
56
|
// This pipeline deploys a fresh app into a per-run workspace, so let the
|
|
57
57
|
// SDK inject a missing app id even in CI (normally a hard error there).
|
|
58
|
-
process.env.
|
|
58
|
+
process.env.TAILOR_CI_ALLOW_ID_INJECTION = "true";
|
|
59
59
|
await deployApplication();
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "workflow",
|
|
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
|
"test:e2e": "vitest --project e2e",
|
|
@@ -15,14 +16,15 @@
|
|
|
15
16
|
"typecheck": "tsc --noEmit"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
|
-
"@tailor-platform/sdk": "2.0
|
|
19
|
-
"@
|
|
20
|
-
"
|
|
19
|
+
"@tailor-platform/eslint-plugin-sdk": "0.2.0-next.1",
|
|
20
|
+
"@tailor-platform/sdk": "2.0.0-next.11",
|
|
21
|
+
"@types/node": "24.13.3",
|
|
22
|
+
"graphql": "17.0.2",
|
|
21
23
|
"graphql-request": "7.4.0",
|
|
22
|
-
"oxfmt": "0.
|
|
23
|
-
"oxlint": "1.
|
|
24
|
-
"oxlint-tsgolint": "0.
|
|
25
|
-
"typescript": "
|
|
26
|
-
"vitest": "4.1.
|
|
24
|
+
"oxfmt": "0.61.0",
|
|
25
|
+
"oxlint": "1.76.0",
|
|
26
|
+
"oxlint-tsgolint": "7.0.2001",
|
|
27
|
+
"typescript": "6.0.3",
|
|
28
|
+
"vitest": "4.1.10"
|
|
27
29
|
}
|
|
28
30
|
}
|
|
@@ -19,7 +19,7 @@ export interface Namespace {
|
|
|
19
19
|
amount: number;
|
|
20
20
|
status: "PENDING" | "PROCESSING" | "COMPLETED" | "FAILED";
|
|
21
21
|
createdAt: Generated<Timestamp>;
|
|
22
|
-
updatedAt: Timestamp
|
|
22
|
+
updatedAt: Generated<Timestamp>;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
User: {
|
|
@@ -28,7 +28,7 @@ export interface Namespace {
|
|
|
28
28
|
email: string;
|
|
29
29
|
age: number;
|
|
30
30
|
createdAt: Generated<Timestamp>;
|
|
31
|
-
updatedAt: Timestamp
|
|
31
|
+
updatedAt: Generated<Timestamp>;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,42 +1,47 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
2
|
import { mockWorkflow } from "@tailor-platform/sdk/vitest";
|
|
3
|
-
import {
|
|
3
|
+
import { approval } from "../workflow/approval";
|
|
4
4
|
import resolver from "./resolveApproval";
|
|
5
5
|
|
|
6
6
|
describe("resolveApproval resolver", () => {
|
|
7
7
|
test("resolves approval with approved=true", async () => {
|
|
8
8
|
using wf = mockWorkflow();
|
|
9
|
-
wf.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const approvalMock = wf.waitPoint(approval);
|
|
10
|
+
const payload = {
|
|
11
|
+
message: "Please approve order order-1",
|
|
12
|
+
orderId: "order-1",
|
|
13
|
+
};
|
|
14
|
+
approvalMock.resolve.mockImplementation(async (_executionId, callback) => {
|
|
15
|
+
expect(await callback(payload)).toEqual({ approved: true });
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
const result = await resolver.body({
|
|
18
19
|
input: { executionId: "exec-1", approved: true },
|
|
19
|
-
|
|
20
|
+
caller: null,
|
|
21
|
+
invoker: null,
|
|
20
22
|
env: {},
|
|
21
23
|
});
|
|
22
24
|
|
|
23
25
|
expect(result).toEqual({ resolved: true });
|
|
24
|
-
expect(
|
|
26
|
+
expect(approvalMock.resolve).toHaveBeenCalledWith("exec-1", expect.any(Function));
|
|
25
27
|
});
|
|
26
28
|
|
|
27
29
|
test("resolves approval with approved=false", async () => {
|
|
28
30
|
using wf = mockWorkflow();
|
|
29
|
-
wf.
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const approvalMock = wf.waitPoint(approval);
|
|
32
|
+
const payload = { message: "Please approve", orderId: "order-2" };
|
|
33
|
+
approvalMock.resolve.mockImplementation(async (_executionId, callback) => {
|
|
34
|
+
expect(await callback(payload)).toEqual({ approved: false });
|
|
32
35
|
});
|
|
33
36
|
|
|
34
37
|
const result = await resolver.body({
|
|
35
38
|
input: { executionId: "exec-2", approved: false },
|
|
36
|
-
|
|
39
|
+
caller: null,
|
|
40
|
+
invoker: null,
|
|
37
41
|
env: {},
|
|
38
42
|
});
|
|
39
43
|
|
|
40
44
|
expect(result).toEqual({ resolved: true });
|
|
45
|
+
expect(approvalMock.resolve).toHaveBeenCalledWith("exec-2", expect.any(Function));
|
|
41
46
|
});
|
|
42
47
|
});
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
2
|
import { mockWorkflow } from "@tailor-platform/sdk/vitest";
|
|
3
|
-
import workflow, { processWithApproval } from "./approval";
|
|
3
|
+
import workflow, { approval, processWithApproval } from "./approval";
|
|
4
4
|
|
|
5
5
|
describe("approval workflow", () => {
|
|
6
6
|
test("approved flow returns approved status", async () => {
|
|
7
7
|
using wf = mockWorkflow();
|
|
8
|
-
|
|
8
|
+
const approvalMock = wf.waitPoint(approval);
|
|
9
|
+
approvalMock.wait.mockResolvedValue({ approved: true });
|
|
9
10
|
|
|
10
|
-
const result = await processWithApproval.body(
|
|
11
|
+
const result = await processWithApproval.body(
|
|
12
|
+
{ orderId: "order-1" },
|
|
13
|
+
{ env: {}, invoker: null },
|
|
14
|
+
);
|
|
11
15
|
|
|
12
16
|
expect(result).toEqual({ orderId: "order-1", status: "approved" });
|
|
13
|
-
expect(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
]);
|
|
17
|
+
expect(approvalMock.wait).toHaveBeenCalledWith({
|
|
18
|
+
message: "Please approve order order-1",
|
|
19
|
+
orderId: "order-1",
|
|
20
|
+
});
|
|
19
21
|
});
|
|
20
22
|
|
|
21
23
|
test("rejected flow returns rejected status", async () => {
|
|
22
24
|
using wf = mockWorkflow();
|
|
23
|
-
wf.
|
|
25
|
+
wf.waitPoint(approval).wait.mockResolvedValue({ approved: false });
|
|
24
26
|
|
|
25
|
-
const result = await processWithApproval.body(
|
|
27
|
+
const result = await processWithApproval.body(
|
|
28
|
+
{ orderId: "order-2" },
|
|
29
|
+
{ env: {}, invoker: null },
|
|
30
|
+
);
|
|
26
31
|
|
|
27
32
|
expect(result).toEqual({ orderId: "order-2", status: "rejected" });
|
|
28
33
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createWorkflow, createWorkflowJob
|
|
1
|
+
import { createWaitPoints, createWorkflow, createWorkflowJob } from "@tailor-platform/sdk";
|
|
2
2
|
|
|
3
|
-
export const { approval } =
|
|
3
|
+
export const { approval } = createWaitPoints((define) => ({
|
|
4
4
|
/** Approval for order processing */
|
|
5
5
|
approval: define<{ message: string; orderId: string }, { approved: boolean }>(),
|
|
6
6
|
}));
|
|
@@ -10,18 +10,24 @@ import workflow, {
|
|
|
10
10
|
describe("order fulfillment workflow", () => {
|
|
11
11
|
describe("individual job tests with .body()", () => {
|
|
12
12
|
test("validateOrder accepts valid order", () => {
|
|
13
|
-
const result = validateOrder.body(
|
|
13
|
+
const result = validateOrder.body(
|
|
14
|
+
{ orderId: "order-1", amount: 100 },
|
|
15
|
+
{ env: {}, invoker: null },
|
|
16
|
+
);
|
|
14
17
|
expect(result).toEqual({ valid: true, orderId: "order-1" });
|
|
15
18
|
});
|
|
16
19
|
|
|
17
20
|
test("validateOrder rejects zero amount", () => {
|
|
18
|
-
expect(() =>
|
|
19
|
-
"
|
|
20
|
-
);
|
|
21
|
+
expect(() =>
|
|
22
|
+
validateOrder.body({ orderId: "order-1", amount: 0 }, { env: {}, invoker: null }),
|
|
23
|
+
).toThrow("Order amount must be positive");
|
|
21
24
|
});
|
|
22
25
|
|
|
23
26
|
test("processPayment returns transaction", () => {
|
|
24
|
-
const result = processPayment.body(
|
|
27
|
+
const result = processPayment.body(
|
|
28
|
+
{ orderId: "order-1", amount: 100 },
|
|
29
|
+
{ env: {}, invoker: null },
|
|
30
|
+
);
|
|
25
31
|
expect(result).toEqual({
|
|
26
32
|
transactionId: "txn-order-1",
|
|
27
33
|
amount: 100,
|
|
@@ -32,7 +38,7 @@ describe("order fulfillment workflow", () => {
|
|
|
32
38
|
test("sendConfirmation returns confirmation", () => {
|
|
33
39
|
const result = sendConfirmation.body(
|
|
34
40
|
{ orderId: "order-1", transactionId: "txn-1" },
|
|
35
|
-
{ env: {} },
|
|
41
|
+
{ env: {}, invoker: null },
|
|
36
42
|
);
|
|
37
43
|
expect(result).toEqual({
|
|
38
44
|
orderId: "order-1",
|
|
@@ -42,34 +48,37 @@ describe("order fulfillment workflow", () => {
|
|
|
42
48
|
});
|
|
43
49
|
});
|
|
44
50
|
|
|
45
|
-
describe("orchestration tests with mocked
|
|
51
|
+
describe("orchestration tests with mocked starts", () => {
|
|
46
52
|
test("fulfillOrder chains all jobs", async () => {
|
|
47
|
-
using _validateSpy = vi.spyOn(validateOrder, "
|
|
53
|
+
using _validateSpy = vi.spyOn(validateOrder, "start").mockReturnValue({
|
|
48
54
|
valid: true,
|
|
49
55
|
orderId: "order-1",
|
|
50
56
|
});
|
|
51
|
-
using _paymentSpy = vi.spyOn(processPayment, "
|
|
57
|
+
using _paymentSpy = vi.spyOn(processPayment, "start").mockReturnValue({
|
|
52
58
|
transactionId: "txn-order-1",
|
|
53
59
|
amount: 100,
|
|
54
60
|
status: "completed" as const,
|
|
55
61
|
});
|
|
56
|
-
using _confirmSpy = vi.spyOn(sendConfirmation, "
|
|
62
|
+
using _confirmSpy = vi.spyOn(sendConfirmation, "start").mockReturnValue({
|
|
57
63
|
orderId: "order-1",
|
|
58
64
|
transactionId: "txn-order-1",
|
|
59
65
|
confirmed: true,
|
|
60
66
|
});
|
|
61
67
|
|
|
62
|
-
const result = await fulfillOrder.body(
|
|
68
|
+
const result = await fulfillOrder.body(
|
|
69
|
+
{ orderId: "order-1", amount: 100 },
|
|
70
|
+
{ env: {}, invoker: null },
|
|
71
|
+
);
|
|
63
72
|
|
|
64
|
-
expect(validateOrder.
|
|
73
|
+
expect(validateOrder.start).toHaveBeenCalledWith({
|
|
65
74
|
orderId: "order-1",
|
|
66
75
|
amount: 100,
|
|
67
76
|
});
|
|
68
|
-
expect(processPayment.
|
|
77
|
+
expect(processPayment.start).toHaveBeenCalledWith({
|
|
69
78
|
orderId: "order-1",
|
|
70
79
|
amount: 100,
|
|
71
80
|
});
|
|
72
|
-
expect(sendConfirmation.
|
|
81
|
+
expect(sendConfirmation.start).toHaveBeenCalledWith({
|
|
73
82
|
orderId: "order-1",
|
|
74
83
|
transactionId: "txn-order-1",
|
|
75
84
|
});
|
|
@@ -82,22 +91,25 @@ describe("order fulfillment workflow", () => {
|
|
|
82
91
|
});
|
|
83
92
|
|
|
84
93
|
test("workflow.mainJob.body() chains all jobs", async () => {
|
|
85
|
-
using _validateSpy = vi.spyOn(validateOrder, "
|
|
94
|
+
using _validateSpy = vi.spyOn(validateOrder, "start").mockReturnValue({
|
|
86
95
|
valid: true,
|
|
87
96
|
orderId: "order-2",
|
|
88
97
|
});
|
|
89
|
-
using _paymentSpy = vi.spyOn(processPayment, "
|
|
98
|
+
using _paymentSpy = vi.spyOn(processPayment, "start").mockReturnValue({
|
|
90
99
|
transactionId: "txn-order-2",
|
|
91
100
|
amount: 200,
|
|
92
101
|
status: "completed" as const,
|
|
93
102
|
});
|
|
94
|
-
using _confirmSpy = vi.spyOn(sendConfirmation, "
|
|
103
|
+
using _confirmSpy = vi.spyOn(sendConfirmation, "start").mockReturnValue({
|
|
95
104
|
orderId: "order-2",
|
|
96
105
|
transactionId: "txn-order-2",
|
|
97
106
|
confirmed: true,
|
|
98
107
|
});
|
|
99
108
|
|
|
100
|
-
const result = await workflow.mainJob.body(
|
|
109
|
+
const result = await workflow.mainJob.body(
|
|
110
|
+
{ orderId: "order-2", amount: 200 },
|
|
111
|
+
{ env: {}, invoker: null },
|
|
112
|
+
);
|
|
101
113
|
|
|
102
114
|
expect(result).toEqual({
|
|
103
115
|
orderId: "order-2",
|
|
@@ -35,7 +35,7 @@ export const sendConfirmation = createWorkflowJob({
|
|
|
35
35
|
export const fulfillOrder = createWorkflowJob({
|
|
36
36
|
name: "fulfill-order",
|
|
37
37
|
body: (input: { orderId: string; amount: number }) => {
|
|
38
|
-
const validation = validateOrder.
|
|
38
|
+
const validation = validateOrder.start({
|
|
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 = processPayment.
|
|
47
|
+
const payment = processPayment.start({
|
|
48
48
|
orderId: input.orderId,
|
|
49
49
|
amount: input.amount,
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
const confirmation = sendConfirmation.
|
|
52
|
+
const confirmation = sendConfirmation.start({
|
|
53
53
|
orderId: input.orderId,
|
|
54
54
|
transactionId: payment.transactionId,
|
|
55
55
|
});
|
|
@@ -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: string;
|
|
8
8
|
}
|
|
9
9
|
interface AttributeList {
|
|
@@ -14,6 +14,8 @@ declare module "@tailor-platform/sdk" {
|
|
|
14
14
|
admin: true;
|
|
15
15
|
}
|
|
16
16
|
interface IdpNameRegistry {}
|
|
17
|
+
interface ConnectionNameRegistry {}
|
|
18
|
+
interface AIGatewayNameRegistry {}
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export {};
|