@helpdice/sdk 0.4.9 → 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 +65 -23
- package/dist/index.js.map +1 -1
- package/dist/types/config/index.d.ts +2 -24
- package/dist/types/config/state.d.ts +31 -0
- package/dist/types/lms/endpoint.d.ts +1 -0
- package/dist/types/lms/enroll_course.d.ts +2 -2
- package/dist/types/lms/index.d.ts +13 -3
- package/dist/types/lms/post_course.d.ts +2 -2
- package/dist/types/lms/post_session.d.ts +12 -0
- package/dist/types/lms/types.d.ts +18 -4
- 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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { default as firebase } from "firebase/compat/app";
|
|
2
|
+
import { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from "axios";
|
|
3
|
+
export type Config = {
|
|
4
|
+
apiKey: string | null;
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
lmsUrl: string;
|
|
7
|
+
linkieUrl?: string;
|
|
8
|
+
appUrl: string;
|
|
9
|
+
apisUrl: string;
|
|
10
|
+
tokenKey: string;
|
|
11
|
+
environment: string;
|
|
12
|
+
firebase?: FirebaseConfig;
|
|
13
|
+
lmsRequestInceptor?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig;
|
|
14
|
+
lmsResponseInterceptor?: (response: AxiosResponse) => AxiosResponse;
|
|
15
|
+
lmsErrorInterceptor?: (error: AxiosError) => Promise<any>;
|
|
16
|
+
};
|
|
17
|
+
export interface FirebaseConfig {
|
|
18
|
+
apiKey?: string;
|
|
19
|
+
authDomain?: string;
|
|
20
|
+
projectId?: string;
|
|
21
|
+
storageBucket?: string;
|
|
22
|
+
messagingSenderId?: string;
|
|
23
|
+
appId?: string;
|
|
24
|
+
measurementId?: string;
|
|
25
|
+
}
|
|
26
|
+
type ConfigReturn = ReturnType<typeof getConfig>;
|
|
27
|
+
export declare function validateConfig(requiredKeys: (keyof ConfigReturn)[]): Boolean;
|
|
28
|
+
export declare function initializeSDK(newConfig: Partial<Config>): void;
|
|
29
|
+
export declare function getFirebase(): firebase.app.App;
|
|
30
|
+
export declare function getConfig(): Config;
|
|
31
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AuthRequestParams } from "../auth/types";
|
|
2
|
-
import type {
|
|
3
|
-
declare const enrollCourse: (data:
|
|
2
|
+
import type { Enroll } from "./types";
|
|
3
|
+
declare const enrollCourse: (data: Enroll, { config, onFetching, onSuccess, onError, onSettled }: {
|
|
4
4
|
onFetching?: () => void;
|
|
5
5
|
onSuccess?: (data: object) => void;
|
|
6
6
|
onError?: (error: string) => void;
|
|
@@ -6,7 +6,8 @@ declare const LMS: {
|
|
|
6
6
|
getMyCourses: () => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
7
7
|
getEnrollStudents: () => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
8
8
|
getCourseProgress: (id: string) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
9
|
-
|
|
9
|
+
getUserSession: (id: string) => Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
10
|
+
postCourse: (data: import("./types").Course, { config, onFetching, onSuccess, onError, onSettled }: {
|
|
10
11
|
onFetching?: () => void;
|
|
11
12
|
onSuccess?: (data: object) => void;
|
|
12
13
|
onError?: (error: string) => void;
|
|
@@ -33,7 +34,16 @@ declare const LMS: {
|
|
|
33
34
|
params: import("../auth/types").AuthRequestParams;
|
|
34
35
|
};
|
|
35
36
|
}) => Promise<void>;
|
|
36
|
-
enrollCourse: (data: import("./types").
|
|
37
|
+
enrollCourse: (data: import("./types").Enroll, { config, onFetching, onSuccess, onError, onSettled }: {
|
|
38
|
+
onFetching?: () => void;
|
|
39
|
+
onSuccess?: (data: object) => void;
|
|
40
|
+
onError?: (error: string) => void;
|
|
41
|
+
onSettled?: () => void;
|
|
42
|
+
config?: {
|
|
43
|
+
params: import("../auth/types").AuthRequestParams;
|
|
44
|
+
};
|
|
45
|
+
}) => Promise<void>;
|
|
46
|
+
postSession: (data: import("./types").Session, { config, onFetching, onSuccess, onError, onSettled }: {
|
|
37
47
|
onFetching?: () => void;
|
|
38
48
|
onSuccess?: (data: object) => void;
|
|
39
49
|
onError?: (error: string) => void;
|
|
@@ -43,5 +53,5 @@ declare const LMS: {
|
|
|
43
53
|
};
|
|
44
54
|
}) => Promise<void>;
|
|
45
55
|
};
|
|
46
|
-
export type {
|
|
56
|
+
export type { Enroll } from "./types";
|
|
47
57
|
export default LMS;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AuthRequestParams } from "../auth/types";
|
|
2
|
-
import type {
|
|
3
|
-
declare const postCourse: (data:
|
|
2
|
+
import type { Course } from "./types";
|
|
3
|
+
declare const postCourse: (data: Course, { config, onFetching, onSuccess, onError, onSettled }: {
|
|
4
4
|
onFetching?: () => void;
|
|
5
5
|
onSuccess?: (data: object) => void;
|
|
6
6
|
onError?: (error: string) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AuthRequestParams } from "../auth/types";
|
|
2
|
+
import type { Session } from "./types";
|
|
3
|
+
declare const postSession: (data: Session, { config, onFetching, onSuccess, onError, onSettled }: {
|
|
4
|
+
onFetching?: () => void;
|
|
5
|
+
onSuccess?: (data: object) => void;
|
|
6
|
+
onError?: (error: string) => void;
|
|
7
|
+
onSettled?: () => void;
|
|
8
|
+
config?: {
|
|
9
|
+
params: AuthRequestParams;
|
|
10
|
+
};
|
|
11
|
+
}) => Promise<void>;
|
|
12
|
+
export default postSession;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface Course {
|
|
2
2
|
id?: string;
|
|
3
|
-
title
|
|
4
|
-
description
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
category: string;
|
|
6
|
+
thumbnailUrl: string;
|
|
7
|
+
price: string;
|
|
8
|
+
}
|
|
9
|
+
interface Enroll {
|
|
10
|
+
user: string;
|
|
11
|
+
course: string;
|
|
5
12
|
}
|
|
6
13
|
interface Module {
|
|
7
14
|
course?: string;
|
|
@@ -22,4 +29,11 @@ interface ModuleProgress {
|
|
|
22
29
|
completed?: Boolean;
|
|
23
30
|
lastAccessedAt: Date;
|
|
24
31
|
}
|
|
25
|
-
|
|
32
|
+
interface Session {
|
|
33
|
+
name: string;
|
|
34
|
+
start: Date;
|
|
35
|
+
end: Date;
|
|
36
|
+
url: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
}
|
|
39
|
+
export type { Enroll, Module, ModuleProgress, Session, Course };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helpdice/sdk",
|
|
3
3
|
"description": "A backend API-based SDK (Software Development Kit) provides developers with pre-built tools and libraries to interact seamlessly with a backend server or service. It simplifies the process of integrating external functionality, such as authentication, data storage, or third-party services, into applications. The SDK typically includes API endpoints, functions, and documentation, allowing developers to make requests, handle responses, and manage errors efficiently. By abstracting complex backend logic, it speeds up development, reduces coding errors, and ensures consistent interactions with the backend, making it easier to build scalable, secure, and feature-rich applications.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
@@ -32,27 +32,27 @@
|
|
|
32
32
|
"@biomejs/biome": "1.8.3",
|
|
33
33
|
"@changesets/cli": "^2.27.7",
|
|
34
34
|
"@rollup/plugin-typescript": "^11.1.3",
|
|
35
|
-
"rollup": "^4.3.0",
|
|
36
35
|
"@total-typescript/tsconfig": "^1.0.4",
|
|
37
36
|
"@types/crypto-js": "^4.2.2",
|
|
38
37
|
"@types/js-cookie": "^3.0.6",
|
|
39
38
|
"@types/react": "^19.0.8",
|
|
39
|
+
"axios": "^1.12.2",
|
|
40
|
+
"crypto-js": "^4.2.0",
|
|
41
|
+
"firebase": "^11.2.0",
|
|
42
|
+
"js-cookie": "^3.0.5",
|
|
43
|
+
"jwt-decode": "^4.0.0",
|
|
44
|
+
"rollup": "^4.3.0",
|
|
40
45
|
"typescript": "^5.5.3"
|
|
41
46
|
},
|
|
42
47
|
"bugs": {
|
|
43
48
|
"url": "https://github.com/helpdice/sdk/issues"
|
|
44
49
|
},
|
|
45
|
-
"
|
|
50
|
+
"peerDependencies": {
|
|
46
51
|
"axios": "^1.12.2",
|
|
47
52
|
"crypto-js": "^4.2.0",
|
|
48
53
|
"firebase": "^11.2.0",
|
|
49
|
-
"fs": "^0.0.1-security",
|
|
50
|
-
"fs-extra": "^11.3.0",
|
|
51
54
|
"js-cookie": "^3.0.5",
|
|
52
|
-
"jwt-decode": "^4.0.0"
|
|
53
|
-
"nookies": "^2.5.2",
|
|
54
|
-
"swr": "^2.3.0",
|
|
55
|
-
"zod": "^3.24.1"
|
|
55
|
+
"jwt-decode": "^4.0.0"
|
|
56
56
|
},
|
|
57
57
|
"packageManager": "pnpm@9.6.0+sha512.38dc6fba8dba35b39340b9700112c2fe1e12f10b17134715a4aa98ccf7bb035e76fd981cf0bb384dfa98f8d6af5481c2bef2f4266a24bfa20c34eb7147ce0b5e"
|
|
58
58
|
}
|
|
@@ -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 route_1 = require("../config/route");
|
|
8
|
-
const update_profile_1 = __importDefault(require("./update_profile"));
|
|
9
|
-
const Account = {
|
|
10
|
-
profile: (id) => (0, axios_1.get)((0, route_1.getUrl)("account", "v1", "profile"), {
|
|
11
|
-
params: {
|
|
12
|
-
id,
|
|
13
|
-
},
|
|
14
|
-
}),
|
|
15
|
-
updateProfile: update_profile_1.default,
|
|
16
|
-
};
|
|
17
|
-
exports.default = Account;
|
|
@@ -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 updateProfile = (data, { config, onFetching, onSuccess, onError, onSettled }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.put)((0, route_1.getUrl)("account", "v1", "profile"), data, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = updateProfile;
|
|
@@ -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 createInvoice = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("accounting", "v1", "invoice"), data, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = createInvoice;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const accounting = {
|
|
4
|
-
v1: {
|
|
5
|
-
item: "item",
|
|
6
|
-
items: "items",
|
|
7
|
-
invoice: "invoice",
|
|
8
|
-
submit_invoice: "invoice/submit",
|
|
9
|
-
invoices: "invoices",
|
|
10
|
-
item_categories: "item/category",
|
|
11
|
-
item_brands: "item/brand",
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
exports.default = accounting;
|
|
@@ -1,25 +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 route_1 = require("../config/route");
|
|
8
|
-
const createInvoice_1 = __importDefault(require("./createInvoice"));
|
|
9
|
-
const submitInvoice_1 = __importDefault(require("./submitInvoice"));
|
|
10
|
-
const updateInvoice_1 = __importDefault(require("./updateInvoice"));
|
|
11
|
-
const Accounting = {
|
|
12
|
-
item: (slug) => (0, axios_1.get)((0, route_1.getUrl)("accounting", "v1", "item"), {
|
|
13
|
-
params: {
|
|
14
|
-
slug,
|
|
15
|
-
},
|
|
16
|
-
}),
|
|
17
|
-
items: (config) => (0, axios_1.get)((0, route_1.getUrl)("accounting", "v1", "items"), config),
|
|
18
|
-
createInvoice: createInvoice_1.default,
|
|
19
|
-
updateInvoice: updateInvoice_1.default,
|
|
20
|
-
invoices: (config) => (0, axios_1.get)((0, route_1.getUrl)("accounting", "v1", "invoices"), config),
|
|
21
|
-
submitInvoice: submitInvoice_1.default,
|
|
22
|
-
itemCategories: () => (0, axios_1.get)((0, route_1.getUrl)("accounting", "v1", "item_categories")),
|
|
23
|
-
itemBrands: () => (0, axios_1.get)((0, route_1.getUrl)("accounting", "v1", "item_brands")),
|
|
24
|
-
};
|
|
25
|
-
exports.default = Accounting;
|
|
@@ -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 submitInvoice = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("accounting", "v1", "submit_invoice"), data, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = submitInvoice;
|
|
@@ -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 updateInvoice = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.put)((0, route_1.getUrl)("accounting", "v1", "invoice"), data, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = updateInvoice;
|
package/dist/cjs/apis/cities.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 config_1 = require("../config");
|
|
9
|
-
const getCities = ({ config, onFetching, onSuccess, onError, onSettled }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.get)(`${(0, config_1.getConfig)().apisUrl}/api/countries/v1/city`, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = getCities;
|
|
@@ -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 config_1 = require("../config");
|
|
9
|
-
const getCountries = ({ config, onFetching, onSuccess, onError, onSettled }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.get)(`${(0, config_1.getConfig)().apisUrl}/api/countries/v1`, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = getCountries;
|
package/dist/cjs/apis/index.js
DELETED
|
@@ -1,14 +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 cities_1 = __importDefault(require("./cities"));
|
|
7
|
-
const countries_1 = __importDefault(require("./countries"));
|
|
8
|
-
const states_1 = __importDefault(require("./states"));
|
|
9
|
-
const Apis = {
|
|
10
|
-
getCountries: countries_1.default,
|
|
11
|
-
getStates: states_1.default,
|
|
12
|
-
getCities: cities_1.default
|
|
13
|
-
};
|
|
14
|
-
exports.default = Apis;
|
package/dist/cjs/apis/states.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 index_1 = require("../config/index");
|
|
9
|
-
const getStates = ({ config, onFetching, onSuccess, onError, onSettled }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.get)(`${(0, index_1.getConfig)().apisUrl}/api/countries/v1/state`, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = getStates;
|
package/dist/cjs/assets/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_1 = require("../config/index");
|
|
4
|
-
const route_1 = require("../config/route");
|
|
5
|
-
const Assets = {
|
|
6
|
-
images: {
|
|
7
|
-
imagePlaceholder: (0, index_1.getConfig)().apiUrl + (0, route_1.getUrl)("assets", "v1", "imagePlaceholder"),
|
|
8
|
-
avatar: (0, index_1.getConfig)().apiUrl + (0, route_1.getUrl)("assets", "v1", "avatar"),
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
exports.default = Assets;
|
|
@@ -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 authWithKey = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("auth", "v1", "auth_with_key"), data, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = authWithKey;
|
|
@@ -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 authWithToken = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("auth", "v1", "auth_with_token"), data, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = authWithToken;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const auth = {
|
|
4
|
-
v1: {
|
|
5
|
-
signin: "signin",
|
|
6
|
-
register: "signup",
|
|
7
|
-
signup: "register",
|
|
8
|
-
logout: "logout",
|
|
9
|
-
auth_with_token: "authenticate",
|
|
10
|
-
auth_with_key: "verify",
|
|
11
|
-
reset_password: "recovery-password",
|
|
12
|
-
change_password: "change-password"
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
exports.default = auth;
|
package/dist/cjs/auth/index.js
DELETED
|
@@ -1,94 +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 js_cookie_1 = __importDefault(require("js-cookie"));
|
|
7
|
-
const jwt_decode_1 = require("jwt-decode");
|
|
8
|
-
// import type { NextPageContext } from "next";
|
|
9
|
-
const index_1 = require("../config/index");
|
|
10
|
-
const auth_1 = require("../utils/auth");
|
|
11
|
-
const localStorage_1 = require("../utils/localStorage");
|
|
12
|
-
const logout_1 = __importDefault(require("./logout"));
|
|
13
|
-
const register_1 = __importDefault(require("./register"));
|
|
14
|
-
const signInWithGoogle_1 = __importDefault(require("./signInWithGoogle"));
|
|
15
|
-
const signin_1 = __importDefault(require("./signin"));
|
|
16
|
-
const signup_1 = __importDefault(require("./signup"));
|
|
17
|
-
const validate_1 = __importDefault(require("../config/validate"));
|
|
18
|
-
const authWithToken_1 = __importDefault(require("./authWithToken"));
|
|
19
|
-
const authWithKey_1 = __importDefault(require("./authWithKey"));
|
|
20
|
-
const resetPassword_1 = __importDefault(require("./resetPassword"));
|
|
21
|
-
const Auth = {
|
|
22
|
-
signIn: signin_1.default,
|
|
23
|
-
signUp: signup_1.default,
|
|
24
|
-
register: register_1.default,
|
|
25
|
-
resetPassword: resetPassword_1.default,
|
|
26
|
-
signInWithGoogle: signInWithGoogle_1.default,
|
|
27
|
-
saveTokenToCookie: (token) => {
|
|
28
|
-
(0, validate_1.default)(['tokenKey']);
|
|
29
|
-
const { tokenKey } = (0, index_1.getConfig)();
|
|
30
|
-
if (tokenKey) {
|
|
31
|
-
js_cookie_1.default.set(tokenKey, token, { expires: 900000 });
|
|
32
|
-
}
|
|
33
|
-
window.location.href = "/";
|
|
34
|
-
},
|
|
35
|
-
saveTokenToStorage: (token) => {
|
|
36
|
-
const accountInfo = (0, jwt_decode_1.jwtDecode)(token);
|
|
37
|
-
if (accountInfo) {
|
|
38
|
-
(0, localStorage_1.setEncryptionKey)("account_key", accountInfo._id + accountInfo.createdAt);
|
|
39
|
-
(0, localStorage_1.setDataInStorage)("accountAccessToken", token);
|
|
40
|
-
(0, localStorage_1.setDataInStorage)("accountInfo", accountInfo);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
getTokenFromStorage: () => {
|
|
44
|
-
return (0, localStorage_1.getDataFromStorage)("accountAccessToken");
|
|
45
|
-
},
|
|
46
|
-
getUserFromStrorage: () => {
|
|
47
|
-
return (0, localStorage_1.getDataFromStorage)("accountInfo");
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* Action to update stored admin info in the redux
|
|
51
|
-
* @param {string | object} key key or an object with key: value of the fields to be updated
|
|
52
|
-
* @param {any} value value of the field to be updated (only if the key passed is of type string)
|
|
53
|
-
*/
|
|
54
|
-
updateUserInfo: (key, value) => () => {
|
|
55
|
-
console.log("typeof key: ", typeof key, key);
|
|
56
|
-
try {
|
|
57
|
-
// console.log(key);
|
|
58
|
-
const accountInfo = (0, localStorage_1.getDataFromStorage)("accountInfo");
|
|
59
|
-
if (typeof key === "object") {
|
|
60
|
-
let updatedInfo = { ...accountInfo };
|
|
61
|
-
// for..of
|
|
62
|
-
for (const [ky, value] of Object.entries(key)) {
|
|
63
|
-
updatedInfo = { ...updatedInfo, [ky]: value };
|
|
64
|
-
}
|
|
65
|
-
// console.log(updatedInfo);
|
|
66
|
-
(0, localStorage_1.setDataInStorage)("accountInfo", updatedInfo);
|
|
67
|
-
}
|
|
68
|
-
else if (typeof key === "string") {
|
|
69
|
-
if (value) {
|
|
70
|
-
(0, localStorage_1.setDataInStorage)("accountInfo", { ...accountInfo, [key]: value });
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
console.error("Value is not provided for the given key to update admin info");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
console.error("update logo action ", error);
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
isAuthenticated: (cookie) => {
|
|
82
|
-
if (cookie) {
|
|
83
|
-
return (0, auth_1.isAuth)();
|
|
84
|
-
}
|
|
85
|
-
return (0, localStorage_1.getDataFromStorage)("accountAccessToken") !== undefined;
|
|
86
|
-
},
|
|
87
|
-
// getServerToken: (ctx: NextPageContext) => getServerSideToken(ctx),
|
|
88
|
-
logout: logout_1.default,
|
|
89
|
-
Server: {
|
|
90
|
-
authWithToken: authWithToken_1.default,
|
|
91
|
-
authWithKey: authWithKey_1.default
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
exports.default = Auth;
|
package/dist/cjs/auth/logout.js
DELETED
|
@@ -1,22 +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 localStorage_1 = require("../utils/localStorage");
|
|
10
|
-
const logout = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
11
|
-
return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("auth", "v1", "logout"), { ...data, fcm_token: (0, localStorage_1.getDataFromStorage)("fcm_token") }, config), {
|
|
12
|
-
onFetching: () => onFetching?.(),
|
|
13
|
-
onError: (error) => onError?.(error),
|
|
14
|
-
onSuccess: (data) => {
|
|
15
|
-
(0, localStorage_1.clearStorage)(["accountAccessToken", "accountInfo", "account_key"]);
|
|
16
|
-
onSuccess?.(data);
|
|
17
|
-
window.location.href = "/";
|
|
18
|
-
},
|
|
19
|
-
onSettled: () => onSettled?.(),
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
exports.default = logout;
|
|
@@ -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 register = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("auth", "v1", "register"), data, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = register;
|
|
@@ -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 resetPassword = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
10
|
-
return (0, handler_1.default)((0, axios_1.post)((0, route_1.getUrl)("auth", "v1", "reset_password"), data, config), {
|
|
11
|
-
onFetching: () => onFetching?.(),
|
|
12
|
-
onError: (error) => onError?.(error),
|
|
13
|
-
onSuccess: (data) => onSuccess?.(data),
|
|
14
|
-
onSettled: () => onSettled?.(),
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
exports.default = resetPassword;
|