@stryke/prisma-trpc-generator 0.2.16 → 0.3.0
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 +22 -7
- package/dist/generator.js +22 -7
- package/dist/index.cjs +22 -7
- package/dist/index.js +22 -7
- package/package.json +1 -1
package/dist/generator.cjs
CHANGED
|
@@ -4926,6 +4926,7 @@ var configShield = z.union([
|
|
|
4926
4926
|
]);
|
|
4927
4927
|
var modelActionEnum = z.nativeEnum(ModelAction);
|
|
4928
4928
|
var configSchema = z.object({
|
|
4929
|
+
debug: configBoolean.default("false"),
|
|
4929
4930
|
withMiddleware: configMiddleware.default("true"),
|
|
4930
4931
|
withShield: configShield.default("true"),
|
|
4931
4932
|
withZod: configBoolean.default("true"),
|
|
@@ -4940,6 +4941,12 @@ var configSchema = z.object({
|
|
|
4940
4941
|
// src/helpers.ts
|
|
4941
4942
|
init_cjs_shims();
|
|
4942
4943
|
|
|
4944
|
+
// ../string-format/src/lower-case-first.ts
|
|
4945
|
+
init_cjs_shims();
|
|
4946
|
+
var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
|
|
4947
|
+
return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
|
|
4948
|
+
}, "lowerCaseFirst");
|
|
4949
|
+
|
|
4943
4950
|
// src/utils/get-prisma-internals.ts
|
|
4944
4951
|
init_cjs_shims();
|
|
4945
4952
|
|
|
@@ -5714,12 +5721,6 @@ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath)
|
|
|
5714
5721
|
}
|
|
5715
5722
|
__name(getRelativePath, "getRelativePath");
|
|
5716
5723
|
|
|
5717
|
-
// src/utils/uncapitalize-first-letter.ts
|
|
5718
|
-
init_cjs_shims();
|
|
5719
|
-
var uncapitalizeFirstLetter = /* @__PURE__ */ __name((str) => {
|
|
5720
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
5721
|
-
}, "uncapitalizeFirstLetter");
|
|
5722
|
-
|
|
5723
5724
|
// src/helpers.ts
|
|
5724
5725
|
var getProcedureName = /* @__PURE__ */ __name((config) => {
|
|
5725
5726
|
return config.withShield ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
|
|
@@ -5876,7 +5877,7 @@ function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOp
|
|
|
5876
5877
|
/* ts */
|
|
5877
5878
|
`${config.showModelNameInProcedure ? name : nameWithoutModel}: ${getProcedureName(config)}
|
|
5878
5879
|
${config.withZod ? `.input(${typeName})` : ""}.${getProcedureTypeByOpName(baseOpType)}(async ({ ctx, input }) => {
|
|
5879
|
-
const ${name} = await ctx.prisma.${
|
|
5880
|
+
const ${name} = await ctx.prisma.${lowerCaseFirst(modelName)}.${opType.replace("One", "")}(${input});
|
|
5880
5881
|
return ${name};
|
|
5881
5882
|
}),`
|
|
5882
5883
|
);
|
|
@@ -6208,22 +6209,34 @@ var project = new import_ts_morph.Project({
|
|
|
6208
6209
|
|
|
6209
6210
|
// src/prisma-generator.ts
|
|
6210
6211
|
async function generate(options) {
|
|
6212
|
+
console.log("[STORM]: Running the Storm Software - Prisma tRPC generator with options: \n", JSON.stringify(options, null, 2));
|
|
6211
6213
|
const internals = await getPrismaInternals();
|
|
6214
|
+
console.log(`[STORM]: Validating configuration options`);
|
|
6212
6215
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
6213
6216
|
const results = configSchema.safeParse(options.generator.config);
|
|
6214
6217
|
if (!results.success) {
|
|
6215
6218
|
throw new Error("Invalid options passed");
|
|
6216
6219
|
}
|
|
6217
6220
|
const config = results.data;
|
|
6221
|
+
const consoleLog = /* @__PURE__ */ __name((message) => {
|
|
6222
|
+
if (config.debug) {
|
|
6223
|
+
console.log(`[STORM]: ${message}`);
|
|
6224
|
+
}
|
|
6225
|
+
}, "consoleLog");
|
|
6226
|
+
consoleLog(`Preparing output directory: ${outputDir}`);
|
|
6218
6227
|
await import_node_fs6.promises.mkdir(outputDir, {
|
|
6219
6228
|
recursive: true
|
|
6220
6229
|
});
|
|
6221
6230
|
await removeDir(outputDir, true);
|
|
6222
6231
|
if (config.withZod !== false) {
|
|
6232
|
+
consoleLog("Generating Zod schemas");
|
|
6223
6233
|
const prismaZodGenerator = await getJiti().import(getJiti().esmResolve("prisma-zod-generator/lib/prisma-generator"));
|
|
6224
6234
|
await prismaZodGenerator.generate(options);
|
|
6235
|
+
} else {
|
|
6236
|
+
consoleLog("Skipping Zod schemas generation");
|
|
6225
6237
|
}
|
|
6226
6238
|
if (config.withShield !== false) {
|
|
6239
|
+
consoleLog("Generating tRPC Shield");
|
|
6227
6240
|
const shieldOutputPath = import_node_path7.default.join(outputDir, "./shield");
|
|
6228
6241
|
await generateShield({
|
|
6229
6242
|
...options,
|
|
@@ -6240,6 +6253,8 @@ async function generate(options) {
|
|
|
6240
6253
|
}
|
|
6241
6254
|
}
|
|
6242
6255
|
});
|
|
6256
|
+
} else {
|
|
6257
|
+
consoleLog("Skipping tRPC Shield generation");
|
|
6243
6258
|
}
|
|
6244
6259
|
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
6245
6260
|
const prismaClientDmmf = await internals.getDMMF({
|
package/dist/generator.js
CHANGED
|
@@ -4931,6 +4931,7 @@ var configShield = z.union([
|
|
|
4931
4931
|
]);
|
|
4932
4932
|
var modelActionEnum = z.nativeEnum(ModelAction);
|
|
4933
4933
|
var configSchema = z.object({
|
|
4934
|
+
debug: configBoolean.default("false"),
|
|
4934
4935
|
withMiddleware: configMiddleware.default("true"),
|
|
4935
4936
|
withShield: configShield.default("true"),
|
|
4936
4937
|
withZod: configBoolean.default("true"),
|
|
@@ -4945,6 +4946,12 @@ var configSchema = z.object({
|
|
|
4945
4946
|
// src/helpers.ts
|
|
4946
4947
|
init_esm_shims();
|
|
4947
4948
|
|
|
4949
|
+
// ../string-format/src/lower-case-first.ts
|
|
4950
|
+
init_esm_shims();
|
|
4951
|
+
var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
|
|
4952
|
+
return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
|
|
4953
|
+
}, "lowerCaseFirst");
|
|
4954
|
+
|
|
4948
4955
|
// src/utils/get-prisma-internals.ts
|
|
4949
4956
|
init_esm_shims();
|
|
4950
4957
|
|
|
@@ -5719,12 +5726,6 @@ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath)
|
|
|
5719
5726
|
}
|
|
5720
5727
|
__name(getRelativePath, "getRelativePath");
|
|
5721
5728
|
|
|
5722
|
-
// src/utils/uncapitalize-first-letter.ts
|
|
5723
|
-
init_esm_shims();
|
|
5724
|
-
var uncapitalizeFirstLetter = /* @__PURE__ */ __name((str) => {
|
|
5725
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
5726
|
-
}, "uncapitalizeFirstLetter");
|
|
5727
|
-
|
|
5728
5729
|
// src/helpers.ts
|
|
5729
5730
|
var getProcedureName = /* @__PURE__ */ __name((config) => {
|
|
5730
5731
|
return config.withShield ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
|
|
@@ -5881,7 +5882,7 @@ function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOp
|
|
|
5881
5882
|
/* ts */
|
|
5882
5883
|
`${config.showModelNameInProcedure ? name : nameWithoutModel}: ${getProcedureName(config)}
|
|
5883
5884
|
${config.withZod ? `.input(${typeName})` : ""}.${getProcedureTypeByOpName(baseOpType)}(async ({ ctx, input }) => {
|
|
5884
|
-
const ${name} = await ctx.prisma.${
|
|
5885
|
+
const ${name} = await ctx.prisma.${lowerCaseFirst(modelName)}.${opType.replace("One", "")}(${input});
|
|
5885
5886
|
return ${name};
|
|
5886
5887
|
}),`
|
|
5887
5888
|
);
|
|
@@ -6213,22 +6214,34 @@ var project = new Project({
|
|
|
6213
6214
|
|
|
6214
6215
|
// src/prisma-generator.ts
|
|
6215
6216
|
async function generate(options) {
|
|
6217
|
+
console.log("[STORM]: Running the Storm Software - Prisma tRPC generator with options: \n", JSON.stringify(options, null, 2));
|
|
6216
6218
|
const internals = await getPrismaInternals();
|
|
6219
|
+
console.log(`[STORM]: Validating configuration options`);
|
|
6217
6220
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
6218
6221
|
const results = configSchema.safeParse(options.generator.config);
|
|
6219
6222
|
if (!results.success) {
|
|
6220
6223
|
throw new Error("Invalid options passed");
|
|
6221
6224
|
}
|
|
6222
6225
|
const config = results.data;
|
|
6226
|
+
const consoleLog = /* @__PURE__ */ __name((message) => {
|
|
6227
|
+
if (config.debug) {
|
|
6228
|
+
console.log(`[STORM]: ${message}`);
|
|
6229
|
+
}
|
|
6230
|
+
}, "consoleLog");
|
|
6231
|
+
consoleLog(`Preparing output directory: ${outputDir}`);
|
|
6223
6232
|
await fs4.mkdir(outputDir, {
|
|
6224
6233
|
recursive: true
|
|
6225
6234
|
});
|
|
6226
6235
|
await removeDir(outputDir, true);
|
|
6227
6236
|
if (config.withZod !== false) {
|
|
6237
|
+
consoleLog("Generating Zod schemas");
|
|
6228
6238
|
const prismaZodGenerator = await getJiti().import(getJiti().esmResolve("prisma-zod-generator/lib/prisma-generator"));
|
|
6229
6239
|
await prismaZodGenerator.generate(options);
|
|
6240
|
+
} else {
|
|
6241
|
+
consoleLog("Skipping Zod schemas generation");
|
|
6230
6242
|
}
|
|
6231
6243
|
if (config.withShield !== false) {
|
|
6244
|
+
consoleLog("Generating tRPC Shield");
|
|
6232
6245
|
const shieldOutputPath = path6.join(outputDir, "./shield");
|
|
6233
6246
|
await generateShield({
|
|
6234
6247
|
...options,
|
|
@@ -6245,6 +6258,8 @@ async function generate(options) {
|
|
|
6245
6258
|
}
|
|
6246
6259
|
}
|
|
6247
6260
|
});
|
|
6261
|
+
} else {
|
|
6262
|
+
consoleLog("Skipping tRPC Shield generation");
|
|
6248
6263
|
}
|
|
6249
6264
|
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
6250
6265
|
const prismaClientDmmf = await internals.getDMMF({
|
package/dist/index.cjs
CHANGED
|
@@ -4922,6 +4922,7 @@ var configShield = z.union([
|
|
|
4922
4922
|
]);
|
|
4923
4923
|
var modelActionEnum = z.nativeEnum(ModelAction);
|
|
4924
4924
|
var configSchema = z.object({
|
|
4925
|
+
debug: configBoolean.default("false"),
|
|
4925
4926
|
withMiddleware: configMiddleware.default("true"),
|
|
4926
4927
|
withShield: configShield.default("true"),
|
|
4927
4928
|
withZod: configBoolean.default("true"),
|
|
@@ -4936,6 +4937,12 @@ var configSchema = z.object({
|
|
|
4936
4937
|
// src/helpers.ts
|
|
4937
4938
|
init_cjs_shims();
|
|
4938
4939
|
|
|
4940
|
+
// ../string-format/src/lower-case-first.ts
|
|
4941
|
+
init_cjs_shims();
|
|
4942
|
+
var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
|
|
4943
|
+
return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
|
|
4944
|
+
}, "lowerCaseFirst");
|
|
4945
|
+
|
|
4939
4946
|
// src/utils/get-prisma-internals.ts
|
|
4940
4947
|
init_cjs_shims();
|
|
4941
4948
|
|
|
@@ -5710,12 +5717,6 @@ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath)
|
|
|
5710
5717
|
}
|
|
5711
5718
|
__name(getRelativePath, "getRelativePath");
|
|
5712
5719
|
|
|
5713
|
-
// src/utils/uncapitalize-first-letter.ts
|
|
5714
|
-
init_cjs_shims();
|
|
5715
|
-
var uncapitalizeFirstLetter = /* @__PURE__ */ __name((str) => {
|
|
5716
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
5717
|
-
}, "uncapitalizeFirstLetter");
|
|
5718
|
-
|
|
5719
5720
|
// src/helpers.ts
|
|
5720
5721
|
var getProcedureName = /* @__PURE__ */ __name((config) => {
|
|
5721
5722
|
return config.withShield ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
|
|
@@ -5872,7 +5873,7 @@ function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOp
|
|
|
5872
5873
|
/* ts */
|
|
5873
5874
|
`${config.showModelNameInProcedure ? name : nameWithoutModel}: ${getProcedureName(config)}
|
|
5874
5875
|
${config.withZod ? `.input(${typeName})` : ""}.${getProcedureTypeByOpName(baseOpType)}(async ({ ctx, input }) => {
|
|
5875
|
-
const ${name} = await ctx.prisma.${
|
|
5876
|
+
const ${name} = await ctx.prisma.${lowerCaseFirst(modelName)}.${opType.replace("One", "")}(${input});
|
|
5876
5877
|
return ${name};
|
|
5877
5878
|
}),`
|
|
5878
5879
|
);
|
|
@@ -6204,22 +6205,34 @@ var project = new import_ts_morph.Project({
|
|
|
6204
6205
|
|
|
6205
6206
|
// src/prisma-generator.ts
|
|
6206
6207
|
async function generate(options) {
|
|
6208
|
+
console.log("[STORM]: Running the Storm Software - Prisma tRPC generator with options: \n", JSON.stringify(options, null, 2));
|
|
6207
6209
|
const internals = await getPrismaInternals();
|
|
6210
|
+
console.log(`[STORM]: Validating configuration options`);
|
|
6208
6211
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
6209
6212
|
const results = configSchema.safeParse(options.generator.config);
|
|
6210
6213
|
if (!results.success) {
|
|
6211
6214
|
throw new Error("Invalid options passed");
|
|
6212
6215
|
}
|
|
6213
6216
|
const config = results.data;
|
|
6217
|
+
const consoleLog = /* @__PURE__ */ __name((message) => {
|
|
6218
|
+
if (config.debug) {
|
|
6219
|
+
console.log(`[STORM]: ${message}`);
|
|
6220
|
+
}
|
|
6221
|
+
}, "consoleLog");
|
|
6222
|
+
consoleLog(`Preparing output directory: ${outputDir}`);
|
|
6214
6223
|
await import_node_fs6.promises.mkdir(outputDir, {
|
|
6215
6224
|
recursive: true
|
|
6216
6225
|
});
|
|
6217
6226
|
await removeDir(outputDir, true);
|
|
6218
6227
|
if (config.withZod !== false) {
|
|
6228
|
+
consoleLog("Generating Zod schemas");
|
|
6219
6229
|
const prismaZodGenerator = await getJiti().import(getJiti().esmResolve("prisma-zod-generator/lib/prisma-generator"));
|
|
6220
6230
|
await prismaZodGenerator.generate(options);
|
|
6231
|
+
} else {
|
|
6232
|
+
consoleLog("Skipping Zod schemas generation");
|
|
6221
6233
|
}
|
|
6222
6234
|
if (config.withShield !== false) {
|
|
6235
|
+
consoleLog("Generating tRPC Shield");
|
|
6223
6236
|
const shieldOutputPath = import_node_path7.default.join(outputDir, "./shield");
|
|
6224
6237
|
await generateShield({
|
|
6225
6238
|
...options,
|
|
@@ -6236,6 +6249,8 @@ async function generate(options) {
|
|
|
6236
6249
|
}
|
|
6237
6250
|
}
|
|
6238
6251
|
});
|
|
6252
|
+
} else {
|
|
6253
|
+
consoleLog("Skipping tRPC Shield generation");
|
|
6239
6254
|
}
|
|
6240
6255
|
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
6241
6256
|
const prismaClientDmmf = await internals.getDMMF({
|
package/dist/index.js
CHANGED
|
@@ -4927,6 +4927,7 @@ var configShield = z.union([
|
|
|
4927
4927
|
]);
|
|
4928
4928
|
var modelActionEnum = z.nativeEnum(ModelAction);
|
|
4929
4929
|
var configSchema = z.object({
|
|
4930
|
+
debug: configBoolean.default("false"),
|
|
4930
4931
|
withMiddleware: configMiddleware.default("true"),
|
|
4931
4932
|
withShield: configShield.default("true"),
|
|
4932
4933
|
withZod: configBoolean.default("true"),
|
|
@@ -4941,6 +4942,12 @@ var configSchema = z.object({
|
|
|
4941
4942
|
// src/helpers.ts
|
|
4942
4943
|
init_esm_shims();
|
|
4943
4944
|
|
|
4945
|
+
// ../string-format/src/lower-case-first.ts
|
|
4946
|
+
init_esm_shims();
|
|
4947
|
+
var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
|
|
4948
|
+
return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
|
|
4949
|
+
}, "lowerCaseFirst");
|
|
4950
|
+
|
|
4944
4951
|
// src/utils/get-prisma-internals.ts
|
|
4945
4952
|
init_esm_shims();
|
|
4946
4953
|
|
|
@@ -5715,12 +5722,6 @@ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath)
|
|
|
5715
5722
|
}
|
|
5716
5723
|
__name(getRelativePath, "getRelativePath");
|
|
5717
5724
|
|
|
5718
|
-
// src/utils/uncapitalize-first-letter.ts
|
|
5719
|
-
init_esm_shims();
|
|
5720
|
-
var uncapitalizeFirstLetter = /* @__PURE__ */ __name((str) => {
|
|
5721
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
5722
|
-
}, "uncapitalizeFirstLetter");
|
|
5723
|
-
|
|
5724
5725
|
// src/helpers.ts
|
|
5725
5726
|
var getProcedureName = /* @__PURE__ */ __name((config) => {
|
|
5726
5727
|
return config.withShield ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
|
|
@@ -5877,7 +5878,7 @@ function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOp
|
|
|
5877
5878
|
/* ts */
|
|
5878
5879
|
`${config.showModelNameInProcedure ? name : nameWithoutModel}: ${getProcedureName(config)}
|
|
5879
5880
|
${config.withZod ? `.input(${typeName})` : ""}.${getProcedureTypeByOpName(baseOpType)}(async ({ ctx, input }) => {
|
|
5880
|
-
const ${name} = await ctx.prisma.${
|
|
5881
|
+
const ${name} = await ctx.prisma.${lowerCaseFirst(modelName)}.${opType.replace("One", "")}(${input});
|
|
5881
5882
|
return ${name};
|
|
5882
5883
|
}),`
|
|
5883
5884
|
);
|
|
@@ -6209,22 +6210,34 @@ var project = new Project({
|
|
|
6209
6210
|
|
|
6210
6211
|
// src/prisma-generator.ts
|
|
6211
6212
|
async function generate(options) {
|
|
6213
|
+
console.log("[STORM]: Running the Storm Software - Prisma tRPC generator with options: \n", JSON.stringify(options, null, 2));
|
|
6212
6214
|
const internals = await getPrismaInternals();
|
|
6215
|
+
console.log(`[STORM]: Validating configuration options`);
|
|
6213
6216
|
const outputDir = internals.parseEnvValue(options.generator.output);
|
|
6214
6217
|
const results = configSchema.safeParse(options.generator.config);
|
|
6215
6218
|
if (!results.success) {
|
|
6216
6219
|
throw new Error("Invalid options passed");
|
|
6217
6220
|
}
|
|
6218
6221
|
const config = results.data;
|
|
6222
|
+
const consoleLog = /* @__PURE__ */ __name((message) => {
|
|
6223
|
+
if (config.debug) {
|
|
6224
|
+
console.log(`[STORM]: ${message}`);
|
|
6225
|
+
}
|
|
6226
|
+
}, "consoleLog");
|
|
6227
|
+
consoleLog(`Preparing output directory: ${outputDir}`);
|
|
6219
6228
|
await fs4.mkdir(outputDir, {
|
|
6220
6229
|
recursive: true
|
|
6221
6230
|
});
|
|
6222
6231
|
await removeDir(outputDir, true);
|
|
6223
6232
|
if (config.withZod !== false) {
|
|
6233
|
+
consoleLog("Generating Zod schemas");
|
|
6224
6234
|
const prismaZodGenerator = await getJiti().import(getJiti().esmResolve("prisma-zod-generator/lib/prisma-generator"));
|
|
6225
6235
|
await prismaZodGenerator.generate(options);
|
|
6236
|
+
} else {
|
|
6237
|
+
consoleLog("Skipping Zod schemas generation");
|
|
6226
6238
|
}
|
|
6227
6239
|
if (config.withShield !== false) {
|
|
6240
|
+
consoleLog("Generating tRPC Shield");
|
|
6228
6241
|
const shieldOutputPath = path6.join(outputDir, "./shield");
|
|
6229
6242
|
await generateShield({
|
|
6230
6243
|
...options,
|
|
@@ -6241,6 +6254,8 @@ async function generate(options) {
|
|
|
6241
6254
|
}
|
|
6242
6255
|
}
|
|
6243
6256
|
});
|
|
6257
|
+
} else {
|
|
6258
|
+
consoleLog("Skipping tRPC Shield generation");
|
|
6244
6259
|
}
|
|
6245
6260
|
const prismaClientProvider = options.otherGenerators.find((it) => internals.parseEnvValue(it.provider) === "prisma-client-js");
|
|
6246
6261
|
const prismaClientDmmf = await internals.getDMMF({
|