mocody 0.2.15 → 0.2.18
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/LICENSE +21 -21
- package/README.md +4 -4
- package/dist/core/base-schema.d.ts +13 -13
- package/dist/core/base-schema.js +11 -11
- package/dist/core/base-schema.js.map +1 -1
- package/dist/couch/couch-data-operation.d.ts +90 -90
- package/dist/couch/couch-data-operation.js +581 -581
- package/dist/couch/couch-data-operation.js.map +1 -1
- package/dist/couch/couch-filter-query-operation.d.ts +47 -47
- package/dist/couch/couch-filter-query-operation.js +438 -438
- package/dist/couch/couch-initializer.d.ts +45 -45
- package/dist/couch/couch-initializer.js +98 -98
- package/dist/couch/couch-initializer.js.map +1 -1
- package/dist/couch/couch-manage-table.d.ts +46 -46
- package/dist/couch/couch-manage-table.js +113 -113
- package/dist/dynamo/dynamo-data-operation.d.ts +97 -97
- package/dist/dynamo/dynamo-data-operation.js +788 -793
- package/dist/dynamo/dynamo-data-operation.js.map +1 -1
- package/dist/dynamo/dynamo-filter-query-operation.d.ts +29 -28
- package/dist/dynamo/dynamo-filter-query-operation.js +655 -627
- package/dist/dynamo/dynamo-filter-query-operation.js.map +1 -1
- package/dist/dynamo/dynamo-helper.d.ts +1 -1
- package/dist/dynamo/dynamo-helper.js +8 -8
- package/dist/dynamo/dynamo-initializer.d.ts +14 -8
- package/dist/dynamo/dynamo-initializer.js +58 -34
- package/dist/dynamo/dynamo-initializer.js.map +1 -1
- package/dist/dynamo/dynamo-manage-table.d.ts +33 -32
- package/dist/dynamo/dynamo-manage-table.js +419 -418
- package/dist/dynamo/dynamo-manage-table.js.map +1 -1
- package/dist/dynamo/dynamo-query-scan-processor.d.ts +25 -24
- package/dist/dynamo/dynamo-query-scan-processor.js +268 -266
- package/dist/dynamo/dynamo-query-scan-processor.js.map +1 -1
- package/dist/helpers/base-joi-helper.d.ts +2 -2
- package/dist/helpers/base-joi-helper.js +12 -12
- package/dist/helpers/constants.d.ts +3 -3
- package/dist/helpers/constants.js +6 -6
- package/dist/helpers/errors.d.ts +13 -13
- package/dist/helpers/errors.js +38 -38
- package/dist/helpers/logging-service.d.ts +8 -8
- package/dist/helpers/logging-service.js +44 -44
- package/dist/helpers/mocody-utils.d.ts +13 -15
- package/dist/helpers/mocody-utils.js +48 -48
- package/dist/helpers/query-validator.d.ts +20 -20
- package/dist/helpers/query-validator.js +96 -84
- package/dist/helpers/query-validator.js.map +1 -1
- package/dist/helpers/util-service.d.ts +29 -29
- package/dist/helpers/util-service.js +155 -155
- package/dist/index.d.ts +10 -10
- package/dist/index.js +19 -19
- package/dist/model/index.d.ts +40 -40
- package/dist/model/index.js +6 -6
- package/dist/mongo/mongo-data-operation.d.ts +88 -88
- package/dist/mongo/mongo-data-operation.js +597 -597
- package/dist/mongo/mongo-data-operation.js.map +1 -1
- package/dist/mongo/mongo-filter-query-operation.d.ts +47 -47
- package/dist/mongo/mongo-filter-query-operation.js +433 -433
- package/dist/mongo/mongo-initializer.d.ts +16 -16
- package/dist/mongo/mongo-initializer.js +47 -47
- package/dist/mongo/mongo-initializer.js.map +1 -1
- package/dist/mongo/mongo-table-manager.d.ts +31 -31
- package/dist/mongo/mongo-table-manager.js +104 -104
- package/dist/type/index.d.ts +109 -108
- package/dist/type/index.js +2 -2
- package/package.json +70 -72
package/dist/helpers/errors.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export declare class MocodyGenericError extends Error {
|
|
2
|
-
constructor(message: string);
|
|
3
|
-
}
|
|
4
|
-
export declare class MocodyErrorUtils {
|
|
5
|
-
mocody_helper_validateRequiredNumber(keyValueValidates: {
|
|
6
|
-
[key: string]: number;
|
|
7
|
-
}): void;
|
|
8
|
-
mocody_helper_createFriendlyError(message: string, statusCode?: number): MocodyGenericError;
|
|
9
|
-
mocody_helper_validateRequiredString(keyValueValidates: {
|
|
10
|
-
[key: string]: string;
|
|
11
|
-
}): void;
|
|
12
|
-
}
|
|
13
|
-
export declare const MocodyErrorUtilsService: MocodyErrorUtils;
|
|
1
|
+
export declare class MocodyGenericError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class MocodyErrorUtils {
|
|
5
|
+
mocody_helper_validateRequiredNumber(keyValueValidates: {
|
|
6
|
+
[key: string]: number;
|
|
7
|
+
}): void;
|
|
8
|
+
mocody_helper_createFriendlyError(message: string, statusCode?: number): MocodyGenericError;
|
|
9
|
+
mocody_helper_validateRequiredString(keyValueValidates: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
}): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const MocodyErrorUtilsService: MocodyErrorUtils;
|
package/dist/helpers/errors.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MocodyErrorUtilsService = exports.MocodyErrorUtils = exports.MocodyGenericError = void 0;
|
|
4
|
-
class MocodyGenericError extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.MocodyGenericError = MocodyGenericError;
|
|
10
|
-
class MocodyErrorUtils {
|
|
11
|
-
mocody_helper_validateRequiredNumber(keyValueValidates) {
|
|
12
|
-
const errors = [];
|
|
13
|
-
Object.entries(keyValueValidates).forEach(([key, value]) => {
|
|
14
|
-
if (!(!isNaN(Number(value)) && typeof value === "number")) {
|
|
15
|
-
errors.push(`${key} is required`);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
if (errors.length) {
|
|
19
|
-
throw new MocodyGenericError(`${errors.join("; ")}.`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
mocody_helper_createFriendlyError(message, statusCode) {
|
|
23
|
-
return new MocodyGenericError(message);
|
|
24
|
-
}
|
|
25
|
-
mocody_helper_validateRequiredString(keyValueValidates) {
|
|
26
|
-
const errors = [];
|
|
27
|
-
Object.entries(keyValueValidates).forEach(([key, value]) => {
|
|
28
|
-
if (!(value && typeof value === "string")) {
|
|
29
|
-
errors.push(`${key} is required`);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
if (errors.length) {
|
|
33
|
-
throw new MocodyGenericError(`${errors.join("; ")}.`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.MocodyErrorUtils = MocodyErrorUtils;
|
|
38
|
-
exports.MocodyErrorUtilsService = new MocodyErrorUtils();
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MocodyErrorUtilsService = exports.MocodyErrorUtils = exports.MocodyGenericError = void 0;
|
|
4
|
+
class MocodyGenericError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.MocodyGenericError = MocodyGenericError;
|
|
10
|
+
class MocodyErrorUtils {
|
|
11
|
+
mocody_helper_validateRequiredNumber(keyValueValidates) {
|
|
12
|
+
const errors = [];
|
|
13
|
+
Object.entries(keyValueValidates).forEach(([key, value]) => {
|
|
14
|
+
if (!(!isNaN(Number(value)) && typeof value === "number")) {
|
|
15
|
+
errors.push(`${key} is required`);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
if (errors.length) {
|
|
19
|
+
throw new MocodyGenericError(`${errors.join("; ")}.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
mocody_helper_createFriendlyError(message, statusCode) {
|
|
23
|
+
return new MocodyGenericError(message);
|
|
24
|
+
}
|
|
25
|
+
mocody_helper_validateRequiredString(keyValueValidates) {
|
|
26
|
+
const errors = [];
|
|
27
|
+
Object.entries(keyValueValidates).forEach(([key, value]) => {
|
|
28
|
+
if (!(value && typeof value === "string")) {
|
|
29
|
+
errors.push(`${key} is required`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (errors.length) {
|
|
33
|
+
throw new MocodyGenericError(`${errors.join("; ")}.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.MocodyErrorUtils = MocodyErrorUtils;
|
|
38
|
+
exports.MocodyErrorUtilsService = new MocodyErrorUtils();
|
|
39
39
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare class LoggingServiceBase {
|
|
2
|
-
private mode;
|
|
3
|
-
constructor();
|
|
4
|
-
error(message: any): void;
|
|
5
|
-
log(message: any, ...optionalParams: any[]): void;
|
|
6
|
-
}
|
|
7
|
-
export declare const LoggingService: LoggingServiceBase;
|
|
8
|
-
export {};
|
|
1
|
+
declare class LoggingServiceBase {
|
|
2
|
+
private mode;
|
|
3
|
+
constructor();
|
|
4
|
+
error(message: any): void;
|
|
5
|
+
log(message: any, ...optionalParams: any[]): void;
|
|
6
|
+
}
|
|
7
|
+
export declare const LoggingService: LoggingServiceBase;
|
|
8
|
+
export {};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoggingService = void 0;
|
|
4
|
-
class LoggingServiceBase {
|
|
5
|
-
constructor() {
|
|
6
|
-
Object.defineProperty(this, "mode", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
configurable: true,
|
|
9
|
-
writable: true,
|
|
10
|
-
value: void 0
|
|
11
|
-
});
|
|
12
|
-
const mode = process.env.MOCODY_DEBUG_MODE;
|
|
13
|
-
if (mode === "true") {
|
|
14
|
-
this.mode = true;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
this.mode = false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
error(message) {
|
|
21
|
-
try {
|
|
22
|
-
if (this.mode) {
|
|
23
|
-
console.error(message);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
log(message, ...optionalParams) {
|
|
30
|
-
try {
|
|
31
|
-
if (this.mode) {
|
|
32
|
-
if (optionalParams?.length) {
|
|
33
|
-
console.log(message, optionalParams);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
console.log(message);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.LoggingService = new LoggingServiceBase();
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoggingService = void 0;
|
|
4
|
+
class LoggingServiceBase {
|
|
5
|
+
constructor() {
|
|
6
|
+
Object.defineProperty(this, "mode", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: void 0
|
|
11
|
+
});
|
|
12
|
+
const mode = process.env.MOCODY_DEBUG_MODE;
|
|
13
|
+
if (mode === "true") {
|
|
14
|
+
this.mode = true;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
this.mode = false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
error(message) {
|
|
21
|
+
try {
|
|
22
|
+
if (this.mode) {
|
|
23
|
+
console.error(message);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
log(message, ...optionalParams) {
|
|
30
|
+
try {
|
|
31
|
+
if (this.mode) {
|
|
32
|
+
if (optionalParams?.length) {
|
|
33
|
+
console.log(message, optionalParams);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.log(message);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.LoggingService = new LoggingServiceBase();
|
|
45
45
|
//# sourceMappingURL=logging-service.js.map
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
declare class MocodyUtilBase {
|
|
2
|
-
marshallFromJson(jsonData: Record<string, any>):
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
export declare const MocodyUtil: MocodyUtilBase;
|
|
15
|
-
export {};
|
|
1
|
+
declare class MocodyUtilBase {
|
|
2
|
+
marshallFromJson(jsonData: Record<string, any>): Record<string, import("@aws-sdk/client-dynamodb").AttributeValue>;
|
|
3
|
+
unmarshallToJson(dynamoData: Record<string, any>): {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
getProjectionFields<T = any>({ excludeFields, fields, entityFields, }: {
|
|
7
|
+
excludeFields?: (keyof T)[];
|
|
8
|
+
fields?: (keyof T)[];
|
|
9
|
+
entityFields: (keyof T)[] | string[];
|
|
10
|
+
}): (keyof T)[] | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare const MocodyUtil: MocodyUtilBase;
|
|
13
|
+
export {};
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MocodyUtil = void 0;
|
|
4
|
-
const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
|
|
5
|
-
class MocodyUtilBase {
|
|
6
|
-
marshallFromJson(jsonData) {
|
|
7
|
-
const marshalled = (0, util_dynamodb_1.marshall)(jsonData, {
|
|
8
|
-
convertClassInstanceToMap: true,
|
|
9
|
-
convertEmptyValues: true,
|
|
10
|
-
removeUndefinedValues: true,
|
|
11
|
-
});
|
|
12
|
-
return marshalled;
|
|
13
|
-
}
|
|
14
|
-
unmarshallToJson(dynamoData) {
|
|
15
|
-
return (0, util_dynamodb_1.unmarshall)(dynamoData);
|
|
16
|
-
}
|
|
17
|
-
getProjectionFields({ excludeFields, fields, entityFields, }) {
|
|
18
|
-
if (!fields?.length && !excludeFields?.length) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
const fields01 = fields?.length ? Array.from(new Set([...fields])) : [];
|
|
22
|
-
const excludeFields01 = excludeFields?.length ? Array.from(new Set([...excludeFields])) : [];
|
|
23
|
-
if (!excludeFields01.length) {
|
|
24
|
-
if (fields01.length) {
|
|
25
|
-
return fields01;
|
|
26
|
-
}
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
let baseFields = [];
|
|
30
|
-
if (fields01.length) {
|
|
31
|
-
baseFields = [...fields01];
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
baseFields = [...entityFields];
|
|
35
|
-
}
|
|
36
|
-
const fieldSet01 = new Set();
|
|
37
|
-
baseFields.forEach((field) => {
|
|
38
|
-
if (!excludeFields01.includes(field)) {
|
|
39
|
-
fieldSet01.add(field);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
if (fieldSet01.size > 0) {
|
|
43
|
-
return [...fieldSet01];
|
|
44
|
-
}
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.MocodyUtil = new MocodyUtilBase();
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MocodyUtil = void 0;
|
|
4
|
+
const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
|
|
5
|
+
class MocodyUtilBase {
|
|
6
|
+
marshallFromJson(jsonData) {
|
|
7
|
+
const marshalled = (0, util_dynamodb_1.marshall)(jsonData, {
|
|
8
|
+
convertClassInstanceToMap: true,
|
|
9
|
+
convertEmptyValues: true,
|
|
10
|
+
removeUndefinedValues: true,
|
|
11
|
+
});
|
|
12
|
+
return marshalled;
|
|
13
|
+
}
|
|
14
|
+
unmarshallToJson(dynamoData) {
|
|
15
|
+
return (0, util_dynamodb_1.unmarshall)(dynamoData);
|
|
16
|
+
}
|
|
17
|
+
getProjectionFields({ excludeFields, fields, entityFields, }) {
|
|
18
|
+
if (!fields?.length && !excludeFields?.length) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const fields01 = fields?.length ? Array.from(new Set([...fields])) : [];
|
|
22
|
+
const excludeFields01 = excludeFields?.length ? Array.from(new Set([...excludeFields])) : [];
|
|
23
|
+
if (!excludeFields01.length) {
|
|
24
|
+
if (fields01.length) {
|
|
25
|
+
return fields01;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
let baseFields = [];
|
|
30
|
+
if (fields01.length) {
|
|
31
|
+
baseFields = [...fields01];
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
baseFields = [...entityFields];
|
|
35
|
+
}
|
|
36
|
+
const fieldSet01 = new Set();
|
|
37
|
+
baseFields.forEach((field) => {
|
|
38
|
+
if (!excludeFields01.includes(field)) {
|
|
39
|
+
fieldSet01.add(field);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
if (fieldSet01.size > 0) {
|
|
43
|
+
return [...fieldSet01];
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.MocodyUtil = new MocodyUtilBase();
|
|
49
49
|
//# sourceMappingURL=mocody-utils.js.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
declare class QueryValidatorCheckBase {
|
|
2
|
-
private queryErrorThrowChecks;
|
|
3
|
-
beginWith(conditionValue: unknown): void;
|
|
4
|
-
between(conditionValue: unknown): void;
|
|
5
|
-
contains(conditionValue: unknown): void;
|
|
6
|
-
notContains(conditionValue: unknown): void;
|
|
7
|
-
in_query(conditionValue: unknown): void;
|
|
8
|
-
notIn(conditionValue: unknown): void;
|
|
9
|
-
elemMatch(conditionValue: {
|
|
10
|
-
$in: any[];
|
|
11
|
-
}): void;
|
|
12
|
-
nestedMatch(conditionValue: Record<string, any>): void;
|
|
13
|
-
not_query(conditionValue: unknown): void;
|
|
14
|
-
exists(conditionValue: unknown): void;
|
|
15
|
-
or_query(conditionValue: unknown): void;
|
|
16
|
-
and_query(conditionValue: unknown): void;
|
|
17
|
-
throwQueryNotFound(queryType: any): void;
|
|
18
|
-
}
|
|
19
|
-
export declare const QueryValidatorCheck: QueryValidatorCheckBase;
|
|
20
|
-
export {};
|
|
1
|
+
declare class QueryValidatorCheckBase {
|
|
2
|
+
private queryErrorThrowChecks;
|
|
3
|
+
beginWith(conditionValue: unknown): void;
|
|
4
|
+
between(conditionValue: unknown): void;
|
|
5
|
+
contains(conditionValue: unknown): void;
|
|
6
|
+
notContains(conditionValue: unknown): void;
|
|
7
|
+
in_query(conditionValue: unknown): void;
|
|
8
|
+
notIn(conditionValue: unknown): void;
|
|
9
|
+
elemMatch(conditionValue: {
|
|
10
|
+
$in: any[];
|
|
11
|
+
}): void;
|
|
12
|
+
nestedMatch(conditionValue: Record<string, any>): void;
|
|
13
|
+
not_query(conditionValue: unknown): void;
|
|
14
|
+
exists(conditionValue: unknown): void;
|
|
15
|
+
or_query(conditionValue: unknown): void;
|
|
16
|
+
and_query(conditionValue: unknown): void;
|
|
17
|
+
throwQueryNotFound(queryType: any): void;
|
|
18
|
+
}
|
|
19
|
+
export declare const QueryValidatorCheck: QueryValidatorCheckBase;
|
|
20
|
+
export {};
|
|
@@ -1,85 +1,97 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QueryValidatorCheck = void 0;
|
|
4
|
-
const errors_1 = require("./errors");
|
|
5
|
-
class QueryValidatorCheckBase {
|
|
6
|
-
queryErrorThrowChecks({ conditionValue, queryType }) {
|
|
7
|
-
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Value: ${JSON.stringify(conditionValue)}, is invalid for ${queryType} query`);
|
|
8
|
-
}
|
|
9
|
-
beginWith(conditionValue) {
|
|
10
|
-
if (!(conditionValue && typeof conditionValue === "string")) {
|
|
11
|
-
this.queryErrorThrowChecks({ conditionValue, queryType: "$beginsWith" });
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
between(conditionValue) {
|
|
15
|
-
if (!(conditionValue && Array.isArray(conditionValue) && conditionValue.length === 2)) {
|
|
16
|
-
this.queryErrorThrowChecks({ conditionValue, queryType: "$between" });
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
contains(conditionValue) {
|
|
20
|
-
if (!(conditionValue && typeof conditionValue === "string")) {
|
|
21
|
-
this.queryErrorThrowChecks({ conditionValue, queryType: "$contains" });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
notContains(conditionValue) {
|
|
25
|
-
if (!(conditionValue && typeof conditionValue === "string")) {
|
|
26
|
-
this.queryErrorThrowChecks({ conditionValue, queryType: "$notContains" });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
in_query(conditionValue) {
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryValidatorCheck = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
class QueryValidatorCheckBase {
|
|
6
|
+
queryErrorThrowChecks({ conditionValue, queryType }) {
|
|
7
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Value: ${JSON.stringify(conditionValue)}, is invalid for ${queryType} query`);
|
|
8
|
+
}
|
|
9
|
+
beginWith(conditionValue) {
|
|
10
|
+
if (!(conditionValue && typeof conditionValue === "string")) {
|
|
11
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$beginsWith" });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
between(conditionValue) {
|
|
15
|
+
if (!(conditionValue && Array.isArray(conditionValue) && conditionValue.length === 2)) {
|
|
16
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$between" });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
contains(conditionValue) {
|
|
20
|
+
if (!(conditionValue && typeof conditionValue === "string")) {
|
|
21
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$contains" });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
notContains(conditionValue) {
|
|
25
|
+
if (!(conditionValue && typeof conditionValue === "string")) {
|
|
26
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$notContains" });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
in_query(conditionValue) {
|
|
30
|
+
if (conditionValue && Array.isArray(conditionValue) && conditionValue.length) {
|
|
31
|
+
const firstValue = conditionValue[0];
|
|
32
|
+
if (typeof firstValue !== "string" || typeof firstValue !== "number") {
|
|
33
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$in" });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$in" });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
notIn(conditionValue) {
|
|
41
|
+
if (conditionValue && Array.isArray(conditionValue) && conditionValue.length) {
|
|
42
|
+
const firstValue = conditionValue[0];
|
|
43
|
+
if (typeof firstValue !== "string" || typeof firstValue !== "number") {
|
|
44
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$nin" });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$nin" });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
elemMatch(conditionValue) {
|
|
52
|
+
if (!(conditionValue && typeof conditionValue === "object")) {
|
|
53
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$elemMatch" });
|
|
54
|
+
}
|
|
55
|
+
if (!(conditionValue?.$in?.length && Array.isArray(conditionValue.$in))) {
|
|
56
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError("$elemMatch must have a valid $in query and must be an array of non-zero length");
|
|
57
|
+
}
|
|
58
|
+
for (const item of conditionValue.$in) {
|
|
59
|
+
if (typeof item !== "number" && typeof item !== "string" && typeof item !== "boolean") {
|
|
60
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError("$in in $elemMatch MUST have values of string or number or boolean");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
nestedMatch(conditionValue) {
|
|
65
|
+
if (!(conditionValue && typeof conditionValue === "object")) {
|
|
66
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$nestedMatch" });
|
|
67
|
+
}
|
|
68
|
+
if (!Object.keys(conditionValue).length) {
|
|
69
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError("$nestedMatch must have a valid query definitions");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
not_query(conditionValue) {
|
|
73
|
+
if (!(conditionValue && typeof conditionValue === "object")) {
|
|
74
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$not" });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exists(conditionValue) {
|
|
78
|
+
if (!(String(conditionValue) === "true" || String(conditionValue) === "false")) {
|
|
79
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$exists" });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
or_query(conditionValue) {
|
|
83
|
+
if (!(conditionValue && Array.isArray(conditionValue) && conditionValue.length)) {
|
|
84
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$or" });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
and_query(conditionValue) {
|
|
88
|
+
if (!(conditionValue && Array.isArray(conditionValue) && conditionValue.length)) {
|
|
89
|
+
this.queryErrorThrowChecks({ conditionValue, queryType: "$and" });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
throwQueryNotFound(queryType) {
|
|
93
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Query type: ${JSON.stringify(queryType)}, not supported`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.QueryValidatorCheck = new QueryValidatorCheckBase();
|
|
85
97
|
//# sourceMappingURL=query-validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-validator.js","sourceRoot":"","sources":["../../src/helpers/query-validator.ts"],"names":[],"mappings":";;;AAAA,qCAAmD;AAEnD,MAAM,uBAAuB;IACnB,qBAAqB,CAAC,EAAE,cAAc,EAAE,SAAS,EAA8C;QACrG,MAAM,gCAAuB,CAAC,iCAAiC,CAC7D,UAAU,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,oBAAoB,SAAS,QAAQ,CAC9E,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,cAAuB;QAC/B,IAAI,CAAC,CAAC,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ,CAAC,EAAE;YAC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AAG,IAAI,uBAAuB,EAAE,CAAC"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
declare class UtilServiceBase {
|
|
2
|
-
convertHexadecimalToNumber(hexString: string): number;
|
|
3
|
-
getRandomDecimal(min: number, max: number): number;
|
|
4
|
-
getRandomInt(min: number, max: number): number;
|
|
5
|
-
getRandomString(count: number): string;
|
|
6
|
-
camelCaseToSentenceCase(text: string): string;
|
|
7
|
-
toTitleCase(text: string): string;
|
|
8
|
-
isValidPhoneNumber(_str: string): boolean;
|
|
9
|
-
convertObjectPlainObject<T = any>(objData: T): T;
|
|
10
|
-
removeDuplicateString(items: string[]): string[];
|
|
11
|
-
objectHasAnyProperty(obj: any): boolean;
|
|
12
|
-
waitUntilMilliseconds(ms: number): Promise<void>;
|
|
13
|
-
waitUntilSeconds(seconds: number): Promise<void>;
|
|
14
|
-
waitUntilMunites(munites: number): Promise<void>;
|
|
15
|
-
generateDynamoTableKey(date?: any): string;
|
|
16
|
-
encodeStringToBase64(str: string): string;
|
|
17
|
-
decodeStringFromBase64(str: string): string;
|
|
18
|
-
isNumeric(n: string | number | null | undefined): boolean;
|
|
19
|
-
isNumericInteger(n: string | number | null | undefined): boolean;
|
|
20
|
-
getEpochTime(date: string | Date): number;
|
|
21
|
-
encodeBase64(str: string): string;
|
|
22
|
-
decodeBase64(str: string): string;
|
|
23
|
-
deleteKeysFromObject<T = Record<string, any>>({ dataObject, delKeys, }: {
|
|
24
|
-
dataObject: T;
|
|
25
|
-
delKeys: (keyof T | string)[];
|
|
26
|
-
}): T;
|
|
27
|
-
}
|
|
28
|
-
export declare const UtilService: UtilServiceBase;
|
|
29
|
-
export {};
|
|
1
|
+
declare class UtilServiceBase {
|
|
2
|
+
convertHexadecimalToNumber(hexString: string): number;
|
|
3
|
+
getRandomDecimal(min: number, max: number): number;
|
|
4
|
+
getRandomInt(min: number, max: number): number;
|
|
5
|
+
getRandomString(count: number): string;
|
|
6
|
+
camelCaseToSentenceCase(text: string): string;
|
|
7
|
+
toTitleCase(text: string): string;
|
|
8
|
+
isValidPhoneNumber(_str: string): boolean;
|
|
9
|
+
convertObjectPlainObject<T = any>(objData: T): T;
|
|
10
|
+
removeDuplicateString(items: string[]): string[];
|
|
11
|
+
objectHasAnyProperty(obj: any): boolean;
|
|
12
|
+
waitUntilMilliseconds(ms: number): Promise<void>;
|
|
13
|
+
waitUntilSeconds(seconds: number): Promise<void>;
|
|
14
|
+
waitUntilMunites(munites: number): Promise<void>;
|
|
15
|
+
generateDynamoTableKey(date?: any): string;
|
|
16
|
+
encodeStringToBase64(str: string): string;
|
|
17
|
+
decodeStringFromBase64(str: string): string;
|
|
18
|
+
isNumeric(n: string | number | null | undefined): boolean;
|
|
19
|
+
isNumericInteger(n: string | number | null | undefined): boolean;
|
|
20
|
+
getEpochTime(date: string | Date): number;
|
|
21
|
+
encodeBase64(str: string): string;
|
|
22
|
+
decodeBase64(str: string): string;
|
|
23
|
+
deleteKeysFromObject<T = Record<string, any>>({ dataObject, delKeys, }: {
|
|
24
|
+
dataObject: T;
|
|
25
|
+
delKeys: (keyof T | string)[];
|
|
26
|
+
}): T;
|
|
27
|
+
}
|
|
28
|
+
export declare const UtilService: UtilServiceBase;
|
|
29
|
+
export {};
|