@adcp/sdk 17.0.0-beta.30 → 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/context.js +14 -10
- package/dist/lib/testing/storyboard/context.mjs +14 -10
- 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
|
@@ -47,11 +47,17 @@ var import_etld = require('../signing/agent-resolver/etld.js');
|
|
|
47
47
|
var import_strict_json = require('../signing/agent-resolver/strict-json.js');
|
|
48
48
|
var import_tldts = require("tldts");
|
|
49
49
|
var import_schemas = __toESM(require('./schemas.draft.js'));
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
let identityAjv;
|
|
51
|
+
function identitySchemas() {
|
|
52
|
+
if (identityAjv) return identityAjv;
|
|
53
|
+
const ajv = new import_ajv.default({ inlineRefs: false, strict: false, allErrors: false });
|
|
54
|
+
(0, import_ajv_formats.default)(ajv);
|
|
55
|
+
for (const schema of import_schemas.default) ajv.addSchema(schema);
|
|
56
|
+
identityAjv = ajv;
|
|
57
|
+
return ajv;
|
|
58
|
+
}
|
|
53
59
|
function validateIdentity33Schema(id, value) {
|
|
54
|
-
return
|
|
60
|
+
return identitySchemas().getSchema(`/schemas/${id}.json`)?.(value) === true;
|
|
55
61
|
}
|
|
56
62
|
class IdentityAuthorizationError extends Error {
|
|
57
63
|
code = "PERMISSION_DENIED";
|
|
@@ -6,11 +6,17 @@ import { eTldPlusOne } from "../signing/agent-resolver/etld.mjs";
|
|
|
6
6
|
import { parseStrictJson } from "../signing/agent-resolver/strict-json.mjs";
|
|
7
7
|
import { parse as parseDomain } from "tldts";
|
|
8
8
|
import schemas from "./schemas.draft.mjs";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
let identityAjv;
|
|
10
|
+
function identitySchemas() {
|
|
11
|
+
if (identityAjv) return identityAjv;
|
|
12
|
+
const ajv = new Ajv({ inlineRefs: false, strict: false, allErrors: false });
|
|
13
|
+
addFormats(ajv);
|
|
14
|
+
for (const schema of schemas) ajv.addSchema(schema);
|
|
15
|
+
identityAjv = ajv;
|
|
16
|
+
return ajv;
|
|
17
|
+
}
|
|
12
18
|
function validateIdentity33Schema(id, value) {
|
|
13
|
-
return
|
|
19
|
+
return identitySchemas().getSchema(`/schemas/${id}.json`)?.(value) === true;
|
|
14
20
|
}
|
|
15
21
|
class IdentityAuthorizationError extends Error {
|
|
16
22
|
code = "PERMISSION_DENIED";
|
|
@@ -1326,15 +1326,16 @@ function projectPayloadErrorToEnvelope(payloadError) {
|
|
|
1326
1326
|
}
|
|
1327
1327
|
return out;
|
|
1328
1328
|
}
|
|
1329
|
-
function enrichErrorTwoLayer(response, toolName,
|
|
1330
|
-
const descriptor = toolsWithErrorArm.get(toolName);
|
|
1331
|
-
if (!descriptor) return;
|
|
1329
|
+
function enrichErrorTwoLayer(response, toolName, version) {
|
|
1332
1330
|
const sc = response.structuredContent;
|
|
1333
1331
|
if (!sc || typeof sc !== "object") return;
|
|
1334
1332
|
const env = sc.adcp_error;
|
|
1335
1333
|
const envValid = env != null && typeof env === "object" && typeof env.code === "string";
|
|
1336
1334
|
const payloadList = sc.errors;
|
|
1337
1335
|
const payloadValid = Array.isArray(payloadList) && payloadList.length > 0;
|
|
1336
|
+
if (!envValid && !payloadValid) return;
|
|
1337
|
+
const descriptor = (0, import_error_arm_tools.getErrorArmDescriptor)(toolName, version);
|
|
1338
|
+
if (!descriptor) return;
|
|
1338
1339
|
const mirrorsBeforePayloadSanitization = contentTextMirrorsStructuredContent(response, sc);
|
|
1339
1340
|
if (payloadValid && sanitizePayloadErrors(sc)) {
|
|
1340
1341
|
syncContentJsonText(response, sc, mirrorsBeforePayloadSanitization);
|
|
@@ -2226,7 +2227,6 @@ function createAdcpServer(config) {
|
|
|
2226
2227
|
if (config.webhooks?.webBotAuth && !config.identity33)
|
|
2227
2228
|
throw new Error("Web Bot Auth webhook signing requires the identity33 experiment");
|
|
2228
2229
|
if (config.webhooks?.webBotAuth?.key) (0, import_web_bot_auth.assertWebBotAuthSigningKey)(config.webhooks.webBotAuth.key);
|
|
2229
|
-
const toolsWithErrorArm = (0, import_error_arm_tools.getToolsWithErrorArm)(adcpVersion);
|
|
2230
2230
|
const isProduction = process.env.NODE_ENV === "production";
|
|
2231
2231
|
const requestValidationMode = validationConfig?.requests ?? (isProduction ? "off" : "strict");
|
|
2232
2232
|
const responseValidationMode = validationConfig?.responses ?? (isProduction ? "off" : "strict");
|
|
@@ -2488,7 +2488,7 @@ function createAdcpServer(config) {
|
|
|
2488
2488
|
const releaseDefinesTool = (toolName, release) => {
|
|
2489
2489
|
if (toolName === "refine_proposals") return true;
|
|
2490
2490
|
try {
|
|
2491
|
-
return (0, import_schema_loader2.
|
|
2491
|
+
return (0, import_schema_loader2.definesToolRequest)(toolName, release.validationVersion);
|
|
2492
2492
|
} catch {
|
|
2493
2493
|
return false;
|
|
2494
2494
|
}
|
|
@@ -2499,7 +2499,7 @@ function createAdcpServer(config) {
|
|
|
2499
2499
|
...servedAdcpVersion !== void 0 && { wireVersion: servedAdcpVersion }
|
|
2500
2500
|
};
|
|
2501
2501
|
sanitizeAdcpErrorEnvelope(response);
|
|
2502
|
-
enrichErrorTwoLayer(response, toolName,
|
|
2502
|
+
enrichErrorTwoLayer(response, toolName, release.validationVersion);
|
|
2503
2503
|
if (!isErrorResponse(response)) {
|
|
2504
2504
|
response = downgradeTaskStatusResult(toolName, response, release.validationVersion);
|
|
2505
2505
|
normalizeMediaBuyStatusCollision(response, toolName, release.validationVersion);
|
|
@@ -2860,7 +2860,6 @@ function createAdcpServer(config) {
|
|
|
2860
2860
|
} else {
|
|
2861
2861
|
requestRelease = releaseSelection;
|
|
2862
2862
|
}
|
|
2863
|
-
const requestErrorArms = (0, import_error_arm_tools.getToolsWithErrorArm)(requestRelease.validationVersion);
|
|
2864
2863
|
const translatesRelease = toolName !== "get_adcp_capabilities" && (0, import_version.translationSteps)(adcpVersion, requestRelease.validationVersion).length > 0;
|
|
2865
2864
|
const ctx = withImmutableServedAdcpVersion(
|
|
2866
2865
|
{
|
|
@@ -2881,7 +2880,7 @@ function createAdcpServer(config) {
|
|
|
2881
2880
|
}
|
|
2882
2881
|
const finalizeProtocolEnvelope = (response) => {
|
|
2883
2882
|
sanitizeAdcpErrorEnvelope(response);
|
|
2884
|
-
enrichErrorTwoLayer(response, toolName,
|
|
2883
|
+
enrichErrorTwoLayer(response, toolName, requestRelease.validationVersion);
|
|
2885
2884
|
normalizeMediaBuyStatusCollision(response, toolName, requestRelease.validationVersion);
|
|
2886
2885
|
injectEnvelopeStatusIntoResponse(response, toolName, requestRelease.validationVersion);
|
|
2887
2886
|
injectContextIntoResponse(response, params.context);
|
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
} from "../media-buy/creative-start-policy.mjs";
|
|
57
57
|
import { ConfigurationError } from "../errors/index.mjs";
|
|
58
58
|
import {
|
|
59
|
-
|
|
59
|
+
definesToolRequest,
|
|
60
60
|
getToolSchemaDocument,
|
|
61
61
|
hasSchemaBundle,
|
|
62
62
|
resolveBundleKey,
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
import { TOOL_INPUT_SHAPES } from "../schemas/index.mjs";
|
|
66
66
|
import { TaskTypeValues } from "../types/enums.generated.mjs";
|
|
67
67
|
import { bundleSupportsAdcpVersionField } from "../protocols/index.mjs";
|
|
68
|
-
import {
|
|
68
|
+
import { getErrorArmDescriptor } from "./error-arm-tools.mjs";
|
|
69
69
|
import { applyStructuredContentTextFallback } from "./structured-content-fallback.mjs";
|
|
70
70
|
import {
|
|
71
71
|
ADCP_CAPABILITIES,
|
|
@@ -1441,15 +1441,16 @@ function projectPayloadErrorToEnvelope(payloadError) {
|
|
|
1441
1441
|
}
|
|
1442
1442
|
return out;
|
|
1443
1443
|
}
|
|
1444
|
-
function enrichErrorTwoLayer(response, toolName,
|
|
1445
|
-
const descriptor = toolsWithErrorArm.get(toolName);
|
|
1446
|
-
if (!descriptor) return;
|
|
1444
|
+
function enrichErrorTwoLayer(response, toolName, version) {
|
|
1447
1445
|
const sc = response.structuredContent;
|
|
1448
1446
|
if (!sc || typeof sc !== "object") return;
|
|
1449
1447
|
const env = sc.adcp_error;
|
|
1450
1448
|
const envValid = env != null && typeof env === "object" && typeof env.code === "string";
|
|
1451
1449
|
const payloadList = sc.errors;
|
|
1452
1450
|
const payloadValid = Array.isArray(payloadList) && payloadList.length > 0;
|
|
1451
|
+
if (!envValid && !payloadValid) return;
|
|
1452
|
+
const descriptor = getErrorArmDescriptor(toolName, version);
|
|
1453
|
+
if (!descriptor) return;
|
|
1453
1454
|
const mirrorsBeforePayloadSanitization = contentTextMirrorsStructuredContent(response, sc);
|
|
1454
1455
|
if (payloadValid && sanitizePayloadErrors(sc)) {
|
|
1455
1456
|
syncContentJsonText(response, sc, mirrorsBeforePayloadSanitization);
|
|
@@ -2341,7 +2342,6 @@ function createAdcpServer(config) {
|
|
|
2341
2342
|
if (config.webhooks?.webBotAuth && !config.identity33)
|
|
2342
2343
|
throw new Error("Web Bot Auth webhook signing requires the identity33 experiment");
|
|
2343
2344
|
if (config.webhooks?.webBotAuth?.key) assertWebBotAuthSigningKey(config.webhooks.webBotAuth.key);
|
|
2344
|
-
const toolsWithErrorArm = getToolsWithErrorArm(adcpVersion);
|
|
2345
2345
|
const isProduction = process.env.NODE_ENV === "production";
|
|
2346
2346
|
const requestValidationMode = validationConfig?.requests ?? (isProduction ? "off" : "strict");
|
|
2347
2347
|
const responseValidationMode = validationConfig?.responses ?? (isProduction ? "off" : "strict");
|
|
@@ -2603,7 +2603,7 @@ function createAdcpServer(config) {
|
|
|
2603
2603
|
const releaseDefinesTool = (toolName, release) => {
|
|
2604
2604
|
if (toolName === "refine_proposals") return true;
|
|
2605
2605
|
try {
|
|
2606
|
-
return
|
|
2606
|
+
return definesToolRequest(toolName, release.validationVersion);
|
|
2607
2607
|
} catch {
|
|
2608
2608
|
return false;
|
|
2609
2609
|
}
|
|
@@ -2614,7 +2614,7 @@ function createAdcpServer(config) {
|
|
|
2614
2614
|
...servedAdcpVersion !== void 0 && { wireVersion: servedAdcpVersion }
|
|
2615
2615
|
};
|
|
2616
2616
|
sanitizeAdcpErrorEnvelope(response);
|
|
2617
|
-
enrichErrorTwoLayer(response, toolName,
|
|
2617
|
+
enrichErrorTwoLayer(response, toolName, release.validationVersion);
|
|
2618
2618
|
if (!isErrorResponse(response)) {
|
|
2619
2619
|
response = downgradeTaskStatusResult(toolName, response, release.validationVersion);
|
|
2620
2620
|
normalizeMediaBuyStatusCollision(response, toolName, release.validationVersion);
|
|
@@ -2975,7 +2975,6 @@ function createAdcpServer(config) {
|
|
|
2975
2975
|
} else {
|
|
2976
2976
|
requestRelease = releaseSelection;
|
|
2977
2977
|
}
|
|
2978
|
-
const requestErrorArms = getToolsWithErrorArm(requestRelease.validationVersion);
|
|
2979
2978
|
const translatesRelease = toolName !== "get_adcp_capabilities" && translationSteps(adcpVersion, requestRelease.validationVersion).length > 0;
|
|
2980
2979
|
const ctx = withImmutableServedAdcpVersion(
|
|
2981
2980
|
{
|
|
@@ -2996,7 +2995,7 @@ function createAdcpServer(config) {
|
|
|
2996
2995
|
}
|
|
2997
2996
|
const finalizeProtocolEnvelope = (response) => {
|
|
2998
2997
|
sanitizeAdcpErrorEnvelope(response);
|
|
2999
|
-
enrichErrorTwoLayer(response, toolName,
|
|
2998
|
+
enrichErrorTwoLayer(response, toolName, requestRelease.validationVersion);
|
|
3000
2999
|
normalizeMediaBuyStatusCollision(response, toolName, requestRelease.validationVersion);
|
|
3001
3000
|
injectEnvelopeStatusIntoResponse(response, toolName, requestRelease.validationVersion);
|
|
3002
3001
|
injectContextIntoResponse(response, params.context);
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
* response schema doesn't define it would add a key the schema
|
|
11
11
|
* doesn't expect.
|
|
12
12
|
*
|
|
13
|
-
* Derived from the active schema-loader authority
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* store exists.
|
|
13
|
+
* Derived from the active schema-loader authority, one tool at a time: a
|
|
14
|
+
* lookup reads only that tool's response schema, and results are memoised
|
|
15
|
+
* by bundle key and resolved root, with loader-epoch invalidation so scoped
|
|
16
|
+
* or re-registered candidate bundles cannot leak. Raw external roots use the
|
|
17
|
+
* loader's response index when no bundled store exists.
|
|
18
18
|
*
|
|
19
19
|
* Spec basis: `error-code.json#GOVERNANCE_DENIED` and
|
|
20
20
|
* `#GOVERNANCE_UNAVAILABLE` both prescribe "populate `errors[].code` in
|
|
@@ -40,16 +40,25 @@ export interface ErrorArmDescriptor {
|
|
|
40
40
|
extraRequired: Readonly<Record<string, unknown>>;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
* declares
|
|
45
|
-
* gate for two-layer auto-emission, plus the
|
|
46
|
-
*
|
|
43
|
+
* Error-arm descriptor of `toolName`'s response schema at `version`, or
|
|
44
|
+
* undefined when the response declares no top-level Error arm requiring
|
|
45
|
+
* `errors[]`. Dispatcher-side gate for two-layer auto-emission, plus the
|
|
46
|
+
* per-arm constants the dispatcher sets when synthesising the wrap.
|
|
47
47
|
*
|
|
48
|
-
*
|
|
49
|
-
* without caching, so later external
|
|
50
|
-
* or entering another schema
|
|
51
|
-
*
|
|
48
|
+
* Reads only that tool's response schema, once per loader generation.
|
|
49
|
+
* Missing roots return undefined without caching, so later external
|
|
50
|
+
* registration takes effect. Re-registering or entering another schema
|
|
51
|
+
* scope starts a new generation, including replacements of candidate
|
|
52
|
+
* bundles at the same path.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getErrorArmDescriptor(toolName: string, version?: string): ErrorArmDescriptor | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Every tool at `version` whose response declares an Error arm, built from
|
|
57
|
+
* the same per-tool lookups and cache as {@link getErrorArmDescriptor}. Tool
|
|
58
|
+
* names come from the bundled store's response files, or from the loader's
|
|
59
|
+
* response index for raw external roots. For audits and tests; the
|
|
60
|
+
* dispatcher looks tools up one at a time.
|
|
52
61
|
*/
|
|
53
62
|
export declare function getToolsWithErrorArm(version?: string): ReadonlyMap<string, ErrorArmDescriptor>;
|
|
54
|
-
/** Test hook: clear cached error-arm
|
|
63
|
+
/** Test hook: clear cached error-arm lookups. */
|
|
55
64
|
export declare function _resetErrorArmToolsCache(): void;
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
* response schema doesn't define it would add a key the schema
|
|
11
11
|
* doesn't expect.
|
|
12
12
|
*
|
|
13
|
-
* Derived from the active schema-loader authority
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* store exists.
|
|
13
|
+
* Derived from the active schema-loader authority, one tool at a time: a
|
|
14
|
+
* lookup reads only that tool's response schema, and results are memoised
|
|
15
|
+
* by bundle key and resolved root, with loader-epoch invalidation so scoped
|
|
16
|
+
* or re-registered candidate bundles cannot leak. Raw external roots use the
|
|
17
|
+
* loader's response index when no bundled store exists.
|
|
18
18
|
*
|
|
19
19
|
* Spec basis: `error-code.json#GOVERNANCE_DENIED` and
|
|
20
20
|
* `#GOVERNANCE_UNAVAILABLE` both prescribe "populate `errors[].code` in
|
|
@@ -40,16 +40,25 @@ export interface ErrorArmDescriptor {
|
|
|
40
40
|
extraRequired: Readonly<Record<string, unknown>>;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
* declares
|
|
45
|
-
* gate for two-layer auto-emission, plus the
|
|
46
|
-
*
|
|
43
|
+
* Error-arm descriptor of `toolName`'s response schema at `version`, or
|
|
44
|
+
* undefined when the response declares no top-level Error arm requiring
|
|
45
|
+
* `errors[]`. Dispatcher-side gate for two-layer auto-emission, plus the
|
|
46
|
+
* per-arm constants the dispatcher sets when synthesising the wrap.
|
|
47
47
|
*
|
|
48
|
-
*
|
|
49
|
-
* without caching, so later external
|
|
50
|
-
* or entering another schema
|
|
51
|
-
*
|
|
48
|
+
* Reads only that tool's response schema, once per loader generation.
|
|
49
|
+
* Missing roots return undefined without caching, so later external
|
|
50
|
+
* registration takes effect. Re-registering or entering another schema
|
|
51
|
+
* scope starts a new generation, including replacements of candidate
|
|
52
|
+
* bundles at the same path.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getErrorArmDescriptor(toolName: string, version?: string): ErrorArmDescriptor | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Every tool at `version` whose response declares an Error arm, built from
|
|
57
|
+
* the same per-tool lookups and cache as {@link getErrorArmDescriptor}. Tool
|
|
58
|
+
* names come from the bundled store's response files, or from the loader's
|
|
59
|
+
* response index for raw external roots. For audits and tests; the
|
|
60
|
+
* dispatcher looks tools up one at a time.
|
|
52
61
|
*/
|
|
53
62
|
export declare function getToolsWithErrorArm(version?: string): ReadonlyMap<string, ErrorArmDescriptor>;
|
|
54
|
-
/** Test hook: clear cached error-arm
|
|
63
|
+
/** Test hook: clear cached error-arm lookups. */
|
|
55
64
|
export declare function _resetErrorArmToolsCache(): void;
|
|
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var error_arm_tools_exports = {};
|
|
30
30
|
__export(error_arm_tools_exports, {
|
|
31
31
|
_resetErrorArmToolsCache: () => _resetErrorArmToolsCache,
|
|
32
|
+
getErrorArmDescriptor: () => getErrorArmDescriptor,
|
|
32
33
|
getToolsWithErrorArm: () => getToolsWithErrorArm
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(error_arm_tools_exports);
|
|
@@ -70,69 +71,116 @@ function describeErrorArm(branch, rootSchema) {
|
|
|
70
71
|
}
|
|
71
72
|
return { extraRequired: Object.freeze(extraRequired) };
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
-
const bundledRoot = import_path.default.join(root, "bundled");
|
|
75
|
-
const map = /* @__PURE__ */ new Map();
|
|
76
|
-
let manifestTools;
|
|
74
|
+
function readManifestTools(root) {
|
|
77
75
|
try {
|
|
78
76
|
const manifest = JSON.parse((0, import_fs.readFileSync)(import_path.default.join(root, "manifest.json"), "utf-8"));
|
|
79
|
-
|
|
77
|
+
return manifest.tools ? new Set(Object.keys(manifest.tools)) : void 0;
|
|
80
78
|
} catch {
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function listResponseFiles(root) {
|
|
83
|
+
const bundledRoot = import_path.default.join(root, "bundled");
|
|
84
|
+
if (!(0, import_bundled_schema_store.hasBundledSchemaStore)(bundledRoot)) return void 0;
|
|
85
|
+
const byTool = /* @__PURE__ */ new Map();
|
|
86
|
+
for (const file of (0, import_bundled_schema_store.listBundledSchemaFiles)(bundledRoot)) {
|
|
87
|
+
if (!file.endsWith("-response.json")) continue;
|
|
88
|
+
const toolName = import_path.default.basename(file, "-response.json").replace(/-/g, "_");
|
|
89
|
+
const files = byTool.get(toolName);
|
|
90
|
+
if (files) files.push(file);
|
|
91
|
+
else byTool.set(toolName, [file]);
|
|
92
|
+
}
|
|
93
|
+
return byTool;
|
|
94
|
+
}
|
|
95
|
+
function describeResponse(schema) {
|
|
96
|
+
const branches = schema.oneOf ?? schema.anyOf;
|
|
97
|
+
if (!Array.isArray(branches)) return void 0;
|
|
98
|
+
for (const branch of branches) {
|
|
99
|
+
const candidate = describeErrorArm(branch, schema);
|
|
100
|
+
if (candidate) return candidate;
|
|
101
|
+
}
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
function resolveDescriptor(index, toolName) {
|
|
105
|
+
if (index.manifestTools && !index.manifestTools.has(toolName)) return void 0;
|
|
106
|
+
if (!index.responseFiles) {
|
|
107
|
+
try {
|
|
108
|
+
const schema = (0, import_schema_loader.getToolSchemaDocument)(toolName, "sync", index.version)?.schema;
|
|
109
|
+
return schema ? describeResponse(schema) : void 0;
|
|
110
|
+
} catch {
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
81
113
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
for (const { toolName, file } of responses) {
|
|
114
|
+
let descriptor;
|
|
115
|
+
for (const file of index.responseFiles.get(toolName) ?? []) {
|
|
85
116
|
let schema;
|
|
86
117
|
try {
|
|
87
|
-
|
|
88
|
-
if (!loaded) continue;
|
|
89
|
-
schema = loaded;
|
|
118
|
+
schema = (0, import_bundled_schema_store.loadBundledSchemaFile)(file);
|
|
90
119
|
} catch {
|
|
91
120
|
continue;
|
|
92
121
|
}
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
let descriptor;
|
|
96
|
-
for (const branch of branches) {
|
|
97
|
-
const candidate = describeErrorArm(branch, schema);
|
|
98
|
-
if (candidate) {
|
|
99
|
-
descriptor = candidate;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (!descriptor) continue;
|
|
104
|
-
if (manifestTools && !manifestTools.has(toolName)) continue;
|
|
105
|
-
map.set(toolName, descriptor);
|
|
122
|
+
const candidate = schema ? describeResponse(schema) : void 0;
|
|
123
|
+
if (candidate) descriptor = candidate;
|
|
106
124
|
}
|
|
107
|
-
return
|
|
125
|
+
return descriptor;
|
|
108
126
|
}
|
|
109
127
|
let cachedGeneration = -1;
|
|
110
|
-
const
|
|
111
|
-
function
|
|
128
|
+
const cachedIndexes = /* @__PURE__ */ new Map();
|
|
129
|
+
function activeRootIndex(version) {
|
|
112
130
|
const bundleKey = (0, import_schema_loader.resolveBundleKey)(version);
|
|
113
131
|
let root;
|
|
114
132
|
try {
|
|
115
133
|
root = (0, import_schema_loader.resolveSchemaRoot)(version);
|
|
116
134
|
} catch {
|
|
117
|
-
return
|
|
135
|
+
return void 0;
|
|
118
136
|
}
|
|
119
137
|
const generation = (0, import_schema_loader.getSchemaLoaderGeneration)();
|
|
120
138
|
if (cachedGeneration !== generation) {
|
|
121
|
-
|
|
139
|
+
cachedIndexes.clear();
|
|
122
140
|
cachedGeneration = generation;
|
|
123
141
|
}
|
|
124
142
|
const key = `${bundleKey}\0${import_path.default.resolve(root)}`;
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
143
|
+
let index = cachedIndexes.get(key);
|
|
144
|
+
if (!index) {
|
|
145
|
+
index = {
|
|
146
|
+
root,
|
|
147
|
+
version,
|
|
148
|
+
manifestTools: readManifestTools(root),
|
|
149
|
+
responseFiles: listResponseFiles(root),
|
|
150
|
+
descriptors: /* @__PURE__ */ new Map()
|
|
151
|
+
};
|
|
152
|
+
cachedIndexes.set(key, index);
|
|
153
|
+
}
|
|
154
|
+
return index;
|
|
155
|
+
}
|
|
156
|
+
function getErrorArmDescriptor(toolName, version = import_version.ADCP_VERSION) {
|
|
157
|
+
const index = activeRootIndex(version);
|
|
158
|
+
if (!index) return void 0;
|
|
159
|
+
const cached = index.descriptors.get(toolName);
|
|
160
|
+
if (cached !== void 0) return cached ?? void 0;
|
|
161
|
+
const descriptor = resolveDescriptor(index, toolName);
|
|
162
|
+
index.descriptors.set(toolName, descriptor ?? null);
|
|
163
|
+
return descriptor;
|
|
164
|
+
}
|
|
165
|
+
function getToolsWithErrorArm(version = import_version.ADCP_VERSION) {
|
|
166
|
+
const index = activeRootIndex(version);
|
|
167
|
+
if (!index) return /* @__PURE__ */ new Map();
|
|
168
|
+
if (index.inventory) return index.inventory;
|
|
169
|
+
const names = index.responseFiles ? [...index.responseFiles.keys()] : (0, import_schema_loader.listValidatorKeys)(version).filter((key) => key.endsWith("::sync")).map((key) => key.slice(0, -"::sync".length));
|
|
170
|
+
const map = /* @__PURE__ */ new Map();
|
|
171
|
+
for (const toolName of names) {
|
|
172
|
+
const descriptor = getErrorArmDescriptor(toolName, version);
|
|
173
|
+
if (descriptor) map.set(toolName, descriptor);
|
|
174
|
+
}
|
|
175
|
+
index.inventory = map;
|
|
129
176
|
return map;
|
|
130
177
|
}
|
|
131
178
|
function _resetErrorArmToolsCache() {
|
|
132
|
-
|
|
179
|
+
cachedIndexes.clear();
|
|
133
180
|
}
|
|
134
181
|
// Annotate the CommonJS export names for ESM import in node:
|
|
135
182
|
0 && (module.exports = {
|
|
136
183
|
_resetErrorArmToolsCache,
|
|
184
|
+
getErrorArmDescriptor,
|
|
137
185
|
getToolsWithErrorArm
|
|
138
186
|
});
|
|
@@ -46,68 +46,115 @@ function describeErrorArm(branch, rootSchema) {
|
|
|
46
46
|
}
|
|
47
47
|
return { extraRequired: Object.freeze(extraRequired) };
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
const bundledRoot = path.join(root, "bundled");
|
|
51
|
-
const map = /* @__PURE__ */ new Map();
|
|
52
|
-
let manifestTools;
|
|
49
|
+
function readManifestTools(root) {
|
|
53
50
|
try {
|
|
54
51
|
const manifest = JSON.parse(readFileSync(path.join(root, "manifest.json"), "utf-8"));
|
|
55
|
-
|
|
52
|
+
return manifest.tools ? new Set(Object.keys(manifest.tools)) : void 0;
|
|
56
53
|
} catch {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function listResponseFiles(root) {
|
|
58
|
+
const bundledRoot = path.join(root, "bundled");
|
|
59
|
+
if (!hasBundledSchemaStore(bundledRoot)) return void 0;
|
|
60
|
+
const byTool = /* @__PURE__ */ new Map();
|
|
61
|
+
for (const file of listBundledSchemaFiles(bundledRoot)) {
|
|
62
|
+
if (!file.endsWith("-response.json")) continue;
|
|
63
|
+
const toolName = path.basename(file, "-response.json").replace(/-/g, "_");
|
|
64
|
+
const files = byTool.get(toolName);
|
|
65
|
+
if (files) files.push(file);
|
|
66
|
+
else byTool.set(toolName, [file]);
|
|
67
|
+
}
|
|
68
|
+
return byTool;
|
|
69
|
+
}
|
|
70
|
+
function describeResponse(schema) {
|
|
71
|
+
const branches = schema.oneOf ?? schema.anyOf;
|
|
72
|
+
if (!Array.isArray(branches)) return void 0;
|
|
73
|
+
for (const branch of branches) {
|
|
74
|
+
const candidate = describeErrorArm(branch, schema);
|
|
75
|
+
if (candidate) return candidate;
|
|
76
|
+
}
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
function resolveDescriptor(index, toolName) {
|
|
80
|
+
if (index.manifestTools && !index.manifestTools.has(toolName)) return void 0;
|
|
81
|
+
if (!index.responseFiles) {
|
|
82
|
+
try {
|
|
83
|
+
const schema = getToolSchemaDocument(toolName, "sync", index.version)?.schema;
|
|
84
|
+
return schema ? describeResponse(schema) : void 0;
|
|
85
|
+
} catch {
|
|
86
|
+
return void 0;
|
|
87
|
+
}
|
|
57
88
|
}
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
for (const { toolName, file } of responses) {
|
|
89
|
+
let descriptor;
|
|
90
|
+
for (const file of index.responseFiles.get(toolName) ?? []) {
|
|
61
91
|
let schema;
|
|
62
92
|
try {
|
|
63
|
-
|
|
64
|
-
if (!loaded) continue;
|
|
65
|
-
schema = loaded;
|
|
93
|
+
schema = loadBundledSchemaFile(file);
|
|
66
94
|
} catch {
|
|
67
95
|
continue;
|
|
68
96
|
}
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
let descriptor;
|
|
72
|
-
for (const branch of branches) {
|
|
73
|
-
const candidate = describeErrorArm(branch, schema);
|
|
74
|
-
if (candidate) {
|
|
75
|
-
descriptor = candidate;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (!descriptor) continue;
|
|
80
|
-
if (manifestTools && !manifestTools.has(toolName)) continue;
|
|
81
|
-
map.set(toolName, descriptor);
|
|
97
|
+
const candidate = schema ? describeResponse(schema) : void 0;
|
|
98
|
+
if (candidate) descriptor = candidate;
|
|
82
99
|
}
|
|
83
|
-
return
|
|
100
|
+
return descriptor;
|
|
84
101
|
}
|
|
85
102
|
let cachedGeneration = -1;
|
|
86
|
-
const
|
|
87
|
-
function
|
|
103
|
+
const cachedIndexes = /* @__PURE__ */ new Map();
|
|
104
|
+
function activeRootIndex(version) {
|
|
88
105
|
const bundleKey = resolveBundleKey(version);
|
|
89
106
|
let root;
|
|
90
107
|
try {
|
|
91
108
|
root = resolveSchemaRoot(version);
|
|
92
109
|
} catch {
|
|
93
|
-
return
|
|
110
|
+
return void 0;
|
|
94
111
|
}
|
|
95
112
|
const generation = getSchemaLoaderGeneration();
|
|
96
113
|
if (cachedGeneration !== generation) {
|
|
97
|
-
|
|
114
|
+
cachedIndexes.clear();
|
|
98
115
|
cachedGeneration = generation;
|
|
99
116
|
}
|
|
100
117
|
const key = `${bundleKey}\0${path.resolve(root)}`;
|
|
101
|
-
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
118
|
+
let index = cachedIndexes.get(key);
|
|
119
|
+
if (!index) {
|
|
120
|
+
index = {
|
|
121
|
+
root,
|
|
122
|
+
version,
|
|
123
|
+
manifestTools: readManifestTools(root),
|
|
124
|
+
responseFiles: listResponseFiles(root),
|
|
125
|
+
descriptors: /* @__PURE__ */ new Map()
|
|
126
|
+
};
|
|
127
|
+
cachedIndexes.set(key, index);
|
|
128
|
+
}
|
|
129
|
+
return index;
|
|
130
|
+
}
|
|
131
|
+
function getErrorArmDescriptor(toolName, version = ADCP_VERSION) {
|
|
132
|
+
const index = activeRootIndex(version);
|
|
133
|
+
if (!index) return void 0;
|
|
134
|
+
const cached = index.descriptors.get(toolName);
|
|
135
|
+
if (cached !== void 0) return cached ?? void 0;
|
|
136
|
+
const descriptor = resolveDescriptor(index, toolName);
|
|
137
|
+
index.descriptors.set(toolName, descriptor ?? null);
|
|
138
|
+
return descriptor;
|
|
139
|
+
}
|
|
140
|
+
function getToolsWithErrorArm(version = ADCP_VERSION) {
|
|
141
|
+
const index = activeRootIndex(version);
|
|
142
|
+
if (!index) return /* @__PURE__ */ new Map();
|
|
143
|
+
if (index.inventory) return index.inventory;
|
|
144
|
+
const names = index.responseFiles ? [...index.responseFiles.keys()] : listValidatorKeys(version).filter((key) => key.endsWith("::sync")).map((key) => key.slice(0, -"::sync".length));
|
|
145
|
+
const map = /* @__PURE__ */ new Map();
|
|
146
|
+
for (const toolName of names) {
|
|
147
|
+
const descriptor = getErrorArmDescriptor(toolName, version);
|
|
148
|
+
if (descriptor) map.set(toolName, descriptor);
|
|
149
|
+
}
|
|
150
|
+
index.inventory = map;
|
|
105
151
|
return map;
|
|
106
152
|
}
|
|
107
153
|
function _resetErrorArmToolsCache() {
|
|
108
|
-
|
|
154
|
+
cachedIndexes.clear();
|
|
109
155
|
}
|
|
110
156
|
export {
|
|
111
157
|
_resetErrorArmToolsCache,
|
|
158
|
+
getErrorArmDescriptor,
|
|
112
159
|
getToolsWithErrorArm
|
|
113
160
|
};
|