@longvansoftware/storefront-js-client 3.8.7 → 3.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/config.d.ts +6 -0
- package/dist/config/config.js +11 -5
- package/dist/src/graphql/orderCloud/mutations.d.ts +1 -0
- package/dist/src/graphql/orderCloud/mutations.js +12 -0
- package/dist/src/lib/SDK.d.ts +3 -0
- package/dist/src/lib/SDK.js +6 -1
- package/dist/src/lib/order/index.d.ts +5 -1
- package/dist/src/lib/order/index.js +28 -2
- package/dist/src/lib/orderCloud/index.d.ts +5 -0
- package/dist/src/lib/orderCloud/index.js +37 -0
- package/dist/src/lib/serviceSDK.d.ts +2 -1
- package/dist/src/lib/serviceSDK.js +2 -1
- package/package.json +1 -1
package/dist/config/config.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export declare const defaultTokens: {
|
|
2
|
+
dev: string;
|
|
3
|
+
live: string;
|
|
4
|
+
};
|
|
1
5
|
export declare const environmentEndpoints: {
|
|
2
6
|
dev: {
|
|
3
7
|
product: string;
|
|
@@ -25,6 +29,7 @@ export declare const environmentEndpoints: {
|
|
|
25
29
|
cashbook: string;
|
|
26
30
|
store: string;
|
|
27
31
|
fileService: string;
|
|
32
|
+
orderCloud: string;
|
|
28
33
|
};
|
|
29
34
|
live: {
|
|
30
35
|
product: string;
|
|
@@ -52,5 +57,6 @@ export declare const environmentEndpoints: {
|
|
|
52
57
|
cashbook: string;
|
|
53
58
|
store: string;
|
|
54
59
|
fileService: string;
|
|
60
|
+
orderCloud: string;
|
|
55
61
|
};
|
|
56
62
|
};
|
package/dist/config/config.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.environmentEndpoints = void 0;
|
|
3
|
+
exports.environmentEndpoints = exports.defaultTokens = void 0;
|
|
4
|
+
exports.defaultTokens = {
|
|
5
|
+
dev: "0194deb7-288b-7935-88ef-2671719a4324",
|
|
6
|
+
live: "0195f9f6-467c-7ff5-8d83-d0229ef63f8f",
|
|
7
|
+
};
|
|
4
8
|
exports.environmentEndpoints = {
|
|
5
9
|
dev: {
|
|
6
10
|
product: "https://product-service.dev.longvan.vn/product-service/graphql",
|
|
@@ -25,9 +29,10 @@ exports.environmentEndpoints = {
|
|
|
25
29
|
omnigateway: "https://omni-gateway.dev.longvan.vn/omni-gateway/v1",
|
|
26
30
|
authorization: "https://id.dev.longvan.vn/authorization/public",
|
|
27
31
|
zca: "https://zca.dev.longvan.vn",
|
|
28
|
-
cashbook:
|
|
32
|
+
cashbook: "https://api-gateway.dev.longvan.vn/cashbook-service/graphql",
|
|
29
33
|
store: "https://storefront.dev.longvan.vn/v2",
|
|
30
|
-
fileService: "https://fileservice.dev.longvan.vn/omnichannel"
|
|
34
|
+
fileService: "https://fileservice.dev.longvan.vn/omnichannel",
|
|
35
|
+
orderCloud: "https://api-gateway.dev.longvan.vn/order-cloud-service/graphql",
|
|
31
36
|
},
|
|
32
37
|
live: {
|
|
33
38
|
product: "https://product-service.longvan.vn/product-service/graphql",
|
|
@@ -52,8 +57,9 @@ exports.environmentEndpoints = {
|
|
|
52
57
|
omnigateway: "https://omni-gateway.longvan.vn/omni-gateway/v1",
|
|
53
58
|
authorization: "https://id.longvan.vn/authorization/public",
|
|
54
59
|
zca: "https://zca.longvan.vn",
|
|
55
|
-
cashbook:
|
|
60
|
+
cashbook: "https://api-gateway.longvan.vn/cashbook-service/graphql",
|
|
56
61
|
store: "https://storefront.longvan.vn/v2",
|
|
57
|
-
fileService: "https://fileservice.longvan.vn/longvan"
|
|
62
|
+
fileService: "https://fileservice.longvan.vn/longvan",
|
|
63
|
+
orderCloud: "https://api-gateway.longvan.vn/order-cloud-service/graphql",
|
|
58
64
|
},
|
|
59
65
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FIND_ORDER_BY_OWNER_PARTYID: import("graphql").DocumentNode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FIND_ORDER_BY_OWNER_PARTYID = void 0;
|
|
4
|
+
const graphql_tag_1 = require("graphql-tag");
|
|
5
|
+
exports.FIND_ORDER_BY_OWNER_PARTYID = (0, graphql_tag_1.gql) `
|
|
6
|
+
mutation FindOrderByOwnerPartyId(
|
|
7
|
+
$partnerId: String!
|
|
8
|
+
$ownerPartyId: String!
|
|
9
|
+
) {
|
|
10
|
+
findOrderByOwnerPartyId(partnerId: $partnerId, ownerPartyId: $ownerPartyId)
|
|
11
|
+
}
|
|
12
|
+
`;
|
package/dist/src/lib/SDK.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { ZcaService } from "./zca";
|
|
|
23
23
|
import { CashbookService } from "./cashbook";
|
|
24
24
|
import { StoreService } from "./store";
|
|
25
25
|
import { FileServiceSerVice } from "./fileService";
|
|
26
|
+
import { OrderCloudService } from "./orderCloud";
|
|
26
27
|
export interface Endpoints {
|
|
27
28
|
product: string;
|
|
28
29
|
crm: string;
|
|
@@ -49,6 +50,7 @@ export interface Endpoints {
|
|
|
49
50
|
cashbook: string;
|
|
50
51
|
store: string;
|
|
51
52
|
fileService: string;
|
|
53
|
+
orderCloud: string;
|
|
52
54
|
}
|
|
53
55
|
export declare class SDK {
|
|
54
56
|
orgId: string;
|
|
@@ -80,6 +82,7 @@ export declare class SDK {
|
|
|
80
82
|
store: StoreService;
|
|
81
83
|
fileService: FileServiceSerVice;
|
|
82
84
|
token: string | null;
|
|
85
|
+
orderCloud: OrderCloudService;
|
|
83
86
|
constructor(orgId: string, storeId: string, environment: "dev" | "live");
|
|
84
87
|
setToken(token: string): void;
|
|
85
88
|
setStoreId(storeId: string): void;
|
package/dist/src/lib/SDK.js
CHANGED
|
@@ -28,6 +28,7 @@ const zca_1 = require("./zca");
|
|
|
28
28
|
const cashbook_1 = require("./cashbook");
|
|
29
29
|
const store_1 = require("./store");
|
|
30
30
|
const fileService_1 = require("./fileService");
|
|
31
|
+
const orderCloud_1 = require("./orderCloud");
|
|
31
32
|
class SDK {
|
|
32
33
|
constructor(orgId, storeId, environment) {
|
|
33
34
|
this.orgId = orgId;
|
|
@@ -37,7 +38,7 @@ class SDK {
|
|
|
37
38
|
const endpoints = config_1.environmentEndpoints[environment];
|
|
38
39
|
this.product = new index_1.ProductService(endpoints.product, orgId, storeId);
|
|
39
40
|
this.auth = new index_2.AuthService(endpoints.auth, orgId, storeId);
|
|
40
|
-
this.order = new index_3.OrderService(endpoints.order, orgId, storeId);
|
|
41
|
+
this.order = new index_3.OrderService(endpoints.order, orgId, storeId, environment);
|
|
41
42
|
this.user = new index_5.UserService(endpoints.user, orgId, storeId);
|
|
42
43
|
this.payment = new index_6.PaymentService(endpoints.payment, orgId, storeId);
|
|
43
44
|
this.crm = new index_7.CrmService(endpoints.crm, orgId, storeId);
|
|
@@ -60,6 +61,7 @@ class SDK {
|
|
|
60
61
|
this.cashbook = new cashbook_1.CashbookService(endpoints.cashbook, orgId, storeId);
|
|
61
62
|
this.store = new store_1.StoreService(endpoints.store, orgId, storeId); // Using product endpoint for now
|
|
62
63
|
this.fileService = new fileService_1.FileServiceSerVice(endpoints.fileService, orgId, storeId);
|
|
64
|
+
this.orderCloud = new orderCloud_1.OrderCloudService(endpoints.orderCloud, orgId, storeId);
|
|
63
65
|
// Initialize other services here
|
|
64
66
|
}
|
|
65
67
|
setToken(token) {
|
|
@@ -91,6 +93,7 @@ class SDK {
|
|
|
91
93
|
this.cashbook.setToken(token);
|
|
92
94
|
this.store.setToken(token);
|
|
93
95
|
this.fileService.setToken(token);
|
|
96
|
+
this.orderCloud.setToken(token);
|
|
94
97
|
}
|
|
95
98
|
// các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
|
|
96
99
|
// src/service.ts
|
|
@@ -119,6 +122,7 @@ class SDK {
|
|
|
119
122
|
this.cashbook.setStoreId(storeId);
|
|
120
123
|
this.store.setStoreId(storeId);
|
|
121
124
|
this.fileService.setStoreId(storeId);
|
|
125
|
+
this.orderCloud.setStoreId(storeId);
|
|
122
126
|
// Set storeId for other services here
|
|
123
127
|
}
|
|
124
128
|
setOrgId(orgId) {
|
|
@@ -146,6 +150,7 @@ class SDK {
|
|
|
146
150
|
this.cashbook.setOrgId(orgId);
|
|
147
151
|
this.store.setOrgId(orgId);
|
|
148
152
|
this.fileService.setOrgId(orgId);
|
|
153
|
+
this.orderCloud.setStoreId(orgId);
|
|
149
154
|
}
|
|
150
155
|
}
|
|
151
156
|
exports.SDK = SDK;
|
|
@@ -10,8 +10,12 @@ export declare class OrderService extends Service {
|
|
|
10
10
|
* @param orgId - The organization ID.
|
|
11
11
|
* @param storeId - The store ID.
|
|
12
12
|
*/
|
|
13
|
-
constructor(endpoint: string, orgId: string, storeId: string);
|
|
13
|
+
constructor(endpoint: string, orgId: string, storeId: string, environment?: "dev" | "live");
|
|
14
14
|
setToken(token: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Override restApiCallWithToken to use default token if no token is set
|
|
17
|
+
*/
|
|
18
|
+
protected restApiCallWithToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
|
|
15
19
|
/**
|
|
16
20
|
* Creates a new order.
|
|
17
21
|
* @param orderData - The data for the order.
|
|
@@ -8,10 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.OrderService = void 0;
|
|
13
16
|
const serviceSDK_1 = require("../serviceSDK");
|
|
14
17
|
const validatePhoneNumber_1 = require("../../utils/validatePhoneNumber");
|
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
|
19
|
+
const config_1 = require("../../../config/config");
|
|
15
20
|
/**
|
|
16
21
|
* Represents a service for managing orders.
|
|
17
22
|
*/
|
|
@@ -22,12 +27,33 @@ class OrderService extends serviceSDK_1.Service {
|
|
|
22
27
|
* @param orgId - The organization ID.
|
|
23
28
|
* @param storeId - The store ID.
|
|
24
29
|
*/
|
|
25
|
-
constructor(endpoint, orgId, storeId) {
|
|
26
|
-
super(endpoint, orgId, storeId);
|
|
30
|
+
constructor(endpoint, orgId, storeId, environment = "dev") {
|
|
31
|
+
super(endpoint, orgId, storeId, environment);
|
|
27
32
|
}
|
|
28
33
|
setToken(token) {
|
|
29
34
|
this.token = token;
|
|
30
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Override restApiCallWithToken to use default token if no token is set
|
|
38
|
+
*/
|
|
39
|
+
restApiCallWithToken(path, method, data, headers) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const tokenToUse = this.token || config_1.defaultTokens[this.environment];
|
|
42
|
+
try {
|
|
43
|
+
const modifiedHeaders = Object.assign(Object.assign({}, headers), { PartnerId: this.orgId, Authorization: "Bearer " + tokenToUse, "X-Ecomos-Access-Token": tokenToUse, "Partner-Id": this.orgId });
|
|
44
|
+
const response = yield (0, axios_1.default)({
|
|
45
|
+
url: this.endpoint + path,
|
|
46
|
+
method,
|
|
47
|
+
data,
|
|
48
|
+
headers: modifiedHeaders,
|
|
49
|
+
});
|
|
50
|
+
return response.data;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
31
57
|
/**
|
|
32
58
|
* Creates a new order.
|
|
33
59
|
* @param orderData - The data for the order.
|
|
@@ -0,0 +1,37 @@
|
|
|
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.OrderCloudService = void 0;
|
|
13
|
+
const serviceSDK_1 = require("../serviceSDK");
|
|
14
|
+
const mutations_1 = require("../../graphql/orderCloud/mutations");
|
|
15
|
+
class OrderCloudService extends serviceSDK_1.Service {
|
|
16
|
+
constructor(endpoint, orgId, storeId) {
|
|
17
|
+
super(endpoint, orgId, storeId);
|
|
18
|
+
}
|
|
19
|
+
//
|
|
20
|
+
findOrderByOwnerPartyId(ownerPartyId) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const mutation = mutations_1.FIND_ORDER_BY_OWNER_PARTYID;
|
|
23
|
+
const variables = {
|
|
24
|
+
partnerId: this.orgId,
|
|
25
|
+
ownerPartyId,
|
|
26
|
+
};
|
|
27
|
+
try {
|
|
28
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
29
|
+
return response.findOrderByOwnerPartyId;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.OrderCloudService = OrderCloudService;
|
|
@@ -6,7 +6,8 @@ export declare class Service {
|
|
|
6
6
|
protected orgId: string;
|
|
7
7
|
protected storeId: string;
|
|
8
8
|
protected endpoint: string;
|
|
9
|
-
|
|
9
|
+
protected environment: "dev" | "live";
|
|
10
|
+
constructor(endpoint: string, orgId: string, storeId: string, environment?: "dev" | "live");
|
|
10
11
|
setToken(token: string): void;
|
|
11
12
|
setStoreId(storeId: string): void;
|
|
12
13
|
setOrgId(orgId: string): void;
|
|
@@ -18,7 +18,7 @@ const client_1 = require("@apollo/client");
|
|
|
18
18
|
const axios_1 = __importDefault(require("axios"));
|
|
19
19
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
20
20
|
class Service {
|
|
21
|
-
constructor(endpoint, orgId, storeId) {
|
|
21
|
+
constructor(endpoint, orgId, storeId, environment = "dev") {
|
|
22
22
|
this.token = null;
|
|
23
23
|
this.client = new client_1.ApolloClient({
|
|
24
24
|
link: new client_1.HttpLink({ uri: endpoint, fetch: cross_fetch_1.default }),
|
|
@@ -33,6 +33,7 @@ class Service {
|
|
|
33
33
|
this.orgId = orgId;
|
|
34
34
|
this.storeId = storeId;
|
|
35
35
|
this.endpoint = endpoint;
|
|
36
|
+
this.environment = environment;
|
|
36
37
|
}
|
|
37
38
|
setToken(token) {
|
|
38
39
|
this.token = token;
|