@stryke/prisma-trpc-generator 0.5.1 → 0.5.2

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.
@@ -7636,12 +7636,6 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7636
7636
  namedImports: imports
7637
7637
  });
7638
7638
  }, "generateCreateRouterImport");
7639
- var generateRPCImport = /* @__PURE__ */ __name((sourceFile) => {
7640
- sourceFile.addImportDeclaration({
7641
- moduleSpecifier: "@trpc/server",
7642
- namespaceImport: "trpc"
7643
- });
7644
- }, "generateRPCImport");
7645
7639
  var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7646
7640
  const internals = await getPrismaInternals();
7647
7641
  const outputDir = internals.parseEnvValue(options.generator.output);
@@ -7837,7 +7831,7 @@ function generateRouterSchemaImports(sourceFile, modelName, modelActions) {
7837
7831
  }
7838
7832
  __name(generateRouterSchemaImports, "generateRouterSchemaImports");
7839
7833
  var getRouterSchemaImportByOpName = /* @__PURE__ */ __name((opName, modelName) => {
7840
- const opType = opName.replace("OrThrow", "");
7834
+ const opType = opName.replace("OrThrow", "").replace("ManyAndReturn", "");
7841
7835
  const inputType = getInputTypeByOpName(opType, modelName);
7842
7836
  return inputType ? `import { ${inputType} } from "../schemas/${opType}${modelName}.schema"; ` : "";
7843
7837
  }, "getRouterSchemaImportByOpName");
@@ -7863,22 +7857,22 @@ var getInputTypeByOpName = /* @__PURE__ */ __name((opName, modelName) => {
7863
7857
  inputType = `${modelName}CreateManySchema`;
7864
7858
  break;
7865
7859
  case "createManyAndReturn":
7866
- inputType = `${modelName}CreateManyAndReturnSchema`;
7860
+ inputType = `${modelName}CreateManySchema`;
7867
7861
  break;
7868
7862
  case "deleteOne":
7869
7863
  inputType = `${modelName}DeleteOneSchema`;
7870
7864
  break;
7871
- case "updateOne":
7872
- inputType = `${modelName}UpdateOneSchema`;
7873
- break;
7874
7865
  case "deleteMany":
7875
7866
  inputType = `${modelName}DeleteManySchema`;
7876
7867
  break;
7868
+ case "updateOne":
7869
+ inputType = `${modelName}UpdateOneSchema`;
7870
+ break;
7877
7871
  case "updateMany":
7878
7872
  inputType = `${modelName}UpdateManySchema`;
7879
7873
  break;
7880
7874
  case "updateManyAndReturn":
7881
- inputType = `${modelName}UpdateManyAndReturnSchema`;
7875
+ inputType = `${modelName}UpdateManySchema`;
7882
7876
  break;
7883
7877
  case "upsertOne":
7884
7878
  inputType = `${modelName}UpsertSchema`;
@@ -7963,7 +7957,7 @@ var getImports = /* @__PURE__ */ __name((type, newPath) => {
7963
7957
  } else if (type === "trpc-shield") {
7964
7958
  statement = "import { shield, allow } from 'trpc-shield';\n";
7965
7959
  } else if (type === "context") {
7966
- statement = `import { Context } from '${newPath}';
7960
+ statement = `import type { Context } from '${newPath}';
7967
7961
  `;
7968
7962
  }
7969
7963
  return statement;
@@ -7987,7 +7981,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7987
7981
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7988
7982
  return `export const permissions = ${shieldObjectText};`;
7989
7983
  }, "wrapWithExport");
7990
- var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options) => {
7984
+ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, shieldOutputDir) => {
7991
7985
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
7992
7986
  return "";
7993
7987
  }
@@ -8014,9 +8008,7 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
8014
8008
  return "";
8015
8009
  }
8016
8010
  let shieldText = getImports("trpc-shield");
8017
- const internals = await getPrismaInternals();
8018
- const outputDir = internals.parseEnvValue(options.generator.output);
8019
- shieldText += getImports("context", relativePath(outputDir, joinPaths(options.schemaPath, config.contextPath)));
8011
+ shieldText += getImports("context", relativePath(shieldOutputDir, joinPaths(options.schemaPath, config.contextPath)));
8020
8012
  shieldText += "\n\n";
8021
8013
  shieldText += wrapWithExport({
8022
8014
  shieldObjectText: wrapWithTrpcShieldCall({
@@ -11672,7 +11664,7 @@ async function generate(options) {
11672
11664
  contextPath: config.contextPath
11673
11665
  }
11674
11666
  }
11675
- });
11667
+ }, shieldOutputDir);
11676
11668
  consoleLog("Saving tRPC Shield source file to disk");
11677
11669
  await writeFileSafely(joinPaths(shieldOutputDir, "shield.ts"), shieldText);
11678
11670
  } else {
@@ -11705,7 +11697,6 @@ export default {${config.useTRPCNext ? "\n transformer," : ""}
11705
11697
  overwrite: true
11706
11698
  });
11707
11699
  consoleLog("Generating tRPC imports");
11708
- generateRPCImport(createRouter);
11709
11700
  if (config.withShield) {
11710
11701
  await generateShieldImport(createRouter, options, config.withShield);
11711
11702
  }
package/dist/generator.js CHANGED
@@ -7641,12 +7641,6 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7641
7641
  namedImports: imports
7642
7642
  });
7643
7643
  }, "generateCreateRouterImport");
7644
- var generateRPCImport = /* @__PURE__ */ __name((sourceFile) => {
7645
- sourceFile.addImportDeclaration({
7646
- moduleSpecifier: "@trpc/server",
7647
- namespaceImport: "trpc"
7648
- });
7649
- }, "generateRPCImport");
7650
7644
  var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7651
7645
  const internals = await getPrismaInternals();
7652
7646
  const outputDir = internals.parseEnvValue(options.generator.output);
@@ -7842,7 +7836,7 @@ function generateRouterSchemaImports(sourceFile, modelName, modelActions) {
7842
7836
  }
7843
7837
  __name(generateRouterSchemaImports, "generateRouterSchemaImports");
7844
7838
  var getRouterSchemaImportByOpName = /* @__PURE__ */ __name((opName, modelName) => {
7845
- const opType = opName.replace("OrThrow", "");
7839
+ const opType = opName.replace("OrThrow", "").replace("ManyAndReturn", "");
7846
7840
  const inputType = getInputTypeByOpName(opType, modelName);
7847
7841
  return inputType ? `import { ${inputType} } from "../schemas/${opType}${modelName}.schema"; ` : "";
7848
7842
  }, "getRouterSchemaImportByOpName");
@@ -7868,22 +7862,22 @@ var getInputTypeByOpName = /* @__PURE__ */ __name((opName, modelName) => {
7868
7862
  inputType = `${modelName}CreateManySchema`;
7869
7863
  break;
7870
7864
  case "createManyAndReturn":
7871
- inputType = `${modelName}CreateManyAndReturnSchema`;
7865
+ inputType = `${modelName}CreateManySchema`;
7872
7866
  break;
7873
7867
  case "deleteOne":
7874
7868
  inputType = `${modelName}DeleteOneSchema`;
7875
7869
  break;
7876
- case "updateOne":
7877
- inputType = `${modelName}UpdateOneSchema`;
7878
- break;
7879
7870
  case "deleteMany":
7880
7871
  inputType = `${modelName}DeleteManySchema`;
7881
7872
  break;
7873
+ case "updateOne":
7874
+ inputType = `${modelName}UpdateOneSchema`;
7875
+ break;
7882
7876
  case "updateMany":
7883
7877
  inputType = `${modelName}UpdateManySchema`;
7884
7878
  break;
7885
7879
  case "updateManyAndReturn":
7886
- inputType = `${modelName}UpdateManyAndReturnSchema`;
7880
+ inputType = `${modelName}UpdateManySchema`;
7887
7881
  break;
7888
7882
  case "upsertOne":
7889
7883
  inputType = `${modelName}UpsertSchema`;
@@ -7968,7 +7962,7 @@ var getImports = /* @__PURE__ */ __name((type, newPath) => {
7968
7962
  } else if (type === "trpc-shield") {
7969
7963
  statement = "import { shield, allow } from 'trpc-shield';\n";
7970
7964
  } else if (type === "context") {
7971
- statement = `import { Context } from '${newPath}';
7965
+ statement = `import type { Context } from '${newPath}';
7972
7966
  `;
7973
7967
  }
7974
7968
  return statement;
@@ -7992,7 +7986,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7992
7986
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7993
7987
  return `export const permissions = ${shieldObjectText};`;
7994
7988
  }, "wrapWithExport");
7995
- var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options) => {
7989
+ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, shieldOutputDir) => {
7996
7990
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
7997
7991
  return "";
7998
7992
  }
@@ -8019,9 +8013,7 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
8019
8013
  return "";
8020
8014
  }
8021
8015
  let shieldText = getImports("trpc-shield");
8022
- const internals = await getPrismaInternals();
8023
- const outputDir = internals.parseEnvValue(options.generator.output);
8024
- shieldText += getImports("context", relativePath(outputDir, joinPaths(options.schemaPath, config.contextPath)));
8016
+ shieldText += getImports("context", relativePath(shieldOutputDir, joinPaths(options.schemaPath, config.contextPath)));
8025
8017
  shieldText += "\n\n";
8026
8018
  shieldText += wrapWithExport({
8027
8019
  shieldObjectText: wrapWithTrpcShieldCall({
@@ -11677,7 +11669,7 @@ async function generate(options) {
11677
11669
  contextPath: config.contextPath
11678
11670
  }
11679
11671
  }
11680
- });
11672
+ }, shieldOutputDir);
11681
11673
  consoleLog("Saving tRPC Shield source file to disk");
11682
11674
  await writeFileSafely(joinPaths(shieldOutputDir, "shield.ts"), shieldText);
11683
11675
  } else {
@@ -11710,7 +11702,6 @@ export default {${config.useTRPCNext ? "\n transformer," : ""}
11710
11702
  overwrite: true
11711
11703
  });
11712
11704
  consoleLog("Generating tRPC imports");
11713
- generateRPCImport(createRouter);
11714
11705
  if (config.withShield) {
11715
11706
  await generateShieldImport(createRouter, options, config.withShield);
11716
11707
  }
package/dist/index.cjs CHANGED
@@ -7632,12 +7632,6 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7632
7632
  namedImports: imports
7633
7633
  });
7634
7634
  }, "generateCreateRouterImport");
7635
- var generateRPCImport = /* @__PURE__ */ __name((sourceFile) => {
7636
- sourceFile.addImportDeclaration({
7637
- moduleSpecifier: "@trpc/server",
7638
- namespaceImport: "trpc"
7639
- });
7640
- }, "generateRPCImport");
7641
7635
  var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7642
7636
  const internals = await getPrismaInternals();
7643
7637
  const outputDir = internals.parseEnvValue(options.generator.output);
@@ -7833,7 +7827,7 @@ function generateRouterSchemaImports(sourceFile, modelName, modelActions) {
7833
7827
  }
7834
7828
  __name(generateRouterSchemaImports, "generateRouterSchemaImports");
7835
7829
  var getRouterSchemaImportByOpName = /* @__PURE__ */ __name((opName, modelName) => {
7836
- const opType = opName.replace("OrThrow", "");
7830
+ const opType = opName.replace("OrThrow", "").replace("ManyAndReturn", "");
7837
7831
  const inputType = getInputTypeByOpName(opType, modelName);
7838
7832
  return inputType ? `import { ${inputType} } from "../schemas/${opType}${modelName}.schema"; ` : "";
7839
7833
  }, "getRouterSchemaImportByOpName");
@@ -7859,22 +7853,22 @@ var getInputTypeByOpName = /* @__PURE__ */ __name((opName, modelName) => {
7859
7853
  inputType = `${modelName}CreateManySchema`;
7860
7854
  break;
7861
7855
  case "createManyAndReturn":
7862
- inputType = `${modelName}CreateManyAndReturnSchema`;
7856
+ inputType = `${modelName}CreateManySchema`;
7863
7857
  break;
7864
7858
  case "deleteOne":
7865
7859
  inputType = `${modelName}DeleteOneSchema`;
7866
7860
  break;
7867
- case "updateOne":
7868
- inputType = `${modelName}UpdateOneSchema`;
7869
- break;
7870
7861
  case "deleteMany":
7871
7862
  inputType = `${modelName}DeleteManySchema`;
7872
7863
  break;
7864
+ case "updateOne":
7865
+ inputType = `${modelName}UpdateOneSchema`;
7866
+ break;
7873
7867
  case "updateMany":
7874
7868
  inputType = `${modelName}UpdateManySchema`;
7875
7869
  break;
7876
7870
  case "updateManyAndReturn":
7877
- inputType = `${modelName}UpdateManyAndReturnSchema`;
7871
+ inputType = `${modelName}UpdateManySchema`;
7878
7872
  break;
7879
7873
  case "upsertOne":
7880
7874
  inputType = `${modelName}UpsertSchema`;
@@ -7959,7 +7953,7 @@ var getImports = /* @__PURE__ */ __name((type, newPath) => {
7959
7953
  } else if (type === "trpc-shield") {
7960
7954
  statement = "import { shield, allow } from 'trpc-shield';\n";
7961
7955
  } else if (type === "context") {
7962
- statement = `import { Context } from '${newPath}';
7956
+ statement = `import type { Context } from '${newPath}';
7963
7957
  `;
7964
7958
  }
7965
7959
  return statement;
@@ -7983,7 +7977,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7983
7977
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7984
7978
  return `export const permissions = ${shieldObjectText};`;
7985
7979
  }, "wrapWithExport");
7986
- var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options) => {
7980
+ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, shieldOutputDir) => {
7987
7981
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
7988
7982
  return "";
7989
7983
  }
@@ -8010,9 +8004,7 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
8010
8004
  return "";
8011
8005
  }
8012
8006
  let shieldText = getImports("trpc-shield");
8013
- const internals = await getPrismaInternals();
8014
- const outputDir = internals.parseEnvValue(options.generator.output);
8015
- shieldText += getImports("context", relativePath(outputDir, joinPaths(options.schemaPath, config.contextPath)));
8007
+ shieldText += getImports("context", relativePath(shieldOutputDir, joinPaths(options.schemaPath, config.contextPath)));
8016
8008
  shieldText += "\n\n";
8017
8009
  shieldText += wrapWithExport({
8018
8010
  shieldObjectText: wrapWithTrpcShieldCall({
@@ -11668,7 +11660,7 @@ async function generate(options) {
11668
11660
  contextPath: config.contextPath
11669
11661
  }
11670
11662
  }
11671
- });
11663
+ }, shieldOutputDir);
11672
11664
  consoleLog("Saving tRPC Shield source file to disk");
11673
11665
  await writeFileSafely(joinPaths(shieldOutputDir, "shield.ts"), shieldText);
11674
11666
  } else {
@@ -11701,7 +11693,6 @@ export default {${config.useTRPCNext ? "\n transformer," : ""}
11701
11693
  overwrite: true
11702
11694
  });
11703
11695
  consoleLog("Generating tRPC imports");
11704
- generateRPCImport(createRouter);
11705
11696
  if (config.withShield) {
11706
11697
  await generateShieldImport(createRouter, options, config.withShield);
11707
11698
  }
package/dist/index.js CHANGED
@@ -7637,12 +7637,6 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7637
7637
  namedImports: imports
7638
7638
  });
7639
7639
  }, "generateCreateRouterImport");
7640
- var generateRPCImport = /* @__PURE__ */ __name((sourceFile) => {
7641
- sourceFile.addImportDeclaration({
7642
- moduleSpecifier: "@trpc/server",
7643
- namespaceImport: "trpc"
7644
- });
7645
- }, "generateRPCImport");
7646
7640
  var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7647
7641
  const internals = await getPrismaInternals();
7648
7642
  const outputDir = internals.parseEnvValue(options.generator.output);
@@ -7838,7 +7832,7 @@ function generateRouterSchemaImports(sourceFile, modelName, modelActions) {
7838
7832
  }
7839
7833
  __name(generateRouterSchemaImports, "generateRouterSchemaImports");
7840
7834
  var getRouterSchemaImportByOpName = /* @__PURE__ */ __name((opName, modelName) => {
7841
- const opType = opName.replace("OrThrow", "");
7835
+ const opType = opName.replace("OrThrow", "").replace("ManyAndReturn", "");
7842
7836
  const inputType = getInputTypeByOpName(opType, modelName);
7843
7837
  return inputType ? `import { ${inputType} } from "../schemas/${opType}${modelName}.schema"; ` : "";
7844
7838
  }, "getRouterSchemaImportByOpName");
@@ -7864,22 +7858,22 @@ var getInputTypeByOpName = /* @__PURE__ */ __name((opName, modelName) => {
7864
7858
  inputType = `${modelName}CreateManySchema`;
7865
7859
  break;
7866
7860
  case "createManyAndReturn":
7867
- inputType = `${modelName}CreateManyAndReturnSchema`;
7861
+ inputType = `${modelName}CreateManySchema`;
7868
7862
  break;
7869
7863
  case "deleteOne":
7870
7864
  inputType = `${modelName}DeleteOneSchema`;
7871
7865
  break;
7872
- case "updateOne":
7873
- inputType = `${modelName}UpdateOneSchema`;
7874
- break;
7875
7866
  case "deleteMany":
7876
7867
  inputType = `${modelName}DeleteManySchema`;
7877
7868
  break;
7869
+ case "updateOne":
7870
+ inputType = `${modelName}UpdateOneSchema`;
7871
+ break;
7878
7872
  case "updateMany":
7879
7873
  inputType = `${modelName}UpdateManySchema`;
7880
7874
  break;
7881
7875
  case "updateManyAndReturn":
7882
- inputType = `${modelName}UpdateManyAndReturnSchema`;
7876
+ inputType = `${modelName}UpdateManySchema`;
7883
7877
  break;
7884
7878
  case "upsertOne":
7885
7879
  inputType = `${modelName}UpsertSchema`;
@@ -7964,7 +7958,7 @@ var getImports = /* @__PURE__ */ __name((type, newPath) => {
7964
7958
  } else if (type === "trpc-shield") {
7965
7959
  statement = "import { shield, allow } from 'trpc-shield';\n";
7966
7960
  } else if (type === "context") {
7967
- statement = `import { Context } from '${newPath}';
7961
+ statement = `import type { Context } from '${newPath}';
7968
7962
  `;
7969
7963
  }
7970
7964
  return statement;
@@ -7988,7 +7982,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7988
7982
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7989
7983
  return `export const permissions = ${shieldObjectText};`;
7990
7984
  }, "wrapWithExport");
7991
- var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options) => {
7985
+ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, shieldOutputDir) => {
7992
7986
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
7993
7987
  return "";
7994
7988
  }
@@ -8015,9 +8009,7 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
8015
8009
  return "";
8016
8010
  }
8017
8011
  let shieldText = getImports("trpc-shield");
8018
- const internals = await getPrismaInternals();
8019
- const outputDir = internals.parseEnvValue(options.generator.output);
8020
- shieldText += getImports("context", relativePath(outputDir, joinPaths(options.schemaPath, config.contextPath)));
8012
+ shieldText += getImports("context", relativePath(shieldOutputDir, joinPaths(options.schemaPath, config.contextPath)));
8021
8013
  shieldText += "\n\n";
8022
8014
  shieldText += wrapWithExport({
8023
8015
  shieldObjectText: wrapWithTrpcShieldCall({
@@ -11673,7 +11665,7 @@ async function generate(options) {
11673
11665
  contextPath: config.contextPath
11674
11666
  }
11675
11667
  }
11676
- });
11668
+ }, shieldOutputDir);
11677
11669
  consoleLog("Saving tRPC Shield source file to disk");
11678
11670
  await writeFileSafely(joinPaths(shieldOutputDir, "shield.ts"), shieldText);
11679
11671
  } else {
@@ -11706,7 +11698,6 @@ export default {${config.useTRPCNext ? "\n transformer," : ""}
11706
11698
  overwrite: true
11707
11699
  });
11708
11700
  consoleLog("Generating tRPC imports");
11709
- generateRPCImport(createRouter);
11710
11701
  if (config.withShield) {
11711
11702
  await generateShieldImport(createRouter, options, config.withShield);
11712
11703
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/prisma-trpc-generator",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "description": "A fork of the prisma-trpc-generator code to work in ESM with Prisma v6.",
6
6
  "repository": {