@c-rex/services 0.1.6 → 0.1.8

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 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(fields: string[]): Promise<string[]>;
109
+ getLabels(): Promise<{
110
+ shortId: string;
111
+ label: string;
112
+ }[]>;
112
113
  }
113
114
 
114
115
  /**
@@ -129,12 +130,13 @@ declare class InformationUnitsService extends BaseService {
129
130
  * @returns A promise that resolves to the information units response
130
131
  * @throws Error if the API request fails
131
132
  */
132
- getList({ queries, page, fields, filters, restrict, languages, wildcard, operator, like, }: {
133
+ getList({ queries, page, fields, filters, tags, restrict, languages, wildcard, operator, like, }: {
133
134
  queries?: string;
134
135
  page?: number;
135
136
  filters?: string[];
136
137
  restrict?: string[];
137
138
  fields?: string[];
139
+ tags?: string[];
138
140
  languages?: string[];
139
141
  wildcard?: WildCardType;
140
142
  operator?: string;
@@ -149,8 +151,9 @@ declare class InformationUnitsService extends BaseService {
149
151
  * @returns A promise that resolves to the information unit data
150
152
  * @throws Error if the API request fails
151
153
  */
152
- getItem({ id }: {
154
+ getItem({ id, shouldGetAllFields }: {
153
155
  id: string;
156
+ shouldGetAllFields?: boolean;
154
157
  }): Promise<informationUnitsItems>;
155
158
  /**
156
159
  * Retrieves autocomplete suggestions based on a query prefix.
@@ -183,4 +186,36 @@ declare class LanguageService extends BaseService {
183
186
  getLanguagesAndCountries(): Promise<LanguageAndCountries[]>;
184
187
  }
185
188
 
186
- export { DirectoryNodesService, DocumentTypesService, InformationUnitsService, LanguageService, RenditionsService };
189
+ type getListProps = {
190
+ queries?: string;
191
+ page?: number;
192
+ filters?: string[];
193
+ fields?: string[];
194
+ languages?: string[];
195
+ wildcard?: WildCardType;
196
+ operator?: string;
197
+ like?: boolean;
198
+ pageSize?: number;
199
+ };
200
+ /**
201
+ * Service for interacting with information units in the API.
202
+ * Provides methods to retrieve and search information units.
203
+ */
204
+ declare class TopicsService extends BaseService {
205
+ constructor();
206
+ /**
207
+ * Retrieves a list of topics based on specified criteria.
208
+ *
209
+ * @param options - Options for filtering and paginating the topics list
210
+ * @param options.queries - Optional search query string
211
+ * @param options.page - Optional page number for pagination (defaults to 1)
212
+ * @param options.fields - Optional array of fields to include in the response
213
+ * @param options.filters - Optional array of filter strings to apply
214
+ * @param options.languages - Optional array of language codes to filter by
215
+ * @returns A promise that resolves to the information units response
216
+ * @throws Error if the API request fails
217
+ */
218
+ getList({ queries, page, fields, filters, languages, wildcard, operator, pageSize }: getListProps): Promise<DefaultResponse<TopicsResponseItem, null>>;
219
+ }
220
+
221
+ 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(fields: string[]): Promise<string[]>;
109
+ getLabels(): Promise<{
110
+ shortId: string;
111
+ label: string;
112
+ }[]>;
112
113
  }
113
114
 
114
115
  /**
@@ -129,12 +130,13 @@ declare class InformationUnitsService extends BaseService {
129
130
  * @returns A promise that resolves to the information units response
130
131
  * @throws Error if the API request fails
131
132
  */
132
- getList({ queries, page, fields, filters, restrict, languages, wildcard, operator, like, }: {
133
+ getList({ queries, page, fields, filters, tags, restrict, languages, wildcard, operator, like, }: {
133
134
  queries?: string;
134
135
  page?: number;
135
136
  filters?: string[];
136
137
  restrict?: string[];
137
138
  fields?: string[];
139
+ tags?: string[];
138
140
  languages?: string[];
139
141
  wildcard?: WildCardType;
140
142
  operator?: string;
@@ -149,8 +151,9 @@ declare class InformationUnitsService extends BaseService {
149
151
  * @returns A promise that resolves to the information unit data
150
152
  * @throws Error if the API request fails
151
153
  */
152
- getItem({ id }: {
154
+ getItem({ id, shouldGetAllFields }: {
153
155
  id: string;
156
+ shouldGetAllFields?: boolean;
154
157
  }): Promise<informationUnitsItems>;
155
158
  /**
156
159
  * Retrieves autocomplete suggestions based on a query prefix.
@@ -183,4 +186,36 @@ declare class LanguageService extends BaseService {
183
186
  getLanguagesAndCountries(): Promise<LanguageAndCountries[]>;
184
187
  }
185
188
 
186
- export { DirectoryNodesService, DocumentTypesService, InformationUnitsService, LanguageService, RenditionsService };
189
+ type getListProps = {
190
+ queries?: string;
191
+ page?: number;
192
+ filters?: string[];
193
+ fields?: string[];
194
+ languages?: string[];
195
+ wildcard?: WildCardType;
196
+ operator?: string;
197
+ like?: boolean;
198
+ pageSize?: number;
199
+ };
200
+ /**
201
+ * Service for interacting with information units in the API.
202
+ * Provides methods to retrieve and search information units.
203
+ */
204
+ declare class TopicsService extends BaseService {
205
+ constructor();
206
+ /**
207
+ * Retrieves a list of topics based on specified criteria.
208
+ *
209
+ * @param options - Options for filtering and paginating the topics list
210
+ * @param options.queries - Optional search query string
211
+ * @param options.page - Optional page number for pagination (defaults to 1)
212
+ * @param options.fields - Optional array of fields to include in the response
213
+ * @param options.filters - Optional array of filter strings to apply
214
+ * @param options.languages - Optional array of language codes to filter by
215
+ * @returns A promise that resolves to the information units response
216
+ * @throws Error if the API request fails
217
+ */
218
+ getList({ queries, page, fields, filters, languages, wildcard, operator, pageSize }: getListProps): Promise<DefaultResponse<TopicsResponseItem, null>>;
219
+ }
220
+
221
+ 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
 
@@ -59,6 +60,7 @@ var API = {
59
60
  };
60
61
  var SDK_CONFIG_KEY = "crex-sdk-config";
61
62
  var CONTENT_LANG_KEY = "CONTENT_LANG_KEY";
63
+ var UI_LANG_KEY = "UI_LANG_KEY";
62
64
  var FLAGS_BY_LANG = {
63
65
  "en": "US",
64
66
  "de": "DE"
@@ -350,13 +352,13 @@ var CrexApi = class {
350
352
  };
351
353
 
352
354
  // ../utils/src/utils.ts
353
- var _generateShaKey = async (input) => {
354
- const encoder = new TextEncoder();
355
- const data = encoder.encode(input);
356
- const hashBuffer = await crypto.subtle.digest("SHA-1", data);
357
- const hashArray = Array.from(new Uint8Array(hashBuffer));
358
- const base64url = btoa(String.fromCharCode(...hashArray)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
359
- return base64url.slice(0, 12);
355
+ var _generateShaKey = (input) => {
356
+ let hash = 0;
357
+ for (let i = 0; i < input.length; i++) {
358
+ hash = (hash << 5) - hash + input.charCodeAt(i);
359
+ hash |= 0;
360
+ }
361
+ return Math.abs(hash).toString(16);
360
362
  };
361
363
  var getCountryCodeByLang = (lang) => {
362
364
  const mappedKeys = Object.keys(FLAGS_BY_LANG);
@@ -366,10 +368,21 @@ var getCountryCodeByLang = (lang) => {
366
368
  const country = FLAGS_BY_LANG[lang];
367
369
  return country;
368
370
  };
371
+ var formatDateToLocale = (date, locale) => {
372
+ if (typeof date !== "string" || !date) {
373
+ return date;
374
+ }
375
+ const dateAux = new Date(date);
376
+ return new Intl.DateTimeFormat(locale, {
377
+ day: "2-digit",
378
+ month: "long",
379
+ year: "numeric"
380
+ }).format(dateAux);
381
+ };
369
382
 
370
383
  // ../utils/src/call.ts
371
384
  var call = async (method, params) => {
372
- const shaKey = await _generateShaKey(JSON.stringify({ method, params }));
385
+ const shaKey = _generateShaKey(JSON.stringify({ method, params }));
373
386
  const cache = localStorage.getItem(shaKey);
374
387
  if (cache !== null) {
375
388
  const { data, expireDate } = JSON.parse(cache);
@@ -415,38 +428,27 @@ var generateQueryParams = (params) => {
415
428
  // ../utils/src/renditions.ts
416
429
  var getFileRenditions = ({ renditions }) => {
417
430
  if (renditions == void 0 || renditions.length == 0) {
418
- return {
419
- filesToDownload: [],
420
- filesToOpen: []
421
- };
431
+ return {};
422
432
  }
423
433
  const filteredRenditions = renditions.filter(
424
434
  (item) => item.format != "application/xhtml+xml" && item.format != "application/json" && item.format != "application/llm+xml"
425
435
  );
426
436
  if (filteredRenditions.length == 0 || filteredRenditions[0] == void 0) {
427
- return {
428
- filesToDownload: [],
429
- filesToOpen: []
430
- };
431
- }
432
- const filesToDownload = filteredRenditions.map((item) => {
433
- const filteredLinks = item.links.filter((item2) => item2.rel == "download");
434
- return {
435
- format: item.format,
436
- link: filteredLinks[0].href
437
- };
438
- });
439
- const filesToOpen = filteredRenditions.map((item) => {
440
- const filteredLinks = item.links.filter((item2) => item2.rel == "view");
441
- return {
442
- format: item.format,
443
- link: filteredLinks[0].href
444
- };
437
+ return {};
438
+ }
439
+ const result = {};
440
+ filteredRenditions.forEach((item) => {
441
+ const key = item.format;
442
+ if (result[key] == void 0) {
443
+ result[key] = {
444
+ view: "",
445
+ download: ""
446
+ };
447
+ }
448
+ result[key].download = item.links.filter((link) => link.rel == "download")[0]?.href;
449
+ result[key].view = item.links.filter((link) => link.rel == "view")[0]?.href;
445
450
  });
446
- return {
447
- filesToDownload,
448
- filesToOpen
449
- };
451
+ return result;
450
452
  };
451
453
 
452
454
  // src/baseService.ts
@@ -573,12 +575,18 @@ var DirectoryNodesService = class extends BaseService {
573
575
  };
574
576
 
575
577
  // src/transforms/documentTypes.ts
578
+ var import_next_cookies2 = require("@c-rex/utils/next-cookies");
579
+ var import_headers2 = require("next/headers");
576
580
  var transformDocumentTypes = (data) => {
577
581
  const labels = [];
582
+ const config = (0, import_next_cookies2.getConfigs)();
583
+ const contentLanguage = (0, import_headers2.cookies)().get(CONTENT_LANG_KEY)?.value || config.languageSwitcher.default;
584
+ const language = contentLanguage.split("-")[0];
578
585
  data.items.forEach((documentItem) => {
579
- const aux = documentItem.labels.flatMap((item) => item);
580
- aux.forEach((item) => {
581
- if (item.language == "en") labels.push(item.value);
586
+ const label = documentItem.labels.find((item) => item.language.toLowerCase() === language.toLowerCase());
587
+ labels.push({
588
+ shortId: documentItem.shortId,
589
+ label: label ? label.value : ""
582
590
  });
583
591
  });
584
592
  return labels;
@@ -591,38 +599,32 @@ var DocumentTypesService = class extends BaseService {
591
599
  }
592
600
  /**
593
601
  * Retrieves document type labels for the specified fields.
594
- * The labels are restricted to English language (EN-us).
595
602
  *
596
- * @param fields - Array of field names to retrieve labels for
597
603
  * @returns A promise that resolves to an array of label strings
598
604
  * @throws Error if the API request fails
599
605
  */
600
- async getLabels(fields) {
601
- const params = [
602
- {
603
- key: "Restrict",
604
- value: `languages~EN-us`
605
- },
606
- ...createParams(fields, "Fields")
607
- ];
606
+ async getLabels() {
608
607
  return await this.request({
609
- params,
608
+ params: [{
609
+ key: "sparqlWhere",
610
+ value: "?iu iirds:is-applicable-for-document-type ?s . ?iu iirds:has-topic-type <https://www.c-rex.net/iirds/td#Blogpost>"
611
+ }],
610
612
  transformer: transformDocumentTypes
611
613
  });
612
614
  }
613
615
  };
614
616
 
615
617
  // src/transforms/information.ts
616
- var import_next_cookies2 = require("@c-rex/utils/next-cookies");
617
- var import_headers2 = require("next/headers");
618
+ var import_next_cookies3 = require("@c-rex/utils/next-cookies");
619
+ var import_headers3 = require("next/headers");
618
620
  var import_logger2 = require("@c-rex/core/logger");
619
621
  var transformInformationUnits = async (data) => {
620
622
  const logger = new import_logger2.CrexLogger();
621
- const config = await (0, import_next_cookies2.getConfigs)();
623
+ const config = await (0, import_next_cookies3.getConfigs)();
622
624
  const filteredTags = {};
623
625
  const items = data.items.map((item) => {
624
626
  const type = item.class.labels.filter((item2) => item2.language === EN_LANG)[0].value.toUpperCase();
625
- const { filesToOpen, filesToDownload } = getFileRenditions({ renditions: item?.renditions });
627
+ const files = getFileRenditions({ renditions: item?.renditions });
626
628
  let link = `/topics/${item.shortId}`;
627
629
  if (config.results.articlePageLayout == "BLOG") {
628
630
  link = `/blog/${item.shortId}`;
@@ -653,12 +655,11 @@ var transformInformationUnits = async (data) => {
653
655
  shortId: item.shortId,
654
656
  disabled: config.results.disabledResults.includes(type),
655
657
  link,
656
- filesToOpen,
657
- filesToDownload
658
+ files
658
659
  };
659
660
  });
660
661
  if (data.tags) {
661
- const contentLang = ((0, import_headers2.cookies)().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase();
662
+ const contentLang = ((0, import_headers3.cookies)().get(CONTENT_LANG_KEY)?.value || EN_LANG).toLowerCase();
662
663
  const splittedContentLang = contentLang.split("-")[0];
663
664
  for (const [key, value] of Object.entries(data.tags)) {
664
665
  if (!value || !value.items || value.items.length === 0) {
@@ -681,7 +682,7 @@ var transformInformationUnits = async (data) => {
681
682
  for (const labelItem of item.labels) {
682
683
  if (labelItem.language === void 0) {
683
684
  logger.log({
684
- level: "warning",
685
+ level: "info",
685
686
  message: `No language on label ${labelItem.value} from category ${key}`
686
687
  });
687
688
  label = labelItem.value;
@@ -748,6 +749,7 @@ var InformationUnitsService = class extends BaseService {
748
749
  page = 1,
749
750
  fields = [],
750
751
  filters = [],
752
+ tags = [],
751
753
  restrict = [],
752
754
  languages = [],
753
755
  wildcard = WILD_CARD_OPTIONS.BOTH,
@@ -757,13 +759,14 @@ var InformationUnitsService = class extends BaseService {
757
759
  const remainFields = createParams(fields, "Fields");
758
760
  const remainFilters = createParams(filters, "Filter");
759
761
  const restrictions = createParams(restrict, "Restrict");
762
+ const remainTags = createParams(tags, "Tags");
760
763
  const languageParam = `VALUES ?lang { ${languages.map((lang) => `"${lang}"`).join(" ")} } ?s iirds:language ?lang .`;
761
764
  const params = [
762
765
  { key: "pageSize", value: "12" },
763
766
  { key: "wildcard", value: wildcard.toLowerCase() },
764
767
  { key: "PageNumber", value: page.toString() },
765
768
  { key: "Operator", value: operator },
766
- { key: "tags", value: "true" },
769
+ ...remainTags,
767
770
  { key: "Like", value: like.toString() },
768
771
  ...remainFields,
769
772
  ...remainFilters,
@@ -791,16 +794,21 @@ var InformationUnitsService = class extends BaseService {
791
794
  * @returns A promise that resolves to the information unit data
792
795
  * @throws Error if the API request fails
793
796
  */
794
- async getItem({ id }) {
795
- const params = [
796
- { key: "Fields", value: "renditions" },
797
- { key: "Fields", value: "directoryNodes" },
798
- { key: "Fields", value: "versionOf" },
799
- { key: "Fields", value: "titles" },
800
- { key: "Fields", value: "languages" },
801
- { key: "Fields", value: "labels" },
802
- { key: "Fields", value: "packages" }
803
- ];
797
+ async getItem({ id, shouldGetAllFields = false }) {
798
+ const params = [];
799
+ if (!shouldGetAllFields) {
800
+ params.push(
801
+ { key: "Fields", value: "renditions" },
802
+ { key: "Fields", value: "directoryNodes" },
803
+ { key: "Fields", value: "versionOf" },
804
+ { key: "Fields", value: "titles" },
805
+ { key: "Fields", value: "languages" },
806
+ { key: "Fields", value: "labels" },
807
+ { key: "Fields", value: "packages" },
808
+ { key: "Fields", value: "created" },
809
+ { key: "Fields", value: "revision" }
810
+ );
811
+ }
804
812
  return await this.request({
805
813
  path: id,
806
814
  params
@@ -828,10 +836,10 @@ var InformationUnitsService = class extends BaseService {
828
836
  };
829
837
 
830
838
  // src/language.ts
831
- var import_next_cookies3 = require("@c-rex/utils/next-cookies");
839
+ var import_next_cookies4 = require("@c-rex/utils/next-cookies");
832
840
  var LanguageService = class extends BaseService {
833
841
  constructor() {
834
- const configs = (0, import_next_cookies3.getConfigs)();
842
+ const configs = (0, import_next_cookies4.getConfigs)();
835
843
  super(configs.languageSwitcher.endpoint);
836
844
  }
837
845
  /**
@@ -866,12 +874,139 @@ var LanguageService = class extends BaseService {
866
874
  });
867
875
  }
868
876
  };
877
+
878
+ // src/transforms/topics.ts
879
+ var import_next_cookies5 = require("@c-rex/utils/next-cookies");
880
+ var import_headers4 = require("next/headers");
881
+ var import_logger3 = require("@c-rex/core/logger");
882
+ var transformTopics = async (data) => {
883
+ const logger = new import_logger3.CrexLogger();
884
+ const config = (0, import_next_cookies5.getConfigs)();
885
+ const uiLang = ((0, import_headers4.cookies)().get(UI_LANG_KEY)?.value || config.languageSwitcher.default).toLowerCase();
886
+ const items = data.items.map((item) => {
887
+ const type = item.class.labels.filter((item2) => item2.language === EN_LANG)[0].value.toUpperCase();
888
+ let link = `/topics/${item.shortId}`;
889
+ if (config.results.articlePageLayout == "BLOG") {
890
+ link = `/blog/${item.shortId}`;
891
+ } else if (type == RESULT_TYPES.DOCUMENT) {
892
+ link = `/documents/${item.shortId}`;
893
+ }
894
+ let title = "NO TITLE";
895
+ let language = "NO LANGUAGE";
896
+ try {
897
+ if (item.titles) {
898
+ title = item.titles[0].value;
899
+ language = item.titles[0].language;
900
+ } else {
901
+ title = item.labels[0].value;
902
+ language = item.labels[0].language;
903
+ }
904
+ } catch {
905
+ logger.log({
906
+ level: "error",
907
+ message: `No label or title on item ${item.shortId}`
908
+ });
909
+ }
910
+ let renditionUrl = "";
911
+ const renditions = item.renditions.filter((item2) => item2.format == "application/xhtml+xml");
912
+ if (renditions.length > 0 || renditions[0] !== void 0) {
913
+ const filteredLinks = renditions[0].links.filter((renditionItem) => renditionItem.rel == "view");
914
+ if (filteredLinks.length > 0 || filteredLinks[0] !== void 0) {
915
+ renditionUrl = filteredLinks[0].href;
916
+ }
917
+ ;
918
+ }
919
+ ;
920
+ let categoryType = type;
921
+ if (item.applicableForTypes && item.applicableForTypes.length > 0) {
922
+ const splittedContentLang = uiLang.split("-")[0];
923
+ categoryType = item.applicableForTypes[0].labels.find((item2) => item2.language === splittedContentLang)?.value || categoryType;
924
+ }
925
+ return {
926
+ language,
927
+ title,
928
+ type: categoryType,
929
+ localeType: "",
930
+ shortId: item.shortId,
931
+ created: formatDateToLocale(item.created, uiLang),
932
+ disabled: config.results.disabledResults.includes(type),
933
+ link,
934
+ renditionUrl,
935
+ image: null,
936
+ description: null
937
+ };
938
+ });
939
+ return {
940
+ tags: null,
941
+ items,
942
+ pageInfo: data.pageInfo
943
+ };
944
+ };
945
+
946
+ // src/topics.ts
947
+ var TopicsService = class extends BaseService {
948
+ constructor() {
949
+ super("Topics/");
950
+ }
951
+ /**
952
+ * Retrieves a list of topics based on specified criteria.
953
+ *
954
+ * @param options - Options for filtering and paginating the topics list
955
+ * @param options.queries - Optional search query string
956
+ * @param options.page - Optional page number for pagination (defaults to 1)
957
+ * @param options.fields - Optional array of fields to include in the response
958
+ * @param options.filters - Optional array of filter strings to apply
959
+ * @param options.languages - Optional array of language codes to filter by
960
+ * @returns A promise that resolves to the information units response
961
+ * @throws Error if the API request fails
962
+ */
963
+ async getList({
964
+ queries = "",
965
+ page = 1,
966
+ fields = [],
967
+ filters = [],
968
+ languages = [],
969
+ wildcard = WILD_CARD_OPTIONS.BOTH,
970
+ operator = OPERATOR_OPTIONS.AND,
971
+ pageSize = 12
972
+ }) {
973
+ const remainFields = createParams(fields, "Fields");
974
+ const remainFilters = createParams(filters, "Filter");
975
+ const languageParam = `VALUES ?lang { ${languages.map((lang) => `"${lang}"`).join(" ")} } ?s iirds:language ?lang .`;
976
+ const params = [
977
+ { key: "pageSize", value: pageSize.toString() },
978
+ { key: "PageNumber", value: page.toString() },
979
+ { key: "Sort", value: "-created;-score" },
980
+ ...remainFields,
981
+ ...remainFilters
982
+ ];
983
+ if (wildcard.length > 0) {
984
+ params.push({ key: "Operator", value: operator });
985
+ }
986
+ if (wildcard.length > 0) {
987
+ params.push({ key: "wildcard", value: wildcard.toLowerCase() });
988
+ }
989
+ if (languages.length > 0) {
990
+ params.push({ key: "sparqlWhere", value: languageParam });
991
+ }
992
+ if (queries.length > 0) {
993
+ params.push(
994
+ { key: "Query", value: queries }
995
+ );
996
+ }
997
+ return await this.request({
998
+ params,
999
+ transformer: transformTopics
1000
+ });
1001
+ }
1002
+ };
869
1003
  // Annotate the CommonJS export names for ESM import in node:
870
1004
  0 && (module.exports = {
871
1005
  DirectoryNodesService,
872
1006
  DocumentTypesService,
873
1007
  InformationUnitsService,
874
1008
  LanguageService,
875
- RenditionsService
1009
+ RenditionsService,
1010
+ TopicsService
876
1011
  });
877
1012
  //# sourceMappingURL=index.js.map