@spoosh/plugin-deduplication 0.2.1 → 0.3.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/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -3
- package/dist/index.mjs +4 -3
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _spoosh_core from '@spoosh/core';
|
|
2
2
|
|
|
3
3
|
type DedupeMode = "in-flight" | false;
|
|
4
4
|
type DeduplicationConfig = {
|
|
@@ -15,7 +15,7 @@ type DeduplicationWriteOptions = {
|
|
|
15
15
|
/** Override deduplication for this request. */
|
|
16
16
|
dedupe?: DedupeMode;
|
|
17
17
|
};
|
|
18
|
-
type
|
|
18
|
+
type DeduplicationPagesOptions = {
|
|
19
19
|
/** Override deduplication for this request. */
|
|
20
20
|
dedupe?: DedupeMode;
|
|
21
21
|
};
|
|
@@ -61,12 +61,12 @@ declare module "@spoosh/core" {
|
|
|
61
61
|
* });
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
|
-
declare function deduplicationPlugin(config?: DeduplicationConfig): SpooshPlugin<{
|
|
64
|
+
declare function deduplicationPlugin(config?: DeduplicationConfig): _spoosh_core.SpooshPlugin<{
|
|
65
65
|
readOptions: DeduplicationReadOptions;
|
|
66
66
|
writeOptions: DeduplicationWriteOptions;
|
|
67
|
-
|
|
67
|
+
pagesOptions: DeduplicationPagesOptions;
|
|
68
68
|
readResult: DeduplicationReadResult;
|
|
69
69
|
writeResult: DeduplicationWriteResult;
|
|
70
70
|
}>;
|
|
71
71
|
|
|
72
|
-
export { type DedupeMode, type DeduplicationConfig, type
|
|
72
|
+
export { type DedupeMode, type DeduplicationConfig, type DeduplicationPagesOptions, type DeduplicationReadOptions, type DeduplicationReadResult, type DeduplicationWriteOptions, type DeduplicationWriteResult, deduplicationPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _spoosh_core from '@spoosh/core';
|
|
2
2
|
|
|
3
3
|
type DedupeMode = "in-flight" | false;
|
|
4
4
|
type DeduplicationConfig = {
|
|
@@ -15,7 +15,7 @@ type DeduplicationWriteOptions = {
|
|
|
15
15
|
/** Override deduplication for this request. */
|
|
16
16
|
dedupe?: DedupeMode;
|
|
17
17
|
};
|
|
18
|
-
type
|
|
18
|
+
type DeduplicationPagesOptions = {
|
|
19
19
|
/** Override deduplication for this request. */
|
|
20
20
|
dedupe?: DedupeMode;
|
|
21
21
|
};
|
|
@@ -61,12 +61,12 @@ declare module "@spoosh/core" {
|
|
|
61
61
|
* });
|
|
62
62
|
* ```
|
|
63
63
|
*/
|
|
64
|
-
declare function deduplicationPlugin(config?: DeduplicationConfig): SpooshPlugin<{
|
|
64
|
+
declare function deduplicationPlugin(config?: DeduplicationConfig): _spoosh_core.SpooshPlugin<{
|
|
65
65
|
readOptions: DeduplicationReadOptions;
|
|
66
66
|
writeOptions: DeduplicationWriteOptions;
|
|
67
|
-
|
|
67
|
+
pagesOptions: DeduplicationPagesOptions;
|
|
68
68
|
readResult: DeduplicationReadResult;
|
|
69
69
|
writeResult: DeduplicationWriteResult;
|
|
70
70
|
}>;
|
|
71
71
|
|
|
72
|
-
export { type DedupeMode, type DeduplicationConfig, type
|
|
72
|
+
export { type DedupeMode, type DeduplicationConfig, type DeduplicationPagesOptions, type DeduplicationReadOptions, type DeduplicationReadResult, type DeduplicationWriteOptions, type DeduplicationWriteResult, deduplicationPlugin };
|
package/dist/index.js
CHANGED
|
@@ -25,15 +25,16 @@ __export(src_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(src_exports);
|
|
26
26
|
|
|
27
27
|
// src/plugin.ts
|
|
28
|
+
var import_core = require("@spoosh/core");
|
|
28
29
|
var PLUGIN_NAME = "spoosh:deduplication";
|
|
29
30
|
function deduplicationPlugin(config) {
|
|
30
31
|
const resolvedConfig = {
|
|
31
32
|
read: config?.read ?? "in-flight",
|
|
32
33
|
write: config?.write ?? false
|
|
33
34
|
};
|
|
34
|
-
return {
|
|
35
|
+
return (0, import_core.createSpooshPlugin)({
|
|
35
36
|
name: PLUGIN_NAME,
|
|
36
|
-
operations: ["read", "
|
|
37
|
+
operations: ["read", "pages", "write"],
|
|
37
38
|
middleware: async (context, next) => {
|
|
38
39
|
const et = context.eventTracer?.(PLUGIN_NAME);
|
|
39
40
|
const defaultMode = context.operationType === "write" ? resolvedConfig.write : resolvedConfig.read;
|
|
@@ -61,5 +62,5 @@ function deduplicationPlugin(config) {
|
|
|
61
62
|
return dedupeMode === "in-flight";
|
|
62
63
|
}
|
|
63
64
|
})
|
|
64
|
-
};
|
|
65
|
+
});
|
|
65
66
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// src/plugin.ts
|
|
2
|
+
import { createSpooshPlugin } from "@spoosh/core";
|
|
2
3
|
var PLUGIN_NAME = "spoosh:deduplication";
|
|
3
4
|
function deduplicationPlugin(config) {
|
|
4
5
|
const resolvedConfig = {
|
|
5
6
|
read: config?.read ?? "in-flight",
|
|
6
7
|
write: config?.write ?? false
|
|
7
8
|
};
|
|
8
|
-
return {
|
|
9
|
+
return createSpooshPlugin({
|
|
9
10
|
name: PLUGIN_NAME,
|
|
10
|
-
operations: ["read", "
|
|
11
|
+
operations: ["read", "pages", "write"],
|
|
11
12
|
middleware: async (context, next) => {
|
|
12
13
|
const et = context.eventTracer?.(PLUGIN_NAME);
|
|
13
14
|
const defaultMode = context.operationType === "write" ? resolvedConfig.write : resolvedConfig.read;
|
|
@@ -35,7 +36,7 @@ function deduplicationPlugin(config) {
|
|
|
35
36
|
return dedupeMode === "in-flight";
|
|
36
37
|
}
|
|
37
38
|
})
|
|
38
|
-
};
|
|
39
|
+
});
|
|
39
40
|
}
|
|
40
41
|
export {
|
|
41
42
|
deduplicationPlugin
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/plugin-deduplication",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Request deduplication plugin for Spoosh - prevents duplicate in-flight requests",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@spoosh/core": ">=0.
|
|
36
|
+
"@spoosh/core": ">=0.15.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@spoosh/core": "0.
|
|
40
|
-
"@spoosh/test-utils": "0.
|
|
39
|
+
"@spoosh/core": "0.15.1",
|
|
40
|
+
"@spoosh/test-utils": "0.3.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "tsup --watch",
|