@stryke/prisma-trpc-generator 0.7.3 → 0.7.4

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.
@@ -7303,6 +7303,14 @@ function findFilePath(filePath) {
7303
7303
  }), "");
7304
7304
  }
7305
7305
  __name(findFilePath, "findFilePath");
7306
+ function findFileExtension(filePath) {
7307
+ if (filePath === "..") {
7308
+ return "";
7309
+ }
7310
+ const match = /.(\.[^./]+|\.)$/.exec(normalizeWindowsPath2(filePath));
7311
+ return match && match[1] || EMPTY_STRING;
7312
+ }
7313
+ __name(findFileExtension, "findFileExtension");
7306
7314
  function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
7307
7315
  const paths = normalizeWindowsPath2(path6).split("/");
7308
7316
  let resolvedPath = "";
@@ -7361,24 +7369,16 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
7361
7369
  ModelAction2["aggregateRaw"] = "aggregateRaw";
7362
7370
  return ModelAction2;
7363
7371
  }(ModelAction || {});
7364
- var configBoolean = z.enum([
7365
- "true",
7366
- "false"
7367
- ]).transform((arg) => JSON.parse(arg));
7368
- var configMiddleware = z.union([
7369
- configBoolean,
7370
- z.string().default("../src/trpc/middleware")
7371
- ]);
7372
7372
  var modelActionEnum = z.nativeEnum(ModelAction);
7373
7373
  var configSchema = z.object({
7374
- debug: configBoolean.default("false"),
7375
- withMiddleware: configMiddleware.default("false"),
7376
- withShield: z.boolean().or(z.string()).default("true"),
7377
- withZod: configBoolean.default("true"),
7378
- withNext: configBoolean.default("true"),
7374
+ debug: z.boolean().or(z.string()).default(false),
7375
+ withMiddleware: z.boolean().or(z.string()).default(false),
7376
+ withShield: z.boolean().or(z.string()).default(true),
7377
+ withZod: z.boolean().default(true),
7378
+ withNext: z.boolean().default(true),
7379
7379
  contextPath: z.string().default("../src/trpc/context"),
7380
- trpcOptions: z.boolean().or(z.string()).optional(),
7381
- showModelNameInProcedure: configBoolean.default("true"),
7380
+ trpcOptions: z.boolean().or(z.string()).default(true),
7381
+ showModelNameInProcedure: z.boolean().default(true),
7382
7382
  generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
7383
7383
  return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
7384
7384
  })
@@ -7610,9 +7610,7 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7610
7610
  namedImports: imports
7611
7611
  });
7612
7612
  }, "generateCreateRouterImport");
7613
- var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7614
- const internals = await getPrismaInternals();
7615
- const outputDir = internals.parseEnvValue(options.generator.output);
7613
+ var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, outputDir, value) => {
7616
7614
  let shieldPath = joinPaths(outputDir, "shield");
7617
7615
  if (typeof value === "string") {
7618
7616
  shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
@@ -11595,7 +11593,7 @@ async function generate(options) {
11595
11593
  consoleLog("Skipping tRPC Shield generation as path provided already exists");
11596
11594
  } else {
11597
11595
  consoleLog("Constructing tRPC Shield source file");
11598
- const shieldOutputDir = typeof config.withShield === "string" && config.withShield !== "true" ? findFilePath(config.withShield) : outputDir;
11596
+ const shieldOutputDir = typeof config.withShield === "string" ? findFileExtension(config.withShield) ? findFilePath(config.withShield) : config.withShield : outputDir;
11599
11597
  const shieldText = await constructShield({
11600
11598
  queries,
11601
11599
  mutations,
@@ -11630,16 +11628,16 @@ export default {${config.withNext ? "\n transformer," : ""}
11630
11628
  `);
11631
11629
  }
11632
11630
  resolveModelsComments(models, hiddenModels);
11633
- const createRouter = project.createSourceFile(import_node_path6.default.resolve(outputDir, "trpc.ts"), void 0, {
11631
+ const trpcExports = project.createSourceFile(import_node_path6.default.resolve(outputDir, "trpc.ts"), void 0, {
11634
11632
  overwrite: true
11635
11633
  });
11636
11634
  consoleLog("Generating tRPC imports");
11637
11635
  if (config.withShield) {
11638
- await generateShieldImport(createRouter, options, config.withShield);
11636
+ await generateShieldImport(trpcExports, options, outputDir, config.withShield);
11639
11637
  }
11640
11638
  consoleLog("Generating tRPC base router");
11641
- await generateBaseRouter(createRouter, config, options);
11642
- createRouter.formatText({
11639
+ await generateBaseRouter(trpcExports, config, options);
11640
+ trpcExports.formatText({
11643
11641
  indentSize: 2
11644
11642
  });
11645
11643
  const appRouter = project.createSourceFile(import_node_path6.default.resolve(outputDir, "routers", `index.ts`), void 0, {
package/dist/generator.js CHANGED
@@ -7308,6 +7308,14 @@ function findFilePath(filePath) {
7308
7308
  }), "");
7309
7309
  }
7310
7310
  __name(findFilePath, "findFilePath");
7311
+ function findFileExtension(filePath) {
7312
+ if (filePath === "..") {
7313
+ return "";
7314
+ }
7315
+ const match = /.(\.[^./]+|\.)$/.exec(normalizeWindowsPath2(filePath));
7316
+ return match && match[1] || EMPTY_STRING;
7317
+ }
7318
+ __name(findFileExtension, "findFileExtension");
7311
7319
  function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
7312
7320
  const paths = normalizeWindowsPath2(path6).split("/");
7313
7321
  let resolvedPath = "";
@@ -7366,24 +7374,16 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
7366
7374
  ModelAction2["aggregateRaw"] = "aggregateRaw";
7367
7375
  return ModelAction2;
7368
7376
  }(ModelAction || {});
7369
- var configBoolean = z.enum([
7370
- "true",
7371
- "false"
7372
- ]).transform((arg) => JSON.parse(arg));
7373
- var configMiddleware = z.union([
7374
- configBoolean,
7375
- z.string().default("../src/trpc/middleware")
7376
- ]);
7377
7377
  var modelActionEnum = z.nativeEnum(ModelAction);
7378
7378
  var configSchema = z.object({
7379
- debug: configBoolean.default("false"),
7380
- withMiddleware: configMiddleware.default("false"),
7381
- withShield: z.boolean().or(z.string()).default("true"),
7382
- withZod: configBoolean.default("true"),
7383
- withNext: configBoolean.default("true"),
7379
+ debug: z.boolean().or(z.string()).default(false),
7380
+ withMiddleware: z.boolean().or(z.string()).default(false),
7381
+ withShield: z.boolean().or(z.string()).default(true),
7382
+ withZod: z.boolean().default(true),
7383
+ withNext: z.boolean().default(true),
7384
7384
  contextPath: z.string().default("../src/trpc/context"),
7385
- trpcOptions: z.boolean().or(z.string()).optional(),
7386
- showModelNameInProcedure: configBoolean.default("true"),
7385
+ trpcOptions: z.boolean().or(z.string()).default(true),
7386
+ showModelNameInProcedure: z.boolean().default(true),
7387
7387
  generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
7388
7388
  return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
7389
7389
  })
@@ -7615,9 +7615,7 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7615
7615
  namedImports: imports
7616
7616
  });
7617
7617
  }, "generateCreateRouterImport");
7618
- var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7619
- const internals = await getPrismaInternals();
7620
- const outputDir = internals.parseEnvValue(options.generator.output);
7618
+ var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, outputDir, value) => {
7621
7619
  let shieldPath = joinPaths(outputDir, "shield");
7622
7620
  if (typeof value === "string") {
7623
7621
  shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
@@ -11600,7 +11598,7 @@ async function generate(options) {
11600
11598
  consoleLog("Skipping tRPC Shield generation as path provided already exists");
11601
11599
  } else {
11602
11600
  consoleLog("Constructing tRPC Shield source file");
11603
- const shieldOutputDir = typeof config.withShield === "string" && config.withShield !== "true" ? findFilePath(config.withShield) : outputDir;
11601
+ const shieldOutputDir = typeof config.withShield === "string" ? findFileExtension(config.withShield) ? findFilePath(config.withShield) : config.withShield : outputDir;
11604
11602
  const shieldText = await constructShield({
11605
11603
  queries,
11606
11604
  mutations,
@@ -11635,16 +11633,16 @@ export default {${config.withNext ? "\n transformer," : ""}
11635
11633
  `);
11636
11634
  }
11637
11635
  resolveModelsComments(models, hiddenModels);
11638
- const createRouter = project.createSourceFile(path5.resolve(outputDir, "trpc.ts"), void 0, {
11636
+ const trpcExports = project.createSourceFile(path5.resolve(outputDir, "trpc.ts"), void 0, {
11639
11637
  overwrite: true
11640
11638
  });
11641
11639
  consoleLog("Generating tRPC imports");
11642
11640
  if (config.withShield) {
11643
- await generateShieldImport(createRouter, options, config.withShield);
11641
+ await generateShieldImport(trpcExports, options, outputDir, config.withShield);
11644
11642
  }
11645
11643
  consoleLog("Generating tRPC base router");
11646
- await generateBaseRouter(createRouter, config, options);
11647
- createRouter.formatText({
11644
+ await generateBaseRouter(trpcExports, config, options);
11645
+ trpcExports.formatText({
11648
11646
  indentSize: 2
11649
11647
  });
11650
11648
  const appRouter = project.createSourceFile(path5.resolve(outputDir, "routers", `index.ts`), void 0, {
package/dist/index.cjs CHANGED
@@ -7299,6 +7299,14 @@ function findFilePath(filePath) {
7299
7299
  }), "");
7300
7300
  }
7301
7301
  __name(findFilePath, "findFilePath");
7302
+ function findFileExtension(filePath) {
7303
+ if (filePath === "..") {
7304
+ return "";
7305
+ }
7306
+ const match = /.(\.[^./]+|\.)$/.exec(normalizeWindowsPath2(filePath));
7307
+ return match && match[1] || EMPTY_STRING;
7308
+ }
7309
+ __name(findFileExtension, "findFileExtension");
7302
7310
  function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
7303
7311
  const paths = normalizeWindowsPath2(path6).split("/");
7304
7312
  let resolvedPath = "";
@@ -7357,24 +7365,16 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
7357
7365
  ModelAction2["aggregateRaw"] = "aggregateRaw";
7358
7366
  return ModelAction2;
7359
7367
  }(ModelAction || {});
7360
- var configBoolean = z.enum([
7361
- "true",
7362
- "false"
7363
- ]).transform((arg) => JSON.parse(arg));
7364
- var configMiddleware = z.union([
7365
- configBoolean,
7366
- z.string().default("../src/trpc/middleware")
7367
- ]);
7368
7368
  var modelActionEnum = z.nativeEnum(ModelAction);
7369
7369
  var configSchema = z.object({
7370
- debug: configBoolean.default("false"),
7371
- withMiddleware: configMiddleware.default("false"),
7372
- withShield: z.boolean().or(z.string()).default("true"),
7373
- withZod: configBoolean.default("true"),
7374
- withNext: configBoolean.default("true"),
7370
+ debug: z.boolean().or(z.string()).default(false),
7371
+ withMiddleware: z.boolean().or(z.string()).default(false),
7372
+ withShield: z.boolean().or(z.string()).default(true),
7373
+ withZod: z.boolean().default(true),
7374
+ withNext: z.boolean().default(true),
7375
7375
  contextPath: z.string().default("../src/trpc/context"),
7376
- trpcOptions: z.boolean().or(z.string()).optional(),
7377
- showModelNameInProcedure: configBoolean.default("true"),
7376
+ trpcOptions: z.boolean().or(z.string()).default(true),
7377
+ showModelNameInProcedure: z.boolean().default(true),
7378
7378
  generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
7379
7379
  return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
7380
7380
  })
@@ -7606,9 +7606,7 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7606
7606
  namedImports: imports
7607
7607
  });
7608
7608
  }, "generateCreateRouterImport");
7609
- var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7610
- const internals = await getPrismaInternals();
7611
- const outputDir = internals.parseEnvValue(options.generator.output);
7609
+ var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, outputDir, value) => {
7612
7610
  let shieldPath = joinPaths(outputDir, "shield");
7613
7611
  if (typeof value === "string") {
7614
7612
  shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
@@ -11591,7 +11589,7 @@ async function generate(options) {
11591
11589
  consoleLog("Skipping tRPC Shield generation as path provided already exists");
11592
11590
  } else {
11593
11591
  consoleLog("Constructing tRPC Shield source file");
11594
- const shieldOutputDir = typeof config.withShield === "string" && config.withShield !== "true" ? findFilePath(config.withShield) : outputDir;
11592
+ const shieldOutputDir = typeof config.withShield === "string" ? findFileExtension(config.withShield) ? findFilePath(config.withShield) : config.withShield : outputDir;
11595
11593
  const shieldText = await constructShield({
11596
11594
  queries,
11597
11595
  mutations,
@@ -11626,16 +11624,16 @@ export default {${config.withNext ? "\n transformer," : ""}
11626
11624
  `);
11627
11625
  }
11628
11626
  resolveModelsComments(models, hiddenModels);
11629
- const createRouter = project.createSourceFile(import_node_path6.default.resolve(outputDir, "trpc.ts"), void 0, {
11627
+ const trpcExports = project.createSourceFile(import_node_path6.default.resolve(outputDir, "trpc.ts"), void 0, {
11630
11628
  overwrite: true
11631
11629
  });
11632
11630
  consoleLog("Generating tRPC imports");
11633
11631
  if (config.withShield) {
11634
- await generateShieldImport(createRouter, options, config.withShield);
11632
+ await generateShieldImport(trpcExports, options, outputDir, config.withShield);
11635
11633
  }
11636
11634
  consoleLog("Generating tRPC base router");
11637
- await generateBaseRouter(createRouter, config, options);
11638
- createRouter.formatText({
11635
+ await generateBaseRouter(trpcExports, config, options);
11636
+ trpcExports.formatText({
11639
11637
  indentSize: 2
11640
11638
  });
11641
11639
  const appRouter = project.createSourceFile(import_node_path6.default.resolve(outputDir, "routers", `index.ts`), void 0, {
package/dist/index.js CHANGED
@@ -7304,6 +7304,14 @@ function findFilePath(filePath) {
7304
7304
  }), "");
7305
7305
  }
7306
7306
  __name(findFilePath, "findFilePath");
7307
+ function findFileExtension(filePath) {
7308
+ if (filePath === "..") {
7309
+ return "";
7310
+ }
7311
+ const match = /.(\.[^./]+|\.)$/.exec(normalizeWindowsPath2(filePath));
7312
+ return match && match[1] || EMPTY_STRING;
7313
+ }
7314
+ __name(findFileExtension, "findFileExtension");
7307
7315
  function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
7308
7316
  const paths = normalizeWindowsPath2(path6).split("/");
7309
7317
  let resolvedPath = "";
@@ -7362,24 +7370,16 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
7362
7370
  ModelAction2["aggregateRaw"] = "aggregateRaw";
7363
7371
  return ModelAction2;
7364
7372
  }(ModelAction || {});
7365
- var configBoolean = z.enum([
7366
- "true",
7367
- "false"
7368
- ]).transform((arg) => JSON.parse(arg));
7369
- var configMiddleware = z.union([
7370
- configBoolean,
7371
- z.string().default("../src/trpc/middleware")
7372
- ]);
7373
7373
  var modelActionEnum = z.nativeEnum(ModelAction);
7374
7374
  var configSchema = z.object({
7375
- debug: configBoolean.default("false"),
7376
- withMiddleware: configMiddleware.default("false"),
7377
- withShield: z.boolean().or(z.string()).default("true"),
7378
- withZod: configBoolean.default("true"),
7379
- withNext: configBoolean.default("true"),
7375
+ debug: z.boolean().or(z.string()).default(false),
7376
+ withMiddleware: z.boolean().or(z.string()).default(false),
7377
+ withShield: z.boolean().or(z.string()).default(true),
7378
+ withZod: z.boolean().default(true),
7379
+ withNext: z.boolean().default(true),
7380
7380
  contextPath: z.string().default("../src/trpc/context"),
7381
- trpcOptions: z.boolean().or(z.string()).optional(),
7382
- showModelNameInProcedure: configBoolean.default("true"),
7381
+ trpcOptions: z.boolean().or(z.string()).default(true),
7382
+ showModelNameInProcedure: z.boolean().default(true),
7383
7383
  generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
7384
7384
  return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
7385
7385
  })
@@ -7611,9 +7611,7 @@ var generateCreateRouterImport = /* @__PURE__ */ __name(({ sourceFile, config })
7611
7611
  namedImports: imports
7612
7612
  });
7613
7613
  }, "generateCreateRouterImport");
7614
- var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, value) => {
7615
- const internals = await getPrismaInternals();
7616
- const outputDir = internals.parseEnvValue(options.generator.output);
7614
+ var generateShieldImport = /* @__PURE__ */ __name(async (sourceFile, options, outputDir, value) => {
7617
7615
  let shieldPath = joinPaths(outputDir, "shield");
7618
7616
  if (typeof value === "string") {
7619
7617
  shieldPath = getRelativePath(outputDir, value, true, options.schemaPath);
@@ -11596,7 +11594,7 @@ async function generate(options) {
11596
11594
  consoleLog("Skipping tRPC Shield generation as path provided already exists");
11597
11595
  } else {
11598
11596
  consoleLog("Constructing tRPC Shield source file");
11599
- const shieldOutputDir = typeof config.withShield === "string" && config.withShield !== "true" ? findFilePath(config.withShield) : outputDir;
11597
+ const shieldOutputDir = typeof config.withShield === "string" ? findFileExtension(config.withShield) ? findFilePath(config.withShield) : config.withShield : outputDir;
11600
11598
  const shieldText = await constructShield({
11601
11599
  queries,
11602
11600
  mutations,
@@ -11631,16 +11629,16 @@ export default {${config.withNext ? "\n transformer," : ""}
11631
11629
  `);
11632
11630
  }
11633
11631
  resolveModelsComments(models, hiddenModels);
11634
- const createRouter = project.createSourceFile(path5.resolve(outputDir, "trpc.ts"), void 0, {
11632
+ const trpcExports = project.createSourceFile(path5.resolve(outputDir, "trpc.ts"), void 0, {
11635
11633
  overwrite: true
11636
11634
  });
11637
11635
  consoleLog("Generating tRPC imports");
11638
11636
  if (config.withShield) {
11639
- await generateShieldImport(createRouter, options, config.withShield);
11637
+ await generateShieldImport(trpcExports, options, outputDir, config.withShield);
11640
11638
  }
11641
11639
  consoleLog("Generating tRPC base router");
11642
- await generateBaseRouter(createRouter, config, options);
11643
- createRouter.formatText({
11640
+ await generateBaseRouter(trpcExports, config, options);
11641
+ trpcExports.formatText({
11644
11642
  indentSize: 2
11645
11643
  });
11646
11644
  const appRouter = project.createSourceFile(path5.resolve(outputDir, "routers", `index.ts`), void 0, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/prisma-trpc-generator",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
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": {