prisma-generator-express 1.8.0 → 1.9.0
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/{src → dist}/bin.js +1 -0
- package/dist/bin.js.map +1 -0
- package/{src → dist}/constants.js +1 -0
- package/dist/constants.js.map +1 -0
- package/dist/generator.js +167 -0
- package/dist/generator.js.map +1 -0
- package/{src → dist}/helpers/generateAggregate.js +1 -7
- package/dist/helpers/generateAggregate.js.map +1 -0
- package/{src → dist}/helpers/generateCount.js +1 -7
- package/dist/helpers/generateCount.js.map +1 -0
- package/{src → dist}/helpers/generateCreate.js +1 -6
- package/dist/helpers/generateCreate.js.map +1 -0
- package/{src → dist}/helpers/generateCreateMany.js +1 -6
- package/dist/helpers/generateCreateMany.js.map +1 -0
- package/{src → dist}/helpers/generateDelete.js +1 -7
- package/dist/helpers/generateDelete.js.map +1 -0
- package/{src → dist}/helpers/generateDeleteMany.js +1 -7
- package/dist/helpers/generateDeleteMany.js.map +1 -0
- package/{src → dist}/helpers/generateFindFirst.js +1 -6
- package/dist/helpers/generateFindFirst.js.map +1 -0
- package/{src → dist}/helpers/generateFindMany.js +1 -6
- package/dist/helpers/generateFindMany.js.map +1 -0
- package/{src → dist}/helpers/generateFindUnique.js +1 -6
- package/dist/helpers/generateFindUnique.js.map +1 -0
- package/{src → dist}/helpers/generateGroupBy.js +1 -7
- package/dist/helpers/generateGroupBy.js.map +1 -0
- package/{src → dist}/helpers/generateImportPrismaStatement.js +1 -1
- package/dist/helpers/generateImportPrismaStatement.js.map +1 -0
- package/{src → dist}/helpers/generateRouteConfigType.js +1 -0
- package/dist/helpers/generateRouteConfigType.js.map +1 -0
- package/{src → dist}/helpers/generateRouteFile.js +4 -2
- package/dist/helpers/generateRouteFile.js.map +1 -0
- package/{src → dist}/helpers/generateUpdate.js +1 -6
- package/dist/helpers/generateUpdate.js.map +1 -0
- package/{src → dist}/helpers/generateUpdateMany.js +1 -6
- package/dist/helpers/generateUpdateMany.js.map +1 -0
- package/{src → dist}/helpers/generateUpsert.js +1 -7
- package/dist/helpers/generateUpsert.js.map +1 -0
- package/{src → dist}/utils/formatFile.js +6 -2
- package/dist/utils/formatFile.js.map +1 -0
- package/{src → dist}/utils/strings.js +1 -0
- package/dist/utils/strings.js.map +1 -0
- package/dist/utils/writeFileSafely.js +21 -0
- package/dist/utils/writeFileSafely.js.map +1 -0
- package/package.json +2 -2
- package/src/helpers/generateRouteFile.ts +3 -2
- package/src/generator.js +0 -195
- package/src/utils/writeFileSafely.js +0 -29
package/{src → dist}/bin.js
RENAMED
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;AACA,uBAAoB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const generator_helper_1 = require("@prisma/generator-helper");
|
|
4
|
+
const sdk_1 = require("@prisma/sdk");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const writeFileSafely_1 = require("./utils/writeFileSafely");
|
|
7
|
+
const generateFindUnique_1 = require("./helpers/generateFindUnique");
|
|
8
|
+
const generateImportPrismaStatement_1 = require("./helpers/generateImportPrismaStatement");
|
|
9
|
+
const generateFindMany_1 = require("./helpers/generateFindMany");
|
|
10
|
+
const generateFindFirst_1 = require("./helpers/generateFindFirst");
|
|
11
|
+
const generateCreate_1 = require("./helpers/generateCreate");
|
|
12
|
+
const generateRouteFile_1 = require("./helpers/generateRouteFile");
|
|
13
|
+
const generateCreateMany_1 = require("./helpers/generateCreateMany");
|
|
14
|
+
const generateUpdate_1 = require("./helpers/generateUpdate");
|
|
15
|
+
const generateUpdateMany_1 = require("./helpers/generateUpdateMany");
|
|
16
|
+
const generateUpsert_1 = require("./helpers/generateUpsert");
|
|
17
|
+
const generateDelete_1 = require("./helpers/generateDelete");
|
|
18
|
+
const generateDeleteMany_1 = require("./helpers/generateDeleteMany");
|
|
19
|
+
const generateAggregate_1 = require("./helpers/generateAggregate");
|
|
20
|
+
const generateCount_1 = require("./helpers/generateCount");
|
|
21
|
+
const generateGroupBy_1 = require("./helpers/generateGroupBy");
|
|
22
|
+
const generateRouteConfigType_1 = require("./helpers/generateRouteConfigType");
|
|
23
|
+
const { version } = require('../package.json');
|
|
24
|
+
(0, generator_helper_1.generatorHandler)({
|
|
25
|
+
onManifest() {
|
|
26
|
+
sdk_1.logger.info(`${constants_1.GENERATOR_NAME}:Registered`);
|
|
27
|
+
return {
|
|
28
|
+
version,
|
|
29
|
+
defaultOutput: '../generated',
|
|
30
|
+
prettyName: constants_1.GENERATOR_NAME,
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
onGenerate: async (options) => {
|
|
34
|
+
const prismaImportStatement = (0, generateImportPrismaStatement_1.generateImportPrismaStatement)(options);
|
|
35
|
+
for await (const model of options.dmmf.datamodel.models) {
|
|
36
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
37
|
+
content: (0, generateFindUnique_1.generateFindUniqueFunction)({
|
|
38
|
+
model,
|
|
39
|
+
prismaImportStatement,
|
|
40
|
+
}),
|
|
41
|
+
options,
|
|
42
|
+
model,
|
|
43
|
+
operation: 'FindUnique',
|
|
44
|
+
});
|
|
45
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
46
|
+
content: (0, generateFindFirst_1.generateFindFirstFunction)({
|
|
47
|
+
model,
|
|
48
|
+
prismaImportStatement,
|
|
49
|
+
}),
|
|
50
|
+
options,
|
|
51
|
+
model,
|
|
52
|
+
operation: 'FindFirst',
|
|
53
|
+
});
|
|
54
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
55
|
+
content: (0, generateFindMany_1.generateFindManyFunction)({
|
|
56
|
+
model,
|
|
57
|
+
prismaImportStatement,
|
|
58
|
+
}),
|
|
59
|
+
options,
|
|
60
|
+
model,
|
|
61
|
+
operation: 'FindMany',
|
|
62
|
+
});
|
|
63
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
64
|
+
content: (0, generateCreate_1.generateCreateFunction)({
|
|
65
|
+
model,
|
|
66
|
+
prismaImportStatement,
|
|
67
|
+
}),
|
|
68
|
+
options,
|
|
69
|
+
model,
|
|
70
|
+
operation: 'Create',
|
|
71
|
+
});
|
|
72
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
73
|
+
content: (0, generateCreateMany_1.generateCreateManyFunction)({
|
|
74
|
+
model,
|
|
75
|
+
prismaImportStatement,
|
|
76
|
+
}),
|
|
77
|
+
options,
|
|
78
|
+
model,
|
|
79
|
+
operation: 'CreateMany',
|
|
80
|
+
});
|
|
81
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
82
|
+
content: (0, generateUpdate_1.generateUpdateFunction)({
|
|
83
|
+
model,
|
|
84
|
+
prismaImportStatement,
|
|
85
|
+
}),
|
|
86
|
+
options,
|
|
87
|
+
model,
|
|
88
|
+
operation: 'Update',
|
|
89
|
+
});
|
|
90
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
91
|
+
content: (0, generateUpdateMany_1.generateUpdateManyFunction)({
|
|
92
|
+
model,
|
|
93
|
+
prismaImportStatement,
|
|
94
|
+
}),
|
|
95
|
+
options,
|
|
96
|
+
model,
|
|
97
|
+
operation: 'UpdateMany',
|
|
98
|
+
});
|
|
99
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
100
|
+
content: (0, generateUpsert_1.generateUpsertFunction)({
|
|
101
|
+
model,
|
|
102
|
+
prismaImportStatement,
|
|
103
|
+
}),
|
|
104
|
+
options,
|
|
105
|
+
model,
|
|
106
|
+
operation: 'Upsert',
|
|
107
|
+
});
|
|
108
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
109
|
+
content: (0, generateDelete_1.generateDeleteFunction)({
|
|
110
|
+
model,
|
|
111
|
+
prismaImportStatement,
|
|
112
|
+
}),
|
|
113
|
+
options,
|
|
114
|
+
model,
|
|
115
|
+
operation: 'Delete',
|
|
116
|
+
});
|
|
117
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
118
|
+
content: (0, generateDeleteMany_1.generateDeleteManyFunction)({
|
|
119
|
+
model,
|
|
120
|
+
prismaImportStatement,
|
|
121
|
+
}),
|
|
122
|
+
options,
|
|
123
|
+
model,
|
|
124
|
+
operation: 'DeleteMany',
|
|
125
|
+
});
|
|
126
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
127
|
+
content: (0, generateAggregate_1.generateAggregateFunction)({
|
|
128
|
+
model,
|
|
129
|
+
prismaImportStatement,
|
|
130
|
+
}),
|
|
131
|
+
options,
|
|
132
|
+
model,
|
|
133
|
+
operation: 'Aggregate',
|
|
134
|
+
});
|
|
135
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
136
|
+
content: (0, generateCount_1.generateCountFunction)({
|
|
137
|
+
model,
|
|
138
|
+
prismaImportStatement,
|
|
139
|
+
}),
|
|
140
|
+
options,
|
|
141
|
+
model,
|
|
142
|
+
operation: 'Count',
|
|
143
|
+
});
|
|
144
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
145
|
+
content: (0, generateGroupBy_1.generateGroupByFunction)({
|
|
146
|
+
model,
|
|
147
|
+
prismaImportStatement,
|
|
148
|
+
}),
|
|
149
|
+
options,
|
|
150
|
+
model,
|
|
151
|
+
operation: 'GroupBy',
|
|
152
|
+
});
|
|
153
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
154
|
+
content: (0, generateRouteFile_1.generateRouterFunction)({ model }),
|
|
155
|
+
options,
|
|
156
|
+
model,
|
|
157
|
+
operation: 'index',
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
await (0, writeFileSafely_1.writeFileSafely)({
|
|
161
|
+
content: (0, generateRouteConfigType_1.generateRouteConfigType)(),
|
|
162
|
+
options,
|
|
163
|
+
operation: 'RouteConfig',
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"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"}
|
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateAggregateFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that handles aggregation queries
|
|
7
|
-
* and includes conditional output validation with Zod.
|
|
8
|
-
* This version dynamically includes the correct type for the arguments based on the Prisma model.
|
|
9
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
10
|
-
* @returns {string} - The generated middleware function as a string.
|
|
11
|
-
*/
|
|
12
5
|
const generateAggregateFunction = (options) => {
|
|
13
6
|
const { model, prismaImportStatement } = options;
|
|
14
7
|
const modelName = model.name;
|
|
@@ -60,3 +53,4 @@ export async function ${functionName}(req: AggregateRequest, res: Response, next
|
|
|
60
53
|
}`;
|
|
61
54
|
};
|
|
62
55
|
exports.generateAggregateFunction = generateAggregateFunction;
|
|
56
|
+
//# sourceMappingURL=generateAggregate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateAggregate.js","sourceRoot":"","sources":["../../src/helpers/generateAggregate.ts"],"names":[],"mappings":";;;AACA,8CAAmE;AAS5D,MAAM,yBAAyB,GAAG,CAAC,OAGzC,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,WAAW,CAAA;IAC5C,MAAM,YAAY,GAAG,UAAU,IAAA,oBAAU,EAAC,SAAS,CAAC,eAAe,CAAA;IAEnE,OAAO;EACP,qBAAqB;;;;;;;;mBAQJ,YAAY;;;;;kFAKmD,YAAY;;wBAEtE,YAAY;;;;;;sCAME,IAAA,8BAAoB,EAAC,SAAS,CAAC,2BAA2B,YAAY;;;;;;;;;;;;;;;;;;;;;EAqB1G,CAAA;AACF,CAAC,CAAA;AArDY,QAAA,yBAAyB,6BAqDrC"}
|
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateCountFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that handles count queries
|
|
7
|
-
* and includes conditional output validation with Zod.
|
|
8
|
-
* This version dynamically includes the correct type for the arguments based on the Prisma model.
|
|
9
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
10
|
-
* @returns {string} - The generated middleware function as a string.
|
|
11
|
-
*/
|
|
12
5
|
const generateCountFunction = (options) => {
|
|
13
6
|
const { model, prismaImportStatement } = options;
|
|
14
7
|
const modelName = model.name;
|
|
@@ -60,3 +53,4 @@ export async function ${functionName}(req: CountRequest, res: Response, next: Ne
|
|
|
60
53
|
}`;
|
|
61
54
|
};
|
|
62
55
|
exports.generateCountFunction = generateCountFunction;
|
|
56
|
+
//# sourceMappingURL=generateCount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateCount.js","sourceRoot":"","sources":["../../src/helpers/generateCount.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAShD,MAAM,qBAAqB,GAAG,CAAC,OAGrC,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,OAAO,CAAA;IACxC,MAAM,YAAY,GAAG,UAAU,SAAS,WAAW,CAAA;IAEnD,OAAO;EACP,qBAAqB;;;;;;;;mBAQJ,YAAY;;;;;;;wBAOP,YAAY;;;;;;sCAME,IAAA,8BAAoB,EAAC,SAAS,CAAC,uBAAuB,YAAY;;;;;;;;;;;;;;;;;;;;;EAqBtG,CAAA;AACF,CAAC,CAAA;AArDY,QAAA,qBAAqB,yBAqDjC"}
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateCreateFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that handles creation of records and includes conditional output validation with Zod.
|
|
7
|
-
* This version dynamically includes the correct type for the arguments based on the Prisma model.
|
|
8
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
9
|
-
* @returns {string} - The generated middleware function as a string.
|
|
10
|
-
*/
|
|
11
5
|
const generateCreateFunction = (options) => {
|
|
12
6
|
const { model, prismaImportStatement } = options;
|
|
13
7
|
const modelName = model.name;
|
|
@@ -59,3 +53,4 @@ export async function ${functionName}(req: CreateRequest, res: Response, next: N
|
|
|
59
53
|
}`;
|
|
60
54
|
};
|
|
61
55
|
exports.generateCreateFunction = generateCreateFunction;
|
|
56
|
+
//# sourceMappingURL=generateCreate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateCreate.js","sourceRoot":"","sources":["../../src/helpers/generateCreate.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAOhD,MAAM,sBAAsB,GAAG,CAAC,OAGtC,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,QAAQ,CAAA;IACzC,MAAM,YAAY,GAAG,UAAU,SAAS,YAAY,CAAA;IAEpD,OAAO;EACP,qBAAqB;;;;;;;UAOb,YAAY;;;;;uEAKiD,YAAY;;wBAE3D,YAAY;;;;;;oCAMA,IAAA,8BAAoB,EAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;EAsBjE,CAAA;AACF,CAAC,CAAA;AArDY,QAAA,sBAAsB,0BAqDlC"}
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateCreateManyFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that handles the creation of multiple records and includes conditional output validation with Zod.
|
|
7
|
-
* This version dynamically includes the correct type for the arguments based on the Prisma model.
|
|
8
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
9
|
-
* @returns {string} - The generated middleware function as a string.
|
|
10
|
-
*/
|
|
11
5
|
const generateCreateManyFunction = (options) => {
|
|
12
6
|
const { model, prismaImportStatement } = options;
|
|
13
7
|
const modelName = model.name;
|
|
@@ -59,3 +53,4 @@ export async function ${functionName}(req: CreateManyRequest, res: Response, nex
|
|
|
59
53
|
}`;
|
|
60
54
|
};
|
|
61
55
|
exports.generateCreateManyFunction = generateCreateManyFunction;
|
|
56
|
+
//# sourceMappingURL=generateCreateMany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateCreateMany.js","sourceRoot":"","sources":["../../src/helpers/generateCreateMany.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAOhD,MAAM,0BAA0B,GAAG,CAAC,OAG1C,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,YAAY,CAAA;IAC7C,MAAM,YAAY,GAAG,UAAU,SAAS,gBAAgB,CAAA;IAExD,OAAO;EACP,qBAAqB;;;;;;;UAOb,YAAY;;;;;2EAKqD,YAAY;;wBAE/D,YAAY;;;;;;oCAMA,IAAA,8BAAoB,EAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;EAsBjE,CAAA;AACF,CAAC,CAAA;AArDY,QAAA,0BAA0B,8BAqDtC"}
|
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateDeleteFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that handles deleting records
|
|
7
|
-
* and includes conditional output validation with Zod.
|
|
8
|
-
* This version dynamically includes the correct type for the arguments based on the Prisma model.
|
|
9
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
10
|
-
* @returns {string} - The generated middleware function as a string.
|
|
11
|
-
*/
|
|
12
5
|
const generateDeleteFunction = (options) => {
|
|
13
6
|
const { model, prismaImportStatement } = options;
|
|
14
7
|
const modelName = model.name;
|
|
@@ -61,3 +54,4 @@ export async function ${functionName}(req: DeleteRequest, res: Response, next: N
|
|
|
61
54
|
}`;
|
|
62
55
|
};
|
|
63
56
|
exports.generateDeleteFunction = generateDeleteFunction;
|
|
57
|
+
//# sourceMappingURL=generateDelete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateDelete.js","sourceRoot":"","sources":["../../src/helpers/generateDelete.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAQhD,MAAM,sBAAsB,GAAG,CAAC,OAGtC,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,QAAQ,CAAA;IACzC,MAAM,YAAY,GAAG,UAAU,SAAS,YAAY,CAAA;IAEpD,OAAO;EACP,qBAAqB;;;;;;;UAOb,YAAY;;;;;uEAKiD,YAAY;;wBAE3D,YAAY;;;;;;oCAMA,IAAA,8BAAoB,EAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;EAuBjE,CAAA;AACF,CAAC,CAAA;AAtDY,QAAA,sBAAsB,0BAsDlC"}
|
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateDeleteManyFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that handles batch deleting records
|
|
7
|
-
* and includes conditional output validation with Zod.
|
|
8
|
-
* This version dynamically includes the correct type for the arguments based on the Prisma model.
|
|
9
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
10
|
-
* @returns {string} - The generated middleware function as a string.
|
|
11
|
-
*/
|
|
12
5
|
const generateDeleteManyFunction = (options) => {
|
|
13
6
|
const { model, prismaImportStatement } = options;
|
|
14
7
|
const modelName = model.name;
|
|
@@ -59,3 +52,4 @@ export async function ${functionName}(req: DeleteManyRequest, res: Response, nex
|
|
|
59
52
|
}`;
|
|
60
53
|
};
|
|
61
54
|
exports.generateDeleteManyFunction = generateDeleteManyFunction;
|
|
55
|
+
//# sourceMappingURL=generateDeleteMany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateDeleteMany.js","sourceRoot":"","sources":["../../src/helpers/generateDeleteMany.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAQhD,MAAM,0BAA0B,GAAG,CAAC,OAG1C,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,YAAY,CAAA;IAC7C,MAAM,YAAY,GAAG,UAAU,SAAS,gBAAgB,CAAA;IAExD,OAAO;EACP,qBAAqB;;;;;;;UAOb,YAAY;;;;;kFAK4D,SAAS;;wBAEnE,YAAY;;;;;;sCAME,IAAA,8BAAoB,EAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;EAqBnE,CAAA;AACF,CAAC,CAAA;AApDY,QAAA,0BAA0B,8BAoDtC"}
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateFindFirstFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that includes conditional output validation with Zod.
|
|
7
|
-
* This version dynamically includes the correct type for the query parameter based on the Prisma model.
|
|
8
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
9
|
-
* @returns {string} - The generated middleware function as a string.
|
|
10
|
-
*/
|
|
11
5
|
const generateFindFirstFunction = (options) => {
|
|
12
6
|
const { model, prismaImportStatement } = options;
|
|
13
7
|
const modelName = model.name;
|
|
@@ -69,3 +63,4 @@ export async function ${functionName}(req: FindFirstRequest, res: Response, next
|
|
|
69
63
|
}`;
|
|
70
64
|
};
|
|
71
65
|
exports.generateFindFirstFunction = generateFindFirstFunction;
|
|
66
|
+
//# sourceMappingURL=generateFindFirst.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateFindFirst.js","sourceRoot":"","sources":["../../src/helpers/generateFindFirst.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAOhD,MAAM,yBAAyB,GAAG,CAAC,OAGzC,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,WAAW,CAAA;IAC5C,MAAM,aAAa,GAAG,UAAU,SAAS,eAAe,CAAA;IAExD,OAAO;EACP,qBAAqB,CAAC,OAAO,CAAC,YAAY,EAAE,aAAa,SAAS,IAAI,CAAC;;;;;;;;;;;WAW9D,aAAa;;;;;aAKX,SAAS;;;+EAGyD,aAAa;;wBAEpE,YAAY;;;;;;oCAMA,IAAA,8BAAoB,EAAC,SAAS,CAAC,2BAA2B,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;EAyBzG,CAAA;AACF,CAAC,CAAA;AA/DY,QAAA,yBAAyB,6BA+DrC"}
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateFindManyFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that handles multiple record retrieval with optional output validation using Zod.
|
|
7
|
-
* This version dynamically includes the correct type for the query parameter based on the Prisma model.
|
|
8
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
9
|
-
* @returns {string} - The generated middleware function as a string.
|
|
10
|
-
*/
|
|
11
5
|
const generateFindManyFunction = (options) => {
|
|
12
6
|
const { model, prismaImportStatement } = options;
|
|
13
7
|
const modelName = model.name;
|
|
@@ -69,3 +63,4 @@ export async function ${functionName}(req: FindManyRequest, res: Response, next:
|
|
|
69
63
|
}`;
|
|
70
64
|
};
|
|
71
65
|
exports.generateFindManyFunction = generateFindManyFunction;
|
|
66
|
+
//# sourceMappingURL=generateFindMany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateFindMany.js","sourceRoot":"","sources":["../../src/helpers/generateFindMany.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAOhD,MAAM,wBAAwB,GAAG,CAAC,OAGxC,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,UAAU,CAAA;IAC3C,MAAM,aAAa,GAAG,UAAU,SAAS,cAAc,CAAA;IAEvD,OAAO;EACP,qBAAqB,CAAC,OAAO,CAAC,YAAY,EAAE,aAAa,SAAS,IAAI,CAAC;;;;;;;;;;;WAW9D,aAAa;;;;;aAKX,SAAS;;;8EAGwD,aAAa;;wBAEnE,YAAY;;;;;;oCAMA,IAAA,8BAAoB,EAAC,SAAS,CAAC,0BAA0B,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;EAyBxG,CAAA;AACF,CAAC,CAAA;AA/DY,QAAA,wBAAwB,4BA+DpC"}
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateFindUniqueFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that includes conditional output validation with Zod.
|
|
7
|
-
* This version dynamically includes the correct type for the query parameter based on the Prisma model.
|
|
8
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
9
|
-
* @returns {string} - The generated middleware function as a string.
|
|
10
|
-
*/
|
|
11
5
|
const generateFindUniqueFunction = (options) => {
|
|
12
6
|
const { model, prismaImportStatement } = options;
|
|
13
7
|
const modelName = model.name;
|
|
@@ -69,3 +63,4 @@ export async function ${functionName}(req: FindUniqueRequest, res: Response, nex
|
|
|
69
63
|
}`;
|
|
70
64
|
};
|
|
71
65
|
exports.generateFindUniqueFunction = generateFindUniqueFunction;
|
|
66
|
+
//# sourceMappingURL=generateFindUnique.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateFindUnique.js","sourceRoot":"","sources":["../../src/helpers/generateFindUnique.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAOhD,MAAM,0BAA0B,GAAG,CAAC,OAG1C,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,YAAY,CAAA;IAC7C,MAAM,aAAa,GAAG,UAAU,SAAS,gBAAgB,CAAA;IAEzD,OAAO;EACP,qBAAqB,CAAC,OAAO,CAAC,YAAY,EAAE,aAAa,SAAS,IAAI,CAAC;;;;;;;;;;;WAW9D,aAAa;;;;;aAKX,SAAS;;;gFAG0D,aAAa;;wBAErE,YAAY;;;;;;oCAMA,IAAA,8BAAoB,EAAC,SAAS,CAAC,4BAA4B,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;EAyB1G,CAAA;AACF,CAAC,CAAA;AA/DY,QAAA,0BAA0B,8BA+DtC"}
|
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateGroupByFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that handles groupBy queries
|
|
7
|
-
* and includes conditional output validation with Zod.
|
|
8
|
-
* This version dynamically includes the correct type for the arguments based on the Prisma model.
|
|
9
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
10
|
-
* @returns {string} - The generated middleware function as a string.
|
|
11
|
-
*/
|
|
12
5
|
const generateGroupByFunction = (options) => {
|
|
13
6
|
const { model, prismaImportStatement } = options;
|
|
14
7
|
const modelName = model.name;
|
|
@@ -61,3 +54,4 @@ export async function ${functionName}(req: GroupByRequest, res: Response, next:
|
|
|
61
54
|
}`;
|
|
62
55
|
};
|
|
63
56
|
exports.generateGroupByFunction = generateGroupByFunction;
|
|
57
|
+
//# sourceMappingURL=generateGroupBy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateGroupBy.js","sourceRoot":"","sources":["../../src/helpers/generateGroupBy.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAUhD,MAAM,uBAAuB,GAAG,CAAC,OAGvC,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,SAAS,CAAA;IAC1C,MAAM,YAAY,GAAG,UAAU,SAAS,aAAa,CAAA;IAErD,OAAO;EACP,qBAAqB;;;;;;;;mBAQJ,YAAY;;;;;;;wBAOP,YAAY;;;;;;;sCAOE,IAAA,8BAAoB,EAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;EAqBnE,CAAA;AACF,CAAC,CAAA;AAtDY,QAAA,uBAAuB,2BAsDnC"}
|
|
@@ -20,7 +20,7 @@ function getImportGeneratorOptions(options) {
|
|
|
20
20
|
}
|
|
21
21
|
function generateImportPrismaStatement(generatorOptions) {
|
|
22
22
|
const options = getImportGeneratorOptions(generatorOptions);
|
|
23
|
-
// console.log('options.outputPath :>> ', options.outputPath)
|
|
24
23
|
return `import type { Prisma } from '${options.outputPath}';\nimport type { PrismaClient } from '${options.outputPath}';\n`;
|
|
25
24
|
}
|
|
26
25
|
exports.generateImportPrismaStatement = generateImportPrismaStatement;
|
|
26
|
+
//# sourceMappingURL=generateImportPrismaStatement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateImportPrismaStatement.js","sourceRoot":"","sources":["../../src/helpers/generateImportPrismaStatement.ts"],"names":[],"mappings":";;;;;;AACA,gDAAuB;AAMvB,SAAS,yBAAyB,CAChC,OAAyB;;IAEzB,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,IAAI,CAClD,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,QAAQ,CAC/B,CAAA;IAED,IAAI,CAAC,eAAe,IAAI,CAAC,CAAA,MAAA,eAAe,CAAC,MAAM,0CAAE,KAAK,CAAA,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IACvD,CAAC;IAED,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAC5B,MAAA,OAAO,CAAC,SAAS,CAAC,MAAM,0CAAE,KAAM,EAChC,aAAa,CACd,CAAA;IACD,MAAM,gBAAgB,GAAG,eAAe,CAAC,MAAM,CAAC,KAAK,CAAA;IAErD,MAAM,kBAAkB,GAAG,cAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA;IAExE,OAAO;QACL,UAAU,EAAE,kBAAkB,CAAC,KAAK,CAAC,cAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,cAAI,CAAC,KAAK,CAAC,GAAG,CAAC;KACpE,CAAA;AACH,CAAC;AAED,SAAgB,6BAA6B,CAC3C,gBAAkC;IAElC,MAAM,OAAO,GAAG,yBAAyB,CAAC,gBAAgB,CAAC,CAAA;IAE3D,OAAO,gCAAgC,OAAO,CAAC,UAAU,0CAA0C,OAAO,CAAC,UAAU,MAAM,CAAA;AAC7H,CAAC;AAND,sEAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateRouteConfigType.js","sourceRoot":"","sources":["../../src/helpers/generateRouteConfigType.ts"],"names":[],"mappings":";;;AAAA,SAAgB,uBAAuB;IACrC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;8BAyBqB,CAAA;AAC9B,CAAC;AA3BD,0DA2BC"}
|
|
@@ -29,11 +29,12 @@ const defaultBeforeAfter = {
|
|
|
29
29
|
/**
|
|
30
30
|
* Generates an Express router for ${modelName} model.
|
|
31
31
|
* @param config Contains optional middleware to enable routes.
|
|
32
|
+
* @param customUrlPrefix Optional custom URL prefix for the routes.
|
|
32
33
|
* @returns {express.Router}
|
|
33
34
|
*/
|
|
34
|
-
export function ${routerFunctionName}(config: RouteConfig<RequestHandler
|
|
35
|
+
export function ${routerFunctionName}(config: RouteConfig<RequestHandler>, customUrlPrefix = '') {
|
|
35
36
|
const router = express.Router();
|
|
36
|
-
const basePath = config.addModelPrefix ? '/${modelName.toLowerCase()}' : '';
|
|
37
|
+
const basePath = customUrlPrefix + (config.addModelPrefix ? '/${modelName.toLowerCase()}' : '');
|
|
37
38
|
|
|
38
39
|
const setupRoute = (
|
|
39
40
|
path: string,
|
|
@@ -153,3 +154,4 @@ export function ${routerFunctionName}(config: RouteConfig<RequestHandler>) {
|
|
|
153
154
|
`;
|
|
154
155
|
}
|
|
155
156
|
exports.generateRouterFunction = generateRouterFunction;
|
|
157
|
+
//# sourceMappingURL=generateRouteFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateRouteFile.js","sourceRoot":"","sources":["../../src/helpers/generateRouteFile.ts"],"names":[],"mappings":";;;AAEA,SAAgB,sBAAsB,CAAC,EACrC,KAAK,GAGN;IACC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,kBAAkB,GAAG,GAAG,SAAS,QAAQ,CAAA;IAE/C,OAAO;;WAEE,SAAS,uBAAuB,SAAS;WACzC,SAAS,sBAAsB,SAAS;WACxC,SAAS,wBAAwB,SAAS;WAC1C,SAAS,oBAAoB,SAAS;WACtC,SAAS,wBAAwB,SAAS;WAC1C,SAAS,oBAAoB,SAAS;WACtC,SAAS,wBAAwB,SAAS;WAC1C,SAAS,oBAAoB,SAAS;WACtC,SAAS,oBAAoB,SAAS;WACtC,SAAS,wBAAwB,SAAS;WAC1C,SAAS,uBAAuB,SAAS;WACzC,SAAS,mBAAmB,SAAS;WACrC,SAAS,qBAAqB,SAAS;;;;;;;;;qCASb,SAAS;;;;;kBAK5B,kBAAkB;;kEAE8B,SAAS,CAAC,WAAW,EAAE;;;;;;;;;;;;;0CAa/C,SAAS;;;;;;;;qCAQd,SAAS;;;;;;;;wCAQN,SAAS;;;;;;;;sCAQX,SAAS;;;;;;;;0CAQL,SAAS;;;;;;;;qCAQd,SAAS;;;;;;;;yCAQL,SAAS;;;;;;;;uCAQX,SAAS;;;;;;;;wCAQR,SAAS;;;;;;;;4CAQL,SAAS;;;;;;;;8CAQP,SAAS;;;;;;;;0CAQb,SAAS;;;;;;;;4CAQP,SAAS;;;;;;;;CAQpD,CAAA;AACD,CAAC;AA5JD,wDA4JC"}
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateUpdateFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that handles updating records and includes conditional output validation with Zod.
|
|
7
|
-
* This version dynamically includes the correct type for the arguments based on the Prisma model.
|
|
8
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
9
|
-
* @returns {string} - The generated middleware function as a string.
|
|
10
|
-
*/
|
|
11
5
|
const generateUpdateFunction = (options) => {
|
|
12
6
|
const { model, prismaImportStatement } = options;
|
|
13
7
|
const modelName = model.name;
|
|
@@ -60,3 +54,4 @@ export async function ${functionName}(req: UpdateRequest, res: Response, next: N
|
|
|
60
54
|
}`;
|
|
61
55
|
};
|
|
62
56
|
exports.generateUpdateFunction = generateUpdateFunction;
|
|
57
|
+
//# sourceMappingURL=generateUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateUpdate.js","sourceRoot":"","sources":["../../src/helpers/generateUpdate.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAOhD,MAAM,sBAAsB,GAAG,CAAC,OAGtC,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,QAAQ,CAAA;IACzC,MAAM,YAAY,GAAG,UAAU,SAAS,YAAY,CAAA;IAEpD,OAAO;EACP,qBAAqB;;;;;;;UAOb,YAAY;;;;;uEAKiD,YAAY;;wBAE3D,YAAY;;;;;;oCAMA,IAAA,8BAAoB,EAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;EAuBjE,CAAA;AACF,CAAC,CAAA;AAtDY,QAAA,sBAAsB,0BAsDlC"}
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateUpdateManyFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that handles updating multiple records and includes conditional output validation with Zod.
|
|
7
|
-
* This version dynamically includes the correct type for the arguments based on the Prisma model.
|
|
8
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
9
|
-
* @returns {string} - The generated middleware function as a string.
|
|
10
|
-
*/
|
|
11
5
|
const generateUpdateManyFunction = (options) => {
|
|
12
6
|
const { model, prismaImportStatement } = options;
|
|
13
7
|
const modelName = model.name;
|
|
@@ -60,3 +54,4 @@ export async function ${functionName}(req: UpdateManyRequest, res: Response, nex
|
|
|
60
54
|
}`;
|
|
61
55
|
};
|
|
62
56
|
exports.generateUpdateManyFunction = generateUpdateManyFunction;
|
|
57
|
+
//# sourceMappingURL=generateUpdateMany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateUpdateMany.js","sourceRoot":"","sources":["../../src/helpers/generateUpdateMany.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAOhD,MAAM,0BAA0B,GAAG,CAAC,OAG1C,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,YAAY,CAAA;IAC7C,MAAM,YAAY,GAAG,UAAU,SAAS,gBAAgB,CAAA;IAExD,OAAO;EACP,qBAAqB;;;;;;;UAOb,YAAY;;;;;2EAKqD,YAAY;;wBAE/D,YAAY;;;;;;oCAMA,IAAA,8BAAoB,EAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;EAuBjE,CAAA;AACF,CAAC,CAAA;AAtDY,QAAA,0BAA0B,8BAsDtC"}
|
|
@@ -2,13 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateUpsertFunction = void 0;
|
|
4
4
|
const strings_1 = require("../utils/strings");
|
|
5
|
-
/**
|
|
6
|
-
* Generates an Express middleware function that handles the upsert operation (create or update)
|
|
7
|
-
* and includes conditional output validation with Zod.
|
|
8
|
-
* This version dynamically includes the correct type for the arguments based on the Prisma model.
|
|
9
|
-
* @param options - The options containing the model name and the import statement for Prisma types.
|
|
10
|
-
* @returns {string} - The generated middleware function as a string.
|
|
11
|
-
*/
|
|
12
5
|
const generateUpsertFunction = (options) => {
|
|
13
6
|
const { model, prismaImportStatement } = options;
|
|
14
7
|
const modelName = model.name;
|
|
@@ -61,3 +54,4 @@ export async function ${functionName}(req: UpsertRequest, res: Response, next: N
|
|
|
61
54
|
}`;
|
|
62
55
|
};
|
|
63
56
|
exports.generateUpsertFunction = generateUpsertFunction;
|
|
57
|
+
//# sourceMappingURL=generateUpsert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateUpsert.js","sourceRoot":"","sources":["../../src/helpers/generateUpsert.ts"],"names":[],"mappings":";;;AACA,8CAAuD;AAQhD,MAAM,sBAAsB,GAAG,CAAC,OAGtC,EAAU,EAAE;IACX,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAA;IAChD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAA;IAC5B,MAAM,YAAY,GAAG,GAAG,SAAS,QAAQ,CAAA;IACzC,MAAM,YAAY,GAAG,UAAU,SAAS,YAAY,CAAA;IAEpD,OAAO;EACP,qBAAqB;;;;;;;UAOb,YAAY;;;;;uEAKiD,YAAY;;wBAE3D,YAAY;;;;;;oCAMA,IAAA,8BAAoB,EAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;EAuBjE,CAAA;AACF,CAAC,CAAA;AAtDY,QAAA,sBAAsB,0BAsDlC"}
|
|
@@ -8,10 +8,13 @@ const prettier_1 = __importDefault(require("prettier"));
|
|
|
8
8
|
const formatFile = (content) => {
|
|
9
9
|
return new Promise((res, rej) => prettier_1.default.resolveConfig(process.cwd()).then((options) => {
|
|
10
10
|
if (!options) {
|
|
11
|
-
res(content);
|
|
11
|
+
res(content);
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
|
-
const formatted = prettier_1.default.format(content,
|
|
14
|
+
const formatted = prettier_1.default.format(content, {
|
|
15
|
+
...options,
|
|
16
|
+
parser: 'typescript',
|
|
17
|
+
});
|
|
15
18
|
res(formatted);
|
|
16
19
|
}
|
|
17
20
|
catch (error) {
|
|
@@ -20,3 +23,4 @@ const formatFile = (content) => {
|
|
|
20
23
|
}));
|
|
21
24
|
};
|
|
22
25
|
exports.formatFile = formatFile;
|
|
26
|
+
//# sourceMappingURL=formatFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatFile.js","sourceRoot":"","sources":["../../src/utils/formatFile.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA+B;AAExB,MAAM,UAAU,GAAG,CAAC,OAAe,EAAmB,EAAE;IAC7D,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAC9B,kBAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QACrD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,GAAG,CAAC,OAAO,CAAC,CAAA;QACd,CAAC;QAED,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,kBAAQ,CAAC,MAAM,CAAC,OAAO,EAAE;gBACzC,GAAG,OAAO;gBACV,MAAM,EAAE,YAAY;aACrB,CAAC,CAAA;YAEF,GAAG,CAAC,SAAS,CAAC,CAAA;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,GAAG,CAAC,KAAK,CAAC,CAAA;QACZ,CAAC;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC,CAAA;AAnBY,QAAA,UAAU,cAmBtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strings.js","sourceRoot":"","sources":["../../src/utils/strings.ts"],"names":[],"mappings":";;;AAAO,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE,CACxC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAD/B,QAAA,UAAU,cACqB;AAE5C,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,IAAI,CAAC,GAAG;QAAE,OAAO,GAAG,CAAA;IACpB,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AACnD,CAAC;AAHD,oDAGC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.writeFileSafely = void 0;
|
|
7
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const formatFile_1 = require("./formatFile");
|
|
10
|
+
const writeFileSafely = async ({ model, operation, options, content, }) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const fileName = operation === 'index' ? 'index' : `${(model === null || model === void 0 ? void 0 : model.name) || ''}${operation}`;
|
|
13
|
+
const filePath = path_1.default.join((_a = options.generator.output) === null || _a === void 0 ? void 0 : _a.value, model ? `${model === null || model === void 0 ? void 0 : model.name}/${fileName}.ts` : `/${fileName}.ts`);
|
|
14
|
+
console.log('filePath :>> ', filePath);
|
|
15
|
+
await promises_1.default.mkdir(path_1.default.dirname(filePath), {
|
|
16
|
+
recursive: true,
|
|
17
|
+
});
|
|
18
|
+
await promises_1.default.writeFile(filePath, await (0, formatFile_1.formatFile)(content));
|
|
19
|
+
};
|
|
20
|
+
exports.writeFileSafely = writeFileSafely;
|
|
21
|
+
//# sourceMappingURL=writeFileSafely.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeFileSafely.js","sourceRoot":"","sources":["../../src/utils/writeFileSafely.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA4B;AAC5B,gDAAuB;AACvB,6CAAyC;AAGlC,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,KAAK,EACL,SAAS,EACT,OAAO,EACP,OAAO,GAMR,EAAE,EAAE;;IACH,MAAM,QAAQ,GACZ,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,KAAI,EAAE,GAAG,SAAS,EAAE,CAAA;IACtE,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CACxB,MAAA,OAAO,CAAC,SAAS,CAAC,MAAM,0CAAE,KAAM,EAChC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,IAAI,QAAQ,KAAK,CAAC,CAAC,CAAC,IAAI,QAAQ,KAAK,CAC5D,CAAA;IACD,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAA;IACtC,MAAM,kBAAE,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACrC,SAAS,EAAE,IAAI;KAChB,CAAC,CAAA;IAEF,MAAM,kBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAA,uBAAU,EAAC,OAAO,CAAC,CAAC,CAAA;AACzD,CAAC,CAAA;AAvBY,QAAA,eAAe,mBAuB3B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-generator-express",
|
|
3
3
|
"description": "Prisma generator of Express CRUD API",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.9.0",
|
|
5
5
|
"main": "dist/generator.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"start": "node dist/bin.js",
|
|
15
15
|
"dev": "npx tsc -w",
|
|
16
|
-
"build": "npx tsc
|
|
16
|
+
"build": "npx tsc",
|
|
17
17
|
"prepack": "yarn build",
|
|
18
18
|
"test": "jest",
|
|
19
19
|
"prepublishOnly": "node copy.js "
|
|
@@ -33,11 +33,12 @@ const defaultBeforeAfter = {
|
|
|
33
33
|
/**
|
|
34
34
|
* Generates an Express router for ${modelName} model.
|
|
35
35
|
* @param config Contains optional middleware to enable routes.
|
|
36
|
+
* @param customUrlPrefix Optional custom URL prefix for the routes.
|
|
36
37
|
* @returns {express.Router}
|
|
37
38
|
*/
|
|
38
|
-
export function ${routerFunctionName}(config: RouteConfig<RequestHandler
|
|
39
|
+
export function ${routerFunctionName}(config: RouteConfig<RequestHandler>, customUrlPrefix = '') {
|
|
39
40
|
const router = express.Router();
|
|
40
|
-
const basePath = config.addModelPrefix ? '/${modelName.toLowerCase()}' : '';
|
|
41
|
+
const basePath = customUrlPrefix + (config.addModelPrefix ? '/${modelName.toLowerCase()}' : '');
|
|
41
42
|
|
|
42
43
|
const setupRoute = (
|
|
43
44
|
path: string,
|
package/src/generator.js
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
-
var m = o[Symbol.asyncIterator], i;
|
|
14
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
const generator_helper_1 = require("@prisma/generator-helper");
|
|
20
|
-
const sdk_1 = require("@prisma/sdk");
|
|
21
|
-
const constants_1 = require("./constants");
|
|
22
|
-
const writeFileSafely_1 = require("./utils/writeFileSafely");
|
|
23
|
-
const generateFindUnique_1 = require("./helpers/generateFindUnique");
|
|
24
|
-
const generateImportPrismaStatement_1 = require("./helpers/generateImportPrismaStatement");
|
|
25
|
-
const generateFindMany_1 = require("./helpers/generateFindMany");
|
|
26
|
-
const generateFindFirst_1 = require("./helpers/generateFindFirst");
|
|
27
|
-
const generateCreate_1 = require("./helpers/generateCreate");
|
|
28
|
-
const generateRouteFile_1 = require("./helpers/generateRouteFile");
|
|
29
|
-
const generateCreateMany_1 = require("./helpers/generateCreateMany");
|
|
30
|
-
const generateUpdate_1 = require("./helpers/generateUpdate");
|
|
31
|
-
const generateUpdateMany_1 = require("./helpers/generateUpdateMany");
|
|
32
|
-
const generateUpsert_1 = require("./helpers/generateUpsert");
|
|
33
|
-
const generateDelete_1 = require("./helpers/generateDelete");
|
|
34
|
-
const generateDeleteMany_1 = require("./helpers/generateDeleteMany");
|
|
35
|
-
const generateAggregate_1 = require("./helpers/generateAggregate");
|
|
36
|
-
const generateCount_1 = require("./helpers/generateCount");
|
|
37
|
-
const generateGroupBy_1 = require("./helpers/generateGroupBy");
|
|
38
|
-
const generateRouteConfigType_1 = require("./helpers/generateRouteConfigType");
|
|
39
|
-
const { version } = require('../package.json');
|
|
40
|
-
(0, generator_helper_1.generatorHandler)({
|
|
41
|
-
onManifest() {
|
|
42
|
-
sdk_1.logger.info(`${constants_1.GENERATOR_NAME}:Registered`);
|
|
43
|
-
return {
|
|
44
|
-
version,
|
|
45
|
-
defaultOutput: '../generated',
|
|
46
|
-
prettyName: constants_1.GENERATOR_NAME,
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
onGenerate: (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
-
var _a, e_1, _b, _c;
|
|
51
|
-
const prismaImportStatement = (0, generateImportPrismaStatement_1.generateImportPrismaStatement)(options);
|
|
52
|
-
try {
|
|
53
|
-
for (var _d = true, _e = __asyncValues(options.dmmf.datamodel.models), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
54
|
-
_c = _f.value;
|
|
55
|
-
_d = false;
|
|
56
|
-
const model = _c;
|
|
57
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
58
|
-
content: (0, generateFindUnique_1.generateFindUniqueFunction)({
|
|
59
|
-
model,
|
|
60
|
-
prismaImportStatement,
|
|
61
|
-
}),
|
|
62
|
-
options,
|
|
63
|
-
model,
|
|
64
|
-
operation: 'FindUnique',
|
|
65
|
-
});
|
|
66
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
67
|
-
content: (0, generateFindFirst_1.generateFindFirstFunction)({
|
|
68
|
-
model,
|
|
69
|
-
prismaImportStatement,
|
|
70
|
-
}),
|
|
71
|
-
options,
|
|
72
|
-
model,
|
|
73
|
-
operation: 'FindFirst',
|
|
74
|
-
});
|
|
75
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
76
|
-
content: (0, generateFindMany_1.generateFindManyFunction)({
|
|
77
|
-
model,
|
|
78
|
-
prismaImportStatement,
|
|
79
|
-
}),
|
|
80
|
-
options,
|
|
81
|
-
model,
|
|
82
|
-
operation: 'FindMany',
|
|
83
|
-
});
|
|
84
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
85
|
-
content: (0, generateCreate_1.generateCreateFunction)({
|
|
86
|
-
model,
|
|
87
|
-
prismaImportStatement,
|
|
88
|
-
}),
|
|
89
|
-
options,
|
|
90
|
-
model,
|
|
91
|
-
operation: 'Create',
|
|
92
|
-
});
|
|
93
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
94
|
-
content: (0, generateCreateMany_1.generateCreateManyFunction)({
|
|
95
|
-
model,
|
|
96
|
-
prismaImportStatement,
|
|
97
|
-
}),
|
|
98
|
-
options,
|
|
99
|
-
model,
|
|
100
|
-
operation: 'CreateMany',
|
|
101
|
-
});
|
|
102
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
103
|
-
content: (0, generateUpdate_1.generateUpdateFunction)({
|
|
104
|
-
model,
|
|
105
|
-
prismaImportStatement,
|
|
106
|
-
}),
|
|
107
|
-
options,
|
|
108
|
-
model,
|
|
109
|
-
operation: 'Update',
|
|
110
|
-
});
|
|
111
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
112
|
-
content: (0, generateUpdateMany_1.generateUpdateManyFunction)({
|
|
113
|
-
model,
|
|
114
|
-
prismaImportStatement,
|
|
115
|
-
}),
|
|
116
|
-
options,
|
|
117
|
-
model,
|
|
118
|
-
operation: 'UpdateMany',
|
|
119
|
-
});
|
|
120
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
121
|
-
content: (0, generateUpsert_1.generateUpsertFunction)({
|
|
122
|
-
model,
|
|
123
|
-
prismaImportStatement,
|
|
124
|
-
}),
|
|
125
|
-
options,
|
|
126
|
-
model,
|
|
127
|
-
operation: 'Upsert',
|
|
128
|
-
});
|
|
129
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
130
|
-
content: (0, generateDelete_1.generateDeleteFunction)({
|
|
131
|
-
model,
|
|
132
|
-
prismaImportStatement,
|
|
133
|
-
}),
|
|
134
|
-
options,
|
|
135
|
-
model,
|
|
136
|
-
operation: 'Delete',
|
|
137
|
-
});
|
|
138
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
139
|
-
content: (0, generateDeleteMany_1.generateDeleteManyFunction)({
|
|
140
|
-
model,
|
|
141
|
-
prismaImportStatement,
|
|
142
|
-
}),
|
|
143
|
-
options,
|
|
144
|
-
model,
|
|
145
|
-
operation: 'DeleteMany',
|
|
146
|
-
});
|
|
147
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
148
|
-
content: (0, generateAggregate_1.generateAggregateFunction)({
|
|
149
|
-
model,
|
|
150
|
-
prismaImportStatement,
|
|
151
|
-
}),
|
|
152
|
-
options,
|
|
153
|
-
model,
|
|
154
|
-
operation: 'Aggregate',
|
|
155
|
-
});
|
|
156
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
157
|
-
content: (0, generateCount_1.generateCountFunction)({
|
|
158
|
-
model,
|
|
159
|
-
prismaImportStatement,
|
|
160
|
-
}),
|
|
161
|
-
options,
|
|
162
|
-
model,
|
|
163
|
-
operation: 'Count',
|
|
164
|
-
});
|
|
165
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
166
|
-
content: (0, generateGroupBy_1.generateGroupByFunction)({
|
|
167
|
-
model,
|
|
168
|
-
prismaImportStatement,
|
|
169
|
-
}),
|
|
170
|
-
options,
|
|
171
|
-
model,
|
|
172
|
-
operation: 'GroupBy',
|
|
173
|
-
});
|
|
174
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
175
|
-
content: (0, generateRouteFile_1.generateRouterFunction)({ model }),
|
|
176
|
-
options,
|
|
177
|
-
model,
|
|
178
|
-
operation: 'index',
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
183
|
-
finally {
|
|
184
|
-
try {
|
|
185
|
-
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
186
|
-
}
|
|
187
|
-
finally { if (e_1) throw e_1.error; }
|
|
188
|
-
}
|
|
189
|
-
yield (0, writeFileSafely_1.writeFileSafely)({
|
|
190
|
-
content: (0, generateRouteConfigType_1.generateRouteConfigType)(),
|
|
191
|
-
options,
|
|
192
|
-
operation: 'RouteConfig',
|
|
193
|
-
});
|
|
194
|
-
}),
|
|
195
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.writeFileSafely = void 0;
|
|
16
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
17
|
-
const path_1 = __importDefault(require("path"));
|
|
18
|
-
const formatFile_1 = require("./formatFile");
|
|
19
|
-
const writeFileSafely = (_a) => __awaiter(void 0, [_a], void 0, function* ({ model, operation, options, content, }) {
|
|
20
|
-
var _b;
|
|
21
|
-
const fileName = operation === 'index' ? 'index' : `${(model === null || model === void 0 ? void 0 : model.name) || ''}${operation}`;
|
|
22
|
-
const filePath = path_1.default.join((_b = options.generator.output) === null || _b === void 0 ? void 0 : _b.value, model ? `${model === null || model === void 0 ? void 0 : model.name}/${fileName}.ts` : `/${fileName}.ts`);
|
|
23
|
-
console.log('filePath :>> ', filePath);
|
|
24
|
-
yield promises_1.default.mkdir(path_1.default.dirname(filePath), {
|
|
25
|
-
recursive: true,
|
|
26
|
-
});
|
|
27
|
-
yield promises_1.default.writeFile(filePath, yield (0, formatFile_1.formatFile)(content));
|
|
28
|
-
});
|
|
29
|
-
exports.writeFileSafely = writeFileSafely;
|