@tailor-platform/create-sdk 1.20.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.
- package/CHANGELOG.md +2 -0
- package/dist/index.js +7 -2
- package/package.json +1 -1
- package/templates/executor/README.md +32 -0
- package/templates/{testing → executor}/eslint.config.js +0 -5
- package/templates/executor/package.json +30 -0
- 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 +30 -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/tsconfig.json +16 -0
- package/templates/resolver/user-defined.d.ts +18 -0
- package/templates/resolver/vitest.config.ts +15 -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 +25 -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/{testing → workflow}/package.json +3 -2
- 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 +148 -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/tsconfig.json +16 -0
- package/templates/workflow/user-defined.d.ts +15 -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
- /package/templates/{testing → workflow}/vitest.config.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,29 @@
|
|
|
1
|
+
# TailorDB Template
|
|
2
|
+
|
|
3
|
+
Comprehensive TailorDB type definitions demonstrating all features of `db.type()`.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- All field types (string, int, float, datetime, uuid, enum, boolean)
|
|
8
|
+
- Relations (n-1, self-referential)
|
|
9
|
+
- Validations (field-level and type-level)
|
|
10
|
+
- Hooks (computed fields)
|
|
11
|
+
- File attachments
|
|
12
|
+
- Composite indexes
|
|
13
|
+
- Role-based permissions
|
|
14
|
+
- Nested objects
|
|
15
|
+
- Timestamps
|
|
16
|
+
|
|
17
|
+
## Getting Started
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm install
|
|
21
|
+
pnpm generate
|
|
22
|
+
pnpm deploy
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Testing
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm test
|
|
29
|
+
```
|
|
@@ -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,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tailordb",
|
|
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
|
+
"format": "oxfmt --write .",
|
|
11
|
+
"format:check": "oxfmt --check .",
|
|
12
|
+
"lint": "oxlint --type-aware . && eslint --cache .",
|
|
13
|
+
"lint:fix": "oxlint --type-aware --fix . && eslint --cache --fix .",
|
|
14
|
+
"typecheck": "tsc --noEmit"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@eslint/js": "9.39.2",
|
|
18
|
+
"@tailor-platform/function-types": "0.8.0",
|
|
19
|
+
"@tailor-platform/sdk": "1.21.0",
|
|
20
|
+
"@types/node": "24.10.9",
|
|
21
|
+
"eslint": "9.39.2",
|
|
22
|
+
"eslint-plugin-oxlint": "1.39.0",
|
|
23
|
+
"oxfmt": "0.24.0",
|
|
24
|
+
"oxlint": "1.39.0",
|
|
25
|
+
"oxlint-tsgolint": "0.11.1",
|
|
26
|
+
"typescript": "5.9.3",
|
|
27
|
+
"typescript-eslint": "8.53.0",
|
|
28
|
+
"vitest": "4.0.17"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { db } from "@tailor-platform/sdk";
|
|
2
|
+
import { allPermission, allGqlPermission } from "./permission";
|
|
3
|
+
|
|
4
|
+
export const category = db
|
|
5
|
+
.type("Category", "Task category with hierarchical structure", {
|
|
6
|
+
name: db.string(),
|
|
7
|
+
description: db.string({ optional: true }),
|
|
8
|
+
parentCategoryId: db.uuid({ optional: true }).relation({
|
|
9
|
+
type: "n-1",
|
|
10
|
+
toward: { type: "self" },
|
|
11
|
+
backward: "children",
|
|
12
|
+
}),
|
|
13
|
+
})
|
|
14
|
+
.permission(allPermission)
|
|
15
|
+
.gqlPermission(allGqlPermission);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { db } from "@tailor-platform/sdk";
|
|
2
|
+
import { allPermission, allGqlPermission } from "./permission";
|
|
3
|
+
import { task } from "./task";
|
|
4
|
+
import { user } from "./user";
|
|
5
|
+
|
|
6
|
+
export const comment = db
|
|
7
|
+
.type("Comment", "A comment on a task", {
|
|
8
|
+
body: db.string().validate([({ value }) => value.length >= 1, "Comment must not be empty"]),
|
|
9
|
+
taskId: db.uuid().relation({
|
|
10
|
+
type: "n-1",
|
|
11
|
+
toward: { type: task },
|
|
12
|
+
}),
|
|
13
|
+
authorId: db.uuid().relation({
|
|
14
|
+
type: "n-1",
|
|
15
|
+
toward: { type: user },
|
|
16
|
+
}),
|
|
17
|
+
metadata: db.object({
|
|
18
|
+
source: db.string().description("Where the comment was posted from"),
|
|
19
|
+
editedAt: db.datetime({ optional: true }),
|
|
20
|
+
isInternal: db.bool().description("Whether comment is internal only"),
|
|
21
|
+
}),
|
|
22
|
+
...db.fields.timestamps(),
|
|
23
|
+
})
|
|
24
|
+
.indexes({ fields: ["taskId", "createdAt"], unique: false })
|
|
25
|
+
.permission(allPermission)
|
|
26
|
+
.gqlPermission(allGqlPermission);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
PermissionCondition,
|
|
3
|
+
TailorTypePermission,
|
|
4
|
+
TailorTypeGqlPermission,
|
|
5
|
+
} from "@tailor-platform/sdk";
|
|
6
|
+
|
|
7
|
+
const loggedIn = [{ user: "_loggedIn" }, "=", true] as const satisfies PermissionCondition;
|
|
8
|
+
const isAdmin = [{ user: "role" }, "=", "admin"] as const satisfies PermissionCondition;
|
|
9
|
+
|
|
10
|
+
export const allPermission: TailorTypePermission = {
|
|
11
|
+
create: [loggedIn],
|
|
12
|
+
read: [loggedIn],
|
|
13
|
+
update: [loggedIn],
|
|
14
|
+
delete: [loggedIn],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const rolePermission: TailorTypePermission = {
|
|
18
|
+
create: [isAdmin, loggedIn],
|
|
19
|
+
read: [loggedIn],
|
|
20
|
+
update: [isAdmin, loggedIn],
|
|
21
|
+
delete: [isAdmin],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const allGqlPermission: TailorTypeGqlPermission = [
|
|
25
|
+
{
|
|
26
|
+
conditions: [loggedIn],
|
|
27
|
+
actions: "all",
|
|
28
|
+
permit: true,
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
export const roleGqlPermission: TailorTypeGqlPermission = [
|
|
33
|
+
{
|
|
34
|
+
conditions: [isAdmin],
|
|
35
|
+
actions: ["create", "read", "update", "delete"],
|
|
36
|
+
permit: true,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
conditions: [loggedIn],
|
|
40
|
+
actions: ["read"],
|
|
41
|
+
permit: true,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { task } from "./task";
|
|
3
|
+
import { user } from "./user";
|
|
4
|
+
import { category } from "./category";
|
|
5
|
+
import { comment } from "./comment";
|
|
6
|
+
|
|
7
|
+
describe("TailorDB type definitions", () => {
|
|
8
|
+
test("task type has expected fields", () => {
|
|
9
|
+
const { fields } = task;
|
|
10
|
+
expect(fields).toHaveProperty("title");
|
|
11
|
+
expect(fields).toHaveProperty("status");
|
|
12
|
+
expect(fields).toHaveProperty("priority");
|
|
13
|
+
expect(fields).toHaveProperty("dueDate");
|
|
14
|
+
expect(fields).toHaveProperty("assigneeId");
|
|
15
|
+
expect(fields).toHaveProperty("categoryId");
|
|
16
|
+
expect(fields).toHaveProperty("isArchived");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("user type has expected fields", () => {
|
|
20
|
+
const { fields } = user;
|
|
21
|
+
expect(fields).toHaveProperty("name");
|
|
22
|
+
expect(fields).toHaveProperty("email");
|
|
23
|
+
expect(fields).toHaveProperty("role");
|
|
24
|
+
expect(fields).toHaveProperty("bio");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("category type has expected fields", () => {
|
|
28
|
+
const { fields } = category;
|
|
29
|
+
expect(fields).toHaveProperty("name");
|
|
30
|
+
expect(fields).toHaveProperty("description");
|
|
31
|
+
expect(fields).toHaveProperty("parentCategoryId");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("comment type has expected fields", () => {
|
|
35
|
+
const { fields } = comment;
|
|
36
|
+
expect(fields).toHaveProperty("body");
|
|
37
|
+
expect(fields).toHaveProperty("taskId");
|
|
38
|
+
expect(fields).toHaveProperty("authorId");
|
|
39
|
+
expect(fields).toHaveProperty("metadata");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { db } from "@tailor-platform/sdk";
|
|
2
|
+
import { category } from "./category";
|
|
3
|
+
import { rolePermission, roleGqlPermission } from "./permission";
|
|
4
|
+
import { user } from "./user";
|
|
5
|
+
|
|
6
|
+
export const task = db
|
|
7
|
+
.type("Task", "A task with comprehensive features", {
|
|
8
|
+
title: db
|
|
9
|
+
.string()
|
|
10
|
+
.validate(
|
|
11
|
+
[({ value }) => value.length >= 3, "Title must be at least 3 characters"],
|
|
12
|
+
[({ value }) => value.length <= 200, "Title must be at most 200 characters"],
|
|
13
|
+
),
|
|
14
|
+
description: db.string({ optional: true }),
|
|
15
|
+
status: db.enum([
|
|
16
|
+
{ value: "TODO", description: "Not started" },
|
|
17
|
+
{ value: "IN_PROGRESS", description: "Currently being worked on" },
|
|
18
|
+
{ value: "DONE", description: "Completed" },
|
|
19
|
+
{ value: "CANCELLED", description: "No longer needed" },
|
|
20
|
+
]),
|
|
21
|
+
priority: db
|
|
22
|
+
.int()
|
|
23
|
+
.validate(
|
|
24
|
+
[({ value }) => value >= 0, "Priority must be non-negative"],
|
|
25
|
+
[({ value }) => value <= 4, "Priority must be at most 4"],
|
|
26
|
+
),
|
|
27
|
+
dueDate: db.datetime({ optional: true }),
|
|
28
|
+
assigneeId: db.uuid({ optional: true }).relation({
|
|
29
|
+
type: "n-1",
|
|
30
|
+
toward: { type: user },
|
|
31
|
+
}),
|
|
32
|
+
categoryId: db.uuid({ optional: true }).relation({
|
|
33
|
+
type: "n-1",
|
|
34
|
+
toward: { type: category },
|
|
35
|
+
}),
|
|
36
|
+
isArchived: db.bool().description("Whether the task is archived"),
|
|
37
|
+
...db.fields.timestamps(),
|
|
38
|
+
})
|
|
39
|
+
.hooks({
|
|
40
|
+
isArchived: {
|
|
41
|
+
create: () => false,
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
.indexes(
|
|
45
|
+
{ fields: ["status", "priority"], unique: false },
|
|
46
|
+
{ fields: ["assigneeId", "status"], unique: false, name: "task_assignee_status_idx" },
|
|
47
|
+
)
|
|
48
|
+
.validate({
|
|
49
|
+
status: [
|
|
50
|
+
({ value, data }) => {
|
|
51
|
+
const d = data as { dueDate: string | null };
|
|
52
|
+
return !(value === "DONE" && d.dueDate === null);
|
|
53
|
+
},
|
|
54
|
+
"Completed tasks must have a due date",
|
|
55
|
+
],
|
|
56
|
+
})
|
|
57
|
+
.permission(rolePermission)
|
|
58
|
+
.gqlPermission(roleGqlPermission);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { db } from "@tailor-platform/sdk";
|
|
2
|
+
import { allPermission, allGqlPermission } from "./permission";
|
|
3
|
+
|
|
4
|
+
export const user = db
|
|
5
|
+
.type("User", {
|
|
6
|
+
name: db.string(),
|
|
7
|
+
email: db.string().unique(),
|
|
8
|
+
role: db.enum([
|
|
9
|
+
{ value: "ADMIN", description: "Administrator with full access" },
|
|
10
|
+
{ value: "MEMBER", description: "Regular team member" },
|
|
11
|
+
{ value: "VIEWER", description: "Read-only access" },
|
|
12
|
+
]),
|
|
13
|
+
bio: db.string({ optional: true }).description("Short biography"),
|
|
14
|
+
...db.fields.timestamps(),
|
|
15
|
+
})
|
|
16
|
+
.files({ avatar: "Profile image" })
|
|
17
|
+
.indexes({ fields: ["role", "createdAt"], unique: false })
|
|
18
|
+
.permission(allPermission)
|
|
19
|
+
.gqlPermission(allGqlPermission);
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
Category: {
|
|
17
|
+
id: Generated<string>;
|
|
18
|
+
name: string;
|
|
19
|
+
description: string | null;
|
|
20
|
+
parentCategoryId: string | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Comment: {
|
|
24
|
+
id: Generated<string>;
|
|
25
|
+
body: string;
|
|
26
|
+
taskId: string;
|
|
27
|
+
authorId: string;
|
|
28
|
+
metadata: {
|
|
29
|
+
source: string;
|
|
30
|
+
editedAt: Timestamp | null;
|
|
31
|
+
isInternal: boolean;
|
|
32
|
+
};
|
|
33
|
+
createdAt: Generated<Timestamp>;
|
|
34
|
+
updatedAt: Timestamp | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Task: {
|
|
38
|
+
id: Generated<string>;
|
|
39
|
+
title: string;
|
|
40
|
+
description: string | null;
|
|
41
|
+
status: "TODO" | "IN_PROGRESS" | "DONE" | "CANCELLED";
|
|
42
|
+
priority: number;
|
|
43
|
+
dueDate: Timestamp | null;
|
|
44
|
+
assigneeId: string | null;
|
|
45
|
+
categoryId: string | null;
|
|
46
|
+
isArchived: Generated<boolean>;
|
|
47
|
+
createdAt: Generated<Timestamp>;
|
|
48
|
+
updatedAt: Timestamp | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
User: {
|
|
52
|
+
id: Generated<string>;
|
|
53
|
+
name: string;
|
|
54
|
+
email: string;
|
|
55
|
+
role: "ADMIN" | "MEMBER" | "VIEWER";
|
|
56
|
+
bio: string | null;
|
|
57
|
+
createdAt: Generated<Timestamp>;
|
|
58
|
+
updatedAt: Timestamp | null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const getDB = createGetDB<Namespace>();
|
|
64
|
+
|
|
65
|
+
export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;
|
|
66
|
+
|
|
67
|
+
export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =
|
|
68
|
+
NamespaceTransaction<Namespace, K>;
|
|
69
|
+
|
|
70
|
+
type TableName = NamespaceTableName<Namespace>;
|
|
71
|
+
export type Table<T extends TableName> = NamespaceTable<Namespace, T>;
|
|
72
|
+
|
|
73
|
+
export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;
|
|
74
|
+
export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;
|
|
75
|
+
export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineAuth, defineConfig, definePlugins, t } from "@tailor-platform/sdk";
|
|
2
|
+
import { kyselyTypePlugin } from "@tailor-platform/sdk/plugin/kysely-type";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
name: "tailordb",
|
|
6
|
+
auth: defineAuth("main-auth", {
|
|
7
|
+
machineUserAttributes: {
|
|
8
|
+
role: t.string(),
|
|
9
|
+
},
|
|
10
|
+
machineUsers: {
|
|
11
|
+
admin: {
|
|
12
|
+
attributes: {
|
|
13
|
+
role: "admin",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
viewer: {
|
|
17
|
+
attributes: {
|
|
18
|
+
role: "viewer",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}),
|
|
23
|
+
db: { "main-db": { files: ["./src/db/*.ts"] } },
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const plugins = definePlugins(kyselyTypePlugin({ distPath: "./src/generated/db.ts" }));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"allowSyntheticDefaultImports": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"noEmit": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"types": ["node", "@tailor-platform/function-types"]
|
|
14
|
+
},
|
|
15
|
+
"include": ["**/*.ts"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// This file is auto-generated by @tailor-platform/sdk
|
|
2
|
+
// Do not edit this file manually
|
|
3
|
+
// Regenerated automatically when running 'tailor-sdk apply' or 'tailor-sdk generate'
|
|
4
|
+
|
|
5
|
+
declare module "@tailor-platform/sdk" {
|
|
6
|
+
interface AttributeMap {
|
|
7
|
+
role: string;
|
|
8
|
+
}
|
|
9
|
+
interface AttributeList {
|
|
10
|
+
__tuple?: [];
|
|
11
|
+
}
|
|
12
|
+
interface Env {}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {};
|