From e9607363ea16b83de12b9ce53bb7df7e5e0f14d0 Mon Sep 17 00:00:00 2001 From: asyncapi-bot Date: Wed, 11 Oct 2023 11:54:15 +0000 Subject: [PATCH] chore(release): v1.14.0 --- docs/api.md | 132 +++++++++++++++++++++++++++++++++++++++++++++- package-lock.json | 15 +++--- package.json | 2 +- 3 files changed, 137 insertions(+), 12 deletions(-) diff --git a/docs/api.md b/docs/api.md index e15f4cdf9..b6923a5e7 100644 --- a/docs/api.md +++ b/docs/api.md @@ -26,7 +26,15 @@ Reference API documentation for AsyncAPI Generator library. * [.hooks](#Generator+hooks) : `Object` * [.mapBaseUrlToFolder](#Generator+mapBaseUrlToFolder) : `Object` * [.templateParams](#Generator+templateParams) : `Object` - * [.generate(asyncapiDocument, [parseOptions])](#Generator+generate) ⇒ `Promise` + * [.generate(asyncapiDocument, [parseOptions])](#Generator+generate) ⇒ `Promise.` + * [.validateAsyncAPIDocument(asyncapiDocument)](#Generator+validateAsyncAPIDocument) + * [.setupOutput()](#Generator+setupOutput) + * [.setupFSOutput()](#Generator+setupFSOutput) ⇒ `Promise.` + * [.setLogLevel()](#Generator+setLogLevel) ⇒ `void` + * [.installAndSetupTemplate()](#Generator+installAndSetupTemplate) ⇒ `Promise.<{templatePkgName: string, templatePkgPath: string}>` + * [.configureTemplateWorkflow(parseOptions)](#Generator+configureTemplateWorkflow) ⇒ `Promise.` + * [.handleEntrypoint()](#Generator+handleEntrypoint) ⇒ `Promise.` + * [.executeAfterHook()](#Generator+executeAfterHook) ⇒ `Promise.` * [.parseInput()](#Generator+parseInput) * [.configureTemplate()](#Generator+configureTemplate) * ~~[.generateFromString(asyncapiString, [parseOptions])](#Generator+generateFromString) ⇒ `Promise`~~ @@ -169,11 +177,19 @@ The template parameters. The structure for this object is based on each individu Generates files from a given template and an AsyncAPIDocument object. **Kind**: instance method of [`Generator`](#Generator) +**Returns**: `Promise.` - A Promise that resolves when the generation is completed. **Params** - asyncapiDocument `AsyncAPIDocument` | `string` - AsyncAPIDocument object to use as source. -- [parseOptions] `Object` ` = {}` - AsyncAPI Parser parse options. Check out [@asyncapi/parser](https://www.github.com/asyncapi/parser-js) for more information. Remember to use the right options to the right parser depending on the template you are using. +- [parseOptions] `Object` ` = {}` - AsyncAPI Parser parse options. + Check out [@asyncapi/parser](https://www.github.com/asyncapi/parser-js) for more information. + Remember to use the right options for the right parser depending on the template you are using. +**Example** +```js +await generator.generate(myAsyncAPIdocument); +console.log('Done!'); +``` **Example** ```js generator @@ -193,6 +209,118 @@ try { } ``` + + +### generator.validateAsyncAPIDocument +Validates the provided AsyncAPI document. + +**Kind**: instance method of [`Generator`](#Generator) +**Throws**: + +- `Error` Throws an error if the document is not valid. + +**Since**: 10/9/2023 - 4:26:33 PM +**Params** + +- asyncapiDocument `*` - The AsyncAPI document to be validated. + + + + +* generator.setupOutput()** : +Sets up the output configuration based on the specified output type. + +**Kind**: instance method of [`Generator`](#Generator) +**Throws**: + +- `Error` If 'output' is set to 'string' without providing 'entrypoint'. + +**Example** +```js +const generator = new Generator(); +generator.setupOutput(); +``` + + + +* generator.setupFSOutput() ⇒ `Promise.`** : +Sets up the file system (FS) output configuration. + +This function creates the target directory if it does not exist and verifies +the target directory if forceWrite is not enabled. + +**Kind**: instance method of [`Generator`](#Generator) +**Returns**: `Promise.` - A promise that fulfills when the setup is complete. +**Throws**: + +- `Error` If verification of the target directory fails and forceWrite is not enabled. + + + + +* generator.setLogLevel() ⇒ `void`** : +Sets the log level based on the debug option. + +If the debug option is enabled, the log level is set to 'debug'. + +**Kind**: instance method of [`Generator`](#Generator) + + + +* generator.installAndSetupTemplate() ⇒ `Promise.<{templatePkgName: string, templatePkgPath: string}>`** : +Installs and sets up the template for code generation. + +This function installs the specified template using the provided installation option, +sets up the necessary directory paths, loads the template configuration, and returns +information about the installed template. + +**Kind**: instance method of [`Generator`](#Generator) +**Returns**: `Promise.<{templatePkgName: string, templatePkgPath: string}>` - A promise that resolves to an object containing the name and path of the installed template. + + + +### generator.configureTemplateWorkflow +Configures the template workflow based on provided parsing options. + +This function performs the following steps: +1. Parses the input AsyncAPI document using the specified parse options. +2. Validates the template configuration and parameters. +3. Configures the template based on the parsed AsyncAPI document. +4. Registers filters, hooks, and launches the 'generate:before' hook if applicable. + +**Kind**: instance method of [`Generator`](#Generator) +**Returns**: `Promise.` - A promise that resolves when the configuration is completed. +**Params** + +- parseOptions `*` - Options for parsing the AsyncAPI document. + + + + +* generator.handleEntrypoint() ⇒ `Promise.`** : +Handles the logic for the template entrypoint. + +If an entrypoint is specified: +- Resolves the absolute path of the entrypoint file. +- Throws an error if the entrypoint file doesn't exist. +- Generates a file or renders content based on the output type. +- Launches the 'generate:after' hook if the output is 'fs'. + +If no entrypoint is specified, generates the directory structure. + +**Kind**: instance method of [`Generator`](#Generator) +**Returns**: `Promise.` - A promise that resolves when the entrypoint logic is completed. + + + +* generator.executeAfterHook() ⇒ `Promise.`** : +Executes the 'generate:after' hook. + +Launches the after-hook to perform additional actions after code generation. + +**Kind**: instance method of [`Generator`](#Generator) +**Returns**: `Promise.` - A promise that resolves when the after-hook execution is completed. + * generator.parseInput()** : diff --git a/package-lock.json b/package-lock.json index b135420dc..24edc01bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/generator", - "version": "1.13.1", + "version": "1.14.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@asyncapi/generator", - "version": "1.13.1", + "version": "1.14.0", "license": "Apache-2.0", "dependencies": { "@asyncapi/generator-react-sdk": "^0.2.23", @@ -58,7 +58,6 @@ "version": "2.2.1", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", "integrity": "sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==", - "dev": true, "dependencies": { "@jridgewell/gen-mapping": "^0.3.0", "@jridgewell/trace-mapping": "^0.3.9" @@ -370,7 +369,6 @@ "version": "7.22.20", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.20.tgz", "integrity": "sha512-Y6jd1ahLubuYweD/zJH+vvOY141v4f9igNQAQ+MBgq9JlHS2iTsZKn1aMsb3vGccZsXI16VzTBw52Xx0DWmtnA==", - "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", @@ -400,7 +398,6 @@ "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, "bin": { "semver": "bin/semver.js" } @@ -3324,7 +3321,7 @@ "version": "7.20.2", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.2.tgz", "integrity": "sha512-pNpr1T1xLUc2l3xJKuPtsEky3ybxN3m4fJkknfIpTCTfIZCDW57oAg+EfCgIIp2rvCe0Wn++/FfodDS4YXxBwA==", - "dev": true, + "devOptional": true, "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", @@ -3337,7 +3334,7 @@ "version": "7.6.5", "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.5.tgz", "integrity": "sha512-h9yIuWbJKdOPLJTbmSpPzkF67e659PbQDba7ifWm5BJ8xTv+sDmS7rFmywkWOvXedGTivCdeGSIIX8WLcRTz8w==", - "dev": true, + "devOptional": true, "dependencies": { "@babel/types": "^7.0.0" } @@ -3346,7 +3343,7 @@ "version": "7.4.2", "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.2.tgz", "integrity": "sha512-/AVzPICMhMOMYoSx9MoKpGDKdBRsIXMNByh1PXSZoa+v6ZoLa8xxtsT/uLQ/NJm0XVAWl/BvId4MlDeXJaeIZQ==", - "dev": true, + "devOptional": true, "dependencies": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" @@ -3356,7 +3353,7 @@ "version": "7.20.2", "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.2.tgz", "integrity": "sha512-ojlGK1Hsfce93J0+kn3H5R73elidKUaZonirN33GSmgTUMpzI/MIFfSpF3haANe3G1bEBS9/9/QEqwTzwqFsKw==", - "dev": true, + "devOptional": true, "dependencies": { "@babel/types": "^7.20.7" } diff --git a/package.json b/package.json index fab123170..ca6073835 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/generator", - "version": "1.13.1", + "version": "1.14.0", "description": "The AsyncAPI generator. It can generate documentation, code, anything!", "main": "./lib/generator.js", "bin": {