@yourrentals/cloudevent-publisher-nestjs 0.1.4 → 0.4.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 +53 -0
- package/index.cjs.d.ts +1 -0
- package/index.cjs.js +119 -0
- package/index.esm.js +111 -0
- package/package.json +8 -3
- package/src/index.d.ts +2 -0
- package/{lib → src/lib}/cloud-event-publisher-core.module.d.ts +1 -1
- package/{lib → src/lib}/cloud-event-publisher.module.d.ts +1 -1
- package/{lib → src/lib}/cloud-event-publisher.service.d.ts +1 -1
- package/index.d.ts +0 -2
- package/index.js +0 -110
- package/index.mjs +0 -23501
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @yourrentals/cloudevent-publisher-nestjs
|
|
2
|
+
|
|
3
|
+
This library defines a JS library to publish messages to the message bus.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add @yourrentals/cloudevent-publisher-nestjs
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { CloudeventPublisherModule } from '@yourrentals/cloudevent-publisher-nestjs';
|
|
15
|
+
|
|
16
|
+
@Injectable()
|
|
17
|
+
export class FeatureService {
|
|
18
|
+
constructor(private readonly publisher: CloudEventPublisherService) {}
|
|
19
|
+
|
|
20
|
+
async doSomething() {
|
|
21
|
+
await this.publisher.publish('my-event', {
|
|
22
|
+
data: {
|
|
23
|
+
foo: 'bar',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Module({
|
|
30
|
+
imports: [
|
|
31
|
+
CloudeventPublisherModule.forFeature({
|
|
32
|
+
topics: [
|
|
33
|
+
{
|
|
34
|
+
eventType: 'my-event',
|
|
35
|
+
topicArn: 'arn:aws:sns:eu-west-1:123456789012:my-topic',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
providers: [FeatureService],
|
|
41
|
+
})
|
|
42
|
+
export class FeatureModule {}
|
|
43
|
+
|
|
44
|
+
@Module({
|
|
45
|
+
imports: [
|
|
46
|
+
CloudeventPublisherModule.forRoot({
|
|
47
|
+
source: 'publisher',
|
|
48
|
+
}),
|
|
49
|
+
FeatureModule,
|
|
50
|
+
],
|
|
51
|
+
})
|
|
52
|
+
export class AppModule {}
|
|
53
|
+
```
|
package/index.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
package/index.cjs.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var common = require('@nestjs/common');
|
|
6
|
+
var cloudeventPublisherCore = require('@yourrentals/cloudevent-publisher-core');
|
|
7
|
+
|
|
8
|
+
/******************************************************************************
|
|
9
|
+
Copyright (c) Microsoft Corporation.
|
|
10
|
+
|
|
11
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
12
|
+
purpose with or without fee is hereby granted.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
15
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
18
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
+
***************************************************************************** */
|
|
22
|
+
|
|
23
|
+
function __decorate(decorators, target, key, desc) {
|
|
24
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
25
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
26
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
27
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function __param(paramIndex, decorator) {
|
|
31
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function __metadata(metadataKey, metadataValue) {
|
|
35
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
39
|
+
var e = new Error(message);
|
|
40
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
let CloudEventPublisherService = class CloudEventPublisherService {
|
|
44
|
+
constructor(publisher) {
|
|
45
|
+
this.publisher = publisher;
|
|
46
|
+
}
|
|
47
|
+
publish(eventType, message) {
|
|
48
|
+
return this.publisher.publish(eventType, message);
|
|
49
|
+
}
|
|
50
|
+
publishBatch(eventType, messages) {
|
|
51
|
+
return this.publisher.publishBatch(eventType, messages);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
CloudEventPublisherService = __decorate([
|
|
55
|
+
common.Injectable(),
|
|
56
|
+
__param(0, common.Inject(cloudeventPublisherCore.CloudEventPublisher)),
|
|
57
|
+
__metadata("design:paramtypes", [cloudeventPublisherCore.CloudEventPublisher])
|
|
58
|
+
], CloudEventPublisherService);
|
|
59
|
+
|
|
60
|
+
var CloudEventPublisherCoreModule_1;
|
|
61
|
+
let CloudEventPublisherCoreModule = CloudEventPublisherCoreModule_1 = class CloudEventPublisherCoreModule {
|
|
62
|
+
static forRoot(options) {
|
|
63
|
+
return {
|
|
64
|
+
module: CloudEventPublisherCoreModule_1,
|
|
65
|
+
global: true,
|
|
66
|
+
providers: [
|
|
67
|
+
{
|
|
68
|
+
provide: cloudeventPublisherCore.CloudEventPublisher,
|
|
69
|
+
useValue: new cloudeventPublisherCore.CloudEventPublisher(options),
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
exports: [cloudeventPublisherCore.CloudEventPublisher],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
CloudEventPublisherCoreModule = CloudEventPublisherCoreModule_1 = __decorate([
|
|
77
|
+
common.Global(),
|
|
78
|
+
common.Module({})
|
|
79
|
+
], CloudEventPublisherCoreModule);
|
|
80
|
+
|
|
81
|
+
var CloudEventPublisherModule_1;
|
|
82
|
+
exports.CloudEventPublisherModule = CloudEventPublisherModule_1 = class CloudEventPublisherModule {
|
|
83
|
+
static forRoot(options) {
|
|
84
|
+
return {
|
|
85
|
+
module: CloudEventPublisherModule_1,
|
|
86
|
+
imports: [CloudEventPublisherCoreModule.forRoot(options)],
|
|
87
|
+
exports: [CloudEventPublisherCoreModule],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
static forFeature(options) {
|
|
91
|
+
const providers = options.topics.map((topic) => ({
|
|
92
|
+
provide: `CLOUD_EVENT_PUBLISHER_TOPIC_${topic.eventType}`,
|
|
93
|
+
useFactory: (publisher) => {
|
|
94
|
+
publisher.addTopic(topic.eventType, topic.topicArn);
|
|
95
|
+
return publisher;
|
|
96
|
+
},
|
|
97
|
+
inject: [cloudeventPublisherCore.CloudEventPublisher],
|
|
98
|
+
}));
|
|
99
|
+
return {
|
|
100
|
+
module: CloudEventPublisherModule_1,
|
|
101
|
+
imports: [CloudEventPublisherCoreModule],
|
|
102
|
+
providers: [...providers],
|
|
103
|
+
exports: [],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
exports.CloudEventPublisherModule = CloudEventPublisherModule_1 = __decorate([
|
|
108
|
+
common.Module({
|
|
109
|
+
providers: [CloudEventPublisherService],
|
|
110
|
+
exports: [CloudEventPublisherService],
|
|
111
|
+
})
|
|
112
|
+
], exports.CloudEventPublisherModule);
|
|
113
|
+
|
|
114
|
+
Object.keys(cloudeventPublisherCore).forEach(function (k) {
|
|
115
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () { return cloudeventPublisherCore[k]; }
|
|
118
|
+
});
|
|
119
|
+
});
|
package/index.esm.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Injectable, Inject, Global, Module } from '@nestjs/common';
|
|
2
|
+
import { CloudEventPublisher } from '@yourrentals/cloudevent-publisher-core';
|
|
3
|
+
export * from '@yourrentals/cloudevent-publisher-core';
|
|
4
|
+
|
|
5
|
+
/******************************************************************************
|
|
6
|
+
Copyright (c) Microsoft Corporation.
|
|
7
|
+
|
|
8
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
+
purpose with or without fee is hereby granted.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
+
***************************************************************************** */
|
|
19
|
+
|
|
20
|
+
function __decorate(decorators, target, key, desc) {
|
|
21
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
22
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
23
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
24
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function __param(paramIndex, decorator) {
|
|
28
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function __metadata(metadataKey, metadataValue) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
36
|
+
var e = new Error(message);
|
|
37
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
let CloudEventPublisherService = class CloudEventPublisherService {
|
|
41
|
+
constructor(publisher) {
|
|
42
|
+
this.publisher = publisher;
|
|
43
|
+
}
|
|
44
|
+
publish(eventType, message) {
|
|
45
|
+
return this.publisher.publish(eventType, message);
|
|
46
|
+
}
|
|
47
|
+
publishBatch(eventType, messages) {
|
|
48
|
+
return this.publisher.publishBatch(eventType, messages);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
CloudEventPublisherService = __decorate([
|
|
52
|
+
Injectable(),
|
|
53
|
+
__param(0, Inject(CloudEventPublisher)),
|
|
54
|
+
__metadata("design:paramtypes", [CloudEventPublisher])
|
|
55
|
+
], CloudEventPublisherService);
|
|
56
|
+
|
|
57
|
+
var CloudEventPublisherCoreModule_1;
|
|
58
|
+
let CloudEventPublisherCoreModule = CloudEventPublisherCoreModule_1 = class CloudEventPublisherCoreModule {
|
|
59
|
+
static forRoot(options) {
|
|
60
|
+
return {
|
|
61
|
+
module: CloudEventPublisherCoreModule_1,
|
|
62
|
+
global: true,
|
|
63
|
+
providers: [
|
|
64
|
+
{
|
|
65
|
+
provide: CloudEventPublisher,
|
|
66
|
+
useValue: new CloudEventPublisher(options),
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
exports: [CloudEventPublisher],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
CloudEventPublisherCoreModule = CloudEventPublisherCoreModule_1 = __decorate([
|
|
74
|
+
Global(),
|
|
75
|
+
Module({})
|
|
76
|
+
], CloudEventPublisherCoreModule);
|
|
77
|
+
|
|
78
|
+
var CloudEventPublisherModule_1;
|
|
79
|
+
let CloudEventPublisherModule = CloudEventPublisherModule_1 = class CloudEventPublisherModule {
|
|
80
|
+
static forRoot(options) {
|
|
81
|
+
return {
|
|
82
|
+
module: CloudEventPublisherModule_1,
|
|
83
|
+
imports: [CloudEventPublisherCoreModule.forRoot(options)],
|
|
84
|
+
exports: [CloudEventPublisherCoreModule],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
static forFeature(options) {
|
|
88
|
+
const providers = options.topics.map((topic) => ({
|
|
89
|
+
provide: `CLOUD_EVENT_PUBLISHER_TOPIC_${topic.eventType}`,
|
|
90
|
+
useFactory: (publisher) => {
|
|
91
|
+
publisher.addTopic(topic.eventType, topic.topicArn);
|
|
92
|
+
return publisher;
|
|
93
|
+
},
|
|
94
|
+
inject: [CloudEventPublisher],
|
|
95
|
+
}));
|
|
96
|
+
return {
|
|
97
|
+
module: CloudEventPublisherModule_1,
|
|
98
|
+
imports: [CloudEventPublisherCoreModule],
|
|
99
|
+
providers: [...providers],
|
|
100
|
+
exports: [],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
CloudEventPublisherModule = CloudEventPublisherModule_1 = __decorate([
|
|
105
|
+
Module({
|
|
106
|
+
providers: [CloudEventPublisherService],
|
|
107
|
+
exports: [CloudEventPublisherService],
|
|
108
|
+
})
|
|
109
|
+
], CloudEventPublisherModule);
|
|
110
|
+
|
|
111
|
+
export { CloudEventPublisherModule };
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yourrentals/cloudevent-publisher-nestjs",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"dependencies": {
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@yourrentals/cloudevent-publisher-core": "0.4.1"
|
|
6
|
+
},
|
|
5
7
|
"peerDependencies": {
|
|
6
8
|
"@nestjs/common": "^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0"
|
|
7
|
-
}
|
|
9
|
+
},
|
|
10
|
+
"type": "commonjs",
|
|
11
|
+
"main": "./index.cjs.js",
|
|
12
|
+
"module": "./index.esm.js"
|
|
8
13
|
}
|
package/src/index.d.ts
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { CloudEventPublisherOptions } from '@
|
|
2
|
+
import { CloudEventPublisherOptions } from '@yourrentals/cloudevent-publisher-core';
|
|
3
3
|
export declare class CloudEventPublisherCoreModule {
|
|
4
4
|
static forRoot(options: CloudEventPublisherOptions): DynamicModule;
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { CloudEventPublisherOptions } from '@
|
|
2
|
+
import { CloudEventPublisherOptions } from '@yourrentals/cloudevent-publisher-core';
|
|
3
3
|
export declare class CloudEventPublisherModule {
|
|
4
4
|
static forRoot(options: CloudEventPublisherOptions): DynamicModule;
|
|
5
5
|
static forFeature(options: Pick<CloudEventPublisherOptions, 'topics'>): DynamicModule;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CloudEventWithFIFOAttributes, CloudEventPublisher } from '@
|
|
1
|
+
import { CloudEventWithFIFOAttributes, CloudEventPublisher } from '@yourrentals/cloudevent-publisher-core';
|
|
2
2
|
export declare class CloudEventPublisherService {
|
|
3
3
|
private readonly publisher;
|
|
4
4
|
constructor(publisher: CloudEventPublisher);
|
package/index.d.ts
DELETED