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,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePrettyWheres = resolvePrettyWheres;
|
|
4
|
-
const ugly_where_resolve_1 = require("./ugly-where.resolve");
|
|
5
|
-
function resolvePrettyWheres(dynamicMethodInfo, dynamicMethodWhereOps) {
|
|
6
|
-
let ANDMode = false;
|
|
7
|
-
let keysSplitedAND = dynamicMethodInfo.keyToMapReplaced.split("AND");
|
|
8
|
-
if (keysSplitedAND.length > 1) {
|
|
9
|
-
ANDMode = true;
|
|
10
|
-
}
|
|
11
|
-
keysSplitedAND.forEach((keySplitedAND, idx) => {
|
|
12
|
-
let orMode = false;
|
|
13
|
-
let keysSplitedOr = idx === 0 ? keySplitedAND.split("Or") : [keySplitedAND];
|
|
14
|
-
if (keysSplitedOr.length > 1) {
|
|
15
|
-
orMode = true;
|
|
16
|
-
}
|
|
17
|
-
for (let i = 0; i < keysSplitedOr.length; i++) {
|
|
18
|
-
if (keysSplitedOr[i] === "")
|
|
19
|
-
continue;
|
|
20
|
-
const keysSplitedAnd = keysSplitedOr[i].split("And");
|
|
21
|
-
for (const keySplitedAnd of keysSplitedAnd) {
|
|
22
|
-
if (keySplitedAnd === "")
|
|
23
|
-
continue;
|
|
24
|
-
const uglyWhere = (0, ugly_where_resolve_1.resolveUglyWhere)(keySplitedAnd);
|
|
25
|
-
if (!orMode) {
|
|
26
|
-
if (idx === 1 && ANDMode) {
|
|
27
|
-
uglyWhere.name = `AND.${i}idx.${uglyWhere.name}`;
|
|
28
|
-
}
|
|
29
|
-
dynamicMethodWhereOps.uglyWheres.push(uglyWhere);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
uglyWhere.name = `OR.${i}idx.${uglyWhere.name}`;
|
|
33
|
-
dynamicMethodWhereOps.uglyWheres.push(uglyWhere);
|
|
34
|
-
}
|
|
35
|
-
if (uglyWhere.autoInjectVal === undefined)
|
|
36
|
-
dynamicMethodInfo.argsCount++;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
const prettyWheres = dynamicMethodWhereOps.uglyWheres.map(arg => {
|
|
41
|
-
let context = [];
|
|
42
|
-
let otherProps = undefined;
|
|
43
|
-
let argName = arg.name;
|
|
44
|
-
const agrNameSplitedOr = argName.split("OR.");
|
|
45
|
-
if (agrNameSplitedOr.length > 1) {
|
|
46
|
-
const agrNameSplitedOrIdx = agrNameSplitedOr[1].split("idx.");
|
|
47
|
-
context.push("OR");
|
|
48
|
-
context.push(Number(agrNameSplitedOrIdx[0]));
|
|
49
|
-
argName = agrNameSplitedOrIdx[1];
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const agrNameSplitedAND = argName.split("AND.");
|
|
53
|
-
if (agrNameSplitedAND.length > 1) {
|
|
54
|
-
const agrNameSplitedANDIdx = agrNameSplitedAND[1].split("idx.");
|
|
55
|
-
context.push("AND");
|
|
56
|
-
context.push(Number(agrNameSplitedANDIdx[0]));
|
|
57
|
-
argName = agrNameSplitedANDIdx[1];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
context.push(argName);
|
|
61
|
-
if (arg.pushProperty !== "$$$") {
|
|
62
|
-
const pushProperty = arg.pushProperty;
|
|
63
|
-
const pushPropertySplitedDot = pushProperty.split(".");
|
|
64
|
-
pushPropertySplitedDot.forEach(prop => context.push(prop));
|
|
65
|
-
}
|
|
66
|
-
if (arg.properties !== undefined) {
|
|
67
|
-
const propertiesKeys = Object.keys(arg.properties);
|
|
68
|
-
otherProps = {};
|
|
69
|
-
for (let i = 0; i < propertiesKeys.length; i++) {
|
|
70
|
-
const key = propertiesKeys[i];
|
|
71
|
-
otherProps[key] = arg.properties[key];
|
|
72
|
-
}
|
|
73
|
-
if (arg.pushProperty === "$$$") {
|
|
74
|
-
context.push("equals");
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
dynamicMethodInfo.whereParams.push(argName);
|
|
78
|
-
return {
|
|
79
|
-
context,
|
|
80
|
-
otherProps,
|
|
81
|
-
argName,
|
|
82
|
-
autoVal: arg.autoInjectVal,
|
|
83
|
-
betweenMode: arg.betweenMode,
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
dynamicMethodWhereOps.prettyWheres = prettyWheres;
|
|
87
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveSelect = resolveSelect;
|
|
4
|
-
function resolveSelect(instance, provided, pushed) {
|
|
5
|
-
const selectModelKey = provided ?? pushed ?? instance.defaultSelectModel;
|
|
6
|
-
return selectModelKey ? instance.selectModels?.[selectModelKey] : undefined;
|
|
7
|
-
}
|
|
@@ -1,84 +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.resolveSpecificWhere = resolveSpecificWhere;
|
|
7
|
-
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
8
|
-
function resolveSpecificWhere(args, prettyWheres) {
|
|
9
|
-
let specificWhere = {};
|
|
10
|
-
let OR;
|
|
11
|
-
let AND;
|
|
12
|
-
let adjust = 0;
|
|
13
|
-
for (let j = 0; j < prettyWheres.length; j++) {
|
|
14
|
-
let path = {};
|
|
15
|
-
let current = path;
|
|
16
|
-
let ormode = false;
|
|
17
|
-
let andmode = false;
|
|
18
|
-
let modeIdx;
|
|
19
|
-
const currentWhereRslvd = prettyWheres[j];
|
|
20
|
-
const context = currentWhereRslvd.context;
|
|
21
|
-
const contextLength = context.length;
|
|
22
|
-
const contextLengthM1 = contextLength - 1;
|
|
23
|
-
for (let i = 0; i < contextLength; i++) {
|
|
24
|
-
if (i < contextLengthM1) {
|
|
25
|
-
if (context[i] === "OR") {
|
|
26
|
-
ormode = true;
|
|
27
|
-
}
|
|
28
|
-
else if (context[i] === "AND") {
|
|
29
|
-
andmode = true;
|
|
30
|
-
}
|
|
31
|
-
else if (typeof context[i] === "number") {
|
|
32
|
-
modeIdx = context[i];
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
if (!current[context[i]])
|
|
36
|
-
current[context[i]] = {};
|
|
37
|
-
current = current[context[i]];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
if (currentWhereRslvd.autoVal !== undefined) {
|
|
42
|
-
current[context[i]] = currentWhereRslvd.autoVal;
|
|
43
|
-
adjust++;
|
|
44
|
-
}
|
|
45
|
-
else if (currentWhereRslvd.betweenMode && args[j - adjust] !== undefined) {
|
|
46
|
-
current[context[i]] = {};
|
|
47
|
-
current[context[i]]["gte"] = args[j - adjust][0];
|
|
48
|
-
current[context[i]]["lte"] = args[j - adjust][1];
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
current[context[i]] = args[j - adjust];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (currentWhereRslvd.otherProps !== undefined) {
|
|
56
|
-
Object.assign(current, currentWhereRslvd.otherProps);
|
|
57
|
-
}
|
|
58
|
-
if (ormode) {
|
|
59
|
-
if (!OR)
|
|
60
|
-
OR = [];
|
|
61
|
-
if (!OR[modeIdx])
|
|
62
|
-
OR[modeIdx] = {};
|
|
63
|
-
OR[modeIdx] = (0, deepmerge_1.default)(OR[modeIdx], path);
|
|
64
|
-
// Object.assign(OR[modeIdx!], path);
|
|
65
|
-
}
|
|
66
|
-
else if (andmode) {
|
|
67
|
-
if (!AND)
|
|
68
|
-
AND = [];
|
|
69
|
-
if (!AND[modeIdx])
|
|
70
|
-
AND[modeIdx] = {};
|
|
71
|
-
AND[modeIdx] = (0, deepmerge_1.default)(AND[modeIdx], path);
|
|
72
|
-
// Object.assign(AND[modeIdx!], path);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
specificWhere = (0, deepmerge_1.default)(specificWhere, path);
|
|
76
|
-
// Object.assign(specificWhere, path);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (OR)
|
|
80
|
-
specificWhere.OR = OR.filter(x => x !== undefined);
|
|
81
|
-
if (AND)
|
|
82
|
-
specificWhere.AND = AND.filter(x => x !== undefined);
|
|
83
|
-
return specificWhere;
|
|
84
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveUglyWhere = resolveUglyWhere;
|
|
4
|
-
const uncapitalize_util_1 = require("../utils/uncapitalize.util");
|
|
5
|
-
function resolveUglyWhere(keySplitedAnd) {
|
|
6
|
-
const uglyWhere = { name: "", pushProperty: "$$$" };
|
|
7
|
-
let nullMode = undefined;
|
|
8
|
-
if (keySplitedAnd.includes("IsNull")) {
|
|
9
|
-
uglyWhere.pushProperty = "$$$";
|
|
10
|
-
uglyWhere.autoInjectVal = null;
|
|
11
|
-
nullMode = "is";
|
|
12
|
-
keySplitedAnd = keySplitedAnd.replace("IsNull", "");
|
|
13
|
-
}
|
|
14
|
-
else if (keySplitedAnd.includes("IsNotNull")) {
|
|
15
|
-
uglyWhere.pushProperty = "not";
|
|
16
|
-
uglyWhere.autoInjectVal = null;
|
|
17
|
-
nullMode = "not";
|
|
18
|
-
keySplitedAnd = keySplitedAnd.replace("IsNotNull", "");
|
|
19
|
-
}
|
|
20
|
-
else if (keySplitedAnd.includes("IsTrue")) {
|
|
21
|
-
uglyWhere.pushProperty = "$$$";
|
|
22
|
-
uglyWhere.autoInjectVal = true;
|
|
23
|
-
keySplitedAnd = keySplitedAnd.replace("IsTrue", "");
|
|
24
|
-
}
|
|
25
|
-
else if (keySplitedAnd.includes("IsFalse")) {
|
|
26
|
-
uglyWhere.pushProperty = "$$$";
|
|
27
|
-
uglyWhere.autoInjectVal = false;
|
|
28
|
-
keySplitedAnd = keySplitedAnd.replace("IsFalse", "");
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
if (keySplitedAnd.includes("Insensitive")) {
|
|
32
|
-
uglyWhere.properties = {};
|
|
33
|
-
uglyWhere.properties.mode = "insensitive";
|
|
34
|
-
keySplitedAnd = keySplitedAnd.replace("Insensitive", "");
|
|
35
|
-
}
|
|
36
|
-
if (keySplitedAnd.includes("Optional")) {
|
|
37
|
-
keySplitedAnd = keySplitedAnd.replace("Optional", "");
|
|
38
|
-
}
|
|
39
|
-
if (keySplitedAnd.includes("NotBetween")) {
|
|
40
|
-
uglyWhere.pushProperty = "not";
|
|
41
|
-
uglyWhere.betweenMode = true;
|
|
42
|
-
keySplitedAnd = keySplitedAnd.replace("NotBetween", "");
|
|
43
|
-
}
|
|
44
|
-
else if (keySplitedAnd.includes("Between")) {
|
|
45
|
-
uglyWhere.pushProperty = "$$$";
|
|
46
|
-
uglyWhere.betweenMode = true;
|
|
47
|
-
keySplitedAnd = keySplitedAnd.replace("Between", "");
|
|
48
|
-
}
|
|
49
|
-
else if (keySplitedAnd.includes("NotStartsWith")) {
|
|
50
|
-
uglyWhere.pushProperty = "not.startsWith";
|
|
51
|
-
keySplitedAnd = keySplitedAnd.replace("NotStartsWith", "");
|
|
52
|
-
}
|
|
53
|
-
else if (keySplitedAnd.includes("StartsWith")) {
|
|
54
|
-
uglyWhere.pushProperty = "startsWith";
|
|
55
|
-
keySplitedAnd = keySplitedAnd.replace("StartsWith", "");
|
|
56
|
-
}
|
|
57
|
-
else if (keySplitedAnd.includes("NotEndsWith")) {
|
|
58
|
-
uglyWhere.pushProperty = "not.endsWith";
|
|
59
|
-
keySplitedAnd = keySplitedAnd.replace("NotEndsWith", "");
|
|
60
|
-
}
|
|
61
|
-
else if (keySplitedAnd.includes("EndsWith")) {
|
|
62
|
-
uglyWhere.pushProperty = "endsWith";
|
|
63
|
-
keySplitedAnd = keySplitedAnd.replace("EndsWith", "");
|
|
64
|
-
}
|
|
65
|
-
else if (keySplitedAnd.includes("NotContains")) {
|
|
66
|
-
uglyWhere.pushProperty = "not.contains";
|
|
67
|
-
keySplitedAnd = keySplitedAnd.replace("NotContains", "");
|
|
68
|
-
}
|
|
69
|
-
else if (keySplitedAnd.includes("Contains")) {
|
|
70
|
-
uglyWhere.pushProperty = "contains";
|
|
71
|
-
keySplitedAnd = keySplitedAnd.replace("Contains", "");
|
|
72
|
-
}
|
|
73
|
-
else if (keySplitedAnd.includes("LessThanEqual")) {
|
|
74
|
-
uglyWhere.pushProperty = "lte";
|
|
75
|
-
keySplitedAnd = keySplitedAnd.replace("LessThanEqual", "");
|
|
76
|
-
}
|
|
77
|
-
else if (keySplitedAnd.includes("LessThan")) {
|
|
78
|
-
uglyWhere.pushProperty = "lt";
|
|
79
|
-
keySplitedAnd = keySplitedAnd.replace("LessThan", "");
|
|
80
|
-
}
|
|
81
|
-
else if (keySplitedAnd.includes("GreaterThanEqual")) {
|
|
82
|
-
uglyWhere.pushProperty = "gte";
|
|
83
|
-
keySplitedAnd = keySplitedAnd.replace("GreaterThanEqual", "");
|
|
84
|
-
}
|
|
85
|
-
else if (keySplitedAnd.includes("GreaterThan")) {
|
|
86
|
-
uglyWhere.pushProperty = "gt";
|
|
87
|
-
keySplitedAnd = keySplitedAnd.replace("GreaterThan", "");
|
|
88
|
-
}
|
|
89
|
-
else if (keySplitedAnd.includes("NotIn")) {
|
|
90
|
-
uglyWhere.pushProperty = "notIn";
|
|
91
|
-
keySplitedAnd = keySplitedAnd.replace("NotIn", "");
|
|
92
|
-
}
|
|
93
|
-
else if (keySplitedAnd.includes("In")) {
|
|
94
|
-
uglyWhere.pushProperty = "in";
|
|
95
|
-
keySplitedAnd = keySplitedAnd.replace("In", "");
|
|
96
|
-
}
|
|
97
|
-
else if (keySplitedAnd.includes("Not")) {
|
|
98
|
-
uglyWhere.pushProperty = "not";
|
|
99
|
-
keySplitedAnd = keySplitedAnd.replace("Not", "");
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
uglyWhere.pushProperty = "$$$";
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (keySplitedAnd.includes("Without")) {
|
|
106
|
-
const keySplitedConector = keySplitedAnd.split("Without");
|
|
107
|
-
const specificField = keySplitedConector[1];
|
|
108
|
-
if (!specificField) {
|
|
109
|
-
if (nullMode) {
|
|
110
|
-
uglyWhere.pushProperty = nullMode === "not" ? "is" : "isNot";
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
uglyWhere.pushProperty = "isNot";
|
|
114
|
-
uglyWhere.autoInjectVal = {};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
uglyWhere.pushProperty = `isNot.${(0, uncapitalize_util_1.uncapitalize)(specificField)}${uglyWhere.pushProperty === "$$$" ? "" : `.${uglyWhere.pushProperty}`}`;
|
|
119
|
-
}
|
|
120
|
-
keySplitedAnd = keySplitedConector[0];
|
|
121
|
-
}
|
|
122
|
-
else if (keySplitedAnd.includes("With")) {
|
|
123
|
-
const keySplitedConector = keySplitedAnd.split("With");
|
|
124
|
-
const specificField = keySplitedConector[1];
|
|
125
|
-
if (!specificField) {
|
|
126
|
-
if (nullMode) {
|
|
127
|
-
uglyWhere.pushProperty = nullMode === "not" ? "isNot" : "is";
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
uglyWhere.pushProperty = "is";
|
|
131
|
-
uglyWhere.autoInjectVal = {};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
uglyWhere.pushProperty = `is.${(0, uncapitalize_util_1.uncapitalize)(specificField)}${uglyWhere.pushProperty === "$$$" ? "" : `.${uglyWhere.pushProperty}`}`;
|
|
136
|
-
}
|
|
137
|
-
keySplitedAnd = keySplitedConector[0];
|
|
138
|
-
}
|
|
139
|
-
else if (keySplitedAnd.includes("Some")) {
|
|
140
|
-
const keySplitedConector = keySplitedAnd.split("Some");
|
|
141
|
-
const specificField = keySplitedConector[1];
|
|
142
|
-
if (!specificField) {
|
|
143
|
-
uglyWhere.pushProperty = "some";
|
|
144
|
-
uglyWhere.autoInjectVal = {};
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
uglyWhere.pushProperty = `some.${(0, uncapitalize_util_1.uncapitalize)(specificField)}${uglyWhere.pushProperty === "$$$" ? "" : `.${uglyWhere.pushProperty}`}`;
|
|
148
|
-
}
|
|
149
|
-
keySplitedAnd = keySplitedConector[0];
|
|
150
|
-
}
|
|
151
|
-
else if (keySplitedAnd.includes("Every")) {
|
|
152
|
-
const keySplitedConector = keySplitedAnd.split("Every");
|
|
153
|
-
const specificField = keySplitedConector[1];
|
|
154
|
-
if (!specificField) {
|
|
155
|
-
uglyWhere.pushProperty = "every";
|
|
156
|
-
uglyWhere.autoInjectVal = {};
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
uglyWhere.pushProperty = `every.${(0, uncapitalize_util_1.uncapitalize)(specificField)}${uglyWhere.pushProperty === "$$$" ? "" : `.${uglyWhere.pushProperty}`}`;
|
|
160
|
-
}
|
|
161
|
-
keySplitedAnd = keySplitedConector[0];
|
|
162
|
-
}
|
|
163
|
-
else if (keySplitedAnd.includes("None")) {
|
|
164
|
-
const keySplitedConector = keySplitedAnd.split("None");
|
|
165
|
-
const specificField = keySplitedConector[1];
|
|
166
|
-
if (!specificField) {
|
|
167
|
-
uglyWhere.pushProperty = "none";
|
|
168
|
-
uglyWhere.autoInjectVal = {};
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
uglyWhere.pushProperty = `none.${(0, uncapitalize_util_1.uncapitalize)(specificField)}${uglyWhere.pushProperty === "$$$" ? "" : `.${uglyWhere.pushProperty}`}`;
|
|
172
|
-
}
|
|
173
|
-
keySplitedAnd = keySplitedConector[0];
|
|
174
|
-
}
|
|
175
|
-
keySplitedAnd = (0, uncapitalize_util_1.uncapitalize)(keySplitedAnd);
|
|
176
|
-
uglyWhere.name = keySplitedAnd;
|
|
177
|
-
return uglyWhere;
|
|
178
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.logger = logger;
|
|
4
|
-
exports.performanceLoggerStart = performanceLoggerStart;
|
|
5
|
-
exports.performanceLoggerEnd = performanceLoggerEnd;
|
|
6
|
-
function logger(message, moment, tableName, obj) {
|
|
7
|
-
console.log(`\n[VSRepository] (${tableName ?? "unknown"}: ${moment}) ${message}`);
|
|
8
|
-
if (obj)
|
|
9
|
-
console.log(JSON.stringify(obj, null, 2));
|
|
10
|
-
}
|
|
11
|
-
function performanceLoggerStart(tableName, operation, prismaArgs) {
|
|
12
|
-
logger(`Executing ${operation}.`, "runtime", tableName);
|
|
13
|
-
if (prismaArgs)
|
|
14
|
-
logger(`Built arguments to ${operation}:`, "runtime", tableName, prismaArgs);
|
|
15
|
-
return performance.now();
|
|
16
|
-
}
|
|
17
|
-
function performanceLoggerEnd(tableName, operation, start) {
|
|
18
|
-
const end = performance.now();
|
|
19
|
-
const duration = (end - start).toFixed(2);
|
|
20
|
-
logger(`Executed ${operation} (took: ${duration}ms).`, "runtime", tableName);
|
|
21
|
-
}
|
|
@@ -1,31 +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.methodSchema = exports.queryOptionsSchema = exports.booleanSchema = exports.objectSchema = exports.stringSchema = void 0;
|
|
7
|
-
const zod_1 = __importDefault(require("zod"));
|
|
8
|
-
exports.stringSchema = zod_1.default.string().trim().nonempty();
|
|
9
|
-
exports.objectSchema = zod_1.default.looseObject({});
|
|
10
|
-
exports.booleanSchema = zod_1.default.boolean();
|
|
11
|
-
exports.queryOptionsSchema = zod_1.default.strictObject({
|
|
12
|
-
value: exports.stringSchema,
|
|
13
|
-
modifying: exports.booleanSchema.default(false),
|
|
14
|
-
});
|
|
15
|
-
exports.methodSchema = zod_1.default
|
|
16
|
-
.strictObject({
|
|
17
|
-
map: exports.booleanSchema,
|
|
18
|
-
selectModel: exports.stringSchema.or(zod_1.default.literal(false)).optional(),
|
|
19
|
-
whereType: zod_1.default.enum(["overwrite", "extending"]).optional(),
|
|
20
|
-
proxyTo: exports.stringSchema.optional(),
|
|
21
|
-
pushWhere: exports.objectSchema.optional(),
|
|
22
|
-
fbMode: zod_1.default.enum(["one", "list"]).optional(),
|
|
23
|
-
injectOrdenation: exports.objectSchema.or(zod_1.default.array(exports.objectSchema)).optional(),
|
|
24
|
-
injectOrdering: exports.objectSchema.or(zod_1.default.array(exports.objectSchema)).optional(),
|
|
25
|
-
injectPagination: exports.objectSchema.optional(),
|
|
26
|
-
query: exports.queryOptionsSchema.optional(),
|
|
27
|
-
})
|
|
28
|
-
.transform(({ injectOrdenation, injectOrdering, ...value }) => ({
|
|
29
|
-
...value,
|
|
30
|
-
injectOrdering: injectOrdering ?? injectOrdenation,
|
|
31
|
-
}));
|
|
@@ -1,84 +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.validateBuildConfig = validateBuildConfig;
|
|
7
|
-
const zod_1 = __importDefault(require("zod"));
|
|
8
|
-
const schemas_util_1 = require("../utils/schemas.util");
|
|
9
|
-
const vs_repo_error_1 = require("../errors/vs-repo.error");
|
|
10
|
-
const defaultBaseMethodConfig = {
|
|
11
|
-
active: true,
|
|
12
|
-
ignoreRequiredWhere: false,
|
|
13
|
-
};
|
|
14
|
-
const defaultBaseMethods = {
|
|
15
|
-
get: defaultBaseMethodConfig,
|
|
16
|
-
getOrThrow: defaultBaseMethodConfig,
|
|
17
|
-
getAll: defaultBaseMethodConfig,
|
|
18
|
-
remove: defaultBaseMethodConfig,
|
|
19
|
-
save: defaultBaseMethodConfig,
|
|
20
|
-
patch: defaultBaseMethodConfig,
|
|
21
|
-
removeList: defaultBaseMethodConfig,
|
|
22
|
-
total: defaultBaseMethodConfig,
|
|
23
|
-
has: defaultBaseMethodConfig,
|
|
24
|
-
merge: defaultBaseMethodConfig,
|
|
25
|
-
getList: defaultBaseMethodConfig,
|
|
26
|
-
saveList: defaultBaseMethodConfig,
|
|
27
|
-
softRemove: defaultBaseMethodConfig,
|
|
28
|
-
restore: defaultBaseMethodConfig,
|
|
29
|
-
softRemoveList: defaultBaseMethodConfig,
|
|
30
|
-
restoreList: defaultBaseMethodConfig,
|
|
31
|
-
patchList: defaultBaseMethodConfig,
|
|
32
|
-
};
|
|
33
|
-
function validateBuildConfig(config, buildInstance) {
|
|
34
|
-
const defaultSelectSchema = buildInstance.selectModels
|
|
35
|
-
? zod_1.default.enum(Object.keys(buildInstance.selectModels)).optional()
|
|
36
|
-
: zod_1.default.never("can only be passed if you have configured 'selectModels'.").optional();
|
|
37
|
-
const activeSchema = schemas_util_1.booleanSchema.default(true);
|
|
38
|
-
const ignoreRequiredWhereSchema = schemas_util_1.booleanSchema.default(false);
|
|
39
|
-
const baseMethodSchema = zod_1.default
|
|
40
|
-
.strictObject({
|
|
41
|
-
active: activeSchema,
|
|
42
|
-
ignoreRequiredWhere: ignoreRequiredWhereSchema,
|
|
43
|
-
})
|
|
44
|
-
.default(defaultBaseMethodConfig);
|
|
45
|
-
const baseMethodWithSelectSchema = zod_1.default
|
|
46
|
-
.strictObject({
|
|
47
|
-
active: activeSchema,
|
|
48
|
-
defaultSelect: defaultSelectSchema,
|
|
49
|
-
ignoreRequiredWhere: ignoreRequiredWhereSchema,
|
|
50
|
-
})
|
|
51
|
-
.default(defaultBaseMethodConfig);
|
|
52
|
-
const buildConfigSchema = zod_1.default.strictObject({
|
|
53
|
-
freeze: schemas_util_1.booleanSchema.default(true),
|
|
54
|
-
showWorking: schemas_util_1.booleanSchema.default(false),
|
|
55
|
-
baseMethods: zod_1.default
|
|
56
|
-
.strictObject({
|
|
57
|
-
get: baseMethodWithSelectSchema,
|
|
58
|
-
getOrThrow: baseMethodWithSelectSchema,
|
|
59
|
-
getAll: baseMethodWithSelectSchema,
|
|
60
|
-
remove: baseMethodWithSelectSchema,
|
|
61
|
-
save: baseMethodWithSelectSchema,
|
|
62
|
-
patch: baseMethodWithSelectSchema,
|
|
63
|
-
removeList: baseMethodSchema,
|
|
64
|
-
total: baseMethodSchema,
|
|
65
|
-
has: baseMethodSchema,
|
|
66
|
-
merge: baseMethodWithSelectSchema,
|
|
67
|
-
getList: baseMethodWithSelectSchema,
|
|
68
|
-
saveList: baseMethodWithSelectSchema,
|
|
69
|
-
softRemove: baseMethodWithSelectSchema,
|
|
70
|
-
restore: baseMethodWithSelectSchema,
|
|
71
|
-
softRemoveList: baseMethodWithSelectSchema,
|
|
72
|
-
restoreList: baseMethodWithSelectSchema,
|
|
73
|
-
patchList: baseMethodWithSelectSchema,
|
|
74
|
-
})
|
|
75
|
-
.default(defaultBaseMethods),
|
|
76
|
-
});
|
|
77
|
-
const buildConfigParsed = buildConfigSchema.safeParse(config);
|
|
78
|
-
if (!buildConfigParsed.success) {
|
|
79
|
-
const firstIssue = buildConfigParsed.error.issues[0];
|
|
80
|
-
const path = firstIssue?.path.length ? firstIssue.path.join(".") : "config";
|
|
81
|
-
throw new vs_repo_error_1.VSRepoBuildError(`[VSRepository] (${buildInstance.tableName}: build) ${path}: ${firstIssue?.message}`);
|
|
82
|
-
}
|
|
83
|
-
return buildConfigParsed.data;
|
|
84
|
-
}
|
|
@@ -1,64 +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.validateConstructorConfig = validateConstructorConfig;
|
|
7
|
-
const zod_1 = __importDefault(require("zod"));
|
|
8
|
-
const schemas_util_1 = require("../utils/schemas.util");
|
|
9
|
-
const vs_repo_error_1 = require("../errors/vs-repo.error");
|
|
10
|
-
function validateConstructorConfig(config) {
|
|
11
|
-
const configSchema = zod_1.default
|
|
12
|
-
.strictObject({
|
|
13
|
-
tableName: schemas_util_1.stringSchema,
|
|
14
|
-
pkName: schemas_util_1.stringSchema,
|
|
15
|
-
softRemovekName: schemas_util_1.stringSchema.optional(),
|
|
16
|
-
selectModels: zod_1.default.record(schemas_util_1.stringSchema, schemas_util_1.objectSchema).optional(),
|
|
17
|
-
includeModels: zod_1.default.record(schemas_util_1.stringSchema, schemas_util_1.objectSchema).optional(),
|
|
18
|
-
defaultSelectModel: schemas_util_1.stringSchema.optional(),
|
|
19
|
-
requiredWhere: schemas_util_1.objectSchema.optional(),
|
|
20
|
-
relations: zod_1.default
|
|
21
|
-
.record(schemas_util_1.stringSchema, zod_1.default.strictObject({
|
|
22
|
-
mode: zod_1.default.enum(["otm", "mtm", "mto", "oto"]),
|
|
23
|
-
restriction: zod_1.default.enum(["set", "add"]),
|
|
24
|
-
pk: schemas_util_1.stringSchema,
|
|
25
|
-
nullAble: schemas_util_1.booleanSchema.optional(),
|
|
26
|
-
nullable: schemas_util_1.booleanSchema.optional(),
|
|
27
|
-
}))
|
|
28
|
-
.optional(),
|
|
29
|
-
methods: zod_1.default.record(schemas_util_1.stringSchema, schemas_util_1.methodSchema).optional(),
|
|
30
|
-
defaultOrdenation: schemas_util_1.objectSchema.or(zod_1.default.array(schemas_util_1.objectSchema)).optional(),
|
|
31
|
-
defaultOrdering: schemas_util_1.objectSchema.or(zod_1.default.array(schemas_util_1.objectSchema)).optional(),
|
|
32
|
-
})
|
|
33
|
-
.superRefine((config, ctx) => {
|
|
34
|
-
if (config.defaultSelectModel && !config.selectModels?.[config.defaultSelectModel]) {
|
|
35
|
-
ctx.addIssue({
|
|
36
|
-
code: "custom",
|
|
37
|
-
path: ["defaultSelectModel"],
|
|
38
|
-
message: "must be a valid key of 'selectModels'",
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (config.methods) {
|
|
42
|
-
for (const [key, method] of Object.entries(config.methods)) {
|
|
43
|
-
if (method.selectModel && !config.selectModels?.[method.selectModel]) {
|
|
44
|
-
ctx.addIssue({
|
|
45
|
-
code: "custom",
|
|
46
|
-
path: ["methods", key, "selectModel"],
|
|
47
|
-
message: "must be a valid key of 'selectModels'",
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
.transform(({ defaultOrdenation, defaultOrdering, ...value }) => ({
|
|
54
|
-
...value,
|
|
55
|
-
defaultOrdering: defaultOrdering ?? defaultOrdenation,
|
|
56
|
-
}));
|
|
57
|
-
const configParsed = configSchema.safeParse(config);
|
|
58
|
-
if (!configParsed.success) {
|
|
59
|
-
const firstIssue = configParsed.error.issues[0];
|
|
60
|
-
const path = firstIssue?.path.length ? firstIssue.path.join(".") : "config";
|
|
61
|
-
throw new vs_repo_error_1.VSRepoConfigError(`[VSRepository] (unknown: config) ${path}: ${firstIssue?.message}`);
|
|
62
|
-
}
|
|
63
|
-
return configParsed.data;
|
|
64
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateDynamicMethodConfig = validateDynamicMethodConfig;
|
|
4
|
-
const vs_repo_error_1 = require("../errors/vs-repo.error");
|
|
5
|
-
const schemas_util_1 = require("../utils/schemas.util");
|
|
6
|
-
const is_object_validate_1 = require("./is-object.validate");
|
|
7
|
-
function validateDynamicMethodConfig(config) {
|
|
8
|
-
if (!(0, is_object_validate_1.isObject)(config)) {
|
|
9
|
-
throw new vs_repo_error_1.VSRepoDecoratorError(`[VSRepository] (unknown: decorator) 'config' must be a valid object`);
|
|
10
|
-
}
|
|
11
|
-
config["map"] = true;
|
|
12
|
-
const configParsed = schemas_util_1.methodSchema.safeParse(config);
|
|
13
|
-
if (!configParsed.success) {
|
|
14
|
-
const firstIssue = configParsed.error.issues[0];
|
|
15
|
-
const path = firstIssue?.path.length ? firstIssue.path.join(".") : "config";
|
|
16
|
-
throw new vs_repo_error_1.VSRepoDecoratorError(`[VSRepository] (unknown: decorator) ${path}: ${firstIssue?.message}`);
|
|
17
|
-
}
|
|
18
|
-
return configParsed.data;
|
|
19
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateExtension = validateExtension;
|
|
4
|
-
const VSRepository_1 = require("../../VSRepository");
|
|
5
|
-
const is_object_validate_1 = require("./is-object.validate");
|
|
6
|
-
function validateExtension(extensionFunc, repo) {
|
|
7
|
-
if (typeof extensionFunc !== "function") {
|
|
8
|
-
throw new VSRepository_1.VSRepoExtendError(`[VSRepository] (${repo.tableName}: extend) 'extensionFunc' must be a valid function.`);
|
|
9
|
-
}
|
|
10
|
-
const extension = extensionFunc(repo);
|
|
11
|
-
if (!(0, is_object_validate_1.isObject)(extension)) {
|
|
12
|
-
throw new VSRepository_1.VSRepoExtendError(`[VSRepository] (${repo.tableName}: extend) The return of the 'extensionFunc' must be a valid object.`);
|
|
13
|
-
}
|
|
14
|
-
return extension;
|
|
15
|
-
}
|
|
@@ -1,42 +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.validateMethodOptions = validateMethodOptions;
|
|
7
|
-
const zod_1 = __importDefault(require("zod"));
|
|
8
|
-
const schemas_util_1 = require("../utils/schemas.util");
|
|
9
|
-
const vs_repo_error_1 = require("../errors/vs-repo.error");
|
|
10
|
-
function validateMethodOptions(options, instance) {
|
|
11
|
-
const optionsSchema = zod_1.default
|
|
12
|
-
.strictObject({
|
|
13
|
-
db: schemas_util_1.objectSchema.optional(),
|
|
14
|
-
selectModel: zod_1.default
|
|
15
|
-
.literal(false)
|
|
16
|
-
.or(zod_1.default.enum(Object.keys(instance.selectModels ?? {})))
|
|
17
|
-
.optional(),
|
|
18
|
-
includeModel: zod_1.default.enum(Object.keys(instance.includeModels ?? {})).optional(),
|
|
19
|
-
see: zod_1.default.enum(["active", "removed", "all"]).default("active"),
|
|
20
|
-
include: schemas_util_1.objectSchema.optional(),
|
|
21
|
-
select: schemas_util_1.objectSchema.optional(),
|
|
22
|
-
})
|
|
23
|
-
.refine(data => {
|
|
24
|
-
const provided = [
|
|
25
|
-
data.select !== undefined,
|
|
26
|
-
data.selectModel !== undefined,
|
|
27
|
-
data.include !== undefined,
|
|
28
|
-
data.includeModel !== undefined,
|
|
29
|
-
].filter(Boolean).length;
|
|
30
|
-
return provided <= 1;
|
|
31
|
-
}, {
|
|
32
|
-
message: "'select', 'selectModel', 'include' and 'includeModel' are mutually exclusive — only one can be provided.",
|
|
33
|
-
path: ["options"],
|
|
34
|
-
});
|
|
35
|
-
const optionsParsed = optionsSchema.safeParse(options ?? {});
|
|
36
|
-
if (!optionsParsed.success) {
|
|
37
|
-
const firstIssue = optionsParsed.error.issues[0];
|
|
38
|
-
const path = firstIssue?.path.length ? firstIssue.path.join(".") : "options";
|
|
39
|
-
throw new vs_repo_error_1.VSRepoRuntimeError(`[VSRepository] (${instance.tableName}: runtime) ${path}: ${firstIssue?.message}`, "67542");
|
|
40
|
-
}
|
|
41
|
-
return optionsParsed.data;
|
|
42
|
-
}
|