@dotcms/types 1.5.1-next.1965 → 1.5.1-next.1977
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 +5 -1
- package/index.esm.js +5 -1
- package/package.json +1 -1
- package/src/lib/client/public.d.ts +7 -0
- package/src/lib/page/public.d.ts +41 -7
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
|
@@ -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
|
}
|
package/src/lib/page/public.d.ts
CHANGED
|
@@ -1129,27 +1129,53 @@ export interface DotCMSPageContainerContentlets {
|
|
|
1129
1129
|
contentlets: DotCMSBasicContentlet[];
|
|
1130
1130
|
}
|
|
1131
1131
|
/**
|
|
1132
|
-
*
|
|
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.
|
|
1133
1142
|
*/
|
|
1134
1143
|
export interface DotGraphQLApiResponse {
|
|
1135
1144
|
data: {
|
|
1136
|
-
page: DotCMSGraphQLPage;
|
|
1145
|
+
page: DotCMSGraphQLPage | null;
|
|
1137
1146
|
content?: Record<string, unknown>;
|
|
1138
|
-
};
|
|
1147
|
+
} | null;
|
|
1139
1148
|
errors?: DotCMSGraphQLError[];
|
|
1140
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';
|
|
1141
1158
|
/**
|
|
1142
1159
|
* Represents a GraphQL error
|
|
1143
1160
|
* @interface DotCMSGraphQLError
|
|
1144
1161
|
*/
|
|
1145
1162
|
export interface DotCMSGraphQLError {
|
|
1146
1163
|
message: string;
|
|
1147
|
-
locations
|
|
1164
|
+
locations?: {
|
|
1148
1165
|
line: number;
|
|
1149
1166
|
column: number;
|
|
1150
1167
|
}[];
|
|
1151
|
-
|
|
1152
|
-
|
|
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;
|
|
1153
1179
|
};
|
|
1154
1180
|
}
|
|
1155
1181
|
/**
|
|
@@ -1158,7 +1184,11 @@ export interface DotCMSGraphQLError {
|
|
|
1158
1184
|
export interface DotCMSPageResponse {
|
|
1159
1185
|
pageAsset: DotCMSPageAsset;
|
|
1160
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
|
+
*/
|
|
1161
1190
|
error?: DotCMSGraphQLError;
|
|
1191
|
+
errors?: DotCMSGraphQLError[];
|
|
1162
1192
|
graphql: {
|
|
1163
1193
|
query: string;
|
|
1164
1194
|
variables: Record<string, unknown>;
|
|
@@ -1178,12 +1208,14 @@ export type DotCMSClientPageGetResponse<T extends DotCMSExtendedPageResponse> =
|
|
|
1178
1208
|
* Wraps HTTP errors and adds page-specific context including GraphQL information
|
|
1179
1209
|
*/
|
|
1180
1210
|
export declare class DotErrorPage extends Error {
|
|
1211
|
+
readonly status: number;
|
|
1212
|
+
readonly code: DotCMSGraphQLErrorCode | 'UNKNOWN';
|
|
1181
1213
|
readonly httpError?: DotHttpError;
|
|
1182
1214
|
readonly graphql?: {
|
|
1183
1215
|
query: string;
|
|
1184
1216
|
variables: Record<string, unknown>;
|
|
1185
1217
|
};
|
|
1186
|
-
constructor(message: string, httpError?: DotHttpError, graphql?: {
|
|
1218
|
+
constructor(message: string, status?: number, code?: DotCMSGraphQLErrorCode | 'UNKNOWN', httpError?: DotHttpError, graphql?: {
|
|
1187
1219
|
query: string;
|
|
1188
1220
|
variables: Record<string, unknown>;
|
|
1189
1221
|
});
|
|
@@ -1193,6 +1225,8 @@ export declare class DotErrorPage extends Error {
|
|
|
1193
1225
|
toJSON(): {
|
|
1194
1226
|
name: string;
|
|
1195
1227
|
message: string;
|
|
1228
|
+
status: number;
|
|
1229
|
+
code: "UNKNOWN" | DotCMSGraphQLErrorCode;
|
|
1196
1230
|
httpError: {
|
|
1197
1231
|
name: string;
|
|
1198
1232
|
message: string;
|