@acala-network/chopsticks-testing 1.1.0 → 1.1.1

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.
@@ -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,
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks-testing",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  "depcheck": "npx depcheck"
14
14
  },
15
15
  "dependencies": {
16
- "@acala-network/chopsticks-utils": "1.1.0",
16
+ "@acala-network/chopsticks-utils": "1.1.1",
17
17
  "@polkadot/api": "^16.2.1",
18
18
  "@polkadot/types": "^16.2.1"
19
19
  },