@helpdice/sdk 0.5.1 → 0.5.2
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/index.js +10 -12
- package/dist/index.js.map +1 -1
- package/dist/types/config/index.d.ts +2 -28
- package/dist/types/config/state.d.ts +31 -0
- package/package.json +9 -9
- package/dist/cjs/account/endpoint.js +0 -8
- package/dist/cjs/account/index.js +0 -17
- package/dist/cjs/account/types.js +0 -2
- package/dist/cjs/account/update_profile.js +0 -17
- package/dist/cjs/accounting/createInvoice.js +0 -17
- package/dist/cjs/accounting/endpoint.js +0 -14
- package/dist/cjs/accounting/index.js +0 -25
- package/dist/cjs/accounting/submitInvoice.js +0 -17
- package/dist/cjs/accounting/types.js +0 -2
- package/dist/cjs/accounting/updateInvoice.js +0 -17
- package/dist/cjs/apis/cities.js +0 -17
- package/dist/cjs/apis/countries.js +0 -17
- package/dist/cjs/apis/index.js +0 -14
- package/dist/cjs/apis/states.js +0 -17
- package/dist/cjs/assets/endpoint.js +0 -9
- package/dist/cjs/assets/index.js +0 -11
- package/dist/cjs/auth/authWithKey.js +0 -17
- package/dist/cjs/auth/authWithToken.js +0 -17
- package/dist/cjs/auth/endpoint.js +0 -15
- package/dist/cjs/auth/index.js +0 -94
- package/dist/cjs/auth/logout.js +0 -22
- package/dist/cjs/auth/register.js +0 -17
- package/dist/cjs/auth/resetPassword.js +0 -17
- package/dist/cjs/auth/signInWithGoogle.js +0 -56
- package/dist/cjs/auth/signin.js +0 -17
- package/dist/cjs/auth/signup.js +0 -17
- package/dist/cjs/auth/types.js +0 -2
- package/dist/cjs/config/axios.js +0 -120
- package/dist/cjs/config/constants.js +0 -12
- package/dist/cjs/config/fetch.js +0 -37
- package/dist/cjs/config/handler.js +0 -32
- package/dist/cjs/config/index.js +0 -37
- package/dist/cjs/config/local-storage.js +0 -29
- package/dist/cjs/config/route.js +0 -47
- package/dist/cjs/config/validate.js +0 -15
- package/dist/cjs/content/endpoint.js +0 -17
- package/dist/cjs/content/index.js +0 -29
- package/dist/cjs/hooks/index.js +0 -10
- package/dist/cjs/hooks/useAuth.js +0 -23
- package/dist/cjs/hooks/usePrivate.js +0 -15
- package/dist/cjs/hooks/useUser.js +0 -15
- package/dist/cjs/index.js +0 -59
- package/dist/cjs/inventory/endpoint.js +0 -9
- package/dist/cjs/inventory/index.js +0 -26
- package/dist/cjs/linkie/endpoint.js +0 -8
- package/dist/cjs/linkie/index.js +0 -20
- package/dist/cjs/linkie/shortUrl.js +0 -17
- package/dist/cjs/linkie/types.js +0 -2
- package/dist/cjs/order/create.js +0 -17
- package/dist/cjs/order/endpoint.js +0 -8
- package/dist/cjs/order/index.js +0 -10
- package/dist/cjs/order/types.js +0 -2
- package/dist/cjs/payment/components/ProcessPayment.js +0 -266
- package/dist/cjs/payment/endpoint.js +0 -9
- package/dist/cjs/payment/index.js +0 -12
- package/dist/cjs/payment/start.js +0 -38
- package/dist/cjs/payment/types.js +0 -2
- package/dist/cjs/payment/verify.js +0 -17
- package/dist/cjs/sales/endpoint.js +0 -8
- package/dist/cjs/sales/index.js +0 -7
- package/dist/cjs/sales/lead.js +0 -22
- package/dist/cjs/sales/types.js +0 -17
- package/dist/cjs/support/endpoint.js +0 -10
- package/dist/cjs/support/index.js +0 -15
- package/dist/cjs/support/newsletter.js +0 -17
- package/dist/cjs/support/ticket.js +0 -17
- package/dist/cjs/tools/endpoint.js +0 -8
- package/dist/cjs/tools/exchangeRates.js +0 -30
- package/dist/cjs/tools/index.js +0 -10
- package/dist/cjs/types.js +0 -9
- package/dist/cjs/utils/auth.js +0 -23
- package/dist/cjs/utils/handler.js +0 -35
- package/dist/cjs/utils/localStorage.js +0 -137
- package/dist/cjs/utils/share.js +0 -25
- package/dist/types/config/local-storage.d.ts +0 -0
- package/dist/types/config/validate.d.ts +0 -4
- package/dist/types/hooks/index.d.ts +0 -1
- package/dist/types/hooks/useAuth.d.ts +0 -0
- package/dist/types/hooks/usePrivate.d.ts +0 -0
- package/dist/types/hooks/useUser.d.ts +0 -8
- package/dist/types/payment/components/ProcessPayment.d.ts +0 -0
package/dist/cjs/auth/signup.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
const axios_1 = require("../config/axios");
|
|
7
|
-
const handler_1 = __importDefault(require("../config/handler"));
|
|
8
|
-
const route_1 = require("../config/route");
|
|
9
|
-
const signup = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("auth", "v1", "signup"), data, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = signup;
|
package/dist/cjs/auth/types.js
DELETED
package/dist/cjs/config/axios.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
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.linkiePost = exports.chttp = exports.signup = exports.passwordReset = exports.logout = exports.login = exports.patch = exports.get = exports.put = exports.post = exports.http = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const constants_1 = require("./constants");
|
|
9
|
-
const auth_1 = require("../utils/auth");
|
|
10
|
-
const index_1 = require("./index");
|
|
11
|
-
const validate_1 = __importDefault(require("./validate"));
|
|
12
|
-
exports.http = axios_1.default.create({
|
|
13
|
-
withCredentials: true,
|
|
14
|
-
headers: {
|
|
15
|
-
"Access-Control-Allow-Origin": "*",
|
|
16
|
-
"Content-Type": "application/json",
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
exports.http.interceptors.request.use((config) => {
|
|
20
|
-
(0, validate_1.default)(['apiKey', 'apiUrl']);
|
|
21
|
-
const { apiUrl } = (0, index_1.getConfig)();
|
|
22
|
-
config.baseURL = apiUrl;
|
|
23
|
-
if (config.headers) {
|
|
24
|
-
config.headers["Content-Type"] = "application/json";
|
|
25
|
-
config.headers.Authorization = `Bearer ${(0, auth_1.getCookie)()}` || "";
|
|
26
|
-
config.headers["HB-API-KEY"] =
|
|
27
|
-
`Bearer ${(0, index_1.getConfig)().apiKey}` || "";
|
|
28
|
-
}
|
|
29
|
-
return config;
|
|
30
|
-
}, Promise.reject);
|
|
31
|
-
const post = (endpoint, data, config) => new Promise((resolve, reject) => exports.http
|
|
32
|
-
.post(endpoint, data, config)
|
|
33
|
-
.then(resolve)
|
|
34
|
-
.catch((e) => reject(e.response?.data)));
|
|
35
|
-
exports.post = post;
|
|
36
|
-
const put = (endpoint, data, config) => new Promise((resolve, reject) => exports.http
|
|
37
|
-
.put(endpoint, data, config)
|
|
38
|
-
.then(resolve)
|
|
39
|
-
.catch((e) => reject(e.response?.data)));
|
|
40
|
-
exports.put = put;
|
|
41
|
-
const get = (endpoint, config) => {
|
|
42
|
-
// console.log('Get Request Config :', config);
|
|
43
|
-
return new Promise((resolve, reject) => exports.http
|
|
44
|
-
.get(endpoint, config)
|
|
45
|
-
.then(resolve)
|
|
46
|
-
.catch((e) => reject(e.response?.data)));
|
|
47
|
-
};
|
|
48
|
-
exports.get = get;
|
|
49
|
-
const patch = (endpoint, data) => new Promise((resolve, reject) => exports.http
|
|
50
|
-
.patch(endpoint, data)
|
|
51
|
-
.then(resolve)
|
|
52
|
-
.catch((e) => reject(e.response.data)));
|
|
53
|
-
exports.patch = patch;
|
|
54
|
-
const login = (data) => (0, exports.post)("passport/basic/login", data);
|
|
55
|
-
exports.login = login;
|
|
56
|
-
const logout = () => (0, exports.post)("user/logout");
|
|
57
|
-
exports.logout = logout;
|
|
58
|
-
const passwordReset = (data) => (0, exports.post)("user/reset-password", data);
|
|
59
|
-
exports.passwordReset = passwordReset;
|
|
60
|
-
const signup = (data) => (0, exports.post)("passport/basic/signup", data);
|
|
61
|
-
exports.signup = signup;
|
|
62
|
-
/* ======================================================================================================= */
|
|
63
|
-
/* ------------------------------------ For Linkie App --------------------------------------------------- */
|
|
64
|
-
/* ======================================================================================================= */
|
|
65
|
-
exports.chttp = axios_1.default.create({
|
|
66
|
-
withCredentials: true,
|
|
67
|
-
headers: {
|
|
68
|
-
"Access-Control-Allow-Origin": "*",
|
|
69
|
-
"Content-Type": "application/json",
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
exports.chttp.interceptors.request.use((config) => {
|
|
73
|
-
(0, validate_1.default)(['apiKey', 'tokenKey', 'linkieUrl']);
|
|
74
|
-
const { linkieUrl } = (0, index_1.getConfig)();
|
|
75
|
-
config.baseURL = linkieUrl;
|
|
76
|
-
if (config.headers) {
|
|
77
|
-
config.headers["Content-Type"] = "application/json";
|
|
78
|
-
config.headers.Authorization = localStorage.getItem(constants_1.TOKEN_KEY) || "";
|
|
79
|
-
config.headers["HB-API-KEY"] =
|
|
80
|
-
`Bearer ${(0, index_1.getConfig)().apiKey}` || "";
|
|
81
|
-
}
|
|
82
|
-
return config;
|
|
83
|
-
}, Promise.reject);
|
|
84
|
-
// chttp.interceptors.response.use(
|
|
85
|
-
// (response) => response,
|
|
86
|
-
// async (error) => {
|
|
87
|
-
// if (error.code === "ERR_NETWORK") {
|
|
88
|
-
// return Promise.reject(error);
|
|
89
|
-
// }
|
|
90
|
-
// const refreshToken = localStorage.getItem(REFRESH_TOKEN_KEY);
|
|
91
|
-
// if (!refreshToken) {
|
|
92
|
-
// return Promise.reject(error);
|
|
93
|
-
// }
|
|
94
|
-
// // const originalRequest = error.config;
|
|
95
|
-
// // if (error.response.status === 401 && !originalRequest._retry) {
|
|
96
|
-
// // originalRequest._retry = true;
|
|
97
|
-
// // if (http.defaults.headers) {
|
|
98
|
-
// // http.defaults.headers.Authorization = `Bearer ${refreshToken}`;
|
|
99
|
-
// // }
|
|
100
|
-
// // try {
|
|
101
|
-
// // const res = await post('auth/token');
|
|
102
|
-
// // const { access_token, threshold } = res.data;
|
|
103
|
-
// // // handleItem(TOKEN_KEY, access_token);
|
|
104
|
-
// // // handleItem(TOKEN_THRESHOLD_KEY, setThreshold(threshold));
|
|
105
|
-
// // if (http.defaults.headers) {
|
|
106
|
-
// // http.defaults.headers.Authorization = access_token;
|
|
107
|
-
// // }
|
|
108
|
-
// // return await http(originalRequest);
|
|
109
|
-
// // } catch (reason) {
|
|
110
|
-
// // return Promise.reject(reason);
|
|
111
|
-
// // }
|
|
112
|
-
// // }
|
|
113
|
-
// return Promise.reject(error);
|
|
114
|
-
// },
|
|
115
|
-
// );
|
|
116
|
-
const linkiePost = (endpoint, data, config) => new Promise((resolve, reject) => exports.chttp
|
|
117
|
-
.post(endpoint, data, config)
|
|
118
|
-
.then(resolve)
|
|
119
|
-
.catch((e) => reject(e.response?.data)));
|
|
120
|
-
exports.linkiePost = linkiePost;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PASSWORD_REGEX = exports.EMAIL_REGEX = exports.AD_CLIENT = exports.TOKEN_THRESHOLD_KEY = exports.REFRESH_TOKEN_KEY = exports.TOKEN_KEY = exports.SITE_NAME = void 0;
|
|
4
|
-
exports.SITE_NAME = "Helpdice";
|
|
5
|
-
exports.TOKEN_KEY = "access-token";
|
|
6
|
-
exports.REFRESH_TOKEN_KEY = "refresh-token";
|
|
7
|
-
exports.TOKEN_THRESHOLD_KEY = "access-token-threshold";
|
|
8
|
-
exports.AD_CLIENT = "ca-pub-7034818195807373";
|
|
9
|
-
/* eslint-disable */
|
|
10
|
-
exports.EMAIL_REGEX = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/;
|
|
11
|
-
exports.PASSWORD_REGEX = /.{8,}/;
|
|
12
|
-
/* eslint-enable */
|
package/dist/cjs/config/fetch.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const axios_1 = require("./axios");
|
|
4
|
-
async function fetch(url, config) {
|
|
5
|
-
// Define states
|
|
6
|
-
let state = {
|
|
7
|
-
loading: true,
|
|
8
|
-
data: null,
|
|
9
|
-
error: null,
|
|
10
|
-
settled: false,
|
|
11
|
-
};
|
|
12
|
-
// Update state to reflect loading
|
|
13
|
-
// console.log('Loading:', state.loading);
|
|
14
|
-
await (0, axios_1.get)(url, config)
|
|
15
|
-
.then((response) => {
|
|
16
|
-
// Update state on success
|
|
17
|
-
state = {
|
|
18
|
-
loading: false,
|
|
19
|
-
data: response.data,
|
|
20
|
-
error: null,
|
|
21
|
-
settled: true,
|
|
22
|
-
};
|
|
23
|
-
// console.log('Success:', state);
|
|
24
|
-
})
|
|
25
|
-
.catch((error) => {
|
|
26
|
-
// Update state on error
|
|
27
|
-
state = {
|
|
28
|
-
loading: false,
|
|
29
|
-
data: null,
|
|
30
|
-
error: error.message,
|
|
31
|
-
settled: true,
|
|
32
|
-
};
|
|
33
|
-
// console.log('Error:', state);
|
|
34
|
-
});
|
|
35
|
-
return state;
|
|
36
|
-
}
|
|
37
|
-
exports.default = fetch;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// The fetchDataWithCallbacks function that accepts a Promise and a callbacks object
|
|
4
|
-
async function handler(promise, callbacks) {
|
|
5
|
-
// Destructure callbacks from the object
|
|
6
|
-
const { onFetching, onSuccess, onError, onSettled } = callbacks ?? {};
|
|
7
|
-
// Call the onFetching callback before making the request
|
|
8
|
-
if (onFetching)
|
|
9
|
-
onFetching();
|
|
10
|
-
// Handle the Promise passed as an argument
|
|
11
|
-
promise
|
|
12
|
-
.then((response) => {
|
|
13
|
-
// Call the onSuccess callback if the Promise resolves successfully
|
|
14
|
-
if (onSuccess)
|
|
15
|
-
onSuccess({
|
|
16
|
-
data: response.data,
|
|
17
|
-
status: response.status,
|
|
18
|
-
statusText: response.statusText,
|
|
19
|
-
});
|
|
20
|
-
})
|
|
21
|
-
.catch((error) => {
|
|
22
|
-
// Call the onError callback if the Promise is rejected
|
|
23
|
-
if (onError)
|
|
24
|
-
onError(error);
|
|
25
|
-
})
|
|
26
|
-
.finally(() => {
|
|
27
|
-
// Call the onSettled callback after the Promise is settled
|
|
28
|
-
if (onSettled)
|
|
29
|
-
onSettled();
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
exports.default = handler;
|
package/dist/cjs/config/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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.initializeSDK = initializeSDK;
|
|
7
|
-
exports.getFirebase = getFirebase;
|
|
8
|
-
exports.getConfig = getConfig;
|
|
9
|
-
const app_1 = __importDefault(require("firebase/compat/app"));
|
|
10
|
-
const validate_1 = __importDefault(require("./validate"));
|
|
11
|
-
let config = {
|
|
12
|
-
tokenKey: '',
|
|
13
|
-
apiKey: null,
|
|
14
|
-
apiUrl: 'https://api.helpdice.com',
|
|
15
|
-
appUrl: '',
|
|
16
|
-
apisUrl: 'https://apis.helpdice.com',
|
|
17
|
-
environment: 'production',
|
|
18
|
-
firebase: undefined
|
|
19
|
-
};
|
|
20
|
-
function initializeSDK(newConfig) {
|
|
21
|
-
config = { ...config, ...newConfig };
|
|
22
|
-
(0, validate_1.default)(['apiKey', 'tokenKey']);
|
|
23
|
-
}
|
|
24
|
-
function getFirebase() {
|
|
25
|
-
(0, validate_1.default)(['firebase']);
|
|
26
|
-
const appConfig = getConfig();
|
|
27
|
-
if (appConfig.firebase) {
|
|
28
|
-
// if (firebase?.default != undefined) {
|
|
29
|
-
// return firebase.default.initializeApp(appConfig.firebase)
|
|
30
|
-
// }
|
|
31
|
-
return app_1.default.initializeApp(appConfig.firebase);
|
|
32
|
-
}
|
|
33
|
-
throw new Error(`SDK configuration error: Firebase is not configured properly`);
|
|
34
|
-
}
|
|
35
|
-
function getConfig() {
|
|
36
|
-
return config;
|
|
37
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import { add, getUnixTime } from 'date-fns';
|
|
3
|
-
// import { AuthAction } from '@store/interfaces';
|
|
4
|
-
// import { REFRESH_TOKEN_KEY, TOKEN_KEY, TOKEN_THRESHOLD_KEY } from './constants';
|
|
5
|
-
// export const setThreshold = (time: number): string =>
|
|
6
|
-
// getUnixTime(
|
|
7
|
-
// add(new Date(), {
|
|
8
|
-
// seconds: time || 3600,
|
|
9
|
-
// }),
|
|
10
|
-
// ).toString();
|
|
11
|
-
// export const handleItem = (key: string, value?: string): void => {
|
|
12
|
-
// if (value) {
|
|
13
|
-
// localStorage.setItem(key, value);
|
|
14
|
-
// } else {
|
|
15
|
-
// localStorage.removeItem(key);
|
|
16
|
-
// }
|
|
17
|
-
// };
|
|
18
|
-
// /* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
19
|
-
// export const setItems = (data: any): void => {
|
|
20
|
-
// handleItem(TOKEN_KEY, data!.token);
|
|
21
|
-
// handleItem(TOKEN_THRESHOLD_KEY, setThreshold(data!.threshold!));
|
|
22
|
-
// handleItem(REFRESH_TOKEN_KEY, data!.refreshToken);
|
|
23
|
-
// };
|
|
24
|
-
// /* eslint-enable @typescript-eslint/no-non-null-assertion */
|
|
25
|
-
// export const removeItems = (): void => {
|
|
26
|
-
// handleItem(TOKEN_KEY);
|
|
27
|
-
// handleItem(TOKEN_THRESHOLD_KEY);
|
|
28
|
-
// handleItem(REFRESH_TOKEN_KEY);
|
|
29
|
-
// };
|
package/dist/cjs/config/route.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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.getUrl = getUrl;
|
|
7
|
-
const endpoint_1 = __importDefault(require("../account/endpoint"));
|
|
8
|
-
const endpoint_2 = __importDefault(require("../accounting/endpoint"));
|
|
9
|
-
const endpoint_3 = __importDefault(require("../assets/endpoint"));
|
|
10
|
-
const endpoint_4 = __importDefault(require("../auth/endpoint"));
|
|
11
|
-
const endpoint_5 = __importDefault(require("../content/endpoint"));
|
|
12
|
-
const endpoint_6 = __importDefault(require("../inventory/endpoint"));
|
|
13
|
-
const endpoint_7 = __importDefault(require("../linkie/endpoint"));
|
|
14
|
-
const endpoint_8 = __importDefault(require("../payment/endpoint"));
|
|
15
|
-
const endpoint_9 = __importDefault(require("../sales/endpoint"));
|
|
16
|
-
const endpoint_10 = __importDefault(require("../support/endpoint"));
|
|
17
|
-
const endpoint_11 = __importDefault(require("../tools/endpoint"));
|
|
18
|
-
const urls = {
|
|
19
|
-
auth: endpoint_4.default,
|
|
20
|
-
cms: endpoint_5.default,
|
|
21
|
-
account: endpoint_1.default,
|
|
22
|
-
accounting: endpoint_2.default,
|
|
23
|
-
support: endpoint_10.default,
|
|
24
|
-
assets: endpoint_3.default,
|
|
25
|
-
payment: endpoint_8.default,
|
|
26
|
-
inventory: endpoint_6.default,
|
|
27
|
-
tools: endpoint_11.default,
|
|
28
|
-
sales: endpoint_9.default,
|
|
29
|
-
linkie: endpoint_7.default
|
|
30
|
-
};
|
|
31
|
-
// Function to get the URL dynamically based on category, version, and action
|
|
32
|
-
function getUrl(category, version, action, omitCategory = false) {
|
|
33
|
-
const categoryData = urls[category]; // Access the correct category dynamically
|
|
34
|
-
if (categoryData) {
|
|
35
|
-
const versionData = categoryData[version]; // Access the correct version dynamically
|
|
36
|
-
// console.log(versionData?.[action]);
|
|
37
|
-
if (versionData !== undefined) {
|
|
38
|
-
console.log(versionData[action]);
|
|
39
|
-
if (omitCategory) {
|
|
40
|
-
return `/api/${version}/${versionData[action]}`;
|
|
41
|
-
}
|
|
42
|
-
return `/api/${version}/${category}/${versionData[action]}`; // Construct the URL
|
|
43
|
-
}
|
|
44
|
-
throw new Error(`Invalid action: ${action} for version: ${version} in category: ${category}`);
|
|
45
|
-
}
|
|
46
|
-
throw new Error(`Invalid category: ${category}`);
|
|
47
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// validateConfig
|
|
4
|
-
const index_1 = require("./index");
|
|
5
|
-
function validateConfig(requiredKeys) {
|
|
6
|
-
const config = (0, index_1.getConfig)();
|
|
7
|
-
const missingKeys = requiredKeys.filter((key) => {
|
|
8
|
-
return !config[key]; // null, undefined, empty string → treated as missing
|
|
9
|
-
});
|
|
10
|
-
if (missingKeys.length > 0) {
|
|
11
|
-
throw new Error(`SDK configuration error: Missing required config value(s): ${missingKeys.join(', ')}\n` +
|
|
12
|
-
'👉 Please ensure these keys are set using setConfig({ ... }) before making requests.');
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.default = validateConfig;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const cms = {
|
|
4
|
-
v1: {
|
|
5
|
-
article: "article",
|
|
6
|
-
articles: "articles",
|
|
7
|
-
articleCategories: "article/categories",
|
|
8
|
-
mcq: "mcq",
|
|
9
|
-
mcqs: "mcqs",
|
|
10
|
-
all_mcqs: "mcqs/all",
|
|
11
|
-
mcqCategories: "mcq/categories",
|
|
12
|
-
qna: "qna",
|
|
13
|
-
qnas: "qnas",
|
|
14
|
-
qnaCategories: "qna/categories",
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
exports.default = cms;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const axios_1 = require("../config/axios");
|
|
4
|
-
const route_1 = require("../config/route");
|
|
5
|
-
const Content = {
|
|
6
|
-
article: (slug) => (0, axios_1.get)((0, route_1.getUrl)("cms", "v1", "article"), {
|
|
7
|
-
params: {
|
|
8
|
-
slug,
|
|
9
|
-
},
|
|
10
|
-
}),
|
|
11
|
-
articles: (config) => (0, axios_1.get)((0, route_1.getUrl)("cms", "v1", "articles"), config),
|
|
12
|
-
articleCategories: (config) => (0, axios_1.get)((0, route_1.getUrl)("cms", "v1", "articleCategories"), config),
|
|
13
|
-
mcq: (slug) => (0, axios_1.get)((0, route_1.getUrl)("cms", "v1", "mcq"), {
|
|
14
|
-
params: {
|
|
15
|
-
slug,
|
|
16
|
-
},
|
|
17
|
-
}),
|
|
18
|
-
mcqs: (config) => (0, axios_1.get)((0, route_1.getUrl)("cms", "v1", "mcqs"), config),
|
|
19
|
-
allMcqs: (config) => (0, axios_1.get)((0, route_1.getUrl)("cms", "v1", "all_mcqs"), config),
|
|
20
|
-
mcqsCategories: (config) => (0, axios_1.get)((0, route_1.getUrl)("cms", "v1", "mcqCategories"), config),
|
|
21
|
-
qna: (slug) => (0, axios_1.get)((0, route_1.getUrl)("cms", "v1", "qna"), {
|
|
22
|
-
params: {
|
|
23
|
-
slug,
|
|
24
|
-
},
|
|
25
|
-
}),
|
|
26
|
-
qnas: (config) => (0, axios_1.get)((0, route_1.getUrl)("cms", "v1", "qnas"), config),
|
|
27
|
-
qnasCategories: (config) => (0, axios_1.get)((0, route_1.getUrl)("cms", "v1", "qnaCategories"), config),
|
|
28
|
-
};
|
|
29
|
-
exports.default = Content;
|
package/dist/cjs/hooks/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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.useUser = void 0;
|
|
7
|
-
// export { default as usePrivate } from "./usePrivate"
|
|
8
|
-
var useUser_1 = require("./useUser");
|
|
9
|
-
Object.defineProperty(exports, "useUser", { enumerable: true, get: function () { return __importDefault(useUser_1).default; } });
|
|
10
|
-
// export { default as useAuth } from './useAuth'
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// import cookie from "js-cookie";
|
|
3
|
-
// import Router from "next/router";
|
|
4
|
-
// import useUser from "./useUser";
|
|
5
|
-
// const useAuth = () => {
|
|
6
|
-
// const { mutate } = useUser();
|
|
7
|
-
// const login = (
|
|
8
|
-
// token: string,
|
|
9
|
-
// url: string = "/",
|
|
10
|
-
// noRedirect: boolean = false
|
|
11
|
-
// ) => {
|
|
12
|
-
// cookie.set("token", token, { expires: 1 });
|
|
13
|
-
// mutate();
|
|
14
|
-
// !noRedirect && Router.push(url);
|
|
15
|
-
// };
|
|
16
|
-
// const logout = () => {
|
|
17
|
-
// cookie.remove("token");
|
|
18
|
-
// mutate();
|
|
19
|
-
// Router.replace("/");
|
|
20
|
-
// };
|
|
21
|
-
// return { login, logout };
|
|
22
|
-
// };
|
|
23
|
-
// export default useAuth;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// "use client"
|
|
3
|
-
// import { useEffect } from "react";
|
|
4
|
-
// import Router from "next/router";
|
|
5
|
-
// import { isAuth } from "../utils/auth";
|
|
6
|
-
// const usePrivate = () => {
|
|
7
|
-
// const authenticated = isAuth();
|
|
8
|
-
// useEffect(() => {
|
|
9
|
-
// if (!authenticated) {
|
|
10
|
-
// Router.replace("/auth");
|
|
11
|
-
// }
|
|
12
|
-
// }, [authenticated]);
|
|
13
|
-
// return authenticated;
|
|
14
|
-
// };
|
|
15
|
-
// export default usePrivate;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const swr_1 = __importDefault(require("swr"));
|
|
8
|
-
const index_1 = __importDefault(require("../account/index"));
|
|
9
|
-
const route_1 = require("../config/route");
|
|
10
|
-
const useUser = () => {
|
|
11
|
-
const { data: user, error, isLoading, mutate, } = (0, swr_1.default)((0, route_1.getUrl)("account", "v1", "profile"), index_1.default.profile);
|
|
12
|
-
const loggedOut = error && error.status === 403;
|
|
13
|
-
return { user, isLoading, error, loggedOut, mutate };
|
|
14
|
-
};
|
|
15
|
-
exports.default = useUser;
|
package/dist/cjs/index.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.getUrl = exports.getCookie = exports.initializeSDK = exports.getConfig = exports.Apis = exports.Linkie = exports.Tools = exports.Inventory = exports.Sales = exports.shareUrl = exports.Account = exports.Assets = exports.Support = exports.Accounting = exports.Content = exports.Payment = exports.Order = exports.Auth = void 0;
|
|
21
|
-
var auth_1 = require("./auth");
|
|
22
|
-
Object.defineProperty(exports, "Auth", { enumerable: true, get: function () { return __importDefault(auth_1).default; } });
|
|
23
|
-
var order_1 = require("./order");
|
|
24
|
-
Object.defineProperty(exports, "Order", { enumerable: true, get: function () { return __importDefault(order_1).default; } });
|
|
25
|
-
var payment_1 = require("./payment");
|
|
26
|
-
Object.defineProperty(exports, "Payment", { enumerable: true, get: function () { return __importDefault(payment_1).default; } });
|
|
27
|
-
var content_1 = require("./content");
|
|
28
|
-
Object.defineProperty(exports, "Content", { enumerable: true, get: function () { return __importDefault(content_1).default; } });
|
|
29
|
-
var accounting_1 = require("./accounting");
|
|
30
|
-
Object.defineProperty(exports, "Accounting", { enumerable: true, get: function () { return __importDefault(accounting_1).default; } });
|
|
31
|
-
var support_1 = require("./support");
|
|
32
|
-
Object.defineProperty(exports, "Support", { enumerable: true, get: function () { return __importDefault(support_1).default; } });
|
|
33
|
-
var assets_1 = require("./assets");
|
|
34
|
-
Object.defineProperty(exports, "Assets", { enumerable: true, get: function () { return __importDefault(assets_1).default; } });
|
|
35
|
-
var account_1 = require("./account");
|
|
36
|
-
Object.defineProperty(exports, "Account", { enumerable: true, get: function () { return __importDefault(account_1).default; } });
|
|
37
|
-
var share_1 = require("./utils/share");
|
|
38
|
-
Object.defineProperty(exports, "shareUrl", { enumerable: true, get: function () { return __importDefault(share_1).default; } });
|
|
39
|
-
var sales_1 = require("./sales");
|
|
40
|
-
Object.defineProperty(exports, "Sales", { enumerable: true, get: function () { return __importDefault(sales_1).default; } });
|
|
41
|
-
var inventory_1 = require("./inventory");
|
|
42
|
-
Object.defineProperty(exports, "Inventory", { enumerable: true, get: function () { return __importDefault(inventory_1).default; } });
|
|
43
|
-
var tools_1 = require("./tools");
|
|
44
|
-
Object.defineProperty(exports, "Tools", { enumerable: true, get: function () { return __importDefault(tools_1).default; } });
|
|
45
|
-
var linkie_1 = require("./linkie");
|
|
46
|
-
Object.defineProperty(exports, "Linkie", { enumerable: true, get: function () { return __importDefault(linkie_1).default; } });
|
|
47
|
-
var apis_1 = require("./apis");
|
|
48
|
-
Object.defineProperty(exports, "Apis", { enumerable: true, get: function () { return __importDefault(apis_1).default; } });
|
|
49
|
-
var config_1 = require("./config");
|
|
50
|
-
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return config_1.getConfig; } });
|
|
51
|
-
Object.defineProperty(exports, "initializeSDK", { enumerable: true, get: function () { return config_1.initializeSDK; } });
|
|
52
|
-
// export { useUser, usePrivate, useAuth } from './hooks';
|
|
53
|
-
// export { isAuth } from './utils/auth';
|
|
54
|
-
var auth_2 = require("./utils/auth");
|
|
55
|
-
Object.defineProperty(exports, "getCookie", { enumerable: true, get: function () { return auth_2.getCookie; } });
|
|
56
|
-
var route_1 = require("./config/route");
|
|
57
|
-
Object.defineProperty(exports, "getUrl", { enumerable: true, get: function () { return route_1.getUrl; } });
|
|
58
|
-
// Types
|
|
59
|
-
__exportStar(require("./sales"), exports);
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const axios_1 = require("../config/axios");
|
|
4
|
-
const route_1 = require("../config/route");
|
|
5
|
-
const Inventory = {
|
|
6
|
-
getStoreById: (id) => (0, axios_1.get)((0, route_1.getUrl)("inventory", "v1", "store"), {
|
|
7
|
-
params: {
|
|
8
|
-
id,
|
|
9
|
-
},
|
|
10
|
-
}),
|
|
11
|
-
getStoreBySlug: (slug) => (0, axios_1.get)((0, route_1.getUrl)("inventory", "v1", "store"), {
|
|
12
|
-
params: {
|
|
13
|
-
slug,
|
|
14
|
-
},
|
|
15
|
-
}),
|
|
16
|
-
getStoreProducts: (slug, category, brand, price, search) => (0, axios_1.get)((0, route_1.getUrl)("inventory", "v1", "store_products"), {
|
|
17
|
-
params: {
|
|
18
|
-
slug,
|
|
19
|
-
category,
|
|
20
|
-
brand,
|
|
21
|
-
price,
|
|
22
|
-
search,
|
|
23
|
-
},
|
|
24
|
-
}),
|
|
25
|
-
};
|
|
26
|
-
exports.default = Inventory;
|
package/dist/cjs/linkie/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
// import cookie from "js-cookie";
|
|
7
|
-
// import { jwtDecode } from "jwt-decode";
|
|
8
|
-
// import type { NextPageContext } from "next";
|
|
9
|
-
// import { getConfig } from "../config/index";
|
|
10
|
-
// import { isAuth } from "../utils/auth";
|
|
11
|
-
// import {
|
|
12
|
-
// getDataFromStorage,
|
|
13
|
-
// setDataInStorage,
|
|
14
|
-
// setEncryptionKey,
|
|
15
|
-
// } from "../utils/localStorage";
|
|
16
|
-
const shortUrl_1 = __importDefault(require("./shortUrl"));
|
|
17
|
-
const Linkie = {
|
|
18
|
-
shortUrl: shortUrl_1.default
|
|
19
|
-
};
|
|
20
|
-
exports.default = Linkie;
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
const axios_1 = require("../config/axios");
|
|
7
|
-
const handler_1 = __importDefault(require("../config/handler"));
|
|
8
|
-
const route_1 = require("../config/route");
|
|
9
|
-
const shortUrl = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.linkiePost)((0, route_1.getUrl)("linkie", "v1", "shorten", true), data, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = shortUrl;
|
package/dist/cjs/linkie/types.js
DELETED
package/dist/cjs/order/create.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
const axios_1 = require("../config/axios");
|
|
7
|
-
const handler_1 = __importDefault(require("../config/handler"));
|
|
8
|
-
const route_1 = require("../config/route");
|
|
9
|
-
const create = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("order", "v1", "create"), data, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = create;
|