@longvansoftware/storefront-js-client 2.7.2 → 2.7.4

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 (30) 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 +6 -0
  5. package/dist/src/graphql/auth/queries.js +71 -21
  6. package/dist/src/graphql/campaign/mutations.js +26 -24
  7. package/dist/src/graphql/campaign/queries.js +368 -368
  8. package/dist/src/graphql/cloud/mutations.js +103 -103
  9. package/dist/src/graphql/cloud/queries.js +112 -112
  10. package/dist/src/graphql/computing/mutations.js +96 -96
  11. package/dist/src/graphql/computing/queries.js +41 -41
  12. package/dist/src/graphql/crm/mutations.js +813 -813
  13. package/dist/src/graphql/crm/queries.js +661 -661
  14. package/dist/src/graphql/payment/mutations.js +40 -40
  15. package/dist/src/graphql/payment/queries.js +57 -57
  16. package/dist/src/graphql/paymentV2/mutations.js +47 -47
  17. package/dist/src/graphql/paymentV2/queries.js +176 -176
  18. package/dist/src/graphql/product/queries.js +453 -453
  19. package/dist/src/graphql/service/mutations.js +304 -304
  20. package/dist/src/graphql/service/queries.js +131 -131
  21. package/dist/src/graphql/user/mutations.js +110 -110
  22. package/dist/src/graphql/user/queries.js +279 -279
  23. package/dist/src/lib/auth/index.d.ts +26 -0
  24. package/dist/src/lib/auth/index.js +233 -0
  25. package/dist/src/lib/campaign/index.d.ts +1 -1
  26. package/dist/src/lib/campaign/index.js +2 -1
  27. package/dist/src/lib/serviceSDK.js +12 -12
  28. package/package.json +43 -43
  29. package/dist/src/lib/shareZalo/index.d.ts +0 -5
  30. package/dist/src/lib/shareZalo/index.js +0 -32
@@ -68,5 +68,238 @@ class AuthService extends serviceSDK_1.Service {
68
68
  }
69
69
  });
70
70
  }
71
+ /**
72
+ * Retrieves user login information using the provided access token.
73
+ *
74
+ * @param {string} accessToken - The access token used to authenticate the request.
75
+ * @returns {Promise<any>} A promise that resolves to the user login information.
76
+ * @throws Will throw an error if the GraphQL query fails.
77
+ */
78
+ getUserLoginByToken(accessToken) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const query = queries_1.GET_USER_LOGIN_BY_TOKEN;
81
+ const variables = {
82
+ accessToken,
83
+ };
84
+ try {
85
+ const response = yield this.graphqlQuery(query, variables);
86
+ return response.getUserLoginByToken;
87
+ }
88
+ catch (error) {
89
+ console.log(`Error in getUserLoginByToken: ${error}`);
90
+ throw error;
91
+ }
92
+ });
93
+ }
94
+ updateProfile(userLoginId, name, phone, email) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ const variables = {
97
+ userLoginId,
98
+ name,
99
+ phone,
100
+ email,
101
+ };
102
+ try {
103
+ const response = yield this.graphqlMutation(mutations_1.UPDATE_PROFILE_MUTATION, variables);
104
+ return response.updateProfile;
105
+ }
106
+ catch (error) {
107
+ console.log(`Error in updateProfile: ${error}`);
108
+ throw error;
109
+ }
110
+ });
111
+ }
112
+ getUserLoginByUserLoginId(userLoginId) {
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ const query = queries_1.GET_USER_LOGIN_BY_USER_LOGIN_ID;
115
+ const variables = {
116
+ userLoginId,
117
+ };
118
+ try {
119
+ const response = yield this.graphqlQuery(query, variables);
120
+ return response.getUserLoginByUserLoginId;
121
+ }
122
+ catch (error) {
123
+ console.log(`Error in getUserLoginByUserLoginId: ${error}`);
124
+ throw error;
125
+ }
126
+ });
127
+ }
128
+ checkUsernameExisted(username) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ const variables = {
131
+ username,
132
+ orgId: this.orgId,
133
+ };
134
+ try {
135
+ const response = yield this.graphqlQuery(queries_1.CHECK_USERNAME_EXISTED, variables);
136
+ return response.checkUsernameExisted;
137
+ }
138
+ catch (error) {
139
+ console.log(`Error in checkUsernameExisted: ${error}`);
140
+ throw error;
141
+ }
142
+ });
143
+ }
144
+ linkingUserLoginAndUserDetail(userLoginId, partyId) {
145
+ return __awaiter(this, void 0, void 0, function* () {
146
+ const variables = {
147
+ userLoginId,
148
+ partyId,
149
+ };
150
+ try {
151
+ const response = yield this.graphqlMutation(mutations_1.LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION, variables);
152
+ return response.linkingUserLoginAndUserDetail;
153
+ }
154
+ catch (error) {
155
+ console.log(`Error in linkingUserLoginAndUserDetail: ${error}`);
156
+ throw error;
157
+ }
158
+ });
159
+ }
160
+ createUserDetail(userLoginId) {
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ const variables = {
163
+ userLoginId,
164
+ partnerId: this.orgId,
165
+ };
166
+ try {
167
+ const response = yield this.graphqlMutation(mutations_1.CREATE_USER_DETAIL_MUTATION, variables);
168
+ return response.createUserDetail;
169
+ }
170
+ catch (error) {
171
+ console.log(`Error in createUserDetail: ${error}`);
172
+ throw error;
173
+ }
174
+ });
175
+ }
176
+ // mutation VerifyCode {
177
+ // sendSmsVerifyCode(orgId: "FYP", username: "0971879660") {
178
+ // id
179
+ // code
180
+ // username
181
+ // timeExpired
182
+ // }
183
+ // }
184
+ sendSmsVerifyCode(username) {
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ const query = mutations_1.SEND_SMS_VERIFY_CODE_MUTATION;
187
+ const variables = {
188
+ orgId: this.orgId,
189
+ username,
190
+ };
191
+ try {
192
+ const response = yield this.graphqlMutation(query, variables);
193
+ return response.sendSmsVerifyCode;
194
+ }
195
+ catch (error) {
196
+ console.log(`Error in sendSmsVerifyCode: ${error}`);
197
+ throw error;
198
+ }
199
+ });
200
+ }
201
+ // mutation VerifyCode {
202
+ // verifyCode(
203
+ // orgId: "FYP"
204
+ // verifyCodeRequest: { username: "0971879660", code: "999999" }
205
+ // )
206
+ // }
207
+ verifyCode(username, code) {
208
+ return __awaiter(this, void 0, void 0, function* () {
209
+ const query = mutations_1.VERIFY_CODE_MUTATION;
210
+ const variables = {
211
+ orgId: this.orgId,
212
+ verifyCodeRequest: { username, code },
213
+ };
214
+ try {
215
+ const response = yield this.graphqlMutation(query, variables);
216
+ return response.verifyCode;
217
+ }
218
+ catch (error) {
219
+ console.log(`Error in verifyCode: ${error}`);
220
+ throw error;
221
+ }
222
+ });
223
+ }
224
+ resetPassword(username, newPassword, accessToken) {
225
+ return __awaiter(this, void 0, void 0, function* () {
226
+ const query = mutations_1.RESET_PASSWORD_MUTATION;
227
+ const variables = {
228
+ orgId: this.orgId,
229
+ username,
230
+ newPassword,
231
+ accessToken,
232
+ };
233
+ try {
234
+ const response = yield this.graphqlMutation(query, variables);
235
+ return response.resetPassword;
236
+ }
237
+ catch (error) {
238
+ console.log(`Error in resetPassword: ${error}`);
239
+ throw error;
240
+ }
241
+ });
242
+ }
243
+ loginGoogle(redirectUrl) {
244
+ return __awaiter(this, void 0, void 0, function* () {
245
+ const query = queries_1.LOGIN_GOOGLE;
246
+ const variables = {
247
+ orgId: this.orgId,
248
+ type: "login",
249
+ redirectUrl,
250
+ };
251
+ try {
252
+ const response = yield this.graphqlQuery(query, variables);
253
+ return response.loginGoogle;
254
+ }
255
+ catch (error) {
256
+ console.log(`Error in loginGoogle: ${error}`);
257
+ throw error;
258
+ }
259
+ });
260
+ }
261
+ loginFacebook(redirectUrl) {
262
+ return __awaiter(this, void 0, void 0, function* () {
263
+ const query = queries_1.LOGIN_FACEBOOK;
264
+ const variables = {
265
+ orgId: this.orgId,
266
+ type: "login",
267
+ redirectUrl,
268
+ };
269
+ try {
270
+ const response = yield this.graphqlQuery(query, variables);
271
+ return response.loginFacebook;
272
+ }
273
+ catch (error) {
274
+ console.log(`Error in loginFacebook: ${error}`);
275
+ throw error;
276
+ }
277
+ });
278
+ }
279
+ /**
280
+ * Logs in a user via Zalo by executing a GraphQL query.
281
+ *
282
+ * @param redirectUrl - The URL to redirect the user to after login.
283
+ * @returns A promise that resolves to the result of the `loginZalo` GraphQL query.
284
+ * @throws Will throw an error if the GraphQL query fails.
285
+ */
286
+ loginZalo(redirectUrl) {
287
+ return __awaiter(this, void 0, void 0, function* () {
288
+ const query = queries_1.LOGIN_ZALO;
289
+ const variables = {
290
+ orgId: this.orgId,
291
+ type: "login",
292
+ redirectUrl,
293
+ };
294
+ try {
295
+ const response = yield this.graphqlQuery(query, variables);
296
+ return response.loginZalo;
297
+ }
298
+ catch (error) {
299
+ console.log(`Error in loginZalo: ${error}`);
300
+ throw error;
301
+ }
302
+ });
303
+ }
71
304
  }
72
305
  exports.AuthService = AuthService;
@@ -13,7 +13,7 @@ export declare class CampaignService extends Service {
13
13
  getCampaignActiveNow(campaignActionType: string, customerId: string): Promise<any>;
14
14
  getPromotionProductPrice(productId: String, productPrice: number): Promise<any>;
15
15
  getVoucherAvailableForCustomer(campaignId: string, campaignActionId: string, customerId: string, excludeExpired: Boolean, isPageAble: Boolean): Promise<any>;
16
- addCustomerToVoucher(voucherCode: string, userId: string): Promise<any>;
16
+ addCustomerToVoucher(voucherCode: string, userId: string, affiliateId: string): Promise<any>;
17
17
  suggestVoucher(): Promise<any>;
18
18
  getCampaignActionById(id: string): Promise<any>;
19
19
  searchProductGiftPromotionResponse(campaignActionId: string): Promise<any>;
@@ -142,13 +142,14 @@ class CampaignService extends serviceSDK_1.Service {
142
142
  }
143
143
  });
144
144
  }
145
- addCustomerToVoucher(voucherCode, userId) {
145
+ addCustomerToVoucher(voucherCode, userId, affiliateId) {
146
146
  return __awaiter(this, void 0, void 0, function* () {
147
147
  const query = mutations_1.ADD_CUSTOMER_ID_INTO_VOUCHER;
148
148
  const variables = {
149
149
  partyId: this.orgId,
150
150
  voucherCode,
151
151
  userId,
152
+ affiliateId,
152
153
  };
153
154
  try {
154
155
  const response = yield this.graphqlMutation(query, variables);
@@ -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: {
package/package.json CHANGED
@@ -1,43 +1,43 @@
1
- {
2
- "name": "@longvansoftware/storefront-js-client",
3
- "version": "2.7.2",
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.7.4",
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;