@longvansoftware/storefront-js-client 2.2.6 → 2.2.7-beta.10

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.
Files changed (34) hide show
  1. package/README.md +93 -93
  2. package/dist/src/graphql/auth/mutations.d.ts +3 -0
  3. package/dist/src/graphql/auth/mutations.js +134 -89
  4. package/dist/src/graphql/auth/queries.d.ts +3 -0
  5. package/dist/src/graphql/auth/queries.js +56 -21
  6. package/dist/src/graphql/campaign/mutations.d.ts +1 -0
  7. package/dist/src/graphql/campaign/mutations.js +31 -0
  8. package/dist/src/graphql/campaign/queries.js +248 -248
  9. package/dist/src/graphql/cloud/mutations.js +103 -103
  10. package/dist/src/graphql/cloud/queries.js +112 -112
  11. package/dist/src/graphql/computing/mutations.js +96 -96
  12. package/dist/src/graphql/computing/queries.js +41 -41
  13. package/dist/src/graphql/crm/mutations.js +799 -799
  14. package/dist/src/graphql/crm/queries.js +615 -615
  15. package/dist/src/graphql/payment/mutations.js +39 -39
  16. package/dist/src/graphql/payment/queries.js +57 -57
  17. package/dist/src/graphql/paymentV2/mutations.js +4 -4
  18. package/dist/src/graphql/paymentV2/queries.js +59 -59
  19. package/dist/src/graphql/product/queries.js +431 -431
  20. package/dist/src/graphql/service/mutations.js +304 -304
  21. package/dist/src/graphql/service/queries.js +131 -131
  22. package/dist/src/graphql/user/mutations.js +110 -110
  23. package/dist/src/graphql/user/queries.js +281 -279
  24. package/dist/src/lib/auth/index.d.ts +16 -0
  25. package/dist/src/lib/auth/index.js +173 -0
  26. package/dist/src/lib/campaign/index.d.ts +2 -1
  27. package/dist/src/lib/campaign/index.js +20 -2
  28. package/dist/src/lib/order/index.d.ts +2 -0
  29. package/dist/src/lib/order/index.js +26 -0
  30. package/dist/src/lib/serviceSDK.js +12 -12
  31. package/dist/src/lib/user/index.js +1 -0
  32. package/package.json +43 -43
  33. package/dist/src/lib/shareZalo/index.d.ts +0 -5
  34. package/dist/src/lib/shareZalo/index.js +0 -32
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AuthService = void 0;
13
+ // lib/auth/index.ts
13
14
  const serviceSDK_1 = require("../serviceSDK");
14
15
  const mutations_1 = require("../../graphql/auth/mutations");
15
16
  const queries_1 = require("../../graphql/auth/queries");
@@ -68,5 +69,177 @@ class AuthService extends serviceSDK_1.Service {
68
69
  }
69
70
  });
70
71
  }
72
+ /**
73
+ * Retrieves user login information using the provided access token.
74
+ *
75
+ * @param {string} accessToken - The access token used to authenticate the request.
76
+ * @returns {Promise<any>} A promise that resolves to the user login information.
77
+ * @throws Will throw an error if the GraphQL query fails.
78
+ */
79
+ getUserLoginByToken(accessToken) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ const query = queries_1.GET_USER_LOGIN_BY_TOKEN;
82
+ const variables = {
83
+ accessToken,
84
+ };
85
+ try {
86
+ const response = yield this.graphqlQuery(query, variables);
87
+ return response.getUserLoginByToken;
88
+ }
89
+ catch (error) {
90
+ console.log(`Error in getUserLoginByToken: ${error}`);
91
+ throw error;
92
+ }
93
+ });
94
+ }
95
+ updateProfile(userLoginId, name, phone, email) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const variables = {
98
+ userLoginId,
99
+ name,
100
+ phone,
101
+ email,
102
+ };
103
+ try {
104
+ const response = yield this.graphqlMutation(mutations_1.UPDATE_PROFILE_MUTATION, variables);
105
+ return response.updateProfile;
106
+ }
107
+ catch (error) {
108
+ console.log(`Error in updateProfile: ${error}`);
109
+ throw error;
110
+ }
111
+ });
112
+ }
113
+ getUserLoginByUserLoginId(userLoginId) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ const query = queries_1.GET_USER_LOGIN_BY_USER_LOGIN_ID;
116
+ const variables = {
117
+ userLoginId,
118
+ };
119
+ try {
120
+ const response = yield this.graphqlQuery(query, variables);
121
+ return response.getUserLoginByUserLoginId;
122
+ }
123
+ catch (error) {
124
+ console.log(`Error in getUserLoginByUserLoginId: ${error}`);
125
+ throw error;
126
+ }
127
+ });
128
+ }
129
+ checkUsernameExisted(username) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ const variables = {
132
+ username,
133
+ orgId: this.orgId,
134
+ };
135
+ try {
136
+ const response = yield this.graphqlQuery(queries_1.CHECK_USERNAME_EXISTED, variables);
137
+ return response.checkUsernameExisted;
138
+ }
139
+ catch (error) {
140
+ console.log(`Error in checkUsernameExisted: ${error}`);
141
+ throw error;
142
+ }
143
+ });
144
+ }
145
+ linkingUserLoginAndUserDetail(userLoginId, partyId) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ const variables = {
148
+ userLoginId,
149
+ partyId,
150
+ };
151
+ try {
152
+ const response = yield this.graphqlMutation(mutations_1.LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION, variables);
153
+ return response.linkingUserLoginAndUserDetail;
154
+ }
155
+ catch (error) {
156
+ console.log(`Error in linkingUserLoginAndUserDetail: ${error}`);
157
+ throw error;
158
+ }
159
+ });
160
+ }
161
+ createUserDetail(userLoginId) {
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ const variables = {
164
+ userLoginId,
165
+ partnerId: this.orgId,
166
+ };
167
+ try {
168
+ const response = yield this.graphqlMutation(mutations_1.CREATE_USER_DETAIL_MUTATION, variables);
169
+ return response.createUserDetail;
170
+ }
171
+ catch (error) {
172
+ console.log(`Error in createUserDetail: ${error}`);
173
+ throw error;
174
+ }
175
+ });
176
+ }
177
+ // mutation VerifyCode {
178
+ // sendSmsVerifyCode(orgId: "FYP", username: "0971879660") {
179
+ // id
180
+ // code
181
+ // username
182
+ // timeExpired
183
+ // }
184
+ // }
185
+ sendSmsVerifyCode(username) {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ const query = mutations_1.SEND_SMS_VERIFY_CODE_MUTATION;
188
+ const variables = {
189
+ orgId: this.orgId,
190
+ username,
191
+ };
192
+ try {
193
+ const response = yield this.graphqlMutation(query, variables);
194
+ return response.sendSmsVerifyCode;
195
+ }
196
+ catch (error) {
197
+ console.log(`Error in sendSmsVerifyCode: ${error}`);
198
+ throw error;
199
+ }
200
+ });
201
+ }
202
+ // mutation VerifyCode {
203
+ // verifyCode(
204
+ // orgId: "FYP"
205
+ // verifyCodeRequest: { username: "0971879660", code: "999999" }
206
+ // )
207
+ // }
208
+ verifyCode(username, code) {
209
+ return __awaiter(this, void 0, void 0, function* () {
210
+ const query = mutations_1.VERIFY_CODE_MUTATION;
211
+ const variables = {
212
+ orgId: this.orgId,
213
+ verifyCodeRequest: { username, code },
214
+ };
215
+ try {
216
+ const response = yield this.graphqlMutation(query, variables);
217
+ return response.verifyCode;
218
+ }
219
+ catch (error) {
220
+ console.log(`Error in verifyCode: ${error}`);
221
+ throw error;
222
+ }
223
+ });
224
+ }
225
+ resetPassword(username, newPassword, accessToken) {
226
+ return __awaiter(this, void 0, void 0, function* () {
227
+ const query = mutations_1.RESET_PASSWORD_MUTATION;
228
+ const variables = {
229
+ orgId: this.orgId,
230
+ username,
231
+ newPassword,
232
+ accessToken,
233
+ };
234
+ try {
235
+ const response = yield this.graphqlMutation(query, variables);
236
+ return response.resetPassword;
237
+ }
238
+ catch (error) {
239
+ console.log(`Error in resetPassword: ${error}`);
240
+ throw error;
241
+ }
242
+ });
243
+ }
71
244
  }
72
245
  exports.AuthService = AuthService;
@@ -9,8 +9,9 @@ export declare class CampaignService extends Service {
9
9
  constructor(endpoint: string, orgId: string, storeId: string);
10
10
  getCampaignActionActiveNow(customerId: string, campaignActionType: string): Promise<any>;
11
11
  searchVouchers(campaignId: String, campaignActionId: String, campaignActionType: String, customerId: String, excludeExpired: Boolean, pageNumber: number, pageSize: number): Promise<any>;
12
- checkValidVoucher(customerId: string, voucherCode: string): Promise<any>;
12
+ checkValidVoucher(customerId: string, campaignActionId: string): Promise<any>;
13
13
  getCampaignActiveNow(campaignActionType: string, customerId: string): Promise<any>;
14
14
  getPromotionProductPrice(productId: String, productPrice: number): Promise<any>;
15
15
  getVoucherAvailableForCustomer(campaignId: string, customerId: string, excludeExpired: Boolean): Promise<any>;
16
+ addCustomerToVoucher(campaignActionId: string, userId: string): Promise<any>;
16
17
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CampaignService = void 0;
13
13
  const serviceSDK_1 = require("../serviceSDK");
14
14
  const queries_1 = require("../../graphql/campaign/queries");
15
+ const mutations_1 = require("../../graphql/campaign/mutations");
15
16
  class CampaignService extends serviceSDK_1.Service {
16
17
  /**
17
18
  * Constructs a new CampaignService instance.
@@ -65,13 +66,13 @@ class CampaignService extends serviceSDK_1.Service {
65
66
  }
66
67
  });
67
68
  }
68
- checkValidVoucher(customerId, voucherCode) {
69
+ checkValidVoucher(customerId, campaignActionId) {
69
70
  return __awaiter(this, void 0, void 0, function* () {
70
71
  const query = queries_1.CHECK_VALID_VOUCHER;
71
72
  const variables = {
72
73
  partyId: this.orgId,
73
74
  customerId,
74
- voucherCode,
75
+ campaignActionId,
75
76
  };
76
77
  try {
77
78
  const response = yield this.graphqlQuery(query, variables);
@@ -138,5 +139,22 @@ class CampaignService extends serviceSDK_1.Service {
138
139
  }
139
140
  });
140
141
  }
142
+ addCustomerToVoucher(campaignActionId, userId) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ const query = mutations_1.ADD_CUSTOMER_ID_INTO_VOUCHER;
145
+ const variables = {
146
+ partyId: this.orgId,
147
+ campaignActionId,
148
+ userId,
149
+ };
150
+ try {
151
+ const response = yield this.graphqlMutation(query, variables);
152
+ return response.addCustomerIdIntoVoucher;
153
+ }
154
+ catch (error) {
155
+ throw error;
156
+ }
157
+ });
158
+ }
141
159
  }
142
160
  exports.CampaignService = CampaignService;
@@ -459,4 +459,6 @@ export declare class OrderService extends Service {
459
459
  enableProductDiary(orderId: string, orderItemId: string): Promise<any>;
460
460
  removeMemberDiscount(orderId: string): Promise<any>;
461
461
  getInfoChatApp(attributesName: string): Promise<any>;
462
+ updateCustomerInOrder(orderId: string, dataRequest: any): Promise<any>;
463
+ findCampaignActionGiftVoucher(): Promise<any>;
462
464
  }
@@ -1343,5 +1343,31 @@ class OrderService extends serviceSDK_1.Service {
1343
1343
  }
1344
1344
  });
1345
1345
  }
1346
+ updateCustomerInOrder(orderId, dataRequest) {
1347
+ return __awaiter(this, void 0, void 0, function* () {
1348
+ const endpoint = `/front/orders/${this.orgId}/${orderId}/customerInfo`;
1349
+ const method = "PUT";
1350
+ try {
1351
+ const response = yield this.restApiCallWithNoToken(endpoint, method, dataRequest);
1352
+ return response;
1353
+ }
1354
+ catch (error) {
1355
+ throw error;
1356
+ }
1357
+ });
1358
+ }
1359
+ findCampaignActionGiftVoucher() {
1360
+ return __awaiter(this, void 0, void 0, function* () {
1361
+ const endpoint = `/front/orders/${this.orgId}/findCampaignActionGiftVoucher`;
1362
+ const method = "GET";
1363
+ try {
1364
+ const response = yield this.restApiCallWithToken(endpoint, method);
1365
+ return response;
1366
+ }
1367
+ catch (error) {
1368
+ throw error;
1369
+ }
1370
+ });
1371
+ }
1346
1372
  }
1347
1373
  exports.OrderService = OrderService;
@@ -57,8 +57,8 @@ class Service {
57
57
  return __awaiter(this, void 0, void 0, function* () {
58
58
  try {
59
59
  const { data, errors } = yield this.client.query({
60
- query: (0, client_1.gql) `
61
- ${query}
60
+ query: (0, client_1.gql) `
61
+ ${query}
62
62
  `,
63
63
  variables,
64
64
  context: {
@@ -84,8 +84,8 @@ class Service {
84
84
  return __awaiter(this, void 0, void 0, function* () {
85
85
  try {
86
86
  const { data, errors } = yield this.client.mutate({
87
- mutation: (0, client_1.gql) `
88
- ${mutation}
87
+ mutation: (0, client_1.gql) `
88
+ ${mutation}
89
89
  `,
90
90
  variables,
91
91
  context: {
@@ -169,8 +169,8 @@ class Service {
169
169
  return __awaiter(this, void 0, void 0, function* () {
170
170
  try {
171
171
  const { data, errors } = yield this.client.query({
172
- query: (0, client_1.gql) `
173
- ${query}
172
+ query: (0, client_1.gql) `
173
+ ${query}
174
174
  `,
175
175
  variables,
176
176
  context: {
@@ -197,8 +197,8 @@ class Service {
197
197
  return __awaiter(this, void 0, void 0, function* () {
198
198
  try {
199
199
  const { data, errors } = yield this.client.mutate({
200
- mutation: (0, client_1.gql) `
201
- ${mutation}
200
+ mutation: (0, client_1.gql) `
201
+ ${mutation}
202
202
  `,
203
203
  variables,
204
204
  context: {
@@ -224,8 +224,8 @@ class Service {
224
224
  return __awaiter(this, void 0, void 0, function* () {
225
225
  try {
226
226
  const { data, errors } = yield this.client.query({
227
- query: (0, client_1.gql) `
228
- ${query}
227
+ query: (0, client_1.gql) `
228
+ ${query}
229
229
  `,
230
230
  variables,
231
231
  context: {
@@ -252,8 +252,8 @@ class Service {
252
252
  return __awaiter(this, void 0, void 0, function* () {
253
253
  try {
254
254
  const { data, errors } = yield this.client.mutate({
255
- mutation: (0, client_1.gql) `
256
- ${mutation}
255
+ mutation: (0, client_1.gql) `
256
+ ${mutation}
257
257
  `,
258
258
  variables,
259
259
  context: {
@@ -181,6 +181,7 @@ class UserService extends serviceSDK_1.Service {
181
181
  partnerId: this.orgId,
182
182
  currentPage: searchParams.currentPage,
183
183
  pageSize: searchParams.pageSize,
184
+ followSocialAppId: searchParams === null || searchParams === void 0 ? void 0 : searchParams.followSocialAppId,
184
185
  };
185
186
  try {
186
187
  const response = yield this.graphqlQuery(query, variables);
package/package.json CHANGED
@@ -1,43 +1,43 @@
1
- {
2
- "name": "@longvansoftware/storefront-js-client",
3
- "version": "2.2.6",
4
- "main": "dist/src/index.js",
5
- "types": "dist/src/index.d.ts",
6
- "files": [
7
- "dist/**/*.d.ts",
8
- "dist/**/*.js"
9
- ],
10
- "directories": {
11
- "test": "jest"
12
- },
13
- "scripts": {
14
- "test": "jest",
15
- "build": "tsc",
16
- "publish": "npm run build && npm publish"
17
- },
18
- "keywords": [],
19
- "author": "",
20
- "license": "ISC",
21
- "dependencies": {
22
- "@apollo/client": "3.9.11",
23
- "apollo-boost": "^0.4.9",
24
- "axios": "^1.6.8",
25
- "cross-fetch": "^4.0.0",
26
- "crypto-js": "^4.2.0",
27
- "graphql": "^15.8.0",
28
- "graphql-request": "^6.1.0",
29
- "graphql-tag": "^2.12.6",
30
- "react": "^18.2.0",
31
- "ts-node": "^10.9.2"
32
- },
33
- "devDependencies": {
34
- "@types/axios": "^0.14.0",
35
- "@types/crypto-js": "^4.2.2",
36
- "@types/jest": "^29.5.12",
37
- "@types/node": "^20.12.7",
38
- "jest": "^29.7.0",
39
- "ts-jest": "^29.1.2",
40
- "typescript": "^5.4.5"
41
- },
42
- "description": ""
43
- }
1
+ {
2
+ "name": "@longvansoftware/storefront-js-client",
3
+ "version": "2.2.7-beta.10",
4
+ "main": "dist/src/index.js",
5
+ "types": "dist/src/index.d.ts",
6
+ "files": [
7
+ "dist/**/*.d.ts",
8
+ "dist/**/*.js"
9
+ ],
10
+ "directories": {
11
+ "test": "jest"
12
+ },
13
+ "scripts": {
14
+ "test": "jest",
15
+ "build": "tsc",
16
+ "publish": "npm run build && npm publish"
17
+ },
18
+ "keywords": [],
19
+ "author": "",
20
+ "license": "ISC",
21
+ "dependencies": {
22
+ "@apollo/client": "3.9.11",
23
+ "apollo-boost": "^0.4.9",
24
+ "axios": "^1.6.8",
25
+ "cross-fetch": "^4.0.0",
26
+ "crypto-js": "^4.2.0",
27
+ "graphql": "^15.8.0",
28
+ "graphql-request": "^6.1.0",
29
+ "graphql-tag": "^2.12.6",
30
+ "react": "^18.2.0",
31
+ "ts-node": "^10.9.2"
32
+ },
33
+ "devDependencies": {
34
+ "@types/axios": "^0.14.0",
35
+ "@types/crypto-js": "^4.2.2",
36
+ "@types/jest": "^29.5.12",
37
+ "@types/node": "^20.12.7",
38
+ "jest": "^29.7.0",
39
+ "ts-jest": "^29.1.2",
40
+ "typescript": "^5.4.5"
41
+ },
42
+ "description": ""
43
+ }
@@ -1,5 +0,0 @@
1
- import { Service } from "../serviceSDK";
2
- export declare class ShareZaloService extends Service {
3
- constructor(endpoint: string, orgId: string, storeId: string);
4
- shareOrder(dataRequet: any): Promise<any>;
5
- }
@@ -1,32 +0,0 @@
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.ShareZaloService = void 0;
13
- const serviceSDK_1 = require("../serviceSDK");
14
- class ShareZaloService extends serviceSDK_1.Service {
15
- constructor(endpoint, orgId, storeId) {
16
- super(endpoint, orgId, storeId);
17
- }
18
- shareOrder(dataRequet) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- const endpoint = ``;
21
- const method = "POST";
22
- try {
23
- const response = yield this.restApiCallWithNoHeader(endpoint, method, dataRequet);
24
- return response;
25
- }
26
- catch (error) {
27
- throw error;
28
- }
29
- });
30
- }
31
- }
32
- exports.ShareZaloService = ShareZaloService;