@dotcms/client 1.2.0-next.2 → 1.2.0-next.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/index.cjs.js CHANGED
@@ -147,6 +147,362 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
147
147
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
148
148
  };
149
149
 
150
+ /**
151
+ * Utility functions for AI search parameter mapping and processing
152
+ */
153
+ /**
154
+ * Appends mapped parameters to URLSearchParams based on a mapping configuration.
155
+ * Only includes parameters that have defined values.
156
+ *
157
+ * @param searchParams - The URLSearchParams object to append to
158
+ * @param sourceObject - The source object containing values
159
+ * @param mapping - Array of [targetKey, sourceKey] pairs for parameter mapping, or [key] to use same key
160
+ * @example
161
+ * ```typescript
162
+ * const params = new URLSearchParams();
163
+ * const query = { limit: 10, offset: 0, siteId: 'default', indexName: 'content' };
164
+ * const mapping = [
165
+ * ['searchLimit', 'limit'], // Maps limit -> searchLimit
166
+ * ['searchOffset', 'offset'], // Maps offset -> searchOffset
167
+ * ['site', 'siteId'], // Maps siteId -> site
168
+ * ['indexName'] // Uses indexName -> indexName (same key)
169
+ * ];
170
+ * appendMappedParams(params, query, mapping);
171
+ * // Results in: searchLimit=10&searchOffset=0&site=default&indexName=content
172
+ * ```
173
+ */
174
+ function appendMappedParams(searchParams, sourceObject, mapping) {
175
+ mapping.forEach((item) => {
176
+ const targetKey = item[0];
177
+ const sourceKey = item[1] ?? item[0];
178
+ const value = sourceObject[sourceKey];
179
+ if (value !== undefined) {
180
+ searchParams.append(targetKey, String(value));
181
+ }
182
+ });
183
+ }
184
+
185
+ var _BaseApiClient_requestOptions, _BaseApiClient_config, _BaseApiClient_httpClient;
186
+ /**
187
+ * Base class for all DotCMS API clients.
188
+ * Provides common constructor parameters and properties that all API clients need.
189
+ * Uses JavaScript private fields (#) for true runtime privacy.
190
+ */
191
+ class BaseApiClient {
192
+ /**
193
+ * Creates a new API client instance.
194
+ *
195
+ * @param {DotCMSClientConfig} config - Configuration options for the DotCMS client
196
+ * @param {DotRequestOptions} requestOptions - Options for fetch requests including authorization headers
197
+ * @param {DotHttpClient} httpClient - HTTP client for making requests
198
+ */
199
+ constructor(config, requestOptions = {}, httpClient) {
200
+ /**
201
+ * Request options including authorization headers.
202
+ * @private
203
+ */
204
+ _BaseApiClient_requestOptions.set(this, void 0);
205
+ /**
206
+ * DotCMS client configuration.
207
+ * @private
208
+ */
209
+ _BaseApiClient_config.set(this, void 0);
210
+ /**
211
+ * HTTP client for making requests.
212
+ * @private
213
+ */
214
+ _BaseApiClient_httpClient.set(this, void 0);
215
+ __classPrivateFieldSet(this, _BaseApiClient_config, {
216
+ siteId: '',
217
+ ...config
218
+ }, "f");
219
+ __classPrivateFieldSet(this, _BaseApiClient_requestOptions, {
220
+ ...requestOptions
221
+ }, "f");
222
+ __classPrivateFieldSet(this, _BaseApiClient_httpClient, httpClient, "f");
223
+ }
224
+ /**
225
+ * Gets the request options including authorization headers.
226
+ * @protected
227
+ */
228
+ get requestOptions() {
229
+ return __classPrivateFieldGet(this, _BaseApiClient_requestOptions, "f");
230
+ }
231
+ /**
232
+ * Gets the DotCMS client configuration.
233
+ * @protected
234
+ */
235
+ get config() {
236
+ return __classPrivateFieldGet(this, _BaseApiClient_config, "f");
237
+ }
238
+ /**
239
+ * Gets the HTTP client for making requests.
240
+ * @protected
241
+ */
242
+ get httpClient() {
243
+ return __classPrivateFieldGet(this, _BaseApiClient_httpClient, "f");
244
+ }
245
+ /**
246
+ * Gets the DotCMS URL from config.
247
+ * @protected
248
+ */
249
+ get dotcmsUrl() {
250
+ return __classPrivateFieldGet(this, _BaseApiClient_config, "f").dotcmsUrl;
251
+ }
252
+ /**
253
+ * Gets the site ID from config.
254
+ * @protected
255
+ */
256
+ get siteId() {
257
+ return __classPrivateFieldGet(this, _BaseApiClient_config, "f").siteId || '';
258
+ }
259
+ }
260
+ _BaseApiClient_requestOptions = new WeakMap(), _BaseApiClient_config = new WeakMap(), _BaseApiClient_httpClient = new WeakMap();
261
+
262
+ /**
263
+ * Default values for AI configuration
264
+ */
265
+ const DEFAULT_AI_CONFIG = {
266
+ threshold: 0.5,
267
+ distanceFunction: types.DISTANCE_FUNCTIONS.cosine,
268
+ responseLength: 1024
269
+ };
270
+ /**
271
+ * Default values for search query
272
+ */
273
+ const DEFAULT_QUERY = {
274
+ limit: 1000,
275
+ offset: 0,
276
+ indexName: 'default'
277
+ };
278
+
279
+ var _AISearch_params, _AISearch_prompt, _AISearch_indexName;
280
+ /**
281
+ * Class for executing AI searches.
282
+ *
283
+ * @template T - The type of the contentlet.
284
+ * @param config - The configuration for the client.
285
+ * @param requestOptions - The request options for the client.
286
+ * @param httpClient - The HTTP client for the client.
287
+ * @param params - The parameters for the search.
288
+ * @param prompt - The prompt for the search.
289
+ */
290
+ class AISearch extends BaseApiClient {
291
+ constructor(config, requestOptions, httpClient, prompt, indexName, params = {}) {
292
+ super(config, requestOptions, httpClient);
293
+ _AISearch_params.set(this, void 0);
294
+ _AISearch_prompt.set(this, void 0);
295
+ _AISearch_indexName.set(this, void 0);
296
+ __classPrivateFieldSet(this, _AISearch_params, params, "f");
297
+ __classPrivateFieldSet(this, _AISearch_prompt, prompt, "f");
298
+ __classPrivateFieldSet(this, _AISearch_indexName, indexName, "f");
299
+ }
300
+ /**
301
+ * Executes the AI search and returns a promise with the search results.
302
+ *
303
+ * @param onfulfilled - Callback function to handle the search results.
304
+ * @param onrejected - Callback function to handle the search error.
305
+ * @returns Promise with the search results or the error.
306
+ * @example
307
+ * ```typescript
308
+ * const results = await client.ai.search('machine learning articles', 'content_index', {
309
+ * query: {
310
+ * limit: 20,
311
+ * contentType: 'BlogPost',
312
+ * languageId: '1' // or 1
313
+ * },
314
+ * config: {
315
+ * threshold: 0.7
316
+ * }
317
+ * });
318
+ * ```
319
+ * @example
320
+ * ```typescript
321
+ * client.ai.search('machine learning articles', 'content_index', {
322
+ * query: {
323
+ * limit: 20,
324
+ * contentType: 'BlogPost',
325
+ * languageId: '1' // or 1
326
+ * },
327
+ * config: {
328
+ * threshold: 0.7
329
+ * }
330
+ * }).then((results) => {
331
+ * console.log(results);
332
+ * }).catch((error) => {
333
+ * console.error(error);
334
+ * });
335
+ * ```
336
+ */
337
+ then(onfulfilled, onrejected) {
338
+ return this.fetch().then((data) => {
339
+ if (typeof onfulfilled === 'function') {
340
+ const result = onfulfilled(data);
341
+ // Ensure we always return a value, fallback to formattedResponse if callback returns undefined
342
+ return result ?? data;
343
+ }
344
+ return data;
345
+ }, (error) => {
346
+ // Wrap error in DotCMSContentError
347
+ let contentError;
348
+ if (error instanceof types.DotHttpError) {
349
+ contentError = new types.DotErrorAISearch({
350
+ message: `AI Search failed (fetch): ${error.message}`,
351
+ httpError: error,
352
+ params: __classPrivateFieldGet(this, _AISearch_params, "f"),
353
+ prompt: __classPrivateFieldGet(this, _AISearch_prompt, "f"),
354
+ indexName: __classPrivateFieldGet(this, _AISearch_indexName, "f")
355
+ });
356
+ }
357
+ else {
358
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
359
+ contentError = new types.DotErrorAISearch({
360
+ message: `AI Search failed (fetch): ${errorMessage}`,
361
+ httpError: undefined,
362
+ params: __classPrivateFieldGet(this, _AISearch_params, "f"),
363
+ prompt: __classPrivateFieldGet(this, _AISearch_prompt, "f"),
364
+ indexName: __classPrivateFieldGet(this, _AISearch_indexName, "f")
365
+ });
366
+ }
367
+ if (typeof onrejected === 'function') {
368
+ const result = onrejected(contentError);
369
+ // Ensure we always return a value, fallback to original error if callback returns undefined
370
+ return result ?? contentError;
371
+ }
372
+ // Throw the wrapped error to trigger .catch()
373
+ throw contentError;
374
+ });
375
+ }
376
+ fetch() {
377
+ const searchParams = this.buildSearchParams(__classPrivateFieldGet(this, _AISearch_prompt, "f"), __classPrivateFieldGet(this, _AISearch_params, "f"));
378
+ const url = new URL('/api/v1/ai/search', this.dotcmsUrl);
379
+ url.search = searchParams.toString();
380
+ return this.httpClient.request(url.toString(), {
381
+ ...this.requestOptions,
382
+ headers: {
383
+ ...this.requestOptions.headers
384
+ },
385
+ method: 'GET'
386
+ });
387
+ }
388
+ /**
389
+ * Builds URLSearchParams from the SDK interface, mapping to backend parameter names.
390
+ * Only includes parameters that have values.
391
+ *
392
+ * @param params - Search parameters with SDK naming
393
+ * @returns URLSearchParams with backend parameter names
394
+ * @private
395
+ */
396
+ buildSearchParams(prompt, params = {}) {
397
+ const searchParams = new URLSearchParams();
398
+ const { query = {}, config = {} } = params;
399
+ const combinedQuery = {
400
+ ...DEFAULT_QUERY,
401
+ siteId: this.siteId,
402
+ ...query
403
+ };
404
+ const combinedConfig = {
405
+ ...DEFAULT_AI_CONFIG,
406
+ ...config
407
+ };
408
+ const entriesQueryParameters = [
409
+ ['searchLimit', 'limit'],
410
+ ['searchOffset', 'offset'],
411
+ ['site', 'siteId'],
412
+ ['language', 'languageId'],
413
+ ['contentType']
414
+ ];
415
+ // Map SDK query parameters to backend parameter names
416
+ appendMappedParams(searchParams, combinedQuery, entriesQueryParameters);
417
+ // Map config parameters using the same key names
418
+ appendMappedParams(searchParams, combinedConfig, Object.keys(combinedConfig).map((key) => [key]));
419
+ // Add search-specific parameters
420
+ searchParams.append('indexName', __classPrivateFieldGet(this, _AISearch_indexName, "f"));
421
+ searchParams.append('query', prompt);
422
+ return searchParams;
423
+ }
424
+ }
425
+ _AISearch_params = new WeakMap(), _AISearch_prompt = new WeakMap(), _AISearch_indexName = new WeakMap();
426
+
427
+ /**
428
+ * Client for interacting with the DotCMS AI API.
429
+ * Provides methods to interact with AI features.
430
+ * @experimental This client is experimental and may be subject to change.
431
+ */
432
+ class AIClient extends BaseApiClient {
433
+ /**
434
+ * Creates a new AIClient instance.
435
+ *
436
+ * @param {DotCMSClientConfig} config - Configuration options for the DotCMS client
437
+ * @param {DotRequestOptions} requestOptions - Options for fetch requests including authorization headers
438
+ * @param {DotHttpClient} httpClient - HTTP client for making requests
439
+ * @example
440
+ * ```typescript
441
+ * const aiClient = new AIClient(
442
+ * {
443
+ * dotcmsUrl: 'https://demo.dotcms.com',
444
+ * authToken: 'your-auth-token',
445
+ * siteId: 'demo.dotcms.com'
446
+ * },
447
+ * {
448
+ * headers: {
449
+ * Authorization: 'Bearer your-auth-token'
450
+ * }
451
+ * },
452
+ * httpClient
453
+ * );
454
+ * ```
455
+ */
456
+ constructor(config, requestOptions, httpClient) {
457
+ super(config, requestOptions, httpClient);
458
+ }
459
+ /**
460
+ * Performs an AI-powered search.
461
+ *
462
+ * @param params - Search parameters with query and AI configuration
463
+ * @returns Promise with search results
464
+ * @experimental This method is experimental and may be subject to change.
465
+ * @template T - The type of the contentlet.
466
+ * @param prompt - The prompt for the search.
467
+ * @param indexName - The name of the index you want to search in.
468
+ * @param params - Search parameters with query and AI configuration.
469
+ * @example
470
+ * @example
471
+ * ```typescript
472
+ * const results = await client.ai.search('machine learning articles', 'content_index', {
473
+ * query: {
474
+ * limit: 20,
475
+ * contentType: 'BlogPost',
476
+ * languageId: "1" // or 1
477
+ * },
478
+ * config: {
479
+ * threshold: 0.7
480
+ * }
481
+ * });
482
+ * ```
483
+ * @example
484
+ * ```typescript
485
+ * client.ai.search('machine learning articles', 'content_index', {
486
+ * query: {
487
+ * limit: 20,
488
+ * contentType: 'BlogPost',
489
+ * languageId: "1" // or 1
490
+ * },
491
+ * config: {
492
+ * threshold: 0.7,
493
+ * distanceFunction: DISTANCE_FUNCTIONS.cosine
494
+ * }
495
+ * }).then((results) => {
496
+ * console.log(results);
497
+ * }).catch((error) => {
498
+ * console.error(error);
499
+ * });
500
+ */
501
+ search(prompt, indexName, params = {}) {
502
+ return new AISearch(this.config, this.requestOptions, this.httpClient, prompt, indexName, params);
503
+ }
504
+ }
505
+
150
506
  /**
151
507
  * Default variant identifier used in the application.
152
508
  */
@@ -746,7 +1102,7 @@ class QueryBuilder {
746
1102
  }
747
1103
  _QueryBuilder_query = new WeakMap();
748
1104
 
749
- var _CollectionBuilder_page, _CollectionBuilder_limit, _CollectionBuilder_depth, _CollectionBuilder_render, _CollectionBuilder_sortBy, _CollectionBuilder_contentType, _CollectionBuilder_defaultQuery, _CollectionBuilder_query, _CollectionBuilder_rawQuery, _CollectionBuilder_languageId, _CollectionBuilder_draft, _CollectionBuilder_requestOptions, _CollectionBuilder_httpClient, _CollectionBuilder_config;
1105
+ var _CollectionBuilder_page, _CollectionBuilder_limit, _CollectionBuilder_depth, _CollectionBuilder_render, _CollectionBuilder_sortBy, _CollectionBuilder_contentType, _CollectionBuilder_defaultQuery, _CollectionBuilder_query, _CollectionBuilder_rawQuery, _CollectionBuilder_languageId, _CollectionBuilder_draft;
750
1106
  /**
751
1107
  * Creates a Builder to filter and fetch content from the content API for a specific content type.
752
1108
  *
@@ -754,7 +1110,7 @@ var _CollectionBuilder_page, _CollectionBuilder_limit, _CollectionBuilder_depth,
754
1110
  * @class CollectionBuilder
755
1111
  * @template T Represents the type of the content type to fetch. Defaults to unknown.
756
1112
  */
757
- class CollectionBuilder {
1113
+ class CollectionBuilder extends BaseApiClient {
758
1114
  /**
759
1115
  * Creates an instance of CollectionBuilder.
760
1116
  * @param {ClientOptions} requestOptions Options for the client request.
@@ -764,6 +1120,7 @@ class CollectionBuilder {
764
1120
  * @memberof CollectionBuilder
765
1121
  */
766
1122
  constructor(requestOptions, config, contentType, httpClient) {
1123
+ super(config, requestOptions, httpClient);
767
1124
  _CollectionBuilder_page.set(this, 1);
768
1125
  _CollectionBuilder_limit.set(this, 10);
769
1126
  _CollectionBuilder_depth.set(this, 0);
@@ -775,14 +1132,7 @@ class CollectionBuilder {
775
1132
  _CollectionBuilder_rawQuery.set(this, void 0);
776
1133
  _CollectionBuilder_languageId.set(this, 1);
777
1134
  _CollectionBuilder_draft.set(this, false);
778
- _CollectionBuilder_requestOptions.set(this, void 0);
779
- _CollectionBuilder_httpClient.set(this, void 0);
780
- _CollectionBuilder_config.set(this, void 0);
781
- __classPrivateFieldSet(this, _CollectionBuilder_requestOptions, requestOptions, "f");
782
- __classPrivateFieldSet(this, _CollectionBuilder_config, config, "f");
783
1135
  __classPrivateFieldSet(this, _CollectionBuilder_contentType, contentType, "f");
784
- __classPrivateFieldSet(this, _CollectionBuilder_httpClient, httpClient, "f");
785
- __classPrivateFieldSet(this, _CollectionBuilder_config, config, "f");
786
1136
  // Build the default query with the contentType field
787
1137
  __classPrivateFieldSet(this, _CollectionBuilder_defaultQuery, new QueryBuilder().field('contentType').equals(__classPrivateFieldGet(this, _CollectionBuilder_contentType, "f")), "f");
788
1138
  }
@@ -814,17 +1164,7 @@ class CollectionBuilder {
814
1164
  * @memberof CollectionBuilder
815
1165
  */
816
1166
  get url() {
817
- return `${__classPrivateFieldGet(this, _CollectionBuilder_config, "f").dotcmsUrl}${CONTENT_API_URL}`;
818
- }
819
- /**
820
- * Returns the site ID from the configuration.
821
- *
822
- * @readonly
823
- * @private
824
- * @memberof CollectionBuilder
825
- */
826
- get siteId() {
827
- return __classPrivateFieldGet(this, _CollectionBuilder_config, "f").siteId;
1167
+ return `${this.config.dotcmsUrl}${CONTENT_API_URL}`;
828
1168
  }
829
1169
  /**
830
1170
  * Returns the current query built.
@@ -1076,11 +1416,11 @@ class CollectionBuilder {
1076
1416
  const finalQuery = this.getFinalQuery();
1077
1417
  const sanitizedQuery = sanitizeQueryForContentType(finalQuery, __classPrivateFieldGet(this, _CollectionBuilder_contentType, "f"));
1078
1418
  const query = __classPrivateFieldGet(this, _CollectionBuilder_rawQuery, "f") ? `${sanitizedQuery} ${__classPrivateFieldGet(this, _CollectionBuilder_rawQuery, "f")}` : sanitizedQuery;
1079
- return __classPrivateFieldGet(this, _CollectionBuilder_httpClient, "f").request(this.url, {
1080
- ...__classPrivateFieldGet(this, _CollectionBuilder_requestOptions, "f"),
1419
+ return this.httpClient.request(this.url, {
1420
+ ...this.requestOptions,
1081
1421
  method: 'POST',
1082
1422
  headers: {
1083
- ...__classPrivateFieldGet(this, _CollectionBuilder_requestOptions, "f").headers,
1423
+ ...this.requestOptions.headers,
1084
1424
  'Content-Type': 'application/json'
1085
1425
  },
1086
1426
  body: JSON.stringify({
@@ -1148,9 +1488,8 @@ class CollectionBuilder {
1148
1488
  return baseQuery;
1149
1489
  }
1150
1490
  }
1151
- _CollectionBuilder_page = new WeakMap(), _CollectionBuilder_limit = new WeakMap(), _CollectionBuilder_depth = new WeakMap(), _CollectionBuilder_render = new WeakMap(), _CollectionBuilder_sortBy = new WeakMap(), _CollectionBuilder_contentType = new WeakMap(), _CollectionBuilder_defaultQuery = new WeakMap(), _CollectionBuilder_query = new WeakMap(), _CollectionBuilder_rawQuery = new WeakMap(), _CollectionBuilder_languageId = new WeakMap(), _CollectionBuilder_draft = new WeakMap(), _CollectionBuilder_requestOptions = new WeakMap(), _CollectionBuilder_httpClient = new WeakMap(), _CollectionBuilder_config = new WeakMap();
1491
+ _CollectionBuilder_page = new WeakMap(), _CollectionBuilder_limit = new WeakMap(), _CollectionBuilder_depth = new WeakMap(), _CollectionBuilder_render = new WeakMap(), _CollectionBuilder_sortBy = new WeakMap(), _CollectionBuilder_contentType = new WeakMap(), _CollectionBuilder_defaultQuery = new WeakMap(), _CollectionBuilder_query = new WeakMap(), _CollectionBuilder_rawQuery = new WeakMap(), _CollectionBuilder_languageId = new WeakMap(), _CollectionBuilder_draft = new WeakMap();
1152
1492
 
1153
- var _Content_requestOptions, _Content_httpClient, _Content_config;
1154
1493
  /**
1155
1494
  * Creates a builder to filter and fetch a collection of content items.
1156
1495
  * @param contentType - The content type to retrieve.
@@ -1200,20 +1539,15 @@ var _Content_requestOptions, _Content_httpClient, _Content_config;
1200
1539
  * });
1201
1540
  * ```
1202
1541
  */
1203
- class Content {
1542
+ class Content extends BaseApiClient {
1204
1543
  /**
1205
1544
  * Creates an instance of Content.
1545
+ * @param {DotCMSClientConfig} config - Configuration options for the DotCMS client
1206
1546
  * @param {DotRequestOptions} requestOptions - The options for the client request.
1207
- * @param {string} serverUrl - The server URL.
1208
1547
  * @param {DotHttpClient} httpClient - HTTP client for making requests.
1209
1548
  */
1210
1549
  constructor(config, requestOptions, httpClient) {
1211
- _Content_requestOptions.set(this, void 0);
1212
- _Content_httpClient.set(this, void 0);
1213
- _Content_config.set(this, void 0);
1214
- __classPrivateFieldSet(this, _Content_requestOptions, requestOptions, "f");
1215
- __classPrivateFieldSet(this, _Content_config, config, "f");
1216
- __classPrivateFieldSet(this, _Content_httpClient, httpClient, "f");
1550
+ super(config, requestOptions, httpClient);
1217
1551
  }
1218
1552
  /**
1219
1553
  * Takes a content type and returns a builder to filter and fetch the collection.
@@ -1281,16 +1615,20 @@ class Content {
1281
1615
  *
1282
1616
  */
1283
1617
  getCollection(contentType) {
1284
- return new CollectionBuilder(__classPrivateFieldGet(this, _Content_requestOptions, "f"), __classPrivateFieldGet(this, _Content_config, "f"), contentType, __classPrivateFieldGet(this, _Content_httpClient, "f"));
1618
+ return new CollectionBuilder(this.requestOptions, this.config, contentType, this.httpClient);
1285
1619
  }
1286
1620
  }
1287
- _Content_requestOptions = new WeakMap(), _Content_httpClient = new WeakMap(), _Content_config = new WeakMap();
1288
1621
 
1289
- class NavigationClient {
1622
+ class NavigationClient extends BaseApiClient {
1623
+ /**
1624
+ * Creates a new NavigationClient instance.
1625
+ * @param {DotCMSClientConfig} config - Configuration options for the DotCMS client
1626
+ * @param {DotRequestOptions} requestOptions - Options for fetch requests including authorization headers
1627
+ * @param {DotHttpClient} httpClient - HTTP client for making requests
1628
+ */
1290
1629
  constructor(config, requestOptions, httpClient) {
1291
- this.requestOptions = requestOptions;
1630
+ super(config, requestOptions, httpClient);
1292
1631
  this.BASE_URL = `${config?.dotcmsUrl}/api/v1/nav`;
1293
- this.httpClient = httpClient;
1294
1632
  }
1295
1633
  /**
1296
1634
  * Retrieves information about the dotCMS file and folder tree.
@@ -1588,7 +1926,7 @@ async function fetchGraphQL({ baseURL, body, headers, httpClient }) {
1588
1926
  * Client for interacting with the DotCMS Page API.
1589
1927
  * Provides methods to retrieve and manipulate pages.
1590
1928
  */
1591
- class PageClient {
1929
+ class PageClient extends BaseApiClient {
1592
1930
  /**
1593
1931
  * Creates a new PageClient instance.
1594
1932
  *
@@ -1613,10 +1951,7 @@ class PageClient {
1613
1951
  * ```
1614
1952
  */
1615
1953
  constructor(config, requestOptions, httpClient) {
1616
- this.requestOptions = requestOptions;
1617
- this.siteId = config.siteId || '';
1618
- this.dotcmsUrl = config.dotcmsUrl;
1619
- this.httpClient = httpClient;
1954
+ super(config, requestOptions, httpClient);
1620
1955
  }
1621
1956
  /**
1622
1957
  * Retrieves a page from DotCMS using GraphQL.
@@ -1781,6 +2116,7 @@ class DotCMSClient {
1781
2116
  this.page = new PageClient(this.config, this.requestOptions, this.httpClient);
1782
2117
  this.nav = new NavigationClient(this.config, this.requestOptions, this.httpClient);
1783
2118
  this.content = new Content(this.config, this.requestOptions, this.httpClient);
2119
+ this.ai = new AIClient(this.config, this.requestOptions, this.httpClient);
1784
2120
  }
1785
2121
  /**
1786
2122
  * Creates request options with authentication headers.