@agnocon/piece-bokio 0.0.8

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 (72) hide show
  1. package/LICENSE.MIT-AP +24 -0
  2. package/dist/index.d.ts +5 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +54 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/actions/add-line-item-to-invoice.d.ts +15 -0
  7. package/dist/lib/actions/add-line-item-to-invoice.d.ts.map +1 -0
  8. package/dist/lib/actions/add-line-item-to-invoice.js +67 -0
  9. package/dist/lib/actions/add-line-item-to-invoice.js.map +1 -0
  10. package/dist/lib/actions/create-a-journal-entry.d.ts +9 -0
  11. package/dist/lib/actions/create-a-journal-entry.d.ts.map +1 -0
  12. package/dist/lib/actions/create-a-journal-entry.js +70 -0
  13. package/dist/lib/actions/create-a-journal-entry.js.map +1 -0
  14. package/dist/lib/actions/create-an-item.d.ts +11 -0
  15. package/dist/lib/actions/create-an-item.d.ts.map +1 -0
  16. package/dist/lib/actions/create-an-item.js +60 -0
  17. package/dist/lib/actions/create-an-item.js.map +1 -0
  18. package/dist/lib/actions/create-customer.d.ts +19 -0
  19. package/dist/lib/actions/create-customer.d.ts.map +1 -0
  20. package/dist/lib/actions/create-customer.js +145 -0
  21. package/dist/lib/actions/create-customer.js.map +1 -0
  22. package/dist/lib/actions/create-invoice.d.ts +18 -0
  23. package/dist/lib/actions/create-invoice.d.ts.map +1 -0
  24. package/dist/lib/actions/create-invoice.js +125 -0
  25. package/dist/lib/actions/create-invoice.js.map +1 -0
  26. package/dist/lib/actions/find-customer.d.ts +10 -0
  27. package/dist/lib/actions/find-customer.d.ts.map +1 -0
  28. package/dist/lib/actions/find-customer.js +78 -0
  29. package/dist/lib/actions/find-customer.js.map +1 -0
  30. package/dist/lib/actions/get-a-journal-entry.d.ts +7 -0
  31. package/dist/lib/actions/get-a-journal-entry.d.ts.map +1 -0
  32. package/dist/lib/actions/get-a-journal-entry.js +34 -0
  33. package/dist/lib/actions/get-a-journal-entry.js.map +1 -0
  34. package/dist/lib/actions/get-an-invoice.d.ts +7 -0
  35. package/dist/lib/actions/get-an-invoice.d.ts.map +1 -0
  36. package/dist/lib/actions/get-an-invoice.js +34 -0
  37. package/dist/lib/actions/get-an-invoice.js.map +1 -0
  38. package/dist/lib/actions/get-draft-invoice-by-customer-name.d.ts +9 -0
  39. package/dist/lib/actions/get-draft-invoice-by-customer-name.d.ts.map +1 -0
  40. package/dist/lib/actions/get-draft-invoice-by-customer-name.js +75 -0
  41. package/dist/lib/actions/get-draft-invoice-by-customer-name.js.map +1 -0
  42. package/dist/lib/actions/update-an-invoice.d.ts +18 -0
  43. package/dist/lib/actions/update-an-invoice.d.ts.map +1 -0
  44. package/dist/lib/actions/update-an-invoice.js +109 -0
  45. package/dist/lib/actions/update-an-invoice.js.map +1 -0
  46. package/dist/lib/common/auth.d.ts +5 -0
  47. package/dist/lib/common/auth.d.ts.map +1 -0
  48. package/dist/lib/common/auth.js +47 -0
  49. package/dist/lib/common/auth.js.map +1 -0
  50. package/dist/lib/common/client.d.ts +4 -0
  51. package/dist/lib/common/client.d.ts.map +1 -0
  52. package/dist/lib/common/client.js +29 -0
  53. package/dist/lib/common/client.js.map +1 -0
  54. package/dist/lib/common/props.d.ts +10 -0
  55. package/dist/lib/common/props.d.ts.map +1 -0
  56. package/dist/lib/common/props.js +128 -0
  57. package/dist/lib/common/props.js.map +1 -0
  58. package/package.json +47 -0
  59. package/src/index.ts +49 -0
  60. package/src/lib/actions/add-line-item-to-invoice.ts +74 -0
  61. package/src/lib/actions/create-a-journal-entry.ts +72 -0
  62. package/src/lib/actions/create-an-item.ts +68 -0
  63. package/src/lib/actions/create-customer.ts +163 -0
  64. package/src/lib/actions/create-invoice.ts +145 -0
  65. package/src/lib/actions/find-customer.ts +75 -0
  66. package/src/lib/actions/get-a-journal-entry.ts +32 -0
  67. package/src/lib/actions/get-an-invoice.ts +32 -0
  68. package/src/lib/actions/get-draft-invoice-by-customer-name.ts +78 -0
  69. package/src/lib/actions/update-an-invoice.ts +127 -0
  70. package/src/lib/common/auth.ts +44 -0
  71. package/src/lib/common/client.ts +25 -0
  72. package/src/lib/common/props.ts +136 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/common/auth.ts"],"names":[],"mappings":";;;;AAAA,2FAA2F;AAC3F,qEAAqE;AACrE,gEAAgE;AAChE,qCAAuC;AACvC,0DAAgE;AAEnD,QAAA,SAAS,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC5C,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,6DAA6D;IAC1E,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACL,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,8BAA8B;YAC3C,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,0BAA0B;YACvC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,QAAQ,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACvB,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC;gBACH,MAAM,IAAA,oBAAW,EACf,IAAI,CAAC,OAAO,EACZ,0BAAU,CAAC,GAAG,EACd,cAAc,IAAI,CAAC,SAAS,kBAAkB,CAC/C,CAAC;gBACF,OAAO;oBACL,KAAK,EAAE,IAAI;iBACZ,CAAC;YACJ,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO;oBACL,KAAK,EAAE,KAAK;oBACZ,KAAK,EAAE,iBAAiB;iBACzB,CAAC;YACJ,CAAC;QACH,CAAC;QACD,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,iBAAiB;SACzB,CAAC;IACJ,CAAC,CAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { HttpMethod } from '@agnocon/pieces-common';
2
+ export declare const BASE_URL = "https://api.bokio.se/v1";
3
+ export declare function makeRequest(api_key: string, method: HttpMethod, path: string, body?: unknown): Promise<any>;
4
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/lib/common/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAc,MAAM,wBAAwB,CAAC;AAEhE,eAAO,MAAM,QAAQ,4BAA4B,CAAC;AAElD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,gBAgBf"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BASE_URL = void 0;
4
+ exports.makeRequest = makeRequest;
5
+ const tslib_1 = require("tslib");
6
+ // Vendored from Activepieces packages/pieces/community/bokio/src/lib/common/client.ts (MIT).
7
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
8
+ const pieces_common_1 = require("@agnocon/pieces-common");
9
+ exports.BASE_URL = `https://api.bokio.se/v1`;
10
+ function makeRequest(api_key, method, path, body) {
11
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ try {
13
+ const response = yield pieces_common_1.httpClient.sendRequest({
14
+ method,
15
+ url: `${exports.BASE_URL}${path}`,
16
+ headers: {
17
+ Authorization: `Bearer ${api_key}`,
18
+ 'Content-Type': 'application/json',
19
+ },
20
+ body,
21
+ });
22
+ return response.body;
23
+ }
24
+ catch (error) {
25
+ throw new Error(`Unexpected error: ${error.message || String(error)}`);
26
+ }
27
+ });
28
+ }
29
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/lib/common/client.ts"],"names":[],"mappings":";;;AAMA,kCAoBC;;AA1BD,6FAA6F;AAC7F,qEAAqE;AACrE,0DAAgE;AAEnD,QAAA,QAAQ,GAAG,yBAAyB,CAAC;AAElD,SAAsB,WAAW,CAC/B,OAAe,EACf,MAAkB,EAClB,IAAY,EACZ,IAAc;;QAEd,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC5C,MAAM;gBACN,GAAG,EAAE,GAAG,gBAAQ,GAAG,IAAI,EAAE;gBACzB,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,OAAO,EAAE;oBAClC,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI;aACL,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;CAAA"}
@@ -0,0 +1,10 @@
1
+ export declare const invoiceIdDropdown: import("@agnocon/pieces-framework").DropdownProperty<unknown, true, import("@agnocon/pieces-framework").CustomAuthProperty<{
2
+ companyId: import("@agnocon/pieces-framework").ShortTextProperty<true>;
3
+ api_key: import("@agnocon/pieces-framework").ShortTextProperty<true>;
4
+ }>>;
5
+ export declare const unitTypeDropdown: import("@agnocon/pieces-framework").StaticDropdownProperty<string, false>;
6
+ export declare const lineItemsProps: import("@agnocon/pieces-framework").DynamicProperties<false, import("@agnocon/pieces-framework").CustomAuthProperty<{
7
+ companyId: import("@agnocon/pieces-framework").ShortTextProperty<true>;
8
+ api_key: import("@agnocon/pieces-framework").ShortTextProperty<true>;
9
+ }>>;
10
+ //# sourceMappingURL=props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../../src/lib/common/props.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB;;;GAoC5B,CAAC;AAEH,eAAO,MAAM,gBAAgB,2EA+B3B,CAAC;AAEH,eAAO,MAAM,cAAc;;;GA2DzB,CAAC"}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lineItemsProps = exports.unitTypeDropdown = exports.invoiceIdDropdown = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/bokio/src/lib/common/props.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 client_1 = require("./client");
9
+ const auth_1 = require("./auth");
10
+ const pieces_common_1 = require("@agnocon/pieces-common");
11
+ exports.invoiceIdDropdown = pieces_framework_1.Property.Dropdown({
12
+ auth: auth_1.bokioAuth,
13
+ displayName: 'Invoice',
14
+ description: 'Select the invoice',
15
+ required: true,
16
+ refreshers: [],
17
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
18
+ if (!auth) {
19
+ return {
20
+ disabled: true,
21
+ options: [],
22
+ };
23
+ }
24
+ try {
25
+ const response = yield (0, client_1.makeRequest)(auth.props.api_key, pieces_common_1.HttpMethod.GET, `/companies/${auth.props.companyId}/invoices?limit=100`);
26
+ const options = response.items.map((invoice) => ({
27
+ label: `#${invoice.invoiceNumber} - ${invoice.customerRef.customerName}`,
28
+ value: invoice.id,
29
+ }));
30
+ return {
31
+ disabled: false,
32
+ options,
33
+ };
34
+ }
35
+ catch (error) {
36
+ return {
37
+ disabled: true,
38
+ options: [],
39
+ };
40
+ }
41
+ }),
42
+ });
43
+ exports.unitTypeDropdown = pieces_framework_1.Property.StaticDropdown({
44
+ displayName: 'Unit Type',
45
+ description: 'Unit type for the item',
46
+ required: false,
47
+ options: {
48
+ options: [
49
+ { label: 'Unspecified', value: 'unspecified' },
50
+ { label: 'Piece', value: 'piece' },
51
+ { label: 'Hour', value: 'hour' },
52
+ { label: 'Day', value: 'day' },
53
+ { label: 'Month', value: 'month' },
54
+ { label: 'Kilogram', value: 'kilogram' },
55
+ { label: 'Gram', value: 'gram' },
56
+ { label: 'Liter', value: 'liter' },
57
+ { label: 'Meter', value: 'meter' },
58
+ { label: 'Centimeter', value: 'centimeter' },
59
+ { label: 'Millimeter', value: 'millimeter' },
60
+ { label: 'Meter Squared', value: 'meterSquared' },
61
+ { label: 'Meter Cubic', value: 'meterCubic' },
62
+ { label: 'Mile', value: 'mile' },
63
+ { label: 'Kilometer', value: 'kilometer' },
64
+ { label: 'Gigabyte', value: 'gigabyte' },
65
+ { label: 'Hectar', value: 'hectar' },
66
+ { label: 'Words', value: 'words' },
67
+ { label: 'Year', value: 'year' },
68
+ { label: 'Week', value: 'week' },
69
+ { label: 'Minute', value: 'minute' },
70
+ { label: 'Megabyte', value: 'megabyte' },
71
+ { label: 'Ton', value: 'ton' },
72
+ ],
73
+ },
74
+ });
75
+ exports.lineItemsProps = pieces_framework_1.Property.DynamicProperties({
76
+ auth: auth_1.bokioAuth,
77
+ displayName: 'Item Details',
78
+ description: 'Configure item details based on item type',
79
+ required: false,
80
+ refreshers: ['itemType'],
81
+ props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ itemType }) {
82
+ const properties = {
83
+ description: pieces_framework_1.Property.ShortText({
84
+ displayName: 'Description',
85
+ description: 'Description of the line item',
86
+ required: true,
87
+ }),
88
+ };
89
+ // Only show pricing fields for sales items
90
+ if (itemType === 'salesItem') {
91
+ properties['itemRefId'] = pieces_framework_1.Property.ShortText({
92
+ displayName: 'Item Reference ID',
93
+ description: 'UUID of the item reference',
94
+ required: false,
95
+ });
96
+ properties['productType'] = pieces_framework_1.Property.StaticDropdown({
97
+ displayName: 'Product Type',
98
+ description: 'Type of product',
99
+ required: true,
100
+ options: {
101
+ options: [
102
+ { label: 'Goods', value: 'goods' },
103
+ { label: 'Service', value: 'service' },
104
+ ],
105
+ },
106
+ });
107
+ properties['unitType'] = exports.unitTypeDropdown;
108
+ properties['quantity'] = pieces_framework_1.Property.Number({
109
+ displayName: 'Quantity',
110
+ description: 'Quantity of the item',
111
+ required: true,
112
+ defaultValue: 1,
113
+ });
114
+ properties['unitPrice'] = pieces_framework_1.Property.Number({
115
+ displayName: 'Unit Price',
116
+ description: 'Price per unit',
117
+ required: true,
118
+ });
119
+ properties['taxRate'] = pieces_framework_1.Property.Number({
120
+ displayName: 'Tax Rate',
121
+ description: 'Tax rate in percentage (e.g., 25 for 25%)',
122
+ required: false,
123
+ });
124
+ }
125
+ return properties;
126
+ }),
127
+ });
128
+ //# sourceMappingURL=props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/lib/common/props.ts"],"names":[],"mappings":";;;;AAAA,4FAA4F;AAC5F,qEAAqE;AACrE,gEAAqD;AACrD,qCAAuC;AACvC,iCAAmC;AACnC,0DAAoD;AAEvC,QAAA,iBAAiB,GAAG,2BAAQ,CAAC,QAAQ,CAAC;IACjD,IAAI,EAAE,gBAAS;IACf,WAAW,EAAE,SAAS;IACtB,WAAW,EAAE,oBAAoB;IACjC,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE;QACtB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;gBACL,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;aACZ,CAAC;QACJ,CAAC;QACD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAW,EAChC,IAAI,CAAC,KAAK,CAAC,OAAO,EAClB,0BAAU,CAAC,GAAG,EACd,cAAc,IAAI,CAAC,KAAK,CAAC,SAAS,qBAAqB,CACxD,CAAC;YAEF,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,C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"types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "require": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "src",
17
+ "LICENSE.MIT-AP"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json",
21
+ "vendor": "node ../scripts/vendor-ap.mjs piece-bokio"
22
+ },
23
+ "dependencies": {
24
+ "@agnocon/core-utils": "0.2.0",
25
+ "@agnocon/piece-types": "0.3.1",
26
+ "@agnocon/pieces-common": "0.12.8",
27
+ "@agnocon/pieces-framework": "0.36.0",
28
+ "tslib": "2.6.2",
29
+ "i18next": "23.13.0"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "20.17.6",
33
+ "typescript": "5.5.4"
34
+ },
35
+ "license": "MIT",
36
+ "agnocon": {
37
+ "originVersion": "0.0.8"
38
+ },
39
+ "publishConfig": {
40
+ "access": "restricted",
41
+ "tag": "latest"
42
+ },
43
+ "keywords": [
44
+ "agnocon",
45
+ "connector"
46
+ ]
47
+ }
package/src/index.ts ADDED
@@ -0,0 +1,49 @@
1
+ import { createPiece, PieceAuth } from '@agnocon/pieces-framework';
2
+ import { bokioAuth } from './lib/common/auth';
3
+ import { createCustomer } from './lib/actions/create-customer';
4
+ import { createInvoice } from './lib/actions/create-invoice';
5
+ import { addLineItemToInvoice } from './lib/actions/add-line-item-to-invoice';
6
+ import { createAnItem } from './lib/actions/create-an-item';
7
+ import { createAJournalEntry } from './lib/actions/create-a-journal-entry';
8
+ import { updateAnInvoice } from './lib/actions/update-an-invoice';
9
+ import { findCustomer } from './lib/actions/find-customer';
10
+ import { getDraftInvoiceByCustomerName } from './lib/actions/get-draft-invoice-by-customer-name';
11
+ import { getAnInvoice } from './lib/actions/get-an-invoice';
12
+ import { getAJournalEntry } from './lib/actions/get-a-journal-entry';
13
+ import { createCustomApiCallAction } from '@agnocon/pieces-common';
14
+ import { PieceCategory } from '@agnocon/pieces-framework';
15
+
16
+ export const bokio = createPiece({
17
+ displayName: 'Bokio',
18
+ auth: bokioAuth,
19
+ minimumSupportedRelease: '0.36.1',
20
+ logoUrl: 'https://cdn.activepieces.com/pieces/bokio.png',
21
+ authors: ['sanket-a11y'],
22
+ categories: [PieceCategory.ACCOUNTING],
23
+ description:
24
+ 'Bokio is an accounting software platform which offers digital bookkeeping, invoicing, and financial management tools to help simplify accounting processes.',
25
+ actions: [
26
+ createCustomer,
27
+ createInvoice,
28
+ addLineItemToInvoice,
29
+ createAnItem,
30
+ createAJournalEntry,
31
+ updateAnInvoice,
32
+ findCustomer,
33
+ getDraftInvoiceByCustomerName,
34
+ getAnInvoice,
35
+ getAJournalEntry,
36
+ createCustomApiCallAction({
37
+ auth: bokioAuth,
38
+ baseUrl: (auth) => {
39
+ return `https://api.bokio.se/v1/companies/${auth?.props.companyId}`;
40
+ },
41
+ authMapping: async (auth) => {
42
+ return {
43
+ Authorization: `Bearer ${auth?.props.api_key}`,
44
+ };
45
+ },
46
+ }),
47
+ ],
48
+ triggers: [],
49
+ });
@@ -0,0 +1,74 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bokioAuth } from '../common/auth';
3
+ import { makeRequest } from '../common/client';
4
+ import { HttpMethod } from '@agnocon/pieces-common';
5
+ import { invoiceIdDropdown, lineItemsProps, unitTypeDropdown } from '../common/props';
6
+
7
+ export const addLineItemToInvoice = createAction({
8
+ auth: bokioAuth,
9
+ name: 'addLineItemToInvoice',
10
+ displayName: 'Add line item to invoice',
11
+ description: 'Adds a line item to an existing draft invoice',
12
+ audience: 'both',
13
+ aiMetadata: { description: 'Appends a single line item to an existing draft invoice in Bokio, identified by invoice ID. Use to add a product, service, or description-only row to an invoice that already exists; pricing fields apply only when item type is a sales item. Not idempotent — each call appends another line item.', idempotent: false },
14
+ props: {
15
+ invoiceId: invoiceIdDropdown,
16
+ itemType: Property.StaticDropdown({
17
+ displayName: 'Item Type',
18
+ description: 'Type of the item',
19
+ required: true,
20
+ options: {
21
+ options: [
22
+ { label: 'Sales Item', value: 'salesItem' },
23
+ { label: 'Description Only Item', value: 'descriptionOnlyItem' },
24
+ ],
25
+ },
26
+ }),
27
+ dynamicProps: lineItemsProps,
28
+ },
29
+ async run(context) {
30
+ const { invoiceId, itemType, dynamicProps } = context.propsValue;
31
+ const { api_key, companyId } = context.auth.props;
32
+
33
+ const body: any = {
34
+ itemType,
35
+ description: dynamicProps?.['description'],
36
+ };
37
+
38
+ // Only add pricing fields for sales items
39
+ if (itemType === 'salesItem' && dynamicProps) {
40
+ body.quantity = dynamicProps['quantity'];
41
+ body.unitPrice = dynamicProps['unitPrice'];
42
+
43
+ if (dynamicProps['itemRefId']) {
44
+ body.itemRef = {
45
+ id: dynamicProps['itemRefId'],
46
+ };
47
+ }
48
+
49
+ if (dynamicProps['productType']) {
50
+ body.productType = dynamicProps['productType'];
51
+ }
52
+
53
+ if (dynamicProps['unitType']) {
54
+ body.unitType = dynamicProps['unitType'];
55
+ }
56
+
57
+ if (
58
+ dynamicProps['taxRate'] !== undefined &&
59
+ dynamicProps['taxRate'] !== null
60
+ ) {
61
+ body.taxRate = dynamicProps['taxRate'];
62
+ }
63
+ }
64
+
65
+ const response = await makeRequest(
66
+ api_key,
67
+ HttpMethod.POST,
68
+ `/companies/${companyId}/invoices/${invoiceId}/line-items`,
69
+ body
70
+ );
71
+
72
+ return response;
73
+ },
74
+ });
@@ -0,0 +1,72 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bokioAuth } from '../common/auth';
3
+ import { makeRequest } from '../common/client';
4
+ import { HttpMethod } from '@agnocon/pieces-common';
5
+
6
+ export const createAJournalEntry = createAction({
7
+ auth: bokioAuth,
8
+ name: 'createAJournalEntry',
9
+ displayName: 'Create a journal entry',
10
+ description: 'Creates a new journal entry in Bokio',
11
+ audience: 'both',
12
+ aiMetadata: { description: 'Records a new bookkeeping journal entry in a Bokio company, posting debit/credit amounts against account numbers. Use for manual double-entry transactions; the entry date is required and items carry the per-account debit/credit lines. Not idempotent — each call posts a separate journal entry.', idempotent: false },
13
+ props: {
14
+ title: Property.ShortText({
15
+ displayName: 'Title',
16
+ description: 'Title of the journal entry',
17
+ required: false,
18
+ }),
19
+ date: Property.ShortText({
20
+ displayName: 'Date',
21
+ description: 'Journal entry date (YYYY-MM-DD)',
22
+ required: true,
23
+ }),
24
+ items: Property.Array({
25
+ displayName: 'Items (JSON)',
26
+ description:
27
+ 'Journal entry items as JSON array. Each item should have: account (account number), debit (optional), credit (optional)',
28
+ required: false,
29
+ properties: {
30
+ account: Property.Number({
31
+ displayName: 'Account Number',
32
+ description: 'Account number for the journal entry item',
33
+ required: false,
34
+ }),
35
+ debit: Property.Number({
36
+ displayName: 'Debit Amount',
37
+ description: 'Debit amount for the journal entry item',
38
+ required: false,
39
+ }),
40
+ credit: Property.Number({
41
+ displayName: 'Credit Amount',
42
+ description: 'Credit amount for the journal entry item',
43
+ required: false,
44
+ }),
45
+ },
46
+ }),
47
+ },
48
+ async run(context) {
49
+ const { title, date, items } = context.propsValue;
50
+ const { api_key, companyId } = context.auth.props;
51
+
52
+ const body: any = {
53
+ date,
54
+ };
55
+
56
+ if (title) {
57
+ body.title = title;
58
+ }
59
+ if (items) {
60
+ body.items = items;
61
+ }
62
+
63
+ const response = await makeRequest(
64
+ api_key,
65
+ HttpMethod.POST,
66
+ `/companies/${companyId}/journal-entries`,
67
+ body
68
+ );
69
+
70
+ return response;
71
+ },
72
+ });
@@ -0,0 +1,68 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bokioAuth } from '../common/auth';
3
+ import { makeRequest } from '../common/client';
4
+ import { HttpMethod } from '@agnocon/pieces-common';
5
+ import { lineItemsProps, unitTypeDropdown } from '../common/props';
6
+
7
+ export const createAnItem = createAction({
8
+ auth: bokioAuth,
9
+ name: 'createAnItem',
10
+ displayName: 'Create an item',
11
+ description: 'Creates a new item in Bokio',
12
+ audience: 'both',
13
+ aiMetadata: { description: 'Creates a new reusable item (a sales item with pricing, or a text item) in a Bokio company catalog. Use to define a product or service that can later be referenced on invoices; item type is required. Not idempotent — each call creates a separate item.', idempotent: false },
14
+ props: {
15
+ itemType: Property.StaticDropdown({
16
+ displayName: 'Item Type',
17
+ description: 'Type of the item',
18
+ required: true,
19
+ options: {
20
+ options: [
21
+ { label: 'Sales Item', value: 'salesItem' },
22
+ { label: 'Text', value: 'text' },
23
+ ],
24
+ },
25
+ }),
26
+ dynamicProps: lineItemsProps,
27
+ },
28
+ async run(context) {
29
+ const { itemType, dynamicProps } = context.propsValue;
30
+ const { api_key, companyId } = context.auth.props;
31
+
32
+ const body: any = {
33
+ itemType,
34
+ description: dynamicProps?.['description'],
35
+ };
36
+
37
+ if (dynamicProps?.['productType']) {
38
+ body.productType = dynamicProps['productType'];
39
+ }
40
+
41
+ if (dynamicProps?.['unitType']) {
42
+ body.unitType = dynamicProps['unitType'];
43
+ }
44
+
45
+ if (
46
+ dynamicProps?.['unitPrice'] !== undefined &&
47
+ dynamicProps?.['unitPrice'] !== null
48
+ ) {
49
+ body.unitPrice = dynamicProps['unitPrice'];
50
+ }
51
+
52
+ if (
53
+ dynamicProps?.['taxRate'] !== undefined &&
54
+ dynamicProps?.['taxRate'] !== null
55
+ ) {
56
+ body.taxRate = dynamicProps['taxRate'];
57
+ }
58
+
59
+ const response = await makeRequest(
60
+ api_key,
61
+ HttpMethod.POST,
62
+ `/companies/${companyId}/items`,
63
+ body
64
+ );
65
+
66
+ return response;
67
+ },
68
+ });
@@ -0,0 +1,163 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { bokioAuth } from '../common/auth';
3
+ import { makeRequest } from '../common/client';
4
+ import { HttpMethod } from '@agnocon/pieces-common';
5
+ import { t } from 'i18next';
6
+
7
+ export const createCustomer = createAction({
8
+ auth: bokioAuth,
9
+ name: 'createCustomer',
10
+ displayName: 'Create Customer',
11
+ description: 'Creates a new customer in Bokio',
12
+ audience: 'both',
13
+ aiMetadata: { description: 'Creates a new customer record in a Bokio accounting company. Use to register a person or company before invoicing them; only customer name and type (individual/company) are required, with optional VAT/org number, contact, and address details. Not idempotent — each call creates a separate customer.', idempotent: false },
14
+ props: {
15
+ customerName: Property.ShortText({
16
+ displayName: 'Customer Name',
17
+ description: 'Name of the customer',
18
+ required: true,
19
+ }),
20
+ type: Property.StaticDropdown({
21
+ displayName: 'Customer Type',
22
+ description: 'Type of the customer',
23
+ required: true,
24
+ options: {
25
+ options: [
26
+ { label: 'Individual', value: 'private' },
27
+ { label: 'Company', value: 'company' },
28
+ ],
29
+ },
30
+ }),
31
+ vatNumber: Property.ShortText({
32
+ displayName: 'VAT Number',
33
+ description: 'Customer VAT number',
34
+ required: false,
35
+ }),
36
+ orgNumber: Property.ShortText({
37
+ displayName: 'Organization Number',
38
+ description: 'Customer organization number',
39
+ required: false,
40
+ }),
41
+ paymentTerms: Property.ShortText({
42
+ displayName: 'Payment Terms',
43
+ description:
44
+ 'Payment terms for the customer. Payment terms for the invoices. Payment terms can both take free text or days, in digits, until the payment is due.',
45
+ required: false,
46
+ }),
47
+ customerNumber: Property.ShortText({
48
+ displayName: 'Customer Number',
49
+ description: 'Customer number (optional)',
50
+ required: false,
51
+ }),
52
+ email: Property.ShortText({
53
+ displayName: 'Email',
54
+ description: 'Customer email address',
55
+ required: false,
56
+ }),
57
+ phone: Property.ShortText({
58
+ displayName: 'Phone',
59
+ description: 'Customer phone number',
60
+ required: false,
61
+ }),
62
+ lin1: Property.ShortText({
63
+ displayName: 'Address line 1',
64
+ description: 'Customer address line 1',
65
+ required: false,
66
+ }),
67
+ line2: Property.ShortText({
68
+ displayName: 'Address line 2',
69
+ description: 'Customer address line 2',
70
+ required: false,
71
+ }),
72
+ zipCode: Property.ShortText({
73
+ displayName: 'Zip Code',
74
+ description: 'Customer zip code',
75
+ required: false,
76
+ }),
77
+ city: Property.ShortText({
78
+ displayName: 'City',
79
+ description: 'Customer city',
80
+ required: false,
81
+ }),
82
+ country: Property.ShortText({
83
+ displayName: 'Country',
84
+ description: 'Customer country (ISO 3166-1 alpha-2 country code)',
85
+ required: false,
86
+ }),
87
+ },
88
+ async run(context) {
89
+ const {
90
+ customerName,
91
+ type,
92
+ vatNumber,
93
+ orgNumber,
94
+ paymentTerms,
95
+ customerNumber,
96
+ email,
97
+ phone,
98
+ lin1,
99
+ line2,
100
+ zipCode,
101
+ city,
102
+ country,
103
+ } = context.propsValue;
104
+ const { api_key, companyId } = context.auth.props;
105
+
106
+ const body: any = {
107
+ name: customerName,
108
+ type: type,
109
+ };
110
+ if (vatNumber) {
111
+ body.vat_number = vatNumber;
112
+ }
113
+ if (orgNumber) {
114
+ body.org_number = orgNumber;
115
+ }
116
+ if (customerNumber) {
117
+ body.customer_number = customerNumber;
118
+ }
119
+ if (paymentTerms) {
120
+ body.payment_terms = paymentTerms;
121
+ }
122
+ const contactsDetails: any = {};
123
+ if (email) {
124
+ contactsDetails.email = email;
125
+ }
126
+ if (phone) {
127
+ contactsDetails.phone = phone;
128
+ }
129
+
130
+ if (Object.keys(contactsDetails).length > 0) {
131
+ body.contactsDetails = contactsDetails;
132
+ }
133
+ const addressDetails: any = {};
134
+ if (lin1) {
135
+ addressDetails.line_1 = lin1;
136
+ }
137
+ if (line2) {
138
+ addressDetails.line_2 = line2;
139
+ }
140
+ if (zipCode) {
141
+ addressDetails.zip_code = zipCode;
142
+ }
143
+ if (city) {
144
+ addressDetails.city = city;
145
+ }
146
+ if (country) {
147
+ addressDetails.country = country;
148
+ }
149
+
150
+ if (Object.keys(addressDetails).length > 0) {
151
+ body.address = addressDetails;
152
+ }
153
+
154
+ const response = await makeRequest(
155
+ api_key,
156
+ HttpMethod.POST,
157
+ `/companies/${companyId}/customers`,
158
+ body
159
+ );
160
+
161
+ return response;
162
+ },
163
+ });