@nest-yalc-2/utils 1.0.0 → 2.0.0
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/package.json +1 -1
- package/src/__tests__/object-mapper.helper.spec.ts +1 -1
- package/src/__tests__/object-mapper.interceptor.spec.ts +1 -1
- package/src/index.d.ts +1 -19
- package/src/index.js +4 -35
- package/src/index.js.map +1 -1
- package/src/index.ts +1 -21
- package/src/object-mapper.interceptor.d.ts +1 -1
- package/src/object-mapper.interceptor.js +3 -8
- package/src/object-mapper.interceptor.js.map +1 -1
- package/src/object-mapper.interceptor.ts +1 -1
- package/src/simple-mapper.interceptor.js +2 -7
- package/src/simple-mapper.interceptor.js.map +1 -1
- package/src/__mocks__/enum.mock.ts +0 -9
- package/src/__tests__/class.helper.spec.ts +0 -32
- package/src/__tests__/command.helper.spec.ts +0 -35
- package/src/__tests__/config-manager.helper.spec.ts +0 -93
- package/src/__tests__/custom-validator.spec.ts +0 -34
- package/src/__tests__/data-structure.helper.spec.ts +0 -30
- package/src/__tests__/date.helper.spec.ts +0 -78
- package/src/__tests__/encryption.helper.spec.ts +0 -45
- package/src/__tests__/enum.helper.spec.ts +0 -53
- package/src/__tests__/env.helper.spec.ts +0 -68
- package/src/__tests__/error.helper.spec.ts +0 -20
- package/src/__tests__/faker-helper.spec.ts +0 -187
- package/src/__tests__/files.helper.spec.ts +0 -22
- package/src/__tests__/http.helper.spec.ts +0 -15
- package/src/__tests__/interval.helper.spec.ts +0 -29
- package/src/__tests__/math.helper.spec.ts +0 -24
- package/src/__tests__/object.helper.spec.ts +0 -181
- package/src/__tests__/plugin.helper.spec.ts +0 -85
- package/src/__tests__/promise.helper.spec.ts +0 -76
- package/src/__tests__/returnValue.spec.ts +0 -49
- package/src/__tests__/rxjs.helper.spec.ts +0 -79
- package/src/__tests__/tsconfig.json +0 -3
- package/src/__tests__/validator-helper.spec.ts +0 -34
- package/src/__tests__/zlib.helper.spec.ts +0 -20
- package/src/class.helper.d.ts +0 -4
- package/src/class.helper.js +0 -19
- package/src/class.helper.js.map +0 -1
- package/src/class.helper.ts +0 -33
- package/src/command.helper.d.ts +0 -1
- package/src/command.helper.js +0 -16
- package/src/command.helper.js.map +0 -1
- package/src/command.helper.ts +0 -19
- package/src/config-manager.helper.d.ts +0 -12
- package/src/config-manager.helper.js +0 -60
- package/src/config-manager.helper.js.map +0 -1
- package/src/config-manager.helper.ts +0 -122
- package/src/custom-validator.d.ts +0 -3
- package/src/custom-validator.js +0 -13
- package/src/custom-validator.js.map +0 -1
- package/src/custom-validator.ts +0 -13
- package/src/data-structure.helper.d.ts +0 -1
- package/src/data-structure.helper.js +0 -13
- package/src/data-structure.helper.js.map +0 -1
- package/src/data-structure.helper.ts +0 -14
- package/src/date.helper.d.ts +0 -12
- package/src/date.helper.js +0 -47
- package/src/date.helper.js.map +0 -1
- package/src/date.helper.ts +0 -65
- package/src/encryption.helper.d.ts +0 -2
- package/src/encryption.helper.js +0 -58
- package/src/encryption.helper.js.map +0 -1
- package/src/encryption.helper.ts +0 -29
- package/src/enum.helper.d.ts +0 -8
- package/src/enum.helper.js +0 -21
- package/src/enum.helper.js.map +0 -1
- package/src/enum.helper.ts +0 -34
- package/src/env.helper.d.ts +0 -3
- package/src/env.helper.js +0 -23
- package/src/env.helper.js.map +0 -1
- package/src/env.helper.ts +0 -35
- package/src/error.helper.d.ts +0 -1
- package/src/error.helper.js +0 -12
- package/src/error.helper.js.map +0 -1
- package/src/error.helper.ts +0 -12
- package/src/faker-helper.d.ts +0 -16
- package/src/faker-helper.js +0 -73
- package/src/faker-helper.js.map +0 -1
- package/src/faker-helper.ts +0 -98
- package/src/files.helper.d.ts +0 -2
- package/src/files.helper.js +0 -13
- package/src/files.helper.js.map +0 -1
- package/src/files.helper.ts +0 -20
- package/src/http.helper.d.ts +0 -26
- package/src/http.helper.js +0 -84
- package/src/http.helper.js.map +0 -1
- package/src/http.helper.ts +0 -152
- package/src/interval.helper.d.ts +0 -5
- package/src/interval.helper.js +0 -16
- package/src/interval.helper.js.map +0 -1
- package/src/interval.helper.ts +0 -13
- package/src/math.helper.d.ts +0 -1
- package/src/math.helper.js +0 -8
- package/src/math.helper.js.map +0 -1
- package/src/math.helper.ts +0 -4
- package/src/nest.decorator.d.ts +0 -3
- package/src/nest.decorator.js +0 -10
- package/src/nest.decorator.js.map +0 -1
- package/src/nest.decorator.ts +0 -10
- package/src/object-mapper.helper.d.ts +0 -16
- package/src/object-mapper.helper.js +0 -47
- package/src/object-mapper.helper.js.map +0 -1
- package/src/object-mapper.helper.ts +0 -148
- package/src/object.helper.d.ts +0 -18
- package/src/object.helper.js +0 -91
- package/src/object.helper.js.map +0 -1
- package/src/object.helper.ts +0 -173
- package/src/plugin.helper.d.ts +0 -22
- package/src/plugin.helper.js +0 -26
- package/src/plugin.helper.js.map +0 -1
- package/src/plugin.helper.ts +0 -42
- package/src/promise.helper.d.ts +0 -13
- package/src/promise.helper.js +0 -71
- package/src/promise.helper.js.map +0 -1
- package/src/promise.helper.ts +0 -65
- package/src/returnValue.d.ts +0 -14
- package/src/returnValue.js +0 -17
- package/src/returnValue.js.map +0 -1
- package/src/returnValue.ts +0 -26
- package/src/rxjs.helper.d.ts +0 -7
- package/src/rxjs.helper.js +0 -33
- package/src/rxjs.helper.js.map +0 -1
- package/src/rxjs.helper.ts +0 -71
- package/src/validator-helper.d.ts +0 -2
- package/src/validator-helper.js +0 -22
- package/src/validator-helper.js.map +0 -1
- package/src/validator-helper.ts +0 -26
- package/src/zlib.helper.d.ts +0 -3
- package/src/zlib.helper.js +0 -25
- package/src/zlib.helper.js.map +0 -1
- package/src/zlib.helper.ts +0 -19
package/src/object.helper.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deepMergeWithoutArrayConcat = exports.deepMerge = exports._deepMerge = exports.isObject = void 0;
|
|
4
|
-
exports.isObjectStrict = isObjectStrict;
|
|
5
|
-
exports.objectSetProp = objectSetProp;
|
|
6
|
-
exports.objectsHaveSameKeys = objectsHaveSameKeys;
|
|
7
|
-
exports.getObjectId = getObjectId;
|
|
8
|
-
const isObject = (val) => {
|
|
9
|
-
return val === Object(val) && !Array.isArray(val);
|
|
10
|
-
};
|
|
11
|
-
exports.isObject = isObject;
|
|
12
|
-
function isObjectStrict(val) {
|
|
13
|
-
return ((0, exports.isObject)(val) &&
|
|
14
|
-
!Array.isArray(val) &&
|
|
15
|
-
!(val instanceof Date) &&
|
|
16
|
-
!(typeof val === 'function'));
|
|
17
|
-
}
|
|
18
|
-
const _deepMerge = (isArrayConcat, target, ...sources) => {
|
|
19
|
-
if (!sources.length) {
|
|
20
|
-
return target;
|
|
21
|
-
}
|
|
22
|
-
const result = target;
|
|
23
|
-
if ((0, exports.isObject)(result)) {
|
|
24
|
-
const len = sources.length;
|
|
25
|
-
for (let i = 0; i < len; i += 1) {
|
|
26
|
-
const elm = sources[i];
|
|
27
|
-
if ((0, exports.isObject)(elm)) {
|
|
28
|
-
for (const key in elm) {
|
|
29
|
-
if (Object.prototype.hasOwnProperty.call(elm, key)) {
|
|
30
|
-
if ((0, exports.isObject)(elm[key]) && typeof elm[key] !== 'function') {
|
|
31
|
-
if (!result[key] || !(0, exports.isObject)(result[key])) {
|
|
32
|
-
result[key] = {};
|
|
33
|
-
}
|
|
34
|
-
(0, exports._deepMerge)(isArrayConcat, result[key], elm[key]);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
if (isArrayConcat &&
|
|
38
|
-
Array.isArray(result[key]) &&
|
|
39
|
-
Array.isArray(elm[key])) {
|
|
40
|
-
result[key] = Array.from(new Set(result[key].concat(elm[key])));
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
result[key] = elm[key];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
};
|
|
53
|
-
exports._deepMerge = _deepMerge;
|
|
54
|
-
const deepMerge = (target, ...sources) => {
|
|
55
|
-
return (0, exports._deepMerge)(true, target, ...sources);
|
|
56
|
-
};
|
|
57
|
-
exports.deepMerge = deepMerge;
|
|
58
|
-
const deepMergeWithoutArrayConcat = (target, ...sources) => {
|
|
59
|
-
return (0, exports._deepMerge)(false, target, ...sources);
|
|
60
|
-
};
|
|
61
|
-
exports.deepMergeWithoutArrayConcat = deepMergeWithoutArrayConcat;
|
|
62
|
-
function objectSetProp(obj, path, value) {
|
|
63
|
-
let schema = obj;
|
|
64
|
-
const pList = path.split('.');
|
|
65
|
-
const len = pList.length;
|
|
66
|
-
for (let i = 0; i < len - 1; i++) {
|
|
67
|
-
const elem = pList[i];
|
|
68
|
-
if (!schema[elem])
|
|
69
|
-
schema[elem] = {};
|
|
70
|
-
schema = schema[elem];
|
|
71
|
-
}
|
|
72
|
-
schema[pList[len - 1]] = value;
|
|
73
|
-
return obj;
|
|
74
|
-
}
|
|
75
|
-
function objectsHaveSameKeys(...objects) {
|
|
76
|
-
const allKeys = objects.reduce((keys, object) => keys.concat(Object.keys(object)), []);
|
|
77
|
-
const union = new Set(allKeys);
|
|
78
|
-
return objects.every((object) => union.size === Object.keys(object).length);
|
|
79
|
-
}
|
|
80
|
-
let count = 0;
|
|
81
|
-
const idMap = new WeakMap();
|
|
82
|
-
function getObjectId(object) {
|
|
83
|
-
const objectId = idMap.get(object);
|
|
84
|
-
if (objectId === undefined) {
|
|
85
|
-
count += 1;
|
|
86
|
-
idMap.set(object, count);
|
|
87
|
-
return count;
|
|
88
|
-
}
|
|
89
|
-
return objectId;
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=object.helper.js.map
|
package/src/object.helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.helper.js","sourceRoot":"","sources":["object.helper.ts"],"names":[],"mappings":";;;AA2BA,wCAOC;A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AAW,CACzB,MAAgD;IAEhD,MAAM,QAAQ,GAAuB,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACvD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,KAAK,IAAI,CAAC,CAAC;QACX,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAEzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/src/object.helper.ts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
interface IIsObject {
|
|
2
|
-
(item: any): boolean;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
interface IObject {
|
|
6
|
-
[key: string]: any;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface IDeepMerge {
|
|
10
|
-
(target: IObject, ...sources: Array<IObject>): IObject;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @description Method to check if an item is an object. Date and Function are considered
|
|
15
|
-
* an object, so if you need to exclude those, please update the method accordingly.
|
|
16
|
-
* @param val - The item that needs to be checked
|
|
17
|
-
* @return {Boolean} Whether or not @item is an object
|
|
18
|
-
*/
|
|
19
|
-
export const isObject: IIsObject = (val: any): val is Record<string, any> => {
|
|
20
|
-
return val === Object(val) && !Array.isArray(val);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @description Method to strictly check if an item is an object. Date and Function are not considered
|
|
25
|
-
* @param val - The item that needs to be checked
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
|
-
export function isObjectStrict(val: any): val is Record<string, any> {
|
|
29
|
-
return (
|
|
30
|
-
isObject(val) &&
|
|
31
|
-
!Array.isArray(val) &&
|
|
32
|
-
!(val instanceof Date) &&
|
|
33
|
-
!(typeof val === 'function')
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @description Method to perform a deep merge of objects
|
|
39
|
-
* @param isArrayConcat - Whether or not to concatenate arrays
|
|
40
|
-
* @param target - The targeted object that needs to be merged with the supplied @sources
|
|
41
|
-
* @param sources - The source(s) that will be used to update the @target object
|
|
42
|
-
* @return The final merged object
|
|
43
|
-
*/
|
|
44
|
-
export const _deepMerge = (
|
|
45
|
-
isArrayConcat: boolean,
|
|
46
|
-
target: IObject,
|
|
47
|
-
...sources: Array<IObject>
|
|
48
|
-
): IObject => {
|
|
49
|
-
// return the target if no sources passed
|
|
50
|
-
if (!sources.length) {
|
|
51
|
-
return target;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const result: IObject = target;
|
|
55
|
-
|
|
56
|
-
if (isObject(result)) {
|
|
57
|
-
const len: number = sources.length;
|
|
58
|
-
|
|
59
|
-
for (let i = 0; i < len; i += 1) {
|
|
60
|
-
const elm: any = sources[i];
|
|
61
|
-
|
|
62
|
-
if (isObject(elm)) {
|
|
63
|
-
for (const key in elm) {
|
|
64
|
-
if (Object.prototype.hasOwnProperty.call(elm, key)) {
|
|
65
|
-
if (isObject(elm[key]) && typeof elm[key] !== 'function') {
|
|
66
|
-
if (!result[key] || !isObject(result[key])) {
|
|
67
|
-
result[key] = {};
|
|
68
|
-
}
|
|
69
|
-
_deepMerge(isArrayConcat, result[key], elm[key]);
|
|
70
|
-
} else {
|
|
71
|
-
if (
|
|
72
|
-
isArrayConcat &&
|
|
73
|
-
Array.isArray(result[key]) &&
|
|
74
|
-
Array.isArray(elm[key])
|
|
75
|
-
) {
|
|
76
|
-
// concatenate the two arrays and remove any duplicate primitive values
|
|
77
|
-
result[key] = Array.from(new Set(result[key].concat(elm[key])));
|
|
78
|
-
} else {
|
|
79
|
-
result[key] = elm[key];
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return result;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @description Method to perform a deep merge of objects
|
|
93
|
-
* @param target - The targeted object that needs to be merged with the supplied @sources
|
|
94
|
-
* @param sources - The source(s) that will be used to update the @target object
|
|
95
|
-
* @returns The final merged object
|
|
96
|
-
*/
|
|
97
|
-
export const deepMerge: IDeepMerge = (
|
|
98
|
-
target: IObject,
|
|
99
|
-
...sources: Array<IObject>
|
|
100
|
-
): IObject => {
|
|
101
|
-
return _deepMerge(true, target, ...sources);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* @description Method to perform a deep merge of objects without concatenating arrays
|
|
106
|
-
* @param target - The targeted object that needs to be merged with the supplied @sources
|
|
107
|
-
* @param sources - The source(s) that will be used to update the @target object
|
|
108
|
-
* @returns The final merged object
|
|
109
|
-
*/
|
|
110
|
-
export const deepMergeWithoutArrayConcat: IDeepMerge = (
|
|
111
|
-
target: IObject,
|
|
112
|
-
...sources: Array<IObject>
|
|
113
|
-
): IObject => {
|
|
114
|
-
return _deepMerge(false, target, ...sources);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Utils to patch a nested property on an object
|
|
119
|
-
* specifying a dot-separated path.
|
|
120
|
-
* If the parent properties do not exist, they will be created
|
|
121
|
-
*
|
|
122
|
-
* @param obj the object to patch
|
|
123
|
-
* @param path the path of the property to set, e.g: "foo.bar.baz"
|
|
124
|
-
* @param value the value to set
|
|
125
|
-
* @returns the patched object
|
|
126
|
-
*/
|
|
127
|
-
export function objectSetProp(
|
|
128
|
-
obj: Record<any, any>,
|
|
129
|
-
path: string,
|
|
130
|
-
value: any,
|
|
131
|
-
): Record<any, any> {
|
|
132
|
-
let schema = obj; // a moving reference to internal objects within obj
|
|
133
|
-
const pList = path.split('.');
|
|
134
|
-
const len = pList.length;
|
|
135
|
-
for (let i = 0; i < len - 1; i++) {
|
|
136
|
-
const elem = pList[i];
|
|
137
|
-
if (!schema[elem]) schema[elem] = {};
|
|
138
|
-
schema = schema[elem];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
schema[pList[len - 1]] = value;
|
|
142
|
-
|
|
143
|
-
return obj;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function objectsHaveSameKeys(...objects: any[]) {
|
|
147
|
-
const allKeys = objects.reduce(
|
|
148
|
-
(keys, object) => keys.concat(Object.keys(object)),
|
|
149
|
-
[],
|
|
150
|
-
);
|
|
151
|
-
const union = new Set(allKeys);
|
|
152
|
-
return objects.every((object) => union.size === Object.keys(object).length);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
let count: number = 0;
|
|
156
|
-
const idMap: WeakMap<Record<string, unknown> | Array<unknown>, number> =
|
|
157
|
-
new WeakMap<Record<string, unknown> | Array<unknown>, number>();
|
|
158
|
-
/**
|
|
159
|
-
* @description Method to get the object id (unique identifier) of an object
|
|
160
|
-
*/
|
|
161
|
-
export function getObjectId(
|
|
162
|
-
object: Record<string, unknown> | Array<unknown>,
|
|
163
|
-
): number {
|
|
164
|
-
const objectId: number | undefined = idMap.get(object);
|
|
165
|
-
if (objectId === undefined) {
|
|
166
|
-
count += 1;
|
|
167
|
-
idMap.set(object, count);
|
|
168
|
-
|
|
169
|
-
return count;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return objectId;
|
|
173
|
-
}
|
package/src/plugin.helper.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ClassType } from '@nest-yalc-2/types/globals.d.js';
|
|
2
|
-
export interface PluginMethods extends Record<string, {
|
|
3
|
-
(...args: any[]): void;
|
|
4
|
-
} | undefined> {
|
|
5
|
-
}
|
|
6
|
-
export interface Plugin<T extends PluginMethods> {
|
|
7
|
-
pluginMethods: T;
|
|
8
|
-
}
|
|
9
|
-
export interface PluginSystem<T extends PluginMethods> {
|
|
10
|
-
registerPlugin(plugin: Plugin<T>): void;
|
|
11
|
-
unregisterPlugin(plugin: Plugin<T>): void;
|
|
12
|
-
invokePlugins(methodName: keyof T, ...args: any[]): void;
|
|
13
|
-
}
|
|
14
|
-
export declare function WithPluginSystem<U extends PluginMethods>(Base?: ClassType): {
|
|
15
|
-
new (...args: any[]): {
|
|
16
|
-
[x: string]: any;
|
|
17
|
-
plugins: Plugin<U>[];
|
|
18
|
-
registerPlugin(plugin: Plugin<U>): void;
|
|
19
|
-
unregisterPlugin(plugin: Plugin<U>): void;
|
|
20
|
-
invokePlugins(methodName: keyof U, ...args: any[]): void;
|
|
21
|
-
};
|
|
22
|
-
};
|
package/src/plugin.helper.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WithPluginSystem = WithPluginSystem;
|
|
4
|
-
class DefaultBase {
|
|
5
|
-
}
|
|
6
|
-
function WithPluginSystem(Base = DefaultBase) {
|
|
7
|
-
class PluginSystemWrapper extends Base {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(...arguments);
|
|
10
|
-
this.plugins = [];
|
|
11
|
-
}
|
|
12
|
-
registerPlugin(plugin) {
|
|
13
|
-
this.plugins.push(plugin);
|
|
14
|
-
}
|
|
15
|
-
unregisterPlugin(plugin) {
|
|
16
|
-
this.plugins = this.plugins.filter((p) => p !== plugin);
|
|
17
|
-
}
|
|
18
|
-
invokePlugins(methodName, ...args) {
|
|
19
|
-
for (const plugin of this.plugins) {
|
|
20
|
-
plugin.pluginMethods[methodName]?.(...args);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return PluginSystemWrapper;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=plugin.helper.js.map
|
package/src/plugin.helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.helper.js","sourceRoot":"","sources":["plugin.helper.ts"],"names":[],"mappings":";;AAmBA,4CAsBC;AAvCD,MAAM,WAAW;CAAG;AAiBpB,SAAgB,gBAAgB,CAC9B,OAAkB,WAAW;IAE7B,MAAM,mBAAoB,SAAQ,IAAI;QAAtC;;YACE,YAAO,GAAgB,EAAE,CAAC;QAe5B,CAAC;QAbC,cAAc,CAAC,MAAiB;YAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;QAED,gBAAgB,CAAC,MAAiB;YAChC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC;QAC1D,CAAC;QAED,aAAa,CAAC,UAAmB,EAAE,GAAG,IAAW;YAC/C,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;KACF;IAED,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
package/src/plugin.helper.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { ClassType } from '@nest-yalc-2/types/globals.d.js';
|
|
2
|
-
|
|
3
|
-
class DefaultBase {}
|
|
4
|
-
|
|
5
|
-
export interface PluginMethods extends Record<
|
|
6
|
-
string,
|
|
7
|
-
{ (...args: any[]): void } | undefined
|
|
8
|
-
> {}
|
|
9
|
-
|
|
10
|
-
export interface Plugin<T extends PluginMethods> {
|
|
11
|
-
pluginMethods: T;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface PluginSystem<T extends PluginMethods> {
|
|
15
|
-
registerPlugin(plugin: Plugin<T>): void;
|
|
16
|
-
unregisterPlugin(plugin: Plugin<T>): void;
|
|
17
|
-
invokePlugins(methodName: keyof T, ...args: any[]): void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function WithPluginSystem<U extends PluginMethods>(
|
|
21
|
-
Base: ClassType = DefaultBase,
|
|
22
|
-
) {
|
|
23
|
-
class PluginSystemWrapper extends Base implements PluginSystem<U> {
|
|
24
|
-
plugins: Plugin<U>[] = [];
|
|
25
|
-
|
|
26
|
-
registerPlugin(plugin: Plugin<U>) {
|
|
27
|
-
this.plugins.push(plugin);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
unregisterPlugin(plugin: Plugin<U>) {
|
|
31
|
-
this.plugins = this.plugins.filter((p) => p !== plugin);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
invokePlugins(methodName: keyof U, ...args: any[]) {
|
|
35
|
-
for (const plugin of this.plugins) {
|
|
36
|
-
plugin.pluginMethods[methodName]?.(...args);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return PluginSystemWrapper;
|
|
42
|
-
}
|
package/src/promise.helper.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { AnyFunction } from '@nest-yalc-2/types/globals.d.js';
|
|
2
|
-
import * as pMap from 'p-map';
|
|
3
|
-
export declare const PROMISE_CONCURRENCY_LIMIT = 1000;
|
|
4
|
-
export declare function promiseMap<Element, NewElement>(input: Iterable<Element>, mapper: pMap.Mapper<Element, NewElement>, options?: pMap.Options): Promise<NewElement[]>;
|
|
5
|
-
export declare class PromiseTracker {
|
|
6
|
-
private promises;
|
|
7
|
-
private deferred;
|
|
8
|
-
add(promise: Promise<any>): void;
|
|
9
|
-
addDeferred(deferred: AnyFunction): void;
|
|
10
|
-
private remove;
|
|
11
|
-
waitForAll(): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
export declare const globalPromiseTracker: PromiseTracker;
|
package/src/promise.helper.js
DELETED
|
@@ -1,71 +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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.globalPromiseTracker = exports.PromiseTracker = exports.PROMISE_CONCURRENCY_LIMIT = void 0;
|
|
37
|
-
exports.promiseMap = promiseMap;
|
|
38
|
-
const pMap = __importStar(require("p-map"));
|
|
39
|
-
exports.PROMISE_CONCURRENCY_LIMIT = 1000;
|
|
40
|
-
function promiseMap(input, mapper, options) {
|
|
41
|
-
return pMap.default(input, mapper, {
|
|
42
|
-
concurrency: options?.concurrency ?? exports.PROMISE_CONCURRENCY_LIMIT,
|
|
43
|
-
stopOnError: options?.stopOnError ?? true,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
class PromiseTracker {
|
|
47
|
-
constructor() {
|
|
48
|
-
this.promises = [];
|
|
49
|
-
this.deferred = [];
|
|
50
|
-
}
|
|
51
|
-
add(promise) {
|
|
52
|
-
this.promises.push(promise);
|
|
53
|
-
void promise
|
|
54
|
-
.finally(() => this.remove(promise))
|
|
55
|
-
.catch(() => {
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
addDeferred(deferred) {
|
|
59
|
-
this.deferred.push(deferred);
|
|
60
|
-
}
|
|
61
|
-
remove(promise) {
|
|
62
|
-
this.promises = this.promises.filter((p) => p !== promise);
|
|
63
|
-
}
|
|
64
|
-
async waitForAll() {
|
|
65
|
-
await Promise.all(this.promises);
|
|
66
|
-
await Promise.all(this.deferred.map((d) => d()));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.PromiseTracker = PromiseTracker;
|
|
70
|
-
exports.globalPromiseTracker = new PromiseTracker();
|
|
71
|
-
//# sourceMappingURL=promise.helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"promise.helper.js","sourceRoot":"","sources":["promise.helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,gCASC;AAtBD,4CAA8B;AAEjB,QAAA,yBAAyB,GAAG,IAAI,CAAC;AAW9C,SAAgB,UAAU,CACxB,KAAwB,EACxB,MAAwC,EACxC,OAAsB;IAEtB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE;QACjC,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,iCAAyB;QAC9D,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,IAAI;KAC1C,CAAC,CAAC;AACL,CAAC;AAKD,MAAa,cAAc;IAA3B;QACU,aAAQ,GAAmB,EAAE,CAAC;QAC9B,aAAQ,GAAkB,EAAE,CAAC;IA6BvC,CAAC;IA3BC,GAAG,CAAC,OAAqB;QACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5B,KAAK,OAAO;aACT,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;aACnC,KAAK,CAAC,GAAG,EAAE;QAGZ,CAAC,CAAC,CAAC;IACP,CAAC;IAKD,WAAW,CAAC,QAAqB;QAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;IAEO,MAAM,CAAC,OAAqB;QAElC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEjC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;CACF;AA/BD,wCA+BC;AAKY,QAAA,oBAAoB,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
package/src/promise.helper.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { AnyFunction } from '@nest-yalc-2/types/globals.d.js';
|
|
2
|
-
import * as pMap from 'p-map';
|
|
3
|
-
|
|
4
|
-
export const PROMISE_CONCURRENCY_LIMIT = 1000;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This method allows you to run multiple async functions concurrently. It's an alternative to the Promise.all native method
|
|
8
|
-
* with support to concurrency limit. It's an adapter of the p-map library.
|
|
9
|
-
* NOTE: concurrency is set to 1000 by default and stopOnError = true
|
|
10
|
-
*
|
|
11
|
-
@param input - Iterated over concurrently in the `mapper` function.
|
|
12
|
-
@param mapper - Function which is called for every item in `input`. Expected to return a `Promise` or value.
|
|
13
|
-
@returns A `Promise` that is fulfilled when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order.
|
|
14
|
-
*/
|
|
15
|
-
export function promiseMap<Element, NewElement>(
|
|
16
|
-
input: Iterable<Element>,
|
|
17
|
-
mapper: pMap.Mapper<Element, NewElement>,
|
|
18
|
-
options?: pMap.Options,
|
|
19
|
-
): Promise<NewElement[]> {
|
|
20
|
-
return pMap.default(input, mapper, {
|
|
21
|
-
concurrency: options?.concurrency ?? PROMISE_CONCURRENCY_LIMIT,
|
|
22
|
-
stopOnError: options?.stopOnError ?? true,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* This class allows you to track multiple promises and wait for all of them to resolve.
|
|
28
|
-
*/
|
|
29
|
-
export class PromiseTracker {
|
|
30
|
-
private promises: Promise<any>[] = [];
|
|
31
|
-
private deferred: AnyFunction[] = [];
|
|
32
|
-
|
|
33
|
-
add(promise: Promise<any>) {
|
|
34
|
-
this.promises.push(promise);
|
|
35
|
-
void promise
|
|
36
|
-
.finally(() => this.remove(promise))
|
|
37
|
-
.catch(() => {
|
|
38
|
-
// The original promise is still awaited by callers; this only prevents
|
|
39
|
-
// the cleanup chain from surfacing a duplicate unhandled rejection.
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @param deferred - A function that will be executed after all promises are resolved.
|
|
45
|
-
*/
|
|
46
|
-
addDeferred(deferred: AnyFunction) {
|
|
47
|
-
this.deferred.push(deferred);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private remove(promise: Promise<any>) {
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
52
|
-
this.promises = this.promises.filter((p) => p !== promise);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async waitForAll() {
|
|
56
|
-
await Promise.all(this.promises);
|
|
57
|
-
|
|
58
|
-
await Promise.all(this.deferred.map((d) => d()));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* This is a global instance of the PromiseTracker class.
|
|
64
|
-
*/
|
|
65
|
-
export const globalPromiseTracker = new PromiseTracker();
|
package/src/returnValue.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ObjectType } from 'typeorm';
|
|
2
|
-
export declare function returnValue<T>(value: string | boolean | number): {
|
|
3
|
-
(): T;
|
|
4
|
-
};
|
|
5
|
-
export declare function returnValue<T>(value: T): {
|
|
6
|
-
(): ObjectType<T>;
|
|
7
|
-
};
|
|
8
|
-
export declare function returnAsyncValue<T>(value: T): {
|
|
9
|
-
(): Promise<T>;
|
|
10
|
-
};
|
|
11
|
-
export declare const returnProperty: <T>(property: keyof T) => {
|
|
12
|
-
(relationEntity: T): T[keyof T];
|
|
13
|
-
};
|
|
14
|
-
export default returnValue;
|
package/src/returnValue.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.returnProperty = void 0;
|
|
4
|
-
exports.returnValue = returnValue;
|
|
5
|
-
exports.returnAsyncValue = returnAsyncValue;
|
|
6
|
-
function returnValue(value) {
|
|
7
|
-
return () => value;
|
|
8
|
-
}
|
|
9
|
-
function returnAsyncValue(value) {
|
|
10
|
-
return async () => value;
|
|
11
|
-
}
|
|
12
|
-
const returnProperty = (property) => {
|
|
13
|
-
return (relationEntity) => relationEntity[property];
|
|
14
|
-
};
|
|
15
|
-
exports.returnProperty = returnProperty;
|
|
16
|
-
exports.default = returnValue;
|
|
17
|
-
//# sourceMappingURL=returnValue.js.map
|
package/src/returnValue.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"returnValue.js","sourceRoot":"","sources":["returnValue.ts"],"names":[],"mappings":";;;AAMA,kCAEC;AAED,4CAIC;AARD,SAAgB,WAAW,CAAI,KAAQ;IACrC,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC;AACrB,CAAC;AAED,SAAgB,gBAAgB,CAAI,KAAQ;IAG1C,OAAO,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC;AAC3B,CAAC;AAKM,MAAM,cAAc,GAAG,CAC5B,QAAiB,EACoB,EAAE;IACvC,OAAO,CAAC,cAAiB,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;AACzD,CAAC,CAAC;AAJW,QAAA,cAAc,kBAIzB;AAEF,kBAAe,WAAW,CAAC"}
|
package/src/returnValue.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ObjectType } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
export function returnValue<T>(value: string | boolean | number): {
|
|
4
|
-
(): T;
|
|
5
|
-
};
|
|
6
|
-
export function returnValue<T>(value: T): { (): ObjectType<T> };
|
|
7
|
-
export function returnValue<T>(value: T): { (): T | ObjectType<T> } {
|
|
8
|
-
return () => value;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function returnAsyncValue<T>(value: T): {
|
|
12
|
-
(): Promise<T>;
|
|
13
|
-
} {
|
|
14
|
-
return async () => value;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Helper function for typeorm decorators
|
|
19
|
-
*/
|
|
20
|
-
export const returnProperty = <T>(
|
|
21
|
-
property: keyof T,
|
|
22
|
-
): { (relationEntity: T): T[keyof T] } => {
|
|
23
|
-
return (relationEntity: T) => relationEntity[property];
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default returnValue;
|
package/src/rxjs.helper.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AnyFunction } from '@nest-yalc-2/types/globals.d.js';
|
|
2
|
-
import { MonoTypeOperatorFunction, ObservableInput, Observable, UnaryFunction } from 'rxjs';
|
|
3
|
-
export declare function wrapIntoObservable<T>(input: Promise<T> | {
|
|
4
|
-
(): Promise<T>;
|
|
5
|
-
} | Observable<T> | T | void): Observable<T>;
|
|
6
|
-
export declare function wrapIntoAnOperator(input: AnyFunction): UnaryFunction<any, any>;
|
|
7
|
-
export declare function switchTap<T, O extends ObservableInput<any>>(project: (value: T, index: number) => O): MonoTypeOperatorFunction<T>;
|
package/src/rxjs.helper.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.wrapIntoObservable = wrapIntoObservable;
|
|
7
|
-
exports.wrapIntoAnOperator = wrapIntoAnOperator;
|
|
8
|
-
exports.switchTap = switchTap;
|
|
9
|
-
const rxjs_1 = require("rxjs");
|
|
10
|
-
const operators_1 = require("rxjs/operators");
|
|
11
|
-
const node_util_1 = __importDefault(require("node:util"));
|
|
12
|
-
function wrapIntoObservable(input) {
|
|
13
|
-
if (input === null || input === undefined) {
|
|
14
|
-
return rxjs_1.EMPTY;
|
|
15
|
-
}
|
|
16
|
-
if (node_util_1.default.types.isAsyncFunction(input)) {
|
|
17
|
-
return (0, rxjs_1.from)(input());
|
|
18
|
-
}
|
|
19
|
-
if ((0, rxjs_1.isObservable)(input)) {
|
|
20
|
-
return input;
|
|
21
|
-
}
|
|
22
|
-
return (0, rxjs_1.of)(input);
|
|
23
|
-
}
|
|
24
|
-
function wrapIntoAnOperator(input) {
|
|
25
|
-
if (node_util_1.default.types.isAsyncFunction(input)) {
|
|
26
|
-
return (0, operators_1.mergeMap)(input);
|
|
27
|
-
}
|
|
28
|
-
return input;
|
|
29
|
-
}
|
|
30
|
-
function switchTap(project) {
|
|
31
|
-
return (input) => input.pipe((0, operators_1.switchMap)((value, index) => (0, rxjs_1.combineLatest)([(0, rxjs_1.of)(value), project(value, index)])), (0, operators_1.map)(([intialValue, projectedValue]) => projectedValue !== undefined ? projectedValue : intialValue));
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=rxjs.helper.js.map
|
package/src/rxjs.helper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rxjs.helper.js","sourceRoot":"","sources":["rxjs.helper.ts"],"names":[],"mappings":";;;;;AA0BA,gDAgBC;AAED,gDAQC;AAMD,8BAYC;AArED,+BAUc;AACd,8CAA0D;AAC1D,0DAA6B;AAa7B,SAAgB,kBAAkB,CAChC,KAAiE;IAEjE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,YAAK,CAAC;IACf,CAAC;IAED,IAAI,mBAAI,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,IAAA,WAAI,EAAE,KAA4B,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,IAAA,mBAAY,EAAC,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAA,SAAE,EAAC,KAAY,CAAC,CAAC;AAC1B,CAAC;AAED,SAAgB,kBAAkB,CAChC,KAAkB;IAElB,IAAI,mBAAI,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,IAAA,oBAAQ,EAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAMD,SAAgB,SAAS,CACvB,OAAuC;IAEvC,OAAO,CAAC,KAAK,EAAE,EAAE,CACf,KAAK,CAAC,IAAI,CACR,IAAA,qBAAS,EAAC,CAAC,KAAK,EAAE,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