@agnocon/piece-bexio 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.MIT-AP +24 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/actions/create-company.d.ts +28 -0
- package/dist/lib/actions/create-company.d.ts.map +1 -0
- package/dist/lib/actions/create-company.js +461 -0
- package/dist/lib/actions/create-company.js.map +1 -0
- package/dist/lib/actions/create-file.d.ts +4 -0
- package/dist/lib/actions/create-file.d.ts.map +1 -0
- package/dist/lib/actions/create-file.js +48 -0
- package/dist/lib/actions/create-file.js.map +1 -0
- package/dist/lib/actions/create-manual-entry.d.ts +7 -0
- package/dist/lib/actions/create-manual-entry.d.ts.map +1 -0
- package/dist/lib/actions/create-manual-entry.js +426 -0
- package/dist/lib/actions/create-manual-entry.js.map +1 -0
- package/dist/lib/actions/create-person.d.ts +30 -0
- package/dist/lib/actions/create-person.d.ts.map +1 -0
- package/dist/lib/actions/create-person.js +477 -0
- package/dist/lib/actions/create-person.js.map +1 -0
- package/dist/lib/actions/create-product.d.ts +34 -0
- package/dist/lib/actions/create-product.d.ts.map +1 -0
- package/dist/lib/actions/create-product.js +527 -0
- package/dist/lib/actions/create-product.js.map +1 -0
- package/dist/lib/actions/create-project.d.ts +17 -0
- package/dist/lib/actions/create-project.d.ts.map +1 -0
- package/dist/lib/actions/create-project.js +316 -0
- package/dist/lib/actions/create-project.js.map +1 -0
- package/dist/lib/actions/create-sales-invoice.d.ts +25 -0
- package/dist/lib/actions/create-sales-invoice.d.ts.map +1 -0
- package/dist/lib/actions/create-sales-invoice.js +615 -0
- package/dist/lib/actions/create-sales-invoice.js.map +1 -0
- package/dist/lib/actions/create-sales-order.d.ts +25 -0
- package/dist/lib/actions/create-sales-order.d.ts.map +1 -0
- package/dist/lib/actions/create-sales-order.js +642 -0
- package/dist/lib/actions/create-sales-order.js.map +1 -0
- package/dist/lib/actions/create-sales-quote.d.ts +28 -0
- package/dist/lib/actions/create-sales-quote.d.ts.map +1 -0
- package/dist/lib/actions/create-sales-quote.js +666 -0
- package/dist/lib/actions/create-sales-quote.js.map +1 -0
- package/dist/lib/actions/create-time-tracking.d.ts +17 -0
- package/dist/lib/actions/create-time-tracking.d.ts.map +1 -0
- package/dist/lib/actions/create-time-tracking.js +380 -0
- package/dist/lib/actions/create-time-tracking.js.map +1 -0
- package/dist/lib/actions/export-invoice-pdf.d.ts +5 -0
- package/dist/lib/actions/export-invoice-pdf.d.ts.map +1 -0
- package/dist/lib/actions/export-invoice-pdf.js +94 -0
- package/dist/lib/actions/export-invoice-pdf.js.map +1 -0
- package/dist/lib/actions/find-account.d.ts +6 -0
- package/dist/lib/actions/find-account.d.ts.map +1 -0
- package/dist/lib/actions/find-account.js +107 -0
- package/dist/lib/actions/find-account.js.map +1 -0
- package/dist/lib/actions/find-company.d.ts +8 -0
- package/dist/lib/actions/find-company.d.ts.map +1 -0
- package/dist/lib/actions/find-company.js +160 -0
- package/dist/lib/actions/find-company.js.map +1 -0
- package/dist/lib/actions/find-country.d.ts +7 -0
- package/dist/lib/actions/find-country.d.ts.map +1 -0
- package/dist/lib/actions/find-country.js +125 -0
- package/dist/lib/actions/find-country.js.map +1 -0
- package/dist/lib/actions/find-person.d.ts +9 -0
- package/dist/lib/actions/find-person.d.ts.map +1 -0
- package/dist/lib/actions/find-person.js +175 -0
- package/dist/lib/actions/find-person.js.map +1 -0
- package/dist/lib/actions/find-product.d.ts +7 -0
- package/dist/lib/actions/find-product.d.ts.map +1 -0
- package/dist/lib/actions/find-product.js +124 -0
- package/dist/lib/actions/find-product.js.map +1 -0
- package/dist/lib/actions/search-invoice.d.ts +7 -0
- package/dist/lib/actions/search-invoice.d.ts.map +1 -0
- package/dist/lib/actions/search-invoice.js +140 -0
- package/dist/lib/actions/search-invoice.js.map +1 -0
- package/dist/lib/actions/search-order.d.ts +7 -0
- package/dist/lib/actions/search-order.d.ts.map +1 -0
- package/dist/lib/actions/search-order.js +139 -0
- package/dist/lib/actions/search-order.js.map +1 -0
- package/dist/lib/actions/search-quote.d.ts +7 -0
- package/dist/lib/actions/search-quote.d.ts.map +1 -0
- package/dist/lib/actions/search-quote.js +140 -0
- package/dist/lib/actions/search-quote.js.map +1 -0
- package/dist/lib/actions/send-sales-invoice.d.ts +9 -0
- package/dist/lib/actions/send-sales-invoice.d.ts.map +1 -0
- package/dist/lib/actions/send-sales-invoice.js +110 -0
- package/dist/lib/actions/send-sales-invoice.js.map +1 -0
- package/dist/lib/actions/update-company.d.ts +29 -0
- package/dist/lib/actions/update-company.d.ts.map +1 -0
- package/dist/lib/actions/update-company.js +506 -0
- package/dist/lib/actions/update-company.js.map +1 -0
- package/dist/lib/actions/update-person.d.ts +31 -0
- package/dist/lib/actions/update-person.d.ts.map +1 -0
- package/dist/lib/actions/update-person.js +524 -0
- package/dist/lib/actions/update-person.js.map +1 -0
- package/dist/lib/actions/update-product.d.ts +34 -0
- package/dist/lib/actions/update-product.d.ts.map +1 -0
- package/dist/lib/actions/update-product.js +556 -0
- package/dist/lib/actions/update-product.js.map +1 -0
- package/dist/lib/auth.d.ts +2 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +51 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/common/client.d.ts +13 -0
- package/dist/lib/common/client.d.ts.map +1 -0
- package/dist/lib/common/client.js +64 -0
- package/dist/lib/common/client.js.map +1 -0
- package/dist/lib/common/index.d.ts +5 -0
- package/dist/lib/common/index.d.ts.map +1 -0
- package/dist/lib/common/index.js +10 -0
- package/dist/lib/common/index.js.map +1 -0
- package/dist/lib/common/props.d.ts +14 -0
- package/dist/lib/common/props.d.ts.map +1 -0
- package/dist/lib/common/props.js +118 -0
- package/dist/lib/common/props.js.map +1 -0
- package/dist/lib/common/types.d.ts +89 -0
- package/dist/lib/common/types.d.ts.map +1 -0
- package/dist/lib/common/types.js +6 -0
- package/dist/lib/common/types.js.map +1 -0
- package/dist/lib/triggers/new-order.d.ts +11 -0
- package/dist/lib/triggers/new-order.d.ts.map +1 -0
- package/dist/lib/triggers/new-order.js +152 -0
- package/dist/lib/triggers/new-order.js.map +1 -0
- package/dist/lib/triggers/new-product.d.ts +3 -0
- package/dist/lib/triggers/new-product.d.ts.map +1 -0
- package/dist/lib/triggers/new-product.js +111 -0
- package/dist/lib/triggers/new-product.js.map +1 -0
- package/dist/lib/triggers/new-project.d.ts +11 -0
- package/dist/lib/triggers/new-project.d.ts.map +1 -0
- package/dist/lib/triggers/new-project.js +141 -0
- package/dist/lib/triggers/new-project.js.map +1 -0
- package/dist/lib/triggers/new-quote.d.ts +11 -0
- package/dist/lib/triggers/new-quote.d.ts.map +1 -0
- package/dist/lib/triggers/new-quote.js +153 -0
- package/dist/lib/triggers/new-quote.js.map +1 -0
- package/dist/lib/triggers/new-sales-invoice.d.ts +11 -0
- package/dist/lib/triggers/new-sales-invoice.d.ts.map +1 -0
- package/dist/lib/triggers/new-sales-invoice.js +153 -0
- package/dist/lib/triggers/new-sales-invoice.js.map +1 -0
- package/dist/lib/triggers/new-updated-company.d.ts +3 -0
- package/dist/lib/triggers/new-updated-company.d.ts.map +1 -0
- package/dist/lib/triggers/new-updated-company.js +122 -0
- package/dist/lib/triggers/new-updated-company.js.map +1 -0
- package/dist/lib/triggers/new-updated-person.d.ts +3 -0
- package/dist/lib/triggers/new-updated-person.d.ts.map +1 -0
- package/dist/lib/triggers/new-updated-person.js +122 -0
- package/dist/lib/triggers/new-updated-person.js.map +1 -0
- package/package.json +48 -0
- package/src/index.ts +89 -0
- package/src/lib/actions/create-company.ts +464 -0
- package/src/lib/actions/create-file.ts +62 -0
- package/src/lib/actions/create-manual-entry.ts +445 -0
- package/src/lib/actions/create-person.ts +481 -0
- package/src/lib/actions/create-product.ts +563 -0
- package/src/lib/actions/create-project.ts +344 -0
- package/src/lib/actions/create-sales-invoice.ts +656 -0
- package/src/lib/actions/create-sales-order.ts +689 -0
- package/src/lib/actions/create-sales-quote.ts +713 -0
- package/src/lib/actions/create-time-tracking.ts +418 -0
- package/src/lib/actions/export-invoice-pdf.ts +104 -0
- package/src/lib/actions/find-account.ts +114 -0
- package/src/lib/actions/find-company.ts +193 -0
- package/src/lib/actions/find-country.ts +127 -0
- package/src/lib/actions/find-person.ts +208 -0
- package/src/lib/actions/find-product.ts +161 -0
- package/src/lib/actions/search-invoice.ts +157 -0
- package/src/lib/actions/search-order.ts +155 -0
- package/src/lib/actions/search-quote.ts +157 -0
- package/src/lib/actions/send-sales-invoice.ts +118 -0
- package/src/lib/actions/update-company.ts +518 -0
- package/src/lib/actions/update-person.ts +536 -0
- package/src/lib/actions/update-product.ts +594 -0
- package/src/lib/auth.ts +44 -0
- package/src/lib/common/client.ts +65 -0
- package/src/lib/common/index.ts +5 -0
- package/src/lib/common/props.ts +127 -0
- package/src/lib/common/types.ts +99 -0
- package/src/lib/triggers/new-order.ts +184 -0
- package/src/lib/triggers/new-product.ts +154 -0
- package/src/lib/triggers/new-project.ts +165 -0
- package/src/lib/triggers/new-quote.ts +186 -0
- package/src/lib/triggers/new-sales-invoice.ts +186 -0
- package/src/lib/triggers/new-updated-company.ts +161 -0
- package/src/lib/triggers/new-updated-person.ts +161 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newProjectTrigger: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
3
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
4
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
5
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
6
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
7
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
9
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=new-project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-project.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-project.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,eAAe,EAAqE,MAAM,2BAA2B,CAAC;AA6D9I,eAAO,MAAM,iBAAiB;;;;;;;;EAsG5B,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newProjectTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/bexio/src/lib/triggers/new-project.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
9
|
+
const auth_1 = require("../auth");
|
|
10
|
+
const client_1 = require("../common/client");
|
|
11
|
+
const polling = {
|
|
12
|
+
strategy: pieces_common_1.DedupeStrategy.LAST_ITEM,
|
|
13
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastItemId, propsValue }) {
|
|
14
|
+
const client = new client_1.BexioClient(auth);
|
|
15
|
+
const searchBody = [
|
|
16
|
+
{
|
|
17
|
+
field: 'name',
|
|
18
|
+
value: '',
|
|
19
|
+
criteria: 'not_null',
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
if (propsValue.status_id !== undefined && propsValue.status_id !== null) {
|
|
23
|
+
searchBody.push({
|
|
24
|
+
field: 'pr_state_id',
|
|
25
|
+
value: propsValue.status_id.toString(),
|
|
26
|
+
criteria: '=',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const queryParams = {
|
|
30
|
+
order_by: 'id_desc',
|
|
31
|
+
limit: '500',
|
|
32
|
+
};
|
|
33
|
+
const projects = yield client.post('/2.0/pr_project/search', searchBody, queryParams);
|
|
34
|
+
return projects.map((project) => ({
|
|
35
|
+
id: project.id,
|
|
36
|
+
data: project,
|
|
37
|
+
}));
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
exports.newProjectTrigger = (0, pieces_framework_1.createTrigger)({
|
|
41
|
+
auth: auth_1.bexioAuth,
|
|
42
|
+
name: 'new_project',
|
|
43
|
+
displayName: 'New Project',
|
|
44
|
+
description: 'Triggers when a Project is created or updated with the chosen status',
|
|
45
|
+
aiMetadata: {
|
|
46
|
+
description: 'Fires when a project is created or updated in Bexio, optionally filtered to a chosen project status. Emits each matching project with its number, name, dates, status, type, contact, invoicing and budget settings. Use to track new or changing projects.',
|
|
47
|
+
},
|
|
48
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
49
|
+
props: {
|
|
50
|
+
status_id: pieces_framework_1.Property.Dropdown({
|
|
51
|
+
auth: auth_1.bexioAuth,
|
|
52
|
+
displayName: 'Status',
|
|
53
|
+
description: 'Filter projects by status (leave empty to trigger for all statuses)',
|
|
54
|
+
required: false,
|
|
55
|
+
refreshers: [],
|
|
56
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
57
|
+
if (!auth) {
|
|
58
|
+
return {
|
|
59
|
+
disabled: true,
|
|
60
|
+
placeholder: 'Connect your Bexio account first',
|
|
61
|
+
options: [],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const client = new client_1.BexioClient(auth);
|
|
66
|
+
const statuses = yield client.get('/2.0/pr_project_state').catch(() => []);
|
|
67
|
+
if (statuses.length === 0) {
|
|
68
|
+
return {
|
|
69
|
+
disabled: false,
|
|
70
|
+
placeholder: 'Status filter not available - will trigger for all statuses',
|
|
71
|
+
options: [],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
disabled: false,
|
|
76
|
+
options: statuses.map((status) => ({
|
|
77
|
+
label: status.name,
|
|
78
|
+
value: status.id,
|
|
79
|
+
})),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
return {
|
|
84
|
+
disabled: false,
|
|
85
|
+
placeholder: 'Enter status ID manually or leave empty for all statuses',
|
|
86
|
+
options: [],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
sampleData: {
|
|
93
|
+
id: 2,
|
|
94
|
+
uuid: '046b6c7f-0b8a-43b9-b35d-6489e6daee91',
|
|
95
|
+
nr: '000002',
|
|
96
|
+
name: 'Villa Kunterbunt',
|
|
97
|
+
start_date: '2019-07-12 00:00:00',
|
|
98
|
+
end_date: null,
|
|
99
|
+
comment: '',
|
|
100
|
+
pr_state_id: 2,
|
|
101
|
+
pr_project_type_id: 2,
|
|
102
|
+
contact_id: 2,
|
|
103
|
+
contact_sub_id: null,
|
|
104
|
+
pr_invoice_type_id: 3,
|
|
105
|
+
pr_invoice_type_amount: '230.00',
|
|
106
|
+
pr_budget_type_id: 1,
|
|
107
|
+
pr_budget_type_amount: '200.00',
|
|
108
|
+
user_id: 1,
|
|
109
|
+
},
|
|
110
|
+
onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
111
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
112
|
+
auth: context.auth,
|
|
113
|
+
store: context.store,
|
|
114
|
+
propsValue: context.propsValue,
|
|
115
|
+
});
|
|
116
|
+
}),
|
|
117
|
+
onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
119
|
+
auth: context.auth,
|
|
120
|
+
store: context.store,
|
|
121
|
+
propsValue: context.propsValue,
|
|
122
|
+
});
|
|
123
|
+
}),
|
|
124
|
+
test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
+
return yield pieces_common_1.pollingHelper.test(polling, {
|
|
126
|
+
auth: context.auth,
|
|
127
|
+
store: context.store,
|
|
128
|
+
propsValue: context.propsValue,
|
|
129
|
+
files: context.files,
|
|
130
|
+
});
|
|
131
|
+
}),
|
|
132
|
+
run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
134
|
+
auth: context.auth,
|
|
135
|
+
store: context.store,
|
|
136
|
+
propsValue: context.propsValue,
|
|
137
|
+
files: context.files,
|
|
138
|
+
});
|
|
139
|
+
}),
|
|
140
|
+
});
|
|
141
|
+
//# sourceMappingURL=new-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-project.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-project.ts"],"names":[],"mappings":";;;;AAAA,oGAAoG;AACpG,qEAAqE;AACrE,gEAA8I;AAC9I,0DAAgF;AAChF,kCAAoC;AACpC,6CAA+C;AAG/C,MAAM,O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AAE,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,11 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newQuoteTrigger: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
3
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
4
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
5
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
6
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
7
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
9
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=new-quote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-quote.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-quote.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,eAAe,EAA+C,MAAM,2BAA2B,CAAC;AA4ExH,eAAO,MAAM,eAAe;;;;;;;;EA4G1B,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newQuoteTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/bexio/src/lib/triggers/new-quote.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
9
|
+
const auth_1 = require("../auth");
|
|
10
|
+
const client_1 = require("../common/client");
|
|
11
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
12
|
+
const polling = {
|
|
13
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
14
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastFetchEpochMS, propsValue }) {
|
|
15
|
+
const client = new client_1.BexioClient(auth);
|
|
16
|
+
const isTest = lastFetchEpochMS === 0;
|
|
17
|
+
const lastFetchDate = isTest
|
|
18
|
+
? (0, dayjs_1.default)().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss')
|
|
19
|
+
: (0, dayjs_1.default)(lastFetchEpochMS).format('YYYY-MM-DD HH:mm:ss');
|
|
20
|
+
const searchBody = [
|
|
21
|
+
{
|
|
22
|
+
field: 'updated_at',
|
|
23
|
+
value: lastFetchDate,
|
|
24
|
+
criteria: '>=',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
if (propsValue.status_id !== undefined && propsValue.status_id !== null) {
|
|
28
|
+
searchBody.push({
|
|
29
|
+
field: 'kb_item_status_id',
|
|
30
|
+
value: propsValue.status_id.toString(),
|
|
31
|
+
criteria: '=',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const queryParams = {
|
|
35
|
+
order_by: 'updated_at_desc',
|
|
36
|
+
limit: isTest ? '5' : '500',
|
|
37
|
+
};
|
|
38
|
+
const quotes = yield client.post('/2.0/kb_offer/search', searchBody, queryParams);
|
|
39
|
+
return quotes.map((quote) => {
|
|
40
|
+
const updatedAt = quote.updated_at || new Date().toISOString();
|
|
41
|
+
const epochMilliSeconds = (0, dayjs_1.default)(updatedAt).valueOf();
|
|
42
|
+
return {
|
|
43
|
+
epochMilliSeconds,
|
|
44
|
+
data: quote,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
exports.newQuoteTrigger = (0, pieces_framework_1.createTrigger)({
|
|
50
|
+
auth: auth_1.bexioAuth,
|
|
51
|
+
name: 'new_quote',
|
|
52
|
+
displayName: 'New Quotes',
|
|
53
|
+
description: 'Triggers when a quote is created or updated with the chosen status',
|
|
54
|
+
aiMetadata: {
|
|
55
|
+
description: 'Fires when a quote (offer) is created or its updated timestamp changes in Bexio, optionally filtered to a chosen quote status. Emits each matching quote with its document number, contact, totals (gross, net, taxes), validity dates, and status. Use to react to new or modified quotes.',
|
|
56
|
+
},
|
|
57
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
58
|
+
props: {
|
|
59
|
+
status_id: pieces_framework_1.Property.Dropdown({
|
|
60
|
+
auth: auth_1.bexioAuth,
|
|
61
|
+
displayName: 'Status',
|
|
62
|
+
description: 'Filter quotes by status (leave empty to trigger for all statuses)',
|
|
63
|
+
required: false,
|
|
64
|
+
refreshers: [],
|
|
65
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
66
|
+
if (!auth) {
|
|
67
|
+
return {
|
|
68
|
+
disabled: true,
|
|
69
|
+
placeholder: 'Connect your Bexio account first',
|
|
70
|
+
options: [],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const client = new client_1.BexioClient(auth);
|
|
75
|
+
const statuses = yield client.get('/2.0/kb_offer_status').catch(() => []);
|
|
76
|
+
if (statuses.length === 0) {
|
|
77
|
+
return {
|
|
78
|
+
disabled: false,
|
|
79
|
+
placeholder: 'Status filter not available - will trigger for all statuses',
|
|
80
|
+
options: [],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
disabled: false,
|
|
85
|
+
options: statuses.map((status) => ({
|
|
86
|
+
label: status.name,
|
|
87
|
+
value: status.id,
|
|
88
|
+
})),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
return {
|
|
93
|
+
disabled: false,
|
|
94
|
+
placeholder: 'Enter status ID manually or leave empty for all statuses',
|
|
95
|
+
options: [],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}),
|
|
99
|
+
}),
|
|
100
|
+
},
|
|
101
|
+
sampleData: {
|
|
102
|
+
id: 4,
|
|
103
|
+
document_nr: 'AN-00001',
|
|
104
|
+
title: null,
|
|
105
|
+
contact_id: 14,
|
|
106
|
+
contact_sub_id: null,
|
|
107
|
+
user_id: 1,
|
|
108
|
+
project_id: null,
|
|
109
|
+
language_id: 1,
|
|
110
|
+
bank_account_id: 1,
|
|
111
|
+
currency_id: 1,
|
|
112
|
+
payment_type_id: 1,
|
|
113
|
+
total_gross: '17.800000',
|
|
114
|
+
total_net: '17.800000',
|
|
115
|
+
total_taxes: '1.3706',
|
|
116
|
+
total: '19.150000',
|
|
117
|
+
kb_item_status_id: 3,
|
|
118
|
+
is_valid_from: '2019-06-24',
|
|
119
|
+
is_valid_until: '2019-07-24',
|
|
120
|
+
updated_at: '2019-04-08 13:17:32',
|
|
121
|
+
},
|
|
122
|
+
onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
124
|
+
auth: context.auth,
|
|
125
|
+
store: context.store,
|
|
126
|
+
propsValue: context.propsValue,
|
|
127
|
+
});
|
|
128
|
+
}),
|
|
129
|
+
onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
131
|
+
auth: context.auth,
|
|
132
|
+
store: context.store,
|
|
133
|
+
propsValue: context.propsValue,
|
|
134
|
+
});
|
|
135
|
+
}),
|
|
136
|
+
test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
+
return yield pieces_common_1.pollingHelper.test(polling, {
|
|
138
|
+
auth: context.auth,
|
|
139
|
+
store: context.store,
|
|
140
|
+
propsValue: context.propsValue,
|
|
141
|
+
files: context.files,
|
|
142
|
+
});
|
|
143
|
+
}),
|
|
144
|
+
run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
145
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
146
|
+
auth: context.auth,
|
|
147
|
+
store: context.store,
|
|
148
|
+
propsValue: context.propsValue,
|
|
149
|
+
files: context.files,
|
|
150
|
+
});
|
|
151
|
+
}),
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=new-quote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-quote.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-quote.ts"],"names":[],"mappings":";;;;AAAA,kGAAkG;AAClG,qEAAqE;AACrE,gEAAwH;AACxH,0DAAgF;AAChF,kCAAoC;AACpC,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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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,11 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newSalesInvoiceTrigger: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
3
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
4
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
5
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
6
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
7
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
8
|
+
}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {
|
|
9
|
+
status_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=new-sales-invoice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-sales-invoice.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-sales-invoice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,eAAe,EAAqE,MAAM,2BAA2B,CAAC;AA4E9I,eAAO,MAAM,sBAAsB;;;;;;;;EA4GjC,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newSalesInvoiceTrigger = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// Vendored from Activepieces packages/pieces/community/bexio/src/lib/triggers/new-sales-invoice.ts (MIT).
|
|
6
|
+
// Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
|
|
7
|
+
const pieces_framework_1 = require("@agnocon/pieces-framework");
|
|
8
|
+
const pieces_common_1 = require("@agnocon/pieces-common");
|
|
9
|
+
const auth_1 = require("../auth");
|
|
10
|
+
const client_1 = require("../common/client");
|
|
11
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
12
|
+
const polling = {
|
|
13
|
+
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
14
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, lastFetchEpochMS, propsValue }) {
|
|
15
|
+
const client = new client_1.BexioClient(auth);
|
|
16
|
+
const isTest = lastFetchEpochMS === 0;
|
|
17
|
+
const lastFetchDate = isTest
|
|
18
|
+
? (0, dayjs_1.default)().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss')
|
|
19
|
+
: (0, dayjs_1.default)(lastFetchEpochMS).format('YYYY-MM-DD HH:mm:ss');
|
|
20
|
+
const searchBody = [
|
|
21
|
+
{
|
|
22
|
+
field: 'updated_at',
|
|
23
|
+
value: lastFetchDate,
|
|
24
|
+
criteria: '>=',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
if (propsValue.status_id !== undefined && propsValue.status_id !== null) {
|
|
28
|
+
searchBody.push({
|
|
29
|
+
field: 'kb_item_status_id',
|
|
30
|
+
value: propsValue.status_id.toString(),
|
|
31
|
+
criteria: '=',
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const queryParams = {
|
|
35
|
+
order_by: 'updated_at_desc',
|
|
36
|
+
limit: isTest ? '5' : '500',
|
|
37
|
+
};
|
|
38
|
+
const invoices = yield client.post('/2.0/kb_invoice/search', searchBody, queryParams);
|
|
39
|
+
return invoices.map((invoice) => {
|
|
40
|
+
const updatedAt = invoice.updated_at || new Date().toISOString();
|
|
41
|
+
const epochMilliSeconds = (0, dayjs_1.default)(updatedAt).valueOf();
|
|
42
|
+
return {
|
|
43
|
+
epochMilliSeconds,
|
|
44
|
+
data: invoice,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
exports.newSalesInvoiceTrigger = (0, pieces_framework_1.createTrigger)({
|
|
50
|
+
auth: auth_1.bexioAuth,
|
|
51
|
+
name: 'new_sales_invoice',
|
|
52
|
+
displayName: 'New Sales-Invoice',
|
|
53
|
+
description: 'Triggers when a Sales-Invoice is created or updated with the chosen status',
|
|
54
|
+
aiMetadata: {
|
|
55
|
+
description: 'Fires when a sales invoice is created or its updated timestamp changes in Bexio, optionally filtered to a chosen invoice status. Emits each matching invoice with its document number, contact, totals (gross, net, taxes), validity dates, and status. Use to react to new or modified customer invoices.',
|
|
56
|
+
},
|
|
57
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
58
|
+
props: {
|
|
59
|
+
status_id: pieces_framework_1.Property.Dropdown({
|
|
60
|
+
auth: auth_1.bexioAuth,
|
|
61
|
+
displayName: 'Status',
|
|
62
|
+
description: 'Filter invoices by status (leave empty to trigger for all statuses)',
|
|
63
|
+
required: false,
|
|
64
|
+
refreshers: [],
|
|
65
|
+
options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
66
|
+
if (!auth) {
|
|
67
|
+
return {
|
|
68
|
+
disabled: true,
|
|
69
|
+
placeholder: 'Connect your Bexio account first',
|
|
70
|
+
options: [],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const client = new client_1.BexioClient(auth);
|
|
75
|
+
const statuses = yield client.get('/2.0/kb_invoice_status').catch(() => []);
|
|
76
|
+
if (statuses.length === 0) {
|
|
77
|
+
return {
|
|
78
|
+
disabled: false,
|
|
79
|
+
placeholder: 'Status filter not available - will trigger for all statuses',
|
|
80
|
+
options: [],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
disabled: false,
|
|
85
|
+
options: statuses.map((status) => ({
|
|
86
|
+
label: status.name,
|
|
87
|
+
value: status.id,
|
|
88
|
+
})),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
return {
|
|
93
|
+
disabled: false,
|
|
94
|
+
placeholder: 'Enter status ID manually or leave empty for all statuses',
|
|
95
|
+
options: [],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}),
|
|
99
|
+
}),
|
|
100
|
+
},
|
|
101
|
+
sampleData: {
|
|
102
|
+
id: 4,
|
|
103
|
+
document_nr: 'RE-00001',
|
|
104
|
+
title: null,
|
|
105
|
+
contact_id: 14,
|
|
106
|
+
contact_sub_id: null,
|
|
107
|
+
user_id: 1,
|
|
108
|
+
project_id: null,
|
|
109
|
+
language_id: 1,
|
|
110
|
+
bank_account_id: 1,
|
|
111
|
+
currency_id: 1,
|
|
112
|
+
payment_type_id: 1,
|
|
113
|
+
total_gross: '17.800000',
|
|
114
|
+
total_net: '17.800000',
|
|
115
|
+
total_taxes: '1.3706',
|
|
116
|
+
total: '19.150000',
|
|
117
|
+
kb_item_status_id: 3,
|
|
118
|
+
is_valid_from: '2019-06-24',
|
|
119
|
+
is_valid_to: '2019-07-24',
|
|
120
|
+
updated_at: '2019-04-08 13:17:32',
|
|
121
|
+
},
|
|
122
|
+
onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
124
|
+
auth: context.auth,
|
|
125
|
+
store: context.store,
|
|
126
|
+
propsValue: context.propsValue,
|
|
127
|
+
});
|
|
128
|
+
}),
|
|
129
|
+
onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
131
|
+
auth: context.auth,
|
|
132
|
+
store: context.store,
|
|
133
|
+
propsValue: context.propsValue,
|
|
134
|
+
});
|
|
135
|
+
}),
|
|
136
|
+
test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
+
return yield pieces_common_1.pollingHelper.test(polling, {
|
|
138
|
+
auth: context.auth,
|
|
139
|
+
store: context.store,
|
|
140
|
+
propsValue: context.propsValue,
|
|
141
|
+
files: context.files,
|
|
142
|
+
});
|
|
143
|
+
}),
|
|
144
|
+
run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
145
|
+
return yield pieces_common_1.pollingHelper.poll(polling, {
|
|
146
|
+
auth: context.auth,
|
|
147
|
+
store: context.store,
|
|
148
|
+
propsValue: context.propsValue,
|
|
149
|
+
files: context.files,
|
|
150
|
+
});
|
|
151
|
+
}),
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=new-sales-invoice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-sales-invoice.js","sourceRoot":"","sources":["../../../src/lib/triggers/new-sales-invoice.ts"],"names":[],"mappings":";;;;AAAA,0GAA0G;AAC1G,qEAAqE;AACrE,gEAA8I;AAC9I,0DAAgF;AAChF,kCAAoC;AACpC,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,CAAC;QACL,CAAC;QAED,MAAM,WAAW,GAA2B;YAC1C,QAAQ,E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IACD,QAAQ,EAAE,CAAO,OAAO,EAAE,EAAE;QAC1B,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,3 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@agnocon/pieces-framework';
|
|
2
|
+
export declare const newUpdatedCompanyTrigger: import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {}> | import("@agnocon/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@agnocon/pieces-framework").OAuth2Property<import("@agnocon/pieces-framework").OAuth2Props>, {}>;
|
|
3
|
+
//# sourceMappingURL=new-updated-company.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-updated-company.d.ts","sourceRoot":"","sources":["../../../src/lib/triggers/new-updated-company.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,eAAe,EAA2D,MAAM,2BAA2B,CAAC;AAqFpI,eAAO,MAAM,wBAAwB,ssBA0EnC,CAAC"}
|