@longvansoftware/storefront-js-client 3.1.8 → 3.2.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.
@@ -14,4 +14,3 @@ export declare const ADD_ROLE_USER_MUTATION: import("graphql").DocumentNode;
14
14
  export declare const CREATE_USER_LOGIN_MUTATION: import("graphql").DocumentNode;
15
15
  export declare const SEND_OTP_MUTATION: import("graphql").DocumentNode;
16
16
  export declare const VALIDATE_OTP_MUTATION: import("graphql").DocumentNode;
17
- export declare const GET_ACCESS_TOKEN_BY_OTP_MUTATION: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GET_ACCESS_TOKEN_BY_OTP_MUTATION = exports.VALIDATE_OTP_MUTATION = exports.SEND_OTP_MUTATION = exports.CREATE_USER_LOGIN_MUTATION = exports.ADD_ROLE_USER_MUTATION = exports.CREATE_ORG_MUTATION = exports.CREATE_USER_DETAIL_MUTATION = exports.LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION = exports.UPDATE_PROFILE_MUTATION = exports.CREATE_PASSWORD_MUTATION = exports.UPDATE_PASSWORD_MUTATION = exports.UPDATE_INFO_MUTATION = exports.RESET_PASSWORD_MUTATION = exports.VERIFY_CODE_MUTATION = exports.SEND_SMS_VERIFY_CODE_MUTATION = exports.REGISTER_MUTATION = exports.LOGIN_MUTATION = void 0;
3
+ exports.VALIDATE_OTP_MUTATION = exports.SEND_OTP_MUTATION = exports.CREATE_USER_LOGIN_MUTATION = exports.ADD_ROLE_USER_MUTATION = exports.CREATE_ORG_MUTATION = exports.CREATE_USER_DETAIL_MUTATION = exports.LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION = exports.UPDATE_PROFILE_MUTATION = exports.CREATE_PASSWORD_MUTATION = exports.UPDATE_PASSWORD_MUTATION = exports.UPDATE_INFO_MUTATION = exports.RESET_PASSWORD_MUTATION = exports.VERIFY_CODE_MUTATION = exports.SEND_SMS_VERIFY_CODE_MUTATION = exports.REGISTER_MUTATION = exports.LOGIN_MUTATION = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.LOGIN_MUTATION = (0, graphql_tag_1.gql) `
6
6
  mutation Login($loginRequest: LoginRequest!) {
@@ -67,8 +67,8 @@ exports.RESET_PASSWORD_MUTATION = (0, graphql_tag_1.gql) `
67
67
  `;
68
68
  exports.UPDATE_INFO_MUTATION = (0, graphql_tag_1.gql) `
69
69
  mutation UpdateInfo(
70
- $orgId: String
71
- $accessToken: String
70
+ $orgId: String!
71
+ $accessToken: String!
72
72
  $updateUserRequest: UpdateUserRequest
73
73
  $type: String
74
74
  $password: String
@@ -98,7 +98,7 @@ exports.UPDATE_PASSWORD_MUTATION = `
98
98
  }
99
99
  `;
100
100
  exports.CREATE_PASSWORD_MUTATION = (0, graphql_tag_1.gql) `
101
- mutation CreatePassword($orgId: String, $accessToken: String, $password: String) {
101
+ mutation CreatePassword($orgId: String!, $accessToken: String!, $password: String!) {
102
102
  updateInfo(orgId: $orgId, accessToken: $accessToken, password: $password) {
103
103
  partyId
104
104
  fullName
@@ -222,8 +222,3 @@ exports.VALIDATE_OTP_MUTATION = (0, graphql_tag_1.gql) `
222
222
  validateOTP(otpCode: $otpCode, phone: $phone, channelType: $channelType)
223
223
  }
224
224
  `;
225
- exports.GET_ACCESS_TOKEN_BY_OTP_MUTATION = (0, graphql_tag_1.gql) `
226
- mutation GetAccessTokenByOTP($otpCode: String!, $phone: String!, $channelType: String) {
227
- getAccessTokenByOTP(otpCode: $otpCode, phone: $phone, channelType: $channelType)
228
- }
229
- `;
@@ -6,3 +6,4 @@ export declare const LOGIN_GOOGLE: import("graphql").DocumentNode;
6
6
  export declare const LOGIN_FACEBOOK: import("graphql").DocumentNode;
7
7
  export declare const LOGIN_ZALO: import("graphql").DocumentNode;
8
8
  export declare const CHECK_USER_LOGIN: import("graphql").DocumentNode;
9
+ export declare const GET_ACCESS_TOKEN_BY_OTP_QUERY: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CHECK_USER_LOGIN = 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;
3
+ exports.GET_ACCESS_TOKEN_BY_OTP_QUERY = exports.CHECK_USER_LOGIN = 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!) {
@@ -78,3 +78,8 @@ exports.CHECK_USER_LOGIN = (0, graphql_tag_1.gql) `
78
78
  checkUserLogin(userLoginId: $userLoginId)
79
79
  }
80
80
  `;
81
+ exports.GET_ACCESS_TOKEN_BY_OTP_QUERY = (0, graphql_tag_1.gql) `
82
+ query GetAccessTokenByOTP($otpCode: String!, $phone: String!, $channelType: String) {
83
+ getAccessTokenByOTP(otpCode: $otpCode, phone: $phone, channelType: $channelType)
84
+ }
85
+ `;
@@ -267,12 +267,16 @@ exports.SUGGEST_VOUCHER = (0, graphql_tag_1.gql) `
267
267
  $partyId: String
268
268
  $customerId: String
269
269
  $excludeExpired: Boolean
270
+ $campaignId:String
271
+ $campaignActionId:String
270
272
  ) {
271
273
  suggestVoucher(
272
274
  searchVoucherRequest: {
273
275
  partyId: $partyId
274
276
  customerId: $customerId
275
277
  excludeExpired: $excludeExpired
278
+ campaignId:$campaignId
279
+ campaignActionId:$campaignActionId
276
280
  }
277
281
  ) {
278
282
  total
@@ -410,6 +414,9 @@ exports.SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE = (0, graphql_tag_1.gql) `
410
414
  featureImage
411
415
  }
412
416
  }
417
+ sort {
418
+ sorted
419
+ }
413
420
  }
414
421
  }
415
422
  `;
@@ -1,5 +1,5 @@
1
1
  import { Service } from "../serviceSDK";
2
- import { LoginRequest, LoginResponse, RegisterRequest, SendOTPResponse, ValidateOTPResponse, CreateUserLoginResponse, GetAccessTokenByOTPResponse } from "../../types/auth";
2
+ import { LoginRequest, LoginResponse, RegisterRequest, SendOTPResponse, ValidateOTPResponse, CreateUserLoginResponse, GetAccessTokenByOTPResponse, UpdateInfoResponse } from "../../types/auth";
3
3
  /**
4
4
  * Represents the authentication service.
5
5
  */
@@ -111,7 +111,7 @@ export declare class AuthService extends Service {
111
111
  * @param phone - The phone number associated with the OTP.
112
112
  * @param type - The type of OTP delivery ('SMS' or 'ZALO'). Defaults to 'SMS' if not specified.
113
113
  * @returns A promise that resolves to an object containing the access token.
114
- * @throws Will throw an error if the GraphQL mutation fails.
114
+ * @throws Will throw an error if the GraphQL query fails.
115
115
  */
116
116
  getAccessTokenByOTP(otpCode: string, phone: string, type?: 'SMS' | 'ZALO'): Promise<GetAccessTokenByOTPResponse>;
117
117
  /**
@@ -123,4 +123,15 @@ export declare class AuthService extends Service {
123
123
  * @throws Will throw an error if the GraphQL mutation fails.
124
124
  */
125
125
  createPassword(password: string): Promise<any>;
126
+ /**
127
+ * Updates user information using the updateInfo mutation.
128
+ * Uses the SDK's internal orgId and token (accessToken).
129
+ *
130
+ * @param updateUserRequest - The user data to update (optional).
131
+ * @param type - The type parameter (optional, use 'oauth' if not updating password).
132
+ * @param password - The password to set (optional).
133
+ * @returns A promise that resolves to the updated user information.
134
+ * @throws Will throw an error if the GraphQL mutation fails.
135
+ */
136
+ updateInfo(updateUserRequest?: any, type?: string, password?: string): Promise<UpdateInfoResponse>;
126
137
  }
@@ -454,7 +454,7 @@ class AuthService extends serviceSDK_1.Service {
454
454
  * @param phone - The phone number associated with the OTP.
455
455
  * @param type - The type of OTP delivery ('SMS' or 'ZALO'). Defaults to 'SMS' if not specified.
456
456
  * @returns A promise that resolves to an object containing the access token.
457
- * @throws Will throw an error if the GraphQL mutation fails.
457
+ * @throws Will throw an error if the GraphQL query fails.
458
458
  */
459
459
  getAccessTokenByOTP(otpCode, phone, type) {
460
460
  return __awaiter(this, void 0, void 0, function* () {
@@ -464,7 +464,7 @@ class AuthService extends serviceSDK_1.Service {
464
464
  channelType: type || 'SMS',
465
465
  };
466
466
  try {
467
- const response = yield this.graphqlMutation(mutations_1.GET_ACCESS_TOKEN_BY_OTP_MUTATION, variables);
467
+ const response = yield this.graphqlQuery(queries_1.GET_ACCESS_TOKEN_BY_OTP_QUERY, variables);
468
468
  return { accessToken: response.getAccessTokenByOTP };
469
469
  }
470
470
  catch (error) {
@@ -498,5 +498,34 @@ class AuthService extends serviceSDK_1.Service {
498
498
  }
499
499
  });
500
500
  }
501
+ /**
502
+ * Updates user information using the updateInfo mutation.
503
+ * Uses the SDK's internal orgId and token (accessToken).
504
+ *
505
+ * @param updateUserRequest - The user data to update (optional).
506
+ * @param type - The type parameter (optional, use 'oauth' if not updating password).
507
+ * @param password - The password to set (optional).
508
+ * @returns A promise that resolves to the updated user information.
509
+ * @throws Will throw an error if the GraphQL mutation fails.
510
+ */
511
+ updateInfo(updateUserRequest, type, password) {
512
+ return __awaiter(this, void 0, void 0, function* () {
513
+ const variables = {
514
+ orgId: this.orgId,
515
+ accessToken: this.token,
516
+ updateUserRequest,
517
+ type,
518
+ password,
519
+ };
520
+ try {
521
+ const response = yield this.graphqlMutation(mutations_1.UPDATE_INFO_MUTATION, variables);
522
+ return response.updateInfo;
523
+ }
524
+ catch (error) {
525
+ console.log(`Error in updateInfo: ${error}`);
526
+ throw error;
527
+ }
528
+ });
529
+ }
501
530
  }
502
531
  exports.AuthService = AuthService;
@@ -14,7 +14,7 @@ export declare class CampaignService extends Service {
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
16
  addCustomerToVoucher(voucherCode: string, userId: string, affiliateId: string): Promise<any>;
17
- suggestVoucher(customerId: string): Promise<any>;
17
+ suggestVoucher(customerId: string, campaignId: string, campaignActionId: string): Promise<any>;
18
18
  getCampaignActionById(id: string): Promise<any>;
19
19
  searchProductGiftPromotionResponse(productIds: string[], campaignActionId: string): Promise<any>;
20
20
  }
@@ -160,12 +160,14 @@ class CampaignService extends serviceSDK_1.Service {
160
160
  }
161
161
  });
162
162
  }
163
- suggestVoucher(customerId) {
163
+ suggestVoucher(customerId, campaignId, campaignActionId) {
164
164
  return __awaiter(this, void 0, void 0, function* () {
165
165
  const query = queries_1.SUGGEST_VOUCHER;
166
166
  const variables = {
167
167
  partyId: this.orgId,
168
168
  customerId: customerId,
169
+ campaignId: campaignId,
170
+ campaignActionId: campaignActionId,
169
171
  excludeExpired: true,
170
172
  };
171
173
  try {
@@ -58,7 +58,7 @@ class StoreService extends serviceSDK_1.Service {
58
58
  */
59
59
  getAvailableStoreChannels(empId) {
60
60
  return __awaiter(this, void 0, void 0, function* () {
61
- const endpoint = `/store-channels/${this.orgId}/available/${empId}`;
61
+ const endpoint = `/store-channels/LONGVAN/available/${empId}`;
62
62
  const method = "GET";
63
63
  try {
64
64
  const response = yield this.restApiCallWithToken(endpoint, method);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/storefront-js-client",
3
- "version": "3.1.8",
3
+ "version": "3.2.0",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [