mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-11-26 22:36:01 +03:00
Renamed EntityPSL to Entity.
This commit is contained in:
parent
58d10ab305
commit
cb217fde44
@ -37,7 +37,7 @@ query getTasks {
|
||||
fn: import { getTasks } from "@ext/queries.js"
|
||||
}
|
||||
|
||||
entityPSL Task {=psl
|
||||
entity Task {=psl
|
||||
id Int @id @default(autoincrement())
|
||||
description String
|
||||
isDone Boolean @default(false)
|
||||
|
@ -7,7 +7,7 @@ page Main {
|
||||
component: import Main from "@ext/MainPage.js"
|
||||
}
|
||||
|
||||
entityPSL Task {=psl
|
||||
entity Task {=psl
|
||||
id Int @id @default(autoincrement())
|
||||
description String
|
||||
isDone Boolean @default(false)
|
||||
|
@ -7,14 +7,14 @@ auth {
|
||||
methods: [ EmailAndPassword ]
|
||||
}
|
||||
|
||||
entityPSL User {=psl
|
||||
entity User {=psl
|
||||
id Int @id @default(autoincrement())
|
||||
email String @unique
|
||||
password String
|
||||
tasks Task[]
|
||||
psl=}
|
||||
|
||||
entityPSL Task {=psl
|
||||
entity Task {=psl
|
||||
id Int @id @default(autoincrement())
|
||||
description String
|
||||
isDone Boolean @default(false)
|
||||
|
@ -11,7 +11,7 @@ import StrongPath (Path, Rel, File, Dir, (</>))
|
||||
import qualified StrongPath as SP
|
||||
import Wasp (Wasp)
|
||||
import qualified Wasp
|
||||
import Wasp.EntityPSL (EntityPSL)
|
||||
import Wasp.Entity (Entity)
|
||||
import CompileOptions (CompileOptions)
|
||||
import Generator.FileDraft (FileDraft, createTemplateFileDraft)
|
||||
import Generator.Common (ProjectRootDir)
|
||||
@ -42,7 +42,7 @@ genDb wasp _ =
|
||||
[ genPrismaSchema $ Wasp.getPSLEntities wasp
|
||||
]
|
||||
|
||||
genPrismaSchema :: [EntityPSL] -> FileDraft
|
||||
genPrismaSchema :: [Entity] -> FileDraft
|
||||
genPrismaSchema entities = createTemplateFileDraft dstPath tmplSrcPath (Just templateData)
|
||||
where
|
||||
dstPath = dbSchemaFileInProjectRootDir
|
||||
|
@ -22,8 +22,8 @@ reservedNamePage = "page"
|
||||
reservedNameRoute :: String
|
||||
reservedNameRoute = "route"
|
||||
|
||||
reservedNameEntityPSL :: String
|
||||
reservedNameEntityPSL = "entityPSL"
|
||||
reservedNameEntity :: String
|
||||
reservedNameEntity = "entity"
|
||||
|
||||
reservedNameAuth :: String
|
||||
reservedNameAuth = "auth"
|
||||
@ -60,7 +60,7 @@ reservedNames =
|
||||
, reservedNameDependencies
|
||||
, reservedNamePage
|
||||
, reservedNameRoute
|
||||
, reservedNameEntityPSL
|
||||
, reservedNameEntity
|
||||
, reservedNameAuth
|
||||
, reservedNameQuery
|
||||
, reservedNameAction
|
||||
|
@ -13,7 +13,7 @@ import Parser.App (app)
|
||||
import Parser.Auth (auth)
|
||||
import Parser.Route (route)
|
||||
import Parser.Page (page)
|
||||
import Parser.EntityPSL (entityPSL)
|
||||
import Parser.Entity (entity)
|
||||
|
||||
import Parser.JsImport (jsImport)
|
||||
import Parser.Common (runWaspParser)
|
||||
@ -27,7 +27,7 @@ waspElement
|
||||
<|> waspElementAuth
|
||||
<|> waspElementPage
|
||||
<|> waspElementRoute
|
||||
<|> waspElementEntityPSL
|
||||
<|> waspElementEntity
|
||||
<|> waspElementQuery
|
||||
<|> waspElementAction
|
||||
<|> waspElementNpmDependencies
|
||||
@ -44,8 +44,8 @@ waspElementPage = Wasp.WaspElementPage <$> page
|
||||
waspElementRoute :: Parser Wasp.WaspElement
|
||||
waspElementRoute = Wasp.WaspElementRoute <$> route
|
||||
|
||||
waspElementEntityPSL :: Parser Wasp.WaspElement
|
||||
waspElementEntityPSL = Wasp.WaspElementEntityPSL <$> entityPSL
|
||||
waspElementEntity :: Parser Wasp.WaspElement
|
||||
waspElementEntity = Wasp.WaspElementEntity <$> entity
|
||||
|
||||
|
||||
waspElementQuery :: Parser Wasp.WaspElement
|
||||
|
@ -1,20 +1,20 @@
|
||||
module Parser.EntityPSL
|
||||
( entityPSL
|
||||
module Parser.Entity
|
||||
( entity
|
||||
) where
|
||||
|
||||
import Text.Parsec.String (Parser)
|
||||
import qualified Data.Text as Text
|
||||
|
||||
import qualified Wasp.EntityPSL
|
||||
import qualified Wasp.Entity
|
||||
import qualified Parser.Common as P
|
||||
import qualified Lexer as L
|
||||
|
||||
entityPSL :: Parser Wasp.EntityPSL.EntityPSL
|
||||
entityPSL = do
|
||||
(name, pslModelSchema) <- P.waspElementNameAndClosure L.reservedNameEntityPSL
|
||||
entity :: Parser Wasp.Entity.Entity
|
||||
entity = do
|
||||
(name, pslModelSchema) <- P.waspElementNameAndClosure L.reservedNameEntity
|
||||
(P.waspNamedClosure "psl")
|
||||
|
||||
return Wasp.EntityPSL.EntityPSL
|
||||
{ Wasp.EntityPSL._name = name
|
||||
, Wasp.EntityPSL._pslModelSchema = Text.pack $ pslModelSchema
|
||||
return Wasp.Entity.Entity
|
||||
{ Wasp.Entity._name = name
|
||||
, Wasp.Entity._pslModelSchema = Text.pack $ pslModelSchema
|
||||
}
|
@ -42,7 +42,7 @@ import qualified Util as U
|
||||
import qualified Wasp.Action
|
||||
import Wasp.App
|
||||
import qualified Wasp.Auth
|
||||
import Wasp.EntityPSL
|
||||
import Wasp.Entity
|
||||
import Wasp.JsImport
|
||||
import Wasp.NpmDependencies (NpmDependencies)
|
||||
import qualified Wasp.NpmDependencies
|
||||
@ -65,7 +65,7 @@ data WaspElement
|
||||
| WaspElementPage !Page
|
||||
| WaspElementNpmDependencies !NpmDependencies
|
||||
| WaspElementRoute !Route
|
||||
| WaspElementEntityPSL !Wasp.EntityPSL.EntityPSL
|
||||
| WaspElementEntity !Wasp.Entity.Entity
|
||||
| WaspElementQuery !Wasp.Query.Query
|
||||
| WaspElementAction !Wasp.Action.Action
|
||||
deriving (Show, Eq)
|
||||
@ -183,8 +183,8 @@ getActionByName wasp name = U.headSafe $ filter (\a -> Wasp.Action._name a == na
|
||||
|
||||
-- * Entities
|
||||
|
||||
getPSLEntities :: Wasp -> [Wasp.EntityPSL.EntityPSL]
|
||||
getPSLEntities wasp = [entityPSL | (WaspElementEntityPSL entityPSL) <- (waspElements wasp)]
|
||||
getPSLEntities :: Wasp -> [Wasp.Entity.Entity]
|
||||
getPSLEntities wasp = [entity | (WaspElementEntity entity) <- (waspElements wasp)]
|
||||
|
||||
|
||||
-- * ToJSON instances.
|
||||
|
@ -1,18 +1,18 @@
|
||||
-- TODO(matija): remove PSL suffix, added it to avoid clashes with the existing Entity module.
|
||||
-- Once the old Entity module is removed, rename to "Entity".
|
||||
module Wasp.EntityPSL
|
||||
( EntityPSL (..)
|
||||
module Wasp.Entity
|
||||
( Entity (..)
|
||||
) where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Data.Aeson (ToJSON(..), (.=), object)
|
||||
|
||||
data EntityPSL = EntityPSL
|
||||
data Entity = Entity
|
||||
{ _name :: !String
|
||||
, _pslModelSchema :: !Text -- ^ PSL stands for Prisma Schema Language.
|
||||
} deriving (Show, Eq)
|
||||
|
||||
instance ToJSON EntityPSL where
|
||||
instance ToJSON Entity where
|
||||
toJSON entity = object
|
||||
[ "name" .= _name entity
|
||||
, "pslModelSchema" .= _pslModelSchema entity
|
@ -8,7 +8,7 @@ import NpmDependency as ND
|
||||
import Parser
|
||||
import qualified StrongPath as SP
|
||||
import Wasp
|
||||
import qualified Wasp.EntityPSL
|
||||
import qualified Wasp.Entity
|
||||
import qualified Wasp.Auth
|
||||
import qualified Wasp.JsImport
|
||||
import qualified Wasp.NpmDependencies
|
||||
@ -59,9 +59,9 @@ spec_parseWasp =
|
||||
, Wasp.JsImport._from = SP.fromPathRelFileP [PPosix.relfile|pages/Test|]
|
||||
}
|
||||
}
|
||||
, WaspElementEntityPSL $ Wasp.EntityPSL.EntityPSL
|
||||
{ Wasp.EntityPSL._name = "Task"
|
||||
, Wasp.EntityPSL._pslModelSchema = "\
|
||||
, WaspElementEntity $ Wasp.Entity.Entity
|
||||
{ Wasp.Entity._name = "Task"
|
||||
, Wasp.Entity._pslModelSchema = "\
|
||||
\id Int @id @default(autoincrement())\n\
|
||||
\ description String\n\
|
||||
\ isDone Boolean @default(false)"
|
||||
|
@ -23,7 +23,7 @@ page TestPage {
|
||||
component: import Test from "@ext/pages/Test"
|
||||
}
|
||||
|
||||
entityPSL Task {=psl
|
||||
entity Task {=psl
|
||||
id Int @id @default(autoincrement())
|
||||
description String
|
||||
isDone Boolean @default(false)
|
||||
|
Loading…
Reference in New Issue
Block a user