@cedarjs/cli 7.1.0-rc.34 → 7.1.1-next.468

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 (194) hide show
  1. package/dist/commands/build/buildHandler.js +2 -1
  2. package/dist/commands/build.js +1 -1
  3. package/dist/commands/check.js +2 -1
  4. package/dist/commands/deploy/baremetal/baremetalHandler.js +364 -73
  5. package/dist/commands/deploy/baremetal/monitors.js +66 -0
  6. package/dist/commands/deploy/baremetal.js +7 -1
  7. package/dist/commands/deploy/flightcontrolHandler.js +1 -1
  8. package/dist/commands/deploy/helpers/deployHandler.js +1 -1
  9. package/dist/commands/deploy/netlify.js +1 -1
  10. package/dist/commands/deploy/renderHandler.js +1 -1
  11. package/dist/commands/deploy/serverlessHandler.js +2 -1
  12. package/dist/commands/deploy/vercel.js +1 -1
  13. package/dist/commands/destroy/handlerHelpers.js +1 -1
  14. package/dist/commands/destroy/page/pageHandler.js +2 -1
  15. package/dist/commands/destroy/scaffold/scaffoldHandler.js +65 -26
  16. package/dist/commands/destroy/sdl/sdlHandler.js +2 -1
  17. package/dist/commands/dev/devHandler.js +3 -4
  18. package/dist/commands/dev/packageWatchCommands.js +8 -3
  19. package/dist/commands/dev.js +1 -1
  20. package/dist/commands/execHandler.js +2 -1
  21. package/dist/commands/experimental/live-queries/liveQueries.js +1 -1
  22. package/dist/commands/experimental/live-queries/liveQueriesHandler.js +3 -3
  23. package/dist/commands/experimental/setupInngest.js +1 -1
  24. package/dist/commands/experimental/setupInngestHandler.js +1 -1
  25. package/dist/commands/experimental/setupOpentelemetry.js +1 -1
  26. package/dist/commands/experimental/setupOpentelemetryHandler.js +2 -1
  27. package/dist/commands/experimental/setupReactCompiler.js +1 -1
  28. package/dist/commands/experimental/setupReactCompilerHandler.js +4 -4
  29. package/dist/commands/experimental/setupRsc.js +1 -1
  30. package/dist/commands/experimental/setupRscHandler.js +2 -1
  31. package/dist/commands/experimental/setupStreamingSsr.js +1 -1
  32. package/dist/commands/experimental/setupStreamingSsrHandler.js +3 -2
  33. package/dist/commands/generate/cell/cell.js +20 -0
  34. package/dist/commands/generate/cell/cellHandler.js +68 -20
  35. package/dist/commands/generate/cell/templates/cell.tsx.template +21 -2
  36. package/dist/commands/generate/cell/templates/cellFragment.tsx.template +43 -0
  37. package/dist/commands/generate/cell/templates/cellList.tsx.template +21 -2
  38. package/dist/commands/generate/cell/templates/storiesFragment.tsx.template +23 -0
  39. package/dist/commands/generate/cell/templates/test.js.template +1 -1
  40. package/dist/commands/generate/cell/templates/testFragment.js.template +30 -0
  41. package/dist/commands/generate/dataMigration/dataMigration.js +2 -1
  42. package/dist/commands/generate/dbAuth/dbAuth.js +6 -2
  43. package/dist/commands/generate/dbAuth/dbAuthHandler.js +80 -17
  44. package/dist/commands/generate/dbAuth/templates/changePassword.tsx.template +131 -0
  45. package/dist/commands/generate/dbAuth/templates/login.oauth.tsx.template +164 -0
  46. package/dist/commands/generate/dbAuth/templates/login.webAuthn.tsx.template +20 -12
  47. package/dist/commands/generate/dbAuth/templates/signup.oauth.tsx.template +147 -0
  48. package/dist/commands/generate/directive/directiveHandler.js +2 -1
  49. package/dist/commands/generate/function/functionHandler.js +2 -1
  50. package/dist/commands/generate/helpers.js +26 -0
  51. package/dist/commands/generate/job/jobHandler.js +2 -1
  52. package/dist/commands/generate/model/modelHandler.js +2 -1
  53. package/dist/commands/generate/ogImage/ogImageHandler.js +2 -1
  54. package/dist/commands/generate/ogImage/templates/ogImage.og.tsx.template +1 -1
  55. package/dist/commands/generate/package/filesTask.js +9 -12
  56. package/dist/commands/generate/package/packageHandler.js +3 -4
  57. package/dist/commands/generate/package/templates/tsconfig.json.template +1 -0
  58. package/dist/commands/generate/page/pageHandler.js +2 -1
  59. package/dist/commands/generate/realtime/realtime.js +1 -1
  60. package/dist/commands/generate/realtime/realtimeHandler.js +2 -9
  61. package/dist/commands/generate/realtime/templates/liveQueries/blank/blank.service.ts.template +12 -4
  62. package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.service.ts.template +2 -2
  63. package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +4 -4
  64. package/dist/commands/generate/scaffold/scaffold.js +1 -1
  65. package/dist/commands/generate/scaffold/scaffoldHandler.js +93 -49
  66. package/dist/commands/generate/scaffold/templates/assets/scaffold.tailwind.css.template +12 -7
  67. package/dist/commands/generate/scaffold/templates/components/EditNameCell.tsx.template +5 -7
  68. package/dist/commands/generate/scaffold/templates/components/NameForm.tsx.template +10 -9
  69. package/dist/commands/generate/scaffold/templates/layouts/NamesScaffoldLayout.tsx.template +18 -0
  70. package/dist/commands/generate/scaffold/templates/lib/formatters.test.tsx.template +11 -0
  71. package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +16 -4
  72. package/dist/commands/generate/script/scriptHandler.js +2 -1
  73. package/dist/commands/generate/script/templates/tsconfig.json.template +1 -0
  74. package/dist/commands/generate/sdl/sdlHandler.js +10 -4
  75. package/dist/commands/generate/secret/secret.js +1 -1
  76. package/dist/commands/generate/service/serviceHandler.js +79 -49
  77. package/dist/commands/generate/service/templates/service.ts.template +40 -13
  78. package/dist/commands/generate/service/templates/test.ts.template +8 -6
  79. package/dist/commands/generate/yargsCommandHelpers.js +1 -1
  80. package/dist/commands/generate/yargsHandlerHelpers.js +2 -1
  81. package/dist/commands/generate.js +1 -1
  82. package/dist/commands/info.js +1 -1
  83. package/dist/commands/jobsHandler.js +5 -3
  84. package/dist/commands/lint.js +1 -1
  85. package/dist/commands/prerenderHandler.js +11 -4
  86. package/dist/commands/prismaHandler.js +7 -2
  87. package/dist/commands/record/init.js +1 -1
  88. package/dist/commands/serve.js +2 -1
  89. package/dist/commands/setup/auth/auth.js +2 -4
  90. package/dist/commands/setup/cache/cache.js +1 -1
  91. package/dist/commands/setup/cache/cacheHandler.js +2 -1
  92. package/dist/commands/setup/cache/templates/memcached.ts.template +14 -17
  93. package/dist/commands/setup/cache/templates/redis.ts.template +12 -20
  94. package/dist/commands/setup/database/postgres.js +1 -1
  95. package/dist/commands/setup/database/postgresHandler.js +3 -1
  96. package/dist/commands/setup/deploy/providers/baremetal.js +7 -0
  97. package/dist/commands/setup/deploy/providers/baremetalHandler.js +130 -21
  98. package/dist/commands/setup/deploy/providers/coherence.js +1 -1
  99. package/dist/commands/setup/deploy/providers/coherenceHandler.js +7 -6
  100. package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +2 -1
  101. package/dist/commands/setup/deploy/providers/netlifyHandler.js +2 -1
  102. package/dist/commands/setup/deploy/providers/renderHandler.js +2 -1
  103. package/dist/commands/setup/deploy/providers/serverlessHandler.js +2 -1
  104. package/dist/commands/setup/deploy/providers/universalDeployHandler.js +4 -6
  105. package/dist/commands/setup/deploy/providers/vercelHandler.js +2 -1
  106. package/dist/commands/setup/deploy/templates/baremetal.js +119 -9
  107. package/dist/commands/setup/deploy/templates/netlifyUD.js +3 -0
  108. package/dist/commands/setup/docker/docker.js +1 -1
  109. package/dist/commands/setup/docker/dockerHandler.js +2 -1
  110. package/dist/commands/setup/generator/generator.js +1 -1
  111. package/dist/commands/setup/generator/generatorHandler.js +1 -1
  112. package/dist/commands/setup/graphql/features/fragments/fragments.js +1 -1
  113. package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +3 -5
  114. package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +1 -1
  115. package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +2 -1
  116. package/dist/commands/setup/i18n/i18n.js +1 -1
  117. package/dist/commands/setup/i18n/i18nHandler.js +1 -1
  118. package/dist/commands/setup/jobs/jobs.js +1 -1
  119. package/dist/commands/setup/jobs/jobsHandler.js +4 -1
  120. package/dist/commands/setup/mailer/mailer.js +1 -1
  121. package/dist/commands/setup/mailer/mailerHandler.js +2 -1
  122. package/dist/commands/setup/middleware/ogImage/ogImage.js +1 -1
  123. package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +2 -1
  124. package/dist/commands/setup/monitoring/sentry/sentry.js +1 -1
  125. package/dist/commands/setup/monitoring/sentry/sentryHandler.js +13 -9
  126. package/dist/commands/setup/monitoring/sentry/templates/sentryApi.ts.template +1 -4
  127. package/dist/commands/setup/monitoring/sentry/templates/sentryWeb.ts.template +7 -4
  128. package/dist/commands/setup/neon/neon.js +1 -1
  129. package/dist/commands/setup/neon/neonHandler.js +5 -9
  130. package/dist/commands/setup/package/package.js +1 -1
  131. package/dist/commands/setup/package/packageHandler.js +4 -4
  132. package/dist/commands/setup/realtime/addRealtimeToGraphql.js +1 -1
  133. package/dist/commands/setup/realtime/realtime.js +1 -1
  134. package/dist/commands/setup/realtime/realtimeHandler.js +4 -16
  135. package/dist/commands/setup/realtime/templates/defer/fastAndSlowFields/fastAndSlowFields.ts.template +4 -1
  136. package/dist/commands/setup/realtime/templates/liveQueries/auctions/auctions.ts.template +12 -4
  137. package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +1 -1
  138. package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +2 -2
  139. package/dist/commands/setup/server-file/serverFile.js +1 -1
  140. package/dist/commands/setup/server-file/serverFileHandler.js +2 -1
  141. package/dist/commands/setup/tenancy/authCodemod.js +66 -0
  142. package/dist/commands/setup/tenancy/dbCodemod.js +64 -0
  143. package/dist/commands/setup/tenancy/graphqlCodemod.js +88 -0
  144. package/dist/commands/setup/tenancy/preflight.js +49 -0
  145. package/dist/commands/setup/tenancy/schemaPrisma.js +81 -0
  146. package/dist/commands/setup/tenancy/signupCodemod.js +154 -0
  147. package/dist/commands/setup/tenancy/templates/InvitePage.tsx.template +72 -0
  148. package/dist/commands/setup/tenancy/templates/OrgScope.tsx.template +40 -0
  149. package/dist/commands/setup/tenancy/templates/ensureDefaultOrganizations.dataMigration.ts.template +39 -0
  150. package/dist/commands/setup/tenancy/templates/organizations.scenarios.ts.template +57 -0
  151. package/dist/commands/setup/tenancy/templates/organizations.sdl.ts.template +89 -0
  152. package/dist/commands/setup/tenancy/templates/organizations.test.ts.template +381 -0
  153. package/dist/commands/setup/tenancy/templates/organizations.ts.template +394 -0
  154. package/dist/commands/setup/tenancy/templates/requireMembership.test.ts.template +35 -0
  155. package/dist/commands/setup/tenancy/templates/requireMembership.ts.template +25 -0
  156. package/dist/commands/setup/tenancy/tenancy.js +30 -0
  157. package/dist/commands/setup/tenancy/tenancyHandler.js +425 -0
  158. package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +2 -1
  159. package/dist/commands/setup/ui/libraries/mantineHandler.js +2 -1
  160. package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +63 -82
  161. package/dist/commands/setup/uploads/gitignore.js +17 -0
  162. package/dist/commands/setup/uploads/schemaPrisma.js +41 -0
  163. package/dist/commands/setup/uploads/serverFile.js +217 -0
  164. package/dist/commands/setup/uploads/templates/requireUploadToken.ts.template +15 -0
  165. package/dist/commands/setup/uploads/templates/srcLibUploads.ts.template +23 -24
  166. package/dist/commands/setup/uploads/templates/uploads.sdl.ts.template +79 -0
  167. package/dist/commands/setup/uploads/templates/uploads.ts.template +98 -0
  168. package/dist/commands/setup/uploads/templates/withDataUri.ts.template +14 -0
  169. package/dist/commands/setup/uploads/templates/withSignedUrl.ts.template +16 -0
  170. package/dist/commands/setup/uploads/uploads.js +49 -7
  171. package/dist/commands/setup/uploads/uploadsHandler.js +277 -69
  172. package/dist/commands/setup.js +2 -1
  173. package/dist/commands/studio.js +1 -1
  174. package/dist/commands/test/testHandler.js +25 -71
  175. package/dist/commands/test/viteVersionCheck.js +75 -0
  176. package/dist/commands/test.js +10 -18
  177. package/dist/commands/type-checkHandler.js +1 -1
  178. package/dist/commands/upgrade/preUpgradeScripts.js +3 -3
  179. package/dist/commands/upgrade/upgrade.js +1 -1
  180. package/dist/commands/upgrade/upgradeHandler.js +2 -1
  181. package/dist/index.js +5 -8
  182. package/dist/lib/exit.js +1 -1
  183. package/dist/lib/index.js +16 -31
  184. package/dist/lib/loadEnvFiles.js +1 -1
  185. package/dist/lib/plugin.js +1 -1
  186. package/dist/lib/test.js +1 -1
  187. package/dist/lib/updateCheck.js +4 -4
  188. package/dist/middleware/checkNodeVersion.js +4 -4
  189. package/package.json +27 -27
  190. package/dist/commands/setup/ui/templates/postcss.config.cjs.template +0 -9
  191. package/dist/commands/setup/uploads/dbCodemod.js +0 -28
  192. package/dist/commands/setup/uploads/templates/signedUrl.ts.template +0 -21
  193. package/dist/commands/test/testHandlerEsm.js +0 -109
  194. package/dist/commands/testEsm.js +0 -41
@@ -17,7 +17,7 @@ import { useAuth } from 'src/auth'
17
17
  const WELCOME_MESSAGE = 'Welcome back!'
18
18
  const REDIRECT = routes.home()
19
19
 
20
- const LoginPage = ({ type }) => {
20
+ const LoginPage = ({ type }: { type?: string }) => {
21
21
  const {
22
22
  isAuthenticated,
23
23
  client: webAuthn,
@@ -27,12 +27,12 @@ const LoginPage = ({ type }) => {
27
27
  } = useAuth()
28
28
  const [shouldShowWebAuthn, setShouldShowWebAuthn] = useState(false)
29
29
  const [showWebAuthn, setShowWebAuthn] = useState(
30
- webAuthn.isEnabled() && type !== 'password'
30
+ !!webAuthn?.isEnabled() && type !== 'password'
31
31
  )
32
32
 
33
33
  // should redirect right after login or wait to show the webAuthn prompts?
34
34
  useEffect(() => {
35
- if (isAuthenticated && (!shouldShowWebAuthn || webAuthn.isEnabled())) {
35
+ if (isAuthenticated && (!shouldShowWebAuthn || webAuthn?.isEnabled())) {
36
36
  navigate(REDIRECT)
37
37
  }
38
38
  }, [isAuthenticated, shouldShowWebAuthn])
@@ -45,13 +45,13 @@ const LoginPage = ({ type }) => {
45
45
  }, [loading, isAuthenticated])
46
46
 
47
47
  // focus on the ${usernameLowerCase} field as soon as the page loads
48
- const ${usernameCamelCase}Ref = useRef()
48
+ const ${usernameCamelCase}Ref = useRef<HTMLInputElement>(null)
49
49
  useEffect(() => {
50
- ${usernameCamelCase}Ref.current && ${usernameCamelCase}Ref.current.focus()
50
+ ${usernameCamelCase}Ref.current?.focus()
51
51
  }, [])
52
52
 
53
- const onSubmit = async (data) => {
54
- const webAuthnSupported = await webAuthn.isSupported()
53
+ const onSubmit = async (data: Record<string, string>) => {
54
+ const webAuthnSupported = !!(await webAuthn?.isSupported())
55
55
 
56
56
  if (webAuthnSupported) {
57
57
  setShouldShowWebAuthn(true)
@@ -75,30 +75,38 @@ const LoginPage = ({ type }) => {
75
75
  }
76
76
 
77
77
  const onAuthenticate = async () => {
78
+ if (!webAuthn) {
79
+ return
80
+ }
81
+
78
82
  try {
79
83
  await webAuthn.authenticate()
80
84
  await reauthenticate()
81
85
  toast.success(WELCOME_MESSAGE)
82
86
  navigate(REDIRECT)
83
87
  } catch (e) {
84
- if (e.name === 'WebAuthnDeviceNotFoundError') {
88
+ if (e instanceof Error && e.name === 'WebAuthnDeviceNotFoundError') {
85
89
  toast.error(
86
90
  'Device not found, log in with ${usernameTitleCase}/${passwordTitleCase} to continue'
87
91
  )
88
92
  setShowWebAuthn(false)
89
93
  } else {
90
- toast.error(e.message)
94
+ toast.error(e instanceof Error ? e.message : String(e))
91
95
  }
92
96
  }
93
97
  }
94
98
 
95
99
  const onRegister = async () => {
100
+ if (!webAuthn) {
101
+ return
102
+ }
103
+
96
104
  try {
97
105
  await webAuthn.register()
98
106
  toast.success(WELCOME_MESSAGE)
99
107
  navigate(REDIRECT)
100
108
  } catch (e) {
101
- toast.error(e.message)
109
+ toast.error(e instanceof Error ? e.message : String(e))
102
110
  }
103
111
  }
104
112
 
@@ -200,7 +208,7 @@ const LoginPage = ({ type }) => {
200
208
 
201
209
  const formToRender = () => {
202
210
  if (showWebAuthn) {
203
- if (webAuthn.isEnabled()) {
211
+ if (webAuthn?.isEnabled()) {
204
212
  return <AuthWebAuthnPrompt />
205
213
  } else {
206
214
  return <RegisterWebAuthnPrompt />
@@ -212,7 +220,7 @@ const LoginPage = ({ type }) => {
212
220
 
213
221
  const linkToRender = () => {
214
222
  if (showWebAuthn) {
215
- if (webAuthn.isEnabled()) {
223
+ if (webAuthn?.isEnabled()) {
216
224
  return (
217
225
  <div className="rw-login-link">
218
226
  <span>or login with </span>{' '}
@@ -0,0 +1,147 @@
1
+ import { useEffect, useRef } from 'react'
2
+
3
+ import {
4
+ Form,
5
+ Label,
6
+ TextField,
7
+ PasswordField,
8
+ FieldError,
9
+ Submit,
10
+ } from '@cedarjs/forms'
11
+ import { Link, navigate, routes } from '@cedarjs/router'
12
+ import { Metadata } from '@cedarjs/web'
13
+ import { toast, Toaster } from '@cedarjs/web/toast'
14
+
15
+ import { getOAuthUrl } from '@cedarjs/auth-dbauth-web/oauth'
16
+
17
+ import { useAuth } from 'src/auth'
18
+
19
+ const SignupPage = () => {
20
+ const { isAuthenticated, signUp } = useAuth()
21
+
22
+ useEffect(() => {
23
+ if (isAuthenticated) {
24
+ navigate(routes.home())
25
+ }
26
+ }, [isAuthenticated])
27
+
28
+ // focus on ${usernameLowerCase} box on page load
29
+ const ${usernameCamelCase}Ref = useRef<HTMLInputElement>(null)
30
+ useEffect(() => {
31
+ ${usernameCamelCase}Ref.current?.focus()
32
+ }, [])
33
+
34
+ const onSubmit = async (data: Record<string, string>) => {
35
+ const response = await signUp({ username: data.${usernameCamelCase}, password: data.${passwordCamelCase} })
36
+
37
+ if (response.message) {
38
+ toast(response.message)
39
+ } else if (response.error) {
40
+ toast.error(response.error)
41
+ } else {
42
+ // user is signed in automatically
43
+ toast.success('Welcome!')
44
+ }
45
+ }
46
+
47
+ return (
48
+ <>
49
+ <Metadata title="Signup" />
50
+
51
+ <main className="rw-main">
52
+ <Toaster toastOptions={{ className: 'rw-toast', duration: 6000 }} />
53
+ <div className="rw-scaffold rw-login-container">
54
+ <div className="rw-segment">
55
+ <header className="rw-segment-header">
56
+ <h2 className="rw-heading rw-heading-secondary">Signup</h2>
57
+ </header>
58
+
59
+ <div className="rw-segment-main">
60
+ <div className="rw-form-wrapper">
61
+ <Form onSubmit={onSubmit} className="rw-form-wrapper">
62
+ <Label
63
+ name="${usernameCamelCase}"
64
+ className="rw-label"
65
+ errorClassName="rw-label rw-label-error"
66
+ >
67
+ ${usernameTitleCase}
68
+ </Label>
69
+ <TextField
70
+ name="${usernameCamelCase}"
71
+ className="rw-input"
72
+ errorClassName="rw-input rw-input-error"
73
+ ref={${usernameCamelCase}Ref}
74
+ validation={{
75
+ required: {
76
+ value: true,
77
+ message: '${usernameTitleCase} is required',
78
+ },
79
+ }}
80
+ />
81
+ <FieldError name="${usernameCamelCase}" className="rw-field-error" />
82
+
83
+ <Label
84
+ name="${passwordCamelCase}"
85
+ className="rw-label"
86
+ errorClassName="rw-label rw-label-error"
87
+ >
88
+ ${passwordTitleCase}
89
+ </Label>
90
+ <PasswordField
91
+ name="${passwordCamelCase}"
92
+ className="rw-input"
93
+ errorClassName="rw-input rw-input-error"
94
+ autoComplete="current-password"
95
+ validation={{
96
+ required: {
97
+ value: true,
98
+ message: '${passwordTitleCase} is required',
99
+ },
100
+ }}
101
+ />
102
+ <FieldError name="${passwordCamelCase}" className="rw-field-error" />
103
+
104
+ <div className="rw-button-group">
105
+ <Submit className="rw-button rw-button-blue">
106
+ Sign Up
107
+ </Submit>
108
+ </div>
109
+ </Form>
110
+
111
+ {/*
112
+ * OAuth signup buttons. Delete the ones for providers you
113
+ * haven't configured in `cedar setup auth dbAuth --oauth`.
114
+ * Each link is a full-page navigation to the provider's
115
+ * authorize route — it must not be turned into a fetch/XHR
116
+ * call.
117
+ */}
118
+ <div className="rw-button-group">
119
+ <a
120
+ href={getOAuthUrl('google', { flow: 'signup' })}
121
+ className="rw-button rw-button-blue"
122
+ >
123
+ Continue with Google
124
+ </a>
125
+ <a
126
+ href={getOAuthUrl('github', { flow: 'signup' })}
127
+ className="rw-button rw-button-blue"
128
+ >
129
+ Continue with GitHub
130
+ </a>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ </div>
135
+ <div className="rw-login-link">
136
+ <span>Already have an account?</span>{' '}
137
+ <Link to={routes.login()} className="rw-link">
138
+ Log in!
139
+ </Link>
140
+ </div>
141
+ </div>
142
+ </main>
143
+ </>
144
+ )
145
+ }
146
+
147
+ export default SignupPage
@@ -1,8 +1,9 @@
1
1
  import camelcase from "camelcase";
2
2
  import { Listr } from "listr2";
3
3
  import prompts from "prompts";
4
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
4
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
5
5
  import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
6
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
6
7
  import { getConfig } from "@cedarjs/project-config";
7
8
  import { writeFilesTask, transformTSToJSMap } from "../../../lib/index.js";
8
9
  import {
@@ -1,6 +1,7 @@
1
1
  import { Listr } from "listr2";
2
2
  import { terminalLink } from "termi-link";
3
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
3
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
4
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
4
5
  import { errorTelemetry } from "@cedarjs/telemetry";
5
6
  import { transformTSToJSMap, writeFilesTask } from "../../../lib/index.js";
6
7
  import { prepareForRollback } from "../../../lib/rollback.js";
@@ -37,11 +37,33 @@ const redactedModelFields = (fieldNames) => {
37
37
  }
38
38
  return sensitive;
39
39
  };
40
+ const DEFAULT_IGNORE_FIELDS_FOR_INPUT = ["createdAt", "updatedAt"];
41
+ const requiredFieldsInUpdateInput = (model) => {
42
+ return inputFields(model).filter((field) => {
43
+ return field.isRequired && !field.isList && !field.isId;
44
+ }).map((field) => field.name);
45
+ };
46
+ const nullableJsonFieldsInInput = (model) => {
47
+ return inputFields(model).filter((field) => {
48
+ return field.type === "Json" && !field.isRequired && !field.isList;
49
+ }).map((field) => field.name);
50
+ };
51
+ const inputFields = (model) => {
52
+ const redactedFields = redactedModelFields(
53
+ model.fields.map((field) => field.name)
54
+ );
55
+ return model.fields.filter((field) => {
56
+ return field.kind !== "object" && !DEFAULT_IGNORE_FIELDS_FOR_INPUT.includes(field.name) && !redactedFields.includes(field.name);
57
+ });
58
+ };
40
59
  const relationsForModel = (model) => {
41
60
  return model?.fields.filter((f) => f.relationName).map((field) => {
42
61
  return field.name;
43
62
  });
44
63
  };
64
+ const nullableRelationsForModel = (model) => {
65
+ return model.fields.filter((f) => f.kind === "object" && !f.isList && !f.isRequired).map((f) => f.name);
66
+ };
45
67
  const intForeignKeysForModel = (model) => {
46
68
  return model.fields.filter((f) => f.name.match(/Id$/) && f.type === "Int").map((f) => f.name);
47
69
  };
@@ -74,14 +96,18 @@ const mapPrismaScalarToPagePropTsType = (scalarType) => {
74
96
  return prismaScalarToTsType[scalarType] || "unknown";
75
97
  };
76
98
  export {
99
+ DEFAULT_IGNORE_FIELDS_FOR_INPUT,
77
100
  SENSITIVE_FIELDS,
78
101
  forcePluralizeWord,
79
102
  intForeignKeysForModel,
80
103
  mapPrismaScalarToPagePropTsType,
81
104
  mapRouteParamTypeToTsType,
105
+ nullableJsonFieldsInInput,
106
+ nullableRelationsForModel,
82
107
  pathName,
83
108
  redactedModelFields,
84
109
  relationsForModel,
85
110
  removeGeneratorName,
111
+ requiredFieldsInUpdateInput,
86
112
  validateName
87
113
  };
@@ -2,8 +2,9 @@ import path from "node:path";
2
2
  import { pathToFileURL } from "node:url";
3
3
  import * as changeCase from "change-case";
4
4
  import { Listr } from "listr2";
5
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
6
  import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
7
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
7
8
  import { errorTelemetry } from "@cedarjs/telemetry";
8
9
  import {
9
10
  getPaths,
@@ -1,6 +1,7 @@
1
1
  import path from "path";
2
2
  import { Listr } from "listr2";
3
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
3
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
4
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
4
5
  import {
5
6
  getPaths,
6
7
  writeFilesTask,
@@ -2,7 +2,8 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import fg from "fast-glob";
4
4
  import { Listr } from "listr2";
5
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
6
7
  import { ensurePosixPath } from "@cedarjs/project-config";
7
8
  import { errorTelemetry } from "@cedarjs/telemetry";
8
9
  import {
@@ -2,7 +2,7 @@ export const data = async () => {
2
2
  return new Date()
3
3
  }
4
4
 
5
- export const output = ({ data }) => {
5
+ export const output = ({ data }: { data: Date }) => {
6
6
  return (
7
7
  <>
8
8
  <h1>${pageName} og:image</h1>
@@ -11,7 +11,6 @@ const files = async ({
11
11
  fileName,
12
12
  typescript,
13
13
  tests: generateTests = true,
14
- esm = false,
15
14
  ...rest
16
15
  }) => {
17
16
  const extension = typescript ? ".ts" : ".js";
@@ -67,17 +66,15 @@ const files = async ({
67
66
  outputPath: path.join(folderName, "src", `${fileName}.test${extension}`)
68
67
  });
69
68
  outputFiles.push(testFile);
70
- if (esm) {
71
- const vitestConfigFile = await templateForFile({
72
- name,
73
- side: "packages",
74
- generator: "package",
75
- templatePath: "vitest.config.ts.template",
76
- templateVars: { folderName, ...rest },
77
- outputPath: path.join(folderName, `vitest.config${extension}`)
78
- });
79
- outputFiles.push(vitestConfigFile);
80
- }
69
+ const vitestConfigFile = await templateForFile({
70
+ name,
71
+ side: "packages",
72
+ generator: "package",
73
+ templatePath: "vitest.config.ts.template",
74
+ templateVars: { folderName, ...rest },
75
+ outputPath: path.join(folderName, `vitest.config${extension}`)
76
+ });
77
+ outputFiles.push(vitestConfigFile);
81
78
  }
82
79
  return outputFiles.reduce(async (accP, [outputPath, content]) => {
83
80
  const acc = await accP;
@@ -6,12 +6,13 @@ import { modify, applyEdits } from "jsonc-parser";
6
6
  import { Listr } from "listr2";
7
7
  import { terminalLink } from "termi-link";
8
8
  import ts from "typescript";
9
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
9
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
10
10
  import { workspacePackageSpecifier } from "@cedarjs/cli-helpers/packageManager";
11
11
  import { runScript, runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
12
12
  import { installPackages } from "@cedarjs/cli-helpers/packageManager/packages";
13
13
  import { addWorkspaceDir } from "@cedarjs/cli-helpers/packageManager/workspaces";
14
- import { getConfig, projectIsEsm } from "@cedarjs/project-config";
14
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
15
+ import { getConfig } from "@cedarjs/project-config";
15
16
  import { getPackageManager } from "@cedarjs/project-config/packageManager";
16
17
  import { errorTelemetry } from "@cedarjs/telemetry";
17
18
  import { getPaths, writeFilesTask } from "../../../lib/index.js";
@@ -342,8 +343,6 @@ const handler = async ({
342
343
  task: async (ctx) => {
343
344
  packageFiles = await files({
344
345
  ...ctx.nameVariants,
345
- // Only Vitest projects get a config generated for them
346
- esm: projectIsEsm(),
347
346
  ...rest
348
347
  });
349
348
  return writeFilesTask(packageFiles, { overwriteExisting: force });
@@ -4,6 +4,7 @@
4
4
  "target": "es2023",
5
5
  "module": "node20",
6
6
  "esModuleInterop": true,
7
+ "strict": true,
7
8
  "skipLibCheck": true,
8
9
  "baseUrl": ".",
9
10
  "rootDir": "src",
@@ -2,7 +2,8 @@ import { execSync } from "child_process";
2
2
  import camelcase from "camelcase";
3
3
  import { Listr } from "listr2";
4
4
  import pascalcase from "pascalcase";
5
- import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
5
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
6
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
6
7
  import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
7
8
  import { getConfig } from "@cedarjs/project-config";
8
9
  import { errorTelemetry } from "@cedarjs/telemetry";
@@ -1,4 +1,4 @@
1
- import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
1
+ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
2
2
  const command = "realtime <name>";
3
3
  const description = "Generate a subscription or live query used with RedwoodJS Realtime";
4
4
  function builder(yargs) {
@@ -4,9 +4,8 @@ import { Listr } from "listr2";
4
4
  import pascalcase from "pascalcase";
5
5
  import pluralize from "pluralize";
6
6
  import prompts from "prompts";
7
- import { colors as c } from "@cedarjs/cli-helpers";
7
+ import { colors as c } from "@cedarjs/cli-helpers/colors";
8
8
  import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
9
- import { projectIsEsm } from "@cedarjs/project-config";
10
9
  import { errorTelemetry } from "@cedarjs/telemetry";
11
10
  import {
12
11
  generateTemplate,
@@ -120,16 +119,10 @@ async function handler({
120
119
  exampleFile,
121
120
  exampleSubscriptionTemplateContent
122
121
  );
123
- let blankTemplateContent = await generateTemplate(
122
+ const blankTemplateContent = await generateTemplate(
124
123
  setupScriptContent,
125
124
  templateVariables(name)
126
125
  );
127
- if (projectIsEsm()) {
128
- blankTemplateContent = blankTemplateContent.replace(
129
- "import gql from 'graphql-tag'",
130
- "import { gql } from 'graphql-tag'"
131
- );
132
- }
133
126
  return [
134
127
  writeFile(
135
128
  sdlFile,
@@ -1,9 +1,17 @@
1
1
  // api/src/services/${name}s/${name}s.ts
2
+ import type { ${typeName}ItemInput } from 'types/graphql'
3
+
2
4
  import type { LiveQueryStorageMechanism } from '@cedarjs/realtime'
3
5
 
4
6
  import { logger } from 'src/lib/logger'
5
7
 
6
- const ${collectionName} = [
8
+ interface ${typeName}Data {
9
+ id: string
10
+ title: string
11
+ items: { amount: number }[]
12
+ }
13
+
14
+ const ${collectionName}: ${typeName}Data[] = [
7
15
  { id: '1', title: 'First ${modelName}', items: [{ amount: 11 }] },
8
16
  { id: '2', title: '2nd ${modelName}', items: [{ amount: 22 }] },
9
17
  { id: '3', title: 'Third ${modelName}', items: [{ amount: 33 }] },
@@ -35,14 +43,14 @@ const ${collectionName} = [
35
43
  * }
36
44
  * }
37
45
  */
38
- export const ${liveQueryName} = async ({ id }) => {
46
+ export const ${liveQueryName} = async ({ id }: { id: string }) => {
39
47
  const found${modelName} = ${collectionName}.find((a) => a.id === id)
40
48
  logger.debug({ id, ${name}: found${modelName} }, `${name} details`)
41
49
  return found${modelName}
42
50
  }
43
51
 
44
52
  export const create${typeName}Item = async (
45
- { input },
53
+ { input }: { input: ${typeName}ItemInput },
46
54
  { context }: { context: { liveQueryStore: LiveQueryStorageMechanism } }
47
55
  ) => {
48
56
  const { ${camelName}Id, amount } = input
@@ -63,7 +71,7 @@ export const create${typeName}Item = async (
63
71
  }
64
72
 
65
73
  export const ${modelName} = {
66
- largest${typeName}Item: (obj, { root }) => {
74
+ largest${typeName}Item: (obj: unknown, { root }: { root: ${typeName}Data }) => {
67
75
  const [largest] = root.items.sort((a, b) => b.amount - a.amount)
68
76
 
69
77
  logger.debug({ obj, root }, 'largest ${typeName}Item')
@@ -1,9 +1,9 @@
1
1
  import type { ${subscriptionInputType} } from 'types/graphql'
2
2
 
3
3
  import { logger } from 'src/lib/logger'
4
- import type { Publish${typeName}ChannelType } from 'src/subscriptions/${name}/${name}.service.js'
4
+ import type { Publish${typeName}ChannelType } from 'src/subscriptions/${name}/${name}.js'
5
5
 
6
- export const ${subscriptionQueryName} = ({ id }) => [id]
6
+ export const ${subscriptionQueryName} = ({ id }: { id: string }) => [id]
7
7
 
8
8
  export const ${subscriptionServiceResolver} = async (
9
9
  { input }: { input: ${subscriptionInputType} },
@@ -1,4 +1,4 @@
1
- import gql from 'graphql-tag'
1
+ import { gql } from 'graphql-tag'
2
2
 
3
3
  import type { PubSub } from '@cedarjs/realtime'
4
4
 
@@ -39,15 +39,15 @@ export type Publish${typeName}ChannelType = PubSub<Publish${typeName}Channel>
39
39
  const ${subscriptionName}Subscription = {
40
40
  ${subscriptionName}: {
41
41
  subscribe: (
42
- _,
43
- { id },
42
+ _: unknown,
43
+ { id }: { id: string },
44
44
  { pubSub }: { pubSub: Publish${typeName}ChannelType }
45
45
  ) => {
46
46
  logger.debug({ id }, '${name} subscription')
47
47
 
48
48
  return pubSub.subscribe('${typeName}', id)
49
49
  },
50
- resolve: (payload) => {
50
+ resolve: (payload: Publish${typeName}Channel['${typeName}'][1]) => {
51
51
  logger.debug({ payload }, '${name} subscription resolve')
52
52
 
53
53
  return payload
@@ -13,7 +13,7 @@ const builder = (yargs) => {
13
13
  description: "Generate test files",
14
14
  type: "boolean"
15
15
  }).option("tailwind", {
16
- description: "Generate TailwindCSS version of scaffold.css (automatically set to `true` if TailwindCSS config exists)",
16
+ description: "Generate TailwindCSS version of scaffold.css (automatically set to `true` if the web side depends on `tailwindcss`)",
17
17
  type: "boolean"
18
18
  }).option("rollback", {
19
19
  description: "Revert all generator actions if an error occurs",