koatty_cacheable 1.2.11 → 1.3.6
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/.eslintrc.js +2 -1
- package/CHANGELOG.md +3 -9
- package/LICENSE +1 -1
- package/babel.config.js +0 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +28 -101
- package/dist/index.js.map +1 -1
- package/jest.config.js +9 -2
- package/jest_html_reporters.html +1 -1
- package/package.json +16 -18
- package/target/npmlist.json +1 -0
- package/tsconfig.json +4 -4
package/.eslintrc.js
CHANGED
|
@@ -22,12 +22,13 @@ module.exports = {
|
|
|
22
22
|
},
|
|
23
23
|
rules: {
|
|
24
24
|
"@typescript-eslint/no-explicit-any": "off",
|
|
25
|
-
"@typescript-eslint/no-require-imports": "off",
|
|
25
|
+
// "@typescript-eslint/no-require-imports": "off",
|
|
26
26
|
"@typescript-eslint/no-var-requires": "off",
|
|
27
27
|
"@typescript-eslint/member-ordering": "off",
|
|
28
28
|
"@typescript-eslint/consistent-type-assertions": "off",
|
|
29
29
|
"@typescript-eslint/no-param-reassign": "off",
|
|
30
30
|
"@typescript-eslint/no-empty-function": "off",
|
|
31
|
+
"@typescript-eslint/no-empty-interface": "off",
|
|
31
32
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
32
33
|
"@typescript-eslint/ban-types": ["error",
|
|
33
34
|
{
|
package/CHANGELOG.md
CHANGED
|
@@ -2,14 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
### [1.
|
|
5
|
+
### [1.3.6](https://github.com/thinkkoa/koatty_cacheable/compare/v1.3.4...v1.3.6) (2021-12-02)
|
|
6
6
|
|
|
7
|
-
### [1.
|
|
7
|
+
### [1.3.4](https://github.com/thinkkoa/koatty_cacheable/compare/v1.3.2...v1.3.4) (2021-11-23)
|
|
8
8
|
|
|
9
|
-
### [1.2
|
|
10
|
-
|
|
11
|
-
### [1.2.5](https://github.com/thinkkoa/koatty_cacheable/compare/v1.2.4...v1.2.5) (2021-06-29)
|
|
12
|
-
|
|
13
|
-
### [1.2.4](https://github.com/thinkkoa/koatty_cacheable/compare/v1.2.3...v1.2.4) (2021-06-23)
|
|
14
|
-
|
|
15
|
-
### 1.2.3 (2021-06-23)
|
|
9
|
+
### [1.3.2](https://github.com/thinkkoa/koatty_cacheable/compare/v1.2.12...v1.3.2) (2021-11-20)
|
package/LICENSE
CHANGED
package/babel.config.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Description : babel配置
|
|
3
3
|
* @usage : 用于jest执行用例
|
|
4
|
-
* @Date : 2020-10-19 23:08:40
|
|
5
|
-
* @Author : fankerwang<fankerwang@tencent.com>
|
|
6
|
-
* @LastEditors : fankerwang<fankerwang@tencent.com>
|
|
7
|
-
* @LastEditTime : 2021-05-21 20:27:11
|
|
8
|
-
* @FilePath : /tkoatty/babel.config.js
|
|
9
4
|
*/
|
|
10
5
|
|
|
11
6
|
module.exports = {
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { Application } from 'koatty_container';
|
|
|
4
4
|
* get instances of cacheStore
|
|
5
5
|
*
|
|
6
6
|
* @export
|
|
7
|
-
* @
|
|
7
|
+
* @param {Application} app
|
|
8
|
+
* @returns {*} {CacheStore}
|
|
8
9
|
*/
|
|
9
10
|
export declare function GetCacheStore(app: Application): Promise<CacheStore>;
|
|
10
11
|
/**
|
|
@@ -14,11 +15,10 @@ export declare function GetCacheStore(app: Application): Promise<CacheStore>;
|
|
|
14
15
|
*
|
|
15
16
|
* @export
|
|
16
17
|
* @param {string} cacheName cache name
|
|
17
|
-
* @param {(number | number[])} [paramKey] The index of the arguments.
|
|
18
18
|
* @param {number} [timeout=3600] cache timeout
|
|
19
19
|
* @returns {MethodDecorator}
|
|
20
20
|
*/
|
|
21
|
-
export declare function CacheAble(cacheName: string,
|
|
21
|
+
export declare function CacheAble(cacheName: string, timeout?: number): MethodDecorator;
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
@@ -28,8 +28,7 @@ export declare type eventTimes = "Before" | "After";
|
|
|
28
28
|
*
|
|
29
29
|
* @export
|
|
30
30
|
* @param {string} cacheName cacheName cache name
|
|
31
|
-
* @param {(number | number[])} [paramKey] The index of the arguments.
|
|
32
31
|
* @param {eventTimes} [eventTime="Before"]
|
|
33
32
|
* @returns
|
|
34
33
|
*/
|
|
35
|
-
export declare function CacheEvict(cacheName: string,
|
|
34
|
+
export declare function CacheEvict(cacheName: string, eventTime?: eventTimes): (target: any, methodName: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
package/dist/index.js
CHANGED
|
@@ -5,11 +5,11 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
/*
|
|
6
6
|
* @Author: richen
|
|
7
7
|
* @Date: 2020-07-06 19:53:43
|
|
8
|
-
* @LastEditTime: 2021-
|
|
8
|
+
* @LastEditTime: 2021-12-02 16:20:52
|
|
9
9
|
* @Description:
|
|
10
10
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
11
11
|
*/
|
|
12
|
-
const helper = tslib_1.__importStar(require("koatty_lib"));
|
|
12
|
+
const helper = (0, tslib_1.__importStar)(require("koatty_lib"));
|
|
13
13
|
const koatty_logger_1 = require("koatty_logger");
|
|
14
14
|
const koatty_store_1 = require("koatty_store");
|
|
15
15
|
const koatty_container_1 = require("koatty_container");
|
|
@@ -21,7 +21,8 @@ const cacheStore = {
|
|
|
21
21
|
* get instances of cacheStore
|
|
22
22
|
*
|
|
23
23
|
* @export
|
|
24
|
-
* @
|
|
24
|
+
* @param {Application} app
|
|
25
|
+
* @returns {*} {CacheStore}
|
|
25
26
|
*/
|
|
26
27
|
async function GetCacheStore(app) {
|
|
27
28
|
var _a;
|
|
@@ -42,11 +43,12 @@ exports.GetCacheStore = GetCacheStore;
|
|
|
42
43
|
/**
|
|
43
44
|
* initiation CacheStore connection and client.
|
|
44
45
|
*
|
|
45
|
-
* @param {Application} app
|
|
46
|
-
* @returns {*} {Promise<CacheStore>}
|
|
47
46
|
*/
|
|
48
|
-
async function InitCacheStore(
|
|
49
|
-
|
|
47
|
+
async function InitCacheStore() {
|
|
48
|
+
const app = koatty_container_1.IOCContainer.getApp();
|
|
49
|
+
app && app.once("appStart", async function () {
|
|
50
|
+
await GetCacheStore(app);
|
|
51
|
+
});
|
|
50
52
|
}
|
|
51
53
|
/**
|
|
52
54
|
* Decorate this method to support caching. Redis server config from db.ts.
|
|
@@ -55,11 +57,10 @@ async function InitCacheStore(app) {
|
|
|
55
57
|
*
|
|
56
58
|
* @export
|
|
57
59
|
* @param {string} cacheName cache name
|
|
58
|
-
* @param {(number | number[])} [paramKey] The index of the arguments.
|
|
59
60
|
* @param {number} [timeout=3600] cache timeout
|
|
60
61
|
* @returns {MethodDecorator}
|
|
61
62
|
*/
|
|
62
|
-
function CacheAble(cacheName,
|
|
63
|
+
function CacheAble(cacheName, timeout = 3600) {
|
|
63
64
|
return (target, methodName, descriptor) => {
|
|
64
65
|
const componentType = koatty_container_1.IOCContainer.getType(target);
|
|
65
66
|
if (componentType !== "SERVICE" && componentType !== "COMPONENT") {
|
|
@@ -82,56 +83,25 @@ function CacheAble(cacheName, paramKey, timeout = 3600) {
|
|
|
82
83
|
if (cacheFlag) {
|
|
83
84
|
// tslint:disable-next-line: one-variable-per-declaration
|
|
84
85
|
let key = "", res;
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
if (!helper.isTrueEmpty(props[it])) {
|
|
88
|
-
if (typeof props[it] === "object") {
|
|
89
|
-
key = `${key}${helper.murmurHash(JSON.stringify(props[it]))}`;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
key = `${key}${props[it] || ''}`;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
else if (helper.isNumber(paramKey)) {
|
|
98
|
-
if (typeof props[paramKey] === "object") {
|
|
99
|
-
key = helper.murmurHash(JSON.stringify(props[paramKey]));
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
key = props[paramKey] || "";
|
|
103
|
-
}
|
|
86
|
+
if (props && props.length > 0) {
|
|
87
|
+
key = `${identifier}:${methodName}:${helper.murmurHash(JSON.stringify(props))}`;
|
|
104
88
|
}
|
|
105
89
|
else {
|
|
106
90
|
key = `${identifier}:${methodName}`;
|
|
107
91
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
else {
|
|
112
|
-
res = await store.get(cacheName).catch(() => null);
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
res = JSON.parse(res || "");
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
res = null;
|
|
92
|
+
res = await store.hget(cacheName, key).catch(() => null);
|
|
93
|
+
if (!helper.isEmpty(res)) {
|
|
94
|
+
return JSON.parse(res);
|
|
119
95
|
}
|
|
96
|
+
// tslint:disable-next-line: no-invalid-this
|
|
97
|
+
res = await value.apply(this, props);
|
|
98
|
+
// prevent cache penetration
|
|
120
99
|
if (helper.isEmpty(res)) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// prevent cache penetration
|
|
124
|
-
if (helper.isEmpty(res)) {
|
|
125
|
-
res = "";
|
|
126
|
-
timeout = 60;
|
|
127
|
-
}
|
|
128
|
-
if (!helper.isTrueEmpty(key)) {
|
|
129
|
-
store.set(`${cacheName}:${key}`, JSON.stringify(res), timeout).catch(() => null);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
store.set(cacheName, JSON.stringify(res), timeout).catch(() => null);
|
|
133
|
-
}
|
|
100
|
+
res = "";
|
|
101
|
+
timeout = 60;
|
|
134
102
|
}
|
|
103
|
+
// async set store
|
|
104
|
+
store.hset(cacheName, key, JSON.stringify(res), timeout).catch(() => null);
|
|
135
105
|
return res;
|
|
136
106
|
}
|
|
137
107
|
else {
|
|
@@ -141,31 +111,20 @@ function CacheAble(cacheName, paramKey, timeout = 3600) {
|
|
|
141
111
|
}
|
|
142
112
|
};
|
|
143
113
|
// bind app_ready hook event
|
|
144
|
-
|
|
114
|
+
InitCacheStore();
|
|
145
115
|
return descriptor;
|
|
146
116
|
};
|
|
147
117
|
}
|
|
148
118
|
exports.CacheAble = CacheAble;
|
|
149
|
-
/**
|
|
150
|
-
* bind scheduler lock init event
|
|
151
|
-
*
|
|
152
|
-
*/
|
|
153
|
-
const bindSchedulerLockInit = function () {
|
|
154
|
-
const app = koatty_container_1.IOCContainer.getApp();
|
|
155
|
-
app && app.once("appStart", async function () {
|
|
156
|
-
await InitCacheStore(app);
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
119
|
/**
|
|
160
120
|
* Decorating the execution of this method will trigger a cache clear operation. Redis server config from db.ts.
|
|
161
121
|
*
|
|
162
122
|
* @export
|
|
163
123
|
* @param {string} cacheName cacheName cache name
|
|
164
|
-
* @param {(number | number[])} [paramKey] The index of the arguments.
|
|
165
124
|
* @param {eventTimes} [eventTime="Before"]
|
|
166
125
|
* @returns
|
|
167
126
|
*/
|
|
168
|
-
function CacheEvict(cacheName,
|
|
127
|
+
function CacheEvict(cacheName, eventTime = "Before") {
|
|
169
128
|
return (target, methodName, descriptor) => {
|
|
170
129
|
const componentType = koatty_container_1.IOCContainer.getType(target);
|
|
171
130
|
if (componentType !== "SERVICE" && componentType !== "COMPONENT") {
|
|
@@ -185,49 +144,15 @@ function CacheEvict(cacheName, paramKey, eventTime = "Before") {
|
|
|
185
144
|
return null;
|
|
186
145
|
});
|
|
187
146
|
if (cacheFlag) {
|
|
188
|
-
let key = "";
|
|
189
|
-
if (helper.isArray(paramKey)) {
|
|
190
|
-
paramKey.map((it) => {
|
|
191
|
-
if (!helper.isTrueEmpty(props[it])) {
|
|
192
|
-
if (typeof props[it] === "object") {
|
|
193
|
-
key = `${key}${helper.murmurHash(JSON.stringify(props[it]))}`;
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
key = `${key}${props[it] || ''}`;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
else if (helper.isNumber(paramKey)) {
|
|
202
|
-
if (typeof props[paramKey] === "object") {
|
|
203
|
-
key = helper.murmurHash(JSON.stringify(props[paramKey]));
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
key = props[paramKey] || "";
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
key = `${identifier}:${methodName}`;
|
|
211
|
-
}
|
|
212
147
|
if (eventTime === "Before") {
|
|
213
|
-
|
|
214
|
-
await store.del(`${cacheName}:${key}`).catch(() => null);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
await store.del(cacheName).catch(() => null);
|
|
218
|
-
}
|
|
148
|
+
await store.del(cacheName).catch(() => null);
|
|
219
149
|
// tslint:disable-next-line: no-invalid-this
|
|
220
150
|
return value.apply(this, props);
|
|
221
151
|
}
|
|
222
152
|
else {
|
|
223
153
|
// tslint:disable-next-line: no-invalid-this
|
|
224
154
|
const res = await value.apply(this, props);
|
|
225
|
-
|
|
226
|
-
await store.del(`${cacheName}:${key}`).catch(() => null);
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
await store.del(cacheName).catch(() => null);
|
|
230
|
-
}
|
|
155
|
+
store.del(cacheName).catch(() => null);
|
|
231
156
|
return res;
|
|
232
157
|
}
|
|
233
158
|
}
|
|
@@ -237,6 +162,8 @@ function CacheEvict(cacheName, paramKey, eventTime = "Before") {
|
|
|
237
162
|
}
|
|
238
163
|
}
|
|
239
164
|
};
|
|
165
|
+
// bind app_ready hook event
|
|
166
|
+
InitCacheStore();
|
|
240
167
|
return descriptor;
|
|
241
168
|
};
|
|
242
169
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA;;;;;;GAMG;AACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA;;;;;;GAMG;AACH,gEAAqC;AACrC,iDAAwD;AACxD,+CAA+D;AAC/D,uDAA6D;AAW7D,aAAa;AACb,MAAM,UAAU,GAAwB;IACpC,KAAK,EAAE,IAAI;CACd,CAAC;AAEF;;;;;;GAMG;AACI,KAAK,UAAU,aAAa,CAAC,GAAgB;;IAChD,IAAI,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,aAAa,EAAE;QACpD,OAAO,UAAU,CAAC,KAAK,CAAC;KAC3B;IACD,MAAM,GAAG,GAAiB,MAAA,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,mCAAI,EAAE,CAAC;IAC/D,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACrB,6BAAM,CAAC,IAAI,CAAC,8HAA8H,CAAC,CAAC;KAC/I;IACD,UAAU,CAAC,KAAK,GAAG,oBAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC1C,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE;QACpD,MAAM,KAAK,CAAC,gCAAgC,CAAC,CAAC;KACjD;IACD,OAAO,UAAU,CAAC,KAAK,CAAC;AAC5B,CAAC;AAbD,sCAaC;AAED;;;GAGG;AACH,KAAK,UAAU,cAAc;IACzB,MAAM,GAAG,GAAG,+BAAY,CAAC,MAAM,EAAE,CAAC;IAClC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK;QAC7B,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAA;AACN,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,SAAS,CAAC,SAAiB,EAAE,OAAO,GAAG,IA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AC;QACjB,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC;AAzCD,gCAyCC"}
|
package/jest.config.js
CHANGED
|
@@ -14,14 +14,21 @@ module.exports = {
|
|
|
14
14
|
'jest-html-reporters'
|
|
15
15
|
], // 测试用例报告
|
|
16
16
|
collectCoverage: true, // 是否收集测试时的覆盖率信息
|
|
17
|
-
coverageReporters: [
|
|
17
|
+
coverageReporters: [
|
|
18
|
+
'html',
|
|
19
|
+
'lcov',
|
|
20
|
+
'json',
|
|
21
|
+
'text',
|
|
22
|
+
'clover',
|
|
23
|
+
'text-summary',
|
|
24
|
+
], // 收集测试时的覆盖率信息
|
|
18
25
|
// 将 `ts-jest` 的配置注入到运行时的全局变量中
|
|
19
26
|
globals: {
|
|
20
27
|
'ts-jest': {
|
|
21
28
|
// 是否使用 babel 配置来转译
|
|
22
29
|
babelConfig: true,
|
|
23
30
|
// 编译 Typescript 所依赖的配置
|
|
24
|
-
|
|
31
|
+
tsconfig: '<rootDir>/tsconfig.json',
|
|
25
32
|
// 是否启用报告诊断,这里是不启用
|
|
26
33
|
diagnostics: false,
|
|
27
34
|
},
|
package/jest_html_reporters.html
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Type" content="text/html;charset=utf-8"><meta name="keywords" contect="jest, reporters"><meta name="author" contect="hazyzh"><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1,maximum-scale=1"><link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAHX0lEQVR4Xu2bfWwUVRDAZ/buSsG0Vxq1EAhtL/e2kKISAVEoKJVE4gfiR6wmJsoflpBANLZKqyRIgVg+/CLBNqKoMX5RKWhFsUbRBuJHRCoECLt7x0Jb5IBmr62tx+3dPrNH93Itd7e7xx0ccu+/dmfmzfz2vXmzu3MI1/jAazx+yADIrIBrnMDl2gK4at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BAzx+jAFQ7DMuyjQDwjJ7RK3mdUtrA8/xStXQx4ocZACF76o8lrFbrKkrp3Yg4wsgkqZahlJ5Xu9kDgcBKt9utNnYbHqYBRFi2OZ3OaYhYRCktZBgmod8FGfZ0mCCldEB950IpPS4Ighq0sUbkRJJgok5eDXqXsgKuhvh0fcwA0EX0Pxf4Dws8WYyVxouxAAAAAElFTkSuQmCC"></head><title>Report</title><body><div id="app"></div><textarea style="display: none;" id="resData">
|
|
2
|
-
"{\"numFailedTestSuites\":0,\"numFailedTests\":0,\"numPassedTestSuites\":0,\"numPassedTests\":0,\"numPendingTestSuites\":0,\"numPendingTests\":0,\"numRuntimeErrorTestSuites\":0,\"numTodoTests\":0,\"numTotalTestSuites\":0,\"numTotalTests\":0,\"openHandles\":[],\"snapshot\":{\"added\":0,\"didUpdate\":false,\"failure\":false,\"filesAdded\":0,\"filesRemoved\":0,\"filesRemovedList\":[],\"filesUnmatched\":0,\"filesUpdated\":0,\"matched\":0,\"total\":0,\"unchecked\":0,\"uncheckedKeysByFile\":[],\"unmatched\":0,\"updated\":0},\"startTime\":
|
|
2
|
+
"{\"numFailedTestSuites\":0,\"numFailedTests\":0,\"numPassedTestSuites\":0,\"numPassedTests\":0,\"numPendingTestSuites\":0,\"numPendingTests\":0,\"numRuntimeErrorTestSuites\":0,\"numTodoTests\":0,\"numTotalTestSuites\":0,\"numTotalTests\":0,\"openHandles\":[],\"snapshot\":{\"added\":0,\"didUpdate\":false,\"failure\":false,\"filesAdded\":0,\"filesRemoved\":0,\"filesRemovedList\":[],\"filesUnmatched\":0,\"filesUpdated\":0,\"matched\":0,\"total\":0,\"unchecked\":0,\"uncheckedKeysByFile\":[],\"unmatched\":0,\"updated\":0},\"startTime\":1638433451851,\"success\":false,\"testResults\":[],\"wasInterrupted\":false,\"coverageMap\":{},\"config\":{\"bail\":0,\"changedFilesWithAncestor\":false,\"collectCoverage\":true,\"collectCoverageFrom\":[],\"coverageDirectory\":\"/Users/richen/Workspace/nodejs/koatty_cacheable/coverage\",\"coverageProvider\":\"babel\",\"coverageReporters\":[\"html\",\"lcov\",\"json\",\"text\",\"clover\",\"text-summary\"],\"detectLeaks\":false,\"detectOpenHandles\":false,\"errorOnDeprecated\":false,\"expand\":false,\"findRelatedTests\":false,\"forceExit\":false,\"json\":false,\"lastCommit\":false,\"listTests\":false,\"logHeapUsage\":false,\"maxConcurrency\":5,\"maxWorkers\":7,\"noStackTrace\":false,\"nonFlagArgs\":[],\"notify\":false,\"notifyMode\":\"failure-change\",\"onlyChanged\":false,\"onlyFailures\":false,\"passWithNoTests\":true,\"projects\":[],\"reporters\":[[\"default\",{}],[\"/Users/richen/Workspace/nodejs/koatty_cacheable/node_modules/jest-html-reporters/index.js\",{}]],\"rootDir\":\"/Users/richen/Workspace/nodejs/koatty_cacheable\",\"runTestsByPath\":false,\"skipFilter\":false,\"testFailureExitCode\":1,\"testPathPattern\":\"\",\"testSequencer\":\"/Users/richen/Workspace/nodejs/koatty_cacheable/node_modules/@jest/test-sequencer/build/index.js\",\"updateSnapshot\":\"new\",\"useStderr\":false,\"watch\":false,\"watchAll\":false,\"watchman\":true},\"endTime\":1638433451897,\"_reporterOptions\":{\"publicPath\":\"/Users/richen/Workspace/nodejs/koatty_cacheable\",\"filename\":\"jest_html_reporters.html\",\"expand\":false,\"pageTitle\":\"\",\"hideIcon\":false,\"testCommand\":\"npx jest\",\"openReport\":false,\"multipleReportsUnitePath\":\"\",\"failureMessageOnly\":false,\"enableMergeData\":false,\"dataMergeLevel\":1},\"attachInfos\":{}}"
|
|
3
3
|
</textarea><script>/*! Copyright Harry All rights reserved. */!function(n){var r={};function o(t){if(r[t])return r[t].exports;var e=r[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}o.m=n,o.c=r,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=1103)}([function(t,e,n){"use strict";t.exports=n(447)},function(t,e,n){t.exports=n(905)()},function(t,e,n){var r;
|
|
4
4
|
/*!
|
|
5
5
|
Copyright (c) 2017 Jed Watson.
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koatty_cacheable",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Cacheable for koatty.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "del-cli --force dist && tsc",
|
|
7
7
|
"eslint": "eslint --ext .ts,.js ./",
|
|
8
8
|
"prepublishOnly": "npm test && npm run build",
|
|
9
|
-
"release": "npm run
|
|
9
|
+
"release": "npm run prepublishOnly && standard-version",
|
|
10
|
+
"pub": "git push --follow-tags origin && npm publish",
|
|
10
11
|
"test": "npm run eslint && jest --passWithNoTests",
|
|
11
12
|
"test:cov": "jest --collectCoverage --detectOpenHandles",
|
|
12
13
|
"version": "conventional-changelog -p angular -i CHANGELOG.md -s"
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"name": "richenlin",
|
|
30
31
|
"email": "richenlin@gmail.com"
|
|
31
32
|
},
|
|
32
|
-
"license": "
|
|
33
|
+
"license": "BSD-3-Clause",
|
|
33
34
|
"bugs": {
|
|
34
35
|
"url": "https://github.com/thinkkoa/koatty_cacheable/issues"
|
|
35
36
|
},
|
|
@@ -46,22 +47,19 @@
|
|
|
46
47
|
"@babel/preset-env": "^7.x.x",
|
|
47
48
|
"@babel/preset-typescript": "^7.x.x",
|
|
48
49
|
"@commitlint/cli": "^12.x.x",
|
|
49
|
-
"@commitlint/config-conventional": "^
|
|
50
|
-
"@types/
|
|
51
|
-
"@types/
|
|
52
|
-
"@types/
|
|
53
|
-
"@
|
|
54
|
-
"@typescript-eslint/
|
|
55
|
-
"@typescript-eslint/parser": "^4.x.x",
|
|
50
|
+
"@commitlint/config-conventional": "^15.x.x",
|
|
51
|
+
"@types/jest": "^27.x.x",
|
|
52
|
+
"@types/koa": "^2.x.x",
|
|
53
|
+
"@types/node": "^16.x.x",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^5.x.x",
|
|
55
|
+
"@typescript-eslint/parser": "^5.x.x",
|
|
56
56
|
"conventional-changelog-cli": "^2.x.x",
|
|
57
|
-
"del-cli": "^
|
|
58
|
-
"eslint": "^
|
|
59
|
-
"eslint-plugin-jest": "^
|
|
60
|
-
"husky": "^
|
|
61
|
-
"jest": "^27.
|
|
57
|
+
"del-cli": "^4.x.x",
|
|
58
|
+
"eslint": "^8.x.x",
|
|
59
|
+
"eslint-plugin-jest": "^25.x.x",
|
|
60
|
+
"husky": "^7.x.x",
|
|
61
|
+
"jest": "^27.x.x",
|
|
62
62
|
"jest-html-reporters": "^2.x.x",
|
|
63
|
-
"koatty_cacheable": "^1.x.x",
|
|
64
|
-
"koatty_schedule": "^1.x.x",
|
|
65
63
|
"standard-version": "^9.x.x",
|
|
66
64
|
"ts-jest": "^27.x.x",
|
|
67
65
|
"ts-node": "^10.x.x",
|
|
@@ -72,7 +70,7 @@
|
|
|
72
70
|
"koatty_lib": "^1.x.x",
|
|
73
71
|
"koatty_logger": "^1.x.x",
|
|
74
72
|
"koatty_store": "^1.x.x",
|
|
75
|
-
"tslib": "^2.3.
|
|
73
|
+
"tslib": "^2.3.1"
|
|
76
74
|
},
|
|
77
75
|
"husky": {
|
|
78
76
|
"hooks": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"1.3.4","name":"koatty_cacheable","dependencies":{"koatty_container":{"version":"1.6.6"},"koatty_lib":{"version":"1.2.6"},"koatty_logger":{"version":"1.2.4"},"koatty_store":{"version":"1.4.10"},"tslib":{"version":"2.3.1"}}}
|
package/tsconfig.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
/* Basic Options */
|
|
4
|
-
"target": "
|
|
4
|
+
"target": "ES2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */,
|
|
5
5
|
"module": "commonjs" /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
|
|
6
6
|
"lib": [
|
|
7
7
|
"es2019"
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */
|
|
59
59
|
},
|
|
60
60
|
"exclude": [
|
|
61
|
-
"node_modules"
|
|
61
|
+
"node_modules",
|
|
62
|
+
"dist"
|
|
62
63
|
],
|
|
63
64
|
"include": [
|
|
64
|
-
"src"
|
|
65
|
-
"src/**/*.json"
|
|
65
|
+
"src/**/*"
|
|
66
66
|
]
|
|
67
67
|
}
|