@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.
Files changed (92) hide show
  1. package/dist/index.js +65 -23
  2. package/dist/index.js.map +1 -1
  3. package/dist/types/config/index.d.ts +2 -24
  4. package/dist/types/config/state.d.ts +31 -0
  5. package/dist/types/lms/endpoint.d.ts +1 -0
  6. package/dist/types/lms/enroll_course.d.ts +2 -2
  7. package/dist/types/lms/index.d.ts +13 -3
  8. package/dist/types/lms/post_course.d.ts +2 -2
  9. package/dist/types/lms/post_session.d.ts +12 -0
  10. package/dist/types/lms/types.d.ts +18 -4
  11. package/package.json +9 -9
  12. package/dist/cjs/account/endpoint.js +0 -8
  13. package/dist/cjs/account/index.js +0 -17
  14. package/dist/cjs/account/types.js +0 -2
  15. package/dist/cjs/account/update_profile.js +0 -17
  16. package/dist/cjs/accounting/createInvoice.js +0 -17
  17. package/dist/cjs/accounting/endpoint.js +0 -14
  18. package/dist/cjs/accounting/index.js +0 -25
  19. package/dist/cjs/accounting/submitInvoice.js +0 -17
  20. package/dist/cjs/accounting/types.js +0 -2
  21. package/dist/cjs/accounting/updateInvoice.js +0 -17
  22. package/dist/cjs/apis/cities.js +0 -17
  23. package/dist/cjs/apis/countries.js +0 -17
  24. package/dist/cjs/apis/index.js +0 -14
  25. package/dist/cjs/apis/states.js +0 -17
  26. package/dist/cjs/assets/endpoint.js +0 -9
  27. package/dist/cjs/assets/index.js +0 -11
  28. package/dist/cjs/auth/authWithKey.js +0 -17
  29. package/dist/cjs/auth/authWithToken.js +0 -17
  30. package/dist/cjs/auth/endpoint.js +0 -15
  31. package/dist/cjs/auth/index.js +0 -94
  32. package/dist/cjs/auth/logout.js +0 -22
  33. package/dist/cjs/auth/register.js +0 -17
  34. package/dist/cjs/auth/resetPassword.js +0 -17
  35. package/dist/cjs/auth/signInWithGoogle.js +0 -56
  36. package/dist/cjs/auth/signin.js +0 -17
  37. package/dist/cjs/auth/signup.js +0 -17
  38. package/dist/cjs/auth/types.js +0 -2
  39. package/dist/cjs/config/axios.js +0 -120
  40. package/dist/cjs/config/constants.js +0 -12
  41. package/dist/cjs/config/fetch.js +0 -37
  42. package/dist/cjs/config/handler.js +0 -32
  43. package/dist/cjs/config/index.js +0 -37
  44. package/dist/cjs/config/local-storage.js +0 -29
  45. package/dist/cjs/config/route.js +0 -47
  46. package/dist/cjs/config/validate.js +0 -15
  47. package/dist/cjs/content/endpoint.js +0 -17
  48. package/dist/cjs/content/index.js +0 -29
  49. package/dist/cjs/hooks/index.js +0 -10
  50. package/dist/cjs/hooks/useAuth.js +0 -23
  51. package/dist/cjs/hooks/usePrivate.js +0 -15
  52. package/dist/cjs/hooks/useUser.js +0 -15
  53. package/dist/cjs/index.js +0 -59
  54. package/dist/cjs/inventory/endpoint.js +0 -9
  55. package/dist/cjs/inventory/index.js +0 -26
  56. package/dist/cjs/linkie/endpoint.js +0 -8
  57. package/dist/cjs/linkie/index.js +0 -20
  58. package/dist/cjs/linkie/shortUrl.js +0 -17
  59. package/dist/cjs/linkie/types.js +0 -2
  60. package/dist/cjs/order/create.js +0 -17
  61. package/dist/cjs/order/endpoint.js +0 -8
  62. package/dist/cjs/order/index.js +0 -10
  63. package/dist/cjs/order/types.js +0 -2
  64. package/dist/cjs/payment/components/ProcessPayment.js +0 -266
  65. package/dist/cjs/payment/endpoint.js +0 -9
  66. package/dist/cjs/payment/index.js +0 -12
  67. package/dist/cjs/payment/start.js +0 -38
  68. package/dist/cjs/payment/types.js +0 -2
  69. package/dist/cjs/payment/verify.js +0 -17
  70. package/dist/cjs/sales/endpoint.js +0 -8
  71. package/dist/cjs/sales/index.js +0 -7
  72. package/dist/cjs/sales/lead.js +0 -22
  73. package/dist/cjs/sales/types.js +0 -17
  74. package/dist/cjs/support/endpoint.js +0 -10
  75. package/dist/cjs/support/index.js +0 -15
  76. package/dist/cjs/support/newsletter.js +0 -17
  77. package/dist/cjs/support/ticket.js +0 -17
  78. package/dist/cjs/tools/endpoint.js +0 -8
  79. package/dist/cjs/tools/exchangeRates.js +0 -30
  80. package/dist/cjs/tools/index.js +0 -10
  81. package/dist/cjs/types.js +0 -9
  82. package/dist/cjs/utils/auth.js +0 -23
  83. package/dist/cjs/utils/handler.js +0 -35
  84. package/dist/cjs/utils/localStorage.js +0 -137
  85. package/dist/cjs/utils/share.js +0 -25
  86. package/dist/types/config/local-storage.d.ts +0 -0
  87. package/dist/types/config/validate.d.ts +0 -4
  88. package/dist/types/hooks/index.d.ts +0 -1
  89. package/dist/types/hooks/useAuth.d.ts +0 -0
  90. package/dist/types/hooks/usePrivate.d.ts +0 -0
  91. package/dist/types/hooks/useUser.d.ts +0 -8
  92. package/dist/types/payment/components/ProcessPayment.d.ts +0 -0
@@ -1,23 +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.isAuth = exports.getCookie = void 0;
7
- const js_cookie_1 = __importDefault(require("js-cookie"));
8
- // import type { NextPageContext } from "next";
9
- // import { parseCookies } from "nookies";
10
- const config_1 = require("../config");
11
- const getCookie = (key = (0, config_1.getConfig)().tokenKey) => {
12
- // console.log(Cookies.get(key));
13
- if (key)
14
- return js_cookie_1.default.get(key);
15
- return "";
16
- };
17
- exports.getCookie = getCookie;
18
- const isAuth = () => !!(0, exports.getCookie)();
19
- exports.isAuth = isAuth;
20
- // export const getServerSideToken = (ctx: NextPageContext) => {
21
- // const { token } = parseCookies(ctx);
22
- // return token;
23
- // };
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const handler = ({ promise, onLoading = () => { }, onSuccess = () => { }, onError = () => { }, onSettled = () => { }, onProgress = () => { }, }) => {
4
- // Call onLoading at the start to show loading state
5
- onLoading(true);
6
- // Handling the passed promise
7
- promise
8
- .then((response) => {
9
- // Show success state
10
- console.log("Request Success:", response);
11
- // Execute success callback if provided
12
- if (onSuccess) {
13
- onSuccess(response.data);
14
- }
15
- })
16
- .catch((error) => {
17
- // Show error state
18
- console.error("Request Error:", error);
19
- // Execute error callback if provided
20
- if (onError) {
21
- onError(error);
22
- }
23
- })
24
- .finally(() => {
25
- // Execute settled callback (on success or error)
26
- if (onSettled) {
27
- onSettled();
28
- }
29
- // Call onLoading to hide loading indicator after completion
30
- onLoading(false);
31
- // Hide loading indicator
32
- console.log("Request Completed");
33
- });
34
- };
35
- exports.default = handler;
@@ -1,137 +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.setEncryptionKey = setEncryptionKey;
7
- exports.getEncryptionKey = getEncryptionKey;
8
- exports.daysCountInMonth = daysCountInMonth;
9
- exports.setDataInStorage = setDataInStorage;
10
- exports.getDataFromStorage = getDataFromStorage;
11
- exports.clearStorage = clearStorage;
12
- const crypto_js_1 = __importDefault(require("crypto-js"));
13
- /**
14
- * Function to set encryption key
15
- * @param {string} key - encryption key name
16
- * @param {string} value string value to be set as encryption key
17
- */
18
- function setEncryptionKey(key, value) {
19
- if (key && value) {
20
- const sha256Key = crypto_js_1.default.SHA256(key).toString();
21
- // console.log('setting key: ', key, value);
22
- const sha256Data = crypto_js_1.default.SHA256(value).toString();
23
- localStorage.setItem(sha256Key, JSON.stringify(sha256Data));
24
- }
25
- else {
26
- console.error("No data provided");
27
- }
28
- }
29
- /**
30
- * function to get the encryption key
31
- * @param {string} - name of the key to get encryption key for
32
- * @returns {string}
33
- */
34
- // eslint-disable-next-line consistent-return
35
- function getEncryptionKey(key) {
36
- try {
37
- const shaKey = crypto_js_1.default.SHA256(key).toString();
38
- // console.log('getting key: ', key, localStorage.getItem(shaKey));
39
- return localStorage.getItem(shaKey);
40
- }
41
- catch (err) {
42
- console.error("something went wrong man hoho");
43
- }
44
- }
45
- function daysCountInMonth(month, year) {
46
- return new Date(year, month, 0).getDate();
47
- }
48
- /**
49
- * Funtion to store data in local storage
50
- * Pass second argument as true if setting data for employee side
51
- * @param {string} key key for the value to be stored
52
- * @param {*} data actual data to be stored with the provided key
53
- * @param {boolean} [useEmployeeKey] - flag to decide which encyption key to use, (employee's or admin's)
54
- */
55
- function setDataInStorage(key, data) {
56
- // Encrypt key
57
- const shaKey = crypto_js_1.default.SHA256(key).toString();
58
- const encKeyName = "account_key";
59
- const encryptionKey = getEncryptionKey(encKeyName);
60
- // console.log('setting data: ', encryption_key, key, shaKey, data);
61
- if (encryptionKey) {
62
- // Encrypt data
63
- const dataCipher = crypto_js_1.default.AES.encrypt(JSON.stringify(data), encryptionKey).toString();
64
- localStorage.setItem(shaKey, JSON.stringify(dataCipher));
65
- }
66
- }
67
- /**
68
- * Function to get data from local storage
69
- * Pass second argument as true if getting data for employee side
70
- * @param {string} key - key of the item to fetch from local storage
71
- * @param {boolean} [useEmployeeKey] - flag to decide which encyption key to use, (employee's or admin's)
72
- * @returns {*} value associated with the key
73
- */
74
- // eslint-disable-next-line consistent-return
75
- function getDataFromStorage(key) {
76
- try {
77
- const shaKey = crypto_js_1.default.SHA256(key).toString();
78
- const encKeyName = "account_key";
79
- const encryptionKey = getEncryptionKey(encKeyName);
80
- // console.log(
81
- // 'from getting data: ',
82
- // key,
83
- // 'encryption-key',
84
- // typeof encryption_key,
85
- // encryption_key
86
- // );
87
- if (encryptionKey && shaKey) {
88
- const ciphertext = JSON.parse(String(localStorage.getItem(shaKey)));
89
- if (ciphertext) {
90
- // Decrypt
91
- const bytes = crypto_js_1.default.AES.decrypt(ciphertext, encryptionKey);
92
- const originalData = bytes.toString(crypto_js_1.default.enc.Utf8);
93
- // console.log('getting data: ', key, shaKey, originalData);
94
- return JSON.parse(originalData);
95
- }
96
- }
97
- }
98
- catch (err) {
99
- // console.error('Error getting data from storage boi boi');
100
- }
101
- }
102
- /**
103
- * Function to clear items from local storage
104
- * @param {(string|string[])} keys - key to remove or array of keys
105
- */
106
- // export function clearStorage(keys: string[]) {
107
- // try {
108
- // if (Array.isArray(keys)) {
109
- // keys.forEach((key) => {
110
- // const shaKey = CryptoJS.SHA256(key).toString();
111
- // localStorage.removeItem(shaKey);
112
- // });
113
- // } else if (typeof keys === "string") {
114
- // const shaKey = CryptoJS.SHA256(keys).toString();
115
- // localStorage.removeItem(shaKey);
116
- // }
117
- // } catch (err) {
118
- // console.error("Error clearing storage", err);
119
- // }
120
- // }
121
- function clearStorage(keys) {
122
- try {
123
- if (Array.isArray(keys)) {
124
- for (const key of keys) {
125
- const shaKey = crypto_js_1.default.SHA256(key).toString();
126
- localStorage.removeItem(shaKey);
127
- }
128
- }
129
- else if (typeof keys === "string") {
130
- const shaKey = crypto_js_1.default.SHA256(keys).toString();
131
- localStorage.removeItem(shaKey);
132
- }
133
- }
134
- catch (err) {
135
- console.error("Error clearing storage", err);
136
- }
137
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = shareUrl;
4
- function shareUrl(title, url) {
5
- // URL encoding to ensure special characters are handled properly
6
- const encodedTitle = encodeURIComponent(title);
7
- const encodedUrl = encodeURIComponent(url);
8
- const target = "_blank";
9
- const dimension = "width=600,height=400";
10
- // Social media share URLs
11
- const shareLinks = {
12
- facebook: `https://www.facebook.com/sharer/sharer.php?u=${encodedUrl}`,
13
- twitter: `https://twitter.com/intent/tweet?text=${encodedTitle}&url=${encodedUrl}`,
14
- linkedin: `https://www.linkedin.com/sharing/share-offsite/?url=${encodedUrl}`,
15
- whatsapp: `https://api.whatsapp.com/send?text=${encodedTitle} ${encodedUrl}`,
16
- pinterest: `https://www.pinterest.com/pin/create/button/?url=${encodedUrl}&description=${encodedTitle}`,
17
- };
18
- return {
19
- facebook: () => window.open(shareLinks.facebook, target, dimension),
20
- twitter: () => window.open(shareLinks.twitter, target, dimension),
21
- linkedin: () => window.open(shareLinks.linkedin, target, dimension),
22
- whatsapp: () => window.open(shareLinks.whatsapp, target, dimension),
23
- pinterest: () => window.open(shareLinks.pinterest, target, dimension),
24
- };
25
- }
File without changes
@@ -1,4 +0,0 @@
1
- import { getConfig } from './index';
2
- type Config = ReturnType<typeof getConfig>;
3
- declare function validateConfig(requiredKeys: (keyof Config)[]): void;
4
- export default validateConfig;
@@ -1 +0,0 @@
1
- export { default as useUser } from "./useUser";
File without changes
File without changes
@@ -1,8 +0,0 @@
1
- declare const useUser: () => {
2
- user: import("axios").AxiosResponse<any, any, {}> | undefined;
3
- isLoading: boolean;
4
- error: any;
5
- loggedOut: any;
6
- mutate: import("swr").KeyedMutator<import("axios").AxiosResponse<any, any, {}>>;
7
- };
8
- export default useUser;
File without changes