@accordproject/concerto-util 4.0.0-alpha.2 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/baseexception.d.ts +7 -7
- package/dist/baseexception.js +40 -6
- package/dist/basefileexception.d.ts +16 -16
- package/dist/basefileexception.js +10 -11
- package/dist/concerto-util.js +1 -1
- package/dist/concerto-util.js.LICENSE.txt +1 -1
- package/dist/errorcodes.d.ts +7 -4
- package/dist/errorcodes.js +11 -6
- package/dist/filedownloader.d.ts +24 -17
- package/dist/filedownloader.js +19 -20
- package/dist/filewriter.d.ts +28 -25
- package/dist/filewriter.js +57 -31
- package/dist/identifiers.d.ts +5 -5
- package/dist/identifiers.js +10 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +0 -1
- package/dist/inmemorywriter.d.ts +11 -6
- package/dist/inmemorywriter.js +3 -4
- package/dist/label.d.ts +6 -6
- package/dist/label.js +7 -9
- package/dist/loaders/compositefileloader.d.ts +18 -13
- package/dist/loaders/compositefileloader.js +7 -8
- package/dist/loaders/defaultfileloader.d.ts +5 -5
- package/dist/loaders/defaultfileloader.js +4 -5
- package/dist/loaders/fileloader.d.ts +4 -0
- package/dist/loaders/fileloader.js +15 -0
- package/dist/loaders/githubfileloader.d.ts +22 -3
- package/dist/loaders/githubfileloader.js +7 -8
- package/dist/loaders/httpfileloader.d.ts +12 -11
- package/dist/loaders/httpfileloader.js +8 -7
- package/dist/logger.d.ts +35 -55
- package/dist/logger.js +24 -64
- package/dist/modelwriter.d.ts +12 -4
- package/dist/modelwriter.js +38 -10
- package/dist/null.d.ts +4 -4
- package/dist/null.js +2 -3
- package/dist/typedstack.d.ts +15 -14
- package/dist/typedstack.js +10 -12
- package/dist/warning.d.ts +5 -5
- package/dist/warning.js +7 -9
- package/dist/writer.d.ts +14 -10
- package/dist/writer.js +9 -10
- package/package.json +2 -2
- package/types/lib/logger.d.ts +2 -2
- package/types/lib/null.d.ts +15 -0
- package/dist/baseexception.js.map +0 -1
- package/dist/basefileexception.js.map +0 -1
- package/dist/errorcodes.js.map +0 -1
- package/dist/filedownloader.js.map +0 -1
- package/dist/filewriter.js.map +0 -1
- package/dist/identifiers.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inmemorywriter.js.map +0 -1
- package/dist/label.js.map +0 -1
- package/dist/loaders/compositefileloader.js.map +0 -1
- package/dist/loaders/defaultfileloader.js.map +0 -1
- package/dist/loaders/githubfileloader.js.map +0 -1
- package/dist/loaders/httpfileloader.js.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/modelwriter.js.map +0 -1
- package/dist/null.js.map +0 -1
- package/dist/typedstack.js.map +0 -1
- package/dist/warning.js.map +0 -1
- package/dist/writer.js.map +0 -1
|
@@ -30,14 +30,14 @@ class CompositeFileLoader {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Adds a FileLoader implemenetation to the FileLoader
|
|
33
|
-
* @param
|
|
33
|
+
* @param fileLoader - The script to add to the ScriptManager
|
|
34
34
|
*/
|
|
35
35
|
addFileLoader(fileLoader) {
|
|
36
36
|
this.fileLoaders.push(fileLoader);
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Get the array of FileLoader instances
|
|
40
|
-
* @return
|
|
40
|
+
* @return The FileLoader registered
|
|
41
41
|
* @private
|
|
42
42
|
*/
|
|
43
43
|
getFileLoaders() {
|
|
@@ -51,8 +51,8 @@ class CompositeFileLoader {
|
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Returns true if this ModelLoader can process the URL
|
|
54
|
-
* @param
|
|
55
|
-
* @return
|
|
54
|
+
* @param url - the URL
|
|
55
|
+
* @return true if this ModelLoader accepts the URL
|
|
56
56
|
* @abstract
|
|
57
57
|
*/
|
|
58
58
|
accepts(url) {
|
|
@@ -66,9 +66,9 @@ class CompositeFileLoader {
|
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Load a File from a URL and return it
|
|
69
|
-
* @param
|
|
70
|
-
* @param
|
|
71
|
-
* @return
|
|
69
|
+
* @param url - the url to get
|
|
70
|
+
* @param options - additional options
|
|
71
|
+
* @return a promise to the File
|
|
72
72
|
*/
|
|
73
73
|
load(url, options) {
|
|
74
74
|
for (let n = 0; n < this.fileLoaders.length; n++) {
|
|
@@ -81,4 +81,3 @@ class CompositeFileLoader {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
module.exports = CompositeFileLoader;
|
|
84
|
-
//# sourceMappingURL=compositefileloader.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import CompositeFileLoader = require('./compositefileloader');
|
|
2
2
|
/**
|
|
3
3
|
* <p>
|
|
4
4
|
* A default CompositeFileLoader implementation which supports
|
|
@@ -9,11 +9,11 @@ export = DefaultFileLoader;
|
|
|
9
9
|
* @see See {@link CompositeFileLoader}
|
|
10
10
|
* @memberof module:concerto-util
|
|
11
11
|
*/
|
|
12
|
-
declare class DefaultFileLoader extends CompositeFileLoader {
|
|
12
|
+
declare class DefaultFileLoader<T> extends CompositeFileLoader<T> {
|
|
13
13
|
/**
|
|
14
14
|
* Create the DefaultFileLoader.
|
|
15
|
-
* @param
|
|
15
|
+
* @param processFile - a function to apply to the content of the file
|
|
16
16
|
*/
|
|
17
|
-
constructor(processFile:
|
|
17
|
+
constructor(processFile: (name: string, text: string) => T);
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
export = DefaultFileLoader;
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
'use strict';
|
|
15
|
-
const CompositeFileLoader = require(
|
|
16
|
-
const HTTPFileLoader = require(
|
|
17
|
-
const GitHubFileLoader = require(
|
|
15
|
+
const CompositeFileLoader = require("./compositefileloader");
|
|
16
|
+
const HTTPFileLoader = require("./httpfileloader");
|
|
17
|
+
const GitHubFileLoader = require("./githubfileloader");
|
|
18
18
|
/**
|
|
19
19
|
* <p>
|
|
20
20
|
* A default CompositeFileLoader implementation which supports
|
|
@@ -28,7 +28,7 @@ const GitHubFileLoader = require('./githubfileloader');
|
|
|
28
28
|
class DefaultFileLoader extends CompositeFileLoader {
|
|
29
29
|
/**
|
|
30
30
|
* Create the DefaultFileLoader.
|
|
31
|
-
* @param
|
|
31
|
+
* @param processFile - a function to apply to the content of the file
|
|
32
32
|
*/
|
|
33
33
|
constructor(processFile) {
|
|
34
34
|
super();
|
|
@@ -39,4 +39,3 @@ class DefaultFileLoader extends CompositeFileLoader {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
module.exports = DefaultFileLoader;
|
|
42
|
-
//# sourceMappingURL=defaultfileloader.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
* you may not use this file except in compliance with the License.
|
|
4
|
+
* You may obtain a copy of the License at
|
|
5
|
+
*
|
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
*
|
|
8
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
* See the License for the specific language governing permissions and
|
|
12
|
+
* limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
'use strict';
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import HTTPFileLoader = require('./httpfileloader');
|
|
2
2
|
/**
|
|
3
3
|
* Loads Files from an external source, such as a URL.
|
|
4
4
|
*
|
|
@@ -6,6 +6,25 @@ export = GitHubFileLoader;
|
|
|
6
6
|
* @private
|
|
7
7
|
* @memberof module:concerto-util
|
|
8
8
|
*/
|
|
9
|
-
declare class GitHubFileLoader extends HTTPFileLoader {
|
|
9
|
+
declare class GitHubFileLoader<T> extends HTTPFileLoader<T> {
|
|
10
|
+
/**
|
|
11
|
+
* Create the GitHubFileLoader.
|
|
12
|
+
* @param processFile - a function to apply to the content of the file
|
|
13
|
+
*/
|
|
14
|
+
constructor(processFile: (name: string, text: string) => T);
|
|
15
|
+
/**
|
|
16
|
+
* Returns true if this ModelLoader can process the URL
|
|
17
|
+
* @param url - the URL
|
|
18
|
+
* @return true if this ModelLoader accepts the URL
|
|
19
|
+
* @abstract
|
|
20
|
+
*/
|
|
21
|
+
accepts(url: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Load a File from a URL and return it
|
|
24
|
+
* @param url - the url to get
|
|
25
|
+
* @param options - additional options
|
|
26
|
+
* @return a promise to the File
|
|
27
|
+
*/
|
|
28
|
+
load(url: string, options?: RequestInit): Promise<T>;
|
|
10
29
|
}
|
|
11
|
-
|
|
30
|
+
export = GitHubFileLoader;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
'use strict';
|
|
15
|
-
const HTTPFileLoader = require(
|
|
15
|
+
const HTTPFileLoader = require("./httpfileloader");
|
|
16
16
|
/**
|
|
17
17
|
* Loads Files from an external source, such as a URL.
|
|
18
18
|
*
|
|
@@ -23,15 +23,15 @@ const HTTPFileLoader = require('./httpfileloader');
|
|
|
23
23
|
class GitHubFileLoader extends HTTPFileLoader {
|
|
24
24
|
/**
|
|
25
25
|
* Create the GitHubFileLoader.
|
|
26
|
-
* @param
|
|
26
|
+
* @param processFile - a function to apply to the content of the file
|
|
27
27
|
*/
|
|
28
28
|
constructor(processFile) {
|
|
29
29
|
super(processFile);
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Returns true if this ModelLoader can process the URL
|
|
33
|
-
* @param
|
|
34
|
-
* @return
|
|
33
|
+
* @param url - the URL
|
|
34
|
+
* @return true if this ModelLoader accepts the URL
|
|
35
35
|
* @abstract
|
|
36
36
|
*/
|
|
37
37
|
accepts(url) {
|
|
@@ -39,9 +39,9 @@ class GitHubFileLoader extends HTTPFileLoader {
|
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Load a File from a URL and return it
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @return
|
|
42
|
+
* @param url - the url to get
|
|
43
|
+
* @param options - additional options
|
|
44
|
+
* @return a promise to the File
|
|
45
45
|
*/
|
|
46
46
|
load(url, options) {
|
|
47
47
|
const rewrittenUrl = 'https://raw.githubusercontent.com/' + url.substring(9);
|
|
@@ -50,4 +50,3 @@ class GitHubFileLoader extends HTTPFileLoader {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
module.exports = GitHubFileLoader;
|
|
53
|
-
//# sourceMappingURL=githubfileloader.js.map
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import type { FileLoader } from './fileloader';
|
|
2
2
|
/**
|
|
3
3
|
* Loads Files from an HTTP(S) URL using fetch.
|
|
4
4
|
* @class
|
|
5
5
|
* @private
|
|
6
6
|
* @memberof module:concerto-util
|
|
7
7
|
*/
|
|
8
|
-
declare class HTTPFileLoader {
|
|
8
|
+
declare class HTTPFileLoader<T> implements FileLoader<T> {
|
|
9
|
+
processFile: (name: string, text: string) => T;
|
|
9
10
|
/**
|
|
10
11
|
* Create the HTTPFileLoader.
|
|
11
|
-
* @param
|
|
12
|
+
* @param processFile - a function to apply to the content of the file
|
|
12
13
|
*/
|
|
13
|
-
constructor(processFile:
|
|
14
|
-
processFile: any;
|
|
14
|
+
constructor(processFile: (name: string, text: string) => T);
|
|
15
15
|
/**
|
|
16
16
|
* Returns true if this ModelLoader can process the URL
|
|
17
|
-
* @param
|
|
18
|
-
* @return
|
|
17
|
+
* @param url - the URL
|
|
18
|
+
* @return true if this ModelLoader accepts the URL
|
|
19
19
|
* @abstract
|
|
20
20
|
*/
|
|
21
21
|
accepts(url: string): boolean;
|
|
22
22
|
/**
|
|
23
23
|
* Load a text File from a URL and return it
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @return
|
|
24
|
+
* @param requestUrl - the url to get
|
|
25
|
+
* @param options - additional options
|
|
26
|
+
* @return a promise to the File
|
|
27
27
|
*/
|
|
28
|
-
load(requestUrl: string, options
|
|
28
|
+
load(requestUrl: string, options?: RequestInit): Promise<T>;
|
|
29
29
|
}
|
|
30
|
+
export = HTTPFileLoader;
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* limitations under the License.
|
|
13
13
|
*/
|
|
14
14
|
'use strict';
|
|
15
|
+
const debug = require('debug')('concerto:HTTPFileLoader');
|
|
15
16
|
/**
|
|
16
17
|
* Loads Files from an HTTP(S) URL using fetch.
|
|
17
18
|
* @class
|
|
@@ -21,15 +22,15 @@
|
|
|
21
22
|
class HTTPFileLoader {
|
|
22
23
|
/**
|
|
23
24
|
* Create the HTTPFileLoader.
|
|
24
|
-
* @param
|
|
25
|
+
* @param processFile - a function to apply to the content of the file
|
|
25
26
|
*/
|
|
26
27
|
constructor(processFile) {
|
|
27
28
|
this.processFile = processFile;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Returns true if this ModelLoader can process the URL
|
|
31
|
-
* @param
|
|
32
|
-
* @return
|
|
32
|
+
* @param url - the URL
|
|
33
|
+
* @return true if this ModelLoader accepts the URL
|
|
33
34
|
* @abstract
|
|
34
35
|
*/
|
|
35
36
|
accepts(url) {
|
|
@@ -37,9 +38,9 @@ class HTTPFileLoader {
|
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
39
40
|
* Load a text File from a URL and return it
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @return
|
|
41
|
+
* @param requestUrl - the url to get
|
|
42
|
+
* @param options - additional options
|
|
43
|
+
* @return a promise to the File
|
|
43
44
|
*/
|
|
44
45
|
async load(requestUrl, options) {
|
|
45
46
|
if (!options) {
|
|
@@ -50,6 +51,7 @@ class HTTPFileLoader {
|
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
53
|
}
|
|
54
|
+
debug('loading', requestUrl);
|
|
53
55
|
const response = await fetch(requestUrl, options);
|
|
54
56
|
if (!response.ok) {
|
|
55
57
|
throw new Error(`HTTP request failed with status: ${response.status}`);
|
|
@@ -63,4 +65,3 @@ class HTTPFileLoader {
|
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
module.exports = HTTPFileLoader;
|
|
66
|
-
//# sourceMappingURL=httpfileloader.js.map
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,106 +1,86 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Default levels for the npm configuration.
|
|
3
|
+
*/
|
|
4
|
+
declare const levels: Record<string, number>;
|
|
5
|
+
/**
|
|
6
|
+
* The default transport for logging at multiple levels to the console
|
|
7
|
+
* @param level - the required log level. e.g. error, warn, info, debug, etc.
|
|
8
|
+
* @param args - the input obj to prettify
|
|
9
|
+
*/
|
|
10
|
+
type LogLevel = keyof typeof levels;
|
|
11
|
+
type Transport = Partial<Record<LogLevel, (...args: unknown[]) => void>>;
|
|
2
12
|
/**
|
|
3
13
|
* A utility class with static function that print to the console
|
|
4
|
-
* @private
|
|
5
14
|
*/
|
|
6
15
|
declare class Logger {
|
|
16
|
+
static level: string;
|
|
17
|
+
static transports: Transport[];
|
|
7
18
|
/**
|
|
8
19
|
* A reusable function for logging at multiple levels
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @returns {void} -
|
|
12
|
-
* @private
|
|
20
|
+
* @param level - the required log level. e.g. error, warn, info, debug, etc.
|
|
21
|
+
* @param args - the input obj to prettify
|
|
13
22
|
*/
|
|
14
|
-
|
|
23
|
+
static dispatch(level: LogLevel, ...args: unknown[]): void;
|
|
15
24
|
/**
|
|
16
25
|
* Add a custom transport for logging
|
|
17
|
-
* @param
|
|
18
|
-
* @returns {void} -
|
|
19
|
-
* @private
|
|
26
|
+
* @param transport - The transport object should have function for the usual logging operations e.g. error, warn, info, debug, etc.
|
|
20
27
|
*/
|
|
21
|
-
|
|
28
|
+
static add(transport: Transport): void;
|
|
22
29
|
/**
|
|
23
30
|
* Write an error statement to the console.
|
|
24
31
|
*
|
|
25
32
|
* Prints to `stderr` with newline.
|
|
26
|
-
* @param
|
|
27
|
-
* @param {any} args -
|
|
28
|
-
* @returns {void} -
|
|
29
|
-
* @private
|
|
33
|
+
* @param args - args
|
|
30
34
|
*/
|
|
31
|
-
|
|
35
|
+
static error(...args: unknown[]): void;
|
|
32
36
|
/**
|
|
33
37
|
* Write a warning statement to the console.
|
|
34
38
|
*
|
|
35
39
|
* Prints to `stderr` with newline.
|
|
36
|
-
* @param
|
|
37
|
-
* @param {any} args -
|
|
38
|
-
* @returns {void} -
|
|
39
|
-
* @private
|
|
40
|
+
* @param args - args
|
|
40
41
|
*/
|
|
41
|
-
|
|
42
|
+
static warn(...args: unknown[]): void;
|
|
42
43
|
/**
|
|
43
44
|
* Write an info statement to the console.
|
|
44
45
|
*
|
|
45
46
|
* Prints to `stdout` with newline.
|
|
46
|
-
* @param
|
|
47
|
-
* @param {any} args -
|
|
48
|
-
* @returns {void} -
|
|
49
|
-
* @private
|
|
47
|
+
* @param args - args
|
|
50
48
|
*/
|
|
51
|
-
|
|
49
|
+
static info(...args: unknown[]): void;
|
|
52
50
|
/**
|
|
53
51
|
* Write an info statement to the console. Alias for `logger.log`
|
|
54
52
|
*
|
|
55
53
|
* Prints to `stdout` with newline.
|
|
56
|
-
* @param
|
|
57
|
-
* @param {any} args -
|
|
58
|
-
* @returns {void} -
|
|
59
|
-
* @private
|
|
54
|
+
* @param args - args
|
|
60
55
|
*/
|
|
61
|
-
|
|
56
|
+
static log(...args: unknown[]): void;
|
|
62
57
|
/**
|
|
63
58
|
* Write an http statement to the console.
|
|
64
59
|
*
|
|
65
60
|
* Prints to `stdout` with newline.
|
|
66
|
-
* @param
|
|
67
|
-
* @param {any} args -
|
|
68
|
-
* @returns {void} -
|
|
69
|
-
* @private
|
|
61
|
+
* @param args - args
|
|
70
62
|
*/
|
|
71
|
-
|
|
63
|
+
static http(...args: unknown[]): void;
|
|
72
64
|
/**
|
|
73
65
|
* Write a verbose log statement to the console.
|
|
74
66
|
*
|
|
75
67
|
* Prints to `stdout` with newline.
|
|
76
|
-
* @param
|
|
77
|
-
* @param {any} args -
|
|
78
|
-
* @returns {void} -
|
|
79
|
-
* @private
|
|
68
|
+
* @param args - args
|
|
80
69
|
*/
|
|
81
|
-
|
|
70
|
+
static verbose(...args: unknown[]): void;
|
|
82
71
|
/**
|
|
83
72
|
* Write a debug statement to the console.
|
|
84
73
|
*
|
|
85
74
|
* Prints to `stdout` with newline.
|
|
86
|
-
* @param
|
|
87
|
-
* @param {any} args -
|
|
88
|
-
* @returns {void} -
|
|
89
|
-
* @private
|
|
75
|
+
* @param args - args
|
|
90
76
|
*/
|
|
91
|
-
|
|
77
|
+
static debug(...args: unknown[]): void;
|
|
92
78
|
/**
|
|
93
79
|
* Write a silly level statement to the console.
|
|
94
80
|
*
|
|
95
81
|
* Prints to `stdout` with newline.
|
|
96
|
-
* @param
|
|
97
|
-
* @param {any} args -
|
|
98
|
-
* @returns {void} -
|
|
99
|
-
* @private
|
|
82
|
+
* @param args - args
|
|
100
83
|
*/
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
declare namespace Logger {
|
|
104
|
-
let level: string;
|
|
105
|
-
let transports: {}[];
|
|
84
|
+
static silly(...args: unknown[]): void;
|
|
106
85
|
}
|
|
86
|
+
export = Logger;
|
package/dist/logger.js
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
/* eslint-disable no-use-before-define */
|
|
17
17
|
/**
|
|
18
18
|
* Default levels for the npm configuration.
|
|
19
|
-
* @type {Object}
|
|
20
19
|
*/
|
|
21
20
|
const levels = {
|
|
22
21
|
error: 0,
|
|
@@ -30,23 +29,15 @@ const levels = {
|
|
|
30
29
|
const timestamp = () => (new Date()).toLocaleTimeString();
|
|
31
30
|
/**
|
|
32
31
|
* Helper function to format JSON objects
|
|
33
|
-
* @param
|
|
34
|
-
* @returns
|
|
35
|
-
* @private
|
|
32
|
+
* @param obj - the input obj to prettify
|
|
33
|
+
* @returns - the prettified object
|
|
36
34
|
*/
|
|
37
35
|
const prettifyJson = (obj) => {
|
|
38
36
|
return obj;
|
|
39
37
|
};
|
|
40
|
-
/**
|
|
41
|
-
* The default transport for logging at multiple levels to the console
|
|
42
|
-
* @param {string} level - the required log level. e.g. error, warn, info, debug, etc.
|
|
43
|
-
* @param {any} obj - the input obj to prettify
|
|
44
|
-
* @returns {void} -
|
|
45
|
-
* @private
|
|
46
|
-
*/
|
|
47
38
|
const defaultTransportShim = (level, ...args) => {
|
|
48
39
|
let mutatedLevel = level;
|
|
49
|
-
|
|
40
|
+
const data = args;
|
|
50
41
|
let first = data.shift();
|
|
51
42
|
// Flatten log object
|
|
52
43
|
if (first && typeof first === 'object' && first.level && first.message) {
|
|
@@ -69,19 +60,17 @@ const defaultTransportShim = (level, ...args) => {
|
|
|
69
60
|
};
|
|
70
61
|
const defaultTransport = {};
|
|
71
62
|
Object.keys(levels).forEach(level => {
|
|
72
|
-
|
|
63
|
+
const typedLevel = level;
|
|
64
|
+
defaultTransport[typedLevel] = (...args) => defaultTransportShim(typedLevel, ...args);
|
|
73
65
|
});
|
|
74
66
|
/**
|
|
75
67
|
* A utility class with static function that print to the console
|
|
76
|
-
* @private
|
|
77
68
|
*/
|
|
78
69
|
class Logger {
|
|
79
70
|
/**
|
|
80
71
|
* A reusable function for logging at multiple levels
|
|
81
|
-
* @param
|
|
82
|
-
* @param
|
|
83
|
-
* @returns {void} -
|
|
84
|
-
* @private
|
|
72
|
+
* @param level - the required log level. e.g. error, warn, info, debug, etc.
|
|
73
|
+
* @param args - the input obj to prettify
|
|
85
74
|
*/
|
|
86
75
|
static dispatch(level, ...args) {
|
|
87
76
|
if (levels[level] > levels[this.level]) {
|
|
@@ -95,9 +84,7 @@ class Logger {
|
|
|
95
84
|
}
|
|
96
85
|
/**
|
|
97
86
|
* Add a custom transport for logging
|
|
98
|
-
* @param
|
|
99
|
-
* @returns {void} -
|
|
100
|
-
* @private
|
|
87
|
+
* @param transport - The transport object should have function for the usual logging operations e.g. error, warn, info, debug, etc.
|
|
101
88
|
*/
|
|
102
89
|
static add(transport) {
|
|
103
90
|
this.transports.push(transport);
|
|
@@ -106,86 +93,59 @@ class Logger {
|
|
|
106
93
|
* Write an error statement to the console.
|
|
107
94
|
*
|
|
108
95
|
* Prints to `stderr` with newline.
|
|
109
|
-
* @param
|
|
110
|
-
* @param {any} args -
|
|
111
|
-
* @returns {void} -
|
|
112
|
-
* @private
|
|
96
|
+
* @param args - args
|
|
113
97
|
*/
|
|
114
|
-
static error(...args) {
|
|
98
|
+
static error(...args) { this.dispatch('error', ...args); }
|
|
115
99
|
/**
|
|
116
100
|
* Write a warning statement to the console.
|
|
117
101
|
*
|
|
118
102
|
* Prints to `stderr` with newline.
|
|
119
|
-
* @param
|
|
120
|
-
* @param {any} args -
|
|
121
|
-
* @returns {void} -
|
|
122
|
-
* @private
|
|
103
|
+
* @param args - args
|
|
123
104
|
*/
|
|
124
|
-
static warn(...args) {
|
|
105
|
+
static warn(...args) { this.dispatch('warn', ...args); }
|
|
125
106
|
/**
|
|
126
107
|
* Write an info statement to the console.
|
|
127
108
|
*
|
|
128
109
|
* Prints to `stdout` with newline.
|
|
129
|
-
* @param
|
|
130
|
-
* @param {any} args -
|
|
131
|
-
* @returns {void} -
|
|
132
|
-
* @private
|
|
110
|
+
* @param args - args
|
|
133
111
|
*/
|
|
134
|
-
static info(...args) {
|
|
112
|
+
static info(...args) { this.dispatch('info', ...args); }
|
|
135
113
|
/**
|
|
136
114
|
* Write an info statement to the console. Alias for `logger.log`
|
|
137
115
|
*
|
|
138
116
|
* Prints to `stdout` with newline.
|
|
139
|
-
* @param
|
|
140
|
-
* @param {any} args -
|
|
141
|
-
* @returns {void} -
|
|
142
|
-
* @private
|
|
117
|
+
* @param args - args
|
|
143
118
|
*/
|
|
144
|
-
static log(...args) {
|
|
119
|
+
static log(...args) { this.info(...args); }
|
|
145
120
|
/**
|
|
146
121
|
* Write an http statement to the console.
|
|
147
122
|
*
|
|
148
123
|
* Prints to `stdout` with newline.
|
|
149
|
-
* @param
|
|
150
|
-
* @param {any} args -
|
|
151
|
-
* @returns {void} -
|
|
152
|
-
* @private
|
|
124
|
+
* @param args - args
|
|
153
125
|
*/
|
|
154
|
-
static http(...args) {
|
|
126
|
+
static http(...args) { this.dispatch('http', ...args); }
|
|
155
127
|
/**
|
|
156
128
|
* Write a verbose log statement to the console.
|
|
157
129
|
*
|
|
158
130
|
* Prints to `stdout` with newline.
|
|
159
|
-
* @param
|
|
160
|
-
* @param {any} args -
|
|
161
|
-
* @returns {void} -
|
|
162
|
-
* @private
|
|
131
|
+
* @param args - args
|
|
163
132
|
*/
|
|
164
|
-
static verbose(...args) {
|
|
133
|
+
static verbose(...args) { this.dispatch('verbose', ...args); }
|
|
165
134
|
/**
|
|
166
135
|
* Write a debug statement to the console.
|
|
167
136
|
*
|
|
168
137
|
* Prints to `stdout` with newline.
|
|
169
|
-
* @param
|
|
170
|
-
* @param {any} args -
|
|
171
|
-
* @returns {void} -
|
|
172
|
-
* @private
|
|
138
|
+
* @param args - args
|
|
173
139
|
*/
|
|
174
|
-
static debug(...args) {
|
|
140
|
+
static debug(...args) { this.dispatch('debug', ...args); }
|
|
175
141
|
/**
|
|
176
142
|
* Write a silly level statement to the console.
|
|
177
143
|
*
|
|
178
144
|
* Prints to `stdout` with newline.
|
|
179
|
-
* @param
|
|
180
|
-
* @param {any} args -
|
|
181
|
-
* @returns {void} -
|
|
182
|
-
* @private
|
|
145
|
+
* @param args - args
|
|
183
146
|
*/
|
|
184
|
-
static silly(...args) {
|
|
147
|
+
static silly(...args) { this.dispatch('silly', ...args); }
|
|
185
148
|
}
|
|
186
|
-
// Set the default logging level
|
|
187
149
|
Logger.level = 'info';
|
|
188
|
-
// A list of user-provided logging tranports
|
|
189
150
|
Logger.transports = [defaultTransport];
|
|
190
151
|
module.exports = Logger;
|
|
191
|
-
//# sourceMappingURL=logger.js.map
|
package/dist/modelwriter.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Writes a set of model files to disk
|
|
3
|
-
* @param
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
3
|
+
* @param files - the set of files to write, with names and whether they are external
|
|
4
|
+
* @param path - a path to the directory where to write the files
|
|
5
|
+
* @param options - a set of options
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export interface WritableModelFile {
|
|
8
|
+
fileName: string;
|
|
9
|
+
definitions: string;
|
|
10
|
+
external?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface WriteModelsOptions {
|
|
13
|
+
includeExternalModels?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function writeModelsToFileSystem(files: WritableModelFile[], path: string, options?: WriteModelsOptions): void;
|