@c-rex/services 0.1.2 → 0.1.4

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
@@ -6,10 +6,6 @@ type QueryParams = {
6
6
  key: string;
7
7
  value: string;
8
8
  };
9
- type FileRenditionType = {
10
- format: string;
11
- link: string;
12
- };
13
9
 
14
10
  /**
15
11
  * Base service class that provides common functionality for API interactions.
@@ -44,30 +40,87 @@ declare class BaseService {
44
40
  }): Promise<T>;
45
41
  }
46
42
 
43
+ /**
44
+ * Service for interacting with renditions in the API.
45
+ * Provides methods to retrieve and process different types of renditions.
46
+ */
47
47
  declare class RenditionsService extends BaseService {
48
48
  constructor();
49
- getHTMLRendition(renditions: informationUnitsRenditions[]): Promise<string>;
50
- getFileRenditions: (renditions: informationUnitsRenditions[]) => {
51
- filesToDownload: FileRenditionType[];
52
- filesToOpen: FileRenditionType[];
53
- };
49
+ /**
50
+ * Retrieves the HTML rendition from a list of renditions.
51
+ * Filters for renditions with format 'application/xhtml+xml' and rel 'view'.
52
+ *
53
+ * @param renditions - Array of rendition objects to process
54
+ * @returns A promise that resolves to the HTML content as a string, or empty string if no suitable rendition is found
55
+ * @throws Error if the API request fails
56
+ */
57
+ getHTMLRendition({ renditions }: {
58
+ renditions: informationUnitsRenditions[];
59
+ }): Promise<string>;
54
60
  }
55
61
 
62
+ /**
63
+ * Service for interacting with directory nodes in the API.
64
+ * Provides methods to retrieve directory node information.
65
+ */
56
66
  declare class DirectoryNodesService extends BaseService {
57
67
  constructor();
68
+ /**
69
+ * Retrieves a specific directory node by its ID.
70
+ *
71
+ * @param id - The unique identifier of the directory node
72
+ * @returns A promise that resolves to the directory node data
73
+ * @throws Error if the API request fails
74
+ */
58
75
  getItem(id: string): Promise<DirectoryNodes>;
76
+ /**
77
+ * Retrieves a list of directory nodes based on specified filters.
78
+ *
79
+ * @param options - Options for filtering the directory nodes list
80
+ * @param options.filters - Optional array of filter strings to apply
81
+ * @returns A promise that resolves to the directory nodes response
82
+ * @throws Error if the API request fails
83
+ */
59
84
  getList({ filters, }: {
60
85
  filters?: string[];
61
86
  }): Promise<DirectoryNodesResponse>;
62
87
  }
63
88
 
89
+ /**
90
+ * Service for interacting with document types in the API.
91
+ * Provides methods to retrieve document type information.
92
+ */
64
93
  declare class DocumentTypesService extends BaseService {
65
94
  constructor();
95
+ /**
96
+ * Retrieves document type labels for the specified fields.
97
+ * The labels are restricted to English language (EN-us).
98
+ *
99
+ * @param fields - Array of field names to retrieve labels for
100
+ * @returns A promise that resolves to an array of label strings
101
+ * @throws Error if the API request fails
102
+ */
66
103
  getLabels(fields: string[]): Promise<string[]>;
67
104
  }
68
105
 
106
+ /**
107
+ * Service for interacting with information units in the API.
108
+ * Provides methods to retrieve and search information units.
109
+ */
69
110
  declare class InformationUnitsService extends BaseService {
70
111
  constructor();
112
+ /**
113
+ * Retrieves a list of information units based on specified criteria.
114
+ *
115
+ * @param options - Options for filtering and paginating the information units list
116
+ * @param options.queries - Optional search query string
117
+ * @param options.page - Optional page number for pagination (defaults to 1)
118
+ * @param options.fields - Optional array of fields to include in the response
119
+ * @param options.filters - Optional array of filter strings to apply
120
+ * @param options.languages - Optional array of language codes to filter by
121
+ * @returns A promise that resolves to the information units response
122
+ * @throws Error if the API request fails
123
+ */
71
124
  getList({ queries, page, fields, filters, languages }: {
72
125
  queries?: string;
73
126
  page?: number;
@@ -75,16 +128,46 @@ declare class InformationUnitsService extends BaseService {
75
128
  fields?: string[];
76
129
  languages?: string[];
77
130
  }): Promise<informationUnitsResponse>;
131
+ /**
132
+ * Retrieves a specific information unit by its ID.
133
+ * Includes renditions, directory nodes, version information, titles, languages, and labels.
134
+ *
135
+ * @param options - Options for retrieving the information unit
136
+ * @param options.id - The unique identifier of the information unit
137
+ * @returns A promise that resolves to the information unit data
138
+ * @throws Error if the API request fails
139
+ */
78
140
  getItem({ id }: {
79
141
  id: string;
80
142
  }): Promise<informationUnitsItems>;
81
- getSuggestions({ query }: {
143
+ /**
144
+ * Retrieves autocomplete suggestions based on a query prefix.
145
+ *
146
+ * @param options - Options for retrieving suggestions
147
+ * @param options.query - The query prefix to get suggestions for
148
+ * @param options.language - The language of the suggestions
149
+ * @returns A promise that resolves to an array of suggestion strings
150
+ * @throws Error if the API request fails
151
+ */
152
+ getSuggestions({ query, language }: {
82
153
  query: string;
154
+ language: string;
83
155
  }): Promise<string[]>;
84
156
  }
85
157
 
158
+ /**
159
+ * Service for interacting with language-related functionality in the API.
160
+ * Provides methods to retrieve language and country information.
161
+ */
86
162
  declare class LanguageService extends BaseService {
87
- constructor(endpoint: string);
163
+ constructor();
164
+ /**
165
+ * Retrieves a list of available languages and their associated countries.
166
+ * Transforms the API response to include language code, country code, and original value.
167
+ *
168
+ * @returns A promise that resolves to an array of language and country objects
169
+ * @throws Error if the API request fails
170
+ */
88
171
  getLanguagesAndCountries(): Promise<LanguageAndCountries[]>;
89
172
  }
90
173
 
package/dist/index.d.ts CHANGED
@@ -6,10 +6,6 @@ type QueryParams = {
6
6
  key: string;
7
7
  value: string;
8
8
  };
9
- type FileRenditionType = {
10
- format: string;
11
- link: string;
12
- };
13
9
 
14
10
  /**
15
11
  * Base service class that provides common functionality for API interactions.
@@ -44,30 +40,87 @@ declare class BaseService {
44
40
  }): Promise<T>;
45
41
  }
46
42
 
43
+ /**
44
+ * Service for interacting with renditions in the API.
45
+ * Provides methods to retrieve and process different types of renditions.
46
+ */
47
47
  declare class RenditionsService extends BaseService {
48
48
  constructor();
49
- getHTMLRendition(renditions: informationUnitsRenditions[]): Promise<string>;
50
- getFileRenditions: (renditions: informationUnitsRenditions[]) => {
51
- filesToDownload: FileRenditionType[];
52
- filesToOpen: FileRenditionType[];
53
- };
49
+ /**
50
+ * Retrieves the HTML rendition from a list of renditions.
51
+ * Filters for renditions with format 'application/xhtml+xml' and rel 'view'.
52
+ *
53
+ * @param renditions - Array of rendition objects to process
54
+ * @returns A promise that resolves to the HTML content as a string, or empty string if no suitable rendition is found
55
+ * @throws Error if the API request fails
56
+ */
57
+ getHTMLRendition({ renditions }: {
58
+ renditions: informationUnitsRenditions[];
59
+ }): Promise<string>;
54
60
  }
55
61
 
62
+ /**
63
+ * Service for interacting with directory nodes in the API.
64
+ * Provides methods to retrieve directory node information.
65
+ */
56
66
  declare class DirectoryNodesService extends BaseService {
57
67
  constructor();
68
+ /**
69
+ * Retrieves a specific directory node by its ID.
70
+ *
71
+ * @param id - The unique identifier of the directory node
72
+ * @returns A promise that resolves to the directory node data
73
+ * @throws Error if the API request fails
74
+ */
58
75
  getItem(id: string): Promise<DirectoryNodes>;
76
+ /**
77
+ * Retrieves a list of directory nodes based on specified filters.
78
+ *
79
+ * @param options - Options for filtering the directory nodes list
80
+ * @param options.filters - Optional array of filter strings to apply
81
+ * @returns A promise that resolves to the directory nodes response
82
+ * @throws Error if the API request fails
83
+ */
59
84
  getList({ filters, }: {
60
85
  filters?: string[];
61
86
  }): Promise<DirectoryNodesResponse>;
62
87
  }
63
88
 
89
+ /**
90
+ * Service for interacting with document types in the API.
91
+ * Provides methods to retrieve document type information.
92
+ */
64
93
  declare class DocumentTypesService extends BaseService {
65
94
  constructor();
95
+ /**
96
+ * Retrieves document type labels for the specified fields.
97
+ * The labels are restricted to English language (EN-us).
98
+ *
99
+ * @param fields - Array of field names to retrieve labels for
100
+ * @returns A promise that resolves to an array of label strings
101
+ * @throws Error if the API request fails
102
+ */
66
103
  getLabels(fields: string[]): Promise<string[]>;
67
104
  }
68
105
 
106
+ /**
107
+ * Service for interacting with information units in the API.
108
+ * Provides methods to retrieve and search information units.
109
+ */
69
110
  declare class InformationUnitsService extends BaseService {
70
111
  constructor();
112
+ /**
113
+ * Retrieves a list of information units based on specified criteria.
114
+ *
115
+ * @param options - Options for filtering and paginating the information units list
116
+ * @param options.queries - Optional search query string
117
+ * @param options.page - Optional page number for pagination (defaults to 1)
118
+ * @param options.fields - Optional array of fields to include in the response
119
+ * @param options.filters - Optional array of filter strings to apply
120
+ * @param options.languages - Optional array of language codes to filter by
121
+ * @returns A promise that resolves to the information units response
122
+ * @throws Error if the API request fails
123
+ */
71
124
  getList({ queries, page, fields, filters, languages }: {
72
125
  queries?: string;
73
126
  page?: number;
@@ -75,16 +128,46 @@ declare class InformationUnitsService extends BaseService {
75
128
  fields?: string[];
76
129
  languages?: string[];
77
130
  }): Promise<informationUnitsResponse>;
131
+ /**
132
+ * Retrieves a specific information unit by its ID.
133
+ * Includes renditions, directory nodes, version information, titles, languages, and labels.
134
+ *
135
+ * @param options - Options for retrieving the information unit
136
+ * @param options.id - The unique identifier of the information unit
137
+ * @returns A promise that resolves to the information unit data
138
+ * @throws Error if the API request fails
139
+ */
78
140
  getItem({ id }: {
79
141
  id: string;
80
142
  }): Promise<informationUnitsItems>;
81
- getSuggestions({ query }: {
143
+ /**
144
+ * Retrieves autocomplete suggestions based on a query prefix.
145
+ *
146
+ * @param options - Options for retrieving suggestions
147
+ * @param options.query - The query prefix to get suggestions for
148
+ * @param options.language - The language of the suggestions
149
+ * @returns A promise that resolves to an array of suggestion strings
150
+ * @throws Error if the API request fails
151
+ */
152
+ getSuggestions({ query, language }: {
82
153
  query: string;
154
+ language: string;
83
155
  }): Promise<string[]>;
84
156
  }
85
157
 
158
+ /**
159
+ * Service for interacting with language-related functionality in the API.
160
+ * Provides methods to retrieve language and country information.
161
+ */
86
162
  declare class LanguageService extends BaseService {
87
- constructor(endpoint: string);
163
+ constructor();
164
+ /**
165
+ * Retrieves a list of available languages and their associated countries.
166
+ * Transforms the API response to include language code, country code, and original value.
167
+ *
168
+ * @returns A promise that resolves to an array of language and country objects
169
+ * @throws Error if the API request fails
170
+ */
88
171
  getLanguagesAndCountries(): Promise<LanguageAndCountries[]>;
89
172
  }
90
173