@adaas/a-utils 0.0.2
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/.nvmrc +1 -0
- package/LICENSE +22 -0
- package/README.md +49 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/src/constants/errors.constants.d.ts +65 -0
- package/dist/src/constants/errors.constants.js +74 -0
- package/dist/src/constants/errors.constants.js.map +1 -0
- package/dist/src/global/ASEID.class.d.ts +77 -0
- package/dist/src/global/ASEID.class.js +129 -0
- package/dist/src/global/ASEID.class.js.map +1 -0
- package/dist/src/global/A_Deferred.class.d.ts +8 -0
- package/dist/src/global/A_Deferred.class.js +19 -0
- package/dist/src/global/A_Deferred.class.js.map +1 -0
- package/dist/src/global/A_Entity.class.d.ts +49 -0
- package/dist/src/global/A_Entity.class.js +94 -0
- package/dist/src/global/A_Entity.class.js.map +1 -0
- package/dist/src/global/A_Error.class.d.ts +13 -0
- package/dist/src/global/A_Error.class.js +54 -0
- package/dist/src/global/A_Error.class.js.map +1 -0
- package/dist/src/global/A_Polyfills.d.ts +21 -0
- package/dist/src/global/A_Polyfills.js +123 -0
- package/dist/src/global/A_Polyfills.js.map +1 -0
- package/dist/src/global/A_ScheduleObject.class.d.ts +9 -0
- package/dist/src/global/A_ScheduleObject.class.js +38 -0
- package/dist/src/global/A_ScheduleObject.class.js.map +1 -0
- package/dist/src/global/A_ServerError.class.d.ts +13 -0
- package/dist/src/global/A_ServerError.class.js +57 -0
- package/dist/src/global/A_ServerError.class.js.map +1 -0
- package/dist/src/helpers/A_Common.helper.d.ts +32 -0
- package/dist/src/helpers/A_Common.helper.js +184 -0
- package/dist/src/helpers/A_Common.helper.js.map +1 -0
- package/dist/src/helpers/A_Schedule.helper.d.ts +6 -0
- package/dist/src/helpers/A_Schedule.helper.js +21 -0
- package/dist/src/helpers/A_Schedule.helper.js.map +1 -0
- package/dist/src/types/ASEID.types.d.ts +65 -0
- package/dist/src/types/ASEID.types.js +5 -0
- package/dist/src/types/ASEID.types.js.map +1 -0
- package/dist/src/types/A_Common.types.d.ts +59 -0
- package/dist/src/types/A_Common.types.js +3 -0
- package/dist/src/types/A_Common.types.js.map +1 -0
- package/dist/src/types/A_Entity.types.d.ts +13 -0
- package/dist/src/types/A_Entity.types.js +4 -0
- package/dist/src/types/A_Entity.types.js.map +1 -0
- package/dist/src/types/A_Error.type.d.ts +7 -0
- package/dist/src/types/A_Error.type.js +3 -0
- package/dist/src/types/A_Error.type.js.map +1 -0
- package/dist/src/types/A_Error.types.d.ts +7 -0
- package/dist/src/types/A_Error.types.js +3 -0
- package/dist/src/types/A_Error.types.js.map +1 -0
- package/dist/src/types/A_ScheduleObject.types.d.ts +9 -0
- package/dist/src/types/A_ScheduleObject.types.js +3 -0
- package/dist/src/types/A_ScheduleObject.types.js.map +1 -0
- package/dist/src/types/A_ServerError.types.d.ts +4 -0
- package/dist/src/types/A_ServerError.types.js +3 -0
- package/dist/src/types/A_ServerError.types.js.map +1 -0
- package/docs/a-logo-docs.png +0 -0
- package/index.ts +64 -0
- package/jest.config.ts +19 -0
- package/package.json +73 -0
- package/src/constants/errors.constants.ts +78 -0
- package/src/global/ASEID.class.ts +208 -0
- package/src/global/A_Deferred.class.ts +20 -0
- package/src/global/A_Entity.class.ts +134 -0
- package/src/global/A_Error.class.ts +75 -0
- package/src/global/A_Polyfills.ts +112 -0
- package/src/global/A_ScheduleObject.class.ts +53 -0
- package/src/global/A_ServerError.class.ts +70 -0
- package/src/helpers/A_Common.helper.ts +229 -0
- package/src/helpers/A_Schedule.helper.ts +25 -0
- package/src/types/ASEID.types.ts +86 -0
- package/src/types/A_Common.types.ts +111 -0
- package/src/types/A_Entity.types.ts +17 -0
- package/src/types/A_Error.types.ts +10 -0
- package/src/types/A_ScheduleObject.types.ts +9 -0
- package/src/types/A_ServerError.types.ts +7 -0
- package/tests/default.test.ts +160 -0
- package/tests/polyfill.test.ts +37 -0
- package/tsconfig.json +58 -0
- package/tslint.json +98 -0
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v20.10.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ADAAS <https://adaas.org>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<img align="left" style="margin-right:40px; margin-bottom:80px;" width="180" height="80" src="./docs/a-logo-docs.png" alt="ADAAS Logo">
|
|
2
|
+
|
|
3
|
+
# A-Utils SDK
|
|
4
|
+
|
|
5
|
+
This package is a set of common utils that can be used across projects related or not related to ADAAS Ecosystem.
|
|
6
|
+
In this package it is possible to find useful features to work with structures, objects and types.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
| LTS | Latest | npm |
|
|
10
|
+
|---------------|----------|---------------------------|
|
|
11
|
+
| v1.0.0 | v1.0.1 | [@adaas/a-utils](https://npm.com) |
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<!-- TABLE OF CONTENTS -->
|
|
15
|
+
## Table of Contents
|
|
16
|
+
|
|
17
|
+
- [About the Project](#overview)
|
|
18
|
+
- [Installation](#installation)
|
|
19
|
+
- [ENV Variables](#environment-variables)
|
|
20
|
+
- [Links](#links)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
|
|
27
|
+
cd /your/project/location
|
|
28
|
+
adf
|
|
29
|
+
npm i @adaas/a-utils
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Environment Variables
|
|
38
|
+
|
|
39
|
+
| Variable Name | Required | Description |
|
|
40
|
+
|---------------|----------|---------------------------|
|
|
41
|
+
| A_NAMESPACE | YES | Your desired Namespace for the project |
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Links
|
|
45
|
+
|
|
46
|
+
- [ADAAS Website](https://adaas.org)
|
|
47
|
+
- [Report Issues](https://github.com/ADAAS-org/adaas-a-utils/issues)
|
|
48
|
+
- [Become Future Creator](https://sso.adaas.org)
|
|
49
|
+
---
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { A_CommonHelper } from './src/helpers/A_Common.helper';
|
|
2
|
+
export { A_ScheduleHelper } from './src/helpers/A_Schedule.helper';
|
|
3
|
+
export { A_Error } from './src/global/A_Error.class';
|
|
4
|
+
export { A_ServerError } from './src/global/A_ServerError.class';
|
|
5
|
+
export { ASEID } from './src/global/ASEID.class';
|
|
6
|
+
export { A_Entity } from './src/global/A_Entity.class';
|
|
7
|
+
export { A_ScheduleObject } from './src/global/A_ScheduleObject.class';
|
|
8
|
+
export { A_Polyfills } from './src/global/A_Polyfills';
|
|
9
|
+
export { A_CONSTANTS__ERROR_CODES } from './src/constants/errors.constants';
|
|
10
|
+
export { A_TYPES__DeepPartial, A_TYPES__Dictionary, A_TYPES__ObjectKeyEnum, A_TYPES__Required, A_TYPES__Paths, A_TYPES__PathsToObject, A_TYPES__UnionToIntersection, A_TYPES__ExtractProperties, A_TYPES__ExtractNested, A_TYPES__NonObjectPaths } from './src/types/A_Common.types';
|
|
11
|
+
export { A_TYPES__IAEntity, A_TYPES__AEntity_JSON } from './src/types/A_Entity.types';
|
|
12
|
+
export { A_TYPES__ScheduleObjectConfig } from './src/types/A_ScheduleObject.types';
|
|
13
|
+
export { A_TYPES__Error } from './src/types/A_Error.types';
|
|
14
|
+
export { A_TYPES__ServerError } from './src/types/A_ServerError.types';
|
|
15
|
+
export { A_TYPES__ASEID_Constructor, A_TYPES__ASEID_ConstructorConfig, A_TYPES__ASEID_JSON } from './src/types/ASEID.types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ====================== EXPORTS ======================
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.A_CONSTANTS__ERROR_CODES = exports.A_Polyfills = exports.A_ScheduleObject = exports.A_Entity = exports.ASEID = exports.A_ServerError = exports.A_Error = exports.A_ScheduleHelper = exports.A_CommonHelper = void 0;
|
|
5
|
+
// --- Helpers ---
|
|
6
|
+
var A_Common_helper_1 = require("./src/helpers/A_Common.helper");
|
|
7
|
+
Object.defineProperty(exports, "A_CommonHelper", { enumerable: true, get: function () { return A_Common_helper_1.A_CommonHelper; } });
|
|
8
|
+
var A_Schedule_helper_1 = require("./src/helpers/A_Schedule.helper");
|
|
9
|
+
Object.defineProperty(exports, "A_ScheduleHelper", { enumerable: true, get: function () { return A_Schedule_helper_1.A_ScheduleHelper; } });
|
|
10
|
+
// --- Global ---
|
|
11
|
+
var A_Error_class_1 = require("./src/global/A_Error.class");
|
|
12
|
+
Object.defineProperty(exports, "A_Error", { enumerable: true, get: function () { return A_Error_class_1.A_Error; } });
|
|
13
|
+
var A_ServerError_class_1 = require("./src/global/A_ServerError.class");
|
|
14
|
+
Object.defineProperty(exports, "A_ServerError", { enumerable: true, get: function () { return A_ServerError_class_1.A_ServerError; } });
|
|
15
|
+
var ASEID_class_1 = require("./src/global/ASEID.class");
|
|
16
|
+
Object.defineProperty(exports, "ASEID", { enumerable: true, get: function () { return ASEID_class_1.ASEID; } });
|
|
17
|
+
var A_Entity_class_1 = require("./src/global/A_Entity.class");
|
|
18
|
+
Object.defineProperty(exports, "A_Entity", { enumerable: true, get: function () { return A_Entity_class_1.A_Entity; } });
|
|
19
|
+
var A_ScheduleObject_class_1 = require("./src/global/A_ScheduleObject.class");
|
|
20
|
+
Object.defineProperty(exports, "A_ScheduleObject", { enumerable: true, get: function () { return A_ScheduleObject_class_1.A_ScheduleObject; } });
|
|
21
|
+
var A_Polyfills_1 = require("./src/global/A_Polyfills");
|
|
22
|
+
Object.defineProperty(exports, "A_Polyfills", { enumerable: true, get: function () { return A_Polyfills_1.A_Polyfills; } });
|
|
23
|
+
// --- Constants ---
|
|
24
|
+
var errors_constants_1 = require("./src/constants/errors.constants");
|
|
25
|
+
Object.defineProperty(exports, "A_CONSTANTS__ERROR_CODES", { enumerable: true, get: function () { return errors_constants_1.A_CONSTANTS__ERROR_CODES; } });
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AAEA,wDAAwD;;;AAGxD,kBAAkB;AAClB,iEAA+D;AAAtD,iHAAA,cAAc,OAAA;AACvB,qEAAmE;AAA1D,qHAAA,gBAAgB,OAAA;AAGzB,iBAAiB;AACjB,4DAAqD;AAA5C,wGAAA,OAAO,OAAA;AAChB,wEAAiE;AAAxD,oHAAA,aAAa,OAAA;AAEtB,wDAAiD;AAAxC,oGAAA,KAAK,OAAA;AACd,8DAAuD;AAA9C,0GAAA,QAAQ,OAAA;AAEjB,8EAAuE;AAA9D,0HAAA,gBAAgB,OAAA;AAIzB,wDAEiC;AAD7B,0GAAA,WAAW,OAAA;AAGf,oBAAoB;AACpB,qEAA4E;AAAnE,4HAAA,wBAAwB,OAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export declare enum A_CONSTANTS__ERROR_CODES {
|
|
2
|
+
INCORRECT_A_ENTITY_CONSTRUCTOR = "ERR-A-Entity-0001",
|
|
3
|
+
INVALID_ASEID = "ERR-ASEID-0001",
|
|
4
|
+
UNEXPECTED_ERROR = "ERR-0001",
|
|
5
|
+
METHOD_NOT_IMPLEMENTED = "ERR-0002",
|
|
6
|
+
ROUTE_NOT_FOUND = "ERR-0003",
|
|
7
|
+
TOKEN_NOT_PROVIDED = "ERR-0004",
|
|
8
|
+
NOT_ALL_PARAMS_WAS_PROVIDED = "ERR-0005",
|
|
9
|
+
CREDENTIALS_NOT_PROVIDED = "ERR-0006",
|
|
10
|
+
CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ = "ERR-0007"
|
|
11
|
+
}
|
|
12
|
+
export declare const A_CONSTANTS__DEFAULT_ERRORS: {
|
|
13
|
+
INCORRECT_A_ENTITY_CONSTRUCTOR: {
|
|
14
|
+
code: A_CONSTANTS__ERROR_CODES;
|
|
15
|
+
description: string;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
INVALID_ASEID: {
|
|
19
|
+
code: A_CONSTANTS__ERROR_CODES;
|
|
20
|
+
description: string;
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
UNEXPECTED_ERROR: {
|
|
24
|
+
serverCode: number;
|
|
25
|
+
code: A_CONSTANTS__ERROR_CODES;
|
|
26
|
+
description: string;
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
METHOD_NOT_IMPLEMENTED: {
|
|
30
|
+
serverCode: number;
|
|
31
|
+
code: A_CONSTANTS__ERROR_CODES;
|
|
32
|
+
description: string;
|
|
33
|
+
message: string;
|
|
34
|
+
link: string;
|
|
35
|
+
};
|
|
36
|
+
ROUTE_NOT_FOUND: {
|
|
37
|
+
serverCode: number;
|
|
38
|
+
code: A_CONSTANTS__ERROR_CODES;
|
|
39
|
+
description: string;
|
|
40
|
+
message: string;
|
|
41
|
+
};
|
|
42
|
+
TOKEN_NOT_PROVIDED: {
|
|
43
|
+
serverCode: number;
|
|
44
|
+
code: A_CONSTANTS__ERROR_CODES;
|
|
45
|
+
description: string;
|
|
46
|
+
message: string;
|
|
47
|
+
};
|
|
48
|
+
NOT_ALL_PARAMS_WAS_PROVIDED: {
|
|
49
|
+
serverCode: number;
|
|
50
|
+
code: A_CONSTANTS__ERROR_CODES;
|
|
51
|
+
description: string;
|
|
52
|
+
message: string;
|
|
53
|
+
};
|
|
54
|
+
CREDENTIALS_NOT_PROVIDED: {
|
|
55
|
+
code: A_CONSTANTS__ERROR_CODES;
|
|
56
|
+
description: string;
|
|
57
|
+
message: string;
|
|
58
|
+
};
|
|
59
|
+
CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ: {
|
|
60
|
+
serverCode: number;
|
|
61
|
+
code: A_CONSTANTS__ERROR_CODES;
|
|
62
|
+
description: string;
|
|
63
|
+
message: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.A_CONSTANTS__DEFAULT_ERRORS = exports.A_CONSTANTS__ERROR_CODES = void 0;
|
|
4
|
+
var A_CONSTANTS__ERROR_CODES;
|
|
5
|
+
(function (A_CONSTANTS__ERROR_CODES) {
|
|
6
|
+
// Default Utils Errors
|
|
7
|
+
A_CONSTANTS__ERROR_CODES["INCORRECT_A_ENTITY_CONSTRUCTOR"] = "ERR-A-Entity-0001";
|
|
8
|
+
A_CONSTANTS__ERROR_CODES["INVALID_ASEID"] = "ERR-ASEID-0001";
|
|
9
|
+
A_CONSTANTS__ERROR_CODES["UNEXPECTED_ERROR"] = "ERR-0001";
|
|
10
|
+
A_CONSTANTS__ERROR_CODES["METHOD_NOT_IMPLEMENTED"] = "ERR-0002";
|
|
11
|
+
A_CONSTANTS__ERROR_CODES["ROUTE_NOT_FOUND"] = "ERR-0003";
|
|
12
|
+
A_CONSTANTS__ERROR_CODES["TOKEN_NOT_PROVIDED"] = "ERR-0004";
|
|
13
|
+
A_CONSTANTS__ERROR_CODES["NOT_ALL_PARAMS_WAS_PROVIDED"] = "ERR-0005";
|
|
14
|
+
A_CONSTANTS__ERROR_CODES["CREDENTIALS_NOT_PROVIDED"] = "ERR-0006";
|
|
15
|
+
A_CONSTANTS__ERROR_CODES["CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ"] = "ERR-0007";
|
|
16
|
+
})(A_CONSTANTS__ERROR_CODES || (exports.A_CONSTANTS__ERROR_CODES = A_CONSTANTS__ERROR_CODES = {}));
|
|
17
|
+
;
|
|
18
|
+
exports.A_CONSTANTS__DEFAULT_ERRORS = {
|
|
19
|
+
// Default A-Utils Errors
|
|
20
|
+
INCORRECT_A_ENTITY_CONSTRUCTOR: {
|
|
21
|
+
code: A_CONSTANTS__ERROR_CODES.INCORRECT_A_ENTITY_CONSTRUCTOR,
|
|
22
|
+
description: 'The A_Entity constructor was called with incorrect parameters.',
|
|
23
|
+
message: 'Incorrect A_Entity constructor parameters.'
|
|
24
|
+
},
|
|
25
|
+
INVALID_ASEID: {
|
|
26
|
+
code: A_CONSTANTS__ERROR_CODES.INVALID_ASEID,
|
|
27
|
+
description: 'The provided ASEID is invalid.',
|
|
28
|
+
message: 'Invalid ASEID provided.'
|
|
29
|
+
},
|
|
30
|
+
// Default Utils Server Errors
|
|
31
|
+
UNEXPECTED_ERROR: {
|
|
32
|
+
serverCode: 500,
|
|
33
|
+
code: A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR,
|
|
34
|
+
description: 'If you see this error please let us know.',
|
|
35
|
+
message: 'Oops... Something went wrong',
|
|
36
|
+
},
|
|
37
|
+
METHOD_NOT_IMPLEMENTED: {
|
|
38
|
+
serverCode: 500,
|
|
39
|
+
code: A_CONSTANTS__ERROR_CODES.METHOD_NOT_IMPLEMENTED,
|
|
40
|
+
description: 'If you see this error please let us know.',
|
|
41
|
+
message: 'Oops... Something went wrong',
|
|
42
|
+
link: 'https://support.adaas.org/error/' + A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR
|
|
43
|
+
},
|
|
44
|
+
ROUTE_NOT_FOUND: {
|
|
45
|
+
serverCode: 404,
|
|
46
|
+
code: A_CONSTANTS__ERROR_CODES.ROUTE_NOT_FOUND,
|
|
47
|
+
description: 'We can not find the route you\'re looking for. Please make sure that you\'re using the correct path.',
|
|
48
|
+
message: 'The target route is not found.'
|
|
49
|
+
},
|
|
50
|
+
TOKEN_NOT_PROVIDED: {
|
|
51
|
+
serverCode: 401,
|
|
52
|
+
code: A_CONSTANTS__ERROR_CODES.TOKEN_NOT_PROVIDED,
|
|
53
|
+
description: 'The token is missed in the Authorization header. Please make sure that it\'s presented.',
|
|
54
|
+
message: 'Token has not found in the authorization header.'
|
|
55
|
+
},
|
|
56
|
+
NOT_ALL_PARAMS_WAS_PROVIDED: {
|
|
57
|
+
serverCode: 409,
|
|
58
|
+
code: A_CONSTANTS__ERROR_CODES.NOT_ALL_PARAMS_WAS_PROVIDED,
|
|
59
|
+
description: 'Not all required params provided in the request',
|
|
60
|
+
message: 'Conflict in request'
|
|
61
|
+
},
|
|
62
|
+
CREDENTIALS_NOT_PROVIDED: {
|
|
63
|
+
code: A_CONSTANTS__ERROR_CODES.CREDENTIALS_NOT_PROVIDED,
|
|
64
|
+
description: 'The credentials are missed. Please make sure that they are presented.',
|
|
65
|
+
message: 'Credentials has not found in the request.'
|
|
66
|
+
},
|
|
67
|
+
CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ: {
|
|
68
|
+
serverCode: 403,
|
|
69
|
+
code: A_CONSTANTS__ERROR_CODES.CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ,
|
|
70
|
+
description: 'The configuration property is not exists or not allowed to read.',
|
|
71
|
+
message: 'Configuration property is not exists or not allowed to read.'
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=errors.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.constants.js","sourceRoot":"","sources":["../../../src/constants/errors.constants.ts"],"names":[],"mappings":";;;AACA,IAAY,wBAaX;AAbD,WAAY,wBAAwB;IAChC,wBAAwB;IACxB,gFAAoD,CAAA;IACpD,4DAAgC,CAAA;IAGhC,yDAA6B,CAAA;IAC7B,+DAAmC,CAAA;IACnC,wDAA4B,CAAA;IAC5B,2DAA+B,CAAA;IAC/B,oEAAwC,CAAA;IACxC,iEAAqC,CAAA;IACrC,iGAAqE,CAAA;AACzE,CAAC,EAbW,wBAAwB,wCAAxB,wBAAwB,QAanC;AAAA,CAAC;AAGW,QAAA,2BAA2B,GAAG;IACvC,yBAAyB;IACzB,8BAA8B,EAAE;QAC5B,IAAI,EAAE,wBAAwB,CAAC,8BAA8B;QAC7D,WAAW,EAAE,gEAAgE;QAC7E,OAAO,EAAE,4CAA4C;KACxD;IACD,aAAa,EAAE;QACX,IAAI,EAAE,wBAAwB,CAAC,aAAa;QAC5C,WAAW,EAAE,gCAAgC;QAC7C,OAAO,EAAE,yBAAyB;KACrC;IAGD,8BAA8B;IAC9B,gBAAgB,EAAE;QACd,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,wBAAwB,CAAC,gBAAgB;QAC/C,WAAW,EAAE,2CAA2C;QACxD,OAAO,EAAE,8BAA8B;KAC1C;IACD,sBAAsB,EAAE;QACpB,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,wBAAwB,CAAC,sBAAsB;QACrD,WAAW,EAAE,2CAA2C;QACxD,OAAO,EAAE,8BAA8B;QACvC,IAAI,EAAE,kCAAkC,GAAG,wBAAwB,CAAC,gBAAgB;KACvF;IACD,eAAe,EAAE;QACb,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,wBAAwB,CAAC,eAAe;QAC9C,WAAW,EAAE,sGAAsG;QACnH,OAAO,EAAE,gCAAgC;KAC5C;IACD,kBAAkB,EAAE;QAChB,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,wBAAwB,CAAC,kBAAkB;QACjD,WAAW,EAAE,yFAAyF;QACtG,OAAO,EAAE,kDAAkD;KAC9D;IACD,2BAA2B,EAAE;QACzB,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,wBAAwB,CAAC,2BAA2B;QAC1D,WAAW,EAAE,iDAAiD;QAC9D,OAAO,EAAE,qBAAqB;KACjC;IACD,wBAAwB,EAAE;QACtB,IAAI,EAAE,wBAAwB,CAAC,wBAAwB;QACvD,WAAW,EAAE,uEAAuE;QACpF,OAAO,EAAE,2CAA2C;KACvD;IACD,wDAAwD,EAAE;QACtD,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,wBAAwB,CAAC,wDAAwD;QACvF,WAAW,EAAE,kEAAkE;QAC/E,OAAO,EAAE,8DAA8D;KAC1E;CAIJ,CAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { A_TYPES__ASEID_Constructor, A_TYPES__ASEID_JSON } from "../types/ASEID.types";
|
|
2
|
+
/**
|
|
3
|
+
* A - ADAAS
|
|
4
|
+
* S - System
|
|
5
|
+
* E - Entity
|
|
6
|
+
* I - Identifier
|
|
7
|
+
* D - iDentifier
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* adaas-sso@scope:usr:0000000001
|
|
11
|
+
*
|
|
12
|
+
* APP_NAMESPACE + @ + SCOPE + : ENTITY_NAME + : + ID + @ + VERSION
|
|
13
|
+
*/
|
|
14
|
+
export declare class ASEID {
|
|
15
|
+
static regexp: RegExp;
|
|
16
|
+
/**
|
|
17
|
+
* Namespace for the ASEID
|
|
18
|
+
* Generally it is the application name or code, should correspond to the namespace of the application
|
|
19
|
+
* Could be ID or ASEID
|
|
20
|
+
*/
|
|
21
|
+
private _namespace;
|
|
22
|
+
/**
|
|
23
|
+
* Entity Scope the primary location of the resource
|
|
24
|
+
* Organization, or organization Unit
|
|
25
|
+
* Could be ID or ASEID
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
private _scope;
|
|
29
|
+
/**
|
|
30
|
+
* Entity Type the type of the resource
|
|
31
|
+
*/
|
|
32
|
+
private _entity;
|
|
33
|
+
/**
|
|
34
|
+
* Entity ID the unique identifier of the resource
|
|
35
|
+
*/
|
|
36
|
+
private _id;
|
|
37
|
+
/**
|
|
38
|
+
* Version of the entity (optional)
|
|
39
|
+
*/
|
|
40
|
+
private _version?;
|
|
41
|
+
/**
|
|
42
|
+
* Shard of the entity (optional)
|
|
43
|
+
*/
|
|
44
|
+
private _shard?;
|
|
45
|
+
constructor(aseid: string);
|
|
46
|
+
constructor(props: A_TYPES__ASEID_Constructor);
|
|
47
|
+
get namespace(): string;
|
|
48
|
+
get scope(): string;
|
|
49
|
+
get entity(): string;
|
|
50
|
+
get id(): string;
|
|
51
|
+
get version(): string | undefined;
|
|
52
|
+
get shard(): string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Tests if the identity string is an ASEID
|
|
55
|
+
*
|
|
56
|
+
* @param identity
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
static isASEID(identity: string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Generate an ASEID from a namespace, entity, and id
|
|
62
|
+
*
|
|
63
|
+
* @param props
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
static generateASEID(props: A_TYPES__ASEID_Constructor): string;
|
|
67
|
+
/**
|
|
68
|
+
* Parse ASEID into its components
|
|
69
|
+
*
|
|
70
|
+
*
|
|
71
|
+
* @param identity
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
static parseASEID(identity: string): A_TYPES__ASEID_JSON;
|
|
75
|
+
toString(): string;
|
|
76
|
+
toJSON(): A_TYPES__ASEID_JSON;
|
|
77
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ASEID = void 0;
|
|
4
|
+
const errors_constants_1 = require("../constants/errors.constants");
|
|
5
|
+
const A_Common_helper_1 = require("../helpers/A_Common.helper");
|
|
6
|
+
const A_Error_class_1 = require("./A_Error.class");
|
|
7
|
+
/**
|
|
8
|
+
* A - ADAAS
|
|
9
|
+
* S - System
|
|
10
|
+
* E - Entity
|
|
11
|
+
* I - Identifier
|
|
12
|
+
* D - iDentifier
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
* adaas-sso@scope:usr:0000000001
|
|
16
|
+
*
|
|
17
|
+
* APP_NAMESPACE + @ + SCOPE + : ENTITY_NAME + : + ID + @ + VERSION
|
|
18
|
+
*/
|
|
19
|
+
class ASEID {
|
|
20
|
+
constructor(param1) {
|
|
21
|
+
if (typeof param1 === 'string' && !ASEID.isASEID(param1)) {
|
|
22
|
+
throw new A_Error_class_1.A_Error(errors_constants_1.A_CONSTANTS__DEFAULT_ERRORS.INVALID_ASEID);
|
|
23
|
+
}
|
|
24
|
+
const aseidString = typeof param1 === 'string' ? param1 : ASEID.generateASEID(param1);
|
|
25
|
+
const { namespace, scope, entity, id, version, shard } = ASEID.parseASEID(aseidString);
|
|
26
|
+
this._namespace = namespace;
|
|
27
|
+
this._scope = scope;
|
|
28
|
+
this._entity = entity;
|
|
29
|
+
this._id = id;
|
|
30
|
+
this._version = version;
|
|
31
|
+
this._shard = shard;
|
|
32
|
+
}
|
|
33
|
+
get namespace() {
|
|
34
|
+
return this._namespace;
|
|
35
|
+
}
|
|
36
|
+
get scope() {
|
|
37
|
+
return this._scope;
|
|
38
|
+
}
|
|
39
|
+
get entity() {
|
|
40
|
+
return this._entity;
|
|
41
|
+
}
|
|
42
|
+
get id() {
|
|
43
|
+
return this._id;
|
|
44
|
+
}
|
|
45
|
+
get version() {
|
|
46
|
+
return this._version;
|
|
47
|
+
}
|
|
48
|
+
get shard() {
|
|
49
|
+
return this._shard;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Tests if the identity string is an ASEID
|
|
53
|
+
*
|
|
54
|
+
* @param identity
|
|
55
|
+
* @returns
|
|
56
|
+
*/
|
|
57
|
+
static isASEID(identity) {
|
|
58
|
+
return this.regexp.test(identity);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generate an ASEID from a namespace, entity, and id
|
|
62
|
+
*
|
|
63
|
+
* @param props
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
static generateASEID(props) {
|
|
67
|
+
const namespace = props.namespace
|
|
68
|
+
? this.isASEID(props.namespace)
|
|
69
|
+
? this.parseASEID(props.namespace).id
|
|
70
|
+
: props.namespace
|
|
71
|
+
: process.env.A_NAMESPACE;
|
|
72
|
+
const scope = typeof props.scope === 'number'
|
|
73
|
+
? A_Common_helper_1.A_CommonHelper.formatWithLeadingZeros(props.scope) :
|
|
74
|
+
this.isASEID(props.scope)
|
|
75
|
+
? this.parseASEID(props.scope).id
|
|
76
|
+
: props.scope;
|
|
77
|
+
const entity = props.entity;
|
|
78
|
+
const id = typeof props.id === 'number'
|
|
79
|
+
? A_Common_helper_1.A_CommonHelper.formatWithLeadingZeros(props.id)
|
|
80
|
+
: props.id;
|
|
81
|
+
const version = props.version;
|
|
82
|
+
const shard = !props.shard ? undefined : props.shard;
|
|
83
|
+
return `${namespace}@${scope}:${entity}:${shard ? (shard + '--' + id) : id}${version ? ('@' + version) : ''}`;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Parse ASEID into its components
|
|
87
|
+
*
|
|
88
|
+
*
|
|
89
|
+
* @param identity
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
static parseASEID(identity) {
|
|
93
|
+
const [namespace, body, version] = identity.split('@');
|
|
94
|
+
const [scope, entity, idCandidate] = body.split(':');
|
|
95
|
+
const shard = idCandidate.includes('--') ? idCandidate.split('--')[0] : undefined;
|
|
96
|
+
const id = idCandidate.includes('--') ? idCandidate.split('--')[1] : idCandidate;
|
|
97
|
+
return {
|
|
98
|
+
namespace,
|
|
99
|
+
scope: scope,
|
|
100
|
+
entity,
|
|
101
|
+
id: id,
|
|
102
|
+
version: version ? version : undefined,
|
|
103
|
+
shard
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
toString() {
|
|
107
|
+
return ASEID.generateASEID({
|
|
108
|
+
namespace: this._namespace,
|
|
109
|
+
scope: this._scope,
|
|
110
|
+
entity: this._entity,
|
|
111
|
+
id: this._id,
|
|
112
|
+
version: this._version,
|
|
113
|
+
shard: this._shard
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
toJSON() {
|
|
117
|
+
return {
|
|
118
|
+
namespace: this._namespace,
|
|
119
|
+
scope: this._scope,
|
|
120
|
+
entity: this._entity,
|
|
121
|
+
id: this._id,
|
|
122
|
+
version: this._version,
|
|
123
|
+
shard: this._shard
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.ASEID = ASEID;
|
|
128
|
+
ASEID.regexp = new RegExp(`^[a-z|A-Z|0-9]+@[a-z|A-Z|0-9|-]+:[a-z|A-Z]+:[a-z|A-Z|0-9|-]+(@v[0-9]+|@lts)?$`);
|
|
129
|
+
//# sourceMappingURL=ASEID.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ASEID.class.js","sourceRoot":"","sources":["../../../src/global/AS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AC,MAAM;SACrB,CAAC,CAAA;IACN,CAAC;IAGD,MAAM;QACF,OAAO;YACH,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,EAAE,EAAE,IAAI,CAAC,GAAG;YACZ,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,KAAK,EAAE,IAAI,CAAC,MAAM;SACrB,CAAA;IACL,CAAC;;AA5LL,sBA6LC;AA3LU,YAAM,GAAW,IAAI,MAAM,CAAC,+EAA+E,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.A_Deferred = void 0;
|
|
4
|
+
class A_Deferred {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.promise = new Promise((resolve, reject) => {
|
|
7
|
+
this.resolveFn = resolve;
|
|
8
|
+
this.rejectFn = reject;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
resolve(value) {
|
|
12
|
+
this.resolveFn(value);
|
|
13
|
+
}
|
|
14
|
+
reject(reason) {
|
|
15
|
+
this.rejectFn(reason);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.A_Deferred = A_Deferred;
|
|
19
|
+
//# sourceMappingURL=A_Deferred.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"A_Deferred.class.js","sourceRoot":"","sources":["../../../src/global/A_Deferred.class.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAU;IAKnB;QACI,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;YACzB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;QAC3B,CAAC,CAAC,CAAC;IACP,CAAC;IAED,OAAO,CAAC,KAAyB;QAC7B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,MAAY;QACf,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;CACJ;AAnBD,gCAmBC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { A_TYPES__AEntity_JSON, A_TYPES__IAEntity } from "../types/A_Entity.types";
|
|
2
|
+
import { ASEID } from "./ASEID.class";
|
|
3
|
+
export declare class A_Entity<_ConstructorType = any, _SerializedType extends A_TYPES__AEntity_JSON = A_TYPES__AEntity_JSON> implements A_TYPES__IAEntity {
|
|
4
|
+
aseid: ASEID;
|
|
5
|
+
constructor(aseid: string);
|
|
6
|
+
constructor(aseid: ASEID);
|
|
7
|
+
constructor(serialized: _SerializedType);
|
|
8
|
+
constructor(newEntity: _ConstructorType);
|
|
9
|
+
/**
|
|
10
|
+
* Extracts the ID from the ASEID
|
|
11
|
+
* ID is the unique identifier of the entity
|
|
12
|
+
*/
|
|
13
|
+
get id(): string | number;
|
|
14
|
+
/**
|
|
15
|
+
* Extracts the namespace from the ASEID
|
|
16
|
+
* namespace is an application specific identifier from where the entity is coming from
|
|
17
|
+
*/
|
|
18
|
+
get namespace(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Extracts the scope from the ASEID
|
|
21
|
+
* scope is the scope of the entity from Application Namespace
|
|
22
|
+
*/
|
|
23
|
+
get scope(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Extracts the entity from the ASEID
|
|
26
|
+
* entity is the name of the entity from Application Namespace
|
|
27
|
+
*/
|
|
28
|
+
get entity(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Extracts the version from the ASEID
|
|
31
|
+
* version is the version of the entity
|
|
32
|
+
*/
|
|
33
|
+
get version(): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Extracts the shard from the ASEID
|
|
36
|
+
* shard is the shard of the entity
|
|
37
|
+
*/
|
|
38
|
+
get shard(): string | undefined;
|
|
39
|
+
protected fromNewEntity(newEntity: _ConstructorType): void;
|
|
40
|
+
protected fromSerialized(serialized: _SerializedType): void;
|
|
41
|
+
/**
|
|
42
|
+
* Converts the entity to a JSON object
|
|
43
|
+
*
|
|
44
|
+
*
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
toJSON(): _SerializedType;
|
|
48
|
+
toString(): string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.A_Entity = void 0;
|
|
4
|
+
const errors_constants_1 = require("../constants/errors.constants");
|
|
5
|
+
const A_Error_class_1 = require("./A_Error.class");
|
|
6
|
+
const ASEID_class_1 = require("./ASEID.class");
|
|
7
|
+
class A_Entity {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
switch (true) {
|
|
10
|
+
case (typeof props === 'string' && ASEID_class_1.ASEID.isASEID(props)):
|
|
11
|
+
this.aseid = new ASEID_class_1.ASEID(props);
|
|
12
|
+
break;
|
|
13
|
+
case (props instanceof ASEID_class_1.ASEID):
|
|
14
|
+
this.aseid = props;
|
|
15
|
+
break;
|
|
16
|
+
case (typeof props === 'object' && props.aseid):
|
|
17
|
+
this.fromSerialized(props);
|
|
18
|
+
break;
|
|
19
|
+
case (typeof props === 'object'):
|
|
20
|
+
this.fromNewEntity(props);
|
|
21
|
+
break;
|
|
22
|
+
default:
|
|
23
|
+
throw new A_Error_class_1.A_Error(errors_constants_1.A_CONSTANTS__DEFAULT_ERRORS.INCORRECT_A_ENTITY_CONSTRUCTOR);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// ====================================================================
|
|
27
|
+
// ================== DUPLICATED ASEID Getters ========================
|
|
28
|
+
// ====================================================================
|
|
29
|
+
/**
|
|
30
|
+
* Extracts the ID from the ASEID
|
|
31
|
+
* ID is the unique identifier of the entity
|
|
32
|
+
*/
|
|
33
|
+
get id() {
|
|
34
|
+
return this.aseid.id;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Extracts the namespace from the ASEID
|
|
38
|
+
* namespace is an application specific identifier from where the entity is coming from
|
|
39
|
+
*/
|
|
40
|
+
get namespace() {
|
|
41
|
+
return this.aseid.namespace;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Extracts the scope from the ASEID
|
|
45
|
+
* scope is the scope of the entity from Application Namespace
|
|
46
|
+
*/
|
|
47
|
+
get scope() {
|
|
48
|
+
return this.aseid.scope;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Extracts the entity from the ASEID
|
|
52
|
+
* entity is the name of the entity from Application Namespace
|
|
53
|
+
*/
|
|
54
|
+
get entity() {
|
|
55
|
+
return this.aseid.entity;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Extracts the version from the ASEID
|
|
59
|
+
* version is the version of the entity
|
|
60
|
+
*/
|
|
61
|
+
get version() {
|
|
62
|
+
return this.aseid.version;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Extracts the shard from the ASEID
|
|
66
|
+
* shard is the shard of the entity
|
|
67
|
+
*/
|
|
68
|
+
get shard() {
|
|
69
|
+
return this.aseid.shard;
|
|
70
|
+
}
|
|
71
|
+
fromNewEntity(newEntity) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
fromSerialized(serialized) {
|
|
75
|
+
this.aseid = new ASEID_class_1.ASEID((serialized).aseid);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Converts the entity to a JSON object
|
|
80
|
+
*
|
|
81
|
+
*
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
toJSON() {
|
|
85
|
+
return {
|
|
86
|
+
aseid: this.aseid.toString()
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
toString() {
|
|
90
|
+
return this.aseid.toString();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.A_Entity = A_Entity;
|
|
94
|
+
//# sourceMappingURL=A_Entity.class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"A_Entity.class.js","sourceRoot":"","sources":["../../../src/global/A_Entity.class.ts"],"names":[],"mappings":";;;AAAA,oEAA4E;AAK5E,mDAA0C;AAC1C,+CAAsC;AAEtC,MAAa,QAAQ;IAqBjB,YAAY,KAA0D;QAElE,QAAQ,IAAI,EAAE,CAAC;YACX,KAAK,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,mBAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACpD,IAAI,CAAC,KAAK,GAAG,IAAI,mBAAK,CAAC,KAAK,CAAC,CAAC;gBAC9B,MAAM;YACV,KAAK,CAAC,KAAK,YAAY,mBAAK,CAAC;gBACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;gBACnB,MAAM;YACV,KAAK,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAK,KAAa,CAAC,KAAK,CAAC;gBACpD,IAAI,CAAC,cAAc,CAAC,KAAwB,CAAC,CAAC;gBAC9C,MAAM;YAEV,KAAK,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;gBAC5B,IAAI,CAAC,aAAa,CAAC,KAAyB,CAAC,CAAC;gBAC9C,MAAK;YAET;gBACI,MAAM,IAAI,uBAAO,CAAC,8CAA2B,CAAC,8BAA8B,CAAC,CAAC;QACtF,CAAC;IAEL,CAAC;IAED,uEAAuE;IACvE,uEAAuE;IACvE,uEAAuE;IAEvE;;;OAGG;IACH,IAAI,EAAE;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAA;IAC/B,CAAC;IAED;;;OAGG;IACH,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,KAA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