@stryke/prisma-trpc-generator 0.10.0 → 0.10.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.
@@ -7671,13 +7671,13 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
7671
7671
  sourceFile.addStatements(
7672
7672
  /* ts */
7673
7673
  `
7674
- import defaultMiddleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
7674
+ import middleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
7675
7675
  `
7676
7676
  );
7677
7677
  sourceFile.addStatements(
7678
7678
  /* ts */
7679
7679
  `
7680
- export const globalMiddleware = t.middleware(defaultMiddleware);`
7680
+ export const globalMiddleware = t.middleware(middleware);`
7681
7681
  );
7682
7682
  middlewares.push({
7683
7683
  type: "global",
@@ -10705,7 +10705,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10705
10705
  if (lines.length === 0) {
10706
10706
  return [];
10707
10707
  }
10708
- let alternatives = lines.reduce((result, inputType) => {
10708
+ let alternatives = lines.slice(0, 1).reduce((result, inputType) => {
10709
10709
  if (inputType.type === "String") {
10710
10710
  result.push(this.wrapWithZodValidators("z.string()", field));
10711
10711
  } else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
@@ -10729,7 +10729,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10729
10729
  if (inputType.type !== this.name && typeof inputType.type === "string") {
10730
10730
  this.addSchemaImport(inputType.type);
10731
10731
  }
10732
- result.push(this.generatePrismaStringLine(field, lines.length));
10732
+ result.push(this.generatePrismaStringLine(field, inputType, lines.length));
10733
10733
  }
10734
10734
  }
10735
10735
  return result;
@@ -10768,11 +10768,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10768
10768
  addSchemaImport(name) {
10769
10769
  this.schemaImports.add(name);
10770
10770
  }
10771
- generatePrismaStringLine(field, inputsLength) {
10772
- if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
10773
- return "";
10774
- }
10775
- const inputType = field.inputTypes[0];
10771
+ generatePrismaStringLine(field, inputType, inputsLength) {
10776
10772
  const isEnum = inputType.location === "enumTypes";
10777
10773
  const inputTypeString = inputType.type;
10778
10774
  const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
@@ -10898,8 +10894,8 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10898
10894
  };
10899
10895
  }
10900
10896
  resolveModelQuerySchemaName(modelName, queryName) {
10901
- const modelNameCapitalized = modelName.charAt(0).toUpperCase() + modelName.slice(1);
10902
- const queryNameCapitalized = queryName.charAt(0).toUpperCase() + queryName.slice(1);
10897
+ const modelNameCapitalized = upperCaseFirst(modelName);
10898
+ const queryNameCapitalized = upperCaseFirst(queryName);
10903
10899
  return `${modelNameCapitalized}${queryNameCapitalized}Schema`;
10904
10900
  }
10905
10901
  wrapWithZodUnion(zodStringFields) {
@@ -11726,8 +11722,9 @@ ${JSON.stringify(config)}`);
11726
11722
  appRouter.addStatements(
11727
11723
  /* ts */
11728
11724
  `
11729
- export const appRouter = t.router({${routerStatements.join()}})
11730
- `
11725
+ export const appRouter = t.router({${routerStatements.join()}});
11726
+
11727
+ export type AppRouter = typeof appRouter;`
11731
11728
  );
11732
11729
  appRouter.formatText({
11733
11730
  indentSize: 2
package/dist/generator.js CHANGED
@@ -7676,13 +7676,13 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
7676
7676
  sourceFile.addStatements(
7677
7677
  /* ts */
7678
7678
  `
7679
- import defaultMiddleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
7679
+ import middleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
7680
7680
  `
7681
7681
  );
7682
7682
  sourceFile.addStatements(
7683
7683
  /* ts */
7684
7684
  `
7685
- export const globalMiddleware = t.middleware(defaultMiddleware);`
7685
+ export const globalMiddleware = t.middleware(middleware);`
7686
7686
  );
7687
7687
  middlewares.push({
7688
7688
  type: "global",
@@ -10710,7 +10710,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10710
10710
  if (lines.length === 0) {
10711
10711
  return [];
10712
10712
  }
10713
- let alternatives = lines.reduce((result, inputType) => {
10713
+ let alternatives = lines.slice(0, 1).reduce((result, inputType) => {
10714
10714
  if (inputType.type === "String") {
10715
10715
  result.push(this.wrapWithZodValidators("z.string()", field));
10716
10716
  } else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
@@ -10734,7 +10734,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10734
10734
  if (inputType.type !== this.name && typeof inputType.type === "string") {
10735
10735
  this.addSchemaImport(inputType.type);
10736
10736
  }
10737
- result.push(this.generatePrismaStringLine(field, lines.length));
10737
+ result.push(this.generatePrismaStringLine(field, inputType, lines.length));
10738
10738
  }
10739
10739
  }
10740
10740
  return result;
@@ -10773,11 +10773,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10773
10773
  addSchemaImport(name) {
10774
10774
  this.schemaImports.add(name);
10775
10775
  }
10776
- generatePrismaStringLine(field, inputsLength) {
10777
- if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
10778
- return "";
10779
- }
10780
- const inputType = field.inputTypes[0];
10776
+ generatePrismaStringLine(field, inputType, inputsLength) {
10781
10777
  const isEnum = inputType.location === "enumTypes";
10782
10778
  const inputTypeString = inputType.type;
10783
10779
  const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
@@ -10903,8 +10899,8 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10903
10899
  };
10904
10900
  }
10905
10901
  resolveModelQuerySchemaName(modelName, queryName) {
10906
- const modelNameCapitalized = modelName.charAt(0).toUpperCase() + modelName.slice(1);
10907
- const queryNameCapitalized = queryName.charAt(0).toUpperCase() + queryName.slice(1);
10902
+ const modelNameCapitalized = upperCaseFirst(modelName);
10903
+ const queryNameCapitalized = upperCaseFirst(queryName);
10908
10904
  return `${modelNameCapitalized}${queryNameCapitalized}Schema`;
10909
10905
  }
10910
10906
  wrapWithZodUnion(zodStringFields) {
@@ -11731,8 +11727,9 @@ ${JSON.stringify(config)}`);
11731
11727
  appRouter.addStatements(
11732
11728
  /* ts */
11733
11729
  `
11734
- export const appRouter = t.router({${routerStatements.join()}})
11735
- `
11730
+ export const appRouter = t.router({${routerStatements.join()}});
11731
+
11732
+ export type AppRouter = typeof appRouter;`
11736
11733
  );
11737
11734
  appRouter.formatText({
11738
11735
  indentSize: 2
package/dist/index.cjs CHANGED
@@ -7667,13 +7667,13 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
7667
7667
  sourceFile.addStatements(
7668
7668
  /* ts */
7669
7669
  `
7670
- import defaultMiddleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
7670
+ import middleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
7671
7671
  `
7672
7672
  );
7673
7673
  sourceFile.addStatements(
7674
7674
  /* ts */
7675
7675
  `
7676
- export const globalMiddleware = t.middleware(defaultMiddleware);`
7676
+ export const globalMiddleware = t.middleware(middleware);`
7677
7677
  );
7678
7678
  middlewares.push({
7679
7679
  type: "global",
@@ -10701,7 +10701,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10701
10701
  if (lines.length === 0) {
10702
10702
  return [];
10703
10703
  }
10704
- let alternatives = lines.reduce((result, inputType) => {
10704
+ let alternatives = lines.slice(0, 1).reduce((result, inputType) => {
10705
10705
  if (inputType.type === "String") {
10706
10706
  result.push(this.wrapWithZodValidators("z.string()", field));
10707
10707
  } else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
@@ -10725,7 +10725,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10725
10725
  if (inputType.type !== this.name && typeof inputType.type === "string") {
10726
10726
  this.addSchemaImport(inputType.type);
10727
10727
  }
10728
- result.push(this.generatePrismaStringLine(field, lines.length));
10728
+ result.push(this.generatePrismaStringLine(field, inputType, lines.length));
10729
10729
  }
10730
10730
  }
10731
10731
  return result;
@@ -10764,11 +10764,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10764
10764
  addSchemaImport(name) {
10765
10765
  this.schemaImports.add(name);
10766
10766
  }
10767
- generatePrismaStringLine(field, inputsLength) {
10768
- if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
10769
- return "";
10770
- }
10771
- const inputType = field.inputTypes[0];
10767
+ generatePrismaStringLine(field, inputType, inputsLength) {
10772
10768
  const isEnum = inputType.location === "enumTypes";
10773
10769
  const inputTypeString = inputType.type;
10774
10770
  const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
@@ -10894,8 +10890,8 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10894
10890
  };
10895
10891
  }
10896
10892
  resolveModelQuerySchemaName(modelName, queryName) {
10897
- const modelNameCapitalized = modelName.charAt(0).toUpperCase() + modelName.slice(1);
10898
- const queryNameCapitalized = queryName.charAt(0).toUpperCase() + queryName.slice(1);
10893
+ const modelNameCapitalized = upperCaseFirst(modelName);
10894
+ const queryNameCapitalized = upperCaseFirst(queryName);
10899
10895
  return `${modelNameCapitalized}${queryNameCapitalized}Schema`;
10900
10896
  }
10901
10897
  wrapWithZodUnion(zodStringFields) {
@@ -11722,8 +11718,9 @@ ${JSON.stringify(config)}`);
11722
11718
  appRouter.addStatements(
11723
11719
  /* ts */
11724
11720
  `
11725
- export const appRouter = t.router({${routerStatements.join()}})
11726
- `
11721
+ export const appRouter = t.router({${routerStatements.join()}});
11722
+
11723
+ export type AppRouter = typeof appRouter;`
11727
11724
  );
11728
11725
  appRouter.formatText({
11729
11726
  indentSize: 2
package/dist/index.js CHANGED
@@ -7672,13 +7672,13 @@ async function generateTRPCExports(sourceFile, config, options, outputDir) {
7672
7672
  sourceFile.addStatements(
7673
7673
  /* ts */
7674
7674
  `
7675
- import defaultMiddleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
7675
+ import middleware from '${relativePath(outputDir, joinPaths(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
7676
7676
  `
7677
7677
  );
7678
7678
  sourceFile.addStatements(
7679
7679
  /* ts */
7680
7680
  `
7681
- export const globalMiddleware = t.middleware(defaultMiddleware);`
7681
+ export const globalMiddleware = t.middleware(middleware);`
7682
7682
  );
7683
7683
  middlewares.push({
7684
7684
  type: "global",
@@ -10706,7 +10706,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10706
10706
  if (lines.length === 0) {
10707
10707
  return [];
10708
10708
  }
10709
- let alternatives = lines.reduce((result, inputType) => {
10709
+ let alternatives = lines.slice(0, 1).reduce((result, inputType) => {
10710
10710
  if (inputType.type === "String") {
10711
10711
  result.push(this.wrapWithZodValidators("z.string()", field));
10712
10712
  } else if (inputType.type === "Int" || inputType.type === "Float" || inputType.type === "Decimal") {
@@ -10730,7 +10730,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10730
10730
  if (inputType.type !== this.name && typeof inputType.type === "string") {
10731
10731
  this.addSchemaImport(inputType.type);
10732
10732
  }
10733
- result.push(this.generatePrismaStringLine(field, lines.length));
10733
+ result.push(this.generatePrismaStringLine(field, inputType, lines.length));
10734
10734
  }
10735
10735
  }
10736
10736
  return result;
@@ -10769,11 +10769,7 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10769
10769
  addSchemaImport(name) {
10770
10770
  this.schemaImports.add(name);
10771
10771
  }
10772
- generatePrismaStringLine(field, inputsLength) {
10773
- if (field.inputTypes.length === 0 || !field.inputTypes[0]) {
10774
- return "";
10775
- }
10776
- const inputType = field.inputTypes[0];
10772
+ generatePrismaStringLine(field, inputType, inputsLength) {
10777
10773
  const isEnum = inputType.location === "enumTypes";
10778
10774
  const inputTypeString = inputType.type;
10779
10775
  const { isModelQueryType, modelName, queryName } = this.checkIsModelQueryType(inputTypeString);
@@ -10899,8 +10895,8 @@ ${this.generateExportSchemaStatement(`${name}`, `z.enum(${JSON.stringify(values)
10899
10895
  };
10900
10896
  }
10901
10897
  resolveModelQuerySchemaName(modelName, queryName) {
10902
- const modelNameCapitalized = modelName.charAt(0).toUpperCase() + modelName.slice(1);
10903
- const queryNameCapitalized = queryName.charAt(0).toUpperCase() + queryName.slice(1);
10898
+ const modelNameCapitalized = upperCaseFirst(modelName);
10899
+ const queryNameCapitalized = upperCaseFirst(queryName);
10904
10900
  return `${modelNameCapitalized}${queryNameCapitalized}Schema`;
10905
10901
  }
10906
10902
  wrapWithZodUnion(zodStringFields) {
@@ -11727,8 +11723,9 @@ ${JSON.stringify(config)}`);
11727
11723
  appRouter.addStatements(
11728
11724
  /* ts */
11729
11725
  `
11730
- export const appRouter = t.router({${routerStatements.join()}})
11731
- `
11726
+ export const appRouter = t.router({${routerStatements.join()}});
11727
+
11728
+ export type AppRouter = typeof appRouter;`
11732
11729
  );
11733
11730
  appRouter.formatText({
11734
11731
  indentSize: 2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/prisma-trpc-generator",
3
- "version": "0.10.0",
3
+ "version": "0.10.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": {