@stryke/prisma-trpc-generator 0.7.2 → 0.7.3

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.
@@ -7326,28 +7326,6 @@ function resolvePaths(...paths) {
7326
7326
  return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath2(path6))));
7327
7327
  }
7328
7328
  __name(resolvePaths, "resolvePaths");
7329
- function relativePath(from, to) {
7330
- const _from = resolvePath(from).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7331
- const _to = resolvePath(to).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7332
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7333
- return _to.join("/");
7334
- }
7335
- const _fromCopy = [
7336
- ..._from
7337
- ];
7338
- for (const segment of _fromCopy) {
7339
- if (_to[0] !== segment) {
7340
- break;
7341
- }
7342
- _from.shift();
7343
- _to.shift();
7344
- }
7345
- return [
7346
- ..._from.map(() => ".."),
7347
- ..._to
7348
- ].join("/");
7349
- }
7350
- __name(relativePath, "relativePath");
7351
7329
 
7352
7330
  // ../string-format/src/lower-case-first.ts
7353
7331
  init_cjs_shims();
@@ -7603,15 +7581,15 @@ __name(getPrismaGeneratorHelper, "getPrismaGeneratorHelper");
7603
7581
  // src/utils/get-relative-path.ts
7604
7582
  init_cjs_shims();
7605
7583
  var import_node_path3 = __toESM(require("node:path"), 1);
7606
- function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath) {
7607
- const fromPath = import_node_path3.default.join(outputPath, "routers", "helpers");
7584
+ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath, fromPath) {
7585
+ const _fromPath = fromPath || outputPath;
7608
7586
  let toPath = import_node_path3.default.join(outputPath, filePath);
7609
7587
  if (isOutsideOutputPath) {
7610
7588
  const schemaPathSplit = schemaPath?.split(import_node_path3.default.sep);
7611
7589
  const schemaPathWithoutFileAndExtension = schemaPathSplit.slice(0, schemaPathSplit.length - 1).join(import_node_path3.default.posix.sep);
7612
7590
  toPath = import_node_path3.default.join(schemaPathWithoutFileAndExtension, filePath);
7613
7591
  }
7614
- const newPath = import_node_path3.default.relative(fromPath, toPath).split(import_node_path3.default.sep).join(import_node_path3.default.posix.sep);
7592
+ const newPath = import_node_path3.default.relative(_fromPath, toPath).split(import_node_path3.default.sep).join(import_node_path3.default.posix.sep);
7615
7593
  return newPath;
7616
7594
  }
7617
7595
  __name(getRelativePath, "getRelativePath");
@@ -7952,7 +7930,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7952
7930
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7953
7931
  return `export const permissions = ${shieldObjectText};`;
7954
7932
  }, "wrapWithExport");
7955
- var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, shieldOutputDir) => {
7933
+ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, outputDir) => {
7956
7934
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
7957
7935
  return "";
7958
7936
  }
@@ -7979,7 +7957,7 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
7979
7957
  return "";
7980
7958
  }
7981
7959
  let shieldText = getImports("trpc-shield");
7982
- shieldText += getImports("context", relativePath(shieldOutputDir, joinPaths(options.schemaPath, config.contextPath)));
7960
+ shieldText += getImports("context", getRelativePath(outputDir, config.contextPath, true, options.schemaPath));
7983
7961
  shieldText += "\n\n";
7984
7962
  shieldText += wrapWithExport({
7985
7963
  shieldObjectText: wrapWithTrpcShieldCall({
@@ -10326,11 +10304,11 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
10326
10304
  }, "writeFileSafely");
10327
10305
  var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
10328
10306
  const rows = Array.from(indexExports).map((filePath) => {
10329
- let relativePath2 = import_node_path4.default.relative(import_node_path4.default.dirname(indexPath), filePath);
10330
- if (relativePath2.endsWith(".ts")) {
10331
- relativePath2 = relativePath2.slice(0, relativePath2.lastIndexOf(".ts"));
10307
+ let relativePath = import_node_path4.default.relative(import_node_path4.default.dirname(indexPath), filePath);
10308
+ if (relativePath.endsWith(".ts")) {
10309
+ relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
10332
10310
  }
10333
- const normalized = correctPath(relativePath2);
10311
+ const normalized = correctPath(relativePath);
10334
10312
  return `export * from './${normalized}'`;
10335
10313
  });
10336
10314
  await writeFileSafely(indexPath, rows.join("\n"), false);
@@ -11617,7 +11595,7 @@ async function generate(options) {
11617
11595
  consoleLog("Skipping tRPC Shield generation as path provided already exists");
11618
11596
  } else {
11619
11597
  consoleLog("Constructing tRPC Shield source file");
11620
- const shieldOutputDir = typeof config.withShield === "string" ? findFilePath(config.withShield) : outputDir;
11598
+ const shieldOutputDir = typeof config.withShield === "string" && config.withShield !== "true" ? findFilePath(config.withShield) : outputDir;
11621
11599
  const shieldText = await constructShield({
11622
11600
  queries,
11623
11601
  mutations,
package/dist/generator.js CHANGED
@@ -7331,28 +7331,6 @@ function resolvePaths(...paths) {
7331
7331
  return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath2(path6))));
7332
7332
  }
7333
7333
  __name(resolvePaths, "resolvePaths");
7334
- function relativePath(from, to) {
7335
- const _from = resolvePath(from).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7336
- const _to = resolvePath(to).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7337
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7338
- return _to.join("/");
7339
- }
7340
- const _fromCopy = [
7341
- ..._from
7342
- ];
7343
- for (const segment of _fromCopy) {
7344
- if (_to[0] !== segment) {
7345
- break;
7346
- }
7347
- _from.shift();
7348
- _to.shift();
7349
- }
7350
- return [
7351
- ..._from.map(() => ".."),
7352
- ..._to
7353
- ].join("/");
7354
- }
7355
- __name(relativePath, "relativePath");
7356
7334
 
7357
7335
  // ../string-format/src/lower-case-first.ts
7358
7336
  init_esm_shims();
@@ -7608,15 +7586,15 @@ __name(getPrismaGeneratorHelper, "getPrismaGeneratorHelper");
7608
7586
  // src/utils/get-relative-path.ts
7609
7587
  init_esm_shims();
7610
7588
  import path2 from "node:path";
7611
- function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath) {
7612
- const fromPath = path2.join(outputPath, "routers", "helpers");
7589
+ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath, fromPath) {
7590
+ const _fromPath = fromPath || outputPath;
7613
7591
  let toPath = path2.join(outputPath, filePath);
7614
7592
  if (isOutsideOutputPath) {
7615
7593
  const schemaPathSplit = schemaPath?.split(path2.sep);
7616
7594
  const schemaPathWithoutFileAndExtension = schemaPathSplit.slice(0, schemaPathSplit.length - 1).join(path2.posix.sep);
7617
7595
  toPath = path2.join(schemaPathWithoutFileAndExtension, filePath);
7618
7596
  }
7619
- const newPath = path2.relative(fromPath, toPath).split(path2.sep).join(path2.posix.sep);
7597
+ const newPath = path2.relative(_fromPath, toPath).split(path2.sep).join(path2.posix.sep);
7620
7598
  return newPath;
7621
7599
  }
7622
7600
  __name(getRelativePath, "getRelativePath");
@@ -7957,7 +7935,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7957
7935
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7958
7936
  return `export const permissions = ${shieldObjectText};`;
7959
7937
  }, "wrapWithExport");
7960
- var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, shieldOutputDir) => {
7938
+ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, outputDir) => {
7961
7939
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
7962
7940
  return "";
7963
7941
  }
@@ -7984,7 +7962,7 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
7984
7962
  return "";
7985
7963
  }
7986
7964
  let shieldText = getImports("trpc-shield");
7987
- shieldText += getImports("context", relativePath(shieldOutputDir, joinPaths(options.schemaPath, config.contextPath)));
7965
+ shieldText += getImports("context", getRelativePath(outputDir, config.contextPath, true, options.schemaPath));
7988
7966
  shieldText += "\n\n";
7989
7967
  shieldText += wrapWithExport({
7990
7968
  shieldObjectText: wrapWithTrpcShieldCall({
@@ -10331,11 +10309,11 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
10331
10309
  }, "writeFileSafely");
10332
10310
  var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
10333
10311
  const rows = Array.from(indexExports).map((filePath) => {
10334
- let relativePath2 = path3.relative(path3.dirname(indexPath), filePath);
10335
- if (relativePath2.endsWith(".ts")) {
10336
- relativePath2 = relativePath2.slice(0, relativePath2.lastIndexOf(".ts"));
10312
+ let relativePath = path3.relative(path3.dirname(indexPath), filePath);
10313
+ if (relativePath.endsWith(".ts")) {
10314
+ relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
10337
10315
  }
10338
- const normalized = correctPath(relativePath2);
10316
+ const normalized = correctPath(relativePath);
10339
10317
  return `export * from './${normalized}'`;
10340
10318
  });
10341
10319
  await writeFileSafely(indexPath, rows.join("\n"), false);
@@ -11622,7 +11600,7 @@ async function generate(options) {
11622
11600
  consoleLog("Skipping tRPC Shield generation as path provided already exists");
11623
11601
  } else {
11624
11602
  consoleLog("Constructing tRPC Shield source file");
11625
- const shieldOutputDir = typeof config.withShield === "string" ? findFilePath(config.withShield) : outputDir;
11603
+ const shieldOutputDir = typeof config.withShield === "string" && config.withShield !== "true" ? findFilePath(config.withShield) : outputDir;
11626
11604
  const shieldText = await constructShield({
11627
11605
  queries,
11628
11606
  mutations,
package/dist/index.cjs CHANGED
@@ -7322,28 +7322,6 @@ function resolvePaths(...paths) {
7322
7322
  return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath2(path6))));
7323
7323
  }
7324
7324
  __name(resolvePaths, "resolvePaths");
7325
- function relativePath(from, to) {
7326
- const _from = resolvePath(from).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7327
- const _to = resolvePath(to).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7328
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7329
- return _to.join("/");
7330
- }
7331
- const _fromCopy = [
7332
- ..._from
7333
- ];
7334
- for (const segment of _fromCopy) {
7335
- if (_to[0] !== segment) {
7336
- break;
7337
- }
7338
- _from.shift();
7339
- _to.shift();
7340
- }
7341
- return [
7342
- ..._from.map(() => ".."),
7343
- ..._to
7344
- ].join("/");
7345
- }
7346
- __name(relativePath, "relativePath");
7347
7325
 
7348
7326
  // ../string-format/src/lower-case-first.ts
7349
7327
  init_cjs_shims();
@@ -7599,15 +7577,15 @@ __name(getPrismaGeneratorHelper, "getPrismaGeneratorHelper");
7599
7577
  // src/utils/get-relative-path.ts
7600
7578
  init_cjs_shims();
7601
7579
  var import_node_path3 = __toESM(require("node:path"), 1);
7602
- function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath) {
7603
- const fromPath = import_node_path3.default.join(outputPath, "routers", "helpers");
7580
+ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath, fromPath) {
7581
+ const _fromPath = fromPath || outputPath;
7604
7582
  let toPath = import_node_path3.default.join(outputPath, filePath);
7605
7583
  if (isOutsideOutputPath) {
7606
7584
  const schemaPathSplit = schemaPath?.split(import_node_path3.default.sep);
7607
7585
  const schemaPathWithoutFileAndExtension = schemaPathSplit.slice(0, schemaPathSplit.length - 1).join(import_node_path3.default.posix.sep);
7608
7586
  toPath = import_node_path3.default.join(schemaPathWithoutFileAndExtension, filePath);
7609
7587
  }
7610
- const newPath = import_node_path3.default.relative(fromPath, toPath).split(import_node_path3.default.sep).join(import_node_path3.default.posix.sep);
7588
+ const newPath = import_node_path3.default.relative(_fromPath, toPath).split(import_node_path3.default.sep).join(import_node_path3.default.posix.sep);
7611
7589
  return newPath;
7612
7590
  }
7613
7591
  __name(getRelativePath, "getRelativePath");
@@ -7948,7 +7926,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7948
7926
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7949
7927
  return `export const permissions = ${shieldObjectText};`;
7950
7928
  }, "wrapWithExport");
7951
- var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, shieldOutputDir) => {
7929
+ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, outputDir) => {
7952
7930
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
7953
7931
  return "";
7954
7932
  }
@@ -7975,7 +7953,7 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
7975
7953
  return "";
7976
7954
  }
7977
7955
  let shieldText = getImports("trpc-shield");
7978
- shieldText += getImports("context", relativePath(shieldOutputDir, joinPaths(options.schemaPath, config.contextPath)));
7956
+ shieldText += getImports("context", getRelativePath(outputDir, config.contextPath, true, options.schemaPath));
7979
7957
  shieldText += "\n\n";
7980
7958
  shieldText += wrapWithExport({
7981
7959
  shieldObjectText: wrapWithTrpcShieldCall({
@@ -10322,11 +10300,11 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
10322
10300
  }, "writeFileSafely");
10323
10301
  var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
10324
10302
  const rows = Array.from(indexExports).map((filePath) => {
10325
- let relativePath2 = import_node_path4.default.relative(import_node_path4.default.dirname(indexPath), filePath);
10326
- if (relativePath2.endsWith(".ts")) {
10327
- relativePath2 = relativePath2.slice(0, relativePath2.lastIndexOf(".ts"));
10303
+ let relativePath = import_node_path4.default.relative(import_node_path4.default.dirname(indexPath), filePath);
10304
+ if (relativePath.endsWith(".ts")) {
10305
+ relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
10328
10306
  }
10329
- const normalized = correctPath(relativePath2);
10307
+ const normalized = correctPath(relativePath);
10330
10308
  return `export * from './${normalized}'`;
10331
10309
  });
10332
10310
  await writeFileSafely(indexPath, rows.join("\n"), false);
@@ -11613,7 +11591,7 @@ async function generate(options) {
11613
11591
  consoleLog("Skipping tRPC Shield generation as path provided already exists");
11614
11592
  } else {
11615
11593
  consoleLog("Constructing tRPC Shield source file");
11616
- const shieldOutputDir = typeof config.withShield === "string" ? findFilePath(config.withShield) : outputDir;
11594
+ const shieldOutputDir = typeof config.withShield === "string" && config.withShield !== "true" ? findFilePath(config.withShield) : outputDir;
11617
11595
  const shieldText = await constructShield({
11618
11596
  queries,
11619
11597
  mutations,
package/dist/index.js CHANGED
@@ -7327,28 +7327,6 @@ function resolvePaths(...paths) {
7327
7327
  return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath2(path6))));
7328
7328
  }
7329
7329
  __name(resolvePaths, "resolvePaths");
7330
- function relativePath(from, to) {
7331
- const _from = resolvePath(from).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7332
- const _to = resolvePath(to).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7333
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7334
- return _to.join("/");
7335
- }
7336
- const _fromCopy = [
7337
- ..._from
7338
- ];
7339
- for (const segment of _fromCopy) {
7340
- if (_to[0] !== segment) {
7341
- break;
7342
- }
7343
- _from.shift();
7344
- _to.shift();
7345
- }
7346
- return [
7347
- ..._from.map(() => ".."),
7348
- ..._to
7349
- ].join("/");
7350
- }
7351
- __name(relativePath, "relativePath");
7352
7330
 
7353
7331
  // ../string-format/src/lower-case-first.ts
7354
7332
  init_esm_shims();
@@ -7604,15 +7582,15 @@ __name(getPrismaGeneratorHelper, "getPrismaGeneratorHelper");
7604
7582
  // src/utils/get-relative-path.ts
7605
7583
  init_esm_shims();
7606
7584
  import path2 from "node:path";
7607
- function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath) {
7608
- const fromPath = path2.join(outputPath, "routers", "helpers");
7585
+ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath, fromPath) {
7586
+ const _fromPath = fromPath || outputPath;
7609
7587
  let toPath = path2.join(outputPath, filePath);
7610
7588
  if (isOutsideOutputPath) {
7611
7589
  const schemaPathSplit = schemaPath?.split(path2.sep);
7612
7590
  const schemaPathWithoutFileAndExtension = schemaPathSplit.slice(0, schemaPathSplit.length - 1).join(path2.posix.sep);
7613
7591
  toPath = path2.join(schemaPathWithoutFileAndExtension, filePath);
7614
7592
  }
7615
- const newPath = path2.relative(fromPath, toPath).split(path2.sep).join(path2.posix.sep);
7593
+ const newPath = path2.relative(_fromPath, toPath).split(path2.sep).join(path2.posix.sep);
7616
7594
  return newPath;
7617
7595
  }
7618
7596
  __name(getRelativePath, "getRelativePath");
@@ -7953,7 +7931,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7953
7931
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7954
7932
  return `export const permissions = ${shieldObjectText};`;
7955
7933
  }, "wrapWithExport");
7956
- var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, shieldOutputDir) => {
7934
+ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, outputDir) => {
7957
7935
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
7958
7936
  return "";
7959
7937
  }
@@ -7980,7 +7958,7 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
7980
7958
  return "";
7981
7959
  }
7982
7960
  let shieldText = getImports("trpc-shield");
7983
- shieldText += getImports("context", relativePath(shieldOutputDir, joinPaths(options.schemaPath, config.contextPath)));
7961
+ shieldText += getImports("context", getRelativePath(outputDir, config.contextPath, true, options.schemaPath));
7984
7962
  shieldText += "\n\n";
7985
7963
  shieldText += wrapWithExport({
7986
7964
  shieldObjectText: wrapWithTrpcShieldCall({
@@ -10327,11 +10305,11 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
10327
10305
  }, "writeFileSafely");
10328
10306
  var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
10329
10307
  const rows = Array.from(indexExports).map((filePath) => {
10330
- let relativePath2 = path3.relative(path3.dirname(indexPath), filePath);
10331
- if (relativePath2.endsWith(".ts")) {
10332
- relativePath2 = relativePath2.slice(0, relativePath2.lastIndexOf(".ts"));
10308
+ let relativePath = path3.relative(path3.dirname(indexPath), filePath);
10309
+ if (relativePath.endsWith(".ts")) {
10310
+ relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
10333
10311
  }
10334
- const normalized = correctPath(relativePath2);
10312
+ const normalized = correctPath(relativePath);
10335
10313
  return `export * from './${normalized}'`;
10336
10314
  });
10337
10315
  await writeFileSafely(indexPath, rows.join("\n"), false);
@@ -11618,7 +11596,7 @@ async function generate(options) {
11618
11596
  consoleLog("Skipping tRPC Shield generation as path provided already exists");
11619
11597
  } else {
11620
11598
  consoleLog("Constructing tRPC Shield source file");
11621
- const shieldOutputDir = typeof config.withShield === "string" ? findFilePath(config.withShield) : outputDir;
11599
+ const shieldOutputDir = typeof config.withShield === "string" && config.withShield !== "true" ? findFilePath(config.withShield) : outputDir;
11622
11600
  const shieldText = await constructShield({
11623
11601
  queries,
11624
11602
  mutations,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/prisma-trpc-generator",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
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": {