@stryke/prisma-trpc-generator 0.4.8 → 0.5.1

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.
@@ -2631,6 +2631,12 @@ function normalizeString(path6, allowAboveRoot) {
2631
2631
  }
2632
2632
  __name(normalizeString, "normalizeString");
2633
2633
 
2634
+ // ../string-format/src/lower-case-first.ts
2635
+ init_cjs_shims();
2636
+ var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
2637
+ return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
2638
+ }, "lowerCaseFirst");
2639
+
2634
2640
  // src/prisma-generator.ts
2635
2641
  var import_node_path6 = __toESM(require("node:path"), 1);
2636
2642
  var import_pluralize = __toESM(require_pluralize(), 1);
@@ -6886,8 +6892,9 @@ var configSchema = z.object({
6886
6892
  withShield: configShield.default("true"),
6887
6893
  withZod: configBoolean.default("true"),
6888
6894
  contextPath: z.string().default("../src/trpc/context"),
6889
- trpcOptionsPath: z.string().optional(),
6895
+ trpcOptions: z.boolean().or(z.string()).optional(),
6890
6896
  showModelNameInProcedure: configBoolean.default("true"),
6897
+ useTRPCNext: configBoolean.default("false"),
6891
6898
  generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
6892
6899
  return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
6893
6900
  })
@@ -6896,223 +6903,39 @@ var configSchema = z.object({
6896
6903
  // src/helpers.ts
6897
6904
  init_cjs_shims();
6898
6905
 
6899
- // ../string-format/src/lower-case-first.ts
6900
- init_cjs_shims();
6901
- var lowerCaseFirst = /* @__PURE__ */ __name((input) => {
6902
- return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
6903
- }, "lowerCaseFirst");
6904
-
6905
- // src/utils/get-prisma-internals.ts
6906
- init_cjs_shims();
6907
-
6908
- // src/utils/get-jiti.ts
6909
- init_cjs_shims();
6910
-
6911
- // ../env/src/get-env-paths.ts
6912
- init_cjs_shims();
6913
-
6914
- // ../string-format/src/title-case.ts
6915
- init_cjs_shims();
6916
-
6917
- // ../string-format/src/acronyms.ts
6918
- init_cjs_shims();
6919
- var ACRONYMS = [
6920
- "API",
6921
- "CPU",
6922
- "CSS",
6923
- "DNS",
6924
- "EOF",
6925
- "GUID",
6926
- "HTML",
6927
- "HTTP",
6928
- "HTTPS",
6929
- "ID",
6930
- "IP",
6931
- "JSON",
6932
- "LHS",
6933
- "OEM",
6934
- "PP",
6935
- "QA",
6936
- "RAM",
6937
- "RHS",
6938
- "RPC",
6939
- "RSS",
6940
- "SLA",
6941
- "SMTP",
6942
- "SQL",
6943
- "SSH",
6944
- "SSL",
6945
- "TCP",
6946
- "TLS",
6947
- "TRPC",
6948
- "TTL",
6949
- "UDP",
6950
- "UI",
6951
- "UID",
6952
- "UUID",
6953
- "URI",
6954
- "URL",
6955
- "UTF",
6956
- "VM",
6957
- "XML",
6958
- "XSS",
6959
- "XSRF"
6960
- ];
6961
-
6962
- // ../string-format/src/upper-case-first.ts
6963
- init_cjs_shims();
6964
- var upperCaseFirst = /* @__PURE__ */ __name((input) => {
6965
- return input ? input.charAt(0).toUpperCase() + input.slice(1) : input;
6966
- }, "upperCaseFirst");
6967
-
6968
- // ../string-format/src/title-case.ts
6969
- var titleCase = /* @__PURE__ */ __name((input) => {
6970
- if (!input) {
6971
- return "";
6972
- }
6973
- return input.split(/(?=[A-Z])|[\s._-]/).map((s) => s.trim()).filter(Boolean).map((s) => ACRONYMS.includes(s) ? s.toUpperCase() : upperCaseFirst(s.toLowerCase())).join(" ");
6974
- }, "titleCase");
6975
-
6976
- // ../type-checks/src/is-string.ts
6977
- init_cjs_shims();
6978
- var isString = /* @__PURE__ */ __name((value) => {
6979
- try {
6980
- return typeof value === "string";
6981
- } catch {
6982
- return false;
6983
- }
6984
- }, "isString");
6985
-
6986
- // ../env/src/get-env-paths.ts
6987
- var import_node_os = __toESM(require("node:os"), 1);
6988
- var import_node_path = __toESM(require("node:path"), 1);
6989
- var homedir = import_node_os.default.homedir();
6990
- var tmpdir = import_node_os.default.tmpdir();
6991
- var macos = /* @__PURE__ */ __name((orgId) => {
6992
- const library = joinPaths(homedir, "Library");
6993
- return {
6994
- data: joinPaths(library, "Application Support", orgId),
6995
- config: joinPaths(library, "Preferences", orgId),
6996
- cache: joinPaths(library, "Caches", orgId),
6997
- log: joinPaths(library, "Logs", orgId),
6998
- temp: joinPaths(tmpdir, orgId)
6999
- };
7000
- }, "macos");
7001
- var windows = /* @__PURE__ */ __name((orgId) => {
7002
- const appData = process.env.APPDATA || joinPaths(homedir, "AppData", "Roaming");
7003
- const localAppData = process.env.LOCALAPPDATA || joinPaths(homedir, "AppData", "Local");
7004
- const windowsFormattedOrgId = titleCase(orgId).trim().replace(/\s+/g, "");
7005
- return {
7006
- // Data/config/cache/log are invented by me as Windows isn't opinionated about this
7007
- data: joinPaths(localAppData, windowsFormattedOrgId, "Data"),
7008
- config: joinPaths(appData, windowsFormattedOrgId, "Config"),
7009
- cache: joinPaths(localAppData, "Cache", orgId),
7010
- log: joinPaths(localAppData, windowsFormattedOrgId, "Log"),
7011
- temp: joinPaths(tmpdir, orgId)
7012
- };
7013
- }, "windows");
7014
- var linux = /* @__PURE__ */ __name((orgId) => {
7015
- const username = import_node_path.default.basename(homedir);
7016
- return {
7017
- data: joinPaths(process.env.XDG_DATA_HOME || joinPaths(homedir, ".local", "share"), orgId),
7018
- config: joinPaths(process.env.XDG_CONFIG_HOME || joinPaths(homedir, ".config"), orgId),
7019
- cache: joinPaths(process.env.XDG_CACHE_HOME || joinPaths(homedir, ".cache"), orgId),
7020
- // https://wiki.debian.org/XDGBaseDirectorySpecification#state
7021
- log: joinPaths(process.env.XDG_STATE_HOME || joinPaths(homedir, ".local", "state"), orgId),
7022
- temp: joinPaths(tmpdir, username, orgId)
7023
- };
7024
- }, "linux");
7025
- function getEnvPaths(options = {}) {
7026
- let orgId = options.orgId || "storm-software";
7027
- if (!orgId) {
7028
- throw new Error("You need to provide an orgId to the `getEnvPaths` function");
7029
- }
7030
- if (options.suffix) {
7031
- orgId += `-${isString(options.suffix) ? options.suffix : "nodejs"}`;
7032
- }
7033
- let result = {};
7034
- if (process.platform === "darwin") {
7035
- result = macos(orgId);
7036
- } else if (process.platform === "win32") {
7037
- result = windows(orgId);
7038
- } else {
7039
- result = linux(orgId);
7040
- }
7041
- if (process.env.STORM_DATA_DIRECTORY) {
7042
- result.data = process.env.STORM_DATA_DIRECTORY;
7043
- } else if (process.env.STORM_CONFIG_DIRECTORY) {
7044
- result.config = process.env.STORM_CONFIG_DIRECTORY;
7045
- } else if (process.env.STORM_CACHE_DIRECTORY) {
7046
- result.cache = process.env.STORM_CACHE_DIRECTORY;
7047
- } else if (process.env.STORM_LOG_DIRECTORY) {
7048
- result.log = process.env.STORM_LOG_DIRECTORY;
7049
- } else if (process.env.STORM_TEMP_DIRECTORY) {
7050
- result.temp = process.env.STORM_TEMP_DIRECTORY;
7051
- }
7052
- if (options.workspaceRoot) {
7053
- result.cache ??= joinPaths(options.workspaceRoot, "node_modules", ".cache", orgId);
7054
- result.temp ??= joinPaths(options.workspaceRoot, "tmp", orgId);
7055
- result.log ??= joinPaths(result.temp, "logs");
7056
- result.config ??= joinPaths(options.workspaceRoot, ".config", orgId);
7057
- }
7058
- return Object.keys(result).reduce((ret, key) => {
7059
- if (result[key]) {
7060
- const filePath = result[key];
7061
- ret[key] = options.appId && options.appId !== options.orgId && options.appId !== options.nestedDir ? joinPaths(filePath, options.appId) : filePath;
7062
- if (options.nestedDir && options.nestedDir !== options.orgId && options.nestedDir !== options.appId) {
7063
- ret[key] = joinPaths(ret[key], options.nestedDir);
7064
- }
7065
- }
7066
- return ret;
7067
- }, {});
7068
- }
7069
- __name(getEnvPaths, "getEnvPaths");
7070
-
7071
- // ../path/src/get-workspace-root.ts
7072
- init_cjs_shims();
7073
-
7074
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/index.js
6906
+ // ../path/src/file-path-fns.ts
7075
6907
  init_cjs_shims();
7076
6908
 
7077
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-K6PUXRK3.js
6909
+ // ../types/src/base.ts
7078
6910
  init_cjs_shims();
6911
+ var EMPTY_STRING = "";
6912
+ var $NestedValue = Symbol("NestedValue");
7079
6913
 
7080
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-NQFXB5CV.js
6914
+ // ../path/src/correct-path.ts
7081
6915
  init_cjs_shims();
7082
6916
 
7083
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-SHUYVCID.js
6917
+ // ../path/src/is-file.ts
7084
6918
  init_cjs_shims();
7085
- var __defProp2 = Object.defineProperty;
7086
- var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", {
7087
- value,
7088
- configurable: true
7089
- }), "__name");
7090
-
7091
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-NQFXB5CV.js
7092
6919
  var import_node_fs2 = require("node:fs");
7093
- var import_node_path2 = require("node:path");
7094
- var MAX_PATH_SEARCH_DEPTH = 30;
7095
- var depth = 0;
7096
- function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
7097
- const _startPath = startPath ?? process.cwd();
7098
- if (endDirectoryNames.some((endDirName) => (0, import_node_fs2.existsSync)((0, import_node_path2.join)(_startPath, endDirName)))) {
7099
- return _startPath;
7100
- }
7101
- if (endFileNames.some((endFileName) => (0, import_node_fs2.existsSync)((0, import_node_path2.join)(_startPath, endFileName)))) {
7102
- return _startPath;
7103
- }
7104
- if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
7105
- const parent = (0, import_node_path2.join)(_startPath, "..");
7106
- return findFolderUp(parent, endFileNames, endDirectoryNames);
7107
- }
7108
- return void 0;
6920
+ function isFile(path6, additionalPath) {
6921
+ return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath, path6) : path6, {
6922
+ throwIfNoEntry: false
6923
+ })?.isFile());
7109
6924
  }
7110
- __name(findFolderUp, "findFolderUp");
7111
- __name2(findFolderUp, "findFolderUp");
6925
+ __name(isFile, "isFile");
6926
+ function isDirectory(path6, additionalPath) {
6927
+ return Boolean((0, import_node_fs2.statSync)(additionalPath ? joinPaths(additionalPath, path6) : path6, {
6928
+ throwIfNoEntry: false
6929
+ })?.isDirectory());
6930
+ }
6931
+ __name(isDirectory, "isDirectory");
6932
+ function isAbsolutePath(path6) {
6933
+ return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path6);
6934
+ }
6935
+ __name(isAbsolutePath, "isAbsolutePath");
7112
6936
 
7113
- // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-D6E6GZD2.js
7114
- init_cjs_shims();
7115
- var _DRIVE_LETTER_START_RE2 = /^[A-Za-z]:\//;
6937
+ // ../path/src/correct-path.ts
6938
+ var _DRIVE_LETTER_START_RE2 = /^[A-Z]:\//i;
7116
6939
  function normalizeWindowsPath2(input = "") {
7117
6940
  if (!input) {
7118
6941
  return input;
@@ -7120,17 +6943,15 @@ function normalizeWindowsPath2(input = "") {
7120
6943
  return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE2, (r) => r.toUpperCase());
7121
6944
  }
7122
6945
  __name(normalizeWindowsPath2, "normalizeWindowsPath");
7123
- __name2(normalizeWindowsPath2, "normalizeWindowsPath");
7124
6946
  var _UNC_REGEX2 = /^[/\\]{2}/;
7125
- var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
7126
- var _DRIVE_LETTER_RE2 = /^[A-Za-z]:$/;
7127
- var correctPaths2 = /* @__PURE__ */ __name2(function(path6) {
6947
+ var _DRIVE_LETTER_RE2 = /^[A-Z]:$/i;
6948
+ function correctPath(path6) {
7128
6949
  if (!path6 || path6.length === 0) {
7129
6950
  return ".";
7130
6951
  }
7131
6952
  path6 = normalizeWindowsPath2(path6);
7132
6953
  const isUNCPath = path6.match(_UNC_REGEX2);
7133
- const isPathAbsolute = isAbsolute2(path6);
6954
+ const isPathAbsolute = isAbsolutePath(path6);
7134
6955
  const trailingSeparator = path6[path6.length - 1] === "/";
7135
6956
  path6 = normalizeString2(path6, !isPathAbsolute);
7136
6957
  if (path6.length === 0) {
@@ -7151,16 +6972,9 @@ var correctPaths2 = /* @__PURE__ */ __name2(function(path6) {
7151
6972
  }
7152
6973
  return `//${path6}`;
7153
6974
  }
7154
- return isPathAbsolute && !isAbsolute2(path6) ? `/${path6}` : path6;
7155
- }, "correctPaths");
7156
- function cwd() {
7157
- if (typeof process !== "undefined" && typeof process.cwd === "function") {
7158
- return process.cwd().replace(/\\/g, "/");
7159
- }
7160
- return "/";
6975
+ return isPathAbsolute && !isAbsolutePath(path6) ? `/${path6}` : path6;
7161
6976
  }
7162
- __name(cwd, "cwd");
7163
- __name2(cwd, "cwd");
6977
+ __name(correctPath, "correctPath");
7164
6978
  function normalizeString2(path6, allowAboveRoot) {
7165
6979
  let res = "";
7166
6980
  let lastSegmentLength = 0;
@@ -7222,110 +7036,52 @@ function normalizeString2(path6, allowAboveRoot) {
7222
7036
  return res;
7223
7037
  }
7224
7038
  __name(normalizeString2, "normalizeString");
7225
- __name2(normalizeString2, "normalizeString");
7226
- var isAbsolute2 = /* @__PURE__ */ __name2(function(p) {
7227
- return _IS_ABSOLUTE_RE2.test(p);
7228
- }, "isAbsolute");
7039
+
7040
+ // ../path/src/get-workspace-root.ts
7041
+ init_cjs_shims();
7042
+
7043
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/index.js
7044
+ init_cjs_shims();
7229
7045
 
7230
7046
  // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-K6PUXRK3.js
7231
- var rootFiles = [
7232
- "storm-workspace.json",
7233
- "storm-workspace.json",
7234
- "storm-workspace.yaml",
7235
- "storm-workspace.yml",
7236
- "storm-workspace.js",
7237
- "storm-workspace.ts",
7238
- ".storm-workspace.json",
7239
- ".storm-workspace.yaml",
7240
- ".storm-workspace.yml",
7241
- ".storm-workspace.js",
7242
- ".storm-workspace.ts",
7243
- "lerna.json",
7244
- "nx.json",
7245
- "turbo.json",
7246
- "npm-workspace.json",
7247
- "yarn-workspace.json",
7248
- "pnpm-workspace.json",
7249
- "npm-workspace.yaml",
7250
- "yarn-workspace.yaml",
7251
- "pnpm-workspace.yaml",
7252
- "npm-workspace.yml",
7253
- "yarn-workspace.yml",
7254
- "pnpm-workspace.yml",
7255
- "npm-lock.json",
7256
- "yarn-lock.json",
7257
- "pnpm-lock.json",
7258
- "npm-lock.yaml",
7259
- "yarn-lock.yaml",
7260
- "pnpm-lock.yaml",
7261
- "npm-lock.yml",
7262
- "yarn-lock.yml",
7263
- "pnpm-lock.yml",
7264
- "bun.lockb"
7265
- ];
7266
- var rootDirectories = [
7267
- ".storm-workspace",
7268
- ".nx",
7269
- ".github",
7270
- ".vscode",
7271
- ".verdaccio"
7272
- ];
7273
- function findWorkspaceRootSafe(pathInsideMonorepo) {
7274
- if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
7275
- return correctPaths2(process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH);
7276
- }
7277
- return correctPaths2(findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles, rootDirectories));
7278
- }
7279
- __name(findWorkspaceRootSafe, "findWorkspaceRootSafe");
7280
- __name2(findWorkspaceRootSafe, "findWorkspaceRootSafe");
7281
- function findWorkspaceRoot(pathInsideMonorepo) {
7282
- const result = findWorkspaceRootSafe(pathInsideMonorepo);
7283
- if (!result) {
7284
- throw new Error(`Cannot find workspace root upwards from known path. Files search list includes:
7285
- ${rootFiles.join("\n")}
7286
- Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`);
7287
- }
7288
- return result;
7289
- }
7290
- __name(findWorkspaceRoot, "findWorkspaceRoot");
7291
- __name2(findWorkspaceRoot, "findWorkspaceRoot");
7292
-
7293
- // ../path/src/get-parent-path.ts
7294
7047
  init_cjs_shims();
7295
7048
 
7296
- // ../path/src/file-path-fns.ts
7297
- init_cjs_shims();
7298
-
7299
- // ../types/src/base.ts
7049
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-NQFXB5CV.js
7300
7050
  init_cjs_shims();
7301
- var EMPTY_STRING = "";
7302
- var $NestedValue = Symbol("NestedValue");
7303
7051
 
7304
- // ../path/src/correct-path.ts
7052
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-SHUYVCID.js
7305
7053
  init_cjs_shims();
7054
+ var __defProp2 = Object.defineProperty;
7055
+ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", {
7056
+ value,
7057
+ configurable: true
7058
+ }), "__name");
7306
7059
 
7307
- // ../path/src/is-file.ts
7308
- init_cjs_shims();
7060
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-NQFXB5CV.js
7309
7061
  var import_node_fs3 = require("node:fs");
7310
- function isFile(path6, additionalPath) {
7311
- return Boolean((0, import_node_fs3.statSync)(additionalPath ? joinPaths(additionalPath, path6) : path6, {
7312
- throwIfNoEntry: false
7313
- })?.isFile());
7314
- }
7315
- __name(isFile, "isFile");
7316
- function isDirectory(path6, additionalPath) {
7317
- return Boolean((0, import_node_fs3.statSync)(additionalPath ? joinPaths(additionalPath, path6) : path6, {
7318
- throwIfNoEntry: false
7319
- })?.isDirectory());
7320
- }
7321
- __name(isDirectory, "isDirectory");
7322
- function isAbsolutePath(path6) {
7323
- return !/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i.test(path6);
7062
+ var import_node_path = require("node:path");
7063
+ var MAX_PATH_SEARCH_DEPTH = 30;
7064
+ var depth = 0;
7065
+ function findFolderUp(startPath, endFileNames = [], endDirectoryNames = []) {
7066
+ const _startPath = startPath ?? process.cwd();
7067
+ if (endDirectoryNames.some((endDirName) => (0, import_node_fs3.existsSync)((0, import_node_path.join)(_startPath, endDirName)))) {
7068
+ return _startPath;
7069
+ }
7070
+ if (endFileNames.some((endFileName) => (0, import_node_fs3.existsSync)((0, import_node_path.join)(_startPath, endFileName)))) {
7071
+ return _startPath;
7072
+ }
7073
+ if (_startPath !== "/" && depth++ < MAX_PATH_SEARCH_DEPTH) {
7074
+ const parent = (0, import_node_path.join)(_startPath, "..");
7075
+ return findFolderUp(parent, endFileNames, endDirectoryNames);
7076
+ }
7077
+ return void 0;
7324
7078
  }
7325
- __name(isAbsolutePath, "isAbsolutePath");
7079
+ __name(findFolderUp, "findFolderUp");
7080
+ __name2(findFolderUp, "findFolderUp");
7326
7081
 
7327
- // ../path/src/correct-path.ts
7328
- var _DRIVE_LETTER_START_RE3 = /^[A-Z]:\//i;
7082
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-D6E6GZD2.js
7083
+ init_cjs_shims();
7084
+ var _DRIVE_LETTER_START_RE3 = /^[A-Za-z]:\//;
7329
7085
  function normalizeWindowsPath3(input = "") {
7330
7086
  if (!input) {
7331
7087
  return input;
@@ -7333,15 +7089,17 @@ function normalizeWindowsPath3(input = "") {
7333
7089
  return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE3, (r) => r.toUpperCase());
7334
7090
  }
7335
7091
  __name(normalizeWindowsPath3, "normalizeWindowsPath");
7092
+ __name2(normalizeWindowsPath3, "normalizeWindowsPath");
7336
7093
  var _UNC_REGEX3 = /^[/\\]{2}/;
7337
- var _DRIVE_LETTER_RE3 = /^[A-Z]:$/i;
7338
- function correctPath(path6) {
7094
+ var _IS_ABSOLUTE_RE2 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
7095
+ var _DRIVE_LETTER_RE3 = /^[A-Za-z]:$/;
7096
+ var correctPaths2 = /* @__PURE__ */ __name2(function(path6) {
7339
7097
  if (!path6 || path6.length === 0) {
7340
7098
  return ".";
7341
7099
  }
7342
7100
  path6 = normalizeWindowsPath3(path6);
7343
7101
  const isUNCPath = path6.match(_UNC_REGEX3);
7344
- const isPathAbsolute = isAbsolutePath(path6);
7102
+ const isPathAbsolute = isAbsolute2(path6);
7345
7103
  const trailingSeparator = path6[path6.length - 1] === "/";
7346
7104
  path6 = normalizeString3(path6, !isPathAbsolute);
7347
7105
  if (path6.length === 0) {
@@ -7362,9 +7120,16 @@ function correctPath(path6) {
7362
7120
  }
7363
7121
  return `//${path6}`;
7364
7122
  }
7365
- return isPathAbsolute && !isAbsolutePath(path6) ? `/${path6}` : path6;
7123
+ return isPathAbsolute && !isAbsolute2(path6) ? `/${path6}` : path6;
7124
+ }, "correctPaths");
7125
+ function cwd() {
7126
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
7127
+ return process.cwd().replace(/\\/g, "/");
7128
+ }
7129
+ return "/";
7366
7130
  }
7367
- __name(correctPath, "correctPath");
7131
+ __name(cwd, "cwd");
7132
+ __name2(cwd, "cwd");
7368
7133
  function normalizeString3(path6, allowAboveRoot) {
7369
7134
  let res = "";
7370
7135
  let lastSegmentLength = 0;
@@ -7426,51 +7191,76 @@ function normalizeString3(path6, allowAboveRoot) {
7426
7191
  return res;
7427
7192
  }
7428
7193
  __name(normalizeString3, "normalizeString");
7194
+ __name2(normalizeString3, "normalizeString");
7195
+ var isAbsolute2 = /* @__PURE__ */ __name2(function(p) {
7196
+ return _IS_ABSOLUTE_RE2.test(p);
7197
+ }, "isAbsolute");
7429
7198
 
7430
- // ../path/src/file-path-fns.ts
7431
- function findFileName(filePath, { requireExtension, withExtension } = {}) {
7432
- const result = normalizeWindowsPath3(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
7433
- if (requireExtension === true && !result.includes(".")) {
7434
- return EMPTY_STRING;
7435
- }
7436
- if (withExtension === false && result.includes(".")) {
7437
- return result.split(".").slice(-1).join(".") || EMPTY_STRING;
7199
+ // ../../node_modules/.pnpm/@storm-software+config-tools@1.160.6_@storm-software+config@1.110.6/node_modules/@storm-software/config-tools/dist/chunk-K6PUXRK3.js
7200
+ var rootFiles = [
7201
+ "storm-workspace.json",
7202
+ "storm-workspace.json",
7203
+ "storm-workspace.yaml",
7204
+ "storm-workspace.yml",
7205
+ "storm-workspace.js",
7206
+ "storm-workspace.ts",
7207
+ ".storm-workspace.json",
7208
+ ".storm-workspace.yaml",
7209
+ ".storm-workspace.yml",
7210
+ ".storm-workspace.js",
7211
+ ".storm-workspace.ts",
7212
+ "lerna.json",
7213
+ "nx.json",
7214
+ "turbo.json",
7215
+ "npm-workspace.json",
7216
+ "yarn-workspace.json",
7217
+ "pnpm-workspace.json",
7218
+ "npm-workspace.yaml",
7219
+ "yarn-workspace.yaml",
7220
+ "pnpm-workspace.yaml",
7221
+ "npm-workspace.yml",
7222
+ "yarn-workspace.yml",
7223
+ "pnpm-workspace.yml",
7224
+ "npm-lock.json",
7225
+ "yarn-lock.json",
7226
+ "pnpm-lock.json",
7227
+ "npm-lock.yaml",
7228
+ "yarn-lock.yaml",
7229
+ "pnpm-lock.yaml",
7230
+ "npm-lock.yml",
7231
+ "yarn-lock.yml",
7232
+ "pnpm-lock.yml",
7233
+ "bun.lockb"
7234
+ ];
7235
+ var rootDirectories = [
7236
+ ".storm-workspace",
7237
+ ".nx",
7238
+ ".github",
7239
+ ".vscode",
7240
+ ".verdaccio"
7241
+ ];
7242
+ function findWorkspaceRootSafe(pathInsideMonorepo) {
7243
+ if (process.env.STORM_WORKSPACE_ROOT || process.env.NX_WORKSPACE_ROOT_PATH) {
7244
+ return correctPaths2(process.env.STORM_WORKSPACE_ROOT ?? process.env.NX_WORKSPACE_ROOT_PATH);
7438
7245
  }
7439
- return result;
7440
- }
7441
- __name(findFileName, "findFileName");
7442
- function findFilePath(filePath) {
7443
- const normalizedPath = normalizeWindowsPath3(filePath);
7444
- return normalizedPath.replace(findFileName(normalizedPath, {
7445
- requireExtension: true
7446
- }), "");
7246
+ return correctPaths2(findFolderUp(pathInsideMonorepo ?? process.cwd(), rootFiles, rootDirectories));
7447
7247
  }
7448
- __name(findFilePath, "findFilePath");
7449
- function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
7450
- const paths = normalizeWindowsPath3(path6).split("/");
7451
- let resolvedPath = "";
7452
- let resolvedAbsolute = false;
7453
- for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
7454
- const path7 = index >= 0 ? paths[index] : cwd2;
7455
- if (!path7 || path7.length === 0) {
7456
- continue;
7457
- }
7458
- resolvedPath = joinPaths(path7, resolvedPath);
7459
- resolvedAbsolute = isAbsolutePath(path7);
7460
- }
7461
- resolvedPath = normalizeString3(resolvedPath, !resolvedAbsolute);
7462
- if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {
7463
- return `/${resolvedPath}`;
7248
+ __name(findWorkspaceRootSafe, "findWorkspaceRootSafe");
7249
+ __name2(findWorkspaceRootSafe, "findWorkspaceRootSafe");
7250
+ function findWorkspaceRoot(pathInsideMonorepo) {
7251
+ const result = findWorkspaceRootSafe(pathInsideMonorepo);
7252
+ if (!result) {
7253
+ throw new Error(`Cannot find workspace root upwards from known path. Files search list includes:
7254
+ ${rootFiles.join("\n")}
7255
+ Path: ${pathInsideMonorepo ? pathInsideMonorepo : process.cwd()}`);
7464
7256
  }
7465
- return resolvedPath.length > 0 ? resolvedPath : ".";
7466
- }
7467
- __name(resolvePath, "resolvePath");
7468
- function resolvePaths(...paths) {
7469
- return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath3(path6))));
7257
+ return result;
7470
7258
  }
7471
- __name(resolvePaths, "resolvePaths");
7259
+ __name(findWorkspaceRoot, "findWorkspaceRoot");
7260
+ __name2(findWorkspaceRoot, "findWorkspaceRoot");
7472
7261
 
7473
7262
  // ../path/src/get-parent-path.ts
7263
+ init_cjs_shims();
7474
7264
  var resolveParentPath = /* @__PURE__ */ __name((path6) => {
7475
7265
  return resolvePaths(path6, "..");
7476
7266
  }, "resolveParentPath");
@@ -7558,6 +7348,237 @@ var getWorkspaceRoot = /* @__PURE__ */ __name((dir = process.cwd()) => {
7558
7348
  return dir;
7559
7349
  }, "getWorkspaceRoot");
7560
7350
 
7351
+ // ../path/src/file-path-fns.ts
7352
+ function findFileName(filePath, { requireExtension, withExtension } = {}) {
7353
+ const result = normalizeWindowsPath2(filePath)?.split(filePath?.includes("\\") ? "\\" : "/")?.pop() ?? "";
7354
+ if (requireExtension === true && !result.includes(".")) {
7355
+ return EMPTY_STRING;
7356
+ }
7357
+ if (withExtension === false && result.includes(".")) {
7358
+ return result.split(".").slice(-1).join(".") || EMPTY_STRING;
7359
+ }
7360
+ return result;
7361
+ }
7362
+ __name(findFileName, "findFileName");
7363
+ function findFilePath(filePath) {
7364
+ const normalizedPath = normalizeWindowsPath2(filePath);
7365
+ return normalizedPath.replace(findFileName(normalizedPath, {
7366
+ requireExtension: true
7367
+ }), "");
7368
+ }
7369
+ __name(findFilePath, "findFilePath");
7370
+ function resolvePath(path6, cwd2 = getWorkspaceRoot()) {
7371
+ const paths = normalizeWindowsPath2(path6).split("/");
7372
+ let resolvedPath = "";
7373
+ let resolvedAbsolute = false;
7374
+ for (let index = paths.length - 1; index >= -1 && !resolvedAbsolute; index--) {
7375
+ const path7 = index >= 0 ? paths[index] : cwd2;
7376
+ if (!path7 || path7.length === 0) {
7377
+ continue;
7378
+ }
7379
+ resolvedPath = joinPaths(path7, resolvedPath);
7380
+ resolvedAbsolute = isAbsolutePath(path7);
7381
+ }
7382
+ resolvedPath = normalizeString2(resolvedPath, !resolvedAbsolute);
7383
+ if (resolvedAbsolute && !isAbsolutePath(resolvedPath)) {
7384
+ return `/${resolvedPath}`;
7385
+ }
7386
+ return resolvedPath.length > 0 ? resolvedPath : ".";
7387
+ }
7388
+ __name(resolvePath, "resolvePath");
7389
+ function resolvePaths(...paths) {
7390
+ return resolvePath(joinPaths(...paths.map((path6) => normalizeWindowsPath2(path6))));
7391
+ }
7392
+ __name(resolvePaths, "resolvePaths");
7393
+ function relativePath(from, to) {
7394
+ const _from = resolvePath(from).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7395
+ const _to = resolvePath(to).replace(/^\/([A-Z]:)?$/i, "$1").split("/");
7396
+ if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
7397
+ return _to.join("/");
7398
+ }
7399
+ const _fromCopy = [
7400
+ ..._from
7401
+ ];
7402
+ for (const segment of _fromCopy) {
7403
+ if (_to[0] !== segment) {
7404
+ break;
7405
+ }
7406
+ _from.shift();
7407
+ _to.shift();
7408
+ }
7409
+ return [
7410
+ ..._from.map(() => ".."),
7411
+ ..._to
7412
+ ].join("/");
7413
+ }
7414
+ __name(relativePath, "relativePath");
7415
+
7416
+ // src/utils/get-prisma-internals.ts
7417
+ init_cjs_shims();
7418
+
7419
+ // src/utils/get-jiti.ts
7420
+ init_cjs_shims();
7421
+
7422
+ // ../env/src/get-env-paths.ts
7423
+ init_cjs_shims();
7424
+
7425
+ // ../string-format/src/title-case.ts
7426
+ init_cjs_shims();
7427
+
7428
+ // ../string-format/src/acronyms.ts
7429
+ init_cjs_shims();
7430
+ var ACRONYMS = [
7431
+ "API",
7432
+ "CPU",
7433
+ "CSS",
7434
+ "DNS",
7435
+ "EOF",
7436
+ "GUID",
7437
+ "HTML",
7438
+ "HTTP",
7439
+ "HTTPS",
7440
+ "ID",
7441
+ "IP",
7442
+ "JSON",
7443
+ "LHS",
7444
+ "OEM",
7445
+ "PP",
7446
+ "QA",
7447
+ "RAM",
7448
+ "RHS",
7449
+ "RPC",
7450
+ "RSS",
7451
+ "SLA",
7452
+ "SMTP",
7453
+ "SQL",
7454
+ "SSH",
7455
+ "SSL",
7456
+ "TCP",
7457
+ "TLS",
7458
+ "TRPC",
7459
+ "TTL",
7460
+ "UDP",
7461
+ "UI",
7462
+ "UID",
7463
+ "UUID",
7464
+ "URI",
7465
+ "URL",
7466
+ "UTF",
7467
+ "VM",
7468
+ "XML",
7469
+ "XSS",
7470
+ "XSRF"
7471
+ ];
7472
+
7473
+ // ../string-format/src/upper-case-first.ts
7474
+ init_cjs_shims();
7475
+ var upperCaseFirst = /* @__PURE__ */ __name((input) => {
7476
+ return input ? input.charAt(0).toUpperCase() + input.slice(1) : input;
7477
+ }, "upperCaseFirst");
7478
+
7479
+ // ../string-format/src/title-case.ts
7480
+ var titleCase = /* @__PURE__ */ __name((input) => {
7481
+ if (!input) {
7482
+ return "";
7483
+ }
7484
+ return input.split(/(?=[A-Z])|[\s._-]/).map((s) => s.trim()).filter(Boolean).map((s) => ACRONYMS.includes(s) ? s.toUpperCase() : upperCaseFirst(s.toLowerCase())).join(" ");
7485
+ }, "titleCase");
7486
+
7487
+ // ../type-checks/src/is-string.ts
7488
+ init_cjs_shims();
7489
+ var isString = /* @__PURE__ */ __name((value) => {
7490
+ try {
7491
+ return typeof value === "string";
7492
+ } catch {
7493
+ return false;
7494
+ }
7495
+ }, "isString");
7496
+
7497
+ // ../env/src/get-env-paths.ts
7498
+ var import_node_os = __toESM(require("node:os"), 1);
7499
+ var import_node_path2 = __toESM(require("node:path"), 1);
7500
+ var homedir = import_node_os.default.homedir();
7501
+ var tmpdir = import_node_os.default.tmpdir();
7502
+ var macos = /* @__PURE__ */ __name((orgId) => {
7503
+ const library = joinPaths(homedir, "Library");
7504
+ return {
7505
+ data: joinPaths(library, "Application Support", orgId),
7506
+ config: joinPaths(library, "Preferences", orgId),
7507
+ cache: joinPaths(library, "Caches", orgId),
7508
+ log: joinPaths(library, "Logs", orgId),
7509
+ temp: joinPaths(tmpdir, orgId)
7510
+ };
7511
+ }, "macos");
7512
+ var windows = /* @__PURE__ */ __name((orgId) => {
7513
+ const appData = process.env.APPDATA || joinPaths(homedir, "AppData", "Roaming");
7514
+ const localAppData = process.env.LOCALAPPDATA || joinPaths(homedir, "AppData", "Local");
7515
+ const windowsFormattedOrgId = titleCase(orgId).trim().replace(/\s+/g, "");
7516
+ return {
7517
+ // Data/config/cache/log are invented by me as Windows isn't opinionated about this
7518
+ data: joinPaths(localAppData, windowsFormattedOrgId, "Data"),
7519
+ config: joinPaths(appData, windowsFormattedOrgId, "Config"),
7520
+ cache: joinPaths(localAppData, "Cache", orgId),
7521
+ log: joinPaths(localAppData, windowsFormattedOrgId, "Log"),
7522
+ temp: joinPaths(tmpdir, orgId)
7523
+ };
7524
+ }, "windows");
7525
+ var linux = /* @__PURE__ */ __name((orgId) => {
7526
+ const username = import_node_path2.default.basename(homedir);
7527
+ return {
7528
+ data: joinPaths(process.env.XDG_DATA_HOME || joinPaths(homedir, ".local", "share"), orgId),
7529
+ config: joinPaths(process.env.XDG_CONFIG_HOME || joinPaths(homedir, ".config"), orgId),
7530
+ cache: joinPaths(process.env.XDG_CACHE_HOME || joinPaths(homedir, ".cache"), orgId),
7531
+ // https://wiki.debian.org/XDGBaseDirectorySpecification#state
7532
+ log: joinPaths(process.env.XDG_STATE_HOME || joinPaths(homedir, ".local", "state"), orgId),
7533
+ temp: joinPaths(tmpdir, username, orgId)
7534
+ };
7535
+ }, "linux");
7536
+ function getEnvPaths(options = {}) {
7537
+ let orgId = options.orgId || "storm-software";
7538
+ if (!orgId) {
7539
+ throw new Error("You need to provide an orgId to the `getEnvPaths` function");
7540
+ }
7541
+ if (options.suffix) {
7542
+ orgId += `-${isString(options.suffix) ? options.suffix : "nodejs"}`;
7543
+ }
7544
+ let result = {};
7545
+ if (process.platform === "darwin") {
7546
+ result = macos(orgId);
7547
+ } else if (process.platform === "win32") {
7548
+ result = windows(orgId);
7549
+ } else {
7550
+ result = linux(orgId);
7551
+ }
7552
+ if (process.env.STORM_DATA_DIRECTORY) {
7553
+ result.data = process.env.STORM_DATA_DIRECTORY;
7554
+ } else if (process.env.STORM_CONFIG_DIRECTORY) {
7555
+ result.config = process.env.STORM_CONFIG_DIRECTORY;
7556
+ } else if (process.env.STORM_CACHE_DIRECTORY) {
7557
+ result.cache = process.env.STORM_CACHE_DIRECTORY;
7558
+ } else if (process.env.STORM_LOG_DIRECTORY) {
7559
+ result.log = process.env.STORM_LOG_DIRECTORY;
7560
+ } else if (process.env.STORM_TEMP_DIRECTORY) {
7561
+ result.temp = process.env.STORM_TEMP_DIRECTORY;
7562
+ }
7563
+ if (options.workspaceRoot) {
7564
+ result.cache ??= joinPaths(options.workspaceRoot, "node_modules", ".cache", orgId);
7565
+ result.temp ??= joinPaths(options.workspaceRoot, "tmp", orgId);
7566
+ result.log ??= joinPaths(result.temp, "logs");
7567
+ result.config ??= joinPaths(options.workspaceRoot, ".config", orgId);
7568
+ }
7569
+ return Object.keys(result).reduce((ret, key) => {
7570
+ if (result[key]) {
7571
+ const filePath = result[key];
7572
+ ret[key] = options.appId && options.appId !== options.orgId && options.appId !== options.nestedDir ? joinPaths(filePath, options.appId) : filePath;
7573
+ if (options.nestedDir && options.nestedDir !== options.orgId && options.nestedDir !== options.appId) {
7574
+ ret[key] = joinPaths(ret[key], options.nestedDir);
7575
+ }
7576
+ }
7577
+ return ret;
7578
+ }, {});
7579
+ }
7580
+ __name(getEnvPaths, "getEnvPaths");
7581
+
7561
7582
  // src/utils/get-jiti.ts
7562
7583
  var import_jiti = require("jiti");
7563
7584
  var jiti;
@@ -7646,24 +7667,35 @@ var generateRouterImport = /* @__PURE__ */ __name((sourceFile, modelNamePlural,
7646
7667
  async function generateBaseRouter(sourceFile, config, options) {
7647
7668
  const internals = await getPrismaInternals();
7648
7669
  const outputDir = internals.parseEnvValue(options.generator.output);
7670
+ const relativeContextPath = getRelativePath(outputDir, config.contextPath, true, options.schemaPath);
7649
7671
  sourceFile.addStatements(
7650
7672
  /* ts */
7651
7673
  `
7652
- import type { Context } from '${getRelativePath(outputDir, config.contextPath, true, options.schemaPath)}';
7674
+ import type { Context } from '${relativeContextPath}';
7653
7675
  `
7654
7676
  );
7655
- if (config.trpcOptionsPath) {
7677
+ if (config.trpcOptions) {
7656
7678
  sourceFile.addStatements(
7657
7679
  /* ts */
7658
7680
  `
7659
- import trpcOptions from '${getRelativePath(outputDir, config.trpcOptionsPath, true, options.schemaPath)}';
7681
+ import trpcOptions from '${getRelativePath(outputDir, typeof config.trpcOptions === "boolean" ? joinPaths(outputDir, "options") : config.trpcOptions, true, options.schemaPath)}';
7660
7682
  `
7661
7683
  );
7662
7684
  }
7685
+ if (config.useTRPCNext) {
7686
+ sourceFile.addStatements(
7687
+ /* ts */
7688
+ `
7689
+ import { createContext } from '${relativeContextPath}';
7690
+ import { initTRPC, TRPCError } from '@trpc/server';
7691
+ import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
7692
+ `
7693
+ );
7694
+ }
7663
7695
  sourceFile.addStatements(
7664
7696
  /* ts */
7665
7697
  `
7666
- export const t = trpc.initTRPC.context<Context>().create(${config.trpcOptionsPath ? "trpcOptions" : ""});
7698
+ export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""});
7667
7699
  `
7668
7700
  );
7669
7701
  const middlewares = [];
@@ -7719,11 +7751,44 @@ async function generateBaseRouter(sourceFile, config, options) {
7719
7751
  )
7720
7752
  });
7721
7753
  }
7754
+ sourceFile.addStatements(
7755
+ /* ts */
7756
+ `
7757
+ /**
7758
+ * Create a server-side caller
7759
+ * @see https://trpc.io/docs/server/server-side-calls
7760
+ */
7761
+ export const createCallerFactory = t.createCallerFactory;`
7762
+ );
7722
7763
  sourceFile.addStatements(
7723
7764
  /* ts */
7724
7765
  `
7725
7766
  export const publicProcedure = t.procedure; `
7726
7767
  );
7768
+ if (config.useTRPCNext) {
7769
+ sourceFile.addStatements(
7770
+ /* ts */
7771
+ `
7772
+ export const protectedProcedure = publicProcedure.use((opts) => {
7773
+ const { session } = opts.ctx;
7774
+
7775
+ if (!session?.user) {
7776
+ throw new TRPCError({
7777
+ code: 'UNAUTHORIZED',
7778
+ });
7779
+ }
7780
+
7781
+ return opts.next({ ctx: { session } });
7782
+ });
7783
+ `
7784
+ );
7785
+ sourceFile.addStatements(
7786
+ /* ts */
7787
+ `
7788
+ export const createAction = createTRPCServerActionHandler(t, createContext);
7789
+ `
7790
+ );
7791
+ }
7727
7792
  if (middlewares.length > 0) {
7728
7793
  const procName = getProcedureName(config);
7729
7794
  middlewares.forEach((middleware, i) => {
@@ -7945,11 +8010,13 @@ var constructShield = /* @__PURE__ */ __name(async ({ queries, mutations, subscr
7945
8010
  })},`;
7946
8011
  rootItems += subscriptionLinesWrapped;
7947
8012
  }
7948
- if (rootItems.length === 0) return "";
8013
+ if (rootItems.length === 0) {
8014
+ return "";
8015
+ }
7949
8016
  let shieldText = getImports("trpc-shield");
7950
8017
  const internals = await getPrismaInternals();
7951
8018
  const outputDir = internals.parseEnvValue(options.generator.output);
7952
- shieldText += getImports("context", getRelativePath(outputDir, config.contextPath, true, options.schemaPath));
8019
+ shieldText += getImports("context", relativePath(outputDir, joinPaths(options.schemaPath, config.contextPath)));
7953
8020
  shieldText += "\n\n";
7954
8021
  shieldText += wrapWithExport({
7955
8022
  shieldObjectText: wrapWithTrpcShieldCall({
@@ -10296,11 +10363,11 @@ var writeFileSafely = /* @__PURE__ */ __name(async (writeLocation, content, addT
10296
10363
  }, "writeFileSafely");
10297
10364
  var writeIndexFile = /* @__PURE__ */ __name(async (indexPath) => {
10298
10365
  const rows = Array.from(indexExports).map((filePath) => {
10299
- let relativePath = import_node_path4.default.relative(import_node_path4.default.dirname(indexPath), filePath);
10300
- if (relativePath.endsWith(".ts")) {
10301
- relativePath = relativePath.slice(0, relativePath.lastIndexOf(".ts"));
10366
+ let relativePath2 = import_node_path4.default.relative(import_node_path4.default.dirname(indexPath), filePath);
10367
+ if (relativePath2.endsWith(".ts")) {
10368
+ relativePath2 = relativePath2.slice(0, relativePath2.lastIndexOf(".ts"));
10302
10369
  }
10303
- const normalized = correctPath(relativePath);
10370
+ const normalized = correctPath(relativePath2);
10304
10371
  return `export * from './${normalized}'`;
10305
10372
  });
10306
10373
  await writeFileSafely(indexPath, rows.join("\n"), false);
@@ -11612,6 +11679,27 @@ async function generate(options) {
11612
11679
  consoleLog("Skipping tRPC Shield generation");
11613
11680
  }
11614
11681
  consoleLog(`Generating tRPC source code for ${models.length} models`);
11682
+ if (config.trpcOptions && typeof config.trpcOptions === "boolean") {
11683
+ const trpcOptionsOutputPath = joinPaths(outputDir, "options.ts");
11684
+ consoleLog("Generating tRPC options source file");
11685
+ await writeFileSafely(trpcOptionsOutputPath, `import { ZodError } from 'zod';${config.useTRPCNext ? '\nimport { transformer } from "@stryke/trpc-next/shared";' : ""}
11686
+
11687
+ export default {${config.useTRPCNext ? "\n transformer," : ""}
11688
+ errorFormatter({ shape, error }) {
11689
+ return {
11690
+ ...shape,
11691
+ data: {
11692
+ ...shape.data,
11693
+ zodError:
11694
+ error.code === 'BAD_REQUEST' && error.cause instanceof ZodError
11695
+ ? error.cause.flatten()
11696
+ : null,
11697
+ },
11698
+ };
11699
+ },
11700
+ };
11701
+ `);
11702
+ }
11615
11703
  resolveModelsComments(models, hiddenModels);
11616
11704
  const createRouter = project.createSourceFile(import_node_path6.default.resolve(outputDir, "routers", "helpers", "createRouter.ts"), void 0, {
11617
11705
  overwrite: true
@@ -11640,6 +11728,10 @@ async function generate(options) {
11640
11728
  consoleLog(`Skipping model ${model} as it is hidden`);
11641
11729
  continue;
11642
11730
  }
11731
+ if (!model) {
11732
+ consoleLog(`Skipping model ${model} as it is not defined`);
11733
+ continue;
11734
+ }
11643
11735
  const modelActions = Object.keys(operations).filter((opType) => (
11644
11736
  // eslint-disable-next-line unicorn/prefer-includes
11645
11737
  config.generateModelActions.some((generateModelAction) => generateModelAction === opType.replace("One", ""))
@@ -11648,7 +11740,7 @@ async function generate(options) {
11648
11740
  consoleLog(`Skipping model ${model} as it has no actions to generate`);
11649
11741
  continue;
11650
11742
  }
11651
- const plural = (0, import_pluralize.default)(model.toLowerCase());
11743
+ const plural = (0, import_pluralize.default)(lowerCaseFirst(model));
11652
11744
  consoleLog(`Generating tRPC router for model ${model}`);
11653
11745
  generateRouterImport(appRouter, plural, model);
11654
11746
  const modelRouter = project.createSourceFile(import_node_path6.default.resolve(outputDir, "routers", `${model}.router.ts`), void 0, {