seratch / slack-edge

Slack app development framework for edge functions with streamlined TypeScript support
https://github.com/seratch/slack-edge-app-template
MIT License
87 stars 5 forks source link

TypeScript usage #19

Closed combi-35 closed 5 months ago

combi-35 commented 6 months ago

Hi, I'm really confused about how to use types with this package. For example if I look at the payload I receive when sending a message into a channel:

{
   "token":"0JW1qXXXXXX",
   "team_id":"T06MXXXXXX",
   "context_team_id":"T06MXXXXX",
   "context_enterprise_id":null,
   "api_app_id":"A06XXXXXX",
   "event":{
      "user":"U0XXXXXX",
      "type":"message",
      "ts":"17098XXXX.2XXXX",
      "client_msg_id":"43055b13-d578-XXXXX",
      "text":"test",
      "team":"T06MXXXXXX",
      "blocks":[
         {
            "type":"rich_text",
            "block_id":"gB9fq",
            "elements":[
               {
                  "type":"rich_text_section",
                  "elements":[
                     {
                        "type":"text",
                        "text":"test"
                     }
                  ]
               }
            ]
         }
      ],
      "channel":"C06MXXXXX",
      "event_ts":"1709806507.XXXXXX",
      "channel_type":"channel"
   },
   "type":"event_callback",
   "event_id":"Ev06NFBXXXXX",
   "event_time":1709806507,
   "authorizations":[
      {
         "enterprise_id":null,
         "team_id":"T06MXXXXX",
         "user_id":"U06MXXXXX",
         "is_bot":true,
         "is_enterprise_install":false
      }
   ],
   "is_ext_shared_channel":false,
   "event_context":"4-eyJldCI6Im1lc3NhZ2UiLCJ0aWQiOiJUMDZNMiQzA2TURIQTdaTFoifQ"
}

But I am not able to find a type which matches this payload with this package?

Thanks!

seratch commented 6 months ago

Hi @combi-35, thanks for writing in. The whole request body data is represented here: https://github.com/seratch/slack-edge/blob/0.10.5/src/request/request-body.ts As for the "event" property for message events, the union type is defined at: https://github.com/seratch/slack-edge/blob/0.10.5/src/request/payload/event.ts#L1247-L1264

The response-body type does not have all the possible properties yet. Adding missing ones can be improved in future releases. Does this make sense?

seratch commented 5 months ago

Since this issue is inactive for a while, let me close this now.