{"id":15148508,"url":"https://github.com/sap/cloudevents-asyncapi-converter","last_synced_at":"2025-10-19T16:32:25.677Z","repository":{"id":253385562,"uuid":"842456067","full_name":"SAP/cloudevents-asyncapi-converter","owner":"SAP","description":"CloudEvents payload to AsyncAPI conversion tool for ABAP, written in TypeScript","archived":false,"fork":false,"pushed_at":"2024-09-09T15:05:19.000Z","size":624,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T21:25:25.480Z","etag":null,"topics":["abap","architecture","asyncapi","btp","business","cloudevents","consumption","conversion","driven","environment","event","events","model","rap","s4hana","sap","tool"],"latest_commit_sha":null,"homepage":"https://sap.github.io/cloudevents-asyncapi-converter","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SAP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-14T11:44:22.000Z","updated_at":"2024-09-09T15:04:49.000Z","dependencies_parsed_at":"2024-09-21T20:01:03.496Z","dependency_job_id":"11e4c287-40fe-4e8b-81ee-a39f886e1f61","html_url":"https://github.com/SAP/cloudevents-asyncapi-converter","commit_stats":null,"previous_names":["sap/cloudevents-asyncapi-converter"],"tags_count":0,"template":false,"template_full_name":"SAP/repository-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fcloudevents-asyncapi-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fcloudevents-asyncapi-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fcloudevents-asyncapi-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fcloudevents-asyncapi-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SAP","download_url":"https://codeload.github.com/SAP/cloudevents-asyncapi-converter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237172145,"owners_count":19266621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abap","architecture","asyncapi","btp","business","cloudevents","consumption","conversion","driven","environment","event","events","model","rap","s4hana","sap","tool"],"created_at":"2024-09-26T13:04:11.103Z","updated_at":"2025-10-19T16:32:20.396Z","avatar_url":"https://github.com/SAP.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![REUSE status](https://api.reuse.software/badge/github.com/SAP/cloudevents-asyncapi-converter)](https://api.reuse.software/info/github.com/SAP/cloudevents-asyncapi-converter)\n\n# Converter for CloudEvents to AsyncAPI\n\n*Converter for CloudEvents to AsyncAPI* is a Node.js library and CLI application that converts any event payload conforming to the [CloudEvents](https://github.com/cloudevents/spec) specification into an [AsyncAPI](https://www.asyncapi.com/docs) catalog which can be used in an ABAP environment to generate an [Event Consumption Model](https://help.sap.com/docs/abap-cloud/abap-development-tools-user-guide/generating-event-consumption-model).\n\nFind the official web application hosted on GitHub Pages at https://sap.github.io/cloudevents-asyncapi-converter.\n\n\u003e [!NOTE]\n\u003e CloudEvents® is a registered trademark of The Linux Foundation.\n\n\n## Installation\n\n### Prerequisites\n\n- Node.js version 20.x or above\n- npm version 9.x or above\n\n### Steps\n\n1. Clone the repository\n2. Navigate to the repository's root folder\n3. Install the package and its dependencies\n\n```bash\nnpm install \u0026\u0026 npm install -g .\n```\n\n\u003e [!TIP]\n\u003e If you wish to install and use the package locally (i.e. not system-wide), simply drop the second `npm install` command.\n\n\n## Usage\n\n### Command Line\n\nTo convert a CloudEvents payload in JSON format to a corresponding AsyncAPI catalog, this package offers the following command:\n\n```\nce2async [input path] [--output|-o path] [--version|-v version] [--help]\n```\n\n* **Arguments:**\n  - `input`\\\n  Path to the input file containing the CloudEvents payload. If not specified, the input is read from _stdin_ instead. If the payload is invalid, the command will fail with a non-zero exit code and print an error message to _stderr_.\n\n* **Options:**\n  - `--output`, `-o`\\\n  Path to the output file that will contain the AsyncAPI catalog. If not specified, the output is written to _stdout_ instead.\n\n  - `--version`, `-v`\\\n  Version of the AsyncAPI specification to use for conversion. Presently, only version `2.0` for AsyncAPI 2.0.x is supported.\n\n  - `--help`\\\n  Help page for this command.\n\n\u003e [!TIP]\n\u003e In case you only installed the package locally, you must run the command with `npx` from within the repository.\n\n#### Example\n\nAs an example, suppose you want to convert the payload in `examples/input.json` to an AsyncAPI 2.0.x catalog file. To achieve that, simply run\n\n```bash\nce2async examples/input.json -o output.json\n```\n\nThe file `output.json` now contains the corresponding AsyncAPI catalog, exactly as in `examples/output.json`.\n\nOr alternatively, to read some event payload from _stdin_ and write the converted result to _stdout_, instead run\n\n```bash\necho '{\"type\":\"sap.eee.iwxbe.testproducer.v1.Event.Conversion\",\"specversion\":\"1.0\",\"source\":\"/default/sap.eee/XXXCLNT400\",\"id\":\"42010aef-0cee-1edb-879d-6a2c14dc9326\",\"time\":\"2020-11-02T09:10:57Z\",\"datacontenttype\":\"application/json\",\"data\":{\"Amount\":100.0,\"Currency\":\"KWD\",\"Quantity\":1000.0,\"Unit\":\"KG\",\"Alpha\":\"1\"}}' | ce2async\n```\n\n### API\n\nAlthough this package is intended to be primarily used as a CLI application, it also provides an API to perform the conversion programmatically. As to that, the package exports a single class `PayloadConverter`, which offers the following methods:\n\n* **Static Methods:**\n  - `create(version?: string): PayloadConverter;`\\\n    Creates a new instance of a `PayloadConverter` for the optionally specified AsyncAPI specification `version`, assuming `v2.0` by default. Throws an error when `version` is invalid or not supported.\n\n* **Instance Methods:**\n  - `convert(payload: object): object;`\\\n    Converts a CloudEvents `payload` object to a corresponding AsyncAPI catalog object, using the converter's specification version. Throws an error when `payload` is malformed according to the CloudEvents specification.\n\n  - `convertAsString(payload: string): string;`\\\n    Functions like `convert(...)` but accepts a JSON string as an input, which is parsed before converting. Returns the output as a JSON string as well.\n\n#### Example\n\n```javascript\nimport { PayloadConverter } from 'cloudevents-asyncapi-converter';\n\nconst converter = PayloadConverter.create();\n\nconst input = '...'; // some CloudEvents JSON string\ntry {\n    const output = converter.convertAsString(input);\n    // conversion succeeded\n} catch (error) {\n    // conversion failed\n}\n```\n\n### Limitations\n\nThe payload converter only generates a rough AsyncAPI catalog solely based on the CloudEvents payload by inferring data types in a naïve manner. Consequently, it exhibits some limitations that require manual adjustments to the payload prior to conversion or to the resulting catalog.\n\n* Properties with value `null` or empty objects `{}` in the payload are currently rejected by the converter.\n* String properties are not analyzed with regards to their data format and have none assigned.\n* Numeric properties always receive the data format `decimal` by the converter.\n* For compositions of objects, the converter is currently unable to link parent and child schemas through references. Instead, it treats them independently of each other.\n\n  \u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003eDetails\u003c/b\u003e\u003c/summary\u003e\n\n  Suppose your payload has nested schemas like the `ComplexCollection` below, containing objects of the type `Complex`.\n\n  ```json\n  // ...\n  \"ComplexCollection\": [\n    {\n      \"Amount\": 100.000,\n      \"Currency\": \"KWD\",\n      \"Quantity\": 1000.000,\n      \"Unit\": \"KG\",\n      \"Alpha\": \"1\"\n    },\n    // ...\n  ],\n  \"Complex\": {\n    \"Amount\": 0.000,\n    \"Currency\": \"KWD\",\n    \"Quantity\": 0.000,\n    \"Unit\": \"KG\",\n    \"Alpha\": \"1\"\n  },\n  // ...\n  ```\n\n  Rather than linking the items of `ComplexCollection` to the `Complex` schema, the converter creates individual schemas for each object.\n\n  ```json\n  // ...\n  \"schemas\": {\n    \"ComplexCollection\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"$ref\": \"#/components/schemas/sap_eee_iwxbe_testproducer_v1_Event_DeepStructure_ComplexCollection\"\n      }\n    },\n    \"Complex\": {\n      \"type\": \"object\",\n      \"$ref\": \"#/components/schemas/sap_eee_iwxbe_testproducer_v1_Event_DeepStructure_Complex\"\n    },\n    // ...\n    \"sap_eee_iwxbe_testproducer_v1_Event_DeepStructure_ComplexCollection\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"Amount\": {\n          \"type\": \"number\",\n          \"format\": \"decimal\"\n        },\n        \"Currency\": {\n          \"type\": \"string\"\n        },\n        \"Quantity\": {\n          \"type\": \"number\",\n          \"format\": \"decimal\"\n        },\n        \"Unit\": {\n          \"type\": \"string\"\n        },\n        \"Alpha\": {\n          \"type\": \"string\"\n        }\n      }\n    },\n    \"sap_eee_iwxbe_testproducer_v1_Event_DeepStructure_Complex\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"Amount\": {\n          \"type\": \"number\",\n          \"format\": \"decimal\"\n        },\n        \"Currency\": {\n          \"type\": \"string\"\n        },\n        \"Quantity\": {\n          \"type\": \"number\",\n          \"format\": \"decimal\"\n        },\n        \"Unit\": {\n          \"type\": \"string\"\n        },\n        \"Alpha\": {\n          \"type\": \"string\"\n        }\n      }\n    }\n  }\n  ```\n  \u003c/details\u003e\n\n\n## Support, Feedback, Contributing\n\nThis project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/SAP/cloudevents-asyncapi-converter/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).\n\n\n## Security / Disclosure\n\nIf you find any bug that may be a security problem, please follow our instructions at [in our security policy](https://github.com/SAP/cloudevents-asyncapi-converter/security/policy) on how to report it. Please do not create GitHub issues for security-related doubts or problems.\n\n\n## Code of Conduct\n\nWe as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](https://github.com/SAP/.github/blob/main/CODE_OF_CONDUCT.md) at all times.\n\n\n## Licensing\n\nCopyright 2024 SAP SE or an SAP affiliate company and *cloudevents-asyncapi-converter* contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/SAP/cloudevents-asyncapi-converter).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap%2Fcloudevents-asyncapi-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsap%2Fcloudevents-asyncapi-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap%2Fcloudevents-asyncapi-converter/lists"}