@wasp.sh/wasp-cli-darwin-arm64-unknown 0.24.0 → 0.25.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/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
|
@@ -1,732 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { GET_TS_APP_SPEC } from "../../src/legacy/_private.js";
|
|
3
|
-
import { makeRefParser, mapApi, mapApiNamespace, mapApp, mapAuth, mapAuthMethods, mapClient, mapCrud, mapCrudOperationOptions, mapCrudOperations, mapDb, mapEmailAuth, mapEmailFromField, mapEmailSender, mapEmailVerification, mapExternalAuth, mapExtImport, mapHttpRoute, mapJob, mapOperation, mapPage, mapPasswordReset, mapPerform, mapRoute, mapSchedule, mapServer, mapUsernameAndPassword, mapWebSocket, } from "../../src/legacy/mapTsAppSpecToAppSpecDecls.js";
|
|
4
|
-
import * as Fixtures from "./testFixtures.js";
|
|
5
|
-
describe("mapApp", () => {
|
|
6
|
-
test("should map minimal config correctly", () => {
|
|
7
|
-
testMapApp(Fixtures.createApp("minimal").app);
|
|
8
|
-
});
|
|
9
|
-
test("should map full config correctly", () => {
|
|
10
|
-
testMapApp(Fixtures.createApp("full").app);
|
|
11
|
-
});
|
|
12
|
-
function testMapApp(app) {
|
|
13
|
-
const tsAppSpec = app[GET_TS_APP_SPEC]();
|
|
14
|
-
const entities = [];
|
|
15
|
-
if (tsAppSpec.auth) {
|
|
16
|
-
if (tsAppSpec.auth.userEntity) {
|
|
17
|
-
entities.push(tsAppSpec.auth.userEntity);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const routes = [];
|
|
21
|
-
if (tsAppSpec.auth) {
|
|
22
|
-
if (tsAppSpec.auth.methods.email?.emailVerification.clientRoute) {
|
|
23
|
-
routes.push(tsAppSpec.auth.methods.email.emailVerification.clientRoute);
|
|
24
|
-
}
|
|
25
|
-
if (tsAppSpec.auth.methods.email?.passwordReset.clientRoute) {
|
|
26
|
-
routes.push(tsAppSpec.auth.methods.email.passwordReset.clientRoute);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const entityRefParser = makeRefParser("Entity", entities);
|
|
30
|
-
const routeRefParser = makeRefParser("Route", routes);
|
|
31
|
-
const result = mapApp(tsAppSpec.app.config, entityRefParser, routeRefParser, tsAppSpec.auth, tsAppSpec.client, tsAppSpec.server, tsAppSpec.db, tsAppSpec.emailSender, tsAppSpec.websocket);
|
|
32
|
-
expect(result).toStrictEqual({
|
|
33
|
-
wasp: {
|
|
34
|
-
version: tsAppSpec.app.config.wasp.version,
|
|
35
|
-
},
|
|
36
|
-
title: tsAppSpec.app.config.title,
|
|
37
|
-
head: tsAppSpec.app.config.head,
|
|
38
|
-
auth: tsAppSpec.auth &&
|
|
39
|
-
mapAuth(tsAppSpec.auth, entityRefParser, routeRefParser),
|
|
40
|
-
server: tsAppSpec.server && mapServer(tsAppSpec.server),
|
|
41
|
-
client: tsAppSpec.client && mapClient(tsAppSpec.client),
|
|
42
|
-
db: tsAppSpec.db && mapDb(tsAppSpec.db),
|
|
43
|
-
emailSender: tsAppSpec.emailSender && mapEmailSender(tsAppSpec.emailSender),
|
|
44
|
-
webSocket: tsAppSpec.websocket && mapWebSocket(tsAppSpec.websocket),
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
describe("mapAuth", () => {
|
|
49
|
-
test("should map minimal config correctly", () => {
|
|
50
|
-
testMapAuth(Fixtures.getAuthConfig("minimal"));
|
|
51
|
-
});
|
|
52
|
-
test("should map full config correctly", () => {
|
|
53
|
-
testMapAuth(Fixtures.getAuthConfig("full"));
|
|
54
|
-
});
|
|
55
|
-
test("should throw if userEntity is not provided to entity parser", () => {
|
|
56
|
-
testMapAuth(Fixtures.getAuthConfig("minimal"), {
|
|
57
|
-
overrideEntities: [],
|
|
58
|
-
shouldError: true,
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
test("should throw if emailVerification clientRoute ref is not provided when defined", () => {
|
|
62
|
-
const auth = Fixtures.getAuthConfig("full");
|
|
63
|
-
expect(auth.methods.email.emailVerification.clientRoute).toBeDefined();
|
|
64
|
-
testMapAuth(auth, {
|
|
65
|
-
overrideRoutes: [auth.methods.email.passwordReset.clientRoute],
|
|
66
|
-
shouldError: true,
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
test("should throw if passwordReset clientRoute ref is not provided when defined", () => {
|
|
70
|
-
const auth = Fixtures.getAuthConfig("full");
|
|
71
|
-
expect(auth.methods.email.passwordReset.clientRoute).toBeDefined();
|
|
72
|
-
testMapAuth(auth, {
|
|
73
|
-
overrideRoutes: [auth.methods.email.emailVerification.clientRoute],
|
|
74
|
-
shouldError: true,
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
function testMapAuth(auth, options = {
|
|
78
|
-
shouldError: false,
|
|
79
|
-
}) {
|
|
80
|
-
const { overrideEntities, overrideRoutes, shouldError } = options;
|
|
81
|
-
const entities = overrideEntities ?? [auth.userEntity];
|
|
82
|
-
const routes = overrideRoutes ??
|
|
83
|
-
[
|
|
84
|
-
auth.methods.email?.emailVerification.clientRoute,
|
|
85
|
-
auth.methods.email?.passwordReset.clientRoute,
|
|
86
|
-
].filter((e) => e !== undefined);
|
|
87
|
-
const entityRefParser = makeRefParser("Entity", entities);
|
|
88
|
-
const routeRefParser = makeRefParser("Route", routes);
|
|
89
|
-
if (shouldError) {
|
|
90
|
-
expect(() => mapAuth(auth, entityRefParser, routeRefParser)).toThrowError();
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const result = mapAuth(auth, entityRefParser, routeRefParser);
|
|
94
|
-
expect(result).toStrictEqual({
|
|
95
|
-
userEntity: entityRefParser(auth.userEntity),
|
|
96
|
-
methods: mapAuthMethods(auth.methods, routeRefParser),
|
|
97
|
-
onAuthFailedRedirectTo: auth.onAuthFailedRedirectTo,
|
|
98
|
-
onAuthSucceededRedirectTo: auth.onAuthSucceededRedirectTo,
|
|
99
|
-
onBeforeSignup: auth.onBeforeSignup && mapExtImport(auth.onBeforeSignup),
|
|
100
|
-
onAfterSignup: auth.onAfterSignup && mapExtImport(auth.onAfterSignup),
|
|
101
|
-
onAfterEmailVerified: auth.onAfterEmailVerified && mapExtImport(auth.onAfterEmailVerified),
|
|
102
|
-
onBeforeOAuthRedirect: auth.onBeforeOAuthRedirect && mapExtImport(auth.onBeforeOAuthRedirect),
|
|
103
|
-
onBeforeLogin: auth.onBeforeLogin && mapExtImport(auth.onBeforeLogin),
|
|
104
|
-
onAfterLogin: auth.onAfterLogin && mapExtImport(auth.onAfterLogin),
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
describe("mapAuthMethods", () => {
|
|
109
|
-
test("should map minimal config correctly", () => {
|
|
110
|
-
testMapAuthMethods(Fixtures.getAuthMethods("minimal"));
|
|
111
|
-
});
|
|
112
|
-
test("should map full config correctly", () => {
|
|
113
|
-
testMapAuthMethods(Fixtures.getAuthMethods("full"));
|
|
114
|
-
});
|
|
115
|
-
test("should throw if emailVerification clientRoute ref is not provided when defined", () => {
|
|
116
|
-
const authMethods = Fixtures.getAuthMethods("full");
|
|
117
|
-
expect(authMethods.email.emailVerification.clientRoute).toBeDefined();
|
|
118
|
-
testMapAuthMethods(authMethods, {
|
|
119
|
-
overrideRoutes: [authMethods.email.emailVerification.clientRoute],
|
|
120
|
-
shouldError: true,
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
test("should throw if passwordReset clientRoute ref is not provided when defined", () => {
|
|
124
|
-
const authMethods = Fixtures.getAuthMethods("full");
|
|
125
|
-
expect(authMethods.email.passwordReset.clientRoute).toBeDefined();
|
|
126
|
-
testMapAuthMethods(authMethods, {
|
|
127
|
-
overrideRoutes: [authMethods.email.passwordReset.clientRoute],
|
|
128
|
-
shouldError: true,
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
function testMapAuthMethods(authMethods, options = {
|
|
132
|
-
shouldError: false,
|
|
133
|
-
}) {
|
|
134
|
-
const { overrideRoutes, shouldError } = options;
|
|
135
|
-
const routes = overrideRoutes ??
|
|
136
|
-
[
|
|
137
|
-
authMethods.email?.emailVerification.clientRoute,
|
|
138
|
-
authMethods.email?.passwordReset.clientRoute,
|
|
139
|
-
].filter((e) => e !== undefined);
|
|
140
|
-
const routeRefParser = makeRefParser("Route", routes);
|
|
141
|
-
if (shouldError) {
|
|
142
|
-
expect(() => mapAuthMethods(authMethods, routeRefParser)).toThrowError();
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const result = mapAuthMethods(authMethods, routeRefParser);
|
|
146
|
-
expect(result).toStrictEqual({
|
|
147
|
-
usernameAndPassword: authMethods.usernameAndPassword &&
|
|
148
|
-
mapUsernameAndPassword(authMethods.usernameAndPassword),
|
|
149
|
-
slack: authMethods.slack && mapExternalAuth(authMethods.slack),
|
|
150
|
-
discord: authMethods.discord && mapExternalAuth(authMethods.discord),
|
|
151
|
-
google: authMethods.google && mapExternalAuth(authMethods.google),
|
|
152
|
-
gitHub: authMethods.gitHub && mapExternalAuth(authMethods.gitHub),
|
|
153
|
-
keycloak: authMethods.keycloak && mapExternalAuth(authMethods.keycloak),
|
|
154
|
-
microsoft: authMethods.microsoft && mapExternalAuth(authMethods.microsoft),
|
|
155
|
-
email: authMethods.email && mapEmailAuth(authMethods.email, routeRefParser),
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
describe("mapEmailAuth", () => {
|
|
160
|
-
test("should map minimal config correctly", () => {
|
|
161
|
-
testMapEmailAuth(Fixtures.getEmailAuthConfig("minimal"));
|
|
162
|
-
});
|
|
163
|
-
test("should map full config correctly", () => {
|
|
164
|
-
testMapEmailAuth(Fixtures.getEmailAuthConfig("full"));
|
|
165
|
-
});
|
|
166
|
-
test("should throw if emailVerification clientRoute ref is not provided when defined", () => {
|
|
167
|
-
const emailAuth = Fixtures.getEmailAuthConfig("full");
|
|
168
|
-
expect(emailAuth.emailVerification.clientRoute).toBeDefined();
|
|
169
|
-
testMapEmailAuth(emailAuth, {
|
|
170
|
-
overrideRoutes: [emailAuth.passwordReset.clientRoute],
|
|
171
|
-
shouldError: true,
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
test("should throw if passwordReset clientRoute ref is not provided when defined", () => {
|
|
175
|
-
const emailAuth = Fixtures.getEmailAuthConfig("full");
|
|
176
|
-
expect(emailAuth.passwordReset.clientRoute).toBeDefined();
|
|
177
|
-
testMapEmailAuth(emailAuth, {
|
|
178
|
-
overrideRoutes: [emailAuth.emailVerification.clientRoute],
|
|
179
|
-
shouldError: true,
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
function testMapEmailAuth(emailAuth, options = {
|
|
183
|
-
shouldError: false,
|
|
184
|
-
}) {
|
|
185
|
-
const { overrideRoutes, shouldError } = options;
|
|
186
|
-
const routes = overrideRoutes ??
|
|
187
|
-
[
|
|
188
|
-
emailAuth?.emailVerification.clientRoute,
|
|
189
|
-
emailAuth?.passwordReset.clientRoute,
|
|
190
|
-
].filter((e) => e !== undefined);
|
|
191
|
-
const routeRefParser = makeRefParser("Route", routes);
|
|
192
|
-
if (shouldError) {
|
|
193
|
-
expect(() => mapEmailAuth(emailAuth, routeRefParser)).toThrowError();
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
const result = mapEmailAuth(emailAuth, routeRefParser);
|
|
197
|
-
expect(result).toStrictEqual({
|
|
198
|
-
userSignupFields: emailAuth.userSignupFields && mapExtImport(emailAuth.userSignupFields),
|
|
199
|
-
fromField: mapEmailFromField(emailAuth.fromField),
|
|
200
|
-
emailVerification: mapEmailVerification(emailAuth.emailVerification, routeRefParser),
|
|
201
|
-
passwordReset: mapPasswordReset(emailAuth.passwordReset, routeRefParser),
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
describe("mapEmailVerification", () => {
|
|
206
|
-
test("should map minimal config correctly", () => {
|
|
207
|
-
testMapEmailVerification(Fixtures.getEmailVerificationConfig("minimal"));
|
|
208
|
-
});
|
|
209
|
-
test("should map full config correctly", () => {
|
|
210
|
-
testMapEmailVerification(Fixtures.getEmailVerificationConfig("full"));
|
|
211
|
-
});
|
|
212
|
-
test("should throw if clientRoute ref is not provided when defined", () => {
|
|
213
|
-
const emailVerification = Fixtures.getEmailVerificationConfig("full");
|
|
214
|
-
expect(emailVerification.clientRoute).toBeDefined();
|
|
215
|
-
testMapEmailVerification(emailVerification, {
|
|
216
|
-
overrideRoutes: [],
|
|
217
|
-
shouldError: true,
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
function testMapEmailVerification(emailVerification, options = {
|
|
221
|
-
shouldError: false,
|
|
222
|
-
}) {
|
|
223
|
-
const { overrideRoutes, shouldError } = options;
|
|
224
|
-
const routes = overrideRoutes ??
|
|
225
|
-
[emailVerification.clientRoute].filter((e) => e !== undefined);
|
|
226
|
-
const routeRefParser = makeRefParser("Route", routes);
|
|
227
|
-
if (shouldError) {
|
|
228
|
-
expect(() => mapEmailVerification(emailVerification, routeRefParser)).toThrowError();
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
const result = mapEmailVerification(emailVerification, routeRefParser);
|
|
232
|
-
expect(result).toStrictEqual({
|
|
233
|
-
clientRoute: routeRefParser(emailVerification.clientRoute),
|
|
234
|
-
getEmailContentFn: emailVerification.getEmailContentFn &&
|
|
235
|
-
mapExtImport(emailVerification.getEmailContentFn),
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
describe("mapPasswordReset", () => {
|
|
240
|
-
test("should map minimal config correctly", () => {
|
|
241
|
-
testMapPasswordReset(Fixtures.getPasswordResetConfig("minimal"));
|
|
242
|
-
});
|
|
243
|
-
test("should map full config correctly", () => {
|
|
244
|
-
testMapPasswordReset(Fixtures.getPasswordResetConfig("full"));
|
|
245
|
-
});
|
|
246
|
-
test("should throw if clientRoute ref is not provided when defined", () => {
|
|
247
|
-
const passwordReset = Fixtures.getPasswordResetConfig("full");
|
|
248
|
-
expect(passwordReset.clientRoute).toBeDefined();
|
|
249
|
-
testMapPasswordReset(passwordReset, {
|
|
250
|
-
overrideRoutes: [],
|
|
251
|
-
shouldError: true,
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
function testMapPasswordReset(passwordReset, options = {
|
|
255
|
-
shouldError: false,
|
|
256
|
-
}) {
|
|
257
|
-
const { overrideRoutes, shouldError } = options;
|
|
258
|
-
const routes = overrideRoutes ??
|
|
259
|
-
[passwordReset.clientRoute].filter((e) => e !== undefined);
|
|
260
|
-
const routeRefParser = makeRefParser("Route", routes);
|
|
261
|
-
if (shouldError) {
|
|
262
|
-
expect(() => mapPasswordReset(passwordReset, routeRefParser)).toThrowError();
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
const result = mapPasswordReset(passwordReset, routeRefParser);
|
|
266
|
-
expect(result).toStrictEqual({
|
|
267
|
-
clientRoute: routeRefParser(passwordReset.clientRoute),
|
|
268
|
-
getEmailContentFn: passwordReset.getEmailContentFn &&
|
|
269
|
-
mapExtImport(passwordReset.getEmailContentFn),
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
describe("mapUsernameAndPassword", () => {
|
|
274
|
-
test("should map minimal config correctly", () => {
|
|
275
|
-
testMapUsernameAndPassword(Fixtures.getUsernameAndPasswordConfig("minimal"));
|
|
276
|
-
});
|
|
277
|
-
test("should map full config correctly", () => {
|
|
278
|
-
testMapUsernameAndPassword(Fixtures.getUsernameAndPasswordConfig("full"));
|
|
279
|
-
});
|
|
280
|
-
function testMapUsernameAndPassword(usernameAndPassword) {
|
|
281
|
-
const result = mapUsernameAndPassword(usernameAndPassword);
|
|
282
|
-
expect(result).toStrictEqual({
|
|
283
|
-
userSignupFields: usernameAndPassword.userSignupFields &&
|
|
284
|
-
mapExtImport(usernameAndPassword.userSignupFields),
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
describe("mapExternalAuth", () => {
|
|
289
|
-
test("should map minimal config correctly", () => {
|
|
290
|
-
testMapExternalAuth(Fixtures.getExternalAuthConfig("minimal"));
|
|
291
|
-
});
|
|
292
|
-
test("should map full config correctly", () => {
|
|
293
|
-
testMapExternalAuth(Fixtures.getExternalAuthConfig("full"));
|
|
294
|
-
});
|
|
295
|
-
function testMapExternalAuth(externalAuth) {
|
|
296
|
-
const result = mapExternalAuth(externalAuth);
|
|
297
|
-
expect(result).toStrictEqual({
|
|
298
|
-
configFn: externalAuth.configFn && mapExtImport(externalAuth.configFn),
|
|
299
|
-
userSignupFields: externalAuth.userSignupFields &&
|
|
300
|
-
mapExtImport(externalAuth.userSignupFields),
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
describe("mapClient", () => {
|
|
305
|
-
test("should map minimal config correctly", () => {
|
|
306
|
-
testMapClient(Fixtures.getClientConfig("minimal"));
|
|
307
|
-
});
|
|
308
|
-
test("should map full config correctly", () => {
|
|
309
|
-
testMapClient(Fixtures.getClientConfig("full"));
|
|
310
|
-
});
|
|
311
|
-
function testMapClient(client) {
|
|
312
|
-
const result = mapClient(client);
|
|
313
|
-
expect(result).toStrictEqual({
|
|
314
|
-
rootComponent: client.rootComponent && mapExtImport(client.rootComponent),
|
|
315
|
-
setupFn: client.setupFn && mapExtImport(client.setupFn),
|
|
316
|
-
baseDir: client.baseDir,
|
|
317
|
-
envValidationSchema: client.envValidationSchema && mapExtImport(client.envValidationSchema),
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
describe("mapServer", () => {
|
|
322
|
-
test("should map minimal config correctly", () => {
|
|
323
|
-
testMapServer(Fixtures.getServerConfig("minimal"));
|
|
324
|
-
});
|
|
325
|
-
test("should map full config correctly", () => {
|
|
326
|
-
testMapServer(Fixtures.getServerConfig("full"));
|
|
327
|
-
});
|
|
328
|
-
function testMapServer(server) {
|
|
329
|
-
const result = mapServer(server);
|
|
330
|
-
expect(result).toStrictEqual({
|
|
331
|
-
setupFn: server.setupFn && mapExtImport(server.setupFn),
|
|
332
|
-
middlewareConfigFn: server.middlewareConfigFn && mapExtImport(server.middlewareConfigFn),
|
|
333
|
-
envValidationSchema: server.envValidationSchema && mapExtImport(server.envValidationSchema),
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
describe("mapEmailSender", () => {
|
|
338
|
-
test("should map minimal config correctly", () => {
|
|
339
|
-
testMapEmailSender(Fixtures.getEmailSenderConfig("minimal"));
|
|
340
|
-
});
|
|
341
|
-
test("should map full config correctly", () => {
|
|
342
|
-
testMapEmailSender(Fixtures.getEmailSenderConfig("full"));
|
|
343
|
-
});
|
|
344
|
-
function testMapEmailSender(emailSender) {
|
|
345
|
-
const result = mapEmailSender(emailSender);
|
|
346
|
-
expect(result).toStrictEqual({
|
|
347
|
-
provider: emailSender.provider,
|
|
348
|
-
defaultFrom: emailSender.defaultFrom && mapEmailFromField(emailSender.defaultFrom),
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
describe("mapWebSocket", () => {
|
|
353
|
-
test("should map minimal config correctly", () => {
|
|
354
|
-
testMapWebSocket(Fixtures.getWebSocketConfig("minimal"));
|
|
355
|
-
});
|
|
356
|
-
test("should map full config correctly", () => {
|
|
357
|
-
testMapWebSocket(Fixtures.getWebSocketConfig("full"));
|
|
358
|
-
});
|
|
359
|
-
function testMapWebSocket(websocket) {
|
|
360
|
-
const result = mapWebSocket(websocket);
|
|
361
|
-
expect(result).toStrictEqual({
|
|
362
|
-
fn: mapExtImport(websocket.fn),
|
|
363
|
-
autoConnect: websocket.autoConnect,
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
describe("mapDb", () => {
|
|
368
|
-
test("should map minimal config correctly", () => {
|
|
369
|
-
testDb(Fixtures.getDbConfig("minimal"));
|
|
370
|
-
});
|
|
371
|
-
test("should map full config correctly", () => {
|
|
372
|
-
testDb(Fixtures.getDbConfig("full"));
|
|
373
|
-
});
|
|
374
|
-
function testDb(db) {
|
|
375
|
-
const result = mapDb(db);
|
|
376
|
-
expect(result).toStrictEqual({
|
|
377
|
-
seeds: db.seeds?.map((seed) => mapExtImport(seed)),
|
|
378
|
-
prismaSetupFn: db.prismaSetupFn && mapExtImport(db.prismaSetupFn),
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
describe("mapPage", () => {
|
|
383
|
-
test("should map minimal config correctly", () => {
|
|
384
|
-
testMapPage(Fixtures.getPageConfig("minimal").config);
|
|
385
|
-
});
|
|
386
|
-
test("should map full config correctly", () => {
|
|
387
|
-
testMapPage(Fixtures.getPageConfig("full").config);
|
|
388
|
-
});
|
|
389
|
-
function testMapPage(page) {
|
|
390
|
-
const result = mapPage(page);
|
|
391
|
-
expect(result).toStrictEqual({
|
|
392
|
-
component: mapExtImport(page.component),
|
|
393
|
-
authRequired: page.authRequired,
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
describe("mapRoute", () => {
|
|
398
|
-
// NOTE: currently minimal config is the same as full config
|
|
399
|
-
test("should map minimal config correctly", () => {
|
|
400
|
-
testMapRoute(Fixtures.getRouteConfig("minimal").config);
|
|
401
|
-
});
|
|
402
|
-
test("should map full config correctly", () => {
|
|
403
|
-
testMapRoute(Fixtures.getRouteConfig("full").config);
|
|
404
|
-
});
|
|
405
|
-
function testMapRoute(route) {
|
|
406
|
-
const pageRefParser = makeRefParser("Page", [route.to]);
|
|
407
|
-
const result = mapRoute(route, pageRefParser);
|
|
408
|
-
expect(result).toStrictEqual({
|
|
409
|
-
path: route.path,
|
|
410
|
-
to: pageRefParser(route.to),
|
|
411
|
-
prerender: route.prerender,
|
|
412
|
-
lazy: route.lazy,
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
describe("mapOperation", () => {
|
|
417
|
-
test("should map minimal query config correctly", () => {
|
|
418
|
-
testMapOperation(Fixtures.getQueryConfig("minimal").config);
|
|
419
|
-
});
|
|
420
|
-
test("should map full query config correctly", () => {
|
|
421
|
-
testMapOperation(Fixtures.getQueryConfig("full").config);
|
|
422
|
-
});
|
|
423
|
-
test("should throw if entity ref is not provided in query config", () => {
|
|
424
|
-
testMapOperation(Fixtures.getQueryConfig("full").config, {
|
|
425
|
-
overrideEntities: [],
|
|
426
|
-
shouldError: true,
|
|
427
|
-
});
|
|
428
|
-
});
|
|
429
|
-
test("should map minimal action config correctly", () => {
|
|
430
|
-
testMapOperation(Fixtures.getActionConfig("minimal").config);
|
|
431
|
-
});
|
|
432
|
-
test("should map action config correctly", () => {
|
|
433
|
-
testMapOperation(Fixtures.getActionConfig("full").config);
|
|
434
|
-
});
|
|
435
|
-
test("should throw if entity ref is not provided in action config", () => {
|
|
436
|
-
testMapOperation(Fixtures.getActionConfig("full").config, {
|
|
437
|
-
overrideEntities: [],
|
|
438
|
-
shouldError: true,
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
function testMapOperation(operation, options = {
|
|
442
|
-
shouldError: false,
|
|
443
|
-
}) {
|
|
444
|
-
const { overrideEntities, shouldError } = options;
|
|
445
|
-
const entities = overrideEntities ??
|
|
446
|
-
operation.entities?.filter((e) => e !== undefined) ??
|
|
447
|
-
[];
|
|
448
|
-
const entityRefParser = makeRefParser("Entity", entities);
|
|
449
|
-
if (shouldError) {
|
|
450
|
-
expect(() => mapOperation(operation, entityRefParser)).toThrowError();
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
const result = mapOperation(operation, entityRefParser);
|
|
454
|
-
expect(result).toStrictEqual({
|
|
455
|
-
fn: mapExtImport(operation.fn),
|
|
456
|
-
entities: operation.entities?.map(entityRefParser),
|
|
457
|
-
auth: operation.auth,
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
describe("mapCrud", () => {
|
|
462
|
-
test("should map minimal config correctly", () => {
|
|
463
|
-
testMapCrud(Fixtures.getCrudConfig("minimal").config);
|
|
464
|
-
});
|
|
465
|
-
test("should map full config correctly", () => {
|
|
466
|
-
testMapCrud(Fixtures.getCrudConfig("full").config);
|
|
467
|
-
});
|
|
468
|
-
test("should throw if entity ref is not provided", () => {
|
|
469
|
-
testMapCrud(Fixtures.getCrudConfig("full").config, {
|
|
470
|
-
overrideEntities: [],
|
|
471
|
-
shouldError: true,
|
|
472
|
-
});
|
|
473
|
-
});
|
|
474
|
-
function testMapCrud(crud, options = {
|
|
475
|
-
shouldError: false,
|
|
476
|
-
}) {
|
|
477
|
-
const { overrideEntities, shouldError } = options;
|
|
478
|
-
const entities = overrideEntities ?? [crud.entity].filter((e) => e !== undefined);
|
|
479
|
-
const entityRefParser = makeRefParser("Entity", entities);
|
|
480
|
-
if (shouldError) {
|
|
481
|
-
expect(() => mapCrud(crud, entityRefParser)).toThrowError();
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
const result = mapCrud(crud, entityRefParser);
|
|
485
|
-
expect(result).toStrictEqual({
|
|
486
|
-
entity: entityRefParser(crud.entity),
|
|
487
|
-
operations: mapCrudOperations(crud.operations),
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
describe("mapCrudOperations", () => {
|
|
492
|
-
test("should map minimal config correctly", () => {
|
|
493
|
-
testMapCrudOperations(Fixtures.getCrudOperations("minimal"));
|
|
494
|
-
});
|
|
495
|
-
test("should map full config correctly", () => {
|
|
496
|
-
testMapCrudOperations(Fixtures.getCrudOperations("full"));
|
|
497
|
-
});
|
|
498
|
-
function testMapCrudOperations(crudOperations) {
|
|
499
|
-
const result = mapCrudOperations(crudOperations);
|
|
500
|
-
expect(result).toStrictEqual({
|
|
501
|
-
get: crudOperations.get && mapCrudOperationOptions(crudOperations.get),
|
|
502
|
-
getAll: crudOperations.getAll && mapCrudOperationOptions(crudOperations.getAll),
|
|
503
|
-
create: crudOperations.create && mapCrudOperationOptions(crudOperations.create),
|
|
504
|
-
update: crudOperations.update && mapCrudOperationOptions(crudOperations.update),
|
|
505
|
-
delete: crudOperations.delete && mapCrudOperationOptions(crudOperations.delete),
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
});
|
|
509
|
-
describe("mapCrudOperationOptions", () => {
|
|
510
|
-
test("should map minimal config correctly", () => {
|
|
511
|
-
testMapCrudOperationOptions(Fixtures.getCrudOperationOptions("minimal"));
|
|
512
|
-
});
|
|
513
|
-
test("should map full config correctly", () => {
|
|
514
|
-
testMapCrudOperationOptions(Fixtures.getCrudOperationOptions("full"));
|
|
515
|
-
});
|
|
516
|
-
function testMapCrudOperationOptions(crudOperationOptions) {
|
|
517
|
-
const result = mapCrudOperationOptions(crudOperationOptions);
|
|
518
|
-
expect(result).toStrictEqual({
|
|
519
|
-
isPublic: crudOperationOptions.isPublic,
|
|
520
|
-
overrideFn: crudOperationOptions.overrideFn &&
|
|
521
|
-
mapExtImport(crudOperationOptions.overrideFn),
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
describe("mapApiNamespace", () => {
|
|
526
|
-
// NOTE: currently minimal config is the same as full config
|
|
527
|
-
test("should map minimal config correctly", () => {
|
|
528
|
-
testMapApiNamespace(Fixtures.getApiNamespaceConfig("minimal").config);
|
|
529
|
-
});
|
|
530
|
-
test("should map full config correctly", () => {
|
|
531
|
-
testMapApiNamespace(Fixtures.getApiNamespaceConfig("full").config);
|
|
532
|
-
});
|
|
533
|
-
function testMapApiNamespace(apiNamespace) {
|
|
534
|
-
const result = mapApiNamespace(apiNamespace);
|
|
535
|
-
expect(result).toStrictEqual({
|
|
536
|
-
middlewareConfigFn: mapExtImport(apiNamespace.middlewareConfigFn),
|
|
537
|
-
path: apiNamespace.path,
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
});
|
|
541
|
-
describe("mapApi", () => {
|
|
542
|
-
test("should map minimal config correctly", () => {
|
|
543
|
-
testMapApi(Fixtures.getApiConfig("minimal").config);
|
|
544
|
-
});
|
|
545
|
-
test("should map full config correctly", () => {
|
|
546
|
-
testMapApi(Fixtures.getApiConfig("full").config);
|
|
547
|
-
});
|
|
548
|
-
test("should throw if entities refs are not provided", () => {
|
|
549
|
-
testMapApi(Fixtures.getApiConfig("full").config, {
|
|
550
|
-
overrideEntities: [],
|
|
551
|
-
shouldError: true,
|
|
552
|
-
});
|
|
553
|
-
});
|
|
554
|
-
function testMapApi(api, options = {
|
|
555
|
-
shouldError: false,
|
|
556
|
-
}) {
|
|
557
|
-
const { overrideEntities, shouldError } = options;
|
|
558
|
-
const entities = overrideEntities ?? api.entities?.filter((e) => e !== undefined) ?? [];
|
|
559
|
-
const entityRefParser = makeRefParser("Entity", entities);
|
|
560
|
-
if (shouldError) {
|
|
561
|
-
expect(() => mapApi(api, entityRefParser)).toThrowError();
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
const result = mapApi(api, entityRefParser);
|
|
565
|
-
expect(result).toStrictEqual({
|
|
566
|
-
fn: mapExtImport(api.fn),
|
|
567
|
-
middlewareConfigFn: api.middlewareConfigFn && mapExtImport(api.middlewareConfigFn),
|
|
568
|
-
entities: api.entities?.map(entityRefParser),
|
|
569
|
-
httpRoute: mapHttpRoute(api.httpRoute),
|
|
570
|
-
auth: api.auth,
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
describe("mapHttpRoute", () => {
|
|
575
|
-
test("should map minimal config correctly", () => {
|
|
576
|
-
testMapHttpRoute(Fixtures.getHttpRoute("minimal"));
|
|
577
|
-
});
|
|
578
|
-
test("should map full config correctly", () => {
|
|
579
|
-
testMapHttpRoute(Fixtures.getHttpRoute("full"));
|
|
580
|
-
});
|
|
581
|
-
function testMapHttpRoute(httpRoute) {
|
|
582
|
-
const result = mapHttpRoute(httpRoute);
|
|
583
|
-
expect(result).toStrictEqual([
|
|
584
|
-
httpRoute.method,
|
|
585
|
-
httpRoute.route,
|
|
586
|
-
]);
|
|
587
|
-
}
|
|
588
|
-
});
|
|
589
|
-
describe("mapJob", () => {
|
|
590
|
-
test("should map minimal config correctly", () => {
|
|
591
|
-
testMapJob(Fixtures.getJobConfig("minimal").config);
|
|
592
|
-
});
|
|
593
|
-
test("should map full config correctly", () => {
|
|
594
|
-
testMapJob(Fixtures.getJobConfig("full").config);
|
|
595
|
-
});
|
|
596
|
-
test("should throw if entity ref is not provided", () => {
|
|
597
|
-
testMapJob(Fixtures.getJobConfig("full").config, {
|
|
598
|
-
overrideEntities: [],
|
|
599
|
-
shouldError: true,
|
|
600
|
-
});
|
|
601
|
-
});
|
|
602
|
-
function testMapJob(job, options = {
|
|
603
|
-
shouldError: false,
|
|
604
|
-
}) {
|
|
605
|
-
const { overrideEntities, shouldError } = options;
|
|
606
|
-
const entities = overrideEntities ?? job.entities?.filter((e) => e !== undefined) ?? [];
|
|
607
|
-
const entityRefParser = makeRefParser("Entity", entities);
|
|
608
|
-
if (shouldError) {
|
|
609
|
-
expect(() => mapJob(job, entityRefParser)).toThrowError();
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
const result = mapJob(job, entityRefParser);
|
|
613
|
-
expect(result).toStrictEqual({
|
|
614
|
-
executor: job.executor,
|
|
615
|
-
perform: mapPerform(job.perform),
|
|
616
|
-
schedule: job.schedule && mapSchedule(job.schedule),
|
|
617
|
-
entities: job.entities?.map(entityRefParser),
|
|
618
|
-
});
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
describe("mapSchedule", () => {
|
|
622
|
-
test("should map minimal config correctly", () => {
|
|
623
|
-
testMapSchedule(Fixtures.getSchedule("minimal"));
|
|
624
|
-
});
|
|
625
|
-
test("should map full config correctly", () => {
|
|
626
|
-
testMapSchedule(Fixtures.getSchedule("full"));
|
|
627
|
-
});
|
|
628
|
-
function testMapSchedule(schedule) {
|
|
629
|
-
const result = mapSchedule(schedule);
|
|
630
|
-
expect(result).toStrictEqual({
|
|
631
|
-
cron: schedule.cron,
|
|
632
|
-
args: schedule.args,
|
|
633
|
-
executorOptions: schedule.executorOptions,
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
describe("mapPerform", () => {
|
|
638
|
-
test("should map minimal config correctly", () => {
|
|
639
|
-
testMapPerform(Fixtures.getPerform("minimal"));
|
|
640
|
-
});
|
|
641
|
-
test("should map full config correctly", () => {
|
|
642
|
-
testMapPerform(Fixtures.getPerform("full"));
|
|
643
|
-
});
|
|
644
|
-
function testMapPerform(perform) {
|
|
645
|
-
const result = mapPerform(perform);
|
|
646
|
-
expect(result).toStrictEqual({
|
|
647
|
-
fn: mapExtImport(perform.fn),
|
|
648
|
-
executorOptions: perform.executorOptions,
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
describe("mapEmailFromField", () => {
|
|
653
|
-
test("should map minimal config correctly", () => {
|
|
654
|
-
testMapEmailFromField(Fixtures.getEmailFromField("minimal"));
|
|
655
|
-
});
|
|
656
|
-
test("should map full config correctly", () => {
|
|
657
|
-
testMapEmailFromField(Fixtures.getEmailFromField("full"));
|
|
658
|
-
});
|
|
659
|
-
function testMapEmailFromField(emailFromField) {
|
|
660
|
-
const result = mapEmailFromField(emailFromField);
|
|
661
|
-
expect(result).toStrictEqual({
|
|
662
|
-
name: emailFromField.name,
|
|
663
|
-
email: emailFromField.email,
|
|
664
|
-
});
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
describe("mapExtImport", () => {
|
|
668
|
-
test("should map minimal named import correctly", () => {
|
|
669
|
-
testMapExtImport(Fixtures.getExtImport("minimal", "named"));
|
|
670
|
-
});
|
|
671
|
-
test("should map full named import correctly", () => {
|
|
672
|
-
testMapExtImport(Fixtures.getExtImport("full", "named"));
|
|
673
|
-
});
|
|
674
|
-
test("should map minimal default import correctly", () => {
|
|
675
|
-
testMapExtImport(Fixtures.getExtImport("minimal", "default"));
|
|
676
|
-
});
|
|
677
|
-
test("should map full default import correctly", () => {
|
|
678
|
-
testMapExtImport(Fixtures.getExtImport("full", "default"));
|
|
679
|
-
});
|
|
680
|
-
test("should throw for missing import kind", () => {
|
|
681
|
-
const extImport = {
|
|
682
|
-
from: "@src/myModule",
|
|
683
|
-
};
|
|
684
|
-
testMapExtImport(extImport, {
|
|
685
|
-
shouldError: true,
|
|
686
|
-
});
|
|
687
|
-
});
|
|
688
|
-
// TODO: unskip this test when we decide how to handle this
|
|
689
|
-
test.skip("should throw for having both import kind", () => {
|
|
690
|
-
const extImport = {
|
|
691
|
-
...Fixtures.getExtImport("full", "named"),
|
|
692
|
-
...Fixtures.getExtImport("full", "default"),
|
|
693
|
-
};
|
|
694
|
-
testMapExtImport(extImport, {
|
|
695
|
-
shouldError: true,
|
|
696
|
-
});
|
|
697
|
-
});
|
|
698
|
-
// TODO: unskip this test when we decide how to handle this
|
|
699
|
-
test.skip("should throw error for invalid from path", () => {
|
|
700
|
-
const extImport = {
|
|
701
|
-
import: "myNamedImport",
|
|
702
|
-
from: "./invalid/path",
|
|
703
|
-
};
|
|
704
|
-
testMapExtImport(extImport, {
|
|
705
|
-
shouldError: true,
|
|
706
|
-
});
|
|
707
|
-
});
|
|
708
|
-
function testMapExtImport(extImport, options = {
|
|
709
|
-
shouldError: false,
|
|
710
|
-
}) {
|
|
711
|
-
const { shouldError } = options;
|
|
712
|
-
if (shouldError) {
|
|
713
|
-
expect(() => mapExtImport(extImport)).toThrowError();
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
const result = mapExtImport(extImport);
|
|
717
|
-
if ("import" in extImport) {
|
|
718
|
-
expect(result).toStrictEqual({
|
|
719
|
-
kind: "named",
|
|
720
|
-
name: extImport.import,
|
|
721
|
-
path: extImport.from,
|
|
722
|
-
});
|
|
723
|
-
}
|
|
724
|
-
else if ("importDefault" in extImport) {
|
|
725
|
-
expect(result).toStrictEqual({
|
|
726
|
-
kind: "default",
|
|
727
|
-
name: extImport.importDefault,
|
|
728
|
-
path: extImport.from,
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
});
|