@c-rex/services 0.1.5 → 0.1.6

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/index.js CHANGED
@@ -58,6 +58,7 @@ var API = {
58
58
  }
59
59
  };
60
60
  var SDK_CONFIG_KEY = "crex-sdk-config";
61
+ var CONTENT_LANG_KEY = "CONTENT_LANG_KEY";
61
62
  var FLAGS_BY_LANG = {
62
63
  "en": "US",
63
64
  "de": "DE"
@@ -66,10 +67,12 @@ var EN_LANG = "en";
66
67
  var TOPIC = "TOPIC";
67
68
  var DOCUMENT = "DOCUMENT";
68
69
  var PACKAGE = "PACKAGE";
70
+ var FRAGMENT = "FRAGMENT";
69
71
  var RESULT_TYPES = {
70
72
  TOPIC,
71
73
  DOCUMENT,
72
- PACKAGE
74
+ PACKAGE,
75
+ FRAGMENT
73
76
  };
74
77
  var DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1e3;
75
78
  var CREX_TOKEN_HEADER_KEY = "crex-token";
@@ -237,7 +240,7 @@ var CrexApi = class {
237
240
  async initAPI() {
238
241
  this.logger = new CrexLogger();
239
242
  if (!this.customerConfig) {
240
- const aux = await (0, import_headers.cookies)().get(SDK_CONFIG_KEY);
243
+ const aux = (0, import_headers.cookies)().get(SDK_CONFIG_KEY);
241
244
  if (aux != void 0) {
242
245
  this.customerConfig = JSON.parse(aux.value);
243
246
  } else {
@@ -611,11 +614,13 @@ var DocumentTypesService = class extends BaseService {
611
614
 
612
615
  // src/transforms/information.ts
613
616
  var import_next_cookies2 = require("@c-rex/utils/next-cookies");
617
+ var import_headers2 = require("next/headers");
614
618
  var import_logger2 = require("@c-rex/core/logger");
615
619
  var transformInformationUnits = async (data) => {
616
- const config = await (0, import_next_cookies2.getConfigs)();
617
620
  const logger = new import_logger2.CrexLogger();
618
- const items = await Promise.all(data.items.map(async (item) => {
621
+ const config = await (0, import_next_cookies2.getConfigs)();
622
+ const filteredTags = {};
623
+ const items = data.items.map((item) => {
619
624
  const type = item.class.labels.filter((item2) => item2.language === EN_LANG)[0].value.toUpperCase();
620
625
  const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });
621
626
  let link = `/topics/${item.shortId}`;
@@ -651,10 +656,60 @@ var transformInformationUnits = async (data) => {
651
656
  filesToOpen,
652
657
  filesToDownload
653
658
  };
654
- }));
655
- const filteredList = items.filter((item) => item != null);
659
+ });
660
+ if (data.tags) {
661
+ const contentLang = ((0, import_headers2.cookies)().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase();
662
+ const splittedContentLang = contentLang.split("-")[0];
663
+ for (const [key, value] of Object.entries(data.tags)) {
664
+ if (!value || !value.items || value.items.length === 0) {
665
+ continue;
666
+ }
667
+ if (!config.search.tags.includes(key)) {
668
+ continue;
669
+ }
670
+ const aux = value.items.map((item) => {
671
+ if (item?.shortId === void 0) return null;
672
+ if (Number(item.hits) === 0) return null;
673
+ if (item?.labels === void 0 || item?.labels.length === 0) {
674
+ logger.log({
675
+ level: "warning",
676
+ message: `No labels on item with id ${item.shortId} from category ${key}`
677
+ });
678
+ return null;
679
+ }
680
+ let label = "";
681
+ for (const labelItem of item.labels) {
682
+ if (labelItem.language === void 0) {
683
+ logger.log({
684
+ level: "warning",
685
+ message: `No language on label ${labelItem.value} from category ${key}`
686
+ });
687
+ label = labelItem.value;
688
+ break;
689
+ }
690
+ if (labelItem.language.toLowerCase() === contentLang || labelItem.language.toLowerCase() === splittedContentLang) {
691
+ label = labelItem.value;
692
+ break;
693
+ }
694
+ label = labelItem.value;
695
+ }
696
+ return {
697
+ hits: item.hits,
698
+ total: item.total,
699
+ label,
700
+ active: false,
701
+ shortId: item.shortId
702
+ };
703
+ }).filter((item) => item !== null);
704
+ if (aux.length === 0) {
705
+ continue;
706
+ }
707
+ filteredTags[key] = aux;
708
+ }
709
+ }
656
710
  return {
657
- items: filteredList,
711
+ tags: filteredTags,
712
+ items,
658
713
  pageInfo: data.pageInfo
659
714
  };
660
715
  };
@@ -702,21 +757,21 @@ var InformationUnitsService = class extends BaseService {
702
757
  const remainFields = createParams(fields, "Fields");
703
758
  const remainFilters = createParams(filters, "Filter");
704
759
  const restrictions = createParams(restrict, "Restrict");
705
- const languageParams = createParams(
706
- languages.map((item) => `?s iirds:language '${item}'`),
707
- "sparqlWhere"
708
- );
760
+ const languageParam = `VALUES ?lang { ${languages.map((lang) => `"${lang}"`).join(" ")} } ?s iirds:language ?lang .`;
709
761
  const params = [
710
762
  { key: "pageSize", value: "12" },
711
763
  { key: "wildcard", value: wildcard.toLowerCase() },
712
764
  { key: "PageNumber", value: page.toString() },
713
765
  { key: "Operator", value: operator },
766
+ { key: "tags", value: "true" },
714
767
  { key: "Like", value: like.toString() },
715
768
  ...remainFields,
716
- ...languageParams,
717
769
  ...remainFilters,
718
770
  ...restrictions
719
771
  ];
772
+ if (languages.length > 0) {
773
+ params.push({ key: "sparqlWhere", value: languageParam });
774
+ }
720
775
  if (queries.length > 0) {
721
776
  params.push(
722
777
  { key: "Query", value: queries }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../../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":["export * from \"./renditions\"\nexport * from \"./directoryNodes\"\nexport * from \"./documentTypes\"\nexport * from \"./informationUnits\"\nexport * from \"./language\"\n","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 = await 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\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\";\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\n","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\";\nimport { CrexLogger } from '@c-rex/core/logger';\nimport { AutocompleteSuggestion } from \"@c-rex/interfaces\";\n\nexport const transformInformationUnits = async (\n data: DefaultRequest<informationUnitsItems>,\n): Promise<informationUnitsResponse> => {\n const config = await getConfigs();\n const logger = new CrexLogger()\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 let title = \"NO TITLE\"\n let language = \"NO LANGUAGE\"\n\n try {\n if (item.titles) {\n title = item.titles[0].value\n language = item.titles[0].language\n } else {\n title = item.labels[0].value\n language = item.labels[0].language\n }\n } catch {\n logger.log({\n level: \"error\",\n message: `No label or title on item ${item.shortId}`\n })\n }\n\n return {\n language: language,\n title: title,\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\n const filteredList = items.filter(item => item != null)\n\n return {\n items: filteredList,\n pageInfo: data.pageInfo,\n };\n};\n\nexport const transformSuggestions = (data: AutocompleteSuggestion, query: string) => {\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}","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits, transformSuggestions } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\nimport { WildCardType } from \"@c-rex/types\";\nimport { OPERATOR_OPTIONS, WILD_CARD_OPTIONS } from \"@c-rex/constants\";\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 restrict = [],\n languages = [],\n wildcard = WILD_CARD_OPTIONS.BOTH,\n operator = OPERATOR_OPTIONS.AND,\n like = false,\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n restrict?: string[],\n fields?: string[],\n languages?: string[],\n wildcard?: WildCardType,\n operator?: string,\n like?: boolean,\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const restrictions = createParams(restrict, \"Restrict\");\n const languageParams = createParams(\n languages.map(item => `?s iirds:language '${item}'`),\n \"sparqlWhere\"\n );\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"wildcard\", value: wildcard.toLowerCase() },\n { key: \"PageNumber\", value: page.toString() },\n { key: \"Operator\", value: operator },\n { key: \"Like\", value: like.toString() },\n ...remainFields,\n ...languageParams,\n ...remainFilters,\n ...restrictions\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 { key: \"Fields\", value: \"packages\" },\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\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) => transformSuggestions(data, query)\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA4D;;;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,MAAM;AAAA,EACN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B,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","import_winston_transport","Transport","Graylog2Transport","winston","axios","item","item","import_next_cookies","import_logger","item","import_next_cookies"]}
1
+ {"version":3,"sources":["../src/index.ts","../../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":["export * from \"./renditions\"\nexport * from \"./directoryNodes\"\nexport * from \"./documentTypes\"\nexport * from \"./informationUnits\"\nexport * from \"./language\"\n","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\";\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 = 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\";\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\n","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 { CONTENT_LANG_KEY, 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 { cookies } from 'next/headers';\nimport { getFileRenditions } from \"@c-rex/utils\";\nimport { CrexLogger } from '@c-rex/core/logger';\nimport { AutocompleteSuggestion } from \"@c-rex/interfaces\";\n\nexport const transformInformationUnits = async (\n data: DefaultRequest<informationUnitsItems>,\n): Promise<informationUnitsResponse> => {\n const logger = new CrexLogger()\n const config = await getConfigs();\n const filteredTags: any = {}\n\n\n const items = data.items.map((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 let title = \"NO TITLE\"\n let language = \"NO LANGUAGE\"\n\n try {\n if (item.titles) {\n title = item.titles[0].value\n language = item.titles[0].language\n } else {\n title = item.labels[0].value\n language = item.labels[0].language\n }\n } catch {\n logger.log({\n level: \"error\",\n message: `No label or title on item ${item.shortId}`\n })\n }\n\n return {\n language: language,\n title: title,\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\n if (data.tags) {\n const contentLang = (cookies().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase()\n const splittedContentLang = contentLang.split(\"-\")[0];\n\n for (const [key, value] of Object.entries(data.tags)) {\n\n if (!value || !value.items || value.items.length === 0) {\n continue;\n }\n if (!config.search.tags.includes(key)) {\n continue;\n }\n\n const aux = value.items.map(item => {\n if (item?.shortId === undefined) return null\n if (Number(item.hits) === 0) return null\n if (item?.labels === undefined || item?.labels.length === 0) {\n logger.log({\n level: \"warning\",\n message: `No labels on item with id ${item.shortId} from category ${key}`\n })\n return null;\n }\n\n let label = \"\"\n\n for (const labelItem of item.labels) {\n if (labelItem.language === undefined) {\n logger.log({\n level: \"warning\",\n message: `No language on label ${labelItem.value} from category ${key}`\n })\n label = labelItem.value\n break;\n }\n\n if (labelItem.language.toLowerCase() === contentLang || labelItem.language.toLowerCase() === splittedContentLang) {\n label = labelItem.value\n break;\n }\n\n label = labelItem.value\n }\n\n return {\n hits: item.hits,\n total: item.total,\n label: label,\n active: false,\n shortId: item.shortId,\n }\n }).filter((item) => item !== null)\n\n if (aux.length === 0) {\n continue;\n }\n\n filteredTags[key] = aux;\n }\n }\n\n return {\n tags: filteredTags,\n items: items,\n pageInfo: data.pageInfo,\n };\n};\n\nexport const transformSuggestions = (data: AutocompleteSuggestion, query: string) => {\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}","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits, transformSuggestions } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\nimport { WildCardType } from \"@c-rex/types\";\nimport { OPERATOR_OPTIONS, WILD_CARD_OPTIONS } from \"@c-rex/constants\";\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 restrict = [],\n languages = [],\n wildcard = WILD_CARD_OPTIONS.BOTH,\n operator = OPERATOR_OPTIONS.AND,\n like = false,\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n restrict?: string[],\n fields?: string[],\n languages?: string[],\n wildcard?: WildCardType,\n operator?: string,\n like?: boolean,\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const restrictions = createParams(restrict, \"Restrict\");\n const languageParam = `VALUES ?lang { ${languages.map(lang => `\"${lang}\"`).join(\" \")} } ?s iirds:language ?lang .`\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"wildcard\", value: wildcard.toLowerCase() },\n { key: \"PageNumber\", value: page.toString() },\n { key: \"Operator\", value: operator },\n { key: \"tags\", value: \"true\" },\n { key: \"Like\", value: like.toString() },\n ...remainFields,\n ...remainFilters,\n ...restrictions\n ];\n if (languages.length > 0) {\n params.push({ key: \"sparqlWhere\", value: languageParam });\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 { key: \"Fields\", value: \"packages\" },\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\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) => transformSuggestions(data, query)\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA4D;;;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;AAEvB,IAAM,mBAAmB;AAMzB,IAAM,gBAAgB;AAAA,EACzB,MAAM;AAAA,EACN,MAAM;AACV;AAIO,IAAM,UAAU;AAQhB,IAAM,QAAQ;AACd,IAAM,WAAW;AACjB,IAAM,UAAU;AAChB,IAAM,WAAW;AAEjB,IAAM,eAAe;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAOO,IAAM,uBAAuB,IAAI,KAAK,KAAK,KAAK;AAQhD,IAAM,wBAAwB;AAE9B,IAAM,oBAAoB;AAAA,EAC7B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AACV;AAEO,IAAM,mBAAmB;AAAA,EAC5B,KAAK;AAAA,EACL,IAAI;AACR;;;AD7FA,qBAAwB;;;AEHxB,qBAAoB;;;ACApB,+BAAsB;AASf,IAAM,kBAAN,cAA8B,yBAAAA,QAAU;AAAA,EACpC;AAAA,EACC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOR,YAAY,SAA0B;AAClC,UAAM;AAAA,MACF,OAAO,QAAQ,KAAK,OAAO;AAAA,MAC3B,QAAQ,QAAQ,KAAK,OA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WA,MAAa,eACT,EAAE,OAAO,SAAS,GACD;AAEjB,WAAO,MAAM,KAAK,QAAQ;AAAA,MACtB,MAAM;AAAA,MACN,QAAQ;AAAA,QACJ,EAAE,KAAK,UAAU,OAAO,MAAM;AAAA,QAC9B,EAAE,KAAK,QAAQ,OAAO,SAAS;AAAA,MACnC;AAAA,MACA,aAAa,CAAC,SAAiC,qBAAqB,MAAM,KAAK;AAAA,IACnF,CAAC;AAAA,EACL;AACJ;;;ACjIA,IAAAC,uBAA2B;AAMpB,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC7C,cAAc;AACV,UAAM,cAAU,iCAAW;AAC3B,UAAM,QAAQ,iBAAiB,QAAQ;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAa,2BAA4D;AACrE,WAAO,MAAM,KAAK,QAAQ;AAAA,MACtB,aAAa,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","import_winston_transport","Transport","Graylog2Transport","winston","axios","item","item","import_next_cookies","import_headers","import_logger","item","import_next_cookies"]}
package/dist/index.mjs CHANGED
@@ -18,6 +18,7 @@ var API = {
18
18
  }
19
19
  };
20
20
  var SDK_CONFIG_KEY = "crex-sdk-config";
21
+ var CONTENT_LANG_KEY = "CONTENT_LANG_KEY";
21
22
  var FLAGS_BY_LANG = {
22
23
  "en": "US",
23
24
  "de": "DE"
@@ -26,10 +27,12 @@ var EN_LANG = "en";
26
27
  var TOPIC = "TOPIC";
27
28
  var DOCUMENT = "DOCUMENT";
28
29
  var PACKAGE = "PACKAGE";
30
+ var FRAGMENT = "FRAGMENT";
29
31
  var RESULT_TYPES = {
30
32
  TOPIC,
31
33
  DOCUMENT,
32
- PACKAGE
34
+ PACKAGE,
35
+ FRAGMENT
33
36
  };
34
37
  var DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1e3;
35
38
  var CREX_TOKEN_HEADER_KEY = "crex-token";
@@ -197,7 +200,7 @@ var CrexApi = class {
197
200
  async initAPI() {
198
201
  this.logger = new CrexLogger();
199
202
  if (!this.customerConfig) {
200
- const aux = await cookies().get(SDK_CONFIG_KEY);
203
+ const aux = cookies().get(SDK_CONFIG_KEY);
201
204
  if (aux != void 0) {
202
205
  this.customerConfig = JSON.parse(aux.value);
203
206
  } else {
@@ -571,11 +574,13 @@ var DocumentTypesService = class extends BaseService {
571
574
 
572
575
  // src/transforms/information.ts
573
576
  import { getConfigs as getConfigs2 } from "@c-rex/utils/next-cookies";
577
+ import { cookies as cookies2 } from "next/headers";
574
578
  import { CrexLogger as CrexLogger2 } from "@c-rex/core/logger";
575
579
  var transformInformationUnits = async (data) => {
576
- const config = await getConfigs2();
577
580
  const logger = new CrexLogger2();
578
- const items = await Promise.all(data.items.map(async (item) => {
581
+ const config = await getConfigs2();
582
+ const filteredTags = {};
583
+ const items = data.items.map((item) => {
579
584
  const type = item.class.labels.filter((item2) => item2.language === EN_LANG)[0].value.toUpperCase();
580
585
  const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });
581
586
  let link = `/topics/${item.shortId}`;
@@ -611,10 +616,60 @@ var transformInformationUnits = async (data) => {
611
616
  filesToOpen,
612
617
  filesToDownload
613
618
  };
614
- }));
615
- const filteredList = items.filter((item) => item != null);
619
+ });
620
+ if (data.tags) {
621
+ const contentLang = (cookies2().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase();
622
+ const splittedContentLang = contentLang.split("-")[0];
623
+ for (const [key, value] of Object.entries(data.tags)) {
624
+ if (!value || !value.items || value.items.length === 0) {
625
+ continue;
626
+ }
627
+ if (!config.search.tags.includes(key)) {
628
+ continue;
629
+ }
630
+ const aux = value.items.map((item) => {
631
+ if (item?.shortId === void 0) return null;
632
+ if (Number(item.hits) === 0) return null;
633
+ if (item?.labels === void 0 || item?.labels.length === 0) {
634
+ logger.log({
635
+ level: "warning",
636
+ message: `No labels on item with id ${item.shortId} from category ${key}`
637
+ });
638
+ return null;
639
+ }
640
+ let label = "";
641
+ for (const labelItem of item.labels) {
642
+ if (labelItem.language === void 0) {
643
+ logger.log({
644
+ level: "warning",
645
+ message: `No language on label ${labelItem.value} from category ${key}`
646
+ });
647
+ label = labelItem.value;
648
+ break;
649
+ }
650
+ if (labelItem.language.toLowerCase() === contentLang || labelItem.language.toLowerCase() === splittedContentLang) {
651
+ label = labelItem.value;
652
+ break;
653
+ }
654
+ label = labelItem.value;
655
+ }
656
+ return {
657
+ hits: item.hits,
658
+ total: item.total,
659
+ label,
660
+ active: false,
661
+ shortId: item.shortId
662
+ };
663
+ }).filter((item) => item !== null);
664
+ if (aux.length === 0) {
665
+ continue;
666
+ }
667
+ filteredTags[key] = aux;
668
+ }
669
+ }
616
670
  return {
617
- items: filteredList,
671
+ tags: filteredTags,
672
+ items,
618
673
  pageInfo: data.pageInfo
619
674
  };
620
675
  };
@@ -662,21 +717,21 @@ var InformationUnitsService = class extends BaseService {
662
717
  const remainFields = createParams(fields, "Fields");
663
718
  const remainFilters = createParams(filters, "Filter");
664
719
  const restrictions = createParams(restrict, "Restrict");
665
- const languageParams = createParams(
666
- languages.map((item) => `?s iirds:language '${item}'`),
667
- "sparqlWhere"
668
- );
720
+ const languageParam = `VALUES ?lang { ${languages.map((lang) => `"${lang}"`).join(" ")} } ?s iirds:language ?lang .`;
669
721
  const params = [
670
722
  { key: "pageSize", value: "12" },
671
723
  { key: "wildcard", value: wildcard.toLowerCase() },
672
724
  { key: "PageNumber", value: page.toString() },
673
725
  { key: "Operator", value: operator },
726
+ { key: "tags", value: "true" },
674
727
  { key: "Like", value: like.toString() },
675
728
  ...remainFields,
676
- ...languageParams,
677
729
  ...remainFilters,
678
730
  ...restrictions
679
731
  ];
732
+ if (languages.length > 0) {
733
+ params.push({ key: "sparqlWhere", value: languageParam });
734
+ }
680
735
  if (queries.length > 0) {
681
736
  params.push(
682
737
  { key: "Query", value: queries }
@@ -1 +1 @@
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 = await 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\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\";\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\n","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\";\nimport { CrexLogger } from '@c-rex/core/logger';\nimport { AutocompleteSuggestion } from \"@c-rex/interfaces\";\n\nexport const transformInformationUnits = async (\n data: DefaultRequest<informationUnitsItems>,\n): Promise<informationUnitsResponse> => {\n const config = await getConfigs();\n const logger = new CrexLogger()\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 let title = \"NO TITLE\"\n let language = \"NO LANGUAGE\"\n\n try {\n if (item.titles) {\n title = item.titles[0].value\n language = item.titles[0].language\n } else {\n title = item.labels[0].value\n language = item.labels[0].language\n }\n } catch {\n logger.log({\n level: \"error\",\n message: `No label or title on item ${item.shortId}`\n })\n }\n\n return {\n language: language,\n title: title,\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\n const filteredList = items.filter(item => item != null)\n\n return {\n items: filteredList,\n pageInfo: data.pageInfo,\n };\n};\n\nexport const transformSuggestions = (data: AutocompleteSuggestion, query: string) => {\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}","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits, transformSuggestions } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\nimport { WildCardType } from \"@c-rex/types\";\nimport { OPERATOR_OPTIONS, WILD_CARD_OPTIONS } from \"@c-rex/constants\";\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 restrict = [],\n languages = [],\n wildcard = WILD_CARD_OPTIONS.BOTH,\n operator = OPERATOR_OPTIONS.AND,\n like = false,\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n restrict?: string[],\n fields?: string[],\n languages?: string[],\n wildcard?: WildCardType,\n operator?: string,\n like?: boolean,\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const restrictions = createParams(restrict, \"Restrict\");\n const languageParams = createParams(\n languages.map(item => `?s iirds:language '${item}'`),\n \"sparqlWhere\"\n );\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"wildcard\", value: wildcard.toLowerCase() },\n { key: \"PageNumber\", value: page.toString() },\n { key: \"Operator\", value: operator },\n { key: \"Like\", value: like.toString() },\n ...remainFields,\n ...languageParams,\n ...remainFilters,\n ...restrictions\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 { key: \"Fields\", value: \"packages\" },\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\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) => transformSuggestions(data, query)\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,MAAM;AAAA,EACN,MAAM;AACV;AAIO,IAAM,UAAU;AAQhB,IAAM,QAAQ;AACd,IAAM,WAAW;AACjB,IAAM,UAAU;AAEhB,IAAM,eAAe;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AACJ;AAOO,IAAM,uBAAuB,IAAI,KAAK,KAAK,KAAK;AAQhD,IAAM,wBAAwB;AAE9B,IAAM,oBAAoB;AAAA,EAC7B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;AACV;AAEO,IAAM,mBAAmB;AAAA,EAC5B,KAAK;AAAA,EACL,IAAI;AACR;;;AD3FA,SAAS,eAAe;;;AEHxB,OAAO,aAAa;;;ACApB,OAAO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,MAAa,eACT,EAAE,OAAO,SAAS,GACD;AAEjB,WAAO,MAAM,KAAK,QAAQ;AAAA,MACtB,MAAM;AAAA,MACN,QAAQ;AAAA,QACJ,EAAE,KAAK,UAAU,OAAO,MAAM;AAAA,QAC9B,EAAE,KAAK,QAAQ,OAAO,SAAS;AAAA,MACnC;AAAA,MACA,aAAa,CAAC,SAAiC,qBAAqB,MAAM,KAAK;AAAA,IACnF,CAAC;AAAA,EACL;AACJ;;;AClIA,SAAS,cAAAC,mBAAkB;AAMpB,IAAM,kBAAN,cAA8B,YAAY;AAAA,EAC7C,cAAc;AACV,UAAM,UAAUA,YAAW;AAC3B,UAAM,QAAQ,iBAAiB,QAAQ;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAa,2BAA4D;AACrE,WAAO,MAAM,KAAK,QAAQ;AAAA,MACtB,aAAa,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","CrexLogger","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\";\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 = 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\";\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\n","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 { CONTENT_LANG_KEY, 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 { cookies } from 'next/headers';\nimport { getFileRenditions } from \"@c-rex/utils\";\nimport { CrexLogger } from '@c-rex/core/logger';\nimport { AutocompleteSuggestion } from \"@c-rex/interfaces\";\n\nexport const transformInformationUnits = async (\n data: DefaultRequest<informationUnitsItems>,\n): Promise<informationUnitsResponse> => {\n const logger = new CrexLogger()\n const config = await getConfigs();\n const filteredTags: any = {}\n\n\n const items = data.items.map((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 let title = \"NO TITLE\"\n let language = \"NO LANGUAGE\"\n\n try {\n if (item.titles) {\n title = item.titles[0].value\n language = item.titles[0].language\n } else {\n title = item.labels[0].value\n language = item.labels[0].language\n }\n } catch {\n logger.log({\n level: \"error\",\n message: `No label or title on item ${item.shortId}`\n })\n }\n\n return {\n language: language,\n title: title,\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\n if (data.tags) {\n const contentLang = (cookies().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase()\n const splittedContentLang = contentLang.split(\"-\")[0];\n\n for (const [key, value] of Object.entries(data.tags)) {\n\n if (!value || !value.items || value.items.length === 0) {\n continue;\n }\n if (!config.search.tags.includes(key)) {\n continue;\n }\n\n const aux = value.items.map(item => {\n if (item?.shortId === undefined) return null\n if (Number(item.hits) === 0) return null\n if (item?.labels === undefined || item?.labels.length === 0) {\n logger.log({\n level: \"warning\",\n message: `No labels on item with id ${item.shortId} from category ${key}`\n })\n return null;\n }\n\n let label = \"\"\n\n for (const labelItem of item.labels) {\n if (labelItem.language === undefined) {\n logger.log({\n level: \"warning\",\n message: `No language on label ${labelItem.value} from category ${key}`\n })\n label = labelItem.value\n break;\n }\n\n if (labelItem.language.toLowerCase() === contentLang || labelItem.language.toLowerCase() === splittedContentLang) {\n label = labelItem.value\n break;\n }\n\n label = labelItem.value\n }\n\n return {\n hits: item.hits,\n total: item.total,\n label: label,\n active: false,\n shortId: item.shortId,\n }\n }).filter((item) => item !== null)\n\n if (aux.length === 0) {\n continue;\n }\n\n filteredTags[key] = aux;\n }\n }\n\n return {\n tags: filteredTags,\n items: items,\n pageInfo: data.pageInfo,\n };\n};\n\nexport const transformSuggestions = (data: AutocompleteSuggestion, query: string) => {\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}","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits, transformSuggestions } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\nimport { WildCardType } from \"@c-rex/types\";\nimport { OPERATOR_OPTIONS, WILD_CARD_OPTIONS } from \"@c-rex/constants\";\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 restrict = [],\n languages = [],\n wildcard = WILD_CARD_OPTIONS.BOTH,\n operator = OPERATOR_OPTIONS.AND,\n like = false,\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n restrict?: string[],\n fields?: string[],\n languages?: string[],\n wildcard?: WildCardType,\n operator?: string,\n like?: boolean,\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const restrictions = createParams(restrict, \"Restrict\");\n const languageParam = `VALUES ?lang { ${languages.map(lang => `\"${lang}\"`).join(\" \")} } ?s iirds:language ?lang .`\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"wildcard\", value: wildcard.toLowerCase() },\n { key: \"PageNumber\", value: page.toString() },\n { key: \"Operator\", value: operator },\n { key: \"tags\", value: \"true\" },\n { key: \"Like\", value: like.toString() },\n ...remainFields,\n ...remainFilters,\n ...restrictions\n ];\n if (languages.length > 0) {\n params.push({ key: \"sparqlWhere\", value: languageParam });\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 { key: \"Fields\", value: \"packages\" },\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\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) => transformSuggestions(data, query)\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;AAEvB,IAAM,mBAAmB;AAMzB,IAAM,gBAAgB;AAAA,EACzB,MAAM;AAAA,EACN,MAAM;AACV;AAIO,IAAM,UAAU;AAQhB,IAAM,QAAQ;AACd,IAAM,WA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M,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","cookies","CrexLogger","getConfigs","item","cookies","getConfigs"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c-rex/services",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "module": "./dist/index.mjs",