@dotcms/client 0.0.1-alpha.38 → 0.0.1-alpha.39

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.
Files changed (53) hide show
  1. package/.eslintrc.json +18 -0
  2. package/jest.config.ts +15 -0
  3. package/package.json +3 -15
  4. package/project.json +72 -0
  5. package/src/index.ts +30 -0
  6. package/src/lib/client/content/builders/collection/collection.spec.ts +515 -0
  7. package/src/lib/client/content/builders/collection/{collection.d.ts → collection.ts} +209 -19
  8. package/src/lib/client/content/{content-api.d.ts → content-api.ts} +14 -4
  9. package/src/lib/client/content/shared/{const.d.ts → const.ts} +5 -3
  10. package/src/lib/client/content/shared/{types.d.ts → types.ts} +19 -2
  11. package/src/lib/client/content/shared/{utils.d.ts → utils.ts} +9 -1
  12. package/src/lib/client/models/{index.d.ts → index.ts} +8 -1
  13. package/src/lib/client/models/{types.d.ts → types.ts} +1 -0
  14. package/src/lib/client/sdk-js-client.spec.ts +483 -0
  15. package/src/lib/client/{sdk-js-client.d.ts → sdk-js-client.ts} +181 -15
  16. package/src/lib/editor/listeners/listeners.spec.ts +119 -0
  17. package/src/lib/editor/listeners/listeners.ts +223 -0
  18. package/src/lib/editor/models/{client.model.d.ts → client.model.ts} +19 -16
  19. package/src/lib/editor/models/{editor.model.d.ts → editor.model.ts} +9 -5
  20. package/src/lib/editor/models/{listeners.model.d.ts → listeners.model.ts} +9 -6
  21. package/src/lib/editor/sdk-editor-vtl.ts +31 -0
  22. package/src/lib/editor/sdk-editor.spec.ts +116 -0
  23. package/src/lib/editor/sdk-editor.ts +105 -0
  24. package/src/lib/editor/utils/editor.utils.spec.ts +206 -0
  25. package/src/lib/editor/utils/{editor.utils.d.ts → editor.utils.ts} +121 -22
  26. package/src/lib/query-builder/lucene-syntax/{Equals.d.ts → Equals.ts} +45 -11
  27. package/src/lib/query-builder/lucene-syntax/{Field.d.ts → Field.ts} +13 -5
  28. package/src/lib/query-builder/lucene-syntax/{NotOperand.d.ts → NotOperand.ts} +13 -5
  29. package/src/lib/query-builder/lucene-syntax/{Operand.d.ts → Operand.ts} +21 -7
  30. package/src/lib/query-builder/sdk-query-builder.spec.ts +159 -0
  31. package/src/lib/query-builder/{sdk-query-builder.d.ts → sdk-query-builder.ts} +16 -5
  32. package/src/lib/query-builder/utils/{index.d.ts → index.ts} +49 -12
  33. package/src/lib/utils/graphql/transforms.spec.ts +150 -0
  34. package/src/lib/utils/graphql/transforms.ts +99 -0
  35. package/src/lib/utils/page/common-utils.spec.ts +37 -0
  36. package/src/lib/utils/page/common-utils.ts +64 -0
  37. package/tsconfig.json +22 -0
  38. package/tsconfig.lib.json +13 -0
  39. package/tsconfig.spec.json +9 -0
  40. package/index.cjs.d.ts +0 -1
  41. package/index.cjs.default.js +0 -1
  42. package/index.cjs.js +0 -1953
  43. package/index.cjs.mjs +0 -2
  44. package/index.esm.d.ts +0 -1
  45. package/index.esm.js +0 -1944
  46. package/src/index.d.ts +0 -6
  47. package/src/lib/editor/listeners/listeners.d.ts +0 -50
  48. package/src/lib/editor/sdk-editor-vtl.d.ts +0 -6
  49. package/src/lib/editor/sdk-editor.d.ts +0 -54
  50. package/src/lib/utils/graphql/transforms.d.ts +0 -24
  51. package/src/lib/utils/page/common-utils.d.ts +0 -33
  52. /package/src/lib/query-builder/lucene-syntax/{index.d.ts → index.ts} +0 -0
  53. /package/src/lib/utils/{index.d.ts → index.ts} +0 -0
@@ -1,5 +1,18 @@
1
+ import { Equals } from '../../../../query-builder/lucene-syntax';
2
+ import { QueryBuilder } from '../../../../query-builder/sdk-query-builder';
1
3
  import { ClientOptions } from '../../../sdk-js-client';
2
- import { GetCollectionResponse, BuildQuery, SortBy, GetCollectionError, OnFullfilled, OnRejected } from '../../shared/types';
4
+ import { CONTENT_API_URL } from '../../shared/const';
5
+ import {
6
+ GetCollectionResponse,
7
+ BuildQuery,
8
+ SortBy,
9
+ GetCollectionRawResponse,
10
+ GetCollectionError,
11
+ OnFullfilled,
12
+ OnRejected
13
+ } from '../../shared/types';
14
+ import { sanitizeQueryForContentType } from '../../shared/utils';
15
+
3
16
  /**
4
17
  * Creates a Builder to filter and fetch content from the content API for a specific content type.
5
18
  *
@@ -7,8 +20,22 @@ import { GetCollectionResponse, BuildQuery, SortBy, GetCollectionError, OnFullfi
7
20
  * @class CollectionBuilder
8
21
  * @template T Represents the type of the content type to fetch. Defaults to unknown.
9
22
  */
10
- export declare class CollectionBuilder<T = unknown> {
11
- #private;
23
+ export class CollectionBuilder<T = unknown> {
24
+ #page = 1;
25
+ #limit = 10;
26
+ #depth = 0;
27
+ #render = false;
28
+ #sortBy?: SortBy[];
29
+ #contentType: string;
30
+ #defaultQuery: Equals;
31
+ #query?: Equals;
32
+ #rawQuery?: string;
33
+ #languageId: number | string = 1;
34
+ #draft = false;
35
+
36
+ #serverUrl: string;
37
+ #requestOptions: ClientOptions;
38
+
12
39
  /**
13
40
  * Creates an instance of CollectionBuilder.
14
41
  * @param {ClientOptions} requestOptions Options for the client request.
@@ -16,7 +43,15 @@ export declare class CollectionBuilder<T = unknown> {
16
43
  * @param {string} contentType The content type to fetch.
17
44
  * @memberof CollectionBuilder
18
45
  */
19
- constructor(requestOptions: ClientOptions, serverUrl: string, contentType: string);
46
+ constructor(requestOptions: ClientOptions, serverUrl: string, contentType: string) {
47
+ this.#requestOptions = requestOptions;
48
+ this.#serverUrl = serverUrl;
49
+ this.#contentType = contentType;
50
+
51
+ // Build the default query with the contentType field
52
+ this.#defaultQuery = new QueryBuilder().field('contentType').equals(this.#contentType);
53
+ }
54
+
20
55
  /**
21
56
  * Returns the sort query in the format: field order, field order, ...
22
57
  *
@@ -24,7 +59,10 @@ export declare class CollectionBuilder<T = unknown> {
24
59
  * @private
25
60
  * @memberof CollectionBuilder
26
61
  */
27
- private get sort();
62
+ private get sort() {
63
+ return this.#sortBy?.map((sort) => `${sort.field} ${sort.order}`).join(',');
64
+ }
65
+
28
66
  /**
29
67
  * Returns the offset for pagination.
30
68
  *
@@ -32,7 +70,10 @@ export declare class CollectionBuilder<T = unknown> {
32
70
  * @private
33
71
  * @memberof CollectionBuilder
34
72
  */
35
- private get offset();
73
+ private get offset() {
74
+ return this.#limit * (this.#page - 1);
75
+ }
76
+
36
77
  /**
37
78
  * Returns the full URL for the content API.
38
79
  *
@@ -40,7 +81,10 @@ export declare class CollectionBuilder<T = unknown> {
40
81
  * @private
41
82
  * @memberof CollectionBuilder
42
83
  */
43
- private get url();
84
+ private get url() {
85
+ return `${this.#serverUrl}${CONTENT_API_URL}`;
86
+ }
87
+
44
88
  /**
45
89
  * Returns the current query built.
46
90
  *
@@ -48,7 +92,10 @@ export declare class CollectionBuilder<T = unknown> {
48
92
  * @private
49
93
  * @memberof CollectionBuilder
50
94
  */
51
- private get currentQuery();
95
+ private get currentQuery() {
96
+ return this.#query ?? this.#defaultQuery;
97
+ }
98
+
52
99
  /**
53
100
  * Filters the content by the specified language ID.
54
101
  *
@@ -63,7 +110,12 @@ export declare class CollectionBuilder<T = unknown> {
63
110
  * @return {CollectionBuilder} A CollectionBuilder instance.
64
111
  * @memberof CollectionBuilder
65
112
  */
66
- language(languageId: number | string): this;
113
+ language(languageId: number | string): this {
114
+ this.#languageId = languageId;
115
+
116
+ return this;
117
+ }
118
+
67
119
  /**
68
120
  * Setting this to true will server side render (using velocity) any widgets that are returned by the content query.
69
121
  *
@@ -72,7 +124,12 @@ export declare class CollectionBuilder<T = unknown> {
72
124
  * @return {CollectionBuilder} A CollectionBuilder instance.
73
125
  * @memberof CollectionBuilder
74
126
  */
75
- render(): this;
127
+ render(): this {
128
+ this.#render = true;
129
+
130
+ return this;
131
+ }
132
+
76
133
  /**
77
134
  * Sorts the content by the specified fields and orders.
78
135
  *
@@ -88,7 +145,12 @@ export declare class CollectionBuilder<T = unknown> {
88
145
  * @return {CollectionBuilder} A CollectionBuilder instance.
89
146
  * @memberof CollectionBuilder
90
147
  */
91
- sortBy(sortBy: SortBy[]): this;
148
+ sortBy(sortBy: SortBy[]): this {
149
+ this.#sortBy = sortBy;
150
+
151
+ return this;
152
+ }
153
+
92
154
  /**
93
155
  * Sets the maximum amount of content to fetch.
94
156
  *
@@ -96,7 +158,12 @@ export declare class CollectionBuilder<T = unknown> {
96
158
  * @return {CollectionBuilder} A CollectionBuilder instance.
97
159
  * @memberof CollectionBuilder
98
160
  */
99
- limit(limit: number): this;
161
+ limit(limit: number): this {
162
+ this.#limit = limit;
163
+
164
+ return this;
165
+ }
166
+
100
167
  /**
101
168
  * Sets the page number to fetch.
102
169
  *
@@ -104,7 +171,12 @@ export declare class CollectionBuilder<T = unknown> {
104
171
  * @return {CollectionBuilder} A CollectionBuilder instance.
105
172
  * @memberof CollectionBuilder
106
173
  */
107
- page(page: number): this;
174
+ page(page: number): this {
175
+ this.#page = page;
176
+
177
+ return this;
178
+ }
179
+
108
180
  /**
109
181
  * Filters the content by a Lucene query string.
110
182
  *
@@ -113,6 +185,7 @@ export declare class CollectionBuilder<T = unknown> {
113
185
  * @memberof CollectionBuilder
114
186
  */
115
187
  query(query: string): this;
188
+
116
189
  /**
117
190
  * Filters the content by building a query using a QueryBuilder function.
118
191
  *
@@ -130,6 +203,33 @@ export declare class CollectionBuilder<T = unknown> {
130
203
  * @memberof CollectionBuilder
131
204
  */
132
205
  query(buildQuery: BuildQuery): this;
206
+ query(arg: unknown): this {
207
+ if (typeof arg === 'string') {
208
+ this.#rawQuery = arg;
209
+
210
+ return this;
211
+ }
212
+
213
+ if (typeof arg !== 'function') {
214
+ throw new Error(
215
+ `Parameter for query method should be a buildQuery function or a string.\nExample:\nclient.content.getCollection('Activity').query((queryBuilder) => queryBuilder.field('title').equals('Hello World'))\nor\nclient.content.getCollection('Activity').query('+Activity.title:"Hello World"') \nSee documentation for more information.`
216
+ );
217
+ }
218
+
219
+ const builtQuery = arg(new QueryBuilder());
220
+
221
+ // This can be use in Javascript so we cannot rely on the type checking
222
+ if (builtQuery instanceof Equals) {
223
+ this.#query = builtQuery.raw(this.currentQuery.build());
224
+ } else {
225
+ throw new Error(
226
+ 'Provided query is not valid. A query should end in an equals method call.\nExample:\n(queryBuilder) => queryBuilder.field("title").equals("Hello World")\nSee documentation for more information.'
227
+ );
228
+ }
229
+
230
+ return this;
231
+ }
232
+
133
233
  /**
134
234
  * Retrieves draft content.
135
235
  * @example
@@ -145,7 +245,12 @@ export declare class CollectionBuilder<T = unknown> {
145
245
  * @return {CollectionBuilder} A CollectionBuilder instance.
146
246
  * @memberof CollectionBuilder
147
247
  */
148
- draft(): this;
248
+ draft(): this {
249
+ this.#draft = true;
250
+
251
+ return this;
252
+ }
253
+
149
254
  /**
150
255
  * Filters the content by a variant ID for [Experiments](https://www.dotcms.com/docs/latest/experiments-and-a-b-testing)
151
256
  *
@@ -165,7 +270,12 @@ export declare class CollectionBuilder<T = unknown> {
165
270
  * @return {CollectionBuilder} A CollectionBuilder instance.
166
271
  * @memberof CollectionBuilder
167
272
  */
168
- variant(variantId: string): this;
273
+ variant(variantId: string): this {
274
+ this.#query = this.currentQuery.field('variant').equals(variantId);
275
+
276
+ return this;
277
+ }
278
+
169
279
  /**
170
280
  * Sets the depth of the relationships of the content.
171
281
  * Specifies the depth of related content to return in the results.
@@ -186,7 +296,16 @@ export declare class CollectionBuilder<T = unknown> {
186
296
  * @return {CollectionBuilder} A CollectionBuilder instance.
187
297
  * @memberof CollectionBuilder
188
298
  */
189
- depth(depth: number): this;
299
+ depth(depth: number): this {
300
+ if (depth < 0 || depth > 3) {
301
+ throw new Error('Depth value must be between 0 and 3');
302
+ }
303
+
304
+ this.#depth = depth;
305
+
306
+ return this;
307
+ }
308
+
190
309
  /**
191
310
  * Executes the fetch and returns a promise that resolves to the content or rejects with an error.
192
311
  *
@@ -205,7 +324,30 @@ export declare class CollectionBuilder<T = unknown> {
205
324
  * @return {Promise<GetCollectionResponse<T> | GetCollectionError>} A promise that resolves to the content or rejects with an error.
206
325
  * @memberof CollectionBuilder
207
326
  */
208
- then(onfulfilled?: OnFullfilled<T>, onrejected?: OnRejected): Promise<GetCollectionResponse<T> | GetCollectionError>;
327
+ then(
328
+ onfulfilled?: OnFullfilled<T>,
329
+ onrejected?: OnRejected
330
+ ): Promise<GetCollectionResponse<T> | GetCollectionError> {
331
+ return this.fetch().then(async (response) => {
332
+ const data = await response.json();
333
+ if (response.ok) {
334
+ const formattedResponse = this.formatResponse<T>(data);
335
+
336
+ const finalResponse =
337
+ typeof onfulfilled === 'function'
338
+ ? onfulfilled(formattedResponse)
339
+ : formattedResponse;
340
+
341
+ return finalResponse;
342
+ } else {
343
+ return {
344
+ status: response.status,
345
+ ...data
346
+ };
347
+ }
348
+ }, onrejected);
349
+ }
350
+
209
351
  /**
210
352
  * Formats the response to the desired format.
211
353
  *
@@ -214,7 +356,25 @@ export declare class CollectionBuilder<T = unknown> {
214
356
  * @return {GetCollectionResponse<T>} The formatted response.
215
357
  * @memberof CollectionBuilder
216
358
  */
217
- private formatResponse;
359
+ private formatResponse<T>(data: GetCollectionRawResponse<T>): GetCollectionResponse<T> {
360
+ const contentlets = data.entity.jsonObjectView.contentlets;
361
+ const total = data.entity.resultsSize;
362
+
363
+ const mappedResponse: GetCollectionResponse<T> = {
364
+ contentlets,
365
+ total,
366
+ page: this.#page,
367
+ size: contentlets.length
368
+ };
369
+
370
+ return this.#sortBy
371
+ ? {
372
+ ...mappedResponse,
373
+ sortedBy: this.#sortBy
374
+ }
375
+ : mappedResponse;
376
+ }
377
+
218
378
  /**
219
379
  * Calls the content API to fetch the content.
220
380
  *
@@ -222,5 +382,35 @@ export declare class CollectionBuilder<T = unknown> {
222
382
  * @return {Promise<Response>} The fetch response.
223
383
  * @memberof CollectionBuilder
224
384
  */
225
- private fetch;
385
+ private fetch(): Promise<Response> {
386
+ const finalQuery = this.currentQuery
387
+ .field('languageId')
388
+ .equals(this.#languageId.toString())
389
+ .field('live')
390
+ .equals((!this.#draft).toString())
391
+ .build();
392
+
393
+ const sanitizedQuery = sanitizeQueryForContentType(finalQuery, this.#contentType);
394
+
395
+ const query = this.#rawQuery ? `${sanitizedQuery} ${this.#rawQuery}` : sanitizedQuery;
396
+
397
+ return fetch(this.url, {
398
+ ...this.#requestOptions,
399
+ method: 'POST',
400
+ headers: {
401
+ ...this.#requestOptions.headers,
402
+ 'Content-Type': 'application/json'
403
+ },
404
+ body: JSON.stringify({
405
+ query,
406
+ render: this.#render,
407
+ sort: this.sort,
408
+ limit: this.#limit,
409
+ offset: this.offset,
410
+ depth: this.#depth
411
+ //userId: This exist but we currently don't use it
412
+ //allCategoriesInfo: This exist but we currently don't use it
413
+ })
414
+ });
415
+ }
226
416
  }
@@ -1,5 +1,7 @@
1
1
  import { CollectionBuilder } from './builders/collection/collection';
2
+
2
3
  import { ClientOptions } from '../sdk-js-client';
4
+
3
5
  /**
4
6
  * Creates a builder to filter and fetch a collection of content items.
5
7
  * @param contentType - The content type to retrieve.
@@ -52,14 +54,20 @@ import { ClientOptions } from '../sdk-js-client';
52
54
  * });
53
55
  * ```
54
56
  */
55
- export declare class Content {
56
- #private;
57
+ export class Content {
58
+ #requestOptions: ClientOptions;
59
+ #serverUrl: string;
60
+
57
61
  /**
58
62
  * Creates an instance of Content.
59
63
  * @param {ClientOptions} requestOptions - The options for the client request.
60
64
  * @param {string} serverUrl - The server URL.
61
65
  */
62
- constructor(requestOptions: ClientOptions, serverUrl: string);
66
+ constructor(requestOptions: ClientOptions, serverUrl: string) {
67
+ this.#requestOptions = requestOptions;
68
+ this.#serverUrl = serverUrl;
69
+ }
70
+
63
71
  /**
64
72
  * Takes a content type and returns a builder to filter and fetch the collection.
65
73
  * @param {string} contentType - The content type to get the collection.
@@ -125,5 +133,7 @@ export declare class Content {
125
133
  * ```
126
134
  *
127
135
  */
128
- getCollection<T = unknown>(contentType: string): CollectionBuilder<T>;
136
+ getCollection<T = unknown>(contentType: string): CollectionBuilder<T> {
137
+ return new CollectionBuilder<T>(this.#requestOptions, this.#serverUrl, contentType);
138
+ }
129
139
  }
@@ -1,13 +1,15 @@
1
1
  /**
2
2
  * Default variant identifier used in the application.
3
3
  */
4
- export declare const DEFAULT_VARIANT_ID = "DEFAULT";
4
+ export const DEFAULT_VARIANT_ID = 'DEFAULT';
5
+
5
6
  /**
6
7
  * Fields that should not be formatted when sanitizing the query.
7
8
  * These fields are essential for maintaining the integrity of the content type.
8
9
  */
9
- export declare const CONTENT_TYPE_MAIN_FIELDS: string[];
10
+ export const CONTENT_TYPE_MAIN_FIELDS: string[] = ['live', 'variant', 'contentType', 'languageId'];
11
+
10
12
  /**
11
13
  * URL endpoint for the content API search functionality.
12
14
  */
13
- export declare const CONTENT_API_URL = "/api/content/_search";
15
+ export const CONTENT_API_URL = '/api/content/_search';
@@ -1,5 +1,6 @@
1
1
  import { Equals } from '../../../query-builder/lucene-syntax';
2
2
  import { QueryBuilder } from '../../../query-builder/sdk-query-builder';
3
+
3
4
  /**
4
5
  * Model to sort by fields.
5
6
  */
@@ -13,6 +14,7 @@ export type SortBy = {
13
14
  */
14
15
  order: 'asc' | 'desc';
15
16
  };
17
+
16
18
  /**
17
19
  * Callback to build a query.
18
20
  *
@@ -21,6 +23,7 @@ export type SortBy = {
21
23
  * @returns {Equals} The built query.
22
24
  */
23
25
  export type BuildQuery = (qb: QueryBuilder) => Equals;
26
+
24
27
  /**
25
28
  * Main fields of a Contentlet (Inherited from the Content Type).
26
29
  */
@@ -57,12 +60,14 @@ export interface ContentTypeMainFields {
57
60
  contentTypeIcon: string;
58
61
  variant: string;
59
62
  }
63
+
60
64
  /**
61
65
  * The contentlet has the main fields and the custom fields of the content type.
62
66
  *
63
67
  * @template T - The custom fields of the content type.
64
68
  */
65
69
  export type Contentlet<T> = T & ContentTypeMainFields;
70
+
66
71
  /**
67
72
  * Callback for a fulfilled promise.
68
73
  *
@@ -71,7 +76,13 @@ export type Contentlet<T> = T & ContentTypeMainFields;
71
76
  * @param {GetCollectionResponse<T>} value - The response value.
72
77
  * @returns {GetCollectionResponse<T> | PromiseLike<GetCollectionResponse<T>> | void} The processed response or a promise.
73
78
  */
74
- export type OnFullfilled<T> = ((value: GetCollectionResponse<T>) => GetCollectionResponse<T> | PromiseLike<GetCollectionResponse<T>> | void) | undefined | null;
79
+ export type OnFullfilled<T> =
80
+ | ((
81
+ value: GetCollectionResponse<T>
82
+ ) => GetCollectionResponse<T> | PromiseLike<GetCollectionResponse<T>> | void)
83
+ | undefined
84
+ | null;
85
+
75
86
  /**
76
87
  * Callback for a rejected promise.
77
88
  *
@@ -79,7 +90,11 @@ export type OnFullfilled<T> = ((value: GetCollectionResponse<T>) => GetCollectio
79
90
  * @param {GetCollectionError} error - The error object.
80
91
  * @returns {GetCollectionError | PromiseLike<GetCollectionError> | void} The processed error or a promise.
81
92
  */
82
- export type OnRejected = ((error: GetCollectionError) => GetCollectionError | PromiseLike<GetCollectionError> | void) | undefined | null;
93
+ export type OnRejected =
94
+ | ((error: GetCollectionError) => GetCollectionError | PromiseLike<GetCollectionError> | void)
95
+ | undefined
96
+ | null;
97
+
83
98
  /**
84
99
  * Response of the get collection method.
85
100
  *
@@ -107,6 +122,7 @@ export interface GetCollectionResponse<T> {
107
122
  */
108
123
  sortedBy?: SortBy[];
109
124
  }
125
+
110
126
  /**
111
127
  * Raw response of the get collection method.
112
128
  *
@@ -126,6 +142,7 @@ export interface GetCollectionRawResponse<T> {
126
142
  resultsSize: number;
127
143
  };
128
144
  }
145
+
129
146
  /**
130
147
  * Error object for the get collection method.
131
148
  */
@@ -1,3 +1,5 @@
1
+ import { CONTENT_TYPE_MAIN_FIELDS } from './const';
2
+
1
3
  /**
2
4
  * @description
3
5
  * Sanitizes the query for the given content type.
@@ -17,4 +19,10 @@
17
19
  * @param {string} contentType - The content type to be used for formatting the fields.
18
20
  * @returns {string} The sanitized query string.
19
21
  */
20
- export declare function sanitizeQueryForContentType(query: string, contentType: string): string;
22
+ export function sanitizeQueryForContentType(query: string, contentType: string): string {
23
+ return query.replace(/\+([^+:]*?):/g, (original, field) => {
24
+ return !CONTENT_TYPE_MAIN_FIELDS.includes(field) // Fields that are not content type fields
25
+ ? `+${contentType}.${field}:` // Should have this format: +contentTypeVar.field:
26
+ : original; // Return the field if it is a content type field
27
+ });
28
+ }
@@ -9,4 +9,11 @@
9
9
  * @property {string} 502 - Bad Gateway. Try again later.
10
10
  * @property {string} 503 - Service Unavailable. Try again later.
11
11
  */
12
- export declare const ErrorMessages: Record<number, string>;
12
+ export const ErrorMessages: Record<number, string> = {
13
+ 401: 'Unauthorized. Check the token and try again.',
14
+ 403: 'Forbidden. Check the permissions and try again.',
15
+ 404: 'Not Found. Check the URL and try again.',
16
+ 500: 'Internal Server Error. Try again later.',
17
+ 502: 'Bad Gateway. Try again later.',
18
+ 503: 'Service Unavailable. Try again later.'
19
+ };
@@ -9,5 +9,6 @@
9
9
  export type DotcmsClientListener = {
10
10
  action: string;
11
11
  event: string;
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
13
  callback: (...args: any[]) => void;
13
14
  };