@sprucelabs/mercury-chunking-emitter 2.0.2 → 2.1.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/build/chunkingEmitter/ChunkingEmitter.d.ts +1 -0
- package/build/chunkingEmitter/SingleChunkEmitter.d.ts +2 -0
- package/build/chunkingEmitter/SingleChunkEmitter.js +4 -6
- package/build/esm/chunkingEmitter/ChunkingEmitter.d.ts +1 -0
- package/build/esm/chunkingEmitter/SingleChunkEmitter.d.ts +2 -0
- package/build/esm/chunkingEmitter/SingleChunkEmitter.js +4 -6
- package/package.json +3 -3
|
@@ -23,6 +23,7 @@ export type ChunkingEmitterEmitOptions = {
|
|
|
23
23
|
items?: Record<string, any>[];
|
|
24
24
|
batchCursor?: BatchCursor<Record<string, any>>;
|
|
25
25
|
payloadKey: string;
|
|
26
|
+
payload?: Record<string, any>;
|
|
26
27
|
target?: Record<string, any>;
|
|
27
28
|
/** will kill any running operations that match the key */
|
|
28
29
|
uniqueKey?: string;
|
|
@@ -15,6 +15,7 @@ export default class SingleChunkEmitter {
|
|
|
15
15
|
private log;
|
|
16
16
|
totalErrors: number;
|
|
17
17
|
private isKilled;
|
|
18
|
+
private payload?;
|
|
18
19
|
constructor(options: SingleChunkEmitterOptions);
|
|
19
20
|
matchesKey(key: string): boolean;
|
|
20
21
|
getTotalErrors(): number;
|
|
@@ -27,6 +28,7 @@ interface SingleChunkEmitterOptions {
|
|
|
27
28
|
batchCursor?: BatchCursor<Record<string, any>>;
|
|
28
29
|
items?: Record<string, any>[];
|
|
29
30
|
payloadKey: string;
|
|
31
|
+
payload?: Record<string, any>;
|
|
30
32
|
target?: Record<string, any>;
|
|
31
33
|
eventName: EventName;
|
|
32
34
|
chunkSize: number;
|
|
@@ -12,7 +12,7 @@ class SingleChunkEmitter {
|
|
|
12
12
|
constructor(options) {
|
|
13
13
|
this.totalErrors = 0;
|
|
14
14
|
this.isKilled = false;
|
|
15
|
-
const { batchCursor: cursor, items, payloadKey, target, eventName, chunkSize, client, uniqueKey, log, } = options;
|
|
15
|
+
const { batchCursor: cursor, items, payloadKey, target, eventName, chunkSize, client, uniqueKey, log, payload, } = options;
|
|
16
16
|
this.cursor = cursor;
|
|
17
17
|
this.uniqueKey = uniqueKey;
|
|
18
18
|
this.items = items;
|
|
@@ -21,6 +21,7 @@ class SingleChunkEmitter {
|
|
|
21
21
|
this.eventName = eventName;
|
|
22
22
|
this.chunkSize = chunkSize;
|
|
23
23
|
this.client = client;
|
|
24
|
+
this.payload = payload;
|
|
24
25
|
this.log = log.buildLog('Emitter');
|
|
25
26
|
}
|
|
26
27
|
matchesKey(key) {
|
|
@@ -70,13 +71,10 @@ class SingleChunkEmitter {
|
|
|
70
71
|
async emitChunk(options) {
|
|
71
72
|
const { chunk, current } = options;
|
|
72
73
|
let targetAndPayload = {
|
|
73
|
-
payload: {
|
|
74
|
-
[this.payloadKey]: chunk,
|
|
75
|
-
chunk: {
|
|
74
|
+
payload: Object.assign(Object.assign({ [this.payloadKey]: chunk }, this.payload), { chunk: {
|
|
76
75
|
current,
|
|
77
76
|
total: this.total,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
77
|
+
} }),
|
|
80
78
|
};
|
|
81
79
|
if (this.target) {
|
|
82
80
|
targetAndPayload.target = this.target;
|
|
@@ -23,6 +23,7 @@ export type ChunkingEmitterEmitOptions = {
|
|
|
23
23
|
items?: Record<string, any>[];
|
|
24
24
|
batchCursor?: BatchCursor<Record<string, any>>;
|
|
25
25
|
payloadKey: string;
|
|
26
|
+
payload?: Record<string, any>;
|
|
26
27
|
target?: Record<string, any>;
|
|
27
28
|
/** will kill any running operations that match the key */
|
|
28
29
|
uniqueKey?: string;
|
|
@@ -15,6 +15,7 @@ export default class SingleChunkEmitter {
|
|
|
15
15
|
private log;
|
|
16
16
|
totalErrors: number;
|
|
17
17
|
private isKilled;
|
|
18
|
+
private payload?;
|
|
18
19
|
constructor(options: SingleChunkEmitterOptions);
|
|
19
20
|
matchesKey(key: string): boolean;
|
|
20
21
|
getTotalErrors(): number;
|
|
@@ -27,6 +28,7 @@ interface SingleChunkEmitterOptions {
|
|
|
27
28
|
batchCursor?: BatchCursor<Record<string, any>>;
|
|
28
29
|
items?: Record<string, any>[];
|
|
29
30
|
payloadKey: string;
|
|
31
|
+
payload?: Record<string, any>;
|
|
30
32
|
target?: Record<string, any>;
|
|
31
33
|
eventName: EventName;
|
|
32
34
|
chunkSize: number;
|
|
@@ -19,7 +19,7 @@ export default class SingleChunkEmitter {
|
|
|
19
19
|
constructor(options) {
|
|
20
20
|
this.totalErrors = 0;
|
|
21
21
|
this.isKilled = false;
|
|
22
|
-
const { batchCursor: cursor, items, payloadKey, target, eventName, chunkSize, client, uniqueKey, log, } = options;
|
|
22
|
+
const { batchCursor: cursor, items, payloadKey, target, eventName, chunkSize, client, uniqueKey, log, payload, } = options;
|
|
23
23
|
this.cursor = cursor;
|
|
24
24
|
this.uniqueKey = uniqueKey;
|
|
25
25
|
this.items = items;
|
|
@@ -28,6 +28,7 @@ export default class SingleChunkEmitter {
|
|
|
28
28
|
this.eventName = eventName;
|
|
29
29
|
this.chunkSize = chunkSize;
|
|
30
30
|
this.client = client;
|
|
31
|
+
this.payload = payload;
|
|
31
32
|
this.log = log.buildLog('Emitter');
|
|
32
33
|
}
|
|
33
34
|
matchesKey(key) {
|
|
@@ -82,13 +83,10 @@ export default class SingleChunkEmitter {
|
|
|
82
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
84
|
const { chunk, current } = options;
|
|
84
85
|
let targetAndPayload = {
|
|
85
|
-
payload: {
|
|
86
|
-
[this.payloadKey]: chunk,
|
|
87
|
-
chunk: {
|
|
86
|
+
payload: Object.assign(Object.assign({ [this.payloadKey]: chunk }, this.payload), { chunk: {
|
|
88
87
|
current,
|
|
89
88
|
total: this.total,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
89
|
+
} }),
|
|
92
90
|
};
|
|
93
91
|
if (this.target) {
|
|
94
92
|
targetAndPayload.target = this.target;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprucelabs/mercury-chunking-emitter",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"build/**/*",
|
|
6
6
|
"!build/__tests__",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@sprucelabs/jest-json-reporter": "^7.0.114",
|
|
44
44
|
"@sprucelabs/resolve-path-aliases": "^1.1.255",
|
|
45
45
|
"@sprucelabs/semantic-release": "^4.0.8",
|
|
46
|
-
"@sprucelabs/spruce-test-fixtures": "^60.1.
|
|
46
|
+
"@sprucelabs/spruce-test-fixtures": "^60.1.15",
|
|
47
47
|
"@sprucelabs/test": "^8.0.23",
|
|
48
48
|
"@sprucelabs/test-utils": "^4.0.64",
|
|
49
49
|
"@types/node": "^20.8.10",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@sprucelabs/data-stores": "^25.7.4",
|
|
90
|
-
"@sprucelabs/mercury-client": "^41.0.
|
|
90
|
+
"@sprucelabs/mercury-client": "^41.0.119",
|
|
91
91
|
"@sprucelabs/mercury-types": "^46.0.106",
|
|
92
92
|
"@sprucelabs/schema": "^29.0.75",
|
|
93
93
|
"@sprucelabs/spruce-core-schemas": "^39.0.112",
|