@tailor-platform/create-sdk 2.0.0-next.5 → 2.0.0-next.6

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 CHANGED
@@ -1,7 +1,13 @@
1
1
  # @tailor-platform/create-sdk
2
2
 
3
+ ## 2.0.0-next.6
4
+
3
5
  ## 2.0.0-next.5
4
6
 
7
+ ### Patch Changes
8
+
9
+ - [#1753](https://github.com/tailor-platform/sdk/pull/1753) [`6bff945`](https://github.com/tailor-platform/sdk/commit/6bff94505f3dbe11a8be36ef301e3641ee2cba89) Thanks [@dqn](https://github.com/dqn)! - Add typed, service-specific Vitest mock controls for runtime APIs and update generated project tests to use them.
10
+
5
11
  ## 2.0.0-next.4
6
12
 
7
13
  ### Major Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/create-sdk",
3
- "version": "2.0.0-next.5",
3
+ "version": "2.0.0-next.6",
4
4
  "description": "A CLI tool to quickly create a new Tailor Platform SDK project",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "eslint-plugin-zod": "4.7.0",
30
30
  "oxlint": "1.73.0",
31
31
  "oxlint-tsgolint": "0.24.0",
32
- "tsdown": "0.22.4",
32
+ "tsdown": "0.22.5",
33
33
  "typescript": "6.0.3"
34
34
  },
35
35
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  "typecheck": "tsc --noEmit"
16
16
  },
17
17
  "devDependencies": {
18
- "@tailor-platform/sdk": "2.0.0-next.5",
18
+ "@tailor-platform/sdk": "2.0.0-next.6",
19
19
  "@types/node": "24.13.3",
20
20
  "oxfmt": "0.58.0",
21
21
  "oxlint": "1.73.0",
@@ -15,7 +15,7 @@
15
15
  "typecheck": "tsc --noEmit"
16
16
  },
17
17
  "devDependencies": {
18
- "@tailor-platform/sdk": "2.0.0-next.5",
18
+ "@tailor-platform/sdk": "2.0.0-next.6",
19
19
  "@types/node": "24.13.3",
20
20
  "oxfmt": "0.58.0",
21
21
  "oxlint": "1.73.0",
@@ -5,19 +5,21 @@ import resolver from "./getProduct";
5
5
  describe("getProduct resolver", () => {
6
6
  test("returns product with category", async () => {
7
7
  using db = mockTailordb();
8
- // Select product
9
- db.enqueueResult({
10
- id: "product-1",
11
- name: "Widget",
12
- price: 9.99,
13
- status: "ACTIVE",
14
- categoryId: "cat-1",
15
- description: null,
16
- createdAt: new Date(),
17
- updatedAt: null,
18
- });
19
- // Select category
20
- db.enqueueResult({ name: "Gadgets" });
8
+ db.enqueueRows(
9
+ [
10
+ {
11
+ id: "product-1",
12
+ name: "Widget",
13
+ price: 9.99,
14
+ status: "ACTIVE",
15
+ categoryId: "cat-1",
16
+ description: null,
17
+ createdAt: new Date(),
18
+ updatedAt: null,
19
+ },
20
+ ],
21
+ [{ name: "Gadgets" }],
22
+ );
21
23
 
22
24
  const result = await resolver.body({
23
25
  input: { productId: "product-1" },
@@ -37,17 +39,18 @@ describe("getProduct resolver", () => {
37
39
 
38
40
  test("returns product without category", async () => {
39
41
  using db = mockTailordb();
40
- // Select product (no categoryId)
41
- db.enqueueResult({
42
- id: "product-2",
43
- name: "Standalone Item",
44
- price: 19.99,
45
- status: "DRAFT",
46
- categoryId: null,
47
- description: null,
48
- createdAt: new Date(),
49
- updatedAt: null,
50
- });
42
+ db.enqueueRows([
43
+ {
44
+ id: "product-2",
45
+ name: "Standalone Item",
46
+ price: 19.99,
47
+ status: "DRAFT",
48
+ categoryId: null,
49
+ description: null,
50
+ createdAt: new Date(),
51
+ updatedAt: null,
52
+ },
53
+ ]);
51
54
 
52
55
  const result = await resolver.body({
53
56
  input: { productId: "product-2" },
@@ -13,7 +13,7 @@
13
13
  "typecheck": "tsc --noEmit"
14
14
  },
15
15
  "devDependencies": {
16
- "@tailor-platform/sdk": "2.0.0-next.5",
16
+ "@tailor-platform/sdk": "2.0.0-next.6",
17
17
  "@types/node": "24.13.3",
18
18
  "oxfmt": "0.58.0",
19
19
  "oxlint": "1.73.0",
@@ -13,7 +13,7 @@
13
13
  "typecheck": "tsc --noEmit"
14
14
  },
15
15
  "devDependencies": {
16
- "@tailor-platform/sdk": "2.0.0-next.5",
16
+ "@tailor-platform/sdk": "2.0.0-next.6",
17
17
  "@types/node": "24.13.3",
18
18
  "oxfmt": "0.58.0",
19
19
  "oxlint": "1.73.0",
@@ -14,7 +14,7 @@
14
14
  "typecheck": "tsc --noEmit"
15
15
  },
16
16
  "devDependencies": {
17
- "@tailor-platform/sdk": "2.0.0-next.5",
17
+ "@tailor-platform/sdk": "2.0.0-next.6",
18
18
  "@types/node": "24.13.3",
19
19
  "oxfmt": "0.58.0",
20
20
  "oxlint": "1.73.0",
@@ -15,7 +15,7 @@
15
15
  "typecheck": "tsc --noEmit"
16
16
  },
17
17
  "devDependencies": {
18
- "@tailor-platform/sdk": "2.0.0-next.5",
18
+ "@tailor-platform/sdk": "2.0.0-next.6",
19
19
  "@types/node": "24.13.3",
20
20
  "oxfmt": "0.58.0",
21
21
  "oxlint": "1.73.0",
@@ -5,7 +5,7 @@ import resolver from "./incrementUserAge";
5
5
  describe("incrementUserAge resolver", () => {
6
6
  test("increments user age", async () => {
7
7
  using db = mockTailordb();
8
- db.enqueueResults(
8
+ db.enqueueRows(
9
9
  [], // BEGIN
10
10
  [{ age: 30 }], // SELECT
11
11
  [], // UPDATE
@@ -24,7 +24,7 @@ describe("incrementUserAge resolver", () => {
24
24
 
25
25
  test("throws when user not found", async () => {
26
26
  using db = mockTailordb();
27
- db.enqueueResults(
27
+ db.enqueueRows(
28
28
  [], // BEGIN
29
29
  [], // SELECT (empty)
30
30
  [], // ROLLBACK
@@ -13,7 +13,7 @@
13
13
  "typecheck": "tsc --noEmit"
14
14
  },
15
15
  "devDependencies": {
16
- "@tailor-platform/sdk": "2.0.0-next.5",
16
+ "@tailor-platform/sdk": "2.0.0-next.6",
17
17
  "@types/node": "24.13.3",
18
18
  "oxfmt": "0.58.0",
19
19
  "oxlint": "1.73.0",
@@ -15,7 +15,7 @@
15
15
  "typecheck": "tsc --noEmit"
16
16
  },
17
17
  "devDependencies": {
18
- "@tailor-platform/sdk": "2.0.0-next.5",
18
+ "@tailor-platform/sdk": "2.0.0-next.6",
19
19
  "@types/node": "24.13.3",
20
20
  "oxfmt": "0.58.0",
21
21
  "oxlint": "1.73.0",
@@ -16,7 +16,7 @@
16
16
  "typecheck": "tsc --noEmit"
17
17
  },
18
18
  "devDependencies": {
19
- "@tailor-platform/sdk": "2.0.0-next.5",
19
+ "@tailor-platform/sdk": "2.0.0-next.6",
20
20
  "@types/node": "24.13.3",
21
21
  "graphql": "17.0.2",
22
22
  "graphql-request": "7.4.0",
@@ -1,16 +1,18 @@
1
1
  import { describe, expect, test } from "vitest";
2
2
  import { mockWorkflow } from "@tailor-platform/sdk/vitest";
3
+ import { approval } from "../workflow/approval";
3
4
  import resolver from "./resolveApproval";
4
5
 
5
6
  describe("resolveApproval resolver", () => {
6
7
  test("resolves approval with approved=true", async () => {
7
8
  using wf = mockWorkflow();
8
- wf.setResolveHandler((_executionId, _key, callback) => {
9
- const callbackResult = callback({
10
- message: "Please approve order order-1",
11
- orderId: "order-1",
12
- });
13
- expect(callbackResult).toEqual({ approved: true });
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 });
14
16
  });
15
17
 
16
18
  const result = await resolver.body({
@@ -21,14 +23,15 @@ describe("resolveApproval resolver", () => {
21
23
  });
22
24
 
23
25
  expect(result).toEqual({ resolved: true });
24
- expect(wf.resolveCalls).toEqual([{ executionId: "exec-1", key: "approval" }]);
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.setResolveHandler((_executionId, _key, callback) => {
30
- const callbackResult = callback({ message: "Please approve", orderId: "order-2" });
31
- expect(callbackResult).toEqual({ approved: false });
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({
@@ -39,5 +42,6 @@ describe("resolveApproval resolver", () => {
39
42
  });
40
43
 
41
44
  expect(result).toEqual({ resolved: true });
45
+ expect(approvalMock.resolve).toHaveBeenCalledWith("exec-2", expect.any(Function));
42
46
  });
43
47
  });
@@ -1,11 +1,12 @@
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
- wf.setWaitHandler((_key, _payload) => ({ approved: true }));
8
+ const approvalMock = wf.waitPoint(approval);
9
+ approvalMock.wait.mockResolvedValue({ approved: true });
9
10
 
10
11
  const result = await processWithApproval.body(
11
12
  { orderId: "order-1" },
@@ -13,17 +14,15 @@ describe("approval workflow", () => {
13
14
  );
14
15
 
15
16
  expect(result).toEqual({ orderId: "order-1", status: "approved" });
16
- expect(wf.waitCalls).toEqual([
17
- {
18
- key: "approval",
19
- payload: { message: "Please approve order order-1", orderId: "order-1" },
20
- },
21
- ]);
17
+ expect(approvalMock.wait).toHaveBeenCalledWith({
18
+ message: "Please approve order order-1",
19
+ orderId: "order-1",
20
+ });
22
21
  });
23
22
 
24
23
  test("rejected flow returns rejected status", async () => {
25
24
  using wf = mockWorkflow();
26
- wf.setWaitHandler({ approved: false });
25
+ wf.waitPoint(approval).wait.mockResolvedValue({ approved: false });
27
26
 
28
27
  const result = await processWithApproval.body(
29
28
  { orderId: "order-2" },