@c-rex/services 0.1.5 → 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 +229 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +227 -31
- 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
|
|
|
@@ -58,6 +59,7 @@ var API = {
|
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
61
|
var SDK_CONFIG_KEY = "crex-sdk-config";
|
|
62
|
+
var CONTENT_LANG_KEY = "CONTENT_LANG_KEY";
|
|
61
63
|
var FLAGS_BY_LANG = {
|
|
62
64
|
"en": "US",
|
|
63
65
|
"de": "DE"
|
|
@@ -66,10 +68,12 @@ var EN_LANG = "en";
|
|
|
66
68
|
var TOPIC = "TOPIC";
|
|
67
69
|
var DOCUMENT = "DOCUMENT";
|
|
68
70
|
var PACKAGE = "PACKAGE";
|
|
71
|
+
var FRAGMENT = "FRAGMENT";
|
|
69
72
|
var RESULT_TYPES = {
|
|
70
73
|
TOPIC,
|
|
71
74
|
DOCUMENT,
|
|
72
|
-
PACKAGE
|
|
75
|
+
PACKAGE,
|
|
76
|
+
FRAGMENT
|
|
73
77
|
};
|
|
74
78
|
var DEFAULT_COOKIE_LIMIT = 7 * 24 * 60 * 60 * 1e3;
|
|
75
79
|
var CREX_TOKEN_HEADER_KEY = "crex-token";
|
|
@@ -237,7 +241,7 @@ var CrexApi = class {
|
|
|
237
241
|
async initAPI() {
|
|
238
242
|
this.logger = new CrexLogger();
|
|
239
243
|
if (!this.customerConfig) {
|
|
240
|
-
const aux =
|
|
244
|
+
const aux = (0, import_headers.cookies)().get(SDK_CONFIG_KEY);
|
|
241
245
|
if (aux != void 0) {
|
|
242
246
|
this.customerConfig = JSON.parse(aux.value);
|
|
243
247
|
} else {
|
|
@@ -363,6 +367,17 @@ var getCountryCodeByLang = (lang) => {
|
|
|
363
367
|
const country = FLAGS_BY_LANG[lang];
|
|
364
368
|
return country;
|
|
365
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
|
+
};
|
|
366
381
|
|
|
367
382
|
// ../utils/src/call.ts
|
|
368
383
|
var call = async (method, params) => {
|
|
@@ -570,12 +585,18 @@ var DirectoryNodesService = class extends BaseService {
|
|
|
570
585
|
};
|
|
571
586
|
|
|
572
587
|
// src/transforms/documentTypes.ts
|
|
588
|
+
var import_next_cookies2 = require("@c-rex/utils/next-cookies");
|
|
589
|
+
var import_headers2 = require("next/headers");
|
|
573
590
|
var transformDocumentTypes = (data) => {
|
|
574
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];
|
|
575
595
|
data.items.forEach((documentItem) => {
|
|
576
|
-
const
|
|
577
|
-
|
|
578
|
-
|
|
596
|
+
const label = documentItem.labels.find((item) => item.language.toLowerCase() === language.toLowerCase());
|
|
597
|
+
labels.push({
|
|
598
|
+
shortId: documentItem.shortId,
|
|
599
|
+
label: label ? label.value : ""
|
|
579
600
|
});
|
|
580
601
|
});
|
|
581
602
|
return labels;
|
|
@@ -588,34 +609,30 @@ var DocumentTypesService = class extends BaseService {
|
|
|
588
609
|
}
|
|
589
610
|
/**
|
|
590
611
|
* Retrieves document type labels for the specified fields.
|
|
591
|
-
* The labels are restricted to English language (EN-us).
|
|
592
612
|
*
|
|
593
|
-
* @param fields - Array of field names to retrieve labels for
|
|
594
613
|
* @returns A promise that resolves to an array of label strings
|
|
595
614
|
* @throws Error if the API request fails
|
|
596
615
|
*/
|
|
597
|
-
async getLabels(
|
|
598
|
-
const params = [
|
|
599
|
-
{
|
|
600
|
-
key: "Restrict",
|
|
601
|
-
value: `languages~EN-us`
|
|
602
|
-
},
|
|
603
|
-
...createParams(fields, "Fields")
|
|
604
|
-
];
|
|
616
|
+
async getLabels() {
|
|
605
617
|
return await this.request({
|
|
606
|
-
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
|
+
}],
|
|
607
622
|
transformer: transformDocumentTypes
|
|
608
623
|
});
|
|
609
624
|
}
|
|
610
625
|
};
|
|
611
626
|
|
|
612
627
|
// src/transforms/information.ts
|
|
613
|
-
var
|
|
628
|
+
var import_next_cookies3 = require("@c-rex/utils/next-cookies");
|
|
629
|
+
var import_headers3 = require("next/headers");
|
|
614
630
|
var import_logger2 = require("@c-rex/core/logger");
|
|
615
631
|
var transformInformationUnits = async (data) => {
|
|
616
|
-
const config = await (0, import_next_cookies2.getConfigs)();
|
|
617
632
|
const logger = new import_logger2.CrexLogger();
|
|
618
|
-
const
|
|
633
|
+
const config = await (0, import_next_cookies3.getConfigs)();
|
|
634
|
+
const filteredTags = {};
|
|
635
|
+
const items = data.items.map((item) => {
|
|
619
636
|
const type = item.class.labels.filter((item2) => item2.language === EN_LANG)[0].value.toUpperCase();
|
|
620
637
|
const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });
|
|
621
638
|
let link = `/topics/${item.shortId}`;
|
|
@@ -651,10 +668,60 @@ var transformInformationUnits = async (data) => {
|
|
|
651
668
|
filesToOpen,
|
|
652
669
|
filesToDownload
|
|
653
670
|
};
|
|
654
|
-
})
|
|
655
|
-
|
|
671
|
+
});
|
|
672
|
+
if (data.tags) {
|
|
673
|
+
const contentLang = ((0, import_headers3.cookies)().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase();
|
|
674
|
+
const splittedContentLang = contentLang.split("-")[0];
|
|
675
|
+
for (const [key, value] of Object.entries(data.tags)) {
|
|
676
|
+
if (!value || !value.items || value.items.length === 0) {
|
|
677
|
+
continue;
|
|
678
|
+
}
|
|
679
|
+
if (!config.search.tags.includes(key)) {
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
682
|
+
const aux = value.items.map((item) => {
|
|
683
|
+
if (item?.shortId === void 0) return null;
|
|
684
|
+
if (Number(item.hits) === 0) return null;
|
|
685
|
+
if (item?.labels === void 0 || item?.labels.length === 0) {
|
|
686
|
+
logger.log({
|
|
687
|
+
level: "warning",
|
|
688
|
+
message: `No labels on item with id ${item.shortId} from category ${key}`
|
|
689
|
+
});
|
|
690
|
+
return null;
|
|
691
|
+
}
|
|
692
|
+
let label = "";
|
|
693
|
+
for (const labelItem of item.labels) {
|
|
694
|
+
if (labelItem.language === void 0) {
|
|
695
|
+
logger.log({
|
|
696
|
+
level: "info",
|
|
697
|
+
message: `No language on label ${labelItem.value} from category ${key}`
|
|
698
|
+
});
|
|
699
|
+
label = labelItem.value;
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
if (labelItem.language.toLowerCase() === contentLang || labelItem.language.toLowerCase() === splittedContentLang) {
|
|
703
|
+
label = labelItem.value;
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
label = labelItem.value;
|
|
707
|
+
}
|
|
708
|
+
return {
|
|
709
|
+
hits: item.hits,
|
|
710
|
+
total: item.total,
|
|
711
|
+
label,
|
|
712
|
+
active: false,
|
|
713
|
+
shortId: item.shortId
|
|
714
|
+
};
|
|
715
|
+
}).filter((item) => item !== null);
|
|
716
|
+
if (aux.length === 0) {
|
|
717
|
+
continue;
|
|
718
|
+
}
|
|
719
|
+
filteredTags[key] = aux;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
656
722
|
return {
|
|
657
|
-
|
|
723
|
+
tags: filteredTags,
|
|
724
|
+
items,
|
|
658
725
|
pageInfo: data.pageInfo
|
|
659
726
|
};
|
|
660
727
|
};
|
|
@@ -702,21 +769,22 @@ var InformationUnitsService = class extends BaseService {
|
|
|
702
769
|
const remainFields = createParams(fields, "Fields");
|
|
703
770
|
const remainFilters = createParams(filters, "Filter");
|
|
704
771
|
const restrictions = createParams(restrict, "Restrict");
|
|
705
|
-
const
|
|
706
|
-
languages.map((item) => `?s iirds:language '${item}'`),
|
|
707
|
-
"sparqlWhere"
|
|
708
|
-
);
|
|
772
|
+
const languageParam = `VALUES ?lang { ${languages.map((lang) => `"${lang}"`).join(" ")} } ?s iirds:language ?lang .`;
|
|
709
773
|
const params = [
|
|
710
774
|
{ key: "pageSize", value: "12" },
|
|
711
775
|
{ key: "wildcard", value: wildcard.toLowerCase() },
|
|
712
776
|
{ key: "PageNumber", value: page.toString() },
|
|
713
777
|
{ key: "Operator", value: operator },
|
|
778
|
+
{ key: "tags", value: "true" },
|
|
779
|
+
// TODO use customer config values and add a param to each one
|
|
714
780
|
{ key: "Like", value: like.toString() },
|
|
715
781
|
...remainFields,
|
|
716
|
-
...languageParams,
|
|
717
782
|
...remainFilters,
|
|
718
783
|
...restrictions
|
|
719
784
|
];
|
|
785
|
+
if (languages.length > 0) {
|
|
786
|
+
params.push({ key: "sparqlWhere", value: languageParam });
|
|
787
|
+
}
|
|
720
788
|
if (queries.length > 0) {
|
|
721
789
|
params.push(
|
|
722
790
|
{ key: "Query", value: queries }
|
|
@@ -744,7 +812,9 @@ var InformationUnitsService = class extends BaseService {
|
|
|
744
812
|
{ key: "Fields", value: "titles" },
|
|
745
813
|
{ key: "Fields", value: "languages" },
|
|
746
814
|
{ key: "Fields", value: "labels" },
|
|
747
|
-
{ key: "Fields", value: "packages" }
|
|
815
|
+
{ key: "Fields", value: "packages" },
|
|
816
|
+
{ key: "Fields", value: "created" },
|
|
817
|
+
{ key: "Fields", value: "revision" }
|
|
748
818
|
];
|
|
749
819
|
return await this.request({
|
|
750
820
|
path: id,
|
|
@@ -773,10 +843,10 @@ var InformationUnitsService = class extends BaseService {
|
|
|
773
843
|
};
|
|
774
844
|
|
|
775
845
|
// src/language.ts
|
|
776
|
-
var
|
|
846
|
+
var import_next_cookies4 = require("@c-rex/utils/next-cookies");
|
|
777
847
|
var LanguageService = class extends BaseService {
|
|
778
848
|
constructor() {
|
|
779
|
-
const configs = (0,
|
|
849
|
+
const configs = (0, import_next_cookies4.getConfigs)();
|
|
780
850
|
super(configs.languageSwitcher.endpoint);
|
|
781
851
|
}
|
|
782
852
|
/**
|
|
@@ -811,12 +881,139 @@ var LanguageService = class extends BaseService {
|
|
|
811
881
|
});
|
|
812
882
|
}
|
|
813
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
|
+
};
|
|
814
1010
|
// Annotate the CommonJS export names for ESM import in node:
|
|
815
1011
|
0 && (module.exports = {
|
|
816
1012
|
DirectoryNodesService,
|
|
817
1013
|
DocumentTypesService,
|
|
818
1014
|
InformationUnitsService,
|
|
819
1015
|
LanguageService,
|
|
820
|
-
RenditionsService
|
|
1016
|
+
RenditionsService,
|
|
1017
|
+
TopicsService
|
|
821
1018
|
});
|
|
822
1019
|
//# sourceMappingURL=index.js.map
|