@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,57 @@
|
|
|
1
|
+
import { biginAuth } from '../auth';
|
|
2
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
3
|
+
import { biginApiService } from '../common/request';
|
|
4
|
+
|
|
5
|
+
export const searchCompanyRecord = createAction({
|
|
6
|
+
auth: biginAuth,
|
|
7
|
+
name: 'searchCompanyRecord',
|
|
8
|
+
displayName: 'Search Company Record',
|
|
9
|
+
description: 'Searches companies by full name (criteria) or word',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: { description: 'Searches company (account) records in Bigin CRM and returns matches. Choose between Criteria mode (matches the Account Name with equals or starts-with) and Word mode (a free-text word search across the module). Use to find a company by name before referencing or updating it. Idempotent: read-only, repeating the search returns the same matches.', idempotent: true },
|
|
12
|
+
props: {
|
|
13
|
+
mode: Property.StaticDropdown({
|
|
14
|
+
displayName: 'Search Mode',
|
|
15
|
+
required: true,
|
|
16
|
+
defaultValue: 'criteria',
|
|
17
|
+
options: {
|
|
18
|
+
options: [
|
|
19
|
+
{ label: 'Criteria (full name)', value: 'criteria' },
|
|
20
|
+
{ label: 'Word', value: 'word' },
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
companyName: Property.ShortText({
|
|
25
|
+
displayName: 'Search Term',
|
|
26
|
+
description: 'Company full name (criteria) or word',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
async run({ auth, propsValue }) {
|
|
31
|
+
const { companyName, mode } = propsValue;
|
|
32
|
+
|
|
33
|
+
const { access_token, data } = auth;
|
|
34
|
+
const api_domain = data['api_domain'];
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const response = await biginApiService.searchRecords(
|
|
38
|
+
access_token,
|
|
39
|
+
api_domain,
|
|
40
|
+
'Accounts',
|
|
41
|
+
mode === 'word'
|
|
42
|
+
? { key: 'word', value: companyName }
|
|
43
|
+
: {
|
|
44
|
+
key: 'criteria',
|
|
45
|
+
value: `(Account_Name:equals:${companyName})OR(Account_Name:starts_with:${companyName})`,
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
message: 'Company record search completed successfully',
|
|
51
|
+
data: response.data,
|
|
52
|
+
};
|
|
53
|
+
} catch (error: any) {
|
|
54
|
+
throw new Error(`Error searching company record: ${error.message}`);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { biginAuth } from '../auth';
|
|
2
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
3
|
+
import { biginApiService } from '../common/request';
|
|
4
|
+
|
|
5
|
+
export const searchContactRecord = createAction({
|
|
6
|
+
auth: biginAuth,
|
|
7
|
+
name: 'searchContactRecord',
|
|
8
|
+
displayName: 'Search Contact Record',
|
|
9
|
+
description: 'Searches contacts by criteria, email, phone, or word',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: { description: 'Searches contact (person) records in Bigin CRM and returns matches. The search mode selects what the term is matched against: Criteria (name/email/mobile with equals or starts-with), a dedicated Email lookup, a dedicated Phone lookup, or a free-text Word search. Use to find a person by name, email, or phone before referencing or updating them. Idempotent: read-only, repeating the search returns the same matches.', idempotent: true },
|
|
12
|
+
props: {
|
|
13
|
+
mode: Property.StaticDropdown({
|
|
14
|
+
displayName: 'Search Mode',
|
|
15
|
+
description: 'Choose how to search Contacts',
|
|
16
|
+
required: true,
|
|
17
|
+
defaultValue: 'criteria',
|
|
18
|
+
options: {
|
|
19
|
+
options: [
|
|
20
|
+
{ label: 'Criteria (name/email/mobile)', value: 'criteria' },
|
|
21
|
+
{ label: 'Email', value: 'email' },
|
|
22
|
+
{ label: 'Phone', value: 'phone' },
|
|
23
|
+
{ label: 'Word', value: 'word' },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
searchTerm: Property.ShortText({
|
|
28
|
+
displayName: 'Search Term',
|
|
29
|
+
description: 'Text, email, phone, or word based on the selected mode',
|
|
30
|
+
required: true,
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
async run({ auth, propsValue }) {
|
|
34
|
+
const { searchTerm, mode } = propsValue;
|
|
35
|
+
|
|
36
|
+
const { access_token, data } = auth;
|
|
37
|
+
const api_domain = data['api_domain'];
|
|
38
|
+
|
|
39
|
+
let queryKey = 'criteria';
|
|
40
|
+
let queryValue = '';
|
|
41
|
+
if (mode === 'email') {
|
|
42
|
+
queryKey = 'email';
|
|
43
|
+
queryValue = searchTerm;
|
|
44
|
+
} else if (mode === 'phone') {
|
|
45
|
+
queryKey = 'phone';
|
|
46
|
+
queryValue = searchTerm;
|
|
47
|
+
} else if (mode === 'word') {
|
|
48
|
+
queryKey = 'word';
|
|
49
|
+
queryValue = searchTerm;
|
|
50
|
+
} else {
|
|
51
|
+
queryValue = ['First_Name', 'Last_Name', 'Email', 'Mobile']
|
|
52
|
+
.flatMap((key) => [
|
|
53
|
+
`${key}:equals:${searchTerm}`,
|
|
54
|
+
`${key}:starts_with:${searchTerm}`,
|
|
55
|
+
])
|
|
56
|
+
.map((condition) => `(${condition})`)
|
|
57
|
+
.join('OR');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const response = await biginApiService.searchRecords(
|
|
62
|
+
access_token,
|
|
63
|
+
api_domain,
|
|
64
|
+
'Contacts',
|
|
65
|
+
{
|
|
66
|
+
key: queryKey,
|
|
67
|
+
value: queryValue,
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
message: 'Contact record search completed successfully',
|
|
73
|
+
data: response.data,
|
|
74
|
+
};
|
|
75
|
+
} catch (error: any) {
|
|
76
|
+
throw new Error(`Error searching contact record: ${error.message}`);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { biginAuth } from '../auth';
|
|
2
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
3
|
+
import { biginApiService } from '../common/request';
|
|
4
|
+
|
|
5
|
+
export const searchPipelineRecord = createAction({
|
|
6
|
+
auth: biginAuth,
|
|
7
|
+
name: 'searchPipelineRecord',
|
|
8
|
+
displayName: 'Search Pipeline Record',
|
|
9
|
+
description: 'Searches deals by name via criteria or word',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: { description: 'Searches pipeline records (deals) in Bigin CRM and returns matches. Choose between Criteria mode (matches the Deal Name with equals or starts-with) and Word mode (a free-text word search across the module). Use to find a deal by name before referencing or updating it. Idempotent: read-only, repeating the search returns the same matches.', idempotent: true },
|
|
12
|
+
props: {
|
|
13
|
+
mode: Property.StaticDropdown({
|
|
14
|
+
displayName: 'Search Mode',
|
|
15
|
+
required: true,
|
|
16
|
+
defaultValue: 'criteria',
|
|
17
|
+
options: {
|
|
18
|
+
options: [
|
|
19
|
+
{ label: 'Criteria (Deal Name)', value: 'criteria' },
|
|
20
|
+
{ label: 'Word', value: 'word' },
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
dealName: Property.ShortText({
|
|
25
|
+
displayName: 'Search Term',
|
|
26
|
+
description: 'Deal Name (criteria) or word',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
async run({ auth, propsValue }) {
|
|
31
|
+
const { dealName, mode } = propsValue;
|
|
32
|
+
|
|
33
|
+
const { access_token, data } = auth;
|
|
34
|
+
const api_domain = data['api_domain'];
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
const response = await biginApiService.searchRecords(
|
|
38
|
+
access_token,
|
|
39
|
+
api_domain,
|
|
40
|
+
'Pipelines',
|
|
41
|
+
mode === 'word' ? { key: 'word', value: dealName } : { key: 'criteria', value: `(Deal_Name:equals:${dealName})OR(Deal_Name:starts_with:${dealName})` }
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
message: 'Pipeline record search completed successfully',
|
|
46
|
+
data: response.data,
|
|
47
|
+
};
|
|
48
|
+
} catch (error: any) {
|
|
49
|
+
throw new Error(`Error searching pipeline record: ${error.message}`);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { biginAuth } from '../auth';
|
|
2
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
3
|
+
import { biginApiService } from '../common/request';
|
|
4
|
+
|
|
5
|
+
export const searchProductRecord = createAction({
|
|
6
|
+
auth: biginAuth,
|
|
7
|
+
name: 'searchProductRecord',
|
|
8
|
+
displayName: 'Search Product Record',
|
|
9
|
+
description: 'Searches products by name/code via criteria or word',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: { description: 'Searches product records in Bigin CRM and returns matches. Choose between Criteria mode (matches Product Name or Product Code with equals or starts-with) and Word mode (a free-text word search across the module). Use to find a product by name or code before associating it with a deal. Idempotent: read-only, repeating the search returns the same matches.', idempotent: true },
|
|
12
|
+
props: {
|
|
13
|
+
mode: Property.StaticDropdown({
|
|
14
|
+
displayName: 'Search Mode',
|
|
15
|
+
required: true,
|
|
16
|
+
defaultValue: 'criteria',
|
|
17
|
+
options: {
|
|
18
|
+
options: [
|
|
19
|
+
{ label: 'Criteria (name/code)', value: 'criteria' },
|
|
20
|
+
{ label: 'Word', value: 'word' },
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
searchTerm: Property.ShortText({
|
|
25
|
+
displayName: 'Search Term',
|
|
26
|
+
description: 'Product name/code (criteria) or word',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
async run({ auth, propsValue }) {
|
|
31
|
+
const { searchTerm, mode } = propsValue;
|
|
32
|
+
|
|
33
|
+
const { access_token, data } = auth;
|
|
34
|
+
const api_domain = data['api_domain'];
|
|
35
|
+
|
|
36
|
+
const criteriaValue = ['Product_Name', 'Product_Code']
|
|
37
|
+
.flatMap((key) => [
|
|
38
|
+
`${key}:equals:${searchTerm}`,
|
|
39
|
+
`${key}:starts_with:${searchTerm}`,
|
|
40
|
+
])
|
|
41
|
+
.map((condition) => `(${condition})`)
|
|
42
|
+
.join('OR');
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const response = await biginApiService.searchRecords(
|
|
46
|
+
access_token,
|
|
47
|
+
api_domain,
|
|
48
|
+
'Products',
|
|
49
|
+
mode === 'word' ? { key: 'word', value: searchTerm } : { key: 'criteria', value: criteriaValue }
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
message: 'Product record search completed successfully',
|
|
54
|
+
data: response.data,
|
|
55
|
+
};
|
|
56
|
+
} catch (error: any) {
|
|
57
|
+
throw new Error(`Error searching product record: ${error.message}`);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { biginAuth } from '../auth';
|
|
2
|
+
import { createAction, Property } from '@agnocon/pieces-framework';
|
|
3
|
+
import { biginApiService } from '../common/request';
|
|
4
|
+
|
|
5
|
+
export const searchUser = createAction({
|
|
6
|
+
auth: biginAuth,
|
|
7
|
+
name: 'searchUser',
|
|
8
|
+
displayName: 'Search User',
|
|
9
|
+
description: 'Locate users by email.',
|
|
10
|
+
audience: 'both',
|
|
11
|
+
aiMetadata: { description: 'Finds Bigin CRM org users whose email contains the given term (case-insensitive substring match), filtering client-side over the user list; an optional user-type filter (e.g. active, admin, current user) and pagination narrow the fetched set. Use to resolve a user id for assigning records as owner. Idempotent: read-only, repeating the search returns the same matches.', idempotent: true },
|
|
12
|
+
props: {
|
|
13
|
+
email: Property.ShortText({
|
|
14
|
+
displayName: 'Email',
|
|
15
|
+
description: 'User email address (full or partial, case-insensitive match)',
|
|
16
|
+
required: true,
|
|
17
|
+
}),
|
|
18
|
+
type: Property.StaticDropdown({
|
|
19
|
+
displayName: 'User Type (optional)',
|
|
20
|
+
required: false,
|
|
21
|
+
options: {
|
|
22
|
+
options: [
|
|
23
|
+
{ label: 'All Users', value: 'AllUsers' },
|
|
24
|
+
{ label: 'Active Users', value: 'ActiveUsers' },
|
|
25
|
+
{ label: 'Deactive Users', value: 'DeactiveUsers' },
|
|
26
|
+
{ label: 'Confirmed Users', value: 'ConfirmedUsers' },
|
|
27
|
+
{ label: 'Not Confirmed Users', value: 'NotConfirmedUsers' },
|
|
28
|
+
{ label: 'Deleted Users', value: 'DeletedUsers' },
|
|
29
|
+
{ label: 'Active Confirmed Users', value: 'ActiveConfirmedUsers' },
|
|
30
|
+
{ label: 'Admin Users', value: 'AdminUsers' },
|
|
31
|
+
{ label: 'Active Confirmed Admins', value: 'ActiveConfirmedAdmins' },
|
|
32
|
+
{ label: 'Current User', value: 'CurrentUser' },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
page: Property.Number({
|
|
37
|
+
displayName: 'Page',
|
|
38
|
+
required: false,
|
|
39
|
+
description: 'Page index (default 1)',
|
|
40
|
+
}),
|
|
41
|
+
per_page: Property.Number({
|
|
42
|
+
displayName: 'Per Page',
|
|
43
|
+
required: false,
|
|
44
|
+
description: 'Records per page (max 200, default 200)',
|
|
45
|
+
}),
|
|
46
|
+
},
|
|
47
|
+
async run({ auth, propsValue }) {
|
|
48
|
+
const { access_token, data } = auth;
|
|
49
|
+
const api_domain = data['api_domain'];
|
|
50
|
+
const emailTerm = String(propsValue.email || '').toLowerCase();
|
|
51
|
+
|
|
52
|
+
const params: any = {};
|
|
53
|
+
if (propsValue.type) params.type = propsValue.type as string;
|
|
54
|
+
if (propsValue.page) params.page = Number(propsValue.page);
|
|
55
|
+
if (propsValue.per_page) params.per_page = Number(propsValue.per_page);
|
|
56
|
+
|
|
57
|
+
const resp = await biginApiService.fetchUsers(access_token, api_domain, params);
|
|
58
|
+
|
|
59
|
+
const users = Array.isArray(resp.users) ? resp.users : [];
|
|
60
|
+
const filtered = users.filter((u: any) => String(u.email || '').toLowerCase().includes(emailTerm));
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
message: 'User search completed successfully',
|
|
64
|
+
count: filtered.length,
|
|
65
|
+
data: filtered,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { biginAuth } from '../auth';
|
|
2
|
+
import {
|
|
3
|
+
createAction,
|
|
4
|
+
InputPropertyMap,
|
|
5
|
+
Property,
|
|
6
|
+
} from '@agnocon/pieces-framework';
|
|
7
|
+
import { tagsDropdown, usersDropdown } from '../common/props';
|
|
8
|
+
import { biginApiService } from '../common/request';
|
|
9
|
+
import { handleDropdownError } from '../common/helpers';
|
|
10
|
+
|
|
11
|
+
export const updateCompany = createAction({
|
|
12
|
+
auth: biginAuth,
|
|
13
|
+
name: 'updateCompany',
|
|
14
|
+
displayName: 'Update Company',
|
|
15
|
+
description:
|
|
16
|
+
'Updates an existing Company and prepopulates its fields for editing.',
|
|
17
|
+
audience: 'both',
|
|
18
|
+
aiMetadata: { description: 'Updates an existing company (account) record in Bigin CRM, identified by selecting the company; its current fields are prepopulated and any you set are overwritten (owner, tags, billing address, and module-defined fields). Use to modify an organization that already exists. Idempotent: re-sending the same field values leaves the record in the same state.', idempotent: true },
|
|
19
|
+
props: {
|
|
20
|
+
companyId: Property.Dropdown({
|
|
21
|
+
auth: biginAuth,
|
|
22
|
+
displayName: 'Select Company',
|
|
23
|
+
description: 'Choose a company to update',
|
|
24
|
+
required: true,
|
|
25
|
+
refreshers: ['auth'],
|
|
26
|
+
options: async (context: any) => {
|
|
27
|
+
if (!context.auth)
|
|
28
|
+
return handleDropdownError('Please connect your account first');
|
|
29
|
+
|
|
30
|
+
const response = await biginApiService.fetchCompanies(
|
|
31
|
+
context.auth.access_token,
|
|
32
|
+
context.auth.data['api_domain']
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
options: response.data.map((company: any) => ({
|
|
37
|
+
label: company.Account_Name,
|
|
38
|
+
value: JSON.stringify(company),
|
|
39
|
+
})),
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
owner: usersDropdown,
|
|
44
|
+
companyDetails: Property.DynamicProperties({
|
|
45
|
+
auth: biginAuth,
|
|
46
|
+
displayName: 'Company Details',
|
|
47
|
+
description: 'These fields will be prepopulated with company data',
|
|
48
|
+
refreshers: ['companyId', 'auth'],
|
|
49
|
+
required: true,
|
|
50
|
+
props: async ({ companyId, auth }: any): Promise<InputPropertyMap> => {
|
|
51
|
+
if (!companyId) return {};
|
|
52
|
+
const company = JSON.parse(companyId);
|
|
53
|
+
const { access_token, data } = auth;
|
|
54
|
+
const api_domain = data['api_domain'];
|
|
55
|
+
|
|
56
|
+
const [fieldsResp, usersResp] = await Promise.all([
|
|
57
|
+
biginApiService.fetchModuleFields(access_token, api_domain, 'Accounts'),
|
|
58
|
+
biginApiService.fetchUsers(access_token, api_domain),
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
const usersOptions = (usersResp.users || []).map((u: any) => ({
|
|
62
|
+
label: `${u.first_name ?? ''} ${u.last_name ?? ''}`.trim(),
|
|
63
|
+
value: u.id,
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
const props: InputPropertyMap = {};
|
|
67
|
+
const fields = (fieldsResp.fields || []) as any[];
|
|
68
|
+
for (const f of fields) {
|
|
69
|
+
const apiName = f.api_name as string;
|
|
70
|
+
|
|
71
|
+
if (f.read_only || f.field_read_only) continue;
|
|
72
|
+
if (!f.view_type || f.view_type.edit !== true) continue;
|
|
73
|
+
if (apiName === 'Tag' || apiName === 'id') continue;
|
|
74
|
+
|
|
75
|
+
let defaultValue: any = company[apiName] ?? undefined;
|
|
76
|
+
if (apiName === 'Owner') defaultValue = company.Owner?.id;
|
|
77
|
+
|
|
78
|
+
switch ((f.data_type as string)?.toLowerCase()) {
|
|
79
|
+
case 'picklist': {
|
|
80
|
+
const options = (f.pick_list_values || []).map((pl: any) => ({
|
|
81
|
+
label: pl.display_value,
|
|
82
|
+
value: pl.actual_value,
|
|
83
|
+
}));
|
|
84
|
+
props[apiName] = Property.StaticDropdown({
|
|
85
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
86
|
+
description: f.tooltip || undefined,
|
|
87
|
+
required: false,
|
|
88
|
+
defaultValue,
|
|
89
|
+
options: { options },
|
|
90
|
+
});
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case 'multiselectpicklist': {
|
|
94
|
+
const options = (f.pick_list_values || []).map((pl: any) => ({
|
|
95
|
+
label: pl.display_value,
|
|
96
|
+
value: pl.actual_value,
|
|
97
|
+
}));
|
|
98
|
+
props[apiName] = Property.StaticMultiSelectDropdown({
|
|
99
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
100
|
+
description: f.tooltip || undefined,
|
|
101
|
+
required: false,
|
|
102
|
+
defaultValue,
|
|
103
|
+
options: { options },
|
|
104
|
+
});
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case 'boolean': {
|
|
108
|
+
props[apiName] = Property.Checkbox({
|
|
109
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
110
|
+
description: f.tooltip || undefined,
|
|
111
|
+
required: false,
|
|
112
|
+
defaultValue: Boolean(defaultValue),
|
|
113
|
+
});
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case 'date': {
|
|
117
|
+
props[apiName] = Property.ShortText({
|
|
118
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
119
|
+
description: f.tooltip || undefined,
|
|
120
|
+
required: false,
|
|
121
|
+
defaultValue,
|
|
122
|
+
});
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case 'datetime': {
|
|
126
|
+
props[apiName] = Property.DateTime({
|
|
127
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
128
|
+
description: f.tooltip || undefined,
|
|
129
|
+
required: false,
|
|
130
|
+
defaultValue,
|
|
131
|
+
});
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
case 'integer':
|
|
135
|
+
case 'long':
|
|
136
|
+
case 'double':
|
|
137
|
+
case 'decimal':
|
|
138
|
+
case 'currency':
|
|
139
|
+
case 'percent': {
|
|
140
|
+
props[apiName] = Property.Number({
|
|
141
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
142
|
+
description: f.tooltip || undefined,
|
|
143
|
+
required: false,
|
|
144
|
+
defaultValue,
|
|
145
|
+
});
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
default: {
|
|
149
|
+
if (apiName === 'Owner') {
|
|
150
|
+
props[apiName] = Property.StaticDropdown({
|
|
151
|
+
displayName: 'Owner',
|
|
152
|
+
description: f.tooltip || undefined,
|
|
153
|
+
required: false,
|
|
154
|
+
defaultValue,
|
|
155
|
+
options: { options: usersOptions },
|
|
156
|
+
});
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
if (apiName === 'Description') {
|
|
160
|
+
props[apiName] = Property.LongText({
|
|
161
|
+
displayName: 'Description',
|
|
162
|
+
description: f.tooltip || undefined,
|
|
163
|
+
required: false,
|
|
164
|
+
defaultValue,
|
|
165
|
+
});
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
props[apiName] = Property.ShortText({
|
|
169
|
+
displayName: f.display_label || f.field_label || apiName,
|
|
170
|
+
description: f.tooltip || undefined,
|
|
171
|
+
required: false,
|
|
172
|
+
defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return props;
|
|
179
|
+
},
|
|
180
|
+
}),
|
|
181
|
+
tag: tagsDropdown('Accounts'),
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
async run(context) {
|
|
185
|
+
try {
|
|
186
|
+
const company = JSON.parse(context.propsValue.companyId);
|
|
187
|
+
const companyId = company.id;
|
|
188
|
+
const updates = context.propsValue.companyDetails as Record<string, any>;
|
|
189
|
+
|
|
190
|
+
const body: Record<string, any> = { id: companyId };
|
|
191
|
+
|
|
192
|
+
for (const [apiName, value] of Object.entries(updates || {})) {
|
|
193
|
+
if (
|
|
194
|
+
value === undefined ||
|
|
195
|
+
value === null ||
|
|
196
|
+
(typeof value === 'string' && value.trim() === '')
|
|
197
|
+
) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (apiName === 'Owner') {
|
|
201
|
+
body['Owner'] = { id: value };
|
|
202
|
+
} else if (apiName === 'Tag') {
|
|
203
|
+
body['Tag'] = (value as any[]).map((t: any) => ({ name: t }));
|
|
204
|
+
} else {
|
|
205
|
+
body[apiName] = value;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (context.propsValue.owner) {
|
|
210
|
+
body['Owner'] = { id: context.propsValue.owner };
|
|
211
|
+
}
|
|
212
|
+
if (
|
|
213
|
+
context.propsValue.tag &&
|
|
214
|
+
Array.isArray(context.propsValue.tag) &&
|
|
215
|
+
context.propsValue.tag.length > 0
|
|
216
|
+
) {
|
|
217
|
+
body['Tag'] = context.propsValue.tag.map((t: any) => ({ name: t }));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const response = await biginApiService.updateCompany(
|
|
221
|
+
context.auth.access_token,
|
|
222
|
+
(context.auth as any).api_domain,
|
|
223
|
+
{ data: [body] }
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
message: 'Company updated successfully',
|
|
228
|
+
data: response.data[0],
|
|
229
|
+
};
|
|
230
|
+
} catch (error: any) {
|
|
231
|
+
console.error('Error updating company:', error);
|
|
232
|
+
throw new Error(error);
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
});
|