@mastra/client-js 0.1.1 → 0.1.2-alpha.1

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @mastra/client-js@0.1.0 build /home/runner/work/mastra/mastra/client-sdks/client-js
2
+ > @mastra/client-js@0.1.2-alpha.1 build /home/runner/work/mastra/mastra/client-sdks/client-js
3
3
  > tsup-node src/index.ts --format esm --dts --clean --treeshake
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,8 +8,8 @@
8
8
  CLI Target: es2022
9
9
  CLI Cleaning output folder
10
10
  ESM Build start
11
- ESM dist/index.mjs 13.06 KB
12
- ESM ⚡️ Build success in 497ms
11
+ ESM dist/index.mjs 13.39 KB
12
+ ESM ⚡️ Build success in 574ms
13
13
  DTS Build start
14
- DTS ⚡️ Build success in 8627ms
14
+ DTS ⚡️ Build success in 9271ms
15
15
  DTS dist/index.d.mts 13.46 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 0.1.2-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [fe0fd01]
8
+ - @mastra/core@0.4.0-alpha.1
9
+
10
+ ## 0.1.2-alpha.0
11
+
12
+ ### Patch Changes
13
+
14
+ - 5297264: Fix build errors by changing contracts
15
+ - Updated dependencies [2fc618f]
16
+ - @mastra/core@0.4.0-alpha.0
17
+
3
18
  ## 0.1.1
4
19
 
5
20
  ### Patch Changes
package/dist/index.mjs CHANGED
@@ -444,16 +444,36 @@ var MastraClient = class extends BaseResource {
444
444
  getTelemetry(params) {
445
445
  const { name, scope, page, perPage, attribute } = params || {};
446
446
  const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
447
- const queryObj = {
448
- ...name ? { name } : {},
449
- ...scope ? { scope } : {},
450
- ...page ? { page: String(page) } : {},
451
- ...perPage ? { perPage: String(perPage) } : {},
447
+ ({
452
448
  ..._attribute?.length ? { attribute: _attribute } : {}
453
- };
454
- const hasQueryParams = Object.keys(queryObj).length > 0;
455
- const queryParams = hasQueryParams ? new URLSearchParams(queryObj) : "";
456
- return this.request(`/api/telemetry?${queryParams}`);
449
+ });
450
+ const searchParams = new URLSearchParams();
451
+ if (name) {
452
+ searchParams.set("name", name);
453
+ }
454
+ if (scope) {
455
+ searchParams.set("scope", scope);
456
+ }
457
+ if (page) {
458
+ searchParams.set("page", String(page));
459
+ }
460
+ if (perPage) {
461
+ searchParams.set("perPage", String(perPage));
462
+ }
463
+ if (_attribute) {
464
+ if (Array.isArray(_attribute)) {
465
+ for (const attr of _attribute) {
466
+ searchParams.append("attribute", attr);
467
+ }
468
+ } else {
469
+ searchParams.set("attribute", _attribute);
470
+ }
471
+ }
472
+ if (searchParams.size) {
473
+ return this.request(`/api/telemetry?${searchParams}`);
474
+ } else {
475
+ return this.request(`/api/telemetry`);
476
+ }
457
477
  }
458
478
  };
459
479
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.1.1",
3
+ "version": "0.1.2-alpha.1",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "types": "dist/index.d.mts",
@@ -20,7 +20,7 @@
20
20
  "json-schema": "^0.4.0",
21
21
  "zod": "^3.24.1",
22
22
  "zod-to-json-schema": "^3.24.1",
23
- "@mastra/core": "^0.3.0"
23
+ "@mastra/core": "^0.4.0-alpha.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@babel/preset-env": "^7.26.0",
package/src/client.ts CHANGED
@@ -163,11 +163,35 @@ export class MastraClient extends BaseResource {
163
163
  ...(page ? { page: String(page) } : {}),
164
164
  ...(perPage ? { perPage: String(perPage) } : {}),
165
165
  ...(_attribute?.length ? { attribute: _attribute } : {}),
166
- };
167
-
168
- const hasQueryParams = Object.keys(queryObj).length > 0;
169
-
170
- const queryParams = hasQueryParams ? new URLSearchParams(queryObj) : '';
171
- return this.request(`/api/telemetry?${queryParams}`);
166
+ } as const;
167
+
168
+ const searchParams = new URLSearchParams();
169
+ if (name) {
170
+ searchParams.set('name', name);
171
+ }
172
+ if (scope) {
173
+ searchParams.set('scope', scope);
174
+ }
175
+ if (page) {
176
+ searchParams.set('page', String(page));
177
+ }
178
+ if (perPage) {
179
+ searchParams.set('perPage', String(perPage));
180
+ }
181
+ if (_attribute) {
182
+ if (Array.isArray(_attribute)) {
183
+ for (const attr of _attribute) {
184
+ searchParams.append('attribute', attr);
185
+ }
186
+ } else {
187
+ searchParams.set('attribute', _attribute);
188
+ }
189
+ }
190
+
191
+ if (searchParams.size) {
192
+ return this.request(`/api/telemetry?${searchParams}`);
193
+ } else {
194
+ return this.request(`/api/telemetry`);
195
+ }
172
196
  }
173
197
  }