@asyncapi/generator 2.7.1 → 2.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/docs/api.md +32 -0
- package/docs/baked-in-templates.md +100 -0
- package/docs/configuration-file.md +49 -31
- package/docs/template.md +22 -3
- package/lib/generator.js +31 -3
- package/lib/templates/BakedInTemplatesList.json +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/.ageneratorrc +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/README.md +12 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/ClientClass.js +42 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/ClientClass.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/ClientFields.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/ClientFields.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/Connect.js +60 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/Connect.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/Constructor.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/Constructor.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/HandleMessage.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/HandleMessage.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/RegisterErrorHandler.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/RegisterErrorHandler.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/SendEchoMessage.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/components/SendEchoMessage.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/template/client.dart.js +181 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/template/client.dart.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/template/pubspec.yaml.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/__transpiled/template/pubspec.yaml.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/ClientClass.js +32 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/ClientFields.js +12 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/Connect.js +49 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/Constructor.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/HandleMessage.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/RegisterErrorHandler.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/components/SendEchoMessage.js +20 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/example.dart +36 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/package.json +54 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/template/client.dart.js +24 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-dart/template/pubspec.yaml.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/.ageneratorrc +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/README.md +28 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ClientConnector.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ClientConnector.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ClientFields.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ClientFields.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ConnectorFields.js +22 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/ConnectorFields.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/EchoWebSocket.js +40 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/EchoWebSocket.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/HandleError.js +20 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/HandleError.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/InitConnector.js +47 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/InitConnector.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnClose.js +23 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnClose.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnOpen.js +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnOpen.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnTextMessageHandler.js +29 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/OnTextMessageHandler.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/dependencies/ClientDependencies.js +29 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/dependencies/ClientDependencies.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/dependencies/ConnectorDependencies.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/components/dependencies/ConnectorDependencies.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/client.java.js +154 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/client.java.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/connector.java.js +108 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/connector.java.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/models/model.js +52 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/java/com/asyncapi/models/model.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/resources/AppProperties.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/__transpiled/template/src/main/resources/AppProperties.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/ClientConnector.js +17 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/ClientFields.js +10 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/ConnectorFields.js +11 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/EchoWebSocket.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/HandleError.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/InitConnector.js +41 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/OnClose.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/OnOpen.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/OnTextMessageHandler.js +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/dependencies/ClientDependencies.js +23 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/components/dependencies/ConnectorDependencies.js +20 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/package.json +63 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/.dockerignore +5 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/.mvn/wrapper/MavenWrapperDownloader.java +93 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/.mvn/wrapper/maven-wrapper.properties +20 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/README.md +58 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/mvnw +332 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/mvnw.cmd +206 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/pom.xml +125 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/src/main/docker/Dockerfile.jvm +98 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/src/main/java/com/asyncapi/client.java.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/src/main/java/com/asyncapi/connector.java.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/src/main/java/com/asyncapi/models/model.js +36 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-java-quarkus/template/src/main/resources/AppProperties.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/.ageneratorrc +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/README.md +10 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/AvailableOperations.js +34 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/AvailableOperations.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ClientClass.js +47 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ClientClass.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Connect.js +63 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Connect.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Constructor.js +29 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/Constructor.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/HandleMessage.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/HandleMessage.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/MessageExamples.js +29 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/MessageExamples.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ModuleExport.js +18 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/ModuleExport.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/OperationHeader.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/OperationHeader.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/RegisterErrorHandler.js +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/RegisterErrorHandler.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/SendOperation.js +53 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/components/SendOperation.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/example.js +43 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/example.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/README.md.js +166 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/README.md.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/client.js.js +216 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/__transpiled/template/client.js.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/AvailableOperations.js +20 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/ClientClass.js +32 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/Connect.js +54 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/Constructor.js +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/HandleMessage.js +14 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/MessageExamples.js +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/ModuleExport.js +11 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/OperationHeader.js +12 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/RegisterErrorHandler.js +18 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/components/SendOperation.js +44 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/example.js +42 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/package.json +54 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/template/README.md.js +106 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-javascript/template/client.js.js +24 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/.ageneratorrc +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/README.md +53 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/ClientClass.js +61 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/ClientClass.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Connect.js +58 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Connect.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Constructor.js +55 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Constructor.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/HandleError.js +25 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/HandleError.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/HandleMessage.js +24 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/HandleMessage.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/InitSignature.js +34 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/InitSignature.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/QueryParamsArgumentsDocs.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/QueryParamsArgumentsDocs.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/QueryParamsVariables.js +36 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/QueryParamsVariables.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/RegisterErrorHandler.js +23 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/RegisterErrorHandler.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/RegisterOutgoingProcessor.js +26 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/RegisterOutgoingProcessor.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Requires.js +24 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Requires.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Send.js +41 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/Send.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/SendOperation.js +56 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/components/SendOperation.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/client.py.js +379 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/client.py.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/models.js +15 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/models.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/requirements.txt.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/__transpiled/template/requirements.txt.js.map +1 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/ClientClass.js +47 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/Connect.js +49 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/Constructor.js +42 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/HandleError.js +18 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/HandleMessage.js +17 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/InitSignature.js +24 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/QueryParamsArgumentsDocs.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/QueryParamsVariables.js +27 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/RegisterErrorHandler.js +16 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/RegisterOutgoingProcessor.js +19 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/Requires.js +15 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/Send.js +33 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/components/SendOperation.js +50 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/example-slack.py +21 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/example.py +41 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/package.json +54 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/template/client.py.js +23 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/template/models.js +5 -0
- package/lib/templates/bakedInTemplates/core-template-client-websocket-python/template/requirements.txt.js +13 -0
- package/lib/templates/bakedInTemplates.js +53 -0
- package/package.json +8 -3
- package/test/__mocks__/@npmcli/arborist.js +0 -11
- package/test/__mocks__/@npmcli/config.js +0 -3
- package/test/__mocks__/fs.extra.js +0 -3
- package/test/__mocks__/loglevel.js +0 -3
- package/test/__mocks__/resolve-from.js +0 -8
- package/test/__mocks__/resolve-pkg.js +0 -8
- package/test/__snapshots__/integration.test.js.snap +0 -419
- package/test/docs/apiwithref.json +0 -41
- package/test/docs/dummy.yml +0 -390
- package/test/docs/dummyV3.yml +0 -31
- package/test/docs/shared.json +0 -27
- package/test/docs/ws.yml +0 -36
- package/test/generator.test.js +0 -629
- package/test/hooksRegistry.test.js +0 -173
- package/test/integration.test.js +0 -203
- package/test/parser.test.js +0 -205
- package/test/renderer.test.js +0 -62
- package/test/templateConfigValidator.test.js +0 -294
- package/test/test-project/.yarncr.yml +0 -3
- package/test/test-project/README.md +0 -8
- package/test/test-project/docker-compose.yml +0 -16
- package/test/test-project/package.json +0 -24
- package/test/test-project/test-global.test.js +0 -37
- package/test/test-project/test-project.test.js +0 -102
- package/test/test-project/test-registry.test.js +0 -62
- package/test/test-project/test.sh +0 -104
- package/test/test-project/verdaccio/config.yaml +0 -22
- package/test/test-project/verdaccio/htpasswd +0 -1
- package/test/test-templates/nunjucks-template/package-lock.json +0 -4062
- package/test/test-templates/nunjucks-template/package.json +0 -21
- package/test/test-templates/nunjucks-template/template/test-file.md +0 -5
- package/test/test-templates/react-template/.ageneratorrc +0 -33
- package/test/test-templates/react-template/package.json +0 -14
- package/test/test-templates/react-template/template/conditionalFile.txt +0 -0
- package/test/test-templates/react-template/template/conditionalFolder/conditionalFile.txt +0 -0
- package/test/test-templates/react-template/template/conditionalFolder2/input.txt +0 -0
- package/test/test-templates/react-template/template/models.js +0 -6
- package/test/test-templates/react-template/template/test-file.md.js +0 -11
- package/test/utils.test.js +0 -129
|
@@ -0,0 +1,63 @@
|
|
|
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 Connect({
|
|
10
|
+
title
|
|
11
|
+
}) {
|
|
12
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
13
|
+
newLines: 2,
|
|
14
|
+
indent: 2,
|
|
15
|
+
children: `// Method to establish a WebSocket connection
|
|
16
|
+
connect() {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
this.websocket = new WebSocket(this.url);
|
|
19
|
+
|
|
20
|
+
// On successful connection
|
|
21
|
+
this.websocket.onopen = () => {
|
|
22
|
+
console.log('Connected to ${title} server');
|
|
23
|
+
resolve();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// On receiving a message
|
|
27
|
+
this.websocket.onmessage = (event) => {
|
|
28
|
+
if (this.messageHandlers.length > 0) {
|
|
29
|
+
// Call custom message handlers
|
|
30
|
+
this.messageHandlers.forEach(handler => {
|
|
31
|
+
if (typeof handler === 'function') {
|
|
32
|
+
this.handleMessage(event.data, handler);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
// Default message logging
|
|
37
|
+
console.log('Message received:', event.data);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// On error first call custom error handlers, then default error behavior
|
|
42
|
+
this.websocket.onerror = (error) => {
|
|
43
|
+
if (this.errorHandlers.length > 0) {
|
|
44
|
+
// Call custom error handlers
|
|
45
|
+
this.errorHandlers.forEach(handler => handler(error));
|
|
46
|
+
} else {
|
|
47
|
+
// Default error behavior
|
|
48
|
+
console.error('WebSocket Error:', error);
|
|
49
|
+
}
|
|
50
|
+
reject(error);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// On connection close
|
|
54
|
+
this.websocket.onclose = () => {
|
|
55
|
+
console.log('Disconnected from ${title} server');
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}`
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.Connect = Connect;
|
|
63
|
+
//# sourceMappingURL=Connect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connect.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/Connect.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function Connect({ title }) {\n return (\n <Text newLines={2} indent={2}>\n {\n `// Method to establish a WebSocket connection\nconnect() {\n return new Promise((resolve, reject) => {\n this.websocket = new WebSocket(this.url);\n\n // On successful connection\n this.websocket.onopen = () => {\n console.log('Connected to ${title} server');\n resolve();\n };\n\n // On receiving a message\n this.websocket.onmessage = (event) => {\n if (this.messageHandlers.length > 0) {\n // Call custom message handlers\n this.messageHandlers.forEach(handler => {\n if (typeof handler === 'function') {\n this.handleMessage(event.data, handler);\n }\n });\n } else {\n // Default message logging\n console.log('Message received:', event.data);\n }\n };\n\n // On error first call custom error handlers, then default error behavior\n this.websocket.onerror = (error) => {\n if (this.errorHandlers.length > 0) {\n // Call custom error handlers\n this.errorHandlers.forEach(handler => handler(error));\n } else {\n // Default error behavior\n console.error('WebSocket Error:', error);\n }\n reject(error);\n };\n\n // On connection close\n this.websocket.onclose = () => {\n console.log('Disconnected from ${title} server');\n };\n });\n}`\n }\n </Text>\n );\n}\n"],"names":["Connect","title","_jsx","Text","newLines","indent","children"],"mappings":";;;;;;;;AAEO,SAASA,OAAOA,CAAC;AAAEC,EAAAA,KAAAA;AAAM,CAAC,EAAE;EACjC,oBACEC,cAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,QAAQ,EAAE,CAAE;AAACC,IAAAA,MAAM,EAAE,CAAE;AAAAC,IAAAA,QAAA,EAEzB,CAAA;AACR;AACA;AACA;AACA;AACA;AACA;AACA,gCAAA,EAAkCL,KAAK,CAAA;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAA,EAAuCA,KAAK,CAAA;AAC5C;AACA;AACA,CAAA,CAAA;AAAE,GAEQ,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 Constructor({
|
|
10
|
+
serverUrl
|
|
11
|
+
}) {
|
|
12
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
13
|
+
indent: 2,
|
|
14
|
+
children: `/*
|
|
15
|
+
* Constructor to initialize the WebSocket client
|
|
16
|
+
* @param {string} url - The WebSocket server URL. Use it if the server URL is different from the default one taken from the AsyncAPI document.
|
|
17
|
+
*/
|
|
18
|
+
constructor(url) {
|
|
19
|
+
this.url = url || '${serverUrl}';
|
|
20
|
+
this.websocket = null;
|
|
21
|
+
this.messageHandlers = [];
|
|
22
|
+
this.errorHandlers = [];
|
|
23
|
+
}
|
|
24
|
+
`
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.Constructor = Constructor;
|
|
29
|
+
//# sourceMappingURL=Constructor.js.map
|
|
@@ -0,0 +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,SAAAA;AAAU,CAAC,EAAE;EACzC,oBACEC,cAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,MAAM,EAAE,CAAE;AAAAC,IAAAA,QAAA,EAEZ,CAAA;AACR;AACA;AACA;AACA;AACA,qBAAA,EAAuBJ,SAAS,CAAA;AAChC;AACA;AACA;AACA;AACA,CAAA;AAAC,GAES,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 HandleMessage() {
|
|
10
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
11
|
+
newLines: 2,
|
|
12
|
+
indent: 2,
|
|
13
|
+
children: `// Method to handle message with callback
|
|
14
|
+
handleMessage(message, cb) {
|
|
15
|
+
if (cb) cb(message);
|
|
16
|
+
}`
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.HandleMessage = HandleMessage;
|
|
21
|
+
//# sourceMappingURL=HandleMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HandleMessage.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/HandleMessage.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function HandleMessage() {\n return (\n <Text newLines={2} indent={2}>\n {\n `// Method to handle message with callback\nhandleMessage(message, cb) {\n if (cb) cb(message);\n}`\n }\n </Text>\n );\n}\n"],"names":["HandleMessage","_jsx","Text","newLines","indent","children"],"mappings":";;;;;;;;AAEO,SAASA,aAAaA,GAAG;EAC9B,oBACEC,cAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,QAAQ,EAAE,CAAE;AAACC,IAAAA,MAAM,EAAE,CAAE;AAAAC,IAAAA,QAAA,EAEzB,CAAA;AACR;AACA;AACA,CAAA,CAAA;AAAE,GAEQ,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
var generatorHelpers = require('@asyncapi/generator-helpers');
|
|
5
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
6
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
7
|
+
|
|
8
|
+
function MessageExamples({
|
|
9
|
+
operation
|
|
10
|
+
}) {
|
|
11
|
+
const operationId = operation.id();
|
|
12
|
+
const messageExamples = [];
|
|
13
|
+
const messages = generatorHelpers.getOperationMessages(operation) || [];
|
|
14
|
+
messages.forEach(message => {
|
|
15
|
+
const examples = generatorHelpers.getMessageExamples(message) || [];
|
|
16
|
+
examples.forEach(example => {
|
|
17
|
+
const payload = example.payload();
|
|
18
|
+
messageExamples.push(`\n\n**Example:**\n\`\`\`javascript\nclient.${operationId}(${JSON.stringify(payload, null, 2)});\n\`\`\``);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
22
|
+
children: messageExamples.map(example => /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
23
|
+
children: example
|
|
24
|
+
}))
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = MessageExamples;
|
|
29
|
+
//# sourceMappingURL=MessageExamples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageExamples.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/MessageExamples.js"],"sourcesContent":["import { getMessageExamples, getOperationMessages } from '@asyncapi/generator-helpers';\nimport { Text } from '@asyncapi/generator-react-sdk';\n\nexport default function MessageExamples({operation}) {\n const operationId = operation.id();\n const messageExamples = [];\n const messages = getOperationMessages(operation) || [];\n\n messages.forEach((message) => {\n const examples = getMessageExamples(message) || [];\n examples.forEach((example) => {\n const payload = example.payload();\n messageExamples.push(`\\n\\n**Example:**\\n\\`\\`\\`javascript\\nclient.${operationId}(${JSON.stringify(payload, null, 2)});\\n\\`\\`\\``);\n });\n });\n return (\n <Text>\n {messageExamples.map(example => (\n <Text>\n {example}\n </Text>\n ))}\n </Text>\n );\n}"],"names":["MessageExamples","operation","operationId","id","messageExamples","messages","getOperationMessages","forEach","message","examples","getMessageExamples","example","payload","push","JSON","stringify","_jsx","Text","children","map"],"mappings":";;;;;;;AAGe,SAASA,eAAeA,CAAC;AAACC,EAAAA,SAAAA;AAAS,CAAC,EAAE;AACnD,EAAA,MAAMC,WAAW,GAAGD,SAAS,CAACE,EAAE,EAAE,CAAA;EAClC,MAAMC,eAAe,GAAG,EAAE,CAAA;AAC1B,EAAA,MAAMC,QAAQ,GAAGC,qCAAoB,CAACL,SAAS,CAAC,IAAI,EAAE,CAAA;AAEtDI,EAAAA,QAAQ,CAACE,OAAO,CAAEC,OAAO,IAAK;AAC5B,IAAA,MAAMC,QAAQ,GAAGC,mCAAkB,CAACF,OAAO,CAAC,IAAI,EAAE,CAAA;AAClDC,IAAAA,QAAQ,CAACF,OAAO,CAAEI,OAAO,IAAK;AAC5B,MAAA,MAAMC,OAAO,GAAGD,OAAO,CAACC,OAAO,EAAE,CAAA;AACjCR,MAAAA,eAAe,CAACS,IAAI,CAAC,CAA8CX,2CAAAA,EAAAA,WAAW,IAAIY,IAAI,CAACC,SAAS,CAACH,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,CAAA;AACjI,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;EACF,oBACEI,cAAA,CAACC,sBAAI,EAAA;IAAAC,QAAA,EACFd,eAAe,CAACe,GAAG,CAACR,OAAO,iBAC1BK,cAAA,CAACC,sBAAI,EAAA;AAAAC,MAAAA,QAAA,EACFP,OAAAA;AAAO,KACJ,CACP,CAAA;AAAC,GACE,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 ModuleExport({
|
|
10
|
+
clientName
|
|
11
|
+
}) {
|
|
12
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
13
|
+
children: `module.exports = ${clientName};`
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.ModuleExport = ModuleExport;
|
|
18
|
+
//# sourceMappingURL=ModuleExport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleExport.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/ModuleExport.js"],"sourcesContent":["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"],"names":["ModuleExport","clientName","_jsx","Text","children"],"mappings":";;;;;;;;AAEO,SAASA,YAAYA,CAAC;AAAEC,EAAAA,UAAAA;AAAW,CAAC,EAAE;EAC3C,oBACEC,cAAA,CAACC,sBAAI,EAAA;IAAAC,QAAA,EAED,oBAAoBH,UAAU,CAAA,CAAA,CAAA;AAAG,GAE/B,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
5
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
6
|
+
|
|
7
|
+
function OperationHeader({
|
|
8
|
+
operation
|
|
9
|
+
}) {
|
|
10
|
+
const operationId = operation.id();
|
|
11
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
12
|
+
children: `#### \`${operationId}(payload)\`
|
|
13
|
+
${operation.hasSummary() ? operation.summary() : ''}
|
|
14
|
+
${operation.hasDescription() ? `\n${operation.description()}` : ''}`
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = OperationHeader;
|
|
19
|
+
//# sourceMappingURL=OperationHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationHeader.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/OperationHeader.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport default function OperationHeader({operation}) {\n const operationId = operation.id();\n return (\n <Text>\n {`#### \\`${operationId}(payload)\\`\n${operation.hasSummary() ? operation.summary() : ''}\n${operation.hasDescription() ? `\\n${operation.description()}` : ''}`}\n </Text>\n );\n}"],"names":["OperationHeader","operation","operationId","id","_jsx","Text","children","hasSummary","summary","hasDescription","description"],"mappings":";;;;;;AAEe,SAASA,eAAeA,CAAC;AAACC,EAAAA,SAAAA;AAAS,CAAC,EAAE;AACnD,EAAA,MAAMC,WAAW,GAAGD,SAAS,CAACE,EAAE,EAAE,CAAA;EAClC,oBACEC,cAAA,CAACC,sBAAI,EAAA;IAAAC,QAAA,EACF,UAAUJ,WAAW,CAAA;AAC5B,EAAED,SAAS,CAACM,UAAU,EAAE,GAAIN,SAAS,CAACO,OAAO,EAAE,GAAG,EAAE,CAAA;AACpD,EAAEP,SAAS,CAACQ,cAAc,EAAE,GAAG,CAAA,EAAA,EAAKR,SAAS,CAACS,WAAW,EAAE,CAAA,CAAE,GAAG,EAAE,CAAA,CAAA;AAAE,GAC1D,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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 RegisterErrorHandler() {
|
|
10
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
11
|
+
newLines: 2,
|
|
12
|
+
indent: 2,
|
|
13
|
+
children: `// Method to register custom error handlers
|
|
14
|
+
registerErrorHandler(handler) {
|
|
15
|
+
if (typeof handler === 'function') {
|
|
16
|
+
this.errorHandlers.push(handler);
|
|
17
|
+
} else {
|
|
18
|
+
console.warn('Error handler must be a function');
|
|
19
|
+
}
|
|
20
|
+
}`
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.RegisterErrorHandler = RegisterErrorHandler;
|
|
25
|
+
//# sourceMappingURL=RegisterErrorHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegisterErrorHandler.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/RegisterErrorHandler.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function RegisterErrorHandler() {\n return (\n <Text newLines={2} indent={2}>\n {\n `// Method to register custom error handlers\nregisterErrorHandler(handler) {\n if (typeof handler === 'function') {\n this.errorHandlers.push(handler);\n } else {\n console.warn('Error handler must be a function');\n }\n}`\n }\n </Text>\n );\n}\n"],"names":["RegisterErrorHandler","_jsx","Text","newLines","indent","children"],"mappings":";;;;;;;;AAEO,SAASA,oBAAoBA,GAAG;EACrC,oBACEC,cAAA,CAACC,sBAAI,EAAA;AAACC,IAAAA,QAAQ,EAAE,CAAE;AAACC,IAAAA,MAAM,EAAE,CAAE;AAAAC,IAAAA,QAAA,EAEzB,CAAA;AACR;AACA;AACA;AACA;AACA;AACA;AACA,CAAA,CAAA;AAAE,GAEQ,CAAC,CAAA;AAEX;;;;"}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 SendOperation({
|
|
10
|
+
sendOperations,
|
|
11
|
+
clientName
|
|
12
|
+
}) {
|
|
13
|
+
if (!sendOperations || sendOperations.length === 0) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
17
|
+
children: sendOperations.map(operation => /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
18
|
+
newLines: 2,
|
|
19
|
+
indent: 2,
|
|
20
|
+
children: `
|
|
21
|
+
/**
|
|
22
|
+
* Sends a ${operation.id()} message over the WebSocket connection.
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} message - The message payload to send. Should match the schema defined in the AsyncAPI document.
|
|
25
|
+
* @param {WebSocket} [socket] - The WebSocket connection to use. If not provided, the client's own connection will be used.
|
|
26
|
+
* @throws {TypeError} If message cannot be stringified to JSON
|
|
27
|
+
* @throws {Error} If WebSocket connection is not in OPEN state
|
|
28
|
+
*/
|
|
29
|
+
static ${operation.id()}(message, socket) {
|
|
30
|
+
try {
|
|
31
|
+
socket.send(JSON.stringify(message));
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('Error sending ${operation.id()} message:', error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Instance method version of ${operation.id()} that uses the client's own WebSocket connection.
|
|
38
|
+
* @param {Object} message - The message payload to send
|
|
39
|
+
* @throws {Error} If WebSocket connection is not established
|
|
40
|
+
*/
|
|
41
|
+
${operation.id()}(message){
|
|
42
|
+
if(!this.websocket){
|
|
43
|
+
throw new Error('WebSocket connection not established. Call connect() first.');
|
|
44
|
+
}
|
|
45
|
+
${clientName}.${operation.id()}(message, this.websocket);
|
|
46
|
+
}
|
|
47
|
+
`
|
|
48
|
+
}))
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.SendOperation = SendOperation;
|
|
53
|
+
//# sourceMappingURL=SendOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SendOperation.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/SendOperation.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport function SendOperation({ sendOperations, clientName }) {\n if (!sendOperations || sendOperations.length === 0) {\n return null;\n }\n\n return (\n <>\n {sendOperations.map((operation) => (\n <Text newLines={2} indent={2}>\n {`\n/**\n * Sends a ${operation.id()} message over the WebSocket connection.\n * \n * @param {Object} message - The message payload to send. Should match the schema defined in the AsyncAPI document.\n * @param {WebSocket} [socket] - The WebSocket connection to use. If not provided, the client's own connection will be used.\n * @throws {TypeError} If message cannot be stringified to JSON\n * @throws {Error} If WebSocket connection is not in OPEN state\n */\nstatic ${operation.id()}(message, socket) {\n try {\n socket.send(JSON.stringify(message));\n } catch (error) {\n console.error('Error sending ${operation.id()} message:', error);\n }\n}\n/**\n * Instance method version of ${operation.id()} that uses the client's own WebSocket connection.\n * @param {Object} message - The message payload to send\n * @throws {Error} If WebSocket connection is not established\n */\n${operation.id()}(message){\n if(!this.websocket){\n throw new Error('WebSocket connection not established. Call connect() first.');\n }\n ${clientName}.${operation.id()}(message, this.websocket);\n}\n `}\n </Text>\n ))}\n </>\n );\n}\n"],"names":["SendOperation","sendOperations","clientName","length","_jsx","_Fragment","children","map","operation","Text","newLines","indent","id"],"mappings":";;;;;;;;AAEO,SAASA,aAAaA,CAAC;EAAEC,cAAc;AAAEC,EAAAA,UAAAA;AAAW,CAAC,EAAE;EAC5D,IAAI,CAACD,cAAc,IAAIA,cAAc,CAACE,MAAM,KAAK,CAAC,EAAE;AAClD,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;EAEA,oBACEC,cAAA,CAAAC,mBAAA,EAAA;IAAAC,QAAA,EACGL,cAAc,CAACM,GAAG,CAAEC,SAAS,iBAC5BJ,cAAA,CAACK,sBAAI,EAAA;AAACC,MAAAA,QAAQ,EAAE,CAAE;AAACC,MAAAA,MAAM,EAAE,CAAE;AAAAL,MAAAA,QAAA,EAC1B,CAAA;AACX;AACA,WAAA,EAAaE,SAAS,CAACI,EAAE,EAAE,CAAA;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA,OAAA,EAASJ,SAAS,CAACI,EAAE,EAAE,CAAA;AACvB;AACA;AACA;AACA,iCAAA,EAAmCJ,SAAS,CAACI,EAAE,EAAE,CAAA;AACjD;AACA;AACA;AACA,8BAAA,EAAgCJ,SAAS,CAACI,EAAE,EAAE,CAAA;AAC9C;AACA;AACA;AACA,EAAEJ,SAAS,CAACI,EAAE,EAAE,CAAA;AAChB;AACA;AACA;AACA,EAAA,EAAIV,UAAU,CAAIM,CAAAA,EAAAA,SAAS,CAACI,EAAE,EAAE,CAAA;AAChC;AACA,EAAA,CAAA;AAAG,KACW,CACP,CAAA;AAAC,GACF,CAAC,CAAA;AAEP;;;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
|
|
5
|
+
const WSClient = require('./test/temp/snapshotTestResult/custom_client_hoppscotch/client.js');
|
|
6
|
+
// Example usage
|
|
7
|
+
const wsClient = new WSClient();
|
|
8
|
+
|
|
9
|
+
// Example of how custom message handler that operates on incoming messages can look like
|
|
10
|
+
function myHandler(message) {
|
|
11
|
+
console.log('====================');
|
|
12
|
+
console.log('Just proving I got the message in myHandler:', message);
|
|
13
|
+
console.log('====================');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Example of custom error handler
|
|
17
|
+
function myErrorHandler(error) {
|
|
18
|
+
console.error('Errors from Websocket:', error.message);
|
|
19
|
+
}
|
|
20
|
+
async function main() {
|
|
21
|
+
wsClient.registerMessageHandler(myHandler);
|
|
22
|
+
wsClient.registerErrorHandler(myErrorHandler);
|
|
23
|
+
try {
|
|
24
|
+
await wsClient.connect();
|
|
25
|
+
|
|
26
|
+
// Loop to send messages every 5 seconds
|
|
27
|
+
const interval = 5000; // 5 seconds
|
|
28
|
+
const message = 'Hello, Echo!';
|
|
29
|
+
while (true) {
|
|
30
|
+
try {
|
|
31
|
+
await wsClient.sendEchoMessage(message);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('Error while sending message:', error);
|
|
34
|
+
}
|
|
35
|
+
// Wait for the interval before sending the next message
|
|
36
|
+
await new Promise(resolve => setTimeout(resolve, interval));
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error('Failed to connect to WebSocket:', error.message);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
main();
|
|
43
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","sources":["../../../../../../../packages/templates/clients/websocket/javascript/example.js"],"sourcesContent":["const WSClient = require('./test/temp/snapshotTestResult/custom_client_hoppscotch/client.js');\n// Example usage\nconst wsClient = new WSClient();\n\n// Example of how custom message handler that operates on incoming messages can look like\nfunction myHandler(message) {\n console.log('====================');\n console.log('Just proving I got the message in myHandler:', message);\n console.log('====================');\n}\n\n// Example of custom error handler\nfunction myErrorHandler(error) {\n console.error('Errors from Websocket:', error.message);\n}\n\nasync function main() {\n wsClient.registerMessageHandler(myHandler);\n wsClient.registerErrorHandler(myErrorHandler);\n\n try {\n await wsClient.connect();\n\n // Loop to send messages every 5 seconds\n const interval = 5000; // 5 seconds\n const message = 'Hello, Echo!';\n\n while (true) {\n try {\n await wsClient.sendEchoMessage(message);\n } catch (error) {\n console.error('Error while sending message:', error);\n }\n // Wait for the interval before sending the next message\n await new Promise(resolve => setTimeout(resolve, interval));\n }\n } catch (error) {\n console.error('Failed to connect to WebSocket:', error.message);\n }\n}\n\nmain();\n"],"names":["WSClient","require","wsClient","myHandler","message","console","log","myErrorHandler","error","main","registerMessageHandler","registerErrorHandler","connect","interval","sendEchoMessage","Promise","resolve","setTimeout"],"mappings":";;;;AAAA,MAAMA,QAAQ,GAAGC,OAAO,CAAC,mEAAmE,CAAC,CAAA;AAC7F;AACA,MAAMC,QAAQ,GAAG,IAAIF,QAAQ,EAAE,CAAA;;AAE/B;AACA,SAASG,SAASA,CAACC,OAAO,EAAE;AAC1BC,EAAAA,OAAO,CAACC,GAAG,CAAC,sBAAsB,CAAC,CAAA;AACnCD,EAAAA,OAAO,CAACC,GAAG,CAAC,8CAA8C,EAAEF,OAAO,CAAC,CAAA;AACpEC,EAAAA,OAAO,CAACC,GAAG,CAAC,sBAAsB,CAAC,CAAA;AACrC,CAAA;;AAEA;AACA,SAASC,cAAcA,CAACC,KAAK,EAAE;EAC7BH,OAAO,CAACG,KAAK,CAAC,wBAAwB,EAAEA,KAAK,CAACJ,OAAO,CAAC,CAAA;AACxD,CAAA;AAEA,eAAeK,IAAIA,GAAG;AACpBP,EAAAA,QAAQ,CAACQ,sBAAsB,CAACP,SAAS,CAAC,CAAA;AAC1CD,EAAAA,QAAQ,CAACS,oBAAoB,CAACJ,cAAc,CAAC,CAAA;EAE7C,IAAI;AACF,IAAA,MAAML,QAAQ,CAACU,OAAO,EAAE,CAAA;;AAExB;AACA,IAAA,MAAMC,QAAQ,GAAG,IAAI,CAAC;IACtB,MAAMT,OAAO,GAAG,cAAc,CAAA;AAE9B,IAAA,OAAO,IAAI,EAAE;MACX,IAAI;AACF,QAAA,MAAMF,QAAQ,CAACY,eAAe,CAACV,OAAO,CAAC,CAAA;OACxC,CAAC,OAAOI,KAAK,EAAE;AACdH,QAAAA,OAAO,CAACG,KAAK,CAAC,8BAA8B,EAAEA,KAAK,CAAC,CAAA;AACtD,OAAA;AACA;MACA,MAAM,IAAIO,OAAO,CAACC,OAAO,IAAIC,UAAU,CAACD,OAAO,EAAEH,QAAQ,CAAC,CAAC,CAAA;AAC7D,KAAA;GACD,CAAC,OAAOL,KAAK,EAAE;IACdH,OAAO,CAACG,KAAK,CAAC,iCAAiC,EAAEA,KAAK,CAACJ,OAAO,CAAC,CAAA;AACjE,GAAA;AACF,CAAA;AAEAK,IAAI,EAAE;;"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('source-map-support/register');
|
|
4
|
+
var generatorReactSdk = require('@asyncapi/generator-react-sdk');
|
|
5
|
+
var generatorHelpers = require('@asyncapi/generator-helpers');
|
|
6
|
+
var jsxRuntime = require('/home/runner/work/generator/generator/node_modules/react/cjs/react-jsx-runtime.production.min.js');
|
|
7
|
+
|
|
8
|
+
function OperationHeader({
|
|
9
|
+
operation
|
|
10
|
+
}) {
|
|
11
|
+
const operationId = operation.id();
|
|
12
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
13
|
+
children: `#### \`${operationId}(payload)\`
|
|
14
|
+
${operation.hasSummary() ? operation.summary() : ''}
|
|
15
|
+
${operation.hasDescription() ? `\n${operation.description()}` : ''}`
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function MessageExamples({
|
|
20
|
+
operation
|
|
21
|
+
}) {
|
|
22
|
+
const operationId = operation.id();
|
|
23
|
+
const messageExamples = [];
|
|
24
|
+
const messages = generatorHelpers.getOperationMessages(operation) || [];
|
|
25
|
+
messages.forEach(message => {
|
|
26
|
+
const examples = generatorHelpers.getMessageExamples(message) || [];
|
|
27
|
+
examples.forEach(example => {
|
|
28
|
+
const payload = example.payload();
|
|
29
|
+
messageExamples.push(`\n\n**Example:**\n\`\`\`javascript\nclient.${operationId}(${JSON.stringify(payload, null, 2)});\n\`\`\``);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
return /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
33
|
+
children: messageExamples.map(example => /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
34
|
+
children: example
|
|
35
|
+
}))
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function AvailableOperations({
|
|
40
|
+
operations
|
|
41
|
+
}) {
|
|
42
|
+
if (!operations || operations.length === 0) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
46
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
47
|
+
newLines: 2,
|
|
48
|
+
children: "### Available Operations"
|
|
49
|
+
}), operations.map(operation => /*#__PURE__*/jsxRuntime.jsxs(generatorReactSdk.Text, {
|
|
50
|
+
newLines: 2,
|
|
51
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(OperationHeader, {
|
|
52
|
+
operation: operation
|
|
53
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MessageExamples, {
|
|
54
|
+
operation: operation
|
|
55
|
+
})]
|
|
56
|
+
}))]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function README_md ({
|
|
61
|
+
asyncapi,
|
|
62
|
+
params
|
|
63
|
+
}) {
|
|
64
|
+
const server = generatorHelpers.getServer(asyncapi.servers(), params.server);
|
|
65
|
+
const info = generatorHelpers.getInfo(asyncapi);
|
|
66
|
+
const clientName = generatorHelpers.getClientName(asyncapi, params.appendClientSuffix, params.customClientName);
|
|
67
|
+
const title = generatorHelpers.getTitle(asyncapi);
|
|
68
|
+
const serverUrl = generatorHelpers.getServerUrl(server);
|
|
69
|
+
const operations = asyncapi.operations().all();
|
|
70
|
+
return /*#__PURE__*/jsxRuntime.jsxs(generatorReactSdk.File, {
|
|
71
|
+
name: "README.md",
|
|
72
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
73
|
+
newLines: 2,
|
|
74
|
+
children: `# ${title}
|
|
75
|
+
|
|
76
|
+
## Overview
|
|
77
|
+
|
|
78
|
+
${info.description() || `A WebSocket client for ${title}.`}
|
|
79
|
+
|
|
80
|
+
- **Version:** ${info.version()}
|
|
81
|
+
- **URL:** ${serverUrl}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## Client API Reference
|
|
85
|
+
|
|
86
|
+
\`\`\`javascript
|
|
87
|
+
const ${clientName} = require('./${params.clientFileName.replace('.js', '')}');
|
|
88
|
+
const wsClient = new ${clientName}();
|
|
89
|
+
\`\`\`
|
|
90
|
+
|
|
91
|
+
Here the wsClient is an instance of the \`${clientName}\` class.
|
|
92
|
+
### Core Methods
|
|
93
|
+
|
|
94
|
+
#### \`connect()\`
|
|
95
|
+
Establishes a WebSocket connection to the server.
|
|
96
|
+
|
|
97
|
+
#### \`registerMessageHandler(handlerFunction)\`
|
|
98
|
+
Registers a callback to handle incoming messages.
|
|
99
|
+
- **Parameter:** \`handlerFunction\` - This Function takes a parameter \`message\` which is a string.
|
|
100
|
+
|
|
101
|
+
#### \`registerErrorHandler(handlerFunction)\`
|
|
102
|
+
Registers a callback to handle WebSocket errors.
|
|
103
|
+
- **Parameter:** \`handlerFunction\` - This Function takes a parameter \`error\` which is an object
|
|
104
|
+
|
|
105
|
+
#### \`close()\`
|
|
106
|
+
Closes the WebSocket connection.`
|
|
107
|
+
}), /*#__PURE__*/jsxRuntime.jsx(AvailableOperations, {
|
|
108
|
+
operations: operations
|
|
109
|
+
}), /*#__PURE__*/jsxRuntime.jsx(generatorReactSdk.Text, {
|
|
110
|
+
newLines: 2,
|
|
111
|
+
children: `## Testing the client
|
|
112
|
+
|
|
113
|
+
\`\`\`javascript
|
|
114
|
+
const ${clientName} = require('./${params.clientFileName.replace('.js', '')}');
|
|
115
|
+
const wsClient = new ${clientName}();
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
// Example of how custom message handler that operates on incoming messages can look like
|
|
119
|
+
|
|
120
|
+
function myHandler(message) {
|
|
121
|
+
console.log('====================');
|
|
122
|
+
console.log('Just proving I got the message in myHandler:', message);
|
|
123
|
+
console.log('====================');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Example of custom error handler
|
|
127
|
+
|
|
128
|
+
function myErrorHandler(error) {
|
|
129
|
+
console.error('Errors from Websocket:', error.message);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function main() {
|
|
133
|
+
wsClient.registerMessageHandler(myHandler);
|
|
134
|
+
wsClient.registerErrorHandler(myErrorHandler);
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
await wsClient.connect();
|
|
138
|
+
|
|
139
|
+
// Loop to send messages every 5 seconds
|
|
140
|
+
const interval = 5000; // 5 seconds
|
|
141
|
+
const message = 'Hello, Echo!';
|
|
142
|
+
|
|
143
|
+
while (true) {
|
|
144
|
+
try {
|
|
145
|
+
await wsClient.sendEchoMessage(message);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error('Error while sending message:', error);
|
|
148
|
+
}
|
|
149
|
+
// Wait for the interval before sending the next message
|
|
150
|
+
await new Promise(resolve => setTimeout(resolve, interval));
|
|
151
|
+
}
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.error('Failed to connect to WebSocket:', error.message);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
main();
|
|
158
|
+
\`\`\`
|
|
159
|
+
|
|
160
|
+
`
|
|
161
|
+
})]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
module.exports = README_md;
|
|
166
|
+
//# sourceMappingURL=README.md.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"README.md.js","sources":["../../../../../../../../packages/templates/clients/websocket/javascript/components/OperationHeader.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/MessageExamples.js","../../../../../../../../packages/templates/clients/websocket/javascript/components/AvailableOperations.js","../../../../../../../../packages/templates/clients/websocket/javascript/template/README.md.js"],"sourcesContent":["import { Text } from '@asyncapi/generator-react-sdk';\n\nexport default function OperationHeader({operation}) {\n const operationId = operation.id();\n return (\n <Text>\n {`#### \\`${operationId}(payload)\\`\n${operation.hasSummary() ? operation.summary() : ''}\n${operation.hasDescription() ? `\\n${operation.description()}` : ''}`}\n </Text>\n );\n}","import { getMessageExamples, getOperationMessages } from '@asyncapi/generator-helpers';\nimport { Text } from '@asyncapi/generator-react-sdk';\n\nexport default function MessageExamples({operation}) {\n const operationId = operation.id();\n const messageExamples = [];\n const messages = getOperationMessages(operation) || [];\n\n messages.forEach((message) => {\n const examples = getMessageExamples(message) || [];\n examples.forEach((example) => {\n const payload = example.payload();\n messageExamples.push(`\\n\\n**Example:**\\n\\`\\`\\`javascript\\nclient.${operationId}(${JSON.stringify(payload, null, 2)});\\n\\`\\`\\``);\n });\n });\n return (\n <Text>\n {messageExamples.map(example => (\n <Text>\n {example}\n </Text>\n ))}\n </Text>\n );\n}","import { Text } from '@asyncapi/generator-react-sdk';\nimport OperationHeader from './OperationHeader';\nimport MessageExamples from './MessageExamples';\n\nexport function AvailableOperations({ operations }) {\n if (!operations || operations.length === 0) {\n return null;\n }\n return (\n <>\n <Text newLines={2}>### Available Operations</Text>\n {operations.map((operation) => (\n <Text newLines={2}>\n <OperationHeader operation={operation} />\n <MessageExamples operation={operation} />\n </Text>\n ))}\n </>\n );\n}\n","import { File, Text } from '@asyncapi/generator-react-sdk';\nimport { getClientName, getServer, getServerUrl, getInfo, getTitle } from '@asyncapi/generator-helpers';\nimport { AvailableOperations } from '../components/AvailableOperations';\n\nexport default function({ asyncapi, params }) {\n const server = getServer(asyncapi.servers(), params.server);\n const info = getInfo(asyncapi);\n const clientName = getClientName(asyncapi, params.appendClientSuffix, params.customClientName);\n const title = getTitle(asyncapi);\n const serverUrl = getServerUrl(server);\n\n const operations = asyncapi.operations().all();\n \n return (\n <File name=\"README.md\">\n <Text newLines={2}>\n {`# ${title} \n\n## Overview\n\n${info.description() || `A WebSocket client for ${title}.`}\n\n- **Version:** ${info.version()}\n- **URL:** ${serverUrl}\n\n\n## Client API Reference\n\n\\`\\`\\`javascript\nconst ${clientName} = require('./${params.clientFileName.replace('.js', '')}');\nconst wsClient = new ${clientName}();\n\\`\\`\\`\n\nHere the wsClient is an instance of the \\`${clientName}\\` class.\n### Core Methods\n\n#### \\`connect()\\`\nEstablishes a WebSocket connection to the server.\n\n#### \\`registerMessageHandler(handlerFunction)\\`\nRegisters a callback to handle incoming messages.\n- **Parameter:** \\`handlerFunction\\` - This Function takes a parameter \\`message\\` which is a string. \n\n#### \\`registerErrorHandler(handlerFunction)\\`\nRegisters a callback to handle WebSocket errors.\n- **Parameter:** \\`handlerFunction\\` - This Function takes a parameter \\`error\\` which is an object\n\n#### \\`close()\\`\nCloses the WebSocket connection.`}\n </Text>\n <AvailableOperations operations={operations} />\n <Text newLines={2}>\n {`## Testing the client\n\n\\`\\`\\`javascript\nconst ${clientName} = require('./${params.clientFileName.replace('.js', '')}');\nconst wsClient = new ${clientName}();\n\n\n// Example of how custom message handler that operates on incoming messages can look like\n\nfunction myHandler(message) {\n console.log('====================');\n console.log('Just proving I got the message in myHandler:', message);\n console.log('===================='); \n}\n\n// Example of custom error handler\n\nfunction myErrorHandler(error) {\n console.error('Errors from Websocket:', error.message);\n}\n\nasync function main() {\n wsClient.registerMessageHandler(myHandler);\n wsClient.registerErrorHandler(myErrorHandler);\n\n try {\n await wsClient.connect();\n\n // Loop to send messages every 5 seconds\n const interval = 5000; // 5 seconds\n const message = 'Hello, Echo!';\n\n while (true) {\n try {\n await wsClient.sendEchoMessage(message);\n } catch (error) {\n console.error('Error while sending message:', error);\n }\n // Wait for the interval before sending the next message\n await new Promise(resolve => setTimeout(resolve, interval));\n }\n } catch (error) {\n console.error('Failed to connect to WebSocket:', error.message);\n }\n}\n\nmain();\n\\`\\`\\`\n\n`}\n </Text>\n </File>\n );\n}"],"names":["OperationHeader","operation","operationId","id","_jsx","Text","children","hasSummary","summary","hasDescription","description","MessageExamples","messageExamples","messages","getOperationMessages","forEach","message","examples","getMessageExamples","example","payload","push","JSON","stringify","map","AvailableOperations","operations","length","_jsxs","_Fragment","newLines","asyncapi","params","server","getServer","servers","info","getInfo","clientName","getClientName","appendClientSuffix","customClientName","title","getTitle","serverUrl","getServerUrl","all","File","name","version","clientFileName","replace"],"mappings":"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"}
|