gristlabs_grist-core/app/server/lib
Alex Hall 3c4d71aeca (core) Initial webhooks implementation
Summary:
See https://grist.quip.com/VKd3ASF99ezD/Outgoing-Webhooks

- 2 new DocApi endpoints: _subscribe and _unsubscribe, not meant to be user friendly or publicly documented. _unsubscribe should be given the response from _subscribe in the body, e.g:

```
$ curl -X POST -H "Authorization: Bearer 8fd4dc59ecb05ab29ae5a183c03101319b8e6ca9" "http://localhost:8080/api/docs/6WYa23FqWxGNe3AR6DLjCJ/tables/Table2/_subscribe" -H "Content-type: application/json" -d '{"url": "https://webhook.site/a916b526-8afc-46e6-aa8f-a625d0d83ec3", "eventTypes": ["add"], "isReadyColumn": "C"}'
{"unsubscribeKey":"3246f158-55b5-4fc7-baa5-093b75ffa86c","triggerId":2,"webhookId":"853b4bfa-9d39-4639-aa33-7d45354903c0"}
$ curl -X POST -H "Authorization: Bearer 8fd4dc59ecb05ab29ae5a183c03101319b8e6ca9" "http://localhost:8080/api/docs/6WYa23FqWxGNe3AR6DLjCJ/tables/Table2/_unsubscribe" -H "Content-type: application/json" -d '{"unsubscribeKey":"3246f158-55b5-4fc7-baa5-093b75ffa86c","triggerId":2,"webhookId":"853b4bfa-9d39-4639-aa33-7d45354903c0"}'
{"success":true}
```

- New DB entity Secret to hold the webhook URL and unsubscribe key
- New document metatable _grist_Triggers subscribes to table changes and points to a secret to use for a webhook
- New file Triggers.ts processes action summaries and uses the two new tables to send webhooks.
- Also went on a bit of a diversion and made a typesafe subclass of TableData for metatables.

I think this is essentially good enough for a first diff, to keep the diffs manageable and to talk about the overall structure. Future diffs can add tests and more robustness using redis etc. After this diff I can also start building the Zapier integration privately.

Test Plan: Tested manually: see curl commands in summary for an example. Payloads can be seen in https://webhook.site/#!/a916b526-8afc-46e6-aa8f-a625d0d83ec3/0b9fe335-33f7-49fe-b90b-2db5ba53382d/1 . Great site for testing webhooks btw.

Reviewers: dsagal, paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3019
2021-09-23 14:35:39 +02:00
..
ACLFormula.ts (core) add OWNERS='owners', EDITOR='editors', VIEWER='viewers' to condition formulas 2021-03-19 18:20:33 -04:00
ActionHistory.ts (core) add endpoints for clearing snapshots and actions 2020-12-18 13:32:31 -05:00
ActionHistoryImpl.ts (core) Log the time taken by decodeActionFromRow() operations. 2021-08-20 11:28:33 -04:00
ActionSummary.ts (core) tolerate table renames when displaying differences 2020-11-12 10:55:15 -05:00
ActiveDoc.ts (core) Initial webhooks implementation 2021-09-23 14:35:39 +02:00
ActiveDocImport.ts (core) Enable incremental imports 2021-09-16 09:15:54 -07:00
AppEndpoint.ts (core) Adding import from google drive to the home screen 2021-08-05 20:46:11 +02:00
Authorizer.ts (core) clean up a collection of small problems affecting grist-core 2021-08-17 21:44:50 -04:00
BrowserSession.ts (core) revive saml support and test against Auth0 2021-08-16 17:36:09 -04:00
checksumFile.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
Client.ts (core) Simple localization support and currency selector. 2021-08-26 13:36:49 -07:00
Comm.js (core) Simple localization support and currency selector. 2021-08-26 13:36:49 -07:00
dbUtils.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
DocApi.ts (core) Initial webhooks implementation 2021-09-23 14:35:39 +02:00
DocClients.ts (core) granular access control in the presence of schema changes 2021-03-01 13:49:31 -05:00
DocManager.ts (core) Adding import from google drive to the home screen 2021-08-05 20:46:11 +02:00
DocPluginData.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
DocPluginManager.ts (core) Move file import plugins into core/sandbox/grist 2021-08-09 18:37:14 +02:00
DocSession.ts (core) Simple localization support and currency selector. 2021-08-26 13:36:49 -07:00
DocSnapshots.ts (core) start reconciling forking with granular access 2021-01-12 14:08:49 -05:00
DocStorage.ts (core) Barely working reference lists in frontend 2021-07-23 18:41:44 +02:00
DocStorageManager.ts (core) uncheck FullCopy special when copying/forking a document 2021-04-29 08:56:54 -04:00
docUtils.d.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
docUtils.js (core) move home server into core 2020-07-21 20:39:10 -04:00
DocWorker.ts (core) Update export CSV and Excel endpoints 2021-08-31 10:47:24 -07:00
DocWorkerMap.ts (core) revive saml support and test against Auth0 2021-08-16 17:36:09 -04:00
ExcelFormatter.ts (core) Simple localization support and currency selector. 2021-08-26 13:36:49 -07:00
ExpandedQuery.ts (core) Linking summary tables grouped by list columns 2021-08-10 20:41:24 +02:00
Export.ts (core) Relocate export urls to /download/ 2021-09-02 09:36:33 -07:00
ExportCSV.ts (core) Relocate export urls to /download/ 2021-09-02 09:36:33 -07:00
ExportXLSX.ts (core) Relocate export urls to /download/ 2021-09-02 09:36:33 -07:00
expressWrap.ts (core) give more detailed reasons for access denied when memos are present 2021-02-15 17:02:24 -05:00
ExternalStorage.ts (core) Add rules to eslint to better match our coding conventions. 2021-05-24 12:56:18 -04:00
extractOrg.ts (core) Refactoring google drive plugin 2021-07-14 09:52:04 +02:00
FileParserElement.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
filterUtils.ts (core) uncheck FullCopy special when copying/forking a document 2021-04-29 08:56:54 -04:00
FlexServer.ts (core) add tests for site deletion 2021-09-14 10:03:18 -04:00
GoogleAuth.ts (core) support python3 in grist-core, and running engine via docker and/or gvisor 2021-07-28 09:02:32 -04:00
GoogleExport.ts (core) support python3 in grist-core, and running engine via docker and/or gvisor 2021-07-28 09:02:32 -04:00
GoogleImport.ts (core) Adding google drive plugin as a fallback for url plugin 2021-08-04 17:59:13 +02:00
GranularAccess.ts (core) apply SchemaEdit flag to metadata changes in general 2021-09-16 13:36:20 -04:00
GristServer.ts (core) add tests for site deletion 2021-09-14 10:03:18 -04:00
gristSessions.ts (core) clean up a collection of small problems affecting grist-core 2021-08-17 21:44:50 -04:00
guessExt.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
HashUtil.ts (core) add more detail to /compare endpoint 2020-09-18 16:31:29 -04:00
HostedMetadataManager.ts (core) revamp snapshot inventory 2020-10-30 13:52:46 -04:00
HostedStorageManager.ts (core) Add rules to eslint to better match our coding conventions. 2021-05-24 12:56:18 -04:00
IBilling.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
IChecksumStore.ts (core) revamp snapshot inventory 2020-10-30 13:52:46 -04:00
ICreate.ts (core) clean up a collection of small problems affecting grist-core 2021-08-17 21:44:50 -04:00
IDocStorageManager.ts (core) uncheck FullCopy special when copying/forking a document 2021-04-29 08:56:54 -04:00
idUtils.ts (core) start reconciling forking with granular access 2021-01-12 14:08:49 -05:00
IElectionStore.ts (core) move some material to core that slipped through in a rebase 2020-07-23 11:29:05 -04:00
INotifier.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
ISandbox.ts (core) add experimental support for python3 in staging 2021-08-26 09:39:26 -04:00
IShell.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
ITestingHooks-ti.ts (core) Remove a bunch of dead code 2021-07-01 18:38:21 +02:00
ITestingHooks.ts (core) Remove a bunch of dead code 2021-07-01 18:38:21 +02:00
log.ts (core) give instructions on using Grist with docker 2020-10-28 13:59:13 -04:00
manifest.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
MinimalLogin.ts (core) clean up a collection of small problems affecting grist-core 2021-08-17 21:44:50 -04:00
NSandbox.ts (core) add experimental support for python3 in staging 2021-08-26 09:39:26 -04:00
OnDemandActions.ts (core) Configure more comprehensive eslint rules for Typescript 2021-04-26 18:54:55 -04:00
PermissionInfo.ts (core) Add 'user' variable to trigger formulas 2021-07-15 15:18:32 -07:00
Permit.ts (core) revive saml support and test against Auth0 2021-08-16 17:36:09 -04:00
places.ts (core) fix docker packaging after core shuffle 2020-07-22 14:45:42 -04:00
PluginEndpoint.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
PluginManager.ts (core) Add rules to eslint to better match our coding conventions. 2021-05-24 12:56:18 -04:00
reportTimeTaken.ts (core) Log the time taken by decodeActionFromRow() operations. 2021-08-20 11:28:33 -04:00
requestUtils.ts (core) support python3 in grist-core, and running engine via docker and/or gvisor 2021-07-28 09:02:32 -04:00
RowAccess.ts (core) Add rules to eslint to better match our coding conventions. 2021-05-24 12:56:18 -04:00
SafePythonComponent.ts (core) Move file import plugins into core/sandbox/grist 2021-08-09 18:37:14 +02:00
SamlConfig.ts (core) lightly freshen the core readme, mentioning roadmap and forums etc. 2021-08-17 23:51:58 -04:00
sandboxUtil.js (core) move home server into core 2020-07-21 20:39:10 -04:00
sendAppPage.ts (core) add a python3 button 2021-09-16 10:06:04 -04:00
ServerColumnGetters.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
ServerLocale.ts (core) Simple localization support and currency selector. 2021-08-26 13:36:49 -07:00
serverUtils.ts (core) add a python3 button 2021-09-16 10:06:04 -04:00
Sessions.ts (core) clean up a collection of small problems affecting grist-core 2021-08-17 21:44:50 -04:00
Sharing.ts (core) Initial webhooks implementation 2021-09-23 14:35:39 +02:00
shortDesc.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
shutdown.js (core) move home server into core 2020-07-21 20:39:10 -04:00
SQLiteDB.ts (core) revamp snapshot inventory 2020-10-30 13:52:46 -04:00
TagChecker.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
TestingHooks.ts (core) clean up a collection of small problems affecting grist-core 2021-08-17 21:44:50 -04:00
Throttle.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
TimeQuery.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
Triggers.ts (core) Initial webhooks implementation 2021-09-23 14:35:39 +02:00
UnsafeNodeComponent.ts (core) move home server into core 2020-07-21 20:39:10 -04:00
uploads.ts (core) Adding google drive plugin as a fallback for url plugin 2021-08-04 17:59:13 +02:00
WorkCoordinator.ts (core) move home server into core 2020-07-21 20:39:10 -04:00