@longvansoftware/storefront-js-client 1.8.3 → 1.8.5
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.d.ts +2 -0
- package/dist/config/config.js +4 -2
- package/dist/src/lib/SDK.d.ts +3 -0
- package/dist/src/lib/SDK.js +6 -1
- package/dist/src/lib/portal/index.d.ts +6 -0
- package/dist/src/lib/portal/index.js +47 -0
- package/dist/src/lib/serviceSDK.d.ts +1 -0
- package/dist/src/lib/serviceSDK.js +23 -0
- package/dist/src/lib/shareZalo/index.js +1 -1
- package/package.json +1 -1
package/dist/config/config.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const environmentEndpoints: {
|
|
|
15
15
|
warehouseV2: string;
|
|
16
16
|
deepLinkVietQr: string;
|
|
17
17
|
shareZalo: string;
|
|
18
|
+
portal: string;
|
|
18
19
|
};
|
|
19
20
|
live: {
|
|
20
21
|
product: string;
|
|
@@ -32,5 +33,6 @@ export declare const environmentEndpoints: {
|
|
|
32
33
|
warehouseV2: string;
|
|
33
34
|
deepLinkVietQr: string;
|
|
34
35
|
shareZalo: string;
|
|
36
|
+
portal: string;
|
|
35
37
|
};
|
|
36
38
|
};
|
package/dist/config/config.js
CHANGED
|
@@ -17,7 +17,8 @@ exports.environmentEndpoints = {
|
|
|
17
17
|
paymentV2: "https://payment.dev.longvan.vn/graphql",
|
|
18
18
|
warehouseV2: "https://portal.dev.longvan.vn/facility-api",
|
|
19
19
|
deepLinkVietQr: "https://api.vietqr.io/v2",
|
|
20
|
-
shareZalo: "https://com-hub.longvan.vn/com-hub/v1/web-hook/zalo/zns/62661ed100adf430d79fb9e5"
|
|
20
|
+
shareZalo: "https://com-hub.longvan.vn/com-hub/v1/web-hook/zalo/zns/62661ed100adf430d79fb9e5",
|
|
21
|
+
portal: " https://portal.dev.longvan.vn"
|
|
21
22
|
},
|
|
22
23
|
live: {
|
|
23
24
|
product: "https://product-service.longvan.vn/product-service/graphql",
|
|
@@ -34,6 +35,7 @@ exports.environmentEndpoints = {
|
|
|
34
35
|
paymentV2: "https://payment-staging.longvan.vn/graphql",
|
|
35
36
|
warehouseV2: "https://portal.longvan.vn/facility-api/public-facility/1.0.0/product-inventory",
|
|
36
37
|
deepLinkVietQr: "https://api.vietqr.io/v2",
|
|
37
|
-
shareZalo: "https://com-hub.longvan.vn/com-hub/v1/web-hook/zalo/zns/62661ed100adf430d79fb9e5"
|
|
38
|
+
shareZalo: "https://com-hub.longvan.vn/com-hub/v1/web-hook/zalo/zns/62661ed100adf430d79fb9e5",
|
|
39
|
+
portal: " https://portal.longvan.vn"
|
|
38
40
|
},
|
|
39
41
|
};
|
package/dist/src/lib/SDK.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { PaymentServiceV2 } from "./paymentV2";
|
|
|
13
13
|
import { WarehouseServiceV2 } from "./warehouseV2";
|
|
14
14
|
import { DeepLinkVietQrService } from "./deepLinkVietQr";
|
|
15
15
|
import { ShareZaloService } from "./shareZalo";
|
|
16
|
+
import { PortalService } from "./portal";
|
|
16
17
|
export interface Endpoints {
|
|
17
18
|
product: string;
|
|
18
19
|
crm: string;
|
|
@@ -29,6 +30,7 @@ export interface Endpoints {
|
|
|
29
30
|
warehouseV2: string;
|
|
30
31
|
deepLinkVietQr: string;
|
|
31
32
|
shareZalo: string;
|
|
33
|
+
portal: string;
|
|
32
34
|
}
|
|
33
35
|
export declare class SDK {
|
|
34
36
|
orgId: string;
|
|
@@ -49,6 +51,7 @@ export declare class SDK {
|
|
|
49
51
|
warehouseV2: WarehouseServiceV2;
|
|
50
52
|
deepLinkVietQr: DeepLinkVietQrService;
|
|
51
53
|
shareZalo: ShareZaloService;
|
|
54
|
+
portal: PortalService;
|
|
52
55
|
token: string | null;
|
|
53
56
|
constructor(orgId: string, storeId: string, environment: "dev" | "live");
|
|
54
57
|
setToken(token: string): void;
|
package/dist/src/lib/SDK.js
CHANGED
|
@@ -18,6 +18,7 @@ const paymentV2_1 = require("./paymentV2");
|
|
|
18
18
|
const warehouseV2_1 = require("./warehouseV2");
|
|
19
19
|
const deepLinkVietQr_1 = require("./deepLinkVietQr");
|
|
20
20
|
const shareZalo_1 = require("./shareZalo");
|
|
21
|
+
const portal_1 = require("./portal");
|
|
21
22
|
class SDK {
|
|
22
23
|
constructor(orgId, storeId, environment) {
|
|
23
24
|
this.orgId = orgId;
|
|
@@ -40,6 +41,7 @@ class SDK {
|
|
|
40
41
|
this.warehouseV2 = new warehouseV2_1.WarehouseServiceV2(endpoints.warehouseV2, orgId, storeId);
|
|
41
42
|
this.deepLinkVietQr = new deepLinkVietQr_1.DeepLinkVietQrService(endpoints.deepLinkVietQr, orgId, storeId);
|
|
42
43
|
this.shareZalo = new shareZalo_1.ShareZaloService(endpoints.shareZalo, orgId, storeId);
|
|
44
|
+
this.portal = new portal_1.PortalService(endpoints.portal, orgId, storeId);
|
|
43
45
|
// Initialize other services here
|
|
44
46
|
}
|
|
45
47
|
setToken(token) {
|
|
@@ -59,7 +61,8 @@ class SDK {
|
|
|
59
61
|
this.warehouseV2.setToken(token);
|
|
60
62
|
this.deepLinkVietQr.setToken(token);
|
|
61
63
|
this.campaign.setToken(token);
|
|
62
|
-
this.
|
|
64
|
+
this.portal.setToken(token);
|
|
65
|
+
// this.shareZalo.setToken(token)
|
|
63
66
|
// Set token for other services here
|
|
64
67
|
}
|
|
65
68
|
// các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
|
|
@@ -79,6 +82,7 @@ class SDK {
|
|
|
79
82
|
this.warehouseV2.setStoreId(storeId);
|
|
80
83
|
this.deepLinkVietQr.setStoreId(storeId);
|
|
81
84
|
this.campaign.setStoreId(storeId);
|
|
85
|
+
this.portal.setStoreId(storeId);
|
|
82
86
|
// Set storeId for other services here
|
|
83
87
|
}
|
|
84
88
|
setOrgId(orgId) {
|
|
@@ -96,6 +100,7 @@ class SDK {
|
|
|
96
100
|
this.warehouseV2.setOrgId(orgId);
|
|
97
101
|
this.deepLinkVietQr.setOrgId(orgId);
|
|
98
102
|
this.campaign.setOrgId(orgId);
|
|
103
|
+
this.portal.setOrgId(orgId);
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
106
|
exports.SDK = SDK;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PortalService = void 0;
|
|
13
|
+
const serviceSDK_1 = require("../serviceSDK");
|
|
14
|
+
class PortalService extends serviceSDK_1.Service {
|
|
15
|
+
constructor(endpoint, orgId, storeId) {
|
|
16
|
+
super(endpoint, orgId, storeId);
|
|
17
|
+
}
|
|
18
|
+
// GET
|
|
19
|
+
getDynamicForm(dataRequest) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const endpoint = `/dynamic-collection/public/v2/formApi/F.diaries`;
|
|
22
|
+
const method = "POST";
|
|
23
|
+
try {
|
|
24
|
+
const response = yield this.restApiCallWithNoHeader(endpoint, method, dataRequest);
|
|
25
|
+
return response;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// POST
|
|
33
|
+
updateDynamicForm(dataRequest) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const endpoint = `/dynamic-collection/public/v2/formApi/F.diaries`;
|
|
36
|
+
const method = "PUT";
|
|
37
|
+
try {
|
|
38
|
+
const response = yield this.restApiCallWithNoHeader(endpoint, method, dataRequest);
|
|
39
|
+
return response;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.PortalService = PortalService;
|
|
@@ -15,6 +15,7 @@ export declare class Service {
|
|
|
15
15
|
protected graphqlMutation(mutation: DocumentNode, variables: any): Promise<any>;
|
|
16
16
|
protected restApiCallWithToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
|
|
17
17
|
protected restApiCallWithNoToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
|
|
18
|
+
protected restApiCallWithNoHeader(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
|
|
18
19
|
protected graphqlQueryV2(query: DocumentNode, variables: any): Promise<any>;
|
|
19
20
|
protected graphqlMutationV2(mutation: DocumentNode, variables: any): Promise<any>;
|
|
20
21
|
protected graphqlQueryV3(query: DocumentNode, variables: any): Promise<any>;
|
|
@@ -142,6 +142,29 @@ class Service {
|
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
+
// call api no header
|
|
146
|
+
restApiCallWithNoHeader(path, method, data, headers) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
try {
|
|
149
|
+
// const modifiedHeaders = {
|
|
150
|
+
// ...headers,
|
|
151
|
+
// Partnerid: this.orgId,
|
|
152
|
+
// };
|
|
153
|
+
const response = yield (0, axios_1.default)({
|
|
154
|
+
url: this.endpoint + path,
|
|
155
|
+
method,
|
|
156
|
+
data,
|
|
157
|
+
// headers: modifiedHeaders,
|
|
158
|
+
});
|
|
159
|
+
return response.data;
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
console.log(`Error in restApiCallWithNoToken: ${error}`);
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
//
|
|
145
168
|
graphqlQueryV2(query, variables) {
|
|
146
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
170
|
try {
|
|
@@ -20,7 +20,7 @@ class ShareZaloService extends serviceSDK_1.Service {
|
|
|
20
20
|
const endpoint = ``;
|
|
21
21
|
const method = "POST";
|
|
22
22
|
try {
|
|
23
|
-
const response = yield this.
|
|
23
|
+
const response = yield this.restApiCallWithNoHeader(endpoint, method, dataRequet);
|
|
24
24
|
return response;
|
|
25
25
|
}
|
|
26
26
|
catch (error) {
|