@adcp/sdk 17.0.0-beta.31 → 17.0.0-beta.32
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/dist/lib/identity-3.3/trust.js +10 -4
- package/dist/lib/identity-3.3/trust.mjs +10 -4
- package/dist/lib/server/create-adcp-server.js +7 -8
- package/dist/lib/server/create-adcp-server.mjs +9 -10
- package/dist/lib/server/error-arm-tools.d.mts +23 -14
- package/dist/lib/server/error-arm-tools.d.ts +23 -14
- package/dist/lib/server/error-arm-tools.js +82 -34
- package/dist/lib/server/error-arm-tools.mjs +81 -34
- package/dist/lib/testing/storyboard/compliance.js +53 -24
- package/dist/lib/testing/storyboard/compliance.mjs +53 -24
- package/dist/lib/testing/storyboard/loader.js +2 -2
- package/dist/lib/testing/storyboard/loader.mjs +2 -2
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/testing/storyboard/yaml-cache.d.mts +21 -0
- package/dist/lib/testing/storyboard/yaml-cache.d.ts +21 -0
- package/dist/lib/testing/storyboard/yaml-cache.js +168 -0
- package/dist/lib/testing/storyboard/yaml-cache.mjs +139 -0
- package/dist/lib/validation/schema-diagnostic-origins.js +55 -25
- package/dist/lib/validation/schema-diagnostic-origins.mjs +55 -25
- package/dist/lib/validation/schema-loader.js +499 -44
- package/dist/lib/validation/schema-loader.mjs +499 -46
- package/dist/lib/validation/schema-validator.js +4 -6
- package/dist/lib/validation/schema-validator.mjs +6 -7
- package/dist/lib/validation/validator-cache.d.mts +45 -0
- package/dist/lib/validation/validator-cache.d.ts +45 -0
- package/dist/lib/validation/validator-cache.js +249 -0
- package/dist/lib/validation/validator-cache.mjs +227 -0
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/docs/TYPE-SUMMARY.md +2 -2
- package/docs/llms.txt +2 -2
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/package.json +1 -1
|
@@ -39,9 +39,9 @@ __export(compliance_exports, {
|
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(compliance_exports);
|
|
41
41
|
var import_fs = require("fs");
|
|
42
|
-
var import_yaml = require("yaml");
|
|
43
42
|
var import_path = require("path");
|
|
44
43
|
var import_loader = require('./loader.js');
|
|
44
|
+
var import_yaml_cache = require('./yaml-cache.js');
|
|
45
45
|
var import_version = require('../../version.js');
|
|
46
46
|
var import_errors = require('../../errors/index.js');
|
|
47
47
|
var import_adcp_version_config = require('../../utils/adcp-version-config.js');
|
|
@@ -345,7 +345,7 @@ function annotateStoryboardVersion(storyboard, adcpVersion, complianceDir) {
|
|
|
345
345
|
function isUniversalMetadataFile(path) {
|
|
346
346
|
try {
|
|
347
347
|
const source = (0, import_fs.readFileSync)(path, "utf8");
|
|
348
|
-
const document = (0,
|
|
348
|
+
const document = (0, import_yaml_cache.parseStoryboardYaml)(source);
|
|
349
349
|
if (document === null && /^\s*#/m.test(source) && source.split(/\r?\n/).every((line) => /^\s*(?:#.*)?$/.test(line)))
|
|
350
350
|
return true;
|
|
351
351
|
if (!document || typeof document !== "object" || Array.isArray(document)) {
|
|
@@ -404,11 +404,12 @@ function withSynthesisErrorPhase(storyboard, err) {
|
|
|
404
404
|
return { ...storyboard, phases: [errorPhase, ...storyboard.phases] };
|
|
405
405
|
}
|
|
406
406
|
function listBundles(options = {}) {
|
|
407
|
-
|
|
408
|
-
|
|
407
|
+
return scopeBundles(complianceScope(options), loadComplianceIndex(options), getComplianceCacheDir(options));
|
|
408
|
+
}
|
|
409
|
+
function scopeBundles(scope, index, dir) {
|
|
409
410
|
const bundles = [];
|
|
410
411
|
for (const name of index.universal) {
|
|
411
|
-
if (
|
|
412
|
+
if (scopedUniversalMetadata(scope, name)) continue;
|
|
412
413
|
bundles.push({
|
|
413
414
|
kind: "universal",
|
|
414
415
|
id: name,
|
|
@@ -436,7 +437,7 @@ function listBundles(options = {}) {
|
|
|
436
437
|
return bundles;
|
|
437
438
|
}
|
|
438
439
|
const STORYBOARD_INDEX_CACHE_LIMIT = 8;
|
|
439
|
-
const
|
|
440
|
+
const complianceScopes = /* @__PURE__ */ new Map();
|
|
440
441
|
function customComplianceInventory(dir) {
|
|
441
442
|
if (!(0, import_fs.existsSync)(dir)) return "missing";
|
|
442
443
|
const entries = [];
|
|
@@ -453,7 +454,7 @@ function customComplianceInventory(dir) {
|
|
|
453
454
|
visit(dir, "");
|
|
454
455
|
return JSON.stringify(entries);
|
|
455
456
|
}
|
|
456
|
-
function
|
|
457
|
+
function complianceScope(options) {
|
|
457
458
|
const dir = (0, import_path.resolve)(getComplianceCacheDir(options));
|
|
458
459
|
const indexPath = (0, import_path.join)(dir, "index.json");
|
|
459
460
|
const stamp = (0, import_fs.existsSync)(indexPath) ? (0, import_fs.statSync)(indexPath) : void 0;
|
|
@@ -469,24 +470,52 @@ function complianceStoryboardIndex(options) {
|
|
|
469
470
|
stamp?.size ?? null,
|
|
470
471
|
inventory
|
|
471
472
|
]);
|
|
472
|
-
const cached =
|
|
473
|
+
const cached = complianceScopes.get(key);
|
|
473
474
|
if (cached) {
|
|
474
|
-
|
|
475
|
-
|
|
475
|
+
complianceScopes.delete(key);
|
|
476
|
+
complianceScopes.set(key, cached);
|
|
476
477
|
return cached;
|
|
477
478
|
}
|
|
478
479
|
if (customRoot) (0, import_vector_loader.invalidateRequestSigningVectorCache)(dir);
|
|
480
|
+
const scope = { dir, bundles: /* @__PURE__ */ new Map(), universalMetadata: /* @__PURE__ */ new Map() };
|
|
481
|
+
complianceScopes.set(key, scope);
|
|
482
|
+
while (complianceScopes.size > STORYBOARD_INDEX_CACHE_LIMIT) {
|
|
483
|
+
const oldest = complianceScopes.keys().next().value;
|
|
484
|
+
if (oldest !== void 0) complianceScopes.delete(oldest);
|
|
485
|
+
}
|
|
486
|
+
return scope;
|
|
487
|
+
}
|
|
488
|
+
function scopedUniversalMetadata(scope, name) {
|
|
489
|
+
let metadata = scope.universalMetadata.get(name);
|
|
490
|
+
if (metadata === void 0) {
|
|
491
|
+
metadata = isUniversalMetadataFile((0, import_path.join)(scope.dir, "universal", `${name}.yaml`));
|
|
492
|
+
scope.universalMetadata.set(name, metadata);
|
|
493
|
+
}
|
|
494
|
+
return metadata;
|
|
495
|
+
}
|
|
496
|
+
function bundlePath(dir, ref) {
|
|
497
|
+
if (ref.kind === "universal") return (0, import_path.join)(dir, "universal", `${ref.id}.yaml`);
|
|
498
|
+
return (0, import_path.join)(dir, ref.kind === "protocol" ? "protocols" : "specialisms", ref.id);
|
|
499
|
+
}
|
|
500
|
+
function scopedBundleStoryboards(scope, ref) {
|
|
501
|
+
const key = `${ref.kind}:${ref.id}`;
|
|
502
|
+
let storyboards = scope.bundles.get(key);
|
|
503
|
+
if (!storyboards) {
|
|
504
|
+
storyboards = loadBundleStoryboards({ ...ref, path: bundlePath(scope.dir, ref) });
|
|
505
|
+
scope.bundles.set(key, storyboards);
|
|
506
|
+
}
|
|
507
|
+
return storyboards;
|
|
508
|
+
}
|
|
509
|
+
function complianceStoryboardIndex(options) {
|
|
510
|
+
const scope = complianceScope(options);
|
|
511
|
+
if (scope.byId) return scope.byId;
|
|
479
512
|
const indexed = /* @__PURE__ */ new Map();
|
|
480
|
-
for (const ref of
|
|
481
|
-
for (const storyboard of
|
|
513
|
+
for (const ref of scopeBundles(scope, loadComplianceIndex(options), scope.dir)) {
|
|
514
|
+
for (const storyboard of scopedBundleStoryboards(scope, ref)) {
|
|
482
515
|
if (!indexed.has(storyboard.id)) indexed.set(storyboard.id, storyboard);
|
|
483
516
|
}
|
|
484
517
|
}
|
|
485
|
-
|
|
486
|
-
while (storyboardIndexes.size > STORYBOARD_INDEX_CACHE_LIMIT) {
|
|
487
|
-
const oldest = storyboardIndexes.keys().next().value;
|
|
488
|
-
if (oldest !== void 0) storyboardIndexes.delete(oldest);
|
|
489
|
-
}
|
|
518
|
+
scope.byId = indexed;
|
|
490
519
|
return indexed;
|
|
491
520
|
}
|
|
492
521
|
function cloneComplianceStoryboard(storyboard) {
|
|
@@ -511,12 +540,11 @@ function loadSpecialismDetail(slug, options = {}) {
|
|
|
511
540
|
const known = index.specialisms.map((s) => s.id).join(", ");
|
|
512
541
|
throw new Error(`Unknown specialism "${slug}". Known specialisms: ${known}`);
|
|
513
542
|
}
|
|
514
|
-
const bundleStoryboards =
|
|
543
|
+
const bundleStoryboards = scopedBundleStoryboards(complianceScope(options), {
|
|
515
544
|
kind: "specialism",
|
|
516
545
|
id: slug,
|
|
517
|
-
path: (0, import_path.join)(getComplianceCacheDir(options), "specialisms", slug),
|
|
518
546
|
adcp_version: index.adcp_version
|
|
519
|
-
});
|
|
547
|
+
}).map(cloneComplianceStoryboard);
|
|
520
548
|
const storyboard = bundleStoryboards.find((sb) => sb.category === entry.id.replace(/-/g, "_")) ?? bundleStoryboards[0];
|
|
521
549
|
if (!storyboard) {
|
|
522
550
|
throw new Error(
|
|
@@ -548,20 +576,21 @@ function listSpecialisms(options = {}) {
|
|
|
548
576
|
}
|
|
549
577
|
function resolveBundleOrStoryboard(id, options = {}) {
|
|
550
578
|
const bundle = findBundleById(id, options);
|
|
551
|
-
if (bundle) return
|
|
579
|
+
if (bundle) return scopedBundleStoryboards(complianceScope(options), bundle).map(cloneComplianceStoryboard);
|
|
552
580
|
const sb = getComplianceStoryboardById(id, options);
|
|
553
581
|
return sb ? [sb] : [];
|
|
554
582
|
}
|
|
555
583
|
function resolveStoryboardsForCapabilities(caps, options = {}) {
|
|
556
584
|
const index = loadComplianceIndex(options);
|
|
557
585
|
assertSupportedComplianceVersion(index.adcp_version, caps.supported_versions, options);
|
|
558
|
-
const
|
|
586
|
+
const scope = complianceScope(options);
|
|
587
|
+
const cacheDir = scope.dir;
|
|
559
588
|
const bundles = [];
|
|
560
589
|
const storyboards = [];
|
|
561
590
|
const notApplicable = [];
|
|
562
591
|
const seenStoryboards = /* @__PURE__ */ new Set();
|
|
563
592
|
const push = (ref) => {
|
|
564
|
-
const sbs =
|
|
593
|
+
const sbs = scopedBundleStoryboards(scope, ref).map(cloneComplianceStoryboard);
|
|
565
594
|
bundles.push({ ref, storyboards: sbs });
|
|
566
595
|
for (const sb of sbs) {
|
|
567
596
|
if (seenStoryboards.has(sb.id)) continue;
|
|
@@ -581,7 +610,7 @@ function resolveStoryboardsForCapabilities(caps, options = {}) {
|
|
|
581
610
|
}
|
|
582
611
|
};
|
|
583
612
|
for (const name of index.universal) {
|
|
584
|
-
if (
|
|
613
|
+
if (scopedUniversalMetadata(scope, name)) continue;
|
|
585
614
|
push({
|
|
586
615
|
kind: "universal",
|
|
587
616
|
id: name,
|
|
@@ -4,9 +4,9 @@ import { createRequire as __adcpCreateRequire } from "node:module";
|
|
|
4
4
|
const __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));
|
|
5
5
|
const require2 = __adcpCreateRequire(import.meta.url);
|
|
6
6
|
import { readFileSync, readdirSync, existsSync, statSync } from "fs";
|
|
7
|
-
import { parse as parseYaml } from "yaml";
|
|
8
7
|
import { basename, dirname, join, resolve } from "path";
|
|
9
8
|
import { loadStoryboardFile } from "./loader.mjs";
|
|
9
|
+
import { parseStoryboardYaml } from "./yaml-cache.mjs";
|
|
10
10
|
import { ADCP_VERSION } from "../../version.mjs";
|
|
11
11
|
import { ADCPError } from "../../errors/index.mjs";
|
|
12
12
|
import { isAdcpVersionSupported } from "../../utils/adcp-version-config.mjs";
|
|
@@ -310,7 +310,7 @@ function annotateStoryboardVersion(storyboard, adcpVersion, complianceDir) {
|
|
|
310
310
|
function isUniversalMetadataFile(path) {
|
|
311
311
|
try {
|
|
312
312
|
const source = readFileSync(path, "utf8");
|
|
313
|
-
const document =
|
|
313
|
+
const document = parseStoryboardYaml(source);
|
|
314
314
|
if (document === null && /^\s*#/m.test(source) && source.split(/\r?\n/).every((line) => /^\s*(?:#.*)?$/.test(line)))
|
|
315
315
|
return true;
|
|
316
316
|
if (!document || typeof document !== "object" || Array.isArray(document)) {
|
|
@@ -369,11 +369,12 @@ function withSynthesisErrorPhase(storyboard, err) {
|
|
|
369
369
|
return { ...storyboard, phases: [errorPhase, ...storyboard.phases] };
|
|
370
370
|
}
|
|
371
371
|
function listBundles(options = {}) {
|
|
372
|
-
|
|
373
|
-
|
|
372
|
+
return scopeBundles(complianceScope(options), loadComplianceIndex(options), getComplianceCacheDir(options));
|
|
373
|
+
}
|
|
374
|
+
function scopeBundles(scope, index, dir) {
|
|
374
375
|
const bundles = [];
|
|
375
376
|
for (const name of index.universal) {
|
|
376
|
-
if (
|
|
377
|
+
if (scopedUniversalMetadata(scope, name)) continue;
|
|
377
378
|
bundles.push({
|
|
378
379
|
kind: "universal",
|
|
379
380
|
id: name,
|
|
@@ -401,7 +402,7 @@ function listBundles(options = {}) {
|
|
|
401
402
|
return bundles;
|
|
402
403
|
}
|
|
403
404
|
const STORYBOARD_INDEX_CACHE_LIMIT = 8;
|
|
404
|
-
const
|
|
405
|
+
const complianceScopes = /* @__PURE__ */ new Map();
|
|
405
406
|
function customComplianceInventory(dir) {
|
|
406
407
|
if (!existsSync(dir)) return "missing";
|
|
407
408
|
const entries = [];
|
|
@@ -418,7 +419,7 @@ function customComplianceInventory(dir) {
|
|
|
418
419
|
visit(dir, "");
|
|
419
420
|
return JSON.stringify(entries);
|
|
420
421
|
}
|
|
421
|
-
function
|
|
422
|
+
function complianceScope(options) {
|
|
422
423
|
const dir = resolve(getComplianceCacheDir(options));
|
|
423
424
|
const indexPath = join(dir, "index.json");
|
|
424
425
|
const stamp = existsSync(indexPath) ? statSync(indexPath) : void 0;
|
|
@@ -434,24 +435,52 @@ function complianceStoryboardIndex(options) {
|
|
|
434
435
|
stamp?.size ?? null,
|
|
435
436
|
inventory
|
|
436
437
|
]);
|
|
437
|
-
const cached =
|
|
438
|
+
const cached = complianceScopes.get(key);
|
|
438
439
|
if (cached) {
|
|
439
|
-
|
|
440
|
-
|
|
440
|
+
complianceScopes.delete(key);
|
|
441
|
+
complianceScopes.set(key, cached);
|
|
441
442
|
return cached;
|
|
442
443
|
}
|
|
443
444
|
if (customRoot) invalidateRequestSigningVectorCache(dir);
|
|
445
|
+
const scope = { dir, bundles: /* @__PURE__ */ new Map(), universalMetadata: /* @__PURE__ */ new Map() };
|
|
446
|
+
complianceScopes.set(key, scope);
|
|
447
|
+
while (complianceScopes.size > STORYBOARD_INDEX_CACHE_LIMIT) {
|
|
448
|
+
const oldest = complianceScopes.keys().next().value;
|
|
449
|
+
if (oldest !== void 0) complianceScopes.delete(oldest);
|
|
450
|
+
}
|
|
451
|
+
return scope;
|
|
452
|
+
}
|
|
453
|
+
function scopedUniversalMetadata(scope, name) {
|
|
454
|
+
let metadata = scope.universalMetadata.get(name);
|
|
455
|
+
if (metadata === void 0) {
|
|
456
|
+
metadata = isUniversalMetadataFile(join(scope.dir, "universal", `${name}.yaml`));
|
|
457
|
+
scope.universalMetadata.set(name, metadata);
|
|
458
|
+
}
|
|
459
|
+
return metadata;
|
|
460
|
+
}
|
|
461
|
+
function bundlePath(dir, ref) {
|
|
462
|
+
if (ref.kind === "universal") return join(dir, "universal", `${ref.id}.yaml`);
|
|
463
|
+
return join(dir, ref.kind === "protocol" ? "protocols" : "specialisms", ref.id);
|
|
464
|
+
}
|
|
465
|
+
function scopedBundleStoryboards(scope, ref) {
|
|
466
|
+
const key = `${ref.kind}:${ref.id}`;
|
|
467
|
+
let storyboards = scope.bundles.get(key);
|
|
468
|
+
if (!storyboards) {
|
|
469
|
+
storyboards = loadBundleStoryboards({ ...ref, path: bundlePath(scope.dir, ref) });
|
|
470
|
+
scope.bundles.set(key, storyboards);
|
|
471
|
+
}
|
|
472
|
+
return storyboards;
|
|
473
|
+
}
|
|
474
|
+
function complianceStoryboardIndex(options) {
|
|
475
|
+
const scope = complianceScope(options);
|
|
476
|
+
if (scope.byId) return scope.byId;
|
|
444
477
|
const indexed = /* @__PURE__ */ new Map();
|
|
445
|
-
for (const ref of
|
|
446
|
-
for (const storyboard of
|
|
478
|
+
for (const ref of scopeBundles(scope, loadComplianceIndex(options), scope.dir)) {
|
|
479
|
+
for (const storyboard of scopedBundleStoryboards(scope, ref)) {
|
|
447
480
|
if (!indexed.has(storyboard.id)) indexed.set(storyboard.id, storyboard);
|
|
448
481
|
}
|
|
449
482
|
}
|
|
450
|
-
|
|
451
|
-
while (storyboardIndexes.size > STORYBOARD_INDEX_CACHE_LIMIT) {
|
|
452
|
-
const oldest = storyboardIndexes.keys().next().value;
|
|
453
|
-
if (oldest !== void 0) storyboardIndexes.delete(oldest);
|
|
454
|
-
}
|
|
483
|
+
scope.byId = indexed;
|
|
455
484
|
return indexed;
|
|
456
485
|
}
|
|
457
486
|
function cloneComplianceStoryboard(storyboard) {
|
|
@@ -476,12 +505,11 @@ function loadSpecialismDetail(slug, options = {}) {
|
|
|
476
505
|
const known = index.specialisms.map((s) => s.id).join(", ");
|
|
477
506
|
throw new Error(`Unknown specialism "${slug}". Known specialisms: ${known}`);
|
|
478
507
|
}
|
|
479
|
-
const bundleStoryboards =
|
|
508
|
+
const bundleStoryboards = scopedBundleStoryboards(complianceScope(options), {
|
|
480
509
|
kind: "specialism",
|
|
481
510
|
id: slug,
|
|
482
|
-
path: join(getComplianceCacheDir(options), "specialisms", slug),
|
|
483
511
|
adcp_version: index.adcp_version
|
|
484
|
-
});
|
|
512
|
+
}).map(cloneComplianceStoryboard);
|
|
485
513
|
const storyboard = bundleStoryboards.find((sb) => sb.category === entry.id.replace(/-/g, "_")) ?? bundleStoryboards[0];
|
|
486
514
|
if (!storyboard) {
|
|
487
515
|
throw new Error(
|
|
@@ -513,20 +541,21 @@ function listSpecialisms(options = {}) {
|
|
|
513
541
|
}
|
|
514
542
|
function resolveBundleOrStoryboard(id, options = {}) {
|
|
515
543
|
const bundle = findBundleById(id, options);
|
|
516
|
-
if (bundle) return
|
|
544
|
+
if (bundle) return scopedBundleStoryboards(complianceScope(options), bundle).map(cloneComplianceStoryboard);
|
|
517
545
|
const sb = getComplianceStoryboardById(id, options);
|
|
518
546
|
return sb ? [sb] : [];
|
|
519
547
|
}
|
|
520
548
|
function resolveStoryboardsForCapabilities(caps, options = {}) {
|
|
521
549
|
const index = loadComplianceIndex(options);
|
|
522
550
|
assertSupportedComplianceVersion(index.adcp_version, caps.supported_versions, options);
|
|
523
|
-
const
|
|
551
|
+
const scope = complianceScope(options);
|
|
552
|
+
const cacheDir = scope.dir;
|
|
524
553
|
const bundles = [];
|
|
525
554
|
const storyboards = [];
|
|
526
555
|
const notApplicable = [];
|
|
527
556
|
const seenStoryboards = /* @__PURE__ */ new Set();
|
|
528
557
|
const push = (ref) => {
|
|
529
|
-
const sbs =
|
|
558
|
+
const sbs = scopedBundleStoryboards(scope, ref).map(cloneComplianceStoryboard);
|
|
530
559
|
bundles.push({ ref, storyboards: sbs });
|
|
531
560
|
for (const sb of sbs) {
|
|
532
561
|
if (seenStoryboards.has(sb.id)) continue;
|
|
@@ -546,7 +575,7 @@ function resolveStoryboardsForCapabilities(caps, options = {}) {
|
|
|
546
575
|
}
|
|
547
576
|
};
|
|
548
577
|
for (const name of index.universal) {
|
|
549
|
-
if (
|
|
578
|
+
if (scopedUniversalMetadata(scope, name)) continue;
|
|
550
579
|
push({
|
|
551
580
|
kind: "universal",
|
|
552
581
|
id: name,
|
|
@@ -27,7 +27,7 @@ __export(loader_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(loader_exports);
|
|
29
29
|
var import_fs = require("fs");
|
|
30
|
-
var
|
|
30
|
+
var import_yaml_cache = require('./yaml-cache.js');
|
|
31
31
|
var import_idempotency = require('../../utils/idempotency.js');
|
|
32
32
|
var import_fixture_resolution = require('./fixture-resolution.js');
|
|
33
33
|
var import_creative_build_probe = require('./creative-build-probe.js');
|
|
@@ -47,7 +47,7 @@ function hasOfflineFormatDirective(value) {
|
|
|
47
47
|
return Object.values(object).some(hasOfflineFormatDirective);
|
|
48
48
|
}
|
|
49
49
|
function parseStoryboard(yamlContent) {
|
|
50
|
-
const parsed = (0,
|
|
50
|
+
const parsed = (0, import_yaml_cache.parseStoryboardYaml)(yamlContent);
|
|
51
51
|
if (!parsed?.id || !parsed?.phases) {
|
|
52
52
|
throw new Error("Invalid storyboard YAML: missing required fields (id, phases)");
|
|
53
53
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFileSync } from "fs";
|
|
2
|
-
import {
|
|
2
|
+
import { parseStoryboardYaml } from "./yaml-cache.mjs";
|
|
3
3
|
import { MUTATING_TASKS } from "../../utils/idempotency.mjs";
|
|
4
4
|
import { validateFixtureResolutionDeclarations } from "./fixture-resolution.mjs";
|
|
5
5
|
import { validateCreativeBuildProbeSpec } from "./creative-build-probe.mjs";
|
|
@@ -19,7 +19,7 @@ function hasOfflineFormatDirective(value) {
|
|
|
19
19
|
return Object.values(object).some(hasOfflineFormatDirective);
|
|
20
20
|
}
|
|
21
21
|
function parseStoryboard(yamlContent) {
|
|
22
|
-
const parsed =
|
|
22
|
+
const parsed = parseStoryboardYaml(yamlContent);
|
|
23
23
|
if (!parsed?.id || !parsed?.phases) {
|
|
24
24
|
throw new Error("Invalid storyboard YAML: missing required fields (id, phases)");
|
|
25
25
|
}
|
|
@@ -200,7 +200,7 @@ export interface UpstreamTrafficQueryResult {
|
|
|
200
200
|
*/
|
|
201
201
|
export declare function runValidations(validations: StoryboardValidation[], context: ValidationContext): ValidationResult[];
|
|
202
202
|
/** Capability semver emitted in run summaries and used for advisory expiry. */
|
|
203
|
-
export declare const RUNNER_CAPABILITY_VERSION = "17.0.0-beta.
|
|
203
|
+
export declare const RUNNER_CAPABILITY_VERSION = "17.0.0-beta.32";
|
|
204
204
|
/** True when a failed validation contributes to the owning step's grade. */
|
|
205
205
|
export declare function validationFailsStep(result: ValidationResult): boolean;
|
|
206
206
|
/**
|
|
@@ -200,7 +200,7 @@ export interface UpstreamTrafficQueryResult {
|
|
|
200
200
|
*/
|
|
201
201
|
export declare function runValidations(validations: StoryboardValidation[], context: ValidationContext): ValidationResult[];
|
|
202
202
|
/** Capability semver emitted in run summaries and used for advisory expiry. */
|
|
203
|
-
export declare const RUNNER_CAPABILITY_VERSION = "17.0.0-beta.
|
|
203
|
+
export declare const RUNNER_CAPABILITY_VERSION = "17.0.0-beta.32";
|
|
204
204
|
/** True when a failed validation contributes to the owning step's grade. */
|
|
205
205
|
export declare function validationFailsStep(result: ValidationResult): boolean;
|
|
206
206
|
/**
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storyboard YAML parsing, with an opt-in cross-process cache.
|
|
3
|
+
*
|
|
4
|
+
* Every storyboard and discovery process parses the same compliance YAML. With
|
|
5
|
+
* `ADCP_VALIDATOR_CACHE_DIR` set to an absolute directory, the parsed document
|
|
6
|
+
* is stored there as a JSON data entry (see validation/validator-cache) and the
|
|
7
|
+
* next process reads it back instead of parsing. The entry key digests the
|
|
8
|
+
* document text, this module's code, the `yaml` package version and the SDK
|
|
9
|
+
* version, so a changed file or parser is a miss and an entry cannot go stale.
|
|
10
|
+
*
|
|
11
|
+
* Only clean parses are stored: a document with YAML errors or warnings goes
|
|
12
|
+
* through `parse` every time, so it throws or warns exactly as before. A value
|
|
13
|
+
* is stored only when it survives the JSON round trip unchanged; objects that
|
|
14
|
+
* YAML aliases share are recorded and shared again on read. Each call returns
|
|
15
|
+
* new objects. With the variable unset, empty or relative, this is `parse`.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Parse a storyboard YAML document: the result of `yaml`'s `parse(source)`,
|
|
19
|
+
* read from the opt-in cache when an earlier process stored it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseStoryboardYaml(source: string): unknown;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storyboard YAML parsing, with an opt-in cross-process cache.
|
|
3
|
+
*
|
|
4
|
+
* Every storyboard and discovery process parses the same compliance YAML. With
|
|
5
|
+
* `ADCP_VALIDATOR_CACHE_DIR` set to an absolute directory, the parsed document
|
|
6
|
+
* is stored there as a JSON data entry (see validation/validator-cache) and the
|
|
7
|
+
* next process reads it back instead of parsing. The entry key digests the
|
|
8
|
+
* document text, this module's code, the `yaml` package version and the SDK
|
|
9
|
+
* version, so a changed file or parser is a miss and an entry cannot go stale.
|
|
10
|
+
*
|
|
11
|
+
* Only clean parses are stored: a document with YAML errors or warnings goes
|
|
12
|
+
* through `parse` every time, so it throws or warns exactly as before. A value
|
|
13
|
+
* is stored only when it survives the JSON round trip unchanged; objects that
|
|
14
|
+
* YAML aliases share are recorded and shared again on read. Each call returns
|
|
15
|
+
* new objects. With the variable unset, empty or relative, this is `parse`.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Parse a storyboard YAML document: the result of `yaml`'s `parse(source)`,
|
|
19
|
+
* read from the opt-in cache when an earlier process stored it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseStoryboardYaml(source: string): unknown;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var yaml_cache_exports = {};
|
|
30
|
+
__export(yaml_cache_exports, {
|
|
31
|
+
parseStoryboardYaml: () => parseStoryboardYaml
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(yaml_cache_exports);
|
|
34
|
+
var import_node_crypto = require("node:crypto");
|
|
35
|
+
var import_node_module = require("node:module");
|
|
36
|
+
var import_node_path = __toESM(require("node:path"));
|
|
37
|
+
var import_node_util = require("node:util");
|
|
38
|
+
var import_yaml = require("yaml");
|
|
39
|
+
var import_version = require('../../version.js');
|
|
40
|
+
const ENTRY_KIND = "storyboard-yaml";
|
|
41
|
+
function cacheDir() {
|
|
42
|
+
const dir = process.env.ADCP_VALIDATOR_CACHE_DIR;
|
|
43
|
+
return dir && import_node_path.default.isAbsolute(dir) ? dir : void 0;
|
|
44
|
+
}
|
|
45
|
+
let opened;
|
|
46
|
+
let staticKey;
|
|
47
|
+
function openCache(dir) {
|
|
48
|
+
if (opened?.dir !== dir) {
|
|
49
|
+
const { openValidatorCache } = (
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
51
|
+
require('../../validation/validator-cache.js')
|
|
52
|
+
);
|
|
53
|
+
opened = { dir, cache: openValidatorCache(dir, import_node_path.default.join(__dirname, "yaml-cache.js")) };
|
|
54
|
+
}
|
|
55
|
+
return opened.cache;
|
|
56
|
+
}
|
|
57
|
+
function parserKey() {
|
|
58
|
+
if (staticKey) return staticKey;
|
|
59
|
+
const { filesDigest } = (
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
61
|
+
require('../../validation/validator-cache.js')
|
|
62
|
+
);
|
|
63
|
+
let yamlVersion = null;
|
|
64
|
+
try {
|
|
65
|
+
const moduleRequire = (0, import_node_module.createRequire)(import_node_path.default.join(__dirname, "yaml-cache.js"));
|
|
66
|
+
yamlVersion = moduleRequire("yaml/package.json").version ?? null;
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
staticKey = [
|
|
70
|
+
import_version.LIBRARY_VERSION,
|
|
71
|
+
filesDigest(["yaml-cache.js", "yaml-cache.mjs"].map((file) => import_node_path.default.join(__dirname, file))),
|
|
72
|
+
yamlVersion
|
|
73
|
+
];
|
|
74
|
+
return staticKey;
|
|
75
|
+
}
|
|
76
|
+
function sharedObjects(root) {
|
|
77
|
+
const firstPath = /* @__PURE__ */ new Map();
|
|
78
|
+
const shared = [];
|
|
79
|
+
const visit = (value, at) => {
|
|
80
|
+
if (value === null || typeof value !== "object") return;
|
|
81
|
+
const first = firstPath.get(value);
|
|
82
|
+
if (first) {
|
|
83
|
+
shared.push([at, first]);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
firstPath.set(value, at);
|
|
87
|
+
if (Array.isArray(value)) value.forEach((item, index) => visit(item, [...at, index]));
|
|
88
|
+
else for (const [key, item] of Object.entries(value)) visit(item, [...at, key]);
|
|
89
|
+
};
|
|
90
|
+
visit(root, []);
|
|
91
|
+
return shared;
|
|
92
|
+
}
|
|
93
|
+
function withoutRepeats(root, shared) {
|
|
94
|
+
if (shared.length === 0) return root;
|
|
95
|
+
const repeats = new Set(shared.map(([at]) => JSON.stringify(at)));
|
|
96
|
+
const copy = (value, at) => {
|
|
97
|
+
if (repeats.has(JSON.stringify(at))) return null;
|
|
98
|
+
if (value === null || typeof value !== "object") return value;
|
|
99
|
+
if (Array.isArray(value)) return value.map((item, index) => copy(item, [...at, index]));
|
|
100
|
+
const out = {};
|
|
101
|
+
for (const [key, item] of Object.entries(value)) out[key] = copy(item, [...at, key]);
|
|
102
|
+
return out;
|
|
103
|
+
};
|
|
104
|
+
return copy(root, []);
|
|
105
|
+
}
|
|
106
|
+
function valueAt(root, at) {
|
|
107
|
+
let value = root;
|
|
108
|
+
for (const segment of at) value = value[segment];
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
function restore(stored) {
|
|
112
|
+
const value = stored.value;
|
|
113
|
+
for (const [at, first] of stored.shared) {
|
|
114
|
+
const parent = valueAt(value, at.slice(0, -1));
|
|
115
|
+
parent[at[at.length - 1]] = valueAt(value, first);
|
|
116
|
+
}
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
function isStoredDocument(value) {
|
|
120
|
+
return value !== null && typeof value === "object" && Object.hasOwn(value, "value") && Array.isArray(value.shared);
|
|
121
|
+
}
|
|
122
|
+
function storable(document) {
|
|
123
|
+
const shared = sharedObjects(document);
|
|
124
|
+
let json;
|
|
125
|
+
try {
|
|
126
|
+
json = JSON.stringify({ value: withoutRepeats(document, shared), shared });
|
|
127
|
+
} catch {
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
if (json === void 0) return void 0;
|
|
131
|
+
const stored = JSON.parse(json);
|
|
132
|
+
const restored = restore(JSON.parse(json));
|
|
133
|
+
if (!(0, import_node_util.isDeepStrictEqual)(restored, document)) return void 0;
|
|
134
|
+
if (!(0, import_node_util.isDeepStrictEqual)(sharedObjects(restored), shared)) return void 0;
|
|
135
|
+
return stored;
|
|
136
|
+
}
|
|
137
|
+
function parseStoryboardYaml(source) {
|
|
138
|
+
const dir = cacheDir();
|
|
139
|
+
if (dir === void 0) return (0, import_yaml.parse)(source);
|
|
140
|
+
const cache = openCache(dir);
|
|
141
|
+
if (!cache) return (0, import_yaml.parse)(source);
|
|
142
|
+
const { validatorCacheKey } = (
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
144
|
+
require('../../validation/validator-cache.js')
|
|
145
|
+
);
|
|
146
|
+
const key = validatorCacheKey([
|
|
147
|
+
ENTRY_KIND,
|
|
148
|
+
...parserKey(),
|
|
149
|
+
(0, import_node_crypto.createHash)("sha256").update(source, "utf8").digest("hex")
|
|
150
|
+
]);
|
|
151
|
+
const hit = cache.readData(key);
|
|
152
|
+
if (isStoredDocument(hit)) {
|
|
153
|
+
try {
|
|
154
|
+
return restore(hit);
|
|
155
|
+
} catch {
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const doc = (0, import_yaml.parseDocument)(source);
|
|
159
|
+
if (doc.errors.length > 0 || doc.warnings.length > 0) return (0, import_yaml.parse)(source);
|
|
160
|
+
const document = doc.toJS();
|
|
161
|
+
const stored = storable(document);
|
|
162
|
+
if (stored) cache.writeData(key, stored);
|
|
163
|
+
return document;
|
|
164
|
+
}
|
|
165
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
166
|
+
0 && (module.exports = {
|
|
167
|
+
parseStoryboardYaml
|
|
168
|
+
});
|