@pinelab/vendure-plugin-webhook 1.1.0 → 1.2.0
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/CHANGELOG.md +8 -0
- package/README.md +4 -5
- package/dist/api/webhook.entity.js +2 -2
- package/dist/api/webhook.resolver.js +6 -6
- package/dist/api/webhook.service.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/webhook.plugin.js +3 -3
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vendure Webhook plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### [Official documentation here](https://pinelab-plugins.com/plugin/vendure-plugin-webhook)
|
|
4
4
|
|
|
5
5
|
Triggers an outgoing webhook based on configured events. Events are specified in `vendure-config` and webhooks are configured per
|
|
6
6
|
channel via the admin UI.
|
|
@@ -18,11 +18,10 @@ platforms when orders are placed by subscribing to OrderPlacedEvents!
|
|
|
18
18
|
|
|
19
19
|
## Getting started
|
|
20
20
|
|
|
21
|
-
1. `
|
|
22
|
-
2. Add the `WebhookPlugin` to your plugins in your `vendure-config.ts`:
|
|
21
|
+
1. Add the `WebhookPlugin` to your plugins in your `vendure-config.ts`:
|
|
23
22
|
|
|
24
23
|
```ts
|
|
25
|
-
import { WebhookPlugin } from 'vendure-plugin-webhook';
|
|
24
|
+
import { WebhookPlugin } from '@pinelab/vendure-plugin-webhook';
|
|
26
25
|
|
|
27
26
|
plugins: [
|
|
28
27
|
WebhookPlugin.init({
|
|
@@ -62,7 +61,7 @@ Request transformers are used to create a custom POST body and custom headers fo
|
|
|
62
61
|
|
|
63
62
|
```ts
|
|
64
63
|
import { Logger, ProductEvent } from '@vendure/core';
|
|
65
|
-
import { RequestTransformer } from 'vendure-plugin-webhook';
|
|
64
|
+
import { RequestTransformer } from '@pinelab/vendure-plugin-webhook';
|
|
66
65
|
|
|
67
66
|
export const stringifyProductTransformer = new RequestTransformer({
|
|
68
67
|
name: 'Stringify Product events',
|
|
@@ -21,6 +21,7 @@ let Webhook = class Webhook extends core_1.VendureEntity {
|
|
|
21
21
|
super(input);
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
+
exports.Webhook = Webhook;
|
|
24
25
|
__decorate([
|
|
25
26
|
(0, typeorm_1.Column)(),
|
|
26
27
|
__metadata("design:type", String)
|
|
@@ -37,8 +38,7 @@ __decorate([
|
|
|
37
38
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
38
39
|
__metadata("design:type", String)
|
|
39
40
|
], Webhook.prototype, "transformerName", void 0);
|
|
40
|
-
Webhook = __decorate([
|
|
41
|
+
exports.Webhook = Webhook = __decorate([
|
|
41
42
|
(0, typeorm_1.Entity)(),
|
|
42
43
|
__metadata("design:paramtypes", [Object])
|
|
43
44
|
], Webhook);
|
|
44
|
-
exports.Webhook = Webhook;
|
|
@@ -12,7 +12,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.WebhookRequestTransformerResolver = exports.WebhookResolver = exports.webhookPermission = void 0;
|
|
16
|
+
exports.mapToGraphqlTransformer = mapToGraphqlTransformer;
|
|
16
17
|
const graphql_1 = require("@nestjs/graphql");
|
|
17
18
|
const core_1 = require("@vendure/core");
|
|
18
19
|
const webhook_service_1 = require("./webhook.service");
|
|
@@ -43,6 +44,7 @@ let WebhookResolver = class WebhookResolver {
|
|
|
43
44
|
return transformers.map(mapToGraphqlTransformer);
|
|
44
45
|
}
|
|
45
46
|
};
|
|
47
|
+
exports.WebhookResolver = WebhookResolver;
|
|
46
48
|
__decorate([
|
|
47
49
|
(0, graphql_1.Mutation)(),
|
|
48
50
|
(0, core_1.Allow)(exports.webhookPermission.Permission),
|
|
@@ -74,11 +76,10 @@ __decorate([
|
|
|
74
76
|
__metadata("design:paramtypes", []),
|
|
75
77
|
__metadata("design:returntype", Promise)
|
|
76
78
|
], WebhookResolver.prototype, "availableWebhookRequestTransformers", null);
|
|
77
|
-
WebhookResolver = __decorate([
|
|
79
|
+
exports.WebhookResolver = WebhookResolver = __decorate([
|
|
78
80
|
(0, graphql_1.Resolver)(),
|
|
79
81
|
__metadata("design:paramtypes", [webhook_service_1.WebhookService])
|
|
80
82
|
], WebhookResolver);
|
|
81
|
-
exports.WebhookResolver = WebhookResolver;
|
|
82
83
|
let WebhookRequestTransformerResolver = class WebhookRequestTransformerResolver {
|
|
83
84
|
constructor(webhookService) {
|
|
84
85
|
this.webhookService = webhookService;
|
|
@@ -98,6 +99,7 @@ let WebhookRequestTransformerResolver = class WebhookRequestTransformerResolver
|
|
|
98
99
|
return mapToGraphqlTransformer(transformer);
|
|
99
100
|
}
|
|
100
101
|
};
|
|
102
|
+
exports.WebhookRequestTransformerResolver = WebhookRequestTransformerResolver;
|
|
101
103
|
__decorate([
|
|
102
104
|
(0, graphql_1.ResolveField)(),
|
|
103
105
|
__param(0, (0, core_1.Ctx)()),
|
|
@@ -107,15 +109,13 @@ __decorate([
|
|
|
107
109
|
webhook_entity_1.Webhook]),
|
|
108
110
|
__metadata("design:returntype", Promise)
|
|
109
111
|
], WebhookRequestTransformerResolver.prototype, "requestTransformer", null);
|
|
110
|
-
WebhookRequestTransformerResolver = __decorate([
|
|
112
|
+
exports.WebhookRequestTransformerResolver = WebhookRequestTransformerResolver = __decorate([
|
|
111
113
|
(0, graphql_1.Resolver)('Webhook'),
|
|
112
114
|
__metadata("design:paramtypes", [webhook_service_1.WebhookService])
|
|
113
115
|
], WebhookRequestTransformerResolver);
|
|
114
|
-
exports.WebhookRequestTransformerResolver = WebhookRequestTransformerResolver;
|
|
115
116
|
function mapToGraphqlTransformer(transformer) {
|
|
116
117
|
return {
|
|
117
118
|
name: transformer.name,
|
|
118
119
|
supportedEvents: transformer.supportedEvents.map((event) => event.name),
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
|
-
exports.mapToGraphqlTransformer = mapToGraphqlTransformer;
|
|
@@ -172,11 +172,11 @@ let WebhookService = class WebhookService {
|
|
|
172
172
|
core_2.Logger.info(`Successfully triggered webhook for event ${event.constructor.name} for channel ${webhook.channelId} with transformer "${webhook.transformerName}"`, constants_1.loggerCtx);
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
|
-
WebhookService =
|
|
175
|
+
exports.WebhookService = WebhookService;
|
|
176
|
+
exports.WebhookService = WebhookService = __decorate([
|
|
176
177
|
(0, common_1.Injectable)(),
|
|
177
178
|
__param(3, (0, common_1.Inject)(constants_1.PLUGIN_INIT_OPTIONS)),
|
|
178
179
|
__metadata("design:paramtypes", [core_2.EventBus,
|
|
179
180
|
core_2.TransactionalConnection,
|
|
180
181
|
core_1.ModuleRef, Object])
|
|
181
182
|
], WebhookService);
|
|
182
|
-
exports.WebhookService = WebhookService;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api/request-transformer"), exports);
|
|
17
18
|
__exportStar(require("./webhook.plugin"), exports);
|
package/dist/webhook.plugin.js
CHANGED
|
@@ -31,6 +31,7 @@ let WebhookPlugin = WebhookPlugin_1 = class WebhookPlugin {
|
|
|
31
31
|
return WebhookPlugin_1;
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
+
exports.WebhookPlugin = WebhookPlugin;
|
|
34
35
|
WebhookPlugin.options = {
|
|
35
36
|
events: [],
|
|
36
37
|
delay: 0,
|
|
@@ -51,13 +52,13 @@ WebhookPlugin.ui = {
|
|
|
51
52
|
},
|
|
52
53
|
],
|
|
53
54
|
};
|
|
54
|
-
WebhookPlugin = WebhookPlugin_1 = __decorate([
|
|
55
|
+
exports.WebhookPlugin = WebhookPlugin = WebhookPlugin_1 = __decorate([
|
|
55
56
|
(0, core_1.VendurePlugin)({
|
|
56
57
|
imports: [core_1.PluginCommonModule],
|
|
57
58
|
entities: [webhook_entity_1.Webhook],
|
|
58
59
|
providers: [
|
|
59
60
|
webhook_service_1.WebhookService,
|
|
60
|
-
{ provide: constants_1.PLUGIN_INIT_OPTIONS, useFactory: () =>
|
|
61
|
+
{ provide: constants_1.PLUGIN_INIT_OPTIONS, useFactory: () => WebhookPlugin.options },
|
|
61
62
|
],
|
|
62
63
|
adminApiExtensions: {
|
|
63
64
|
schema: api_extension_1.adminSchema,
|
|
@@ -70,4 +71,3 @@ WebhookPlugin = WebhookPlugin_1 = __decorate([
|
|
|
70
71
|
compatibility: '^2.0.0',
|
|
71
72
|
})
|
|
72
73
|
], WebhookPlugin);
|
|
73
|
-
exports.WebhookPlugin = WebhookPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pinelab/vendure-plugin-webhook",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Call webhooks based on configured events from Vendure",
|
|
5
5
|
"author": "Martijn van de Brug <martijn@pinelab.studio>",
|
|
6
6
|
"homepage": "https://pinelab-plugins.com/",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "yarn graphql-codegen && rimraf dist && tsc && copyfiles -u 1 'src/ui/**/*' dist/",
|
|
22
22
|
"start": "yarn ts-node test/dev-server.ts",
|
|
23
|
-
"test": "vitest run"
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"lint": "echo 'No linting configured'"
|
|
24
25
|
},
|
|
25
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "a4375f51797b974b3edfb15e6f68926e7ccebe96"
|
|
26
27
|
}
|