@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.
Files changed (84) hide show
  1. package/Constants.d.ts +11 -0
  2. package/Constants.js +15 -0
  3. package/Constants.js.map +1 -0
  4. package/LICENSE +23 -0
  5. package/MetaArgs.d.ts +9 -0
  6. package/MetaArgs.js +21 -0
  7. package/MetaArgs.js.map +1 -0
  8. package/MetadataStorage.d.ts +17 -0
  9. package/MetadataStorage.js +47 -0
  10. package/MetadataStorage.js.map +1 -0
  11. package/README.md +6 -0
  12. package/browser.d.ts +2 -0
  13. package/browser.js +32 -0
  14. package/browser.js.map +1 -0
  15. package/exceptions/NestedException.d.ts +11 -0
  16. package/exceptions/NestedException.js +31 -0
  17. package/exceptions/NestedException.js.map +1 -0
  18. package/exceptions/NotSupportedError.d.ts +3 -0
  19. package/exceptions/NotSupportedError.js +11 -0
  20. package/exceptions/NotSupportedError.js.map +1 -0
  21. package/exceptions/NotYetImplementedError.d.ts +3 -0
  22. package/exceptions/NotYetImplementedError.js +11 -0
  23. package/exceptions/NotYetImplementedError.js.map +1 -0
  24. package/exceptions/TodoException.d.ts +3 -0
  25. package/exceptions/TodoException.js +11 -0
  26. package/exceptions/TodoException.js.map +1 -0
  27. package/index.d.ts +4 -0
  28. package/index.js +36 -0
  29. package/index.js.map +1 -0
  30. package/locking/LockFactory.d.ts +15 -0
  31. package/locking/LockFactory.js +60 -0
  32. package/locking/LockFactory.js.map +1 -0
  33. package/locking/Semaphore.d.ts +45 -0
  34. package/locking/Semaphore.js +108 -0
  35. package/locking/Semaphore.js.map +1 -0
  36. package/logging/AbstractLogger.d.ts +24 -0
  37. package/logging/AbstractLogger.js +73 -0
  38. package/logging/AbstractLogger.js.map +1 -0
  39. package/logging/ConsoleLogger.d.ts +4 -0
  40. package/logging/ConsoleLogger.js +31 -0
  41. package/logging/ConsoleLogger.js.map +1 -0
  42. package/logging/ILogLevel.d.ts +4 -0
  43. package/logging/ILogLevel.js +4 -0
  44. package/logging/ILogLevel.js.map +1 -0
  45. package/logging/ILoggerApi.d.ts +12 -0
  46. package/logging/ILoggerApi.js +4 -0
  47. package/logging/ILoggerApi.js.map +1 -0
  48. package/logging/ILoggerOptions.d.ts +7 -0
  49. package/logging/ILoggerOptions.js +4 -0
  50. package/logging/ILoggerOptions.js.map +1 -0
  51. package/logging/Logger.d.ts +23 -0
  52. package/logging/Logger.js +66 -0
  53. package/logging/Logger.js.map +1 -0
  54. package/package.json +63 -0
  55. package/shared.d.ts +20 -0
  56. package/shared.js +47 -0
  57. package/shared.js.map +1 -0
  58. package/utils/ClassLoader.d.ts +28 -0
  59. package/utils/ClassLoader.js +183 -0
  60. package/utils/ClassLoader.js.map +1 -0
  61. package/utils/ClassUtils.d.ts +5 -0
  62. package/utils/ClassUtils.js +50 -0
  63. package/utils/ClassUtils.js.map +1 -0
  64. package/utils/CryptUtils.d.ts +10 -0
  65. package/utils/CryptUtils.js +64 -0
  66. package/utils/CryptUtils.js.map +1 -0
  67. package/utils/FileUtils.d.ts +14 -0
  68. package/utils/FileUtils.js +99 -0
  69. package/utils/FileUtils.js.map +1 -0
  70. package/utils/JsonUtils.d.ts +5 -0
  71. package/utils/JsonUtils.js +35 -0
  72. package/utils/JsonUtils.js.map +1 -0
  73. package/utils/PlatformUtils.d.ts +97 -0
  74. package/utils/PlatformUtils.js +288 -0
  75. package/utils/PlatformUtils.js.map +1 -0
  76. package/utils/PlatformUtilsBrowser.d.ts +86 -0
  77. package/utils/PlatformUtilsBrowser.js +177 -0
  78. package/utils/PlatformUtilsBrowser.js.map +1 -0
  79. package/utils/Serializer.d.ts +9 -0
  80. package/utils/Serializer.js +84 -0
  81. package/utils/Serializer.js.map +1 -0
  82. package/utils/TreeUtils.d.ts +12 -0
  83. package/utils/TreeUtils.js +110 -0
  84. package/utils/TreeUtils.js.map +1 -0
@@ -0,0 +1,288 @@
1
+ "use strict";
2
+ /**
3
+ * see https://github.com/typeorm/typeorm/blob/master/src/platform/PlatformTools.ts
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PlatformUtils = void 0;
7
+ const path = require("path");
8
+ const fs = require("fs");
9
+ const lodash_1 = require("lodash");
10
+ const FileUtils_1 = require("./FileUtils");
11
+ const FILEPATH = path.sep === '/' ? /^(\.|\.\/|\/)([\w\/\.\-_ ]*)$/ : /^(?:[a-zA-Z]\:|\\\\[\w\.]+\\[\w.$]+)\\(?:[\w]+\\)*\w([\w.])+$/;
12
+ /**
13
+ * Platform-specific tools.
14
+ */
15
+ class PlatformUtils {
16
+ /**
17
+ * Gets global variable where global stuff can be stored.
18
+ */
19
+ static getGlobalVariable() {
20
+ return global;
21
+ }
22
+ /**
23
+ * set workdir
24
+ */
25
+ static setWorkDir(workdir) {
26
+ if (lodash_1.isString(workdir)) {
27
+ this.workdir = PlatformUtils.pathResolve(workdir);
28
+ }
29
+ else {
30
+ this.workdir = null;
31
+ }
32
+ }
33
+ static join(...args) {
34
+ return path.join(...args);
35
+ }
36
+ /**
37
+ * Loads ("require"-s) given file or package.
38
+ * This operation only supports on node platform
39
+ */
40
+ static load(name) {
41
+ // if name is not absolute or relative, then try to load package from the node_modules of the directory we are currenly in
42
+ // this is useful when we are using typeorm package globally installed and it accesses drivers
43
+ // that are not installed globally
44
+ try {
45
+ if (this.fileExist(name)) {
46
+ const ext = this.pathExtname(name);
47
+ if (ext) {
48
+ // name without ext
49
+ name = name.replace(ext, '');
50
+ }
51
+ }
52
+ return require(name);
53
+ }
54
+ catch (err) {
55
+ if (!path.isAbsolute(name) && name.substr(0, 2) !== './' && name.substr(0, 3) !== '../') {
56
+ return require(path.resolve(process.cwd() + '/node_modules/' + name));
57
+ }
58
+ throw err;
59
+ }
60
+ }
61
+ /**
62
+ * Loads ("require"-s) given file or package.
63
+ * This operation only supports on node platform
64
+ */
65
+ static loadAsync(name) {
66
+ // if name is not absolute or relative, then try to load package from the node_modules of the directory we are currenly in
67
+ // this is useful when we are using typeorm package globally installed and it accesses drivers
68
+ // that are not installed globally
69
+ try {
70
+ if (this.fileExist(name)) {
71
+ const ext = this.pathExtname(name);
72
+ if (ext) {
73
+ // name without ext
74
+ name = name.replace(ext, '');
75
+ }
76
+ }
77
+ return Promise.resolve().then(() => require(name));
78
+ }
79
+ catch (err) {
80
+ if (!path.isAbsolute(name) && name.substr(0, 2) !== './' && name.substr(0, 3) !== '../') {
81
+ return Promise.resolve().then(() => require(path.resolve(process.cwd() + '/node_modules/' + name)));
82
+ }
83
+ throw err;
84
+ }
85
+ }
86
+ /**
87
+ * Normalizes given path. Does "path.normalize".
88
+ */
89
+ static pathNormilize(pathStr) {
90
+ return path.normalize(pathStr);
91
+ }
92
+ /**
93
+ * Gets file extension. Does "path.extname".
94
+ */
95
+ static pathExtname(pathStr, dotted = true) {
96
+ let str = '';
97
+ if (/\$\{.*\}/.test(pathStr)) {
98
+ str = this.withoutInterpolation(pathStr, (str) => {
99
+ return path.extname(str);
100
+ });
101
+ }
102
+ else {
103
+ str = path.extname(pathStr);
104
+ }
105
+ if (!dotted) {
106
+ str = str.replace('.', '');
107
+ }
108
+ return str;
109
+ }
110
+ /**
111
+ * Resolved given path. Does "path.resolve".
112
+ */
113
+ static pathResolve(pathStr) {
114
+ if (this.workdir) {
115
+ return path.resolve(this.workdir, pathStr);
116
+ }
117
+ return path.resolve(pathStr);
118
+ }
119
+ /**
120
+ * Resolved given path. Does "path.resolve".
121
+ */
122
+ static pathNormAndResolve(pathStr) {
123
+ return this.pathNormilize(this.pathResolve(pathStr));
124
+ }
125
+ static isFile(pathStr) {
126
+ return fs.statSync(pathStr).isFile();
127
+ }
128
+ static isDir(pathStr) {
129
+ return fs.statSync(pathStr).isDirectory();
130
+ }
131
+ /**
132
+ * Synchronously checks if file exist. Does "fs.existsSync".
133
+ */
134
+ static fileExist(pathStr) {
135
+ return fs.existsSync(pathStr);
136
+ }
137
+ /**
138
+ * Synchronously checks if file exist. Does "fs.existsSync".
139
+ */
140
+ static fileExistAsync(pathStr) {
141
+ return new Promise((resolve, reject) => {
142
+ fs.stat(pathStr, err => {
143
+ if (err) {
144
+ reject(err);
145
+ }
146
+ else {
147
+ resolve(null);
148
+ }
149
+ });
150
+ });
151
+ }
152
+ /**
153
+ * Returns the basename of a file
154
+ */
155
+ static basename(pathStr) {
156
+ return path.basename(pathStr);
157
+ }
158
+ static withoutInterpolation(str, fn) {
159
+ if (/\$\{.*\}/.test(str)) {
160
+ // has interpolations
161
+ const regex = new RegExp(/\$\{.*\}/g);
162
+ const m = regex.exec(str);
163
+ const cache = {};
164
+ let inc = 0;
165
+ for (const _m of m) {
166
+ const r = '###' + (inc++) + '###';
167
+ str = str.replace(_m, r);
168
+ cache[r] = _m;
169
+ }
170
+ str = fn(str);
171
+ for (const _m in cache) {
172
+ if (cache.hasOwnProperty(_m)) {
173
+ str = str.replace(_m, cache[_m]);
174
+ }
175
+ }
176
+ }
177
+ return str;
178
+ }
179
+ /**
180
+ * Returns the filename only (without extension)
181
+ */
182
+ static filename(pathStr) {
183
+ const base = path.basename(pathStr);
184
+ if (/\$\{.*\}/.test(base)) {
185
+ return this.withoutInterpolation(base, (str) => {
186
+ return str.replace(new RegExp('\\' + path.extname(str) + '$'), '');
187
+ });
188
+ }
189
+ return base.replace(new RegExp('\\' + path.extname(base) + '$'), '');
190
+ }
191
+ /**
192
+ * Returns the dirname of the file
193
+ */
194
+ static dirname(pathStr) {
195
+ return path.dirname(pathStr);
196
+ }
197
+ static testForFilePath(path) {
198
+ return FILEPATH.test(path);
199
+ }
200
+ /**
201
+ * Normalizes given path. Does "path.normalize".
202
+ */
203
+ static pathNormalize(pathStr) {
204
+ return path.normalize(pathStr);
205
+ }
206
+ /**
207
+ * Normalizes given path. Does "path.normalize".
208
+ */
209
+ static pathResolveAndNormalize(pathStr) {
210
+ return this.pathNormalize(this.pathResolve(pathStr));
211
+ }
212
+ /**
213
+ * Test if path is absolute.
214
+ */
215
+ static isAbsolute(pathStr) {
216
+ return path.isAbsolute(pathStr);
217
+ }
218
+ static directory(file) {
219
+ return path.dirname(file);
220
+ }
221
+ /**
222
+ * Gets environment variable.
223
+ */
224
+ static getEnvVariable(name) {
225
+ return process.env[name];
226
+ }
227
+ static getHostPath() {
228
+ if (process.platform === 'win32') {
229
+ return path.join(process.env.SYSTEMROOT, '/System32/drivers/etc/hosts');
230
+ }
231
+ return '/etc/hosts';
232
+ }
233
+ static getHostFileContent() {
234
+ return fs.readFileSync(this.getHostPath(), { encoding: 'utf-8' });
235
+ }
236
+ static mkdir(targetDir, sep = path.sep) {
237
+ const initDir = path.isAbsolute(targetDir) ? sep : '';
238
+ targetDir.split(sep).reduce((parentDir, childDir) => {
239
+ const curDir = path.resolve(parentDir, childDir);
240
+ if (!fs.existsSync(curDir)) {
241
+ fs.mkdirSync(curDir);
242
+ }
243
+ return curDir;
244
+ }, initDir);
245
+ return true;
246
+ }
247
+ static readFile(filename) {
248
+ return FileUtils_1.FileUtils.readFile(filename);
249
+ }
250
+ static readFileSync(filename) {
251
+ return FileUtils_1.FileUtils.readFileSync(filename);
252
+ }
253
+ static deleteFile(dir, file) {
254
+ return FileUtils_1.FileUtils.deleteFile(dir, file);
255
+ }
256
+ static deleteDirectory(dir) {
257
+ return new Promise(function (resolve, reject) {
258
+ fs.access(dir, function (err) {
259
+ if (err) {
260
+ return reject(err);
261
+ }
262
+ fs.readdir(dir, function (err, files) {
263
+ if (err) {
264
+ return reject(err);
265
+ }
266
+ Promise.all(files.map(function (file) {
267
+ return PlatformUtils.deleteFile(dir, file);
268
+ })).then(function () {
269
+ fs.rmdir(dir, function (err) {
270
+ if (err) {
271
+ return reject(err);
272
+ }
273
+ resolve(null);
274
+ });
275
+ }).catch(reject);
276
+ });
277
+ });
278
+ });
279
+ }
280
+ }
281
+ exports.PlatformUtils = PlatformUtils;
282
+ /**
283
+ * Type of the currently running platform.
284
+ */
285
+ PlatformUtils.type = 'node';
286
+ PlatformUtils.workdir = null;
287
+
288
+ //# sourceMappingURL=PlatformUtils.js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blob/master/src/platform/PlatformTools.ts\n */\n\n\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport {isString} from 'lodash';\nimport {FileUtils} from './FileUtils';\n\n\nconst FILEPATH = path.sep === '/' ? /^(\\.|\\.\\/|\\/)([\\w\\/\\.\\-_ ]*)$/ : /^(?:[a-zA-Z]\\:|\\\\\\\\[\\w\\.]+\\\\[\\w.$]+)\\\\(?:[\\w]+\\\\)*\\w([\\w.])+$/;\n\n/**\n * Platform-specific tools.\n */\nexport class PlatformUtils {\n\n /**\n * Type of the currently running platform.\n */\n static type: 'browser' | 'node' = 'node';\n\n static workdir: string = null;\n\n /**\n * Gets global variable where global stuff can be stored.\n */\n static getGlobalVariable(): any {\n return global;\n }\n\n\n /**\n * set workdir\n */\n static setWorkDir(workdir: string) {\n if (isString(workdir)) {\n this.workdir = PlatformUtils.pathResolve(workdir);\n } else {\n this.workdir = null;\n }\n }\n\n\n static join(...args: string[]) {\n return path.join(...args);\n }\n\n /**\n * Loads (\"require\"-s) given file or package.\n * This operation only supports on node platform\n */\n static load(name: string): any {\n\n // if name is not absolute or relative, then try to load package from the node_modules of the directory we are currenly in\n // this is useful when we are using typeorm package globally installed and it accesses drivers\n // that are not installed globally\n\n try {\n if (this.fileExist(name)) {\n const ext = this.pathExtname(name);\n if (ext) {\n // name without ext\n name = name.replace(ext, '');\n }\n }\n return require(name);\n } catch (err) {\n if (!path.isAbsolute(name) && name.substr(0, 2) !== './' && name.substr(0, 3) !== '../') {\n return require(path.resolve(process.cwd() + '/node_modules/' + name));\n }\n\n throw err;\n }\n }\n\n /**\n * Loads (\"require\"-s) given file or package.\n * This operation only supports on node platform\n */\n static loadAsync(name: string): Promise<any> {\n\n // if name is not absolute or relative, then try to load package from the node_modules of the directory we are currenly in\n // this is useful when we are using typeorm package globally installed and it accesses drivers\n // that are not installed globally\n\n try {\n if (this.fileExist(name)) {\n const ext = this.pathExtname(name);\n if (ext) {\n // name without ext\n name = name.replace(ext, '');\n }\n }\n return import(name);\n } catch (err) {\n if (!path.isAbsolute(name) && name.substr(0, 2) !== './' && name.substr(0, 3) !== '../') {\n return import(path.resolve(process.cwd() + '/node_modules/' + name));\n }\n\n throw err;\n }\n }\n\n /**\n * Normalizes given path. Does \"path.normalize\".\n */\n static pathNormilize(pathStr: string): string {\n return path.normalize(pathStr);\n }\n\n /**\n * Gets file extension. Does \"path.extname\".\n */\n static pathExtname(pathStr: string, dotted: boolean = true): string {\n let str = '';\n if (/\\$\\{.*\\}/.test(pathStr)) {\n str = this.withoutInterpolation(pathStr, (str) => {\n return path.extname(str);\n });\n } else {\n str = path.extname(pathStr);\n }\n if (!dotted) {\n str = str.replace('.', '');\n }\n return str;\n }\n\n /**\n * Resolved given path. Does \"path.resolve\".\n */\n static pathResolve(pathStr: string): string {\n if (this.workdir) {\n return path.resolve(this.workdir, pathStr);\n }\n return path.resolve(pathStr);\n }\n\n /**\n * Resolved given path. Does \"path.resolve\".\n */\n static pathNormAndResolve(pathStr: string): string {\n return this.pathNormilize(this.pathResolve(pathStr));\n }\n\n static isFile(pathStr: string): boolean {\n return fs.statSync(pathStr).isFile();\n }\n\n static isDir(pathStr: string): boolean {\n return fs.statSync(pathStr).isDirectory();\n }\n\n /**\n * Synchronously checks if file exist. Does \"fs.existsSync\".\n */\n static fileExist(pathStr: string): boolean {\n return fs.existsSync(pathStr);\n }\n\n /**\n * Synchronously checks if file exist. Does \"fs.existsSync\".\n */\n static fileExistAsync(pathStr: string): Promise<boolean> {\n return new Promise((resolve, reject) => {\n fs.stat(pathStr, err => {\n if (err) {\n reject(err);\n } else {\n resolve(null);\n }\n });\n });\n }\n\n /**\n * Returns the basename of a file\n */\n static basename(pathStr: string): string {\n return path.basename(pathStr);\n }\n\n static withoutInterpolation(str: string, fn: (str: string) => string) {\n if (/\\$\\{.*\\}/.test(str)) {\n // has interpolations\n const regex = new RegExp(/\\$\\{.*\\}/g);\n const m = regex.exec(str);\n const cache = {};\n let inc = 0;\n for (const _m of m) {\n const r = '###' + (inc++) + '###';\n str = str.replace(_m, r);\n cache[r] = _m;\n }\n str = fn(str);\n for (const _m in cache) {\n if (cache.hasOwnProperty(_m)) {\n str = str.replace(_m, cache[_m]);\n }\n }\n }\n return str;\n }\n\n /**\n * Returns the filename only (without extension)\n */\n static filename(pathStr: string): string {\n const base = path.basename(pathStr);\n if (/\\$\\{.*\\}/.test(base)) {\n return this.withoutInterpolation(base, (str) => {\n return str.replace(new RegExp('\\\\' + path.extname(str) + '$'), '');\n });\n }\n return base.replace(new RegExp('\\\\' + path.extname(base) + '$'), '');\n }\n\n\n /**\n * Returns the dirname of the file\n */\n static dirname(pathStr: string): string {\n return path.dirname(pathStr);\n }\n\n\n static testForFilePath(path: string) {\n return FILEPATH.test(path);\n }\n\n /**\n * Normalizes given path. Does \"path.normalize\".\n */\n static pathNormalize(pathStr: string): string {\n return path.normalize(pathStr);\n }\n\n /**\n * Normalizes given path. Does \"path.normalize\".\n */\n static pathResolveAndNormalize(pathStr: string): string {\n return this.pathNormalize(this.pathResolve(pathStr));\n }\n\n\n /**\n * Test if path is absolute.\n */\n static isAbsolute(pathStr: string): boolean {\n return path.isAbsolute(pathStr);\n }\n\n static directory(file: string): string {\n return path.dirname(file);\n }\n\n\n /**\n * Gets environment variable.\n */\n static getEnvVariable(name: string): any {\n return process.env[name];\n }\n\n\n static getHostPath(): string {\n if (process.platform === 'win32') {\n return path.join(process.env.SYSTEMROOT, '/System32/drivers/etc/hosts');\n }\n return '/etc/hosts';\n }\n\n static getHostFileContent(): string {\n return fs.readFileSync(this.getHostPath(), {encoding: 'utf-8'});\n }\n\n static mkdir(targetDir: string, sep: string = path.sep): boolean {\n const initDir = path.isAbsolute(targetDir) ? sep : '';\n targetDir.split(sep).reduce((parentDir, childDir) => {\n const curDir = path.resolve(parentDir, childDir);\n if (!fs.existsSync(curDir)) {\n fs.mkdirSync(curDir);\n }\n return curDir;\n }, initDir);\n return true;\n }\n\n\n static readFile(filename: string): Promise<Buffer> {\n return FileUtils.readFile(filename);\n }\n\n static readFileSync(filename: string): Buffer {\n return FileUtils.readFileSync(filename);\n }\n\n static deleteFile(dir: string, file: string): Promise<{}> {\n return FileUtils.deleteFile(dir, file);\n }\n\n static deleteDirectory(dir: string): Promise<{}> {\n return new Promise(function (resolve, reject) {\n fs.access(dir, function (err) {\n if (err) {\n return reject(err);\n }\n fs.readdir(dir, function (err, files) {\n if (err) {\n return reject(err);\n }\n Promise.all(files.map(function (file) {\n return PlatformUtils.deleteFile(dir, file);\n })).then(function () {\n fs.rmdir(dir, function (err) {\n if (err) {\n return reject(err);\n }\n resolve(null);\n });\n }).catch(reject);\n });\n });\n });\n }\n\n\n}\n"],"sourceRoot":".."}
@@ -0,0 +1,86 @@
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
+ static load(name: string): any;
24
+ static loadAsync(name: string): Promise<any>;
25
+ /**
26
+ * Normalizes given path. Does "path.normalize".
27
+ */
28
+ static pathNormilize(pathStr: string): string;
29
+ /**
30
+ * Gets file extension. Does "path.extname".
31
+ */
32
+ static pathExtname(pathStr: string, dotted?: boolean): string;
33
+ /**
34
+ * Resolved given path. Does "path.resolve".
35
+ */
36
+ static pathResolve(pathStr: string): string;
37
+ /**
38
+ * Resolved given path. Does "path.resolve".
39
+ */
40
+ static pathNormAndResolve(pathStr: string): string;
41
+ static isFile(pathStr: string): boolean;
42
+ static isDir(pathStr: string): boolean;
43
+ /**
44
+ * Synchronously checks if file exist. Does "fs.existsSync".
45
+ */
46
+ static fileExist(pathStr: string): boolean;
47
+ static fileExistAsync(pathStr: string): Promise<boolean>;
48
+ /**
49
+ * Returns the basename of a file
50
+ */
51
+ static basename(pathStr: string): string;
52
+ static withoutInterpolation(str: string, fn: (str: string) => string): string;
53
+ /**
54
+ * Returns the filename only (without extension)
55
+ */
56
+ static filename(pathStr: string): string;
57
+ /**
58
+ * Returns the dirname of the file
59
+ */
60
+ static dirname(pathStr: string): string;
61
+ static testForFilePath(path: string): void;
62
+ /**
63
+ * Normalizes given path. Does "path.normalize".
64
+ */
65
+ static pathNormalize(pathStr: string): string;
66
+ /**
67
+ * Normalizes given path. Does "path.normalize".
68
+ */
69
+ static pathResolveAndNormalize(pathStr: string): string;
70
+ /**
71
+ * Test if path is absolute.
72
+ */
73
+ static isAbsolute(pathStr: string): boolean;
74
+ static directory(file: string): string;
75
+ /**
76
+ * Gets environment variable.
77
+ */
78
+ static getEnvVariable(name: string): any;
79
+ static getHostPath(): string;
80
+ static getHostFileContent(): string;
81
+ static mkdir(targetDir: string, sep?: string): boolean;
82
+ static readFile(filename: string): Promise<Buffer>;
83
+ static readFileSync(filename: string): Buffer;
84
+ static deleteFile(dir: string, file: string): Promise<{}>;
85
+ static deleteDirectory(dir: string): Promise<{}>;
86
+ }
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ /**
3
+ * see https://github.com/typeorm/typeorm/blob/master/src/platform/PlatformTools.ts
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PlatformUtils = void 0;
7
+ const lodash_1 = require("lodash");
8
+ const NotSupportedError_1 = require("../exceptions/NotSupportedError");
9
+ // const FILEPATH = path.sep === '/' ? /^(\.|\.\/|\/)([\w\/\.\-_ ]*)$/ : /^(?:[a-zA-Z]\:|\\\\[\w\.]+\\[\w.$]+)\\(?:[\w]+\\)*\w([\w.])+$/;
10
+ /**
11
+ * Platform-specific tools.
12
+ */
13
+ class PlatformUtils {
14
+ /**
15
+ * Gets global variable where global stuff can be stored.
16
+ */
17
+ static getGlobalVariable() {
18
+ return global;
19
+ }
20
+ /**
21
+ * set workdir
22
+ */
23
+ static setWorkDir(workdir) {
24
+ if (lodash_1.isString(workdir)) {
25
+ this.workdir = PlatformUtils.pathResolve(workdir);
26
+ }
27
+ else {
28
+ this.workdir = null;
29
+ }
30
+ }
31
+ static join(...args) {
32
+ return args.join('/');
33
+ }
34
+ static load(name) {
35
+ throw new NotSupportedError_1.NotSupportedError('not supported');
36
+ }
37
+ static loadAsync(name) {
38
+ throw new NotSupportedError_1.NotSupportedError('not supported');
39
+ }
40
+ /**
41
+ * Normalizes given path. Does "path.normalize".
42
+ */
43
+ static pathNormilize(pathStr) {
44
+ throw new NotSupportedError_1.NotSupportedError('not supported');
45
+ }
46
+ /**
47
+ * Gets file extension. Does "path.extname".
48
+ */
49
+ static pathExtname(pathStr, dotted = true) {
50
+ throw new NotSupportedError_1.NotSupportedError('not supported');
51
+ }
52
+ /**
53
+ * Resolved given path. Does "path.resolve".
54
+ */
55
+ static pathResolve(pathStr) {
56
+ throw new NotSupportedError_1.NotSupportedError('not supported');
57
+ }
58
+ /**
59
+ * Resolved given path. Does "path.resolve".
60
+ */
61
+ static pathNormAndResolve(pathStr) {
62
+ return this.pathNormilize(this.pathResolve(pathStr));
63
+ }
64
+ static isFile(pathStr) {
65
+ throw new NotSupportedError_1.NotSupportedError('not supported');
66
+ }
67
+ static isDir(pathStr) {
68
+ throw new NotSupportedError_1.NotSupportedError('not supported');
69
+ }
70
+ /**
71
+ * Synchronously checks if file exist. Does "fs.existsSync".
72
+ */
73
+ static fileExist(pathStr) {
74
+ throw new NotSupportedError_1.NotSupportedError('not supported');
75
+ }
76
+ static fileExistAsync(pathStr) {
77
+ throw new NotSupportedError_1.NotSupportedError('not supported');
78
+ }
79
+ /**
80
+ * Returns the basename of a file
81
+ */
82
+ static basename(pathStr) {
83
+ throw new NotSupportedError_1.NotSupportedError('not supported');
84
+ }
85
+ static withoutInterpolation(str, fn) {
86
+ if (/\$\{.*\}/.test(str)) {
87
+ // has interpolations
88
+ const regex = new RegExp(/\$\{.*\}/g);
89
+ const m = regex.exec(str);
90
+ const cache = {};
91
+ let inc = 0;
92
+ for (const _m of m) {
93
+ const r = '###' + (inc++) + '###';
94
+ str = str.replace(_m, r);
95
+ cache[r] = _m;
96
+ }
97
+ str = fn(str);
98
+ for (const _m in cache) {
99
+ if (cache.hasOwnProperty(_m)) {
100
+ str = str.replace(_m, cache[_m]);
101
+ }
102
+ }
103
+ }
104
+ return str;
105
+ }
106
+ /**
107
+ * Returns the filename only (without extension)
108
+ */
109
+ static filename(pathStr) {
110
+ throw new NotSupportedError_1.NotSupportedError('not supported');
111
+ }
112
+ /**
113
+ * Returns the dirname of the file
114
+ */
115
+ static dirname(pathStr) {
116
+ throw new NotSupportedError_1.NotSupportedError('not supported');
117
+ }
118
+ static testForFilePath(path) {
119
+ throw new NotSupportedError_1.NotSupportedError('not supported');
120
+ }
121
+ /**
122
+ * Normalizes given path. Does "path.normalize".
123
+ */
124
+ static pathNormalize(pathStr) {
125
+ throw new NotSupportedError_1.NotSupportedError('not supported');
126
+ }
127
+ /**
128
+ * Normalizes given path. Does "path.normalize".
129
+ */
130
+ static pathResolveAndNormalize(pathStr) {
131
+ return this.pathNormalize(this.pathResolve(pathStr));
132
+ }
133
+ /**
134
+ * Test if path is absolute.
135
+ */
136
+ static isAbsolute(pathStr) {
137
+ throw new NotSupportedError_1.NotSupportedError('not supported');
138
+ }
139
+ static directory(file) {
140
+ throw new NotSupportedError_1.NotSupportedError('not supported');
141
+ }
142
+ /**
143
+ * Gets environment variable.
144
+ */
145
+ static getEnvVariable(name) {
146
+ return process.env[name];
147
+ }
148
+ static getHostPath() {
149
+ throw new NotSupportedError_1.NotSupportedError('not supported');
150
+ }
151
+ static getHostFileContent() {
152
+ throw new NotSupportedError_1.NotSupportedError('not supported');
153
+ }
154
+ static mkdir(targetDir, sep = null) {
155
+ throw new NotSupportedError_1.NotSupportedError('not supported');
156
+ }
157
+ static readFile(filename) {
158
+ throw new NotSupportedError_1.NotSupportedError('not supported');
159
+ }
160
+ static readFileSync(filename) {
161
+ throw new NotSupportedError_1.NotSupportedError('not supported');
162
+ }
163
+ static deleteFile(dir, file) {
164
+ throw new NotSupportedError_1.NotSupportedError('not supported');
165
+ }
166
+ static deleteDirectory(dir) {
167
+ throw new NotSupportedError_1.NotSupportedError('not supported');
168
+ }
169
+ }
170
+ exports.PlatformUtils = PlatformUtils;
171
+ /**
172
+ * Type of the currently running platform.
173
+ */
174
+ PlatformUtils.type = 'node';
175
+ PlatformUtils.workdir = null;
176
+
177
+ //# sourceMappingURL=PlatformUtilsBrowser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/PlatformUtilsBrowser.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,mCAAgC;AAChC,uEAAkE;AAGlE,yIAAyI;AAEzI;;GAEG;AACH,MAAa,aAAa;IASxB;;OAEG;IACH,MAAM,CAAC,iBAAiB;QACtB,OAAO,MAAM,CAAC;IAChB,CAAC;IAGD;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,OAAe;QAC/B,IAAI,iBAAQ,CAAC,OAAO,CAAC,EAAE;YACrB,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;SACnD;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACrB;IACH,CAAC;IAGD,MAAM,CAAC,IAAI,CAAC,GAAG,IAAc;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,IAAY;QACtB,MAAM,IAAI,qCAAiB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,IAAY;QAC3B,MAAM,IAAI,qCAAiB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAGD;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,OAAe;QAClC,MAAM,IAAI,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AiB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,IAAY;QAC3B,MAAM,IAAI,qCAAiB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAGD;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,IAAY;QAChC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAGD,MAAM,CAAC,WAAW;QAChB,MAAM,IAAI,qCAAiB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,kBAAkB;QACvB,MAAM,IAAI,qCAAiB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,SAAiB,EAAE,MAAc,IAAI;QAChD,MAAM,IAAI,qCAAiB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAGD,MAAM,CAAC,QAAQ,CAAC,QAAgB;QAC9B,MAAM,IAAI,qCAAiB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,QAAgB;QAClC,MAAM,IAAI,qCAAiB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,GAAW,EAAE,IAAY;QACzC,MAAM,IAAI,qCAAiB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,GAAW;QAChC,MAAM,IAAI,qCAAiB,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;;AAxMH,sCA2MC;AAzMC;;GAEG;AACI,kBAAI,GAAuB,MAAM,CAAC;AAElC,qBAAO,GAAW,IAAI,CAAC","file":"PlatformUtilsBrowser.js","sourcesContent":["/**\n * see https://github.com/typeorm/typeorm/blob/master/src/platform/PlatformTools.ts\n */\n\nimport {isString} from 'lodash';\nimport {NotSupportedError} from '../exceptions/NotSupportedError';\n\n\n// const FILEPATH = path.sep === '/' ? /^(\\.|\\.\\/|\\/)([\\w\\/\\.\\-_ ]*)$/ : /^(?:[a-zA-Z]\\:|\\\\\\\\[\\w\\.]+\\\\[\\w.$]+)\\\\(?:[\\w]+\\\\)*\\w([\\w.])+$/;\n\n/**\n * Platform-specific tools.\n */\nexport class PlatformUtils {\n\n /**\n * Type of the currently running platform.\n */\n static type: 'browser' | 'node' = 'node';\n\n static workdir: string = null;\n\n /**\n * Gets global variable where global stuff can be stored.\n */\n static getGlobalVariable(): any {\n return global;\n }\n\n\n /**\n * set workdir\n */\n static setWorkDir(workdir: string) {\n if (isString(workdir)) {\n this.workdir = PlatformUtils.pathResolve(workdir);\n } else {\n this.workdir = null;\n }\n }\n\n\n static join(...args: string[]) {\n return args.join('/');\n }\n\n static load(name: string): any {\n throw new NotSupportedError('not supported');\n }\n\n static loadAsync(name: string): Promise<any> {\n throw new NotSupportedError('not supported');\n }\n\n\n /**\n * Normalizes given path. Does \"path.normalize\".\n */\n static pathNormilize(pathStr: string): string {\n throw new NotSupportedError('not supported');\n }\n\n /**\n * Gets file extension. Does \"path.extname\".\n */\n static pathExtname(pathStr: string, dotted: boolean = true): string {\n throw new NotSupportedError('not supported');\n }\n\n /**\n * Resolved given path. Does \"path.resolve\".\n */\n static pathResolve(pathStr: string): string {\n throw new NotSupportedError('not supported');\n }\n\n /**\n * Resolved given path. Does \"path.resolve\".\n */\n static pathNormAndResolve(pathStr: string): string {\n return this.pathNormilize(this.pathResolve(pathStr));\n }\n\n static isFile(pathStr: string): boolean {\n throw new NotSupportedError('not supported');\n }\n\n static isDir(pathStr: string): boolean {\n throw new NotSupportedError('not supported');\n }\n\n /**\n * Synchronously checks if file exist. Does \"fs.existsSync\".\n */\n static fileExist(pathStr: string): boolean {\n throw new NotSupportedError('not supported');\n }\n\n static fileExistAsync(pathStr: string): Promise<boolean> {\n throw new NotSupportedError('not supported');\n }\n\n /**\n * Returns the basename of a file\n */\n static basename(pathStr: string): string {\n throw new NotSupportedError('not supported');\n }\n\n static withoutInterpolation(str: string, fn: (str: string) => string) {\n if (/\\$\\{.*\\}/.test(str)) {\n // has interpolations\n const regex = new RegExp(/\\$\\{.*\\}/g);\n const m = regex.exec(str);\n const cache = {};\n let inc = 0;\n for (const _m of m) {\n const r = '###' + (inc++) + '###';\n str = str.replace(_m, r);\n cache[r] = _m;\n }\n str = fn(str);\n for (const _m in cache) {\n if (cache.hasOwnProperty(_m)) {\n str = str.replace(_m, cache[_m]);\n }\n }\n }\n return str;\n }\n\n /**\n * Returns the filename only (without extension)\n */\n static filename(pathStr: string): string {\n throw new NotSupportedError('not supported');\n }\n\n\n /**\n * Returns the dirname of the file\n */\n static dirname(pathStr: string): string {\n throw new NotSupportedError('not supported');\n }\n\n\n static testForFilePath(path: string) {\n throw new NotSupportedError('not supported');\n }\n\n /**\n * Normalizes given path. Does \"path.normalize\".\n */\n static pathNormalize(pathStr: string): string {\n throw new NotSupportedError('not supported');\n }\n\n /**\n * Normalizes given path. Does \"path.normalize\".\n */\n static pathResolveAndNormalize(pathStr: string): string {\n return this.pathNormalize(this.pathResolve(pathStr));\n }\n\n\n /**\n * Test if path is absolute.\n */\n static isAbsolute(pathStr: string): boolean {\n throw new NotSupportedError('not supported');\n }\n\n static directory(file: string): string {\n throw new NotSupportedError('not supported');\n }\n\n\n /**\n * Gets environment variable.\n */\n static getEnvVariable(name: string): any {\n return process.env[name];\n }\n\n\n static getHostPath(): string {\n throw new NotSupportedError('not supported');\n }\n\n static getHostFileContent(): string {\n throw new NotSupportedError('not supported');\n }\n\n static mkdir(targetDir: string, sep: string = null): boolean {\n throw new NotSupportedError('not supported');\n }\n\n\n static readFile(filename: string): Promise<Buffer> {\n throw new NotSupportedError('not supported');\n }\n\n static readFileSync(filename: string): Buffer {\n throw new NotSupportedError('not supported');\n }\n\n static deleteFile(dir: string, file: string): Promise<{}> {\n throw new NotSupportedError('not supported');\n }\n\n static deleteDirectory(dir: string): Promise<{}> {\n throw new NotSupportedError('not supported');\n }\n\n\n}\n"],"sourceRoot":".."}
@@ -0,0 +1,9 @@
1
+ export declare class Serializer {
2
+ static TYPES: {};
3
+ static serialize(data: any): string;
4
+ static deserialize(data: any): any;
5
+ static serializeObject(x: any): void;
6
+ static deserializeObject(x: any): any;
7
+ static serializeClass(x: any): void;
8
+ static deserializeClass(x: any): any;
9
+ }