@contember/create 2.0.2 → 2.1.0-alpha.10

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 (282) hide show
  1. package/dist/development/src/commands/WorkspaceCreateCommand.cjs +37 -23
  2. package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
  3. package/dist/development/src/commands/WorkspaceCreateCommand.js +37 -23
  4. package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
  5. package/dist/development/src/lib/FileSystem.cjs +1 -0
  6. package/dist/development/src/lib/FileSystem.cjs.map +1 -1
  7. package/dist/development/src/lib/FileSystem.js +1 -0
  8. package/dist/development/src/lib/FileSystem.js.map +1 -1
  9. package/dist/development/src/lib/TemplateInstaller.cjs +24 -5
  10. package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
  11. package/dist/development/src/lib/TemplateInstaller.js +24 -5
  12. package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
  13. package/dist/development/src/lib/packageManagerDetector.cjs +22 -0
  14. package/dist/development/src/lib/packageManagerDetector.cjs.map +1 -0
  15. package/dist/development/src/lib/packageManagerDetector.js +22 -0
  16. package/dist/development/src/lib/packageManagerDetector.js.map +1 -0
  17. package/dist/production/src/commands/WorkspaceCreateCommand.cjs +37 -23
  18. package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
  19. package/dist/production/src/commands/WorkspaceCreateCommand.js +37 -23
  20. package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
  21. package/dist/production/src/lib/FileSystem.cjs +1 -0
  22. package/dist/production/src/lib/FileSystem.cjs.map +1 -1
  23. package/dist/production/src/lib/FileSystem.js +1 -0
  24. package/dist/production/src/lib/FileSystem.js.map +1 -1
  25. package/dist/production/src/lib/TemplateInstaller.cjs +24 -5
  26. package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
  27. package/dist/production/src/lib/TemplateInstaller.js +24 -5
  28. package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
  29. package/dist/production/src/lib/packageManagerDetector.cjs +22 -0
  30. package/dist/production/src/lib/packageManagerDetector.cjs.map +1 -0
  31. package/dist/production/src/lib/packageManagerDetector.js +22 -0
  32. package/dist/production/src/lib/packageManagerDetector.js.map +1 -0
  33. package/dist/types/commands/WorkspaceCreateCommand.d.ts +4 -2
  34. package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
  35. package/dist/types/lib/FileSystem.d.ts +1 -0
  36. package/dist/types/lib/FileSystem.d.ts.map +1 -1
  37. package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
  38. package/dist/types/lib/packageManagerDetector.d.ts +3 -0
  39. package/dist/types/lib/packageManagerDetector.d.ts.map +1 -0
  40. package/dist/types/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +7 -3
  42. package/resources/templates/default/.gitignore.dist +154 -0
  43. package/resources/templates/default/README.md +98 -0
  44. package/resources/templates/{template-workspace → default}/admin/.env.development +1 -0
  45. package/resources/templates/{template-workspace → default}/admin/app/components/layout.tsx +7 -3
  46. package/resources/templates/default/admin/app/components/navigation.tsx +85 -0
  47. package/resources/templates/{template-workspace → default}/admin/app/index.tsx +4 -4
  48. package/resources/templates/default/admin/app/pages/tenant.tsx +160 -0
  49. package/resources/templates/default/admin/entrypoint/components/layout.tsx +14 -0
  50. package/resources/templates/default/admin/entrypoint/components/logged-in.tsx +47 -0
  51. package/resources/templates/default/admin/entrypoint/components/login.tsx +103 -0
  52. package/resources/templates/default/admin/entrypoint/config.ts +35 -0
  53. package/resources/templates/default/admin/entrypoint/contexts/login.tsx +18 -0
  54. package/resources/templates/default/admin/entrypoint/index.tsx +12 -0
  55. package/resources/templates/default/admin/entrypoint/login-entrypoint.tsx +24 -0
  56. package/resources/templates/default/admin/entrypoint/pages/index.tsx +48 -0
  57. package/resources/templates/default/admin/entrypoint/pages/magicLink.tsx +56 -0
  58. package/resources/templates/default/admin/entrypoint/pages/magicLintSent.tsx +63 -0
  59. package/resources/templates/default/admin/entrypoint/pages/passwordReset.tsx +44 -0
  60. package/resources/templates/default/admin/entrypoint/pages/resetRequest.tsx +35 -0
  61. package/resources/templates/default/admin/entrypoint/pages/resetRequestSuccess.tsx +34 -0
  62. package/resources/templates/default/admin/index.css +94 -0
  63. package/resources/templates/{template-workspace → default}/admin/index.html +1 -1
  64. package/resources/templates/{template-workspace → default}/admin/lib/block-repeater/block-repeater.tsx +4 -4
  65. package/resources/templates/{template-workspace → default}/admin/lib/board/board.tsx +3 -3
  66. package/resources/templates/{template-workspace → default}/admin/lib/datagrid/cells.tsx +47 -0
  67. package/resources/templates/{template-workspace → default}/admin/lib/datagrid/column-header.tsx +1 -1
  68. package/resources/templates/{template-workspace → default}/admin/lib/datagrid/columns.tsx +72 -9
  69. package/resources/templates/default/admin/lib/datagrid/elements.tsx +59 -0
  70. package/resources/templates/{template-workspace → default}/admin/lib/datagrid/empty.tsx +1 -1
  71. package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/date.tsx +4 -4
  72. package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/enum.tsx +37 -0
  73. package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/relation.tsx +1 -1
  74. package/resources/templates/{template-workspace → default}/admin/lib/datagrid/pagination.tsx +1 -1
  75. package/resources/templates/{template-workspace → default}/admin/lib/datagrid/table.tsx +1 -1
  76. package/resources/templates/{template-workspace → default}/admin/lib/datagrid/ui.tsx +4 -4
  77. package/resources/templates/{template-workspace → default}/admin/lib/dimensions/dimensions.tsx +2 -2
  78. package/resources/templates/{template-workspace → default}/admin/lib/editor/common/editor-block-toolbar.tsx +1 -1
  79. package/resources/templates/{template-workspace → default}/admin/lib/editor/common/editor-canvas.tsx +2 -2
  80. package/resources/templates/{template-workspace → default}/admin/lib/editor/common/editor-inline-toolbar.tsx +1 -1
  81. package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/BlockElement.tsx +2 -2
  82. package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/TableCellElementRenderer.tsx +1 -1
  83. package/resources/templates/{template-workspace → default}/admin/lib/editor/editor-block.tsx +1 -1
  84. package/resources/templates/{template-workspace → default}/admin/lib/editor/sortable-block.tsx +1 -1
  85. package/resources/templates/{template-workspace → default}/admin/lib/form/container.tsx +2 -1
  86. package/resources/templates/{template-workspace → default}/admin/lib/layout/layout-boxed.tsx +4 -4
  87. package/resources/templates/{template-workspace → default}/admin/lib/repeater/repeater.tsx +3 -3
  88. package/resources/templates/{template-workspace → default}/admin/lib/select/ui.tsx +5 -5
  89. package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/common.tsx +1 -1
  90. package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/memberships-control.tsx +1 -1
  91. package/resources/templates/{template-workspace → default}/admin/lib/tenant/otp/otp-setup.tsx +1 -1
  92. package/resources/templates/{template-workspace → default}/admin/lib/toast/toast.tsx +4 -5
  93. package/resources/templates/{template-workspace → default}/admin/lib/ui/button.tsx +6 -6
  94. package/resources/templates/{template-workspace → default}/admin/lib/ui/card.tsx +1 -1
  95. package/resources/templates/{template-workspace → default}/admin/lib/ui/dialog.tsx +2 -2
  96. package/resources/templates/{template-workspace → default}/admin/lib/ui/dropdown.tsx +6 -6
  97. package/resources/templates/{template-workspace → default}/admin/lib/ui/input.tsx +11 -11
  98. package/resources/templates/{template-workspace → default}/admin/lib/ui/overlay.tsx +1 -1
  99. package/resources/templates/{template-workspace → default}/admin/lib/ui/popover.tsx +1 -1
  100. package/resources/templates/{template-workspace → default}/admin/lib/ui/property-list.tsx +3 -3
  101. package/resources/templates/{template-workspace → default}/admin/lib/ui/select.tsx +3 -3
  102. package/resources/templates/{template-workspace → default}/admin/lib/ui/sheet.tsx +4 -4
  103. package/resources/templates/{template-workspace → default}/admin/lib/ui/sidebar.tsx +15 -16
  104. package/resources/templates/{template-workspace → default}/admin/lib/ui/sortable.tsx +1 -1
  105. package/resources/templates/{template-workspace → default}/admin/lib/ui/switch.tsx +1 -1
  106. package/resources/templates/{template-workspace → default}/admin/lib/ui/table.tsx +3 -3
  107. package/resources/templates/{template-workspace → default}/admin/lib/ui/textarea.tsx +3 -3
  108. package/resources/templates/{template-workspace → default}/admin/lib/ui/toggle.tsx +2 -3
  109. package/resources/templates/{template-workspace → default}/admin/lib/ui/tooltip.tsx +2 -2
  110. package/resources/templates/{template-workspace → default}/admin/lib/upload/ui.tsx +4 -4
  111. package/resources/templates/{template-workspace → default}/admin/lib/upload/upload-progress.tsx +1 -1
  112. package/resources/templates/{template-workspace → default}/admin/lib/upload/view.tsx +3 -3
  113. package/resources/templates/{template-workspace → default}/admin/lib/utils/uic.tsx +30 -23
  114. package/resources/templates/{template-workspace → default}/admin/package.json +6 -3
  115. package/resources/templates/default/admin/postcss.config.js +5 -0
  116. package/resources/templates/default/admin/sentry.ts +26 -0
  117. package/resources/templates/{template-workspace → default}/admin/tsconfig.json +1 -9
  118. package/resources/templates/default/admin/vite-env.d.ts +12 -0
  119. package/resources/templates/default/admin/vite.config.ts +11 -0
  120. package/resources/templates/default/api/README.md +87 -0
  121. package/resources/templates/{template-workspace → default}/biome.json +1 -1
  122. package/resources/templates/default/client/README.md +285 -0
  123. package/resources/templates/{template-workspace → default}/contember.template.yaml +5 -0
  124. package/resources/templates/{template-workspace → default}/package.json +2 -2
  125. package/resources/templates/default/scripts/generate-client.sh +7 -0
  126. package/resources/templates/default/scripts/update-ui-lib.sh +344 -0
  127. package/src/commands/WorkspaceCreateCommand.ts +41 -24
  128. package/src/lib/FileSystem.ts +1 -0
  129. package/src/lib/TemplateInstaller.ts +30 -7
  130. package/src/lib/packageManagerDetector.ts +24 -0
  131. package/resources/templates/template-workspace/.gitignore.dist +0 -3
  132. package/resources/templates/template-workspace/admin/app/components/navigation.tsx +0 -1
  133. package/resources/templates/template-workspace/admin/index.css +0 -53
  134. package/resources/templates/template-workspace/admin/index.tsx +0 -268
  135. package/resources/templates/template-workspace/admin/lib/datagrid/elements.tsx +0 -48
  136. package/resources/templates/template-workspace/admin/postcss.config.js +0 -6
  137. package/resources/templates/template-workspace/admin/tailwind.config.js +0 -73
  138. package/resources/templates/template-workspace/admin/vite-env.d.ts +0 -7
  139. package/resources/templates/template-workspace/scripts/generate-client.sh +0 -8
  140. /package/resources/templates/{template-workspace → default}/.github/scripts/setup-actions-variables.sh +0 -0
  141. /package/resources/templates/{template-workspace → default}/.github/workflows/deploy.yaml +0 -0
  142. /package/resources/templates/{template-workspace → default}/admin/app/components/logo.tsx +0 -0
  143. /package/resources/templates/{template-workspace → default}/admin/app/config.ts +0 -0
  144. /package/resources/templates/{template-workspace → default}/admin/app/index.html +0 -0
  145. /package/resources/templates/{template-workspace → default}/admin/app/pages/index.tsx +0 -0
  146. /package/resources/templates/{template-workspace → default}/admin/lib/binding/binding.tsx +0 -0
  147. /package/resources/templates/{template-workspace → default}/admin/lib/binding/delete.tsx +0 -0
  148. /package/resources/templates/{template-workspace → default}/admin/lib/binding/hooks.tsx +0 -0
  149. /package/resources/templates/{template-workspace → default}/admin/lib/binding/identity.tsx +0 -0
  150. /package/resources/templates/{template-workspace → default}/admin/lib/binding/index.ts +0 -0
  151. /package/resources/templates/{template-workspace → default}/admin/lib/binding/navigation-guard-dialog.tsx +0 -0
  152. /package/resources/templates/{template-workspace → default}/admin/lib/binding/persist.tsx +0 -0
  153. /package/resources/templates/{template-workspace → default}/admin/lib/block-repeater/index.ts +0 -0
  154. /package/resources/templates/{template-workspace → default}/admin/lib/board/index.ts +0 -0
  155. /package/resources/templates/{template-workspace → default}/admin/lib/buttons/back-button.tsx +0 -0
  156. /package/resources/templates/{template-workspace → default}/admin/lib/buttons/index.ts +0 -0
  157. /package/resources/templates/{template-workspace → default}/admin/lib/buttons/link-back-button.tsx +0 -0
  158. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/column-leaf.tsx +0 -0
  159. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/export.tsx +0 -0
  160. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/boolean.tsx +0 -0
  161. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/common.tsx +0 -0
  162. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/defined.tsx +0 -0
  163. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/index.ts +0 -0
  164. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/mobile.tsx +0 -0
  165. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/number.tsx +0 -0
  166. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/filters/text.tsx +0 -0
  167. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/grid.tsx +0 -0
  168. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/index.ts +0 -0
  169. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/labels.tsx +0 -0
  170. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/layout-switcher.tsx +0 -0
  171. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/loader.tsx +0 -0
  172. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/tiles.tsx +0 -0
  173. /package/resources/templates/{template-workspace → default}/admin/lib/datagrid/toolbar.tsx +0 -0
  174. /package/resources/templates/{template-workspace → default}/admin/lib/dev/index.ts +0 -0
  175. /package/resources/templates/{template-workspace → default}/admin/lib/dev/login-panel.tsx +0 -0
  176. /package/resources/templates/{template-workspace → default}/admin/lib/dev/todo.tsx +0 -0
  177. /package/resources/templates/{template-workspace → default}/admin/lib/dict.ts +0 -0
  178. /package/resources/templates/{template-workspace → default}/admin/lib/dimensions/index.ts +0 -0
  179. /package/resources/templates/{template-workspace → default}/admin/lib/editor/block-editor.tsx +0 -0
  180. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/baseEditorPlugins.tsx +0 -0
  181. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/buttons.tsx +0 -0
  182. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/editor-editable-canvas.tsx +0 -0
  183. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/AnchorRenderer.tsx +0 -0
  184. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/HeadingRenderer.tsx +0 -0
  185. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +0 -0
  186. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/ListItemRenderer.tsx +0 -0
  187. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/OrderedListRenderer.tsx +0 -0
  188. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/ParagraphRenderer.tsx +0 -0
  189. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/ScrollTargetRenderer.tsx +0 -0
  190. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/TableElementRenderer.tsx +0 -0
  191. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/TableRowElementRenderer.tsx +0 -0
  192. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +0 -0
  193. /package/resources/templates/{template-workspace → default}/admin/lib/editor/common/index.ts +0 -0
  194. /package/resources/templates/{template-workspace → default}/admin/lib/editor/index.ts +0 -0
  195. /package/resources/templates/{template-workspace → default}/admin/lib/editor/plugins.tsx +0 -0
  196. /package/resources/templates/{template-workspace → default}/admin/lib/editor/rich-text-view.tsx +0 -0
  197. /package/resources/templates/{template-workspace → default}/admin/lib/editor/rich-text.tsx +0 -0
  198. /package/resources/templates/{template-workspace → default}/admin/lib/errors/error-boundary.tsx +0 -0
  199. /package/resources/templates/{template-workspace → default}/admin/lib/errors/index.ts +0 -0
  200. /package/resources/templates/{template-workspace → default}/admin/lib/errors/use-error-formatter.ts +0 -0
  201. /package/resources/templates/{template-workspace → default}/admin/lib/field/formatted-field.tsx +0 -0
  202. /package/resources/templates/{template-workspace → default}/admin/lib/field/index.ts +0 -0
  203. /package/resources/templates/{template-workspace → default}/admin/lib/form/index.ts +0 -0
  204. /package/resources/templates/{template-workspace → default}/admin/lib/form/inputs.tsx +0 -0
  205. /package/resources/templates/{template-workspace → default}/admin/lib/form/labels.tsx +0 -0
  206. /package/resources/templates/{template-workspace → default}/admin/lib/form/select.tsx +0 -0
  207. /package/resources/templates/{template-workspace → default}/admin/lib/form/ui.tsx +0 -0
  208. /package/resources/templates/{template-workspace → default}/admin/lib/form/upload-repeaters.tsx +0 -0
  209. /package/resources/templates/{template-workspace → default}/admin/lib/form/upload.tsx +0 -0
  210. /package/resources/templates/{template-workspace → default}/admin/lib/formatting/formatting.ts +0 -0
  211. /package/resources/templates/{template-workspace → default}/admin/lib/formatting/index.ts +0 -0
  212. /package/resources/templates/{template-workspace → default}/admin/lib/images/formatImageResizeUrl.ts +0 -0
  213. /package/resources/templates/{template-workspace → default}/admin/lib/images/index.ts +0 -0
  214. /package/resources/templates/{template-workspace → default}/admin/lib/labels/enum-labels.ts +0 -0
  215. /package/resources/templates/{template-workspace → default}/admin/lib/labels/field-labels.ts +0 -0
  216. /package/resources/templates/{template-workspace → default}/admin/lib/labels/index.ts +0 -0
  217. /package/resources/templates/{template-workspace → default}/admin/lib/layout/index.ts +0 -0
  218. /package/resources/templates/{template-workspace → default}/admin/lib/layout/layout.tsx +0 -0
  219. /package/resources/templates/{template-workspace → default}/admin/lib/layout/slots.tsx +0 -0
  220. /package/resources/templates/{template-workspace → default}/admin/lib/outdated-application-dialog/index.ts +0 -0
  221. /package/resources/templates/{template-workspace → default}/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +0 -0
  222. /package/resources/templates/{template-workspace → default}/admin/lib/repeater/index.ts +0 -0
  223. /package/resources/templates/{template-workspace → default}/admin/lib/select/create-new.tsx +0 -0
  224. /package/resources/templates/{template-workspace → default}/admin/lib/select/filter.tsx +0 -0
  225. /package/resources/templates/{template-workspace → default}/admin/lib/select/highlight.tsx +0 -0
  226. /package/resources/templates/{template-workspace → default}/admin/lib/select/index.ts +0 -0
  227. /package/resources/templates/{template-workspace → default}/admin/lib/select/list.tsx +0 -0
  228. /package/resources/templates/{template-workspace → default}/admin/lib/select/multi-select.tsx +0 -0
  229. /package/resources/templates/{template-workspace → default}/admin/lib/select/select.tsx +0 -0
  230. /package/resources/templates/{template-workspace → default}/admin/lib/select/sortable-select.tsx +0 -0
  231. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/change-my-password.tsx +0 -0
  232. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/create-api-key.tsx +0 -0
  233. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/index.ts +0 -0
  234. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/invite.tsx +0 -0
  235. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/login.tsx +0 -0
  236. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/password-reset-request.tsx +0 -0
  237. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/password-reset.tsx +0 -0
  238. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/passwordless-signin-init.tsx +0 -0
  239. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/passwordless-signin.tsx +0 -0
  240. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/forms/update-project-member.tsx +0 -0
  241. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/hooks/useInvite.ts +0 -0
  242. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/hooks/useInviteUser.tsx +0 -0
  243. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/index.ts +0 -0
  244. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/listing/api-key-list.tsx +0 -0
  245. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/listing/index.ts +0 -0
  246. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/listing/member-delete-dialog.tsx +0 -0
  247. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/listing/member-list.tsx +0 -0
  248. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/listing/person-list.tsx +0 -0
  249. /package/resources/templates/{template-workspace → default}/admin/lib/tenant/otp/index.ts +0 -0
  250. /package/resources/templates/{template-workspace → default}/admin/lib/toast/index.ts +0 -0
  251. /package/resources/templates/{template-workspace → default}/admin/lib/toast/toaster.tsx +0 -0
  252. /package/resources/templates/{template-workspace → default}/admin/lib/ui/alert-dialog.tsx +0 -0
  253. /package/resources/templates/{template-workspace → default}/admin/lib/ui/avatar.tsx +0 -0
  254. /package/resources/templates/{template-workspace → default}/admin/lib/ui/collapsible.tsx +0 -0
  255. /package/resources/templates/{template-workspace → default}/admin/lib/ui/divider.tsx +0 -0
  256. /package/resources/templates/{template-workspace → default}/admin/lib/ui/label.tsx +0 -0
  257. /package/resources/templates/{template-workspace → default}/admin/lib/ui/loader.tsx +0 -0
  258. /package/resources/templates/{template-workspace → default}/admin/lib/ui/menu.tsx +0 -0
  259. /package/resources/templates/{template-workspace → default}/admin/lib/ui/progress.tsx +0 -0
  260. /package/resources/templates/{template-workspace → default}/admin/lib/ui/scroll-area.tsx +0 -0
  261. /package/resources/templates/{template-workspace → default}/admin/lib/ui/separator.tsx +0 -0
  262. /package/resources/templates/{template-workspace → default}/admin/lib/ui/skeleton.tsx +0 -0
  263. /package/resources/templates/{template-workspace → default}/admin/lib/ui/toggle-group.tsx +0 -0
  264. /package/resources/templates/{template-workspace → default}/admin/lib/upload/dropzone.tsx +0 -0
  265. /package/resources/templates/{template-workspace → default}/admin/lib/upload/index.ts +0 -0
  266. /package/resources/templates/{template-workspace → default}/admin/lib/upload/repeater.tsx +0 -0
  267. /package/resources/templates/{template-workspace → default}/admin/lib/utils/cn.ts +0 -0
  268. /package/resources/templates/{template-workspace → default}/admin/lib/utils/createComponentOpenHooks.tsx +0 -0
  269. /package/resources/templates/{template-workspace → default}/admin/lib/utils/index.ts +0 -0
  270. /package/resources/templates/{template-workspace → default}/admin/lib/utils/use-mobile.ts +0 -0
  271. /package/resources/templates/{template-workspace → default}/admin/public/favicon.png +0 -0
  272. /package/resources/templates/{template-workspace → default}/api/index.ts +0 -0
  273. /package/resources/templates/{template-workspace → default}/api/migrations/.gitkeep +0 -0
  274. /package/resources/templates/{template-workspace → default}/api/model/index.ts +0 -0
  275. /package/resources/templates/{template-workspace → default}/api/package.json +0 -0
  276. /package/resources/templates/{template-workspace → default}/api/tsconfig.json +0 -0
  277. /package/resources/templates/{template-workspace → default}/client/package.json +0 -0
  278. /package/resources/templates/{template-workspace → default}/client/src/index.ts +0 -0
  279. /package/resources/templates/{template-workspace → default}/client/tsconfig.json +0 -0
  280. /package/resources/templates/{template-workspace → default}/docker-compose.yaml +0 -0
  281. /package/resources/templates/{template-workspace → default}/tsconfig.json +0 -0
  282. /package/resources/templates/{template-workspace → default}/tsconfig.settings.json +0 -0
@@ -0,0 +1,98 @@
1
+ # My awesome multilingual CMS
2
+
3
+ Welcome to your new project created with [Contember AI Studio](https://www.contember.com/studio)! If you need
4
+ assistance, feel free to join the conversation in
5
+ our [GitHub Discussions](https://github.com/orgs/contember/discussions/categories/support).
6
+
7
+ ## Getting Started
8
+
9
+ Before you begin, ensure you have:
10
+
11
+ - [Yarn](https://yarnpkg.com/getting-started/install) installed
12
+ - [Docker](https://docs.docker.com/get-docker/) installed and running
13
+
14
+ ### Project Overview
15
+
16
+ Your project consists of the following packages:
17
+
18
+ #### [@app/admin](./admin)
19
+
20
+ - **Location:** `./admin`
21
+ - **Description:** A React SPA that serves as the administration UI, built with Contember DataBinding for seamless integration with the Contember API.
22
+ - **Sentry:** [Sentry](https://sentry.io) is integrated into the project. To enable Sentry, set the `VITE_SENTRY_DSN` environment variable in the `.env.production` file.
23
+
24
+ #### [@app/api](./api)
25
+
26
+ - **Location:** `./api`
27
+ - **Description:** Defines the data model and permissions for the Contember API.
28
+
29
+ #### [@app/client](./client)
30
+
31
+ - **Location:** `./client`
32
+ - **Description:** A type-safe GraphQL client for interacting with the Contember API, complete with generated types.
33
+ - **Documentation:** [Client Documentation](./client/README.md)
34
+
35
+ #### [@app/worker](./worker)
36
+
37
+ - **Location:** `./worker`
38
+ - **Description:** A serverless function deployed to Cloudflare Workers for executing server-side operations.
39
+ - **Documentation:** [Worker Documentation](./worker/README.md)
40
+
41
+ - - -
42
+
43
+ ## Running the Project Locally
44
+
45
+ Follow these steps to set up and run your project locally:
46
+
47
+ 1. **Install Dependencies**
48
+
49
+ Run the following command to install all required dependencies:
50
+ ```bash
51
+ {packageManager} install
52
+ ```
53
+
54
+ 2. **Start the Project**
55
+
56
+ Start the admin application and all necessary services with:
57
+ ```bash
58
+ {packageManager} run start
59
+ ```
60
+
61
+ This will launch the following components:
62
+
63
+ | Container | Port | Url |
64
+ |------------------|------|------------------------------------------------|
65
+ | Contember Engine | 1481 | [http://localhost:1481](http://localhost:1481) |
66
+ | Postgres | 1482 | [http://localhost:1482](http://localhost:1482) |
67
+ | S3 | 1483 | [http://localhost:1483](http://localhost:1483) |
68
+ | MailPit | 1484 | [http://localhost:1484](http://localhost:1484) |
69
+ | Adminer | 1485 | [http://localhost:1485](http://localhost:1485) |
70
+ | S3 Dashboard | 1486 | [http://localhost:1486](http://localhost:1486) |
71
+
72
+ When you're done, stop the Docker containers with:
73
+
74
+ ```bash
75
+ docker compose down
76
+ ```
77
+
78
+ - - -
79
+
80
+ ## Next Steps
81
+
82
+ Congratulations, your project is now running locally! Access the administration UI
83
+ at [http://localhost:1480](http://localhost:1480/).
84
+
85
+ Enjoy building with Contember!
86
+
87
+ - - -
88
+
89
+ ## Update headless UI components
90
+
91
+ To update the headless UI components, run the following command:
92
+
93
+ ```bash
94
+ sh ./scripts/update-ui-lib.sh
95
+ ```
96
+
97
+ This will update `lib` folder in the `@app/admin` package with the latest headless UI components. If you have made any
98
+ changes to the components, make sure to commit them before running this command.
@@ -1,3 +1,4 @@
1
1
  VITE_CONTEMBER_ADMIN_API_BASE_URL=http://localhost:1481
2
2
  VITE_CONTEMBER_ADMIN_SESSION_TOKEN=0000000000000000000000000000000000000000
3
+ VITE_CONTEMBER_ADMIN_LOGIN_TOKEN=1111111111111111111111111111111111111111
3
4
  VITE_CONTEMBER_ADMIN_PROJECT_NAME=app
@@ -1,9 +1,9 @@
1
1
  import { memo, PropsWithChildren } from 'react'
2
- import { IdentityLoader } from '@app/lib/binding'
3
- import { LayoutComponent, Slots } from '@app/lib/layout'
4
- import { Navigation } from './navigation'
2
+ import { Navigation, UserNavigation } from './navigation'
5
3
  import { Link } from '@contember/interface'
6
4
  import { Logo } from './logo'
5
+ import { IdentityLoader } from '~/lib/binding'
6
+ import { LayoutComponent, Slots } from '~/lib/layout'
7
7
 
8
8
  export const Layout = memo(({ children }: PropsWithChildren) => {
9
9
  return (
@@ -20,6 +20,10 @@ export const Layout = memo(({ children }: PropsWithChildren) => {
20
20
  <Navigation />
21
21
  </Slots.Navigation>
22
22
 
23
+ <Slots.UserNavigation>
24
+ <UserNavigation />
25
+ </Slots.UserNavigation>
26
+
23
27
  <Slots.Footer>
24
28
  <p><small>Created with <a className="content-link" href="https://www.contember.com/">Contember</a></small></p>
25
29
  </Slots.Footer>
@@ -0,0 +1,85 @@
1
+ import { Link, LogoutTrigger, useIdentity } from '@contember/interface'
2
+ import { BadgeCheckIcon, BellIcon, ChevronsUpDown, LogOutIcon } from 'lucide-react'
3
+ import { dict } from '~/lib/dict'
4
+ import { Avatar, AvatarFallback } from '~/lib/ui/avatar'
5
+ import { AnchorButton, Button } from '~/lib/ui/button'
6
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from '~/lib/ui/dropdown'
7
+ import { SidebarMenuButton } from '~/lib/ui/sidebar'
8
+ import { useIsMobile } from '~/lib/utils/use-mobile'
9
+
10
+ export const Navigation = () => (<div>Navigation</div>)
11
+
12
+ export const UserNavigation = () => {
13
+ const isMobile = useIsMobile()
14
+ const identity = useIdentity()
15
+
16
+ const userEmail = identity?.person?.email
17
+ const userInitial = userEmail?.substring(0, 1).toLocaleUpperCase()
18
+
19
+ return (
20
+ <DropdownMenu>
21
+ <DropdownMenuTrigger asChild>
22
+ <SidebarMenuButton
23
+ size="lg"
24
+ className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
25
+ >
26
+ <Avatar className="icon h-6 w-6 rounded-lg">
27
+ <AvatarFallback avatarFallbackColorString={userEmail} className="rounded-lg">
28
+ {userInitial}
29
+ </AvatarFallback>
30
+ </Avatar>
31
+ <div className="grid flex-1 text-left text-sm leading-tight">
32
+ <span className="truncate font-semibold">{userEmail}</span>
33
+ </div>
34
+ <ChevronsUpDown className="ml-auto size-4" />
35
+ </SidebarMenuButton>
36
+ </DropdownMenuTrigger>
37
+ <DropdownMenuContent
38
+ className="w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg"
39
+ side={isMobile ? 'bottom' : 'right'}
40
+ align="end"
41
+ sideOffset={4}
42
+ >
43
+ <DropdownMenuLabel className="p-0 font-normal">
44
+ <div className="flex items-center gap-2 pl-3 pr-1 py-1.5 text-left text-sm">
45
+ <Avatar className="h-8 w-8 rounded-lg">
46
+ <AvatarFallback avatarFallbackColorString={userEmail} className="rounded-lg">
47
+ {userInitial}
48
+ </AvatarFallback>
49
+ </Avatar>
50
+ <div className="grid flex-1 text-left text-sm leading-tight">
51
+ <span className="truncate font-semibold">{userEmail}</span>
52
+ </div>
53
+ </div>
54
+ </DropdownMenuLabel>
55
+ <DropdownMenuSeparator />
56
+ <DropdownMenuGroup>
57
+ <DropdownMenuItem>
58
+ <Link to="tenant/security">
59
+ <AnchorButton variant="ghost" size="xs" className="flex gap-2">
60
+ <BadgeCheckIcon size={16} />
61
+ Security
62
+ </AnchorButton>
63
+ </Link>
64
+ </DropdownMenuItem>
65
+ <DropdownMenuItem>
66
+ <Link to="tenant/apiKeys">
67
+ <AnchorButton variant="ghost" size="xs" className="flex gap-2">
68
+ <BellIcon size={16} />
69
+ API keys
70
+ </AnchorButton>
71
+ </Link>
72
+ </DropdownMenuItem>
73
+ </DropdownMenuGroup>
74
+ <DropdownMenuSeparator />
75
+ <DropdownMenuItem>
76
+ <LogoutTrigger>
77
+ <Button variant="ghost" size="xs" className="flex gap-2">
78
+ <LogOutIcon size={16} /> {dict.logout}
79
+ </Button>
80
+ </LogoutTrigger>
81
+ </DropdownMenuItem>
82
+ </DropdownMenuContent>
83
+ </DropdownMenu>
84
+ )
85
+ }
@@ -1,13 +1,13 @@
1
- import { LoginWithEmail } from '../lib/dev'
2
- import { OutdatedApplicationDialog } from '@app/lib/outdated-application-dialog'
3
- import { Toaster } from '@app/lib/toast'
4
1
  import { ApplicationEntrypoint, PageModule, Pages } from '@contember/interface'
5
2
  import { createErrorHandler, DevBar, DevPanel } from '@contember/react-devbar'
6
3
  import { SlotsProvider } from '@contember/react-slots'
7
4
  import { LogInIcon } from 'lucide-react'
8
5
  import { createRoot } from 'react-dom/client'
9
- import { Layout } from './components/layout'
6
+ import { OutdatedApplicationDialog } from '~/lib/outdated-application-dialog'
7
+ import { Toaster } from '~/lib/toast'
10
8
  import '../index.css'
9
+ import { LoginWithEmail } from '../lib/dev'
10
+ import { Layout } from './components/layout'
11
11
  import { getConfig } from './config'
12
12
 
13
13
  const errorHandler = createErrorHandler((dom, react, onRecoverableError) => createRoot(dom, { onRecoverableError }).render(react))
@@ -0,0 +1,160 @@
1
+ import { useProjectSlug } from '@contember/react-client'
2
+ import { ChangeMyPasswordForm, CreateApiKeyForm, InviteForm } from '@contember/react-identity'
3
+ import { KeyRoundIcon, LockKeyholeIcon, UsersIcon } from 'lucide-react'
4
+ import { ReactNode, useRef } from 'react'
5
+ import { Slots } from '~/lib/layout'
6
+ import {
7
+ ApiKeyList,
8
+ ChangeMyPasswordFormFields,
9
+ CreateApiKeyFormFields,
10
+ InviteFormFields,
11
+ MemberListController,
12
+ OtpSetup,
13
+ PersonList,
14
+ } from '~/lib/tenant'
15
+ import { ToastContent, useShowToast } from '~/lib/toast'
16
+ import { Card, CardContent, CardHeader, CardTitle } from '~/lib/ui/card'
17
+ import { Input } from '~/lib/ui/input'
18
+
19
+ const Title = ({ icon, children }: { icon?: ReactNode; children: ReactNode }) => {
20
+ return (
21
+ <div className="flex items-center">
22
+ {icon && <div className="mr-2">{icon}</div>}
23
+ <h1>{children}</h1>
24
+ </div>
25
+ )
26
+ }
27
+
28
+ export const Security = () => {
29
+ const showToast = useShowToast()
30
+
31
+ return (
32
+ <>
33
+ <Slots.Title>
34
+ <Title icon={<LockKeyholeIcon />}>Security</Title>
35
+ </Slots.Title>
36
+
37
+ <div className="flex flex-col gap-4">
38
+ <Card className="w-[40rem] max-w-full">
39
+ <CardHeader>
40
+ <CardTitle className="text-2xl">Change Password</CardTitle>
41
+ </CardHeader>
42
+ <CardContent>
43
+ <ChangeMyPasswordForm onSuccess={() => showToast(
44
+ <ToastContent>Password changed</ToastContent>, { type: 'success' })}>
45
+ <form className="grid gap-4">
46
+ <ChangeMyPasswordFormFields />
47
+ </form>
48
+ </ChangeMyPasswordForm>
49
+ </CardContent>
50
+ </Card>
51
+ <Card className="w-[40rem] max-w-full">
52
+ <CardHeader>
53
+ <CardTitle className="text-2xl">Two-factor setup</CardTitle>
54
+ </CardHeader>
55
+ <CardContent>
56
+ <OtpSetup />
57
+ </CardContent>
58
+ </Card>
59
+ </div>
60
+ </>
61
+ )
62
+ }
63
+
64
+ export const Members = () => {
65
+ const projectSlug = useProjectSlug()!
66
+ const showToast = useShowToast()
67
+ const memberListController = useRef<MemberListController>()
68
+
69
+ return (
70
+ <>
71
+ <Slots.Title>
72
+ <Title icon={<UsersIcon />}>Members</Title>
73
+ </Slots.Title>
74
+
75
+ <div className="flex flex-col gap-4">
76
+ <Card className="w-[40rem] max-w-full">
77
+ <CardHeader>
78
+ <CardTitle className="text-2xl">Invite</CardTitle>
79
+ </CardHeader>
80
+ <CardContent>
81
+ <InviteForm
82
+ projectSlug={projectSlug}
83
+ initialMemberships={[{ role: 'admin', variables: [] }]}
84
+ onSuccess={args => {
85
+ showToast(
86
+ <ToastContent>Invitation sent to {args.result.person?.email}</ToastContent>, { type: 'success' })
87
+ memberListController.current?.refresh()
88
+ }}
89
+ >
90
+ <form>
91
+ <InviteFormFields projectSlug={projectSlug} />
92
+ </form>
93
+ </InviteForm>
94
+ </CardContent>
95
+ </Card>
96
+ <Card className="w-[40rem] max-w-full">
97
+ <CardHeader>
98
+ <CardTitle className="text-2xl">Members</CardTitle>
99
+ </CardHeader>
100
+ <CardContent>
101
+ <PersonList controller={memberListController} />
102
+ </CardContent>
103
+ </Card>
104
+
105
+ </div>
106
+ </>
107
+ )
108
+ }
109
+
110
+ export const ApiKeys = () => {
111
+ const projectSlug = useProjectSlug()!
112
+ const showToast = useShowToast()
113
+ const memberListController = useRef<MemberListController>()
114
+
115
+ return (
116
+ <>
117
+ <Slots.Title>
118
+ <Title icon={<KeyRoundIcon />}>API keys</Title>
119
+ </Slots.Title>
120
+
121
+ <div className="flex flex-col gap-4">
122
+ <div>
123
+ <Card className="w-[40rem] max-w-full">
124
+ <CardHeader>
125
+ <CardTitle className="text-2xl">Create API key</CardTitle>
126
+ </CardHeader>
127
+ <CardContent>
128
+ <CreateApiKeyForm
129
+ projectSlug={projectSlug}
130
+ initialMemberships={[{ role: 'admin', variables: [] }]}
131
+ onSuccess={args => {
132
+ showToast((
133
+ <ToastContent title="API key created">
134
+ <Input value={args.result.apiKey.token} type="text" />
135
+ </ToastContent>
136
+ ), { type: 'success' })
137
+ memberListController.current?.refresh()
138
+ }}
139
+ >
140
+ <form className="grid gap-4">
141
+ <CreateApiKeyFormFields projectSlug={projectSlug} />
142
+ </form>
143
+ </CreateApiKeyForm>
144
+ </CardContent>
145
+ </Card>
146
+ </div>
147
+ <div>
148
+ <Card className="w-[40rem] max-w-full">
149
+ <CardHeader>
150
+ <CardTitle className="text-2xl">API keys</CardTitle>
151
+ </CardHeader>
152
+ <CardContent>
153
+ <ApiKeyList controller={memberListController} />
154
+ </CardContent>
155
+ </Card>
156
+ </div>
157
+ </div>
158
+ </>
159
+ )
160
+ }
@@ -0,0 +1,14 @@
1
+ export const Layout = ({ children }: { children?: React.ReactNode }) => (
2
+ <div className="grid md:grid-cols-2 min-h-screen ">
3
+ <div className="bg-gray-100 p-4 flex items-center justify-center">
4
+ {children}
5
+ </div>
6
+ <div className="bg-gray-700 text-white p-4 flex items-center justify-center">
7
+ <div className="w-full max-w-md">
8
+ <div className="text-center text-2xl">Welcome to your app</div>
9
+ <p className="mt-8 text-center text-gray-300">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec auctor, sem
10
+ eget ultricies ultricies, sapien urna tristique eros, ac tincidunt felis lacus nec nunc.</p>
11
+ </div>
12
+ </div>
13
+ </div>
14
+ )
@@ -0,0 +1,47 @@
1
+ import { useIdentity } from '@contember/react-identity'
2
+ import { useEffect } from 'react'
3
+ import { Card, CardDescription, CardHeader, CardTitle } from '~/lib/ui/card'
4
+ import { Loader } from '~/lib/ui/loader'
5
+
6
+ /**
7
+ * Props for {@link LoggedIn} component
8
+ */
9
+ export type LoggedInProps = {
10
+ /**
11
+ * The URL to redirect to after successful login.
12
+ */
13
+ appUrl: string
14
+ }
15
+
16
+ /**
17
+ * Props {@link LoggedInProps}
18
+ *
19
+ * `LoggedIn` displays a confirmation UI upon successful login and redirects the user to the specified app URL.
20
+ * Must be used in a context where `useIdentity` is available (e.g., inside a Contember admin interface).
21
+ *
22
+ * #### Example: login redirect screen
23
+ * ```tsx
24
+ * <LoggedIn appUrl="https://admin.example.com/dashboard" />
25
+ * ```
26
+ */
27
+ export const LoggedIn = ({ appUrl }: LoggedInProps) => {
28
+ const identity = useIdentity()
29
+
30
+ useEffect(() => {
31
+ setTimeout(() => {
32
+ window.location.href = appUrl
33
+ }, 500)
34
+ }, [appUrl])
35
+
36
+ return (
37
+ <Card className="w-96 relative">
38
+ <CardHeader>
39
+ <CardTitle className="text-2xl">Logged in</CardTitle>
40
+ <CardDescription>
41
+ as {identity?.person?.email ?? 'unknown'}
42
+ </CardDescription>
43
+ </CardHeader>
44
+ <Loader position="static" />
45
+ </Card>
46
+ )
47
+ }
@@ -0,0 +1,103 @@
1
+ import { ToastContent, useShowToast } from '~/lib/toast'
2
+ import { dict } from '~/lib/dict'
3
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '~/lib/ui/card'
4
+ import { AnchorButton, Button } from '~/lib/ui/button'
5
+ import { LoginFormFields } from '~/lib/tenant'
6
+ import { PasswordlessSignInInitFormFields } from '~/lib/tenant/forms/passwordless-signin-init'
7
+ import { Loader } from '~/lib/ui/loader'
8
+ import { useRedirect } from '@contember/react-routing'
9
+ import { IDP, IDPInitTrigger, IDPState, LoginForm, PasswordlessSignInInitForm } from '@contember/react-identity'
10
+
11
+ /**
12
+ * Props for {@link Login} component
13
+ */
14
+ export type LoginProps = {
15
+ /**
16
+ * IDPs to be displayed in the login form
17
+ */
18
+ idps: Record<string, string>
19
+ /**
20
+ * Whether the login form should display a token from environment
21
+ */
22
+ hasTokenFromEnv: boolean
23
+ /**
24
+ * The URL of the application
25
+ */
26
+ appUrl: string
27
+ /**
28
+ * Whether the login form should display a magic link
29
+ */
30
+ magicLink: boolean
31
+ }
32
+
33
+ /**
34
+ * Props {@link LoginProps}
35
+ *
36
+ * `Login` renders a flexible authentication UI supporting multiple identity providers (IDPs), magic link login, and fallback login options.
37
+ * Must be used within a Contember environment where `useShowToast` and `useRedirect` are available.
38
+ *
39
+ * - Supports IDP login (OAuth, SAML, etc.) with customizable labels
40
+ * - Displays errors via toast notifications
41
+ * - Supports magic link (passwordless) login
42
+ * - Optional login as a default user using token from environment
43
+ *
44
+ * #### Example: full-featured login page
45
+ * ```tsx
46
+ * <Login
47
+ * idps={{ github: 'GitHub', google: 'Google' }}
48
+ * hasTokenFromEnv={true}
49
+ * appUrl="https://admin.example.com/dashboard"
50
+ * magicLink={true}
51
+ * />
52
+ * ```
53
+ */
54
+ export const Login = ({ idps, hasTokenFromEnv, appUrl, magicLink }: LoginProps) => {
55
+ const showToast = useShowToast()
56
+ const redirect = useRedirect()
57
+
58
+ return (
59
+ <IDP
60
+ onInitError={error => showToast(<ToastContent>{dict.tenant.login.idpInitError} {error}</ToastContent>, { type: 'error' })}
61
+ onResponseError={error => showToast(
62
+ <ToastContent>{dict.tenant.login.idpResponseError} {error}</ToastContent>, { type: 'error' })}
63
+ >
64
+ <Card className="w-96 relative">
65
+ <CardHeader>
66
+ <CardTitle className="text-2xl">{dict.tenant.login.title}</CardTitle>
67
+ <CardDescription>
68
+ {dict.tenant.login.description}
69
+ </CardDescription>
70
+ </CardHeader>
71
+ <CardContent>
72
+ {hasTokenFromEnv && <AnchorButton href={appUrl} size="lg" className="w-full" variant="destructive">
73
+ Continue as default user
74
+ </AnchorButton>}
75
+ <LoginForm>
76
+ <form className="grid gap-4">
77
+ <LoginFormFields />
78
+ </form>
79
+ </LoginForm>
80
+
81
+ {Object.entries(idps).map(([idp, label]) => (
82
+ <IDPInitTrigger key={idp} identityProvider={idp}>
83
+ <Button variant="outline" className="w-full">
84
+ {label}
85
+ </Button>
86
+ </IDPInitTrigger>
87
+ ))}
88
+
89
+ {magicLink && <PasswordlessSignInInitForm onSuccess={({ result }) => {
90
+ redirect('magicLinkSent(request_id: $requestId)', { requestId: result.requestId })
91
+ }}>
92
+ <form>
93
+ <PasswordlessSignInInitFormFields />
94
+ </form>
95
+ </PasswordlessSignInInitForm>}
96
+ </CardContent>
97
+ <IDPState state={['processing_init', 'processing_response', 'success']}>
98
+ <Loader />
99
+ </IDPState>
100
+ </Card>
101
+ </IDP>
102
+ )
103
+ }
@@ -0,0 +1,35 @@
1
+ import { ContemberClientProps } from '@contember/react-client'
2
+
3
+ /**
4
+ * Configuration for the login entrypoint.
5
+ * Loads environment variables and prepares configuration for the Contember client.
6
+ */
7
+ export const loginEntrypointConfig = (() => {
8
+ const apiBaseUrl = import.meta.env.VITE_CONTEMBER_ADMIN_API_BASE_URL
9
+ const loginToken = import.meta.env.VITE_CONTEMBER_ADMIN_LOGIN_TOKEN
10
+
11
+ if (!apiBaseUrl) {
12
+ throw new Error('VITE_CONTEMBER_ADMIN_API_BASE_URL is not set')
13
+ }
14
+ if (!loginToken) {
15
+ throw new Error('VITE_CONTEMBER_ADMIN_LOGIN_TOKEN is not set')
16
+ }
17
+
18
+ const clientConfig = {
19
+ apiBaseUrl,
20
+ loginToken,
21
+ } satisfies ContemberClientProps
22
+
23
+ // You can add more IDPs here
24
+ const identityProviders = {
25
+ // google: 'Login with Google',
26
+ } satisfies Record<string, string>
27
+
28
+ return {
29
+ ...clientConfig,
30
+ idps: identityProviders,
31
+ appUrl: '/app',
32
+ hasTokenFromEnv: import.meta.env.VITE_CONTEMBER_ADMIN_SESSION_TOKEN !== '__SESSION_TOKEN__',
33
+ magicLink: true,
34
+ }
35
+ })()
@@ -0,0 +1,18 @@
1
+ import { createRequiredContext } from '@contember/react-utils'
2
+ import { PropsWithChildren } from 'react'
3
+
4
+ export type LoginConfig = {
5
+ appUrl: string
6
+ hasTokenFromEnv: boolean
7
+ idps: Record<string, string>
8
+ magicLink: boolean
9
+ }
10
+
11
+ const [LoginConfigContext, useLoginConfig] = createRequiredContext<LoginConfig>('LoginConfigContext')
12
+ export { LoginConfigContext, useLoginConfig }
13
+
14
+ export const LoginConfigProvider = ({ children, ...config }: PropsWithChildren<LoginConfig>) => (
15
+ <LoginConfigContext.Provider value={config}>
16
+ {children}
17
+ </LoginConfigContext.Provider>
18
+ )
@@ -0,0 +1,12 @@
1
+ import { createErrorHandler } from '@contember/react-devbar'
2
+ import { LoginEntrypoint } from './login-entrypoint'
3
+ import { createRoot } from 'react-dom/client'
4
+ import '../index.css'
5
+ import '../sentry'
6
+ import { loginEntrypointConfig } from './config'
7
+
8
+ const errorHandler = createErrorHandler((dom, react, onRecoverableError) => createRoot(dom, { onRecoverableError }).render(react))
9
+
10
+ const rootEl = document.body.appendChild(document.createElement('div'))
11
+
12
+ errorHandler(onRecoverableError => createRoot(rootEl, { onRecoverableError }).render(<LoginEntrypoint {...loginEntrypointConfig} />))
@@ -0,0 +1,24 @@
1
+ import { ContemberClient, ContemberClientProps } from '@contember/react-client'
2
+ import { type PageModule, Pages, RoutingProvider } from '@contember/react-routing'
3
+ import { Toaster } from '~/lib/toast/toast'
4
+ import { Layout } from './components/layout'
5
+ import { type LoginConfig, LoginConfigProvider } from './contexts/login'
6
+
7
+ export type LoginEntrypointProps = ContemberClientProps & LoginConfig
8
+
9
+ export const LoginEntrypoint = ({ appUrl, hasTokenFromEnv, idps, magicLink, apiBaseUrl, sessionToken, loginToken, project, stage }: LoginEntrypointProps) => (
10
+ <ContemberClient apiBaseUrl={apiBaseUrl} sessionToken={sessionToken} loginToken={loginToken} project={project} stage={stage}>
11
+ <LoginConfigProvider appUrl={appUrl} hasTokenFromEnv={hasTokenFromEnv} idps={idps} magicLink={magicLink}>
12
+ <RoutingProvider pageInQuery>
13
+ <Toaster>
14
+ <Pages
15
+ layout={Layout}
16
+ children={import.meta.glob<PageModule>(
17
+ './pages/**/*.tsx',
18
+ { eager: true }
19
+ )} />
20
+ </Toaster>
21
+ </RoutingProvider>
22
+ </LoginConfigProvider>
23
+ </ContemberClient>
24
+ )