@dotcms/client 1.5.1-next.1996 → 1.5.1-next.2011

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
@@ -2160,6 +2160,7 @@ const buildPageQuery = ({ page, fragments, additionalQueries, verbose = false })
2160
2160
  lockedBy
2161
2161
  lockedByName
2162
2162
  numberContents
2163
+ styleEditorSchemas
2163
2164
  urlContentMap {
2164
2165
  _map
2165
2166
  }
@@ -2309,46 +2310,6 @@ function mapContentResponse(responseData, keys) {
2309
2310
  return accumulator;
2310
2311
  }, {});
2311
2312
  }
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 (!pageId) {
2320
- console.warn('[DotCMS PageClient]: fetchStyleEditorSchemas called without a pageId — ' +
2321
- 'make sure "identifier" is included in your GraphQL page fragment.');
2322
- return [];
2323
- }
2324
- try {
2325
- const url = new URL(config.dotcmsUrl);
2326
- url.pathname = `/api/v1/page/${encodeURIComponent(pageId)}/contenttype-schema`;
2327
- const data = await httpClient.request(url.toString(), {
2328
- ...requestOptions,
2329
- method: 'GET',
2330
- headers: {
2331
- Accept: 'application/json',
2332
- ...requestOptions.headers
2333
- }
2334
- });
2335
- const { entity } = data ?? {};
2336
- if (!Array.isArray(entity)) {
2337
- return [];
2338
- }
2339
- return entity;
2340
- }
2341
- catch (error) {
2342
- if (error instanceof types.DotHttpError && (error.status === 401 || error.status === 403)) {
2343
- console.warn(`[DotCMS PageClient]: Style editor schemas request failed with ${error.status} — ` +
2344
- 'make sure your DotCMS client is configured with a valid authToken that has READ access to the page.');
2345
- }
2346
- else {
2347
- console.warn('[DotCMS PageClient]: Skipping style editor schemas:', error);
2348
- }
2349
- return [];
2350
- }
2351
- }
2352
2313
  /**
2353
2314
  * Executes a GraphQL query against the DotCMS API.
2354
2315
  *
@@ -2551,6 +2512,7 @@ class PageClient extends BaseApiClient {
2551
2512
  const pageResponse = response.data.page
2552
2513
  ? internal.graphqlToPageEntity(response.data.page)
2553
2514
  : null;
2515
+ const styleEditorSchemas = pageResponse ? pageResponse.page.styleEditorSchemas : [];
2554
2516
  if (!pageResponse) {
2555
2517
  throw new types.DotErrorPage(`Page '${normalizedUrl}' was not found`, 404, 'NOT_FOUND', new types.DotHttpError({
2556
2518
  status: 404,
@@ -2559,7 +2521,6 @@ class PageClient extends BaseApiClient {
2559
2521
  data: response.errors
2560
2522
  }), { query: completeQuery, variables: requestVariables });
2561
2523
  }
2562
- const styleEditorSchemas = await fetchStyleEditorSchemas(pageResponse.page.identifier, this.config, this.requestOptions, this.httpClient);
2563
2524
  // 5. Build response — include any non-fatal errors for consumers to inspect
2564
2525
  const contentResponse = mapContentResponse(response.data, Object.keys(content));
2565
2526
  return {
@@ -2570,7 +2531,7 @@ class PageClient extends BaseApiClient {
2570
2531
  variables: requestVariables
2571
2532
  },
2572
2533
  errors: response.errors?.length ? response.errors : undefined,
2573
- ...(styleEditorSchemas.length > 0 && { styleEditorSchemas })
2534
+ ...(styleEditorSchemas?.length && { styleEditorSchemas })
2574
2535
  };
2575
2536
  }
2576
2537
  catch (error) {
package/index.esm.js CHANGED
@@ -2158,6 +2158,7 @@ const buildPageQuery = ({ page, fragments, additionalQueries, verbose = false })
2158
2158
  lockedBy
2159
2159
  lockedByName
2160
2160
  numberContents
2161
+ styleEditorSchemas
2161
2162
  urlContentMap {
2162
2163
  _map
2163
2164
  }
@@ -2307,46 +2308,6 @@ function mapContentResponse(responseData, keys) {
2307
2308
  return accumulator;
2308
2309
  }, {});
2309
2310
  }
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 (!pageId) {
2318
- console.warn('[DotCMS PageClient]: fetchStyleEditorSchemas called without a pageId — ' +
2319
- 'make sure "identifier" is included in your GraphQL page fragment.');
2320
- return [];
2321
- }
2322
- try {
2323
- const url = new URL(config.dotcmsUrl);
2324
- url.pathname = `/api/v1/page/${encodeURIComponent(pageId)}/contenttype-schema`;
2325
- const data = await httpClient.request(url.toString(), {
2326
- ...requestOptions,
2327
- method: 'GET',
2328
- headers: {
2329
- Accept: 'application/json',
2330
- ...requestOptions.headers
2331
- }
2332
- });
2333
- const { entity } = data ?? {};
2334
- if (!Array.isArray(entity)) {
2335
- return [];
2336
- }
2337
- return entity;
2338
- }
2339
- catch (error) {
2340
- if (error instanceof DotHttpError && (error.status === 401 || error.status === 403)) {
2341
- console.warn(`[DotCMS PageClient]: Style editor schemas request failed with ${error.status} — ` +
2342
- 'make sure your DotCMS client is configured with a valid authToken that has READ access to the page.');
2343
- }
2344
- else {
2345
- console.warn('[DotCMS PageClient]: Skipping style editor schemas:', error);
2346
- }
2347
- return [];
2348
- }
2349
- }
2350
2311
  /**
2351
2312
  * Executes a GraphQL query against the DotCMS API.
2352
2313
  *
@@ -2549,6 +2510,7 @@ class PageClient extends BaseApiClient {
2549
2510
  const pageResponse = response.data.page
2550
2511
  ? graphqlToPageEntity(response.data.page)
2551
2512
  : null;
2513
+ const styleEditorSchemas = pageResponse ? pageResponse.page.styleEditorSchemas : [];
2552
2514
  if (!pageResponse) {
2553
2515
  throw new DotErrorPage(`Page '${normalizedUrl}' was not found`, 404, 'NOT_FOUND', new DotHttpError({
2554
2516
  status: 404,
@@ -2557,7 +2519,6 @@ class PageClient extends BaseApiClient {
2557
2519
  data: response.errors
2558
2520
  }), { query: completeQuery, variables: requestVariables });
2559
2521
  }
2560
- const styleEditorSchemas = await fetchStyleEditorSchemas(pageResponse.page.identifier, this.config, this.requestOptions, this.httpClient);
2561
2522
  // 5. Build response — include any non-fatal errors for consumers to inspect
2562
2523
  const contentResponse = mapContentResponse(response.data, Object.keys(content));
2563
2524
  return {
@@ -2568,7 +2529,7 @@ class PageClient extends BaseApiClient {
2568
2529
  variables: requestVariables
2569
2530
  },
2570
2531
  errors: response.errors?.length ? response.errors : undefined,
2571
- ...(styleEditorSchemas.length > 0 && { styleEditorSchemas })
2532
+ ...(styleEditorSchemas?.length && { styleEditorSchemas })
2572
2533
  };
2573
2534
  }
2574
2535
  catch (error) {
package/internal.cjs.js CHANGED
@@ -42,7 +42,10 @@ const graphqlToPageEntity = (page) => {
42
42
  containers: parseContainers(containers),
43
43
  page: {
44
44
  ...data,
45
- ...typedPageAsset
45
+ ...typedPageAsset,
46
+ // GQL returns null when not in EDIT_MODE; normalize to undefined so the
47
+ // DotCMSPage type (StyleEditorFormSchema[], non-null) remains accurate.
48
+ styleEditorSchemas: typedPageAsset.styleEditorSchemas ?? undefined
46
49
  }
47
50
  };
48
51
  };
package/internal.esm.js CHANGED
@@ -40,7 +40,10 @@ const graphqlToPageEntity = (page) => {
40
40
  containers: parseContainers(containers),
41
41
  page: {
42
42
  ...data,
43
- ...typedPageAsset
43
+ ...typedPageAsset,
44
+ // GQL returns null when not in EDIT_MODE; normalize to undefined so the
45
+ // DotCMSPage type (StyleEditorFormSchema[], non-null) remains accurate.
46
+ styleEditorSchemas: typedPageAsset.styleEditorSchemas ?? undefined
44
47
  }
45
48
  };
46
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/client",
3
- "version": "1.5.1-next.1996",
3
+ "version": "1.5.1-next.2011",
4
4
  "description": "Official JavaScript library for interacting with DotCMS REST APIs.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,4 @@
1
- import { DotCMSClientConfig, DotGraphQLApiResponse, DotHttpClient, DotRequestOptions } from '@dotcms/types';
2
- import { StyleEditorFormSchema } from '@dotcms/types/internal';
1
+ import { DotGraphQLApiResponse, DotHttpClient } from '@dotcms/types';
3
2
  /**
4
3
  * Builds a GraphQL query for retrieving page content from DotCMS.
5
4
  *
@@ -28,13 +27,6 @@ export declare function buildQuery(queryData: Record<string, string>): string;
28
27
  * @returns {Record<string, unknown> | undefined} New object containing only the specified keys
29
28
  */
30
29
  export declare function mapContentResponse(responseData: Record<string, unknown> | undefined, keys: string[]): Record<string, unknown> | undefined;
31
- /**
32
- * Loads style editor schemas from GET /api/v1/page/{pageId}/contenttype-schema.
33
- * Requires READ on the page; failures are silently ignored so callers still work without auth.
34
- *
35
- * @internal
36
- */
37
- export declare function fetchStyleEditorSchemas(pageId: string | undefined, config: DotCMSClientConfig, requestOptions: DotRequestOptions, httpClient: DotHttpClient): Promise<StyleEditorFormSchema[]>;
38
30
  /**
39
31
  * Executes a GraphQL query against the DotCMS API.
40
32
  *