@longvansoftware/storefront-js-client 1.4.3 → 1.4.5

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.
@@ -8,6 +8,7 @@ export declare const environmentEndpoints: {
8
8
  payment: string;
9
9
  service: string;
10
10
  warehouse: string;
11
+ computing: string;
11
12
  };
12
13
  live: {
13
14
  product: string;
@@ -18,5 +19,6 @@ export declare const environmentEndpoints: {
18
19
  payment: string;
19
20
  service: string;
20
21
  warehouse: string;
22
+ computing: string;
21
23
  };
22
24
  };
@@ -11,6 +11,7 @@ exports.environmentEndpoints = {
11
11
  payment: "https://portal.dev.longvan.vn/invoice-gateway/graphql",
12
12
  service: "https://portal.dev.longvan.vn/service-api/graphql",
13
13
  warehouse: "https://facility-api-v2.dev.longvan.vn/facility-api/public-facility/1.0.0",
14
+ computing: "https://api-gateway.dev.longvan.vn/computing-service/graphql",
14
15
  },
15
16
  live: {
16
17
  product: "https://product-service.dev.longvan.vn/product-service/graphql",
@@ -21,5 +22,6 @@ exports.environmentEndpoints = {
21
22
  payment: "https://portal.dev.longvan.vn/invoice-gateway/graphql",
22
23
  service: "https://portal.dev.longvan.vn/service-api/graphql",
23
24
  warehouse: "https://facility-api-v2.dev.longvan.vn/facility-api/public-facility/1.0.0",
25
+ computing: "https://api-gateway.longvan.vn/computing-service/graphql",
24
26
  },
25
27
  };
@@ -0,0 +1,2 @@
1
+ export declare const COMPUTING_DETAIL: import("graphql").DocumentNode;
2
+ export declare const PORTNATS: import("graphql").DocumentNode;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PORTNATS = exports.COMPUTING_DETAIL = void 0;
4
+ const graphql_tag_1 = require("graphql-tag");
5
+ exports.COMPUTING_DETAIL = (0, graphql_tag_1.gql) `
6
+ query ComputingDetail($computingId: String!){
7
+ computingDetail(computingId: $computingId) {
8
+ id
9
+ name
10
+ username
11
+ password
12
+ state
13
+ os
14
+ ips
15
+ province
16
+ console
17
+ existPortNat
18
+ }
19
+ }
20
+ `;
21
+ exports.PORTNATS = (0, graphql_tag_1.gql) `
22
+ query PortNats($computingId: String!){
23
+ portNats(computingId: $computingId) {
24
+ id
25
+ action
26
+ protocol
27
+ originalAddress
28
+ originalPort
29
+ translatedAddress
30
+ translatedPort
31
+ description
32
+ status
33
+ }
34
+ }
35
+ `;
@@ -138,6 +138,10 @@ exports.GET_PRODUCT_BY_ID_QUERY = (0, graphql_tag_1.gql) `
138
138
  id
139
139
  name
140
140
  values
141
+ valuesFull {
142
+ id
143
+ name
144
+ }
141
145
  }
142
146
  categories {
143
147
  id
@@ -258,6 +262,7 @@ exports.GET_SIMPLE_PRODUCTS_QUERY = (0, graphql_tag_1.gql) `
258
262
  sku
259
263
  shortDescription
260
264
  vat
265
+ subType
261
266
  qualify
262
267
  handle
263
268
  price
@@ -398,7 +403,11 @@ exports.GET_PRODUCT_OPTION = (0, graphql_tag_1.gql) `
398
403
  $storeChannel: String!
399
404
  $productId: String!
400
405
  ) {
401
- getProductOption(partnerId: $partnerId, storeChannel: $storeChannel, productId: $productId) {
406
+ getProductOption(
407
+ partnerId: $partnerId
408
+ storeChannel: $storeChannel
409
+ productId: $productId
410
+ ) {
402
411
  id
403
412
  name
404
413
  subType
@@ -414,11 +423,9 @@ exports.GET_PRODUCT_OPTION = (0, graphql_tag_1.gql) `
414
423
  }
415
424
  `;
416
425
  exports.GET_POLICY = (0, graphql_tag_1.gql) `
417
- query GetPolicy(
418
- $groupId: String!
419
- ) {
426
+ query GetPolicy($groupId: String!) {
420
427
  getPolicy(groupId: $groupId) {
421
428
  value
422
429
  }
423
- }
430
+ }
424
431
  `;
@@ -1,3 +1,13 @@
1
1
  export declare const GET_PERSON_BY_IDS_QUERY: import("graphql").DocumentNode;
2
- export declare const GET_CUSTOMER_BY_ID: import("graphql").DocumentNode;
3
2
  export declare const SEARCH_COMPANY: import("graphql").DocumentNode;
3
+ export declare const GET_CUSTOMER_BY_ID: import("graphql").DocumentNode;
4
+ export declare const SEARCH_CUSTOMER: import("graphql").DocumentNode;
5
+ export declare const SEARCH_EMPLOYEES: import("graphql").DocumentNode;
6
+ export declare const GET_POSTIONS_BY_EMPLOYEES_ID: import("graphql").DocumentNode;
7
+ export declare const GET_STORE_CHANEL_IDS_BY_EMPLOYESS_ID: import("graphql").DocumentNode;
8
+ export declare const GET_EMPLOYEES_BY_STORE_CHANEL_ID: import("graphql").DocumentNode;
9
+ export declare const GET_COMPANY_BY_CONTACT_INFO_ID: import("graphql").DocumentNode;
10
+ export declare const GET_CONTACT_INFOS_BY_COMPANY_ID: import("graphql").DocumentNode;
11
+ export declare const GET_PROVINCES: import("graphql").DocumentNode;
12
+ export declare const GET_DISTRICTS: import("graphql").DocumentNode;
13
+ export declare const GET_WARDS: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SEARCH_COMPANY = exports.GET_CUSTOMER_BY_ID = exports.GET_PERSON_BY_IDS_QUERY = void 0;
3
+ exports.GET_WARDS = exports.GET_DISTRICTS = exports.GET_PROVINCES = exports.GET_CONTACT_INFOS_BY_COMPANY_ID = exports.GET_COMPANY_BY_CONTACT_INFO_ID = exports.GET_EMPLOYEES_BY_STORE_CHANEL_ID = exports.GET_STORE_CHANEL_IDS_BY_EMPLOYESS_ID = exports.GET_POSTIONS_BY_EMPLOYEES_ID = exports.SEARCH_EMPLOYEES = exports.SEARCH_CUSTOMER = exports.GET_CUSTOMER_BY_ID = exports.SEARCH_COMPANY = exports.GET_PERSON_BY_IDS_QUERY = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.GET_PERSON_BY_IDS_QUERY = (0, graphql_tag_1.gql) `
6
6
  query GetPersonByIds($partyIds: [String!]!) {
@@ -31,37 +31,222 @@ exports.GET_PERSON_BY_IDS_QUERY = (0, graphql_tag_1.gql) `
31
31
  }
32
32
  }
33
33
  `;
34
+ exports.SEARCH_COMPANY = (0, graphql_tag_1.gql) `
35
+ query SearchCompany($keyword: String, $orgId: String!, $limit: Int) {
36
+ searchCompany(keyword: $keyword, orgId: $orgId, limit: $limit) {
37
+ id
38
+ name
39
+ address
40
+ gender
41
+ identityNumber
42
+ birthDate
43
+ email
44
+ phone
45
+ createdStamp
46
+ createdBy
47
+ memberLevel
48
+ }
49
+ }
50
+ `;
34
51
  exports.GET_CUSTOMER_BY_ID = (0, graphql_tag_1.gql) `
35
- query GetCustomerById($id: String!){
36
- getCustomerById(id: $id) {
37
- id
38
- name
39
- address
40
- gender
41
- identityNumber
42
- birthDate
43
- email
44
- phone
45
- createdStamp
46
- createdBy
47
- memberLevel
52
+ query GetCustomerById($id: String!) {
53
+ getCustomerById(id: $id) {
54
+ id
55
+ name
56
+ address
57
+ gender
58
+ identityNumber
59
+ birthDate
60
+ email
61
+ phone
62
+ createdStamp
63
+ createdBy
64
+ memberLevel
65
+ }
48
66
  }
49
- }
50
67
  `;
51
- exports.SEARCH_COMPANY = (0, graphql_tag_1.gql) `
52
- query SearchCompany($keyword: String, $orgId: String!, $limit: Int){
53
- searchCompany(keyword: $keyword, orgId: $orgId, limit: $limit) {
54
- id
55
- name
56
- address
57
- gender
58
- identityNumber
59
- birthDate
60
- email
61
- phone
62
- createdStamp
63
- createdBy
64
- memberLevel
68
+ exports.SEARCH_CUSTOMER = (0, graphql_tag_1.gql) `
69
+ query SearchCustomers(
70
+ $keyword: String
71
+ $type: String
72
+ $startCreatedDate: DateCustom
73
+ $endCreatedDate: DateCustom
74
+ $memberLevel: String
75
+ $partnerId: String!
76
+ $currentPage: Int!
77
+ $pageSize: Int!
78
+ ) {
79
+ searchCustomers(
80
+ keyword: $keyword
81
+ type: $type
82
+ startCreatedDate: $startCreatedDate
83
+ endCreatedDate: $endCreatedDate
84
+ memberLevel: $memberLevel
85
+ partnerId: $partnerId
86
+ currentPage: $currentPage
87
+ pageSize: $pageSize
88
+ ) {
89
+ totalPages
90
+ totalElements
91
+ currentPage
92
+ content {
93
+ id
94
+ name
95
+ address
96
+ gender
97
+ identityNumber
98
+ birthDate
99
+ email
100
+ phone
101
+ createdStamp
102
+ createdBy
103
+ memberLevel
104
+ }
105
+ }
106
+ }
107
+ `;
108
+ exports.SEARCH_EMPLOYEES = (0, graphql_tag_1.gql) `
109
+ query SearchEmployees($keyword: String, $positionShortName: String, $partnerId: String) {
110
+ searchEmployees(
111
+ keyword: $keyword
112
+ positionShortName: $positionShortName
113
+ partnerId: $partnerId
114
+ ) {
115
+ id
116
+ name
117
+ address
118
+ gender
119
+ identityNumber
120
+ birthDate
121
+ email
122
+ phone
123
+ createdStamp
124
+ createdBy
125
+ memberLevel
126
+ }
127
+ }
128
+ `;
129
+ exports.GET_POSTIONS_BY_EMPLOYEES_ID = (0, graphql_tag_1.gql) `
130
+ query GetPositionsByEmployeeId($employeeId: String!, $partnerId: String!) {
131
+ getPositionsByEmployeeId(employeeId: $employeeId, partnerId: $partnerId)
132
+ }
133
+ `;
134
+ exports.GET_STORE_CHANEL_IDS_BY_EMPLOYESS_ID = (0, graphql_tag_1.gql) `
135
+ query GetStoreChannelIdsByEmployeeId($employeeId: String!, $partnerId: String!) {
136
+ getStoreChannelIdsByEmployeeId(employeeId: $employeeId, partnerId: $partnerId)
137
+ }
138
+ `;
139
+ exports.GET_EMPLOYEES_BY_STORE_CHANEL_ID = (0, graphql_tag_1.gql) `
140
+ query GetEmployeesByStoreChannelId($storeChannelId: String!, $partnerId: String!) {
141
+ getEmployeesByStoreChannelId(storeChannelId: $storeChannelId, partnerId: $partnerId) {
142
+ id
143
+ name
144
+ address
145
+ gender
146
+ identityNumber
147
+ birthDate
148
+ email
149
+ phone
150
+ createdStamp
151
+ createdBy
152
+ memberLevel
153
+ }
154
+ }
155
+ `;
156
+ exports.GET_COMPANY_BY_CONTACT_INFO_ID = (0, graphql_tag_1.gql) `
157
+ query GetCompanyByContactInfoId($contactId: String!, $partnerId: String!) {
158
+ getCompanyByContactInfoId(contactId: $contactId, partnerId: $partnerId) {
159
+ id
160
+ name
161
+ address
162
+ gender
163
+ identityNumber
164
+ birthDate
165
+ email
166
+ phone
167
+ createdStamp
168
+ createdBy
169
+ memberLevel
170
+ }
171
+ }
172
+ `;
173
+ exports.GET_CONTACT_INFOS_BY_COMPANY_ID = (0, graphql_tag_1.gql) `
174
+ query GetContactInfosByCompanyId($companyId: String!, $partnerId: String!) {
175
+ getContactInfosByCompanyId(companyId: $companyId, partnerId: $partnerId) {
176
+ id
177
+ name
178
+ address
179
+ gender
180
+ identityNumber
181
+ birthDate
182
+ email
183
+ phone
184
+ createdStamp
185
+ createdBy
186
+ memberLevel
187
+ }
188
+ }
189
+ `;
190
+ exports.GET_PROVINCES = (0, graphql_tag_1.gql) `
191
+ query GetProvinces {
192
+ getProvinces {
193
+ geoId
194
+ geoTypeId
195
+ geoName
196
+ geoNameLocal
197
+ geoCode
198
+ geoSecCode
199
+ abbreviation
200
+ vnPostId
201
+ jtExpressId
202
+ vnPostRegion
203
+ inetId
204
+ lastUpdatedStamp
205
+ lastUpdatedTxStamp
206
+ createdStamp
207
+ createdTxStamp
208
+ }
209
+ }
210
+ `;
211
+ exports.GET_DISTRICTS = (0, graphql_tag_1.gql) `
212
+ query GetDistricts($provinceId: String!) {
213
+ getDistricts(provinceId: $provinceId) {
214
+ geoId
215
+ geoTypeId
216
+ geoName
217
+ geoNameLocal
218
+ geoCode
219
+ geoSecCode
220
+ abbreviation
221
+ vnPostId
222
+ jtExpressId
223
+ vnPostRegion
224
+ inetId
225
+ lastUpdatedStamp
226
+ lastUpdatedTxStamp
227
+ createdStamp
228
+ createdTxStamp
229
+ }
230
+ }
231
+ `;
232
+ exports.GET_WARDS = (0, graphql_tag_1.gql) `
233
+ query GetWards($districtId: String!) {
234
+ getWards(districtId: $districtId) {
235
+ geoId
236
+ geoTypeId
237
+ geoName
238
+ geoNameLocal
239
+ geoCode
240
+ geoSecCode
241
+ abbreviation
242
+ vnPostId
243
+ jtExpressId
244
+ vnPostRegion
245
+ inetId
246
+ lastUpdatedStamp
247
+ lastUpdatedTxStamp
248
+ createdStamp
249
+ createdTxStamp
250
+ }
65
251
  }
66
- }
67
252
  `;
@@ -6,6 +6,7 @@ import { UserService } from "../lib/user/index";
6
6
  import { PaymentService } from "../lib/payment/index";
7
7
  import { CrmService } from "../lib/crm/index";
8
8
  import { WarehouseService } from "../lib/warehouse/index";
9
+ import { ComputingService } from "../lib/computing/index";
9
10
  export interface Endpoints {
10
11
  product: string;
11
12
  crm: string;
@@ -15,6 +16,7 @@ export interface Endpoints {
15
16
  payment: string;
16
17
  service: string;
17
18
  warehouse: string;
19
+ computing: string;
18
20
  }
19
21
  export declare class SDK {
20
22
  orgId: string;
@@ -28,7 +30,9 @@ export declare class SDK {
28
30
  crm: CrmService;
29
31
  service: ServiceManagementService;
30
32
  warehouse: WarehouseService;
33
+ computing: ComputingService;
31
34
  token: string | null;
32
35
  constructor(orgId: string, storeId: string, storefrontAccessToken: string);
33
36
  setToken(token: string): void;
37
+ setStoreId(storeId: string): void;
34
38
  }
@@ -12,6 +12,7 @@ const helpers_1 = require("../utils/helpers");
12
12
  const index_6 = require("../lib/payment/index");
13
13
  const index_7 = require("../lib/crm/index");
14
14
  const index_8 = require("../lib/warehouse/index");
15
+ const index_9 = require("../lib/computing/index");
15
16
  class SDK {
16
17
  constructor(orgId, storeId, storefrontAccessToken) {
17
18
  this.orgId = orgId;
@@ -20,6 +21,7 @@ class SDK {
20
21
  this.token = null;
21
22
  (0, helpers_1.validateStorefrontAccessToken)(storefrontAccessToken);
22
23
  const endpoints = config_1.environmentEndpoints.dev;
24
+ console.log("🚀 ~ SDK ~ endpoints:", endpoints.computing);
23
25
  this.product = new index_1.ProductService(endpoints.product, orgId, storeId);
24
26
  this.auth = new index_2.AuthService(endpoints.auth, orgId, storeId);
25
27
  this.order = new index_3.OrderService(endpoints.order, orgId, storeId);
@@ -28,6 +30,7 @@ class SDK {
28
30
  this.crm = new index_7.CrmService(endpoints.crm, orgId, storeId);
29
31
  this.service = new index_4.ServiceManagementService(endpoints.service, orgId, storeId);
30
32
  this.warehouse = new index_8.WarehouseService(endpoints.warehouse, orgId, storeId);
33
+ this.computing = new index_9.ComputingService(endpoints.computing, orgId, storeId);
31
34
  // Initialize other services here
32
35
  }
33
36
  setToken(token) {
@@ -41,7 +44,22 @@ class SDK {
41
44
  this.crm.setToken(token);
42
45
  this.service.setToken(token);
43
46
  this.warehouse.setToken(token);
47
+ this.computing.setToken(token);
44
48
  // Set token for other services here
45
49
  }
50
+ // các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
51
+ // src/service.ts
52
+ setStoreId(storeId) {
53
+ this.storeId = storeId;
54
+ this.product.setStoreId(storeId);
55
+ this.auth.setStoreId(storeId);
56
+ this.order.setStoreId(storeId);
57
+ this.user.setStoreId(storeId);
58
+ this.payment.setStoreId(storeId);
59
+ this.crm.setStoreId(storeId);
60
+ this.service.setStoreId(storeId);
61
+ this.warehouse.setStoreId(storeId);
62
+ // Set storeId for other services here
63
+ }
46
64
  }
47
65
  exports.SDK = SDK;
@@ -0,0 +1,13 @@
1
+ import { Service } from "../serviceSDK";
2
+ export declare class ComputingService extends Service {
3
+ /**
4
+ * Constructs a new OrderService instance.
5
+ * @param endpoint - The endpoint URL for the service.
6
+ * @param orgId - The organization ID.
7
+ * @param storeId - The store ID.
8
+ */
9
+ constructor(endpoint: string, orgId: string, storeId: string);
10
+ setToken(token: string): void;
11
+ computingDetail(computingId: string): Promise<any>;
12
+ portNats(computingId: string): Promise<any>;
13
+ }
@@ -0,0 +1,61 @@
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.ComputingService = void 0;
13
+ const queries_1 = require("../../graphql/computing/queries");
14
+ const serviceSDK_1 = require("../serviceSDK");
15
+ class ComputingService extends serviceSDK_1.Service {
16
+ /**
17
+ * Constructs a new OrderService instance.
18
+ * @param endpoint - The endpoint URL for the service.
19
+ * @param orgId - The organization ID.
20
+ * @param storeId - The store ID.
21
+ */
22
+ constructor(endpoint, orgId, storeId) {
23
+ super(endpoint, orgId, storeId);
24
+ }
25
+ setToken(token) {
26
+ this.token = token;
27
+ }
28
+ computingDetail(computingId) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ const query = queries_1.COMPUTING_DETAIL;
31
+ const variables = {
32
+ computingId,
33
+ };
34
+ try {
35
+ const response = yield this.graphqlQuery(query, variables);
36
+ return response.computingDetail;
37
+ }
38
+ catch (error) {
39
+ console.log(`Error in computingDetail: ${error}`);
40
+ throw error;
41
+ }
42
+ });
43
+ }
44
+ portNats(computingId) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const query = queries_1.PORTNATS;
47
+ const variables = {
48
+ computingId,
49
+ };
50
+ try {
51
+ const response = yield this.graphqlQuery(query, variables);
52
+ return response.portNats;
53
+ }
54
+ catch (error) {
55
+ console.log(`Error in portNats: ${error}`);
56
+ throw error;
57
+ }
58
+ });
59
+ }
60
+ }
61
+ exports.ComputingService = ComputingService;
@@ -2,6 +2,7 @@ import { AddOpportunityRequest, GetOpportunityRequest } from '../../types/crm';
2
2
  import { Service } from '../serviceSDK';
3
3
  export declare class CrmService extends Service {
4
4
  constructor(endpoint: string, orgId: string, storeId: string);
5
+ setToken(token: string): void;
5
6
  addOpportunity(addOpportunityRequest: AddOpportunityRequest, performerId: string): Promise<any>;
6
7
  getListOpportunity(performerId: string, getOpportunityRequest: GetOpportunityRequest): Promise<any>;
7
8
  getListTodo(workEffortId: string[]): Promise<any>;
@@ -17,6 +17,9 @@ class CrmService extends serviceSDK_1.Service {
17
17
  constructor(endpoint, orgId, storeId) {
18
18
  super(endpoint, orgId, storeId);
19
19
  }
20
+ setToken(token) {
21
+ this.token = token;
22
+ }
20
23
  addOpportunity(addOpportunityRequest, performerId) {
21
24
  return __awaiter(this, void 0, void 0, function* () {
22
25
  const mutation = mutations_1.ADD_OPPORTUNITY_MUTATION;
@@ -304,6 +304,7 @@ export declare class OrderService extends Service {
304
304
  * @throws If an error occurs while updating the customer and shipping address.
305
305
  */
306
306
  getListSellOrder(requestData: OrderQuery): Promise<any>;
307
+ getDiaries(requestData: OrderQuery): Promise<any>;
307
308
  /**
308
309
  * Get list sale order status
309
310
  * @returns A promise that resolves when the customer and shipping address are updated.
@@ -446,4 +447,6 @@ export declare class OrderService extends Service {
446
447
  * @throws If an error occurs while updating the customer and shipping address.
447
448
  */
448
449
  deleteNoteWithoutLogin(orderId: string, noteId: string, deletedBy: string): Promise<any>;
450
+ updateOrderDescription(orderId: string, description: string): Promise<any>;
451
+ getOrderDetail(orderId: string): Promise<any>;
449
452
  }
@@ -25,7 +25,6 @@ class OrderService extends serviceSDK_1.Service {
25
25
  super(endpoint, orgId, storeId);
26
26
  }
27
27
  setToken(token) {
28
- console.log("🚀 ~ OrderService ~ setToken ~ token:", token);
29
28
  this.token = token;
30
29
  }
31
30
  /**
@@ -784,6 +783,25 @@ class OrderService extends serviceSDK_1.Service {
784
783
  }
785
784
  });
786
785
  }
786
+ getDiaries(requestData) {
787
+ return __awaiter(this, void 0, void 0, function* () {
788
+ // Convert requestData to a format suitable for URLSearchParams
789
+ const params = new URLSearchParams(Object.entries(requestData).reduce((acc, [key, value]) => {
790
+ acc[key] = Array.isArray(value) ? value.join(",") : value.toString();
791
+ return acc;
792
+ }, {})).toString();
793
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/diaries?${params}`;
794
+ const method = "GET";
795
+ try {
796
+ const response = yield this.restApiCallWithToken(endpoint, method);
797
+ return response;
798
+ }
799
+ catch (error) {
800
+ console.error(`Error in getListSellOrder: ${error}`);
801
+ throw error;
802
+ }
803
+ });
804
+ }
787
805
  /**
788
806
  * Get list sale order status
789
807
  * @returns A promise that resolves when the customer and shipping address are updated.
@@ -1161,22 +1179,26 @@ class OrderService extends serviceSDK_1.Service {
1161
1179
  }
1162
1180
  });
1163
1181
  }
1182
+ updateOrderDescription(orderId, description) {
1183
+ return __awaiter(this, void 0, void 0, function* () {
1184
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/description`;
1185
+ const method = "PUT";
1186
+ try {
1187
+ const response = yield this.restApiCallWithToken(endpoint, method, description, {
1188
+ 'Content-Type': 'text/plain'
1189
+ });
1190
+ return response;
1191
+ }
1192
+ catch (error) {
1193
+ console.log(`Error in updateOrderDescription: ${error}`);
1194
+ throw error;
1195
+ }
1196
+ });
1197
+ }
1198
+ getOrderDetail(orderId) {
1199
+ return __awaiter(this, void 0, void 0, function* () {
1200
+ return this.restApiCallWithToken(`/orders/${this.orgId}/${this.storeId}/${orderId}/sale_order`, 'GET');
1201
+ });
1202
+ }
1164
1203
  }
1165
1204
  exports.OrderService = OrderService;
1166
- const data = {
1167
- orderType: "POS_SALE",
1168
- customer_id: "20.51269",
1169
- line_items: [
1170
- {
1171
- id: "121122",
1172
- productName: "",
1173
- quantity: 1,
1174
- typeDiscount: "MONEY",
1175
- parent_id: "121121",
1176
- product_id: "121122",
1177
- supplier_id: "",
1178
- input_price: 220000,
1179
- discount_amount: 0,
1180
- },
1181
- ],
1182
- };
@@ -328,9 +328,6 @@ class ServiceManagementService extends serviceSDK_1.Service {
328
328
  }
329
329
  });
330
330
  }
331
- // query GetActionAttribute {
332
- // getActionAttribute(actionId: "20.27592", attributeName: "ztbee")
333
- // }
334
331
  getActionAttribute(actionId, attributeName) {
335
332
  return __awaiter(this, void 0, void 0, function* () {
336
333
  const query = queries_1.GET_ACTION_ATTRIBUTE;
@@ -8,6 +8,7 @@ export declare class Service {
8
8
  protected endpoint: string;
9
9
  constructor(endpoint: string, orgId: string, storeId: string);
10
10
  setToken(token: string): void;
11
+ setStoreId(storeId: string): void;
11
12
  protected graphqlQuery(query: DocumentNode, variables: any): Promise<any>;
12
13
  protected graphqlMutation(mutation: DocumentNode, variables: any): Promise<any>;
13
14
  protected restApiCallWithToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
@@ -16,11 +16,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.Service = void 0;
17
17
  const client_1 = require("@apollo/client");
18
18
  const axios_1 = __importDefault(require("axios"));
19
+ const cross_fetch_1 = __importDefault(require("cross-fetch"));
19
20
  class Service {
20
21
  constructor(endpoint, orgId, storeId) {
21
22
  this.token = null;
22
23
  this.client = new client_1.ApolloClient({
23
- uri: endpoint,
24
+ link: new client_1.HttpLink({ uri: endpoint, fetch: cross_fetch_1.default }),
25
+ // uri: endpoint,
24
26
  cache: new client_1.InMemoryCache(),
25
27
  defaultOptions: {
26
28
  query: {
@@ -35,6 +37,9 @@ class Service {
35
37
  setToken(token) {
36
38
  this.token = token;
37
39
  }
40
+ setStoreId(storeId) {
41
+ this.storeId = storeId;
42
+ }
38
43
  graphqlQuery(query, variables) {
39
44
  return __awaiter(this, void 0, void 0, function* () {
40
45
  try {
@@ -43,6 +48,13 @@ class Service {
43
48
  ${query}
44
49
  `,
45
50
  variables,
51
+ context: {
52
+ method: "POST",
53
+ headers: {
54
+ "Content-Type": "application/json",
55
+ partnerId: this.orgId,
56
+ },
57
+ },
46
58
  });
47
59
  if (errors) {
48
60
  throw new Error(`GraphQL error! errors: ${errors}`);
@@ -94,7 +106,7 @@ class Service {
94
106
  restApiCallWithNoToken(path, method, data, headers) {
95
107
  return __awaiter(this, void 0, void 0, function* () {
96
108
  try {
97
- const modifiedHeaders = Object.assign(Object.assign({}, headers), { PartnerId: this.orgId });
109
+ const modifiedHeaders = Object.assign(Object.assign({}, headers), { Partnerid: this.orgId });
98
110
  const response = yield (0, axios_1.default)({
99
111
  url: this.endpoint + path,
100
112
  method,
@@ -104,9 +116,6 @@ class Service {
104
116
  return response.data;
105
117
  }
106
118
  catch (error) {
107
- if (error.response.status === 401) {
108
- throw new Error("Không có quyền truy cập!");
109
- }
110
119
  console.log(`Error in restApiCallWithNoToken: ${error}`);
111
120
  throw error;
112
121
  }
@@ -1,5 +1,5 @@
1
1
  import { Service } from "../serviceSDK";
2
- import { createCompanyRequest, createCustomerRequest, dataCustomerRequest, updateCustomerRequest } from "../../types/user";
2
+ import { createCompanyRequest, createCustomerRequest, dataCustomerRequest, updateCustomerRequest, customerQuery, searchCustomersResponse, employeesQuery } from "../../types/user";
3
3
  export declare class UserService extends Service {
4
4
  constructor(endpoint: string, orgId: string, storeId: string);
5
5
  getPersonByPartyIds(partyIds: string[]): Promise<any>;
@@ -10,4 +10,14 @@ export declare class UserService extends Service {
10
10
  searchCompany(keyword: string, limit: number): Promise<any>;
11
11
  createCustomerV2(createCustomerRequest: createCustomerRequest, createdBy: string): Promise<any>;
12
12
  createCustomer(dataCustomerRequest: dataCustomerRequest, createdBy: string, type: string): Promise<any>;
13
+ searchCustomer(searchParams: customerQuery): Promise<searchCustomersResponse>;
14
+ searchEmployees(searchParams: employeesQuery): Promise<any>;
15
+ getPositionsByEmployeeId(employeeId: string): Promise<any>;
16
+ getStoreChannelIdsByEmployeeId(employeeId: string): Promise<any>;
17
+ getEmployeesByStoreChannelId(): Promise<any>;
18
+ getCompanyByContactInfoId(contactId: string): Promise<any>;
19
+ getContactInfosByCompanyId(companyId: string): Promise<any>;
20
+ getProvinces(): Promise<any>;
21
+ getDistricts(provinceId: string): Promise<any>;
22
+ getWards(districtId: string): Promise<any>;
13
23
  }
@@ -169,5 +169,177 @@ class UserService extends serviceSDK_1.Service {
169
169
  }
170
170
  });
171
171
  }
172
+ searchCustomer(searchParams) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ const query = queries_1.SEARCH_CUSTOMER;
175
+ const variables = {
176
+ keyword: searchParams.keyword,
177
+ type: searchParams.type,
178
+ startCreatedDate: searchParams.startCreatedDate,
179
+ endCreatedDate: searchParams.endCreatedDate,
180
+ memberLevel: searchParams.memberLevel,
181
+ partnerId: this.orgId,
182
+ currentPage: searchParams.currentPage,
183
+ pageSize: searchParams.pageSize,
184
+ };
185
+ try {
186
+ const response = yield this.graphqlQuery(query, variables);
187
+ return response.searchCustomers;
188
+ }
189
+ catch (error) {
190
+ console.log(`Error in searchCustomer: ${error}`);
191
+ throw error;
192
+ }
193
+ });
194
+ }
195
+ searchEmployees(searchParams) {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ const query = queries_1.SEARCH_EMPLOYEES;
198
+ const variables = {
199
+ keyword: searchParams.keyword,
200
+ partnerId: this.orgId,
201
+ positionShortName: searchParams.positionShortName,
202
+ };
203
+ try {
204
+ const response = yield this.graphqlQuery(query, variables);
205
+ return response.searchEmployees;
206
+ }
207
+ catch (error) {
208
+ console.log(`Error inseachEmployess: ${error}`);
209
+ throw error;
210
+ }
211
+ });
212
+ }
213
+ getPositionsByEmployeeId(employeeId) {
214
+ return __awaiter(this, void 0, void 0, function* () {
215
+ const query = queries_1.GET_POSTIONS_BY_EMPLOYEES_ID;
216
+ const variables = {
217
+ employeeId,
218
+ partnerId: this.orgId,
219
+ };
220
+ try {
221
+ const response = yield this.graphqlQuery(query, variables);
222
+ return response.getPositionsByEmployeeId;
223
+ }
224
+ catch (error) {
225
+ console.log(`Error in getPositionsByEmployeeId: ${error}`);
226
+ throw error;
227
+ }
228
+ });
229
+ }
230
+ getStoreChannelIdsByEmployeeId(employeeId) {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ const query = queries_1.GET_STORE_CHANEL_IDS_BY_EMPLOYESS_ID;
233
+ const variables = {
234
+ employeeId,
235
+ partnerId: this.orgId,
236
+ };
237
+ try {
238
+ const response = yield this.graphqlQuery(query, variables);
239
+ return response.getStoreChannelIdsByEmployeeId;
240
+ }
241
+ catch (error) {
242
+ console.log(`Error in getStoreChannelIdsByEmployeeId: ${error}`);
243
+ throw error;
244
+ }
245
+ });
246
+ }
247
+ getEmployeesByStoreChannelId() {
248
+ return __awaiter(this, void 0, void 0, function* () {
249
+ const query = queries_1.GET_EMPLOYEES_BY_STORE_CHANEL_ID;
250
+ const variables = {
251
+ storeChannelId: this.storeId,
252
+ partnerId: this.orgId,
253
+ };
254
+ try {
255
+ const response = yield this.graphqlQuery(query, variables);
256
+ return response.getEmployeesByStoreChannelId;
257
+ }
258
+ catch (error) {
259
+ console.log(`Error in getEmployeesByStoreChannelId: ${error}`);
260
+ throw error;
261
+ }
262
+ });
263
+ }
264
+ getCompanyByContactInfoId(contactId) {
265
+ return __awaiter(this, void 0, void 0, function* () {
266
+ const query = queries_1.GET_COMPANY_BY_CONTACT_INFO_ID;
267
+ const variables = {
268
+ contactId,
269
+ partnerId: this.orgId,
270
+ };
271
+ try {
272
+ const response = yield this.graphqlQuery(query, variables);
273
+ return response.getCompanyByContactInfoId;
274
+ }
275
+ catch (error) {
276
+ console.log(`Error in getCompanyByContactInfoId: ${error}`);
277
+ throw error;
278
+ }
279
+ });
280
+ }
281
+ getContactInfosByCompanyId(companyId) {
282
+ return __awaiter(this, void 0, void 0, function* () {
283
+ const query = queries_1.GET_CONTACT_INFOS_BY_COMPANY_ID;
284
+ const variables = {
285
+ companyId,
286
+ partnerId: this.orgId,
287
+ };
288
+ try {
289
+ const response = yield this.graphqlQuery(query, variables);
290
+ return response.getContactInfosByCompanyId;
291
+ }
292
+ catch (error) {
293
+ console.log(`Error in getContactInfosByCompanyId: ${error}`);
294
+ throw error;
295
+ }
296
+ });
297
+ }
298
+ getProvinces() {
299
+ return __awaiter(this, void 0, void 0, function* () {
300
+ const query = queries_1.GET_PROVINCES;
301
+ const variables = {};
302
+ try {
303
+ const response = yield this.graphqlQuery(query, variables);
304
+ return response.getProvinces;
305
+ }
306
+ catch (error) {
307
+ console.log(`Error in getProvinces: ${error}`);
308
+ throw error;
309
+ }
310
+ });
311
+ }
312
+ getDistricts(provinceId) {
313
+ return __awaiter(this, void 0, void 0, function* () {
314
+ const query = queries_1.GET_DISTRICTS;
315
+ const variables = {
316
+ provinceId,
317
+ };
318
+ try {
319
+ const response = yield this.graphqlQuery(query, variables);
320
+ return response.getDistricts;
321
+ }
322
+ catch (error) {
323
+ console.log(`Error in getDistricts: ${error}`);
324
+ throw error;
325
+ }
326
+ });
327
+ }
328
+ getWards(districtId) {
329
+ return __awaiter(this, void 0, void 0, function* () {
330
+ const query = queries_1.GET_WARDS;
331
+ const variables = {
332
+ districtId,
333
+ };
334
+ try {
335
+ const response = yield this.graphqlQuery(query, variables);
336
+ return response.getWards;
337
+ }
338
+ catch (error) {
339
+ console.log(`Error in getWards: ${error}`);
340
+ throw error;
341
+ }
342
+ });
343
+ }
172
344
  }
173
345
  exports.UserService = UserService;
@@ -1,9 +1,9 @@
1
1
  export interface LineItem {
2
2
  quantity: number;
3
- parent_id: string;
3
+ parent_id?: string;
4
4
  product_id: string;
5
- input_price: number;
6
- discount_amount: number;
5
+ input_price?: number;
6
+ discount_amount?: number;
7
7
  }
8
8
  export interface DiscountCampaign {
9
9
  type_discount: string;
@@ -31,23 +31,24 @@ export interface CampaignPromotion {
31
31
  campaign_action_type: string;
32
32
  }
33
33
  export interface OrderQuery {
34
- order_id: string;
35
- status: [number];
36
- status_ignore: [number];
37
- sub_status: string;
38
- ffm_status: string;
39
- sub_type: string;
40
- payment_method: string;
41
- keyword: string;
42
- customer_multi_value: string;
43
- product_multi_value: string;
44
- customer_id: string;
45
- created_by: string;
46
- date_create_from: number;
47
- date_create_to: number;
48
- date_update_from: number;
49
- date_update_to: number;
50
- employee_assign: string;
51
- currentPage: number;
52
- maxResult: number;
34
+ order_id?: string;
35
+ status?: [number];
36
+ status_ignore?: [number];
37
+ sub_status?: string;
38
+ ffm_status?: string;
39
+ sub_type?: string;
40
+ payment_method?: string;
41
+ keyword?: string;
42
+ customer_multi_value?: string;
43
+ product_multi_value?: string;
44
+ customer_id?: string;
45
+ created_by?: string;
46
+ date_create_from?: number;
47
+ date_create_to?: number;
48
+ date_update_from?: number;
49
+ date_update_to?: number;
50
+ employee_assign?: string;
51
+ currentPage?: number;
52
+ maxResult?: number;
53
+ source?: string;
53
54
  }
@@ -6,6 +6,8 @@ export interface Product {
6
6
  price: number;
7
7
  available: boolean;
8
8
  categories: Category[];
9
+ featuredImage: string;
10
+ subType: string;
9
11
  }
10
12
  export interface Category {
11
13
  id: string;
@@ -25,4 +25,5 @@ export interface ServiceRequest {
25
25
  urlPublic: String;
26
26
  serviceType: Number;
27
27
  actionResult: String;
28
+ attrs: {};
28
29
  }
@@ -64,3 +64,32 @@ export interface dataCustomerRequest {
64
64
  address: string;
65
65
  birthDate: Date;
66
66
  }
67
+ export interface customerQuery {
68
+ keyword: string;
69
+ type: string;
70
+ startCreatedDate?: number;
71
+ endCreatedDate?: number;
72
+ memberLevel?: string;
73
+ currentPage?: number | 1;
74
+ pageSize: number | 20;
75
+ }
76
+ export interface employeesQuery {
77
+ keyword: string;
78
+ positionShortName: string;
79
+ }
80
+ export interface customer {
81
+ id: string;
82
+ name: string;
83
+ address: string;
84
+ gender: string;
85
+ identityNumber: string;
86
+ birthDate: Date;
87
+ email: string;
88
+ phone: string;
89
+ createdStamp: Date;
90
+ createdBy: string;
91
+ memberLevel: string;
92
+ }
93
+ export interface searchCustomersResponse {
94
+ content: customer[];
95
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/storefront-js-client",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [
@@ -22,6 +22,7 @@
22
22
  "@apollo/client": "3.9.11",
23
23
  "apollo-boost": "^0.4.9",
24
24
  "axios": "^1.6.8",
25
+ "cross-fetch": "^4.0.0",
25
26
  "crypto-js": "^4.2.0",
26
27
  "graphql": "^15.8.0",
27
28
  "graphql-request": "^6.1.0",