@tailor-platform/create-sdk 1.19.0 → 1.21.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.
Files changed (149) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/index.js +7 -2
  3. package/package.json +1 -1
  4. package/templates/executor/README.md +32 -0
  5. package/templates/{testing → executor}/eslint.config.js +0 -5
  6. package/templates/executor/package.json +30 -0
  7. package/templates/executor/src/db/auditLog.ts +24 -0
  8. package/templates/executor/src/db/notification.ts +27 -0
  9. package/templates/executor/src/db/user.ts +22 -0
  10. package/templates/executor/src/executor/dailyCleanup.ts +16 -0
  11. package/templates/executor/src/executor/externalWebhook.ts +18 -0
  12. package/templates/executor/src/executor/onDataProcessed.ts +26 -0
  13. package/templates/executor/src/executor/onIdpUserCreated.ts +19 -0
  14. package/templates/executor/src/executor/onIdpUserDeleted.ts +19 -0
  15. package/templates/executor/src/executor/onIdpUserUpdated.ts +19 -0
  16. package/templates/executor/src/executor/onTokenIssued.ts +19 -0
  17. package/templates/executor/src/executor/onTokenRefreshed.ts +19 -0
  18. package/templates/executor/src/executor/onTokenRevoked.ts +19 -0
  19. package/templates/executor/src/executor/onUserCreated.ts +23 -0
  20. package/templates/executor/src/executor/onUserDeleted.ts +22 -0
  21. package/templates/executor/src/executor/onUserUpdated.ts +22 -0
  22. package/templates/executor/src/executor/shared.test.ts +36 -0
  23. package/templates/executor/src/executor/shared.ts +13 -0
  24. package/templates/executor/src/generated/db.ts +59 -0
  25. package/templates/executor/src/resolver/processData.ts +22 -0
  26. package/templates/executor/src/workflow/cleanup.ts +13 -0
  27. package/templates/executor/tailor.config.ts +40 -0
  28. package/templates/executor/vitest.config.ts +15 -0
  29. package/templates/generators/.oxfmtrc.json +3 -0
  30. package/templates/generators/.oxlintrc.json +197 -0
  31. package/templates/generators/.prettierignore +1 -0
  32. package/templates/generators/.prettierrc +1 -0
  33. package/templates/generators/README.md +30 -0
  34. package/templates/generators/__dot__gitignore +3 -0
  35. package/templates/generators/eslint.config.js +24 -0
  36. package/templates/generators/package.json +30 -0
  37. package/templates/generators/src/db/category.ts +25 -0
  38. package/templates/generators/src/db/order.ts +38 -0
  39. package/templates/generators/src/db/product.ts +34 -0
  40. package/templates/generators/src/db/user.ts +26 -0
  41. package/templates/generators/src/generated/db.ts +68 -0
  42. package/templates/generators/src/generated/enums.ts +39 -0
  43. package/templates/generators/src/generated/files.ts +51 -0
  44. package/templates/generators/src/resolver/getProduct.test.ts +92 -0
  45. package/templates/generators/src/resolver/getProduct.ts +53 -0
  46. package/templates/generators/src/seed/data/Category.jsonl +0 -0
  47. package/templates/generators/src/seed/data/Category.schema.ts +23 -0
  48. package/templates/generators/src/seed/data/Order.jsonl +0 -0
  49. package/templates/generators/src/seed/data/Order.schema.ts +21 -0
  50. package/templates/generators/src/seed/data/Product.jsonl +0 -0
  51. package/templates/generators/src/seed/data/Product.schema.ts +23 -0
  52. package/templates/generators/src/seed/data/User.jsonl +0 -0
  53. package/templates/generators/src/seed/data/User.schema.ts +20 -0
  54. package/templates/generators/src/seed/exec.mjs +419 -0
  55. package/templates/generators/tailor.config.ts +36 -0
  56. package/templates/generators/tsconfig.json +16 -0
  57. package/templates/generators/vitest.config.ts +15 -0
  58. package/templates/hello-world/package.json +1 -1
  59. package/templates/inventory-management/package.json +1 -1
  60. package/templates/inventory-management/user-defined.d.ts +15 -0
  61. package/templates/multi-application/package.json +1 -1
  62. package/templates/resolver/.oxfmtrc.json +3 -0
  63. package/templates/resolver/.oxlintrc.json +197 -0
  64. package/templates/resolver/.prettierrc +1 -0
  65. package/templates/resolver/README.md +31 -0
  66. package/templates/resolver/__dot__gitignore +3 -0
  67. package/templates/resolver/eslint.config.js +24 -0
  68. package/templates/resolver/package.json +30 -0
  69. package/templates/resolver/src/resolver/add.test.ts +23 -0
  70. package/templates/{testing/src/resolver/mockTailordb.test.ts → resolver/src/resolver/queryUser.test.ts} +5 -6
  71. package/templates/{testing/src/resolver/mockTailordb.ts → resolver/src/resolver/queryUser.ts} +0 -5
  72. package/templates/resolver/src/resolver/showEnv.test.ts +14 -0
  73. package/templates/resolver/src/resolver/showEnv.ts +19 -0
  74. package/templates/resolver/src/resolver/showUserInfo.test.ts +37 -0
  75. package/templates/resolver/src/resolver/showUserInfo.ts +21 -0
  76. package/templates/{testing/src/resolver/wrapTailordb.test.ts → resolver/src/resolver/updateUser.test.ts} +3 -5
  77. package/templates/{testing/src/resolver/wrapTailordb.ts → resolver/src/resolver/updateUser.ts} +0 -5
  78. package/templates/resolver/tailor.config.ts +26 -0
  79. package/templates/resolver/tsconfig.json +16 -0
  80. package/templates/resolver/user-defined.d.ts +18 -0
  81. package/templates/resolver/vitest.config.ts +15 -0
  82. package/templates/static-web-site/.oxfmtrc.json +3 -0
  83. package/templates/static-web-site/.oxlintrc.json +197 -0
  84. package/templates/static-web-site/.prettierrc +1 -0
  85. package/templates/static-web-site/README.md +21 -0
  86. package/templates/static-web-site/__dot__gitignore +3 -0
  87. package/templates/static-web-site/eslint.config.js +24 -0
  88. package/templates/static-web-site/package.json +27 -0
  89. package/templates/static-web-site/public/callback.html +34 -0
  90. package/templates/static-web-site/public/index.html +55 -0
  91. package/templates/static-web-site/public/style.css +62 -0
  92. package/templates/static-web-site/src/db/user.ts +22 -0
  93. package/templates/static-web-site/tailor.config.ts +55 -0
  94. package/templates/static-web-site/tsconfig.json +16 -0
  95. package/templates/tailordb/.oxfmtrc.json +3 -0
  96. package/templates/tailordb/.oxlintrc.json +197 -0
  97. package/templates/tailordb/.prettierrc +1 -0
  98. package/templates/tailordb/README.md +29 -0
  99. package/templates/tailordb/__dot__gitignore +3 -0
  100. package/templates/tailordb/eslint.config.js +24 -0
  101. package/templates/tailordb/package.json +30 -0
  102. package/templates/tailordb/src/db/category.ts +15 -0
  103. package/templates/tailordb/src/db/comment.ts +26 -0
  104. package/templates/tailordb/src/db/permission.ts +43 -0
  105. package/templates/tailordb/src/db/task.test.ts +41 -0
  106. package/templates/tailordb/src/db/task.ts +58 -0
  107. package/templates/tailordb/src/db/user.ts +19 -0
  108. package/templates/tailordb/src/generated/db.ts +75 -0
  109. package/templates/tailordb/tailor.config.ts +26 -0
  110. package/templates/tailordb/tsconfig.json +16 -0
  111. package/templates/tailordb/user-defined.d.ts +15 -0
  112. package/templates/tailordb/vitest.config.ts +15 -0
  113. package/templates/workflow/.oxfmtrc.json +3 -0
  114. package/templates/workflow/.oxlintrc.json +197 -0
  115. package/templates/workflow/.prettierrc +1 -0
  116. package/templates/workflow/README.md +25 -0
  117. package/templates/workflow/__dot__gitignore +3 -0
  118. package/templates/{testing → workflow}/e2e/globalSetup.ts +5 -5
  119. package/templates/workflow/e2e/resolver.test.ts +90 -0
  120. package/templates/workflow/e2e/workflow.test.ts +31 -0
  121. package/templates/workflow/eslint.config.js +24 -0
  122. package/templates/{testing → workflow}/package.json +3 -2
  123. package/templates/workflow/src/db/order.ts +22 -0
  124. package/templates/workflow/src/db/user.ts +22 -0
  125. package/templates/workflow/src/generated/db.ts +48 -0
  126. package/templates/workflow/src/resolver/incrementAge.ts +40 -0
  127. package/templates/workflow/src/workflow/order-fulfillment.test.ts +148 -0
  128. package/templates/workflow/src/workflow/order-fulfillment.ts +69 -0
  129. package/templates/{testing/src/workflow/wrapTailordb.test.ts → workflow/src/workflow/sync-profile.test.ts} +1 -1
  130. package/templates/{testing → workflow}/tailor.config.ts +1 -1
  131. package/templates/workflow/tsconfig.json +16 -0
  132. package/templates/workflow/user-defined.d.ts +15 -0
  133. package/templates/testing/README.md +0 -130
  134. package/templates/testing/e2e/resolver.test.ts +0 -57
  135. package/templates/testing/e2e/workflow.test.ts +0 -47
  136. package/templates/testing/src/resolver/simple.test.ts +0 -14
  137. package/templates/testing/src/workflow/simple.test.ts +0 -88
  138. package/templates/testing/src/workflow/simple.ts +0 -36
  139. package/templates/testing/src/workflow/trigger.test.ts +0 -104
  140. /package/templates/{testing → executor}/.oxfmtrc.json +0 -0
  141. /package/templates/{testing → executor}/.oxlintrc.json +0 -0
  142. /package/templates/{testing → executor}/.prettierrc +0 -0
  143. /package/templates/{testing → executor}/__dot__gitignore +0 -0
  144. /package/templates/{testing → executor}/tsconfig.json +0 -0
  145. /package/templates/{testing → resolver}/src/db/user.ts +0 -0
  146. /package/templates/{testing → resolver}/src/generated/db.ts +0 -0
  147. /package/templates/{testing/src/resolver/simple.ts → resolver/src/resolver/add.ts} +0 -0
  148. /package/templates/{testing/src/workflow/wrapTailordb.ts → workflow/src/workflow/sync-profile.ts} +0 -0
  149. /package/templates/{testing → workflow}/vitest.config.ts +0 -0
@@ -1,104 +0,0 @@
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 / WORKFLOW_TEST_USER_KEY to set environment variables
6
- * - Use vi.spyOn() to mock dependent jobs
7
- * - Call .trigger() on jobs/workflows directly
8
- */
9
- import {
10
- WORKFLOW_TEST_ENV_KEY,
11
- WORKFLOW_TEST_USER_KEY,
12
- unauthenticatedTailorUser,
13
- } from "@tailor-platform/sdk/test";
14
- import { afterEach, describe, expect, test, vi } from "vitest";
15
- import workflow, { addNumbers, calculate, getUserInfo, multiplyNumbers } from "./simple";
16
-
17
- describe("workflow trigger tests", () => {
18
- afterEach(() => {
19
- vi.unstubAllEnvs();
20
- vi.restoreAllMocks();
21
- });
22
-
23
- describe("unit tests with .body()", () => {
24
- test("addNumbers.body() adds two numbers", () => {
25
- const result = addNumbers.body(
26
- { a: 2, b: 3 },
27
- {
28
- env: {},
29
- user: unauthenticatedTailorUser,
30
- },
31
- );
32
- expect(result).toBe(5);
33
- });
34
-
35
- test("multiplyNumbers.body() multiplies two numbers", () => {
36
- const result = multiplyNumbers.body(
37
- { x: 4, y: 5 },
38
- {
39
- env: {},
40
- user: unauthenticatedTailorUser,
41
- },
42
- );
43
- expect(result).toBe(20);
44
- });
45
-
46
- test("calculate.body() with mocked dependent jobs", async () => {
47
- // Mock the trigger methods for dependent jobs
48
- vi.spyOn(addNumbers, "trigger").mockResolvedValue(5);
49
- vi.spyOn(multiplyNumbers, "trigger").mockResolvedValue(10);
50
-
51
- const result = await calculate.body(
52
- { a: 2, b: 3 },
53
- {
54
- env: {},
55
- user: unauthenticatedTailorUser,
56
- },
57
- );
58
-
59
- expect(addNumbers.trigger).toHaveBeenCalledWith({ a: 2, b: 3 });
60
- expect(multiplyNumbers.trigger).toHaveBeenCalledWith({ x: 5, y: 2 });
61
- expect(result).toBe(10);
62
- });
63
- });
64
-
65
- describe("workflow tests", () => {
66
- test("workflow.mainJob.body() with mocked dependent jobs", async () => {
67
- // Mock the trigger methods for dependent jobs
68
- vi.spyOn(addNumbers, "trigger").mockResolvedValue(7);
69
- vi.spyOn(multiplyNumbers, "trigger").mockResolvedValue(21);
70
-
71
- const result = await workflow.mainJob.body(
72
- { a: 3, b: 4 },
73
- {
74
- env: {},
75
- user: unauthenticatedTailorUser,
76
- },
77
- );
78
-
79
- expect(addNumbers.trigger).toHaveBeenCalledWith({ a: 3, b: 4 });
80
- expect(multiplyNumbers.trigger).toHaveBeenCalledWith({ x: 7, y: 3 });
81
- expect(result).toBe(21);
82
- });
83
-
84
- test("workflow.trigger() executes all jobs (integration)", async () => {
85
- // stubEnv ensures all dependent jobs' .trigger() calls use the same env
86
- vi.stubEnv(WORKFLOW_TEST_ENV_KEY, JSON.stringify({ NODE_ENV: "test" }));
87
-
88
- // No mocking - all jobs execute their actual body functions
89
- const result = await workflow.mainJob.trigger({ a: 3, b: 4 });
90
-
91
- // (3 + 4) * 3 = 21
92
- expect(result).toBe(21);
93
- });
94
-
95
- test("getUserInfo.trigger() uses mocked user", async () => {
96
- // stubEnv with WORKFLOW_TEST_USER_KEY to inject a custom user into .trigger() calls
97
- const customUser = { ...unauthenticatedTailorUser, id: "user-abc", workspaceId: "ws-xyz" };
98
- vi.stubEnv(WORKFLOW_TEST_USER_KEY, JSON.stringify(customUser));
99
-
100
- const result = await getUserInfo.trigger();
101
- expect(result).toEqual({ userId: "user-abc", workspaceId: "ws-xyz" });
102
- });
103
- });
104
- });
File without changes
File without changes
File without changes
File without changes
File without changes