@longvansoftware/service-js-client 2.8.1 → 2.8.3
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.
- package/dist/config/config.js +1 -1
- package/dist/src/graphql/campaign/queries.d.ts +11 -13
- package/dist/src/graphql/campaign/queries.js +111 -39
- package/dist/src/graphql/cloud/mutations.d.ts +3 -0
- package/dist/src/graphql/cloud/mutations.js +62 -1
- package/dist/src/graphql/cloud/queries.d.ts +2 -0
- package/dist/src/graphql/cloud/queries.js +34 -1
- package/dist/src/graphql/paymentV2/mutations.d.ts +0 -1
- package/dist/src/graphql/paymentV2/mutations.js +1 -15
- package/dist/src/graphql/paymentV2/queries.d.ts +0 -2
- package/dist/src/graphql/paymentV2/queries.js +1 -58
- package/dist/src/lib/campaign/index.d.ts +0 -1
- package/dist/src/lib/campaign/index.js +12 -69
- package/dist/src/lib/cloud/index.d.ts +6 -1
- package/dist/src/lib/cloud/index.js +84 -0
- package/dist/src/lib/paymentV2/index.d.ts +0 -10
- package/dist/src/lib/paymentV2/index.js +0 -39
- package/dist/src/lib/portal/index.d.ts +0 -3
- package/dist/src/lib/portal/index.js +0 -50
- package/dist/src/lib/service.d.ts +14 -0
- package/dist/src/lib/service.js +101 -0
- package/dist/src/types/cloud.d.ts +37 -0
- package/dist/src/utils/build-field-string.d.ts +1 -0
- package/dist/src/utils/build-field-string.js +16 -0
- package/package.json +1 -1
- package/dist/src/graphql/marketplace/mutations.d.ts +0 -3
- package/dist/src/graphql/marketplace/mutations.js +0 -54
- package/dist/src/graphql/marketplace/queries.d.ts +0 -2
- package/dist/src/graphql/marketplace/queries.js +0 -42
- package/dist/src/graphql/storefont/mutation.d.ts +0 -0
- package/dist/src/graphql/storefont/mutation.js +0 -1
- package/dist/src/graphql/storefont/queries.d.ts +0 -2
- package/dist/src/graphql/storefont/queries.js +0 -46
- package/dist/src/graphql/tag/mutations.d.ts +0 -2
- package/dist/src/graphql/tag/mutations.js +0 -44
- package/dist/src/graphql/tag/queries.d.ts +0 -1
- package/dist/src/graphql/tag/queries.js +0 -20
- package/dist/src/lib/marketplace/index.d.ts +0 -9
- package/dist/src/lib/marketplace/index.js +0 -106
- package/dist/src/lib/storefont/index.d.ts +0 -6
- package/dist/src/lib/storefont/index.js +0 -51
- package/dist/src/lib/tag/index.d.ts +0 -7
- package/dist/src/lib/tag/index.js +0 -61
|
@@ -30,7 +30,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
30
30
|
partyId: this.orgId,
|
|
31
31
|
productStoreId: this.storeId,
|
|
32
32
|
customerId,
|
|
33
|
-
campaignActionType
|
|
33
|
+
campaignActionType,
|
|
34
34
|
};
|
|
35
35
|
try {
|
|
36
36
|
const response = yield this.graphqlQuery(query, variables);
|
|
@@ -54,7 +54,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
54
54
|
customerId,
|
|
55
55
|
excludeExpired,
|
|
56
56
|
pageNumber,
|
|
57
|
-
pageSize
|
|
57
|
+
pageSize,
|
|
58
58
|
};
|
|
59
59
|
try {
|
|
60
60
|
const response = yield this.graphqlQuery(query, variables);
|
|
@@ -73,7 +73,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
73
73
|
partyId: this.orgId,
|
|
74
74
|
productStoreId: this.storeId,
|
|
75
75
|
customerId,
|
|
76
|
-
voucherCode
|
|
76
|
+
voucherCode,
|
|
77
77
|
};
|
|
78
78
|
try {
|
|
79
79
|
const response = yield this.graphqlQuery(query, variables);
|
|
@@ -92,7 +92,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
92
92
|
partyId: this.orgId,
|
|
93
93
|
productStoreId: this.storeId,
|
|
94
94
|
campaignActionType,
|
|
95
|
-
customerId
|
|
95
|
+
customerId,
|
|
96
96
|
};
|
|
97
97
|
try {
|
|
98
98
|
const response = yield this.graphqlQuery(query, variables);
|
|
@@ -110,7 +110,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
110
110
|
partyId: this.orgId,
|
|
111
111
|
productStoreId: this.storeId,
|
|
112
112
|
productId,
|
|
113
|
-
productPrice
|
|
113
|
+
productPrice,
|
|
114
114
|
};
|
|
115
115
|
try {
|
|
116
116
|
const response = yield this.graphqlQuery(query, variables);
|
|
@@ -131,7 +131,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
131
131
|
campaignActionId,
|
|
132
132
|
customerId,
|
|
133
133
|
excludeExpired,
|
|
134
|
-
isPageAble
|
|
134
|
+
isPageAble,
|
|
135
135
|
};
|
|
136
136
|
try {
|
|
137
137
|
const response = yield this.graphqlQuery(query, variables);
|
|
@@ -149,7 +149,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
149
149
|
partyId: this.orgId,
|
|
150
150
|
voucherCode,
|
|
151
151
|
userId,
|
|
152
|
-
affiliateId
|
|
152
|
+
affiliateId,
|
|
153
153
|
};
|
|
154
154
|
try {
|
|
155
155
|
const response = yield this.graphqlMutation(query, variables);
|
|
@@ -169,7 +169,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
169
169
|
campaignId: campaignId,
|
|
170
170
|
campaignActionId: campaignActionId,
|
|
171
171
|
excludeExpired: true,
|
|
172
|
-
isBirthday: isBirthday
|
|
172
|
+
isBirthday: isBirthday,
|
|
173
173
|
};
|
|
174
174
|
try {
|
|
175
175
|
const response = yield this.graphqlQuery(query, variables);
|
|
@@ -184,7 +184,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
184
184
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
185
|
const query = queries_1.GET_CAMPAIGN_ACTION_BY_ID;
|
|
186
186
|
const variables = {
|
|
187
|
-
id
|
|
187
|
+
id,
|
|
188
188
|
};
|
|
189
189
|
try {
|
|
190
190
|
const response = yield this.graphqlQuery(query, variables);
|
|
@@ -203,7 +203,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
203
203
|
storeId: this.storeId,
|
|
204
204
|
productIds: productIds,
|
|
205
205
|
campaignActionId: campaignActionId,
|
|
206
|
-
sort: { asc: true, key: "createdStamp" }
|
|
206
|
+
sort: { asc: true, key: "createdStamp" },
|
|
207
207
|
};
|
|
208
208
|
try {
|
|
209
209
|
const response = yield this.graphqlQuery(query, variables);
|
|
@@ -218,7 +218,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
218
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
219
219
|
const query = queries_1.GET_CAMPAIGN;
|
|
220
220
|
const variables = {
|
|
221
|
-
id
|
|
221
|
+
id,
|
|
222
222
|
};
|
|
223
223
|
try {
|
|
224
224
|
const response = yield this.graphqlQuery(query, variables);
|
|
@@ -237,7 +237,7 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
237
237
|
campaignId,
|
|
238
238
|
campaignActionId,
|
|
239
239
|
statusActive,
|
|
240
|
-
sort: { asc: true, key: "productId" }
|
|
240
|
+
sort: { asc: true, key: "productId" },
|
|
241
241
|
};
|
|
242
242
|
try {
|
|
243
243
|
const response = yield this.graphqlQuery(query, variables);
|
|
@@ -248,62 +248,5 @@ class CampaignService extends serviceSDK_1.Service {
|
|
|
248
248
|
}
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
|
-
voucherForUserRequest(orderId_1) {
|
|
252
|
-
return __awaiter(this, arguments, void 0, function* (orderId, customerId = "", paymentMethodId, shippingCompanyId, pageNumber = 0, pageSize = 20, fields = [
|
|
253
|
-
`content {
|
|
254
|
-
id
|
|
255
|
-
voucherCode
|
|
256
|
-
isBirthday
|
|
257
|
-
discountAmount
|
|
258
|
-
discountPercent
|
|
259
|
-
usageLimitPerVoucher
|
|
260
|
-
numberOfTimeUsed
|
|
261
|
-
maximumDiscount
|
|
262
|
-
maximumDiscountType
|
|
263
|
-
memberLevel
|
|
264
|
-
affiliateId
|
|
265
|
-
description
|
|
266
|
-
usageLimitType
|
|
267
|
-
minimumSpend
|
|
268
|
-
maximumSpend
|
|
269
|
-
expiryDate
|
|
270
|
-
isUsable
|
|
271
|
-
unusableReasons
|
|
272
|
-
remainingAmount
|
|
273
|
-
discountType
|
|
274
|
-
discountValue
|
|
275
|
-
ownerPartyId
|
|
276
|
-
rewardType
|
|
277
|
-
voucherType
|
|
278
|
-
}`,
|
|
279
|
-
"total",
|
|
280
|
-
"pageNumber",
|
|
281
|
-
"pageSize",
|
|
282
|
-
"totalPages",
|
|
283
|
-
"numberOfElements",
|
|
284
|
-
"first",
|
|
285
|
-
"last"
|
|
286
|
-
]) {
|
|
287
|
-
const query = (0, queries_1.GET_VOUCHER_FOR_USER)(fields);
|
|
288
|
-
const variables = {
|
|
289
|
-
voucherForUserRequest: {
|
|
290
|
-
orderId,
|
|
291
|
-
customerId,
|
|
292
|
-
storeId: this.storeId,
|
|
293
|
-
paymentMethodId,
|
|
294
|
-
shippingCompanyId,
|
|
295
|
-
pageNumber,
|
|
296
|
-
pageSize
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
try {
|
|
300
|
-
const res = yield this.graphqlQuery(query, variables);
|
|
301
|
-
return res.getVouchersForUser;
|
|
302
|
-
}
|
|
303
|
-
catch (error) {
|
|
304
|
-
throw error;
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
251
|
}
|
|
309
252
|
exports.CampaignService = CampaignService;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreateUserMailHosting, DeleteUserPassword, Filter, UpdateInforMationService, UpdateUserPassword } from "../../types/cloud";
|
|
1
|
+
import { CreateUserMailHosting, DeleteUserPassword, DomainDns, Filter, RecordDns, RecordDnsInput, UpdateInforMationService, UpdateUserPassword } from "../../types/cloud";
|
|
2
2
|
import { Service } from "../serviceSDK";
|
|
3
3
|
export declare class CloudService extends Service {
|
|
4
4
|
/**
|
|
@@ -56,4 +56,9 @@ export declare class CloudService extends Service {
|
|
|
56
56
|
convertProductResourceOutputsToProductJsonList(productResourceInput: any, fields: string[]): Promise<any>;
|
|
57
57
|
searchActionsDynamic(parameter: any, fields: string[]): Promise<any>;
|
|
58
58
|
addLetsEncryptSSLForMailHosting(serviceId: string, actorId: string): Promise<any>;
|
|
59
|
+
removeRecord(serviceId: string, nameRecord: string, typeRecord: string): Promise<boolean>;
|
|
60
|
+
updateRecord(serviceId: string, record: RecordDnsInput): Promise<RecordDns>;
|
|
61
|
+
saveRecord(serviceId: string, record: RecordDnsInput): Promise<RecordDns>;
|
|
62
|
+
getRecord(serviceId: string): Promise<RecordDns[]>;
|
|
63
|
+
getDomainDns(serviceId: string): Promise<DomainDns | null>;
|
|
59
64
|
}
|
|
@@ -818,5 +818,89 @@ class CloudService extends serviceSDK_1.Service {
|
|
|
818
818
|
}
|
|
819
819
|
});
|
|
820
820
|
}
|
|
821
|
+
removeRecord(serviceId, nameRecord, typeRecord) {
|
|
822
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
823
|
+
const mutation = mutations_1.REMOVE_RECORD;
|
|
824
|
+
const variables = {
|
|
825
|
+
serviceId,
|
|
826
|
+
nameRecord,
|
|
827
|
+
typeRecord,
|
|
828
|
+
};
|
|
829
|
+
try {
|
|
830
|
+
const response = yield this.graphqlMutationV2(mutation, variables);
|
|
831
|
+
return response.removeRecord;
|
|
832
|
+
}
|
|
833
|
+
catch (error) {
|
|
834
|
+
console.log(`Error in removeRecord: ${error}`);
|
|
835
|
+
throw error;
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
updateRecord(serviceId, record) {
|
|
840
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
841
|
+
const mutation = mutations_1.UPDATE_RECORD;
|
|
842
|
+
const variables = {
|
|
843
|
+
serviceId,
|
|
844
|
+
record,
|
|
845
|
+
};
|
|
846
|
+
try {
|
|
847
|
+
const response = yield this.graphqlMutationV2(mutation, variables);
|
|
848
|
+
return response.updateRecord;
|
|
849
|
+
}
|
|
850
|
+
catch (error) {
|
|
851
|
+
console.log(`Error in updateRecord: ${error}`);
|
|
852
|
+
throw error;
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
saveRecord(serviceId, record) {
|
|
857
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
858
|
+
const mutation = mutations_1.SAVE_RECORD;
|
|
859
|
+
const variables = {
|
|
860
|
+
serviceId,
|
|
861
|
+
record,
|
|
862
|
+
};
|
|
863
|
+
try {
|
|
864
|
+
const response = yield this.graphqlMutationV2(mutation, variables);
|
|
865
|
+
return response.saveRecord;
|
|
866
|
+
}
|
|
867
|
+
catch (error) {
|
|
868
|
+
console.log(`Error in saveRecord: ${error}`);
|
|
869
|
+
throw error;
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
getRecord(serviceId) {
|
|
874
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
875
|
+
const query = queries_1.GET_RECORD;
|
|
876
|
+
const variables = {
|
|
877
|
+
serviceId,
|
|
878
|
+
};
|
|
879
|
+
try {
|
|
880
|
+
const response = yield this.graphqlQueryV2(query, variables);
|
|
881
|
+
return response.getRecord;
|
|
882
|
+
}
|
|
883
|
+
catch (error) {
|
|
884
|
+
console.log(`Error in getRecord: ${error}`);
|
|
885
|
+
throw error;
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
getDomainDns(serviceId) {
|
|
890
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
891
|
+
const query = queries_1.GET_DOMAIN_DNS;
|
|
892
|
+
const variables = {
|
|
893
|
+
serviceId,
|
|
894
|
+
};
|
|
895
|
+
try {
|
|
896
|
+
const response = yield this.graphqlQueryV2(query, variables);
|
|
897
|
+
return response.getDomainDns;
|
|
898
|
+
}
|
|
899
|
+
catch (error) {
|
|
900
|
+
console.log(`Error in getDomainDns: ${error}`);
|
|
901
|
+
throw error;
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
}
|
|
821
905
|
}
|
|
822
906
|
exports.CloudService = CloudService;
|
|
@@ -16,14 +16,4 @@ export declare class PaymentServiceV2 extends Service {
|
|
|
16
16
|
getPaymentGatewaysByMethodCode(methodCode: string): Promise<any>;
|
|
17
17
|
getPaymentMethodTypesV2(storeActive: any, allMethodTypes: boolean): Promise<any>;
|
|
18
18
|
getTransferInfo(storeId: string, paymentId: string): Promise<any>;
|
|
19
|
-
createPayment(paymentData: {
|
|
20
|
-
totalAmount: number;
|
|
21
|
-
storeID: string;
|
|
22
|
-
partnerCode: string;
|
|
23
|
-
methodCode: string;
|
|
24
|
-
phone?: string;
|
|
25
|
-
email?: string;
|
|
26
|
-
}): Promise<any>;
|
|
27
|
-
paymentMethodsByPartner(partnerCode?: string): Promise<any>;
|
|
28
|
-
getPaymentMethodTypesWithGatewayConfig(partnerId?: string, storeId?: string): Promise<any>;
|
|
29
19
|
}
|
|
@@ -260,44 +260,5 @@ class PaymentServiceV2 extends serviceSDK_1.Service {
|
|
|
260
260
|
}
|
|
261
261
|
});
|
|
262
262
|
}
|
|
263
|
-
createPayment(paymentData) {
|
|
264
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
265
|
-
const mutation = mutations_1.CREATE_PAYMENT;
|
|
266
|
-
const variables = { paymentData };
|
|
267
|
-
try {
|
|
268
|
-
const response = yield this.graphqlMutationV3(mutation, variables);
|
|
269
|
-
return response.createPayment;
|
|
270
|
-
}
|
|
271
|
-
catch (error) {
|
|
272
|
-
throw error;
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
paymentMethodsByPartner(partnerCode) {
|
|
277
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
-
const query = queries_1.PAYMENT_METHODS_BY_PARTNER;
|
|
279
|
-
const variables = { partnerCode };
|
|
280
|
-
try {
|
|
281
|
-
const response = yield this.graphqlQueryV3(query, variables);
|
|
282
|
-
return response.paymentMethods;
|
|
283
|
-
}
|
|
284
|
-
catch (error) {
|
|
285
|
-
throw error;
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
getPaymentMethodTypesWithGatewayConfig(partnerId, storeId) {
|
|
290
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
291
|
-
const query = queries_1.GET_PAYMENT_METHOD_TYPES_WITH_GATEWAY_CONFIG;
|
|
292
|
-
const variables = { partnerId, storeId };
|
|
293
|
-
try {
|
|
294
|
-
const response = yield this.graphqlQueryV3(query, variables);
|
|
295
|
-
return response.getPaymentMethodTypes;
|
|
296
|
-
}
|
|
297
|
-
catch (error) {
|
|
298
|
-
throw error;
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
263
|
}
|
|
303
264
|
exports.PaymentServiceV2 = PaymentServiceV2;
|
|
@@ -30,7 +30,4 @@ export declare class PortalService extends Service {
|
|
|
30
30
|
getPosition(query?: Record<string, any>): Promise<any>;
|
|
31
31
|
getPositionForTime(query?: Record<string, any>): Promise<any>;
|
|
32
32
|
getBookingCount(query?: Record<string, any>): Promise<any>;
|
|
33
|
-
getSlugPathFromDynamicFrom(query?: Record<string, any>): Promise<any>;
|
|
34
|
-
putSlugPathFromDynamicFrom(data: any): Promise<any>;
|
|
35
|
-
postSlugPathFromDynamicFrom(data: any): Promise<any>;
|
|
36
33
|
}
|
|
@@ -452,55 +452,5 @@ class PortalService extends serviceSDK_1.Service {
|
|
|
452
452
|
}
|
|
453
453
|
});
|
|
454
454
|
}
|
|
455
|
-
getSlugPathFromDynamicFrom(query) {
|
|
456
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
457
|
-
const method = "GET";
|
|
458
|
-
const baseUrl = `/dynamic-collection/public/v2/records/slug_path/slug_path_view`;
|
|
459
|
-
const params = new URLSearchParams();
|
|
460
|
-
if (query) {
|
|
461
|
-
Object.entries(query).forEach(([key, value]) => {
|
|
462
|
-
if (value !== undefined && value !== null) {
|
|
463
|
-
params.append(key, String(value));
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
const endpoint = params.toString()
|
|
468
|
-
? `${baseUrl}?${params.toString()}`
|
|
469
|
-
: baseUrl;
|
|
470
|
-
try {
|
|
471
|
-
const response = yield this.restApiCallWithNoToken(endpoint, method);
|
|
472
|
-
return response;
|
|
473
|
-
}
|
|
474
|
-
catch (error) {
|
|
475
|
-
throw error;
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
putSlugPathFromDynamicFrom(data) {
|
|
480
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
481
|
-
const method = "PUT";
|
|
482
|
-
const endpoint = `/dynamic-collection/public/v2/records/slug_path/slug_path_form`;
|
|
483
|
-
try {
|
|
484
|
-
const response = yield this.restApiCallWithNoToken(endpoint, method, data);
|
|
485
|
-
return response;
|
|
486
|
-
}
|
|
487
|
-
catch (error) {
|
|
488
|
-
throw error;
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
postSlugPathFromDynamicFrom(data) {
|
|
493
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
494
|
-
const method = "POST";
|
|
495
|
-
const endpoint = `/dynamic-collection/public/v2/records/slug_path/slug_path_form`;
|
|
496
|
-
try {
|
|
497
|
-
const response = yield this.restApiCallWithNoHeader(endpoint, method, data);
|
|
498
|
-
return response;
|
|
499
|
-
}
|
|
500
|
-
catch (error) {
|
|
501
|
-
throw error;
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
455
|
}
|
|
506
456
|
exports.PortalService = PortalService;
|
|
@@ -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;
|
|
@@ -40,3 +40,40 @@ export interface ServiceStatus {
|
|
|
40
40
|
CANCELLED: "CANCELLED";
|
|
41
41
|
CLOSED: "CLOSED";
|
|
42
42
|
}
|
|
43
|
+
export interface RecordDnsInput {
|
|
44
|
+
id?: number;
|
|
45
|
+
name: string;
|
|
46
|
+
type: string;
|
|
47
|
+
content?: string;
|
|
48
|
+
ttl?: number;
|
|
49
|
+
prio?: number;
|
|
50
|
+
changeDate?: number;
|
|
51
|
+
disabled?: number;
|
|
52
|
+
ordername?: string;
|
|
53
|
+
auth?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface RecordDns {
|
|
56
|
+
id?: number;
|
|
57
|
+
domainName?: string;
|
|
58
|
+
domainId?: number;
|
|
59
|
+
name?: string;
|
|
60
|
+
type?: string;
|
|
61
|
+
content?: string;
|
|
62
|
+
ttl?: number;
|
|
63
|
+
prio?: number;
|
|
64
|
+
changeDate?: number;
|
|
65
|
+
disabled?: number;
|
|
66
|
+
ordername?: string;
|
|
67
|
+
auth?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface DomainDns {
|
|
70
|
+
id?: number;
|
|
71
|
+
name?: string;
|
|
72
|
+
master?: string;
|
|
73
|
+
lastCheck?: number;
|
|
74
|
+
type?: string;
|
|
75
|
+
notifiedSerial?: number;
|
|
76
|
+
account?: string;
|
|
77
|
+
email?: string;
|
|
78
|
+
nameServer?: string;
|
|
79
|
+
}
|
|
@@ -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,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REMOVE_PRODUCT_TAG = exports.ADD_PRODUCT_TAG = exports.CREATE_TAG = void 0;
|
|
4
|
-
const graphql_tag_1 = require("graphql-tag");
|
|
5
|
-
exports.CREATE_TAG = (0, graphql_tag_1.gql) `
|
|
6
|
-
mutation CreateTag($name: String!, $slug: String!, $createdBy: String!) {
|
|
7
|
-
createTag(name: $name, slug: $slug, createdBy: $createdBy) {
|
|
8
|
-
id
|
|
9
|
-
name
|
|
10
|
-
slug
|
|
11
|
-
type
|
|
12
|
-
scope
|
|
13
|
-
storeIds
|
|
14
|
-
selected
|
|
15
|
-
title
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
exports.ADD_PRODUCT_TAG = (0, graphql_tag_1.gql) `
|
|
20
|
-
mutation AddProductTag(
|
|
21
|
-
$productId: String!
|
|
22
|
-
$tagId: String!
|
|
23
|
-
$tagGroupId: String
|
|
24
|
-
$createBy: String!
|
|
25
|
-
) {
|
|
26
|
-
addProductTag(
|
|
27
|
-
productId: $productId
|
|
28
|
-
tagId: $tagId
|
|
29
|
-
tagGroupId: $tagGroupId
|
|
30
|
-
createBy: $createBy
|
|
31
|
-
) {
|
|
32
|
-
status
|
|
33
|
-
message
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
`;
|
|
37
|
-
exports.REMOVE_PRODUCT_TAG = (0, graphql_tag_1.gql) `
|
|
38
|
-
mutation RemoveProductTag(
|
|
39
|
-
$productId: String!
|
|
40
|
-
$tagId: String!
|
|
41
|
-
$tagGroupId: String
|
|
42
|
-
$updatedBy: String!
|
|
43
|
-
) {
|
|
44
|
-
removeProductTag(
|
|
45
|
-
productId: $productId
|
|
46
|
-
tagId: $tagId
|
|
47
|
-
tagGroupId: $tagGroupId
|
|
48
|
-
updatedBy: $updatedBy
|
|
49
|
-
) {
|
|
50
|
-
status
|
|
51
|
-
message
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
`;
|