@allgemein/base 1.6.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/Constants.d.ts +11 -0
- package/Constants.js +15 -0
- package/Constants.js.map +1 -0
- package/LICENSE +23 -0
- package/MetaArgs.d.ts +9 -0
- package/MetaArgs.js +21 -0
- package/MetaArgs.js.map +1 -0
- package/MetadataStorage.d.ts +17 -0
- package/MetadataStorage.js +47 -0
- package/MetadataStorage.js.map +1 -0
- package/README.md +6 -0
- package/browser.d.ts +2 -0
- package/browser.js +32 -0
- package/browser.js.map +1 -0
- package/exceptions/NestedException.d.ts +11 -0
- package/exceptions/NestedException.js +31 -0
- package/exceptions/NestedException.js.map +1 -0
- package/exceptions/NotSupportedError.d.ts +3 -0
- package/exceptions/NotSupportedError.js +11 -0
- package/exceptions/NotSupportedError.js.map +1 -0
- package/exceptions/NotYetImplementedError.d.ts +3 -0
- package/exceptions/NotYetImplementedError.js +11 -0
- package/exceptions/NotYetImplementedError.js.map +1 -0
- package/exceptions/TodoException.d.ts +3 -0
- package/exceptions/TodoException.js +11 -0
- package/exceptions/TodoException.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +36 -0
- package/index.js.map +1 -0
- package/locking/LockFactory.d.ts +15 -0
- package/locking/LockFactory.js +60 -0
- package/locking/LockFactory.js.map +1 -0
- package/locking/Semaphore.d.ts +45 -0
- package/locking/Semaphore.js +108 -0
- package/locking/Semaphore.js.map +1 -0
- package/logging/AbstractLogger.d.ts +24 -0
- package/logging/AbstractLogger.js +73 -0
- package/logging/AbstractLogger.js.map +1 -0
- package/logging/ConsoleLogger.d.ts +4 -0
- package/logging/ConsoleLogger.js +31 -0
- package/logging/ConsoleLogger.js.map +1 -0
- package/logging/ILogLevel.d.ts +4 -0
- package/logging/ILogLevel.js +4 -0
- package/logging/ILogLevel.js.map +1 -0
- package/logging/ILoggerApi.d.ts +12 -0
- package/logging/ILoggerApi.js +4 -0
- package/logging/ILoggerApi.js.map +1 -0
- package/logging/ILoggerOptions.d.ts +7 -0
- package/logging/ILoggerOptions.js +4 -0
- package/logging/ILoggerOptions.js.map +1 -0
- package/logging/Logger.d.ts +23 -0
- package/logging/Logger.js +66 -0
- package/logging/Logger.js.map +1 -0
- package/package.json +63 -0
- package/shared.d.ts +20 -0
- package/shared.js +47 -0
- package/shared.js.map +1 -0
- package/utils/ClassLoader.d.ts +28 -0
- package/utils/ClassLoader.js +183 -0
- package/utils/ClassLoader.js.map +1 -0
- package/utils/ClassUtils.d.ts +5 -0
- package/utils/ClassUtils.js +50 -0
- package/utils/ClassUtils.js.map +1 -0
- package/utils/CryptUtils.d.ts +10 -0
- package/utils/CryptUtils.js +64 -0
- package/utils/CryptUtils.js.map +1 -0
- package/utils/FileUtils.d.ts +14 -0
- package/utils/FileUtils.js +99 -0
- package/utils/FileUtils.js.map +1 -0
- package/utils/JsonUtils.d.ts +5 -0
- package/utils/JsonUtils.js +35 -0
- package/utils/JsonUtils.js.map +1 -0
- package/utils/PlatformUtils.d.ts +97 -0
- package/utils/PlatformUtils.js +288 -0
- package/utils/PlatformUtils.js.map +1 -0
- package/utils/PlatformUtilsBrowser.d.ts +86 -0
- package/utils/PlatformUtilsBrowser.js +177 -0
- package/utils/PlatformUtilsBrowser.js.map +1 -0
- package/utils/Serializer.d.ts +9 -0
- package/utils/Serializer.js +84 -0
- package/utils/Serializer.js.map +1 -0
- package/utils/TreeUtils.d.ts +12 -0
- package/utils/TreeUtils.js +110 -0
- package/utils/TreeUtils.js.map +1 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @see https://github.com/typeorm/typeorm/blob/master/src/util/DirectoryExportedClassesLoader.ts
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ClassLoader = void 0;
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
|
+
const PlatformUtils_1 = require("./PlatformUtils");
|
|
11
|
+
const FileUtils_1 = require("./FileUtils");
|
|
12
|
+
const ClassUtils_1 = require("./ClassUtils");
|
|
13
|
+
const __SOURCE__ = '__SOURCE__';
|
|
14
|
+
/**
|
|
15
|
+
* Loads all exported classes from the given directory.
|
|
16
|
+
*/
|
|
17
|
+
class ClassLoader {
|
|
18
|
+
static importClassesFromAny(o) {
|
|
19
|
+
let klasses = [];
|
|
20
|
+
o.forEach(x => {
|
|
21
|
+
if (lodash_1.isString(x)) {
|
|
22
|
+
const _x = PlatformUtils_1.PlatformUtils.pathNormilize(PlatformUtils_1.PlatformUtils.pathResolve(x));
|
|
23
|
+
const exported = ClassLoader.importClassesFromDirectories([_x]);
|
|
24
|
+
klasses = klasses.concat.apply(klasses, exported);
|
|
25
|
+
}
|
|
26
|
+
else if (x instanceof Function) {
|
|
27
|
+
klasses.push(x);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new Error('TODO: unknown ' + x);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return klasses;
|
|
34
|
+
}
|
|
35
|
+
static importClassesFromAnyAsync(o) {
|
|
36
|
+
return Promise.all(o.map(async (x) => {
|
|
37
|
+
if (lodash_1.isString(x)) {
|
|
38
|
+
const _x = PlatformUtils_1.PlatformUtils.pathNormilize(PlatformUtils_1.PlatformUtils.pathResolve(x));
|
|
39
|
+
return ClassLoader.importClassesFromDirectoriesAsync([_x]);
|
|
40
|
+
}
|
|
41
|
+
else if (x instanceof Function) {
|
|
42
|
+
return [x];
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw new Error('TODO: unknown ' + x);
|
|
46
|
+
}
|
|
47
|
+
})).then(x => {
|
|
48
|
+
return lodash_1.concat([], ...x);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
static importClassesFromDirectories(directories, formats = ['.js', '.ts']) {
|
|
52
|
+
const allFiles = directories.reduce((allDirs, dir) => {
|
|
53
|
+
const x = PlatformUtils_1.PlatformUtils.pathNormilize(dir);
|
|
54
|
+
const y = PlatformUtils_1.PlatformUtils.load('glob').sync(x);
|
|
55
|
+
return allDirs.concat(y);
|
|
56
|
+
}, []);
|
|
57
|
+
const dirs = allFiles
|
|
58
|
+
.filter(file => {
|
|
59
|
+
const dtsExtension = file.substring(file.length - 5, file.length);
|
|
60
|
+
return formats.indexOf(PlatformUtils_1.PlatformUtils.pathExtname(file)) !== -1 && dtsExtension !== '.d.ts';
|
|
61
|
+
})
|
|
62
|
+
.map(file => {
|
|
63
|
+
const cls = {
|
|
64
|
+
source: file,
|
|
65
|
+
loaded: PlatformUtils_1.PlatformUtils.load(PlatformUtils_1.PlatformUtils.pathResolve(file))
|
|
66
|
+
};
|
|
67
|
+
return cls;
|
|
68
|
+
});
|
|
69
|
+
return this.filterClasses(dirs, []); // this.loadFileClasses(dirs, []);
|
|
70
|
+
}
|
|
71
|
+
static async importClassesFromDirectoriesAsync(directories, formats = ['.js', '.ts']) {
|
|
72
|
+
let allFiles = [];
|
|
73
|
+
const promises = [];
|
|
74
|
+
for (const dir of directories) {
|
|
75
|
+
const x = PlatformUtils_1.PlatformUtils.pathNormilize(dir);
|
|
76
|
+
promises.push(FileUtils_1.FileUtils.glob(x));
|
|
77
|
+
}
|
|
78
|
+
await Promise.all(promises).then(r => {
|
|
79
|
+
allFiles = allFiles.concat(...r);
|
|
80
|
+
});
|
|
81
|
+
const dirs = await Promise.all(allFiles
|
|
82
|
+
.filter(file => {
|
|
83
|
+
const dtsExtension = file.substring(file.length - 5, file.length);
|
|
84
|
+
return formats.indexOf(PlatformUtils_1.PlatformUtils.pathExtname(file)) !== -1 && dtsExtension !== '.d.ts';
|
|
85
|
+
})
|
|
86
|
+
.map(file => PlatformUtils_1.PlatformUtils.pathResolve(file))
|
|
87
|
+
.filter(file => PlatformUtils_1.PlatformUtils.fileExist(file))
|
|
88
|
+
.map(async (file) => {
|
|
89
|
+
try {
|
|
90
|
+
const cls = {
|
|
91
|
+
source: file,
|
|
92
|
+
loaded: await PlatformUtils_1.PlatformUtils.loadAsync(file)
|
|
93
|
+
};
|
|
94
|
+
return cls;
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
return this.filterClasses(dirs.filter(x => !lodash_1.isNull(x)), []); // this.loadFileClasses(dirs, []);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Loads all json files from the given directory.
|
|
104
|
+
*/
|
|
105
|
+
static importJsonsFromDirectories(directories, format = '.json') {
|
|
106
|
+
const allFiles = directories.reduce((allDirs, dir) => {
|
|
107
|
+
return allDirs.concat(PlatformUtils_1.PlatformUtils.load('glob').sync(PlatformUtils_1.PlatformUtils.pathNormilize(dir)));
|
|
108
|
+
}, []);
|
|
109
|
+
return allFiles
|
|
110
|
+
.filter(file => PlatformUtils_1.PlatformUtils.pathExtname(file) === format)
|
|
111
|
+
.map(file => PlatformUtils_1.PlatformUtils.load(PlatformUtils_1.PlatformUtils.pathResolve(file)));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Loads all json files from the given directory.
|
|
115
|
+
*/
|
|
116
|
+
static async importJsonsFromDirectoriesAsync(directories, format = '.json') {
|
|
117
|
+
let allFiles = [];
|
|
118
|
+
const promises = [];
|
|
119
|
+
for (const dir of directories) {
|
|
120
|
+
const x = PlatformUtils_1.PlatformUtils.pathNormilize(dir);
|
|
121
|
+
promises.push(FileUtils_1.FileUtils.glob(x));
|
|
122
|
+
}
|
|
123
|
+
await Promise.all(promises).then(r => {
|
|
124
|
+
allFiles = allFiles.concat(...r);
|
|
125
|
+
});
|
|
126
|
+
return allFiles
|
|
127
|
+
.filter(file => PlatformUtils_1.PlatformUtils.pathExtname(file) === format)
|
|
128
|
+
.map(file => PlatformUtils_1.PlatformUtils.load(PlatformUtils_1.PlatformUtils.pathResolve(file)));
|
|
129
|
+
}
|
|
130
|
+
static getSource(cls) {
|
|
131
|
+
return ClassUtils_1.ClassUtils.getSource(cls);
|
|
132
|
+
}
|
|
133
|
+
static getClassName(klass) {
|
|
134
|
+
return ClassUtils_1.ClassUtils.getClassName(klass);
|
|
135
|
+
}
|
|
136
|
+
static getFunction(klass) {
|
|
137
|
+
return ClassUtils_1.ClassUtils.getFunction(klass);
|
|
138
|
+
}
|
|
139
|
+
static filterClasses(exported, allLoaded) {
|
|
140
|
+
if (lodash_1.isArray(exported)) {
|
|
141
|
+
exported.forEach(e => this.filterClasses(e, allLoaded));
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
if (exported.loaded instanceof Function) {
|
|
145
|
+
if (Reflect && Reflect['getOwnMetadata']) {
|
|
146
|
+
Reflect['defineMetadata'](__SOURCE__, exported.source, exported.loaded);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
exported.loaded.__SOURCE__ = exported.source;
|
|
150
|
+
}
|
|
151
|
+
allLoaded.push(exported.loaded);
|
|
152
|
+
}
|
|
153
|
+
else if (exported.loaded instanceof Object) {
|
|
154
|
+
lodash_1.keys(exported.loaded).forEach(key => this.filterClasses({
|
|
155
|
+
loaded: exported.loaded[key],
|
|
156
|
+
source: exported.source
|
|
157
|
+
}, allLoaded));
|
|
158
|
+
}
|
|
159
|
+
else if (exported.loaded instanceof Array) {
|
|
160
|
+
exported.loaded.forEach((i) => this.filterClasses({
|
|
161
|
+
loaded: i,
|
|
162
|
+
source: exported.source
|
|
163
|
+
}, allLoaded));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return allLoaded;
|
|
167
|
+
}
|
|
168
|
+
static loadFileClasses(exported, allLoaded) {
|
|
169
|
+
if (exported instanceof Function) {
|
|
170
|
+
allLoaded.push(exported);
|
|
171
|
+
}
|
|
172
|
+
else if (exported instanceof Object) {
|
|
173
|
+
Object.keys(exported).forEach(key => this.loadFileClasses(exported[key], allLoaded));
|
|
174
|
+
}
|
|
175
|
+
else if (exported instanceof Array) {
|
|
176
|
+
exported.forEach((i) => this.loadFileClasses(i, allLoaded));
|
|
177
|
+
}
|
|
178
|
+
return allLoaded;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.ClassLoader = ClassLoader;
|
|
182
|
+
|
|
183
|
+
//# sourceMappingURL=ClassLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/ClassLoader.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mCAA+D;AAC/D,mDAA8C;AAE9C,2CAAsC;AACtC,6CAAwC;AAGxC,MAAM,UAAU,GAAG,YAAY,CAAC;AAEhC;;GAEG;AACH,MAAa,WAAW;IAEtB,MAAM,CAAC,oBAAoB,CAAC,CAAqB;QAC/C,IAAI,OAAO,GAAe,EAAE,CAAC;QAC7B,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACZ,IAAI,iBAAQ,CAAC,CAAC,CAAC,EAAE;gBACf,MAAM,EAAE,GAAG,6BAAa,CAAC,aAAa,CAAC,6BAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;gBACrE,MAAM,QAAQ,GAAG,WAAW,CAAC,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBAChE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;aACnD;iBAAM,IAAI,CAAC,YAAY,QAAQ,EAAE;gBAChC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;iBAAM;gBACL,MAAM,IAAI,KAAK,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC;aACvC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,yBAAyB,CAAC,CAAqB;QACpD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;YACj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AS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC1B;aAAM,IAAI,QAAQ,YAAY,MAAM,EAAE;YACrC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;SAEtF;aAAM,IAAI,QAAQ,YAAY,KAAK,EAAE;YACpC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;SAClE;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AArLD,kCAqLC","file":"ClassLoader.js","sourcesContent":["/**\n *\n * @see https://github.com/typeorm/typeorm/blob/master/src/util/DirectoryExportedClassesLoader.ts\n *\n */\n\nimport {concat, isArray, isNull, isString, keys} from 'lodash';\nimport {PlatformUtils} from './PlatformUtils';\nimport {StringOrFunction} from '../Constants';\nimport {FileUtils} from './FileUtils';\nimport {ClassUtils} from './ClassUtils';\n\n\nconst __SOURCE__ = '__SOURCE__';\n\n/**\n * Loads all exported classes from the given directory.\n */\nexport class ClassLoader {\n\n static importClassesFromAny(o: StringOrFunction[]): Function[] {\n let klasses: Function[] = [];\n o.forEach(x => {\n if (isString(x)) {\n const _x = PlatformUtils.pathNormilize(PlatformUtils.pathResolve(x));\n const exported = ClassLoader.importClassesFromDirectories([_x]);\n klasses = klasses.concat.apply(klasses, exported);\n } else if (x instanceof Function) {\n klasses.push(x);\n } else {\n throw new Error('TODO: unknown ' + x);\n }\n });\n return klasses;\n }\n\n static importClassesFromAnyAsync(o: StringOrFunction[]): Promise<Function[]> {\n return Promise.all(o.map(async x => {\n if (isString(x)) {\n const _x = PlatformUtils.pathNormilize(PlatformUtils.pathResolve(x));\n return ClassLoader.importClassesFromDirectoriesAsync([_x]);\n } else if (x instanceof Function) {\n return [x];\n } else {\n throw new Error('TODO: unknown ' + x);\n }\n })).then(x => {\n return concat([], ...x);\n });\n }\n\n\n static importClassesFromDirectories(directories: string[], formats = ['.js', '.ts']): Function[] {\n\n const allFiles = directories.reduce((allDirs, dir) => {\n const x = PlatformUtils.pathNormilize(dir);\n const y = PlatformUtils.load('glob').sync(x);\n return allDirs.concat(y);\n }, [] as string[]);\n\n const dirs: { loaded: any, source: string }[] = allFiles\n .filter(file => {\n const dtsExtension = file.substring(file.length - 5, file.length);\n return formats.indexOf(PlatformUtils.pathExtname(file)) !== -1 && dtsExtension !== '.d.ts';\n })\n .map(file => {\n const cls = {\n source: file,\n loaded: PlatformUtils.load(PlatformUtils.pathResolve(file))\n };\n return cls;\n });\n\n return this.filterClasses(dirs, []); // this.loadFileClasses(dirs, []);\n }\n\n\n static async importClassesFromDirectoriesAsync(directories: string[], formats = ['.js', '.ts']): Promise<Function[]> {\n let allFiles: string[] = [];\n const promises = [];\n for (const dir of directories) {\n const x = PlatformUtils.pathNormilize(dir);\n promises.push(FileUtils.glob(x));\n }\n await Promise.all(promises).then(r => {\n allFiles = allFiles.concat(...r);\n });\n\n const dirs: { loaded: any, source: string }[] = await Promise.all(allFiles\n .filter(file => {\n const dtsExtension = file.substring(file.length - 5, file.length);\n return formats.indexOf(PlatformUtils.pathExtname(file)) !== -1 && dtsExtension !== '.d.ts';\n })\n .map(file => PlatformUtils.pathResolve(file))\n .filter(file => PlatformUtils.fileExist(file))\n .map(async file => {\n try {\n const cls = {\n source: file,\n loaded: await PlatformUtils.loadAsync(file)\n };\n return cls;\n } catch (e) {\n return null;\n }\n }));\n return this.filterClasses(dirs.filter(x => !isNull(x)), []); // this.loadFileClasses(dirs, []);\n }\n\n\n /**\n * Loads all json files from the given directory.\n */\n static importJsonsFromDirectories(directories: string[], format = '.json'): any[] {\n\n const allFiles = directories.reduce((allDirs, dir) => {\n return allDirs.concat(PlatformUtils.load('glob').sync(PlatformUtils.pathNormilize(dir)));\n }, [] as string[]);\n\n return allFiles\n .filter(file => PlatformUtils.pathExtname(file) === format)\n .map(file => PlatformUtils.load(PlatformUtils.pathResolve(file)));\n }\n\n /**\n * Loads all json files from the given directory.\n */\n static async importJsonsFromDirectoriesAsync(directories: string[], format = '.json'): Promise<any[]> {\n let allFiles: string[] = [];\n const promises = [];\n for (const dir of directories) {\n const x = PlatformUtils.pathNormilize(dir);\n promises.push(FileUtils.glob(x));\n }\n await Promise.all(promises).then(r => {\n allFiles = allFiles.concat(...r);\n });\n\n return allFiles\n .filter(file => PlatformUtils.pathExtname(file) === format)\n .map(file => PlatformUtils.load(PlatformUtils.pathResolve(file)));\n }\n\n\n static getSource(cls: Function): string {\n return ClassUtils.getSource(cls);\n }\n\n\n static getClassName(klass: string | Function) {\n return ClassUtils.getClassName(klass);\n }\n\n\n static getFunction(klass: string | Function) {\n return ClassUtils.getFunction(klass);\n }\n\n\n private static filterClasses(exported: { loaded: any, source: string } | { loaded: any, source: string }[], allLoaded: Function[]) {\n if (isArray(exported)) {\n exported.forEach(e => this.filterClasses(e, allLoaded));\n } else {\n if (exported.loaded instanceof Function) {\n if (Reflect && Reflect['getOwnMetadata']) {\n Reflect['defineMetadata'](__SOURCE__, exported.source, exported.loaded);\n } else {\n exported.loaded.__SOURCE__ = exported.source;\n }\n allLoaded.push(exported.loaded);\n } else if (exported.loaded instanceof Object) {\n keys(exported.loaded).forEach(key => this.filterClasses({\n loaded: exported.loaded[key],\n source: exported.source\n }, allLoaded));\n } else if (exported.loaded instanceof Array) {\n exported.loaded.forEach((i: any) => this.filterClasses({\n loaded: i,\n source: exported.source\n }, allLoaded));\n }\n }\n\n return allLoaded;\n }\n\n\n private static loadFileClasses(exported: any, allLoaded: Function[]) {\n if (exported instanceof Function) {\n allLoaded.push(exported);\n } else if (exported instanceof Object) {\n Object.keys(exported).forEach(key => this.loadFileClasses(exported[key], allLoaded));\n\n } else if (exported instanceof Array) {\n exported.forEach((i: any) => this.loadFileClasses(i, allLoaded));\n }\n\n return allLoaded;\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClassUtils = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const Constants_1 = require("../Constants");
|
|
6
|
+
class ClassUtils {
|
|
7
|
+
static getClassName(klass) {
|
|
8
|
+
if (lodash_1.isString(klass)) {
|
|
9
|
+
return klass;
|
|
10
|
+
}
|
|
11
|
+
else if (lodash_1.isFunction(klass)) {
|
|
12
|
+
return klass.name;
|
|
13
|
+
}
|
|
14
|
+
else if (lodash_1.isObject(klass)) {
|
|
15
|
+
return klass.constructor.name;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
throw new Error('class not found!');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
static getFunction(klass) {
|
|
22
|
+
if (lodash_1.isString(klass)) {
|
|
23
|
+
// TODO create error class
|
|
24
|
+
throw new Error('class not found! 02');
|
|
25
|
+
}
|
|
26
|
+
else if (lodash_1.isFunction(klass)) {
|
|
27
|
+
return klass;
|
|
28
|
+
}
|
|
29
|
+
else if (lodash_1.isObject(klass)) {
|
|
30
|
+
return klass.constructor;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// TODO create error class
|
|
34
|
+
throw new Error('class not found! 01');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
static getSource(cls) {
|
|
38
|
+
let _path = null;
|
|
39
|
+
if (Reflect && Reflect['getOwnMetadata']) {
|
|
40
|
+
_path = Reflect['getOwnMetadata'](Constants_1.__SOURCE__, cls);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
_path = cls[Constants_1.__SOURCE__] ? cls[Constants_1.__SOURCE__] : null;
|
|
44
|
+
}
|
|
45
|
+
return _path;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.ClassUtils = ClassUtils;
|
|
49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CAAC,GAAG,CAAC,sBAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;SAClD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAEF;AAtCD,gCAsCC","file":"ClassUtils.js","sourcesContent":["import {isNull, isNumber, find, isString, snakeCase, concat, isArray, keys, isFunction, isObject} from 'lodash';\nimport {__SOURCE__} from '../Constants';\n\nexport class ClassUtils {\n static getClassName(klass: string | Function) {\n if (isString(klass)) {\n return klass;\n } else if (isFunction(klass)) {\n return klass.name;\n } else if (isObject(klass)) {\n return klass.constructor.name;\n } else {\n throw new Error('class not found!');\n }\n }\n\n\n static getFunction(klass: string | Function) {\n if (isString(klass)) {\n // TODO create error class\n throw new Error('class not found! 02');\n } else if (isFunction(klass)) {\n return klass;\n } else if (isObject(klass)) {\n return klass.constructor;\n } else {\n // TODO create error class\n throw new Error('class not found! 01');\n }\n }\n\n static getSource(cls: Function): string {\n let _path = null;\n if (Reflect && Reflect['getOwnMetadata']) {\n _path = Reflect['getOwnMetadata'](__SOURCE__, cls);\n } else {\n _path = cls[__SOURCE__] ? cls[__SOURCE__] : null;\n }\n return _path;\n }\n\n}\n"],"sourceRoot":".."}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class CryptUtils {
|
|
2
|
+
static bitwise(str: string): number;
|
|
3
|
+
private static binaryTransfer;
|
|
4
|
+
/**
|
|
5
|
+
* why choose 61 binary, because we need the last element char to replace the minus sign
|
|
6
|
+
* eg: -aGtzd will be ZaGtzd
|
|
7
|
+
*/
|
|
8
|
+
static shorthash(text: string): string;
|
|
9
|
+
static random(_len?: number): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CryptUtils = void 0;
|
|
4
|
+
class CryptUtils {
|
|
5
|
+
static bitwise(str) {
|
|
6
|
+
let hash = 0;
|
|
7
|
+
if (str.length === 0) {
|
|
8
|
+
return hash;
|
|
9
|
+
}
|
|
10
|
+
for (let i = 0; i < str.length; i++) {
|
|
11
|
+
const ch = str.charCodeAt(i);
|
|
12
|
+
// tslint:disable-next-line:no-bitwise
|
|
13
|
+
hash = ((hash << 5) - hash) + ch;
|
|
14
|
+
// tslint:disable-next-line:no-bitwise
|
|
15
|
+
hash = hash & hash; // Convert to 32bit integer
|
|
16
|
+
}
|
|
17
|
+
return hash;
|
|
18
|
+
}
|
|
19
|
+
static binaryTransfer(integer, binary) {
|
|
20
|
+
binary = binary || 62;
|
|
21
|
+
const stack = [];
|
|
22
|
+
let num;
|
|
23
|
+
let result = '';
|
|
24
|
+
const sign = integer < 0 ? '-' : '';
|
|
25
|
+
function table(num) {
|
|
26
|
+
const t = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
27
|
+
return t[num];
|
|
28
|
+
}
|
|
29
|
+
integer = Math.abs(integer);
|
|
30
|
+
while (integer >= binary) {
|
|
31
|
+
num = integer % binary;
|
|
32
|
+
integer = Math.floor(integer / binary);
|
|
33
|
+
stack.push(table(num));
|
|
34
|
+
}
|
|
35
|
+
if (integer > 0) {
|
|
36
|
+
stack.push(table(integer));
|
|
37
|
+
}
|
|
38
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
39
|
+
result += stack[i];
|
|
40
|
+
}
|
|
41
|
+
return sign + result;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* why choose 61 binary, because we need the last element char to replace the minus sign
|
|
45
|
+
* eg: -aGtzd will be ZaGtzd
|
|
46
|
+
*/
|
|
47
|
+
static shorthash(text) {
|
|
48
|
+
const id = this.binaryTransfer(this.bitwise(text), 61);
|
|
49
|
+
return id.replace('-', 'Z');
|
|
50
|
+
}
|
|
51
|
+
static random(_len = 8) {
|
|
52
|
+
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';
|
|
53
|
+
let rs = '';
|
|
54
|
+
const len = _len || 8;
|
|
55
|
+
for (let i = 0; i < len; i++) {
|
|
56
|
+
const pos = Math.floor(Math.random() * chars.length);
|
|
57
|
+
rs += chars.substring(pos, pos + 1);
|
|
58
|
+
}
|
|
59
|
+
return rs;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.CryptUtils = CryptUtils;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=CryptUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/CryptUtils.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAU;IAErB,MAAM,CAAC,OAAO,CAAC,GAAW;QACxB,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;YACpB,OAAO,IAAI,CAAC;SACb;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,MAAM,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7B,sCAAsC;YACtC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACjC,sCAAsC;YACtC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,2BAA2B;SAChD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,MAAM,CAAC,cAAc,CAAC,OAAe,EAAE,MAAW;QACxD,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,IAAI,GAAG,CAAC;QACR,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAEpC,SAAS,KAAK,CAAC,GAAQ;YACrB,MAAM,CAA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AM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YACrD,EAAE,IAAI,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;SACrC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAvED,gCAuEC","file":"CryptUtils.js","sourcesContent":["export class CryptUtils {\n\n static bitwise(str: string): number {\n let hash = 0;\n if (str.length === 0) {\n return hash;\n }\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i);\n // tslint:disable-next-line:no-bitwise\n hash = ((hash << 5) - hash) + ch;\n // tslint:disable-next-line:no-bitwise\n hash = hash & hash; // Convert to 32bit integer\n }\n return hash;\n }\n\n private static binaryTransfer(integer: number, binary: any) {\n binary = binary || 62;\n const stack = [];\n let num;\n let result = '';\n const sign = integer < 0 ? '-' : '';\n\n function table(num: any) {\n const t = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\n return t[num];\n }\n\n integer = Math.abs(integer);\n\n while (integer >= binary) {\n num = integer % binary;\n integer = Math.floor(integer / binary);\n stack.push(table(num));\n }\n\n if (integer > 0) {\n stack.push(table(integer));\n }\n\n for (let i = stack.length - 1; i >= 0; i--) {\n result += stack[i];\n }\n\n return sign + result;\n }\n\n\n /**\n * why choose 61 binary, because we need the last element char to replace the minus sign\n * eg: -aGtzd will be ZaGtzd\n */\n\n static shorthash(text: string): string {\n const id = this.binaryTransfer(this.bitwise(text), 61);\n return id.replace('-', 'Z');\n }\n\n\n static random(_len: number = 8): string {\n\n const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz';\n let rs = '';\n const len = _len || 8;\n for (let i = 0; i < len; i++) {\n const pos = Math.floor(Math.random() * chars.length);\n rs += chars.substring(pos, pos + 1);\n }\n return rs;\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
export declare class FileUtils {
|
|
4
|
+
static _GLOB: any;
|
|
5
|
+
static _getGlob(): any;
|
|
6
|
+
static glob(lib_path: string): Promise<string[]>;
|
|
7
|
+
static getJson(filepath: string): Promise<any>;
|
|
8
|
+
static getJsonSync(filepath: string): any;
|
|
9
|
+
static readFile(filename: string): Promise<Buffer>;
|
|
10
|
+
static readFileSync(filename: string): Buffer;
|
|
11
|
+
static writeFileSync(filename: string, content: Buffer | string, options?: fs.WriteFileOptions | string | null): void;
|
|
12
|
+
static writeFile(filename: string, content: string | Buffer, options?: fs.WriteFileOptions | string | null): Promise<void>;
|
|
13
|
+
static deleteFile(dir: string, file: string): Promise<{}>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileUtils = void 0;
|
|
4
|
+
const PlatformUtils_1 = require("./PlatformUtils");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
class FileUtils {
|
|
8
|
+
static _getGlob() {
|
|
9
|
+
if (!this._GLOB) {
|
|
10
|
+
this._GLOB = PlatformUtils_1.PlatformUtils.load('glob');
|
|
11
|
+
}
|
|
12
|
+
return this._GLOB;
|
|
13
|
+
}
|
|
14
|
+
static glob(lib_path) {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
this._getGlob()(lib_path, ((err, matches) => {
|
|
17
|
+
if (err) {
|
|
18
|
+
reject(err);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
resolve(matches);
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
static async getJson(filepath) {
|
|
27
|
+
try {
|
|
28
|
+
const data = await this.readFile(filepath);
|
|
29
|
+
return JSON.parse(data.toString('utf-8'));
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
static getJsonSync(filepath) {
|
|
36
|
+
try {
|
|
37
|
+
const data = this.readFileSync(filepath);
|
|
38
|
+
return JSON.parse(data.toString('utf-8'));
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
static readFile(filename) {
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
fs.readFile(filename, (err, data) => {
|
|
47
|
+
if (err) {
|
|
48
|
+
reject(err);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
resolve(data);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
static readFileSync(filename) {
|
|
57
|
+
return fs.readFileSync(filename);
|
|
58
|
+
}
|
|
59
|
+
static writeFileSync(filename, content, options) {
|
|
60
|
+
return fs.writeFileSync(filename, content, options);
|
|
61
|
+
}
|
|
62
|
+
static writeFile(filename, content, options) {
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
fs.writeFile(filename, content, options, (err) => {
|
|
65
|
+
if (err) {
|
|
66
|
+
reject(err);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
resolve();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
static deleteFile(dir, file) {
|
|
75
|
+
return new Promise(function (resolve, reject) {
|
|
76
|
+
const filePath = path.join(dir, file);
|
|
77
|
+
fs.lstat(filePath, function (err, stats) {
|
|
78
|
+
if (err) {
|
|
79
|
+
return reject(err);
|
|
80
|
+
}
|
|
81
|
+
if (stats.isDirectory()) {
|
|
82
|
+
resolve(PlatformUtils_1.PlatformUtils.deleteDirectory(filePath));
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
fs.unlink(filePath, function (err) {
|
|
86
|
+
if (err) {
|
|
87
|
+
return reject(err);
|
|
88
|
+
}
|
|
89
|
+
resolve(null);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.FileUtils = FileUtils;
|
|
97
|
+
FileUtils._GLOB = null;
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=FileUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/FileUtils.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAC9C,6BAA6B;AAC7B,yBAAyB;AAGzB,MAAa,SAAS;IAIpB,MAAM,CAAC,QAAQ;QACb,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,KAAK,GAAG,6BAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACzC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAGD,MAAM,CAAC,IAAI,CAAC,QAAgB;QAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAU,EAAE,OAAiB,EAAE,EAAE;gBAC3D,IAAI,GAAG,EAAE;oBACP,MAAM,CAAC,GAAG,CAAC,CAAC;iBACb;qBAAM;oBACL,OAAO,CAAC,OAAO,CAAC,CAAC;iBAClB;YACH,CAAC,CAAC,CAAC,CAAC;QACN,CAAC,CAAC,CAAC;IACL,CAAC;IAGD,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAgB;QACnC,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;SAC3C;QAAC,OAAO,CAAC,EAAE;SACX;QACD,OAAO,IAAI,CAAC;IACd,CAAC;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,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAGD,MAAM,CAAC,UAAU,CAAC,GAAW,EAAE,IAAY;QACzC,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM;YAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACtC,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,GAAG,EAAE,KAAK;gBACrC,IAAI,GAAG,EAAE;oBACP,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;iBACpB;gBACD,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;oBACvB,OAAO,CAAC,6BAAa,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;iBAClD;qBAAM;oBACL,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,GAAG;wBAC/B,IAAI,GAAG,EAAE;4BACP,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;yBACpB;wBACD,OAAO,CAAC,IAAI,CAAC,CAAC;oBAChB,CAAC,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;;AAlGH,8BAoGC;AAlGQ,eAAK,GAAQ,IAAI,CAAC","file":"FileUtils.js","sourcesContent":["import {PlatformUtils} from './PlatformUtils';\nimport * as path from 'path';\nimport * as fs from 'fs';\n\n\nexport class FileUtils {\n\n static _GLOB: any = null;\n\n static _getGlob() {\n if (!this._GLOB) {\n this._GLOB = PlatformUtils.load('glob');\n }\n return this._GLOB;\n }\n\n\n static glob(lib_path: string): Promise<string[]> {\n return new Promise((resolve, reject) => {\n this._getGlob()(lib_path, ((err: Error, matches: string[]) => {\n if (err) {\n reject(err);\n } else {\n resolve(matches);\n }\n }));\n });\n }\n\n\n static async getJson(filepath: string): Promise<any> {\n try {\n const data = await this.readFile(filepath);\n return JSON.parse(data.toString('utf-8'));\n } catch (e) {\n }\n return null;\n }\n\n static getJsonSync(filepath: string): any {\n try {\n const data = this.readFileSync(filepath);\n return JSON.parse(data.toString('utf-8'));\n } catch (e) {\n }\n return null;\n }\n\n\n static readFile(filename: string): Promise<Buffer> {\n return new Promise((resolve, reject) => {\n fs.readFile(filename, (err, data) => {\n if (err) {\n reject(err);\n } else {\n resolve(data);\n }\n });\n });\n }\n\n static readFileSync(filename: string): Buffer {\n return fs.readFileSync(filename);\n }\n\n static writeFileSync(filename: string, content: Buffer | string,\n options?: fs.WriteFileOptions | string | null): void {\n return fs.writeFileSync(filename, content, options);\n }\n\n static writeFile(filename: string, content: string | Buffer,\n options?: fs.WriteFileOptions | string | null): Promise<void> {\n return new Promise((resolve, reject) => {\n fs.writeFile(filename, content, options, (err) => {\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n });\n });\n }\n\n\n static deleteFile(dir: string, file: string): Promise<{}> {\n return new Promise(function (resolve, reject) {\n const filePath = path.join(dir, file);\n fs.lstat(filePath, function (err, stats) {\n if (err) {\n return reject(err);\n }\n if (stats.isDirectory()) {\n resolve(PlatformUtils.deleteDirectory(filePath));\n } else {\n fs.unlink(filePath, function (err) {\n if (err) {\n return reject(err);\n }\n resolve(null);\n });\n }\n });\n });\n }\n\n}\n"],"sourceRoot":".."}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonUtils = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const TreeUtils_1 = require("./TreeUtils");
|
|
6
|
+
const Constants_1 = require("../Constants");
|
|
7
|
+
class JsonUtils {
|
|
8
|
+
static parse(json) {
|
|
9
|
+
let _json = JSON.parse(json);
|
|
10
|
+
_json = this.correctTypes(_json);
|
|
11
|
+
return _json;
|
|
12
|
+
}
|
|
13
|
+
static correctTypes(c) {
|
|
14
|
+
TreeUtils_1.TreeUtils.walk(c, x => {
|
|
15
|
+
if (x.value && lodash_1.isString(x.value) && x.value.length < 48 && x.value.length > 0) {
|
|
16
|
+
if (Constants_1.ISO8601.test(x.value)) {
|
|
17
|
+
const date = new Date(x.value);
|
|
18
|
+
if (lodash_1.isNumber(x.index)) {
|
|
19
|
+
x.parent[x.index] = date;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
x.parent[x.key] = date;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return c;
|
|
28
|
+
}
|
|
29
|
+
static stringify(obj) {
|
|
30
|
+
return JSON.stringify(obj);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.JsonUtils = JsonUtils;
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=JsonUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/JsonUtils.ts"],"names":[],"mappings":";;;AAAA,mCAA0C;AAC1C,2CAAsC;AACtC,4CAAqC;AAErC,MAAa,SAAS;IAEpB,MAAM,CAAC,KAAK,CAAC,IAAY;QACvB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,CAAM;QACxB,qBAAS,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;YAClB,IAAI,CAAC,CAAC,KAAK,IAAI,iBAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC7E,IAAI,mBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;oBACzB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;oBAC/B,IAAI,iBAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;wBACrB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;qBAC1B;yBAAM;wBACL,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;qBACxB;iBACF;aACF;QACH,CAAC,CACF,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC;IAGD,MAAM,CAAC,SAAS,CAAC,GAAQ;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF;AA7BD,8BA6BC","file":"JsonUtils.js","sourcesContent":["import {isNumber, isString} from 'lodash';\nimport {TreeUtils} from './TreeUtils';\nimport {ISO8601} from '../Constants';\n\nexport class JsonUtils {\n\n static parse(json: string) {\n let _json = JSON.parse(json);\n _json = this.correctTypes(_json);\n return _json;\n }\n\n static correctTypes(c: any) {\n TreeUtils.walk(c, x => {\n if (x.value && isString(x.value) && x.value.length < 48 && x.value.length > 0) {\n if (ISO8601.test(x.value)) {\n const date = new Date(x.value);\n if (isNumber(x.index)) {\n x.parent[x.index] = date;\n } else {\n x.parent[x.key] = date;\n }\n }\n }\n }\n );\n return c;\n }\n\n\n static stringify(obj: any) {\n return JSON.stringify(obj);\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* see https://github.com/typeorm/typeorm/blob/master/src/platform/PlatformTools.ts
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Platform-specific tools.
|
|
7
|
+
*/
|
|
8
|
+
export declare class PlatformUtils {
|
|
9
|
+
/**
|
|
10
|
+
* Type of the currently running platform.
|
|
11
|
+
*/
|
|
12
|
+
static type: 'browser' | 'node';
|
|
13
|
+
static workdir: string;
|
|
14
|
+
/**
|
|
15
|
+
* Gets global variable where global stuff can be stored.
|
|
16
|
+
*/
|
|
17
|
+
static getGlobalVariable(): any;
|
|
18
|
+
/**
|
|
19
|
+
* set workdir
|
|
20
|
+
*/
|
|
21
|
+
static setWorkDir(workdir: string): void;
|
|
22
|
+
static join(...args: string[]): string;
|
|
23
|
+
/**
|
|
24
|
+
* Loads ("require"-s) given file or package.
|
|
25
|
+
* This operation only supports on node platform
|
|
26
|
+
*/
|
|
27
|
+
static load(name: string): any;
|
|
28
|
+
/**
|
|
29
|
+
* Loads ("require"-s) given file or package.
|
|
30
|
+
* This operation only supports on node platform
|
|
31
|
+
*/
|
|
32
|
+
static loadAsync(name: string): Promise<any>;
|
|
33
|
+
/**
|
|
34
|
+
* Normalizes given path. Does "path.normalize".
|
|
35
|
+
*/
|
|
36
|
+
static pathNormilize(pathStr: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Gets file extension. Does "path.extname".
|
|
39
|
+
*/
|
|
40
|
+
static pathExtname(pathStr: string, dotted?: boolean): string;
|
|
41
|
+
/**
|
|
42
|
+
* Resolved given path. Does "path.resolve".
|
|
43
|
+
*/
|
|
44
|
+
static pathResolve(pathStr: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Resolved given path. Does "path.resolve".
|
|
47
|
+
*/
|
|
48
|
+
static pathNormAndResolve(pathStr: string): string;
|
|
49
|
+
static isFile(pathStr: string): boolean;
|
|
50
|
+
static isDir(pathStr: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Synchronously checks if file exist. Does "fs.existsSync".
|
|
53
|
+
*/
|
|
54
|
+
static fileExist(pathStr: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Synchronously checks if file exist. Does "fs.existsSync".
|
|
57
|
+
*/
|
|
58
|
+
static fileExistAsync(pathStr: string): Promise<boolean>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the basename of a file
|
|
61
|
+
*/
|
|
62
|
+
static basename(pathStr: string): string;
|
|
63
|
+
static withoutInterpolation(str: string, fn: (str: string) => string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the filename only (without extension)
|
|
66
|
+
*/
|
|
67
|
+
static filename(pathStr: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* Returns the dirname of the file
|
|
70
|
+
*/
|
|
71
|
+
static dirname(pathStr: string): string;
|
|
72
|
+
static testForFilePath(path: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Normalizes given path. Does "path.normalize".
|
|
75
|
+
*/
|
|
76
|
+
static pathNormalize(pathStr: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* Normalizes given path. Does "path.normalize".
|
|
79
|
+
*/
|
|
80
|
+
static pathResolveAndNormalize(pathStr: string): string;
|
|
81
|
+
/**
|
|
82
|
+
* Test if path is absolute.
|
|
83
|
+
*/
|
|
84
|
+
static isAbsolute(pathStr: string): boolean;
|
|
85
|
+
static directory(file: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* Gets environment variable.
|
|
88
|
+
*/
|
|
89
|
+
static getEnvVariable(name: string): any;
|
|
90
|
+
static getHostPath(): string;
|
|
91
|
+
static getHostFileContent(): string;
|
|
92
|
+
static mkdir(targetDir: string, sep?: string): boolean;
|
|
93
|
+
static readFile(filename: string): Promise<Buffer>;
|
|
94
|
+
static readFileSync(filename: string): Buffer;
|
|
95
|
+
static deleteFile(dir: string, file: string): Promise<{}>;
|
|
96
|
+
static deleteDirectory(dir: string): Promise<{}>;
|
|
97
|
+
}
|