vsrepo 1.4.2 → 2.1.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/README.md +827 -1322
- package/README.pt-BR.md +833 -1325
- package/dist/VSRepoAdapter.d.ts +109 -0
- package/dist/VSRepoAdapter.js +18 -0
- package/dist/VSRepository.d.ts +166 -1201
- package/dist/VSRepository.js +327 -237
- package/dist/decorators/dynamic-method.decorator.d.ts +25 -0
- package/dist/decorators/dynamic-method.decorator.js +38 -0
- package/dist/decorators/query-method.decorator.d.ts +27 -0
- package/dist/decorators/query-method.decorator.js +45 -0
- package/dist/errors/VSRepoAdapterError.d.ts +22 -0
- package/dist/errors/VSRepoAdapterError.js +31 -0
- package/dist/errors/VSRepoError.d.ts +15 -0
- package/dist/errors/VSRepoError.js +21 -0
- package/dist/index.d.ts +38 -1
- package/dist/index.js +28 -15
- package/dist/internal/constants/debug-arg-symbol.constant.d.ts +1 -0
- package/dist/internal/constants/debug-arg-symbol.constant.js +4 -0
- package/dist/internal/constants/dynamic-methods-key.constant.d.ts +1 -0
- package/dist/internal/constants/query-methods-key.constant.d.ts +1 -0
- package/dist/internal/constants/query-methods-key.constant.js +4 -0
- package/dist/internal/enums/adapter-error-code.enum.d.ts +125 -0
- package/dist/internal/enums/adapter-error-code.enum.js +129 -0
- package/dist/internal/enums/transaction-isolation-level.enum.d.ts +16 -0
- package/dist/internal/enums/transaction-isolation-level.enum.js +20 -0
- package/dist/internal/enums/vs-log-level.enum.d.ts +18 -0
- package/dist/internal/enums/vs-log-level.enum.js +22 -0
- package/dist/internal/enums/vsrepo-error-type.enum.d.ts +19 -0
- package/dist/internal/enums/vsrepo-error-type.enum.js +23 -0
- package/dist/internal/resolvers/dynamic-methods.resolver.d.ts +23 -0
- package/dist/internal/resolvers/dynamic-methods.resolver.js +910 -0
- package/dist/internal/resolvers/merge-wheres.resolver.d.ts +7 -0
- package/dist/internal/resolvers/merge-wheres.resolver.js +26 -0
- package/dist/internal/utils/uncapitalize.util.d.ts +1 -0
- package/dist/internal/utils/vs-logger.util.d.ts +25 -0
- package/dist/internal/utils/vs-logger.util.js +139 -0
- package/dist/internal/validators/decorators.validator.d.ts +8 -0
- package/dist/internal/validators/decorators.validator.js +75 -0
- package/dist/internal/validators/schemas/ordering.schema.d.ts +3 -0
- package/dist/internal/validators/schemas/ordering.schema.js +38 -0
- package/dist/internal/validators/schemas/pagination.schema.d.ts +6 -0
- package/dist/internal/validators/schemas/pagination.schema.js +40 -0
- package/dist/internal/validators/schemas/where.schema.d.ts +7 -0
- package/dist/internal/validators/schemas/where.schema.js +42 -0
- package/dist/internal/validators/vsrepo.validator.d.ts +40 -0
- package/dist/internal/validators/vsrepo.validator.js +182 -0
- package/dist/types/adapter/adapter-method-options.type.d.ts +24 -0
- package/dist/types/adapter/adapter-query-options.type.d.ts +5 -0
- package/dist/types/decorators/dynamic-method-options.type.d.ts +14 -0
- package/dist/types/decorators/query-method-options.type.d.ts +15 -0
- package/dist/types/dynamic-methods/dynamic-method-customization.type.d.ts +7 -0
- package/dist/types/dynamic-methods/dynamic-method-info.type.d.ts +18 -0
- package/dist/types/dynamic-methods/dynamic-method-where-ops.type.d.ts +6 -0
- package/dist/types/utils/count-result.type.d.ts +9 -0
- package/dist/types/utils/decimal-like.type.d.ts +23 -0
- package/dist/types/utils/deep-partial.type.d.ts +14 -0
- package/dist/types/utils/keys-of-type.type.d.ts +20 -0
- package/dist/types/utils/methods-options.type.d.ts +23 -0
- package/dist/types/utils/numeric-keys.type.d.ts +24 -0
- package/dist/types/utils/numeric-like.type.d.ts +10 -0
- package/dist/types/utils/ordering.type.d.ts +39 -0
- package/dist/types/utils/pagination.type.d.ts +11 -0
- package/dist/types/utils/perform-data.type.d.ts +4 -0
- package/dist/types/utils/primitive.type.d.ts +7 -0
- package/dist/types/utils/query-method-arg.type.d.ts +27 -0
- package/dist/types/utils/restrict-method-options.type.d.ts +14 -0
- package/dist/types/utils/see-mode.type.d.ts +12 -0
- package/dist/types/vsrepo/vsrepo-args.type.d.ts +9 -0
- package/dist/types/vsrepo/vsrepo-method.type.d.ts +4 -0
- package/dist/types/vsrepo/vsrepo-method.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-options.type.d.ts +34 -0
- package/dist/types/vsrepo/vsrepo-options.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-orm-types.type.d.ts +17 -0
- package/dist/types/vsrepo/vsrepo-orm-types.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-pretty-where.type.d.ts +7 -0
- package/dist/types/vsrepo/vsrepo-pretty-where.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-query-options.type.d.ts +17 -0
- package/dist/types/vsrepo/vsrepo-query-options.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-query.type.d.ts +5 -0
- package/dist/types/vsrepo/vsrepo-query.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-relations.type.d.ts +26 -0
- package/dist/types/vsrepo/vsrepo-relations.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-resolve-args-data.type.d.ts +19 -0
- package/dist/types/vsrepo/vsrepo-resolve-args-data.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-select.type.d.ts +15 -0
- package/dist/types/vsrepo/vsrepo-select.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-transaction-options.type.d.ts +12 -0
- package/dist/types/vsrepo/vsrepo-transaction-options.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-ugly-where.type.d.ts +9 -0
- package/dist/types/vsrepo/vsrepo-ugly-where.type.js +2 -0
- package/dist/types/vsrepo/vsrepo-where.type.d.ts +99 -0
- package/dist/types/vsrepo/vsrepo-where.type.js +2 -0
- package/package.json +16 -37
- package/README-DynamicRepo.md +0 -625
- package/README-DynamicRepo.pt-BR.md +0 -625
- package/dist/DynamicRepository.d.ts +0 -497
- package/dist/DynamicRepository.js +0 -26
- package/dist/VSRepoError.d.ts +0 -83
- package/dist/VSRepoError.js +0 -17
- package/dist/internal/decorators/dynamic-method.decorator.js +0 -14
- package/dist/internal/decorators/query-method.decorator.js +0 -20
- package/dist/internal/entities/dynamic-method-metadata.entity.js +0 -26
- package/dist/internal/errors/vs-repo.error.js +0 -31
- package/dist/internal/resolvers/base-methods.resolve.js +0 -541
- package/dist/internal/resolvers/create-update-payloads-with-relations.resolve.js +0 -143
- package/dist/internal/resolvers/data-payload-with-relations.resolve.js +0 -60
- package/dist/internal/resolvers/dbAndPrismaArgs.resolve.js +0 -63
- package/dist/internal/resolvers/dynamic-method-customization.resolve.js +0 -57
- package/dist/internal/resolvers/dynamic-method-info.resolve.js +0 -279
- package/dist/internal/resolvers/dynamic-methods-metadata.resolve.js +0 -15
- package/dist/internal/resolvers/merge-wheres.resolve.js +0 -22
- package/dist/internal/resolvers/pretty-wheres.resolve.js +0 -87
- package/dist/internal/resolvers/select.resolve.js +0 -7
- package/dist/internal/resolvers/specific-where.resolve.js +0 -84
- package/dist/internal/resolvers/ugly-where.resolve.js +0 -178
- package/dist/internal/utils/logger.util.js +0 -21
- package/dist/internal/utils/schemas.util.js +0 -31
- package/dist/internal/validation/build-config.validate.js +0 -84
- package/dist/internal/validation/constructor-config.validate.js +0 -64
- package/dist/internal/validation/dynamic-method-config.validate.js +0 -19
- package/dist/internal/validation/extension.validate.js +0 -15
- package/dist/internal/validation/is-object.validate.js +0 -6
- package/dist/internal/validation/method-options.validate.js +0 -42
- package/dist/internal/validation/obj-with-relations.validate.js +0 -37
- package/dist/internal/validation/prisma-client.validate.js +0 -10
- package/dist/internal/validation/query-method-arg.validate.js +0 -22
- package/dist/internal/validation/query-method-options.validate.js +0 -24
- package/scripts/configure-prisma-import.mjs +0 -283
- package/scripts/copy-types.mjs +0 -24
- /package/dist/{internal/decorators/types/dynamic-method-config.type.js → types/adapter/adapter-method-options.type.js} +0 -0
- /package/dist/{internal/errors/types/vs-repo-error-type.type.js → types/adapter/adapter-query-options.type.js} +0 -0
- /package/dist/{internal/errors/types/vs-repo-runtime-error-code.type.js → types/decorators/dynamic-method-options.type.js} +0 -0
- /package/dist/{internal/validation/types → types/decorators}/query-method-options.type.js +0 -0
- /package/dist/{internal/resolvers/types → types/dynamic-methods}/dynamic-method-customization.type.js +0 -0
- /package/dist/{internal/resolvers/types → types/dynamic-methods}/dynamic-method-info.type.js +0 -0
- /package/dist/{internal/resolvers/types → types/dynamic-methods}/dynamic-method-where-ops.type.js +0 -0
- /package/dist/{internal/resolvers/types/base-method-function.type.js → types/utils/count-result.type.js} +0 -0
- /package/dist/{internal/resolvers/types/pretty-where.type.js → types/utils/decimal-like.type.js} +0 -0
- /package/dist/{internal/resolvers/types/prisma-args.type.js → types/utils/deep-partial.type.js} +0 -0
- /package/dist/{internal/resolvers/types/repository-build-instance.type.js → types/utils/keys-of-type.type.js} +0 -0
- /package/dist/{internal/resolvers/types/resolve-db-and-prisma-args-data.type.js → types/utils/methods-options.type.js} +0 -0
- /package/dist/{internal/resolvers/types/ugly-where.type.js → types/utils/numeric-keys.type.js} +0 -0
- /package/dist/{internal/validation/types/base-methods.type.js → types/utils/numeric-like.type.js} +0 -0
- /package/dist/{internal/validation/types/build-config.type.js → types/utils/ordering.type.js} +0 -0
- /package/dist/{internal/validation/types → types/utils}/pagination.type.js +0 -0
- /package/dist/{internal/validation/types/constructor-config.type.js → types/utils/perform-data.type.js} +0 -0
- /package/dist/{internal/validation/types/method-options.type.js → types/utils/primitive.type.js} +0 -0
- /package/dist/{internal/validation/types → types/utils}/query-method-arg.type.js +0 -0
- /package/dist/{internal/validation/types/method.type.js → types/utils/restrict-method-options.type.js} +0 -0
- /package/dist/{internal/validation/types → types/utils}/see-mode.type.js +0 -0
- /package/dist/{internal/validation/types/relation.type.js → types/vsrepo/vsrepo-args.type.js} +0 -0
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveCreateUpdatePayloadsWithRelations = resolveCreateUpdatePayloadsWithRelations;
|
|
4
|
-
function resolveCreateUpdatePayloadsWithRelations(instance, obj, relationsKeys) {
|
|
5
|
-
const relations = instance.relations;
|
|
6
|
-
if (!relations) {
|
|
7
|
-
const objUpdate = { ...obj };
|
|
8
|
-
delete objUpdate[instance.pkName];
|
|
9
|
-
return {
|
|
10
|
-
createPayload: obj,
|
|
11
|
-
updatePayload: objUpdate,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
const createPayload = {};
|
|
15
|
-
const updatePayload = {};
|
|
16
|
-
const objKeys = Object.keys(obj);
|
|
17
|
-
for (let i = 0; i < objKeys.length; i++) {
|
|
18
|
-
const key = objKeys[i];
|
|
19
|
-
const field = obj[key];
|
|
20
|
-
if (field === undefined)
|
|
21
|
-
continue;
|
|
22
|
-
if (relationsKeys.includes(key)) {
|
|
23
|
-
const relation = relations[key];
|
|
24
|
-
if (relation.mode === "oto" || relation.mode === "mto") {
|
|
25
|
-
if (field === null) {
|
|
26
|
-
if (relation.mode === "oto" && relation.restriction === "set") {
|
|
27
|
-
updatePayload[key] = { delete: true };
|
|
28
|
-
}
|
|
29
|
-
else if (relation.mode === "mto" && (relation.nullAble || relation.nullable)) {
|
|
30
|
-
updatePayload[key] = { disconnect: true };
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
else if (field !== undefined) {
|
|
34
|
-
const relationFieldPk = field[relation.pk];
|
|
35
|
-
if (relationFieldPk != null) {
|
|
36
|
-
const connectOrCreate = {
|
|
37
|
-
where: { [relation.pk]: relationFieldPk },
|
|
38
|
-
create: field,
|
|
39
|
-
};
|
|
40
|
-
createPayload[key] = { connectOrCreate };
|
|
41
|
-
if (relation.restriction === "add") {
|
|
42
|
-
updatePayload[key] = { connectOrCreate };
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
const update = { ...field };
|
|
46
|
-
delete update[relation.pk];
|
|
47
|
-
updatePayload[key] = {
|
|
48
|
-
upsert: {
|
|
49
|
-
where: { [relation.pk]: relationFieldPk },
|
|
50
|
-
create: field,
|
|
51
|
-
update: update,
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
createPayload[key] = { create: field };
|
|
58
|
-
updatePayload[key] =
|
|
59
|
-
relation.restriction === "add"
|
|
60
|
-
? { create: field }
|
|
61
|
-
: { upsert: { create: field, update: field } };
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
const fieldAnyArray = field;
|
|
67
|
-
const dataWithPk = [];
|
|
68
|
-
const dataWithoutPk = [];
|
|
69
|
-
fieldAnyArray.forEach((data) => {
|
|
70
|
-
if (data[relation.pk] !== undefined) {
|
|
71
|
-
dataWithPk.push(data);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
dataWithoutPk.push(data);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
const connectOrCreate = dataWithPk.map(data => ({
|
|
78
|
-
where: { [relation.pk]: data[relation.pk] },
|
|
79
|
-
create: data,
|
|
80
|
-
}));
|
|
81
|
-
createPayload[key] = {
|
|
82
|
-
create: dataWithoutPk,
|
|
83
|
-
connectOrCreate,
|
|
84
|
-
};
|
|
85
|
-
if (relation.restriction === "add") {
|
|
86
|
-
if (relation.mode === "mtm") {
|
|
87
|
-
updatePayload[key] = {
|
|
88
|
-
create: dataWithoutPk,
|
|
89
|
-
connectOrCreate,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
updatePayload[key] = {
|
|
94
|
-
create: dataWithoutPk,
|
|
95
|
-
upsert: dataWithPk.map(data => {
|
|
96
|
-
const update = { ...data };
|
|
97
|
-
delete update[relation.pk];
|
|
98
|
-
return {
|
|
99
|
-
where: { [relation.pk]: data[relation.pk] },
|
|
100
|
-
create: data,
|
|
101
|
-
update,
|
|
102
|
-
};
|
|
103
|
-
}),
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
if (relation.mode === "mtm") {
|
|
109
|
-
updatePayload[key] = {
|
|
110
|
-
set: [],
|
|
111
|
-
create: dataWithoutPk,
|
|
112
|
-
connectOrCreate,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
updatePayload[key] = {
|
|
117
|
-
deleteMany: {
|
|
118
|
-
[relation.pk]: { notIn: dataWithPk.map(data => data[relation.pk]) },
|
|
119
|
-
},
|
|
120
|
-
create: dataWithoutPk,
|
|
121
|
-
upsert: dataWithPk.map(data => {
|
|
122
|
-
const update = { ...data };
|
|
123
|
-
delete update[relation.pk];
|
|
124
|
-
return {
|
|
125
|
-
where: { [relation.pk]: data[relation.pk] },
|
|
126
|
-
create: data,
|
|
127
|
-
update,
|
|
128
|
-
};
|
|
129
|
-
}),
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
createPayload[key] = field;
|
|
137
|
-
if (key !== instance.pkName) {
|
|
138
|
-
updatePayload[key] = field;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return { createPayload, updatePayload };
|
|
143
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveDataPayloadWithRelations = resolveDataPayloadWithRelations;
|
|
4
|
-
function resolveDataPayloadWithRelations(instance, obj, relationsKeys) {
|
|
5
|
-
const relations = instance.relations;
|
|
6
|
-
if (!relations)
|
|
7
|
-
return obj;
|
|
8
|
-
const dataPayload = {};
|
|
9
|
-
const objKeys = Object.keys(obj);
|
|
10
|
-
for (let i = 0; i < objKeys.length; i++) {
|
|
11
|
-
const key = objKeys[i];
|
|
12
|
-
const field = obj[key];
|
|
13
|
-
if (field === undefined)
|
|
14
|
-
continue;
|
|
15
|
-
if (relationsKeys.includes(key)) {
|
|
16
|
-
if (field === null)
|
|
17
|
-
continue;
|
|
18
|
-
const relation = relations[key];
|
|
19
|
-
if (relation.mode === "otm" || relation.mode === "mtm") {
|
|
20
|
-
const dataWithPk = [];
|
|
21
|
-
const dataWithoutPk = [];
|
|
22
|
-
field.forEach((data) => {
|
|
23
|
-
if (data[relation.pk] !== undefined) {
|
|
24
|
-
dataWithPk.push(data);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
dataWithoutPk.push(data);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
dataPayload[key] = {
|
|
31
|
-
create: dataWithoutPk,
|
|
32
|
-
connectOrCreate: dataWithPk.map(data => ({
|
|
33
|
-
where: { [relation.pk]: data[relation.pk] },
|
|
34
|
-
create: data,
|
|
35
|
-
})),
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const relationFieldPk = field[relation.pk];
|
|
40
|
-
if (relationFieldPk != null) {
|
|
41
|
-
dataPayload[key] = {
|
|
42
|
-
connectOrCreate: {
|
|
43
|
-
where: { [relation.pk]: relationFieldPk },
|
|
44
|
-
create: field,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
dataPayload[key] = {
|
|
50
|
-
create: field,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
dataPayload[key] = field;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return dataPayload;
|
|
60
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveDbAndPrismaArgs = resolveDbAndPrismaArgs;
|
|
4
|
-
const method_options_validate_1 = require("../validation/method-options.validate");
|
|
5
|
-
const merge_wheres_resolve_1 = require("./merge-wheres.resolve");
|
|
6
|
-
const select_resolve_1 = require("./select.resolve");
|
|
7
|
-
function resolveDbAndPrismaArgs(data) {
|
|
8
|
-
const { baseConfig, instance, options, wherePkValue, withoutSelect, withoutWhere, specificSelect, dataPayload, createPayload, updatePayload, alreadyValidatedOptions, specificWhere, pushWhere, ordering, pagination, skipDuplicates, forceSeeMode, withOrderingAndPagination, distinctKeys, } = data;
|
|
9
|
-
const validatedOptions = alreadyValidatedOptions && options
|
|
10
|
-
? options
|
|
11
|
-
: (0, method_options_validate_1.validateMethodOptions)(options, instance);
|
|
12
|
-
const db = validatedOptions.db ?? instance.prisma;
|
|
13
|
-
const prismaArgs = {};
|
|
14
|
-
if (!withoutWhere) {
|
|
15
|
-
prismaArgs.where = (0, merge_wheres_resolve_1.resolveMergeWheres)({
|
|
16
|
-
respectRequired: !baseConfig.ignoreRequiredWhere,
|
|
17
|
-
see: forceSeeMode ?? validatedOptions.see,
|
|
18
|
-
}, wherePkValue != undefined ? { [instance.pkName]: wherePkValue } : specificWhere, pushWhere, instance.requiredWhere, instance.softRemovekName);
|
|
19
|
-
}
|
|
20
|
-
if (!withoutSelect) {
|
|
21
|
-
if (specificSelect) {
|
|
22
|
-
prismaArgs.select = specificSelect;
|
|
23
|
-
}
|
|
24
|
-
else if (validatedOptions.select) {
|
|
25
|
-
prismaArgs.select = validatedOptions.select;
|
|
26
|
-
}
|
|
27
|
-
else if (validatedOptions.includeModel) {
|
|
28
|
-
prismaArgs.include = instance.includeModels?.[validatedOptions.includeModel];
|
|
29
|
-
}
|
|
30
|
-
else if (validatedOptions.include) {
|
|
31
|
-
prismaArgs.include = validatedOptions.include;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
prismaArgs.select = (0, select_resolve_1.resolveSelect)(instance, validatedOptions.selectModel, baseConfig.defaultSelect);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (dataPayload) {
|
|
38
|
-
prismaArgs.data = dataPayload;
|
|
39
|
-
}
|
|
40
|
-
if (createPayload) {
|
|
41
|
-
prismaArgs.create = createPayload;
|
|
42
|
-
}
|
|
43
|
-
if (updatePayload) {
|
|
44
|
-
prismaArgs.update = updatePayload;
|
|
45
|
-
}
|
|
46
|
-
if (withOrderingAndPagination) {
|
|
47
|
-
if (instance.defaultOrdering || ordering) {
|
|
48
|
-
prismaArgs.orderBy = ordering ?? instance.defaultOrdering;
|
|
49
|
-
}
|
|
50
|
-
if (pagination) {
|
|
51
|
-
prismaArgs.skip = pagination.skip;
|
|
52
|
-
prismaArgs.take = pagination.take;
|
|
53
|
-
prismaArgs.cursor = pagination.cursor;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (skipDuplicates !== undefined) {
|
|
57
|
-
prismaArgs.skipDuplicates = skipDuplicates;
|
|
58
|
-
}
|
|
59
|
-
if (distinctKeys !== undefined) {
|
|
60
|
-
prismaArgs.distinct = distinctKeys;
|
|
61
|
-
}
|
|
62
|
-
return { db, prismaArgs };
|
|
63
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveDynamicMethodCustomization = resolveDynamicMethodCustomization;
|
|
4
|
-
const uncapitalize_util_1 = require("../utils/uncapitalize.util");
|
|
5
|
-
function resolveDynamicMethodCustomization(instance, dynamicMethodInfo, originalKey) {
|
|
6
|
-
const dynamicMethodCustomization = {};
|
|
7
|
-
if (!dynamicMethodInfo.ignoreSkipDuplicates) {
|
|
8
|
-
if (dynamicMethodInfo.keyToMapReplaced.endsWith("SkipDuplicates")) {
|
|
9
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethodInfo.keyToMapReplaced.replace("SkipDuplicates", "");
|
|
10
|
-
dynamicMethodCustomization.skipDuplicates = true;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
if (!dynamicMethodInfo.ignoreOrderByAndPagination) {
|
|
14
|
-
dynamicMethodCustomization.injectOrdering =
|
|
15
|
-
instance.methods?.[originalKey]?.injectOrdering;
|
|
16
|
-
dynamicMethodCustomization.injectPagination =
|
|
17
|
-
instance.methods?.[originalKey]?.injectPagination;
|
|
18
|
-
if (dynamicMethodInfo.keyToMapReplaced.endsWith("PaginatedAndOrdered")) {
|
|
19
|
-
dynamicMethodCustomization.orderPosition = -2;
|
|
20
|
-
dynamicMethodCustomization.paginationPosition = -3;
|
|
21
|
-
dynamicMethodInfo.otherParams.push("pagination");
|
|
22
|
-
dynamicMethodInfo.otherParams.push("order");
|
|
23
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethodInfo.keyToMapReplaced.replace("PaginatedAndOrdered", "");
|
|
24
|
-
dynamicMethodInfo.argsCount += 2;
|
|
25
|
-
}
|
|
26
|
-
else if (dynamicMethodInfo.keyToMapReplaced.endsWith("OrderedAndPaginated")) {
|
|
27
|
-
dynamicMethodCustomization.orderPosition = -3;
|
|
28
|
-
dynamicMethodCustomization.paginationPosition = -2;
|
|
29
|
-
dynamicMethodInfo.otherParams.push("order");
|
|
30
|
-
dynamicMethodInfo.otherParams.push("pagination");
|
|
31
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethodInfo.keyToMapReplaced.replace("OrderedAndPaginated", "");
|
|
32
|
-
dynamicMethodInfo.argsCount += 2;
|
|
33
|
-
}
|
|
34
|
-
else if (dynamicMethodInfo.keyToMapReplaced.endsWith("Paginated")) {
|
|
35
|
-
dynamicMethodCustomization.paginationPosition = -2;
|
|
36
|
-
dynamicMethodInfo.otherParams.push("pagination");
|
|
37
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethodInfo.keyToMapReplaced.replace("Paginated", "");
|
|
38
|
-
dynamicMethodInfo.argsCount++;
|
|
39
|
-
}
|
|
40
|
-
else if (dynamicMethodInfo.keyToMapReplaced.endsWith("Ordered")) {
|
|
41
|
-
dynamicMethodCustomization.orderPosition = -2;
|
|
42
|
-
dynamicMethodInfo.otherParams.push("order");
|
|
43
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethodInfo.keyToMapReplaced.replace("Ordered", "");
|
|
44
|
-
dynamicMethodInfo.argsCount++;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (!dynamicMethodInfo.ignoreDistinct) {
|
|
48
|
-
const keySplitedDistinct = dynamicMethodInfo.keyToMapReplaced.split("Distinct");
|
|
49
|
-
if (keySplitedDistinct[1]) {
|
|
50
|
-
dynamicMethodCustomization.distinctKeys = keySplitedDistinct[1]
|
|
51
|
-
.split("And")
|
|
52
|
-
.map(uncapitalize_util_1.uncapitalize);
|
|
53
|
-
}
|
|
54
|
-
dynamicMethodInfo.keyToMapReplaced = keySplitedDistinct[0];
|
|
55
|
-
}
|
|
56
|
-
return dynamicMethodCustomization;
|
|
57
|
-
}
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveDynamicMethodInfo = resolveDynamicMethodInfo;
|
|
4
|
-
const vs_repo_error_1 = require("../errors/vs-repo.error");
|
|
5
|
-
function resolveDynamicMethodInfo(instance, dynamicMethod, originalKey) {
|
|
6
|
-
const dynamicMethodInfo = {
|
|
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 (dynamicMethod === "aggregate") {
|
|
21
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("aggregate", "");
|
|
22
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
23
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
24
|
-
dynamicMethodInfo.method = "aggregate";
|
|
25
|
-
dynamicMethodInfo.prismaArgsIndex = 0;
|
|
26
|
-
dynamicMethodInfo.otherParams.push("prismaArgs");
|
|
27
|
-
dynamicMethodInfo.argsCount++;
|
|
28
|
-
}
|
|
29
|
-
else if (dynamicMethod === "groupBy") {
|
|
30
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("groupBy", "");
|
|
31
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
32
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
33
|
-
dynamicMethodInfo.method = "groupBy";
|
|
34
|
-
dynamicMethodInfo.prismaArgsIndex = 0;
|
|
35
|
-
dynamicMethodInfo.otherParams.push("prismaArgs");
|
|
36
|
-
dynamicMethodInfo.argsCount++;
|
|
37
|
-
}
|
|
38
|
-
else if (dynamicMethod.startsWith("findUniqueOrThrowBy")) {
|
|
39
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findUniqueOrThrowBy", "");
|
|
40
|
-
dynamicMethodInfo.method = "findUniqueOrThrow";
|
|
41
|
-
}
|
|
42
|
-
else if (dynamicMethod.startsWith("findUniqueBy")) {
|
|
43
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findUniqueBy", "");
|
|
44
|
-
dynamicMethodInfo.method = "findUnique";
|
|
45
|
-
}
|
|
46
|
-
else if (dynamicMethod.startsWith("findFirstOrThrowBy")) {
|
|
47
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findFirstOrThrowBy", "");
|
|
48
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
49
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
50
|
-
dynamicMethodInfo.method = "findFirstOrThrow";
|
|
51
|
-
}
|
|
52
|
-
else if (dynamicMethod.startsWith("findFirstOrThrow")) {
|
|
53
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findFirstOrThrow", "");
|
|
54
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
55
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
56
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
57
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
58
|
-
dynamicMethodInfo.method = "findFirstOrThrow";
|
|
59
|
-
}
|
|
60
|
-
else if (dynamicMethod.startsWith("findFirstBy")) {
|
|
61
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findFirstBy", "");
|
|
62
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
63
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
64
|
-
dynamicMethodInfo.method = "findFirst";
|
|
65
|
-
}
|
|
66
|
-
else if (dynamicMethod.startsWith("findFirst")) {
|
|
67
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findFirst", "");
|
|
68
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
69
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
70
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
71
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
72
|
-
dynamicMethodInfo.method = "findFirst";
|
|
73
|
-
}
|
|
74
|
-
else if (dynamicMethod.startsWith("countBy")) {
|
|
75
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("countBy", "");
|
|
76
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
77
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
78
|
-
dynamicMethodInfo.method = "count";
|
|
79
|
-
}
|
|
80
|
-
else if (dynamicMethod.startsWith("countWhere")) {
|
|
81
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("countWhere", "");
|
|
82
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
83
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
84
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
85
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
86
|
-
dynamicMethodInfo.method = "count";
|
|
87
|
-
dynamicMethodInfo.whereIndex = 0;
|
|
88
|
-
dynamicMethodInfo.otherParams.push("where");
|
|
89
|
-
dynamicMethodInfo.argsCount += 1;
|
|
90
|
-
}
|
|
91
|
-
else if (dynamicMethod.startsWith("count")) {
|
|
92
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("count", "");
|
|
93
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
94
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
95
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
96
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
97
|
-
dynamicMethodInfo.method = "count";
|
|
98
|
-
}
|
|
99
|
-
else if (dynamicMethod.startsWith("existsBy")) {
|
|
100
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("existsBy", "");
|
|
101
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
102
|
-
dynamicMethodInfo.existsMode = true;
|
|
103
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
104
|
-
dynamicMethodInfo.method = "findFirst";
|
|
105
|
-
}
|
|
106
|
-
else if (dynamicMethod.startsWith("existsWhere")) {
|
|
107
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("existsWhere", "");
|
|
108
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
109
|
-
dynamicMethodInfo.existsMode = true;
|
|
110
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
111
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
112
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
113
|
-
dynamicMethodInfo.method = "findFirst";
|
|
114
|
-
dynamicMethodInfo.whereIndex = 0;
|
|
115
|
-
dynamicMethodInfo.otherParams.push("where");
|
|
116
|
-
dynamicMethodInfo.argsCount += 1;
|
|
117
|
-
}
|
|
118
|
-
else if (dynamicMethod.startsWith("findManyBy")) {
|
|
119
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findManyBy", "");
|
|
120
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
121
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
122
|
-
dynamicMethodInfo.method = "findMany";
|
|
123
|
-
}
|
|
124
|
-
else if (dynamicMethod.startsWith("findMany")) {
|
|
125
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findMany", "");
|
|
126
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
127
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
128
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
129
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
130
|
-
dynamicMethodInfo.method = "findMany";
|
|
131
|
-
}
|
|
132
|
-
else if (dynamicMethod.startsWith("createManyAndReturn")) {
|
|
133
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("createManyAndReturn", "");
|
|
134
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
135
|
-
dynamicMethodInfo.ignoreSkipDuplicates = false;
|
|
136
|
-
dynamicMethodInfo.method = "createManyAndReturn";
|
|
137
|
-
dynamicMethodInfo.dataIndex = 0;
|
|
138
|
-
dynamicMethodInfo.otherParams.push("data");
|
|
139
|
-
dynamicMethodInfo.argsCount++;
|
|
140
|
-
}
|
|
141
|
-
else if (dynamicMethod.startsWith("createMany")) {
|
|
142
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("createMany", "");
|
|
143
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
144
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
145
|
-
dynamicMethodInfo.ignoreSkipDuplicates = false;
|
|
146
|
-
dynamicMethodInfo.method = "createMany";
|
|
147
|
-
dynamicMethodInfo.dataIndex = 0;
|
|
148
|
-
dynamicMethodInfo.otherParams.push("data");
|
|
149
|
-
dynamicMethodInfo.argsCount++;
|
|
150
|
-
}
|
|
151
|
-
else if (dynamicMethod.startsWith("create")) {
|
|
152
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("create", "");
|
|
153
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
154
|
-
dynamicMethodInfo.method = "create";
|
|
155
|
-
dynamicMethodInfo.dataIndex = 0;
|
|
156
|
-
dynamicMethodInfo.otherParams.push("data");
|
|
157
|
-
dynamicMethodInfo.argsCount++;
|
|
158
|
-
}
|
|
159
|
-
else if (dynamicMethod.startsWith("updateManyAndReturnBy")) {
|
|
160
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("updateManyAndReturnBy", "");
|
|
161
|
-
dynamicMethodInfo.method = "updateManyAndReturn";
|
|
162
|
-
dynamicMethodInfo.dataIndex = -2;
|
|
163
|
-
dynamicMethodInfo.otherParams.push("data");
|
|
164
|
-
dynamicMethodInfo.argsCount++;
|
|
165
|
-
}
|
|
166
|
-
else if (dynamicMethod.startsWith("updateManyAndReturnWhere")) {
|
|
167
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("updateManyAndReturnWhere", "");
|
|
168
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
169
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
170
|
-
dynamicMethodInfo.method = "updateManyAndReturn";
|
|
171
|
-
dynamicMethodInfo.dataIndex = -2;
|
|
172
|
-
dynamicMethodInfo.whereIndex = 0;
|
|
173
|
-
dynamicMethodInfo.otherParams.push("where", "data");
|
|
174
|
-
dynamicMethodInfo.argsCount += 2;
|
|
175
|
-
}
|
|
176
|
-
else if (dynamicMethod.startsWith("updateManyBy")) {
|
|
177
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("updateManyBy", "");
|
|
178
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
179
|
-
dynamicMethodInfo.method = "updateMany";
|
|
180
|
-
dynamicMethodInfo.dataIndex = -2;
|
|
181
|
-
dynamicMethodInfo.otherParams.push("data");
|
|
182
|
-
dynamicMethodInfo.argsCount++;
|
|
183
|
-
}
|
|
184
|
-
else if (dynamicMethod.startsWith("updateManyWhere")) {
|
|
185
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("updateManyWhere", "");
|
|
186
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
187
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
188
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
189
|
-
dynamicMethodInfo.method = "updateMany";
|
|
190
|
-
dynamicMethodInfo.dataIndex = -2;
|
|
191
|
-
dynamicMethodInfo.whereIndex = 0;
|
|
192
|
-
dynamicMethodInfo.otherParams.push("where", "data");
|
|
193
|
-
dynamicMethodInfo.argsCount += 2;
|
|
194
|
-
}
|
|
195
|
-
else if (dynamicMethod.startsWith("updateBy")) {
|
|
196
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("updateBy", "");
|
|
197
|
-
dynamicMethodInfo.method = "update";
|
|
198
|
-
dynamicMethodInfo.dataIndex = -2;
|
|
199
|
-
dynamicMethodInfo.otherParams.push("data");
|
|
200
|
-
dynamicMethodInfo.argsCount++;
|
|
201
|
-
}
|
|
202
|
-
else if (dynamicMethod.startsWith("upsertBy")) {
|
|
203
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("upsertBy", "");
|
|
204
|
-
dynamicMethodInfo.method = "upsert";
|
|
205
|
-
dynamicMethodInfo.createIndex = -2;
|
|
206
|
-
dynamicMethodInfo.updateIndex = -3;
|
|
207
|
-
dynamicMethodInfo.otherParams.push("update");
|
|
208
|
-
dynamicMethodInfo.otherParams.push("create");
|
|
209
|
-
dynamicMethodInfo.argsCount += 2;
|
|
210
|
-
}
|
|
211
|
-
else if (dynamicMethod.startsWith("deleteManyBy")) {
|
|
212
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("deleteManyBy", "");
|
|
213
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
214
|
-
dynamicMethodInfo.method = "deleteMany";
|
|
215
|
-
}
|
|
216
|
-
else if (dynamicMethod.startsWith("deleteManyWhere")) {
|
|
217
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("deleteManyWhere", "");
|
|
218
|
-
dynamicMethodInfo.ignoreSelect = true;
|
|
219
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
220
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
221
|
-
dynamicMethodInfo.method = "deleteMany";
|
|
222
|
-
dynamicMethodInfo.whereIndex = 0;
|
|
223
|
-
dynamicMethodInfo.otherParams.push("where");
|
|
224
|
-
dynamicMethodInfo.argsCount += 1;
|
|
225
|
-
}
|
|
226
|
-
else if (dynamicMethod.startsWith("deleteBy")) {
|
|
227
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("deleteBy", "");
|
|
228
|
-
dynamicMethodInfo.method = "delete";
|
|
229
|
-
}
|
|
230
|
-
else if (dynamicMethod.startsWith("findWhere")) {
|
|
231
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findWhere", "");
|
|
232
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
233
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
234
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
235
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
236
|
-
dynamicMethodInfo.method = "findFirst";
|
|
237
|
-
dynamicMethodInfo.whereIndex = 0;
|
|
238
|
-
dynamicMethodInfo.otherParams.push("where");
|
|
239
|
-
dynamicMethodInfo.argsCount += 1;
|
|
240
|
-
}
|
|
241
|
-
else if (dynamicMethod.startsWith("findOneWhere")) {
|
|
242
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findOneWhere", "");
|
|
243
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
244
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
245
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
246
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
247
|
-
dynamicMethodInfo.method = "findFirst";
|
|
248
|
-
dynamicMethodInfo.whereIndex = 0;
|
|
249
|
-
dynamicMethodInfo.otherParams.push("where");
|
|
250
|
-
dynamicMethodInfo.argsCount += 1;
|
|
251
|
-
}
|
|
252
|
-
else if (dynamicMethod.startsWith("findListWhere")) {
|
|
253
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findListWhere", "");
|
|
254
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
255
|
-
dynamicMethodInfo.ignoreWhere = true;
|
|
256
|
-
dynamicMethodInfo.onlyBaseWheres = true;
|
|
257
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
258
|
-
dynamicMethodInfo.method = "findMany";
|
|
259
|
-
dynamicMethodInfo.whereIndex = 0;
|
|
260
|
-
dynamicMethodInfo.otherParams.push("where");
|
|
261
|
-
dynamicMethodInfo.argsCount += 1;
|
|
262
|
-
}
|
|
263
|
-
else if (dynamicMethod.startsWith("findOneBy")) {
|
|
264
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findOneBy", "");
|
|
265
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
266
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
267
|
-
dynamicMethodInfo.method = "findFirst";
|
|
268
|
-
}
|
|
269
|
-
else if (dynamicMethod.startsWith("findBy")) {
|
|
270
|
-
dynamicMethodInfo.keyToMapReplaced = dynamicMethod.replace("findBy", "");
|
|
271
|
-
dynamicMethodInfo.ignoreOrderByAndPagination = false;
|
|
272
|
-
dynamicMethodInfo.ignoreDistinct = false;
|
|
273
|
-
dynamicMethodInfo.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: ${dynamicMethod}.`);
|
|
277
|
-
}
|
|
278
|
-
return dynamicMethodInfo;
|
|
279
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveDynamicMethodsMetadata = resolveDynamicMethodsMetadata;
|
|
4
|
-
const dynamic_methods_key_constant_1 = require("../constants/dynamic-methods-key.constant");
|
|
5
|
-
function resolveDynamicMethodsMetadata(prototype) {
|
|
6
|
-
const methods = Reflect.getMetadata(dynamic_methods_key_constant_1.DYNAMIC_METHODS_KEY, prototype);
|
|
7
|
-
const methodsRecord = {};
|
|
8
|
-
if (!methods)
|
|
9
|
-
return methodsRecord;
|
|
10
|
-
for (const method of methods) {
|
|
11
|
-
const { propertyKey, ...rest } = method;
|
|
12
|
-
methodsRecord[propertyKey] = rest;
|
|
13
|
-
}
|
|
14
|
-
return methodsRecord;
|
|
15
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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.resolveMergeWheres = resolveMergeWheres;
|
|
7
|
-
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
8
|
-
function resolveMergeWheres(config, provided, pushed, required, softRemovekName) {
|
|
9
|
-
const objectsToMerge = [];
|
|
10
|
-
if (provided)
|
|
11
|
-
objectsToMerge.push(provided);
|
|
12
|
-
if (pushed)
|
|
13
|
-
objectsToMerge.push(pushed);
|
|
14
|
-
if (required && config.respectRequired)
|
|
15
|
-
objectsToMerge.push(required);
|
|
16
|
-
if (softRemovekName && config.see !== "all")
|
|
17
|
-
objectsToMerge.push({ [softRemovekName]: config.see === "active" ? null : { not: null } });
|
|
18
|
-
const whereResolved = deepmerge_1.default.all(objectsToMerge, {
|
|
19
|
-
arrayMerge: (target, source) => source.concat(target),
|
|
20
|
-
});
|
|
21
|
-
return whereResolved;
|
|
22
|
-
}
|