@longvansoftware/storefront-js-client 2.2.7-beta.11 → 2.2.7-beta.13

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.
@@ -2,3 +2,6 @@ export declare const GET_USER_DETAIL: import("graphql").DocumentNode;
2
2
  export declare const GET_USER_LOGIN_BY_TOKEN: import("graphql").DocumentNode;
3
3
  export declare const GET_USER_LOGIN_BY_USER_LOGIN_ID: import("graphql").DocumentNode;
4
4
  export declare const CHECK_USERNAME_EXISTED: import("graphql").DocumentNode;
5
+ export declare const LOGIN_GOOGLE: import("graphql").DocumentNode;
6
+ export declare const LOGIN_FACEBOOK: import("graphql").DocumentNode;
7
+ export declare const LOGIN_ZALO: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CHECK_USERNAME_EXISTED = exports.GET_USER_LOGIN_BY_USER_LOGIN_ID = exports.GET_USER_LOGIN_BY_TOKEN = exports.GET_USER_DETAIL = void 0;
3
+ exports.LOGIN_ZALO = exports.LOGIN_FACEBOOK = exports.LOGIN_GOOGLE = exports.CHECK_USERNAME_EXISTED = exports.GET_USER_LOGIN_BY_USER_LOGIN_ID = exports.GET_USER_LOGIN_BY_TOKEN = exports.GET_USER_DETAIL = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.GET_USER_DETAIL = (0, graphql_tag_1.gql) `
6
6
  query GetUserDetail($orgId: String!, $accessToken: String!) {
@@ -58,3 +58,18 @@ exports.CHECK_USERNAME_EXISTED = (0, graphql_tag_1.gql) `
58
58
  checkUsernameExisted(username: $username, orgId: $orgId)
59
59
  }
60
60
  `;
61
+ exports.LOGIN_GOOGLE = (0, graphql_tag_1.gql) `
62
+ query LoginGoogle($orgId: String!, $type: String!, $redirectUrl: String!) {
63
+ loginGoogle(orgId: $orgId, type: $type, redirectUrl: $redirectUrl)
64
+ }
65
+ `;
66
+ exports.LOGIN_FACEBOOK = (0, graphql_tag_1.gql) `
67
+ query LoginFacebook($orgId: String!, $type: String!, $redirectUrl: String!) {
68
+ loginFacebook(orgId: $orgId, type: $type, redirectUrl: $redirectUrl)
69
+ }
70
+ `;
71
+ exports.LOGIN_ZALO = (0, graphql_tag_1.gql) `
72
+ query LoginZalo($orgId: String!, $type: String!, $redirectUrl: String!) {
73
+ loginZalo(orgId: $orgId, type: $type, redirectUrl: $redirectUrl)
74
+ }
75
+ `;
@@ -4,3 +4,5 @@ export declare const CHECK_VALID_VOUCHER: import("graphql").DocumentNode;
4
4
  export declare const GET_CAMPAIGN_ACTIVE_NOW: import("graphql").DocumentNode;
5
5
  export declare const GET_PROMOTION_PRODUCT_PRICE: import("graphql").DocumentNode;
6
6
  export declare const GET_VOUCHER_AVAILABLE_FOR_CUSTOMER: import("graphql").DocumentNode;
7
+ export declare const SUGGEST_VOUCHER: import("graphql").DocumentNode;
8
+ export declare const GET_CAMPAIGN_ACTION_BY_ID: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET_VOUCHER_AVAILABLE_FOR_CUSTOMER = exports.GET_PROMOTION_PRODUCT_PRICE = exports.GET_CAMPAIGN_ACTIVE_NOW = exports.CHECK_VALID_VOUCHER = exports.GET_VOUCHERS = exports.GET_CAMPAIGN_ACTION_ACTIVE_NOW = void 0;
3
+ exports.GET_CAMPAIGN_ACTION_BY_ID = exports.SUGGEST_VOUCHER = exports.GET_VOUCHER_AVAILABLE_FOR_CUSTOMER = exports.GET_PROMOTION_PRODUCT_PRICE = exports.GET_CAMPAIGN_ACTIVE_NOW = exports.CHECK_VALID_VOUCHER = exports.GET_VOUCHERS = exports.GET_CAMPAIGN_ACTION_ACTIVE_NOW = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.GET_CAMPAIGN_ACTION_ACTIVE_NOW = (0, graphql_tag_1.gql) `
6
6
  query GetCampaignActionActiveNow(
@@ -256,3 +256,94 @@ exports.GET_VOUCHER_AVAILABLE_FOR_CUSTOMER = (0, graphql_tag_1.gql) `
256
256
  }
257
257
  }
258
258
  `;
259
+ exports.SUGGEST_VOUCHER = (0, graphql_tag_1.gql) `
260
+ query SuggestVoucher($partyId: String, $excludeExpired: Boolean) {
261
+ suggestVoucher(
262
+ searchVoucherRequest: {
263
+ partyId: $partyId
264
+ excludeExpired: $excludeExpired
265
+ }
266
+ ) {
267
+ total
268
+ totalPages
269
+ totalElements
270
+ last
271
+ first
272
+ number
273
+ numberOfElements
274
+ size
275
+ empty
276
+ content {
277
+ campaignActionId
278
+ campaignId
279
+ partyId
280
+ voucherCode
281
+ voucherType
282
+ status
283
+ discountAmount
284
+ discountPercent
285
+ usageLimitPerVoucher
286
+ maximumDiscount
287
+ numberOfTimeUsed
288
+ id
289
+ createdStamp
290
+ updatedStamp
291
+ updatedBy
292
+ createdBy
293
+ isBirthday
294
+ customerId
295
+ scope
296
+ }
297
+ }
298
+ }
299
+ `;
300
+ // query GetCampaignActionById {
301
+ // getCampaignActionById(id: "20.1273.888") {
302
+ // name
303
+ // description
304
+ // partyId
305
+ // type
306
+ // viewTemplateId
307
+ // urlTemplate
308
+ // shortCode
309
+ // uriPattern
310
+ // parameterPattern
311
+ // status
312
+ // extendDaysForHeadReview
313
+ // priorityLevel
314
+ // positionConnectionType
315
+ // baseCommissionPercent
316
+ // targetType
317
+ // id
318
+ // createdStamp
319
+ // updatedStamp
320
+ // updatedBy
321
+ // createdBy
322
+ // }
323
+ // }
324
+ exports.GET_CAMPAIGN_ACTION_BY_ID = (0, graphql_tag_1.gql) `
325
+ query GetCampaignActionById($id: String!) {
326
+ getCampaignActionById(id: $id) {
327
+ name
328
+ description
329
+ partyId
330
+ type
331
+ viewTemplateId
332
+ urlTemplate
333
+ shortCode
334
+ uriPattern
335
+ parameterPattern
336
+ status
337
+ extendDaysForHeadReview
338
+ priorityLevel
339
+ positionConnectionType
340
+ baseCommissionPercent
341
+ targetType
342
+ id
343
+ createdStamp
344
+ updatedStamp
345
+ updatedBy
346
+ createdBy
347
+ }
348
+ }
349
+ `;
@@ -40,4 +40,7 @@ export declare class AuthService extends Service {
40
40
  sendSmsVerifyCode(username: string): Promise<any>;
41
41
  verifyCode(username: string, code: string): Promise<any>;
42
42
  resetPassword(username: string, newPassword: string, accessToken: string): Promise<any>;
43
+ loginGoogle(redirectUrl: string): Promise<any>;
44
+ loginFacebook(redirectUrl: string): Promise<any>;
45
+ loginZalo(redirectUrl: string): Promise<any>;
43
46
  }
@@ -241,5 +241,59 @@ class AuthService extends serviceSDK_1.Service {
241
241
  }
242
242
  });
243
243
  }
244
+ loginGoogle(redirectUrl) {
245
+ return __awaiter(this, void 0, void 0, function* () {
246
+ const query = queries_1.LOGIN_GOOGLE;
247
+ const variables = {
248
+ orgId: this.orgId,
249
+ type: "login",
250
+ redirectUrl,
251
+ };
252
+ try {
253
+ const response = yield this.graphqlQuery(query, variables);
254
+ return response.loginGoogle;
255
+ }
256
+ catch (error) {
257
+ console.log(`Error in loginGoogle: ${error}`);
258
+ throw error;
259
+ }
260
+ });
261
+ }
262
+ loginFacebook(redirectUrl) {
263
+ return __awaiter(this, void 0, void 0, function* () {
264
+ const query = queries_1.LOGIN_FACEBOOK;
265
+ const variables = {
266
+ orgId: this.orgId,
267
+ type: "login",
268
+ redirectUrl,
269
+ };
270
+ try {
271
+ const response = yield this.graphqlQuery(query, variables);
272
+ return response.loginFacebook;
273
+ }
274
+ catch (error) {
275
+ console.log(`Error in loginFacebook: ${error}`);
276
+ throw error;
277
+ }
278
+ });
279
+ }
280
+ loginZalo(redirectUrl) {
281
+ return __awaiter(this, void 0, void 0, function* () {
282
+ const query = queries_1.LOGIN_ZALO;
283
+ const variables = {
284
+ orgId: this.orgId,
285
+ type: "login",
286
+ redirectUrl,
287
+ };
288
+ try {
289
+ const response = yield this.graphqlQuery(query, variables);
290
+ return response.loginZalo;
291
+ }
292
+ catch (error) {
293
+ console.log(`Error in loginZalo: ${error}`);
294
+ throw error;
295
+ }
296
+ });
297
+ }
244
298
  }
245
299
  exports.AuthService = AuthService;
@@ -14,4 +14,6 @@ export declare class CampaignService extends Service {
14
14
  getPromotionProductPrice(productId: String, productPrice: number): Promise<any>;
15
15
  getVoucherAvailableForCustomer(campaignId: string, customerId: string, excludeExpired: Boolean): Promise<any>;
16
16
  addCustomerToVoucher(voucherCode: string, userId: string): Promise<any>;
17
+ suggestVoucher(): Promise<any>;
18
+ getCampaignActionById(id: string): Promise<any>;
17
19
  }
@@ -156,5 +156,36 @@ class CampaignService extends serviceSDK_1.Service {
156
156
  }
157
157
  });
158
158
  }
159
+ suggestVoucher() {
160
+ return __awaiter(this, void 0, void 0, function* () {
161
+ const query = queries_1.SUGGEST_VOUCHER;
162
+ const variables = {
163
+ partyId: this.orgId,
164
+ excludeExpired: true,
165
+ };
166
+ try {
167
+ const response = yield this.graphqlQuery(query, variables);
168
+ return response.suggestVoucher;
169
+ }
170
+ catch (error) {
171
+ throw error;
172
+ }
173
+ });
174
+ }
175
+ getCampaignActionById(id) {
176
+ return __awaiter(this, void 0, void 0, function* () {
177
+ const query = queries_1.GET_CAMPAIGN_ACTION_BY_ID;
178
+ const variables = {
179
+ id,
180
+ };
181
+ try {
182
+ const response = yield this.graphqlQuery(query, variables);
183
+ return response.getCampaignActionById;
184
+ }
185
+ catch (error) {
186
+ throw error;
187
+ }
188
+ });
189
+ }
159
190
  }
160
191
  exports.CampaignService = CampaignService;
@@ -0,0 +1,5 @@
1
+ import { Service } from "../serviceSDK";
2
+ export declare class AuthorizationService extends Service {
3
+ constructor(endpoint: string, orgId: string, storeId: string);
4
+ checkToken(orgId: string, token: string): Promise<any>;
5
+ }
@@ -0,0 +1,32 @@
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.AuthorizationService = void 0;
13
+ const serviceSDK_1 = require("../serviceSDK");
14
+ class AuthorizationService extends serviceSDK_1.Service {
15
+ constructor(endpoint, orgId, storeId) {
16
+ super(endpoint, orgId, storeId);
17
+ }
18
+ checkToken(orgId, token) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const endpoint = `/${orgId}/oauth2/api/v1/token/${token}`;
21
+ const method = "GET";
22
+ try {
23
+ const response = yield this.restApiCallWithNoHeader(endpoint, method);
24
+ return response;
25
+ }
26
+ catch (error) {
27
+ throw error;
28
+ }
29
+ });
30
+ }
31
+ }
32
+ exports.AuthorizationService = AuthorizationService;
@@ -0,0 +1 @@
1
+ export declare function validatePhoneNumber(phoneNumber: string): boolean;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validatePhoneNumber = void 0;
4
+ function validatePhoneNumber(phoneNumber) {
5
+ var _a;
6
+ const urlParams = new URLSearchParams(window.location.search);
7
+ const country = ((_a = urlParams.get("country")) === null || _a === void 0 ? void 0 : _a.trim()) || "default";
8
+ const pattern = (() => {
9
+ switch (country) {
10
+ case "vietnam":
11
+ return /^(0?)(3[2-9]|5[6|8|9]|7[0|6-9]|8[0-6|8|9]|9[0-4|6-9])[0-9]{7}$/;
12
+ case "quocte":
13
+ return /^(\+|00)[1-9][0-9]{1,3}[0-9]{4,14}$/;
14
+ default:
15
+ return /^(0?)(3[2-9]|5[6|8|9]|7[0|6-9]|8[0-6|8|9]|9[0-4|6-9])[0-9]{7}$|^(\+|00)[1-9][0-9]{1,3}[0-9]{4,14}$/;
16
+ }
17
+ })();
18
+ return pattern.test(phoneNumber);
19
+ }
20
+ exports.validatePhoneNumber = validatePhoneNumber;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/storefront-js-client",
3
- "version": "2.2.7-beta.11",
3
+ "version": "2.2.7-beta.13",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [