@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
|
@@ -7,7 +7,7 @@ export { ForgotPasswordForm } from '../../auth/forms/ForgotPassword'
|
|
|
7
7
|
export { VerifyEmailForm } from '../../auth/forms/VerifyEmail'
|
|
8
8
|
export { ResetPasswordForm } from '../../auth/forms/ResetPassword'
|
|
9
9
|
{=/ isEmailAuthEnabled =}
|
|
10
|
-
export type { CustomizationOptions } from '
|
|
10
|
+
export type { CustomizationOptions } from '@wasp.sh/lib-sdk-core/browser'
|
|
11
11
|
{=# isSlackAuthEnabled =}
|
|
12
12
|
export { SignInButton as SlackSignInButton } from '../../auth/helpers/Slack'
|
|
13
13
|
{=/ isSlackAuthEnabled =}
|
|
@@ -32,4 +32,4 @@ export {
|
|
|
32
32
|
FormTextarea,
|
|
33
33
|
FormItemGroup,
|
|
34
34
|
FormLabel,
|
|
35
|
-
} from '
|
|
35
|
+
} from '@wasp.sh/lib-sdk-core/browser'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { login
|
|
2
|
-
|
|
1
|
+
export { login } from '../../auth/username/actions/login'
|
|
2
|
+
export { signup } from '../../auth/username/actions/signup'
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import { stripTrailingSlash } from '
|
|
2
|
+
import { stripTrailingSlash, type ClientConfig } from '@wasp.sh/lib-sdk-core'
|
|
3
3
|
import { env } from './env.js'
|
|
4
4
|
|
|
5
5
|
const apiUrl = stripTrailingSlash(env["{= serverUrlEnvVarName =}"])
|
|
6
6
|
|
|
7
|
-
// PUBLIC API
|
|
8
|
-
export type ClientConfig = {
|
|
9
|
-
apiUrl: string,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
7
|
// PUBLIC API
|
|
13
8
|
export const config: ClientConfig = {
|
|
14
9
|
apiUrl,
|
|
@@ -1,89 +1,143 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import { createAction } from "../operations/actions/core
|
|
3
|
-
import { createQuery } from "../operations/queries/core
|
|
4
|
-
import { makeUseActionFor, makeUseQueryFor } from "
|
|
2
|
+
import { createAction } from "../operations/actions/core";
|
|
3
|
+
import { createQuery } from "../operations/queries/core";
|
|
4
|
+
import { makeUseActionFor, makeUseQueryFor, type ActionFor, type QueryFor, type UseActionFor, type UseQueryFor } from "@wasp.sh/lib-sdk-core/browser";
|
|
5
5
|
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} from
|
|
6
|
+
{=# operations.Get =}
|
|
7
|
+
RegisteredGetQuery,
|
|
8
|
+
{=/ operations.Get =}
|
|
9
|
+
{=# operations.GetAll =}
|
|
10
|
+
RegisteredGetAllQuery,
|
|
11
|
+
{=/ operations.GetAll =}
|
|
12
|
+
{=# operations.Create =}
|
|
13
|
+
RegisteredCreateAction,
|
|
14
|
+
{=/ operations.Create =}
|
|
15
|
+
{=# operations.Update =}
|
|
16
|
+
RegisteredUpdateAction,
|
|
17
|
+
{=/ operations.Update =}
|
|
18
|
+
{=# operations.Delete =}
|
|
19
|
+
RegisteredDeleteAction,
|
|
20
|
+
{=/ operations.Delete =}
|
|
21
|
+
} from "../../server/crud/{= name =}";
|
|
22
|
+
|
|
23
|
+
// PUBLIC API
|
|
24
|
+
export const {= name =}: {= entityUpper =}Crud = createCrud();
|
|
25
|
+
|
|
26
|
+
// PUBLIC API
|
|
27
|
+
export interface {= entityUpper =}Crud {
|
|
28
|
+
{=# operations.Get =}
|
|
29
|
+
get: {= entityUpper =}Get;
|
|
30
|
+
{=/ operations.Get =}
|
|
31
|
+
{=# operations.GetAll =}
|
|
32
|
+
getAll: {= entityUpper =}GetAll;
|
|
33
|
+
{=/ operations.GetAll =}
|
|
34
|
+
{=# operations.Create =}
|
|
35
|
+
create: {= entityUpper =}Create;
|
|
36
|
+
{=/ operations.Create =}
|
|
37
|
+
{=# operations.Update =}
|
|
38
|
+
update: {= entityUpper =}Update;
|
|
39
|
+
{=/ operations.Update =}
|
|
40
|
+
{=# operations.Delete =}
|
|
41
|
+
delete: {= entityUpper =}Delete;
|
|
42
|
+
{=/ operations.Delete =}
|
|
43
|
+
};
|
|
44
|
+
{=# operations.Get =}
|
|
45
|
+
|
|
46
|
+
export interface {= entityUpper =}Get {
|
|
47
|
+
query: QueryFor<RegisteredGetQuery>;
|
|
48
|
+
useQuery: UseQueryFor<RegisteredGetQuery>;
|
|
49
|
+
}
|
|
50
|
+
{=/ operations.Get =}
|
|
51
|
+
{=# operations.GetAll =}
|
|
52
|
+
|
|
53
|
+
export interface {= entityUpper =}GetAll {
|
|
54
|
+
query: QueryFor<RegisteredGetAllQuery>;
|
|
55
|
+
useQuery: UseQueryFor<RegisteredGetAllQuery>;
|
|
56
|
+
};
|
|
57
|
+
{=/ operations.GetAll =}
|
|
58
|
+
{=# operations.Create =}
|
|
22
59
|
|
|
23
|
-
|
|
60
|
+
export interface {= entityUpper =}Create {
|
|
61
|
+
action: ActionFor<RegisteredCreateAction>;
|
|
62
|
+
useAction: UseActionFor<RegisteredCreateAction>;
|
|
63
|
+
};
|
|
64
|
+
{=/ operations.Create =}
|
|
65
|
+
{=# operations.Update =}
|
|
66
|
+
|
|
67
|
+
export interface {= entityUpper =}Update {
|
|
68
|
+
action: ActionFor<RegisteredUpdateAction>;
|
|
69
|
+
useAction: UseActionFor<RegisteredUpdateAction>;
|
|
70
|
+
};
|
|
71
|
+
{=/ operations.Update =}
|
|
72
|
+
{=# operations.Delete =}
|
|
73
|
+
|
|
74
|
+
export interface {= entityUpper =}Delete {
|
|
75
|
+
action: ActionFor<RegisteredDeleteAction>;
|
|
76
|
+
useAction: UseActionFor<RegisteredDeleteAction>;
|
|
77
|
+
};
|
|
78
|
+
{=/ operations.Delete =}
|
|
79
|
+
|
|
80
|
+
function createCrud(): {= entityUpper =}Crud {
|
|
81
|
+
{=# operations.Get =}
|
|
82
|
+
const crudGetQuery = createQuery<RegisteredGetQuery>(
|
|
83
|
+
'{= fullPath =}',
|
|
84
|
+
{=& entitiesArray =}
|
|
85
|
+
)
|
|
86
|
+
{=/ operations.Get =}
|
|
87
|
+
{=# operations.GetAll =}
|
|
88
|
+
const crudGetAllQuery = createQuery<RegisteredGetAllQuery>(
|
|
89
|
+
'{= fullPath =}',
|
|
90
|
+
{=& entitiesArray =}
|
|
91
|
+
)
|
|
92
|
+
{=/ operations.GetAll =}
|
|
93
|
+
{=# operations.Create =}
|
|
94
|
+
const crudCreateAction = createAction<RegisteredCreateAction>(
|
|
95
|
+
'{= fullPath =}',
|
|
96
|
+
{=& entitiesArray =}
|
|
97
|
+
)
|
|
98
|
+
{=/ operations.Create =}
|
|
99
|
+
{=# operations.Update =}
|
|
100
|
+
const crudUpdateAction = createAction<RegisteredUpdateAction>(
|
|
101
|
+
'{= fullPath =}',
|
|
102
|
+
{=& entitiesArray =}
|
|
103
|
+
)
|
|
104
|
+
{=/ operations.Update =}
|
|
105
|
+
{=# operations.Delete =}
|
|
106
|
+
const crudDeleteAction = createAction<RegisteredDeleteAction>(
|
|
107
|
+
'{= fullPath =}',
|
|
108
|
+
{=& entitiesArray =}
|
|
109
|
+
)
|
|
110
|
+
{=/ operations.Delete =}
|
|
111
|
+
return {
|
|
24
112
|
{=# operations.Get =}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
113
|
+
get: {
|
|
114
|
+
query: crudGetQuery,
|
|
115
|
+
useQuery: makeUseQueryFor(crudGetQuery)
|
|
116
|
+
},
|
|
29
117
|
{=/ operations.Get =}
|
|
30
118
|
{=# operations.GetAll =}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
119
|
+
getAll: {
|
|
120
|
+
query: crudGetAllQuery,
|
|
121
|
+
useQuery: makeUseQueryFor(crudGetAllQuery)
|
|
122
|
+
},
|
|
35
123
|
{=/ operations.GetAll =}
|
|
36
124
|
{=# operations.Create =}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
125
|
+
create: {
|
|
126
|
+
action: crudCreateAction,
|
|
127
|
+
useAction: makeUseActionFor(crudCreateAction)
|
|
128
|
+
},
|
|
41
129
|
{=/ operations.Create =}
|
|
42
130
|
{=# operations.Update =}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
131
|
+
update: {
|
|
132
|
+
action: crudUpdateAction,
|
|
133
|
+
useAction: makeUseActionFor(crudUpdateAction)
|
|
134
|
+
},
|
|
47
135
|
{=/ operations.Update =}
|
|
48
136
|
{=# operations.Delete =}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
137
|
+
delete: {
|
|
138
|
+
action: crudDeleteAction,
|
|
139
|
+
useAction: makeUseActionFor(crudDeleteAction)
|
|
140
|
+
},
|
|
53
141
|
{=/ operations.Delete =}
|
|
54
|
-
|
|
55
|
-
{=# operations.Get =}
|
|
56
|
-
get: {
|
|
57
|
-
query: crudGetQuery,
|
|
58
|
-
useQuery: makeUseQueryFor(crudGetQuery)
|
|
59
|
-
},
|
|
60
|
-
{=/ operations.Get =}
|
|
61
|
-
{=# operations.GetAll =}
|
|
62
|
-
getAll: {
|
|
63
|
-
query: crudGetAllQuery,
|
|
64
|
-
useQuery: makeUseQueryFor(crudGetAllQuery)
|
|
65
|
-
},
|
|
66
|
-
{=/ operations.GetAll =}
|
|
67
|
-
{=# operations.Create =}
|
|
68
|
-
create: {
|
|
69
|
-
action: crudCreateAction,
|
|
70
|
-
useAction: makeUseActionFor(crudCreateAction)
|
|
71
|
-
},
|
|
72
|
-
{=/ operations.Create =}
|
|
73
|
-
{=# operations.Update =}
|
|
74
|
-
update: {
|
|
75
|
-
action: crudUpdateAction,
|
|
76
|
-
useAction: makeUseActionFor(crudUpdateAction)
|
|
77
|
-
},
|
|
78
|
-
{=/ operations.Update =}
|
|
79
|
-
{=# operations.Delete =}
|
|
80
|
-
delete: {
|
|
81
|
-
action: crudDeleteAction,
|
|
82
|
-
useAction: makeUseActionFor(crudDeleteAction)
|
|
83
|
-
},
|
|
84
|
-
{=/ operations.Delete =}
|
|
85
|
-
}
|
|
142
|
+
}
|
|
86
143
|
}
|
|
87
|
-
|
|
88
|
-
// PUBLIC API
|
|
89
|
-
export const {= name =} = createCrud();
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import * as z from "zod"
|
|
3
|
-
|
|
3
|
+
import type { FromRegister } from "../../types/register";
|
|
4
4
|
{=# envValidationSchema.isDefined =}
|
|
5
5
|
{=& envValidationSchema.importStatement =}
|
|
6
|
-
|
|
6
|
+
{=/ envValidationSchema.isDefined =}
|
|
7
|
+
|
|
8
|
+
export type RegisteredClientEnvValidationSchema = FromRegister<"clientEnvValidationSchema", z.ZodObject<{}>>;
|
|
9
|
+
type UserClientEnvSchema = RegisteredClientEnvValidationSchema;
|
|
10
|
+
|
|
11
|
+
{=# envValidationSchema.isDefined =}
|
|
12
|
+
const userClientEnvSchema: UserClientEnvSchema = {= envValidationSchema.importIdentifier =};
|
|
7
13
|
{=/ envValidationSchema.isDefined =}
|
|
8
14
|
{=^ envValidationSchema.isDefined =}
|
|
9
|
-
const userClientEnvSchema = z.object({});
|
|
15
|
+
const userClientEnvSchema: UserClientEnvSchema = z.object({});
|
|
10
16
|
{=/ envValidationSchema.isDefined =}
|
|
11
17
|
|
|
12
18
|
const serverUrlSchema =
|
|
@@ -20,8 +26,7 @@ const serverUrlSchema =
|
|
|
20
26
|
)
|
|
21
27
|
|
|
22
28
|
const waspDevClientEnvSchema = z.object({
|
|
23
|
-
"{= serverUrlEnvVarName =}": serverUrlSchema
|
|
24
|
-
.default("{= defaultServerUrl =}"),
|
|
29
|
+
"{= serverUrlEnvVarName =}": serverUrlSchema,
|
|
25
30
|
});
|
|
26
31
|
|
|
27
32
|
const waspProdClientEnvSchema = z.object({
|
|
@@ -32,8 +37,10 @@ const waspClientEnvSchema = import.meta.env.MODE === "production"
|
|
|
32
37
|
? waspProdClientEnvSchema
|
|
33
38
|
: waspDevClientEnvSchema;
|
|
34
39
|
|
|
40
|
+
export type CompleteClientEnvSchema = z.ZodObject<typeof waspClientEnvSchema["shape"] & UserClientEnvSchema["shape"]>;
|
|
41
|
+
|
|
35
42
|
// PRIVATE API (sdk, Vite config)
|
|
36
|
-
export const clientEnvSchema = z.object({
|
|
43
|
+
export const clientEnvSchema: CompleteClientEnvSchema = z.object({
|
|
37
44
|
...userClientEnvSchema.shape,
|
|
38
|
-
...waspClientEnvSchema.shape
|
|
45
|
+
...waspClientEnvSchema.shape
|
|
39
46
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type * as z from "zod";
|
|
2
|
+
import { ensureEnvSchema } from "@wasp.sh/lib-sdk-core";
|
|
3
|
+
import { type CompleteClientEnvSchema, clientEnvSchema } from "./env/schema";
|
|
3
4
|
|
|
4
5
|
// PUBLIC API
|
|
5
|
-
export const env = ensureEnvSchema(
|
|
6
|
+
export const env: z.infer<CompleteClientEnvSchema> = ensureEnvSchema(
|
|
6
7
|
import.meta.env,
|
|
7
8
|
clientEnvSchema,
|
|
8
9
|
);
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
// PUBLIC API
|
|
2
|
-
|
|
3
|
-
export enum HttpMethod {
|
|
4
|
-
Get = 'GET',
|
|
5
|
-
Post = 'POST',
|
|
6
|
-
Put = 'PUT',
|
|
7
|
-
Delete = 'DELETE',
|
|
8
|
-
}
|
|
2
|
+
export { HttpMethod, type ClientConfig, type Route } from '@wasp.sh/lib-sdk-core'
|
|
9
3
|
|
|
10
4
|
// PUBLIC API
|
|
11
|
-
export
|
|
5
|
+
export { config } from './config';
|
|
12
6
|
|
|
13
7
|
// PUBLIC API
|
|
14
|
-
export {
|
|
15
|
-
|
|
16
|
-
// PUBLIC API
|
|
17
|
-
export { env } from './env.js'
|
|
8
|
+
export { env } from './env';
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import type { _Awaited, _ReturnType } from '../../../universal/types.js'
|
|
2
|
-
import type { OperationRpcFor, GenericBackendOperation } from '../rpc.js'
|
|
3
|
-
import { callOperation, makeOperationRoute } from '../internal/index.js'
|
|
4
1
|
import {
|
|
2
|
+
type ActionFor,
|
|
3
|
+
type SpecificOptimisticUpdateDefinition,
|
|
5
4
|
registerActionInProgress,
|
|
6
5
|
registerActionDone,
|
|
7
|
-
} from '
|
|
6
|
+
} from '@wasp.sh/lib-sdk-core/browser'
|
|
7
|
+
import {
|
|
8
|
+
makeOperationRoute,
|
|
9
|
+
type OperationRpcFor,
|
|
10
|
+
type GenericBackendOperation,
|
|
11
|
+
} from '@wasp.sh/lib-sdk-core'
|
|
12
|
+
import { callOperation } from '../internal/index.js'
|
|
8
13
|
|
|
9
14
|
// PRIVATE API
|
|
10
15
|
export function createAction<BackendAction extends GenericBackendOperation>(
|
|
@@ -13,7 +18,10 @@ export function createAction<BackendAction extends GenericBackendOperation>(
|
|
|
13
18
|
): ActionFor<BackendAction> {
|
|
14
19
|
const actionRoute = makeOperationRoute(relativeActionRoute)
|
|
15
20
|
|
|
16
|
-
async function internalAction(
|
|
21
|
+
async function internalAction<CachedData>(
|
|
22
|
+
args: unknown,
|
|
23
|
+
specificOptimisticUpdateDefinitions: SpecificOptimisticUpdateDefinition<CachedData>[]
|
|
24
|
+
): Promise<unknown> {
|
|
17
25
|
registerActionInProgress(specificOptimisticUpdateDefinitions)
|
|
18
26
|
try {
|
|
19
27
|
// The `return await` is not redundant here. If we removed the await, the
|
|
@@ -34,7 +42,7 @@ export function createAction<BackendAction extends GenericBackendOperation>(
|
|
|
34
42
|
// While it does technically allow our users to access the interal API, it
|
|
35
43
|
// shouldn't be a problem in practice. Still, if it turns out to be a problem,
|
|
36
44
|
// we can always hide it using a Symbol.
|
|
37
|
-
const action = (args) => internalAction(args, [])
|
|
45
|
+
const action = (args: unknown) => internalAction(args, [])
|
|
38
46
|
action.internal = internalAction
|
|
39
47
|
|
|
40
48
|
// NOTE: I'm not sure why unknown is necessary here,
|
|
@@ -43,7 +51,3 @@ export function createAction<BackendAction extends GenericBackendOperation>(
|
|
|
43
51
|
// https://www.typescriptlang.org/play/?#code/MYewdgzgLgBCBGArGBeGBvGBDAXDA5AGYgj4wC+AUAogHTyoHxYBO+llA9JzIQK5hgUAJbhsAG3EgA7hGxgYAUwBuIccuFgA5jCgBPAA6KY8PrBqKhMACYhFcsCCiVQkWPwVoAFAEpUAPgJiUkoPekZ8ZjYgA
|
|
44
52
|
return action as unknown as ActionFor<BackendAction>
|
|
45
53
|
}
|
|
46
|
-
|
|
47
|
-
// PRIVATE API
|
|
48
|
-
export type ActionFor<BackendAction extends GenericBackendOperation> =
|
|
49
|
-
OperationRpcFor<BackendAction>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import {
|
|
2
|
+
import type { ActionFor } from '@wasp.sh/lib-sdk-core/browser'
|
|
3
|
+
import { createAction } from "./core";
|
|
4
|
+
import type {
|
|
3
5
|
{=# actions =}
|
|
4
|
-
{
|
|
6
|
+
{= registeredOperationTypeName =},
|
|
5
7
|
{=/ actions =}
|
|
8
|
+
} from "../../../server/operations/actions/index";
|
|
6
9
|
{=# actions =}
|
|
7
10
|
|
|
8
11
|
// PUBLIC API
|
|
9
|
-
export const {= operationName =}: ActionFor<{=
|
|
10
|
-
|
|
12
|
+
export const {= operationName =}: ActionFor<{= registeredOperationTypeName =}> = createAction<{= registeredOperationTypeName =}>(
|
|
13
|
+
"{= actionRoute =}",
|
|
11
14
|
{=& entitiesArray =},
|
|
12
15
|
)
|
|
13
16
|
{=/ actions =}
|
|
@@ -10,7 +10,7 @@ export {
|
|
|
10
10
|
useQuery,
|
|
11
11
|
// PUBLIC API
|
|
12
12
|
type OptimisticUpdateDefinition,
|
|
13
|
-
} from '
|
|
13
|
+
} from '@wasp.sh/lib-sdk-core/browser'
|
|
14
14
|
|
|
15
15
|
export {
|
|
16
16
|
// PUBLIC API
|
|
@@ -19,9 +19,9 @@ export {
|
|
|
19
19
|
initializeQueryClient,
|
|
20
20
|
// PRIVATE API (framework code)
|
|
21
21
|
queryClientInitialized
|
|
22
|
-
} from '
|
|
22
|
+
} from '@wasp.sh/lib-sdk-core/browser'
|
|
23
23
|
|
|
24
|
-
export {
|
|
24
|
+
export type {
|
|
25
25
|
// PUBLIC API
|
|
26
|
-
|
|
27
|
-
} from '
|
|
26
|
+
QueryMetadata,
|
|
27
|
+
} from '@wasp.sh/lib-sdk-core'
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import type { OperationRoute } from '@wasp.sh/lib-sdk-core'
|
|
1
2
|
import { api, handleApiError } from '../../../api/index.js'
|
|
2
3
|
import { HttpMethod } from '../../index.js'
|
|
3
4
|
import { serialize, deserialize } from '../../../core/serialization/index.js'
|
|
4
5
|
|
|
5
|
-
// PRIVATE API
|
|
6
|
-
export type OperationRoute = { method: HttpMethod.Post, path: string }
|
|
7
|
-
|
|
8
6
|
// PRIVATE API
|
|
9
7
|
export async function callOperation(operationRoute: OperationRoute, args: any) {
|
|
10
8
|
try {
|
|
@@ -17,8 +15,3 @@ export async function callOperation(operationRoute: OperationRoute, args: any) {
|
|
|
17
15
|
throw handleApiError(error)
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
// PRIVATE API
|
|
22
|
-
export function makeOperationRoute(relativeOperationRoute: string): OperationRoute {
|
|
23
|
-
return { method: HttpMethod.Post, path: `/${relativeOperationRoute}` }
|
|
24
|
-
}
|
|
@@ -1,31 +1,18 @@
|
|
|
1
|
-
import { Route } from '../../index.js'
|
|
2
|
-
import type { _Awaited, _ReturnType } from '../../../universal/types.js'
|
|
3
|
-
import type {
|
|
4
|
-
GenericBackendOperation,
|
|
5
|
-
GenericOperationRpc,
|
|
6
|
-
OperationRpcFor,
|
|
7
|
-
Query,
|
|
8
|
-
QueryMetadata,
|
|
9
|
-
} from '../rpc.js'
|
|
10
|
-
import { callOperation, makeOperationRoute } from '../internal/index.js'
|
|
11
1
|
import {
|
|
2
|
+
makeQueryCacheKey,
|
|
3
|
+
buildAndRegisterQuery,
|
|
4
|
+
type QueryFor,
|
|
12
5
|
addResourcesUsedByQuery,
|
|
13
6
|
getActiveOptimisticUpdates,
|
|
14
|
-
} from '
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
payload: Input
|
|
22
|
-
): (string | Input)[] {
|
|
23
|
-
return payload !== undefined ?
|
|
24
|
-
[...query.queryCacheKey, payload]
|
|
25
|
-
: query.queryCacheKey
|
|
26
|
-
}
|
|
7
|
+
} from '@wasp.sh/lib-sdk-core/browser'
|
|
8
|
+
import {
|
|
9
|
+
makeOperationRoute,
|
|
10
|
+
type GenericBackendOperation,
|
|
11
|
+
type OperationRpcFor,
|
|
12
|
+
} from '@wasp.sh/lib-sdk-core'
|
|
13
|
+
import { callOperation } from '../internal/index.js'
|
|
27
14
|
|
|
28
|
-
// PRIVATE API (
|
|
15
|
+
// PRIVATE API (used in SDK)
|
|
29
16
|
export function createQuery<BackendQuery extends GenericBackendOperation>(
|
|
30
17
|
relativeQueryPath: string,
|
|
31
18
|
entitiesUsed: string[]
|
|
@@ -33,14 +20,14 @@ export function createQuery<BackendQuery extends GenericBackendOperation>(
|
|
|
33
20
|
const queryRoute = makeOperationRoute(relativeQueryPath)
|
|
34
21
|
const queryCacheKey = [relativeQueryPath]
|
|
35
22
|
|
|
36
|
-
const queryFn = (async (queryArgs) => {
|
|
23
|
+
const queryFn = (async (queryArgs: Parameters<BackendQuery>[0]) => {
|
|
37
24
|
const serverResult = await callOperation(queryRoute, queryArgs)
|
|
38
25
|
// todo: The full queryCacheKey is constructed in two places, both here and
|
|
39
26
|
// inside the useQuery hook. See
|
|
40
27
|
// https://github.com/wasp-lang/wasp/issues/2017
|
|
41
28
|
const queryCacheKey = makeQueryCacheKey(queryFn as QueryFor<BackendQuery>, queryArgs)
|
|
42
29
|
return getActiveOptimisticUpdates(queryCacheKey).reduce(
|
|
43
|
-
(result, update) => update(result),
|
|
30
|
+
(result: unknown, update: (data: unknown) => unknown) => update(result),
|
|
44
31
|
serverResult,
|
|
45
32
|
)
|
|
46
33
|
// This assertion is necessary because, when the Input is void, we want to
|
|
@@ -54,38 +41,9 @@ export function createQuery<BackendQuery extends GenericBackendOperation>(
|
|
|
54
41
|
)
|
|
55
42
|
}
|
|
56
43
|
|
|
57
|
-
// PRIVATE API (used in SDK)
|
|
58
|
-
export function buildAndRegisterQuery<QF extends GenericOperationRpc>(
|
|
59
|
-
queryFn: QF,
|
|
60
|
-
{ queryCacheKey, queryRoute, entitiesUsed }:
|
|
61
|
-
{ queryCacheKey: string[], queryRoute: Route, entitiesUsed: string[] }
|
|
62
|
-
): QueryForFunction<QF> {
|
|
63
|
-
const query = queryFn as QueryForFunction<QF>
|
|
64
|
-
|
|
65
|
-
query.queryCacheKey = queryCacheKey
|
|
66
|
-
query.route = queryRoute
|
|
67
|
-
addResourcesUsedByQuery(query.queryCacheKey, entitiesUsed)
|
|
68
|
-
|
|
69
|
-
return query
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// PRIVATE API (but should maybe be public, users define values of this type)
|
|
73
|
-
/**
|
|
74
|
-
* Constructs the client Query object type from the type of the Query's definition
|
|
75
|
-
* on the backend.
|
|
76
|
-
*/
|
|
77
|
-
export type QueryFor<BackendQuery extends GenericBackendOperation> =
|
|
78
|
-
QueryForFunction<QueryFunctionFor<BackendQuery>>
|
|
79
|
-
|
|
80
44
|
/**
|
|
81
45
|
* Constructs the client Query function type from the type of the Query's
|
|
82
46
|
* definition on the backend.
|
|
83
47
|
*/
|
|
84
48
|
type QueryFunctionFor<BackendQuery extends GenericBackendOperation> =
|
|
85
49
|
OperationRpcFor<BackendQuery>
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Returns the appropriate client Query object type for the provided client
|
|
89
|
-
* Query function type.
|
|
90
|
-
*/
|
|
91
|
-
type QueryForFunction<QF extends GenericOperationRpc> = QF & QueryMetadata
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import {
|
|
2
|
+
import type { QueryFor } from '@wasp.sh/lib-sdk-core/browser'
|
|
3
|
+
import { createQuery } from "./core";
|
|
4
|
+
import type {
|
|
3
5
|
{=# queries =}
|
|
4
|
-
{
|
|
6
|
+
{= registeredOperationTypeName =},
|
|
5
7
|
{=/ queries =}
|
|
8
|
+
} from "../../../server/operations/queries/index";
|
|
6
9
|
{=# queries =}
|
|
7
10
|
|
|
8
11
|
// PUBLIC API
|
|
9
|
-
export const {= operationName =}: QueryFor<{=
|
|
10
|
-
|
|
12
|
+
export const {= operationName =}: QueryFor<{= registeredOperationTypeName =}> = createQuery<{= registeredOperationTypeName =}>(
|
|
13
|
+
"{= queryRoute =}",
|
|
11
14
|
{=& entitiesArray =},
|
|
12
15
|
)
|
|
13
16
|
{=/ queries =}
|
|
14
|
-
|
|
15
|
-
// PRIVATE API (used in SDK)
|
|
16
|
-
export { buildAndRegisterQuery } from './core'
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { useMemo } from 'react'
|
|
2
2
|
import { Link as RouterLink } from 'react-router'
|
|
3
|
-
import { interpolatePath } from '
|
|
4
|
-
import {
|
|
3
|
+
import { interpolatePath, type OptionalRouteOptions } from '@wasp.sh/lib-sdk-core'
|
|
4
|
+
import type { Routes } from './index'
|
|
5
5
|
|
|
6
6
|
type RouterLinkProps = Parameters<typeof RouterLink>[0]
|
|
7
7
|
|
|
8
8
|
// PUBLIC API
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
& {
|
|
12
|
-
search?: Record<string, string>;
|
|
13
|
-
hash?: string;
|
|
14
|
-
}
|
|
9
|
+
export type LinkProps = Omit<RouterLinkProps, "to">
|
|
10
|
+
& OptionalRouteOptions
|
|
15
11
|
& Routes
|
|
12
|
+
|
|
13
|
+
// PUBLIC API
|
|
14
|
+
export function Link(
|
|
15
|
+
{ to, params, search, hash, ...restOfProps }: LinkProps
|
|
16
16
|
): React.JSX.Element {
|
|
17
17
|
const toPropWithParams = useMemo(() => {
|
|
18
18
|
return interpolatePath(to, params, search, hash)
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { useMemo } from 'react'
|
|
2
2
|
import { NavLink as RouterNavLink } from 'react-router'
|
|
3
|
-
import { interpolatePath } from '
|
|
4
|
-
import {
|
|
3
|
+
import { interpolatePath, type OptionalRouteOptions } from '@wasp.sh/lib-sdk-core'
|
|
4
|
+
import type { Routes } from './index'
|
|
5
5
|
|
|
6
6
|
type RouterNavLinkProps = Parameters<typeof RouterNavLink>[0]
|
|
7
7
|
|
|
8
8
|
// PUBLIC API
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
& {
|
|
12
|
-
search?: Record<string, string>;
|
|
13
|
-
hash?: string;
|
|
14
|
-
}
|
|
9
|
+
export type NavLinkProps = Omit<RouterNavLinkProps, "to">
|
|
10
|
+
& OptionalRouteOptions
|
|
15
11
|
& Routes
|
|
12
|
+
|
|
13
|
+
// PUBLIC API
|
|
14
|
+
export function NavLink(
|
|
15
|
+
{ to, params, search, hash, ...restOfProps }: NavLinkProps
|
|
16
16
|
): React.JSX.Element {
|
|
17
17
|
const toPropWithParams = useMemo(() => {
|
|
18
18
|
return interpolatePath(to, params, search, hash)
|