Skip to content

Commit c5c08ae

Browse files
committed
types:ref: update jsdocs for targetUrl property in error response schemas
- Moved the targetUrl property to a consistent position in BaseErrorResponseSchema, LinksErrorResponseSchema, and ReadResponseBaseSchema to enhance clarity. - Updated documentation and examples to reflect the changes, ensuring better understanding of the error response structure for developers.
1 parent d4529e5 commit c5c08ae

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

packages/types/src/common/response-schemas.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import * as z from 'zod/v4';
1414
* ```typescript
1515
* const errorResponse = {
1616
* success: false,
17-
* targetUrl: 'https://example.com/article',
1817
* requestUrl: 'https://example.com/article#fragment',
18+
* targetUrl: 'https://example.com/article',
1919
* timestamp: '2024-01-15T10:30:00.000Z'
2020
* error: 'Failed to fetch: 404 Not Found',
2121
* };
@@ -28,11 +28,6 @@ export const BaseErrorResponseSchema = z
2828
description: 'Indicates that the operation failed',
2929
examples: [false],
3030
}),
31-
/* The URL that was being processed when the error occurred */
32-
targetUrl: z.string().meta({
33-
description: 'The URL that was being processed when the error occurred',
34-
examples: ['https://example.com/article'],
35-
}),
3631
/* The URL, raw url, that was requested to be processed and might be different from the target url */
3732
requestUrl: z
3833
.string()
@@ -42,6 +37,11 @@ export const BaseErrorResponseSchema = z
4237
'The URL, raw url, that was requested to be processed and might be different from the target url',
4338
examples: ['https://example.com/article#fragment'],
4439
}),
40+
/* The URL that was being processed when the error occurred */
41+
targetUrl: z.string().meta({
42+
description: 'The URL that was being processed when the error occurred',
43+
examples: ['https://example.com/article'],
44+
}),
4545
/* ISO timestamp when the error occurred */
4646
timestamp: z.string().meta({
4747
description: 'ISO timestamp when the error occurred',

packages/types/src/routers/links/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ export const LinksErrorResponseSchema = BaseErrorResponseSchema.extend({
875875
examples: [
876876
{
877877
success: false,
878+
requestUrl: 'https://example.com/article#fragment',
878879
targetUrl: 'https://example.com',
879880
timestamp: '2024-01-15T10:30:00.000Z',
880881
error: 'Failed to fetch: 404 Not Found',
@@ -1062,8 +1063,8 @@ export type LinksSuccessResponse = z.infer<typeof LinksSuccessResponseSchema>;
10621063
* Contains information about what went wrong.
10631064
*
10641065
* @property success - Whether the operation was successful
1065-
* @property targetUrl - The URL that was requested to be scraped
10661066
* @property [requestUrl] - URL, raw url, that was requested to be processed and might be different from the target url
1067+
* @property targetUrl - The URL that was requested to be scraped
10671068
* @property timestamp - ISO timestamp when the request was processed
10681069
* @property error - Error message describing what went wrong
10691070
* @property tree - Partial site map tree if available
@@ -1072,8 +1073,8 @@ export type LinksSuccessResponse = z.infer<typeof LinksSuccessResponseSchema>;
10721073
* ```typescript
10731074
* const errorResponse: LinksErrorResponse = {
10741075
* success: false,
1075-
* targetUrl: "https://example.com",
10761076
* requestUrl: "https://example.com/article#fragment",
1077+
* targetUrl: "https://example.com",
10771078
* timestamp: "2025-04-02T14:28:23.000Z",
10781079
* error: "Failed to connect to the server"
10791080
* };

packages/types/src/routers/read/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ export const ReadResponseBaseSchema = z.object({
218218
*
219219
* @property {false} success - Always false for error responses
220220
* @property {string} error - Error message describing what went wrong
221-
* @property {string} targetUrl - URL that was being processed when error occurred
222221
* @property {string} [requestUrl] - URL, raw url, that was requested to be processed and might be different from the target url
222+
* @property {string} targetUrl - URL that was being processed when error occurred
223223
* @property {string} timestamp - ISO timestamp when the error occurred
224224
*
225225
* @see {@link BaseErrorResponseSchema} for base error response structure
@@ -229,8 +229,8 @@ export const ReadResponseBaseSchema = z.object({
229229
* {
230230
* success: false,
231231
* error: 'Failed to fetch URL',
232-
* targetUrl: 'https://example.com/article',
233232
* requestUrl: 'https://example.com/article#fragment', // optional
233+
* targetUrl: 'https://example.com/article',
234234
* timestamp: '2025-09-12T10:30:00.000Z'
235235
* }
236236
* ```
@@ -452,17 +452,17 @@ export type ReadResponseBase = z.infer<typeof ReadResponseBaseSchema>;
452452
*
453453
* @property {false} success - Always false for error responses
454454
* @property {string} error - Error message describing what went wrong
455-
* @property {string} targetUrl - URL that was being processed when error occurred
456455
* @property {string} [requestUrl] - URL, raw url, that was requested to be processed and might be different from the target url
456+
* @property {string} targetUrl - URL that was being processed when error occurred
457457
* @property {string} timestamp - ISO timestamp when the error occurred
458458
*
459459
* @example
460460
* ```typescript
461461
* const errorResponse: ReadErrorResponse = {
462462
* success: false,
463463
* error: 'Failed to fetch URL',
464-
* targetUrl: 'https://example.com/article',
465464
* requestUrl: 'https://example.com/article#fragment', // optional
465+
* targetUrl: 'https://example.com/article',
466466
* timestamp: '2025-09-12T10:30:00.000Z'
467467
* };
468468
* ```

0 commit comments

Comments
 (0)