Removing restructuring leftover files (#1925)

This commit is contained in:
Filip Sodić 2024-03-28 16:12:18 +01:00 committed by GitHub
parent ce61dcf5fe
commit 1de32ac113
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
39 changed files with 4 additions and 970 deletions

View File

@ -1,22 +0,0 @@
{{={= =}=}}
import {
{=# entities =}
{= name =},
{=/ entities =}
} from '@prisma/client'
export type {
{=# entities =}
{= name =},
{=/ entities =}
{=# isAuthEnabled =}
{= authEntityName =},
{= authIdentityEntityName =},
{=/ isAuthEnabled =}
} from '@prisma/client'
export type Entity =
{=# entities =}
| {= name =}
{=/ entities =}
| never

View File

@ -1,23 +0,0 @@
import { QueryClient } from '@tanstack/react-query'
const defaultQueryClientConfig = {}
let queryClientConfig, resolveQueryClientInitialized, isQueryClientInitialized
export const queryClientInitialized = new Promise(resolve => {
resolveQueryClientInitialized = resolve
});
export function configureQueryClient(config) {
if (isQueryClientInitialized) {
throw new Error("Attempted to configure the QueryClient after initialization")
}
queryClientConfig = config
}
export function initializeQueryClient() {
const queryClient = new QueryClient(queryClientConfig ?? defaultQueryClientConfig)
isQueryClientInitialized = true;
resolveQueryClientInitialized(queryClient)
}

View File

@ -1,50 +0,0 @@
export type DataStore = {
getPrefixedKey(key: string): string
set(key: string, value: unknown): void
get(key: string): unknown
remove(key: string): void
clear(): void
}
function createLocalStorageDataStore(prefix: string): DataStore {
function getPrefixedKey(key: string): string {
return `${prefix}:${key}`
}
return {
getPrefixedKey,
set(key, value) {
ensureLocalStorageIsAvailable()
localStorage.setItem(getPrefixedKey(key), JSON.stringify(value))
},
get(key) {
ensureLocalStorageIsAvailable()
const value = localStorage.getItem(getPrefixedKey(key))
try {
return value ? JSON.parse(value) : undefined
} catch (e: any) {
return undefined
}
},
remove(key) {
ensureLocalStorageIsAvailable()
localStorage.removeItem(getPrefixedKey(key))
},
clear() {
ensureLocalStorageIsAvailable()
Object.keys(localStorage).forEach((key) => {
if (key.startsWith(prefix)) {
localStorage.removeItem(key)
}
})
},
}
}
export const storage = createLocalStorageDataStore('wasp')
function ensureLocalStorageIsAvailable(): void {
if (!window.localStorage) {
throw new Error('Local storage is not available.')
}
}

View File

@ -1,34 +0,0 @@
{{={= =}=}}
{=! TODO: This template is exactly the same at the moment as one for query
types, consider whether it makes sense to address this in the future. =}
import {
{=# allEntities =}
type {= internalTypeName =},
{=/ allEntities =}
{=# shouldImportNonAuthenticatedOperation =}
type Action,
{=/ shouldImportNonAuthenticatedOperation =}
{=# shouldImportAuthenticatedOperation =}
type AuthenticatedAction,
{=/ shouldImportAuthenticatedOperation =}
type Payload,
} from 'wasp/server/_types'
{=# operations =}
export type {= typeName =}<Input extends Payload = never, Output extends Payload = Payload> =
{=# usesAuth =}
AuthenticatedAction<
{=/ usesAuth =}
{=^ usesAuth =}
Action<
{=/ usesAuth =}
[
{=# entities =}
{= internalTypeName =},
{=/ entities =}
],
Input,
Output
>
{=/ operations =}

View File

@ -1,293 +0,0 @@
{{={= =}=}}
import { hashPassword } from 'wasp/auth/password'
import { prisma, HttpError } from 'wasp/server'
import { sleep } from 'wasp/server/utils'
import {
type {= userEntityUpper =},
type {= authEntityUpper =},
type {= authIdentityEntityUpper =},
} from 'wasp/entities/index'
import { Prisma } from '@prisma/client';
import { throwValidationError } from 'wasp/auth/validation'
import { type UserSignupFields, type PossibleUserFields } from 'wasp/auth/providers/types'
export type EmailProviderData = {
hashedPassword: string;
isEmailVerified: boolean;
emailVerificationSentAt: string | null;
passwordResetSentAt: string | null;
}
export type UsernameProviderData = {
hashedPassword: string;
}
export type OAuthProviderData = {}
/**
* This type is used for type-level programming e.g. to enumerate
* all possible provider data types.
*
* The keys of this type are the names of the providers and the values
* are the types of the provider data.
*/
export type PossibleProviderData = {
email: EmailProviderData;
username: UsernameProviderData;
google: OAuthProviderData;
keycloak: OAuthProviderData;
github: OAuthProviderData;
}
export type ProviderName = keyof PossibleProviderData
export const contextWithUserEntity = {
entities: {
{= userEntityUpper =}: prisma.{= userEntityLower =}
}
}
export const authConfig = {
failureRedirectPath: "{= failureRedirectPath =}",
successRedirectPath: "{= successRedirectPath =}",
}
/**
* ProviderId uniquely identifies an auth identity e.g.
* "email" provider with user id "test@test.com" or
* "google" provider with user id "1234567890".
*
* We use this type to avoid passing the providerName and providerUserId
* separately. Also, we can normalize the providerUserId to make sure it's
* consistent across different DB operations.
*/
export type ProviderId = {
providerName: ProviderName;
providerUserId: string;
}
export function createProviderId(providerName: ProviderName, providerUserId: string): ProviderId {
return {
providerName,
providerUserId: providerUserId.toLowerCase(),
}
}
export async function findAuthIdentity(providerId: ProviderId): Promise<{= authIdentityEntityUpper =} | null> {
return prisma.{= authIdentityEntityLower =}.findUnique({
where: {
providerName_providerUserId: providerId,
}
});
}
/**
* Updates the provider data for the given auth identity.
*
* This function performs data sanitization and serialization.
* Sanitization is done by hashing the password, so this function
* expects the password received in the `providerDataUpdates`
* **not to be hashed**.
*/
export async function updateAuthIdentityProviderData<PN extends ProviderName>(
providerId: ProviderId,
existingProviderData: PossibleProviderData[PN],
providerDataUpdates: Partial<PossibleProviderData[PN]>,
): Promise<{= authIdentityEntityUpper =}> {
// We are doing the sanitization here only on updates to avoid
// hashing the password multiple times.
const sanitizedProviderDataUpdates = await sanitizeProviderData(providerDataUpdates);
const newProviderData = {
...existingProviderData,
...sanitizedProviderDataUpdates,
}
const serializedProviderData = await serializeProviderData<PN>(newProviderData);
return prisma.{= authIdentityEntityLower =}.update({
where: {
providerName_providerUserId: providerId,
},
data: { providerData: serializedProviderData },
});
}
type FindAuthWithUserResult = {= authEntityUpper =} & {
{= userFieldOnAuthEntityName =}: {= userEntityUpper =}
}
export async function findAuthWithUserBy(
where: Prisma.{= authEntityUpper =}WhereInput
): Promise<FindAuthWithUserResult> {
return prisma.{= authEntityLower =}.findFirst({ where, include: { {= userFieldOnAuthEntityName =}: true }});
}
export async function createUser(
providerId: ProviderId,
serializedProviderData?: string,
userFields?: PossibleUserFields,
): Promise<{= userEntityUpper =} & {
auth: {= authEntityUpper =}
}> {
return prisma.{= userEntityLower =}.create({
data: {
// Using any here to prevent type errors when userFields are not
// defined. We want Prisma to throw an error in that case.
...(userFields ?? {} as any),
{= authFieldOnUserEntityName =}: {
create: {
{= identitiesFieldOnAuthEntityName =}: {
create: {
providerName: providerId.providerName,
providerUserId: providerId.providerUserId,
providerData: serializedProviderData,
},
},
}
},
},
// We need to include the Auth entity here because we need `authId`
// to be able to create a session.
include: {
{= authFieldOnUserEntityName =}: true,
},
})
}
export async function deleteUserByAuthId(authId: string): Promise<{ count: number }> {
return prisma.{= userEntityLower =}.deleteMany({ where: { auth: {
id: authId,
} } })
}
// If an user exists, we don't want to leak information
// about it. Pretending that we're doing some work
// will make it harder for an attacker to determine
// if a user exists or not.
// NOTE: Attacker measuring time to response can still determine
// if a user exists or not. We'll be able to avoid it when
// we implement e-mail sending via jobs.
export async function doFakeWork(): Promise<unknown> {
const timeToWork = Math.floor(Math.random() * 1000) + 1000;
return sleep(timeToWork);
}
export function rethrowPossibleAuthError(e: unknown): void {
// Prisma code P2002 is for unique constraint violations.
if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === 'P2002') {
throw new HttpError(422, 'Save failed', {
message: `user with the same identity already exists`,
})
}
if (e instanceof Prisma.PrismaClientValidationError) {
// NOTE: Logging the error since this usually means that there are
// required fields missing in the request, we want the developer
// to know about it.
console.error(e)
throw new HttpError(422, 'Save failed', {
message: 'there was a database error'
})
}
// Prisma code P2021 is for missing table errors.
if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === 'P2021') {
// NOTE: Logging the error since this usually means that the database
// migrations weren't run, we want the developer to know about it.
console.error(e)
console.info('🐝 This error can happen if you did\'t run the database migrations.')
throw new HttpError(500, 'Save failed', {
message: `there was a database error`,
})
}
// Prisma code P2003 is for foreign key constraint failure
if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === 'P2003') {
console.error(e)
console.info(`🐝 This error can happen if you have some relation on your {= userEntityUpper =} entity
but you didn't specify the "onDelete" behaviour to either "Cascade" or "SetNull".
Read more at: https://www.prisma.io/docs/orm/prisma-schema/data-model/relations/referential-actions`)
throw new HttpError(500, 'Save failed', {
message: `there was a database error`,
})
}
throw e
}
export async function validateAndGetUserFields(
data: {
[key: string]: unknown
},
userSignupFields?: UserSignupFields,
): Promise<Record<string, any>> {
const {
password: _password,
...sanitizedData
} = data;
const result: Record<string, any> = {};
if (!userSignupFields) {
return result;
}
for (const [field, getFieldValue] of Object.entries(userSignupFields)) {
try {
const value = await getFieldValue(sanitizedData)
result[field] = value
} catch (e) {
throwValidationError(e.message)
}
}
return result;
}
export function deserializeAndSanitizeProviderData<PN extends ProviderName>(
providerData: string,
{ shouldRemovePasswordField = false }: { shouldRemovePasswordField?: boolean } = {},
): PossibleProviderData[PN] {
// NOTE: We are letting JSON.parse throw an error if the providerData is not valid JSON.
let data = JSON.parse(providerData) as PossibleProviderData[PN];
if (providerDataHasPasswordField(data) && shouldRemovePasswordField) {
delete data.hashedPassword;
}
return data;
}
export async function sanitizeAndSerializeProviderData<PN extends ProviderName>(
providerData: PossibleProviderData[PN],
): Promise<string> {
return serializeProviderData(
await sanitizeProviderData(providerData)
);
}
function serializeProviderData<PN extends ProviderName>(providerData: PossibleProviderData[PN]): string {
return JSON.stringify(providerData);
}
async function sanitizeProviderData<PN extends ProviderName>(
providerData: PossibleProviderData[PN],
): Promise<PossibleProviderData[PN]> {
const data = {
...providerData,
};
if (providerDataHasPasswordField(data)) {
data.hashedPassword = await hashPassword(data.hashedPassword);
}
return data;
}
function providerDataHasPasswordField(
providerData: PossibleProviderData[keyof PossibleProviderData],
): providerData is { hashedPassword: string } {
return 'hashedPassword' in providerData;
}
export function throwInvalidCredentialsError(message?: string): void {
throw new HttpError(401, 'Invalid credentials', { message })
}

View File

@ -1,35 +0,0 @@
{{={= =}=}}
{=! TODO: This template is exactly the same at the moment as one for action
types, consider whether it makes sense to address this in the future. =}
import {
{=# allEntities =}
type {= internalTypeName =},
{=/ allEntities =}
{=# shouldImportNonAuthenticatedOperation =}
type Query,
{=/ shouldImportNonAuthenticatedOperation =}
{=# shouldImportAuthenticatedOperation =}
type AuthenticatedQuery,
{=/ shouldImportAuthenticatedOperation =}
type Payload,
} from 'wasp/server/_types'
{=# operations =}
export type {= typeName =}<Input extends Payload = never, Output extends Payload = Payload> =
{=# usesAuth =}
AuthenticatedQuery<
{=/ usesAuth =}
{=^ usesAuth =}
Query<
{=/ usesAuth =}
[
{=# entities =}
{= internalTypeName =},
{=/ entities =}
],
Input,
Output
>
{=/ operations =}

View File

@ -1,42 +0,0 @@
{{={= =}=}}
import crypto from 'crypto'
import { Request, Response, NextFunction } from 'express'
import { readdir } from 'fs'
import { dirname } from 'path'
import { fileURLToPath } from 'url'
{=# isAuthEnabled =}
import { type AuthUser } from 'wasp/auth'
{=/ isAuthEnabled =}
type RequestWithExtraFields = Request & {
{=# isAuthEnabled =}
user?: AuthUser;
sessionId?: string;
{=/ isAuthEnabled =}
}
/**
* Decorator for async express middleware that handles promise rejections.
* @param {Func} middleware - Express middleware function.
* @returns Express middleware that is exactly the same as the given middleware but,
* if given middleware returns promise, reject of that promise will be correctly handled,
* meaning that error will be forwarded to next().
*/
export const handleRejection = (
middleware: (
req: RequestWithExtraFields,
res: Response,
next: NextFunction
) => any
) =>
async (req: RequestWithExtraFields, res: Response, next: NextFunction) => {
try {
await middleware(req, res, next)
} catch (error) {
next(error)
}
}
export const sleep = (ms: number): Promise<unknown> => new Promise((r) => setTimeout(r, ms))

View File

@ -190,13 +190,11 @@ waspBuild/.wasp/build/server/nodemon.json
waspBuild/.wasp/build/server/package.json
waspBuild/.wasp/build/server/rollup.config.js
waspBuild/.wasp/build/server/scripts/validate-env.mjs
waspBuild/.wasp/build/server/src/actions/types.ts
waspBuild/.wasp/build/server/src/app.js
waspBuild/.wasp/build/server/src/middleware/globalMiddleware.ts
waspBuild/.wasp/build/server/src/middleware/index.ts
waspBuild/.wasp/build/server/src/middleware/operations.ts
waspBuild/.wasp/build/server/src/polyfill.ts
waspBuild/.wasp/build/server/src/queries/types.ts
waspBuild/.wasp/build/server/src/routes/index.js
waspBuild/.wasp/build/server/src/routes/operations/index.js
waspBuild/.wasp/build/server/src/server.ts
@ -214,10 +212,8 @@ waspBuild/.wasp/build/web-app/public/.gitkeep
waspBuild/.wasp/build/web-app/public/favicon.ico
waspBuild/.wasp/build/web-app/public/manifest.json
waspBuild/.wasp/build/web-app/scripts/validate-env.mjs
waspBuild/.wasp/build/web-app/src/entities/index.ts
waspBuild/.wasp/build/web-app/src/index.tsx
waspBuild/.wasp/build/web-app/src/logo.png
waspBuild/.wasp/build/web-app/src/queryClient.js
waspBuild/.wasp/build/web-app/src/router.tsx
waspBuild/.wasp/build/web-app/src/test/vitest/setup.ts
waspBuild/.wasp/build/web-app/src/utils.js

View File

@ -426,13 +426,6 @@
],
"100177b4326ccab7362eff378315d532ad1cc17cd28d1ed5978cb167fd627746"
],
[
[
"file",
"server/src/actions/types.ts"
],
"cc03111599e32695d677e8ac4e65b98cf90e0cb066e71c3da06af254c784b489"
],
[
[
"file",
@ -468,13 +461,6 @@
],
"1149661e0aa7228b184bb2c04ac63232a6523b09b33829db6977f79daba3fd8d"
],
[
[
"file",
"server/src/queries/types.ts"
],
"19f72a3a37efd1e29b0793caa7f379494ad236bb513c8c8804b5a8d305c45196"
],
[
[
"file",
@ -573,13 +559,6 @@
],
"a9a3a7eb6bc3ead49d8e3850a70737c93c789098beb3b40196bf145fd38893cd"
],
[
[
"file",
"web-app/src/entities/index.ts"
],
"52d61b8ed11976d75b351d2b7227469697781fbf8996b5b98143e220ada383f9"
],
[
[
"file",
@ -594,13 +573,6 @@
],
"35f14abf46cb0e9d9b4e3d11961917eecb86be65a0d7f4e6bc9713c5766b5f1b"
],
[
[
"file",
"web-app/src/queryClient.js"
],
"1739d8618286b4a2aa536bd3fcb754514c828ec896b69c7074e22f66c07e7b03"
],
[
[
"file",

View File

@ -1,4 +0,0 @@
import {
type Payload,
} from 'wasp/server/_types'

View File

@ -1,5 +0,0 @@
import {
type Payload,
} from 'wasp/server/_types'

View File

@ -1,8 +0,0 @@
import {
} from '@prisma/client'
export type {
} from '@prisma/client'
export type Entity =
| never

View File

@ -1,23 +0,0 @@
import { QueryClient } from '@tanstack/react-query'
const defaultQueryClientConfig = {}
let queryClientConfig, resolveQueryClientInitialized, isQueryClientInitialized
export const queryClientInitialized = new Promise(resolve => {
resolveQueryClientInitialized = resolve
});
export function configureQueryClient(config) {
if (isQueryClientInitialized) {
throw new Error("Attempted to configure the QueryClient after initialization")
}
queryClientConfig = config
}
export function initializeQueryClient() {
const queryClient = new QueryClient(queryClientConfig ?? defaultQueryClientConfig)
isQueryClientInitialized = true;
resolveQueryClientInitialized(queryClient)
}

View File

@ -190,13 +190,11 @@ waspCompile/.wasp/out/server/nodemon.json
waspCompile/.wasp/out/server/package.json
waspCompile/.wasp/out/server/rollup.config.js
waspCompile/.wasp/out/server/scripts/validate-env.mjs
waspCompile/.wasp/out/server/src/actions/types.ts
waspCompile/.wasp/out/server/src/app.js
waspCompile/.wasp/out/server/src/middleware/globalMiddleware.ts
waspCompile/.wasp/out/server/src/middleware/index.ts
waspCompile/.wasp/out/server/src/middleware/operations.ts
waspCompile/.wasp/out/server/src/polyfill.ts
waspCompile/.wasp/out/server/src/queries/types.ts
waspCompile/.wasp/out/server/src/routes/index.js
waspCompile/.wasp/out/server/src/routes/operations/index.js
waspCompile/.wasp/out/server/src/server.ts
@ -211,10 +209,8 @@ waspCompile/.wasp/out/web-app/public/.gitkeep
waspCompile/.wasp/out/web-app/public/favicon.ico
waspCompile/.wasp/out/web-app/public/manifest.json
waspCompile/.wasp/out/web-app/scripts/validate-env.mjs
waspCompile/.wasp/out/web-app/src/entities/index.ts
waspCompile/.wasp/out/web-app/src/index.tsx
waspCompile/.wasp/out/web-app/src/logo.png
waspCompile/.wasp/out/web-app/src/queryClient.js
waspCompile/.wasp/out/web-app/src/router.tsx
waspCompile/.wasp/out/web-app/src/test/vitest/setup.ts
waspCompile/.wasp/out/web-app/src/utils.js

View File

@ -433,13 +433,6 @@
],
"100177b4326ccab7362eff378315d532ad1cc17cd28d1ed5978cb167fd627746"
],
[
[
"file",
"server/src/actions/types.ts"
],
"cc03111599e32695d677e8ac4e65b98cf90e0cb066e71c3da06af254c784b489"
],
[
[
"file",
@ -475,13 +468,6 @@
],
"1149661e0aa7228b184bb2c04ac63232a6523b09b33829db6977f79daba3fd8d"
],
[
[
"file",
"server/src/queries/types.ts"
],
"19f72a3a37efd1e29b0793caa7f379494ad236bb513c8c8804b5a8d305c45196"
],
[
[
"file",
@ -587,13 +573,6 @@
],
"a9a3a7eb6bc3ead49d8e3850a70737c93c789098beb3b40196bf145fd38893cd"
],
[
[
"file",
"web-app/src/entities/index.ts"
],
"52d61b8ed11976d75b351d2b7227469697781fbf8996b5b98143e220ada383f9"
],
[
[
"file",
@ -608,13 +587,6 @@
],
"35f14abf46cb0e9d9b4e3d11961917eecb86be65a0d7f4e6bc9713c5766b5f1b"
],
[
[
"file",
"web-app/src/queryClient.js"
],
"1739d8618286b4a2aa536bd3fcb754514c828ec896b69c7074e22f66c07e7b03"
],
[
[
"file",

View File

@ -1,4 +0,0 @@
import {
type Payload,
} from 'wasp/server/_types'

View File

@ -1,5 +0,0 @@
import {
type Payload,
} from 'wasp/server/_types'

View File

@ -1,8 +0,0 @@
import {
} from '@prisma/client'
export type {
} from '@prisma/client'
export type Entity =
| never

View File

@ -1,23 +0,0 @@
import { QueryClient } from '@tanstack/react-query'
const defaultQueryClientConfig = {}
let queryClientConfig, resolveQueryClientInitialized, isQueryClientInitialized
export const queryClientInitialized = new Promise(resolve => {
resolveQueryClientInitialized = resolve
});
export function configureQueryClient(config) {
if (isQueryClientInitialized) {
throw new Error("Attempted to configure the QueryClient after initialization")
}
queryClientConfig = config
}
export function initializeQueryClient() {
const queryClient = new QueryClient(queryClientConfig ?? defaultQueryClientConfig)
isQueryClientInitialized = true;
resolveQueryClientInitialized(queryClient)
}

View File

@ -417,7 +417,6 @@ waspComplexTest/.wasp/out/server/package.json
waspComplexTest/.wasp/out/server/rollup.config.js
waspComplexTest/.wasp/out/server/scripts/validate-env.mjs
waspComplexTest/.wasp/out/server/src/actions/mySpecialAction.ts
waspComplexTest/.wasp/out/server/src/actions/types.ts
waspComplexTest/.wasp/out/server/src/app.js
waspComplexTest/.wasp/out/server/src/auth/providers/config/google.ts
waspComplexTest/.wasp/out/server/src/auth/providers/index.ts
@ -439,7 +438,6 @@ waspComplexTest/.wasp/out/server/src/middleware/index.ts
waspComplexTest/.wasp/out/server/src/middleware/operations.ts
waspComplexTest/.wasp/out/server/src/polyfill.ts
waspComplexTest/.wasp/out/server/src/queries/mySpecialQuery.ts
waspComplexTest/.wasp/out/server/src/queries/types.ts
waspComplexTest/.wasp/out/server/src/routes/apis/index.ts
waspComplexTest/.wasp/out/server/src/routes/auth/index.js
waspComplexTest/.wasp/out/server/src/routes/auth/logout.ts
@ -464,10 +462,8 @@ waspComplexTest/.wasp/out/web-app/public/manifest.json
waspComplexTest/.wasp/out/web-app/scripts/validate-env.mjs
waspComplexTest/.wasp/out/web-app/src/auth/pages/OAuthCallback.tsx
waspComplexTest/.wasp/out/web-app/src/auth/pages/createAuthRequiredPage.jsx
waspComplexTest/.wasp/out/web-app/src/entities/index.ts
waspComplexTest/.wasp/out/web-app/src/index.tsx
waspComplexTest/.wasp/out/web-app/src/logo.png
waspComplexTest/.wasp/out/web-app/src/queryClient.js
waspComplexTest/.wasp/out/web-app/src/router.tsx
waspComplexTest/.wasp/out/web-app/src/test/vitest/setup.ts
waspComplexTest/.wasp/out/web-app/src/utils.js

View File

@ -832,13 +832,6 @@
],
"d306e32442616e08a6a2bbf4fce881a983d5db12b6de648313a83e362dcc552a"
],
[
[
"file",
"server/src/actions/types.ts"
],
"a589183e85ac3cf0dca3011e3cdf1d59e28b03cc38b3fb6e4e57008ac1c8d66b"
],
[
[
"file",
@ -986,13 +979,6 @@
],
"4f907aed444b1778b919bb2021a44a53f2282d238e65e843670d2e786a623a71"
],
[
[
"file",
"server/src/queries/types.ts"
],
"66c2b2bc17cf6042948123ee3995c07cad5d92e61394596a3a817a497d469c97"
],
[
[
"file",
@ -1168,13 +1154,6 @@
],
"04ca0c6aa20114998fb60080474026d80b9efbb7fc3cbe29f86a5ecab2300b05"
],
[
[
"file",
"web-app/src/entities/index.ts"
],
"f3daa2f99b1ead27d95ef05fbd493c26b697a4c6d413432a1959d41e4cb205a2"
],
[
[
"file",
@ -1189,13 +1168,6 @@
],
"35f14abf46cb0e9d9b4e3d11961917eecb86be65a0d7f4e6bc9713c5766b5f1b"
],
[
[
"file",
"web-app/src/queryClient.js"
],
"1739d8618286b4a2aa536bd3fcb754514c828ec896b69c7074e22f66c07e7b03"
],
[
[
"file",

View File

@ -1,15 +0,0 @@
import {
type _User,
type AuthenticatedAction,
type Payload,
} from 'wasp/server/_types'
export type MySpecialAction<Input extends Payload = never, Output extends Payload = Payload> =
AuthenticatedAction<
[
_User,
],
Input,
Output
>

View File

@ -1,16 +0,0 @@
import {
type _User,
type AuthenticatedQuery,
type Payload,
} from 'wasp/server/_types'
export type MySpecialQuery<Input extends Payload = never, Output extends Payload = Payload> =
AuthenticatedQuery<
[
_User,
],
Input,
Output
>

View File

@ -1,19 +0,0 @@
import {
User,
SocialLogin,
Task,
} from '@prisma/client'
export type {
User,
SocialLogin,
Task,
Auth,
AuthIdentity,
} from '@prisma/client'
export type Entity =
| User
| SocialLogin
| Task
| never

View File

@ -1,23 +0,0 @@
import { QueryClient } from '@tanstack/react-query'
const defaultQueryClientConfig = {}
let queryClientConfig, resolveQueryClientInitialized, isQueryClientInitialized
export const queryClientInitialized = new Promise(resolve => {
resolveQueryClientInitialized = resolve
});
export function configureQueryClient(config) {
if (isQueryClientInitialized) {
throw new Error("Attempted to configure the QueryClient after initialization")
}
queryClientConfig = config
}
export function initializeQueryClient() {
const queryClient = new QueryClient(queryClientConfig ?? defaultQueryClientConfig)
isQueryClientInitialized = true;
resolveQueryClientInitialized(queryClient)
}

View File

@ -223,7 +223,6 @@ waspJob/.wasp/out/server/nodemon.json
waspJob/.wasp/out/server/package.json
waspJob/.wasp/out/server/rollup.config.js
waspJob/.wasp/out/server/scripts/validate-env.mjs
waspJob/.wasp/out/server/src/actions/types.ts
waspJob/.wasp/out/server/src/app.js
waspJob/.wasp/out/server/src/jobs/core/allJobs.ts
waspJob/.wasp/out/server/src/jobs/mySpecialJob.ts
@ -231,7 +230,6 @@ waspJob/.wasp/out/server/src/middleware/globalMiddleware.ts
waspJob/.wasp/out/server/src/middleware/index.ts
waspJob/.wasp/out/server/src/middleware/operations.ts
waspJob/.wasp/out/server/src/polyfill.ts
waspJob/.wasp/out/server/src/queries/types.ts
waspJob/.wasp/out/server/src/routes/index.js
waspJob/.wasp/out/server/src/routes/operations/index.js
waspJob/.wasp/out/server/src/server.ts
@ -246,10 +244,8 @@ waspJob/.wasp/out/web-app/public/.gitkeep
waspJob/.wasp/out/web-app/public/favicon.ico
waspJob/.wasp/out/web-app/public/manifest.json
waspJob/.wasp/out/web-app/scripts/validate-env.mjs
waspJob/.wasp/out/web-app/src/entities/index.ts
waspJob/.wasp/out/web-app/src/index.tsx
waspJob/.wasp/out/web-app/src/logo.png
waspJob/.wasp/out/web-app/src/queryClient.js
waspJob/.wasp/out/web-app/src/router.tsx
waspJob/.wasp/out/web-app/src/test/vitest/setup.ts
waspJob/.wasp/out/web-app/src/utils.js

View File

@ -489,13 +489,6 @@
],
"100177b4326ccab7362eff378315d532ad1cc17cd28d1ed5978cb167fd627746"
],
[
[
"file",
"server/src/actions/types.ts"
],
"cc03111599e32695d677e8ac4e65b98cf90e0cb066e71c3da06af254c784b489"
],
[
[
"file",
@ -545,13 +538,6 @@
],
"1149661e0aa7228b184bb2c04ac63232a6523b09b33829db6977f79daba3fd8d"
],
[
[
"file",
"server/src/queries/types.ts"
],
"19f72a3a37efd1e29b0793caa7f379494ad236bb513c8c8804b5a8d305c45196"
],
[
[
"file",
@ -657,13 +643,6 @@
],
"a9a3a7eb6bc3ead49d8e3850a70737c93c789098beb3b40196bf145fd38893cd"
],
[
[
"file",
"web-app/src/entities/index.ts"
],
"52d61b8ed11976d75b351d2b7227469697781fbf8996b5b98143e220ada383f9"
],
[
[
"file",
@ -678,13 +657,6 @@
],
"35f14abf46cb0e9d9b4e3d11961917eecb86be65a0d7f4e6bc9713c5766b5f1b"
],
[
[
"file",
"web-app/src/queryClient.js"
],
"1739d8618286b4a2aa536bd3fcb754514c828ec896b69c7074e22f66c07e7b03"
],
[
[
"file",

View File

@ -1,4 +0,0 @@
import {
type Payload,
} from 'wasp/server/_types'

View File

@ -1,5 +0,0 @@
import {
type Payload,
} from 'wasp/server/_types'

View File

@ -1,8 +0,0 @@
import {
} from '@prisma/client'
export type {
} from '@prisma/client'
export type Entity =
| never

View File

@ -1,23 +0,0 @@
import { QueryClient } from '@tanstack/react-query'
const defaultQueryClientConfig = {}
let queryClientConfig, resolveQueryClientInitialized, isQueryClientInitialized
export const queryClientInitialized = new Promise(resolve => {
resolveQueryClientInitialized = resolve
});
export function configureQueryClient(config) {
if (isQueryClientInitialized) {
throw new Error("Attempted to configure the QueryClient after initialization")
}
queryClientConfig = config
}
export function initializeQueryClient() {
const queryClient = new QueryClient(queryClientConfig ?? defaultQueryClientConfig)
isQueryClientInitialized = true;
resolveQueryClientInitialized(queryClient)
}

View File

@ -194,13 +194,11 @@ waspMigrate/.wasp/out/server/nodemon.json
waspMigrate/.wasp/out/server/package.json
waspMigrate/.wasp/out/server/rollup.config.js
waspMigrate/.wasp/out/server/scripts/validate-env.mjs
waspMigrate/.wasp/out/server/src/actions/types.ts
waspMigrate/.wasp/out/server/src/app.js
waspMigrate/.wasp/out/server/src/middleware/globalMiddleware.ts
waspMigrate/.wasp/out/server/src/middleware/index.ts
waspMigrate/.wasp/out/server/src/middleware/operations.ts
waspMigrate/.wasp/out/server/src/polyfill.ts
waspMigrate/.wasp/out/server/src/queries/types.ts
waspMigrate/.wasp/out/server/src/routes/index.js
waspMigrate/.wasp/out/server/src/routes/operations/index.js
waspMigrate/.wasp/out/server/src/server.ts
@ -215,10 +213,8 @@ waspMigrate/.wasp/out/web-app/public/.gitkeep
waspMigrate/.wasp/out/web-app/public/favicon.ico
waspMigrate/.wasp/out/web-app/public/manifest.json
waspMigrate/.wasp/out/web-app/scripts/validate-env.mjs
waspMigrate/.wasp/out/web-app/src/entities/index.ts
waspMigrate/.wasp/out/web-app/src/index.tsx
waspMigrate/.wasp/out/web-app/src/logo.png
waspMigrate/.wasp/out/web-app/src/queryClient.js
waspMigrate/.wasp/out/web-app/src/router.tsx
waspMigrate/.wasp/out/web-app/src/test/vitest/setup.ts
waspMigrate/.wasp/out/web-app/src/utils.js

View File

@ -433,13 +433,6 @@
],
"100177b4326ccab7362eff378315d532ad1cc17cd28d1ed5978cb167fd627746"
],
[
[
"file",
"server/src/actions/types.ts"
],
"cc03111599e32695d677e8ac4e65b98cf90e0cb066e71c3da06af254c784b489"
],
[
[
"file",
@ -475,13 +468,6 @@
],
"1149661e0aa7228b184bb2c04ac63232a6523b09b33829db6977f79daba3fd8d"
],
[
[
"file",
"server/src/queries/types.ts"
],
"19f72a3a37efd1e29b0793caa7f379494ad236bb513c8c8804b5a8d305c45196"
],
[
[
"file",
@ -587,13 +573,6 @@
],
"a9a3a7eb6bc3ead49d8e3850a70737c93c789098beb3b40196bf145fd38893cd"
],
[
[
"file",
"web-app/src/entities/index.ts"
],
"cfb888ebcfafcc416b6e7d583081053d3fa2aa8b7be7d4e21d5f547e731d2467"
],
[
[
"file",
@ -608,13 +587,6 @@
],
"35f14abf46cb0e9d9b4e3d11961917eecb86be65a0d7f4e6bc9713c5766b5f1b"
],
[
[
"file",
"web-app/src/queryClient.js"
],
"1739d8618286b4a2aa536bd3fcb754514c828ec896b69c7074e22f66c07e7b03"
],
[
[
"file",

View File

@ -1,4 +0,0 @@
import {
type Payload,
} from 'wasp/server/_types'

View File

@ -1,5 +0,0 @@
import {
type Payload,
} from 'wasp/server/_types'

View File

@ -1,11 +0,0 @@
import {
Task,
} from '@prisma/client'
export type {
Task,
} from '@prisma/client'
export type Entity =
| Task
| never

View File

@ -1,23 +0,0 @@
import { QueryClient } from '@tanstack/react-query'
const defaultQueryClientConfig = {}
let queryClientConfig, resolveQueryClientInitialized, isQueryClientInitialized
export const queryClientInitialized = new Promise(resolve => {
resolveQueryClientInitialized = resolve
});
export function configureQueryClient(config) {
if (isQueryClientInitialized) {
throw new Error("Attempted to configure the QueryClient after initialization")
}
queryClientConfig = config
}
export function initializeQueryClient() {
const queryClient = new QueryClient(queryClientConfig ?? defaultQueryClientConfig)
isQueryClientInitialized = true;
resolveQueryClientInitialized(queryClient)
}

View File

@ -10,8 +10,7 @@ where
import Data.Aeson (object, (.=))
import qualified Data.Aeson as Aeson
import Data.List (nub)
import Data.Maybe (fromJust, fromMaybe)
import Data.Maybe (fromJust)
import StrongPath (Dir, File', Path, Path', Posix, Rel, reldir, reldirP, relfile, (</>))
import qualified StrongPath as SP
import Wasp.AppSpec (AppSpec)
@ -20,8 +19,7 @@ import qualified Wasp.AppSpec.Action as AS.Action
import Wasp.AppSpec.Operation (getName)
import qualified Wasp.AppSpec.Operation as AS.Operation
import qualified Wasp.AppSpec.Query as AS.Query
import Wasp.AppSpec.Valid (isAuthEnabled)
import Wasp.Generator.Common (ServerRootDir, makeJsonWithEntityData)
import Wasp.Generator.Common (makeJsonWithEntityData)
import Wasp.Generator.FileDraft (FileDraft)
import Wasp.Generator.Monad (Generator)
import qualified Wasp.Generator.ServerGenerator.Common as C
@ -30,11 +28,7 @@ import Wasp.Util (toUpperFirst, (<++>))
genOperations :: AppSpec -> Generator [FileDraft]
genOperations spec =
sequence
[ genQueryTypesFile spec,
genActionTypesFile spec
]
<++> genQueries spec
genQueries spec
<++> genActions spec
genQueries :: AppSpec -> Generator [FileDraft]
@ -43,22 +37,6 @@ genQueries = mapM genQuery . AS.getQueries
genActions :: AppSpec -> Generator [FileDraft]
genActions = mapM genAction . AS.getActions
genQueryTypesFile :: AppSpec -> Generator FileDraft
genQueryTypesFile spec = genOperationTypesFile tmplFile dstFile operations isAuthEnabledGlobally
where
tmplFile = [relfile|src/queries/types.ts|]
dstFile = [relfile|src/queries/types.ts|]
operations = map (uncurry AS.Operation.QueryOp) $ AS.getQueries spec
isAuthEnabledGlobally = isAuthEnabled spec
genActionTypesFile :: AppSpec -> Generator FileDraft
genActionTypesFile spec = genOperationTypesFile tmplFile dstFile operations isAuthEnabledGlobally
where
tmplFile = [relfile|src/actions/types.ts|]
dstFile = [relfile|src/actions/types.ts|]
operations = map (uncurry AS.Operation.ActionOp) $ AS.getActions spec
isAuthEnabledGlobally = isAuthEnabled spec
-- | Here we generate JS file that basically imports JS query function provided by user,
-- decorates it (mostly injects stuff into it) and exports. Idea is that the rest of the server,
-- and user also, should use this new JS function, and not the old one directly.
@ -70,31 +48,6 @@ genQuery (queryName, query) = return $ C.mkTmplFdWithDstAndData tmplFile dstFile
dstFile = C.serverSrcDirInServerRootDir </> queryFileInSrcDir queryName
tmplData = operationTmplData operation
genOperationTypesFile ::
Path' (Rel C.ServerTemplatesDir) File' ->
Path' (Rel ServerRootDir) File' ->
[AS.Operation.Operation] ->
Bool ->
Generator FileDraft
genOperationTypesFile tmplFile dstFile operations isAuthEnabledGlobally =
return $ C.mkTmplFdWithDstAndData tmplFile dstFile (Just tmplData)
where
tmplData =
object
[ "operations" .= map operationTypeData operations,
"shouldImportAuthenticatedOperation" .= any usesAuth operations,
"shouldImportNonAuthenticatedOperation" .= not (all usesAuth operations),
"allEntities" .= nub (concatMap getEntities operations)
]
operationTypeData operation =
object
[ "typeName" .= toUpperFirst (getName operation),
"entities" .= getEntities operation,
"usesAuth" .= usesAuth operation
]
getEntities = map makeJsonWithEntityData . maybe [] (map AS.refName) . AS.Operation.getEntities
usesAuth = fromMaybe isAuthEnabledGlobally . AS.Operation.getAuth
-- | Analogous to genQuery.
genAction :: (String, AS.Action.Action) -> Generator FileDraft
genAction (actionName, action) = return $ C.mkTmplFdWithDstAndData tmplFile dstFile (Just tmplData)

View File

@ -8,7 +8,7 @@ where
import Data.Aeson (object, (.=))
import Data.List (intercalate)
import Data.Maybe (fromJust, isJust)
import Data.Maybe (fromJust)
import qualified FilePath.Extra as FP.Extra
import StrongPath
( Dir,
@ -26,17 +26,13 @@ import qualified System.FilePath.Posix as FP.Posix
import Wasp.AppSpec (AppSpec)
import qualified Wasp.AppSpec as AS
import qualified Wasp.AppSpec.App as AS.App
import qualified Wasp.AppSpec.App.Auth as AS.App.Auth
import qualified Wasp.AppSpec.App.Client as AS.App.Client
import qualified Wasp.AppSpec.App.Dependency as AS.Dependency
import qualified Wasp.AppSpec.Entity as AS.Entity
import Wasp.AppSpec.Valid (getApp)
import Wasp.Env (envVarsToDotEnvContent)
import Wasp.Generator.Common
( makeJsArrayFromHaskellList,
makeJsonWithEntityData,
)
import qualified Wasp.Generator.DbGenerator.Auth as DbAuth
import Wasp.Generator.FileDraft (FileDraft, createTextFileDraft)
import qualified Wasp.Generator.FileDraft as FD
import Wasp.Generator.JsImport (jsImportToImportJson)
@ -197,35 +193,15 @@ genSrcDir :: AppSpec -> Generator [FileDraft]
genSrcDir spec =
sequence
[ genFileCopy [relfile|logo.png|],
genFileCopy [relfile|queryClient.js|],
genFileCopy [relfile|utils.js|],
genFileCopy [relfile|vite-env.d.ts|],
getIndexTs spec
]
<++> genEntitiesDir spec
<++> genAuth spec
<++> genRouter spec
where
genFileCopy = return . C.mkSrcTmplFd
genEntitiesDir :: AppSpec -> Generator [FileDraft]
genEntitiesDir spec = return [entitiesIndexFileDraft]
where
entitiesIndexFileDraft =
C.mkTmplFdWithDstAndData
[relfile|src/entities/index.ts|]
[relfile|src/entities/index.ts|]
( Just $
object
[ "entities" .= allEntities,
"isAuthEnabled" .= isJust maybeUserEntityName,
"authEntityName" .= DbAuth.authEntityName,
"authIdentityEntityName" .= DbAuth.authIdentityEntityName
]
)
allEntities = map (makeJsonWithEntityData . fst) $ AS.getDecls @AS.Entity.Entity spec
maybeUserEntityName = AS.refName . AS.App.Auth.userEntity <$> AS.App.auth (snd $ getApp spec)
getIndexTs :: AppSpec -> Generator FileDraft
getIndexTs spec =
return $