@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
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { fileURLToPath as __adcpFileURLToPath } from "node:url";
|
|
2
|
+
import { dirname as __adcpDirname } from "node:path";
|
|
3
|
+
import { createRequire as __adcpCreateRequire } from "node:module";
|
|
4
|
+
const __dirname = __adcpDirname(__adcpFileURLToPath(import.meta.url));
|
|
5
|
+
const require2 = __adcpCreateRequire(import.meta.url);
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { isDeepStrictEqual } from "node:util";
|
|
10
|
+
import { parse, parseDocument } from "yaml";
|
|
11
|
+
import { LIBRARY_VERSION } from "../../version.mjs";
|
|
12
|
+
const ENTRY_KIND = "storyboard-yaml";
|
|
13
|
+
function cacheDir() {
|
|
14
|
+
const dir = process.env.ADCP_VALIDATOR_CACHE_DIR;
|
|
15
|
+
return dir && path.isAbsolute(dir) ? dir : void 0;
|
|
16
|
+
}
|
|
17
|
+
let opened;
|
|
18
|
+
let staticKey;
|
|
19
|
+
function openCache(dir) {
|
|
20
|
+
if (opened?.dir !== dir) {
|
|
21
|
+
const { openValidatorCache } = (
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
23
|
+
require2("../../validation/validator-cache")
|
|
24
|
+
);
|
|
25
|
+
opened = { dir, cache: openValidatorCache(dir, path.join(__dirname, "yaml-cache.js")) };
|
|
26
|
+
}
|
|
27
|
+
return opened.cache;
|
|
28
|
+
}
|
|
29
|
+
function parserKey() {
|
|
30
|
+
if (staticKey) return staticKey;
|
|
31
|
+
const { filesDigest } = (
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
33
|
+
require2("../../validation/validator-cache")
|
|
34
|
+
);
|
|
35
|
+
let yamlVersion = null;
|
|
36
|
+
try {
|
|
37
|
+
const moduleRequire = createRequire(path.join(__dirname, "yaml-cache.js"));
|
|
38
|
+
yamlVersion = moduleRequire("yaml/package.json").version ?? null;
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
staticKey = [
|
|
42
|
+
LIBRARY_VERSION,
|
|
43
|
+
filesDigest(["yaml-cache.js", "yaml-cache.mjs"].map((file) => path.join(__dirname, file))),
|
|
44
|
+
yamlVersion
|
|
45
|
+
];
|
|
46
|
+
return staticKey;
|
|
47
|
+
}
|
|
48
|
+
function sharedObjects(root) {
|
|
49
|
+
const firstPath = /* @__PURE__ */ new Map();
|
|
50
|
+
const shared = [];
|
|
51
|
+
const visit = (value, at) => {
|
|
52
|
+
if (value === null || typeof value !== "object") return;
|
|
53
|
+
const first = firstPath.get(value);
|
|
54
|
+
if (first) {
|
|
55
|
+
shared.push([at, first]);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
firstPath.set(value, at);
|
|
59
|
+
if (Array.isArray(value)) value.forEach((item, index) => visit(item, [...at, index]));
|
|
60
|
+
else for (const [key, item] of Object.entries(value)) visit(item, [...at, key]);
|
|
61
|
+
};
|
|
62
|
+
visit(root, []);
|
|
63
|
+
return shared;
|
|
64
|
+
}
|
|
65
|
+
function withoutRepeats(root, shared) {
|
|
66
|
+
if (shared.length === 0) return root;
|
|
67
|
+
const repeats = new Set(shared.map(([at]) => JSON.stringify(at)));
|
|
68
|
+
const copy = (value, at) => {
|
|
69
|
+
if (repeats.has(JSON.stringify(at))) return null;
|
|
70
|
+
if (value === null || typeof value !== "object") return value;
|
|
71
|
+
if (Array.isArray(value)) return value.map((item, index) => copy(item, [...at, index]));
|
|
72
|
+
const out = {};
|
|
73
|
+
for (const [key, item] of Object.entries(value)) out[key] = copy(item, [...at, key]);
|
|
74
|
+
return out;
|
|
75
|
+
};
|
|
76
|
+
return copy(root, []);
|
|
77
|
+
}
|
|
78
|
+
function valueAt(root, at) {
|
|
79
|
+
let value = root;
|
|
80
|
+
for (const segment of at) value = value[segment];
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
function restore(stored) {
|
|
84
|
+
const value = stored.value;
|
|
85
|
+
for (const [at, first] of stored.shared) {
|
|
86
|
+
const parent = valueAt(value, at.slice(0, -1));
|
|
87
|
+
parent[at[at.length - 1]] = valueAt(value, first);
|
|
88
|
+
}
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
function isStoredDocument(value) {
|
|
92
|
+
return value !== null && typeof value === "object" && Object.hasOwn(value, "value") && Array.isArray(value.shared);
|
|
93
|
+
}
|
|
94
|
+
function storable(document) {
|
|
95
|
+
const shared = sharedObjects(document);
|
|
96
|
+
let json;
|
|
97
|
+
try {
|
|
98
|
+
json = JSON.stringify({ value: withoutRepeats(document, shared), shared });
|
|
99
|
+
} catch {
|
|
100
|
+
return void 0;
|
|
101
|
+
}
|
|
102
|
+
if (json === void 0) return void 0;
|
|
103
|
+
const stored = JSON.parse(json);
|
|
104
|
+
const restored = restore(JSON.parse(json));
|
|
105
|
+
if (!isDeepStrictEqual(restored, document)) return void 0;
|
|
106
|
+
if (!isDeepStrictEqual(sharedObjects(restored), shared)) return void 0;
|
|
107
|
+
return stored;
|
|
108
|
+
}
|
|
109
|
+
function parseStoryboardYaml(source) {
|
|
110
|
+
const dir = cacheDir();
|
|
111
|
+
if (dir === void 0) return parse(source);
|
|
112
|
+
const cache = openCache(dir);
|
|
113
|
+
if (!cache) return parse(source);
|
|
114
|
+
const { validatorCacheKey } = (
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
116
|
+
require2("../../validation/validator-cache")
|
|
117
|
+
);
|
|
118
|
+
const key = validatorCacheKey([
|
|
119
|
+
ENTRY_KIND,
|
|
120
|
+
...parserKey(),
|
|
121
|
+
createHash("sha256").update(source, "utf8").digest("hex")
|
|
122
|
+
]);
|
|
123
|
+
const hit = cache.readData(key);
|
|
124
|
+
if (isStoredDocument(hit)) {
|
|
125
|
+
try {
|
|
126
|
+
return restore(hit);
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const doc = parseDocument(source);
|
|
131
|
+
if (doc.errors.length > 0 || doc.warnings.length > 0) return parse(source);
|
|
132
|
+
const document = doc.toJS();
|
|
133
|
+
const stored = storable(document);
|
|
134
|
+
if (stored) cache.writeData(key, stored);
|
|
135
|
+
return document;
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
parseStoryboardYaml
|
|
139
|
+
};
|
|
@@ -24,56 +24,86 @@ module.exports = __toCommonJS(schema_diagnostic_origins_exports);
|
|
|
24
24
|
function object(value) {
|
|
25
25
|
return value !== null && typeof value === "object";
|
|
26
26
|
}
|
|
27
|
+
function isWhitespace(code) {
|
|
28
|
+
return code === 32 || code >= 9 && code <= 13 || code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288 || code === 65279;
|
|
29
|
+
}
|
|
30
|
+
function isIdentifierStart(code) {
|
|
31
|
+
return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code === 95 || code === 36;
|
|
32
|
+
}
|
|
33
|
+
function isIdentifierPart(code) {
|
|
34
|
+
return isIdentifierStart(code) || code >= 48 && code <= 57;
|
|
35
|
+
}
|
|
27
36
|
function schemaPathLiterals(source) {
|
|
28
37
|
const paths = [];
|
|
38
|
+
const length = source.length;
|
|
29
39
|
const stringEnd = (start) => {
|
|
30
|
-
const quote = source
|
|
31
|
-
for (let index = start + 1; index <
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
const quote = source.charCodeAt(start);
|
|
41
|
+
for (let index = start + 1; index < length; index++) {
|
|
42
|
+
const code = source.charCodeAt(index);
|
|
43
|
+
if (code === 92) index++;
|
|
44
|
+
else if (code === quote) return index + 1;
|
|
34
45
|
}
|
|
35
46
|
return -1;
|
|
36
47
|
};
|
|
37
|
-
|
|
48
|
+
const followsReplaceCall = (end) => {
|
|
49
|
+
let cursor = end - 1;
|
|
50
|
+
while (cursor >= 0 && isWhitespace(source.charCodeAt(cursor))) cursor--;
|
|
51
|
+
return cursor >= 8 && source.startsWith(".replace(", cursor - 8);
|
|
52
|
+
};
|
|
53
|
+
const followsDataVariable = (end) => {
|
|
54
|
+
let cursor = end - 1;
|
|
55
|
+
while (cursor >= 0 && isWhitespace(source.charCodeAt(cursor))) cursor--;
|
|
56
|
+
while (cursor >= 0 && source.charCodeAt(cursor) >= 48 && source.charCodeAt(cursor) <= 57) cursor--;
|
|
57
|
+
if (cursor < 3 || !source.startsWith("data", cursor - 3)) return false;
|
|
58
|
+
return cursor === 3 || !isIdentifierPart(source.charCodeAt(cursor - 4));
|
|
59
|
+
};
|
|
60
|
+
for (let index = 0; index < length; ) {
|
|
38
61
|
const start = index;
|
|
39
|
-
|
|
40
|
-
|
|
62
|
+
const code = source.charCodeAt(index);
|
|
63
|
+
let isSchemaPathKey = false;
|
|
64
|
+
if (code === 34 || code === 39) {
|
|
41
65
|
index = stringEnd(index);
|
|
42
66
|
if (index < 0) return void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
67
|
+
if (code === 34) {
|
|
68
|
+
const literal = source.slice(start, index);
|
|
69
|
+
if (literal === '"schemaPath"') isSchemaPathKey = true;
|
|
70
|
+
else if (literal.includes("\\")) {
|
|
71
|
+
try {
|
|
72
|
+
isSchemaPathKey = JSON.parse(literal) === "schemaPath";
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
46
76
|
}
|
|
47
|
-
} else if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
77
|
+
} else if (isIdentifierStart(code)) {
|
|
78
|
+
index++;
|
|
79
|
+
while (index < length && isIdentifierPart(source.charCodeAt(index))) index++;
|
|
80
|
+
isSchemaPathKey = index - start === 10 && source.startsWith("schemaPath", start);
|
|
81
|
+
} else if (code === 47 && source.charCodeAt(index + 1) === 47) {
|
|
51
82
|
index = source.indexOf("\n", index + 2);
|
|
52
83
|
if (index < 0) break;
|
|
53
|
-
} else if (source.
|
|
84
|
+
} else if (code === 47 && source.charCodeAt(index + 1) === 42) {
|
|
54
85
|
index = source.indexOf("*/", index + 2);
|
|
55
86
|
if (index < 0) return void 0;
|
|
56
87
|
index += 2;
|
|
57
88
|
} else {
|
|
58
|
-
if (
|
|
59
|
-
if (
|
|
89
|
+
if (code === 96) return void 0;
|
|
90
|
+
if (code === 47) {
|
|
60
91
|
const pointerEscape = source.startsWith("/~/g", index) ? "/~/g" : source.startsWith("/\\//g", index) ? "/\\//g" : void 0;
|
|
61
|
-
if (pointerEscape &&
|
|
92
|
+
if (pointerEscape && followsReplaceCall(index)) {
|
|
62
93
|
index += pointerEscape.length;
|
|
63
94
|
continue;
|
|
64
95
|
}
|
|
65
|
-
|
|
66
|
-
if (!previous) return void 0;
|
|
96
|
+
if (!followsDataVariable(index)) return void 0;
|
|
67
97
|
}
|
|
68
98
|
index++;
|
|
69
99
|
}
|
|
70
|
-
if (
|
|
100
|
+
if (!isSchemaPathKey) continue;
|
|
71
101
|
let valueStart = index;
|
|
72
|
-
while (
|
|
73
|
-
if (source
|
|
102
|
+
while (valueStart < length && isWhitespace(source.charCodeAt(valueStart))) valueStart++;
|
|
103
|
+
if (source.charCodeAt(valueStart) !== 58) continue;
|
|
74
104
|
valueStart++;
|
|
75
|
-
while (
|
|
76
|
-
if (source
|
|
105
|
+
while (valueStart < length && isWhitespace(source.charCodeAt(valueStart))) valueStart++;
|
|
106
|
+
if (source.charCodeAt(valueStart) !== 34) return void 0;
|
|
77
107
|
const end = stringEnd(valueStart);
|
|
78
108
|
if (end < 0) return void 0;
|
|
79
109
|
let value;
|
|
@@ -1,56 +1,86 @@
|
|
|
1
1
|
function object(value) {
|
|
2
2
|
return value !== null && typeof value === "object";
|
|
3
3
|
}
|
|
4
|
+
function isWhitespace(code) {
|
|
5
|
+
return code === 32 || code >= 9 && code <= 13 || code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288 || code === 65279;
|
|
6
|
+
}
|
|
7
|
+
function isIdentifierStart(code) {
|
|
8
|
+
return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code === 95 || code === 36;
|
|
9
|
+
}
|
|
10
|
+
function isIdentifierPart(code) {
|
|
11
|
+
return isIdentifierStart(code) || code >= 48 && code <= 57;
|
|
12
|
+
}
|
|
4
13
|
function schemaPathLiterals(source) {
|
|
5
14
|
const paths = [];
|
|
15
|
+
const length = source.length;
|
|
6
16
|
const stringEnd = (start) => {
|
|
7
|
-
const quote = source
|
|
8
|
-
for (let index = start + 1; index <
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
const quote = source.charCodeAt(start);
|
|
18
|
+
for (let index = start + 1; index < length; index++) {
|
|
19
|
+
const code = source.charCodeAt(index);
|
|
20
|
+
if (code === 92) index++;
|
|
21
|
+
else if (code === quote) return index + 1;
|
|
11
22
|
}
|
|
12
23
|
return -1;
|
|
13
24
|
};
|
|
14
|
-
|
|
25
|
+
const followsReplaceCall = (end) => {
|
|
26
|
+
let cursor = end - 1;
|
|
27
|
+
while (cursor >= 0 && isWhitespace(source.charCodeAt(cursor))) cursor--;
|
|
28
|
+
return cursor >= 8 && source.startsWith(".replace(", cursor - 8);
|
|
29
|
+
};
|
|
30
|
+
const followsDataVariable = (end) => {
|
|
31
|
+
let cursor = end - 1;
|
|
32
|
+
while (cursor >= 0 && isWhitespace(source.charCodeAt(cursor))) cursor--;
|
|
33
|
+
while (cursor >= 0 && source.charCodeAt(cursor) >= 48 && source.charCodeAt(cursor) <= 57) cursor--;
|
|
34
|
+
if (cursor < 3 || !source.startsWith("data", cursor - 3)) return false;
|
|
35
|
+
return cursor === 3 || !isIdentifierPart(source.charCodeAt(cursor - 4));
|
|
36
|
+
};
|
|
37
|
+
for (let index = 0; index < length; ) {
|
|
15
38
|
const start = index;
|
|
16
|
-
|
|
17
|
-
|
|
39
|
+
const code = source.charCodeAt(index);
|
|
40
|
+
let isSchemaPathKey = false;
|
|
41
|
+
if (code === 34 || code === 39) {
|
|
18
42
|
index = stringEnd(index);
|
|
19
43
|
if (index < 0) return void 0;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
44
|
+
if (code === 34) {
|
|
45
|
+
const literal = source.slice(start, index);
|
|
46
|
+
if (literal === '"schemaPath"') isSchemaPathKey = true;
|
|
47
|
+
else if (literal.includes("\\")) {
|
|
48
|
+
try {
|
|
49
|
+
isSchemaPathKey = JSON.parse(literal) === "schemaPath";
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
}
|
|
23
53
|
}
|
|
24
|
-
} else if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
54
|
+
} else if (isIdentifierStart(code)) {
|
|
55
|
+
index++;
|
|
56
|
+
while (index < length && isIdentifierPart(source.charCodeAt(index))) index++;
|
|
57
|
+
isSchemaPathKey = index - start === 10 && source.startsWith("schemaPath", start);
|
|
58
|
+
} else if (code === 47 && source.charCodeAt(index + 1) === 47) {
|
|
28
59
|
index = source.indexOf("\n", index + 2);
|
|
29
60
|
if (index < 0) break;
|
|
30
|
-
} else if (source.
|
|
61
|
+
} else if (code === 47 && source.charCodeAt(index + 1) === 42) {
|
|
31
62
|
index = source.indexOf("*/", index + 2);
|
|
32
63
|
if (index < 0) return void 0;
|
|
33
64
|
index += 2;
|
|
34
65
|
} else {
|
|
35
|
-
if (
|
|
36
|
-
if (
|
|
66
|
+
if (code === 96) return void 0;
|
|
67
|
+
if (code === 47) {
|
|
37
68
|
const pointerEscape = source.startsWith("/~/g", index) ? "/~/g" : source.startsWith("/\\//g", index) ? "/\\//g" : void 0;
|
|
38
|
-
if (pointerEscape &&
|
|
69
|
+
if (pointerEscape && followsReplaceCall(index)) {
|
|
39
70
|
index += pointerEscape.length;
|
|
40
71
|
continue;
|
|
41
72
|
}
|
|
42
|
-
|
|
43
|
-
if (!previous) return void 0;
|
|
73
|
+
if (!followsDataVariable(index)) return void 0;
|
|
44
74
|
}
|
|
45
75
|
index++;
|
|
46
76
|
}
|
|
47
|
-
if (
|
|
77
|
+
if (!isSchemaPathKey) continue;
|
|
48
78
|
let valueStart = index;
|
|
49
|
-
while (
|
|
50
|
-
if (source
|
|
79
|
+
while (valueStart < length && isWhitespace(source.charCodeAt(valueStart))) valueStart++;
|
|
80
|
+
if (source.charCodeAt(valueStart) !== 58) continue;
|
|
51
81
|
valueStart++;
|
|
52
|
-
while (
|
|
53
|
-
if (source
|
|
82
|
+
while (valueStart < length && isWhitespace(source.charCodeAt(valueStart))) valueStart++;
|
|
83
|
+
if (source.charCodeAt(valueStart) !== 34) return void 0;
|
|
54
84
|
const end = stringEnd(valueStart);
|
|
55
85
|
if (end < 0) return void 0;
|
|
56
86
|
let value;
|