@activepieces/piece-saastic 0.0.2

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-saastic
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build pieces-saastic` to build the library.
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@activepieces/piece-saastic",
3
+ "version": "0.0.2",
4
+ "dependencies": {
5
+ "@activepieces/pieces-common": "latest",
6
+ "@activepieces/pieces-framework": "latest",
7
+ "@sinclair/typebox": "0.26.8",
8
+ "axios": "^1.0.0",
9
+ "dayjs": "1.11.9",
10
+ "is-base64": "1.1.0",
11
+ "lodash": "4.17.21",
12
+ "nanoid": "3.3.6",
13
+ "semver": "7.5.4",
14
+ "tslib": "^2.6.2",
15
+ "@activepieces/shared": "0.10.5"
16
+ },
17
+ "main": "./src/index.js",
18
+ "type": "commonjs"
19
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare const saasticAuth: import("@activepieces/pieces-framework").SecretTextProperty<true>;
2
+ export declare const saastic: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").SecretTextProperty<true>>;
package/src/index.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saastic = exports.saasticAuth = 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 create_customer_1 = require("./lib/actions/create-customer");
8
+ const create_charge_1 = require("./lib/actions/create-charge");
9
+ exports.saasticAuth = pieces_framework_1.PieceAuth.SecretText({
10
+ description: ' You can find your project’s API key here: https://saastic.com/settings/developers',
11
+ displayName: 'Api Key',
12
+ required: true,
13
+ validate: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
14
+ try {
15
+ yield pieces_common_1.httpClient.sendRequest({
16
+ url: 'https://api.saastic.com/beacon/customers',
17
+ method: pieces_common_1.HttpMethod.GET,
18
+ authentication: {
19
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
20
+ token: auth.auth
21
+ }
22
+ });
23
+ return {
24
+ valid: true,
25
+ };
26
+ }
27
+ catch (e) {
28
+ return {
29
+ valid: false,
30
+ error: 'Invalid API token'
31
+ };
32
+ }
33
+ })
34
+ });
35
+ exports.saastic = (0, pieces_framework_1.createPiece)({
36
+ displayName: "Saastic",
37
+ auth: exports.saasticAuth,
38
+ minimumSupportedRelease: '0.9.0',
39
+ logoUrl: "https://cdn.activepieces.com/pieces/saastic.png",
40
+ authors: ["joselupianez"],
41
+ actions: [create_customer_1.createCustomer, create_charge_1.createCharge],
42
+ triggers: [],
43
+ });
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/saastic/src/index.ts"],"names":[],"mappings":";;;;AACA,qEAAwE;AACxE,+DAAyF;AACzF,mEAA+D;AAC/D,+DAA2D;AAE9C,QAAA,WAAW,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC9C,WAAW,EAAE,oFAAoF;IACjG,WAAW,EAAE,SAAS;IACtB,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,CAAO,IAAI,EAAE,EAAE;QACvB,IAAG;YACD,MAAM,0BAAU,CAAC,WAAW,CAEzB;gBACD,GAAG,EAAE,0CAA0C;gBAC/C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,cAAc,EAAE;oBACd,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,IAAI,CAAC,IAAc;iBAC3B;aACF,CAAC,CAAC;YACH,OAAM;gBACJ,KAAK,EAAE,IAAI;aACZ,CAAA;SACF;QAAA,OAAM,CAAC,EAAC;YACP,OAAM;gBACJ,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,mBAAmB;aAC3B,CAAA;SACF;IACH,CAAC,CAAA;CACF,CAAC,CAAC;AAEU,QAAA,OAAO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,SAAS;IACtB,IAAI,EAAE,mBAAW;IACjB,uBAAuB,EAAE,OAAO;IAChC,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,CAAC,cAAc,CAAC;IACzB,OAAO,EAAE,CAAC,gCAAc,EAAE,4BAAY,CAAC;IACvC,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const createCharge: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ email: import("@activepieces/pieces-framework").LongTextProperty<true>;
3
+ amount: import("@activepieces/pieces-framework").NumberProperty<false>;
4
+ currency: import("@activepieces/pieces-framework").ShortTextProperty<false>;
5
+ charged_at: import("@activepieces/pieces-framework").DateTimeProperty<false>;
6
+ }>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCharge = 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 __1 = require("../..");
9
+ exports.createCharge = (0, pieces_framework_1.createAction)({
10
+ auth: __1.saasticAuth,
11
+ name: 'create_charge',
12
+ displayName: 'Create a Customer Charge',
13
+ description: 'Creates a customer charge.',
14
+ props: {
15
+ email: pieces_framework_1.Property.LongText({
16
+ displayName: 'Email',
17
+ description: 'The customer\'s email address.',
18
+ required: true,
19
+ processors: [],
20
+ validators: [pieces_framework_1.Validators.email],
21
+ }),
22
+ amount: pieces_framework_1.Property.Number({
23
+ displayName: 'Amount',
24
+ description: 'The amount charged in the smallest currency unit.',
25
+ required: false
26
+ }),
27
+ currency: pieces_framework_1.Property.ShortText({
28
+ displayName: 'Currency',
29
+ description: 'The ISO currency code.',
30
+ required: false,
31
+ defaultValue: 'USD',
32
+ }),
33
+ charged_at: pieces_framework_1.Property.DateTime({
34
+ displayName: 'Charge date',
35
+ description: 'The date the customer was charged.',
36
+ required: false
37
+ })
38
+ },
39
+ run(context) {
40
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
41
+ const request = {
42
+ method: pieces_common_1.HttpMethod.POST,
43
+ url: `${common_1.saasticCommon.baseUrl}/charges`,
44
+ body: {
45
+ email: context.propsValue.email || '',
46
+ amount: context.propsValue.amount || '',
47
+ currency: context.propsValue.currency || '',
48
+ charged_at: context.propsValue.charged_at || ''
49
+ },
50
+ authentication: {
51
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
52
+ token: context.auth,
53
+ },
54
+ queryParams: {},
55
+ };
56
+ yield pieces_common_1.httpClient.sendRequest(request);
57
+ return {
58
+ success: true
59
+ };
60
+ });
61
+ }
62
+ });
63
+ //# sourceMappingURL=create-charge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-charge.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/saastic/src/lib/actions/create-charge.ts"],"names":[],"mappings":";;;;AAAA,qEAAoF;AACpF,+DAAsG;AACtG,sCAA0C;AAC1C,6BAAoC;AAEvB,QAAA,YAAY,GAAG,IAAA,+BAAY,EAAC;IACrC,IAAI,EAAE,eAAW;IACjB,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,0BAA0B;IACvC,WAAW,EAAE,4BAA4B;IAEzC,KAAK,EAAE;QACH,KAAK,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACrB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,gCAAgC;YAC7C,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,EAAE;YACd,UAAU,EAAE,CAAC,6BAAU,CAAC,KAAK,CAAC;SACjC,CAAC;QACF,MAAM,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,mDAAmD;YAChE,QAAQ,EAAE,KAAK;SAClB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,wBAAwB;YACrC,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;SACtB,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC1B,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,oCAAoC;YACjD,QAAQ,EAAE,KAAK;SAClB,CAAC;KACL;IAEK,GAAG,CAAC,OAAO;;YACb,MAAM,OAAO,GAAgB;gBACzB,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,GAAG,sBAAa,CAAC,OAAO,UAAU;gBACvC,IAAI,EAAE;oBACF,KAAK,EAAG,OAAO,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE;oBACtC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,IAAI,EAAE;oBACvC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,IAAI,EAAE;oBAC3C,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU,IAAI,EAAE;iBAClD;gBACD,cAAc,EAAE;oBACZ,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,OAAO,CAAC,IAAI;iBACtB;gBACD,WAAW,EAAE,EAAE;aAClB,CAAC;YAEF,MAAM,0BAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAEtC,OAAO;gBACH,OAAO,EAAE,IAAI;aAChB,CAAC;QACN,CAAC;KAAA;CACJ,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ export declare const createCustomer: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
2
+ first_name: import("@activepieces/pieces-framework").LongTextProperty<true>;
3
+ last_name: import("@activepieces/pieces-framework").LongTextProperty<true>;
4
+ email: import("@activepieces/pieces-framework").LongTextProperty<true>;
5
+ phone: import("@activepieces/pieces-framework").LongTextProperty<false>;
6
+ signed_up_at: import("@activepieces/pieces-framework").DateTimeProperty<false>;
7
+ }>;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCustomer = 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 __1 = require("../..");
9
+ exports.createCustomer = (0, pieces_framework_1.createAction)({
10
+ auth: __1.saasticAuth,
11
+ name: 'create_customer',
12
+ displayName: 'Create or Update a Customer',
13
+ description: 'Create or update a customer.',
14
+ props: {
15
+ first_name: pieces_framework_1.Property.LongText({
16
+ displayName: 'First Name',
17
+ description: 'The customer\'s first name.',
18
+ required: true,
19
+ }),
20
+ last_name: pieces_framework_1.Property.LongText({
21
+ displayName: 'Last Name',
22
+ description: 'The customer\'s last name.',
23
+ required: true,
24
+ }),
25
+ email: pieces_framework_1.Property.LongText({
26
+ displayName: 'Email',
27
+ description: 'The customer\'s email address.',
28
+ required: true,
29
+ processors: [],
30
+ validators: [pieces_framework_1.Validators.email],
31
+ }),
32
+ phone: pieces_framework_1.Property.LongText({
33
+ displayName: 'Phone',
34
+ description: 'The customer\'s phone number. Ex: +15555555555',
35
+ required: false,
36
+ }),
37
+ signed_up_at: pieces_framework_1.Property.DateTime({
38
+ displayName: 'Signup Date',
39
+ description: 'The date the customer signed up.',
40
+ required: false,
41
+ processors: [],
42
+ validators: [pieces_framework_1.Validators.datetimeIso],
43
+ })
44
+ },
45
+ run(context) {
46
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
47
+ const request = {
48
+ method: pieces_common_1.HttpMethod.POST,
49
+ url: `${common_1.saasticCommon.baseUrl}/customers`,
50
+ body: {
51
+ first_name: context.propsValue.first_name || '',
52
+ last_name: context.propsValue.last_name || '',
53
+ email: context.propsValue.email || '',
54
+ phone: context.propsValue.phone || '',
55
+ signed_up_at: context.propsValue.signed_up_at || ''
56
+ },
57
+ authentication: {
58
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
59
+ token: context.auth,
60
+ },
61
+ queryParams: {},
62
+ };
63
+ yield pieces_common_1.httpClient.sendRequest(request);
64
+ return {
65
+ success: true
66
+ };
67
+ });
68
+ }
69
+ });
70
+ //# sourceMappingURL=create-customer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-customer.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/saastic/src/lib/actions/create-customer.ts"],"names":[],"mappings":";;;;AAAA,qEAAoF;AACpF,+DAAsG;AACtG,sCAA0C;AAC1C,6BAAoC;AAEvB,QAAA,cAAc,GAAG,IAAA,+BAAY,EAAC;IACvC,IAAI,EAAE,eAAW;IACjB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,6BAA6B;IAC1C,WAAW,EAAE,8BAA8B;IAE3C,KAAK,EAAE;QACH,UAAU,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC1B,WAAW,EAAE,YAAY;YACzB,WAAW,EAAE,6BAA6B;YAC1C,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACzB,WAAW,EAAE,WAAW;YACxB,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACrB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,gCAAgC;YAC7C,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,EAAE;YACd,UAAU,EAAE,CAAC,6BAAU,CAAC,KAAK,CAAC;SACjC,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACrB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,KAAK;SAClB,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC5B,WAAW,EAAE,aAAa;YAC1B,WAAW,EAAE,kCAAkC;YAC/C,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,EAAE;YACd,UAAU,EAAE,CAAC,6BAAU,CAAC,WAAW,CAAC;SACvC,CAAC;KACL;IAEK,GAAG,CAAC,OAAO;;YACb,MAAM,OAAO,GAAgB;gBACzB,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,GAAG,sBAAa,CAAC,OAAO,YAAY;gBACzC,IAAI,EAAE;oBACF,UAAU,EAAG,OAAO,CAAC,UAAU,CAAC,UAAU,IAAI,EAAE;oBAChD,SAAS,EAAG,OAAO,CAAC,UAAU,CAAC,SAAS,IAAI,EAAE;oBAC9C,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE;oBACrC,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE;oBACrC,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,YAAY,IAAI,EAAE;iBACtD;gBACD,cAAc,EAAE;oBACZ,IAAI,EAAE,kCAAkB,CAAC,YAAY;oBACrC,KAAK,EAAE,OAAO,CAAC,IAAI;iBACtB;gBACD,WAAW,EAAE,EAAE;aAClB,CAAC;YACF,MAAM,0BAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAEtC,OAAO;gBACH,OAAO,EAAE,IAAI;aAChB,CAAC;QACN,CAAC;KAAA;CACJ,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const saasticCommon: {
2
+ baseUrl: string;
3
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saasticCommon = void 0;
4
+ exports.saasticCommon = {
5
+ baseUrl: "https://api.saastic.com/beacon",
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/saastic/src/lib/common/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IACzB,OAAO,EAAE,gCAAgC;CAC5C,CAAA"}