merchi_sdk_ts 1.14.0 → 1.15.0

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,127 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
28
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
29
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
32
+ };
33
+ var __metadata = (this && this.__metadata) || function (k, v) {
34
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
35
+ };
36
+ import { Entity } from '../entity.js';
37
+ import { Company } from './company.js';
38
+ import { Domain } from './domain.js';
39
+ import { User } from './user.js';
40
+ import { AgentConversation } from './agent_conversation.js';
41
+ import { SupportConversation } from './support_conversation.js';
42
+ var AgentTokenUsage = /** @class */ (function (_super) {
43
+ __extends(AgentTokenUsage, _super);
44
+ function AgentTokenUsage() {
45
+ return _super !== null && _super.apply(this, arguments) || this;
46
+ }
47
+ var _a;
48
+ _a = AgentTokenUsage;
49
+ AgentTokenUsage.resourceName = 'agent_token_usage';
50
+ AgentTokenUsage.singularName = 'agentTokenUsage';
51
+ AgentTokenUsage.pluralName = 'agentTokenUsage';
52
+ AgentTokenUsage.record = function (payload, fetchOptions) {
53
+ var Constructor = _a;
54
+ var fetchOpts = __assign(__assign({}, (fetchOptions || {})), { method: 'POST', body: JSON.stringify(payload), headers: __assign(__assign({}, ((fetchOptions === null || fetchOptions === void 0 ? void 0 : fetchOptions.headers) || {})), { 'Content-Type': 'application/json' }) });
55
+ return Constructor.merchi.authenticatedFetch('/agent_token_usage/', fetchOpts);
56
+ };
57
+ __decorate([
58
+ AgentTokenUsage.property(),
59
+ __metadata("design:type", Number)
60
+ ], AgentTokenUsage.prototype, "id", void 0);
61
+ __decorate([
62
+ AgentTokenUsage.property({ type: Date }),
63
+ __metadata("design:type", Object)
64
+ ], AgentTokenUsage.prototype, "createdAt", void 0);
65
+ __decorate([
66
+ AgentTokenUsage.property(),
67
+ __metadata("design:type", Number)
68
+ ], AgentTokenUsage.prototype, "companyId", void 0);
69
+ __decorate([
70
+ AgentTokenUsage.property(),
71
+ __metadata("design:type", Number)
72
+ ], AgentTokenUsage.prototype, "domainId", void 0);
73
+ __decorate([
74
+ AgentTokenUsage.property(),
75
+ __metadata("design:type", Number)
76
+ ], AgentTokenUsage.prototype, "userId", void 0);
77
+ __decorate([
78
+ AgentTokenUsage.property({ type: Company }),
79
+ __metadata("design:type", Object)
80
+ ], AgentTokenUsage.prototype, "company", void 0);
81
+ __decorate([
82
+ AgentTokenUsage.property({ type: Domain }),
83
+ __metadata("design:type", Object)
84
+ ], AgentTokenUsage.prototype, "domain", void 0);
85
+ __decorate([
86
+ AgentTokenUsage.property({ type: User }),
87
+ __metadata("design:type", Object)
88
+ ], AgentTokenUsage.prototype, "user", void 0);
89
+ __decorate([
90
+ AgentTokenUsage.property({ type: AgentConversation }),
91
+ __metadata("design:type", Object)
92
+ ], AgentTokenUsage.prototype, "agentConversation", void 0);
93
+ __decorate([
94
+ AgentTokenUsage.property({ type: SupportConversation }),
95
+ __metadata("design:type", Object)
96
+ ], AgentTokenUsage.prototype, "supportConversation", void 0);
97
+ __decorate([
98
+ AgentTokenUsage.property(),
99
+ __metadata("design:type", Number)
100
+ ], AgentTokenUsage.prototype, "agentConversationId", void 0);
101
+ __decorate([
102
+ AgentTokenUsage.property(),
103
+ __metadata("design:type", Number)
104
+ ], AgentTokenUsage.prototype, "supportConversationId", void 0);
105
+ __decorate([
106
+ AgentTokenUsage.property(),
107
+ __metadata("design:type", String)
108
+ ], AgentTokenUsage.prototype, "sourceType", void 0);
109
+ __decorate([
110
+ AgentTokenUsage.property(),
111
+ __metadata("design:type", String)
112
+ ], AgentTokenUsage.prototype, "modelName", void 0);
113
+ __decorate([
114
+ AgentTokenUsage.property(),
115
+ __metadata("design:type", Number)
116
+ ], AgentTokenUsage.prototype, "promptTokens", void 0);
117
+ __decorate([
118
+ AgentTokenUsage.property(),
119
+ __metadata("design:type", Number)
120
+ ], AgentTokenUsage.prototype, "completionTokens", void 0);
121
+ __decorate([
122
+ AgentTokenUsage.property(),
123
+ __metadata("design:type", Number)
124
+ ], AgentTokenUsage.prototype, "totalTokens", void 0);
125
+ return AgentTokenUsage;
126
+ }(Entity));
127
+ export { AgentTokenUsage };
@@ -0,0 +1,6 @@
1
+ import { Merchi } from '../merchi.js';
2
+ test('can record agent token usage', function () {
3
+ var merchi = new Merchi();
4
+ var usage = new merchi.AgentTokenUsage();
5
+ expect(usage).toBeTruthy();
6
+ });
@@ -22,6 +22,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
22
22
  var __metadata = (this && this.__metadata) || function (k, v) {
23
23
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
24
24
  };
25
+ var __read = (this && this.__read) || function (o, n) {
26
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
27
+ if (!m) return o;
28
+ var i = m.call(o), r, ar = [], e;
29
+ try {
30
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
31
+ }
32
+ catch (error) { e = { error: error }; }
33
+ finally {
34
+ try {
35
+ if (r && !r.done && (m = i["return"])) m.call(i);
36
+ }
37
+ finally { if (e) throw e.error; }
38
+ }
39
+ return ar;
40
+ };
25
41
  import { Entity } from '../entity.js';
26
42
  import { MerchiFile } from './file.js';
27
43
  import { User } from './user.js';
@@ -29,7 +45,41 @@ import { SubscriptionPlan } from './subscription_plan.js';
29
45
  var Company = /** @class */ (function (_super) {
30
46
  __extends(Company, _super);
31
47
  function Company() {
32
- return _super !== null && _super.apply(this, arguments) || this;
48
+ var _this = _super !== null && _super.apply(this, arguments) || this;
49
+ _this.getCompanyId = function () {
50
+ if (_this.id === undefined || _this.id === null) {
51
+ throw new Error('id is undefined, did you forget to set it?');
52
+ }
53
+ return _this.id;
54
+ };
55
+ _this.analyticsRequest = function (resource, method, payload, queryParams) {
56
+ if (method === void 0) { method = 'GET'; }
57
+ var query = [];
58
+ if (queryParams) {
59
+ Object.entries(queryParams).forEach(function (_a) {
60
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
61
+ if (value !== undefined && value !== '') {
62
+ query.push([key, value]);
63
+ }
64
+ });
65
+ }
66
+ var fetchOptions = {
67
+ method: method,
68
+ query: query,
69
+ };
70
+ if (payload !== undefined) {
71
+ fetchOptions.body = JSON.stringify(payload);
72
+ fetchOptions.headers = { 'Content-Type': 'application/json' };
73
+ }
74
+ return _this.merchi.authenticatedFetch(resource, fetchOptions);
75
+ };
76
+ _this.getAnalytics = function () {
77
+ return _this.analyticsRequest("/companies/".concat(_this.getCompanyId(), "/analytics/"), 'GET');
78
+ };
79
+ _this.getAgentTokenAnalytics = function (queryParams) {
80
+ return _this.analyticsRequest("/companies/".concat(_this.getCompanyId(), "/agent_token_analytics/"), 'GET', undefined, queryParams);
81
+ };
82
+ return _this;
33
83
  }
34
84
  Company.resourceName = 'companies';
35
85
  Company.singularName = 'company';
@@ -169,6 +169,12 @@ var Domain = /** @class */ (function (_super) {
169
169
  _this.publishStorefrontV2Category = function (payload) {
170
170
  return _this.storefrontV2Request(_this.storefrontV2DomainResource('categories/publish/'), 'POST', payload);
171
171
  };
172
+ _this.getAnalytics = function () {
173
+ return _this.storefrontV2Request("/domains/".concat(_this.getDomainId(), "/analytics/"), 'GET');
174
+ };
175
+ _this.getAgentTokenAnalytics = function (queryParams) {
176
+ return _this.storefrontV2Request("/domains/".concat(_this.getDomainId(), "/agent_token_analytics/"), 'GET', undefined, queryParams);
177
+ };
172
178
  return _this;
173
179
  }
174
180
  Domain.resourceName = 'domains';
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Address } from './entities/address.js';
2
2
  import { AgentConversation } from './entities/agent_conversation.js';
3
+ import { AgentTokenUsage } from './entities/agent_token_usage.js';
3
4
  import { AgentSkill } from './entities/agent_skill.js';
4
5
  import { AgentSkillVersion } from './entities/agent_skill_version.js';
5
6
  import { AgentSkillApproval } from './entities/agent_skill_approval.js';
@@ -88,4 +89,4 @@ import * as request from './request.js';
88
89
  import * as util from './util/index.js';
89
90
  import * as pricing from './pricing/index.js';
90
91
  import { toastNotifications } from './toasts.js';
91
- export { constants, request, util, pricing, toastNotifications, Address, AgentConversation, AgentSkill, AgentSkillVersion, AgentSkillApproval, DomainChatSettings, SupportConversation, SupportMessage, Assignment, AutomaticPaymentRelationship, Bank, Cart, CartItem, CartShipmentGroup, CartShipmentQuote, Category, Company, CompanyInvitation, Component, ComponentTag, ComponentVersion, ProductForm, ProductFormVersion, CountryTax, Discount, DiscountGroup, Domain, DomainInvitation, DomainTag, Draft, DraftComment, DraftTemplate, EmailAddress, EmailCounter, EnrolledDomain, Entity, ExchangeRate, InternalTag, Inventory, InventoryUnitVariation, Invoice, Item, Job, JobComment, JobNote, JobOperationLog, MatchingInventory, Menu, MenuItem, Merchi, MerchiFile, Notification, Page, Payment, PaymentDevice, PhoneNumber, Product, ProductReview, ProductionComment, Quote, QuoteItem, Reminder, apiFetch, apiFetchWithProgress, Session, Shipment, ShipmentLog, ShipmentItem, ShipmentItemFulfillment, ShipmentMethod, ShipmentMethodVariation, ShortUrl, SubscriptionPlan, SupplyDomain, SystemRole, Theme, ThemeCssSetting, User, UserCompany, Variation, VariationField, VariationFieldsOption, VariationOption, VariationsGroup, generateUUID, getCookie };
92
+ export { constants, request, util, pricing, toastNotifications, Address, AgentConversation, AgentTokenUsage, AgentSkill, AgentSkillVersion, AgentSkillApproval, DomainChatSettings, SupportConversation, SupportMessage, Assignment, AutomaticPaymentRelationship, Bank, Cart, CartItem, CartShipmentGroup, CartShipmentQuote, Category, Company, CompanyInvitation, Component, ComponentTag, ComponentVersion, ProductForm, ProductFormVersion, CountryTax, Discount, DiscountGroup, Domain, DomainInvitation, DomainTag, Draft, DraftComment, DraftTemplate, EmailAddress, EmailCounter, EnrolledDomain, Entity, ExchangeRate, InternalTag, Inventory, InventoryUnitVariation, Invoice, Item, Job, JobComment, JobNote, JobOperationLog, MatchingInventory, Menu, MenuItem, Merchi, MerchiFile, Notification, Page, Payment, PaymentDevice, PhoneNumber, Product, ProductReview, ProductionComment, Quote, QuoteItem, Reminder, apiFetch, apiFetchWithProgress, Session, Shipment, ShipmentLog, ShipmentItem, ShipmentItemFulfillment, ShipmentMethod, ShipmentMethodVariation, ShortUrl, SubscriptionPlan, SupplyDomain, SystemRole, Theme, ThemeCssSetting, User, UserCompany, Variation, VariationField, VariationFieldsOption, VariationOption, VariationsGroup, generateUUID, getCookie };
package/dist/merchi.js CHANGED
@@ -84,6 +84,7 @@ import { Variation } from './entities/variation.js';
84
84
  import { CartItem } from './entities/cart_item.js';
85
85
  import { Address } from './entities/address.js';
86
86
  import { AgentConversation } from './entities/agent_conversation.js';
87
+ import { AgentTokenUsage } from './entities/agent_token_usage.js';
87
88
  import { AgentSkill } from './entities/agent_skill.js';
88
89
  import { AgentSkillVersion } from './entities/agent_skill_version.js';
89
90
  import { AgentSkillApproval } from './entities/agent_skill_approval.js';
@@ -269,6 +270,7 @@ var Merchi = /** @class */ (function () {
269
270
  this.VariationFieldsOption = this.setupClass(VariationFieldsOption);
270
271
  this.Address = this.setupClass(Address);
271
272
  this.AgentConversation = this.setupClass(AgentConversation);
273
+ this.AgentTokenUsage = this.setupClass(AgentTokenUsage);
272
274
  this.AgentSkill = this.setupClass(AgentSkill);
273
275
  this.AgentSkillVersion = this.setupClass(AgentSkillVersion);
274
276
  this.AgentSkillApproval = this.setupClass(AgentSkillApproval);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merchi_sdk_ts",
3
- "version": "1.14.0",
3
+ "version": "1.15.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "repository": "git@github.com:merchisdk/merchi_sdk_ts.git",
@@ -0,0 +1,49 @@
1
+ export interface AgentTokenAnalyticsSummary {
2
+ percentageDifference?: number | null;
3
+ totals?: number;
4
+ previousTotals?: number;
5
+ }
6
+
7
+ export interface AgentTokenAnalyticsTimeseries {
8
+ dates?: string[];
9
+ totalTokens?: number[];
10
+ promptTokens?: number[];
11
+ completionTokens?: number[];
12
+ }
13
+
14
+ export interface ProfileAnalyticsSummaryMetric {
15
+ percentageDifference?: number | null;
16
+ totals?: number | { total?: number; currency?: string };
17
+ previousTotals?: number | { total?: number; currency?: string };
18
+ }
19
+
20
+ export interface CompanyAnalyticsResponse {
21
+ totalJobs?: ProfileAnalyticsSummaryMetric;
22
+ completedJobs?: ProfileAnalyticsSummaryMetric;
23
+ totalInvoices?: ProfileAnalyticsSummaryMetric;
24
+ paymentsReceived?: ProfileAnalyticsSummaryMetric;
25
+ agentTokenUsage?: AgentTokenAnalyticsSummary;
26
+ }
27
+
28
+ export interface DomainAnalyticsResponse extends CompanyAnalyticsResponse {}
29
+
30
+ export interface AgentTokenUsageRecordPayload {
31
+ companyId?: number;
32
+ domainId?: number;
33
+ promptTokens?: number;
34
+ completionTokens?: number;
35
+ totalTokens?: number;
36
+ sourceType?: string;
37
+ modelName?: string;
38
+ agentConversationId?: number;
39
+ supportConversationId?: number;
40
+ }
41
+
42
+ export interface AgentTokenUsageRecordResponse {
43
+ agentTokenUsage?: {
44
+ id?: number;
45
+ companyId?: number;
46
+ domainId?: number;
47
+ totalTokens?: number;
48
+ };
49
+ }
@@ -0,0 +1,7 @@
1
+ import { Merchi } from '../merchi.js';
2
+
3
+ test('can record agent token usage', () => {
4
+ const merchi = new Merchi();
5
+ const usage = new merchi.AgentTokenUsage();
6
+ expect(usage).toBeTruthy();
7
+ });
@@ -0,0 +1,88 @@
1
+ import { Entity } from '../entity.js';
2
+ import { Company } from './company.js';
3
+ import { Domain } from './domain.js';
4
+ import { User } from './user.js';
5
+ import { AgentConversation } from './agent_conversation.js';
6
+ import { SupportConversation } from './support_conversation.js';
7
+ import type {
8
+ AgentTokenUsageRecordPayload,
9
+ AgentTokenUsageRecordResponse,
10
+ } from './agent_token_analytics.js';
11
+ import type { RequestOptions } from '../request.js';
12
+
13
+ export class AgentTokenUsage extends Entity {
14
+ protected static resourceName = 'agent_token_usage';
15
+ protected static singularName = 'agentTokenUsage';
16
+ protected static pluralName = 'agentTokenUsage';
17
+
18
+ @AgentTokenUsage.property()
19
+ public id?: number;
20
+
21
+ @AgentTokenUsage.property({type: Date})
22
+ public createdAt?: Date | null;
23
+
24
+ @AgentTokenUsage.property()
25
+ public companyId?: number;
26
+
27
+ @AgentTokenUsage.property()
28
+ public domainId?: number;
29
+
30
+ @AgentTokenUsage.property()
31
+ public userId?: number;
32
+
33
+ @AgentTokenUsage.property({type: Company})
34
+ public company?: Company | null;
35
+
36
+ @AgentTokenUsage.property({type: Domain})
37
+ public domain?: Domain | null;
38
+
39
+ @AgentTokenUsage.property({type: User})
40
+ public user?: User | null;
41
+
42
+ @AgentTokenUsage.property({type: AgentConversation})
43
+ public agentConversation?: AgentConversation | null;
44
+
45
+ @AgentTokenUsage.property({type: SupportConversation})
46
+ public supportConversation?: SupportConversation | null;
47
+
48
+ @AgentTokenUsage.property()
49
+ public agentConversationId?: number;
50
+
51
+ @AgentTokenUsage.property()
52
+ public supportConversationId?: number;
53
+
54
+ @AgentTokenUsage.property()
55
+ public sourceType?: string;
56
+
57
+ @AgentTokenUsage.property()
58
+ public modelName?: string;
59
+
60
+ @AgentTokenUsage.property()
61
+ public promptTokens?: number;
62
+
63
+ @AgentTokenUsage.property()
64
+ public completionTokens?: number;
65
+
66
+ @AgentTokenUsage.property()
67
+ public totalTokens?: number;
68
+
69
+ public static record = (
70
+ payload: AgentTokenUsageRecordPayload,
71
+ fetchOptions?: RequestOptions
72
+ ): Promise<AgentTokenUsageRecordResponse> => {
73
+ const Constructor = this as typeof AgentTokenUsage;
74
+ const fetchOpts: RequestOptions = {
75
+ ...(fetchOptions || {}),
76
+ method: 'POST',
77
+ body: JSON.stringify(payload),
78
+ headers: {
79
+ ...(fetchOptions?.headers || {}),
80
+ 'Content-Type': 'application/json',
81
+ },
82
+ };
83
+ return Constructor.merchi.authenticatedFetch(
84
+ '/agent_token_usage/',
85
+ fetchOpts
86
+ ) as Promise<AgentTokenUsageRecordResponse>;
87
+ };
88
+ }
@@ -19,6 +19,11 @@ import { User } from './user.js';
19
19
  import { UserCompany } from './user_company.js';
20
20
  import { SubscriptionPlan } from './subscription_plan.js';
21
21
  import { PaymentDevice } from './payment_device.js';
22
+ import type {
23
+ AgentTokenAnalyticsTimeseries,
24
+ CompanyAnalyticsResponse,
25
+ } from './agent_token_analytics.js';
26
+ import type { RequestOptions } from '../request.js';
22
27
 
23
28
  export class Company extends Entity {
24
29
  protected static resourceName = 'companies';
@@ -333,4 +338,54 @@ export class Company extends Entity {
333
338
 
334
339
  @Company.property({arrayType: 'Address'})
335
340
  public addresses?: Address[];
341
+
342
+ private getCompanyId = () => {
343
+ if (this.id === undefined || this.id === null) {
344
+ throw new Error('id is undefined, did you forget to set it?');
345
+ }
346
+ return this.id;
347
+ };
348
+
349
+ private analyticsRequest = (
350
+ resource: string,
351
+ method: 'GET' | 'POST' = 'GET',
352
+ payload?: Record<string, any>,
353
+ queryParams?: Record<string, string | undefined>
354
+ ) => {
355
+ const query: Array<[string, string]> = [];
356
+ if (queryParams) {
357
+ Object.entries(queryParams).forEach(([key, value]) => {
358
+ if (value !== undefined && value !== '') {
359
+ query.push([key, value]);
360
+ }
361
+ });
362
+ }
363
+ const fetchOptions: RequestOptions = {
364
+ method: method,
365
+ query: query,
366
+ };
367
+ if (payload !== undefined) {
368
+ fetchOptions.body = JSON.stringify(payload);
369
+ fetchOptions.headers = {'Content-Type': 'application/json'};
370
+ }
371
+ return this.merchi.authenticatedFetch(resource, fetchOptions);
372
+ };
373
+
374
+ public getAnalytics = (): Promise<CompanyAnalyticsResponse> => {
375
+ return this.analyticsRequest(
376
+ `/companies/${this.getCompanyId()}/analytics/`,
377
+ 'GET'
378
+ ) as Promise<CompanyAnalyticsResponse>;
379
+ };
380
+
381
+ public getAgentTokenAnalytics = (
382
+ queryParams?: Record<string, string | undefined>
383
+ ): Promise<AgentTokenAnalyticsTimeseries> => {
384
+ return this.analyticsRequest(
385
+ `/companies/${this.getCompanyId()}/agent_token_analytics/`,
386
+ 'GET',
387
+ undefined,
388
+ queryParams
389
+ ) as Promise<AgentTokenAnalyticsTimeseries>;
390
+ };
336
391
  }
@@ -5,6 +5,10 @@ import { DomainInvitation } from './domain_invitation.js';
5
5
  import { DomainTag } from './domain_tag.js';
6
6
  import { EnrolledDomain } from './enrolled_domain.js';
7
7
  import { Entity } from '../entity.js';
8
+ import type {
9
+ AgentTokenAnalyticsTimeseries,
10
+ DomainAnalyticsResponse,
11
+ } from './agent_token_analytics.js';
8
12
  import { MerchiFile } from './file.js';
9
13
  import { InternalTag } from './internal_tag.js';
10
14
  import { Invoice } from './invoice.js';
@@ -891,4 +895,22 @@ export class Domain extends Entity {
891
895
  payload
892
896
  ) as Promise<{categoryPublish: StorefrontV2CategoryPublishResult}>;
893
897
  };
898
+
899
+ public getAnalytics = (): Promise<DomainAnalyticsResponse> => {
900
+ return this.storefrontV2Request(
901
+ `/domains/${this.getDomainId()}/analytics/`,
902
+ 'GET'
903
+ ) as Promise<DomainAnalyticsResponse>;
904
+ };
905
+
906
+ public getAgentTokenAnalytics = (
907
+ queryParams?: Record<string, string | undefined>
908
+ ): Promise<AgentTokenAnalyticsTimeseries> => {
909
+ return this.storefrontV2Request(
910
+ `/domains/${this.getDomainId()}/agent_token_analytics/`,
911
+ 'GET',
912
+ undefined,
913
+ queryParams
914
+ ) as Promise<AgentTokenAnalyticsTimeseries>;
915
+ };
894
916
  }
package/src/index.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import { Address } from './entities/address.js';
2
2
  import { AgentConversation } from './entities/agent_conversation.js';
3
+ import { AgentTokenUsage } from './entities/agent_token_usage.js';
4
+ export type {
5
+ AgentTokenAnalyticsSummary,
6
+ AgentTokenAnalyticsTimeseries,
7
+ AgentTokenUsageRecordPayload,
8
+ AgentTokenUsageRecordResponse,
9
+ CompanyAnalyticsResponse,
10
+ DomainAnalyticsResponse,
11
+ ProfileAnalyticsSummaryMetric,
12
+ } from './entities/agent_token_analytics.js';
3
13
  import { AgentSkill } from './entities/agent_skill.js';
4
14
  import { AgentSkillVersion } from './entities/agent_skill_version.js';
5
15
  import { AgentSkillApproval } from './entities/agent_skill_approval.js';
@@ -101,6 +111,7 @@ export {
101
111
  toastNotifications,
102
112
  Address,
103
113
  AgentConversation,
114
+ AgentTokenUsage,
104
115
  AgentSkill,
105
116
  AgentSkillVersion,
106
117
  AgentSkillApproval,
package/src/merchi.ts CHANGED
@@ -78,6 +78,7 @@ import { Variation } from './entities/variation.js';
78
78
  import { CartItem } from './entities/cart_item.js';
79
79
  import { Address } from './entities/address.js';
80
80
  import { AgentConversation } from './entities/agent_conversation.js';
81
+ import { AgentTokenUsage } from './entities/agent_token_usage.js';
81
82
  import { AgentSkill } from './entities/agent_skill.js';
82
83
  import { AgentSkillVersion } from './entities/agent_skill_version.js';
83
84
  import { AgentSkillApproval } from './entities/agent_skill_approval.js';
@@ -169,6 +170,7 @@ export class Merchi {
169
170
  public Company: typeof Company;
170
171
  public Address: typeof Address;
171
172
  public AgentConversation: typeof AgentConversation;
173
+ public AgentTokenUsage: typeof AgentTokenUsage;
172
174
  public AgentSkill: typeof AgentSkill;
173
175
  public AgentSkillVersion: typeof AgentSkillVersion;
174
176
  public AgentSkillApproval: typeof AgentSkillApproval;
@@ -354,6 +356,7 @@ export class Merchi {
354
356
  ) as typeof VariationFieldsOption;
355
357
  this.Address = this.setupClass(Address) as typeof Address;
356
358
  this.AgentConversation = this.setupClass(AgentConversation) as typeof AgentConversation;
359
+ this.AgentTokenUsage = this.setupClass(AgentTokenUsage) as typeof AgentTokenUsage;
357
360
  this.AgentSkill = this.setupClass(AgentSkill) as typeof AgentSkill;
358
361
  this.AgentSkillVersion = this.setupClass(AgentSkillVersion) as typeof AgentSkillVersion;
359
362
  this.AgentSkillApproval = this.setupClass(AgentSkillApproval) as typeof AgentSkillApproval;