@powerlines/plugin-asyncapi 0.1.50 → 0.1.52
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/README.md +8 -2
- package/dist/index-BgAdqTbb.d.mts +1 -0
- package/dist/index-CEgs-Dz2.d.cts +1 -0
- package/dist/index.cjs +1 -7
- package/dist/index.d.cts +7 -27
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +15 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/plugin-BvfgqzoB.d.mts +1736 -0
- package/dist/plugin-BvfgqzoB.d.mts.map +1 -0
- package/dist/plugin-Bvn-he2n.mjs +1 -0
- package/dist/plugin-CWW0OtEe.d.cts +1736 -0
- package/dist/plugin-CWW0OtEe.d.cts.map +1 -0
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +3 -24
- package/dist/types/index.d.mts +3 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/plugin.cjs +1 -1
- package/dist/types/plugin.d.cts +2 -24
- package/dist/types/plugin.d.mts +2 -0
- package/dist/types/plugin.mjs +1 -0
- package/dist/types-B7VYa_Pp.mjs +1 -0
- package/dist/types-DHkg7xmX.cjs +0 -0
- package/package.json +44 -26
- package/dist/index-Dd20bHwO.d.cts +0 -1647
- package/dist/index-Dd20bHwO.d.ts +0 -1647
- package/dist/index.d.ts +0 -35
- package/dist/index.js +0 -7
- package/dist/types/index.d.ts +0 -24
- package/dist/types/index.js +0 -1
- package/dist/types/plugin.d.ts +0 -24
- /package/dist/{types/plugin.js → plugin-DHXHjv16.cjs} +0 -0
package/README.md
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
<!-- markdownlint-disable -->
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
<div align="center"
|
|
6
|
+
<div align="center">
|
|
7
|
+
<picture>
|
|
8
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/powerlines/banner-1280x640-dark-optimized.gif">
|
|
9
|
+
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/powerlines/banner-1280x640-light-optimized.gif">
|
|
10
|
+
<img src="https://public.storm-cdn.com/powerlines/banner-1280x640-dark-optimized.gif" width="100%" alt="Powerlines" />
|
|
11
|
+
</picture>
|
|
12
|
+
</div>
|
|
7
13
|
<br />
|
|
8
14
|
|
|
9
15
|
<div align="center">
|
|
@@ -16,7 +22,7 @@
|
|
|
16
22
|
</div>
|
|
17
23
|
|
|
18
24
|
<br />
|
|
19
|
-
This package is part of the
|
|
25
|
+
This package is part of the 🔌 <b>Powerlines</b> monorepo. Powerlines packages include CLI utility applications, tools, and various libraries used to create modern, scalable web applications.
|
|
20
26
|
<br />
|
|
21
27
|
|
|
22
28
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* ⚡ Built by Storm Software
|
|
4
|
-
*
|
|
5
|
-
*****************************************/
|
|
6
|
-
|
|
7
|
-
var s=Object.defineProperty;var n=(t,i)=>s(t,"name",{value:i,configurable:true});const f=n(t=>({name:"asyncapi",config(){return {asyncapi:p__default.default(t,{schema:join.joinPaths(this.workspaceConfig.workspaceRoot,this.config.projectRoot,"schema.yaml"),output:"string",install:false,compile:false,debug:this.config.mode==="development"||this.config.logLevel==="debug"||this.config.logLevel==="trace",targetDir:join.joinPaths(this.builtinsPath,"asyncapi")})}},async configResolved(){if(!this.config.asyncapi.schema)throw new Error('AsyncAPI schema is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.schema".');if(!this.config.asyncapi.document||!document.isAsyncAPIDocument(this.config.asyncapi.document))if(document.isAsyncAPIDocument(this.config.asyncapi.schema))this.config.asyncapi.document=this.config.asyncapi.schema;else if(exists.existsSync(this.config.asyncapi.schema.toString())){const i=await this.fs.read(this.config.asyncapi.schema.toString());if(!i)throw new Error(`Failed to read AsyncAPI schema from file: ${this.config.asyncapi.schema.toString()}`);this.config.asyncapi.document=i;}else {const i=await this.fetch(this.config.asyncapi.schema.toString());if(!i)throw new Error(`Failed to fetch AsyncAPI schema from endpoint: ${this.config.asyncapi.schema.toString()}`);this.config.asyncapi.document=await i.text();}if(!this.config.asyncapi.templateName)throw new Error('AsyncAPI template name is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.templateName".');if(!this.config.asyncapi.outputPath)throw new Error('AsyncAPI output path is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.outputPath".');!exists.existsSync(this.config.asyncapi.templateName)&&!packageFns.isPackageExists(this.config.asyncapi.templateName)&&(this.devDependencies[this.config.asyncapi.templateName]="latest"),this.config.asyncapi.outputPath=paths.replacePathTokens(this,this.config.asyncapi.outputPath);},async prepare(){await new generator.Generator(this.config.asyncapi.templateName,this.config.asyncapi.outputPath,this.config.asyncapi).generate(this.config.asyncapi.document);}}),"plugin");var S=f;exports.default=S;exports.plugin=f;Object.keys(types).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return types[k]}})});
|
|
1
|
+
Object.defineProperty(exports,`__esModule`,{value:!0});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));require(`./plugin-DHXHjv16.cjs`),require(`./types-DHkg7xmX.cjs`);let c=require(`@asyncapi/generator`),l=require(`@asyncapi/parser/esm/document`),u=require(`@stryke/fs/exists`),d=require(`@stryke/fs/package-fns`),f=require(`@stryke/path/join`),p=require(`defu`);p=s(p);let m=require(`@stryke/path/replace`);function h(e,t){return t&&t.replaceAll(`{workspaceRoot}`,e.workspaceConfig.workspaceRoot).replaceAll(`{root}`,e.config.projectRoot).replaceAll(`{projectRoot}`,e.config.projectRoot).replaceAll(`{sourceRoot}`,e.config.sourceRoot).replaceAll(`{powerlinesPath}`,e.powerlinesPath).replaceAll(`{cachePath}`,e.cachePath).replaceAll(`{dataPath}`,e.dataPath).replaceAll(`{logPath}`,e.envPaths.log).replaceAll(`{tempPath}`,e.envPaths.temp).replaceAll(`{configPath}`,e.envPaths.config).replaceAll(`{outputPath}`,e.config.output.outputPath).replaceAll(`{buildPath}`,e.config.output.buildPath).replaceAll(`{artifactsPath}`,(0,m.replacePath)(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,(0,m.replacePath)(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,(0,m.replacePath)(e.entryPath,e.workspaceConfig.workspaceRoot))}const g=e=>({name:`asyncapi`,config(){return{asyncapi:(0,p.default)(e,{schema:(0,f.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`schema.yaml`),output:`string`,install:!1,compile:!1,debug:this.config.mode===`development`||this.config.logLevel===`debug`||this.config.logLevel===`trace`,targetDir:(0,f.joinPaths)(this.builtinsPath,`asyncapi`)})}},async configResolved(){if(!this.config.asyncapi.schema)throw Error(`AsyncAPI schema is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.schema".`);if(!this.config.asyncapi.document||!(0,l.isAsyncAPIDocument)(this.config.asyncapi.document))if((0,l.isAsyncAPIDocument)(this.config.asyncapi.schema))this.config.asyncapi.document=this.config.asyncapi.schema;else if((0,u.existsSync)(this.config.asyncapi.schema.toString())){let e=await this.fs.read(this.config.asyncapi.schema.toString());if(!e)throw Error(`Failed to read AsyncAPI schema from file: ${this.config.asyncapi.schema.toString()}`);this.config.asyncapi.document=e}else{let e=await this.fetch(this.config.asyncapi.schema.toString());if(!e)throw Error(`Failed to fetch AsyncAPI schema from endpoint: ${this.config.asyncapi.schema.toString()}`);this.config.asyncapi.document=await e.text()}if(!this.config.asyncapi.templateName)throw Error(`AsyncAPI template name is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.templateName".`);if(!this.config.asyncapi.outputPath)throw Error(`AsyncAPI output path is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.outputPath".`);!(0,u.existsSync)(this.config.asyncapi.templateName)&&!(0,d.isPackageExists)(this.config.asyncapi.templateName)&&(this.devDependencies[this.config.asyncapi.templateName]=`latest`),this.config.asyncapi.outputPath=h(this,this.config.asyncapi.outputPath)},async prepare(){await new c.Generator(this.config.asyncapi.templateName,this.config.asyncapi.outputPath,this.config.asyncapi).generate(this.config.asyncapi.document)}});var _=g;exports.default=_,exports.plugin=g;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import '@storm-software/build-tools/types';
|
|
6
|
-
import '@storm-software/config-tools/types';
|
|
7
|
-
import '@storm-software/config/types';
|
|
8
|
-
import '@stryke/types/base';
|
|
9
|
-
import '@stryke/types/configuration';
|
|
10
|
-
import '@stryke/types/file';
|
|
11
|
-
import 'vite';
|
|
12
|
-
import '@stryke/env/get-env-paths';
|
|
13
|
-
import '@stryke/http/fetch';
|
|
14
|
-
import '@stryke/types/package-json';
|
|
15
|
-
import 'jiti';
|
|
16
|
-
import 'magic-string';
|
|
17
|
-
import 'oxc-parser';
|
|
18
|
-
import 'semver';
|
|
19
|
-
import 'ts-morph';
|
|
20
|
-
import 'undici';
|
|
21
|
-
import 'unplugin';
|
|
22
|
-
import '@stryke/fs/resolve';
|
|
23
|
-
import '@stryke/types/tsconfig';
|
|
24
|
-
import 'typescript';
|
|
25
|
-
import '@stryke/types/array';
|
|
1
|
+
import { a as __ΩAsyncAPIPluginContext, c as __ΩAsyncAPIPluginUserConfig, i as AsyncAPIPluginUserConfig, l as Plugin, n as AsyncAPIPluginOptions, o as __ΩAsyncAPIPluginOptions, r as AsyncAPIPluginResolvedConfig, s as __ΩAsyncAPIPluginResolvedConfig, t as AsyncAPIPluginContext } from "./plugin-CWW0OtEe.cjs";
|
|
2
|
+
import "./index-CEgs-Dz2.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
26
5
|
|
|
27
6
|
/**
|
|
28
7
|
* A Powerlines plugin to integrate AsyncAPI for code generation.
|
|
@@ -31,5 +10,6 @@ import '@stryke/types/array';
|
|
|
31
10
|
* @returns A Powerlines plugin instance.
|
|
32
11
|
*/
|
|
33
12
|
declare const plugin: <TContext extends AsyncAPIPluginContext = AsyncAPIPluginContext>(options: AsyncAPIPluginOptions) => Plugin<TContext>;
|
|
34
|
-
|
|
35
|
-
export { AsyncAPIPluginContext, AsyncAPIPluginOptions, plugin as default, plugin };
|
|
13
|
+
//#endregion
|
|
14
|
+
export { AsyncAPIPluginContext, AsyncAPIPluginOptions, AsyncAPIPluginResolvedConfig, AsyncAPIPluginUserConfig, __ΩAsyncAPIPluginContext, __ΩAsyncAPIPluginOptions, __ΩAsyncAPIPluginResolvedConfig, __ΩAsyncAPIPluginUserConfig, plugin as default, plugin };
|
|
15
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;AAoCA;;;;;AAIG,cAJU,MAIV,EAAA,CAAA,iBAHgB,qBAGhB,GAHwC,qBAGxC,CAAA,CAAA,OAAA,EADQ,qBACR,EAAA,GAAA,MAAA,CAAO,QAAP,CAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { a as __ΩAsyncAPIPluginContext, c as __ΩAsyncAPIPluginUserConfig, i as AsyncAPIPluginUserConfig, l as Plugin, n as AsyncAPIPluginOptions, o as __ΩAsyncAPIPluginOptions, r as AsyncAPIPluginResolvedConfig, s as __ΩAsyncAPIPluginResolvedConfig, t as AsyncAPIPluginContext } from "./plugin-BvfgqzoB.mjs";
|
|
2
|
+
import "./index-BgAdqTbb.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A Powerlines plugin to integrate AsyncAPI for code generation.
|
|
8
|
+
*
|
|
9
|
+
* @param options - The plugin options.
|
|
10
|
+
* @returns A Powerlines plugin instance.
|
|
11
|
+
*/
|
|
12
|
+
declare const plugin: <TContext extends AsyncAPIPluginContext = AsyncAPIPluginContext>(options: AsyncAPIPluginOptions) => Plugin<TContext>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { AsyncAPIPluginContext, AsyncAPIPluginOptions, AsyncAPIPluginResolvedConfig, AsyncAPIPluginUserConfig, __ΩAsyncAPIPluginContext, __ΩAsyncAPIPluginOptions, __ΩAsyncAPIPluginResolvedConfig, __ΩAsyncAPIPluginUserConfig, plugin as default, plugin };
|
|
15
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;AAoCA;;;;;AAIG,cAJU,MAIV,EAAA,CAAA,iBAHgB,qBAGhB,GAHwC,qBAGxC,CAAA,CAAA,OAAA,EADQ,qBACR,EAAA,GAAA,MAAA,CAAO,QAAP,CAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./plugin-Bvn-he2n.mjs";import"./types-B7VYa_Pp.mjs";import{Generator as e}from"@asyncapi/generator";import{isAsyncAPIDocument as t}from"@asyncapi/parser/esm/document";import{existsSync as n}from"@stryke/fs/exists";import{isPackageExists as r}from"@stryke/fs/package-fns";import{joinPaths as i}from"@stryke/path/join";import a from"defu";import{replacePath as o}from"@stryke/path/replace";function s(e,t){return t&&t.replaceAll(`{workspaceRoot}`,e.workspaceConfig.workspaceRoot).replaceAll(`{root}`,e.config.projectRoot).replaceAll(`{projectRoot}`,e.config.projectRoot).replaceAll(`{sourceRoot}`,e.config.sourceRoot).replaceAll(`{powerlinesPath}`,e.powerlinesPath).replaceAll(`{cachePath}`,e.cachePath).replaceAll(`{dataPath}`,e.dataPath).replaceAll(`{logPath}`,e.envPaths.log).replaceAll(`{tempPath}`,e.envPaths.temp).replaceAll(`{configPath}`,e.envPaths.config).replaceAll(`{outputPath}`,e.config.output.outputPath).replaceAll(`{buildPath}`,e.config.output.buildPath).replaceAll(`{artifactsPath}`,o(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,o(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,o(e.entryPath,e.workspaceConfig.workspaceRoot))}const c=o=>({name:`asyncapi`,config(){return{asyncapi:a(o,{schema:i(this.workspaceConfig.workspaceRoot,this.config.projectRoot,`schema.yaml`),output:`string`,install:!1,compile:!1,debug:this.config.mode===`development`||this.config.logLevel===`debug`||this.config.logLevel===`trace`,targetDir:i(this.builtinsPath,`asyncapi`)})}},async configResolved(){if(!this.config.asyncapi.schema)throw Error(`AsyncAPI schema is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.schema".`);if(!this.config.asyncapi.document||!t(this.config.asyncapi.document))if(t(this.config.asyncapi.schema))this.config.asyncapi.document=this.config.asyncapi.schema;else if(n(this.config.asyncapi.schema.toString())){let e=await this.fs.read(this.config.asyncapi.schema.toString());if(!e)throw Error(`Failed to read AsyncAPI schema from file: ${this.config.asyncapi.schema.toString()}`);this.config.asyncapi.document=e}else{let e=await this.fetch(this.config.asyncapi.schema.toString());if(!e)throw Error(`Failed to fetch AsyncAPI schema from endpoint: ${this.config.asyncapi.schema.toString()}`);this.config.asyncapi.document=await e.text()}if(!this.config.asyncapi.templateName)throw Error(`AsyncAPI template name is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.templateName".`);if(!this.config.asyncapi.outputPath)throw Error(`AsyncAPI output path is required. Please specify it in the plugin options or your Powerlines configuration under "asyncapi.outputPath".`);!n(this.config.asyncapi.templateName)&&!r(this.config.asyncapi.templateName)&&(this.devDependencies[this.config.asyncapi.templateName]=`latest`),this.config.asyncapi.outputPath=s(this,this.config.asyncapi.outputPath)},async prepare(){await new e(this.config.asyncapi.templateName,this.config.asyncapi.outputPath,this.config.asyncapi).generate(this.config.asyncapi.document)}});var l=c;export{l as default,c as plugin};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../powerlines/src/plugin-utils/paths.ts","../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { replacePath } from \"@stryke/path/replace\";\nimport { IsUndefined } from \"@stryke/types/base\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Replaces tokens in the given path string with their corresponding values from the context.\n *\n * @remarks\n * The following tokens are supported:\n * - `{workspaceRoot}` - The root directory of the workspace.\n * - `{root}` - The root directory of the project (same as `{projectRoot}`).\n * - `{projectRoot}` - The root directory of the project (same as `{root}`).\n * - `{sourceRoot}` - The source root directory of the project (usually `./src`).\n * - `{powerlinesPath}` - The directory where Powerlines is installed.\n * - `{cachePath}` - The environment's directory for cached files.\n * - `{dataPath}` - The environment's directory for data files.\n * - `{logPath}` - The environment's directory for log files.\n * - `{tempPath}` - The environment's directory for temporary files.\n * - `{configPath}` - The environment's directory for configuration files.\n * - `{outputPath}` - The configured output directory for the project.\n * - `{buildPath}` - The configured distribution directory for the project.\n * - `{artifactsPath}` - The configured directory for build artifacts.\n * - `{builtinPath}` - The configured directory for generated built-in plugins.\n * - `{entryPath}` - The configured directory for generated entry files.\n *\n * @param context - The context containing the values for the path tokens.\n * @param path - The path string with tokens to replace.\n * @returns The path string with tokens replaced by their corresponding values from the context.\n */\nexport function replacePathTokens(\n context: UnresolvedContext,\n path?: string\n): IsUndefined<typeof path> extends true ? undefined : string {\n if (!path) {\n return path as IsUndefined<typeof path> extends true ? undefined : string;\n }\n\n return path\n .replaceAll(\"{workspaceRoot}\", context.workspaceConfig.workspaceRoot)\n .replaceAll(\"{root}\", context.config.projectRoot)\n .replaceAll(\"{projectRoot}\", context.config.projectRoot)\n .replaceAll(\"{sourceRoot}\", context.config.sourceRoot)\n .replaceAll(\"{powerlinesPath}\", context.powerlinesPath)\n .replaceAll(\"{cachePath}\", context.cachePath)\n .replaceAll(\"{dataPath}\", context.dataPath)\n .replaceAll(\"{logPath}\", context.envPaths.log)\n .replaceAll(\"{tempPath}\", context.envPaths.temp)\n .replaceAll(\"{configPath}\", context.envPaths.config)\n .replaceAll(\"{outputPath}\", context.config.output.outputPath)\n .replaceAll(\"{buildPath}\", context.config.output.buildPath)\n .replaceAll(\n \"{artifactsPath}\",\n replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)\n )\n .replaceAll(\n \"{builtinPath}\",\n replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)\n )\n .replaceAll(\n \"{entryPath}\",\n replacePath(context.entryPath, context.workspaceConfig.workspaceRoot)\n );\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Generator } from \"@asyncapi/generator\";\nimport { isAsyncAPIDocument } from \"@asyncapi/parser/esm/document\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { isPackageExists } from \"@stryke/fs/package-fns\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport defu from \"defu\";\nimport { replacePathTokens } from \"powerlines/plugin-utils/paths\";\nimport { Plugin } from \"powerlines/types/plugin\";\nimport { AsyncAPIPluginContext, AsyncAPIPluginOptions } from \"./types/plugin\";\n\nexport * from \"./types\";\n\n/**\n * A Powerlines plugin to integrate AsyncAPI for code generation.\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends AsyncAPIPluginContext = AsyncAPIPluginContext\n>(\n options: AsyncAPIPluginOptions\n): Plugin<TContext> => {\n return {\n name: \"asyncapi\",\n config() {\n return {\n asyncapi: defu(options, {\n schema: joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot,\n \"schema.yaml\"\n ),\n output: \"string\",\n install: false,\n compile: false,\n debug:\n this.config.mode === \"development\" ||\n this.config.logLevel === \"debug\" ||\n this.config.logLevel === \"trace\",\n targetDir: joinPaths(this.builtinsPath, \"asyncapi\")\n })\n };\n },\n async configResolved() {\n if (!this.config.asyncapi.schema) {\n throw new Error(\n 'AsyncAPI schema is required. Please specify it in the plugin options or your Powerlines configuration under \"asyncapi.schema\".'\n );\n }\n\n if (\n !this.config.asyncapi.document ||\n !isAsyncAPIDocument(this.config.asyncapi.document)\n ) {\n if (isAsyncAPIDocument(this.config.asyncapi.schema)) {\n this.config.asyncapi.document = this.config.asyncapi.schema;\n } else if (existsSync(this.config.asyncapi.schema.toString())) {\n const document = await this.fs.read(\n this.config.asyncapi.schema.toString()\n );\n if (!document) {\n throw new Error(\n `Failed to read AsyncAPI schema from file: ${this.config.asyncapi.schema.toString()}`\n );\n }\n\n this.config.asyncapi.document = document;\n } else {\n const document = await this.fetch(\n this.config.asyncapi.schema.toString()\n );\n if (!document) {\n throw new Error(\n `Failed to fetch AsyncAPI schema from endpoint: ${this.config.asyncapi.schema.toString()}`\n );\n }\n\n this.config.asyncapi.document = await document.text();\n }\n }\n\n if (!this.config.asyncapi.templateName) {\n throw new Error(\n 'AsyncAPI template name is required. Please specify it in the plugin options or your Powerlines configuration under \"asyncapi.templateName\".'\n );\n }\n\n if (!this.config.asyncapi.outputPath) {\n throw new Error(\n 'AsyncAPI output path is required. Please specify it in the plugin options or your Powerlines configuration under \"asyncapi.outputPath\".'\n );\n }\n\n if (\n !existsSync(this.config.asyncapi.templateName) &&\n !isPackageExists(this.config.asyncapi.templateName)\n ) {\n this.devDependencies[this.config.asyncapi.templateName] = \"latest\";\n }\n\n this.config.asyncapi.outputPath = replacePathTokens(\n this,\n this.config.asyncapi.outputPath\n );\n },\n async prepare() {\n const generator = new Generator(\n this.config.asyncapi.templateName,\n this.config.asyncapi.outputPath,\n this.config.asyncapi\n );\n\n await generator.generate(this.config.asyncapi.document);\n }\n };\n};\n\nexport default plugin;\n"],"mappings":"2YA+CA,SAAgB,EACd,EACA,EAC4D,CAK5D,OAJK,GAIE,EACJ,WAAW,kBAAmB,EAAQ,gBAAgB,cAAc,CACpE,WAAW,SAAU,EAAQ,OAAO,YAAY,CAChD,WAAW,gBAAiB,EAAQ,OAAO,YAAY,CACvD,WAAW,eAAgB,EAAQ,OAAO,WAAW,CACrD,WAAW,mBAAoB,EAAQ,eAAe,CACtD,WAAW,cAAe,EAAQ,UAAU,CAC5C,WAAW,aAA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