@longvansoftware/storefront-js-client 2.2.6 → 2.2.7-beta.2

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.
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AuthService = void 0;
13
+ // lib/auth/index.ts
13
14
  const serviceSDK_1 = require("../serviceSDK");
14
15
  const mutations_1 = require("../../graphql/auth/mutations");
15
16
  const queries_1 = require("../../graphql/auth/queries");
@@ -68,5 +69,185 @@ class AuthService extends serviceSDK_1.Service {
68
69
  }
69
70
  });
70
71
  }
72
+ /**
73
+ * Retrieves user login information using the provided access token.
74
+ *
75
+ * @param {string} accessToken - The access token used to authenticate the request.
76
+ * @returns {Promise<any>} A promise that resolves to the user login information.
77
+ * @throws Will throw an error if the GraphQL query fails.
78
+ */
79
+ getUserLoginByToken(accessToken) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ const query = queries_1.GET_USER_LOGIN_BY_TOKEN;
82
+ const variables = {
83
+ accessToken,
84
+ };
85
+ try {
86
+ const response = yield this.graphqlQuery(query, variables);
87
+ return response.getUserLoginByToken;
88
+ }
89
+ catch (error) {
90
+ console.log(`Error in getUserLoginByToken: ${error}`);
91
+ throw error;
92
+ }
93
+ });
94
+ }
95
+ updateProfile(userLoginId, name, phone, email) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const variables = {
98
+ userLoginId,
99
+ name,
100
+ phone,
101
+ email,
102
+ };
103
+ try {
104
+ const response = yield this.graphqlMutation(mutations_1.UPDATE_PROFILE_MUTATION, variables);
105
+ return response.updateProfile;
106
+ }
107
+ catch (error) {
108
+ console.log(`Error in updateProfile: ${error}`);
109
+ throw error;
110
+ }
111
+ });
112
+ }
113
+ getUserLoginByUserLoginId(userLoginId) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ const query = queries_1.GET_USER_LOGIN_BY_USER_LOGIN_ID;
116
+ const variables = {
117
+ userLoginId,
118
+ };
119
+ try {
120
+ const response = yield this.graphqlQuery(query, variables);
121
+ return response.getUserLoginByUserLoginId;
122
+ }
123
+ catch (error) {
124
+ console.log(`Error in getUserLoginByUserLoginId: ${error}`);
125
+ throw error;
126
+ }
127
+ });
128
+ }
129
+ checkUsernameExisted(username) {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ const variables = {
132
+ username,
133
+ orgId: this.orgId,
134
+ };
135
+ try {
136
+ const response = yield this.graphqlQuery(queries_1.CHECK_USERNAME_EXISTED, variables);
137
+ return response.checkUsernameExisted;
138
+ }
139
+ catch (error) {
140
+ console.log(`Error in checkUsernameExisted: ${error}`);
141
+ throw error;
142
+ }
143
+ });
144
+ }
145
+ linkingUserLoginAndUserDetail(userLoginId, partyId) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ const variables = {
148
+ userLoginId,
149
+ partyId,
150
+ };
151
+ try {
152
+ const response = yield this.graphqlMutation(mutations_1.LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION, variables);
153
+ return response.linkingUserLoginAndUserDetail;
154
+ }
155
+ catch (error) {
156
+ console.log(`Error in linkingUserLoginAndUserDetail: ${error}`);
157
+ throw error;
158
+ }
159
+ });
160
+ }
161
+ createUserDetail(userLoginId) {
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ const variables = {
164
+ userLoginId,
165
+ partnerId: this.orgId,
166
+ };
167
+ try {
168
+ const response = yield this.graphqlMutation(mutations_1.CREATE_USER_DETAIL_MUTATION, variables);
169
+ return response.createUserDetail;
170
+ }
171
+ catch (error) {
172
+ console.log(`Error in createUserDetail: ${error}`);
173
+ throw error;
174
+ }
175
+ });
176
+ }
177
+ // mutation VerifyCode {
178
+ // sendSmsVerifyCode(orgId: "FYP", username: "0971879660") {
179
+ // id
180
+ // code
181
+ // username
182
+ // timeExpired
183
+ // }
184
+ // }
185
+ sendSmsVerifyCode(username) {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ const query = mutations_1.SEND_SMS_VERIFY_CODE_MUTATION;
188
+ const variables = {
189
+ orgId: this.orgId,
190
+ username,
191
+ };
192
+ try {
193
+ const response = yield this.graphqlMutation(query, variables);
194
+ return response.sendSmsVerifyCode;
195
+ }
196
+ catch (error) {
197
+ console.log(`Error in sendSmsVerifyCode: ${error}`);
198
+ throw error;
199
+ }
200
+ });
201
+ }
202
+ // mutation VerifyCode {
203
+ // verifyCode(
204
+ // orgId: "FYP"
205
+ // verifyCodeRequest: { username: "0971879660", code: "999999" }
206
+ // )
207
+ // }
208
+ verifyCode(username, code) {
209
+ return __awaiter(this, void 0, void 0, function* () {
210
+ const query = mutations_1.VERIFY_CODE_MUTATION;
211
+ const variables = {
212
+ orgId: this.orgId,
213
+ verifyCodeRequest: { username, code },
214
+ };
215
+ try {
216
+ const response = yield this.graphqlMutation(query, variables);
217
+ return response.verifyCode;
218
+ }
219
+ catch (error) {
220
+ console.log(`Error in verifyCode: ${error}`);
221
+ throw error;
222
+ }
223
+ });
224
+ }
225
+ // mutation ResetPassword {
226
+ // resetPassword(
227
+ // orgId: "FYP"
228
+ // username: "0971879660"
229
+ // newPassword: "123123"
230
+ // accessToken: "882812312"
231
+ // )
232
+ // }
233
+ resetPassword(username, newPassword, accessToken) {
234
+ return __awaiter(this, void 0, void 0, function* () {
235
+ const query = mutations_1.RESET_PASSWORD_MUTATION;
236
+ const variables = {
237
+ orgId: this.orgId,
238
+ username,
239
+ newPassword,
240
+ accessToken,
241
+ };
242
+ try {
243
+ const response = yield this.graphqlMutation(query, variables);
244
+ return response.resetPassword;
245
+ }
246
+ catch (error) {
247
+ console.log(`Error in resetPassword: ${error}`);
248
+ throw error;
249
+ }
250
+ });
251
+ }
71
252
  }
72
253
  exports.AuthService = AuthService;
@@ -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: {
@@ -181,6 +181,7 @@ class UserService extends serviceSDK_1.Service {
181
181
  partnerId: this.orgId,
182
182
  currentPage: searchParams.currentPage,
183
183
  pageSize: searchParams.pageSize,
184
+ followSocialAppId: searchParams === null || searchParams === void 0 ? void 0 : searchParams.followSocialAppId,
184
185
  };
185
186
  try {
186
187
  const response = yield this.graphqlQuery(query, variables);
package/package.json CHANGED
@@ -1,43 +1,43 @@
1
- {
2
- "name": "@longvansoftware/storefront-js-client",
3
- "version": "2.2.6",
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.2.7-beta.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,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;