@longvansoftware/storefront-js-client 1.3.8 → 1.4.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/dist/src/graphql/service/mutations.d.ts +1 -0
- package/dist/src/graphql/service/mutations.js +39 -1
- package/dist/src/graphql/service/queries.d.ts +1 -0
- package/dist/src/graphql/service/queries.js +16 -1
- package/dist/src/lib/SDK.d.ts +1 -1
- package/dist/src/lib/SDK.js +10 -12
- package/dist/src/lib/service/index.d.ts +2 -1
- package/dist/src/lib/service/index.js +32 -16
- package/dist/src/lib/serviceSDK.js +3 -4
- package/dist/src/lib/user/index.d.ts +1 -1
- package/dist/src/lib/user/index.js +1 -1
- package/package.json +1 -1
|
@@ -6,3 +6,4 @@ export declare const DELETE_ATTR_VALUE: import("graphql").DocumentNode;
|
|
|
6
6
|
export declare const UPDATE_SUCCESS_ACTION_PROCESS_STATUS: import("graphql").DocumentNode;
|
|
7
7
|
export declare const UPDATE_FAIL_ACTION_PROCESS_STATUS: import("graphql").DocumentNode;
|
|
8
8
|
export declare const CREATE_SERVICE_TICKET: import("graphql").DocumentNode;
|
|
9
|
+
export declare const CREATE_SERVICE_ACTION: import("graphql").DocumentNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CREATE_SERVICE_TICKET = exports.UPDATE_FAIL_ACTION_PROCESS_STATUS = exports.UPDATE_SUCCESS_ACTION_PROCESS_STATUS = exports.DELETE_ATTR_VALUE = exports.UPDATE_ATTR_VALUE = exports.DELETE_SERVICE = exports.UPDATE_SERVICE = exports.CREATE_SERVICE = void 0;
|
|
3
|
+
exports.CREATE_SERVICE_ACTION = exports.CREATE_SERVICE_TICKET = exports.UPDATE_FAIL_ACTION_PROCESS_STATUS = exports.UPDATE_SUCCESS_ACTION_PROCESS_STATUS = exports.DELETE_ATTR_VALUE = exports.UPDATE_ATTR_VALUE = exports.DELETE_SERVICE = exports.UPDATE_SERVICE = exports.CREATE_SERVICE = void 0;
|
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
|
5
5
|
exports.CREATE_SERVICE = (0, graphql_tag_1.gql) `
|
|
6
6
|
mutation CreateService($partnerId: String!, $createModel: ServiceRequest!) {
|
|
@@ -201,3 +201,41 @@ exports.CREATE_SERVICE_TICKET = (0, graphql_tag_1.gql) `
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
`;
|
|
204
|
+
// mutation CreateServiceAction {
|
|
205
|
+
// createServiceAction(serviceId: null, actionType: null, createdBy: null) {
|
|
206
|
+
// id
|
|
207
|
+
// serviceId
|
|
208
|
+
// actionType
|
|
209
|
+
// description
|
|
210
|
+
// status
|
|
211
|
+
// processStatus
|
|
212
|
+
// createdBy
|
|
213
|
+
// createdStamp
|
|
214
|
+
// updatedBy
|
|
215
|
+
// updatedStamp
|
|
216
|
+
// }
|
|
217
|
+
// }
|
|
218
|
+
exports.CREATE_SERVICE_ACTION = (0, graphql_tag_1.gql) `
|
|
219
|
+
mutation CreateServiceAction(
|
|
220
|
+
$serviceId: String!
|
|
221
|
+
$actionType: String!
|
|
222
|
+
$createdBy: String!
|
|
223
|
+
) {
|
|
224
|
+
createServiceAction(
|
|
225
|
+
serviceId: $serviceId
|
|
226
|
+
actionType: $actionType
|
|
227
|
+
createdBy: $createdBy
|
|
228
|
+
) {
|
|
229
|
+
id
|
|
230
|
+
serviceId
|
|
231
|
+
actionType
|
|
232
|
+
description
|
|
233
|
+
status
|
|
234
|
+
processStatus
|
|
235
|
+
createdBy
|
|
236
|
+
createdStamp
|
|
237
|
+
updatedBy
|
|
238
|
+
updatedStamp
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
`;
|
|
@@ -2,3 +2,4 @@ export declare const GET_SERVICE_BY_ID: import("graphql").DocumentNode;
|
|
|
2
2
|
export declare const GET_SERVICE_BY_TYPE: import("graphql").DocumentNode;
|
|
3
3
|
export declare const GET_SERVICE_BY_OWNER_ID: import("graphql").DocumentNode;
|
|
4
4
|
export declare const GET_SERVICE_ACTION: import("graphql").DocumentNode;
|
|
5
|
+
export declare const GET_SERVICE_TICKETS: import("graphql").DocumentNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GET_SERVICE_ACTION = exports.GET_SERVICE_BY_OWNER_ID = exports.GET_SERVICE_BY_TYPE = exports.GET_SERVICE_BY_ID = void 0;
|
|
3
|
+
exports.GET_SERVICE_TICKETS = exports.GET_SERVICE_ACTION = exports.GET_SERVICE_BY_OWNER_ID = exports.GET_SERVICE_BY_TYPE = exports.GET_SERVICE_BY_ID = void 0;
|
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
|
5
5
|
exports.GET_SERVICE_BY_ID = (0, graphql_tag_1.gql) `
|
|
6
6
|
query GetServiceById($partnerId: String!, $serviceId: String!) {
|
|
@@ -152,3 +152,18 @@ exports.GET_SERVICE_ACTION = (0, graphql_tag_1.gql) `
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
`;
|
|
155
|
+
exports.GET_SERVICE_TICKETS = (0, graphql_tag_1.gql) `
|
|
156
|
+
query GetServiceTickets($serviceId: String!) {
|
|
157
|
+
getServiceTickets(serviceId: $serviceId) {
|
|
158
|
+
id
|
|
159
|
+
serviceId
|
|
160
|
+
description
|
|
161
|
+
status
|
|
162
|
+
processStatus
|
|
163
|
+
createdBy
|
|
164
|
+
createdStamp
|
|
165
|
+
updatedBy
|
|
166
|
+
updatedStamp
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
`;
|
package/dist/src/lib/SDK.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ProductService } from "../lib/product/index";
|
|
2
2
|
import { AuthService } from "../lib/auth/index";
|
|
3
3
|
import { OrderService } from "../lib/order/index";
|
|
4
|
-
import { ServiceManagementService } from "./service";
|
|
4
|
+
import { ServiceManagementService } from "./service/index";
|
|
5
5
|
import { UserService } from "../lib/user/index";
|
|
6
6
|
import { PaymentService } from "../lib/payment/index";
|
|
7
7
|
import { CrmService } from "../lib/crm/index";
|
package/dist/src/lib/SDK.js
CHANGED
|
@@ -5,31 +5,29 @@ exports.SDK = void 0;
|
|
|
5
5
|
const index_1 = require("../lib/product/index");
|
|
6
6
|
const index_2 = require("../lib/auth/index");
|
|
7
7
|
const index_3 = require("../lib/order/index");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const index_4 = require("./service/index");
|
|
9
|
+
const index_5 = require("../lib/user/index");
|
|
10
10
|
const config_1 = require("../../config/config");
|
|
11
11
|
const helpers_1 = require("../utils/helpers");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
12
|
+
const index_6 = require("../lib/payment/index");
|
|
13
|
+
const index_7 = require("../lib/crm/index");
|
|
14
|
+
const index_8 = require("../lib/warehouse/index");
|
|
15
15
|
class SDK {
|
|
16
16
|
constructor(orgId, storeId, storefrontAccessToken) {
|
|
17
17
|
this.orgId = orgId;
|
|
18
18
|
this.storeId = storeId;
|
|
19
19
|
this.storefrontAccessToken = storefrontAccessToken;
|
|
20
|
-
// public crm: CrmService;
|
|
21
|
-
// Other services here
|
|
22
20
|
this.token = null;
|
|
23
21
|
(0, helpers_1.validateStorefrontAccessToken)(storefrontAccessToken);
|
|
24
22
|
const endpoints = config_1.environmentEndpoints.dev;
|
|
25
23
|
this.product = new index_1.ProductService(endpoints.product, orgId, storeId);
|
|
26
24
|
this.auth = new index_2.AuthService(endpoints.auth, orgId, storeId);
|
|
27
25
|
this.order = new index_3.OrderService(endpoints.order, orgId, storeId);
|
|
28
|
-
this.user = new
|
|
29
|
-
this.payment = new
|
|
30
|
-
this.crm = new
|
|
31
|
-
this.service = new
|
|
32
|
-
this.warehouse = new
|
|
26
|
+
this.user = new index_5.UserService(endpoints.user, orgId, storeId);
|
|
27
|
+
this.payment = new index_6.PaymentService(endpoints.payment, orgId, storeId);
|
|
28
|
+
this.crm = new index_7.CrmService(endpoints.crm, orgId, storeId);
|
|
29
|
+
this.service = new index_4.ServiceManagementService(endpoints.service, orgId, storeId);
|
|
30
|
+
this.warehouse = new index_8.WarehouseService(endpoints.warehouse, orgId, storeId);
|
|
33
31
|
// Initialize other services here
|
|
34
32
|
}
|
|
35
33
|
setToken(token) {
|
|
@@ -17,7 +17,6 @@ export declare class ServiceManagementService extends Service {
|
|
|
17
17
|
* get service by type
|
|
18
18
|
* @param type - The endpoint URL for the service.
|
|
19
19
|
*/
|
|
20
|
-
getServiceByType(type: string): Promise<any>;
|
|
21
20
|
/**
|
|
22
21
|
* get service by owner id
|
|
23
22
|
* @param ownerId - The endpoint URL for the service.
|
|
@@ -88,4 +87,6 @@ export declare class ServiceManagementService extends Service {
|
|
|
88
87
|
* @throws {Error} - If an error occurs during the creation of the service ticket.
|
|
89
88
|
*/
|
|
90
89
|
createServiceTicket(serviceId: string, name: string, createdBy: string, description: string): Promise<any>;
|
|
90
|
+
getServiceTicket(serviceId: string): Promise<any>;
|
|
91
|
+
createServiceAction(serviceId: string, actionType: string, createdBy: string): Promise<any>;
|
|
91
92
|
}
|
|
@@ -48,22 +48,6 @@ class ServiceManagementService extends serviceSDK_1.Service {
|
|
|
48
48
|
* get service by type
|
|
49
49
|
* @param type - The endpoint URL for the service.
|
|
50
50
|
*/
|
|
51
|
-
getServiceByType(type) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const query = queries_1.GET_SERVICE_BY_TYPE;
|
|
54
|
-
const variables = {
|
|
55
|
-
partnerId: this.orgId,
|
|
56
|
-
type,
|
|
57
|
-
};
|
|
58
|
-
try {
|
|
59
|
-
const response = yield this.graphqlQuery(query, variables);
|
|
60
|
-
return response.getServiceByType;
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
console.log(`Error in getServiceByType :${error}`);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
51
|
/**
|
|
68
52
|
* get service by owner id
|
|
69
53
|
* @param ownerId - The endpoint URL for the service.
|
|
@@ -294,5 +278,37 @@ class ServiceManagementService extends serviceSDK_1.Service {
|
|
|
294
278
|
}
|
|
295
279
|
});
|
|
296
280
|
}
|
|
281
|
+
getServiceTicket(serviceId) {
|
|
282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
+
const query = queries_1.GET_SERVICE_TICKETS;
|
|
284
|
+
const variables = {
|
|
285
|
+
serviceId,
|
|
286
|
+
};
|
|
287
|
+
try {
|
|
288
|
+
const response = yield this.graphqlQuery(query, variables);
|
|
289
|
+
return response.getServiceTickets;
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
throw error;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
createServiceAction(serviceId, actionType, createdBy) {
|
|
297
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
298
|
+
const mutation = mutations_1.CREATE_SERVICE_ACTION;
|
|
299
|
+
const variables = {
|
|
300
|
+
serviceId,
|
|
301
|
+
actionType,
|
|
302
|
+
createdBy,
|
|
303
|
+
};
|
|
304
|
+
try {
|
|
305
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
306
|
+
return response.createServiceAction;
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
throw error;
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
}
|
|
297
313
|
}
|
|
298
314
|
exports.ServiceManagementService = ServiceManagementService;
|
|
@@ -70,7 +70,6 @@ class Service {
|
|
|
70
70
|
return data;
|
|
71
71
|
}
|
|
72
72
|
catch (error) {
|
|
73
|
-
console.log(`Error in graphqlMutation: ${error}`);
|
|
74
73
|
throw error;
|
|
75
74
|
}
|
|
76
75
|
});
|
|
@@ -79,7 +78,6 @@ class Service {
|
|
|
79
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
79
|
try {
|
|
81
80
|
const modifiedHeaders = Object.assign(Object.assign({}, headers), { "Partner-Id": this.orgId, "X-Ecomos-Access-Token": this.token });
|
|
82
|
-
console.log("🚀 ~ Service ~ modifiedHeaders:", modifiedHeaders);
|
|
83
81
|
const response = yield (0, axios_1.default)({
|
|
84
82
|
url: this.endpoint + path,
|
|
85
83
|
method,
|
|
@@ -89,7 +87,6 @@ class Service {
|
|
|
89
87
|
return response.data;
|
|
90
88
|
}
|
|
91
89
|
catch (error) {
|
|
92
|
-
console.log(`Error in restApiCallWithToken: ${error}`);
|
|
93
90
|
throw error;
|
|
94
91
|
}
|
|
95
92
|
});
|
|
@@ -98,7 +95,6 @@ class Service {
|
|
|
98
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
96
|
try {
|
|
100
97
|
const modifiedHeaders = Object.assign(Object.assign({}, headers), { PartnerId: this.orgId });
|
|
101
|
-
console.log("🚀 ~ Service ~ modifiedHeaders:", modifiedHeaders);
|
|
102
98
|
const response = yield (0, axios_1.default)({
|
|
103
99
|
url: this.endpoint + path,
|
|
104
100
|
method,
|
|
@@ -108,6 +104,9 @@ class Service {
|
|
|
108
104
|
return response.data;
|
|
109
105
|
}
|
|
110
106
|
catch (error) {
|
|
107
|
+
if (error.response.status === 401) {
|
|
108
|
+
throw new Error("Không có quyền truy cập!");
|
|
109
|
+
}
|
|
111
110
|
console.log(`Error in restApiCallWithNoToken: ${error}`);
|
|
112
111
|
throw error;
|
|
113
112
|
}
|
|
@@ -5,7 +5,7 @@ export declare class UserService extends Service {
|
|
|
5
5
|
getPersonByPartyIds(partyIds: string[]): Promise<any>;
|
|
6
6
|
createCompany(payload: createCompanyRequest, createdBy: string): Promise<any>;
|
|
7
7
|
updateCompanyInfo(id: string, fieldName: string, valueUpdate: string, updatedBy: string): Promise<any>;
|
|
8
|
-
|
|
8
|
+
updateCustomer(id: string, customerItem: updateCustomerRequest, updatedBy: string): Promise<any>;
|
|
9
9
|
getCustomerById(id: string): Promise<any>;
|
|
10
10
|
searchCompany(keyword: string, limit: number): Promise<any>;
|
|
11
11
|
createCustomerV2(createCustomerRequest: createCustomerRequest, createdBy: string): Promise<any>;
|
|
@@ -70,7 +70,7 @@ class UserService extends serviceSDK_1.Service {
|
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
updateCustomer(id, customerItem, updatedBy) {
|
|
74
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
75
|
const mutation = mutations_1.UPDATE_CUSTOMER_V2;
|
|
76
76
|
const variables = {
|