@mark1russell7/site-pages 0.2.26 → 0.3.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.
- package/README.md +14 -5
- package/build/chunks/build.js +114 -22
- package/build/chunks/build.js.map +1 -1
- package/build/chunks/data-stamp.js +21 -7
- package/build/chunks/data-stamp.js.map +1 -1
- package/build/chunks/freshness.d.ts +23 -4
- package/build/chunks/freshness.d.ts.map +1 -1
- package/build/chunks/freshness.js +50 -11
- package/build/chunks/freshness.js.map +1 -1
- package/build/cli.js +1 -1
- package/build/index.d.ts +37 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -3
- package/build/vite.d.ts +1 -1
- package/build/vite.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as listText, g as link, m as escapeHtml } from "./freshness.js";
|
|
2
2
|
// src/render/data-stamp.ts
|
|
3
|
+
const DAY_MS = 864e5;
|
|
3
4
|
/** This function gives an engine and its version in the short form, without the npm scope. */
|
|
4
5
|
function engineText(name, version) {
|
|
5
6
|
return `${name.slice(name.indexOf("/") + 1)} ${version}`;
|
|
@@ -7,16 +8,29 @@ function engineText(name, version) {
|
|
|
7
8
|
/** This function gives the html of one run: a link to the run, the day of its start and each engine. */
|
|
8
9
|
function runHtml(run) {
|
|
9
10
|
const engines = Object.entries(run.engines).map(([name, version]) => escapeHtml(engineText(name, version)));
|
|
10
|
-
return `${escapeHtml(run.method ?? "run")} ${link(run.url, escapeHtml(run.id))} of ${escapeHtml(run.date.slice(0, 10))}, on ${listText(engines)}`;
|
|
11
|
+
return `${escapeHtml(run.method ?? "run")} ${link(run.url, escapeHtml(run.id))} of ${escapeHtml(run.date.slice(0, 10))}${run.commit === void 0 ? "" : `, at commit ${escapeHtml(run.commit.slice(0, 7))}`}, on ${listText(engines)}`;
|
|
11
12
|
}
|
|
12
|
-
/** This function gives the html of the
|
|
13
|
+
/** This function gives the html of the sentences of a study, with each version of its runs once. A study with a limit is not a fixed study. */
|
|
13
14
|
function studyHtml(stamp) {
|
|
14
15
|
const engines = [...new Set(stamp.runs.flatMap((run) => Object.entries(run.engines).map(([name, version]) => engineText(name, version))))].map(escapeHtml);
|
|
15
|
-
return `<span>The measured numbers of this page are a
|
|
16
|
+
if (stamp.limit !== void 0) return `<span>The measured numbers of this page are a study of ${listText(engines)}.</span> `;
|
|
17
|
+
const statements = stamp.noLimit === void 0 ? "" : ` ${escapeHtml(stamp.noLimit.reproduce)} ${escapeHtml(stamp.noLimit.today)}`;
|
|
18
|
+
return `<span>The measured numbers of this page are a fixed study of ${listText(engines)}. They tell nothing about a newer release.${statements}</span> `;
|
|
16
19
|
}
|
|
17
|
-
/** This function gives the html
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
+
/** This function gives the html of the age of the oldest run, at the time of the build. */
|
|
21
|
+
function ageHtml(stamp, now) {
|
|
22
|
+
const oldest = Math.min(...stamp.runs.map((run) => Date.parse(run.date)));
|
|
23
|
+
const days = Math.max(0, Math.floor((Date.parse(now) - oldest) / DAY_MS));
|
|
24
|
+
return ` <span>The oldest data of this page is ${days} ${days === 1 ? "day" : "days"} old at this build, on ${escapeHtml(now.slice(0, 10))}.</span>`;
|
|
25
|
+
}
|
|
26
|
+
/** This function gives the html line of the stamp of a page. A page shows this line with its data. The value `now` is the ISO time of the build. */
|
|
27
|
+
function renderDataStamp(stamp, now = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
28
|
+
const study = stamp.study === true ? studyHtml(stamp) : "";
|
|
29
|
+
const data = `<span>The data comes from ${listText(stamp.runs.map(runHtml))}.</span>`;
|
|
30
|
+
const flight = stamp.inFlight === void 0 ? "" : ` <span>A newer run is in flight: ${runHtml(stamp.inFlight)}.</span>`;
|
|
31
|
+
const start = stamp.limit?.startsAt === void 0 ? "" : `, from ${escapeHtml(stamp.limit.startsAt.slice(0, 10))}`;
|
|
32
|
+
const limit = stamp.limit === void 0 ? "" : ` <span>The age limit of this data is ${stamp.limit.days} days${start}. ${escapeHtml(stamp.limit.reason)}</span>`;
|
|
33
|
+
return `<p class="data-stamp">${study}${data}${ageHtml(stamp, now)}${flight}${limit}</p>`;
|
|
20
34
|
}
|
|
21
35
|
export { renderDataStamp as t };
|
|
22
36
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-stamp.js","names":[],"sources":["../../src/render/data-stamp.ts"],"sourcesContent":["/**\n * The line that a measured page shows for its data: the run, its date and its engine versions, and a run in flight.\n * The line also
|
|
1
|
+
{"version":3,"file":"data-stamp.js","names":[],"sources":["../../src/render/data-stamp.ts"],"sourcesContent":["/**\n * The line that a measured page shows for its data: the run, its date and its engine versions, and a run in flight.\n * The line also shows the age of the data at the build. It tells when the numbers are a study, and it shows the reason for a longer age limit.\n */\n\nimport type { DataRun, PageStamp } from \"../check/freshness.ts\";\nimport { escapeHtml, link, listText } from \"./html.ts\";\n\nconst DAY_MS = 86_400_000;\n\n/** This function gives an engine and its version in the short form, without the npm scope. */\nfunction engineText(name: string, version: string): string {\n return `${name.slice(name.indexOf(\"/\") + 1)} ${version}`;\n}\n\n/** This function gives the html of one run: a link to the run, the day of its start and each engine. */\nfunction runHtml(run: DataRun): string {\n const engines = Object.entries(run.engines).map(([name, version]) => escapeHtml(engineText(name, version)));\n return `${escapeHtml(run.method ?? \"run\")} ${link(run.url, escapeHtml(run.id))} of ${escapeHtml(run.date.slice(0, 10))}${run.commit === undefined ? \"\" : `, at commit ${escapeHtml(run.commit.slice(0, 7))}`}, on ${listText(engines)}`;\n}\n\n/** This function gives the html of the sentences of a study, with each version of its runs once. A study with a limit is not a fixed study. */\nfunction studyHtml(stamp: PageStamp): string {\n const engines = [...new Set(stamp.runs.flatMap((run) => Object.entries(run.engines).map(([name, version]) => engineText(name, version))))].map(escapeHtml);\n if (stamp.limit !== undefined) return `<span>The measured numbers of this page are a study of ${listText(engines)}.</span> `;\n const statements = stamp.noLimit === undefined ? \"\" : ` ${escapeHtml(stamp.noLimit.reproduce)} ${escapeHtml(stamp.noLimit.today)}`;\n return `<span>The measured numbers of this page are a fixed study of ${listText(engines)}. They tell nothing about a newer release.${statements}</span> `;\n}\n\n/** This function gives the html of the age of the oldest run, at the time of the build. */\nfunction ageHtml(stamp: PageStamp, now: string): string {\n const oldest = Math.min(...stamp.runs.map((run) => Date.parse(run.date)));\n const days = Math.max(0, Math.floor((Date.parse(now) - oldest) / DAY_MS));\n return ` <span>The oldest data of this page is ${days} ${days === 1 ? \"day\" : \"days\"} old at this build, on ${escapeHtml(now.slice(0, 10))}.</span>`;\n}\n\n/** This function gives the html line of the stamp of a page. A page shows this line with its data. The value `now` is the ISO time of the build. */\nexport function renderDataStamp(stamp: PageStamp, now: string = new Date().toISOString()): string {\n const study = stamp.study === true ? studyHtml(stamp) : \"\";\n const data = `<span>The data comes from ${listText(stamp.runs.map(runHtml))}.</span>`;\n const flight = stamp.inFlight === undefined ? \"\" : ` <span>A newer run is in flight: ${runHtml(stamp.inFlight)}.</span>`;\n const start = stamp.limit?.startsAt === undefined ? \"\" : `, from ${escapeHtml(stamp.limit.startsAt.slice(0, 10))}`;\n const limit = stamp.limit === undefined ? \"\" : ` <span>The age limit of this data is ${stamp.limit.days} days${start}. ${escapeHtml(stamp.limit.reason)}</span>`;\n return `<p class=\"data-stamp\">${study}${data}${ageHtml(stamp, now)}${flight}${limit}</p>`;\n}\n"],"mappings":";;AAQA,MAAM,SAAS;;AAGf,SAAS,WAAW,MAAc,SAAyB;CACzD,OAAO,GAAG,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAI,CAAC,EAAE,GAAG;AACjD;;AAGA,SAAS,QAAQ,KAAsB;CACrC,MAAM,UAAU,OAAO,QAAQ,IAAI,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,aAAa,WAAW,WAAW,MAAM,OAAO,CAAC,CAAC;CAC1G,OAAO,GAAG,WAAW,IAAI,UAAU,KAAK,EAAE,GAAG,KAAK,IAAI,KAAK,WAAW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AAY,KAAK,oCAAoC,QAAQ,MAAM,QAAQ,EAAE;CAC/G,MAAM,QAAQ,MAAM,OAAO,aAAa,KAAA,IAAY,KAAK,UAAU,WAAW,MAAM,MAAM,SAAS,MAAM,GAAG,EAAE,CAAC;CAC/G,MAAM,QAAQ,MAAM,UAAU,KAAA,IAAY,KAAK,wCAAwC,MAAM,MAAM,KAAK,OAAO,MAAM,IAAI,WAAW,MAAM,MAAM,MAAM,EAAE;CACxJ,OAAO,yBAAyB,QAAQ,OAAO,QAAQ,OAAO,GAAG,IAAI,SAAS,MAAM;AACtF"}
|
|
@@ -220,6 +220,10 @@ declare const MAX_DATA_AGE_DAYS = 3;
|
|
|
220
220
|
declare const MAX_MINORS_BEHIND = 1;
|
|
221
221
|
/** The longest limit of a page, in days, with no ruling for that site. */
|
|
222
222
|
declare const MAX_LIMIT_DAYS_WITHOUT_RULING = 14;
|
|
223
|
+
/** The longest limit of a study, in days, also with a ruling. A study over `MAX_LIMIT_DAYS_WITHOUT_RULING` also needs a ruling. */
|
|
224
|
+
declare const MAX_STUDY_LIMIT_DAYS = 30;
|
|
225
|
+
/** The last time at which a limit can start. A limit turns on at this time if its site did not turn it on before. */
|
|
226
|
+
declare const LAST_LIMIT_START = "2026-12-07T00:00:00Z";
|
|
223
227
|
/** One run that gives the data of a page. */
|
|
224
228
|
interface DataRun {
|
|
225
229
|
readonly id: string;
|
|
@@ -230,6 +234,8 @@ interface DataRun {
|
|
|
230
234
|
readonly engines: Readonly<Record<string, string>>;
|
|
231
235
|
/** The words for data that no CI run made, for example `lab run` or `hand count`. The page shows them in place of `run`. */
|
|
232
236
|
readonly method?: string;
|
|
237
|
+
/** The full commit of the code that ran. It is not the commit that added a copy of the data. A study with a limit in force needs it. */
|
|
238
|
+
readonly commit?: string;
|
|
233
239
|
}
|
|
234
240
|
/** The age limit of one page, in place of `MAX_DATA_AGE_DAYS`. */
|
|
235
241
|
interface DataLimit {
|
|
@@ -241,6 +247,15 @@ interface DataLimit {
|
|
|
241
247
|
readonly workflow: string;
|
|
242
248
|
/** The link to the public ruling. A limit over `MAX_LIMIT_DAYS_WITHOUT_RULING` needs it. */
|
|
243
249
|
readonly ruling?: string;
|
|
250
|
+
/** The ISO time at which the age rule and the commit rule start, at most `LAST_LIMIT_START`. A site removes this field at the first green read of its workflow. */
|
|
251
|
+
readonly startsAt?: string;
|
|
252
|
+
}
|
|
253
|
+
/** The two statements of a study with no age limit. The page shows both. */
|
|
254
|
+
interface NoAgeLimit {
|
|
255
|
+
/** The reason that no run of the current code can reproduce the numbers. */
|
|
256
|
+
readonly reproduce: string;
|
|
257
|
+
/** The reason that the page claims nothing about today. */
|
|
258
|
+
readonly today: string;
|
|
244
259
|
}
|
|
245
260
|
/** The stamp of one measured page. */
|
|
246
261
|
interface PageStamp {
|
|
@@ -249,10 +264,12 @@ interface PageStamp {
|
|
|
249
264
|
readonly runs: readonly DataRun[];
|
|
250
265
|
/** The run on newer engines that is in progress. */
|
|
251
266
|
readonly inFlight?: DataRun;
|
|
252
|
-
/** The page shows a
|
|
267
|
+
/** The page shows a study of the versions of its runs. A study has a `limit` or the field `noLimit`, and the rule of the engines does not apply to it. */
|
|
253
268
|
readonly study?: true;
|
|
254
269
|
/** The age limit of this page, in place of the default. */
|
|
255
270
|
readonly limit?: DataLimit;
|
|
271
|
+
/** The statements of a study with no age limit. */
|
|
272
|
+
readonly noLimit?: NoAgeLimit;
|
|
256
273
|
}
|
|
257
274
|
/** The content of a file of data stamps. */
|
|
258
275
|
interface DataStamps {
|
|
@@ -315,7 +332,9 @@ declare function cronLines(workflow: string): CronLine[];
|
|
|
315
332
|
* - The engines of the newest run are at most `maxMinorsBehind` behind npm at the start of that run.
|
|
316
333
|
* - A run in flight has the same age limit, so an old stamp does not hold the gate open.
|
|
317
334
|
* - A page with its own limit uses that limit, and the schedule of its workflow meets the limit.
|
|
318
|
-
* - A
|
|
335
|
+
* - A study has no limit of the engines, because it tells about the versions that it names.
|
|
336
|
+
* - A study with a limit in force names the commit of each run. A study with no limit has no age rule.
|
|
337
|
+
* - A limit with `startsAt` applies the age rule and the commit rule from that time. The schedule rule applies at once.
|
|
319
338
|
*/
|
|
320
339
|
declare function checkFreshness(stamps: DataStamps, options: FreshnessOptions): FreshnessCheck;
|
|
321
340
|
/** A time at which the gate must fail for a page, and what the gate says at that time. */
|
|
@@ -329,9 +348,9 @@ interface FailingCase {
|
|
|
329
348
|
}
|
|
330
349
|
/**
|
|
331
350
|
* This function gives one failing case for each page, from the stamps of the site itself. A measured page must fail one
|
|
332
|
-
* day after its limit, from `options.now
|
|
351
|
+
* day after its limit, from `options.now` or the start of the limit. A study with no limit must fail before the date of its run.
|
|
333
352
|
* Stamps that pass and give a case with no fault tell that the gate does not examine that page.
|
|
334
353
|
*/
|
|
335
354
|
declare function failingCases(stamps: DataStamps, options: FreshnessOptions): readonly FailingCase[];
|
|
336
|
-
export {
|
|
355
|
+
export { readKpi as A, KpiFile as B, KPI_FILE as C, kpiFile as D, KpiInput as E, CheckState as F, OpenWorkTotals as G, Link as H, GitHubOpenWork as I, ReleaseKind as J, Release as K, GitHubRelease as L, BoardIssue as M, BoardItem as N, kpiProblems as O, BoardPullRequest as P, GitHubReleases as R, parseDataStamps as S, KpiError as T, NpmPublishTimes as U, KpiMeasure as V, NpmVersionTime as W, StatusClass as X, StatusBoardData as Y, checkFreshness as _, DataStamps as a, latestAt as b, FreshnessCheck as c, MAX_DATA_AGE_DAYS as d, MAX_LIMIT_DAYS_WITHOUT_RULING as f, PageStamp as g, NoAgeLimit as h, DataRun as i, writeKpi as j, kpiText as k, FreshnessOptions as l, MAX_STUDY_LIMIT_DAYS as m, DATA_STAMP_SCHEMA as n, DataStampsParse as o, MAX_MINORS_BEHIND as p, ReleaseChange as q, DataLimit as r, FailingCase as s, CronLine as t, LAST_LIMIT_START as u, cronLines as v, KPI_FORMAT as w, minorsBehind as x, failingCases as y, KpiEngine as z };
|
|
337
356
|
//# sourceMappingURL=freshness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"freshness.d.ts","names":[],"sources":["../../src/data/types.ts","../../src/data/kpi.ts","../../src/check/freshness.ts"],"mappings":";;;;;UAMiB;EACf;EACA;;;;;;KAWU;;UAGK;;EAEf;;EAEA;;EAEA;;;UAIe;EACf;;EAEA;EACA,MAAM;;EAEN,SAAS;;EAET,OAAO;;;UAIQ;EACf;EACA;;EAEA;;EAEA;EACA;EACA;;;KAIU;EAAmB;EAAiB,UAAU;;EAAsB;EAAkB;;;UAGjF;EACf;EACA;EACA;;;UAIe;EACf,OAAO;EACP;;;KAQU;;UAGK;EACf;EACA;;EAEA;EACA,aAAa;EACb;EACA;;EAEA;;EAEA;;EAEA;EACA,OAAO;;;KAIG;;UAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,QAAQ;;;UAIO;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;UAIe;EACf;EACA;;;KAIU;EACN;EAAiB,cAAc;EAAoB,QAAQ;EAAc,QAAQ;;EACjF;EAAkB;;;UAGP;;EAEf;EACA;EACA;;EAEA;;EAEA;;;UAIe;;EAEf;EACA;;;UAIe;EACf;;EAEA;;EAEA;;EAEA;EACA,UAAU;;EAEV,UAAU;;;UAIK;;EAEf;;EAEA;;EAEA;IAAU;IAAwB;;EAClC,OAAO;EACP,cAAc;EACd,QAAQ;;EAER;IAAU;IAAoB;IAAiB,SAAS;;;EAExD,MAAM;;;cCzKK;;cAGA;;KAGD,WAAW,KAAK;;cAef,iBAAiB;WACnB;EAET,YAAY;;;;;;;;iBA6CE,YAAY,gBAAgB;;;;;;iBAgC5B,QAAQ,OAAO,UAAU,eAAe;;iBASxC,QAAQ,MAAM;;;;;;iBASd,QAAQ,cAAc,eAAe;;;;;;iBAkBrC,SAAS,aAAa,OAAO,UAAU;;cCpI1C;;cAGA;;cAGA;;cAGA;;
|
|
1
|
+
{"version":3,"file":"freshness.d.ts","names":[],"sources":["../../src/data/types.ts","../../src/data/kpi.ts","../../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AAe;;WAEf,WAAW;;WAEX;;WAEA,QAAQ;;WAER,UAAU;;;UAIJ;WACN,eAAe;WACf,gBAAgB;;;KAIf;WAA6B;WAAmB,QAAQ;;WAA0B;WAAoB;;;UAGjG;;WAEN;;WAEA,gBAAgB;;WAEhB;;WAEA;;WAEA,YAAY,SAAS;;;UAIf;;WAEN;;WAEA;;;;;;iBAkFK,gBAAgB,eAAe;;iBAwB/B,aAAa,cAAc;;iBAS3B,SAAS,gBAAgB,kBAAkB,cAAc;;UAqDxD;;WAEN;;WAEA;;;;;;iBAOK,UAAU,mBAAmB;;;;;;;;;;;;iBAwD7B,eAAe,QAAQ,YAAY,SAAS,mBAAmB;;UA8C9D;;WAEN;;WAEA;;WAEA;;;;;;;iBAQK,aAAa,QAAQ,YAAY,SAAS,4BAA4B"}
|
|
@@ -451,7 +451,7 @@ function listText(parts) {
|
|
|
451
451
|
* Each stamp names the page, its runs, their dates and their engine versions.
|
|
452
452
|
* The gate fails on a page with no versions or no run date, and on old data with no newer run in flight.
|
|
453
453
|
* The gate also fails on a run that started behind the engines on npm.
|
|
454
|
-
* A
|
|
454
|
+
* A study has an age limit and a scheduled workflow, or it says why it needs no limit. A page with a longer limit names the reason and the workflow.
|
|
455
455
|
* This file imports only Node.js and the folder `data`, so `reusable-pages.yml` starts it with no npm release of the package.
|
|
456
456
|
*/
|
|
457
457
|
/** The schema of a file of data stamps. */
|
|
@@ -462,7 +462,13 @@ const MAX_DATA_AGE_DAYS = 3;
|
|
|
462
462
|
const MAX_MINORS_BEHIND = 1;
|
|
463
463
|
/** The longest limit of a page, in days, with no ruling for that site. */
|
|
464
464
|
const MAX_LIMIT_DAYS_WITHOUT_RULING = 14;
|
|
465
|
+
/** The longest limit of a study, in days, also with a ruling. A study over `MAX_LIMIT_DAYS_WITHOUT_RULING` also needs a ruling. */
|
|
466
|
+
const MAX_STUDY_LIMIT_DAYS = 30;
|
|
467
|
+
/** The last time at which a limit can start. A limit turns on at this time if its site did not turn it on before. */
|
|
468
|
+
const LAST_LIMIT_START = "2026-12-07T00:00:00Z";
|
|
465
469
|
const DAY_MS = 864e5;
|
|
470
|
+
/** The form of a full commit. */
|
|
471
|
+
const FULL_COMMIT = /^[0-9a-f]{40}$/;
|
|
466
472
|
const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
467
473
|
/** The form of a two-part image tag, for example `7.4`. A fixed study can name it, because no check compares the versions of a study. */
|
|
468
474
|
const IMAGE_TAG = /^\d+\.\d+$/;
|
|
@@ -476,13 +482,14 @@ function runFaults(raw, at, study = false) {
|
|
|
476
482
|
if (typeof run["url"] !== "string" || !run["url"].startsWith("https://")) faults.push(`${label}: the run has no https link.`);
|
|
477
483
|
if (typeof run["date"] !== "string" || !Number.isFinite(Date.parse(run["date"]))) faults.push(`${label}: the run has no date.`);
|
|
478
484
|
if (run["method"] !== void 0 && (typeof run["method"] !== "string" || run["method"].trim() === "")) faults.push(`${label}: the method of the run is not text.`);
|
|
485
|
+
if (run["commit"] !== void 0 && (typeof run["commit"] !== "string" || !FULL_COMMIT.test(run["commit"]))) faults.push(`${label}: the commit of the run is not a full commit.`);
|
|
479
486
|
const engines = record(run["engines"]);
|
|
480
487
|
if (engines === null || Object.keys(engines).length === 0) return [...faults, `${label}: the run names no engine versions.`];
|
|
481
488
|
for (const [name, version] of Object.entries(engines)) if (!(typeof version === "string" && (parseVersion(version) !== null || study && IMAGE_TAG.test(version)))) faults.push(`${label}: the version of ${name} is not a version.`);
|
|
482
489
|
return faults;
|
|
483
490
|
}
|
|
484
491
|
/** This function gives the faults of the age limit of one page. */
|
|
485
|
-
function limitFaults(raw, at) {
|
|
492
|
+
function limitFaults(raw, at, study) {
|
|
486
493
|
const limit = record(raw);
|
|
487
494
|
if (limit === null) return [`${at}: the limit is not an object.`];
|
|
488
495
|
const faults = [];
|
|
@@ -493,6 +500,22 @@ function limitFaults(raw, at) {
|
|
|
493
500
|
const ruling = limit["ruling"];
|
|
494
501
|
if (ruling !== void 0 && (typeof ruling !== "string" || !ruling.startsWith("https://"))) faults.push(`${at}: the ruling of the limit has no https link.`);
|
|
495
502
|
if (typeof days === "number" && days > 14 && ruling === void 0) faults.push(`${at}: a limit over 14 days needs a ruling for this site.`);
|
|
503
|
+
if (study && typeof days === "number" && days > 30) faults.push(`${at}: the limit of a study is at most 30 days.`);
|
|
504
|
+
const startsAt = limit["startsAt"];
|
|
505
|
+
if (startsAt !== void 0) {
|
|
506
|
+
if (typeof startsAt !== "string" || !Number.isFinite(Date.parse(startsAt))) faults.push(`${at}: the start of the limit has no date.`);
|
|
507
|
+
else if (Date.parse(startsAt) > Date.parse("2026-12-07T00:00:00Z")) faults.push(`${at}: the start of the limit is after ${LAST_LIMIT_START.slice(0, 10)}.`);
|
|
508
|
+
}
|
|
509
|
+
return faults;
|
|
510
|
+
}
|
|
511
|
+
/** This function gives the faults of the statements of a study with no age limit. */
|
|
512
|
+
function noLimitFaults(raw, at) {
|
|
513
|
+
const statements = record(raw);
|
|
514
|
+
if (statements === null) return [`${at}: the field noLimit is not an object.`];
|
|
515
|
+
const faults = [];
|
|
516
|
+
const said = (value) => typeof value === "string" && value.trim() !== "";
|
|
517
|
+
if (!said(statements["reproduce"])) faults.push(`${at}: the field noLimit does not say why no run of the current code can reproduce the numbers.`);
|
|
518
|
+
if (!said(statements["today"])) faults.push(`${at}: the field noLimit does not say why the page claims nothing about today.`);
|
|
496
519
|
return faults;
|
|
497
520
|
}
|
|
498
521
|
/** This function gives the faults of the fields of a page that change the age rule. */
|
|
@@ -500,9 +523,14 @@ function ageRuleFaults(page, at) {
|
|
|
500
523
|
const faults = [];
|
|
501
524
|
const study = page["study"];
|
|
502
525
|
if (study !== void 0 && study !== true) faults.push(`${at}: the field study is not true.`);
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
if (
|
|
526
|
+
const limit = page["limit"];
|
|
527
|
+
const noLimit = page["noLimit"];
|
|
528
|
+
if (study === true && limit === void 0 && noLimit === void 0) faults.push(`${at}: a study needs a limit, or the field noLimit.`);
|
|
529
|
+
if (limit !== void 0 && noLimit !== void 0) faults.push(`${at}: a page has a limit or the field noLimit, not both.`);
|
|
530
|
+
if (study !== true && noLimit !== void 0) faults.push(`${at}: only a study has the field noLimit.`);
|
|
531
|
+
if (study === true && page["inFlight"] !== void 0) faults.push(`${at}: a study has no run in flight.`);
|
|
532
|
+
if (limit !== void 0) faults.push(...limitFaults(limit, at, study === true));
|
|
533
|
+
if (noLimit !== void 0) faults.push(...noLimitFaults(noLimit, at));
|
|
506
534
|
return faults;
|
|
507
535
|
}
|
|
508
536
|
/**
|
|
@@ -656,7 +684,9 @@ function hasNewerEngine(run, than) {
|
|
|
656
684
|
* - The engines of the newest run are at most `maxMinorsBehind` behind npm at the start of that run.
|
|
657
685
|
* - A run in flight has the same age limit, so an old stamp does not hold the gate open.
|
|
658
686
|
* - A page with its own limit uses that limit, and the schedule of its workflow meets the limit.
|
|
659
|
-
* - A
|
|
687
|
+
* - A study has no limit of the engines, because it tells about the versions that it names.
|
|
688
|
+
* - A study with a limit in force names the commit of each run. A study with no limit has no age rule.
|
|
689
|
+
* - A limit with `startsAt` applies the age rule and the commit rule from that time. The schedule rule applies at once.
|
|
660
690
|
*/
|
|
661
691
|
function checkFreshness(stamps, options) {
|
|
662
692
|
const { times, maxAgeDays: defaultAge = 3, maxMinorsBehind = 1, schedules = {} } = options;
|
|
@@ -665,8 +695,10 @@ function checkFreshness(stamps, options) {
|
|
|
665
695
|
const notRun = [];
|
|
666
696
|
for (const stamp of stamps.pages) {
|
|
667
697
|
for (const run of [...stamp.runs, ...stamp.inFlight === void 0 ? [] : [stamp.inFlight]]) if (ageInDays(run.date, now) < 0) faults.push(`${stamp.page}: the run ${run.id} has a date after the check.`);
|
|
668
|
-
if (stamp.study === true) continue;
|
|
698
|
+
if (stamp.study === true && stamp.limit === void 0) continue;
|
|
669
699
|
const maxAgeDays = stamp.limit?.days ?? defaultAge;
|
|
700
|
+
const startsAt = stamp.limit?.startsAt;
|
|
701
|
+
const inForce = startsAt === void 0 || Date.parse(startsAt) <= now;
|
|
670
702
|
if (stamp.limit !== void 0) {
|
|
671
703
|
const gap = schedules[stamp.limit.workflow];
|
|
672
704
|
if (gap === void 0 || typeof gap === "string") faults.push(`${stamp.page}: the limit of ${maxAgeDays} days has no schedule that the gate can read in ${stamp.limit.workflow}: ${gap ?? "the check has no read of this workflow"}.`);
|
|
@@ -677,7 +709,13 @@ function checkFreshness(stamps, options) {
|
|
|
677
709
|
if (flight !== void 0 && !flying) faults.push(`${stamp.page}: the run ${flight.id} is in flight for more than ${maxAgeDays} days.`);
|
|
678
710
|
for (const run of stamp.runs) {
|
|
679
711
|
const age = ageInDays(run.date, now);
|
|
680
|
-
if (age > maxAgeDays && !(flying && hasNewerEngine(flight, run))) faults.push(`${stamp.page}: the run ${run.id} is ${age.toFixed(1)} days old, over the limit of ${maxAgeDays}, and no run on newer engines is in flight.`);
|
|
712
|
+
if (inForce && age > maxAgeDays && !(flying && hasNewerEngine(flight, run))) faults.push(`${stamp.page}: the run ${run.id} is ${age.toFixed(1)} days old, over the limit of ${maxAgeDays}, and no run on newer engines is in flight.`);
|
|
713
|
+
}
|
|
714
|
+
if (stamp.study === true) {
|
|
715
|
+
if (inForce) {
|
|
716
|
+
for (const run of stamp.runs) if (run.commit === void 0) faults.push(`${stamp.page}: the run ${run.id} names no commit.`);
|
|
717
|
+
}
|
|
718
|
+
continue;
|
|
681
719
|
}
|
|
682
720
|
const newest = flight ?? [...stamp.runs].sort((a, b) => Date.parse(a.date) - Date.parse(b.date)).at(-1);
|
|
683
721
|
if (newest === void 0) continue;
|
|
@@ -694,14 +732,15 @@ function checkFreshness(stamps, options) {
|
|
|
694
732
|
}
|
|
695
733
|
/**
|
|
696
734
|
* This function gives one failing case for each page, from the stamps of the site itself. A measured page must fail one
|
|
697
|
-
* day after its limit, from `options.now
|
|
735
|
+
* day after its limit, from `options.now` or the start of the limit. A study with no limit must fail before the date of its run.
|
|
698
736
|
* Stamps that pass and give a case with no fault tell that the gate does not examine that page.
|
|
699
737
|
*/
|
|
700
738
|
function failingCases(stamps, options) {
|
|
701
739
|
return stamps.pages.map((stamp) => {
|
|
702
740
|
const dates = [...stamp.runs, ...stamp.inFlight === void 0 ? [] : [stamp.inFlight]].map((run) => Date.parse(run.date));
|
|
703
741
|
const days = stamp.limit?.days ?? options.maxAgeDays ?? 3;
|
|
704
|
-
const
|
|
742
|
+
const from = Math.max(Date.parse(options.now), Date.parse(stamp.limit?.startsAt ?? options.now));
|
|
743
|
+
const time = stamp.study === true && stamp.limit === void 0 ? Math.min(...dates) - DAY_MS : from + (days + 1) * DAY_MS;
|
|
705
744
|
const at = new Date(time).toISOString();
|
|
706
745
|
const [fault] = checkFreshness({
|
|
707
746
|
schema: stamps.schema,
|
|
@@ -799,6 +838,6 @@ async function runFreshnessCli(argv, io, fetcher) {
|
|
|
799
838
|
} else io.stdout(`Failing case at ${at}: ${fault}\n`);
|
|
800
839
|
return held ? 0 : 1;
|
|
801
840
|
}
|
|
802
|
-
export {
|
|
841
|
+
export { headCommit as A, versionOfTag as B, kpiFile as C, writeKpi as D, readKpi as E, NPM_REGISTRY as F, npmPublishTimes as I, compareVersions as L, isShallow as M, originRepository as N, git as O, versionCommitTime as P, kindOf as R, KpiError as S, kpiText as T, listText as _, MAX_MINORS_BEHIND as a, KPI_FILE as b, cronLines as c, minorsBehind as d, parseDataStamps as f, link as g, inlineMarkdown as h, MAX_LIMIT_DAYS_WITHOUT_RULING as i, headingDate as j, gitTagDates as k, failingCases as l, escapeHtml as m, LAST_LIMIT_START as n, MAX_STUDY_LIMIT_DAYS as o, runFreshnessCli as p, MAX_DATA_AGE_DAYS as r, checkFreshness as s, DATA_STAMP_SCHEMA as t, latestAt as u, plural as v, kpiProblems as w, KPI_FORMAT as x, safeUrl as y, parseVersion as z };
|
|
803
842
|
|
|
804
843
|
//# sourceMappingURL=freshness.js.map
|