@magemetrics/core 0.11.0 → 0.11.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.js CHANGED
@@ -13,6 +13,7 @@ import { DefaultChatTransport } from 'ai';
13
13
  var HEADER_CLIENT_VERSION = "X-Client-Version";
14
14
  var HEADER_SP_TOKEN = "sp-access-token";
15
15
  var HEADER_API_KEY = "X-Api-Key";
16
+ var HEADER_APPLICATION_NAME = "X-Application-Name";
16
17
  var ApiError = class extends Error {
17
18
  extra;
18
19
  response;
@@ -57,7 +58,7 @@ var addApiKeyHeader = (apiKey) => {
57
58
 
58
59
  // package.json
59
60
  var package_default = {
60
- version: "0.11.0"};
61
+ version: "0.11.3"};
61
62
 
62
63
  // src/core/MageMetricsEventEmitter.ts
63
64
  var MageMetricsEventEmitter = class {
@@ -469,7 +470,7 @@ function getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {
469
470
  };
470
471
  }
471
472
 
472
- // ../../node_modules/.pnpm/hono@4.11.7/node_modules/hono/dist/router/reg-exp-router/node.js
473
+ // ../../node_modules/.pnpm/hono@4.11.10/node_modules/hono/dist/router/reg-exp-router/node.js
473
474
  new Set(".\\+*[^]$()");
474
475
  var createRoute = (routeConfig) => {
475
476
  const route = {
@@ -495,9 +496,6 @@ var GetApiInformation = createRoute({
495
496
  path: "/api/v1/auth/apiInformation",
496
497
  operationId: "getApiInformation",
497
498
  tags: ["public"],
498
- request: {
499
- query: GetApiInformationInputSchema
500
- },
501
499
  responses: {
502
500
  200: {
503
501
  content: {
@@ -703,13 +701,7 @@ var ExternalAuthProvider = class {
703
701
  this.noAuthApiClient.use(throwOnError);
704
702
  this.noAuthApiClient.use(addVersionHeader(MM_CLIENT_VERSION2));
705
703
  this.noAuthApiClient.use(addApiKeyHeader(this.config.apiKey));
706
- const { data } = await this.noAuthApiClient.GET(GetApiInformation.path, {
707
- params: {
708
- query: {
709
- apiKey: this.config.apiKey
710
- }
711
- }
712
- });
704
+ const { data } = await this.noAuthApiClient.GET(GetApiInformation.path);
713
705
  if (!data) {
714
706
  throw new Error("Failed to fetch API information");
715
707
  }
@@ -842,7 +834,7 @@ var ExternalAuthProvider = class {
842
834
  }
843
835
  };
844
836
  var SupabaseUserHeaderSchema = z.object({
845
- [HEADER_SP_TOKEN]: z.string()
837
+ [HEADER_SP_TOKEN]: z.string().optional()
846
838
  });
847
839
  var SupabaseHeaderSchema = SupabaseUserHeaderSchema;
848
840
  var FEEDBACK_OPTIONS = [
@@ -1229,6 +1221,7 @@ var RetrieveFlowDataReports = createRoute({
1229
1221
  });
1230
1222
  createRoute({
1231
1223
  method: "get",
1224
+ hide: true,
1232
1225
  path: "/api/v1/flows/{flowId}/data-reports/last/status",
1233
1226
  operationId: "retrieveLatestDataReportStatus",
1234
1227
  tags: ["public"],
@@ -2947,7 +2940,7 @@ var MageMetricsChatTransport = class extends DefaultChatTransport {
2947
2940
  super({
2948
2941
  ...options,
2949
2942
  api: `${apiUrl}/api/v1/chat/${flowId}`,
2950
- prepareSendMessagesRequest({ messages, id: chatId }) {
2943
+ prepareSendMessagesRequest({ messages, id: chatId, body }) {
2951
2944
  const lastMessage = messages.at(-1);
2952
2945
  if (lastMessage && isToolResultMessage(lastMessage)) {
2953
2946
  lastMessage.metadata = {
@@ -2955,7 +2948,14 @@ var MageMetricsChatTransport = class extends DefaultChatTransport {
2955
2948
  isFrontendToolSubmission: true
2956
2949
  };
2957
2950
  }
2958
- return { body: { message: lastMessage, id: chatId } };
2951
+ const chatHints = body?.chatHints;
2952
+ return {
2953
+ body: {
2954
+ message: lastMessage,
2955
+ id: chatId,
2956
+ ...chatHints ? { chatHints } : {}
2957
+ }
2958
+ };
2959
2959
  }
2960
2960
  });
2961
2961
  }
@@ -3063,7 +3063,11 @@ var MageMetricsClient = class {
3063
3063
  }
3064
3064
  async getHeaders() {
3065
3065
  await this.waitForAuth();
3066
- return this.authProvider.getHeaders();
3066
+ const headers = await this.authProvider.getHeaders();
3067
+ if (this.config.applicationName) {
3068
+ headers[HEADER_APPLICATION_NAME] = this.config.applicationName;
3069
+ }
3070
+ return headers;
3067
3071
  }
3068
3072
  async logout() {
3069
3073
  await this.authProvider.logout();