@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.
- package/README.md +7 -0
- package/package.json +27 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +133 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-company.d.ts +27 -0
- package/src/lib/actions/create-company.js +449 -0
- package/src/lib/actions/create-company.js.map +1 -0
- package/src/lib/actions/create-file.d.ts +3 -0
- package/src/lib/actions/create-file.js +44 -0
- package/src/lib/actions/create-file.js.map +1 -0
- package/src/lib/actions/create-manual-entry.d.ts +6 -0
- package/src/lib/actions/create-manual-entry.js +421 -0
- package/src/lib/actions/create-manual-entry.js.map +1 -0
- package/src/lib/actions/create-person.d.ts +29 -0
- package/src/lib/actions/create-person.js +465 -0
- package/src/lib/actions/create-person.js.map +1 -0
- package/src/lib/actions/create-product.d.ts +33 -0
- package/src/lib/actions/create-product.js +515 -0
- package/src/lib/actions/create-product.js.map +1 -0
- package/src/lib/actions/create-project.d.ts +16 -0
- package/src/lib/actions/create-project.js +307 -0
- package/src/lib/actions/create-project.js.map +1 -0
- package/src/lib/actions/create-sales-invoice.d.ts +24 -0
- package/src/lib/actions/create-sales-invoice.js +602 -0
- package/src/lib/actions/create-sales-invoice.js.map +1 -0
- package/src/lib/actions/create-sales-order.d.ts +24 -0
- package/src/lib/actions/create-sales-order.js +628 -0
- package/src/lib/actions/create-sales-order.js.map +1 -0
- package/src/lib/actions/create-sales-quote.d.ts +27 -0
- package/src/lib/actions/create-sales-quote.js +652 -0
- package/src/lib/actions/create-sales-quote.js.map +1 -0
- package/src/lib/actions/create-time-tracking.d.ts +16 -0
- package/src/lib/actions/create-time-tracking.js +369 -0
- package/src/lib/actions/create-time-tracking.js.map +1 -0
- package/src/lib/actions/export-invoice-pdf.d.ts +4 -0
- package/src/lib/actions/export-invoice-pdf.js +89 -0
- package/src/lib/actions/export-invoice-pdf.js.map +1 -0
- package/src/lib/actions/find-account.d.ts +5 -0
- package/src/lib/actions/find-account.js +103 -0
- package/src/lib/actions/find-account.js.map +1 -0
- package/src/lib/actions/find-company.d.ts +7 -0
- package/src/lib/actions/find-company.js +156 -0
- package/src/lib/actions/find-company.js.map +1 -0
- package/src/lib/actions/find-country.d.ts +6 -0
- package/src/lib/actions/find-country.js +121 -0
- package/src/lib/actions/find-country.js.map +1 -0
- package/src/lib/actions/find-person.d.ts +8 -0
- package/src/lib/actions/find-person.js +171 -0
- package/src/lib/actions/find-person.js.map +1 -0
- package/src/lib/actions/find-product.d.ts +6 -0
- package/src/lib/actions/find-product.js +120 -0
- package/src/lib/actions/find-product.js.map +1 -0
- package/src/lib/actions/search-invoice.d.ts +6 -0
- package/src/lib/actions/search-invoice.js +136 -0
- package/src/lib/actions/search-invoice.js.map +1 -0
- package/src/lib/actions/search-order.d.ts +6 -0
- package/src/lib/actions/search-order.js +135 -0
- package/src/lib/actions/search-order.js.map +1 -0
- package/src/lib/actions/search-quote.d.ts +6 -0
- package/src/lib/actions/search-quote.js +136 -0
- package/src/lib/actions/search-quote.js.map +1 -0
- package/src/lib/actions/send-sales-invoice.d.ts +8 -0
- package/src/lib/actions/send-sales-invoice.js +105 -0
- package/src/lib/actions/send-sales-invoice.js.map +1 -0
- package/src/lib/actions/update-company.d.ts +28 -0
- package/src/lib/actions/update-company.js +493 -0
- package/src/lib/actions/update-company.js.map +1 -0
- package/src/lib/actions/update-person.d.ts +30 -0
- package/src/lib/actions/update-person.js +511 -0
- package/src/lib/actions/update-person.js.map +1 -0
- package/src/lib/actions/update-product.d.ts +33 -0
- package/src/lib/actions/update-product.js +543 -0
- package/src/lib/actions/update-product.js.map +1 -0
- package/src/lib/common/client.d.ts +11 -0
- package/src/lib/common/client.js +62 -0
- package/src/lib/common/client.js.map +1 -0
- package/src/lib/common/index.d.ts +4 -0
- package/src/lib/common/index.js +8 -0
- package/src/lib/common/index.js.map +1 -0
- package/src/lib/common/props.d.ts +13 -0
- package/src/lib/common/props.js +112 -0
- package/src/lib/common/props.js.map +1 -0
- package/src/lib/common/types.d.ts +88 -0
- package/src/lib/common/types.js +4 -0
- package/src/lib/common/types.js.map +1 -0
- package/src/lib/triggers/new-order.d.ts +8 -0
- package/src/lib/triggers/new-order.js +146 -0
- package/src/lib/triggers/new-order.js.map +1 -0
- package/src/lib/triggers/new-product.d.ts +2 -0
- package/src/lib/triggers/new-product.js +106 -0
- package/src/lib/triggers/new-product.js.map +1 -0
- package/src/lib/triggers/new-project.d.ts +8 -0
- package/src/lib/triggers/new-project.js +135 -0
- package/src/lib/triggers/new-project.js.map +1 -0
- package/src/lib/triggers/new-quote.d.ts +8 -0
- package/src/lib/triggers/new-quote.js +147 -0
- package/src/lib/triggers/new-quote.js.map +1 -0
- package/src/lib/triggers/new-sales-invoice.d.ts +8 -0
- package/src/lib/triggers/new-sales-invoice.js +147 -0
- package/src/lib/triggers/new-sales-invoice.js.map +1 -0
- package/src/lib/triggers/new-updated-company.d.ts +2 -0
- package/src/lib/triggers/new-updated-company.js +117 -0
- package/src/lib/triggers/new-updated-company.js.map +1 -0
- package/src/lib/triggers/new-updated-person.d.ts +2 -0
- package/src/lib/triggers/new-updated-person.js +117 -0
- package/src/lib/triggers/new-updated-person.js.map +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const bexioCommonProps: {
|
|
2
|
+
account: (options: {
|
|
3
|
+
displayName: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
}) => import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
|
|
7
|
+
tax: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
|
|
8
|
+
currency: (options: {
|
|
9
|
+
displayName: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
}) => import("@activepieces/pieces-framework").DropdownProperty<number, false> | import("@activepieces/pieces-framework").DropdownProperty<number, true>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bexioCommonProps = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const client_1 = require("./client");
|
|
7
|
+
exports.bexioCommonProps = {
|
|
8
|
+
account: (options) => {
|
|
9
|
+
return pieces_framework_1.Property.Dropdown({
|
|
10
|
+
displayName: options.displayName,
|
|
11
|
+
description: options.description,
|
|
12
|
+
required: options.required,
|
|
13
|
+
refreshers: [],
|
|
14
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
15
|
+
if (!auth) {
|
|
16
|
+
return {
|
|
17
|
+
disabled: true,
|
|
18
|
+
placeholder: 'Connect your Bexio account first',
|
|
19
|
+
options: [],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const client = new client_1.BexioClient(auth);
|
|
24
|
+
const accounts = yield client.get('/accounts');
|
|
25
|
+
return {
|
|
26
|
+
disabled: false,
|
|
27
|
+
options: accounts.map((account) => ({
|
|
28
|
+
label: `${account.account_no} - ${account.name}`,
|
|
29
|
+
value: account.id,
|
|
30
|
+
})),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
disabled: true,
|
|
36
|
+
placeholder: 'Failed to load accounts',
|
|
37
|
+
options: [],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
tax: pieces_framework_1.Property.Dropdown({
|
|
44
|
+
displayName: 'Tax',
|
|
45
|
+
description: 'Select a tax rate',
|
|
46
|
+
required: false,
|
|
47
|
+
refreshers: [],
|
|
48
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
49
|
+
if (!auth) {
|
|
50
|
+
return {
|
|
51
|
+
disabled: true,
|
|
52
|
+
placeholder: 'Connect your Bexio account first',
|
|
53
|
+
options: [],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const client = new client_1.BexioClient(auth);
|
|
58
|
+
const taxes = yield client.get('/taxes');
|
|
59
|
+
return {
|
|
60
|
+
disabled: false,
|
|
61
|
+
options: taxes.map((tax) => ({
|
|
62
|
+
label: `${tax.name} (${tax.percentage}%)`,
|
|
63
|
+
value: tax.id,
|
|
64
|
+
})),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
return {
|
|
69
|
+
disabled: true,
|
|
70
|
+
placeholder: 'Failed to load taxes',
|
|
71
|
+
options: [],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
}),
|
|
76
|
+
currency: (options) => {
|
|
77
|
+
return pieces_framework_1.Property.Dropdown({
|
|
78
|
+
displayName: options.displayName,
|
|
79
|
+
description: options.description,
|
|
80
|
+
required: options.required,
|
|
81
|
+
refreshers: [],
|
|
82
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
83
|
+
if (!auth) {
|
|
84
|
+
return {
|
|
85
|
+
disabled: true,
|
|
86
|
+
placeholder: 'Connect your Bexio account first',
|
|
87
|
+
options: [],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const client = new client_1.BexioClient(auth);
|
|
92
|
+
const currencies = yield client.get('/3.0/currencies');
|
|
93
|
+
return {
|
|
94
|
+
disabled: false,
|
|
95
|
+
options: currencies.map((currency) => ({
|
|
96
|
+
label: currency.name,
|
|
97
|
+
value: currency.id,
|
|
98
|
+
})),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
return {
|
|
103
|
+
disabled: true,
|
|
104
|
+
placeholder: 'Failed to load currencies',
|
|
105
|
+
options: [],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bexio/src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,qEAA+E;AAC/E,qCAAuC;AAG1B,QAAA,gBAAgB,GAAG;IAC9B,OAAO,EAAE,CAAC,OAIT,EAAE,EAAE;QACH,OAAO,2BAAQ,CAAC,QAAQ,CAAC;YACvB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;gBACtB,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,WAAW,EAAE,kCAAkC;wBAC/C,OAAO,EAAE,EAAE;qBACZ,CAAC;gBACJ,CAAC;gBAED,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC,IAA2B,CAAC,CAAC;oBAC5D,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAAiB,WAAW,CAAC,CAAC;oBAE/D,OAAO;wBACL,QAAQ,EAAE,KAAK;wBACf,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;4BAClC,KAAK,EAAE,GAAG,OAAO,CAAC,UAAU,MAAM,OAAO,CAAC,IAAI,EAAE;4BAChD,KAAK,EAAE,OAAO,CAAC,EAAE;yBAClB,CAAC,CAAC;qBACJ,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO;wBACL,QAAQ,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,WAAW;YAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,UAAU,EAAE,EAAE;YACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;gBACtB,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,WAAW,EAAE,kCAAkC;wBAC/C,OAAO,EAAE,EAAE;qBACZ,CAAC;gBACJ,CAAC;gBAED,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC,IAA2B,CAAC,CAAC;oBAC5D,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,GAAG,CAAkB,iBAAiB,CAAC,CAAC;oBAExE,OAAO;wBACL,QAAQ,EAAE,KAAK;wBACf,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;4BACrC,KAAK,EAAE,QAAQ,CAAC,IAAI;4BACpB,KAAK,EAAE,QAAQ,CAAC,EAAE;yBACnB,CAAC,CAAC;qBACJ,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO;wBACL,QAAQ,EAAE,IAAI;wBACd,WAAW,EAAE,2BAA2B;wBACxC,OAAO,EAAE,EAAE;qBACZ,CAAC;gBACJ,CAAC;YACH,CAAC,CAAA;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export interface BexioContact {
|
|
2
|
+
id: number;
|
|
3
|
+
nr: string;
|
|
4
|
+
contact_type_id: number;
|
|
5
|
+
name_1: string;
|
|
6
|
+
name_2?: string;
|
|
7
|
+
salutation_id?: number;
|
|
8
|
+
salutation_form?: number;
|
|
9
|
+
title_id?: number;
|
|
10
|
+
birthday?: string;
|
|
11
|
+
address?: string;
|
|
12
|
+
postcode?: string;
|
|
13
|
+
city?: string;
|
|
14
|
+
country_id?: number;
|
|
15
|
+
mail?: string;
|
|
16
|
+
mail_second?: string;
|
|
17
|
+
phone_fixed?: string;
|
|
18
|
+
phone_fixed_second?: string;
|
|
19
|
+
phone_mobile?: string;
|
|
20
|
+
fax?: string;
|
|
21
|
+
url?: string;
|
|
22
|
+
skype_name?: string;
|
|
23
|
+
remarks?: string;
|
|
24
|
+
language_id?: number;
|
|
25
|
+
contact_group_ids?: string;
|
|
26
|
+
contact_branch_ids?: string;
|
|
27
|
+
user_id?: number;
|
|
28
|
+
owner_id?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface BexioCompany {
|
|
31
|
+
id: number;
|
|
32
|
+
name: string;
|
|
33
|
+
address?: string;
|
|
34
|
+
address_nr?: string;
|
|
35
|
+
postcode?: string;
|
|
36
|
+
city?: string;
|
|
37
|
+
country_id?: number;
|
|
38
|
+
legal_form?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface BexioAccount {
|
|
41
|
+
id: number;
|
|
42
|
+
account_no: string;
|
|
43
|
+
name: string;
|
|
44
|
+
account_type: number;
|
|
45
|
+
}
|
|
46
|
+
export interface BexioTax {
|
|
47
|
+
id: number;
|
|
48
|
+
name: string;
|
|
49
|
+
percentage: string;
|
|
50
|
+
}
|
|
51
|
+
export interface BexioCurrency {
|
|
52
|
+
id: number;
|
|
53
|
+
name: string;
|
|
54
|
+
}
|
|
55
|
+
export interface BexioManualEntry {
|
|
56
|
+
debit_account_id?: number;
|
|
57
|
+
credit_account_id?: number;
|
|
58
|
+
tax_id?: number;
|
|
59
|
+
tax_account_id?: number;
|
|
60
|
+
description?: string;
|
|
61
|
+
amount?: number;
|
|
62
|
+
currency_id?: number;
|
|
63
|
+
currency_factor?: number;
|
|
64
|
+
}
|
|
65
|
+
export interface BexioManualEntryResponse {
|
|
66
|
+
id: number;
|
|
67
|
+
type: 'manual_single_entry' | 'manual_compound_entry' | 'manual_group_entry';
|
|
68
|
+
date: string;
|
|
69
|
+
reference_nr?: string;
|
|
70
|
+
created_by_user_id?: number;
|
|
71
|
+
edited_by_user_id?: number;
|
|
72
|
+
entries: BexioManualEntry[];
|
|
73
|
+
is_locked?: boolean;
|
|
74
|
+
locked_info?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface BexioError {
|
|
77
|
+
error_code: number;
|
|
78
|
+
message: string;
|
|
79
|
+
}
|
|
80
|
+
export interface BexioListResponse<T> {
|
|
81
|
+
data: T[];
|
|
82
|
+
paging?: {
|
|
83
|
+
page: number;
|
|
84
|
+
page_size: number;
|
|
85
|
+
page_count: number;
|
|
86
|
+
item_count: number;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bexio/src/lib/common/types.ts"],"names":[],"mappings":";AAAA,6BAA6B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newOrderTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
+
status_id: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
|
|
4
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
5
|
+
status_id: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
|
|
6
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
7
|
+
status_id: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newOrderTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
10
|
+
const polling = {
|
|
11
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
12
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastFetchEpochMS, propsValue }) {
|
|
13
|
+
const client = new client_1.BexioClient(auth);
|
|
14
|
+
const isTest = lastFetchEpochMS === 0;
|
|
15
|
+
const lastFetchDate = isTest
|
|
16
|
+
? (0, dayjs_1.default)().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss')
|
|
17
|
+
: (0, dayjs_1.default)(lastFetchEpochMS).format('YYYY-MM-DD HH:mm:ss');
|
|
18
|
+
const searchBody = [
|
|
19
|
+
{
|
|
20
|
+
field: 'updated_at',
|
|
21
|
+
value: lastFetchDate,
|
|
22
|
+
criteria: '>=',
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
if (propsValue.status_id !== undefined && propsValue.status_id !== null) {
|
|
26
|
+
searchBody.push({
|
|
27
|
+
field: 'kb_item_status_id',
|
|
28
|
+
value: propsValue.status_id.toString(),
|
|
29
|
+
criteria: '=',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const queryParams = {
|
|
33
|
+
order_by: 'updated_at_desc',
|
|
34
|
+
limit: isTest ? '5' : '500',
|
|
35
|
+
};
|
|
36
|
+
const orders = yield client.post('/2.0/kb_order/search', searchBody, queryParams);
|
|
37
|
+
return orders.map((order) => {
|
|
38
|
+
const updatedAt = order.updated_at || new Date().toISOString();
|
|
39
|
+
const epochMilliSeconds = (0, dayjs_1.default)(updatedAt).valueOf();
|
|
40
|
+
return {
|
|
41
|
+
epochMilliSeconds,
|
|
42
|
+
data: order,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}),
|
|
46
|
+
};
|
|
47
|
+
exports.newOrderTrigger = (0, pieces_framework_1.createTrigger)({
|
|
48
|
+
auth: index_1.bexioAuth,
|
|
49
|
+
name: 'new_order',
|
|
50
|
+
displayName: 'New Order',
|
|
51
|
+
description: 'Triggers when an Order is created or updated with the chosen status',
|
|
52
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
53
|
+
props: {
|
|
54
|
+
status_id: pieces_framework_1.Property.Dropdown({
|
|
55
|
+
displayName: 'Status',
|
|
56
|
+
description: 'Filter orders by status (leave empty to trigger for all statuses)',
|
|
57
|
+
required: false,
|
|
58
|
+
refreshers: [],
|
|
59
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
60
|
+
if (!auth) {
|
|
61
|
+
return {
|
|
62
|
+
disabled: true,
|
|
63
|
+
placeholder: 'Connect your Bexio account first',
|
|
64
|
+
options: [],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const client = new client_1.BexioClient(auth);
|
|
69
|
+
const statuses = yield client.get('/2.0/kb_order_status').catch(() => []);
|
|
70
|
+
if (statuses.length === 0) {
|
|
71
|
+
return {
|
|
72
|
+
disabled: false,
|
|
73
|
+
placeholder: 'Status filter not available - will trigger for all statuses',
|
|
74
|
+
options: [],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
disabled: false,
|
|
79
|
+
options: statuses.map((status) => ({
|
|
80
|
+
label: status.name,
|
|
81
|
+
value: status.id,
|
|
82
|
+
})),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
return {
|
|
87
|
+
disabled: false,
|
|
88
|
+
placeholder: 'Enter status ID manually or leave empty for all statuses',
|
|
89
|
+
options: [],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
}),
|
|
94
|
+
},
|
|
95
|
+
sampleData: {
|
|
96
|
+
id: 4,
|
|
97
|
+
document_nr: 'AU-00001',
|
|
98
|
+
title: null,
|
|
99
|
+
contact_id: 14,
|
|
100
|
+
contact_sub_id: null,
|
|
101
|
+
user_id: 1,
|
|
102
|
+
project_id: null,
|
|
103
|
+
language_id: 1,
|
|
104
|
+
bank_account_id: 1,
|
|
105
|
+
currency_id: 1,
|
|
106
|
+
payment_type_id: 1,
|
|
107
|
+
total_gross: '17.800000',
|
|
108
|
+
total_net: '17.800000',
|
|
109
|
+
total_taxes: '1.3706',
|
|
110
|
+
total: '19.150000',
|
|
111
|
+
kb_item_status_id: 5,
|
|
112
|
+
is_valid_from: '2019-06-24',
|
|
113
|
+
updated_at: '2019-04-08 13:17:32',
|
|
114
|
+
},
|
|
115
|
+
onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
117
|
+
auth: context.auth,
|
|
118
|
+
store: context.store,
|
|
119
|
+
propsValue: context.propsValue,
|
|
120
|
+
});
|
|
121
|
+
}),
|
|
122
|
+
onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
124
|
+
auth: context.auth,
|
|
125
|
+
store: context.store,
|
|
126
|
+
propsValue: context.propsValue,
|
|
127
|
+
});
|
|
128
|
+
}),
|
|
129
|
+
test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
+
return yield pieces_common_1.pollingHelper.test(polling, {
|
|
131
|
+
auth: context.auth,
|
|
132
|
+
store: context.store,
|
|
133
|
+
propsValue: context.propsValue,
|
|
134
|
+
files: context.files,
|
|
135
|
+
});
|
|
136
|
+
}),
|
|
137
|
+
run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
139
|
+
auth: context.auth,
|
|
140
|
+
store: context.store,
|
|
141
|
+
propsValue: context.propsValue,
|
|
142
|
+
files: context.files,
|
|
143
|
+
});
|
|
144
|
+
}),
|
|
145
|
+
});
|
|
146
|
+
//# sourceMappingURL=new-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-order.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bexio/src/lib/triggers/new-order.ts"],"names":[],"mappings":";;;;AAAA,qEAAgH;AAChH,+DAAqF;AACrF,uCAAwC;AACxC,6CAA+C;AAE/C,0DAA0B;AAE1B,MAAM,OAAO,GAGT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAA+C,EAAE,oDAA1C,EAAE,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE;QAClD,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC,IAAI,CAAC,CAAC;QAErC,MAAM,MAAM,GAAG,gBAAgB,KAAK,CAAC,CAAC;QAEtC,MAAM,aAAa,GAAG,MAAM;YAC1B,CAAC,CAAC,IAAA,eAAK,GAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC;YAC1D,CAAC,CAAC,IAAA,eAAK,EAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAE1D,MAAM,UAAU,GAA8D;YAC5E;gBACE,KAAK,EAAE,YAAY;gBACnB,KAAK,EAAE,aAAa;gBACpB,QAAQ,EAAE,IAAI;aACf;SACF,CAAC;QAEF,IAAI,UAAU,CAAC,SAAS,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;YACxE,UAAU,CAAC,IAAI,CAAC;gBACd,KAAK,EAAE,mBAAmB;gBAC1B,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE;gBACtC,QAAQ,EAAE,GAAG;aACd,CAAC,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1B,MAAM,6BAAa,CAAC,QAAQ,CAAC,OAAO,EAAE;YACpC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAC,CAAC;IACL,CAAC,CAAA;IACD,SAAS,EAAE,CAAO,OAAO,EAAE,EAAE;QAC3B,MAAM,6BAAa,CAAC,SAAS,CAAC,OAAO,EAAE;YACrC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAC,CAAC;IACL,CAAC,CAAA;IACD,IAAI,EAAE,CAAO,OAAO,EAAE,EAAE;QACtB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE;YACvC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC,CAAC;IACL,CAAC,CAAA;IACD,GAAG,EAAE,CAAO,OAAO,EAAE,EAAE;QACrB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE;YACvC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;SACrB,CAAC,CAAC;IACL,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newProductTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {}>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newProductTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const polling = {
|
|
10
|
+
strategy: pieces_common_1.DedupeStrategy.LAST_ITEM,
|
|
11
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastItemId }) {
|
|
12
|
+
const client = new client_1.BexioClient(auth);
|
|
13
|
+
// Use GET endpoint to fetch all articles, then sort by ID descending
|
|
14
|
+
// This avoids the issue with empty search arrays
|
|
15
|
+
const queryParams = {
|
|
16
|
+
limit: '500',
|
|
17
|
+
};
|
|
18
|
+
const products = yield client.get('/2.0/article', queryParams);
|
|
19
|
+
// Sort by ID descending to get newest first (since GET doesn't support order_by)
|
|
20
|
+
const sortedProducts = products.sort((a, b) => b.id - a.id);
|
|
21
|
+
return sortedProducts.map((product) => ({
|
|
22
|
+
id: product.id,
|
|
23
|
+
data: product,
|
|
24
|
+
}));
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
exports.newProductTrigger = (0, pieces_framework_1.createTrigger)({
|
|
28
|
+
auth: index_1.bexioAuth,
|
|
29
|
+
name: 'new_product',
|
|
30
|
+
displayName: 'New Product',
|
|
31
|
+
description: 'Triggers when a new product is created',
|
|
32
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
33
|
+
props: {},
|
|
34
|
+
sampleData: {
|
|
35
|
+
id: 4,
|
|
36
|
+
user_id: 1,
|
|
37
|
+
article_type_id: 1,
|
|
38
|
+
contact_id: 14,
|
|
39
|
+
deliverer_code: null,
|
|
40
|
+
deliverer_name: null,
|
|
41
|
+
deliverer_description: null,
|
|
42
|
+
intern_code: 'wh-2019',
|
|
43
|
+
intern_name: 'Webhosting',
|
|
44
|
+
intern_description: null,
|
|
45
|
+
purchase_price: null,
|
|
46
|
+
sale_price: null,
|
|
47
|
+
purchase_total: null,
|
|
48
|
+
sale_total: null,
|
|
49
|
+
currency_id: null,
|
|
50
|
+
tax_income_id: null,
|
|
51
|
+
tax_id: null,
|
|
52
|
+
tax_expense_id: null,
|
|
53
|
+
unit_id: null,
|
|
54
|
+
is_stock: false,
|
|
55
|
+
stock_id: null,
|
|
56
|
+
stock_place_id: null,
|
|
57
|
+
stock_nr: 0,
|
|
58
|
+
stock_min_nr: 0,
|
|
59
|
+
stock_reserved_nr: 0,
|
|
60
|
+
stock_available_nr: 0,
|
|
61
|
+
stock_picked_nr: 0,
|
|
62
|
+
stock_disposed_nr: 0,
|
|
63
|
+
stock_ordered_nr: 0,
|
|
64
|
+
width: null,
|
|
65
|
+
height: null,
|
|
66
|
+
weight: null,
|
|
67
|
+
volume: null,
|
|
68
|
+
html_text: null,
|
|
69
|
+
remarks: null,
|
|
70
|
+
delivery_price: null,
|
|
71
|
+
article_group_id: null,
|
|
72
|
+
account_id: null,
|
|
73
|
+
expense_account_id: null,
|
|
74
|
+
},
|
|
75
|
+
onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
77
|
+
auth: context.auth,
|
|
78
|
+
store: context.store,
|
|
79
|
+
propsValue: context.propsValue,
|
|
80
|
+
});
|
|
81
|
+
}),
|
|
82
|
+
onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
83
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
84
|
+
auth: context.auth,
|
|
85
|
+
store: context.store,
|
|
86
|
+
propsValue: context.propsValue,
|
|
87
|
+
});
|
|
88
|
+
}),
|
|
89
|
+
test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
return yield pieces_common_1.pollingHelper.test(polling, {
|
|
91
|
+
auth: context.auth,
|
|
92
|
+
store: context.store,
|
|
93
|
+
propsValue: context.propsValue,
|
|
94
|
+
files: context.files,
|
|
95
|
+
});
|
|
96
|
+
}),
|
|
97
|
+
run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
99
|
+
auth: context.auth,
|
|
100
|
+
store: context.store,
|
|
101
|
+
propsValue: context.propsValue,
|
|
102
|
+
files: context.files,
|
|
103
|
+
});
|
|
104
|
+
}),
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=new-product.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-product.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bexio/src/lib/triggers/new-product.ts"],"names":[],"mappings":";;;;AAAA,qEAAsG;AACtG,+DAAqF;AACrF,uCAAwC;AACxC,6CAA+C;AAE/C,MAAM,OAAO,GAGT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAA6B,EAAE,oDAAxB,EAAE,IAAI,EAAE,UAAU,EAAE;QAChC,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC,IAAI,CAAC,CAAC;QAErC,qEAAqE;QACrE,iDAAiD;QACjD,MAAM,WAAW,GAA2B;YAC1C,KAAK,EAAE,KAAK;SACb,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,CAwC7B,cAAc,EAAE,WAAW,CAAC,CAAC;QAEjC,iFAAiF;QACjF,MAAM,cAAc,GAAG,QAAQ,CAA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K;SACrB,CAAC,CAAC;IACL,CAAC,CAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newProjectTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
3
|
+
status_id: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
|
|
4
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
5
|
+
status_id: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
|
|
6
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
|
|
7
|
+
status_id: import("@activepieces/pieces-framework").DropdownProperty<number, false>;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newProjectTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const index_1 = require("../../index");
|
|
8
|
+
const client_1 = require("../common/client");
|
|
9
|
+
const polling = {
|
|
10
|
+
strategy: pieces_common_1.DedupeStrategy.LAST_ITEM,
|
|
11
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastItemId, propsValue }) {
|
|
12
|
+
const client = new client_1.BexioClient(auth);
|
|
13
|
+
const searchBody = [
|
|
14
|
+
{
|
|
15
|
+
field: 'name',
|
|
16
|
+
value: '',
|
|
17
|
+
criteria: 'not_null',
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
if (propsValue.status_id !== undefined && propsValue.status_id !== null) {
|
|
21
|
+
searchBody.push({
|
|
22
|
+
field: 'pr_state_id',
|
|
23
|
+
value: propsValue.status_id.toString(),
|
|
24
|
+
criteria: '=',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const queryParams = {
|
|
28
|
+
order_by: 'id_desc',
|
|
29
|
+
limit: '500',
|
|
30
|
+
};
|
|
31
|
+
const projects = yield client.post('/2.0/pr_project/search', searchBody, queryParams);
|
|
32
|
+
return projects.map((project) => ({
|
|
33
|
+
id: project.id,
|
|
34
|
+
data: project,
|
|
35
|
+
}));
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
exports.newProjectTrigger = (0, pieces_framework_1.createTrigger)({
|
|
39
|
+
auth: index_1.bexioAuth,
|
|
40
|
+
name: 'new_project',
|
|
41
|
+
displayName: 'New Project',
|
|
42
|
+
description: 'Triggers when a Project is created or updated with the chosen status',
|
|
43
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
44
|
+
props: {
|
|
45
|
+
status_id: pieces_framework_1.Property.Dropdown({
|
|
46
|
+
displayName: 'Status',
|
|
47
|
+
description: 'Filter projects by status (leave empty to trigger for all statuses)',
|
|
48
|
+
required: false,
|
|
49
|
+
refreshers: [],
|
|
50
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
51
|
+
if (!auth) {
|
|
52
|
+
return {
|
|
53
|
+
disabled: true,
|
|
54
|
+
placeholder: 'Connect your Bexio account first',
|
|
55
|
+
options: [],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const client = new client_1.BexioClient(auth);
|
|
60
|
+
const statuses = yield client.get('/2.0/pr_project_state').catch(() => []);
|
|
61
|
+
if (statuses.length === 0) {
|
|
62
|
+
return {
|
|
63
|
+
disabled: false,
|
|
64
|
+
placeholder: 'Status filter not available - will trigger for all statuses',
|
|
65
|
+
options: [],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
disabled: false,
|
|
70
|
+
options: statuses.map((status) => ({
|
|
71
|
+
label: status.name,
|
|
72
|
+
value: status.id,
|
|
73
|
+
})),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return {
|
|
78
|
+
disabled: false,
|
|
79
|
+
placeholder: 'Enter status ID manually or leave empty for all statuses',
|
|
80
|
+
options: [],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
}),
|
|
85
|
+
},
|
|
86
|
+
sampleData: {
|
|
87
|
+
id: 2,
|
|
88
|
+
uuid: '046b6c7f-0b8a-43b9-b35d-6489e6daee91',
|
|
89
|
+
nr: '000002',
|
|
90
|
+
name: 'Villa Kunterbunt',
|
|
91
|
+
start_date: '2019-07-12 00:00:00',
|
|
92
|
+
end_date: null,
|
|
93
|
+
comment: '',
|
|
94
|
+
pr_state_id: 2,
|
|
95
|
+
pr_project_type_id: 2,
|
|
96
|
+
contact_id: 2,
|
|
97
|
+
contact_sub_id: null,
|
|
98
|
+
pr_invoice_type_id: 3,
|
|
99
|
+
pr_invoice_type_amount: '230.00',
|
|
100
|
+
pr_budget_type_id: 1,
|
|
101
|
+
pr_budget_type_amount: '200.00',
|
|
102
|
+
user_id: 1,
|
|
103
|
+
},
|
|
104
|
+
onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
106
|
+
auth: context.auth,
|
|
107
|
+
store: context.store,
|
|
108
|
+
propsValue: context.propsValue,
|
|
109
|
+
});
|
|
110
|
+
}),
|
|
111
|
+
onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
112
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
113
|
+
auth: context.auth,
|
|
114
|
+
store: context.store,
|
|
115
|
+
propsValue: context.propsValue,
|
|
116
|
+
});
|
|
117
|
+
}),
|
|
118
|
+
test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
+
return yield pieces_common_1.pollingHelper.test(polling, {
|
|
120
|
+
auth: context.auth,
|
|
121
|
+
store: context.store,
|
|
122
|
+
propsValue: context.propsValue,
|
|
123
|
+
files: context.files,
|
|
124
|
+
});
|
|
125
|
+
}),
|
|
126
|
+
run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
127
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
128
|
+
auth: context.auth,
|
|
129
|
+
store: context.store,
|
|
130
|
+
propsValue: context.propsValue,
|
|
131
|
+
files: context.files,
|
|
132
|
+
});
|
|
133
|
+
}),
|
|
134
|
+
});
|
|
135
|
+
//# sourceMappingURL=new-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-project.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/bexio/src/lib/triggers/new-project.ts"],"names":[],"mappings":";;;;AAAA,qEAAgH;AAChH,+DAAqF;AACrF,uCAAwC;AACxC,6CAA+C;AAG/C,MAAM,OAAO,GAGT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAAyC,EAAE,oDAApC,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE;QAC5C,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC,IAAI,CAAC,CAAC;QAErC,MAAM,UAAU,GAA8D;YAC5E;gBACE,KAAK,EAAE,MAAM;gBACb,KAAK,EAAE,EAAE;gBACT,QAAQ,EAAE,UAAU;aACrB;SACF,CAAC;QAEF,IAAI,UAAU,CAAC,SAAS,KAAK,SAAS,IAAI,UAAU,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;YACxE,UAAU,CAAC,IAAI,CAAC;gBACd,KAAK,EAAE,aAAa;gBACpB,KAAK,EA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