@activepieces/piece-bexio 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 (107) hide show
  1. package/README.md +7 -0
  2. package/package.json +27 -0
  3. package/src/index.d.ts +2 -0
  4. package/src/index.js +133 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/actions/create-company.d.ts +27 -0
  7. package/src/lib/actions/create-company.js +449 -0
  8. package/src/lib/actions/create-company.js.map +1 -0
  9. package/src/lib/actions/create-file.d.ts +3 -0
  10. package/src/lib/actions/create-file.js +44 -0
  11. package/src/lib/actions/create-file.js.map +1 -0
  12. package/src/lib/actions/create-manual-entry.d.ts +6 -0
  13. package/src/lib/actions/create-manual-entry.js +421 -0
  14. package/src/lib/actions/create-manual-entry.js.map +1 -0
  15. package/src/lib/actions/create-person.d.ts +29 -0
  16. package/src/lib/actions/create-person.js +465 -0
  17. package/src/lib/actions/create-person.js.map +1 -0
  18. package/src/lib/actions/create-product.d.ts +33 -0
  19. package/src/lib/actions/create-product.js +515 -0
  20. package/src/lib/actions/create-product.js.map +1 -0
  21. package/src/lib/actions/create-project.d.ts +16 -0
  22. package/src/lib/actions/create-project.js +307 -0
  23. package/src/lib/actions/create-project.js.map +1 -0
  24. package/src/lib/actions/create-sales-invoice.d.ts +24 -0
  25. package/src/lib/actions/create-sales-invoice.js +602 -0
  26. package/src/lib/actions/create-sales-invoice.js.map +1 -0
  27. package/src/lib/actions/create-sales-order.d.ts +24 -0
  28. package/src/lib/actions/create-sales-order.js +628 -0
  29. package/src/lib/actions/create-sales-order.js.map +1 -0
  30. package/src/lib/actions/create-sales-quote.d.ts +27 -0
  31. package/src/lib/actions/create-sales-quote.js +652 -0
  32. package/src/lib/actions/create-sales-quote.js.map +1 -0
  33. package/src/lib/actions/create-time-tracking.d.ts +16 -0
  34. package/src/lib/actions/create-time-tracking.js +369 -0
  35. package/src/lib/actions/create-time-tracking.js.map +1 -0
  36. package/src/lib/actions/export-invoice-pdf.d.ts +4 -0
  37. package/src/lib/actions/export-invoice-pdf.js +89 -0
  38. package/src/lib/actions/export-invoice-pdf.js.map +1 -0
  39. package/src/lib/actions/find-account.d.ts +5 -0
  40. package/src/lib/actions/find-account.js +103 -0
  41. package/src/lib/actions/find-account.js.map +1 -0
  42. package/src/lib/actions/find-company.d.ts +7 -0
  43. package/src/lib/actions/find-company.js +156 -0
  44. package/src/lib/actions/find-company.js.map +1 -0
  45. package/src/lib/actions/find-country.d.ts +6 -0
  46. package/src/lib/actions/find-country.js +121 -0
  47. package/src/lib/actions/find-country.js.map +1 -0
  48. package/src/lib/actions/find-person.d.ts +8 -0
  49. package/src/lib/actions/find-person.js +171 -0
  50. package/src/lib/actions/find-person.js.map +1 -0
  51. package/src/lib/actions/find-product.d.ts +6 -0
  52. package/src/lib/actions/find-product.js +120 -0
  53. package/src/lib/actions/find-product.js.map +1 -0
  54. package/src/lib/actions/search-invoice.d.ts +6 -0
  55. package/src/lib/actions/search-invoice.js +136 -0
  56. package/src/lib/actions/search-invoice.js.map +1 -0
  57. package/src/lib/actions/search-order.d.ts +6 -0
  58. package/src/lib/actions/search-order.js +135 -0
  59. package/src/lib/actions/search-order.js.map +1 -0
  60. package/src/lib/actions/search-quote.d.ts +6 -0
  61. package/src/lib/actions/search-quote.js +136 -0
  62. package/src/lib/actions/search-quote.js.map +1 -0
  63. package/src/lib/actions/send-sales-invoice.d.ts +8 -0
  64. package/src/lib/actions/send-sales-invoice.js +105 -0
  65. package/src/lib/actions/send-sales-invoice.js.map +1 -0
  66. package/src/lib/actions/update-company.d.ts +28 -0
  67. package/src/lib/actions/update-company.js +493 -0
  68. package/src/lib/actions/update-company.js.map +1 -0
  69. package/src/lib/actions/update-person.d.ts +30 -0
  70. package/src/lib/actions/update-person.js +511 -0
  71. package/src/lib/actions/update-person.js.map +1 -0
  72. package/src/lib/actions/update-product.d.ts +33 -0
  73. package/src/lib/actions/update-product.js +543 -0
  74. package/src/lib/actions/update-product.js.map +1 -0
  75. package/src/lib/common/client.d.ts +11 -0
  76. package/src/lib/common/client.js +62 -0
  77. package/src/lib/common/client.js.map +1 -0
  78. package/src/lib/common/index.d.ts +4 -0
  79. package/src/lib/common/index.js +8 -0
  80. package/src/lib/common/index.js.map +1 -0
  81. package/src/lib/common/props.d.ts +13 -0
  82. package/src/lib/common/props.js +112 -0
  83. package/src/lib/common/props.js.map +1 -0
  84. package/src/lib/common/types.d.ts +88 -0
  85. package/src/lib/common/types.js +4 -0
  86. package/src/lib/common/types.js.map +1 -0
  87. package/src/lib/triggers/new-order.d.ts +8 -0
  88. package/src/lib/triggers/new-order.js +146 -0
  89. package/src/lib/triggers/new-order.js.map +1 -0
  90. package/src/lib/triggers/new-product.d.ts +2 -0
  91. package/src/lib/triggers/new-product.js +106 -0
  92. package/src/lib/triggers/new-product.js.map +1 -0
  93. package/src/lib/triggers/new-project.d.ts +8 -0
  94. package/src/lib/triggers/new-project.js +135 -0
  95. package/src/lib/triggers/new-project.js.map +1 -0
  96. package/src/lib/triggers/new-quote.d.ts +8 -0
  97. package/src/lib/triggers/new-quote.js +147 -0
  98. package/src/lib/triggers/new-quote.js.map +1 -0
  99. package/src/lib/triggers/new-sales-invoice.d.ts +8 -0
  100. package/src/lib/triggers/new-sales-invoice.js +147 -0
  101. package/src/lib/triggers/new-sales-invoice.js.map +1 -0
  102. package/src/lib/triggers/new-updated-company.d.ts +2 -0
  103. package/src/lib/triggers/new-updated-company.js +117 -0
  104. package/src/lib/triggers/new-updated-company.js.map +1 -0
  105. package/src/lib/triggers/new-updated-person.d.ts +2 -0
  106. package/src/lib/triggers/new-updated-person.js +117 -0
  107. package/src/lib/triggers/new-updated-person.js.map +1 -0
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-bexio
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-bexio` to build the library.
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@activepieces/piece-bexio",
3
+ "version": "0.0.1",
4
+ "type": "commonjs",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "dependencies": {
8
+ "@sinclair/typebox": "0.34.11",
9
+ "axios": "1.8.3",
10
+ "axios-retry": "4.4.1",
11
+ "dayjs": "1.11.9",
12
+ "deepmerge-ts": "7.1.0",
13
+ "form-data": "4.0.4",
14
+ "mime-types": "2.1.35",
15
+ "nanoid": "3.3.8",
16
+ "semver": "7.6.0",
17
+ "socket.io-client": "4.8.1",
18
+ "tslib": "^2.3.0",
19
+ "zod": "3.25.76",
20
+ "@activepieces/pieces-common": "0.8.1",
21
+ "@activepieces/pieces-framework": "0.20.2",
22
+ "@activepieces/shared": "0.26.0"
23
+ },
24
+ "resolutions": {
25
+ "rollup": "npm:@rollup/wasm-node"
26
+ }
27
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const bexioAuth: import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>;
2
+ export declare const bexio: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>>;
package/src/index.js ADDED
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bexio = exports.bexioAuth = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
7
+ const shared_1 = require("@activepieces/shared");
8
+ const client_1 = require("./lib/common/client");
9
+ const create_manual_entry_1 = require("./lib/actions/create-manual-entry");
10
+ const create_company_1 = require("./lib/actions/create-company");
11
+ const create_person_1 = require("./lib/actions/create-person");
12
+ const update_person_1 = require("./lib/actions/update-person");
13
+ const create_file_1 = require("./lib/actions/create-file");
14
+ const create_sales_invoice_1 = require("./lib/actions/create-sales-invoice");
15
+ const export_invoice_pdf_1 = require("./lib/actions/export-invoice-pdf");
16
+ const send_sales_invoice_1 = require("./lib/actions/send-sales-invoice");
17
+ const create_product_1 = require("./lib/actions/create-product");
18
+ const update_product_1 = require("./lib/actions/update-product");
19
+ const create_sales_order_1 = require("./lib/actions/create-sales-order");
20
+ const create_project_1 = require("./lib/actions/create-project");
21
+ const create_sales_quote_1 = require("./lib/actions/create-sales-quote");
22
+ const create_time_tracking_1 = require("./lib/actions/create-time-tracking");
23
+ const update_company_1 = require("./lib/actions/update-company");
24
+ const find_account_1 = require("./lib/actions/find-account");
25
+ const find_company_1 = require("./lib/actions/find-company");
26
+ const find_person_1 = require("./lib/actions/find-person");
27
+ const find_product_1 = require("./lib/actions/find-product");
28
+ const find_country_1 = require("./lib/actions/find-country");
29
+ const search_invoice_1 = require("./lib/actions/search-invoice");
30
+ const search_order_1 = require("./lib/actions/search-order");
31
+ const search_quote_1 = require("./lib/actions/search-quote");
32
+ const new_updated_company_1 = require("./lib/triggers/new-updated-company");
33
+ const new_sales_invoice_1 = require("./lib/triggers/new-sales-invoice");
34
+ const new_order_1 = require("./lib/triggers/new-order");
35
+ const new_updated_person_1 = require("./lib/triggers/new-updated-person");
36
+ const new_product_1 = require("./lib/triggers/new-product");
37
+ const new_project_1 = require("./lib/triggers/new-project");
38
+ const new_quote_1 = require("./lib/triggers/new-quote");
39
+ exports.bexioAuth = pieces_framework_1.PieceAuth.OAuth2({
40
+ authUrl: 'https://auth.bexio.com/realms/bexio/protocol/openid-connect/auth',
41
+ tokenUrl: 'https://auth.bexio.com/realms/bexio/protocol/openid-connect/token',
42
+ required: true,
43
+ scope: [
44
+ 'openid',
45
+ 'profile',
46
+ 'email',
47
+ 'offline_access',
48
+ 'contact_show',
49
+ 'contact_edit',
50
+ 'article_show',
51
+ 'article_edit',
52
+ 'kb_invoice_show',
53
+ 'kb_invoice_edit',
54
+ 'kb_offer_show',
55
+ 'kb_offer_edit',
56
+ 'kb_order_show',
57
+ 'kb_order_edit',
58
+ 'project_show',
59
+ 'project_edit',
60
+ 'task_show',
61
+ 'monitoring_edit',
62
+ 'accounting',
63
+ 'file',
64
+ ],
65
+ validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
66
+ try {
67
+ const client = new client_1.BexioClient(auth);
68
+ yield client.get('/users/me');
69
+ return {
70
+ valid: true,
71
+ };
72
+ }
73
+ catch (error) {
74
+ return {
75
+ valid: false,
76
+ error: 'Authentication failed. Please check your connection and try again.',
77
+ };
78
+ }
79
+ }),
80
+ });
81
+ exports.bexio = (0, pieces_framework_1.createPiece)({
82
+ displayName: 'Bexio',
83
+ description: 'Swiss business software for accounting, invoicing, and project management',
84
+ auth: exports.bexioAuth,
85
+ minimumSupportedRelease: '0.36.1',
86
+ logoUrl: 'https://cdn.activepieces.com/pieces/bexio.png',
87
+ authors: ["onyedikachi-david"],
88
+ categories: [shared_1.PieceCategory.BUSINESS_INTELLIGENCE],
89
+ actions: [
90
+ create_manual_entry_1.createManualEntryAction,
91
+ create_company_1.createCompanyAction,
92
+ create_person_1.createPersonAction,
93
+ update_person_1.updatePersonAction,
94
+ update_company_1.updateCompanyAction,
95
+ find_account_1.findAccountAction,
96
+ find_company_1.findCompanyAction,
97
+ find_person_1.findPersonAction,
98
+ find_product_1.findProductAction,
99
+ find_country_1.findCountryAction,
100
+ search_invoice_1.searchInvoiceAction,
101
+ search_order_1.searchOrderAction,
102
+ search_quote_1.searchQuoteAction,
103
+ create_file_1.createFileAction,
104
+ create_sales_invoice_1.createSalesInvoiceAction,
105
+ export_invoice_pdf_1.exportInvoicePdfAction,
106
+ send_sales_invoice_1.sendSalesInvoiceAction,
107
+ create_product_1.createProductAction,
108
+ update_product_1.updateProductAction,
109
+ create_sales_order_1.createSalesOrderAction,
110
+ create_project_1.createProjectAction,
111
+ create_sales_quote_1.createSalesQuoteAction,
112
+ create_time_tracking_1.createTimeTrackingAction,
113
+ (0, pieces_common_1.createCustomApiCallAction)({
114
+ baseUrl: () => 'https://api.bexio.com',
115
+ auth: exports.bexioAuth,
116
+ authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
117
+ return ({
118
+ Authorization: `Bearer ${auth.access_token}`,
119
+ });
120
+ }),
121
+ }),
122
+ ],
123
+ triggers: [
124
+ new_updated_company_1.newUpdatedCompanyTrigger,
125
+ new_updated_person_1.newUpdatedPersonTrigger,
126
+ new_product_1.newProductTrigger,
127
+ new_project_1.newProjectTrigger,
128
+ new_sales_invoice_1.newSalesInvoiceTrigger,
129
+ new_order_1.newOrderTrigger,
130
+ new_quote_1.newQuoteTrigger,
131
+ ],
132
+ });
133
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/bexio/src/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,27 @@
1
+ export declare const createCompanyAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ name_1: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ name_2: import("@activepieces/pieces-framework").ShortTextProperty<false>;
4
+ nr: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
+ salutation_id: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
6
+ title_id: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
7
+ street_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
8
+ house_number: import("@activepieces/pieces-framework").ShortTextProperty<false>;
9
+ address_addition: import("@activepieces/pieces-framework").ShortTextProperty<false>;
10
+ postcode: import("@activepieces/pieces-framework").ShortTextProperty<false>;
11
+ city: import("@activepieces/pieces-framework").ShortTextProperty<false>;
12
+ country_id: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
13
+ mail: import("@activepieces/pieces-framework").ShortTextProperty<false>;
14
+ mail_second: import("@activepieces/pieces-framework").ShortTextProperty<false>;
15
+ phone_fixed: import("@activepieces/pieces-framework").ShortTextProperty<false>;
16
+ phone_fixed_second: import("@activepieces/pieces-framework").ShortTextProperty<false>;
17
+ phone_mobile: import("@activepieces/pieces-framework").ShortTextProperty<false>;
18
+ fax: import("@activepieces/pieces-framework").ShortTextProperty<false>;
19
+ url: import("@activepieces/pieces-framework").ShortTextProperty<false>;
20
+ skype_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
21
+ remarks: import("@activepieces/pieces-framework").LongTextProperty<false>;
22
+ language_id: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
23
+ contact_group_ids: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, false>;
24
+ contact_branch_ids: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, false>;
25
+ user_id: import("@activepieces/pieces-framework").DropdownProperty<number, true>;
26
+ owner_id: import("@activepieces/pieces-framework").DropdownProperty<number, true>;
27
+ }>;
@@ -0,0 +1,449 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCompanyAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const index_1 = require("../../index");
7
+ const client_1 = require("../common/client");
8
+ exports.createCompanyAction = (0, pieces_framework_1.createAction)({
9
+ auth: index_1.bexioAuth,
10
+ name: 'create_company',
11
+ displayName: 'Create Company',
12
+ description: 'Create a new company contact',
13
+ props: {
14
+ name_1: pieces_framework_1.Property.ShortText({
15
+ displayName: 'Company Name',
16
+ description: 'The name of the company',
17
+ required: true,
18
+ }),
19
+ name_2: pieces_framework_1.Property.ShortText({
20
+ displayName: 'Company Addition',
21
+ description: 'Additional company name (e.g., "Ltd.", "Inc.")',
22
+ required: false,
23
+ }),
24
+ nr: pieces_framework_1.Property.ShortText({
25
+ displayName: 'Contact Number',
26
+ description: 'Contact number (leave empty to auto-assign)',
27
+ required: false,
28
+ }),
29
+ salutation_id: pieces_framework_1.Property.Dropdown({
30
+ displayName: 'Salutation',
31
+ description: 'Salutation for the company',
32
+ required: false,
33
+ refreshers: [],
34
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
35
+ if (!auth) {
36
+ return {
37
+ disabled: true,
38
+ placeholder: 'Connect your Bexio account first',
39
+ options: [],
40
+ };
41
+ }
42
+ try {
43
+ const client = new client_1.BexioClient(auth);
44
+ const salutations = yield client.get('/2.0/salutation');
45
+ return {
46
+ disabled: false,
47
+ options: salutations.map((sal) => ({
48
+ label: sal.name,
49
+ value: sal.id,
50
+ })),
51
+ };
52
+ }
53
+ catch (error) {
54
+ return {
55
+ disabled: true,
56
+ placeholder: 'Failed to load salutations',
57
+ options: [],
58
+ };
59
+ }
60
+ }),
61
+ }),
62
+ title_id: pieces_framework_1.Property.Dropdown({
63
+ displayName: 'Title',
64
+ description: 'Title for the company',
65
+ required: false,
66
+ refreshers: [],
67
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
68
+ if (!auth) {
69
+ return {
70
+ disabled: true,
71
+ placeholder: 'Connect your Bexio account first',
72
+ options: [],
73
+ };
74
+ }
75
+ try {
76
+ const client = new client_1.BexioClient(auth);
77
+ const titles = yield client.get('/2.0/title');
78
+ return {
79
+ disabled: false,
80
+ options: titles.map((title) => ({
81
+ label: title.name,
82
+ value: title.id,
83
+ })),
84
+ };
85
+ }
86
+ catch (error) {
87
+ return {
88
+ disabled: true,
89
+ placeholder: 'Failed to load titles',
90
+ options: [],
91
+ };
92
+ }
93
+ }),
94
+ }),
95
+ street_name: pieces_framework_1.Property.ShortText({
96
+ displayName: 'Street Name',
97
+ description: 'Street name',
98
+ required: false,
99
+ }),
100
+ house_number: pieces_framework_1.Property.ShortText({
101
+ displayName: 'House Number',
102
+ description: 'House number',
103
+ required: false,
104
+ }),
105
+ address_addition: pieces_framework_1.Property.ShortText({
106
+ displayName: 'Address Addition',
107
+ description: 'Additional address information (e.g., "Building C")',
108
+ required: false,
109
+ }),
110
+ postcode: pieces_framework_1.Property.ShortText({
111
+ displayName: 'Postcode',
112
+ description: 'Postal code',
113
+ required: false,
114
+ }),
115
+ city: pieces_framework_1.Property.ShortText({
116
+ displayName: 'City',
117
+ description: 'City',
118
+ required: false,
119
+ }),
120
+ country_id: pieces_framework_1.Property.Dropdown({
121
+ displayName: 'Country',
122
+ description: 'Country',
123
+ required: false,
124
+ refreshers: [],
125
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
126
+ if (!auth) {
127
+ return {
128
+ disabled: true,
129
+ placeholder: 'Connect your Bexio account first',
130
+ options: [],
131
+ };
132
+ }
133
+ try {
134
+ const client = new client_1.BexioClient(auth);
135
+ const countries = yield client.get('/2.0/country');
136
+ return {
137
+ disabled: false,
138
+ options: countries.map((country) => ({
139
+ label: country.name,
140
+ value: country.id,
141
+ })),
142
+ };
143
+ }
144
+ catch (error) {
145
+ return {
146
+ disabled: true,
147
+ placeholder: 'Failed to load countries',
148
+ options: [],
149
+ };
150
+ }
151
+ }),
152
+ }),
153
+ mail: pieces_framework_1.Property.ShortText({
154
+ displayName: 'Email',
155
+ description: 'Primary email address',
156
+ required: false,
157
+ }),
158
+ mail_second: pieces_framework_1.Property.ShortText({
159
+ displayName: 'Secondary Email',
160
+ description: 'Secondary email address',
161
+ required: false,
162
+ }),
163
+ phone_fixed: pieces_framework_1.Property.ShortText({
164
+ displayName: 'Phone',
165
+ description: 'Fixed phone number',
166
+ required: false,
167
+ }),
168
+ phone_fixed_second: pieces_framework_1.Property.ShortText({
169
+ displayName: 'Secondary Phone',
170
+ description: 'Secondary fixed phone number',
171
+ required: false,
172
+ }),
173
+ phone_mobile: pieces_framework_1.Property.ShortText({
174
+ displayName: 'Mobile Phone',
175
+ description: 'Mobile phone number',
176
+ required: false,
177
+ }),
178
+ fax: pieces_framework_1.Property.ShortText({
179
+ displayName: 'Fax',
180
+ description: 'Fax number',
181
+ required: false,
182
+ }),
183
+ url: pieces_framework_1.Property.ShortText({
184
+ displayName: 'Website',
185
+ description: 'Company website URL',
186
+ required: false,
187
+ }),
188
+ skype_name: pieces_framework_1.Property.ShortText({
189
+ displayName: 'Skype Name',
190
+ description: 'Skype username',
191
+ required: false,
192
+ }),
193
+ remarks: pieces_framework_1.Property.LongText({
194
+ displayName: 'Remarks',
195
+ description: 'Additional notes about the company',
196
+ required: false,
197
+ }),
198
+ language_id: pieces_framework_1.Property.Dropdown({
199
+ displayName: 'Language',
200
+ description: 'Preferred language',
201
+ required: false,
202
+ refreshers: [],
203
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
204
+ if (!auth) {
205
+ return {
206
+ disabled: true,
207
+ placeholder: 'Connect your Bexio account first',
208
+ options: [],
209
+ };
210
+ }
211
+ try {
212
+ const client = new client_1.BexioClient(auth);
213
+ const languages = yield client.get('/2.0/language');
214
+ return {
215
+ disabled: false,
216
+ options: languages.map((lang) => ({
217
+ label: lang.name,
218
+ value: lang.id,
219
+ })),
220
+ };
221
+ }
222
+ catch (error) {
223
+ return {
224
+ disabled: true,
225
+ placeholder: 'Failed to load languages',
226
+ options: [],
227
+ };
228
+ }
229
+ }),
230
+ }),
231
+ contact_group_ids: pieces_framework_1.Property.MultiSelectDropdown({
232
+ displayName: 'Contact Groups',
233
+ description: 'Select contact groups',
234
+ required: false,
235
+ refreshers: [],
236
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
237
+ if (!auth) {
238
+ return {
239
+ disabled: true,
240
+ placeholder: 'Connect your Bexio account first',
241
+ options: [],
242
+ };
243
+ }
244
+ try {
245
+ const client = new client_1.BexioClient(auth);
246
+ const groups = yield client.get('/2.0/contact_group');
247
+ return {
248
+ disabled: false,
249
+ options: groups.map((group) => ({
250
+ label: group.name,
251
+ value: group.id.toString(),
252
+ })),
253
+ };
254
+ }
255
+ catch (error) {
256
+ return {
257
+ disabled: true,
258
+ placeholder: 'Failed to load contact groups',
259
+ options: [],
260
+ };
261
+ }
262
+ }),
263
+ }),
264
+ contact_branch_ids: pieces_framework_1.Property.MultiSelectDropdown({
265
+ displayName: 'Contact Sectors',
266
+ description: 'Select contact sectors',
267
+ required: false,
268
+ refreshers: [],
269
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
270
+ if (!auth) {
271
+ return {
272
+ disabled: true,
273
+ placeholder: 'Connect your Bexio account first',
274
+ options: [],
275
+ };
276
+ }
277
+ try {
278
+ const client = new client_1.BexioClient(auth);
279
+ const branches = yield client.get('/2.0/contact_branch');
280
+ return {
281
+ disabled: false,
282
+ options: branches.map((branch) => ({
283
+ label: branch.name,
284
+ value: branch.id.toString(),
285
+ })),
286
+ };
287
+ }
288
+ catch (error) {
289
+ return {
290
+ disabled: true,
291
+ placeholder: 'Failed to load contact sectors',
292
+ options: [],
293
+ };
294
+ }
295
+ }),
296
+ }),
297
+ user_id: pieces_framework_1.Property.Dropdown({
298
+ displayName: 'User',
299
+ description: 'User assigned to this contact',
300
+ required: true,
301
+ refreshers: [],
302
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
303
+ if (!auth) {
304
+ return {
305
+ disabled: true,
306
+ placeholder: 'Connect your Bexio account first',
307
+ options: [],
308
+ };
309
+ }
310
+ try {
311
+ const client = new client_1.BexioClient(auth);
312
+ const users = yield client.get('/3.0/users');
313
+ return {
314
+ disabled: false,
315
+ options: users.map((user) => ({
316
+ label: `${user.firstname || ''} ${user.lastname || ''}`.trim() || user.email,
317
+ value: user.id,
318
+ })),
319
+ };
320
+ }
321
+ catch (error) {
322
+ return {
323
+ disabled: true,
324
+ placeholder: 'Failed to load users',
325
+ options: [],
326
+ };
327
+ }
328
+ }),
329
+ }),
330
+ owner_id: pieces_framework_1.Property.Dropdown({
331
+ displayName: 'Owner',
332
+ description: 'Owner of this contact',
333
+ required: true,
334
+ refreshers: [],
335
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
336
+ if (!auth) {
337
+ return {
338
+ disabled: true,
339
+ placeholder: 'Connect your Bexio account first',
340
+ options: [],
341
+ };
342
+ }
343
+ try {
344
+ const client = new client_1.BexioClient(auth);
345
+ const users = yield client.get('/3.0/users');
346
+ return {
347
+ disabled: false,
348
+ options: users.map((user) => ({
349
+ label: `${user.firstname || ''} ${user.lastname || ''}`.trim() || user.email,
350
+ value: user.id,
351
+ })),
352
+ };
353
+ }
354
+ catch (error) {
355
+ return {
356
+ disabled: true,
357
+ placeholder: 'Failed to load users',
358
+ options: [],
359
+ };
360
+ }
361
+ }),
362
+ }),
363
+ },
364
+ run(context) {
365
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
366
+ const client = new client_1.BexioClient(context.auth);
367
+ const props = context.propsValue;
368
+ const requestBody = {
369
+ contact_type_id: 1, // 1 = company
370
+ name_1: props['name_1'],
371
+ user_id: props['user_id'],
372
+ owner_id: props['owner_id'],
373
+ };
374
+ // Add optional fields only if they have values
375
+ if (props['name_2']) {
376
+ requestBody['name_2'] = props['name_2'];
377
+ }
378
+ if (props['nr'] !== undefined && props['nr'] !== null && props['nr'] !== '') {
379
+ requestBody['nr'] = props['nr'];
380
+ }
381
+ else {
382
+ requestBody['nr'] = null; // Auto-assign
383
+ }
384
+ if (props['salutation_id']) {
385
+ requestBody['salutation_id'] = props['salutation_id'];
386
+ }
387
+ if (props['title_id']) {
388
+ requestBody['title_id'] = props['title_id'];
389
+ }
390
+ if (props['street_name']) {
391
+ requestBody['street_name'] = props['street_name'];
392
+ }
393
+ if (props['house_number']) {
394
+ requestBody['house_number'] = props['house_number'];
395
+ }
396
+ if (props['address_addition']) {
397
+ requestBody['address_addition'] = props['address_addition'];
398
+ }
399
+ if (props['postcode']) {
400
+ requestBody['postcode'] = props['postcode'];
401
+ }
402
+ if (props['city']) {
403
+ requestBody['city'] = props['city'];
404
+ }
405
+ if (props['country_id']) {
406
+ requestBody['country_id'] = props['country_id'];
407
+ }
408
+ if (props['mail']) {
409
+ requestBody['mail'] = props['mail'];
410
+ }
411
+ if (props['mail_second']) {
412
+ requestBody['mail_second'] = props['mail_second'];
413
+ }
414
+ if (props['phone_fixed']) {
415
+ requestBody['phone_fixed'] = props['phone_fixed'];
416
+ }
417
+ if (props['phone_fixed_second']) {
418
+ requestBody['phone_fixed_second'] = props['phone_fixed_second'];
419
+ }
420
+ if (props['phone_mobile']) {
421
+ requestBody['phone_mobile'] = props['phone_mobile'];
422
+ }
423
+ if (props['fax']) {
424
+ requestBody['fax'] = props['fax'];
425
+ }
426
+ if (props['url']) {
427
+ requestBody['url'] = props['url'];
428
+ }
429
+ if (props['skype_name']) {
430
+ requestBody['skype_name'] = props['skype_name'];
431
+ }
432
+ if (props['remarks']) {
433
+ requestBody['remarks'] = props['remarks'];
434
+ }
435
+ if (props['language_id']) {
436
+ requestBody['language_id'] = props['language_id'];
437
+ }
438
+ if (props['contact_group_ids'] && Array.isArray(props['contact_group_ids']) && props['contact_group_ids'].length > 0) {
439
+ requestBody['contact_group_ids'] = props['contact_group_ids'].join(',');
440
+ }
441
+ if (props['contact_branch_ids'] && Array.isArray(props['contact_branch_ids']) && props['contact_branch_ids'].length > 0) {
442
+ requestBody['contact_branch_ids'] = props['contact_branch_ids'].join(',');
443
+ }
444
+ const response = yield client.post('/2.0/contact', requestBody);
445
+ return response;
446
+ });
447
+ },
448
+ });
449
+ //# sourceMappingURL=create-company.js.map