@asyncapi/generator 2.8.4 → 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 (82) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/docs/api.md +2 -51
  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/jsdoc2md-handlebars/main-index/global-index/global-index-dl.hbs +13 -0
  10. package/docs/jsdoc2md-handlebars/member-index-grouped.hbs +6 -0
  11. package/docs/jsdoc2md-handlebars/member-index-list.hbs +6 -0
  12. package/docs/jsdoc2md-handlebars/members.hbs +1 -0
  13. package/docs/react-render-engine.md +5 -37
  14. package/docs/template-development.md +2 -7
  15. package/docs/template.md +2 -2
  16. package/docs/typescript-support.md +3 -5
  17. package/jest.config.js +3 -6
  18. package/lib/__mocks__/utils.js +0 -3
  19. package/lib/generator.js +4 -20
  20. package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/.ageneratorrc +2 -4
  21. package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/__transpiled/jest.config.js +13 -0
  22. package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/__transpiled/jest.config.js.map +1 -0
  23. package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/jest.config.js +14 -0
  24. package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/package.json +3 -17
  25. package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/.ageneratorrc +0 -1
  26. package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/jest.config.js +13 -0
  27. package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/jest.config.js.map +1 -0
  28. package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/jest.config.js +14 -0
  29. package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/package.json +3 -17
  30. package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/.ageneratorrc +0 -2
  31. package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/jest.config.js +13 -0
  32. package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/jest.config.js.map +1 -0
  33. package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/jest.config.js +14 -0
  34. package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/package.json +4 -18
  35. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/.ageneratorrc +8 -1
  36. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ClientClass.js +5 -1
  37. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ClientClass.js.map +1 -1
  38. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/CompileOperationSchemas.js +48 -0
  39. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/CompileOperationSchemas.js.map +1 -0
  40. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Constructor.js +7 -1
  41. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Constructor.js.map +1 -1
  42. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/jest.config.js +13 -0
  43. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/jest.config.js.map +1 -0
  44. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/README.md.js +5 -153
  45. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/README.md.js.map +1 -1
  46. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/client.js.js +52 -3
  47. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/client.js.js.map +1 -1
  48. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/ClientClass.js +4 -2
  49. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/CompileOperationSchemas.js +40 -0
  50. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/Constructor.js +7 -1
  51. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/jest.config.js +14 -0
  52. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/package.json +7 -20
  53. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/template/README.md.js +2 -103
  54. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/template/client.js.js +5 -1
  55. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/.ageneratorrc +0 -1
  56. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/jest.config.js +13 -0
  57. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/jest.config.js.map +1 -0
  58. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/README.md.js +18 -0
  59. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/README.md.js.map +1 -0
  60. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/jest.config.js +14 -0
  61. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/package.json +3 -17
  62. package/lib/templates/bakedInTemplates/core-template-client-websocket-python/template/README.md.js +5 -0
  63. package/lib/templates/config/validator.js +3 -3
  64. package/lib/utils.js +0 -21
  65. package/package.json +7 -14
  66. package/Dockerfile +0 -20
  67. package/cli.js +0 -205
  68. package/docs/migration-cli.md +0 -70
  69. package/docs/migration-nunjucks-react.md +0 -144
  70. package/docs/nunjucks-render-engine.md +0 -83
  71. package/lib/filtersRegistry.js +0 -134
  72. package/lib/renderer/nunjucks.js +0 -42
  73. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/AvailableOperations.js +0 -34
  74. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/AvailableOperations.js.map +0 -1
  75. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/MessageExamples.js +0 -29
  76. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/MessageExamples.js.map +0 -1
  77. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/OperationHeader.js +0 -19
  78. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/OperationHeader.js.map +0 -1
  79. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/AvailableOperations.js +0 -20
  80. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/MessageExamples.js +0 -25
  81. package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/OperationHeader.js +0 -12
  82. package/lib/watcher.js +0 -147
package/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @asyncapi/generator
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - df08ae7: ### Breaking Changes
8
+
9
+ - You must use Node.js 24.11 or higher, and NPM 11.5.1 or higher
10
+ - Nunjucks renderer removed — React is now the sole rendering engine. No need to specify render engine in config anymore
11
+ - Nunjucks filters package and its public filters removed; filter-based template APIs no longer available.
12
+ - `ag` CLI is no longer available. It was announced some time ago that it would be deprecated, and users are encouraged to switch to the [AsyncAPI CLI](https://github.com/asyncapi/cli/)
13
+
14
+ ### Migration Guides
15
+
16
+ - [Migrating from Nunjucks to React render engine](https://github.com/asyncapi/generator/blob/%40asyncapi/generator%402.8.4/apps/generator/docs/migration-nunjucks-react.md)
17
+ - [Migrating from `ag` CLI to AsyncAPI CLI](https://github.com/asyncapi/generator/blob/%40asyncapi/generator%402.8.4/apps/generator/docs/migration-cli.md)
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [df08ae7]
22
+ - @asyncapi/generator-helpers@1.0.0
23
+
24
+ ## 2.11.0
25
+
26
+ ### Minor Changes
27
+
28
+ - ced1404: Pushing of release https://github.com/asyncapi/generator/pull/1747 that failed due to pipeline issues.
29
+
30
+ ## 2.10.0
31
+
32
+ ### Minor Changes
33
+
34
+ - aee45ba: Pushing of release https://github.com/asyncapi/generator/pull/1747 that failed due to pipeline issues.
35
+
36
+ ## 2.9.0
37
+
38
+ ### Minor Changes
39
+
40
+ - 8168bcd: Pushing of release https://github.com/asyncapi/generator/pull/1747 that failed due to pipeline issues.
41
+
3
42
  ## 2.8.4
4
43
 
5
44
  ### Patch Changes
package/docs/api.md CHANGED
@@ -8,7 +8,6 @@ Reference API documentation for AsyncAPI Generator library.
8
8
 
9
9
  <dl>
10
10
  <dt><a href="#Generator">Generator</a></dt>
11
- <dd></dd>
12
11
  </dl>
13
12
 
14
13
  ## Members
@@ -16,7 +15,7 @@ Reference API documentation for AsyncAPI Generator library.
16
15
  <dl>
17
16
  <dt><a href="#listBakedInTemplates">listBakedInTemplates</a> ⇒ <code>Array.&lt;Object&gt;</code></dt>
18
17
  <dd><p>List core templates, optionally filter by type, stack, protocol, or target.
19
- Use name of returned templates as input for the <code>generate</code> method for template generation. Such core templates code is part of the @asyncapi/generator package.</p></dd>
18
+ Use name of returned templates as input for the `generate` method for template generation. Such core templates code is part of the @asyncapi/generator package.</p></dd>
20
19
  </dl>
21
20
 
22
21
 
@@ -54,7 +53,6 @@ Use name of returned templates as input for the <code>generate</code> method for
54
53
  * [.executeAfterHook()](#Generator+executeAfterHook) ⇒ `Promise.<void>`
55
54
  * [.parseInput()](#Generator+parseInput)
56
55
  * [.configureTemplate()](#Generator+configureTemplate)
57
- * ~~[.generateFromString(asyncapiString, [parseOptions])](#Generator+generateFromString) ⇒ `Promise.<(TemplateRenderResult|undefined)>`~~
58
56
  * [.generateFromURL(asyncapiURL)](#Generator+generateFromURL) ⇒ `Promise.<(TemplateRenderResult|undefined)>`
59
57
  * [.generateFromFile(asyncapiFile)](#Generator+generateFromFile) ⇒ `Promise.<(TemplateRenderResult|undefined)>`
60
58
  * [.installTemplate([force])](#Generator+installTemplate)
@@ -367,57 +365,10 @@ Parse the generator input based on the template `templateConfig.apiVersion` valu
367
365
  <a name="Generator+configureTemplate"></a>
368
366
 
369
367
  * generator.configureTemplate()** :
370
- Configure the templates based the desired renderer.
368
+ Configure the templates.
371
369
 
372
370
  **Kind**: instance method of [`Generator`](#Generator)
373
371
 
374
- <a name="Generator+generateFromString"></a>
375
-
376
- ### ~~generator.generateFromString~~
377
- ***Deprecated***
378
-
379
- Generates files from a given template and AsyncAPI string.
380
-
381
- **Kind**: instance method of [`Generator`](#Generator)
382
- **Params**
383
-
384
- - asyncapiString `String` - AsyncAPI string to use as source.
385
- - [parseOptions] `Object` ` = {}` - AsyncAPI Parser parse options. Check out [@asyncapi/parser](https://www.github.com/asyncapi/parser-js) for more information.
386
-
387
- **Example**
388
- ```js
389
- const asyncapiString = `
390
- asyncapi: '2.0.0'
391
- info:
392
- title: Example
393
- version: 1.0.0
394
- ...
395
- `;
396
- generator
397
- .generateFromString(asyncapiString)
398
- .then(() => {
399
- console.log('Done!');
400
- })
401
- .catch(console.error);
402
- ```
403
- **Example** *(Using async/await)*
404
- ```js
405
- const asyncapiString = `
406
- asyncapi: '2.0.0'
407
- info:
408
- title: Example
409
- version: 1.0.0
410
- ...
411
- `;
412
-
413
- try {
414
- await generator.generateFromString(asyncapiString);
415
- console.log('Done!');
416
- } catch (e) {
417
- console.error(e);
418
- }
419
- ```
420
-
421
372
  <a name="Generator+generateFromURL"></a>
422
373
 
423
374
  ### generator.generateFromURL
@@ -21,7 +21,7 @@ In the following sections, you'll learn about the inner working of the generator
21
21
  3. The **Parser** validates the **AsyncAPI Document** using additional schema-related plugins, either the OpenAPI schema, RAML data types, or Avro schema.
22
22
  4. If the **Parser** determines that the **AsyncAPI Document** is valid, it manipulates the original JSON/YAML document and provides a set of helper functions in return, bundling them together into an **asyncapi** variable that is an instance of [**AsyncAPIDocument**](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#asyncapidocument).
23
23
  5. At this point, the **Generator** passes the **originalAsyncAPI** and the **asyncapi** which make up part of the **[Template Context](template-context)** to the **Render Engine**.
24
- 6. The **Template Context** is accessible to the template files that are passed to either the [react](react-render-engine) or [nunjucks](nunjucks-render-engine) **Render Engines**.
24
+ 6. The **Template Context** is accessible to the template files that are passed to the [react](react-render-engine) **Render Engine**.
25
25
 
26
26
  ```mermaid
27
27
  graph LR
@@ -21,7 +21,6 @@ metadata:
21
21
  target: javascript
22
22
  stack: express
23
23
 
24
- renderer: react
25
24
  apiVersion: v3
26
25
  supportedProtocols:
27
26
  - amqp
@@ -86,7 +85,6 @@ Alternatively, you can include your configuration in the `generator` property of
86
85
  "target": "javascript",
87
86
  "stack": "express"
88
87
  },
89
- "renderer": "react",
90
88
  "apiVersion": "v3",
91
89
  "supportedProtocols": ["amqp", "mqtt"],
92
90
  "parameters": {
@@ -150,7 +148,6 @@ The `generator` property from `package.json` file must contain a JSON object and
150
148
  | `metadata.protocol` | String | **Required for `client`/`sdk`**. The protocol this template targets (e.g., `websocket`, `kafka`). Not used for `docs`/`config`. |
151
149
  | `metadata.target` | String | **Required**. The output language or format (e.g., `javascript`, `html`, `yaml`). |
152
150
  | `metadata.stack` | String | Optional. The stack or framework (e.g., `express`, `quarkus`). Only for `client`/`sdk`. |
153
- | `renderer` | String | Its value can be either `react` or `nunjucks` (default). |
154
151
  | `apiVersion` | String | Determines which **major** version of the [Parser-API](https://github.com/asyncapi/parser-api) the template uses. For example, `v2` for `v2.x.x`. If not specified, the Generator assumes the template is not compatible with the Parser-API so it will use the [Parser-JS v1 API](https://github.com/asyncapi/parser-js/tree/v1.18.1#api-documentation). For templates that need to support AsyncAPI specification v3 make sure to use `v3` [Parser-API](https://github.com/asyncapi/parser-api). If the template uses a version of the Parser-API that is not supported by the Generator, the Generator will throw an error. |
155
152
  | `supportedProtocols` | [String] | A list with all the protocols this template supports. |
156
153
  | `parameters` | Object[String, Object] | An object with all the parameters that can be passed when generating the template. When using the command line, it's done by indicating `--param name=value` or `-p name=value`. |
@@ -166,7 +163,6 @@ The `generator` property from `package.json` file must contain a JSON object and
166
163
  | `conditionalGeneration[filePath/directoryName].validation` | Object (JSON Schema fragment) | The validation defines the condition under which the file or directory will be generated. It must be a valid JSON Schema fragment that validates the value of the parameter. For example, if you want to include a folder only when includeDocs is true, use "validation": `{ "const": true }`. You can also use more complex validation logic, like "enum": ["yes", "true"] or "type": "string" with a "pattern" constraint. If the parameter fails validation, the file or folder will not be included in the generated output. This allows for powerful and flexible control over template generation based on user input. |
167
164
  | `nonRenderableFiles` | [String] | A list of file paths or [globs](https://en.wikipedia.org/wiki/Glob_(programming)) that must be copied "as-is" to the target directory, i.e., without performing any rendering process. This is useful when you want to copy binary files. |
168
165
  | `generator` | [String] | A string representing the generator version-range the template is compatible with. This value must follow the [semver](https://nodejs.dev/learn/semantic-versioning-using-npm) syntax. E.g., `>=1.0.0`, `>=1.0.0 <=2.0.0`, `~1.0.0`, `^1.0.0`, `1.0.0`, etc. [Read more about semver](https://docs.npmjs.com/about-semantic-versioning). |
169
- | `filters` | [String] | A list of modules containing functions that can be used as Nunjucks filters. In case of external modules, remember they need to be added as a dependency in `package.json` of your template. |
170
166
  | `hooks` | Object[String, String] or Object[String, Array[String]] | A list of modules containing hooks, except for the ones you keep locally in your template in the default location. For each module you must specify the exact name of the hook that should be used in the template. For a single hook, you can specify it as a string; for more hooks, you must pass an array of strings. In the case of external modules, remember they need to be added as a dependency in `package.json` of your template. There is also [an official hooks library](hooks#official-library) always included in the generator. As this is a library of multiple hooks, you still need to explicitly specify in the configuration which one you want to use. Use `@asyncapi/generator-hooks` as the library name. |
171
167
 
172
168
  ## Special parameters
@@ -3,67 +3,9 @@ title: "File templates"
3
3
  weight: 140
4
4
  ---
5
5
 
6
- ## Generating files with the Nunjucks render engine
7
-
8
- > **Note**: This section applies only to the Nunjucks render engine. For information on using the React render engine, refer to the [Generating files with the React render engine](#generating-files-with-the-react-render-engine) section below.
9
-
10
- > **Note**: Nunjucks renderer engine is deprecated and will be removed in the future. Use the React renderer engine instead. For more details read notes from release [@asyncapi/generator@2.6.0](https://github.com/asyncapi/generator/releases/tag/%40asyncapi%2Fgenerator%402.6.0).
11
-
12
- It is possible to generate files for each specific object in your AsyncAPI documentation using the Nunjucks render engine. For example, you can specify a filename like `$$channel$$.js` to generate a file for each channel defined in your AsyncAPI. The following file-template names and extra variables are available:
13
-
14
- - `$$channel$$`, within the template-file you have access to two variables [`channel`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channel) and [`channelName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channels). Where the `channel` contains the current channel being rendered.
15
- - `$$message$$`, within the template-file you have access to two variables [`message`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#message) and [`messageName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#message). Where `message` contains the current message being rendered.
16
- - `$$schema$$`, within the template-file you have access to two variables [`schema`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema) and [`schemaName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema). Where `schema` contains the current schema being rendered. Only schemas from [Components object](https://www.asyncapi.com/docs/reference/specification/latest#componentsObject) are used.
17
- - `$$everySchema$$`, within the template-file you have access to two variables [`schema`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema) and [`schemaName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schemas). Where `schema` contains the current schema being rendered. Every [Schema object](https://www.asyncapi.com/docs/specifications/2.0.0/#schemaObject) from the entire AsyncAPI file is used.
18
- - `$$objectSchema$$`, within the template-file you have access to two variables [`schema`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schema) and [`schemaName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#schemas). Where `schema` contains the current schema being rendered. All the [Schema objects](https://www.asyncapi.com/docs/reference/specification/latest#multiFormatSchemaObject) with type object is used.
19
- - `$$parameter$$`, within the template-file you have access to two variables [`parameter`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channelparameter) and [`parameterName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#channelparameters). Where the `parameter` contains the current parameter being rendered.
20
- - `$$securityScheme$$`, within the template-file you have access to two variables [`securityScheme`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#securityscheme) and [`securitySchemeName`](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#securityschemes). Where `securityScheme` contains the current security scheme being rendered.
21
-
22
- The file name will be equal to `*Name` variable.
23
-
24
- ### Example
25
-
26
- The file name is `$$schema$$.txt`, the content of this file is:
27
- ```
28
- Schema name is '{{schemaName}}' and properties are:
29
- {% for propName, prop in schema.properties() %}
30
- - {{prop.uid()}}
31
- {% endfor %}
32
- ```
33
-
34
- With the following AsyncAPI:
35
- ```
36
- components:
37
- schemas:
38
- peoplePayload:
39
- type: object
40
- properties:
41
- event:
42
- $ref: "#/components/schemas/people"
43
- people:
44
- type: object
45
- properties:
46
- id:
47
- type: integer
48
- ```
49
-
50
- The generator creates two files `peoplePayload.txt` and `people.txt` with the following content:
51
- ```
52
- Schema name is 'peoplePayload' and properties are:
53
- - people
54
- ```
55
-
56
- and
57
- ```
58
- Schema name is 'people' and properties are:
59
- - id
60
- ```
61
-
62
- > You can see an example of a file template that uses the Nunjucks render engine [here](https://github.com/asyncapi/template-for-generator-templates/tree/nunjucks/template/schemas).
63
-
64
6
  ## Generating files with the React render engine
65
7
 
66
- The above method of rendering **file templates** only works for the Nunjucks render engine. To use the React render engine, you need to follow a different approach. The React render engine allows for a more generic way to render multiple files by returning an array of `File` components in the rendering component. This can be particularly useful for complex templates or when you need to generate a large number of files with varying content.
8
+ The React render engine allows for a more generic way to render multiple files by returning an array of `File` components in the rendering component. This can be particularly useful for complex templates or when you need to generate a large number of files with varying content.
67
9
 
68
10
  ### Example 1: Rendering hardcoded files
69
11
 
@@ -61,7 +61,6 @@ Add the following code snippet to your package.json file:
61
61
  "version": "0.0.1",
62
62
  "description": "A template that generates a Java MQTT client using MQTT.",
63
63
  "generator": {
64
- "renderer": "react",
65
64
  "apiVersion": "v1",
66
65
  "generator": ">=1.10.0 <2.0.0",
67
66
  "supportedProtocols": ["mqtt"]
@@ -287,7 +286,6 @@ In **package.json** define a script property that you invoke by calling `npm run
287
286
  "version": "0.0.1",
288
287
  "description": "A template that generates a Java MQTT client using MQTT.",
289
288
  "generator": {
290
- "renderer": "react",
291
289
  "apiVersion": "v1",
292
290
  "generator": ">=1.10.0 <2.0.0",
293
291
  "supportedProtocols": ["mqtt"],
@@ -112,7 +112,6 @@ The **package.json** file is used to define the dependencies for your template.
112
112
  "version": "0.0.1",
113
113
  "description": "A template that generates a Python MQTT client using MQTT.",
114
114
  "generator": {
115
- "renderer": "react",
116
115
  "apiVersion": "v1",
117
116
  "generator": ">=1.10.0 <2.0.0",
118
117
  "supportedProtocols": ["mqtt"]
@@ -132,7 +131,6 @@ Here's what is contained in the code snippet above:
132
131
  - **version** - the current version of your template.
133
132
  - **description** - a description of what your template does.
134
133
  - **generator** - specify generator [specific configuration](https://www.asyncapi.com/docs/tools/generator/configuration-file).
135
- - **renderer** - can either be [`react`](https://www.asyncapi.com/docs/tools/generator/react-render-engine) or [`nunjucks`](https://www.asyncapi.com/docs/tools/generator/nunjucks-render-engine). In this case the generator will pass your template to the react render engine to generate the output.
136
134
  - **apiVersion** - specifies which major version of the [Parser-API](https://github.com/asyncapi/parser-api) your template will use.
137
135
  - **generator** - a string representing the generator version-range your template is compatible with.
138
136
  - **supportedProtocols** - A list that specifies which protocols are supported by your template.
@@ -328,7 +326,6 @@ In **package.json** you can have the scripts property that you invoke by calling
328
326
  "test": "npm run test:clean && npm run test:generate && npm run test:start"
329
327
  },
330
328
  "generator": {
331
- "renderer": "react",
332
329
  "apiVersion": "v1",
333
330
  "generator": ">=1.10.0 <2.0.0",
334
331
  "supportedProtocols": ["mqtt"]
@@ -459,7 +456,7 @@ export default function ({ asyncapi, params }) {
459
456
  4. Dynamically get the class name **TemperatureServiceClient** from the AsyncAPI document from the **info** object using the Parser API using the code: `asyncapi.info().title()` . It will return `Temperature Service`, then remove the spaces and add `Client` as a suffix.
460
457
  5. There is no templating needed in the `__init__` function, there is only hardcoded information.
461
458
 
462
- > If you're on the fence about which templating engine you should use in your template, check out the [React render engine](https://www.asyncapi.com/docs/tools/generator/react-render-engine) and [nunjucks render engine](https://www.asyncapi.com/docs/tools/generator/nunjucks-render-engine) documentation.
459
+ > If you're on the fence about which templating engine you should use in your template, check out the [React render engine](https://www.asyncapi.com/docs/tools/generator/react-render-engine) documentation.
463
460
  In the next section, you'll refactor your template to use React.
464
461
 
465
462
  #### 5c. Creating a reusable component
package/docs/index.md CHANGED
@@ -24,8 +24,8 @@ The AsyncAPI generator is a tool that generates anything you want using the **[A
24
24
  3. The **Parser** uses additional plugins such as the OpenAPI, RAML, or Avro schemas to validate custom schemas of message payloads defined in the **AsyncAPI Document**.
25
25
  4. If the **Parser** determines that the original **AsyncAPI Document** is valid, it manipulates the document and returns a set of helper functions and properties and bundles them together into an **asyncapi** variable that is an instance of [**AsyncAPIDocument**](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#asyncapidocument). The **asyncapi** helper functions make it easier to access the contents of the AsyncAPI Document.
26
26
  5. At this point, the **Generator** passes the **[asyncapi](generator/asyncapi-document#method-2-asyncapi-and-template)**, the **[originalAsyncAPI](generator/asyncapi-document#method-1-originalasyncapi-and-template)**, and the **params** which collectively make up the **[Template Context](generator/template-context)** to the **Render Engine**.
27
- 6. AsyncAPI has two **Render Engines**([react](generator/react-render-engine) and [nunjucks](generator/nunjucks-render-engine)). Depending on which one you've specified in your `package.json`, the **Generator** knows the right **Render Engine** to pass both the **Template Files** and the **Template Context**.
28
- 7. Once the **Render Engine** receives the **Template Files** and the **Template Context**, it injects all the dynamic values in your react or nunjucks based **Template Files** using the **Template Context**. As a result, the **Render Engine** generates **markdown**, **pdf**, **boilerplate code**, and **anything else** you specified to be generated as output.
27
+ 6. AsyncAPI has a **Render Engine**([react](generator/react-render-engine)). The **Generator** passes both the **Template Files** and the **Template Context** to the **Render Engine**.
28
+ 7. Once the **Render Engine** receives the **Template Files** and the **Template Context**, it injects all the dynamic values in your react based **Template Files** using the **Template Context**. As a result, the **Render Engine** generates **markdown**, **pdf**, **boilerplate code**, and **anything else** you specified to be generated as output.
29
29
 
30
30
  > You can generate anything you want using the generator as long as it can be defined in a **Template**.
31
31
 
@@ -0,0 +1,13 @@
1
+ {{#globals kind=kind ~}}
2
+ {{#if @first~}}{{>heading-indent}}{{../title}}
3
+
4
+ <dl>
5
+ {{/if~}}
6
+ <dt>{{>sig-link-html}}</dt>
7
+ {{#if description~}}
8
+ <dd><p>{{{inlineLinks description}}}</p></dd>
9
+ {{/if}}
10
+ {{#if @last~}}</dl>
11
+
12
+ {{/if~}}
13
+ {{/globals~}}
@@ -0,0 +1,6 @@
1
+ {{#unless deprecated~}}
2
+ {{string-repeat " " (add level baseLevel)}}* {{#unless (equal _title undefined)}}_{{_title}}_{{else}}{{>sig-link}}{{/unless}}
3
+ {{#groupBy (option "group-by")~}}
4
+ {{>member-index-grouped baseLevel=(add ../level ../baseLevel 1)~}}
5
+ {{/groupBy~}}
6
+ {{/unless~}}
@@ -0,0 +1,6 @@
1
+ {{#unless deprecated~}}
2
+ {{>index-indent}}* {{>sig-link-parent}}
3
+ {{#indexChildren ~}}
4
+ {{>member-index-list~}}
5
+ {{/indexChildren}}
6
+ {{/unless~}}
@@ -0,0 +1 @@
1
+ {{#children inherited=undefined ~}}{{#unless deprecated~}}{{>docs~}}{{/unless~}}{{/children~}}
@@ -3,14 +3,14 @@ title: "React render engine"
3
3
  weight: 110
4
4
  ---
5
5
 
6
- [React](https://reactjs.org) is the render engine that we strongly suggest you should use for any new templates. The only reason it is not the default render engine is to stay backward compatible.
6
+ [React](https://reactjs.org) is the only render engine supported by the AsyncAPI generator.
7
7
 
8
- * It enables the possibility of [debugging](#debugging-react-template) your template (this is not possible with Nunjucks).
8
+ * It enables the possibility of debugging your template.
9
9
  * It provides better error stack traces.
10
10
  * Provides better support for separating code into more manageable chunks/components.
11
- * The readability of the template is much better compared to Nunjucks syntax.
11
+ * The readability of the template is much better.
12
12
  * Better tool support for development.
13
- * Introduces testability of components which is not possible with Nunjucks.
13
+ * Introduces testability of components.
14
14
 
15
15
  When writing React templates you decide whether to use CommonJS, ES5, or ES6 modules since everything is bundled together before the rendering process takes over. We use our own React renderer which can be found in the [Generator React SDK](https://github.com/asyncapi/generator-react-sdk).
16
16
  There you can find information about how the renderer works or how we transpile your template files.
@@ -45,36 +45,4 @@ For further information about components, props, etc, see the [Generator React S
45
45
  - `asyncapi` which is a parsed spec file object. Read the [API](https://github.com/asyncapi/parser-api/blob/master/docs/api.md#asyncapidocument) of the Parser to understand what structure you have access to in this parameter.
46
46
  - `originalAsyncAPI` which is an original spec file before it is parsed.
47
47
  - `params` that contain the parameters provided when generating.
48
- 1. All the file templates are supported where the variables are provided after the default props as listed above.
49
-
50
- ### Debugging React template in VSCode
51
-
52
- With React, it enables you to debug your templates. For Visual Studio Code, we have created a boilerplate [launch configuration](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) to enable debugging in your template. Add the following launch configuration:
53
-
54
- ```json
55
- {
56
- "version": "0.2.0",
57
- "configurations": [
58
- {
59
- "type": "node",
60
- "request": "launch",
61
- "name": "Debug template",
62
- "timeout": 10000,
63
- "sourceMaps": true,
64
- "args": [
65
- "./asyncapi.yml",
66
- "./template",
67
- "--output",
68
- "./output",
69
- "--install",
70
- "--force-write"
71
- ],
72
- "program": "ag"
73
- }
74
- ]
75
- }
76
- ```
77
-
78
- Now replace `./asyncapi.yml` with your document of choice. Replace `./template` with the path to your React template. You can now debug your template by adding any breakpoints you want and inspecting your code.
79
-
80
-
48
+ 1. All the file templates are supported where the variables are provided after the default props as listed above.
@@ -3,7 +3,7 @@ title: "Template development"
3
3
  weight: 80
4
4
  ---
5
5
  > **Note**
6
- > It is advised against attempting to manually template types and models from scratch using the AsyncAPI templating engines such as Nunjucks and React render engines. Instead, it is recommended to use [AsyncAPI Modelina](/docs/tools/generator/model-generation) a dedicated library for model generation.
6
+ > It is advised against attempting to manually template types and models from scratch using the AsyncAPI templating engines such as the React render engine. Instead, it is recommended to use [AsyncAPI Modelina](/docs/tools/generator/model-generation) a dedicated library for model generation.
7
7
 
8
8
  ## Minimum template requirements
9
9
 
@@ -40,9 +40,7 @@ The following block shows an example `package.json` file that points to the [Rea
40
40
  ```json
41
41
  {
42
42
  "name": "myTemplate",
43
- "generator": {
44
- "renderer": "react"
45
- },
43
+ "generator": {},
46
44
  "dependencies": {
47
45
  "@asyncapi/generator-react-sdk": "^0.2.25"
48
46
  }
@@ -57,7 +55,6 @@ You must configure the generator's `package.json` file to contain JSON objects w
57
55
 
58
56
  |Name|Type|Description|
59
57
  |---|---|---|
60
- |`renderer`| String | Its value can be either `react` or `nunjucks` (default).
61
58
  |`supportedProtocols`| [String] | A list with all the protocols this template supports.
62
59
  |`parameters`| Object[String, Object] | An object with all the parameters that can be passed when generating the template. When using the command line, it's done by indicating `--param name=value` or `-p name=value`.
63
60
  |`parameters[param].description`| String | A user-friendly description about the parameter.
@@ -76,7 +73,6 @@ The following examples show some advanced configurations that we can use in our
76
73
  {
77
74
  "name": "myTemplate",
78
75
  "generator": {
79
- "renderer": "react",
80
76
  "supportedProtocols": [
81
77
  "mqtt"
82
78
  ]
@@ -98,7 +94,6 @@ Additionally, we can also have a configuration called `parameters`, which is an
98
94
  {
99
95
  "name": "myTemplate",
100
96
  "generator": {
101
- "renderer": "react",
102
97
  "supportedProtocols": [
103
98
  "mqtt"
104
99
  ],
package/docs/template.md CHANGED
@@ -45,8 +45,8 @@ You can store template projects on a local drive or as a `git` repository during
45
45
  2. **asyncapi** (which is an instance of AsyncAPIDocument) is injected into your template file by default.
46
46
  3. **params** are the parameters you pass to the AsyncAPI CLI. Later, you can also pass these **params** further to other components.
47
47
  4. The generator passes both the **asyncapi**, the **originalAsyncAPI**, and the **params** to the **Template Context**.
48
- 5. Concurrently, the generator passes **Template files** to the **Render engine** as well. AsyncAPI uses two render engines — _react_ and _nunjucks_.
49
- 6. Once the Render Engine receives both the Template Files and the Template Context, it injects all the dynamic values into your react or nunjucks engine, based on the Template Files using the Template Context.
48
+ 5. Concurrently, the generator passes **Template files** to the **Render engine** as well. AsyncAPI uses the _react_ render engine.
49
+ 6. Once the Render Engine receives both the Template Files and the Template Context, it injects all the dynamic values into your react based Template Files using the Template Context.
50
50
  7. The render engine generates whatever output you may have specified in your template. (i.e. code, documentation, diagrams, pdfs, applications, etc.)
51
51
 
52
52
  ```mermaid
@@ -3,11 +3,9 @@ title: "TypeScript support"
3
3
  weight: 150
4
4
  ---
5
5
 
6
- The AsyncAPI generator has TypeScript support for [hooks](#hooks) and Nunjucks's [filters](#filters). Assumptions:
6
+ The AsyncAPI generator has TypeScript support for [hooks](hooks). Assumptions:
7
7
 
8
- - Installing the `typescript` package and creating the` tsconfig.json` file isn't necessary.
8
+ - Installing the `typescript` package and creating the `tsconfig.json` file isn't necessary.
9
9
  - Source code of the hook/filter must have `.ts` extension.
10
10
  - Each package related to the typings for TypeScript like `@types/node` must be installed in the template under `dependencies` array. This is because the Generator transpiles the TypeScript code on-the-fly while rendering the template, and cannot use packages under `devDependencies`.
11
- - Each template should have `@types/node` package installed to enable support for typings for Node.
12
-
13
-
11
+ - Each template should have `@types/node` package installed to enable support for typings for Node.
package/jest.config.js CHANGED
@@ -1,9 +1,6 @@
1
- const path = require('path');
1
+ const baseConfig = require('../../jest.config.base');
2
+
2
3
  module.exports = {
4
+ ...baseConfig(__dirname),
3
5
  clearMocks: true,
4
- moduleNameMapper: {
5
- '^nimma/legacy$': '<rootDir>../../node_modules/nimma/dist/legacy/cjs/index.js',
6
- '^nimma/(.*)': '<rootDir>../../node_modules/nimma/dist/cjs/$1',
7
- '^@asyncapi/nunjucks-filters$': path.resolve(__dirname, '../nunjucks-filters'),
8
- },
9
6
  };
@@ -13,9 +13,6 @@ utils.fetchSpec = jest.fn(async (fileUrl) => {
13
13
  utils.__isFileSystemPathValue = false;
14
14
  utils.isFileSystemPath = jest.fn(() => utils.__isFileSystemPathValue);
15
15
 
16
- utils.__isLocalTemplateValue = false;
17
- utils.isLocalTemplate = jest.fn(async () => utils.__isLocalTemplateValue);
18
-
19
16
  utils.__generatorVersion = '';
20
17
  utils.getGeneratorVersion = jest.fn(() => utils.__generatorVersion);
21
18
 
package/lib/generator.js CHANGED
@@ -12,7 +12,6 @@ const npmPath = requireg.resolve('npm').replace('index.js','');
12
12
  const { isAsyncAPIDocument } = require('@asyncapi/parser/cjs/document');
13
13
 
14
14
  const { configureReact, renderReact, saveRenderedReactContent } = require('./renderer/react');
15
- const { configureNunjucks, renderNunjucks } = require('./renderer/nunjucks');
16
15
  const { validateTemplateConfig } = require('./templates/config/validator');
17
16
  const { loadTemplateConfig } = require('./templates/config/loader');
18
17
  const { isGenerationConditionMet } = require('./conditionalGeneration');
@@ -26,17 +25,14 @@ const {
26
25
  copyFile,
27
26
  exists,
28
27
  fetchSpec,
29
- isReactTemplate,
30
28
  isJsFile,
31
29
  getTemplateDetails,
32
30
  convertCollectionToObject,
33
31
  } = require('./utils');
34
32
  const { parse, usesNewAPI, getProperApiDocument } = require('./parser');
35
- const { registerFilters } = require('./filtersRegistry');
36
33
  const { registerHooks } = require('./hooksRegistry');
37
34
  const { definitions, flatten, shorthands } = require('@npmcli/config/lib/definitions');
38
35
 
39
- const FILTERS_DIRNAME = 'filters';
40
36
  const HOOKS_DIRNAME = 'hooks';
41
37
  const PACKAGE_JSON_FILENAME = 'package.json';
42
38
  const GIT_IGNORE_FILENAME = '{.gitignore}';
@@ -325,9 +321,6 @@ class Generator {
325
321
  await this.parseInput(this.asyncapi, parseOptions);
326
322
  validateTemplateConfig(this.templateConfig, this.templateParams, this.asyncapi);
327
323
  await this.configureTemplate();
328
- if (!isReactTemplate(this.templateConfig)) {
329
- await registerFilters(this.nunjucks, this.templateConfig, this.templateDir, FILTERS_DIRNAME);
330
- }
331
324
  await registerHooks(this.hooks, this.templateConfig, this.templateDir, HOOKS_DIRNAME);
332
325
  await this.launchHook('generate:before');
333
326
  }
@@ -407,10 +400,8 @@ class Generator {
407
400
  * Configure the templates based the desired renderer.
408
401
  */
409
402
  async configureTemplate() {
410
- if (isReactTemplate(this.templateConfig) && this.compile) {
403
+ if (this.compile) {
411
404
  await configureReact(this.templateDir, this.templateContentDir, TRANSPILED_TEMPLATE_LOCATION);
412
- } else {
413
- this.nunjucks = configureNunjucks(this.debug, this.templateDir);
414
405
  }
415
406
  }
416
407
 
@@ -876,11 +867,8 @@ class Generator {
876
867
  const renderContent = await this.renderFile(asyncapiDocument, templateFilePath, extraTemplateData);
877
868
  if (renderContent === undefined) {
878
869
  return;
879
- } else if (isReactTemplate(this.templateConfig)) {
880
- await saveRenderedReactContent(renderContent, outputpath, this.noOverwriteGlobs);
881
- } else {
882
- await writeFile(outputpath, renderContent);
883
870
  }
871
+ await saveRenderedReactContent(renderContent, outputpath, this.noOverwriteGlobs);
884
872
  }
885
873
 
886
874
  /**
@@ -981,11 +969,7 @@ class Generator {
981
969
  * @return {Promise<string|TemplateRenderResult|Array<TemplateRenderResult>|undefined>}
982
970
  */
983
971
  async renderFile(asyncapiDocument, filePath, extraTemplateData = {}) {
984
- if (isReactTemplate(this.templateConfig)) {
985
- return await renderReact(asyncapiDocument, filePath, extraTemplateData, this.templateDir, this.templateContentDir, TRANSPILED_TEMPLATE_LOCATION, this.templateParams, this.debug, this.originalAsyncAPI);
986
- }
987
- const templateString = await readFile(filePath, 'utf8');
988
- return renderNunjucks(asyncapiDocument, templateString, filePath, extraTemplateData, this.templateParams, this.originalAsyncAPI, this.nunjucks);
972
+ return await renderReact(asyncapiDocument, filePath, extraTemplateData, this.templateDir, this.templateContentDir, TRANSPILED_TEMPLATE_LOCATION, this.templateParams, this.debug, this.originalAsyncAPI);
989
973
  }
990
974
 
991
975
  /**
@@ -999,7 +983,7 @@ class Generator {
999
983
  const nonRenderableFiles = this.templateConfig.nonRenderableFiles || [];
1000
984
  return Array.isArray(nonRenderableFiles) &&
1001
985
  (nonRenderableFiles.some(globExp => minimatch(fileName, globExp)) ||
1002
- (isReactTemplate(this.templateConfig) && !isJsFile(fileName)));
986
+ !isJsFile(fileName));
1003
987
  }
1004
988
 
1005
989
  /**
@@ -1,6 +1,4 @@
1
- renderer: react
2
1
  apiVersion: v3
3
- generator: '>=1.3.0 <3.0.0'
4
2
  parameters:
5
3
  server:
6
4
  description: The name of the server described in AsyncAPI document
@@ -13,11 +11,11 @@ parameters:
13
11
  description: The custom name for the generated client class
14
12
  required: false
15
13
  env:
16
- description: 'The environment for the generated client, e.g., dev, prod'
14
+ description: The environment for the generated client, e.g., dev, prod
17
15
  required: false
18
16
  default: dev
19
17
  version:
20
- description: 'The version for the generated client, e.g., V1, V2'
18
+ description: The version for the generated client, e.g., V1, V2
21
19
  required: false
22
20
  default: V1
23
21
  nonRenderableFiles:
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ require('source-map-support/register');
4
+
5
+ const baseConfig = require('../../../../../../jest.config.base');
6
+ module.exports = {
7
+ ...baseConfig(__dirname),
8
+ moduleFileExtensions: ['js', 'json', 'jsx'],
9
+ transform: {
10
+ '^.+\\.jsx?$': 'babel-jest'
11
+ }
12
+ };
13
+ //# sourceMappingURL=jest.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jest.config.js","sources":["../../../../../../../packages/templates/clients/kafka/java/quarkus/jest.config.js"],"sourcesContent":["const baseConfig = require('../../../../../../jest.config.base');\n\nmodule.exports = {\n ...baseConfig(__dirname),\n moduleFileExtensions: [\n 'js',\n 'json',\n 'jsx'\n ],\n transform: {\n '^.+\\\\.jsx?$': 'babel-jest'\n },\n};\n\n"],"names":["baseConfig","require","module","exports","__dirname","moduleFileExtensions","transform"],"mappings":";;;;AAAA,MAAMA,UAAU,GAAGC,OAAO,CAAC,oCAAoC,CAAC,CAAA;AAEhEC,MAAM,CAACC,OAAO,GAAG;EACf,GAAGH,UAAU,CAACI,SAAS,CAAC;AACxBC,EAAAA,oBAAoB,EAAE,CACpB,IAAI,EACJ,MAAM,EACN,KAAK,CACN;AACDC,EAAAA,SAAS,EAAE;AACT,IAAA,aAAa,EAAE,YAAA;AACjB,GAAA;AACF,CAAC;;"}
@@ -0,0 +1,14 @@
1
+ const baseConfig = require('../../../../../../jest.config.base');
2
+
3
+ module.exports = {
4
+ ...baseConfig(__dirname),
5
+ moduleFileExtensions: [
6
+ 'js',
7
+ 'json',
8
+ 'jsx'
9
+ ],
10
+ transform: {
11
+ '^.+\\.jsx?$': 'babel-jest'
12
+ },
13
+ };
14
+