@c-rex/utils 0.1.10 → 0.1.11
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/next-cookies.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ConfigInterface } from '@c-rex/interfaces';
|
|
1
|
+
import { CookiesConfigs, ConfigInterface } from '@c-rex/interfaces';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves and parses configuration data from a cookie.
|
|
5
5
|
* @returns The parsed configuration object
|
|
6
6
|
* @throws Error if the configuration cookie is not found or cannot be parsed
|
|
7
7
|
*/
|
|
8
|
-
declare const
|
|
8
|
+
declare const getClientConfigs: () => CookiesConfigs;
|
|
9
|
+
declare const getServerConfigs: () => Promise<ConfigInterface>;
|
|
9
10
|
|
|
10
|
-
export {
|
|
11
|
+
export { getClientConfigs, getServerConfigs };
|
package/dist/next-cookies.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ConfigInterface } from '@c-rex/interfaces';
|
|
1
|
+
import { CookiesConfigs, ConfigInterface } from '@c-rex/interfaces';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves and parses configuration data from a cookie.
|
|
5
5
|
* @returns The parsed configuration object
|
|
6
6
|
* @throws Error if the configuration cookie is not found or cannot be parsed
|
|
7
7
|
*/
|
|
8
|
-
declare const
|
|
8
|
+
declare const getClientConfigs: () => CookiesConfigs;
|
|
9
|
+
declare const getServerConfigs: () => Promise<ConfigInterface>;
|
|
9
10
|
|
|
10
|
-
export {
|
|
11
|
+
export { getClientConfigs, getServerConfigs };
|
package/dist/next-cookies.js
CHANGED
|
@@ -21,7 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/next-cookies.ts
|
|
22
22
|
var next_cookies_exports = {};
|
|
23
23
|
__export(next_cookies_exports, {
|
|
24
|
-
|
|
24
|
+
getClientConfigs: () => getClientConfigs,
|
|
25
|
+
getServerConfigs: () => getServerConfigs
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(next_cookies_exports);
|
|
27
28
|
|
|
@@ -31,7 +32,7 @@ var DEFAULT_COOKIE_LIMIT = 30 * 24 * 60 * 60 * 1e3;
|
|
|
31
32
|
|
|
32
33
|
// src/next-cookies.ts
|
|
33
34
|
var import_headers = require("next/headers");
|
|
34
|
-
var
|
|
35
|
+
var getClientConfigs = () => {
|
|
35
36
|
const jsonConfigs = (0, import_headers.cookies)().get(SDK_CONFIG_KEY)?.value;
|
|
36
37
|
if (!jsonConfigs) {
|
|
37
38
|
throw new Error("Configs not found");
|
|
@@ -39,8 +40,14 @@ var getConfigs = () => {
|
|
|
39
40
|
const configs = JSON.parse(jsonConfigs);
|
|
40
41
|
return configs;
|
|
41
42
|
};
|
|
43
|
+
var getServerConfigs = async () => {
|
|
44
|
+
const configs = await getClientConfigs();
|
|
45
|
+
const result = await fetch(`${configs.publicNextApiUrl}/api/config`);
|
|
46
|
+
return result.json();
|
|
47
|
+
};
|
|
42
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
49
|
0 && (module.exports = {
|
|
44
|
-
|
|
50
|
+
getClientConfigs,
|
|
51
|
+
getServerConfigs
|
|
45
52
|
});
|
|
46
53
|
//# sourceMappingURL=next-cookies.js.map
|
package/dist/next-cookies.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/next-cookies.ts","../../constants/src/index.ts"],"sourcesContent":["'use server';\n\nimport { SDK_CONFIG_KEY } from '@c-rex/constants';\nimport { ConfigInterface } from '@c-rex/interfaces';\nimport { cookies } from 'next/headers';\n\n/**\n * Retrieves and parses configuration data from a cookie.\n * @returns The parsed configuration object\n * @throws Error if the configuration cookie is not found or cannot be parsed\n */\nexport const
|
|
1
|
+
{"version":3,"sources":["../src/next-cookies.ts","../../constants/src/index.ts"],"sourcesContent":["'use server';\n\nimport { SDK_CONFIG_KEY } from '@c-rex/constants';\nimport { ConfigInterface } from '@c-rex/interfaces';\nimport { CookiesConfigs } from '@c-rex/interfaces';\nimport { cookies } from 'next/headers';\n\n/**\n * Retrieves and parses configuration data from a cookie.\n * @returns The parsed configuration object\n * @throws Error if the configuration cookie is not found or cannot be parsed\n */\nexport const getClientConfigs = (): CookiesConfigs => {\n const jsonConfigs = cookies().get(SDK_CONFIG_KEY)?.value;\n if (!jsonConfigs) {\n throw new Error('Configs not found');\n }\n\n const configs: CookiesConfigs = JSON.parse(jsonConfigs);\n\n return configs;\n}\n\nexport const getServerConfigs = async (): Promise<ConfigInterface> => {\n const configs = await getClientConfigs();\n const result = await fetch(`${configs.publicNextApiUrl}/api/config`);\n return result.json();\n}","export const ALL = \"*\"\n\nexport const LOG_CATEGORIES = [\n \"NoLicense\",\n \"Scenario\",\n \"Favorites\",\n \"Subscription\",\n \"Share\",\n \"Document\",\n \"Search\",\n \"History\",\n \"Notification\",\n \"UserProfile\",\n] as const;\n\nexport const LOG_LEVELS = {\n critical: 2,\n error: 3,\n warning: 4,\n info: 6,\n debug: 7,\n} as const;\n\nexport const RESULT_VIEW_STYLES = [\n \"cards\",\n \"table\",\n] as const;\n\nexport const API = {\n MAX_RETRY: 3,\n API_TIMEOUT: 10000,\n RETRY_DELAY: 500,\n API_HEADERS: {\n \"content-Type\": \"application/json\",\n },\n};\n\nexport const SDK_CONFIG_KEY = \"crex-sdk-config\";\n\nexport const CONTENT_LANG_KEY = \"CONTENT_LANG_KEY\";\n\nexport const AVAILABLE_CONTENT_LANG_KEY = \"AVAILABLE_CONTENT_LANG_KEY\";\n\nexport const UI_LANG_KEY = \"UI_LANG_KEY\";\n\nexport const FLAGS_BY_LANG = {\n \"en\": \"US\",\n \"de\": \"DE\",\n};\n\nexport const DEFAULT_LANG = \"en-US\";\n\nexport const EN_LANG = \"en\";\n\nexport const UI_LANG_OPTIONS = [\"en-us\", \"de-de\"];\n\nexport const TOPICS_TYPE_AND_LINK = \"topics\";\nexport const BLOG_TYPE_AND_LINK = \"blog\";\nexport const DOCUMENTS_TYPE_AND_LINK = \"documents\";\n\nexport const TOPIC = \"TOPIC\";\nexport const DOCUMENT = \"DOCUMENT\";\nexport const PACKAGE = \"PACKAGE\";\nexport const FRAGMENT = \"FRAGMENT\";\n\nexport const RESULT_TYPES = {\n TOPIC: TOPIC,\n DOCUMENT: DOCUMENT,\n PACKAGE: PACKAGE,\n FRAGMENT: FRAGMENT\n} as const;\n\nexport const FILES_EXTENSIONS = {\n PDF: \"application/pdf\",\n HTML: \"text/html\",\n} as const;\n\nexport const DEFAULT_COOKIE_LIMIT = 30 * 24 * 60 * 60 * 1000; // 30 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";\n\nexport const CREX_TOKEN_HEADER_KEY = \"crex-token\";\n\nexport const WILD_CARD_OPTIONS = {\n BOTH: \"BOTH\",\n END: \"END\",\n START: \"START\",\n NONE: \"NONE\",\n} as const;\n\nexport const OPERATOR_OPTIONS = {\n AND: \"AND\",\n OR: \"OR\",\n} as const;\n\nexport const ARTICLE_PAGE_LAYOUT = {\n BLOG: \"BLOG\",\n DOCUMENT: \"DOCUMENT\",\n} as const;\n\nexport const DEVICE_OPTIONS = {\n MOBILE: \"mobile\",\n TABLET: \"tablet\",\n DESKTOP: \"desktop\",\n}\nexport const BREAKPOINTS = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n \"2xl\": 1536,\n};"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqCO,IAAM,iBAAiB;AAwCvB,IAAM,uBAAuB,KAAK,KAAK,KAAK,KAAK;;;ADxExD,qBAAwB;AAOjB,IAAM,mBAAmB,MAAsB;AAClD,QAAM,kBAAc,wBAAQ,EAAE,IAAI,cAAc,GAAG;AACnD,MAAI,CAAC,aAAa;AACd,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACvC;AAEA,QAAM,UAA0B,KAAK,MAAM,WAAW;AAEtD,SAAO;AACX;AAEO,IAAM,mBAAmB,YAAsC;AAClE,QAAM,UAAU,MAAM,iBAAiB;AACvC,QAAM,SAAS,MAAM,MAAM,GAAG,QAAQ,gBAAgB,aAAa;AACnE,SAAO,OAAO,KAAK;AACvB;","names":[]}
|
package/dist/next-cookies.mjs
CHANGED
|
@@ -6,7 +6,7 @@ var DEFAULT_COOKIE_LIMIT = 30 * 24 * 60 * 60 * 1e3;
|
|
|
6
6
|
|
|
7
7
|
// src/next-cookies.ts
|
|
8
8
|
import { cookies } from "next/headers";
|
|
9
|
-
var
|
|
9
|
+
var getClientConfigs = () => {
|
|
10
10
|
const jsonConfigs = cookies().get(SDK_CONFIG_KEY)?.value;
|
|
11
11
|
if (!jsonConfigs) {
|
|
12
12
|
throw new Error("Configs not found");
|
|
@@ -14,7 +14,13 @@ var getConfigs = () => {
|
|
|
14
14
|
const configs = JSON.parse(jsonConfigs);
|
|
15
15
|
return configs;
|
|
16
16
|
};
|
|
17
|
+
var getServerConfigs = async () => {
|
|
18
|
+
const configs = await getClientConfigs();
|
|
19
|
+
const result = await fetch(`${configs.publicNextApiUrl}/api/config`);
|
|
20
|
+
return result.json();
|
|
21
|
+
};
|
|
17
22
|
export {
|
|
18
|
-
|
|
23
|
+
getClientConfigs,
|
|
24
|
+
getServerConfigs
|
|
19
25
|
};
|
|
20
26
|
//# sourceMappingURL=next-cookies.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../constants/src/index.ts","../src/next-cookies.ts"],"sourcesContent":["export const ALL = \"*\"\n\nexport const LOG_CATEGORIES = [\n \"NoLicense\",\n \"Scenario\",\n \"Favorites\",\n \"Subscription\",\n \"Share\",\n \"Document\",\n \"Search\",\n \"History\",\n \"Notification\",\n \"UserProfile\",\n] as const;\n\nexport const LOG_LEVELS = {\n critical: 2,\n error: 3,\n warning: 4,\n info: 6,\n debug: 7,\n} as const;\n\nexport const RESULT_VIEW_STYLES = [\n \"cards\",\n \"table\",\n] as const;\n\nexport const API = {\n MAX_RETRY: 3,\n API_TIMEOUT: 10000,\n RETRY_DELAY: 500,\n API_HEADERS: {\n \"content-Type\": \"application/json\",\n },\n};\n\nexport const SDK_CONFIG_KEY = \"crex-sdk-config\";\n\nexport const CONTENT_LANG_KEY = \"CONTENT_LANG_KEY\";\n\nexport const AVAILABLE_CONTENT_LANG_KEY = \"AVAILABLE_CONTENT_LANG_KEY\";\n\nexport const UI_LANG_KEY = \"UI_LANG_KEY\";\n\nexport const FLAGS_BY_LANG = {\n \"en\": \"US\",\n \"de\": \"DE\",\n};\n\nexport const DEFAULT_LANG = \"en-US\";\n\nexport const EN_LANG = \"en\";\n\nexport const UI_LANG_OPTIONS = [\"en-us\", \"de-de\"];\n\nexport const TOPICS_TYPE_AND_LINK = \"topics\";\nexport const BLOG_TYPE_AND_LINK = \"blog\";\nexport const DOCUMENTS_TYPE_AND_LINK = \"documents\";\n\nexport const TOPIC = \"TOPIC\";\nexport const DOCUMENT = \"DOCUMENT\";\nexport const PACKAGE = \"PACKAGE\";\nexport const FRAGMENT = \"FRAGMENT\";\n\nexport const RESULT_TYPES = {\n TOPIC: TOPIC,\n DOCUMENT: DOCUMENT,\n PACKAGE: PACKAGE,\n FRAGMENT: FRAGMENT\n} as const;\n\nexport const FILES_EXTENSIONS = {\n PDF: \"application/pdf\",\n HTML: \"text/html\",\n} as const;\n\nexport const DEFAULT_COOKIE_LIMIT = 30 * 24 * 60 * 60 * 1000; // 30 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";\n\nexport const CREX_TOKEN_HEADER_KEY = \"crex-token\";\n\nexport const WILD_CARD_OPTIONS = {\n BOTH: \"BOTH\",\n END: \"END\",\n START: \"START\",\n NONE: \"NONE\",\n} as const;\n\nexport const OPERATOR_OPTIONS = {\n AND: \"AND\",\n OR: \"OR\",\n} as const;\n\nexport const ARTICLE_PAGE_LAYOUT = {\n BLOG: \"BLOG\",\n DOCUMENT: \"DOCUMENT\",\n} as const;\n\nexport const DEVICE_OPTIONS = {\n MOBILE: \"mobile\",\n TABLET: \"tablet\",\n DESKTOP: \"desktop\",\n}\nexport const BREAKPOINTS = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n \"2xl\": 1536,\n};","'use server';\n\nimport { SDK_CONFIG_KEY } from '@c-rex/constants';\nimport { ConfigInterface } from '@c-rex/interfaces';\nimport { cookies } from 'next/headers';\n\n/**\n * Retrieves and parses configuration data from a cookie.\n * @returns The parsed configuration object\n * @throws Error if the configuration cookie is not found or cannot be parsed\n */\nexport const
|
|
1
|
+
{"version":3,"sources":["../../constants/src/index.ts","../src/next-cookies.ts"],"sourcesContent":["export const ALL = \"*\"\n\nexport const LOG_CATEGORIES = [\n \"NoLicense\",\n \"Scenario\",\n \"Favorites\",\n \"Subscription\",\n \"Share\",\n \"Document\",\n \"Search\",\n \"History\",\n \"Notification\",\n \"UserProfile\",\n] as const;\n\nexport const LOG_LEVELS = {\n critical: 2,\n error: 3,\n warning: 4,\n info: 6,\n debug: 7,\n} as const;\n\nexport const RESULT_VIEW_STYLES = [\n \"cards\",\n \"table\",\n] as const;\n\nexport const API = {\n MAX_RETRY: 3,\n API_TIMEOUT: 10000,\n RETRY_DELAY: 500,\n API_HEADERS: {\n \"content-Type\": \"application/json\",\n },\n};\n\nexport const SDK_CONFIG_KEY = \"crex-sdk-config\";\n\nexport const CONTENT_LANG_KEY = \"CONTENT_LANG_KEY\";\n\nexport const AVAILABLE_CONTENT_LANG_KEY = \"AVAILABLE_CONTENT_LANG_KEY\";\n\nexport const UI_LANG_KEY = \"UI_LANG_KEY\";\n\nexport const FLAGS_BY_LANG = {\n \"en\": \"US\",\n \"de\": \"DE\",\n};\n\nexport const DEFAULT_LANG = \"en-US\";\n\nexport const EN_LANG = \"en\";\n\nexport const UI_LANG_OPTIONS = [\"en-us\", \"de-de\"];\n\nexport const TOPICS_TYPE_AND_LINK = \"topics\";\nexport const BLOG_TYPE_AND_LINK = \"blog\";\nexport const DOCUMENTS_TYPE_AND_LINK = \"documents\";\n\nexport const TOPIC = \"TOPIC\";\nexport const DOCUMENT = \"DOCUMENT\";\nexport const PACKAGE = \"PACKAGE\";\nexport const FRAGMENT = \"FRAGMENT\";\n\nexport const RESULT_TYPES = {\n TOPIC: TOPIC,\n DOCUMENT: DOCUMENT,\n PACKAGE: PACKAGE,\n FRAGMENT: FRAGMENT\n} as const;\n\nexport const FILES_EXTENSIONS = {\n PDF: \"application/pdf\",\n HTML: \"text/html\",\n} as const;\n\nexport const DEFAULT_COOKIE_LIMIT = 30 * 24 * 60 * 60 * 1000; // 30 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";\n\nexport const CREX_TOKEN_HEADER_KEY = \"crex-token\";\n\nexport const WILD_CARD_OPTIONS = {\n BOTH: \"BOTH\",\n END: \"END\",\n START: \"START\",\n NONE: \"NONE\",\n} as const;\n\nexport const OPERATOR_OPTIONS = {\n AND: \"AND\",\n OR: \"OR\",\n} as const;\n\nexport const ARTICLE_PAGE_LAYOUT = {\n BLOG: \"BLOG\",\n DOCUMENT: \"DOCUMENT\",\n} as const;\n\nexport const DEVICE_OPTIONS = {\n MOBILE: \"mobile\",\n TABLET: \"tablet\",\n DESKTOP: \"desktop\",\n}\nexport const BREAKPOINTS = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n \"2xl\": 1536,\n};","'use server';\n\nimport { SDK_CONFIG_KEY } from '@c-rex/constants';\nimport { ConfigInterface } from '@c-rex/interfaces';\nimport { CookiesConfigs } from '@c-rex/interfaces';\nimport { cookies } from 'next/headers';\n\n/**\n * Retrieves and parses configuration data from a cookie.\n * @returns The parsed configuration object\n * @throws Error if the configuration cookie is not found or cannot be parsed\n */\nexport const getClientConfigs = (): CookiesConfigs => {\n const jsonConfigs = cookies().get(SDK_CONFIG_KEY)?.value;\n if (!jsonConfigs) {\n throw new Error('Configs not found');\n }\n\n const configs: CookiesConfigs = JSON.parse(jsonConfigs);\n\n return configs;\n}\n\nexport const getServerConfigs = async (): Promise<ConfigInterface> => {\n const configs = await getClientConfigs();\n const result = await fetch(`${configs.publicNextApiUrl}/api/config`);\n return result.json();\n}"],"mappings":";;;AAqCO,IAAM,iBAAiB;AAwCvB,IAAM,uBAAuB,KAAK,KAAK,KAAK,KAAK;;;ACxExD,SAAS,eAAe;AAOjB,IAAM,mBAAmB,MAAsB;AAClD,QAAM,cAAc,QAAQ,EAAE,IAAI,cAAc,GAAG;AACnD,MAAI,CAAC,aAAa;AACd,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACvC;AAEA,QAAM,UAA0B,KAAK,MAAM,WAAW;AAEtD,SAAO;AACX;AAEO,IAAM,mBAAmB,YAAsC;AAClE,QAAM,UAAU,MAAM,iBAAiB;AACvC,QAAM,SAAS,MAAM,MAAM,GAAG,QAAQ,gBAAgB,aAAa;AACnE,SAAO,OAAO,KAAK;AACvB;","names":[]}
|