@stryke/prisma-trpc-generator 0.7.4 → 0.7.6

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.
@@ -7334,6 +7334,28 @@ function resolvePaths(...paths) {
7334
7334
  return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath2(path6))));
7335
7335
  }
7336
7336
  __name(resolvePaths, "resolvePaths");
7337
+ function relativePath(from, to) {
7338
+ const _from = resolvePath(from).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7339
+ const _to = resolvePath(to).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7340
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7341
+ return _to.join("/");
7342
+ }
7343
+ const _fromCopy = [
7344
+ ..._from
7345
+ ];
7346
+ for (const segment of _fromCopy) {
7347
+ if (_to[0] !== segment) {
7348
+ break;
7349
+ }
7350
+ _from.shift();
7351
+ _to.shift();
7352
+ }
7353
+ return [
7354
+ ..._from.map(() => ".."),
7355
+ ..._to
7356
+ ].join("/");
7357
+ }
7358
+ __name(relativePath, "relativePath");
7337
7359
 
7338
7360
  // ../string-format/src/lower-case-first.ts
7339
7361
  init_cjs_shims();
@@ -7371,14 +7393,14 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
7371
7393
  }(ModelAction || {});
7372
7394
  var modelActionEnum = z.nativeEnum(ModelAction);
7373
7395
  var configSchema = z.object({
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),
7396
+ debug: z.coerce.boolean().or(z.string()).default(false),
7397
+ withMiddleware: z.coerce.boolean().or(z.string()).default(false),
7398
+ withShield: z.coerce.boolean().or(z.string()).default(true),
7399
+ withZod: z.coerce.boolean().or(z.string()).default(true),
7400
+ withNext: z.coerce.boolean().or(z.string()).default(true),
7379
7401
  contextPath: z.string().default("../src/trpc/context"),
7380
- trpcOptions: z.boolean().or(z.string()).default(true),
7381
- showModelNameInProcedure: z.boolean().default(true),
7402
+ trpcOptions: z.coerce.boolean().or(z.string()).default(true),
7403
+ showModelNameInProcedure: z.coerce.boolean().or(z.string()).default(true),
7382
7404
  generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
7383
7405
  return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
7384
7406
  })
@@ -7589,7 +7611,7 @@ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath,
7589
7611
  const schemaPathWithoutFileAndExtension = schemaPathSplit.slice(0, schemaPathSplit.length - 1).join(import_node_path3.default.posix.sep);
7590
7612
  toPath = import_node_path3.default.join(schemaPathWithoutFileAndExtension, filePath);
7591
7613
  }
7592
- const newPath = import_node_path3.default.relative(_fromPath, toPath).split(import_node_path3.default.sep).join(import_node_path3.default.posix.sep);
7614
+ const newPath = relativePath(_fromPath, toPath).split(import_node_path3.default.sep).join(import_node_path3.default.posix.sep);
7593
7615
  return newPath;
7594
7616
  }
7595
7617
  __name(getRelativePath, "getRelativePath");
@@ -7700,7 +7722,8 @@ async function generateBaseRouter(sourceFile, config, options) {
7700
7722
  sourceFile.addStatements(
7701
7723
  /* ts */
7702
7724
  `
7703
- export const permissionsMiddleware = t.middleware(permissions); `
7725
+ export const permissionsMiddleware = t.middleware(permissions);
7726
+ `
7704
7727
  );
7705
7728
  middlewares.push({
7706
7729
  type: "shield",
@@ -7725,14 +7748,6 @@ export const createCallerFactory = t.createCallerFactory;`
7725
7748
  `
7726
7749
  export const publicProcedure = t.procedure; `
7727
7750
  );
7728
- if (config.withNext) {
7729
- sourceFile.addStatements(
7730
- /* ts */
7731
- `
7732
- export const createAction = createTRPCServerActionHandler(t, createContext);
7733
- `
7734
- );
7735
- }
7736
7751
  if (middlewares.length > 0) {
7737
7752
  const procName = getProcedureName(config);
7738
7753
  middlewares.forEach((middleware, i) => {
@@ -7749,6 +7764,15 @@ export const createCallerFactory = t.createCallerFactory;`
7749
7764
  );
7750
7765
  });
7751
7766
  }
7767
+ if (config.withNext) {
7768
+ sourceFile.addStatements(
7769
+ /* ts */
7770
+ `
7771
+ export const createAction: ReturnType<typeof createTRPCServerActionHandler> =
7772
+ createTRPCServerActionHandler(t, createContext);
7773
+ `
7774
+ );
7775
+ }
7752
7776
  }
7753
7777
  __name(generateBaseRouter, "generateBaseRouter");
7754
7778
  function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOpType, config) {
@@ -7926,7 +7950,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7926
7950
  return wrapped;
7927
7951
  }, "wrapWithTrpcShieldCall");
7928
7952
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7929
- return `export const permissions = ${shieldObjectText};`;
7953
+ return `export const permissions: ReturnType<typeof shield<Context>> = ${shieldObjectText};`;
7930
7954
  }, "wrapWithExport");
7931
7955
  var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, outputDir) => {
7932
7956
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
@@ -10302,11 +10326,11 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
10302
10326
  }, "writeFileSafely");
10303
10327
  var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
10304
10328
  const rows = Array.from(indexExports).map((filePath) => {
10305
- let relativePath = import_node_path4.default.relative(import_node_path4.default.dirname(indexPath), filePath);
10306
- if (relativePath.endsWith(".ts")) {
10307
- relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
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"));
10308
10332
  }
10309
- const normalized = correctPath(relativePath);
10333
+ const normalized = correctPath(relativePath2);
10310
10334
  return `export * from './${normalized}'`;
10311
10335
  });
10312
10336
  await writeFileSafely(indexPath, rows.join("\n"), false);
package/dist/generator.js CHANGED
@@ -7339,6 +7339,28 @@ function resolvePaths(...paths) {
7339
7339
  return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath2(path6))));
7340
7340
  }
7341
7341
  __name(resolvePaths, "resolvePaths");
7342
+ function relativePath(from, to) {
7343
+ const _from = resolvePath(from).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7344
+ const _to = resolvePath(to).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7345
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7346
+ return _to.join("/");
7347
+ }
7348
+ const _fromCopy = [
7349
+ ..._from
7350
+ ];
7351
+ for (const segment of _fromCopy) {
7352
+ if (_to[0] !== segment) {
7353
+ break;
7354
+ }
7355
+ _from.shift();
7356
+ _to.shift();
7357
+ }
7358
+ return [
7359
+ ..._from.map(() => ".."),
7360
+ ..._to
7361
+ ].join("/");
7362
+ }
7363
+ __name(relativePath, "relativePath");
7342
7364
 
7343
7365
  // ../string-format/src/lower-case-first.ts
7344
7366
  init_esm_shims();
@@ -7376,14 +7398,14 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
7376
7398
  }(ModelAction || {});
7377
7399
  var modelActionEnum = z.nativeEnum(ModelAction);
7378
7400
  var configSchema = z.object({
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),
7401
+ debug: z.coerce.boolean().or(z.string()).default(false),
7402
+ withMiddleware: z.coerce.boolean().or(z.string()).default(false),
7403
+ withShield: z.coerce.boolean().or(z.string()).default(true),
7404
+ withZod: z.coerce.boolean().or(z.string()).default(true),
7405
+ withNext: z.coerce.boolean().or(z.string()).default(true),
7384
7406
  contextPath: z.string().default("../src/trpc/context"),
7385
- trpcOptions: z.boolean().or(z.string()).default(true),
7386
- showModelNameInProcedure: z.boolean().default(true),
7407
+ trpcOptions: z.coerce.boolean().or(z.string()).default(true),
7408
+ showModelNameInProcedure: z.coerce.boolean().or(z.string()).default(true),
7387
7409
  generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
7388
7410
  return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
7389
7411
  })
@@ -7594,7 +7616,7 @@ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath,
7594
7616
  const schemaPathWithoutFileAndExtension = schemaPathSplit.slice(0, schemaPathSplit.length - 1).join(path2.posix.sep);
7595
7617
  toPath = path2.join(schemaPathWithoutFileAndExtension, filePath);
7596
7618
  }
7597
- const newPath = path2.relative(_fromPath, toPath).split(path2.sep).join(path2.posix.sep);
7619
+ const newPath = relativePath(_fromPath, toPath).split(path2.sep).join(path2.posix.sep);
7598
7620
  return newPath;
7599
7621
  }
7600
7622
  __name(getRelativePath, "getRelativePath");
@@ -7705,7 +7727,8 @@ async function generateBaseRouter(sourceFile, config, options) {
7705
7727
  sourceFile.addStatements(
7706
7728
  /* ts */
7707
7729
  `
7708
- export const permissionsMiddleware = t.middleware(permissions); `
7730
+ export const permissionsMiddleware = t.middleware(permissions);
7731
+ `
7709
7732
  );
7710
7733
  middlewares.push({
7711
7734
  type: "shield",
@@ -7730,14 +7753,6 @@ export const createCallerFactory = t.createCallerFactory;`
7730
7753
  `
7731
7754
  export const publicProcedure = t.procedure; `
7732
7755
  );
7733
- if (config.withNext) {
7734
- sourceFile.addStatements(
7735
- /* ts */
7736
- `
7737
- export const createAction = createTRPCServerActionHandler(t, createContext);
7738
- `
7739
- );
7740
- }
7741
7756
  if (middlewares.length > 0) {
7742
7757
  const procName = getProcedureName(config);
7743
7758
  middlewares.forEach((middleware, i) => {
@@ -7754,6 +7769,15 @@ export const createCallerFactory = t.createCallerFactory;`
7754
7769
  );
7755
7770
  });
7756
7771
  }
7772
+ if (config.withNext) {
7773
+ sourceFile.addStatements(
7774
+ /* ts */
7775
+ `
7776
+ export const createAction: ReturnType<typeof createTRPCServerActionHandler> =
7777
+ createTRPCServerActionHandler(t, createContext);
7778
+ `
7779
+ );
7780
+ }
7757
7781
  }
7758
7782
  __name(generateBaseRouter, "generateBaseRouter");
7759
7783
  function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOpType, config) {
@@ -7931,7 +7955,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7931
7955
  return wrapped;
7932
7956
  }, "wrapWithTrpcShieldCall");
7933
7957
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7934
- return `export const permissions = ${shieldObjectText};`;
7958
+ return `export const permissions: ReturnType<typeof shield<Context>> = ${shieldObjectText};`;
7935
7959
  }, "wrapWithExport");
7936
7960
  var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, outputDir) => {
7937
7961
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
@@ -10307,11 +10331,11 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
10307
10331
  }, "writeFileSafely");
10308
10332
  var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
10309
10333
  const rows = Array.from(indexExports).map((filePath) => {
10310
- let relativePath = path3.relative(path3.dirname(indexPath), filePath);
10311
- if (relativePath.endsWith(".ts")) {
10312
- relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
10334
+ let relativePath2 = path3.relative(path3.dirname(indexPath), filePath);
10335
+ if (relativePath2.endsWith(".ts")) {
10336
+ relativePath2 = relativePath2.slice(0, relativePath2.lastIndexOf(".ts"));
10313
10337
  }
10314
- const normalized = correctPath(relativePath);
10338
+ const normalized = correctPath(relativePath2);
10315
10339
  return `export * from './${normalized}'`;
10316
10340
  });
10317
10341
  await writeFileSafely(indexPath, rows.join("\n"), false);
package/dist/index.cjs CHANGED
@@ -7330,6 +7330,28 @@ function resolvePaths(...paths) {
7330
7330
  return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath2(path6))));
7331
7331
  }
7332
7332
  __name(resolvePaths, "resolvePaths");
7333
+ function relativePath(from, to) {
7334
+ const _from = resolvePath(from).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7335
+ const _to = resolvePath(to).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7336
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7337
+ return _to.join("/");
7338
+ }
7339
+ const _fromCopy = [
7340
+ ..._from
7341
+ ];
7342
+ for (const segment of _fromCopy) {
7343
+ if (_to[0] !== segment) {
7344
+ break;
7345
+ }
7346
+ _from.shift();
7347
+ _to.shift();
7348
+ }
7349
+ return [
7350
+ ..._from.map(() => ".."),
7351
+ ..._to
7352
+ ].join("/");
7353
+ }
7354
+ __name(relativePath, "relativePath");
7333
7355
 
7334
7356
  // ../string-format/src/lower-case-first.ts
7335
7357
  init_cjs_shims();
@@ -7367,14 +7389,14 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
7367
7389
  }(ModelAction || {});
7368
7390
  var modelActionEnum = z.nativeEnum(ModelAction);
7369
7391
  var configSchema = z.object({
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),
7392
+ debug: z.coerce.boolean().or(z.string()).default(false),
7393
+ withMiddleware: z.coerce.boolean().or(z.string()).default(false),
7394
+ withShield: z.coerce.boolean().or(z.string()).default(true),
7395
+ withZod: z.coerce.boolean().or(z.string()).default(true),
7396
+ withNext: z.coerce.boolean().or(z.string()).default(true),
7375
7397
  contextPath: z.string().default("../src/trpc/context"),
7376
- trpcOptions: z.boolean().or(z.string()).default(true),
7377
- showModelNameInProcedure: z.boolean().default(true),
7398
+ trpcOptions: z.coerce.boolean().or(z.string()).default(true),
7399
+ showModelNameInProcedure: z.coerce.boolean().or(z.string()).default(true),
7378
7400
  generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
7379
7401
  return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
7380
7402
  })
@@ -7585,7 +7607,7 @@ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath,
7585
7607
  const schemaPathWithoutFileAndExtension = schemaPathSplit.slice(0, schemaPathSplit.length - 1).join(import_node_path3.default.posix.sep);
7586
7608
  toPath = import_node_path3.default.join(schemaPathWithoutFileAndExtension, filePath);
7587
7609
  }
7588
- const newPath = import_node_path3.default.relative(_fromPath, toPath).split(import_node_path3.default.sep).join(import_node_path3.default.posix.sep);
7610
+ const newPath = relativePath(_fromPath, toPath).split(import_node_path3.default.sep).join(import_node_path3.default.posix.sep);
7589
7611
  return newPath;
7590
7612
  }
7591
7613
  __name(getRelativePath, "getRelativePath");
@@ -7696,7 +7718,8 @@ async function generateBaseRouter(sourceFile, config, options) {
7696
7718
  sourceFile.addStatements(
7697
7719
  /* ts */
7698
7720
  `
7699
- export const permissionsMiddleware = t.middleware(permissions); `
7721
+ export const permissionsMiddleware = t.middleware(permissions);
7722
+ `
7700
7723
  );
7701
7724
  middlewares.push({
7702
7725
  type: "shield",
@@ -7721,14 +7744,6 @@ export const createCallerFactory = t.createCallerFactory;`
7721
7744
  `
7722
7745
  export const publicProcedure = t.procedure; `
7723
7746
  );
7724
- if (config.withNext) {
7725
- sourceFile.addStatements(
7726
- /* ts */
7727
- `
7728
- export const createAction = createTRPCServerActionHandler(t, createContext);
7729
- `
7730
- );
7731
- }
7732
7747
  if (middlewares.length > 0) {
7733
7748
  const procName = getProcedureName(config);
7734
7749
  middlewares.forEach((middleware, i) => {
@@ -7745,6 +7760,15 @@ export const createCallerFactory = t.createCallerFactory;`
7745
7760
  );
7746
7761
  });
7747
7762
  }
7763
+ if (config.withNext) {
7764
+ sourceFile.addStatements(
7765
+ /* ts */
7766
+ `
7767
+ export const createAction: ReturnType<typeof createTRPCServerActionHandler> =
7768
+ createTRPCServerActionHandler(t, createContext);
7769
+ `
7770
+ );
7771
+ }
7748
7772
  }
7749
7773
  __name(generateBaseRouter, "generateBaseRouter");
7750
7774
  function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOpType, config) {
@@ -7922,7 +7946,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7922
7946
  return wrapped;
7923
7947
  }, "wrapWithTrpcShieldCall");
7924
7948
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7925
- return `export const permissions = ${shieldObjectText};`;
7949
+ return `export const permissions: ReturnType<typeof shield<Context>> = ${shieldObjectText};`;
7926
7950
  }, "wrapWithExport");
7927
7951
  var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, outputDir) => {
7928
7952
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
@@ -10298,11 +10322,11 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
10298
10322
  }, "writeFileSafely");
10299
10323
  var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
10300
10324
  const rows = Array.from(indexExports).map((filePath) => {
10301
- let relativePath = import_node_path4.default.relative(import_node_path4.default.dirname(indexPath), filePath);
10302
- if (relativePath.endsWith(".ts")) {
10303
- relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
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"));
10304
10328
  }
10305
- const normalized = correctPath(relativePath);
10329
+ const normalized = correctPath(relativePath2);
10306
10330
  return `export * from './${normalized}'`;
10307
10331
  });
10308
10332
  await writeFileSafely(indexPath, rows.join("\n"), false);
package/dist/index.js CHANGED
@@ -7335,6 +7335,28 @@ function resolvePaths(...paths) {
7335
7335
  return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath2(path6))));
7336
7336
  }
7337
7337
  __name(resolvePaths, "resolvePaths");
7338
+ function relativePath(from, to) {
7339
+ const _from = resolvePath(from).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7340
+ const _to = resolvePath(to).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7341
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7342
+ return _to.join("/");
7343
+ }
7344
+ const _fromCopy = [
7345
+ ..._from
7346
+ ];
7347
+ for (const segment of _fromCopy) {
7348
+ if (_to[0] !== segment) {
7349
+ break;
7350
+ }
7351
+ _from.shift();
7352
+ _to.shift();
7353
+ }
7354
+ return [
7355
+ ..._from.map(() => ".."),
7356
+ ..._to
7357
+ ].join("/");
7358
+ }
7359
+ __name(relativePath, "relativePath");
7338
7360
 
7339
7361
  // ../string-format/src/lower-case-first.ts
7340
7362
  init_esm_shims();
@@ -7372,14 +7394,14 @@ var ModelAction = /* @__PURE__ */ function(ModelAction2) {
7372
7394
  }(ModelAction || {});
7373
7395
  var modelActionEnum = z.nativeEnum(ModelAction);
7374
7396
  var configSchema = z.object({
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),
7397
+ debug: z.coerce.boolean().or(z.string()).default(false),
7398
+ withMiddleware: z.coerce.boolean().or(z.string()).default(false),
7399
+ withShield: z.coerce.boolean().or(z.string()).default(true),
7400
+ withZod: z.coerce.boolean().or(z.string()).default(true),
7401
+ withNext: z.coerce.boolean().or(z.string()).default(true),
7380
7402
  contextPath: z.string().default("../src/trpc/context"),
7381
- trpcOptions: z.boolean().or(z.string()).default(true),
7382
- showModelNameInProcedure: z.boolean().default(true),
7403
+ trpcOptions: z.coerce.boolean().or(z.string()).default(true),
7404
+ showModelNameInProcedure: z.coerce.boolean().or(z.string()).default(true),
7383
7405
  generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
7384
7406
  return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
7385
7407
  })
@@ -7590,7 +7612,7 @@ function getRelativePath(outputPath, filePath, isOutsideOutputPath, schemaPath,
7590
7612
  const schemaPathWithoutFileAndExtension = schemaPathSplit.slice(0, schemaPathSplit.length - 1).join(path2.posix.sep);
7591
7613
  toPath = path2.join(schemaPathWithoutFileAndExtension, filePath);
7592
7614
  }
7593
- const newPath = path2.relative(_fromPath, toPath).split(path2.sep).join(path2.posix.sep);
7615
+ const newPath = relativePath(_fromPath, toPath).split(path2.sep).join(path2.posix.sep);
7594
7616
  return newPath;
7595
7617
  }
7596
7618
  __name(getRelativePath, "getRelativePath");
@@ -7701,7 +7723,8 @@ async function generateBaseRouter(sourceFile, config, options) {
7701
7723
  sourceFile.addStatements(
7702
7724
  /* ts */
7703
7725
  `
7704
- export const permissionsMiddleware = t.middleware(permissions); `
7726
+ export const permissionsMiddleware = t.middleware(permissions);
7727
+ `
7705
7728
  );
7706
7729
  middlewares.push({
7707
7730
  type: "shield",
@@ -7726,14 +7749,6 @@ export const createCallerFactory = t.createCallerFactory;`
7726
7749
  `
7727
7750
  export const publicProcedure = t.procedure; `
7728
7751
  );
7729
- if (config.withNext) {
7730
- sourceFile.addStatements(
7731
- /* ts */
7732
- `
7733
- export const createAction = createTRPCServerActionHandler(t, createContext);
7734
- `
7735
- );
7736
- }
7737
7752
  if (middlewares.length > 0) {
7738
7753
  const procName = getProcedureName(config);
7739
7754
  middlewares.forEach((middleware, i) => {
@@ -7750,6 +7765,15 @@ export const createCallerFactory = t.createCallerFactory;`
7750
7765
  );
7751
7766
  });
7752
7767
  }
7768
+ if (config.withNext) {
7769
+ sourceFile.addStatements(
7770
+ /* ts */
7771
+ `
7772
+ export const createAction: ReturnType<typeof createTRPCServerActionHandler> =
7773
+ createTRPCServerActionHandler(t, createContext);
7774
+ `
7775
+ );
7776
+ }
7753
7777
  }
7754
7778
  __name(generateBaseRouter, "generateBaseRouter");
7755
7779
  function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOpType, config) {
@@ -7927,7 +7951,7 @@ var wrapWithTrpcShieldCall = /* @__PURE__ */ __name(({ shieldObjectTextWrapped }
7927
7951
  return wrapped;
7928
7952
  }, "wrapWithTrpcShieldCall");
7929
7953
  var wrapWithExport = /* @__PURE__ */ __name(({ shieldObjectText }) => {
7930
- return `export const permissions = ${shieldObjectText};`;
7954
+ return `export const permissions: ReturnType<typeof shield<Context>> = ${shieldObjectText};`;
7931
7955
  }, "wrapWithExport");
7932
7956
  var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscriptions }, config, options, outputDir) => {
7933
7957
  if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) {
@@ -10303,11 +10327,11 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
10303
10327
  }, "writeFileSafely");
10304
10328
  var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
10305
10329
  const rows = Array.from(indexExports).map((filePath) => {
10306
- let relativePath = path3.relative(path3.dirname(indexPath), filePath);
10307
- if (relativePath.endsWith(".ts")) {
10308
- relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
10330
+ let relativePath2 = path3.relative(path3.dirname(indexPath), filePath);
10331
+ if (relativePath2.endsWith(".ts")) {
10332
+ relativePath2 = relativePath2.slice(0, relativePath2.lastIndexOf(".ts"));
10309
10333
  }
10310
- const normalized = correctPath(relativePath);
10334
+ const normalized = correctPath(relativePath2);
10311
10335
  return `export * from './${normalized}'`;
10312
10336
  });
10313
10337
  await writeFileSafely(indexPath, rows.join("\n"), false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/prisma-trpc-generator",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
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": {