prisma-trpc-generator
Version:
Prisma 2+ generator to emit fully implemented tRPC routers
53 lines • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.configSchema = void 0;
const zod_1 = require("zod");
const configBoolean = zod_1.z
.enum(['true', 'false'])
.transform((arg) => JSON.parse(arg));
const configMiddleware = zod_1.z.union([
configBoolean,
zod_1.z.string().default('../../../../src/middleware'),
]);
const configShield = zod_1.z.union([
configBoolean,
zod_1.z.string().default('../../../../src/shield'),
]);
// Define model actions directly since DMMF.ModelAction is not available at runtime
const ModelAction = {
findFirst: 'findFirst',
findFirstOrThrow: 'findFirstOrThrow',
findMany: 'findMany',
findUnique: 'findUnique',
findUniqueOrThrow: 'findUniqueOrThrow',
create: 'create',
createMany: 'createMany',
update: 'update',
updateMany: 'updateMany',
upsert: 'upsert',
delete: 'delete',
deleteMany: 'deleteMany',
aggregate: 'aggregate',
groupBy: 'groupBy',
count: 'count',
findRaw: 'findRaw',
aggregateRaw: 'aggregateRaw'
};
const modelActionEnum = zod_1.z.nativeEnum(ModelAction);
exports.configSchema = zod_1.z.object({
withMiddleware: configMiddleware.default('true'),
withShield: configShield.default('true'),
withZod: configBoolean.default('true'),
contextPath: zod_1.z.string().default('../../../../src/context'),
trpcOptionsPath: zod_1.z.string().optional(),
showModelNameInProcedure: configBoolean.default('true'),
generateModelActions: zod_1.z
.string()
.default(Object.values(ModelAction).join(','))
.transform((arg) => {
return arg
.split(',')
.map((action) => modelActionEnum.parse(action.trim()));
}),
});
//# sourceMappingURL=config.js.map