@middy/util 4.2.5 → 4.2.7
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/index.cjs +1 -8
- package/index.d.ts +33 -9
- package/index.js +1 -8
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -127,14 +127,7 @@ const processCache = (options, fetch = ()=>undefined, request)=>{
|
|
|
127
127
|
const value = fetch(request);
|
|
128
128
|
const expiry = Date.now() + cacheExpiry;
|
|
129
129
|
if (cacheExpiry) {
|
|
130
|
-
const refresh = cacheExpiry > 0 ? setInterval(()=>
|
|
131
|
-
const value = fetch(request);
|
|
132
|
-
const expiry = Date.now() + cacheExpiry;
|
|
133
|
-
Object.assign(cache[cacheKey], {
|
|
134
|
-
value,
|
|
135
|
-
expiry
|
|
136
|
-
});
|
|
137
|
-
}, cacheExpiry) : undefined;
|
|
130
|
+
const refresh = cacheExpiry > 0 ? setInterval(()=>processCache(options, fetch, request), cacheExpiry) : undefined;
|
|
138
131
|
cache[cacheKey] = {
|
|
139
132
|
value,
|
|
140
133
|
expiry,
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import middy from '@middy/core'
|
|
2
2
|
|
|
3
3
|
interface Options<Client, ClientOptions> {
|
|
4
|
-
AwsClient?: new(...args: any[]) => Client
|
|
4
|
+
AwsClient?: new (...args: any[]) => Client
|
|
5
5
|
awsClientOptions?: Partial<ClientOptions>
|
|
6
6
|
awsClientAssumeRole?: string
|
|
7
7
|
awsClientCapture?: (service: Client) => Client
|
|
@@ -20,26 +20,50 @@ type HttpError = Error & {
|
|
|
20
20
|
[key: number]: any
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
declare function createPrefetchClient<Client, ClientOptions> (
|
|
23
|
+
declare function createPrefetchClient<Client, ClientOptions> (
|
|
24
|
+
options: Options<Client, ClientOptions>
|
|
25
|
+
): Client
|
|
24
26
|
|
|
25
|
-
declare function createClient<Client, ClientOptions> (
|
|
27
|
+
declare function createClient<Client, ClientOptions> (
|
|
28
|
+
options: Options<Client, ClientOptions>,
|
|
29
|
+
request: middy.Request
|
|
30
|
+
): Promise<Client>
|
|
26
31
|
|
|
27
|
-
declare function canPrefetch<Client, ClientOptions> (
|
|
32
|
+
declare function canPrefetch<Client, ClientOptions> (
|
|
33
|
+
options: Options<Client, ClientOptions>
|
|
34
|
+
): boolean
|
|
28
35
|
|
|
29
|
-
declare function getInternal (
|
|
36
|
+
declare function getInternal (
|
|
37
|
+
variables: any,
|
|
38
|
+
request: middy.Request
|
|
39
|
+
): Promise<any>
|
|
30
40
|
|
|
31
41
|
declare function sanitizeKey (key: string): string
|
|
32
42
|
|
|
33
|
-
declare function processCache<Client, ClientOptions> (
|
|
43
|
+
declare function processCache<Client, ClientOptions> (
|
|
44
|
+
options: Options<Client, ClientOptions>,
|
|
45
|
+
fetch: (request: middy.Request, cachedValues: any) => any,
|
|
46
|
+
request?: middy.Request
|
|
47
|
+
): { value: any, expiry: number }
|
|
34
48
|
|
|
35
49
|
declare function getCache (keys: string): any
|
|
36
50
|
|
|
37
51
|
declare function clearCache (keys?: string | string[] | null): void
|
|
38
52
|
|
|
39
|
-
declare function jsonSafeParse (
|
|
53
|
+
declare function jsonSafeParse (
|
|
54
|
+
string: string,
|
|
55
|
+
reviver?: (key: string, value: any) => any
|
|
56
|
+
): any
|
|
40
57
|
|
|
41
|
-
declare function normalizeHttpResponse (
|
|
58
|
+
declare function normalizeHttpResponse (
|
|
59
|
+
request: any,
|
|
60
|
+
fallbackResponse?: any
|
|
61
|
+
): any
|
|
42
62
|
|
|
43
|
-
declare function createError (
|
|
63
|
+
declare function createError (
|
|
64
|
+
code: number,
|
|
65
|
+
message: string,
|
|
66
|
+
properties?: Record<string, any>
|
|
67
|
+
): HttpError
|
|
44
68
|
|
|
45
69
|
declare function modifyCache (cacheKey: string, value: any): void
|
package/index.js
CHANGED
|
@@ -101,14 +101,7 @@ export const processCache = (options, fetch = ()=>undefined, request)=>{
|
|
|
101
101
|
const value = fetch(request);
|
|
102
102
|
const expiry = Date.now() + cacheExpiry;
|
|
103
103
|
if (cacheExpiry) {
|
|
104
|
-
const refresh = cacheExpiry > 0 ? setInterval(()=>
|
|
105
|
-
const value = fetch(request);
|
|
106
|
-
const expiry = Date.now() + cacheExpiry;
|
|
107
|
-
Object.assign(cache[cacheKey], {
|
|
108
|
-
value,
|
|
109
|
-
expiry
|
|
110
|
-
});
|
|
111
|
-
}, cacheExpiry) : undefined;
|
|
104
|
+
const refresh = cacheExpiry > 0 ? setInterval(()=>processCache(options, fetch, request), cacheExpiry) : undefined;
|
|
112
105
|
cache[cacheKey] = {
|
|
113
106
|
value,
|
|
114
107
|
expiry,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/util",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.7",
|
|
4
4
|
"description": "🛵 The stylish Node.js middleware engine for AWS Lambda (util package)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@aws-sdk/client-ssm": "^3.0.0",
|
|
64
|
-
"@middy/core": "4.2.
|
|
64
|
+
"@middy/core": "4.2.7",
|
|
65
65
|
"@types/aws-lambda": "^8.10.76",
|
|
66
66
|
"@types/node": "^18.0.0",
|
|
67
67
|
"aws-xray-sdk": "^3.3.3"
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"type": "github",
|
|
72
72
|
"url": "https://github.com/sponsors/willfarrell"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "f17e0e371d1d1c7a67365c895775a847aab5aa0b"
|
|
75
75
|
}
|