@tailor-platform/create-sdk 1.4.1 → 1.5.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @tailor-platform/create-sdk
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#478](https://github.com/tailor-platform/sdk/pull/478) [`dce0040`](https://github.com/tailor-platform/sdk/commit/dce0040f0477c2603b604ab3aac17383ec03f3e7) Thanks [@toiroakr](https://github.com/toiroakr)! - Add local testing support for workflows
8
+
9
+ - `createWorkflowJob`: `.trigger()` now executes body directly for local testing
10
+ - `createWorkflow`: `.trigger()` now calls `mainJob.trigger()` for local testing
11
+ - Export `WORKFLOW_TEST_ENV_KEY` from `@tailor-platform/sdk/test` for env configuration
12
+ - Add workflow trigger test examples to testing template
13
+
14
+ ## 1.4.2
15
+
16
+ ### Patch Changes
17
+
18
+ - [#475](https://github.com/tailor-platform/sdk/pull/475) [`d8b0ab0`](https://github.com/tailor-platform/sdk/commit/d8b0ab07c417eb932f58a58e2a5cb59e6cee2fa0) Thanks [@haru0017](https://github.com/haru0017)! - Remove unused @tailor-platform/function-types from hello-world and multi-application template
19
+
3
20
  ## 1.4.1
4
21
 
5
22
  ## 1.4.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/create-sdk",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "A CLI tool to quickly create a new Tailor Platform SDK project",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "devDependencies": {
14
14
  "@eslint/js": "9.39.2",
15
- "@tailor-platform/sdk": "1.4.1",
15
+ "@tailor-platform/sdk": "1.5.0",
16
16
  "@types/node": "24.10.9",
17
17
  "eslint": "9.39.2",
18
18
  "eslint-plugin-oxlint": "1.39.0",
@@ -10,7 +10,7 @@
10
10
  "noEmit": true,
11
11
  "skipLibCheck": true,
12
12
  "resolveJsonModule": true,
13
- "types": ["node", "@tailor-platform/function-types"]
13
+ "types": ["node"]
14
14
  },
15
15
  "include": ["**/*.ts"]
16
16
  }
@@ -18,7 +18,7 @@
18
18
  "devDependencies": {
19
19
  "@eslint/js": "9.39.2",
20
20
  "@tailor-platform/function-types": "0.8.0",
21
- "@tailor-platform/sdk": "1.4.1",
21
+ "@tailor-platform/sdk": "1.5.0",
22
22
  "@types/node": "24.10.9",
23
23
  "eslint": "9.39.2",
24
24
  "eslint-plugin-oxlint": "1.39.0",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "devDependencies": {
16
16
  "@eslint/js": "9.39.2",
17
- "@tailor-platform/sdk": "1.4.1",
17
+ "@tailor-platform/sdk": "1.5.0",
18
18
  "@types/node": "24.10.9",
19
19
  "eslint": "9.39.2",
20
20
  "eslint-plugin-oxlint": "1.39.0",
@@ -10,7 +10,7 @@
10
10
  "noEmit": true,
11
11
  "skipLibCheck": true,
12
12
  "resolveJsonModule": true,
13
- "types": ["node", "@tailor-platform/function-types"]
13
+ "types": ["node"]
14
14
  },
15
15
  "include": ["**/*.ts"]
16
16
  }
@@ -21,7 +21,7 @@
21
21
  "devDependencies": {
22
22
  "@eslint/js": "9.39.2",
23
23
  "@tailor-platform/function-types": "0.8.0",
24
- "@tailor-platform/sdk": "1.4.1",
24
+ "@tailor-platform/sdk": "1.5.0",
25
25
  "@types/node": "24.10.9",
26
26
  "eslint": "9.39.2",
27
27
  "eslint-plugin-oxlint": "1.39.0",
@@ -0,0 +1,67 @@
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 to set environment variables
6
+ * - Use vi.spyOn() to mock dependent jobs
7
+ * - Call .trigger() on jobs/workflows directly
8
+ */
9
+ import { WORKFLOW_TEST_ENV_KEY } from "@tailor-platform/sdk/test";
10
+ import { afterEach, describe, expect, test, vi } from "vitest";
11
+ import workflow, { addNumbers, calculate, multiplyNumbers } from "./simple";
12
+
13
+ describe("workflow trigger tests", () => {
14
+ afterEach(() => {
15
+ vi.unstubAllEnvs();
16
+ vi.restoreAllMocks();
17
+ });
18
+
19
+ describe("unit tests with .body()", () => {
20
+ test("addNumbers.body() adds two numbers", () => {
21
+ const result = addNumbers.body({ a: 2, b: 3 }, { env: {} });
22
+ expect(result).toBe(5);
23
+ });
24
+
25
+ test("multiplyNumbers.body() multiplies two numbers", () => {
26
+ const result = multiplyNumbers.body({ x: 4, y: 5 }, { env: {} });
27
+ expect(result).toBe(20);
28
+ });
29
+
30
+ test("calculate.body() with mocked dependent jobs", async () => {
31
+ // Mock the trigger methods for dependent jobs
32
+ vi.spyOn(addNumbers, "trigger").mockResolvedValue(5);
33
+ vi.spyOn(multiplyNumbers, "trigger").mockResolvedValue(10);
34
+
35
+ const result = await calculate.body({ a: 2, b: 3 }, { env: {} });
36
+
37
+ expect(addNumbers.trigger).toHaveBeenCalledWith({ a: 2, b: 3 });
38
+ expect(multiplyNumbers.trigger).toHaveBeenCalledWith({ x: 5, y: 2 });
39
+ expect(result).toBe(10);
40
+ });
41
+ });
42
+
43
+ describe("workflow tests", () => {
44
+ test("workflow.mainJob.body() with mocked dependent jobs", async () => {
45
+ // Mock the trigger methods for dependent jobs
46
+ vi.spyOn(addNumbers, "trigger").mockResolvedValue(7);
47
+ vi.spyOn(multiplyNumbers, "trigger").mockResolvedValue(21);
48
+
49
+ const result = await workflow.mainJob.body({ a: 3, b: 4 }, { env: {} });
50
+
51
+ expect(addNumbers.trigger).toHaveBeenCalledWith({ a: 3, b: 4 });
52
+ expect(multiplyNumbers.trigger).toHaveBeenCalledWith({ x: 7, y: 3 });
53
+ expect(result).toBe(21);
54
+ });
55
+
56
+ test("workflow.trigger() executes all jobs (integration)", async () => {
57
+ // stubEnv ensures all dependent jobs' .trigger() calls use the same env
58
+ vi.stubEnv(WORKFLOW_TEST_ENV_KEY, JSON.stringify({ NODE_ENV: "test" }));
59
+
60
+ // No mocking - all jobs execute their actual body functions
61
+ const result = await workflow.mainJob.trigger({ a: 3, b: 4 });
62
+
63
+ // (3 + 4) * 3 = 21
64
+ expect(result).toBe(21);
65
+ });
66
+ });
67
+ });
@@ -1,11 +1,16 @@
1
- import { defineAuth, defineConfig, defineGenerators } from "@tailor-platform/sdk";
1
+ import { defineAuth, defineConfig, defineGenerators, t } from "@tailor-platform/sdk";
2
2
 
3
3
  export default defineConfig({
4
4
  name: "testing",
5
5
  auth: defineAuth("main-auth", {
6
+ machineUserAttributes: {
7
+ role: t.string(),
8
+ },
6
9
  machineUsers: {
7
10
  admin: {
8
- attributes: {},
11
+ attributes: {
12
+ role: "admin",
13
+ },
9
14
  },
10
15
  },
11
16
  }),