@activepieces/piece-bigin-by-zoho 0.0.1
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/README.md +7 -0
- package/package.json +38 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +121 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-call.d.ts +15 -0
- package/src/lib/actions/create-call.js +155 -0
- package/src/lib/actions/create-call.js.map +1 -0
- package/src/lib/actions/create-company.d.ts +13 -0
- package/src/lib/actions/create-company.js +104 -0
- package/src/lib/actions/create-company.js.map +1 -0
- package/src/lib/actions/create-contact.d.ts +17 -0
- package/src/lib/actions/create-contact.js +126 -0
- package/src/lib/actions/create-contact.js.map +1 -0
- package/src/lib/actions/create-event.d.ts +17 -0
- package/src/lib/actions/create-event.js +351 -0
- package/src/lib/actions/create-event.js.map +1 -0
- package/src/lib/actions/create-pipeline-record.d.ts +15 -0
- package/src/lib/actions/create-pipeline-record.js +213 -0
- package/src/lib/actions/create-pipeline-record.js.map +1 -0
- package/src/lib/actions/create-task.d.ts +15 -0
- package/src/lib/actions/create-task.js +371 -0
- package/src/lib/actions/create-task.js.map +1 -0
- package/src/lib/actions/search-company-record.d.ts +4 -0
- package/src/lib/actions/search-company-record.js +53 -0
- package/src/lib/actions/search-company-record.js.map +1 -0
- package/src/lib/actions/search-contact-record.d.ts +4 -0
- package/src/lib/actions/search-contact-record.js +77 -0
- package/src/lib/actions/search-contact-record.js.map +1 -0
- package/src/lib/actions/search-pipeline-records.d.ts +4 -0
- package/src/lib/actions/search-pipeline-records.js +48 -0
- package/src/lib/actions/search-pipeline-records.js.map +1 -0
- package/src/lib/actions/search-product.d.ts +4 -0
- package/src/lib/actions/search-product.js +55 -0
- package/src/lib/actions/search-product.js.map +1 -0
- package/src/lib/actions/search-user.d.ts +6 -0
- package/src/lib/actions/search-user.js +70 -0
- package/src/lib/actions/search-user.js.map +1 -0
- package/src/lib/actions/update-company.d.ts +6 -0
- package/src/lib/actions/update-company.js +217 -0
- package/src/lib/actions/update-company.js.map +1 -0
- package/src/lib/actions/update-contact.d.ts +6 -0
- package/src/lib/actions/update-contact.js +241 -0
- package/src/lib/actions/update-contact.js.map +1 -0
- package/src/lib/actions/update-event.d.ts +12 -0
- package/src/lib/actions/update-event.js +454 -0
- package/src/lib/actions/update-event.js.map +1 -0
- package/src/lib/actions/update-pipeline-record.d.ts +13 -0
- package/src/lib/actions/update-pipeline-record.js +200 -0
- package/src/lib/actions/update-pipeline-record.js.map +1 -0
- package/src/lib/actions/update-task.d.ts +12 -0
- package/src/lib/actions/update-task.js +436 -0
- package/src/lib/actions/update-task.js.map +1 -0
- package/src/lib/common/constants.d.ts +22 -0
- package/src/lib/common/constants.js +70 -0
- package/src/lib/common/constants.js.map +1 -0
- package/src/lib/common/helpers.d.ts +10 -0
- package/src/lib/common/helpers.js +40 -0
- package/src/lib/common/helpers.js.map +1 -0
- package/src/lib/common/props.d.ts +9 -0
- package/src/lib/common/props.js +205 -0
- package/src/lib/common/props.js.map +1 -0
- package/src/lib/common/request.d.ts +34 -0
- package/src/lib/common/request.js +224 -0
- package/src/lib/common/request.js.map +1 -0
- package/src/lib/triggers/company-updated.d.ts +2 -0
- package/src/lib/triggers/company-updated.js +61 -0
- package/src/lib/triggers/company-updated.js.map +1 -0
- package/src/lib/triggers/contact-updated.d.ts +2 -0
- package/src/lib/triggers/contact-updated.js +61 -0
- package/src/lib/triggers/contact-updated.js.map +1 -0
- package/src/lib/triggers/new-call-created.d.ts +2 -0
- package/src/lib/triggers/new-call-created.js +61 -0
- package/src/lib/triggers/new-call-created.js.map +1 -0
- package/src/lib/triggers/new-company-created.d.ts +2 -0
- package/src/lib/triggers/new-company-created.js +61 -0
- package/src/lib/triggers/new-company-created.js.map +1 -0
- package/src/lib/triggers/new-contact-created.d.ts +2 -0
- package/src/lib/triggers/new-contact-created.js +70 -0
- package/src/lib/triggers/new-contact-created.js.map +1 -0
- package/src/lib/triggers/new-event-created.d.ts +2 -0
- package/src/lib/triggers/new-event-created.js +61 -0
- package/src/lib/triggers/new-event-created.js.map +1 -0
- package/src/lib/triggers/new-pipeline-record.d.ts +2 -0
- package/src/lib/triggers/new-pipeline-record.js +61 -0
- package/src/lib/triggers/new-pipeline-record.js.map +1 -0
- package/src/lib/triggers/new-task-created.d.ts +2 -0
- package/src/lib/triggers/new-task-created.js +61 -0
- package/src/lib/triggers/new-task-created.js.map +1 -0
- package/src/lib/triggers/pipeline-record-updated.d.ts +2 -0
- package/src/lib/triggers/pipeline-record-updated.js +61 -0
- package/src/lib/triggers/pipeline-record-updated.js.map +1 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updatePipelineRecord = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const index_1 = require("../../index");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const props_1 = require("../common/props");
|
|
8
|
+
const request_1 = require("../common/request");
|
|
9
|
+
const helpers_1 = require("../common/helpers");
|
|
10
|
+
exports.updatePipelineRecord = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: index_1.biginAuth,
|
|
12
|
+
name: 'updatePipeline',
|
|
13
|
+
displayName: 'Update Pipeline',
|
|
14
|
+
description: 'updates a pipeline record in Bigin',
|
|
15
|
+
props: {
|
|
16
|
+
pipelineRecordId: props_1.pipelineRecordsDropdown,
|
|
17
|
+
pipelineDetails: pieces_framework_1.Property.DynamicProperties({
|
|
18
|
+
displayName: 'Pipeline Details',
|
|
19
|
+
description: 'These fields will be prepopulated with pipeline data',
|
|
20
|
+
refreshers: ['pipelineRecordId', 'auth'],
|
|
21
|
+
required: true,
|
|
22
|
+
props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ pipelineRecordId, auth }) {
|
|
23
|
+
var _b, _c;
|
|
24
|
+
const pipelineData = JSON.parse(pipelineRecordId);
|
|
25
|
+
const pipelineId = pipelineData.id;
|
|
26
|
+
if (!pipelineId) {
|
|
27
|
+
throw new Error('Pipeline ID is required to update the record');
|
|
28
|
+
}
|
|
29
|
+
const { access_token, api_domain } = auth;
|
|
30
|
+
const fieldsResp = yield request_1.biginApiService.fetchModuleFields(access_token, api_domain, 'Pipelines');
|
|
31
|
+
const props = {};
|
|
32
|
+
for (const f of (fieldsResp.fields || [])) {
|
|
33
|
+
const apiName = f.api_name;
|
|
34
|
+
if (f.read_only || f.field_read_only)
|
|
35
|
+
continue;
|
|
36
|
+
if (!f.view_type || f.view_type.edit !== true)
|
|
37
|
+
continue;
|
|
38
|
+
if (apiName === 'Tag' || apiName === 'id' || apiName === 'Secondary_Contacts')
|
|
39
|
+
continue;
|
|
40
|
+
const defaultValue = (_b = pipelineData[apiName]) !== null && _b !== void 0 ? _b : undefined;
|
|
41
|
+
switch ((_c = f.data_type) === null || _c === void 0 ? void 0 : _c.toLowerCase()) {
|
|
42
|
+
case 'picklist': {
|
|
43
|
+
const options = (f.pick_list_values || []).map((pl) => ({
|
|
44
|
+
label: pl.display_value,
|
|
45
|
+
value: pl.actual_value,
|
|
46
|
+
}));
|
|
47
|
+
props[apiName] = pieces_framework_1.Property.StaticDropdown({
|
|
48
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
49
|
+
description: f.tooltip || undefined,
|
|
50
|
+
required: false,
|
|
51
|
+
defaultValue,
|
|
52
|
+
options: { options },
|
|
53
|
+
});
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case 'multiselectpicklist': {
|
|
57
|
+
const options = (f.pick_list_values || []).map((pl) => ({
|
|
58
|
+
label: pl.display_value,
|
|
59
|
+
value: pl.actual_value,
|
|
60
|
+
}));
|
|
61
|
+
props[apiName] = pieces_framework_1.Property.StaticMultiSelectDropdown({
|
|
62
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
63
|
+
description: f.tooltip || undefined,
|
|
64
|
+
required: false,
|
|
65
|
+
defaultValue,
|
|
66
|
+
options: { options },
|
|
67
|
+
});
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case 'boolean': {
|
|
71
|
+
props[apiName] = pieces_framework_1.Property.Checkbox({
|
|
72
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
73
|
+
description: f.tooltip || undefined,
|
|
74
|
+
required: false,
|
|
75
|
+
defaultValue: Boolean(defaultValue),
|
|
76
|
+
});
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case 'date': {
|
|
80
|
+
props[apiName] = pieces_framework_1.Property.ShortText({
|
|
81
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
82
|
+
description: f.tooltip || 'Format: YYYY-MM-DD',
|
|
83
|
+
required: false,
|
|
84
|
+
defaultValue,
|
|
85
|
+
});
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case 'datetime': {
|
|
89
|
+
props[apiName] = pieces_framework_1.Property.DateTime({
|
|
90
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
91
|
+
description: f.tooltip || 'Format: ISO 8601 (YYYY-MM-DDTHH:mm:ss±HH:mm)',
|
|
92
|
+
required: false,
|
|
93
|
+
defaultValue,
|
|
94
|
+
});
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case 'integer':
|
|
98
|
+
case 'long':
|
|
99
|
+
case 'double':
|
|
100
|
+
case 'decimal':
|
|
101
|
+
case 'currency':
|
|
102
|
+
case 'percent': {
|
|
103
|
+
props[apiName] = pieces_framework_1.Property.Number({
|
|
104
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
105
|
+
description: f.tooltip || undefined,
|
|
106
|
+
required: false,
|
|
107
|
+
defaultValue,
|
|
108
|
+
});
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
default: {
|
|
112
|
+
props[apiName] = pieces_framework_1.Property.ShortText({
|
|
113
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
114
|
+
description: f.tooltip || undefined,
|
|
115
|
+
required: false,
|
|
116
|
+
defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return props;
|
|
122
|
+
}),
|
|
123
|
+
}),
|
|
124
|
+
pipeline: (0, props_1.layoutsDropdown)('Pipelines', 'Provide the Team Pipeline to which the pipeline record (deal) belongs', 'Pipelines'),
|
|
125
|
+
subPipeline: (0, props_1.SubPipelineorStageDropdown)('Sub Pipeline', 'Pick one of the configured sub-pipelines', 'Sub Pipeline'),
|
|
126
|
+
stage: (0, props_1.SubPipelineorStageDropdown)('Stage', 'Provide the current stage of the pipeline record (deal) within the Sub-Pipeline', 'Stage'),
|
|
127
|
+
owner: props_1.usersDropdown,
|
|
128
|
+
accountName: props_1.companyDropdown,
|
|
129
|
+
contactName: props_1.contactsDropdown,
|
|
130
|
+
secondaryContacts: props_1.multiContactsDropdown,
|
|
131
|
+
associatedProducts: props_1.productsDropdown,
|
|
132
|
+
tag: (0, props_1.tagsDropdown)('Pipelines'),
|
|
133
|
+
},
|
|
134
|
+
run(_a) {
|
|
135
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ propsValue, auth }) {
|
|
136
|
+
const pipelineData = JSON.parse(propsValue.pipelineRecordId);
|
|
137
|
+
const payload = {
|
|
138
|
+
id: pipelineData.id,
|
|
139
|
+
};
|
|
140
|
+
if (propsValue.owner)
|
|
141
|
+
payload.Owner = propsValue.owner;
|
|
142
|
+
if (propsValue.accountName)
|
|
143
|
+
payload.Account_Name = { id: propsValue.accountName };
|
|
144
|
+
if (propsValue.contactName)
|
|
145
|
+
payload.Contact_Name = { id: propsValue.contactName };
|
|
146
|
+
if (propsValue.subPipeline)
|
|
147
|
+
payload['Sub Pipeline'] = propsValue.subPipeline;
|
|
148
|
+
if (propsValue.stage)
|
|
149
|
+
payload.Stage = propsValue.stage;
|
|
150
|
+
if (propsValue.pipelineDetails['dealName'])
|
|
151
|
+
payload.Deal_Name = propsValue.pipelineDetails['dealName'];
|
|
152
|
+
if (propsValue.pipelineDetails['amount'])
|
|
153
|
+
payload.Amount = propsValue.pipelineDetails['amount'];
|
|
154
|
+
if (propsValue.pipelineDetails['closingDate'])
|
|
155
|
+
payload.Closing_Date = (0, helpers_1.formatDateOnly)(propsValue.pipelineDetails['closingDate']);
|
|
156
|
+
if (propsValue.pipeline) {
|
|
157
|
+
const pipeline = JSON.parse(propsValue.pipeline);
|
|
158
|
+
payload.Pipeline = { id: pipeline.id, name: pipeline.name };
|
|
159
|
+
}
|
|
160
|
+
if (propsValue.associatedProducts) {
|
|
161
|
+
payload.Associated_Products = propsValue.associatedProducts.map((product) => {
|
|
162
|
+
const p = JSON.parse(product);
|
|
163
|
+
return { id: p.id, name: p.name };
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (propsValue.tag) {
|
|
167
|
+
payload.Tag = propsValue.tag.map((t) => ({ name: t }));
|
|
168
|
+
}
|
|
169
|
+
const { access_token, api_domain } = auth;
|
|
170
|
+
try {
|
|
171
|
+
const response = yield request_1.biginApiService.updatePipelineRecord(access_token, api_domain, { data: [payload] });
|
|
172
|
+
if (propsValue.secondaryContacts &&
|
|
173
|
+
Array.isArray(propsValue.secondaryContacts)) {
|
|
174
|
+
const secondaries = propsValue.secondaryContacts
|
|
175
|
+
.map((v) => String(v))
|
|
176
|
+
.filter((id) => id !== propsValue.contactName);
|
|
177
|
+
if (secondaries.length > 0) {
|
|
178
|
+
yield request_1.biginApiService.updatePipelineRecord(access_token, api_domain, {
|
|
179
|
+
data: [
|
|
180
|
+
{
|
|
181
|
+
id: pipelineData.id,
|
|
182
|
+
Secondary_Contacts: secondaries.map((id) => ({ id })),
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
message: 'Pipeline record updated successfully',
|
|
190
|
+
pipelineRecord: response.data[0],
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
console.error('Error updating pipeline record:', error);
|
|
195
|
+
throw new Error(error);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
//# sourceMappingURL=update-pipeline-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-pipeline-record.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bigin-by-zoho/src/lib/actions/update-pipeline-record.ts"],"names":[],"mappings":";;;;AAAA,uCAAwC;AACxC,qEAAwE;AACxE,2CAAgN;AAChN,+CAAoD;AACpD,+CAAmD;AAEtC,QAAA,oBAAoB,GAAG,IAAA,+BAAY,EAAC;IAC/C,IAAI,EAAE,iBAAS;IACf,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,oCAAoC;IACjD,KAAK,EAAE;QACL,gBAAgB,EAAE,+BAAuB;QACzC,eAAe,EAAE,2BAAQ,CAAC,iBAAiB,CAAC;YAC1C,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EAAE,sDAAsD;YACnE,UAAU,EAAE,CAAC,kBAAkB,EAAE,MAAM,CAAC;YACxC,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,KAAwC,EAAE,oDAAnC,EAAE,gBAAgB,EAAE,IAAI,EAAO;;gBAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;gBAClD,MAAM,UAAU,GAAG,YAAY,CAAC,EAAE,CAAC;gBACnC,IAAI,CAAC,UAAU,EAAE,CAAC;oBAChB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;gBAClE,CAAC;gBAED,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,IAAW,CAAC;gBACjD,MAAM,UAAU,GAAG,MAAM,yBAAe,CAAC,iBAAiB,CACxD,YAAY,EACZ,UAAU,EACV,WAAW,CACZ,CAAC;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AAC;oBACD,MAAM,WAAW,GAAI,UAAU,CAAC,iBAA2B;yBACxD,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;yBAC1B,MAAM,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,EAAE,KAAK,UAAU,CAAC,WAAW,CAAC,CAAC;oBAEzD,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAC3B,MAAM,yBAAe,CAAC,oBAAoB,CACxC,YAAY,EACZ,UAAU,EACV;4BACE,IAAI,EAAE;gCACJ;oCACE,EAAE,EAAE,YAAY,CAAC,EAAE;oCACnB,kBAAkB,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;iCAC9D;6BACF;yBACF,CACF,CAAC;oBACJ,CAAC;gBACH,CAAC;gBAED,OAAO;oBACL,OAAO,EAAE,sCAAsC;oBAC/C,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;iBACjC,CAAC;YACL,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;gBACxD,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;QACF,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const updateTask: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
2
|
+
taskId: import("@activepieces/pieces-framework").DropdownProperty<any, true>;
|
|
3
|
+
owner: import("@activepieces/pieces-framework").DropdownProperty<unknown, false>;
|
|
4
|
+
taskDetails: import("@activepieces/pieces-framework").DynamicProperties<true>;
|
|
5
|
+
enableRecurring: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
6
|
+
recurringInfo: import("@activepieces/pieces-framework").DynamicProperties<false>;
|
|
7
|
+
enableReminder: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
8
|
+
reminderInfo: import("@activepieces/pieces-framework").DynamicProperties<false>;
|
|
9
|
+
relatedModule: import("@activepieces/pieces-framework").DropdownProperty<string, false>;
|
|
10
|
+
relatedTo: import("@activepieces/pieces-framework").DropdownProperty<any, false>;
|
|
11
|
+
tag: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<unknown, false>;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateTask = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const index_1 = require("../../index");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const props_1 = require("../common/props");
|
|
8
|
+
const helpers_1 = require("../common/helpers");
|
|
9
|
+
const request_1 = require("../common/request");
|
|
10
|
+
exports.updateTask = (0, pieces_framework_1.createAction)({
|
|
11
|
+
auth: index_1.biginAuth,
|
|
12
|
+
name: 'updateTask',
|
|
13
|
+
displayName: 'Update Task',
|
|
14
|
+
description: 'updates a Task',
|
|
15
|
+
props: {
|
|
16
|
+
taskId: pieces_framework_1.Property.Dropdown({
|
|
17
|
+
displayName: 'Select Task',
|
|
18
|
+
description: 'Choose a task to update',
|
|
19
|
+
required: true,
|
|
20
|
+
refreshers: ['auth'],
|
|
21
|
+
options: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
if (!context.auth)
|
|
23
|
+
return (0, helpers_1.handleDropdownError)('Please connect your account first');
|
|
24
|
+
const response = yield request_1.biginApiService.fetchTasks(context.auth.access_token, context.auth.api_domain);
|
|
25
|
+
return {
|
|
26
|
+
options: response.data.map((task) => ({
|
|
27
|
+
label: task.Subject,
|
|
28
|
+
value: JSON.stringify(task),
|
|
29
|
+
})),
|
|
30
|
+
};
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
owner: props_1.usersDropdown,
|
|
34
|
+
taskDetails: pieces_framework_1.Property.DynamicProperties({
|
|
35
|
+
displayName: 'Task Details',
|
|
36
|
+
description: 'These fields will be prepopulated with task data',
|
|
37
|
+
refreshers: ['taskId', 'auth'],
|
|
38
|
+
required: true,
|
|
39
|
+
props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ taskId, auth }) {
|
|
40
|
+
var _b, _c;
|
|
41
|
+
if (!taskId)
|
|
42
|
+
return {};
|
|
43
|
+
const task = JSON.parse(taskId);
|
|
44
|
+
const { access_token, api_domain } = auth;
|
|
45
|
+
const fieldsResp = yield request_1.biginApiService.fetchModuleFields(access_token, api_domain, 'Tasks');
|
|
46
|
+
const props = {};
|
|
47
|
+
for (const f of (fieldsResp.fields || [])) {
|
|
48
|
+
const apiName = f.api_name;
|
|
49
|
+
if (f.read_only || f.field_read_only)
|
|
50
|
+
continue;
|
|
51
|
+
if (!f.view_type || f.view_type.edit !== true)
|
|
52
|
+
continue;
|
|
53
|
+
if (apiName === 'Tag' || apiName === 'id')
|
|
54
|
+
continue;
|
|
55
|
+
const defaultValue = (_b = task[apiName]) !== null && _b !== void 0 ? _b : undefined;
|
|
56
|
+
switch ((_c = f.data_type) === null || _c === void 0 ? void 0 : _c.toLowerCase()) {
|
|
57
|
+
case 'picklist': {
|
|
58
|
+
const options = (f.pick_list_values || []).map((pl) => ({
|
|
59
|
+
label: pl.display_value,
|
|
60
|
+
value: pl.actual_value,
|
|
61
|
+
}));
|
|
62
|
+
props[apiName] = pieces_framework_1.Property.StaticDropdown({
|
|
63
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
64
|
+
description: f.tooltip || undefined,
|
|
65
|
+
required: false,
|
|
66
|
+
defaultValue,
|
|
67
|
+
options: { options },
|
|
68
|
+
});
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case 'multiselectpicklist': {
|
|
72
|
+
const options = (f.pick_list_values || []).map((pl) => ({
|
|
73
|
+
label: pl.display_value,
|
|
74
|
+
value: pl.actual_value,
|
|
75
|
+
}));
|
|
76
|
+
props[apiName] = pieces_framework_1.Property.StaticMultiSelectDropdown({
|
|
77
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
78
|
+
description: f.tooltip || undefined,
|
|
79
|
+
required: false,
|
|
80
|
+
defaultValue,
|
|
81
|
+
options: { options },
|
|
82
|
+
});
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case 'boolean': {
|
|
86
|
+
props[apiName] = pieces_framework_1.Property.Checkbox({
|
|
87
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
88
|
+
description: f.tooltip || undefined,
|
|
89
|
+
required: false,
|
|
90
|
+
defaultValue: Boolean(defaultValue),
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case 'date': {
|
|
95
|
+
props[apiName] = pieces_framework_1.Property.ShortText({
|
|
96
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
97
|
+
description: f.tooltip || 'Format: YYYY-MM-DD',
|
|
98
|
+
required: false,
|
|
99
|
+
defaultValue,
|
|
100
|
+
});
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
case 'datetime': {
|
|
104
|
+
props[apiName] = pieces_framework_1.Property.DateTime({
|
|
105
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
106
|
+
description: f.tooltip || 'Format: ISO 8601 (YYYY-MM-DDTHH:mm:ss±HH:mm)',
|
|
107
|
+
required: false,
|
|
108
|
+
defaultValue,
|
|
109
|
+
});
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case 'integer':
|
|
113
|
+
case 'long':
|
|
114
|
+
case 'double':
|
|
115
|
+
case 'decimal':
|
|
116
|
+
case 'currency':
|
|
117
|
+
case 'percent': {
|
|
118
|
+
props[apiName] = pieces_framework_1.Property.Number({
|
|
119
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
120
|
+
description: f.tooltip || undefined,
|
|
121
|
+
required: false,
|
|
122
|
+
defaultValue,
|
|
123
|
+
});
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
default: {
|
|
127
|
+
if (apiName === 'Description') {
|
|
128
|
+
props[apiName] = pieces_framework_1.Property.LongText({
|
|
129
|
+
displayName: 'Description',
|
|
130
|
+
required: false,
|
|
131
|
+
defaultValue,
|
|
132
|
+
});
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
props[apiName] = pieces_framework_1.Property.ShortText({
|
|
136
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
137
|
+
description: f.tooltip || undefined,
|
|
138
|
+
required: false,
|
|
139
|
+
defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return props;
|
|
145
|
+
}),
|
|
146
|
+
}),
|
|
147
|
+
enableRecurring: pieces_framework_1.Property.Checkbox({
|
|
148
|
+
displayName: 'Make Task Recurring',
|
|
149
|
+
description: 'make this task recurring',
|
|
150
|
+
required: false,
|
|
151
|
+
}),
|
|
152
|
+
recurringInfo: pieces_framework_1.Property.DynamicProperties({
|
|
153
|
+
displayName: 'Recurring Info',
|
|
154
|
+
description: 'Please note: Due Date must be set above for recurring tasks',
|
|
155
|
+
refreshers: ['enableRecurring'],
|
|
156
|
+
required: false,
|
|
157
|
+
props: (propsValue, ctx) => {
|
|
158
|
+
if (propsValue['enableRecurring']) {
|
|
159
|
+
return {
|
|
160
|
+
freq: pieces_framework_1.Property.StaticDropdown({
|
|
161
|
+
displayName: 'Frequency',
|
|
162
|
+
required: true,
|
|
163
|
+
options: {
|
|
164
|
+
options: [
|
|
165
|
+
{ label: 'Daily', value: 'DAILY' },
|
|
166
|
+
{ label: 'Weekly', value: 'WEEKLY' },
|
|
167
|
+
{ label: 'Monthly', value: 'MONTHLY' },
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
}),
|
|
171
|
+
interval: pieces_framework_1.Property.Number({
|
|
172
|
+
displayName: 'Interval',
|
|
173
|
+
required: true,
|
|
174
|
+
description: 'Indicates the time gap between each event. The INTERVAL value range from 1 to 99. For example, an INTERVAL of 2 for a WEEKLY recurring event means that there will be a two-week gap between each event.',
|
|
175
|
+
}),
|
|
176
|
+
count: pieces_framework_1.Property.Number({
|
|
177
|
+
displayName: 'Count',
|
|
178
|
+
required: true,
|
|
179
|
+
description: 'Indicates the number of events you want to create. THE COUNT value range from 1 to 99. For example, a COUNT of 3 creates three individual events.',
|
|
180
|
+
}),
|
|
181
|
+
byday: pieces_framework_1.Property.StaticDropdown({
|
|
182
|
+
displayName: 'By Day',
|
|
183
|
+
required: false,
|
|
184
|
+
description: 'Indicates the day of the week the event repeats. The possible values are SU, MO, TU, WE, TH, FR, or SA. This is applicable only for weekly, and monthly events.',
|
|
185
|
+
options: {
|
|
186
|
+
options: [
|
|
187
|
+
{ label: 'Sunday', value: 'SU' },
|
|
188
|
+
{ label: 'Monday', value: 'MO' },
|
|
189
|
+
{ label: 'Tuesday', value: 'TU' },
|
|
190
|
+
{ label: 'Wednesday', value: 'WE' },
|
|
191
|
+
{ label: 'Thursday', value: 'TH' },
|
|
192
|
+
{ label: 'Friday', value: 'FR' },
|
|
193
|
+
{ label: 'Saturday', value: 'SA' },
|
|
194
|
+
],
|
|
195
|
+
},
|
|
196
|
+
}),
|
|
197
|
+
bymonthday: pieces_framework_1.Property.Number({
|
|
198
|
+
displayName: 'By Month Day',
|
|
199
|
+
required: false,
|
|
200
|
+
description: ' Indicates the day of the month the event repeats. The BYMONTHDAY value range from 1 to 31. This is applicable only for weekly and monthly events.',
|
|
201
|
+
}),
|
|
202
|
+
bysetpos: pieces_framework_1.Property.StaticDropdown({
|
|
203
|
+
displayName: 'By Set Position',
|
|
204
|
+
required: false,
|
|
205
|
+
description: 'Indicates the week of the month the event repeats. The possible values are 1 for the first week of the month, 2 for the second week of the month, 3 the for third week of the month, 4 for the fourth week of the month, or -1 for the last week of the month. This is applicable only for weekly and monthly events.',
|
|
206
|
+
options: {
|
|
207
|
+
options: [
|
|
208
|
+
{ label: 'First Week of the Month', value: '1' },
|
|
209
|
+
{ label: 'Second Week of the Month', value: '2' },
|
|
210
|
+
{ label: 'Third Week of the Month', value: '3' },
|
|
211
|
+
{ label: 'Fourth Week of the Month', value: '4' },
|
|
212
|
+
{ label: 'Last Week of the Month', value: '-1' },
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
}),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return {};
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
}),
|
|
223
|
+
enableReminder: pieces_framework_1.Property.Checkbox({
|
|
224
|
+
displayName: 'Enable Reminder',
|
|
225
|
+
description: 'Enable reminder for this task',
|
|
226
|
+
required: false,
|
|
227
|
+
}),
|
|
228
|
+
reminderInfo: pieces_framework_1.Property.DynamicProperties({
|
|
229
|
+
displayName: 'Reminder Information',
|
|
230
|
+
refreshers: ['enableReminder'],
|
|
231
|
+
required: false,
|
|
232
|
+
props: (propsValue, ctx) => {
|
|
233
|
+
if (propsValue['enableReminder']) {
|
|
234
|
+
return {
|
|
235
|
+
reminderAction: pieces_framework_1.Property.StaticDropdown({
|
|
236
|
+
displayName: 'Reminder Action',
|
|
237
|
+
description: 'How the reminder should be shown',
|
|
238
|
+
required: false,
|
|
239
|
+
options: {
|
|
240
|
+
options: [
|
|
241
|
+
{ label: 'Email', value: 'EMAIL' },
|
|
242
|
+
{ label: 'Popup', value: 'POPUP' },
|
|
243
|
+
{ label: 'Email and Popup', value: 'EMAILANDPOPUP' },
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
}),
|
|
247
|
+
reminderType: pieces_framework_1.Property.StaticDropdown({
|
|
248
|
+
displayName: 'Reminder Type',
|
|
249
|
+
description: 'When to trigger the reminder',
|
|
250
|
+
required: false,
|
|
251
|
+
options: {
|
|
252
|
+
options: [
|
|
253
|
+
{ label: 'Specific Date & Time', value: 'datetime' },
|
|
254
|
+
{ label: 'Days Before', value: 'days_before' },
|
|
255
|
+
{ label: 'Weeks Before', value: 'weeks_before' },
|
|
256
|
+
],
|
|
257
|
+
},
|
|
258
|
+
}),
|
|
259
|
+
reminderDateTime: pieces_framework_1.Property.DateTime({
|
|
260
|
+
displayName: 'Reminder Date & Time',
|
|
261
|
+
description: 'Specific date and time for reminder (for non-recurring tasks)',
|
|
262
|
+
required: false,
|
|
263
|
+
}),
|
|
264
|
+
reminderDaysBefore: pieces_framework_1.Property.Number({
|
|
265
|
+
displayName: 'Days Before',
|
|
266
|
+
description: 'Number of days before the task to send reminder',
|
|
267
|
+
required: false,
|
|
268
|
+
}),
|
|
269
|
+
reminderWeeksBefore: pieces_framework_1.Property.Number({
|
|
270
|
+
displayName: 'Weeks Before',
|
|
271
|
+
description: 'Number of weeks before the task to send reminder',
|
|
272
|
+
required: false,
|
|
273
|
+
}),
|
|
274
|
+
reminderTime: pieces_framework_1.Property.ShortText({
|
|
275
|
+
displayName: 'Reminder Time',
|
|
276
|
+
description: 'Time for reminder in HH:MM format (24-hour, for recurring tasks)',
|
|
277
|
+
required: false,
|
|
278
|
+
}),
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
return {};
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
}),
|
|
286
|
+
relatedModule: pieces_framework_1.Property.Dropdown({
|
|
287
|
+
displayName: 'Related Module',
|
|
288
|
+
description: 'Select the type of entity the task is related to. Options: Contacts, Pipelines, Companies.',
|
|
289
|
+
required: false,
|
|
290
|
+
refreshers: ['auth'],
|
|
291
|
+
defaultValue: 'Contacts',
|
|
292
|
+
options: () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
293
|
+
return ({
|
|
294
|
+
options: [
|
|
295
|
+
{ label: 'Contacts', value: 'Contacts' },
|
|
296
|
+
{ label: 'Pipelines', value: 'Pipelines' },
|
|
297
|
+
{ label: 'Companies', value: 'Companies' },
|
|
298
|
+
],
|
|
299
|
+
});
|
|
300
|
+
}),
|
|
301
|
+
}),
|
|
302
|
+
relatedTo: pieces_framework_1.Property.Dropdown({
|
|
303
|
+
displayName: 'Related To',
|
|
304
|
+
description: 'Select the specific record the task is related to.',
|
|
305
|
+
required: false,
|
|
306
|
+
refreshers: ['auth', 'relatedModule'],
|
|
307
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, relatedModule }) {
|
|
308
|
+
if (!auth)
|
|
309
|
+
return (0, helpers_1.handleDropdownError)('Please connect first');
|
|
310
|
+
if (!relatedModule)
|
|
311
|
+
return { options: [] };
|
|
312
|
+
const { access_token, api_domain } = auth;
|
|
313
|
+
const fetchMap = {
|
|
314
|
+
Contacts: () => request_1.biginApiService.fetchContacts(access_token, api_domain),
|
|
315
|
+
Pipelines: () => request_1.biginApiService.fetchPipelinesRecords(access_token, api_domain),
|
|
316
|
+
Companies: () => request_1.biginApiService.fetchCompanies(access_token, api_domain),
|
|
317
|
+
};
|
|
318
|
+
const fetchFn = fetchMap[relatedModule];
|
|
319
|
+
const response = yield fetchFn();
|
|
320
|
+
const records = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
321
|
+
return {
|
|
322
|
+
options: records.map((item) => ({
|
|
323
|
+
label: (0, helpers_1.getSafeLabel)(item),
|
|
324
|
+
value: item.id,
|
|
325
|
+
})),
|
|
326
|
+
};
|
|
327
|
+
}),
|
|
328
|
+
}),
|
|
329
|
+
tag: (0, props_1.tagsDropdown)('Tasks'),
|
|
330
|
+
},
|
|
331
|
+
run(_a) {
|
|
332
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
|
|
333
|
+
const { access_token, api_domain } = auth;
|
|
334
|
+
const taskId = JSON.parse(propsValue.taskId).id;
|
|
335
|
+
const taskDetails = propsValue.taskDetails;
|
|
336
|
+
const taskData = {
|
|
337
|
+
Subject: taskDetails.subject,
|
|
338
|
+
id: taskId,
|
|
339
|
+
};
|
|
340
|
+
if (taskDetails.owner) {
|
|
341
|
+
taskData.Owner = { id: taskDetails.owner };
|
|
342
|
+
}
|
|
343
|
+
if (taskDetails.dueDate) {
|
|
344
|
+
const dueDate = new Date(taskDetails.dueDate);
|
|
345
|
+
taskData.Due_Date = dueDate.toISOString().split('T')[0];
|
|
346
|
+
}
|
|
347
|
+
if (propsValue.enableRecurring && propsValue.recurringInfo) {
|
|
348
|
+
if (!taskDetails.dueDate) {
|
|
349
|
+
throw new Error('Due Date is required when creating recurring tasks');
|
|
350
|
+
}
|
|
351
|
+
const recurringInfo = propsValue.recurringInfo;
|
|
352
|
+
const rruleParts = [`FREQ=${recurringInfo.freq}`];
|
|
353
|
+
const startDate = new Date(taskDetails.dueDate);
|
|
354
|
+
rruleParts.push(`DTSTART=${startDate.toISOString().split('T')[0]}`);
|
|
355
|
+
if (recurringInfo.interval) {
|
|
356
|
+
rruleParts.push(`INTERVAL=${recurringInfo.interval}`);
|
|
357
|
+
}
|
|
358
|
+
if (recurringInfo.count) {
|
|
359
|
+
rruleParts.push(`COUNT=${recurringInfo.count}`);
|
|
360
|
+
}
|
|
361
|
+
if (recurringInfo.byday) {
|
|
362
|
+
rruleParts.push(`BYDAY=${recurringInfo.byday}`);
|
|
363
|
+
}
|
|
364
|
+
if (recurringInfo.bymonthday) {
|
|
365
|
+
rruleParts.push(`BYMONTHDAY=${recurringInfo.bymonthday}`);
|
|
366
|
+
}
|
|
367
|
+
if (recurringInfo.bysetpos) {
|
|
368
|
+
rruleParts.push(`BYSETPOS=${recurringInfo.bysetpos}`);
|
|
369
|
+
}
|
|
370
|
+
if (recurringInfo.until) {
|
|
371
|
+
rruleParts.push(`UNTIL=${recurringInfo.until}`);
|
|
372
|
+
}
|
|
373
|
+
taskData.Recurring_Activity = {
|
|
374
|
+
RRULE: rruleParts.join(';') + ';',
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
if (propsValue.enableReminder && propsValue.reminderInfo) {
|
|
378
|
+
const reminderInfo = propsValue.reminderInfo;
|
|
379
|
+
const reminderAction = reminderInfo.reminderAction || 'EMAIL';
|
|
380
|
+
let alarmValue = `ACTION=${reminderAction}`;
|
|
381
|
+
const reminderTime = reminderInfo.reminderTime || '09:00';
|
|
382
|
+
if (propsValue.recurringInfo &&
|
|
383
|
+
reminderInfo.reminderType === 'days_before') {
|
|
384
|
+
const daysBefore = reminderInfo.reminderDaysBefore || 1;
|
|
385
|
+
alarmValue += `;TRIGGER=-P${daysBefore}D;TRIGGER_TIME=${reminderTime}`;
|
|
386
|
+
}
|
|
387
|
+
else if (propsValue.recurringInfo &&
|
|
388
|
+
reminderInfo.reminderType === 'weeks_before') {
|
|
389
|
+
const weeksBefore = reminderInfo.reminderWeeksBefore || 1;
|
|
390
|
+
alarmValue += `;TRIGGER=-P${weeksBefore}W;TRIGGER_TIME=${reminderTime}`;
|
|
391
|
+
}
|
|
392
|
+
else if (reminderInfo.reminderDateTime) {
|
|
393
|
+
const reminderDate = new Date(reminderInfo.reminderDateTime);
|
|
394
|
+
alarmValue += `;TRIGGER=DATE-TIME:${reminderDate.toISOString()}`;
|
|
395
|
+
}
|
|
396
|
+
taskData.Remind_At = {
|
|
397
|
+
ALARM: alarmValue,
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
if (propsValue.relatedTo && propsValue.relatedModule) {
|
|
401
|
+
const relatedModuleMap = {
|
|
402
|
+
Contacts: 'Contacts',
|
|
403
|
+
Pipelines: 'Deals',
|
|
404
|
+
Companies: 'Accounts',
|
|
405
|
+
};
|
|
406
|
+
const relatedModule = relatedModuleMap[propsValue.relatedModule] || 'Contacts';
|
|
407
|
+
taskData.Related_To = { id: propsValue.relatedTo };
|
|
408
|
+
taskData.$related_module = relatedModule;
|
|
409
|
+
}
|
|
410
|
+
if (taskDetails.description) {
|
|
411
|
+
taskData.Description = taskDetails.description;
|
|
412
|
+
}
|
|
413
|
+
if (taskDetails.priority) {
|
|
414
|
+
taskData.Priority = taskDetails.priority;
|
|
415
|
+
}
|
|
416
|
+
if (taskDetails.status) {
|
|
417
|
+
taskData.Status = taskDetails.status;
|
|
418
|
+
}
|
|
419
|
+
if (taskDetails.tag &&
|
|
420
|
+
Array.isArray(taskDetails.tag) &&
|
|
421
|
+
taskDetails.tag.length > 0) {
|
|
422
|
+
taskData.Tag = taskDetails.tag.map((tagName) => ({ name: tagName }));
|
|
423
|
+
}
|
|
424
|
+
const payload = { data: [taskData] };
|
|
425
|
+
try {
|
|
426
|
+
const response = yield request_1.biginApiService.updateTask(access_token, api_domain, payload);
|
|
427
|
+
return response.data[0];
|
|
428
|
+
}
|
|
429
|
+
catch (error) {
|
|
430
|
+
console.error('Error updating task:', error);
|
|
431
|
+
throw new Error(error);
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
//# sourceMappingURL=update-task.js.map
|