@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.
Files changed (92) hide show
  1. package/README.md +7 -0
  2. package/package.json +38 -0
  3. package/src/index.d.ts +2 -0
  4. package/src/index.js +121 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/actions/create-call.d.ts +15 -0
  7. package/src/lib/actions/create-call.js +155 -0
  8. package/src/lib/actions/create-call.js.map +1 -0
  9. package/src/lib/actions/create-company.d.ts +13 -0
  10. package/src/lib/actions/create-company.js +104 -0
  11. package/src/lib/actions/create-company.js.map +1 -0
  12. package/src/lib/actions/create-contact.d.ts +17 -0
  13. package/src/lib/actions/create-contact.js +126 -0
  14. package/src/lib/actions/create-contact.js.map +1 -0
  15. package/src/lib/actions/create-event.d.ts +17 -0
  16. package/src/lib/actions/create-event.js +351 -0
  17. package/src/lib/actions/create-event.js.map +1 -0
  18. package/src/lib/actions/create-pipeline-record.d.ts +15 -0
  19. package/src/lib/actions/create-pipeline-record.js +213 -0
  20. package/src/lib/actions/create-pipeline-record.js.map +1 -0
  21. package/src/lib/actions/create-task.d.ts +15 -0
  22. package/src/lib/actions/create-task.js +371 -0
  23. package/src/lib/actions/create-task.js.map +1 -0
  24. package/src/lib/actions/search-company-record.d.ts +4 -0
  25. package/src/lib/actions/search-company-record.js +53 -0
  26. package/src/lib/actions/search-company-record.js.map +1 -0
  27. package/src/lib/actions/search-contact-record.d.ts +4 -0
  28. package/src/lib/actions/search-contact-record.js +77 -0
  29. package/src/lib/actions/search-contact-record.js.map +1 -0
  30. package/src/lib/actions/search-pipeline-records.d.ts +4 -0
  31. package/src/lib/actions/search-pipeline-records.js +48 -0
  32. package/src/lib/actions/search-pipeline-records.js.map +1 -0
  33. package/src/lib/actions/search-product.d.ts +4 -0
  34. package/src/lib/actions/search-product.js +55 -0
  35. package/src/lib/actions/search-product.js.map +1 -0
  36. package/src/lib/actions/search-user.d.ts +6 -0
  37. package/src/lib/actions/search-user.js +70 -0
  38. package/src/lib/actions/search-user.js.map +1 -0
  39. package/src/lib/actions/update-company.d.ts +6 -0
  40. package/src/lib/actions/update-company.js +217 -0
  41. package/src/lib/actions/update-company.js.map +1 -0
  42. package/src/lib/actions/update-contact.d.ts +6 -0
  43. package/src/lib/actions/update-contact.js +241 -0
  44. package/src/lib/actions/update-contact.js.map +1 -0
  45. package/src/lib/actions/update-event.d.ts +12 -0
  46. package/src/lib/actions/update-event.js +454 -0
  47. package/src/lib/actions/update-event.js.map +1 -0
  48. package/src/lib/actions/update-pipeline-record.d.ts +13 -0
  49. package/src/lib/actions/update-pipeline-record.js +200 -0
  50. package/src/lib/actions/update-pipeline-record.js.map +1 -0
  51. package/src/lib/actions/update-task.d.ts +12 -0
  52. package/src/lib/actions/update-task.js +436 -0
  53. package/src/lib/actions/update-task.js.map +1 -0
  54. package/src/lib/common/constants.d.ts +22 -0
  55. package/src/lib/common/constants.js +70 -0
  56. package/src/lib/common/constants.js.map +1 -0
  57. package/src/lib/common/helpers.d.ts +10 -0
  58. package/src/lib/common/helpers.js +40 -0
  59. package/src/lib/common/helpers.js.map +1 -0
  60. package/src/lib/common/props.d.ts +9 -0
  61. package/src/lib/common/props.js +205 -0
  62. package/src/lib/common/props.js.map +1 -0
  63. package/src/lib/common/request.d.ts +34 -0
  64. package/src/lib/common/request.js +224 -0
  65. package/src/lib/common/request.js.map +1 -0
  66. package/src/lib/triggers/company-updated.d.ts +2 -0
  67. package/src/lib/triggers/company-updated.js +61 -0
  68. package/src/lib/triggers/company-updated.js.map +1 -0
  69. package/src/lib/triggers/contact-updated.d.ts +2 -0
  70. package/src/lib/triggers/contact-updated.js +61 -0
  71. package/src/lib/triggers/contact-updated.js.map +1 -0
  72. package/src/lib/triggers/new-call-created.d.ts +2 -0
  73. package/src/lib/triggers/new-call-created.js +61 -0
  74. package/src/lib/triggers/new-call-created.js.map +1 -0
  75. package/src/lib/triggers/new-company-created.d.ts +2 -0
  76. package/src/lib/triggers/new-company-created.js +61 -0
  77. package/src/lib/triggers/new-company-created.js.map +1 -0
  78. package/src/lib/triggers/new-contact-created.d.ts +2 -0
  79. package/src/lib/triggers/new-contact-created.js +70 -0
  80. package/src/lib/triggers/new-contact-created.js.map +1 -0
  81. package/src/lib/triggers/new-event-created.d.ts +2 -0
  82. package/src/lib/triggers/new-event-created.js +61 -0
  83. package/src/lib/triggers/new-event-created.js.map +1 -0
  84. package/src/lib/triggers/new-pipeline-record.d.ts +2 -0
  85. package/src/lib/triggers/new-pipeline-record.js +61 -0
  86. package/src/lib/triggers/new-pipeline-record.js.map +1 -0
  87. package/src/lib/triggers/new-task-created.d.ts +2 -0
  88. package/src/lib/triggers/new-task-created.js +61 -0
  89. package/src/lib/triggers/new-task-created.js.map +1 -0
  90. package/src/lib/triggers/pipeline-record-updated.d.ts +2 -0
  91. package/src/lib/triggers/pipeline-record-updated.js +61 -0
  92. package/src/lib/triggers/pipeline-record-updated.js.map +1 -0
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchProductRecord = 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 request_1 = require("../common/request");
8
+ exports.searchProductRecord = (0, pieces_framework_1.createAction)({
9
+ auth: index_1.biginAuth,
10
+ name: 'searchProductRecord',
11
+ displayName: 'Search Product Record',
12
+ description: 'Searches products by name/code via criteria or word',
13
+ props: {
14
+ mode: pieces_framework_1.Property.StaticDropdown({
15
+ displayName: 'Search Mode',
16
+ required: true,
17
+ defaultValue: 'criteria',
18
+ options: {
19
+ options: [
20
+ { label: 'Criteria (name/code)', value: 'criteria' },
21
+ { label: 'Word', value: 'word' },
22
+ ],
23
+ },
24
+ }),
25
+ searchTerm: pieces_framework_1.Property.ShortText({
26
+ displayName: 'Search Term',
27
+ description: 'Product name/code (criteria) or word',
28
+ required: true,
29
+ }),
30
+ },
31
+ run(_a) {
32
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
33
+ const { searchTerm, mode } = propsValue;
34
+ const { access_token, api_domain } = auth;
35
+ const criteriaValue = ['Product_Name', 'Product_Code']
36
+ .flatMap((key) => [
37
+ `${key}:equals:${searchTerm}`,
38
+ `${key}:starts_with:${searchTerm}`,
39
+ ])
40
+ .map((condition) => `(${condition})`)
41
+ .join('OR');
42
+ try {
43
+ const response = yield request_1.biginApiService.searchRecords(access_token, api_domain, 'Products', mode === 'word' ? { key: 'word', value: searchTerm } : { key: 'criteria', value: criteriaValue });
44
+ return {
45
+ message: 'Product record search completed successfully',
46
+ data: response.data,
47
+ };
48
+ }
49
+ catch (error) {
50
+ throw new Error(`Error searching product record: ${error.message}`);
51
+ }
52
+ });
53
+ },
54
+ });
55
+ //# sourceMappingURL=search-product.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-product.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bigin-by-zoho/src/lib/actions/search-product.ts"],"names":[],"mappings":";;;;AAAA,uCAAwC;AACxC,qEAAwE;AACxE,+CAAoD;AAEvC,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC9C,IAAI,EAAE,iBAAS;IACf,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,uBAAuB;IACpC,WAAW,EAAE,qDAAqD;IAClE,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC5B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,UAAU;YACxB,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,UAAU,EAAE;oBACpD,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;iBACjC;aACF;SACF,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,sCAAsC;YACnD,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,UAAiB,CAAC;YAE/C,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,IAAW,CAAC;YAEjD,MAAM,aAAa,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC;iBACnD,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC;gBAChB,GAAG,GAAG,WAAW,UAAU,EAAE;gBAC7B,GAAG,GAAG,gBAAgB,UAAU,EAAE;aACnC,CAAC;iBACD,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,SAAS,GAAG,CAAC;iBACpC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,yBAAe,CAAC,aAAa,CAClD,YAAY,EACZ,UAAU,EACV,UAAU,EACV,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,CACjG,CAAC;gBAEF,OAAO;oBACL,OAAO,EAAE,8CAA8C;oBACvD,IAAI,EAAE,QAAQ,CAAC,IAAI;iBACpB,CAAC;YACJ,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const searchUser: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ email: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ type: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
4
+ page: import("@activepieces/pieces-framework").NumberProperty<false>;
5
+ per_page: import("@activepieces/pieces-framework").NumberProperty<false>;
6
+ }>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.searchUser = 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 request_1 = require("../common/request");
8
+ exports.searchUser = (0, pieces_framework_1.createAction)({
9
+ auth: index_1.biginAuth,
10
+ name: 'searchUser',
11
+ displayName: 'Search User',
12
+ description: 'Locate users by email.',
13
+ props: {
14
+ email: pieces_framework_1.Property.ShortText({
15
+ displayName: 'Email',
16
+ description: 'User email address (full or partial, case-insensitive match)',
17
+ required: true,
18
+ }),
19
+ type: pieces_framework_1.Property.StaticDropdown({
20
+ displayName: 'User Type (optional)',
21
+ required: false,
22
+ options: {
23
+ options: [
24
+ { label: 'All Users', value: 'AllUsers' },
25
+ { label: 'Active Users', value: 'ActiveUsers' },
26
+ { label: 'Deactive Users', value: 'DeactiveUsers' },
27
+ { label: 'Confirmed Users', value: 'ConfirmedUsers' },
28
+ { label: 'Not Confirmed Users', value: 'NotConfirmedUsers' },
29
+ { label: 'Deleted Users', value: 'DeletedUsers' },
30
+ { label: 'Active Confirmed Users', value: 'ActiveConfirmedUsers' },
31
+ { label: 'Admin Users', value: 'AdminUsers' },
32
+ { label: 'Active Confirmed Admins', value: 'ActiveConfirmedAdmins' },
33
+ { label: 'Current User', value: 'CurrentUser' },
34
+ ],
35
+ },
36
+ }),
37
+ page: pieces_framework_1.Property.Number({
38
+ displayName: 'Page',
39
+ required: false,
40
+ description: 'Page index (default 1)',
41
+ }),
42
+ per_page: pieces_framework_1.Property.Number({
43
+ displayName: 'Per Page',
44
+ required: false,
45
+ description: 'Records per page (max 200, default 200)',
46
+ }),
47
+ },
48
+ run(_a) {
49
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
50
+ const { access_token, api_domain } = auth;
51
+ const emailTerm = String(propsValue.email || '').toLowerCase();
52
+ const params = {};
53
+ if (propsValue.type)
54
+ params.type = propsValue.type;
55
+ if (propsValue.page)
56
+ params.page = Number(propsValue.page);
57
+ if (propsValue.per_page)
58
+ params.per_page = Number(propsValue.per_page);
59
+ const resp = yield request_1.biginApiService.fetchUsers(access_token, api_domain, params);
60
+ const users = Array.isArray(resp.users) ? resp.users : [];
61
+ const filtered = users.filter((u) => String(u.email || '').toLowerCase().includes(emailTerm));
62
+ return {
63
+ message: 'User search completed successfully',
64
+ count: filtered.length,
65
+ data: filtered,
66
+ };
67
+ });
68
+ },
69
+ });
70
+ //# sourceMappingURL=search-user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-user.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bigin-by-zoho/src/lib/actions/search-user.ts"],"names":[],"mappings":";;;;AAAA,uCAAwC;AACxC,qEAAwE;AACxE,+CAAoD;AAEvC,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACrC,IAAI,EAAE,iBAAS;IACf,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,wBAAwB;IACrC,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,8DAA8D;YAC3E,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC5B,WAAW,EAAE,sBAAsB;YACnC,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE;oBACzC,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,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,IAAI,CAAC,CAAC;YAC3D,IAAI,UAAU,CAAC,QAAQ;gBAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAEvE,MAAM,IAAI,GAAG,MAAM,yBAAe,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;YAEhF,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1D,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;YAEnG,OAAO;gBACL,OAAO,EAAE,oCAAoC;gBAC7C,KAAK,EAAE,QAAQ,CAAC,MAAM;gBACtB,IAAI,EAAE,QAAQ;aACf,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const updateCompany: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ companyId: import("@activepieces/pieces-framework").DropdownProperty<any, true>;
3
+ owner: import("@activepieces/pieces-framework").DropdownProperty<unknown, false>;
4
+ companyDetails: import("@activepieces/pieces-framework").DynamicProperties<true>;
5
+ tag: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<unknown, false>;
6
+ }>;
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateCompany = 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.updateCompany = (0, pieces_framework_1.createAction)({
11
+ auth: index_1.biginAuth,
12
+ name: 'updateCompany',
13
+ displayName: 'Update Company',
14
+ description: 'Updates an existing Company and prepopulates its fields for editing.',
15
+ props: {
16
+ companyId: pieces_framework_1.Property.Dropdown({
17
+ displayName: 'Select Company',
18
+ description: 'Choose a company 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.fetchCompanies(context.auth.access_token, context.auth.api_domain);
25
+ return {
26
+ options: response.data.map((company) => ({
27
+ label: company.Account_Name,
28
+ value: JSON.stringify(company),
29
+ })),
30
+ };
31
+ }),
32
+ }),
33
+ owner: props_1.usersDropdown,
34
+ companyDetails: pieces_framework_1.Property.DynamicProperties({
35
+ displayName: 'Company Details',
36
+ description: 'These fields will be prepopulated with company data',
37
+ refreshers: ['companyId', 'auth'],
38
+ required: true,
39
+ props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ companyId, auth }) {
40
+ var _b, _c, _d;
41
+ if (!companyId)
42
+ return {};
43
+ const company = JSON.parse(companyId);
44
+ const { access_token, api_domain } = auth;
45
+ const [fieldsResp, usersResp] = yield Promise.all([
46
+ request_1.biginApiService.fetchModuleFields(access_token, api_domain, 'Accounts'),
47
+ request_1.biginApiService.fetchUsers(access_token, api_domain),
48
+ ]);
49
+ const usersOptions = (usersResp.users || []).map((u) => {
50
+ var _a, _b;
51
+ return ({
52
+ label: `${(_a = u.first_name) !== null && _a !== void 0 ? _a : ''} ${(_b = u.last_name) !== null && _b !== void 0 ? _b : ''}`.trim(),
53
+ value: u.id,
54
+ });
55
+ });
56
+ const props = {};
57
+ const fields = (fieldsResp.fields || []);
58
+ for (const f of fields) {
59
+ const apiName = f.api_name;
60
+ if (f.read_only || f.field_read_only)
61
+ continue;
62
+ if (!f.view_type || f.view_type.edit !== true)
63
+ continue;
64
+ if (apiName === 'Tag' || apiName === 'id')
65
+ continue;
66
+ let defaultValue = (_b = company[apiName]) !== null && _b !== void 0 ? _b : undefined;
67
+ if (apiName === 'Owner')
68
+ defaultValue = (_c = company.Owner) === null || _c === void 0 ? void 0 : _c.id;
69
+ switch ((_d = f.data_type) === null || _d === void 0 ? void 0 : _d.toLowerCase()) {
70
+ case 'picklist': {
71
+ const options = (f.pick_list_values || []).map((pl) => ({
72
+ label: pl.display_value,
73
+ value: pl.actual_value,
74
+ }));
75
+ props[apiName] = pieces_framework_1.Property.StaticDropdown({
76
+ displayName: f.display_label || f.field_label || apiName,
77
+ description: f.tooltip || undefined,
78
+ required: false,
79
+ defaultValue,
80
+ options: { options },
81
+ });
82
+ break;
83
+ }
84
+ case 'multiselectpicklist': {
85
+ const options = (f.pick_list_values || []).map((pl) => ({
86
+ label: pl.display_value,
87
+ value: pl.actual_value,
88
+ }));
89
+ props[apiName] = pieces_framework_1.Property.StaticMultiSelectDropdown({
90
+ displayName: f.display_label || f.field_label || apiName,
91
+ description: f.tooltip || undefined,
92
+ required: false,
93
+ defaultValue,
94
+ options: { options },
95
+ });
96
+ break;
97
+ }
98
+ case 'boolean': {
99
+ props[apiName] = pieces_framework_1.Property.Checkbox({
100
+ displayName: f.display_label || f.field_label || apiName,
101
+ description: f.tooltip || undefined,
102
+ required: false,
103
+ defaultValue: Boolean(defaultValue),
104
+ });
105
+ break;
106
+ }
107
+ case 'date': {
108
+ props[apiName] = pieces_framework_1.Property.ShortText({
109
+ displayName: f.display_label || f.field_label || apiName,
110
+ description: f.tooltip || undefined,
111
+ required: false,
112
+ defaultValue,
113
+ });
114
+ break;
115
+ }
116
+ case 'datetime': {
117
+ props[apiName] = pieces_framework_1.Property.DateTime({
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 'integer':
126
+ case 'long':
127
+ case 'double':
128
+ case 'decimal':
129
+ case 'currency':
130
+ case 'percent': {
131
+ props[apiName] = pieces_framework_1.Property.Number({
132
+ displayName: f.display_label || f.field_label || apiName,
133
+ description: f.tooltip || undefined,
134
+ required: false,
135
+ defaultValue,
136
+ });
137
+ break;
138
+ }
139
+ default: {
140
+ if (apiName === 'Owner') {
141
+ props[apiName] = pieces_framework_1.Property.StaticDropdown({
142
+ displayName: 'Owner',
143
+ description: f.tooltip || undefined,
144
+ required: false,
145
+ defaultValue,
146
+ options: { options: usersOptions },
147
+ });
148
+ break;
149
+ }
150
+ if (apiName === 'Description') {
151
+ props[apiName] = pieces_framework_1.Property.LongText({
152
+ displayName: 'Description',
153
+ description: f.tooltip || undefined,
154
+ required: false,
155
+ defaultValue,
156
+ });
157
+ break;
158
+ }
159
+ props[apiName] = pieces_framework_1.Property.ShortText({
160
+ displayName: f.display_label || f.field_label || apiName,
161
+ description: f.tooltip || undefined,
162
+ required: false,
163
+ defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined,
164
+ });
165
+ }
166
+ }
167
+ }
168
+ return props;
169
+ }),
170
+ }),
171
+ tag: (0, props_1.tagsDropdown)('Accounts'),
172
+ },
173
+ run(context) {
174
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
175
+ try {
176
+ const company = JSON.parse(context.propsValue.companyId);
177
+ const companyId = company.id;
178
+ const updates = context.propsValue.companyDetails;
179
+ const body = { id: companyId };
180
+ for (const [apiName, value] of Object.entries(updates || {})) {
181
+ if (value === undefined ||
182
+ value === null ||
183
+ (typeof value === 'string' && value.trim() === '')) {
184
+ continue;
185
+ }
186
+ if (apiName === 'Owner') {
187
+ body['Owner'] = { id: value };
188
+ }
189
+ else if (apiName === 'Tag') {
190
+ body['Tag'] = value.map((t) => ({ name: t }));
191
+ }
192
+ else {
193
+ body[apiName] = value;
194
+ }
195
+ }
196
+ if (context.propsValue.owner) {
197
+ body['Owner'] = { id: context.propsValue.owner };
198
+ }
199
+ if (context.propsValue.tag &&
200
+ Array.isArray(context.propsValue.tag) &&
201
+ context.propsValue.tag.length > 0) {
202
+ body['Tag'] = context.propsValue.tag.map((t) => ({ name: t }));
203
+ }
204
+ const response = yield request_1.biginApiService.updateCompany(context.auth.access_token, context.auth.api_domain, { data: [body] });
205
+ return {
206
+ message: 'Company updated successfully',
207
+ data: response.data[0],
208
+ };
209
+ }
210
+ catch (error) {
211
+ console.error('Error updating company:', error);
212
+ throw new Error(error);
213
+ }
214
+ });
215
+ },
216
+ });
217
+ //# sourceMappingURL=update-company.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-company.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bigin-by-zoho/src/lib/actions/update-company.ts"],"names":[],"mappings":";;;;AAAA,uCAAwC;AACxC,qEAIwC;AACxC,2CAA8D;AAC9D,+CAAoD;AACpD,+CAAwD;AAE3C,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACxC,IAAI,EAAE,iBAAS;IACf,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EACT,sEAAsE;IACxE,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC3B,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,CAAC,MAAM,CAAC;YACpB,OAAO,EAAE,CAAO,OAAY,EAAE,EAAE;gBAC9B,IAAI,CAAC,OAAO,CAAC,IAAI;oBACf,OAAO,IAAA,6BAAmB,EAAC,mCAAmC,CAAC,CAAC;gBAElE,MAAM,QAAQ,GAAG,MAAM,yBAAe,CAAC,cAAc,CACnD,OAAO,CAAC,IAAI,CAAC,YAAY,EACxB,OAAO,CAAC,IAAY,CAAC,UAAU,CACjC,CAAC;gBAEF,OAAO;oBACL,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC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CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;gBAChD,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const updateContact: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ contactId: import("@activepieces/pieces-framework").DropdownProperty<any, true>;
3
+ contactDetails: import("@activepieces/pieces-framework").DynamicProperties<true>;
4
+ accountName: import("@activepieces/pieces-framework").DropdownProperty<unknown, false>;
5
+ tag: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<unknown, false>;
6
+ }>;
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateContact = 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.updateContact = (0, pieces_framework_1.createAction)({
11
+ auth: index_1.biginAuth,
12
+ name: 'updateContact',
13
+ displayName: 'Update Contact',
14
+ description: 'Select and update an existing Contact record.',
15
+ props: {
16
+ contactId: pieces_framework_1.Property.Dropdown({
17
+ displayName: 'Select Contact',
18
+ description: 'Choose a contact to update',
19
+ required: true,
20
+ refreshers: ['auth'],
21
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
22
+ if (!auth)
23
+ return (0, helpers_1.handleDropdownError)('Please connect first');
24
+ const resp = yield request_1.biginApiService.fetchContacts(auth.access_token, auth.api_domain);
25
+ return {
26
+ options: resp.data.map((c) => {
27
+ var _a;
28
+ return ({
29
+ label: `${(_a = c.First_Name) !== null && _a !== void 0 ? _a : ''} ${c.Last_Name}`.trim(),
30
+ value: JSON.stringify(c),
31
+ });
32
+ }),
33
+ };
34
+ }),
35
+ }),
36
+ contactDetails: pieces_framework_1.Property.DynamicProperties({
37
+ displayName: 'Contact Fields',
38
+ description: 'Edit any of these fields',
39
+ refreshers: ['contactId', 'auth'],
40
+ required: true,
41
+ props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ contactId, auth }) {
42
+ var _b, _c, _d, _e;
43
+ if (!contactId)
44
+ return {};
45
+ const contact = JSON.parse(contactId);
46
+ const { access_token, api_domain } = auth;
47
+ const [fieldsResp, usersResp, companiesResp] = yield Promise.all([
48
+ request_1.biginApiService.fetchModuleFields(access_token, api_domain, 'Contacts'),
49
+ request_1.biginApiService.fetchUsers(access_token, api_domain),
50
+ request_1.biginApiService.fetchCompanies(access_token, api_domain),
51
+ ]);
52
+ const usersOptions = (usersResp.users || []).map((u) => {
53
+ var _a, _b;
54
+ return ({
55
+ label: `${(_a = u.first_name) !== null && _a !== void 0 ? _a : ''} ${(_b = u.last_name) !== null && _b !== void 0 ? _b : ''}`.trim(),
56
+ value: u.id,
57
+ });
58
+ });
59
+ const companyOptions = (companiesResp.data || []).map((c) => ({
60
+ label: c.Account_Name,
61
+ value: c.id,
62
+ }));
63
+ const props = {};
64
+ const fields = (fieldsResp.fields || []);
65
+ for (const f of fields) {
66
+ const apiName = f.api_name;
67
+ if (f.read_only || f.field_read_only)
68
+ continue;
69
+ if (!f.view_type || f.view_type.edit !== true)
70
+ continue;
71
+ if (apiName === 'Tag')
72
+ continue;
73
+ if (apiName === 'id')
74
+ continue;
75
+ let defaultValue = (_b = contact[apiName]) !== null && _b !== void 0 ? _b : undefined;
76
+ if (apiName === 'Owner')
77
+ defaultValue = (_c = contact.Owner) === null || _c === void 0 ? void 0 : _c.id;
78
+ if (apiName === 'Account_Name')
79
+ defaultValue = (_d = contact.Account_Name) === null || _d === void 0 ? void 0 : _d.id;
80
+ switch ((_e = f.data_type) === null || _e === void 0 ? void 0 : _e.toLowerCase()) {
81
+ case 'picklist': {
82
+ const options = (f.pick_list_values || []).map((pl) => ({
83
+ label: pl.display_value,
84
+ value: pl.actual_value,
85
+ }));
86
+ props[apiName] = pieces_framework_1.Property.StaticDropdown({
87
+ displayName: f.display_label || f.field_label || apiName,
88
+ description: f.tooltip || undefined,
89
+ required: false,
90
+ defaultValue,
91
+ options: { options },
92
+ });
93
+ break;
94
+ }
95
+ case 'multiselectpicklist': {
96
+ const options = (f.pick_list_values || []).map((pl) => ({
97
+ label: pl.display_value,
98
+ value: pl.actual_value,
99
+ }));
100
+ props[apiName] = pieces_framework_1.Property.StaticMultiSelectDropdown({
101
+ displayName: f.display_label || f.field_label || apiName,
102
+ description: f.tooltip || undefined,
103
+ required: false,
104
+ defaultValue,
105
+ options: { options },
106
+ });
107
+ break;
108
+ }
109
+ case 'boolean': {
110
+ props[apiName] = pieces_framework_1.Property.Checkbox({
111
+ displayName: f.display_label || f.field_label || apiName,
112
+ description: f.tooltip || undefined,
113
+ required: false,
114
+ defaultValue: Boolean(defaultValue),
115
+ });
116
+ break;
117
+ }
118
+ case 'date': {
119
+ props[apiName] = pieces_framework_1.Property.ShortText({
120
+ displayName: f.display_label || f.field_label || apiName,
121
+ description: f.tooltip || undefined,
122
+ required: false,
123
+ defaultValue,
124
+ });
125
+ break;
126
+ }
127
+ case 'datetime': {
128
+ props[apiName] = pieces_framework_1.Property.DateTime({
129
+ displayName: f.display_label || f.field_label || apiName,
130
+ description: f.tooltip || undefined,
131
+ required: false,
132
+ defaultValue,
133
+ });
134
+ break;
135
+ }
136
+ case 'integer':
137
+ case 'long':
138
+ case 'double':
139
+ case 'decimal':
140
+ case 'currency':
141
+ case 'percent': {
142
+ props[apiName] = pieces_framework_1.Property.Number({
143
+ displayName: f.display_label || f.field_label || apiName,
144
+ description: f.tooltip || undefined,
145
+ required: false,
146
+ defaultValue,
147
+ });
148
+ break;
149
+ }
150
+ default: {
151
+ if (apiName === 'Owner') {
152
+ props[apiName] = pieces_framework_1.Property.StaticDropdown({
153
+ displayName: 'Owner',
154
+ description: f.tooltip || undefined,
155
+ required: false,
156
+ defaultValue,
157
+ options: { options: usersOptions },
158
+ });
159
+ break;
160
+ }
161
+ if (apiName === 'Account_Name') {
162
+ props[apiName] = pieces_framework_1.Property.StaticDropdown({
163
+ displayName: 'Company',
164
+ description: f.tooltip || undefined,
165
+ required: false,
166
+ defaultValue,
167
+ options: { options: companyOptions },
168
+ });
169
+ break;
170
+ }
171
+ if (apiName === 'Description') {
172
+ props[apiName] = pieces_framework_1.Property.LongText({
173
+ displayName: 'Description',
174
+ description: f.tooltip || undefined,
175
+ required: false,
176
+ defaultValue,
177
+ });
178
+ break;
179
+ }
180
+ props[apiName] = pieces_framework_1.Property.ShortText({
181
+ displayName: f.display_label || f.field_label || apiName,
182
+ description: f.tooltip || undefined,
183
+ required: false,
184
+ defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined,
185
+ });
186
+ }
187
+ }
188
+ }
189
+ return props;
190
+ }),
191
+ }),
192
+ accountName: props_1.companyDropdown,
193
+ tag: (0, props_1.tagsDropdown)('Contacts'),
194
+ },
195
+ run(context) {
196
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
197
+ try {
198
+ const { contactDetails, contactId, accountName, tag } = context.propsValue;
199
+ const record = { id: JSON.parse(contactId).id };
200
+ if (contactDetails && typeof contactDetails === 'object') {
201
+ for (const [apiName, value] of Object.entries(contactDetails)) {
202
+ if (value === undefined ||
203
+ value === null ||
204
+ (typeof value === 'string' && value.trim() === '') ||
205
+ (Array.isArray(value) && value.length === 0)) {
206
+ continue;
207
+ }
208
+ if (apiName === 'Owner' || apiName === 'Account_Name') {
209
+ record[apiName] = { id: value };
210
+ }
211
+ else if (apiName === 'Tag') {
212
+ record['Tag'] = value.map((t) => ({ name: t }));
213
+ }
214
+ else {
215
+ record[apiName] = value;
216
+ }
217
+ }
218
+ }
219
+ if (accountName) {
220
+ record['Account_Name'] = { id: accountName };
221
+ }
222
+ if (tag && Array.isArray(tag) && tag.length > 0) {
223
+ record['Tag'] = tag.map((t) => ({ name: t }));
224
+ }
225
+ const payload = { data: [record] };
226
+ const resp = yield request_1.biginApiService.updateContact(context.auth.access_token, context.auth.api_domain, payload);
227
+ return {
228
+ message: 'Contact updated successfully',
229
+ data: resp.data[0],
230
+ };
231
+ }
232
+ catch (error) {
233
+ console.error('Error updating contact:', error);
234
+ throw new Error(error instanceof Error
235
+ ? `Failed to update contact: ${error.message}`
236
+ : 'Failed to update contact due to an unknown error');
237
+ }
238
+ });
239
+ },
240
+ });
241
+ //# sourceMappingURL=update-contact.js.map