@stryke/prisma-trpc-generator 0.6.0 → 0.7.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.
@@ -6883,13 +6883,13 @@ var configMiddleware = z.union([
6883
6883
  ]);
6884
6884
  var configShield = z.union([
6885
6885
  configBoolean,
6886
- z.string().default("../src/trpc/shield")
6886
+ z.string().default("../src/trpc/shields")
6887
6887
  ]);
6888
6888
  var modelActionEnum = z.nativeEnum(ModelAction);
6889
6889
  var configSchema = z.object({
6890
6890
  debug: configBoolean.default("false"),
6891
- withMiddleware: configMiddleware.default("true"),
6892
- withShield: configShield.default("true"),
6891
+ withMiddleware: configMiddleware.default("false"),
6892
+ withShields: configShield.default("true"),
6893
6893
  withZod: configBoolean.default("true"),
6894
6894
  withNext: configBoolean.default("true"),
6895
6895
  contextPath: z.string().default("../src/trpc/context"),
@@ -7622,7 +7622,7 @@ __name(getRelativePath, "getRelativePath");
7622
7622
 
7623
7623
  // src/helpers.ts
7624
7624
  var getProcedureName = /* @__PURE__ */ __name((config) => {
7625
- return config.withShield ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
7625
+ return config.withShields ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
7626
7626
  }, "getProcedureName");
7627
7627
  var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config }) => {
7628
7628
  const imports = [
@@ -7632,14 +7632,14 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7632
7632
  imports.push(getProcedureName(config));
7633
7633
  }
7634
7634
  sourceFile.addImportDeclaration({
7635
- moduleSpecifier: "./helpers/createRouter",
7635
+ moduleSpecifier: "../trpc",
7636
7636
  namedImports: imports
7637
7637
  });
7638
7638
  }, "generateCreateRouterImport");
7639
7639
  var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7640
7640
  const internals = await getPrismaInternals();
7641
7641
  const outputDir = internals.parseEnvValue(options.generator.output);
7642
- let shieldPath = getRelativePath(outputDir, "shield/shield");
7642
+ let shieldPath = getRelativePath(outputDir, "shield");
7643
7643
  if (typeof value === "string") {
7644
7644
  shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
7645
7645
  }
@@ -7682,6 +7682,7 @@ async function generateBaseRouter(sourceFile, config, options) {
7682
7682
  `
7683
7683
  import { createContext } from '${relativeContextPath}';
7684
7684
  import { initTRPC, TRPCError } from '@trpc/server';
7685
+ import { experimental_nextAppDirCaller } from '@trpc/server/adapters/next-app-dir';
7685
7686
  import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
7686
7687
  `
7687
7688
  );
@@ -7730,7 +7731,7 @@ async function generateBaseRouter(sourceFile, config, options) {
7730
7731
  )
7731
7732
  });
7732
7733
  }
7733
- if (config.withShield) {
7734
+ if (config.withShields) {
7734
7735
  sourceFile.addStatements(
7735
7736
  /* ts */
7736
7737
  `
@@ -7763,22 +7764,6 @@ export const createCallerFactory = t.createCallerFactory;`
7763
7764
  sourceFile.addStatements(
7764
7765
  /* ts */
7765
7766
  `
7766
- export const protectedProcedure = publicProcedure.use((opts) => {
7767
- const { session } = opts.ctx;
7768
-
7769
- if (!session?.user) {
7770
- throw new TRPCError({
7771
- code: 'UNAUTHORIZED',
7772
- });
7773
- }
7774
-
7775
- return opts.next({ ctx: { session } });
7776
- });
7777
- `
7778
- );
7779
- sourceFile.addStatements(
7780
- /* ts */
7781
- `
7782
7767
  export const createAction = createTRPCServerActionHandler(t, createContext);
7783
7768
  `
7784
7769
  );
@@ -7790,14 +7775,17 @@ export const protectedProcedure = publicProcedure.use((opts) => {
7790
7775
  sourceFile.addStatements(
7791
7776
  /* ts */
7792
7777
  `
7793
- export const ${procName} = t.procedure
7794
- `
7778
+ export const ${procName} = t.procedure`
7795
7779
  );
7796
7780
  }
7797
7781
  sourceFile.addStatements(
7798
7782
  /* ts */
7799
7783
  `
7800
- .use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})
7784
+ .use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})${config.withNext ? `.experimental_caller(
7785
+ experimental_nextAppDirCaller({
7786
+ normalizeFormData: true,
7787
+ }),
7788
+ )` : ""}
7801
7789
  `
7802
7790
  );
7803
7791
  });
@@ -11640,7 +11628,7 @@ async function generate(options) {
11640
11628
  queries.sort();
11641
11629
  mutations.sort();
11642
11630
  subscriptions.sort();
11643
- if (config.withShield !== false) {
11631
+ if (config.withShields !== false) {
11644
11632
  consoleLog("Generating tRPC Shield");
11645
11633
  const shieldOutputDir = outputDir;
11646
11634
  consoleLog("Constructing tRPC Shield source file");
@@ -11695,8 +11683,8 @@ export default {${config.withNext ? "\n transformer," : ""}
11695
11683
  overwrite: true
11696
11684
  });
11697
11685
  consoleLog("Generating tRPC imports");
11698
- if (config.withShield) {
11699
- await generateShieldImport(createRouter, options, config.withShield);
11686
+ if (config.withShields) {
11687
+ await generateShieldImport(createRouter, options, config.withShields);
11700
11688
  }
11701
11689
  consoleLog("Generating tRPC base router");
11702
11690
  await generateBaseRouter(createRouter, config, options);
@@ -11766,7 +11754,7 @@ export default {${config.withNext ? "\n transformer," : ""}
11766
11754
  routerStatements.push(
11767
11755
  /* ts */
11768
11756
  `
11769
- ${model.toLowerCase()}: ${plural}Router`
11757
+ ${lowerCaseFirst(model)}: ${plural}Router`
11770
11758
  );
11771
11759
  consoleLog(`Generated tRPC router for model ${model} with ${modelActions.length} actions`);
11772
11760
  }
package/dist/generator.js CHANGED
@@ -6888,13 +6888,13 @@ var configMiddleware = z.union([
6888
6888
  ]);
6889
6889
  var configShield = z.union([
6890
6890
  configBoolean,
6891
- z.string().default("../src/trpc/shield")
6891
+ z.string().default("../src/trpc/shields")
6892
6892
  ]);
6893
6893
  var modelActionEnum = z.nativeEnum(ModelAction);
6894
6894
  var configSchema = z.object({
6895
6895
  debug: configBoolean.default("false"),
6896
- withMiddleware: configMiddleware.default("true"),
6897
- withShield: configShield.default("true"),
6896
+ withMiddleware: configMiddleware.default("false"),
6897
+ withShields: configShield.default("true"),
6898
6898
  withZod: configBoolean.default("true"),
6899
6899
  withNext: configBoolean.default("true"),
6900
6900
  contextPath: z.string().default("../src/trpc/context"),
@@ -7627,7 +7627,7 @@ __name(getRelativePath, "getRelativePath");
7627
7627
 
7628
7628
  // src/helpers.ts
7629
7629
  var getProcedureName = /* @__PURE__ */ __name((config) => {
7630
- return config.withShield ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
7630
+ return config.withShields ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
7631
7631
  }, "getProcedureName");
7632
7632
  var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config }) => {
7633
7633
  const imports = [
@@ -7637,14 +7637,14 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7637
7637
  imports.push(getProcedureName(config));
7638
7638
  }
7639
7639
  sourceFile.addImportDeclaration({
7640
- moduleSpecifier: "./helpers/createRouter",
7640
+ moduleSpecifier: "../trpc",
7641
7641
  namedImports: imports
7642
7642
  });
7643
7643
  }, "generateCreateRouterImport");
7644
7644
  var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7645
7645
  const internals = await getPrismaInternals();
7646
7646
  const outputDir = internals.parseEnvValue(options.generator.output);
7647
- let shieldPath = getRelativePath(outputDir, "shield/shield");
7647
+ let shieldPath = getRelativePath(outputDir, "shield");
7648
7648
  if (typeof value === "string") {
7649
7649
  shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
7650
7650
  }
@@ -7687,6 +7687,7 @@ async function generateBaseRouter(sourceFile, config, options) {
7687
7687
  `
7688
7688
  import { createContext } from '${relativeContextPath}';
7689
7689
  import { initTRPC, TRPCError } from '@trpc/server';
7690
+ import { experimental_nextAppDirCaller } from '@trpc/server/adapters/next-app-dir';
7690
7691
  import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
7691
7692
  `
7692
7693
  );
@@ -7735,7 +7736,7 @@ async function generateBaseRouter(sourceFile, config, options) {
7735
7736
  )
7736
7737
  });
7737
7738
  }
7738
- if (config.withShield) {
7739
+ if (config.withShields) {
7739
7740
  sourceFile.addStatements(
7740
7741
  /* ts */
7741
7742
  `
@@ -7768,22 +7769,6 @@ export const createCallerFactory = t.createCallerFactory;`
7768
7769
  sourceFile.addStatements(
7769
7770
  /* ts */
7770
7771
  `
7771
- export const protectedProcedure = publicProcedure.use((opts) => {
7772
- const { session } = opts.ctx;
7773
-
7774
- if (!session?.user) {
7775
- throw new TRPCError({
7776
- code: 'UNAUTHORIZED',
7777
- });
7778
- }
7779
-
7780
- return opts.next({ ctx: { session } });
7781
- });
7782
- `
7783
- );
7784
- sourceFile.addStatements(
7785
- /* ts */
7786
- `
7787
7772
  export const createAction = createTRPCServerActionHandler(t, createContext);
7788
7773
  `
7789
7774
  );
@@ -7795,14 +7780,17 @@ export const protectedProcedure = publicProcedure.use((opts) => {
7795
7780
  sourceFile.addStatements(
7796
7781
  /* ts */
7797
7782
  `
7798
- export const ${procName} = t.procedure
7799
- `
7783
+ export const ${procName} = t.procedure`
7800
7784
  );
7801
7785
  }
7802
7786
  sourceFile.addStatements(
7803
7787
  /* ts */
7804
7788
  `
7805
- .use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})
7789
+ .use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})${config.withNext ? `.experimental_caller(
7790
+ experimental_nextAppDirCaller({
7791
+ normalizeFormData: true,
7792
+ }),
7793
+ )` : ""}
7806
7794
  `
7807
7795
  );
7808
7796
  });
@@ -11645,7 +11633,7 @@ async function generate(options) {
11645
11633
  queries.sort();
11646
11634
  mutations.sort();
11647
11635
  subscriptions.sort();
11648
- if (config.withShield !== false) {
11636
+ if (config.withShields !== false) {
11649
11637
  consoleLog("Generating tRPC Shield");
11650
11638
  const shieldOutputDir = outputDir;
11651
11639
  consoleLog("Constructing tRPC Shield source file");
@@ -11700,8 +11688,8 @@ export default {${config.withNext ? "\n transformer," : ""}
11700
11688
  overwrite: true
11701
11689
  });
11702
11690
  consoleLog("Generating tRPC imports");
11703
- if (config.withShield) {
11704
- await generateShieldImport(createRouter, options, config.withShield);
11691
+ if (config.withShields) {
11692
+ await generateShieldImport(createRouter, options, config.withShields);
11705
11693
  }
11706
11694
  consoleLog("Generating tRPC base router");
11707
11695
  await generateBaseRouter(createRouter, config, options);
@@ -11771,7 +11759,7 @@ export default {${config.withNext ? "\n transformer," : ""}
11771
11759
  routerStatements.push(
11772
11760
  /* ts */
11773
11761
  `
11774
- ${model.toLowerCase()}: ${plural}Router`
11762
+ ${lowerCaseFirst(model)}: ${plural}Router`
11775
11763
  );
11776
11764
  consoleLog(`Generated tRPC router for model ${model} with ${modelActions.length} actions`);
11777
11765
  }
package/dist/index.cjs CHANGED
@@ -6879,13 +6879,13 @@ var configMiddleware = z.union([
6879
6879
  ]);
6880
6880
  var configShield = z.union([
6881
6881
  configBoolean,
6882
- z.string().default("../src/trpc/shield")
6882
+ z.string().default("../src/trpc/shields")
6883
6883
  ]);
6884
6884
  var modelActionEnum = z.nativeEnum(ModelAction);
6885
6885
  var configSchema = z.object({
6886
6886
  debug: configBoolean.default("false"),
6887
- withMiddleware: configMiddleware.default("true"),
6888
- withShield: configShield.default("true"),
6887
+ withMiddleware: configMiddleware.default("false"),
6888
+ withShields: configShield.default("true"),
6889
6889
  withZod: configBoolean.default("true"),
6890
6890
  withNext: configBoolean.default("true"),
6891
6891
  contextPath: z.string().default("../src/trpc/context"),
@@ -7618,7 +7618,7 @@ __name(getRelativePath, "getRelativePath");
7618
7618
 
7619
7619
  // src/helpers.ts
7620
7620
  var getProcedureName = /* @__PURE__ */ __name((config) => {
7621
- return config.withShield ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
7621
+ return config.withShields ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
7622
7622
  }, "getProcedureName");
7623
7623
  var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config }) => {
7624
7624
  const imports = [
@@ -7628,14 +7628,14 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7628
7628
  imports.push(getProcedureName(config));
7629
7629
  }
7630
7630
  sourceFile.addImportDeclaration({
7631
- moduleSpecifier: "./helpers/createRouter",
7631
+ moduleSpecifier: "../trpc",
7632
7632
  namedImports: imports
7633
7633
  });
7634
7634
  }, "generateCreateRouterImport");
7635
7635
  var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7636
7636
  const internals = await getPrismaInternals();
7637
7637
  const outputDir = internals.parseEnvValue(options.generator.output);
7638
- let shieldPath = getRelativePath(outputDir, "shield/shield");
7638
+ let shieldPath = getRelativePath(outputDir, "shield");
7639
7639
  if (typeof value === "string") {
7640
7640
  shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
7641
7641
  }
@@ -7678,6 +7678,7 @@ async function generateBaseRouter(sourceFile, config, options) {
7678
7678
  `
7679
7679
  import { createContext } from '${relativeContextPath}';
7680
7680
  import { initTRPC, TRPCError } from '@trpc/server';
7681
+ import { experimental_nextAppDirCaller } from '@trpc/server/adapters/next-app-dir';
7681
7682
  import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
7682
7683
  `
7683
7684
  );
@@ -7726,7 +7727,7 @@ async function generateBaseRouter(sourceFile, config, options) {
7726
7727
  )
7727
7728
  });
7728
7729
  }
7729
- if (config.withShield) {
7730
+ if (config.withShields) {
7730
7731
  sourceFile.addStatements(
7731
7732
  /* ts */
7732
7733
  `
@@ -7759,22 +7760,6 @@ export const createCallerFactory = t.createCallerFactory;`
7759
7760
  sourceFile.addStatements(
7760
7761
  /* ts */
7761
7762
  `
7762
- export const protectedProcedure = publicProcedure.use((opts) => {
7763
- const { session } = opts.ctx;
7764
-
7765
- if (!session?.user) {
7766
- throw new TRPCError({
7767
- code: 'UNAUTHORIZED',
7768
- });
7769
- }
7770
-
7771
- return opts.next({ ctx: { session } });
7772
- });
7773
- `
7774
- );
7775
- sourceFile.addStatements(
7776
- /* ts */
7777
- `
7778
7763
  export const createAction = createTRPCServerActionHandler(t, createContext);
7779
7764
  `
7780
7765
  );
@@ -7786,14 +7771,17 @@ export const protectedProcedure = publicProcedure.use((opts) => {
7786
7771
  sourceFile.addStatements(
7787
7772
  /* ts */
7788
7773
  `
7789
- export const ${procName} = t.procedure
7790
- `
7774
+ export const ${procName} = t.procedure`
7791
7775
  );
7792
7776
  }
7793
7777
  sourceFile.addStatements(
7794
7778
  /* ts */
7795
7779
  `
7796
- .use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})
7780
+ .use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})${config.withNext ? `.experimental_caller(
7781
+ experimental_nextAppDirCaller({
7782
+ normalizeFormData: true,
7783
+ }),
7784
+ )` : ""}
7797
7785
  `
7798
7786
  );
7799
7787
  });
@@ -11636,7 +11624,7 @@ async function generate(options) {
11636
11624
  queries.sort();
11637
11625
  mutations.sort();
11638
11626
  subscriptions.sort();
11639
- if (config.withShield !== false) {
11627
+ if (config.withShields !== false) {
11640
11628
  consoleLog("Generating tRPC Shield");
11641
11629
  const shieldOutputDir = outputDir;
11642
11630
  consoleLog("Constructing tRPC Shield source file");
@@ -11691,8 +11679,8 @@ export default {${config.withNext ? "\n transformer," : ""}
11691
11679
  overwrite: true
11692
11680
  });
11693
11681
  consoleLog("Generating tRPC imports");
11694
- if (config.withShield) {
11695
- await generateShieldImport(createRouter, options, config.withShield);
11682
+ if (config.withShields) {
11683
+ await generateShieldImport(createRouter, options, config.withShields);
11696
11684
  }
11697
11685
  consoleLog("Generating tRPC base router");
11698
11686
  await generateBaseRouter(createRouter, config, options);
@@ -11762,7 +11750,7 @@ export default {${config.withNext ? "\n transformer," : ""}
11762
11750
  routerStatements.push(
11763
11751
  /* ts */
11764
11752
  `
11765
- ${model.toLowerCase()}: ${plural}Router`
11753
+ ${lowerCaseFirst(model)}: ${plural}Router`
11766
11754
  );
11767
11755
  consoleLog(`Generated tRPC router for model ${model} with ${modelActions.length} actions`);
11768
11756
  }
package/dist/index.js CHANGED
@@ -6884,13 +6884,13 @@ var configMiddleware = z.union([
6884
6884
  ]);
6885
6885
  var configShield = z.union([
6886
6886
  configBoolean,
6887
- z.string().default("../src/trpc/shield")
6887
+ z.string().default("../src/trpc/shields")
6888
6888
  ]);
6889
6889
  var modelActionEnum = z.nativeEnum(ModelAction);
6890
6890
  var configSchema = z.object({
6891
6891
  debug: configBoolean.default("false"),
6892
- withMiddleware: configMiddleware.default("true"),
6893
- withShield: configShield.default("true"),
6892
+ withMiddleware: configMiddleware.default("false"),
6893
+ withShields: configShield.default("true"),
6894
6894
  withZod: configBoolean.default("true"),
6895
6895
  withNext: configBoolean.default("true"),
6896
6896
  contextPath: z.string().default("../src/trpc/context"),
@@ -7623,7 +7623,7 @@ __name(getRelativePath, "getRelativePath");
7623
7623
 
7624
7624
  // src/helpers.ts
7625
7625
  var getProcedureName = /* @__PURE__ */ __name((config) => {
7626
- return config.withShield ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
7626
+ return config.withShields ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
7627
7627
  }, "getProcedureName");
7628
7628
  var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config }) => {
7629
7629
  const imports = [
@@ -7633,14 +7633,14 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7633
7633
  imports.push(getProcedureName(config));
7634
7634
  }
7635
7635
  sourceFile.addImportDeclaration({
7636
- moduleSpecifier: "./helpers/createRouter",
7636
+ moduleSpecifier: "../trpc",
7637
7637
  namedImports: imports
7638
7638
  });
7639
7639
  }, "generateCreateRouterImport");
7640
7640
  var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7641
7641
  const internals = await getPrismaInternals();
7642
7642
  const outputDir = internals.parseEnvValue(options.generator.output);
7643
- let shieldPath = getRelativePath(outputDir, "shield/shield");
7643
+ let shieldPath = getRelativePath(outputDir, "shield");
7644
7644
  if (typeof value === "string") {
7645
7645
  shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
7646
7646
  }
@@ -7683,6 +7683,7 @@ async function generateBaseRouter(sourceFile, config, options) {
7683
7683
  `
7684
7684
  import { createContext } from '${relativeContextPath}';
7685
7685
  import { initTRPC, TRPCError } from '@trpc/server';
7686
+ import { experimental_nextAppDirCaller } from '@trpc/server/adapters/next-app-dir';
7686
7687
  import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
7687
7688
  `
7688
7689
  );
@@ -7731,7 +7732,7 @@ async function generateBaseRouter(sourceFile, config, options) {
7731
7732
  )
7732
7733
  });
7733
7734
  }
7734
- if (config.withShield) {
7735
+ if (config.withShields) {
7735
7736
  sourceFile.addStatements(
7736
7737
  /* ts */
7737
7738
  `
@@ -7764,22 +7765,6 @@ export const createCallerFactory = t.createCallerFactory;`
7764
7765
  sourceFile.addStatements(
7765
7766
  /* ts */
7766
7767
  `
7767
- export const protectedProcedure = publicProcedure.use((opts) => {
7768
- const { session } = opts.ctx;
7769
-
7770
- if (!session?.user) {
7771
- throw new TRPCError({
7772
- code: 'UNAUTHORIZED',
7773
- });
7774
- }
7775
-
7776
- return opts.next({ ctx: { session } });
7777
- });
7778
- `
7779
- );
7780
- sourceFile.addStatements(
7781
- /* ts */
7782
- `
7783
7768
  export const createAction = createTRPCServerActionHandler(t, createContext);
7784
7769
  `
7785
7770
  );
@@ -7791,14 +7776,17 @@ export const protectedProcedure = publicProcedure.use((opts) => {
7791
7776
  sourceFile.addStatements(
7792
7777
  /* ts */
7793
7778
  `
7794
- export const ${procName} = t.procedure
7795
- `
7779
+ export const ${procName} = t.procedure`
7796
7780
  );
7797
7781
  }
7798
7782
  sourceFile.addStatements(
7799
7783
  /* ts */
7800
7784
  `
7801
- .use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})
7785
+ .use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})${config.withNext ? `.experimental_caller(
7786
+ experimental_nextAppDirCaller({
7787
+ normalizeFormData: true,
7788
+ }),
7789
+ )` : ""}
7802
7790
  `
7803
7791
  );
7804
7792
  });
@@ -11641,7 +11629,7 @@ async function generate(options) {
11641
11629
  queries.sort();
11642
11630
  mutations.sort();
11643
11631
  subscriptions.sort();
11644
- if (config.withShield !== false) {
11632
+ if (config.withShields !== false) {
11645
11633
  consoleLog("Generating tRPC Shield");
11646
11634
  const shieldOutputDir = outputDir;
11647
11635
  consoleLog("Constructing tRPC Shield source file");
@@ -11696,8 +11684,8 @@ export default {${config.withNext ? "\n transformer," : ""}
11696
11684
  overwrite: true
11697
11685
  });
11698
11686
  consoleLog("Generating tRPC imports");
11699
- if (config.withShield) {
11700
- await generateShieldImport(createRouter, options, config.withShield);
11687
+ if (config.withShields) {
11688
+ await generateShieldImport(createRouter, options, config.withShields);
11701
11689
  }
11702
11690
  consoleLog("Generating tRPC base router");
11703
11691
  await generateBaseRouter(createRouter, config, options);
@@ -11767,7 +11755,7 @@ export default {${config.withNext ? "\n transformer," : ""}
11767
11755
  routerStatements.push(
11768
11756
  /* ts */
11769
11757
  `
11770
- ${model.toLowerCase()}: ${plural}Router`
11758
+ ${lowerCaseFirst(model)}: ${plural}Router`
11771
11759
  );
11772
11760
  consoleLog(`Generated tRPC router for model ${model} with ${modelActions.length} actions`);
11773
11761
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/prisma-trpc-generator",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
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": {