Skip to content

Commit

Permalink
WIP(*) Some adjustments to jsdoc for TS generation
Browse files Browse the repository at this point in the history
Signed-off-by: jeromesimeon <[email protected]>
  • Loading branch information
jeromesimeon committed Dec 2, 2021
1 parent c641751 commit 87d86fd
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 102 deletions.
2 changes: 1 addition & 1 deletion packages/concerto-core/lib/modelmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ const debug = require('debug')('concerto:ModelManager');
*
* Use the {@link Concerto} class to validate instances.
*
* @class
* @memberof module:concerto-core
*/
class ModelManager {
/**
* Create the ModelManager.
* @constructor
* @param {object} [options] - Serializer options
*/
constructor(options) {
Expand Down
7 changes: 0 additions & 7 deletions packages/concerto-core/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export var BaseException: typeof import("./lib/baseexception");
export var BaseFileException: typeof import("./lib/basefileexception");
export var ParseException: typeof import("./lib/introspect/parseexception");
export var SecurityException: typeof import("./lib/securityexception");
export var IllegalModelException: typeof import("./lib/introspect/illegalmodelexception");
export var TypeNotFoundException: typeof import("./lib/typenotfoundexception");
Expand All @@ -22,19 +19,15 @@ export var Typed: typeof import("./lib/model/typed");
export var Identifiable: typeof import("./lib/model/identifiable");
export var Relationship: typeof import("./lib/model/relationship");
export var Resource: typeof import("./lib/model/resource");
export var Writer: typeof import("./lib/writer");
export var Factory: typeof import("./lib/factory");
export var Globalize: typeof import("./lib/globalize");
export var Introspector: typeof import("./lib/introspect/introspector");
export var ModelFile: typeof import("./lib/introspect/modelfile");
export var ModelManager: typeof import("./lib/modelmanager");
export var Serializer: typeof import("./lib/serializer");
export var ModelUtil: typeof import("./lib/modelutil");
export var DefaultModelFileLoader: typeof import("./lib/introspect/loaders/defaultmodelfileloader");
export var ModelLoader: typeof import("./lib/modelloader");
export var DateTimeUtil: typeof import("./lib/datetimeutil");
export var Logger: typeof import("./lib/logger");
export var TypedStack: typeof import("./lib/serializer/typedstack");
export var Concerto: typeof import("./lib/concerto");
export var MetaModel: typeof import("./lib/introspect/metamodel");
export var version: any;
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
export = IllegalModelException;
declare const IllegalModelException_base: typeof import("@accordproject/concerto-cto/types/lib/basefileexception");
/**
* Exception throws when a composer file is semantically invalid
* @extends BaseFileException
* @see See {@link BaseFileException}
* @class
* @memberof module:concerto-core
*/
declare class IllegalModelException extends BaseFileException {
declare class IllegalModelException extends IllegalModelException_base {
/**
* Create an IllegalModelException.
* @param {string} message - the message for the exception
Expand All @@ -20,4 +21,3 @@ declare class IllegalModelException extends BaseFileException {
*/
constructor(message: string, modelFile?: ModelFile, fileLocation?: any, component?: string);
}
import BaseFileException = require("../basefileexception");
56 changes: 2 additions & 54 deletions packages/concerto-core/types/lib/introspect/metamodel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ declare class MetaModel {
* Resolve the namespace for names in the metamodel
* @param {object} modelManager - the ModelManager
* @param {object} metaModel - the MetaModel
* @param {boolean} [validate] - whether to perform validation
* @return {object} the resolved metamodel
*/
static resolveMetaModel(modelManager: object, metaModel: object): object;
static resolveMetaModel(modelManager: object, metaModel: object, validate?: boolean): object;
/**
* Export metamodel from a model file
* @param {object} modelFile - the ModelFile
Expand All @@ -62,64 +63,11 @@ declare class MetaModel {
* @return {object} the metamodel for this model manager
*/
static modelManagerToMetaModel(modelManager: object, resolve?: boolean, validate?: boolean): object;
/**
* Create decorator argument string from a metamodel
* @param {object} mm - the metamodel
* @return {string} the string for the decorator argument
*/
static decoratorArgFromMetaModel(mm: object): string;
/**
* Create decorator string from a metamodel
* @param {object} mm - the metamodel
* @return {string} the string for the decorator
*/
static decoratorFromMetaModel(mm: object): string;
/**
* Create decorators string from a metamodel
* @param {object} mm - the metamodel
* @param {string} prefix - indentation
* @return {string} the string for the decorators
*/
static decoratorsFromMetaModel(mm: object, prefix: string): string;
/**
* Create a property string from a metamodel
* @param {object} mm - the metamodel
* @return {string} the string for that property
*/
static propertyFromMetaModel(mm: object): string;
/**
* Create a declaration string from a metamodel
* @param {object} mm - the metamodel
* @return {string} the string for that declaration
*/
static declFromMetaModel(mm: object): string;
/**
* Create a model string from a metamodel
* @param {object} metaModel - the metamodel
* @param {boolean} [validate] - whether to perform validation
* @return {string} the string for that model
*/
static ctoFromMetaModel(metaModel: object, validate?: boolean): string;
/**
* Import metamodel to a model manager
* @param {object} metaModel - the metamodel
* @param {boolean} [validate] - whether to perform validation
* @return {object} the metamodel for this model manager
*/
static modelManagerFromMetaModel(metaModel: object, validate?: boolean): object;
/**
* Export metamodel from a model string
* @param {string} model - the string for the model
* @param {boolean} [validate] - whether to perform validation
* @return {object} the metamodel for this model
*/
static ctoToMetaModel(model: string, validate?: boolean): object;
/**
* Export metamodel from a model string and resolve names
* @param {*} modelManager - the model manager
* @param {string} model - the string for the model
* @param {boolean} [validate] - whether to perform validation
* @return {object} the metamodel for this model
*/
static ctoToMetaModelAndResolve(modelManager: any, model: string, validate?: boolean): object;
}
12 changes: 9 additions & 3 deletions packages/concerto-core/types/lib/introspect/modelfile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ declare class ModelFile {
* Use the ModelManager to manage ModelFiles.
* @param {ModelManager} modelManager - the ModelManager that manages this
* ModelFile
* @param {string} definitions - The DSL model as a string.
* @param {object} ast - The abstract syntax tree of the model as a JSON object.
* @param {string} [definitions] - The optional CTO model as a string.
* @param {string} [fileName] - The optional filename for this modelfile
* @throws {IllegalModelException}
*/
constructor(modelManager: ModelManager, definitions: string, fileName?: string);
constructor(modelManager: ModelManager, ast: object, definitions?: string, fileName?: string);
modelManager: ModelManager;
external: boolean;
declarations: any[];
Expand All @@ -27,8 +28,8 @@ declare class ModelFile {
importUriMap: {};
fileName: string;
concertoVersion: any;
definitions: string;
ast: any;
definitions: string;
/**
* Returns true
* @returns {boolean} true
Expand Down Expand Up @@ -227,6 +228,11 @@ declare class ModelFile {
* @return {string} The definitions for this model.
*/
getDefinitions(): string;
/**
* Get the ast for this model.
* @return {object} The definitions for this model.
*/
getAst(): object;
/**
* Get the expected concerto version
* @return {string} The semver range for compatible concerto versions
Expand Down
11 changes: 5 additions & 6 deletions packages/concerto-core/types/lib/modelmanager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export = ModelManager;
*
* Use the {@link Concerto} class to validate instances.
*
* @class
* @memberof module:concerto-core
*/
declare class ModelManager {
/**
* Create the ModelManager.
* @constructor
* @param {object} [options] - Serializer options
*/
constructor(options?: object);
Expand Down Expand Up @@ -49,11 +49,11 @@ declare class ModelManager {
* Note that if there are dependencies between multiple files the files
* must be added in dependency order, or the addModelFiles method can be
* used to add a set of files irrespective of dependencies.
* @param {string} modelFile - The Concerto file as a string
* @param {string|ModelFile} modelFile - The Concerto file as a string
* @param {string} [fileName] - a file name to associate with the model file
* @throws {IllegalModelException}
*/
validateModelFile(modelFile: string, fileName?: string): void;
validateModelFile(modelFile: string | ModelFile, fileName?: string): void;
/**
* Throws an error with details about the existing namespace.
* @param {ModelFile} modelFile The model file that is trying to declare an existing namespace
Expand Down Expand Up @@ -108,11 +108,11 @@ declare class ModelManager {
* Downloads all ModelFiles that are external dependencies and adds or
* updates them in this ModelManager.
* @param {Object} [options] - Options object passed to ModelFileLoaders
* @param {ModelFileDownloader} [modelFileDownloader] - an optional ModelFileDownloader
* @param {FileDownloader} [fileDownloader] - an optional FileDownloader
* @throws {IllegalModelException} if the models fail validation
* @return {Promise} a promise when the download and update operation is completed.
*/
updateExternalModels(options?: any, modelFileDownloader?: ModelFileDownloader): Promise<any>;
updateExternalModels(options?: any, fileDownloader?: typeof import("@accordproject/concerto-util/types/lib/filedownloader")): Promise<any>;
/**
* Write all models in this model manager to the specified path in the file system
*
Expand Down Expand Up @@ -249,4 +249,3 @@ declare class ModelManager {
import Factory = require("./factory");
import Serializer = require("./serializer");
import ModelFile = require("./introspect/modelfile");
import ModelFileDownloader = require("./introspect/loaders/modelfiledownloader");
4 changes: 2 additions & 2 deletions packages/concerto-core/types/lib/securityexception.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export = SecurityException;
declare const SecurityException_base: typeof import("@accordproject/concerto-cto/types/lib/baseexception");
/**
* Class representing a security exception
* @extends BaseException
* @see See {@link BaseException}
* @class
* @memberof module:concerto-core
*/
declare class SecurityException extends BaseException {
declare class SecurityException extends SecurityException_base {
/**
* Create the SecurityException.
* @param {string} message - The exception message.
*/
constructor(message: string);
}
import BaseException = require("./baseexception");
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export = ValidationException;
declare const ValidationException_base: typeof import("@accordproject/concerto-cto/types/lib/baseexception");
/**
* Exception thrown when a resource fails to model against the model
* @extends BaseException
Expand All @@ -7,6 +8,5 @@ export = ValidationException;
* @memberof module:concerto-core
* @private
*/
declare class ValidationException extends BaseException {
declare class ValidationException extends ValidationException_base {
}
import BaseException = require("../baseexception");
4 changes: 2 additions & 2 deletions packages/concerto-core/types/lib/typenotfoundexception.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
export = TypeNotFoundException;
declare const TypeNotFoundException_base: typeof import("@accordproject/concerto-cto/types/lib/baseexception");
/**
* Error thrown when a Concerto type does not exist.
* @extends BaseException
* @see see {@link BaseException}
* @class
* @memberof module:concerto-core
*/
declare class TypeNotFoundException extends BaseException {
declare class TypeNotFoundException extends TypeNotFoundException_base {
/**
* Constructor. If the optional 'message' argument is not supplied, it will be set to a default value that
* includes the type name.
Expand All @@ -22,4 +23,3 @@ declare class TypeNotFoundException extends BaseException {
*/
getTypeName(): string;
}
import BaseException = require("./baseexception");
4 changes: 2 additions & 2 deletions packages/concerto-util/lib/filedownloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ const handleJobError = async (error, job) => {

/**
* Downloads the transitive closure of a set of model files.
* @class
* @memberof module:concerto-core
*/
class FileDownloader {
/**
* Create a FileDownloader and bind to a FileLoader.
* @param {fileLoader} fileLoader - the loader to use to download model files
* @constructor
* @param {*} fileLoader - the loader to use to download model files
* @param {*} getExternalImports - a function taking a file and returning new files
* @param {Number} concurrency - the number of model files to download concurrently
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/concerto-util/lib/loaders/compositefileloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class CompositeFileLoader {

/**
* Adds a FileLoader implemenetation to the FileLoader
* @param {FileLoader} fileLoader - The script to add to the ScriptManager
* @param {*} fileLoader - The script to add to the ScriptManager
*/
addFileLoader(fileLoader) {
this.fileLoaders.push(fileLoader);
}

/**
* Get the array of FileLoader instances
* @return {FileLoaders[]} The FileLoader registered
* @return {*} The FileLoader registered
* @private
*/
getFileLoaders() {
Expand Down
8 changes: 4 additions & 4 deletions packages/concerto-util/lib/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Writer {

/**
* Writes text to the start of the buffer
* @param {int} tabs - the number of tabs to use
* @param {number} tabs - the number of tabs to use
* @param {string} text - the text to write
*/
writeBeforeLine(tabs, text) {
Expand All @@ -47,7 +47,7 @@ class Writer {

/**
* Append text to the buffer
* @param {int} tabs - the number of tabs to use
* @param {number} tabs - the number of tabs to use
* @param {string} text - the text to write
*/
writeLine(tabs, text) {
Expand All @@ -61,7 +61,7 @@ class Writer {

/**
* Returns the number of lines that have been written to the buffer.
* @return {int} the number of lines written to the buffer.
* @return {number} the number of lines written to the buffer.
*/
getLineCount() {
return this.linesWritten;
Expand All @@ -70,7 +70,7 @@ class Writer {

/**
* Append text to the buffer, prepending tabs
* @param {int} tabs - the number of tabs to use
* @param {number} tabs - the number of tabs to use
* @param {string} text - the text to write
*/
writeIndented(tabs,text) {
Expand Down
8 changes: 4 additions & 4 deletions packages/concerto-util/types/lib/filedownloader.d.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
export = FileDownloader;
/**
* Downloads the transitive closure of a set of model files.
* @class
* @memberof module:concerto-core
*/
declare class FileDownloader {
/**
* Create a FileDownloader and bind to a FileLoader.
* @param {fileLoader} fileLoader - the loader to use to download model files
* @constructor
* @param {*} fileLoader - the loader to use to download model files
* @param {*} getExternalImports - a function taking a file and returning new files
* @param {Number} concurrency - the number of model files to download concurrently
*/
constructor(fileLoader: fileLoader, getExternalImports: any, concurrency?: number);
fileLoader: fileLoader;
constructor(fileLoader: any, getExternalImports: any, concurrency?: number);
fileLoader: any;
concurrency: number;
getExternalImports: any;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ declare class CompositeFileLoader {
fileLoaders: any[];
/**
* Adds a FileLoader implemenetation to the FileLoader
* @param {FileLoader} fileLoader - The script to add to the ScriptManager
* @param {*} fileLoader - The script to add to the ScriptManager
*/
addFileLoader(fileLoader: FileLoader): void;
addFileLoader(fileLoader: any): void;
/**
* Get the array of FileLoader instances
* @return {FileLoaders[]} The FileLoader registered
* @return {*[]} The FileLoader registered
* @private
*/
private getFileLoaders;
Expand Down
Loading

0 comments on commit 87d86fd

Please sign in to comment.