@openclaw/whatsapp 2026.9.1-beta.1 → 2026.9.2
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/{accounts-BX2fZUyR.js → accounts-CiKHiuEe.js} +10 -27
- package/dist/{action-runtime-C075e6OP.js → action-runtime-CRZLhN3f.js} +2 -2
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/agent-tools-api.js +3 -3
- package/dist/api.js +10 -10
- package/dist/{approval-handler.runtime-CljxfPJz.js → approval-handler.runtime-C2cpkbpY.js} +8 -4
- package/dist/{approval-reactions-Jyr1JaAK.js → approval-reactions-DrZe-NmN.js} +7 -5
- package/dist/auth-presence.js +1 -1
- package/dist/{auth-store-CtpBqH5S.js → auth-store-ZWaclAbd.js} +8 -6
- package/dist/channel-config-api.js +1 -1
- package/dist/{channel-C4FMOZTE.js → channel-dwfgnadr.js} +56 -66
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-Bhp2BYRr.js → channel-react-action-CHeJSG9F.js} +3 -3
- package/dist/{channel.runtime-CrahUvcb.js → channel.runtime-Bn3K5Ygb.js} +4 -4
- package/dist/{channel.setup-CGcBvnpP.js → channel.setup-DckQm9ma.js} +1 -1
- package/dist/{config-schema-BQP5YCeK.js → config-schema-BYA6e_Ii.js} +6 -4
- package/dist/{connection-controller-CIYuBJrs.js → connection-controller-DNp6U1NN.js} +2 -2
- package/dist/{constants-HU41RHGI.js → constants-C7m81BNe.js} +1 -1
- package/dist/{creds-files-W6B3EMZ8.js → creds-files-Drg3usj1.js} +1 -1
- package/dist/{directory-config-P7_3U73Z.js → directory-config-CoWFw1zn.js} +3 -3
- package/dist/directory-contract-api.js +1 -1
- package/dist/doctor-BPb-SjdE.js +65 -0
- package/dist/doctor-contract-api.js +21 -3
- package/dist/{group-session-key-DmFc_Cqi.js → group-session-key-BmVDSPr1.js} +11 -12
- package/dist/light-runtime-api.js +1 -1
- package/dist/{login-BkpKpndm.js → login-6j2iP9nR.js} +6 -5
- package/dist/{login-qr-DY4VFgOq.js → login-qr-DRFgI6k1.js} +9 -7
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-C_Nw23PZ.js → monitor-Bc6DC5jl.js} +189 -156
- package/dist/{question-reactions-D3eAeB0i.js → question-reactions-bbe0Qnjn.js} +1 -1
- package/dist/runtime-api.js +9 -9
- package/dist/{send-DLMUc2uZ.js → send-BDDGPxav.js} +53 -28
- package/dist/{send-api-BtK45TmZ.js → send-api-C_Zn4Ij-.js} +48 -48
- package/dist/{setup-finalize-C1nij8NS.js → setup-finalize-gLmc3FTV.js} +7 -6
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-CjjqIxQP.js → setup-surface-twIi4TdN.js} +3 -3
- package/dist/{shared-BekHi69d.js → shared-ByeKDmh0.js} +13 -8
- package/dist/{socket-close-2T0_jZTN.js → socket-close-B3X9uerq.js} +10 -7
- package/dist/{targets-runtime-TMk0lGuy.js → targets-runtime-RBjx3pg_.js} +1 -2
- package/dist/{text-runtime-CaKLhowd.js → text-runtime-DyfmcATV.js} +1 -1
- package/node_modules/baileys/node_modules/process-warning/.github/dependabot.yml +42 -2
- package/node_modules/baileys/node_modules/process-warning/.github/workflows/ci.yml +12 -1
- package/node_modules/baileys/node_modules/process-warning/.github/workflows/lock-threads.yml +19 -0
- package/node_modules/baileys/node_modules/process-warning/LICENSE +1 -1
- package/node_modules/baileys/node_modules/process-warning/README.md +41 -2
- package/node_modules/baileys/node_modules/process-warning/index.js +85 -17
- package/node_modules/baileys/node_modules/process-warning/package.json +6 -7
- package/node_modules/baileys/node_modules/process-warning/test/emit-once-only.test.js +3 -3
- package/node_modules/baileys/node_modules/process-warning/test/emit-reset.test.js +4 -4
- package/node_modules/baileys/node_modules/process-warning/test/emit-unlimited.test.js +2 -2
- package/node_modules/baileys/node_modules/process-warning/test/spy-warning.test.js +143 -0
- package/node_modules/baileys/node_modules/process-warning/types/index.d.ts +15 -1
- package/node_modules/baileys/node_modules/process-warning/types/index.tst.ts +48 -0
- package/node_modules/baileys/node_modules/ws/lib/permessage-deflate.js +3 -1
- package/node_modules/baileys/node_modules/ws/package.json +1 -1
- package/node_modules/typebox/build/format/email.mjs +1 -1
- package/node_modules/typebox/build/format/idna/idn-hostname.mjs +19 -1
- package/node_modules/typebox/build/format/json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer.mjs +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.d.mts +2 -2
- package/node_modules/typebox/build/format/json_pointer_uri_fragment.mjs +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/system/memory/assign.mjs +2 -1
- package/node_modules/typebox/build/system/memory/create.mjs +3 -4
- package/node_modules/typebox/build/system/memory/discard.mjs +2 -2
- package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
- package/node_modules/typebox/build/system/memory/update.mjs +3 -2
- package/node_modules/typebox/package.json +1 -1
- package/openclaw.plugin.json +0 -1
- package/package.json +7 -6
- package/dist/doctor-CwzVXKoE.js +0 -10
- package/node_modules/baileys/node_modules/process-warning/types/index.test-d.ts +0 -36
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/process-warning)
|
|
5
5
|
[](https://github.com/neostandard/neostandard)
|
|
6
6
|
|
|
7
|
-
A small utility for generating consistent warning objects across your codebase.
|
|
7
|
+
A small utility for generating consistent [warning objects](https://nodejs.org/api/process.html#event-warning) across your codebase.
|
|
8
8
|
It also exposes a utility for emitting those warnings, guaranteeing that they are issued only once (unless configured otherwise).
|
|
9
9
|
|
|
10
10
|
_This module is used by the [Fastify](https://fastify.dev) framework and it was called `fastify-warning` prior to version 1.0.0._
|
|
@@ -31,7 +31,7 @@ const warning = createWarning({
|
|
|
31
31
|
message: 'Hello %s',
|
|
32
32
|
unlimited: true
|
|
33
33
|
})
|
|
34
|
-
warning('world')
|
|
34
|
+
const emitted = warning('world')
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
#### Methods
|
|
@@ -101,6 +101,45 @@ FST_ERROR_CODE('world') // will be emitted
|
|
|
101
101
|
FST_ERROR_CODE('world') // will be emitted again
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
+
#### `spyWarning(warning)`
|
|
105
|
+
|
|
106
|
+
Spy the created warning function for testing purpose.
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
const { test } = require('node:test')
|
|
110
|
+
const { createWarning, spyWarning } = require('process-warning')
|
|
111
|
+
const FST_ERROR_CODE = createWarning({ name: 'MyAppWarning', code: 'FST_ERROR_CODE', message: 'Hello %s' })
|
|
112
|
+
|
|
113
|
+
test('spy warning', t => {
|
|
114
|
+
const spyData = spyWarning(FST_ERROR_CODE)
|
|
115
|
+
|
|
116
|
+
// call after spy
|
|
117
|
+
const emitted = FST_ERROR_CODE('world')
|
|
118
|
+
t.assert.strictEqual(emitted, true)
|
|
119
|
+
|
|
120
|
+
// restore the warning function
|
|
121
|
+
// it must be called when you do not need to spy anymore
|
|
122
|
+
// otherwise, the calls data will accumulates.
|
|
123
|
+
t.after(() => spyData.restore())
|
|
124
|
+
|
|
125
|
+
t.assert.strictEqual(FST_ERROR_CODE.emitted, true)
|
|
126
|
+
// calls return the arguments and result.
|
|
127
|
+
// result indicate whether warning is emitted through process.emitWarning
|
|
128
|
+
console.log(spyData.calls) // [{ arguments: ['world'], result: true }]
|
|
129
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, ['world'])
|
|
130
|
+
t.assert.strictEqual(spyData.calls[0].result, true)
|
|
131
|
+
// number of times called the function
|
|
132
|
+
console.log(spyData.callCount()) // 1
|
|
133
|
+
t.assert.strictEqual(spyData.callCount(), 1)
|
|
134
|
+
|
|
135
|
+
// reset the spy stat and warning state
|
|
136
|
+
spyData.reset()
|
|
137
|
+
t.assert.strictEqual(FST_ERROR_CODE.emitted, false)
|
|
138
|
+
t.assert.deepStrictEqual(spyData.calls, [])
|
|
139
|
+
t.assert.strictEqual(spyData.callCount(), 0)
|
|
140
|
+
})
|
|
141
|
+
```
|
|
142
|
+
|
|
104
143
|
#### Suppressing warnings
|
|
105
144
|
|
|
106
145
|
It is possible to suppress warnings by utilizing one of node's built-in warning suppression mechanisms.
|
|
@@ -17,6 +17,7 @@ const { format } = require('node:util')
|
|
|
17
17
|
* @property {string} message - The warning message.
|
|
18
18
|
* @property {boolean} emitted - Indicates if the warning has been emitted.
|
|
19
19
|
* @property {function} format - Formats the warning message.
|
|
20
|
+
* @returns {boolean} emit - Indicates if the warning has been emitted by this call.
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -33,8 +34,69 @@ const { format } = require('node:util')
|
|
|
33
34
|
* @typedef {Object} ProcessWarning
|
|
34
35
|
* @property {function} createWarning - Creates a warning item.
|
|
35
36
|
* @property {function} createDeprecation - Creates a deprecation warning item.
|
|
37
|
+
* @property {function} spyWarning - Spy a warning item.
|
|
36
38
|
*/
|
|
37
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Represents the spy data.
|
|
42
|
+
* @typedef {Object} WarningSpyData
|
|
43
|
+
* @property {object} calls - Arguments of WarningItem calls with.
|
|
44
|
+
* @property {function} callCount - Number of counts called the WarningItem.
|
|
45
|
+
* @property {function} reset - Reset the calls data and state of WarningItem.
|
|
46
|
+
* @property {function} restore - Remove spy from WarningItem.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
const kWarningFn = Symbol('process-warning.fn')
|
|
50
|
+
const kWarningSpyData = Symbol('process-warning.spyData')
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Spy a warning item.
|
|
54
|
+
* @function
|
|
55
|
+
* @memberof processWarning
|
|
56
|
+
* @param {WarningItem} warning - The warning item to spy.
|
|
57
|
+
* @returns {WarningSpyData} The created spy data.
|
|
58
|
+
*/
|
|
59
|
+
function spyWarning (warning) {
|
|
60
|
+
// Do not double spy the same warning
|
|
61
|
+
if (warning[kWarningSpyData] === null) {
|
|
62
|
+
const warningFn = warning[kWarningFn]
|
|
63
|
+
warning[kWarningFn] = function (a, b, c) {
|
|
64
|
+
const args = []
|
|
65
|
+
// since warning always call by fn(a, b, c)
|
|
66
|
+
// it need to remove the trailing undefined arguments
|
|
67
|
+
if (c) {
|
|
68
|
+
args.push(a, b, c)
|
|
69
|
+
} else if (b) {
|
|
70
|
+
args.push(a, b)
|
|
71
|
+
} else if (a) {
|
|
72
|
+
args.push(a)
|
|
73
|
+
}
|
|
74
|
+
warning[kWarningSpyData].calls.push({
|
|
75
|
+
arguments: args,
|
|
76
|
+
result: warningFn(a, b, c)
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
const spyData = {
|
|
80
|
+
calls: [],
|
|
81
|
+
callCount () {
|
|
82
|
+
return spyData.calls.length
|
|
83
|
+
},
|
|
84
|
+
reset () {
|
|
85
|
+
warning.emitted = false
|
|
86
|
+
spyData.calls.length = 0
|
|
87
|
+
},
|
|
88
|
+
restore () {
|
|
89
|
+
spyData.reset()
|
|
90
|
+
warning[kWarningFn] = warningFn
|
|
91
|
+
warning[kWarningSpyData] = null
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
warning[kWarningSpyData] = spyData
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return warning[kWarningSpyData]
|
|
98
|
+
}
|
|
99
|
+
|
|
38
100
|
/**
|
|
39
101
|
* Creates a deprecation warning item.
|
|
40
102
|
* @function
|
|
@@ -62,21 +124,24 @@ function createWarning ({ name, code, message, unlimited = false } = {}) {
|
|
|
62
124
|
|
|
63
125
|
code = code.toUpperCase()
|
|
64
126
|
|
|
65
|
-
|
|
66
|
-
|
|
127
|
+
const warningFn = unlimited === true
|
|
128
|
+
? function (a, b, c) {
|
|
129
|
+
warning.emitted = true
|
|
130
|
+
process.emitWarning(warning.format(a, b, c), warning.name, warning.code)
|
|
131
|
+
return true
|
|
132
|
+
}
|
|
133
|
+
: function (a, b, c) {
|
|
67
134
|
if (warning.emitted === true && warning.unlimited !== true) {
|
|
68
|
-
return
|
|
135
|
+
return false
|
|
69
136
|
}
|
|
70
137
|
warning.emitted = true
|
|
71
138
|
process.emitWarning(warning.format(a, b, c), warning.name, warning.code)
|
|
139
|
+
return true
|
|
72
140
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
[
|
|
77
|
-
warning.emitted = true
|
|
78
|
-
process.emitWarning(warning.format(a, b, c), warning.name, warning.code)
|
|
79
|
-
}
|
|
141
|
+
|
|
142
|
+
const warningContainer = {
|
|
143
|
+
[name]: function (a, b, c) {
|
|
144
|
+
return warning[kWarningFn](a, b, c)
|
|
80
145
|
}
|
|
81
146
|
}
|
|
82
147
|
|
|
@@ -86,14 +151,16 @@ function createWarning ({ name, code, message, unlimited = false } = {}) {
|
|
|
86
151
|
warning.message = message
|
|
87
152
|
warning.unlimited = unlimited
|
|
88
153
|
warning.code = code
|
|
154
|
+
warning[kWarningFn] = warningFn
|
|
155
|
+
warning[kWarningSpyData] = null
|
|
89
156
|
|
|
90
157
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
158
|
+
* Formats the warning message.
|
|
159
|
+
* @param {*} [a] Possible message interpolation value.
|
|
160
|
+
* @param {*} [b] Possible message interpolation value.
|
|
161
|
+
* @param {*} [c] Possible message interpolation value.
|
|
162
|
+
* @returns {string} The formatted warning message.
|
|
163
|
+
*/
|
|
97
164
|
warning.format = function (a, b, c) {
|
|
98
165
|
let formatted
|
|
99
166
|
if (a && b && c) {
|
|
@@ -116,9 +183,10 @@ function createWarning ({ name, code, message, unlimited = false } = {}) {
|
|
|
116
183
|
* @namespace
|
|
117
184
|
* @property {function} createWarning - Creates a warning item.
|
|
118
185
|
* @property {function} createDeprecation - Creates a deprecation warning item.
|
|
186
|
+
* @property {function} spyWarning - Spy a warning item.
|
|
119
187
|
* @property {ProcessWarning} processWarning - Represents the process warning functionality.
|
|
120
188
|
*/
|
|
121
|
-
const out = { createWarning, createDeprecation }
|
|
189
|
+
const out = { createWarning, createDeprecation, spyWarning }
|
|
122
190
|
module.exports = out
|
|
123
191
|
module.exports.default = out
|
|
124
192
|
module.exports.processWarning = out
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "process-warning",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "A small utility for creating warnings and emitting them.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"test": "npm run test:unit && npm run test:jest && npm run test:typescript",
|
|
12
12
|
"test:jest": "jest jest.test.js",
|
|
13
13
|
"test:unit": "c8 --100 node --test",
|
|
14
|
-
"test:typescript": "
|
|
14
|
+
"test:typescript": "tstyche"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -62,12 +62,11 @@
|
|
|
62
62
|
}
|
|
63
63
|
],
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@fastify/pre-commit": "^2.1.0",
|
|
66
65
|
"benchmark": "^2.1.4",
|
|
67
|
-
"c8": "^
|
|
66
|
+
"c8": "^12.0.0",
|
|
68
67
|
"eslint": "^9.17.0",
|
|
69
|
-
"jest": "^
|
|
70
|
-
"neostandard": "^0.
|
|
71
|
-
"
|
|
68
|
+
"jest": "^30.0.3",
|
|
69
|
+
"neostandard": "^0.13.0",
|
|
70
|
+
"tstyche": "^7.0.0"
|
|
72
71
|
}
|
|
73
72
|
}
|
|
@@ -5,7 +5,7 @@ const { createWarning } = require('..')
|
|
|
5
5
|
const { withResolvers } = require('./promise')
|
|
6
6
|
|
|
7
7
|
test('emit should emit a given code only once', t => {
|
|
8
|
-
t.plan(
|
|
8
|
+
t.plan(6)
|
|
9
9
|
|
|
10
10
|
const { promise, resolve } = withResolvers()
|
|
11
11
|
|
|
@@ -22,8 +22,8 @@ test('emit should emit a given code only once', t => {
|
|
|
22
22
|
code: 'CODE',
|
|
23
23
|
message: 'Hello world'
|
|
24
24
|
})
|
|
25
|
-
warn()
|
|
26
|
-
warn()
|
|
25
|
+
t.assert.strictEqual(warn(), true)
|
|
26
|
+
t.assert.strictEqual(warn(), false)
|
|
27
27
|
setImmediate(() => {
|
|
28
28
|
process.removeListener('warning', onWarning)
|
|
29
29
|
resolve()
|
|
@@ -5,7 +5,7 @@ const { createWarning } = require('../')
|
|
|
5
5
|
const { withResolvers } = require('./promise')
|
|
6
6
|
|
|
7
7
|
test('a limited warning can be re-set', t => {
|
|
8
|
-
t.plan(
|
|
8
|
+
t.plan(7)
|
|
9
9
|
|
|
10
10
|
const { promise, resolve } = withResolvers()
|
|
11
11
|
let count = 0
|
|
@@ -20,14 +20,14 @@ test('a limited warning can be re-set', t => {
|
|
|
20
20
|
message: 'Hello world'
|
|
21
21
|
})
|
|
22
22
|
|
|
23
|
-
warn()
|
|
23
|
+
t.assert.strictEqual(warn(), true)
|
|
24
24
|
t.assert.ok(warn.emitted)
|
|
25
25
|
|
|
26
|
-
warn()
|
|
26
|
+
t.assert.strictEqual(warn(), false)
|
|
27
27
|
t.assert.ok(warn.emitted)
|
|
28
28
|
|
|
29
29
|
warn.emitted = false
|
|
30
|
-
warn()
|
|
30
|
+
t.assert.strictEqual(warn(), true)
|
|
31
31
|
t.assert.ok(warn.emitted)
|
|
32
32
|
|
|
33
33
|
setImmediate(() => {
|
|
@@ -5,7 +5,7 @@ const { createWarning } = require('..')
|
|
|
5
5
|
const { withResolvers } = require('./promise')
|
|
6
6
|
|
|
7
7
|
test('emit should emit a given code unlimited times', t => {
|
|
8
|
-
t.plan(
|
|
8
|
+
t.plan(60)
|
|
9
9
|
|
|
10
10
|
let runs = 0
|
|
11
11
|
const expectedRun = []
|
|
@@ -31,7 +31,7 @@ test('emit should emit a given code unlimited times', t => {
|
|
|
31
31
|
|
|
32
32
|
for (let i = 0; i < times; i++) {
|
|
33
33
|
expectedRun.push(i)
|
|
34
|
-
warn()
|
|
34
|
+
t.assert.strictEqual(warn(), true)
|
|
35
35
|
}
|
|
36
36
|
setImmediate(() => {
|
|
37
37
|
process.removeListener('warning', onWarning)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { test } = require('node:test')
|
|
4
|
+
const { createWarning } = require('..')
|
|
5
|
+
const { spyWarning } = require('..')
|
|
6
|
+
|
|
7
|
+
test('Spy ProcessWarning - unlimited: false', t => {
|
|
8
|
+
const warning = createWarning({
|
|
9
|
+
name: 'Warning',
|
|
10
|
+
code: 'WRN',
|
|
11
|
+
message: 'Hello %s'
|
|
12
|
+
})
|
|
13
|
+
const spyData = spyWarning(warning)
|
|
14
|
+
|
|
15
|
+
t.assert.strictEqual(warning.emitted, false)
|
|
16
|
+
t.assert.deepStrictEqual(spyData.calls, [])
|
|
17
|
+
t.assert.strictEqual(spyData.callCount(), 0)
|
|
18
|
+
|
|
19
|
+
warning('World')
|
|
20
|
+
t.assert.strictEqual(warning.emitted, true)
|
|
21
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
|
|
22
|
+
t.assert.strictEqual(spyData.calls[0].result, true)
|
|
23
|
+
t.assert.strictEqual(spyData.callCount(), 1)
|
|
24
|
+
|
|
25
|
+
warning('World')
|
|
26
|
+
t.assert.strictEqual(warning.emitted, true)
|
|
27
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
|
|
28
|
+
t.assert.strictEqual(spyData.calls[0].result, true)
|
|
29
|
+
t.assert.deepStrictEqual(spyData.calls[1].arguments, ['World'])
|
|
30
|
+
t.assert.strictEqual(spyData.calls[1].result, false)
|
|
31
|
+
t.assert.strictEqual(spyData.callCount(), 2)
|
|
32
|
+
|
|
33
|
+
spyData.reset()
|
|
34
|
+
t.assert.strictEqual(warning.emitted, false)
|
|
35
|
+
t.assert.deepStrictEqual(spyData.calls, [])
|
|
36
|
+
t.assert.strictEqual(spyData.callCount(), 0)
|
|
37
|
+
|
|
38
|
+
warning('World')
|
|
39
|
+
t.assert.strictEqual(warning.emitted, true)
|
|
40
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
|
|
41
|
+
t.assert.strictEqual(spyData.calls[0].result, true)
|
|
42
|
+
t.assert.strictEqual(spyData.callCount(), 1)
|
|
43
|
+
|
|
44
|
+
spyData.restore()
|
|
45
|
+
t.assert.strictEqual(warning.emitted, false)
|
|
46
|
+
t.assert.deepStrictEqual(spyData.calls, [])
|
|
47
|
+
t.assert.strictEqual(spyData.callCount(), 0)
|
|
48
|
+
|
|
49
|
+
warning('World')
|
|
50
|
+
t.assert.strictEqual(warning.emitted, true)
|
|
51
|
+
t.assert.deepStrictEqual(spyData.calls, [])
|
|
52
|
+
t.assert.strictEqual(spyData.callCount(), 0)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('Spy ProcessWarning - unlimited: true', t => {
|
|
56
|
+
const warning = createWarning({
|
|
57
|
+
name: 'Warning',
|
|
58
|
+
code: 'WRN',
|
|
59
|
+
message: 'Hello %s',
|
|
60
|
+
unlimited: true
|
|
61
|
+
})
|
|
62
|
+
const spyData = spyWarning(warning)
|
|
63
|
+
|
|
64
|
+
t.assert.strictEqual(warning.emitted, false)
|
|
65
|
+
t.assert.deepStrictEqual(spyData.calls, [])
|
|
66
|
+
t.assert.strictEqual(spyData.callCount(), 0)
|
|
67
|
+
|
|
68
|
+
warning('World')
|
|
69
|
+
t.assert.strictEqual(warning.emitted, true)
|
|
70
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
|
|
71
|
+
t.assert.strictEqual(spyData.calls[0].result, true)
|
|
72
|
+
t.assert.strictEqual(spyData.callCount(), 1)
|
|
73
|
+
|
|
74
|
+
warning('World')
|
|
75
|
+
t.assert.strictEqual(warning.emitted, true)
|
|
76
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
|
|
77
|
+
t.assert.strictEqual(spyData.calls[0].result, true)
|
|
78
|
+
t.assert.deepStrictEqual(spyData.calls[1].arguments, ['World'])
|
|
79
|
+
t.assert.strictEqual(spyData.calls[1].result, true)
|
|
80
|
+
t.assert.strictEqual(spyData.callCount(), 2)
|
|
81
|
+
|
|
82
|
+
spyData.reset()
|
|
83
|
+
t.assert.strictEqual(warning.emitted, false)
|
|
84
|
+
t.assert.deepStrictEqual(spyData.calls, [])
|
|
85
|
+
t.assert.strictEqual(spyData.callCount(), 0)
|
|
86
|
+
|
|
87
|
+
warning('World')
|
|
88
|
+
t.assert.strictEqual(warning.emitted, true)
|
|
89
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
|
|
90
|
+
t.assert.strictEqual(spyData.calls[0].result, true)
|
|
91
|
+
t.assert.strictEqual(spyData.callCount(), 1)
|
|
92
|
+
|
|
93
|
+
spyData.restore()
|
|
94
|
+
t.assert.strictEqual(warning.emitted, false)
|
|
95
|
+
t.assert.deepStrictEqual(spyData.calls, [])
|
|
96
|
+
t.assert.strictEqual(spyData.callCount(), 0)
|
|
97
|
+
|
|
98
|
+
warning('World')
|
|
99
|
+
t.assert.strictEqual(warning.emitted, true)
|
|
100
|
+
t.assert.deepStrictEqual(spyData.calls, [])
|
|
101
|
+
t.assert.strictEqual(spyData.callCount(), 0)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
test('Spy ProcessWarning - calls[].arguments', t => {
|
|
105
|
+
const warning = createWarning({
|
|
106
|
+
name: 'Warning',
|
|
107
|
+
code: 'WRN',
|
|
108
|
+
message: 'Hello %s'
|
|
109
|
+
})
|
|
110
|
+
const spyData = spyWarning(warning)
|
|
111
|
+
|
|
112
|
+
warning(undefined)
|
|
113
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, [])
|
|
114
|
+
spyData.reset()
|
|
115
|
+
|
|
116
|
+
warning()
|
|
117
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, [])
|
|
118
|
+
spyData.reset()
|
|
119
|
+
|
|
120
|
+
warning('World')
|
|
121
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World'])
|
|
122
|
+
spyData.reset()
|
|
123
|
+
|
|
124
|
+
warning('World', 'Hello')
|
|
125
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World', 'Hello'])
|
|
126
|
+
spyData.reset()
|
|
127
|
+
|
|
128
|
+
warning(undefined, 'Hello')
|
|
129
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, [undefined, 'Hello'])
|
|
130
|
+
spyData.reset()
|
|
131
|
+
|
|
132
|
+
warning('World', 'Hello', 'World')
|
|
133
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World', 'Hello', 'World'])
|
|
134
|
+
spyData.reset()
|
|
135
|
+
|
|
136
|
+
warning('World', undefined, 'World')
|
|
137
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, ['World', undefined, 'World'])
|
|
138
|
+
spyData.reset()
|
|
139
|
+
|
|
140
|
+
warning(undefined, 'Hello', 'World')
|
|
141
|
+
t.assert.deepStrictEqual(spyData.calls[0].arguments, [undefined, 'Hello', 'World'])
|
|
142
|
+
spyData.reset()
|
|
143
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare namespace processWarning {
|
|
2
2
|
export interface WarningItem {
|
|
3
|
-
(a?: any, b?: any, c?: any):
|
|
3
|
+
(a?: any, b?: any, c?: any): boolean;
|
|
4
4
|
name: string;
|
|
5
5
|
code: string;
|
|
6
6
|
message: string;
|
|
@@ -22,13 +22,27 @@ declare namespace processWarning {
|
|
|
22
22
|
unlimited?: boolean;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export type WarningSpyData = {
|
|
26
|
+
calls: WarningCallData[],
|
|
27
|
+
callCount(): number
|
|
28
|
+
reset(): void
|
|
29
|
+
restore(): void
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type WarningCallData = {
|
|
33
|
+
arguments: unknown[]
|
|
34
|
+
result: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
25
37
|
export type ProcessWarning = {
|
|
26
38
|
createWarning(params: WarningOptions): WarningItem;
|
|
27
39
|
createDeprecation(params: DeprecationOptions): WarningItem;
|
|
40
|
+
spyWarning(warning: WarningItem): WarningSpyData
|
|
28
41
|
}
|
|
29
42
|
|
|
30
43
|
export function createWarning (params: WarningOptions): WarningItem
|
|
31
44
|
export function createDeprecation (params: DeprecationOptions): WarningItem
|
|
45
|
+
export function spyWarning (warning: WarningItem): WarningSpyData
|
|
32
46
|
|
|
33
47
|
const processWarning: ProcessWarning
|
|
34
48
|
export { processWarning as default }
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { expect } from 'tstyche'
|
|
2
|
+
import { createDeprecation, createWarning, spyWarning, WarningCallData, WarningSpyData } from '..'
|
|
3
|
+
|
|
4
|
+
const WarnInstance = createWarning({
|
|
5
|
+
name: 'TypeScriptWarning',
|
|
6
|
+
code: 'CODE',
|
|
7
|
+
message: 'message'
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
expect(WarnInstance.code).type.toBe<string>()
|
|
11
|
+
expect(WarnInstance.message).type.toBe<string>()
|
|
12
|
+
expect(WarnInstance.name).type.toBe<string>()
|
|
13
|
+
expect(WarnInstance.emitted).type.toBe<boolean>()
|
|
14
|
+
expect(WarnInstance.unlimited).type.toBe<boolean>()
|
|
15
|
+
|
|
16
|
+
expect(WarnInstance()).type.toBe<boolean>()
|
|
17
|
+
expect(WarnInstance('foo')).type.toBe<boolean>()
|
|
18
|
+
expect(WarnInstance('foo', 'bar')).type.toBe<boolean>()
|
|
19
|
+
|
|
20
|
+
const buildWarnUnlimited = createWarning({
|
|
21
|
+
name: 'TypeScriptWarning',
|
|
22
|
+
code: 'CODE',
|
|
23
|
+
message: 'message',
|
|
24
|
+
unlimited: true
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
expect(buildWarnUnlimited.unlimited).type.toBe<boolean>()
|
|
28
|
+
|
|
29
|
+
const DeprecationInstance = createDeprecation({
|
|
30
|
+
code: 'CODE',
|
|
31
|
+
message: 'message'
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
expect(DeprecationInstance.code).type.toBe<string>()
|
|
35
|
+
|
|
36
|
+
expect(DeprecationInstance()).type.toBe<boolean>()
|
|
37
|
+
expect(DeprecationInstance('foo')).type.toBe<boolean>()
|
|
38
|
+
expect(DeprecationInstance('foo', 'bar')).type.toBe<boolean>()
|
|
39
|
+
|
|
40
|
+
const spyData = spyWarning(WarnInstance)
|
|
41
|
+
expect(spyData).type.toBe<WarningSpyData>()
|
|
42
|
+
expect(spyData.calls).type.toBe<WarningCallData[]>()
|
|
43
|
+
expect(spyData.callCount).type.toBe<(() => number)>()
|
|
44
|
+
expect(spyData.callCount()).type.toBe<number>()
|
|
45
|
+
expect(spyData.reset).type.toBe<(() => void)>()
|
|
46
|
+
expect(spyData.reset()).type.toBe<void>()
|
|
47
|
+
expect(spyData.restore).type.toBe<(() => void)>()
|
|
48
|
+
expect(spyData.restore()).type.toBe<void>()
|
|
@@ -167,7 +167,9 @@ class PerMessageDeflate {
|
|
|
167
167
|
(typeof opts.serverMaxWindowBits === 'number' &&
|
|
168
168
|
opts.serverMaxWindowBits > params.server_max_window_bits))) ||
|
|
169
169
|
(typeof opts.clientMaxWindowBits === 'number' &&
|
|
170
|
-
|
|
170
|
+
(typeof params.client_max_window_bits === 'number'
|
|
171
|
+
? opts.clientMaxWindowBits > params.client_max_window_bits
|
|
172
|
+
: !params.client_max_window_bits))
|
|
171
173
|
) {
|
|
172
174
|
return false;
|
|
173
175
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const Email = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]
|
|
1
|
+
const Email = /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[^"\\]|\\[\x20-\x7e])*")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*|\[(?:IPv6:[a-f0-9:]+|(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?:\.(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3})\])$/i;
|
|
2
2
|
/**
|
|
3
3
|
* Returns true if the value is an Email
|
|
4
4
|
* @specification https://datatracker.ietf.org/doc/html/rfc5322
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as FormatBidi from './format/bidi.mjs';
|
|
2
2
|
import * as LabelUnicode from './label/unicode.mjs';
|
|
3
3
|
import * as LabelPuny from './label/puny.mjs';
|
|
4
|
+
// ------------------------------------------------------------------
|
|
5
|
+
// IsLabel
|
|
6
|
+
// ------------------------------------------------------------------
|
|
4
7
|
function IsValidLabelLength(value) {
|
|
5
8
|
return value.length > 0 && value.length <= 63;
|
|
6
9
|
}
|
|
@@ -8,9 +11,24 @@ function IsLabel(value) {
|
|
|
8
11
|
return IsValidLabelLength(value) && (LabelPuny.IsPunyLabel(value) ||
|
|
9
12
|
LabelUnicode.IsUnicodeLabel(value));
|
|
10
13
|
}
|
|
14
|
+
// ------------------------------------------------------------------
|
|
15
|
+
// NormalizeHostname
|
|
16
|
+
//
|
|
17
|
+
// Normalizes a hostname for label validation. Normalizes for NFC
|
|
18
|
+
// such that equivalent codepoint sequences can be uniformly
|
|
19
|
+
// compared. It also removes codepoints that IDNA mapping ignores,
|
|
20
|
+
// and converts full stop variants to ASCII '.' so the hostname can
|
|
21
|
+
// be split into labels.
|
|
22
|
+
// ------------------------------------------------------------------
|
|
11
23
|
function NormalizeHostname(value) {
|
|
12
|
-
return value
|
|
24
|
+
return value
|
|
25
|
+
.normalize('NFC')
|
|
26
|
+
.replace(/[\u00ad\u034f\u180b-\u180d\u200b\ufe00-\ufe0f\u{e0100}-\u{e01ef}]/gu, '') // RE_IGNORED_MAPPING
|
|
27
|
+
.replace(/[\u002E\u3002\uFF0E\uFF61]/g, '.'); // RE_FULL_STOP_MAPPING
|
|
13
28
|
}
|
|
29
|
+
// ------------------------------------------------------------------
|
|
30
|
+
// IsIdnHostname
|
|
31
|
+
// ------------------------------------------------------------------
|
|
14
32
|
export function IsIdnHostname(value) {
|
|
15
33
|
if (value.length === 0 || value.includes(' '))
|
|
16
34
|
return false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns true if the value is a json pointer
|
|
3
|
-
* @specification
|
|
4
|
-
* @source ajv-formats
|
|
3
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc6901
|
|
4
|
+
* @source https://github.com/ajv-validator/ajv-formats
|
|
5
5
|
*/
|
|
6
6
|
export declare function IsJsonPointer(value: string): boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const JsonPointer = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
|
|
2
2
|
/**
|
|
3
3
|
* Returns true if the value is a json pointer
|
|
4
|
-
* @specification
|
|
5
|
-
* @source ajv-formats
|
|
4
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc6901
|
|
5
|
+
* @source https://github.com/ajv-validator/ajv-formats
|
|
6
6
|
*/
|
|
7
7
|
export function IsJsonPointer(value) {
|
|
8
8
|
return JsonPointer.test(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns true if the value is a json pointer uri fragment
|
|
3
|
-
* @specification
|
|
4
|
-
* @source ajv-formats
|
|
3
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc6901
|
|
4
|
+
* @source https://github.com/ajv-validator/ajv-formats
|
|
5
5
|
*/
|
|
6
6
|
export declare function IsJsonPointerUriFragment(value: string): boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const JsonPointerUriFragment = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
|
|
2
2
|
/**
|
|
3
3
|
* Returns true if the value is a json pointer uri fragment
|
|
4
|
-
* @specification
|
|
5
|
-
* @source ajv-formats
|
|
4
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc6901
|
|
5
|
+
* @source https://github.com/ajv-validator/ajv-formats
|
|
6
6
|
*/
|
|
7
7
|
export function IsJsonPointerUriFragment(value) {
|
|
8
8
|
return JsonPointerUriFragment.test(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns true if the value is a relative json pointer
|
|
3
|
-
* @specification
|
|
4
|
-
* @source ajv-formats
|
|
3
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc6901
|
|
4
|
+
* @source https://github.com/ajv-validator/ajv-formats
|
|
5
5
|
*/
|
|
6
6
|
export declare function IsRelativeJsonPointer(value: string): boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const RelativeJsonPointer = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
|
|
2
2
|
/**
|
|
3
3
|
* Returns true if the value is a relative json pointer
|
|
4
|
-
* @specification
|
|
5
|
-
* @source ajv-formats
|
|
4
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc6901
|
|
5
|
+
* @source https://github.com/ajv-validator/ajv-formats
|
|
6
6
|
*/
|
|
7
7
|
export function IsRelativeJsonPointer(value) {
|
|
8
8
|
return RelativeJsonPointer.test(value);
|