@topolo/sdk 0.14.0 → 0.14.2

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 CHANGED
@@ -161,6 +161,7 @@ var ERROR_CODE_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
161
161
  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;
162
162
  var CLOUDFLARE_RAY_ID_PATTERN = /^[0-9a-f]{16}-[A-Z]{3}$/;
163
163
  var PERMISSION_PATTERN = /^[a-z][a-z0-9_-]{0,63}(?:\.[a-z][a-z0-9_-]{0,63})*:(?:[a-z][a-z0-9_-]{0,63}|\*)$/;
164
+ var PUBLIC_FIELD_PATH_PATTERN = /^[$.a-z0-9_[\]-]{1,160}$/i;
164
165
  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$/;
165
166
  var PUBLIC_DETAIL_SOURCES = /* @__PURE__ */ new Set([
166
167
  "api_key_introspection",
@@ -273,7 +274,11 @@ function extractTopoloServiceErrorDetails(body) {
273
274
  if (candidate === void 0) candidate = nestedRecord.details ?? nestedRecord;
274
275
  }
275
276
  if (candidate === void 0) candidate = record;
276
- if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) return void 0;
277
+ if (Array.isArray(candidate)) {
278
+ const paths = canonicalTopoloValidationPaths(candidate);
279
+ return paths.length ? { paths } : void 0;
280
+ }
281
+ if (!candidate || typeof candidate !== "object") return void 0;
277
282
  const source = candidate;
278
283
  const safe = {};
279
284
  for (const [key, value] of Object.entries(source)) {
@@ -310,12 +315,42 @@ function extractTopoloServiceErrorDetails(body) {
310
315
  continue;
311
316
  }
312
317
  if (["missingFields", "fields", "paths"].includes(key) && Array.isArray(value)) {
313
- const paths = value.filter((item) => typeof item === "string" && /^[$.a-z0-9_[\]-]{1,160}$/i.test(item));
318
+ const paths = value.filter((item) => typeof item === "string" && PUBLIC_FIELD_PATH_PATTERN.test(item));
314
319
  if (paths.length) safe[key] = paths;
315
320
  }
316
321
  }
317
322
  return Object.keys(safe).length ? safe : void 0;
318
323
  }
324
+ function canonicalTopoloValidationPaths(issues) {
325
+ const paths = [];
326
+ for (const issue of issues) {
327
+ if (!issue || typeof issue !== "object" || Array.isArray(issue)) continue;
328
+ const record = issue;
329
+ const path = canonicalTopoloValidationPath(record.field) ?? canonicalTopoloValidationPath(record.path);
330
+ if (path && !paths.includes(path)) paths.push(path);
331
+ if (paths.length === 32) break;
332
+ }
333
+ return paths;
334
+ }
335
+ function canonicalTopoloValidationPath(value) {
336
+ if (typeof value === "string") {
337
+ const path2 = value.trim();
338
+ return PUBLIC_FIELD_PATH_PATTERN.test(path2) ? path2 : void 0;
339
+ }
340
+ if (!Array.isArray(value) || value.length === 0 || value.length > 32) return void 0;
341
+ const segments = value.map((segment) => {
342
+ if (typeof segment === "number" && Number.isSafeInteger(segment) && segment >= 0) {
343
+ return String(segment);
344
+ }
345
+ if (typeof segment === "string" && /^[a-z0-9_$-]{1,80}$/i.test(segment)) {
346
+ return segment;
347
+ }
348
+ return null;
349
+ });
350
+ if (segments.includes(null)) return void 0;
351
+ const path = segments.join(".");
352
+ return PUBLIC_FIELD_PATH_PATTERN.test(path) ? path : void 0;
353
+ }
319
354
  function publicTopoloErrorMessage(error) {
320
355
  const code = canonicalTopoloErrorCode(
321
356
  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 (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) return void 0;
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" && /^[$.a-z0-9_[\]-]{1,160}$/i.test(item));
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 (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) return void 0;
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" && /^[$.a-z0-9_[\]-]{1,160}$/i.test(item));
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 (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) return void 0;
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" && /^[$.a-z0-9_[\]-]{1,160}$/i.test(item));
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.0",
4
- "topoloPublishedVersion": "0.14.0",
3
+ "version": "0.14.2",
4
+ "topoloPublishedVersion": "0.14.2",
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",