goabstract / abstract-sdk

Universal JavaScript bindings for the Abstract API and CLI
https://sdk.goabstract.com
MIT License
57 stars 18 forks source link

Investigating on Webhook and User types #296

Open silversonicaxel opened 4 years ago

silversonicaxel commented 4 years ago

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

mascardoso commented 4 years ago

following ^ ...

berezovskyicom commented 4 years ago

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 :)

silversonicaxel commented 4 years ago

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

silversonicaxel commented 4 years ago

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 commented 4 years ago

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

silversonicaxel commented 4 years ago

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