@mastra/client-js 1.60.1-alpha.2 → 1.60.1-alpha.4
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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +6 -6
- package/dist/docs/references/docs-server-mastra-client.md +2 -0
- package/dist/docs/references/reference-client-js-mastra-client.md +1 -1
- package/dist/index.cjs +36 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -5
- package/dist/index.js.map +1 -1
- package/dist/resources/base.d.ts +6 -0
- package/dist/resources/base.d.ts.map +1 -1
- package/dist/resources/observability.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +1 -0
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +11 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1188,6 +1188,24 @@ var MastraClientError = class extends Error {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
};
|
|
1190
1190
|
// src/resources/base.ts
|
|
1191
|
+
/**
|
|
1192
|
+
* Retry attempts applied when the caller has not configured one. Only read
|
|
1193
|
+
* methods keep this default; every other method is attempted once unless the
|
|
1194
|
+
* caller opts in with an explicit `retries` count.
|
|
1195
|
+
*/
|
|
1196
|
+
const DEFAULT_RETRIES = 3;
|
|
1197
|
+
/**
|
|
1198
|
+
* HTTP methods that read server state. A retried read only repeats a lookup,
|
|
1199
|
+
* so it is safe to retry by default. Methods outside this set (POST, PUT,
|
|
1200
|
+
* PATCH, DELETE and anything unrecognized) may already have applied a side
|
|
1201
|
+
* effect when the attempt failed, so they are not retried unless the caller
|
|
1202
|
+
* asks for it.
|
|
1203
|
+
*/
|
|
1204
|
+
const READ_METHODS = /* @__PURE__ */ new Set([
|
|
1205
|
+
"GET",
|
|
1206
|
+
"HEAD",
|
|
1207
|
+
"OPTIONS"
|
|
1208
|
+
]);
|
|
1191
1209
|
var BaseResource = class {
|
|
1192
1210
|
options;
|
|
1193
1211
|
apiPrefix;
|
|
@@ -1196,6 +1214,14 @@ var BaseResource = class {
|
|
|
1196
1214
|
this.apiPrefix = normalizeRoutePath(options.apiPrefix ?? "/api");
|
|
1197
1215
|
}
|
|
1198
1216
|
/**
|
|
1217
|
+
* Retry count for a request that only reads server state even though its HTTP method is not a
|
|
1218
|
+
* read method, such as a query sent as POST. It keeps the read default unless the client was
|
|
1219
|
+
* configured with an explicit `retries` count, which always wins.
|
|
1220
|
+
*/
|
|
1221
|
+
readRetries() {
|
|
1222
|
+
return this.options.retries ?? DEFAULT_RETRIES;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1199
1225
|
* Makes an HTTP request to the API with retries and exponential backoff
|
|
1200
1226
|
* @param path - The API endpoint path (without prefix, e.g., '/agents')
|
|
1201
1227
|
* @param options - Optional request configuration
|
|
@@ -1203,9 +1229,10 @@ var BaseResource = class {
|
|
|
1203
1229
|
*/
|
|
1204
1230
|
async request(path, options = {}) {
|
|
1205
1231
|
let lastError = null;
|
|
1206
|
-
const { baseUrl, retries:
|
|
1232
|
+
const { baseUrl, retries: configuredRetries, backoffMs = 100, maxBackoffMs = 1e3, headers = {}, credentials, fetch: customFetch } = this.options;
|
|
1207
1233
|
const { retries: requestRetries, ...fetchOptions } = options;
|
|
1208
|
-
const
|
|
1234
|
+
const method = (fetchOptions.method ?? "GET").toUpperCase();
|
|
1235
|
+
const retries = requestRetries ?? configuredRetries ?? (READ_METHODS.has(method) ? DEFAULT_RETRIES : 0);
|
|
1209
1236
|
if (!Number.isSafeInteger(retries) || retries < 0) throw new RangeError("retries must be a non-negative safe integer");
|
|
1210
1237
|
const signal = mergeAbortSignals(this.options.abortSignal, fetchOptions.signal);
|
|
1211
1238
|
const fetchFn = customFetch || fetch;
|
|
@@ -5509,6 +5536,7 @@ var Observability = class extends BaseResource {
|
|
|
5509
5536
|
return this.request("/observability/traces/aggregate", {
|
|
5510
5537
|
method: "POST",
|
|
5511
5538
|
body: params,
|
|
5539
|
+
retries: this.readRetries(),
|
|
5512
5540
|
signal: options?.signal
|
|
5513
5541
|
});
|
|
5514
5542
|
}
|
|
@@ -5520,7 +5548,8 @@ var Observability = class extends BaseResource {
|
|
|
5520
5548
|
aggregateSpans(params) {
|
|
5521
5549
|
return this.request("/observability/spans/aggregate", {
|
|
5522
5550
|
method: "POST",
|
|
5523
|
-
body: params
|
|
5551
|
+
body: params,
|
|
5552
|
+
retries: this.readRetries()
|
|
5524
5553
|
});
|
|
5525
5554
|
}
|
|
5526
5555
|
/** Returns canonical and observed fields available to the advanced trace-query grammar. */
|
|
@@ -5550,7 +5579,8 @@ var Observability = class extends BaseResource {
|
|
|
5550
5579
|
queryTraceThreads(params) {
|
|
5551
5580
|
return this.request("/observability/threads/query", {
|
|
5552
5581
|
method: "POST",
|
|
5553
|
-
body: params
|
|
5582
|
+
body: params,
|
|
5583
|
+
retries: this.readRetries()
|
|
5554
5584
|
});
|
|
5555
5585
|
}
|
|
5556
5586
|
/**
|
|
@@ -5562,7 +5592,8 @@ var Observability = class extends BaseResource {
|
|
|
5562
5592
|
querySpans(params) {
|
|
5563
5593
|
return this.request("/observability/spans/query", {
|
|
5564
5594
|
method: "POST",
|
|
5565
|
-
body: params
|
|
5595
|
+
body: params,
|
|
5596
|
+
retries: this.readRetries()
|
|
5566
5597
|
});
|
|
5567
5598
|
}
|
|
5568
5599
|
/**
|