@c-rex/services 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +62 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,10 +2,18 @@ import { CrexApi } from '@c-rex/core';
|
|
|
2
2
|
import { Method } from 'axios';
|
|
3
3
|
import { informationUnitsRenditions, DirectoryNodes, DirectoryNodesResponse, informationUnitsResponse, informationUnitsItems, LanguageAndCountries } from '@c-rex/interfaces';
|
|
4
4
|
|
|
5
|
+
declare const WILD_CARD_OPTIONS: {
|
|
6
|
+
readonly BOTH: "BOTH";
|
|
7
|
+
readonly END: "END";
|
|
8
|
+
readonly START: "START";
|
|
9
|
+
readonly NONE: "NONE";
|
|
10
|
+
};
|
|
11
|
+
|
|
5
12
|
type QueryParams = {
|
|
6
13
|
key: string;
|
|
7
14
|
value: string;
|
|
8
15
|
};
|
|
16
|
+
type WildCardType = keyof typeof WILD_CARD_OPTIONS;
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
19
|
* Base service class that provides common functionality for API interactions.
|
|
@@ -121,12 +129,16 @@ declare class InformationUnitsService extends BaseService {
|
|
|
121
129
|
* @returns A promise that resolves to the information units response
|
|
122
130
|
* @throws Error if the API request fails
|
|
123
131
|
*/
|
|
124
|
-
getList({ queries, page, fields, filters, languages }: {
|
|
132
|
+
getList({ queries, page, fields, filters, restrict, languages, wildcard, operator, like, }: {
|
|
125
133
|
queries?: string;
|
|
126
134
|
page?: number;
|
|
127
135
|
filters?: string[];
|
|
136
|
+
restrict?: string[];
|
|
128
137
|
fields?: string[];
|
|
129
138
|
languages?: string[];
|
|
139
|
+
wildcard?: WildCardType;
|
|
140
|
+
operator?: string;
|
|
141
|
+
like?: boolean;
|
|
130
142
|
}): Promise<informationUnitsResponse>;
|
|
131
143
|
/**
|
|
132
144
|
* Retrieves a specific information unit by its ID.
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,18 @@ import { CrexApi } from '@c-rex/core';
|
|
|
2
2
|
import { Method } from 'axios';
|
|
3
3
|
import { informationUnitsRenditions, DirectoryNodes, DirectoryNodesResponse, informationUnitsResponse, informationUnitsItems, LanguageAndCountries } from '@c-rex/interfaces';
|
|
4
4
|
|
|
5
|
+
declare const WILD_CARD_OPTIONS: {
|
|
6
|
+
readonly BOTH: "BOTH";
|
|
7
|
+
readonly END: "END";
|
|
8
|
+
readonly START: "START";
|
|
9
|
+
readonly NONE: "NONE";
|
|
10
|
+
};
|
|
11
|
+
|
|
5
12
|
type QueryParams = {
|
|
6
13
|
key: string;
|
|
7
14
|
value: string;
|
|
8
15
|
};
|
|
16
|
+
type WildCardType = keyof typeof WILD_CARD_OPTIONS;
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
19
|
* Base service class that provides common functionality for API interactions.
|
|
@@ -121,12 +129,16 @@ declare class InformationUnitsService extends BaseService {
|
|
|
121
129
|
* @returns A promise that resolves to the information units response
|
|
122
130
|
* @throws Error if the API request fails
|
|
123
131
|
*/
|
|
124
|
-
getList({ queries, page, fields, filters, languages }: {
|
|
132
|
+
getList({ queries, page, fields, filters, restrict, languages, wildcard, operator, like, }: {
|
|
125
133
|
queries?: string;
|
|
126
134
|
page?: number;
|
|
127
135
|
filters?: string[];
|
|
136
|
+
restrict?: string[];
|
|
128
137
|
fields?: string[];
|
|
129
138
|
languages?: string[];
|
|
139
|
+
wildcard?: WildCardType;
|
|
140
|
+
operator?: string;
|
|
141
|
+
like?: boolean;
|
|
130
142
|
}): Promise<informationUnitsResponse>;
|
|
131
143
|
/**
|
|
132
144
|
* Retrieves a specific information unit by its ID.
|
package/dist/index.js
CHANGED
|
@@ -73,6 +73,16 @@ var RESULT_TYPES = {
|
|
|
73
73
|
};
|
|
74
74
|
var DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1e3;
|
|
75
75
|
var CREX_TOKEN_HEADER_KEY = "crex-token";
|
|
76
|
+
var WILD_CARD_OPTIONS = {
|
|
77
|
+
BOTH: "BOTH",
|
|
78
|
+
END: "END",
|
|
79
|
+
START: "START",
|
|
80
|
+
NONE: "NONE"
|
|
81
|
+
};
|
|
82
|
+
var OPERATOR_OPTIONS = {
|
|
83
|
+
AND: "AND",
|
|
84
|
+
OR: "OR"
|
|
85
|
+
};
|
|
76
86
|
|
|
77
87
|
// ../core/src/requests.ts
|
|
78
88
|
var import_headers = require("next/headers");
|
|
@@ -227,7 +237,7 @@ var CrexApi = class {
|
|
|
227
237
|
async initAPI() {
|
|
228
238
|
this.logger = new CrexLogger();
|
|
229
239
|
if (!this.customerConfig) {
|
|
230
|
-
const aux = (0, import_headers.cookies)().get(SDK_CONFIG_KEY);
|
|
240
|
+
const aux = await (0, import_headers.cookies)().get(SDK_CONFIG_KEY);
|
|
231
241
|
if (aux != void 0) {
|
|
232
242
|
this.customerConfig = JSON.parse(aux.value);
|
|
233
243
|
} else {
|
|
@@ -601,8 +611,10 @@ var DocumentTypesService = class extends BaseService {
|
|
|
601
611
|
|
|
602
612
|
// src/transforms/information.ts
|
|
603
613
|
var import_next_cookies2 = require("@c-rex/utils/next-cookies");
|
|
614
|
+
var import_logger2 = require("@c-rex/core/logger");
|
|
604
615
|
var transformInformationUnits = async (data) => {
|
|
605
616
|
const config = await (0, import_next_cookies2.getConfigs)();
|
|
617
|
+
const logger = new import_logger2.CrexLogger();
|
|
606
618
|
const items = await Promise.all(data.items.map(async (item) => {
|
|
607
619
|
const type = item.class.labels.filter((item2) => item2.language === EN_LANG)[0].value.toUpperCase();
|
|
608
620
|
const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });
|
|
@@ -612,9 +624,25 @@ var transformInformationUnits = async (data) => {
|
|
|
612
624
|
} else if (type == RESULT_TYPES.DOCUMENT) {
|
|
613
625
|
link = `/documents/${item.shortId}`;
|
|
614
626
|
}
|
|
627
|
+
let title = "NO TITLE";
|
|
628
|
+
let language = "NO LANGUAGE";
|
|
629
|
+
try {
|
|
630
|
+
if (item.titles) {
|
|
631
|
+
title = item.titles[0].value;
|
|
632
|
+
language = item.titles[0].language;
|
|
633
|
+
} else {
|
|
634
|
+
title = item.labels[0].value;
|
|
635
|
+
language = item.labels[0].language;
|
|
636
|
+
}
|
|
637
|
+
} catch {
|
|
638
|
+
logger.log({
|
|
639
|
+
level: "error",
|
|
640
|
+
message: `No label or title on item ${item.shortId}`
|
|
641
|
+
});
|
|
642
|
+
}
|
|
615
643
|
return {
|
|
616
|
-
language
|
|
617
|
-
title
|
|
644
|
+
language,
|
|
645
|
+
title,
|
|
618
646
|
type,
|
|
619
647
|
localeType: "",
|
|
620
648
|
shortId: item.shortId,
|
|
@@ -624,11 +652,24 @@ var transformInformationUnits = async (data) => {
|
|
|
624
652
|
filesToDownload
|
|
625
653
|
};
|
|
626
654
|
}));
|
|
655
|
+
const filteredList = items.filter((item) => item != null);
|
|
627
656
|
return {
|
|
628
|
-
items,
|
|
657
|
+
items: filteredList,
|
|
629
658
|
pageInfo: data.pageInfo
|
|
630
659
|
};
|
|
631
660
|
};
|
|
661
|
+
var transformSuggestions = (data, query) => {
|
|
662
|
+
const suggestions = [];
|
|
663
|
+
const comparableList = [];
|
|
664
|
+
data.suggestions.forEach((item) => {
|
|
665
|
+
suggestions.push(item.value);
|
|
666
|
+
comparableList.push(item.value.toLowerCase());
|
|
667
|
+
});
|
|
668
|
+
if (!comparableList.includes(query.toLowerCase())) {
|
|
669
|
+
return [query, ...suggestions];
|
|
670
|
+
}
|
|
671
|
+
return suggestions;
|
|
672
|
+
};
|
|
632
673
|
|
|
633
674
|
// src/informationUnits.ts
|
|
634
675
|
var InformationUnitsService = class extends BaseService {
|
|
@@ -652,20 +693,29 @@ var InformationUnitsService = class extends BaseService {
|
|
|
652
693
|
page = 1,
|
|
653
694
|
fields = [],
|
|
654
695
|
filters = [],
|
|
655
|
-
|
|
696
|
+
restrict = [],
|
|
697
|
+
languages = [],
|
|
698
|
+
wildcard = WILD_CARD_OPTIONS.BOTH,
|
|
699
|
+
operator = OPERATOR_OPTIONS.AND,
|
|
700
|
+
like = false
|
|
656
701
|
}) {
|
|
657
702
|
const remainFields = createParams(fields, "Fields");
|
|
658
703
|
const remainFilters = createParams(filters, "Filter");
|
|
704
|
+
const restrictions = createParams(restrict, "Restrict");
|
|
659
705
|
const languageParams = createParams(
|
|
660
|
-
languages.map((item) =>
|
|
661
|
-
"
|
|
706
|
+
languages.map((item) => `?s iirds:language '${item}'`),
|
|
707
|
+
"sparqlWhere"
|
|
662
708
|
);
|
|
663
709
|
const params = [
|
|
664
710
|
{ key: "pageSize", value: "12" },
|
|
711
|
+
{ key: "wildcard", value: wildcard.toLowerCase() },
|
|
665
712
|
{ key: "PageNumber", value: page.toString() },
|
|
713
|
+
{ key: "Operator", value: operator },
|
|
714
|
+
{ key: "Like", value: like.toString() },
|
|
666
715
|
...remainFields,
|
|
667
716
|
...languageParams,
|
|
668
|
-
...remainFilters
|
|
717
|
+
...remainFilters,
|
|
718
|
+
...restrictions
|
|
669
719
|
];
|
|
670
720
|
if (queries.length > 0) {
|
|
671
721
|
params.push(
|
|
@@ -693,7 +743,8 @@ var InformationUnitsService = class extends BaseService {
|
|
|
693
743
|
{ key: "Fields", value: "versionOf" },
|
|
694
744
|
{ key: "Fields", value: "titles" },
|
|
695
745
|
{ key: "Fields", value: "languages" },
|
|
696
|
-
{ key: "Fields", value: "labels" }
|
|
746
|
+
{ key: "Fields", value: "labels" },
|
|
747
|
+
{ key: "Fields", value: "packages" }
|
|
697
748
|
];
|
|
698
749
|
return await this.request({
|
|
699
750
|
path: id,
|
|
@@ -711,23 +762,12 @@ var InformationUnitsService = class extends BaseService {
|
|
|
711
762
|
*/
|
|
712
763
|
async getSuggestions({ query, language }) {
|
|
713
764
|
return await this.request({
|
|
714
|
-
path:
|
|
765
|
+
path: "Suggestions",
|
|
715
766
|
params: [
|
|
716
767
|
{ key: "prefix", value: query },
|
|
717
768
|
{ key: "lang", value: language }
|
|
718
769
|
],
|
|
719
|
-
transformer: (data) =>
|
|
720
|
-
const suggestions = [];
|
|
721
|
-
const comparableList = [];
|
|
722
|
-
data.suggestions.forEach((item) => {
|
|
723
|
-
suggestions.push(item.value);
|
|
724
|
-
comparableList.push(item.value.toLowerCase());
|
|
725
|
-
});
|
|
726
|
-
if (!comparableList.includes(query.toLowerCase())) {
|
|
727
|
-
return [query, ...suggestions];
|
|
728
|
-
}
|
|
729
|
-
return suggestions;
|
|
730
|
-
}
|
|
770
|
+
transformer: (data) => transformSuggestions(data, query)
|
|
731
771
|
});
|
|
732
772
|
}
|
|
733
773
|
};
|
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 = cookies().get(SDK_CONFIG_KEY);\n if (aux != undefined) {\n this.customerConfig = JSON.parse(aux.value);\n } else {\n this.logger.log({\n level: \"error\",\n message: `utils.initAPI error: Config cookie not available`\n });\n\n throw new Error(\"Config cookie not available\");\n }\n }\n\n if (!this.apiClient) {\n this.apiClient = axios.create({\n baseURL: this.customerConfig.baseUrl,\n })\n }\n }\n\n private async getToken() {\n try {\n const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/token`, {\n method: 'POST',\n credentials: 'include',\n });\n\n const { token } = await response.json();\n\n return token;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `utils.getToken error: ${error}`\n });\n\n throw error\n }\n }\n\n private async manageToken() {\n try {\n let token = \"\";\n const hasToken = cookies().get(CREX_TOKEN_HEADER_KEY);\n\n if (hasToken == undefined || hasToken.value === null) {\n const tokenResult = await this.getToken();\n\n if (tokenResult === null) throw new Error(\"Token is undefined\");\n\n token = tokenResult;\n } else {\n token = hasToken.value;\n }\n\n return token;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `utils.manageToken error: ${error}`\n });\n\n throw error\n }\n }\n\n /**\n * Executes an API request with caching, authentication, and retry logic.\n * \n * @param options - Request options\n * @param options.url - The URL to request\n * @param options.method - The HTTP method to use\n * @param options.params - Optional query parameters\n * @param options.body - Optional request body\n * @param options.headers - Optional request headers\n * @returns The response data\n * @throws Error if the request fails after maximum retries\n */\n async execute<T>({\n url,\n method,\n params,\n body,\n headers = {},\n }: CallParams): Promise<T> {\n await this.initAPI();\n\n let response: APIGenericResponse<T> | undefined = undefined;\n\n if (this.customerConfig.OIDC.client.enabled) {\n const token = await this.manageToken();\n\n headers = {\n ...headers,\n Authorization: `Bearer ${token}`,\n };\n\n this.apiClient.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n }\n\n for (let retry = 0; retry < API.MAX_RETRY; retry++) {\n try {\n response = await this.apiClient.request({\n url,\n method,\n data: body,\n params,\n headers,\n });\n\n break;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `API.execute ${retry + 1}º error when request ${url}. Error: ${error}`\n });\n\n if (retry === API.MAX_RETRY - 1) {\n throw error;\n }\n }\n }\n\n if (response) {\n return response.data;\n }\n\n throw new Error(\"API.execute error: Failed to retrieve a valid response\");\n }\n}","export const ALL = \"*\"\n\nexport const LOG_CATEGORIES = [\n \"NoLicense\",\n \"Scenario\",\n \"Favorites\",\n \"Subscription\",\n \"Share\",\n \"Document\",\n \"Search\",\n \"History\",\n \"Notification\",\n \"UserProfile\",\n] as const;\n\nexport const LOG_LEVELS = {\n critical: 2,\n error: 3,\n warning: 4,\n info: 6,\n debug: 7,\n} as const;\n\nexport const RESULT_VIEW_STYLES = [\n \"cards\",\n \"table\",\n] as const;\n\nexport const API = {\n MAX_RETRY: 3,\n API_TIMEOUT: 10000,\n API_HEADERS: {\n \"content-Type\": \"application/json\",\n },\n};\n\nexport const SDK_CONFIG_KEY = \"crex-sdk-config\";\n\nexport const CONTENT_LANG_KEY = \"CONTENT_LANG_KEY\";\n\nexport const AVAILABLE_CONTENT_LANG_KEY = \"AVAILABLE_CONTENT_LANG_KEY\";\n\nexport const UI_LANG_KEY = \"UI_LANG_KEY\";\n\nexport const FLAGS_BY_LANG = {\n \"en\": \"US\",\n \"de\": \"DE\",\n};\n\nexport const DEFAULT_LANG = \"en-US\";\n\nexport const EN_LANG = \"en\";\n\nexport const UI_LANG_OPTIONS = [\"en-us\", \"de-de\"];\n\nexport const TOPICS_TYPE_AND_LINK = \"topics\";\nexport const BLOG_TYPE_AND_LINK = \"blog\";\nexport const DOCUMENTS_TYPE_AND_LINK = \"documents\";\n\nexport const TOPIC = \"TOPIC\";\nexport const DOCUMENT = \"DOCUMENT\";\nexport const PACKAGE = \"PACKAGE\";\n\nexport const RESULT_TYPES = {\n TOPIC: TOPIC,\n DOCUMENT: DOCUMENT,\n PACKAGE: PACKAGE,\n} as const;\n\nexport const FILES_EXTENSIONS = {\n PDF: \"application/pdf\",\n HTML: \"text/html\",\n} as const;\n\nexport const DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";\n\nexport const CREX_TOKEN_HEADER_KEY = \"crex-token\";","import winston from \"winston\";\nimport { MatomoTransport } from \"./transports/matomo\";\nimport { GraylogTransport } from \"./transports/graylog\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { LOG_LEVELS } from \"@c-rex/constants\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\n/**\n * Logger class for the CREX application.\n * Provides logging functionality with multiple transports (Console, Matomo, Graylog).\n */\nexport class CrexLogger {\n private customerConfig!: ConfigInterface;\n public logger!: winston.Logger;\n\n /**\n * Initializes the logger instance if it hasn't been initialized yet.\n * Loads customer configuration and creates the logger with appropriate transports.\n * \n * @private\n */\n private async initLogger() {\n try {\n if (!this.customerConfig) {\n this.customerConfig = await getConfigs();\n }\n if (!this.logger) {\n this.logger = this.createLogger();\n }\n } catch (error) {\n console.error(\"Error initializing logger:\", error);\n }\n }\n\n /**\n * Logs a message with the specified level and optional category.\n * \n * @param options - Logging options\n * @param options.level - The log level (error, warn, info, etc.)\n * @param options.message - The message to log\n * @param options.category - Optional category for the log message\n */\n public async log({ level, message, category }: {\n level: LogLevelType,\n message: string,\n category?: LogCategoriesType\n }) {\n await this.initLogger();\n this.logger.log(level, message, category);\n }\n\n /**\n * Creates a new Winston logger instance with configured transports.\n * \n * @private\n * @returns A configured Winston logger instance\n */\n private createLogger() {\n return winston.createLogger({\n levels: LOG_LEVELS,\n transports: [\n new winston.transports.Console({\n level: this.customerConfig.logs.console.minimumLevel,\n silent: this.customerConfig.logs.console.silent,\n }),\n new MatomoTransport(this.customerConfig),\n new GraylogTransport(this.customerConfig),\n ],\n });\n }\n}","import Transport from \"winston-transport\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\n/**\n * Winston transport for sending logs to Matomo analytics.\n * Extends the base Winston transport with Matomo-specific functionality.\n */\nexport class MatomoTransport extends Transport {\n public matomoTransport: any;\n private configs: ConfigInterface;\n\n /**\n * Creates a new instance of MatomoTransport.\n * \n * @param configs - The application configuration containing logging settings\n */\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.matomo.minimumLevel,\n silent: configs.logs.matomo.silent,\n });\n\n this.matomoTransport = new Transport();\n this.configs = configs;\n }\n\n /**\n * Logs a message to Matomo if the message category is included in the configured categories.\n * \n * @param info - The log information including level, message, and category\n * @param callback - Callback function to execute after logging\n */\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const matomoCategory = this.configs.logs.matomo.categoriesLevel\n\n if (matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {\n this.matomoTransport.log(info, callback);\n }\n }\n}\n","import Transport from \"winston-transport\";\nimport Graylog2Transport from \"winston-graylog2\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\n/**\n * Winston transport for sending logs to Graylog.\n * Extends the base Winston transport with Graylog-specific functionality.\n */\nexport class GraylogTransport extends Transport {\n public graylogTransport: any;\n private configs: ConfigInterface\n\n /**\n * Creates a new instance of GraylogTransport.\n * \n * @param configs - The application configuration containing logging settings\n */\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.graylog.minimumLevel,\n silent: configs.logs.graylog.silent,\n });\n\n this.configs = configs;\n this.graylogTransport = new Graylog2Transport({\n name: \"crex.net.documentation\",\n //name: \"crex.net.blog\",\n silent: false,\n handleExceptions: false,\n graylog: {\n servers: [\n { host: \"localhost\", port: 12201 },\n { host: \"https://log.c-rex.net\", port: 12202 }\n\n //TODO: check the URL => https://log.c-rex.net:12202/gelf\" GELF??\n ],\n },\n });\n }\n\n /**\n * Logs a message to Graylog if the message category is included in the configured categories.\n * \n * @param info - The log information including level, message, and category\n * @param callback - Callback function to execute after logging\n */\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const graylogCategory = this.configs.logs.graylog.categoriesLevel\n\n if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {\n this.graylogTransport.log(info, callback);\n }\n }\n}\n","import { FLAGS_BY_LANG } from \"@c-rex/constants\";\n\nexport const _generateShaKey = async (input: string): Promise<string> => {\n const encoder = new TextEncoder();\n const data = encoder.encode(input);\n const hashBuffer = await crypto.subtle.digest('SHA-1', data);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const base64url = btoa(String.fromCharCode(...hashArray))\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '');\n\n return base64url.slice(0, 12);\n}\n\n/**\n * Retrieves the country code associated with a given language code.\n * @param lang - The language code to look up (e.g., \"en-US\")\n * @returns The corresponding country code, or the original language code if not found\n */\nexport const getCountryCodeByLang = (lang: string): string => {\n const mappedKeys = Object.keys(FLAGS_BY_LANG);\n\n if (!mappedKeys.includes(lang)) {\n return lang\n }\n\n type LangKey = keyof typeof FLAGS_BY_LANG;\n const country = FLAGS_BY_LANG[lang as LangKey]\n\n return country\n}\n\nexport const getFromCookieString = (cookieString: string, key: string): string => {\n const cookies = cookieString.split(';')\n\n for (const cookie of cookies) {\n const [cookieKey, cookieValue] = cookie.trim().split('=')\n\n if (cookieKey === key) {\n return cookieValue as string;\n }\n }\n\n return ''\n}\n","import { _generateShaKey } from \"./utils\"\n\n/**\n * Makes an asynchronous RPC API call to the server.\n * @param method - The RPC method name to call\n * @param params - Optional parameters to pass to the method\n * @returns A Promise resolving to the response data of type T\n */\nexport const call = async<T = unknown>(method: string, params?: any): Promise<T> => {\n type result = {\n data: string,\n expireDate: Date,\n }\n\n const shaKey = await _generateShaKey(JSON.stringify({ method, params }))\n const cache = localStorage.getItem(shaKey)\n\n if (cache !== null) {\n const { data, expireDate } = JSON.parse(cache) as result\n\n if (new Date(expireDate) > new Date()) {\n return JSON.parse(data) as T\n } else {\n localStorage.removeItem(shaKey)\n }\n }\n\n const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/rpc`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ method, params }),\n credentials: 'include',\n });\n\n const json = await res.json();\n\n if (!res.ok) throw new Error(json.error || 'Unknown error');\n\n const today = new Date()\n const result: result = {\n data: JSON.stringify(json.data),\n expireDate: new Date(today.getTime() + 1000 * 60 * 60),\n }\n\n localStorage.setItem(shaKey, JSON.stringify(result))\n\n return json.data;\n}","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merges multiple class values into a single string using clsx and tailwind-merge.\n * Useful for conditionally applying Tailwind CSS classes.\n * @param inputs - Any number of class values (strings, objects, arrays, etc.)\n * @returns A merged string of class names optimized for Tailwind CSS\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import { QueryParams } from '@c-rex/types';\n\n/**\n * Creates an array of parameter objects from a list of field values.\n * @param fieldsList - Array of field values to transform into parameter objects\n * @param key - The key to use for each parameter object (defaults to \"Fields\")\n * @returns An array of objects with key-value pairs\n */\nexport const createParams = (fieldsList: string[], key: string = \"Fields\") =>\n fieldsList.map((item) => ({\n key: key,\n value: item,\n }));\n\n/**\n * Generates a URL query string from an array of parameter objects.\n * @param params - Array of QueryParams objects containing key-value pairs\n * @returns A URL-encoded query string\n */\nexport const generateQueryParams = (params: QueryParams[]): string => {\n const queryParams = params\n .map(\n (param) =>\n `${encodeURIComponent(param.key)}=${encodeURIComponent(param.value)}`,\n )\n .join(\"&\");\n return queryParams;\n};\n","import { FileRenditionType } from \"@c-rex/types\";\nimport { informationUnitsRenditions } from \"@c-rex/interfaces\";\n\ntype RenditionType = {\n filesToDownload: FileRenditionType[],\n filesToOpen: FileRenditionType[]\n}\nexport const getFileRenditions = ({ renditions }: { renditions: informationUnitsRenditions[] }): RenditionType => {\n if (renditions == undefined || renditions.length == 0) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filteredRenditions = renditions.filter(\n (item) => item.format != \"application/xhtml+xml\" && item.format != \"application/json\" && item.format != \"application/llm+xml\"\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filesToDownload = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"download\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n });\n\n const filesToOpen = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n })\n\n return {\n filesToDownload: filesToDownload,\n filesToOpen: filesToOpen,\n }\n}","import { CrexApi } from \"@c-rex/core\";\nimport { QueryParams } from \"@c-rex/types\";\nimport { call, generateQueryParams } from \"@c-rex/utils\";\nimport { Method } from \"axios\";\n\n/**\n * Base service class that provides common functionality for API interactions.\n * All specific service classes extend this base class.\n */\nexport class BaseService {\n protected api: CrexApi;\n private endpoint: string;\n\n /**\n * Creates a new instance of BaseService.\n * \n * @param endpoint - The API endpoint URL for this service\n */\n constructor(endpoint: string) {\n this.api = new CrexApi();\n this.endpoint = endpoint;\n }\n\n /**\n * Makes an API request to the specified endpoint.\n * \n * @param options - Request configuration options\n * @param options.path - Optional path to append to the endpoint\n * @param options.params - Optional query parameters to include in the request\n * @param options.method - HTTP method to use (defaults to 'get')\n * @param options.transformer - Optional function to transform the response data\n * @returns The response data, optionally transformed\n * @throws Error if the API request fails\n */\n protected async request<T>({\n path = \"\",\n method = \"get\",\n params = [],\n headers = {},\n transformer = (response: any) => response,\n }: {\n path?: string,\n method?: Method,\n params?: QueryParams[],\n headers?: any,\n transformer?: (data: any) => T,\n }): Promise<T> {\n try {\n let url = `${this.endpoint}${path}`;\n\n const queryParams = generateQueryParams(params);\n if (queryParams.length > 0) {\n url += `?${queryParams}`;\n }\n\n const response = await this.api.execute({\n url,\n method,\n headers,\n })\n\n return await transformer(response);\n\n } catch (error) {\n call(\"CrexLogger.log\", {\n level: \"error\",\n message: `BaseService.request error when request ${path}. Error: ${error}`\n });\n\n throw error;\n }\n }\n}\n\n","import { BaseService } from \"./baseService\";\nimport { informationUnitsRenditions } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with renditions in the API.\n * Provides methods to retrieve and process different types of renditions.\n */\nexport class RenditionsService extends BaseService {\n constructor() {\n super(\"Renditions/\");\n }\n\n /**\n * Retrieves the HTML rendition from a list of renditions.\n * Filters for renditions with format 'application/xhtml+xml' and rel 'view'.\n * \n * @param renditions - Array of rendition objects to process\n * @returns A promise that resolves to the HTML content as a string, or empty string if no suitable rendition is found\n * @throws Error if the API request fails\n */\n public async getHTMLRendition({ renditions }: { renditions: informationUnitsRenditions[] }): Promise<string> {\n const filteredRenditions = renditions.filter(\n (item) => item.format == \"application/xhtml+xml\",\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) return \"\";\n const item = filteredRenditions[0];\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n\n if (filteredLinks.length == 0 || filteredLinks[0] == undefined) return \"\";\n const url = filteredLinks[0].href;\n const response = await this.api.execute({\n url,\n method: \"get\",\n headers: {\n Accept: \"application/xhtml+xml\",\n },\n })\n\n return response as string;\n }\n}","import { BaseService } from \"./baseService\";\nimport { createParams } from \"@c-rex/utils\";\nimport { DirectoryNodes, DirectoryNodesResponse } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with directory nodes in the API.\n * Provides methods to retrieve directory node information.\n */\nexport class DirectoryNodesService extends BaseService {\n constructor() {\n super(\"DirectoryNodes/\");\n }\n\n /**\n * Retrieves a specific directory node by its ID.\n * \n * @param id - The unique identifier of the directory node\n * @returns A promise that resolves to the directory node data\n * @throws Error if the API request fails\n */\n public async getItem(id: string): Promise<DirectoryNodes> {\n return await this.request({\n path: id,\n });\n }\n\n /**\n * Retrieves a list of directory nodes based on specified filters.\n * \n * @param options - Options for filtering the directory nodes list\n * @param options.filters - Optional array of filter strings to apply\n * @returns A promise that resolves to the directory nodes response\n * @throws Error if the API request fails\n */\n public async getList({\n filters = [],\n }: {\n filters?: string[],\n }): Promise<DirectoryNodesResponse> {\n\n const remainFilters = createParams(filters, \"Filter\");\n\n return await this.request({\n params: {\n ...remainFilters,\n },\n });\n }\n}\n","import { DefaultRequest } from \"@c-rex/interfaces\";\nimport { DocumentTypesItem } from \"@c-rex/interfaces\";\n\nexport const transformDocumentTypes = (data: DefaultRequest<DocumentTypesItem>) => {\n const labels: string[] = [];\n\n data.items.forEach((documentItem: DocumentTypesItem) => {\n const aux = documentItem.labels.flatMap((item) => item);\n\n aux.forEach((item) => {\n if (item.language == \"en\") labels.push(item.value);\n });\n });\n\n return labels;\n};\n","import { createParams } from \"@c-rex/utils\";\nimport { transformDocumentTypes } from \"./transforms/documentTypes\";\nimport { BaseService } from \"./baseService\";\n\n/**\n * Service for interacting with document types in the API.\n * Provides methods to retrieve document type information.\n */\nexport class DocumentTypesService extends BaseService {\n constructor() {\n super(\"DocumentTypes/\");\n }\n\n /**\n * Retrieves document type labels for the specified fields.\n * The labels are restricted to English language (EN-us).\n * \n * @param fields - Array of field names to retrieve labels for\n * @returns A promise that resolves to an array of label strings\n * @throws Error if the API request fails\n */\n public async getLabels(fields: string[]): Promise<string[]> {\n const params = [\n {\n key: \"Restrict\",\n value: `languages~EN-us`,\n },\n ...createParams(fields, \"Fields\"),\n ];\n\n return await this.request({\n params,\n transformer: transformDocumentTypes,\n });\n }\n}\n","import { EN_LANG, RESULT_TYPES } from \"@c-rex/constants\";\nimport {\n DefaultRequest,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { getFileRenditions } from \"@c-rex/utils\";\n\nexport const transformInformationUnits = async (\n data: DefaultRequest<informationUnitsItems>,\n): Promise<informationUnitsResponse> => {\n const config = await getConfigs();\n\n const items = await Promise.all(data.items.map(async (item) => {\n const type = item.class.labels.filter((item) => item.language === EN_LANG)[0].value.toUpperCase();\n const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });\n\n let link = `/topics/${item.shortId}`;\n\n if (config.results.articlePageLayout == \"BLOG\") {\n link = `/blog/${item.shortId}`\n } else if (type == RESULT_TYPES.DOCUMENT) {\n link = `/documents/${item.shortId}`;\n }\n\n return {\n language: item.labels[0].language,\n title: item.labels[0].value,\n type: type,\n localeType: \"\",\n shortId: item.shortId,\n disabled: config.results.disabledResults.includes(type as any),\n link: link,\n filesToOpen,\n filesToDownload\n }\n }));\n return {\n items: items,\n pageInfo: data.pageInfo,\n };\n};","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\n\n/**\n * Service for interacting with information units in the API.\n * Provides methods to retrieve and search information units.\n */\nexport class InformationUnitsService extends BaseService {\n constructor() {\n super(\"InformationUnits/\");\n }\n\n /**\n * Retrieves a list of information units based on specified criteria.\n * \n * @param options - Options for filtering and paginating the information units list\n * @param options.queries - Optional search query string\n * @param options.page - Optional page number for pagination (defaults to 1)\n * @param options.fields - Optional array of fields to include in the response\n * @param options.filters - Optional array of filter strings to apply\n * @param options.languages - Optional array of language codes to filter by\n * @returns A promise that resolves to the information units response\n * @throws Error if the API request fails\n */\n public async getList({\n queries = \"\",\n page = 1,\n fields = [],\n filters = [],\n languages = []\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n fields?: string[],\n languages?: string[]\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const languageParams = createParams(\n languages.map(item => `languages=${item}`),\n \"Filter\"\n );\n /*\n const languageParams = createParams(\n languages.map(item => `?s iirds:language ${item}`),\n \"sparqlWhere\"\n );\n */\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"PageNumber\", value: page.toString() },\n ...remainFields,\n ...languageParams,\n ...remainFilters\n ];\n\n if (queries.length > 0) {\n params.push(\n { key: \"Query\", value: queries },\n );\n }\n\n return await this.request({\n params: params,\n transformer: transformInformationUnits\n });\n }\n\n /**\n * Retrieves a specific information unit by its ID.\n * Includes renditions, directory nodes, version information, titles, languages, and labels.\n * \n * @param options - Options for retrieving the information unit\n * @param options.id - The unique identifier of the information unit\n * @returns A promise that resolves to the information unit data\n * @throws Error if the API request fails\n */\n public async getItem({ id }: { id: string }): Promise<informationUnitsItems> {\n const params = [\n { key: \"Fields\", value: \"renditions\" },\n { key: \"Fields\", value: \"directoryNodes\" },\n { key: \"Fields\", value: \"versionOf\" },\n { key: \"Fields\", value: \"titles\" },\n { key: \"Fields\", value: \"languages\" },\n { key: \"Fields\", value: \"labels\" },\n ];\n\n return await this.request({\n path: id,\n params,\n });\n }\n\n /**\n * Retrieves autocomplete suggestions based on a query prefix.\n * \n * @param options - Options for retrieving suggestions\n * @param options.query - The query prefix to get suggestions for\n * @param options.language - The language of the suggestions\n * @returns A promise that resolves to an array of suggestion strings\n * @throws Error if the API request fails\n */\n public async getSuggestions(\n { query, language }: { query: string, language: string }\n ): Promise<string[]> {\n return await this.request({\n path: `Suggestions`,\n params: [\n { key: \"prefix\", value: query },\n { key: \"lang\", value: language },\n ],\n transformer: (data: AutocompleteSuggestion) => {\n const suggestions: string[] = []\n const comparableList: string[] = []\n\n data.suggestions.forEach((item) => {\n suggestions.push(item.value);\n comparableList.push(item.value.toLowerCase())\n })\n\n if (!comparableList.includes(query.toLowerCase())) {\n return [query, ...suggestions];\n }\n\n return suggestions\n },\n });\n }\n}\n","import { LanguageAndCountries } from \"@c-rex/interfaces\";\nimport { BaseService } from \"./baseService\";\nimport { getCountryCodeByLang } from \"@c-rex/utils\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\n/**\n * Service for interacting with language-related functionality in the API.\n * Provides methods to retrieve language and country information.\n */\nexport class LanguageService extends BaseService {\n constructor() {\n const configs = getConfigs()\n super(configs.languageSwitcher.endpoint);\n }\n\n /**\n * Retrieves a list of available languages and their associated countries.\n * Transforms the API response to include language code, country code, and original value.\n * \n * @returns A promise that resolves to an array of language and country objects\n * @throws Error if the API request fails\n */\n public async getLanguagesAndCountries(): Promise<LanguageAndCountries[]> {\n return await this.request({\n transformer: (data: { value: string; score: number }[]) => {\n const countryCodeList = data.map((item) => {\n /*\n api -> en, en-US\n default -> en-US. Then use EN-US \n\n api -> en\n default -> en-US. Then use EN\n */\n //should be abble to handle this items: en-US, en, pt, pt-PT, pt-BR \n\n const splittedValue = item.value.split(\"-\")\n const lang = splittedValue[0]\n let country = splittedValue[0]\n\n if (splittedValue.length > 1) {\n country = splittedValue[1]\n } else {\n country = getCountryCodeByLang(lang)\n }\n\n return {\n country: country,\n lang: lang,\n value: item.value,\n }\n })\n\n return countryCodeList.sort((a, b) => {\n return a.value.localeCompare(b.value)\n })\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA4D;;;ACArD,IAAM,MAAM;AAeZ,IAAM,aAAa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AACJ;;;ACrIA,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","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 = 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,MAA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K,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_logger","item","import_next_cookies"]}
|
package/dist/index.mjs
CHANGED
|
@@ -33,6 +33,16 @@ var RESULT_TYPES = {
|
|
|
33
33
|
};
|
|
34
34
|
var DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1e3;
|
|
35
35
|
var CREX_TOKEN_HEADER_KEY = "crex-token";
|
|
36
|
+
var WILD_CARD_OPTIONS = {
|
|
37
|
+
BOTH: "BOTH",
|
|
38
|
+
END: "END",
|
|
39
|
+
START: "START",
|
|
40
|
+
NONE: "NONE"
|
|
41
|
+
};
|
|
42
|
+
var OPERATOR_OPTIONS = {
|
|
43
|
+
AND: "AND",
|
|
44
|
+
OR: "OR"
|
|
45
|
+
};
|
|
36
46
|
|
|
37
47
|
// ../core/src/requests.ts
|
|
38
48
|
import { cookies } from "next/headers";
|
|
@@ -187,7 +197,7 @@ var CrexApi = class {
|
|
|
187
197
|
async initAPI() {
|
|
188
198
|
this.logger = new CrexLogger();
|
|
189
199
|
if (!this.customerConfig) {
|
|
190
|
-
const aux = cookies().get(SDK_CONFIG_KEY);
|
|
200
|
+
const aux = await cookies().get(SDK_CONFIG_KEY);
|
|
191
201
|
if (aux != void 0) {
|
|
192
202
|
this.customerConfig = JSON.parse(aux.value);
|
|
193
203
|
} else {
|
|
@@ -561,8 +571,10 @@ var DocumentTypesService = class extends BaseService {
|
|
|
561
571
|
|
|
562
572
|
// src/transforms/information.ts
|
|
563
573
|
import { getConfigs as getConfigs2 } from "@c-rex/utils/next-cookies";
|
|
574
|
+
import { CrexLogger as CrexLogger2 } from "@c-rex/core/logger";
|
|
564
575
|
var transformInformationUnits = async (data) => {
|
|
565
576
|
const config = await getConfigs2();
|
|
577
|
+
const logger = new CrexLogger2();
|
|
566
578
|
const items = await Promise.all(data.items.map(async (item) => {
|
|
567
579
|
const type = item.class.labels.filter((item2) => item2.language === EN_LANG)[0].value.toUpperCase();
|
|
568
580
|
const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });
|
|
@@ -572,9 +584,25 @@ var transformInformationUnits = async (data) => {
|
|
|
572
584
|
} else if (type == RESULT_TYPES.DOCUMENT) {
|
|
573
585
|
link = `/documents/${item.shortId}`;
|
|
574
586
|
}
|
|
587
|
+
let title = "NO TITLE";
|
|
588
|
+
let language = "NO LANGUAGE";
|
|
589
|
+
try {
|
|
590
|
+
if (item.titles) {
|
|
591
|
+
title = item.titles[0].value;
|
|
592
|
+
language = item.titles[0].language;
|
|
593
|
+
} else {
|
|
594
|
+
title = item.labels[0].value;
|
|
595
|
+
language = item.labels[0].language;
|
|
596
|
+
}
|
|
597
|
+
} catch {
|
|
598
|
+
logger.log({
|
|
599
|
+
level: "error",
|
|
600
|
+
message: `No label or title on item ${item.shortId}`
|
|
601
|
+
});
|
|
602
|
+
}
|
|
575
603
|
return {
|
|
576
|
-
language
|
|
577
|
-
title
|
|
604
|
+
language,
|
|
605
|
+
title,
|
|
578
606
|
type,
|
|
579
607
|
localeType: "",
|
|
580
608
|
shortId: item.shortId,
|
|
@@ -584,11 +612,24 @@ var transformInformationUnits = async (data) => {
|
|
|
584
612
|
filesToDownload
|
|
585
613
|
};
|
|
586
614
|
}));
|
|
615
|
+
const filteredList = items.filter((item) => item != null);
|
|
587
616
|
return {
|
|
588
|
-
items,
|
|
617
|
+
items: filteredList,
|
|
589
618
|
pageInfo: data.pageInfo
|
|
590
619
|
};
|
|
591
620
|
};
|
|
621
|
+
var transformSuggestions = (data, query) => {
|
|
622
|
+
const suggestions = [];
|
|
623
|
+
const comparableList = [];
|
|
624
|
+
data.suggestions.forEach((item) => {
|
|
625
|
+
suggestions.push(item.value);
|
|
626
|
+
comparableList.push(item.value.toLowerCase());
|
|
627
|
+
});
|
|
628
|
+
if (!comparableList.includes(query.toLowerCase())) {
|
|
629
|
+
return [query, ...suggestions];
|
|
630
|
+
}
|
|
631
|
+
return suggestions;
|
|
632
|
+
};
|
|
592
633
|
|
|
593
634
|
// src/informationUnits.ts
|
|
594
635
|
var InformationUnitsService = class extends BaseService {
|
|
@@ -612,20 +653,29 @@ var InformationUnitsService = class extends BaseService {
|
|
|
612
653
|
page = 1,
|
|
613
654
|
fields = [],
|
|
614
655
|
filters = [],
|
|
615
|
-
|
|
656
|
+
restrict = [],
|
|
657
|
+
languages = [],
|
|
658
|
+
wildcard = WILD_CARD_OPTIONS.BOTH,
|
|
659
|
+
operator = OPERATOR_OPTIONS.AND,
|
|
660
|
+
like = false
|
|
616
661
|
}) {
|
|
617
662
|
const remainFields = createParams(fields, "Fields");
|
|
618
663
|
const remainFilters = createParams(filters, "Filter");
|
|
664
|
+
const restrictions = createParams(restrict, "Restrict");
|
|
619
665
|
const languageParams = createParams(
|
|
620
|
-
languages.map((item) =>
|
|
621
|
-
"
|
|
666
|
+
languages.map((item) => `?s iirds:language '${item}'`),
|
|
667
|
+
"sparqlWhere"
|
|
622
668
|
);
|
|
623
669
|
const params = [
|
|
624
670
|
{ key: "pageSize", value: "12" },
|
|
671
|
+
{ key: "wildcard", value: wildcard.toLowerCase() },
|
|
625
672
|
{ key: "PageNumber", value: page.toString() },
|
|
673
|
+
{ key: "Operator", value: operator },
|
|
674
|
+
{ key: "Like", value: like.toString() },
|
|
626
675
|
...remainFields,
|
|
627
676
|
...languageParams,
|
|
628
|
-
...remainFilters
|
|
677
|
+
...remainFilters,
|
|
678
|
+
...restrictions
|
|
629
679
|
];
|
|
630
680
|
if (queries.length > 0) {
|
|
631
681
|
params.push(
|
|
@@ -653,7 +703,8 @@ var InformationUnitsService = class extends BaseService {
|
|
|
653
703
|
{ key: "Fields", value: "versionOf" },
|
|
654
704
|
{ key: "Fields", value: "titles" },
|
|
655
705
|
{ key: "Fields", value: "languages" },
|
|
656
|
-
{ key: "Fields", value: "labels" }
|
|
706
|
+
{ key: "Fields", value: "labels" },
|
|
707
|
+
{ key: "Fields", value: "packages" }
|
|
657
708
|
];
|
|
658
709
|
return await this.request({
|
|
659
710
|
path: id,
|
|
@@ -671,23 +722,12 @@ var InformationUnitsService = class extends BaseService {
|
|
|
671
722
|
*/
|
|
672
723
|
async getSuggestions({ query, language }) {
|
|
673
724
|
return await this.request({
|
|
674
|
-
path:
|
|
725
|
+
path: "Suggestions",
|
|
675
726
|
params: [
|
|
676
727
|
{ key: "prefix", value: query },
|
|
677
728
|
{ key: "lang", value: language }
|
|
678
729
|
],
|
|
679
|
-
transformer: (data) =>
|
|
680
|
-
const suggestions = [];
|
|
681
|
-
const comparableList = [];
|
|
682
|
-
data.suggestions.forEach((item) => {
|
|
683
|
-
suggestions.push(item.value);
|
|
684
|
-
comparableList.push(item.value.toLowerCase());
|
|
685
|
-
});
|
|
686
|
-
if (!comparableList.includes(query.toLowerCase())) {
|
|
687
|
-
return [query, ...suggestions];
|
|
688
|
-
}
|
|
689
|
-
return suggestions;
|
|
690
|
-
}
|
|
730
|
+
transformer: (data) => transformSuggestions(data, query)
|
|
691
731
|
});
|
|
692
732
|
}
|
|
693
733
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -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 = cookies().get(SDK_CONFIG_KEY);\n if (aux != undefined) {\n this.customerConfig = JSON.parse(aux.value);\n } else {\n this.logger.log({\n level: \"error\",\n message: `utils.initAPI error: Config cookie not available`\n });\n\n throw new Error(\"Config cookie not available\");\n }\n }\n\n if (!this.apiClient) {\n this.apiClient = axios.create({\n baseURL: this.customerConfig.baseUrl,\n })\n }\n }\n\n private async getToken() {\n try {\n const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/token`, {\n method: 'POST',\n credentials: 'include',\n });\n\n const { token } = await response.json();\n\n return token;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `utils.getToken error: ${error}`\n });\n\n throw error\n }\n }\n\n private async manageToken() {\n try {\n let token = \"\";\n const hasToken = cookies().get(CREX_TOKEN_HEADER_KEY);\n\n if (hasToken == undefined || hasToken.value === null) {\n const tokenResult = await this.getToken();\n\n if (tokenResult === null) throw new Error(\"Token is undefined\");\n\n token = tokenResult;\n } else {\n token = hasToken.value;\n }\n\n return token;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `utils.manageToken error: ${error}`\n });\n\n throw error\n }\n }\n\n /**\n * Executes an API request with caching, authentication, and retry logic.\n * \n * @param options - Request options\n * @param options.url - The URL to request\n * @param options.method - The HTTP method to use\n * @param options.params - Optional query parameters\n * @param options.body - Optional request body\n * @param options.headers - Optional request headers\n * @returns The response data\n * @throws Error if the request fails after maximum retries\n */\n async execute<T>({\n url,\n method,\n params,\n body,\n headers = {},\n }: CallParams): Promise<T> {\n await this.initAPI();\n\n let response: APIGenericResponse<T> | undefined = undefined;\n\n if (this.customerConfig.OIDC.client.enabled) {\n const token = await this.manageToken();\n\n headers = {\n ...headers,\n Authorization: `Bearer ${token}`,\n };\n\n this.apiClient.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n }\n\n for (let retry = 0; retry < API.MAX_RETRY; retry++) {\n try {\n response = await this.apiClient.request({\n url,\n method,\n data: body,\n params,\n headers,\n });\n\n break;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `API.execute ${retry + 1}º error when request ${url}. Error: ${error}`\n });\n\n if (retry === API.MAX_RETRY - 1) {\n throw error;\n }\n }\n }\n\n if (response) {\n return response.data;\n }\n\n throw new Error(\"API.execute error: Failed to retrieve a valid response\");\n }\n}","export const ALL = \"*\"\n\nexport const LOG_CATEGORIES = [\n \"NoLicense\",\n \"Scenario\",\n \"Favorites\",\n \"Subscription\",\n \"Share\",\n \"Document\",\n \"Search\",\n \"History\",\n \"Notification\",\n \"UserProfile\",\n] as const;\n\nexport const LOG_LEVELS = {\n critical: 2,\n error: 3,\n warning: 4,\n info: 6,\n debug: 7,\n} as const;\n\nexport const RESULT_VIEW_STYLES = [\n \"cards\",\n \"table\",\n] as const;\n\nexport const API = {\n MAX_RETRY: 3,\n API_TIMEOUT: 10000,\n API_HEADERS: {\n \"content-Type\": \"application/json\",\n },\n};\n\nexport const SDK_CONFIG_KEY = \"crex-sdk-config\";\n\nexport const CONTENT_LANG_KEY = \"CONTENT_LANG_KEY\";\n\nexport const AVAILABLE_CONTENT_LANG_KEY = \"AVAILABLE_CONTENT_LANG_KEY\";\n\nexport const UI_LANG_KEY = \"UI_LANG_KEY\";\n\nexport const FLAGS_BY_LANG = {\n \"en\": \"US\",\n \"de\": \"DE\",\n};\n\nexport const DEFAULT_LANG = \"en-US\";\n\nexport const EN_LANG = \"en\";\n\nexport const UI_LANG_OPTIONS = [\"en-us\", \"de-de\"];\n\nexport const TOPICS_TYPE_AND_LINK = \"topics\";\nexport const BLOG_TYPE_AND_LINK = \"blog\";\nexport const DOCUMENTS_TYPE_AND_LINK = \"documents\";\n\nexport const TOPIC = \"TOPIC\";\nexport const DOCUMENT = \"DOCUMENT\";\nexport const PACKAGE = \"PACKAGE\";\n\nexport const RESULT_TYPES = {\n TOPIC: TOPIC,\n DOCUMENT: DOCUMENT,\n PACKAGE: PACKAGE,\n} as const;\n\nexport const FILES_EXTENSIONS = {\n PDF: \"application/pdf\",\n HTML: \"text/html\",\n} as const;\n\nexport const DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";\n\nexport const CREX_TOKEN_HEADER_KEY = \"crex-token\";","import winston from \"winston\";\nimport { MatomoTransport } from \"./transports/matomo\";\nimport { GraylogTransport } from \"./transports/graylog\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { LOG_LEVELS } from \"@c-rex/constants\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\n/**\n * Logger class for the CREX application.\n * Provides logging functionality with multiple transports (Console, Matomo, Graylog).\n */\nexport class CrexLogger {\n private customerConfig!: ConfigInterface;\n public logger!: winston.Logger;\n\n /**\n * Initializes the logger instance if it hasn't been initialized yet.\n * Loads customer configuration and creates the logger with appropriate transports.\n * \n * @private\n */\n private async initLogger() {\n try {\n if (!this.customerConfig) {\n this.customerConfig = await getConfigs();\n }\n if (!this.logger) {\n this.logger = this.createLogger();\n }\n } catch (error) {\n console.error(\"Error initializing logger:\", error);\n }\n }\n\n /**\n * Logs a message with the specified level and optional category.\n * \n * @param options - Logging options\n * @param options.level - The log level (error, warn, info, etc.)\n * @param options.message - The message to log\n * @param options.category - Optional category for the log message\n */\n public async log({ level, message, category }: {\n level: LogLevelType,\n message: string,\n category?: LogCategoriesType\n }) {\n await this.initLogger();\n this.logger.log(level, message, category);\n }\n\n /**\n * Creates a new Winston logger instance with configured transports.\n * \n * @private\n * @returns A configured Winston logger instance\n */\n private createLogger() {\n return winston.createLogger({\n levels: LOG_LEVELS,\n transports: [\n new winston.transports.Console({\n level: this.customerConfig.logs.console.minimumLevel,\n silent: this.customerConfig.logs.console.silent,\n }),\n new MatomoTransport(this.customerConfig),\n new GraylogTransport(this.customerConfig),\n ],\n });\n }\n}","import Transport from \"winston-transport\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\n/**\n * Winston transport for sending logs to Matomo analytics.\n * Extends the base Winston transport with Matomo-specific functionality.\n */\nexport class MatomoTransport extends Transport {\n public matomoTransport: any;\n private configs: ConfigInterface;\n\n /**\n * Creates a new instance of MatomoTransport.\n * \n * @param configs - The application configuration containing logging settings\n */\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.matomo.minimumLevel,\n silent: configs.logs.matomo.silent,\n });\n\n this.matomoTransport = new Transport();\n this.configs = configs;\n }\n\n /**\n * Logs a message to Matomo if the message category is included in the configured categories.\n * \n * @param info - The log information including level, message, and category\n * @param callback - Callback function to execute after logging\n */\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const matomoCategory = this.configs.logs.matomo.categoriesLevel\n\n if (matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {\n this.matomoTransport.log(info, callback);\n }\n }\n}\n","import Transport from \"winston-transport\";\nimport Graylog2Transport from \"winston-graylog2\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\n/**\n * Winston transport for sending logs to Graylog.\n * Extends the base Winston transport with Graylog-specific functionality.\n */\nexport class GraylogTransport extends Transport {\n public graylogTransport: any;\n private configs: ConfigInterface\n\n /**\n * Creates a new instance of GraylogTransport.\n * \n * @param configs - The application configuration containing logging settings\n */\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.graylog.minimumLevel,\n silent: configs.logs.graylog.silent,\n });\n\n this.configs = configs;\n this.graylogTransport = new Graylog2Transport({\n name: \"crex.net.documentation\",\n //name: \"crex.net.blog\",\n silent: false,\n handleExceptions: false,\n graylog: {\n servers: [\n { host: \"localhost\", port: 12201 },\n { host: \"https://log.c-rex.net\", port: 12202 }\n\n //TODO: check the URL => https://log.c-rex.net:12202/gelf\" GELF??\n ],\n },\n });\n }\n\n /**\n * Logs a message to Graylog if the message category is included in the configured categories.\n * \n * @param info - The log information including level, message, and category\n * @param callback - Callback function to execute after logging\n */\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const graylogCategory = this.configs.logs.graylog.categoriesLevel\n\n if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {\n this.graylogTransport.log(info, callback);\n }\n }\n}\n","import { FLAGS_BY_LANG } from \"@c-rex/constants\";\n\nexport const _generateShaKey = async (input: string): Promise<string> => {\n const encoder = new TextEncoder();\n const data = encoder.encode(input);\n const hashBuffer = await crypto.subtle.digest('SHA-1', data);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const base64url = btoa(String.fromCharCode(...hashArray))\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '');\n\n return base64url.slice(0, 12);\n}\n\n/**\n * Retrieves the country code associated with a given language code.\n * @param lang - The language code to look up (e.g., \"en-US\")\n * @returns The corresponding country code, or the original language code if not found\n */\nexport const getCountryCodeByLang = (lang: string): string => {\n const mappedKeys = Object.keys(FLAGS_BY_LANG);\n\n if (!mappedKeys.includes(lang)) {\n return lang\n }\n\n type LangKey = keyof typeof FLAGS_BY_LANG;\n const country = FLAGS_BY_LANG[lang as LangKey]\n\n return country\n}\n\nexport const getFromCookieString = (cookieString: string, key: string): string => {\n const cookies = cookieString.split(';')\n\n for (const cookie of cookies) {\n const [cookieKey, cookieValue] = cookie.trim().split('=')\n\n if (cookieKey === key) {\n return cookieValue as string;\n }\n }\n\n return ''\n}\n","import { _generateShaKey } from \"./utils\"\n\n/**\n * Makes an asynchronous RPC API call to the server.\n * @param method - The RPC method name to call\n * @param params - Optional parameters to pass to the method\n * @returns A Promise resolving to the response data of type T\n */\nexport const call = async<T = unknown>(method: string, params?: any): Promise<T> => {\n type result = {\n data: string,\n expireDate: Date,\n }\n\n const shaKey = await _generateShaKey(JSON.stringify({ method, params }))\n const cache = localStorage.getItem(shaKey)\n\n if (cache !== null) {\n const { data, expireDate } = JSON.parse(cache) as result\n\n if (new Date(expireDate) > new Date()) {\n return JSON.parse(data) as T\n } else {\n localStorage.removeItem(shaKey)\n }\n }\n\n const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/rpc`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ method, params }),\n credentials: 'include',\n });\n\n const json = await res.json();\n\n if (!res.ok) throw new Error(json.error || 'Unknown error');\n\n const today = new Date()\n const result: result = {\n data: JSON.stringify(json.data),\n expireDate: new Date(today.getTime() + 1000 * 60 * 60),\n }\n\n localStorage.setItem(shaKey, JSON.stringify(result))\n\n return json.data;\n}","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merges multiple class values into a single string using clsx and tailwind-merge.\n * Useful for conditionally applying Tailwind CSS classes.\n * @param inputs - Any number of class values (strings, objects, arrays, etc.)\n * @returns A merged string of class names optimized for Tailwind CSS\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import { QueryParams } from '@c-rex/types';\n\n/**\n * Creates an array of parameter objects from a list of field values.\n * @param fieldsList - Array of field values to transform into parameter objects\n * @param key - The key to use for each parameter object (defaults to \"Fields\")\n * @returns An array of objects with key-value pairs\n */\nexport const createParams = (fieldsList: string[], key: string = \"Fields\") =>\n fieldsList.map((item) => ({\n key: key,\n value: item,\n }));\n\n/**\n * Generates a URL query string from an array of parameter objects.\n * @param params - Array of QueryParams objects containing key-value pairs\n * @returns A URL-encoded query string\n */\nexport const generateQueryParams = (params: QueryParams[]): string => {\n const queryParams = params\n .map(\n (param) =>\n `${encodeURIComponent(param.key)}=${encodeURIComponent(param.value)}`,\n )\n .join(\"&\");\n return queryParams;\n};\n","import { FileRenditionType } from \"@c-rex/types\";\nimport { informationUnitsRenditions } from \"@c-rex/interfaces\";\n\ntype RenditionType = {\n filesToDownload: FileRenditionType[],\n filesToOpen: FileRenditionType[]\n}\nexport const getFileRenditions = ({ renditions }: { renditions: informationUnitsRenditions[] }): RenditionType => {\n if (renditions == undefined || renditions.length == 0) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filteredRenditions = renditions.filter(\n (item) => item.format != \"application/xhtml+xml\" && item.format != \"application/json\" && item.format != \"application/llm+xml\"\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filesToDownload = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"download\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n });\n\n const filesToOpen = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n })\n\n return {\n filesToDownload: filesToDownload,\n filesToOpen: filesToOpen,\n }\n}","import { CrexApi } from \"@c-rex/core\";\nimport { QueryParams } from \"@c-rex/types\";\nimport { call, generateQueryParams } from \"@c-rex/utils\";\nimport { Method } from \"axios\";\n\n/**\n * Base service class that provides common functionality for API interactions.\n * All specific service classes extend this base class.\n */\nexport class BaseService {\n protected api: CrexApi;\n private endpoint: string;\n\n /**\n * Creates a new instance of BaseService.\n * \n * @param endpoint - The API endpoint URL for this service\n */\n constructor(endpoint: string) {\n this.api = new CrexApi();\n this.endpoint = endpoint;\n }\n\n /**\n * Makes an API request to the specified endpoint.\n * \n * @param options - Request configuration options\n * @param options.path - Optional path to append to the endpoint\n * @param options.params - Optional query parameters to include in the request\n * @param options.method - HTTP method to use (defaults to 'get')\n * @param options.transformer - Optional function to transform the response data\n * @returns The response data, optionally transformed\n * @throws Error if the API request fails\n */\n protected async request<T>({\n path = \"\",\n method = \"get\",\n params = [],\n headers = {},\n transformer = (response: any) => response,\n }: {\n path?: string,\n method?: Method,\n params?: QueryParams[],\n headers?: any,\n transformer?: (data: any) => T,\n }): Promise<T> {\n try {\n let url = `${this.endpoint}${path}`;\n\n const queryParams = generateQueryParams(params);\n if (queryParams.length > 0) {\n url += `?${queryParams}`;\n }\n\n const response = await this.api.execute({\n url,\n method,\n headers,\n })\n\n return await transformer(response);\n\n } catch (error) {\n call(\"CrexLogger.log\", {\n level: \"error\",\n message: `BaseService.request error when request ${path}. Error: ${error}`\n });\n\n throw error;\n }\n }\n}\n\n","import { BaseService } from \"./baseService\";\nimport { informationUnitsRenditions } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with renditions in the API.\n * Provides methods to retrieve and process different types of renditions.\n */\nexport class RenditionsService extends BaseService {\n constructor() {\n super(\"Renditions/\");\n }\n\n /**\n * Retrieves the HTML rendition from a list of renditions.\n * Filters for renditions with format 'application/xhtml+xml' and rel 'view'.\n * \n * @param renditions - Array of rendition objects to process\n * @returns A promise that resolves to the HTML content as a string, or empty string if no suitable rendition is found\n * @throws Error if the API request fails\n */\n public async getHTMLRendition({ renditions }: { renditions: informationUnitsRenditions[] }): Promise<string> {\n const filteredRenditions = renditions.filter(\n (item) => item.format == \"application/xhtml+xml\",\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) return \"\";\n const item = filteredRenditions[0];\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n\n if (filteredLinks.length == 0 || filteredLinks[0] == undefined) return \"\";\n const url = filteredLinks[0].href;\n const response = await this.api.execute({\n url,\n method: \"get\",\n headers: {\n Accept: \"application/xhtml+xml\",\n },\n })\n\n return response as string;\n }\n}","import { BaseService } from \"./baseService\";\nimport { createParams } from \"@c-rex/utils\";\nimport { DirectoryNodes, DirectoryNodesResponse } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with directory nodes in the API.\n * Provides methods to retrieve directory node information.\n */\nexport class DirectoryNodesService extends BaseService {\n constructor() {\n super(\"DirectoryNodes/\");\n }\n\n /**\n * Retrieves a specific directory node by its ID.\n * \n * @param id - The unique identifier of the directory node\n * @returns A promise that resolves to the directory node data\n * @throws Error if the API request fails\n */\n public async getItem(id: string): Promise<DirectoryNodes> {\n return await this.request({\n path: id,\n });\n }\n\n /**\n * Retrieves a list of directory nodes based on specified filters.\n * \n * @param options - Options for filtering the directory nodes list\n * @param options.filters - Optional array of filter strings to apply\n * @returns A promise that resolves to the directory nodes response\n * @throws Error if the API request fails\n */\n public async getList({\n filters = [],\n }: {\n filters?: string[],\n }): Promise<DirectoryNodesResponse> {\n\n const remainFilters = createParams(filters, \"Filter\");\n\n return await this.request({\n params: {\n ...remainFilters,\n },\n });\n }\n}\n","import { DefaultRequest } from \"@c-rex/interfaces\";\nimport { DocumentTypesItem } from \"@c-rex/interfaces\";\n\nexport const transformDocumentTypes = (data: DefaultRequest<DocumentTypesItem>) => {\n const labels: string[] = [];\n\n data.items.forEach((documentItem: DocumentTypesItem) => {\n const aux = documentItem.labels.flatMap((item) => item);\n\n aux.forEach((item) => {\n if (item.language == \"en\") labels.push(item.value);\n });\n });\n\n return labels;\n};\n","import { createParams } from \"@c-rex/utils\";\nimport { transformDocumentTypes } from \"./transforms/documentTypes\";\nimport { BaseService } from \"./baseService\";\n\n/**\n * Service for interacting with document types in the API.\n * Provides methods to retrieve document type information.\n */\nexport class DocumentTypesService extends BaseService {\n constructor() {\n super(\"DocumentTypes/\");\n }\n\n /**\n * Retrieves document type labels for the specified fields.\n * The labels are restricted to English language (EN-us).\n * \n * @param fields - Array of field names to retrieve labels for\n * @returns A promise that resolves to an array of label strings\n * @throws Error if the API request fails\n */\n public async getLabels(fields: string[]): Promise<string[]> {\n const params = [\n {\n key: \"Restrict\",\n value: `languages~EN-us`,\n },\n ...createParams(fields, \"Fields\"),\n ];\n\n return await this.request({\n params,\n transformer: transformDocumentTypes,\n });\n }\n}\n","import { EN_LANG, RESULT_TYPES } from \"@c-rex/constants\";\nimport {\n DefaultRequest,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { getFileRenditions } from \"@c-rex/utils\";\n\nexport const transformInformationUnits = async (\n data: DefaultRequest<informationUnitsItems>,\n): Promise<informationUnitsResponse> => {\n const config = await getConfigs();\n\n const items = await Promise.all(data.items.map(async (item) => {\n const type = item.class.labels.filter((item) => item.language === EN_LANG)[0].value.toUpperCase();\n const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });\n\n let link = `/topics/${item.shortId}`;\n\n if (config.results.articlePageLayout == \"BLOG\") {\n link = `/blog/${item.shortId}`\n } else if (type == RESULT_TYPES.DOCUMENT) {\n link = `/documents/${item.shortId}`;\n }\n\n return {\n language: item.labels[0].language,\n title: item.labels[0].value,\n type: type,\n localeType: \"\",\n shortId: item.shortId,\n disabled: config.results.disabledResults.includes(type as any),\n link: link,\n filesToOpen,\n filesToDownload\n }\n }));\n return {\n items: items,\n pageInfo: data.pageInfo,\n };\n};","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\n\n/**\n * Service for interacting with information units in the API.\n * Provides methods to retrieve and search information units.\n */\nexport class InformationUnitsService extends BaseService {\n constructor() {\n super(\"InformationUnits/\");\n }\n\n /**\n * Retrieves a list of information units based on specified criteria.\n * \n * @param options - Options for filtering and paginating the information units list\n * @param options.queries - Optional search query string\n * @param options.page - Optional page number for pagination (defaults to 1)\n * @param options.fields - Optional array of fields to include in the response\n * @param options.filters - Optional array of filter strings to apply\n * @param options.languages - Optional array of language codes to filter by\n * @returns A promise that resolves to the information units response\n * @throws Error if the API request fails\n */\n public async getList({\n queries = \"\",\n page = 1,\n fields = [],\n filters = [],\n languages = []\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n fields?: string[],\n languages?: string[]\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const languageParams = createParams(\n languages.map(item => `languages=${item}`),\n \"Filter\"\n );\n /*\n const languageParams = createParams(\n languages.map(item => `?s iirds:language ${item}`),\n \"sparqlWhere\"\n );\n */\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"PageNumber\", value: page.toString() },\n ...remainFields,\n ...languageParams,\n ...remainFilters\n ];\n\n if (queries.length > 0) {\n params.push(\n { key: \"Query\", value: queries },\n );\n }\n\n return await this.request({\n params: params,\n transformer: transformInformationUnits\n });\n }\n\n /**\n * Retrieves a specific information unit by its ID.\n * Includes renditions, directory nodes, version information, titles, languages, and labels.\n * \n * @param options - Options for retrieving the information unit\n * @param options.id - The unique identifier of the information unit\n * @returns A promise that resolves to the information unit data\n * @throws Error if the API request fails\n */\n public async getItem({ id }: { id: string }): Promise<informationUnitsItems> {\n const params = [\n { key: \"Fields\", value: \"renditions\" },\n { key: \"Fields\", value: \"directoryNodes\" },\n { key: \"Fields\", value: \"versionOf\" },\n { key: \"Fields\", value: \"titles\" },\n { key: \"Fields\", value: \"languages\" },\n { key: \"Fields\", value: \"labels\" },\n ];\n\n return await this.request({\n path: id,\n params,\n });\n }\n\n /**\n * Retrieves autocomplete suggestions based on a query prefix.\n * \n * @param options - Options for retrieving suggestions\n * @param options.query - The query prefix to get suggestions for\n * @param options.language - The language of the suggestions\n * @returns A promise that resolves to an array of suggestion strings\n * @throws Error if the API request fails\n */\n public async getSuggestions(\n { query, language }: { query: string, language: string }\n ): Promise<string[]> {\n return await this.request({\n path: `Suggestions`,\n params: [\n { key: \"prefix\", value: query },\n { key: \"lang\", value: language },\n ],\n transformer: (data: AutocompleteSuggestion) => {\n const suggestions: string[] = []\n const comparableList: string[] = []\n\n data.suggestions.forEach((item) => {\n suggestions.push(item.value);\n comparableList.push(item.value.toLowerCase())\n })\n\n if (!comparableList.includes(query.toLowerCase())) {\n return [query, ...suggestions];\n }\n\n return suggestions\n },\n });\n }\n}\n","import { LanguageAndCountries } from \"@c-rex/interfaces\";\nimport { BaseService } from \"./baseService\";\nimport { getCountryCodeByLang } from \"@c-rex/utils\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\n/**\n * Service for interacting with language-related functionality in the API.\n * Provides methods to retrieve language and country information.\n */\nexport class LanguageService extends BaseService {\n constructor() {\n const configs = getConfigs()\n super(configs.languageSwitcher.endpoint);\n }\n\n /**\n * Retrieves a list of available languages and their associated countries.\n * Transforms the API response to include language code, country code, and original value.\n * \n * @returns A promise that resolves to an array of language and country objects\n * @throws Error if the API request fails\n */\n public async getLanguagesAndCountries(): Promise<LanguageAndCountries[]> {\n return await this.request({\n transformer: (data: { value: string; score: number }[]) => {\n const countryCodeList = data.map((item) => {\n /*\n api -> en, en-US\n default -> en-US. Then use EN-US \n\n api -> en\n default -> en-US. Then use EN\n */\n //should be abble to handle this items: en-US, en, pt, pt-PT, pt-BR \n\n const splittedValue = item.value.split(\"-\")\n const lang = splittedValue[0]\n let country = splittedValue[0]\n\n if (splittedValue.length > 1) {\n country = splittedValue[1]\n } else {\n country = getCountryCodeByLang(lang)\n }\n\n return {\n country: country,\n lang: lang,\n value: item.value,\n }\n })\n\n return countryCodeList.sort((a, b) => {\n return a.value.localeCompare(b.value)\n })\n },\n });\n }\n}\n"],"mappings":";AAAA,OAAO,WAAqD;;;ACArD,IAAM,MAAM;AAeZ,IAAM,aAAa;AAAA,EACtB,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACX;AAOO,IAAM,MAAM;AAAA,EACf,WAAW;AAAA,EACX,aAAa;AAAA,EACb,aAAa;AAAA,IACT,gBAAgB;AAAA,EACpB;AACJ;AAEO,IAAM,iBAAiB;AAQvB,IAAM,gBAAgB;AAAA,EACzB,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;;;AD/ErC,SAAS,eAAe;;;AEHxB,OAAO,aAAa;;;ACApB,OAAO,eAAe;AASf,IAAM,kBAAN,cAA8B,UAAU;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,OAAO;AAAA,IAChC,CAAC;AAED,SAAK,kBAAkB,IA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;","names":["Transport","Transport","item","item","getConfigs","getConfigs","item","getConfigs"]}
|
|
1
|
+
{"version":3,"sources":["../../core/src/requests.ts","../../constants/src/index.ts","../../core/src/logger.ts","../../core/src/transports/matomo.ts","../../core/src/transports/graylog.ts","../../utils/src/utils.ts","../../utils/src/call.ts","../../utils/src/classMerge.ts","../../utils/src/params.ts","../../utils/src/renditions.ts","../src/baseService.ts","../src/renditions.ts","../src/directoryNodes.ts","../src/transforms/documentTypes.ts","../src/documentTypes.ts","../src/transforms/information.ts","../src/informationUnits.ts","../src/language.ts"],"sourcesContent":["import axios, { AxiosResponse, Method, AxiosInstance } from \"axios\";\nimport { API, CREX_TOKEN_HEADER_KEY, SDK_CONFIG_KEY } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { cookies } from \"next/headers\";\nimport { CrexLogger } from \"./logger\";\n\n/**\n * Interface for API response with generic data type.\n */\ninterface APIGenericResponse<T> extends AxiosResponse {\n data: T;\n statusCode: number;\n}\n\n/**\n * Interface for API call parameters.\n */\ninterface CallParams {\n url: string;\n method: Method;\n body?: any;\n headers?: any;\n params?: any;\n}\n\n/**\n * API client class for the CREX application.\n * Handles API requests with caching, authentication, and retry logic.\n */\nexport class CrexApi {\n private customerConfig!: ConfigInterface;\n private apiClient!: AxiosInstance;\n private logger!: CrexLogger;\n\n /**\n * Initializes the API client if it hasn't been initialized yet.\n * Loads customer configuration, creates the axios instance, and initializes the logger.\n * \n * @private\n */\n private async initAPI() {\n this.logger = new CrexLogger();\n\n if (!this.customerConfig) {\n const aux = 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,eAAe;AASf,IAAM,kBAAN,cAA8B,UAAU;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,OAAO;AAAA,IAChC,CAAC;AAED,SAAK,kBAAkB,IAAI,UAAU;AACrC,SAAK,UAAU;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IACI,MACA,UACI;AACJ,UAAM,iBAAiB,KAAK,QAAQ,K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