Make server and client fields optional (#2351)

This commit is contained in:
Filip Sodić 2024-10-21 22:37:05 +02:00 committed by GitHub
parent 7ef2a34409
commit 01af22f6e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 45 additions and 29 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## 0.15.1
### 🐞 Bug fixes
- Server and Client setup props are no longer mandatory when using TS Config.
## 0.15.0
### 🎉 New Features and improvements

View File

@ -1,6 +1,6 @@
app waspBuild {
wasp: {
version: "^0.15.0"
version: "^0.15.1"
},
title: "waspBuild"
}

View File

@ -1,6 +1,6 @@
app waspCompile {
wasp: {
version: "^0.15.0"
version: "^0.15.1"
},
title: "waspCompile"
}

View File

@ -1,6 +1,6 @@
app waspComplexTest {
wasp: {
version: "^0.15.0"
version: "^0.15.1"
},
auth: {
userEntity: User,

View File

@ -1,6 +1,6 @@
app waspJob {
wasp: {
version: "^0.15.0"
version: "^0.15.1"
},
title: "waspJob"
}

View File

@ -1,6 +1,6 @@
app waspMigrate {
wasp: {
version: "^0.15.0"
version: "^0.15.1"
},
title: "waspMigrate"
}

View File

@ -1,6 +1,6 @@
app waspNew {
wasp: {
version: "^0.15.0"
version: "^0.15.1"
},
title: "waspNew"
}

View File

@ -143,12 +143,18 @@ function mapOperationConfig(
function mapExtImport(extImport: User.ExtImport): AppSpec.ExtImport {
if ('import' in extImport) {
return { kind: 'named', name: extImport.import, path: extImport.from };
return { kind: 'named', name: extImport.import, path: extImport.from }
} else if ('importDefault' in extImport) {
return { kind: 'default', name: extImport.importDefault, path: extImport.from };
return {
kind: 'default',
name: extImport.importDefault,
path: extImport.from,
}
} else {
const _exhaustiveCheck: never = extImport;
throw new Error('Invalid ExtImport: neither `import` nor `importDefault` is defined');
const _exhaustiveCheck: never = extImport
throw new Error(
'Invalid ExtImport: neither `import` nor `importDefault` is defined'
)
}
}
@ -326,16 +332,19 @@ function mapEmailSender(
function mapServer(server: User.ServerConfig): AppSpec.Server {
const { setupFn, middlewareConfigFn } = server
return {
setupFn: mapExtImport(setupFn),
middlewareConfigFn: mapExtImport(middlewareConfigFn),
...(setupFn && { setupFn: mapExtImport(setupFn) }),
...(middlewareConfigFn && {
middlewareConfigFn: mapExtImport(middlewareConfigFn),
}),
}
}
function mapClient(client: User.ClientConfig): AppSpec.Client {
const { setupFn, rootComponent } = client
const { setupFn, rootComponent, baseDir } = client
return {
setupFn: mapExtImport(setupFn),
rootComponent: mapExtImport(rootComponent),
...(setupFn && { setupFn: mapExtImport(setupFn) }),
...(rootComponent && { rootComponent: mapExtImport(rootComponent) }),
...(baseDir && { baseDir }),
}
}

View File

@ -94,17 +94,19 @@ export type WaspConfig = AppSpec.Wasp
export type AppConfig = Pick<AppSpec.App, 'title' | 'wasp' | 'head'>
export type ExtImport = {
import: string
from: AppSpec.ExtImport['path']
} | {
importDefault: string
from: AppSpec.ExtImport['path']
}
export type ExtImport =
| {
import: string
from: AppSpec.ExtImport['path']
}
| {
importDefault: string
from: AppSpec.ExtImport['path']
}
export type ServerConfig = {
setupFn: ExtImport
middlewareConfigFn: ExtImport
setupFn?: ExtImport
middlewareConfigFn?: ExtImport
}
export type PageConfig = {
@ -118,8 +120,9 @@ export type WebsocketConfig = {
}
export type ClientConfig = {
rootComponent: ExtImport
setupFn: ExtImport
rootComponent?: ExtImport
setupFn?: ExtImport
baseDir?: `/${string}`
}
export type DbConfig = {

View File

@ -20,8 +20,6 @@ where
import Control.Arrow (left)
import qualified Data.Aeson as Aeson
import qualified Data.ByteString.Lazy.UTF8 as ByteStringLazyUTF8
import Data.List (stripPrefix)
import qualified StrongPath as SP
import Wasp.Analyzer.Evaluator.Evaluation.Internal (evaluation, evaluation', runEvaluation)
import Wasp.Analyzer.Evaluator.Evaluation.TypedExpr (TypedExprEvaluation)
import qualified Wasp.Analyzer.Evaluator.EvaluationError as ER

View File

@ -6,7 +6,7 @@ cabal-version: 2.4
-- Consider using hpack, or maybe even hpack-dhall.
name: waspc
version: 0.15.0
version: 0.15.1
description: Please see the README on GitHub at <https://github.com/wasp-lang/wasp/waspc#readme>
homepage: https://github.com/wasp-lang/wasp/waspc#readme
bug-reports: https://github.com/wasp-lang/wasp/issues