@riddledc/riddle-proof 0.7.94 → 0.7.96
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 +8 -3
- package/dist/{chunk-FQ4QBY2N.js → chunk-G3UY3SHZ.js} +160 -18
- package/dist/cli.cjs +171 -22
- package/dist/cli.js +12 -5
- package/dist/index.cjs +160 -18
- package/dist/index.js +1 -1
- package/dist/profile.cjs +160 -18
- package/dist/profile.d.cts +2 -0
- package/dist/profile.d.ts +2 -0
- package/dist/profile.js +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -7678,6 +7678,12 @@ function normalizeCheck(input, index) {
|
|
|
7678
7678
|
`checks[${index}] allowed_statuses`
|
|
7679
7679
|
) : void 0;
|
|
7680
7680
|
const maxLinks = isLinkStatusCheck ? normalizePositiveInteger(input.max_links ?? input.maxLinks ?? input.limit, `checks[${index}] max_links`, 500) : void 0;
|
|
7681
|
+
const minBytes = isLinkStatusCheck ? normalizePositiveInteger(input.min_bytes ?? input.minBytes ?? input.min_response_bytes ?? input.minResponseBytes, `checks[${index}] min_bytes`) : void 0;
|
|
7682
|
+
const expectedContentType = isLinkStatusCheck ? stringValue2(input.expected_content_type) || stringValue2(input.expectedContentType) || stringValue2(input.content_type) || stringValue2(input.contentType) : void 0;
|
|
7683
|
+
const allowedContentTypes = isLinkStatusCheck ? normalizeStringList(
|
|
7684
|
+
input.allowed_content_types ?? input.allowedContentTypes ?? input.expected_content_types ?? input.expectedContentTypes,
|
|
7685
|
+
`checks[${index}] allowed_content_types`
|
|
7686
|
+
) ?? (expectedContentType ? [expectedContentType] : void 0) : void 0;
|
|
7681
7687
|
if (isLinkStatusCheck) {
|
|
7682
7688
|
if (minCount !== void 0 && (!Number.isInteger(minCount) || minCount < 0)) {
|
|
7683
7689
|
throw new Error(`checks[${index}] ${type} min_count must be a non-negative integer.`);
|
|
@@ -7719,6 +7725,8 @@ function normalizeCheck(input, index) {
|
|
|
7719
7725
|
same_origin_only: isLinkStatusCheck ? input.same_origin_only === true || input.sameOriginOnly === true : void 0,
|
|
7720
7726
|
dedupe: isLinkStatusCheck ? input.dedupe === false ? false : true : void 0,
|
|
7721
7727
|
require_nonzero_bytes: isLinkStatusCheck ? input.require_nonzero_bytes === true || input.requireNonzeroBytes === true : void 0,
|
|
7728
|
+
min_bytes: minBytes,
|
|
7729
|
+
allowed_content_types: allowedContentTypes,
|
|
7722
7730
|
allow_get_fallback: isLinkStatusCheck ? input.allow_get_fallback === false || input.allowGetFallback === false ? false : true : void 0,
|
|
7723
7731
|
max_overflow_px: numberValue(input.max_overflow_px),
|
|
7724
7732
|
timeout_ms: numberValue(input.timeout_ms) ?? numberValue(input.timeoutMs),
|
|
@@ -7825,15 +7833,40 @@ function linkStatusIsAllowed(status, check) {
|
|
|
7825
7833
|
const allowed = linkStatusAllowedStatuses(check);
|
|
7826
7834
|
return allowed?.length ? allowed.includes(status) : status >= 200 && status < 400;
|
|
7827
7835
|
}
|
|
7836
|
+
function linkStatusObservedBytes(result) {
|
|
7837
|
+
const bytes = numberValue(result.bytes);
|
|
7838
|
+
const contentLength = numberValue(result.content_length);
|
|
7839
|
+
return Math.max(bytes ?? 0, contentLength ?? 0) || void 0;
|
|
7840
|
+
}
|
|
7841
|
+
function normalizeLinkStatusContentType(value) {
|
|
7842
|
+
const normalized = value?.split(";")[0]?.trim().toLowerCase();
|
|
7843
|
+
return normalized || void 0;
|
|
7844
|
+
}
|
|
7845
|
+
function linkStatusContentTypeOk(result, check) {
|
|
7846
|
+
const expected = check.allowed_content_types;
|
|
7847
|
+
if (!expected?.length) return true;
|
|
7848
|
+
const actual = normalizeLinkStatusContentType(stringValue2(result.content_type));
|
|
7849
|
+
if (!actual) return false;
|
|
7850
|
+
return expected.some((contentType) => {
|
|
7851
|
+
const normalized = normalizeLinkStatusContentType(contentType);
|
|
7852
|
+
if (!normalized) return false;
|
|
7853
|
+
if (normalized.endsWith("/*")) return actual.startsWith(normalized.slice(0, -1));
|
|
7854
|
+
return actual === normalized;
|
|
7855
|
+
});
|
|
7856
|
+
}
|
|
7828
7857
|
function linkStatusResultOk(result, check) {
|
|
7829
7858
|
const status = numberValue(result.status);
|
|
7830
7859
|
if (!linkStatusIsAllowed(status, check)) return false;
|
|
7831
7860
|
if (stringValue2(result.error)) return false;
|
|
7832
7861
|
if (result.ok === false) return false;
|
|
7862
|
+
if (!linkStatusContentTypeOk(result, check)) return false;
|
|
7833
7863
|
if (check.require_nonzero_bytes) {
|
|
7834
|
-
const
|
|
7835
|
-
|
|
7836
|
-
|
|
7864
|
+
const observedBytes = linkStatusObservedBytes(result);
|
|
7865
|
+
if (observedBytes === void 0 || observedBytes <= 0) return false;
|
|
7866
|
+
}
|
|
7867
|
+
if (check.min_bytes !== void 0) {
|
|
7868
|
+
const observedBytes = linkStatusObservedBytes(result);
|
|
7869
|
+
if (observedBytes === void 0 || observedBytes < check.min_bytes) return false;
|
|
7837
7870
|
}
|
|
7838
7871
|
return true;
|
|
7839
7872
|
}
|
|
@@ -7855,6 +7888,10 @@ function summarizeLinkStatusEvidence(viewport, check) {
|
|
|
7855
7888
|
}
|
|
7856
7889
|
const results = Array.isArray(linkEvidence.results) ? linkEvidence.results.filter(isRecord) : [];
|
|
7857
7890
|
const totalCount = numberValue(linkEvidence.total_count) ?? results.length;
|
|
7891
|
+
const resultCount = numberValue(linkEvidence.result_count) ?? totalCount;
|
|
7892
|
+
const storedResultCount = numberValue(linkEvidence.stored_result_count) ?? results.length;
|
|
7893
|
+
const omittedResultCount = numberValue(linkEvidence.omitted_result_count) ?? Math.max(0, resultCount - storedResultCount);
|
|
7894
|
+
const omittedSuccessCount = numberValue(linkEvidence.omitted_success_count) ?? 0;
|
|
7858
7895
|
const okCount = results.filter((result) => linkStatusResultOk(result, check)).length;
|
|
7859
7896
|
const failures = results.filter((result) => !linkStatusResultOk(result, check)).map((result) => ({
|
|
7860
7897
|
code: "link_status_failed",
|
|
@@ -7862,7 +7899,10 @@ function summarizeLinkStatusEvidence(viewport, check) {
|
|
|
7862
7899
|
status: numberValue(result.status) ?? null,
|
|
7863
7900
|
method: stringValue2(result.method) ?? null,
|
|
7864
7901
|
error: stringValue2(result.error) ?? null,
|
|
7865
|
-
|
|
7902
|
+
content_type: stringValue2(result.content_type) ?? null,
|
|
7903
|
+
bytes: linkStatusObservedBytes(result) ?? null,
|
|
7904
|
+
min_bytes: check.min_bytes ?? null,
|
|
7905
|
+
allowed_content_types: check.allowed_content_types ?? null
|
|
7866
7906
|
}));
|
|
7867
7907
|
if (stringValue2(linkEvidence.error)) {
|
|
7868
7908
|
failures.push({ code: "link_status_capture_failed", error: stringValue2(linkEvidence.error) ?? "" });
|
|
@@ -7899,6 +7939,13 @@ function summarizeLinkStatusEvidence(viewport, check) {
|
|
|
7899
7939
|
failed_count: failures.length,
|
|
7900
7940
|
truncated: linkEvidence.truncated === true,
|
|
7901
7941
|
max_links: numberValue(linkEvidence.max_links) ?? check.max_links ?? 100,
|
|
7942
|
+
result_count: resultCount,
|
|
7943
|
+
stored_result_count: storedResultCount,
|
|
7944
|
+
omitted_result_count: omittedResultCount,
|
|
7945
|
+
omitted_success_count: omittedSuccessCount,
|
|
7946
|
+
results_compacted: linkEvidence.results_compacted === true || omittedResultCount > 0,
|
|
7947
|
+
min_bytes: check.min_bytes ?? null,
|
|
7948
|
+
allowed_content_types: check.allowed_content_types ?? null,
|
|
7902
7949
|
status_counts: statusCounts,
|
|
7903
7950
|
failures: failures.slice(0, 20)
|
|
7904
7951
|
};
|
|
@@ -8427,6 +8474,8 @@ function assessCheckFromEvidence(check, evidence) {
|
|
|
8427
8474
|
min_count: check.min_count ?? null,
|
|
8428
8475
|
allowed_statuses: linkStatusAllowedStatuses(check) || ["2xx", "3xx"],
|
|
8429
8476
|
require_nonzero_bytes: check.require_nonzero_bytes === true,
|
|
8477
|
+
min_bytes: check.min_bytes ?? null,
|
|
8478
|
+
allowed_content_types: check.allowed_content_types ?? null,
|
|
8430
8479
|
viewports: summaries.map((summary) => toJsonValue(summary)),
|
|
8431
8480
|
failures: failed.flatMap((summary) => Array.isArray(summary.failures) ? summary.failures.map((failure) => toJsonValue({ viewport: stringValue2(summary.viewport) ?? null, failure })) : [])
|
|
8432
8481
|
},
|
|
@@ -9014,15 +9063,41 @@ function linkStatusIsAllowed(status, check) {
|
|
|
9014
9063
|
const allowed = linkStatusAllowedStatuses(check);
|
|
9015
9064
|
return Array.isArray(allowed) && allowed.length ? allowed.includes(status) : status >= 200 && status < 400;
|
|
9016
9065
|
}
|
|
9066
|
+
function linkStatusObservedBytes(result) {
|
|
9067
|
+
const bytes = typeof result.bytes === "number" && Number.isFinite(result.bytes) ? result.bytes : undefined;
|
|
9068
|
+
const contentLength = typeof result.content_length === "number" && Number.isFinite(result.content_length) ? result.content_length : undefined;
|
|
9069
|
+
const observed = Math.max(bytes || 0, contentLength || 0);
|
|
9070
|
+
return observed > 0 ? observed : undefined;
|
|
9071
|
+
}
|
|
9072
|
+
function normalizeLinkStatusContentType(value) {
|
|
9073
|
+
if (typeof value !== "string") return undefined;
|
|
9074
|
+
const normalized = (value.split(";")[0] || "").trim().toLowerCase();
|
|
9075
|
+
return normalized || undefined;
|
|
9076
|
+
}
|
|
9077
|
+
function linkStatusContentTypeOk(result, check) {
|
|
9078
|
+
if (!Array.isArray(check.allowed_content_types) || !check.allowed_content_types.length) return true;
|
|
9079
|
+
const actual = normalizeLinkStatusContentType(result.content_type);
|
|
9080
|
+
if (!actual) return false;
|
|
9081
|
+
return check.allowed_content_types.some((contentType) => {
|
|
9082
|
+
const normalized = normalizeLinkStatusContentType(contentType);
|
|
9083
|
+
if (!normalized) return false;
|
|
9084
|
+
if (normalized.endsWith("/*")) return actual.startsWith(normalized.slice(0, -1));
|
|
9085
|
+
return actual === normalized;
|
|
9086
|
+
});
|
|
9087
|
+
}
|
|
9017
9088
|
function linkStatusResultOk(result, check) {
|
|
9018
9089
|
if (!result || typeof result !== "object" || Array.isArray(result)) return false;
|
|
9019
9090
|
if (!linkStatusIsAllowed(result.status, check)) return false;
|
|
9020
9091
|
if (typeof result.error === "string" && result.error.trim()) return false;
|
|
9021
9092
|
if (result.ok === false) return false;
|
|
9093
|
+
if (!linkStatusContentTypeOk(result, check)) return false;
|
|
9022
9094
|
if (check.require_nonzero_bytes === true) {
|
|
9023
|
-
const
|
|
9024
|
-
|
|
9025
|
-
|
|
9095
|
+
const observedBytes = linkStatusObservedBytes(result);
|
|
9096
|
+
if (observedBytes === undefined || observedBytes <= 0) return false;
|
|
9097
|
+
}
|
|
9098
|
+
if (typeof check.min_bytes === "number" && Number.isFinite(check.min_bytes)) {
|
|
9099
|
+
const observedBytes = linkStatusObservedBytes(result);
|
|
9100
|
+
if (observedBytes === undefined || observedBytes < check.min_bytes) return false;
|
|
9026
9101
|
}
|
|
9027
9102
|
return true;
|
|
9028
9103
|
}
|
|
@@ -9041,6 +9116,10 @@ function summarizeLinkStatusEvidence(viewport, check) {
|
|
|
9041
9116
|
}
|
|
9042
9117
|
const results = Array.isArray(linkEvidence.results) ? linkEvidence.results.filter((result) => result && typeof result === "object" && !Array.isArray(result)) : [];
|
|
9043
9118
|
const totalCount = typeof linkEvidence.total_count === "number" && Number.isFinite(linkEvidence.total_count) ? linkEvidence.total_count : results.length;
|
|
9119
|
+
const resultCount = typeof linkEvidence.result_count === "number" && Number.isFinite(linkEvidence.result_count) ? linkEvidence.result_count : totalCount;
|
|
9120
|
+
const storedResultCount = typeof linkEvidence.stored_result_count === "number" && Number.isFinite(linkEvidence.stored_result_count) ? linkEvidence.stored_result_count : results.length;
|
|
9121
|
+
const omittedResultCount = typeof linkEvidence.omitted_result_count === "number" && Number.isFinite(linkEvidence.omitted_result_count) ? linkEvidence.omitted_result_count : Math.max(0, resultCount - storedResultCount);
|
|
9122
|
+
const omittedSuccessCount = typeof linkEvidence.omitted_success_count === "number" && Number.isFinite(linkEvidence.omitted_success_count) ? linkEvidence.omitted_success_count : 0;
|
|
9044
9123
|
const okCount = results.filter((result) => linkStatusResultOk(result, check)).length;
|
|
9045
9124
|
const failures = results
|
|
9046
9125
|
.filter((result) => !linkStatusResultOk(result, check))
|
|
@@ -9050,11 +9129,10 @@ function summarizeLinkStatusEvidence(viewport, check) {
|
|
|
9050
9129
|
status: typeof result.status === "number" && Number.isFinite(result.status) ? result.status : null,
|
|
9051
9130
|
method: typeof result.method === "string" ? result.method : null,
|
|
9052
9131
|
error: typeof result.error === "string" ? result.error : null,
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
: null,
|
|
9132
|
+
content_type: typeof result.content_type === "string" ? result.content_type : null,
|
|
9133
|
+
bytes: linkStatusObservedBytes(result) ?? null,
|
|
9134
|
+
min_bytes: typeof check.min_bytes === "number" && Number.isFinite(check.min_bytes) ? check.min_bytes : null,
|
|
9135
|
+
allowed_content_types: Array.isArray(check.allowed_content_types) ? check.allowed_content_types : null,
|
|
9058
9136
|
}));
|
|
9059
9137
|
if (typeof linkEvidence.error === "string" && linkEvidence.error.trim()) {
|
|
9060
9138
|
failures.push({ code: "link_status_capture_failed", error: linkEvidence.error });
|
|
@@ -9089,6 +9167,13 @@ function summarizeLinkStatusEvidence(viewport, check) {
|
|
|
9089
9167
|
failed_count: failures.length,
|
|
9090
9168
|
truncated: linkEvidence.truncated === true,
|
|
9091
9169
|
max_links: typeof linkEvidence.max_links === "number" ? linkEvidence.max_links : check.max_links || 100,
|
|
9170
|
+
result_count: resultCount,
|
|
9171
|
+
stored_result_count: storedResultCount,
|
|
9172
|
+
omitted_result_count: omittedResultCount,
|
|
9173
|
+
omitted_success_count: omittedSuccessCount,
|
|
9174
|
+
results_compacted: linkEvidence.results_compacted === true || omittedResultCount > 0,
|
|
9175
|
+
min_bytes: typeof check.min_bytes === "number" && Number.isFinite(check.min_bytes) ? check.min_bytes : null,
|
|
9176
|
+
allowed_content_types: Array.isArray(check.allowed_content_types) ? check.allowed_content_types : null,
|
|
9092
9177
|
status_counts: linkEvidence.status_counts && typeof linkEvidence.status_counts === "object" && !Array.isArray(linkEvidence.status_counts) ? linkEvidence.status_counts : {},
|
|
9093
9178
|
failures: failures.slice(0, 20),
|
|
9094
9179
|
};
|
|
@@ -9785,6 +9870,8 @@ function assessProfile(profile, evidence) {
|
|
|
9785
9870
|
min_count: check.min_count ?? null,
|
|
9786
9871
|
allowed_statuses: linkStatusAllowedStatuses(check) || ["2xx", "3xx"],
|
|
9787
9872
|
require_nonzero_bytes: check.require_nonzero_bytes === true,
|
|
9873
|
+
min_bytes: check.min_bytes ?? null,
|
|
9874
|
+
allowed_content_types: check.allowed_content_types ?? null,
|
|
9788
9875
|
viewports: summaries,
|
|
9789
9876
|
failures: failed.flatMap((summary) => Array.isArray(summary.failures)
|
|
9790
9877
|
? summary.failures.map((failure) => ({ viewport: summary.viewport || null, failure }))
|
|
@@ -10932,6 +11019,28 @@ function linkProbeAllowed(status, check) {
|
|
|
10932
11019
|
: null;
|
|
10933
11020
|
return allowed ? allowed.includes(status) : status >= 200 && status < 400;
|
|
10934
11021
|
}
|
|
11022
|
+
function linkProbeObservedBytes(result) {
|
|
11023
|
+
const bytes = typeof result.bytes === "number" && Number.isFinite(result.bytes) ? result.bytes : undefined;
|
|
11024
|
+
const contentLength = typeof result.content_length === "number" && Number.isFinite(result.content_length) ? result.content_length : undefined;
|
|
11025
|
+
const observed = Math.max(bytes || 0, contentLength || 0);
|
|
11026
|
+
return observed > 0 ? observed : undefined;
|
|
11027
|
+
}
|
|
11028
|
+
function normalizeLinkProbeContentType(value) {
|
|
11029
|
+
if (typeof value !== "string") return undefined;
|
|
11030
|
+
const normalized = (value.split(";")[0] || "").trim().toLowerCase();
|
|
11031
|
+
return normalized || undefined;
|
|
11032
|
+
}
|
|
11033
|
+
function linkProbeContentTypeAllowed(result, check) {
|
|
11034
|
+
if (!Array.isArray(check.allowed_content_types) || !check.allowed_content_types.length) return true;
|
|
11035
|
+
const actual = normalizeLinkProbeContentType(result.content_type);
|
|
11036
|
+
if (!actual) return false;
|
|
11037
|
+
return check.allowed_content_types.some((contentType) => {
|
|
11038
|
+
const normalized = normalizeLinkProbeContentType(contentType);
|
|
11039
|
+
if (!normalized) return false;
|
|
11040
|
+
if (normalized.endsWith("/*")) return actual.startsWith(normalized.slice(0, -1));
|
|
11041
|
+
return actual === normalized;
|
|
11042
|
+
});
|
|
11043
|
+
}
|
|
10935
11044
|
function linkProbeResponseFields(response, method) {
|
|
10936
11045
|
const contentLengthHeader = response.headers && typeof response.headers.get === "function" ? response.headers.get("content-length") : null;
|
|
10937
11046
|
const contentLength = contentLengthHeader && /^\d+$/.test(contentLengthHeader) ? Number(contentLengthHeader) : null;
|
|
@@ -10946,6 +11055,7 @@ function linkProbeResponseFields(response, method) {
|
|
|
10946
11055
|
}
|
|
10947
11056
|
async function probeLinkStatus(candidate, check) {
|
|
10948
11057
|
const requireNonzeroBytes = check.require_nonzero_bytes === true;
|
|
11058
|
+
const minBytes = typeof check.min_bytes === "number" && Number.isFinite(check.min_bytes) ? Math.max(1, Math.floor(check.min_bytes)) : null;
|
|
10949
11059
|
const allowGetFallback = check.allow_get_fallback !== false;
|
|
10950
11060
|
const result = {
|
|
10951
11061
|
url: candidate.url,
|
|
@@ -10963,7 +11073,7 @@ async function probeLinkStatus(candidate, check) {
|
|
|
10963
11073
|
};
|
|
10964
11074
|
const applyResponse = async (response, method, readBytes) => {
|
|
10965
11075
|
Object.assign(result, linkProbeResponseFields(response, method));
|
|
10966
|
-
if (readBytes
|
|
11076
|
+
if (readBytes) {
|
|
10967
11077
|
try {
|
|
10968
11078
|
const buffer = await response.arrayBuffer();
|
|
10969
11079
|
result.bytes = buffer.byteLength;
|
|
@@ -10972,7 +11082,9 @@ async function probeLinkStatus(candidate, check) {
|
|
|
10972
11082
|
}
|
|
10973
11083
|
}
|
|
10974
11084
|
result.ok = linkProbeAllowed(result.status, check)
|
|
10975
|
-
&& (
|
|
11085
|
+
&& linkProbeContentTypeAllowed(result, check)
|
|
11086
|
+
&& (!requireNonzeroBytes || ((linkProbeObservedBytes(result) || 0) > 0))
|
|
11087
|
+
&& (minBytes === null || ((linkProbeObservedBytes(result) || 0) >= minBytes))
|
|
10976
11088
|
&& !result.error;
|
|
10977
11089
|
};
|
|
10978
11090
|
try {
|
|
@@ -10989,9 +11101,9 @@ async function probeLinkStatus(candidate, check) {
|
|
|
10989
11101
|
method: "GET",
|
|
10990
11102
|
redirect: "follow",
|
|
10991
11103
|
cache: "no-store",
|
|
10992
|
-
headers: { Range: "bytes=0-
|
|
11104
|
+
headers: { Range: "bytes=0-" + String((minBytes || 1) - 1) },
|
|
10993
11105
|
});
|
|
10994
|
-
await applyResponse(response, "GET", requireNonzeroBytes);
|
|
11106
|
+
await applyResponse(response, "GET", requireNonzeroBytes || minBytes !== null);
|
|
10995
11107
|
return result;
|
|
10996
11108
|
} catch (error) {
|
|
10997
11109
|
result.error = String(error && error.message ? error.message : error).slice(0, 500);
|
|
@@ -10999,6 +11111,30 @@ async function probeLinkStatus(candidate, check) {
|
|
|
10999
11111
|
return result;
|
|
11000
11112
|
}
|
|
11001
11113
|
}
|
|
11114
|
+
function compactLinkProbeResults(results) {
|
|
11115
|
+
const allResults = Array.isArray(results) ? results : [];
|
|
11116
|
+
if (allResults.length <= 20) {
|
|
11117
|
+
return {
|
|
11118
|
+
result_count: allResults.length,
|
|
11119
|
+
stored_result_count: allResults.length,
|
|
11120
|
+
omitted_result_count: 0,
|
|
11121
|
+
omitted_success_count: 0,
|
|
11122
|
+
results_compacted: false,
|
|
11123
|
+
results: allResults,
|
|
11124
|
+
};
|
|
11125
|
+
}
|
|
11126
|
+
const successResults = allResults.filter((result) => result && result.ok);
|
|
11127
|
+
const sampledSuccesses = new Set(successResults.slice(0, 5));
|
|
11128
|
+
const storedResults = allResults.filter((result) => result && (!result.ok || sampledSuccesses.has(result)));
|
|
11129
|
+
return {
|
|
11130
|
+
result_count: allResults.length,
|
|
11131
|
+
stored_result_count: storedResults.length,
|
|
11132
|
+
omitted_result_count: allResults.length - storedResults.length,
|
|
11133
|
+
omitted_success_count: Math.max(0, successResults.length - sampledSuccesses.size),
|
|
11134
|
+
results_compacted: storedResults.length < allResults.length,
|
|
11135
|
+
results: storedResults,
|
|
11136
|
+
};
|
|
11137
|
+
}
|
|
11002
11138
|
async function collectLinkStatus(check) {
|
|
11003
11139
|
const selector = linkStatusSelector(check);
|
|
11004
11140
|
const candidateResult = await collectLinkCandidates(selector);
|
|
@@ -11045,13 +11181,17 @@ async function collectLinkStatus(check) {
|
|
|
11045
11181
|
status: result.status,
|
|
11046
11182
|
method: result.method,
|
|
11047
11183
|
error: result.error,
|
|
11048
|
-
|
|
11184
|
+
content_type: result.content_type,
|
|
11185
|
+
bytes: linkProbeObservedBytes(result) || null,
|
|
11186
|
+
min_bytes: typeof check.min_bytes === "number" && Number.isFinite(check.min_bytes) ? check.min_bytes : null,
|
|
11187
|
+
allowed_content_types: Array.isArray(check.allowed_content_types) ? check.allowed_content_types : null,
|
|
11049
11188
|
}));
|
|
11050
11189
|
const statusCounts = {};
|
|
11051
11190
|
for (const result of results) {
|
|
11052
11191
|
const key = result.status == null ? "error" : String(result.status);
|
|
11053
11192
|
statusCounts[key] = (statusCounts[key] || 0) + 1;
|
|
11054
11193
|
}
|
|
11194
|
+
const compactedResults = compactLinkProbeResults(results);
|
|
11055
11195
|
return {
|
|
11056
11196
|
version: "riddle-proof.link-status.v1",
|
|
11057
11197
|
selector,
|
|
@@ -11059,6 +11199,8 @@ async function collectLinkStatus(check) {
|
|
|
11059
11199
|
same_origin_only: linkProbeSameOriginOnly(check),
|
|
11060
11200
|
dedupe: linkProbeDedupe(check),
|
|
11061
11201
|
require_nonzero_bytes: check.require_nonzero_bytes === true,
|
|
11202
|
+
min_bytes: typeof check.min_bytes === "number" && Number.isFinite(check.min_bytes) ? check.min_bytes : null,
|
|
11203
|
+
allowed_content_types: Array.isArray(check.allowed_content_types) ? check.allowed_content_types : null,
|
|
11062
11204
|
allowed_statuses: Array.isArray(check.allowed_statuses) && check.allowed_statuses.length
|
|
11063
11205
|
? check.allowed_statuses
|
|
11064
11206
|
: typeof check.expected_status === "number"
|
|
@@ -11071,7 +11213,7 @@ async function collectLinkStatus(check) {
|
|
|
11071
11213
|
failed_count: failures.length,
|
|
11072
11214
|
status_counts: statusCounts,
|
|
11073
11215
|
failures: failures.slice(0, 20),
|
|
11074
|
-
|
|
11216
|
+
...compactedResults,
|
|
11075
11217
|
};
|
|
11076
11218
|
}
|
|
11077
11219
|
async function frameEvidence(selector) {
|
|
@@ -12279,9 +12421,13 @@ function profileCheckMarkdownTarget(check) {
|
|
|
12279
12421
|
if (check.type === "link_status" || check.type === "artifact_link_status") {
|
|
12280
12422
|
const expectedCount = cliFiniteNumber(evidence.expected_count);
|
|
12281
12423
|
const minCount = cliFiniteNumber(evidence.min_count);
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12424
|
+
const minBytes = cliFiniteNumber(evidence.min_bytes);
|
|
12425
|
+
const parts = [];
|
|
12426
|
+
if (expectedCount !== void 0) parts.push(`links = ${expectedCount}`);
|
|
12427
|
+
else if (minCount !== void 0) parts.push(`links >= ${minCount}`);
|
|
12428
|
+
if (minBytes !== void 0) parts.push(`bytes >= ${minBytes}`);
|
|
12429
|
+
if (selector && parts.length) return `${markdownInlineCode(selector)} ${parts.join(", ")}`;
|
|
12430
|
+
return selector ? markdownInlineCode(selector) : parts.join(", ") || void 0;
|
|
12285
12431
|
}
|
|
12286
12432
|
if (check.type === "no_horizontal_overflow" || check.type === "no_mobile_horizontal_overflow") {
|
|
12287
12433
|
const maxOverflow = cliFiniteNumber(evidence.max_overflow_px);
|
|
@@ -12489,9 +12635,12 @@ function profileLinkStatusSummaryMarkdown(result) {
|
|
|
12489
12635
|
const okTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.ok_count) || 0), 0);
|
|
12490
12636
|
const failedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.failed_count) || 0), 0);
|
|
12491
12637
|
const truncatedTotal = viewports.filter((viewport) => viewport.truncated === true).length;
|
|
12638
|
+
const omittedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.omitted_result_count) || 0), 0);
|
|
12639
|
+
const minBytes = cliFiniteNumber(evidence.min_bytes);
|
|
12640
|
+
const allowedContentTypes = Array.isArray(evidence.allowed_content_types) ? evidence.allowed_content_types.map(cliString).filter((value) => Boolean(value)) : [];
|
|
12492
12641
|
const countText = totals.length ? totals.join("/") : "unknown";
|
|
12493
12642
|
lines.push(
|
|
12494
|
-
`- ${label}${selector ? ` ${markdownInlineCode(selector)}` : ""}: links ${countText}, ok ${okTotal}, failures ${failedTotal}${truncatedTotal ? `, truncated viewports ${truncatedTotal}` : ""}`
|
|
12643
|
+
`- ${label}${selector ? ` ${markdownInlineCode(selector)}` : ""}: links ${countText}, ok ${okTotal}, failures ${failedTotal}${omittedTotal ? `, compacted ${omittedTotal} result row(s)` : ""}${truncatedTotal ? `, truncated viewports ${truncatedTotal}` : ""}${minBytes !== void 0 ? `, min bytes ${minBytes}` : ""}${allowedContentTypes.length ? `, content types ${allowedContentTypes.map((value) => markdownInlineCode(value)).join(", ")}` : ""}`
|
|
12495
12644
|
);
|
|
12496
12645
|
}
|
|
12497
12646
|
return lines;
|
package/dist/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
profileStatusExitCode,
|
|
11
11
|
resolveRiddleProofProfileTargetUrl,
|
|
12
12
|
resolveRiddleProofProfileTimeoutSec
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-G3UY3SHZ.js";
|
|
14
14
|
import {
|
|
15
15
|
createRiddleApiClient,
|
|
16
16
|
parseRiddleViewport
|
|
@@ -423,9 +423,13 @@ function profileCheckMarkdownTarget(check) {
|
|
|
423
423
|
if (check.type === "link_status" || check.type === "artifact_link_status") {
|
|
424
424
|
const expectedCount = cliFiniteNumber(evidence.expected_count);
|
|
425
425
|
const minCount = cliFiniteNumber(evidence.min_count);
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
426
|
+
const minBytes = cliFiniteNumber(evidence.min_bytes);
|
|
427
|
+
const parts = [];
|
|
428
|
+
if (expectedCount !== void 0) parts.push(`links = ${expectedCount}`);
|
|
429
|
+
else if (minCount !== void 0) parts.push(`links >= ${minCount}`);
|
|
430
|
+
if (minBytes !== void 0) parts.push(`bytes >= ${minBytes}`);
|
|
431
|
+
if (selector && parts.length) return `${markdownInlineCode(selector)} ${parts.join(", ")}`;
|
|
432
|
+
return selector ? markdownInlineCode(selector) : parts.join(", ") || void 0;
|
|
429
433
|
}
|
|
430
434
|
if (check.type === "no_horizontal_overflow" || check.type === "no_mobile_horizontal_overflow") {
|
|
431
435
|
const maxOverflow = cliFiniteNumber(evidence.max_overflow_px);
|
|
@@ -633,9 +637,12 @@ function profileLinkStatusSummaryMarkdown(result) {
|
|
|
633
637
|
const okTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.ok_count) || 0), 0);
|
|
634
638
|
const failedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.failed_count) || 0), 0);
|
|
635
639
|
const truncatedTotal = viewports.filter((viewport) => viewport.truncated === true).length;
|
|
640
|
+
const omittedTotal = viewports.reduce((sum, viewport) => sum + (cliFiniteNumber(viewport.omitted_result_count) || 0), 0);
|
|
641
|
+
const minBytes = cliFiniteNumber(evidence.min_bytes);
|
|
642
|
+
const allowedContentTypes = Array.isArray(evidence.allowed_content_types) ? evidence.allowed_content_types.map(cliString).filter((value) => Boolean(value)) : [];
|
|
636
643
|
const countText = totals.length ? totals.join("/") : "unknown";
|
|
637
644
|
lines.push(
|
|
638
|
-
`- ${label}${selector ? ` ${markdownInlineCode(selector)}` : ""}: links ${countText}, ok ${okTotal}, failures ${failedTotal}${truncatedTotal ? `, truncated viewports ${truncatedTotal}` : ""}`
|
|
645
|
+
`- ${label}${selector ? ` ${markdownInlineCode(selector)}` : ""}: links ${countText}, ok ${okTotal}, failures ${failedTotal}${omittedTotal ? `, compacted ${omittedTotal} result row(s)` : ""}${truncatedTotal ? `, truncated viewports ${truncatedTotal}` : ""}${minBytes !== void 0 ? `, min bytes ${minBytes}` : ""}${allowedContentTypes.length ? `, content types ${allowedContentTypes.map((value) => markdownInlineCode(value)).join(", ")}` : ""}`
|
|
639
646
|
);
|
|
640
647
|
}
|
|
641
648
|
return lines;
|