mocody 0.4.38 → 0.5.0-alpha
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/dist/core/base-schema.d.ts +13 -13
- package/dist/core/base-schema.js +11 -11
- package/dist/couch/couch-data-operation.d.ts +92 -92
- package/dist/couch/couch-data-operation.js +580 -580
- package/dist/couch/couch-data-operation.js.map +1 -1
- package/dist/couch/couch-filter-query-operation.d.ts +45 -47
- package/dist/couch/couch-filter-query-operation.js +371 -438
- package/dist/couch/couch-filter-query-operation.js.map +1 -1
- package/dist/couch/couch-initializer.d.ts +126 -126
- package/dist/couch/couch-initializer.js +189 -189
- 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 +103 -103
- package/dist/couch/couch-manage-table.js.map +1 -1
- package/dist/dynamo/dynamo-data-operation.d.ts +102 -99
- package/dist/dynamo/dynamo-data-operation.js +932 -797
- package/dist/dynamo/dynamo-data-operation.js.map +1 -1
- package/dist/dynamo/dynamo-filter-query-operation.d.ts +29 -29
- package/dist/dynamo/dynamo-filter-query-operation.js +603 -690
- package/dist/dynamo/dynamo-filter-query-operation.js.map +1 -1
- package/dist/dynamo/dynamo-filter-query-partiql-operation.d.ts +22 -0
- package/dist/dynamo/dynamo-filter-query-partiql-operation.js +457 -0
- package/dist/dynamo/dynamo-filter-query-partiql-operation.js.map +1 -0
- package/dist/dynamo/dynamo-helper.d.ts +1 -1
- package/dist/dynamo/dynamo-helper.js +8 -8
- package/dist/dynamo/dynamo-initializer.d.ts +15 -14
- package/dist/dynamo/dynamo-initializer.js +66 -58
- package/dist/dynamo/dynamo-initializer.js.map +1 -1
- package/dist/dynamo/dynamo-manage-table.d.ts +33 -33
- package/dist/dynamo/dynamo-manage-table.js +419 -419
- package/dist/dynamo/dynamo-manage-table.js.map +1 -1
- package/dist/dynamo/dynamo-query-partiql-processor.d.ts +31 -0
- package/dist/dynamo/dynamo-query-partiql-processor.js +277 -0
- package/dist/dynamo/dynamo-query-partiql-processor.js.map +1 -0
- package/dist/dynamo/dynamo-query-scan-processor.d.ts +25 -25
- package/dist/dynamo/dynamo-query-scan-processor.js +268 -268
- 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 +9 -9
- package/dist/helpers/logging-service.js +53 -53
- package/dist/helpers/logging-service.js.map +1 -1
- package/dist/helpers/mocody-utils.d.ts +16 -16
- package/dist/helpers/mocody-utils.js +58 -58
- package/dist/helpers/query-validator.d.ts +20 -20
- package/dist/helpers/query-validator.js +96 -96
- package/dist/helpers/util-service.d.ts +29 -29
- package/dist/helpers/util-service.js +155 -155
- package/dist/index.d.ts +12 -12
- package/dist/index.js +23 -23
- package/dist/model/index.d.ts +42 -42
- package/dist/model/index.js +6 -6
- package/dist/mongo/mongo-data-operation.d.ts +90 -90
- package/dist/mongo/mongo-data-operation.js +607 -607
- package/dist/mongo/mongo-data-operation.js.map +1 -1
- package/dist/mongo/mongo-filter-query-operation.d.ts +45 -47
- package/dist/mongo/mongo-filter-query-operation.js +368 -433
- package/dist/mongo/mongo-filter-query-operation.js.map +1 -1
- 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/mongo/mongo-table-manager.js.map +1 -1
- package/dist/pouch/pouch-data-operation.d.ts +90 -90
- package/dist/pouch/pouch-data-operation.js +583 -583
- package/dist/pouch/pouch-data-operation.js.map +1 -1
- package/dist/pouch/pouch-filter-query-operation.d.ts +45 -47
- package/dist/pouch/pouch-filter-query-operation.js +371 -438
- package/dist/pouch/pouch-filter-query-operation.js.map +1 -1
- package/dist/pouch/pouch-initializer.d.ts +111 -109
- package/dist/pouch/pouch-initializer.js +357 -357
- package/dist/pouch/pouch-initializer.js.map +1 -1
- package/dist/pouch/pouch-manage-table.d.ts +35 -35
- package/dist/pouch/pouch-manage-table.js +99 -99
- package/dist/pouch/pouch-manage-table.js.map +1 -1
- package/dist/type/index.d.ts +118 -119
- package/dist/type/index.js +2 -2
- package/package.json +17 -16
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,9 +1,9 @@
|
|
|
1
|
-
declare class LoggingServiceBase {
|
|
2
|
-
private mode;
|
|
3
|
-
constructor();
|
|
4
|
-
error(message: unknown): void;
|
|
5
|
-
log(message: unknown, ...optionalParams: unknown[]): void;
|
|
6
|
-
logAsString(logData: unknown): void;
|
|
7
|
-
}
|
|
8
|
-
export declare const LoggingService: LoggingServiceBase;
|
|
9
|
-
export {};
|
|
1
|
+
declare class LoggingServiceBase {
|
|
2
|
+
private mode;
|
|
3
|
+
constructor();
|
|
4
|
+
error(message: unknown): void;
|
|
5
|
+
log(message: unknown, ...optionalParams: unknown[]): void;
|
|
6
|
+
logAsString(logData: unknown): void;
|
|
7
|
+
}
|
|
8
|
+
export declare const LoggingService: LoggingServiceBase;
|
|
9
|
+
export {};
|
|
@@ -1,54 +1,54 @@
|
|
|
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 (String(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
|
-
logAsString(logData) {
|
|
44
|
-
try {
|
|
45
|
-
if (this.mode) {
|
|
46
|
-
console.log(typeof logData === "string" ? logData : JSON.stringify(logData, null, 2));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
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 (String(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
|
+
logAsString(logData) {
|
|
44
|
+
try {
|
|
45
|
+
if (this.mode) {
|
|
46
|
+
console.log(typeof logData === "string" ? logData : JSON.stringify(logData, null, 2));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.LoggingService = new LoggingServiceBase();
|
|
54
54
|
//# sourceMappingURL=logging-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging-service.js","sourceRoot":"","sources":["../../src/helpers/logging-service.ts"],"names":[],"mappings":";;;AAAA,MAAM,kBAAkB;IAGtB;
|
|
1
|
+
{"version":3,"file":"logging-service.js","sourceRoot":"","sources":["../../src/helpers/logging-service.ts"],"names":[],"mappings":";;;AAAA,MAAM,kBAAkB;IAGtB;QAFQ;;;;;WAAc;QAGpB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC;QACjD,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,MAAM,EAAE;YAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SAClB;aAAM;YACL,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;SACnB;IACH,CAAC;IAED,KAAK,CAAC,OAAgB;QACpB,IAAI;YACF,IAAI,IAAI,CAAC,IAAI,EAAE;gBACb,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;aACxB;SACF;QAAC,OAAO,KAAK,EAAE;SAEf;IACH,CAAC;IAED,GAAG,CAAC,OAAgB,EAAE,GAAG,cAAyB;QAChD,IAAI;YACF,IAAI,IAAI,CAAC,IAAI,EAAE;gBACb,IAAI,cAAc,EAAE,MAAM,EAAE;oBAC1B,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;iBACtC;qBAAM;oBACL,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;iBACtB;aACF;SACF;QAAC,OAAO,KAAK,EAAE;SAEf;IACH,CAAC;IAED,WAAW,CAAC,OAAgB;QAC1B,IAAI;YACF,IAAI,IAAI,CAAC,IAAI,EAAE;gBACb,OAAO,CAAC,GAAG,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;aACvF;SACF;QAAC,OAAO,KAAK,EAAE;SAEf;IACH,CAAC;CACF;AAEY,QAAA,cAAc,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
declare class MocodyUtilBase {
|
|
2
|
-
marshallFromJson(jsonData: Record<string, any>): Record<string, import("@aws-sdk/client-dynamodb").AttributeValue>;
|
|
3
|
-
unmarshallToJson(dynamoData: Record<string, any>): Record<string, any>;
|
|
4
|
-
getProjectionFields<T = any>({ excludeFields, fields, entityFields, }: {
|
|
5
|
-
excludeFields?: (keyof T)[] | undefined | null;
|
|
6
|
-
fields?: (keyof T)[] | undefined | null;
|
|
7
|
-
entityFields: (keyof T)[] | string[];
|
|
8
|
-
}): (keyof T)[] | undefined;
|
|
9
|
-
validateFieldAlias<T>({ data, fieldAliases, featureEntity, }: {
|
|
10
|
-
data: Partial<T>;
|
|
11
|
-
fieldAliases: [keyof T, keyof T][] | undefined | null;
|
|
12
|
-
featureEntity: string;
|
|
13
|
-
}): void;
|
|
14
|
-
}
|
|
15
|
-
export declare const MocodyUtil: MocodyUtilBase;
|
|
16
|
-
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>): Record<string, any>;
|
|
4
|
+
getProjectionFields<T = any>({ excludeFields, fields, entityFields, }: {
|
|
5
|
+
excludeFields?: (keyof T)[] | undefined | null;
|
|
6
|
+
fields?: (keyof T)[] | undefined | null;
|
|
7
|
+
entityFields: (keyof T)[] | string[];
|
|
8
|
+
}): (keyof T)[] | undefined;
|
|
9
|
+
validateFieldAlias<T>({ data, fieldAliases, featureEntity, }: {
|
|
10
|
+
data: Partial<T>;
|
|
11
|
+
fieldAliases: [keyof T, keyof T][] | undefined | null;
|
|
12
|
+
featureEntity: string;
|
|
13
|
+
}): void;
|
|
14
|
+
}
|
|
15
|
+
export declare const MocodyUtil: MocodyUtilBase;
|
|
16
|
+
export {};
|
|
@@ -1,59 +1,59 @@
|
|
|
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
|
-
const errors_1 = require("./errors");
|
|
6
|
-
class MocodyUtilBase {
|
|
7
|
-
marshallFromJson(jsonData) {
|
|
8
|
-
const marshalled = (0, util_dynamodb_1.marshall)(jsonData, {
|
|
9
|
-
convertClassInstanceToMap: true,
|
|
10
|
-
convertEmptyValues: true,
|
|
11
|
-
removeUndefinedValues: true,
|
|
12
|
-
});
|
|
13
|
-
return marshalled;
|
|
14
|
-
}
|
|
15
|
-
unmarshallToJson(dynamoData) {
|
|
16
|
-
return (0, util_dynamodb_1.unmarshall)(dynamoData);
|
|
17
|
-
}
|
|
18
|
-
getProjectionFields({ excludeFields, fields, entityFields, }) {
|
|
19
|
-
if (!fields?.length && !excludeFields?.length) {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
const fields01 = fields?.length ? Array.from(new Set([...fields])) : [];
|
|
23
|
-
const excludeFields01 = excludeFields?.length ? Array.from(new Set([...excludeFields])) : [];
|
|
24
|
-
if (!excludeFields01.length) {
|
|
25
|
-
if (fields01.length) {
|
|
26
|
-
return fields01;
|
|
27
|
-
}
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
let baseFields = [];
|
|
31
|
-
if (fields01.length) {
|
|
32
|
-
baseFields = [...fields01];
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
baseFields = [...entityFields];
|
|
36
|
-
}
|
|
37
|
-
const fieldSet01 = new Set();
|
|
38
|
-
baseFields.forEach((field) => {
|
|
39
|
-
if (!excludeFields01.includes(field)) {
|
|
40
|
-
fieldSet01.add(field);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
if (fieldSet01.size > 0) {
|
|
44
|
-
return [...fieldSet01];
|
|
45
|
-
}
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
validateFieldAlias({ data, fieldAliases, featureEntity, }) {
|
|
49
|
-
if (fieldAliases?.length && typeof data === "object" && featureEntity) {
|
|
50
|
-
fieldAliases.forEach(([field01, field02]) => {
|
|
51
|
-
if (data[field01] !== data[field02]) {
|
|
52
|
-
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Aliases mismatched for '${featureEntity}'`);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
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
|
+
const errors_1 = require("./errors");
|
|
6
|
+
class MocodyUtilBase {
|
|
7
|
+
marshallFromJson(jsonData) {
|
|
8
|
+
const marshalled = (0, util_dynamodb_1.marshall)(jsonData, {
|
|
9
|
+
convertClassInstanceToMap: true,
|
|
10
|
+
convertEmptyValues: true,
|
|
11
|
+
removeUndefinedValues: true,
|
|
12
|
+
});
|
|
13
|
+
return marshalled;
|
|
14
|
+
}
|
|
15
|
+
unmarshallToJson(dynamoData) {
|
|
16
|
+
return (0, util_dynamodb_1.unmarshall)(dynamoData);
|
|
17
|
+
}
|
|
18
|
+
getProjectionFields({ excludeFields, fields, entityFields, }) {
|
|
19
|
+
if (!fields?.length && !excludeFields?.length) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const fields01 = fields?.length ? Array.from(new Set([...fields])) : [];
|
|
23
|
+
const excludeFields01 = excludeFields?.length ? Array.from(new Set([...excludeFields])) : [];
|
|
24
|
+
if (!excludeFields01.length) {
|
|
25
|
+
if (fields01.length) {
|
|
26
|
+
return fields01;
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
let baseFields = [];
|
|
31
|
+
if (fields01.length) {
|
|
32
|
+
baseFields = [...fields01];
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
baseFields = [...entityFields];
|
|
36
|
+
}
|
|
37
|
+
const fieldSet01 = new Set();
|
|
38
|
+
baseFields.forEach((field) => {
|
|
39
|
+
if (!excludeFields01.includes(field)) {
|
|
40
|
+
fieldSet01.add(field);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
if (fieldSet01.size > 0) {
|
|
44
|
+
return [...fieldSet01];
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
validateFieldAlias({ data, fieldAliases, featureEntity, }) {
|
|
49
|
+
if (fieldAliases?.length && typeof data === "object" && featureEntity) {
|
|
50
|
+
fieldAliases.forEach(([field01, field02]) => {
|
|
51
|
+
if (data[field01] !== data[field02]) {
|
|
52
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError(`Aliases mismatched for '${featureEntity}'`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.MocodyUtil = new MocodyUtilBase();
|
|
59
59
|
//# 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,97 +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 (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") {
|
|
60
|
-
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError("$in in $elemMatch MUST have values of string or number");
|
|
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();
|
|
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") {
|
|
60
|
+
throw errors_1.MocodyErrorUtilsService.mocody_helper_createFriendlyError("$in in $elemMatch MUST have values of string or number");
|
|
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();
|
|
97
97
|
//# sourceMappingURL=query-validator.js.map
|