@longvansoftware/service-js-client 2.3.7 → 2.3.8

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.
@@ -30,8 +30,8 @@ const GET_LIST_BUCKET_BY_S3_USER_ID = (fields = []) => {
30
30
  const fieldStr = fields.join('\n ');
31
31
  const hasFields = fields.length > 0;
32
32
  return (0, graphql_tag_1.gql) `
33
- query GetListBucketByS3UserId($s3UserId: String!) {
34
- getListBucketByS3UserId(s3UserId: $s3UserId) {
33
+ query GetListBucketByS3UserId($s3UserId: String!, $serviceId: String!) {
34
+ getListBucketByS3UserId(s3UserId: $s3UserId, serviceId: $serviceId) {
35
35
  ${hasFields ? `${fieldStr}` : ''}
36
36
  }
37
37
  }
@@ -42,8 +42,8 @@ const GET_LIST_OBJECT = (fields = []) => {
42
42
  const fieldStr = fields.join('\n ');
43
43
  const hasFields = fields.length > 0;
44
44
  return (0, graphql_tag_1.gql) `
45
- query GetListObject($s3UserId: String!, $bucketId: String!, $key: String!) {
46
- getListObject(s3UserId: $s3UserId, bucketId: $bucketId, key: $key) {
45
+ query GetListObject($s3UserId: String!, $bucketId: String!, $key: String!, $serviceId: String!) {
46
+ getListObject(s3UserId: $s3UserId, bucketId: $bucketId, key: $key, serviceId: $serviceId) {
47
47
  ${hasFields ? `${fieldStr}` : ''}
48
48
  }
49
49
  }
@@ -54,8 +54,8 @@ const GET_LIST_FILE_TRASH = (fields = []) => {
54
54
  const fieldStr = fields.join('\n ');
55
55
  const hasFields = fields.length > 0;
56
56
  return (0, graphql_tag_1.gql) `
57
- query GetListFileTrash($s3UserId: String!, $bucketId: String!) {
58
- getListFileTrash(s3UserId: $s3UserId, bucketId: $bucketId) {
57
+ query GetListFileTrash($s3UserId: String!, $bucketId: String!, $serviceId: String!) {
58
+ getListFileTrash(s3UserId: $s3UserId, bucketId: $bucketId, serviceId: $serviceId) {
59
59
  ${hasFields ? `${fieldStr}` : ''}
60
60
  }
61
61
  }
@@ -66,8 +66,8 @@ const GET_LIST_S3_DOMAIN_BY_S3_USER_ID = (fields = []) => {
66
66
  const fieldStr = fields.join('\n ');
67
67
  const hasFields = fields.length > 0;
68
68
  return (0, graphql_tag_1.gql) `
69
- query GetListS3DomainByS3UserId($s3UserId: String!) {
70
- getListS3DomainByS3UserId(s3UserId: $s3UserId) {
69
+ query GetListS3DomainByS3UserId($s3UserId: String!, $serviceId: String!) {
70
+ getListS3DomainByS3UserId(s3UserId: $s3UserId, serviceId: $serviceId) {
71
71
  ${hasFields ? `${fieldStr}` : ''}
72
72
  }
73
73
  }
@@ -78,8 +78,8 @@ const GET_LIST_CORS_BY_S3_USER_ID = (fields = []) => {
78
78
  const fieldStr = fields.join('\n ');
79
79
  const hasFields = fields.length > 0;
80
80
  return (0, graphql_tag_1.gql) `
81
- query GetListCorsByS3UserId($s3UserId: String!, $bucketId: String!) {
82
- getListCorsByS3UserId(s3UserId: $s3UserId, bucketId: $bucketId) {
81
+ query GetListCorsByS3UserId($s3UserId: String!, $bucketId: String!, $serviceId: String!) {
82
+ getListCorsByS3UserId(s3UserId: $s3UserId, bucketId: $bucketId, serviceId: $serviceId) {
83
83
  ${hasFields ? `${fieldStr}` : ''}
84
84
  }
85
85
  }
@@ -90,8 +90,8 @@ const GET_LIST_FILE_OTHER_VERSION = (fields = []) => {
90
90
  const fieldStr = fields.join('\n ');
91
91
  const hasFields = fields.length > 0;
92
92
  return (0, graphql_tag_1.gql) `
93
- query GetListFileOtherVersion($s3UserId: String!, $bucketId: String!, $key: String) {
94
- getListFileOtherVersion(s3UserId: $s3UserId, bucketId: $bucketId, key: $key) {
93
+ query GetListFileOtherVersion($s3UserId: String!, $bucketId: String!, $key: String, $serviceId: String!) {
94
+ getListFileOtherVersion(s3UserId: $s3UserId, bucketId: $bucketId, key: $key, serviceId: $serviceId) {
95
95
  ${hasFields ? `${fieldStr}` : ''}
96
96
  }
97
97
  }
@@ -102,8 +102,8 @@ const CHART_IN_YEAR = (fields = []) => {
102
102
  const fieldStr = fields.join('\n ');
103
103
  const hasFields = fields.length > 0;
104
104
  return (0, graphql_tag_1.gql) `
105
- query ChartInYear($s3UserId: String!, $year: Int!, $month: Int!) {
106
- chartInYear(s3UserId: $s3UserId, year: $year, month: $month) {
105
+ query ChartInYear($s3UserId: String!, $year: Int!, $month: Int!, $serviceId: String!) {
106
+ chartInYear(s3UserId: $s3UserId, year: $year, month: $month, serviceId: $serviceId) {
107
107
  ${hasFields ? `${fieldStr}` : ''}
108
108
  }
109
109
  }
@@ -111,16 +111,16 @@ const CHART_IN_YEAR = (fields = []) => {
111
111
  };
112
112
  exports.CHART_IN_YEAR = CHART_IN_YEAR;
113
113
  exports.GET_IP_CONSUL = (0, graphql_tag_1.gql) `
114
- query GetIPConsul($userId: String!) {
115
- getIPConsul(userId: $userId)
114
+ query GetIPConsul($userId: String!, $serviceId: String!) {
115
+ getIPConsul(userId: $userId, serviceId: $serviceId)
116
116
  }
117
117
  `;
118
118
  const FILTER_LIST_OBJECT = (fields = []) => {
119
119
  const fieldStr = fields.join('\n ');
120
120
  const hasFields = fields.length > 0;
121
121
  return (0, graphql_tag_1.gql) `
122
- query FilterListObject($s3UserId: String!, $bucketId: String!, $maxKeys: Int!, $key: String, $prefixSearch: String, $continuationToken: String) {
123
- filterListObject(s3UserId: $s3UserId, bucketId: $bucketId, maxKeys: $maxKeys, key: $key, prefixSearch: $prefixSearch, continuationToken: $continuationToken){
122
+ query FilterListObject($s3UserId: String!, $bucketId: String!, $maxKeys: Int!, $key: String, $prefixSearch: String, $continuationToken: String, $serviceId: String!) {
123
+ filterListObject(s3UserId: $s3UserId, bucketId: $bucketId, maxKeys: $maxKeys, key: $key, prefixSearch: $prefixSearch, continuationToken: $continuationToken, serviceId: $serviceId){
124
124
  ${hasFields ? `${fieldStr}` : ''}
125
125
  }
126
126
  }
@@ -10,16 +10,16 @@ export declare class ComputingService extends Service {
10
10
  constructor(endpoint: string, orgId: string, storeId: string);
11
11
  setToken(token: string): void;
12
12
  setStoreId(storeId: string): void;
13
- computingDetail(computingId: string): Promise<any>;
14
- portNats(computingId: string): Promise<any>;
15
- restartVM(computingId: string, actor: string): Promise<any>;
13
+ computingDetail(computingId: string, serviceId: string): Promise<any>;
14
+ portNats(computingId: string, serviceId: string): Promise<any>;
15
+ restartVM(computingId: string, actor: string, serviceId: string): Promise<any>;
16
16
  updateDescriptionPortNat(payload: UpdateDescriptionPortNat, updateBy: string): Promise<any>;
17
17
  createPortNat(payload: CreatePortNat, createBy: string): Promise<any>;
18
18
  updatePortNat(payload: CreatePortNat, updateBy: string): Promise<any>;
19
19
  removePortNat(portNatId: string, updateBy: string): Promise<any>;
20
- startVM(computingId: string, actor: string): Promise<any>;
21
- stopVM(computingId: string, actor: string): Promise<any>;
22
- snapshots(computingId: string): Promise<any>;
20
+ startVM(computingId: string, actor: string, serviceId: string): Promise<any>;
21
+ stopVM(computingId: string, actor: string, serviceId: string): Promise<any>;
22
+ snapshots(computingId: string, serviceId: string): Promise<any>;
23
23
  createSnapshot(payload: CreateSnapShot, createBy: string): Promise<any>;
24
24
  rollbackSnapshot(payload: RollBackSnapShot, createBy: string): Promise<any>;
25
25
  deleteSnapshot(payload: RollBackSnapShot, updateBy: string): Promise<any>;
@@ -41,25 +41,25 @@ export declare class ComputingService extends Service {
41
41
  getCluster(clusterId: string): Promise<any>;
42
42
  getComputingByCluster(clusterId: string): Promise<any>;
43
43
  getComputingByService(serviceId: string): Promise<any>;
44
- stopUseComputing(computingId: string, userId: string): Promise<any>;
44
+ stopUseComputing(computingId: string, userId: string, serviceId: string): Promise<any>;
45
45
  getEdges(serviceId: string): Promise<any>;
46
46
  addPortNat(data: any): Promise<any>;
47
47
  getPortNatsByServiceId(serviceId: any): Promise<any>;
48
- updateDescriptionComputing(computingId: string, description: string, updateBy: string): Promise<any>;
48
+ updateDescriptionComputing(computingId: string, description: string, updateBy: string, serviceId: string): Promise<any>;
49
49
  getTemplates(): Promise<any>;
50
50
  getAvailableSubnetIPsByResourcePoolId(resourcePoolId: string): Promise<any>;
51
51
  getAvailableStoragesForDC(resourcePoolId: string): Promise<any>;
52
52
  getResourcePoolsByService(serviceId: string): Promise<any>;
53
53
  createComputingForDC(data: any, createBy: string): Promise<any>;
54
- updateNameComputing(computingId: string, name: string, updateBy: string): Promise<any>;
54
+ updateNameComputing(computingId: string, name: string, updateBy: string, serviceId: string): Promise<any>;
55
55
  getConsole(computingId: string): Promise<any>;
56
56
  getComputingWaitRevoke(serviceId: string, fields: string[]): Promise<any>;
57
- computingWaitingRevoke(computingId: string, userId: string, fields: string[]): Promise<any>;
58
- restoreComputingWaitingRevoke(computingId: string, userId: string, fields: string[]): Promise<any>;
59
- deleteComputing(computingId: string, userId: string, fields: string[]): Promise<any>;
57
+ computingWaitingRevoke(computingId: string, userId: string, serviceId: string, fields: string[]): Promise<any>;
58
+ restoreComputingWaitingRevoke(computingId: string, userId: string, serviceId: string, fields: string[]): Promise<any>;
59
+ deleteComputing(computingId: string, userId: string, serviceId: string, fields: string[]): Promise<any>;
60
60
  getStorageMappingForDC(resourcePoolId: string): Promise<any>;
61
- updateCPU(computingId: string, socket: number, corePerSocket: number, updateBy: string): Promise<any>;
62
- updateRAM(computingId: string, size: number, unit: string, updateBy: string): Promise<any>;
61
+ updateCPU(computingId: string, socket: number, corePerSocket: number, updateBy: string, serviceId: string): Promise<any>;
62
+ updateRAM(computingId: string, size: number, unit: string, updateBy: string, serviceId: string): Promise<any>;
63
63
  getComputingsDynamic(userId: string, fields: string[]): Promise<any>;
64
64
  createComputingForEC(createComputingInputForEC: any, createBy: string): Promise<any>;
65
65
  }
@@ -29,11 +29,12 @@ class ComputingService extends serviceSDK_1.Service {
29
29
  setStoreId(storeId) {
30
30
  this.storeId = storeId;
31
31
  }
32
- computingDetail(computingId) {
32
+ computingDetail(computingId, serviceId) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
34
  const query = queries_1.COMPUTING_DETAIL;
35
35
  const variables = {
36
36
  computingId,
37
+ serviceId
37
38
  };
38
39
  try {
39
40
  const response = yield this.graphqlQueryV2(query, variables);
@@ -45,11 +46,12 @@ class ComputingService extends serviceSDK_1.Service {
45
46
  }
46
47
  });
47
48
  }
48
- portNats(computingId) {
49
+ portNats(computingId, serviceId) {
49
50
  return __awaiter(this, void 0, void 0, function* () {
50
51
  const query = queries_1.PORTNATS;
51
52
  const variables = {
52
53
  computingId,
54
+ serviceId
53
55
  };
54
56
  try {
55
57
  const response = yield this.graphqlQueryV2(query, variables);
@@ -61,12 +63,13 @@ class ComputingService extends serviceSDK_1.Service {
61
63
  }
62
64
  });
63
65
  }
64
- restartVM(computingId, actor) {
66
+ restartVM(computingId, actor, serviceId) {
65
67
  return __awaiter(this, void 0, void 0, function* () {
66
68
  const mutation = mutations_1.RESTARTVM;
67
69
  const variables = {
68
70
  computingId,
69
71
  actor,
72
+ serviceId
70
73
  };
71
74
  try {
72
75
  const response = yield this.graphqlMutationV2(mutation, variables);
@@ -149,12 +152,13 @@ class ComputingService extends serviceSDK_1.Service {
149
152
  }
150
153
  });
151
154
  }
152
- startVM(computingId, actor) {
155
+ startVM(computingId, actor, serviceId) {
153
156
  return __awaiter(this, void 0, void 0, function* () {
154
157
  const mutation = mutations_1.POWER_ON;
155
158
  const variables = {
156
159
  computingId,
157
160
  actor,
161
+ serviceId
158
162
  };
159
163
  try {
160
164
  const response = yield this.graphqlMutationV2(mutation, variables);
@@ -166,12 +170,13 @@ class ComputingService extends serviceSDK_1.Service {
166
170
  }
167
171
  });
168
172
  }
169
- stopVM(computingId, actor) {
173
+ stopVM(computingId, actor, serviceId) {
170
174
  return __awaiter(this, void 0, void 0, function* () {
171
175
  const mutation = mutations_1.POWER_OFF;
172
176
  const variables = {
173
177
  computingId,
174
178
  actor,
179
+ serviceId
175
180
  };
176
181
  try {
177
182
  const response = yield this.graphqlMutationV2(mutation, variables);
@@ -183,11 +188,12 @@ class ComputingService extends serviceSDK_1.Service {
183
188
  }
184
189
  });
185
190
  }
186
- snapshots(computingId) {
191
+ snapshots(computingId, serviceId) {
187
192
  return __awaiter(this, void 0, void 0, function* () {
188
193
  const query = queries_1.SNAP_SHOTS;
189
194
  const variables = {
190
195
  computingId,
196
+ serviceId
191
197
  };
192
198
  try {
193
199
  const response = yield this.graphqlQueryV2(query, variables);
@@ -205,6 +211,7 @@ class ComputingService extends serviceSDK_1.Service {
205
211
  const variables = {
206
212
  computingId: payload.computingId,
207
213
  snapshotName: payload.snapshotName,
214
+ serviceId: payload.serviceId,
208
215
  createBy,
209
216
  };
210
217
  try {
@@ -223,6 +230,7 @@ class ComputingService extends serviceSDK_1.Service {
223
230
  const variables = {
224
231
  computingId: payload.computingId,
225
232
  snapshotId: payload.snapshotId,
233
+ serviceId: payload.serviceId,
226
234
  createBy,
227
235
  };
228
236
  try {
@@ -241,6 +249,7 @@ class ComputingService extends serviceSDK_1.Service {
241
249
  const variables = {
242
250
  computingId: payload.computingId,
243
251
  snapshotId: payload.snapshotId,
252
+ serviceId: payload.serviceId,
244
253
  updateBy,
245
254
  };
246
255
  try {
@@ -566,12 +575,13 @@ class ComputingService extends serviceSDK_1.Service {
566
575
  }
567
576
  });
568
577
  }
569
- stopUseComputing(computingId, userId) {
578
+ stopUseComputing(computingId, userId, serviceId) {
570
579
  return __awaiter(this, void 0, void 0, function* () {
571
580
  const mutation = mutations_1.STOP_USE_COMPUTING;
572
581
  const variables = {
573
582
  computingId,
574
583
  userId,
584
+ serviceId,
575
585
  };
576
586
  try {
577
587
  const response = yield this.graphqlMutationV2(mutation, variables);
@@ -629,13 +639,14 @@ class ComputingService extends serviceSDK_1.Service {
629
639
  }
630
640
  });
631
641
  }
632
- updateDescriptionComputing(computingId, description, updateBy) {
642
+ updateDescriptionComputing(computingId, description, updateBy, serviceId) {
633
643
  return __awaiter(this, void 0, void 0, function* () {
634
644
  const query = mutations_1.UPDATE_DESCRIPTION_COMPUTING;
635
645
  const variables = {
636
646
  computingId,
637
647
  description,
638
648
  updateBy,
649
+ serviceId
639
650
  };
640
651
  try {
641
652
  const response = yield this.graphqlMutationV2(query, variables);
@@ -735,13 +746,14 @@ class ComputingService extends serviceSDK_1.Service {
735
746
  }
736
747
  });
737
748
  }
738
- updateNameComputing(computingId, name, updateBy) {
749
+ updateNameComputing(computingId, name, updateBy, serviceId) {
739
750
  return __awaiter(this, void 0, void 0, function* () {
740
751
  const mutation = mutations_1.UPDATE_NAME_COMPUTING;
741
752
  const variables = {
742
753
  computingId,
743
754
  name,
744
755
  updateBy,
756
+ serviceId
745
757
  };
746
758
  try {
747
759
  const response = yield this.graphqlMutationV2(mutation, variables);
@@ -785,12 +797,13 @@ class ComputingService extends serviceSDK_1.Service {
785
797
  }
786
798
  });
787
799
  }
788
- computingWaitingRevoke(computingId, userId, fields) {
800
+ computingWaitingRevoke(computingId, userId, serviceId, fields) {
789
801
  return __awaiter(this, void 0, void 0, function* () {
790
802
  const query = (0, mutations_1.COMPUTING_WAITING_REVOKE)(fields);
791
803
  const variables = {
792
804
  computingId,
793
805
  userId,
806
+ serviceId
794
807
  };
795
808
  try {
796
809
  const response = yield this.graphqlMutationV2(query, variables);
@@ -802,12 +815,13 @@ class ComputingService extends serviceSDK_1.Service {
802
815
  }
803
816
  });
804
817
  }
805
- restoreComputingWaitingRevoke(computingId, userId, fields) {
818
+ restoreComputingWaitingRevoke(computingId, userId, serviceId, fields) {
806
819
  return __awaiter(this, void 0, void 0, function* () {
807
820
  const query = (0, mutations_1.RESTORE_COMPUTING_WAITING_REVOKE)(fields);
808
821
  const variables = {
809
822
  computingId,
810
823
  userId,
824
+ serviceId
811
825
  };
812
826
  try {
813
827
  const response = yield this.graphqlMutationV2(query, variables);
@@ -819,12 +833,13 @@ class ComputingService extends serviceSDK_1.Service {
819
833
  }
820
834
  });
821
835
  }
822
- deleteComputing(computingId, userId, fields) {
836
+ deleteComputing(computingId, userId, serviceId, fields) {
823
837
  return __awaiter(this, void 0, void 0, function* () {
824
838
  const query = (0, mutations_1.DELETE_COMPUTING)(fields);
825
839
  const variables = {
826
840
  computingId,
827
841
  userId,
842
+ serviceId
828
843
  };
829
844
  try {
830
845
  const response = yield this.graphqlMutationV2(query, variables);
@@ -852,7 +867,7 @@ class ComputingService extends serviceSDK_1.Service {
852
867
  }
853
868
  });
854
869
  }
855
- updateCPU(computingId, socket, corePerSocket, updateBy) {
870
+ updateCPU(computingId, socket, corePerSocket, updateBy, serviceId) {
856
871
  return __awaiter(this, void 0, void 0, function* () {
857
872
  const mutation = mutations_1.UPDATE_CPU;
858
873
  const variables = {
@@ -860,6 +875,7 @@ class ComputingService extends serviceSDK_1.Service {
860
875
  socket,
861
876
  corePerSocket,
862
877
  updateBy,
878
+ serviceId
863
879
  };
864
880
  try {
865
881
  const response = yield this.graphqlMutationV2(mutation, variables);
@@ -871,7 +887,7 @@ class ComputingService extends serviceSDK_1.Service {
871
887
  }
872
888
  });
873
889
  }
874
- updateRAM(computingId, size, unit, updateBy) {
890
+ updateRAM(computingId, size, unit, updateBy, serviceId) {
875
891
  return __awaiter(this, void 0, void 0, function* () {
876
892
  const mutation = mutations_1.UPDATE_RAM;
877
893
  const variables = {
@@ -879,6 +895,7 @@ class ComputingService extends serviceSDK_1.Service {
879
895
  size,
880
896
  unit,
881
897
  updateBy,
898
+ serviceId
882
899
  };
883
900
  try {
884
901
  const response = yield this.graphqlMutationV2(mutation, variables);
@@ -56,4 +56,5 @@ export declare class ProductService extends Service {
56
56
  getSimpleProductsDynamic(variables: any, storeId: string, fields: string[]): Promise<any>;
57
57
  getProductRelatedToArticle(articleId: string, storeId: string, fields: string[]): Promise<any>;
58
58
  getProductFeatureTypesDynamic(productId: string, storeId: string, fields: string[]): Promise<any>;
59
+ getProductSimpleByHandle(handle: string, store: string, fields: string[]): Promise<any>;
59
60
  }
@@ -455,5 +455,23 @@ class ProductService extends serviceSDK_1.Service {
455
455
  }
456
456
  });
457
457
  }
458
+ getProductSimpleByHandle(handle, store, fields) {
459
+ return __awaiter(this, void 0, void 0, function* () {
460
+ const query = (0, queries_1.GET_PRODUCT_SIMPLE_BY_HANDLE_DYNAMIC)(fields);
461
+ const variablesHandle = {
462
+ partnerId: this.orgId,
463
+ storeChannel: store ? store : this.storeId,
464
+ handle,
465
+ };
466
+ try {
467
+ const response = yield this.graphqlQueryV2(query, variablesHandle);
468
+ return response.getProductSimpleByHandle;
469
+ }
470
+ catch (error) {
471
+ console.log(`Error fetching getProductSimpleByHandle : ${error}`);
472
+ throw error;
473
+ }
474
+ });
475
+ }
458
476
  }
459
477
  exports.ProductService = ProductService;
@@ -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;
@@ -4,39 +4,39 @@ export declare class StorageS3Service extends Service {
4
4
  constructor(endpoint: string, orgId: string, storeId: string);
5
5
  getListS3UserByServiceId(serviceId: string, fields: string[]): Promise<any>;
6
6
  getListS3UserActiveByServiceId(serviceId: string, fields: string[]): Promise<any>;
7
- getListBucketByS3UserId(s3UserId: string, fields: string[]): Promise<any>;
8
- getListObject(s3UserId: string, bucketId: string, key: string, fields: string[]): Promise<any>;
9
- uploadFolder(userId: string, bucketId: string, fileInfo: [FileInfoInput], basePrefix: string, fields: string[]): Promise<any>;
7
+ getListBucketByS3UserId(s3UserId: string, serviceId: string, fields: string[]): Promise<any>;
8
+ getListObject(s3UserId: string, bucketId: string, key: string, serviceId: string, fields: string[]): Promise<any>;
9
+ uploadFolder(userId: string, bucketId: string, fileInfo: [FileInfoInput], basePrefix: string, serviceId: string, fields: string[]): Promise<any>;
10
10
  uploadFile(s3UserId: string, bucketId: string, key: string, fields: string[]): Promise<any>;
11
- updateAclPermissionFile(s3UserId: string, bucketId: string, key: string, isPublic: boolean, fields: string[]): Promise<any>;
12
- renameFile(s3UserId: string, bucketId: string, key: string, fileNewName: boolean, fields: string[]): Promise<any>;
13
- shareLinkFileByTime(s3UserId: string, bucketId: string, key: string, quantityHour: number): Promise<any>;
14
- copyFile(s3UserId: string, bucketId: string, srcFileKey: string, dstFileKey: string, fields: string[]): Promise<any>;
15
- moveFile(s3UserId: string, bucketId: string, srcFileKey: string, dstFileKey: string, fields: string[]): Promise<any>;
16
- removeFile(s3UserId: string, bucketId: string, keys: string[], fields: string[]): Promise<any>;
17
- createFolder(s3UserId: string, bucketId: string, folderName: string, key: string, fields: string[]): Promise<any>;
18
- removeFolder(s3UserId: string, bucketId: string, key: string, fields: string[]): Promise<any>;
19
- createBucket(s3UserId: string, bucketName: string, internalId: string, randomInternalId: boolean, enableObjectLock: boolean, enableBucketVersioning: boolean, byUser: string, fields: string[]): Promise<any>;
20
- renameBucket(bucketId: string, bucketName: string, updateBy: string, fields: string[]): Promise<any>;
21
- deleteBucket(bucketId: string, updateBy: string, fields: string[]): Promise<any>;
22
- updateAclPermissionBucket(s3UserId: string, bucketId: string, isPublic: boolean, updateBy: string, fields: string[]): Promise<any>;
23
- updateBucketVersioning(s3UserId: string, bucketId: string, isOn: boolean, updateBy: string, fields: string[]): Promise<any>;
24
- getListFileTrash(s3UserId: string, bucketId: string, fields: string[]): Promise<any>;
25
- restoreFileTrash(s3UserId: string, bucketId: string, key: string, versionId: string, fields: string[]): Promise<any>;
26
- removeFileTrash(s3UserId: string, bucketId: string, files: [FileTrashInput], fields: string[]): Promise<any>;
27
- getListS3DomainByS3UserId(s3UserId: string, fields: string[]): Promise<any>;
28
- addS3Domain(s3UserId: string, domain: string, byUser: string, fields: string[]): Promise<any>;
29
- removeS3Domain(s3UserId: string, domainId: string, byUser: string, fields: string[]): Promise<any>;
30
- getListCorsByS3UserId(s3UserId: string, bucketId: string, fields: string[]): Promise<any>;
31
- addCorsBucket(s3UserId: string, bucketId: string, allowedMethods: string[], allowedOrigins: string[], allowedHeaders: string[], exposeHeaders: string[], maxAgeSeconds: number, updateBy: string, fields: string[]): Promise<any>;
32
- updateCorsBucket(bucketId: string, corsId: string, allowedMethods: string[], allowedOrigins: string[], allowedHeaders: string[], exposeHeaders: string[], maxAgeSeconds: number, updateBy: string, fields: string[]): Promise<any>;
33
- removeCorsBucket(bucketId: string, corsId: string, updateBy: string, fields: string[]): Promise<any>;
34
- getListFileOtherVersion(s3UserId: string, bucketId: string, key: string, fields: string[]): Promise<any>;
35
- restoreFileOtherVersion(s3UserId: string, bucketId: string, key: string, versionId: string, fields: string[]): Promise<any>;
36
- removeFileOtherVersion(s3UserId: string, bucketId: string, key: string, versionId: string, fields: string[]): Promise<any>;
37
- resetKey(s3UserId: string, updateBy: string, fields: string[]): Promise<any>;
38
- actionSyncUserFromS3(s3UserId: string, updateBy: string, fields: string[]): Promise<any>;
39
- chartInYear(s3UserId: string, year: number, month: number, fields: string[]): Promise<any>;
40
- getIPConsul(userId: string): Promise<any>;
41
- filterListObject(s3UserId: string, bucketId: string, maxKeys: number, key: string, prefixSearch: string, continuationToken: string, fields: string[]): Promise<any>;
11
+ updateAclPermissionFile(s3UserId: string, bucketId: string, key: string, isPublic: boolean, serviceId: string, fields: string[]): Promise<any>;
12
+ renameFile(s3UserId: string, bucketId: string, key: string, fileNewName: boolean, serviceId: string, fields: string[]): Promise<any>;
13
+ shareLinkFileByTime(s3UserId: string, bucketId: string, key: string, quantityHour: number, serviceId: string): Promise<any>;
14
+ copyFile(s3UserId: string, bucketId: string, srcFileKey: string, dstFileKey: string, serviceId: string, fields: string[]): Promise<any>;
15
+ moveFile(s3UserId: string, bucketId: string, srcFileKey: string, dstFileKey: string, serviceId: string, fields: string[]): Promise<any>;
16
+ removeFile(s3UserId: string, bucketId: string, keys: string[], serviceId: string, fields: string[]): Promise<any>;
17
+ createFolder(s3UserId: string, bucketId: string, folderName: string, key: string, serviceId: string, fields: string[]): Promise<any>;
18
+ removeFolder(s3UserId: string, bucketId: string, key: string, serviceId: string, fields: string[]): Promise<any>;
19
+ createBucket(s3UserId: string, bucketName: string, internalId: string, randomInternalId: boolean, enableObjectLock: boolean, enableBucketVersioning: boolean, byUser: string, serviceId: string, fields: string[]): Promise<any>;
20
+ renameBucket(bucketId: string, bucketName: string, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
21
+ deleteBucket(bucketId: string, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
22
+ updateAclPermissionBucket(s3UserId: string, bucketId: string, isPublic: boolean, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
23
+ updateBucketVersioning(s3UserId: string, bucketId: string, isOn: boolean, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
24
+ getListFileTrash(s3UserId: string, bucketId: string, serviceId: string, fields: string[]): Promise<any>;
25
+ restoreFileTrash(s3UserId: string, bucketId: string, key: string, versionId: string, serviceId: string, fields: string[]): Promise<any>;
26
+ removeFileTrash(s3UserId: string, bucketId: string, files: [FileTrashInput], serviceId: string, fields: string[]): Promise<any>;
27
+ getListS3DomainByS3UserId(s3UserId: string, serviceId: string, fields: string[]): Promise<any>;
28
+ addS3Domain(s3UserId: string, domain: string, byUser: string, serviceId: string, fields: string[]): Promise<any>;
29
+ removeS3Domain(s3UserId: string, domainId: string, byUser: string, serviceId: string, fields: string[]): Promise<any>;
30
+ getListCorsByS3UserId(s3UserId: string, bucketId: string, serviceId: string, fields: string[]): Promise<any>;
31
+ addCorsBucket(s3UserId: string, bucketId: string, allowedMethods: string[], allowedOrigins: string[], allowedHeaders: string[], exposeHeaders: string[], maxAgeSeconds: number, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
32
+ updateCorsBucket(bucketId: string, corsId: string, allowedMethods: string[], allowedOrigins: string[], allowedHeaders: string[], exposeHeaders: string[], maxAgeSeconds: number, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
33
+ removeCorsBucket(bucketId: string, corsId: string, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
34
+ getListFileOtherVersion(s3UserId: string, bucketId: string, key: string, serviceId: string, fields: string[]): Promise<any>;
35
+ restoreFileOtherVersion(s3UserId: string, bucketId: string, key: string, versionId: string, serviceId: string, fields: string[]): Promise<any>;
36
+ removeFileOtherVersion(s3UserId: string, bucketId: string, key: string, versionId: string, serviceId: string, fields: string[]): Promise<any>;
37
+ resetKey(s3UserId: string, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
38
+ actionSyncUserFromS3(s3UserId: string, updateBy: string, serviceId: string, fields: string[]): Promise<any>;
39
+ chartInYear(s3UserId: string, year: number, month: number, serviceId: string, fields: string[]): Promise<any>;
40
+ getIPConsul(userId: string, serviceId: string): Promise<any>;
41
+ filterListObject(s3UserId: string, bucketId: string, maxKeys: number, key: string, prefixSearch: string, continuationToken: string, serviceId: string, fields: string[]): Promise<any>;
42
42
  }