dl-commons 0.0.2-testing.12 → 0.0.2-testing.14
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/services/dictionaries.service.js +7 -2
- package/dist/services/dictionaries.service.js.map +1 -1
- package/dist/transformers/common.transformer.d.ts +1 -0
- package/dist/transformers/common.transformer.js +4 -0
- package/dist/transformers/common.transformer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/helper.utils.d.ts +2 -1
- package/dist/utils/helper.utils.js +16 -1
- package/dist/utils/helper.utils.js.map +1 -1
- package/package.json +1 -1
- package/src/services/dictionaries.service.ts +9 -5
- package/src/transformers/common.transformer.ts +6 -1
- package/src/utils/helper.utils.ts +18 -1
|
@@ -3,4 +3,5 @@ declare const toStringArray: (value: string | string[]) => string[];
|
|
|
3
3
|
declare const toMongoId: (value: string) => import("bson").ObjectId;
|
|
4
4
|
declare const toMongoIdArray: (values: string | string[]) => Types.ObjectId[];
|
|
5
5
|
declare const toBoolean: (value: string) => value is "true";
|
|
6
|
-
|
|
6
|
+
declare const toInt64: (value: string) => bigint;
|
|
7
|
+
export { toStringArray, toMongoId, toMongoIdArray, toBoolean, toInt64 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toBoolean = exports.toMongoIdArray = exports.toMongoId = exports.toStringArray = void 0;
|
|
3
|
+
exports.toInt64 = exports.toBoolean = exports.toMongoIdArray = exports.toMongoId = exports.toStringArray = void 0;
|
|
4
4
|
const class_validator_1 = require("class-validator");
|
|
5
5
|
const mongoose_1 = require("mongoose");
|
|
6
6
|
const rest_wrapper_class_1 = require("../models/dtos/wrappers/rest-wrapper.class");
|
|
@@ -29,4 +29,19 @@ const toBoolean = (value) => {
|
|
|
29
29
|
return value === 'true';
|
|
30
30
|
};
|
|
31
31
|
exports.toBoolean = toBoolean;
|
|
32
|
+
const toInt64 = (value) => {
|
|
33
|
+
try {
|
|
34
|
+
const int64Value = BigInt(value);
|
|
35
|
+
const int64Min = BigInt('-9223372036854775808');
|
|
36
|
+
const int64Max = BigInt('9223372036854775807');
|
|
37
|
+
if (int64Value < int64Min || int64Value > int64Max) {
|
|
38
|
+
throw new rest_wrapper_class_1.RESTError('conversion_error', 'Value is out of the 64-bit signed integer range.');
|
|
39
|
+
}
|
|
40
|
+
return int64Value;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw new rest_wrapper_class_1.RESTError('conversion_error_invalid_input', `Invalid input for conversion to Int64: ${error.message}`);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.toInt64 = toInt64;
|
|
32
47
|
//# sourceMappingURL=helper.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.utils.js","sourceRoot":"","sources":["../../src/utils/helper.utils.ts"],"names":[],"mappings":";;;AAAA,qDAA4C;AAC5C,uCAAiC;AACjC,mFAAuE;AAEvE,MAAM,aAAa,GAAG,CAAC,KAAwB,EAAE,EAAE;IAC/C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACvD,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"helper.utils.js","sourceRoot":"","sources":["../../src/utils/helper.utils.ts"],"names":[],"mappings":";;;AAAA,qDAA4C;AAC5C,uCAAiC;AACjC,mFAAuE;AAEvE,MAAM,aAAa,GAAG,CAAC,KAAwB,EAAE,EAAE;IAC/C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACvD,CAAC,CAAC;AAwCO,sCAAa;AAtCtB,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE;IAChC,MAAM,KAAK,GAAG,IAAA,2BAAS,EAAC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C,EAAE,0CAA0C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACrH,CAAC;AACL,CAAC,CAAC;AAE4D,0BAAO"}
|
package/package.json
CHANGED
|
@@ -61,12 +61,16 @@ export class DictionariesService {
|
|
|
61
61
|
throw new RESTError('dictionaries_api_error', 'empty response');
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
if (response.data.result.data) {
|
|
65
|
+
const result: IDictionary = {
|
|
66
|
+
...response.data.result.data,
|
|
67
|
+
_id: new Types.ObjectId(response.data.result.data._id),
|
|
68
|
+
};
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
return result;
|
|
71
|
+
} else {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
70
74
|
} catch (e) {
|
|
71
75
|
throw RESTError.createFromCatch(e, { keyword: 'unknown', debug: e });
|
|
72
76
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformFnParams } from 'class-transformer';
|
|
2
|
-
import { toStringArray, toMongoId, toMongoIdArray, toBoolean } from '../utils/helper.utils';
|
|
2
|
+
import { toStringArray, toMongoId, toMongoIdArray, toBoolean, toInt64 } from '../utils/helper.utils';
|
|
3
3
|
|
|
4
4
|
const stringArray = (params: TransformFnParams) => {
|
|
5
5
|
return toStringArray(params.value);
|
|
@@ -17,11 +17,16 @@ const boolean = (params: TransformFnParams) => {
|
|
|
17
17
|
return toBoolean(params.value);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
const int64 = (params: TransformFnParams) => {
|
|
21
|
+
return toInt64(params.value);
|
|
22
|
+
};
|
|
23
|
+
|
|
20
24
|
const transformers = {
|
|
21
25
|
stringArray,
|
|
22
26
|
mongoId,
|
|
23
27
|
mongoIdArray,
|
|
24
28
|
boolean,
|
|
29
|
+
int64,
|
|
25
30
|
};
|
|
26
31
|
|
|
27
32
|
export { transformers };
|
|
@@ -27,4 +27,21 @@ const toBoolean = (value: string) => {
|
|
|
27
27
|
return value === 'true';
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const toInt64 = (value: string) => {
|
|
31
|
+
try {
|
|
32
|
+
// Convert the string to a BigInt
|
|
33
|
+
const int64Value = BigInt(value);
|
|
34
|
+
|
|
35
|
+
// Ensure it's within the 64-bit integer range
|
|
36
|
+
const int64Min = BigInt('-9223372036854775808');
|
|
37
|
+
const int64Max = BigInt('9223372036854775807');
|
|
38
|
+
if (int64Value < int64Min || int64Value > int64Max) {
|
|
39
|
+
throw new RESTError('conversion_error', 'Value is out of the 64-bit signed integer range.');
|
|
40
|
+
}
|
|
41
|
+
return int64Value;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new RESTError('conversion_error_invalid_input', `Invalid input for conversion to Int64: ${error.message}`);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { toStringArray, toMongoId, toMongoIdArray, toBoolean, toInt64 };
|