@asyncapi/generator 2.8.4 → 2.11.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.
- package/CHANGELOG.md +18 -0
- package/docs/api.md +1 -50
- package/docs/jsdoc2md-handlebars/main-index/global-index/global-index-dl.hbs +13 -0
- package/docs/jsdoc2md-handlebars/member-index-grouped.hbs +6 -0
- package/docs/jsdoc2md-handlebars/member-index-list.hbs +6 -0
- package/docs/jsdoc2md-handlebars/members.hbs +1 -0
- package/docs/migration-nunjucks-react.md +2 -2
- package/jest.config.js +7 -5
- package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/.ageneratorrc +2 -2
- package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/__transpiled/jest.config.js +13 -0
- package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/__transpiled/jest.config.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/jest.config.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/package.json +0 -14
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/jest.config.js +13 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/jest.config.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/jest.config.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/package.json +0 -14
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/jest.config.js +13 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/jest.config.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/jest.config.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/package.json +0 -14
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/.ageneratorrc +8 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ClientClass.js +5 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ClientClass.js.map +1 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/CompileOperationSchemas.js +48 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/CompileOperationSchemas.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Constructor.js +7 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Constructor.js.map +1 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/jest.config.js +13 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/jest.config.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/client.js.js +52 -3
- 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/ClientClass.js +4 -2
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/CompileOperationSchemas.js +40 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/Constructor.js +7 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/jest.config.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/package.json +5 -18
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/template/client.js.js +5 -1
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/jest.config.js +13 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/jest.config.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/jest.config.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/package.json +0 -14
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @asyncapi/generator
|
|
2
2
|
|
|
3
|
+
## 2.11.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ced1404: Pushing of release https://github.com/asyncapi/generator/pull/1747 that failed due to pipeline issues.
|
|
8
|
+
|
|
9
|
+
## 2.10.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- aee45ba: Pushing of release https://github.com/asyncapi/generator/pull/1747 that failed due to pipeline issues.
|
|
14
|
+
|
|
15
|
+
## 2.9.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 8168bcd: Pushing of release https://github.com/asyncapi/generator/pull/1747 that failed due to pipeline issues.
|
|
20
|
+
|
|
3
21
|
## 2.8.4
|
|
4
22
|
|
|
5
23
|
### 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.<Object></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
|
|
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)
|
|
@@ -371,53 +369,6 @@ Configure the templates based the desired renderer.
|
|
|
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
|
|
@@ -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 @@
|
|
|
1
|
+
{{#children inherited=undefined ~}}{{#unless deprecated~}}{{>docs~}}{{/unless~}}{{/children~}}
|
package/jest.config.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const baseConfig = require('../../jest.config.base');
|
|
3
|
+
|
|
2
4
|
module.exports = {
|
|
5
|
+
...baseConfig(__dirname, {
|
|
6
|
+
moduleNameMapper: {
|
|
7
|
+
'^@asyncapi/nunjucks-filters$': path.resolve(__dirname, '../nunjucks-filters'),
|
|
8
|
+
},
|
|
9
|
+
}),
|
|
3
10
|
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
11
|
};
|
package/lib/templates/bakedInTemplates/core-template-client-kafka-java-quarkus/.ageneratorrc
CHANGED
|
@@ -13,11 +13,11 @@ parameters:
|
|
|
13
13
|
description: The custom name for the generated client class
|
|
14
14
|
required: false
|
|
15
15
|
env:
|
|
16
|
-
description:
|
|
16
|
+
description: The environment for the generated client, e.g., dev, prod
|
|
17
17
|
required: false
|
|
18
18
|
default: dev
|
|
19
19
|
version:
|
|
20
|
-
description:
|
|
20
|
+
description: The version for the generated client, e.g., V1, V2
|
|
21
21
|
required: false
|
|
22
22
|
default: V1
|
|
23
23
|
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;;"}
|
|
@@ -35,20 +35,6 @@
|
|
|
35
35
|
"eslint-plugin-sonarjs": "^0.5.0",
|
|
36
36
|
"jest-esm-transformer": "^1.0.0"
|
|
37
37
|
},
|
|
38
|
-
"jest": {
|
|
39
|
-
"moduleFileExtensions": [
|
|
40
|
-
"js",
|
|
41
|
-
"json",
|
|
42
|
-
"jsx"
|
|
43
|
-
],
|
|
44
|
-
"transform": {
|
|
45
|
-
"^.+\\.jsx?$": "babel-jest"
|
|
46
|
-
},
|
|
47
|
-
"moduleNameMapper": {
|
|
48
|
-
"^nimma/legacy$": "<rootDir>/../../../../../node_modules/nimma/dist/legacy/cjs/index.js",
|
|
49
|
-
"^nimma/(.*)": "<rootDir>/../../../../../node_modules/nimma/dist/cjs/$1"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
38
|
"babel": {
|
|
53
39
|
"presets": [
|
|
54
40
|
"@babel/preset-env",
|
|
@@ -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/websocket/dart/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,iCAAiC,CAAC,CAAA;AAE7DC,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;;"}
|
|
@@ -27,20 +27,6 @@
|
|
|
27
27
|
"eslint-plugin-react": "^7.34.1",
|
|
28
28
|
"eslint-plugin-sonarjs": "^0.5.0"
|
|
29
29
|
},
|
|
30
|
-
"jest": {
|
|
31
|
-
"moduleFileExtensions": [
|
|
32
|
-
"js",
|
|
33
|
-
"json",
|
|
34
|
-
"jsx"
|
|
35
|
-
],
|
|
36
|
-
"transform": {
|
|
37
|
-
"^.+\\.jsx?$": "babel-jest"
|
|
38
|
-
},
|
|
39
|
-
"moduleNameMapper": {
|
|
40
|
-
"^nimma/legacy$": "<rootDir>/../../../../../node_modules/nimma/dist/legacy/cjs/index.js",
|
|
41
|
-
"^nimma/(.*)": "<rootDir>/../../../../../node_modules/nimma/dist/cjs/$1"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
30
|
"babel": {
|
|
45
31
|
"presets": [
|
|
46
32
|
"@babel/preset-env",
|
|
@@ -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/websocket/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;;"}
|
package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/package.json
CHANGED
|
@@ -36,20 +36,6 @@
|
|
|
36
36
|
"eslint-plugin-sonarjs": "^0.5.0",
|
|
37
37
|
"jest-esm-transformer": "^1.0.0"
|
|
38
38
|
},
|
|
39
|
-
"jest": {
|
|
40
|
-
"moduleFileExtensions": [
|
|
41
|
-
"js",
|
|
42
|
-
"json",
|
|
43
|
-
"jsx"
|
|
44
|
-
],
|
|
45
|
-
"transform": {
|
|
46
|
-
"^.+\\.jsx?$": "babel-jest"
|
|
47
|
-
},
|
|
48
|
-
"moduleNameMapper": {
|
|
49
|
-
"^nimma/legacy$": "<rootDir>/../../../../../node_modules/nimma/dist/legacy/cjs/index.js",
|
|
50
|
-
"^nimma/(.*)": "<rootDir>/../../../../../node_modules/nimma/dist/cjs/$1"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
39
|
"babel": {
|
|
54
40
|
"presets": [
|
|
55
41
|
"@babel/preset-env",
|
package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/.ageneratorrc
CHANGED
|
@@ -15,7 +15,15 @@ parameters:
|
|
|
15
15
|
customClientName:
|
|
16
16
|
description: The custom name for the generated client class
|
|
17
17
|
required: false
|
|
18
|
+
asyncapiFileDir:
|
|
19
|
+
description: >-
|
|
20
|
+
Custom location of the AsyncAPI file that you provided as an input in generation. By default it is located in the
|
|
21
|
+
root of the output directory
|
|
22
|
+
required: false
|
|
23
|
+
default: .
|
|
18
24
|
metadata:
|
|
19
25
|
type: client
|
|
20
26
|
protocol: websocket
|
|
21
27
|
target: javascript
|
|
28
|
+
hooks:
|
|
29
|
+
'@asyncapi/generator-hooks': createAsyncapiFile
|
|
@@ -7,6 +7,7 @@ var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
|
7
7
|
var Constructor = require('./Constructor.js');
|
|
8
8
|
var generatorComponents = require('@asyncapi/generator-components');
|
|
9
9
|
var ModuleExport = require('./ModuleExport.js');
|
|
10
|
+
var CompileOperationSchemas = require('./CompileOperationSchemas.js');
|
|
10
11
|
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
11
12
|
|
|
12
13
|
function ClientClass({
|
|
@@ -20,7 +21,8 @@ function ClientClass({
|
|
|
20
21
|
newLines: 2,
|
|
21
22
|
children: `class ${clientName} {`
|
|
22
23
|
}), /*#__PURE__*/jsxRuntime.jsx(Constructor.Constructor, {
|
|
23
|
-
serverUrl: serverUrl
|
|
24
|
+
serverUrl: serverUrl,
|
|
25
|
+
sendOperations: sendOperations
|
|
24
26
|
}), /*#__PURE__*/jsxRuntime.jsx(generatorComponents.Connect, {
|
|
25
27
|
language: "javascript",
|
|
26
28
|
title: title
|
|
@@ -33,6 +35,8 @@ function ClientClass({
|
|
|
33
35
|
}), /*#__PURE__*/jsxRuntime.jsx(generatorComponents.HandleMessage, {
|
|
34
36
|
language: "javascript",
|
|
35
37
|
methodParams: ['message', 'cb']
|
|
38
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CompileOperationSchemas.CompileOperationSchemas, {
|
|
39
|
+
sendOperations: sendOperations
|
|
36
40
|
}), /*#__PURE__*/jsxRuntime.jsx(generatorComponents.SendOperations, {
|
|
37
41
|
language: "javascript",
|
|
38
42
|
sendOperations: sendOperations,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientClass.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/ClientClass.js"],"sourcesContent":["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';\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} />\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 <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"],"names":["ClientClass","clientName","serverUrl","title","sendOperations","_jsxs","Text","children","_jsx","newLines","Constructor","Connect","language","RegisterMessageHandler","methodParams","RegisterErrorHandler","HandleMessage","SendOperations","CloseConnection","ModuleExport"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ClientClass.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/ClientClass.js"],"sourcesContent":["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"],"names":["ClientClass","clientName","serverUrl","title","sendOperations","_jsxs","Text","children","_jsx","newLines","Constructor","Connect","language","RegisterMessageHandler","methodParams","RegisterErrorHandler","HandleMessage","CompileOperationSchemas","SendOperations","CloseConnection","ModuleExport"],"mappings":";;;;;;;;;;;;AAMO,SAASA,WAAWA,CAAC;EAAEC,UAAU;EAAEC,SAAS;EAAEC,KAAK;AAAEC,EAAAA,cAAAA;AAAe,CAAC,EAAE;EAC5E,oBACEC,eAAA,CAACC,sBAAI,EAAA;IAAAC,QAAA,EAAA,cACHC,cAAA,CAACF,sBAAI,EAAA;AAACG,MAAAA,QAAQ,EAAE,CAAE;MAAAF,QAAA,EACf,SAASN,UAAU,CAAA,EAAA,CAAA;AAAI,KACpB,CAAC,eACPO,cAAA,CAACE,uBAAW,EAAA;AAACR,MAAAA,SAAS,EAAEA,SAAU;AAACE,MAAAA,cAAc,EAAEA,cAAAA;AAAe,KAAE,CAAC,eACrEI,cAAA,CAACG,2BAAO,EAAA;AAACC,MAAAA,QAAQ,EAAC,YAAY;AAACT,MAAAA,KAAK,EAAEA,KAAAA;AAAM,KAAE,CAAC,eAC/CK,cAAA,CAACK,0CAAsB,EAAA;AACrBD,MAAAA,QAAQ,EAAC,YAAY;MACrBE,YAAY,EAAE,CAAC,SAAS,CAAA;AAAE,KAC3B,CAAC,eACFN,cAAA,CAACO,wCAAoB,EAAA;AACnBH,MAAAA,QAAQ,EAAC,YAAY;MACrBE,YAAY,EAAE,CAAC,SAAS,CAAA;AAAE,KAC3B,CAAC,eACFN,cAAA,CAACQ,iCAAa,EAAA;AACZJ,MAAAA,QAAQ,EAAC,YAAY;AACrBE,MAAAA,YAAY,EAAE,CAAC,SAAS,EAAE,IAAI,CAAA;AAAE,KACjC,CAAC,eACFN,cAAA,CAACS,+CAAuB,EAAA;AAACb,MAAAA,cAAc,EAAEA,cAAAA;AAAe,KAAE,CAAC,eAC3DI,cAAA,CAACU,kCAAc,EAAA;AACbN,MAAAA,QAAQ,EAAC,YAAY;AACrBR,MAAAA,cAAc,EAAEA,cAAe;AAC/BH,MAAAA,UAAU,EAAEA,UAAAA;AAAW,KACxB,CAAC,eACFO,cAAA,CAACW,mCAAe,EAAA;AAACP,MAAAA,QAAQ,EAAC,YAAA;AAAY,KAAE,CAAC,eACzCJ,cAAA,CAACF,sBAAI,EAAA;AAAAC,MAAAA,QAAA,EACF,GAAA;AAAG,KACA,CAAC,eACPC,cAAA,CAACY,yBAAY,EAAA;AAACnB,MAAAA,UAAU,EAAEA,UAAAA;AAAW,KAAE,CAAC,CAAA;AAAA,GACpC,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('source-map-support/register');
|
|
6
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
7
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
8
|
+
|
|
9
|
+
function CompileOperationSchemas({
|
|
10
|
+
sendOperations
|
|
11
|
+
}) {
|
|
12
|
+
if (!sendOperations || sendOperations.length === 0) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
16
|
+
children: /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
17
|
+
indent: 2,
|
|
18
|
+
newLines: 2,
|
|
19
|
+
children: `/**
|
|
20
|
+
* Initialize and compile all schemas for operations defined.
|
|
21
|
+
* This should be called once after creating the client instance.
|
|
22
|
+
* Subsequent calls will be ignored if schemas are already compiled.
|
|
23
|
+
*
|
|
24
|
+
* @returns {Promise<void>}
|
|
25
|
+
* @throws {Error} If schema compilation fails for any operation
|
|
26
|
+
*/
|
|
27
|
+
async compileOperationSchemas() {
|
|
28
|
+
if (this.schemasCompiled) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
// Compile schemas for all send operations
|
|
34
|
+
for (const operationId of this.sendOperationsId) {
|
|
35
|
+
this.compiledSchemas[operationId] = await compileSchemasByOperationId(asyncapiFilepath, operationId);
|
|
36
|
+
}
|
|
37
|
+
this.schemasCompiled = true;
|
|
38
|
+
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error('Error initializing schemas:', error);
|
|
41
|
+
}
|
|
42
|
+
}`
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.CompileOperationSchemas = CompileOperationSchemas;
|
|
48
|
+
//# sourceMappingURL=CompileOperationSchemas.js.map
|
|
@@ -0,0 +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;;;;"}
|
|
@@ -7,8 +7,11 @@ var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
|
7
7
|
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
8
8
|
|
|
9
9
|
function Constructor({
|
|
10
|
-
serverUrl
|
|
10
|
+
serverUrl,
|
|
11
|
+
sendOperations
|
|
11
12
|
}) {
|
|
13
|
+
const sendOperationsId = sendOperations.map(operation => operation.id());
|
|
14
|
+
const sendOperationsArray = JSON.stringify(sendOperationsId);
|
|
12
15
|
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
13
16
|
indent: 2,
|
|
14
17
|
children: `/*
|
|
@@ -20,6 +23,9 @@ constructor(url) {
|
|
|
20
23
|
this.websocket = null;
|
|
21
24
|
this.messageHandlers = [];
|
|
22
25
|
this.errorHandlers = [];
|
|
26
|
+
this.compiledSchemas = {};
|
|
27
|
+
this.schemasCompiled = false;
|
|
28
|
+
this.sendOperationsId = ${sendOperationsArray};
|
|
23
29
|
}
|
|
24
30
|
`
|
|
25
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constructor.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/Constructor.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function Constructor({ serverUrl }) {\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}\n`\n }\n </Text>\n );\n}\n"],"names":["Constructor","serverUrl","_jsx","Text","indent","children"],"mappings":";;;;;;;;AAEO,SAASA,WAAWA,CAAC;AAAEC,EAAAA,
|
|
1
|
+
{"version":3,"file":"Constructor.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/Constructor.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"],"names":["Constructor","serverUrl","sendOperations","sendOperationsId","map","operation","id","sendOperationsArray","JSON","stringify","_jsx","Text","indent","children"],"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;;;;"}
|
|
@@ -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/websocket/javascript/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,iCAAiC,CAAC,CAAA;AAE7DC,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;;"}
|
|
@@ -7,8 +7,11 @@ var generatorComponents = require('@asyncapi/generator-components');
|
|
|
7
7
|
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
8
8
|
|
|
9
9
|
function Constructor({
|
|
10
|
-
serverUrl
|
|
10
|
+
serverUrl,
|
|
11
|
+
sendOperations
|
|
11
12
|
}) {
|
|
13
|
+
const sendOperationsId = sendOperations.map(operation => operation.id());
|
|
14
|
+
const sendOperationsArray = JSON.stringify(sendOperationsId);
|
|
12
15
|
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
13
16
|
indent: 2,
|
|
14
17
|
children: `/*
|
|
@@ -20,6 +23,9 @@ constructor(url) {
|
|
|
20
23
|
this.websocket = null;
|
|
21
24
|
this.messageHandlers = [];
|
|
22
25
|
this.errorHandlers = [];
|
|
26
|
+
this.compiledSchemas = {};
|
|
27
|
+
this.schemasCompiled = false;
|
|
28
|
+
this.sendOperationsId = ${sendOperationsArray};
|
|
23
29
|
}
|
|
24
30
|
`
|
|
25
31
|
});
|
|
@@ -33,6 +39,44 @@ function ModuleExport({
|
|
|
33
39
|
});
|
|
34
40
|
}
|
|
35
41
|
|
|
42
|
+
function CompileOperationSchemas({
|
|
43
|
+
sendOperations
|
|
44
|
+
}) {
|
|
45
|
+
if (!sendOperations || sendOperations.length === 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
49
|
+
children: /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
50
|
+
indent: 2,
|
|
51
|
+
newLines: 2,
|
|
52
|
+
children: `/**
|
|
53
|
+
* Initialize and compile all schemas for operations defined.
|
|
54
|
+
* This should be called once after creating the client instance.
|
|
55
|
+
* Subsequent calls will be ignored if schemas are already compiled.
|
|
56
|
+
*
|
|
57
|
+
* @returns {Promise<void>}
|
|
58
|
+
* @throws {Error} If schema compilation fails for any operation
|
|
59
|
+
*/
|
|
60
|
+
async compileOperationSchemas() {
|
|
61
|
+
if (this.schemasCompiled) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
// Compile schemas for all send operations
|
|
67
|
+
for (const operationId of this.sendOperationsId) {
|
|
68
|
+
this.compiledSchemas[operationId] = await compileSchemasByOperationId(asyncapiFilepath, operationId);
|
|
69
|
+
}
|
|
70
|
+
this.schemasCompiled = true;
|
|
71
|
+
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('Error initializing schemas:', error);
|
|
74
|
+
}
|
|
75
|
+
}`
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
36
80
|
function ClientClass({
|
|
37
81
|
clientName,
|
|
38
82
|
serverUrl,
|
|
@@ -44,7 +88,8 @@ function ClientClass({
|
|
|
44
88
|
newLines: 2,
|
|
45
89
|
children: `class ${clientName} {`
|
|
46
90
|
}), /*#__PURE__*/jsxRuntime.jsx(Constructor, {
|
|
47
|
-
serverUrl: serverUrl
|
|
91
|
+
serverUrl: serverUrl,
|
|
92
|
+
sendOperations: sendOperations
|
|
48
93
|
}), /*#__PURE__*/jsxRuntime.jsx(generatorComponents.Connect, {
|
|
49
94
|
language: "javascript",
|
|
50
95
|
title: title
|
|
@@ -57,6 +102,8 @@ function ClientClass({
|
|
|
57
102
|
}), /*#__PURE__*/jsxRuntime.jsx(generatorComponents.HandleMessage, {
|
|
58
103
|
language: "javascript",
|
|
59
104
|
methodParams: ['message', 'cb']
|
|
105
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CompileOperationSchemas, {
|
|
106
|
+
sendOperations: sendOperations
|
|
60
107
|
}), /*#__PURE__*/jsxRuntime.jsx(generatorComponents.SendOperations, {
|
|
61
108
|
language: "javascript",
|
|
62
109
|
sendOperations: sendOperations,
|
|
@@ -81,6 +128,7 @@ function client_js ({
|
|
|
81
128
|
const clientName = generatorHelpers.getClientName(asyncapi, params.appendClientSuffix, params.customClientName);
|
|
82
129
|
const serverUrl = generatorHelpers.getServerUrl(server);
|
|
83
130
|
const sendOperations = asyncapi.operations().filterBySend();
|
|
131
|
+
const asyncapiFilepath = `${params.asyncapiFileDir}/asyncapi.yaml`;
|
|
84
132
|
return /*#__PURE__*/jsxRuntime.jsxs(generatorReactSdk.File, {
|
|
85
133
|
name: params.clientFileName,
|
|
86
134
|
children: [/*#__PURE__*/jsxRuntime.jsx(generatorComponents.FileHeaderInfo, {
|
|
@@ -88,7 +136,8 @@ function client_js ({
|
|
|
88
136
|
server: server,
|
|
89
137
|
language: "javascript"
|
|
90
138
|
}), /*#__PURE__*/jsxRuntime.jsx(generatorComponents.DependencyProvider, {
|
|
91
|
-
language: "javascript"
|
|
139
|
+
language: "javascript",
|
|
140
|
+
additionalDependencies: ['const path = require(\'path\');', `const asyncapiFilepath = path.resolve(__dirname, '${asyncapiFilepath}');`]
|
|
92
141
|
}), /*#__PURE__*/jsxRuntime.jsx(ClientClass, {
|
|
93
142
|
clientName: clientName,
|
|
94
143
|
serverUrl: serverUrl,
|
|
@@ -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/ClientClass.js","../../../../../../../../packages/templates/clients/websocket/javascript/template/client.js.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function Constructor({ serverUrl }) {\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}\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';\nimport { Constructor } from './Constructor';\nimport { CloseConnection, RegisterMessageHandler, RegisterErrorHandler, SendOperations, Connect, HandleMessage } from '@asyncapi/generator-components';\nimport { ModuleExport } from './ModuleExport';\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} />\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 <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 return (\n <File name={params.clientFileName}>\n <FileHeaderInfo\n info={info}\n server={server}\n language=\"javascript\"\n />\n <DependencyProvider
|
|
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":"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"}
|
|
@@ -2,14 +2,15 @@ import { Text } from '@asyncapi/generator-react-sdk';
|
|
|
2
2
|
import { Constructor } from './Constructor';
|
|
3
3
|
import { CloseConnection, RegisterMessageHandler, RegisterErrorHandler, SendOperations, Connect, HandleMessage } from '@asyncapi/generator-components';
|
|
4
4
|
import { ModuleExport } from './ModuleExport';
|
|
5
|
+
import { CompileOperationSchemas } from './CompileOperationSchemas';
|
|
5
6
|
|
|
6
|
-
export function ClientClass({ clientName, serverUrl, title, sendOperations}) {
|
|
7
|
+
export function ClientClass({ clientName, serverUrl, title, sendOperations }) {
|
|
7
8
|
return (
|
|
8
9
|
<Text>
|
|
9
10
|
<Text newLines={2}>
|
|
10
11
|
{`class ${clientName} {`}
|
|
11
12
|
</Text>
|
|
12
|
-
<Constructor serverUrl={serverUrl} />
|
|
13
|
+
<Constructor serverUrl={serverUrl} sendOperations={sendOperations} />
|
|
13
14
|
<Connect language="javascript" title={title} />
|
|
14
15
|
<RegisterMessageHandler
|
|
15
16
|
language="javascript"
|
|
@@ -23,6 +24,7 @@ export function ClientClass({ clientName, serverUrl, title, sendOperations}) {
|
|
|
23
24
|
language="javascript"
|
|
24
25
|
methodParams={['message', 'cb']}
|
|
25
26
|
/>
|
|
27
|
+
<CompileOperationSchemas sendOperations={sendOperations} />
|
|
26
28
|
<SendOperations
|
|
27
29
|
language="javascript"
|
|
28
30
|
sendOperations={sendOperations}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Text } from '@asyncapi/generator-react-sdk';
|
|
2
|
+
|
|
3
|
+
export function CompileOperationSchemas({ sendOperations }) {
|
|
4
|
+
if (!sendOperations || sendOperations.length === 0) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<Text indent={2} newLines={2}>
|
|
11
|
+
{
|
|
12
|
+
`/**
|
|
13
|
+
* Initialize and compile all schemas for operations defined.
|
|
14
|
+
* This should be called once after creating the client instance.
|
|
15
|
+
* Subsequent calls will be ignored if schemas are already compiled.
|
|
16
|
+
*
|
|
17
|
+
* @returns {Promise<void>}
|
|
18
|
+
* @throws {Error} If schema compilation fails for any operation
|
|
19
|
+
*/
|
|
20
|
+
async compileOperationSchemas() {
|
|
21
|
+
if (this.schemasCompiled) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
// Compile schemas for all send operations
|
|
27
|
+
for (const operationId of this.sendOperationsId) {
|
|
28
|
+
this.compiledSchemas[operationId] = await compileSchemasByOperationId(asyncapiFilepath, operationId);
|
|
29
|
+
}
|
|
30
|
+
this.schemasCompiled = true;
|
|
31
|
+
console.log('Schemas initialized successfully for operations:', this.sendOperationsId.join(', '));
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('Error initializing schemas:', error);
|
|
34
|
+
}
|
|
35
|
+
}`
|
|
36
|
+
}
|
|
37
|
+
</Text>
|
|
38
|
+
</>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Text } from '@asyncapi/generator-react-sdk';
|
|
2
2
|
|
|
3
|
-
export function Constructor({ serverUrl }) {
|
|
3
|
+
export function Constructor({ serverUrl, sendOperations }) {
|
|
4
|
+
const sendOperationsId = sendOperations.map((operation) => operation.id());
|
|
5
|
+
const sendOperationsArray = JSON.stringify(sendOperationsId);
|
|
6
|
+
|
|
4
7
|
return (
|
|
5
8
|
<Text indent={2}>
|
|
6
9
|
{
|
|
@@ -13,6 +16,9 @@ constructor(url) {
|
|
|
13
16
|
this.websocket = null;
|
|
14
17
|
this.messageHandlers = [];
|
|
15
18
|
this.errorHandlers = [];
|
|
19
|
+
this.compiledSchemas = {};
|
|
20
|
+
this.schemasCompiled = false;
|
|
21
|
+
this.sendOperationsId = ${sendOperationsArray};
|
|
16
22
|
}
|
|
17
23
|
`
|
|
18
24
|
}
|
package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/package.json
CHANGED
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
"author": "Lukasz Gornicki <lpgornicki@gmail.com>",
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@asyncapi/generator-react-sdk": "*",
|
|
15
14
|
"@asyncapi/generator-helpers": "0.2.0",
|
|
16
|
-
"@asyncapi/generator-
|
|
15
|
+
"@asyncapi/generator-react-sdk": "*",
|
|
16
|
+
"@asyncapi/generator-components": "0.3.1",
|
|
17
|
+
"@asyncapi/keeper": "0.5.0"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"@asyncapi/parser": "^3.0.14",
|
|
@@ -21,25 +22,11 @@
|
|
|
21
22
|
"@babel/core": "^7.26.0",
|
|
22
23
|
"@babel/preset-env": "^7.26.0",
|
|
23
24
|
"@babel/preset-react": "^7.25.9",
|
|
24
|
-
"jest-esm-transformer": "^1.0.0",
|
|
25
25
|
"eslint": "^6.8.0",
|
|
26
26
|
"eslint-plugin-jest": "^23.8.2",
|
|
27
27
|
"eslint-plugin-react": "^7.34.1",
|
|
28
|
-
"eslint-plugin-sonarjs": "^0.5.0"
|
|
29
|
-
|
|
30
|
-
"jest": {
|
|
31
|
-
"moduleFileExtensions": [
|
|
32
|
-
"js",
|
|
33
|
-
"json",
|
|
34
|
-
"jsx"
|
|
35
|
-
],
|
|
36
|
-
"transform": {
|
|
37
|
-
"^.+\\.jsx?$": "babel-jest"
|
|
38
|
-
},
|
|
39
|
-
"moduleNameMapper": {
|
|
40
|
-
"^nimma/legacy$": "<rootDir>/../../../../../node_modules/nimma/dist/legacy/cjs/index.js",
|
|
41
|
-
"^nimma/(.*)": "<rootDir>/../../../../../node_modules/nimma/dist/cjs/$1"
|
|
42
|
-
}
|
|
28
|
+
"eslint-plugin-sonarjs": "^0.5.0",
|
|
29
|
+
"jest-esm-transformer": "^1.0.0"
|
|
43
30
|
},
|
|
44
31
|
"babel": {
|
|
45
32
|
"presets": [
|
|
@@ -10,6 +10,7 @@ export default function ({ asyncapi, params }) {
|
|
|
10
10
|
const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);
|
|
11
11
|
const serverUrl = getServerUrl(server);
|
|
12
12
|
const sendOperations = asyncapi.operations().filterBySend();
|
|
13
|
+
const asyncapiFilepath = `${params.asyncapiFileDir}/asyncapi.yaml`;
|
|
13
14
|
return (
|
|
14
15
|
<File name={params.clientFileName}>
|
|
15
16
|
<FileHeaderInfo
|
|
@@ -17,7 +18,10 @@ export default function ({ asyncapi, params }) {
|
|
|
17
18
|
server={server}
|
|
18
19
|
language="javascript"
|
|
19
20
|
/>
|
|
20
|
-
<DependencyProvider
|
|
21
|
+
<DependencyProvider
|
|
22
|
+
language="javascript"
|
|
23
|
+
additionalDependencies={['const path = require(\'path\');', `const asyncapiFilepath = path.resolve(__dirname, '${asyncapiFilepath}');`]}
|
|
24
|
+
/>
|
|
21
25
|
<ClientClass clientName={clientName} serverUrl={serverUrl} title={title} sendOperations={sendOperations} />
|
|
22
26
|
</File>
|
|
23
27
|
);
|
|
@@ -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/websocket/python/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,iCAAiC,CAAC,CAAA;AAE7DC,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;;"}
|
|
@@ -27,20 +27,6 @@
|
|
|
27
27
|
"eslint-plugin-react": "^7.34.1",
|
|
28
28
|
"eslint-plugin-sonarjs": "^0.5.0"
|
|
29
29
|
},
|
|
30
|
-
"jest": {
|
|
31
|
-
"moduleFileExtensions": [
|
|
32
|
-
"js",
|
|
33
|
-
"json",
|
|
34
|
-
"jsx"
|
|
35
|
-
],
|
|
36
|
-
"transform": {
|
|
37
|
-
"^.+\\.jsx?$": "babel-jest"
|
|
38
|
-
},
|
|
39
|
-
"moduleNameMapper": {
|
|
40
|
-
"^nimma/legacy$": "<rootDir>/../../../../../node_modules/nimma/dist/legacy/cjs/index.js",
|
|
41
|
-
"^nimma/(.*)": "<rootDir>/../../../../../node_modules/nimma/dist/cjs/$1"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
30
|
"babel": {
|
|
45
31
|
"presets": [
|
|
46
32
|
"@babel/preset-env",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asyncapi/generator",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "The AsyncAPI generator. It can generate documentation, code, anything!",
|
|
5
5
|
"main": "./lib/generator.js",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"test:integration": "npm run test:cleanup && jest --testPathPattern=integration --modulePathIgnorePatterns='./__mocks__(?!\\/loglevel\\.js$)'",
|
|
19
19
|
"test:integration:update": "npm run test:integration -- -u",
|
|
20
20
|
"test:cleanup": "rimraf \"test/temp\"",
|
|
21
|
-
"docs": "jsdoc2md --partial docs/jsdoc2md-handlebars
|
|
21
|
+
"docs": "jsdoc2md --partial \"docs/jsdoc2md-handlebars/**/*.hbs\" --files lib/generator.js > docs/api.md",
|
|
22
22
|
"docker:build": "docker build -t asyncapi/generator:latest .",
|
|
23
23
|
"lint": "eslint --max-warnings 0 --config ../../.eslintrc --ignore-path ../../.eslintignore .",
|
|
24
24
|
"lint:fix": "npm run lint -- --fix",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"fs.extra": "^1.3.2",
|
|
69
69
|
"global-dirs": "^3.0.0",
|
|
70
70
|
"jmespath": "^0.15.0",
|
|
71
|
-
"js-yaml": "^
|
|
71
|
+
"js-yaml": "^4.1.1",
|
|
72
72
|
"levenshtein-edit-distance": "^2.0.5",
|
|
73
73
|
"loglevel": "^1.6.8",
|
|
74
74
|
"minimatch": "^3.0.4",
|