@asyncapi/generator 3.1.1 → 3.1.2
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/CHANGELOG.md +6 -0
- package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/README.md +1 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/README.md +1 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/CompileOperationSchemas.js +7 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/CompileOperationSchemas.js.map +1 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/client.js.js +7 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/client.js.js.map +1 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/CompileOperationSchemas.js +7 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
1. Navigate to `packages/templates/clients/kafka/java/quarkus`
|
|
27
27
|
2. Install with `npm install`
|
|
28
28
|
3. Navigate back to `./generator`
|
|
29
|
-
4. Generate the template client with `node .\apps\generator\cli.js <path-to-custom-document> .\packages\templates\clients\kafka\java\quarkus\ -o outputClient --force-write --param server=<custom-server>`
|
|
29
|
+
4. Generate the template client with `node .\apps\generator\test\cli.js <path-to-custom-document> .\packages\templates\clients\kafka\java\quarkus\ -o outputClient --force-write --param server=<custom-server>`
|
|
30
30
|
5. Navigate to `outputClient` or any other name you gave the output folder
|
|
31
31
|
6. Navigate to the docker folder with `cd src/main/docker` and find the `docker-compose.yaml` file.
|
|
32
32
|
7. Start the kafka broker by runnning `docker-compose up -d`. Make sure you have docker desktop up and running.
|
package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/README.md
CHANGED
|
@@ -75,7 +75,7 @@ You can use our AsyncAPI's credentials to access different set of events produce
|
|
|
75
75
|
2. Navigate to `packages/templates/clients/websocket/java/quarkus`
|
|
76
76
|
3. Install with `npm install`
|
|
77
77
|
4. Navigate back to `./generator`
|
|
78
|
-
5. Generate the template client with `node .\apps\generator\cli.js <path-to-custom-document> .\packages\templates\clients\websocket\java\quarkus\ -o outputClient --force-write --param server=<custom-server>`
|
|
78
|
+
5. Generate the template client with `node .\apps\generator\test\cli.js <path-to-custom-document> .\packages\templates\clients\websocket\java\quarkus\ -o outputClient --force-write --param server=<custom-server>`
|
|
79
79
|
6. Navigate to `outputClient` or any other name you gave the output folder
|
|
80
80
|
7. Run `mvn quarkus:dev`
|
|
81
81
|
8. See the output in the terminal
|
|
@@ -38,6 +38,13 @@ async compileOperationSchemas() {
|
|
|
38
38
|
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
|
|
39
39
|
} catch (error) {
|
|
40
40
|
console.error('Error initializing schemas:', error);
|
|
41
|
+
this.schemasCompiled = false;
|
|
42
|
+
if (error instanceof Error) {
|
|
43
|
+
error.message = \`Schema compilation failed: \${error.message}\`;
|
|
44
|
+
throw error;
|
|
45
|
+
} else {
|
|
46
|
+
throw new Error(\`Schema compilation failed: \${String(error)}\`);
|
|
47
|
+
}
|
|
41
48
|
}
|
|
42
49
|
}`
|
|
43
50
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompileOperationSchemas.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function CompileOperationSchemas({ sendOperations }) {\n if (!sendOperations || sendOperations.length === 0) {\n return null;\n } \n\n return (\n <>\n <Text indent={2} newLines={2}>\n {\n `/**\n * Initialize and compile all schemas for operations defined.\n * This should be called once after creating the client instance.\n * Subsequent calls will be ignored if schemas are already compiled.\n * \n * @returns {Promise<void>}\n * @throws {Error} If schema compilation fails for any operation\n */\nasync compileOperationSchemas() {\n if (this.schemasCompiled) {\n return;\n }\n\n try {\n // Compile schemas for all send operations\n for (const operationId of this.sendOperationsId) {\n this.compiledSchemas[operationId] = await compileSchemasByOperationId(asyncapiFilepath, operationId);\n }\n this.schemasCompiled = true;\n console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));\n } catch (error) {\n console.error('Error initializing schemas:', error);\n }\n}`\n }\n </Text>\n </>\n );\n}\n"],"names":["CompileOperationSchemas","sendOperations","length","_jsx","_Fragment","children","Text","indent","newLines"],"mappings":";;;;;;;;AAEO,SAASA,uBAAuBA,CAAC;AAAEC,EAAAA,cAAAA;AAAe,CAAC,EAAE;EAC1D,IAAI,CAACA,cAAc,IAAIA,cAAc,CAACC,MAAM,KAAK,CAAC,EAAE;AAClD,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;EAEA,oBACEC,cAAA,CAAAC,mBAAA,EAAA;IAAAC,QAAA,eACEF,cAAA,CAACG,sBAAI,EAAA;AAACC,MAAAA,MAAM,EAAE,CAAE;AAACC,MAAAA,QAAQ,EAAE,CAAE;AAAAH,MAAAA,QAAA,EAEzB,CAAA;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAA,CAAA;KAEY,CAAA;AAAC,GACP,CAAC,CAAA;AAEP;;;;"}
|
|
1
|
+
{"version":3,"file":"CompileOperationSchemas.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function CompileOperationSchemas({ sendOperations }) {\n if (!sendOperations || sendOperations.length === 0) {\n return null;\n } \n\n return (\n <>\n <Text indent={2} newLines={2}>\n {\n `/**\n * Initialize and compile all schemas for operations defined.\n * This should be called once after creating the client instance.\n * Subsequent calls will be ignored if schemas are already compiled.\n * \n * @returns {Promise<void>}\n * @throws {Error} If schema compilation fails for any operation\n */\nasync compileOperationSchemas() {\n if (this.schemasCompiled) {\n return;\n }\n\n try {\n // Compile schemas for all send operations\n for (const operationId of this.sendOperationsId) {\n this.compiledSchemas[operationId] = await compileSchemasByOperationId(asyncapiFilepath, operationId);\n }\n this.schemasCompiled = true;\n console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));\n } catch (error) {\n console.error('Error initializing schemas:', error);\n this.schemasCompiled = false;\n if (error instanceof Error) {\n error.message = \\`Schema compilation failed: \\${error.message}\\`;\n throw error;\n } else {\n throw new Error(\\`Schema compilation failed: \\${String(error)}\\`);\n }\n }\n}`\n }\n </Text>\n </>\n );\n}\n"],"names":["CompileOperationSchemas","sendOperations","length","_jsx","_Fragment","children","Text","indent","newLines"],"mappings":";;;;;;;;AAEO,SAASA,uBAAuBA,CAAC;AAAEC,EAAAA,cAAAA;AAAe,CAAC,EAAE;EAC1D,IAAI,CAACA,cAAc,IAAIA,cAAc,CAACC,MAAM,KAAK,CAAC,EAAE;AAClD,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;EAEA,oBACEC,cAAA,CAAAC,mBAAA,EAAA;IAAAC,QAAA,eACEF,cAAA,CAACG,sBAAI,EAAA;AAACC,MAAAA,MAAM,EAAE,CAAE;AAACC,MAAAA,QAAQ,EAAE,CAAE;AAAAH,MAAAA,QAAA,EAEzB,CAAA;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAA,CAAA;KAEY,CAAA;AAAC,GACP,CAAC,CAAA;AAEP;;;;"}
|
|
@@ -71,6 +71,13 @@ async compileOperationSchemas() {
|
|
|
71
71
|
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
|
|
72
72
|
} catch (error) {
|
|
73
73
|
console.error('Error initializing schemas:', error);
|
|
74
|
+
this.schemasCompiled = false;
|
|
75
|
+
if (error instanceof Error) {
|
|
76
|
+
error.message = \`Schema compilation failed: \${error.message}\`;
|
|
77
|
+
throw error;
|
|
78
|
+
} else {
|
|
79
|
+
throw new Error(\`Schema compilation failed: \${String(error)}\`);
|
|
80
|
+
}
|
|
74
81
|
}
|
|
75
82
|
}`
|
|
76
83
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/Constructor.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/ModuleExport.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/ClientClass.js","../../../../../../../../packages/templates/clients/websocket/javascript/template/client.js.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function Constructor({ serverUrl, sendOperations }) {\n const sendOperationsId = sendOperations.map((operation) => operation.id());\n const sendOperationsArray = JSON.stringify(sendOperationsId);\n\n return (\n <Text indent={2}>\n {\n `/*\n * Constructor to initialize the WebSocket client\n * @param {string} url - The WebSocket server URL. Use it if the server URL is different from the default one taken from the AsyncAPI document.\n*/\nconstructor(url) {\n this.url = url || '${serverUrl}';\n this.websocket = null;\n this.messageHandlers = [];\n this.errorHandlers = [];\n this.compiledSchemas = {};\n this.schemasCompiled = false;\n this.sendOperationsId = ${sendOperationsArray};\n}\n`\n }\n </Text>\n );\n}\n","import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function ModuleExport({ clientName }) {\n return (\n <Text>\n {\n `module.exports = ${clientName};`\n }\n </Text>\n );\n}\n","import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function CompileOperationSchemas({ sendOperations }) {\n if (!sendOperations || sendOperations.length === 0) {\n return null;\n } \n\n return (\n <>\n <Text indent={2} newLines={2}>\n {\n `/**\n * Initialize and compile all schemas for operations defined.\n * This should be called once after creating the client instance.\n * Subsequent calls will be ignored if schemas are already compiled.\n * \n * @returns {Promise<void>}\n * @throws {Error} If schema compilation fails for any operation\n */\nasync compileOperationSchemas() {\n if (this.schemasCompiled) {\n return;\n }\n\n try {\n // Compile schemas for all send operations\n for (const operationId of this.sendOperationsId) {\n this.compiledSchemas[operationId] = await compileSchemasByOperationId(asyncapiFilepath, operationId);\n }\n this.schemasCompiled = true;\n console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));\n } catch (error) {\n console.error('Error initializing schemas:', error);\n }\n}`\n }\n </Text>\n </>\n );\n}\n","import { Text } from '@asyncapi/generator-react-sdk';\nimport { Constructor } from './Constructor';\nimport { CloseConnection, RegisterMessageHandler, RegisterErrorHandler, SendOperations, Connect, HandleMessage } from '@asyncapi/generator-components';\nimport { ModuleExport } from './ModuleExport';\nimport { CompileOperationSchemas } from './CompileOperationSchemas';\n\nexport function ClientClass({ clientName, serverUrl, title, sendOperations }) {\n return (\n <Text>\n <Text newLines={2}>\n {`class ${clientName} {`}\n </Text>\n <Constructor serverUrl={serverUrl} sendOperations={sendOperations} />\n <Connect language=\"javascript\" title={title} />\n <RegisterMessageHandler \n language=\"javascript\" \n methodParams={['handler']}\n />\n <RegisterErrorHandler\n language=\"javascript\" \n methodParams={['handler']}\n />\n <HandleMessage \n language=\"javascript\" \n methodParams={['message', 'cb']}\n />\n <CompileOperationSchemas sendOperations={sendOperations} />\n <SendOperations \n language=\"javascript\" \n sendOperations={sendOperations} \n clientName={clientName} \n />\n <CloseConnection language=\"javascript\" />\n <Text>\n {'}'}\n </Text>\n <ModuleExport clientName={clientName} />\n </Text>\n );\n}\n","import { File } from '@asyncapi/generator-react-sdk';\nimport { getClientName, getServerUrl, getServer, getInfo, getTitle } from '@asyncapi/generator-helpers';\nimport { FileHeaderInfo, DependencyProvider } from '@asyncapi/generator-components';\nimport { ClientClass } from '../components/ClientClass';\n\nexport default function ({ asyncapi, params }) {\n const server = getServer(asyncapi.servers(), params.server);\n const info = getInfo(asyncapi);\n const title = getTitle(asyncapi);\n const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);\n const serverUrl = getServerUrl(server);\n const sendOperations = asyncapi.operations().filterBySend();\n const asyncapiFilepath = `${params.asyncapiFileDir}/asyncapi.yaml`;\n return (\n <File name={params.clientFileName}>\n <FileHeaderInfo\n info={info}\n server={server}\n language=\"javascript\"\n />\n <DependencyProvider\n language=\"javascript\"\n additionalDependencies={['const path = require(\\'path\\');', `const asyncapiFilepath = path.resolve(__dirname, '${asyncapiFilepath}');`]}\n />\n <ClientClass clientName={clientName} serverUrl={serverUrl} title={title} sendOperations={sendOperations} />\n </File>\n );\n}\n"],"names":["Constructor","serverUrl","sendOperations","sendOperationsId","map","operation","id","sendOperationsArray","JSON","stringify","_jsx","Text","indent","children","ModuleExport","clientName","CompileOperationSchemas","length","_Fragment","newLines","ClientClass","title","_jsxs","Connect","language","RegisterMessageHandler","methodParams","RegisterErrorHandler","HandleMessage","SendOperations","CloseConnection","asyncapi","params","server","getServer","servers","info","getInfo","getTitle","getClientName","appendClientSuffix","customClientName","getServerUrl","operations","filterBySend","asyncapiFilepath","asyncapiFileDir","File","name","clientFileName","FileHeaderInfo","DependencyProvider","additionalDependencies"],"mappings":";;;;;;;;AAEO,SAASA,WAAWA,CAAC;EAAEC,SAAS;AAAEC,EAAAA,cAAAA;AAAe,CAAC,EAAE;AACzD,EAAA,MAAMC,gBAAgB,GAAGD,cAAc,CAACE,GAAG,CAAEC,SAAS,IAAKA,SAAS,CAACC,EAAE,EAAE,CAAC,CAAA;AAC1E,EAAA,MAAMC,mBAAmB,GAAGC,IAAI,CAACC,SAAS,CAACN,gBAAgB,CAAC,CAAA;EAE5D,oBACEO,cAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,MAAM,EAAE,CAAE;AAAAC,IAAAA,QAAA,EAEZ,CAAA;AACR;AACA;AACA;AACA;AACA,qBAAA,EAAuBZ,SAAS,CAAA;AAChC;AACA;AACA;AACA;AACA;AACA,0BAAA,EAA4BM,mBAAmB,CAAA;AAC/C;AACA,CAAA;AAAC,GAES,CAAC,CAAA;AAEX;;ACxBO,SAASO,YAAYA,CAAC;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EAAA,MAAMhB,UAAU,GAAGwB,8BAAa,CAACR,QAAQ,EAAEC,MAAM,CAACQ,kBAAkB,EAAER,MAAM,CAACS,gBAAgB,CAAC,CAAA;AAC9F,EAAA,MAAMxC,SAAS,GAAGyC,6BAAY,CAACT,MAAM,CAAC,CAAA;EACtC,MAAM/B,cAAc,GAAG6B,QAAQ,CAACY,UAAU,EAAE,CAACC,YAAY,EAAE,CAAA;AAC3D,EAAA,MAAMC,gBAAgB,GAAG,CAAA,EAAGb,MAAM,CAACc,eAAe,CAAgB,cAAA,CAAA,CAAA;EAClE,oBACExB,eAAA,CAACyB,sBAAI,EAAA;IAACC,IAAI,EAAEhB,MAAM,CAACiB,cAAe;IAAApC,QAAA,EAAA,cAChCH,cAAA,CAACwC,kCAAc,EAAA;AACbd,MAAAA,IAAI,EAAEA,IAAK;AACXH,MAAAA,MAAM,EAAEA,MAAO;AACfT,MAAAA,QAAQ,EAAC,YAAA;AAAY,KACtB,CAAC,eACFd,cAAA,CAACyC,sCAAkB,EAAA;AACjB3B,MAAAA,QAAQ,EAAC,YAAY;AACrB4B,MAAAA,sBAAsB,EAAE,CAAC,iCAAiC,EAAE,CAAA,kDAAA,EAAqDP,gBAAgB,CAAK,GAAA,CAAA,CAAA;AAAE,KACzI,CAAC,eACFnC,cAAA,CAACU,WAAW,EAAA;AAACL,MAAAA,UAAU,EAAEA,UAAW;AAACd,MAAAA,SAAS,EAAEA,SAAU;AAACoB,MAAAA,KAAK,EAAEA,KAAM;AAACnB,MAAAA,cAAc,EAAEA,cAAAA;AAAe,KAAE,CAAC,CAAA;AAAA,GACvG,CAAC,CAAA;AAEX;;;;"}
|
|
1
|
+
{"version":3,"file":"client.js.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/Constructor.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/ModuleExport.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/CompileOperationSchemas.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/ClientClass.js","../../../../../../../../packages/templates/clients/websocket/javascript/template/client.js.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function Constructor({ serverUrl, sendOperations }) {\n const sendOperationsId = sendOperations.map((operation) => operation.id());\n const sendOperationsArray = JSON.stringify(sendOperationsId);\n\n return (\n <Text indent={2}>\n {\n `/*\n * Constructor to initialize the WebSocket client\n * @param {string} url - The WebSocket server URL. Use it if the server URL is different from the default one taken from the AsyncAPI document.\n*/\nconstructor(url) {\n this.url = url || '${serverUrl}';\n this.websocket = null;\n this.messageHandlers = [];\n this.errorHandlers = [];\n this.compiledSchemas = {};\n this.schemasCompiled = false;\n this.sendOperationsId = ${sendOperationsArray};\n}\n`\n }\n </Text>\n );\n}\n","import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function ModuleExport({ clientName }) {\n return (\n <Text>\n {\n `module.exports = ${clientName};`\n }\n </Text>\n );\n}\n","import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function CompileOperationSchemas({ sendOperations }) {\n if (!sendOperations || sendOperations.length === 0) {\n return null;\n } \n\n return (\n <>\n <Text indent={2} newLines={2}>\n {\n `/**\n * Initialize and compile all schemas for operations defined.\n * This should be called once after creating the client instance.\n * Subsequent calls will be ignored if schemas are already compiled.\n * \n * @returns {Promise<void>}\n * @throws {Error} If schema compilation fails for any operation\n */\nasync compileOperationSchemas() {\n if (this.schemasCompiled) {\n return;\n }\n\n try {\n // Compile schemas for all send operations\n for (const operationId of this.sendOperationsId) {\n this.compiledSchemas[operationId] = await compileSchemasByOperationId(asyncapiFilepath, operationId);\n }\n this.schemasCompiled = true;\n console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));\n } catch (error) {\n console.error('Error initializing schemas:', error);\n this.schemasCompiled = false;\n if (error instanceof Error) {\n error.message = \\`Schema compilation failed: \\${error.message}\\`;\n throw error;\n } else {\n throw new Error(\\`Schema compilation failed: \\${String(error)}\\`);\n }\n }\n}`\n }\n </Text>\n </>\n );\n}\n","import { Text } from '@asyncapi/generator-react-sdk';\nimport { Constructor } from './Constructor';\nimport { CloseConnection, RegisterMessageHandler, RegisterErrorHandler, SendOperations, Connect, HandleMessage } from '@asyncapi/generator-components';\nimport { ModuleExport } from './ModuleExport';\nimport { CompileOperationSchemas } from './CompileOperationSchemas';\n\nexport function ClientClass({ clientName, serverUrl, title, sendOperations }) {\n return (\n <Text>\n <Text newLines={2}>\n {`class ${clientName} {`}\n </Text>\n <Constructor serverUrl={serverUrl} sendOperations={sendOperations} />\n <Connect language=\"javascript\" title={title} />\n <RegisterMessageHandler \n language=\"javascript\" \n methodParams={['handler']}\n />\n <RegisterErrorHandler\n language=\"javascript\" \n methodParams={['handler']}\n />\n <HandleMessage \n language=\"javascript\" \n methodParams={['message', 'cb']}\n />\n <CompileOperationSchemas sendOperations={sendOperations} />\n <SendOperations \n language=\"javascript\" \n sendOperations={sendOperations} \n clientName={clientName} \n />\n <CloseConnection language=\"javascript\" />\n <Text>\n {'}'}\n </Text>\n <ModuleExport clientName={clientName} />\n </Text>\n );\n}\n","import { File } from '@asyncapi/generator-react-sdk';\nimport { getClientName, getServerUrl, getServer, getInfo, getTitle } from '@asyncapi/generator-helpers';\nimport { FileHeaderInfo, DependencyProvider } from '@asyncapi/generator-components';\nimport { ClientClass } from '../components/ClientClass';\n\nexport default function ({ asyncapi, params }) {\n const server = getServer(asyncapi.servers(), params.server);\n const info = getInfo(asyncapi);\n const title = getTitle(asyncapi);\n const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);\n const serverUrl = getServerUrl(server);\n const sendOperations = asyncapi.operations().filterBySend();\n const asyncapiFilepath = `${params.asyncapiFileDir}/asyncapi.yaml`;\n return (\n <File name={params.clientFileName}>\n <FileHeaderInfo\n info={info}\n server={server}\n language=\"javascript\"\n />\n <DependencyProvider\n language=\"javascript\"\n additionalDependencies={['const path = require(\\'path\\');', `const asyncapiFilepath = path.resolve(__dirname, '${asyncapiFilepath}');`]}\n />\n <ClientClass clientName={clientName} serverUrl={serverUrl} title={title} sendOperations={sendOperations} />\n </File>\n );\n}\n"],"names":["Constructor","serverUrl","sendOperations","sendOperationsId","map","operation","id","sendOperationsArray","JSON","stringify","_jsx","Text","indent","children","ModuleExport","clientName","CompileOperationSchemas","length","_Fragment","newLines","ClientClass","title","_jsxs","Connect","language","RegisterMessageHandler","methodParams","RegisterErrorHandler","HandleMessage","SendOperations","CloseConnection","asyncapi","params","server","getServer","servers","info","getInfo","getTitle","getClientName","appendClientSuffix","customClientName","getServerUrl","operations","filterBySend","asyncapiFilepath","asyncapiFileDir","File","name","clientFileName","FileHeaderInfo","DependencyProvider","additionalDependencies"],"mappings":";;;;;;;;AAEO,SAASA,WAAWA,CAAC;EAAEC,SAAS;AAAEC,EAAAA,cAAAA;AAAe,CAAC,EAAE;AACzD,EAAA,MAAMC,gBAAgB,GAAGD,cAAc,CAACE,GAAG,CAAEC,SAAS,IAAKA,SAAS,CAACC,EAAE,EAAE,CAAC,CAAA;AAC1E,EAAA,MAAMC,mBAAmB,GAAGC,IAAI,CAACC,SAAS,CAACN,gBAAgB,CAAC,CAAA;EAE5D,oBACEO,cAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,MAAM,EAAE,CAAE;AAAAC,IAAAA,QAAA,EAEZ,CAAA;AACR;AACA;AACA;AACA;AACA,qBAAA,EAAuBZ,SAAS,CAAA;AAChC;AACA;AACA;AACA;AACA;AACA,0BAAA,EAA4BM,mBAAmB,CAAA;AAC/C;AACA,CAAA;AAAC,GAES,CAAC,CAAA;AAEX;;ACxBO,SAASO,YAAYA,CAAC;AAAEC,EAAAA,UAAAA;AAAW,CAAC,EAAE;EAC3C,oBACEL,cAAA,CAACC,sBAAI,EAAA;IAAAE,QAAA,EAED,oBAAoBE,UAAU,CAAA,CAAA,CAAA;AAAG,GAE/B,CAAC,CAAA;AAEX;;ACRO,SAASC,uBAAuBA,CAAC;AAAEd,EAAAA,cAAAA;AAAe,CAAC,EAAE;EAC1D,IAAI,CAACA,cAAc,IAAI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AAU,EAAE,CAACC,YAAY,EAAE,CAAA;AAC3D,EAAA,MAAMC,gBAAgB,GAAG,CAAA,EAAGb,MAAM,CAACc,eAAe,CAAgB,cAAA,CAAA,CAAA;EAClE,oBACExB,eAAA,CAACyB,sBAAI,EAAA;IAACC,IAAI,EAAEhB,MAAM,CAACiB,cAAe;IAAApC,QAAA,EAAA,cAChCH,cAAA,CAACwC,kCAAc,EAAA;AACbd,MAAAA,IAAI,EAAEA,IAAK;AACXH,MAAAA,MAAM,EAAEA,MAAO;AACfT,MAAAA,QAAQ,EAAC,YAAA;AAAY,KACtB,CAAC,eACFd,cAAA,CAACyC,sCAAkB,EAAA;AACjB3B,MAAAA,QAAQ,EAAC,YAAY;AACrB4B,MAAAA,sBAAsB,EAAE,CAAC,iCAAiC,EAAE,CAAA,kDAAA,EAAqDP,gBAAgB,CAAK,GAAA,CAAA,CAAA;AAAE,KACzI,CAAC,eACFnC,cAAA,CAACU,WAAW,EAAA;AAACL,MAAAA,UAAU,EAAEA,UAAW;AAACd,MAAAA,SAAS,EAAEA,SAAU;AAACoB,MAAAA,KAAK,EAAEA,KAAM;AAACnB,MAAAA,cAAc,EAAEA,cAAAA;AAAe,KAAE,CAAC,CAAA;AAAA,GACvG,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -31,6 +31,13 @@ async compileOperationSchemas() {
|
|
|
31
31
|
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
|
|
32
32
|
} catch (error) {
|
|
33
33
|
console.error('Error initializing schemas:', error);
|
|
34
|
+
this.schemasCompiled = false;
|
|
35
|
+
if (error instanceof Error) {
|
|
36
|
+
error.message = \`Schema compilation failed: \${error.message}\`;
|
|
37
|
+
throw error;
|
|
38
|
+
} else {
|
|
39
|
+
throw new Error(\`Schema compilation failed: \${String(error)}\`);
|
|
40
|
+
}
|
|
34
41
|
}
|
|
35
42
|
}`
|
|
36
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asyncapi/generator",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "The AsyncAPI generator. It can generate documentation, code, anything!",
|
|
5
5
|
"main": "./lib/generator.js",
|
|
6
6
|
"engines": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@asyncapi/generator-hooks": "*",
|
|
54
54
|
"@asyncapi/generator-react-sdk": "*",
|
|
55
55
|
"@asyncapi/multi-parser": "^2.2.0",
|
|
56
|
-
"@asyncapi/parser": "^3.
|
|
56
|
+
"@asyncapi/parser": "^3.6.0",
|
|
57
57
|
"@npmcli/arborist": "5.6.3",
|
|
58
58
|
"@npmcli/config": "^8.0.2",
|
|
59
59
|
"ajv": "^8.12.0",
|