@topolo/sdk 0.9.7 → 0.9.8
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/README.md +12 -0
- package/dist/index.cjs +355 -43
- package/dist/index.d.cts +82 -8
- package/dist/index.d.ts +82 -8
- package/dist/index.js +352 -43
- package/dist/node/credential-store.cjs +30 -3
- package/dist/node/credential-store.js +30 -3
- package/package.json +2 -2
|
@@ -58,23 +58,50 @@ var TopoloSdkError = class extends Error {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
var TopoloAuthError = class extends TopoloSdkError {
|
|
61
|
-
|
|
61
|
+
status;
|
|
62
|
+
body;
|
|
63
|
+
service;
|
|
64
|
+
path;
|
|
65
|
+
requestId;
|
|
66
|
+
retryAfter;
|
|
67
|
+
constructor(message, code = "auth_error", options = {}) {
|
|
62
68
|
super(code, message);
|
|
63
69
|
this.name = "TopoloAuthError";
|
|
70
|
+
this.status = options.status ?? 401;
|
|
71
|
+
this.body = options.body;
|
|
72
|
+
this.service = options.service;
|
|
73
|
+
this.path = options.path;
|
|
74
|
+
this.requestId = options.requestId;
|
|
75
|
+
this.retryAfter = options.retryAfter;
|
|
64
76
|
}
|
|
65
77
|
};
|
|
78
|
+
function extractHttpErrorCode(body) {
|
|
79
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return "http_error";
|
|
80
|
+
const record = body;
|
|
81
|
+
if (typeof record.code === "string" && record.code.trim()) return record.code.trim();
|
|
82
|
+
const nested = record.error;
|
|
83
|
+
if (nested && typeof nested === "object" && !Array.isArray(nested)) {
|
|
84
|
+
const code = nested.code;
|
|
85
|
+
if (typeof code === "string" && code.trim()) return code.trim();
|
|
86
|
+
}
|
|
87
|
+
return "http_error";
|
|
88
|
+
}
|
|
66
89
|
var TopoloHttpError = class extends TopoloSdkError {
|
|
67
90
|
status;
|
|
68
91
|
body;
|
|
69
92
|
service;
|
|
70
93
|
path;
|
|
71
|
-
|
|
72
|
-
|
|
94
|
+
requestId;
|
|
95
|
+
retryAfter;
|
|
96
|
+
constructor(service, path, status, body, message, options = {}) {
|
|
97
|
+
super(extractHttpErrorCode(body), message ?? `HTTP ${status} from ${service}${path}`);
|
|
73
98
|
this.name = "TopoloHttpError";
|
|
74
99
|
this.status = status;
|
|
75
100
|
this.body = body;
|
|
76
101
|
this.service = service;
|
|
77
102
|
this.path = path;
|
|
103
|
+
this.requestId = options.requestId;
|
|
104
|
+
this.retryAfter = options.retryAfter;
|
|
78
105
|
}
|
|
79
106
|
};
|
|
80
107
|
|
|
@@ -14,23 +14,50 @@ var TopoloSdkError = class extends Error {
|
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
var TopoloAuthError = class extends TopoloSdkError {
|
|
17
|
-
|
|
17
|
+
status;
|
|
18
|
+
body;
|
|
19
|
+
service;
|
|
20
|
+
path;
|
|
21
|
+
requestId;
|
|
22
|
+
retryAfter;
|
|
23
|
+
constructor(message, code = "auth_error", options = {}) {
|
|
18
24
|
super(code, message);
|
|
19
25
|
this.name = "TopoloAuthError";
|
|
26
|
+
this.status = options.status ?? 401;
|
|
27
|
+
this.body = options.body;
|
|
28
|
+
this.service = options.service;
|
|
29
|
+
this.path = options.path;
|
|
30
|
+
this.requestId = options.requestId;
|
|
31
|
+
this.retryAfter = options.retryAfter;
|
|
20
32
|
}
|
|
21
33
|
};
|
|
34
|
+
function extractHttpErrorCode(body) {
|
|
35
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return "http_error";
|
|
36
|
+
const record = body;
|
|
37
|
+
if (typeof record.code === "string" && record.code.trim()) return record.code.trim();
|
|
38
|
+
const nested = record.error;
|
|
39
|
+
if (nested && typeof nested === "object" && !Array.isArray(nested)) {
|
|
40
|
+
const code = nested.code;
|
|
41
|
+
if (typeof code === "string" && code.trim()) return code.trim();
|
|
42
|
+
}
|
|
43
|
+
return "http_error";
|
|
44
|
+
}
|
|
22
45
|
var TopoloHttpError = class extends TopoloSdkError {
|
|
23
46
|
status;
|
|
24
47
|
body;
|
|
25
48
|
service;
|
|
26
49
|
path;
|
|
27
|
-
|
|
28
|
-
|
|
50
|
+
requestId;
|
|
51
|
+
retryAfter;
|
|
52
|
+
constructor(service, path, status, body, message, options = {}) {
|
|
53
|
+
super(extractHttpErrorCode(body), message ?? `HTTP ${status} from ${service}${path}`);
|
|
29
54
|
this.name = "TopoloHttpError";
|
|
30
55
|
this.status = status;
|
|
31
56
|
this.body = body;
|
|
32
57
|
this.service = service;
|
|
33
58
|
this.path = path;
|
|
59
|
+
this.requestId = options.requestId;
|
|
60
|
+
this.retryAfter = options.retryAfter;
|
|
34
61
|
}
|
|
35
62
|
};
|
|
36
63
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/sdk",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"topoloPublishedVersion": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
|
+
"topoloPublishedVersion": "0.9.8",
|
|
5
5
|
"description": "Typed client SDK for the Topolo platform. Used by TopoloCli, TopoloMCP, and third-party agents.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|