@topolo/sdk 0.11.4 → 0.11.5
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/index.cjs +16 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -3
- package/dist/node/credential-store.cjs +1 -0
- package/dist/node/credential-store.js +1 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -153,6 +153,7 @@ var PUBLIC_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
153
153
|
"permission_denied",
|
|
154
154
|
"rate_limited",
|
|
155
155
|
"request_failed",
|
|
156
|
+
"request_timeout",
|
|
156
157
|
"service_catalog_unavailable",
|
|
157
158
|
"service_path_origin_mismatch",
|
|
158
159
|
"service_required",
|
|
@@ -1138,7 +1139,7 @@ var TopoloClient = class _TopoloClient {
|
|
|
1138
1139
|
this.serviceUrls = options.environment ? topoloServiceOrigins(options.serviceUrls, options.environment) : options.serviceUrls;
|
|
1139
1140
|
this.appIds = options.appIds;
|
|
1140
1141
|
this.requireConfirmForWrites = options.requireConfirmForWrites !== false;
|
|
1141
|
-
this.timeoutMs = options.timeoutMs ??
|
|
1142
|
+
this.timeoutMs = options.timeoutMs ?? 12e4;
|
|
1142
1143
|
this.fetchImpl = options.fetch ?? fetch;
|
|
1143
1144
|
this.credentialProvider = options.credentialProvider;
|
|
1144
1145
|
this.refreshCredential = options.refreshCredential;
|
|
@@ -1209,7 +1210,11 @@ var TopoloClient = class _TopoloClient {
|
|
|
1209
1210
|
this.emit({ phase: "request", method, service: resolvedService.serviceKey, path: opts.path, url: urlStr, requestId });
|
|
1210
1211
|
const fetchOnce = async () => {
|
|
1211
1212
|
const controller = new AbortController();
|
|
1212
|
-
|
|
1213
|
+
let timedOut = false;
|
|
1214
|
+
const timeoutId = setTimeout(() => {
|
|
1215
|
+
timedOut = true;
|
|
1216
|
+
controller.abort();
|
|
1217
|
+
}, this.timeoutMs);
|
|
1213
1218
|
const signal = opts.signal ? mergeSignals(opts.signal, controller.signal) : controller.signal;
|
|
1214
1219
|
try {
|
|
1215
1220
|
return await this.fetchImpl(urlStr, {
|
|
@@ -1218,6 +1223,14 @@ var TopoloClient = class _TopoloClient {
|
|
|
1218
1223
|
body: opts.rawBody ?? (opts.body !== void 0 ? JSON.stringify(opts.body) : null),
|
|
1219
1224
|
signal
|
|
1220
1225
|
});
|
|
1226
|
+
} catch (error) {
|
|
1227
|
+
if (timedOut) {
|
|
1228
|
+
throw new TopoloSdkError(
|
|
1229
|
+
"request_timeout",
|
|
1230
|
+
`Topolo request timed out after ${this.timeoutMs}ms. Verify current state before retrying a mutation.`
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
throw error;
|
|
1221
1234
|
} finally {
|
|
1222
1235
|
clearTimeout(timeoutId);
|
|
1223
1236
|
}
|
|
@@ -1243,7 +1256,7 @@ var TopoloClient = class _TopoloClient {
|
|
|
1243
1256
|
url: urlStr,
|
|
1244
1257
|
requestId,
|
|
1245
1258
|
durationMs: Date.now() - startedAt,
|
|
1246
|
-
error: "network_error"
|
|
1259
|
+
error: err instanceof TopoloSdkError ? err.code : "network_error"
|
|
1247
1260
|
});
|
|
1248
1261
|
throw err;
|
|
1249
1262
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -95,7 +95,7 @@ interface TopoloClientOptions {
|
|
|
95
95
|
* `{ confirm: true }`. Defaults to true. Set false only for trusted surfaces.
|
|
96
96
|
*/
|
|
97
97
|
requireConfirmForWrites?: boolean;
|
|
98
|
-
/** HTTP request timeout (ms). Default
|
|
98
|
+
/** HTTP request timeout (ms). Default 120s. */
|
|
99
99
|
timeoutMs?: number;
|
|
100
100
|
/** Injected fetch, for testing. Defaults to global fetch. */
|
|
101
101
|
fetch?: typeof fetch;
|
package/dist/index.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ interface TopoloClientOptions {
|
|
|
95
95
|
* `{ confirm: true }`. Defaults to true. Set false only for trusted surfaces.
|
|
96
96
|
*/
|
|
97
97
|
requireConfirmForWrites?: boolean;
|
|
98
|
-
/** HTTP request timeout (ms). Default
|
|
98
|
+
/** HTTP request timeout (ms). Default 120s. */
|
|
99
99
|
timeoutMs?: number;
|
|
100
100
|
/** Injected fetch, for testing. Defaults to global fetch. */
|
|
101
101
|
fetch?: typeof fetch;
|
package/dist/index.js
CHANGED
|
@@ -63,6 +63,7 @@ var PUBLIC_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
63
63
|
"permission_denied",
|
|
64
64
|
"rate_limited",
|
|
65
65
|
"request_failed",
|
|
66
|
+
"request_timeout",
|
|
66
67
|
"service_catalog_unavailable",
|
|
67
68
|
"service_path_origin_mismatch",
|
|
68
69
|
"service_required",
|
|
@@ -1048,7 +1049,7 @@ var TopoloClient = class _TopoloClient {
|
|
|
1048
1049
|
this.serviceUrls = options.environment ? topoloServiceOrigins(options.serviceUrls, options.environment) : options.serviceUrls;
|
|
1049
1050
|
this.appIds = options.appIds;
|
|
1050
1051
|
this.requireConfirmForWrites = options.requireConfirmForWrites !== false;
|
|
1051
|
-
this.timeoutMs = options.timeoutMs ??
|
|
1052
|
+
this.timeoutMs = options.timeoutMs ?? 12e4;
|
|
1052
1053
|
this.fetchImpl = options.fetch ?? fetch;
|
|
1053
1054
|
this.credentialProvider = options.credentialProvider;
|
|
1054
1055
|
this.refreshCredential = options.refreshCredential;
|
|
@@ -1119,7 +1120,11 @@ var TopoloClient = class _TopoloClient {
|
|
|
1119
1120
|
this.emit({ phase: "request", method, service: resolvedService.serviceKey, path: opts.path, url: urlStr, requestId });
|
|
1120
1121
|
const fetchOnce = async () => {
|
|
1121
1122
|
const controller = new AbortController();
|
|
1122
|
-
|
|
1123
|
+
let timedOut = false;
|
|
1124
|
+
const timeoutId = setTimeout(() => {
|
|
1125
|
+
timedOut = true;
|
|
1126
|
+
controller.abort();
|
|
1127
|
+
}, this.timeoutMs);
|
|
1123
1128
|
const signal = opts.signal ? mergeSignals(opts.signal, controller.signal) : controller.signal;
|
|
1124
1129
|
try {
|
|
1125
1130
|
return await this.fetchImpl(urlStr, {
|
|
@@ -1128,6 +1133,14 @@ var TopoloClient = class _TopoloClient {
|
|
|
1128
1133
|
body: opts.rawBody ?? (opts.body !== void 0 ? JSON.stringify(opts.body) : null),
|
|
1129
1134
|
signal
|
|
1130
1135
|
});
|
|
1136
|
+
} catch (error) {
|
|
1137
|
+
if (timedOut) {
|
|
1138
|
+
throw new TopoloSdkError(
|
|
1139
|
+
"request_timeout",
|
|
1140
|
+
`Topolo request timed out after ${this.timeoutMs}ms. Verify current state before retrying a mutation.`
|
|
1141
|
+
);
|
|
1142
|
+
}
|
|
1143
|
+
throw error;
|
|
1131
1144
|
} finally {
|
|
1132
1145
|
clearTimeout(timeoutId);
|
|
1133
1146
|
}
|
|
@@ -1153,7 +1166,7 @@ var TopoloClient = class _TopoloClient {
|
|
|
1153
1166
|
url: urlStr,
|
|
1154
1167
|
requestId,
|
|
1155
1168
|
durationMs: Date.now() - startedAt,
|
|
1156
|
-
error: "network_error"
|
|
1169
|
+
error: err instanceof TopoloSdkError ? err.code : "network_error"
|
|
1157
1170
|
});
|
|
1158
1171
|
throw err;
|
|
1159
1172
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/sdk",
|
|
3
|
-
"version": "0.11.
|
|
4
|
-
"topoloPublishedVersion": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
|
+
"topoloPublishedVersion": "0.11.5",
|
|
5
5
|
"description": "Typed client SDK for the Topolo platform. Used by TopoloCli, TopoloMCP, and third-party agents.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"author": "Topolo",
|