@longvansoftware/storefront-js-client 0.0.2 → 1.0.1
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 +18 -0
- package/dist/config/config.js +21 -0
- package/dist/src/graphql/auth/mutations.d.ts +7 -0
- package/dist/src/graphql/auth/mutations.js +99 -0
- package/dist/src/graphql/crm/mutations.d.ts +6 -0
- package/dist/src/graphql/crm/mutations.js +258 -0
- package/dist/src/graphql/crm/queries.d.ts +3 -0
- package/dist/src/graphql/crm/queries.js +155 -0
- package/dist/src/graphql/payment/mutations.d.ts +1 -0
- package/dist/src/graphql/payment/mutations.js +35 -0
- package/dist/src/graphql/payment/queries.d.ts +1 -0
- package/dist/src/graphql/payment/queries.js +12 -0
- package/dist/src/graphql/product/mutations.d.ts +0 -0
- package/dist/src/graphql/product/mutations.js +1 -0
- package/dist/src/graphql/product/queries.d.ts +10 -0
- package/dist/src/graphql/product/queries.js +415 -0
- package/dist/src/graphql/user/mutations.d.ts +3 -0
- package/dist/src/graphql/user/mutations.js +87 -0
- package/dist/src/graphql/user/queries.d.ts +3 -0
- package/dist/src/graphql/user/queries.js +67 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/lib/SDK.d.ts +28 -0
- package/dist/src/lib/SDK.js +43 -0
- package/dist/src/lib/auth/index.d.ts +26 -0
- package/dist/src/lib/auth/index.js +54 -0
- package/dist/src/lib/crm/index.d.ts +14 -0
- package/dist/src/lib/crm/index.js +185 -0
- package/dist/src/lib/order/index.d.ts +87 -0
- package/dist/src/lib/order/index.js +209 -0
- package/dist/src/lib/payment/index.d.ts +6 -0
- package/dist/src/lib/payment/index.js +50 -0
- package/dist/src/lib/product/index.d.ts +36 -0
- package/dist/src/lib/product/index.js +116 -0
- package/dist/src/lib/service.d.ts +14 -0
- package/dist/src/lib/service.js +97 -0
- package/dist/src/lib/user/index.d.ts +11 -0
- package/dist/src/lib/user/index.js +135 -0
- package/dist/src/types/auth.d.ts +82 -0
- package/dist/src/types/auth.js +2 -0
- package/dist/src/types/crm.d.ts +219 -0
- package/dist/src/types/crm.js +2 -0
- package/dist/src/types/order.d.ts +7 -0
- package/dist/src/types/order.js +2 -0
- package/dist/src/types/product.d.ts +61 -0
- package/dist/src/types/product.js +2 -0
- package/dist/src/types/user.d.ts +49 -0
- package/dist/src/types/user.js +2 -0
- package/dist/src/utils/helpers.d.ts +4 -0
- package/dist/src/utils/helpers.js +41 -0
- package/package.json +25 -19
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface Product {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
sku: string;
|
|
6
|
+
price: number;
|
|
7
|
+
available: boolean;
|
|
8
|
+
categories: Category[];
|
|
9
|
+
}
|
|
10
|
+
export interface Category {
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
image: string;
|
|
14
|
+
icon: string;
|
|
15
|
+
parentId: string | null;
|
|
16
|
+
level: number;
|
|
17
|
+
sequence: number;
|
|
18
|
+
handle: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ProductFilterOptions {
|
|
21
|
+
partnerId?: string;
|
|
22
|
+
storeChannel?: string;
|
|
23
|
+
category?: string;
|
|
24
|
+
product?: string;
|
|
25
|
+
sku?: string;
|
|
26
|
+
tag?: string;
|
|
27
|
+
priceFrom?: number;
|
|
28
|
+
priceTo?: number;
|
|
29
|
+
status?: string;
|
|
30
|
+
productType?: string;
|
|
31
|
+
subType?: string;
|
|
32
|
+
brandId?: string;
|
|
33
|
+
keyword?: string;
|
|
34
|
+
display?: boolean;
|
|
35
|
+
onlyPromotion?: boolean;
|
|
36
|
+
currentPage?: number;
|
|
37
|
+
maxResult?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface CategoryFilterOptions {
|
|
40
|
+
partnerId?: string;
|
|
41
|
+
storeChannel?: string;
|
|
42
|
+
typeBuild?: string;
|
|
43
|
+
level?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface Category {
|
|
46
|
+
id: string;
|
|
47
|
+
title: string;
|
|
48
|
+
image: string;
|
|
49
|
+
icon: string;
|
|
50
|
+
parentId: string | null;
|
|
51
|
+
level: number;
|
|
52
|
+
sequence: number;
|
|
53
|
+
handle: string;
|
|
54
|
+
child?: Category[];
|
|
55
|
+
}
|
|
56
|
+
export interface Brand {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
image: string;
|
|
60
|
+
imageIcon: string;
|
|
61
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface createCompanyRequest {
|
|
2
|
+
name: string;
|
|
3
|
+
phone: string;
|
|
4
|
+
address: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CreateCompany {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
address: string;
|
|
10
|
+
gender: string;
|
|
11
|
+
identityNumber: string;
|
|
12
|
+
birthDate: Date;
|
|
13
|
+
email: string;
|
|
14
|
+
phone: string;
|
|
15
|
+
createdStamp: Date;
|
|
16
|
+
createdBy: string;
|
|
17
|
+
memberLevel: string;
|
|
18
|
+
}
|
|
19
|
+
export interface updateCustomerRequest {
|
|
20
|
+
fullName: string;
|
|
21
|
+
phone: string;
|
|
22
|
+
address: string;
|
|
23
|
+
}
|
|
24
|
+
export interface GetPersonByPartyIds {
|
|
25
|
+
status: string;
|
|
26
|
+
partyId: string;
|
|
27
|
+
fullName: string;
|
|
28
|
+
phone: string;
|
|
29
|
+
address: string;
|
|
30
|
+
gender: string;
|
|
31
|
+
birthDate: Date;
|
|
32
|
+
email: string;
|
|
33
|
+
personalTitle: string;
|
|
34
|
+
imageUrl: string;
|
|
35
|
+
identityNumber: string;
|
|
36
|
+
addressModel: addressModel;
|
|
37
|
+
id: string;
|
|
38
|
+
}
|
|
39
|
+
export interface addressModel {
|
|
40
|
+
id: string;
|
|
41
|
+
addressInfo: string;
|
|
42
|
+
provinceGeoId: string;
|
|
43
|
+
districtGeoId: string;
|
|
44
|
+
wardGeoId: string;
|
|
45
|
+
provinceName: string;
|
|
46
|
+
districtName: string;
|
|
47
|
+
wardName: string;
|
|
48
|
+
isDefault: boolean;
|
|
49
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Endpoints } from "../lib/SDK";
|
|
2
|
+
export declare function createToken(environment: string): string;
|
|
3
|
+
export declare function decodeToken(token: string): string | null;
|
|
4
|
+
export declare function validateStorefrontAccessToken(storefrontAccessToken: string): Endpoints;
|
|
@@ -0,0 +1,41 @@
|
|
|
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.validateStorefrontAccessToken = exports.decodeToken = exports.createToken = void 0;
|
|
7
|
+
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
8
|
+
const config_1 = require("../../config/config");
|
|
9
|
+
function createToken(environment) {
|
|
10
|
+
const cipherText = crypto_js_1.default.AES.encrypt(environment, "lvs").toString();
|
|
11
|
+
console.log("🚀 ~ createToken ~ cipherText:", cipherText);
|
|
12
|
+
return cipherText;
|
|
13
|
+
}
|
|
14
|
+
exports.createToken = createToken;
|
|
15
|
+
function decodeToken(token) {
|
|
16
|
+
try {
|
|
17
|
+
const bytes = crypto_js_1.default.AES.decrypt(token, "lvs");
|
|
18
|
+
const decryptedData = bytes.toString(crypto_js_1.default.enc.Utf8);
|
|
19
|
+
return decryptedData;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.log("Invalid token");
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.decodeToken = decodeToken;
|
|
27
|
+
function validateStorefrontAccessToken(storefrontAccessToken) {
|
|
28
|
+
const environment = decodeToken(storefrontAccessToken) || ""; // Handle null case by providing a default value
|
|
29
|
+
console.log("🚀 ~ environment:", environment);
|
|
30
|
+
const validEnvironments = {
|
|
31
|
+
dev: "dev",
|
|
32
|
+
live: "live",
|
|
33
|
+
};
|
|
34
|
+
if (!Object.keys(validEnvironments).includes(environment)) {
|
|
35
|
+
throw new Error("Invalid storefrontAccessToken");
|
|
36
|
+
}
|
|
37
|
+
return environment == "dev"
|
|
38
|
+
? config_1.environmentEndpoints.dev
|
|
39
|
+
: config_1.environmentEndpoints.live;
|
|
40
|
+
}
|
|
41
|
+
exports.validateStorefrontAccessToken = validateStorefrontAccessToken;
|
package/package.json
CHANGED
|
@@ -1,36 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longvansoftware/storefront-js-client",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"main": "dist/src/index.js",
|
|
5
|
+
"types": "dist/src/index.d.ts",
|
|
7
6
|
"files": [
|
|
8
|
-
"dist"
|
|
7
|
+
"dist/**/*.d.ts",
|
|
8
|
+
"dist/**/*.js"
|
|
9
9
|
],
|
|
10
|
+
"directories": {
|
|
11
|
+
"test": "jest"
|
|
12
|
+
},
|
|
10
13
|
"scripts": {
|
|
11
|
-
"dev": "nodemon .",
|
|
12
|
-
"build": "tsc",
|
|
13
14
|
"test": "jest",
|
|
15
|
+
"build": "tsc",
|
|
14
16
|
"publish": "npm run build && npm publish"
|
|
15
17
|
},
|
|
18
|
+
"keywords": [],
|
|
16
19
|
"author": "",
|
|
17
20
|
"license": "ISC",
|
|
18
|
-
"
|
|
19
|
-
"@
|
|
20
|
-
"
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@apollo/client": "3.9.11",
|
|
23
|
+
"apollo-boost": "^0.4.9",
|
|
21
24
|
"axios": "^1.6.8",
|
|
25
|
+
"crypto-js": "^4.2.0",
|
|
26
|
+
"graphql": "^15.8.0",
|
|
22
27
|
"graphql-request": "^6.1.0",
|
|
23
28
|
"graphql-tag": "^2.12.6",
|
|
29
|
+
"react": "^18.2.0",
|
|
30
|
+
"ts-node": "^10.9.2"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/axios": "^0.14.0",
|
|
34
|
+
"@types/crypto-js": "^4.2.2",
|
|
35
|
+
"@types/jest": "^29.5.12",
|
|
36
|
+
"@types/node": "^20.12.7",
|
|
24
37
|
"jest": "^29.7.0",
|
|
25
|
-
"nodemon": "^2.0.15",
|
|
26
38
|
"ts-jest": "^29.1.2",
|
|
27
|
-
"
|
|
28
|
-
"typescript": "^5.4.3",
|
|
29
|
-
"webpack-loader": "^0.0.1"
|
|
39
|
+
"typescript": "^5.4.5"
|
|
30
40
|
},
|
|
31
|
-
"
|
|
32
|
-
"graphql": "^16.8.1",
|
|
33
|
-
"graphql-request": "^6.1.0",
|
|
34
|
-
"graphql-tag": "^2.12.6"
|
|
35
|
-
}
|
|
41
|
+
"description": ""
|
|
36
42
|
}
|