@longvansoftware/service-js-client 1.16.0 → 1.16.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.
Files changed (91) hide show
  1. package/README.md +93 -93
  2. package/dist/src/graphql/accounting_service/mutations.js +96 -96
  3. package/dist/src/graphql/accounting_service/queries.js +57 -57
  4. package/dist/src/graphql/auth/mutations.js +235 -235
  5. package/dist/src/graphql/auth/queries.js +68 -68
  6. package/dist/src/graphql/cloud/mutations.js +282 -282
  7. package/dist/src/graphql/cloud/queries.js +341 -341
  8. package/dist/src/graphql/computing/mutations.js +303 -303
  9. package/dist/src/graphql/computing/queries.js +548 -548
  10. package/dist/src/graphql/crm/mutations.js +390 -390
  11. package/dist/src/graphql/crm/queries.js +357 -357
  12. package/dist/src/graphql/crm_camping/mutations.js +32 -32
  13. package/dist/src/graphql/crm_camping/queries.js +228 -199
  14. package/dist/src/graphql/orderGraphQL/mutations.js +351 -351
  15. package/dist/src/graphql/orderGraphQL/queries.js +387 -387
  16. package/dist/src/graphql/payment/mutations.js +45 -45
  17. package/dist/src/graphql/payment/queries.js +60 -60
  18. package/dist/src/graphql/paymentLV/mutations.js +19 -19
  19. package/dist/src/graphql/paymentLV/queries.js +75 -75
  20. package/dist/src/graphql/product/queries.d.ts +1 -0
  21. package/dist/src/graphql/product/queries.js +910 -892
  22. package/dist/src/graphql/quicklab_service/mutations.js +154 -154
  23. package/dist/src/graphql/quicklab_service/queries.js +108 -108
  24. package/dist/src/graphql/resource_permission/mutations.js +57 -57
  25. package/dist/src/graphql/resource_permission/queries.js +13 -13
  26. package/dist/src/graphql/service/mutations.js +228 -228
  27. package/dist/src/graphql/service/queries.js +128 -128
  28. package/dist/src/graphql/user/mutations.js +214 -214
  29. package/dist/src/graphql/user/queries.js +312 -312
  30. package/dist/src/lib/crm_camping/index.d.ts +1 -1
  31. package/dist/src/lib/crm_camping/index.js +10 -6
  32. package/dist/src/lib/product/index.d.ts +1 -0
  33. package/dist/src/lib/product/index.js +18 -0
  34. package/dist/src/lib/service.d.ts +14 -0
  35. package/dist/src/lib/service.js +101 -0
  36. package/dist/src/lib/serviceSDK.js +12 -12
  37. package/dist/src/utils/build-field-string.d.ts +1 -0
  38. package/dist/src/utils/build-field-string.js +16 -0
  39. package/package.json +43 -44
  40. package/dist/src/graphql/campaign/mutations.d.ts +0 -1
  41. package/dist/src/graphql/campaign/mutations.js +0 -34
  42. package/dist/src/graphql/campaign/queries.d.ts +0 -9
  43. package/dist/src/graphql/campaign/queries.js +0 -412
  44. package/dist/src/graphql/cashbook/queries.d.ts +0 -2
  45. package/dist/src/graphql/cashbook/queries.js +0 -99
  46. package/dist/src/graphql/paymentV2/mutations.d.ts +0 -3
  47. package/dist/src/graphql/paymentV2/mutations.js +0 -54
  48. package/dist/src/graphql/paymentV2/queries.d.ts +0 -6
  49. package/dist/src/graphql/paymentV2/queries.js +0 -186
  50. package/dist/src/graphql/store/mutations.d.ts +0 -1
  51. package/dist/src/graphql/store/mutations.js +0 -29
  52. package/dist/src/graphql/store/queries.d.ts +0 -1
  53. package/dist/src/graphql/store/queries.js +0 -29
  54. package/dist/src/lib/accounting/index.d.ts +0 -5
  55. package/dist/src/lib/accounting/index.js +0 -32
  56. package/dist/src/lib/campaign/index.d.ts +0 -20
  57. package/dist/src/lib/campaign/index.js +0 -213
  58. package/dist/src/lib/cashbook/index.d.ts +0 -6
  59. package/dist/src/lib/cashbook/index.js +0 -56
  60. package/dist/src/lib/comhub/index.d.ts +0 -6
  61. package/dist/src/lib/comhub/index.js +0 -50
  62. package/dist/src/lib/deepLinkVietQr/index.d.ts +0 -6
  63. package/dist/src/lib/deepLinkVietQr/index.js +0 -45
  64. package/dist/src/lib/getImage/index.d.ts +0 -4
  65. package/dist/src/lib/getImage/index.js +0 -10
  66. package/dist/src/lib/image/index.d.ts +0 -7
  67. package/dist/src/lib/image/index.js +0 -49
  68. package/dist/src/lib/omnigateway/index.d.ts +0 -7
  69. package/dist/src/lib/omnigateway/index.js +0 -58
  70. package/dist/src/lib/paymentV2/index.d.ts +0 -13
  71. package/dist/src/lib/paymentV2/index.js +0 -163
  72. package/dist/src/lib/portal/index.d.ts +0 -21
  73. package/dist/src/lib/portal/index.js +0 -225
  74. package/dist/src/lib/store/index.d.ts +0 -30
  75. package/dist/src/lib/store/index.js +0 -74
  76. package/dist/src/lib/token/index.d.ts +0 -5
  77. package/dist/src/lib/token/index.js +0 -32
  78. package/dist/src/lib/upload/index.d.ts +0 -5
  79. package/dist/src/lib/upload/index.js +0 -35
  80. package/dist/src/lib/warehouseV2/index.d.ts +0 -13
  81. package/dist/src/lib/warehouseV2/index.js +0 -54
  82. package/dist/src/lib/zca/index.d.ts +0 -12
  83. package/dist/src/lib/zca/index.js +0 -41
  84. package/dist/src/types/campaign.d.ts +0 -14
  85. package/dist/src/types/campaign.js +0 -2
  86. package/dist/src/types/invoice.d.ts +0 -13
  87. package/dist/src/types/invoice.js +0 -2
  88. package/dist/src/types/store.d.ts +0 -158
  89. package/dist/src/types/store.js +0 -3
  90. package/dist/src/utils/validatePhoneNumber.d.ts +0 -1
  91. package/dist/src/utils/validatePhoneNumber.js +0 -20
@@ -138,7 +138,7 @@ class CrmCampingService extends serviceSDK_1.Service {
138
138
  targetIds,
139
139
  customerId,
140
140
  evaluationType,
141
- orgId: this.orgId
141
+ orgId: this.orgId,
142
142
  };
143
143
  try {
144
144
  const response = yield this.graphqlQueryV2(query, variables);
@@ -157,7 +157,7 @@ class CrmCampingService extends serviceSDK_1.Service {
157
157
  targetIds,
158
158
  customerId,
159
159
  evaluationType,
160
- orgId: this.orgId
160
+ orgId: this.orgId,
161
161
  };
162
162
  try {
163
163
  const response = yield this.graphqlQueryV2(query, variables);
@@ -174,7 +174,7 @@ class CrmCampingService extends serviceSDK_1.Service {
174
174
  const query = queries_1.GET_NUMBER_OF_TICKET_EVALUATION;
175
175
  const variables = {
176
176
  customerId,
177
- orgId: this.orgId
177
+ orgId: this.orgId,
178
178
  };
179
179
  try {
180
180
  const response = yield this.graphqlQueryV2(query, variables);
@@ -186,13 +186,17 @@ class CrmCampingService extends serviceSDK_1.Service {
186
186
  }
187
187
  });
188
188
  }
189
- searchProductGiftPromotionResponse(productId) {
189
+ searchProductGiftPromotionResponse(parameterSearchProductGift) {
190
190
  return __awaiter(this, void 0, void 0, function* () {
191
+ // console.log("🚀 ~ CrmCampingService ~ searchProductGiftPromotionResponse ~ parameterSearchProductGift:", parameterSearchProductGift)
191
192
  const query = queries_1.SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE;
192
193
  const variables = {
193
- partyId: this.orgId,
194
- productId
194
+ parameterSearchProductGift: Object.assign({ partyId: this.orgId }, parameterSearchProductGift),
195
195
  };
196
+ // console.log(
197
+ // "🚀 ~ CrmCampingService ~ searchProductGiftPromotionResponse ~ variables:",
198
+ // variables
199
+ // );
196
200
  try {
197
201
  const response = yield this.graphqlQueryV2(query, variables);
198
202
  return response.searchProductGiftPromotionResponse;
@@ -43,6 +43,7 @@ export declare class ProductService extends Service {
43
43
  getHandleByServiceTypes(serviceTypes: [string]): Promise<any>;
44
44
  getResourceByProduct(productId: string): Promise<any>;
45
45
  getProductVariantById(variantId: string): Promise<any>;
46
+ getProductVariantByIdDynamic(variantId: string, store: string, fields: string[]): Promise<any>;
46
47
  getRelatedInfor(id: string): Promise<any>;
47
48
  getDetailStores(storeId: string): Promise<any>;
48
49
  getListPrice(productIds: string[], storeId: string): Promise<any>;
@@ -231,6 +231,24 @@ class ProductService extends serviceSDK_1.Service {
231
231
  }
232
232
  });
233
233
  }
234
+ getProductVariantByIdDynamic(variantId, store, fields) {
235
+ return __awaiter(this, void 0, void 0, function* () {
236
+ const query = (0, queries_1.GET_PRODUCT_VARIANT_BY_ID_QUERY_DYNAMIC)(fields);
237
+ const variables = {
238
+ partnerId: this.orgId,
239
+ storeChannel: store ? store : this.storeId,
240
+ variantId,
241
+ };
242
+ try {
243
+ const response = yield this.graphqlQuery(query, variables);
244
+ return response.getProductById;
245
+ }
246
+ catch (error) {
247
+ console.log(`Error fetching product by ID: ${error}`);
248
+ throw error;
249
+ }
250
+ });
251
+ }
234
252
  getRelatedInfor(id) {
235
253
  return __awaiter(this, void 0, void 0, function* () {
236
254
  const query = queries_1.GET_RELATED_INFOR;
@@ -0,0 +1,14 @@
1
+ import { ApolloClient, NormalizedCacheObject } from "@apollo/client";
2
+ import { DocumentNode } from "graphql";
3
+ export declare class Service {
4
+ protected token: string | null;
5
+ protected client: ApolloClient<NormalizedCacheObject>;
6
+ protected orgId: string;
7
+ protected storeId: string;
8
+ protected endpoint: string;
9
+ constructor(endpoint: string, orgId: string, storeId: string);
10
+ setToken(token: string): void;
11
+ protected graphqlQuery(query: DocumentNode, variables: any): Promise<any>;
12
+ protected graphqlMutation(mutation: DocumentNode, variables: any): Promise<any>;
13
+ protected restApiCallWithToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
14
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ // src/service.ts
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Service = void 0;
17
+ const client_1 = require("@apollo/client");
18
+ const axios_1 = __importDefault(require("axios"));
19
+ class Service {
20
+ constructor(endpoint, orgId, storeId) {
21
+ this.token = null;
22
+ this.client = new client_1.ApolloClient({
23
+ uri: endpoint,
24
+ cache: new client_1.InMemoryCache(),
25
+ defaultOptions: {
26
+ query: {
27
+ fetchPolicy: "network-only",
28
+ },
29
+ },
30
+ });
31
+ this.orgId = orgId;
32
+ this.storeId = storeId;
33
+ this.endpoint = endpoint;
34
+ }
35
+ setToken(token) {
36
+ this.token = token;
37
+ }
38
+ // setOrgId(orgId: string) {
39
+ // this.orgId = orgId;
40
+ // }
41
+ graphqlQuery(query, variables) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ try {
44
+ const { data, errors } = yield this.client.query({
45
+ query: (0, client_1.gql) `
46
+ ${query}
47
+ `,
48
+ variables,
49
+ });
50
+ if (errors) {
51
+ throw new Error(`GraphQL error! errors: ${errors}`);
52
+ }
53
+ return data;
54
+ }
55
+ catch (error) {
56
+ console.log(`Error in graphqlQuery: ${error}`);
57
+ throw error;
58
+ }
59
+ });
60
+ }
61
+ graphqlMutation(mutation, variables) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ try {
64
+ const { data, errors } = yield this.client.mutate({
65
+ mutation: (0, client_1.gql) `
66
+ ${mutation}
67
+ `,
68
+ variables,
69
+ });
70
+ if (errors) {
71
+ throw new Error(`GraphQL error! errors: ${errors}`);
72
+ }
73
+ return data;
74
+ }
75
+ catch (error) {
76
+ console.log(`Error in graphqlMutation: ${error}`);
77
+ throw error;
78
+ }
79
+ });
80
+ }
81
+ restApiCallWithToken(path, method, data, headers) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ try {
84
+ const modifiedHeaders = Object.assign(Object.assign({}, headers), { "Partner-Id": this.orgId, "X-Ecomos-Access-Token": this.token });
85
+ console.log("🚀 ~ Service ~ modifiedHeaders:", modifiedHeaders);
86
+ const response = yield (0, axios_1.default)({
87
+ url: this.endpoint + path,
88
+ method,
89
+ data,
90
+ headers: modifiedHeaders,
91
+ });
92
+ return response.data;
93
+ }
94
+ catch (error) {
95
+ console.log(`Error in restApiCallWithToken: ${error}`);
96
+ throw error;
97
+ }
98
+ });
99
+ }
100
+ }
101
+ exports.Service = Service;
@@ -44,8 +44,8 @@ class Service {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
45
  try {
46
46
  const { data, errors } = yield this.client.query({
47
- query: (0, client_1.gql) `
48
- ${query}
47
+ query: (0, client_1.gql) `
48
+ ${query}
49
49
  `,
50
50
  variables,
51
51
  fetchPolicy: "no-cache",
@@ -72,8 +72,8 @@ class Service {
72
72
  return __awaiter(this, void 0, void 0, function* () {
73
73
  try {
74
74
  const { data, errors } = yield this.client.mutate({
75
- mutation: (0, client_1.gql) `
76
- ${mutation}
75
+ mutation: (0, client_1.gql) `
76
+ ${mutation}
77
77
  `,
78
78
  variables,
79
79
  fetchPolicy: "no-cache",
@@ -134,8 +134,8 @@ class Service {
134
134
  return __awaiter(this, void 0, void 0, function* () {
135
135
  try {
136
136
  const { data, errors } = yield this.client.query({
137
- query: (0, client_1.gql) `
138
- ${query}
137
+ query: (0, client_1.gql) `
138
+ ${query}
139
139
  `,
140
140
  variables,
141
141
  fetchPolicy: "no-cache",
@@ -163,8 +163,8 @@ class Service {
163
163
  return __awaiter(this, void 0, void 0, function* () {
164
164
  try {
165
165
  const { data, errors } = yield this.client.mutate({
166
- mutation: (0, client_1.gql) `
167
- ${mutation}
166
+ mutation: (0, client_1.gql) `
167
+ ${mutation}
168
168
  `,
169
169
  variables,
170
170
  fetchPolicy: "no-cache",
@@ -192,8 +192,8 @@ class Service {
192
192
  try {
193
193
  const headers = Object.assign({ "Content-Type": "application/json" }, additionalHeaders);
194
194
  const { data, errors } = yield this.client.query({
195
- query: (0, client_1.gql) `
196
- ${query}
195
+ query: (0, client_1.gql) `
196
+ ${query}
197
197
  `,
198
198
  variables,
199
199
  fetchPolicy: "no-cache",
@@ -218,8 +218,8 @@ class Service {
218
218
  try {
219
219
  const headers = Object.assign({ "Content-Type": "application/json" }, additionalHeaders);
220
220
  const { data, errors } = yield this.client.mutate({
221
- mutation: (0, client_1.gql) `
222
- ${mutation}
221
+ mutation: (0, client_1.gql) `
222
+ ${mutation}
223
223
  `,
224
224
  variables,
225
225
  fetchPolicy: "no-cache",
@@ -0,0 +1 @@
1
+ export declare function buildFieldString(fields: (string | Record<string, any>)[], indent?: number): string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildFieldString = void 0;
4
+ function buildFieldString(fields, indent = 6) {
5
+ const space = " ".repeat(indent);
6
+ return fields
7
+ .map((field) => {
8
+ if (typeof field === "string")
9
+ return `${space}${field}`;
10
+ const [key, value] = Object.entries(field)[0];
11
+ const nested = buildFieldString(value, indent + 2);
12
+ return `${space}${key} {\n${nested}\n${space}}`;
13
+ })
14
+ .join("\n");
15
+ }
16
+ exports.buildFieldString = buildFieldString;
package/package.json CHANGED
@@ -1,44 +1,43 @@
1
- {
2
- "name": "@longvansoftware/service-js-client",
3
- "version": "1.16.0",
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/service-js-client",
3
+ "version": "1.16.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 +0,0 @@
1
- export declare const ADD_CUSTOMER_ID_INTO_VOUCHER: import("graphql").DocumentNode;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ADD_CUSTOMER_ID_INTO_VOUCHER = void 0;
7
- const graphql_tag_1 = __importDefault(require("graphql-tag"));
8
- exports.ADD_CUSTOMER_ID_INTO_VOUCHER = (0, graphql_tag_1.default) `
9
- mutation AddCustomerToVoucher(
10
- $partyId: String!
11
- $voucherCode: String!
12
- $userId: String!
13
- $affiliateId: String
14
- ) {
15
- addCustomerToVoucher(
16
- partyId: $partyId
17
- voucherCode: $voucherCode
18
- userId: $userId
19
- affiliateId: $affiliateId
20
- ) {
21
- id
22
- customerId
23
- campaignActionId
24
- campaignId
25
- partyId
26
- voucherCode
27
- voucherType
28
- status
29
- discountAmount
30
- discountPercent
31
- usageLimitPerVoucher
32
- }
33
- }
34
- `;
@@ -1,9 +0,0 @@
1
- export declare const GET_CAMPAIGN_ACTION_ACTIVE_NOW: import("graphql").DocumentNode;
2
- export declare const GET_VOUCHERS: import("graphql").DocumentNode;
3
- export declare const CHECK_VALID_VOUCHER: import("graphql").DocumentNode;
4
- export declare const GET_CAMPAIGN_ACTIVE_NOW: import("graphql").DocumentNode;
5
- export declare const GET_PROMOTION_PRODUCT_PRICE: import("graphql").DocumentNode;
6
- export declare const GET_VOUCHER_AVAILABLE_FOR_CUSTOMER: import("graphql").DocumentNode;
7
- export declare const SUGGEST_VOUCHER: import("graphql").DocumentNode;
8
- export declare const GET_CAMPAIGN_ACTION_BY_ID: import("graphql").DocumentNode;
9
- export declare const SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE: import("graphql").DocumentNode;