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:
martmull
2024-11-04 17:44:36 +01:00
committed by GitHub
parent 741020fbb0
commit 695991881f
62 changed files with 547 additions and 578 deletions

View File

@ -4,7 +4,7 @@ import { crudRecordKey } from '../../creates/crud_record';
import App from '../../index';
import getBundle from '../../utils/getBundle';
import requestDb from '../../utils/requestDb';
import { Operation } from '../../utils/triggers/triggers.utils';
import { DatabaseEventAction } from '../../utils/triggers/triggers.utils';
const appTester = createAppTester(App);
tools.env.inject();
@ -12,7 +12,7 @@ describe('creates.create_company', () => {
test('should run to create a Company Record', async () => {
const bundle = getBundle({
nameSingular: 'Company',
crudZapierOperation: Operation.create,
crudZapierOperation: DatabaseEventAction.CREATED,
name: 'Company Name',
address: { addressCity: 'Paris' },
linkedinLink: {
@ -56,7 +56,7 @@ describe('creates.create_company', () => {
test('should run to create a Person Record', async () => {
const bundle = getBundle({
nameSingular: 'Person',
crudZapierOperation: Operation.create,
crudZapierOperation: DatabaseEventAction.CREATED,
name: { firstName: 'John', lastName: 'Doe' },
phones: {
primaryPhoneNumber: '610203040',
@ -90,7 +90,7 @@ describe('creates.update_company', () => {
test('should run to update a Company record', async () => {
const createBundle = getBundle({
nameSingular: 'Company',
crudZapierOperation: Operation.create,
crudZapierOperation: DatabaseEventAction.CREATED,
name: 'Company Name',
employees: 25,
});
@ -104,7 +104,7 @@ describe('creates.update_company', () => {
const updateBundle = getBundle({
nameSingular: 'Company',
crudZapierOperation: Operation.update,
crudZapierOperation: DatabaseEventAction.UPDATED,
id: companyId,
name: 'Updated Company Name',
});
@ -133,7 +133,7 @@ describe('creates.delete_company', () => {
test('should run to delete a Company record', async () => {
const createBundle = getBundle({
nameSingular: 'Company',
crudZapierOperation: Operation.create,
crudZapierOperation: DatabaseEventAction.CREATED,
name: 'Delete Company Name',
employees: 25,
});
@ -147,7 +147,7 @@ describe('creates.delete_company', () => {
const deleteBundle = getBundle({
nameSingular: 'Company',
crudZapierOperation: Operation.delete,
crudZapierOperation: DatabaseEventAction.DELETED,
id: companyId,
});

View File

@ -4,13 +4,14 @@ import App from '../../index';
import { triggerRecordKey } from '../../triggers/trigger_record';
import getBundle from '../../utils/getBundle';
import requestDb from '../../utils/requestDb';
import { DatabaseEventAction } from '../../utils/triggers/triggers.utils';
const appTester = createAppTester(App);
describe('triggers.trigger_record.created', () => {
test('should succeed to subscribe', async () => {
const bundle = getBundle({});
bundle.inputData.nameSingular = 'company';
bundle.inputData.operation = 'create';
bundle.inputData.operation = DatabaseEventAction.CREATED;
bundle.targetUrl = 'https://test.com';
const result = await appTester(
App.triggers[triggerRecordKey].operation.performSubscribe,