@topolo/sdk 0.14.1 → 0.14.3
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 +37 -2
- package/dist/index.js +37 -2
- package/dist/node/credential-store.cjs +37 -2
- package/dist/node/credential-store.js +37 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -163,6 +163,7 @@ var ERROR_CODE_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
|
|
|
163
163
|
var TOPOLO_REQUEST_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
164
164
|
var CLOUDFLARE_RAY_ID_PATTERN = /^[0-9a-f]{16}-[A-Z]{3}$/;
|
|
165
165
|
var PERMISSION_PATTERN = /^[a-z][a-z0-9_-]{0,63}(?:\.[a-z][a-z0-9_-]{0,63})*:(?:[a-z][a-z0-9_-]{0,63}|\*)$/;
|
|
166
|
+
var PUBLIC_FIELD_PATH_PATTERN = /^[$.a-z0-9_[\]-]{1,160}$/i;
|
|
166
167
|
var RETRY_AFTER_DATE_PATTERN = /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT$/;
|
|
167
168
|
var PUBLIC_DETAIL_SOURCES = /* @__PURE__ */ new Set([
|
|
168
169
|
"api_key_introspection",
|
|
@@ -275,7 +276,11 @@ function extractTopoloServiceErrorDetails(body) {
|
|
|
275
276
|
if (candidate === void 0) candidate = nestedRecord.details ?? nestedRecord;
|
|
276
277
|
}
|
|
277
278
|
if (candidate === void 0) candidate = record;
|
|
278
|
-
if (
|
|
279
|
+
if (Array.isArray(candidate)) {
|
|
280
|
+
const paths = canonicalTopoloValidationPaths(candidate);
|
|
281
|
+
return paths.length ? { paths } : void 0;
|
|
282
|
+
}
|
|
283
|
+
if (!candidate || typeof candidate !== "object") return void 0;
|
|
279
284
|
const source = candidate;
|
|
280
285
|
const safe = {};
|
|
281
286
|
for (const [key, value] of Object.entries(source)) {
|
|
@@ -312,12 +317,42 @@ function extractTopoloServiceErrorDetails(body) {
|
|
|
312
317
|
continue;
|
|
313
318
|
}
|
|
314
319
|
if (["missingFields", "fields", "paths"].includes(key) && Array.isArray(value)) {
|
|
315
|
-
const paths = value.filter((item) => typeof item === "string" &&
|
|
320
|
+
const paths = value.filter((item) => typeof item === "string" && PUBLIC_FIELD_PATH_PATTERN.test(item));
|
|
316
321
|
if (paths.length) safe[key] = paths;
|
|
317
322
|
}
|
|
318
323
|
}
|
|
319
324
|
return Object.keys(safe).length ? safe : void 0;
|
|
320
325
|
}
|
|
326
|
+
function canonicalTopoloValidationPaths(issues) {
|
|
327
|
+
const paths = [];
|
|
328
|
+
for (const issue of issues) {
|
|
329
|
+
if (!issue || typeof issue !== "object" || Array.isArray(issue)) continue;
|
|
330
|
+
const record = issue;
|
|
331
|
+
const path = canonicalTopoloValidationPath(record.field) ?? canonicalTopoloValidationPath(record.path);
|
|
332
|
+
if (path && !paths.includes(path)) paths.push(path);
|
|
333
|
+
if (paths.length === 32) break;
|
|
334
|
+
}
|
|
335
|
+
return paths;
|
|
336
|
+
}
|
|
337
|
+
function canonicalTopoloValidationPath(value) {
|
|
338
|
+
if (typeof value === "string") {
|
|
339
|
+
const path2 = value.trim();
|
|
340
|
+
return PUBLIC_FIELD_PATH_PATTERN.test(path2) ? path2 : void 0;
|
|
341
|
+
}
|
|
342
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > 32) return void 0;
|
|
343
|
+
const segments = value.map((segment) => {
|
|
344
|
+
if (typeof segment === "number" && Number.isSafeInteger(segment) && segment >= 0) {
|
|
345
|
+
return String(segment);
|
|
346
|
+
}
|
|
347
|
+
if (typeof segment === "string" && /^[a-z0-9_$-]{1,80}$/i.test(segment)) {
|
|
348
|
+
return segment;
|
|
349
|
+
}
|
|
350
|
+
return null;
|
|
351
|
+
});
|
|
352
|
+
if (segments.includes(null)) return void 0;
|
|
353
|
+
const path = segments.join(".");
|
|
354
|
+
return PUBLIC_FIELD_PATH_PATTERN.test(path) ? path : void 0;
|
|
355
|
+
}
|
|
321
356
|
function publicTopoloErrorMessage(error) {
|
|
322
357
|
const code = canonicalTopoloErrorCode(
|
|
323
358
|
typeof error === "string" ? error : error.code ?? extractTopoloServiceErrorCode(error.body)
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,7 @@ var ERROR_CODE_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
|
|
|
77
77
|
var TOPOLO_REQUEST_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
78
78
|
var CLOUDFLARE_RAY_ID_PATTERN = /^[0-9a-f]{16}-[A-Z]{3}$/;
|
|
79
79
|
var PERMISSION_PATTERN = /^[a-z][a-z0-9_-]{0,63}(?:\.[a-z][a-z0-9_-]{0,63})*:(?:[a-z][a-z0-9_-]{0,63}|\*)$/;
|
|
80
|
+
var PUBLIC_FIELD_PATH_PATTERN = /^[$.a-z0-9_[\]-]{1,160}$/i;
|
|
80
81
|
var RETRY_AFTER_DATE_PATTERN = /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT$/;
|
|
81
82
|
var PUBLIC_DETAIL_SOURCES = /* @__PURE__ */ new Set([
|
|
82
83
|
"api_key_introspection",
|
|
@@ -189,7 +190,11 @@ function extractTopoloServiceErrorDetails(body) {
|
|
|
189
190
|
if (candidate === void 0) candidate = nestedRecord.details ?? nestedRecord;
|
|
190
191
|
}
|
|
191
192
|
if (candidate === void 0) candidate = record;
|
|
192
|
-
if (
|
|
193
|
+
if (Array.isArray(candidate)) {
|
|
194
|
+
const paths = canonicalTopoloValidationPaths(candidate);
|
|
195
|
+
return paths.length ? { paths } : void 0;
|
|
196
|
+
}
|
|
197
|
+
if (!candidate || typeof candidate !== "object") return void 0;
|
|
193
198
|
const source = candidate;
|
|
194
199
|
const safe = {};
|
|
195
200
|
for (const [key, value] of Object.entries(source)) {
|
|
@@ -226,12 +231,42 @@ function extractTopoloServiceErrorDetails(body) {
|
|
|
226
231
|
continue;
|
|
227
232
|
}
|
|
228
233
|
if (["missingFields", "fields", "paths"].includes(key) && Array.isArray(value)) {
|
|
229
|
-
const paths = value.filter((item) => typeof item === "string" &&
|
|
234
|
+
const paths = value.filter((item) => typeof item === "string" && PUBLIC_FIELD_PATH_PATTERN.test(item));
|
|
230
235
|
if (paths.length) safe[key] = paths;
|
|
231
236
|
}
|
|
232
237
|
}
|
|
233
238
|
return Object.keys(safe).length ? safe : void 0;
|
|
234
239
|
}
|
|
240
|
+
function canonicalTopoloValidationPaths(issues) {
|
|
241
|
+
const paths = [];
|
|
242
|
+
for (const issue of issues) {
|
|
243
|
+
if (!issue || typeof issue !== "object" || Array.isArray(issue)) continue;
|
|
244
|
+
const record = issue;
|
|
245
|
+
const path = canonicalTopoloValidationPath(record.field) ?? canonicalTopoloValidationPath(record.path);
|
|
246
|
+
if (path && !paths.includes(path)) paths.push(path);
|
|
247
|
+
if (paths.length === 32) break;
|
|
248
|
+
}
|
|
249
|
+
return paths;
|
|
250
|
+
}
|
|
251
|
+
function canonicalTopoloValidationPath(value) {
|
|
252
|
+
if (typeof value === "string") {
|
|
253
|
+
const path2 = value.trim();
|
|
254
|
+
return PUBLIC_FIELD_PATH_PATTERN.test(path2) ? path2 : void 0;
|
|
255
|
+
}
|
|
256
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > 32) return void 0;
|
|
257
|
+
const segments = value.map((segment) => {
|
|
258
|
+
if (typeof segment === "number" && Number.isSafeInteger(segment) && segment >= 0) {
|
|
259
|
+
return String(segment);
|
|
260
|
+
}
|
|
261
|
+
if (typeof segment === "string" && /^[a-z0-9_$-]{1,80}$/i.test(segment)) {
|
|
262
|
+
return segment;
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
});
|
|
266
|
+
if (segments.includes(null)) return void 0;
|
|
267
|
+
const path = segments.join(".");
|
|
268
|
+
return PUBLIC_FIELD_PATH_PATTERN.test(path) ? path : void 0;
|
|
269
|
+
}
|
|
235
270
|
function publicTopoloErrorMessage(error) {
|
|
236
271
|
const code = canonicalTopoloErrorCode(
|
|
237
272
|
typeof error === "string" ? error : error.code ?? extractTopoloServiceErrorCode(error.body)
|
|
@@ -110,6 +110,7 @@ var ERROR_CODE_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
|
|
|
110
110
|
var TOPOLO_REQUEST_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
111
111
|
var CLOUDFLARE_RAY_ID_PATTERN = /^[0-9a-f]{16}-[A-Z]{3}$/;
|
|
112
112
|
var PERMISSION_PATTERN = /^[a-z][a-z0-9_-]{0,63}(?:\.[a-z][a-z0-9_-]{0,63})*:(?:[a-z][a-z0-9_-]{0,63}|\*)$/;
|
|
113
|
+
var PUBLIC_FIELD_PATH_PATTERN = /^[$.a-z0-9_[\]-]{1,160}$/i;
|
|
113
114
|
var RETRY_AFTER_DATE_PATTERN = /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT$/;
|
|
114
115
|
var PUBLIC_DETAIL_SOURCES = /* @__PURE__ */ new Set([
|
|
115
116
|
"api_key_introspection",
|
|
@@ -195,7 +196,11 @@ function extractTopoloServiceErrorDetails(body) {
|
|
|
195
196
|
if (candidate === void 0) candidate = nestedRecord.details ?? nestedRecord;
|
|
196
197
|
}
|
|
197
198
|
if (candidate === void 0) candidate = record;
|
|
198
|
-
if (
|
|
199
|
+
if (Array.isArray(candidate)) {
|
|
200
|
+
const paths = canonicalTopoloValidationPaths(candidate);
|
|
201
|
+
return paths.length ? { paths } : void 0;
|
|
202
|
+
}
|
|
203
|
+
if (!candidate || typeof candidate !== "object") return void 0;
|
|
199
204
|
const source = candidate;
|
|
200
205
|
const safe = {};
|
|
201
206
|
for (const [key, value] of Object.entries(source)) {
|
|
@@ -232,12 +237,42 @@ function extractTopoloServiceErrorDetails(body) {
|
|
|
232
237
|
continue;
|
|
233
238
|
}
|
|
234
239
|
if (["missingFields", "fields", "paths"].includes(key) && Array.isArray(value)) {
|
|
235
|
-
const paths = value.filter((item) => typeof item === "string" &&
|
|
240
|
+
const paths = value.filter((item) => typeof item === "string" && PUBLIC_FIELD_PATH_PATTERN.test(item));
|
|
236
241
|
if (paths.length) safe[key] = paths;
|
|
237
242
|
}
|
|
238
243
|
}
|
|
239
244
|
return Object.keys(safe).length ? safe : void 0;
|
|
240
245
|
}
|
|
246
|
+
function canonicalTopoloValidationPaths(issues) {
|
|
247
|
+
const paths = [];
|
|
248
|
+
for (const issue of issues) {
|
|
249
|
+
if (!issue || typeof issue !== "object" || Array.isArray(issue)) continue;
|
|
250
|
+
const record = issue;
|
|
251
|
+
const path = canonicalTopoloValidationPath(record.field) ?? canonicalTopoloValidationPath(record.path);
|
|
252
|
+
if (path && !paths.includes(path)) paths.push(path);
|
|
253
|
+
if (paths.length === 32) break;
|
|
254
|
+
}
|
|
255
|
+
return paths;
|
|
256
|
+
}
|
|
257
|
+
function canonicalTopoloValidationPath(value) {
|
|
258
|
+
if (typeof value === "string") {
|
|
259
|
+
const path2 = value.trim();
|
|
260
|
+
return PUBLIC_FIELD_PATH_PATTERN.test(path2) ? path2 : void 0;
|
|
261
|
+
}
|
|
262
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > 32) return void 0;
|
|
263
|
+
const segments = value.map((segment) => {
|
|
264
|
+
if (typeof segment === "number" && Number.isSafeInteger(segment) && segment >= 0) {
|
|
265
|
+
return String(segment);
|
|
266
|
+
}
|
|
267
|
+
if (typeof segment === "string" && /^[a-z0-9_$-]{1,80}$/i.test(segment)) {
|
|
268
|
+
return segment;
|
|
269
|
+
}
|
|
270
|
+
return null;
|
|
271
|
+
});
|
|
272
|
+
if (segments.includes(null)) return void 0;
|
|
273
|
+
const path = segments.join(".");
|
|
274
|
+
return PUBLIC_FIELD_PATH_PATTERN.test(path) ? path : void 0;
|
|
275
|
+
}
|
|
241
276
|
var TopoloHttpError = class extends TopoloSdkError {
|
|
242
277
|
status;
|
|
243
278
|
body;
|
|
@@ -63,6 +63,7 @@ var ERROR_CODE_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
|
|
|
63
63
|
var TOPOLO_REQUEST_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
64
64
|
var CLOUDFLARE_RAY_ID_PATTERN = /^[0-9a-f]{16}-[A-Z]{3}$/;
|
|
65
65
|
var PERMISSION_PATTERN = /^[a-z][a-z0-9_-]{0,63}(?:\.[a-z][a-z0-9_-]{0,63})*:(?:[a-z][a-z0-9_-]{0,63}|\*)$/;
|
|
66
|
+
var PUBLIC_FIELD_PATH_PATTERN = /^[$.a-z0-9_[\]-]{1,160}$/i;
|
|
66
67
|
var RETRY_AFTER_DATE_PATTERN = /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT$/;
|
|
67
68
|
var PUBLIC_DETAIL_SOURCES = /* @__PURE__ */ new Set([
|
|
68
69
|
"api_key_introspection",
|
|
@@ -148,7 +149,11 @@ function extractTopoloServiceErrorDetails(body) {
|
|
|
148
149
|
if (candidate === void 0) candidate = nestedRecord.details ?? nestedRecord;
|
|
149
150
|
}
|
|
150
151
|
if (candidate === void 0) candidate = record;
|
|
151
|
-
if (
|
|
152
|
+
if (Array.isArray(candidate)) {
|
|
153
|
+
const paths = canonicalTopoloValidationPaths(candidate);
|
|
154
|
+
return paths.length ? { paths } : void 0;
|
|
155
|
+
}
|
|
156
|
+
if (!candidate || typeof candidate !== "object") return void 0;
|
|
152
157
|
const source = candidate;
|
|
153
158
|
const safe = {};
|
|
154
159
|
for (const [key, value] of Object.entries(source)) {
|
|
@@ -185,12 +190,42 @@ function extractTopoloServiceErrorDetails(body) {
|
|
|
185
190
|
continue;
|
|
186
191
|
}
|
|
187
192
|
if (["missingFields", "fields", "paths"].includes(key) && Array.isArray(value)) {
|
|
188
|
-
const paths = value.filter((item) => typeof item === "string" &&
|
|
193
|
+
const paths = value.filter((item) => typeof item === "string" && PUBLIC_FIELD_PATH_PATTERN.test(item));
|
|
189
194
|
if (paths.length) safe[key] = paths;
|
|
190
195
|
}
|
|
191
196
|
}
|
|
192
197
|
return Object.keys(safe).length ? safe : void 0;
|
|
193
198
|
}
|
|
199
|
+
function canonicalTopoloValidationPaths(issues) {
|
|
200
|
+
const paths = [];
|
|
201
|
+
for (const issue of issues) {
|
|
202
|
+
if (!issue || typeof issue !== "object" || Array.isArray(issue)) continue;
|
|
203
|
+
const record = issue;
|
|
204
|
+
const path = canonicalTopoloValidationPath(record.field) ?? canonicalTopoloValidationPath(record.path);
|
|
205
|
+
if (path && !paths.includes(path)) paths.push(path);
|
|
206
|
+
if (paths.length === 32) break;
|
|
207
|
+
}
|
|
208
|
+
return paths;
|
|
209
|
+
}
|
|
210
|
+
function canonicalTopoloValidationPath(value) {
|
|
211
|
+
if (typeof value === "string") {
|
|
212
|
+
const path2 = value.trim();
|
|
213
|
+
return PUBLIC_FIELD_PATH_PATTERN.test(path2) ? path2 : void 0;
|
|
214
|
+
}
|
|
215
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > 32) return void 0;
|
|
216
|
+
const segments = value.map((segment) => {
|
|
217
|
+
if (typeof segment === "number" && Number.isSafeInteger(segment) && segment >= 0) {
|
|
218
|
+
return String(segment);
|
|
219
|
+
}
|
|
220
|
+
if (typeof segment === "string" && /^[a-z0-9_$-]{1,80}$/i.test(segment)) {
|
|
221
|
+
return segment;
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
});
|
|
225
|
+
if (segments.includes(null)) return void 0;
|
|
226
|
+
const path = segments.join(".");
|
|
227
|
+
return PUBLIC_FIELD_PATH_PATTERN.test(path) ? path : void 0;
|
|
228
|
+
}
|
|
194
229
|
var TopoloHttpError = class extends TopoloSdkError {
|
|
195
230
|
status;
|
|
196
231
|
body;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/sdk",
|
|
3
|
-
"version": "0.14.
|
|
4
|
-
"topoloPublishedVersion": "0.14.
|
|
3
|
+
"version": "0.14.3",
|
|
4
|
+
"topoloPublishedVersion": "0.14.3",
|
|
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",
|