promidas 2.0.0
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/LICENSE +21 -0
- package/README.md +179 -0
- package/dist/builder.d.ts +158 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +255 -0
- package/dist/builder.js.map +1 -0
- package/dist/factory.d.ts +154 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +243 -0
- package/dist/factory.js.map +1 -0
- package/dist/fetcher/client/config.d.ts +140 -0
- package/dist/fetcher/client/config.d.ts.map +1 -0
- package/dist/fetcher/client/config.js +2 -0
- package/dist/fetcher/client/config.js.map +1 -0
- package/dist/fetcher/client/fetch-with-progress.d.ts +156 -0
- package/dist/fetcher/client/fetch-with-progress.d.ts.map +1 -0
- package/dist/fetcher/client/fetch-with-progress.js +313 -0
- package/dist/fetcher/client/fetch-with-progress.js.map +1 -0
- package/dist/fetcher/client/fetch-with-timeout.d.ts +6 -0
- package/dist/fetcher/client/fetch-with-timeout.d.ts.map +1 -0
- package/dist/fetcher/client/fetch-with-timeout.js +48 -0
- package/dist/fetcher/client/fetch-with-timeout.js.map +1 -0
- package/dist/fetcher/client/protopedia-api-custom-client.d.ts +141 -0
- package/dist/fetcher/client/protopedia-api-custom-client.d.ts.map +1 -0
- package/dist/fetcher/client/protopedia-api-custom-client.js +268 -0
- package/dist/fetcher/client/protopedia-api-custom-client.js.map +1 -0
- package/dist/fetcher/client/select-custom-fetch.d.ts +58 -0
- package/dist/fetcher/client/select-custom-fetch.d.ts.map +1 -0
- package/dist/fetcher/client/select-custom-fetch.js +58 -0
- package/dist/fetcher/client/select-custom-fetch.js.map +1 -0
- package/dist/fetcher/errors/fetcher-error.d.ts +10 -0
- package/dist/fetcher/errors/fetcher-error.d.ts.map +1 -0
- package/dist/fetcher/errors/fetcher-error.js +15 -0
- package/dist/fetcher/errors/fetcher-error.js.map +1 -0
- package/dist/fetcher/index.d.ts +73 -0
- package/dist/fetcher/index.d.ts.map +1 -0
- package/dist/fetcher/index.js +70 -0
- package/dist/fetcher/index.js.map +1 -0
- package/dist/fetcher/types/index.d.ts +9 -0
- package/dist/fetcher/types/index.d.ts.map +1 -0
- package/dist/fetcher/types/index.js +7 -0
- package/dist/fetcher/types/index.js.map +1 -0
- package/dist/fetcher/types/progress-event.types.d.ts +221 -0
- package/dist/fetcher/types/progress-event.types.d.ts.map +1 -0
- package/dist/fetcher/types/progress-event.types.js +10 -0
- package/dist/fetcher/types/progress-event.types.js.map +1 -0
- package/dist/fetcher/types/prototype-api.types.d.ts +106 -0
- package/dist/fetcher/types/prototype-api.types.d.ts.map +1 -0
- package/dist/fetcher/types/prototype-api.types.js +2 -0
- package/dist/fetcher/types/prototype-api.types.js.map +1 -0
- package/dist/fetcher/types/result.types.d.ts +75 -0
- package/dist/fetcher/types/result.types.d.ts.map +1 -0
- package/dist/fetcher/types/result.types.js +2 -0
- package/dist/fetcher/types/result.types.js.map +1 -0
- package/dist/fetcher/utils/create-client-fetch.d.ts +63 -0
- package/dist/fetcher/utils/create-client-fetch.d.ts.map +1 -0
- package/dist/fetcher/utils/create-client-fetch.js +89 -0
- package/dist/fetcher/utils/create-client-fetch.js.map +1 -0
- package/dist/fetcher/utils/create-fetch-with-stripped-headers.d.ts +6 -0
- package/dist/fetcher/utils/create-fetch-with-stripped-headers.d.ts.map +1 -0
- package/dist/fetcher/utils/create-fetch-with-stripped-headers.js +40 -0
- package/dist/fetcher/utils/create-fetch-with-stripped-headers.js.map +1 -0
- package/dist/fetcher/utils/errors/handler.d.ts +58 -0
- package/dist/fetcher/utils/errors/handler.d.ts.map +1 -0
- package/dist/fetcher/utils/errors/handler.js +243 -0
- package/dist/fetcher/utils/errors/handler.js.map +1 -0
- package/dist/fetcher/utils/errors/messages.d.ts +75 -0
- package/dist/fetcher/utils/errors/messages.d.ts.map +1 -0
- package/dist/fetcher/utils/errors/messages.js +88 -0
- package/dist/fetcher/utils/errors/messages.js.map +1 -0
- package/dist/fetcher/utils/index.d.ts +13 -0
- package/dist/fetcher/utils/index.d.ts.map +1 -0
- package/dist/fetcher/utils/index.js +12 -0
- package/dist/fetcher/utils/index.js.map +1 -0
- package/dist/fetcher/utils/log-timestamp-normalization-warnings.d.ts +10 -0
- package/dist/fetcher/utils/log-timestamp-normalization-warnings.d.ts.map +1 -0
- package/dist/fetcher/utils/log-timestamp-normalization-warnings.js +32 -0
- package/dist/fetcher/utils/log-timestamp-normalization-warnings.js.map +1 -0
- package/dist/fetcher/utils/normalize-protopedia-timestamp.d.ts +59 -0
- package/dist/fetcher/utils/normalize-protopedia-timestamp.d.ts.map +1 -0
- package/dist/fetcher/utils/normalize-protopedia-timestamp.js +81 -0
- package/dist/fetcher/utils/normalize-protopedia-timestamp.js.map +1 -0
- package/dist/fetcher/utils/normalize-prototype.d.ts +56 -0
- package/dist/fetcher/utils/normalize-prototype.d.ts.map +1 -0
- package/dist/fetcher/utils/normalize-prototype.js +113 -0
- package/dist/fetcher/utils/normalize-prototype.js.map +1 -0
- package/dist/fetcher/utils/sanitize-options.d.ts +14 -0
- package/dist/fetcher/utils/sanitize-options.d.ts.map +1 -0
- package/dist/fetcher/utils/sanitize-options.js +16 -0
- package/dist/fetcher/utils/sanitize-options.js.map +1 -0
- package/dist/fetcher/utils/string-parsers.d.ts +45 -0
- package/dist/fetcher/utils/string-parsers.d.ts.map +1 -0
- package/dist/fetcher/utils/string-parsers.js +53 -0
- package/dist/fetcher/utils/string-parsers.js.map +1 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/console-logger.d.ts +74 -0
- package/dist/logger/console-logger.d.ts.map +1 -0
- package/dist/logger/console-logger.js +113 -0
- package/dist/logger/console-logger.js.map +1 -0
- package/dist/logger/factory.d.ts +88 -0
- package/dist/logger/factory.d.ts.map +1 -0
- package/dist/logger/factory.js +94 -0
- package/dist/logger/factory.js.map +1 -0
- package/dist/logger/index.d.ts +42 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +41 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/logger.types.d.ts +49 -0
- package/dist/logger/logger.types.d.ts.map +1 -0
- package/dist/logger/logger.types.js +2 -0
- package/dist/logger/logger.types.js.map +1 -0
- package/dist/repository/errors/validation-error.d.ts +24 -0
- package/dist/repository/errors/validation-error.d.ts.map +1 -0
- package/dist/repository/errors/validation-error.js +26 -0
- package/dist/repository/errors/validation-error.js.map +1 -0
- package/dist/repository/index.d.ts +122 -0
- package/dist/repository/index.d.ts.map +1 -0
- package/dist/repository/index.js +44 -0
- package/dist/repository/index.js.map +1 -0
- package/dist/repository/protopedia-in-memory-repository.d.ts +560 -0
- package/dist/repository/protopedia-in-memory-repository.d.ts.map +1 -0
- package/dist/repository/protopedia-in-memory-repository.js +929 -0
- package/dist/repository/protopedia-in-memory-repository.js.map +1 -0
- package/dist/repository/schemas/index.d.ts +9 -0
- package/dist/repository/schemas/index.d.ts.map +1 -0
- package/dist/repository/schemas/index.js +11 -0
- package/dist/repository/schemas/index.js.map +1 -0
- package/dist/repository/schemas/params.d.ts +44 -0
- package/dist/repository/schemas/params.d.ts.map +1 -0
- package/dist/repository/schemas/params.js +44 -0
- package/dist/repository/schemas/params.js.map +1 -0
- package/dist/repository/schemas/serializable-snapshot.d.ts +33 -0
- package/dist/repository/schemas/serializable-snapshot.d.ts.map +1 -0
- package/dist/repository/schemas/serializable-snapshot.js +45 -0
- package/dist/repository/schemas/serializable-snapshot.js.map +1 -0
- package/dist/repository/types/analysis.types.d.ts +89 -0
- package/dist/repository/types/analysis.types.d.ts.map +1 -0
- package/dist/repository/types/analysis.types.js +2 -0
- package/dist/repository/types/analysis.types.js.map +1 -0
- package/dist/repository/types/index.d.ts +12 -0
- package/dist/repository/types/index.d.ts.map +1 -0
- package/dist/repository/types/index.js +7 -0
- package/dist/repository/types/index.js.map +1 -0
- package/dist/repository/types/repository-events.types.d.ts +110 -0
- package/dist/repository/types/repository-events.types.d.ts.map +1 -0
- package/dist/repository/types/repository-events.types.js +2 -0
- package/dist/repository/types/repository-events.types.js.map +1 -0
- package/dist/repository/types/repository.types.d.ts +330 -0
- package/dist/repository/types/repository.types.d.ts.map +1 -0
- package/dist/repository/types/repository.types.js +2 -0
- package/dist/repository/types/repository.types.js.map +1 -0
- package/dist/repository/types/result.types.d.ts +55 -0
- package/dist/repository/types/result.types.d.ts.map +1 -0
- package/dist/repository/types/result.types.js +2 -0
- package/dist/repository/types/result.types.js.map +1 -0
- package/dist/repository/types/serialization.types.d.ts +61 -0
- package/dist/repository/types/serialization.types.d.ts.map +1 -0
- package/dist/repository/types/serialization.types.js +2 -0
- package/dist/repository/types/serialization.types.js.map +1 -0
- package/dist/repository/types/snapshot-operation.types.d.ts +140 -0
- package/dist/repository/types/snapshot-operation.types.d.ts.map +1 -0
- package/dist/repository/types/snapshot-operation.types.js +2 -0
- package/dist/repository/types/snapshot-operation.types.js.map +1 -0
- package/dist/repository/utils/convert-fetch-result.d.ts +46 -0
- package/dist/repository/utils/convert-fetch-result.d.ts.map +1 -0
- package/dist/repository/utils/convert-fetch-result.js +59 -0
- package/dist/repository/utils/convert-fetch-result.js.map +1 -0
- package/dist/repository/utils/convert-store-result.d.ts +36 -0
- package/dist/repository/utils/convert-store-result.d.ts.map +1 -0
- package/dist/repository/utils/convert-store-result.js +36 -0
- package/dist/repository/utils/convert-store-result.js.map +1 -0
- package/dist/repository/utils/emit-repository-event-safely.d.ts +5 -0
- package/dist/repository/utils/emit-repository-event-safely.d.ts.map +1 -0
- package/dist/repository/utils/emit-repository-event-safely.js +17 -0
- package/dist/repository/utils/emit-repository-event-safely.js.map +1 -0
- package/dist/repository/utils/index.d.ts +3 -0
- package/dist/repository/utils/index.d.ts.map +1 -0
- package/dist/repository/utils/index.js +3 -0
- package/dist/repository/utils/index.js.map +1 -0
- package/dist/repository/validation/index.d.ts +9 -0
- package/dist/repository/validation/index.d.ts.map +1 -0
- package/dist/repository/validation/index.js +10 -0
- package/dist/repository/validation/index.js.map +1 -0
- package/dist/repository/validation/params-validators.d.ts +46 -0
- package/dist/repository/validation/params-validators.d.ts.map +1 -0
- package/dist/repository/validation/params-validators.js +68 -0
- package/dist/repository/validation/params-validators.js.map +1 -0
- package/dist/repository/validation/serializable-snapshot.d.ts +47 -0
- package/dist/repository/validation/serializable-snapshot.d.ts.map +1 -0
- package/dist/repository/validation/serializable-snapshot.js +104 -0
- package/dist/repository/validation/serializable-snapshot.js.map +1 -0
- package/dist/schemas/index.d.ts +8 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +8 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/normalized-prototype.d.ts +56 -0
- package/dist/schemas/normalized-prototype.d.ts.map +1 -0
- package/dist/schemas/normalized-prototype.js +123 -0
- package/dist/schemas/normalized-prototype.js.map +1 -0
- package/dist/store/errors/store-error.d.ts +148 -0
- package/dist/store/errors/store-error.d.ts.map +1 -0
- package/dist/store/errors/store-error.js +156 -0
- package/dist/store/errors/store-error.js.map +1 -0
- package/dist/store/index.d.ts +84 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +83 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/store.d.ts +295 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +411 -0
- package/dist/store/store.js.map +1 -0
- package/dist/store/types/index.d.ts +2 -0
- package/dist/store/types/index.d.ts.map +1 -0
- package/dist/store/types/index.js +2 -0
- package/dist/store/types/index.js.map +1 -0
- package/dist/store/types/result.types.d.ts +67 -0
- package/dist/store/types/result.types.d.ts.map +1 -0
- package/dist/store/types/result.types.js +2 -0
- package/dist/store/types/result.types.js.map +1 -0
- package/dist/types/codes.d.ts +44 -0
- package/dist/types/codes.d.ts.map +1 -0
- package/dist/types/codes.js +9 -0
- package/dist/types/codes.js.map +1 -0
- package/dist/types/index.d.ts +61 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +60 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/normalized-prototype.d.ts +95 -0
- package/dist/types/normalized-prototype.d.ts.map +1 -0
- package/dist/types/normalized-prototype.js +2 -0
- package/dist/types/normalized-prototype.js.map +1 -0
- package/dist/utils/converters/index.d.ts +15 -0
- package/dist/utils/converters/index.d.ts.map +1 -0
- package/dist/utils/converters/index.js +15 -0
- package/dist/utils/converters/index.js.map +1 -0
- package/dist/utils/converters/license-type.d.ts +23 -0
- package/dist/utils/converters/license-type.d.ts.map +1 -0
- package/dist/utils/converters/license-type.js +38 -0
- package/dist/utils/converters/license-type.js.map +1 -0
- package/dist/utils/converters/release-flag.d.ts +24 -0
- package/dist/utils/converters/release-flag.d.ts.map +1 -0
- package/dist/utils/converters/release-flag.js +40 -0
- package/dist/utils/converters/release-flag.js.map +1 -0
- package/dist/utils/converters/status.d.ts +23 -0
- package/dist/utils/converters/status.d.ts.map +1 -0
- package/dist/utils/converters/status.js +40 -0
- package/dist/utils/converters/status.js.map +1 -0
- package/dist/utils/converters/thanks-flag.d.ts +25 -0
- package/dist/utils/converters/thanks-flag.d.ts.map +1 -0
- package/dist/utils/converters/thanks-flag.js +41 -0
- package/dist/utils/converters/thanks-flag.js.map +1 -0
- package/dist/utils/deep-merge.d.ts +38 -0
- package/dist/utils/deep-merge.d.ts.map +1 -0
- package/dist/utils/deep-merge.js +85 -0
- package/dist/utils/deep-merge.js.map +1 -0
- package/dist/utils/index.d.ts +80 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +85 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger-utils.d.ts +100 -0
- package/dist/utils/logger-utils.d.ts.map +1 -0
- package/dist/utils/logger-utils.js +265 -0
- package/dist/utils/logger-utils.js.map +1 -0
- package/dist/utils/time/constants.d.ts +14 -0
- package/dist/utils/time/constants.d.ts.map +1 -0
- package/dist/utils/time/constants.js +14 -0
- package/dist/utils/time/constants.js.map +1 -0
- package/dist/utils/time/index.d.ts +28 -0
- package/dist/utils/time/index.d.ts.map +1 -0
- package/dist/utils/time/index.js +28 -0
- package/dist/utils/time/index.js.map +1 -0
- package/dist/utils/time/parser.d.ts +91 -0
- package/dist/utils/time/parser.d.ts.map +1 -0
- package/dist/utils/time/parser.js +143 -0
- package/dist/utils/time/parser.js.map +1 -0
- package/dist/utils/validation/index.d.ts +8 -0
- package/dist/utils/validation/index.d.ts.map +1 -0
- package/dist/utils/validation/index.js +7 -0
- package/dist/utils/validation/index.js.map +1 -0
- package/dist/utils/validation/normalized-prototype.d.ts +64 -0
- package/dist/utils/validation/normalized-prototype.d.ts.map +1 -0
- package/dist/utils/validation/normalized-prototype.js +97 -0
- package/dist/utils/validation/normalized-prototype.js.map +1 -0
- package/dist/utils/validation/types.d.ts +62 -0
- package/dist/utils/validation/types.d.ts.map +1 -0
- package/dist/utils/validation/types.js +8 -0
- package/dist/utils/validation/types.js.map +1 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +138 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client fetch function factory.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a factory function that creates a customized fetch function
|
|
5
|
+
* by composing multiple fetch wrappers based on configuration:
|
|
6
|
+
* - Timeout wrapper (if timeoutMs is specified)
|
|
7
|
+
* - Header stripping wrapper (for browser compatibility)
|
|
8
|
+
* - Progress tracking wrapper (if progress features are enabled)
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { createFetchWithTimeout } from '../client/fetch-with-timeout.js';
|
|
13
|
+
import { selectCustomFetch } from '../client/select-custom-fetch.js';
|
|
14
|
+
import { createFetchWithStrippedHeaders } from './create-fetch-with-stripped-headers.js';
|
|
15
|
+
/**
|
|
16
|
+
* Create a customized fetch function with optional features.
|
|
17
|
+
*
|
|
18
|
+
* This function composes multiple fetch wrappers in the following order:
|
|
19
|
+
* 1. Timeout wrapper (if timeoutMs is specified)
|
|
20
|
+
* 2. Header stripping wrapper (if stripHeaders is specified)
|
|
21
|
+
* 3. Progress tracking wrapper (if enableProgressLog or progressCallback is specified)
|
|
22
|
+
*
|
|
23
|
+
* @param params - Configuration parameters for fetch customization
|
|
24
|
+
* @returns Customized fetch function, or undefined to use default fetch
|
|
25
|
+
*
|
|
26
|
+
* @example Basic usage with timeout
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const customFetch = createClientFetch({
|
|
29
|
+
* logger: myLogger,
|
|
30
|
+
* enableProgressLog: false,
|
|
31
|
+
* progressCallback: undefined,
|
|
32
|
+
* timeoutMs: 30000,
|
|
33
|
+
* providedFetch: undefined,
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example With progress tracking
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const customFetch = createClientFetch({
|
|
40
|
+
* logger: myLogger,
|
|
41
|
+
* enableProgressLog: true,
|
|
42
|
+
* progressCallback: (event) => {
|
|
43
|
+
* if (event.type === 'download-progress') {
|
|
44
|
+
* console.log(`Progress: ${event.percentage}%`);
|
|
45
|
+
* }
|
|
46
|
+
* },
|
|
47
|
+
* timeoutMs: undefined,
|
|
48
|
+
* providedFetch: undefined,
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export function createClientFetch(params) {
|
|
53
|
+
const { logger, enableProgressLog, progressCallback, timeoutMs, providedFetch, stripHeaders, } = params;
|
|
54
|
+
const timeoutWrappedFetch = typeof timeoutMs === 'number'
|
|
55
|
+
? createFetchWithTimeout({
|
|
56
|
+
timeoutMs,
|
|
57
|
+
baseFetch: providedFetch,
|
|
58
|
+
})
|
|
59
|
+
: providedFetch;
|
|
60
|
+
const shouldStripHeaders = Array.isArray(stripHeaders) && stripHeaders.length > 0;
|
|
61
|
+
const baseFetchForStripping = shouldStripHeaders
|
|
62
|
+
? (timeoutWrappedFetch ??
|
|
63
|
+
(typeof globalThis.fetch === 'function'
|
|
64
|
+
? globalThis.fetch
|
|
65
|
+
: undefined))
|
|
66
|
+
: undefined;
|
|
67
|
+
const strippedFetch = shouldStripHeaders
|
|
68
|
+
? baseFetchForStripping !== undefined
|
|
69
|
+
? createFetchWithStrippedHeaders({
|
|
70
|
+
baseFetch: baseFetchForStripping,
|
|
71
|
+
headerNames: stripHeaders,
|
|
72
|
+
})
|
|
73
|
+
: undefined
|
|
74
|
+
: timeoutWrappedFetch;
|
|
75
|
+
// If user provides a custom fetch, wrap it with progress tracking.
|
|
76
|
+
// Otherwise, progress tracking wraps the global fetch.
|
|
77
|
+
const selected = selectCustomFetch({
|
|
78
|
+
logger,
|
|
79
|
+
enableProgressLog,
|
|
80
|
+
...(strippedFetch !== undefined && {
|
|
81
|
+
baseFetch: strippedFetch,
|
|
82
|
+
}),
|
|
83
|
+
...(progressCallback !== undefined && {
|
|
84
|
+
onProgressEvent: progressCallback,
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
return selected;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=create-client-fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-client-fetch.js","sourceRoot":"","sources":["../../../lib/fetcher/utils/create-client-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGrE,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAczF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAA+B;IAE/B,MAAM,EACJ,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,YAAY,GACb,GAAG,MAAM,CAAC;IAEX,MAAM,mBAAmB,GACvB,OAAO,SAAS,KAAK,QAAQ;QAC3B,CAAC,CAAC,sBAAsB,CAAC;YACrB,SAAS;YACT,SAAS,EAAE,aAAa;SACzB,CAAC;QACJ,CAAC,CAAC,aAAa,CAAC;IAEpB,MAAM,kBAAkB,GACtB,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IAEzD,MAAM,qBAAqB,GAA6B,kBAAkB;QACxE,CAAC,CAAC,CAAC,mBAAmB;YACpB,CAAC,OAAO,UAAU,CAAC,KAAK,KAAK,UAAU;gBACrC,CAAC,CAAE,UAAU,CAAC,KAAsB;gBACpC,CAAC,CAAC,SAAS,CAAC,CAAC;QACjB,CAAC,CAAC,SAAS,CAAC;IAEd,MAAM,aAAa,GAA6B,kBAAkB;QAChE,CAAC,CAAC,qBAAqB,KAAK,SAAS;YACnC,CAAC,CAAC,8BAA8B,CAAC;gBAC7B,SAAS,EAAE,qBAAqB;gBAChC,WAAW,EAAE,YAAY;aAC1B,CAAC;YACJ,CAAC,CAAC,SAAS;QACb,CAAC,CAAC,mBAAmB,CAAC;IAExB,mEAAmE;IACnE,uDAAuD;IACvD,MAAM,QAAQ,GAAG,iBAAiB,CAAC;QACjC,MAAM;QACN,iBAAiB;QACjB,GAAG,CAAC,aAAa,KAAK,SAAS,IAAI;YACjC,SAAS,EAAE,aAAa;SACzB,CAAC;QACF,GAAG,CAAC,gBAAgB,KAAK,SAAS,IAAI;YACpC,eAAe,EAAE,gBAAgB;SAClC,CAAC;KACH,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type CreateFetchWithStrippedHeadersParams = {
|
|
2
|
+
baseFetch: typeof fetch;
|
|
3
|
+
headerNames: string[];
|
|
4
|
+
};
|
|
5
|
+
export declare function createFetchWithStrippedHeaders(params: CreateFetchWithStrippedHeadersParams): typeof fetch;
|
|
6
|
+
//# sourceMappingURL=create-fetch-with-stripped-headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-fetch-with-stripped-headers.d.ts","sourceRoot":"","sources":["../../../lib/fetcher/utils/create-fetch-with-stripped-headers.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oCAAoC,GAAG;IACjD,SAAS,EAAE,OAAO,KAAK,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AASF,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,oCAAoC,GAC3C,OAAO,KAAK,CAuCd"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function toLowerCaseHeaderNames(headerNames) {
|
|
2
|
+
return headerNames
|
|
3
|
+
.map((value) => value.trim())
|
|
4
|
+
.filter((value) => value !== '')
|
|
5
|
+
.map((value) => value.toLowerCase());
|
|
6
|
+
}
|
|
7
|
+
export function createFetchWithStrippedHeaders(params) {
|
|
8
|
+
const { baseFetch } = params;
|
|
9
|
+
const headerNames = toLowerCaseHeaderNames(params.headerNames);
|
|
10
|
+
return async (input, init) => {
|
|
11
|
+
if (headerNames.length === 0) {
|
|
12
|
+
return baseFetch(input, init);
|
|
13
|
+
}
|
|
14
|
+
if (typeof Request !== 'undefined' && input instanceof Request) {
|
|
15
|
+
const headers = new Headers(input.headers);
|
|
16
|
+
if (init?.headers !== undefined) {
|
|
17
|
+
const initHeaders = new Headers(init.headers);
|
|
18
|
+
initHeaders.forEach((value, key) => {
|
|
19
|
+
headers.set(key, value);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
for (const headerName of headerNames) {
|
|
23
|
+
headers.delete(headerName);
|
|
24
|
+
}
|
|
25
|
+
const strippedRequest = new Request(input, { headers });
|
|
26
|
+
return init !== undefined
|
|
27
|
+
? baseFetch(strippedRequest, { ...init, headers })
|
|
28
|
+
: baseFetch(strippedRequest);
|
|
29
|
+
}
|
|
30
|
+
if (init?.headers !== undefined) {
|
|
31
|
+
const headers = new Headers(init.headers);
|
|
32
|
+
for (const headerName of headerNames) {
|
|
33
|
+
headers.delete(headerName);
|
|
34
|
+
}
|
|
35
|
+
return baseFetch(input, { ...init, headers });
|
|
36
|
+
}
|
|
37
|
+
return baseFetch(input, init);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=create-fetch-with-stripped-headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-fetch-with-stripped-headers.js","sourceRoot":"","sources":["../../../lib/fetcher/utils/create-fetch-with-stripped-headers.ts"],"names":[],"mappings":"AAKA,SAAS,sBAAsB,CAAC,WAAqB;IACnD,OAAO,WAAW;SACf,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;SAC5B,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC;SAC/B,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC5C,MAA4C;IAE5C,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAC7B,MAAM,WAAW,GAAG,sBAAsB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,KAAK,YAAY,OAAO,EAAE,CAAC;YAC/D,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAE3C,IAAI,IAAI,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAC9C,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;oBACjC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBAC1B,CAAC,CAAC,CAAC;YACL,CAAC;YAED,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;gBACrC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC7B,CAAC;YAED,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;YACxD,OAAO,IAAI,KAAK,SAAS;gBACvB,CAAC,CAAC,SAAS,CAAC,eAAe,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC;gBAClD,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QACjC,CAAC;QAED,IAAI,IAAI,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC1C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;gBACrC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC7B,CAAC;YACD,OAAO,SAAS,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module protopedia/utils/errors/handler
|
|
3
|
+
*
|
|
4
|
+
* Error handling utilities for ProtoPedia API calls.
|
|
5
|
+
*
|
|
6
|
+
* This module provides the central error handler that transforms various
|
|
7
|
+
* error scenarios into a consistent {@link FetchPrototypesResult} failure
|
|
8
|
+
* shape. HTTP normalization is limited to ProtoPedia API errors; all other
|
|
9
|
+
* errors are classified as network/timeout/abort/unknown.
|
|
10
|
+
*
|
|
11
|
+
* Key responsibilities:
|
|
12
|
+
* - Mapping `PromidasTimeoutError` (timeout) to a TIMEOUT failure.
|
|
13
|
+
* - Detecting `AbortError` (caller-driven abort) and mapping it to an ABORTED failure.
|
|
14
|
+
* - Normalizing {@link ProtoPediaApiError} into HTTP failures with status/statusText.
|
|
15
|
+
* - Preserving network error codes (ENOTFOUND, ECONNREFUSED, etc.) when available.
|
|
16
|
+
* - Classifying opaque fetch failures (TypeError with well-known messages) as CORS_BLOCKED.
|
|
17
|
+
* - Ensuring all API errors are normalized into {@link FetchPrototypesResult}
|
|
18
|
+
* without throwing exceptions.
|
|
19
|
+
*/
|
|
20
|
+
import { ProtoPediaApiError } from 'protopedia-api-v2-client';
|
|
21
|
+
import type { FetchPrototypesResult } from '../../types/result.types.js';
|
|
22
|
+
/**
|
|
23
|
+
* Normalize a {@link ProtoPediaApiError} into a fetcher HTTP failure result.
|
|
24
|
+
*
|
|
25
|
+
* @param error - ProtoPedia API client error containing status and metadata
|
|
26
|
+
* @returns Failure result with kind 'http' and mapped FetcherErrorCode
|
|
27
|
+
*/
|
|
28
|
+
export declare function handleProtoPediaApiError(error: ProtoPediaApiError): FetchPrototypesResult;
|
|
29
|
+
/**
|
|
30
|
+
* Normalize non-ProtoPedia errors into fetcher failure results.
|
|
31
|
+
*
|
|
32
|
+
* Paths:
|
|
33
|
+
* - PromidasTimeoutError → timeout/TIMEOUT (no HTTP status)
|
|
34
|
+
* - AbortError → abort/ABORTED (caller-driven abort, no HTTP status)
|
|
35
|
+
* - Network-ish errors with code → network/<code>
|
|
36
|
+
* - Opaque fetch (known TypeError messages) → cors/CORS_BLOCKED
|
|
37
|
+
* - Fallback → unknown/UNKNOWN
|
|
38
|
+
*
|
|
39
|
+
* Notes:
|
|
40
|
+
* - Do not trust arbitrary error.status; do not treat non-ProtoPedia errors as HTTP.
|
|
41
|
+
* - If details.res.code exists, classify as network; otherwise choose cors/unknown.
|
|
42
|
+
*/
|
|
43
|
+
export declare function handleNotProtoPediaApiError(error: unknown): FetchPrototypesResult;
|
|
44
|
+
/**
|
|
45
|
+
* Normalize any error thrown during ProtoPedia API calls into a
|
|
46
|
+
* {@link FetchPrototypesResult} failure object.
|
|
47
|
+
*
|
|
48
|
+
* Delegation:
|
|
49
|
+
* - ProtoPediaApiError → {@link handleProtoPediaApiError} (HTTP, preserves status/statusText)
|
|
50
|
+
* - Others → {@link handleNotProtoPediaApiError} (timeout/abort/network/cors/unknown)
|
|
51
|
+
*
|
|
52
|
+
* Notes:
|
|
53
|
+
* - Only ProtoPediaApiError is treated as trusted HTTP (status/statusText retained).
|
|
54
|
+
* - If a network code is available, store it in details.res.code and return kind 'network'.
|
|
55
|
+
* - Known opaque fetch messages (TypeError) are classified as CORS_BLOCKED.
|
|
56
|
+
*/
|
|
57
|
+
export declare function handleApiError(error: unknown): FetchPrototypesResult;
|
|
58
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../lib/fetcher/utils/errors/handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,KAAK,EAGV,qBAAqB,EAEtB,MAAM,6BAA6B,CAAC;AAyIrC;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,kBAAkB,GACxB,qBAAqB,CAgBvB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,GACb,qBAAqB,CAiEvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,CAQpE"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module protopedia/utils/errors/handler
|
|
3
|
+
*
|
|
4
|
+
* Error handling utilities for ProtoPedia API calls.
|
|
5
|
+
*
|
|
6
|
+
* This module provides the central error handler that transforms various
|
|
7
|
+
* error scenarios into a consistent {@link FetchPrototypesResult} failure
|
|
8
|
+
* shape. HTTP normalization is limited to ProtoPedia API errors; all other
|
|
9
|
+
* errors are classified as network/timeout/abort/unknown.
|
|
10
|
+
*
|
|
11
|
+
* Key responsibilities:
|
|
12
|
+
* - Mapping `PromidasTimeoutError` (timeout) to a TIMEOUT failure.
|
|
13
|
+
* - Detecting `AbortError` (caller-driven abort) and mapping it to an ABORTED failure.
|
|
14
|
+
* - Normalizing {@link ProtoPediaApiError} into HTTP failures with status/statusText.
|
|
15
|
+
* - Preserving network error codes (ENOTFOUND, ECONNREFUSED, etc.) when available.
|
|
16
|
+
* - Classifying opaque fetch failures (TypeError with well-known messages) as CORS_BLOCKED.
|
|
17
|
+
* - Ensuring all API errors are normalized into {@link FetchPrototypesResult}
|
|
18
|
+
* without throwing exceptions.
|
|
19
|
+
*/
|
|
20
|
+
import { ProtoPediaApiError } from 'protopedia-api-v2-client';
|
|
21
|
+
import { PromidasTimeoutError } from '../../errors/fetcher-error.js';
|
|
22
|
+
/**
|
|
23
|
+
* Standard error names used in error detection.
|
|
24
|
+
*/
|
|
25
|
+
const ERROR_NAMES = {
|
|
26
|
+
ABORT: 'AbortError',
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Standard error messages for common failure scenarios.
|
|
30
|
+
*/
|
|
31
|
+
const ERROR_MESSAGES = {
|
|
32
|
+
ABORTED: 'Upstream request aborted',
|
|
33
|
+
TIMEOUT: 'Upstream request timed out',
|
|
34
|
+
UNKNOWN: 'Failed to fetch prototypes',
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Default error code for network failures where the runtime does not provide
|
|
38
|
+
* a more specific code (e.g. browser fetch TypeError("Failed to fetch")).
|
|
39
|
+
*/
|
|
40
|
+
const DEFAULT_NETWORK_ERROR_CODE = 'NETWORK_ERROR';
|
|
41
|
+
/**
|
|
42
|
+
* A small set of well-known fetch network error messages.
|
|
43
|
+
*
|
|
44
|
+
* Browsers commonly surface CORS/network failures as a generic TypeError with
|
|
45
|
+
* a short message (e.g. "Failed to fetch"), without any structured error code.
|
|
46
|
+
*/
|
|
47
|
+
const KNOWN_FETCH_NETWORK_ERROR_MESSAGES = new Set([
|
|
48
|
+
'Failed to fetch',
|
|
49
|
+
'fetch failed',
|
|
50
|
+
'Load failed',
|
|
51
|
+
'NetworkError when attempting to fetch resource.',
|
|
52
|
+
]);
|
|
53
|
+
const STATUS_CODE_MAP = {
|
|
54
|
+
400: 'CLIENT_BAD_REQUEST',
|
|
55
|
+
401: 'CLIENT_UNAUTHORIZED',
|
|
56
|
+
403: 'CLIENT_FORBIDDEN',
|
|
57
|
+
404: 'CLIENT_NOT_FOUND',
|
|
58
|
+
405: 'CLIENT_METHOD_NOT_ALLOWED',
|
|
59
|
+
408: 'CLIENT_TIMEOUT',
|
|
60
|
+
429: 'CLIENT_RATE_LIMITED',
|
|
61
|
+
500: 'SERVER_INTERNAL_ERROR',
|
|
62
|
+
502: 'SERVER_BAD_GATEWAY',
|
|
63
|
+
503: 'SERVER_SERVICE_UNAVAILABLE',
|
|
64
|
+
504: 'SERVER_GATEWAY_TIMEOUT',
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Type guard to check if an error is an AbortError.
|
|
68
|
+
*
|
|
69
|
+
* @param error - The error to check
|
|
70
|
+
* @returns True if the error is a DOMException with name 'AbortError'
|
|
71
|
+
*/
|
|
72
|
+
function isAbortError(error) {
|
|
73
|
+
return error instanceof DOMException && error.name === ERROR_NAMES.ABORT;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Type guard to check if an error has a code property.
|
|
77
|
+
*
|
|
78
|
+
* This intentionally uses a broad `error is object` type guard to handle
|
|
79
|
+
* nested error structures flexibly. Node.js native fetch wraps network
|
|
80
|
+
* error codes in `error.cause.code`:
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const error = new Error('fetch failed');
|
|
85
|
+
* error.cause = { code: 'ENOTFOUND' };
|
|
86
|
+
* // hasErrorCode(error) returns true, allowing us to check error.cause.code
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* A more specific type guard like `error is { code: string }` would reject
|
|
90
|
+
* errors that only have `cause.code`, preventing extraction of nested codes.
|
|
91
|
+
*
|
|
92
|
+
* @param error - The error to check
|
|
93
|
+
* @returns True if the error is an object that might contain code information
|
|
94
|
+
*/
|
|
95
|
+
function hasErrorCode(error) {
|
|
96
|
+
return error !== null && typeof error === 'object';
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create the common portion of a FetchPrototypesFailure.
|
|
100
|
+
*
|
|
101
|
+
* @param error - Error message string
|
|
102
|
+
* @param details - Additional error details (always required, use {} if no metadata)
|
|
103
|
+
* @param status - HTTP status code (undefined for network errors without server response)
|
|
104
|
+
* @returns A partial FetchPrototypesFailure without kind/code
|
|
105
|
+
*/
|
|
106
|
+
function createFailureResult(error, details, status) {
|
|
107
|
+
const result = {
|
|
108
|
+
ok: false,
|
|
109
|
+
origin: 'fetcher',
|
|
110
|
+
error,
|
|
111
|
+
details,
|
|
112
|
+
};
|
|
113
|
+
if (status !== undefined) {
|
|
114
|
+
result.status = status;
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
function mapHttpStatusToCode(status) {
|
|
119
|
+
if (status === undefined)
|
|
120
|
+
return 'UNKNOWN';
|
|
121
|
+
const mapped = STATUS_CODE_MAP[status];
|
|
122
|
+
if (mapped !== undefined) {
|
|
123
|
+
return mapped;
|
|
124
|
+
}
|
|
125
|
+
if (status >= 500 && status < 600)
|
|
126
|
+
return 'SERVER_ERROR';
|
|
127
|
+
if (status >= 400 && status < 500)
|
|
128
|
+
return 'CLIENT_ERROR';
|
|
129
|
+
return 'UNKNOWN';
|
|
130
|
+
}
|
|
131
|
+
function finalize(base, kind, code) {
|
|
132
|
+
return {
|
|
133
|
+
...base,
|
|
134
|
+
kind,
|
|
135
|
+
code,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Normalize a {@link ProtoPediaApiError} into a fetcher HTTP failure result.
|
|
140
|
+
*
|
|
141
|
+
* @param error - ProtoPedia API client error containing status and metadata
|
|
142
|
+
* @returns Failure result with kind 'http' and mapped FetcherErrorCode
|
|
143
|
+
*/
|
|
144
|
+
export function handleProtoPediaApiError(error) {
|
|
145
|
+
const result = createFailureResult(error.message, {
|
|
146
|
+
req: {
|
|
147
|
+
url: error.req.url,
|
|
148
|
+
method: error.req.method,
|
|
149
|
+
},
|
|
150
|
+
res: {
|
|
151
|
+
statusText: error.statusText,
|
|
152
|
+
},
|
|
153
|
+
}, error.status);
|
|
154
|
+
return finalize(result, 'http', mapHttpStatusToCode(error.status));
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Normalize non-ProtoPedia errors into fetcher failure results.
|
|
158
|
+
*
|
|
159
|
+
* Paths:
|
|
160
|
+
* - PromidasTimeoutError → timeout/TIMEOUT (no HTTP status)
|
|
161
|
+
* - AbortError → abort/ABORTED (caller-driven abort, no HTTP status)
|
|
162
|
+
* - Network-ish errors with code → network/<code>
|
|
163
|
+
* - Opaque fetch (known TypeError messages) → cors/CORS_BLOCKED
|
|
164
|
+
* - Fallback → unknown/UNKNOWN
|
|
165
|
+
*
|
|
166
|
+
* Notes:
|
|
167
|
+
* - Do not trust arbitrary error.status; do not treat non-ProtoPedia errors as HTTP.
|
|
168
|
+
* - If details.res.code exists, classify as network; otherwise choose cors/unknown.
|
|
169
|
+
*/
|
|
170
|
+
export function handleNotProtoPediaApiError(error) {
|
|
171
|
+
/**
|
|
172
|
+
* Handle explicit timeout errors (distinguishable from AbortError).
|
|
173
|
+
* These are fetcher-level timeouts, not HTTP 408 responses.
|
|
174
|
+
*/
|
|
175
|
+
// Handle explicit timeout errors (distinguishable from AbortError)
|
|
176
|
+
if (error instanceof PromidasTimeoutError) {
|
|
177
|
+
const result = createFailureResult(ERROR_MESSAGES.TIMEOUT, {
|
|
178
|
+
res: {
|
|
179
|
+
code: 'TIMEOUT',
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
return finalize(result, 'timeout', 'TIMEOUT');
|
|
183
|
+
}
|
|
184
|
+
// Handle AbortError (caller-driven abort) - network error, no status
|
|
185
|
+
if (isAbortError(error)) {
|
|
186
|
+
const result = createFailureResult(ERROR_MESSAGES.ABORTED, {
|
|
187
|
+
res: {
|
|
188
|
+
code: 'ABORTED',
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
return finalize(result, 'abort', 'ABORTED');
|
|
192
|
+
}
|
|
193
|
+
const message = error instanceof Error ? error.message : ERROR_MESSAGES.UNKNOWN;
|
|
194
|
+
const details = {};
|
|
195
|
+
// Extract network error code from error.code or error.cause.code
|
|
196
|
+
// (Node.js native fetch wraps ENOTFOUND etc. in error.cause)
|
|
197
|
+
if (hasErrorCode(error)) {
|
|
198
|
+
const errorObj = error;
|
|
199
|
+
const code = errorObj.code ?? errorObj.cause?.code;
|
|
200
|
+
if (code !== undefined) {
|
|
201
|
+
details.res ??= {};
|
|
202
|
+
details.res.code = code;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const isOpaqueFetchError = error instanceof TypeError &&
|
|
206
|
+
KNOWN_FETCH_NETWORK_ERROR_MESSAGES.has(message);
|
|
207
|
+
if (details.res?.code === undefined && isOpaqueFetchError) {
|
|
208
|
+
// Keep diagnostics (use generic network code) but classify as CORS_BLOCKED.
|
|
209
|
+
details.res ??= {};
|
|
210
|
+
details.res.code = DEFAULT_NETWORK_ERROR_CODE;
|
|
211
|
+
const result = createFailureResult(message, details);
|
|
212
|
+
return finalize(result, 'cors', 'CORS_BLOCKED');
|
|
213
|
+
}
|
|
214
|
+
if (details.res?.code !== undefined) {
|
|
215
|
+
const result = createFailureResult(message, details);
|
|
216
|
+
const code = details.res.code;
|
|
217
|
+
return finalize(result, 'network', code);
|
|
218
|
+
}
|
|
219
|
+
const result = createFailureResult(message, details);
|
|
220
|
+
return finalize(result, 'unknown', 'UNKNOWN');
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Normalize any error thrown during ProtoPedia API calls into a
|
|
224
|
+
* {@link FetchPrototypesResult} failure object.
|
|
225
|
+
*
|
|
226
|
+
* Delegation:
|
|
227
|
+
* - ProtoPediaApiError → {@link handleProtoPediaApiError} (HTTP, preserves status/statusText)
|
|
228
|
+
* - Others → {@link handleNotProtoPediaApiError} (timeout/abort/network/cors/unknown)
|
|
229
|
+
*
|
|
230
|
+
* Notes:
|
|
231
|
+
* - Only ProtoPediaApiError is treated as trusted HTTP (status/statusText retained).
|
|
232
|
+
* - If a network code is available, store it in details.res.code and return kind 'network'.
|
|
233
|
+
* - Known opaque fetch messages (TypeError) are classified as CORS_BLOCKED.
|
|
234
|
+
*/
|
|
235
|
+
export function handleApiError(error) {
|
|
236
|
+
// Handle ProtoPediaApiError specifically - HTTP error with status
|
|
237
|
+
if (error instanceof ProtoPediaApiError) {
|
|
238
|
+
return handleProtoPediaApiError(error);
|
|
239
|
+
}
|
|
240
|
+
// Handle all non-ProtoPediaApiError cases (network/abort/timeout/unknown)
|
|
241
|
+
return handleNotProtoPediaApiError(error);
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../../lib/fetcher/utils/errors/handler.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module protopedia/utils/errors/messages
|
|
3
|
+
*
|
|
4
|
+
* Message formatting utilities for ProtoPedia API errors.
|
|
5
|
+
*
|
|
6
|
+
* This module provides helpers to extract and format error messages
|
|
7
|
+
* from various error types into user-friendly display strings.
|
|
8
|
+
*/
|
|
9
|
+
import type { NetworkFailure } from '../../types/prototype-api.types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Resolve an unknown error value into a readable string message.
|
|
12
|
+
*
|
|
13
|
+
* This helper provides a safe way to extract error messages from various
|
|
14
|
+
* error types that may be thrown by network calls or API clients.
|
|
15
|
+
*
|
|
16
|
+
* @param value - The error value to resolve. Can be an `Error`, a string,
|
|
17
|
+
* or any other value.
|
|
18
|
+
* @returns A string message. If `value` is an `Error`, returns its
|
|
19
|
+
* `message` property. If `value` is a non-empty string, returns it as-is.
|
|
20
|
+
* Otherwise, returns a generic fallback message.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* resolveErrorMessage(new Error('Network timeout'));
|
|
25
|
+
* // => 'Network timeout'
|
|
26
|
+
*
|
|
27
|
+
* resolveErrorMessage('Custom error');
|
|
28
|
+
* // => 'Custom error'
|
|
29
|
+
*
|
|
30
|
+
* resolveErrorMessage(null);
|
|
31
|
+
* // => 'Unknown error occurred.'
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const resolveErrorMessage: (value: unknown) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Construct a user-friendly display message from a network failure object.
|
|
37
|
+
*
|
|
38
|
+
* This function builds a comprehensive error message by combining:
|
|
39
|
+
* 1. A prefix from `details.statusText` (e.g., "Not Found") or
|
|
40
|
+
* `details.code` (e.g., "ENOTFOUND").
|
|
41
|
+
* 2. The resolved error message from {@link resolveErrorMessage}.
|
|
42
|
+
* 3. The HTTP status code appended in parentheses (e.g., "(404)") if
|
|
43
|
+
* status is defined. For network errors without a status, the code
|
|
44
|
+
* is omitted.
|
|
45
|
+
*
|
|
46
|
+
* The result is suitable for displaying to users or logging.
|
|
47
|
+
*
|
|
48
|
+
* @param failure - The {@link NetworkFailure} object containing status,
|
|
49
|
+
* error, and optional details.
|
|
50
|
+
* @returns A formatted error message string.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* // HTTP error with status
|
|
55
|
+
* const httpFailure: NetworkFailure = {
|
|
56
|
+
* status: 404,
|
|
57
|
+
* error: new Error('Resource not found'),
|
|
58
|
+
* details: { res: { statusText: 'Not Found' } },
|
|
59
|
+
* };
|
|
60
|
+
*
|
|
61
|
+
* constructDisplayMessage(httpFailure);
|
|
62
|
+
* // => 'Not Found: Resource not found (404)'
|
|
63
|
+
*
|
|
64
|
+
* // Network error without status
|
|
65
|
+
* const networkFailure: NetworkFailure = {
|
|
66
|
+
* error: new Error('Connection refused'),
|
|
67
|
+
* details: { res: { code: 'ECONNREFUSED' } },
|
|
68
|
+
* };
|
|
69
|
+
*
|
|
70
|
+
* constructDisplayMessage(networkFailure);
|
|
71
|
+
* // => 'ECONNREFUSED: Connection refused'
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare const constructDisplayMessage: (failure: NetworkFailure) => string;
|
|
75
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../lib/fetcher/utils/errors/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,KAAG,MAUpD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,cAAc,KAAG,MAiBjE,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve an unknown error value into a readable string message.
|
|
3
|
+
*
|
|
4
|
+
* This helper provides a safe way to extract error messages from various
|
|
5
|
+
* error types that may be thrown by network calls or API clients.
|
|
6
|
+
*
|
|
7
|
+
* @param value - The error value to resolve. Can be an `Error`, a string,
|
|
8
|
+
* or any other value.
|
|
9
|
+
* @returns A string message. If `value` is an `Error`, returns its
|
|
10
|
+
* `message` property. If `value` is a non-empty string, returns it as-is.
|
|
11
|
+
* Otherwise, returns a generic fallback message.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* resolveErrorMessage(new Error('Network timeout'));
|
|
16
|
+
* // => 'Network timeout'
|
|
17
|
+
*
|
|
18
|
+
* resolveErrorMessage('Custom error');
|
|
19
|
+
* // => 'Custom error'
|
|
20
|
+
*
|
|
21
|
+
* resolveErrorMessage(null);
|
|
22
|
+
* // => 'Unknown error occurred.'
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export const resolveErrorMessage = (value) => {
|
|
26
|
+
if (value instanceof Error) {
|
|
27
|
+
return value.message;
|
|
28
|
+
}
|
|
29
|
+
if (typeof value === 'string' && value.length > 0) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
return 'Unknown error occurred.';
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Construct a user-friendly display message from a network failure object.
|
|
36
|
+
*
|
|
37
|
+
* This function builds a comprehensive error message by combining:
|
|
38
|
+
* 1. A prefix from `details.statusText` (e.g., "Not Found") or
|
|
39
|
+
* `details.code` (e.g., "ENOTFOUND").
|
|
40
|
+
* 2. The resolved error message from {@link resolveErrorMessage}.
|
|
41
|
+
* 3. The HTTP status code appended in parentheses (e.g., "(404)") if
|
|
42
|
+
* status is defined. For network errors without a status, the code
|
|
43
|
+
* is omitted.
|
|
44
|
+
*
|
|
45
|
+
* The result is suitable for displaying to users or logging.
|
|
46
|
+
*
|
|
47
|
+
* @param failure - The {@link NetworkFailure} object containing status,
|
|
48
|
+
* error, and optional details.
|
|
49
|
+
* @returns A formatted error message string.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* // HTTP error with status
|
|
54
|
+
* const httpFailure: NetworkFailure = {
|
|
55
|
+
* status: 404,
|
|
56
|
+
* error: new Error('Resource not found'),
|
|
57
|
+
* details: { res: { statusText: 'Not Found' } },
|
|
58
|
+
* };
|
|
59
|
+
*
|
|
60
|
+
* constructDisplayMessage(httpFailure);
|
|
61
|
+
* // => 'Not Found: Resource not found (404)'
|
|
62
|
+
*
|
|
63
|
+
* // Network error without status
|
|
64
|
+
* const networkFailure: NetworkFailure = {
|
|
65
|
+
* error: new Error('Connection refused'),
|
|
66
|
+
* details: { res: { code: 'ECONNREFUSED' } },
|
|
67
|
+
* };
|
|
68
|
+
*
|
|
69
|
+
* constructDisplayMessage(networkFailure);
|
|
70
|
+
* // => 'ECONNREFUSED: Connection refused'
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export const constructDisplayMessage = (failure) => {
|
|
74
|
+
const { error, status, details } = failure;
|
|
75
|
+
const statusText = details?.res?.statusText;
|
|
76
|
+
const code = details?.res?.code;
|
|
77
|
+
let message = resolveErrorMessage(error);
|
|
78
|
+
const prefix = statusText || code;
|
|
79
|
+
if (prefix) {
|
|
80
|
+
// Prepend prefix if not already present
|
|
81
|
+
if (!message.startsWith(prefix)) {
|
|
82
|
+
message = `${prefix}: ${message}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Only append status code if it's defined (HTTP errors have status, network errors don't)
|
|
86
|
+
return status !== undefined ? `${message} (${status})` : message;
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../lib/fetcher/utils/errors/messages.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAAU,EAAE;IAC5D,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,yBAAyB,CAAC;AACnC,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAuB,EAAU,EAAE;IACzE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC3C,MAAM,UAAU,GAAG,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC;IAC5C,MAAM,IAAI,GAAG,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC;IAChC,IAAI,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAEzC,MAAM,MAAM,GAAG,UAAU,IAAI,IAAI,CAAC;IAElC,IAAI,MAAM,EAAE,CAAC;QACX,wCAAwC;QACxC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAChC,OAAO,GAAG,GAAG,MAAM,KAAK,OAAO,EAAE,CAAC;QACpC,CAAC;IACH,CAAC;IAED,0FAA0F;IAC1F,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;AACnE,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module protopedia/utils
|
|
3
|
+
*
|
|
4
|
+
* Utility functions for ProtoPedia API data processing.
|
|
5
|
+
*/
|
|
6
|
+
export { splitPipeSeparatedString } from './string-parsers.js';
|
|
7
|
+
export { normalizePrototype } from './normalize-prototype.js';
|
|
8
|
+
export type { UpstreamPrototype } from '../types/prototype-api.types.js';
|
|
9
|
+
export { normalizeProtoPediaTimestamp } from './normalize-protopedia-timestamp.js';
|
|
10
|
+
export { handleApiError } from './errors/handler.js';
|
|
11
|
+
export { PromidasTimeoutError } from '../errors/fetcher-error.js';
|
|
12
|
+
export { resolveErrorMessage, constructDisplayMessage, } from './errors/messages.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/fetcher/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,sBAAsB,CAAC"}
|