Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make server and client fields optional #2351

Merged
merged 4 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions waspc/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 18 additions & 9 deletions waspc/packages/wasp-config/src/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
}
}

Expand Down Expand Up @@ -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 }),
}
}

Expand Down
25 changes: 14 additions & 11 deletions waspc/packages/wasp-config/src/userApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -118,8 +120,9 @@ export type WebsocketConfig = {
}

export type ClientConfig = {
rootComponent: ExtImport
setupFn: ExtImport
rootComponent?: ExtImport
setupFn?: ExtImport
baseDir?: `/${string}`
}

export type DbConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion waspc/waspc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading