@c-rex/services 0.1.3 → 0.1.4

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":["../../core/src/requests.ts","../../constants/src/index.ts","../../utils/src/utils.ts","../../utils/src/memory.ts","../../utils/src/classMerge.ts","../../utils/src/params.ts","../../utils/src/token.ts","../../core/src/cache.ts","../src/baseService.ts","../src/renditions.ts","../src/directoryNodes.ts","../src/transforms/documentTypes.ts","../src/documentTypes.ts","../src/transforms/information.ts","../src/informationUnits.ts","../src/language.ts"],"sourcesContent":["import axios, { AxiosResponse, Method, AxiosInstance } from \"axios\";\nimport { API } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { call, manageToken } from \"@c-rex/utils\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { CrexCache } from \"./cache\";\n\n\n/**\n * Interface for API response with generic data type.\n */\ninterface APIGenericResponse<T> extends AxiosResponse {\n data: T;\n statusCode: number;\n}\n\n/**\n * Interface for API call parameters.\n */\ninterface CallParams {\n url: string;\n method: Method;\n body?: any;\n headers?: any;\n params?: any;\n}\n\n/**\n * API client class for the CREX application.\n * Handles API requests with caching, authentication, and retry logic.\n */\nexport class CrexApi {\n private customerConfig!: ConfigInterface;\n private apiClient!: AxiosInstance;\n private cache!: CrexCache;\n\n /**\n * Initializes the API client if it hasn't been initialized yet.\n * Loads customer configuration, creates the axios instance, and initializes the cache.\n * \n * @private\n */\n private async initAPI() {\n if (!this.customerConfig) {\n this.customerConfig = await getConfigs();\n }\n if (!this.apiClient) {\n this.apiClient = axios.create({\n baseURL: this.customerConfig.baseUrl,\n })\n }\n if (!this.cache) {\n this.cache = new CrexCache();\n }\n }\n\n /**\n * Executes an API request with caching, authentication, and retry logic.\n * \n * @param options - Request options\n * @param options.url - The URL to request\n * @param options.method - The HTTP method to use\n * @param options.params - Optional query parameters\n * @param options.body - Optional request body\n * @param options.headers - Optional request headers\n * @returns The response data\n * @throws Error if the request fails after maximum retries\n */\n async execute<T>({\n url,\n method,\n params,\n body,\n headers = {},\n }: CallParams): Promise<T> {\n await this.initAPI();\n\n let response: APIGenericResponse<T> | undefined = undefined;\n /*\n const cacheKey = this.cache.generateCacheKey({ url, method, body, params, headers });\n\n if (method.toUpperCase() === \"GET\") {\n const cachedResponse = await this.cache.get(cacheKey);\n\n if (cachedResponse) {\n\n return JSON.parse(cachedResponse) as T;\n }\n }\n */\n\n if (this.customerConfig.OIDC.client.enabled) {\n const token = await manageToken();\n\n headers = {\n ...headers,\n Authorization: `Bearer ${token}`,\n };\n\n this.apiClient.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n }\n\n for (let retry = 0; retry < API.MAX_RETRY; retry++) {\n try {\n response = await this.apiClient.request({\n url,\n method,\n data: body,\n params,\n headers,\n });\n\n break;\n } catch (error) {\n call(\"CrexLogger.log\", {\n level: \"error\",\n message: `API.execute ${retry + 1}º error when request ${url}. Error: ${error}`\n });\n\n if (retry === API.MAX_RETRY - 1) {\n throw error;\n }\n }\n }\n\n if (response) {\n return response.data;\n }\n\n throw new Error(\"API.execute error: Failed to retrieve a valid response\");\n }\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 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 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\";","import { FLAGS_BY_LANG } from \"@c-rex/constants\";\n\n/**\n * Makes an asynchronous RPC API call to the server.\n * @param method - The RPC method name to call\n * @param params - Optional parameters to pass to the method\n * @returns A Promise resolving to the response data of type T, or null if an error occurs\n */\nexport const call = async<T = unknown>(method: string, params?: any): Promise<T> => {\n try {\n const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/rpc`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ method, params }),\n credentials: 'include',\n });\n\n const json = await res.json();\n\n if (!res.ok) throw new Error(json.error || 'Unknown error');\n\n return json.data;\n } catch (error) {\n //TODO: add logger\n console.error(error);\n return null as T;\n }\n}\n\n/**\n * Retrieves the country code associated with a given language code.\n * @param lang - The language code to look up (e.g., \"en-US\")\n * @returns The corresponding country code, or the original language code if not found\n */\nexport const getCountryCodeByLang = (lang: string): string => {\n const mappedKeys = Object.keys(FLAGS_BY_LANG);\n\n if (!mappedKeys.includes(lang)) {\n return lang\n }\n\n type LangKey = keyof typeof FLAGS_BY_LANG;\n const country = FLAGS_BY_LANG[lang as LangKey]\n\n return country\n}\n\nexport const getFromCookieString = (cookieString: string, key: string): string => {\n const cookies = cookieString.split(';')\n\n for (const cookie of cookies) {\n const [cookieKey, cookieValue] = cookie.trim().split('=')\n\n if (cookieKey === key) {\n return cookieValue as string;\n }\n }\n\n return ''\n}\n","import { DEFAULT_COOKIE_LIMIT } from \"@c-rex/constants\";\nimport { call } from \"./utils\";\n\n/**\n * Fetches a cookie value from the server API in client-side code.\n * @param key - The key of the cookie to retrieve\n * @returns A Promise resolving to an object containing the key and value of the cookie\n */\nexport const getCookie = async (key: string): Promise<{ key: string, value: string | null }> => {\n const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/cookies?key=${key}`);\n\n if (!res.ok) {\n return { key: key, value: null };\n }\n const json = await res.json();\n\n return json;\n}\n\n/**\n * Sets a cookie value through the server API in client-side code.\n * @param key - The key of the cookie to set\n * @param value - The value to store in the cookie\n * @param maxAge - Optional maximum age of the cookie in seconds. Defaults to DEFAULT_COOKIE_LIMIT if not specified.\n * @returns A Promise that resolves when the cookie has been set\n */\nexport const setCookie = async (key: string, value: string, maxAge?: number): Promise<void> => {\n try {\n\n if (maxAge === undefined) {\n maxAge = DEFAULT_COOKIE_LIMIT;\n }\n\n await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/cookies`, {\n method: 'POST',\n credentials: 'include',\n body: JSON.stringify({\n key: key,\n value: value,\n maxAge: maxAge,\n }),\n });\n } catch (error) {\n call(\"CrexLogger.log\", {\n level: \"error\",\n message: `utils.setCookie error: ${error}`\n });\n }\n}\n\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merges multiple class values into a single string using clsx and tailwind-merge.\n * Useful for conditionally applying Tailwind CSS classes.\n * @param inputs - Any number of class values (strings, objects, arrays, etc.)\n * @returns A merged string of class names optimized for Tailwind CSS\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import { QueryParams } from '@c-rex/types';\n\n/**\n * Creates an array of parameter objects from a list of field values.\n * @param fieldsList - Array of field values to transform into parameter objects\n * @param key - The key to use for each parameter object (defaults to \"Fields\")\n * @returns An array of objects with key-value pairs\n */\nexport const createParams = (fieldsList: string[], key: string = \"Fields\") =>\n fieldsList.map((item) => ({\n key: key,\n value: item,\n }));\n\n/**\n * Generates a URL query string from an array of parameter objects.\n * @param params - Array of QueryParams objects containing key-value pairs\n * @returns A URL-encoded query string\n */\nexport const generateQueryParams = (params: QueryParams[]): string => {\n const queryParams = params\n .map(\n (param) =>\n `${encodeURIComponent(param.key)}=${encodeURIComponent(param.value)}`,\n )\n .join(\"&\");\n return queryParams;\n};\n","import { CREX_TOKEN_HEADER_KEY } from \"@c-rex/constants\";\nimport { getCookie } from \"./memory\";\nimport { call } from \"./utils\";\n\nconst updateToken = async (): Promise<string | null> => {\n try {\n const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/token`, {\n method: 'POST',\n credentials: 'include',\n });\n\n const cookies = response.headers.get(\"set-cookie\");\n if (cookies === null) return null\n\n const aux = cookies.split(`${CREX_TOKEN_HEADER_KEY}=`);\n if (aux.length == 0) return null\n\n const token = aux[1].split(\";\")[0];\n if (token === undefined) throw new Error(\"Token is undefined\");\n\n return token;\n } catch (error) {\n call(\"CrexLogger.log\", {\n level: \"error\",\n message: `utils.updateToken error: ${error}`\n });\n return null\n }\n}\n\nexport const manageToken = async (): Promise<string | null> => {\n try {\n\n const hasToken = await getCookie(CREX_TOKEN_HEADER_KEY);\n let token = hasToken.value!;\n\n if (hasToken.value === null) {\n const tokenResult = await updateToken();\n\n if (tokenResult === null) throw new Error(\"Token is undefined\");\n\n token = tokenResult;\n }\n\n return token;\n } catch (error) {\n call(\"CrexLogger.log\", {\n level: \"error\",\n message: `utils.manageToken error: ${error}`\n });\n\n return null\n }\n}","import { call, getCookie, setCookie } from \"@c-rex/utils\";\n\n/**\n * Cache class for the CREX application.\n * Provides cookie-based caching functionality for API responses.\n */\nexport class CrexCache {\n /**\n * Retrieves a value from the cache by key.\n * \n * @param key - The cache key to retrieve\n * @returns The cached value as a string, or null if not found\n */\n public async get(key: string): Promise<string | null> {\n const cookie = await getCookie(key);\n\n return cookie.value;\n }\n\n /**\n * Stores a value in the cache with the specified key.\n * Checks if the value size is within cookie size limits (4KB).\n * \n * @param key - The cache key\n * @param value - The value to store\n */\n public async set(key: string, value: string): Promise<void> {\n try {\n const byteLength = new TextEncoder().encode(value).length;\n\n if (byteLength <= 4096) {\n await setCookie(key, value);\n } else {\n console.warn(`Cookie ${key} value is too large to be stored in a single cookie`);\n }\n\n } catch (error) {\n call(\"CrexLogger.log\", {\n level: \"error\",\n message: `CrexCache.set error: ${error}`\n });\n }\n }\n\n /**\n * Generates a cache key based on request parameters.\n * Combines URL, method, and optionally params, body, and headers into a single string key.\n * \n * @param options - Request options to generate key from\n * @param options.url - The request URL\n * @param options.method - The HTTP method\n * @param options.body - Optional request body\n * @param options.params - Optional query parameters\n * @param options.headers - Optional request headers\n * @returns A string cache key\n */\n public generateCacheKey({\n url,\n method,\n body,\n params,\n headers,\n }: any) {\n let cacheKey = `${url}-${method}`\n\n if (params !== undefined && Object.keys(params).length > 0) {\n cacheKey += `-${JSON.stringify(params)}`\n }\n if (body !== undefined && Object.keys(body).length > 0) {\n cacheKey += `-${JSON.stringify(body)}`\n }\n if (headers !== undefined && Object.keys(headers).length > 0) {\n cacheKey += `-${JSON.stringify(headers)}`\n }\n\n return cacheKey;\n }\n}","import { CrexApi } from \"@c-rex/core\";\nimport { QueryParams } from \"@c-rex/types\";\nimport { call, generateQueryParams } from \"@c-rex/utils\";\nimport { Method } from \"axios\";\n\n/**\n * Base service class that provides common functionality for API interactions.\n * All specific service classes extend this base class.\n */\nexport class BaseService {\n protected api: CrexApi;\n private endpoint: string;\n\n /**\n * Creates a new instance of BaseService.\n * \n * @param endpoint - The API endpoint URL for this service\n */\n constructor(endpoint: string) {\n this.api = new CrexApi();\n this.endpoint = endpoint;\n }\n\n /**\n * Makes an API request to the specified endpoint.\n * \n * @param options - Request configuration options\n * @param options.path - Optional path to append to the endpoint\n * @param options.params - Optional query parameters to include in the request\n * @param options.method - HTTP method to use (defaults to 'get')\n * @param options.transformer - Optional function to transform the response data\n * @returns The response data, optionally transformed\n * @throws Error if the API request fails\n */\n protected async request<T>({\n path = \"\",\n method = \"get\",\n params = [],\n headers = {},\n transformer = (response: any) => response,\n }: {\n path?: string,\n method?: Method,\n params?: QueryParams[],\n headers?: any,\n transformer?: (data: any) => T,\n }): Promise<T> {\n try {\n let url = `${this.endpoint}${path}`;\n\n const queryParams = generateQueryParams(params);\n if (queryParams.length > 0) {\n url += `?${queryParams}`;\n }\n\n const response = await this.api.execute({\n url,\n method,\n headers,\n })\n\n return await transformer(response);\n\n } catch (error) {\n call(\"CrexLogger.log\", {\n level: \"error\",\n message: `BaseService.request error when request ${path}. Error: ${error}`\n });\n\n throw error;\n }\n }\n}\n\n","import { FileRenditionType } from \"@c-rex/types\";\nimport { BaseService } from \"./baseService\";\nimport { informationUnitsRenditions } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with renditions in the API.\n * Provides methods to retrieve and process different types of renditions.\n */\nexport class RenditionsService extends BaseService {\n constructor() {\n super(\"Renditions/\");\n }\n\n /**\n * Retrieves the HTML rendition from a list of renditions.\n * Filters for renditions with format 'application/xhtml+xml' and rel 'view'.\n * \n * @param renditions - Array of rendition objects to process\n * @returns A promise that resolves to the HTML content as a string, or empty string if no suitable rendition is found\n * @throws Error if the API request fails\n */\n public async getHTMLRendition({ renditions }: { renditions: informationUnitsRenditions[] }): Promise<string> {\n const filteredRenditions = renditions.filter(\n (item) => item.format == \"application/xhtml+xml\",\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) return \"\";\n const item = filteredRenditions[0];\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n\n if (filteredLinks.length == 0 || filteredLinks[0] == undefined) return \"\";\n const url = filteredLinks[0].href;\n const response = await this.api.execute({\n url,\n method: \"get\",\n headers: {\n Accept: \"application/xhtml+xml\",\n },\n })\n\n return response as string;\n }\n\n /**\n * Processes a list of renditions and categorizes them into files to download and files to open.\n * Excludes renditions with formats 'application/xhtml+xml', 'application/json', and 'application/llm+xml'.\n * \n * @param renditions - Array of rendition objects to process\n * @returns An object containing arrays of file renditions categorized as 'filesToDownload' and 'filesToOpen'\n */\n public getFileRenditions = ({ renditions }: { renditions: informationUnitsRenditions[] }): {\n filesToDownload: FileRenditionType[],\n filesToOpen: FileRenditionType[]\n } => {\n if (renditions == undefined || renditions.length == 0) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filteredRenditions = renditions.filter(\n (item) => item.format != \"application/xhtml+xml\" && item.format != \"application/json\" && item.format != \"application/llm+xml\"\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filesToDownload = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"download\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n });\n\n const filesToOpen = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n })\n\n return {\n filesToDownload: filesToDownload,\n filesToOpen: filesToOpen,\n }\n }\n}","import { BaseService } from \"./baseService\";\nimport { createParams } from \"@c-rex/utils\";\nimport { DirectoryNodes, DirectoryNodesResponse } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with directory nodes in the API.\n * Provides methods to retrieve directory node information.\n */\nexport class DirectoryNodesService extends BaseService {\n constructor() {\n super(\"DirectoryNodes/\");\n }\n\n /**\n * Retrieves a specific directory node by its ID.\n * \n * @param id - The unique identifier of the directory node\n * @returns A promise that resolves to the directory node data\n * @throws Error if the API request fails\n */\n public async getItem(id: string): Promise<DirectoryNodes> {\n return await this.request({\n path: id,\n });\n }\n\n /**\n * Retrieves a list of directory nodes based on specified filters.\n * \n * @param options - Options for filtering the directory nodes list\n * @param options.filters - Optional array of filter strings to apply\n * @returns A promise that resolves to the directory nodes response\n * @throws Error if the API request fails\n */\n public async getList({\n filters = [],\n }: {\n filters?: string[],\n }): Promise<DirectoryNodesResponse> {\n\n const remainFilters = createParams(filters, \"Filter\");\n\n return await this.request({\n params: {\n ...remainFilters,\n },\n });\n }\n}\n","import { DefaultRequest } from \"@c-rex/interfaces\";\nimport { DocumentTypesItem } from \"@c-rex/interfaces\";\n\nexport const transformDocumentTypes = (data: DefaultRequest<DocumentTypesItem>) => {\n const labels: string[] = [];\n\n data.items.forEach((documentItem: DocumentTypesItem) => {\n const aux = documentItem.labels.flatMap((item) => item);\n\n aux.forEach((item) => {\n if (item.language == \"en\") labels.push(item.value);\n });\n });\n\n return labels;\n};\n","import { createParams } from \"@c-rex/utils\";\nimport { transformDocumentTypes } from \"./transforms/documentTypes\";\nimport { BaseService } from \"./baseService\";\n\n/**\n * Service for interacting with document types in the API.\n * Provides methods to retrieve document type information.\n */\nexport class DocumentTypesService extends BaseService {\n constructor() {\n super(\"DocumentTypes/\");\n }\n\n /**\n * Retrieves document type labels for the specified fields.\n * The labels are restricted to English language (EN-us).\n * \n * @param fields - Array of field names to retrieve labels for\n * @returns A promise that resolves to an array of label strings\n * @throws Error if the API request fails\n */\n public async getLabels(fields: string[]): Promise<string[]> {\n const params = [\n {\n key: \"Restrict\",\n value: `languages~EN-us`,\n },\n ...createParams(fields, \"Fields\"),\n ];\n\n return await this.request({\n params,\n transformer: transformDocumentTypes,\n });\n }\n}\n","import { EN_LANG, RESULT_TYPES } from \"@c-rex/constants\";\nimport {\n DefaultRequest,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { RenditionsService } from \"../renditions\";\n\nexport const transformInformationUnits = async (\n data: DefaultRequest<informationUnitsItems>,\n): Promise<informationUnitsResponse> => {\n const config = getConfigs();\n\n const items = await Promise.all(data.items.map(async (item) => {\n const type = item.class.labels.filter((item) => item.language === EN_LANG)[0].value.toUpperCase();\n const service = new RenditionsService();\n const { filesToOpen, filesToDownload } = service.getFileRenditions({ renditions: item?.renditions });\n\n let link = `/topics/${item.shortId}`;\n\n if (config.results.articlePageLayout == \"BLOG\") {\n link = `/blog/${item.shortId}`\n } else if (type == RESULT_TYPES.DOCUMENT) {\n link = `/documents/${item.shortId}`;\n }\n\n return {\n language: item.labels[0].language,\n title: item.labels[0].value,\n type: type,\n localeType: \"\",\n shortId: item.shortId,\n disabled: config.results.disabledResults.includes(type as any),\n link: link,\n filesToOpen,\n filesToDownload\n }\n }));\n return {\n items: items,\n pageInfo: data.pageInfo,\n };\n};","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\n\n/**\n * Service for interacting with information units in the API.\n * Provides methods to retrieve and search information units.\n */\nexport class InformationUnitsService extends BaseService {\n constructor() {\n super(\"InformationUnits/\");\n }\n\n /**\n * Retrieves a list of information units based on specified criteria.\n * \n * @param options - Options for filtering and paginating the information units list\n * @param options.queries - Optional search query string\n * @param options.page - Optional page number for pagination (defaults to 1)\n * @param options.fields - Optional array of fields to include in the response\n * @param options.filters - Optional array of filter strings to apply\n * @param options.languages - Optional array of language codes to filter by\n * @returns A promise that resolves to the information units response\n * @throws Error if the API request fails\n */\n public async getList({\n queries = \"\",\n page = 1,\n fields = [],\n filters = [],\n languages = []\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n fields?: string[],\n languages?: string[]\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const languageParams = createParams(\n languages.map(item => `languages=${item}`),\n \"Filter\"\n );\n /*\n const languageParams = createParams(\n languages.map(item => `?s iirds:language ${item}`),\n \"sparqlWhere\"\n );\n */\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"PageNumber\", value: page.toString() },\n ...remainFields,\n ...languageParams,\n ...remainFilters\n ];\n\n if (queries.length > 0) {\n params.push(\n { key: \"Query\", value: queries },\n );\n }\n\n return await this.request({\n params: params,\n transformer: transformInformationUnits\n });\n }\n\n /**\n * Retrieves a specific information unit by its ID.\n * Includes renditions, directory nodes, version information, titles, languages, and labels.\n * \n * @param options - Options for retrieving the information unit\n * @param options.id - The unique identifier of the information unit\n * @returns A promise that resolves to the information unit data\n * @throws Error if the API request fails\n */\n public async getItem({ id }: { id: string }): Promise<informationUnitsItems> {\n const params = [\n { key: \"Fields\", value: \"renditions\" },\n { key: \"Fields\", value: \"directoryNodes\" },\n { key: \"Fields\", value: \"versionOf\" },\n { key: \"Fields\", value: \"titles\" },\n { key: \"Fields\", value: \"languages\" },\n { key: \"Fields\", value: \"labels\" },\n ];\n\n return await this.request({\n path: id,\n params,\n });\n }\n\n /**\n * Retrieves autocomplete suggestions based on a query prefix.\n * \n * @param options - Options for retrieving suggestions\n * @param options.query - The query prefix to get suggestions for\n * @param options.language - The language of the suggestions\n * @returns A promise that resolves to an array of suggestion strings\n * @throws Error if the API request fails\n */\n public async getSuggestions(\n { query, language }: { query: string, language: string }\n ): Promise<string[]> {\n return await this.request({\n path: `Suggestions`,\n params: [\n { key: \"prefix\", value: query },\n { key: \"lang\", value: language },\n ],\n transformer: (data: AutocompleteSuggestion) => {\n const suggestions: string[] = []\n const comparableList: string[] = []\n\n data.suggestions.forEach((item) => {\n suggestions.push(item.value);\n comparableList.push(item.value.toLowerCase())\n })\n\n if (!comparableList.includes(query.toLowerCase())) {\n return [query, ...suggestions];\n }\n\n return suggestions\n },\n });\n }\n}\n","import { LanguageAndCountries } from \"@c-rex/interfaces\";\nimport { BaseService } from \"./baseService\";\nimport { getCountryCodeByLang } from \"@c-rex/utils\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\n/**\n * Service for interacting with language-related functionality in the API.\n * Provides methods to retrieve language and country information.\n */\nexport class LanguageService extends BaseService {\n constructor() {\n const configs = getConfigs()\n super(configs.languageSwitcher.endpoint);\n\n }\n\n /*\n public static async getInstance(): Promise<LanguageService> {\n const customerConfig = await getConfigs()\n\n if (!LanguageService.instance) {\n LanguageService.instance = new LanguageService(customerConfig.languageSwitcher.endpoint);\n }\n return LanguageService.instance;\n }\n */\n\n /**\n * Retrieves a list of available languages and their associated countries.\n * Transforms the API response to include language code, country code, and original value.\n * \n * @returns A promise that resolves to an array of language and country objects\n * @throws Error if the API request fails\n */\n public async getLanguagesAndCountries(): Promise<LanguageAndCountries[]> {\n return await this.request({\n transformer: (data: { value: string; score: number }[]) => {\n const countryCodeList = data.map((item) => {\n /*\n api -> en, en-US\n default -> en-US. Then use EN-US \n\n api -> en\n default -> en-US. Then use EN\n */\n //should be abble to handle this items: en-US, en, pt, pt-PT, pt-BR \n\n const splittedValue = item.value.split(\"-\")\n const lang = splittedValue[0]\n let country = splittedValue[0]\n\n if (splittedValue.length > 1) {\n country = splittedValue[1]\n } else {\n country = getCountryCodeByLang(lang)\n }\n\n return {\n country: country,\n lang: lang,\n value: item.value,\n }\n })\n\n return countryCodeList.sort((a, b) => {\n return a.value.localeCompare(b.value)\n })\n },\n });\n }\n}\n"],"mappings":";AAAA,OAAO,WAAqD;;;AC4BrD,IAAM,MAAM;AAAA,EACf,WAAW;AAAA,EACX,aAAa;AAAA,EACb,aAAa;AAAA,IACT,gBAAgB;AAAA,EACpB;AACJ;AAUO,IAAM,gBAAgB;AAAA,EACzB,MAAM;AAAA,EACN,MAAM;AACV;AAIO,IAAM,UAAU;AAOhB,IAAM,QAAQ;AACd,IAAM,W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AC1C,gBAAM,OAAO,cAAc,CAAC;AAC5B,cAAI,UAAU,cAAc,CAAC;AAE7B,cAAI,cAAc,SAAS,GAAG;AAC1B,sBAAU,cAAc,CAAC;AAAA,UAC7B,OAAO;AACH,sBAAU,qBAAqB,IAAI;AAAA,UACvC;AAEA,iBAAO;AAAA,YACH;AAAA,YACA;AAAA,YACA,OAAO,KAAK;AAAA,UAChB;AAAA,QACJ,CAAC;AAED,eAAO,gBAAgB,KAAK,CAAC,GAAG,MAAM;AAClC,iBAAO,EAAE,MAAM,cAAc,EAAE,KAAK;AAAA,QACxC,CAAC;AAAA,MACL;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;","names":["item","getConfigs","getConfigs","item","getConfigs"]}
1
+ {"version":3,"sources":["../../core/src/requests.ts","../../constants/src/index.ts","../../core/src/logger.ts","../../core/src/transports/matomo.ts","../../core/src/transports/graylog.ts","../../utils/src/utils.ts","../../utils/src/call.ts","../../utils/src/classMerge.ts","../../utils/src/params.ts","../../utils/src/renditions.ts","../src/baseService.ts","../src/renditions.ts","../src/directoryNodes.ts","../src/transforms/documentTypes.ts","../src/documentTypes.ts","../src/transforms/information.ts","../src/informationUnits.ts","../src/language.ts"],"sourcesContent":["import axios, { AxiosResponse, Method, AxiosInstance } from \"axios\";\nimport { API, CREX_TOKEN_HEADER_KEY, SDK_CONFIG_KEY } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { cookies } from \"next/headers\";\nimport { CrexLogger } from \"./logger\";\n\n/**\n * Interface for API response with generic data type.\n */\ninterface APIGenericResponse<T> extends AxiosResponse {\n data: T;\n statusCode: number;\n}\n\n/**\n * Interface for API call parameters.\n */\ninterface CallParams {\n url: string;\n method: Method;\n body?: any;\n headers?: any;\n params?: any;\n}\n\n/**\n * API client class for the CREX application.\n * Handles API requests with caching, authentication, and retry logic.\n */\nexport class CrexApi {\n private customerConfig!: ConfigInterface;\n private apiClient!: AxiosInstance;\n private logger!: CrexLogger;\n\n /**\n * Initializes the API client if it hasn't been initialized yet.\n * Loads customer configuration, creates the axios instance, and initializes the logger.\n * \n * @private\n */\n private async initAPI() {\n this.logger = new CrexLogger();\n\n if (!this.customerConfig) {\n const aux = cookies().get(SDK_CONFIG_KEY);\n if (aux != undefined) {\n this.customerConfig = JSON.parse(aux.value);\n } else {\n this.logger.log({\n level: \"error\",\n message: `utils.initAPI error: Config cookie not available`\n });\n\n throw new Error(\"Config cookie not available\");\n }\n }\n\n if (!this.apiClient) {\n this.apiClient = axios.create({\n baseURL: this.customerConfig.baseUrl,\n })\n }\n }\n\n private async getToken() {\n try {\n const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/token`, {\n method: 'POST',\n credentials: 'include',\n });\n\n const { token } = await response.json();\n\n return token;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `utils.getToken error: ${error}`\n });\n\n throw error\n }\n }\n\n private async manageToken() {\n try {\n let token = \"\";\n const hasToken = cookies().get(CREX_TOKEN_HEADER_KEY);\n\n if (hasToken == undefined || hasToken.value === null) {\n const tokenResult = await this.getToken();\n\n if (tokenResult === null) throw new Error(\"Token is undefined\");\n\n token = tokenResult;\n } else {\n token = hasToken.value;\n }\n\n return token;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `utils.manageToken error: ${error}`\n });\n\n throw error\n }\n }\n\n /**\n * Executes an API request with caching, authentication, and retry logic.\n * \n * @param options - Request options\n * @param options.url - The URL to request\n * @param options.method - The HTTP method to use\n * @param options.params - Optional query parameters\n * @param options.body - Optional request body\n * @param options.headers - Optional request headers\n * @returns The response data\n * @throws Error if the request fails after maximum retries\n */\n async execute<T>({\n url,\n method,\n params,\n body,\n headers = {},\n }: CallParams): Promise<T> {\n await this.initAPI();\n\n let response: APIGenericResponse<T> | undefined = undefined;\n\n if (this.customerConfig.OIDC.client.enabled) {\n const token = await this.manageToken();\n\n headers = {\n ...headers,\n Authorization: `Bearer ${token}`,\n };\n\n this.apiClient.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n }\n\n for (let retry = 0; retry < API.MAX_RETRY; retry++) {\n try {\n response = await this.apiClient.request({\n url,\n method,\n data: body,\n params,\n headers,\n });\n\n break;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `API.execute ${retry + 1}º error when request ${url}. Error: ${error}`\n });\n\n if (retry === API.MAX_RETRY - 1) {\n throw error;\n }\n }\n }\n\n if (response) {\n return response.data;\n }\n\n throw new Error(\"API.execute error: Failed to retrieve a valid response\");\n }\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 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\";","import winston from \"winston\";\nimport { MatomoTransport } from \"./transports/matomo\";\nimport { GraylogTransport } from \"./transports/graylog\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { LOG_LEVELS } from \"@c-rex/constants\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\n/**\n * Logger class for the CREX application.\n * Provides logging functionality with multiple transports (Console, Matomo, Graylog).\n */\nexport class CrexLogger {\n private customerConfig!: ConfigInterface;\n public logger!: winston.Logger;\n\n /**\n * Initializes the logger instance if it hasn't been initialized yet.\n * Loads customer configuration and creates the logger with appropriate transports.\n * \n * @private\n */\n private async initLogger() {\n try {\n if (!this.customerConfig) {\n this.customerConfig = await getConfigs();\n }\n if (!this.logger) {\n this.logger = this.createLogger();\n }\n } catch (error) {\n console.error(\"Error initializing logger:\", error);\n }\n }\n\n /**\n * Logs a message with the specified level and optional category.\n * \n * @param options - Logging options\n * @param options.level - The log level (error, warn, info, etc.)\n * @param options.message - The message to log\n * @param options.category - Optional category for the log message\n */\n public async log({ level, message, category }: {\n level: LogLevelType,\n message: string,\n category?: LogCategoriesType\n }) {\n await this.initLogger();\n this.logger.log(level, message, category);\n }\n\n /**\n * Creates a new Winston logger instance with configured transports.\n * \n * @private\n * @returns A configured Winston logger instance\n */\n private createLogger() {\n return winston.createLogger({\n levels: LOG_LEVELS,\n transports: [\n new winston.transports.Console({\n level: this.customerConfig.logs.console.minimumLevel,\n silent: this.customerConfig.logs.console.silent,\n }),\n new MatomoTransport(this.customerConfig),\n new GraylogTransport(this.customerConfig),\n ],\n });\n }\n}","import Transport from \"winston-transport\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\n/**\n * Winston transport for sending logs to Matomo analytics.\n * Extends the base Winston transport with Matomo-specific functionality.\n */\nexport class MatomoTransport extends Transport {\n public matomoTransport: any;\n private configs: ConfigInterface;\n\n /**\n * Creates a new instance of MatomoTransport.\n * \n * @param configs - The application configuration containing logging settings\n */\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.matomo.minimumLevel,\n silent: configs.logs.matomo.silent,\n });\n\n this.matomoTransport = new Transport();\n this.configs = configs;\n }\n\n /**\n * Logs a message to Matomo if the message category is included in the configured categories.\n * \n * @param info - The log information including level, message, and category\n * @param callback - Callback function to execute after logging\n */\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const matomoCategory = this.configs.logs.matomo.categoriesLevel\n\n if (matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {\n this.matomoTransport.log(info, callback);\n }\n }\n}\n","import Transport from \"winston-transport\";\nimport Graylog2Transport from \"winston-graylog2\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\n/**\n * Winston transport for sending logs to Graylog.\n * Extends the base Winston transport with Graylog-specific functionality.\n */\nexport class GraylogTransport extends Transport {\n public graylogTransport: any;\n private configs: ConfigInterface\n\n /**\n * Creates a new instance of GraylogTransport.\n * \n * @param configs - The application configuration containing logging settings\n */\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.graylog.minimumLevel,\n silent: configs.logs.graylog.silent,\n });\n\n this.configs = configs;\n this.graylogTransport = new Graylog2Transport({\n name: \"crex.net.documentation\",\n //name: \"crex.net.blog\",\n silent: false,\n handleExceptions: false,\n graylog: {\n servers: [\n { host: \"localhost\", port: 12201 },\n { host: \"https://log.c-rex.net\", port: 12202 }\n\n //TODO: check the URL => https://log.c-rex.net:12202/gelf\" GELF??\n ],\n },\n });\n }\n\n /**\n * Logs a message to Graylog if the message category is included in the configured categories.\n * \n * @param info - The log information including level, message, and category\n * @param callback - Callback function to execute after logging\n */\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const graylogCategory = this.configs.logs.graylog.categoriesLevel\n\n if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {\n this.graylogTransport.log(info, callback);\n }\n }\n}\n","import { FLAGS_BY_LANG } from \"@c-rex/constants\";\n\nexport const _generateShaKey = async (input: string): Promise<string> => {\n const encoder = new TextEncoder();\n const data = encoder.encode(input);\n const hashBuffer = await crypto.subtle.digest('SHA-1', data);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const base64url = btoa(String.fromCharCode(...hashArray))\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '');\n\n return base64url.slice(0, 12);\n}\n\n/**\n * Retrieves the country code associated with a given language code.\n * @param lang - The language code to look up (e.g., \"en-US\")\n * @returns The corresponding country code, or the original language code if not found\n */\nexport const getCountryCodeByLang = (lang: string): string => {\n const mappedKeys = Object.keys(FLAGS_BY_LANG);\n\n if (!mappedKeys.includes(lang)) {\n return lang\n }\n\n type LangKey = keyof typeof FLAGS_BY_LANG;\n const country = FLAGS_BY_LANG[lang as LangKey]\n\n return country\n}\n\nexport const getFromCookieString = (cookieString: string, key: string): string => {\n const cookies = cookieString.split(';')\n\n for (const cookie of cookies) {\n const [cookieKey, cookieValue] = cookie.trim().split('=')\n\n if (cookieKey === key) {\n return cookieValue as string;\n }\n }\n\n return ''\n}\n","import { _generateShaKey } from \"./utils\"\n\n/**\n * Makes an asynchronous RPC API call to the server.\n * @param method - The RPC method name to call\n * @param params - Optional parameters to pass to the method\n * @returns A Promise resolving to the response data of type T\n */\nexport const call = async<T = unknown>(method: string, params?: any): Promise<T> => {\n type result = {\n data: string,\n expireDate: Date,\n }\n\n const shaKey = await _generateShaKey(JSON.stringify({ method, params }))\n const cache = localStorage.getItem(shaKey)\n\n if (cache !== null) {\n const { data, expireDate } = JSON.parse(cache) as result\n\n if (new Date(expireDate) > new Date()) {\n return JSON.parse(data) as T\n } else {\n localStorage.removeItem(shaKey)\n }\n }\n\n const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/rpc`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ method, params }),\n credentials: 'include',\n });\n\n const json = await res.json();\n\n if (!res.ok) throw new Error(json.error || 'Unknown error');\n\n const today = new Date()\n const result: result = {\n data: JSON.stringify(json.data),\n expireDate: new Date(today.getTime() + 1000 * 60 * 60),\n }\n\n localStorage.setItem(shaKey, JSON.stringify(result))\n\n return json.data;\n}","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merges multiple class values into a single string using clsx and tailwind-merge.\n * Useful for conditionally applying Tailwind CSS classes.\n * @param inputs - Any number of class values (strings, objects, arrays, etc.)\n * @returns A merged string of class names optimized for Tailwind CSS\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import { QueryParams } from '@c-rex/types';\n\n/**\n * Creates an array of parameter objects from a list of field values.\n * @param fieldsList - Array of field values to transform into parameter objects\n * @param key - The key to use for each parameter object (defaults to \"Fields\")\n * @returns An array of objects with key-value pairs\n */\nexport const createParams = (fieldsList: string[], key: string = \"Fields\") =>\n fieldsList.map((item) => ({\n key: key,\n value: item,\n }));\n\n/**\n * Generates a URL query string from an array of parameter objects.\n * @param params - Array of QueryParams objects containing key-value pairs\n * @returns A URL-encoded query string\n */\nexport const generateQueryParams = (params: QueryParams[]): string => {\n const queryParams = params\n .map(\n (param) =>\n `${encodeURIComponent(param.key)}=${encodeURIComponent(param.value)}`,\n )\n .join(\"&\");\n return queryParams;\n};\n","import { FileRenditionType } from \"@c-rex/types\";\nimport { informationUnitsRenditions } from \"@c-rex/interfaces\";\n\ntype RenditionType = {\n filesToDownload: FileRenditionType[],\n filesToOpen: FileRenditionType[]\n}\nexport const getFileRenditions = ({ renditions }: { renditions: informationUnitsRenditions[] }): RenditionType => {\n if (renditions == undefined || renditions.length == 0) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filteredRenditions = renditions.filter(\n (item) => item.format != \"application/xhtml+xml\" && item.format != \"application/json\" && item.format != \"application/llm+xml\"\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filesToDownload = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"download\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n });\n\n const filesToOpen = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n })\n\n return {\n filesToDownload: filesToDownload,\n filesToOpen: filesToOpen,\n }\n}","import { CrexApi } from \"@c-rex/core\";\nimport { QueryParams } from \"@c-rex/types\";\nimport { call, generateQueryParams } from \"@c-rex/utils\";\nimport { Method } from \"axios\";\n\n/**\n * Base service class that provides common functionality for API interactions.\n * All specific service classes extend this base class.\n */\nexport class BaseService {\n protected api: CrexApi;\n private endpoint: string;\n\n /**\n * Creates a new instance of BaseService.\n * \n * @param endpoint - The API endpoint URL for this service\n */\n constructor(endpoint: string) {\n this.api = new CrexApi();\n this.endpoint = endpoint;\n }\n\n /**\n * Makes an API request to the specified endpoint.\n * \n * @param options - Request configuration options\n * @param options.path - Optional path to append to the endpoint\n * @param options.params - Optional query parameters to include in the request\n * @param options.method - HTTP method to use (defaults to 'get')\n * @param options.transformer - Optional function to transform the response data\n * @returns The response data, optionally transformed\n * @throws Error if the API request fails\n */\n protected async request<T>({\n path = \"\",\n method = \"get\",\n params = [],\n headers = {},\n transformer = (response: any) => response,\n }: {\n path?: string,\n method?: Method,\n params?: QueryParams[],\n headers?: any,\n transformer?: (data: any) => T,\n }): Promise<T> {\n try {\n let url = `${this.endpoint}${path}`;\n\n const queryParams = generateQueryParams(params);\n if (queryParams.length > 0) {\n url += `?${queryParams}`;\n }\n\n const response = await this.api.execute({\n url,\n method,\n headers,\n })\n\n return await transformer(response);\n\n } catch (error) {\n call(\"CrexLogger.log\", {\n level: \"error\",\n message: `BaseService.request error when request ${path}. Error: ${error}`\n });\n\n throw error;\n }\n }\n}\n\n","import { BaseService } from \"./baseService\";\nimport { informationUnitsRenditions } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with renditions in the API.\n * Provides methods to retrieve and process different types of renditions.\n */\nexport class RenditionsService extends BaseService {\n constructor() {\n super(\"Renditions/\");\n }\n\n /**\n * Retrieves the HTML rendition from a list of renditions.\n * Filters for renditions with format 'application/xhtml+xml' and rel 'view'.\n * \n * @param renditions - Array of rendition objects to process\n * @returns A promise that resolves to the HTML content as a string, or empty string if no suitable rendition is found\n * @throws Error if the API request fails\n */\n public async getHTMLRendition({ renditions }: { renditions: informationUnitsRenditions[] }): Promise<string> {\n const filteredRenditions = renditions.filter(\n (item) => item.format == \"application/xhtml+xml\",\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) return \"\";\n const item = filteredRenditions[0];\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n\n if (filteredLinks.length == 0 || filteredLinks[0] == undefined) return \"\";\n const url = filteredLinks[0].href;\n const response = await this.api.execute({\n url,\n method: \"get\",\n headers: {\n Accept: \"application/xhtml+xml\",\n },\n })\n\n return response as string;\n }\n}","import { BaseService } from \"./baseService\";\nimport { createParams } from \"@c-rex/utils\";\nimport { DirectoryNodes, DirectoryNodesResponse } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with directory nodes in the API.\n * Provides methods to retrieve directory node information.\n */\nexport class DirectoryNodesService extends BaseService {\n constructor() {\n super(\"DirectoryNodes/\");\n }\n\n /**\n * Retrieves a specific directory node by its ID.\n * \n * @param id - The unique identifier of the directory node\n * @returns A promise that resolves to the directory node data\n * @throws Error if the API request fails\n */\n public async getItem(id: string): Promise<DirectoryNodes> {\n return await this.request({\n path: id,\n });\n }\n\n /**\n * Retrieves a list of directory nodes based on specified filters.\n * \n * @param options - Options for filtering the directory nodes list\n * @param options.filters - Optional array of filter strings to apply\n * @returns A promise that resolves to the directory nodes response\n * @throws Error if the API request fails\n */\n public async getList({\n filters = [],\n }: {\n filters?: string[],\n }): Promise<DirectoryNodesResponse> {\n\n const remainFilters = createParams(filters, \"Filter\");\n\n return await this.request({\n params: {\n ...remainFilters,\n },\n });\n }\n}\n","import { DefaultRequest } from \"@c-rex/interfaces\";\nimport { DocumentTypesItem } from \"@c-rex/interfaces\";\n\nexport const transformDocumentTypes = (data: DefaultRequest<DocumentTypesItem>) => {\n const labels: string[] = [];\n\n data.items.forEach((documentItem: DocumentTypesItem) => {\n const aux = documentItem.labels.flatMap((item) => item);\n\n aux.forEach((item) => {\n if (item.language == \"en\") labels.push(item.value);\n });\n });\n\n return labels;\n};\n","import { createParams } from \"@c-rex/utils\";\nimport { transformDocumentTypes } from \"./transforms/documentTypes\";\nimport { BaseService } from \"./baseService\";\n\n/**\n * Service for interacting with document types in the API.\n * Provides methods to retrieve document type information.\n */\nexport class DocumentTypesService extends BaseService {\n constructor() {\n super(\"DocumentTypes/\");\n }\n\n /**\n * Retrieves document type labels for the specified fields.\n * The labels are restricted to English language (EN-us).\n * \n * @param fields - Array of field names to retrieve labels for\n * @returns A promise that resolves to an array of label strings\n * @throws Error if the API request fails\n */\n public async getLabels(fields: string[]): Promise<string[]> {\n const params = [\n {\n key: \"Restrict\",\n value: `languages~EN-us`,\n },\n ...createParams(fields, \"Fields\"),\n ];\n\n return await this.request({\n params,\n transformer: transformDocumentTypes,\n });\n }\n}\n","import { EN_LANG, RESULT_TYPES } from \"@c-rex/constants\";\nimport {\n DefaultRequest,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { getFileRenditions } from \"@c-rex/utils\";\n\nexport const transformInformationUnits = async (\n data: DefaultRequest<informationUnitsItems>,\n): Promise<informationUnitsResponse> => {\n const config = await getConfigs();\n\n const items = await Promise.all(data.items.map(async (item) => {\n const type = item.class.labels.filter((item) => item.language === EN_LANG)[0].value.toUpperCase();\n const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });\n\n let link = `/topics/${item.shortId}`;\n\n if (config.results.articlePageLayout == \"BLOG\") {\n link = `/blog/${item.shortId}`\n } else if (type == RESULT_TYPES.DOCUMENT) {\n link = `/documents/${item.shortId}`;\n }\n\n return {\n language: item.labels[0].language,\n title: item.labels[0].value,\n type: type,\n localeType: \"\",\n shortId: item.shortId,\n disabled: config.results.disabledResults.includes(type as any),\n link: link,\n filesToOpen,\n filesToDownload\n }\n }));\n return {\n items: items,\n pageInfo: data.pageInfo,\n };\n};","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\n\n/**\n * Service for interacting with information units in the API.\n * Provides methods to retrieve and search information units.\n */\nexport class InformationUnitsService extends BaseService {\n constructor() {\n super(\"InformationUnits/\");\n }\n\n /**\n * Retrieves a list of information units based on specified criteria.\n * \n * @param options - Options for filtering and paginating the information units list\n * @param options.queries - Optional search query string\n * @param options.page - Optional page number for pagination (defaults to 1)\n * @param options.fields - Optional array of fields to include in the response\n * @param options.filters - Optional array of filter strings to apply\n * @param options.languages - Optional array of language codes to filter by\n * @returns A promise that resolves to the information units response\n * @throws Error if the API request fails\n */\n public async getList({\n queries = \"\",\n page = 1,\n fields = [],\n filters = [],\n languages = []\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n fields?: string[],\n languages?: string[]\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const languageParams = createParams(\n languages.map(item => `languages=${item}`),\n \"Filter\"\n );\n /*\n const languageParams = createParams(\n languages.map(item => `?s iirds:language ${item}`),\n \"sparqlWhere\"\n );\n */\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"PageNumber\", value: page.toString() },\n ...remainFields,\n ...languageParams,\n ...remainFilters\n ];\n\n if (queries.length > 0) {\n params.push(\n { key: \"Query\", value: queries },\n );\n }\n\n return await this.request({\n params: params,\n transformer: transformInformationUnits\n });\n }\n\n /**\n * Retrieves a specific information unit by its ID.\n * Includes renditions, directory nodes, version information, titles, languages, and labels.\n * \n * @param options - Options for retrieving the information unit\n * @param options.id - The unique identifier of the information unit\n * @returns A promise that resolves to the information unit data\n * @throws Error if the API request fails\n */\n public async getItem({ id }: { id: string }): Promise<informationUnitsItems> {\n const params = [\n { key: \"Fields\", value: \"renditions\" },\n { key: \"Fields\", value: \"directoryNodes\" },\n { key: \"Fields\", value: \"versionOf\" },\n { key: \"Fields\", value: \"titles\" },\n { key: \"Fields\", value: \"languages\" },\n { key: \"Fields\", value: \"labels\" },\n ];\n\n return await this.request({\n path: id,\n params,\n });\n }\n\n /**\n * Retrieves autocomplete suggestions based on a query prefix.\n * \n * @param options - Options for retrieving suggestions\n * @param options.query - The query prefix to get suggestions for\n * @param options.language - The language of the suggestions\n * @returns A promise that resolves to an array of suggestion strings\n * @throws Error if the API request fails\n */\n public async getSuggestions(\n { query, language }: { query: string, language: string }\n ): Promise<string[]> {\n return await this.request({\n path: `Suggestions`,\n params: [\n { key: \"prefix\", value: query },\n { key: \"lang\", value: language },\n ],\n transformer: (data: AutocompleteSuggestion) => {\n const suggestions: string[] = []\n const comparableList: string[] = []\n\n data.suggestions.forEach((item) => {\n suggestions.push(item.value);\n comparableList.push(item.value.toLowerCase())\n })\n\n if (!comparableList.includes(query.toLowerCase())) {\n return [query, ...suggestions];\n }\n\n return suggestions\n },\n });\n }\n}\n","import { LanguageAndCountries } from \"@c-rex/interfaces\";\nimport { BaseService } from \"./baseService\";\nimport { getCountryCodeByLang } from \"@c-rex/utils\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\n/**\n * Service for interacting with language-related functionality in the API.\n * Provides methods to retrieve language and country information.\n */\nexport class LanguageService extends BaseService {\n constructor() {\n const configs = getConfigs()\n super(configs.languageSwitcher.endpoint);\n }\n\n /**\n * Retrieves a list of available languages and their associated countries.\n * Transforms the API response to include language code, country code, and original value.\n * \n * @returns A promise that resolves to an array of language and country objects\n * @throws Error if the API request fails\n */\n public async getLanguagesAndCountries(): Promise<LanguageAndCountries[]> {\n return await this.request({\n transformer: (data: { value: string; score: number }[]) => {\n const countryCodeList = data.map((item) => {\n /*\n api -> en, en-US\n default -> en-US. Then use EN-US \n\n api -> en\n default -> en-US. Then use EN\n */\n //should be abble to handle this items: en-US, en, pt, pt-PT, pt-BR \n\n const splittedValue = item.value.split(\"-\")\n const lang = splittedValue[0]\n let country = splittedValue[0]\n\n if (splittedValue.length > 1) {\n country = splittedValue[1]\n } else {\n country = getCountryCodeByLang(lang)\n }\n\n return {\n country: country,\n lang: lang,\n value: item.value,\n }\n })\n\n return countryCodeList.sort((a, b) => {\n return a.value.localeCompare(b.value)\n })\n },\n });\n }\n}\n"],"mappings":";AAAA,OAAO,WAAqD;;;ACArD,IAAM,MAAM;AAeZ,IAAM,aAAa;AAAA,EACtB,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACX;AAOO,IAAM,MAAM;AAAA,EACf,WAAW;AAAA,EACX,aAAa;AAAA,EACb,aAAa;AAAA,IACT,gBAAgB;AAAA,EACpB;AACJ;AAEO,IAAM,iBAAiB;AAQvB,IAAM,gBAAgB;AAAA,EACzB,MAA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AAa,CAAC,SAA6C;AACvD,cAAM,kBAAkB,KAAK,IAAI,CAAC,SAAS;AAUvC,gBAAM,gBAAgB,KAAK,MAAM,MAAM,GAAG;AAC1C,gBAAM,OAAO,cAAc,CAAC;AAC5B,cAAI,UAAU,cAAc,CAAC;AAE7B,cAAI,cAAc,SAAS,GAAG;AAC1B,sBAAU,cAAc,CAAC;AAAA,UAC7B,OAAO;AACH,sBAAU,qBAAqB,IAAI;AAAA,UACvC;AAEA,iBAAO;AAAA,YACH;AAAA,YACA;AAAA,YACA,OAAO,KAAK;AAAA,UAChB;AAAA,QACJ,CAAC;AAED,eAAO,gBAAgB,KAAK,CAAC,GAAG,MAAM;AAClC,iBAAO,EAAE,MAAM,cAAc,EAAE,KAAK;AAAA,QACxC,CAAC;AAAA,MACL;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;","names":["Transport","Transport","item","item","getConfigs","getConfigs","item","getConfigs"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-rex/services",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "module": "./dist/index.mjs",