@longvansoftware/storefront-js-client 3.0.2 → 3.0.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.
@@ -121,8 +121,8 @@ exports.LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION = (0, graphql_tag_1.gql) `
121
121
  }
122
122
  `;
123
123
  exports.CREATE_USER_DETAIL_MUTATION = (0, graphql_tag_1.gql) `
124
- mutation CreateUserDetail($userLoginId: String!, $partnerId: String!) {
125
- createUserDetail(userLoginId: $userLoginId, partnerId: $partnerId) {
124
+ mutation CreateUserDetail($userLoginId: String!, $orgId: String!) {
125
+ createUserDetail(userLoginId: $userLoginId, orgId: $orgId) {
126
126
  partyId
127
127
  orgId
128
128
  fullName
@@ -1,5 +1,5 @@
1
1
  import { Service } from "../serviceSDK";
2
- import { LoginRequest, LoginResponse, RegisterRequest, SendOTPResponse, ValidateOTPResponse, CreateUserLoginResponse, GetAccessTokenByOTPResponse, CreateOrgResponse } from "../../types/auth";
2
+ import { LoginRequest, LoginResponse, RegisterRequest, SendOTPResponse, ValidateOTPResponse, CreateUserLoginResponse, GetAccessTokenByOTPResponse, CreateOrgResponse, CreateUserDetailResponse, UpdateInfoRequest, UpdateInfoResponse } from "../../types/auth";
3
3
  /**
4
4
  * Represents the authentication service.
5
5
  */
@@ -36,7 +36,15 @@ export declare class AuthService extends Service {
36
36
  getUserLoginByUserLoginId(userLoginId: string): Promise<any>;
37
37
  checkUsernameExisted(username: string): Promise<any>;
38
38
  linkingUserLoginAndUserDetail(userLoginId: string, partyId: string): Promise<any>;
39
- createUserDetail(userLoginId: string): Promise<any>;
39
+ /**
40
+ * Creates user detail for the specified user login ID.
41
+ * Uses the SDK's configured orgId automatically.
42
+ *
43
+ * @param userLoginId - The user login ID to create detail for.
44
+ * @returns A promise that resolves to the created user detail with full profile information.
45
+ * @throws Will throw an error if the GraphQL mutation fails.
46
+ */
47
+ createUserDetail(userLoginId: string): Promise<CreateUserDetailResponse>;
40
48
  sendSmsVerifyCode(username: string): Promise<any>;
41
49
  verifyCode(username: string, code: string): Promise<any>;
42
50
  resetPassword(username: string, newPassword: string, accessToken: string): Promise<any>;
@@ -114,4 +122,15 @@ export declare class AuthService extends Service {
114
122
  * @throws Will throw an error if the GraphQL mutation fails.
115
123
  */
116
124
  getAccessTokenByOTP(otpCode: string, phone: string, type?: "SMS" | "ZALO"): Promise<GetAccessTokenByOTPResponse>;
125
+ /**
126
+ * Updates user information.
127
+ * Uses the SDK's configured orgId and access token automatically.
128
+ *
129
+ * @param updateUserRequest - The user information to update.
130
+ * @param type - Optional type parameter.
131
+ * @param password - Optional password for verification.
132
+ * @returns A promise that resolves to the updated user information.
133
+ * @throws Will throw an error if the GraphQL mutation fails.
134
+ */
135
+ updateInfo(updateUserRequest: UpdateInfoRequest, type?: string, password?: string): Promise<UpdateInfoResponse>;
117
136
  }
@@ -158,11 +158,19 @@ class AuthService extends serviceSDK_1.Service {
158
158
  }
159
159
  });
160
160
  }
161
+ /**
162
+ * Creates user detail for the specified user login ID.
163
+ * Uses the SDK's configured orgId automatically.
164
+ *
165
+ * @param userLoginId - The user login ID to create detail for.
166
+ * @returns A promise that resolves to the created user detail with full profile information.
167
+ * @throws Will throw an error if the GraphQL mutation fails.
168
+ */
161
169
  createUserDetail(userLoginId) {
162
170
  return __awaiter(this, void 0, void 0, function* () {
163
171
  const variables = {
164
172
  userLoginId,
165
- partnerId: this.orgId,
173
+ orgId: this.orgId,
166
174
  };
167
175
  try {
168
176
  const response = yield this.graphqlMutation(mutations_1.CREATE_USER_DETAIL_MUTATION, variables);
@@ -465,7 +473,7 @@ class AuthService extends serviceSDK_1.Service {
465
473
  };
466
474
  try {
467
475
  const response = yield this.graphqlQuery(queries_1.GET_ACCESS_TOKEN_BY_OTP, variables);
468
- return response;
476
+ return { accessToken: response.getAccessTokenByOTP };
469
477
  }
470
478
  catch (error) {
471
479
  console.log(`Error in getAccessTokenByOTP: ${error}`);
@@ -473,5 +481,34 @@ class AuthService extends serviceSDK_1.Service {
473
481
  }
474
482
  });
475
483
  }
484
+ /**
485
+ * Updates user information.
486
+ * Uses the SDK's configured orgId and access token automatically.
487
+ *
488
+ * @param updateUserRequest - The user information to update.
489
+ * @param type - Optional type parameter.
490
+ * @param password - Optional password for verification.
491
+ * @returns A promise that resolves to the updated user information.
492
+ * @throws Will throw an error if the GraphQL mutation fails.
493
+ */
494
+ updateInfo(updateUserRequest, type, password) {
495
+ return __awaiter(this, void 0, void 0, function* () {
496
+ const variables = {
497
+ orgId: this.orgId,
498
+ accessToken: this.token,
499
+ updateUserRequest,
500
+ type,
501
+ password,
502
+ };
503
+ try {
504
+ const response = yield this.graphqlMutation(mutations_1.UPDATE_INFO_MUTATION, variables);
505
+ return response.updateInfo;
506
+ }
507
+ catch (error) {
508
+ console.log(`Error in updateInfo: ${error}`);
509
+ throw error;
510
+ }
511
+ });
512
+ }
476
513
  }
477
514
  exports.AuthService = AuthService;
@@ -197,3 +197,86 @@ export interface CreateOrgResponse {
197
197
  /** Prefix */
198
198
  prefix: string;
199
199
  }
200
+ /**
201
+ * Response interface for creating user detail
202
+ * Returns the created user detail with full profile information
203
+ */
204
+ export interface CreateUserDetailResponse {
205
+ /** Party ID */
206
+ partyId: string;
207
+ /** Organization ID */
208
+ orgId: string;
209
+ /** Full name */
210
+ fullName: string;
211
+ /** Email address */
212
+ email: string;
213
+ /** Phone number */
214
+ phone: string;
215
+ /** Address */
216
+ address: string;
217
+ /** Identity number */
218
+ identityNumber: string;
219
+ /** Gender */
220
+ gender: string;
221
+ /** Birth date */
222
+ birthDate: string;
223
+ /** Avatar URL */
224
+ avatarUrl: string;
225
+ /** Access token */
226
+ accessToken: string;
227
+ /** Username */
228
+ username: string;
229
+ /** Ready V2 flag */
230
+ readyV2: boolean;
231
+ /** Organization permissions map */
232
+ orgPermissionsMap: Record<string, any>;
233
+ /** Organization positions map */
234
+ orgPositionsMap: Record<string, any>;
235
+ /** Organization roles map */
236
+ orgRolesMap: Record<string, any>;
237
+ }
238
+ /**
239
+ * Request interface for updating user information
240
+ */
241
+ export interface UpdateInfoRequest {
242
+ /** Full name */
243
+ fullName?: string;
244
+ /** Email address */
245
+ email?: string;
246
+ /** Phone number */
247
+ phone?: string;
248
+ /** Address */
249
+ address?: string;
250
+ /** Identity number */
251
+ identityNumber?: string;
252
+ /** Gender */
253
+ gender?: string;
254
+ /** Birth date */
255
+ birthDate?: string;
256
+ /** Avatar URL */
257
+ avatarUrl?: string;
258
+ }
259
+ /**
260
+ * Response interface for updating user information
261
+ * Returns the updated user profile with full information
262
+ */
263
+ export interface UpdateInfoResponse {
264
+ /** Party ID */
265
+ partyId: string;
266
+ /** Full name */
267
+ fullName: string;
268
+ /** Email address */
269
+ email: string;
270
+ /** Phone number */
271
+ phone: string;
272
+ /** Address */
273
+ address: string;
274
+ /** Identity number */
275
+ identityNumber: string;
276
+ /** Gender */
277
+ gender: string;
278
+ /** Birth date */
279
+ birthDate: string;
280
+ /** Avatar URL */
281
+ avatarUrl: string;
282
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/storefront-js-client",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [