feat: Convert all app files to JS
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create activity',
|
||||
@@ -9,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Subject',
|
||||
key: 'subject',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -17,7 +17,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Organization',
|
||||
key: 'organizationId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -35,7 +35,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Assigned To',
|
||||
key: 'userId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'If omitted, the activity will be assigned to the user of the connected account.',
|
||||
@@ -54,7 +54,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Person',
|
||||
key: 'personId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -72,7 +72,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Deal',
|
||||
key: 'dealId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -90,7 +90,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Is done?',
|
||||
key: 'isDone',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
options: [
|
||||
@@ -107,7 +107,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Type',
|
||||
key: 'type',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -125,7 +125,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Due Date',
|
||||
key: 'dueDate',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Format must be YYYY-MM-DD',
|
||||
variables: true,
|
||||
@@ -133,7 +133,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Due Time',
|
||||
key: 'dueTime',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Format must be HH:MM',
|
||||
variables: true,
|
||||
@@ -141,7 +141,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Duration',
|
||||
key: 'duration',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Format must be HH:MM',
|
||||
variables: true,
|
||||
@@ -149,7 +149,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Note',
|
||||
key: 'note',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Accepts HTML format',
|
||||
variables: true,
|
||||
@@ -172,17 +172,17 @@ export default defineAction({
|
||||
} = $.step.parameters;
|
||||
|
||||
const fields = {
|
||||
subject: subject as string,
|
||||
org_id: organizationId as number,
|
||||
user_id: userId as number,
|
||||
person_id: personId as number,
|
||||
deal_id: dealId as number,
|
||||
done: isDone as number,
|
||||
type: type as string,
|
||||
due_time: dueTime as string,
|
||||
due_date: dueDate as string,
|
||||
duration: duration as string,
|
||||
note: note as string,
|
||||
subject: subject,
|
||||
org_id: organizationId,
|
||||
user_id: userId,
|
||||
person_id: personId,
|
||||
deal_id: dealId,
|
||||
done: isDone,
|
||||
type: type,
|
||||
due_time: dueTime,
|
||||
due_date: dueDate,
|
||||
duration: duration,
|
||||
note: note,
|
||||
};
|
||||
|
||||
const body = filterProvidedFields(fields);
|
@@ -1,5 +1,5 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create deal',
|
||||
@@ -9,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -17,7 +17,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Creation Date',
|
||||
key: 'addTime',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description:
|
||||
'Requires admin access to Pipedrive account. Format: YYYY-MM-DD HH:MM:SS',
|
||||
@@ -26,7 +26,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Status',
|
||||
key: 'status',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
options: [
|
||||
@@ -51,7 +51,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Lost Reason',
|
||||
key: 'lostReason',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -59,7 +59,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Stage',
|
||||
key: 'stageId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
value: '1',
|
||||
description:
|
||||
@@ -94,7 +94,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Owner',
|
||||
key: 'userId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Select user who will be marked as the owner of this deal. If omitted, the authorized user will be used.',
|
||||
@@ -113,7 +113,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Organization',
|
||||
key: 'organizationId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: 'Organization this deal will be associated with.',
|
||||
variables: true,
|
||||
@@ -131,7 +131,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Person',
|
||||
key: 'personId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: 'Person this deal will be associated with.',
|
||||
variables: true,
|
||||
@@ -149,7 +149,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Probability',
|
||||
key: 'probability',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description:
|
||||
'The success probability percentage of the deal. Used/shown only when deal_probability for the pipeline of the deal is enabled.',
|
||||
@@ -158,7 +158,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Expected Close Date',
|
||||
key: 'expectedCloseDate',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description:
|
||||
'The expected close date of the deal. In ISO 8601 format: YYYY-MM-DD.',
|
||||
@@ -167,7 +167,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Value',
|
||||
key: 'value',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'The value of the deal. If omitted, value will be set to 0.',
|
||||
variables: true,
|
||||
@@ -175,7 +175,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Currency',
|
||||
key: 'currency',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'The currency of the deal. Accepts a 3-character currency code. If omitted, currency will be set to the default currency of the authorized user.',
|
||||
@@ -210,18 +210,18 @@ export default defineAction({
|
||||
} = $.step.parameters;
|
||||
|
||||
const fields = {
|
||||
title: title as string,
|
||||
value: value as string,
|
||||
add_time: addTime as string,
|
||||
status: status as string,
|
||||
lost_reason: lostReason as string,
|
||||
stage_id: stageId as number,
|
||||
user_id: userId as number,
|
||||
org_id: organizationId as number,
|
||||
person_id: personId as number,
|
||||
probability: probability as number,
|
||||
expected_close_date: expectedCloseDate as string,
|
||||
currency: currency as string,
|
||||
title: title,
|
||||
value: value,
|
||||
add_time: addTime,
|
||||
status: status,
|
||||
lost_reason: lostReason,
|
||||
stage_id: stageId,
|
||||
user_id: userId,
|
||||
org_id: organizationId,
|
||||
person_id: personId,
|
||||
probability: probability,
|
||||
expected_close_date: expectedCloseDate,
|
||||
currency: currency,
|
||||
};
|
||||
|
||||
const body = filterProvidedFields(fields);
|
@@ -1,9 +1,5 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields';
|
||||
|
||||
type LabelIds = { __id: string; leadLabelId: string }[];
|
||||
|
||||
type LabelValue = { amount?: number; currency?: string };
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create lead',
|
||||
@@ -13,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -21,7 +17,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Person',
|
||||
key: 'personId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Lead must be associated with at least one person or organization.',
|
||||
@@ -40,7 +36,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Organization',
|
||||
key: 'organizationId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Lead must be associated with at least one person or organization.',
|
||||
@@ -59,7 +55,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Owner',
|
||||
key: 'ownerId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Select user who will be marked as the owner of this lead. If omitted, the authorized user will be used.',
|
||||
@@ -78,14 +74,14 @@ export default defineAction({
|
||||
{
|
||||
label: 'Lead Labels',
|
||||
key: 'labelIds',
|
||||
type: 'dynamic' as const,
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Label',
|
||||
key: 'leadLabelId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
variables: true,
|
||||
source: {
|
||||
@@ -104,7 +100,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Expected Close Date',
|
||||
key: 'expectedCloseDate',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'E.g. 2023-10-23',
|
||||
variables: true,
|
||||
@@ -112,7 +108,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Lead Value',
|
||||
key: 'value',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'E.g. 150',
|
||||
variables: true,
|
||||
@@ -120,7 +116,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Lead Value Currency',
|
||||
key: 'currency',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: 'This field is required if a Lead Value amount is provided.',
|
||||
variables: true,
|
||||
@@ -149,25 +145,25 @@ export default defineAction({
|
||||
currency,
|
||||
} = $.step.parameters;
|
||||
|
||||
const onlyLabelIds = (labelIds as LabelIds)
|
||||
const onlyLabelIds = labelIds
|
||||
.map((labelId) => labelId.leadLabelId)
|
||||
.filter(Boolean);
|
||||
|
||||
const labelValue: LabelValue = {};
|
||||
const labelValue = {};
|
||||
|
||||
if (value) {
|
||||
labelValue.amount = Number(value);
|
||||
}
|
||||
if (currency) {
|
||||
labelValue.currency = currency as string;
|
||||
labelValue.currency = currency;
|
||||
}
|
||||
|
||||
const fields = {
|
||||
title: title as string,
|
||||
title: title,
|
||||
person_id: Number(personId),
|
||||
organization_id: Number(organizationId),
|
||||
owner_id: Number(ownerId),
|
||||
expected_close_date: expectedCloseDate as string,
|
||||
expected_close_date: expectedCloseDate,
|
||||
label_ids: onlyLabelIds,
|
||||
value: labelValue,
|
||||
};
|
@@ -1,5 +1,5 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create note',
|
||||
@@ -9,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Content',
|
||||
key: 'content',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Supports some HTML formatting.',
|
||||
variables: true,
|
||||
@@ -17,7 +17,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Deal',
|
||||
key: 'dealId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Note must be associated with at least one deal, person, organization, or lead.',
|
||||
@@ -36,7 +36,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Pin note on specified deal?',
|
||||
key: 'pinnedDeal',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
options: [
|
||||
@@ -53,7 +53,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Person',
|
||||
key: 'personId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Note must be associated with at least one deal, person, organization, or lead.',
|
||||
@@ -72,7 +72,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Pin note on specified person?',
|
||||
key: 'pinnedPerson',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
options: [
|
||||
@@ -89,7 +89,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Organization',
|
||||
key: 'organizationId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Note must be associated with at least one deal, person, organization, or lead.',
|
||||
@@ -108,7 +108,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Pin note on specified organization?',
|
||||
key: 'pinnedOrganization',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
options: [
|
||||
@@ -125,7 +125,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Lead',
|
||||
key: 'leadId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Note must be associated with at least one deal, person, organization, or lead.',
|
||||
@@ -144,7 +144,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Pin note on specified lead?',
|
||||
key: 'pinnedLead',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
options: [
|
||||
@@ -174,15 +174,15 @@ export default defineAction({
|
||||
} = $.step.parameters;
|
||||
|
||||
const fields = {
|
||||
content: content as string,
|
||||
deal_id: dealId as number,
|
||||
pinned_to_deal_flag: pinnedDeal as number,
|
||||
person_id: personId as number,
|
||||
pinned_to_person_flag: pinnedPerson as number,
|
||||
org_id: organizationId as number,
|
||||
pinned_to_organization_flag: pinnedOrganization as number,
|
||||
lead_id: leadId as string,
|
||||
pinned_to_lead_flag: pinnedLead as number,
|
||||
content: content,
|
||||
deal_id: dealId,
|
||||
pinned_to_deal_flag: pinnedDeal,
|
||||
person_id: personId,
|
||||
pinned_to_person_flag: pinnedPerson,
|
||||
org_id: organizationId,
|
||||
pinned_to_organization_flag: pinnedOrganization,
|
||||
lead_id: leadId,
|
||||
pinned_to_lead_flag: pinnedLead,
|
||||
};
|
||||
|
||||
const body = filterProvidedFields(fields);
|
@@ -1,5 +1,5 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create organization',
|
||||
@@ -9,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -17,7 +17,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Owner',
|
||||
key: 'ownerId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -35,7 +35,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Label',
|
||||
key: 'labelId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
@@ -1,15 +1,5 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields';
|
||||
|
||||
type TEmail = {
|
||||
__id: string;
|
||||
email: string;
|
||||
}[];
|
||||
|
||||
type TPhone = {
|
||||
__id: string;
|
||||
phone: string;
|
||||
}[];
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import { filterProvidedFields } from '../../common/filter-provided-fields.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create person',
|
||||
@@ -19,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -27,7 +17,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Owner',
|
||||
key: 'ownerId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -45,7 +35,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Organization',
|
||||
key: 'organizationId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -63,14 +53,14 @@ export default defineAction({
|
||||
{
|
||||
label: 'Emails',
|
||||
key: 'emails',
|
||||
type: 'dynamic' as const,
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Email',
|
||||
key: 'email',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -80,14 +70,14 @@ export default defineAction({
|
||||
{
|
||||
label: 'Phones',
|
||||
key: 'phones',
|
||||
type: 'dynamic' as const,
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Phone',
|
||||
key: 'phone',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -97,7 +87,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Label',
|
||||
key: 'labelId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -116,9 +106,9 @@ export default defineAction({
|
||||
|
||||
async run($) {
|
||||
const { name, ownerId, organizationId, labelId } = $.step.parameters;
|
||||
const emails = $.step.parameters.emails as TEmail;
|
||||
const emails = $.step.parameters.emails;
|
||||
const emailValues = emails.map((entry) => entry.email);
|
||||
const phones = $.step.parameters.phones as TPhone;
|
||||
const phones = $.step.parameters.phones;
|
||||
const phoneValues = phones.map((entry) => entry.phone);
|
||||
|
||||
const fields = {
|
15
packages/backend/src/apps/pipedrive/actions/index.js
Normal file
15
packages/backend/src/apps/pipedrive/actions/index.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import createActivity from './create-activity/index.js';
|
||||
import createDeal from './create-deal/index.js';
|
||||
import createLead from './create-lead/index.js';
|
||||
import createNote from './create-note/index.js';
|
||||
import createOrganization from './create-organization/index.js';
|
||||
import createPerson from './create-person/index.js';
|
||||
|
||||
export default [
|
||||
createActivity,
|
||||
createDeal,
|
||||
createLead,
|
||||
createNote,
|
||||
createOrganization,
|
||||
createPerson,
|
||||
];
|
@@ -1,15 +0,0 @@
|
||||
import createActivity from './create-activity';
|
||||
import createDeal from './create-deal';
|
||||
import createLead from './create-lead';
|
||||
import createNote from './create-note';
|
||||
import createOrganization from './create-organization';
|
||||
import createPerson from './create-person';
|
||||
|
||||
export default [
|
||||
createActivity,
|
||||
createDeal,
|
||||
createLead,
|
||||
createNote,
|
||||
createOrganization,
|
||||
createPerson,
|
||||
];
|
@@ -1,13 +1,12 @@
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
|
||||
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||
export default async function generateAuthUrl($) {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value as string;
|
||||
const redirectUri = oauthRedirectUrlField.value;
|
||||
const searchParams = new URLSearchParams({
|
||||
client_id: $.auth.data.clientId as string,
|
||||
client_id: $.auth.data.clientId,
|
||||
redirect_uri: redirectUri,
|
||||
});
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import generateAuthUrl from './generate-auth-url';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import refreshToken from './refresh-token';
|
||||
import isStillVerified from './is-still-verified';
|
||||
import generateAuthUrl from './generate-auth-url.js';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import refreshToken from './refresh-token.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'oAuthRedirectUrl',
|
||||
label: 'OAuth Redirect URL',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: true,
|
||||
value: '{WEB_APP_URL}/app/pipedrive/connections/add',
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
{
|
||||
key: 'clientId',
|
||||
label: 'Client ID',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -31,7 +31,7 @@ export default {
|
||||
{
|
||||
key: 'clientSecret',
|
||||
label: 'Client Secret',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
@@ -0,0 +1,8 @@
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
|
||||
const isStillVerified = async ($) => {
|
||||
const currentUser = await getCurrentUser($);
|
||||
return !!currentUser;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,9 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
const currentUser = await getCurrentUser($);
|
||||
return !!currentUser;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,10 +1,9 @@
|
||||
import { URLSearchParams } from 'node:url';
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const refreshToken = async ($: IGlobalVariable) => {
|
||||
const refreshToken = async ($) => {
|
||||
const params = new URLSearchParams({
|
||||
grant_type: 'refresh_token',
|
||||
refresh_token: $.auth.data.refreshToken as string,
|
||||
refresh_token: $.auth.data.refreshToken,
|
||||
});
|
||||
|
||||
const headers = {
|
@@ -1,15 +1,14 @@
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const verifyCredentials = async ($) => {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value as string;
|
||||
const redirectUri = oauthRedirectUrlField.value;
|
||||
const params = new URLSearchParams({
|
||||
grant_type: 'authorization_code',
|
||||
code: $.auth.data.code as string,
|
||||
code: $.auth.data.code,
|
||||
redirect_uri: redirectUri,
|
||||
});
|
||||
|
@@ -1,6 +1,4 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if (requestConfig.additionalProperties?.skipAddingAuthHeader)
|
||||
return requestConfig;
|
||||
|
@@ -0,0 +1,16 @@
|
||||
import isObject from 'lodash/isObject.js';
|
||||
|
||||
export function filterProvidedFields(body) {
|
||||
return Object.keys(body).reduce((result, key) => {
|
||||
const value = body[key];
|
||||
if (isObject(value)) {
|
||||
const filteredNestedObj = filterProvidedFields(value);
|
||||
if (Object.keys(filteredNestedObj).length > 0) {
|
||||
result[key] = filteredNestedObj;
|
||||
}
|
||||
} else if (body[key]) {
|
||||
result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}, {});
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
import isObject from 'lodash/isObject';
|
||||
|
||||
export function filterProvidedFields(body: Record<string, unknown>) {
|
||||
return Object.keys(body).reduce<Record<string, unknown>>((result, key) => {
|
||||
const value = body[key];
|
||||
if (isObject(value)) {
|
||||
const filteredNestedObj = filterProvidedFields(
|
||||
value as Record<string, unknown>
|
||||
);
|
||||
if (Object.keys(filteredNestedObj).length > 0) {
|
||||
result[key] = filteredNestedObj;
|
||||
}
|
||||
} else if (body[key]) {
|
||||
result[key] = value;
|
||||
}
|
||||
return result;
|
||||
}, {});
|
||||
}
|
@@ -1,6 +1,4 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
|
||||
const getCurrentUser = async ($) => {
|
||||
const response = await $.http.get(`${$.auth.data.apiDomain}/api/v1/users/me`);
|
||||
const currentUser = response.data.data;
|
||||
|
10
packages/backend/src/apps/pipedrive/common/set-base-url.js
Normal file
10
packages/backend/src/apps/pipedrive/common/set-base-url.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const setBaseUrl = ($, requestConfig) => {
|
||||
const { apiDomain } = $.auth.data;
|
||||
|
||||
if (apiDomain) {
|
||||
requestConfig.baseURL = apiDomain;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
export default setBaseUrl;
|
@@ -1,12 +0,0 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const setBaseUrl: TBeforeRequest = ($, requestConfig) => {
|
||||
const { apiDomain } = $.auth.data;
|
||||
|
||||
if (apiDomain) {
|
||||
requestConfig.baseURL = apiDomain as string;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
export default setBaseUrl;
|
23
packages/backend/src/apps/pipedrive/dynamic-data/index.js
Normal file
23
packages/backend/src/apps/pipedrive/dynamic-data/index.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import listActivityTypes from './list-activity-types/index.js';
|
||||
import listCurrencies from './list-currencies/index.js';
|
||||
import listDeals from './list-deals/index.js';
|
||||
import listLeads from './list-leads/index.js';
|
||||
import listLeadLabels from './list-lead-labels/index.js';
|
||||
import listOrganizations from './list-organizations/index.js';
|
||||
import listOrganizationLabelField from './list-organization-label-field/index.js';
|
||||
import listPersonLabelField from './list-person-label-field/index.js';
|
||||
import listPersons from './list-persons/index.js';
|
||||
import listUsers from './list-users/index.js';
|
||||
|
||||
export default [
|
||||
listActivityTypes,
|
||||
listCurrencies,
|
||||
listDeals,
|
||||
listLeads,
|
||||
listLeadLabels,
|
||||
listOrganizations,
|
||||
listOrganizationLabelField,
|
||||
listPersonLabelField,
|
||||
listPersons,
|
||||
listUsers,
|
||||
];
|
@@ -1,23 +0,0 @@
|
||||
import listActivityTypes from './list-activity-types';
|
||||
import listCurrencies from './list-currencies';
|
||||
import listDeals from './list-deals';
|
||||
import listLeads from './list-leads';
|
||||
import listLeadLabels from './list-lead-labels';
|
||||
import listOrganizations from './list-organizations';
|
||||
import listOrganizationLabelField from './list-organization-label-field';
|
||||
import listPersonLabelField from './list-person-label-field';
|
||||
import listPersons from './list-persons';
|
||||
import listUsers from './list-users';
|
||||
|
||||
export default [
|
||||
listActivityTypes,
|
||||
listCurrencies,
|
||||
listDeals,
|
||||
listLeads,
|
||||
listLeadLabels,
|
||||
listOrganizations,
|
||||
listOrganizationLabelField,
|
||||
listPersonLabelField,
|
||||
listPersons,
|
||||
listUsers,
|
||||
];
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List activity types',
|
||||
key: 'listActivityTypes',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const activityTypes: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const activityTypes = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List currencies',
|
||||
key: 'listCurrencies',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const currencies: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const currencies = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List deals',
|
||||
key: 'listDeals',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const deals: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const deals = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List lead labels',
|
||||
key: 'listLeadLabels',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const leadLabels: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const leadLabels = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List leads',
|
||||
key: 'listLeads',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const leads: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const leads = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List organization label field',
|
||||
key: 'listOrganizationLabelField',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const labelFields: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const labelFields = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
@@ -15,9 +11,7 @@ export default {
|
||||
`${$.auth.data.apiDomain}/api/v1/organizationFields`
|
||||
);
|
||||
|
||||
const labelField = data.data.filter(
|
||||
(field: IJSONObject) => field.key === 'label'
|
||||
);
|
||||
const labelField = data.data.filter((field) => field.key === 'label');
|
||||
const labelOptions = labelField[0].options;
|
||||
|
||||
if (labelOptions?.length) {
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List organizations',
|
||||
key: 'listOrganizations',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const organizations: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const organizations = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List person label field',
|
||||
key: 'listPersonLabelField',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const personFields: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const personFields = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
@@ -24,7 +20,7 @@ export default {
|
||||
params.start = data.additional_data?.pagination?.next_start;
|
||||
|
||||
const labelField = data.data?.filter(
|
||||
(personField: IJSONObject) => personField.key === 'label'
|
||||
(personField) => personField.key === 'label'
|
||||
);
|
||||
const labelOptions = labelField[0].options;
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List persons',
|
||||
key: 'listPersons',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const persons: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const persons = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List users',
|
||||
key: 'listUsers',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const users: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const users = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import setBaseUrl from './common/set-base-url';
|
||||
import auth from './auth';
|
||||
import triggers from './triggers';
|
||||
import actions from './actions';
|
||||
import dynamicData from './dynamic-data';
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import setBaseUrl from './common/set-base-url.js';
|
||||
import auth from './auth/index.js';
|
||||
import triggers from './triggers/index.js';
|
||||
import actions from './actions/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Pipedrive',
|
6
packages/backend/src/apps/pipedrive/triggers/index.js
Normal file
6
packages/backend/src/apps/pipedrive/triggers/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import newActivities from './new-activities/index.js';
|
||||
import newDeals from './new-deals/index.js';
|
||||
import newLeads from './new-leads/index.js';
|
||||
import newNotes from './new-notes/index.js';
|
||||
|
||||
export default [newActivities, newDeals, newLeads, newNotes];
|
@@ -1,6 +0,0 @@
|
||||
import newActivities from './new-activities';
|
||||
import newDeals from './new-deals';
|
||||
import newLeads from './new-leads';
|
||||
import newNotes from './new-notes';
|
||||
|
||||
export default [newActivities, newDeals, newLeads, newNotes];
|
@@ -1,10 +1,4 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
|
||||
type Payload = {
|
||||
start: number;
|
||||
limit: number;
|
||||
sort: string;
|
||||
};
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New activities',
|
||||
@@ -14,7 +8,7 @@ export default defineTrigger({
|
||||
arguments: [],
|
||||
|
||||
async run($) {
|
||||
const params: Payload = {
|
||||
const params = {
|
||||
start: 0,
|
||||
limit: 100,
|
||||
sort: 'add_time DESC',
|
@@ -1,10 +1,4 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
|
||||
type Payload = {
|
||||
start: number;
|
||||
limit: number;
|
||||
sort: string;
|
||||
};
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New deals',
|
||||
@@ -14,7 +8,7 @@ export default defineTrigger({
|
||||
arguments: [],
|
||||
|
||||
async run($) {
|
||||
const params: Payload = {
|
||||
const params = {
|
||||
start: 0,
|
||||
limit: 100,
|
||||
sort: 'add_time DESC',
|
@@ -1,21 +1,4 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
|
||||
type Payload = {
|
||||
start: number;
|
||||
limit: number;
|
||||
sort: string;
|
||||
};
|
||||
|
||||
type ResponseData = {
|
||||
data: {
|
||||
id: number;
|
||||
}[];
|
||||
additional_data: {
|
||||
pagination: {
|
||||
next_start: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New leads',
|
||||
@@ -25,7 +8,7 @@ export default defineTrigger({
|
||||
arguments: [],
|
||||
|
||||
async run($) {
|
||||
const params: Payload = {
|
||||
const params = {
|
||||
start: 0,
|
||||
limit: 100,
|
||||
sort: 'add_time DESC',
|
@@ -1,10 +1,4 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
|
||||
type Payload = {
|
||||
start: number;
|
||||
limit: number;
|
||||
sort: string;
|
||||
};
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New notes',
|
||||
@@ -14,7 +8,7 @@ export default defineTrigger({
|
||||
arguments: [],
|
||||
|
||||
async run($) {
|
||||
const params: Payload = {
|
||||
const params = {
|
||||
start: 0,
|
||||
limit: 100,
|
||||
sort: 'add_time DESC',
|
Reference in New Issue
Block a user