@acala-network/chopsticks-testing 1.1.0 → 1.2.0
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/cjs/check.d.ts +7 -0
- package/dist/cjs/check.js +21 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/esm/check.d.ts +7 -0
- package/dist/esm/check.js +17 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/package.json +7 -7
package/dist/cjs/check.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type RedactOptions = {
|
|
|
24
24
|
redactKeys?: RegExp;
|
|
25
25
|
/** Regex pattern for keys that should be removed */
|
|
26
26
|
removeKeys?: RegExp;
|
|
27
|
+
/** Regex pattern for keys that should not be redacted */
|
|
28
|
+
noRedactKeys?: RegExp;
|
|
27
29
|
};
|
|
28
30
|
/**
|
|
29
31
|
* Function type for test assertions
|
|
@@ -77,6 +79,11 @@ export declare class Checker {
|
|
|
77
79
|
* @param fn - Function to apply
|
|
78
80
|
*/
|
|
79
81
|
pipe(fn?: (value: Checker) => Checker): Checker;
|
|
82
|
+
/**
|
|
83
|
+
* Add an extra check function to the pipeline
|
|
84
|
+
* @param fn - Extra check function
|
|
85
|
+
*/
|
|
86
|
+
check(fn: (value: any) => Promise<void> | void): this;
|
|
80
87
|
/**
|
|
81
88
|
* Get the final processed value
|
|
82
89
|
* @returns Processed value after applying all transformations
|
package/dist/cjs/check.js
CHANGED
|
@@ -84,7 +84,7 @@ function _class_private_method_init(obj, privateSet) {
|
|
|
84
84
|
* Converts Codec data to JSON format
|
|
85
85
|
* @param codec - Codec data to convert
|
|
86
86
|
*/ const toJson = (codec)=>processCodecOrArray(codec, (c)=>c?.toJSON?.() ?? c);
|
|
87
|
-
var _expectFn = /*#__PURE__*/ new WeakMap(), _value = /*#__PURE__*/ new WeakMap(), _pipeline = /*#__PURE__*/ new WeakMap(), _format = /*#__PURE__*/ new WeakMap(), _message = /*#__PURE__*/ new WeakMap(), _redactOptions = /*#__PURE__*/ new WeakMap(), _redact = /*#__PURE__*/ new WeakSet();
|
|
87
|
+
var _expectFn = /*#__PURE__*/ new WeakMap(), _value = /*#__PURE__*/ new WeakMap(), _pipeline = /*#__PURE__*/ new WeakMap(), _extraChecks = /*#__PURE__*/ new WeakMap(), _format = /*#__PURE__*/ new WeakMap(), _message = /*#__PURE__*/ new WeakMap(), _redactOptions = /*#__PURE__*/ new WeakMap(), _redact = /*#__PURE__*/ new WeakSet();
|
|
88
88
|
class Checker {
|
|
89
89
|
/** Convert the checked value to human-readable format */ toHuman() {
|
|
90
90
|
_class_private_field_set(this, _format, 'human');
|
|
@@ -156,6 +156,13 @@ class Checker {
|
|
|
156
156
|
return fn ? fn(this) : this;
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
|
+
* Add an extra check function to the pipeline
|
|
160
|
+
* @param fn - Extra check function
|
|
161
|
+
*/ check(fn) {
|
|
162
|
+
_class_private_field_get(this, _extraChecks).push(fn);
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
159
166
|
* Get the final processed value
|
|
160
167
|
* @returns Processed value after applying all transformations
|
|
161
168
|
*/ async value() {
|
|
@@ -175,6 +182,9 @@ class Checker {
|
|
|
175
182
|
value = await fn(value);
|
|
176
183
|
}
|
|
177
184
|
value = _class_private_method_get(this, _redact, redact).call(this, value);
|
|
185
|
+
for (const fn of _class_private_field_get(this, _extraChecks)){
|
|
186
|
+
await fn(value);
|
|
187
|
+
}
|
|
178
188
|
return value;
|
|
179
189
|
}
|
|
180
190
|
/**
|
|
@@ -216,6 +226,10 @@ class Checker {
|
|
|
216
226
|
writable: true,
|
|
217
227
|
value: []
|
|
218
228
|
});
|
|
229
|
+
_class_private_field_init(this, _extraChecks, {
|
|
230
|
+
writable: true,
|
|
231
|
+
value: []
|
|
232
|
+
});
|
|
219
233
|
_class_private_field_init(this, _format, {
|
|
220
234
|
writable: true,
|
|
221
235
|
value: 'json'
|
|
@@ -293,6 +307,12 @@ function redact(value) {
|
|
|
293
307
|
}
|
|
294
308
|
return true;
|
|
295
309
|
}).map(([k, v])=>{
|
|
310
|
+
if (_class_private_field_get(this, _redactOptions)?.noRedactKeys?.test(k)) {
|
|
311
|
+
return [
|
|
312
|
+
k,
|
|
313
|
+
v
|
|
314
|
+
];
|
|
315
|
+
}
|
|
296
316
|
if (_class_private_field_get(this, _redactOptions)?.redactKeys?.test(k)) {
|
|
297
317
|
return [
|
|
298
318
|
k,
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
_export_star(require("./check.js"), exports);
|
|
6
5
|
_export_star(require("@acala-network/chopsticks-utils"), exports);
|
|
6
|
+
_export_star(require("./check.js"), exports);
|
|
7
7
|
function _export_star(from, to) {
|
|
8
8
|
Object.keys(from).forEach(function(k) {
|
|
9
9
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
package/dist/esm/check.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type RedactOptions = {
|
|
|
24
24
|
redactKeys?: RegExp;
|
|
25
25
|
/** Regex pattern for keys that should be removed */
|
|
26
26
|
removeKeys?: RegExp;
|
|
27
|
+
/** Regex pattern for keys that should not be redacted */
|
|
28
|
+
noRedactKeys?: RegExp;
|
|
27
29
|
};
|
|
28
30
|
/**
|
|
29
31
|
* Function type for test assertions
|
|
@@ -77,6 +79,11 @@ export declare class Checker {
|
|
|
77
79
|
* @param fn - Function to apply
|
|
78
80
|
*/
|
|
79
81
|
pipe(fn?: (value: Checker) => Checker): Checker;
|
|
82
|
+
/**
|
|
83
|
+
* Add an extra check function to the pipeline
|
|
84
|
+
* @param fn - Extra check function
|
|
85
|
+
*/
|
|
86
|
+
check(fn: (value: any) => Promise<void> | void): this;
|
|
80
87
|
/**
|
|
81
88
|
* Get the final processed value
|
|
82
89
|
* @returns Processed value after applying all transformations
|
package/dist/esm/check.js
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
#expectFn;
|
|
24
24
|
#value;
|
|
25
25
|
#pipeline = [];
|
|
26
|
+
#extraChecks = [];
|
|
26
27
|
#format = 'json';
|
|
27
28
|
#message;
|
|
28
29
|
#redactOptions;
|
|
@@ -152,6 +153,12 @@
|
|
|
152
153
|
}
|
|
153
154
|
return true;
|
|
154
155
|
}).map(([k, v])=>{
|
|
156
|
+
if (this.#redactOptions?.noRedactKeys?.test(k)) {
|
|
157
|
+
return [
|
|
158
|
+
k,
|
|
159
|
+
v
|
|
160
|
+
];
|
|
161
|
+
}
|
|
155
162
|
if (this.#redactOptions?.redactKeys?.test(k)) {
|
|
156
163
|
return [
|
|
157
164
|
k,
|
|
@@ -182,6 +189,13 @@
|
|
|
182
189
|
return fn ? fn(this) : this;
|
|
183
190
|
}
|
|
184
191
|
/**
|
|
192
|
+
* Add an extra check function to the pipeline
|
|
193
|
+
* @param fn - Extra check function
|
|
194
|
+
*/ check(fn) {
|
|
195
|
+
this.#extraChecks.push(fn);
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
185
199
|
* Get the final processed value
|
|
186
200
|
* @returns Processed value after applying all transformations
|
|
187
201
|
*/ async value() {
|
|
@@ -201,6 +215,9 @@
|
|
|
201
215
|
value = await fn(value);
|
|
202
216
|
}
|
|
203
217
|
value = this.#redact(value);
|
|
218
|
+
for (const fn of this.#extraChecks){
|
|
219
|
+
await fn(value);
|
|
220
|
+
}
|
|
204
221
|
return value;
|
|
205
222
|
}
|
|
206
223
|
/**
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acala-network/chopsticks-testing",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"author": "Acala Developers <hello@acala.network>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": ">=
|
|
8
|
+
"node": ">=v22"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"depcheck": "npx depcheck"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@acala-network/chopsticks-utils": "1.
|
|
17
|
-
"@polkadot/api": "^16.
|
|
18
|
-
"@polkadot/types": "^16.
|
|
16
|
+
"@acala-network/chopsticks-utils": "1.2.0",
|
|
17
|
+
"@polkadot/api": "^16.4.1",
|
|
18
|
+
"@polkadot/types": "^16.4.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@swc/cli": "0.7.
|
|
22
|
-
"@swc/core": "^1.12.
|
|
21
|
+
"@swc/cli": "0.7.8",
|
|
22
|
+
"@swc/core": "^1.12.11",
|
|
23
23
|
"typescript": "^5.8.3"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|