spoko-design-system 0.2.62 → 0.2.63

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/index.ts CHANGED
@@ -53,7 +53,8 @@ export { default as getProductChecklist } from './src/utils/product/getProductCh
53
53
  export { default as getShorterDescription } from './src/utils/seo/getShorterDescription';
54
54
 
55
55
  // Utils: Text
56
- export { getTranslation, text2paragraphs, countWords, firstSentence, removeSemicolon, apiInfo } from './src/utils/text';
56
+ export { getTranslation, text2paragraphs, countWords, firstSentence, removeSemicolon } from './src/utils/text';
57
+ export { apiInfo, getData} from './src/utils/getData';
57
58
  export { default as formatDate } from './src/utils/text/formatDate';
58
59
  export { default as formatLocaleNumber } from './src/utils/text/formatLocaleNumber';
59
60
  export { default as formatPad } from './src/utils/text/formatPad';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spoko-design-system",
3
- "version": "0.2.62",
3
+ "version": "0.2.63",
4
4
  "private": false,
5
5
  "main": "./index.ts",
6
6
  "module": "./index.ts",
@@ -1,4 +1,3 @@
1
- const API_URL = import.meta.env.API_URL;
2
1
  const version = (Math.random() + 1).toString(36).substring(7); // random version to refresh cache from Cloudflare
3
2
 
4
3
  interface ApiResponse<T> {
@@ -6,6 +5,27 @@ interface ApiResponse<T> {
6
5
  data: T;
7
6
  }
8
7
 
8
+ export function getEnvVariable(key, defaultValue = null) {
9
+ // First we check import.meta.env (for ES6 environments)
10
+ if (typeof import.meta !== 'undefined' && typeof import.meta.env !== 'undefined') {
11
+ return import.meta.env[key] || defaultValue;
12
+ }
13
+
14
+ // Then check process.env (for Node.js environment)
15
+ if (typeof process !== 'undefined' && typeof process.env !== 'undefined') {
16
+ return process.env[key] || defaultValue;
17
+ }
18
+
19
+ // If no variable is found, the default value is returned
20
+ return defaultValue;
21
+ }
22
+ const API_URL = getEnvVariable('API_URL', 'https://default-api.com');
23
+
24
+
25
+ export const apiInfo = (name: string) => {
26
+ return API_URL
27
+ }
28
+
9
29
  export const getData = async <T>(type: string): Promise<T | null> => {
10
30
  const API = `${API_URL}${type}?version=${version}`;
11
31
 
package/src/utils/text.ts CHANGED
@@ -1,24 +1,5 @@
1
1
  import i18next, { t } from "i18next";
2
2
 
3
- export function getEnvVariable(key, defaultValue = null) {
4
- // First we check import.meta.env (for ES6 environments)
5
- if (typeof import.meta !== 'undefined' && typeof import.meta.env !== 'undefined') {
6
- return import.meta.env[key] || defaultValue;
7
- }
8
-
9
- // Then check process.env (for Node.js environment)
10
- if (typeof process !== 'undefined' && typeof process.env !== 'undefined') {
11
- return process.env[key] || defaultValue;
12
- }
13
-
14
- // If no variable is found, the default value is returned
15
- return defaultValue;
16
- }
17
- const API_URL = getEnvVariable('API_URL', 'http://default-api.com');
18
-
19
-
20
-
21
-
22
3
  // import { t } from "i18next";
23
4
 
24
5
  export const getTranslation = (translationKey: string) => {
@@ -45,6 +26,3 @@ export const removeSemicolon = (name: string) => {
45
26
  return name.replace(';', '')
46
27
  }
47
28
 
48
- export const apiInfo = (name: string) => {
49
- return API_URL
50
- }