@adaas/a-utils 0.1.10 → 0.1.11
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/index.d.mts +914 -0
- package/dist/index.d.ts +914 -27
- package/dist/index.js +1760 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1738 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -3
- package/src/index.ts +70 -0
- package/src/lib/A-Logger/A-Logger.component.ts +10 -3
- package/src/lib/A-Polyfill/A-Polyfill.component.ts +153 -15
- package/src/lib/A-Polyfill/A-Polyfill.types.ts +54 -0
- package/src/lib/A-Polyfill/classes/A-Buffer-Polyfill.class.ts +85 -0
- package/src/lib/A-Polyfill/classes/A-Crypto-Polyfill.class.ts +87 -0
- package/src/lib/A-Polyfill/classes/A-FS-Polyfill.class.ts +61 -0
- package/src/lib/A-Polyfill/classes/A-Http-Polyfill.class.ts +100 -0
- package/src/lib/A-Polyfill/classes/A-Https-Polyfill.class.ts +100 -0
- package/src/lib/A-Polyfill/classes/A-Path-Polyfill.class.ts +97 -0
- package/src/lib/A-Polyfill/classes/A-Process-Polyfill.class.ts +73 -0
- package/src/lib/A-Polyfill/classes/A-Url-Polyfill.class.ts +88 -0
- package/tests/A-Config.test.ts +5 -5
- package/tests/A-Polyfill.test.ts +446 -29
- package/tsconfig.json +1 -1
- package/tsup.config.ts +15 -0
- package/dist/src/constants/errors.constants.d.ts +0 -0
- package/dist/src/constants/errors.constants.js +0 -2
- package/dist/src/constants/errors.constants.js.map +0 -1
- package/dist/src/lib/A-Channel/A-Channel.component.d.ts +0 -22
- package/dist/src/lib/A-Channel/A-Channel.component.js +0 -84
- package/dist/src/lib/A-Channel/A-Channel.component.js.map +0 -1
- package/dist/src/lib/A-Channel/A-Channel.error.d.ts +0 -4
- package/dist/src/lib/A-Channel/A-Channel.error.js +0 -9
- package/dist/src/lib/A-Channel/A-Channel.error.js.map +0 -1
- package/dist/src/lib/A-Channel/A-Channel.types.d.ts +0 -0
- package/dist/src/lib/A-Channel/A-Channel.types.js +0 -2
- package/dist/src/lib/A-Channel/A-Channel.types.js.map +0 -1
- package/dist/src/lib/A-Command/A-Command.constants.d.ts +0 -22
- package/dist/src/lib/A-Command/A-Command.constants.js +0 -28
- package/dist/src/lib/A-Command/A-Command.constants.js.map +0 -1
- package/dist/src/lib/A-Command/A-Command.entity.d.ts +0 -133
- package/dist/src/lib/A-Command/A-Command.entity.js +0 -273
- package/dist/src/lib/A-Command/A-Command.entity.js.map +0 -1
- package/dist/src/lib/A-Command/A-Command.error.d.ts +0 -3
- package/dist/src/lib/A-Command/A-Command.error.js +0 -8
- package/dist/src/lib/A-Command/A-Command.error.js.map +0 -1
- package/dist/src/lib/A-Command/A-Command.types.d.ts +0 -73
- package/dist/src/lib/A-Command/A-Command.types.js +0 -4
- package/dist/src/lib/A-Command/A-Command.types.js.map +0 -1
- package/dist/src/lib/A-Config/A-Config.constants.d.ts +0 -3
- package/dist/src/lib/A-Config/A-Config.constants.js +0 -6
- package/dist/src/lib/A-Config/A-Config.constants.js.map +0 -1
- package/dist/src/lib/A-Config/A-Config.container.d.ts +0 -6
- package/dist/src/lib/A-Config/A-Config.container.js +0 -77
- package/dist/src/lib/A-Config/A-Config.container.js.map +0 -1
- package/dist/src/lib/A-Config/A-Config.context.d.ts +0 -29
- package/dist/src/lib/A-Config/A-Config.context.js +0 -63
- package/dist/src/lib/A-Config/A-Config.context.js.map +0 -1
- package/dist/src/lib/A-Config/A-Config.error.d.ts +0 -4
- package/dist/src/lib/A-Config/A-Config.error.js +0 -9
- package/dist/src/lib/A-Config/A-Config.error.js.map +0 -1
- package/dist/src/lib/A-Config/A-Config.types.d.ts +0 -19
- package/dist/src/lib/A-Config/A-Config.types.js +0 -7
- package/dist/src/lib/A-Config/A-Config.types.js.map +0 -1
- package/dist/src/lib/A-Config/components/ConfigReader.component.d.ts +0 -30
- package/dist/src/lib/A-Config/components/ConfigReader.component.js +0 -103
- package/dist/src/lib/A-Config/components/ConfigReader.component.js.map +0 -1
- package/dist/src/lib/A-Config/components/ENVConfigReader.component.d.ts +0 -14
- package/dist/src/lib/A-Config/components/ENVConfigReader.component.js +0 -72
- package/dist/src/lib/A-Config/components/ENVConfigReader.component.js.map +0 -1
- package/dist/src/lib/A-Config/components/FileConfigReader.component.d.ts +0 -11
- package/dist/src/lib/A-Config/components/FileConfigReader.component.js +0 -47
- package/dist/src/lib/A-Config/components/FileConfigReader.component.js.map +0 -1
- package/dist/src/lib/A-Logger/A-Logger.component.d.ts +0 -29
- package/dist/src/lib/A-Logger/A-Logger.component.js +0 -152
- package/dist/src/lib/A-Logger/A-Logger.component.js.map +0 -1
- package/dist/src/lib/A-Logger/A-Logger.types.d.ts +0 -0
- package/dist/src/lib/A-Logger/A-Logger.types.js +0 -2
- package/dist/src/lib/A-Logger/A-Logger.types.js.map +0 -1
- package/dist/src/lib/A-Manifest/A-Manifest.context.d.ts +0 -52
- package/dist/src/lib/A-Manifest/A-Manifest.context.js +0 -154
- package/dist/src/lib/A-Manifest/A-Manifest.context.js.map +0 -1
- package/dist/src/lib/A-Manifest/A-Manifest.error.d.ts +0 -4
- package/dist/src/lib/A-Manifest/A-Manifest.error.js +0 -9
- package/dist/src/lib/A-Manifest/A-Manifest.error.js.map +0 -1
- package/dist/src/lib/A-Manifest/A-Manifest.types.d.ts +0 -43
- package/dist/src/lib/A-Manifest/A-Manifest.types.js +0 -3
- package/dist/src/lib/A-Manifest/A-Manifest.types.js.map +0 -1
- package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.d.ts +0 -14
- package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.js +0 -24
- package/dist/src/lib/A-Manifest/classes/A-ManifestChecker.class.js.map +0 -1
- package/dist/src/lib/A-Memory/A-Memory.context.d.ts +0 -64
- package/dist/src/lib/A-Memory/A-Memory.context.js +0 -105
- package/dist/src/lib/A-Memory/A-Memory.context.js.map +0 -1
- package/dist/src/lib/A-Polyfill/A-Polyfill.component.d.ts +0 -20
- package/dist/src/lib/A-Polyfill/A-Polyfill.component.js +0 -53
- package/dist/src/lib/A-Polyfill/A-Polyfill.component.js.map +0 -1
- package/dist/src/lib/A-Polyfill/A-Polyfill.types.d.ts +0 -9
- package/dist/src/lib/A-Polyfill/A-Polyfill.types.js +0 -3
- package/dist/src/lib/A-Polyfill/A-Polyfill.types.js.map +0 -1
- package/dist/src/lib/A-Polyfill/A-Polyfills.class.d.ts +0 -11
- package/dist/src/lib/A-Polyfill/A-Polyfills.class.js +0 -123
- package/dist/src/lib/A-Polyfill/A-Polyfills.class.js.map +0 -1
- package/dist/src/lib/A-Schedule/A-Deferred.class.d.ts +0 -12
- package/dist/src/lib/A-Schedule/A-Deferred.class.js +0 -23
- package/dist/src/lib/A-Schedule/A-Deferred.class.js.map +0 -1
- package/dist/src/lib/A-Schedule/A-Schedule.component.d.ts +0 -57
- package/dist/src/lib/A-Schedule/A-Schedule.component.js +0 -49
- package/dist/src/lib/A-Schedule/A-Schedule.component.js.map +0 -1
- package/dist/src/lib/A-Schedule/A-Schedule.types.d.ts +0 -10
- package/dist/src/lib/A-Schedule/A-Schedule.types.js +0 -3
- package/dist/src/lib/A-Schedule/A-Schedule.types.js.map +0 -1
- package/dist/src/lib/A-Schedule/A-ScheduleObject.class.d.ts +0 -29
- package/dist/src/lib/A-Schedule/A-ScheduleObject.class.js +0 -58
- package/dist/src/lib/A-Schedule/A-ScheduleObject.class.js.map +0 -1
- package/index.ts +0 -71
- package/src/lib/A-Polyfill/A-Polyfills.class.ts +0 -99
- package/tsconfig.build.json +0 -56
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.A_Memory = void 0;
|
|
13
|
-
const a_concept_1 = require("@adaas/a-concept");
|
|
14
|
-
class A_Memory extends a_concept_1.A_Fragment {
|
|
15
|
-
/**
|
|
16
|
-
* Memory object that allows to store intermediate values and errors
|
|
17
|
-
*
|
|
18
|
-
* @param initialValues
|
|
19
|
-
*/
|
|
20
|
-
constructor(initialValues) {
|
|
21
|
-
super();
|
|
22
|
-
this._memory = new Map(Object.entries(initialValues || {}));
|
|
23
|
-
this._errors = new Set();
|
|
24
|
-
}
|
|
25
|
-
get Errors() {
|
|
26
|
-
return this._errors.size > 0 ? this._errors : undefined;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Verifies that all required keys are present in the proxy values
|
|
30
|
-
*
|
|
31
|
-
* @param requiredKeys
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
verifyPrerequisites(requiredKeys) {
|
|
35
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
return requiredKeys.every(key => this._memory.has(key));
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Adds an error to the context
|
|
41
|
-
*
|
|
42
|
-
* @param error
|
|
43
|
-
*/
|
|
44
|
-
error(error) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
this._errors.add(error);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Saves a value in the context memory
|
|
51
|
-
*
|
|
52
|
-
* @param key
|
|
53
|
-
* @param value
|
|
54
|
-
*/
|
|
55
|
-
set(
|
|
56
|
-
/**
|
|
57
|
-
* Key to save the value under
|
|
58
|
-
*/
|
|
59
|
-
key,
|
|
60
|
-
/**
|
|
61
|
-
* Value to save
|
|
62
|
-
*/
|
|
63
|
-
value) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
this._memory.set(key, value);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Removes a value from the context memory by key
|
|
70
|
-
*
|
|
71
|
-
* @param key
|
|
72
|
-
*/
|
|
73
|
-
drop(key) {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
this._memory.delete(key);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Clears all stored values in the context memory
|
|
80
|
-
*/
|
|
81
|
-
clear() {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
this._memory.clear();
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Converts all stored values to a plain object
|
|
88
|
-
*
|
|
89
|
-
* [!] By default uses all saved in memory values
|
|
90
|
-
*
|
|
91
|
-
* @returns
|
|
92
|
-
*/
|
|
93
|
-
toJSON() {
|
|
94
|
-
const obj = {};
|
|
95
|
-
this._memory.forEach((value, key) => {
|
|
96
|
-
obj[key] =
|
|
97
|
-
typeof value === 'object' && value !== null && 'toJSON' in value && typeof value.toJSON === 'function'
|
|
98
|
-
? value.toJSON()
|
|
99
|
-
: value;
|
|
100
|
-
});
|
|
101
|
-
return obj;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.A_Memory = A_Memory;
|
|
105
|
-
//# sourceMappingURL=A-Memory.context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-Memory.context.js","sourceRoot":"","sources":["../../../../src/lib/A-Memory/A-Memory.context.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAAuD;AAGvD,MAAa,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,GAAG,CAAC,GAAa,CAAC;gBACd,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,UAAU;oBAClG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;oBAChB,CAAC,CAAC,KAAK,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,OAAO,GAAsB,CAAC;IAClC,CAAC;CACJ;AA/GD,4BA+GC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { A_Component } from "@adaas/a-concept";
|
|
2
|
-
import { A_PolyfillClass } from "./A-Polyfills.class";
|
|
3
|
-
export declare class A_Polyfill extends A_Component {
|
|
4
|
-
protected _polyfill: A_PolyfillClass;
|
|
5
|
-
load(): Promise<void>;
|
|
6
|
-
/**
|
|
7
|
-
* Allows to use the 'fs' polyfill methods regardless of the environment
|
|
8
|
-
* This method loads the 'fs' polyfill and returns its instance
|
|
9
|
-
*
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
fs(): Promise<import("./A-Polyfill.types").Ifspolyfill>;
|
|
13
|
-
/**
|
|
14
|
-
* Allows to use the 'crypto' polyfill methods regardless of the environment
|
|
15
|
-
* This method loads the 'crypto' polyfill and returns its instance
|
|
16
|
-
*
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
crypto(): Promise<import("./A-Polyfill.types").IcryptoInterface>;
|
|
20
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.A_Polyfill = void 0;
|
|
13
|
-
const a_concept_1 = require("@adaas/a-concept");
|
|
14
|
-
const A_Polyfills_class_1 = require("./A-Polyfills.class");
|
|
15
|
-
class A_Polyfill extends a_concept_1.A_Component {
|
|
16
|
-
load() {
|
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
this._polyfill = new A_Polyfills_class_1.A_PolyfillClass();
|
|
19
|
-
yield this._polyfill.fs();
|
|
20
|
-
yield this._polyfill.crypto();
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Allows to use the 'fs' polyfill methods regardless of the environment
|
|
25
|
-
* This method loads the 'fs' polyfill and returns its instance
|
|
26
|
-
*
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
fs() {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
if (!this._polyfill) {
|
|
32
|
-
yield this.load();
|
|
33
|
-
}
|
|
34
|
-
return yield this._polyfill.fs();
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Allows to use the 'crypto' polyfill methods regardless of the environment
|
|
39
|
-
* This method loads the 'crypto' polyfill and returns its instance
|
|
40
|
-
*
|
|
41
|
-
* @returns
|
|
42
|
-
*/
|
|
43
|
-
crypto() {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
if (!this._polyfill) {
|
|
46
|
-
yield this.load();
|
|
47
|
-
}
|
|
48
|
-
return yield this._polyfill.crypto();
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.A_Polyfill = A_Polyfill;
|
|
53
|
-
//# sourceMappingURL=A-Polyfill.component.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-Polyfill.component.js","sourceRoot":"","sources":["../../../../src/lib/A-Polyfill/A-Polyfill.component.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA+C;AAC/C,2DAAsD;AAItD,MAAa,UAAW,SAAQ,uBAAW;IAIjC,IAAI;;YACN,IAAI,CAAC,SAAS,GAAG,IAAI,mCAAe,EAAE,CAAC;YAEvC,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;YAC1B,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QAClC,CAAC;KAAA;IAGD;;;;;OAKG;IACG,EAAE;;YACJ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;gBAClB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACtB,CAAC;YAED,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;QACrC,CAAC;KAAA;IAED;;;;;OAKG;IACG,MAAM;;YACR,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;gBAClB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACtB,CAAC;YAED,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QACzC,CAAC;KAAA;CACJ;AAvCD,gCAuCC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export interface Ifspolyfill {
|
|
2
|
-
readFileSync: (path: string, encoding: string) => string;
|
|
3
|
-
existsSync: (path: string) => boolean;
|
|
4
|
-
createReadStream: (path: string, options?: BufferEncoding) => any;
|
|
5
|
-
}
|
|
6
|
-
export interface IcryptoInterface {
|
|
7
|
-
createTextHash(text: string, algorithm: string): Promise<string>;
|
|
8
|
-
createFileHash(filePath: string, algorithm: string): Promise<string>;
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-Polyfill.types.js","sourceRoot":"","sources":["../../../../src/lib/A-Polyfill/A-Polyfill.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IcryptoInterface, Ifspolyfill } from "./A-Polyfill.types";
|
|
2
|
-
export declare class A_PolyfillClass {
|
|
3
|
-
private _fs;
|
|
4
|
-
private _crypto;
|
|
5
|
-
private fsName;
|
|
6
|
-
private cryptoName;
|
|
7
|
-
fs(): Promise<Ifspolyfill>;
|
|
8
|
-
crypto(): Promise<IcryptoInterface>;
|
|
9
|
-
get env(): 'server' | 'browser';
|
|
10
|
-
private init;
|
|
11
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.A_PolyfillClass = void 0;
|
|
36
|
-
class A_PolyfillClass {
|
|
37
|
-
constructor() {
|
|
38
|
-
// eslint-disable-next-line no-use-before-define
|
|
39
|
-
this.fsName = 'fs';
|
|
40
|
-
this.cryptoName = 'crypto';
|
|
41
|
-
}
|
|
42
|
-
fs() {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
if (!this._fs) {
|
|
45
|
-
yield this.init();
|
|
46
|
-
}
|
|
47
|
-
return this._fs;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
crypto() {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
if (!this._crypto) {
|
|
53
|
-
yield this.init();
|
|
54
|
-
}
|
|
55
|
-
return this._crypto;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
get env() {
|
|
59
|
-
let testEnvironment = 'browser';
|
|
60
|
-
try {
|
|
61
|
-
testEnvironment = window.location ? 'browser' : 'server';
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
testEnvironment = 'server';
|
|
65
|
-
}
|
|
66
|
-
return testEnvironment;
|
|
67
|
-
}
|
|
68
|
-
init() {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
try {
|
|
71
|
-
if (this.env === 'server') {
|
|
72
|
-
// eslint-disable-next-line no-use-before-define
|
|
73
|
-
this._fs = (yield Promise.resolve(`${'' + this.fsName}`).then(s => __importStar(require(s))));
|
|
74
|
-
// eslint-disable-next-line no-use-before-define
|
|
75
|
-
this._crypto = {
|
|
76
|
-
createTextHash: () => Promise.resolve(''),
|
|
77
|
-
createFileHash: (filePath, algorithm = 'sha384') => new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
try {
|
|
79
|
-
const crypto = yield Promise.resolve(`${'' + this.cryptoName}`).then(s => __importStar(require(s)));
|
|
80
|
-
const hash = crypto.createHash(algorithm);
|
|
81
|
-
const fileStream = this._fs.createReadStream(filePath);
|
|
82
|
-
fileStream.on('data', (data) => hash.update(data));
|
|
83
|
-
fileStream.on('end', () => resolve(`${algorithm}-${hash.digest('base64')}`));
|
|
84
|
-
fileStream.on('error', (err) => reject(err));
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
return reject(error);
|
|
88
|
-
}
|
|
89
|
-
}))
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
throw new Error('Not Server Environment');
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
this._fs = {
|
|
98
|
-
readFileSync: (path, encoding) => '',
|
|
99
|
-
existsSync: (path) => false,
|
|
100
|
-
createReadStream: (path) => ''
|
|
101
|
-
};
|
|
102
|
-
this._crypto = {
|
|
103
|
-
createFileHash: () => Promise.resolve(''),
|
|
104
|
-
createTextHash: (text, algorithm = 'SHA-384') => new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
try {
|
|
106
|
-
const encoder = new TextEncoder();
|
|
107
|
-
const data = encoder.encode(text);
|
|
108
|
-
const hashBuffer = yield crypto.subtle.digest(algorithm, data);
|
|
109
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
110
|
-
const hashBase64 = btoa(String.fromCharCode(...hashArray.map(byte => String.fromCharCode(byte))));
|
|
111
|
-
return resolve(`${algorithm}-${hashBase64}`);
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
return reject(error);
|
|
115
|
-
}
|
|
116
|
-
}))
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.A_PolyfillClass = A_PolyfillClass;
|
|
123
|
-
//# sourceMappingURL=A-Polyfills.class.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-Polyfills.class.js","sourceRoot":"","sources":["../../../../src/lib/A-Polyfill/A-Polyfills.class.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAa,eAAe;IAA5B;QAKI,gDAAgD;QACxC,WAAM,GAAG,IAAI,CAAA;QACb,eAAU,GAAG,QAAQ,CAAA;IAuFjC,CAAC;IApFS,EAAE;;YACJ,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;gBACZ,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACtB,CAAC;YACD,OAAO,IAAI,CAAC,GAAG,CAAC;QACpB,CAAC;KAAA;IAEK,MAAM;;YACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAChB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YACtB,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC;QACxB,CAAC;KAAA;IAGD,IAAI,GAAG;QACH,IAAI,eAAe,GAAyB,SAAS,CAAC;QAEtD,IAAI,CAAC;YACD,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;QAE7D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAEb,eAAe,GAAG,QAAQ,CAAC;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AM,CAAC,KAAK,CAAC,CAAC;wBACzB,CAAC;oBACL,CAAC,CAAA,CAAC;iBACL,CAAC;YACN,CAAC;QACL,CAAC;KAAA;CACJ;AA9FD,0CA8FC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare class A_Deferred<T> {
|
|
2
|
-
promise: Promise<T>;
|
|
3
|
-
private resolveFn;
|
|
4
|
-
private rejectFn;
|
|
5
|
-
/**
|
|
6
|
-
* Creates a deferred promise
|
|
7
|
-
* @returns A promise that can be resolved or rejected later
|
|
8
|
-
*/
|
|
9
|
-
constructor();
|
|
10
|
-
resolve(value: T | PromiseLike<T>): void;
|
|
11
|
-
reject(reason?: any): void;
|
|
12
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.A_Deferred = void 0;
|
|
4
|
-
class A_Deferred {
|
|
5
|
-
/**
|
|
6
|
-
* Creates a deferred promise
|
|
7
|
-
* @returns A promise that can be resolved or rejected later
|
|
8
|
-
*/
|
|
9
|
-
constructor() {
|
|
10
|
-
this.promise = new Promise((resolve, reject) => {
|
|
11
|
-
this.resolveFn = resolve;
|
|
12
|
-
this.rejectFn = reject;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
resolve(value) {
|
|
16
|
-
this.resolveFn(value);
|
|
17
|
-
}
|
|
18
|
-
reject(reason) {
|
|
19
|
-
this.rejectFn(reason);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.A_Deferred = A_Deferred;
|
|
23
|
-
//# sourceMappingURL=A-Deferred.class.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-Deferred.class.js","sourceRoot":"","sources":["../../../../src/lib/A-Schedule/A-Deferred.class.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAU;IAKnB;;;OAGG;IACH;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;AAvBD,gCAuBC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { A_Component } from "@adaas/a-concept";
|
|
2
|
-
import { A_ScheduleObject } from "./A-ScheduleObject.class";
|
|
3
|
-
import { A_UTILS_TYPES__ScheduleObjectCallback, A_UTILS_TYPES__ScheduleObjectConfig } from "./A-Schedule.types";
|
|
4
|
-
export declare class A_Schedule extends A_Component {
|
|
5
|
-
/**
|
|
6
|
-
* Allows to schedule a callback for particular time in the future
|
|
7
|
-
*
|
|
8
|
-
* @param timestamp - Unix timestamp in milliseconds
|
|
9
|
-
* @param callback - The callback to execute
|
|
10
|
-
* @returns A promise that resolves to the schedule object
|
|
11
|
-
*/
|
|
12
|
-
schedule<T extends any = any>(
|
|
13
|
-
/**
|
|
14
|
-
* Unix timestamp in milliseconds
|
|
15
|
-
*/
|
|
16
|
-
timestamp: number,
|
|
17
|
-
/**
|
|
18
|
-
* The callback to execute
|
|
19
|
-
*/
|
|
20
|
-
callback: A_UTILS_TYPES__ScheduleObjectCallback<T>,
|
|
21
|
-
/**
|
|
22
|
-
* Configuration options for the schedule object
|
|
23
|
-
*/
|
|
24
|
-
config?: A_UTILS_TYPES__ScheduleObjectConfig): Promise<A_ScheduleObject<T>>;
|
|
25
|
-
schedule<T extends any = any>(
|
|
26
|
-
/**
|
|
27
|
-
* ISO date string representing the date and time to schedule the callback for
|
|
28
|
-
*/
|
|
29
|
-
date: string,
|
|
30
|
-
/**
|
|
31
|
-
* The callback to execute
|
|
32
|
-
*/
|
|
33
|
-
callback: A_UTILS_TYPES__ScheduleObjectCallback<T>,
|
|
34
|
-
/**
|
|
35
|
-
* Configuration options for the schedule object
|
|
36
|
-
*/
|
|
37
|
-
config?: A_UTILS_TYPES__ScheduleObjectConfig): Promise<A_ScheduleObject<T>>;
|
|
38
|
-
/**
|
|
39
|
-
* Allows to execute callback after particular delay in milliseconds
|
|
40
|
-
* So the callback will be executed after the specified delay
|
|
41
|
-
*
|
|
42
|
-
* @param ms
|
|
43
|
-
*/
|
|
44
|
-
delay<T extends any = any>(
|
|
45
|
-
/**
|
|
46
|
-
* Delay in milliseconds
|
|
47
|
-
*/
|
|
48
|
-
ms: number,
|
|
49
|
-
/**
|
|
50
|
-
* The callback to execute after the delay
|
|
51
|
-
*/
|
|
52
|
-
callback: A_UTILS_TYPES__ScheduleObjectCallback<T>,
|
|
53
|
-
/**
|
|
54
|
-
* Configuration options for the schedule object
|
|
55
|
-
*/
|
|
56
|
-
config?: A_UTILS_TYPES__ScheduleObjectConfig): Promise<A_ScheduleObject<T>>;
|
|
57
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.A_Schedule = void 0;
|
|
13
|
-
const a_concept_1 = require("@adaas/a-concept");
|
|
14
|
-
const A_ScheduleObject_class_1 = require("./A-ScheduleObject.class");
|
|
15
|
-
class A_Schedule extends a_concept_1.A_Component {
|
|
16
|
-
schedule(date, callback, config) {
|
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const timestamp = a_concept_1.A_TypeGuards.isString(date)
|
|
19
|
-
? (new Date(date)).getTime()
|
|
20
|
-
: date;
|
|
21
|
-
return new A_ScheduleObject_class_1.A_ScheduleObject(timestamp - Date.now(), callback, config);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Allows to execute callback after particular delay in milliseconds
|
|
26
|
-
* So the callback will be executed after the specified delay
|
|
27
|
-
*
|
|
28
|
-
* @param ms
|
|
29
|
-
*/
|
|
30
|
-
delay(
|
|
31
|
-
/**
|
|
32
|
-
* Delay in milliseconds
|
|
33
|
-
*/
|
|
34
|
-
ms,
|
|
35
|
-
/**
|
|
36
|
-
* The callback to execute after the delay
|
|
37
|
-
*/
|
|
38
|
-
callback,
|
|
39
|
-
/**
|
|
40
|
-
* Configuration options for the schedule object
|
|
41
|
-
*/
|
|
42
|
-
config) {
|
|
43
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
return new A_ScheduleObject_class_1.A_ScheduleObject(ms, callback, config);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.A_Schedule = A_Schedule;
|
|
49
|
-
//# sourceMappingURL=A-Schedule.component.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-Schedule.component.js","sourceRoot":"","sources":["../../../../src/lib/A-Schedule/A-Schedule.component.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA6D;AAC7D,qEAA4D;AAK5D,MAAa,UAAW,SAAQ,uBAAW;IAqCjC,QAAQ,CACV,IAAqB,EACrB,QAAkD,EAClD,MAA4C;;YAG5C,MAAM,SAAS,GAAG,wBAAY,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACzC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE;gBAC5B,CAAC,CAAC,IAAI,CAAC;YAEX,OAAO,IAAI,yCAAgB,CACvB,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,EACtB,QAAQ,EACR,MAAM,CACT,CAAC;QACN,CAAC;KAAA;IAID;;;;;OAKG;IACG,KAAK;IACP;;OAEG;IACH,EAAU;IACV;;OAEG;IACH,QAAkD;IAClD;;MAEE;IACF,MAA4C;;YAE5C,OAAO,IAAI,yCAAgB,CACvB,EAAE,EACF,QAAQ,EACR,MAAM,CACT,CAAC;QACN,CAAC;KAAA;CACJ;AAlFD,gCAkFC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type A_UTILS_TYPES__ScheduleObjectConfig = {
|
|
2
|
-
/**
|
|
3
|
-
* If the timeout is cleared, should the promise resolve or reject?
|
|
4
|
-
* BY Default it rejects
|
|
5
|
-
*
|
|
6
|
-
* !!!NOTE: If the property is set to true, the promise will resolve with undefined
|
|
7
|
-
*/
|
|
8
|
-
resolveOnClear: boolean;
|
|
9
|
-
};
|
|
10
|
-
export type A_UTILS_TYPES__ScheduleObjectCallback<T> = () => Promise<T>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-Schedule.types.js","sourceRoot":"","sources":["../../../../src/lib/A-Schedule/A-Schedule.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { A_UTILS_TYPES__ScheduleObjectCallback, A_UTILS_TYPES__ScheduleObjectConfig } from "./A-Schedule.types";
|
|
2
|
-
export declare class A_ScheduleObject<T extends any = any> {
|
|
3
|
-
private timeout;
|
|
4
|
-
private deferred;
|
|
5
|
-
private config;
|
|
6
|
-
/**
|
|
7
|
-
* Creates a scheduled object that will execute the action after specified milliseconds
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @param ms - milliseconds to wait before executing the action
|
|
11
|
-
* @param action - the action to execute
|
|
12
|
-
* @param config - configuration options for the schedule object
|
|
13
|
-
*/
|
|
14
|
-
constructor(
|
|
15
|
-
/**
|
|
16
|
-
* Milliseconds to wait before executing the action
|
|
17
|
-
*/
|
|
18
|
-
ms: number,
|
|
19
|
-
/**
|
|
20
|
-
* The action to execute after the specified milliseconds
|
|
21
|
-
*/
|
|
22
|
-
action: A_UTILS_TYPES__ScheduleObjectCallback<T>,
|
|
23
|
-
/**
|
|
24
|
-
* Configuration options for the schedule object
|
|
25
|
-
*/
|
|
26
|
-
config?: A_UTILS_TYPES__ScheduleObjectConfig);
|
|
27
|
-
get promise(): Promise<T>;
|
|
28
|
-
clear(): void;
|
|
29
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.A_ScheduleObject = void 0;
|
|
4
|
-
const A_Deferred_class_1 = require("./A-Deferred.class");
|
|
5
|
-
const a_concept_1 = require("@adaas/a-concept");
|
|
6
|
-
class A_ScheduleObject {
|
|
7
|
-
/**
|
|
8
|
-
* Creates a scheduled object that will execute the action after specified milliseconds
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @param ms - milliseconds to wait before executing the action
|
|
12
|
-
* @param action - the action to execute
|
|
13
|
-
* @param config - configuration options for the schedule object
|
|
14
|
-
*/
|
|
15
|
-
constructor(
|
|
16
|
-
/**
|
|
17
|
-
* Milliseconds to wait before executing the action
|
|
18
|
-
*/
|
|
19
|
-
ms,
|
|
20
|
-
/**
|
|
21
|
-
* The action to execute after the specified milliseconds
|
|
22
|
-
*/
|
|
23
|
-
action,
|
|
24
|
-
/**
|
|
25
|
-
* Configuration options for the schedule object
|
|
26
|
-
*/
|
|
27
|
-
config) {
|
|
28
|
-
this.config = {
|
|
29
|
-
/**
|
|
30
|
-
* If the timeout is cleared, should the promise resolve or reject?
|
|
31
|
-
* BY Default it rejects
|
|
32
|
-
*
|
|
33
|
-
* !!!NOTE: If the property is set to true, the promise will resolve with undefined
|
|
34
|
-
*/
|
|
35
|
-
resolveOnClear: false
|
|
36
|
-
};
|
|
37
|
-
if (config)
|
|
38
|
-
this.config = Object.assign(Object.assign({}, this.config), config);
|
|
39
|
-
this.deferred = new A_Deferred_class_1.A_Deferred();
|
|
40
|
-
this.timeout = setTimeout(() => action()
|
|
41
|
-
.then((...args) => this.deferred.resolve(...args))
|
|
42
|
-
.catch((...args) => this.deferred.reject(...args)), ms);
|
|
43
|
-
}
|
|
44
|
-
get promise() {
|
|
45
|
-
return this.deferred.promise;
|
|
46
|
-
}
|
|
47
|
-
clear() {
|
|
48
|
-
if (this.timeout) {
|
|
49
|
-
clearTimeout(this.timeout);
|
|
50
|
-
if (this.config.resolveOnClear)
|
|
51
|
-
this.deferred.resolve(undefined);
|
|
52
|
-
else
|
|
53
|
-
this.deferred.reject(new a_concept_1.A_Error("Timeout Cleared"));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.A_ScheduleObject = A_ScheduleObject;
|
|
58
|
-
//# sourceMappingURL=A-ScheduleObject.class.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-ScheduleObject.class.js","sourceRoot":"","sources":["../../../../src/lib/A-Schedule/A-ScheduleObject.class.ts"],"names":[],"mappings":";;;AAAA,yDAAgD;AAChD,gDAA2C;AAG3C,MAAa,gBAAgB;IAgBzB;;;;;;;OAOG;IACH;IACI;;OAEG;IACH,EAAU;IACV;;OAEG;IACH,MAAgD;IAChD;;OAEG;IACH,MAA4C;QA/BxC,WAAM,GAAwC;YAClD;;;;;eAKG;YACH,cAAc,EAAE,KAAK;SACxB,CAAC;QAyBE,IAAI,MAAM;YACN,IAAI,CAAC,MAAM,mCAAQ,IAAI,CAAC,MAAM,GAAK,MAAM,CAAE,CAAC;QAEhD,IAA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