@orkestrel/capture 0.0.9 → 0.0.10
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 +4 -2
- package/dist/src/core/index.cjs +75 -22
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +124 -51
- package/dist/src/core/index.d.ts +124 -51
- package/dist/src/core/index.js +73 -22
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +1012 -316
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +523 -22
- package/dist/src/server/index.d.ts +523 -22
- package/dist/src/server/index.js +991 -319
- package/dist/src/server/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -79,8 +79,10 @@ A selector is `all` or a declared colon-separated owner path. Only `--variant` r
|
|
|
79
79
|
flag except `--plan` and `--no-bail` takes a nonempty value as `--flag value` or `--flag=value`; a
|
|
80
80
|
value beginning with a dash needs equals form. The CLI refuses the `--` terminator and repeated single-value flags.
|
|
81
81
|
|
|
82
|
-
Registry refresh checks inherited manifest and lookup journal schemas before
|
|
83
|
-
|
|
82
|
+
Registry refresh checks inherited manifest and lookup journal versions, then schemas, before
|
|
83
|
+
starting a stage. A document of another version refuses the refresh with the files to remove and
|
|
84
|
+
the refresh commands; an unreadable document or an unsupported schema names the file to inspect
|
|
85
|
+
and repair.
|
|
84
86
|
|
|
85
87
|
For changed selection, `HEAD` includes uncommitted work. The plan prints changed paths and commands
|
|
86
88
|
after discovery and starts no execution child. Shared inputs refuse narrowing and print an explicit
|
package/dist/src/core/index.cjs
CHANGED
|
@@ -8,7 +8,9 @@ let _orkestrel_contract = require("@orkestrel/contract");
|
|
|
8
8
|
* `USAGE` is a refused command line and exits 64; every other condition exits 1. `SELECTION`
|
|
9
9
|
* names a selector, variant, case, state, or portfolio the host does not declare. `HOST` names a
|
|
10
10
|
* wrapper, configuration, or declaration fault. `STAGE` names a runner stage that did not
|
|
11
|
-
* complete. `EVIDENCE` names a record, report,
|
|
11
|
+
* complete. `EVIDENCE` names a record, report, journal, or manifest that fails its protocol, and a
|
|
12
|
+
* document of another version. `REGISTRY` names an accepted registry that is absent, fails
|
|
13
|
+
* authentication, or lags the declarations. `LOOKUP` names a state lookup that is absent or stale.
|
|
12
14
|
* `CONTAINMENT` names a path that leaves the authorized roots.
|
|
13
15
|
*
|
|
14
16
|
* @example
|
|
@@ -22,6 +24,8 @@ var CAPTURE_ERROR_CODES = Object.freeze([
|
|
|
22
24
|
"HOST",
|
|
23
25
|
"STAGE",
|
|
24
26
|
"EVIDENCE",
|
|
27
|
+
"REGISTRY",
|
|
28
|
+
"LOOKUP",
|
|
25
29
|
"CONTAINMENT"
|
|
26
30
|
]);
|
|
27
31
|
/**
|
|
@@ -71,10 +75,10 @@ var CAPTURE_REQUEST_PREFIX = "journey-selection";
|
|
|
71
75
|
*
|
|
72
76
|
* @example
|
|
73
77
|
* ```ts
|
|
74
|
-
* CAPTURE_VERSION //
|
|
78
|
+
* CAPTURE_VERSION // 2
|
|
75
79
|
* ```
|
|
76
80
|
*/
|
|
77
|
-
var CAPTURE_VERSION =
|
|
81
|
+
var CAPTURE_VERSION = 2;
|
|
78
82
|
/**
|
|
79
83
|
* Holds the eight bytes every PNG file opens with.
|
|
80
84
|
*
|
|
@@ -339,11 +343,11 @@ function isCaptureIdentity(value) {
|
|
|
339
343
|
* @example
|
|
340
344
|
* ```ts
|
|
341
345
|
* isCaptureRequest(JSON.parse(text)) // true for a well-formed runner request
|
|
342
|
-
* isCaptureRequest({ version:
|
|
346
|
+
* isCaptureRequest({ version: 1 }) // false
|
|
343
347
|
* ```
|
|
344
348
|
*/
|
|
345
349
|
function isCaptureRequest(value) {
|
|
346
|
-
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && isCaptureIdentity(value) && value.version ===
|
|
350
|
+
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && isCaptureIdentity(value) && value.version === 2 && (value.command === "journey" || value.command === "capture") && (value.mode === void 0 || typeof value.mode === "string" && value.mode.trim() !== "") && isCaptureSelector(value.selector) && (0, _orkestrel_contract.arrayOf)(isCaptureSegment)(value.variants) && value.variants.length > 0 && (0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isString)(value.args) && (value.case === void 0 || typeof value.case === "string" && value.case.trim() !== "") && (value.state === void 0 || value.command === "capture" && isCaptureSegment(value.state)));
|
|
347
351
|
}
|
|
348
352
|
/**
|
|
349
353
|
* Checks whether a collected declaration preserves its full owner and state population.
|
|
@@ -423,7 +427,7 @@ function isCaptureArtifact(value) {
|
|
|
423
427
|
* ```
|
|
424
428
|
*/
|
|
425
429
|
function isCaptureRun(value) {
|
|
426
|
-
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && value.version ===
|
|
430
|
+
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && value.version === 2 && isCaptureSegment(value.variant) && typeof value.time === "string" && Number.isFinite(Date.parse(value.time)) && typeof value.complete === "boolean" && typeof value.reference === "boolean" && (0, _orkestrel_contract.arrayOf)(isCaptureDeclaration)(value.declarations) && (0, _orkestrel_contract.arrayOf)(isCaptureDestination)(value.registry) && (0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isString)(value.passed) && (0, _orkestrel_contract.arrayOf)(isCaptureSegment)(value.observed) && (0, _orkestrel_contract.arrayOf)(isCaptureEntry)(value.entries) && (value.artifact === void 0 || isCaptureArtifact(value.artifact)) && (value.identity === void 0 && value.request === void 0 || isCaptureIdentity(value.identity) && isCaptureRequest(value.request)));
|
|
427
431
|
}
|
|
428
432
|
/**
|
|
429
433
|
* Checks whether a shared-source digest retains both patterns and expanded file hashes.
|
|
@@ -453,7 +457,7 @@ function isCaptureDigest(value) {
|
|
|
453
457
|
* ```
|
|
454
458
|
*/
|
|
455
459
|
function isCaptureReceipt(value) {
|
|
456
|
-
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && value.version ===
|
|
460
|
+
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && value.version === 2 && isCaptureSegment(value.variant) && typeof value.time === "string" && Number.isFinite(Date.parse(value.time)) && (0, _orkestrel_contract.isRecord)(value.report) && isCapturePath(value.report.file) && isCaptureHash(value.report.digest) && isCaptureHashes(value.inputs) && (0, _orkestrel_contract.arrayOf)(isCaptureDeclaration)(value.declarations) && (0, _orkestrel_contract.arrayOf)(isCaptureDestination)(value.registry) && typeof value.complete === "boolean");
|
|
457
461
|
}
|
|
458
462
|
/**
|
|
459
463
|
* Checks whether a registry document retains its receipts and required output pairs.
|
|
@@ -468,7 +472,7 @@ function isCaptureReceipt(value) {
|
|
|
468
472
|
* ```
|
|
469
473
|
*/
|
|
470
474
|
function isCaptureRegistry(value) {
|
|
471
|
-
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && value.version ===
|
|
475
|
+
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && value.version === 2 && (0, _orkestrel_contract.arrayOf)(isCaptureReceipt)(value.receipts) && (0, _orkestrel_contract.arrayOf)(isCaptureDestination)(value.entries) && isCaptureHash(value.digest));
|
|
472
476
|
}
|
|
473
477
|
/**
|
|
474
478
|
* Checks whether a lookup binds a passing case to its full run record and input hashes.
|
|
@@ -494,12 +498,12 @@ function isCaptureLookup(value) {
|
|
|
494
498
|
*
|
|
495
499
|
* @example
|
|
496
500
|
* ```ts
|
|
497
|
-
* isCaptureLookupJournal({ version:
|
|
498
|
-
* isCaptureLookupJournal({ version:
|
|
501
|
+
* isCaptureLookupJournal({ version: 2, populations: {}, lookups: [] }) // true
|
|
502
|
+
* isCaptureLookupJournal({ version: 1, populations: {}, lookups: [] }) // false
|
|
499
503
|
* ```
|
|
500
504
|
*/
|
|
501
505
|
function isCaptureLookupJournal(value) {
|
|
502
|
-
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && (value.collections === void 0 || (0, _orkestrel_contract.arrayOf)(isCaptureCollection)(value.collections)) && value.version ===
|
|
506
|
+
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && (value.collections === void 0 || (0, _orkestrel_contract.arrayOf)(isCaptureCollection)(value.collections)) && value.version === 2 && (value.manifest === void 0 || isCaptureHash(value.manifest)) && (0, _orkestrel_contract.isRecord)(value.populations) && Object.entries(value.populations).every(([digest, inputs]) => isCaptureHash(digest) && isCaptureHashes(inputs)) && (0, _orkestrel_contract.arrayOf)((entry) => (0, _orkestrel_contract.isRecord)(entry) && isCaptureHash(entry.inputs) && isCaptureLookup({
|
|
503
507
|
...entry,
|
|
504
508
|
inputs: {}
|
|
505
509
|
}))(value.lookups));
|
|
@@ -520,19 +524,19 @@ function isCaptureStamp(value) {
|
|
|
520
524
|
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && isCaptureEntry(value) && isCaptureIdentity(value.identity) && typeof value.time === "string" && Number.isFinite(Date.parse(value.time)) && typeof value.commit === "string" && /^[a-f0-9]{40,64}$/u.test(value.commit) && (0, _orkestrel_contract.arrayOf)(isCapturePath)(value.dirty) && isCaptureHashes(value.own) && isCaptureDigest(value.shared) && isCaptureHashes(value.tests) && isCaptureHash(value.registry) && (0, _orkestrel_contract.isRecord)(value.image) && isCaptureHash(value.image.digest) && (0, _orkestrel_contract.isFiniteNumber)(value.image.size) && Number.isSafeInteger(value.image.size) && value.image.size > 0 && (0, _orkestrel_contract.isFiniteNumber)(value.image.modified) && value.image.modified >= 0);
|
|
521
525
|
}
|
|
522
526
|
/**
|
|
523
|
-
* Checks whether an
|
|
527
|
+
* Checks whether an expanded manifest has the supported schema without discarding malformed rows.
|
|
524
528
|
*
|
|
525
529
|
* @param value - The manifest
|
|
526
530
|
* @returns True if every inherited member validates; false otherwise
|
|
527
531
|
*
|
|
528
532
|
* @example
|
|
529
533
|
* ```ts
|
|
530
|
-
* isCaptureManifest(JSON.parse(text)) // true for
|
|
534
|
+
* isCaptureManifest(readCaptureManifest(JSON.parse(text), file)) // true for an expanded manifest.json
|
|
531
535
|
* isCaptureManifest('manifest') // false
|
|
532
536
|
* ```
|
|
533
537
|
*/
|
|
534
538
|
function isCaptureManifest(value) {
|
|
535
|
-
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && value.version ===
|
|
539
|
+
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && value.version === 2 && isCaptureRegistry(value.registry) && (0, _orkestrel_contract.isRecord)(value.entries) && Object.entries(value.entries).every(([key, stamp]) => isCapturePath(key) && isCaptureStamp(stamp)) && (0, _orkestrel_contract.arrayOf)(isCaptureLookup)(value.lookups));
|
|
536
540
|
}
|
|
537
541
|
/**
|
|
538
542
|
* Checks whether collection evidence pins complete input membership and both external artifacts.
|
|
@@ -550,21 +554,68 @@ function isCaptureCollection(value) {
|
|
|
550
554
|
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && isCaptureHash(value.registry) && isCaptureSegment(value.variant) && typeof value.project === "string" && value.project.trim() !== "" && isCaptureDigest(value.inputs) && (0, _orkestrel_contract.isRecord)(value.run) && isCapturePath(value.run.file) && isCaptureHash(value.run.digest) && (0, _orkestrel_contract.isRecord)(value.report) && isCapturePath(value.report.file) && isCaptureHash(value.report.digest));
|
|
551
555
|
}
|
|
552
556
|
/**
|
|
553
|
-
* Checks optional collection
|
|
557
|
+
* Checks whether an expanded manifest and its optional collection receipts have the supported schema.
|
|
554
558
|
*
|
|
555
|
-
* @param value - The
|
|
556
|
-
* @returns True if
|
|
559
|
+
* @param value - The expanded manifest
|
|
560
|
+
* @returns True if the manifest and any collection receipts are valid; false otherwise
|
|
557
561
|
*
|
|
558
562
|
* @example
|
|
559
563
|
* ```ts
|
|
560
|
-
*
|
|
561
|
-
*
|
|
564
|
+
* isCaptureExpandedManifest(readCaptureManifest(JSON.parse(text), file)) // true with or without collections
|
|
565
|
+
* isCaptureExpandedManifest(null) // false
|
|
562
566
|
* ```
|
|
563
567
|
*/
|
|
564
|
-
function
|
|
568
|
+
function isCaptureExpandedManifest(value) {
|
|
565
569
|
return (0, _orkestrel_contract.holds)(() => isCaptureManifest(value) && (0, _orkestrel_contract.isRecord)(value) && (value.collections === void 0 || (0, _orkestrel_contract.arrayOf)(isCaptureCollection)(value.collections)));
|
|
566
570
|
}
|
|
567
571
|
/**
|
|
572
|
+
* Checks whether a digest names its file map by a table key beside its patterns and combined digest.
|
|
573
|
+
*
|
|
574
|
+
* @param value - The stored digest reference
|
|
575
|
+
* @returns True if the patterns are valid and both digests are SHA-256 hexadecimal; false otherwise
|
|
576
|
+
*
|
|
577
|
+
* @example
|
|
578
|
+
* ```ts
|
|
579
|
+
* isCaptureDigestReference({ patterns: ['src/**'], files: 'a'.repeat(64), digest: 'b'.repeat(64) }) // true
|
|
580
|
+
* isCaptureDigestReference({ patterns: ['src/**'], files: {}, digest: 'b'.repeat(64) }) // false
|
|
581
|
+
* ```
|
|
582
|
+
*/
|
|
583
|
+
function isCaptureDigestReference(value) {
|
|
584
|
+
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && (0, _orkestrel_contract.arrayOf)(isCapturePattern)(value.patterns) && isCaptureHash(value.files) && isCaptureHash(value.digest));
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Checks whether a stored manifest holds its population table and every member that names a table key.
|
|
588
|
+
*
|
|
589
|
+
* @param value - The decoded manifest file
|
|
590
|
+
* @returns True if the version, table, registry, stamps, lookups, and collections are valid; false otherwise
|
|
591
|
+
* @remarks Table digests and reference existence are verified when the document is read.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* ```ts
|
|
595
|
+
* isCaptureManifestDocument(JSON.parse(text)) // true for a written manifest.json
|
|
596
|
+
* isCaptureManifestDocument({ version: 1, populations: {}, entries: {}, lookups: [] }) // false
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
function isCaptureManifestDocument(value) {
|
|
600
|
+
return (0, _orkestrel_contract.holds)(() => (0, _orkestrel_contract.isRecord)(value) && isCaptureLookupJournal({
|
|
601
|
+
version: value.version,
|
|
602
|
+
populations: value.populations,
|
|
603
|
+
lookups: value.lookups
|
|
604
|
+
}) && isCaptureRegistry(value.registry) && (0, _orkestrel_contract.isRecord)(value.entries) && Object.entries(value.entries).every(([key, stamp]) => isCapturePath(key) && (0, _orkestrel_contract.isRecord)(stamp) && isCaptureDigestReference(stamp.shared) && isCaptureStamp({
|
|
605
|
+
...stamp,
|
|
606
|
+
shared: {
|
|
607
|
+
...stamp.shared,
|
|
608
|
+
files: {}
|
|
609
|
+
}
|
|
610
|
+
})) && (value.collections === void 0 || (0, _orkestrel_contract.arrayOf)((entry) => (0, _orkestrel_contract.isRecord)(entry) && isCaptureDigestReference(entry.inputs) && isCaptureCollection({
|
|
611
|
+
...entry,
|
|
612
|
+
inputs: {
|
|
613
|
+
...entry.inputs,
|
|
614
|
+
files: {}
|
|
615
|
+
}
|
|
616
|
+
}))(value.collections)));
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
568
619
|
* Checks the host's declared viewport without deriving geometry from an output name.
|
|
569
620
|
*
|
|
570
621
|
* @param value - The published viewport data
|
|
@@ -1290,7 +1341,7 @@ function buildCaptureRun(options) {
|
|
|
1290
1341
|
const reference = options.registry.filter((entry) => entry.section === entry.state);
|
|
1291
1342
|
const request = options.request;
|
|
1292
1343
|
return {
|
|
1293
|
-
version:
|
|
1344
|
+
version: 2,
|
|
1294
1345
|
...request === void 0 ? {} : {
|
|
1295
1346
|
identity: {
|
|
1296
1347
|
id: request.id,
|
|
@@ -1389,8 +1440,10 @@ exports.isCaptureCollection = isCaptureCollection;
|
|
|
1389
1440
|
exports.isCaptureDeclaration = isCaptureDeclaration;
|
|
1390
1441
|
exports.isCaptureDestination = isCaptureDestination;
|
|
1391
1442
|
exports.isCaptureDigest = isCaptureDigest;
|
|
1443
|
+
exports.isCaptureDigestReference = isCaptureDigestReference;
|
|
1392
1444
|
exports.isCaptureEntry = isCaptureEntry;
|
|
1393
1445
|
exports.isCaptureError = isCaptureError;
|
|
1446
|
+
exports.isCaptureExpandedManifest = isCaptureExpandedManifest;
|
|
1394
1447
|
exports.isCaptureGeometry = isCaptureGeometry;
|
|
1395
1448
|
exports.isCaptureHash = isCaptureHash;
|
|
1396
1449
|
exports.isCaptureHashes = isCaptureHashes;
|
|
@@ -1398,6 +1451,7 @@ exports.isCaptureIdentity = isCaptureIdentity;
|
|
|
1398
1451
|
exports.isCaptureLookup = isCaptureLookup;
|
|
1399
1452
|
exports.isCaptureLookupJournal = isCaptureLookupJournal;
|
|
1400
1453
|
exports.isCaptureManifest = isCaptureManifest;
|
|
1454
|
+
exports.isCaptureManifestDocument = isCaptureManifestDocument;
|
|
1401
1455
|
exports.isCapturePath = isCapturePath;
|
|
1402
1456
|
exports.isCapturePattern = isCapturePattern;
|
|
1403
1457
|
exports.isCaptureReceipt = isCaptureReceipt;
|
|
@@ -1408,7 +1462,6 @@ exports.isCaptureSegment = isCaptureSegment;
|
|
|
1408
1462
|
exports.isCaptureSelector = isCaptureSelector;
|
|
1409
1463
|
exports.isCaptureSources = isCaptureSources;
|
|
1410
1464
|
exports.isCaptureStamp = isCaptureStamp;
|
|
1411
|
-
exports.isCaptureStoredManifest = isCaptureStoredManifest;
|
|
1412
1465
|
exports.matchesCaptureMembers = matchesCaptureMembers;
|
|
1413
1466
|
exports.matchesCaptureSelector = matchesCaptureSelector;
|
|
1414
1467
|
exports.readCaptureArtifact = readCaptureArtifact;
|