abstract-sdk icon indicating copy to clipboard operation
abstract-sdk copied to clipboard

Investigating on Webhook and User types

Open silversonicaxel opened this issue 5 years ago • 6 comments

Hello everyone, I'm working with Abstract API version ^8.0.0-beta.32 and I am checking the Webhook and User types described in file https://github.com/goabstract/abstract-sdk/blob/master/abstract-sdk.d.ts

type Webhook = {
  active: boolean,
  createdAt: string,
  errorCount?: number,
  events: string[],
  id: string,
  lastPushedAt?: string,
  organizationId: string,
  updatedAt: string,
  url: string,
  user?: User
};

type User = {
  id: string,
  primaryEmailId: string,
  createdAt: string,
  updatedAt: string,
  deletedAt: string,
  lastActiveAt: string,
  username: string,
  name: string,
  avatarUrl: string
};

I setup a small application -built in typescript- with a server listening to the events branch.statusUpdated within my project within Abstract. And indeed it works, every time someone merge a branch the event is listened by the server. Issue is, I would like to use the type you offer, and I thought that Webhook type should have been the proper one.

But the data I receive in the server is this one

{
  "createdAt": "2020-07-16T15:13:00Z",
  "event": "branch.statusUpdated",
  "data": {
    "changes": {
      "status": [
        "wip",
        "merged"
      ]
    },
    "object": {
      "createdAt": "2020-07-16T09:07:12Z",
      "description": "",
      "divergedFromBranchId": "",
      "head": "XYZ",
      "id": "XYZ",
      "mergeSha": "XYZ",
      "mergedIntoBranchId": "XYZ",
      "name": "test2",
      "objectType": "branch",
      "parent": "XYZ",
      "projectId": "XYZ",
      "startedAtSha": "XYZ",
      "status": "merged",
      "updatedAt": "2020-07-16T15:12:39Z",
      "user": {
        "avatarUrl": "https://www.gravatar.com/avatar/XYZ",
        "createdAt": "2019-08-22T06:51:02Z",
        "id": "XYZ",
        "name": "XYZ",
        "objectType": "user",
        "updatedAt": "2019-08-22T06:51:02Z",
        "username": "XYZ"
      }
    }
  }
}

as you might notice from the Webhook type is missing data and object, event is not events so I guess this won't be the proper one - but I couldn't even find the proper type. What is the Abstract Webhook type used for? Shall we expect a proper Webhook type, in line with the data received by the server?

Same question for User type that is missing objectType. What is the Abstract User type used for? Shall we expect a proper User type, in line with the data received by the server?

Thanks

silversonicaxel avatar Jul 17 '20 08:07 silversonicaxel

following ^ ...

mascardoso avatar Jul 17 '20 08:07 mascardoso

Hello there! The back end response might have been changed on some purposes, which were not synced with sdk. We added your issue to this sprint, so stay tuned :)

berezovskyicom avatar Jul 28 '20 07:07 berezovskyicom

Thanks a lot @berezovskycom , I will keep an eye on it

silversonicaxel avatar Jul 28 '20 07:07 silversonicaxel

hello everyone, for your information, versions moved from ^8.0.0-beta.32 to ^8.0.0-beta.36 and still I've this problem, Webhook type did not change. any news?

silversonicaxel avatar Aug 18 '20 14:08 silversonicaxel

I could also try to write a PR, in case, do I need an NPM_TOKEN, something else?

silversonicaxel avatar Aug 18 '20 14:08 silversonicaxel

any news about this issue?

I worked on a small update https://github.com/goabstract/abstract-sdk/pull/305 to solve the Webhook type. I was wondering if that could be merged, or if there is some error to fix. And, if that's gonna be fixed, I've in mind also to continue with the follow up for the User type.

Thanks a lot for the attention

silversonicaxel avatar Sep 07 '20 13:09 silversonicaxel