@wasp.sh/wasp-cli-darwin-x64-unknown 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/Cli/starters/README.md +2 -0
- package/data/Cli/starters/basic/README.md +3 -3
- package/data/Cli/starters/basic/src/tags/components/CreateTagForm.tsx +2 -3
- package/data/Cli/starters/basic/vite.config.ts +0 -3
- package/data/Cli/starters/minimal/package.json +4 -1
- package/data/Cli/starters/minimal/vite.config.ts +0 -3
- package/data/Cli/starters/skeleton/AGENTS.md +6 -0
- package/data/Cli/starters/skeleton/CLAUDE.md +6 -0
- package/data/Cli/starters/skeleton/tsconfig.src.json +1 -11
- package/data/Generator/libs/auth/wasp.sh-lib-auth-0.26.0.tgz +0 -0
- package/data/Generator/libs/sdk-core/node_modules/@wasp.sh/lib-auth/wasp.sh-lib-auth-0.26.0.tgz +0 -0
- package/data/Generator/libs/sdk-core/wasp.sh-lib-sdk-core-0.26.0.tgz +0 -0
- package/data/Generator/libs/vite-ssr/{wasp.sh-lib-vite-ssr-0.25.0.tgz → wasp.sh-lib-vite-ssr-0.26.0.tgz} +0 -0
- package/data/Generator/templates/Dockerfile +1 -0
- package/data/Generator/templates/sdk/wasp/api/index.ts +5 -86
- package/data/Generator/templates/sdk/wasp/auth/email/actions/login.ts +2 -2
- package/data/Generator/templates/sdk/wasp/auth/email/actions/passwordReset.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/email/actions/signup.ts +7 -6
- package/data/Generator/templates/sdk/wasp/auth/email/actions/verifyEmail.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/Auth.tsx +12 -6
- package/data/Generator/templates/sdk/wasp/auth/forms/ForgotPassword.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/Login.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/ResetPassword.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/Signup.tsx +5 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/VerifyEmail.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/common/LoginSignupForm.tsx +34 -33
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/DummyEmailSenderNotice.module.css +11 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/DummyEmailSenderNotice.tsx +17 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ForgotPasswordForm.tsx +9 -13
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ResetPasswordForm.tsx +8 -9
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/VerifyEmailForm.tsx +4 -8
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/useEmail.ts +5 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/usernameAndPassword/useUsernameAndPassword.ts +6 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/types.ts +0 -59
- package/data/Generator/templates/sdk/wasp/auth/helpers/_Provider.tsx +2 -2
- package/data/Generator/templates/sdk/wasp/auth/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/logout.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/providers/index.ts +4 -4
- package/data/Generator/templates/sdk/wasp/auth/providers/types.ts +20 -24
- package/data/Generator/templates/sdk/wasp/auth/useAuth.ts +5 -5
- package/data/Generator/templates/sdk/wasp/auth/user.ts +147 -14
- package/data/Generator/templates/sdk/wasp/auth/username/actions/login.ts +2 -2
- package/data/Generator/templates/sdk/wasp/auth/username/actions/signup.ts +6 -5
- package/data/Generator/templates/sdk/wasp/auth/validation.ts +1 -83
- package/data/Generator/templates/sdk/wasp/client/app/pages/OAuthCallback.tsx +8 -5
- package/data/Generator/templates/sdk/wasp/client/app/pages/createAuthRequiredPage.jsx +6 -4
- package/data/Generator/templates/sdk/wasp/client/app/router.tsx +2 -2
- package/data/Generator/templates/sdk/wasp/client/auth/ui.ts +2 -2
- package/data/Generator/templates/sdk/wasp/client/auth/username.ts +2 -2
- package/data/Generator/templates/sdk/wasp/client/config.ts +1 -6
- package/data/Generator/templates/sdk/wasp/client/crud/_crud.ts +129 -75
- package/data/Generator/templates/sdk/wasp/client/env/schema.ts +14 -7
- package/data/Generator/templates/sdk/wasp/client/env.ts +4 -3
- package/data/Generator/templates/sdk/wasp/client/index.ts +3 -12
- package/data/Generator/templates/sdk/wasp/client/operations/actions/core.ts +14 -10
- package/data/Generator/templates/sdk/wasp/client/operations/actions/index.ts +7 -4
- package/data/Generator/templates/sdk/wasp/client/operations/index.ts +5 -5
- package/data/Generator/templates/sdk/wasp/client/operations/internal/index.ts +1 -8
- package/data/Generator/templates/sdk/wasp/client/operations/queries/core.ts +13 -55
- package/data/Generator/templates/sdk/wasp/client/operations/queries/index.ts +7 -7
- package/data/Generator/templates/sdk/wasp/client/router/Link.tsx +8 -8
- package/data/Generator/templates/sdk/wasp/client/router/NavLink.tsx +8 -8
- package/data/Generator/templates/sdk/wasp/client/router/index.ts +15 -15
- package/data/Generator/templates/sdk/wasp/client/test/index.ts +2 -1
- package/data/Generator/templates/sdk/wasp/client/test/vitest/helpers.tsx +5 -36
- package/data/Generator/templates/sdk/wasp/client/vite/index.ts +2 -1
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/virtualUserModules.ts +43 -0
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/{virtualModules.ts → virtualWaspModules.ts} +4 -4
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/wasp.ts +17 -14
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/waspConfig.ts +60 -18
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/client-entry.tsx +1 -1
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/routes.tsx +1 -1
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/ssr-entry.tsx +1 -1
- package/data/Generator/templates/sdk/wasp/client/webSocket/WebSocketProvider.tsx +3 -3
- package/data/Generator/templates/sdk/wasp/client/webSocket/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/core/serialization/index.ts +2 -47
- package/data/Generator/templates/sdk/wasp/core/serialization/prisma.ts +0 -1
- package/data/Generator/templates/sdk/wasp/entities/index.ts +6 -6
- package/data/Generator/templates/sdk/wasp/env/index.ts +1 -9
- package/data/Generator/templates/sdk/wasp/package.json +150 -104
- package/data/Generator/templates/sdk/wasp/server/_types/index.ts +8 -10
- package/data/Generator/templates/sdk/wasp/server/_types/taggedEntities.ts +4 -4
- package/data/Generator/templates/sdk/wasp/server/api/index.ts +5 -5
- package/data/Generator/templates/sdk/wasp/server/auth/email/index.ts +2 -12
- package/data/Generator/templates/sdk/wasp/server/auth/email/utils.ts +8 -30
- package/data/Generator/templates/sdk/wasp/server/auth/hooks.ts +5 -2
- package/data/Generator/templates/sdk/wasp/server/auth/index.ts +3 -3
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/jwt.ts +1 -1
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/lucia.ts +4 -4
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/oneTimeCode.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/discord.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/github.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/google.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/keycloak.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/microsoft.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/slack.ts +1 -1
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/session.ts +17 -6
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/utils.ts +40 -183
- package/data/Generator/templates/sdk/wasp/server/config.ts +1 -1
- package/data/Generator/templates/sdk/wasp/{core → server/core}/auth.ts +3 -3
- package/data/Generator/templates/sdk/wasp/server/crud/_operationTypes.ts +16 -63
- package/data/Generator/templates/sdk/wasp/server/dbClient.ts +15 -17
- package/data/Generator/templates/sdk/wasp/server/email/core/helpers.ts +3 -20
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/dummy.ts +2 -2
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/resend.ts +2 -1
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/smtp.ts +2 -1
- package/data/Generator/templates/sdk/wasp/server/email/core/types.ts +2 -45
- package/data/Generator/templates/sdk/wasp/server/email/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/env.ts +20 -11
- package/data/Generator/templates/sdk/wasp/server/index.ts +3 -3
- package/data/Generator/templates/sdk/wasp/server/jobs/_job.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBossJob.ts +4 -4
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/types.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/middleware/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/operations/actions/index.ts +14 -8
- package/data/Generator/templates/sdk/wasp/server/operations/actions/types.ts +5 -5
- package/data/Generator/templates/sdk/wasp/server/operations/queries/index.ts +14 -8
- package/data/Generator/templates/sdk/wasp/server/operations/queries/types.ts +5 -5
- package/data/Generator/templates/sdk/wasp/server/operations/wrappers.ts +40 -14
- package/data/Generator/templates/sdk/wasp/server/types/index.ts +1 -11
- package/data/Generator/templates/sdk/wasp/server/utils.ts +5 -20
- package/data/Generator/templates/sdk/wasp/server/webSocket/index.ts +7 -7
- package/data/Generator/templates/sdk/wasp/tsconfig.json +20 -46
- package/data/Generator/templates/sdk/wasp/types/index.ts +8 -0
- package/data/Generator/templates/sdk/wasp/types/register.ts +21 -0
- package/data/Generator/templates/sdk/wasp/vite-env.d.ts +0 -9
- package/data/Generator/templates/sdk/wasp/wasp-ssr.d.ts +8 -0
- package/data/Generator/templates/sdk/wasp/wasp-user-virtual-modules.d.ts +20 -0
- package/data/Generator/templates/server/package.json +2 -1
- package/data/Generator/templates/server/rollup.config.js +2 -43
- package/data/Generator/templates/server/rollup.dbSeed.config.js +3 -0
- package/data/Generator/templates/server/src/app.js +2 -2
- package/data/Generator/templates/server/src/auth/providers/config/email.ts +5 -5
- package/data/Generator/templates/server/src/auth/providers/email/login.ts +4 -4
- package/data/Generator/templates/server/src/auth/providers/email/requestPasswordReset.ts +4 -4
- package/data/Generator/templates/server/src/auth/providers/email/resetPassword.ts +13 -5
- package/data/Generator/templates/server/src/auth/providers/email/signup.ts +29 -18
- package/data/Generator/templates/server/src/auth/providers/email/verifyEmail.ts +7 -2
- package/data/Generator/templates/server/src/auth/providers/oauth/cookies.ts +5 -1
- package/data/Generator/templates/server/src/auth/providers/oauth/handler.ts +1 -1
- package/data/Generator/templates/server/src/auth/providers/oauth/oneTimeCode.ts +2 -2
- package/data/Generator/templates/server/src/auth/providers/oauth/state.ts +55 -13
- package/data/Generator/templates/server/src/auth/providers/oauth/user.ts +6 -3
- package/data/Generator/templates/server/src/auth/providers/username/login.ts +4 -4
- package/data/Generator/templates/server/src/auth/providers/username/signup.ts +12 -4
- package/data/Generator/templates/server/src/createRollupBundle.js +47 -0
- package/data/Generator/templates/server/src/crud/_operations.ts +16 -16
- package/data/Generator/templates/server/src/plugins/virtualUserModules.js +40 -0
- package/data/Generator/templates/server/src/routes/apis/index.ts +3 -3
- package/data/Generator/templates/server/src/routes/auth/index.js +1 -1
- package/data/Generator/templates/server/src/routes/auth/logout.ts +2 -2
- package/data/Generator/templates/server/src/routes/crud/_crud.ts +1 -1
- package/data/Generator/templates/server/src/routes/index.js +18 -18
- package/data/Generator/templates/server/src/routes/operations/index.js +1 -1
- package/data/Generator/templates/server/src/webSocket/initialization.ts +1 -1
- package/data/Generator/templates/server/tsconfig.json +7 -13
- package/data/Generator/templates/types/app/sdk/register.ts +57 -0
- package/data/packages/deploy/dist/common/cliVersion.js +17 -0
- package/data/packages/deploy/dist/common/waspProject.js +1 -1
- package/data/packages/deploy/dist/common/zx.js +24 -6
- package/data/packages/deploy/dist/providers/fly/commands/createDb/createDb.js +13 -5
- package/data/packages/deploy/dist/providers/fly/flyCli.js +29 -17
- package/data/packages/deploy/dist/providers/fly/index.js +16 -8
- package/data/packages/deploy/dist/providers/railway/commands/setup/setup.js +19 -31
- package/data/packages/deploy/dist/providers/railway/index.js +11 -2
- package/data/packages/deploy/dist/providers/railway/jsonOutputSchemas.js +19 -34
- package/data/packages/deploy/dist/providers/railway/railwayCli.js +11 -20
- package/data/packages/deploy/dist/providers/railway/railwayEnvironment/cli.js +20 -0
- package/data/packages/deploy/dist/providers/railway/railwayProject/RailwayProject.js +4 -1
- package/data/packages/deploy/dist/providers/railway/railwayProject/cli.js +6 -14
- package/data/packages/deploy/dist/providers/railway/railwayService/database.js +88 -0
- package/data/packages/deploy/dist/providers/railway/railwayService/deployment.js +12 -25
- package/data/packages/deploy/dist/providers/railway/railwayService/nameGenerator.js +5 -4
- package/data/packages/deploy/dist/providers/railway/railwayService/serviceInstance.js +48 -0
- package/data/packages/deploy/dist/providers/railway/railwayService/url.js +9 -30
- package/data/packages/deploy/package-lock.json +2 -2
- package/data/packages/deploy/package.json +1 -1
- package/data/packages/prisma/package-lock.json +2 -2
- package/data/packages/prisma/package.json +1 -1
- package/data/packages/spec/dist/__tests__/spec/mapApp.unit.test.js +19 -15
- package/data/packages/spec/dist/__tests__/spec/tsAppSpec.test-d.js +6 -0
- package/data/packages/spec/dist/src/appSpec.d.ts +15 -2
- package/data/packages/spec/dist/src/appSpec.d.ts.map +1 -1
- package/data/packages/spec/dist/src/spec/mapper/app.d.ts +1 -0
- package/data/packages/spec/dist/src/spec/mapper/app.d.ts.map +1 -1
- package/data/packages/spec/dist/src/spec/mapper/app.js +8 -2
- package/data/packages/spec/dist/src/spec/mapper/context.js +4 -4
- package/data/packages/spec/dist/src/spec/mapper/specElements.js +9 -9
- package/data/packages/spec/dist/src/spec/publicApi/constructors.d.ts +11 -11
- package/data/packages/spec/dist/src/spec/publicApi/constructors.js +11 -11
- package/data/packages/spec/dist/src/spec/publicApi/register.d.ts +1 -1
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts +58 -38
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts.map +1 -1
- package/data/packages/spec/package-lock.json +2 -2
- package/data/packages/spec/package.json +1 -1
- package/data/packages/studio/package-lock.json +15 -23
- package/data/packages/studio/package.json +2 -2
- package/package.json +1 -1
- package/wasp-bin +0 -0
- package/data/Generator/libs/auth/wasp.sh-lib-auth-0.25.0.tgz +0 -0
- package/data/Generator/templates/sdk/wasp/api/events.ts +0 -11
- package/data/Generator/templates/sdk/wasp/auth/email/index.ts +0 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.module.css +0 -99
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.tsx +0 -74
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.module.css +0 -22
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.tsx +0 -34
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/auth-styles.css +0 -30
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.module.css +0 -33
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.tsx +0 -14
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.module.css +0 -4
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.tsx +0 -85
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/util.ts +0 -16
- package/data/Generator/templates/sdk/wasp/auth/helpers/user.ts +0 -15
- package/data/Generator/templates/sdk/wasp/auth/responseSchemas.ts +0 -10
- package/data/Generator/templates/sdk/wasp/auth/types.ts +0 -2
- package/data/Generator/templates/sdk/wasp/auth/username/index.ts +0 -2
- package/data/Generator/templates/sdk/wasp/client/app/components/DefaultRootErrorBoundary.tsx +0 -16
- package/data/Generator/templates/sdk/wasp/client/app/components/FullPageWrapper.tsx +0 -21
- package/data/Generator/templates/sdk/wasp/client/app/components/Loader.module.css +0 -37
- package/data/Generator/templates/sdk/wasp/client/app/components/Loader.tsx +0 -12
- package/data/Generator/templates/sdk/wasp/client/app/components/Message.tsx +0 -86
- package/data/Generator/templates/sdk/wasp/client/crud/operationsHelpers.ts +0 -21
- package/data/Generator/templates/sdk/wasp/client/hooks.ts +0 -19
- package/data/Generator/templates/sdk/wasp/client/operations/hooks.ts +0 -347
- package/data/Generator/templates/sdk/wasp/client/operations/internal/resources.js +0 -85
- package/data/Generator/templates/sdk/wasp/client/operations/internal/updateHandlersMap.js +0 -37
- package/data/Generator/templates/sdk/wasp/client/operations/queryClient.ts +0 -34
- package/data/Generator/templates/sdk/wasp/client/operations/rpc.ts +0 -96
- package/data/Generator/templates/sdk/wasp/client/router/linkHelpers.ts +0 -48
- package/data/Generator/templates/sdk/wasp/client/router/types.ts +0 -98
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/detectServerImports.ts +0 -50
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/envFile.ts +0 -112
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/typescriptCheck.ts +0 -36
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/validateEnv.ts +0 -88
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/resolver.ts +0 -35
- package/data/Generator/templates/sdk/wasp/core/serialization/custom-register.ts +0 -21
- package/data/Generator/templates/sdk/wasp/core/storage.ts +0 -73
- package/data/Generator/templates/sdk/wasp/env/validation.ts +0 -44
- package/data/Generator/templates/sdk/wasp/server/HttpError.ts +0 -30
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/provider.ts +0 -20
- package/data/Generator/templates/sdk/wasp/server/auth/user.ts +0 -154
- package/data/Generator/templates/sdk/wasp/server/auth/username.ts +0 -1
- package/data/Generator/templates/sdk/wasp/server/jobs/core/job.ts +0 -28
- package/data/Generator/templates/sdk/wasp/server/middleware/globalMiddleware.ts +0 -8
- package/data/Generator/templates/sdk/wasp/universal/ansiColors.ts +0 -58
- package/data/Generator/templates/sdk/wasp/universal/predicates.ts +0 -3
- package/data/Generator/templates/sdk/wasp/universal/types.ts +0 -74
- package/data/Generator/templates/sdk/wasp/universal/url.ts +0 -9
- package/data/Generator/templates/sdk/wasp/universal/validators.ts +0 -21
- package/data/packages/ts-inspect/dist/exports.js +0 -82
- package/data/packages/ts-inspect/dist/index.js +0 -28
- package/data/packages/ts-inspect/package-lock.json +0 -4724
- package/data/packages/ts-inspect/package.json +0 -31
- /package/data/Generator/templates/sdk/wasp/{auth → server/auth}/password.ts +0 -0
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// PRIVATE API
|
|
2
|
-
export type RouteDefinitionsToRoutes<Routes extends RoutesDefinition> =
|
|
3
|
-
RouteDefinitionsToRoutesObj<Routes>[keyof RouteDefinitionsToRoutesObj<Routes>]
|
|
4
|
-
|
|
5
|
-
// PRIVATE API
|
|
6
|
-
export type OptionalRouteOptions = {
|
|
7
|
-
search?: Search
|
|
8
|
-
hash?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// PRIVATE API
|
|
12
|
-
export type ParamValue = string | number
|
|
13
|
-
// PRIVATE API
|
|
14
|
-
export type Params = { [name: string]: ParamValue }
|
|
15
|
-
// PRIVATE API
|
|
16
|
-
export type Search =
|
|
17
|
-
| string[][]
|
|
18
|
-
| Record<string, string>
|
|
19
|
-
| string
|
|
20
|
-
| URLSearchParams
|
|
21
|
-
|
|
22
|
-
type RouteDefinitionsToRoutesObj<Routes extends RoutesDefinition> = {
|
|
23
|
-
[K in keyof Routes]: {
|
|
24
|
-
to: ExpandRouteOnOptionalStaticSegments<Routes[K]['to']>
|
|
25
|
-
} & ParamsFromBuildFn<Routes[K]['build']>
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
type RoutesDefinition = {
|
|
29
|
-
[name: string]: {
|
|
30
|
-
to: string
|
|
31
|
-
build: BuildFn
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type BuildFn = (params: never) => string
|
|
36
|
-
|
|
37
|
-
type ParamsFromBuildFn<BF extends BuildFn> = Parameters<BF>[0] extends {
|
|
38
|
-
params: infer Params
|
|
39
|
-
}
|
|
40
|
-
? { params: Params }
|
|
41
|
-
: { params?: never }
|
|
42
|
-
|
|
43
|
-
// PRIVATE API (sdk)
|
|
44
|
-
/**
|
|
45
|
-
* Optional static segments handling: expands routes with optional segments
|
|
46
|
-
* into multiple routes, one for each possible combination of optional segments.
|
|
47
|
-
*
|
|
48
|
-
* For example: /users/tasks?/:id? will be expanded into two routes:
|
|
49
|
-
* - /users/:id?
|
|
50
|
-
* - /users/tasks/:id?
|
|
51
|
-
*/
|
|
52
|
-
export type ExpandRouteOnOptionalStaticSegments<Route extends string> = JoinPath<
|
|
53
|
-
ExpandOptionalSegments<ParseSegments<SplitPath<NonEmptyString<Route>>>>
|
|
54
|
-
>;
|
|
55
|
-
|
|
56
|
-
type ParseSegments<T> = T extends [infer Head, ...infer Tail]
|
|
57
|
-
? [_ParseSegment<Head>, ...ParseSegments<Tail>]
|
|
58
|
-
: T;
|
|
59
|
-
|
|
60
|
-
type _ParseSegment<T> = T extends `:${infer P}`
|
|
61
|
-
? // Param segment
|
|
62
|
-
{ segment: T }
|
|
63
|
-
: T extends `${infer S}?`
|
|
64
|
-
? // Optional segment
|
|
65
|
-
{ optionalSegment: S }
|
|
66
|
-
: // Regular segment
|
|
67
|
-
{ segment: T };
|
|
68
|
-
|
|
69
|
-
type Segment = { segment: string };
|
|
70
|
-
type OptionalSegment = { optionalSegment: string };
|
|
71
|
-
|
|
72
|
-
type Elem = Segment | OptionalSegment;
|
|
73
|
-
|
|
74
|
-
type ExpandOptionalSegments<T extends Elem[]> = T extends []
|
|
75
|
-
? []
|
|
76
|
-
: T extends [infer First extends Elem, ...infer Rest extends Elem[]]
|
|
77
|
-
? First extends Segment
|
|
78
|
-
? [First["segment"], ...ExpandOptionalSegments<Rest>]
|
|
79
|
-
: First extends OptionalSegment
|
|
80
|
-
? [First["optionalSegment"], ...ExpandOptionalSegments<Rest>] | ExpandOptionalSegments<Rest>
|
|
81
|
-
: []
|
|
82
|
-
: [];
|
|
83
|
-
|
|
84
|
-
type SplitPath<S extends string> = S extends "/"
|
|
85
|
-
? [""]
|
|
86
|
-
: S extends `${infer T}/${infer U}`
|
|
87
|
-
? [T, ...SplitPath<U>]
|
|
88
|
-
: [S];
|
|
89
|
-
|
|
90
|
-
type JoinPath<T extends string[]> = T extends [infer Only extends string]
|
|
91
|
-
? Only extends ""
|
|
92
|
-
? "/"
|
|
93
|
-
: Only
|
|
94
|
-
: T extends [infer First extends string, ...infer Rest extends string[]]
|
|
95
|
-
? `${First}/${JoinPath<Rest>}`
|
|
96
|
-
: never;
|
|
97
|
-
|
|
98
|
-
type NonEmptyString<S extends string> = S extends "" ? never : S;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{{={= =}=}}
|
|
2
|
-
import { type Plugin } from 'vite'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
|
|
5
|
-
export function detectServerImports(): Plugin {
|
|
6
|
-
let parsePathToUserCode!: ParsePathToUserCodeFn
|
|
7
|
-
return {
|
|
8
|
-
name: 'wasp:detect-server-imports',
|
|
9
|
-
enforce: 'pre',
|
|
10
|
-
configResolved(config) {
|
|
11
|
-
parsePathToUserCode = createPathToUserCodeParser(config.root)
|
|
12
|
-
},
|
|
13
|
-
resolveId(source, importer) {
|
|
14
|
-
if (!importer) {
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const pathToUserCode = parsePathToUserCode(importer)
|
|
19
|
-
if (!pathToUserCode) {
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (isServerImport(source)) {
|
|
24
|
-
throw new Error(
|
|
25
|
-
`Server code cannot be imported in the client code. Import from "${source}" in "${pathToUserCode}" is not allowed.`
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function isServerImport(moduleName: string): boolean {
|
|
33
|
-
return moduleName.startsWith('wasp/server')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type RelativePathToUserCode = string & { _brand: 'relativePathToUserCode' }
|
|
37
|
-
|
|
38
|
-
type ParsePathToUserCodeFn = (importerPath: string) => RelativePathToUserCode | null;
|
|
39
|
-
|
|
40
|
-
function createPathToUserCodeParser(waspProjectDirPath: string): ParsePathToUserCodeFn {
|
|
41
|
-
return (importerPath: string): RelativePathToUserCode | null => {
|
|
42
|
-
const importerPathRelativeToWaspProjectDir = path.relative(
|
|
43
|
-
waspProjectDirPath,
|
|
44
|
-
importerPath
|
|
45
|
-
)
|
|
46
|
-
return importerPathRelativeToWaspProjectDir.startsWith('{= srcDirInWaspProjectDir =}')
|
|
47
|
-
? (importerPathRelativeToWaspProjectDir as RelativePathToUserCode)
|
|
48
|
-
: null
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
{{={= =}=}}
|
|
2
|
-
import { type Plugin, type UserConfig } from 'vite'
|
|
3
|
-
import { resolve } from 'node:path'
|
|
4
|
-
import { readFile, access, constants } from 'node:fs/promises'
|
|
5
|
-
import { parse as parseDotenv } from 'dotenv'
|
|
6
|
-
import { expand, type DotenvPopulateInput } from 'dotenv-expand'
|
|
7
|
-
|
|
8
|
-
const envFileName = '{= clientEnvFileName =}'
|
|
9
|
-
|
|
10
|
-
export function envFile(): Plugin {
|
|
11
|
-
let envFilePath!: string
|
|
12
|
-
return {
|
|
13
|
-
name: 'wasp:env-file',
|
|
14
|
-
enforce: 'pre',
|
|
15
|
-
async config(config, env) {
|
|
16
|
-
const rootDir = config.root || process.cwd()
|
|
17
|
-
const envVars = await loadEnvVars({
|
|
18
|
-
rootDir,
|
|
19
|
-
// We are sure that `envPrefix` is defined because
|
|
20
|
-
// we defined it in an earlier plugin.
|
|
21
|
-
envPrefix: config.envPrefix!,
|
|
22
|
-
// We load the env file variables only in development,
|
|
23
|
-
// when building for production, users are expected to
|
|
24
|
-
// provide the environment variables inline.
|
|
25
|
-
loadDotEnvFile: env.command === 'serve',
|
|
26
|
-
})
|
|
27
|
-
envFilePath = resolve(rootDir, envFileName)
|
|
28
|
-
|
|
29
|
-
const prefixedVars = Object.entries(envVars)
|
|
30
|
-
.reduce((acc, [key, value]) => {
|
|
31
|
-
acc[`import.meta.env.${key}`] = JSON.stringify(value)
|
|
32
|
-
return acc
|
|
33
|
-
}, {} as Record<string, string>)
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
// Disable Vite's default .env loading.
|
|
37
|
-
envDir: false,
|
|
38
|
-
define: prefixedVars,
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
configureServer(server) {
|
|
42
|
-
const reloadServerOnEnvFileEvent = (path: string) => {
|
|
43
|
-
if (path === envFilePath) {
|
|
44
|
-
server.restart()
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
server.watcher.on('add', reloadServerOnEnvFileEvent)
|
|
49
|
-
server.watcher.on('change', reloadServerOnEnvFileEvent)
|
|
50
|
-
server.watcher.on('unlink', reloadServerOnEnvFileEvent)
|
|
51
|
-
},
|
|
52
|
-
async buildStart() {
|
|
53
|
-
this.addWatchFile(envFilePath)
|
|
54
|
-
},
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Based on: https://github.com/vitejs/vite/blob/8bb32036792a6f522f5c947112f3d688add755a0/packages/vite/src/node/env.ts
|
|
59
|
-
export async function loadEnvVars({
|
|
60
|
-
rootDir,
|
|
61
|
-
envPrefix,
|
|
62
|
-
loadDotEnvFile,
|
|
63
|
-
}: {
|
|
64
|
-
rootDir: string
|
|
65
|
-
envPrefix: NonNullable<UserConfig['envPrefix']>
|
|
66
|
-
loadDotEnvFile: boolean
|
|
67
|
-
}): Promise<Record<string, string>> {
|
|
68
|
-
const envPrefixNormalized = Array.isArray(envPrefix) ? envPrefix : [envPrefix]
|
|
69
|
-
const env: Record<string, string> = {}
|
|
70
|
-
|
|
71
|
-
if (loadDotEnvFile) {
|
|
72
|
-
const envFilePath = resolve(rootDir, envFileName)
|
|
73
|
-
const parsed = await parseEnvFile(envFilePath)
|
|
74
|
-
|
|
75
|
-
// Let environment variables use each other. Make a copy of `process.env` so that `dotenv-expand`
|
|
76
|
-
// doesn't re-assign the expanded values to the global `process.env`.
|
|
77
|
-
const processEnv = { ...process.env } as DotenvPopulateInput
|
|
78
|
-
expand({ parsed, processEnv })
|
|
79
|
-
|
|
80
|
-
// Only keys that start with prefix are exposed to client.
|
|
81
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
82
|
-
if (envPrefixNormalized.some(prefix => key.startsWith(prefix))) {
|
|
83
|
-
env[key] = value
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Make sure that inline env variables are prioritized over env file variables.
|
|
89
|
-
// Follows the logic Vite uses for env variables.
|
|
90
|
-
for (const key in process.env) {
|
|
91
|
-
if (envPrefixNormalized.some(prefix => key.startsWith(prefix))) {
|
|
92
|
-
env[key] = process.env[key] as string
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return env
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function parseEnvFile(envFilePath: string): Promise<Record<string, string>> {
|
|
100
|
-
try {
|
|
101
|
-
await access(envFilePath, constants.R_OK)
|
|
102
|
-
} catch {
|
|
103
|
-
return {}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
try {
|
|
107
|
-
return parseDotenv(await readFile(envFilePath, 'utf-8'))
|
|
108
|
-
} catch (error) {
|
|
109
|
-
console.error(`Error parsing ${envFileName}:`, error)
|
|
110
|
-
throw error
|
|
111
|
-
}
|
|
112
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type Plugin } from 'vite'
|
|
2
|
-
import { spawn } from 'node:child_process'
|
|
3
|
-
|
|
4
|
-
interface TypeScriptCheckOptions {
|
|
5
|
-
srcTsConfigPath: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function typescriptCheck(options: TypeScriptCheckOptions): Plugin {
|
|
9
|
-
return {
|
|
10
|
-
name: 'wasp:typescript-check',
|
|
11
|
-
apply: 'build',
|
|
12
|
-
async buildStart() {
|
|
13
|
-
await runTsc(options.srcTsConfigPath)
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function runTsc(srcTsConfigPath: string): Promise<void> {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
const child = spawn(
|
|
21
|
-
'tsc',
|
|
22
|
-
['--project', srcTsConfigPath, '--noEmit'],
|
|
23
|
-
{
|
|
24
|
-
stdio: 'inherit',
|
|
25
|
-
shell: process.platform === 'win32',
|
|
26
|
-
}
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
child.once('error', reject)
|
|
30
|
-
child.once('close', (code) =>
|
|
31
|
-
code === 0
|
|
32
|
-
? resolve()
|
|
33
|
-
: reject(new Error(`TypeScript check failed (exit ${code})`))
|
|
34
|
-
)
|
|
35
|
-
})
|
|
36
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
{{={= =}=}}
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
type Plugin,
|
|
5
|
-
type ResolvedConfig,
|
|
6
|
-
createServer as createViteServer,
|
|
7
|
-
isRunnableDevEnvironment
|
|
8
|
-
} from "vite";
|
|
9
|
-
|
|
10
|
-
const PLUGIN_NAME = "wasp:validate-env";
|
|
11
|
-
const CLIENT_ENV_SCHEMA_VALIDATION_MODULE = "{= clientEnvSchemaValidationModulePath =}"
|
|
12
|
-
|
|
13
|
-
export function validateEnv(): Plugin {
|
|
14
|
-
let resolvedConfig: ResolvedConfig;
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
name: PLUGIN_NAME,
|
|
18
|
-
configResolved(config) {
|
|
19
|
-
resolvedConfig = config;
|
|
20
|
-
},
|
|
21
|
-
// We validate just before any artifacts are built.
|
|
22
|
-
async buildStart() {
|
|
23
|
-
// We need to import the client env schema validation module
|
|
24
|
-
// through a Vite server, because both the user and the Wasp schema
|
|
25
|
-
// modules may depend on bundler features.
|
|
26
|
-
// Because of that we spin up a temporary Vite server.
|
|
27
|
-
//
|
|
28
|
-
// Alternatively, for `serve`, we could use the Vite server provided
|
|
29
|
-
// through the `configureServer` hook, but that would complicate
|
|
30
|
-
// the solution for negligible performance benefits.
|
|
31
|
-
const tempServer = await createViteServer({
|
|
32
|
-
root: resolvedConfig.root,
|
|
33
|
-
mode: resolvedConfig.mode,
|
|
34
|
-
// To ensure we pick up all user-defined plugins (resolution matches the main build)
|
|
35
|
-
// while avoiding recursion. This includes the `wasp` plugin.
|
|
36
|
-
configFile: false,
|
|
37
|
-
plugins: resolvedConfig.plugins
|
|
38
|
-
.filter((plugin) => plugin.name !== PLUGIN_NAME)
|
|
39
|
-
|
|
40
|
-
// Ignore `vite:`-prefixed plugins since Vite will recreate them for
|
|
41
|
-
// the temporary server anyway.
|
|
42
|
-
.filter((plugin) => !plugin.name.startsWith("vite:"))
|
|
43
|
-
|
|
44
|
-
// Vite's `configureServer`/`configurePreviewServer` hooks let plugins
|
|
45
|
-
// wire long-lived behavior into a dev or preview server: middleware,
|
|
46
|
-
// websocket handlers, file watchers, and similar background tasks.
|
|
47
|
-
//
|
|
48
|
-
// Plugins are supposed to clean these up by returning a teardown
|
|
49
|
-
// function from the hook, but some forget to, so resources they
|
|
50
|
-
// allocate end up outliving the server. This forces the original
|
|
51
|
-
// Vite process to be alive indefinitely.
|
|
52
|
-
//
|
|
53
|
-
// We don't need either hook to validate the client env schema.
|
|
54
|
-
// We only need module resolution and transforms.
|
|
55
|
-
.map((plugin) => ({
|
|
56
|
-
...plugin,
|
|
57
|
-
configureServer: undefined,
|
|
58
|
-
configurePreviewServer: undefined,
|
|
59
|
-
})),
|
|
60
|
-
|
|
61
|
-
// Minimize side effects from spinning up a temporary dev server.
|
|
62
|
-
appType: 'custom', // avoid HTML handling
|
|
63
|
-
server: {
|
|
64
|
-
middlewareMode: true, // do not start an actual HTTP server
|
|
65
|
-
watch: null,
|
|
66
|
-
hmr: false
|
|
67
|
-
},
|
|
68
|
-
logLevel: "silent",
|
|
69
|
-
optimizeDeps: { noDiscovery: true, include: [] },
|
|
70
|
-
clearScreen: false,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
// Vite's `ssr` means bundled for "backend JS runtime", like Node.
|
|
75
|
-
// This environment is always runnable in vite dev server.
|
|
76
|
-
if (!isRunnableDevEnvironment(tempServer.environments.ssr)) {
|
|
77
|
-
throw new Error(`Expected ssr to be a runnable dev environment`)
|
|
78
|
-
}
|
|
79
|
-
// The imported module runs env schema validation as an import
|
|
80
|
-
// side-effect and throws on failure.
|
|
81
|
-
const moduleAbsPath = path.resolve(resolvedConfig.root, CLIENT_ENV_SCHEMA_VALIDATION_MODULE);
|
|
82
|
-
await tempServer.environments.ssr.runner.import(moduleAbsPath);
|
|
83
|
-
} finally {
|
|
84
|
-
await tempServer.close();
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import * as path from "node:path"
|
|
2
|
-
|
|
3
|
-
export type VirtualFiles = {
|
|
4
|
-
ids: ReadonlyMap<string, string>;
|
|
5
|
-
loaders: ReadonlyMap<string, () => Promise<string> | string>;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
type VirtualFilesDefinition = {
|
|
9
|
-
id: string;
|
|
10
|
-
load: () => Promise<string> | string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const makeVirtualFilesResolver =
|
|
14
|
-
(files: VirtualFilesDefinition[]) =>
|
|
15
|
-
(rootPath: string): VirtualFiles => {
|
|
16
|
-
const filesWithAbsPath = files.map((d) => ({
|
|
17
|
-
...d,
|
|
18
|
-
absPath: path.resolve(rootPath, path.basename(d.id)),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
const ids = new Map(
|
|
22
|
-
filesWithAbsPath.flatMap((d) =>
|
|
23
|
-
// We'll resolve both the relative and absolute paths for the virtual
|
|
24
|
-
// files, since Vite and other plugins may request either.
|
|
25
|
-
[
|
|
26
|
-
[d.id, d.absPath],
|
|
27
|
-
[d.absPath, d.absPath],
|
|
28
|
-
],
|
|
29
|
-
),
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const loaders = new Map(filesWithAbsPath.map((d) => [d.absPath, d.load]));
|
|
33
|
-
|
|
34
|
-
return { ids, loaders };
|
|
35
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { WaspInternal_CustomSerializableJSONValue_Register } from "superjson"
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
This is a workaround for declaring custom types through side-effects in
|
|
5
|
-
TypeScript. This way a bare import, like `import "./prisma"` will register
|
|
6
|
-
itself as a custom serialization in the type-level, like it does at the
|
|
7
|
-
runtime-level.
|
|
8
|
-
|
|
9
|
-
This declaration creates an empty interface. Implementations of custom
|
|
10
|
-
serialization types can extend this interface through augmentation
|
|
11
|
-
(https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces).
|
|
12
|
-
We can later inspect this interface to see which custom types are registered.
|
|
13
|
-
|
|
14
|
-
This approach is copied from TanStack Router's `Register` interface
|
|
15
|
-
https://github.com/TanStack/router/blob/v1.124.1/docs/router/framework/react/guide/creating-a-router.md#router-type-safety
|
|
16
|
-
*/
|
|
17
|
-
declare module "superjson" {
|
|
18
|
-
interface WaspInternal_CustomSerializableJSONValue_Register {}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type CustomSerializableJSONValue = WaspInternal_CustomSerializableJSONValue_Register[keyof WaspInternal_CustomSerializableJSONValue_Register]
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export type DataStore = {
|
|
2
|
-
getPrefixedKey(key: string): string;
|
|
3
|
-
set(key: string, value: unknown): void;
|
|
4
|
-
get(key: string): unknown;
|
|
5
|
-
remove(key: string): void;
|
|
6
|
-
clear(): void;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const createStorage =
|
|
10
|
-
typeof window === "undefined" || !window.localStorage
|
|
11
|
-
? createMemoryDataStore
|
|
12
|
-
: createLocalStorageDataStore
|
|
13
|
-
|
|
14
|
-
export const storage = createStorage("wasp");
|
|
15
|
-
|
|
16
|
-
function createMemoryDataStore(prefix: string): DataStore {
|
|
17
|
-
const store: Map<string, unknown> = new Map();
|
|
18
|
-
|
|
19
|
-
function getPrefixedKey(key: string): string {
|
|
20
|
-
return `${prefix}:${key}`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
getPrefixedKey,
|
|
25
|
-
set(key, value) {
|
|
26
|
-
store.set(getPrefixedKey(key), value);
|
|
27
|
-
},
|
|
28
|
-
get(key) {
|
|
29
|
-
return store.get(getPrefixedKey(key));
|
|
30
|
-
},
|
|
31
|
-
remove(key) {
|
|
32
|
-
store.delete(getPrefixedKey(key));
|
|
33
|
-
},
|
|
34
|
-
clear() {
|
|
35
|
-
store.clear();
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function createLocalStorageDataStore(prefix: string): DataStore {
|
|
41
|
-
if (!window.localStorage) {
|
|
42
|
-
throw new Error("Local storage is not available.");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function getPrefixedKey(key: string): string {
|
|
46
|
-
return `${prefix}:${key}`;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
getPrefixedKey,
|
|
51
|
-
set(key, value) {
|
|
52
|
-
localStorage.setItem(getPrefixedKey(key), JSON.stringify(value));
|
|
53
|
-
},
|
|
54
|
-
get(key) {
|
|
55
|
-
const value = localStorage.getItem(getPrefixedKey(key));
|
|
56
|
-
try {
|
|
57
|
-
return value ? JSON.parse(value) : undefined;
|
|
58
|
-
} catch (e: any) {
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
remove(key) {
|
|
63
|
-
localStorage.removeItem(getPrefixedKey(key));
|
|
64
|
-
},
|
|
65
|
-
clear() {
|
|
66
|
-
Object.keys(localStorage).forEach((key) => {
|
|
67
|
-
if (key.startsWith(prefix)) {
|
|
68
|
-
localStorage.removeItem(key);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
|
|
3
|
-
import { colorize } from "../universal/ansiColors.js";
|
|
4
|
-
|
|
5
|
-
// PRIVATE API (SDK)
|
|
6
|
-
export function ensureEnvSchema<Schema extends z.ZodType>(
|
|
7
|
-
data: unknown,
|
|
8
|
-
schema: Schema,
|
|
9
|
-
): z.infer<Schema> {
|
|
10
|
-
const result = getValidatedEnvOrError(data, schema);
|
|
11
|
-
if (result.success) {
|
|
12
|
-
return result.data;
|
|
13
|
-
} else {
|
|
14
|
-
console.error(colorize("red", formatZodEnvError(result.error)));
|
|
15
|
-
throw new Error("Error parsing environment variables");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// PRIVATE API (SDK, Vite config)
|
|
20
|
-
export function getValidatedEnvOrError<Schema extends z.ZodType>(
|
|
21
|
-
env: unknown,
|
|
22
|
-
schema: Schema,
|
|
23
|
-
): z.ZodSafeParseResult<z.infer<Schema>> {
|
|
24
|
-
return schema.safeParse(env);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// PRIVATE API (SDK, Vite config)
|
|
28
|
-
export function formatZodEnvError(error: z.ZodError): string {
|
|
29
|
-
const flattenedIssues = z.flattenError(error);
|
|
30
|
-
|
|
31
|
-
return [
|
|
32
|
-
"══ Env vars validation failed ══",
|
|
33
|
-
"",
|
|
34
|
-
// Top-level errors
|
|
35
|
-
...flattenedIssues.formErrors,
|
|
36
|
-
"",
|
|
37
|
-
// Errors per field
|
|
38
|
-
...Object.entries(flattenedIssues.fieldErrors).map(
|
|
39
|
-
([prop, error]) => `${prop} - ${error}`,
|
|
40
|
-
),
|
|
41
|
-
"",
|
|
42
|
-
"════════════════════════════════",
|
|
43
|
-
].join("\n");
|
|
44
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export class HttpError extends Error {
|
|
2
|
-
public statusCode: number
|
|
3
|
-
public data: unknown
|
|
4
|
-
|
|
5
|
-
constructor(
|
|
6
|
-
statusCode: number,
|
|
7
|
-
message?: string,
|
|
8
|
-
data?: Record<string, unknown>,
|
|
9
|
-
options?: ErrorOptions
|
|
10
|
-
) {
|
|
11
|
-
super(message, options)
|
|
12
|
-
|
|
13
|
-
if (Error.captureStackTrace) {
|
|
14
|
-
Error.captureStackTrace(this, HttpError)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
this.name = this.constructor.name
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
!(Number.isInteger(statusCode) && statusCode >= 400 && statusCode < 600)
|
|
21
|
-
) {
|
|
22
|
-
throw new Error('statusCode has to be integer in range [400, 600).')
|
|
23
|
-
}
|
|
24
|
-
this.statusCode = statusCode
|
|
25
|
-
|
|
26
|
-
if (data) {
|
|
27
|
-
this.data = data
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { OAuth2Provider, OAuth2ProviderWithPKCE } from "arctic";
|
|
2
|
-
|
|
3
|
-
export function defineProvider<
|
|
4
|
-
OAuthClient extends OAuth2Provider | OAuth2ProviderWithPKCE,
|
|
5
|
-
const Id extends string
|
|
6
|
-
>({
|
|
7
|
-
id,
|
|
8
|
-
displayName,
|
|
9
|
-
oAuthClient,
|
|
10
|
-
}: {
|
|
11
|
-
id: Id;
|
|
12
|
-
displayName: string;
|
|
13
|
-
oAuthClient: OAuthClient;
|
|
14
|
-
}) {
|
|
15
|
-
return {
|
|
16
|
-
id,
|
|
17
|
-
displayName,
|
|
18
|
-
oAuthClient,
|
|
19
|
-
};
|
|
20
|
-
}
|