mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) GET endpoint for webhooks returns now data in format {webhooks:[...]}
Summary:
Rework of endpoint GET for webhooks to make it coherent with other endpoints. Now data should be return in {webhooks:[{id:"...",fields:{"..."}]} format
```
{
"webhooks": [
{
"id": ...
"fields": {
"url": ...
"unsubscribeKey": ...
"eventTypes": [
"add",
"update"
],
"isReadyColumn": null,
"tableId": "...",
"enabled": false,
"name": "...",
"memo": "..."
},
"usage": {
"status": "idle",
"numWaiting": 0,
"lastEventBatch": null
}
},
{
"id": "...",
"fields": {
"url": "...",
"unsubscribeKey": "...",
"eventTypes": [
"add",
"update"
],
"isReadyColumn": null,
"tableId": "...",
"enabled": true,
"name": "...",
"memo": "..."
},
"usage": {
"status": "error",
"numWaiting": 0,
"updatedTime": 1689076978098,
"lastEventBatch": {
"status": "rejected",
"httpStatus": 404,
"errorMessage": "{\"success\":false,\"error\":{\"message\":\"Alias 5a9bf6a8-4865-403a-bec6-b4ko not found\",\"id\":null}}",
"size": 49,
"attempts": 5
},
"lastSuccessTime": null,
"lastFailureTime": 1689076978097,
"lastErrorMessage": "{\"success\":false,\"error\":{\"message\":\"Alias 5a9bf6a8-4865-403a-bec6-b4ko not found\",\"id\":null}}",
"lastHttpStatus": 404
}
}
]
}
```
Test Plan: new test added to check if GET data fromat is correct. Other tests fixed to handle changed endpoint.
Reviewers: paulfitz
Reviewed By: paulfitz
Differential Revision: https://phab.getgrist.com/D3966
This commit is contained in:
@@ -4,6 +4,14 @@
|
||||
import * as t from "ts-interface-checker";
|
||||
// tslint:disable:object-literal-key-quotes
|
||||
|
||||
export const WebhookSubscribeCollection = t.iface([], {
|
||||
"webhooks": t.array("Webhook"),
|
||||
});
|
||||
|
||||
export const Webhook = t.iface([], {
|
||||
"fields": "WebhookFields",
|
||||
});
|
||||
|
||||
export const WebhookFields = t.iface([], {
|
||||
"url": "string",
|
||||
"eventTypes": t.array(t.union(t.lit("add"), t.lit("update"))),
|
||||
@@ -14,10 +22,6 @@ export const WebhookFields = t.iface([], {
|
||||
"memo": t.opt("string"),
|
||||
});
|
||||
|
||||
export const Webhook = t.iface([], {
|
||||
"fields": "WebhookFields",
|
||||
});
|
||||
|
||||
export const WebhookBatchStatus = t.union(t.lit('success'), t.lit('failure'), t.lit('rejected'));
|
||||
|
||||
export const WebhookStatus = t.union(t.lit('idle'), t.lit('sending'), t.lit('retrying'), t.lit('postponed'), t.lit('error'), t.lit('invalid'));
|
||||
@@ -31,8 +35,8 @@ export const WebhookSubscribe = t.iface([], {
|
||||
"memo": t.opt("string"),
|
||||
});
|
||||
|
||||
export const WebhookSubscribeCollection = t.iface([], {
|
||||
"webhooks": t.array("Webhook"),
|
||||
export const WebhookSummaryCollection = t.iface([], {
|
||||
"webhooks": t.array("WebhookSummary"),
|
||||
});
|
||||
|
||||
export const WebhookSummary = t.iface([], {
|
||||
@@ -87,12 +91,13 @@ export const WebhookUsage = t.iface([], {
|
||||
});
|
||||
|
||||
const exportedTypeSuite: t.ITypeSuite = {
|
||||
WebhookFields,
|
||||
WebhookSubscribeCollection,
|
||||
Webhook,
|
||||
WebhookFields,
|
||||
WebhookBatchStatus,
|
||||
WebhookStatus,
|
||||
WebhookSubscribe,
|
||||
WebhookSubscribeCollection,
|
||||
WebhookSummaryCollection,
|
||||
WebhookSummary,
|
||||
WebhookUpdate,
|
||||
WebhookPatch,
|
||||
|
||||
@@ -33,7 +33,9 @@ export interface WebhookSubscribe {
|
||||
}
|
||||
|
||||
|
||||
|
||||
export interface WebhookSummaryCollection {
|
||||
webhooks: Array<WebhookSummary>;
|
||||
}
|
||||
export interface WebhookSummary {
|
||||
id: string;
|
||||
fields: {
|
||||
|
||||
@@ -14,7 +14,12 @@ import {encodeQueryParams} from 'app/common/gutil';
|
||||
import {FullUser, UserProfile} from 'app/common/LoginSessionAPI';
|
||||
import {OrgPrefs, UserOrgPrefs, UserPrefs} from 'app/common/Prefs';
|
||||
import * as roles from 'app/common/roles';
|
||||
import {WebhookFields, WebhookSubscribe, WebhookSummary, WebhookUpdate} from 'app/common/Triggers';
|
||||
import {
|
||||
WebhookFields,
|
||||
WebhookSubscribe,
|
||||
WebhookSummaryCollection,
|
||||
WebhookUpdate
|
||||
} from 'app/common/Triggers';
|
||||
import {addCurrentOrgToPath} from 'app/common/urlUtils';
|
||||
import omitBy from 'lodash/omitBy';
|
||||
|
||||
@@ -457,7 +462,7 @@ export interface DocAPI {
|
||||
// Get users that are worth proposing to "View As" for access control purposes.
|
||||
getUsersForViewAs(): Promise<PermissionDataWithExtraUsers>;
|
||||
|
||||
getWebhooks(): Promise<WebhookSummary[]>;
|
||||
getWebhooks(): Promise<WebhookSummaryCollection>;
|
||||
addWebhook(webhook: WebhookFields): Promise<{webhookId: string}>;
|
||||
removeWebhook(webhookId: string, tableId: string): Promise<void>;
|
||||
// Update webhook
|
||||
@@ -915,7 +920,7 @@ export class DocAPIImpl extends BaseAPI implements DocAPI {
|
||||
return this.requestJson(`${this._url}/usersForViewAs`);
|
||||
}
|
||||
|
||||
public async getWebhooks(): Promise<WebhookSummary[]> {
|
||||
public async getWebhooks(): Promise<WebhookSummaryCollection> {
|
||||
return this.requestJson(`${this._url}/webhooks`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user