@dotcms/client 0.0.1-beta.3 → 0.0.1-beta.30

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 (41) hide show
  1. package/README.md +183 -36
  2. package/index.cjs.js +102 -1238
  3. package/index.esm.js +86 -1221
  4. package/next.cjs.d.ts +1 -0
  5. package/next.cjs.default.js +1 -0
  6. package/next.cjs.js +526 -0
  7. package/next.cjs.mjs +2 -0
  8. package/next.esm.d.ts +1 -0
  9. package/next.esm.js +524 -0
  10. package/package.json +26 -7
  11. package/src/index.d.ts +6 -6
  12. package/src/lib/client/client.d.ts +56 -0
  13. package/src/lib/client/content/builders/collection/collection.d.ts +1 -1
  14. package/src/lib/client/content/content-api.d.ts +3 -3
  15. package/src/lib/client/content/shared/types.d.ts +3 -44
  16. package/src/lib/client/navigation/navigation-api.d.ts +14 -0
  17. package/src/lib/client/page/page-api.d.ts +96 -0
  18. package/src/lib/client/page/utils.d.ts +41 -0
  19. package/src/lib/{editor → deprecated/editor}/models/client.model.d.ts +13 -0
  20. package/src/lib/{editor → deprecated/editor}/sdk-editor.d.ts +1 -1
  21. package/src/lib/{client → deprecated}/sdk-js-client.d.ts +1 -1
  22. package/src/lib/utils/graphql/transforms.d.ts +2 -13
  23. package/src/lib/utils/page/common-utils.d.ts +1 -1
  24. package/src/next.d.ts +1 -0
  25. package/transforms.cjs.js +1150 -0
  26. package/transforms.esm.js +1144 -0
  27. package/src/lib/client/models/types.d.ts +0 -13
  28. /package/src/lib/{query-builder → client/content/builders/query}/lucene-syntax/Equals.d.ts +0 -0
  29. /package/src/lib/{query-builder → client/content/builders/query}/lucene-syntax/Field.d.ts +0 -0
  30. /package/src/lib/{query-builder → client/content/builders/query}/lucene-syntax/NotOperand.d.ts +0 -0
  31. /package/src/lib/{query-builder → client/content/builders/query}/lucene-syntax/Operand.d.ts +0 -0
  32. /package/src/lib/{query-builder → client/content/builders/query}/lucene-syntax/index.d.ts +0 -0
  33. /package/src/lib/{query-builder/sdk-query-builder.d.ts → client/content/builders/query/query.d.ts} +0 -0
  34. /package/src/lib/{query-builder → client/content/builders/query}/utils/index.d.ts +0 -0
  35. /package/src/lib/{editor → deprecated/editor}/listeners/listeners.d.ts +0 -0
  36. /package/src/lib/{editor → deprecated/editor}/models/editor.model.d.ts +0 -0
  37. /package/src/lib/{editor → deprecated/editor}/models/inline-event.model.d.ts +0 -0
  38. /package/src/lib/{editor → deprecated/editor}/models/listeners.model.d.ts +0 -0
  39. /package/src/lib/{editor → deprecated/editor}/sdk-editor-vtl.d.ts +0 -0
  40. /package/src/lib/{editor → deprecated/editor}/utils/editor.utils.d.ts +0 -0
  41. /package/src/lib/{editor → deprecated/editor}/utils/traditional-vtl.utils.d.ts +0 -0
package/next.esm.js ADDED
@@ -0,0 +1,524 @@
1
+ import { E as ErrorMessages, _ as __classPrivateFieldGet, g as graphqlToPageEntity, C as Content } from './transforms.esm.js';
2
+
3
+ class NavigationClient {
4
+ constructor(config, requestOptions) {
5
+ this.requestOptions = requestOptions;
6
+ this.BASE_URL = `${config?.dotcmsUrl}/api/v1/nav`;
7
+ }
8
+ /**
9
+ * Retrieves information about the dotCMS file and folder tree.
10
+ * @param {NavigationApiOptions} options - The options for the Navigation API call. Defaults to `{ depth: 0, path: '/', languageId: 1 }`.
11
+ * @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
12
+ * @throws {Error} - Throws an error if the options are not valid.
13
+ */
14
+ async get(path, params) {
15
+ if (!path) {
16
+ throw new Error("The 'path' parameter is required for the Navigation API");
17
+ }
18
+ const navParams = params ? this.mapToBackendParams(params) : {};
19
+ const urlParams = new URLSearchParams(navParams).toString();
20
+ const parsedPath = path.replace(/^\/+/, '/').replace(/\/+$/, '/');
21
+ const url = `${this.BASE_URL}${parsedPath}${urlParams ? `?${urlParams}` : ''}`;
22
+ const response = await fetch(url, this.requestOptions);
23
+ if (!response.ok) {
24
+ throw new Error(`Failed to fetch navigation data: ${response.statusText} - ${response.status}`);
25
+ }
26
+ return response.json().then((data) => data.entity);
27
+ }
28
+ mapToBackendParams(params) {
29
+ const backendParams = {};
30
+ if (params.depth) {
31
+ backendParams['depth'] = String(params.depth);
32
+ }
33
+ if (params.languageId) {
34
+ backendParams['language_id'] = String(params.languageId);
35
+ }
36
+ return backendParams;
37
+ }
38
+ }
39
+
40
+ const DEFAULT_PAGE_CONTENTLETS_CONTENT = `
41
+ publishDate
42
+ inode
43
+ identifier
44
+ archived
45
+ urlMap
46
+ urlMap
47
+ locked
48
+ contentType
49
+ creationDate
50
+ modDate
51
+ title
52
+ baseType
53
+ working
54
+ live
55
+ publishUser {
56
+ firstName
57
+ lastName
58
+ }
59
+ owner {
60
+ lastName
61
+ }
62
+ conLanguage {
63
+ language
64
+ languageCode
65
+ }
66
+ modUser {
67
+ firstName
68
+ lastName
69
+ }
70
+ `;
71
+ /**
72
+ * Builds a GraphQL query for retrieving page content from DotCMS.
73
+ *
74
+ * @param {string} pageQuery - Custom fragment fields to include in the ClientPage fragment
75
+ * @param {string} additionalQueries - Additional GraphQL queries to include in the main query
76
+ * @returns {string} Complete GraphQL query string for page content
77
+ */
78
+ const buildPageQuery = ({ page, fragments, additionalQueries }) => {
79
+ if (!page) {
80
+ console.warn('No page query provided. The query will be used by fetching all content with _map. This may mean poor performance in the query. We suggest you provide a detailed query on page attribute.');
81
+ }
82
+ return `
83
+ fragment DotCMSPage on DotPage {
84
+ publishDate
85
+ type
86
+ httpsRequired
87
+ inode
88
+ path
89
+ identifier
90
+ hasTitleImage
91
+ sortOrder
92
+ extension
93
+ canRead
94
+ pageURI
95
+ canEdit
96
+ archived
97
+ friendlyName
98
+ workingInode
99
+ url
100
+ pageURI
101
+ hasLiveVersion
102
+ deleted
103
+ pageUrl
104
+ shortyWorking
105
+ mimeType
106
+ locked
107
+ stInode
108
+ contentType
109
+ creationDate
110
+ liveInode
111
+ name
112
+ shortyLive
113
+ modDate
114
+ title
115
+ baseType
116
+ working
117
+ canLock
118
+ live
119
+ isContentlet
120
+ statusIcons
121
+ canEdit
122
+ canLock
123
+ canRead
124
+ canEdit
125
+ canLock
126
+ canRead
127
+ urlContentMap {
128
+ _map
129
+ }
130
+ conLanguage {
131
+ id
132
+ language
133
+ languageCode
134
+ }
135
+ template {
136
+ drawed
137
+ }
138
+ containers {
139
+ path
140
+ identifier
141
+ maxContentlets
142
+ containerStructures {
143
+ id
144
+ code
145
+ structureId
146
+ containerId
147
+ contentTypeVar
148
+ containerInode
149
+ }
150
+ containerContentlets {
151
+ uuid
152
+ contentlets {
153
+ ${page ? DEFAULT_PAGE_CONTENTLETS_CONTENT : '_map'}
154
+ }
155
+ }
156
+ }
157
+ layout {
158
+ header
159
+ footer
160
+ body {
161
+ rows {
162
+ columns {
163
+ leftOffset
164
+ styleClass
165
+ width
166
+ left
167
+ containers {
168
+ identifier
169
+ uuid
170
+ }
171
+ }
172
+ }
173
+ }
174
+ }
175
+ viewAs {
176
+ visitor {
177
+ persona {
178
+ modDate
179
+ inode
180
+ name
181
+ identifier
182
+ keyTag
183
+ photo {
184
+ versionPath
185
+ }
186
+ }
187
+ }
188
+ persona {
189
+ modDate
190
+ inode
191
+ name
192
+ identifier
193
+ keyTag
194
+ photo {
195
+ versionPath
196
+ }
197
+ }
198
+ language {
199
+ id
200
+ languageCode
201
+ countryCode
202
+ language
203
+ country
204
+ }
205
+ }
206
+ }
207
+
208
+ ${page ? ` fragment ClientPage on DotPage { ${page} } ` : ''}
209
+
210
+ ${fragments ? fragments.join('\n\n') : ''}
211
+
212
+ query PageContent($url: String!, $languageId: String, $mode: String, $personaId: String, $fireRules: Boolean, $publishDate: String, $siteId: String) {
213
+ page: page(url: $url, languageId: $languageId, pageMode: $mode, persona: $personaId, fireRules: $fireRules, publishDate: $publishDate, site: $siteId) {
214
+ ...DotCMSPage
215
+ ${page ? '...ClientPage' : ''}
216
+ }
217
+
218
+ ${additionalQueries}
219
+ }
220
+ `;
221
+ };
222
+ /**
223
+ * Converts a record of query strings into a single GraphQL query string.
224
+ *
225
+ * @param {Record<string, string>} queryData - Object containing named query strings
226
+ * @returns {string} Combined query string or empty string if no queryData provided
227
+ */
228
+ function buildQuery(queryData) {
229
+ if (!queryData)
230
+ return '';
231
+ return Object.entries(queryData)
232
+ .map(([key, query]) => `${key}: ${query}`)
233
+ .join(' ');
234
+ }
235
+ /**
236
+ * Filters response data to include only specified keys.
237
+ *
238
+ * @param {Record<string, string>} responseData - Original response data object
239
+ * @param {string[]} keys - Array of keys to extract from the response data
240
+ * @returns {Record<string, string>} New object containing only the specified keys
241
+ */
242
+ function mapResponseData(responseData, keys) {
243
+ return keys.reduce((accumulator, key) => {
244
+ if (responseData[key] !== undefined) {
245
+ accumulator[key] = responseData[key];
246
+ }
247
+ return accumulator;
248
+ }, {});
249
+ }
250
+ /**
251
+ * Executes a GraphQL query against the DotCMS API.
252
+ *
253
+ * @param {Object} options - Options for the fetch request
254
+ * @param {string} options.body - GraphQL query string
255
+ * @param {Record<string, string>} options.headers - HTTP headers for the request
256
+ * @returns {Promise<any>} Parsed JSON response from the GraphQL API
257
+ * @throws {Error} If the HTTP response is not successful
258
+ */
259
+ async function fetchGraphQL({ baseURL, body, headers }) {
260
+ const url = new URL(baseURL);
261
+ url.pathname = '/api/v1/graphql';
262
+ const response = await fetch(url.toString(), {
263
+ method: 'POST',
264
+ body,
265
+ headers
266
+ });
267
+ if (!response.ok) {
268
+ const error = {
269
+ status: response.status,
270
+ message: ErrorMessages[response.status] || response.statusText
271
+ };
272
+ throw error;
273
+ }
274
+ return await response.json();
275
+ }
276
+
277
+ var _PageClient_instances, _PageClient_getPageFromGraphQL;
278
+ /**
279
+ * Client for interacting with the DotCMS Page API.
280
+ * Provides methods to retrieve and manipulate pages.
281
+ */
282
+ class PageClient {
283
+ /**
284
+ * Creates a new PageClient instance.
285
+ *
286
+ * @param {DotCMSClientConfig} config - Configuration options for the DotCMS client
287
+ * @param {RequestOptions} requestOptions - Options for fetch requests including authorization headers
288
+ * @example
289
+ * ```typescript
290
+ * const pageClient = new PageClient(
291
+ * {
292
+ * dotcmsUrl: 'https://demo.dotcms.com',
293
+ * authToken: 'your-auth-token',
294
+ * siteId: 'demo.dotcms.com'
295
+ * },
296
+ * {
297
+ * headers: {
298
+ * Authorization: 'Bearer your-auth-token'
299
+ * }
300
+ * }
301
+ * );
302
+ * ```
303
+ */
304
+ constructor(config, requestOptions) {
305
+ _PageClient_instances.add(this);
306
+ this.requestOptions = requestOptions;
307
+ this.siteId = config.siteId || '';
308
+ this.dotcmsUrl = config.dotcmsUrl;
309
+ }
310
+ /**
311
+ * Retrieves a page from DotCMS using GraphQL.
312
+ *
313
+ * @param {string} url - The URL of the page to retrieve
314
+ * @param {DotCMSPageRequestParams} [options] - Options for the request
315
+ * @template T - The type of the page and content, defaults to DotCMSBasicPage and Record<string, unknown> | unknown
316
+ * @returns {Promise<DotCMSComposedPageResponse<T>>} A Promise that resolves to the page data
317
+ *
318
+ * @example Using GraphQL
319
+ * ```typescript
320
+ * const page = await pageClient.get<{ page: MyPageWithBanners; content: { blogPosts: { blogTitle: string } } }>(
321
+ * '/index',
322
+ * {
323
+ * languageId: '1',
324
+ * mode: 'LIVE',
325
+ * graphql: {
326
+ * page: `
327
+ * containers {
328
+ * containerContentlets {
329
+ * contentlets {
330
+ * ... on Banner {
331
+ * ...bannerFragment
332
+ * }
333
+ * }
334
+ * }
335
+ * `,
336
+ * content: {
337
+ * blogPosts: `
338
+ * BlogCollection(limit: 3) {
339
+ * ...blogFragment
340
+ * }
341
+ * `,
342
+ * },
343
+ * fragments: [
344
+ * `
345
+ * fragment bannerFragment on Banner {
346
+ * caption
347
+ * }
348
+ * `,
349
+ * `
350
+ * fragment blogFragment on Blog {
351
+ * title
352
+ * urlTitle
353
+ * }
354
+ * `
355
+ * ]
356
+ * }
357
+ * });
358
+ * ```
359
+ */
360
+ get(url, options) {
361
+ return __classPrivateFieldGet(this, _PageClient_instances, "m", _PageClient_getPageFromGraphQL).call(this, url, options);
362
+ }
363
+ }
364
+ _PageClient_instances = new WeakSet(), _PageClient_getPageFromGraphQL =
365
+ /**
366
+ * Private implementation method that fetches page data using GraphQL.
367
+ * This method is used internally by the public get() method.
368
+ *
369
+ * @private
370
+ * @param {string} url - The URL of the page to retrieve
371
+ * @param {DotCMSPageRequestParams} [options] - Options including languageId, mode, and GraphQL parameters
372
+ * @returns {Promise<DotCMSComposedPageResponse<T>>} A Promise that resolves to the page data
373
+ */
374
+ async function _PageClient_getPageFromGraphQL(url, options) {
375
+ const { languageId = '1', mode = 'LIVE', siteId = this.siteId, fireRules = false, personaId, publishDate, graphql = {} } = options || {};
376
+ const { page, content = {}, variables, fragments } = graphql;
377
+ const contentQuery = buildQuery(content);
378
+ const completeQuery = buildPageQuery({
379
+ page,
380
+ fragments,
381
+ additionalQueries: contentQuery
382
+ });
383
+ const requestVariables = {
384
+ url,
385
+ mode,
386
+ languageId,
387
+ personaId,
388
+ fireRules,
389
+ publishDate,
390
+ siteId,
391
+ ...variables
392
+ };
393
+ const requestHeaders = this.requestOptions.headers;
394
+ const requestBody = JSON.stringify({ query: completeQuery, variables: requestVariables });
395
+ try {
396
+ const { data, errors } = await fetchGraphQL({
397
+ baseURL: this.dotcmsUrl,
398
+ body: requestBody,
399
+ headers: requestHeaders
400
+ });
401
+ if (errors) {
402
+ errors.forEach((error) => {
403
+ throw new Error(error.message);
404
+ });
405
+ }
406
+ const pageResponse = graphqlToPageEntity(data);
407
+ if (!pageResponse) {
408
+ throw new Error('No page data found');
409
+ }
410
+ const contentResponse = mapResponseData(data, Object.keys(content));
411
+ return {
412
+ pageAsset: pageResponse,
413
+ content: contentResponse,
414
+ graphql: {
415
+ query: completeQuery,
416
+ variables: requestVariables
417
+ }
418
+ };
419
+ }
420
+ catch (error) {
421
+ const errorMessage = {
422
+ error,
423
+ message: 'Failed to retrieve page data',
424
+ graphql: {
425
+ query: completeQuery,
426
+ variables: requestVariables
427
+ }
428
+ };
429
+ throw errorMessage;
430
+ }
431
+ };
432
+
433
+ /**
434
+ * Parses a string into a URL object.
435
+ *
436
+ * @param url - The URL string to parse
437
+ * @returns A URL object if parsing is successful, undefined otherwise
438
+ */
439
+ function parseURL(url) {
440
+ try {
441
+ return new URL(url);
442
+ }
443
+ catch {
444
+ console.error('Invalid URL:', url);
445
+ return undefined;
446
+ }
447
+ }
448
+ /**
449
+ * Default configuration for the DotCMS client.
450
+ */
451
+ const defaultConfig = {
452
+ dotcmsUrl: '',
453
+ authToken: '',
454
+ requestOptions: {}
455
+ };
456
+ /**
457
+ * Client for interacting with the DotCMS REST API.
458
+ * Provides access to content, page, and navigation functionality.
459
+ */
460
+ class DotCMSClient {
461
+ /**
462
+ * Creates a new DotCMS client instance.
463
+ *
464
+ * @param config - Configuration options for the client
465
+ * @throws Warning if dotcmsUrl is invalid or authToken is missing
466
+ */
467
+ constructor(config = defaultConfig) {
468
+ this.config = config;
469
+ this.requestOptions = this.createAuthenticatedRequestOptions(this.config);
470
+ // Initialize clients
471
+ this.page = new PageClient(this.config, this.requestOptions);
472
+ this.nav = new NavigationClient(this.config, this.requestOptions);
473
+ this.content = new Content(this.requestOptions, this.config.dotcmsUrl);
474
+ }
475
+ /**
476
+ * Creates request options with authentication headers.
477
+ *
478
+ * @param config - The client configuration
479
+ * @returns Request options with authorization headers
480
+ */
481
+ createAuthenticatedRequestOptions(config) {
482
+ return {
483
+ ...config.requestOptions,
484
+ headers: {
485
+ ...config.requestOptions?.headers,
486
+ Authorization: `Bearer ${config.authToken}`
487
+ }
488
+ };
489
+ }
490
+ }
491
+ /**
492
+ * Creates and returns a new DotCMS client instance.
493
+ *
494
+ * @param config - Configuration options for the client
495
+ * @returns A configured DotCMS client instance
496
+ * @example
497
+ * ```typescript
498
+ * const client = dotCMSCreateClient({
499
+ * dotcmsUrl: 'https://demo.dotcms.com',
500
+ * authToken: 'your-auth-token'
501
+ * });
502
+ *
503
+ * // Use the client to fetch content
504
+ * const pages = await client.page.get('/about-us');
505
+ * ```
506
+ */
507
+ const createDotCMSClient = (clientConfig) => {
508
+ const { dotcmsUrl, authToken } = clientConfig || {};
509
+ const instanceUrl = parseURL(dotcmsUrl)?.origin;
510
+ if (!instanceUrl) {
511
+ throw new TypeError("Invalid configuration - 'dotcmsUrl' must be a valid URL");
512
+ }
513
+ if (!authToken) {
514
+ throw new TypeError("Invalid configuration - 'authToken' is required");
515
+ }
516
+ const config = {
517
+ ...clientConfig,
518
+ authToken,
519
+ dotcmsUrl: instanceUrl
520
+ };
521
+ return new DotCMSClient(config);
522
+ };
523
+
524
+ export { createDotCMSClient };
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@dotcms/client",
3
- "version": "0.0.1-beta.3",
3
+ "version": "0.0.1-beta.30",
4
4
  "description": "Official JavaScript library for interacting with DotCMS REST APIs.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/dotCMS/core.git#main"
8
8
  },
9
+ "devDependencies": {
10
+ "@dotcms/types": "next"
11
+ },
9
12
  "scripts": {
10
13
  "build": "nx run sdk-client:build:js; cd ../../../../dotCMS/src/main/webapp/html/js/editor-js; rm -rf src package.json *.esm.d.ts"
11
14
  },
@@ -16,12 +19,6 @@
16
19
  "API Client",
17
20
  "REST API"
18
21
  ],
19
- "author": "dotcms <dev@dotcms.com>",
20
- "license": "MIT",
21
- "bugs": {
22
- "url": "https://github.com/dotCMS/core/issues"
23
- },
24
- "homepage": "https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/client/README.md",
25
22
  "exports": {
26
23
  "./package.json": "./package.json",
27
24
  ".": {
@@ -29,8 +26,30 @@
29
26
  "types": "./index.esm.d.ts",
30
27
  "import": "./index.cjs.mjs",
31
28
  "default": "./index.cjs.js"
29
+ },
30
+ "./next": {
31
+ "module": "./next.esm.js",
32
+ "types": "./next.esm.d.ts",
33
+ "import": "./next.cjs.mjs",
34
+ "default": "./next.cjs.js"
32
35
  }
33
36
  },
37
+ "typesVersions": {
38
+ "*": {
39
+ ".": [
40
+ "./src/index.d.ts"
41
+ ],
42
+ "next": [
43
+ "./src/next.d.ts"
44
+ ]
45
+ }
46
+ },
47
+ "author": "dotcms <dev@dotcms.com>",
48
+ "license": "MIT",
49
+ "bugs": {
50
+ "url": "https://github.com/dotCMS/core/issues"
51
+ },
52
+ "homepage": "https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/client/README.md",
34
53
  "module": "./index.esm.js",
35
54
  "main": "./index.cjs.js",
36
55
  "types": "./index.esm.d.ts"
package/src/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { ClientConfig, DotCmsClient } from './lib/client/sdk-js-client';
2
- import { CLIENT_ACTIONS, postMessageToEditor } from './lib/editor/models/client.model';
3
- import { CustomClientParams, DotCMSPageEditorConfig, EditorConfig } from './lib/editor/models/editor.model';
4
- import { InlineEditorData, INLINE_EDITING_EVENT_KEY, InlineEditEventData } from './lib/editor/models/inline-event.model';
5
- import { NOTIFY_CLIENT } from './lib/editor/models/listeners.model';
6
- import { destroyEditor, editContentlet, reorderMenu, initEditor, isInsideEditor, updateNavigation, initInlineEditing } from './lib/editor/sdk-editor';
1
+ import { CLIENT_ACTIONS, postMessageToEditor } from './lib/deprecated/editor/models/client.model';
2
+ import { CustomClientParams, DotCMSPageEditorConfig, EditorConfig } from './lib/deprecated/editor/models/editor.model';
3
+ import { InlineEditorData, INLINE_EDITING_EVENT_KEY, InlineEditEventData } from './lib/deprecated/editor/models/inline-event.model';
4
+ import { NOTIFY_CLIENT } from './lib/deprecated/editor/models/listeners.model';
5
+ import { destroyEditor, editContentlet, reorderMenu, initEditor, isInsideEditor, updateNavigation, initInlineEditing } from './lib/deprecated/editor/sdk-editor';
6
+ import { ClientConfig, DotCmsClient } from './lib/deprecated/sdk-js-client';
7
7
  import { getPageRequestParams, graphqlToPageEntity } from './lib/utils';
8
8
  export { destroyEditor, editContentlet, getPageRequestParams, graphqlToPageEntity, initEditor, initInlineEditing, isInsideEditor, postMessageToEditor, reorderMenu, updateNavigation, DotCmsClient, ClientConfig, CustomClientParams, DotCMSPageEditorConfig, EditorConfig, InlineEditEventData, InlineEditorData, CLIENT_ACTIONS, INLINE_EDITING_EVENT_KEY, NOTIFY_CLIENT };
@@ -0,0 +1,56 @@
1
+ import { DotCMSClientConfig } from '@dotcms/types';
2
+ import { Content } from './content/content-api';
3
+ import { NavigationClient } from './navigation/navigation-api';
4
+ import { PageClient } from './page/page-api';
5
+ /**
6
+ * Client for interacting with the DotCMS REST API.
7
+ * Provides access to content, page, and navigation functionality.
8
+ */
9
+ declare class DotCMSClient {
10
+ private config;
11
+ private requestOptions;
12
+ /**
13
+ * Client for content-related operations.
14
+ */
15
+ content: Content;
16
+ /**
17
+ * Client for page-related operations.
18
+ */
19
+ page: PageClient;
20
+ /**
21
+ * Client for navigation-related operations.
22
+ */
23
+ nav: NavigationClient;
24
+ /**
25
+ * Creates a new DotCMS client instance.
26
+ *
27
+ * @param config - Configuration options for the client
28
+ * @throws Warning if dotcmsUrl is invalid or authToken is missing
29
+ */
30
+ constructor(config?: DotCMSClientConfig);
31
+ /**
32
+ * Creates request options with authentication headers.
33
+ *
34
+ * @param config - The client configuration
35
+ * @returns Request options with authorization headers
36
+ */
37
+ private createAuthenticatedRequestOptions;
38
+ }
39
+ /**
40
+ * Creates and returns a new DotCMS client instance.
41
+ *
42
+ * @param config - Configuration options for the client
43
+ * @returns A configured DotCMS client instance
44
+ * @example
45
+ * ```typescript
46
+ * const client = dotCMSCreateClient({
47
+ * dotcmsUrl: 'https://demo.dotcms.com',
48
+ * authToken: 'your-auth-token'
49
+ * });
50
+ *
51
+ * // Use the client to fetch content
52
+ * const pages = await client.page.get('/about-us');
53
+ * ```
54
+ */
55
+ export declare const createDotCMSClient: (clientConfig: DotCMSClientConfig) => DotCMSClient;
56
+ export {};
@@ -1,4 +1,4 @@
1
- import { ClientOptions } from '../../../sdk-js-client';
1
+ import { ClientOptions } from '../../../../deprecated/sdk-js-client';
2
2
  import { GetCollectionResponse, BuildQuery, SortBy, GetCollectionError, OnFullfilled, OnRejected } from '../../shared/types';
3
3
  /**
4
4
  * Creates a Builder to filter and fetch content from the content API for a specific content type.
@@ -1,5 +1,5 @@
1
+ import { RequestOptions } from '@dotcms/types';
1
2
  import { CollectionBuilder } from './builders/collection/collection';
2
- import { ClientOptions } from '../sdk-js-client';
3
3
  /**
4
4
  * Creates a builder to filter and fetch a collection of content items.
5
5
  * @param contentType - The content type to retrieve.
@@ -56,10 +56,10 @@ export declare class Content {
56
56
  #private;
57
57
  /**
58
58
  * Creates an instance of Content.
59
- * @param {ClientOptions} requestOptions - The options for the client request.
59
+ * @param {RequestOptions} requestOptions - The options for the client request.
60
60
  * @param {string} serverUrl - The server URL.
61
61
  */
62
- constructor(requestOptions: ClientOptions, serverUrl: string);
62
+ constructor(requestOptions: RequestOptions, serverUrl: string);
63
63
  /**
64
64
  * Takes a content type and returns a builder to filter and fetch the collection.
65
65
  * @param {string} contentType - The content type to get the collection.