@stryke/prisma-trpc-generator 0.13.49 → 0.13.50
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.
- package/dist/_virtual/rolldown_runtime.cjs +31 -1
- package/dist/_virtual/rolldown_runtime.mjs +32 -1
- package/dist/config.cjs +50 -1
- package/dist/config.mjs +49 -1
- package/dist/config.mjs.map +1 -1
- package/dist/generator.cjs +1 -1
- package/dist/generator.mjs +3 -1
- package/dist/helpers.cjs +281 -32
- package/dist/helpers.mjs +271 -32
- package/dist/helpers.mjs.map +1 -1
- package/dist/index.cjs +26 -1
- package/dist/index.mjs +27 -1
- package/dist/index.mjs.map +1 -1
- package/dist/packages/env/src/get-env-paths.cjs +87 -1
- package/dist/packages/env/src/get-env-paths.mjs +84 -1
- package/dist/packages/env/src/get-env-paths.mjs.map +1 -1
- package/dist/packages/string-format/src/acronyms.cjs +408 -1
- package/dist/packages/string-format/src/acronyms.mjs +407 -1
- package/dist/packages/string-format/src/acronyms.mjs.map +1 -1
- package/dist/packages/string-format/src/articles.cjs +10 -1
- package/dist/packages/string-format/src/articles.mjs +9 -1
- package/dist/packages/string-format/src/articles.mjs.map +1 -1
- package/dist/packages/string-format/src/combine.cjs +15 -1
- package/dist/packages/string-format/src/combine.mjs +14 -1
- package/dist/packages/string-format/src/combine.mjs.map +1 -1
- package/dist/packages/string-format/src/conjunctions.cjs +32 -1
- package/dist/packages/string-format/src/conjunctions.mjs +31 -1
- package/dist/packages/string-format/src/conjunctions.mjs.map +1 -1
- package/dist/packages/string-format/src/decamelize.cjs +14 -1
- package/dist/packages/string-format/src/decamelize.mjs +13 -1
- package/dist/packages/string-format/src/decamelize.mjs.map +1 -1
- package/dist/packages/string-format/src/format-special-cases.cjs +33 -1
- package/dist/packages/string-format/src/format-special-cases.mjs +33 -1
- package/dist/packages/string-format/src/format-special-cases.mjs.map +1 -1
- package/dist/packages/string-format/src/lower-case-first.cjs +17 -1
- package/dist/packages/string-format/src/lower-case-first.mjs +16 -1
- package/dist/packages/string-format/src/lower-case-first.mjs.map +1 -1
- package/dist/packages/string-format/src/prepositions.cjs +68 -1
- package/dist/packages/string-format/src/prepositions.mjs +67 -1
- package/dist/packages/string-format/src/prepositions.mjs.map +1 -1
- package/dist/packages/string-format/src/special-cases.cjs +53 -1
- package/dist/packages/string-format/src/special-cases.mjs +52 -1
- package/dist/packages/string-format/src/special-cases.mjs.map +1 -1
- package/dist/packages/string-format/src/title-case.cjs +19 -1
- package/dist/packages/string-format/src/title-case.mjs +19 -1
- package/dist/packages/string-format/src/title-case.mjs.map +1 -1
- package/dist/packages/string-format/src/upper-case-first.cjs +17 -1
- package/dist/packages/string-format/src/upper-case-first.mjs +16 -1
- package/dist/packages/string-format/src/upper-case-first.mjs.map +1 -1
- package/dist/prisma-generator.cjs +185 -8
- package/dist/prisma-generator.mjs +184 -8
- package/dist/prisma-generator.mjs.map +1 -1
- package/dist/project.cjs +15 -1
- package/dist/project.mjs +14 -1
- package/dist/project.mjs.map +1 -1
- package/dist/utils/format-file.cjs +25 -1
- package/dist/utils/format-file.mjs +23 -1
- package/dist/utils/format-file.mjs.map +1 -1
- package/dist/utils/get-jiti.cjs +21 -1
- package/dist/utils/get-jiti.mjs +20 -1
- package/dist/utils/get-jiti.mjs.map +1 -1
- package/dist/utils/get-prisma-internals.cjs +13 -1
- package/dist/utils/get-prisma-internals.mjs +12 -1
- package/dist/utils/get-prisma-internals.mjs.map +1 -1
- package/dist/utils/write-file-safely.cjs +32 -2
- package/dist/utils/write-file-safely.mjs +29 -2
- package/dist/utils/write-file-safely.mjs.map +1 -1
- package/dist/zod/aggregate-helpers.cjs +70 -1
- package/dist/zod/aggregate-helpers.mjs +67 -1
- package/dist/zod/aggregate-helpers.mjs.map +1 -1
- package/dist/zod/comments-helpers.cjs +77 -1
- package/dist/zod/comments-helpers.mjs +75 -1
- package/dist/zod/comments-helpers.mjs.map +1 -1
- package/dist/zod/docs-helpers.cjs +23 -3
- package/dist/zod/docs-helpers.mjs +20 -3
- package/dist/zod/docs-helpers.mjs.map +1 -1
- package/dist/zod/generator-helpers.cjs +34 -1
- package/dist/zod/generator-helpers.mjs +31 -1
- package/dist/zod/generator-helpers.mjs.map +1 -1
- package/dist/zod/helpers.cjs +26 -1
- package/dist/zod/helpers.mjs +26 -1
- package/dist/zod/helpers.mjs.map +1 -1
- package/dist/zod/include-helpers.cjs +69 -1
- package/dist/zod/include-helpers.mjs +69 -1
- package/dist/zod/include-helpers.mjs.map +1 -1
- package/dist/zod/model-helpers.cjs +244 -1
- package/dist/zod/model-helpers.mjs +236 -1
- package/dist/zod/model-helpers.mjs.map +1 -1
- package/dist/zod/modelArgs-helpers.cjs +56 -1
- package/dist/zod/modelArgs-helpers.mjs +56 -1
- package/dist/zod/modelArgs-helpers.mjs.map +1 -1
- package/dist/zod/mongodb-helpers.cjs +49 -1
- package/dist/zod/mongodb-helpers.mjs +48 -1
- package/dist/zod/mongodb-helpers.mjs.map +1 -1
- package/dist/zod/select-helpers.cjs +128 -1
- package/dist/zod/select-helpers.mjs +128 -1
- package/dist/zod/select-helpers.mjs.map +1 -1
- package/dist/zod/transformer.cjs +434 -19
- package/dist/zod/transformer.mjs +432 -19
- package/dist/zod/transformer.mjs.map +1 -1
- package/dist/zod/whereUniqueInput-helpers.cjs +17 -1
- package/dist/zod/whereUniqueInput-helpers.mjs +16 -1
- package/dist/zod/whereUniqueInput-helpers.mjs.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
|
|
30
|
+
exports.__commonJSMin = __commonJSMin;
|
|
31
|
+
exports.__toESM = __toESM;
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
import{createRequire
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
__defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
29
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { __commonJSMin, __require, __toESM };
|
package/dist/config.cjs
CHANGED
|
@@ -1 +1,50 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
|
|
4
|
+
//#region src/config.ts
|
|
5
|
+
let ModelAction = /* @__PURE__ */ function(ModelAction$1) {
|
|
6
|
+
ModelAction$1["findUnique"] = "findUnique";
|
|
7
|
+
ModelAction$1["findUniqueOrThrow"] = "findUniqueOrThrow";
|
|
8
|
+
ModelAction$1["findFirst"] = "findFirst";
|
|
9
|
+
ModelAction$1["findFirstOrThrow"] = "findFirstOrThrow";
|
|
10
|
+
ModelAction$1["findMany"] = "findMany";
|
|
11
|
+
ModelAction$1["create"] = "create";
|
|
12
|
+
ModelAction$1["createMany"] = "createMany";
|
|
13
|
+
ModelAction$1["createManyAndReturn"] = "createManyAndReturn";
|
|
14
|
+
ModelAction$1["update"] = "update";
|
|
15
|
+
ModelAction$1["updateMany"] = "updateMany";
|
|
16
|
+
ModelAction$1["updateManyAndReturn"] = "updateManyAndReturn";
|
|
17
|
+
ModelAction$1["upsert"] = "upsert";
|
|
18
|
+
ModelAction$1["delete"] = "delete";
|
|
19
|
+
ModelAction$1["deleteMany"] = "deleteMany";
|
|
20
|
+
ModelAction$1["groupBy"] = "groupBy";
|
|
21
|
+
ModelAction$1["count"] = "count";
|
|
22
|
+
ModelAction$1["aggregate"] = "aggregate";
|
|
23
|
+
ModelAction$1["findRaw"] = "findRaw";
|
|
24
|
+
ModelAction$1["aggregateRaw"] = "aggregateRaw";
|
|
25
|
+
return ModelAction$1;
|
|
26
|
+
}({});
|
|
27
|
+
const modelActionEnum = zod.z.nativeEnum(ModelAction);
|
|
28
|
+
const configBoolean = zod.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);
|
|
29
|
+
const configSchema = zod.z.object({
|
|
30
|
+
debug: configBoolean.default("false"),
|
|
31
|
+
withNext: configBoolean.default("true"),
|
|
32
|
+
withMiddleware: configBoolean.default("false"),
|
|
33
|
+
withShield: configBoolean.default("false"),
|
|
34
|
+
contextPath: zod.z.string().trim().default("../context"),
|
|
35
|
+
trpcOptions: configBoolean.default("true"),
|
|
36
|
+
showModelNameInProcedure: configBoolean.default("false"),
|
|
37
|
+
generateModelActions: zod.z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
|
|
38
|
+
return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
|
|
39
|
+
}),
|
|
40
|
+
withZod: configBoolean.default("true"),
|
|
41
|
+
relationModel: configBoolean.default("true").or(zod.z.literal("default")),
|
|
42
|
+
modelSuffix: zod.z.string().default("Schema"),
|
|
43
|
+
modelCase: zod.z.enum(["PascalCase", "camelCase"]).default("camelCase"),
|
|
44
|
+
useDecimalJs: configBoolean.default("true"),
|
|
45
|
+
imports: zod.z.string().optional(),
|
|
46
|
+
prismaJsonNullability: configBoolean.default("true")
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.configSchema = configSchema;
|
package/dist/config.mjs
CHANGED
|
@@ -1,2 +1,50 @@
|
|
|
1
|
-
import{z
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/config.ts
|
|
4
|
+
let ModelAction = /* @__PURE__ */ function(ModelAction$1) {
|
|
5
|
+
ModelAction$1["findUnique"] = "findUnique";
|
|
6
|
+
ModelAction$1["findUniqueOrThrow"] = "findUniqueOrThrow";
|
|
7
|
+
ModelAction$1["findFirst"] = "findFirst";
|
|
8
|
+
ModelAction$1["findFirstOrThrow"] = "findFirstOrThrow";
|
|
9
|
+
ModelAction$1["findMany"] = "findMany";
|
|
10
|
+
ModelAction$1["create"] = "create";
|
|
11
|
+
ModelAction$1["createMany"] = "createMany";
|
|
12
|
+
ModelAction$1["createManyAndReturn"] = "createManyAndReturn";
|
|
13
|
+
ModelAction$1["update"] = "update";
|
|
14
|
+
ModelAction$1["updateMany"] = "updateMany";
|
|
15
|
+
ModelAction$1["updateManyAndReturn"] = "updateManyAndReturn";
|
|
16
|
+
ModelAction$1["upsert"] = "upsert";
|
|
17
|
+
ModelAction$1["delete"] = "delete";
|
|
18
|
+
ModelAction$1["deleteMany"] = "deleteMany";
|
|
19
|
+
ModelAction$1["groupBy"] = "groupBy";
|
|
20
|
+
ModelAction$1["count"] = "count";
|
|
21
|
+
ModelAction$1["aggregate"] = "aggregate";
|
|
22
|
+
ModelAction$1["findRaw"] = "findRaw";
|
|
23
|
+
ModelAction$1["aggregateRaw"] = "aggregateRaw";
|
|
24
|
+
return ModelAction$1;
|
|
25
|
+
}({});
|
|
26
|
+
const modelActionEnum = z.nativeEnum(ModelAction);
|
|
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);
|
|
28
|
+
const configSchema = z.object({
|
|
29
|
+
debug: configBoolean.default("false"),
|
|
30
|
+
withNext: configBoolean.default("true"),
|
|
31
|
+
withMiddleware: configBoolean.default("false"),
|
|
32
|
+
withShield: configBoolean.default("false"),
|
|
33
|
+
contextPath: z.string().trim().default("../context"),
|
|
34
|
+
trpcOptions: configBoolean.default("true"),
|
|
35
|
+
showModelNameInProcedure: configBoolean.default("false"),
|
|
36
|
+
generateModelActions: z.string().default(Object.values(ModelAction).join(",")).transform((arg) => {
|
|
37
|
+
return arg.split(",").map((action) => modelActionEnum.parse(action.trim()));
|
|
38
|
+
}),
|
|
39
|
+
withZod: configBoolean.default("true"),
|
|
40
|
+
relationModel: configBoolean.default("true").or(z.literal("default")),
|
|
41
|
+
modelSuffix: z.string().default("Schema"),
|
|
42
|
+
modelCase: z.enum(["PascalCase", "camelCase"]).default("camelCase"),
|
|
43
|
+
useDecimalJs: configBoolean.default("true"),
|
|
44
|
+
imports: z.string().optional(),
|
|
45
|
+
prismaJsonNullability: configBoolean.default("true")
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
export { configSchema };
|
|
2
50
|
//# sourceMappingURL=config.mjs.map
|
package/dist/config.mjs.map
CHANGED
|
@@ -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 { z } from \"zod\";\n\nexport enum ModelAction {\n findUnique = \"findUnique\",\n findUniqueOrThrow = \"findUniqueOrThrow\",\n findFirst = \"findFirst\",\n findFirstOrThrow = \"findFirstOrThrow\",\n findMany = \"findMany\",\n create = \"create\",\n createMany = \"createMany\",\n createManyAndReturn = \"createManyAndReturn\",\n update = \"update\",\n updateMany = \"updateMany\",\n updateManyAndReturn = \"updateManyAndReturn\",\n upsert = \"upsert\",\n delete = \"delete\",\n deleteMany = \"deleteMany\",\n groupBy = \"groupBy\",\n count = \"count\", // TODO: count does not actually exist, why?\n aggregate = \"aggregate\",\n findRaw = \"findRaw\",\n aggregateRaw = \"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":"
|
|
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 { z } from \"zod\";\n\nexport enum ModelAction {\n findUnique = \"findUnique\",\n findUniqueOrThrow = \"findUniqueOrThrow\",\n findFirst = \"findFirst\",\n findFirstOrThrow = \"findFirstOrThrow\",\n findMany = \"findMany\",\n create = \"create\",\n createMany = \"createMany\",\n createManyAndReturn = \"createManyAndReturn\",\n update = \"update\",\n updateMany = \"updateMany\",\n updateManyAndReturn = \"updateManyAndReturn\",\n upsert = \"upsert\",\n delete = \"delete\",\n deleteMany = \"deleteMany\",\n groupBy = \"groupBy\",\n count = \"count\", // TODO: count does not actually exist, why?\n aggregate = \"aggregate\",\n findRaw = \"findRaw\",\n aggregateRaw = \"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"}
|
package/dist/generator.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
require(
|
|
2
|
+
require('./index.cjs');
|
package/dist/generator.mjs
CHANGED
package/dist/helpers.cjs
CHANGED
|
@@ -1,48 +1,275 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_lower_case_first = require('./packages/string-format/src/lower-case-first.cjs');
|
|
3
|
+
const require_project = require('./project.cjs');
|
|
4
|
+
require('./utils/get-prisma-internals.cjs');
|
|
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");
|
|
8
|
+
|
|
9
|
+
//#region src/helpers.ts
|
|
10
|
+
const getProcedureName = (config) => {
|
|
11
|
+
return config.withShield ? "shieldedProcedure" : config.withMiddleware ? "protectedProcedure" : "publicProcedure";
|
|
12
|
+
};
|
|
13
|
+
const generateCreateRouterImport = ({ sourceFile, config }) => {
|
|
14
|
+
const imports = ["t"];
|
|
15
|
+
if (config) imports.push(getProcedureName(config));
|
|
16
|
+
sourceFile.addImportDeclaration({
|
|
17
|
+
moduleSpecifier: "../trpc",
|
|
18
|
+
namedImports: imports
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const generateRouterImport = (sourceFile, modelNamePlural, modelNameCamelCase) => {
|
|
22
|
+
sourceFile.addImportDeclaration({
|
|
23
|
+
moduleSpecifier: `./${require_lower_case_first.lowerCaseFirst(modelNameCamelCase)}.router`,
|
|
24
|
+
namedImports: [`${modelNamePlural}Router`]
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
async function generateTRPCExports(sourceFile, config, options, outputDir) {
|
|
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")),
|
|
30
|
+
namedImports: ["permissions"]
|
|
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))}';
|
|
2
35
|
import { initTRPC } from '@trpc/server';
|
|
3
36
|
import { createTRPCServerActionHandler } from '@stryke/trpc-next/action-handler';
|
|
4
|
-
import { cookies } from "next/headers";`)
|
|
5
|
-
|
|
37
|
+
import { cookies } from "next/headers";`);
|
|
38
|
+
sourceFile.addStatements(`
|
|
39
|
+
export const t = initTRPC.context<Context>().create(${config.trpcOptions ? "trpcOptions" : ""});`);
|
|
40
|
+
const middlewares = [];
|
|
41
|
+
if (config.withMiddleware && typeof config.withMiddleware === "boolean") {
|
|
42
|
+
sourceFile.addStatements(`
|
|
6
43
|
export const globalMiddleware = t.middleware(async ({ ctx, next }) => {
|
|
7
44
|
console.log('inside middleware!')
|
|
8
45
|
return next()
|
|
9
|
-
});`)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
46
|
+
});`);
|
|
47
|
+
middlewares.push({
|
|
48
|
+
type: "global",
|
|
49
|
+
value: `.use(globalMiddleware)`
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (config.withMiddleware && typeof config.withMiddleware === "string") {
|
|
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"))}';
|
|
55
|
+
`);
|
|
56
|
+
sourceFile.addStatements(`
|
|
57
|
+
export const globalMiddleware = t.middleware(middleware);`);
|
|
58
|
+
middlewares.push({
|
|
59
|
+
type: "global",
|
|
60
|
+
value: `.use(globalMiddleware)`
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (config.withShield) {
|
|
64
|
+
sourceFile.addStatements(`
|
|
13
65
|
export const permissionsMiddleware = t.middleware(permissions);
|
|
14
|
-
`)
|
|
15
|
-
|
|
66
|
+
`);
|
|
67
|
+
middlewares.push({
|
|
68
|
+
type: "shield",
|
|
69
|
+
value: `
|
|
70
|
+
.use(permissions)`
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
sourceFile.addStatements(`
|
|
16
74
|
/**
|
|
17
75
|
* Create a server-side caller
|
|
18
76
|
* @see https://trpc.io/docs/server/server-side-calls
|
|
19
77
|
*/
|
|
20
|
-
export const createCallerFactory = t.createCallerFactory;`)
|
|
21
|
-
|
|
22
|
-
export const
|
|
78
|
+
export const createCallerFactory = t.createCallerFactory;`);
|
|
79
|
+
sourceFile.addStatements(`
|
|
80
|
+
export const publicProcedure = t.procedure; `);
|
|
81
|
+
if (middlewares.length > 0) {
|
|
82
|
+
const procName = getProcedureName(config);
|
|
83
|
+
middlewares.forEach((middleware, i) => {
|
|
84
|
+
if (i === 0) sourceFile.addStatements(`
|
|
85
|
+
export const ${procName} = t.procedure`);
|
|
86
|
+
sourceFile.addStatements(`.use(${middleware.type === "shield" ? "permissionsMiddleware" : "globalMiddleware"})`);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (config.withNext) sourceFile.addStatements(`
|
|
23
90
|
export const createAction: ReturnType<typeof createTRPCServerActionHandler> =
|
|
24
91
|
createTRPCServerActionHandler(cookies, t, createContext);
|
|
25
|
-
`)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
92
|
+
`);
|
|
93
|
+
sourceFile.formatText({ indentSize: 2 });
|
|
94
|
+
}
|
|
95
|
+
function generateProcedure(sourceFile, name, typeName, modelName, opType, baseOpType, config) {
|
|
96
|
+
let input = `input${!config.withZod ? " as any" : ""}`;
|
|
97
|
+
const nameWithoutModel = name.replace(modelName, "");
|
|
98
|
+
if (nameWithoutModel === "groupBy" && config.withZod) input = "{ where: input.where, orderBy: input.orderBy, by: input.by, having: input.having, take: input.take, skip: input.skip }";
|
|
99
|
+
sourceFile.addStatements(`${config.showModelNameInProcedure ? name : nameWithoutModel}: ${getProcedureName(config)}
|
|
100
|
+
${config.withZod ? `.input(${require_lower_case_first.lowerCaseFirst(typeName)})` : ""}.${getProcedureTypeByOpName(baseOpType)}(async ({ ctx, input }) => {
|
|
101
|
+
const ${name} = await ctx.prisma.${require_lower_case_first.lowerCaseFirst(modelName)}.${opType.replace("One", "")}(${input});
|
|
102
|
+
return ${name};
|
|
103
|
+
}),`);
|
|
104
|
+
}
|
|
105
|
+
function generateRouterSchemaImports(sourceFile, modelName, modelActions) {
|
|
106
|
+
sourceFile.addStatements([...new Set(modelActions.map((opName) => getRouterSchemaImportByOpName(opName, modelName)))].join("\n"));
|
|
107
|
+
}
|
|
108
|
+
const getRouterSchemaImportByOpName = (opName, modelName) => {
|
|
109
|
+
const opType = opName.replace("OrThrow", "").replace("ManyAndReturn", "");
|
|
110
|
+
const inputType = getInputTypeByOpName(opType, modelName);
|
|
111
|
+
return inputType ? `import { ${require_lower_case_first.lowerCaseFirst(inputType)} } from "../schemas/${require_lower_case_first.lowerCaseFirst(opType)}${modelName}.schema"; ` : "";
|
|
112
|
+
};
|
|
113
|
+
const getInputTypeByOpName = (opName, modelName) => {
|
|
114
|
+
let inputType;
|
|
115
|
+
switch (opName) {
|
|
116
|
+
case "findUnique":
|
|
117
|
+
inputType = `${modelName}FindUniqueSchema`;
|
|
118
|
+
break;
|
|
119
|
+
case "findFirst":
|
|
120
|
+
inputType = `${modelName}FindFirstSchema`;
|
|
121
|
+
break;
|
|
122
|
+
case "findMany":
|
|
123
|
+
inputType = `${modelName}FindManySchema`;
|
|
124
|
+
break;
|
|
125
|
+
case "findRaw":
|
|
126
|
+
inputType = `${modelName}FindRawObjectSchema`;
|
|
127
|
+
break;
|
|
128
|
+
case "createOne":
|
|
129
|
+
inputType = `${modelName}CreateOneSchema`;
|
|
130
|
+
break;
|
|
131
|
+
case "createMany":
|
|
132
|
+
inputType = `${modelName}CreateManySchema`;
|
|
133
|
+
break;
|
|
134
|
+
case "createManyAndReturn":
|
|
135
|
+
inputType = `${modelName}CreateManySchema`;
|
|
136
|
+
break;
|
|
137
|
+
case "deleteOne":
|
|
138
|
+
inputType = `${modelName}DeleteOneSchema`;
|
|
139
|
+
break;
|
|
140
|
+
case "deleteMany":
|
|
141
|
+
inputType = `${modelName}DeleteManySchema`;
|
|
142
|
+
break;
|
|
143
|
+
case "updateOne":
|
|
144
|
+
inputType = `${modelName}UpdateOneSchema`;
|
|
145
|
+
break;
|
|
146
|
+
case "updateMany":
|
|
147
|
+
inputType = `${modelName}UpdateManySchema`;
|
|
148
|
+
break;
|
|
149
|
+
case "updateManyAndReturn":
|
|
150
|
+
inputType = `${modelName}UpdateManySchema`;
|
|
151
|
+
break;
|
|
152
|
+
case "upsertOne":
|
|
153
|
+
inputType = `${modelName}UpsertSchema`;
|
|
154
|
+
break;
|
|
155
|
+
case "aggregate":
|
|
156
|
+
inputType = `${modelName}AggregateSchema`;
|
|
157
|
+
break;
|
|
158
|
+
case "aggregateRaw":
|
|
159
|
+
inputType = `${modelName}AggregateRawObjectSchema`;
|
|
160
|
+
break;
|
|
161
|
+
case "groupBy":
|
|
162
|
+
inputType = `${modelName}GroupBySchema`;
|
|
163
|
+
break;
|
|
164
|
+
default: console.log("getInputTypeByOpName: ", {
|
|
165
|
+
opName,
|
|
166
|
+
modelName
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return inputType;
|
|
170
|
+
};
|
|
171
|
+
const getProcedureTypeByOpName = (opName) => {
|
|
172
|
+
let procType;
|
|
173
|
+
switch (opName) {
|
|
174
|
+
case "findUnique":
|
|
175
|
+
case "findFirst":
|
|
176
|
+
case "findMany":
|
|
177
|
+
case "findRaw":
|
|
178
|
+
case "aggregate":
|
|
179
|
+
case "aggregateRaw":
|
|
180
|
+
case "groupBy":
|
|
181
|
+
procType = "query";
|
|
182
|
+
break;
|
|
183
|
+
case "createOne":
|
|
184
|
+
case "createMany":
|
|
185
|
+
case "createManyAndReturn":
|
|
186
|
+
case "deleteOne":
|
|
187
|
+
case "updateOne":
|
|
188
|
+
case "deleteMany":
|
|
189
|
+
case "updateMany":
|
|
190
|
+
case "updateManyAndReturn":
|
|
191
|
+
case "upsertOne":
|
|
192
|
+
procType = "mutation";
|
|
193
|
+
break;
|
|
194
|
+
default: console.log("getProcedureTypeByOpName: ", { opName });
|
|
195
|
+
}
|
|
196
|
+
return procType;
|
|
197
|
+
};
|
|
198
|
+
function resolveModelsComments(models, hiddenModels) {
|
|
199
|
+
const modelAttributeRegex = /(?:@@Gen\.)+[A-z]+\(.+\)/;
|
|
200
|
+
const attributeNameRegex = /\.+[A-Z]+\(+/i;
|
|
201
|
+
const attributeArgsRegex = /\(+[A-Z]+:.+\)/i;
|
|
202
|
+
for (const model of models) if (model.documentation) {
|
|
203
|
+
const attribute = model.documentation?.match(modelAttributeRegex)?.[0];
|
|
204
|
+
if (attribute?.match(attributeNameRegex)?.[0]?.slice(1, -1) !== "model") continue;
|
|
205
|
+
const rawAttributeArgs = attribute?.match(attributeArgsRegex)?.[0]?.slice(1, -1);
|
|
206
|
+
const parsedAttributeArgs = {};
|
|
207
|
+
if (rawAttributeArgs) {
|
|
208
|
+
const rawAttributeArgsParts = rawAttributeArgs.split(":").map((it) => it.trim()).map((part) => part.startsWith("[") ? part : part.split(",")).flat().map((it) => it.trim());
|
|
209
|
+
for (let i = 0; i < rawAttributeArgsParts.length; i += 2) {
|
|
210
|
+
const key = rawAttributeArgsParts[i];
|
|
211
|
+
const value = rawAttributeArgsParts[i + 1];
|
|
212
|
+
parsedAttributeArgs[key] = JSON.parse(value);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (parsedAttributeArgs.hide) hiddenModels.push(model.name);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const getImports = (type, newPath) => {
|
|
219
|
+
let statement = "";
|
|
220
|
+
if (type === "trpc") statement = "import * as trpc from '@trpc/server';\n";
|
|
221
|
+
else if (type === "trpc-shield") statement = "import { shield, allow } from '@stryke/trpc-next/shield';\n";
|
|
222
|
+
else if (type === "context") statement = `import type { Context } from '${newPath}';\n`;
|
|
223
|
+
return statement;
|
|
224
|
+
};
|
|
225
|
+
const wrapWithObject = ({ shieldItemLines }) => {
|
|
226
|
+
let wrapped = "{";
|
|
227
|
+
wrapped += "\n";
|
|
228
|
+
wrapped += Array.isArray(shieldItemLines) ? ` ${shieldItemLines.join(",\r\n")}` : ` ${shieldItemLines}`;
|
|
229
|
+
wrapped += "\n";
|
|
230
|
+
wrapped += "}";
|
|
231
|
+
return wrapped;
|
|
232
|
+
};
|
|
233
|
+
const wrapWithTrpcShieldCall = ({ shieldObjectTextWrapped }) => {
|
|
234
|
+
let wrapped = "shield<Context>(";
|
|
235
|
+
wrapped += "\n";
|
|
236
|
+
wrapped += ` ${shieldObjectTextWrapped}`;
|
|
237
|
+
wrapped += "\n";
|
|
238
|
+
wrapped += ")";
|
|
239
|
+
return wrapped;
|
|
240
|
+
};
|
|
241
|
+
const wrapWithExport = ({ shieldObjectText }) => {
|
|
242
|
+
return `export const permissions: ReturnType<typeof shield<Context>> = ${shieldObjectText};`;
|
|
243
|
+
};
|
|
244
|
+
const constructShield = async ({ queries, mutations, subscriptions }, config, options, outputDir) => {
|
|
245
|
+
if (queries.length === 0 && mutations.length === 0 && subscriptions.length === 0) return "";
|
|
246
|
+
let rootItems = "";
|
|
247
|
+
if (queries.length > 0) {
|
|
248
|
+
const queryLinesWrapped = `query: ${wrapWithObject({ shieldItemLines: queries.map((query) => `${query}: allow`) })},`;
|
|
249
|
+
rootItems += queryLinesWrapped;
|
|
250
|
+
}
|
|
251
|
+
if (mutations.length > 0) {
|
|
252
|
+
const mutationLinesWrapped = `mutation: ${wrapWithObject({ shieldItemLines: mutations.map((mutation) => `${mutation}: allow`) })},`;
|
|
253
|
+
rootItems += mutationLinesWrapped;
|
|
254
|
+
}
|
|
255
|
+
if (subscriptions.length > 0) {
|
|
256
|
+
const subscriptionLinesWrapped = `subscription: ${wrapWithObject({ shieldItemLines: subscriptions.map((subscription) => `${subscription}: allow`) })},`;
|
|
257
|
+
rootItems += subscriptionLinesWrapped;
|
|
258
|
+
}
|
|
259
|
+
if (rootItems.length === 0) return "";
|
|
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)));
|
|
262
|
+
shieldText += "\n\n";
|
|
263
|
+
shieldText += wrapWithExport({ shieldObjectText: wrapWithTrpcShieldCall({ shieldObjectTextWrapped: wrapWithObject({ shieldItemLines: rootItems }) }) });
|
|
264
|
+
return shieldText;
|
|
265
|
+
};
|
|
266
|
+
const constructDefaultOptions = (config, options, outputDir) => {
|
|
267
|
+
return `import { ZodError } from 'zod';${config.withNext ? "\nimport { transformer } from \"@stryke/trpc-next/shared\";" : ""}
|
|
41
268
|
import type {
|
|
42
269
|
DataTransformerOptions,
|
|
43
270
|
RootConfig
|
|
44
271
|
} from "@trpc/server/unstable-core-do-not-import";
|
|
45
|
-
import type { Context } from "${(0,
|
|
272
|
+
import type { Context } from "${(0, __stryke_path_file_path_fns.relativePath)(outputDir, (0, __stryke_path_join_paths.joinPaths)(outputDir, config.contextPath))}";
|
|
46
273
|
|
|
47
274
|
interface RuntimeConfigOptions<
|
|
48
275
|
TContext extends object,
|
|
@@ -65,8 +292,7 @@ interface RuntimeConfigOptions<
|
|
|
65
292
|
transformer?: DataTransformerOptions;
|
|
66
293
|
}
|
|
67
294
|
|
|
68
|
-
const options: RuntimeConfigOptions<Context> = {${
|
|
69
|
-
transformer,`:``}
|
|
295
|
+
const options: RuntimeConfigOptions<Context> = {${config.withNext ? "\n transformer," : ""}
|
|
70
296
|
errorFormatter({ shape, error }) {
|
|
71
297
|
return {
|
|
72
298
|
...shape,
|
|
@@ -82,4 +308,27 @@ const options: RuntimeConfigOptions<Context> = {${e.withNext?`
|
|
|
82
308
|
};
|
|
83
309
|
|
|
84
310
|
export default options;
|
|
85
|
-
|
|
311
|
+
`;
|
|
312
|
+
};
|
|
313
|
+
const constructZodModels = async (models, outputPath, config, options) => {
|
|
314
|
+
const indexFile = require_project.project.createSourceFile(`${outputPath}/index.ts`, {}, { overwrite: true });
|
|
315
|
+
require_model_helpers.generateBarrelFile(models, indexFile);
|
|
316
|
+
indexFile.formatText({ indentSize: 2 });
|
|
317
|
+
await Promise.all(models.map(async (model) => {
|
|
318
|
+
const sourceFile = require_project.project.createSourceFile(`${outputPath}/${require_lower_case_first.lowerCaseFirst(model.name)}.schema.ts`, {}, { overwrite: true });
|
|
319
|
+
await require_model_helpers.populateModelFile(model, sourceFile, config, options);
|
|
320
|
+
sourceFile.formatText({ indentSize: 2 });
|
|
321
|
+
}));
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
//#endregion
|
|
325
|
+
exports.constructDefaultOptions = constructDefaultOptions;
|
|
326
|
+
exports.constructShield = constructShield;
|
|
327
|
+
exports.constructZodModels = constructZodModels;
|
|
328
|
+
exports.generateCreateRouterImport = generateCreateRouterImport;
|
|
329
|
+
exports.generateProcedure = generateProcedure;
|
|
330
|
+
exports.generateRouterImport = generateRouterImport;
|
|
331
|
+
exports.generateRouterSchemaImports = generateRouterSchemaImports;
|
|
332
|
+
exports.generateTRPCExports = generateTRPCExports;
|
|
333
|
+
exports.getInputTypeByOpName = getInputTypeByOpName;
|
|
334
|
+
exports.resolveModelsComments = resolveModelsComments;
|