/** This module is a mirror implementation of FromJSON for AppSpec Decls in * TypeScript. The original implemention is in Haskell (waspc). * * IMPORTANT: Do not change this file without updating the AppSpec in waspc. */ export type Decl = { [Type in keyof DeclTypeToValue]: { declType: Type; declName: string; declValue: DeclTypeToValue[Type]; }; }[keyof DeclTypeToValue]; export type DeclTypeToValue = { App: App; Page: Page; Route: Route; Query: Query; Action: Action; Job: Job; Api: Api; ApiNamespace: ApiNamespace; Crud: Crud; }; export type GetDeclForType = Extract; export type DeclType = Decl["declType"] | "Entity"; export type Page = { component: ExtImport; authRequired: Optional; }; export type Route = { path: string; to: Ref<"Page">; prerender: Optional; lazy: Optional; }; export type Action = { fn: ExtImport; entities: Optional[]>; auth: Optional; }; export type Query = { fn: ExtImport; entities: Optional[]>; auth: Optional; }; export type Job = { executor: JobExecutor; perform: Perform; schedule: Optional; entities: Optional[]>; }; export type Schedule = { cron: string; args: Optional; executorOptions: Optional; }; export type Perform = { fn: ExtImport; executorOptions: Optional; }; export type Api = { fn: ExtImport; middlewareConfigFn: Optional; entities: Optional[]>; httpRoute: HttpRoute; auth: Optional; }; export type ApiNamespace = { middlewareConfigFn: ExtImport; path: string; }; export type Crud = { entity: Ref<"Entity">; operations: CrudOperations; }; export type App = { wasp: Wasp; title: string; head: Optional; auth: Optional; server: Optional; client: Optional; db: Optional; emailSender: Optional; webSocket: Optional; }; export type ExtImport = NamedExtImport | DefaultExtImport; export type ExtImportKind = ExtImport["kind"]; export type NamedExtImport = { kind: "named"; name: string; path: `@src/${string}`; alias?: string; }; export type DefaultExtImport = { kind: "default"; name: string; path: `@src/${string}`; }; export type JobExecutor = "PgBoss"; export type ExecutorOptions = { pgBoss: Optional; }; export type HttpMethod = "ALL" | "GET" | "POST" | "PUT" | "DELETE"; export type HttpRoute = [HttpMethod, string]; export type CrudOperations = { get: Optional; getAll: Optional; create: Optional; update: Optional; delete: Optional; }; export type CrudOperationOptions = { isPublic: Optional; overrideFn: Optional; }; export type Wasp = { version: string; }; export type Auth = { userEntity: Ref<"Entity">; methods: AuthMethods; onAuthFailedRedirectTo: string; onAuthSucceededRedirectTo: Optional; onBeforeSignup: Optional; onAfterSignup: Optional; onAfterEmailVerified: Optional; onBeforeOAuthRedirect: Optional; onBeforeLogin: Optional; onAfterLogin: Optional; }; export type AuthMethods = { usernameAndPassword: Optional; slack: Optional; discord: Optional; google: Optional; gitHub: Optional; keycloak: Optional; microsoft: Optional; email: Optional; }; export type UsernameAndPasswordConfig = { userSignupFields: Optional; }; export type ExternalAuthConfig = { configFn: Optional; userSignupFields: Optional; }; export type EmailAuthConfig = { userSignupFields: Optional; fromField: EmailFromField; emailVerification: EmailVerificationConfig; passwordReset: PasswordResetConfig; }; export type EmailSender = { provider: EmailProvider; defaultFrom: Optional; }; export type EmailProvider = "SMTP" | "SendGrid" | "Mailgun" | "Dummy"; export type EmailFromField = { name: Optional; email: string; }; export type EmailVerificationConfig = { getEmailContentFn: Optional; clientRoute: Ref<"Route">; }; export type PasswordResetConfig = { getEmailContentFn: Optional; clientRoute: Ref<"Route">; }; export type Ref = { name: string; declType: T; }; export type Server = { setupFn: Optional; middlewareConfigFn: Optional; envValidationSchema: Optional; }; export type Client = { setupFn: Optional; rootComponent: Optional; baseDir: Optional<`/${string}`>; envValidationSchema: Optional; }; export type Db = { seeds: Optional; prismaSetupFn: Optional; }; export type WebSocket = { fn: ExtImport; autoConnect: Optional; }; /** * We use this type for fields that are optional (Maybe) in AppSpec. * We do this instead of `someField?:` because we want TypeScript to force us * to explicitly set the field to `undefined`. * * This way, if the AppSpec changes on the Haskell side, we won't forget to * implement a proper mapping in TypeScript. * * For example, let's say `bar` is optional (both for the user and for the app * spec). This would be the correct mapping code: * ``` * const { foo, bar } = userConfig * const decl: SomeDecl = { * foo: mapForAppSpec(foo), * bar: mapForAppSpec(bar) * } * ``` * The code below is wrong. It forgets to map `bar` even though it might exist * in `userConfig`: * ``` * const { foo } = userConfig * const decl: SomeDecl = { * foo: mapForAppSpec(foo), * } * ``` * If `bar` is an optional field of `SomeDecl` (`bar?: string`), TypeScript * doesn't catch this error. * * If `bar` is a mandatory field of `SomeDecl` that can be set to `undefined` * (`bar: Optional`), TypeScript catches the error. * * Explicitly setting optional fields to `undefined` doesn't impact JSON * serialization since fields set to `undefined` are treated as missing fields. */ type Optional = T | undefined; export {}; //# sourceMappingURL=appSpec.d.ts.map