@dereekb/util 12.0.0 → 12.0.2
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/fetch/index.cjs.js +2 -2
- package/fetch/index.esm.js +2 -2
- package/fetch/package.json +1 -1
- package/fetch/src/lib/fetch.d.ts +15 -15
- package/fetch/src/lib/json.d.ts +3 -3
- package/index.cjs.js +3 -1
- package/index.esm.js +3 -1
- package/package.json +1 -1
- package/test/CHANGELOG.md +8 -0
- package/test/package.json +1 -1
package/fetch/index.cjs.js
CHANGED
|
@@ -5823,7 +5823,7 @@ function mergeRequestInits(base, requestInit) {
|
|
|
5823
5823
|
}
|
|
5824
5824
|
function mergeRequestHeaders(inputHeadersArray) {
|
|
5825
5825
|
const headersMap = util.multiValueMapBuilder();
|
|
5826
|
-
util.filterMaybeArrayValues(inputHeadersArray).forEach(
|
|
5826
|
+
util.filterMaybeArrayValues(inputHeadersArray).forEach(headers => {
|
|
5827
5827
|
const tuples = headersToHeadersTuple(headers);
|
|
5828
5828
|
const visitedKeysSet = new Set();
|
|
5829
5829
|
tuples.forEach(([key, value]) => {
|
|
@@ -6645,7 +6645,7 @@ function fetchJsonBodyString(body) {
|
|
|
6645
6645
|
const throwJsonResponseParseErrorFunction = response => {
|
|
6646
6646
|
throw new JsonResponseParseError(response);
|
|
6647
6647
|
};
|
|
6648
|
-
const returnNullHandleFetchJsonParseErrorFunction =
|
|
6648
|
+
const returnNullHandleFetchJsonParseErrorFunction = _ => null;
|
|
6649
6649
|
/**
|
|
6650
6650
|
* Creates a FetchJsonFunction from the input ConfiguredFetch.
|
|
6651
6651
|
*/
|
package/fetch/index.esm.js
CHANGED
|
@@ -5821,7 +5821,7 @@ function mergeRequestInits(base, requestInit) {
|
|
|
5821
5821
|
}
|
|
5822
5822
|
function mergeRequestHeaders(inputHeadersArray) {
|
|
5823
5823
|
const headersMap = multiValueMapBuilder();
|
|
5824
|
-
filterMaybeArrayValues(inputHeadersArray).forEach(
|
|
5824
|
+
filterMaybeArrayValues(inputHeadersArray).forEach(headers => {
|
|
5825
5825
|
const tuples = headersToHeadersTuple(headers);
|
|
5826
5826
|
const visitedKeysSet = new Set();
|
|
5827
5827
|
tuples.forEach(([key, value]) => {
|
|
@@ -6643,7 +6643,7 @@ function fetchJsonBodyString(body) {
|
|
|
6643
6643
|
const throwJsonResponseParseErrorFunction = response => {
|
|
6644
6644
|
throw new JsonResponseParseError(response);
|
|
6645
6645
|
};
|
|
6646
|
-
const returnNullHandleFetchJsonParseErrorFunction =
|
|
6646
|
+
const returnNullHandleFetchJsonParseErrorFunction = _ => null;
|
|
6647
6647
|
/**
|
|
6648
6648
|
* Creates a FetchJsonFunction from the input ConfiguredFetch.
|
|
6649
6649
|
*/
|
package/fetch/package.json
CHANGED
package/fetch/src/lib/fetch.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { type ConfiguredFetchWithTimeout, type RequestInitWithTimeout } from './
|
|
|
4
4
|
* Interface used for creating fetch related resource factories.
|
|
5
5
|
*/
|
|
6
6
|
export interface FetchService {
|
|
7
|
-
makeFetch: (config?: ConfigureFetchInput) => ConfiguredFetchWithTimeout;
|
|
8
|
-
makeRequest: FetchRequestFactory;
|
|
9
|
-
fetchRequestFactory: typeof fetchRequestFactory;
|
|
7
|
+
readonly makeFetch: (config?: ConfigureFetchInput) => ConfiguredFetchWithTimeout;
|
|
8
|
+
readonly makeRequest: FetchRequestFactory;
|
|
9
|
+
readonly fetchRequestFactory: typeof fetchRequestFactory;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* fetchService() configuration.
|
|
@@ -25,29 +25,29 @@ export type MapFetchResponseFunction = MapFunction<Promise<Response>, Promise<Re
|
|
|
25
25
|
*/
|
|
26
26
|
export type FetchHandler = (request: Request, makeFetch: typeof fetch) => Promise<Response>;
|
|
27
27
|
export interface ConfigureFetchInput extends FetchRequestFactoryInput {
|
|
28
|
-
makeFetch?: typeof fetch;
|
|
28
|
+
readonly makeFetch?: typeof fetch;
|
|
29
29
|
/**
|
|
30
30
|
* Whether or not to add timeout handling using timeoutFetch().
|
|
31
31
|
*
|
|
32
32
|
* Default: false
|
|
33
33
|
*/
|
|
34
|
-
useTimeout?: boolean;
|
|
34
|
+
readonly useTimeout?: boolean;
|
|
35
35
|
/**
|
|
36
36
|
* Whether or not to map the fetch response using requireOkResponse().
|
|
37
37
|
*
|
|
38
38
|
* Default: false
|
|
39
39
|
*/
|
|
40
|
-
requireOkResponse?: boolean;
|
|
40
|
+
readonly requireOkResponse?: boolean;
|
|
41
41
|
/**
|
|
42
42
|
* (Optional) Custom fetch handler.
|
|
43
43
|
*/
|
|
44
|
-
fetchHandler?: FetchHandler;
|
|
44
|
+
readonly fetchHandler?: FetchHandler;
|
|
45
45
|
/**
|
|
46
46
|
* (Optional) MapFetchResponseFunction
|
|
47
47
|
*
|
|
48
48
|
* If requireOkResponse is true, this mapping occurs afterwards.
|
|
49
49
|
*/
|
|
50
|
-
mapResponse?: MapFetchResponseFunction;
|
|
50
|
+
readonly mapResponse?: MapFetchResponseFunction;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Default FetchHabdler
|
|
@@ -67,37 +67,37 @@ export interface FetchRequestFactoryInput {
|
|
|
67
67
|
/**
|
|
68
68
|
* Request factory to use. If not defined, will default to window/global.
|
|
69
69
|
*/
|
|
70
|
-
makeRequest?: FetchRequestFactory;
|
|
70
|
+
readonly makeRequest?: FetchRequestFactory;
|
|
71
71
|
/**
|
|
72
72
|
* Appends this URL to every fetch request.
|
|
73
73
|
*/
|
|
74
|
-
baseUrl?: WebsiteUrl;
|
|
74
|
+
readonly baseUrl?: WebsiteUrl;
|
|
75
75
|
/**
|
|
76
76
|
* Whether or not to append the base url to RequestInfo that is already configured, instead of only URL or strings.
|
|
77
77
|
*/
|
|
78
|
-
useBaseUrlForConfiguredFetchRequests?: boolean;
|
|
78
|
+
readonly useBaseUrlForConfiguredFetchRequests?: boolean;
|
|
79
79
|
/**
|
|
80
80
|
* Whether or not to force always using the base url even when a WebsiteUrlWithPrefix value is provided.
|
|
81
81
|
*
|
|
82
82
|
* Defaults to useBaseUrlForConfiguredFetchRequests's value.
|
|
83
83
|
*/
|
|
84
|
-
forceBaseUrlForWebsiteUrlWithPrefix?: boolean;
|
|
84
|
+
readonly forceBaseUrlForWebsiteUrlWithPrefix?: boolean;
|
|
85
85
|
/**
|
|
86
86
|
* Base request info to add to each value.
|
|
87
87
|
*/
|
|
88
|
-
baseRequest?: GetterOrValue<PromiseOrValue<RequestInit>>;
|
|
88
|
+
readonly baseRequest?: GetterOrValue<PromiseOrValue<RequestInit>>;
|
|
89
89
|
/**
|
|
90
90
|
* Default timeout to add to requestInit values.
|
|
91
91
|
*
|
|
92
92
|
* NOTE: This timeout is not used by this fetchRequest directly, but is added to the baseRequest.
|
|
93
93
|
*/
|
|
94
|
-
timeout?: number;
|
|
94
|
+
readonly timeout?: number;
|
|
95
95
|
/**
|
|
96
96
|
* Maps the input RequestInit value to another.
|
|
97
97
|
*
|
|
98
98
|
* If baseRequest is provided, the values will already be appended before reaching this factory.
|
|
99
99
|
*/
|
|
100
|
-
requestInitFactory?: FetchRequestInitFactory;
|
|
100
|
+
readonly requestInitFactory?: FetchRequestInitFactory;
|
|
101
101
|
}
|
|
102
102
|
export type FetchRequestInitFactory = (currRequest: PromiseOrValue<Request>, init?: PromiseOrValue<RequestInit>) => PromiseOrValue<RequestInitWithTimeout | undefined>;
|
|
103
103
|
export type FetchRequestFactory = (input: RequestInfo | URL, init?: RequestInit | undefined) => PromiseOrValue<Request>;
|
package/fetch/src/lib/json.d.ts
CHANGED
|
@@ -14,14 +14,14 @@ export declare class JsonResponseParseError extends Error {
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function fetchJsonBodyString(body: FetchJsonBody | undefined): string | undefined;
|
|
16
16
|
export interface FetchJsonInput extends Omit<RequestInit, 'body'> {
|
|
17
|
-
method: FetchMethod;
|
|
18
|
-
body?: FetchJsonBody | undefined;
|
|
17
|
+
readonly method: FetchMethod;
|
|
18
|
+
readonly body?: FetchJsonBody | undefined;
|
|
19
19
|
/**
|
|
20
20
|
* Optional intercept function to intercept/transform the response.
|
|
21
21
|
*
|
|
22
22
|
* Does not override any other configured interceptor and occurs after those configured interceptors.
|
|
23
23
|
*/
|
|
24
|
-
interceptResponse?: FetchJsonInterceptJsonResponseFunction;
|
|
24
|
+
readonly interceptResponse?: FetchJsonInterceptJsonResponseFunction;
|
|
25
25
|
}
|
|
26
26
|
export type FetchJsonInputMapFunction = MapSameFunction<FetchJsonInput>;
|
|
27
27
|
export type FetchJsonGetFunction = <R>(url: FetchURLInput) => Promise<R>;
|
package/index.cjs.js
CHANGED
|
@@ -5396,6 +5396,7 @@ function getFunctionType(x) {
|
|
|
5396
5396
|
* @param x
|
|
5397
5397
|
* @returns
|
|
5398
5398
|
*/
|
|
5399
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
5399
5400
|
function isNonClassFunction(x) {
|
|
5400
5401
|
const type = getFunctionType(x);
|
|
5401
5402
|
return type != null && type !== 'class';
|
|
@@ -14399,7 +14400,7 @@ function performTasksFromFactoryInParallelFunction(config) {
|
|
|
14399
14400
|
const maxParallelTasks = inputMaxParallelTasks != null ? inputMaxParallelTasks : sequential ? 1 : undefined;
|
|
14400
14401
|
const maxPromisesToRunAtOneTime = Math.max(1, maxParallelTasks != null ? maxParallelTasks : 1);
|
|
14401
14402
|
return taskInputFactory => {
|
|
14402
|
-
return new Promise(
|
|
14403
|
+
return new Promise((resolve, reject) => {
|
|
14403
14404
|
const taskKeyFactory = nonConcurrentTaskKeyFactory != null ? nonConcurrentTaskKeyFactory : defaultNonConcurrentTaskKeyFactory;
|
|
14404
14405
|
let incompleteTasks = [];
|
|
14405
14406
|
let baseI = 0;
|
|
@@ -14498,6 +14499,7 @@ function performTasksFromFactoryInParallelFunction(config) {
|
|
|
14498
14499
|
// un-reserve the key from each parallel task
|
|
14499
14500
|
currentParellelTaskKeys.delete(key);
|
|
14500
14501
|
const waitingForKey = waitingConcurrentTasks.get(key);
|
|
14502
|
+
// eslint-disable-next-line no-constant-condition
|
|
14501
14503
|
while (true) {
|
|
14502
14504
|
const nextWaitingTask = waitingForKey.shift(); // take from the front to retain unique task order
|
|
14503
14505
|
if (nextWaitingTask) {
|
package/index.esm.js
CHANGED
|
@@ -5394,6 +5394,7 @@ function getFunctionType(x) {
|
|
|
5394
5394
|
* @param x
|
|
5395
5395
|
* @returns
|
|
5396
5396
|
*/
|
|
5397
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
5397
5398
|
function isNonClassFunction(x) {
|
|
5398
5399
|
const type = getFunctionType(x);
|
|
5399
5400
|
return type != null && type !== 'class';
|
|
@@ -14397,7 +14398,7 @@ function performTasksFromFactoryInParallelFunction(config) {
|
|
|
14397
14398
|
const maxParallelTasks = inputMaxParallelTasks != null ? inputMaxParallelTasks : sequential ? 1 : undefined;
|
|
14398
14399
|
const maxPromisesToRunAtOneTime = Math.max(1, maxParallelTasks != null ? maxParallelTasks : 1);
|
|
14399
14400
|
return taskInputFactory => {
|
|
14400
|
-
return new Promise(
|
|
14401
|
+
return new Promise((resolve, reject) => {
|
|
14401
14402
|
const taskKeyFactory = nonConcurrentTaskKeyFactory != null ? nonConcurrentTaskKeyFactory : defaultNonConcurrentTaskKeyFactory;
|
|
14402
14403
|
let incompleteTasks = [];
|
|
14403
14404
|
let baseI = 0;
|
|
@@ -14496,6 +14497,7 @@ function performTasksFromFactoryInParallelFunction(config) {
|
|
|
14496
14497
|
// un-reserve the key from each parallel task
|
|
14497
14498
|
currentParellelTaskKeys.delete(key);
|
|
14498
14499
|
const waitingForKey = waitingConcurrentTasks.get(key);
|
|
14500
|
+
// eslint-disable-next-line no-constant-condition
|
|
14499
14501
|
while (true) {
|
|
14500
14502
|
const nextWaitingTask = waitingForKey.shift(); // take from the front to retain unique task order
|
|
14501
14503
|
if (nextWaitingTask) {
|
package/package.json
CHANGED
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [12.0.2](https://github.com/dereekb/dbx-components/compare/v12.0.1-dev...v12.0.2) (2025-04-26)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [12.0.1](https://github.com/dereekb/dbx-components/compare/v12.0.0-dev...v12.0.1) (2025-04-25)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
# [12.0.0](https://github.com/dereekb/dbx-components/compare/v11.1.8-dev...v12.0.0) (2025-04-23)
|
|
6
14
|
|
|
7
15
|
|