@c-rex/utils 0.1.3 → 0.1.5

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.
@@ -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 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 RESULT_TYPES = {\n TOPIC: \"TOPIC\",\n DOCUMENT: \"DOCUMENT\",\n PACKAGE: \"PACKAGE\",\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 = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";","'use server';\n\nimport { DEFAULT_COOKIE_LIMIT, SDK_CONFIG_KEY } from '@c-rex/constants';\nimport { ConfigInterface } from '@c-rex/interfaces';\nimport { cookies } from 'next/headers';\n\n/*\n* Use this function to get a cookie value by key.\n* @param key - The key of the cookie.\n* @returns The value of the cookie.\n*/\n/**\n * Gets a cookie value from the server-side cookies store.\n * @param key - The key of the cookie to retrieve\n * @returns The value of the cookie\n * @throws Error if the cookie is not found\n */\nexport const getCookieFromBack = (key: string): string => {\n const value = cookies().get(key);\n if (value) {\n return value.value;\n }\n\n throw new Error(`Cookie ${key} not found`);\n}\n\n/**\n * Sets a cookie with secure and HttpOnly flags.\n * @param key - The key of the cookie to set\n * @param value - The value to store in the cookie\n */\nexport const setCookie = (key: string, value: string): void => {\n cookies().set(key, value, {\n path: '/',\n secure: true,\n httpOnly: true,\n maxAge: DEFAULT_COOKIE_LIMIT\n });\n}\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 getConfigs = (): ConfigInterface => {\n const jsonConfigs = getCookieFromBack(SDK_CONFIG_KEY);\n if (!jsonConfigs) {\n throw new Error('Configs not found');\n }\n\n const configs: ConfigInterface = JSON.parse(jsonConfigs);\n\n return configs;\n}"],"mappings":";;;AAoCO,IAAM,iBAAiB;AA8BvB,IAAM,uBAAuB,IAAI,KAAK,KAAK,KAAK;;;AC9DvD,SAAS,eAAe;AAajB,IAAM,oBAAoB,CAAC,QAAwB;AACtD,QAAM,QAAQ,QAAQ,EAAE,IAAI,GAAG;AAC/B,MAAI,OAAO;AACP,WAAO,MAAM;AAAA,EACjB;AAEA,QAAM,IAAI,MAAM,UAAU,GAAG,YAAY;AAC7C;AAOO,IAAM,YAAY,CAAC,KAAa,UAAwB;AAC3D,UAAQ,EAAE,IAAI,KAAK,OAAO;AAAA,IACtB,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,QAAQ;AAAA,EACZ,CAAC;AACL;AAOO,IAAM,aAAa,MAAuB;AAC7C,QAAM,cAAc,kBAAkB,cAAc;AACpD,MAAI,CAAC,aAAa;AACd,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACvC;AAEA,QAAM,UAA2B,KAAK,MAAM,WAAW;AAEvD,SAAO;AACX;","names":[]}
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 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\";\n\nexport const RESULT_TYPES = {\n TOPIC: TOPIC,\n DOCUMENT: DOCUMENT,\n PACKAGE: PACKAGE,\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 = 7 * 24 * 60 * 60 * 1000; // 7 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\";","'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 getConfigs = (): ConfigInterface => {\n const jsonConfigs = cookies().get(SDK_CONFIG_KEY)?.value;\n if (!jsonConfigs) {\n throw new Error('Configs not found');\n }\n\n const configs: ConfigInterface = JSON.parse(jsonConfigs);\n\n return configs;\n}"],"mappings":";;;AAoCO,IAAM,iBAAiB;AAsCvB,IAAM,uBAAuB,IAAI,KAAK,KAAK,KAAK;;;ACtEvD,SAAS,eAAe;AAOjB,IAAM,aAAa,MAAuB;AAC7C,QAAM,cAAc,QAAQ,EAAE,IAAI,cAAc,GAAG;AACnD,MAAI,CAAC,aAAa;AACd,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACvC;AAEA,QAAM,UAA2B,KAAK,MAAM,WAAW;AAEvD,SAAO;AACX;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-rex/utils",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "files": [
5
5
  "dist"
6
6
  ],