@longvansoftware/service-js-client 1.13.9 → 1.14.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.
- package/dist/config/config.d.ts +2 -0
- package/dist/config/config.js +2 -0
- package/dist/src/graphql/computing/queries.d.ts +1 -0
- package/dist/src/graphql/computing/queries.js +11 -1
- package/dist/src/graphql/crm/queries.d.ts +0 -3
- package/dist/src/graphql/crm/queries.js +1 -28
- package/dist/src/graphql/crm_camping/queries.d.ts +3 -0
- package/dist/src/graphql/crm_camping/queries.js +28 -1
- package/dist/src/graphql/quicklab_service/mutations.d.ts +6 -0
- package/dist/src/graphql/quicklab_service/mutations.js +121 -0
- package/dist/src/graphql/quicklab_service/queries.d.ts +5 -0
- package/dist/src/graphql/quicklab_service/queries.js +75 -0
- package/dist/src/lib/SDK.d.ts +3 -0
- package/dist/src/lib/SDK.js +4 -0
- package/dist/src/lib/computing/index.d.ts +1 -0
- package/dist/src/lib/computing/index.js +16 -0
- package/dist/src/lib/crm/index.d.ts +0 -3
- package/dist/src/lib/crm/index.js +0 -55
- package/dist/src/lib/crm_camping/index.d.ts +3 -0
- package/dist/src/lib/crm_camping/index.js +55 -0
- package/dist/src/lib/quicklab_service/index.d.ts +15 -0
- package/dist/src/lib/quicklab_service/index.js +155 -0
- package/dist/src/lib/service.d.ts +14 -0
- package/dist/src/lib/service.js +101 -0
- package/dist/src/utils/build-field-string.d.ts +1 -0
- package/dist/src/utils/build-field-string.js +16 -0
- package/package.json +1 -1
package/dist/config/config.d.ts
CHANGED
@@ -18,6 +18,7 @@ export declare const environmentEndpoints: {
|
|
18
18
|
resource_permission: string;
|
19
19
|
cloud_rest: string;
|
20
20
|
accounting_service: string;
|
21
|
+
quicklab_service: string;
|
21
22
|
};
|
22
23
|
live: {
|
23
24
|
product: string;
|
@@ -38,5 +39,6 @@ export declare const environmentEndpoints: {
|
|
38
39
|
resource_permission: string;
|
39
40
|
cloud_rest: string;
|
40
41
|
accounting_service: string;
|
42
|
+
quicklab_service: string;
|
41
43
|
};
|
42
44
|
};
|
package/dist/config/config.js
CHANGED
@@ -21,6 +21,7 @@ exports.environmentEndpoints = {
|
|
21
21
|
resource_permission: "https://api-gateway.dev.longvan.vn/resource-permission-api/graphql",
|
22
22
|
cloud_rest: "https://api-gateway.dev.longvan.vn/cloud-service-api/v1",
|
23
23
|
accounting_service: "https://api-gateway.dev.longvan.vn/accounting-service/graphql/",
|
24
|
+
quicklab_service: "http://portal.dev.longvan.vn/quicklab-api/graphql",
|
24
25
|
},
|
25
26
|
live: {
|
26
27
|
product: "https://product-service.longvan.vn/product-service/graphql",
|
@@ -41,5 +42,6 @@ exports.environmentEndpoints = {
|
|
41
42
|
resource_permission: "https://api-gateway.longvan.vn/resource-permission-api/graphql",
|
42
43
|
cloud_rest: "https://api-gateway.longvan.vn/cloud-service-api/v1",
|
43
44
|
accounting_service: "https://api-gateway.longvan.vn/accounting-service/graphql/",
|
45
|
+
quicklab_service: "http://portal.longvan.vn/quicklab-api/graphql",
|
44
46
|
},
|
45
47
|
};
|
@@ -26,3 +26,4 @@ export declare const GET_RESOUCE_POOL_BY_SERVICE: DocumentNode;
|
|
26
26
|
export declare const GET_CONSOLE: DocumentNode;
|
27
27
|
export declare const GET_COMPUTING_WAIT_REVOKE: (fields?: string[]) => DocumentNode;
|
28
28
|
export declare const GET_STOREGE_MAPPING_FOR_DC: DocumentNode;
|
29
|
+
export declare const GET_COMPUTINGS_DYNAMIC: (fields?: string[]) => DocumentNode;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.GET_STOREGE_MAPPING_FOR_DC = exports.GET_COMPUTING_WAIT_REVOKE = exports.GET_CONSOLE = exports.GET_RESOUCE_POOL_BY_SERVICE = exports.GET_AVAILABLE_STORAGES_FOR_DC = exports.GET_AVAILABLE_SUBNET_IPS_BY_RESOURCEPOLL_ID = exports.GET_TEMPLATE = exports.GET_PORT_NATS_BY_SERVICE_ID = exports.GET_EDGES = exports.GET_COMPUTING_BY_SERVICE = exports.GET_COMPUTING_BY_CLUSTER = exports.GET_CLUSTER = exports.GET_CLUSTERS = exports.GET_LAB_INSTANCE = exports.GET_COMPUTINGS = exports.BACKUP_POINT = exports.DISK_USAGE_DATE_RANGE = exports.NETWORK_USAGE_DATE_RANGE = exports.CPU_USAGE_DATE_RANGE = exports.RAM_USAGE_DATE_RANGE = exports.DISK_USAGE_START_TIME = exports.NETWORK_USAGE_START_TIME = exports.CPU_USAGE_START_TIME = exports.RAM_USAGE_START_TIME = exports.SNAP_SHOTS = exports.PORTNATS = exports.COMPUTING_DETAIL = void 0;
|
3
|
+
exports.GET_COMPUTINGS_DYNAMIC = exports.GET_STOREGE_MAPPING_FOR_DC = exports.GET_COMPUTING_WAIT_REVOKE = exports.GET_CONSOLE = exports.GET_RESOUCE_POOL_BY_SERVICE = exports.GET_AVAILABLE_STORAGES_FOR_DC = exports.GET_AVAILABLE_SUBNET_IPS_BY_RESOURCEPOLL_ID = exports.GET_TEMPLATE = exports.GET_PORT_NATS_BY_SERVICE_ID = exports.GET_EDGES = exports.GET_COMPUTING_BY_SERVICE = exports.GET_COMPUTING_BY_CLUSTER = exports.GET_CLUSTER = exports.GET_CLUSTERS = exports.GET_LAB_INSTANCE = exports.GET_COMPUTINGS = exports.BACKUP_POINT = exports.DISK_USAGE_DATE_RANGE = exports.NETWORK_USAGE_DATE_RANGE = exports.CPU_USAGE_DATE_RANGE = exports.RAM_USAGE_DATE_RANGE = exports.DISK_USAGE_START_TIME = exports.NETWORK_USAGE_START_TIME = exports.CPU_USAGE_START_TIME = exports.RAM_USAGE_START_TIME = exports.SNAP_SHOTS = exports.PORTNATS = exports.COMPUTING_DETAIL = void 0;
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
5
5
|
exports.COMPUTING_DETAIL = (0, graphql_tag_1.gql) `
|
6
6
|
query ComputingDetail($computingId: String!) {
|
@@ -578,3 +578,13 @@ exports.GET_STOREGE_MAPPING_FOR_DC = (0, graphql_tag_1.gql) `
|
|
578
578
|
}
|
579
579
|
}
|
580
580
|
`;
|
581
|
+
const GET_COMPUTINGS_DYNAMIC = (fields = []) => {
|
582
|
+
const fieldStr = fields.join("\n ");
|
583
|
+
const hasFields = fields.length > 0;
|
584
|
+
return (0, graphql_tag_1.gql) `
|
585
|
+
query GetComputings($userId: String!) {
|
586
|
+
getComputings(userId: $userId) ${hasFields ? `{ ${fieldStr} }` : ""}
|
587
|
+
}
|
588
|
+
`;
|
589
|
+
};
|
590
|
+
exports.GET_COMPUTINGS_DYNAMIC = GET_COMPUTINGS_DYNAMIC;
|
@@ -3,9 +3,6 @@ export declare const GET_LIST_TODO: import("graphql").DocumentNode;
|
|
3
3
|
export declare const GET_LIST_WORK_EFFORT_TYPE: import("graphql").DocumentNode;
|
4
4
|
export declare const GET_LIST_TICKET: import("graphql").DocumentNode;
|
5
5
|
export declare const GET_TICKET_BY_ID: import("graphql").DocumentNode;
|
6
|
-
export declare const GET_AVERAGE_RATING: import("graphql").DocumentNode;
|
7
|
-
export declare const GET_URL_EVALUATION: import("graphql").DocumentNode;
|
8
|
-
export declare const GET_NUMBER_OF_TICKET_EVALUATION: import("graphql").DocumentNode;
|
9
6
|
export declare const GET_ATTACHMENT_BY_WORK_EFFORT_ID: import("graphql").DocumentNode;
|
10
7
|
export declare const GET_LIST_COMMENT: import("graphql").DocumentNode;
|
11
8
|
export declare const GET_RESUME_ID_BY_RESOURCE: import("graphql").DocumentNode;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.GET_RESUME_DOMAIN_BY_SERVICE_ID = exports.GET_REUSME_BY_CUSTOMER_ID = exports.GET_RESUME_CONTACT = exports.GET_RESUME_ID_BY_RESOURCE = exports.GET_LIST_COMMENT = exports.GET_ATTACHMENT_BY_WORK_EFFORT_ID = exports.
|
3
|
+
exports.GET_RESUME_DOMAIN_BY_SERVICE_ID = exports.GET_REUSME_BY_CUSTOMER_ID = exports.GET_RESUME_CONTACT = exports.GET_RESUME_ID_BY_RESOURCE = exports.GET_LIST_COMMENT = exports.GET_ATTACHMENT_BY_WORK_EFFORT_ID = exports.GET_TICKET_BY_ID = exports.GET_LIST_TICKET = exports.GET_LIST_WORK_EFFORT_TYPE = exports.GET_LIST_TODO = exports.GET_LIST_OPPORTUNITY_QUERY = void 0;
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
5
5
|
exports.GET_LIST_OPPORTUNITY_QUERY = (0, graphql_tag_1.gql) `
|
6
6
|
query GetListOpportunity(
|
@@ -218,33 +218,6 @@ exports.GET_TICKET_BY_ID = (0, graphql_tag_1.gql) `
|
|
218
218
|
}
|
219
219
|
}
|
220
220
|
`;
|
221
|
-
exports.GET_AVERAGE_RATING = (0, graphql_tag_1.gql) `
|
222
|
-
query GetAverageRating($targetIds: [String]!, $customerId: String, $evaluationType: String, $orgId: String) {
|
223
|
-
getAverageRating(targetIds: $targetIds, customerId: $customerId, evaluationType: $evaluationType, orgId: $orgId,) {
|
224
|
-
url
|
225
|
-
targetId
|
226
|
-
evaluationType
|
227
|
-
averageRating
|
228
|
-
haveEvaluation
|
229
|
-
}
|
230
|
-
}
|
231
|
-
`;
|
232
|
-
exports.GET_URL_EVALUATION = (0, graphql_tag_1.gql) `
|
233
|
-
query GetUrlEvaluation($targetIds: [String]!, $customerId: String, $evaluationType: String, $orgId: String) {
|
234
|
-
getUrlEvaluation(targetIds: $targetIds, customerId: $customerId, evaluationType: $evaluationType, orgId: $orgId,) {
|
235
|
-
url
|
236
|
-
targetId
|
237
|
-
evaluationType
|
238
|
-
averageRating
|
239
|
-
haveEvaluation
|
240
|
-
}
|
241
|
-
}
|
242
|
-
`;
|
243
|
-
exports.GET_NUMBER_OF_TICKET_EVALUATION = (0, graphql_tag_1.gql) `
|
244
|
-
query GetNumberOfTicketEvaluation($customerId: String, $orgId: String) {
|
245
|
-
getNumberOfTicketEvaluation(customerId: $customerId, orgId: $orgId,)
|
246
|
-
}
|
247
|
-
`;
|
248
221
|
exports.GET_ATTACHMENT_BY_WORK_EFFORT_ID = (0, graphql_tag_1.gql) `
|
249
222
|
query GetAttachmentByWorkEffortId(
|
250
223
|
$partyId: String!
|
@@ -2,3 +2,6 @@ export declare const SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION: import("graphql")
|
|
2
2
|
export declare const GET_CAMPAIGN_ACTION_BY_ID: import("graphql").DocumentNode;
|
3
3
|
export declare const SUGGEST_VOUCHER: import("graphql").DocumentNode;
|
4
4
|
export declare const GET_VOUCHERS: import("graphql").DocumentNode;
|
5
|
+
export declare const GET_AVERAGE_RATING: import("graphql").DocumentNode;
|
6
|
+
export declare const GET_URL_EVALUATION: import("graphql").DocumentNode;
|
7
|
+
export declare const GET_NUMBER_OF_TICKET_EVALUATION: import("graphql").DocumentNode;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.GET_VOUCHERS = exports.SUGGEST_VOUCHER = exports.GET_CAMPAIGN_ACTION_BY_ID = exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = void 0;
|
3
|
+
exports.GET_NUMBER_OF_TICKET_EVALUATION = exports.GET_URL_EVALUATION = exports.GET_AVERAGE_RATING = exports.GET_VOUCHERS = exports.SUGGEST_VOUCHER = exports.GET_CAMPAIGN_ACTION_BY_ID = exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = void 0;
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
5
5
|
exports.SEARCH_PRODUCT_QUANTITY_PROMOTION_ACTION = (0, graphql_tag_1.gql) `
|
6
6
|
query SearchProductQuantityPromotionAction(
|
@@ -182,3 +182,30 @@ exports.GET_VOUCHERS = (0, graphql_tag_1.gql) `
|
|
182
182
|
}
|
183
183
|
}
|
184
184
|
`;
|
185
|
+
exports.GET_AVERAGE_RATING = (0, graphql_tag_1.gql) `
|
186
|
+
query GetAverageRating($targetIds: [String]!, $customerId: String!, $evaluationType: String!, $orgId: String!) {
|
187
|
+
getAverageRating(targetIds: $targetIds, customerId: $customerId, evaluationType: $evaluationType, orgId: $orgId) {
|
188
|
+
url
|
189
|
+
targetId
|
190
|
+
evaluationType
|
191
|
+
averageRating
|
192
|
+
haveEvaluation
|
193
|
+
}
|
194
|
+
}
|
195
|
+
`;
|
196
|
+
exports.GET_URL_EVALUATION = (0, graphql_tag_1.gql) `
|
197
|
+
query GetUrlEvaluation($targetIds: [String]!, $customerId: String!, $evaluationType: String!, $orgId: String!) {
|
198
|
+
getUrlEvaluation(targetIds: $targetIds, customerId: $customerId, evaluationType: $evaluationType, orgId: $orgId,) {
|
199
|
+
url
|
200
|
+
targetId
|
201
|
+
evaluationType
|
202
|
+
averageRating
|
203
|
+
haveEvaluation
|
204
|
+
}
|
205
|
+
}
|
206
|
+
`;
|
207
|
+
exports.GET_NUMBER_OF_TICKET_EVALUATION = (0, graphql_tag_1.gql) `
|
208
|
+
query GetNumberOfTicketEvaluation($customerId: String!, $orgId: String!) {
|
209
|
+
getNumberOfTicketEvaluation(customerId: $customerId, orgId: $orgId,)
|
210
|
+
}
|
211
|
+
`;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { DocumentNode } from "graphql";
|
2
|
+
export declare const CREATE_LAB_SESSION_BY_TEMPLATE_ID: DocumentNode;
|
3
|
+
export declare const CREATE_LAB_SESSION_BY_LAB_SESSION_ID: DocumentNode;
|
4
|
+
export declare const CREATE_LAB_SESSION_BY_COMPUTING_ID: DocumentNode;
|
5
|
+
export declare const UPDATE_END_TIME_LAB_SESSION: DocumentNode;
|
6
|
+
export declare const STOP_LAB_SESSION: DocumentNode;
|
@@ -0,0 +1,121 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.STOP_LAB_SESSION = exports.UPDATE_END_TIME_LAB_SESSION = exports.CREATE_LAB_SESSION_BY_COMPUTING_ID = exports.CREATE_LAB_SESSION_BY_LAB_SESSION_ID = exports.CREATE_LAB_SESSION_BY_TEMPLATE_ID = void 0;
|
4
|
+
const graphql_tag_1 = require("graphql-tag");
|
5
|
+
// Tạo phiên thực hành từ template
|
6
|
+
exports.CREATE_LAB_SESSION_BY_TEMPLATE_ID = (0, graphql_tag_1.gql) `
|
7
|
+
mutation CreateLabSessionByTemplateId(
|
8
|
+
$templateId: String!
|
9
|
+
$userId: String!
|
10
|
+
$articleId: String!
|
11
|
+
$typeLabSessionCode: String!
|
12
|
+
) {
|
13
|
+
createLabSessionByTemplateId(
|
14
|
+
templateId: $templateId
|
15
|
+
userId: $userId
|
16
|
+
articleId: $articleId
|
17
|
+
typeLabSessionCode: $typeLabSessionCode
|
18
|
+
) {
|
19
|
+
labSessionId
|
20
|
+
userId
|
21
|
+
typeLabSession
|
22
|
+
statusUseName
|
23
|
+
statusUse
|
24
|
+
startTime
|
25
|
+
endTime
|
26
|
+
note
|
27
|
+
articleId
|
28
|
+
articleTitle
|
29
|
+
computingId
|
30
|
+
computingName
|
31
|
+
templateId
|
32
|
+
templateName
|
33
|
+
productId
|
34
|
+
productName
|
35
|
+
}
|
36
|
+
}
|
37
|
+
`;
|
38
|
+
// Tạo phiên thực hành con từ phiên thực hành chính
|
39
|
+
exports.CREATE_LAB_SESSION_BY_LAB_SESSION_ID = (0, graphql_tag_1.gql) `
|
40
|
+
mutation CreateLabSessionByLabSessionId(
|
41
|
+
$labSessionId: String!
|
42
|
+
$userId: String!
|
43
|
+
$articleId: String!
|
44
|
+
) {
|
45
|
+
createLabSessionByLabSessionId(
|
46
|
+
labSessionId: $labSessionId
|
47
|
+
userId: $userId
|
48
|
+
articleId: $articleId
|
49
|
+
) {
|
50
|
+
labSessionId
|
51
|
+
userId
|
52
|
+
typeLabSession
|
53
|
+
statusUseName
|
54
|
+
statusUse
|
55
|
+
startTime
|
56
|
+
endTime
|
57
|
+
note
|
58
|
+
articleId
|
59
|
+
articleTitle
|
60
|
+
computingId
|
61
|
+
computingName
|
62
|
+
templateId
|
63
|
+
templateName
|
64
|
+
productId
|
65
|
+
productName
|
66
|
+
}
|
67
|
+
}
|
68
|
+
`;
|
69
|
+
// Tạo phiên thực hành từ computing của khách hàng
|
70
|
+
exports.CREATE_LAB_SESSION_BY_COMPUTING_ID = (0, graphql_tag_1.gql) `
|
71
|
+
mutation CreateLabSessionByComputingId(
|
72
|
+
$computingId: String!
|
73
|
+
$userId: String!
|
74
|
+
$articleId: String!
|
75
|
+
) {
|
76
|
+
createLabSessionByComputingId(
|
77
|
+
computingId: $computingId
|
78
|
+
userId: $userId
|
79
|
+
articleId: $articleId
|
80
|
+
) {
|
81
|
+
labSessionId
|
82
|
+
userId
|
83
|
+
typeLabSession
|
84
|
+
statusUseName
|
85
|
+
statusUse
|
86
|
+
startTime
|
87
|
+
endTime
|
88
|
+
note
|
89
|
+
articleId
|
90
|
+
articleTitle
|
91
|
+
computingId
|
92
|
+
computingName
|
93
|
+
templateId
|
94
|
+
templateName
|
95
|
+
productId
|
96
|
+
productName
|
97
|
+
}
|
98
|
+
}
|
99
|
+
`;
|
100
|
+
// Cập nhật lại thời gian thực hành mỗi phút 1 lần(setup realtime ở FE)
|
101
|
+
exports.UPDATE_END_TIME_LAB_SESSION = (0, graphql_tag_1.gql) `
|
102
|
+
mutation UpdateEndTimeLabSession($labSessionId: String!, $userId: String!) {
|
103
|
+
updateEndTimeLabSession(labSessionId: $labSessionId, userId: $userId) {
|
104
|
+
status
|
105
|
+
message
|
106
|
+
}
|
107
|
+
}
|
108
|
+
`;
|
109
|
+
// Dừng thực hành
|
110
|
+
exports.STOP_LAB_SESSION = (0, graphql_tag_1.gql) `
|
111
|
+
mutation StopLabSession(
|
112
|
+
$labSessionId: String!
|
113
|
+
$userId: String!
|
114
|
+
$note: String
|
115
|
+
) {
|
116
|
+
stopLabSession(labSessionId: $labSessionId, userId: $userId, note: $note) {
|
117
|
+
status
|
118
|
+
message
|
119
|
+
}
|
120
|
+
}
|
121
|
+
`;
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { DocumentNode } from "graphql";
|
2
|
+
export declare const GET_TEMPLATE_BY_ARTICLE_ID: DocumentNode;
|
3
|
+
export declare const GET_TYPE_LAB_SESSION: DocumentNode;
|
4
|
+
export declare const GET_LAB_SESSIONS_BY_USER_ID: DocumentNode;
|
5
|
+
export declare const GET_LAB_SESSIONS_BY_USER_ID_AND_ARTICLE_ID: DocumentNode;
|
@@ -0,0 +1,75 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.GET_LAB_SESSIONS_BY_USER_ID_AND_ARTICLE_ID = exports.GET_LAB_SESSIONS_BY_USER_ID = exports.GET_TYPE_LAB_SESSION = exports.GET_TEMPLATE_BY_ARTICLE_ID = void 0;
|
4
|
+
const graphql_tag_1 = require("graphql-tag");
|
5
|
+
// Danh sách template của bài lab
|
6
|
+
exports.GET_TEMPLATE_BY_ARTICLE_ID = (0, graphql_tag_1.gql) `
|
7
|
+
query GetTemplatesByArticleId($articleId: String!) {
|
8
|
+
getTemplatesByArticleId(articleId: $articleId) {
|
9
|
+
templateId
|
10
|
+
templateName
|
11
|
+
product {
|
12
|
+
id
|
13
|
+
title
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
`;
|
18
|
+
// Danh sách loại thực hành
|
19
|
+
exports.GET_TYPE_LAB_SESSION = (0, graphql_tag_1.gql) `
|
20
|
+
query {
|
21
|
+
getTypeLabSessions {
|
22
|
+
name
|
23
|
+
code
|
24
|
+
}
|
25
|
+
}
|
26
|
+
`;
|
27
|
+
// Danh sách phiên thực hành của người dùng
|
28
|
+
exports.GET_LAB_SESSIONS_BY_USER_ID = (0, graphql_tag_1.gql) `
|
29
|
+
query GetLabSessionsByUserId($userId: String!) {
|
30
|
+
getLabSessionsByUserId(userId: $userId) {
|
31
|
+
labSessionId
|
32
|
+
userId
|
33
|
+
typeLabSession
|
34
|
+
statusUseName
|
35
|
+
statusUse
|
36
|
+
startTime
|
37
|
+
endTime
|
38
|
+
note
|
39
|
+
articleId
|
40
|
+
articleTitle
|
41
|
+
computingId
|
42
|
+
computingName
|
43
|
+
templateId
|
44
|
+
templateName
|
45
|
+
productId
|
46
|
+
productName
|
47
|
+
}
|
48
|
+
}
|
49
|
+
`;
|
50
|
+
// Danh sách phiên thực hành theo bài lab của người dùng
|
51
|
+
exports.GET_LAB_SESSIONS_BY_USER_ID_AND_ARTICLE_ID = (0, graphql_tag_1.gql) `
|
52
|
+
query GetLabSessionsByUserIdAndArticleId(
|
53
|
+
$userId: String!
|
54
|
+
$articleId: String!
|
55
|
+
) {
|
56
|
+
getLabSessionsByUserIdAndArticleId(userId: $userId, articleId: $articleId) {
|
57
|
+
labSessionId
|
58
|
+
userId
|
59
|
+
typeLabSession
|
60
|
+
statusUseName
|
61
|
+
statusUse
|
62
|
+
startTime
|
63
|
+
endTime
|
64
|
+
note
|
65
|
+
articleId
|
66
|
+
articleTitle
|
67
|
+
computingId
|
68
|
+
computingName
|
69
|
+
templateId
|
70
|
+
templateName
|
71
|
+
productId
|
72
|
+
productName
|
73
|
+
}
|
74
|
+
}
|
75
|
+
`;
|
package/dist/src/lib/SDK.d.ts
CHANGED
@@ -16,6 +16,7 @@ import { ResourcePermissionService } from "./resource_permission";
|
|
16
16
|
import { CloudRestService } from "./cloud_rest";
|
17
17
|
import { OrderCloudRestService } from "./order_cloud_rest";
|
18
18
|
import { AccountingService } from "./accounting_service";
|
19
|
+
import { QuicklabService } from "./quicklab_service";
|
19
20
|
export interface Endpoints {
|
20
21
|
product: string;
|
21
22
|
crm: string;
|
@@ -35,6 +36,7 @@ export interface Endpoints {
|
|
35
36
|
cloud_rest: string;
|
36
37
|
order_cloud_rest: string;
|
37
38
|
accounting_service: string;
|
39
|
+
quicklab_service: string;
|
38
40
|
}
|
39
41
|
export declare class SDK {
|
40
42
|
orgId: string;
|
@@ -59,6 +61,7 @@ export declare class SDK {
|
|
59
61
|
cloud_rest: CloudRestService;
|
60
62
|
order_cloud_rest: OrderCloudRestService;
|
61
63
|
accounting_service: AccountingService;
|
64
|
+
quicklab_service: QuicklabService;
|
62
65
|
token: string | null;
|
63
66
|
private endpoints;
|
64
67
|
constructor(orgId: string, storeId: string, storefrontAccessToken: string, environment: string);
|
package/dist/src/lib/SDK.js
CHANGED
@@ -22,6 +22,7 @@ const resource_permission_1 = require("./resource_permission");
|
|
22
22
|
const cloud_rest_1 = require("./cloud_rest");
|
23
23
|
const order_cloud_rest_1 = require("./order_cloud_rest");
|
24
24
|
const accounting_service_1 = require("./accounting_service");
|
25
|
+
const quicklab_service_1 = require("./quicklab_service");
|
25
26
|
class SDK {
|
26
27
|
constructor(orgId, storeId, storefrontAccessToken, environment) {
|
27
28
|
this.orgId = orgId;
|
@@ -54,6 +55,7 @@ class SDK {
|
|
54
55
|
this.cloud_rest = new cloud_rest_1.CloudRestService(this.endpoints.cloud_rest, orgId, storeId);
|
55
56
|
this.order_cloud_rest = new order_cloud_rest_1.OrderCloudRestService(this.endpoints.order_cloud_rest, orgId, storeId);
|
56
57
|
this.accounting_service = new accounting_service_1.AccountingService(this.endpoints.accounting_service, orgId, storeId);
|
58
|
+
this.quicklab_service = new quicklab_service_1.QuicklabService(this.endpoints.quicklab_service, orgId, storeId);
|
57
59
|
// Initialize other services here
|
58
60
|
}
|
59
61
|
setToken(token) {
|
@@ -77,6 +79,7 @@ class SDK {
|
|
77
79
|
this.cloud_rest.setToken(token);
|
78
80
|
this.order_cloud_rest.setToken(token);
|
79
81
|
this.accounting_service.setToken(token);
|
82
|
+
this.quicklab_service.setToken(token);
|
80
83
|
// Set token for other services here
|
81
84
|
}
|
82
85
|
// các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
|
@@ -102,6 +105,7 @@ class SDK {
|
|
102
105
|
this.cloud_rest = new cloud_rest_1.CloudRestService(this.endpoints.cloud_rest, this.orgId, storeId);
|
103
106
|
this.order_cloud_rest = new order_cloud_rest_1.OrderCloudRestService(this.endpoints.order_cloud_rest, this.orgId, storeId);
|
104
107
|
this.accounting_service = new accounting_service_1.AccountingService(this.endpoints.accounting_service, this.orgId, storeId);
|
108
|
+
this.quicklab_service = new quicklab_service_1.QuicklabService(this.endpoints.quicklab_service, this.orgId, storeId);
|
105
109
|
}
|
106
110
|
}
|
107
111
|
exports.SDK = SDK;
|
@@ -60,4 +60,5 @@ export declare class ComputingService extends Service {
|
|
60
60
|
getStorageMappingForDC(resourcePoolId: string): Promise<any>;
|
61
61
|
updateCPU(computingId: string, socket: number, corePerSocket: number, updateBy: string): Promise<any>;
|
62
62
|
updateRAM(computingId: string, size: number, unit: string, updateBy: string): Promise<any>;
|
63
|
+
getComputingsDynamic(userId: string, fields: string[]): Promise<any>;
|
63
64
|
}
|
@@ -890,5 +890,21 @@ class ComputingService extends serviceSDK_1.Service {
|
|
890
890
|
}
|
891
891
|
});
|
892
892
|
}
|
893
|
+
getComputingsDynamic(userId, fields) {
|
894
|
+
return __awaiter(this, void 0, void 0, function* () {
|
895
|
+
const query = (0, queries_1.GET_COMPUTINGS_DYNAMIC)(fields);
|
896
|
+
const variables = {
|
897
|
+
userId,
|
898
|
+
};
|
899
|
+
try {
|
900
|
+
const response = yield this.graphqlQueryV2(query, variables);
|
901
|
+
return response.getComputings;
|
902
|
+
}
|
903
|
+
catch (error) {
|
904
|
+
console.log(`Error fetching get getComputingsDynamic method: ${error}`);
|
905
|
+
throw error;
|
906
|
+
}
|
907
|
+
});
|
908
|
+
}
|
893
909
|
}
|
894
910
|
exports.ComputingService = ComputingService;
|
@@ -16,9 +16,6 @@ export declare class CrmService extends Service {
|
|
16
16
|
getListTicket(performerId: string, getTicketRequest: getTicketRequest): Promise<any>;
|
17
17
|
addTicket(performerId: string, addTicketRequest: AddTicketRequest, addAttachmentRequest: [AddAttachmentRequest]): Promise<any>;
|
18
18
|
getTicketById(ticketId: string): Promise<any>;
|
19
|
-
getAverageRating(targetIds: [string], customerId: string, evaluationType: string): Promise<any>;
|
20
|
-
getUrlEvaluation(targetIds: [string], customerId: string, evaluationType: string): Promise<any>;
|
21
|
-
getNumberOfTicketEvaluation(customerId: string): Promise<any>;
|
22
19
|
getAttachmentByWorkEffortId(workEffortIds: [string]): Promise<any>;
|
23
20
|
getListComment(getCommentRequest: GetCommentRequest): Promise<any>;
|
24
21
|
addComment(params: any): Promise<any>;
|
@@ -240,61 +240,6 @@ class CrmService extends serviceSDK_1.Service {
|
|
240
240
|
}
|
241
241
|
});
|
242
242
|
}
|
243
|
-
getAverageRating(targetIds, customerId, evaluationType) {
|
244
|
-
return __awaiter(this, void 0, void 0, function* () {
|
245
|
-
const query = queries_1.GET_AVERAGE_RATING;
|
246
|
-
const variables = {
|
247
|
-
targetIds,
|
248
|
-
customerId,
|
249
|
-
evaluationType,
|
250
|
-
orgId: this.orgId
|
251
|
-
};
|
252
|
-
try {
|
253
|
-
const response = yield this.graphqlQueryV2(query, variables);
|
254
|
-
return response.getAverageRating;
|
255
|
-
}
|
256
|
-
catch (error) {
|
257
|
-
console.log(`Error in getAverageRating: ${error}`);
|
258
|
-
throw error;
|
259
|
-
}
|
260
|
-
});
|
261
|
-
}
|
262
|
-
getUrlEvaluation(targetIds, customerId, evaluationType) {
|
263
|
-
return __awaiter(this, void 0, void 0, function* () {
|
264
|
-
const query = queries_1.GET_URL_EVALUATION;
|
265
|
-
const variables = {
|
266
|
-
targetIds,
|
267
|
-
customerId,
|
268
|
-
evaluationType,
|
269
|
-
orgId: this.orgId
|
270
|
-
};
|
271
|
-
try {
|
272
|
-
const response = yield this.graphqlQueryV2(query, variables);
|
273
|
-
return response.getUrlEvaluation;
|
274
|
-
}
|
275
|
-
catch (error) {
|
276
|
-
console.log(`Error in getUrlEvaluation: ${error}`);
|
277
|
-
throw error;
|
278
|
-
}
|
279
|
-
});
|
280
|
-
}
|
281
|
-
getNumberOfTicketEvaluation(customerId) {
|
282
|
-
return __awaiter(this, void 0, void 0, function* () {
|
283
|
-
const query = queries_1.GET_NUMBER_OF_TICKET_EVALUATION;
|
284
|
-
const variables = {
|
285
|
-
customerId,
|
286
|
-
orgId: this.orgId
|
287
|
-
};
|
288
|
-
try {
|
289
|
-
const response = yield this.graphqlQueryV2(query, variables);
|
290
|
-
return response.getNumberOfTicketEvaluation;
|
291
|
-
}
|
292
|
-
catch (error) {
|
293
|
-
console.log(`Error in getNumberOfTicketEvaluation: ${error}`);
|
294
|
-
throw error;
|
295
|
-
}
|
296
|
-
});
|
297
|
-
}
|
298
243
|
getAttachmentByWorkEffortId(workEffortIds) {
|
299
244
|
return __awaiter(this, void 0, void 0, function* () {
|
300
245
|
const query = queries_1.GET_ATTACHMENT_BY_WORK_EFFORT_ID;
|
@@ -8,4 +8,7 @@ export declare class CrmCampingService extends Service {
|
|
8
8
|
getCampaignActionById(campaignActionId: string): Promise<any>;
|
9
9
|
suggestVoucher(customerId: string, scope: string | null, isNewCustomer: boolean): Promise<any>;
|
10
10
|
searchVouchers(campaignId: String, campaignActionId: String, campaignActionType: String, customerId: String, pageNumber: number, pageSize: number): Promise<any>;
|
11
|
+
getAverageRating(targetIds: [string], customerId: string, evaluationType: string): Promise<any>;
|
12
|
+
getUrlEvaluation(targetIds: [string], customerId: string, evaluationType: string): Promise<any>;
|
13
|
+
getNumberOfTicketEvaluation(customerId: string): Promise<any>;
|
11
14
|
}
|
@@ -130,5 +130,60 @@ class CrmCampingService extends serviceSDK_1.Service {
|
|
130
130
|
}
|
131
131
|
});
|
132
132
|
}
|
133
|
+
getAverageRating(targetIds, customerId, evaluationType) {
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
135
|
+
const query = queries_1.GET_AVERAGE_RATING;
|
136
|
+
const variables = {
|
137
|
+
targetIds,
|
138
|
+
customerId,
|
139
|
+
evaluationType,
|
140
|
+
orgId: this.orgId
|
141
|
+
};
|
142
|
+
try {
|
143
|
+
const response = yield this.graphqlQueryV2(query, variables);
|
144
|
+
return response.getAverageRating;
|
145
|
+
}
|
146
|
+
catch (error) {
|
147
|
+
console.log(`Error in getAverageRating: ${error}`);
|
148
|
+
throw error;
|
149
|
+
}
|
150
|
+
});
|
151
|
+
}
|
152
|
+
getUrlEvaluation(targetIds, customerId, evaluationType) {
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
154
|
+
const query = queries_1.GET_URL_EVALUATION;
|
155
|
+
const variables = {
|
156
|
+
targetIds,
|
157
|
+
customerId,
|
158
|
+
evaluationType,
|
159
|
+
orgId: this.orgId
|
160
|
+
};
|
161
|
+
try {
|
162
|
+
const response = yield this.graphqlQueryV2(query, variables);
|
163
|
+
return response.getUrlEvaluation;
|
164
|
+
}
|
165
|
+
catch (error) {
|
166
|
+
console.log(`Error in getUrlEvaluation: ${error}`);
|
167
|
+
throw error;
|
168
|
+
}
|
169
|
+
});
|
170
|
+
}
|
171
|
+
getNumberOfTicketEvaluation(customerId) {
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
173
|
+
const query = queries_1.GET_NUMBER_OF_TICKET_EVALUATION;
|
174
|
+
const variables = {
|
175
|
+
customerId,
|
176
|
+
orgId: this.orgId
|
177
|
+
};
|
178
|
+
try {
|
179
|
+
const response = yield this.graphqlQueryV2(query, variables);
|
180
|
+
return response.getNumberOfTicketEvaluation;
|
181
|
+
}
|
182
|
+
catch (error) {
|
183
|
+
console.log(`Error in getNumberOfTicketEvaluation: ${error}`);
|
184
|
+
throw error;
|
185
|
+
}
|
186
|
+
});
|
187
|
+
}
|
133
188
|
}
|
134
189
|
exports.CrmCampingService = CrmCampingService;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Service } from "../serviceSDK";
|
2
|
+
export declare class QuicklabService extends Service {
|
3
|
+
constructor(endpoint: string, orgId: string, storeId: string);
|
4
|
+
setToken(token: string): void;
|
5
|
+
setStoreId(storeId: string): void;
|
6
|
+
getTemplatesByArticleId(articleId: string): Promise<any>;
|
7
|
+
getTypeLabSessions(): Promise<any>;
|
8
|
+
getLabSessionsByUserId(userId: string): Promise<any>;
|
9
|
+
getLabSessionsByUserIdAndArticleId(userId: string, articleId: string): Promise<any>;
|
10
|
+
createLabSessionByTemplateId(templateId: string, userId: string, articleId: string, typeLabSessionCode: string): Promise<any>;
|
11
|
+
createLabSessionByLabSessionId(labSessionId: string, userId: string, articleId: string): Promise<any>;
|
12
|
+
createLabSessionByComputingId(computingId: string, userId: string, articleId: string): Promise<any>;
|
13
|
+
updateEndTimeLabSession(labSessionId: string, userId: string): Promise<any>;
|
14
|
+
stopLabSession(labSessionId: string, userId: string, note: string): Promise<any>;
|
15
|
+
}
|
@@ -0,0 +1,155 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.QuicklabService = void 0;
|
13
|
+
const mutations_1 = require("../../graphql/quicklab_service/mutations");
|
14
|
+
const queries_1 = require("../../graphql/quicklab_service/queries");
|
15
|
+
const serviceSDK_1 = require("../serviceSDK");
|
16
|
+
class QuicklabService extends serviceSDK_1.Service {
|
17
|
+
constructor(endpoint, orgId, storeId) {
|
18
|
+
super(endpoint, orgId, storeId);
|
19
|
+
}
|
20
|
+
setToken(token) {
|
21
|
+
this.token = token;
|
22
|
+
}
|
23
|
+
setStoreId(storeId) {
|
24
|
+
this.storeId = storeId;
|
25
|
+
}
|
26
|
+
getTemplatesByArticleId(articleId) {
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
28
|
+
const query = queries_1.GET_TEMPLATE_BY_ARTICLE_ID;
|
29
|
+
const variables = {
|
30
|
+
articleId,
|
31
|
+
};
|
32
|
+
try {
|
33
|
+
const response = yield this.graphqlQuery(query, variables);
|
34
|
+
return response.getTemplatesByArticleId;
|
35
|
+
}
|
36
|
+
catch (error) {
|
37
|
+
console.log(`Error in getTemplatesByArticleId : ${error}`);
|
38
|
+
throw error;
|
39
|
+
}
|
40
|
+
});
|
41
|
+
}
|
42
|
+
getTypeLabSessions() {
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
44
|
+
const query = queries_1.GET_TYPE_LAB_SESSION;
|
45
|
+
const variables = {};
|
46
|
+
try {
|
47
|
+
const response = yield this.graphqlQuery(query, variables);
|
48
|
+
return response.getTypeLabSessions;
|
49
|
+
}
|
50
|
+
catch (error) {
|
51
|
+
console.log(`Error in getTypeLabSessions : ${error}`);
|
52
|
+
throw error;
|
53
|
+
}
|
54
|
+
});
|
55
|
+
}
|
56
|
+
getLabSessionsByUserId(userId) {
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
58
|
+
const query = queries_1.GET_LAB_SESSIONS_BY_USER_ID;
|
59
|
+
const variables = { userId };
|
60
|
+
try {
|
61
|
+
const response = yield this.graphqlQuery(query, variables);
|
62
|
+
return response.getLabSessionsByUserId;
|
63
|
+
}
|
64
|
+
catch (error) {
|
65
|
+
console.log(`Error in getLabSessionsByUserId : ${error}`);
|
66
|
+
throw error;
|
67
|
+
}
|
68
|
+
});
|
69
|
+
}
|
70
|
+
getLabSessionsByUserIdAndArticleId(userId, articleId) {
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
72
|
+
const query = queries_1.GET_LAB_SESSIONS_BY_USER_ID_AND_ARTICLE_ID;
|
73
|
+
const variables = { userId, articleId };
|
74
|
+
try {
|
75
|
+
const response = yield this.graphqlQuery(query, variables);
|
76
|
+
return response.getLabSessionsByUserIdAndArticleId;
|
77
|
+
}
|
78
|
+
catch (error) {
|
79
|
+
console.log(`Error in getLabSessionsByUserIdAndArticleId : ${error}`);
|
80
|
+
throw error;
|
81
|
+
}
|
82
|
+
});
|
83
|
+
}
|
84
|
+
createLabSessionByTemplateId(templateId, userId, articleId, typeLabSessionCode) {
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
86
|
+
const mutation = mutations_1.CREATE_LAB_SESSION_BY_TEMPLATE_ID;
|
87
|
+
const variables = { templateId, userId, articleId, typeLabSessionCode };
|
88
|
+
try {
|
89
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
90
|
+
return response.createLabSessionByTemplateId;
|
91
|
+
}
|
92
|
+
catch (error) {
|
93
|
+
console.log(`Error in createLabSessionByTemplateId : ${error}`);
|
94
|
+
throw error;
|
95
|
+
}
|
96
|
+
});
|
97
|
+
}
|
98
|
+
createLabSessionByLabSessionId(labSessionId, userId, articleId) {
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
100
|
+
const mutation = mutations_1.CREATE_LAB_SESSION_BY_LAB_SESSION_ID;
|
101
|
+
const variables = { labSessionId, userId, articleId };
|
102
|
+
try {
|
103
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
104
|
+
return response.createLabSessionByLabSessionId;
|
105
|
+
}
|
106
|
+
catch (error) {
|
107
|
+
console.log(`Error in createLabSessionByLabSessionId : ${error}`);
|
108
|
+
throw error;
|
109
|
+
}
|
110
|
+
});
|
111
|
+
}
|
112
|
+
createLabSessionByComputingId(computingId, userId, articleId) {
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
114
|
+
const mutation = mutations_1.CREATE_LAB_SESSION_BY_COMPUTING_ID;
|
115
|
+
const variables = { computingId, userId, articleId };
|
116
|
+
try {
|
117
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
118
|
+
return response.createLabSessionByComputingId;
|
119
|
+
}
|
120
|
+
catch (error) {
|
121
|
+
console.log(`Error in createLabSessionByComputingId : ${error}`);
|
122
|
+
throw error;
|
123
|
+
}
|
124
|
+
});
|
125
|
+
}
|
126
|
+
updateEndTimeLabSession(labSessionId, userId) {
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
128
|
+
const mutation = mutations_1.UPDATE_END_TIME_LAB_SESSION;
|
129
|
+
const variables = { labSessionId, userId };
|
130
|
+
try {
|
131
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
132
|
+
return response.updateEndTimeLabSession;
|
133
|
+
}
|
134
|
+
catch (error) {
|
135
|
+
console.log(`Error in updateEndTimeLabSession : ${error}`);
|
136
|
+
throw error;
|
137
|
+
}
|
138
|
+
});
|
139
|
+
}
|
140
|
+
stopLabSession(labSessionId, userId, note) {
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
142
|
+
const mutation = mutations_1.STOP_LAB_SESSION;
|
143
|
+
const variables = { labSessionId, userId, note };
|
144
|
+
try {
|
145
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
146
|
+
return response.stopLabSession;
|
147
|
+
}
|
148
|
+
catch (error) {
|
149
|
+
console.log(`Error in stopLabSession : ${error}`);
|
150
|
+
throw error;
|
151
|
+
}
|
152
|
+
});
|
153
|
+
}
|
154
|
+
}
|
155
|
+
exports.QuicklabService = QuicklabService;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ApolloClient, NormalizedCacheObject } from "@apollo/client";
|
2
|
+
import { DocumentNode } from "graphql";
|
3
|
+
export declare class Service {
|
4
|
+
protected token: string | null;
|
5
|
+
protected client: ApolloClient<NormalizedCacheObject>;
|
6
|
+
protected orgId: string;
|
7
|
+
protected storeId: string;
|
8
|
+
protected endpoint: string;
|
9
|
+
constructor(endpoint: string, orgId: string, storeId: string);
|
10
|
+
setToken(token: string): void;
|
11
|
+
protected graphqlQuery(query: DocumentNode, variables: any): Promise<any>;
|
12
|
+
protected graphqlMutation(mutation: DocumentNode, variables: any): Promise<any>;
|
13
|
+
protected restApiCallWithToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
|
14
|
+
}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
"use strict";
|
2
|
+
// src/service.ts
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
10
|
+
});
|
11
|
+
};
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
14
|
+
};
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
16
|
+
exports.Service = void 0;
|
17
|
+
const client_1 = require("@apollo/client");
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
19
|
+
class Service {
|
20
|
+
constructor(endpoint, orgId, storeId) {
|
21
|
+
this.token = null;
|
22
|
+
this.client = new client_1.ApolloClient({
|
23
|
+
uri: endpoint,
|
24
|
+
cache: new client_1.InMemoryCache(),
|
25
|
+
defaultOptions: {
|
26
|
+
query: {
|
27
|
+
fetchPolicy: "network-only",
|
28
|
+
},
|
29
|
+
},
|
30
|
+
});
|
31
|
+
this.orgId = orgId;
|
32
|
+
this.storeId = storeId;
|
33
|
+
this.endpoint = endpoint;
|
34
|
+
}
|
35
|
+
setToken(token) {
|
36
|
+
this.token = token;
|
37
|
+
}
|
38
|
+
// setOrgId(orgId: string) {
|
39
|
+
// this.orgId = orgId;
|
40
|
+
// }
|
41
|
+
graphqlQuery(query, variables) {
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
43
|
+
try {
|
44
|
+
const { data, errors } = yield this.client.query({
|
45
|
+
query: (0, client_1.gql) `
|
46
|
+
${query}
|
47
|
+
`,
|
48
|
+
variables,
|
49
|
+
});
|
50
|
+
if (errors) {
|
51
|
+
throw new Error(`GraphQL error! errors: ${errors}`);
|
52
|
+
}
|
53
|
+
return data;
|
54
|
+
}
|
55
|
+
catch (error) {
|
56
|
+
console.log(`Error in graphqlQuery: ${error}`);
|
57
|
+
throw error;
|
58
|
+
}
|
59
|
+
});
|
60
|
+
}
|
61
|
+
graphqlMutation(mutation, variables) {
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
63
|
+
try {
|
64
|
+
const { data, errors } = yield this.client.mutate({
|
65
|
+
mutation: (0, client_1.gql) `
|
66
|
+
${mutation}
|
67
|
+
`,
|
68
|
+
variables,
|
69
|
+
});
|
70
|
+
if (errors) {
|
71
|
+
throw new Error(`GraphQL error! errors: ${errors}`);
|
72
|
+
}
|
73
|
+
return data;
|
74
|
+
}
|
75
|
+
catch (error) {
|
76
|
+
console.log(`Error in graphqlMutation: ${error}`);
|
77
|
+
throw error;
|
78
|
+
}
|
79
|
+
});
|
80
|
+
}
|
81
|
+
restApiCallWithToken(path, method, data, headers) {
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
83
|
+
try {
|
84
|
+
const modifiedHeaders = Object.assign(Object.assign({}, headers), { "Partner-Id": this.orgId, "X-Ecomos-Access-Token": this.token });
|
85
|
+
console.log("🚀 ~ Service ~ modifiedHeaders:", modifiedHeaders);
|
86
|
+
const response = yield (0, axios_1.default)({
|
87
|
+
url: this.endpoint + path,
|
88
|
+
method,
|
89
|
+
data,
|
90
|
+
headers: modifiedHeaders,
|
91
|
+
});
|
92
|
+
return response.data;
|
93
|
+
}
|
94
|
+
catch (error) {
|
95
|
+
console.log(`Error in restApiCallWithToken: ${error}`);
|
96
|
+
throw error;
|
97
|
+
}
|
98
|
+
});
|
99
|
+
}
|
100
|
+
}
|
101
|
+
exports.Service = Service;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function buildFieldString(fields: (string | Record<string, any>)[], indent?: number): string;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.buildFieldString = void 0;
|
4
|
+
function buildFieldString(fields, indent = 6) {
|
5
|
+
const space = " ".repeat(indent);
|
6
|
+
return fields
|
7
|
+
.map((field) => {
|
8
|
+
if (typeof field === "string")
|
9
|
+
return `${space}${field}`;
|
10
|
+
const [key, value] = Object.entries(field)[0];
|
11
|
+
const nested = buildFieldString(value, indent + 2);
|
12
|
+
return `${space}${key} {\n${nested}\n${space}}`;
|
13
|
+
})
|
14
|
+
.join("\n");
|
15
|
+
}
|
16
|
+
exports.buildFieldString = buildFieldString;
|