@stryke/prisma-trpc-generator 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generator.cjs +23 -2
- package/dist/generator.js +23 -2
- package/dist/index.cjs +23 -2
- package/dist/index.js +23 -2
- package/package.json +1 -1
package/dist/generator.cjs
CHANGED
|
@@ -6256,7 +6256,12 @@ async function generate(options) {
|
|
|
6256
6256
|
} else {
|
|
6257
6257
|
consoleLog("Skipping tRPC Shield generation");
|
|
6258
6258
|
}
|
|
6259
|
+
consoleLog("Finding Prisma Client generator");
|
|
6259
6260
|
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
6261
|
+
if (!prismaClientProvider) {
|
|
6262
|
+
throw new Error("No Prisma Client generator found. Please add `prisma-client-js` to your generator list.");
|
|
6263
|
+
}
|
|
6264
|
+
consoleLog("Generating Prisma Client DMMF");
|
|
6260
6265
|
const prismaClientDmmf = await internals.getDMMF({
|
|
6261
6266
|
datamodel: options.datamodel,
|
|
6262
6267
|
previewFeatures: prismaClientProvider?.previewFeatures
|
|
@@ -6264,14 +6269,17 @@ async function generate(options) {
|
|
|
6264
6269
|
const modelOperations = prismaClientDmmf.mappings.modelOperations;
|
|
6265
6270
|
const models = prismaClientDmmf.datamodel.models;
|
|
6266
6271
|
const hiddenModels = [];
|
|
6272
|
+
consoleLog(`Generating tRPC source code for ${models.length} models`);
|
|
6267
6273
|
resolveModelsComments(models, hiddenModels);
|
|
6268
6274
|
const createRouter = project.createSourceFile(import_node_path7.default.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
|
|
6269
6275
|
overwrite: true
|
|
6270
6276
|
});
|
|
6277
|
+
consoleLog("Generating tRPC imports");
|
|
6271
6278
|
generateRPCImport(createRouter);
|
|
6272
6279
|
if (config.withShield) {
|
|
6273
6280
|
await generateShieldImport(createRouter, options, config.withShield);
|
|
6274
6281
|
}
|
|
6282
|
+
consoleLog("Generating tRPC base router");
|
|
6275
6283
|
await generateBaseRouter(createRouter, config, options);
|
|
6276
6284
|
createRouter.formatText({
|
|
6277
6285
|
indentSize: 2
|
|
@@ -6279,16 +6287,24 @@ async function generate(options) {
|
|
|
6279
6287
|
const appRouter = project.createSourceFile(import_node_path7.default.resolve(outputDir, "routers", `index.ts`), void 0, {
|
|
6280
6288
|
overwrite: true
|
|
6281
6289
|
});
|
|
6290
|
+
consoleLog("Generating tRPC router imports");
|
|
6282
6291
|
generateCreateRouterImport({
|
|
6283
6292
|
sourceFile: appRouter
|
|
6284
6293
|
});
|
|
6285
6294
|
const routerStatements = [];
|
|
6286
6295
|
for (const modelOperation of modelOperations) {
|
|
6287
6296
|
const { model, ...operations } = modelOperation;
|
|
6288
|
-
if (hiddenModels.includes(model))
|
|
6297
|
+
if (hiddenModels.includes(model)) {
|
|
6298
|
+
consoleLog(`Skipping model ${model} as it is hidden`);
|
|
6299
|
+
continue;
|
|
6300
|
+
}
|
|
6289
6301
|
const modelActions = Object.keys(operations).filter((opType) => config.generateModelActions.includes(opType.replace("One", "")));
|
|
6290
|
-
if (!modelActions.length)
|
|
6302
|
+
if (!modelActions.length) {
|
|
6303
|
+
consoleLog(`Skipping model ${model} as it has no actions to generate`);
|
|
6304
|
+
continue;
|
|
6305
|
+
}
|
|
6291
6306
|
const plural = (0, import_pluralize.default)(model.toLowerCase());
|
|
6307
|
+
consoleLog(`Generating tRPC router for model ${model}`);
|
|
6292
6308
|
generateRouterImport(appRouter, plural, model);
|
|
6293
6309
|
const modelRouter = project.createSourceFile(import_node_path7.default.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
|
|
6294
6310
|
overwrite: true
|
|
@@ -6298,6 +6314,7 @@ async function generate(options) {
|
|
|
6298
6314
|
config
|
|
6299
6315
|
});
|
|
6300
6316
|
if (config.withZod) {
|
|
6317
|
+
consoleLog("Generating Zod schemas imports");
|
|
6301
6318
|
generateRouterSchemaImports(modelRouter, model, modelActions);
|
|
6302
6319
|
}
|
|
6303
6320
|
modelRouter.addStatements(
|
|
@@ -6323,7 +6340,9 @@ async function generate(options) {
|
|
|
6323
6340
|
`
|
|
6324
6341
|
${model.toLowerCase()}: ${plural}Router`
|
|
6325
6342
|
);
|
|
6343
|
+
consoleLog(`Generated tRPC router for model ${model} with ${modelActions.length} actions`);
|
|
6326
6344
|
}
|
|
6345
|
+
consoleLog("Generating tRPC app router");
|
|
6327
6346
|
appRouter.addStatements(
|
|
6328
6347
|
/* ts */
|
|
6329
6348
|
`
|
|
@@ -6333,7 +6352,9 @@ async function generate(options) {
|
|
|
6333
6352
|
appRouter.formatText({
|
|
6334
6353
|
indentSize: 2
|
|
6335
6354
|
});
|
|
6355
|
+
consoleLog("Saving tRPC router source files to disk");
|
|
6336
6356
|
await project.save();
|
|
6357
|
+
consoleLog("Storm Software - Prisma tRPC generator completed successfully");
|
|
6337
6358
|
}
|
|
6338
6359
|
__name(generate, "generate");
|
|
6339
6360
|
|
package/dist/generator.js
CHANGED
|
@@ -6261,7 +6261,12 @@ async function generate(options) {
|
|
|
6261
6261
|
} else {
|
|
6262
6262
|
consoleLog("Skipping tRPC Shield generation");
|
|
6263
6263
|
}
|
|
6264
|
+
consoleLog("Finding Prisma Client generator");
|
|
6264
6265
|
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
6266
|
+
if (!prismaClientProvider) {
|
|
6267
|
+
throw new Error("No Prisma Client generator found. Please add `prisma-client-js` to your generator list.");
|
|
6268
|
+
}
|
|
6269
|
+
consoleLog("Generating Prisma Client DMMF");
|
|
6265
6270
|
const prismaClientDmmf = await internals.getDMMF({
|
|
6266
6271
|
datamodel: options.datamodel,
|
|
6267
6272
|
previewFeatures: prismaClientProvider?.previewFeatures
|
|
@@ -6269,14 +6274,17 @@ async function generate(options) {
|
|
|
6269
6274
|
const modelOperations = prismaClientDmmf.mappings.modelOperations;
|
|
6270
6275
|
const models = prismaClientDmmf.datamodel.models;
|
|
6271
6276
|
const hiddenModels = [];
|
|
6277
|
+
consoleLog(`Generating tRPC source code for ${models.length} models`);
|
|
6272
6278
|
resolveModelsComments(models, hiddenModels);
|
|
6273
6279
|
const createRouter = project.createSourceFile(path6.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
|
|
6274
6280
|
overwrite: true
|
|
6275
6281
|
});
|
|
6282
|
+
consoleLog("Generating tRPC imports");
|
|
6276
6283
|
generateRPCImport(createRouter);
|
|
6277
6284
|
if (config.withShield) {
|
|
6278
6285
|
await generateShieldImport(createRouter, options, config.withShield);
|
|
6279
6286
|
}
|
|
6287
|
+
consoleLog("Generating tRPC base router");
|
|
6280
6288
|
await generateBaseRouter(createRouter, config, options);
|
|
6281
6289
|
createRouter.formatText({
|
|
6282
6290
|
indentSize: 2
|
|
@@ -6284,16 +6292,24 @@ async function generate(options) {
|
|
|
6284
6292
|
const appRouter = project.createSourceFile(path6.resolve(outputDir, "routers", `index.ts`), void 0, {
|
|
6285
6293
|
overwrite: true
|
|
6286
6294
|
});
|
|
6295
|
+
consoleLog("Generating tRPC router imports");
|
|
6287
6296
|
generateCreateRouterImport({
|
|
6288
6297
|
sourceFile: appRouter
|
|
6289
6298
|
});
|
|
6290
6299
|
const routerStatements = [];
|
|
6291
6300
|
for (const modelOperation of modelOperations) {
|
|
6292
6301
|
const { model, ...operations } = modelOperation;
|
|
6293
|
-
if (hiddenModels.includes(model))
|
|
6302
|
+
if (hiddenModels.includes(model)) {
|
|
6303
|
+
consoleLog(`Skipping model ${model} as it is hidden`);
|
|
6304
|
+
continue;
|
|
6305
|
+
}
|
|
6294
6306
|
const modelActions = Object.keys(operations).filter((opType) => config.generateModelActions.includes(opType.replace("One", "")));
|
|
6295
|
-
if (!modelActions.length)
|
|
6307
|
+
if (!modelActions.length) {
|
|
6308
|
+
consoleLog(`Skipping model ${model} as it has no actions to generate`);
|
|
6309
|
+
continue;
|
|
6310
|
+
}
|
|
6296
6311
|
const plural = (0, import_pluralize.default)(model.toLowerCase());
|
|
6312
|
+
consoleLog(`Generating tRPC router for model ${model}`);
|
|
6297
6313
|
generateRouterImport(appRouter, plural, model);
|
|
6298
6314
|
const modelRouter = project.createSourceFile(path6.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
|
|
6299
6315
|
overwrite: true
|
|
@@ -6303,6 +6319,7 @@ async function generate(options) {
|
|
|
6303
6319
|
config
|
|
6304
6320
|
});
|
|
6305
6321
|
if (config.withZod) {
|
|
6322
|
+
consoleLog("Generating Zod schemas imports");
|
|
6306
6323
|
generateRouterSchemaImports(modelRouter, model, modelActions);
|
|
6307
6324
|
}
|
|
6308
6325
|
modelRouter.addStatements(
|
|
@@ -6328,7 +6345,9 @@ async function generate(options) {
|
|
|
6328
6345
|
`
|
|
6329
6346
|
${model.toLowerCase()}: ${plural}Router`
|
|
6330
6347
|
);
|
|
6348
|
+
consoleLog(`Generated tRPC router for model ${model} with ${modelActions.length} actions`);
|
|
6331
6349
|
}
|
|
6350
|
+
consoleLog("Generating tRPC app router");
|
|
6332
6351
|
appRouter.addStatements(
|
|
6333
6352
|
/* ts */
|
|
6334
6353
|
`
|
|
@@ -6338,7 +6357,9 @@ async function generate(options) {
|
|
|
6338
6357
|
appRouter.formatText({
|
|
6339
6358
|
indentSize: 2
|
|
6340
6359
|
});
|
|
6360
|
+
consoleLog("Saving tRPC router source files to disk");
|
|
6341
6361
|
await project.save();
|
|
6362
|
+
consoleLog("Storm Software - Prisma tRPC generator completed successfully");
|
|
6342
6363
|
}
|
|
6343
6364
|
__name(generate, "generate");
|
|
6344
6365
|
|
package/dist/index.cjs
CHANGED
|
@@ -6252,7 +6252,12 @@ async function generate(options) {
|
|
|
6252
6252
|
} else {
|
|
6253
6253
|
consoleLog("Skipping tRPC Shield generation");
|
|
6254
6254
|
}
|
|
6255
|
+
consoleLog("Finding Prisma Client generator");
|
|
6255
6256
|
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
6257
|
+
if (!prismaClientProvider) {
|
|
6258
|
+
throw new Error("No Prisma Client generator found. Please add `prisma-client-js` to your generator list.");
|
|
6259
|
+
}
|
|
6260
|
+
consoleLog("Generating Prisma Client DMMF");
|
|
6256
6261
|
const prismaClientDmmf = await internals.getDMMF({
|
|
6257
6262
|
datamodel: options.datamodel,
|
|
6258
6263
|
previewFeatures: prismaClientProvider?.previewFeatures
|
|
@@ -6260,14 +6265,17 @@ async function generate(options) {
|
|
|
6260
6265
|
const modelOperations = prismaClientDmmf.mappings.modelOperations;
|
|
6261
6266
|
const models = prismaClientDmmf.datamodel.models;
|
|
6262
6267
|
const hiddenModels = [];
|
|
6268
|
+
consoleLog(`Generating tRPC source code for ${models.length} models`);
|
|
6263
6269
|
resolveModelsComments(models, hiddenModels);
|
|
6264
6270
|
const createRouter = project.createSourceFile(import_node_path7.default.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
|
|
6265
6271
|
overwrite: true
|
|
6266
6272
|
});
|
|
6273
|
+
consoleLog("Generating tRPC imports");
|
|
6267
6274
|
generateRPCImport(createRouter);
|
|
6268
6275
|
if (config.withShield) {
|
|
6269
6276
|
await generateShieldImport(createRouter, options, config.withShield);
|
|
6270
6277
|
}
|
|
6278
|
+
consoleLog("Generating tRPC base router");
|
|
6271
6279
|
await generateBaseRouter(createRouter, config, options);
|
|
6272
6280
|
createRouter.formatText({
|
|
6273
6281
|
indentSize: 2
|
|
@@ -6275,16 +6283,24 @@ async function generate(options) {
|
|
|
6275
6283
|
const appRouter = project.createSourceFile(import_node_path7.default.resolve(outputDir, "routers", `index.ts`), void 0, {
|
|
6276
6284
|
overwrite: true
|
|
6277
6285
|
});
|
|
6286
|
+
consoleLog("Generating tRPC router imports");
|
|
6278
6287
|
generateCreateRouterImport({
|
|
6279
6288
|
sourceFile: appRouter
|
|
6280
6289
|
});
|
|
6281
6290
|
const routerStatements = [];
|
|
6282
6291
|
for (const modelOperation of modelOperations) {
|
|
6283
6292
|
const { model, ...operations } = modelOperation;
|
|
6284
|
-
if (hiddenModels.includes(model))
|
|
6293
|
+
if (hiddenModels.includes(model)) {
|
|
6294
|
+
consoleLog(`Skipping model ${model} as it is hidden`);
|
|
6295
|
+
continue;
|
|
6296
|
+
}
|
|
6285
6297
|
const modelActions = Object.keys(operations).filter((opType) => config.generateModelActions.includes(opType.replace("One", "")));
|
|
6286
|
-
if (!modelActions.length)
|
|
6298
|
+
if (!modelActions.length) {
|
|
6299
|
+
consoleLog(`Skipping model ${model} as it has no actions to generate`);
|
|
6300
|
+
continue;
|
|
6301
|
+
}
|
|
6287
6302
|
const plural = (0, import_pluralize.default)(model.toLowerCase());
|
|
6303
|
+
consoleLog(`Generating tRPC router for model ${model}`);
|
|
6288
6304
|
generateRouterImport(appRouter, plural, model);
|
|
6289
6305
|
const modelRouter = project.createSourceFile(import_node_path7.default.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
|
|
6290
6306
|
overwrite: true
|
|
@@ -6294,6 +6310,7 @@ async function generate(options) {
|
|
|
6294
6310
|
config
|
|
6295
6311
|
});
|
|
6296
6312
|
if (config.withZod) {
|
|
6313
|
+
consoleLog("Generating Zod schemas imports");
|
|
6297
6314
|
generateRouterSchemaImports(modelRouter, model, modelActions);
|
|
6298
6315
|
}
|
|
6299
6316
|
modelRouter.addStatements(
|
|
@@ -6319,7 +6336,9 @@ async function generate(options) {
|
|
|
6319
6336
|
`
|
|
6320
6337
|
${model.toLowerCase()}: ${plural}Router`
|
|
6321
6338
|
);
|
|
6339
|
+
consoleLog(`Generated tRPC router for model ${model} with ${modelActions.length} actions`);
|
|
6322
6340
|
}
|
|
6341
|
+
consoleLog("Generating tRPC app router");
|
|
6323
6342
|
appRouter.addStatements(
|
|
6324
6343
|
/* ts */
|
|
6325
6344
|
`
|
|
@@ -6329,7 +6348,9 @@ async function generate(options) {
|
|
|
6329
6348
|
appRouter.formatText({
|
|
6330
6349
|
indentSize: 2
|
|
6331
6350
|
});
|
|
6351
|
+
consoleLog("Saving tRPC router source files to disk");
|
|
6332
6352
|
await project.save();
|
|
6353
|
+
consoleLog("Storm Software - Prisma tRPC generator completed successfully");
|
|
6333
6354
|
}
|
|
6334
6355
|
__name(generate, "generate");
|
|
6335
6356
|
|
package/dist/index.js
CHANGED
|
@@ -6257,7 +6257,12 @@ async function generate(options) {
|
|
|
6257
6257
|
} else {
|
|
6258
6258
|
consoleLog("Skipping tRPC Shield generation");
|
|
6259
6259
|
}
|
|
6260
|
+
consoleLog("Finding Prisma Client generator");
|
|
6260
6261
|
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
6262
|
+
if (!prismaClientProvider) {
|
|
6263
|
+
throw new Error("No Prisma Client generator found. Please add `prisma-client-js` to your generator list.");
|
|
6264
|
+
}
|
|
6265
|
+
consoleLog("Generating Prisma Client DMMF");
|
|
6261
6266
|
const prismaClientDmmf = await internals.getDMMF({
|
|
6262
6267
|
datamodel: options.datamodel,
|
|
6263
6268
|
previewFeatures: prismaClientProvider?.previewFeatures
|
|
@@ -6265,14 +6270,17 @@ async function generate(options) {
|
|
|
6265
6270
|
const modelOperations = prismaClientDmmf.mappings.modelOperations;
|
|
6266
6271
|
const models = prismaClientDmmf.datamodel.models;
|
|
6267
6272
|
const hiddenModels = [];
|
|
6273
|
+
consoleLog(`Generating tRPC source code for ${models.length} models`);
|
|
6268
6274
|
resolveModelsComments(models, hiddenModels);
|
|
6269
6275
|
const createRouter = project.createSourceFile(path6.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
|
|
6270
6276
|
overwrite: true
|
|
6271
6277
|
});
|
|
6278
|
+
consoleLog("Generating tRPC imports");
|
|
6272
6279
|
generateRPCImport(createRouter);
|
|
6273
6280
|
if (config.withShield) {
|
|
6274
6281
|
await generateShieldImport(createRouter, options, config.withShield);
|
|
6275
6282
|
}
|
|
6283
|
+
consoleLog("Generating tRPC base router");
|
|
6276
6284
|
await generateBaseRouter(createRouter, config, options);
|
|
6277
6285
|
createRouter.formatText({
|
|
6278
6286
|
indentSize: 2
|
|
@@ -6280,16 +6288,24 @@ async function generate(options) {
|
|
|
6280
6288
|
const appRouter = project.createSourceFile(path6.resolve(outputDir, "routers", `index.ts`), void 0, {
|
|
6281
6289
|
overwrite: true
|
|
6282
6290
|
});
|
|
6291
|
+
consoleLog("Generating tRPC router imports");
|
|
6283
6292
|
generateCreateRouterImport({
|
|
6284
6293
|
sourceFile: appRouter
|
|
6285
6294
|
});
|
|
6286
6295
|
const routerStatements = [];
|
|
6287
6296
|
for (const modelOperation of modelOperations) {
|
|
6288
6297
|
const { model, ...operations } = modelOperation;
|
|
6289
|
-
if (hiddenModels.includes(model))
|
|
6298
|
+
if (hiddenModels.includes(model)) {
|
|
6299
|
+
consoleLog(`Skipping model ${model} as it is hidden`);
|
|
6300
|
+
continue;
|
|
6301
|
+
}
|
|
6290
6302
|
const modelActions = Object.keys(operations).filter((opType) => config.generateModelActions.includes(opType.replace("One", "")));
|
|
6291
|
-
if (!modelActions.length)
|
|
6303
|
+
if (!modelActions.length) {
|
|
6304
|
+
consoleLog(`Skipping model ${model} as it has no actions to generate`);
|
|
6305
|
+
continue;
|
|
6306
|
+
}
|
|
6292
6307
|
const plural = (0, import_pluralize.default)(model.toLowerCase());
|
|
6308
|
+
consoleLog(`Generating tRPC router for model ${model}`);
|
|
6293
6309
|
generateRouterImport(appRouter, plural, model);
|
|
6294
6310
|
const modelRouter = project.createSourceFile(path6.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {
|
|
6295
6311
|
overwrite: true
|
|
@@ -6299,6 +6315,7 @@ async function generate(options) {
|
|
|
6299
6315
|
config
|
|
6300
6316
|
});
|
|
6301
6317
|
if (config.withZod) {
|
|
6318
|
+
consoleLog("Generating Zod schemas imports");
|
|
6302
6319
|
generateRouterSchemaImports(modelRouter, model, modelActions);
|
|
6303
6320
|
}
|
|
6304
6321
|
modelRouter.addStatements(
|
|
@@ -6324,7 +6341,9 @@ async function generate(options) {
|
|
|
6324
6341
|
`
|
|
6325
6342
|
${model.toLowerCase()}: ${plural}Router`
|
|
6326
6343
|
);
|
|
6344
|
+
consoleLog(`Generated tRPC router for model ${model} with ${modelActions.length} actions`);
|
|
6327
6345
|
}
|
|
6346
|
+
consoleLog("Generating tRPC app router");
|
|
6328
6347
|
appRouter.addStatements(
|
|
6329
6348
|
/* ts */
|
|
6330
6349
|
`
|
|
@@ -6334,7 +6353,9 @@ async function generate(options) {
|
|
|
6334
6353
|
appRouter.formatText({
|
|
6335
6354
|
indentSize: 2
|
|
6336
6355
|
});
|
|
6356
|
+
consoleLog("Saving tRPC router source files to disk");
|
|
6337
6357
|
await project.save();
|
|
6358
|
+
consoleLog("Storm Software - Prisma tRPC generator completed successfully");
|
|
6338
6359
|
}
|
|
6339
6360
|
__name(generate, "generate");
|
|
6340
6361
|
|