-
-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webhook trigger update by column #832
Webhook trigger update by column #832
Conversation
The last error seams to have no link to my feature .. |
Thanks @CamilleLegeron for the contribution! I'm afraid I'm not working at GristLabs any more though, so I've requested review from others. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments I hope that may help :)
app/common/Triggers.ts
Outdated
@@ -10,6 +10,7 @@ export interface WebhookFields { | |||
url: string; | |||
eventTypes: Array<"add"|"update">; | |||
tableId: string; | |||
columnIds: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may run yarn build:prod
to update the Triggers-ti.ts
file (whose classes are used as body validator for the APIs):
$ yarn build:prod
yarn run v1.22.21
$ buildtools/build.sh
+ tsc --build
+ buildtools/update_type_info.sh app
Updating app/common/Triggers-ti.ts from app/common/Triggers.ts
Updating app/plugin/CustomSectionAPI-ti.ts from app/plugin/CustomSectionAPI.ts
Updating app/plugin/GristData-ti.ts from app/plugin/GristData.ts
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have few more comments :)
|
||
const webhook = await autoSubscribe('200', docId, { | ||
columnIds: 'A', eventTypes: ['add', 'update'] | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be hard to add another test with a second column in columnIds
?
This would allow to check whether the ;
works as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your right, I will do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
Hi, I just put a new notification for you paulfitz in case you haven't seen this PR. Sorry if your are too busy, in that case I can ask other dev in gristlabs to review this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @CamilleLegeron !
test/server/lib/DocApi.ts
Outdated
}; | ||
|
||
// subscribe | ||
const webhook = await subscribe('foo', docId, origFields); | ||
const { data } = await axios.post( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change just to use newer /webhooks
instead of older /_subscribe
endpoint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to test the newer endpoint but I don't remember if in this case something went wrong with the older
Do you want me to create a specific subscribe function with the new endpoint call and rename the old one with oldEndpointsubscribe
or something like that
app/server/lib/DocApi.ts
Outdated
throw new ApiError(`Cannot find columns "${columnIds}" because table is not known`, 404); | ||
} | ||
// columnIds have to be of shape "columnId; columnId; columnId" | ||
fields.columnRefList = [GristObjCode.List, ...columnIds.split(";") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here, we are in the back-end, defining the behavior of a REST API endpoint. Sending ;
-separated columns seems pretty inconsistent with how lists are handled elsewhere in the API. I can understand doing that in the minimalist front-end UI, just because of lack of time to do something pretty (the same trade-off we made for isReadyColumn), but is there a way to isolate that to the front end? Once the back-end does something, changing it is hard since someone may rely on it.
It will be sad if we eventually add a pretty UI for this and it ends up having the convert a nice structured list of column ids into a semicolon separated string to send to the back end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
columnIds
is a little vague, and a bit inconsistent with isReadyColumn
which doesn't specify the Id
part. Maybe something like watchedColumns
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if column ids are stored as strings, would need some thinking about updating them when columns are renamed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This remark is a very good point, I isolated this logical in the frontend.
The watchedColIds
is stored in the db as watchedColRefList
so if the column is renamed it's works well
The test failure looks relevant:
|
Well ... I don't understand why this error happen, reinitializing the migration it works well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK for me modulo my comment related to the options
column.
@paulfitz, send you this notification in case you haven't seen I worked on this PR :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this @CamilleLegeron !
Context
#763
Done
Screencast from 06-02-2024 11:44:39.webm
Screencast from 06-02-2024 11:46:48.webm
I used a string for columnIds because it seems to be difficult to show only the list corresponding to the selected tableId to the user. If we change the list shown to the user we change it for all instance of webhooks, that it's not acceptable.