@dotcms/client 1.5.1-next.1964 → 1.5.1-next.1965

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
@@ -2309,6 +2309,49 @@ function mapContentResponse(responseData, keys) {
2309
2309
  return accumulator;
2310
2310
  }, {});
2311
2311
  }
2312
+ /**
2313
+ * Loads style editor schemas from GET /api/v1/page/{pageId}/contenttype-schema.
2314
+ * Requires READ on the page; failures are silently ignored so callers still work without auth.
2315
+ *
2316
+ * @internal
2317
+ */
2318
+ async function fetchStyleEditorSchemas(pageId, config, requestOptions, httpClient) {
2319
+ if (typeof window === 'undefined') {
2320
+ return [];
2321
+ }
2322
+ if (!pageId) {
2323
+ consola.consola.warn('[DotCMS PageClient]: fetchStyleEditorSchemas called without a pageId — ' +
2324
+ 'make sure "identifier" is included in your GraphQL page fragment.');
2325
+ return [];
2326
+ }
2327
+ try {
2328
+ const url = new URL(config.dotcmsUrl);
2329
+ url.pathname = `/api/v1/page/${encodeURIComponent(pageId)}/contenttype-schema`;
2330
+ const data = await httpClient.request(url.toString(), {
2331
+ ...requestOptions,
2332
+ method: 'GET',
2333
+ headers: {
2334
+ Accept: 'application/json',
2335
+ ...requestOptions.headers
2336
+ }
2337
+ });
2338
+ const { entity } = data ?? {};
2339
+ if (!Array.isArray(entity)) {
2340
+ return [];
2341
+ }
2342
+ return entity;
2343
+ }
2344
+ catch (error) {
2345
+ if (error instanceof types.DotHttpError && (error.status === 401 || error.status === 403)) {
2346
+ consola.consola.warn(`[DotCMS PageClient]: Style editor schemas request failed with ${error.status} — ` +
2347
+ 'make sure your DotCMS client is configured with a valid authToken that has READ access to the page.');
2348
+ }
2349
+ else {
2350
+ consola.consola.debug('[DotCMS PageClient]: Skipping style editor schemas:', error);
2351
+ }
2352
+ return [];
2353
+ }
2354
+ }
2312
2355
  /**
2313
2356
  * Executes a GraphQL query against the DotCMS API.
2314
2357
  *
@@ -2468,6 +2511,7 @@ class PageClient extends BaseApiClient {
2468
2511
  data: response.errors
2469
2512
  });
2470
2513
  }
2514
+ const styleEditorSchemas = await fetchStyleEditorSchemas(pageResponse.page.identifier, this.config, this.requestOptions, this.httpClient);
2471
2515
  const contentResponse = mapContentResponse(response.data, Object.keys(content));
2472
2516
  return {
2473
2517
  pageAsset: pageResponse,
@@ -2475,7 +2519,8 @@ class PageClient extends BaseApiClient {
2475
2519
  graphql: {
2476
2520
  query: completeQuery,
2477
2521
  variables: requestVariables
2478
- }
2522
+ },
2523
+ ...(styleEditorSchemas.length > 0 && { styleEditorSchemas })
2479
2524
  };
2480
2525
  }
2481
2526
  catch (error) {
package/index.esm.js CHANGED
@@ -2307,6 +2307,49 @@ function mapContentResponse(responseData, keys) {
2307
2307
  return accumulator;
2308
2308
  }, {});
2309
2309
  }
2310
+ /**
2311
+ * Loads style editor schemas from GET /api/v1/page/{pageId}/contenttype-schema.
2312
+ * Requires READ on the page; failures are silently ignored so callers still work without auth.
2313
+ *
2314
+ * @internal
2315
+ */
2316
+ async function fetchStyleEditorSchemas(pageId, config, requestOptions, httpClient) {
2317
+ if (typeof window === 'undefined') {
2318
+ return [];
2319
+ }
2320
+ if (!pageId) {
2321
+ consola.warn('[DotCMS PageClient]: fetchStyleEditorSchemas called without a pageId — ' +
2322
+ 'make sure "identifier" is included in your GraphQL page fragment.');
2323
+ return [];
2324
+ }
2325
+ try {
2326
+ const url = new URL(config.dotcmsUrl);
2327
+ url.pathname = `/api/v1/page/${encodeURIComponent(pageId)}/contenttype-schema`;
2328
+ const data = await httpClient.request(url.toString(), {
2329
+ ...requestOptions,
2330
+ method: 'GET',
2331
+ headers: {
2332
+ Accept: 'application/json',
2333
+ ...requestOptions.headers
2334
+ }
2335
+ });
2336
+ const { entity } = data ?? {};
2337
+ if (!Array.isArray(entity)) {
2338
+ return [];
2339
+ }
2340
+ return entity;
2341
+ }
2342
+ catch (error) {
2343
+ if (error instanceof DotHttpError && (error.status === 401 || error.status === 403)) {
2344
+ consola.warn(`[DotCMS PageClient]: Style editor schemas request failed with ${error.status} — ` +
2345
+ 'make sure your DotCMS client is configured with a valid authToken that has READ access to the page.');
2346
+ }
2347
+ else {
2348
+ consola.debug('[DotCMS PageClient]: Skipping style editor schemas:', error);
2349
+ }
2350
+ return [];
2351
+ }
2352
+ }
2310
2353
  /**
2311
2354
  * Executes a GraphQL query against the DotCMS API.
2312
2355
  *
@@ -2466,6 +2509,7 @@ class PageClient extends BaseApiClient {
2466
2509
  data: response.errors
2467
2510
  });
2468
2511
  }
2512
+ const styleEditorSchemas = await fetchStyleEditorSchemas(pageResponse.page.identifier, this.config, this.requestOptions, this.httpClient);
2469
2513
  const contentResponse = mapContentResponse(response.data, Object.keys(content));
2470
2514
  return {
2471
2515
  pageAsset: pageResponse,
@@ -2473,7 +2517,8 @@ class PageClient extends BaseApiClient {
2473
2517
  graphql: {
2474
2518
  query: completeQuery,
2475
2519
  variables: requestVariables
2476
- }
2520
+ },
2521
+ ...(styleEditorSchemas.length > 0 && { styleEditorSchemas })
2477
2522
  };
2478
2523
  }
2479
2524
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/client",
3
- "version": "1.5.1-next.1964",
3
+ "version": "1.5.1-next.1965",
4
4
  "description": "Official JavaScript library for interacting with DotCMS REST APIs.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,4 +1,4 @@
1
- import { DotCMSClientConfig, DotCMSPageRequestParams, DotCMSPageResponse, DotCMSExtendedPageResponse, DotCMSComposedPageResponse, DotHttpClient, DotRequestOptions } from '@dotcms/types';
1
+ import { DotCMSClientConfig, DotCMSComposedPageResponse, DotCMSExtendedPageResponse, DotCMSPageRequestParams, DotCMSPageResponse, DotHttpClient, DotRequestOptions } from '@dotcms/types';
2
2
  import { BaseApiClient } from '../base/api/base-api';
3
3
  /**
4
4
  * Client for interacting with the DotCMS Page API.
@@ -1,4 +1,5 @@
1
- import { DotGraphQLApiResponse, DotHttpClient } from '@dotcms/types';
1
+ import { DotCMSClientConfig, DotGraphQLApiResponse, DotHttpClient, DotRequestOptions } from '@dotcms/types';
2
+ import { StyleEditorFormSchema } from '@dotcms/types/internal';
2
3
  /**
3
4
  * Builds a GraphQL query for retrieving page content from DotCMS.
4
5
  *
@@ -26,6 +27,13 @@ export declare function buildQuery(queryData: Record<string, string>): string;
26
27
  * @returns {Record<string, unknown> | undefined} New object containing only the specified keys
27
28
  */
28
29
  export declare function mapContentResponse(responseData: Record<string, unknown> | undefined, keys: string[]): Record<string, unknown> | undefined;
30
+ /**
31
+ * Loads style editor schemas from GET /api/v1/page/{pageId}/contenttype-schema.
32
+ * Requires READ on the page; failures are silently ignored so callers still work without auth.
33
+ *
34
+ * @internal
35
+ */
36
+ export declare function fetchStyleEditorSchemas(pageId: string | undefined, config: DotCMSClientConfig, requestOptions: DotRequestOptions, httpClient: DotHttpClient): Promise<StyleEditorFormSchema[]>;
29
37
  /**
30
38
  * Executes a GraphQL query against the DotCMS API.
31
39
  *