@stryke/prisma-trpc-generator 0.7.6 → 0.8.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.
@@ -7926,7 +7926,7 @@ var getImports = /* @__PURE__ */ __name((type, newPath) => {
7926
7926
  if (type === "trpc") {
7927
7927
  statement = "import * as trpc from '@trpc/server';\n";
7928
7928
  } else if (type === "trpc-shield") {
7929
- statement = "import { shield, allow } from 'trpc-shield';\n";
7929
+ statement = "import { shield, allow } from '@stryke/trpc-next/shield';\n";
7930
7930
  } else if (type === "context") {
7931
7931
  statement = `import type { Context } from '${newPath}';
7932
7932
  `;
@@ -11634,21 +11634,49 @@ async function generate(options) {
11634
11634
  const trpcOptionsOutputPath = joinPaths(outputDir, "options.ts");
11635
11635
  consoleLog("Generating tRPC options source file");
11636
11636
  await writeFileSafely(trpcOptionsOutputPath, `import { ZodError } from 'zod';${config.withNext ? '\nimport { transformer } from "@stryke/trpc-next/shared";' : ""}
11637
+ import type {
11638
+ DataTransformerOptions,
11639
+ RootConfig
11640
+ } from "@trpc/server/unstable-core-do-not-import";
11641
+ import type { Context } from "../context";
11637
11642
 
11638
- export default {${config.withNext ? "\n transformer," : ""}
11643
+ interface RuntimeConfigOptions<
11644
+ TContext extends object,
11645
+ TMeta extends object = object
11646
+ > extends Partial<
11647
+ Omit<
11648
+ RootConfig<{
11649
+ ctx: TContext;
11650
+ meta: TMeta;
11651
+ errorShape: any;
11652
+ transformer: any;
11653
+ }>,
11654
+ "$types" | "transformer"
11655
+ >
11656
+ > {
11657
+ /**
11658
+ * Use a data transformer
11659
+ * @see https://trpc.io/docs/v11/data-transformers
11660
+ */
11661
+ transformer?: DataTransformerOptions;
11662
+ }
11663
+
11664
+ const options: RuntimeConfigOptions<Context> = {${config.withNext ? "\n transformer," : ""}
11639
11665
  errorFormatter({ shape, error }) {
11640
11666
  return {
11641
11667
  ...shape,
11642
11668
  data: {
11643
11669
  ...shape.data,
11644
11670
  zodError:
11645
- error.code === 'BAD_REQUEST' && error.cause instanceof ZodError
11671
+ error.code === "BAD_REQUEST" && error.cause instanceof ZodError
11646
11672
  ? error.cause.flatten()
11647
- : null,
11648
- },
11673
+ : null
11674
+ }
11649
11675
  };
11650
- },
11676
+ }
11651
11677
  };
11678
+
11679
+ export default options;
11652
11680
  `);
11653
11681
  }
11654
11682
  resolveModelsComments(models, hiddenModels);
package/dist/generator.js CHANGED
@@ -7931,7 +7931,7 @@ var getImports = /* @__PURE__ */ __name((type, newPath) => {
7931
7931
  if (type === "trpc") {
7932
7932
  statement = "import * as trpc from '@trpc/server';\n";
7933
7933
  } else if (type === "trpc-shield") {
7934
- statement = "import { shield, allow } from 'trpc-shield';\n";
7934
+ statement = "import { shield, allow } from '@stryke/trpc-next/shield';\n";
7935
7935
  } else if (type === "context") {
7936
7936
  statement = `import type { Context } from '${newPath}';
7937
7937
  `;
@@ -11639,21 +11639,49 @@ async function generate(options) {
11639
11639
  const trpcOptionsOutputPath = joinPaths(outputDir, "options.ts");
11640
11640
  consoleLog("Generating tRPC options source file");
11641
11641
  await writeFileSafely(trpcOptionsOutputPath, `import { ZodError } from 'zod';${config.withNext ? '\nimport { transformer } from "@stryke/trpc-next/shared";' : ""}
11642
+ import type {
11643
+ DataTransformerOptions,
11644
+ RootConfig
11645
+ } from "@trpc/server/unstable-core-do-not-import";
11646
+ import type { Context } from "../context";
11642
11647
 
11643
- export default {${config.withNext ? "\n transformer," : ""}
11648
+ interface RuntimeConfigOptions<
11649
+ TContext extends object,
11650
+ TMeta extends object = object
11651
+ > extends Partial<
11652
+ Omit<
11653
+ RootConfig<{
11654
+ ctx: TContext;
11655
+ meta: TMeta;
11656
+ errorShape: any;
11657
+ transformer: any;
11658
+ }>,
11659
+ "$types" | "transformer"
11660
+ >
11661
+ > {
11662
+ /**
11663
+ * Use a data transformer
11664
+ * @see https://trpc.io/docs/v11/data-transformers
11665
+ */
11666
+ transformer?: DataTransformerOptions;
11667
+ }
11668
+
11669
+ const options: RuntimeConfigOptions<Context> = {${config.withNext ? "\n transformer," : ""}
11644
11670
  errorFormatter({ shape, error }) {
11645
11671
  return {
11646
11672
  ...shape,
11647
11673
  data: {
11648
11674
  ...shape.data,
11649
11675
  zodError:
11650
- error.code === 'BAD_REQUEST' && error.cause instanceof ZodError
11676
+ error.code === "BAD_REQUEST" && error.cause instanceof ZodError
11651
11677
  ? error.cause.flatten()
11652
- : null,
11653
- },
11678
+ : null
11679
+ }
11654
11680
  };
11655
- },
11681
+ }
11656
11682
  };
11683
+
11684
+ export default options;
11657
11685
  `);
11658
11686
  }
11659
11687
  resolveModelsComments(models, hiddenModels);
package/dist/index.cjs CHANGED
@@ -7922,7 +7922,7 @@ var getImports = /* @__PURE__ */ __name((type, newPath) => {
7922
7922
  if (type === "trpc") {
7923
7923
  statement = "import * as trpc from '@trpc/server';\n";
7924
7924
  } else if (type === "trpc-shield") {
7925
- statement = "import { shield, allow } from 'trpc-shield';\n";
7925
+ statement = "import { shield, allow } from '@stryke/trpc-next/shield';\n";
7926
7926
  } else if (type === "context") {
7927
7927
  statement = `import type { Context } from '${newPath}';
7928
7928
  `;
@@ -11630,21 +11630,49 @@ async function generate(options) {
11630
11630
  const trpcOptionsOutputPath = joinPaths(outputDir, "options.ts");
11631
11631
  consoleLog("Generating tRPC options source file");
11632
11632
  await writeFileSafely(trpcOptionsOutputPath, `import { ZodError } from 'zod';${config.withNext ? '\nimport { transformer } from "@stryke/trpc-next/shared";' : ""}
11633
+ import type {
11634
+ DataTransformerOptions,
11635
+ RootConfig
11636
+ } from "@trpc/server/unstable-core-do-not-import";
11637
+ import type { Context } from "../context";
11633
11638
 
11634
- export default {${config.withNext ? "\n transformer," : ""}
11639
+ interface RuntimeConfigOptions<
11640
+ TContext extends object,
11641
+ TMeta extends object = object
11642
+ > extends Partial<
11643
+ Omit<
11644
+ RootConfig<{
11645
+ ctx: TContext;
11646
+ meta: TMeta;
11647
+ errorShape: any;
11648
+ transformer: any;
11649
+ }>,
11650
+ "$types" | "transformer"
11651
+ >
11652
+ > {
11653
+ /**
11654
+ * Use a data transformer
11655
+ * @see https://trpc.io/docs/v11/data-transformers
11656
+ */
11657
+ transformer?: DataTransformerOptions;
11658
+ }
11659
+
11660
+ const options: RuntimeConfigOptions<Context> = {${config.withNext ? "\n transformer," : ""}
11635
11661
  errorFormatter({ shape, error }) {
11636
11662
  return {
11637
11663
  ...shape,
11638
11664
  data: {
11639
11665
  ...shape.data,
11640
11666
  zodError:
11641
- error.code === 'BAD_REQUEST' && error.cause instanceof ZodError
11667
+ error.code === "BAD_REQUEST" && error.cause instanceof ZodError
11642
11668
  ? error.cause.flatten()
11643
- : null,
11644
- },
11669
+ : null
11670
+ }
11645
11671
  };
11646
- },
11672
+ }
11647
11673
  };
11674
+
11675
+ export default options;
11648
11676
  `);
11649
11677
  }
11650
11678
  resolveModelsComments(models, hiddenModels);
package/dist/index.js CHANGED
@@ -7927,7 +7927,7 @@ var getImports = /* @__PURE__ */ __name((type, newPath) => {
7927
7927
  if (type === "trpc") {
7928
7928
  statement = "import * as trpc from '@trpc/server';\n";
7929
7929
  } else if (type === "trpc-shield") {
7930
- statement = "import { shield, allow } from 'trpc-shield';\n";
7930
+ statement = "import { shield, allow } from '@stryke/trpc-next/shield';\n";
7931
7931
  } else if (type === "context") {
7932
7932
  statement = `import type { Context } from '${newPath}';
7933
7933
  `;
@@ -11635,21 +11635,49 @@ async function generate(options) {
11635
11635
  const trpcOptionsOutputPath = joinPaths(outputDir, "options.ts");
11636
11636
  consoleLog("Generating tRPC options source file");
11637
11637
  await writeFileSafely(trpcOptionsOutputPath, `import { ZodError } from 'zod';${config.withNext ? '\nimport { transformer } from "@stryke/trpc-next/shared";' : ""}
11638
+ import type {
11639
+ DataTransformerOptions,
11640
+ RootConfig
11641
+ } from "@trpc/server/unstable-core-do-not-import";
11642
+ import type { Context } from "../context";
11638
11643
 
11639
- export default {${config.withNext ? "\n transformer," : ""}
11644
+ interface RuntimeConfigOptions<
11645
+ TContext extends object,
11646
+ TMeta extends object = object
11647
+ > extends Partial<
11648
+ Omit<
11649
+ RootConfig<{
11650
+ ctx: TContext;
11651
+ meta: TMeta;
11652
+ errorShape: any;
11653
+ transformer: any;
11654
+ }>,
11655
+ "$types" | "transformer"
11656
+ >
11657
+ > {
11658
+ /**
11659
+ * Use a data transformer
11660
+ * @see https://trpc.io/docs/v11/data-transformers
11661
+ */
11662
+ transformer?: DataTransformerOptions;
11663
+ }
11664
+
11665
+ const options: RuntimeConfigOptions<Context> = {${config.withNext ? "\n transformer," : ""}
11640
11666
  errorFormatter({ shape, error }) {
11641
11667
  return {
11642
11668
  ...shape,
11643
11669
  data: {
11644
11670
  ...shape.data,
11645
11671
  zodError:
11646
- error.code === 'BAD_REQUEST' && error.cause instanceof ZodError
11672
+ error.code === "BAD_REQUEST" && error.cause instanceof ZodError
11647
11673
  ? error.cause.flatten()
11648
- : null,
11649
- },
11674
+ : null
11675
+ }
11650
11676
  };
11651
- },
11677
+ }
11652
11678
  };
11679
+
11680
+ export default options;
11653
11681
  `);
11654
11682
  }
11655
11683
  resolveModelsComments(models, hiddenModels);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/prisma-trpc-generator",
3
- "version": "0.7.6",
3
+ "version": "0.8.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": {