Fix create trigger called twice (#3243)
* Fix create trigger called twice * Add Zapier update action * Add Zapier delete action * Update description * Add dropDown for ids
This commit is contained in:
37
packages/twenty-zapier/src/triggers/list_record_ids.ts
Normal file
37
packages/twenty-zapier/src/triggers/list_record_ids.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { Bundle, ZObject } from 'zapier-platform-core';
|
||||
|
||||
import { capitalize } from '../utils/capitalize';
|
||||
import requestDb from '../utils/requestDb';
|
||||
|
||||
const listRecordIdsRequest = async (
|
||||
z: ZObject,
|
||||
bundle: Bundle,
|
||||
): Promise<{ id: string }[]> => {
|
||||
const data = bundle.inputData;
|
||||
const namePlural = data.namePlural;
|
||||
const query = `
|
||||
query List${capitalize(namePlural)}Ids {
|
||||
${namePlural}{edges{node{id}}}
|
||||
}`;
|
||||
const result = await requestDb(z, bundle, query);
|
||||
return result.data[namePlural]['edges'].map((edge: any) => {
|
||||
return {
|
||||
id: edge.node.id,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
export const listRecordIdsKey = 'list_record_ids';
|
||||
|
||||
export default {
|
||||
display: {
|
||||
description: 'List Record Ids of an object.',
|
||||
label: 'List Record Ids.',
|
||||
hidden: true,
|
||||
},
|
||||
key: listRecordIdsKey,
|
||||
noun: 'Object',
|
||||
operation: {
|
||||
perform: listRecordIdsRequest,
|
||||
},
|
||||
};
|
||||
@ -1,3 +1,5 @@
|
||||
import { Bundle, ZObject } from 'zapier-platform-core';
|
||||
|
||||
import { findObjectNamesPluralKey } from '../triggers/find_object_names_plural';
|
||||
import {
|
||||
listSample,
|
||||
@ -5,8 +7,7 @@ import {
|
||||
perform,
|
||||
performUnsubscribe,
|
||||
subscribe,
|
||||
} from '../utils/triggers.utils';
|
||||
import { Bundle, ZObject } from 'zapier-platform-core';
|
||||
} from '../utils/triggers/triggers.utils';
|
||||
|
||||
export const triggerRecordCreatedKey = 'trigger_record_created';
|
||||
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
import { Bundle, ZObject } from 'zapier-platform-core';
|
||||
|
||||
import { findObjectNamesPluralKey } from '../triggers/find_object_names_plural';
|
||||
import {
|
||||
perform,
|
||||
listSample,
|
||||
subscribe,
|
||||
performUnsubscribe,
|
||||
Operation,
|
||||
} from '../utils/triggers.utils';
|
||||
import { Bundle, ZObject } from 'zapier-platform-core';
|
||||
perform,
|
||||
performUnsubscribe,
|
||||
subscribe,
|
||||
} from '../utils/triggers/triggers.utils';
|
||||
|
||||
export const triggerRecordDeletedKey = 'trigger_record_deleted';
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import { Bundle, ZObject } from 'zapier-platform-core';
|
||||
|
||||
import { findObjectNamesPluralKey } from '../triggers/find_object_names_plural';
|
||||
import {
|
||||
listSample,
|
||||
@ -5,8 +7,7 @@ import {
|
||||
perform,
|
||||
performUnsubscribe,
|
||||
subscribe,
|
||||
} from '../utils/triggers.utils';
|
||||
import { Bundle, ZObject } from 'zapier-platform-core';
|
||||
} from '../utils/triggers/triggers.utils';
|
||||
|
||||
export const triggerRecordUpdatedKey = 'trigger_record_updated';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user