@longvansoftware/service-js-client 1.16.4 → 1.16.6

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 (100) hide show
  1. package/dist/src/graphql/cloud/mutations.d.ts +0 -4
  2. package/dist/src/graphql/cloud/mutations.js +1 -47
  3. package/dist/src/graphql/cloud/queries.d.ts +0 -1
  4. package/dist/src/graphql/cloud/queries.js +1 -26
  5. package/dist/src/graphql/computing/mutations.d.ts +0 -1
  6. package/dist/src/graphql/computing/mutations.js +1 -15
  7. package/dist/src/graphql/crm/mutations.d.ts +0 -3
  8. package/dist/src/graphql/crm/mutations.js +1 -54
  9. package/dist/src/graphql/crm/queries.d.ts +0 -3
  10. package/dist/src/graphql/crm/queries.js +1 -71
  11. package/dist/src/graphql/crm_camping/queries.js +19 -49
  12. package/dist/src/graphql/orderGraphQL/queries.d.ts +5 -7
  13. package/dist/src/graphql/orderGraphQL/queries.js +1 -11
  14. package/dist/src/graphql/product/queries.d.ts +0 -2
  15. package/dist/src/graphql/product/queries.js +1 -32
  16. package/dist/src/lib/auth/index.d.ts +1 -1
  17. package/dist/src/lib/auth/index.js +4 -3
  18. package/dist/src/lib/cloud/index.d.ts +0 -5
  19. package/dist/src/lib/cloud/index.js +0 -85
  20. package/dist/src/lib/computing/index.d.ts +0 -1
  21. package/dist/src/lib/computing/index.js +0 -17
  22. package/dist/src/lib/crm/index.d.ts +0 -6
  23. package/dist/src/lib/crm/index.js +0 -107
  24. package/dist/src/lib/crm_camping/index.d.ts +2 -2
  25. package/dist/src/lib/crm_camping/index.js +8 -13
  26. package/dist/src/lib/orderGraphQL/index.d.ts +0 -1
  27. package/dist/src/lib/orderGraphQL/index.js +0 -16
  28. package/dist/src/lib/product/index.d.ts +0 -2
  29. package/dist/src/lib/product/index.js +0 -34
  30. package/dist/src/lib/resource_permission/index.d.ts +2 -2
  31. package/dist/src/lib/resource_permission/index.js +4 -4
  32. package/dist/src/lib/service.d.ts +14 -0
  33. package/dist/src/lib/service.js +101 -0
  34. package/dist/src/utils/build-field-string.d.ts +1 -0
  35. package/dist/src/utils/build-field-string.js +16 -0
  36. package/package.json +1 -1
  37. package/dist/src/graphql/campaign/mutations.d.ts +0 -1
  38. package/dist/src/graphql/campaign/mutations.js +0 -34
  39. package/dist/src/graphql/campaign/queries.d.ts +0 -9
  40. package/dist/src/graphql/campaign/queries.js +0 -427
  41. package/dist/src/graphql/cashbook/queries.d.ts +0 -2
  42. package/dist/src/graphql/cashbook/queries.js +0 -99
  43. package/dist/src/graphql/fragments/product.d.ts +0 -38
  44. package/dist/src/graphql/fragments/product.js +0 -196
  45. package/dist/src/graphql/paymentV2/mutations.d.ts +0 -5
  46. package/dist/src/graphql/paymentV2/mutations.js +0 -120
  47. package/dist/src/graphql/paymentV2/queries.d.ts +0 -9
  48. package/dist/src/graphql/paymentV2/queries.js +0 -257
  49. package/dist/src/graphql/store/mutations.d.ts +0 -1
  50. package/dist/src/graphql/store/mutations.js +0 -29
  51. package/dist/src/graphql/store/queries.d.ts +0 -1
  52. package/dist/src/graphql/store/queries.js +0 -29
  53. package/dist/src/lib/accounting/index.d.ts +0 -5
  54. package/dist/src/lib/accounting/index.js +0 -32
  55. package/dist/src/lib/campaign/index.d.ts +0 -20
  56. package/dist/src/lib/campaign/index.js +0 -218
  57. package/dist/src/lib/cashbook/index.d.ts +0 -6
  58. package/dist/src/lib/cashbook/index.js +0 -56
  59. package/dist/src/lib/comhub/index.d.ts +0 -6
  60. package/dist/src/lib/comhub/index.js +0 -50
  61. package/dist/src/lib/deepLinkVietQr/index.d.ts +0 -7
  62. package/dist/src/lib/deepLinkVietQr/index.js +0 -58
  63. package/dist/src/lib/fileService/index.d.ts +0 -34
  64. package/dist/src/lib/fileService/index.js +0 -80
  65. package/dist/src/lib/getImage/index.d.ts +0 -4
  66. package/dist/src/lib/getImage/index.js +0 -10
  67. package/dist/src/lib/image/index.d.ts +0 -7
  68. package/dist/src/lib/image/index.js +0 -49
  69. package/dist/src/lib/omnigateway/index.d.ts +0 -7
  70. package/dist/src/lib/omnigateway/index.js +0 -58
  71. package/dist/src/lib/paymentV2/index.d.ts +0 -18
  72. package/dist/src/lib/paymentV2/index.js +0 -245
  73. package/dist/src/lib/portal/index.d.ts +0 -23
  74. package/dist/src/lib/portal/index.js +0 -255
  75. package/dist/src/lib/shareZalo/index.d.ts +0 -5
  76. package/dist/src/lib/shareZalo/index.js +0 -32
  77. package/dist/src/lib/store/index.d.ts +0 -30
  78. package/dist/src/lib/store/index.js +0 -74
  79. package/dist/src/lib/token/index.d.ts +0 -5
  80. package/dist/src/lib/token/index.js +0 -32
  81. package/dist/src/lib/upload/index.d.ts +0 -5
  82. package/dist/src/lib/upload/index.js +0 -35
  83. package/dist/src/lib/warehouseV2/index.d.ts +0 -13
  84. package/dist/src/lib/warehouseV2/index.js +0 -54
  85. package/dist/src/lib/zca/index.d.ts +0 -12
  86. package/dist/src/lib/zca/index.js +0 -41
  87. package/dist/src/types/campaign.d.ts +0 -14
  88. package/dist/src/types/campaign.js +0 -2
  89. package/dist/src/types/common.d.ts +0 -264
  90. package/dist/src/types/common.js +0 -35
  91. package/dist/src/types/invoice.d.ts +0 -13
  92. package/dist/src/types/invoice.js +0 -2
  93. package/dist/src/types/portal.d.ts +0 -7
  94. package/dist/src/types/portal.js +0 -2
  95. package/dist/src/types/store.d.ts +0 -158
  96. package/dist/src/types/store.js +0 -3
  97. package/dist/src/utils/errorHandler.d.ts +0 -64
  98. package/dist/src/utils/errorHandler.js +0 -197
  99. package/dist/src/utils/validatePhoneNumber.d.ts +0 -1
  100. package/dist/src/utils/validatePhoneNumber.js +0 -20
@@ -45,75 +45,6 @@ class CloudService extends serviceSDK_1.Service {
45
45
  }
46
46
  });
47
47
  }
48
- updateServiceCompleted(serviceId, handleBy) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const mutation = mutations_1.UPDATE_SERVICE_COMPLETED;
51
- const variables = {
52
- serviceId,
53
- handleBy,
54
- };
55
- try {
56
- const response = yield this.graphqlMutationV2(mutation, variables);
57
- return response.updateServiceCompleted;
58
- }
59
- catch (error) {
60
- console.log(`Error in updateServiceCompleted: ${error}`);
61
- throw error;
62
- }
63
- });
64
- }
65
- updateServiceNew(serviceId, handleBy) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const mutation = mutations_1.UPDATE_SERVICE_NEW;
68
- const variables = {
69
- serviceId,
70
- handleBy,
71
- };
72
- try {
73
- const response = yield this.graphqlMutationV2(mutation, variables);
74
- return response.updateServiceNew;
75
- }
76
- catch (error) {
77
- console.log(`Error in updateServiceNew: ${error}`);
78
- throw error;
79
- }
80
- });
81
- }
82
- updateServiceReadyDeploy(serviceId, handleBy) {
83
- return __awaiter(this, void 0, void 0, function* () {
84
- const mutation = mutations_1.UPDATE_SERVICE_READY_DEPLOY;
85
- const variables = {
86
- serviceId,
87
- handleBy,
88
- };
89
- try {
90
- const response = yield this.graphqlMutationV2(mutation, variables);
91
- return response.updateServiceReadyDeploy;
92
- }
93
- catch (error) {
94
- console.log(`Error in updateServiceReadyDeploy: ${error}`);
95
- throw error;
96
- }
97
- });
98
- }
99
- updateUrlPublic(serviceId, handleBy, urlPublic) {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- const mutation = mutations_1.UPDATE_URL_PUBLIC;
102
- const variables = {
103
- serviceId,
104
- handleBy,
105
- urlPublic
106
- };
107
- try {
108
- const response = yield this.graphqlMutationV2(mutation, variables);
109
- return response.updateUrlPublic;
110
- }
111
- catch (error) {
112
- console.log(`Error in updateUrlPublic: ${error}`);
113
- throw error;
114
- }
115
- });
116
- }
117
48
  getMailResource(serviceId) {
118
49
  return __awaiter(this, void 0, void 0, function* () {
119
50
  const query = queries_1.GET_MAIL_RESOURCE;
@@ -680,21 +611,5 @@ class CloudService extends serviceSDK_1.Service {
680
611
  }
681
612
  });
682
613
  }
683
- getElasticCloudResource(serviceId) {
684
- return __awaiter(this, void 0, void 0, function* () {
685
- const query = queries_1.GET_ELASTIC_CLOUD_RESOURCE;
686
- const variables = {
687
- serviceId,
688
- };
689
- try {
690
- const response = yield this.graphqlQueryV2(query, variables);
691
- return response.getElasticCloudResource;
692
- }
693
- catch (error) {
694
- console.log(`Error in getElasticCloudResource: ${error}`);
695
- throw error;
696
- }
697
- });
698
- }
699
614
  }
700
615
  exports.CloudService = CloudService;
@@ -61,5 +61,4 @@ export declare class ComputingService extends Service {
61
61
  updateCPU(computingId: string, socket: number, corePerSocket: number, updateBy: string): Promise<any>;
62
62
  updateRAM(computingId: string, size: number, unit: string, updateBy: string): Promise<any>;
63
63
  getComputingsDynamic(userId: string, fields: string[]): Promise<any>;
64
- createComputingForEC(createComputingInputForEC: any, createBy: string): Promise<any>;
65
64
  }
@@ -906,22 +906,5 @@ class ComputingService extends serviceSDK_1.Service {
906
906
  }
907
907
  });
908
908
  }
909
- createComputingForEC(createComputingInputForEC, createBy) {
910
- return __awaiter(this, void 0, void 0, function* () {
911
- const mutation = mutations_1.CREATE_COMPUTING_FOR_EC;
912
- const variables = {
913
- createComputingInputForEC,
914
- createBy,
915
- };
916
- try {
917
- const response = yield this.graphqlMutationV2(mutation, variables);
918
- return response.createComputingForEC;
919
- }
920
- catch (error) {
921
- console.log(`Error fetching get createComputingForEC method: ${error}`);
922
- throw error;
923
- }
924
- });
925
- }
926
909
  }
927
910
  exports.ComputingService = ComputingService;
@@ -28,10 +28,4 @@ export declare class CrmService extends Service {
28
28
  cloneResume(resumeOriginalId: string, domain: string, createdBy: string): Promise<any>;
29
29
  linkingResumeDomainAndContact(resumeDomainId: string, resumeContactId: string, contactType: string, linkedBy: string): Promise<any>;
30
30
  getResumeDomainByServiceId(serviceId: string): Promise<any>;
31
- getCollegesByProvinceId(provinceId: string | null): Promise<any>;
32
- getRelatedResourceByResourceType(fromId: string, fromResourceType: string, toResourceType: string): Promise<any>;
33
- addResourceRelated(fromId: string, fromResourceType: string, toIds: string[], toResourceType: string, createdBy: string): Promise<any>;
34
- getResumeInfoByCustomerId(customerId: string): Promise<any>;
35
- createResumeInfo(data: any): Promise<any>;
36
- updateFieldResume(resumeId: string, fieldName: string, value: string, resourceType: string, updatedBy: string): Promise<any>;
37
31
  }
@@ -457,112 +457,5 @@ class CrmService extends serviceSDK_1.Service {
457
457
  }
458
458
  });
459
459
  }
460
- getCollegesByProvinceId(provinceId) {
461
- return __awaiter(this, void 0, void 0, function* () {
462
- const query = queries_1.GET_COLLEGES_BY_PROVINCE_ID;
463
- const variables = {
464
- provinceId,
465
- };
466
- try {
467
- const response = yield this.graphqlQueryV2(query, variables);
468
- return response.getCollegesByProvinceId;
469
- }
470
- catch (error) {
471
- console.log(`Error in getCollegesByProvinceId: ${error}`);
472
- throw error;
473
- }
474
- });
475
- }
476
- getRelatedResourceByResourceType(fromId, fromResourceType, toResourceType) {
477
- return __awaiter(this, void 0, void 0, function* () {
478
- const query = queries_1.GET_RELATED_RESOURCE_BY_RESOURCE_TYPE;
479
- const variables = {
480
- fromId,
481
- fromResourceType,
482
- toResourceType,
483
- accessToken: this.token,
484
- partnerId: this.orgId,
485
- };
486
- try {
487
- const response = yield this.graphqlQueryV2(query, variables);
488
- return response.getRelatedResourceByResourceType;
489
- }
490
- catch (error) {
491
- console.log(`Error in getRelatedResourceByResourceType: ${error}`);
492
- throw error;
493
- }
494
- });
495
- }
496
- addResourceRelated(fromId, fromResourceType, toIds, toResourceType, createdBy) {
497
- return __awaiter(this, void 0, void 0, function* () {
498
- const mutation = mutations_1.ADD_RESOURCE_RELATED;
499
- const variables = {
500
- fromId,
501
- fromResourceType,
502
- toIds,
503
- toResourceType,
504
- createdBy,
505
- };
506
- try {
507
- const response = yield this.graphqlMutationV2(mutation, variables);
508
- return response.addResourceRelated;
509
- }
510
- catch (error) {
511
- console.log(`Error in addResourceRelated: ${error}`);
512
- throw error;
513
- }
514
- });
515
- }
516
- getResumeInfoByCustomerId(customerId) {
517
- return __awaiter(this, void 0, void 0, function* () {
518
- const query = queries_1.GET_RESUME_INFO_BY_CUSTOMER_ID;
519
- const variables = {
520
- customerId,
521
- orgId: this.orgId,
522
- };
523
- try {
524
- const response = yield this.graphqlQueryV2(query, variables);
525
- return response.getResumeInfoByCustomerId;
526
- }
527
- catch (error) {
528
- console.log(`Error in getResumeInfoByCustomerId: ${error}`);
529
- throw error;
530
- }
531
- });
532
- }
533
- createResumeInfo(data) {
534
- return __awaiter(this, void 0, void 0, function* () {
535
- const mutation = mutations_1.CREATE_RUSUME_INFO;
536
- const variables = Object.assign(Object.assign({}, data), { orgId: this.orgId });
537
- try {
538
- const response = yield this.graphqlMutationV2(mutation, variables);
539
- return response.createResumeInfo;
540
- }
541
- catch (error) {
542
- console.log(`Error in createResumeInfo: ${error}`);
543
- throw error;
544
- }
545
- });
546
- }
547
- updateFieldResume(resumeId, fieldName, value, resourceType, updatedBy) {
548
- return __awaiter(this, void 0, void 0, function* () {
549
- const mutation = mutations_1.UPDATE_FIELD_RESUME;
550
- const variables = {
551
- resumeId,
552
- fieldName,
553
- value,
554
- resourceType,
555
- updatedBy,
556
- };
557
- try {
558
- const response = yield this.graphqlMutationV2(mutation, variables);
559
- return response.updateFieldResume;
560
- }
561
- catch (error) {
562
- console.log(`Error in updateFieldResume: ${error}`);
563
- throw error;
564
- }
565
- });
566
- }
567
460
  }
568
461
  exports.CrmService = CrmService;
@@ -6,11 +6,11 @@ export declare class CrmCampingService extends Service {
6
6
  searchProductQuantityPromotionAction(productId: string): Promise<any>;
7
7
  addCustomerToVoucher(userId: string, voucherCode: string): Promise<any>;
8
8
  getCampaignActionById(campaignActionId: string): Promise<any>;
9
- suggestVoucher(customerId: string, scopeIgnore: string | null, scope: string | null, isNewCustomer: boolean): Promise<any>;
9
+ suggestVoucher(customerId: string, scope: string | null, isNewCustomer: boolean): Promise<any>;
10
10
  searchVouchers(campaignId: String, campaignActionId: String, campaignActionType: String, customerId: String, pageNumber: number, pageSize: number): Promise<any>;
11
11
  getAverageRating(targetIds: [string], customerId: string, evaluationType: string): Promise<any>;
12
12
  getUrlEvaluation(targetIds: [string], customerId: string, evaluationType: string): Promise<any>;
13
13
  getNumberOfTicketEvaluation(customerId: string): Promise<any>;
14
- searchProductGiftPromotionResponse(parameterSearchProductGift: any): Promise<any>;
14
+ searchProductGiftPromotionResponse(productId: string): Promise<any>;
15
15
  addProductGiftPromotion(orderId: string, updatedBy: string, addData: any): Promise<any>;
16
16
  }
@@ -89,7 +89,7 @@ class CrmCampingService extends serviceSDK_1.Service {
89
89
  // throw error;
90
90
  // }
91
91
  // }
92
- suggestVoucher(customerId, scopeIgnore, scope, isNewCustomer) {
92
+ suggestVoucher(customerId, scope, isNewCustomer) {
93
93
  return __awaiter(this, void 0, void 0, function* () {
94
94
  const query = queries_1.SUGGEST_VOUCHER;
95
95
  const variables = {
@@ -97,8 +97,7 @@ class CrmCampingService extends serviceSDK_1.Service {
97
97
  excludeExpired: true,
98
98
  customerId,
99
99
  scope,
100
- isNewCustomer,
101
- scopeIgnore,
100
+ isNewCustomer
102
101
  };
103
102
  try {
104
103
  const response = yield this.graphqlQueryV2(query, variables);
@@ -138,7 +137,7 @@ class CrmCampingService extends serviceSDK_1.Service {
138
137
  targetIds,
139
138
  customerId,
140
139
  evaluationType,
141
- orgId: this.orgId,
140
+ orgId: this.orgId
142
141
  };
143
142
  try {
144
143
  const response = yield this.graphqlQueryV2(query, variables);
@@ -157,7 +156,7 @@ class CrmCampingService extends serviceSDK_1.Service {
157
156
  targetIds,
158
157
  customerId,
159
158
  evaluationType,
160
- orgId: this.orgId,
159
+ orgId: this.orgId
161
160
  };
162
161
  try {
163
162
  const response = yield this.graphqlQueryV2(query, variables);
@@ -174,7 +173,7 @@ class CrmCampingService extends serviceSDK_1.Service {
174
173
  const query = queries_1.GET_NUMBER_OF_TICKET_EVALUATION;
175
174
  const variables = {
176
175
  customerId,
177
- orgId: this.orgId,
176
+ orgId: this.orgId
178
177
  };
179
178
  try {
180
179
  const response = yield this.graphqlQueryV2(query, variables);
@@ -186,17 +185,13 @@ class CrmCampingService extends serviceSDK_1.Service {
186
185
  }
187
186
  });
188
187
  }
189
- searchProductGiftPromotionResponse(parameterSearchProductGift) {
188
+ searchProductGiftPromotionResponse(productId) {
190
189
  return __awaiter(this, void 0, void 0, function* () {
191
- // console.log("🚀 ~ CrmCampingService ~ searchProductGiftPromotionResponse ~ parameterSearchProductGift:", parameterSearchProductGift)
192
190
  const query = queries_1.SEARCH_PRODUCT_GIFT_PROMOTION_RESPONSE;
193
191
  const variables = {
194
- parameterSearchProductGift: Object.assign({ partyId: this.orgId }, parameterSearchProductGift),
192
+ partyId: this.orgId,
193
+ productId
195
194
  };
196
- // console.log(
197
- // "🚀 ~ CrmCampingService ~ searchProductGiftPromotionResponse ~ variables:",
198
- // variables
199
- // );
200
195
  try {
201
196
  const response = yield this.graphqlQueryV2(query, variables);
202
197
  return response.searchProductGiftPromotionResponse;
@@ -5,7 +5,6 @@ export declare class OrderGraphQLService extends Service {
5
5
  setStoreId(storeId: string): void;
6
6
  createOrder(input: any): Promise<any>;
7
7
  getOrderDetail(orderId: string): Promise<any>;
8
- getOrderDetailDynamic(orderId: string, fields: string[]): Promise<any>;
9
8
  getQuantityOrderLineItems(orderId: string): Promise<any>;
10
9
  updateQuantityV2(payload: any): Promise<any>;
11
10
  getOrderLineItemByServiceId(serviceId: string): Promise<any>;
@@ -55,22 +55,6 @@ class OrderGraphQLService extends serviceSDK_1.Service {
55
55
  }
56
56
  });
57
57
  }
58
- getOrderDetailDynamic(orderId, fields) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- const query = (0, queries_1.GET_ORDER_DETAIL_DYNAMIC)(fields);
61
- const variables = {
62
- orderId,
63
- };
64
- try {
65
- const response = yield this.graphqlQueryV2(query, variables);
66
- return response.orderDetail;
67
- }
68
- catch (error) {
69
- console.log(`Error in orderDetailDynamic: ${error}`);
70
- throw error;
71
- }
72
- });
73
- }
74
58
  getQuantityOrderLineItems(orderId) {
75
59
  return __awaiter(this, void 0, void 0, function* () {
76
60
  const query = queries_1.GET_QUANTITY_ORDER_LINEITEMS;
@@ -43,12 +43,10 @@ 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>;
47
46
  getRelatedInfor(id: string): Promise<any>;
48
47
  getDetailStores(storeId: string): Promise<any>;
49
48
  getListPrice(productIds: string[], storeId: string): Promise<any>;
50
49
  getTags(storeId: string): Promise<any>;
51
50
  getTagsByCategory(categoryId: string, storeId: string): Promise<any>;
52
51
  getListProductConfigDynamic(productId: string, store: string, fields: string[]): Promise<any>;
53
- getCategories(): Promise<any>;
54
52
  }
@@ -231,24 +231,6 @@ 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
- }
252
234
  getRelatedInfor(id) {
253
235
  return __awaiter(this, void 0, void 0, function* () {
254
236
  const query = queries_1.GET_RELATED_INFOR;
@@ -353,21 +335,5 @@ class ProductService extends serviceSDK_1.Service {
353
335
  }
354
336
  });
355
337
  }
356
- getCategories() {
357
- return __awaiter(this, void 0, void 0, function* () {
358
- const query = queries_1.GET_CATEGORIES;
359
- const variables = {
360
- partnerId: this.orgId,
361
- storeChannel: this.storeId,
362
- };
363
- try {
364
- const response = yield this.graphqlQuery(query, variables);
365
- return response.getCategories;
366
- }
367
- catch (error) {
368
- throw error;
369
- }
370
- });
371
- }
372
338
  }
373
339
  exports.ProductService = ProductService;
@@ -3,7 +3,7 @@ export declare class ResourcePermissionService extends Service {
3
3
  constructor(endpoint: string, orgId: string, storeId: string);
4
4
  setToken(token: string): void;
5
5
  setStoreId(storeId: string): void;
6
- shareResource(createModel: any, partnerId: string): Promise<any>;
7
- removeShareParty(resourceId: string, sharePartyId: string, resourceType: string, partnerId: string): Promise<any>;
6
+ shareResource(createModel: any): Promise<any>;
7
+ removeShareParty(resourceId: string, sharePartyId: string, resourceType: string): Promise<any>;
8
8
  getSharedUserByService(resourceType: string, resourceId: string): Promise<any>;
9
9
  }
@@ -23,11 +23,11 @@ class ResourcePermissionService extends serviceSDK_1.Service {
23
23
  setStoreId(storeId) {
24
24
  this.storeId = storeId;
25
25
  }
26
- shareResource(createModel, partnerId) {
26
+ shareResource(createModel) {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
28
  const mutation = mutations_1.SHARE_RESOURCE;
29
29
  const variables = {
30
- partnerId: partnerId,
30
+ partnerId: this.orgId,
31
31
  createModel,
32
32
  };
33
33
  try {
@@ -40,11 +40,11 @@ class ResourcePermissionService extends serviceSDK_1.Service {
40
40
  }
41
41
  });
42
42
  }
43
- removeShareParty(resourceId, sharePartyId, resourceType, partnerId) {
43
+ removeShareParty(resourceId, sharePartyId, resourceType) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
45
  const mutation = mutations_1.REMOVE_SHARE_PARTY;
46
46
  const variables = {
47
- partnerId: partnerId,
47
+ partnerId: this.orgId,
48
48
  orgId: this.orgId,
49
49
  resourceType,
50
50
  resourceId,
@@ -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.4",
3
+ "version": "1.16.6",
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;