@dotcms/types 1.5.1-next.1964 → 1.5.1-next.1972

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
@@ -156,9 +156,11 @@ exports.UVEEventType = void 0;
156
156
  * Wraps HTTP errors and adds page-specific context including GraphQL information
157
157
  */
158
158
  class DotErrorPage extends Error {
159
- constructor(message, httpError, graphql) {
159
+ constructor(message, status = 500, code = 'UNKNOWN', httpError, graphql) {
160
160
  super(message);
161
161
  this.name = 'DotCMSPageError';
162
+ this.status = status;
163
+ this.code = code;
162
164
  this.httpError = httpError;
163
165
  this.graphql = graphql;
164
166
  // Ensure proper prototype chain for instanceof checks
@@ -171,6 +173,8 @@ class DotErrorPage extends Error {
171
173
  return {
172
174
  name: this.name,
173
175
  message: this.message,
176
+ status: this.status,
177
+ code: this.code,
174
178
  httpError: this.httpError?.toJSON(),
175
179
  graphql: this.graphql,
176
180
  stack: this.stack
package/index.esm.js CHANGED
@@ -154,9 +154,11 @@ var UVEEventType;
154
154
  * Wraps HTTP errors and adds page-specific context including GraphQL information
155
155
  */
156
156
  class DotErrorPage extends Error {
157
- constructor(message, httpError, graphql) {
157
+ constructor(message, status = 500, code = 'UNKNOWN', httpError, graphql) {
158
158
  super(message);
159
159
  this.name = 'DotCMSPageError';
160
+ this.status = status;
161
+ this.code = code;
160
162
  this.httpError = httpError;
161
163
  this.graphql = graphql;
162
164
  // Ensure proper prototype chain for instanceof checks
@@ -169,6 +171,8 @@ class DotErrorPage extends Error {
169
171
  return {
170
172
  name: this.name,
171
173
  message: this.message,
174
+ status: this.status,
175
+ code: this.code,
172
176
  httpError: this.httpError?.toJSON(),
173
177
  graphql: this.graphql,
174
178
  stack: this.stack
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/types",
3
- "version": "1.5.1-next.1964",
3
+ "version": "1.5.1-next.1972",
4
4
  "keywords": [
5
5
  "dotCMS",
6
6
  "CMS",
package/src/internal.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './lib/events/internal';
3
3
  export * from './lib/editor/internal';
4
4
  export * from './lib/ai/internal';
5
5
  export * from './lib/client/internal';
6
+ export * from './lib/style-editor/internal';
@@ -315,4 +315,11 @@ export interface DotCMSClientConfig {
315
315
  * @example `{ httpClient: new AxiosHttpClient() }`
316
316
  */
317
317
  httpClient?: DotHttpClient;
318
+ /**
319
+ * Controls the verbosity of error logs from the SDK.
320
+ * - `'default'`: logs the error message only (default)
321
+ * - `'verbose'`: also logs the HTTP status, error code, and the GraphQL query and variables
322
+ * @example `logLevel: 'verbose'`
323
+ */
324
+ logLevel?: 'default' | 'verbose';
318
325
  }
@@ -1,4 +1,5 @@
1
1
  import { DotHttpError } from '../client/public';
2
+ import { StyleEditorFormSchema } from '../style-editor/internal';
2
3
  /**
3
4
  * Represents a map of style property keys and their corresponding values
4
5
  * for use in the style editor.
@@ -1128,27 +1129,53 @@ export interface DotCMSPageContainerContentlets {
1128
1129
  contentlets: DotCMSBasicContentlet[];
1129
1130
  }
1130
1131
  /**
1131
- * dotCMS's GraphQL API response with a page and content query
1132
+ * Raw GraphQL API response for a dotCMS page query.
1133
+ *
1134
+ * Shape varies by failure mode:
1135
+ * - Success: { data: { page: DotCMSGraphQLPage, ... }, errors: undefined }
1136
+ * - Page not found: { data: { page: null }, errors: [{ extensions: { code: 'NOT_FOUND' } }] }
1137
+ * - Bad query: { data: null, errors: [{ message: '...' }] }
1138
+ * - Partial failure: { data: { page: DotCMSGraphQLPage, ... }, errors: [...] }
1139
+ * (page loaded but secondary content queries failed)
1140
+ *
1141
+ * Always check `errors` even when `data` is present — partial failures surface both.
1132
1142
  */
1133
1143
  export interface DotGraphQLApiResponse {
1134
1144
  data: {
1135
- page: DotCMSGraphQLPage;
1145
+ page: DotCMSGraphQLPage | null;
1136
1146
  content?: Record<string, unknown>;
1137
- };
1147
+ } | null;
1138
1148
  errors?: DotCMSGraphQLError[];
1139
1149
  }
1150
+ /**
1151
+ * Error codes returned by the DotCMS GraphQL API.
1152
+ * - NOT_FOUND: The requested page or resource does not exist (HTTP 404)
1153
+ * - PERMISSION_DENIED: The user lacks permission or is not authenticated (always HTTP 403 — dotCMS does not distinguish 401 vs 403 at the GraphQL layer)
1154
+ * - INVALID_LANGUAGE: The languageId provided is not a valid language (HTTP 400)
1155
+ * - BAD_REQUEST: The GraphQL query itself is malformed or invalid (HTTP 400)
1156
+ */
1157
+ export type DotCMSGraphQLErrorCode = 'NOT_FOUND' | 'PERMISSION_DENIED' | 'INVALID_LANGUAGE' | 'BAD_REQUEST';
1140
1158
  /**
1141
1159
  * Represents a GraphQL error
1142
1160
  * @interface DotCMSGraphQLError
1143
1161
  */
1144
1162
  export interface DotCMSGraphQLError {
1145
1163
  message: string;
1146
- locations: {
1164
+ locations?: {
1147
1165
  line: number;
1148
1166
  column: number;
1149
1167
  }[];
1150
- extensions: {
1151
- classification: string;
1168
+ path?: string[];
1169
+ extensions?: {
1170
+ classification?: string;
1171
+ /** Structured error code from DotCMS backend — use this for programmatic error handling */
1172
+ code?: DotCMSGraphQLErrorCode;
1173
+ /** HTTP status hint from backend (e.g. 404, 400) */
1174
+ status?: number;
1175
+ /** The type of resource that was not found, if applicable */
1176
+ resourceType?: string;
1177
+ /** The identifier of the resource that was not found, if applicable */
1178
+ resourceId?: string;
1152
1179
  };
1153
1180
  }
1154
1181
  /**
@@ -1157,11 +1184,16 @@ export interface DotCMSGraphQLError {
1157
1184
  export interface DotCMSPageResponse {
1158
1185
  pageAsset: DotCMSPageAsset;
1159
1186
  content?: Record<string, unknown> | unknown;
1187
+ /**
1188
+ * @deprecated Use `errors` instead. Will be removed in August 2026. Kept for backward compatibility — represents the first GraphQL error when present.
1189
+ */
1160
1190
  error?: DotCMSGraphQLError;
1191
+ errors?: DotCMSGraphQLError[];
1161
1192
  graphql: {
1162
1193
  query: string;
1163
1194
  variables: Record<string, unknown>;
1164
1195
  };
1196
+ styleEditorSchemas?: StyleEditorFormSchema[];
1165
1197
  }
1166
1198
  export type DotCMSExtendedPageResponse = Partial<Pick<DotCMSPageResponse, 'pageAsset' | 'content'>>;
1167
1199
  export type DotCMSComposedPageAsset<T extends DotCMSExtendedPageResponse> = T['pageAsset'] extends DotCMSPageResponse['pageAsset'] ? DotCMSPageResponse['pageAsset'] & T['pageAsset'] : DotCMSPageResponse['pageAsset'];
@@ -1176,12 +1208,14 @@ export type DotCMSClientPageGetResponse<T extends DotCMSExtendedPageResponse> =
1176
1208
  * Wraps HTTP errors and adds page-specific context including GraphQL information
1177
1209
  */
1178
1210
  export declare class DotErrorPage extends Error {
1211
+ readonly status: number;
1212
+ readonly code: DotCMSGraphQLErrorCode | 'UNKNOWN';
1179
1213
  readonly httpError?: DotHttpError;
1180
1214
  readonly graphql?: {
1181
1215
  query: string;
1182
1216
  variables: Record<string, unknown>;
1183
1217
  };
1184
- constructor(message: string, httpError?: DotHttpError, graphql?: {
1218
+ constructor(message: string, status?: number, code?: DotCMSGraphQLErrorCode | 'UNKNOWN', httpError?: DotHttpError, graphql?: {
1185
1219
  query: string;
1186
1220
  variables: Record<string, unknown>;
1187
1221
  });
@@ -1191,6 +1225,8 @@ export declare class DotErrorPage extends Error {
1191
1225
  toJSON(): {
1192
1226
  name: string;
1193
1227
  message: string;
1228
+ status: number;
1229
+ code: "UNKNOWN" | DotCMSGraphQLErrorCode;
1194
1230
  httpError: {
1195
1231
  name: string;
1196
1232
  message: string;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Available field types for the style editor.
3
+ */
4
+ export type StyleEditorFieldType = 'input' | 'dropdown' | 'radio' | 'checkboxGroup';
5
+ /**
6
+ * Available input types for input fields in the style editor.
7
+ */
8
+ export type StyleEditorFieldInputType = 'text' | 'number';
9
+ /**
10
+ * Base option object with label and value properties.
11
+ */
12
+ export interface StyleEditorOptionObject {
13
+ label: string;
14
+ value: string;
15
+ }
16
+ /**
17
+ * Extended option object for radio fields with optional image support.
18
+ */
19
+ export interface StyleEditorRadioOptionObject extends StyleEditorOptionObject {
20
+ imageURL?: string;
21
+ }
22
+ /**
23
+ * Option type for dropdown fields.
24
+ */
25
+ export type StyleEditorOption = StyleEditorOptionObject;
26
+ /**
27
+ * Option type for radio fields (supports optional image).
28
+ */
29
+ export type StyleEditorRadioOption = StyleEditorRadioOptionObject;
30
+ /**
31
+ * Checkbox option with a key identifier instead of value.
32
+ */
33
+ export interface StyleEditorCheckboxOption {
34
+ label: string;
35
+ key: string;
36
+ }
37
+ /**
38
+ * Configuration object for normalized field schemas sent to UVE.
39
+ */
40
+ export interface StyleEditorFieldSchemaConfig {
41
+ inputType?: StyleEditorFieldInputType;
42
+ placeholder?: string;
43
+ options?: StyleEditorRadioOptionObject[];
44
+ columns?: 1 | 2;
45
+ }
46
+ /**
47
+ * Normalized field schema sent to UVE.
48
+ */
49
+ export interface StyleEditorFieldSchema {
50
+ id: string;
51
+ type: StyleEditorFieldType;
52
+ label: string;
53
+ config: StyleEditorFieldSchemaConfig;
54
+ }
55
+ /**
56
+ * Normalized section schema sent to UVE.
57
+ */
58
+ export interface StyleEditorSectionSchema {
59
+ title: string;
60
+ fields: StyleEditorFieldSchema[];
61
+ }
62
+ /**
63
+ * Complete normalized form schema sent to UVE.
64
+ * This is the output format after processing a style editor form definition.
65
+ */
66
+ export interface StyleEditorFormSchema {
67
+ contentType: string;
68
+ sections: StyleEditorSectionSchema[];
69
+ }