@asyncapi/generator 2.11.0 → 3.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/docs/api.md +1 -1
  3. package/docs/asyncapi-document.md +1 -1
  4. package/docs/configuration-file.md +0 -4
  5. package/docs/file-templates.md +1 -59
  6. package/docs/generator-template-java.md +0 -2
  7. package/docs/generator-template.md +1 -4
  8. package/docs/index.md +2 -2
  9. package/docs/react-render-engine.md +5 -37
  10. package/docs/template-development.md +2 -7
  11. package/docs/template.md +2 -2
  12. package/docs/typescript-support.md +3 -5
  13. package/jest.config.js +1 -6
  14. package/lib/__mocks__/utils.js +0 -3
  15. package/lib/generator.js +4 -20
  16. package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/.ageneratorrc +0 -2
  17. package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/package.json +3 -3
  18. package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/.ageneratorrc +0 -1
  19. package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/package.json +3 -3
  20. package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/.ageneratorrc +0 -2
  21. package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/package.json +4 -4
  22. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/.ageneratorrc +0 -1
  23. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/README.md.js +5 -153
  24. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/README.md.js.map +1 -1
  25. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/package.json +4 -4
  26. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/template/README.md.js +2 -103
  27. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/.ageneratorrc +0 -1
  28. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/README.md.js +18 -0
  29. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/README.md.js.map +1 -0
  30. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/package.json +3 -3
  31. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/template/README.md.js +5 -0
  32. package/lib/templates/config/validator.js +3 -3
  33. package/lib/utils.js +0 -21
  34. package/package.json +5 -12
  35. package/Dockerfile +0 -20
  36. package/cli.js +0 -205
  37. package/docs/migration-cli.md +0 -70
  38. package/docs/migration-nunjucks-react.md +0 -144
  39. package/docs/nunjucks-render-engine.md +0 -83
  40. package/lib/filtersRegistry.js +0 -134
  41. package/lib/renderer/nunjucks.js +0 -42
  42. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/AvailableOperations.js +0 -34
  43. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/AvailableOperations.js.map +0 -1
  44. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/MessageExamples.js +0 -29
  45. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/MessageExamples.js.map +0 -1
  46. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/OperationHeader.js +0 -19
  47. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/OperationHeader.js.map +0 -1
  48. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/AvailableOperations.js +0 -20
  49. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/MessageExamples.js +0 -25
  50. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/OperationHeader.js +0 -12
  51. package/lib/watcher.js +0 -147
@@ -1,164 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  require('source-map-support/register');
4
- var generatorReactSdk = require('@asyncapi/generator-react-sdk');
5
- var generatorHelpers = require('@asyncapi/generator-helpers');
6
- var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
7
-
8
- function OperationHeader({
9
- operation
10
- }) {
11
- const operationId = operation.id();
12
- return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
13
- children: `#### \`${operationId}(payload)\`
14
- ${operation.hasSummary() ? operation.summary() : ''}
15
- ${operation.hasDescription() ? `\n${operation.description()}` : ''}`
16
- });
17
- }
18
-
19
- function MessageExamples({
20
- operation
21
- }) {
22
- const operationId = operation.id();
23
- const messageExamples = [];
24
- const messages = generatorHelpers.getOperationMessages(operation) || [];
25
- messages.forEach(message => {
26
- const examples = generatorHelpers.getMessageExamples(message) || [];
27
- examples.forEach(example => {
28
- const payload = example.payload();
29
- messageExamples.push(`\n\n**Example:**\n\`\`\`javascript\nclient.${operationId}(${JSON.stringify(payload, null, 2)});\n\`\`\``);
30
- });
31
- });
32
- return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
33
- children: messageExamples.map(example => /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
34
- children: example
35
- }))
36
- });
37
- }
38
-
39
- function AvailableOperations({
40
- operations
41
- }) {
42
- if (!operations || operations.length === 0) {
43
- return null;
44
- }
45
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
46
- children: [/*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
47
- newLines: 2,
48
- children: "### Available Operations"
49
- }), operations.map(operation => /*#__PURE__*/jsxRuntime.jsxs(generatorReactSdk.Text, {
50
- newLines: 2,
51
- children: [/*#__PURE__*/jsxRuntime.jsx(OperationHeader, {
52
- operation: operation
53
- }), /*#__PURE__*/jsxRuntime.jsx(MessageExamples, {
54
- operation: operation
55
- })]
56
- }))]
57
- });
58
- }
4
+ var generatorComponents = require('@asyncapi/generator-components');
59
5
 
60
6
  function README_md ({
61
7
  asyncapi,
62
8
  params
63
9
  }) {
64
- const server = generatorHelpers.getServer(asyncapi.servers(), params.server);
65
- const info = generatorHelpers.getInfo(asyncapi);
66
- const clientName = generatorHelpers.getClientName(asyncapi, params.appendClientSuffix, params.customClientName);
67
- const title = generatorHelpers.getTitle(asyncapi);
68
- const serverUrl = generatorHelpers.getServerUrl(server);
69
- const operations = asyncapi.operations().all();
70
- return /*#__PURE__*/jsxRuntime.jsxs(generatorReactSdk.File, {
71
- name: "README.md",
72
- children: [/*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
73
- newLines: 2,
74
- children: `# ${title}
75
-
76
- ## Overview
77
-
78
- ${info.description() || `A WebSocket client for ${title}.`}
79
-
80
- - **Version:** ${info.version()}
81
- - **URL:** ${serverUrl}
82
-
83
-
84
- ## Client API Reference
85
-
86
- \`\`\`javascript
87
- const ${clientName} = require('./${params.clientFileName.replace('.js', '')}');
88
- const wsClient = new ${clientName}();
89
- \`\`\`
90
-
91
- Here the wsClient is an instance of the \`${clientName}\` class.
92
- ### Core Methods
93
-
94
- #### \`connect()\`
95
- Establishes a WebSocket connection to the server.
96
-
97
- #### \`registerMessageHandler(handlerFunction)\`
98
- Registers a callback to handle incoming messages.
99
- - **Parameter:** \`handlerFunction\` - This Function takes a parameter \`message\` which is a string.
100
-
101
- #### \`registerErrorHandler(handlerFunction)\`
102
- Registers a callback to handle WebSocket errors.
103
- - **Parameter:** \`handlerFunction\` - This Function takes a parameter \`error\` which is an object
104
-
105
- #### \`close()\`
106
- Closes the WebSocket connection.`
107
- }), /*#__PURE__*/jsxRuntime.jsx(AvailableOperations, {
108
- operations: operations
109
- }), /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
110
- newLines: 2,
111
- children: `## Testing the client
112
-
113
- \`\`\`javascript
114
- const ${clientName} = require('./${params.clientFileName.replace('.js', '')}');
115
- const wsClient = new ${clientName}();
116
-
117
-
118
- // Example of how custom message handler that operates on incoming messages can look like
119
-
120
- function myHandler(message) {
121
- console.log('====================');
122
- console.log('Just proving I got the message in myHandler:', message);
123
- console.log('====================');
124
- }
125
-
126
- // Example of custom error handler
127
-
128
- function myErrorHandler(error) {
129
- console.error('Errors from Websocket:', error.message);
130
- }
131
-
132
- async function main() {
133
- wsClient.registerMessageHandler(myHandler);
134
- wsClient.registerErrorHandler(myErrorHandler);
135
-
136
- try {
137
- await wsClient.connect();
138
-
139
- // Loop to send messages every 5 seconds
140
- const interval = 5000; // 5 seconds
141
- const message = 'Hello, Echo!';
142
-
143
- while (true) {
144
- try {
145
- await wsClient.sendEchoMessage(message);
146
- } catch (error) {
147
- console.error('Error while sending message:', error);
148
- }
149
- // Wait for the interval before sending the next message
150
- await new Promise(resolve => setTimeout(resolve, interval));
151
- }
152
- } catch (error) {
153
- console.error('Failed to connect to WebSocket:', error.message);
154
- }
155
- }
156
-
157
- main();
158
- \`\`\`
159
-
160
- `
161
- })]
10
+ return generatorComponents.Readme({
11
+ asyncapi,
12
+ params,
13
+ language: 'javascript'
162
14
  });
163
15
  }
164
16
 
@@ -1 +1 @@
1
- {"version":3,"file":"README.md.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/OperationHeader.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/MessageExamples.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/AvailableOperations.js","../../../../../../../../packages/templates/clients/websocket/javascript/template/README.md.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport default function OperationHeader({operation}) {\n const operationId = operation.id();\n return (\n <Text>\n {`#### \\`${operationId}(payload)\\`\n${operation.hasSummary() ? operation.summary() : ''}\n${operation.hasDescription() ? `\\n${operation.description()}` : ''}`}\n </Text>\n );\n}","import { getMessageExamples, getOperationMessages } from '@asyncapi/generator-helpers';\nimport { Text } from '@asyncapi/generator-react-sdk';\n\nexport default function MessageExamples({operation}) {\n const operationId = operation.id();\n const messageExamples = [];\n const messages = getOperationMessages(operation) || [];\n\n messages.forEach((message) => {\n const examples = getMessageExamples(message) || [];\n examples.forEach((example) => {\n const payload = example.payload();\n messageExamples.push(`\\n\\n**Example:**\\n\\`\\`\\`javascript\\nclient.${operationId}(${JSON.stringify(payload, null, 2)});\\n\\`\\`\\``);\n });\n });\n return (\n <Text>\n {messageExamples.map(example => (\n <Text>\n {example}\n </Text>\n ))}\n </Text>\n );\n}","import { Text } from '@asyncapi/generator-react-sdk';\nimport OperationHeader from './OperationHeader';\nimport MessageExamples from './MessageExamples';\n\nexport function AvailableOperations({ operations }) {\n if (!operations || operations.length === 0) {\n return null;\n }\n return (\n <>\n <Text newLines={2}>### Available Operations</Text>\n {operations.map((operation) => (\n <Text newLines={2}>\n <OperationHeader operation={operation} />\n <MessageExamples operation={operation} />\n </Text>\n ))}\n </>\n );\n}\n","import { File, Text } from '@asyncapi/generator-react-sdk';\nimport { getClientName, getServer, getServerUrl, getInfo, getTitle } from '@asyncapi/generator-helpers';\nimport { AvailableOperations } from '../components/AvailableOperations';\n\nexport default function({ asyncapi, params }) {\n const server = getServer(asyncapi.servers(), params.server);\n const info = getInfo(asyncapi);\n const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);\n const title = getTitle(asyncapi);\n const serverUrl = getServerUrl(server);\n\n const operations = asyncapi.operations().all();\n \n return (\n <File name=\"README.md\">\n <Text newLines={2}>\n {`# ${title} \n\n## Overview\n\n${info.description() || `A WebSocket client for ${title}.`}\n\n- **Version:** ${info.version()}\n- **URL:** ${serverUrl}\n\n\n## Client API Reference\n\n\\`\\`\\`javascript\nconst ${clientName} = require('./${params.clientFileName.replace('.js', '')}');\nconst wsClient = new ${clientName}();\n\\`\\`\\`\n\nHere the wsClient is an instance of the \\`${clientName}\\` class.\n### Core Methods\n\n#### \\`connect()\\`\nEstablishes a WebSocket connection to the server.\n\n#### \\`registerMessageHandler(handlerFunction)\\`\nRegisters a callback to handle incoming messages.\n- **Parameter:** \\`handlerFunction\\` - This Function takes a parameter \\`message\\` which is a string. \n\n#### \\`registerErrorHandler(handlerFunction)\\`\nRegisters a callback to handle WebSocket errors.\n- **Parameter:** \\`handlerFunction\\` - This Function takes a parameter \\`error\\` which is an object\n\n#### \\`close()\\`\nCloses the WebSocket connection.`}\n </Text>\n <AvailableOperations operations={operations} />\n <Text newLines={2}>\n {`## Testing the client\n\n\\`\\`\\`javascript\nconst ${clientName} = require('./${params.clientFileName.replace('.js', '')}');\nconst wsClient = new ${clientName}();\n\n\n// Example of how custom message handler that operates on incoming messages can look like\n\nfunction myHandler(message) {\n console.log('====================');\n console.log('Just proving I got the message in myHandler:', message);\n console.log('===================='); \n}\n\n// Example of custom error handler\n\nfunction myErrorHandler(error) {\n console.error('Errors from Websocket:', error.message);\n}\n\nasync function main() {\n wsClient.registerMessageHandler(myHandler);\n wsClient.registerErrorHandler(myErrorHandler);\n\n try {\n await wsClient.connect();\n\n // Loop to send messages every 5 seconds\n const interval = 5000; // 5 seconds\n const message = 'Hello, Echo!';\n\n while (true) {\n try {\n await wsClient.sendEchoMessage(message);\n } catch (error) {\n console.error('Error while sending message:', error);\n }\n // Wait for the interval before sending the next message\n await new Promise(resolve => setTimeout(resolve, interval));\n }\n } catch (error) {\n console.error('Failed to connect to WebSocket:', error.message);\n }\n}\n\nmain();\n\\`\\`\\`\n\n`}\n </Text>\n </File>\n );\n}"],"names":["OperationHeader","operation","operationId","id","_jsx","Text","children","hasSummary","summary","hasDescription","description","MessageExamples","messageExamples","messages","getOperationMessages","forEach","message","examples","getMessageExamples","example","payload","push","JSON","stringify","map","AvailableOperations","operations","length","_jsxs","_Fragment","newLines","asyncapi","params","server","getServer","servers","info","getInfo","clientName","getClientName","appendClientSuffix","customClientName","title","getTitle","serverUrl","getServerUrl","all","File","name","version","clientFileName","replace"],"mappings":";;;;;;;AAEe,SAASA,eAAeA,CAAC;AAACC,EAAAA,SAAAA;AAAS,CAAC,EAAE;AACnD,EAAA,MAAMC,WAAW,GAAGD,SAAS,CAACE,EAAE,EAAE,CAAA;EAClC,oBACEC,cAAA,CAACC,sBAAI,EAAA;IAAAC,QAAA,EACF,UAAUJ,WAAW,CAAA;AAC5B,EAAED,SAAS,CAACM,UAAU,EAAE,GAAIN,SAAS,CAACO,OAAO,EAAE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CAAA;AAAA,GACH,CAAC,CAAA;AAEX;;;;"}
1
+ {"version":3,"file":"README.md.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/template/README.md.js"],"sourcesContent":["import { Readme } from '@asyncapi/generator-components';\n\nexport default function({ asyncapi, params }) {\n return Readme({asyncapi, params, language: 'javascript'}); \n}"],"names":["asyncapi","params","Readme","language"],"mappings":";;;;;AAEe,kBAAS,EAAA;EAAEA,QAAQ;AAAEC,EAAAA,MAAAA;AAAO,CAAC,EAAE;AAC5C,EAAA,OAAOC,0BAAM,CAAC;IAACF,QAAQ;IAAEC,MAAM;AAAEE,IAAAA,QAAQ,EAAE,YAAA;AAAY,GAAC,CAAC,CAAA;AAC3D;;;;"}
@@ -3,7 +3,7 @@
3
3
  "private": true,
4
4
  "description": "This is a template generating JavaScript websocket client",
5
5
  "scripts": {
6
- "test": "jest --coverage",
6
+ "test": "jest --coverage --passWithNoTests",
7
7
  "test:update": "npm run test -- -u",
8
8
  "lint": "eslint --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore .",
9
9
  "lint:fix": "eslint --fix --max-warnings 0 --config ../../../../../.eslintrc --ignore-path ../../../../../.eslintignore ."
@@ -11,13 +11,13 @@
11
11
  "author": "Lukasz Gornicki <lpgornicki@gmail.com>",
12
12
  "license": "Apache-2.0",
13
13
  "dependencies": {
14
- "@asyncapi/generator-helpers": "0.2.0",
14
+ "@asyncapi/generator-helpers": "1.0.0",
15
15
  "@asyncapi/generator-react-sdk": "*",
16
- "@asyncapi/generator-components": "0.3.1",
16
+ "@asyncapi/generator-components": "0.4.0",
17
17
  "@asyncapi/keeper": "0.5.0"
18
18
  },
19
19
  "devDependencies": {
20
- "@asyncapi/parser": "^3.0.14",
20
+ "@asyncapi/parser": "^3.4.0",
21
21
  "@babel/cli": "^7.25.9",
22
22
  "@babel/core": "^7.26.0",
23
23
  "@babel/preset-env": "^7.26.0",
@@ -1,106 +1,5 @@
1
- import { File, Text } from '@asyncapi/generator-react-sdk';
2
- import { getClientName, getServer, getServerUrl, getInfo, getTitle } from '@asyncapi/generator-helpers';
3
- import { AvailableOperations } from '../components/AvailableOperations';
1
+ import { Readme } from '@asyncapi/generator-components';
4
2
 
5
3
  export default function({ asyncapi, params }) {
6
- const server = getServer(asyncapi.servers(), params.server);
7
- const info = getInfo(asyncapi);
8
- const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);
9
- const title = getTitle(asyncapi);
10
- const serverUrl = getServerUrl(server);
11
-
12
- const operations = asyncapi.operations().all();
13
-
14
- return (
15
- <File name="README.md">
16
- <Text newLines={2}>
17
- {`# ${title}
18
-
19
- ## Overview
20
-
21
- ${info.description() || `A WebSocket client for ${title}.`}
22
-
23
- - **Version:** ${info.version()}
24
- - **URL:** ${serverUrl}
25
-
26
-
27
- ## Client API Reference
28
-
29
- \`\`\`javascript
30
- const ${clientName} = require('./${params.clientFileName.replace('.js', '')}');
31
- const wsClient = new ${clientName}();
32
- \`\`\`
33
-
34
- Here the wsClient is an instance of the \`${clientName}\` class.
35
- ### Core Methods
36
-
37
- #### \`connect()\`
38
- Establishes a WebSocket connection to the server.
39
-
40
- #### \`registerMessageHandler(handlerFunction)\`
41
- Registers a callback to handle incoming messages.
42
- - **Parameter:** \`handlerFunction\` - This Function takes a parameter \`message\` which is a string.
43
-
44
- #### \`registerErrorHandler(handlerFunction)\`
45
- Registers a callback to handle WebSocket errors.
46
- - **Parameter:** \`handlerFunction\` - This Function takes a parameter \`error\` which is an object
47
-
48
- #### \`close()\`
49
- Closes the WebSocket connection.`}
50
- </Text>
51
- <AvailableOperations operations={operations} />
52
- <Text newLines={2}>
53
- {`## Testing the client
54
-
55
- \`\`\`javascript
56
- const ${clientName} = require('./${params.clientFileName.replace('.js', '')}');
57
- const wsClient = new ${clientName}();
58
-
59
-
60
- // Example of how custom message handler that operates on incoming messages can look like
61
-
62
- function myHandler(message) {
63
- console.log('====================');
64
- console.log('Just proving I got the message in myHandler:', message);
65
- console.log('====================');
66
- }
67
-
68
- // Example of custom error handler
69
-
70
- function myErrorHandler(error) {
71
- console.error('Errors from Websocket:', error.message);
72
- }
73
-
74
- async function main() {
75
- wsClient.registerMessageHandler(myHandler);
76
- wsClient.registerErrorHandler(myErrorHandler);
77
-
78
- try {
79
- await wsClient.connect();
80
-
81
- // Loop to send messages every 5 seconds
82
- const interval = 5000; // 5 seconds
83
- const message = 'Hello, Echo!';
84
-
85
- while (true) {
86
- try {
87
- await wsClient.sendEchoMessage(message);
88
- } catch (error) {
89
- console.error('Error while sending message:', error);
90
- }
91
- // Wait for the interval before sending the next message
92
- await new Promise(resolve => setTimeout(resolve, interval));
93
- }
94
- } catch (error) {
95
- console.error('Failed to connect to WebSocket:', error.message);
96
- }
97
- }
98
-
99
- main();
100
- \`\`\`
101
-
102
- `}
103
- </Text>
104
- </File>
105
- );
4
+ return Readme({asyncapi, params, language: 'javascript'});
106
5
  }
@@ -1,4 +1,3 @@
1
- renderer: react
2
1
  apiVersion: v3
3
2
  parameters:
4
3
  server:
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ require('source-map-support/register');
4
+ var generatorComponents = require('@asyncapi/generator-components');
5
+
6
+ function README_md ({
7
+ asyncapi,
8
+ params
9
+ }) {
10
+ return generatorComponents.Readme({
11
+ asyncapi,
12
+ params,
13
+ language: 'python'
14
+ });
15
+ }
16
+
17
+ module.exports = README_md;
18
+ //# sourceMappingURL=README.md.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"README.md.js","sources":["../../../../../../../../packages/templates/clients/websocket/python/template/README.md.js"],"sourcesContent":["import { Readme } from '@asyncapi/generator-components';\n\nexport default function({ asyncapi, params }) {\n return Readme({asyncapi, params, language: 'python'}); \n}"],"names":["asyncapi","params","Readme","language"],"mappings":";;;;;AAEe,kBAAS,EAAA;EAAEA,QAAQ;AAAEC,EAAAA,MAAAA;AAAO,CAAC,EAAE;AAC5C,EAAA,OAAOC,0BAAM,CAAC;IAACF,QAAQ;IAAEC,MAAM;AAAEE,IAAAA,QAAQ,EAAE,QAAA;AAAQ,GAAC,CAAC,CAAA;AACvD;;;;"}
@@ -12,11 +12,11 @@
12
12
  "license": "Apache-2.0",
13
13
  "dependencies": {
14
14
  "@asyncapi/generator-react-sdk": "*",
15
- "@asyncapi/generator-helpers": "0.2.0",
16
- "@asyncapi/generator-components": "0.3.1"
15
+ "@asyncapi/generator-helpers": "1.0.0",
16
+ "@asyncapi/generator-components": "0.4.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@asyncapi/parser": "^3.0.14",
19
+ "@asyncapi/parser": "^3.4.0",
20
20
  "@babel/cli": "^7.25.9",
21
21
  "@babel/core": "^7.26.0",
22
22
  "@babel/preset-env": "^7.26.0",
@@ -0,0 +1,5 @@
1
+ import { Readme } from '@asyncapi/generator-components';
2
+
3
+ export default function({ asyncapi, params }) {
4
+ return Readme({asyncapi, params, language: 'python'});
5
+ }
@@ -130,17 +130,17 @@ function isServerProtocolSupported(server, supportedProtocols, paramsServerName)
130
130
  }
131
131
 
132
132
  /**
133
- * Checks if the the provided renderer are supported (no renderer are also supported, defaults to nunjucks)
133
+ * Checks if the provided renderer is supported (no renderer is also supported, defaults to react)
134
134
  *
135
135
  * @param {Object} templateConfig Template configuration.
136
136
  */
137
137
  function isProvidedTemplateRendererSupported(templateConfig) {
138
- const supportedRenderers = [undefined, 'react', 'nunjucks'];
138
+ const supportedRenderers = [undefined, 'react'];
139
139
  if (supportedRenderers.includes(templateConfig.renderer)) {
140
140
  return;
141
141
  }
142
142
 
143
- throw new Error(`We do not support '${templateConfig.renderer}' as a renderer for a template. Only 'react' or 'nunjucks' are supported.`);
143
+ throw new Error(`We do not support '${templateConfig.renderer}' as a renderer for a template. Only 'react' is supported.`);
144
144
  }
145
145
 
146
146
  /**
package/lib/utils.js CHANGED
@@ -59,27 +59,6 @@ utils.convertMapToObject = (map) => {
59
59
  return tempObject;
60
60
  };
61
61
 
62
- /**
63
- * Checks if template is local or not (i.e., it's remote).
64
- * @private
65
- * @param {String} templatePath The path to the template.
66
- * @returns {Promise<Boolean>}
67
- */
68
- utils.isLocalTemplate = async (templatePath) => {
69
- const stats = await utils.lstat(templatePath);
70
- return stats.isSymbolicLink();
71
- };
72
-
73
- /**
74
- * Returns whether or not the template is a react template
75
- *
76
- * @param {object} templateConfig
77
- * @returns {boolean} Whether the template is a React template or not.
78
- */
79
- utils.isReactTemplate = (templateConfig) => {
80
- return templateConfig !== undefined && templateConfig.renderer === 'react';
81
- };
82
-
83
62
  /**
84
63
  * Fetches an AsyncAPI document from the given URL and return its content as string
85
64
  *
package/package.json CHANGED
@@ -1,15 +1,11 @@
1
1
  {
2
2
  "name": "@asyncapi/generator",
3
- "version": "2.11.0",
3
+ "version": "3.0.0",
4
4
  "description": "The AsyncAPI generator. It can generate documentation, code, anything!",
5
5
  "main": "./lib/generator.js",
6
- "bin": {
7
- "asyncapi-generator": "./cli.js",
8
- "ag": "./cli.js"
9
- },
10
6
  "engines": {
11
- "node": ">=18.12.0",
12
- "npm": ">=8.19.0"
7
+ "node": ">=24.11",
8
+ "npm": ">=11.5.1"
13
9
  },
14
10
  "scripts": {
15
11
  "test": "npm run test:unit && npm run test:integration",
@@ -56,13 +52,11 @@
56
52
  "@asyncapi/generator-helpers": "*",
57
53
  "@asyncapi/generator-hooks": "*",
58
54
  "@asyncapi/generator-react-sdk": "*",
59
- "@asyncapi/multi-parser": "^2.1.1",
60
- "@asyncapi/nunjucks-filters": "*",
61
- "@asyncapi/parser": "^3.0.14",
55
+ "@asyncapi/multi-parser": "^2.2.0",
56
+ "@asyncapi/parser": "^3.4.0",
62
57
  "@npmcli/arborist": "5.6.3",
63
58
  "@npmcli/config": "^8.0.2",
64
59
  "ajv": "^8.12.0",
65
- "chokidar": "^3.4.0",
66
60
  "commander": "^6.1.0",
67
61
  "filenamify": "^4.1.0",
68
62
  "fs.extra": "^1.3.2",
@@ -73,7 +67,6 @@
73
67
  "loglevel": "^1.6.8",
74
68
  "minimatch": "^3.0.4",
75
69
  "node-fetch": "^2.6.0",
76
- "nunjucks": "^3.2.0",
77
70
  "requireg": "^0.2.2",
78
71
  "resolve-from": "^5.0.0",
79
72
  "resolve-pkg": "^2.0.0",
package/Dockerfile DELETED
@@ -1,20 +0,0 @@
1
- FROM node:18-alpine
2
-
3
- ARG ASYNCAPI_GENERATOR_VERSION=1.10.9
4
-
5
- WORKDIR /app
6
-
7
- # Since 0.14.0 release of html-template chromium is needed for pdf generation
8
- ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
9
- ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
10
-
11
- # Since 0.30.0 release Git is supported and required as a dependency
12
- # Since 0.14.0 release of html-template chromium is needed for pdf generation.
13
- # More custom packages for specific template should not be added to this dockerfile. Instead, we should come up with some extensibility solution.
14
- # Installing latest released npm package
15
- RUN apk --update add git chromium && \
16
- rm /var/cache/apk/* && \
17
- npm install --ignore-scripts -g "@asyncapi/generator@${ASYNCAPI_GENERATOR_VERSION}"
18
-
19
-
20
- ENTRYPOINT [ "ag" ]