@wasp.sh/wasp-cli-darwin-arm64-unknown 0.24.0 → 0.25.0-rc.1
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/basic/main.wasp.ts +1 -1
- package/data/Cli/starters/basic/package.json +5 -5
- package/data/Cli/starters/basic/src/App.css +12 -11
- package/data/Cli/starters/basic/src/assets/wasp-logo-rounded.svg +1 -0
- package/data/Cli/starters/basic/src/shared/components/Header.tsx +3 -3
- package/data/Cli/starters/minimal/main.wasp.ts +1 -1
- package/data/Cli/starters/minimal/package.json +4 -4
- package/data/Cli/starters/minimal/src/Main.css +5 -5
- package/data/Cli/starters/minimal/src/MainPage.tsx +2 -2
- package/data/Cli/starters/minimal/src/assets/wasp-logo-rounded.svg +1 -0
- package/data/Cli/starters/skeleton/public/favicon.ico +0 -0
- package/data/Cli/starters/skeleton/tsconfig.src.json +2 -1
- package/data/Cli/starters/skeleton/tsconfig.wasp.json +3 -2
- package/data/Generator/libs/auth/wasp.sh-lib-auth-0.25.0.tgz +0 -0
- package/data/Generator/libs/vite-ssr/wasp.sh-lib-vite-ssr-0.25.0.tgz +0 -0
- package/data/Generator/templates/sdk/wasp/api/index.ts +2 -2
- package/data/Generator/templates/sdk/wasp/auth/email/actions/login.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/email/actions/passwordReset.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/email/actions/signup.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/email/actions/verifyEmail.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/auth-styles.css +2 -2
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/common/LoginSignupForm.tsx +1 -1
- package/data/Generator/templates/sdk/wasp/auth/helpers/_Provider.tsx +1 -1
- package/data/Generator/templates/sdk/wasp/auth/helpers/user.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/jwt.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/logout.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/lucia.ts +2 -2
- package/data/Generator/templates/sdk/wasp/auth/providers/types.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/session.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/types.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/useAuth.ts +5 -5
- package/data/Generator/templates/sdk/wasp/auth/username/actions/login.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/username/actions/signup.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/utils.ts +3 -3
- package/data/Generator/templates/sdk/wasp/auth/validation.ts +1 -1
- package/data/Generator/templates/sdk/wasp/client/app/layout.tsx +55 -46
- package/data/Generator/templates/sdk/wasp/client/app/router.tsx +2 -5
- package/data/Generator/templates/sdk/wasp/client/crud/_crud.ts +2 -2
- package/data/Generator/templates/sdk/wasp/client/operations/actions/core.ts +1 -1
- package/data/Generator/templates/sdk/wasp/client/operations/index.ts +5 -0
- package/data/Generator/templates/sdk/wasp/client/operations/internal/index.ts +3 -3
- package/data/Generator/templates/sdk/wasp/client/operations/internal/resources.js +4 -2
- package/data/Generator/templates/sdk/wasp/client/operations/queries/core.ts +2 -2
- package/data/Generator/templates/sdk/wasp/client/operations/rpc.ts +2 -2
- package/data/Generator/templates/sdk/wasp/client/test/vitest/helpers.tsx +3 -4
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/validateEnv.ts +14 -8
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/client-entry.tsx +31 -11
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/routes.tsx +26 -20
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/ssr-entry.tsx +29 -24
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/resolver.ts +12 -5
- package/data/Generator/templates/sdk/wasp/client/webSocket/WebSocketProvider.tsx +4 -4
- package/data/Generator/templates/sdk/wasp/client/webSocket/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/core/auth.ts +3 -3
- package/data/Generator/templates/sdk/wasp/env/validation.ts +1 -1
- package/data/Generator/templates/sdk/wasp/package.json +2 -42
- package/data/Generator/templates/sdk/wasp/serialization/index.ts +11 -0
- package/data/Generator/templates/sdk/wasp/server/_types/index.ts +6 -6
- package/data/Generator/templates/sdk/wasp/server/_types/taggedEntities.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/email/utils.ts +6 -6
- package/data/Generator/templates/sdk/wasp/server/crud/_operationTypes.ts +2 -2
- package/data/Generator/templates/sdk/wasp/server/email/core/index.ts +4 -0
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/dummy.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/resend.ts +31 -0
- package/data/Generator/templates/sdk/wasp/server/email/core/types.ts +7 -1
- package/data/Generator/templates/sdk/wasp/server/email/index.ts +6 -0
- package/data/Generator/templates/sdk/wasp/server/env.ts +5 -0
- package/data/Generator/templates/sdk/wasp/server/jobs/_job.ts +2 -2
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBossJob.ts +3 -3
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/types.ts +2 -2
- package/data/Generator/templates/sdk/wasp/server/operations/actions/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/operations/actions/types.ts +2 -2
- package/data/Generator/templates/sdk/wasp/server/operations/queries/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/operations/queries/types.ts +2 -2
- package/data/Generator/templates/sdk/wasp/server/operations/wrappers.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/webSocket/index.ts +2 -3
- package/data/Generator/templates/sdk/wasp/tsconfig.json +1 -0
- package/data/Generator/templates/server/tsconfig.json +2 -1
- package/data/packages/deploy/package-lock.json +2015 -2285
- package/data/packages/deploy/package.json +7 -6
- package/data/packages/prisma/package-lock.json +1730 -2131
- package/data/packages/prisma/package.json +6 -6
- package/data/packages/spec/dist/__tests__/spec/appAnalyzer.unit.test.js +4 -4
- package/data/packages/spec/dist/__tests__/spec/mapApp.unit.test.js +161 -129
- package/data/packages/spec/dist/__tests__/spec/normalizePrerender.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/normalizePrerender.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/normalizePrerender.unit.test.js +15 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.unit.test.js +2 -2
- package/data/packages/spec/dist/__tests__/spec/refObjectPath.unit.test.js +3 -3
- package/data/packages/spec/dist/__tests__/spec-pipeline/pipeline.integration.test.js +38 -7
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/imports.unit.test.js +5 -5
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/refHelper.unit.test.js +2 -2
- package/data/packages/spec/dist/src/appSpec.d.ts +2 -2
- package/data/packages/spec/dist/src/appSpec.d.ts.map +1 -1
- package/data/packages/spec/dist/src/normalizePrerender.d.ts +11 -0
- package/data/packages/spec/dist/src/normalizePrerender.d.ts.map +1 -0
- package/data/packages/spec/dist/src/normalizePrerender.js +18 -0
- package/data/packages/spec/dist/src/run.js +2 -2
- package/data/packages/spec/dist/src/spec/appAnalyzer.js +5 -5
- package/data/packages/spec/dist/src/spec/mapper/app.d.ts +17 -0
- package/data/packages/spec/dist/src/spec/mapper/app.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/mapper/app.js +119 -0
- package/data/packages/spec/dist/src/spec/mapper/context.d.ts +19 -0
- package/data/packages/spec/dist/src/spec/mapper/context.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/mapper/context.js +65 -0
- package/data/packages/spec/dist/src/spec/mapper/index.d.ts +7 -0
- package/data/packages/spec/dist/src/spec/mapper/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/mapper/index.js +20 -0
- package/data/packages/spec/dist/src/spec/mapper/specElements.d.ts +28 -0
- package/data/packages/spec/dist/src/spec/mapper/specElements.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/mapper/specElements.js +162 -0
- package/data/packages/spec/dist/src/spec/publicApi/constructors.d.ts +54 -13
- package/data/packages/spec/dist/src/spec/publicApi/constructors.d.ts.map +1 -1
- package/data/packages/spec/dist/src/spec/publicApi/constructors.js +10 -7
- package/data/packages/spec/dist/src/spec/publicApi/index.d.ts +2 -0
- package/data/packages/spec/dist/src/spec/publicApi/index.d.ts.map +1 -1
- package/data/packages/spec/dist/src/spec/publicApi/index.js +1 -0
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts +23 -10
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts.map +1 -1
- package/data/packages/spec/dist/src/spec/refObject.js +4 -4
- package/data/packages/spec/dist/src/spec/refObjectPath.js +2 -2
- package/data/packages/spec/dist/src/spec/waspSpecUserError.d.ts +31 -0
- package/data/packages/spec/dist/src/spec/waspSpecUserError.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/waspSpecUserError.js +30 -0
- package/data/packages/spec/dist/src/spec-pipeline/loadWaspTsSpec.d.ts.map +1 -1
- package/data/packages/spec/dist/src/spec-pipeline/loadWaspTsSpec.js +18 -15
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/apply.js +2 -2
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/check.js +2 -2
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/plan.js +2 -2
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/check.js +2 -2
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/index.js +2 -2
- package/data/packages/spec/package-lock.json +189 -169
- package/data/packages/spec/package.json +30 -7
- package/data/packages/studio/dist/public/assets/Flow-CyIU6UP_.js +26 -0
- package/data/packages/studio/dist/public/assets/dist-CttM53IC.js +1 -0
- package/data/packages/studio/dist/public/assets/index-Cb2AqsRv.js +20 -0
- package/data/packages/studio/dist/public/assets/index-Cq-JJ-zI.css +1 -0
- package/data/packages/studio/dist/public/index.html +2 -2
- package/data/packages/studio/package-lock.json +6 -6
- package/data/packages/studio/package.json +2 -2
- package/data/packages/ts-inspect/package-lock.json +1918 -2142
- package/data/packages/ts-inspect/package.json +6 -6
- package/package.json +1 -1
- package/wasp-bin +0 -0
- package/data/Cli/starters/basic/src/assets/logo.svg +0 -1
- package/data/Cli/starters/minimal/src/assets/logo.svg +0 -1
- package/data/Cli/starters/skeleton/public/.gitkeep +0 -0
- package/data/Generator/libs/auth/wasp.sh-lib-auth-0.24.0.tgz +0 -0
- package/data/Generator/libs/vite-ssr/wasp.sh-lib-vite-ssr-0.24.0.tgz +0 -0
- package/data/Generator/templates/sdk/wasp/client/app/hooks/useIsClient.ts +0 -16
- package/data/packages/spec/dist/__tests__/legacy/appAnalyzer.unit.test.d.ts +0 -2
- package/data/packages/spec/dist/__tests__/legacy/appAnalyzer.unit.test.d.ts.map +0 -1
- package/data/packages/spec/dist/__tests__/legacy/appAnalyzer.unit.test.js +0 -72
- package/data/packages/spec/dist/__tests__/legacy/mapTsAppSpecToAppSpecDecls.integration.test.d.ts +0 -2
- package/data/packages/spec/dist/__tests__/legacy/mapTsAppSpecToAppSpecDecls.integration.test.d.ts.map +0 -1
- package/data/packages/spec/dist/__tests__/legacy/mapTsAppSpecToAppSpecDecls.integration.test.js +0 -126
- package/data/packages/spec/dist/__tests__/legacy/mapTsAppSpecToAppSpecDecls.unit.test.d.ts +0 -2
- package/data/packages/spec/dist/__tests__/legacy/mapTsAppSpecToAppSpecDecls.unit.test.d.ts.map +0 -1
- package/data/packages/spec/dist/__tests__/legacy/mapTsAppSpecToAppSpecDecls.unit.test.js +0 -732
- package/data/packages/spec/dist/__tests__/legacy/testFixtures.d.ts +0 -224
- package/data/packages/spec/dist/__tests__/legacy/testFixtures.d.ts.map +0 -1
- package/data/packages/spec/dist/__tests__/legacy/testFixtures.js +0 -659
- package/data/packages/spec/dist/__tests__/legacy/testFixtures.test-d.d.ts +0 -2
- package/data/packages/spec/dist/__tests__/legacy/testFixtures.test-d.d.ts.map +0 -1
- package/data/packages/spec/dist/__tests__/legacy/testFixtures.test-d.js +0 -57
- package/data/packages/spec/dist/src/legacy/_private.d.ts +0 -2
- package/data/packages/spec/dist/src/legacy/_private.d.ts.map +0 -1
- package/data/packages/spec/dist/src/legacy/_private.js +0 -1
- package/data/packages/spec/dist/src/legacy/appAnalyzer.d.ts +0 -16
- package/data/packages/spec/dist/src/legacy/appAnalyzer.d.ts.map +0 -1
- package/data/packages/spec/dist/src/legacy/appAnalyzer.js +0 -34
- package/data/packages/spec/dist/src/legacy/mapTsAppSpecToAppSpecDecls.d.ts +0 -38
- package/data/packages/spec/dist/src/legacy/mapTsAppSpecToAppSpecDecls.d.ts.map +0 -1
- package/data/packages/spec/dist/src/legacy/mapTsAppSpecToAppSpecDecls.js +0 -294
- package/data/packages/spec/dist/src/legacy/publicApi/App.d.ts +0 -24
- package/data/packages/spec/dist/src/legacy/publicApi/App.d.ts.map +0 -1
- package/data/packages/spec/dist/src/legacy/publicApi/App.js +0 -75
- package/data/packages/spec/dist/src/legacy/publicApi/tsAppSpec.d.ts +0 -174
- package/data/packages/spec/dist/src/legacy/publicApi/tsAppSpec.d.ts.map +0 -1
- package/data/packages/spec/dist/src/legacy/publicApi/tsAppSpec.js +0 -1
- package/data/packages/spec/dist/src/spec/mapApp.d.ts +0 -54
- package/data/packages/spec/dist/src/spec/mapApp.d.ts.map +0 -1
- package/data/packages/spec/dist/src/spec/mapApp.js +0 -336
- package/data/packages/spec/dist/src/spec/specUserError.d.ts +0 -9
- package/data/packages/spec/dist/src/spec/specUserError.d.ts.map +0 -1
- package/data/packages/spec/dist/src/spec/specUserError.js +0 -8
- package/data/packages/studio/dist/public/assets/Flow-_d98T2dd.js +0 -26
- package/data/packages/studio/dist/public/assets/index-B6X8EdJH.js +0 -21
- package/data/packages/studio/dist/public/assets/index-CXlD_bzV.js +0 -1
- package/data/packages/studio/dist/public/assets/index-IWX3d-Jz.css +0 -1
|
@@ -65,8 +65,10 @@ async function invalidateQueriesUsing(resources) {
|
|
|
65
65
|
const queryClient = await queryClientInitialized
|
|
66
66
|
|
|
67
67
|
const queryCacheKeysToInvalidate = getQueriesUsingResources(resources)
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
await Promise.all(
|
|
69
|
+
queryCacheKeysToInvalidate.map(
|
|
70
|
+
queryCacheKey => queryClient.invalidateQueries(queryCacheKey)
|
|
71
|
+
)
|
|
70
72
|
)
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Route } from '
|
|
2
|
-
import type { _Awaited, _ReturnType } from '
|
|
1
|
+
import { Route } from '../../index.js'
|
|
2
|
+
import type { _Awaited, _ReturnType } from '../../../universal/types.js'
|
|
3
3
|
import type {
|
|
4
4
|
GenericBackendOperation,
|
|
5
5
|
GenericOperationRpc,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type Route } from "
|
|
1
|
+
import { type Route } from "../index.js";
|
|
2
2
|
import type {
|
|
3
3
|
IfAny,
|
|
4
4
|
_Awaited,
|
|
5
5
|
_ReturnType,
|
|
6
|
-
} from "
|
|
6
|
+
} from "../../universal/types.js"
|
|
7
7
|
|
|
8
8
|
// PRIVATE API (for SDK, should maybe be public, users define values of this
|
|
9
9
|
// type).
|
|
@@ -5,10 +5,9 @@ import { BrowserRouter as Router } from 'react-router'
|
|
|
5
5
|
import { render, RenderResult, cleanup } from '@testing-library/react'
|
|
6
6
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
7
7
|
import { beforeAll, afterEach, afterAll } from 'vitest'
|
|
8
|
-
import { Query } from '
|
|
9
|
-
import { config } from '
|
|
10
|
-
import {
|
|
11
|
-
import { serialize } from 'wasp/core/serialization'
|
|
8
|
+
import { Query } from '../../operations/rpc.js'
|
|
9
|
+
import { config, HttpMethod, Route } from '../../index.js'
|
|
10
|
+
import { serialize } from '../../../core/serialization/index.js'
|
|
12
11
|
|
|
13
12
|
// PRIVATE API
|
|
14
13
|
export type MockQuery = <Input, Output, MockOutput extends Output>(
|
|
@@ -16,18 +16,18 @@ export function validateEnv(): Plugin {
|
|
|
16
16
|
return {
|
|
17
17
|
name: PLUGIN_NAME,
|
|
18
18
|
configResolved(config) {
|
|
19
|
-
resolvedConfig = config;
|
|
19
|
+
resolvedConfig = config;
|
|
20
20
|
},
|
|
21
21
|
// We validate just before any artifacts are built.
|
|
22
22
|
async buildStart() {
|
|
23
23
|
// We need to import the client env schema validation module
|
|
24
24
|
// through a Vite server, because both the user and the Wasp schema
|
|
25
25
|
// modules may depend on bundler features.
|
|
26
|
-
// Because of that we spin up a
|
|
26
|
+
// Because of that we spin up a temporary Vite server.
|
|
27
27
|
//
|
|
28
28
|
// Alternatively, for `serve`, we could use the Vite server provided
|
|
29
29
|
// through the `configureServer` hook, but that would complicate
|
|
30
|
-
// the solution for negligible performance benefits.
|
|
30
|
+
// the solution for negligible performance benefits.
|
|
31
31
|
const tempServer = await createViteServer({
|
|
32
32
|
root: resolvedConfig.root,
|
|
33
33
|
mode: resolvedConfig.mode,
|
|
@@ -36,6 +36,11 @@ export function validateEnv(): Plugin {
|
|
|
36
36
|
configFile: false,
|
|
37
37
|
plugins: resolvedConfig.plugins
|
|
38
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
|
+
|
|
39
44
|
// Vite's `configureServer`/`configurePreviewServer` hooks let plugins
|
|
40
45
|
// wire long-lived behavior into a dev or preview server: middleware,
|
|
41
46
|
// websocket handlers, file watchers, and similar background tasks.
|
|
@@ -52,12 +57,13 @@ export function validateEnv(): Plugin {
|
|
|
52
57
|
configureServer: undefined,
|
|
53
58
|
configurePreviewServer: undefined,
|
|
54
59
|
})),
|
|
60
|
+
|
|
55
61
|
// Minimize side effects from spinning up a temporary dev server.
|
|
56
62
|
appType: 'custom', // avoid HTML handling
|
|
57
|
-
server: {
|
|
63
|
+
server: {
|
|
58
64
|
middlewareMode: true, // do not start an actual HTTP server
|
|
59
|
-
watch: null,
|
|
60
|
-
hmr: false
|
|
65
|
+
watch: null,
|
|
66
|
+
hmr: false
|
|
61
67
|
},
|
|
62
68
|
logLevel: "silent",
|
|
63
69
|
optimizeDeps: { noDiscovery: true, include: [] },
|
|
@@ -66,12 +72,12 @@ export function validateEnv(): Plugin {
|
|
|
66
72
|
|
|
67
73
|
try {
|
|
68
74
|
// Vite's `ssr` means bundled for "backend JS runtime", like Node.
|
|
69
|
-
// This
|
|
75
|
+
// This environment is always runnable in vite dev server.
|
|
70
76
|
if (!isRunnableDevEnvironment(tempServer.environments.ssr)) {
|
|
71
77
|
throw new Error(`Expected ssr to be a runnable dev environment`)
|
|
72
78
|
}
|
|
73
79
|
// The imported module runs env schema validation as an import
|
|
74
|
-
// side-effect and throws on failure.
|
|
80
|
+
// side-effect and throws on failure.
|
|
75
81
|
const moduleAbsPath = path.resolve(resolvedConfig.root, CLIENT_ENV_SCHEMA_VALIDATION_MODULE);
|
|
76
82
|
await tempServer.environments.ssr.runner.import(moduleAbsPath);
|
|
77
83
|
} finally {
|
|
@@ -12,23 +12,43 @@ import { WaspApp } from "wasp/client/app";
|
|
|
12
12
|
const router = createBrowserRouter({= routeObjects.importIdentifier =}, {
|
|
13
13
|
basename: "{= baseDir =}",
|
|
14
14
|
// React Router will put hydration data on this property of the `window` object.
|
|
15
|
-
// https://reactrouter.com/
|
|
15
|
+
// https://reactrouter.com/8.0.1/start/data/custom#4-hydrate-in-the-browser
|
|
16
16
|
hydrationData: window.__staticRouterHydrationData,
|
|
17
17
|
})
|
|
18
18
|
|
|
19
19
|
// We embed this data at prerendering time.
|
|
20
20
|
const { isFallbackPage } = window.__WASP_SSR_DATA__ ?? {}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
22
|
+
const routerProviderPromise =
|
|
23
|
+
waitForRouterInitialized(router).then(() => (
|
|
24
|
+
<RouterProvider router={router} />
|
|
25
|
+
))
|
|
26
|
+
|
|
27
|
+
const fullAppTree = (
|
|
28
|
+
<Layout isFallbackPage={isFallbackPage}>
|
|
29
|
+
<WaspApp>
|
|
30
|
+
{routerProviderPromise}
|
|
31
|
+
</WaspApp>
|
|
32
|
+
</Layout>
|
|
33
|
+
)
|
|
31
34
|
|
|
32
35
|
startTransition(() => {
|
|
33
|
-
hydrateRoot(document,
|
|
36
|
+
hydrateRoot(document, fullAppTree);
|
|
34
37
|
});
|
|
38
|
+
|
|
39
|
+
async function waitForRouterInitialized(
|
|
40
|
+
router: ReturnType<typeof createBrowserRouter>,
|
|
41
|
+
): Promise<void> {
|
|
42
|
+
if (router.state.initialized) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return new Promise((resolve) => {
|
|
47
|
+
const unsubscribe = router.subscribe(() => {
|
|
48
|
+
if (router.state.initialized) {
|
|
49
|
+
unsubscribe();
|
|
50
|
+
resolve();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { getRouteObjects } from "wasp/client/app/router";
|
|
3
3
|
import { initializeQueryClient } from "wasp/client/operations";
|
|
4
|
-
|
|
4
|
+
{=^ rootComponent.isDefined =}
|
|
5
|
+
import { Outlet } from "react-router"
|
|
6
|
+
{=/ rootComponent.isDefined =}
|
|
5
7
|
|
|
6
8
|
{=# isAuthEnabled =}
|
|
7
9
|
import { createAuthRequiredPage } from "wasp/client/app"
|
|
@@ -25,19 +27,19 @@ const routesMapping = {
|
|
|
25
27
|
{=# routes =}
|
|
26
28
|
{=# isLazy =}
|
|
27
29
|
{= name =}: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
lazy: async () => {
|
|
31
|
+
const Component = await {=& import.dynamicImportExpression =};
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
Component:
|
|
35
|
+
{=# isAuthRequired =}
|
|
36
|
+
createAuthRequiredPage(Component),
|
|
37
|
+
{=/ isAuthRequired =}
|
|
38
|
+
{=^ isAuthRequired =}
|
|
39
|
+
Component,
|
|
40
|
+
{=/ isAuthRequired =}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
41
43
|
},
|
|
42
44
|
{=/ isLazy =}
|
|
43
45
|
{=^ isLazy =}
|
|
@@ -60,12 +62,16 @@ await {= setupFn.importIdentifier =}()
|
|
|
60
62
|
initializeQueryClient()
|
|
61
63
|
|
|
62
64
|
const rootElement =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
// We don't really need to wrap the app in a div nor name it "root", but we
|
|
66
|
+
// keep it for backwards compatibility with older Wasp versions.
|
|
67
|
+
<div id="root">
|
|
68
|
+
{=# rootComponent.isDefined =}
|
|
69
|
+
<{= rootComponent.importIdentifier =} />
|
|
70
|
+
{=/ rootComponent.isDefined =}
|
|
71
|
+
{=^ rootComponent.isDefined =}
|
|
72
|
+
<Outlet />
|
|
73
|
+
{=/ rootComponent.isDefined =}
|
|
74
|
+
</div>
|
|
69
75
|
|
|
70
76
|
export const routeObjects = getRouteObjects({
|
|
71
77
|
routesMapping,
|
|
@@ -6,7 +6,7 @@ import { prerenderToNodeStream as reactPrerender } from "react-dom/static";
|
|
|
6
6
|
import {
|
|
7
7
|
createStaticHandler,
|
|
8
8
|
createStaticRouter,
|
|
9
|
-
|
|
9
|
+
StaticRouterProvider,
|
|
10
10
|
} from "react-router";
|
|
11
11
|
|
|
12
12
|
import { Layout } from "wasp/client/app/layout";
|
|
@@ -17,34 +17,21 @@ import { WaspApp } from "wasp/client/app";
|
|
|
17
17
|
const SPA_FALLBACK_FILE = "{= spaFallbackFile =}";
|
|
18
18
|
|
|
19
19
|
const prerenderApp: PrerenderFn = async (route, { clientEntrySrc }) => {
|
|
20
|
-
const { query, dataRoutes } = createStaticHandler({= routeObjects.importIdentifier =}, {
|
|
21
|
-
basename: "{= baseDir =}",
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const req = new Request(new URL(route, "http://localhost"));
|
|
25
|
-
|
|
26
|
-
const context = await query(req);
|
|
27
|
-
assert(
|
|
28
|
-
!(context instanceof Response),
|
|
29
|
-
"Redirects from React Router's `loader`s are not supported",
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const router = createStaticRouter(dataRoutes, context);
|
|
33
20
|
const isFallbackPage = route === SPA_FALLBACK_FILE;
|
|
34
21
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</
|
|
42
|
-
|
|
43
|
-
|
|
22
|
+
const staticRouterProvider = isFallbackPage ? undefined : (await makeStaticRouterProvider(route));
|
|
23
|
+
|
|
24
|
+
const fullAppTree = (
|
|
25
|
+
<Layout isFallbackPage={isFallbackPage} clientEntrySrc={clientEntrySrc}>
|
|
26
|
+
<WaspApp>
|
|
27
|
+
{staticRouterProvider}
|
|
28
|
+
</WaspApp>
|
|
29
|
+
</Layout>
|
|
30
|
+
)
|
|
44
31
|
|
|
45
32
|
const WASP_SSR_DATA: WaspSSRData = { isFallbackPage }
|
|
46
33
|
|
|
47
|
-
const html = await reactPrerender(
|
|
34
|
+
const html = await reactPrerender(fullAppTree, {
|
|
48
35
|
bootstrapScriptContent: `window.__WASP_SSR_DATA__=${JSON.stringify(WASP_SSR_DATA)};`,
|
|
49
36
|
})
|
|
50
37
|
.then((result) => streamConsumers.text(result.prelude))
|
|
@@ -53,3 +40,21 @@ const prerenderApp: PrerenderFn = async (route, { clientEntrySrc }) => {
|
|
|
53
40
|
}
|
|
54
41
|
|
|
55
42
|
export default prerenderApp;
|
|
43
|
+
|
|
44
|
+
const { query, dataRoutes } = createStaticHandler({= routeObjects.importIdentifier =}, {
|
|
45
|
+
basename: "{= baseDir =}",
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
async function makeStaticRouterProvider(route: string) {
|
|
49
|
+
const req = new Request(new URL(route, "http://localhost"));
|
|
50
|
+
|
|
51
|
+
const context = await query(req);
|
|
52
|
+
assert(
|
|
53
|
+
!(context instanceof Response),
|
|
54
|
+
"Redirects from React Router's `loader`s are not supported",
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const router = createStaticRouter(dataRoutes, context);
|
|
58
|
+
|
|
59
|
+
return <StaticRouterProvider router={router} context={context} />;
|
|
60
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as path from "node:path"
|
|
1
|
+
import * as path from "node:path"
|
|
2
2
|
|
|
3
3
|
export type VirtualFiles = {
|
|
4
4
|
ids: ReadonlyMap<string, string>;
|
|
@@ -18,11 +18,18 @@ export const makeVirtualFilesResolver =
|
|
|
18
18
|
absPath: path.resolve(rootPath, path.basename(d.id)),
|
|
19
19
|
}));
|
|
20
20
|
|
|
21
|
-
const ids = new Map(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
+
),
|
|
25
30
|
);
|
|
26
31
|
|
|
32
|
+
const loaders = new Map(filesWithAbsPath.map((d) => [d.absPath, d.load]));
|
|
33
|
+
|
|
27
34
|
return { ids, loaders };
|
|
28
35
|
};
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { createContext, useState, useEffect, Context, ReactNode } from 'react'
|
|
3
3
|
import { io, Socket } from 'socket.io-client'
|
|
4
4
|
|
|
5
|
-
import { getSessionId } from '
|
|
6
|
-
import { apiEventsEmitter } from '
|
|
7
|
-
import { config } from '
|
|
5
|
+
import { getSessionId } from '../../api/index.js'
|
|
6
|
+
import { apiEventsEmitter } from '../../api/events.js'
|
|
7
|
+
import { config } from '../index.js'
|
|
8
8
|
|
|
9
|
-
import type { ClientToServerEvents, ServerToClientEvents } from '
|
|
9
|
+
import type { ClientToServerEvents, ServerToClientEvents } from '../../server/webSocket/index.js';
|
|
10
10
|
|
|
11
11
|
export type WebSocketContextValue = {
|
|
12
12
|
socket: typeof socket
|
|
@@ -3,7 +3,7 @@ import { WebSocketContext, WebSocketContextValue } from './WebSocketProvider'
|
|
|
3
3
|
import type {
|
|
4
4
|
ClientToServerEvents,
|
|
5
5
|
ServerToClientEvents,
|
|
6
|
-
} from '
|
|
6
|
+
} from '../../server/webSocket/index.js'
|
|
7
7
|
|
|
8
8
|
// PUBLIC API
|
|
9
9
|
export type ServerToClientPayload<Event extends keyof ServerToClientEvents> =
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getSessionAndUserFromBearerToken } from '
|
|
2
|
-
import { createInvalidCredentialsError } from '
|
|
3
|
-
import { defineHandler } from '
|
|
1
|
+
import { getSessionAndUserFromBearerToken } from '../auth/session.js'
|
|
2
|
+
import { createInvalidCredentialsError } from '../auth/utils.js'
|
|
3
|
+
import { defineHandler } from '../server/utils.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Auth middleware
|
|
@@ -16,20 +16,14 @@
|
|
|
16
16
|
{=! Some of the statements in the comments might become incorrect. =}
|
|
17
17
|
{=! "our code" means: "web-app", "server" or "SDK", or "some combination of the three". =}
|
|
18
18
|
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
19
|
-
"./core/storage": "./dist/core/storage.js",
|
|
20
|
-
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
21
19
|
"./core/serialization": "./dist/core/serialization/index.js",
|
|
22
20
|
"./core/auth": "./dist/core/auth.js",
|
|
23
21
|
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
24
|
-
"./auth/helpers/user": "./dist/auth/helpers/user.js",
|
|
25
|
-
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
26
22
|
"./auth/session": "./dist/auth/session.js",
|
|
27
23
|
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
28
24
|
"./auth/user": "./dist/auth/user.js",
|
|
29
25
|
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
30
26
|
"./auth/providers/types": "./dist/auth/providers/types.js",
|
|
31
|
-
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
32
|
-
"./auth/types": "./dist/auth/types.js",
|
|
33
27
|
{=! Used by users, documented. =}
|
|
34
28
|
"./auth/utils": "./dist/auth/utils.js",
|
|
35
29
|
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
@@ -38,27 +32,7 @@
|
|
|
38
32
|
"./auth/jwt": "./dist/auth/jwt.js",
|
|
39
33
|
{=! Used by user, documented. =}
|
|
40
34
|
"./auth/validation": "./dist/auth/validation.js",
|
|
41
|
-
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
42
|
-
"./auth/pages/createAuthRequiredPage": "./dist/auth/pages/createAuthRequiredPage.jsx",
|
|
43
|
-
{=! Used by our framework code (Websockets), undocumented (but accessible) for users. =}
|
|
44
|
-
"./api/events": "./dist/api/events.js",
|
|
45
|
-
{=! Used by users, documented. =}
|
|
46
|
-
"./operations": "./dist/operations/index.js",
|
|
47
|
-
{=! If we import a symbol like "import something form 'wasp/something'", we must =}
|
|
48
|
-
{=! expose it here (which leaks it to our users). We could avoid this by =}
|
|
49
|
-
{=! using relative imports inside SDK code (instead of library imports), =}
|
|
50
|
-
{=! but I didn't have time to implement it. =}
|
|
51
35
|
"./src/*": "./dist/src/*.js",
|
|
52
|
-
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
53
|
-
"./operations/*": "./dist/operations/*",
|
|
54
|
-
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
55
|
-
"./universal/url": "./dist/universal/url.js",
|
|
56
|
-
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
57
|
-
"./universal/types": "./dist/universal/types.js",
|
|
58
|
-
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
59
|
-
"./universal/validators": "./dist/universal/validators.js",
|
|
60
|
-
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
61
|
-
"./universal/ansiColors": "./dist/universal/ansiColors.js",
|
|
62
36
|
{=! Parts are used by users, documented. Parts are probably used by our code, undocumented (but accessible). =}
|
|
63
37
|
"./server/utils": "./dist/server/utils.js",
|
|
64
38
|
{=! Used by our code, undocumented (but accessible) for users. =}
|
|
@@ -75,14 +49,11 @@
|
|
|
75
49
|
{=! Todo(filip): This export becomes problematic once we start supporting different executors =}
|
|
76
50
|
"./server/jobs/core/pgBoss": "./dist/server/jobs/core/pgBoss/index.js",
|
|
77
51
|
|
|
78
|
-
{=! Used by the framework client code, reconsider during refactoring. =}
|
|
79
|
-
"./client/webSocket/WebSocketProvider": "./dist/client/webSocket/WebSocketProvider.jsx",
|
|
80
52
|
{=! Still needed, reconsider during refactoring. =}
|
|
81
53
|
"./server/types": "./dist/server/types/index.js",
|
|
82
54
|
{=! Used by the framework server code, reconsider during refactoring. =}
|
|
83
55
|
"./server/middleware": "./dist/server/middleware/index.js",
|
|
84
56
|
|
|
85
|
-
{=! ================= NEW API HERE =================== =}
|
|
86
57
|
{=! Public: { config, prisma, type ServerSetupFn, HttpError, type DbSeedFn, type MiddlewareConfigFn } =}
|
|
87
58
|
{=! Private: [] =}
|
|
88
59
|
"./server": "./dist/server/index.js",
|
|
@@ -112,26 +83,15 @@
|
|
|
112
83
|
"./client/router": "./dist/client/router/index.js",
|
|
113
84
|
"./client/test": "./dist/client/test/index.js",
|
|
114
85
|
"./client/test/setup": "./dist/client/test/setup.js",
|
|
115
|
-
"./client/hooks": "./dist/client/hooks.js",
|
|
116
86
|
"./client": "./dist/client/index.js",
|
|
117
87
|
"./env": "./dist/env/index.js",
|
|
118
|
-
|
|
119
|
-
"./env/validation": "./dist/env/validation.js",
|
|
120
|
-
{=! Private: [client, sdk] =}
|
|
121
|
-
"./client/env/schema": "./dist/client/env/schema.js",
|
|
88
|
+
"./serialization": "./dist/serialization/index.js",
|
|
122
89
|
{=! Private: [client] =}
|
|
123
90
|
"./client/app": "./dist/client/app/index.jsx",
|
|
124
91
|
"./client/app/layout": "./dist/client/app/layout.jsx",
|
|
125
92
|
"./client/app/router": "./dist/client/app/router.jsx",
|
|
126
93
|
{=! Private: [client] =}
|
|
127
|
-
"./client/vite": "./dist/client/vite/index.js"
|
|
128
|
-
|
|
129
|
-
{=! todo(filip): Fixes below are for type errors in 0.13.1, remove ASAP =}
|
|
130
|
-
{=! Used by our code (SDK for full-stack type safety), undocumented (but accessible) for users. =}
|
|
131
|
-
"./client/operations/rpc": "./dist/client/operations/rpc.js",
|
|
132
|
-
"./server/operations/actions": "./dist/server/operations/actions/index.js",
|
|
133
|
-
"./server/operations/queries": "./dist/server/operations/queries/index.js",
|
|
134
|
-
"./server/_types": "./dist/server/_types/index.js"
|
|
94
|
+
"./client/vite": "./dist/client/vite/index.js"
|
|
135
95
|
|
|
136
96
|
},
|
|
137
97
|
{=!
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import { type Expand } from '
|
|
2
|
+
import { type Expand } from '../../universal/types.js'
|
|
3
3
|
import { type Request, type Response } from 'express'
|
|
4
4
|
import {
|
|
5
5
|
type ParamsDictionary as ExpressParams,
|
|
6
6
|
type Query as ExpressQuery,
|
|
7
7
|
} from 'express-serve-static-core'
|
|
8
|
-
import { prisma } from '
|
|
8
|
+
import { prisma } from '../index.js'
|
|
9
9
|
{=# isAuthEnabled =}
|
|
10
|
-
import { type AuthUser } from '
|
|
10
|
+
import { type AuthUser } from '../auth/user.js'
|
|
11
11
|
{=/ isAuthEnabled =}
|
|
12
12
|
import { type _Entity } from './taggedEntities'
|
|
13
|
-
import { type Payload } from '
|
|
13
|
+
import { type Payload } from '../../core/serialization/index.js'
|
|
14
14
|
|
|
15
15
|
export * from "./taggedEntities"
|
|
16
|
-
export * from "
|
|
16
|
+
export * from "../../core/serialization/index.js"
|
|
17
17
|
|
|
18
18
|
export type UnauthenticatedQueryDefinition<
|
|
19
19
|
Entities extends _Entity[],
|
|
@@ -101,5 +101,5 @@ type ContextWithUser<Entities extends _Entity[]> = Expand<
|
|
|
101
101
|
Context<Entities> & { user?: AuthUser }
|
|
102
102
|
>
|
|
103
103
|
|
|
104
|
-
export type { ProviderName } from '
|
|
104
|
+
export type { ProviderName } from '../../auth/utils.js'
|
|
105
105
|
{=/ isAuthEnabled =}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import { createJWT, TimeSpan } from '
|
|
3
|
-
import { emailSender } from '
|
|
4
|
-
import { Email } from '
|
|
2
|
+
import { createJWT, TimeSpan } from '../../../auth/jwt.js'
|
|
3
|
+
import { emailSender } from '../../email/index.js';
|
|
4
|
+
import { Email } from '../../email/core/types.js';
|
|
5
5
|
import {
|
|
6
6
|
createProviderId,
|
|
7
7
|
updateAuthIdentityProviderData,
|
|
8
8
|
findAuthIdentity,
|
|
9
9
|
getProviderDataWithPassword,
|
|
10
10
|
type EmailProviderData,
|
|
11
|
-
} from '
|
|
12
|
-
import { config as waspServerConfig } from '
|
|
13
|
-
import { type {= userEntityUpper =}, type {= authEntityUpper =} } from '
|
|
11
|
+
} from '../../../auth/utils.js';
|
|
12
|
+
import { config as waspServerConfig } from '../../index.js';
|
|
13
|
+
import { type {= userEntityUpper =}, type {= authEntityUpper =} } from '../../../entities/index.js'
|
|
14
14
|
|
|
15
15
|
// PUBLIC API
|
|
16
16
|
export async function createEmailVerificationLink(
|
|
@@ -11,10 +11,10 @@ import type {
|
|
|
11
11
|
_{= crud.entityUpper =},
|
|
12
12
|
} from "../_types";
|
|
13
13
|
import type { Prisma } from "@prisma/client";
|
|
14
|
-
import type { Payload, SuperJSONObject } from "
|
|
14
|
+
import type { Payload, SuperJSONObject } from "../../core/serialization/index.js";
|
|
15
15
|
import type {
|
|
16
16
|
{= crud.entityUpper =},
|
|
17
|
-
} from "
|
|
17
|
+
} from "../../entities/index.js";
|
|
18
18
|
{=# overrides.GetAll.isDefined =}
|
|
19
19
|
{=& overrides.GetAll.importStatement =}
|
|
20
20
|
{=/ overrides.GetAll.isDefined =}
|
|
@@ -11,6 +11,10 @@ export { initSendGridEmailSender as initEmailSender } from "./providers/sendgrid
|
|
|
11
11
|
// PRIVATE API
|
|
12
12
|
export { initMailgunEmailSender as initEmailSender } from "./providers/mailgun.js";
|
|
13
13
|
{=/ isMailgunProviderEnabled =}
|
|
14
|
+
{=# isResendProviderEnabled =}
|
|
15
|
+
// PRIVATE API
|
|
16
|
+
export { initResendEmailSender as initEmailSender } from "./providers/resend.js";
|
|
17
|
+
{=/ isResendProviderEnabled =}
|
|
14
18
|
{=# isDummyProviderEnabled =}
|
|
15
19
|
// PRIVATE API
|
|
16
20
|
export { initDummyEmailSender as initEmailSender } from "./providers/dummy.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getDefaultFromField } from "../helpers.js";
|
|
2
2
|
import { DummyEmailProvider, EmailSender } from "../types";
|
|
3
3
|
|
|
4
|
-
import { colorize } from "
|
|
4
|
+
import { colorize } from "../../../../universal/ansiColors.js";
|
|
5
5
|
|
|
6
6
|
// PRIVATE API
|
|
7
7
|
export function initDummyEmailSender(
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Resend } from 'resend';
|
|
2
|
+
import { formatFromField, getDefaultFromField } from "../helpers.js";
|
|
3
|
+
import type { ResendEmailProvider, EmailSender } from "../types";
|
|
4
|
+
|
|
5
|
+
// PRIVATE API
|
|
6
|
+
export function initResendEmailSender(
|
|
7
|
+
config: ResendEmailProvider
|
|
8
|
+
): EmailSender {
|
|
9
|
+
const defaultFromField = getDefaultFromField();
|
|
10
|
+
|
|
11
|
+
const client = new Resend(config.apiKey);
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
async send(email) {
|
|
15
|
+
// Resend's SDK resolves with `{ data, error }` instead of throwing on
|
|
16
|
+
// API errors, so we surface the error ourselves to match the other
|
|
17
|
+
// providers (and so callers' error handling actually fires).
|
|
18
|
+
const { data, error } = await client.emails.send({
|
|
19
|
+
from: formatFromField(email.from || defaultFromField),
|
|
20
|
+
to: email.to,
|
|
21
|
+
subject: email.subject,
|
|
22
|
+
text: email.text,
|
|
23
|
+
html: email.html,
|
|
24
|
+
});
|
|
25
|
+
if (error) {
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
return data;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|