Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using JSON objects within properties of an event in the event metadata does not work #5

Open
hanninen opened this issue Jun 4, 2021 · 1 comment

Comments

@hanninen
Copy link

hanninen commented Jun 4, 2021

We have a following type of event format in use that contains nested JSON objects with the detail item in the EventBridge event:

"detail": {
"version": 1,
"principal": {
  "type": "USER",
  "id": "USERID",
  "workspace_id": "WORKSPACEID"
},
"status": "SUCCEEDED",
"data": {
  "workspace_id": "WORKSPACEID",
  "activity_id": "ACTIVITYID",
  "document_ids": [
    "DOCID1",
    "DOCID2"
  ]
}

I then try to describe this through the event_metadata.json and add the principal and data objects with their sub-items:

"events": {
  "ACTIVITY_DELETED": {
    "description": "Event is raised when an Activity is deleted.",
    "properties": {
      "version": "Integer to define the event schema version",
      "principal": {
        "type": "USER or SYSTEM to identify the type for the principal",
        "id": "ID of the principal (user ID or system identifier)",
        "workspace_id": "Workspace ID for the principal"
      },
      "status": "One of the: SUCCESS, ERROR, IN_PROGRESS, CANCELLED",
      "data": {
        "workspace_id": "ID of the workspace for the Activity.",
        "activity_id": "ID of the Activity.",
        "document_ids": "List of Document IDs attached to the Activity."
      }
    },

When I run npm run build:slate gives out the following error:

❯ npm run build:slate

> [email protected] build:slate
> npm run clean --silent && npm run generate --silent -- --format=slate

[1/3] 🔎 Fetching data from AWS...
[2/3] 🧑🏻‍💻 Generating format for desired tool: slate ...
e Error: There is no such converter: type
    at json2md (/home/aki/src/github/eventbridge-atlas/node_modules/json2md/lib/index.js:73:15)
    at /home/aki/src/github/eventbridge-atlas/node_modules/json2md/lib/converters.js:178:20
    at Array.map (<anonymous>)
    at /home/aki/src/github/eventbridge-atlas/node_modules/json2md/lib/converters.js:177:13
    at Array.map (<anonymous>)
    at converters.table (/home/aki/src/github/eventbridge-atlas/node_modules/json2md/lib/converters.js:174:34)
    at json2md (/home/aki/src/github/eventbridge-atlas/node_modules/json2md/lib/index.js:71:28)
    at json2md (/home/aki/src/github/eventbridge-atlas/node_modules/json2md/lib/index.js:63:34)
    at _callee$ (/home/aki/src/github/eventbridge-atlas/src/parsers/slate/src/init.js:79:3)
    at tryCatch (/home/aki/src/github/eventbridge-atlas/node_modules/regenerator-runtime/runtime.js:63:40)

Removing or flattening the nested object for principal or data field removes the error and generates the docs, but I lose the nested structure and would need to use embedded HTML tags or similar for formatting it nicely.

@hanninen
Copy link
Author

hanninen commented Jun 4, 2021

Just a bit of background information:

We've defined our own product specific schema for EventBridge that defines the:

  • principal
  • status
  • version
  • data

fields to be common fields with known values (data is the exception here).

data can be anything that the developers decide for the event type. EventBridge Atlas would be a great way to document the structure across all teams and make the schema and how events are used much more discoverable across our engineering org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant