vsrepo 1.3.4 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +181 -137
  2. package/README.pt-BR.md +188 -144
  3. package/dist/DynamicRepository.d.ts +36 -15
  4. package/dist/VSRepoError.d.ts +21 -1
  5. package/dist/VSRepository.d.ts +126 -87
  6. package/dist/VSRepository.js +49 -49
  7. package/dist/internal/constants/dynamic-methods-key.constant.js +4 -0
  8. package/dist/internal/decorators/dynamic-method.decorator.js +4 -4
  9. package/dist/internal/decorators/query-method.decorator.js +7 -3
  10. package/dist/internal/entities/dynamic-method-metadata.entity.js +3 -3
  11. package/dist/internal/resolvers/base-methods.resolve.js +2 -2
  12. package/dist/internal/resolvers/dbAndPrismaArgs.resolve.js +7 -4
  13. package/dist/internal/resolvers/dynamic-method-customization.resolve.js +57 -0
  14. package/dist/internal/resolvers/dynamic-method-info.resolve.js +279 -0
  15. package/dist/internal/resolvers/dynamic-methods-metadata.resolve.js +2 -2
  16. package/dist/internal/resolvers/pretty-wheres.resolve.js +8 -8
  17. package/dist/internal/resolvers/types/dynamic-method-where-ops.type.js +2 -0
  18. package/dist/internal/utils/schemas.util.js +8 -2
  19. package/dist/internal/validation/constructor-config.validate.js +7 -4
  20. package/dist/internal/validation/method-options.validate.js +10 -3
  21. package/package.json +11 -2
  22. package/scripts/configure-prisma-import.mjs +12 -8
  23. package/scripts/copy-types.mjs +16 -16
  24. package/dist/internal/constants/dinamic-methods-key.constant.js +0 -4
  25. package/dist/internal/resolvers/dinamic-method-customization.resolve.js +0 -57
  26. package/dist/internal/resolvers/dinamic-method-info.resolve.js +0 -279
  27. /package/dist/internal/{resolvers/types/dinamic-method-customization.type.js → errors/types/vs-repo-runtime-error-code.type.js} +0 -0
  28. /package/dist/internal/resolvers/types/{dinamic-method-info.type.js → dynamic-method-customization.type.js} +0 -0
  29. /package/dist/internal/resolvers/types/{dinamic-method-where-ops.type.js → dynamic-method-info.type.js} +0 -0
@@ -1,279 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveDinamicMethodInfo = resolveDinamicMethodInfo;
4
- const vs_repo_error_1 = require("../errors/vs-repo.error");
5
- function resolveDinamicMethodInfo(instance, dinamicMethod, originalKey) {
6
- const dinamicMethodInfo = {
7
- onlyBaseWheres: false,
8
- ignoreWhere: false,
9
- ignoreOrderByAndPagination: true,
10
- ignoreSelect: false,
11
- keyToMapReplaced: "",
12
- argsCount: 0,
13
- method: "unknown",
14
- existsMode: false,
15
- ignoreSkipDuplicates: true,
16
- whereParams: [],
17
- otherParams: [],
18
- ignoreDistinct: true,
19
- };
20
- if (dinamicMethod === "aggregate") {
21
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("aggregate", "");
22
- dinamicMethodInfo.ignoreSelect = true;
23
- dinamicMethodInfo.ignoreWhere = true;
24
- dinamicMethodInfo.method = "aggregate";
25
- dinamicMethodInfo.prismaArgsIndex = 0;
26
- dinamicMethodInfo.otherParams.push("prismaArgs");
27
- dinamicMethodInfo.argsCount++;
28
- }
29
- else if (dinamicMethod === "groupBy") {
30
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("groupBy", "");
31
- dinamicMethodInfo.ignoreSelect = true;
32
- dinamicMethodInfo.ignoreWhere = true;
33
- dinamicMethodInfo.method = "groupBy";
34
- dinamicMethodInfo.prismaArgsIndex = 0;
35
- dinamicMethodInfo.otherParams.push("prismaArgs");
36
- dinamicMethodInfo.argsCount++;
37
- }
38
- else if (dinamicMethod.startsWith("findUniqueOrThrowBy")) {
39
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findUniqueOrThrowBy", "");
40
- dinamicMethodInfo.method = "findUniqueOrThrow";
41
- }
42
- else if (dinamicMethod.startsWith("findUniqueBy")) {
43
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findUniqueBy", "");
44
- dinamicMethodInfo.method = "findUnique";
45
- }
46
- else if (dinamicMethod.startsWith("findFirstOrThrowBy")) {
47
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findFirstOrThrowBy", "");
48
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
49
- dinamicMethodInfo.ignoreDistinct = false;
50
- dinamicMethodInfo.method = "findFirstOrThrow";
51
- }
52
- else if (dinamicMethod.startsWith("findFirstOrThrow")) {
53
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findFirstOrThrow", "");
54
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
55
- dinamicMethodInfo.ignoreWhere = true;
56
- dinamicMethodInfo.onlyBaseWheres = true;
57
- dinamicMethodInfo.ignoreDistinct = false;
58
- dinamicMethodInfo.method = "findFirstOrThrow";
59
- }
60
- else if (dinamicMethod.startsWith("findFirstBy")) {
61
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findFirstBy", "");
62
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
63
- dinamicMethodInfo.ignoreDistinct = false;
64
- dinamicMethodInfo.method = "findFirst";
65
- }
66
- else if (dinamicMethod.startsWith("findFirst")) {
67
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findFirst", "");
68
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
69
- dinamicMethodInfo.ignoreWhere = true;
70
- dinamicMethodInfo.onlyBaseWheres = true;
71
- dinamicMethodInfo.ignoreDistinct = false;
72
- dinamicMethodInfo.method = "findFirst";
73
- }
74
- else if (dinamicMethod.startsWith("countBy")) {
75
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("countBy", "");
76
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
77
- dinamicMethodInfo.ignoreSelect = true;
78
- dinamicMethodInfo.method = "count";
79
- }
80
- else if (dinamicMethod.startsWith("countWhere")) {
81
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("countWhere", "");
82
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
83
- dinamicMethodInfo.ignoreWhere = true;
84
- dinamicMethodInfo.onlyBaseWheres = true;
85
- dinamicMethodInfo.ignoreSelect = true;
86
- dinamicMethodInfo.method = "count";
87
- dinamicMethodInfo.whereIndex = 0;
88
- dinamicMethodInfo.otherParams.push("where");
89
- dinamicMethodInfo.argsCount += 1;
90
- }
91
- else if (dinamicMethod.startsWith("count")) {
92
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("count", "");
93
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
94
- dinamicMethodInfo.ignoreSelect = true;
95
- dinamicMethodInfo.ignoreWhere = true;
96
- dinamicMethodInfo.onlyBaseWheres = true;
97
- dinamicMethodInfo.method = "count";
98
- }
99
- else if (dinamicMethod.startsWith("existsBy")) {
100
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("existsBy", "");
101
- dinamicMethodInfo.ignoreSelect = true;
102
- dinamicMethodInfo.existsMode = true;
103
- dinamicMethodInfo.ignoreDistinct = false;
104
- dinamicMethodInfo.method = "findFirst";
105
- }
106
- else if (dinamicMethod.startsWith("existsWhere")) {
107
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("existsWhere", "");
108
- dinamicMethodInfo.ignoreSelect = true;
109
- dinamicMethodInfo.existsMode = true;
110
- dinamicMethodInfo.ignoreWhere = true;
111
- dinamicMethodInfo.onlyBaseWheres = true;
112
- dinamicMethodInfo.ignoreDistinct = false;
113
- dinamicMethodInfo.method = "findFirst";
114
- dinamicMethodInfo.whereIndex = 0;
115
- dinamicMethodInfo.otherParams.push("where");
116
- dinamicMethodInfo.argsCount += 1;
117
- }
118
- else if (dinamicMethod.startsWith("findManyBy")) {
119
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findManyBy", "");
120
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
121
- dinamicMethodInfo.ignoreDistinct = false;
122
- dinamicMethodInfo.method = "findMany";
123
- }
124
- else if (dinamicMethod.startsWith("findMany")) {
125
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findMany", "");
126
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
127
- dinamicMethodInfo.ignoreWhere = true;
128
- dinamicMethodInfo.onlyBaseWheres = true;
129
- dinamicMethodInfo.ignoreDistinct = false;
130
- dinamicMethodInfo.method = "findMany";
131
- }
132
- else if (dinamicMethod.startsWith("createManyAndReturn")) {
133
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("createManyAndReturn", "");
134
- dinamicMethodInfo.ignoreWhere = true;
135
- dinamicMethodInfo.ignoreSkipDuplicates = false;
136
- dinamicMethodInfo.method = "createManyAndReturn";
137
- dinamicMethodInfo.dataIndex = 0;
138
- dinamicMethodInfo.otherParams.push("data");
139
- dinamicMethodInfo.argsCount++;
140
- }
141
- else if (dinamicMethod.startsWith("createMany")) {
142
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("createMany", "");
143
- dinamicMethodInfo.ignoreWhere = true;
144
- dinamicMethodInfo.ignoreSelect = true;
145
- dinamicMethodInfo.ignoreSkipDuplicates = false;
146
- dinamicMethodInfo.method = "createMany";
147
- dinamicMethodInfo.dataIndex = 0;
148
- dinamicMethodInfo.otherParams.push("data");
149
- dinamicMethodInfo.argsCount++;
150
- }
151
- else if (dinamicMethod.startsWith("create")) {
152
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("create", "");
153
- dinamicMethodInfo.ignoreWhere = true;
154
- dinamicMethodInfo.method = "create";
155
- dinamicMethodInfo.dataIndex = 0;
156
- dinamicMethodInfo.otherParams.push("data");
157
- dinamicMethodInfo.argsCount++;
158
- }
159
- else if (dinamicMethod.startsWith("updateManyAndReturnBy")) {
160
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("updateManyAndReturnBy", "");
161
- dinamicMethodInfo.method = "updateManyAndReturn";
162
- dinamicMethodInfo.dataIndex = -2;
163
- dinamicMethodInfo.otherParams.push("data");
164
- dinamicMethodInfo.argsCount++;
165
- }
166
- else if (dinamicMethod.startsWith("updateManyAndReturnWhere")) {
167
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("updateManyAndReturnWhere", "");
168
- dinamicMethodInfo.ignoreWhere = true;
169
- dinamicMethodInfo.onlyBaseWheres = true;
170
- dinamicMethodInfo.method = "updateManyAndReturn";
171
- dinamicMethodInfo.dataIndex = -2;
172
- dinamicMethodInfo.whereIndex = 0;
173
- dinamicMethodInfo.otherParams.push("where", "data");
174
- dinamicMethodInfo.argsCount += 2;
175
- }
176
- else if (dinamicMethod.startsWith("updateManyBy")) {
177
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("updateManyBy", "");
178
- dinamicMethodInfo.ignoreSelect = true;
179
- dinamicMethodInfo.method = "updateMany";
180
- dinamicMethodInfo.dataIndex = -2;
181
- dinamicMethodInfo.otherParams.push("data");
182
- dinamicMethodInfo.argsCount++;
183
- }
184
- else if (dinamicMethod.startsWith("updateManyWhere")) {
185
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("updateManyWhere", "");
186
- dinamicMethodInfo.ignoreSelect = true;
187
- dinamicMethodInfo.ignoreWhere = true;
188
- dinamicMethodInfo.onlyBaseWheres = true;
189
- dinamicMethodInfo.method = "updateMany";
190
- dinamicMethodInfo.dataIndex = -2;
191
- dinamicMethodInfo.whereIndex = 0;
192
- dinamicMethodInfo.otherParams.push("where", "data");
193
- dinamicMethodInfo.argsCount += 2;
194
- }
195
- else if (dinamicMethod.startsWith("updateBy")) {
196
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("updateBy", "");
197
- dinamicMethodInfo.method = "update";
198
- dinamicMethodInfo.dataIndex = -2;
199
- dinamicMethodInfo.otherParams.push("data");
200
- dinamicMethodInfo.argsCount++;
201
- }
202
- else if (dinamicMethod.startsWith("upsertBy")) {
203
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("upsertBy", "");
204
- dinamicMethodInfo.method = "upsert";
205
- dinamicMethodInfo.createIndex = -2;
206
- dinamicMethodInfo.updateIndex = -3;
207
- dinamicMethodInfo.otherParams.push("update");
208
- dinamicMethodInfo.otherParams.push("create");
209
- dinamicMethodInfo.argsCount += 2;
210
- }
211
- else if (dinamicMethod.startsWith("deleteManyBy")) {
212
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("deleteManyBy", "");
213
- dinamicMethodInfo.ignoreSelect = true;
214
- dinamicMethodInfo.method = "deleteMany";
215
- }
216
- else if (dinamicMethod.startsWith("deleteManyWhere")) {
217
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("deleteManyWhere", "");
218
- dinamicMethodInfo.ignoreSelect = true;
219
- dinamicMethodInfo.ignoreWhere = true;
220
- dinamicMethodInfo.onlyBaseWheres = true;
221
- dinamicMethodInfo.method = "deleteMany";
222
- dinamicMethodInfo.whereIndex = 0;
223
- dinamicMethodInfo.otherParams.push("where");
224
- dinamicMethodInfo.argsCount += 1;
225
- }
226
- else if (dinamicMethod.startsWith("deleteBy")) {
227
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("deleteBy", "");
228
- dinamicMethodInfo.method = "delete";
229
- }
230
- else if (dinamicMethod.startsWith("findWhere")) {
231
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findWhere", "");
232
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
233
- dinamicMethodInfo.ignoreWhere = true;
234
- dinamicMethodInfo.onlyBaseWheres = true;
235
- dinamicMethodInfo.ignoreDistinct = false;
236
- dinamicMethodInfo.method = "findFirst";
237
- dinamicMethodInfo.whereIndex = 0;
238
- dinamicMethodInfo.otherParams.push("where");
239
- dinamicMethodInfo.argsCount += 1;
240
- }
241
- else if (dinamicMethod.startsWith("findOneWhere")) {
242
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findOneWhere", "");
243
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
244
- dinamicMethodInfo.ignoreWhere = true;
245
- dinamicMethodInfo.onlyBaseWheres = true;
246
- dinamicMethodInfo.ignoreDistinct = false;
247
- dinamicMethodInfo.method = "findFirst";
248
- dinamicMethodInfo.whereIndex = 0;
249
- dinamicMethodInfo.otherParams.push("where");
250
- dinamicMethodInfo.argsCount += 1;
251
- }
252
- else if (dinamicMethod.startsWith("findListWhere")) {
253
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findListWhere", "");
254
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
255
- dinamicMethodInfo.ignoreWhere = true;
256
- dinamicMethodInfo.onlyBaseWheres = true;
257
- dinamicMethodInfo.ignoreDistinct = false;
258
- dinamicMethodInfo.method = "findMany";
259
- dinamicMethodInfo.whereIndex = 0;
260
- dinamicMethodInfo.otherParams.push("where");
261
- dinamicMethodInfo.argsCount += 1;
262
- }
263
- else if (dinamicMethod.startsWith("findOneBy")) {
264
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findOneBy", "");
265
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
266
- dinamicMethodInfo.ignoreDistinct = false;
267
- dinamicMethodInfo.method = "findFirst";
268
- }
269
- else if (dinamicMethod.startsWith("findBy")) {
270
- dinamicMethodInfo.keyToMapReplaced = dinamicMethod.replace("findBy", "");
271
- dinamicMethodInfo.ignoreOrderByAndPagination = false;
272
- dinamicMethodInfo.ignoreDistinct = false;
273
- dinamicMethodInfo.method = instance.methods?.[originalKey]?.fbMode === "one" ? "findFirst" : "findMany";
274
- }
275
- else {
276
- throw new vs_repo_error_1.VSRepoBuildError(`[VSRepository] (${instance.tableName}: build) Unknown method: ${dinamicMethod}.`);
277
- }
278
- return dinamicMethodInfo;
279
- }