@tailor-platform/create-sdk 1.20.0 → 1.22.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/dist/index.js +7 -2
- package/package.json +4 -3
- package/templates/executor/README.md +32 -0
- package/templates/{testing → executor}/eslint.config.js +0 -5
- package/templates/{testing → executor}/package.json +2 -4
- package/templates/executor/src/db/auditLog.ts +24 -0
- package/templates/executor/src/db/notification.ts +27 -0
- package/templates/executor/src/db/user.ts +22 -0
- package/templates/executor/src/executor/dailyCleanup.ts +16 -0
- package/templates/executor/src/executor/externalWebhook.ts +18 -0
- package/templates/executor/src/executor/onDataProcessed.ts +26 -0
- package/templates/executor/src/executor/onIdpUserCreated.ts +19 -0
- package/templates/executor/src/executor/onIdpUserDeleted.ts +19 -0
- package/templates/executor/src/executor/onIdpUserUpdated.ts +19 -0
- package/templates/executor/src/executor/onTokenIssued.ts +19 -0
- package/templates/executor/src/executor/onTokenRefreshed.ts +19 -0
- package/templates/executor/src/executor/onTokenRevoked.ts +19 -0
- package/templates/executor/src/executor/onUserCreated.ts +23 -0
- package/templates/executor/src/executor/onUserDeleted.ts +22 -0
- package/templates/executor/src/executor/onUserUpdated.ts +22 -0
- package/templates/executor/src/executor/shared.test.ts +36 -0
- package/templates/executor/src/executor/shared.ts +13 -0
- package/templates/executor/src/generated/db.ts +59 -0
- package/templates/executor/src/resolver/processData.ts +22 -0
- package/templates/executor/src/workflow/cleanup.ts +13 -0
- package/templates/executor/tailor.config.ts +40 -0
- package/templates/executor/vitest.config.ts +15 -0
- package/templates/generators/.oxfmtrc.json +3 -0
- package/templates/generators/.oxlintrc.json +197 -0
- package/templates/generators/.prettierignore +1 -0
- package/templates/generators/.prettierrc +1 -0
- package/templates/generators/README.md +30 -0
- package/templates/generators/__dot__gitignore +3 -0
- package/templates/generators/eslint.config.js +24 -0
- package/templates/generators/package.json +30 -0
- package/templates/generators/src/db/category.ts +25 -0
- package/templates/generators/src/db/order.ts +38 -0
- package/templates/generators/src/db/product.ts +34 -0
- package/templates/generators/src/db/user.ts +26 -0
- package/templates/generators/src/generated/db.ts +68 -0
- package/templates/generators/src/generated/enums.ts +39 -0
- package/templates/generators/src/generated/files.ts +51 -0
- package/templates/generators/src/resolver/getProduct.test.ts +92 -0
- package/templates/generators/src/resolver/getProduct.ts +53 -0
- package/templates/generators/src/seed/data/Category.jsonl +0 -0
- package/templates/generators/src/seed/data/Category.schema.ts +23 -0
- package/templates/generators/src/seed/data/Order.jsonl +0 -0
- package/templates/generators/src/seed/data/Order.schema.ts +21 -0
- package/templates/generators/src/seed/data/Product.jsonl +0 -0
- package/templates/generators/src/seed/data/Product.schema.ts +23 -0
- package/templates/generators/src/seed/data/User.jsonl +0 -0
- package/templates/generators/src/seed/data/User.schema.ts +20 -0
- package/templates/generators/src/seed/exec.mjs +419 -0
- package/templates/generators/tailor.config.ts +36 -0
- package/templates/generators/tsconfig.json +16 -0
- package/templates/generators/vitest.config.ts +15 -0
- package/templates/hello-world/package.json +1 -1
- package/templates/inventory-management/package.json +1 -1
- package/templates/inventory-management/user-defined.d.ts +15 -0
- package/templates/multi-application/package.json +1 -1
- package/templates/resolver/.oxfmtrc.json +3 -0
- package/templates/resolver/.oxlintrc.json +197 -0
- package/templates/resolver/.prettierrc +1 -0
- package/templates/resolver/README.md +31 -0
- package/templates/resolver/__dot__gitignore +3 -0
- package/templates/resolver/eslint.config.js +24 -0
- package/templates/resolver/package.json +32 -0
- package/templates/resolver/src/resolver/add.test.ts +23 -0
- package/templates/{testing/src/resolver/mockTailordb.test.ts → resolver/src/resolver/queryUser.test.ts} +5 -6
- package/templates/{testing/src/resolver/mockTailordb.ts → resolver/src/resolver/queryUser.ts} +0 -5
- package/templates/resolver/src/resolver/showEnv.test.ts +14 -0
- package/templates/resolver/src/resolver/showEnv.ts +19 -0
- package/templates/resolver/src/resolver/showUserInfo.test.ts +37 -0
- package/templates/resolver/src/resolver/showUserInfo.ts +21 -0
- package/templates/{testing/src/resolver/wrapTailordb.test.ts → resolver/src/resolver/updateUser.test.ts} +3 -5
- package/templates/{testing/src/resolver/wrapTailordb.ts → resolver/src/resolver/updateUser.ts} +0 -5
- package/templates/resolver/tailor.config.ts +26 -0
- package/templates/resolver/tests/bundled.test.ts +97 -0
- package/templates/resolver/tsconfig.json +16 -0
- package/templates/resolver/user-defined.d.ts +18 -0
- package/templates/resolver/vitest.config.ts +21 -0
- package/templates/static-web-site/.oxfmtrc.json +3 -0
- package/templates/static-web-site/.oxlintrc.json +197 -0
- package/templates/static-web-site/.prettierrc +1 -0
- package/templates/static-web-site/README.md +21 -0
- package/templates/static-web-site/__dot__gitignore +3 -0
- package/templates/static-web-site/eslint.config.js +24 -0
- package/templates/static-web-site/package.json +27 -0
- package/templates/static-web-site/public/callback.html +34 -0
- package/templates/static-web-site/public/index.html +55 -0
- package/templates/static-web-site/public/style.css +62 -0
- package/templates/static-web-site/src/db/user.ts +22 -0
- package/templates/static-web-site/tailor.config.ts +55 -0
- package/templates/static-web-site/tsconfig.json +16 -0
- package/templates/tailordb/.oxfmtrc.json +3 -0
- package/templates/tailordb/.oxlintrc.json +197 -0
- package/templates/tailordb/.prettierrc +1 -0
- package/templates/tailordb/README.md +29 -0
- package/templates/tailordb/__dot__gitignore +3 -0
- package/templates/tailordb/eslint.config.js +24 -0
- package/templates/tailordb/package.json +30 -0
- package/templates/tailordb/src/db/category.ts +15 -0
- package/templates/tailordb/src/db/comment.ts +26 -0
- package/templates/tailordb/src/db/permission.ts +43 -0
- package/templates/tailordb/src/db/task.test.ts +41 -0
- package/templates/tailordb/src/db/task.ts +58 -0
- package/templates/tailordb/src/db/user.ts +19 -0
- package/templates/tailordb/src/generated/db.ts +75 -0
- package/templates/tailordb/tailor.config.ts +26 -0
- package/templates/tailordb/tsconfig.json +16 -0
- package/templates/tailordb/user-defined.d.ts +15 -0
- package/templates/tailordb/vitest.config.ts +15 -0
- package/templates/workflow/.oxfmtrc.json +3 -0
- package/templates/workflow/.oxlintrc.json +197 -0
- package/templates/workflow/.prettierrc +1 -0
- package/templates/workflow/README.md +24 -0
- package/templates/workflow/__dot__gitignore +3 -0
- package/templates/{testing → workflow}/e2e/globalSetup.ts +5 -5
- package/templates/workflow/e2e/resolver.test.ts +90 -0
- package/templates/workflow/e2e/workflow.test.ts +31 -0
- package/templates/workflow/eslint.config.js +24 -0
- package/templates/workflow/package.json +35 -0
- package/templates/workflow/src/db/order.ts +22 -0
- package/templates/workflow/src/db/user.ts +22 -0
- package/templates/workflow/src/generated/db.ts +48 -0
- package/templates/workflow/src/resolver/incrementAge.ts +40 -0
- package/templates/workflow/src/workflow/order-fulfillment.test.ts +133 -0
- package/templates/workflow/src/workflow/order-fulfillment.ts +69 -0
- package/templates/{testing/src/workflow/wrapTailordb.test.ts → workflow/src/workflow/sync-profile.test.ts} +1 -1
- package/templates/{testing → workflow}/tailor.config.ts +1 -1
- package/templates/workflow/tests/bundled.test.ts +145 -0
- package/templates/workflow/tsconfig.json +16 -0
- package/templates/workflow/user-defined.d.ts +15 -0
- package/templates/{testing → workflow}/vitest.config.ts +6 -0
- package/templates/testing/README.md +0 -130
- package/templates/testing/e2e/resolver.test.ts +0 -57
- package/templates/testing/e2e/workflow.test.ts +0 -47
- package/templates/testing/src/resolver/simple.test.ts +0 -14
- package/templates/testing/src/workflow/simple.test.ts +0 -88
- package/templates/testing/src/workflow/simple.ts +0 -36
- package/templates/testing/src/workflow/trigger.test.ts +0 -104
- /package/templates/{testing → executor}/.oxfmtrc.json +0 -0
- /package/templates/{testing → executor}/.oxlintrc.json +0 -0
- /package/templates/{testing → executor}/.prettierrc +0 -0
- /package/templates/{testing → executor}/__dot__gitignore +0 -0
- /package/templates/{testing → executor}/tsconfig.json +0 -0
- /package/templates/{testing → resolver}/src/db/user.ts +0 -0
- /package/templates/{testing → resolver}/src/generated/db.ts +0 -0
- /package/templates/{testing/src/resolver/simple.ts → resolver/src/resolver/add.ts} +0 -0
- /package/templates/{testing/src/workflow/wrapTailordb.ts → workflow/src/workflow/sync-profile.ts} +0 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
|
3
|
+
"plugins": ["typescript"],
|
|
4
|
+
"categories": {
|
|
5
|
+
"correctness": "off"
|
|
6
|
+
},
|
|
7
|
+
"env": {
|
|
8
|
+
"builtin": true
|
|
9
|
+
},
|
|
10
|
+
"ignorePatterns": [".tailor-sdk/", "src/generated/"],
|
|
11
|
+
"rules": {
|
|
12
|
+
"constructor-super": "error",
|
|
13
|
+
"for-direction": "error",
|
|
14
|
+
"no-async-promise-executor": "error",
|
|
15
|
+
"no-case-declarations": "error",
|
|
16
|
+
"no-class-assign": "error",
|
|
17
|
+
"no-compare-neg-zero": "error",
|
|
18
|
+
"no-cond-assign": "error",
|
|
19
|
+
"no-const-assign": "error",
|
|
20
|
+
"no-constant-binary-expression": "error",
|
|
21
|
+
"no-constant-condition": "error",
|
|
22
|
+
"no-control-regex": "error",
|
|
23
|
+
"no-debugger": "error",
|
|
24
|
+
"no-delete-var": "error",
|
|
25
|
+
"no-dupe-class-members": "error",
|
|
26
|
+
"no-dupe-else-if": "error",
|
|
27
|
+
"no-dupe-keys": "error",
|
|
28
|
+
"no-duplicate-case": "error",
|
|
29
|
+
"no-empty": "error",
|
|
30
|
+
"no-empty-character-class": "error",
|
|
31
|
+
"no-empty-pattern": "error",
|
|
32
|
+
"no-empty-static-block": "error",
|
|
33
|
+
"no-ex-assign": "error",
|
|
34
|
+
"no-extra-boolean-cast": "error",
|
|
35
|
+
"no-fallthrough": "error",
|
|
36
|
+
"no-func-assign": "error",
|
|
37
|
+
"no-global-assign": "error",
|
|
38
|
+
"no-import-assign": "error",
|
|
39
|
+
"no-invalid-regexp": "error",
|
|
40
|
+
"no-irregular-whitespace": "error",
|
|
41
|
+
"no-loss-of-precision": "error",
|
|
42
|
+
"no-new-native-nonconstructor": "error",
|
|
43
|
+
"no-nonoctal-decimal-escape": "error",
|
|
44
|
+
"no-obj-calls": "error",
|
|
45
|
+
"no-prototype-builtins": "error",
|
|
46
|
+
"no-redeclare": "error",
|
|
47
|
+
"no-regex-spaces": "error",
|
|
48
|
+
"no-self-assign": "error",
|
|
49
|
+
"no-setter-return": "error",
|
|
50
|
+
"no-shadow-restricted-names": "error",
|
|
51
|
+
"no-sparse-arrays": "error",
|
|
52
|
+
"no-this-before-super": "error",
|
|
53
|
+
"no-unexpected-multiline": "error",
|
|
54
|
+
"no-unsafe-finally": "error",
|
|
55
|
+
"no-unsafe-negation": "error",
|
|
56
|
+
"no-unsafe-optional-chaining": "error",
|
|
57
|
+
"no-unused-labels": "error",
|
|
58
|
+
"no-unused-private-class-members": "error",
|
|
59
|
+
"no-unused-vars": "error",
|
|
60
|
+
"no-useless-backreference": "error",
|
|
61
|
+
"no-useless-catch": "error",
|
|
62
|
+
"no-useless-escape": "error",
|
|
63
|
+
"no-with": "error",
|
|
64
|
+
"require-yield": "error",
|
|
65
|
+
"use-isnan": "error",
|
|
66
|
+
"valid-typeof": "error",
|
|
67
|
+
"@typescript-eslint/await-thenable": "error",
|
|
68
|
+
"@typescript-eslint/ban-ts-comment": "error",
|
|
69
|
+
"no-array-constructor": "error",
|
|
70
|
+
"@typescript-eslint/no-array-delete": "error",
|
|
71
|
+
"@typescript-eslint/no-base-to-string": "error",
|
|
72
|
+
"@typescript-eslint/no-duplicate-enum-values": "error",
|
|
73
|
+
"@typescript-eslint/no-duplicate-type-constituents": "error",
|
|
74
|
+
"@typescript-eslint/no-empty-object-type": "error",
|
|
75
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
76
|
+
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
|
77
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
78
|
+
"@typescript-eslint/no-for-in-array": "error",
|
|
79
|
+
"@typescript-eslint/no-implied-eval": "error",
|
|
80
|
+
"@typescript-eslint/no-misused-new": "error",
|
|
81
|
+
"@typescript-eslint/no-misused-promises": "error",
|
|
82
|
+
"@typescript-eslint/no-namespace": "error",
|
|
83
|
+
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
|
|
84
|
+
"@typescript-eslint/no-redundant-type-constituents": "error",
|
|
85
|
+
"@typescript-eslint/no-require-imports": "error",
|
|
86
|
+
"@typescript-eslint/no-this-alias": "error",
|
|
87
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
88
|
+
"@typescript-eslint/no-unnecessary-type-constraint": "error",
|
|
89
|
+
"@typescript-eslint/no-unsafe-argument": "error",
|
|
90
|
+
"@typescript-eslint/no-unsafe-assignment": "error",
|
|
91
|
+
"@typescript-eslint/no-unsafe-call": "error",
|
|
92
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "error",
|
|
93
|
+
"@typescript-eslint/no-unsafe-enum-comparison": "error",
|
|
94
|
+
"@typescript-eslint/no-unsafe-function-type": "error",
|
|
95
|
+
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
96
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
97
|
+
"@typescript-eslint/no-unsafe-unary-minus": "error",
|
|
98
|
+
"no-unused-expressions": "error",
|
|
99
|
+
"@typescript-eslint/no-wrapper-object-types": "error",
|
|
100
|
+
"@typescript-eslint/only-throw-error": "error",
|
|
101
|
+
"@typescript-eslint/prefer-as-const": "error",
|
|
102
|
+
"@typescript-eslint/prefer-namespace-keyword": "error",
|
|
103
|
+
"@typescript-eslint/prefer-promise-reject-errors": "error",
|
|
104
|
+
"@typescript-eslint/require-await": "error",
|
|
105
|
+
"@typescript-eslint/restrict-plus-operands": "error",
|
|
106
|
+
"@typescript-eslint/restrict-template-expressions": "error",
|
|
107
|
+
"@typescript-eslint/triple-slash-reference": "error",
|
|
108
|
+
"@typescript-eslint/unbound-method": "error",
|
|
109
|
+
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
110
|
+
"@typescript-eslint/array-type": "error",
|
|
111
|
+
"@typescript-eslint/ban-tslint-comment": "error",
|
|
112
|
+
"@typescript-eslint/consistent-generic-constructors": "error",
|
|
113
|
+
"@typescript-eslint/consistent-indexed-object-style": "error",
|
|
114
|
+
"@typescript-eslint/consistent-type-definitions": "error",
|
|
115
|
+
"@typescript-eslint/no-confusing-non-null-assertion": "error",
|
|
116
|
+
"no-empty-function": "error",
|
|
117
|
+
"@typescript-eslint/no-inferrable-types": "error",
|
|
118
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "error",
|
|
119
|
+
"@typescript-eslint/prefer-for-of": "error",
|
|
120
|
+
"@typescript-eslint/prefer-function-type": "error",
|
|
121
|
+
"@typescript-eslint/prefer-includes": "error",
|
|
122
|
+
"@typescript-eslint/prefer-nullish-coalescing": "error"
|
|
123
|
+
},
|
|
124
|
+
"overrides": [
|
|
125
|
+
{
|
|
126
|
+
"files": ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"],
|
|
127
|
+
"rules": {
|
|
128
|
+
"constructor-super": "off",
|
|
129
|
+
"no-class-assign": "off",
|
|
130
|
+
"no-const-assign": "off",
|
|
131
|
+
"no-dupe-class-members": "off",
|
|
132
|
+
"no-dupe-keys": "off",
|
|
133
|
+
"no-func-assign": "off",
|
|
134
|
+
"no-import-assign": "off",
|
|
135
|
+
"no-new-native-nonconstructor": "off",
|
|
136
|
+
"no-obj-calls": "off",
|
|
137
|
+
"no-redeclare": "off",
|
|
138
|
+
"no-setter-return": "off",
|
|
139
|
+
"no-this-before-super": "off",
|
|
140
|
+
"no-unsafe-negation": "off",
|
|
141
|
+
"no-var": "error",
|
|
142
|
+
"no-with": "off",
|
|
143
|
+
"prefer-rest-params": "error",
|
|
144
|
+
"prefer-spread": "error"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"files": ["eslint.config.js"],
|
|
149
|
+
"rules": {
|
|
150
|
+
"@typescript-eslint/await-thenable": "off",
|
|
151
|
+
"@typescript-eslint/no-array-delete": "off",
|
|
152
|
+
"@typescript-eslint/no-base-to-string": "off",
|
|
153
|
+
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
154
|
+
"@typescript-eslint/no-deprecated": "off",
|
|
155
|
+
"@typescript-eslint/no-duplicate-type-constituents": "off",
|
|
156
|
+
"@typescript-eslint/no-floating-promises": "off",
|
|
157
|
+
"@typescript-eslint/no-for-in-array": "off",
|
|
158
|
+
"@typescript-eslint/no-implied-eval": "off",
|
|
159
|
+
"@typescript-eslint/no-meaningless-void-operator": "off",
|
|
160
|
+
"@typescript-eslint/no-misused-promises": "off",
|
|
161
|
+
"@typescript-eslint/no-misused-spread": "off",
|
|
162
|
+
"@typescript-eslint/no-mixed-enums": "off",
|
|
163
|
+
"@typescript-eslint/no-redundant-type-constituents": "off",
|
|
164
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
|
|
165
|
+
"@typescript-eslint/no-unnecessary-template-expression": "off",
|
|
166
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "off",
|
|
167
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "off",
|
|
168
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
169
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
170
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
171
|
+
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
172
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
173
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
174
|
+
"@typescript-eslint/no-unsafe-type-assertion": "off",
|
|
175
|
+
"@typescript-eslint/no-unsafe-unary-minus": "off",
|
|
176
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "off",
|
|
177
|
+
"@typescript-eslint/only-throw-error": "off",
|
|
178
|
+
"@typescript-eslint/prefer-includes": "off",
|
|
179
|
+
"@typescript-eslint/prefer-nullish-coalescing": "off",
|
|
180
|
+
"@typescript-eslint/prefer-promise-reject-errors": "off",
|
|
181
|
+
"@typescript-eslint/prefer-reduce-type-parameter": "off",
|
|
182
|
+
"@typescript-eslint/prefer-return-this-type": "off",
|
|
183
|
+
"@typescript-eslint/promise-function-async": "off",
|
|
184
|
+
"@typescript-eslint/related-getter-setter-pairs": "off",
|
|
185
|
+
"@typescript-eslint/require-array-sort-compare": "off",
|
|
186
|
+
"@typescript-eslint/require-await": "off",
|
|
187
|
+
"@typescript-eslint/restrict-plus-operands": "off",
|
|
188
|
+
"@typescript-eslint/restrict-template-expressions": "off",
|
|
189
|
+
"@typescript-eslint/return-await": "off",
|
|
190
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
191
|
+
"@typescript-eslint/switch-exhaustiveness-check": "off",
|
|
192
|
+
"@typescript-eslint/unbound-method": "off",
|
|
193
|
+
"@typescript-eslint/use-unknown-in-catch-callback-variable": "off"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Workflow Template
|
|
2
|
+
|
|
3
|
+
Demonstrates workflow patterns with job chaining, trigger testing, and dependency injection.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Workflow with multiple jobs (`createWorkflow`, `createWorkflowJob`)
|
|
8
|
+
- Job chaining via `.trigger()`
|
|
9
|
+
- Database operations in workflow jobs (DI pattern)
|
|
10
|
+
- Integration testing with `WORKFLOW_TEST_ENV_KEY`
|
|
11
|
+
|
|
12
|
+
## Getting Started
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm install
|
|
16
|
+
pnpm generate
|
|
17
|
+
pnpm deploy
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Testing
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm test
|
|
24
|
+
```
|
|
@@ -17,26 +17,26 @@ declare module "vitest" {
|
|
|
17
17
|
|
|
18
18
|
let createdWorkspace: WorkspaceInfo | null = null;
|
|
19
19
|
|
|
20
|
-
async function setupWorkspace(name: string, region: string) {
|
|
20
|
+
async function setupWorkspace(name: string, region: string): Promise<WorkspaceInfo> {
|
|
21
21
|
console.log(`Creating workspace "${name}" in region "${region}"...`);
|
|
22
22
|
const workspace = await createWorkspace({ name, region });
|
|
23
23
|
console.log(`Workspace "${workspace.name}" created successfully.`);
|
|
24
24
|
return workspace;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
async function deployApplication() {
|
|
27
|
+
async function deployApplication(): Promise<void> {
|
|
28
28
|
console.log("Deploying application...");
|
|
29
29
|
await apply();
|
|
30
30
|
console.log("Application deployed successfully.");
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function cleanupWorkspace(workspaceId: string) {
|
|
33
|
+
async function cleanupWorkspace(workspaceId: string): Promise<void> {
|
|
34
34
|
console.log("Deleting workspace...");
|
|
35
35
|
await deleteWorkspace({ workspaceId });
|
|
36
36
|
console.log("Workspace deleted successfully.");
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export async function setup(project: TestProject) {
|
|
39
|
+
export async function setup(project: TestProject): Promise<void> {
|
|
40
40
|
const isCI = process.env.CI === "true";
|
|
41
41
|
if (isCI) {
|
|
42
42
|
const workspaceName = process.env.TAILOR_PLATFORM_WORKSPACE_NAME;
|
|
@@ -57,7 +57,7 @@ export async function setup(project: TestProject) {
|
|
|
57
57
|
project.provide("token", tokens.accessToken);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export async function teardown() {
|
|
60
|
+
export async function teardown(): Promise<void> {
|
|
61
61
|
if (createdWorkspace) {
|
|
62
62
|
await cleanupWorkspace(createdWorkspace.id);
|
|
63
63
|
createdWorkspace = null;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { gql, GraphQLClient } from "graphql-request";
|
|
3
|
+
import { describe, expect, inject, test } from "vitest";
|
|
4
|
+
|
|
5
|
+
function createGraphQLClient(): GraphQLClient {
|
|
6
|
+
const endpoint = new URL("/query", inject("url")).href;
|
|
7
|
+
return new GraphQLClient(endpoint, {
|
|
8
|
+
headers: {
|
|
9
|
+
Authorization: `Bearer ${inject("token")}`,
|
|
10
|
+
},
|
|
11
|
+
// Prevent throwing errors on GraphQL errors.
|
|
12
|
+
errorPolicy: "all",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe("resolver", () => {
|
|
17
|
+
const graphQLClient = createGraphQLClient();
|
|
18
|
+
|
|
19
|
+
describe.sequential("incrementAge", () => {
|
|
20
|
+
const uuid = randomUUID();
|
|
21
|
+
const testEmail = `alice-${uuid}@example.com`;
|
|
22
|
+
|
|
23
|
+
test("create test user", async () => {
|
|
24
|
+
const query = gql`
|
|
25
|
+
mutation ($input: UserCreateInput!) {
|
|
26
|
+
createUser(input: $input) {
|
|
27
|
+
id
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const result = await graphQLClient.rawRequest(query, {
|
|
32
|
+
input: { name: "alice", email: testEmail, age: 30 },
|
|
33
|
+
});
|
|
34
|
+
expect(result.errors).toBeUndefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("increment age returns old and new values", async () => {
|
|
38
|
+
const query = gql`
|
|
39
|
+
mutation ($email: String!) {
|
|
40
|
+
incrementAge(email: $email) {
|
|
41
|
+
oldAge
|
|
42
|
+
newAge
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
const result = await graphQLClient.rawRequest(query, { email: testEmail });
|
|
47
|
+
expect(result.errors).toBeUndefined();
|
|
48
|
+
expect(result.data).toEqual({
|
|
49
|
+
incrementAge: {
|
|
50
|
+
oldAge: 30,
|
|
51
|
+
newAge: 31,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("increment is idempotent per call", async () => {
|
|
57
|
+
const query = gql`
|
|
58
|
+
mutation ($email: String!) {
|
|
59
|
+
incrementAge(email: $email) {
|
|
60
|
+
oldAge
|
|
61
|
+
newAge
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
const result = await graphQLClient.rawRequest(query, { email: testEmail });
|
|
66
|
+
expect(result.errors).toBeUndefined();
|
|
67
|
+
expect(result.data).toEqual({
|
|
68
|
+
incrementAge: {
|
|
69
|
+
oldAge: 31,
|
|
70
|
+
newAge: 32,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("incrementAge fails for non-existent user", async () => {
|
|
77
|
+
const query = gql`
|
|
78
|
+
mutation ($email: String!) {
|
|
79
|
+
incrementAge(email: $email) {
|
|
80
|
+
oldAge
|
|
81
|
+
newAge
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
const result = await graphQLClient.rawRequest(query, {
|
|
86
|
+
email: "non-existent@example.com",
|
|
87
|
+
});
|
|
88
|
+
expect(result.errors).toBeDefined();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { describe, expect, test } from "vitest";
|
|
3
|
+
import { startWorkflow } from "@tailor-platform/sdk/cli";
|
|
4
|
+
import config from "../tailor.config";
|
|
5
|
+
import userProfileSyncWorkflow from "../src/workflow/sync-profile";
|
|
6
|
+
|
|
7
|
+
describe("workflow", () => {
|
|
8
|
+
test("user-profile-sync: execute db-backed workflow", { timeout: 120000 }, async () => {
|
|
9
|
+
const uuid = randomUUID();
|
|
10
|
+
const testEmail = `workflow-test-${uuid}@example.com`;
|
|
11
|
+
|
|
12
|
+
const { executionId, wait } = await startWorkflow({
|
|
13
|
+
workflow: userProfileSyncWorkflow,
|
|
14
|
+
authInvoker: config.auth.invoker("admin"),
|
|
15
|
+
arg: {
|
|
16
|
+
name: "workflow-test-user",
|
|
17
|
+
email: testEmail,
|
|
18
|
+
age: 25,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
console.log(`[user-profile-sync] Execution ID: ${executionId}`);
|
|
23
|
+
|
|
24
|
+
const result = await wait();
|
|
25
|
+
expect(result).toMatchObject({
|
|
26
|
+
workflowName: "user-profile-sync",
|
|
27
|
+
status: "SUCCESS",
|
|
28
|
+
});
|
|
29
|
+
expect(result.jobExecutions).toBe(1);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import eslint from "@eslint/js";
|
|
2
|
+
import tseslint from "typescript-eslint";
|
|
3
|
+
import { defineConfig, globalIgnores } from "eslint/config";
|
|
4
|
+
import oxlint from "eslint-plugin-oxlint";
|
|
5
|
+
|
|
6
|
+
export default defineConfig([
|
|
7
|
+
globalIgnores([".tailor-sdk/", "src/generated/"]),
|
|
8
|
+
eslint.configs.recommended,
|
|
9
|
+
tseslint.configs.recommendedTypeChecked,
|
|
10
|
+
tseslint.configs.stylisticTypeChecked,
|
|
11
|
+
{
|
|
12
|
+
languageOptions: {
|
|
13
|
+
parserOptions: {
|
|
14
|
+
projectService: true,
|
|
15
|
+
tsconfigRootDir: import.meta.dirname,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
files: ["eslint.config.js"],
|
|
21
|
+
extends: [tseslint.configs.disableTypeChecked],
|
|
22
|
+
},
|
|
23
|
+
...oxlint.buildFromOxlintConfigFile("./.oxlintrc.json"),
|
|
24
|
+
]);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "workflow",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"generate": "tailor-sdk generate",
|
|
7
|
+
"deploy": "tailor-sdk apply",
|
|
8
|
+
"test": "vitest --project unit",
|
|
9
|
+
"test:unit": "vitest --project unit",
|
|
10
|
+
"test:bundled:prepare": "TAILOR_PLATFORM_SDK_BUILD_ONLY=true tailor-sdk apply -c tailor.config.ts",
|
|
11
|
+
"test:bundled": "pnpm test:bundled:prepare && vitest --project bundled",
|
|
12
|
+
"test:e2e": "vitest --project e2e",
|
|
13
|
+
"format": "oxfmt --write .",
|
|
14
|
+
"format:check": "oxfmt --check .",
|
|
15
|
+
"lint": "oxlint --type-aware . && eslint --cache .",
|
|
16
|
+
"lint:fix": "oxlint --type-aware --fix . && eslint --cache --fix .",
|
|
17
|
+
"typecheck": "tsc --noEmit"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@eslint/js": "9.39.2",
|
|
21
|
+
"@tailor-platform/function-types": "0.8.0",
|
|
22
|
+
"@tailor-platform/sdk": "1.22.0",
|
|
23
|
+
"@types/node": "24.10.9",
|
|
24
|
+
"eslint": "9.39.2",
|
|
25
|
+
"eslint-plugin-oxlint": "1.39.0",
|
|
26
|
+
"graphql": "16.12.0",
|
|
27
|
+
"graphql-request": "7.4.0",
|
|
28
|
+
"oxfmt": "0.24.0",
|
|
29
|
+
"oxlint": "1.39.0",
|
|
30
|
+
"oxlint-tsgolint": "0.11.1",
|
|
31
|
+
"typescript": "5.9.3",
|
|
32
|
+
"typescript-eslint": "8.53.0",
|
|
33
|
+
"vitest": "4.0.17"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { db } from "@tailor-platform/sdk";
|
|
2
|
+
|
|
3
|
+
export const order = db
|
|
4
|
+
.type("Order", {
|
|
5
|
+
customerName: db.string(),
|
|
6
|
+
amount: db.int(),
|
|
7
|
+
status: db.enum(["PENDING", "PROCESSING", "COMPLETED", "FAILED"]),
|
|
8
|
+
...db.fields.timestamps(),
|
|
9
|
+
})
|
|
10
|
+
.permission({
|
|
11
|
+
create: [[{ user: "_loggedIn" }, "=", true]],
|
|
12
|
+
read: [[{ user: "_loggedIn" }, "=", true]],
|
|
13
|
+
update: [[{ user: "_loggedIn" }, "=", true]],
|
|
14
|
+
delete: [[{ user: "_loggedIn" }, "=", true]],
|
|
15
|
+
})
|
|
16
|
+
.gqlPermission([
|
|
17
|
+
{
|
|
18
|
+
conditions: [[{ user: "_loggedIn" }, "=", true]],
|
|
19
|
+
actions: "all",
|
|
20
|
+
permit: true,
|
|
21
|
+
},
|
|
22
|
+
]);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { db } from "@tailor-platform/sdk";
|
|
2
|
+
|
|
3
|
+
export const user = db
|
|
4
|
+
.type("User", {
|
|
5
|
+
name: db.string(),
|
|
6
|
+
email: db.string().unique(),
|
|
7
|
+
age: db.int(),
|
|
8
|
+
...db.fields.timestamps(),
|
|
9
|
+
})
|
|
10
|
+
.permission({
|
|
11
|
+
create: [[{ user: "_loggedIn" }, "=", true]],
|
|
12
|
+
read: [[{ user: "_loggedIn" }, "=", true]],
|
|
13
|
+
update: [[{ user: "_loggedIn" }, "=", true]],
|
|
14
|
+
delete: [[{ user: "_loggedIn" }, "=", true]],
|
|
15
|
+
})
|
|
16
|
+
.gqlPermission([
|
|
17
|
+
{
|
|
18
|
+
conditions: [[{ user: "_loggedIn" }, "=", true]],
|
|
19
|
+
actions: "all",
|
|
20
|
+
permit: true,
|
|
21
|
+
},
|
|
22
|
+
]);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createGetDB,
|
|
3
|
+
type Generated,
|
|
4
|
+
type Timestamp,
|
|
5
|
+
type NamespaceDB,
|
|
6
|
+
type NamespaceInsertable,
|
|
7
|
+
type NamespaceSelectable,
|
|
8
|
+
type NamespaceTable,
|
|
9
|
+
type NamespaceTableName,
|
|
10
|
+
type NamespaceTransaction,
|
|
11
|
+
type NamespaceUpdateable,
|
|
12
|
+
} from "@tailor-platform/sdk/kysely";
|
|
13
|
+
|
|
14
|
+
export interface Namespace {
|
|
15
|
+
"main-db": {
|
|
16
|
+
Order: {
|
|
17
|
+
id: Generated<string>;
|
|
18
|
+
customerName: string;
|
|
19
|
+
amount: number;
|
|
20
|
+
status: "PENDING" | "PROCESSING" | "COMPLETED" | "FAILED";
|
|
21
|
+
createdAt: Generated<Timestamp>;
|
|
22
|
+
updatedAt: Timestamp | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
User: {
|
|
26
|
+
id: Generated<string>;
|
|
27
|
+
name: string;
|
|
28
|
+
email: string;
|
|
29
|
+
age: number;
|
|
30
|
+
createdAt: Generated<Timestamp>;
|
|
31
|
+
updatedAt: Timestamp | null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const getDB = createGetDB<Namespace>();
|
|
37
|
+
|
|
38
|
+
export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;
|
|
39
|
+
|
|
40
|
+
export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =
|
|
41
|
+
NamespaceTransaction<Namespace, K>;
|
|
42
|
+
|
|
43
|
+
type TableName = NamespaceTableName<Namespace>;
|
|
44
|
+
export type Table<T extends TableName> = NamespaceTable<Namespace, T>;
|
|
45
|
+
|
|
46
|
+
export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;
|
|
47
|
+
export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;
|
|
48
|
+
export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createResolver, t } from "@tailor-platform/sdk";
|
|
2
|
+
import { getDB } from "../generated/db";
|
|
3
|
+
|
|
4
|
+
const resolver = createResolver({
|
|
5
|
+
name: "incrementAge",
|
|
6
|
+
description: "Increment age of a user by email",
|
|
7
|
+
operation: "mutation",
|
|
8
|
+
input: {
|
|
9
|
+
email: t.string(),
|
|
10
|
+
},
|
|
11
|
+
body: async (context) => {
|
|
12
|
+
const db = getDB("main-db");
|
|
13
|
+
|
|
14
|
+
return await db.transaction().execute(async (trx) => {
|
|
15
|
+
const { age } = await trx
|
|
16
|
+
.selectFrom("User")
|
|
17
|
+
.where("email", "=", context.input.email)
|
|
18
|
+
.select("age")
|
|
19
|
+
.forUpdate()
|
|
20
|
+
.executeTakeFirstOrThrow();
|
|
21
|
+
|
|
22
|
+
const oldAge = age;
|
|
23
|
+
const newAge = age + 1;
|
|
24
|
+
|
|
25
|
+
await trx
|
|
26
|
+
.updateTable("User")
|
|
27
|
+
.set({ age: newAge })
|
|
28
|
+
.where("email", "=", context.input.email)
|
|
29
|
+
.execute();
|
|
30
|
+
|
|
31
|
+
return { oldAge, newAge };
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
output: t.object({
|
|
35
|
+
oldAge: t.int(),
|
|
36
|
+
newAge: t.int(),
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export default resolver;
|