@longvansoftware/storefront-js-client 3.1.6 → 3.1.7

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.
Files changed (42) hide show
  1. package/README.md +221 -221
  2. package/dist/src/graphql/auth/mutations.d.ts +0 -1
  3. package/dist/src/graphql/auth/mutations.js +220 -225
  4. package/dist/src/graphql/auth/queries.d.ts +1 -0
  5. package/dist/src/graphql/auth/queries.js +65 -60
  6. package/dist/src/graphql/campaign/mutations.js +26 -26
  7. package/dist/src/graphql/campaign/queries.js +375 -375
  8. package/dist/src/graphql/cashbook/queries.js +93 -93
  9. package/dist/src/graphql/cloud/mutations.js +103 -103
  10. package/dist/src/graphql/cloud/queries.js +112 -112
  11. package/dist/src/graphql/computing/mutations.js +96 -96
  12. package/dist/src/graphql/computing/queries.js +41 -41
  13. package/dist/src/graphql/crm/mutations.js +813 -813
  14. package/dist/src/graphql/crm/queries.js +661 -661
  15. package/dist/src/graphql/payment/mutations.js +146 -146
  16. package/dist/src/graphql/payment/queries.js +116 -116
  17. package/dist/src/graphql/paymentV2/mutations.js +47 -47
  18. package/dist/src/graphql/paymentV2/queries.js +176 -176
  19. package/dist/src/graphql/product/mutations.js +94 -94
  20. package/dist/src/graphql/product/queries.js +472 -472
  21. package/dist/src/graphql/service/mutations.js +304 -304
  22. package/dist/src/graphql/service/queries.js +131 -131
  23. package/dist/src/graphql/store/mutations.js +24 -24
  24. package/dist/src/graphql/store/queries.js +24 -24
  25. package/dist/src/graphql/user/mutations.js +142 -142
  26. package/dist/src/graphql/user/queries.d.ts +0 -1
  27. package/dist/src/graphql/user/queries.js +299 -319
  28. package/dist/src/lib/auth/index.d.ts +13 -2
  29. package/dist/src/lib/auth/index.js +31 -2
  30. package/dist/src/lib/serviceSDK.js +12 -12
  31. package/dist/src/lib/store/index.js +1 -1
  32. package/dist/src/lib/user/index.d.ts +1 -2
  33. package/dist/src/lib/user/index.js +2 -20
  34. package/package.json +44 -44
  35. package/dist/src/graphql/fragments/product.d.ts +0 -38
  36. package/dist/src/graphql/fragments/product.js +0 -196
  37. package/dist/src/lib/shareZalo/index.d.ts +0 -5
  38. package/dist/src/lib/shareZalo/index.js +0 -32
  39. package/dist/src/types/common.d.ts +0 -264
  40. package/dist/src/types/common.js +0 -35
  41. package/dist/src/utils/errorHandler.d.ts +0 -64
  42. package/dist/src/utils/errorHandler.js +0 -197
@@ -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;
@@ -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: {
@@ -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);
@@ -17,8 +17,7 @@ export declare class UserService extends Service {
17
17
  getEmployeesByStoreChannelId(): Promise<any>;
18
18
  getCompanyByContactInfoId(contactId: string): Promise<any>;
19
19
  getContactInfosByCompanyId(companyId: string): Promise<any>;
20
- getProvinces(version: number): Promise<any>;
21
- getWardsByProvinceId(provinceId: string): Promise<any>;
20
+ getProvinces(): Promise<any>;
22
21
  getDistricts(provinceId: string): Promise<any>;
23
22
  getWards(districtId: string): Promise<any>;
24
23
  getPersonByPartyId(partyId: string): Promise<any>;
@@ -295,12 +295,10 @@ class UserService extends serviceSDK_1.Service {
295
295
  }
296
296
  });
297
297
  }
298
- getProvinces(version) {
298
+ getProvinces() {
299
299
  return __awaiter(this, void 0, void 0, function* () {
300
300
  const query = queries_1.GET_PROVINCES;
301
- const variables = {
302
- version,
303
- };
301
+ const variables = {};
304
302
  try {
305
303
  const response = yield this.graphqlQuery(query, variables);
306
304
  return response.getProvinces;
@@ -311,22 +309,6 @@ class UserService extends serviceSDK_1.Service {
311
309
  }
312
310
  });
313
311
  }
314
- getWardsByProvinceId(provinceId) {
315
- return __awaiter(this, void 0, void 0, function* () {
316
- const query = queries_1.GET_WARDS_BY_PROVINCEID;
317
- const variables = {
318
- provinceId,
319
- };
320
- try {
321
- const response = yield this.graphqlQuery(query, variables);
322
- return response.getWardsByProvinceId;
323
- }
324
- catch (error) {
325
- console.log(`Error in getWardsByProvinceId: ${error}`);
326
- throw error;
327
- }
328
- });
329
- }
330
312
  getDistricts(provinceId) {
331
313
  return __awaiter(this, void 0, void 0, function* () {
332
314
  const query = queries_1.GET_DISTRICTS;
package/package.json CHANGED
@@ -1,44 +1,44 @@
1
- {
2
- "name": "@longvansoftware/storefront-js-client",
3
- "version": "3.1.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
- "packageManager": "yarn@4.7.0+sha512.5a0afa1d4c1d844b3447ee3319633797bcd6385d9a44be07993ae52ff4facabccafb4af5dcd1c2f9a94ac113e5e9ff56f6130431905884414229e284e37bb7c9"
44
- }
1
+ {
2
+ "name": "@longvansoftware/storefront-js-client",
3
+ "version": "3.1.7",
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
+ "packageManager": "yarn@4.7.0+sha512.5a0afa1d4c1d844b3447ee3319633797bcd6385d9a44be07993ae52ff4facabccafb4af5dcd1c2f9a94ac113e5e9ff56f6130431905884414229e284e37bb7c9"
44
+ }
@@ -1,38 +0,0 @@
1
- /**
2
- * Common product fields fragment
3
- * Used across multiple product queries to reduce duplication
4
- */
5
- export declare const PRODUCT_CORE_FIELDS: import("graphql").DocumentNode;
6
- /**
7
- * Product attributes fragment
8
- */
9
- export declare const PRODUCT_ATTRIBUTES: import("graphql").DocumentNode;
10
- /**
11
- * Product variants fragment
12
- */
13
- export declare const PRODUCT_VARIANTS: import("graphql").DocumentNode;
14
- /**
15
- * Product feature types fragment
16
- */
17
- export declare const PRODUCT_FEATURE_TYPES: import("graphql").DocumentNode;
18
- /**
19
- * Product categories fragment
20
- */
21
- export declare const PRODUCT_CATEGORIES: import("graphql").DocumentNode;
22
- /**
23
- * Product unit fragment
24
- */
25
- export declare const PRODUCT_UNIT: import("graphql").DocumentNode;
26
- /**
27
- * Complete product details fragment
28
- * Combines all product fragments for detailed queries
29
- */
30
- export declare const PRODUCT_FULL_DETAILS: import("graphql").DocumentNode;
31
- /**
32
- * Simple product fields for list views
33
- */
34
- export declare const PRODUCT_SIMPLE_FIELDS: import("graphql").DocumentNode;
35
- /**
36
- * Extended product fields for getProducts query
37
- */
38
- export declare const PRODUCT_EXTENDED_FIELDS: import("graphql").DocumentNode;
@@ -1,196 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PRODUCT_EXTENDED_FIELDS = exports.PRODUCT_SIMPLE_FIELDS = exports.PRODUCT_FULL_DETAILS = exports.PRODUCT_UNIT = exports.PRODUCT_CATEGORIES = exports.PRODUCT_FEATURE_TYPES = exports.PRODUCT_VARIANTS = exports.PRODUCT_ATTRIBUTES = exports.PRODUCT_CORE_FIELDS = void 0;
4
- const graphql_tag_1 = require("graphql-tag");
5
- /**
6
- * Common product fields fragment
7
- * Used across multiple product queries to reduce duplication
8
- */
9
- exports.PRODUCT_CORE_FIELDS = (0, graphql_tag_1.gql) `
10
- fragment ProductCoreFields on Product {
11
- id
12
- title
13
- description
14
- sku
15
- shortDescription
16
- weight
17
- width
18
- depth
19
- height
20
- vat
21
- qualify
22
- parentId
23
- handle
24
- price
25
- options
26
- optionsRelationship
27
- compareAtPrice
28
- featuredImage
29
- images
30
- }
31
- `;
32
- /**
33
- * Product attributes fragment
34
- */
35
- exports.PRODUCT_ATTRIBUTES = (0, graphql_tag_1.gql) `
36
- fragment ProductAttributes on Product {
37
- productAttributes {
38
- attributeName
39
- attributeValue
40
- }
41
- }
42
- `;
43
- /**
44
- * Product variants fragment
45
- */
46
- exports.PRODUCT_VARIANTS = (0, graphql_tag_1.gql) `
47
- fragment ProductVariants on Product {
48
- variants {
49
- id
50
- handle
51
- title
52
- price
53
- compareAtPrice
54
- options
55
- optionsIds
56
- featuredImage
57
- sku
58
- }
59
- }
60
- `;
61
- /**
62
- * Product feature types fragment
63
- */
64
- exports.PRODUCT_FEATURE_TYPES = (0, graphql_tag_1.gql) `
65
- fragment ProductFeatureTypes on Product {
66
- featureTypes {
67
- id
68
- name
69
- values
70
- valuesFull {
71
- id
72
- name
73
- }
74
- }
75
- }
76
- `;
77
- /**
78
- * Product categories fragment
79
- */
80
- exports.PRODUCT_CATEGORIES = (0, graphql_tag_1.gql) `
81
- fragment ProductCategories on Product {
82
- categories {
83
- id
84
- title
85
- handle
86
- }
87
- }
88
- `;
89
- /**
90
- * Product unit fragment
91
- */
92
- exports.PRODUCT_UNIT = (0, graphql_tag_1.gql) `
93
- fragment ProductUnit on Product {
94
- unitDTO {
95
- id
96
- name
97
- }
98
- }
99
- `;
100
- /**
101
- * Complete product details fragment
102
- * Combines all product fragments for detailed queries
103
- */
104
- exports.PRODUCT_FULL_DETAILS = (0, graphql_tag_1.gql) `
105
- fragment ProductFullDetails on Product {
106
- ...ProductCoreFields
107
- ...ProductAttributes
108
- ...ProductVariants
109
- ...ProductFeatureTypes
110
- ...ProductCategories
111
- ...ProductUnit
112
- }
113
- ${exports.PRODUCT_CORE_FIELDS}
114
- ${exports.PRODUCT_ATTRIBUTES}
115
- ${exports.PRODUCT_VARIANTS}
116
- ${exports.PRODUCT_FEATURE_TYPES}
117
- ${exports.PRODUCT_CATEGORIES}
118
- ${exports.PRODUCT_UNIT}
119
- `;
120
- /**
121
- * Simple product fields for list views
122
- */
123
- exports.PRODUCT_SIMPLE_FIELDS = (0, graphql_tag_1.gql) `
124
- fragment ProductSimpleFields on Product {
125
- id
126
- title
127
- sku
128
- shortDescription
129
- description
130
- subType
131
- vat
132
- qualify
133
- parentId
134
- handle
135
- price
136
- compareAtPrice
137
- priceType
138
- priceTypeName
139
- featuredImage
140
- optionsRelationship
141
- images
142
- }
143
- `;
144
- /**
145
- * Extended product fields for getProducts query
146
- */
147
- exports.PRODUCT_EXTENDED_FIELDS = (0, graphql_tag_1.gql) `
148
- fragment ProductExtendedFields on Product {
149
- id
150
- title
151
- subType
152
- description
153
- sku
154
- shortDescription
155
- weight
156
- width
157
- depth
158
- height
159
- vat
160
- qualify
161
- parentId
162
- handle
163
- price
164
- priceType
165
- salePolicy
166
- priceTypeName
167
- priceVaries
168
- available
169
- tags
170
- options
171
- optionsRelationship
172
- compareAtPrice
173
- featuredImage
174
- images
175
- categories {
176
- id
177
- title
178
- image
179
- icon
180
- parentId
181
- level
182
- handle
183
- description
184
- }
185
- groups {
186
- id
187
- name
188
- policy
189
- image
190
- }
191
- unitDTO {
192
- id
193
- name
194
- }
195
- }
196
- `;
@@ -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;