@riddledc/riddle-proof 0.7.127 → 0.7.128
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/README.md +3 -1
- package/dist/{chunk-JLINSUKO.js → chunk-TO3FVF5S.js} +73 -2
- package/dist/cli.cjs +73 -2
- package/dist/cli.js +1 -1
- package/dist/index.cjs +73 -2
- package/dist/index.js +1 -1
- package/dist/profile.cjs +73 -2
- package/dist/profile.d.cts +4 -0
- package/dist/profile.d.ts +4 -0
- package/dist/profile.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -612,7 +612,9 @@ a field value rather than a raw substring:
|
|
|
612
612
|
|
|
613
613
|
JSON paths support dot keys and array indexes such as `checks[0].status`, with
|
|
614
614
|
`$` as the root. Each assertion supports `exists`, `equals`, `not_equals`,
|
|
615
|
-
`contains`, and `type`.
|
|
615
|
+
`contains`, and `type`. Scalar observations are recorded inline; arrays and
|
|
616
|
+
objects are summarized with length or key counts plus a small sample so large
|
|
617
|
+
proof artifacts do not get duplicated into the assertion evidence.
|
|
616
618
|
|
|
617
619
|
`body_contains`, `body_patterns`, `body_not_contains`, and
|
|
618
620
|
`body_not_patterns` match the raw HTTP response body, not rendered browser
|
|
@@ -244,6 +244,37 @@ function jsonValueType(value) {
|
|
|
244
244
|
if (typeof value === "string") return "string";
|
|
245
245
|
return "object";
|
|
246
246
|
}
|
|
247
|
+
function compactJsonAssertionSample(value, depth = 0) {
|
|
248
|
+
if (typeof value === "string") return value.length > 240 ? `${value.slice(0, 237)}...` : value;
|
|
249
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") return toJsonValue(value);
|
|
250
|
+
if (Array.isArray(value)) {
|
|
251
|
+
if (depth >= 2) return `[array:${value.length}]`;
|
|
252
|
+
return value.slice(0, 3).map((item) => compactJsonAssertionSample(item, depth + 1));
|
|
253
|
+
}
|
|
254
|
+
if (isRecord(value)) {
|
|
255
|
+
const entries = Object.entries(value).slice(0, 8);
|
|
256
|
+
if (depth >= 2) return `[object:${Object.keys(value).length} keys]`;
|
|
257
|
+
return Object.fromEntries(entries.map(([key, child]) => [key, compactJsonAssertionSample(child, depth + 1)]));
|
|
258
|
+
}
|
|
259
|
+
return String(value);
|
|
260
|
+
}
|
|
261
|
+
function attachJsonAssertionObservedValue(result, value) {
|
|
262
|
+
const type = jsonValueType(value);
|
|
263
|
+
if (type === "array" && Array.isArray(value)) {
|
|
264
|
+
result.observed_length = value.length;
|
|
265
|
+
result.observed_omitted_count = Math.max(0, value.length - 3);
|
|
266
|
+
result.observed_sample = compactJsonAssertionSample(value);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (type === "object" && isRecord(value)) {
|
|
270
|
+
const keyCount = Object.keys(value).length;
|
|
271
|
+
result.observed_key_count = keyCount;
|
|
272
|
+
result.observed_omitted_count = Math.max(0, keyCount - 8);
|
|
273
|
+
result.observed_sample = compactJsonAssertionSample(value);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
result.observed = toJsonValue(value);
|
|
277
|
+
}
|
|
247
278
|
function deepJsonEqual(left, right) {
|
|
248
279
|
if (left === right) return true;
|
|
249
280
|
if (typeof left !== typeof right) return false;
|
|
@@ -341,7 +372,7 @@ function evaluateHttpStatusBodyJsonAssertion(root, assertion) {
|
|
|
341
372
|
exists: resolved.exists,
|
|
342
373
|
observed_type: resolved.exists ? jsonValueType(resolved.value) : "missing"
|
|
343
374
|
};
|
|
344
|
-
if (resolved.exists) result
|
|
375
|
+
if (resolved.exists) attachJsonAssertionObservedValue(result, resolved.value);
|
|
345
376
|
if (resolved.error) errors.push(resolved.error);
|
|
346
377
|
if (hasOwn(assertion, "exists")) {
|
|
347
378
|
result.expected_exists = assertion.exists;
|
|
@@ -1434,6 +1465,10 @@ function httpStatusBodyJsonAssertionFailures(result, check) {
|
|
|
1434
1465
|
ok: false,
|
|
1435
1466
|
exists: assertion.exists === true,
|
|
1436
1467
|
observed: hasOwn(assertion, "observed") ? toJsonValue(assertion.observed) : void 0,
|
|
1468
|
+
observed_sample: hasOwn(assertion, "observed_sample") ? toJsonValue(assertion.observed_sample) : void 0,
|
|
1469
|
+
observed_length: numberValue(assertion.observed_length),
|
|
1470
|
+
observed_key_count: numberValue(assertion.observed_key_count),
|
|
1471
|
+
observed_omitted_count: numberValue(assertion.observed_omitted_count),
|
|
1437
1472
|
observed_type: stringValue(assertion.observed_type) || "missing",
|
|
1438
1473
|
expected_exists: booleanValue(assertion.expected_exists),
|
|
1439
1474
|
equals: hasOwn(assertion, "equals") ? toJsonValue(assertion.equals) : void 0,
|
|
@@ -3064,6 +3099,10 @@ function httpStatusBodyJsonAssertionFailures(result, check) {
|
|
|
3064
3099
|
ok: false,
|
|
3065
3100
|
exists: assertion.exists === true,
|
|
3066
3101
|
observed: Object.hasOwn(assertion, "observed") ? assertion.observed : undefined,
|
|
3102
|
+
observed_sample: Object.hasOwn(assertion, "observed_sample") ? assertion.observed_sample : undefined,
|
|
3103
|
+
observed_length: typeof assertion.observed_length === "number" && Number.isFinite(assertion.observed_length) ? assertion.observed_length : undefined,
|
|
3104
|
+
observed_key_count: typeof assertion.observed_key_count === "number" && Number.isFinite(assertion.observed_key_count) ? assertion.observed_key_count : undefined,
|
|
3105
|
+
observed_omitted_count: typeof assertion.observed_omitted_count === "number" && Number.isFinite(assertion.observed_omitted_count) ? assertion.observed_omitted_count : undefined,
|
|
3067
3106
|
observed_type: typeof assertion.observed_type === "string" && assertion.observed_type ? assertion.observed_type : "missing",
|
|
3068
3107
|
expected_exists: typeof assertion.expected_exists === "boolean" ? assertion.expected_exists : undefined,
|
|
3069
3108
|
equals: Object.hasOwn(assertion, "equals") ? assertion.equals : undefined,
|
|
@@ -5271,6 +5310,38 @@ function jsonProbeValueType(value) {
|
|
|
5271
5310
|
if (typeof value === "string") return "string";
|
|
5272
5311
|
return "object";
|
|
5273
5312
|
}
|
|
5313
|
+
function compactJsonProbeSample(value, depth) {
|
|
5314
|
+
const level = typeof depth === "number" ? depth : 0;
|
|
5315
|
+
if (typeof value === "string") return value.length > 240 ? value.slice(0, 237) + "..." : value;
|
|
5316
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") return value;
|
|
5317
|
+
if (Array.isArray(value)) {
|
|
5318
|
+
if (level >= 2) return "[array:" + value.length + "]";
|
|
5319
|
+
return value.slice(0, 3).map((item) => compactJsonProbeSample(item, level + 1));
|
|
5320
|
+
}
|
|
5321
|
+
if (value && typeof value === "object") {
|
|
5322
|
+
const entries = Object.entries(value);
|
|
5323
|
+
if (level >= 2) return "[object:" + entries.length + " keys]";
|
|
5324
|
+
return Object.fromEntries(entries.slice(0, 8).map(([key, child]) => [key, compactJsonProbeSample(child, level + 1)]));
|
|
5325
|
+
}
|
|
5326
|
+
return String(value);
|
|
5327
|
+
}
|
|
5328
|
+
function attachJsonProbeObservedValue(result, value) {
|
|
5329
|
+
const type = jsonProbeValueType(value);
|
|
5330
|
+
if (type === "array" && Array.isArray(value)) {
|
|
5331
|
+
result.observed_length = value.length;
|
|
5332
|
+
result.observed_omitted_count = Math.max(0, value.length - 3);
|
|
5333
|
+
result.observed_sample = compactJsonProbeSample(value, 0);
|
|
5334
|
+
return;
|
|
5335
|
+
}
|
|
5336
|
+
if (type === "object" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
5337
|
+
const keyCount = Object.keys(value).length;
|
|
5338
|
+
result.observed_key_count = keyCount;
|
|
5339
|
+
result.observed_omitted_count = Math.max(0, keyCount - 8);
|
|
5340
|
+
result.observed_sample = compactJsonProbeSample(value, 0);
|
|
5341
|
+
return;
|
|
5342
|
+
}
|
|
5343
|
+
result.observed = value;
|
|
5344
|
+
}
|
|
5274
5345
|
function jsonProbeDeepEqual(left, right) {
|
|
5275
5346
|
if (left === right) return true;
|
|
5276
5347
|
if (typeof left !== typeof right) return false;
|
|
@@ -5367,7 +5438,7 @@ function evaluateJsonProbeAssertion(root, assertion) {
|
|
|
5367
5438
|
exists: resolved.exists,
|
|
5368
5439
|
observed_type: resolved.exists ? jsonProbeValueType(resolved.value) : "missing",
|
|
5369
5440
|
};
|
|
5370
|
-
if (resolved.exists) result
|
|
5441
|
+
if (resolved.exists) attachJsonProbeObservedValue(result, resolved.value);
|
|
5371
5442
|
if (resolved.error) errors.push(resolved.error);
|
|
5372
5443
|
if (Object.hasOwn(assertion, "exists")) {
|
|
5373
5444
|
result.expected_exists = assertion.exists;
|
package/dist/cli.cjs
CHANGED
|
@@ -7181,6 +7181,37 @@ function jsonValueType(value) {
|
|
|
7181
7181
|
if (typeof value === "string") return "string";
|
|
7182
7182
|
return "object";
|
|
7183
7183
|
}
|
|
7184
|
+
function compactJsonAssertionSample(value, depth = 0) {
|
|
7185
|
+
if (typeof value === "string") return value.length > 240 ? `${value.slice(0, 237)}...` : value;
|
|
7186
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") return toJsonValue(value);
|
|
7187
|
+
if (Array.isArray(value)) {
|
|
7188
|
+
if (depth >= 2) return `[array:${value.length}]`;
|
|
7189
|
+
return value.slice(0, 3).map((item) => compactJsonAssertionSample(item, depth + 1));
|
|
7190
|
+
}
|
|
7191
|
+
if (isRecord(value)) {
|
|
7192
|
+
const entries = Object.entries(value).slice(0, 8);
|
|
7193
|
+
if (depth >= 2) return `[object:${Object.keys(value).length} keys]`;
|
|
7194
|
+
return Object.fromEntries(entries.map(([key, child]) => [key, compactJsonAssertionSample(child, depth + 1)]));
|
|
7195
|
+
}
|
|
7196
|
+
return String(value);
|
|
7197
|
+
}
|
|
7198
|
+
function attachJsonAssertionObservedValue(result, value) {
|
|
7199
|
+
const type = jsonValueType(value);
|
|
7200
|
+
if (type === "array" && Array.isArray(value)) {
|
|
7201
|
+
result.observed_length = value.length;
|
|
7202
|
+
result.observed_omitted_count = Math.max(0, value.length - 3);
|
|
7203
|
+
result.observed_sample = compactJsonAssertionSample(value);
|
|
7204
|
+
return;
|
|
7205
|
+
}
|
|
7206
|
+
if (type === "object" && isRecord(value)) {
|
|
7207
|
+
const keyCount = Object.keys(value).length;
|
|
7208
|
+
result.observed_key_count = keyCount;
|
|
7209
|
+
result.observed_omitted_count = Math.max(0, keyCount - 8);
|
|
7210
|
+
result.observed_sample = compactJsonAssertionSample(value);
|
|
7211
|
+
return;
|
|
7212
|
+
}
|
|
7213
|
+
result.observed = toJsonValue(value);
|
|
7214
|
+
}
|
|
7184
7215
|
function deepJsonEqual(left, right) {
|
|
7185
7216
|
if (left === right) return true;
|
|
7186
7217
|
if (typeof left !== typeof right) return false;
|
|
@@ -7278,7 +7309,7 @@ function evaluateHttpStatusBodyJsonAssertion(root, assertion) {
|
|
|
7278
7309
|
exists: resolved.exists,
|
|
7279
7310
|
observed_type: resolved.exists ? jsonValueType(resolved.value) : "missing"
|
|
7280
7311
|
};
|
|
7281
|
-
if (resolved.exists) result
|
|
7312
|
+
if (resolved.exists) attachJsonAssertionObservedValue(result, resolved.value);
|
|
7282
7313
|
if (resolved.error) errors.push(resolved.error);
|
|
7283
7314
|
if (hasOwn(assertion, "exists")) {
|
|
7284
7315
|
result.expected_exists = assertion.exists;
|
|
@@ -8371,6 +8402,10 @@ function httpStatusBodyJsonAssertionFailures(result, check) {
|
|
|
8371
8402
|
ok: false,
|
|
8372
8403
|
exists: assertion.exists === true,
|
|
8373
8404
|
observed: hasOwn(assertion, "observed") ? toJsonValue(assertion.observed) : void 0,
|
|
8405
|
+
observed_sample: hasOwn(assertion, "observed_sample") ? toJsonValue(assertion.observed_sample) : void 0,
|
|
8406
|
+
observed_length: numberValue(assertion.observed_length),
|
|
8407
|
+
observed_key_count: numberValue(assertion.observed_key_count),
|
|
8408
|
+
observed_omitted_count: numberValue(assertion.observed_omitted_count),
|
|
8374
8409
|
observed_type: stringValue2(assertion.observed_type) || "missing",
|
|
8375
8410
|
expected_exists: booleanValue(assertion.expected_exists),
|
|
8376
8411
|
equals: hasOwn(assertion, "equals") ? toJsonValue(assertion.equals) : void 0,
|
|
@@ -9985,6 +10020,10 @@ function httpStatusBodyJsonAssertionFailures(result, check) {
|
|
|
9985
10020
|
ok: false,
|
|
9986
10021
|
exists: assertion.exists === true,
|
|
9987
10022
|
observed: Object.hasOwn(assertion, "observed") ? assertion.observed : undefined,
|
|
10023
|
+
observed_sample: Object.hasOwn(assertion, "observed_sample") ? assertion.observed_sample : undefined,
|
|
10024
|
+
observed_length: typeof assertion.observed_length === "number" && Number.isFinite(assertion.observed_length) ? assertion.observed_length : undefined,
|
|
10025
|
+
observed_key_count: typeof assertion.observed_key_count === "number" && Number.isFinite(assertion.observed_key_count) ? assertion.observed_key_count : undefined,
|
|
10026
|
+
observed_omitted_count: typeof assertion.observed_omitted_count === "number" && Number.isFinite(assertion.observed_omitted_count) ? assertion.observed_omitted_count : undefined,
|
|
9988
10027
|
observed_type: typeof assertion.observed_type === "string" && assertion.observed_type ? assertion.observed_type : "missing",
|
|
9989
10028
|
expected_exists: typeof assertion.expected_exists === "boolean" ? assertion.expected_exists : undefined,
|
|
9990
10029
|
equals: Object.hasOwn(assertion, "equals") ? assertion.equals : undefined,
|
|
@@ -12192,6 +12231,38 @@ function jsonProbeValueType(value) {
|
|
|
12192
12231
|
if (typeof value === "string") return "string";
|
|
12193
12232
|
return "object";
|
|
12194
12233
|
}
|
|
12234
|
+
function compactJsonProbeSample(value, depth) {
|
|
12235
|
+
const level = typeof depth === "number" ? depth : 0;
|
|
12236
|
+
if (typeof value === "string") return value.length > 240 ? value.slice(0, 237) + "..." : value;
|
|
12237
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") return value;
|
|
12238
|
+
if (Array.isArray(value)) {
|
|
12239
|
+
if (level >= 2) return "[array:" + value.length + "]";
|
|
12240
|
+
return value.slice(0, 3).map((item) => compactJsonProbeSample(item, level + 1));
|
|
12241
|
+
}
|
|
12242
|
+
if (value && typeof value === "object") {
|
|
12243
|
+
const entries = Object.entries(value);
|
|
12244
|
+
if (level >= 2) return "[object:" + entries.length + " keys]";
|
|
12245
|
+
return Object.fromEntries(entries.slice(0, 8).map(([key, child]) => [key, compactJsonProbeSample(child, level + 1)]));
|
|
12246
|
+
}
|
|
12247
|
+
return String(value);
|
|
12248
|
+
}
|
|
12249
|
+
function attachJsonProbeObservedValue(result, value) {
|
|
12250
|
+
const type = jsonProbeValueType(value);
|
|
12251
|
+
if (type === "array" && Array.isArray(value)) {
|
|
12252
|
+
result.observed_length = value.length;
|
|
12253
|
+
result.observed_omitted_count = Math.max(0, value.length - 3);
|
|
12254
|
+
result.observed_sample = compactJsonProbeSample(value, 0);
|
|
12255
|
+
return;
|
|
12256
|
+
}
|
|
12257
|
+
if (type === "object" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
12258
|
+
const keyCount = Object.keys(value).length;
|
|
12259
|
+
result.observed_key_count = keyCount;
|
|
12260
|
+
result.observed_omitted_count = Math.max(0, keyCount - 8);
|
|
12261
|
+
result.observed_sample = compactJsonProbeSample(value, 0);
|
|
12262
|
+
return;
|
|
12263
|
+
}
|
|
12264
|
+
result.observed = value;
|
|
12265
|
+
}
|
|
12195
12266
|
function jsonProbeDeepEqual(left, right) {
|
|
12196
12267
|
if (left === right) return true;
|
|
12197
12268
|
if (typeof left !== typeof right) return false;
|
|
@@ -12288,7 +12359,7 @@ function evaluateJsonProbeAssertion(root, assertion) {
|
|
|
12288
12359
|
exists: resolved.exists,
|
|
12289
12360
|
observed_type: resolved.exists ? jsonProbeValueType(resolved.value) : "missing",
|
|
12290
12361
|
};
|
|
12291
|
-
if (resolved.exists) result
|
|
12362
|
+
if (resolved.exists) attachJsonProbeObservedValue(result, resolved.value);
|
|
12292
12363
|
if (resolved.error) errors.push(resolved.error);
|
|
12293
12364
|
if (Object.hasOwn(assertion, "exists")) {
|
|
12294
12365
|
result.expected_exists = assertion.exists;
|
package/dist/cli.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -8977,6 +8977,37 @@ function jsonValueType(value) {
|
|
|
8977
8977
|
if (typeof value === "string") return "string";
|
|
8978
8978
|
return "object";
|
|
8979
8979
|
}
|
|
8980
|
+
function compactJsonAssertionSample(value, depth = 0) {
|
|
8981
|
+
if (typeof value === "string") return value.length > 240 ? `${value.slice(0, 237)}...` : value;
|
|
8982
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") return toJsonValue(value);
|
|
8983
|
+
if (Array.isArray(value)) {
|
|
8984
|
+
if (depth >= 2) return `[array:${value.length}]`;
|
|
8985
|
+
return value.slice(0, 3).map((item) => compactJsonAssertionSample(item, depth + 1));
|
|
8986
|
+
}
|
|
8987
|
+
if (isRecord2(value)) {
|
|
8988
|
+
const entries = Object.entries(value).slice(0, 8);
|
|
8989
|
+
if (depth >= 2) return `[object:${Object.keys(value).length} keys]`;
|
|
8990
|
+
return Object.fromEntries(entries.map(([key, child]) => [key, compactJsonAssertionSample(child, depth + 1)]));
|
|
8991
|
+
}
|
|
8992
|
+
return String(value);
|
|
8993
|
+
}
|
|
8994
|
+
function attachJsonAssertionObservedValue(result, value) {
|
|
8995
|
+
const type = jsonValueType(value);
|
|
8996
|
+
if (type === "array" && Array.isArray(value)) {
|
|
8997
|
+
result.observed_length = value.length;
|
|
8998
|
+
result.observed_omitted_count = Math.max(0, value.length - 3);
|
|
8999
|
+
result.observed_sample = compactJsonAssertionSample(value);
|
|
9000
|
+
return;
|
|
9001
|
+
}
|
|
9002
|
+
if (type === "object" && isRecord2(value)) {
|
|
9003
|
+
const keyCount = Object.keys(value).length;
|
|
9004
|
+
result.observed_key_count = keyCount;
|
|
9005
|
+
result.observed_omitted_count = Math.max(0, keyCount - 8);
|
|
9006
|
+
result.observed_sample = compactJsonAssertionSample(value);
|
|
9007
|
+
return;
|
|
9008
|
+
}
|
|
9009
|
+
result.observed = toJsonValue(value);
|
|
9010
|
+
}
|
|
8980
9011
|
function deepJsonEqual(left, right) {
|
|
8981
9012
|
if (left === right) return true;
|
|
8982
9013
|
if (typeof left !== typeof right) return false;
|
|
@@ -9074,7 +9105,7 @@ function evaluateHttpStatusBodyJsonAssertion(root, assertion) {
|
|
|
9074
9105
|
exists: resolved.exists,
|
|
9075
9106
|
observed_type: resolved.exists ? jsonValueType(resolved.value) : "missing"
|
|
9076
9107
|
};
|
|
9077
|
-
if (resolved.exists) result
|
|
9108
|
+
if (resolved.exists) attachJsonAssertionObservedValue(result, resolved.value);
|
|
9078
9109
|
if (resolved.error) errors.push(resolved.error);
|
|
9079
9110
|
if (hasOwn(assertion, "exists")) {
|
|
9080
9111
|
result.expected_exists = assertion.exists;
|
|
@@ -10167,6 +10198,10 @@ function httpStatusBodyJsonAssertionFailures(result, check) {
|
|
|
10167
10198
|
ok: false,
|
|
10168
10199
|
exists: assertion.exists === true,
|
|
10169
10200
|
observed: hasOwn(assertion, "observed") ? toJsonValue(assertion.observed) : void 0,
|
|
10201
|
+
observed_sample: hasOwn(assertion, "observed_sample") ? toJsonValue(assertion.observed_sample) : void 0,
|
|
10202
|
+
observed_length: numberValue3(assertion.observed_length),
|
|
10203
|
+
observed_key_count: numberValue3(assertion.observed_key_count),
|
|
10204
|
+
observed_omitted_count: numberValue3(assertion.observed_omitted_count),
|
|
10170
10205
|
observed_type: stringValue5(assertion.observed_type) || "missing",
|
|
10171
10206
|
expected_exists: booleanValue(assertion.expected_exists),
|
|
10172
10207
|
equals: hasOwn(assertion, "equals") ? toJsonValue(assertion.equals) : void 0,
|
|
@@ -11797,6 +11832,10 @@ function httpStatusBodyJsonAssertionFailures(result, check) {
|
|
|
11797
11832
|
ok: false,
|
|
11798
11833
|
exists: assertion.exists === true,
|
|
11799
11834
|
observed: Object.hasOwn(assertion, "observed") ? assertion.observed : undefined,
|
|
11835
|
+
observed_sample: Object.hasOwn(assertion, "observed_sample") ? assertion.observed_sample : undefined,
|
|
11836
|
+
observed_length: typeof assertion.observed_length === "number" && Number.isFinite(assertion.observed_length) ? assertion.observed_length : undefined,
|
|
11837
|
+
observed_key_count: typeof assertion.observed_key_count === "number" && Number.isFinite(assertion.observed_key_count) ? assertion.observed_key_count : undefined,
|
|
11838
|
+
observed_omitted_count: typeof assertion.observed_omitted_count === "number" && Number.isFinite(assertion.observed_omitted_count) ? assertion.observed_omitted_count : undefined,
|
|
11800
11839
|
observed_type: typeof assertion.observed_type === "string" && assertion.observed_type ? assertion.observed_type : "missing",
|
|
11801
11840
|
expected_exists: typeof assertion.expected_exists === "boolean" ? assertion.expected_exists : undefined,
|
|
11802
11841
|
equals: Object.hasOwn(assertion, "equals") ? assertion.equals : undefined,
|
|
@@ -14004,6 +14043,38 @@ function jsonProbeValueType(value) {
|
|
|
14004
14043
|
if (typeof value === "string") return "string";
|
|
14005
14044
|
return "object";
|
|
14006
14045
|
}
|
|
14046
|
+
function compactJsonProbeSample(value, depth) {
|
|
14047
|
+
const level = typeof depth === "number" ? depth : 0;
|
|
14048
|
+
if (typeof value === "string") return value.length > 240 ? value.slice(0, 237) + "..." : value;
|
|
14049
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") return value;
|
|
14050
|
+
if (Array.isArray(value)) {
|
|
14051
|
+
if (level >= 2) return "[array:" + value.length + "]";
|
|
14052
|
+
return value.slice(0, 3).map((item) => compactJsonProbeSample(item, level + 1));
|
|
14053
|
+
}
|
|
14054
|
+
if (value && typeof value === "object") {
|
|
14055
|
+
const entries = Object.entries(value);
|
|
14056
|
+
if (level >= 2) return "[object:" + entries.length + " keys]";
|
|
14057
|
+
return Object.fromEntries(entries.slice(0, 8).map(([key, child]) => [key, compactJsonProbeSample(child, level + 1)]));
|
|
14058
|
+
}
|
|
14059
|
+
return String(value);
|
|
14060
|
+
}
|
|
14061
|
+
function attachJsonProbeObservedValue(result, value) {
|
|
14062
|
+
const type = jsonProbeValueType(value);
|
|
14063
|
+
if (type === "array" && Array.isArray(value)) {
|
|
14064
|
+
result.observed_length = value.length;
|
|
14065
|
+
result.observed_omitted_count = Math.max(0, value.length - 3);
|
|
14066
|
+
result.observed_sample = compactJsonProbeSample(value, 0);
|
|
14067
|
+
return;
|
|
14068
|
+
}
|
|
14069
|
+
if (type === "object" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
14070
|
+
const keyCount = Object.keys(value).length;
|
|
14071
|
+
result.observed_key_count = keyCount;
|
|
14072
|
+
result.observed_omitted_count = Math.max(0, keyCount - 8);
|
|
14073
|
+
result.observed_sample = compactJsonProbeSample(value, 0);
|
|
14074
|
+
return;
|
|
14075
|
+
}
|
|
14076
|
+
result.observed = value;
|
|
14077
|
+
}
|
|
14007
14078
|
function jsonProbeDeepEqual(left, right) {
|
|
14008
14079
|
if (left === right) return true;
|
|
14009
14080
|
if (typeof left !== typeof right) return false;
|
|
@@ -14100,7 +14171,7 @@ function evaluateJsonProbeAssertion(root, assertion) {
|
|
|
14100
14171
|
exists: resolved.exists,
|
|
14101
14172
|
observed_type: resolved.exists ? jsonProbeValueType(resolved.value) : "missing",
|
|
14102
14173
|
};
|
|
14103
|
-
if (resolved.exists) result
|
|
14174
|
+
if (resolved.exists) attachJsonProbeObservedValue(result, resolved.value);
|
|
14104
14175
|
if (resolved.error) errors.push(resolved.error);
|
|
14105
14176
|
if (Object.hasOwn(assertion, "exists")) {
|
|
14106
14177
|
result.expected_exists = assertion.exists;
|
package/dist/index.js
CHANGED
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
resolveRiddleProofProfileTimeoutSec,
|
|
63
63
|
slugifyRiddleProofProfileName,
|
|
64
64
|
summarizeRiddleProofProfileResult
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-TO3FVF5S.js";
|
|
66
66
|
import {
|
|
67
67
|
DEFAULT_RIDDLE_API_BASE_URL,
|
|
68
68
|
DEFAULT_RIDDLE_API_KEY_FILE,
|
package/dist/profile.cjs
CHANGED
|
@@ -291,6 +291,37 @@ function jsonValueType(value) {
|
|
|
291
291
|
if (typeof value === "string") return "string";
|
|
292
292
|
return "object";
|
|
293
293
|
}
|
|
294
|
+
function compactJsonAssertionSample(value, depth = 0) {
|
|
295
|
+
if (typeof value === "string") return value.length > 240 ? `${value.slice(0, 237)}...` : value;
|
|
296
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") return toJsonValue(value);
|
|
297
|
+
if (Array.isArray(value)) {
|
|
298
|
+
if (depth >= 2) return `[array:${value.length}]`;
|
|
299
|
+
return value.slice(0, 3).map((item) => compactJsonAssertionSample(item, depth + 1));
|
|
300
|
+
}
|
|
301
|
+
if (isRecord(value)) {
|
|
302
|
+
const entries = Object.entries(value).slice(0, 8);
|
|
303
|
+
if (depth >= 2) return `[object:${Object.keys(value).length} keys]`;
|
|
304
|
+
return Object.fromEntries(entries.map(([key, child]) => [key, compactJsonAssertionSample(child, depth + 1)]));
|
|
305
|
+
}
|
|
306
|
+
return String(value);
|
|
307
|
+
}
|
|
308
|
+
function attachJsonAssertionObservedValue(result, value) {
|
|
309
|
+
const type = jsonValueType(value);
|
|
310
|
+
if (type === "array" && Array.isArray(value)) {
|
|
311
|
+
result.observed_length = value.length;
|
|
312
|
+
result.observed_omitted_count = Math.max(0, value.length - 3);
|
|
313
|
+
result.observed_sample = compactJsonAssertionSample(value);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
if (type === "object" && isRecord(value)) {
|
|
317
|
+
const keyCount = Object.keys(value).length;
|
|
318
|
+
result.observed_key_count = keyCount;
|
|
319
|
+
result.observed_omitted_count = Math.max(0, keyCount - 8);
|
|
320
|
+
result.observed_sample = compactJsonAssertionSample(value);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
result.observed = toJsonValue(value);
|
|
324
|
+
}
|
|
294
325
|
function deepJsonEqual(left, right) {
|
|
295
326
|
if (left === right) return true;
|
|
296
327
|
if (typeof left !== typeof right) return false;
|
|
@@ -388,7 +419,7 @@ function evaluateHttpStatusBodyJsonAssertion(root, assertion) {
|
|
|
388
419
|
exists: resolved.exists,
|
|
389
420
|
observed_type: resolved.exists ? jsonValueType(resolved.value) : "missing"
|
|
390
421
|
};
|
|
391
|
-
if (resolved.exists) result
|
|
422
|
+
if (resolved.exists) attachJsonAssertionObservedValue(result, resolved.value);
|
|
392
423
|
if (resolved.error) errors.push(resolved.error);
|
|
393
424
|
if (hasOwn(assertion, "exists")) {
|
|
394
425
|
result.expected_exists = assertion.exists;
|
|
@@ -1481,6 +1512,10 @@ function httpStatusBodyJsonAssertionFailures(result, check) {
|
|
|
1481
1512
|
ok: false,
|
|
1482
1513
|
exists: assertion.exists === true,
|
|
1483
1514
|
observed: hasOwn(assertion, "observed") ? toJsonValue(assertion.observed) : void 0,
|
|
1515
|
+
observed_sample: hasOwn(assertion, "observed_sample") ? toJsonValue(assertion.observed_sample) : void 0,
|
|
1516
|
+
observed_length: numberValue(assertion.observed_length),
|
|
1517
|
+
observed_key_count: numberValue(assertion.observed_key_count),
|
|
1518
|
+
observed_omitted_count: numberValue(assertion.observed_omitted_count),
|
|
1484
1519
|
observed_type: stringValue(assertion.observed_type) || "missing",
|
|
1485
1520
|
expected_exists: booleanValue(assertion.expected_exists),
|
|
1486
1521
|
equals: hasOwn(assertion, "equals") ? toJsonValue(assertion.equals) : void 0,
|
|
@@ -3111,6 +3146,10 @@ function httpStatusBodyJsonAssertionFailures(result, check) {
|
|
|
3111
3146
|
ok: false,
|
|
3112
3147
|
exists: assertion.exists === true,
|
|
3113
3148
|
observed: Object.hasOwn(assertion, "observed") ? assertion.observed : undefined,
|
|
3149
|
+
observed_sample: Object.hasOwn(assertion, "observed_sample") ? assertion.observed_sample : undefined,
|
|
3150
|
+
observed_length: typeof assertion.observed_length === "number" && Number.isFinite(assertion.observed_length) ? assertion.observed_length : undefined,
|
|
3151
|
+
observed_key_count: typeof assertion.observed_key_count === "number" && Number.isFinite(assertion.observed_key_count) ? assertion.observed_key_count : undefined,
|
|
3152
|
+
observed_omitted_count: typeof assertion.observed_omitted_count === "number" && Number.isFinite(assertion.observed_omitted_count) ? assertion.observed_omitted_count : undefined,
|
|
3114
3153
|
observed_type: typeof assertion.observed_type === "string" && assertion.observed_type ? assertion.observed_type : "missing",
|
|
3115
3154
|
expected_exists: typeof assertion.expected_exists === "boolean" ? assertion.expected_exists : undefined,
|
|
3116
3155
|
equals: Object.hasOwn(assertion, "equals") ? assertion.equals : undefined,
|
|
@@ -5318,6 +5357,38 @@ function jsonProbeValueType(value) {
|
|
|
5318
5357
|
if (typeof value === "string") return "string";
|
|
5319
5358
|
return "object";
|
|
5320
5359
|
}
|
|
5360
|
+
function compactJsonProbeSample(value, depth) {
|
|
5361
|
+
const level = typeof depth === "number" ? depth : 0;
|
|
5362
|
+
if (typeof value === "string") return value.length > 240 ? value.slice(0, 237) + "..." : value;
|
|
5363
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") return value;
|
|
5364
|
+
if (Array.isArray(value)) {
|
|
5365
|
+
if (level >= 2) return "[array:" + value.length + "]";
|
|
5366
|
+
return value.slice(0, 3).map((item) => compactJsonProbeSample(item, level + 1));
|
|
5367
|
+
}
|
|
5368
|
+
if (value && typeof value === "object") {
|
|
5369
|
+
const entries = Object.entries(value);
|
|
5370
|
+
if (level >= 2) return "[object:" + entries.length + " keys]";
|
|
5371
|
+
return Object.fromEntries(entries.slice(0, 8).map(([key, child]) => [key, compactJsonProbeSample(child, level + 1)]));
|
|
5372
|
+
}
|
|
5373
|
+
return String(value);
|
|
5374
|
+
}
|
|
5375
|
+
function attachJsonProbeObservedValue(result, value) {
|
|
5376
|
+
const type = jsonProbeValueType(value);
|
|
5377
|
+
if (type === "array" && Array.isArray(value)) {
|
|
5378
|
+
result.observed_length = value.length;
|
|
5379
|
+
result.observed_omitted_count = Math.max(0, value.length - 3);
|
|
5380
|
+
result.observed_sample = compactJsonProbeSample(value, 0);
|
|
5381
|
+
return;
|
|
5382
|
+
}
|
|
5383
|
+
if (type === "object" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
5384
|
+
const keyCount = Object.keys(value).length;
|
|
5385
|
+
result.observed_key_count = keyCount;
|
|
5386
|
+
result.observed_omitted_count = Math.max(0, keyCount - 8);
|
|
5387
|
+
result.observed_sample = compactJsonProbeSample(value, 0);
|
|
5388
|
+
return;
|
|
5389
|
+
}
|
|
5390
|
+
result.observed = value;
|
|
5391
|
+
}
|
|
5321
5392
|
function jsonProbeDeepEqual(left, right) {
|
|
5322
5393
|
if (left === right) return true;
|
|
5323
5394
|
if (typeof left !== typeof right) return false;
|
|
@@ -5414,7 +5485,7 @@ function evaluateJsonProbeAssertion(root, assertion) {
|
|
|
5414
5485
|
exists: resolved.exists,
|
|
5415
5486
|
observed_type: resolved.exists ? jsonProbeValueType(resolved.value) : "missing",
|
|
5416
5487
|
};
|
|
5417
|
-
if (resolved.exists) result
|
|
5488
|
+
if (resolved.exists) attachJsonProbeObservedValue(result, resolved.value);
|
|
5418
5489
|
if (resolved.error) errors.push(resolved.error);
|
|
5419
5490
|
if (Object.hasOwn(assertion, "exists")) {
|
|
5420
5491
|
result.expected_exists = assertion.exists;
|
package/dist/profile.d.cts
CHANGED
|
@@ -54,6 +54,10 @@ interface RiddleProofProfileHttpStatusBodyJsonAssertionResult {
|
|
|
54
54
|
ok: boolean;
|
|
55
55
|
exists: boolean;
|
|
56
56
|
observed?: JsonValue;
|
|
57
|
+
observed_sample?: JsonValue;
|
|
58
|
+
observed_length?: number;
|
|
59
|
+
observed_key_count?: number;
|
|
60
|
+
observed_omitted_count?: number;
|
|
57
61
|
observed_type: RiddleProofProfileJsonValueType | "missing";
|
|
58
62
|
expected_exists?: boolean;
|
|
59
63
|
equals?: JsonValue;
|
package/dist/profile.d.ts
CHANGED
|
@@ -54,6 +54,10 @@ interface RiddleProofProfileHttpStatusBodyJsonAssertionResult {
|
|
|
54
54
|
ok: boolean;
|
|
55
55
|
exists: boolean;
|
|
56
56
|
observed?: JsonValue;
|
|
57
|
+
observed_sample?: JsonValue;
|
|
58
|
+
observed_length?: number;
|
|
59
|
+
observed_key_count?: number;
|
|
60
|
+
observed_omitted_count?: number;
|
|
57
61
|
observed_type: RiddleProofProfileJsonValueType | "missing";
|
|
58
62
|
expected_exists?: boolean;
|
|
59
63
|
equals?: JsonValue;
|
package/dist/profile.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
resolveRiddleProofProfileTimeoutSec,
|
|
24
24
|
slugifyRiddleProofProfileName,
|
|
25
25
|
summarizeRiddleProofProfileResult
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-TO3FVF5S.js";
|
|
27
27
|
export {
|
|
28
28
|
RIDDLE_PROOF_PROFILE_CHECK_TYPES,
|
|
29
29
|
RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
|