@activepieces/piece-logsnag 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/package.json +16 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +34 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-event.d.ts +6 -0
- package/src/lib/actions/create-event.js +40 -0
- package/src/lib/actions/create-event.js.map +1 -0
- package/src/lib/triggers/new-event-created.d.ts +18 -0
- package/src/lib/triggers/new-event-created.js +74 -0
- package/src/lib/triggers/new-event-created.js.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-logsnag",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"main": "./src/index.js",
|
|
5
|
+
"types": "./src/index.d.ts",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@activepieces/pieces-common": "0.11.7",
|
|
8
|
+
"@activepieces/pieces-framework": "0.25.5",
|
|
9
|
+
"@activepieces/shared": "0.38.4",
|
|
10
|
+
"tslib": "2.6.2"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.lib.json && cp package.json dist/",
|
|
14
|
+
"lint": "eslint 'src/**/*.ts'"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logsnag = exports.logsnagAuth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const create_event_1 = require("./lib/actions/create-event");
|
|
7
|
+
const new_event_created_1 = require("./lib/triggers/new-event-created");
|
|
8
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
9
|
+
exports.logsnagAuth = pieces_framework_1.PieceAuth.SecretText({
|
|
10
|
+
displayName: 'API Key',
|
|
11
|
+
required: true,
|
|
12
|
+
description: 'Your LogSnag API key specific to the project',
|
|
13
|
+
});
|
|
14
|
+
exports.logsnag = (0, pieces_framework_1.createPiece)({
|
|
15
|
+
displayName: 'LogSnag',
|
|
16
|
+
auth: exports.logsnagAuth,
|
|
17
|
+
minimumSupportedRelease: '0.36.1',
|
|
18
|
+
logoUrl: 'https://cdn.activepieces.com/pieces/logsnag.png',
|
|
19
|
+
authors: [],
|
|
20
|
+
actions: [
|
|
21
|
+
create_event_1.createEvent,
|
|
22
|
+
(0, pieces_common_1.createCustomApiCallAction)({
|
|
23
|
+
auth: exports.logsnagAuth,
|
|
24
|
+
baseUrl: () => 'https://api.logsnag.com/v1',
|
|
25
|
+
authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
return {
|
|
27
|
+
Authorization: `Bearer ${auth.secret_text}`,
|
|
28
|
+
};
|
|
29
|
+
}),
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
triggers: [new_event_created_1.newEventCreated],
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,6DAAyD;AACzD,wEAAmE;AACnE,+DAAwE;AAE3D,QAAA,WAAW,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC9C,WAAW,EAAE,SAAS;IACtB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,8CAA8C;CAC5D,CAAC,CAAC;AAEU,QAAA,OAAO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,SAAS;IACtB,IAAI,EAAE,mBAAW;IACjB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,EAAE;IACX,OAAO,EAAE;QACP,0BAAW;QACX,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,mBAAW;YACjB,OAAO,EAAE,GAAG,EAAE,CAAC,4BAA4B;YAC3C,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,OAAO;oBACL,aAAa,EAAE,UAAU,IAAI,CAAC,WAAW,EAAE;iBAC5C,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,mCAAe,CAAC;CAC5B,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const createEvent: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
2
|
+
project: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
channel: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
event: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
description: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEvent = 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 __1 = require("../..");
|
|
8
|
+
exports.createEvent = (0, pieces_framework_1.createAction)({
|
|
9
|
+
auth: __1.logsnagAuth,
|
|
10
|
+
name: 'createEvent',
|
|
11
|
+
displayName: 'Create Event',
|
|
12
|
+
description: 'Creates a new event in LogSnag with the specified channel and details.',
|
|
13
|
+
props: {
|
|
14
|
+
project: pieces_framework_1.Property.ShortText({ displayName: "Project", required: true }),
|
|
15
|
+
channel: pieces_framework_1.Property.ShortText({ displayName: "Channel", required: true }),
|
|
16
|
+
event: pieces_framework_1.Property.ShortText({ displayName: "Event", required: true }),
|
|
17
|
+
description: pieces_framework_1.Property.ShortText({ displayName: "Description", required: false }),
|
|
18
|
+
},
|
|
19
|
+
run(context) {
|
|
20
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const { project, channel, event, description } = context.propsValue;
|
|
22
|
+
const res = yield pieces_common_1.httpClient.sendRequest({
|
|
23
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
24
|
+
url: 'https://api.logsnag.com/v1/log',
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: `Bearer ${context.auth.secret_text}`,
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
},
|
|
29
|
+
body: {
|
|
30
|
+
project,
|
|
31
|
+
channel,
|
|
32
|
+
event,
|
|
33
|
+
description,
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return res.body;
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=create-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-event.js","sourceRoot":"","sources":["../../../../src/lib/actions/create-event.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,6BAAoC;AAEvB,QAAA,WAAW,GAAG,IAAA,+BAAY,EAAC;IACtC,IAAI,EAAE,eAAW;IACjB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,wEAAwE;IACrF,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;QACrE,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;QACrE,KAAK,EAAG,2BAAQ,CAAC,SAAS,CAAC,EAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;QAClE,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC,EAAC,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC;KAC/E;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;YACpE,MAAM,GAAG,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAW;gBACjD,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,gCAAgC;gBACrC,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE;oBACnD,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE;oBACJ,OAAO;oBACP,OAAO;oBACP,KAAK;oBACL,WAAW;iBACZ;aACF,CAAC,CAAC;YACH,OAAO,GAAG,CAAC,IAAI,CAAC;QAClB,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
+
export declare const newEventCreated: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
3
|
+
project: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
channel: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
+
event: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
7
|
+
project: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
8
|
+
channel: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
event: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
11
|
+
project: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
12
|
+
channel: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
13
|
+
event: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
14
|
+
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").SecretTextProperty<true>, {
|
|
15
|
+
project: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
16
|
+
channel: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
17
|
+
event: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newEventCreated = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const __1 = require("../../");
|
|
6
|
+
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
8
|
+
// since LogSnag doesn't expose an endpoint to GET data
|
|
9
|
+
// by polling or an endpoint to register webhooks,
|
|
10
|
+
// this sample uses a fictional endpoint URL
|
|
11
|
+
// in order to demonstrate how it could work in theory
|
|
12
|
+
// using a webhook
|
|
13
|
+
exports.newEventCreated = (0, pieces_framework_1.createTrigger)({
|
|
14
|
+
auth: __1.logsnagAuth,
|
|
15
|
+
name: 'newEventCreated',
|
|
16
|
+
displayName: 'New event created',
|
|
17
|
+
description: 'triggers when a new event ic created and logged',
|
|
18
|
+
props: {
|
|
19
|
+
project: pieces_framework_1.Property.ShortText({ displayName: "Project", required: true }),
|
|
20
|
+
channel: pieces_framework_1.Property.ShortText({ displayName: "Channel", required: true }),
|
|
21
|
+
event: pieces_framework_1.Property.ShortText({ displayName: "Event", required: true }),
|
|
22
|
+
},
|
|
23
|
+
sampleData: {
|
|
24
|
+
project: "MyProject",
|
|
25
|
+
channel: "MyChannel",
|
|
26
|
+
event: "TestEvent",
|
|
27
|
+
},
|
|
28
|
+
type: pieces_framework_1.TriggerStrategy.WEBHOOK,
|
|
29
|
+
onEnable(context) {
|
|
30
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const response = yield pieces_common_1.httpClient.sendRequest({
|
|
32
|
+
method: pieces_common_1.HttpMethod.POST,
|
|
33
|
+
url: "https://api.logsnag.com/v1/webhooks", // <-- fictional LogSnag API endpoint,
|
|
34
|
+
headers: {
|
|
35
|
+
Authorization: `Bearer ${context.auth.secret_text}`,
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
},
|
|
38
|
+
body: {
|
|
39
|
+
event: 'event.created',
|
|
40
|
+
target: context.webhookUrl,
|
|
41
|
+
project: context.propsValue.project,
|
|
42
|
+
channel: context.propsValue.channel,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
if (response.status === 200 || response.status === 201) {
|
|
46
|
+
const webhook = response.body;
|
|
47
|
+
yield context.store.put('_logsnag_webhook', webhook.uuid);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
onDisable(context) {
|
|
52
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const webhookId = yield context.store.get('_logsnag_webhook');
|
|
54
|
+
if (webhookId) {
|
|
55
|
+
yield pieces_common_1.httpClient.sendRequest({
|
|
56
|
+
method: pieces_common_1.HttpMethod.DELETE,
|
|
57
|
+
url: `https://api.logsnag.com/v1/webhooks/${webhookId}/`,
|
|
58
|
+
headers: {
|
|
59
|
+
Authorization: `Bearer ${context.auth.secret_text}`,
|
|
60
|
+
'Content-Type': 'application/json',
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
yield context.store.delete('_logsnag_webhook');
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
run(context) {
|
|
68
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const payload = context.payload.body;
|
|
70
|
+
return [payload];
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=new-event-created.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-event-created.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-event-created.ts"],"names":[],"mappings":";;;;AAAA,8BAAmC;AACnC,+DAAqE;AACrE,qEAA0F;AAE1F,wDAAwD;AACxD,kDAAkD;AAClD,6CAA6C;AAC7C,sDAAsD;AACtD,kBAAkB;AAEL,QAAA,eAAe,GAAG,IAAA,gCAAa,EAAC;IACzC,IAAI,EAAE,eAAW;IACjB,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,iDAAiD;IAC9D,KAAK,EAAE;QACH,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;QACrE,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;QACrE,KAAK,EAAG,2BAAQ,CAAC,SAAS,CAAC,EAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;KACrE;IACD,UAAU,EAAE;QACR,OAAO,EAAE,WAAW;QACpB,OAAO,EAAE,WAAW;QACpB,KAAK,EAAE,WAAW;KACrB;IACD,IAAI,EAAE,kCAAe,CAAC,OAAO;IACvB,QAAQ,CAAC,OAAO;;YAClB,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC1C,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,qCAAqC,EAAE,sCAAsC;gBAClF,O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