@stryke/prisma-trpc-generator 0.13.86 → 0.13.88

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.
Files changed (37) hide show
  1. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +2 -2
  2. package/dist/_virtual/{rolldown_runtime.mjs → _rolldown/runtime.mjs} +2 -2
  3. package/dist/config.cjs +23 -23
  4. package/dist/config.mjs +21 -21
  5. package/dist/config.mjs.map +1 -1
  6. package/dist/helpers.cjs +10 -10
  7. package/dist/helpers.mjs.map +1 -1
  8. package/dist/packages/env/src/get-env-paths.cjs +28 -28
  9. package/dist/packages/string-format/src/acronyms.cjs +0 -1
  10. package/dist/packages/string-format/src/acronyms.mjs +0 -1
  11. package/dist/packages/string-format/src/acronyms.mjs.map +1 -1
  12. package/dist/prisma-generator.cjs +13 -13
  13. package/dist/prisma-generator.mjs +1 -1
  14. package/dist/prisma-generator.mjs.map +1 -1
  15. package/dist/project.cjs +1 -1
  16. package/dist/project.mjs.map +1 -1
  17. package/dist/utils/format-file.cjs +2 -2
  18. package/dist/utils/format-file.mjs.map +1 -1
  19. package/dist/utils/get-jiti.cjs +5 -5
  20. package/dist/utils/get-jiti.mjs.map +1 -1
  21. package/dist/utils/write-file-safely.cjs +9 -9
  22. package/dist/utils/write-file-safely.mjs +3 -3
  23. package/dist/utils/write-file-safely.mjs.map +1 -1
  24. package/dist/zod/aggregate-helpers.mjs.map +1 -1
  25. package/dist/zod/comments-helpers.mjs.map +1 -1
  26. package/dist/zod/docs-helpers.cjs +2 -2
  27. package/dist/zod/docs-helpers.mjs.map +1 -1
  28. package/dist/zod/generator-helpers.mjs.map +1 -1
  29. package/dist/zod/include-helpers.mjs.map +1 -1
  30. package/dist/zod/model-helpers.cjs +2 -2
  31. package/dist/zod/model-helpers.mjs.map +1 -1
  32. package/dist/zod/modelArgs-helpers.mjs.map +1 -1
  33. package/dist/zod/mongodb-helpers.mjs.map +1 -1
  34. package/dist/zod/select-helpers.mjs.map +1 -1
  35. package/dist/zod/transformer.cjs +2 -2
  36. package/dist/zod/transformer.mjs.map +1 -1
  37. package/package.json +139 -10
@@ -1,11 +1,11 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
9
  var __copyProps = (to, from, except, desc) => {
10
10
  if (from && typeof from === "object" || typeof from === "function") {
11
11
  for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
@@ -1,13 +1,13 @@
1
1
  import { createRequire } from "node:module";
2
2
 
3
- //#region rolldown:runtime
3
+ //#region \0rolldown/runtime.js
4
4
  var __create = Object.create;
5
5
  var __defProp = Object.defineProperty;
6
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
8
8
  var __getProtoOf = Object.getPrototypeOf;
9
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
10
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
11
11
  var __copyProps = (to, from, except, desc) => {
12
12
  if (from && typeof from === "object" || typeof from === "function") {
13
13
  for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
package/dist/config.cjs CHANGED
@@ -1,29 +1,29 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
2
  let zod = require("zod");
3
- zod = require_rolldown_runtime.__toESM(zod);
3
+ zod = require_runtime.__toESM(zod, 1);
4
4
 
5
5
  //#region src/config.ts
6
- let ModelAction = /* @__PURE__ */ function(ModelAction$1) {
7
- ModelAction$1["FIND_UNIQUE"] = "findUnique";
8
- ModelAction$1["FIND_UNIQUE_OR_THROW"] = "findUniqueOrThrow";
9
- ModelAction$1["FIND_FIRST"] = "findFirst";
10
- ModelAction$1["FIND_FIRST_OR_THROW"] = "findFirstOrThrow";
11
- ModelAction$1["FIND_MANY"] = "findMany";
12
- ModelAction$1["CREATE"] = "create";
13
- ModelAction$1["CREATE_MANY"] = "createMany";
14
- ModelAction$1["CREATE_MANY_AND_RETURN"] = "createManyAndReturn";
15
- ModelAction$1["UPDATE"] = "update";
16
- ModelAction$1["UPDATE_MANY"] = "updateMany";
17
- ModelAction$1["UPDATE_MANY_AND_RETURN"] = "updateManyAndReturn";
18
- ModelAction$1["UPSERT"] = "upsert";
19
- ModelAction$1["DELETE"] = "delete";
20
- ModelAction$1["DELETE_MANY"] = "deleteMany";
21
- ModelAction$1["GROUP_BY"] = "groupBy";
22
- ModelAction$1["COUNT"] = "count";
23
- ModelAction$1["AGGREGATE"] = "aggregate";
24
- ModelAction$1["FIND_RAW"] = "findRaw";
25
- ModelAction$1["AGGREGATE_RAW"] = "aggregateRaw";
26
- return ModelAction$1;
6
+ let ModelAction = /* @__PURE__ */ function(ModelAction) {
7
+ ModelAction["FIND_UNIQUE"] = "findUnique";
8
+ ModelAction["FIND_UNIQUE_OR_THROW"] = "findUniqueOrThrow";
9
+ ModelAction["FIND_FIRST"] = "findFirst";
10
+ ModelAction["FIND_FIRST_OR_THROW"] = "findFirstOrThrow";
11
+ ModelAction["FIND_MANY"] = "findMany";
12
+ ModelAction["CREATE"] = "create";
13
+ ModelAction["CREATE_MANY"] = "createMany";
14
+ ModelAction["CREATE_MANY_AND_RETURN"] = "createManyAndReturn";
15
+ ModelAction["UPDATE"] = "update";
16
+ ModelAction["UPDATE_MANY"] = "updateMany";
17
+ ModelAction["UPDATE_MANY_AND_RETURN"] = "updateManyAndReturn";
18
+ ModelAction["UPSERT"] = "upsert";
19
+ ModelAction["DELETE"] = "delete";
20
+ ModelAction["DELETE_MANY"] = "deleteMany";
21
+ ModelAction["GROUP_BY"] = "groupBy";
22
+ ModelAction["COUNT"] = "count";
23
+ ModelAction["AGGREGATE"] = "aggregate";
24
+ ModelAction["FIND_RAW"] = "findRaw";
25
+ ModelAction["AGGREGATE_RAW"] = "aggregateRaw";
26
+ return ModelAction;
27
27
  }({});
28
28
  const modelActionEnum = zod.nativeEnum(ModelAction);
29
29
  const configBoolean = zod.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
package/dist/config.mjs CHANGED
@@ -1,27 +1,27 @@
1
1
  import * as z from "zod";
2
2
 
3
3
  //#region src/config.ts
4
- let ModelAction = /* @__PURE__ */ function(ModelAction$1) {
5
- ModelAction$1["FIND_UNIQUE"] = "findUnique";
6
- ModelAction$1["FIND_UNIQUE_OR_THROW"] = "findUniqueOrThrow";
7
- ModelAction$1["FIND_FIRST"] = "findFirst";
8
- ModelAction$1["FIND_FIRST_OR_THROW"] = "findFirstOrThrow";
9
- ModelAction$1["FIND_MANY"] = "findMany";
10
- ModelAction$1["CREATE"] = "create";
11
- ModelAction$1["CREATE_MANY"] = "createMany";
12
- ModelAction$1["CREATE_MANY_AND_RETURN"] = "createManyAndReturn";
13
- ModelAction$1["UPDATE"] = "update";
14
- ModelAction$1["UPDATE_MANY"] = "updateMany";
15
- ModelAction$1["UPDATE_MANY_AND_RETURN"] = "updateManyAndReturn";
16
- ModelAction$1["UPSERT"] = "upsert";
17
- ModelAction$1["DELETE"] = "delete";
18
- ModelAction$1["DELETE_MANY"] = "deleteMany";
19
- ModelAction$1["GROUP_BY"] = "groupBy";
20
- ModelAction$1["COUNT"] = "count";
21
- ModelAction$1["AGGREGATE"] = "aggregate";
22
- ModelAction$1["FIND_RAW"] = "findRaw";
23
- ModelAction$1["AGGREGATE_RAW"] = "aggregateRaw";
24
- return ModelAction$1;
4
+ let ModelAction = /* @__PURE__ */ function(ModelAction) {
5
+ ModelAction["FIND_UNIQUE"] = "findUnique";
6
+ ModelAction["FIND_UNIQUE_OR_THROW"] = "findUniqueOrThrow";
7
+ ModelAction["FIND_FIRST"] = "findFirst";
8
+ ModelAction["FIND_FIRST_OR_THROW"] = "findFirstOrThrow";
9
+ ModelAction["FIND_MANY"] = "findMany";
10
+ ModelAction["CREATE"] = "create";
11
+ ModelAction["CREATE_MANY"] = "createMany";
12
+ ModelAction["CREATE_MANY_AND_RETURN"] = "createManyAndReturn";
13
+ ModelAction["UPDATE"] = "update";
14
+ ModelAction["UPDATE_MANY"] = "updateMany";
15
+ ModelAction["UPDATE_MANY_AND_RETURN"] = "updateManyAndReturn";
16
+ ModelAction["UPSERT"] = "upsert";
17
+ ModelAction["DELETE"] = "delete";
18
+ ModelAction["DELETE_MANY"] = "deleteMany";
19
+ ModelAction["GROUP_BY"] = "groupBy";
20
+ ModelAction["COUNT"] = "count";
21
+ ModelAction["AGGREGATE"] = "aggregate";
22
+ ModelAction["FIND_RAW"] = "findRaw";
23
+ ModelAction["AGGREGATE_RAW"] = "aggregateRaw";
24
+ return ModelAction;
25
25
  }({});
26
26
  const modelActionEnum = z.nativeEnum(ModelAction);
27
27
  const configBoolean = z.string().trim().transform((value) => !value || value.toLowerCase() === "false" || value.toLowerCase() === "n" || value.toLowerCase() === "no" || value === "0" ? false : value.toLowerCase() === "true" || value.toLowerCase() === "y" || value.toLowerCase() === "yes" || value === "1" ? true : value);
@@ -1 +1 @@
1
- {"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport * as z from \"zod\";\n\nexport enum ModelAction {\n FIND_UNIQUE = \"findUnique\",\n FIND_UNIQUE_OR_THROW = \"findUniqueOrThrow\",\n FIND_FIRST = \"findFirst\",\n FIND_FIRST_OR_THROW = \"findFirstOrThrow\",\n FIND_MANY = \"findMany\",\n CREATE = \"create\",\n CREATE_MANY = \"createMany\",\n CREATE_MANY_AND_RETURN = \"createManyAndReturn\",\n UPDATE = \"update\",\n UPDATE_MANY = \"updateMany\",\n UPDATE_MANY_AND_RETURN = \"updateManyAndReturn\",\n UPSERT = \"upsert\",\n DELETE = \"delete\",\n DELETE_MANY = \"deleteMany\",\n GROUP_BY = \"groupBy\",\n COUNT = \"count\", // TODO: count does not actually exist, why?\n AGGREGATE = \"aggregate\",\n FIND_RAW = \"findRaw\",\n AGGREGATE_RAW = \"aggregateRaw\"\n}\n\nconst modelActionEnum = z.nativeEnum(ModelAction);\n\nconst configBoolean = z\n .string()\n .trim()\n .transform(value =>\n !value ||\n value.toLowerCase() === \"false\" ||\n value.toLowerCase() === \"n\" ||\n value.toLowerCase() === \"no\" ||\n value === \"0\"\n ? false\n : value.toLowerCase() === \"true\" ||\n value.toLowerCase() === \"y\" ||\n value.toLowerCase() === \"yes\" ||\n value === \"1\"\n ? true\n : value\n );\n\nexport const configSchema = z.object({\n debug: configBoolean.default(\"false\"),\n withNext: configBoolean.default(\"true\"),\n withMiddleware: configBoolean.default(\"false\"),\n withShield: configBoolean.default(\"false\"),\n contextPath: z.string().trim().default(\"../context\"),\n trpcOptions: configBoolean.default(\"true\"),\n showModelNameInProcedure: configBoolean.default(\"false\"),\n generateModelActions: z\n .string()\n .default(Object.values(ModelAction).join(\",\"))\n .transform(arg => {\n return arg.split(\",\").map(action => modelActionEnum.parse(action.trim()));\n }),\n\n // Zod configuration\n withZod: configBoolean.default(\"true\"),\n relationModel: configBoolean.default(\"true\").or(z.literal(\"default\")),\n modelSuffix: z.string().default(\"Schema\"),\n modelCase: z.enum([\"PascalCase\", \"camelCase\"]).default(\"camelCase\"),\n useDecimalJs: configBoolean.default(\"true\"),\n imports: z.string().optional(),\n prismaJsonNullability: configBoolean.default(\"true\")\n});\n\nexport type Config = z.infer<typeof configSchema>;\n"],"mappings":";;;AAoBA,IAAY,sDAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGF,MAAM,kBAAkB,EAAE,WAAW,YAAY;AAEjD,MAAM,gBAAgB,EACnB,QAAQ,CACR,MAAM,CACN,WAAU,UACT,CAAC,SACD,MAAM,aAAa,KAAK,WACxB,MAAM,aAAa,KAAK,OACxB,MAAM,aAAa,KAAK,QACxB,UAAU,MACN,QACA,MAAM,aAAa,KAAK,UACtB,MAAM,aAAa,KAAK,OACxB,MAAM,aAAa,KAAK,SACxB,UAAU,MACV,OACA,MACP;AAEH,MAAa,eAAe,EAAE,OAAO;CACnC,OAAO,cAAc,QAAQ,QAAQ;CACrC,UAAU,cAAc,QAAQ,OAAO;CACvC,gBAAgB,cAAc,QAAQ,QAAQ;CAC9C,YAAY,cAAc,QAAQ,QAAQ;CAC1C,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,aAAa;CACpD,aAAa,cAAc,QAAQ,OAAO;CAC1C,0BAA0B,cAAc,QAAQ,QAAQ;CACxD,sBAAsB,EACnB,QAAQ,CACR,QAAQ,OAAO,OAAO,YAAY,CAAC,KAAK,IAAI,CAAC,CAC7C,WAAU,QAAO;AAChB,SAAO,IAAI,MAAM,IAAI,CAAC,KAAI,WAAU,gBAAgB,MAAM,OAAO,MAAM,CAAC,CAAC;GACzE;CAGJ,SAAS,cAAc,QAAQ,OAAO;CACtC,eAAe,cAAc,QAAQ,OAAO,CAAC,GAAG,EAAE,QAAQ,UAAU,CAAC;CACrE,aAAa,EAAE,QAAQ,CAAC,QAAQ,SAAS;CACzC,WAAW,EAAE,KAAK,CAAC,cAAc,YAAY,CAAC,CAAC,QAAQ,YAAY;CACnE,cAAc,cAAc,QAAQ,OAAO;CAC3C,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,uBAAuB,cAAc,QAAQ,OAAO;CACrD,CAAC"}
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport * as z from \"zod\";\n\nexport enum ModelAction {\n FIND_UNIQUE = \"findUnique\",\n FIND_UNIQUE_OR_THROW = \"findUniqueOrThrow\",\n FIND_FIRST = \"findFirst\",\n FIND_FIRST_OR_THROW = \"findFirstOrThrow\",\n FIND_MANY = \"findMany\",\n CREATE = \"create\",\n CREATE_MANY = \"createMany\",\n CREATE_MANY_AND_RETURN = \"createManyAndReturn\",\n UPDATE = \"update\",\n UPDATE_MANY = \"updateMany\",\n UPDATE_MANY_AND_RETURN = \"updateManyAndReturn\",\n UPSERT = \"upsert\",\n DELETE = \"delete\",\n DELETE_MANY = \"deleteMany\",\n GROUP_BY = \"groupBy\",\n COUNT = \"count\", // TODO: count does not actually exist, why?\n AGGREGATE = \"aggregate\",\n FIND_RAW = \"findRaw\",\n AGGREGATE_RAW = \"aggregateRaw\"\n}\n\nconst modelActionEnum = z.nativeEnum(ModelAction);\n\nconst configBoolean = z\n .string()\n .trim()\n .transform(value =>\n !value ||\n value.toLowerCase() === \"false\" ||\n value.toLowerCase() === \"n\" ||\n value.toLowerCase() === \"no\" ||\n value === \"0\"\n ? false\n : value.toLowerCase() === \"true\" ||\n value.toLowerCase() === \"y\" ||\n value.toLowerCase() === \"yes\" ||\n value === \"1\"\n ? true\n : value\n );\n\nexport const configSchema = z.object({\n debug: configBoolean.default(\"false\"),\n withNext: configBoolean.default(\"true\"),\n withMiddleware: configBoolean.default(\"false\"),\n withShield: configBoolean.default(\"false\"),\n contextPath: z.string().trim().default(\"../context\"),\n trpcOptions: configBoolean.default(\"true\"),\n showModelNameInProcedure: configBoolean.default(\"false\"),\n generateModelActions: z\n .string()\n .default(Object.values(ModelAction).join(\",\"))\n .transform(arg => {\n return arg.split(\",\").map(action => modelActionEnum.parse(action.trim()));\n }),\n\n // Zod configuration\n withZod: configBoolean.default(\"true\"),\n relationModel: configBoolean.default(\"true\").or(z.literal(\"default\")),\n modelSuffix: z.string().default(\"Schema\"),\n modelCase: z.enum([\"PascalCase\", \"camelCase\"]).default(\"camelCase\"),\n useDecimalJs: configBoolean.default(\"true\"),\n imports: z.string().optional(),\n prismaJsonNullability: configBoolean.default(\"true\")\n});\n\nexport type Config = z.infer<typeof configSchema>;\n"],"mappings":";;;AAoBA,IAAY,cAAL;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;KACD;AAED,MAAM,kBAAkB,EAAE,WAAW,YAAY;AAEjD,MAAM,gBAAgB,EACnB,QAAQ,CACR,MAAM,CACN,WAAU,UACT,CAAC,SACD,MAAM,aAAa,KAAK,WACxB,MAAM,aAAa,KAAK,OACxB,MAAM,aAAa,KAAK,QACxB,UAAU,MACN,QACA,MAAM,aAAa,KAAK,UACtB,MAAM,aAAa,KAAK,OACxB,MAAM,aAAa,KAAK,SACxB,UAAU,MACV,OACA,MACP;AAEH,MAAa,eAAe,EAAE,OAAO;CACnC,OAAO,cAAc,QAAQ,QAAQ;CACrC,UAAU,cAAc,QAAQ,OAAO;CACvC,gBAAgB,cAAc,QAAQ,QAAQ;CAC9C,YAAY,cAAc,QAAQ,QAAQ;CAC1C,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,aAAa;CACpD,aAAa,cAAc,QAAQ,OAAO;CAC1C,0BAA0B,cAAc,QAAQ,QAAQ;CACxD,sBAAsB,EACnB,QAAQ,CACR,QAAQ,OAAO,OAAO,YAAY,CAAC,KAAK,IAAI,CAAC,CAC7C,WAAU,QAAO;AAChB,SAAO,IAAI,MAAM,IAAI,CAAC,KAAI,WAAU,gBAAgB,MAAM,OAAO,MAAM,CAAC,CAAC;GACzE;CAGJ,SAAS,cAAc,QAAQ,OAAO;CACtC,eAAe,cAAc,QAAQ,OAAO,CAAC,GAAG,EAAE,QAAQ,UAAU,CAAC;CACrE,aAAa,EAAE,QAAQ,CAAC,QAAQ,SAAS;CACzC,WAAW,EAAE,KAAK,CAAC,cAAc,YAAY,CAAC,CAAC,QAAQ,YAAY;CACnE,cAAc,cAAc,QAAQ,OAAO;CAC3C,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,uBAAuB,cAAc,QAAQ,OAAO;CACrD,CAAC"}
package/dist/helpers.cjs CHANGED
@@ -1,10 +1,10 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
1
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
2
  const require_lower_case_first = require('./packages/string-format/src/lower-case-first.cjs');
3
3
  const require_project = require('./project.cjs');
4
4
  require('./utils/get-prisma-internals.cjs');
5
5
  const require_model_helpers = require('./zod/model-helpers.cjs');
6
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
7
- let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
6
+ let _stryke_path_join_paths = require("@stryke/path/join-paths");
7
+ let _stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
8
8
 
9
9
  //#region src/helpers.ts
10
10
  const getProcedureName = (config) => {
@@ -26,12 +26,12 @@ const generateRouterImport = (sourceFile, modelNamePlural, modelNameCamelCase) =
26
26
  };
27
27
  async function generateTRPCExports(sourceFile, config, options, outputDir) {
28
28
  if (config.withShield) sourceFile.addImportDeclaration({
29
- moduleSpecifier: (0, __stryke_path_file_path_fns.relativePath)(outputDir, (0, __stryke_path_join_paths.joinPaths)(outputDir, typeof config.withShield === "string" ? config.withShield : "shield")),
29
+ moduleSpecifier: (0, _stryke_path_file_path_fns.relativePath)(outputDir, (0, _stryke_path_join_paths.joinPaths)(outputDir, typeof config.withShield === "string" ? config.withShield : "shield")),
30
30
  namedImports: ["permissions"]
31
31
  });
32
- sourceFile.addStatements(`import type { Context } from '${(0, __stryke_path_file_path_fns.relativePath)(outputDir, (0, __stryke_path_join_paths.joinPaths)(outputDir, config.contextPath))}';`);
33
- if (config.trpcOptions) sourceFile.addStatements(`import trpcOptions from '${typeof config.trpcOptions === "string" ? (0, __stryke_path_file_path_fns.relativePath)(outputDir, (0, __stryke_path_join_paths.joinPaths)(outputDir, config.trpcOptions)) : "./options"}';`);
34
- if (config.withNext) sourceFile.addStatements(`import { createContext } from '${(0, __stryke_path_file_path_fns.relativePath)(outputDir, (0, __stryke_path_join_paths.joinPaths)(outputDir, config.contextPath))}';
32
+ sourceFile.addStatements(`import type { Context } from '${(0, _stryke_path_file_path_fns.relativePath)(outputDir, (0, _stryke_path_join_paths.joinPaths)(outputDir, config.contextPath))}';`);
33
+ if (config.trpcOptions) sourceFile.addStatements(`import trpcOptions from '${typeof config.trpcOptions === "string" ? (0, _stryke_path_file_path_fns.relativePath)(outputDir, (0, _stryke_path_join_paths.joinPaths)(outputDir, config.trpcOptions)) : "./options"}';`);
34
+ if (config.withNext) sourceFile.addStatements(`import { createContext } from '${(0, _stryke_path_file_path_fns.relativePath)(outputDir, (0, _stryke_path_join_paths.joinPaths)(outputDir, config.contextPath))}';
35
35
  import { initTRPC } from '@trpc/server';
36
36
  import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
37
37
  import { cookies } from "next/headers";`);
@@ -51,7 +51,7 @@ export const globalMiddleware = t.middleware(async ({ ctx, next }) => {
51
51
  }
52
52
  if (config.withMiddleware && typeof config.withMiddleware === "string") {
53
53
  sourceFile.addStatements(`
54
- import middleware from '${(0, __stryke_path_file_path_fns.relativePath)(outputDir, (0, __stryke_path_join_paths.joinPaths)(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
54
+ import middleware from '${(0, _stryke_path_file_path_fns.relativePath)(outputDir, (0, _stryke_path_join_paths.joinPaths)(outputDir, typeof config.withMiddleware === "string" ? config.withMiddleware : "middleware"))}';
55
55
  `);
56
56
  sourceFile.addStatements(`
57
57
  export const globalMiddleware = t.middleware(middleware);`);
@@ -258,7 +258,7 @@ const constructShield = async ({ queries, mutations, subscriptions }, config, op
258
258
  }
259
259
  if (rootItems.length === 0) return "";
260
260
  let shieldText = getImports("trpc-shield");
261
- shieldText += getImports("context", (0, __stryke_path_file_path_fns.relativePath)(outputDir, (0, __stryke_path_join_paths.joinPaths)(outputDir, config.contextPath)));
261
+ shieldText += getImports("context", (0, _stryke_path_file_path_fns.relativePath)(outputDir, (0, _stryke_path_join_paths.joinPaths)(outputDir, config.contextPath)));
262
262
  shieldText += "\n\n";
263
263
  shieldText += wrapWithExport({ shieldObjectText: wrapWithTrpcShieldCall({ shieldObjectTextWrapped: wrapWithObject({ shieldItemLines: rootItems }) }) });
264
264
  return shieldText;
@@ -269,7 +269,7 @@ import type {
269
269
  DataTransformerOptions,
270
270
  RootConfig
271
271
  } from "@trpc/server/unstable-core-do-not-import";
272
- import type { Context } from "${(0, __stryke_path_file_path_fns.relativePath)(outputDir, (0, __stryke_path_join_paths.joinPaths)(outputDir, config.contextPath))}";
272
+ import type { Context } from "${(0, _stryke_path_file_path_fns.relativePath)(outputDir, (0, _stryke_path_join_paths.joinPaths)(outputDir, config.contextPath))}";
273
273
 
274
274
  interface RuntimeConfigOptions<
275
275
  TContext extends object,
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","names":["parsedAttributeArgs: Record<string, unknown>"],"sources":["../src/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/* eslint-disable ts/no-use-before-define */\n\nimport type {\n DMMF,\n EnvValue,\n GeneratorOptions\n} from \"@prisma/generator-helper\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { lowerCaseFirst } from \"@stryke/string-format/lower-case-first\";\nimport type { SourceFile } from \"ts-morph\";\nimport type { Config } from \"./config\";\nimport { project } from \"./project\";\nimport type { Writeable } from \"./types\";\nimport { getPrismaInternals } from \"./utils/get-prisma-internals\";\nimport { generateBarrelFile, populateModelFile } from \"./zod/model-helpers\";\n\nconst getProcedureName = (config: Config) => {\n return config.withShield\n ? \"shieldedProcedure\"\n : config.withMiddleware\n ? \"protectedProcedure\"\n : \"publicProcedure\";\n};\n\nexport const generateCreateRouterImport = ({\n sourceFile,\n config\n}: {\n sourceFile: SourceFile;\n config?: Config;\n}) => {\n const imports = [\"t\"];\n\n if (config) {\n imports.push(getProcedureName(config));\n }\n\n sourceFile.addImportDeclaration({\n moduleSpecifier: \"../trpc\",\n namedImports: imports\n });\n};\n\nexport const generateRPCImport = (sourceFile: SourceFile) => {\n sourceFile.addImportDeclaration({\n moduleSpecifier: \"@trpc/server\",\n namespaceImport: \"trpc\"\n });\n};\n\nexport const generateMiddlewareImport = async (\n sourceFile: SourceFile,\n options: GeneratorOptions\n) => {\n const internals = await getPrismaInternals();\n\n const outputDir = internals.parseEnvValue(\n options.generator.output as EnvValue\n );\n sourceFile.addImportDeclaration({\n moduleSpecifier: relativePath(\n outputDir,\n joinPaths(outputDir, \"middleware\")\n ),\n namedImports: [\"permissions\"]\n });\n};\n\nexport const generateRouterImport = (\n sourceFile: SourceFile,\n modelNamePlural: string,\n modelNameCamelCase: string\n) => {\n sourceFile.addImportDeclaration({\n moduleSpecifier: `./${lowerCaseFirst(modelNameCamelCase)}.router`,\n namedImports: [`${modelNamePlural}Router`]\n });\n};\n\nexport async function generateTRPCExports(\n sourceFile: SourceFile,\n config: Config,\n options: GeneratorOptions,\n outputDir: string\n) {\n if (config.withShield) {\n sourceFile.addImportDeclaration({\n moduleSpecifier: relativePath(\n outputDir,\n joinPaths(\n outputDir,\n typeof config.withShield === \"string\" ? config.withShield : \"shield\"\n )\n ),\n namedImports: [\"permissions\"]\n });\n }\n\n sourceFile.addStatements(\n /* ts */ `import type { Context } from '${relativePath(\n outputDir,\n joinPaths(outputDir, config.contextPath)\n )}';`\n );\n\n if (config.trpcOptions) {\n sourceFile.addStatements(\n /* ts */ `import trpcOptions from '${\n typeof config.trpcOptions === \"string\"\n ? relativePath(outputDir, joinPaths(outputDir, config.trpcOptions))\n : \"./options\"\n }';`\n );\n }\n\n if (config.withNext) {\n sourceFile.addStatements(/* ts */ `import { createContext } from '${relativePath(\n outputDir,\n joinPaths(outputDir, config.contextPath)\n )}';\nimport { initTRPC } from '@trpc/server';\nimport { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';\nimport { cookies } from \"next/headers\";`);\n }\n\n sourceFile.addStatements(/* ts */ `\nexport const t = initTRPC.context<Context>().create(${\n config.trpcOptions ? \"trpcOptions\" : \"\"\n });`);\n\n const middlewares = [];\n\n if (config.withMiddleware && typeof config.withMiddleware === \"boolean\") {\n sourceFile.addStatements(/* ts */ `\nexport const globalMiddleware = t.middleware(async ({ ctx, next }) => {\n console.log('inside middleware!')\n return next()\n});`);\n middlewares.push({\n type: \"global\",\n value: /* ts */ `.use(globalMiddleware)`\n });\n }\n\n if (config.withMiddleware && typeof config.withMiddleware === \"string\") {\n sourceFile.addStatements(/* ts */ `\nimport middleware from '${relativePath(\n outputDir,\n joinPaths(\n outputDir,\n typeof config.withMiddleware === \"string\"\n ? config.withMiddleware\n : \"middleware\"\n )\n )}';\n `);\n sourceFile.addStatements(/* ts */ `\nexport const globalMiddleware = t.middleware(middleware);`);\n middlewares.push({\n type: \"global\",\n value: /* ts */ `.use(globalMiddleware)`\n });\n }\n\n if (config.withShield) {\n sourceFile.addStatements(/* ts */ `\nexport const permissionsMiddleware = t.middleware(permissions);\n `);\n\n middlewares.push({\n type: \"shield\",\n value: /* ts */ `\n .use(permissions)`\n });\n }\n\n sourceFile.addStatements(/* ts */ `\n/**\n * Create a server-side caller\n * @see https://trpc.io/docs/server/server-side-calls\n */\nexport const createCallerFactory = t.createCallerFactory;`);\n\n sourceFile.addStatements(/* ts */ `\nexport const publicProcedure = t.procedure; `);\n\n if (middlewares.length > 0) {\n const procName = getProcedureName(config);\n\n middlewares.forEach((middleware, i) => {\n if (i === 0) {\n sourceFile.addStatements(/* ts */ `\nexport const ${procName} = t.procedure`);\n }\n\n sourceFile.addStatements(\n /* ts */ `.use(${\n middleware.type === \"shield\"\n ? \"permissionsMiddleware\"\n : \"globalMiddleware\"\n })`\n );\n });\n }\n\n if (config.withNext) {\n sourceFile.addStatements(/* ts */ `\nexport const createAction: ReturnType<typeof createTRPCServerActionHandler> =\n createTRPCServerActionHandler(cookies, t, createContext);\n`);\n }\n\n sourceFile.formatText({\n indentSize: 2\n });\n}\n\nexport function generateProcedure(\n sourceFile: SourceFile,\n name: string,\n typeName: string,\n modelName: string,\n opType: string,\n baseOpType: string,\n config: Config\n) {\n let input = `input${!config.withZod ? \" as any\" : \"\"}`;\n const nameWithoutModel = name.replace(modelName, \"\");\n if (nameWithoutModel === \"groupBy\" && config.withZod) {\n input =\n \"{ where: input.where, orderBy: input.orderBy, by: input.by, having: input.having, take: input.take, skip: input.skip }\";\n }\n sourceFile.addStatements(/* ts */ `${\n config.showModelNameInProcedure ? name : nameWithoutModel\n }: ${getProcedureName(config)}\n ${config.withZod ? `.input(${lowerCaseFirst(typeName)})` : \"\"}.${getProcedureTypeByOpName(\n baseOpType\n )}(async ({ ctx, input }) => {\n const ${name} = await ctx.prisma.${lowerCaseFirst(\n modelName\n )}.${opType.replace(\"One\", \"\")}(${input});\n return ${name};\n }),`);\n}\n\nexport function generateRouterSchemaImports(\n sourceFile: SourceFile,\n modelName: string,\n modelActions: string[]\n) {\n sourceFile.addStatements(\n /* ts */\n [\n // remove any duplicate import statements\n ...new Set(\n modelActions.map(opName =>\n getRouterSchemaImportByOpName(opName, modelName)\n )\n )\n ].join(\"\\n\")\n );\n}\n\nexport const getRouterSchemaImportByOpName = (\n opName: string,\n modelName: string\n) => {\n const opType = opName.replace(\"OrThrow\", \"\").replace(\"ManyAndReturn\", \"\");\n const inputType = getInputTypeByOpName(opType, modelName);\n\n return inputType\n ? `import { ${lowerCaseFirst(inputType)} } from \"../schemas/${lowerCaseFirst(opType)}${modelName}.schema\"; `\n : \"\";\n};\n\nexport const getInputTypeByOpName = (opName: string, modelName: string) => {\n let inputType;\n switch (opName) {\n case \"findUnique\":\n inputType = `${modelName}FindUniqueSchema`;\n break;\n case \"findFirst\":\n inputType = `${modelName}FindFirstSchema`;\n break;\n case \"findMany\":\n inputType = `${modelName}FindManySchema`;\n break;\n case \"findRaw\":\n inputType = `${modelName}FindRawObjectSchema`;\n break;\n case \"createOne\":\n inputType = `${modelName}CreateOneSchema`;\n break;\n case \"createMany\":\n inputType = `${modelName}CreateManySchema`;\n break;\n case \"createManyAndReturn\":\n inputType = `${modelName}CreateManySchema`;\n break;\n case \"deleteOne\":\n inputType = `${modelName}DeleteOneSchema`;\n break;\n case \"deleteMany\":\n inputType = `${modelName}DeleteManySchema`;\n break;\n case \"updateOne\":\n inputType = `${modelName}UpdateOneSchema`;\n break;\n case \"updateMany\":\n inputType = `${modelName}UpdateManySchema`;\n break;\n case \"updateManyAndReturn\":\n inputType = `${modelName}UpdateManySchema`;\n break;\n case \"upsertOne\":\n inputType = `${modelName}UpsertSchema`;\n break;\n case \"aggregate\":\n inputType = `${modelName}AggregateSchema`;\n break;\n case \"aggregateRaw\":\n inputType = `${modelName}AggregateRawObjectSchema`;\n break;\n case \"groupBy\":\n inputType = `${modelName}GroupBySchema`;\n break;\n default:\n // eslint-disable-next-line no-console\n console.log(\"getInputTypeByOpName: \", { opName, modelName });\n }\n return inputType;\n};\n\nexport const getProcedureTypeByOpName = (opName: string) => {\n let procType;\n switch (opName) {\n case \"findUnique\":\n case \"findFirst\":\n case \"findMany\":\n case \"findRaw\":\n case \"aggregate\":\n case \"aggregateRaw\":\n case \"groupBy\":\n procType = \"query\";\n break;\n case \"createOne\":\n case \"createMany\":\n case \"createManyAndReturn\":\n case \"deleteOne\":\n case \"updateOne\":\n case \"deleteMany\":\n case \"updateMany\":\n case \"updateManyAndReturn\":\n case \"upsertOne\":\n procType = \"mutation\";\n break;\n default:\n // eslint-disable-next-line no-console\n console.log(\"getProcedureTypeByOpName: \", { opName });\n }\n return procType;\n};\n\nexport function resolveModelsComments(\n models: DMMF.Model[],\n hiddenModels: string[]\n) {\n // eslint-disable-next-line regexp/no-obscure-range\n const modelAttributeRegex = /(?:@@Gen\\.)+[A-z]+\\(.+\\)/;\n const attributeNameRegex = /\\.+[A-Z]+\\(+/i;\n const attributeArgsRegex = /\\(+[A-Z]+:.+\\)/i;\n\n for (const model of models) {\n if (model.documentation) {\n const attribute = model.documentation?.match(modelAttributeRegex)?.[0];\n const attributeName = attribute\n ?.match(attributeNameRegex)?.[0]\n ?.slice(1, -1);\n if (attributeName !== \"model\") continue;\n const rawAttributeArgs = attribute\n ?.match(attributeArgsRegex)?.[0]\n ?.slice(1, -1);\n\n const parsedAttributeArgs: Record<string, unknown> = {};\n if (rawAttributeArgs) {\n const rawAttributeArgsParts = rawAttributeArgs\n .split(\":\")\n .map(it => it.trim())\n .map(part => (part.startsWith(\"[\") ? part : part.split(\",\")))\n .flat()\n .map(it => it.trim());\n\n for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {\n const key = rawAttributeArgsParts[i];\n const value = rawAttributeArgsParts[i + 1];\n parsedAttributeArgs[key!] = JSON.parse(value!);\n }\n }\n\n if (parsedAttributeArgs.hide) {\n hiddenModels.push(model.name);\n }\n }\n }\n}\n\nexport const getImports = (\n type: \"trpc\" | \"trpc-shield\" | \"context\",\n newPath?: string\n) => {\n let statement = \"\";\n if (type === \"trpc\") {\n statement = \"import * as trpc from '@trpc/server';\\n\";\n } else if (type === \"trpc-shield\") {\n statement = \"import { shield, allow } from '@stryke/trpc-next/shield';\\n\";\n } else if (type === \"context\") {\n statement = `import type { Context } from '${newPath}';\\n`;\n }\n\n return statement;\n};\n\nexport const wrapWithObject = ({\n shieldItemLines\n}: {\n shieldItemLines: Array<string> | string;\n}) => {\n let wrapped = \"{\";\n wrapped += \"\\n\";\n wrapped += Array.isArray(shieldItemLines)\n ? ` ${shieldItemLines.join(\",\\r\\n\")}`\n : ` ${shieldItemLines}`;\n wrapped += \"\\n\";\n wrapped += \"}\";\n return wrapped;\n};\n\nexport const wrapWithTrpcShieldCall = ({\n shieldObjectTextWrapped\n}: {\n shieldObjectTextWrapped: string;\n}) => {\n let wrapped = \"shield<Context>(\";\n wrapped += \"\\n\";\n wrapped += ` ${shieldObjectTextWrapped}`;\n wrapped += \"\\n\";\n wrapped += \")\";\n return wrapped;\n};\n\nexport const wrapWithExport = ({\n shieldObjectText\n}: {\n shieldObjectText: string;\n}) => {\n return `export const permissions: ReturnType<typeof shield<Context>> = ${shieldObjectText};`;\n};\n\nexport const constructShield = async (\n {\n queries,\n mutations,\n subscriptions\n }: {\n queries: Array<string>;\n mutations: Array<string>;\n subscriptions: Array<string>;\n },\n config: Config,\n options: GeneratorOptions,\n outputDir: string\n) => {\n if (\n queries.length === 0 &&\n mutations.length === 0 &&\n subscriptions.length === 0\n ) {\n return \"\";\n }\n\n let rootItems = \"\";\n if (queries.length > 0) {\n const queryLinesWrapped = `query: ${wrapWithObject({\n shieldItemLines: queries.map(query => `${query}: allow`)\n })},`;\n rootItems += queryLinesWrapped;\n }\n if (mutations.length > 0) {\n const mutationLinesWrapped = `mutation: ${wrapWithObject({\n shieldItemLines: mutations.map(mutation => `${mutation}: allow`)\n })},`;\n rootItems += mutationLinesWrapped;\n }\n\n if (subscriptions.length > 0) {\n const subscriptionLinesWrapped = `subscription: ${wrapWithObject({\n shieldItemLines: subscriptions.map(\n subscription => `${subscription}: allow`\n )\n })},`;\n rootItems += subscriptionLinesWrapped;\n }\n\n if (rootItems.length === 0) {\n return \"\";\n }\n\n let shieldText = getImports(\"trpc-shield\");\n shieldText += getImports(\n \"context\",\n relativePath(outputDir, joinPaths(outputDir, config.contextPath))\n );\n shieldText += \"\\n\\n\";\n shieldText += wrapWithExport({\n shieldObjectText: wrapWithTrpcShieldCall({\n shieldObjectTextWrapped: wrapWithObject({ shieldItemLines: rootItems })\n })\n });\n\n return shieldText;\n};\n\nexport const constructDefaultOptions = (\n config: Config,\n options: GeneratorOptions,\n outputDir: string\n) => {\n return `import { ZodError } from 'zod';${config.withNext ? '\\nimport { transformer } from \"@stryke/trpc-next/shared\";' : \"\"}\nimport type {\n DataTransformerOptions,\n RootConfig\n} from \"@trpc/server/unstable-core-do-not-import\";\nimport type { Context } from \"${relativePath(outputDir, joinPaths(outputDir, config.contextPath))}\";\n\ninterface RuntimeConfigOptions<\n TContext extends object,\n TMeta extends object = object\n> extends Partial<\n Omit<\n RootConfig<{\n ctx: TContext;\n meta: TMeta;\n errorShape: any;\n transformer: any;\n }>,\n \"$types\" | \"transformer\"\n >\n > {\n /**\n * Use a data transformer\n * @see https://trpc.io/docs/v11/data-transformers\n */\n transformer?: DataTransformerOptions;\n}\n\nconst options: RuntimeConfigOptions<Context> = {${config.withNext ? \"\\n transformer,\" : \"\"}\n errorFormatter({ shape, error }) {\n return {\n ...shape,\n data: {\n ...shape.data,\n zodError:\n error.code === \"BAD_REQUEST\" && error.cause instanceof ZodError\n ? error.cause.flatten()\n : null\n }\n };\n }\n};\n\nexport default options;\n`;\n};\n\nexport const constructZodModels = async (\n models: Writeable<DMMF.Model[]>,\n outputPath: string,\n config: Config,\n options: GeneratorOptions\n) => {\n const indexFile = project.createSourceFile(\n `${outputPath}/index.ts`,\n {},\n { overwrite: true }\n );\n\n generateBarrelFile(models, indexFile);\n\n indexFile.formatText({\n indentSize: 2\n });\n\n await Promise.all(\n models.map(async model => {\n const sourceFile = project.createSourceFile(\n `${outputPath}/${lowerCaseFirst(model.name)}.schema.ts`,\n {},\n { overwrite: true }\n );\n\n await populateModelFile(model, sourceFile, config, options);\n\n sourceFile.formatText({\n indentSize: 2\n });\n })\n );\n};\n"],"mappings":";;;;;;;;AAmCA,MAAM,oBAAoB,WAAmB;AAC3C,QAAO,OAAO,aACV,sBACA,OAAO,iBACL,uBACA;;AAGR,MAAa,8BAA8B,EACzC,YACA,aAII;CACJ,MAAM,UAAU,CAAC,IAAI;AAErB,KAAI,OACF,SAAQ,KAAK,iBAAiB,OAAO,CAAC;AAGxC,YAAW,qBAAqB;EAC9B,iBAAiB;EACjB,cAAc;EACf,CAAC;;AA4BJ,MAAa,wBACX,YACA,iBACA,uBACG;AACH,YAAW,qBAAqB;EAC9B,iBAAiB,KAAK,eAAe,mBAAmB,CAAC;EACzD,cAAc,CAAC,GAAG,gBAAgB,QAAQ;EAC3C,CAAC;;AAGJ,eAAsB,oBACpB,YACA,QACA,SACA,WACA;AACA,KAAI,OAAO,WACT,YAAW,qBAAqB;EAC9B,iBAAiB,aACf,WACA,UACE,WACA,OAAO,OAAO,eAAe,WAAW,OAAO,aAAa,SAC7D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------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/* eslint-disable ts/no-use-before-define */\n\nimport type {\n DMMF,\n EnvValue,\n GeneratorOptions\n} from \"@prisma/generator-helper\";\nimport { relativePath } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { lowerCaseFirst } from \"@stryke/string-format/lower-case-first\";\nimport type { SourceFile } from \"ts-morph\";\nimport type { Config } from \"./config\";\nimport { project } from \"./project\";\nimport type { Writeable } from \"./types\";\nimport { getPrismaInternals } from \"./utils/get-prisma-internals\";\nimport { generateBarrelFile, populateModelFile } from \"./zod/model-helpers\";\n\nconst getProcedureName = (config: Config) => {\n return config.withShield\n ? \"shieldedProcedure\"\n : config.withMiddleware\n ? \"protectedProcedure\"\n : \"publicProcedure\";\n};\n\nexport const generateCreateRouterImport = ({\n sourceFile,\n config\n}: {\n sourceFile: SourceFile;\n config?: Config;\n}) => {\n const imports = [\"t\"];\n\n if (config) {\n imports.push(getProcedureName(config));\n }\n\n sourceFile.addImportDeclaration({\n moduleSpecifier: \"../trpc\",\n namedImports: imports\n });\n};\n\nexport const generateRPCImport = (sourceFile: SourceFile) => {\n sourceFile.addImportDeclaration({\n moduleSpecifier: \"@trpc/server\",\n namespaceImport: \"trpc\"\n });\n};\n\nexport const generateMiddlewareImport = async (\n sourceFile: SourceFile,\n options: GeneratorOptions\n) => {\n const internals = await getPrismaInternals();\n\n const outputDir = internals.parseEnvValue(\n options.generator.output as EnvValue\n );\n sourceFile.addImportDeclaration({\n moduleSpecifier: relativePath(\n outputDir,\n joinPaths(outputDir, \"middleware\")\n ),\n namedImports: [\"permissions\"]\n });\n};\n\nexport const generateRouterImport = (\n sourceFile: SourceFile,\n modelNamePlural: string,\n modelNameCamelCase: string\n) => {\n sourceFile.addImportDeclaration({\n moduleSpecifier: `./${lowerCaseFirst(modelNameCamelCase)}.router`,\n namedImports: [`${modelNamePlural}Router`]\n });\n};\n\nexport async function generateTRPCExports(\n sourceFile: SourceFile,\n config: Config,\n options: GeneratorOptions,\n outputDir: string\n) {\n if (config.withShield) {\n sourceFile.addImportDeclaration({\n moduleSpecifier: relativePath(\n outputDir,\n joinPaths(\n outputDir,\n typeof config.withShield === \"string\" ? config.withShield : \"shield\"\n )\n ),\n namedImports: [\"permissions\"]\n });\n }\n\n sourceFile.addStatements(\n /* ts */ `import type { Context } from '${relativePath(\n outputDir,\n joinPaths(outputDir, config.contextPath)\n )}';`\n );\n\n if (config.trpcOptions) {\n sourceFile.addStatements(\n /* ts */ `import trpcOptions from '${\n typeof config.trpcOptions === \"string\"\n ? relativePath(outputDir, joinPaths(outputDir, config.trpcOptions))\n : \"./options\"\n }';`\n );\n }\n\n if (config.withNext) {\n sourceFile.addStatements(/* ts */ `import { createContext } from '${relativePath(\n outputDir,\n joinPaths(outputDir, config.contextPath)\n )}';\nimport { initTRPC } from '@trpc/server';\nimport { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';\nimport { cookies } from \"next/headers\";`);\n }\n\n sourceFile.addStatements(/* ts */ `\nexport const t = initTRPC.context<Context>().create(${\n config.trpcOptions ? \"trpcOptions\" : \"\"\n });`);\n\n const middlewares = [];\n\n if (config.withMiddleware && typeof config.withMiddleware === \"boolean\") {\n sourceFile.addStatements(/* ts */ `\nexport const globalMiddleware = t.middleware(async ({ ctx, next }) => {\n console.log('inside middleware!')\n return next()\n});`);\n middlewares.push({\n type: \"global\",\n value: /* ts */ `.use(globalMiddleware)`\n });\n }\n\n if (config.withMiddleware && typeof config.withMiddleware === \"string\") {\n sourceFile.addStatements(/* ts */ `\nimport middleware from '${relativePath(\n outputDir,\n joinPaths(\n outputDir,\n typeof config.withMiddleware === \"string\"\n ? config.withMiddleware\n : \"middleware\"\n )\n )}';\n `);\n sourceFile.addStatements(/* ts */ `\nexport const globalMiddleware = t.middleware(middleware);`);\n middlewares.push({\n type: \"global\",\n value: /* ts */ `.use(globalMiddleware)`\n });\n }\n\n if (config.withShield) {\n sourceFile.addStatements(/* ts */ `\nexport const permissionsMiddleware = t.middleware(permissions);\n `);\n\n middlewares.push({\n type: \"shield\",\n value: /* ts */ `\n .use(permissions)`\n });\n }\n\n sourceFile.addStatements(/* ts */ `\n/**\n * Create a server-side caller\n * @see https://trpc.io/docs/server/server-side-calls\n */\nexport const createCallerFactory = t.createCallerFactory;`);\n\n sourceFile.addStatements(/* ts */ `\nexport const publicProcedure = t.procedure; `);\n\n if (middlewares.length > 0) {\n const procName = getProcedureName(config);\n\n middlewares.forEach((middleware, i) => {\n if (i === 0) {\n sourceFile.addStatements(/* ts */ `\nexport const ${procName} = t.procedure`);\n }\n\n sourceFile.addStatements(\n /* ts */ `.use(${\n middleware.type === \"shield\"\n ? \"permissionsMiddleware\"\n : \"globalMiddleware\"\n })`\n );\n });\n }\n\n if (config.withNext) {\n sourceFile.addStatements(/* ts */ `\nexport const createAction: ReturnType<typeof createTRPCServerActionHandler> =\n createTRPCServerActionHandler(cookies, t, createContext);\n`);\n }\n\n sourceFile.formatText({\n indentSize: 2\n });\n}\n\nexport function generateProcedure(\n sourceFile: SourceFile,\n name: string,\n typeName: string,\n modelName: string,\n opType: string,\n baseOpType: string,\n config: Config\n) {\n let input = `input${!config.withZod ? \" as any\" : \"\"}`;\n const nameWithoutModel = name.replace(modelName, \"\");\n if (nameWithoutModel === \"groupBy\" && config.withZod) {\n input =\n \"{ where: input.where, orderBy: input.orderBy, by: input.by, having: input.having, take: input.take, skip: input.skip }\";\n }\n sourceFile.addStatements(/* ts */ `${\n config.showModelNameInProcedure ? name : nameWithoutModel\n }: ${getProcedureName(config)}\n ${config.withZod ? `.input(${lowerCaseFirst(typeName)})` : \"\"}.${getProcedureTypeByOpName(\n baseOpType\n )}(async ({ ctx, input }) => {\n const ${name} = await ctx.prisma.${lowerCaseFirst(\n modelName\n )}.${opType.replace(\"One\", \"\")}(${input});\n return ${name};\n }),`);\n}\n\nexport function generateRouterSchemaImports(\n sourceFile: SourceFile,\n modelName: string,\n modelActions: string[]\n) {\n sourceFile.addStatements(\n /* ts */\n [\n // remove any duplicate import statements\n ...new Set(\n modelActions.map(opName =>\n getRouterSchemaImportByOpName(opName, modelName)\n )\n )\n ].join(\"\\n\")\n );\n}\n\nexport const getRouterSchemaImportByOpName = (\n opName: string,\n modelName: string\n) => {\n const opType = opName.replace(\"OrThrow\", \"\").replace(\"ManyAndReturn\", \"\");\n const inputType = getInputTypeByOpName(opType, modelName);\n\n return inputType\n ? `import { ${lowerCaseFirst(inputType)} } from \"../schemas/${lowerCaseFirst(opType)}${modelName}.schema\"; `\n : \"\";\n};\n\nexport const getInputTypeByOpName = (opName: string, modelName: string) => {\n let inputType;\n switch (opName) {\n case \"findUnique\":\n inputType = `${modelName}FindUniqueSchema`;\n break;\n case \"findFirst\":\n inputType = `${modelName}FindFirstSchema`;\n break;\n case \"findMany\":\n inputType = `${modelName}FindManySchema`;\n break;\n case \"findRaw\":\n inputType = `${modelName}FindRawObjectSchema`;\n break;\n case \"createOne\":\n inputType = `${modelName}CreateOneSchema`;\n break;\n case \"createMany\":\n inputType = `${modelName}CreateManySchema`;\n break;\n case \"createManyAndReturn\":\n inputType = `${modelName}CreateManySchema`;\n break;\n case \"deleteOne\":\n inputType = `${modelName}DeleteOneSchema`;\n break;\n case \"deleteMany\":\n inputType = `${modelName}DeleteManySchema`;\n break;\n case \"updateOne\":\n inputType = `${modelName}UpdateOneSchema`;\n break;\n case \"updateMany\":\n inputType = `${modelName}UpdateManySchema`;\n break;\n case \"updateManyAndReturn\":\n inputType = `${modelName}UpdateManySchema`;\n break;\n case \"upsertOne\":\n inputType = `${modelName}UpsertSchema`;\n break;\n case \"aggregate\":\n inputType = `${modelName}AggregateSchema`;\n break;\n case \"aggregateRaw\":\n inputType = `${modelName}AggregateRawObjectSchema`;\n break;\n case \"groupBy\":\n inputType = `${modelName}GroupBySchema`;\n break;\n default:\n // eslint-disable-next-line no-console\n console.log(\"getInputTypeByOpName: \", { opName, modelName });\n }\n return inputType;\n};\n\nexport const getProcedureTypeByOpName = (opName: string) => {\n let procType;\n switch (opName) {\n case \"findUnique\":\n case \"findFirst\":\n case \"findMany\":\n case \"findRaw\":\n case \"aggregate\":\n case \"aggregateRaw\":\n case \"groupBy\":\n procType = \"query\";\n break;\n case \"createOne\":\n case \"createMany\":\n case \"createManyAndReturn\":\n case \"deleteOne\":\n case \"updateOne\":\n case \"deleteMany\":\n case \"updateMany\":\n case \"updateManyAndReturn\":\n case \"upsertOne\":\n procType = \"mutation\";\n break;\n default:\n // eslint-disable-next-line no-console\n console.log(\"getProcedureTypeByOpName: \", { opName });\n }\n return procType;\n};\n\nexport function resolveModelsComments(\n models: DMMF.Model[],\n hiddenModels: string[]\n) {\n // eslint-disable-next-line regexp/no-obscure-range\n const modelAttributeRegex = /(?:@@Gen\\.)+[A-z]+\\(.+\\)/;\n const attributeNameRegex = /\\.+[A-Z]+\\(+/i;\n const attributeArgsRegex = /\\(+[A-Z]+:.+\\)/i;\n\n for (const model of models) {\n if (model.documentation) {\n const attribute = model.documentation?.match(modelAttributeRegex)?.[0];\n const attributeName = attribute\n ?.match(attributeNameRegex)?.[0]\n ?.slice(1, -1);\n if (attributeName !== \"model\") continue;\n const rawAttributeArgs = attribute\n ?.match(attributeArgsRegex)?.[0]\n ?.slice(1, -1);\n\n const parsedAttributeArgs: Record<string, unknown> = {};\n if (rawAttributeArgs) {\n const rawAttributeArgsParts = rawAttributeArgs\n .split(\":\")\n .map(it => it.trim())\n .map(part => (part.startsWith(\"[\") ? part : part.split(\",\")))\n .flat()\n .map(it => it.trim());\n\n for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {\n const key = rawAttributeArgsParts[i];\n const value = rawAttributeArgsParts[i + 1];\n parsedAttributeArgs[key!] = JSON.parse(value!);\n }\n }\n\n if (parsedAttributeArgs.hide) {\n hiddenModels.push(model.name);\n }\n }\n }\n}\n\nexport const getImports = (\n type: \"trpc\" | \"trpc-shield\" | \"context\",\n newPath?: string\n) => {\n let statement = \"\";\n if (type === \"trpc\") {\n statement = \"import * as trpc from '@trpc/server';\\n\";\n } else if (type === \"trpc-shield\") {\n statement = \"import { shield, allow } from '@stryke/trpc-next/shield';\\n\";\n } else if (type === \"context\") {\n statement = `import type { Context } from '${newPath}';\\n`;\n }\n\n return statement;\n};\n\nexport const wrapWithObject = ({\n shieldItemLines\n}: {\n shieldItemLines: Array<string> | string;\n}) => {\n let wrapped = \"{\";\n wrapped += \"\\n\";\n wrapped += Array.isArray(shieldItemLines)\n ? ` ${shieldItemLines.join(\",\\r\\n\")}`\n : ` ${shieldItemLines}`;\n wrapped += \"\\n\";\n wrapped += \"}\";\n return wrapped;\n};\n\nexport const wrapWithTrpcShieldCall = ({\n shieldObjectTextWrapped\n}: {\n shieldObjectTextWrapped: string;\n}) => {\n let wrapped = \"shield<Context>(\";\n wrapped += \"\\n\";\n wrapped += ` ${shieldObjectTextWrapped}`;\n wrapped += \"\\n\";\n wrapped += \")\";\n return wrapped;\n};\n\nexport const wrapWithExport = ({\n shieldObjectText\n}: {\n shieldObjectText: string;\n}) => {\n return `export const permissions: ReturnType<typeof shield<Context>> = ${shieldObjectText};`;\n};\n\nexport const constructShield = async (\n {\n queries,\n mutations,\n subscriptions\n }: {\n queries: Array<string>;\n mutations: Array<string>;\n subscriptions: Array<string>;\n },\n config: Config,\n options: GeneratorOptions,\n outputDir: string\n) => {\n if (\n queries.length === 0 &&\n mutations.length === 0 &&\n subscriptions.length === 0\n ) {\n return \"\";\n }\n\n let rootItems = \"\";\n if (queries.length > 0) {\n const queryLinesWrapped = `query: ${wrapWithObject({\n shieldItemLines: queries.map(query => `${query}: allow`)\n })},`;\n rootItems += queryLinesWrapped;\n }\n if (mutations.length > 0) {\n const mutationLinesWrapped = `mutation: ${wrapWithObject({\n shieldItemLines: mutations.map(mutation => `${mutation}: allow`)\n })},`;\n rootItems += mutationLinesWrapped;\n }\n\n if (subscriptions.length > 0) {\n const subscriptionLinesWrapped = `subscription: ${wrapWithObject({\n shieldItemLines: subscriptions.map(\n subscription => `${subscription}: allow`\n )\n })},`;\n rootItems += subscriptionLinesWrapped;\n }\n\n if (rootItems.length === 0) {\n return \"\";\n }\n\n let shieldText = getImports(\"trpc-shield\");\n shieldText += getImports(\n \"context\",\n relativePath(outputDir, joinPaths(outputDir, config.contextPath))\n );\n shieldText += \"\\n\\n\";\n shieldText += wrapWithExport({\n shieldObjectText: wrapWithTrpcShieldCall({\n shieldObjectTextWrapped: wrapWithObject({ shieldItemLines: rootItems })\n })\n });\n\n return shieldText;\n};\n\nexport const constructDefaultOptions = (\n config: Config,\n options: GeneratorOptions,\n outputDir: string\n) => {\n return `import { ZodError } from 'zod';${config.withNext ? '\\nimport { transformer } from \"@stryke/trpc-next/shared\";' : \"\"}\nimport type {\n DataTransformerOptions,\n RootConfig\n} from \"@trpc/server/unstable-core-do-not-import\";\nimport type { Context } from \"${relativePath(outputDir, joinPaths(outputDir, config.contextPath))}\";\n\ninterface RuntimeConfigOptions<\n TContext extends object,\n TMeta extends object = object\n> extends Partial<\n Omit<\n RootConfig<{\n ctx: TContext;\n meta: TMeta;\n errorShape: any;\n transformer: any;\n }>,\n \"$types\" | \"transformer\"\n >\n > {\n /**\n * Use a data transformer\n * @see https://trpc.io/docs/v11/data-transformers\n */\n transformer?: DataTransformerOptions;\n}\n\nconst options: RuntimeConfigOptions<Context> = {${config.withNext ? \"\\n transformer,\" : \"\"}\n errorFormatter({ shape, error }) {\n return {\n ...shape,\n data: {\n ...shape.data,\n zodError:\n error.code === \"BAD_REQUEST\" && error.cause instanceof ZodError\n ? error.cause.flatten()\n : null\n }\n };\n }\n};\n\nexport default options;\n`;\n};\n\nexport const constructZodModels = async (\n models: Writeable<DMMF.Model[]>,\n outputPath: string,\n config: Config,\n options: GeneratorOptions\n) => {\n const indexFile = project.createSourceFile(\n `${outputPath}/index.ts`,\n {},\n { overwrite: true }\n );\n\n generateBarrelFile(models, indexFile);\n\n indexFile.formatText({\n indentSize: 2\n });\n\n await Promise.all(\n models.map(async model => {\n const sourceFile = project.createSourceFile(\n `${outputPath}/${lowerCaseFirst(model.name)}.schema.ts`,\n {},\n { overwrite: true }\n );\n\n await populateModelFile(model, sourceFile, config, options);\n\n sourceFile.formatText({\n indentSize: 2\n });\n })\n );\n};\n"],"mappings":";;;;;;;;AAmCA,MAAM,oBAAoB,WAAmB;AAC3C,QAAO,OAAO,aACV,sBACA,OAAO,iBACL,uBACA;;AAGR,MAAa,8BAA8B,EACzC,YACA,aAII;CACJ,MAAM,UAAU,CAAC,IAAI;AAErB,KAAI,OACF,SAAQ,KAAK,iBAAiB,OAAO,CAAC;AAGxC,YAAW,qBAAqB;EAC9B,iBAAiB;EACjB,cAAc;EACf,CAAC;;AA4BJ,MAAa,wBACX,YACA,iBACA,uBACG;AACH,YAAW,qBAAqB;EAC9B,iBAAiB,KAAK,eAAe,mBAAmB,CAAC;EACzD,cAAc,CAAC,GAAG,gBAAgB,QAAQ;EAC3C,CAAC;;AAGJ,eAAsB,oBACpB,YACA,QACA,SACA,WACA;AACA,KAAI,OAAO,WACT,YAAW,qBAAqB;EAC9B,iBAAiB,aACf,WACA,UACE,WACA,OAAO,OAAO,eAAe,WAAW,OAAO,aAAa,SAC7D,CACF;EACD,cAAc,CAAC,cAAc;EAC9B,CAAC;AAGJ,YAAW,cACA,iCAAiC,aACxC,WACA,UAAU,WAAW,OAAO,YAAY,CACzC,CAAC,IACH;AAED,KAAI,OAAO,YACT,YAAW,cACA,4BACP,OAAO,OAAO,gBAAgB,WAC1B,aAAa,WAAW,UAAU,WAAW,OAAO,YAAY,CAAC,GACjE,YACL,IACF;AAGH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AI,aAAa,WAAW,cAAc;AAC1C,eAAc,WACZ,WACA,aAAa,WAAW,UAAU,WAAW,OAAO,YAAY,CAAC,CAClE;AACD,eAAc;AACd,eAAc,eAAe,EAC3B,kBAAkB,uBAAuB,EACvC,yBAAyB,eAAe,EAAE,iBAAiB,WAAW,CAAC,EACxE,CAAC,EACH,CAAC;AAEF,QAAO;;AAGT,MAAa,2BACX,QACA,SACA,cACG;AACH,QAAO,kCAAkC,OAAO,WAAW,gEAA8D,GAAG;;;;;gCAK9F,aAAa,WAAW,UAAU,WAAW,OAAO,YAAY,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;kDAuBhD,OAAO,WAAW,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;AAmB3F,MAAa,qBAAqB,OAChC,QACA,YACA,QACA,YACG;CACH,MAAM,YAAY,QAAQ,iBACxB,GAAG,WAAW,YACd,EAAE,EACF,EAAE,WAAW,MAAM,CACpB;AAED,oBAAmB,QAAQ,UAAU;AAErC,WAAU,WAAW,EACnB,YAAY,GACb,CAAC;AAEF,OAAM,QAAQ,IACZ,OAAO,IAAI,OAAM,UAAS;EACxB,MAAM,aAAa,QAAQ,iBACzB,GAAG,WAAW,GAAG,eAAe,MAAM,KAAK,CAAC,aAC5C,EAAE,EACF,EAAE,WAAW,MAAM,CACpB;AAED,QAAM,kBAAkB,OAAO,YAAY,QAAQ,QAAQ;AAE3D,aAAW,WAAW,EACpB,YAAY,GACb,CAAC;GACF,CACH"}
@@ -1,44 +1,44 @@
1
- const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
1
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
2
2
  const require_title_case = require('../../string-format/src/title-case.cjs');
3
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
3
+ let _stryke_path_join_paths = require("@stryke/path/join-paths");
4
4
  let node_path = require("node:path");
5
- node_path = require_rolldown_runtime.__toESM(node_path);
5
+ node_path = require_runtime.__toESM(node_path, 1);
6
6
  let node_os = require("node:os");
7
- node_os = require_rolldown_runtime.__toESM(node_os);
7
+ node_os = require_runtime.__toESM(node_os, 1);
8
8
 
9
9
  //#region ../env/src/get-env-paths.ts
10
10
  const homedir = node_os.default.homedir();
11
11
  const tmpdir = node_os.default.tmpdir();
12
12
  const macos = (orgId) => {
13
- const library = (0, __stryke_path_join_paths.joinPaths)(homedir, "Library");
13
+ const library = (0, _stryke_path_join_paths.joinPaths)(homedir, "Library");
14
14
  return {
15
- data: (0, __stryke_path_join_paths.joinPaths)(library, "Application Support", orgId),
16
- config: (0, __stryke_path_join_paths.joinPaths)(library, "Preferences", orgId),
17
- cache: (0, __stryke_path_join_paths.joinPaths)(library, "Caches", orgId),
18
- log: (0, __stryke_path_join_paths.joinPaths)(library, "Logs", orgId),
19
- temp: (0, __stryke_path_join_paths.joinPaths)(tmpdir, orgId)
15
+ data: (0, _stryke_path_join_paths.joinPaths)(library, "Application Support", orgId),
16
+ config: (0, _stryke_path_join_paths.joinPaths)(library, "Preferences", orgId),
17
+ cache: (0, _stryke_path_join_paths.joinPaths)(library, "Caches", orgId),
18
+ log: (0, _stryke_path_join_paths.joinPaths)(library, "Logs", orgId),
19
+ temp: (0, _stryke_path_join_paths.joinPaths)(tmpdir, orgId)
20
20
  };
21
21
  };
22
22
  const windows = (orgId) => {
23
- const appData = process.env.APPDATA || (0, __stryke_path_join_paths.joinPaths)(homedir, "AppData", "Roaming");
24
- const localAppData = process.env.LOCALAPPDATA || (0, __stryke_path_join_paths.joinPaths)(homedir, "AppData", "Local");
23
+ const appData = process.env.APPDATA || (0, _stryke_path_join_paths.joinPaths)(homedir, "AppData", "Roaming");
24
+ const localAppData = process.env.LOCALAPPDATA || (0, _stryke_path_join_paths.joinPaths)(homedir, "AppData", "Local");
25
25
  const windowsFormattedOrgId = require_title_case.titleCase(orgId).trim().replace(/\s+/g, "");
26
26
  return {
27
- data: (0, __stryke_path_join_paths.joinPaths)(localAppData, windowsFormattedOrgId, "Data"),
28
- config: (0, __stryke_path_join_paths.joinPaths)(appData, windowsFormattedOrgId, "Config"),
29
- cache: (0, __stryke_path_join_paths.joinPaths)(localAppData, "Cache", orgId),
30
- log: (0, __stryke_path_join_paths.joinPaths)(localAppData, windowsFormattedOrgId, "Log"),
31
- temp: (0, __stryke_path_join_paths.joinPaths)(tmpdir, orgId)
27
+ data: (0, _stryke_path_join_paths.joinPaths)(localAppData, windowsFormattedOrgId, "Data"),
28
+ config: (0, _stryke_path_join_paths.joinPaths)(appData, windowsFormattedOrgId, "Config"),
29
+ cache: (0, _stryke_path_join_paths.joinPaths)(localAppData, "Cache", orgId),
30
+ log: (0, _stryke_path_join_paths.joinPaths)(localAppData, windowsFormattedOrgId, "Log"),
31
+ temp: (0, _stryke_path_join_paths.joinPaths)(tmpdir, orgId)
32
32
  };
33
33
  };
34
34
  const linux = (orgId) => {
35
35
  const username = node_path.default.basename(homedir);
36
36
  return {
37
- data: (0, __stryke_path_join_paths.joinPaths)(process.env.XDG_DATA_HOME || (0, __stryke_path_join_paths.joinPaths)(homedir, ".local", "share"), orgId),
38
- config: (0, __stryke_path_join_paths.joinPaths)(process.env.XDG_CONFIG_HOME || (0, __stryke_path_join_paths.joinPaths)(homedir, ".config"), orgId),
39
- cache: (0, __stryke_path_join_paths.joinPaths)(process.env.XDG_CACHE_HOME || (0, __stryke_path_join_paths.joinPaths)(homedir, ".cache"), orgId),
40
- log: (0, __stryke_path_join_paths.joinPaths)(process.env.XDG_STATE_HOME || (0, __stryke_path_join_paths.joinPaths)(homedir, ".local", "state"), orgId),
41
- temp: process.env.DEVENV_RUNTIME || process.env.XDG_RUNTIME_DIR ? (0, __stryke_path_join_paths.joinPaths)(process.env.DEVENV_RUNTIME || process.env.XDG_RUNTIME_DIR, orgId) : (0, __stryke_path_join_paths.joinPaths)(tmpdir, username, orgId)
37
+ data: (0, _stryke_path_join_paths.joinPaths)(process.env.XDG_DATA_HOME || (0, _stryke_path_join_paths.joinPaths)(homedir, ".local", "share"), orgId),
38
+ config: (0, _stryke_path_join_paths.joinPaths)(process.env.XDG_CONFIG_HOME || (0, _stryke_path_join_paths.joinPaths)(homedir, ".config"), orgId),
39
+ cache: (0, _stryke_path_join_paths.joinPaths)(process.env.XDG_CACHE_HOME || (0, _stryke_path_join_paths.joinPaths)(homedir, ".cache"), orgId),
40
+ log: (0, _stryke_path_join_paths.joinPaths)(process.env.XDG_STATE_HOME || (0, _stryke_path_join_paths.joinPaths)(homedir, ".local", "state"), orgId),
41
+ temp: process.env.DEVENV_RUNTIME || process.env.XDG_RUNTIME_DIR ? (0, _stryke_path_join_paths.joinPaths)(process.env.DEVENV_RUNTIME || process.env.XDG_RUNTIME_DIR, orgId) : (0, _stryke_path_join_paths.joinPaths)(tmpdir, username, orgId)
42
42
  };
43
43
  };
44
44
  /**
@@ -68,16 +68,16 @@ function getEnvPaths(options = {}) {
68
68
  else if (process.env.STORM_LOG_DIR) result.log = process.env.STORM_LOG_DIR;
69
69
  else if (process.env.STORM_TEMP_DIR) result.temp = process.env.STORM_TEMP_DIR;
70
70
  if (options.workspaceRoot) {
71
- result.cache ??= (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "node_modules", ".cache", orgId);
72
- result.temp ??= (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, "tmp", orgId);
73
- result.log ??= (0, __stryke_path_join_paths.joinPaths)(result.temp, "logs");
74
- result.config ??= (0, __stryke_path_join_paths.joinPaths)(options.workspaceRoot, ".config", orgId);
71
+ result.cache ??= (0, _stryke_path_join_paths.joinPaths)(options.workspaceRoot, "node_modules", ".cache", orgId);
72
+ result.temp ??= (0, _stryke_path_join_paths.joinPaths)(options.workspaceRoot, "tmp", orgId);
73
+ result.log ??= (0, _stryke_path_join_paths.joinPaths)(result.temp, "logs");
74
+ result.config ??= (0, _stryke_path_join_paths.joinPaths)(options.workspaceRoot, ".config", orgId);
75
75
  }
76
76
  return Object.keys(result).reduce((ret, key) => {
77
77
  if (result[key]) {
78
78
  const filePath = result[key];
79
- ret[key] = options.appId && options.appId !== options.orgId && options.appId !== options.nestedDir ? (0, __stryke_path_join_paths.joinPaths)(filePath, options.appId) : filePath;
80
- if (options.nestedDir && options.nestedDir !== options.orgId && options.nestedDir !== options.appId) ret[key] = (0, __stryke_path_join_paths.joinPaths)(ret[key], options.nestedDir);
79
+ ret[key] = options.appId && options.appId !== options.orgId && options.appId !== options.nestedDir ? (0, _stryke_path_join_paths.joinPaths)(filePath, options.appId) : filePath;
80
+ if (options.nestedDir && options.nestedDir !== options.orgId && options.nestedDir !== options.appId) ret[key] = (0, _stryke_path_join_paths.joinPaths)(ret[key], options.nestedDir);
81
81
  }
82
82
  return ret;
83
83
  }, {});
@@ -409,7 +409,6 @@ const ACRONYMS = {
409
409
  };
410
410
  const ACRONYM_DISPLAY = Object.fromEntries(Object.entries(ACRONYMS).map(([key, value]) => [key, value.display ?? key]));
411
411
  const ACRONYM_DESCRIPTION = Object.fromEntries(Object.entries(ACRONYMS).map(([key, value]) => [key, value.description]));
412
- const ACRONYM_LIST = Object.keys(ACRONYMS);
413
412
 
414
413
  //#endregion
415
414
  exports.ACRONYMS = ACRONYMS;
@@ -408,7 +408,6 @@ const ACRONYMS = {
408
408
  };
409
409
  const ACRONYM_DISPLAY = Object.fromEntries(Object.entries(ACRONYMS).map(([key, value]) => [key, value.display ?? key]));
410
410
  const ACRONYM_DESCRIPTION = Object.fromEntries(Object.entries(ACRONYMS).map(([key, value]) => [key, value.description]));
411
- const ACRONYM_LIST = Object.keys(ACRONYMS);
412
411
 
413
412
  //#endregion
414
413
  export { ACRONYMS };