@adcp/sdk 13.0.0-rc.13 → 13.0.0-rc.14
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/index.d.mts +2 -2
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +6 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/index.mjs +6 -0
- package/dist/lib/index.mjs.map +1 -1
- package/dist/lib/protocols/transportDiagnostics.js +2 -1
- package/dist/lib/protocols/transportDiagnostics.js.map +1 -1
- package/dist/lib/protocols/transportDiagnostics.mjs +2 -1
- package/dist/lib/protocols/transportDiagnostics.mjs.map +1 -1
- package/dist/lib/registry/index.d.mts +17 -0
- package/dist/lib/registry/index.d.ts +17 -0
- package/dist/lib/registry/index.d.ts.map +1 -1
- package/dist/lib/registry/index.js +81 -7
- package/dist/lib/registry/index.js.map +1 -1
- package/dist/lib/registry/index.mjs +79 -7
- package/dist/lib/registry/index.mjs.map +1 -1
- package/dist/lib/registry/types.generated.d.mts +157 -7
- package/dist/lib/registry/types.generated.d.ts +157 -7
- package/dist/lib/registry/types.generated.d.ts.map +1 -1
- package/dist/lib/registry/types.generated.js.map +1 -1
- package/dist/lib/schemas-data/v2.5/_provenance.json +1 -1
- package/dist/lib/server/errors.d.mts +10 -2
- package/dist/lib/server/errors.d.ts +10 -2
- package/dist/lib/server/errors.d.ts.map +1 -1
- package/dist/lib/server/errors.js +9 -2
- package/dist/lib/server/errors.js.map +1 -1
- package/dist/lib/server/errors.mjs +9 -2
- package/dist/lib/server/errors.mjs.map +1 -1
- package/dist/lib/testing/compliance/comply.d.mts +6 -0
- package/dist/lib/testing/compliance/comply.d.ts +6 -0
- package/dist/lib/testing/compliance/comply.d.ts.map +1 -1
- package/dist/lib/testing/compliance/comply.js +3 -0
- package/dist/lib/testing/compliance/comply.js.map +1 -1
- package/dist/lib/testing/compliance/comply.mjs +3 -0
- package/dist/lib/testing/compliance/comply.mjs.map +1 -1
- package/dist/lib/testing/storyboard/runner.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/runner.js +31 -5
- package/dist/lib/testing/storyboard/runner.js.map +1 -1
- package/dist/lib/testing/storyboard/runner.mjs +36 -6
- package/dist/lib/testing/storyboard/runner.mjs.map +1 -1
- package/dist/lib/testing/storyboard/types.d.mts +16 -5
- package/dist/lib/testing/storyboard/types.d.ts +16 -5
- package/dist/lib/testing/storyboard/types.d.ts.map +1 -1
- package/dist/lib/testing/storyboard/types.js +1 -1
- package/dist/lib/testing/storyboard/types.js.map +1 -1
- package/dist/lib/testing/storyboard/types.mjs +1 -1
- package/dist/lib/testing/storyboard/types.mjs.map +1 -1
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/v2/projection/augment-response.d.mts +16 -0
- package/dist/lib/v2/projection/augment-response.d.ts +16 -0
- package/dist/lib/v2/projection/augment-response.d.ts.map +1 -1
- package/dist/lib/v2/projection/augment-response.js +13 -4
- package/dist/lib/v2/projection/augment-response.js.map +1 -1
- package/dist/lib/v2/projection/augment-response.mjs +12 -4
- package/dist/lib/v2/projection/augment-response.mjs.map +1 -1
- package/dist/lib/v2/projection/index.d.mts +3 -1
- package/dist/lib/v2/projection/index.d.ts +3 -1
- package/dist/lib/v2/projection/index.d.ts.map +1 -1
- package/dist/lib/v2/projection/index.js +2 -0
- package/dist/lib/v2/projection/index.js.map +1 -1
- package/dist/lib/v2/projection/index.mjs +2 -0
- package/dist/lib/v2/projection/index.mjs.map +1 -1
- 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.js.map +1 -1
- package/dist/lib/version.mjs +3 -3
- package/dist/lib/version.mjs.map +1 -1
- package/examples/error-compliant-server.ts +9 -3
- package/package.json +1 -1
|
@@ -22,6 +22,59 @@ const MAX_BRAND_BULK_DOMAINS = 25;
|
|
|
22
22
|
const MAX_BULK_DOMAINS = 100;
|
|
23
23
|
const MAX_CHECK_DOMAINS = 1e4;
|
|
24
24
|
const COMMUNITY_MIRROR_PLATFORM_RE = /^[a-z0-9_-]{1,64}$/;
|
|
25
|
+
const MAX_REGISTRY_ERROR_DETAILS_BYTES = 64 * 1024;
|
|
26
|
+
const MAX_RETRY_AFTER_MS = 2147483647;
|
|
27
|
+
class RegistryRequestError extends Error {
|
|
28
|
+
status;
|
|
29
|
+
method;
|
|
30
|
+
retryAfterMs;
|
|
31
|
+
/** Bounded, untrusted JSON returned by the remote registry. */
|
|
32
|
+
details;
|
|
33
|
+
constructor(status, message, options) {
|
|
34
|
+
super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
|
|
35
|
+
this.name = "RegistryRequestError";
|
|
36
|
+
this.status = status;
|
|
37
|
+
this.method = options.method;
|
|
38
|
+
this.retryAfterMs = options.retryAfterMs;
|
|
39
|
+
this.details = options.details;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function isRegistryRequestError(error) {
|
|
43
|
+
if (error instanceof RegistryRequestError) return true;
|
|
44
|
+
if (error === null || typeof error !== "object" || Array.isArray(error)) return false;
|
|
45
|
+
const candidate = error;
|
|
46
|
+
return candidate.name === "RegistryRequestError" && typeof candidate.message === "string" && typeof candidate.status === "number" && Number.isFinite(candidate.status) && typeof candidate.method === "string";
|
|
47
|
+
}
|
|
48
|
+
function parseRegistryErrorDetails(text) {
|
|
49
|
+
if (new TextEncoder().encode(text).byteLength > MAX_REGISTRY_ERROR_DETAILS_BYTES) return void 0;
|
|
50
|
+
try {
|
|
51
|
+
const parsed = JSON.parse(text);
|
|
52
|
+
return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
|
|
53
|
+
} catch {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function boundedRetryAfterMsFromSeconds(seconds) {
|
|
58
|
+
if (!Number.isFinite(seconds) || seconds < 0) return void 0;
|
|
59
|
+
const milliseconds = seconds * 1e3;
|
|
60
|
+
if (!Number.isFinite(milliseconds)) return MAX_RETRY_AFTER_MS;
|
|
61
|
+
return Math.min(milliseconds, MAX_RETRY_AFTER_MS);
|
|
62
|
+
}
|
|
63
|
+
function retryAfterMsFromDetails(details) {
|
|
64
|
+
if (!details || typeof details !== "object" || Array.isArray(details)) return void 0;
|
|
65
|
+
const record = details;
|
|
66
|
+
if (typeof record.retryAfterMs === "number" && Number.isFinite(record.retryAfterMs) && record.retryAfterMs >= 0) {
|
|
67
|
+
return Math.min(record.retryAfterMs, MAX_RETRY_AFTER_MS);
|
|
68
|
+
}
|
|
69
|
+
const seconds = record.retryAfter ?? record.retry_after;
|
|
70
|
+
return typeof seconds === "number" ? boundedRetryAfterMsFromSeconds(seconds) : void 0;
|
|
71
|
+
}
|
|
72
|
+
function retryAfterMsFromHeader(value) {
|
|
73
|
+
const trimmed = value?.trim();
|
|
74
|
+
if (!trimmed || !/^\d+$/.test(trimmed)) return void 0;
|
|
75
|
+
const seconds = Number(trimmed);
|
|
76
|
+
return Number.isFinite(seconds) ? boundedRetryAfterMsFromSeconds(seconds) : MAX_RETRY_AFTER_MS;
|
|
77
|
+
}
|
|
25
78
|
function buildCommunityMirrorAdagents(config) {
|
|
26
79
|
const maybeConfig = config;
|
|
27
80
|
if ("authorized_agents" in maybeConfig) {
|
|
@@ -694,7 +747,7 @@ class RegistryClient {
|
|
|
694
747
|
return { events: [], cursor: null, has_more: false, cursor_expired: true };
|
|
695
748
|
}
|
|
696
749
|
if (!res.ok) {
|
|
697
|
-
throw
|
|
750
|
+
throw this.requestError(res, text, "GET");
|
|
698
751
|
}
|
|
699
752
|
return this.parseJson(text);
|
|
700
753
|
}
|
|
@@ -837,7 +890,7 @@ class RegistryClient {
|
|
|
837
890
|
const { res, text } = await this.requestText(url, { headers: this.getHeaders() });
|
|
838
891
|
if (opts?.nullOn404 && res.status === 404) return null;
|
|
839
892
|
if (!res.ok) {
|
|
840
|
-
throw
|
|
893
|
+
throw this.requestError(res, text, "GET");
|
|
841
894
|
}
|
|
842
895
|
return this.parseJson(text);
|
|
843
896
|
}
|
|
@@ -848,7 +901,7 @@ class RegistryClient {
|
|
|
848
901
|
body: JSON.stringify(body)
|
|
849
902
|
});
|
|
850
903
|
if (!res.ok) {
|
|
851
|
-
throw
|
|
904
|
+
throw this.requestError(res, text, "POST");
|
|
852
905
|
}
|
|
853
906
|
return this.parseJson(text);
|
|
854
907
|
}
|
|
@@ -859,7 +912,7 @@ class RegistryClient {
|
|
|
859
912
|
body
|
|
860
913
|
});
|
|
861
914
|
if (!res.ok) {
|
|
862
|
-
throw
|
|
915
|
+
throw this.requestError(res, text, "POST");
|
|
863
916
|
}
|
|
864
917
|
return this.parseJson(text);
|
|
865
918
|
}
|
|
@@ -870,7 +923,7 @@ class RegistryClient {
|
|
|
870
923
|
body: JSON.stringify(body)
|
|
871
924
|
});
|
|
872
925
|
if (!res.ok) {
|
|
873
|
-
throw
|
|
926
|
+
throw this.requestError(res, text, "PUT");
|
|
874
927
|
}
|
|
875
928
|
return this.parseJson(text);
|
|
876
929
|
}
|
|
@@ -880,7 +933,7 @@ class RegistryClient {
|
|
|
880
933
|
headers: this.getHeaders()
|
|
881
934
|
});
|
|
882
935
|
if (!res.ok) {
|
|
883
|
-
throw
|
|
936
|
+
throw this.requestError(res, text, "DELETE");
|
|
884
937
|
}
|
|
885
938
|
return this.parseJson(text);
|
|
886
939
|
}
|
|
@@ -995,7 +1048,13 @@ class RegistryClient {
|
|
|
995
1048
|
redirect: this.redirect,
|
|
996
1049
|
signal: controller.signal
|
|
997
1050
|
});
|
|
998
|
-
|
|
1051
|
+
let text;
|
|
1052
|
+
try {
|
|
1053
|
+
text = await this.readBody(res, this.bodyLimitForUrl(url));
|
|
1054
|
+
} catch (error) {
|
|
1055
|
+
if (!res.ok) throw this.requestError(res, "", init.method ?? "GET", error);
|
|
1056
|
+
throw error;
|
|
1057
|
+
}
|
|
999
1058
|
return { res, text };
|
|
1000
1059
|
});
|
|
1001
1060
|
requestPromise.catch(() => {
|
|
@@ -1080,6 +1139,17 @@ class RegistryClient {
|
|
|
1080
1139
|
preview(text) {
|
|
1081
1140
|
return text.slice(0, ERROR_BODY_PREVIEW_CHARS).replace(/[\u0000-\u001f\u007f]/g, (ch) => `\\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`);
|
|
1082
1141
|
}
|
|
1142
|
+
requestError(res, text, method, cause) {
|
|
1143
|
+
const details = parseRegistryErrorDetails(text);
|
|
1144
|
+
const retryAfterMs = retryAfterMsFromHeader(res.headers.get("retry-after")) ?? retryAfterMsFromDetails(details);
|
|
1145
|
+
const preview = cause === void 0 ? this.preview(text) : "[response body unavailable]";
|
|
1146
|
+
return new RegistryRequestError(res.status, `Registry request failed (${res.status}): ${preview}`, {
|
|
1147
|
+
method,
|
|
1148
|
+
...retryAfterMs !== void 0 ? { retryAfterMs } : {},
|
|
1149
|
+
...details !== void 0 ? { details } : {},
|
|
1150
|
+
...cause !== void 0 ? { cause } : {}
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1083
1153
|
buildParams(options) {
|
|
1084
1154
|
if (!options) return "";
|
|
1085
1155
|
const params = new URLSearchParams();
|
|
@@ -1112,8 +1182,10 @@ export {
|
|
|
1112
1182
|
InMemoryCursorStore,
|
|
1113
1183
|
PropertyRegistry,
|
|
1114
1184
|
RegistryClient,
|
|
1185
|
+
RegistryRequestError,
|
|
1115
1186
|
RegistrySync,
|
|
1116
1187
|
buildCommunityMirrorAdagents,
|
|
1188
|
+
isRegistryRequestError,
|
|
1117
1189
|
openFeedStream2 as openFeedStream,
|
|
1118
1190
|
parseSseStream,
|
|
1119
1191
|
sanitizeStreamText
|