2023-03-01 20:43:22 +00:00
|
|
|
/**
|
|
|
|
* This module was automatically generated by `ts-interface-builder`
|
|
|
|
*/
|
|
|
|
import * as t from "ts-interface-checker";
|
|
|
|
// tslint:disable:object-literal-key-quotes
|
|
|
|
|
(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
2023-07-25 13:29:19 +00:00
|
|
|
export const WebhookSubscribeCollection = t.iface([], {
|
|
|
|
"webhooks": t.array("Webhook"),
|
|
|
|
});
|
|
|
|
|
|
|
|
export const Webhook = t.iface([], {
|
|
|
|
"fields": "WebhookFields",
|
|
|
|
});
|
|
|
|
|
2023-03-01 20:43:22 +00:00
|
|
|
export const WebhookFields = t.iface([], {
|
|
|
|
"url": "string",
|
2024-07-04 12:17:10 +00:00
|
|
|
"authorization": t.opt("string"),
|
2023-03-01 20:43:22 +00:00
|
|
|
"eventTypes": t.array(t.union(t.lit("add"), t.lit("update"))),
|
|
|
|
"tableId": "string",
|
2024-04-12 20:04:37 +00:00
|
|
|
"watchedColIds": t.opt(t.array("string")),
|
2023-03-01 20:43:22 +00:00
|
|
|
"enabled": t.opt("boolean"),
|
|
|
|
"isReadyColumn": t.opt(t.union("string", "null")),
|
2023-05-08 22:06:24 +00:00
|
|
|
"name": t.opt("string"),
|
|
|
|
"memo": t.opt("string"),
|
2023-03-01 20:43:22 +00:00
|
|
|
});
|
|
|
|
|
2023-05-08 22:06:24 +00:00
|
|
|
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'));
|
|
|
|
|
2023-03-01 20:43:22 +00:00
|
|
|
export const WebhookSubscribe = t.iface([], {
|
|
|
|
"url": "string",
|
2024-07-04 12:17:10 +00:00
|
|
|
"authorization": t.opt("string"),
|
2023-03-01 20:43:22 +00:00
|
|
|
"eventTypes": t.array(t.union(t.lit("add"), t.lit("update"))),
|
2024-04-12 20:04:37 +00:00
|
|
|
"watchedColIds": t.opt(t.array("string")),
|
2023-03-01 20:43:22 +00:00
|
|
|
"enabled": t.opt("boolean"),
|
|
|
|
"isReadyColumn": t.opt(t.union("string", "null")),
|
2023-05-08 22:06:24 +00:00
|
|
|
"name": t.opt("string"),
|
|
|
|
"memo": t.opt("string"),
|
|
|
|
});
|
|
|
|
|
(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
2023-07-25 13:29:19 +00:00
|
|
|
export const WebhookSummaryCollection = t.iface([], {
|
|
|
|
"webhooks": t.array("WebhookSummary"),
|
(core) API reworked to use POST to create webhook and DELET to remove it
Summary:
introduces POST /api/docs/{docId}/webhooks and DELETE /api/docs/{docId}/webhooks/{webhookId} on place of old _subscribe and _unsubscribe endpoints.
Remove checking for unsubscribeKey while deleting webhook - only owner can delete webhook using DELETE endpoint. subscription key is still needed for _unsubscribe endpoint.
old _unsubscribe and _subscribe endpoints are still active and work as before - no changes there.
Posting schema:
```
POST /api/docs/[docId]/webhooks
```
Request Body:
```
{
"webhooks": [
{
"fields": {
"url": "https://webhook.site/3bd02246-f122-445e-ba7f-bf5ea5bb6eb1",
"eventTypes": [
"add",
"update"
],
"enabled": true,
"name": "WebhookName",
"memo": "just a text",
"tableId": "Table1"
}
},
{
"fields": {
"url": "https://webhook.site/3bd02246-f122-445e-ba7f-bf5ea5bb6eb2",
"eventTypes": [
"add",
],
"enabled": true,
"name": "OtherWebhookName",
"memo": "just a text",
"tableId": "Table1"
}
}
]
}
```
Expected response: WebhookId for each webhook posted:
```
{
"webhooks": [
{
"id": "85c77108-f1e1-4217-a50d-acd1c5996da2"
},
{
"id": "d87a6402-cfd7-4822-878c-657308fcc8c3"
}
]
}
```
Deleting webhooks:
```
DELETE api/docs/[docId]/webhooks/[webhookId]
```
there is no payload in DELETE request. Therefore only one webhook can be deleted at once
Response:
```
{
"success": true
}
```
Test Plan: Old unit test improved to handle new endpoints, and one more added to check if endpoints are in fact created/removed
Reviewers: alexmojaki
Reviewed By: alexmojaki
Subscribers: paulfitz, alexmojaki
Differential Revision: https://phab.getgrist.com/D3916
2023-07-14 10:05:22 +00:00
|
|
|
});
|
|
|
|
|
2023-05-08 22:06:24 +00:00
|
|
|
export const WebhookSummary = t.iface([], {
|
|
|
|
"id": "string",
|
|
|
|
"fields": t.iface([], {
|
|
|
|
"url": "string",
|
2024-07-04 12:17:10 +00:00
|
|
|
"authorization": t.opt("string"),
|
2023-05-08 22:06:24 +00:00
|
|
|
"unsubscribeKey": "string",
|
|
|
|
"eventTypes": t.array("string"),
|
|
|
|
"isReadyColumn": t.union("string", "null"),
|
|
|
|
"tableId": "string",
|
2024-04-12 20:04:37 +00:00
|
|
|
"watchedColIds": t.opt(t.array("string")),
|
2023-05-08 22:06:24 +00:00
|
|
|
"enabled": "boolean",
|
|
|
|
"name": "string",
|
|
|
|
"memo": "string",
|
|
|
|
}),
|
|
|
|
"usage": t.union("WebhookUsage", "null"),
|
2023-03-01 20:43:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
export const WebhookUpdate = t.iface([], {
|
|
|
|
"id": "string",
|
|
|
|
"fields": "WebhookPatch",
|
|
|
|
});
|
|
|
|
|
|
|
|
export const WebhookPatch = t.iface([], {
|
|
|
|
"url": t.opt("string"),
|
2024-07-04 12:17:10 +00:00
|
|
|
"authorization": t.opt("string"),
|
2023-03-01 20:43:22 +00:00
|
|
|
"eventTypes": t.opt(t.array(t.union(t.lit("add"), t.lit("update")))),
|
|
|
|
"tableId": t.opt("string"),
|
2024-04-12 20:04:37 +00:00
|
|
|
"watchedColIds": t.opt(t.array("string")),
|
2023-03-01 20:43:22 +00:00
|
|
|
"enabled": t.opt("boolean"),
|
|
|
|
"isReadyColumn": t.opt(t.union("string", "null")),
|
2023-05-08 22:06:24 +00:00
|
|
|
"name": t.opt("string"),
|
|
|
|
"memo": t.opt("string"),
|
|
|
|
});
|
|
|
|
|
|
|
|
export const WebhookUsage = t.iface([], {
|
|
|
|
"numWaiting": "number",
|
|
|
|
"status": "WebhookStatus",
|
|
|
|
"updatedTime": t.opt(t.union("number", "null")),
|
|
|
|
"lastSuccessTime": t.opt(t.union("number", "null")),
|
|
|
|
"lastFailureTime": t.opt(t.union("number", "null")),
|
|
|
|
"lastErrorMessage": t.opt(t.union("string", "null")),
|
|
|
|
"lastHttpStatus": t.opt(t.union("number", "null")),
|
|
|
|
"lastEventBatch": t.opt(t.union("null", t.iface([], {
|
|
|
|
"size": "number",
|
|
|
|
"errorMessage": t.union("string", "null"),
|
|
|
|
"httpStatus": t.union("number", "null"),
|
|
|
|
"status": "WebhookBatchStatus",
|
|
|
|
"attempts": "number",
|
|
|
|
}))),
|
|
|
|
"numSuccess": t.opt(t.iface([], {
|
|
|
|
"pastHour": "number",
|
|
|
|
"past24Hours": "number",
|
|
|
|
})),
|
2023-03-01 20:43:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const exportedTypeSuite: t.ITypeSuite = {
|
(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
2023-07-25 13:29:19 +00:00
|
|
|
WebhookSubscribeCollection,
|
(core) API reworked to use POST to create webhook and DELET to remove it
Summary:
introduces POST /api/docs/{docId}/webhooks and DELETE /api/docs/{docId}/webhooks/{webhookId} on place of old _subscribe and _unsubscribe endpoints.
Remove checking for unsubscribeKey while deleting webhook - only owner can delete webhook using DELETE endpoint. subscription key is still needed for _unsubscribe endpoint.
old _unsubscribe and _subscribe endpoints are still active and work as before - no changes there.
Posting schema:
```
POST /api/docs/[docId]/webhooks
```
Request Body:
```
{
"webhooks": [
{
"fields": {
"url": "https://webhook.site/3bd02246-f122-445e-ba7f-bf5ea5bb6eb1",
"eventTypes": [
"add",
"update"
],
"enabled": true,
"name": "WebhookName",
"memo": "just a text",
"tableId": "Table1"
}
},
{
"fields": {
"url": "https://webhook.site/3bd02246-f122-445e-ba7f-bf5ea5bb6eb2",
"eventTypes": [
"add",
],
"enabled": true,
"name": "OtherWebhookName",
"memo": "just a text",
"tableId": "Table1"
}
}
]
}
```
Expected response: WebhookId for each webhook posted:
```
{
"webhooks": [
{
"id": "85c77108-f1e1-4217-a50d-acd1c5996da2"
},
{
"id": "d87a6402-cfd7-4822-878c-657308fcc8c3"
}
]
}
```
Deleting webhooks:
```
DELETE api/docs/[docId]/webhooks/[webhookId]
```
there is no payload in DELETE request. Therefore only one webhook can be deleted at once
Response:
```
{
"success": true
}
```
Test Plan: Old unit test improved to handle new endpoints, and one more added to check if endpoints are in fact created/removed
Reviewers: alexmojaki
Reviewed By: alexmojaki
Subscribers: paulfitz, alexmojaki
Differential Revision: https://phab.getgrist.com/D3916
2023-07-14 10:05:22 +00:00
|
|
|
Webhook,
|
(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
2023-07-25 13:29:19 +00:00
|
|
|
WebhookFields,
|
2023-05-08 22:06:24 +00:00
|
|
|
WebhookBatchStatus,
|
|
|
|
WebhookStatus,
|
2023-03-01 20:43:22 +00:00
|
|
|
WebhookSubscribe,
|
(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
2023-07-25 13:29:19 +00:00
|
|
|
WebhookSummaryCollection,
|
2023-05-08 22:06:24 +00:00
|
|
|
WebhookSummary,
|
2023-03-01 20:43:22 +00:00
|
|
|
WebhookUpdate,
|
|
|
|
WebhookPatch,
|
2023-05-08 22:06:24 +00:00
|
|
|
WebhookUsage,
|
2023-03-01 20:43:22 +00:00
|
|
|
};
|
|
|
|
export default exportedTypeSuite;
|