@longvansoftware/service-js-client 1.16.7 → 1.16.9

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 (74) hide show
  1. package/dist/src/graphql/cloud/queries.js +1 -0
  2. package/dist/src/graphql/crm_camping/queries.js +3 -0
  3. package/dist/src/graphql/orderGraphQL/queries.js +37 -11
  4. package/dist/src/lib/order/index.d.ts +1 -0
  5. package/dist/src/lib/order/index.js +18 -0
  6. package/dist/src/lib/service.d.ts +14 -0
  7. package/dist/src/lib/service.js +101 -0
  8. package/dist/src/utils/build-field-string.d.ts +1 -0
  9. package/dist/src/utils/build-field-string.js +16 -0
  10. package/package.json +1 -1
  11. package/dist/src/graphql/campaign/mutations.d.ts +0 -1
  12. package/dist/src/graphql/campaign/mutations.js +0 -34
  13. package/dist/src/graphql/campaign/queries.d.ts +0 -9
  14. package/dist/src/graphql/campaign/queries.js +0 -427
  15. package/dist/src/graphql/cashbook/queries.d.ts +0 -2
  16. package/dist/src/graphql/cashbook/queries.js +0 -99
  17. package/dist/src/graphql/fragments/product.d.ts +0 -38
  18. package/dist/src/graphql/fragments/product.js +0 -196
  19. package/dist/src/graphql/paymentV2/mutations.d.ts +0 -5
  20. package/dist/src/graphql/paymentV2/mutations.js +0 -120
  21. package/dist/src/graphql/paymentV2/queries.d.ts +0 -9
  22. package/dist/src/graphql/paymentV2/queries.js +0 -257
  23. package/dist/src/graphql/store/mutations.d.ts +0 -1
  24. package/dist/src/graphql/store/mutations.js +0 -29
  25. package/dist/src/graphql/store/queries.d.ts +0 -1
  26. package/dist/src/graphql/store/queries.js +0 -29
  27. package/dist/src/lib/accounting/index.d.ts +0 -5
  28. package/dist/src/lib/accounting/index.js +0 -32
  29. package/dist/src/lib/campaign/index.d.ts +0 -20
  30. package/dist/src/lib/campaign/index.js +0 -218
  31. package/dist/src/lib/cashbook/index.d.ts +0 -6
  32. package/dist/src/lib/cashbook/index.js +0 -56
  33. package/dist/src/lib/comhub/index.d.ts +0 -6
  34. package/dist/src/lib/comhub/index.js +0 -50
  35. package/dist/src/lib/deepLinkVietQr/index.d.ts +0 -7
  36. package/dist/src/lib/deepLinkVietQr/index.js +0 -58
  37. package/dist/src/lib/fileService/index.d.ts +0 -34
  38. package/dist/src/lib/fileService/index.js +0 -80
  39. package/dist/src/lib/getImage/index.d.ts +0 -4
  40. package/dist/src/lib/getImage/index.js +0 -10
  41. package/dist/src/lib/image/index.d.ts +0 -7
  42. package/dist/src/lib/image/index.js +0 -49
  43. package/dist/src/lib/omnigateway/index.d.ts +0 -7
  44. package/dist/src/lib/omnigateway/index.js +0 -58
  45. package/dist/src/lib/paymentV2/index.d.ts +0 -18
  46. package/dist/src/lib/paymentV2/index.js +0 -245
  47. package/dist/src/lib/portal/index.d.ts +0 -23
  48. package/dist/src/lib/portal/index.js +0 -255
  49. package/dist/src/lib/shareZalo/index.d.ts +0 -5
  50. package/dist/src/lib/shareZalo/index.js +0 -32
  51. package/dist/src/lib/store/index.d.ts +0 -30
  52. package/dist/src/lib/store/index.js +0 -74
  53. package/dist/src/lib/token/index.d.ts +0 -5
  54. package/dist/src/lib/token/index.js +0 -32
  55. package/dist/src/lib/upload/index.d.ts +0 -5
  56. package/dist/src/lib/upload/index.js +0 -35
  57. package/dist/src/lib/warehouseV2/index.d.ts +0 -13
  58. package/dist/src/lib/warehouseV2/index.js +0 -54
  59. package/dist/src/lib/zca/index.d.ts +0 -12
  60. package/dist/src/lib/zca/index.js +0 -41
  61. package/dist/src/types/campaign.d.ts +0 -14
  62. package/dist/src/types/campaign.js +0 -2
  63. package/dist/src/types/common.d.ts +0 -264
  64. package/dist/src/types/common.js +0 -35
  65. package/dist/src/types/invoice.d.ts +0 -13
  66. package/dist/src/types/invoice.js +0 -2
  67. package/dist/src/types/portal.d.ts +0 -7
  68. package/dist/src/types/portal.js +0 -2
  69. package/dist/src/types/store.d.ts +0 -158
  70. package/dist/src/types/store.js +0 -3
  71. package/dist/src/utils/errorHandler.d.ts +0 -64
  72. package/dist/src/utils/errorHandler.js +0 -197
  73. package/dist/src/utils/validatePhoneNumber.d.ts +0 -1
  74. package/dist/src/utils/validatePhoneNumber.js +0 -20
@@ -359,6 +359,7 @@ exports.GET_ELASTIC_CLOUD_RESOURCE = (0, graphql_tag_1.gql) `
359
359
  size
360
360
  used
361
361
  }
362
+ provinces
362
363
  }
363
364
  }
364
365
  `;
@@ -257,9 +257,12 @@ exports.SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE = (0, graphql_tag_1.gql) `
257
257
  productId
258
258
  productParentId
259
259
  quantityLimit
260
+ newCustomer
261
+ minimumSpend
260
262
  giftPromotions {
261
263
  fromQuantity
262
264
  toProductId
265
+ toProductParentId
263
266
  toQuantity
264
267
  productName
265
268
  sku
@@ -135,18 +135,44 @@ exports.GET_ORDER_DETAIL = (0, graphql_tag_1.gql) `
135
135
  value
136
136
  title
137
137
  }
138
- resourceItems {
139
- name
140
- quantity
141
- unit
142
- productId
143
- }
144
138
  resourceConfigs {
145
- name
146
- quantity
147
- unit
148
- productId
149
- }
139
+ name
140
+ quantity
141
+ unit
142
+ productId
143
+ giftProductId
144
+ gift
145
+ giftQuantity
146
+ campaignId
147
+ campaignActionId
148
+ qualify
149
+ idParent
150
+ addQuantity
151
+ defaultQuantity
152
+ title
153
+ price
154
+ unitPrice
155
+ totalResource
156
+ }
157
+ resourceItems {
158
+ name
159
+ quantity
160
+ unit
161
+ productId
162
+ giftProductId
163
+ gift
164
+ giftQuantity
165
+ campaignId
166
+ campaignActionId
167
+ qualify
168
+ idParent
169
+ addQuantity
170
+ defaultQuantity
171
+ title
172
+ price
173
+ unitPrice
174
+ totalResource
175
+ }
150
176
  itemType
151
177
  }
152
178
  serviceId
@@ -471,4 +471,5 @@ export declare class OrderService extends Service {
471
471
  addProductInOrderWithoutLogin(orderId: string, updated_by: string, data: any, store: string): Promise<any>;
472
472
  findCampaignActionGiftVoucher(): Promise<any>;
473
473
  addProductGiftPromotion(orderId: string, updatedBy: string, data: any): Promise<any>;
474
+ removeProductGiftPromotion(orderId: string, orderLineItemId: string): Promise<any>;
474
475
  }
@@ -1295,5 +1295,23 @@ class OrderService extends serviceSDK_1.Service {
1295
1295
  }
1296
1296
  });
1297
1297
  }
1298
+ // https://storefront.dev.longvan.vn/swagger-ui/index.html#/Order%20API/removeGiftQuantity
1299
+ removeProductGiftPromotion(orderId, orderLineItemId) {
1300
+ return __awaiter(this, void 0, void 0, function* () {
1301
+ console.log("🚀 ~ OrderService ~ removeProductGiftPromotion ~ orderLineItemId:", orderLineItemId);
1302
+ console.log("🚀 ~ OrderService ~ removeProductGiftPromotion ~ orderId:", orderId);
1303
+ const endpoint = `/orders/${this.orgId}/${orderId}/${orderLineItemId}/giftQuantity`;
1304
+ const method = "PUT";
1305
+ try {
1306
+ const response = yield this.restApiCallWithToken(endpoint, method);
1307
+ console.log(response);
1308
+ return response;
1309
+ }
1310
+ catch (error) {
1311
+ console.log(`Error in removeProductGiftPromotion: ${error}`);
1312
+ throw error;
1313
+ }
1314
+ });
1315
+ }
1298
1316
  }
1299
1317
  exports.OrderService = OrderService;
@@ -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;
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "1.16.7",
3
+ "version": "1.16.9",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [
@@ -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;