@tailor-platform/create-sdk 1.57.0 → 1.59.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/package.json +3 -3
- package/templates/executor/package.json +2 -2
- package/templates/executor/src/executor/shared.test.ts +4 -7
- package/templates/generators/package.json +2 -2
- package/templates/generators/src/resolver/getProduct.test.ts +9 -11
- package/templates/hello-world/package.json +2 -2
- package/templates/inventory-management/package.json +2 -2
- package/templates/multi-application/package.json +2 -2
- package/templates/resolver/README.md +1 -1
- package/templates/resolver/package.json +2 -2
- package/templates/resolver/src/resolver/incrementUserAge.test.ts +8 -10
- package/templates/static-web-site/package.json +2 -2
- package/templates/tailordb/package.json +2 -2
- package/templates/workflow/package.json +2 -2
- package/templates/workflow/src/resolver/resolveApproval.test.ts +7 -9
- package/templates/workflow/src/workflow/approval.test.ts +7 -9
- package/templates/workflow/src/workflow/order-fulfillment.test.ts +1 -6
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/create-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.59.0",
|
|
4
4
|
"description": "A CLI tool to quickly create a new Tailor Platform SDK project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"type": "module",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@clack/prompts": "1.5.
|
|
20
|
+
"@clack/prompts": "1.5.1",
|
|
21
21
|
"execa": "9.6.1",
|
|
22
22
|
"picocolors": "1.1.1",
|
|
23
23
|
"pkg-types": "2.3.1",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"zod": "4.4.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@types/node": "24.
|
|
28
|
+
"@types/node": "24.13.1",
|
|
29
29
|
"oxlint": "1.68.0",
|
|
30
30
|
"oxlint-tsgolint": "0.23.0",
|
|
31
31
|
"tsdown": "0.22.1",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"typecheck": "tsc --noEmit"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@tailor-platform/sdk": "1.
|
|
18
|
-
"@types/node": "24.
|
|
17
|
+
"@tailor-platform/sdk": "1.59.0",
|
|
18
|
+
"@types/node": "24.13.1",
|
|
19
19
|
"oxfmt": "0.53.0",
|
|
20
20
|
"oxlint": "1.68.0",
|
|
21
21
|
"oxlint-tsgolint": "0.23.0",
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { mockTailordb } from "@tailor-platform/sdk/vitest";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
3
|
import { createAuditLog } from "./shared";
|
|
4
4
|
|
|
5
5
|
describe("createAuditLog", () => {
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
tailordbMock.reset();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
6
|
test("inserts audit log record", async () => {
|
|
7
|
+
using db = mockTailordb();
|
|
11
8
|
await createAuditLog({
|
|
12
9
|
action: "USER_CREATED",
|
|
13
10
|
entityType: "User",
|
|
@@ -15,6 +12,6 @@ describe("createAuditLog", () => {
|
|
|
15
12
|
message: "Test audit log",
|
|
16
13
|
});
|
|
17
14
|
|
|
18
|
-
expect(
|
|
15
|
+
expect(db.executedQueries).toHaveLength(1);
|
|
19
16
|
});
|
|
20
17
|
});
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"typecheck": "tsc --noEmit"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@tailor-platform/sdk": "1.
|
|
18
|
-
"@types/node": "24.
|
|
17
|
+
"@tailor-platform/sdk": "1.59.0",
|
|
18
|
+
"@types/node": "24.13.1",
|
|
19
19
|
"oxfmt": "0.53.0",
|
|
20
20
|
"oxlint": "1.68.0",
|
|
21
21
|
"oxlint-tsgolint": "0.23.0",
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { unauthenticatedTailorUser } from "@tailor-platform/sdk/test";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { mockTailordb } from "@tailor-platform/sdk/vitest";
|
|
3
|
+
import { describe, expect, test } from "vitest";
|
|
4
4
|
import resolver from "./getProduct";
|
|
5
5
|
|
|
6
6
|
describe("getProduct resolver", () => {
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
tailordbMock.reset();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
7
|
test("returns product with category", async () => {
|
|
8
|
+
using db = mockTailordb();
|
|
12
9
|
// Select product
|
|
13
|
-
|
|
10
|
+
db.enqueueResult({
|
|
14
11
|
id: "product-1",
|
|
15
12
|
name: "Widget",
|
|
16
13
|
price: 9.99,
|
|
@@ -21,7 +18,7 @@ describe("getProduct resolver", () => {
|
|
|
21
18
|
updatedAt: null,
|
|
22
19
|
});
|
|
23
20
|
// Select category
|
|
24
|
-
|
|
21
|
+
db.enqueueResult({ name: "Gadgets" });
|
|
25
22
|
|
|
26
23
|
const result = await resolver.body({
|
|
27
24
|
input: { productId: "product-1" },
|
|
@@ -35,12 +32,13 @@ describe("getProduct resolver", () => {
|
|
|
35
32
|
status: "ACTIVE",
|
|
36
33
|
categoryName: "Gadgets",
|
|
37
34
|
});
|
|
38
|
-
expect(
|
|
35
|
+
expect(db.executedQueries).toHaveLength(2);
|
|
39
36
|
});
|
|
40
37
|
|
|
41
38
|
test("returns product without category", async () => {
|
|
39
|
+
using db = mockTailordb();
|
|
42
40
|
// Select product (no categoryId)
|
|
43
|
-
|
|
41
|
+
db.enqueueResult({
|
|
44
42
|
id: "product-2",
|
|
45
43
|
name: "Standalone Item",
|
|
46
44
|
price: 19.99,
|
|
@@ -63,6 +61,6 @@ describe("getProduct resolver", () => {
|
|
|
63
61
|
status: "DRAFT",
|
|
64
62
|
categoryName: null,
|
|
65
63
|
});
|
|
66
|
-
expect(
|
|
64
|
+
expect(db.executedQueries).toHaveLength(1);
|
|
67
65
|
});
|
|
68
66
|
});
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"typecheck": "tsc --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@tailor-platform/sdk": "1.
|
|
16
|
-
"@types/node": "24.
|
|
15
|
+
"@tailor-platform/sdk": "1.59.0",
|
|
16
|
+
"@types/node": "24.13.1",
|
|
17
17
|
"oxfmt": "0.53.0",
|
|
18
18
|
"oxlint": "1.68.0",
|
|
19
19
|
"oxlint-tsgolint": "0.23.0",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"typecheck": "tsc --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@tailor-platform/sdk": "1.
|
|
16
|
-
"@types/node": "24.
|
|
15
|
+
"@tailor-platform/sdk": "1.59.0",
|
|
16
|
+
"@types/node": "24.13.1",
|
|
17
17
|
"oxfmt": "0.53.0",
|
|
18
18
|
"oxlint": "1.68.0",
|
|
19
19
|
"oxlint-tsgolint": "0.23.0",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"typecheck": "tsc --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@tailor-platform/sdk": "1.
|
|
17
|
-
"@types/node": "24.
|
|
16
|
+
"@tailor-platform/sdk": "1.59.0",
|
|
17
|
+
"@types/node": "24.13.1",
|
|
18
18
|
"oxfmt": "0.53.0",
|
|
19
19
|
"oxlint": "1.68.0",
|
|
20
20
|
"oxlint-tsgolint": "0.23.0",
|
|
@@ -13,7 +13,7 @@ Demonstrates all resolver patterns with comprehensive testing approaches.
|
|
|
13
13
|
## Testing Approaches
|
|
14
14
|
|
|
15
15
|
1. **Direct `body()` call** - Simple resolvers with `unauthenticatedTailorUser`
|
|
16
|
-
2. **`tailor-runtime` environment + `
|
|
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
|
|
|
19
19
|
## Getting Started
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"typecheck": "tsc --noEmit"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@tailor-platform/sdk": "1.
|
|
18
|
-
"@types/node": "24.
|
|
17
|
+
"@tailor-platform/sdk": "1.59.0",
|
|
18
|
+
"@types/node": "24.13.1",
|
|
19
19
|
"oxfmt": "0.53.0",
|
|
20
20
|
"oxlint": "1.68.0",
|
|
21
21
|
"oxlint-tsgolint": "0.23.0",
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { unauthenticatedTailorUser } from "@tailor-platform/sdk/test";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { mockTailordb } from "@tailor-platform/sdk/vitest";
|
|
3
|
+
import { describe, expect, test } from "vitest";
|
|
4
4
|
import resolver from "./incrementUserAge";
|
|
5
5
|
|
|
6
6
|
describe("incrementUserAge resolver", () => {
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
tailordbMock.reset();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
7
|
test("increments user age", async () => {
|
|
12
|
-
|
|
8
|
+
using db = mockTailordb();
|
|
9
|
+
db.enqueueResults(
|
|
13
10
|
[], // BEGIN
|
|
14
11
|
[{ age: 30 }], // SELECT
|
|
15
12
|
[], // UPDATE
|
|
@@ -22,11 +19,12 @@ describe("incrementUserAge resolver", () => {
|
|
|
22
19
|
env: { appName: "Resolver Template", version: 1 },
|
|
23
20
|
});
|
|
24
21
|
expect(result).toEqual({ oldAge: 30, newAge: 31 });
|
|
25
|
-
expect(
|
|
22
|
+
expect(db.executedQueries).toHaveLength(4);
|
|
26
23
|
});
|
|
27
24
|
|
|
28
25
|
test("throws when user not found", async () => {
|
|
29
|
-
|
|
26
|
+
using db = mockTailordb();
|
|
27
|
+
db.enqueueResults(
|
|
30
28
|
[], // BEGIN
|
|
31
29
|
[], // SELECT (empty)
|
|
32
30
|
[], // ROLLBACK
|
|
@@ -38,6 +36,6 @@ describe("incrementUserAge resolver", () => {
|
|
|
38
36
|
env: { appName: "Resolver Template", version: 1 },
|
|
39
37
|
});
|
|
40
38
|
await expect(result).rejects.toThrowError(/no result/i);
|
|
41
|
-
expect(
|
|
39
|
+
expect(db.executedQueries).toHaveLength(3);
|
|
42
40
|
});
|
|
43
41
|
});
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"typecheck": "tsc --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@tailor-platform/sdk": "1.
|
|
16
|
-
"@types/node": "24.
|
|
15
|
+
"@tailor-platform/sdk": "1.59.0",
|
|
16
|
+
"@types/node": "24.13.1",
|
|
17
17
|
"oxfmt": "0.53.0",
|
|
18
18
|
"oxlint": "1.68.0",
|
|
19
19
|
"oxlint-tsgolint": "0.23.0",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"typecheck": "tsc --noEmit"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@tailor-platform/sdk": "1.
|
|
18
|
-
"@types/node": "24.
|
|
17
|
+
"@tailor-platform/sdk": "1.59.0",
|
|
18
|
+
"@types/node": "24.13.1",
|
|
19
19
|
"oxfmt": "0.53.0",
|
|
20
20
|
"oxlint": "1.68.0",
|
|
21
21
|
"oxlint-tsgolint": "0.23.0",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"typecheck": "tsc --noEmit"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@tailor-platform/sdk": "1.
|
|
19
|
-
"@types/node": "24.
|
|
18
|
+
"@tailor-platform/sdk": "1.59.0",
|
|
19
|
+
"@types/node": "24.13.1",
|
|
20
20
|
"graphql": "16.14.1",
|
|
21
21
|
"graphql-request": "7.4.0",
|
|
22
22
|
"oxfmt": "0.53.0",
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { mockWorkflow } from "@tailor-platform/sdk/vitest";
|
|
3
3
|
import { unauthenticatedTailorUser } from "@tailor-platform/sdk/test";
|
|
4
4
|
import resolver from "./resolveApproval";
|
|
5
5
|
|
|
6
6
|
describe("resolveApproval resolver", () => {
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
workflowMock.reset();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
7
|
test("resolves approval with approved=true", async () => {
|
|
12
|
-
|
|
8
|
+
using wf = mockWorkflow();
|
|
9
|
+
wf.setResolveHandler((_executionId, _key, callback) => {
|
|
13
10
|
const callbackResult = callback({
|
|
14
11
|
message: "Please approve order order-1",
|
|
15
12
|
orderId: "order-1",
|
|
@@ -24,11 +21,12 @@ describe("resolveApproval resolver", () => {
|
|
|
24
21
|
});
|
|
25
22
|
|
|
26
23
|
expect(result).toEqual({ resolved: true });
|
|
27
|
-
expect(
|
|
24
|
+
expect(wf.resolveCalls).toEqual([{ executionId: "exec-1", key: "approval" }]);
|
|
28
25
|
});
|
|
29
26
|
|
|
30
27
|
test("resolves approval with approved=false", async () => {
|
|
31
|
-
|
|
28
|
+
using wf = mockWorkflow();
|
|
29
|
+
wf.setResolveHandler((_executionId, _key, callback) => {
|
|
32
30
|
const callbackResult = callback({ message: "Please approve", orderId: "order-2" });
|
|
33
31
|
expect(callbackResult).toEqual({ approved: false });
|
|
34
32
|
});
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { mockWorkflow } from "@tailor-platform/sdk/vitest";
|
|
3
3
|
import workflow, { processWithApproval } from "./approval";
|
|
4
4
|
|
|
5
5
|
describe("approval workflow", () => {
|
|
6
|
-
beforeEach(() => {
|
|
7
|
-
workflowMock.reset();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
6
|
test("approved flow returns approved status", async () => {
|
|
11
|
-
|
|
7
|
+
using wf = mockWorkflow();
|
|
8
|
+
wf.setWaitHandler((_key, _payload) => ({ approved: true }));
|
|
12
9
|
|
|
13
10
|
const result = await processWithApproval.body({ orderId: "order-1" }, { env: {} });
|
|
14
11
|
|
|
15
12
|
expect(result).toEqual({ orderId: "order-1", status: "approved" });
|
|
16
|
-
expect(
|
|
13
|
+
expect(wf.waitCalls).toEqual([
|
|
17
14
|
{
|
|
18
15
|
key: "approval",
|
|
19
16
|
payload: { message: "Please approve order order-1", orderId: "order-1" },
|
|
@@ -22,7 +19,8 @@ describe("approval workflow", () => {
|
|
|
22
19
|
});
|
|
23
20
|
|
|
24
21
|
test("rejected flow returns rejected status", async () => {
|
|
25
|
-
|
|
22
|
+
using wf = mockWorkflow();
|
|
23
|
+
wf.setWaitHandler({ approved: false });
|
|
26
24
|
|
|
27
25
|
const result = await processWithApproval.body({ orderId: "order-2" }, { env: {} });
|
|
28
26
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
1
|
+
import { describe, expect, test, vi } from "vitest";
|
|
3
2
|
import workflow, {
|
|
4
3
|
fulfillOrder,
|
|
5
4
|
processPayment,
|
|
@@ -8,10 +7,6 @@ import workflow, {
|
|
|
8
7
|
} from "./order-fulfillment";
|
|
9
8
|
|
|
10
9
|
describe("order fulfillment workflow", () => {
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
workflowMock.reset();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
10
|
describe("individual job tests with .body()", () => {
|
|
16
11
|
test("validateOrder accepts valid order", () => {
|
|
17
12
|
const result = validateOrder.body({ orderId: "order-1", amount: 100 }, { env: {} });
|