@longvansoftware/storefront-js-client 3.1.1 → 3.1.3

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.
@@ -5,6 +5,7 @@ export declare const VERIFY_CODE_MUTATION: import("graphql").DocumentNode;
5
5
  export declare const RESET_PASSWORD_MUTATION: import("graphql").DocumentNode;
6
6
  export declare const UPDATE_INFO_MUTATION: import("graphql").DocumentNode;
7
7
  export declare const UPDATE_PASSWORD_MUTATION = "\n mutation UpdatePassword($orgId: String!, $accessToken: String!, $currentPassword: String!, $newPassword: String!) {\n updatePassword(orgId: $orgId, accessToken: $accessToken, currentPassword: $currentPassword, newPassword: $newPassword)\n }\n";
8
+ export declare const CREATE_PASSWORD_MUTATION: import("graphql").DocumentNode;
8
9
  export declare const UPDATE_PROFILE_MUTATION: import("graphql").DocumentNode;
9
10
  export declare const LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION: import("graphql").DocumentNode;
10
11
  export declare const CREATE_USER_DETAIL_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.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.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;
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!) {
@@ -97,6 +97,21 @@ exports.UPDATE_PASSWORD_MUTATION = `
97
97
  updatePassword(orgId: $orgId, accessToken: $accessToken, currentPassword: $currentPassword, newPassword: $newPassword)
98
98
  }
99
99
  `;
100
+ exports.CREATE_PASSWORD_MUTATION = (0, graphql_tag_1.gql) `
101
+ mutation CreatePassword($orgId: String, $accessToken: String, $password: String) {
102
+ updateInfo(orgId: $orgId, accessToken: $accessToken, password: $password) {
103
+ partyId
104
+ fullName
105
+ email
106
+ phone
107
+ address
108
+ identityNumber
109
+ gender
110
+ birthDate
111
+ avatarUrl
112
+ }
113
+ }
114
+ `;
100
115
  exports.UPDATE_PROFILE_MUTATION = (0, graphql_tag_1.gql) `
101
116
  mutation UpdateProfile(
102
117
  $userLoginId: String!
@@ -114,4 +114,13 @@ export declare class AuthService extends Service {
114
114
  * @throws Will throw an error if the GraphQL mutation fails.
115
115
  */
116
116
  getAccessTokenByOTP(otpCode: string, phone: string, type?: 'SMS' | 'ZALO'): Promise<GetAccessTokenByOTPResponse>;
117
+ /**
118
+ * Creates/sets a password for a user using the updateInfo mutation.
119
+ * Uses the SDK's internal orgId and token (accessToken).
120
+ *
121
+ * @param password - The new password to set.
122
+ * @returns A promise that resolves to the updated user information.
123
+ * @throws Will throw an error if the GraphQL mutation fails.
124
+ */
125
+ createPassword(password: string): Promise<any>;
117
126
  }
@@ -473,5 +473,30 @@ class AuthService extends serviceSDK_1.Service {
473
473
  }
474
474
  });
475
475
  }
476
+ /**
477
+ * Creates/sets a password for a user using the updateInfo mutation.
478
+ * Uses the SDK's internal orgId and token (accessToken).
479
+ *
480
+ * @param password - The new password to set.
481
+ * @returns A promise that resolves to the updated user information.
482
+ * @throws Will throw an error if the GraphQL mutation fails.
483
+ */
484
+ createPassword(password) {
485
+ return __awaiter(this, void 0, void 0, function* () {
486
+ const variables = {
487
+ orgId: this.orgId,
488
+ accessToken: this.token,
489
+ password,
490
+ };
491
+ try {
492
+ const response = yield this.graphqlMutation(mutations_1.CREATE_PASSWORD_MUTATION, variables);
493
+ return response.updateInfo;
494
+ }
495
+ catch (error) {
496
+ console.log(`Error in createPassword: ${error}`);
497
+ throw error;
498
+ }
499
+ });
500
+ }
476
501
  }
477
502
  exports.AuthService = AuthService;
@@ -528,4 +528,21 @@ export declare class OrderService extends Service {
528
528
  * @throws If an error occurs while updating the customer information
529
529
  */
530
530
  updateCustomerInfoFront(orderId: string, customerInfo: CustomerInfo): Promise<any>;
531
+ /**
532
+ * Creates a store channel.
533
+ *
534
+ * @param storeChannelData - The data for creating the store channel.
535
+ * @returns A promise that resolves to the created store channel response.
536
+ * @throws If an error occurs while creating the store channel.
537
+ */
538
+ createStoreChannel(storeChannelData: any): Promise<any>;
539
+ /**
540
+ * Gets available store channels for an employee.
541
+ *
542
+ * @param partnerId - The partner ID.
543
+ * @param empId - The employee ID.
544
+ * @returns A promise that resolves to the available store channels.
545
+ * @throws If an error occurs while fetching the store channels.
546
+ */
547
+ getAvailableStoreChannels(empId: string): Promise<any>;
531
548
  }
@@ -1590,5 +1590,48 @@ class OrderService extends serviceSDK_1.Service {
1590
1590
  }
1591
1591
  });
1592
1592
  }
1593
+ /**
1594
+ * Creates a store channel.
1595
+ *
1596
+ * @param storeChannelData - The data for creating the store channel.
1597
+ * @returns A promise that resolves to the created store channel response.
1598
+ * @throws If an error occurs while creating the store channel.
1599
+ */
1600
+ createStoreChannel(storeChannelData) {
1601
+ return __awaiter(this, void 0, void 0, function* () {
1602
+ const endpoint = `/store-channels/${this.orgId}`;
1603
+ const method = "POST";
1604
+ try {
1605
+ const response = yield this.restApiCallWithToken(endpoint, method, Object.assign(Object.assign({}, storeChannelData), { partyId: this.orgId }));
1606
+ return response;
1607
+ }
1608
+ catch (error) {
1609
+ console.log(`Error in createStoreChannel: ${error}`);
1610
+ throw error;
1611
+ }
1612
+ });
1613
+ }
1614
+ /**
1615
+ * Gets available store channels for an employee.
1616
+ *
1617
+ * @param partnerId - The partner ID.
1618
+ * @param empId - The employee ID.
1619
+ * @returns A promise that resolves to the available store channels.
1620
+ * @throws If an error occurs while fetching the store channels.
1621
+ */
1622
+ getAvailableStoreChannels(empId) {
1623
+ return __awaiter(this, void 0, void 0, function* () {
1624
+ const endpoint = `/store-channels/${this.orgId}/available/${empId}`;
1625
+ const method = "GET";
1626
+ try {
1627
+ const response = yield this.restApiCallWithToken(endpoint, method);
1628
+ return response;
1629
+ }
1630
+ catch (error) {
1631
+ console.log(`Error in getAvailableStoreChannels: ${error}`);
1632
+ throw error;
1633
+ }
1634
+ });
1635
+ }
1593
1636
  }
1594
1637
  exports.OrderService = OrderService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/storefront-js-client",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [