6071 return only updated fields of records in zapier update trigger (#8193)
- move webhook triggers into `entity-events-to-db.listener.ts` - refactor event management - add a `@OnDatabaseEvent` decorator to manage database events - add updatedFields in updated events - update openApi webhooks docs - update zapier integration
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import chalk from 'chalk';
|
||||
import { Command } from 'nest-commander';
|
||||
import chalk from 'chalk';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
import { ActiveWorkspacesCommandRunner } from 'src/database/commands/active-workspaces.command';
|
||||
@ -43,17 +43,26 @@ export class CopyWebhookOperationIntoOperationsCommand extends ActiveWorkspacesC
|
||||
|
||||
for (const webhook of webhooks) {
|
||||
if ('operation' in webhook) {
|
||||
let newOperation = webhook.operation;
|
||||
let newOpe = webhook.operation;
|
||||
|
||||
const [firstWebhookPart, lastWebhookPart] = newOperation.split('.');
|
||||
newOpe = newOpe.replace(/\bcreate\b(?=\.|$)/g, 'created');
|
||||
newOpe = newOpe.replace(/\bupdate\b(?=\.|$)/g, 'updated');
|
||||
newOpe = newOpe.replace(/\bdelete\b(?=\.|$)/g, 'deleted');
|
||||
newOpe = newOpe.replace(/\bdestroy\b(?=\.|$)/g, 'destroyed');
|
||||
|
||||
if (['created', 'updated', 'deleted'].includes(firstWebhookPart)) {
|
||||
newOperation = `${lastWebhookPart}.${firstWebhookPart}`;
|
||||
const [firstWebhookPart, lastWebhookPart] = newOpe.split('.');
|
||||
|
||||
if (
|
||||
['created', 'updated', 'deleted', 'destroyed'].includes(
|
||||
firstWebhookPart,
|
||||
)
|
||||
) {
|
||||
newOpe = `${lastWebhookPart}.${firstWebhookPart}`;
|
||||
}
|
||||
|
||||
await webhookRepository.update(webhook.id, {
|
||||
operation: newOperation,
|
||||
operations: [newOperation],
|
||||
operation: newOpe,
|
||||
operations: [newOpe],
|
||||
});
|
||||
|
||||
this.logger.log(
|
||||
|
||||
Reference in New Issue
Block a user