@agnocon/piece-bigin-by-zoho 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.MIT-AP +24 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions/create-call.d.ts +16 -0
- package/dist/lib/actions/create-call.d.ts.map +1 -0
- package/dist/lib/actions/create-call.js +162 -0
- package/dist/lib/actions/create-call.js.map +1 -0
- package/dist/lib/actions/create-company.d.ts +14 -0
- package/dist/lib/actions/create-company.d.ts.map +1 -0
- package/dist/lib/actions/create-company.js +108 -0
- package/dist/lib/actions/create-company.js.map +1 -0
- package/dist/lib/actions/create-contact.d.ts +18 -0
- package/dist/lib/actions/create-contact.d.ts.map +1 -0
- package/dist/lib/actions/create-contact.js +130 -0
- package/dist/lib/actions/create-contact.js.map +1 -0
- package/dist/lib/actions/create-event.d.ts +18 -0
- package/dist/lib/actions/create-event.d.ts.map +1 -0
- package/dist/lib/actions/create-event.js +360 -0
- package/dist/lib/actions/create-event.js.map +1 -0
- package/dist/lib/actions/create-pipeline-record.d.ts +16 -0
- package/dist/lib/actions/create-pipeline-record.d.ts.map +1 -0
- package/dist/lib/actions/create-pipeline-record.js +219 -0
- package/dist/lib/actions/create-pipeline-record.js.map +1 -0
- package/dist/lib/actions/create-task.d.ts +16 -0
- package/dist/lib/actions/create-task.d.ts.map +1 -0
- package/dist/lib/actions/create-task.js +380 -0
- package/dist/lib/actions/create-task.js.map +1 -0
- package/dist/lib/actions/search-company-record.d.ts +5 -0
- package/dist/lib/actions/search-company-record.d.ts.map +1 -0
- package/dist/lib/actions/search-company-record.js +58 -0
- package/dist/lib/actions/search-company-record.js.map +1 -0
- package/dist/lib/actions/search-contact-record.d.ts +5 -0
- package/dist/lib/actions/search-contact-record.d.ts.map +1 -0
- package/dist/lib/actions/search-contact-record.js +82 -0
- package/dist/lib/actions/search-contact-record.js.map +1 -0
- package/dist/lib/actions/search-pipeline-records.d.ts +5 -0
- package/dist/lib/actions/search-pipeline-records.d.ts.map +1 -0
- package/dist/lib/actions/search-pipeline-records.js +53 -0
- package/dist/lib/actions/search-pipeline-records.js.map +1 -0
- package/dist/lib/actions/search-product.d.ts +5 -0
- package/dist/lib/actions/search-product.d.ts.map +1 -0
- package/dist/lib/actions/search-product.js +60 -0
- package/dist/lib/actions/search-product.js.map +1 -0
- package/dist/lib/actions/search-user.d.ts +7 -0
- package/dist/lib/actions/search-user.d.ts.map +1 -0
- package/dist/lib/actions/search-user.js +75 -0
- package/dist/lib/actions/search-user.js.map +1 -0
- package/dist/lib/actions/update-company.d.ts +7 -0
- package/dist/lib/actions/update-company.d.ts.map +1 -0
- package/dist/lib/actions/update-company.js +224 -0
- package/dist/lib/actions/update-company.js.map +1 -0
- package/dist/lib/actions/update-contact.d.ts +7 -0
- package/dist/lib/actions/update-contact.d.ts.map +1 -0
- package/dist/lib/actions/update-contact.js +248 -0
- package/dist/lib/actions/update-contact.js.map +1 -0
- package/dist/lib/actions/update-event.d.ts +13 -0
- package/dist/lib/actions/update-event.d.ts.map +1 -0
- package/dist/lib/actions/update-event.js +466 -0
- package/dist/lib/actions/update-event.js.map +1 -0
- package/dist/lib/actions/update-pipeline-record.d.ts +14 -0
- package/dist/lib/actions/update-pipeline-record.d.ts.map +1 -0
- package/dist/lib/actions/update-pipeline-record.js +205 -0
- package/dist/lib/actions/update-pipeline-record.js.map +1 -0
- package/dist/lib/actions/update-task.d.ts +13 -0
- package/dist/lib/actions/update-task.d.ts.map +1 -0
- package/dist/lib/actions/update-task.js +449 -0
- package/dist/lib/actions/update-task.js.map +1 -0
- package/dist/lib/auth.d.ts +2 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +59 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/common/constants.d.ts +23 -0
- package/dist/lib/common/constants.d.ts.map +1 -0
- package/dist/lib/common/constants.js +72 -0
- package/dist/lib/common/constants.js.map +1 -0
- package/dist/lib/common/helpers.d.ts +11 -0
- package/dist/lib/common/helpers.d.ts.map +1 -0
- package/dist/lib/common/helpers.js +40 -0
- package/dist/lib/common/helpers.js.map +1 -0
- package/dist/lib/common/props.d.ts +10 -0
- package/dist/lib/common/props.d.ts.map +1 -0
- package/dist/lib/common/props.js +217 -0
- package/dist/lib/common/props.js.map +1 -0
- package/dist/lib/common/request.d.ts +35 -0
- package/dist/lib/common/request.d.ts.map +1 -0
- package/dist/lib/common/request.js +226 -0
- package/dist/lib/common/request.js.map +1 -0
- package/dist/lib/triggers/company-updated.d.ts +3 -0
- package/dist/lib/triggers/company-updated.d.ts.map +1 -0
- package/dist/lib/triggers/company-updated.js +66 -0
- package/dist/lib/triggers/company-updated.js.map +1 -0
- package/dist/lib/triggers/contact-updated.d.ts +3 -0
- package/dist/lib/triggers/contact-updated.d.ts.map +1 -0
- package/dist/lib/triggers/contact-updated.js +66 -0
- package/dist/lib/triggers/contact-updated.js.map +1 -0
- package/dist/lib/triggers/new-call-created.d.ts +3 -0
- package/dist/lib/triggers/new-call-created.d.ts.map +1 -0
- package/dist/lib/triggers/new-call-created.js +66 -0
- package/dist/lib/triggers/new-call-created.js.map +1 -0
- package/dist/lib/triggers/new-company-created.d.ts +3 -0
- package/dist/lib/triggers/new-company-created.d.ts.map +1 -0
- package/dist/lib/triggers/new-company-created.js +66 -0
- package/dist/lib/triggers/new-company-created.js.map +1 -0
- package/dist/lib/triggers/new-contact-created.d.ts +3 -0
- package/dist/lib/triggers/new-contact-created.d.ts.map +1 -0
- package/dist/lib/triggers/new-contact-created.js +75 -0
- package/dist/lib/triggers/new-contact-created.js.map +1 -0
- package/dist/lib/triggers/new-event-created.d.ts +3 -0
- package/dist/lib/triggers/new-event-created.d.ts.map +1 -0
- package/dist/lib/triggers/new-event-created.js +66 -0
- package/dist/lib/triggers/new-event-created.js.map +1 -0
- package/dist/lib/triggers/new-pipeline-record.d.ts +3 -0
- package/dist/lib/triggers/new-pipeline-record.d.ts.map +1 -0
- package/dist/lib/triggers/new-pipeline-record.js +66 -0
- package/dist/lib/triggers/new-pipeline-record.js.map +1 -0
- package/dist/lib/triggers/new-task-created.d.ts +3 -0
- package/dist/lib/triggers/new-task-created.d.ts.map +1 -0
- package/dist/lib/triggers/new-task-created.js +66 -0
- package/dist/lib/triggers/new-task-created.js.map +1 -0
- package/dist/lib/triggers/pipeline-record-updated.d.ts +3 -0
- package/dist/lib/triggers/pipeline-record-updated.d.ts.map +1 -0
- package/dist/lib/triggers/pipeline-record-updated.js +66 -0
- package/dist/lib/triggers/pipeline-record-updated.js.map +1 -0
- package/package.json +46 -0
- package/src/index.ts +72 -0
- package/src/lib/actions/create-call.ts +168 -0
- package/src/lib/actions/create-company.ts +124 -0
- package/src/lib/actions/create-contact.ts +151 -0
- package/src/lib/actions/create-event.ts +399 -0
- package/src/lib/actions/create-pipeline-record.ts +255 -0
- package/src/lib/actions/create-task.ts +426 -0
- package/src/lib/actions/search-company-record.ts +57 -0
- package/src/lib/actions/search-contact-record.ts +79 -0
- package/src/lib/actions/search-pipeline-records.ts +52 -0
- package/src/lib/actions/search-product.ts +60 -0
- package/src/lib/actions/search-user.ts +70 -0
- package/src/lib/actions/update-company.ts +235 -0
- package/src/lib/actions/update-contact.ts +261 -0
- package/src/lib/actions/update-event.ts +528 -0
- package/src/lib/actions/update-pipeline-record.ts +235 -0
- package/src/lib/actions/update-task.ts +499 -0
- package/src/lib/auth.ts +57 -0
- package/src/lib/common/constants.ts +68 -0
- package/src/lib/common/helpers.ts +46 -0
- package/src/lib/common/props.ts +270 -0
- package/src/lib/common/request.ts +285 -0
- package/src/lib/triggers/company-updated.ts +69 -0
- package/src/lib/triggers/contact-updated.ts +65 -0
- package/src/lib/triggers/new-call-created.ts +69 -0
- package/src/lib/triggers/new-company-created.ts +69 -0
- package/src/lib/triggers/new-contact-created.ts +75 -0
- package/src/lib/triggers/new-event-created.ts +69 -0
- package/src/lib/triggers/new-pipeline-record.ts +69 -0
- package/src/lib/triggers/new-task-created.ts +69 -0
- package/src/lib/triggers/pipeline-record-updated.ts +69 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { biginAuth } from '../auth';
|
|
2
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
3
|
+
import { companyDropdown, contactsDropdown, layoutsDropdown, multiContactsDropdown, pipelineRecordsDropdown, productsDropdown, SubPipelineorStageDropdown, tagsDropdown, usersDropdown } from '../common/props';
|
|
4
|
+
import { biginApiService } from '../common/request';
|
|
5
|
+
import { formatDateOnly } from '../common/helpers';
|
|
6
|
+
|
|
7
|
+
export const updatePipelineRecord = createAction({
|
|
8
|
+
auth: biginAuth,
|
|
9
|
+
name: 'updatePipeline',
|
|
10
|
+
displayName: 'Update Pipeline',
|
|
11
|
+
description: 'updates a pipeline record in Bigin',
|
|
12
|
+
audience: 'both',
|
|
13
|
+
aiMetadata: { description: 'Updates an existing pipeline record (deal) in Bigin CRM, identified by selecting the record; any fields you set are overwritten (deal name, sub-pipeline, stage, amount, closing date, owner, company, contact, secondary contacts, associated products, tags). Use to advance a deal stage or revise its details. Idempotent: re-sending the same field values leaves the record in the same state.', idempotent: true },
|
|
14
|
+
props: {
|
|
15
|
+
pipelineRecordId: pipelineRecordsDropdown,
|
|
16
|
+
pipelineDetails: Property.DynamicProperties({
|
|
17
|
+
auth: biginAuth,
|
|
18
|
+
displayName: 'Pipeline Details',
|
|
19
|
+
description: 'These fields will be prepopulated with pipeline data',
|
|
20
|
+
refreshers: ['pipelineRecordId', 'auth'],
|
|
21
|
+
required: true,
|
|
22
|
+
props: async ({ pipelineRecordId, auth }: any) => {
|
|
23
|
+
const pipelineData = JSON.parse(pipelineRecordId);
|
|
24
|
+
const pipelineId = pipelineData.id;
|
|
25
|
+
if (!pipelineId) {
|
|
26
|
+
throw new Error('Pipeline ID is required to update the record');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const { access_token, api_domain } = auth as any;
|
|
30
|
+
const fieldsResp = await biginApiService.fetchModuleFields(
|
|
31
|
+
access_token,
|
|
32
|
+
api_domain,
|
|
33
|
+
'Pipelines'
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const props: any = {};
|
|
37
|
+
for (const f of (fieldsResp.fields || []) as any[]) {
|
|
38
|
+
const apiName = f.api_name as string;
|
|
39
|
+
if (f.read_only || f.field_read_only) continue;
|
|
40
|
+
if (!f.view_type || f.view_type.edit !== true) continue;
|
|
41
|
+
if (apiName === 'Tag' || apiName === 'id' || apiName === 'Secondary_Contacts') continue;
|
|
42
|
+
|
|
43
|
+
const defaultValue = pipelineData[apiName] ?? undefined;
|
|
44
|
+
switch ((f.data_type as string)?.toLowerCase()) {
|
|
45
|
+
case 'picklist': {
|
|
46
|
+
const options = (f.pick_list_values || []).map((pl: any) => ({
|
|
47
|
+
label: pl.display_value,
|
|
48
|
+
value: pl.actual_value,
|
|
49
|
+
}));
|
|
50
|
+
props[apiName] = Property.StaticDropdown({
|
|
51
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
52
|
+
description: f.tooltip || undefined,
|
|
53
|
+
required: false,
|
|
54
|
+
defaultValue,
|
|
55
|
+
options: { options },
|
|
56
|
+
});
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case 'multiselectpicklist': {
|
|
60
|
+
const options = (f.pick_list_values || []).map((pl: any) => ({
|
|
61
|
+
label: pl.display_value,
|
|
62
|
+
value: pl.actual_value,
|
|
63
|
+
}));
|
|
64
|
+
props[apiName] = Property.StaticMultiSelectDropdown({
|
|
65
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
66
|
+
description: f.tooltip || undefined,
|
|
67
|
+
required: false,
|
|
68
|
+
defaultValue,
|
|
69
|
+
options: { options },
|
|
70
|
+
});
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case 'boolean': {
|
|
74
|
+
props[apiName] = Property.Checkbox({
|
|
75
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
76
|
+
description: f.tooltip || undefined,
|
|
77
|
+
required: false,
|
|
78
|
+
defaultValue: Boolean(defaultValue),
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case 'date': {
|
|
83
|
+
props[apiName] = Property.ShortText({
|
|
84
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
85
|
+
description: f.tooltip || 'Format: YYYY-MM-DD',
|
|
86
|
+
required: false,
|
|
87
|
+
defaultValue,
|
|
88
|
+
});
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case 'datetime': {
|
|
92
|
+
props[apiName] = Property.DateTime({
|
|
93
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
94
|
+
description:
|
|
95
|
+
f.tooltip || 'Format: ISO 8601 (YYYY-MM-DDTHH:mm:ss±HH:mm)',
|
|
96
|
+
required: false,
|
|
97
|
+
defaultValue,
|
|
98
|
+
});
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case 'integer':
|
|
102
|
+
case 'long':
|
|
103
|
+
case 'double':
|
|
104
|
+
case 'decimal':
|
|
105
|
+
case 'currency':
|
|
106
|
+
case 'percent': {
|
|
107
|
+
props[apiName] = Property.Number({
|
|
108
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
109
|
+
description: f.tooltip || undefined,
|
|
110
|
+
required: false,
|
|
111
|
+
defaultValue,
|
|
112
|
+
});
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
default: {
|
|
116
|
+
props[apiName] = Property.ShortText({
|
|
117
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
118
|
+
description: f.tooltip || undefined,
|
|
119
|
+
required: false,
|
|
120
|
+
defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return props;
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
pipeline: layoutsDropdown(
|
|
130
|
+
'Pipelines',
|
|
131
|
+
'Provide the Team Pipeline to which the pipeline record (deal) belongs',
|
|
132
|
+
'Pipelines'
|
|
133
|
+
),
|
|
134
|
+
subPipeline: SubPipelineorStageDropdown(
|
|
135
|
+
'Sub Pipeline',
|
|
136
|
+
'Pick one of the configured sub-pipelines',
|
|
137
|
+
'Sub Pipeline',
|
|
138
|
+
),
|
|
139
|
+
stage: SubPipelineorStageDropdown(
|
|
140
|
+
'Stage',
|
|
141
|
+
'Provide the current stage of the pipeline record (deal) within the Sub-Pipeline',
|
|
142
|
+
'Stage',
|
|
143
|
+
),
|
|
144
|
+
owner: usersDropdown,
|
|
145
|
+
accountName: companyDropdown,
|
|
146
|
+
contactName: contactsDropdown,
|
|
147
|
+
secondaryContacts: multiContactsDropdown,
|
|
148
|
+
associatedProducts: productsDropdown,
|
|
149
|
+
tag: tagsDropdown('Pipelines'),
|
|
150
|
+
},
|
|
151
|
+
async run({propsValue, auth}) {
|
|
152
|
+
const pipelineData = JSON.parse(propsValue.pipelineRecordId as string);
|
|
153
|
+
|
|
154
|
+
const payload: any = {
|
|
155
|
+
id: pipelineData.id,
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
if (propsValue.owner) payload.Owner = propsValue.owner;
|
|
159
|
+
if (propsValue.accountName)
|
|
160
|
+
payload.Account_Name = { id: propsValue.accountName };
|
|
161
|
+
if (propsValue.contactName)
|
|
162
|
+
payload.Contact_Name = { id: propsValue.contactName };
|
|
163
|
+
|
|
164
|
+
if (propsValue.subPipeline)
|
|
165
|
+
payload['Sub Pipeline'] = propsValue.subPipeline;
|
|
166
|
+
|
|
167
|
+
if (propsValue.stage) payload.Stage = propsValue.stage;
|
|
168
|
+
if (propsValue.pipelineDetails['dealName']) payload.Deal_Name = propsValue.pipelineDetails['dealName'];
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if (propsValue.pipelineDetails['amount']) payload.Amount = propsValue.pipelineDetails['amount'];
|
|
172
|
+
if (propsValue.pipelineDetails['closingDate'])
|
|
173
|
+
payload.Closing_Date = formatDateOnly(
|
|
174
|
+
propsValue.pipelineDetails['closingDate']
|
|
175
|
+
);
|
|
176
|
+
if (propsValue.pipeline) {
|
|
177
|
+
const pipeline = JSON.parse(propsValue.pipeline as any);
|
|
178
|
+
payload.Pipeline = { id: pipeline.id, name: pipeline.name };
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (propsValue.associatedProducts) {
|
|
182
|
+
payload.Associated_Products = propsValue.associatedProducts.map(
|
|
183
|
+
(product: any) => {
|
|
184
|
+
const p = JSON.parse(product);
|
|
185
|
+
return { id: p.id, name: p.name };
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
if (propsValue.tag) {
|
|
190
|
+
payload.Tag = propsValue.tag.map((t: any) => ({ name: t }));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const {access_token, api_domain} = auth as any;
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
const response = await biginApiService.updatePipelineRecord(
|
|
197
|
+
access_token,
|
|
198
|
+
api_domain,
|
|
199
|
+
{ data: [payload] }
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
if (
|
|
203
|
+
propsValue.secondaryContacts &&
|
|
204
|
+
Array.isArray(propsValue.secondaryContacts)
|
|
205
|
+
) {
|
|
206
|
+
const secondaries = (propsValue.secondaryContacts as any[])
|
|
207
|
+
.map((v: any) => String(v))
|
|
208
|
+
.filter((id: string) => id !== propsValue.contactName);
|
|
209
|
+
|
|
210
|
+
if (secondaries.length > 0) {
|
|
211
|
+
await biginApiService.updatePipelineRecord(
|
|
212
|
+
access_token,
|
|
213
|
+
api_domain,
|
|
214
|
+
{
|
|
215
|
+
data: [
|
|
216
|
+
{
|
|
217
|
+
id: pipelineData.id,
|
|
218
|
+
Secondary_Contacts: secondaries.map((id: string) => ({ id })),
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
message: 'Pipeline record updated successfully',
|
|
228
|
+
pipelineRecord: response.data[0],
|
|
229
|
+
};
|
|
230
|
+
} catch (error: any) {
|
|
231
|
+
console.error('Error updating pipeline record:', error);
|
|
232
|
+
throw new Error(error);
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
});
|