cloudstructs 0.4.21 → 0.4.24
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/.gitattributes +0 -1
- package/.jsii +3 -3
- package/assets/email-receiver/s3.lambda/index.js +8 -13
- package/assets/email-receiver/whitelist.lambda/index.js +8 -13
- package/assets/slack-app/provider.lambda/index.js +196 -33
- package/assets/slack-events/events.lambda/index.js +9 -16
- package/assets/slack-textract/detect.lambda/index.js +272 -44
- package/assets/toolkit-cleaner/clean-images.lambda/index.js +8 -13
- package/assets/toolkit-cleaner/clean-objects.lambda/index.js +9 -16
- package/assets/toolkit-cleaner/extract-template-hashes.lambda/index.js +8 -13
- package/assets/toolkit-cleaner/get-stack-names.lambda/index.js +8 -13
- package/assets/url-shortener/shortener.lambda/index.js +8 -13
- package/changelog.md +1 -1
- package/lib/codecommit-mirror/index.js +2 -2
- package/lib/ecs-service-roller/index.js +2 -2
- package/lib/email-receiver/receiver.js +1 -1
- package/lib/saml-identity-provider/index.js +2 -2
- package/lib/slack-app/manifest.js +1 -1
- package/lib/slack-app/slack-app.js +2 -2
- package/lib/slack-events/index.js +1 -1
- package/lib/slack-textract/index.js +1 -1
- package/lib/state-machine-cr-provider/index.js +1 -1
- package/lib/static-website/index.js +14 -3
- package/lib/toolkit-cleaner/index.js +1 -1
- package/lib/url-shortener/index.js +1 -1
- package/node_modules/@slack/logger/node_modules/@types/node/README.md +2 -2
- package/node_modules/@slack/logger/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@slack/logger/node_modules/@types/node/buffer.d.ts +1 -1
- package/node_modules/@slack/logger/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@slack/logger/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@slack/logger/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@slack/logger/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@slack/logger/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@slack/logger/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@slack/logger/node_modules/@types/node/package.json +3 -3
- package/node_modules/@slack/logger/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/README.md +2 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/buffer.d.ts +1 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@slack/web-api/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@slack/web-api/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@slack/web-api/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@slack/web-api/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@slack/web-api/node_modules/@types/node/package.json +3 -3
- package/node_modules/@slack/web-api/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/cacheable-request/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/buffer.d.ts +1 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@types/cacheable-request/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@types/cacheable-request/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@types/cacheable-request/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@types/cacheable-request/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@types/cacheable-request/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/cacheable-request/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/is-stream/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/is-stream/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@types/is-stream/node_modules/@types/node/buffer.d.ts +1 -1
- package/node_modules/@types/is-stream/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@types/is-stream/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@types/is-stream/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@types/is-stream/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@types/is-stream/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@types/is-stream/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@types/is-stream/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/is-stream/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/json-buffer/LICENSE +21 -0
- package/node_modules/@types/json-buffer/README.md +16 -0
- package/node_modules/@types/json-buffer/index.d.ts +19 -0
- package/node_modules/@types/json-buffer/package.json +24 -0
- package/node_modules/@types/keyv/README.md +1 -1
- package/node_modules/@types/keyv/index.d.ts +16 -3
- package/node_modules/@types/keyv/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/keyv/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@types/keyv/node_modules/@types/node/buffer.d.ts +1 -1
- package/node_modules/@types/keyv/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@types/keyv/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@types/keyv/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@types/keyv/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@types/keyv/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@types/keyv/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@types/keyv/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/keyv/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/keyv/package.json +3 -3
- package/node_modules/@types/responselike/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/responselike/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/node_modules/@types/responselike/node_modules/@types/node/buffer.d.ts +1 -1
- package/node_modules/@types/responselike/node_modules/@types/node/crypto.d.ts +41 -10
- package/node_modules/@types/responselike/node_modules/@types/node/diagnostics_channel.d.ts +19 -1
- package/node_modules/@types/responselike/node_modules/@types/node/fs.d.ts +48 -14
- package/node_modules/@types/responselike/node_modules/@types/node/globals.d.ts +12 -2
- package/node_modules/@types/responselike/node_modules/@types/node/http2.d.ts +1 -0
- package/node_modules/@types/responselike/node_modules/@types/node/net.d.ts +7 -0
- package/node_modules/@types/responselike/node_modules/@types/node/package.json +3 -3
- package/node_modules/@types/responselike/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/retry/LICENSE +21 -21
- package/node_modules/@types/retry/README.md +4 -4
- package/node_modules/@types/retry/index.d.ts +9 -9
- package/node_modules/@types/retry/package.json +5 -7
- package/node_modules/compress-brotli/LICENSE.md +21 -0
- package/node_modules/compress-brotli/README.md +125 -0
- package/node_modules/compress-brotli/package.json +97 -0
- package/node_modules/compress-brotli/src/index.d.ts +36 -0
- package/node_modules/compress-brotli/src/index.js +45 -0
- package/node_modules/compress-brotli/src/merge-options.js +18 -0
- package/node_modules/follow-redirects/README.md +8 -1
- package/node_modules/follow-redirects/index.js +23 -4
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/keyv/package.json +55 -46
- package/node_modules/keyv/src/index.d.ts +89 -0
- package/node_modules/keyv/src/index.js +177 -25
- package/node_modules/mime-db/HISTORY.md +8 -0
- package/node_modules/mime-db/LICENSE +19 -18
- package/node_modules/mime-db/README.md +1 -1
- package/node_modules/mime-db/db.json +54 -6
- package/node_modules/mime-db/index.js +1 -0
- package/node_modules/mime-db/package.json +5 -4
- package/node_modules/mime-types/HISTORY.md +9 -0
- package/node_modules/mime-types/README.md +1 -1
- package/node_modules/mime-types/package.json +5 -5
- package/node_modules/p-retry/package.json +2 -2
- package/package.json +14 -14
- package/releasetag.txt +1 -1
- package/version.txt +1 -1
- package/node_modules/keyv/.nyc_output/5d6b8dd1-67cf-42ee-8492-c8ae62ce826c.json +0 -1
- package/node_modules/keyv/.nyc_output/ce27532e-5888-46d4-ae10-5a71058d3f0c.json +0 -1
- package/node_modules/keyv/.nyc_output/processinfo/5d6b8dd1-67cf-42ee-8492-c8ae62ce826c.json +0 -1
- package/node_modules/keyv/.nyc_output/processinfo/ce27532e-5888-46d4-ae10-5a71058d3f0c.json +0 -1
- package/node_modules/keyv/.nyc_output/processinfo/index.json +0 -1
- package/node_modules/keyv/test/test.js +0 -130
- package/node_modules/keyv/test/testdb.sqlite +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# compress-brotli
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://coveralls.io/github/Kikobeats/compress-brotli)
|
|
5
|
+
[](https://www.npmjs.org/package/compress-brotli)
|
|
6
|
+
|
|
7
|
+
> Compress/Decompress using Brotli in a simple way.
|
|
8
|
+
|
|
9
|
+
## Highlights
|
|
10
|
+
|
|
11
|
+
- Handle edge cases (such as try to compress `undefined`).
|
|
12
|
+
- JSON serialization/deserialization with Buffer support by default.
|
|
13
|
+
- Easy tu customize (e.g., using [v8 serialization](https://nodejs.org/api/v8.html#v8_v8_serialize_value)).
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
$ npm install compress-brotli --save
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const createCompress = require('compress-brotli')
|
|
25
|
+
|
|
26
|
+
// It exposes compress/decompress methods
|
|
27
|
+
const { compress, decompress } = createCompress()
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
using [v8 serialization](https://nodejs.org/api/v8.html#v8_v8_serialize_value):
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
const createCompress = require('compress-brotli')
|
|
34
|
+
const v8 = require('v8')
|
|
35
|
+
|
|
36
|
+
const { compress, decompress } = createCompress({
|
|
37
|
+
serialize: v8.serialize,
|
|
38
|
+
deserialize: v8.deserialize
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
customizing compress options:
|
|
42
|
+
```js
|
|
43
|
+
const createCompress = require('compress-brotli')
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
constants: {
|
|
47
|
+
BROTLI_MODE_TEXT,
|
|
48
|
+
BROTLI_PARAM_MODE,
|
|
49
|
+
BROTLI_PARAM_QUALITY
|
|
50
|
+
}
|
|
51
|
+
} = require('zlib')
|
|
52
|
+
|
|
53
|
+
// Provide factory level default options
|
|
54
|
+
const { compress, decompress } = createCompress({
|
|
55
|
+
compressOptions: {
|
|
56
|
+
chunkSize: 1024,
|
|
57
|
+
parameters: {
|
|
58
|
+
[BROTLI_PARAM_MODE]: BROTLI_MODE_TEXT
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
decompressOptions: {
|
|
62
|
+
chunkSize: 1024,
|
|
63
|
+
parameters: {
|
|
64
|
+
[BROTLI_PARAM_MODE]: BROTLI_MODE_TEXT
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
const data = 'whatever'
|
|
69
|
+
|
|
70
|
+
// Override call level options (deep merge for parameters)
|
|
71
|
+
const compressed = compress(data, {
|
|
72
|
+
parameters: {
|
|
73
|
+
[BROTLI_PARAM_QUALITY]: 7
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
decompress(compressed, {
|
|
77
|
+
chunkSize: 2048
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## API
|
|
82
|
+
|
|
83
|
+
### compressBrotli([options])
|
|
84
|
+
|
|
85
|
+
#### enable
|
|
86
|
+
|
|
87
|
+
Type: `boolean`<br>
|
|
88
|
+
Default: `false`
|
|
89
|
+
|
|
90
|
+
If pass disable, it will return a noop compress/decompress methods.
|
|
91
|
+
|
|
92
|
+
#### serialize
|
|
93
|
+
|
|
94
|
+
Type: `function`<br>
|
|
95
|
+
Default: `JSONB.stringify`
|
|
96
|
+
|
|
97
|
+
It determines the serialize method to use before compress the data.
|
|
98
|
+
|
|
99
|
+
#### deserialize
|
|
100
|
+
|
|
101
|
+
Type: `function`<br>
|
|
102
|
+
Default: `JSONB.parse`
|
|
103
|
+
|
|
104
|
+
It determines the deserialize method to use after decompress the data.
|
|
105
|
+
|
|
106
|
+
#### compressOptions
|
|
107
|
+
|
|
108
|
+
Type: `zlib.BrotliOptions`<br>
|
|
109
|
+
Default: `{}` i.e. default *zlib.brotliCompress* options will be used
|
|
110
|
+
|
|
111
|
+
It defines default options to be used in wrapped *zlib.brotliCompress* call
|
|
112
|
+
|
|
113
|
+
#### decompressOptions
|
|
114
|
+
|
|
115
|
+
Type: `zlib.BrotliOptions`<br>
|
|
116
|
+
Default: `{}` i.e. default *zlib.brotliDecompress* options will be used
|
|
117
|
+
|
|
118
|
+
It defines default options to be used in wrapped *zlib.brotliDecompress* call
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
**compress-brotli** © [Kiko Beats](https://kikobeats.com), released under the [MIT](https://github.com/Kikobeats/compress-brotli/blob/master/LICENSE.md) License.<br>
|
|
123
|
+
Authored and maintained by Kiko Beats with help from [contributors](https://github.com/Kikobeats/compress-brotli/contributors).
|
|
124
|
+
|
|
125
|
+
> [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/Kikobeats) · Twitter [@Kikobeats](https://twitter.com/Kikobeats)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "compress-brotli",
|
|
3
|
+
"description": "Simple cross Node.js inteface for using brotli compression",
|
|
4
|
+
"homepage": "https://nicedoc.io/Kikobeats/compress-brotli",
|
|
5
|
+
"version": "1.3.8",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"author": {
|
|
8
|
+
"email": "josefrancisco.verdu@gmail.com",
|
|
9
|
+
"name": "Kiko Beats",
|
|
10
|
+
"url": "https://kikobeats.com"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/Kikobeats/compress-brotli.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/Kikobeats/compress-brotli/issues"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"api",
|
|
21
|
+
"brotli",
|
|
22
|
+
"compress",
|
|
23
|
+
"compressed",
|
|
24
|
+
"compression",
|
|
25
|
+
"decode",
|
|
26
|
+
"decompress",
|
|
27
|
+
"decompression",
|
|
28
|
+
"encode",
|
|
29
|
+
"format",
|
|
30
|
+
"zlib"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@types/json-buffer": "~3.0.0",
|
|
34
|
+
"json-buffer": "~3.0.1"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@commitlint/cli": "latest",
|
|
38
|
+
"@commitlint/config-conventional": "latest",
|
|
39
|
+
"ava": "latest",
|
|
40
|
+
"c8": "latest",
|
|
41
|
+
"ci-publish": "latest",
|
|
42
|
+
"conventional-github-releaser": "latest",
|
|
43
|
+
"finepack": "latest",
|
|
44
|
+
"git-authors-cli": "latest",
|
|
45
|
+
"git-dirty": "latest",
|
|
46
|
+
"nano-staged": "latest",
|
|
47
|
+
"npm-check-updates": "latest",
|
|
48
|
+
"prettier-standard": "latest",
|
|
49
|
+
"simple-git-hooks": "latest",
|
|
50
|
+
"sinon": "latest",
|
|
51
|
+
"standard": "latest",
|
|
52
|
+
"standard-markdown": "latest",
|
|
53
|
+
"standard-version": "latest"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">= 12"
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"src"
|
|
60
|
+
],
|
|
61
|
+
"scripts": {
|
|
62
|
+
"clean": "rm -rf node_modules",
|
|
63
|
+
"contributors": "(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
|
64
|
+
"lint": "standard-markdown README.md && standard",
|
|
65
|
+
"postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
|
|
66
|
+
"prerelease": "npm run update:check && npm run contributors",
|
|
67
|
+
"pretest": "npm run lint",
|
|
68
|
+
"release": "standard-version -a",
|
|
69
|
+
"release:github": "conventional-github-releaser -p angular",
|
|
70
|
+
"release:tags": "git push --follow-tags origin HEAD:master",
|
|
71
|
+
"test": "c8 ava",
|
|
72
|
+
"update": "ncu -u",
|
|
73
|
+
"update:check": "ncu -- --error-level 2"
|
|
74
|
+
},
|
|
75
|
+
"license": "MIT",
|
|
76
|
+
"commitlint": {
|
|
77
|
+
"extends": [
|
|
78
|
+
"@commitlint/config-conventional"
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"nano-staged": {
|
|
82
|
+
"*.js,!*.min.js,": [
|
|
83
|
+
"prettier-standard"
|
|
84
|
+
],
|
|
85
|
+
"*.md": [
|
|
86
|
+
"standard-markdown"
|
|
87
|
+
],
|
|
88
|
+
"package.json": [
|
|
89
|
+
"finepack"
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
"simple-git-hooks": {
|
|
93
|
+
"commit-msg": "npx commitlint --edit",
|
|
94
|
+
"pre-commit": "npx nano-staged"
|
|
95
|
+
},
|
|
96
|
+
"types": "src/index.d.ts"
|
|
97
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BrotliOptions, InputType, CompressCallback } from 'zlib'
|
|
2
|
+
import { stringify as JSONBstringify, parse as JSONBparse } from 'json-buffer'
|
|
3
|
+
|
|
4
|
+
declare module 'compress-brotli'
|
|
5
|
+
|
|
6
|
+
type CompressResult = Promise<Parameters<CompressCallback>[1]>
|
|
7
|
+
type DecompressResult = Promise<ReturnType<typeof JSONBparse>>
|
|
8
|
+
|
|
9
|
+
type Serialize<T> = (source: InputType) => T
|
|
10
|
+
type Deserialize<T> = (source: CompressResult) => T
|
|
11
|
+
|
|
12
|
+
declare function createCompress<
|
|
13
|
+
SerializeResult = ReturnType<typeof JSONBstringify>,
|
|
14
|
+
DeserializeResult = ReturnType<typeof JSONBparse>
|
|
15
|
+
>(
|
|
16
|
+
options?: {
|
|
17
|
+
enable?: boolean,
|
|
18
|
+
serialize?: Serialize<SerializeResult>,
|
|
19
|
+
deserialize?: Deserialize<DeserializeResult>,
|
|
20
|
+
iltorb?: any,
|
|
21
|
+
compressOptions?: BrotliOptions,
|
|
22
|
+
decompressOptions?: BrotliOptions
|
|
23
|
+
}
|
|
24
|
+
): {
|
|
25
|
+
serialize: Serialize<SerializeResult>,
|
|
26
|
+
deserialize: Deserialize<DeserializeResult>,
|
|
27
|
+
compress: (data: InputType, optioins?: BrotliOptions) => CompressResult
|
|
28
|
+
decompress: (data: InputType, optioins?: BrotliOptions) => DecompressResult
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare namespace createCompress {
|
|
32
|
+
const stringify: typeof JSONBstringify
|
|
33
|
+
const parse: typeof JSONBparse
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default createCompress
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { promisify } = require('util')
|
|
4
|
+
const JSONB = require('json-buffer')
|
|
5
|
+
const zlib = require('zlib')
|
|
6
|
+
|
|
7
|
+
const mergeOptions = require('./merge-options')
|
|
8
|
+
|
|
9
|
+
const compress = promisify(zlib.brotliCompress)
|
|
10
|
+
|
|
11
|
+
const decompress = promisify(zlib.brotliDecompress)
|
|
12
|
+
|
|
13
|
+
const identity = val => val
|
|
14
|
+
|
|
15
|
+
const createCompress = ({
|
|
16
|
+
enable = true,
|
|
17
|
+
serialize = JSONB.stringify,
|
|
18
|
+
deserialize = JSONB.parse,
|
|
19
|
+
compressOptions,
|
|
20
|
+
decompressOptions
|
|
21
|
+
} = {}) => {
|
|
22
|
+
if (!enable) {
|
|
23
|
+
return { serialize, deserialize, decompress: identity, compress: identity }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
serialize,
|
|
28
|
+
deserialize,
|
|
29
|
+
compress: async (data, options = {}) => {
|
|
30
|
+
if (data === undefined) return data
|
|
31
|
+
const serializedData = serialize(data)
|
|
32
|
+
return compress(serializedData, mergeOptions(compressOptions, options))
|
|
33
|
+
},
|
|
34
|
+
decompress: async (data, options = {}) => {
|
|
35
|
+
if (data === undefined) return data
|
|
36
|
+
return deserialize(
|
|
37
|
+
await decompress(data, mergeOptions(decompressOptions, options))
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = createCompress
|
|
44
|
+
module.exports.stringify = JSONB.stringify
|
|
45
|
+
module.exports.parse = JSONB.parse
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = (defaultOptions = {}, options = {}) => {
|
|
4
|
+
const params = {
|
|
5
|
+
...(defaultOptions.params || {}),
|
|
6
|
+
...(options.params || {})
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
...defaultOptions,
|
|
11
|
+
...options,
|
|
12
|
+
...(Object.keys(params).length
|
|
13
|
+
? {
|
|
14
|
+
params
|
|
15
|
+
}
|
|
16
|
+
: {})
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -63,10 +63,17 @@ const { http, https } = require('follow-redirects');
|
|
|
63
63
|
|
|
64
64
|
const options = url.parse('http://bit.ly/900913');
|
|
65
65
|
options.maxRedirects = 10;
|
|
66
|
-
options.beforeRedirect = (options,
|
|
66
|
+
options.beforeRedirect = (options, response, request) => {
|
|
67
67
|
// Use this to adjust the request options upon redirecting,
|
|
68
68
|
// to inspect the latest response headers,
|
|
69
69
|
// or to cancel the request by throwing an error
|
|
70
|
+
|
|
71
|
+
// response.headers = the redirect response headers
|
|
72
|
+
// response.statusCode = the redirect response code (eg. 301, 307, etc.)
|
|
73
|
+
|
|
74
|
+
// request.url = the requested URL that resulted in a redirect
|
|
75
|
+
// request.headers = the headers in the request that resulted in a redirect
|
|
76
|
+
// request.method = the method of the request that resulted in a redirect
|
|
70
77
|
if (options.hostname === "example.com") {
|
|
71
78
|
options.auth = "user:password";
|
|
72
79
|
}
|
|
@@ -270,7 +270,7 @@ RedirectableRequest.prototype._performRequest = function () {
|
|
|
270
270
|
// If specified, use the agent corresponding to the protocol
|
|
271
271
|
// (HTTP and HTTPS use different types of agents)
|
|
272
272
|
if (this._options.agents) {
|
|
273
|
-
var scheme = protocol.
|
|
273
|
+
var scheme = protocol.slice(0, -1);
|
|
274
274
|
this._options.agent = this._options.agents[scheme];
|
|
275
275
|
}
|
|
276
276
|
|
|
@@ -362,10 +362,21 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
|
362
362
|
return;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
+
// Store the request headers if applicable
|
|
366
|
+
var requestHeaders;
|
|
367
|
+
var beforeRedirect = this._options.beforeRedirect;
|
|
368
|
+
if (beforeRedirect) {
|
|
369
|
+
requestHeaders = Object.assign({
|
|
370
|
+
// The Host header was set by nativeProtocol.request
|
|
371
|
+
Host: response.req.getHeader("host"),
|
|
372
|
+
}, this._options.headers);
|
|
373
|
+
}
|
|
374
|
+
|
|
365
375
|
// RFC7231§6.4: Automatic redirection needs to done with
|
|
366
376
|
// care for methods not known to be safe, […]
|
|
367
377
|
// RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
|
|
368
378
|
// the request method from POST to GET for the subsequent request.
|
|
379
|
+
var method = this._options.method;
|
|
369
380
|
if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" ||
|
|
370
381
|
// RFC7231§6.4.4: The 303 (See Other) status code indicates that
|
|
371
382
|
// the server is redirecting the user agent to a different resource […]
|
|
@@ -413,10 +424,18 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
|
413
424
|
}
|
|
414
425
|
|
|
415
426
|
// Evaluate the beforeRedirect callback
|
|
416
|
-
if (typeof
|
|
417
|
-
var responseDetails = {
|
|
427
|
+
if (typeof beforeRedirect === "function") {
|
|
428
|
+
var responseDetails = {
|
|
429
|
+
headers: response.headers,
|
|
430
|
+
statusCode: statusCode,
|
|
431
|
+
};
|
|
432
|
+
var requestDetails = {
|
|
433
|
+
url: currentUrl,
|
|
434
|
+
method: method,
|
|
435
|
+
headers: requestHeaders,
|
|
436
|
+
};
|
|
418
437
|
try {
|
|
419
|
-
|
|
438
|
+
beforeRedirect(this._options, responseDetails, requestDetails);
|
|
420
439
|
}
|
|
421
440
|
catch (err) {
|
|
422
441
|
this.emit("error", err);
|
|
@@ -1,48 +1,57 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
2
|
+
"name": "keyv",
|
|
3
|
+
"version": "4.2.6",
|
|
4
|
+
"description": "Simple key-value storage with support for multiple backends",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "xo && nyc ava --serial",
|
|
8
|
+
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
|
|
9
|
+
"clean": "rm -rf node_modules && rm -rf .nyc_output && rm -rf coverage.lcov && rm -rf ./test/testdb.sqlite"
|
|
10
|
+
},
|
|
11
|
+
"xo": {
|
|
12
|
+
"rules": {
|
|
13
|
+
"unicorn/prefer-module": 0,
|
|
14
|
+
"unicorn/prefer-node-protocol": 0
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/jaredwray/keyv.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"key",
|
|
23
|
+
"value",
|
|
24
|
+
"store",
|
|
25
|
+
"cache",
|
|
26
|
+
"ttl"
|
|
27
|
+
],
|
|
28
|
+
"author": "Jared Wray <me@jaredwray.com> (http://jaredwray.com)",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/jaredwray/keyv/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/jaredwray/keyv",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"compress-brotli": "^1.3.8",
|
|
36
|
+
"json-buffer": "3.0.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@keyv/test-suite": "*",
|
|
40
|
+
"ava": "^4.2.0",
|
|
41
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
42
|
+
"nyc": "^15.1.0",
|
|
43
|
+
"pify": "5.0.0",
|
|
44
|
+
"this": "^1.1.0",
|
|
45
|
+
"timekeeper": "^2.2.0",
|
|
46
|
+
"tsd": "^0.20.0",
|
|
47
|
+
"typescript": "^4.6.4",
|
|
48
|
+
"xo": "^0.48.0"
|
|
49
|
+
},
|
|
50
|
+
"tsd": {
|
|
51
|
+
"directory": "test"
|
|
52
|
+
},
|
|
53
|
+
"types": "./src/index.d.ts",
|
|
54
|
+
"files": [
|
|
55
|
+
"src"
|
|
56
|
+
]
|
|
48
57
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {EventEmitter} from 'events';
|
|
2
|
+
|
|
3
|
+
type WithRequiredProperties<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
4
|
+
|
|
5
|
+
declare class Keyv<Value = any, Options extends Record<string, any> = Record<string, unknown>> extends EventEmitter {
|
|
6
|
+
/**
|
|
7
|
+
* `this.opts` is an object containing at least the properties listed
|
|
8
|
+
* below. However, `Keyv.Options` allows arbitrary properties as well.
|
|
9
|
+
* These properties can be specified as the second type parameter to `Keyv`.
|
|
10
|
+
*/
|
|
11
|
+
opts: WithRequiredProperties<
|
|
12
|
+
Keyv.Options<Value>,
|
|
13
|
+
'deserialize' | 'namespace' | 'serialize' | 'store' | 'uri'
|
|
14
|
+
> &
|
|
15
|
+
Options;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
|
|
19
|
+
*/
|
|
20
|
+
constructor(options?: Keyv.Options<Value> & Options);
|
|
21
|
+
/**
|
|
22
|
+
* @param uri The connection string URI.
|
|
23
|
+
*
|
|
24
|
+
* Merged into the options object as options.uri.
|
|
25
|
+
* @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options.
|
|
26
|
+
*/
|
|
27
|
+
constructor(uri?: string, options?: Keyv.Options<Value> & Options);
|
|
28
|
+
|
|
29
|
+
/** Returns the value. */
|
|
30
|
+
get<Raw extends boolean = false>(key: string | string[], options?: {raw?: Raw}):
|
|
31
|
+
Promise<(Raw extends false
|
|
32
|
+
? Value
|
|
33
|
+
: Keyv.DeserializedData<Value>) | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Set a value.
|
|
36
|
+
*
|
|
37
|
+
* By default keys are persistent. You can set an expiry TTL in milliseconds.
|
|
38
|
+
*/
|
|
39
|
+
set(key: string, value: Value, ttl?: number): Promise<true>;
|
|
40
|
+
/**
|
|
41
|
+
* Deletes an entry.
|
|
42
|
+
*
|
|
43
|
+
* Returns `true` if the key existed, `false` if not.
|
|
44
|
+
*/
|
|
45
|
+
delete(key: string | string[]): Promise<boolean>;
|
|
46
|
+
/** Delete all entries in the current namespace. */
|
|
47
|
+
clear(): Promise<void>;
|
|
48
|
+
/** Check if key exists in current namespace. */
|
|
49
|
+
has(key: string): Promise<boolean>;
|
|
50
|
+
/** Iterator */
|
|
51
|
+
iterator(namespace: string | undefined): AsyncGenerator<any, void, any>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare namespace Keyv {
|
|
55
|
+
interface Options<Value> {
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
|
|
58
|
+
/** Namespace for the current instance. */
|
|
59
|
+
namespace?: string | undefined;
|
|
60
|
+
/** A custom serialization function. */
|
|
61
|
+
serialize?: ((data: DeserializedData<Value>) => string) | undefined;
|
|
62
|
+
/** A custom deserialization function. */
|
|
63
|
+
deserialize?: ((data: string) => DeserializedData<Value> | undefined) | undefined;
|
|
64
|
+
/** The connection string URI. */
|
|
65
|
+
uri?: string | undefined;
|
|
66
|
+
/** The storage adapter instance to be used by Keyv. */
|
|
67
|
+
store?: Store<Value> | undefined;
|
|
68
|
+
/** Default TTL. Can be overridden by specififying a TTL on `.set()`. */
|
|
69
|
+
ttl?: number | undefined;
|
|
70
|
+
/** Specify an adapter to use. e.g `'redis'` or `'mongodb'`. */
|
|
71
|
+
adapter?: 'redis' | 'mongodb' | 'mongo' | 'sqlite' | 'postgresql' | 'postgres' | 'mysql' | undefined;
|
|
72
|
+
/** Enable compression option **/
|
|
73
|
+
compress?: Record<string, unknown> | undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface DeserializedData<Value> {
|
|
77
|
+
value: Value; expires: number | undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface Store<Value> {
|
|
81
|
+
get(key: string): Value | Promise<Value | undefined> | undefined;
|
|
82
|
+
set(key: string, value: Value, ttl?: number): any;
|
|
83
|
+
delete(key: string): boolean | Promise<boolean>;
|
|
84
|
+
clear(): void | Promise<void>;
|
|
85
|
+
has(key: string): boolean | Promise<boolean>;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export = Keyv;
|