@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.
Files changed (64) hide show
  1. package/dist/baseexception.d.ts +7 -7
  2. package/dist/baseexception.js +40 -6
  3. package/dist/basefileexception.d.ts +16 -16
  4. package/dist/basefileexception.js +10 -11
  5. package/dist/concerto-util.js +1 -1
  6. package/dist/concerto-util.js.LICENSE.txt +1 -1
  7. package/dist/errorcodes.d.ts +7 -4
  8. package/dist/errorcodes.js +11 -6
  9. package/dist/filedownloader.d.ts +24 -17
  10. package/dist/filedownloader.js +19 -20
  11. package/dist/filewriter.d.ts +28 -25
  12. package/dist/filewriter.js +57 -31
  13. package/dist/identifiers.d.ts +5 -5
  14. package/dist/identifiers.js +10 -11
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.js +0 -1
  17. package/dist/inmemorywriter.d.ts +11 -6
  18. package/dist/inmemorywriter.js +3 -4
  19. package/dist/label.d.ts +6 -6
  20. package/dist/label.js +7 -9
  21. package/dist/loaders/compositefileloader.d.ts +18 -13
  22. package/dist/loaders/compositefileloader.js +7 -8
  23. package/dist/loaders/defaultfileloader.d.ts +5 -5
  24. package/dist/loaders/defaultfileloader.js +4 -5
  25. package/dist/loaders/fileloader.d.ts +4 -0
  26. package/dist/loaders/fileloader.js +15 -0
  27. package/dist/loaders/githubfileloader.d.ts +22 -3
  28. package/dist/loaders/githubfileloader.js +7 -8
  29. package/dist/loaders/httpfileloader.d.ts +12 -11
  30. package/dist/loaders/httpfileloader.js +8 -7
  31. package/dist/logger.d.ts +35 -55
  32. package/dist/logger.js +24 -64
  33. package/dist/modelwriter.d.ts +12 -4
  34. package/dist/modelwriter.js +38 -10
  35. package/dist/null.d.ts +4 -4
  36. package/dist/null.js +2 -3
  37. package/dist/typedstack.d.ts +15 -14
  38. package/dist/typedstack.js +10 -12
  39. package/dist/warning.d.ts +5 -5
  40. package/dist/warning.js +7 -9
  41. package/dist/writer.d.ts +14 -10
  42. package/dist/writer.js +9 -10
  43. package/package.json +2 -2
  44. package/types/lib/logger.d.ts +2 -2
  45. package/types/lib/null.d.ts +15 -0
  46. package/dist/baseexception.js.map +0 -1
  47. package/dist/basefileexception.js.map +0 -1
  48. package/dist/errorcodes.js.map +0 -1
  49. package/dist/filedownloader.js.map +0 -1
  50. package/dist/filewriter.js.map +0 -1
  51. package/dist/identifiers.js.map +0 -1
  52. package/dist/index.js.map +0 -1
  53. package/dist/inmemorywriter.js.map +0 -1
  54. package/dist/label.js.map +0 -1
  55. package/dist/loaders/compositefileloader.js.map +0 -1
  56. package/dist/loaders/defaultfileloader.js.map +0 -1
  57. package/dist/loaders/githubfileloader.js.map +0 -1
  58. package/dist/loaders/httpfileloader.js.map +0 -1
  59. package/dist/logger.js.map +0 -1
  60. package/dist/modelwriter.js.map +0 -1
  61. package/dist/null.js.map +0 -1
  62. package/dist/typedstack.js.map +0 -1
  63. package/dist/warning.js.map +0 -1
  64. package/dist/writer.js.map +0 -1
@@ -1,31 +1,38 @@
1
- export = FileDownloader;
1
+ import type { FileLoader } from './loaders/fileloader';
2
+ type ExternalImportMap = Record<string, string>;
3
+ type DownloadJob<TFile> = {
4
+ downloadedUris: Set<string>;
5
+ url: string;
6
+ options: RequestInit;
7
+ };
2
8
  /**
3
9
  * Downloads the transitive closure of a set of model files.
4
10
  * @memberof module:concerto-core
5
11
  */
6
- declare class FileDownloader {
12
+ declare class FileDownloader<TFile = unknown> {
13
+ fileLoader: FileLoader<TFile>;
14
+ getExternalImports: (file: TFile) => ExternalImportMap;
15
+ concurrency: number;
7
16
  /**
8
17
  * Create a FileDownloader and bind to a FileLoader.
9
- * @param {*} fileLoader - the loader to use to download model files
10
- * @param {*} getExternalImports - a function taking a file and returning new files
11
- * @param {Number} concurrency - the number of model files to download concurrently
18
+ * @param fileLoader - the loader to use to download model files
19
+ * @param getExternalImports - a function taking a file and returning new files
20
+ * @param concurrency - the number of model files to download concurrently
12
21
  */
13
- constructor(fileLoader: any, getExternalImports: any, concurrency?: number);
14
- fileLoader: any;
15
- concurrency: number;
16
- getExternalImports: any;
22
+ constructor(fileLoader: FileLoader<TFile>, getExternalImports: (file: TFile) => ExternalImportMap, concurrency?: number);
17
23
  /**
18
24
  * Download all external dependencies for an array of model files
19
- * @param {File[]} files - the model files
20
- * @param {Object} [options] - Options object passed to FileLoaders
21
- * @return {Promise} a promise that resolves to Files[] for the external model files
25
+ * @param files - the model files
26
+ * @param options - Options object passed to FileLoaders
27
+ * @return a promise that resolves to Files[] for the external model files
22
28
  */
23
- downloadExternalDependencies(files: File[], options?: Object): Promise<any>;
29
+ downloadExternalDependencies(files: TFile[], options?: RequestInit): Promise<TFile[]>;
24
30
  /**
25
31
  * Execute a Job
26
- * @param {Object} job - the job to execute
27
- * @param {Object} fileLoader - the loader to use to download model files.
28
- * @return {Promise} a promise to the job results
32
+ * @param job - the job to execute
33
+ * @param fileLoader - the loader to use to download model files.
34
+ * @return a promise to the job results
29
35
  */
30
- runJob(job: Object, fileLoader: Object): Promise<any>;
36
+ runJob(job: DownloadJob<TFile>, fileLoader: FileLoader<TFile>): Promise<TFile[]>;
31
37
  }
38
+ export = FileDownloader;
@@ -12,13 +12,16 @@
12
12
  * limitations under the License.
13
13
  */
14
14
  'use strict';
15
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
15
16
  const debug = require('debug')('concerto:FileDownloader');
17
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
16
18
  const PromisePool = require('@supercharge/promise-pool');
17
- const flatten = arr => [].concat(...arr);
18
- const filterUndefined = arr => arr.filter(Boolean);
19
+ const flatten = (arr) => [].concat(...arr);
20
+ const filterUndefined = (arr) => arr.filter((value) => Boolean(value));
19
21
  const handleJobError = async (error, job) => {
20
- const badHttpResponse = error.response && error.response.status && error.response.status !== 200;
21
- const dnsFailure = error.code && error.code === 'ENOTFOUND';
22
+ const errLike = error;
23
+ const badHttpResponse = errLike.response && errLike.response.status && errLike.response.status !== 200;
24
+ const dnsFailure = errLike.code && errLike.code === 'ENOTFOUND';
22
25
  if (badHttpResponse || dnsFailure) {
23
26
  const err = new Error(`Unable to download external model dependency '${job.url}'`);
24
27
  err.code = 'MISSING_DEPENDENCY';
@@ -33,9 +36,9 @@ const handleJobError = async (error, job) => {
33
36
  class FileDownloader {
34
37
  /**
35
38
  * Create a FileDownloader and bind to a FileLoader.
36
- * @param {*} fileLoader - the loader to use to download model files
37
- * @param {*} getExternalImports - a function taking a file and returning new files
38
- * @param {Number} concurrency - the number of model files to download concurrently
39
+ * @param fileLoader - the loader to use to download model files
40
+ * @param getExternalImports - a function taking a file and returning new files
41
+ * @param concurrency - the number of model files to download concurrently
39
42
  */
40
43
  constructor(fileLoader, getExternalImports, concurrency = 10) {
41
44
  this.fileLoader = fileLoader;
@@ -44,17 +47,14 @@ class FileDownloader {
44
47
  }
45
48
  /**
46
49
  * Download all external dependencies for an array of model files
47
- * @param {File[]} files - the model files
48
- * @param {Object} [options] - Options object passed to FileLoaders
49
- * @return {Promise} a promise that resolves to Files[] for the external model files
50
+ * @param files - the model files
51
+ * @param options - Options object passed to FileLoaders
52
+ * @return a promise that resolves to Files[] for the external model files
50
53
  */
51
- downloadExternalDependencies(files, options) {
54
+ downloadExternalDependencies(files, options = {}) {
52
55
  const method = 'downloadExternalDependencies';
53
56
  debug(method);
54
57
  const downloadedUris = new Set();
55
- if (!options) {
56
- options = {};
57
- }
58
58
  const jobs = flatten(files.map(file => {
59
59
  const externalImports = this.getExternalImports(file);
60
60
  return Object.keys(externalImports).map(importDeclaration => ({
@@ -67,14 +67,14 @@ class FileDownloader {
67
67
  .withConcurrency(this.concurrency)
68
68
  .for(jobs)
69
69
  .handleError(handleJobError)
70
- .process(x => this.runJob(x, this.fileLoader))
70
+ .process((x) => this.runJob(x, this.fileLoader))
71
71
  .then(({ results }) => filterUndefined(flatten(results)));
72
72
  }
73
73
  /**
74
74
  * Execute a Job
75
- * @param {Object} job - the job to execute
76
- * @param {Object} fileLoader - the loader to use to download model files.
77
- * @return {Promise} a promise to the job results
75
+ * @param job - the job to execute
76
+ * @param fileLoader - the loader to use to download model files.
77
+ * @return a promise to the job results
78
78
  */
79
79
  runJob(job, fileLoader) {
80
80
  const downloadedUris = job.downloadedUris;
@@ -95,7 +95,7 @@ class FileDownloader {
95
95
  .withConcurrency(this.concurrency)
96
96
  .for(importedUris)
97
97
  .handleError(handleJobError)
98
- .process(uri => {
98
+ .process((uri) => {
99
99
  if (!downloadedUris.has(uri)) {
100
100
  // recurse and add a new job for the referenced URI
101
101
  return this.runJob({
@@ -111,4 +111,3 @@ class FileDownloader {
111
111
  }
112
112
  }
113
113
  module.exports = FileDownloader;
114
- //# sourceMappingURL=filedownloader.js.map
@@ -1,44 +1,47 @@
1
- export = FileWriter;
1
+ import Writer = require('./writer');
2
2
  /**
3
- * FileWriter creates text files under a directory tree. It can be used
4
- * by code generators to create source files for example.
5
- * Basic usage is: openFile(fileName), writeLine(...), closeFile().
6
- *
3
+ * FileWriter buffers text to be written to a file.
7
4
  * @private
8
- * @extends Writer
9
- * @see See {@link Writer}
10
5
  * @class
11
- * @memberof module:concerto-core
6
+ * @memberof module:concerto-util
12
7
  */
13
8
  declare class FileWriter extends Writer {
9
+ outputDirectory: string;
10
+ fileName: string | null;
11
+ relativeDir: string | null;
14
12
  /**
15
13
  * Create a FileWriter.
16
- *
17
- * @param {string} outputDirectory - the path to an output directory
18
- * that will be used to store generated files.
14
+ * @param outputDirectory - the output directory
19
15
  */
20
16
  constructor(outputDirectory: string);
21
- outputDirectory: string;
22
- relativeDir: string | null;
23
- fileName: string | null;
24
17
  /**
25
- * Opens a file for writing. The file will be created in the
26
- * root directory of this FileWriter.
27
- *
28
- * @param {string} fileName - the name of the file to open
18
+ * Open a file for writing. The file is created in the
19
+ * output directory.
20
+ * @param fileName - the name of the file to open
29
21
  */
30
22
  openFile(fileName: string): void;
31
23
  /**
32
- * Opens a file for writing, with a location relative to the
33
- * root directory of this FileWriter.
34
- *
35
- * @param {string} relativeDir - the relative directory to use
36
- * @param {string} fileName - the name of the file to open
24
+ * Open a file for writing. The file is created in the
25
+ * output directory, plus the relative directory path.
26
+ * @param relativeDir - the relative directory
27
+ * @param fileName - the name of the file to open
37
28
  */
38
29
  openRelativeFile(relativeDir: string, fileName: string): void;
39
30
  /**
40
- * Closes the current open file
31
+ * Writes text to the current open file
32
+ * @param tabs - the number of tabs to use
33
+ * @param text - the text to write
34
+ */
35
+ writeLine(tabs: number, text: string): void;
36
+ /**
37
+ * Writes text to the start of the current open file
38
+ * @param tabs - the number of tabs to use
39
+ * @param text - the text to write
40
+ */
41
+ writeBeforeLine(tabs: number, text: string): void;
42
+ /**
43
+ * Closes the file, flushing the buffer to disk.
41
44
  */
42
45
  closeFile(): void;
43
46
  }
44
- import Writer = require("./writer");
47
+ export = FileWriter;
@@ -12,83 +12,110 @@
12
12
  * limitations under the License.
13
13
  */
14
14
  'use strict';
15
- const fs = require('fs');
16
- const path = require('path');
17
- const Writer = require('./writer');
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
28
+ }) : function(o, v) {
29
+ o["default"] = v;
30
+ });
31
+ var __importStar = (this && this.__importStar) || (function () {
32
+ var ownKeys = function(o) {
33
+ ownKeys = Object.getOwnPropertyNames || function (o) {
34
+ var ar = [];
35
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
36
+ return ar;
37
+ };
38
+ return ownKeys(o);
39
+ };
40
+ return function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
47
+ })();
48
+ const fs = __importStar(require("fs"));
49
+ const path = __importStar(require("path"));
50
+ const Writer = require("./writer");
18
51
  /**
19
- * FileWriter creates text files under a directory tree. It can be used
20
- * by code generators to create source files for example.
21
- * Basic usage is: openFile(fileName), writeLine(...), closeFile().
22
- *
52
+ * FileWriter buffers text to be written to a file.
23
53
  * @private
24
- * @extends Writer
25
- * @see See {@link Writer}
26
54
  * @class
27
- * @memberof module:concerto-core
55
+ * @memberof module:concerto-util
28
56
  */
29
57
  class FileWriter extends Writer {
30
58
  /**
31
59
  * Create a FileWriter.
32
- *
33
- * @param {string} outputDirectory - the path to an output directory
34
- * that will be used to store generated files.
60
+ * @param outputDirectory - the output directory
35
61
  */
36
62
  constructor(outputDirectory) {
37
63
  super();
64
+ this.fileName = null;
65
+ this.relativeDir = null;
38
66
  this.outputDirectory = outputDirectory;
39
67
  this.relativeDir = null;
40
68
  this.fileName = null;
41
69
  fs.mkdirSync(outputDirectory, { recursive: true });
42
70
  }
43
71
  /**
44
- * Opens a file for writing. The file will be created in the
45
- * root directory of this FileWriter.
46
- *
47
- * @param {string} fileName - the name of the file to open
72
+ * Open a file for writing. The file is created in the
73
+ * output directory.
74
+ * @param fileName - the name of the file to open
48
75
  */
49
76
  openFile(fileName) {
50
77
  this.fileName = fileName;
51
78
  this.relativeDir = null;
52
79
  }
53
80
  /**
54
- * Opens a file for writing, with a location relative to the
55
- * root directory of this FileWriter.
56
- *
57
- * @param {string} relativeDir - the relative directory to use
58
- * @param {string} fileName - the name of the file to open
81
+ * Open a file for writing. The file is created in the
82
+ * output directory, plus the relative directory path.
83
+ * @param relativeDir - the relative directory
84
+ * @param fileName - the name of the file to open
59
85
  */
60
86
  openRelativeFile(relativeDir, fileName) {
61
- this.relativeDir = relativeDir;
62
87
  this.fileName = fileName;
88
+ this.relativeDir = relativeDir;
89
+ this.clearBuffer();
63
90
  }
64
91
  /**
65
92
  * Writes text to the current open file
66
- * @param {number} tabs - the number of tabs to use
67
- * @param {string} text - the text to write
93
+ * @param tabs - the number of tabs to use
94
+ * @param text - the text to write
68
95
  */
69
96
  writeLine(tabs, text) {
70
97
  if (this.fileName) {
71
98
  super.writeLine(tabs, text);
72
99
  }
73
100
  else {
74
- throw Error('File has not been opened!');
101
+ throw new Error('File has not been opened!');
75
102
  }
76
103
  }
77
104
  /**
78
105
  * Writes text to the start of the current open file
79
- * @param {number} tabs - the number of tabs to use
80
- * @param {string} text - the text to write
106
+ * @param tabs - the number of tabs to use
107
+ * @param text - the text to write
81
108
  */
82
109
  writeBeforeLine(tabs, text) {
83
110
  if (this.fileName) {
84
111
  super.writeBeforeLine(tabs, text);
85
112
  }
86
113
  else {
87
- throw Error('File has not been opened!');
114
+ throw new Error('File has not been opened!');
88
115
  }
89
116
  }
90
117
  /**
91
- * Closes the current open file
118
+ * Closes the file, flushing the buffer to disk.
92
119
  */
93
120
  closeFile() {
94
121
  if (!this.fileName) {
@@ -108,4 +135,3 @@ class FileWriter extends Writer {
108
135
  }
109
136
  }
110
137
  module.exports = FileWriter;
111
- //# sourceMappingURL=filewriter.js.map
@@ -1,10 +1,10 @@
1
+ export declare const ID_REGEX: RegExp;
1
2
  /**
2
3
  * Function that attempts to normalize arbitrary strings
3
4
  * into valid Concerto identifiers
4
5
  *
5
- * @param {string} identifier - the input value
6
- * @param {number} [truncateLength] - Length at which to truncate the identifier
7
- * @returns {string} - An identifier that meets the Concerto specification
6
+ * @param identifier - the input value
7
+ * @param truncateLength - Length at which to truncate the identifier
8
+ * @returns - An identifier that meets the Concerto specification
8
9
  */
9
- export function normalizeIdentifier(identifier: string, truncateLength?: number): string;
10
- export const ID_REGEX: RegExp;
10
+ export declare function normalizeIdentifier(identifier: string | null | undefined, truncateLength?: number): string;
@@ -12,27 +12,31 @@
12
12
  * limitations under the License.
13
13
  */
14
14
  'use strict';
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ID_REGEX = void 0;
17
+ exports.normalizeIdentifier = normalizeIdentifier;
15
18
  // Conforms to Concerto Spec for identifiers
16
- const ID_REGEX = /^(\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4})(?:\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\u200C|\u200D)*$/u;
19
+ exports.ID_REGEX = /^(\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4})(?:\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\$|_|\\u[0-9A-Fa-f]{4}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\u200C|\u200D)*$/u;
17
20
  /**
18
21
  * Function that attempts to normalize arbitrary strings
19
22
  * into valid Concerto identifiers
20
23
  *
21
- * @param {string} identifier - the input value
22
- * @param {number} [truncateLength] - Length at which to truncate the identifier
23
- * @returns {string} - An identifier that meets the Concerto specification
24
+ * @param identifier - the input value
25
+ * @param truncateLength - Length at which to truncate the identifier
26
+ * @returns - An identifier that meets the Concerto specification
24
27
  */
25
28
  function normalizeIdentifier(identifier, truncateLength = -1) {
26
29
  const replacer = (_match, group1) => {
27
30
  let escapedChar = '';
28
31
  // Loop through characters with multiple code points
29
32
  for (const codePoint of group1) {
33
+ // @ts-ignore
30
34
  escapedChar += `_${codePoint.codePointAt(0).toString(16)}`;
31
35
  }
32
36
  return escapedChar;
33
37
  };
34
38
  // Stringify null & undefined values
35
- let result = identifier ?? String(identifier);
39
+ let result = identifier !== null && identifier !== void 0 ? identifier : String(identifier);
36
40
  if (typeof result !== 'string') {
37
41
  throw new Error(`Unsupported identifier type, '${typeof result}'.`);
38
42
  }
@@ -51,13 +55,8 @@ function normalizeIdentifier(identifier, truncateLength = -1) {
51
55
  result = result.substring(0, truncateLength);
52
56
  }
53
57
  // Check validity
54
- if (!ID_REGEX.test(result)) {
58
+ if (!exports.ID_REGEX.test(result)) {
55
59
  throw new Error(`Unexpected error. Not able to escape identifier '${result}'.`);
56
60
  }
57
61
  return result;
58
62
  }
59
- module.exports = {
60
- normalizeIdentifier,
61
- ID_REGEX
62
- };
63
- //# sourceMappingURL=identifiers.js.map
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare const CompositeFileLoader: any;
11
11
  export declare const DefaultFileLoader: any;
12
12
  export declare const GitHubFileLoader: any;
13
13
  export declare const HTTPFileLoader: any;
14
+ export type { FileLoader } from './loaders/fileloader';
14
15
  export declare const Writer: any;
15
16
  export declare const FileWriter: any;
16
17
  export declare const ModelWriter: any;
package/dist/index.js CHANGED
@@ -49,4 +49,3 @@ exports.ErrorCodes = require('./errorcodes');
49
49
  exports.NullUtil = require('./null');
50
50
  // Warning
51
51
  exports.Warning = require('./warning');
52
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- export = InMemoryWriter;
1
+ import Writer = require('./writer');
2
2
  /**
3
3
  * InMemoryWriter stores string representation of files in a map structure.
4
4
  * The Map key is the filename, and the value are its string contents.
@@ -11,11 +11,16 @@ export = InMemoryWriter;
11
11
  */
12
12
  declare class InMemoryWriter extends Writer {
13
13
  fileName: string;
14
- data: Map<any, any>;
14
+ data: Map<string, string>;
15
+ /**
16
+ * Create a FileWriter.
17
+ *
18
+ */
19
+ constructor();
15
20
  /**
16
21
  * Creates the filename which will be used for association with its string content.
17
22
  *
18
- * @param {string} fileName - the name of the file.
23
+ * @param fileName - the name of the file.
19
24
  */
20
25
  openFile(fileName: string): void;
21
26
  /**
@@ -25,8 +30,8 @@ declare class InMemoryWriter extends Writer {
25
30
  /**
26
31
  * Returns the content of the Map store.
27
32
  *
28
- * @return {Map} - a Map containing the string representation of files. (k,v) => (filename, file content).
33
+ * @return - a Map containing the string representation of files. (k,v) => (filename, file content).
29
34
  */
30
- getFilesInMemory(): Map<any, any>;
35
+ getFilesInMemory(): Map<string, string>;
31
36
  }
32
- import Writer = require("./writer");
37
+ export = InMemoryWriter;
@@ -12,7 +12,7 @@
12
12
  * limitations under the License.
13
13
  */
14
14
  'use strict';
15
- const Writer = require('./writer');
15
+ const Writer = require("./writer");
16
16
  /**
17
17
  * InMemoryWriter stores string representation of files in a map structure.
18
18
  * The Map key is the filename, and the value are its string contents.
@@ -36,7 +36,7 @@ class InMemoryWriter extends Writer {
36
36
  /**
37
37
  * Creates the filename which will be used for association with its string content.
38
38
  *
39
- * @param {string} fileName - the name of the file.
39
+ * @param fileName - the name of the file.
40
40
  */
41
41
  openFile(fileName) {
42
42
  this.fileName = fileName;
@@ -51,11 +51,10 @@ class InMemoryWriter extends Writer {
51
51
  /**
52
52
  * Returns the content of the Map store.
53
53
  *
54
- * @return {Map} - a Map containing the string representation of files. (k,v) => (filename, file content).
54
+ * @return - a Map containing the string representation of files. (k,v) => (filename, file content).
55
55
  */
56
56
  getFilesInMemory() {
57
57
  return this.data;
58
58
  }
59
59
  }
60
60
  module.exports = InMemoryWriter;
61
- //# sourceMappingURL=inmemorywriter.js.map
package/dist/label.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Inserts correct spacing and capitalization to a camelCase label
3
- * @param {string} labelName - the label text to be transformed
4
- * @returns {string} - The label text formatted for rendering
3
+ * @param labelName - the label text to be transformed
4
+ * @returns - The label text formatted for rendering
5
5
  */
6
- export function labelToSentence(labelName?: string): string;
6
+ export declare function labelToSentence(labelName?: string): string;
7
7
  /**
8
8
  * Create a camelCase label from a sentence
9
- * @param {string} sentence - the sentence
10
- * @returns {string} - The camelCase label
9
+ * @param sentence - the sentence
10
+ * @returns - The camelCase label
11
11
  */
12
- export function sentenceToLabel(sentence?: string): string;
12
+ export declare function sentenceToLabel(sentence?: string): string;
package/dist/label.js CHANGED
@@ -12,10 +12,13 @@
12
12
  * limitations under the License.
13
13
  */
14
14
  'use strict';
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.labelToSentence = labelToSentence;
17
+ exports.sentenceToLabel = sentenceToLabel;
15
18
  /**
16
19
  * Inserts correct spacing and capitalization to a camelCase label
17
- * @param {string} labelName - the label text to be transformed
18
- * @returns {string} - The label text formatted for rendering
20
+ * @param labelName - the label text to be transformed
21
+ * @returns - The label text formatted for rendering
19
22
  */
20
23
  function labelToSentence(labelName = '') {
21
24
  return labelName
@@ -27,8 +30,8 @@ function labelToSentence(labelName = '') {
27
30
  }
28
31
  /**
29
32
  * Create a camelCase label from a sentence
30
- * @param {string} sentence - the sentence
31
- * @returns {string} - The camelCase label
33
+ * @param sentence - the sentence
34
+ * @returns - The camelCase label
32
35
  */
33
36
  function sentenceToLabel(sentence = '') {
34
37
  const split = sentence.split(/[^A-Za-z0-9_-]+/);
@@ -38,8 +41,3 @@ function sentenceToLabel(sentence = '') {
38
41
  const joined = split.join('');
39
42
  return joined.replace(/^./, str => str.toLowerCase());
40
43
  }
41
- module.exports = {
42
- labelToSentence,
43
- sentenceToLabel,
44
- };
45
- //# sourceMappingURL=label.js.map
@@ -1,4 +1,4 @@
1
- export = CompositeFileLoader;
1
+ import type { FileLoader } from './fileloader';
2
2
  /**
3
3
  * <p>
4
4
  * Manages a set of model file loaders, delegating to the first model file
@@ -8,35 +8,40 @@ export = CompositeFileLoader;
8
8
  * @class
9
9
  * @memberof module:concerto-util
10
10
  */
11
- declare class CompositeFileLoader {
12
- fileLoaders: any[];
11
+ declare class CompositeFileLoader<T = unknown> {
12
+ fileLoaders: Array<FileLoader<T>>;
13
+ /**
14
+ * Create the CompositeFileLoader. Used to delegate to a set of FileLoaders.
15
+ */
16
+ constructor();
13
17
  /**
14
18
  * Adds a FileLoader implemenetation to the FileLoader
15
- * @param {*} fileLoader - The script to add to the ScriptManager
19
+ * @param fileLoader - The script to add to the ScriptManager
16
20
  */
17
- addFileLoader(fileLoader: any): void;
21
+ addFileLoader(fileLoader: FileLoader<T>): void;
18
22
  /**
19
23
  * Get the array of FileLoader instances
20
- * @return {*} The FileLoader registered
24
+ * @return The FileLoader registered
21
25
  * @private
22
26
  */
23
- private getFileLoaders;
27
+ getFileLoaders(): Array<FileLoader<T>>;
24
28
  /**
25
29
  * Remove all registered FileLoaders
26
30
  */
27
31
  clearFileLoaders(): void;
28
32
  /**
29
33
  * Returns true if this ModelLoader can process the URL
30
- * @param {string} url - the URL
31
- * @return {boolean} true if this ModelLoader accepts the URL
34
+ * @param url - the URL
35
+ * @return true if this ModelLoader accepts the URL
32
36
  * @abstract
33
37
  */
34
38
  accepts(url: string): boolean;
35
39
  /**
36
40
  * Load a File from a URL and return it
37
- * @param {string} url - the url to get
38
- * @param {object} options - additional options
39
- * @return {Promise} a promise to the File
41
+ * @param url - the url to get
42
+ * @param options - additional options
43
+ * @return a promise to the File
40
44
  */
41
- load(url: string, options: object): Promise<any>;
45
+ load(url: string, options?: RequestInit): Promise<T>;
42
46
  }
47
+ export = CompositeFileLoader;