@c-rex/services 0.1.6 → 0.1.7
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 +38 -5
- package/dist/index.d.ts +38 -5
- package/dist/index.js +166 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +164 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CrexApi } from '@c-rex/core';
|
|
2
2
|
import { Method } from 'axios';
|
|
3
|
-
import { informationUnitsRenditions, DirectoryNodes, DirectoryNodesResponse, informationUnitsResponse, informationUnitsItems, LanguageAndCountries } from '@c-rex/interfaces';
|
|
3
|
+
import { informationUnitsRenditions, DirectoryNodes, DirectoryNodesResponse, informationUnitsResponse, informationUnitsItems, LanguageAndCountries, DefaultResponse, TopicsResponseItem } from '@c-rex/interfaces';
|
|
4
4
|
|
|
5
5
|
declare const WILD_CARD_OPTIONS: {
|
|
6
6
|
readonly BOTH: "BOTH";
|
|
@@ -102,13 +102,14 @@ declare class DocumentTypesService extends BaseService {
|
|
|
102
102
|
constructor();
|
|
103
103
|
/**
|
|
104
104
|
* Retrieves document type labels for the specified fields.
|
|
105
|
-
* The labels are restricted to English language (EN-us).
|
|
106
105
|
*
|
|
107
|
-
* @param fields - Array of field names to retrieve labels for
|
|
108
106
|
* @returns A promise that resolves to an array of label strings
|
|
109
107
|
* @throws Error if the API request fails
|
|
110
108
|
*/
|
|
111
|
-
getLabels(
|
|
109
|
+
getLabels(): Promise<{
|
|
110
|
+
shortId: string;
|
|
111
|
+
label: string;
|
|
112
|
+
}[]>;
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
/**
|
|
@@ -183,4 +184,36 @@ declare class LanguageService extends BaseService {
|
|
|
183
184
|
getLanguagesAndCountries(): Promise<LanguageAndCountries[]>;
|
|
184
185
|
}
|
|
185
186
|
|
|
186
|
-
|
|
187
|
+
type getListProps = {
|
|
188
|
+
queries?: string;
|
|
189
|
+
page?: number;
|
|
190
|
+
filters?: string[];
|
|
191
|
+
fields?: string[];
|
|
192
|
+
languages?: string[];
|
|
193
|
+
wildcard?: WildCardType;
|
|
194
|
+
operator?: string;
|
|
195
|
+
like?: boolean;
|
|
196
|
+
pageSize?: number;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Service for interacting with information units in the API.
|
|
200
|
+
* Provides methods to retrieve and search information units.
|
|
201
|
+
*/
|
|
202
|
+
declare class TopicsService extends BaseService {
|
|
203
|
+
constructor();
|
|
204
|
+
/**
|
|
205
|
+
* Retrieves a list of topics based on specified criteria.
|
|
206
|
+
*
|
|
207
|
+
* @param options - Options for filtering and paginating the topics list
|
|
208
|
+
* @param options.queries - Optional search query string
|
|
209
|
+
* @param options.page - Optional page number for pagination (defaults to 1)
|
|
210
|
+
* @param options.fields - Optional array of fields to include in the response
|
|
211
|
+
* @param options.filters - Optional array of filter strings to apply
|
|
212
|
+
* @param options.languages - Optional array of language codes to filter by
|
|
213
|
+
* @returns A promise that resolves to the information units response
|
|
214
|
+
* @throws Error if the API request fails
|
|
215
|
+
*/
|
|
216
|
+
getList({ queries, page, fields, filters, languages, wildcard, operator, pageSize }: getListProps): Promise<DefaultResponse<TopicsResponseItem, null>>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export { DirectoryNodesService, DocumentTypesService, InformationUnitsService, LanguageService, RenditionsService, TopicsService };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CrexApi } from '@c-rex/core';
|
|
2
2
|
import { Method } from 'axios';
|
|
3
|
-
import { informationUnitsRenditions, DirectoryNodes, DirectoryNodesResponse, informationUnitsResponse, informationUnitsItems, LanguageAndCountries } from '@c-rex/interfaces';
|
|
3
|
+
import { informationUnitsRenditions, DirectoryNodes, DirectoryNodesResponse, informationUnitsResponse, informationUnitsItems, LanguageAndCountries, DefaultResponse, TopicsResponseItem } from '@c-rex/interfaces';
|
|
4
4
|
|
|
5
5
|
declare const WILD_CARD_OPTIONS: {
|
|
6
6
|
readonly BOTH: "BOTH";
|
|
@@ -102,13 +102,14 @@ declare class DocumentTypesService extends BaseService {
|
|
|
102
102
|
constructor();
|
|
103
103
|
/**
|
|
104
104
|
* Retrieves document type labels for the specified fields.
|
|
105
|
-
* The labels are restricted to English language (EN-us).
|
|
106
105
|
*
|
|
107
|
-
* @param fields - Array of field names to retrieve labels for
|
|
108
106
|
* @returns A promise that resolves to an array of label strings
|
|
109
107
|
* @throws Error if the API request fails
|
|
110
108
|
*/
|
|
111
|
-
getLabels(
|
|
109
|
+
getLabels(): Promise<{
|
|
110
|
+
shortId: string;
|
|
111
|
+
label: string;
|
|
112
|
+
}[]>;
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
/**
|
|
@@ -183,4 +184,36 @@ declare class LanguageService extends BaseService {
|
|
|
183
184
|
getLanguagesAndCountries(): Promise<LanguageAndCountries[]>;
|
|
184
185
|
}
|
|
185
186
|
|
|
186
|
-
|
|
187
|
+
type getListProps = {
|
|
188
|
+
queries?: string;
|
|
189
|
+
page?: number;
|
|
190
|
+
filters?: string[];
|
|
191
|
+
fields?: string[];
|
|
192
|
+
languages?: string[];
|
|
193
|
+
wildcard?: WildCardType;
|
|
194
|
+
operator?: string;
|
|
195
|
+
like?: boolean;
|
|
196
|
+
pageSize?: number;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Service for interacting with information units in the API.
|
|
200
|
+
* Provides methods to retrieve and search information units.
|
|
201
|
+
*/
|
|
202
|
+
declare class TopicsService extends BaseService {
|
|
203
|
+
constructor();
|
|
204
|
+
/**
|
|
205
|
+
* Retrieves a list of topics based on specified criteria.
|
|
206
|
+
*
|
|
207
|
+
* @param options - Options for filtering and paginating the topics list
|
|
208
|
+
* @param options.queries - Optional search query string
|
|
209
|
+
* @param options.page - Optional page number for pagination (defaults to 1)
|
|
210
|
+
* @param options.fields - Optional array of fields to include in the response
|
|
211
|
+
* @param options.filters - Optional array of filter strings to apply
|
|
212
|
+
* @param options.languages - Optional array of language codes to filter by
|
|
213
|
+
* @returns A promise that resolves to the information units response
|
|
214
|
+
* @throws Error if the API request fails
|
|
215
|
+
*/
|
|
216
|
+
getList({ queries, page, fields, filters, languages, wildcard, operator, pageSize }: getListProps): Promise<DefaultResponse<TopicsResponseItem, null>>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export { DirectoryNodesService, DocumentTypesService, InformationUnitsService, LanguageService, RenditionsService, TopicsService };
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,8 @@ __export(index_exports, {
|
|
|
34
34
|
DocumentTypesService: () => DocumentTypesService,
|
|
35
35
|
InformationUnitsService: () => InformationUnitsService,
|
|
36
36
|
LanguageService: () => LanguageService,
|
|
37
|
-
RenditionsService: () => RenditionsService
|
|
37
|
+
RenditionsService: () => RenditionsService,
|
|
38
|
+
TopicsService: () => TopicsService
|
|
38
39
|
});
|
|
39
40
|
module.exports = __toCommonJS(index_exports);
|
|
40
41
|
|
|
@@ -366,6 +367,17 @@ var getCountryCodeByLang = (lang) => {
|
|
|
366
367
|
const country = FLAGS_BY_LANG[lang];
|
|
367
368
|
return country;
|
|
368
369
|
};
|
|
370
|
+
var formatDateToLocale = (date, locale) => {
|
|
371
|
+
if (typeof date !== "string" || !date) {
|
|
372
|
+
return date;
|
|
373
|
+
}
|
|
374
|
+
const dateAux = new Date(date);
|
|
375
|
+
return new Intl.DateTimeFormat(locale, {
|
|
376
|
+
day: "2-digit",
|
|
377
|
+
month: "long",
|
|
378
|
+
year: "numeric"
|
|
379
|
+
}).format(dateAux);
|
|
380
|
+
};
|
|
369
381
|
|
|
370
382
|
// ../utils/src/call.ts
|
|
371
383
|
var call = async (method, params) => {
|
|
@@ -573,12 +585,18 @@ var DirectoryNodesService = class extends BaseService {
|
|
|
573
585
|
};
|
|
574
586
|
|
|
575
587
|
// src/transforms/documentTypes.ts
|
|
588
|
+
var import_next_cookies2 = require("@c-rex/utils/next-cookies");
|
|
589
|
+
var import_headers2 = require("next/headers");
|
|
576
590
|
var transformDocumentTypes = (data) => {
|
|
577
591
|
const labels = [];
|
|
592
|
+
const config = (0, import_next_cookies2.getConfigs)();
|
|
593
|
+
const contentLanguage = (0, import_headers2.cookies)().get(CONTENT_LANG_KEY)?.value || config.languageSwitcher.default;
|
|
594
|
+
const language = contentLanguage.split("-")[0];
|
|
578
595
|
data.items.forEach((documentItem) => {
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
|
|
596
|
+
const label = documentItem.labels.find((item) => item.language.toLowerCase() === language.toLowerCase());
|
|
597
|
+
labels.push({
|
|
598
|
+
shortId: documentItem.shortId,
|
|
599
|
+
label: label ? label.value : ""
|
|
582
600
|
});
|
|
583
601
|
});
|
|
584
602
|
return labels;
|
|
@@ -591,34 +609,28 @@ var DocumentTypesService = class extends BaseService {
|
|
|
591
609
|
}
|
|
592
610
|
/**
|
|
593
611
|
* Retrieves document type labels for the specified fields.
|
|
594
|
-
* The labels are restricted to English language (EN-us).
|
|
595
612
|
*
|
|
596
|
-
* @param fields - Array of field names to retrieve labels for
|
|
597
613
|
* @returns A promise that resolves to an array of label strings
|
|
598
614
|
* @throws Error if the API request fails
|
|
599
615
|
*/
|
|
600
|
-
async getLabels(
|
|
601
|
-
const params = [
|
|
602
|
-
{
|
|
603
|
-
key: "Restrict",
|
|
604
|
-
value: `languages~EN-us`
|
|
605
|
-
},
|
|
606
|
-
...createParams(fields, "Fields")
|
|
607
|
-
];
|
|
616
|
+
async getLabels() {
|
|
608
617
|
return await this.request({
|
|
609
|
-
params
|
|
618
|
+
params: [{
|
|
619
|
+
key: "sparqlWhere",
|
|
620
|
+
value: "?iu iirds:is-applicable-for-document-type ?s . ?iu iirds:has-topic-type <https://www.c-rex.net/iirds/td#Blogpost>"
|
|
621
|
+
}],
|
|
610
622
|
transformer: transformDocumentTypes
|
|
611
623
|
});
|
|
612
624
|
}
|
|
613
625
|
};
|
|
614
626
|
|
|
615
627
|
// src/transforms/information.ts
|
|
616
|
-
var
|
|
617
|
-
var
|
|
628
|
+
var import_next_cookies3 = require("@c-rex/utils/next-cookies");
|
|
629
|
+
var import_headers3 = require("next/headers");
|
|
618
630
|
var import_logger2 = require("@c-rex/core/logger");
|
|
619
631
|
var transformInformationUnits = async (data) => {
|
|
620
632
|
const logger = new import_logger2.CrexLogger();
|
|
621
|
-
const config = await (0,
|
|
633
|
+
const config = await (0, import_next_cookies3.getConfigs)();
|
|
622
634
|
const filteredTags = {};
|
|
623
635
|
const items = data.items.map((item) => {
|
|
624
636
|
const type = item.class.labels.filter((item2) => item2.language === EN_LANG)[0].value.toUpperCase();
|
|
@@ -658,7 +670,7 @@ var transformInformationUnits = async (data) => {
|
|
|
658
670
|
};
|
|
659
671
|
});
|
|
660
672
|
if (data.tags) {
|
|
661
|
-
const contentLang = ((0,
|
|
673
|
+
const contentLang = ((0, import_headers3.cookies)().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase();
|
|
662
674
|
const splittedContentLang = contentLang.split("-")[0];
|
|
663
675
|
for (const [key, value] of Object.entries(data.tags)) {
|
|
664
676
|
if (!value || !value.items || value.items.length === 0) {
|
|
@@ -681,7 +693,7 @@ var transformInformationUnits = async (data) => {
|
|
|
681
693
|
for (const labelItem of item.labels) {
|
|
682
694
|
if (labelItem.language === void 0) {
|
|
683
695
|
logger.log({
|
|
684
|
-
level: "
|
|
696
|
+
level: "info",
|
|
685
697
|
message: `No language on label ${labelItem.value} from category ${key}`
|
|
686
698
|
});
|
|
687
699
|
label = labelItem.value;
|
|
@@ -764,6 +776,7 @@ var InformationUnitsService = class extends BaseService {
|
|
|
764
776
|
{ key: "PageNumber", value: page.toString() },
|
|
765
777
|
{ key: "Operator", value: operator },
|
|
766
778
|
{ key: "tags", value: "true" },
|
|
779
|
+
// TODO use customer config values and add a param to each one
|
|
767
780
|
{ key: "Like", value: like.toString() },
|
|
768
781
|
...remainFields,
|
|
769
782
|
...remainFilters,
|
|
@@ -799,7 +812,9 @@ var InformationUnitsService = class extends BaseService {
|
|
|
799
812
|
{ key: "Fields", value: "titles" },
|
|
800
813
|
{ key: "Fields", value: "languages" },
|
|
801
814
|
{ key: "Fields", value: "labels" },
|
|
802
|
-
{ key: "Fields", value: "packages" }
|
|
815
|
+
{ key: "Fields", value: "packages" },
|
|
816
|
+
{ key: "Fields", value: "created" },
|
|
817
|
+
{ key: "Fields", value: "revision" }
|
|
803
818
|
];
|
|
804
819
|
return await this.request({
|
|
805
820
|
path: id,
|
|
@@ -828,10 +843,10 @@ var InformationUnitsService = class extends BaseService {
|
|
|
828
843
|
};
|
|
829
844
|
|
|
830
845
|
// src/language.ts
|
|
831
|
-
var
|
|
846
|
+
var import_next_cookies4 = require("@c-rex/utils/next-cookies");
|
|
832
847
|
var LanguageService = class extends BaseService {
|
|
833
848
|
constructor() {
|
|
834
|
-
const configs = (0,
|
|
849
|
+
const configs = (0, import_next_cookies4.getConfigs)();
|
|
835
850
|
super(configs.languageSwitcher.endpoint);
|
|
836
851
|
}
|
|
837
852
|
/**
|
|
@@ -866,12 +881,139 @@ var LanguageService = class extends BaseService {
|
|
|
866
881
|
});
|
|
867
882
|
}
|
|
868
883
|
};
|
|
884
|
+
|
|
885
|
+
// src/transforms/topics.ts
|
|
886
|
+
var import_next_cookies5 = require("@c-rex/utils/next-cookies");
|
|
887
|
+
var import_headers4 = require("next/headers");
|
|
888
|
+
var import_logger3 = require("@c-rex/core/logger");
|
|
889
|
+
var transformTopics = async (data) => {
|
|
890
|
+
const logger = new import_logger3.CrexLogger();
|
|
891
|
+
const config = (0, import_next_cookies5.getConfigs)();
|
|
892
|
+
const contentLang = ((0, import_headers4.cookies)().get(CONTENT_LANG_KEY)?.value || config.languageSwitcher.default).toLowerCase();
|
|
893
|
+
const items = data.items.map((item) => {
|
|
894
|
+
const type = item.class.labels.filter((item2) => item2.language === EN_LANG)[0].value.toUpperCase();
|
|
895
|
+
let link = `/topics/${item.shortId}`;
|
|
896
|
+
if (config.results.articlePageLayout == "BLOG") {
|
|
897
|
+
link = `/blog/${item.shortId}`;
|
|
898
|
+
} else if (type == RESULT_TYPES.DOCUMENT) {
|
|
899
|
+
link = `/documents/${item.shortId}`;
|
|
900
|
+
}
|
|
901
|
+
let title = "NO TITLE";
|
|
902
|
+
let language = "NO LANGUAGE";
|
|
903
|
+
try {
|
|
904
|
+
if (item.titles) {
|
|
905
|
+
title = item.titles[0].value;
|
|
906
|
+
language = item.titles[0].language;
|
|
907
|
+
} else {
|
|
908
|
+
title = item.labels[0].value;
|
|
909
|
+
language = item.labels[0].language;
|
|
910
|
+
}
|
|
911
|
+
} catch {
|
|
912
|
+
logger.log({
|
|
913
|
+
level: "error",
|
|
914
|
+
message: `No label or title on item ${item.shortId}`
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
let renditionUrl = "";
|
|
918
|
+
const renditions = item.renditions.filter((item2) => item2.format == "application/xhtml+xml");
|
|
919
|
+
if (renditions.length > 0 || renditions[0] !== void 0) {
|
|
920
|
+
const filteredLinks = renditions[0].links.filter((renditionItem) => renditionItem.rel == "view");
|
|
921
|
+
if (filteredLinks.length > 0 || filteredLinks[0] !== void 0) {
|
|
922
|
+
renditionUrl = filteredLinks[0].href;
|
|
923
|
+
}
|
|
924
|
+
;
|
|
925
|
+
}
|
|
926
|
+
;
|
|
927
|
+
let categoryType = type;
|
|
928
|
+
if (item.applicableForTypes && item.applicableForTypes.length > 0) {
|
|
929
|
+
const splittedContentLang = contentLang.split("-")[0];
|
|
930
|
+
categoryType = item.applicableForTypes[0].labels.find((item2) => item2.language === splittedContentLang)?.value || categoryType;
|
|
931
|
+
}
|
|
932
|
+
return {
|
|
933
|
+
language,
|
|
934
|
+
title,
|
|
935
|
+
type: categoryType,
|
|
936
|
+
localeType: "",
|
|
937
|
+
shortId: item.shortId,
|
|
938
|
+
created: formatDateToLocale(item.created, contentLang),
|
|
939
|
+
disabled: config.results.disabledResults.includes(type),
|
|
940
|
+
link,
|
|
941
|
+
renditionUrl,
|
|
942
|
+
image: null,
|
|
943
|
+
description: null
|
|
944
|
+
};
|
|
945
|
+
});
|
|
946
|
+
return {
|
|
947
|
+
tags: null,
|
|
948
|
+
items,
|
|
949
|
+
pageInfo: data.pageInfo
|
|
950
|
+
};
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
// src/topics.ts
|
|
954
|
+
var TopicsService = class extends BaseService {
|
|
955
|
+
constructor() {
|
|
956
|
+
super("Topics/");
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Retrieves a list of topics based on specified criteria.
|
|
960
|
+
*
|
|
961
|
+
* @param options - Options for filtering and paginating the topics list
|
|
962
|
+
* @param options.queries - Optional search query string
|
|
963
|
+
* @param options.page - Optional page number for pagination (defaults to 1)
|
|
964
|
+
* @param options.fields - Optional array of fields to include in the response
|
|
965
|
+
* @param options.filters - Optional array of filter strings to apply
|
|
966
|
+
* @param options.languages - Optional array of language codes to filter by
|
|
967
|
+
* @returns A promise that resolves to the information units response
|
|
968
|
+
* @throws Error if the API request fails
|
|
969
|
+
*/
|
|
970
|
+
async getList({
|
|
971
|
+
queries = "",
|
|
972
|
+
page = 1,
|
|
973
|
+
fields = [],
|
|
974
|
+
filters = [],
|
|
975
|
+
languages = [],
|
|
976
|
+
wildcard = WILD_CARD_OPTIONS.BOTH,
|
|
977
|
+
operator = OPERATOR_OPTIONS.AND,
|
|
978
|
+
pageSize = 12
|
|
979
|
+
}) {
|
|
980
|
+
const remainFields = createParams(fields, "Fields");
|
|
981
|
+
const remainFilters = createParams(filters, "Filter");
|
|
982
|
+
const languageParam = `VALUES ?lang { ${languages.map((lang) => `"${lang}"`).join(" ")} } ?s iirds:language ?lang .`;
|
|
983
|
+
const params = [
|
|
984
|
+
{ key: "pageSize", value: pageSize.toString() },
|
|
985
|
+
{ key: "PageNumber", value: page.toString() },
|
|
986
|
+
{ key: "Sort", value: "-created;-score" },
|
|
987
|
+
...remainFields,
|
|
988
|
+
...remainFilters
|
|
989
|
+
];
|
|
990
|
+
if (wildcard.length > 0) {
|
|
991
|
+
params.push({ key: "Operator", value: operator });
|
|
992
|
+
}
|
|
993
|
+
if (wildcard.length > 0) {
|
|
994
|
+
params.push({ key: "wildcard", value: wildcard.toLowerCase() });
|
|
995
|
+
}
|
|
996
|
+
if (languages.length > 0) {
|
|
997
|
+
params.push({ key: "sparqlWhere", value: languageParam });
|
|
998
|
+
}
|
|
999
|
+
if (queries.length > 0) {
|
|
1000
|
+
params.push(
|
|
1001
|
+
{ key: "Query", value: queries }
|
|
1002
|
+
);
|
|
1003
|
+
}
|
|
1004
|
+
return await this.request({
|
|
1005
|
+
params,
|
|
1006
|
+
transformer: transformTopics
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
869
1010
|
// Annotate the CommonJS export names for ESM import in node:
|
|
870
1011
|
0 && (module.exports = {
|
|
871
1012
|
DirectoryNodesService,
|
|
872
1013
|
DocumentTypesService,
|
|
873
1014
|
InformationUnitsService,
|
|
874
1015
|
LanguageService,
|
|
875
|
-
RenditionsService
|
|
1016
|
+
RenditionsService,
|
|
1017
|
+
TopicsService
|
|
876
1018
|
});
|
|
877
1019
|
//# sourceMappingURL=index.js.map
|
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\";\nexport const FRAGMENT = \"FRAGMENT\";\n\nexport const RESULT_TYPES = {\n TOPIC: TOPIC,\n DOCUMENT: DOCUMENT,\n PACKAGE: PACKAGE,\n FRAGMENT: FRAGMENT\n} as const;\n\nexport const FILES_EXTENSIONS = {\n PDF: \"application/pdf\",\n HTML: \"text/html\",\n} as const;\n\nexport const DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";\n\nexport const CREX_TOKEN_HEADER_KEY = \"crex-token\";\n\nexport const WILD_CARD_OPTIONS = {\n BOTH: \"BOTH\",\n END: \"END\",\n START: \"START\",\n NONE: \"NONE\",\n} as const;\n\nexport const OPERATOR_OPTIONS = {\n AND: \"AND\",\n OR: \"OR\",\n} as const;\n\n","import winston from \"winston\";\nimport { MatomoTransport } from \"./transports/matomo\";\nimport { GraylogTransport } from \"./transports/graylog\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { LOG_LEVELS } from \"@c-rex/constants\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\n/**\n * Logger class for the CREX application.\n * Provides logging functionality with multiple transports (Console, Matomo, Graylog).\n */\nexport class CrexLogger {\n private customerConfig!: ConfigInterface;\n public logger!: winston.Logger;\n\n /**\n * Initializes the logger instance if it hasn't been initialized yet.\n * Loads customer configuration and creates the logger with appropriate transports.\n * \n * @private\n */\n private async initLogger() {\n try {\n if (!this.customerConfig) {\n this.customerConfig = await getConfigs();\n }\n if (!this.logger) {\n this.logger = this.createLogger();\n }\n } catch (error) {\n console.error(\"Error initializing logger:\", error);\n }\n }\n\n /**\n * Logs a message with the specified level and optional category.\n * \n * @param options - Logging options\n * @param options.level - The log level (error, warn, info, etc.)\n * @param options.message - The message to log\n * @param options.category - Optional category for the log message\n */\n public async log({ level, message, category }: {\n level: LogLevelType,\n message: string,\n category?: LogCategoriesType\n }) {\n await this.initLogger();\n this.logger.log(level, message, category);\n }\n\n /**\n * Creates a new Winston logger instance with configured transports.\n * \n * @private\n * @returns A configured Winston logger instance\n */\n private createLogger() {\n return winston.createLogger({\n levels: LOG_LEVELS,\n transports: [\n new winston.transports.Console({\n level: this.customerConfig.logs.console.minimumLevel,\n silent: this.customerConfig.logs.console.silent,\n }),\n new MatomoTransport(this.customerConfig),\n new GraylogTransport(this.customerConfig),\n ],\n });\n }\n}","import Transport from \"winston-transport\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\n/**\n * Winston transport for sending logs to Matomo analytics.\n * Extends the base Winston transport with Matomo-specific functionality.\n */\nexport class MatomoTransport extends Transport {\n public matomoTransport: any;\n private configs: ConfigInterface;\n\n /**\n * Creates a new instance of MatomoTransport.\n * \n * @param configs - The application configuration containing logging settings\n */\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.matomo.minimumLevel,\n silent: configs.logs.matomo.silent,\n });\n\n this.matomoTransport = new Transport();\n this.configs = configs;\n }\n\n /**\n * Logs a message to Matomo if the message category is included in the configured categories.\n * \n * @param info - The log information including level, message, and category\n * @param callback - Callback function to execute after logging\n */\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const matomoCategory = this.configs.logs.matomo.categoriesLevel\n\n if (matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {\n this.matomoTransport.log(info, callback);\n }\n }\n}\n","import Transport from \"winston-transport\";\nimport Graylog2Transport from \"winston-graylog2\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\n/**\n * Winston transport for sending logs to Graylog.\n * Extends the base Winston transport with Graylog-specific functionality.\n */\nexport class GraylogTransport extends Transport {\n public graylogTransport: any;\n private configs: ConfigInterface\n\n /**\n * Creates a new instance of GraylogTransport.\n * \n * @param configs - The application configuration containing logging settings\n */\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.graylog.minimumLevel,\n silent: configs.logs.graylog.silent,\n });\n\n this.configs = configs;\n this.graylogTransport = new Graylog2Transport({\n name: \"crex.net.documentation\",\n //name: \"crex.net.blog\",\n silent: false,\n handleExceptions: false,\n graylog: {\n servers: [\n { host: \"localhost\", port: 12201 },\n { host: \"https://log.c-rex.net\", port: 12202 }\n\n //TODO: check the URL => https://log.c-rex.net:12202/gelf\" GELF??\n ],\n },\n });\n }\n\n /**\n * Logs a message to Graylog if the message category is included in the configured categories.\n * \n * @param info - The log information including level, message, and category\n * @param callback - Callback function to execute after logging\n */\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const graylogCategory = this.configs.logs.graylog.categoriesLevel\n\n if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {\n this.graylogTransport.log(info, callback);\n }\n }\n}\n","import { FLAGS_BY_LANG } from \"@c-rex/constants\";\n\nexport const _generateShaKey = async (input: string): Promise<string> => {\n const encoder = new TextEncoder();\n const data = encoder.encode(input);\n const hashBuffer = await crypto.subtle.digest('SHA-1', data);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const base64url = btoa(String.fromCharCode(...hashArray))\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '');\n\n return base64url.slice(0, 12);\n}\n\n/**\n * Retrieves the country code associated with a given language code.\n * @param lang - The language code to look up (e.g., \"en-US\")\n * @returns The corresponding country code, or the original language code if not found\n */\nexport const getCountryCodeByLang = (lang: string): string => {\n const mappedKeys = Object.keys(FLAGS_BY_LANG);\n\n if (!mappedKeys.includes(lang)) {\n return lang\n }\n\n type LangKey = keyof typeof FLAGS_BY_LANG;\n const country = FLAGS_BY_LANG[lang as LangKey]\n\n return country\n}\n\nexport const getFromCookieString = (cookieString: string, key: string): string => {\n const cookies = cookieString.split(';')\n\n for (const cookie of cookies) {\n const [cookieKey, cookieValue] = cookie.trim().split('=')\n\n if (cookieKey === key) {\n return cookieValue as string;\n }\n }\n\n return ''\n}\n","import { _generateShaKey } from \"./utils\"\n\n/**\n * Makes an asynchronous RPC API call to the server.\n * @param method - The RPC method name to call\n * @param params - Optional parameters to pass to the method\n * @returns A Promise resolving to the response data of type T\n */\nexport const call = async<T = unknown>(method: string, params?: any): Promise<T> => {\n type result = {\n data: string,\n expireDate: Date,\n }\n\n const shaKey = await _generateShaKey(JSON.stringify({ method, params }))\n const cache = localStorage.getItem(shaKey)\n\n if (cache !== null) {\n const { data, expireDate } = JSON.parse(cache) as result\n\n if (new Date(expireDate) > new Date()) {\n return JSON.parse(data) as T\n } else {\n localStorage.removeItem(shaKey)\n }\n }\n\n const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/rpc`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ method, params }),\n credentials: 'include',\n });\n\n const json = await res.json();\n\n if (!res.ok) throw new Error(json.error || 'Unknown error');\n\n const today = new Date()\n const result: result = {\n data: JSON.stringify(json.data),\n expireDate: new Date(today.getTime() + 1000 * 60 * 60),\n }\n\n localStorage.setItem(shaKey, JSON.stringify(result))\n\n return json.data;\n}","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merges multiple class values into a single string using clsx and tailwind-merge.\n * Useful for conditionally applying Tailwind CSS classes.\n * @param inputs - Any number of class values (strings, objects, arrays, etc.)\n * @returns A merged string of class names optimized for Tailwind CSS\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import { QueryParams } from '@c-rex/types';\n\n/**\n * Creates an array of parameter objects from a list of field values.\n * @param fieldsList - Array of field values to transform into parameter objects\n * @param key - The key to use for each parameter object (defaults to \"Fields\")\n * @returns An array of objects with key-value pairs\n */\nexport const createParams = (fieldsList: string[], key: string = \"Fields\") =>\n fieldsList.map((item) => ({\n key: key,\n value: item,\n }));\n\n/**\n * Generates a URL query string from an array of parameter objects.\n * @param params - Array of QueryParams objects containing key-value pairs\n * @returns A URL-encoded query string\n */\nexport const generateQueryParams = (params: QueryParams[]): string => {\n const queryParams = params\n .map(\n (param) =>\n `${encodeURIComponent(param.key)}=${encodeURIComponent(param.value)}`,\n )\n .join(\"&\");\n return queryParams;\n};\n","import { FileRenditionType } from \"@c-rex/types\";\nimport { informationUnitsRenditions } from \"@c-rex/interfaces\";\n\ntype RenditionType = {\n filesToDownload: FileRenditionType[],\n filesToOpen: FileRenditionType[]\n}\nexport const getFileRenditions = ({ renditions }: { renditions: informationUnitsRenditions[] }): RenditionType => {\n if (renditions == undefined || renditions.length == 0) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filteredRenditions = renditions.filter(\n (item) => item.format != \"application/xhtml+xml\" && item.format != \"application/json\" && item.format != \"application/llm+xml\"\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filesToDownload = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"download\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n });\n\n const filesToOpen = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n })\n\n return {\n filesToDownload: filesToDownload,\n filesToOpen: filesToOpen,\n }\n}","import { CrexApi } from \"@c-rex/core\";\nimport { QueryParams } from \"@c-rex/types\";\nimport { call, generateQueryParams } from \"@c-rex/utils\";\nimport { Method } from \"axios\";\n\n/**\n * Base service class that provides common functionality for API interactions.\n * All specific service classes extend this base class.\n */\nexport class BaseService {\n protected api: CrexApi;\n private endpoint: string;\n\n /**\n * Creates a new instance of BaseService.\n * \n * @param endpoint - The API endpoint URL for this service\n */\n constructor(endpoint: string) {\n this.api = new CrexApi();\n this.endpoint = endpoint;\n }\n\n /**\n * Makes an API request to the specified endpoint.\n * \n * @param options - Request configuration options\n * @param options.path - Optional path to append to the endpoint\n * @param options.params - Optional query parameters to include in the request\n * @param options.method - HTTP method to use (defaults to 'get')\n * @param options.transformer - Optional function to transform the response data\n * @returns The response data, optionally transformed\n * @throws Error if the API request fails\n */\n protected async request<T>({\n path = \"\",\n method = \"get\",\n params = [],\n headers = {},\n transformer = (response: any) => response,\n }: {\n path?: string,\n method?: Method,\n params?: QueryParams[],\n headers?: any,\n transformer?: (data: any) => T,\n }): Promise<T> {\n try {\n let url = `${this.endpoint}${path}`;\n\n const queryParams = generateQueryParams(params);\n if (queryParams.length > 0) {\n url += `?${queryParams}`;\n }\n\n const response = await this.api.execute({\n url,\n method,\n headers,\n })\n\n return await transformer(response);\n\n } catch (error) {\n call(\"CrexLogger.log\", {\n level: \"error\",\n message: `BaseService.request error when request ${path}. Error: ${error}`\n });\n\n throw error;\n }\n }\n}\n\n","import { BaseService } from \"./baseService\";\nimport { informationUnitsRenditions } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with renditions in the API.\n * Provides methods to retrieve and process different types of renditions.\n */\nexport class RenditionsService extends BaseService {\n constructor() {\n super(\"Renditions/\");\n }\n\n /**\n * Retrieves the HTML rendition from a list of renditions.\n * Filters for renditions with format 'application/xhtml+xml' and rel 'view'.\n * \n * @param renditions - Array of rendition objects to process\n * @returns A promise that resolves to the HTML content as a string, or empty string if no suitable rendition is found\n * @throws Error if the API request fails\n */\n public async getHTMLRendition({ renditions }: { renditions: informationUnitsRenditions[] }): Promise<string> {\n const filteredRenditions = renditions.filter(\n (item) => item.format == \"application/xhtml+xml\",\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) return \"\";\n const item = filteredRenditions[0];\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n\n if (filteredLinks.length == 0 || filteredLinks[0] == undefined) return \"\";\n const url = filteredLinks[0].href;\n const response = await this.api.execute({\n url,\n method: \"get\",\n headers: {\n Accept: \"application/xhtml+xml\",\n },\n })\n\n return response as string;\n }\n}","import { BaseService } from \"./baseService\";\nimport { createParams } from \"@c-rex/utils\";\nimport { DirectoryNodes, DirectoryNodesResponse } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with directory nodes in the API.\n * Provides methods to retrieve directory node information.\n */\nexport class DirectoryNodesService extends BaseService {\n constructor() {\n super(\"DirectoryNodes/\");\n }\n\n /**\n * Retrieves a specific directory node by its ID.\n * \n * @param id - The unique identifier of the directory node\n * @returns A promise that resolves to the directory node data\n * @throws Error if the API request fails\n */\n public async getItem(id: string): Promise<DirectoryNodes> {\n return await this.request({\n path: id,\n });\n }\n\n /**\n * Retrieves a list of directory nodes based on specified filters.\n * \n * @param options - Options for filtering the directory nodes list\n * @param options.filters - Optional array of filter strings to apply\n * @returns A promise that resolves to the directory nodes response\n * @throws Error if the API request fails\n */\n public async getList({\n filters = [],\n }: {\n filters?: string[],\n }): Promise<DirectoryNodesResponse> {\n\n const remainFilters = createParams(filters, \"Filter\");\n\n return await this.request({\n params: {\n ...remainFilters,\n },\n });\n }\n}\n","import { DefaultRequest } from \"@c-rex/interfaces\";\nimport { DocumentTypesItem } from \"@c-rex/interfaces\";\n\nexport const transformDocumentTypes = (data: DefaultRequest<DocumentTypesItem>) => {\n const labels: string[] = [];\n\n data.items.forEach((documentItem: DocumentTypesItem) => {\n const aux = documentItem.labels.flatMap((item) => item);\n\n aux.forEach((item) => {\n if (item.language == \"en\") labels.push(item.value);\n });\n });\n\n return labels;\n};\n","import { createParams } from \"@c-rex/utils\";\nimport { transformDocumentTypes } from \"./transforms/documentTypes\";\nimport { BaseService } from \"./baseService\";\n\n/**\n * Service for interacting with document types in the API.\n * Provides methods to retrieve document type information.\n */\nexport class DocumentTypesService extends BaseService {\n constructor() {\n super(\"DocumentTypes/\");\n }\n\n /**\n * Retrieves document type labels for the specified fields.\n * The labels are restricted to English language (EN-us).\n * \n * @param fields - Array of field names to retrieve labels for\n * @returns A promise that resolves to an array of label strings\n * @throws Error if the API request fails\n */\n public async getLabels(fields: string[]): Promise<string[]> {\n const params = [\n {\n key: \"Restrict\",\n value: `languages~EN-us`,\n },\n ...createParams(fields, \"Fields\"),\n ];\n\n return await this.request({\n params,\n transformer: transformDocumentTypes,\n });\n }\n}\n","import { CONTENT_LANG_KEY, EN_LANG, RESULT_TYPES } from \"@c-rex/constants\";\nimport {\n DefaultRequest,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { cookies } from 'next/headers';\nimport { getFileRenditions } from \"@c-rex/utils\";\nimport { CrexLogger } from '@c-rex/core/logger';\nimport { AutocompleteSuggestion } from \"@c-rex/interfaces\";\n\nexport const transformInformationUnits = async (\n data: DefaultRequest<informationUnitsItems>,\n): Promise<informationUnitsResponse> => {\n const logger = new CrexLogger()\n const config = await getConfigs();\n const filteredTags: any = {}\n\n\n const items = data.items.map((item) => {\n const type = item.class.labels.filter((item) => item.language === EN_LANG)[0].value.toUpperCase();\n const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });\n\n let link = `/topics/${item.shortId}`;\n\n if (config.results.articlePageLayout == \"BLOG\") {\n link = `/blog/${item.shortId}`\n } else if (type == RESULT_TYPES.DOCUMENT) {\n link = `/documents/${item.shortId}`;\n }\n\n let title = \"NO TITLE\"\n let language = \"NO LANGUAGE\"\n\n try {\n if (item.titles) {\n title = item.titles[0].value\n language = item.titles[0].language\n } else {\n title = item.labels[0].value\n language = item.labels[0].language\n }\n } catch {\n logger.log({\n level: \"error\",\n message: `No label or title on item ${item.shortId}`\n })\n }\n\n return {\n language: language,\n title: title,\n type: type,\n localeType: \"\",\n shortId: item.shortId,\n disabled: config.results.disabledResults.includes(type as any),\n link: link,\n filesToOpen,\n filesToDownload\n }\n });\n\n if (data.tags) {\n const contentLang = (cookies().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase()\n const splittedContentLang = contentLang.split(\"-\")[0];\n\n for (const [key, value] of Object.entries(data.tags)) {\n\n if (!value || !value.items || value.items.length === 0) {\n continue;\n }\n if (!config.search.tags.includes(key)) {\n continue;\n }\n\n const aux = value.items.map(item => {\n if (item?.shortId === undefined) return null\n if (Number(item.hits) === 0) return null\n if (item?.labels === undefined || item?.labels.length === 0) {\n logger.log({\n level: \"warning\",\n message: `No labels on item with id ${item.shortId} from category ${key}`\n })\n return null;\n }\n\n let label = \"\"\n\n for (const labelItem of item.labels) {\n if (labelItem.language === undefined) {\n logger.log({\n level: \"warning\",\n message: `No language on label ${labelItem.value} from category ${key}`\n })\n label = labelItem.value\n break;\n }\n\n if (labelItem.language.toLowerCase() === contentLang || labelItem.language.toLowerCase() === splittedContentLang) {\n label = labelItem.value\n break;\n }\n\n label = labelItem.value\n }\n\n return {\n hits: item.hits,\n total: item.total,\n label: label,\n active: false,\n shortId: item.shortId,\n }\n }).filter((item) => item !== null)\n\n if (aux.length === 0) {\n continue;\n }\n\n filteredTags[key] = aux;\n }\n }\n\n return {\n tags: filteredTags,\n items: items,\n pageInfo: data.pageInfo,\n };\n};\n\nexport const transformSuggestions = (data: AutocompleteSuggestion, query: string) => {\n const suggestions: string[] = []\n const comparableList: string[] = []\n\n data.suggestions.forEach((item) => {\n suggestions.push(item.value);\n comparableList.push(item.value.toLowerCase())\n })\n\n if (!comparableList.includes(query.toLowerCase())) {\n return [query, ...suggestions];\n }\n\n return suggestions\n}","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits, transformSuggestions } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\nimport { WildCardType } from \"@c-rex/types\";\nimport { OPERATOR_OPTIONS, WILD_CARD_OPTIONS } from \"@c-rex/constants\";\n\n/**\n * Service for interacting with information units in the API.\n * Provides methods to retrieve and search information units.\n */\nexport class InformationUnitsService extends BaseService {\n constructor() {\n super(\"InformationUnits/\");\n }\n\n /**\n * Retrieves a list of information units based on specified criteria.\n * \n * @param options - Options for filtering and paginating the information units list\n * @param options.queries - Optional search query string\n * @param options.page - Optional page number for pagination (defaults to 1)\n * @param options.fields - Optional array of fields to include in the response\n * @param options.filters - Optional array of filter strings to apply\n * @param options.languages - Optional array of language codes to filter by\n * @returns A promise that resolves to the information units response\n * @throws Error if the API request fails\n */\n public async getList({\n queries = \"\",\n page = 1,\n fields = [],\n filters = [],\n restrict = [],\n languages = [],\n wildcard = WILD_CARD_OPTIONS.BOTH,\n operator = OPERATOR_OPTIONS.AND,\n like = false,\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n restrict?: string[],\n fields?: string[],\n languages?: string[],\n wildcard?: WildCardType,\n operator?: string,\n like?: boolean,\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const restrictions = createParams(restrict, \"Restrict\");\n const languageParam = `VALUES ?lang { ${languages.map(lang => `\"${lang}\"`).join(\" \")} } ?s iirds:language ?lang .`\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"wildcard\", value: wildcard.toLowerCase() },\n { key: \"PageNumber\", value: page.toString() },\n { key: \"Operator\", value: operator },\n { key: \"tags\", value: \"true\" },\n { key: \"Like\", value: like.toString() },\n ...remainFields,\n ...remainFilters,\n ...restrictions\n ];\n if (languages.length > 0) {\n params.push({ key: \"sparqlWhere\", value: languageParam });\n }\n if (queries.length > 0) {\n params.push(\n { key: \"Query\", value: queries },\n );\n }\n\n return await this.request({\n params: params,\n transformer: transformInformationUnits\n });\n }\n\n /**\n * Retrieves a specific information unit by its ID.\n * Includes renditions, directory nodes, version information, titles, languages, and labels.\n * \n * @param options - Options for retrieving the information unit\n * @param options.id - The unique identifier of the information unit\n * @returns A promise that resolves to the information unit data\n * @throws Error if the API request fails\n */\n public async getItem({ id }: { id: string }): Promise<informationUnitsItems> {\n const params = [\n { key: \"Fields\", value: \"renditions\" },\n { key: \"Fields\", value: \"directoryNodes\" },\n { key: \"Fields\", value: \"versionOf\" },\n { key: \"Fields\", value: \"titles\" },\n { key: \"Fields\", value: \"languages\" },\n { key: \"Fields\", value: \"labels\" },\n { key: \"Fields\", value: \"packages\" },\n ];\n\n return await this.request({\n path: id,\n params,\n });\n }\n\n /**\n * Retrieves autocomplete suggestions based on a query prefix.\n * \n * @param options - Options for retrieving suggestions\n * @param options.query - The query prefix to get suggestions for\n * @param options.language - The language of the suggestions\n * @returns A promise that resolves to an array of suggestion strings\n * @throws Error if the API request fails\n */\n public async getSuggestions(\n { query, language }: { query: string, language: string }\n ): Promise<string[]> {\n\n return await this.request({\n path: 'Suggestions',\n params: [\n { key: \"prefix\", value: query },\n { key: \"lang\", value: language },\n ],\n transformer: (data: AutocompleteSuggestion) => transformSuggestions(data, query)\n });\n }\n}\n","import { LanguageAndCountries } from \"@c-rex/interfaces\";\nimport { BaseService } from \"./baseService\";\nimport { getCountryCodeByLang } from \"@c-rex/utils\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\n/**\n * Service for interacting with language-related functionality in the API.\n * Provides methods to retrieve language and country information.\n */\nexport class LanguageService extends BaseService {\n constructor() {\n const configs = getConfigs()\n super(configs.languageSwitcher.endpoint);\n }\n\n /**\n * Retrieves a list of available languages and their associated countries.\n * Transforms the API response to include language code, country code, and original value.\n * \n * @returns A promise that resolves to an array of language and country objects\n * @throws Error if the API request fails\n */\n public async getLanguagesAndCountries(): Promise<LanguageAndCountries[]> {\n return await this.request({\n transformer: (data: { value: string; score: number }[]) => {\n const countryCodeList = data.map((item) => {\n /*\n api -> en, en-US\n default -> en-US. Then use EN-US \n\n api -> en\n default -> en-US. Then use EN\n */\n //should be abble to handle this items: en-US, en, pt, pt-PT, pt-BR \n\n const splittedValue = item.value.split(\"-\")\n const lang = splittedValue[0]\n let country = splittedValue[0]\n\n if (splittedValue.length > 1) {\n country = splittedValue[1]\n } else {\n country = getCountryCodeByLang(lang)\n }\n\n return {\n country: country,\n lang: lang,\n value: item.value,\n }\n })\n\n return countryCodeList.sort((a, b) => {\n return a.value.localeCompare(b.value)\n })\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA4D;;;ACArD,IAAM,MAAM;AAeZ,IAAM,aAAa;AAAA,EACtB,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACX;AAOO,IAAM,MAAM;AAAA,EACf,WAAW;AAAA,EACX,aAAa;AAAA,EACb,aAAa;AAAA,IACT,gBAAgB;AAAA,EACpB;AACJ;AAEO,IAAM,iBAAiB;AAEvB,IAAM,mBAAmB;AAMzB,IAAM,gBAAgB;AAAA,EACzB,MAAM;AAAA,EACN,MAAM;AACV;AAIO,IAAM,UAAU;AAQhB,IAAM,QAAQ;AACd,IAAM,WAAW;AACjB,IAAM,UAAU;AAChB,IAAM,WAAW;AAEjB,IAAM,eAAe;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAOO,IAAM,u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BAAU,cAAc,CAAC;AAAA,UAC7B,OAAO;AACH,sBAAU,qBAAqB,IAAI;AAAA,UACvC;AAEA,iBAAO;AAAA,YACH;AAAA,YACA;AAAA,YACA,OAAO,KAAK;AAAA,UAChB;AAAA,QACJ,CAAC;AAED,eAAO,gBAAgB,KAAK,CAAC,GAAG,MAAM;AAClC,iBAAO,EAAE,MAAM,cAAc,EAAE,KAAK;AAAA,QACxC,CAAC;AAAA,MACL;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;","names":["Transport","import_winston_transport","Transport","Graylog2Transport","winston","axios","item","item","import_next_cookies","import_headers","import_logger","item","import_next_cookies"]}
|
|
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","../src/transforms/topics.ts","../src/topics.ts"],"sourcesContent":["export * from \"./renditions\"\nexport * from \"./directoryNodes\"\nexport * from \"./documentTypes\"\nexport * from \"./informationUnits\"\nexport * from \"./language\"\nexport * from \"./topics\"","import axios, { AxiosResponse, Method, AxiosInstance } from \"axios\";\nimport { API, CREX_TOKEN_HEADER_KEY, SDK_CONFIG_KEY } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { cookies } from \"next/headers\";\nimport { CrexLogger } from \"./logger\";\n\n/**\n * Interface for API response with generic data type.\n */\ninterface APIGenericResponse<T> extends AxiosResponse {\n data: T;\n statusCode: number;\n}\n\n/**\n * Interface for API call parameters.\n */\ninterface CallParams {\n url: string;\n method: Method;\n body?: any;\n headers?: any;\n params?: any;\n}\n\n/**\n * API client class for the CREX application.\n * Handles API requests with caching, authentication, and retry logic.\n */\nexport class CrexApi {\n private customerConfig!: ConfigInterface;\n private apiClient!: AxiosInstance;\n private logger!: CrexLogger;\n\n /**\n * Initializes the API client if it hasn't been initialized yet.\n * Loads customer configuration, creates the axios instance, and initializes the logger.\n * \n * @private\n */\n private async initAPI() {\n this.logger = new CrexLogger();\n\n if (!this.customerConfig) {\n const aux = cookies().get(SDK_CONFIG_KEY);\n if (aux != undefined) {\n this.customerConfig = JSON.parse(aux.value);\n } else {\n this.logger.log({\n level: \"error\",\n message: `utils.initAPI error: Config cookie not available`\n });\n\n throw new Error(\"Config cookie not available\");\n }\n }\n\n if (!this.apiClient) {\n this.apiClient = axios.create({\n baseURL: this.customerConfig.baseUrl,\n })\n }\n }\n\n private async getToken() {\n try {\n const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/token`, {\n method: 'POST',\n credentials: 'include',\n });\n\n const { token } = await response.json();\n\n return token;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `utils.getToken error: ${error}`\n });\n\n throw error\n }\n }\n\n private async manageToken() {\n try {\n let token = \"\";\n const hasToken = cookies().get(CREX_TOKEN_HEADER_KEY);\n\n if (hasToken == undefined || hasToken.value === null) {\n const tokenResult = await this.getToken();\n\n if (tokenResult === null) throw new Error(\"Token is undefined\");\n\n token = tokenResult;\n } else {\n token = hasToken.value;\n }\n\n return token;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `utils.manageToken error: ${error}`\n });\n\n throw error\n }\n }\n\n /**\n * Executes an API request with caching, authentication, and retry logic.\n * \n * @param options - Request options\n * @param options.url - The URL to request\n * @param options.method - The HTTP method to use\n * @param options.params - Optional query parameters\n * @param options.body - Optional request body\n * @param options.headers - Optional request headers\n * @returns The response data\n * @throws Error if the request fails after maximum retries\n */\n async execute<T>({\n url,\n method,\n params,\n body,\n headers = {},\n }: CallParams): Promise<T> {\n await this.initAPI();\n\n let response: APIGenericResponse<T> | undefined = undefined;\n\n if (this.customerConfig.OIDC.client.enabled) {\n const token = await this.manageToken();\n\n headers = {\n ...headers,\n Authorization: `Bearer ${token}`,\n };\n\n this.apiClient.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n }\n\n for (let retry = 0; retry < API.MAX_RETRY; retry++) {\n try {\n response = await this.apiClient.request({\n url,\n method,\n data: body,\n params,\n headers,\n });\n\n break;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `API.execute ${retry + 1}º error when request ${url}. Error: ${error}`\n });\n\n if (retry === API.MAX_RETRY - 1) {\n throw error;\n }\n }\n }\n\n if (response) {\n return response.data;\n }\n\n throw new Error(\"API.execute error: Failed to retrieve a valid response\");\n }\n}","export const ALL = \"*\"\n\nexport const LOG_CATEGORIES = [\n \"NoLicense\",\n \"Scenario\",\n \"Favorites\",\n \"Subscription\",\n \"Share\",\n \"Document\",\n \"Search\",\n \"History\",\n \"Notification\",\n \"UserProfile\",\n] as const;\n\nexport const LOG_LEVELS = {\n critical: 2,\n error: 3,\n warning: 4,\n info: 6,\n debug: 7,\n} as const;\n\nexport const RESULT_VIEW_STYLES = [\n \"cards\",\n \"table\",\n] as const;\n\nexport const API = {\n MAX_RETRY: 3,\n API_TIMEOUT: 10000,\n API_HEADERS: {\n \"content-Type\": \"application/json\",\n },\n};\n\nexport const SDK_CONFIG_KEY = \"crex-sdk-config\";\n\nexport const CONTENT_LANG_KEY = \"CONTENT_LANG_KEY\";\n\nexport const AVAILABLE_CONTENT_LANG_KEY = \"AVAILABLE_CONTENT_LANG_KEY\";\n\nexport const UI_LANG_KEY = \"UI_LANG_KEY\";\n\nexport const FLAGS_BY_LANG = {\n \"en\": \"US\",\n \"de\": \"DE\",\n};\n\nexport const DEFAULT_LANG = \"en-US\";\n\nexport const EN_LANG = \"en\";\n\nexport const UI_LANG_OPTIONS = [\"en-us\", \"de-de\"];\n\nexport const TOPICS_TYPE_AND_LINK = \"topics\";\nexport const BLOG_TYPE_AND_LINK = \"blog\";\nexport const DOCUMENTS_TYPE_AND_LINK = \"documents\";\n\nexport const TOPIC = \"TOPIC\";\nexport const DOCUMENT = \"DOCUMENT\";\nexport const PACKAGE = \"PACKAGE\";\nexport const FRAGMENT = \"FRAGMENT\";\n\nexport const RESULT_TYPES = {\n TOPIC: TOPIC,\n DOCUMENT: DOCUMENT,\n PACKAGE: PACKAGE,\n FRAGMENT: FRAGMENT\n} as const;\n\nexport const FILES_EXTENSIONS = {\n PDF: \"application/pdf\",\n HTML: \"text/html\",\n} as const;\n\nexport const DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";\n\nexport const CREX_TOKEN_HEADER_KEY = \"crex-token\";\n\nexport const WILD_CARD_OPTIONS = {\n BOTH: \"BOTH\",\n END: \"END\",\n START: \"START\",\n NONE: \"NONE\",\n} as const;\n\nexport const OPERATOR_OPTIONS = {\n AND: \"AND\",\n OR: \"OR\",\n} as const;\n\nexport const ARTICLE_PAGE_LAYOUT = {\n BLOG: \"BLOG\",\n DOCUMENT: \"DOCUMENT\",\n} as const;\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\nexport const formatDateToLocale = (date: string, locale: string): string => {\n if (typeof date !== 'string' || !date) {\n return date;\n }\n\n const dateAux = new Date(date);\n return new Intl.DateTimeFormat(locale, {\n day: '2-digit',\n month: 'long',\n year: 'numeric'\n }).format(dateAux);\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 { CONTENT_LANG_KEY } from \"@c-rex/constants\";\nimport { DefaultRequest } from \"@c-rex/interfaces\";\nimport { DocumentTypesItem } from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { cookies } from \"next/headers\";\n\nexport const transformDocumentTypes = (data: DefaultRequest<DocumentTypesItem>) => {\n const labels: { shortId: string, label: string }[] = [];\n const config = getConfigs();\n const contentLanguage = cookies().get(CONTENT_LANG_KEY)?.value || config.languageSwitcher.default;\n const language = contentLanguage.split(\"-\")[0];\n\n data.items.forEach((documentItem) => {\n const label = documentItem.labels.find((item) => item.language.toLowerCase() === language.toLowerCase());\n\n labels.push({\n shortId: documentItem.shortId,\n label: label ? label.value : \"\"\n })\n });\n\n return labels;\n};\n","import { 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 * \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(): Promise<{ shortId: string, label: string }[]> {\n return await this.request({\n params: [{\n key: \"sparqlWhere\",\n value: \"?iu iirds:is-applicable-for-document-type ?s . ?iu iirds:has-topic-type <https://www.c-rex.net/iirds/td#Blogpost>\"\n }],\n transformer: transformDocumentTypes,\n });\n }\n}\n","import { CONTENT_LANG_KEY, EN_LANG, RESULT_TYPES } from \"@c-rex/constants\";\nimport {\n DefaultRequest,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { cookies } from 'next/headers';\nimport { getFileRenditions } from \"@c-rex/utils\";\nimport { CrexLogger } from '@c-rex/core/logger';\nimport { AutocompleteSuggestion } from \"@c-rex/interfaces\";\n\nexport const transformInformationUnits = async (data: DefaultRequest<informationUnitsItems>): Promise<informationUnitsResponse> => {\n const logger = new CrexLogger()\n const config = await getConfigs();\n const filteredTags: any = {}\n\n const items = data.items.map((item) => {\n const type = item.class.labels.filter((item) => item.language === EN_LANG)[0].value.toUpperCase();\n const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });\n\n let link = `/topics/${item.shortId}`;\n\n if (config.results.articlePageLayout == \"BLOG\") {\n link = `/blog/${item.shortId}`\n } else if (type == RESULT_TYPES.DOCUMENT) {\n link = `/documents/${item.shortId}`;\n }\n\n let title = \"NO TITLE\"\n let language = \"NO LANGUAGE\"\n\n try {\n if (item.titles) {\n title = item.titles[0].value\n language = item.titles[0].language\n } else {\n title = item.labels[0].value\n language = item.labels[0].language\n }\n } catch {\n logger.log({\n level: \"error\",\n message: `No label or title on item ${item.shortId}`\n })\n }\n\n return {\n language: language,\n title: title,\n type: type,\n localeType: \"\",\n shortId: item.shortId,\n disabled: config.results.disabledResults.includes(type as any),\n link: link,\n filesToOpen,\n filesToDownload\n }\n });\n\n if (data.tags) {\n const contentLang = (cookies().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase()\n const splittedContentLang = contentLang.split(\"-\")[0];\n\n for (const [key, value] of Object.entries(data.tags)) {\n\n if (!value || !value.items || value.items.length === 0) {\n continue;\n }\n if (!config.search.tags.includes(key)) {\n continue;\n }\n\n const aux = value.items.map(item => {\n if (item?.shortId === undefined) return null\n if (Number(item.hits) === 0) return null\n if (item?.labels === undefined || item?.labels.length === 0) {\n logger.log({\n level: \"warning\",\n message: `No labels on item with id ${item.shortId} from category ${key}`\n })\n return null;\n }\n\n let label = \"\"\n\n for (const labelItem of item.labels) {\n if (labelItem.language === undefined) {\n logger.log({\n level: \"info\",\n message: `No language on label ${labelItem.value} from category ${key}`\n })\n label = labelItem.value\n break;\n }\n\n if (labelItem.language.toLowerCase() === contentLang || labelItem.language.toLowerCase() === splittedContentLang) {\n label = labelItem.value\n break;\n }\n\n label = labelItem.value\n\n //TODO: fallback in english\n }\n\n return {\n hits: item.hits,\n total: item.total,\n label: label,\n active: false,\n shortId: item.shortId,\n }\n }).filter((item) => item !== null)\n\n if (aux.length === 0) {\n continue;\n }\n\n filteredTags[key] = aux;\n }\n }\n\n return {\n tags: filteredTags,\n items: items,\n pageInfo: data.pageInfo,\n };\n};\n\nexport const transformSuggestions = (data: AutocompleteSuggestion, query: string) => {\n const suggestions: string[] = []\n const comparableList: string[] = []\n\n data.suggestions.forEach((item) => {\n suggestions.push(item.value);\n comparableList.push(item.value.toLowerCase())\n })\n\n if (!comparableList.includes(query.toLowerCase())) {\n return [query, ...suggestions];\n }\n\n return suggestions\n}","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits, transformSuggestions } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\nimport { WildCardType } from \"@c-rex/types\";\nimport { OPERATOR_OPTIONS, WILD_CARD_OPTIONS } from \"@c-rex/constants\";\n\n/**\n * Service for interacting with information units in the API.\n * Provides methods to retrieve and search information units.\n */\nexport class InformationUnitsService extends BaseService {\n constructor() {\n super(\"InformationUnits/\");\n }\n\n /**\n * Retrieves a list of information units based on specified criteria.\n * \n * @param options - Options for filtering and paginating the information units list\n * @param options.queries - Optional search query string\n * @param options.page - Optional page number for pagination (defaults to 1)\n * @param options.fields - Optional array of fields to include in the response\n * @param options.filters - Optional array of filter strings to apply\n * @param options.languages - Optional array of language codes to filter by\n * @returns A promise that resolves to the information units response\n * @throws Error if the API request fails\n */\n public async getList({\n queries = \"\",\n page = 1,\n fields = [],\n filters = [],\n restrict = [],\n languages = [],\n wildcard = WILD_CARD_OPTIONS.BOTH,\n operator = OPERATOR_OPTIONS.AND,\n like = false,\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n restrict?: string[],\n fields?: string[],\n languages?: string[],\n wildcard?: WildCardType,\n operator?: string,\n like?: boolean,\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const restrictions = createParams(restrict, \"Restrict\");\n const languageParam = `VALUES ?lang { ${languages.map(lang => `\"${lang}\"`).join(\" \")} } ?s iirds:language ?lang .`\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"wildcard\", value: wildcard.toLowerCase() },\n { key: \"PageNumber\", value: page.toString() },\n { key: \"Operator\", value: operator },\n { key: \"tags\", value: \"true\" }, // TODO use customer config values and add a param to each one\n { key: \"Like\", value: like.toString() },\n ...remainFields,\n ...remainFilters,\n ...restrictions\n ];\n if (languages.length > 0) {\n params.push({ key: \"sparqlWhere\", value: languageParam });\n }\n if (queries.length > 0) {\n params.push(\n { key: \"Query\", value: queries },\n );\n }\n\n return await this.request({\n params: params,\n transformer: transformInformationUnits\n });\n }\n\n /**\n * Retrieves a specific information unit by its ID.\n * Includes renditions, directory nodes, version information, titles, languages, and labels.\n * \n * @param options - Options for retrieving the information unit\n * @param options.id - The unique identifier of the information unit\n * @returns A promise that resolves to the information unit data\n * @throws Error if the API request fails\n */\n public async getItem({ id }: { id: string }): Promise<informationUnitsItems> {\n const params = [\n { key: \"Fields\", value: \"renditions\" },\n { key: \"Fields\", value: \"directoryNodes\" },\n { key: \"Fields\", value: \"versionOf\" },\n { key: \"Fields\", value: \"titles\" },\n { key: \"Fields\", value: \"languages\" },\n { key: \"Fields\", value: \"labels\" },\n { key: \"Fields\", value: \"packages\" },\n { key: \"Fields\", value: \"created\" },\n { key: \"Fields\", value: \"revision\" },\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","import { CONTENT_LANG_KEY, EN_LANG, RESULT_TYPES } from \"@c-rex/constants\";\nimport { DefaultRequest, AutocompleteSuggestion, TopicsRequestItem, DefaultResponse, TopicsResponseItem } from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { cookies } from 'next/headers';\nimport { CrexLogger } from '@c-rex/core/logger';\nimport { formatDateToLocale } from \"@c-rex/utils\";\n\nexport const transformTopics = async (data: DefaultRequest<TopicsRequestItem>): Promise<DefaultResponse<TopicsResponseItem, null>> => {\n const logger = new CrexLogger()\n const config = getConfigs();\n const contentLang = (cookies().get(CONTENT_LANG_KEY)?.value || config.languageSwitcher.default).toLowerCase()\n\n const items = data.items.map(item => {\n const type = item.class.labels.filter((item) => item.language === EN_LANG)[0].value.toUpperCase();\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 let renditionUrl = \"\"\n const renditions = item.renditions.filter(item => item.format == \"application/xhtml+xml\");\n if (renditions.length > 0 || renditions[0] !== undefined) {\n const filteredLinks = renditions[0].links.filter((renditionItem) => renditionItem.rel == \"view\");\n if (filteredLinks.length > 0 || filteredLinks[0] !== undefined) {\n renditionUrl = filteredLinks[0].href;\n };\n };\n\n let categoryType = type\n if (item.applicableForTypes && item.applicableForTypes.length > 0) {\n const splittedContentLang = contentLang.split(\"-\")[0];\n categoryType = item.applicableForTypes[0].labels.find(item => item.language === splittedContentLang)?.value || categoryType;\n }\n\n return {\n language: language,\n title: title,\n type: categoryType,\n localeType: \"\",\n shortId: item.shortId,\n created: formatDateToLocale(item.created, contentLang),\n disabled: config.results.disabledResults.includes(type as any),\n link: link,\n renditionUrl: renditionUrl,\n image: null,\n description: null,\n }\n })\n\n return {\n tags: null,\n items: items,\n pageInfo: data.pageInfo,\n };\n};\n","import { transformTopics } from \"./transforms/topics\";\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\";\nimport { DefaultResponse, TopicsResponseItem } from \"@c-rex/interfaces\";\n\ntype getListProps = {\n queries?: string,\n page?: number,\n filters?: string[],\n fields?: string[],\n languages?: string[],\n wildcard?: WildCardType,\n operator?: string,\n like?: boolean,\n pageSize?: number\n}\n\n\n/**\n * Service for interacting with information units in the API.\n * Provides methods to retrieve and search information units.\n */\nexport class TopicsService extends BaseService {\n constructor() {\n super(\"Topics/\");\n }\n\n /**\n * Retrieves a list of topics based on specified criteria.\n * \n * @param options - Options for filtering and paginating the topics 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 wildcard = WILD_CARD_OPTIONS.BOTH,\n operator = OPERATOR_OPTIONS.AND,\n pageSize = 12\n }: getListProps): Promise<DefaultResponse<TopicsResponseItem, null>> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const languageParam = `VALUES ?lang { ${languages.map(lang => `\"${lang}\"`).join(\" \")} } ?s iirds:language ?lang .`\n\n const params = [\n { key: \"pageSize\", value: pageSize.toString() },\n { key: \"PageNumber\", value: page.toString() },\n { key: \"Sort\", value: \"-created;-score\" },\n ...remainFields,\n ...remainFilters,\n ];\n\n if (wildcard.length > 0) {\n params.push({ key: \"Operator\", value: operator });\n }\n if (wildcard.length > 0) {\n params.push({ key: \"wildcard\", value: wildcard.toLowerCase() });\n }\n if (languages.length > 0) {\n params.push({ key: \"sparqlWhere\", value: languageParam });\n }\n if (queries.length > 0) {\n params.push(\n { key: \"Query\", value: queries },\n );\n }\n\n return await this.request({\n params: params,\n transformer: transformTopics\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA4D;;;ACArD,IAAM,MAAM;AAeZ,IAAM,aAAa;AAAA,EACtB,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACX;AAOO,IAAM,MAAM;AAA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,SAAS,EAAE;AAAA,MAC9C,EAAE,KAAK,cAAc,OAAO,KAAK,SAAS,EAAE;AAAA,MAC5C,EAAE,KAAK,QAAQ,OAAO,kBAAkB;AAAA,MACxC,GAAG;AAAA,MACH,GAAG;AAAA,IACP;AAEA,QAAI,SAAS,SAAS,GAAG;AACrB,aAAO,KAAK,EAAE,KAAK,YAAY,OAAO,SAAS,CAAC;AAAA,IACpD;AACA,QAAI,SAAS,SAAS,GAAG;AACrB,aAAO,KAAK,EAAE,KAAK,YAAY,OAAO,SAAS,YAAY,EAAE,CAAC;AAAA,IAClE;AACA,QAAI,UAAU,SAAS,GAAG;AACtB,aAAO,KAAK,EAAE,KAAK,eAAe,OAAO,cAAc,CAAC;AAAA,IAC5D;AACA,QAAI,QAAQ,SAAS,GAAG;AACpB,aAAO;AAAA,QACH,EAAE,KAAK,SAAS,OAAO,QAAQ;AAAA,MACnC;AAAA,IACJ;AAEA,WAAO,MAAM,KAAK,QAAQ;AAAA,MACtB;AAAA,MACA,aAAa;AAAA,IACjB,CAAC;AAAA,EACL;AACJ;","names":["Transport","import_winston_transport","Transport","Graylog2Transport","winston","axios","item","item","import_next_cookies","import_headers","import_next_cookies","import_headers","import_logger","item","import_next_cookies","import_next_cookies","import_headers","import_logger","item"]}
|
package/dist/index.mjs
CHANGED
|
@@ -326,6 +326,17 @@ var getCountryCodeByLang = (lang) => {
|
|
|
326
326
|
const country = FLAGS_BY_LANG[lang];
|
|
327
327
|
return country;
|
|
328
328
|
};
|
|
329
|
+
var formatDateToLocale = (date, locale) => {
|
|
330
|
+
if (typeof date !== "string" || !date) {
|
|
331
|
+
return date;
|
|
332
|
+
}
|
|
333
|
+
const dateAux = new Date(date);
|
|
334
|
+
return new Intl.DateTimeFormat(locale, {
|
|
335
|
+
day: "2-digit",
|
|
336
|
+
month: "long",
|
|
337
|
+
year: "numeric"
|
|
338
|
+
}).format(dateAux);
|
|
339
|
+
};
|
|
329
340
|
|
|
330
341
|
// ../utils/src/call.ts
|
|
331
342
|
var call = async (method, params) => {
|
|
@@ -533,12 +544,18 @@ var DirectoryNodesService = class extends BaseService {
|
|
|
533
544
|
};
|
|
534
545
|
|
|
535
546
|
// src/transforms/documentTypes.ts
|
|
547
|
+
import { getConfigs as getConfigs2 } from "@c-rex/utils/next-cookies";
|
|
548
|
+
import { cookies as cookies2 } from "next/headers";
|
|
536
549
|
var transformDocumentTypes = (data) => {
|
|
537
550
|
const labels = [];
|
|
551
|
+
const config = getConfigs2();
|
|
552
|
+
const contentLanguage = cookies2().get(CONTENT_LANG_KEY)?.value || config.languageSwitcher.default;
|
|
553
|
+
const language = contentLanguage.split("-")[0];
|
|
538
554
|
data.items.forEach((documentItem) => {
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
|
|
555
|
+
const label = documentItem.labels.find((item) => item.language.toLowerCase() === language.toLowerCase());
|
|
556
|
+
labels.push({
|
|
557
|
+
shortId: documentItem.shortId,
|
|
558
|
+
label: label ? label.value : ""
|
|
542
559
|
});
|
|
543
560
|
});
|
|
544
561
|
return labels;
|
|
@@ -551,34 +568,28 @@ var DocumentTypesService = class extends BaseService {
|
|
|
551
568
|
}
|
|
552
569
|
/**
|
|
553
570
|
* Retrieves document type labels for the specified fields.
|
|
554
|
-
* The labels are restricted to English language (EN-us).
|
|
555
571
|
*
|
|
556
|
-
* @param fields - Array of field names to retrieve labels for
|
|
557
572
|
* @returns A promise that resolves to an array of label strings
|
|
558
573
|
* @throws Error if the API request fails
|
|
559
574
|
*/
|
|
560
|
-
async getLabels(
|
|
561
|
-
const params = [
|
|
562
|
-
{
|
|
563
|
-
key: "Restrict",
|
|
564
|
-
value: `languages~EN-us`
|
|
565
|
-
},
|
|
566
|
-
...createParams(fields, "Fields")
|
|
567
|
-
];
|
|
575
|
+
async getLabels() {
|
|
568
576
|
return await this.request({
|
|
569
|
-
params
|
|
577
|
+
params: [{
|
|
578
|
+
key: "sparqlWhere",
|
|
579
|
+
value: "?iu iirds:is-applicable-for-document-type ?s . ?iu iirds:has-topic-type <https://www.c-rex.net/iirds/td#Blogpost>"
|
|
580
|
+
}],
|
|
570
581
|
transformer: transformDocumentTypes
|
|
571
582
|
});
|
|
572
583
|
}
|
|
573
584
|
};
|
|
574
585
|
|
|
575
586
|
// src/transforms/information.ts
|
|
576
|
-
import { getConfigs as
|
|
577
|
-
import { cookies as
|
|
587
|
+
import { getConfigs as getConfigs3 } from "@c-rex/utils/next-cookies";
|
|
588
|
+
import { cookies as cookies3 } from "next/headers";
|
|
578
589
|
import { CrexLogger as CrexLogger2 } from "@c-rex/core/logger";
|
|
579
590
|
var transformInformationUnits = async (data) => {
|
|
580
591
|
const logger = new CrexLogger2();
|
|
581
|
-
const config = await
|
|
592
|
+
const config = await getConfigs3();
|
|
582
593
|
const filteredTags = {};
|
|
583
594
|
const items = data.items.map((item) => {
|
|
584
595
|
const type = item.class.labels.filter((item2) => item2.language === EN_LANG)[0].value.toUpperCase();
|
|
@@ -618,7 +629,7 @@ var transformInformationUnits = async (data) => {
|
|
|
618
629
|
};
|
|
619
630
|
});
|
|
620
631
|
if (data.tags) {
|
|
621
|
-
const contentLang = (
|
|
632
|
+
const contentLang = (cookies3().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase();
|
|
622
633
|
const splittedContentLang = contentLang.split("-")[0];
|
|
623
634
|
for (const [key, value] of Object.entries(data.tags)) {
|
|
624
635
|
if (!value || !value.items || value.items.length === 0) {
|
|
@@ -641,7 +652,7 @@ var transformInformationUnits = async (data) => {
|
|
|
641
652
|
for (const labelItem of item.labels) {
|
|
642
653
|
if (labelItem.language === void 0) {
|
|
643
654
|
logger.log({
|
|
644
|
-
level: "
|
|
655
|
+
level: "info",
|
|
645
656
|
message: `No language on label ${labelItem.value} from category ${key}`
|
|
646
657
|
});
|
|
647
658
|
label = labelItem.value;
|
|
@@ -724,6 +735,7 @@ var InformationUnitsService = class extends BaseService {
|
|
|
724
735
|
{ key: "PageNumber", value: page.toString() },
|
|
725
736
|
{ key: "Operator", value: operator },
|
|
726
737
|
{ key: "tags", value: "true" },
|
|
738
|
+
// TODO use customer config values and add a param to each one
|
|
727
739
|
{ key: "Like", value: like.toString() },
|
|
728
740
|
...remainFields,
|
|
729
741
|
...remainFilters,
|
|
@@ -759,7 +771,9 @@ var InformationUnitsService = class extends BaseService {
|
|
|
759
771
|
{ key: "Fields", value: "titles" },
|
|
760
772
|
{ key: "Fields", value: "languages" },
|
|
761
773
|
{ key: "Fields", value: "labels" },
|
|
762
|
-
{ key: "Fields", value: "packages" }
|
|
774
|
+
{ key: "Fields", value: "packages" },
|
|
775
|
+
{ key: "Fields", value: "created" },
|
|
776
|
+
{ key: "Fields", value: "revision" }
|
|
763
777
|
];
|
|
764
778
|
return await this.request({
|
|
765
779
|
path: id,
|
|
@@ -788,10 +802,10 @@ var InformationUnitsService = class extends BaseService {
|
|
|
788
802
|
};
|
|
789
803
|
|
|
790
804
|
// src/language.ts
|
|
791
|
-
import { getConfigs as
|
|
805
|
+
import { getConfigs as getConfigs4 } from "@c-rex/utils/next-cookies";
|
|
792
806
|
var LanguageService = class extends BaseService {
|
|
793
807
|
constructor() {
|
|
794
|
-
const configs =
|
|
808
|
+
const configs = getConfigs4();
|
|
795
809
|
super(configs.languageSwitcher.endpoint);
|
|
796
810
|
}
|
|
797
811
|
/**
|
|
@@ -826,11 +840,138 @@ var LanguageService = class extends BaseService {
|
|
|
826
840
|
});
|
|
827
841
|
}
|
|
828
842
|
};
|
|
843
|
+
|
|
844
|
+
// src/transforms/topics.ts
|
|
845
|
+
import { getConfigs as getConfigs5 } from "@c-rex/utils/next-cookies";
|
|
846
|
+
import { cookies as cookies4 } from "next/headers";
|
|
847
|
+
import { CrexLogger as CrexLogger3 } from "@c-rex/core/logger";
|
|
848
|
+
var transformTopics = async (data) => {
|
|
849
|
+
const logger = new CrexLogger3();
|
|
850
|
+
const config = getConfigs5();
|
|
851
|
+
const contentLang = (cookies4().get(CONTENT_LANG_KEY)?.value || config.languageSwitcher.default).toLowerCase();
|
|
852
|
+
const items = data.items.map((item) => {
|
|
853
|
+
const type = item.class.labels.filter((item2) => item2.language === EN_LANG)[0].value.toUpperCase();
|
|
854
|
+
let link = `/topics/${item.shortId}`;
|
|
855
|
+
if (config.results.articlePageLayout == "BLOG") {
|
|
856
|
+
link = `/blog/${item.shortId}`;
|
|
857
|
+
} else if (type == RESULT_TYPES.DOCUMENT) {
|
|
858
|
+
link = `/documents/${item.shortId}`;
|
|
859
|
+
}
|
|
860
|
+
let title = "NO TITLE";
|
|
861
|
+
let language = "NO LANGUAGE";
|
|
862
|
+
try {
|
|
863
|
+
if (item.titles) {
|
|
864
|
+
title = item.titles[0].value;
|
|
865
|
+
language = item.titles[0].language;
|
|
866
|
+
} else {
|
|
867
|
+
title = item.labels[0].value;
|
|
868
|
+
language = item.labels[0].language;
|
|
869
|
+
}
|
|
870
|
+
} catch {
|
|
871
|
+
logger.log({
|
|
872
|
+
level: "error",
|
|
873
|
+
message: `No label or title on item ${item.shortId}`
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
let renditionUrl = "";
|
|
877
|
+
const renditions = item.renditions.filter((item2) => item2.format == "application/xhtml+xml");
|
|
878
|
+
if (renditions.length > 0 || renditions[0] !== void 0) {
|
|
879
|
+
const filteredLinks = renditions[0].links.filter((renditionItem) => renditionItem.rel == "view");
|
|
880
|
+
if (filteredLinks.length > 0 || filteredLinks[0] !== void 0) {
|
|
881
|
+
renditionUrl = filteredLinks[0].href;
|
|
882
|
+
}
|
|
883
|
+
;
|
|
884
|
+
}
|
|
885
|
+
;
|
|
886
|
+
let categoryType = type;
|
|
887
|
+
if (item.applicableForTypes && item.applicableForTypes.length > 0) {
|
|
888
|
+
const splittedContentLang = contentLang.split("-")[0];
|
|
889
|
+
categoryType = item.applicableForTypes[0].labels.find((item2) => item2.language === splittedContentLang)?.value || categoryType;
|
|
890
|
+
}
|
|
891
|
+
return {
|
|
892
|
+
language,
|
|
893
|
+
title,
|
|
894
|
+
type: categoryType,
|
|
895
|
+
localeType: "",
|
|
896
|
+
shortId: item.shortId,
|
|
897
|
+
created: formatDateToLocale(item.created, contentLang),
|
|
898
|
+
disabled: config.results.disabledResults.includes(type),
|
|
899
|
+
link,
|
|
900
|
+
renditionUrl,
|
|
901
|
+
image: null,
|
|
902
|
+
description: null
|
|
903
|
+
};
|
|
904
|
+
});
|
|
905
|
+
return {
|
|
906
|
+
tags: null,
|
|
907
|
+
items,
|
|
908
|
+
pageInfo: data.pageInfo
|
|
909
|
+
};
|
|
910
|
+
};
|
|
911
|
+
|
|
912
|
+
// src/topics.ts
|
|
913
|
+
var TopicsService = class extends BaseService {
|
|
914
|
+
constructor() {
|
|
915
|
+
super("Topics/");
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Retrieves a list of topics based on specified criteria.
|
|
919
|
+
*
|
|
920
|
+
* @param options - Options for filtering and paginating the topics list
|
|
921
|
+
* @param options.queries - Optional search query string
|
|
922
|
+
* @param options.page - Optional page number for pagination (defaults to 1)
|
|
923
|
+
* @param options.fields - Optional array of fields to include in the response
|
|
924
|
+
* @param options.filters - Optional array of filter strings to apply
|
|
925
|
+
* @param options.languages - Optional array of language codes to filter by
|
|
926
|
+
* @returns A promise that resolves to the information units response
|
|
927
|
+
* @throws Error if the API request fails
|
|
928
|
+
*/
|
|
929
|
+
async getList({
|
|
930
|
+
queries = "",
|
|
931
|
+
page = 1,
|
|
932
|
+
fields = [],
|
|
933
|
+
filters = [],
|
|
934
|
+
languages = [],
|
|
935
|
+
wildcard = WILD_CARD_OPTIONS.BOTH,
|
|
936
|
+
operator = OPERATOR_OPTIONS.AND,
|
|
937
|
+
pageSize = 12
|
|
938
|
+
}) {
|
|
939
|
+
const remainFields = createParams(fields, "Fields");
|
|
940
|
+
const remainFilters = createParams(filters, "Filter");
|
|
941
|
+
const languageParam = `VALUES ?lang { ${languages.map((lang) => `"${lang}"`).join(" ")} } ?s iirds:language ?lang .`;
|
|
942
|
+
const params = [
|
|
943
|
+
{ key: "pageSize", value: pageSize.toString() },
|
|
944
|
+
{ key: "PageNumber", value: page.toString() },
|
|
945
|
+
{ key: "Sort", value: "-created;-score" },
|
|
946
|
+
...remainFields,
|
|
947
|
+
...remainFilters
|
|
948
|
+
];
|
|
949
|
+
if (wildcard.length > 0) {
|
|
950
|
+
params.push({ key: "Operator", value: operator });
|
|
951
|
+
}
|
|
952
|
+
if (wildcard.length > 0) {
|
|
953
|
+
params.push({ key: "wildcard", value: wildcard.toLowerCase() });
|
|
954
|
+
}
|
|
955
|
+
if (languages.length > 0) {
|
|
956
|
+
params.push({ key: "sparqlWhere", value: languageParam });
|
|
957
|
+
}
|
|
958
|
+
if (queries.length > 0) {
|
|
959
|
+
params.push(
|
|
960
|
+
{ key: "Query", value: queries }
|
|
961
|
+
);
|
|
962
|
+
}
|
|
963
|
+
return await this.request({
|
|
964
|
+
params,
|
|
965
|
+
transformer: transformTopics
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
};
|
|
829
969
|
export {
|
|
830
970
|
DirectoryNodesService,
|
|
831
971
|
DocumentTypesService,
|
|
832
972
|
InformationUnitsService,
|
|
833
973
|
LanguageService,
|
|
834
|
-
RenditionsService
|
|
974
|
+
RenditionsService,
|
|
975
|
+
TopicsService
|
|
835
976
|
};
|
|
836
977
|
//# sourceMappingURL=index.mjs.map
|
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\";\nexport const FRAGMENT = \"FRAGMENT\";\n\nexport const RESULT_TYPES = {\n TOPIC: TOPIC,\n DOCUMENT: DOCUMENT,\n PACKAGE: PACKAGE,\n FRAGMENT: FRAGMENT\n} as const;\n\nexport const FILES_EXTENSIONS = {\n PDF: \"application/pdf\",\n HTML: \"text/html\",\n} as const;\n\nexport const DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";\n\nexport const CREX_TOKEN_HEADER_KEY = \"crex-token\";\n\nexport const WILD_CARD_OPTIONS = {\n BOTH: \"BOTH\",\n END: \"END\",\n START: \"START\",\n NONE: \"NONE\",\n} as const;\n\nexport const OPERATOR_OPTIONS = {\n AND: \"AND\",\n OR: \"OR\",\n} as const;\n\n","import winston from \"winston\";\nimport { MatomoTransport } from \"./transports/matomo\";\nimport { GraylogTransport } from \"./transports/graylog\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { LOG_LEVELS } from \"@c-rex/constants\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\n/**\n * Logger class for the CREX application.\n * Provides logging functionality with multiple transports (Console, Matomo, Graylog).\n */\nexport class CrexLogger {\n private customerConfig!: ConfigInterface;\n public logger!: winston.Logger;\n\n /**\n * Initializes the logger instance if it hasn't been initialized yet.\n * Loads customer configuration and creates the logger with appropriate transports.\n * \n * @private\n */\n private async initLogger() {\n try {\n if (!this.customerConfig) {\n this.customerConfig = await getConfigs();\n }\n if (!this.logger) {\n this.logger = this.createLogger();\n }\n } catch (error) {\n console.error(\"Error initializing logger:\", error);\n }\n }\n\n /**\n * Logs a message with the specified level and optional category.\n * \n * @param options - Logging options\n * @param options.level - The log level (error, warn, info, etc.)\n * @param options.message - The message to log\n * @param options.category - Optional category for the log message\n */\n public async log({ level, message, category }: {\n level: LogLevelType,\n message: string,\n category?: LogCategoriesType\n }) {\n await this.initLogger();\n this.logger.log(level, message, category);\n }\n\n /**\n * Creates a new Winston logger instance with configured transports.\n * \n * @private\n * @returns A configured Winston logger instance\n */\n private createLogger() {\n return winston.createLogger({\n levels: LOG_LEVELS,\n transports: [\n new winston.transports.Console({\n level: this.customerConfig.logs.console.minimumLevel,\n silent: this.customerConfig.logs.console.silent,\n }),\n new MatomoTransport(this.customerConfig),\n new GraylogTransport(this.customerConfig),\n ],\n });\n }\n}","import Transport from \"winston-transport\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\n/**\n * Winston transport for sending logs to Matomo analytics.\n * Extends the base Winston transport with Matomo-specific functionality.\n */\nexport class MatomoTransport extends Transport {\n public matomoTransport: any;\n private configs: ConfigInterface;\n\n /**\n * Creates a new instance of MatomoTransport.\n * \n * @param configs - The application configuration containing logging settings\n */\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.matomo.minimumLevel,\n silent: configs.logs.matomo.silent,\n });\n\n this.matomoTransport = new Transport();\n this.configs = configs;\n }\n\n /**\n * Logs a message to Matomo if the message category is included in the configured categories.\n * \n * @param info - The log information including level, message, and category\n * @param callback - Callback function to execute after logging\n */\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const matomoCategory = this.configs.logs.matomo.categoriesLevel\n\n if (matomoCategory.includes(info.category) || matomoCategory.includes(ALL)) {\n this.matomoTransport.log(info, callback);\n }\n }\n}\n","import Transport from \"winston-transport\";\nimport Graylog2Transport from \"winston-graylog2\";\nimport { LogCategoriesType, LogLevelType } from \"@c-rex/types\";\nimport { ALL } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\n\n/**\n * Winston transport for sending logs to Graylog.\n * Extends the base Winston transport with Graylog-specific functionality.\n */\nexport class GraylogTransport extends Transport {\n public graylogTransport: any;\n private configs: ConfigInterface\n\n /**\n * Creates a new instance of GraylogTransport.\n * \n * @param configs - The application configuration containing logging settings\n */\n constructor(configs: ConfigInterface) {\n super({\n level: configs.logs.graylog.minimumLevel,\n silent: configs.logs.graylog.silent,\n });\n\n this.configs = configs;\n this.graylogTransport = new Graylog2Transport({\n name: \"crex.net.documentation\",\n //name: \"crex.net.blog\",\n silent: false,\n handleExceptions: false,\n graylog: {\n servers: [\n { host: \"localhost\", port: 12201 },\n { host: \"https://log.c-rex.net\", port: 12202 }\n\n //TODO: check the URL => https://log.c-rex.net:12202/gelf\" GELF??\n ],\n },\n });\n }\n\n /**\n * Logs a message to Graylog if the message category is included in the configured categories.\n * \n * @param info - The log information including level, message, and category\n * @param callback - Callback function to execute after logging\n */\n log(\n info: { level: LogLevelType, message: string, category: LogCategoriesType },\n callback: () => void,\n ): void {\n const graylogCategory = this.configs.logs.graylog.categoriesLevel\n\n if (graylogCategory.includes(info.category) || graylogCategory.includes(ALL)) {\n this.graylogTransport.log(info, callback);\n }\n }\n}\n","import { FLAGS_BY_LANG } from \"@c-rex/constants\";\n\nexport const _generateShaKey = async (input: string): Promise<string> => {\n const encoder = new TextEncoder();\n const data = encoder.encode(input);\n const hashBuffer = await crypto.subtle.digest('SHA-1', data);\n const hashArray = Array.from(new Uint8Array(hashBuffer));\n const base64url = btoa(String.fromCharCode(...hashArray))\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '');\n\n return base64url.slice(0, 12);\n}\n\n/**\n * Retrieves the country code associated with a given language code.\n * @param lang - The language code to look up (e.g., \"en-US\")\n * @returns The corresponding country code, or the original language code if not found\n */\nexport const getCountryCodeByLang = (lang: string): string => {\n const mappedKeys = Object.keys(FLAGS_BY_LANG);\n\n if (!mappedKeys.includes(lang)) {\n return lang\n }\n\n type LangKey = keyof typeof FLAGS_BY_LANG;\n const country = FLAGS_BY_LANG[lang as LangKey]\n\n return country\n}\n\nexport const getFromCookieString = (cookieString: string, key: string): string => {\n const cookies = cookieString.split(';')\n\n for (const cookie of cookies) {\n const [cookieKey, cookieValue] = cookie.trim().split('=')\n\n if (cookieKey === key) {\n return cookieValue as string;\n }\n }\n\n return ''\n}\n","import { _generateShaKey } from \"./utils\"\n\n/**\n * Makes an asynchronous RPC API call to the server.\n * @param method - The RPC method name to call\n * @param params - Optional parameters to pass to the method\n * @returns A Promise resolving to the response data of type T\n */\nexport const call = async<T = unknown>(method: string, params?: any): Promise<T> => {\n type result = {\n data: string,\n expireDate: Date,\n }\n\n const shaKey = await _generateShaKey(JSON.stringify({ method, params }))\n const cache = localStorage.getItem(shaKey)\n\n if (cache !== null) {\n const { data, expireDate } = JSON.parse(cache) as result\n\n if (new Date(expireDate) > new Date()) {\n return JSON.parse(data) as T\n } else {\n localStorage.removeItem(shaKey)\n }\n }\n\n const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/rpc`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ method, params }),\n credentials: 'include',\n });\n\n const json = await res.json();\n\n if (!res.ok) throw new Error(json.error || 'Unknown error');\n\n const today = new Date()\n const result: result = {\n data: JSON.stringify(json.data),\n expireDate: new Date(today.getTime() + 1000 * 60 * 60),\n }\n\n localStorage.setItem(shaKey, JSON.stringify(result))\n\n return json.data;\n}","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merges multiple class values into a single string using clsx and tailwind-merge.\n * Useful for conditionally applying Tailwind CSS classes.\n * @param inputs - Any number of class values (strings, objects, arrays, etc.)\n * @returns A merged string of class names optimized for Tailwind CSS\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import { QueryParams } from '@c-rex/types';\n\n/**\n * Creates an array of parameter objects from a list of field values.\n * @param fieldsList - Array of field values to transform into parameter objects\n * @param key - The key to use for each parameter object (defaults to \"Fields\")\n * @returns An array of objects with key-value pairs\n */\nexport const createParams = (fieldsList: string[], key: string = \"Fields\") =>\n fieldsList.map((item) => ({\n key: key,\n value: item,\n }));\n\n/**\n * Generates a URL query string from an array of parameter objects.\n * @param params - Array of QueryParams objects containing key-value pairs\n * @returns A URL-encoded query string\n */\nexport const generateQueryParams = (params: QueryParams[]): string => {\n const queryParams = params\n .map(\n (param) =>\n `${encodeURIComponent(param.key)}=${encodeURIComponent(param.value)}`,\n )\n .join(\"&\");\n return queryParams;\n};\n","import { FileRenditionType } from \"@c-rex/types\";\nimport { informationUnitsRenditions } from \"@c-rex/interfaces\";\n\ntype RenditionType = {\n filesToDownload: FileRenditionType[],\n filesToOpen: FileRenditionType[]\n}\nexport const getFileRenditions = ({ renditions }: { renditions: informationUnitsRenditions[] }): RenditionType => {\n if (renditions == undefined || renditions.length == 0) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filteredRenditions = renditions.filter(\n (item) => item.format != \"application/xhtml+xml\" && item.format != \"application/json\" && item.format != \"application/llm+xml\"\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) {\n return {\n filesToDownload: [],\n filesToOpen: [],\n };\n }\n\n const filesToDownload = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"download\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n });\n\n const filesToOpen = filteredRenditions.map((item) => {\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n return {\n format: item.format,\n link: filteredLinks[0].href,\n };\n })\n\n return {\n filesToDownload: filesToDownload,\n filesToOpen: filesToOpen,\n }\n}","import { CrexApi } from \"@c-rex/core\";\nimport { QueryParams } from \"@c-rex/types\";\nimport { call, generateQueryParams } from \"@c-rex/utils\";\nimport { Method } from \"axios\";\n\n/**\n * Base service class that provides common functionality for API interactions.\n * All specific service classes extend this base class.\n */\nexport class BaseService {\n protected api: CrexApi;\n private endpoint: string;\n\n /**\n * Creates a new instance of BaseService.\n * \n * @param endpoint - The API endpoint URL for this service\n */\n constructor(endpoint: string) {\n this.api = new CrexApi();\n this.endpoint = endpoint;\n }\n\n /**\n * Makes an API request to the specified endpoint.\n * \n * @param options - Request configuration options\n * @param options.path - Optional path to append to the endpoint\n * @param options.params - Optional query parameters to include in the request\n * @param options.method - HTTP method to use (defaults to 'get')\n * @param options.transformer - Optional function to transform the response data\n * @returns The response data, optionally transformed\n * @throws Error if the API request fails\n */\n protected async request<T>({\n path = \"\",\n method = \"get\",\n params = [],\n headers = {},\n transformer = (response: any) => response,\n }: {\n path?: string,\n method?: Method,\n params?: QueryParams[],\n headers?: any,\n transformer?: (data: any) => T,\n }): Promise<T> {\n try {\n let url = `${this.endpoint}${path}`;\n\n const queryParams = generateQueryParams(params);\n if (queryParams.length > 0) {\n url += `?${queryParams}`;\n }\n\n const response = await this.api.execute({\n url,\n method,\n headers,\n })\n\n return await transformer(response);\n\n } catch (error) {\n call(\"CrexLogger.log\", {\n level: \"error\",\n message: `BaseService.request error when request ${path}. Error: ${error}`\n });\n\n throw error;\n }\n }\n}\n\n","import { BaseService } from \"./baseService\";\nimport { informationUnitsRenditions } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with renditions in the API.\n * Provides methods to retrieve and process different types of renditions.\n */\nexport class RenditionsService extends BaseService {\n constructor() {\n super(\"Renditions/\");\n }\n\n /**\n * Retrieves the HTML rendition from a list of renditions.\n * Filters for renditions with format 'application/xhtml+xml' and rel 'view'.\n * \n * @param renditions - Array of rendition objects to process\n * @returns A promise that resolves to the HTML content as a string, or empty string if no suitable rendition is found\n * @throws Error if the API request fails\n */\n public async getHTMLRendition({ renditions }: { renditions: informationUnitsRenditions[] }): Promise<string> {\n const filteredRenditions = renditions.filter(\n (item) => item.format == \"application/xhtml+xml\",\n );\n\n if (filteredRenditions.length == 0 || filteredRenditions[0] == undefined) return \"\";\n const item = filteredRenditions[0];\n const filteredLinks = item.links.filter((item) => item.rel == \"view\");\n\n if (filteredLinks.length == 0 || filteredLinks[0] == undefined) return \"\";\n const url = filteredLinks[0].href;\n const response = await this.api.execute({\n url,\n method: \"get\",\n headers: {\n Accept: \"application/xhtml+xml\",\n },\n })\n\n return response as string;\n }\n}","import { BaseService } from \"./baseService\";\nimport { createParams } from \"@c-rex/utils\";\nimport { DirectoryNodes, DirectoryNodesResponse } from \"@c-rex/interfaces\";\n\n/**\n * Service for interacting with directory nodes in the API.\n * Provides methods to retrieve directory node information.\n */\nexport class DirectoryNodesService extends BaseService {\n constructor() {\n super(\"DirectoryNodes/\");\n }\n\n /**\n * Retrieves a specific directory node by its ID.\n * \n * @param id - The unique identifier of the directory node\n * @returns A promise that resolves to the directory node data\n * @throws Error if the API request fails\n */\n public async getItem(id: string): Promise<DirectoryNodes> {\n return await this.request({\n path: id,\n });\n }\n\n /**\n * Retrieves a list of directory nodes based on specified filters.\n * \n * @param options - Options for filtering the directory nodes list\n * @param options.filters - Optional array of filter strings to apply\n * @returns A promise that resolves to the directory nodes response\n * @throws Error if the API request fails\n */\n public async getList({\n filters = [],\n }: {\n filters?: string[],\n }): Promise<DirectoryNodesResponse> {\n\n const remainFilters = createParams(filters, \"Filter\");\n\n return await this.request({\n params: {\n ...remainFilters,\n },\n });\n }\n}\n","import { DefaultRequest } from \"@c-rex/interfaces\";\nimport { DocumentTypesItem } from \"@c-rex/interfaces\";\n\nexport const transformDocumentTypes = (data: DefaultRequest<DocumentTypesItem>) => {\n const labels: string[] = [];\n\n data.items.forEach((documentItem: DocumentTypesItem) => {\n const aux = documentItem.labels.flatMap((item) => item);\n\n aux.forEach((item) => {\n if (item.language == \"en\") labels.push(item.value);\n });\n });\n\n return labels;\n};\n","import { createParams } from \"@c-rex/utils\";\nimport { transformDocumentTypes } from \"./transforms/documentTypes\";\nimport { BaseService } from \"./baseService\";\n\n/**\n * Service for interacting with document types in the API.\n * Provides methods to retrieve document type information.\n */\nexport class DocumentTypesService extends BaseService {\n constructor() {\n super(\"DocumentTypes/\");\n }\n\n /**\n * Retrieves document type labels for the specified fields.\n * The labels are restricted to English language (EN-us).\n * \n * @param fields - Array of field names to retrieve labels for\n * @returns A promise that resolves to an array of label strings\n * @throws Error if the API request fails\n */\n public async getLabels(fields: string[]): Promise<string[]> {\n const params = [\n {\n key: \"Restrict\",\n value: `languages~EN-us`,\n },\n ...createParams(fields, \"Fields\"),\n ];\n\n return await this.request({\n params,\n transformer: transformDocumentTypes,\n });\n }\n}\n","import { CONTENT_LANG_KEY, EN_LANG, RESULT_TYPES } from \"@c-rex/constants\";\nimport {\n DefaultRequest,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { cookies } from 'next/headers';\nimport { getFileRenditions } from \"@c-rex/utils\";\nimport { CrexLogger } from '@c-rex/core/logger';\nimport { AutocompleteSuggestion } from \"@c-rex/interfaces\";\n\nexport const transformInformationUnits = async (\n data: DefaultRequest<informationUnitsItems>,\n): Promise<informationUnitsResponse> => {\n const logger = new CrexLogger()\n const config = await getConfigs();\n const filteredTags: any = {}\n\n\n const items = data.items.map((item) => {\n const type = item.class.labels.filter((item) => item.language === EN_LANG)[0].value.toUpperCase();\n const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });\n\n let link = `/topics/${item.shortId}`;\n\n if (config.results.articlePageLayout == \"BLOG\") {\n link = `/blog/${item.shortId}`\n } else if (type == RESULT_TYPES.DOCUMENT) {\n link = `/documents/${item.shortId}`;\n }\n\n let title = \"NO TITLE\"\n let language = \"NO LANGUAGE\"\n\n try {\n if (item.titles) {\n title = item.titles[0].value\n language = item.titles[0].language\n } else {\n title = item.labels[0].value\n language = item.labels[0].language\n }\n } catch {\n logger.log({\n level: \"error\",\n message: `No label or title on item ${item.shortId}`\n })\n }\n\n return {\n language: language,\n title: title,\n type: type,\n localeType: \"\",\n shortId: item.shortId,\n disabled: config.results.disabledResults.includes(type as any),\n link: link,\n filesToOpen,\n filesToDownload\n }\n });\n\n if (data.tags) {\n const contentLang = (cookies().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase()\n const splittedContentLang = contentLang.split(\"-\")[0];\n\n for (const [key, value] of Object.entries(data.tags)) {\n\n if (!value || !value.items || value.items.length === 0) {\n continue;\n }\n if (!config.search.tags.includes(key)) {\n continue;\n }\n\n const aux = value.items.map(item => {\n if (item?.shortId === undefined) return null\n if (Number(item.hits) === 0) return null\n if (item?.labels === undefined || item?.labels.length === 0) {\n logger.log({\n level: \"warning\",\n message: `No labels on item with id ${item.shortId} from category ${key}`\n })\n return null;\n }\n\n let label = \"\"\n\n for (const labelItem of item.labels) {\n if (labelItem.language === undefined) {\n logger.log({\n level: \"warning\",\n message: `No language on label ${labelItem.value} from category ${key}`\n })\n label = labelItem.value\n break;\n }\n\n if (labelItem.language.toLowerCase() === contentLang || labelItem.language.toLowerCase() === splittedContentLang) {\n label = labelItem.value\n break;\n }\n\n label = labelItem.value\n }\n\n return {\n hits: item.hits,\n total: item.total,\n label: label,\n active: false,\n shortId: item.shortId,\n }\n }).filter((item) => item !== null)\n\n if (aux.length === 0) {\n continue;\n }\n\n filteredTags[key] = aux;\n }\n }\n\n return {\n tags: filteredTags,\n items: items,\n pageInfo: data.pageInfo,\n };\n};\n\nexport const transformSuggestions = (data: AutocompleteSuggestion, query: string) => {\n const suggestions: string[] = []\n const comparableList: string[] = []\n\n data.suggestions.forEach((item) => {\n suggestions.push(item.value);\n comparableList.push(item.value.toLowerCase())\n })\n\n if (!comparableList.includes(query.toLowerCase())) {\n return [query, ...suggestions];\n }\n\n return suggestions\n}","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits, transformSuggestions } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\nimport { WildCardType } from \"@c-rex/types\";\nimport { OPERATOR_OPTIONS, WILD_CARD_OPTIONS } from \"@c-rex/constants\";\n\n/**\n * Service for interacting with information units in the API.\n * Provides methods to retrieve and search information units.\n */\nexport class InformationUnitsService extends BaseService {\n constructor() {\n super(\"InformationUnits/\");\n }\n\n /**\n * Retrieves a list of information units based on specified criteria.\n * \n * @param options - Options for filtering and paginating the information units list\n * @param options.queries - Optional search query string\n * @param options.page - Optional page number for pagination (defaults to 1)\n * @param options.fields - Optional array of fields to include in the response\n * @param options.filters - Optional array of filter strings to apply\n * @param options.languages - Optional array of language codes to filter by\n * @returns A promise that resolves to the information units response\n * @throws Error if the API request fails\n */\n public async getList({\n queries = \"\",\n page = 1,\n fields = [],\n filters = [],\n restrict = [],\n languages = [],\n wildcard = WILD_CARD_OPTIONS.BOTH,\n operator = OPERATOR_OPTIONS.AND,\n like = false,\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n restrict?: string[],\n fields?: string[],\n languages?: string[],\n wildcard?: WildCardType,\n operator?: string,\n like?: boolean,\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const restrictions = createParams(restrict, \"Restrict\");\n const languageParam = `VALUES ?lang { ${languages.map(lang => `\"${lang}\"`).join(\" \")} } ?s iirds:language ?lang .`\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"wildcard\", value: wildcard.toLowerCase() },\n { key: \"PageNumber\", value: page.toString() },\n { key: \"Operator\", value: operator },\n { key: \"tags\", value: \"true\" },\n { key: \"Like\", value: like.toString() },\n ...remainFields,\n ...remainFilters,\n ...restrictions\n ];\n if (languages.length > 0) {\n params.push({ key: \"sparqlWhere\", value: languageParam });\n }\n if (queries.length > 0) {\n params.push(\n { key: \"Query\", value: queries },\n );\n }\n\n return await this.request({\n params: params,\n transformer: transformInformationUnits\n });\n }\n\n /**\n * Retrieves a specific information unit by its ID.\n * Includes renditions, directory nodes, version information, titles, languages, and labels.\n * \n * @param options - Options for retrieving the information unit\n * @param options.id - The unique identifier of the information unit\n * @returns A promise that resolves to the information unit data\n * @throws Error if the API request fails\n */\n public async getItem({ id }: { id: string }): Promise<informationUnitsItems> {\n const params = [\n { key: \"Fields\", value: \"renditions\" },\n { key: \"Fields\", value: \"directoryNodes\" },\n { key: \"Fields\", value: \"versionOf\" },\n { key: \"Fields\", value: \"titles\" },\n { key: \"Fields\", value: \"languages\" },\n { key: \"Fields\", value: \"labels\" },\n { key: \"Fields\", value: \"packages\" },\n ];\n\n return await this.request({\n path: id,\n params,\n });\n }\n\n /**\n * Retrieves autocomplete suggestions based on a query prefix.\n * \n * @param options - Options for retrieving suggestions\n * @param options.query - The query prefix to get suggestions for\n * @param options.language - The language of the suggestions\n * @returns A promise that resolves to an array of suggestion strings\n * @throws Error if the API request fails\n */\n public async getSuggestions(\n { query, language }: { query: string, language: string }\n ): Promise<string[]> {\n\n return await this.request({\n path: 'Suggestions',\n params: [\n { key: \"prefix\", value: query },\n { key: \"lang\", value: language },\n ],\n transformer: (data: AutocompleteSuggestion) => transformSuggestions(data, query)\n });\n }\n}\n","import { LanguageAndCountries } from \"@c-rex/interfaces\";\nimport { BaseService } from \"./baseService\";\nimport { getCountryCodeByLang } from \"@c-rex/utils\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\n\n/**\n * Service for interacting with language-related functionality in the API.\n * Provides methods to retrieve language and country information.\n */\nexport class LanguageService extends BaseService {\n constructor() {\n const configs = getConfigs()\n super(configs.languageSwitcher.endpoint);\n }\n\n /**\n * Retrieves a list of available languages and their associated countries.\n * Transforms the API response to include language code, country code, and original value.\n * \n * @returns A promise that resolves to an array of language and country objects\n * @throws Error if the API request fails\n */\n public async getLanguagesAndCountries(): Promise<LanguageAndCountries[]> {\n return await this.request({\n transformer: (data: { value: string; score: number }[]) => {\n const countryCodeList = data.map((item) => {\n /*\n api -> en, en-US\n default -> en-US. Then use EN-US \n\n api -> en\n default -> en-US. Then use EN\n */\n //should be abble to handle this items: en-US, en, pt, pt-PT, pt-BR \n\n const splittedValue = item.value.split(\"-\")\n const lang = splittedValue[0]\n let country = splittedValue[0]\n\n if (splittedValue.length > 1) {\n country = splittedValue[1]\n } else {\n country = getCountryCodeByLang(lang)\n }\n\n return {\n country: country,\n lang: lang,\n value: item.value,\n }\n })\n\n return countryCodeList.sort((a, b) => {\n return a.value.localeCompare(b.value)\n })\n },\n });\n }\n}\n"],"mappings":";AAAA,OAAO,WAAqD;;;ACArD,IAAM,MAAM;AAeZ,IAAM,aAAa;AAAA,EACtB,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACX;AAOO,IAAM,MAAM;AAAA,EACf,WAAW;AAAA,EACX,aAAa;AAAA,EACb,aAAa;AAAA,IACT,gBAAgB;AAAA,EACpB;AACJ;AAEO,IAAM,iBAAiB;AAEvB,IAAM,mBAAmB;AAMzB,IAAM,gBAAgB;AAAA,EACzB,MAAM;AAAA,EACN,MAAM;AACV;AAIO,IAAM,UAAU;AAQhB,IAAM,QAAQ;AACd,IAAM,WAAW;AACjB,IAAM,UAAU;AAChB,IAAM,WAAW;AAEjB,IAAM,eAAe;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAOO,IAAM,uBAAuB,IAAI,KAAK,KAAK,KAAK;AAQhD,IAAM,wBAAwB;AAE9B,IAAM,oBAAoB;AAAA,EAC7B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM;A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,QACJ,CAAC;AAED,eAAO,gBAAgB,KAAK,CAAC,GAAG,MAAM;AAClC,iBAAO,EAAE,MAAM,cAAc,EAAE,KAAK;AAAA,QACxC,CAAC;AAAA,MACL;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;","names":["Transport","Transport","item","item","getConfigs","cookies","CrexLogger","getConfigs","item","cookies","getConfigs"]}
|
|
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","../src/transforms/topics.ts","../src/topics.ts"],"sourcesContent":["import axios, { AxiosResponse, Method, AxiosInstance } from \"axios\";\nimport { API, CREX_TOKEN_HEADER_KEY, SDK_CONFIG_KEY } from \"@c-rex/constants\";\nimport { ConfigInterface } from \"@c-rex/interfaces\";\nimport { cookies } from \"next/headers\";\nimport { CrexLogger } from \"./logger\";\n\n/**\n * Interface for API response with generic data type.\n */\ninterface APIGenericResponse<T> extends AxiosResponse {\n data: T;\n statusCode: number;\n}\n\n/**\n * Interface for API call parameters.\n */\ninterface CallParams {\n url: string;\n method: Method;\n body?: any;\n headers?: any;\n params?: any;\n}\n\n/**\n * API client class for the CREX application.\n * Handles API requests with caching, authentication, and retry logic.\n */\nexport class CrexApi {\n private customerConfig!: ConfigInterface;\n private apiClient!: AxiosInstance;\n private logger!: CrexLogger;\n\n /**\n * Initializes the API client if it hasn't been initialized yet.\n * Loads customer configuration, creates the axios instance, and initializes the logger.\n * \n * @private\n */\n private async initAPI() {\n this.logger = new CrexLogger();\n\n if (!this.customerConfig) {\n const aux = cookies().get(SDK_CONFIG_KEY);\n if (aux != undefined) {\n this.customerConfig = JSON.parse(aux.value);\n } else {\n this.logger.log({\n level: \"error\",\n message: `utils.initAPI error: Config cookie not available`\n });\n\n throw new Error(\"Config cookie not available\");\n }\n }\n\n if (!this.apiClient) {\n this.apiClient = axios.create({\n baseURL: this.customerConfig.baseUrl,\n })\n }\n }\n\n private async getToken() {\n try {\n const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/token`, {\n method: 'POST',\n credentials: 'include',\n });\n\n const { token } = await response.json();\n\n return token;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `utils.getToken error: ${error}`\n });\n\n throw error\n }\n }\n\n private async manageToken() {\n try {\n let token = \"\";\n const hasToken = cookies().get(CREX_TOKEN_HEADER_KEY);\n\n if (hasToken == undefined || hasToken.value === null) {\n const tokenResult = await this.getToken();\n\n if (tokenResult === null) throw new Error(\"Token is undefined\");\n\n token = tokenResult;\n } else {\n token = hasToken.value;\n }\n\n return token;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `utils.manageToken error: ${error}`\n });\n\n throw error\n }\n }\n\n /**\n * Executes an API request with caching, authentication, and retry logic.\n * \n * @param options - Request options\n * @param options.url - The URL to request\n * @param options.method - The HTTP method to use\n * @param options.params - Optional query parameters\n * @param options.body - Optional request body\n * @param options.headers - Optional request headers\n * @returns The response data\n * @throws Error if the request fails after maximum retries\n */\n async execute<T>({\n url,\n method,\n params,\n body,\n headers = {},\n }: CallParams): Promise<T> {\n await this.initAPI();\n\n let response: APIGenericResponse<T> | undefined = undefined;\n\n if (this.customerConfig.OIDC.client.enabled) {\n const token = await this.manageToken();\n\n headers = {\n ...headers,\n Authorization: `Bearer ${token}`,\n };\n\n this.apiClient.defaults.headers.common['Authorization'] = `Bearer ${token}`;\n }\n\n for (let retry = 0; retry < API.MAX_RETRY; retry++) {\n try {\n response = await this.apiClient.request({\n url,\n method,\n data: body,\n params,\n headers,\n });\n\n break;\n } catch (error) {\n this.logger.log({\n level: \"error\",\n message: `API.execute ${retry + 1}º error when request ${url}. Error: ${error}`\n });\n\n if (retry === API.MAX_RETRY - 1) {\n throw error;\n }\n }\n }\n\n if (response) {\n return response.data;\n }\n\n throw new Error(\"API.execute error: Failed to retrieve a valid response\");\n }\n}","export const ALL = \"*\"\n\nexport const LOG_CATEGORIES = [\n \"NoLicense\",\n \"Scenario\",\n \"Favorites\",\n \"Subscription\",\n \"Share\",\n \"Document\",\n \"Search\",\n \"History\",\n \"Notification\",\n \"UserProfile\",\n] as const;\n\nexport const LOG_LEVELS = {\n critical: 2,\n error: 3,\n warning: 4,\n info: 6,\n debug: 7,\n} as const;\n\nexport const RESULT_VIEW_STYLES = [\n \"cards\",\n \"table\",\n] as const;\n\nexport const API = {\n MAX_RETRY: 3,\n API_TIMEOUT: 10000,\n API_HEADERS: {\n \"content-Type\": \"application/json\",\n },\n};\n\nexport const SDK_CONFIG_KEY = \"crex-sdk-config\";\n\nexport const CONTENT_LANG_KEY = \"CONTENT_LANG_KEY\";\n\nexport const AVAILABLE_CONTENT_LANG_KEY = \"AVAILABLE_CONTENT_LANG_KEY\";\n\nexport const UI_LANG_KEY = \"UI_LANG_KEY\";\n\nexport const FLAGS_BY_LANG = {\n \"en\": \"US\",\n \"de\": \"DE\",\n};\n\nexport const DEFAULT_LANG = \"en-US\";\n\nexport const EN_LANG = \"en\";\n\nexport const UI_LANG_OPTIONS = [\"en-us\", \"de-de\"];\n\nexport const TOPICS_TYPE_AND_LINK = \"topics\";\nexport const BLOG_TYPE_AND_LINK = \"blog\";\nexport const DOCUMENTS_TYPE_AND_LINK = \"documents\";\n\nexport const TOPIC = \"TOPIC\";\nexport const DOCUMENT = \"DOCUMENT\";\nexport const PACKAGE = \"PACKAGE\";\nexport const FRAGMENT = \"FRAGMENT\";\n\nexport const RESULT_TYPES = {\n TOPIC: TOPIC,\n DOCUMENT: DOCUMENT,\n PACKAGE: PACKAGE,\n FRAGMENT: FRAGMENT\n} as const;\n\nexport const FILES_EXTENSIONS = {\n PDF: \"application/pdf\",\n HTML: \"text/html\",\n} as const;\n\nexport const DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1000; // 7 days in milliseconds\n\nexport const ICONS_BY_FILE_EXTENSION = {\n \"application/pdf\": \"FaFilePdf\",\n} as const;\n\nexport const DEFAULT_ICON = \"file\";\n\nexport const CREX_TOKEN_HEADER_KEY = \"crex-token\";\n\nexport const WILD_CARD_OPTIONS = {\n BOTH: \"BOTH\",\n END: \"END\",\n START: \"START\",\n NONE: \"NONE\",\n} as const;\n\nexport const OPERATOR_OPTIONS = {\n AND: \"AND\",\n OR: \"OR\",\n} as const;\n\nexport const ARTICLE_PAGE_LAYOUT = {\n BLOG: \"BLOG\",\n DOCUMENT: \"DOCUMENT\",\n} as const;\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\nexport const formatDateToLocale = (date: string, locale: string): string => {\n if (typeof date !== 'string' || !date) {\n return date;\n }\n\n const dateAux = new Date(date);\n return new Intl.DateTimeFormat(locale, {\n day: '2-digit',\n month: 'long',\n year: 'numeric'\n }).format(dateAux);\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 { CONTENT_LANG_KEY } from \"@c-rex/constants\";\nimport { DefaultRequest } from \"@c-rex/interfaces\";\nimport { DocumentTypesItem } from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { cookies } from \"next/headers\";\n\nexport const transformDocumentTypes = (data: DefaultRequest<DocumentTypesItem>) => {\n const labels: { shortId: string, label: string }[] = [];\n const config = getConfigs();\n const contentLanguage = cookies().get(CONTENT_LANG_KEY)?.value || config.languageSwitcher.default;\n const language = contentLanguage.split(\"-\")[0];\n\n data.items.forEach((documentItem) => {\n const label = documentItem.labels.find((item) => item.language.toLowerCase() === language.toLowerCase());\n\n labels.push({\n shortId: documentItem.shortId,\n label: label ? label.value : \"\"\n })\n });\n\n return labels;\n};\n","import { 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 * \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(): Promise<{ shortId: string, label: string }[]> {\n return await this.request({\n params: [{\n key: \"sparqlWhere\",\n value: \"?iu iirds:is-applicable-for-document-type ?s . ?iu iirds:has-topic-type <https://www.c-rex.net/iirds/td#Blogpost>\"\n }],\n transformer: transformDocumentTypes,\n });\n }\n}\n","import { CONTENT_LANG_KEY, EN_LANG, RESULT_TYPES } from \"@c-rex/constants\";\nimport {\n DefaultRequest,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { cookies } from 'next/headers';\nimport { getFileRenditions } from \"@c-rex/utils\";\nimport { CrexLogger } from '@c-rex/core/logger';\nimport { AutocompleteSuggestion } from \"@c-rex/interfaces\";\n\nexport const transformInformationUnits = async (data: DefaultRequest<informationUnitsItems>): Promise<informationUnitsResponse> => {\n const logger = new CrexLogger()\n const config = await getConfigs();\n const filteredTags: any = {}\n\n const items = data.items.map((item) => {\n const type = item.class.labels.filter((item) => item.language === EN_LANG)[0].value.toUpperCase();\n const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });\n\n let link = `/topics/${item.shortId}`;\n\n if (config.results.articlePageLayout == \"BLOG\") {\n link = `/blog/${item.shortId}`\n } else if (type == RESULT_TYPES.DOCUMENT) {\n link = `/documents/${item.shortId}`;\n }\n\n let title = \"NO TITLE\"\n let language = \"NO LANGUAGE\"\n\n try {\n if (item.titles) {\n title = item.titles[0].value\n language = item.titles[0].language\n } else {\n title = item.labels[0].value\n language = item.labels[0].language\n }\n } catch {\n logger.log({\n level: \"error\",\n message: `No label or title on item ${item.shortId}`\n })\n }\n\n return {\n language: language,\n title: title,\n type: type,\n localeType: \"\",\n shortId: item.shortId,\n disabled: config.results.disabledResults.includes(type as any),\n link: link,\n filesToOpen,\n filesToDownload\n }\n });\n\n if (data.tags) {\n const contentLang = (cookies().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase()\n const splittedContentLang = contentLang.split(\"-\")[0];\n\n for (const [key, value] of Object.entries(data.tags)) {\n\n if (!value || !value.items || value.items.length === 0) {\n continue;\n }\n if (!config.search.tags.includes(key)) {\n continue;\n }\n\n const aux = value.items.map(item => {\n if (item?.shortId === undefined) return null\n if (Number(item.hits) === 0) return null\n if (item?.labels === undefined || item?.labels.length === 0) {\n logger.log({\n level: \"warning\",\n message: `No labels on item with id ${item.shortId} from category ${key}`\n })\n return null;\n }\n\n let label = \"\"\n\n for (const labelItem of item.labels) {\n if (labelItem.language === undefined) {\n logger.log({\n level: \"info\",\n message: `No language on label ${labelItem.value} from category ${key}`\n })\n label = labelItem.value\n break;\n }\n\n if (labelItem.language.toLowerCase() === contentLang || labelItem.language.toLowerCase() === splittedContentLang) {\n label = labelItem.value\n break;\n }\n\n label = labelItem.value\n\n //TODO: fallback in english\n }\n\n return {\n hits: item.hits,\n total: item.total,\n label: label,\n active: false,\n shortId: item.shortId,\n }\n }).filter((item) => item !== null)\n\n if (aux.length === 0) {\n continue;\n }\n\n filteredTags[key] = aux;\n }\n }\n\n return {\n tags: filteredTags,\n items: items,\n pageInfo: data.pageInfo,\n };\n};\n\nexport const transformSuggestions = (data: AutocompleteSuggestion, query: string) => {\n const suggestions: string[] = []\n const comparableList: string[] = []\n\n data.suggestions.forEach((item) => {\n suggestions.push(item.value);\n comparableList.push(item.value.toLowerCase())\n })\n\n if (!comparableList.includes(query.toLowerCase())) {\n return [query, ...suggestions];\n }\n\n return suggestions\n}","import {\n AutocompleteSuggestion,\n informationUnitsResponse,\n informationUnitsItems,\n} from \"@c-rex/interfaces\";\nimport { transformInformationUnits, transformSuggestions } from \"./transforms/information\";\nimport { createParams } from \"@c-rex/utils\";\nimport { BaseService } from \"./baseService\";\nimport { WildCardType } from \"@c-rex/types\";\nimport { OPERATOR_OPTIONS, WILD_CARD_OPTIONS } from \"@c-rex/constants\";\n\n/**\n * Service for interacting with information units in the API.\n * Provides methods to retrieve and search information units.\n */\nexport class InformationUnitsService extends BaseService {\n constructor() {\n super(\"InformationUnits/\");\n }\n\n /**\n * Retrieves a list of information units based on specified criteria.\n * \n * @param options - Options for filtering and paginating the information units list\n * @param options.queries - Optional search query string\n * @param options.page - Optional page number for pagination (defaults to 1)\n * @param options.fields - Optional array of fields to include in the response\n * @param options.filters - Optional array of filter strings to apply\n * @param options.languages - Optional array of language codes to filter by\n * @returns A promise that resolves to the information units response\n * @throws Error if the API request fails\n */\n public async getList({\n queries = \"\",\n page = 1,\n fields = [],\n filters = [],\n restrict = [],\n languages = [],\n wildcard = WILD_CARD_OPTIONS.BOTH,\n operator = OPERATOR_OPTIONS.AND,\n like = false,\n }: {\n queries?: string,\n page?: number,\n filters?: string[],\n restrict?: string[],\n fields?: string[],\n languages?: string[],\n wildcard?: WildCardType,\n operator?: string,\n like?: boolean,\n }): Promise<informationUnitsResponse> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const restrictions = createParams(restrict, \"Restrict\");\n const languageParam = `VALUES ?lang { ${languages.map(lang => `\"${lang}\"`).join(\" \")} } ?s iirds:language ?lang .`\n\n const params = [\n { key: \"pageSize\", value: \"12\" },\n { key: \"wildcard\", value: wildcard.toLowerCase() },\n { key: \"PageNumber\", value: page.toString() },\n { key: \"Operator\", value: operator },\n { key: \"tags\", value: \"true\" }, // TODO use customer config values and add a param to each one\n { key: \"Like\", value: like.toString() },\n ...remainFields,\n ...remainFilters,\n ...restrictions\n ];\n if (languages.length > 0) {\n params.push({ key: \"sparqlWhere\", value: languageParam });\n }\n if (queries.length > 0) {\n params.push(\n { key: \"Query\", value: queries },\n );\n }\n\n return await this.request({\n params: params,\n transformer: transformInformationUnits\n });\n }\n\n /**\n * Retrieves a specific information unit by its ID.\n * Includes renditions, directory nodes, version information, titles, languages, and labels.\n * \n * @param options - Options for retrieving the information unit\n * @param options.id - The unique identifier of the information unit\n * @returns A promise that resolves to the information unit data\n * @throws Error if the API request fails\n */\n public async getItem({ id }: { id: string }): Promise<informationUnitsItems> {\n const params = [\n { key: \"Fields\", value: \"renditions\" },\n { key: \"Fields\", value: \"directoryNodes\" },\n { key: \"Fields\", value: \"versionOf\" },\n { key: \"Fields\", value: \"titles\" },\n { key: \"Fields\", value: \"languages\" },\n { key: \"Fields\", value: \"labels\" },\n { key: \"Fields\", value: \"packages\" },\n { key: \"Fields\", value: \"created\" },\n { key: \"Fields\", value: \"revision\" },\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","import { CONTENT_LANG_KEY, EN_LANG, RESULT_TYPES } from \"@c-rex/constants\";\nimport { DefaultRequest, AutocompleteSuggestion, TopicsRequestItem, DefaultResponse, TopicsResponseItem } from \"@c-rex/interfaces\";\nimport { getConfigs } from \"@c-rex/utils/next-cookies\";\nimport { cookies } from 'next/headers';\nimport { CrexLogger } from '@c-rex/core/logger';\nimport { formatDateToLocale } from \"@c-rex/utils\";\n\nexport const transformTopics = async (data: DefaultRequest<TopicsRequestItem>): Promise<DefaultResponse<TopicsResponseItem, null>> => {\n const logger = new CrexLogger()\n const config = getConfigs();\n const contentLang = (cookies().get(CONTENT_LANG_KEY)?.value || config.languageSwitcher.default).toLowerCase()\n\n const items = data.items.map(item => {\n const type = item.class.labels.filter((item) => item.language === EN_LANG)[0].value.toUpperCase();\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 let renditionUrl = \"\"\n const renditions = item.renditions.filter(item => item.format == \"application/xhtml+xml\");\n if (renditions.length > 0 || renditions[0] !== undefined) {\n const filteredLinks = renditions[0].links.filter((renditionItem) => renditionItem.rel == \"view\");\n if (filteredLinks.length > 0 || filteredLinks[0] !== undefined) {\n renditionUrl = filteredLinks[0].href;\n };\n };\n\n let categoryType = type\n if (item.applicableForTypes && item.applicableForTypes.length > 0) {\n const splittedContentLang = contentLang.split(\"-\")[0];\n categoryType = item.applicableForTypes[0].labels.find(item => item.language === splittedContentLang)?.value || categoryType;\n }\n\n return {\n language: language,\n title: title,\n type: categoryType,\n localeType: \"\",\n shortId: item.shortId,\n created: formatDateToLocale(item.created, contentLang),\n disabled: config.results.disabledResults.includes(type as any),\n link: link,\n renditionUrl: renditionUrl,\n image: null,\n description: null,\n }\n })\n\n return {\n tags: null,\n items: items,\n pageInfo: data.pageInfo,\n };\n};\n","import { transformTopics } from \"./transforms/topics\";\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\";\nimport { DefaultResponse, TopicsResponseItem } from \"@c-rex/interfaces\";\n\ntype getListProps = {\n queries?: string,\n page?: number,\n filters?: string[],\n fields?: string[],\n languages?: string[],\n wildcard?: WildCardType,\n operator?: string,\n like?: boolean,\n pageSize?: number\n}\n\n\n/**\n * Service for interacting with information units in the API.\n * Provides methods to retrieve and search information units.\n */\nexport class TopicsService extends BaseService {\n constructor() {\n super(\"Topics/\");\n }\n\n /**\n * Retrieves a list of topics based on specified criteria.\n * \n * @param options - Options for filtering and paginating the topics 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 wildcard = WILD_CARD_OPTIONS.BOTH,\n operator = OPERATOR_OPTIONS.AND,\n pageSize = 12\n }: getListProps): Promise<DefaultResponse<TopicsResponseItem, null>> {\n const remainFields = createParams(fields, \"Fields\");\n const remainFilters = createParams(filters, \"Filter\");\n const languageParam = `VALUES ?lang { ${languages.map(lang => `\"${lang}\"`).join(\" \")} } ?s iirds:language ?lang .`\n\n const params = [\n { key: \"pageSize\", value: pageSize.toString() },\n { key: \"PageNumber\", value: page.toString() },\n { key: \"Sort\", value: \"-created;-score\" },\n ...remainFields,\n ...remainFilters,\n ];\n\n if (wildcard.length > 0) {\n params.push({ key: \"Operator\", value: operator });\n }\n if (wildcard.length > 0) {\n params.push({ key: \"wildcard\", value: wildcard.toLowerCase() });\n }\n if (languages.length > 0) {\n params.push({ key: \"sparqlWhere\", value: languageParam });\n }\n if (queries.length > 0) {\n params.push(\n { key: \"Query\", value: queries },\n );\n }\n\n return await this.request({\n params: params,\n transformer: transformTopics\n });\n }\n}\n"],"mappings":";AAAA,OAAO,WAAqD;;;ACArD,IAAM,MAAM;AAeZ,IAAM,aAAa;AAAA,EACtB,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACX;AAOO,IAAM,MAAM;AAAA,EACf,WAAW;AAAA,EACX,aAAa;AAAA,EACb,aAAa;AAAA,IACT,gBAAgB;AAAA,EACpB;AACJ;AAEO,IAAM,iBAAiB;AAEvB,IAAM,mBAAmB;AAMzB,IAAM,gBAAgB;AAAA,EACzB,MAAM;AAAA,EACN,MAAM;AACV;AAIO,IAAM,UAAU;AAQhB,IAAM,QAAQ;AACd,IAAM,WAAW;AACjB,IAAM,UAAU;AAChB,IAAM,WAAW;AAEjB,IAAM,eAAe;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAOO,IAAM,uBAAuB,IAAI,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A,IAClE;AACA,QAAI,UAAU,SAAS,GAAG;AACtB,aAAO,KAAK,EAAE,KAAK,eAAe,OAAO,cAAc,CAAC;AAAA,IAC5D;AACA,QAAI,QAAQ,SAAS,GAAG;AACpB,aAAO;AAAA,QACH,EAAE,KAAK,SAAS,OAAO,QAAQ;AAAA,MACnC;AAAA,IACJ;AAEA,WAAO,MAAM,KAAK,QAAQ;AAAA,MACtB;AAAA,MACA,aAAa;AAAA,IACjB,CAAC;AAAA,EACL;AACJ;","names":["Transport","Transport","item","item","getConfigs","cookies","getConfigs","cookies","CrexLogger","getConfigs","item","cookies","getConfigs","getConfigs","cookies","CrexLogger","CrexLogger","getConfigs","cookies","item"]}
|