@accordproject/concerto-util 2.0.0-alpha.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -22,28 +22,44 @@
22
22
  */
23
23
 
24
24
  // Exceptions
25
- module.exports.BaseException = require('./lib/baseexception');
26
- module.exports.BaseFileException = require('./lib/basefileexception');
25
+ const BaseException = require('./lib/baseexception');
26
+ const BaseFileException = require('./lib/basefileexception');
27
27
 
28
28
  // Transitive closure downloader
29
- module.exports.FileDownloader = require('./lib/filedownloader');
29
+ const FileDownloader = require('./lib/filedownloader');
30
30
 
31
31
  // File Loaders
32
- module.exports.CompositeFileLoader = require('./lib/loaders/compositefileloader');
33
- module.exports.DefaultFileLoader = require('./lib/loaders/defaultfileloader');
34
- module.exports.GitHubFileLoader = require('./lib/loaders/githubfileloader');
35
- module.exports.HTTPFileLoader = require('./lib/loaders/httpfileloader');
32
+ const CompositeFileLoader = require('./lib/loaders/compositefileloader');
33
+ const DefaultFileLoader = require('./lib/loaders/defaultfileloader');
34
+ const GitHubFileLoader = require('./lib/loaders/githubfileloader');
35
+ const HTTPFileLoader = require('./lib/loaders/httpfileloader');
36
36
 
37
37
  // Writers
38
- module.exports.Writer = require('./lib/writer');
39
- module.exports.FileWriter = require('./lib/filewriter');
40
- module.exports.ModelWriter = require('./lib/modelwriter');
38
+ const Writer = require('./lib/writer');
39
+ const FileWriter = require('./lib/filewriter');
40
+ const ModelWriter = require('./lib/modelwriter');
41
41
 
42
42
  // Logger
43
- module.exports.Logger = require('./lib/logger');
43
+ const Logger = require('./lib/logger');
44
44
 
45
45
  // TypedStack
46
- module.exports.TypedStack = require('./lib/typedstack');
46
+ const TypedStack = require('./lib/typedstack');
47
47
 
48
48
  // Label
49
- module.exports.Label = require('./lib/label');
49
+ const Label = require('./lib/label');
50
+
51
+ module.exports = {
52
+ BaseException,
53
+ BaseFileException,
54
+ FileDownloader,
55
+ CompositeFileLoader,
56
+ DefaultFileLoader,
57
+ GitHubFileLoader,
58
+ HTTPFileLoader,
59
+ Writer,
60
+ FileWriter,
61
+ ModelWriter,
62
+ Logger,
63
+ TypedStack,
64
+ Label
65
+ };
package/lib/filewriter.js CHANGED
@@ -72,7 +72,7 @@ class FileWriter extends Writer {
72
72
 
73
73
  /**
74
74
  * Writes text to the current open file
75
- * @param {int} tabs - the number of tabs to use
75
+ * @param {number} tabs - the number of tabs to use
76
76
  * @param {string} text - the text to write
77
77
  */
78
78
  writeLine(tabs,text) {
@@ -85,7 +85,7 @@ class FileWriter extends Writer {
85
85
 
86
86
  /**
87
87
  * Writes text to the start of the current open file
88
- * @param {int} tabs - the number of tabs to use
88
+ * @param {number} tabs - the number of tabs to use
89
89
  * @param {string} text - the text to write
90
90
  */
91
91
  writeBeforeLine(tabs,text) {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@accordproject/concerto-util",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0",
4
4
  "description": "Utilities for Concerto Modeling Language",
5
5
  "homepage": "https://github.com/accordproject/concerto",
6
6
  "engines": {
7
- "node": ">=12",
7
+ "node": ">=14",
8
8
  "npm": ">=6"
9
9
  },
10
10
  "main": "index.js",
@@ -16,11 +16,12 @@
16
16
  "licchk": "license-check-and-add",
17
17
  "postlicchk": "npm run doc",
18
18
  "doc": "jsdoc --pedantic --recurse -c jsdoc.json",
19
+ "postdoc": "npm run build:types",
19
20
  "test": "nyc mocha --recursive -t 10000",
20
21
  "test:watch": "nyc mocha --watch --recursive -t 10000",
21
22
  "mocha": "mocha --recursive -t 10000",
22
23
  "nyc": "nyc mocha --recursive -t 10000",
23
- "build:types": "npx -p typescript tsc ./lib/**/*.js index.js --declaration --allowJs --emitDeclarationOnly --outDir types"
24
+ "build:types": "tsc index.js --declaration --allowJs --emitDeclarationOnly --outDir types"
24
25
  },
25
26
  "repository": {
26
27
  "type": "git",
@@ -44,7 +45,8 @@
44
45
  "mocha": "8.3.2",
45
46
  "moxios": "0.4.0",
46
47
  "nyc": "15.1.0",
47
- "tmp-promise": "3.0.2"
48
+ "tmp-promise": "3.0.2",
49
+ "typescript": "4.6.3"
48
50
  },
49
51
  "dependencies": {
50
52
  "@supercharge/promise-pool": "1.7.0",
package/types/index.d.ts CHANGED
@@ -1,8 +1,14 @@
1
- export var FileDownloader: typeof import("./lib/filedownloader");
2
- export var CompositeFileLoader: typeof import("./lib/loaders/compositefileloader");
3
- export var DefaultFileLoader: typeof import("./lib/loaders/defaultfileloader");
4
- export var GitHubFileLoader: typeof import("./lib/loaders/githubfileloader");
5
- export var HTTPFileLoader: typeof import("./lib/loaders/httpfileloader");
6
- export var Writer: typeof import("./lib/writer");
7
- export var Logger: typeof import("./lib/logger");
8
- export var TypedStack: typeof import("./lib/typedstack");
1
+ import BaseException = require("./lib/baseexception");
2
+ import BaseFileException = require("./lib/basefileexception");
3
+ import FileDownloader = require("./lib/filedownloader");
4
+ import CompositeFileLoader = require("./lib/loaders/compositefileloader");
5
+ import DefaultFileLoader = require("./lib/loaders/defaultfileloader");
6
+ import GitHubFileLoader = require("./lib/loaders/githubfileloader");
7
+ import HTTPFileLoader = require("./lib/loaders/httpfileloader");
8
+ import Writer = require("./lib/writer");
9
+ import FileWriter = require("./lib/filewriter");
10
+ import ModelWriter = require("./lib/modelwriter");
11
+ import Logger = require("./lib/logger");
12
+ import TypedStack = require("./lib/typedstack");
13
+ import Label = require("./lib/label");
14
+ export { BaseException, BaseFileException, FileDownloader, CompositeFileLoader, DefaultFileLoader, GitHubFileLoader, HTTPFileLoader, Writer, FileWriter, ModelWriter, Logger, TypedStack, Label };
@@ -0,0 +1,16 @@
1
+ export = BaseException;
2
+ /**
3
+ * A base class for all Concerto exceptions
4
+ * @extends Error
5
+ * @class
6
+ * @memberof module:concerto-core
7
+ */
8
+ declare class BaseException extends Error {
9
+ /**
10
+ * Create the BaseException.
11
+ * @param {string} message - The exception message.
12
+ * @param {string} component - The optional component which throws this error.
13
+ */
14
+ constructor(message: string, component: string);
15
+ component: any;
16
+ }
@@ -0,0 +1,38 @@
1
+ export = BaseFileException;
2
+ /**
3
+ * Exception throws when a Concerto file is semantically invalid
4
+ * @extends BaseException
5
+ * @see {@link BaseException}
6
+ * @class
7
+ * @memberof module:concerto-core
8
+ */
9
+ declare class BaseFileException extends BaseException {
10
+ /**
11
+ * Create an BaseFileException
12
+ * @param {string} message - the message for the exception
13
+ * @param {string} fileLocation - the optional file location associated with the exception
14
+ * @param {string} fullMessage - the optional full message text
15
+ * @param {string} [fileName] - the file name
16
+ * @param {string} [component] - the component which throws this error
17
+ */
18
+ constructor(message: string, fileLocation: string, fullMessage: string, fileName?: string, component?: string);
19
+ fileLocation: string;
20
+ shortMessage: string;
21
+ fileName: string;
22
+ /**
23
+ * Returns the file location associated with the exception or null
24
+ * @return {string} the optional location associated with the exception
25
+ */
26
+ getFileLocation(): string;
27
+ /**
28
+ * Returns the error message without the location of the error
29
+ * @returns {string} the error message
30
+ */
31
+ getShortMessage(): string;
32
+ /**
33
+ * Returns the fileName for the error
34
+ * @returns {string} the file name or null
35
+ */
36
+ getFileName(): string;
37
+ }
38
+ import BaseException = require("./baseexception");
@@ -0,0 +1,44 @@
1
+ export = FileWriter;
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
+ *
7
+ * @private
8
+ * @extends Writer
9
+ * @see See {@link Writer}
10
+ * @class
11
+ * @memberof module:concerto-core
12
+ */
13
+ declare class FileWriter extends Writer {
14
+ /**
15
+ * Create a FileWriter.
16
+ *
17
+ * @param {string} outputDirectory - the path to an output directory
18
+ * that will be used to store generated files.
19
+ */
20
+ constructor(outputDirectory: string);
21
+ outputDirectory: string;
22
+ relativeDir: string;
23
+ fileName: string;
24
+ /**
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
29
+ */
30
+ openFile(fileName: string): void;
31
+ /**
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
37
+ */
38
+ openRelativeFile(relativeDir: string, fileName: string): void;
39
+ /**
40
+ * Closes the current open file
41
+ */
42
+ closeFile(): void;
43
+ }
44
+ import Writer = require("./writer");
@@ -0,0 +1,12 @@
1
+ /**
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
5
+ */
6
+ export function labelToSentence(labelName?: string): string;
7
+ /**
8
+ * Create a camelCase label from a sentence
9
+ * @param {string} sentence - the sentence
10
+ * @returns {string} - The camelCase label
11
+ */
12
+ export function sentenceToLabel(sentence?: string): string;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Writes a set of model files to disk
3
+ * @param {*} files - the set of files to write, with names and whether they are external
4
+ * @param {string} path - a path to the directory where to write the files
5
+ * @param {*} options - a set of options
6
+ */
7
+ export function writeModelsToFileSystem(files: any, path: string, options?: any): void;