@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
@@ -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,21 @@
1
+ # Static Web Site Template
2
+
3
+ Demonstrates static website configuration with authentication and identity provider integration.
4
+
5
+ ## Features
6
+
7
+ - Static website definition (`defineStaticWebSite`)
8
+ - Identity provider configuration (`defineIdp`) with password policy
9
+ - Authentication setup (`defineAuth`) with user profile, machine users, and OAuth2 clients
10
+ - CORS configuration using deployment-time `website.url`
11
+ - Simple HTML login page with OAuth2 callback handler
12
+
13
+ ## Getting Started
14
+
15
+ ```bash
16
+ pnpm install
17
+ pnpm deploy
18
+ ```
19
+
20
+ After deployment, the static website URL will be available in the deployment output.
21
+ Upload the files in `public/` to the static website.
@@ -0,0 +1,3 @@
1
+ node_modules/
2
+ .tailor-sdk/
3
+ .eslintcache
@@ -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,27 @@
1
+ {
2
+ "name": "static-web-site",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "deploy": "tailor-sdk apply",
7
+ "generate": "tailor-sdk generate",
8
+ "format": "oxfmt --write .",
9
+ "format:check": "oxfmt --check .",
10
+ "lint": "oxlint --type-aware . && eslint --cache .",
11
+ "lint:fix": "oxlint --type-aware --fix . && eslint --cache --fix .",
12
+ "typecheck": "tsc --noEmit"
13
+ },
14
+ "devDependencies": {
15
+ "@eslint/js": "9.39.2",
16
+ "@tailor-platform/function-types": "0.8.0",
17
+ "@tailor-platform/sdk": "1.21.0",
18
+ "@types/node": "24.10.9",
19
+ "eslint": "9.39.2",
20
+ "eslint-plugin-oxlint": "1.39.0",
21
+ "oxfmt": "0.24.0",
22
+ "oxlint": "1.39.0",
23
+ "oxlint-tsgolint": "0.11.1",
24
+ "typescript": "5.9.3",
25
+ "typescript-eslint": "8.53.0"
26
+ }
27
+ }
@@ -0,0 +1,34 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>OAuth2 Callback</title>
7
+ <link rel="stylesheet" href="style.css" />
8
+ </head>
9
+ <body>
10
+ <div class="container">
11
+ <h1>Processing login...</h1>
12
+ <p id="status">Exchanging authorization code for access token...</p>
13
+ </div>
14
+ <script>
15
+ const params = new URLSearchParams(window.location.search);
16
+ const code = params.get("code");
17
+ const error = params.get("error");
18
+
19
+ if (error) {
20
+ document.getElementById("status").textContent = "Login failed: " + error;
21
+ } else if (code) {
22
+ document.getElementById("status").textContent =
23
+ "Authorization code received. Implement token exchange on your backend.";
24
+ // In production, exchange the code for tokens via your backend
25
+ // For demo purposes, we just show the code was received
26
+ setTimeout(() => {
27
+ window.location.href = "/";
28
+ }, 3000);
29
+ } else {
30
+ document.getElementById("status").textContent = "No authorization code received.";
31
+ }
32
+ </script>
33
+ </body>
34
+ </html>
@@ -0,0 +1,55 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Login</title>
7
+ <link rel="stylesheet" href="style.css" />
8
+ </head>
9
+ <body>
10
+ <div class="container">
11
+ <h1>Tailor Platform Login</h1>
12
+ <p>Click the button below to sign in with your account.</p>
13
+ <button id="login-btn">Sign In</button>
14
+ <div id="user-info" class="hidden">
15
+ <h2>Welcome!</h2>
16
+ <pre id="user-data"></pre>
17
+ <button id="logout-btn">Sign Out</button>
18
+ </div>
19
+ </div>
20
+ <script>
21
+ // Replace with your actual OAuth2 configuration after deployment
22
+ const CONFIG = {
23
+ authorizationEndpoint: "/oauth2/authorize",
24
+ clientId: "web-client",
25
+ redirectUri: window.location.origin + "/callback.html",
26
+ scope: "openid profile email",
27
+ };
28
+
29
+ document.getElementById("login-btn").addEventListener("click", () => {
30
+ const params = new URLSearchParams({
31
+ response_type: "code",
32
+ client_id: CONFIG.clientId,
33
+ redirect_uri: CONFIG.redirectUri,
34
+ scope: CONFIG.scope,
35
+ });
36
+ window.location.href = CONFIG.authorizationEndpoint + "?" + params.toString();
37
+ });
38
+
39
+ document.getElementById("logout-btn").addEventListener("click", () => {
40
+ localStorage.removeItem("access_token");
41
+ document.getElementById("user-info").classList.add("hidden");
42
+ document.getElementById("login-btn").classList.remove("hidden");
43
+ });
44
+
45
+ // Check if user is already logged in
46
+ const token = localStorage.getItem("access_token");
47
+ if (token) {
48
+ document.getElementById("login-btn").classList.add("hidden");
49
+ document.getElementById("user-info").classList.remove("hidden");
50
+ document.getElementById("user-data").textContent =
51
+ "Logged in with token: " + token.substring(0, 20) + "...";
52
+ }
53
+ </script>
54
+ </body>
55
+ </html>
@@ -0,0 +1,62 @@
1
+ * {
2
+ margin: 0;
3
+ padding: 0;
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ body {
8
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
9
+ background-color: #f5f5f5;
10
+ display: flex;
11
+ justify-content: center;
12
+ align-items: center;
13
+ min-height: 100vh;
14
+ }
15
+
16
+ .container {
17
+ background: white;
18
+ padding: 2rem;
19
+ border-radius: 8px;
20
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
21
+ max-width: 400px;
22
+ width: 90%;
23
+ text-align: center;
24
+ }
25
+
26
+ h1 {
27
+ margin-bottom: 1rem;
28
+ color: #333;
29
+ }
30
+
31
+ p {
32
+ margin-bottom: 1.5rem;
33
+ color: #666;
34
+ }
35
+
36
+ button {
37
+ background-color: #0066cc;
38
+ color: white;
39
+ border: none;
40
+ padding: 0.75rem 1.5rem;
41
+ border-radius: 4px;
42
+ cursor: pointer;
43
+ font-size: 1rem;
44
+ }
45
+
46
+ button:hover {
47
+ background-color: #0052a3;
48
+ }
49
+
50
+ pre {
51
+ text-align: left;
52
+ background: #f0f0f0;
53
+ padding: 1rem;
54
+ border-radius: 4px;
55
+ margin: 1rem 0;
56
+ overflow-x: auto;
57
+ font-size: 0.85rem;
58
+ }
59
+
60
+ .hidden {
61
+ display: none;
62
+ }
@@ -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
+ role: db.enum(["ADMIN", "MEMBER"]),
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,55 @@
1
+ import { defineAuth, defineConfig, defineIdp, defineStaticWebSite } from "@tailor-platform/sdk";
2
+ import { user } from "./src/db/user";
3
+
4
+ const website = defineStaticWebSite("my-frontend", {
5
+ description: "Frontend application with login",
6
+ });
7
+
8
+ const idp = defineIdp("my-idp", {
9
+ authorization: "loggedIn",
10
+ clients: ["default-idp-client"],
11
+ userAuthPolicy: {
12
+ useNonEmailIdentifier: false,
13
+ allowSelfPasswordReset: true,
14
+ passwordRequireUppercase: true,
15
+ passwordRequireLowercase: true,
16
+ passwordRequireNonAlphanumeric: true,
17
+ passwordRequireNumeric: true,
18
+ passwordMinLength: 8,
19
+ passwordMaxLength: 128,
20
+ },
21
+ });
22
+
23
+ const auth = defineAuth("my-auth", {
24
+ userProfile: {
25
+ type: user,
26
+ usernameField: "email",
27
+ attributes: {
28
+ role: true,
29
+ },
30
+ },
31
+ machineUsers: {
32
+ admin: {
33
+ attributes: {
34
+ role: "ADMIN",
35
+ },
36
+ },
37
+ },
38
+ oauth2Clients: {
39
+ "web-client": {
40
+ redirectURIs: [`${website.url}/callback.html`],
41
+ description: "Web application OAuth2 client",
42
+ grantTypes: ["authorization_code", "refresh_token"],
43
+ },
44
+ },
45
+ idProvider: idp.provider("web-provider", "default-idp-client"),
46
+ });
47
+
48
+ export default defineConfig({
49
+ name: "static-web-site",
50
+ cors: [website.url],
51
+ db: { "main-db": { files: ["./src/db/*.ts"] } },
52
+ idp: [idp],
53
+ auth,
54
+ staticWebsites: [website],
55
+ });
@@ -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,3 @@
1
+ {
2
+ "ignorePatterns": ["src/generated/", "pnpm-lock.yaml"]
3
+ }