@activepieces/piece-zoho-invoice 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 ADDED
@@ -0,0 +1,7 @@
1
+ # pieces-zoho-invoice
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-zoho-invoice` to build the library.
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@activepieces/piece-zoho-invoice",
3
+ "version": "0.0.1",
4
+ "dependencies": {
5
+ "@sinclair/typebox": "^0.26.3",
6
+ "axios": "1.4.0",
7
+ "dayjs": "^1.11.8",
8
+ "is-base64": "^1.1.0",
9
+ "lodash": "4.17.21",
10
+ "nanoid": "^3.3.4",
11
+ "semver": "7.5.3",
12
+ "@activepieces/pieces-common": "0.2.1",
13
+ "@activepieces/pieces-framework": "0.6.7",
14
+ "@activepieces/shared": "0.5.11",
15
+ "tslib": "1.14.1"
16
+ },
17
+ "main": "./src/index.js",
18
+ "types": "./src/index.d.ts"
19
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const zohoAuth: import("@activepieces/pieces-framework").OAuth2Property<true, import("@activepieces/pieces-framework").OAuth2Props>;
2
+ export declare const zohoInvoice: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").OAuth2Property<true, import("@activepieces/pieces-framework").OAuth2Props>>;
package/src/index.js ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.zohoInvoice = exports.zohoAuth = void 0;
4
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
5
+ const new_invoice_1 = require("./lib/triggers/new-invoice");
6
+ exports.zohoAuth = pieces_framework_1.PieceAuth.OAuth2({
7
+ displayName: 'Authentication',
8
+ required: true,
9
+ authUrl: 'https://accounts.zoho.{region}/oauth/v2/auth',
10
+ tokenUrl: 'https://accounts.zoho.{region}/oauth/v2/token',
11
+ scope: ['ZohoInvoice.invoices.READ'],
12
+ props: {
13
+ region: pieces_framework_1.Property.StaticDropdown({
14
+ displayName: 'Region',
15
+ description: 'Select your account region',
16
+ required: true,
17
+ options: {
18
+ options: [
19
+ {
20
+ label: 'US (.com)',
21
+ value: 'com'
22
+ },
23
+ {
24
+ label: 'Europe (.eu)',
25
+ value: 'eu'
26
+ },
27
+ {
28
+ label: 'India (.in)',
29
+ value: 'in'
30
+ },
31
+ {
32
+ label: 'Australia (.com.au)',
33
+ value: 'com.au'
34
+ },
35
+ {
36
+ label: 'Japan (.jp)',
37
+ value: 'jp'
38
+ }
39
+ ]
40
+ }
41
+ })
42
+ },
43
+ });
44
+ exports.zohoInvoice = (0, pieces_framework_1.createPiece)({
45
+ displayName: "Zoho Invoice",
46
+ auth: exports.zohoAuth,
47
+ minimumSupportedRelease: '0.5.0',
48
+ logoUrl: "https://cdn.activepieces.com/pieces/zoho-invoice.png",
49
+ authors: ['MoShizzle'],
50
+ actions: [],
51
+ triggers: [new_invoice_1.newInvoice],
52
+ });
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/zoho-invoice/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAkF;AAClF,4DAAwD;AAE3C,QAAA,QAAQ,GAAG,4BAAS,CAAC,MAAM,CAAC;IACrC,WAAW,EAAE,gBAAgB;IAC7B,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,8CAA8C;IACvD,QAAQ,EAAE,+CAA+C;IACzD,KAAK,EAAE,CAAC,2BAA2B,CAAC;IACpC,KAAK,EAAE;QACH,MAAM,EAAE,2BAAQ,CAAC,cAAc,CAAC;YAC5B,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACL,OAAO,EAAE;oBACL;wBACI,KAAK,EAAE,WAAW;wBAClB,KAAK,EAAE,KAAK;qBACf;oBACD;wBACI,KAAK,EAAE,cAAc;wBACrB,KAAK,EAAE,IAAI;qBACd;oBACD;wBACI,KAAK,EAAE,aAAa;wBACpB,KAAK,EAAE,IAAI;qBACd;oBACD;wBACI,KAAK,EAAE,qBAAqB;wBAC5B,KAAK,EAAE,QAAQ;qBAClB;oBACD;wBACI,KAAK,EAAE,aAAa;wBACpB,KAAK,EAAE,IAAI;qBACd;iBACJ;aACJ;SACJ,CAAC;KACL;CACJ,CAAC,CAAC;AAEU,QAAA,WAAW,GAAG,IAAA,8BAAW,EAAC;IACnC,WAAW,EAAE,cAAc;IAC3B,IAAI,EAAE,gBAAQ;IACd,uBAAuB,EAAE,OAAO;IAChC,OAAO,EAAE,sDAAsD;IAC/D,OAAO,EAAE,CAAC,WAAW,CAAC;IACtB,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,CAAC,wBAAU,CAAC;CACzB,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { OAuth2PropertyValue } from "@activepieces/pieces-framework";
2
+ export declare const common: {
3
+ baseUrl: (region: string) => string;
4
+ authHeaders: (accessToken: string) => {
5
+ Authorization: string;
6
+ };
7
+ getInvoices(auth: OAuth2PropertyValue, search?: {
8
+ createdSince?: string;
9
+ }): Promise<any>;
10
+ };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.common = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_common_1 = require("@activepieces/pieces-common");
6
+ exports.common = {
7
+ baseUrl: (region) => { return `https://www.zohoapis.${region}/invoice/v3`; },
8
+ authHeaders: (accessToken) => {
9
+ return {
10
+ 'Authorization': `Zoho-oauthtoken ${accessToken}`
11
+ };
12
+ },
13
+ getInvoices(auth, search) {
14
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
+ const q = {};
16
+ if (search === null || search === void 0 ? void 0 : search.createdSince)
17
+ q.last_modified_at = search.createdSince;
18
+ const response = yield pieces_common_1.httpClient.sendRequest({
19
+ url: `${exports.common.baseUrl(auth.props['region'])}/invoices`,
20
+ method: pieces_common_1.HttpMethod.GET,
21
+ headers: exports.common.authHeaders(auth.access_token),
22
+ queryParams: q
23
+ });
24
+ return response.body['invoices'];
25
+ });
26
+ }
27
+ };
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/zoho-invoice/src/lib/common/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAoE;AAGvD,QAAA,MAAM,GAAG;IAClB,OAAO,EAAE,CAAC,MAAc,EAAE,EAAE,GAAG,OAAO,wBAAwB,MAAM,aAAa,CAAA,CAAC,CAAC;IACnF,WAAW,EAAE,CAAC,WAAmB,EAAE,EAAE;QACjC,OAAO;YACH,eAAe,EAAE,mBAAmB,WAAW,EAAE;SACpD,CAAA;IACL,CAAC;IAEK,WAAW,CAAC,IAAyB,EAAE,MAE5C;;YACG,MAAM,CAAC,GAEH,EAAE,CAAC;YACP,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY;gBAAE,CAAC,CAAC,gBAAgB,GAAG,MAAM,CAAC,YAAY,CAAC;YAEnE,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC1C,GAAG,EAAE,GAAG,cAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAM,CAAC,QAAQ,CAAC,CAAC,WAAW;gBACxD,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,OAAO,EAAE,cAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC9C,WAAW,EAAE,CAAC;aACjB,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;KAAA;CACJ,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const newInvoice: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<true, import("@activepieces/pieces-framework").OAuth2Props>, {}>;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newInvoice = 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 common_1 = require("../common");
8
+ const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
9
+ const __1 = require("../..");
10
+ const polling = {
11
+ strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
12
+ items: ({ auth, lastFetchEpochMS }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
13
+ var _a;
14
+ const currentValues = (_a = yield common_1.common.getInvoices(auth, {
15
+ createdSince: (0, dayjs_1.default)(lastFetchEpochMS).format('YYYY-MM-DD')
16
+ })) !== null && _a !== void 0 ? _a : [];
17
+ const items = currentValues.map((item) => ({
18
+ epochMilliSeconds: (0, dayjs_1.default)(item.created_time).valueOf(),
19
+ data: item
20
+ }));
21
+ return items;
22
+ })
23
+ };
24
+ exports.newInvoice = (0, pieces_framework_1.createTrigger)({
25
+ auth: __1.zohoAuth,
26
+ name: 'new_invoice',
27
+ displayName: 'New Invoice',
28
+ description: 'Trigger when a new invoice is received.',
29
+ props: {},
30
+ type: pieces_framework_1.TriggerStrategy.POLLING,
31
+ onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
32
+ yield pieces_common_1.pollingHelper.onEnable(polling, {
33
+ auth: context.auth,
34
+ store: context.store,
35
+ propsValue: context.propsValue,
36
+ });
37
+ }),
38
+ onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
39
+ yield pieces_common_1.pollingHelper.onDisable(polling, {
40
+ auth: context.auth,
41
+ store: context.store,
42
+ propsValue: context.propsValue,
43
+ });
44
+ }),
45
+ run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
46
+ return yield pieces_common_1.pollingHelper.poll(polling, {
47
+ auth: context.auth,
48
+ store: context.store,
49
+ propsValue: context.propsValue,
50
+ });
51
+ }),
52
+ test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
53
+ return yield pieces_common_1.pollingHelper.test(polling, {
54
+ auth: context.auth,
55
+ store: context.store,
56
+ propsValue: context.propsValue,
57
+ });
58
+ }),
59
+ sampleData: {}
60
+ });
61
+ //# sourceMappingURL=new-invoice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-invoice.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/zoho-invoice/src/lib/triggers/new-invoice.ts"],"names":[],"mappings":";;;;AAAA,qEAAsG;AACtG,+DAAqF;AAErF,sCAAmC;AAEnC,0DAA0B;AAC1B,6BAAiC;AAEjC,MAAM,OAAO,GAAyE;IAClF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,CAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE;;QACxC,MAAM,aAAa,GAAG,MAAA,MAAM,eAAM,CAAC,WAAW,CAAC,IAAI,EAAE;YACjD,YAAY,EAAE,IAAA,eAAK,EAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;SAC7D,CAAC,mCAAI,EAAE,CAAC;QACT,MAAM,KAAK,GAAI,aAAuB,CAAC,GAAG,CAAC,CAAC,IAA8B,EAAE,EAAE,CAAC,CAAC;YAC5E,iBAAiB,EAAE,IAAA,eAAK,EAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;YACrD,IAAI,EAAE,IAAI;SACb,CAAC,CAAC,CAAC;QACJ,OAAO,KAAK,CAAC;IACjB,CAAC,CAAA;CACJ,CAAC;AAEW,QAAA,UAAU,GAAG,IAAA,gCAAa,EAAC;IACpC,IAAI,EAAE,YAAQ;IACd,IAAI,EAAE,aAAa;IACnB,WAAW,EAA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