merchi_sdk_js 0.8.0 → 0.9.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.
- package/package.json +1 -1
- package/src/agent_conversation.js +2 -0
- package/src/agent_token_usage.js +90 -0
- package/src/company.js +48 -0
- package/src/domain.js +28 -0
- package/src/job.js +3 -0
- package/src/merchi.js +3 -0
- package/src/user.js +1 -0
package/package.json
CHANGED
|
@@ -13,6 +13,8 @@ export function AgentConversation() {
|
|
|
13
13
|
addPropertyTo(this, 'conversationId');
|
|
14
14
|
addPropertyTo(this, 'initialPrompt');
|
|
15
15
|
addPropertyTo(this, 'creationDate');
|
|
16
|
+
addPropertyTo(this, 'entityType');
|
|
17
|
+
addPropertyTo(this, 'entityId');
|
|
16
18
|
addPropertyTo(this, 'serviceProvider');
|
|
17
19
|
addPropertyTo(this, 'user', User);
|
|
18
20
|
addPropertyTo(this, 'domain', Domain);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { generateUUID } from './uuid.js';
|
|
2
|
+
import {
|
|
3
|
+
addPropertyTo,
|
|
4
|
+
fromJson,
|
|
5
|
+
getOne,
|
|
6
|
+
getList,
|
|
7
|
+
fromJsonList,
|
|
8
|
+
} from './model.js';
|
|
9
|
+
import { Company } from './company.js';
|
|
10
|
+
import { Domain } from './domain.js';
|
|
11
|
+
import { User } from './user.js';
|
|
12
|
+
import { AgentConversation } from './agent_conversation.js';
|
|
13
|
+
import { SupportConversation } from './support_conversation.js';
|
|
14
|
+
import { Request } from './model.js';
|
|
15
|
+
|
|
16
|
+
export function AgentTokenUsage() {
|
|
17
|
+
this.resource = '/agent_token_usage';
|
|
18
|
+
this.json = 'agentTokenUsage';
|
|
19
|
+
this.temporaryId = generateUUID();
|
|
20
|
+
|
|
21
|
+
addPropertyTo(this, 'id');
|
|
22
|
+
addPropertyTo(this, 'createdAt');
|
|
23
|
+
addPropertyTo(this, 'companyId');
|
|
24
|
+
addPropertyTo(this, 'domainId');
|
|
25
|
+
addPropertyTo(this, 'userId');
|
|
26
|
+
addPropertyTo(this, 'company', Company);
|
|
27
|
+
addPropertyTo(this, 'domain', Domain);
|
|
28
|
+
addPropertyTo(this, 'user', User);
|
|
29
|
+
addPropertyTo(this, 'agentConversation', AgentConversation);
|
|
30
|
+
addPropertyTo(this, 'supportConversation', SupportConversation);
|
|
31
|
+
addPropertyTo(this, 'agentConversationId');
|
|
32
|
+
addPropertyTo(this, 'supportConversationId');
|
|
33
|
+
addPropertyTo(this, 'sourceType');
|
|
34
|
+
addPropertyTo(this, 'modelName');
|
|
35
|
+
addPropertyTo(this, 'promptTokens');
|
|
36
|
+
addPropertyTo(this, 'completionTokens');
|
|
37
|
+
addPropertyTo(this, 'totalTokens');
|
|
38
|
+
|
|
39
|
+
this.get = function (success, error, embed) {
|
|
40
|
+
var self = this;
|
|
41
|
+
function handleResponse(result) {
|
|
42
|
+
success(
|
|
43
|
+
fromJson(self, result[self.json], { makesDirty: false })
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
getOne({
|
|
47
|
+
resource: this.resource,
|
|
48
|
+
id: this.id(),
|
|
49
|
+
success: handleResponse,
|
|
50
|
+
error: error,
|
|
51
|
+
embed: embed,
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function AgentTokenUsages() {
|
|
57
|
+
this.resource = '/agent_token_usage';
|
|
58
|
+
this.json = 'agentTokenUsage';
|
|
59
|
+
this.single = AgentTokenUsage;
|
|
60
|
+
|
|
61
|
+
this.get = function (success, error, parameters) {
|
|
62
|
+
var self = this;
|
|
63
|
+
function handleResponse(result) {
|
|
64
|
+
success(fromJsonList(self, result, { makesDirty: false }));
|
|
65
|
+
}
|
|
66
|
+
getList(this.resource, handleResponse, error, parameters || {});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
this.record = function (payload, success, error) {
|
|
70
|
+
var request = new Request();
|
|
71
|
+
request.resource('/agent_token_usage/').method('POST');
|
|
72
|
+
Object.keys(payload || {}).forEach(function(key) {
|
|
73
|
+
var value = payload[key];
|
|
74
|
+
if (value !== undefined && value !== null) {
|
|
75
|
+
request.data().add(key, value);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
function handleResponse(status, data) {
|
|
79
|
+
if (status >= 200 && status < 300) {
|
|
80
|
+
if (success) {
|
|
81
|
+
success(data);
|
|
82
|
+
}
|
|
83
|
+
} else if (error) {
|
|
84
|
+
error(status, data);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
request.responseHandler(handleResponse).errorHandler(handleResponse);
|
|
88
|
+
request.send();
|
|
89
|
+
};
|
|
90
|
+
}
|
package/src/company.js
CHANGED
|
@@ -268,6 +268,54 @@ export function Company() {
|
|
|
268
268
|
var logo = this.logo();
|
|
269
269
|
return logo && logo.viewUrl() ? logo.viewUrl() : null;
|
|
270
270
|
}
|
|
271
|
+
|
|
272
|
+
function sendAnalyticsRequest(resource, method, success, error, queryParams) {
|
|
273
|
+
var request = new Request();
|
|
274
|
+
request.resource(resource).method(method || 'GET');
|
|
275
|
+
if (queryParams) {
|
|
276
|
+
Object.keys(queryParams).forEach(function(key) {
|
|
277
|
+
var value = queryParams[key];
|
|
278
|
+
if (value !== undefined && value !== null && value !== '') {
|
|
279
|
+
request.query().add(key, value);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function handleResponse(status, data) {
|
|
284
|
+
if (status >= 200 && status < 300) {
|
|
285
|
+
if (success) {
|
|
286
|
+
success(data);
|
|
287
|
+
}
|
|
288
|
+
} else if (error) {
|
|
289
|
+
error(status, data);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
request.responseHandler(handleResponse).errorHandler(handleResponse);
|
|
293
|
+
request.send();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
this.getAnalytics = function (success, error) {
|
|
297
|
+
sendAnalyticsRequest(
|
|
298
|
+
'/companies/' + this.id() + '/analytics/',
|
|
299
|
+
'GET',
|
|
300
|
+
success,
|
|
301
|
+
error
|
|
302
|
+
);
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
this.getAgentTokenAnalytics = function (queryParams, success, error) {
|
|
306
|
+
if (typeof queryParams === 'function') {
|
|
307
|
+
error = success;
|
|
308
|
+
success = queryParams;
|
|
309
|
+
queryParams = null;
|
|
310
|
+
}
|
|
311
|
+
sendAnalyticsRequest(
|
|
312
|
+
'/companies/' + this.id() + '/agent_token_analytics/',
|
|
313
|
+
'GET',
|
|
314
|
+
success,
|
|
315
|
+
error,
|
|
316
|
+
queryParams
|
|
317
|
+
);
|
|
318
|
+
};
|
|
271
319
|
}
|
|
272
320
|
|
|
273
321
|
export function Companies() {
|
package/src/domain.js
CHANGED
|
@@ -74,6 +74,8 @@ export function Domain() {
|
|
|
74
74
|
addPropertyTo(this, 'publicAccessRestricted');
|
|
75
75
|
addPropertyTo(this, 'showDomainToAccessibleEntitiesOnly')
|
|
76
76
|
addPropertyTo(this, 'enableNotifications');
|
|
77
|
+
addPropertyTo(this, 'assignToAgent');
|
|
78
|
+
addPropertyTo(this, 'merchiAgentUser', User);
|
|
77
79
|
addPropertyTo(this, 'enableEmailNotifications');
|
|
78
80
|
addPropertyTo(this, 'enableSmsNotifications');
|
|
79
81
|
addPropertyTo(this, 'seoDomainPages', SeoDomainPage);
|
|
@@ -791,6 +793,32 @@ export function Domain() {
|
|
|
791
793
|
args.error
|
|
792
794
|
);
|
|
793
795
|
};
|
|
796
|
+
|
|
797
|
+
this.getAnalytics = function (success, error) {
|
|
798
|
+
sendStorefrontRequest(
|
|
799
|
+
'/domains/' + this.id() + '/analytics/',
|
|
800
|
+
'GET',
|
|
801
|
+
null,
|
|
802
|
+
success,
|
|
803
|
+
error
|
|
804
|
+
);
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
this.getAgentTokenAnalytics = function (queryParams, success, error) {
|
|
808
|
+
if (typeof queryParams === 'function') {
|
|
809
|
+
error = success;
|
|
810
|
+
success = queryParams;
|
|
811
|
+
queryParams = null;
|
|
812
|
+
}
|
|
813
|
+
sendStorefrontRequest(
|
|
814
|
+
'/domains/' + this.id() + '/agent_token_analytics/',
|
|
815
|
+
'GET',
|
|
816
|
+
null,
|
|
817
|
+
success,
|
|
818
|
+
error,
|
|
819
|
+
queryParams
|
|
820
|
+
);
|
|
821
|
+
};
|
|
794
822
|
}
|
|
795
823
|
|
|
796
824
|
export function Domains() {
|
package/src/job.js
CHANGED
|
@@ -110,6 +110,9 @@ export function Job() {
|
|
|
110
110
|
addPropertyTo(this, 'canDeduct');
|
|
111
111
|
|
|
112
112
|
addPropertyTo(this, "needsDrafting");
|
|
113
|
+
addPropertyTo(this, "assignToAgent");
|
|
114
|
+
addPropertyTo(this, "agentLastRunAt");
|
|
115
|
+
addPropertyTo(this, "agentNextCheckAt");
|
|
113
116
|
addPropertyTo(this, "needsGroupBuy");
|
|
114
117
|
addPropertyTo(this, "needsProduction");
|
|
115
118
|
addPropertyTo(this, "needsShipping");
|
package/src/merchi.js
CHANGED
|
@@ -85,6 +85,7 @@ import { Quotes, Quote } from './quote.js';
|
|
|
85
85
|
import { Reminder, Reminders } from './reminder.js';
|
|
86
86
|
import { InternalTag, InternalTags } from './internal_tag.js';
|
|
87
87
|
import { AgentConversation, AgentConversations } from './agent_conversation.js';
|
|
88
|
+
import { AgentTokenUsage, AgentTokenUsages } from './agent_token_usage.js';
|
|
88
89
|
import { AgentSkill, AgentSkills } from './agent_skill.js';
|
|
89
90
|
import { AgentSkillVersion, AgentSkillVersions } from './agent_skill_version.js';
|
|
90
91
|
import { AgentSkillApproval, AgentSkillApprovals } from './agent_skill_approval.js';
|
|
@@ -1123,6 +1124,8 @@ export function merchi(backendUri, websocketUri) {
|
|
|
1123
1124
|
'notifications': new Notifications(),
|
|
1124
1125
|
'AgentConversation': AgentConversation,
|
|
1125
1126
|
'agentConversations': new AgentConversations(),
|
|
1127
|
+
'AgentTokenUsage': AgentTokenUsage,
|
|
1128
|
+
'agentTokenUsage': new AgentTokenUsages(),
|
|
1126
1129
|
'AgentSkill': AgentSkill,
|
|
1127
1130
|
'agentSkills': new AgentSkills(),
|
|
1128
1131
|
'AgentSkillVersion': AgentSkillVersion,
|
package/src/user.js
CHANGED
|
@@ -29,6 +29,7 @@ export function User() {
|
|
|
29
29
|
addPropertyTo(this, 'name');
|
|
30
30
|
addPropertyTo(this, 'userType');
|
|
31
31
|
addPropertyTo(this, 'registeredAsGuest');
|
|
32
|
+
addPropertyTo(this, 'isMerchiAgent');
|
|
32
33
|
addPropertyTo(this, 'registeredUnderDomains', Domain);
|
|
33
34
|
addPropertyTo(this, 'password');
|
|
34
35
|
addPropertyTo(this, 'resetToken');
|