ropegeo-common 1.12.5 → 1.12.8
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/dist/components/RopeGeoCursorPaginationHttpRequest.d.ts +2 -2
- package/dist/components/RopeGeoCursorPaginationHttpRequest.d.ts.map +1 -1
- package/dist/components/RopeGeoCursorPaginationHttpRequest.js +36 -32
- package/dist/components/RopeGeoHttpRequest.d.ts +1 -2
- package/dist/components/RopeGeoHttpRequest.d.ts.map +1 -1
- package/dist/components/RopeGeoHttpRequest.js +17 -15
- package/dist/components/RopeGeoPaginationHttpRequest.d.ts +3 -3
- package/dist/components/RopeGeoPaginationHttpRequest.d.ts.map +1 -1
- package/dist/components/RopeGeoPaginationHttpRequest.js +48 -30
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +1 -4
- package/dist/helpers/network/index.d.ts +1 -1
- package/dist/helpers/network/index.d.ts.map +1 -1
- package/dist/helpers/network/index.js +1 -4
- package/dist/helpers/network/networkRequestPolicy.d.ts +4 -12
- package/dist/helpers/network/networkRequestPolicy.d.ts.map +1 -1
- package/dist/helpers/network/networkRequestPolicy.js +5 -13
- package/package.json +1 -1
|
@@ -8,8 +8,8 @@ export type RopeGeoCursorPaginationHttpRequestProps<T = unknown> = {
|
|
|
8
8
|
pathParams?: Record<string, string>;
|
|
9
9
|
queryParams: CursorPaginationParams;
|
|
10
10
|
/**
|
|
11
|
-
* Request deadline in seconds for each fetch (initial and `loadMore`).
|
|
12
|
-
*
|
|
11
|
+
* Request deadline in seconds for each fetch (initial and `loadMore`). When omitted, timeout
|
|
12
|
+
* and countdown are disabled.
|
|
13
13
|
*/
|
|
14
14
|
timeoutAfterSeconds?: number;
|
|
15
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RopeGeoCursorPaginationHttpRequest.d.ts","sourceRoot":"","sources":["../../src/components/RopeGeoCursorPaginationHttpRequest.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAoB,MAAM,sBAAsB,CAAC;AAsCzE,MAAM,MAAM,uCAAuC,CAAC,CAAC,GAAG,OAAO,IAAI;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,EAAE,sBAAsB,CAAC;IACpC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,WAAW,EAAE,OAAO,CAAC;QACrB,IAAI,EAAE,CAAC,EAAE,CAAC;QACV,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;QACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;QACrB,OAAO,EAAE,OAAO,CAAC;QACjB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;KACjC,KAAK,SAAS,CAAC;CACjB,CAAC;AAEF,wBAAgB,kCAAkC,CAAC,CAAC,GAAG,OAAO,EAAE,EAC9D,OAAO,EACP,MAAmB,EACnB,IAAI,EACJ,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,QAAQ,GACT,EAAE,uCAAuC,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"RopeGeoCursorPaginationHttpRequest.d.ts","sourceRoot":"","sources":["../../src/components/RopeGeoCursorPaginationHttpRequest.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQvC,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAoB,MAAM,sBAAsB,CAAC;AAsCzE,MAAM,MAAM,uCAAuC,CAAC,CAAC,GAAG,OAAO,IAAI;IACjE,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,EAAE,sBAAsB,CAAC;IACpC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,WAAW,EAAE,OAAO,CAAC;QACrB,IAAI,EAAE,CAAC,EAAE,CAAC;QACV,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;QACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;QACrB,OAAO,EAAE,OAAO,CAAC;QACjB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;KACjC,KAAK,SAAS,CAAC;CACjB,CAAC;AAEF,wBAAgB,kCAAkC,CAAC,CAAC,GAAG,OAAO,EAAE,EAC9D,OAAO,EACP,MAAmB,EACnB,IAAI,EACJ,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,QAAQ,GACT,EAAE,uCAAuC,CAAC,CAAC,CAAC,2CAiP5C"}
|
|
@@ -58,21 +58,23 @@ function RopeGeoCursorPaginationHttpRequest({ service, method = RopeGeoHttpReque
|
|
|
58
58
|
setLoading(true);
|
|
59
59
|
setErrors(null);
|
|
60
60
|
setTimeoutCountdown(null);
|
|
61
|
-
const policyDispose =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
const policyDispose = timeoutMs == null
|
|
62
|
+
? () => { }
|
|
63
|
+
: (0, network_1.installNetworkRequestPolicyTimers)(requestStartedAt, timeoutMs, {
|
|
64
|
+
isActive: () => !cancelled,
|
|
65
|
+
onTimeoutCountdown: (seconds) => {
|
|
66
|
+
if (!cancelled)
|
|
67
|
+
setTimeoutCountdown(seconds);
|
|
68
|
+
},
|
|
69
|
+
onClearTimeoutCountdown: () => {
|
|
70
|
+
if (!cancelled)
|
|
71
|
+
setTimeoutCountdown(null);
|
|
72
|
+
},
|
|
73
|
+
onHardTimeout: () => {
|
|
74
|
+
timedOutRef.current = true;
|
|
75
|
+
abortController.abort();
|
|
76
|
+
},
|
|
77
|
+
});
|
|
76
78
|
const url = buildUrl(queryParams);
|
|
77
79
|
const init = {
|
|
78
80
|
method,
|
|
@@ -164,23 +166,25 @@ function RopeGeoCursorPaginationHttpRequest({ service, method = RopeGeoHttpReque
|
|
|
164
166
|
const timedOutRef = { current: false };
|
|
165
167
|
const requestStartedAt = Date.now();
|
|
166
168
|
const timeoutMs = (0, network_1.resolveRequestTimeoutMs)(timeoutAfterSeconds);
|
|
167
|
-
const policyDispose =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
169
|
+
const policyDispose = timeoutMs == null
|
|
170
|
+
? () => { }
|
|
171
|
+
: (0, network_1.installNetworkRequestPolicyTimers)(requestStartedAt, timeoutMs, {
|
|
172
|
+
isActive: () => loadMoreAbortRef.current === outer,
|
|
173
|
+
onTimeoutCountdown: (seconds) => {
|
|
174
|
+
if (loadMoreAbortRef.current === outer) {
|
|
175
|
+
setTimeoutCountdown(seconds);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
onClearTimeoutCountdown: () => {
|
|
179
|
+
if (loadMoreAbortRef.current === outer) {
|
|
180
|
+
setTimeoutCountdown(null);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
onHardTimeout: () => {
|
|
184
|
+
timedOutRef.current = true;
|
|
185
|
+
outer.abort();
|
|
186
|
+
},
|
|
187
|
+
});
|
|
184
188
|
const url = buildUrl(params);
|
|
185
189
|
const init = {
|
|
186
190
|
method,
|
|
@@ -19,8 +19,7 @@ export type RopeGeoHttpRequestProps<T = unknown> = {
|
|
|
19
19
|
queryParams?: Record<string, string | number | boolean | undefined>;
|
|
20
20
|
body?: object;
|
|
21
21
|
/**
|
|
22
|
-
* Request deadline in seconds (abort + timeout error).
|
|
23
|
-
* (`NETWORK_REQUEST_DEFAULT_TIMEOUT_SECONDS` from `ropegeo-common/helpers`) when omitted.
|
|
22
|
+
* Request deadline in seconds (abort + timeout error). When omitted, no timeout is enforced.
|
|
24
23
|
*/
|
|
25
24
|
timeoutAfterSeconds?: number;
|
|
26
25
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RopeGeoHttpRequest.d.ts","sourceRoot":"","sources":["../../src/components/RopeGeoHttpRequest.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUvC,eAAO,MAAM,OAAO;;CAEV,CAAC;AACX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAE7D,eAAO,MAAM,MAAM;;;;;CAKT,CAAC;AACX,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC;AAE1D,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,OAAO,EA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;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;QACf,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;QACrB;;;;WAIG;QACH,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;KACjC,KAAK,SAAS,CAAC;CACjB,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,OAAO,EAAE,EAC9C,OAAO,EACP,MAAM,EACN,IAAI,EACJ,UAAU,EACV,WAAW,EACX,IAAI,EACJ,mBAAmB,EACnB,QAAQ,GACT,EAAE,uBAAuB,CAAC,CAAC,CAAC,2CAwI5B"}
|
|
@@ -61,21 +61,23 @@ function RopeGeoHttpRequest({ service, method, path, pathParams, queryParams, bo
|
|
|
61
61
|
setLoading(true);
|
|
62
62
|
setErrors(null);
|
|
63
63
|
setTimeoutCountdown(null);
|
|
64
|
-
const policyDispose =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
64
|
+
const policyDispose = timeoutMs == null
|
|
65
|
+
? () => { }
|
|
66
|
+
: (0, network_1.installNetworkRequestPolicyTimers)(requestStartedAt, timeoutMs, {
|
|
67
|
+
isActive: () => !cancelled,
|
|
68
|
+
onTimeoutCountdown: (seconds) => {
|
|
69
|
+
if (!cancelled)
|
|
70
|
+
setTimeoutCountdown(seconds);
|
|
71
|
+
},
|
|
72
|
+
onClearTimeoutCountdown: () => {
|
|
73
|
+
if (!cancelled)
|
|
74
|
+
setTimeoutCountdown(null);
|
|
75
|
+
},
|
|
76
|
+
onHardTimeout: () => {
|
|
77
|
+
timedOutRef.current = true;
|
|
78
|
+
abortController.abort();
|
|
79
|
+
},
|
|
80
|
+
});
|
|
79
81
|
const baseUrl = exports.SERVICE_BASE_URL[service];
|
|
80
82
|
const url = buildUrl(baseUrl, path, pathParams, queryParams);
|
|
81
83
|
const init = {
|
|
@@ -14,8 +14,8 @@ export type RopeGeoPaginationHttpRequestProps<T = unknown> = {
|
|
|
14
14
|
*/
|
|
15
15
|
batchSize?: number;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Deadline in seconds for each request phase: initial page fetch, then each concurrent page batch.
|
|
18
|
+
* When omitted, timeout and countdown are disabled.
|
|
19
19
|
*/
|
|
20
20
|
timeoutAfterSeconds?: number;
|
|
21
21
|
children: (args: {
|
|
@@ -29,7 +29,7 @@ export type RopeGeoPaginationHttpRequestProps<T = unknown> = {
|
|
|
29
29
|
data: T[] | null;
|
|
30
30
|
/** Set when `data` is `null` after a terminal failure; cleared only when all pages succeed. */
|
|
31
31
|
errors: Error | null;
|
|
32
|
-
/** Timeout countdown for the
|
|
32
|
+
/** Timeout countdown for the active phase (initial page or current batch); `null` between phases. */
|
|
33
33
|
timeoutCountdown: number | null;
|
|
34
34
|
}) => ReactNode;
|
|
35
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RopeGeoPaginationHttpRequest.d.ts","sourceRoot":"","sources":["../../src/components/RopeGeoPaginationHttpRequest.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASvC,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAoB,MAAM,sBAAsB,CAAC;AA8DzE,MAAM,MAAM,iCAAiC,CAAC,CAAC,GAAG,OAAO,IAAI;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CA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AE;QACf,OAAO,EAAE,OAAO,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB;;;WAGG;QACH,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;QACjB,+FAA+F;QAC/F,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;QACrB,qGAAqG;QACrG,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;KACjC,KAAK,SAAS,CAAC;CACjB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,GAAG,OAAO,EAAE,EACxD,OAAO,EACP,MAAmB,EACnB,IAAI,EACJ,UAAU,EACV,WAAW,EACX,SAAc,EACd,mBAAmB,EACnB,QAAQ,GACT,EAAE,iCAAiC,CAAC,CAAC,CAAC,2CA4OtC"}
|
|
@@ -87,6 +87,47 @@ function RopeGeoPaginationHttpRequest({ service, method = RopeGeoHttpRequest_1.M
|
|
|
87
87
|
(async () => {
|
|
88
88
|
const pagesByNum = new Map();
|
|
89
89
|
const limit = queryParams.limit;
|
|
90
|
+
let activePolicyDispose = null;
|
|
91
|
+
const clearActivePolicy = () => {
|
|
92
|
+
activePolicyDispose?.();
|
|
93
|
+
activePolicyDispose = null;
|
|
94
|
+
};
|
|
95
|
+
const runWithPhaseCountdown = async (runner) => {
|
|
96
|
+
if (timeoutMs == null) {
|
|
97
|
+
if (!cancelled)
|
|
98
|
+
setTimeoutCountdown(null);
|
|
99
|
+
return runner();
|
|
100
|
+
}
|
|
101
|
+
let phaseTimedOut = false;
|
|
102
|
+
clearActivePolicy();
|
|
103
|
+
activePolicyDispose = (0, network_1.installNetworkRequestPolicyTimers)(Date.now(), timeoutMs, {
|
|
104
|
+
isActive: () => !cancelled,
|
|
105
|
+
onTimeoutCountdown: (seconds) => {
|
|
106
|
+
if (!cancelled)
|
|
107
|
+
setTimeoutCountdown(seconds);
|
|
108
|
+
},
|
|
109
|
+
onClearTimeoutCountdown: () => {
|
|
110
|
+
if (!cancelled)
|
|
111
|
+
setTimeoutCountdown(null);
|
|
112
|
+
},
|
|
113
|
+
onHardTimeout: () => {
|
|
114
|
+
phaseTimedOut = true;
|
|
115
|
+
abortController.abort();
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
try {
|
|
119
|
+
return await runner();
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
if (phaseTimedOut) {
|
|
123
|
+
throw new Error(network_1.NETWORK_REQUEST_TIMED_OUT_MESSAGE);
|
|
124
|
+
}
|
|
125
|
+
throw err;
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
clearActivePolicy();
|
|
129
|
+
}
|
|
130
|
+
};
|
|
90
131
|
const fetchPage = async (pageNum) => {
|
|
91
132
|
const params = queryParams.withPage(pageNum);
|
|
92
133
|
const queryString = params.toQueryString();
|
|
@@ -94,31 +135,14 @@ function RopeGeoPaginationHttpRequest({ service, method = RopeGeoHttpRequest_1.M
|
|
|
94
135
|
? `${resolvedPath}?${queryString}`
|
|
95
136
|
: resolvedPath;
|
|
96
137
|
const url = new URL(fullPath, baseUrl).toString();
|
|
97
|
-
let pageOnePolicyDispose = null;
|
|
98
|
-
const pageOneTimedOutRef = { current: false };
|
|
99
|
-
if (pageNum === 1) {
|
|
100
|
-
const startedAt = Date.now();
|
|
101
|
-
pageOnePolicyDispose = (0, network_1.installNetworkRequestPolicyTimers)(startedAt, timeoutMs, {
|
|
102
|
-
isActive: () => !cancelled,
|
|
103
|
-
onTimeoutCountdown: (seconds) => {
|
|
104
|
-
if (!cancelled)
|
|
105
|
-
setTimeoutCountdown(seconds);
|
|
106
|
-
},
|
|
107
|
-
onClearTimeoutCountdown: () => {
|
|
108
|
-
if (!cancelled)
|
|
109
|
-
setTimeoutCountdown(null);
|
|
110
|
-
},
|
|
111
|
-
onHardTimeout: () => {
|
|
112
|
-
pageOneTimedOutRef.current = true;
|
|
113
|
-
abortController.abort();
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
138
|
let merged = null;
|
|
118
139
|
let signalForFetch;
|
|
119
140
|
if (pageNum === 1) {
|
|
120
141
|
signalForFetch = signal;
|
|
121
142
|
}
|
|
143
|
+
else if (timeoutMs == null) {
|
|
144
|
+
signalForFetch = signal;
|
|
145
|
+
}
|
|
122
146
|
else {
|
|
123
147
|
merged = (0, network_1.mergeParentSignalWithDeadline)(signal, timeoutMs);
|
|
124
148
|
signalForFetch = merged.signal;
|
|
@@ -164,21 +188,14 @@ function RopeGeoPaginationHttpRequest({ service, method = RopeGeoHttpRequest_1.M
|
|
|
164
188
|
abortController.abort();
|
|
165
189
|
throw new Error(network_1.NETWORK_REQUEST_TIMED_OUT_MESSAGE);
|
|
166
190
|
}
|
|
167
|
-
if (pageNum === 1 && pageOneTimedOutRef.current) {
|
|
168
|
-
throw new Error(network_1.NETWORK_REQUEST_TIMED_OUT_MESSAGE);
|
|
169
|
-
}
|
|
170
191
|
throw err;
|
|
171
192
|
}
|
|
172
193
|
finally {
|
|
173
|
-
pageOnePolicyDispose?.();
|
|
174
194
|
merged?.dispose();
|
|
175
|
-
if (pageNum === 1 && !cancelled) {
|
|
176
|
-
setTimeoutCountdown(null);
|
|
177
|
-
}
|
|
178
195
|
}
|
|
179
196
|
};
|
|
180
197
|
try {
|
|
181
|
-
const first = await fetchPage(1);
|
|
198
|
+
const first = await runWithPhaseCountdown(() => fetchPage(1));
|
|
182
199
|
if (cancelled)
|
|
183
200
|
return;
|
|
184
201
|
pagesByNum.set(1, first);
|
|
@@ -206,14 +223,14 @@ function RopeGeoPaginationHttpRequest({ service, method = RopeGeoHttpRequest_1.M
|
|
|
206
223
|
if (sumReceived(pagesByNum) >= totalCount)
|
|
207
224
|
break;
|
|
208
225
|
const chunk = toFetch.slice(i, i + effectiveBatch);
|
|
209
|
-
await Promise.all(chunk.map(async (pageNum) => {
|
|
226
|
+
await runWithPhaseCountdown(() => Promise.all(chunk.map(async (pageNum) => {
|
|
210
227
|
const parsed = await fetchPage(pageNum);
|
|
211
228
|
if (cancelled)
|
|
212
229
|
return;
|
|
213
230
|
pagesByNum.set(pageNum, parsed);
|
|
214
231
|
setReceived(sumReceived(pagesByNum));
|
|
215
232
|
setTotal(totalCount);
|
|
216
|
-
}));
|
|
233
|
+
})));
|
|
217
234
|
if (cancelled)
|
|
218
235
|
return;
|
|
219
236
|
if (sumReceived(pagesByNum) >= totalCount)
|
|
@@ -234,6 +251,7 @@ function RopeGeoPaginationHttpRequest({ service, method = RopeGeoHttpRequest_1.M
|
|
|
234
251
|
setData(null);
|
|
235
252
|
}
|
|
236
253
|
finally {
|
|
254
|
+
clearActivePolicy();
|
|
237
255
|
if (!cancelled)
|
|
238
256
|
setLoading(false);
|
|
239
257
|
}
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { httpRequest } from './httpRequest';
|
|
2
2
|
export { default as ProgressLogger } from './progressLogger';
|
|
3
3
|
export { timeoutAfter } from './timeoutAfter';
|
|
4
|
-
export {
|
|
4
|
+
export { NETWORK_REQUEST_TIMED_OUT_MESSAGE, installNetworkRequestPolicyTimers, isAbortError, isNetworkRequestTimeoutError, mergeParentSignalWithDeadline, resolveRequestTimeoutMs, type MergedDeadlineHandles, type NetworkRequestPolicyTimerCallbacks, } from './network';
|
|
5
5
|
export { getS3Client, resetS3ClientForTests } from './s3/getS3Client';
|
|
6
6
|
export { default as listS3Objects, type S3ObjectEntry } from './s3/listS3Objects';
|
|
7
7
|
export { default as getS3Object, type GetS3ObjectResult } from './s3/getS3Object';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,M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AAE,MAAM,2CAA2C,CAAC"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createCloudFrontInvalidation = exports.changeSQSMessageVisibilityTimeout = exports.deleteSQSMessage = exports.sendSQSMessage = exports.resetSQSClientForTests = exports.getSQSClient = exports.replaceS3Folder = exports.putS3Folder = exports.listS3Folder = exports.deleteS3Object = exports.putS3Object = exports.getS3Object = exports.listS3Objects = exports.resetS3ClientForTests = exports.getS3Client = exports.resolveRequestTimeoutMs = exports.mergeParentSignalWithDeadline = exports.isNetworkRequestTimeoutError = exports.isAbortError = exports.installNetworkRequestPolicyTimers = exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE = exports.
|
|
6
|
+
exports.createCloudFrontInvalidation = exports.changeSQSMessageVisibilityTimeout = exports.deleteSQSMessage = exports.sendSQSMessage = exports.resetSQSClientForTests = exports.getSQSClient = exports.replaceS3Folder = exports.putS3Folder = exports.listS3Folder = exports.deleteS3Object = exports.putS3Object = exports.getS3Object = exports.listS3Objects = exports.resetS3ClientForTests = exports.getS3Client = exports.resolveRequestTimeoutMs = exports.mergeParentSignalWithDeadline = exports.isNetworkRequestTimeoutError = exports.isAbortError = exports.installNetworkRequestPolicyTimers = exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE = exports.timeoutAfter = exports.ProgressLogger = exports.httpRequest = void 0;
|
|
7
7
|
var httpRequest_1 = require("./httpRequest");
|
|
8
8
|
Object.defineProperty(exports, "httpRequest", { enumerable: true, get: function () { return httpRequest_1.httpRequest; } });
|
|
9
9
|
var progressLogger_1 = require("./progressLogger");
|
|
@@ -11,9 +11,6 @@ Object.defineProperty(exports, "ProgressLogger", { enumerable: true, get: functi
|
|
|
11
11
|
var timeoutAfter_1 = require("./timeoutAfter");
|
|
12
12
|
Object.defineProperty(exports, "timeoutAfter", { enumerable: true, get: function () { return timeoutAfter_1.timeoutAfter; } });
|
|
13
13
|
var network_1 = require("./network");
|
|
14
|
-
Object.defineProperty(exports, "NETWORK_REQUEST_DEFAULT_TIMEOUT_SECONDS", { enumerable: true, get: function () { return network_1.NETWORK_REQUEST_DEFAULT_TIMEOUT_SECONDS; } });
|
|
15
|
-
Object.defineProperty(exports, "NETWORK_REQUEST_HARD_TIMEOUT_MS", { enumerable: true, get: function () { return network_1.NETWORK_REQUEST_HARD_TIMEOUT_MS; } });
|
|
16
|
-
Object.defineProperty(exports, "NETWORK_REQUEST_SLOW_THRESHOLD_MS", { enumerable: true, get: function () { return network_1.NETWORK_REQUEST_SLOW_THRESHOLD_MS; } });
|
|
17
14
|
Object.defineProperty(exports, "NETWORK_REQUEST_TIMED_OUT_MESSAGE", { enumerable: true, get: function () { return network_1.NETWORK_REQUEST_TIMED_OUT_MESSAGE; } });
|
|
18
15
|
Object.defineProperty(exports, "installNetworkRequestPolicyTimers", { enumerable: true, get: function () { return network_1.installNetworkRequestPolicyTimers; } });
|
|
19
16
|
Object.defineProperty(exports, "isAbortError", { enumerable: true, get: function () { return network_1.isAbortError; } });
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Published as `ropegeo-common/helpers/network`. Prefer this entry over `ropegeo-common/helpers` in
|
|
4
4
|
* Metro/RN bundles so the full helpers barrel (S3 folder upload, etc.) is not resolved.
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
6
|
+
export { NETWORK_REQUEST_TIMED_OUT_MESSAGE, installNetworkRequestPolicyTimers, isAbortError, isNetworkRequestTimeoutError, mergeParentSignalWithDeadline, resolveRequestTimeoutMs, type MergedDeadlineHandles, type NetworkRequestPolicyTimerCallbacks, } from "./networkRequestPolicy";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/network/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/network/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iCAAiC,EACjC,iCAAiC,EACjC,YAAY,EACZ,4BAA4B,EAC5B,6BAA6B,EAC7B,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,kCAAkC,GACxC,MAAM,wBAAwB,CAAC"}
|
|
@@ -5,11 +5,8 @@
|
|
|
5
5
|
* Metro/RN bundles so the full helpers barrel (S3 folder upload, etc.) is not resolved.
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.resolveRequestTimeoutMs = exports.mergeParentSignalWithDeadline = exports.isNetworkRequestTimeoutError = exports.isAbortError = exports.installNetworkRequestPolicyTimers = exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE =
|
|
8
|
+
exports.resolveRequestTimeoutMs = exports.mergeParentSignalWithDeadline = exports.isNetworkRequestTimeoutError = exports.isAbortError = exports.installNetworkRequestPolicyTimers = exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE = void 0;
|
|
9
9
|
var networkRequestPolicy_1 = require("./networkRequestPolicy");
|
|
10
|
-
Object.defineProperty(exports, "NETWORK_REQUEST_DEFAULT_TIMEOUT_SECONDS", { enumerable: true, get: function () { return networkRequestPolicy_1.NETWORK_REQUEST_DEFAULT_TIMEOUT_SECONDS; } });
|
|
11
|
-
Object.defineProperty(exports, "NETWORK_REQUEST_HARD_TIMEOUT_MS", { enumerable: true, get: function () { return networkRequestPolicy_1.NETWORK_REQUEST_HARD_TIMEOUT_MS; } });
|
|
12
|
-
Object.defineProperty(exports, "NETWORK_REQUEST_SLOW_THRESHOLD_MS", { enumerable: true, get: function () { return networkRequestPolicy_1.NETWORK_REQUEST_SLOW_THRESHOLD_MS; } });
|
|
13
10
|
Object.defineProperty(exports, "NETWORK_REQUEST_TIMED_OUT_MESSAGE", { enumerable: true, get: function () { return networkRequestPolicy_1.NETWORK_REQUEST_TIMED_OUT_MESSAGE; } });
|
|
14
11
|
Object.defineProperty(exports, "installNetworkRequestPolicyTimers", { enumerable: true, get: function () { return networkRequestPolicy_1.installNetworkRequestPolicyTimers; } });
|
|
15
12
|
Object.defineProperty(exports, "isAbortError", { enumerable: true, get: function () { return networkRequestPolicy_1.isAbortError; } });
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defaults for HTTP wrappers and other network clients (see plan: mobile-network-resilience).
|
|
3
|
-
* Apps may pass their own deadline via `timeoutAfterSeconds` on components; when omitted,
|
|
4
|
-
* {@link NETWORK_REQUEST_DEFAULT_TIMEOUT_SECONDS} applies.
|
|
5
|
-
*/
|
|
6
|
-
export declare const NETWORK_REQUEST_DEFAULT_TIMEOUT_SECONDS = 30;
|
|
7
|
-
export declare const NETWORK_REQUEST_HARD_TIMEOUT_MS: number;
|
|
8
|
-
/** Use when showing “slow network” UI before the full countdown is surfaced (e.g. toasts). */
|
|
9
|
-
export declare const NETWORK_REQUEST_SLOW_THRESHOLD_MS = 15000;
|
|
1
|
+
/** Network helpers for optional request deadlines and timeout countdowns. */
|
|
10
2
|
/** Use this exact message so callers can detect timeout vs other failures. */
|
|
11
3
|
export declare const NETWORK_REQUEST_TIMED_OUT_MESSAGE = "Network request timed out";
|
|
12
4
|
export declare function isNetworkRequestTimeoutError(e: unknown): boolean;
|
|
13
5
|
export declare function isAbortError(e: unknown): boolean;
|
|
14
|
-
/** Milliseconds for `timeoutAfterSeconds` on request components
|
|
15
|
-
export declare function resolveRequestTimeoutMs(timeoutAfterSeconds?: number): number;
|
|
6
|
+
/** Milliseconds for `timeoutAfterSeconds` on request components; `null` when timeout is disabled. */
|
|
7
|
+
export declare function resolveRequestTimeoutMs(timeoutAfterSeconds?: number): number | null;
|
|
16
8
|
export type NetworkRequestPolicyTimerCallbacks = {
|
|
17
9
|
isActive: () => boolean;
|
|
18
10
|
onTimeoutCountdown: (secondsRemaining: number) => void;
|
|
@@ -35,5 +27,5 @@ export type MergedDeadlineHandles = {
|
|
|
35
27
|
* Call `dispose()` after the request settles to clear the timer; then `consumeDidTimeout()` to see
|
|
36
28
|
* whether the deadline fired (vs parent abort only).
|
|
37
29
|
*/
|
|
38
|
-
export declare function mergeParentSignalWithDeadline(parentSignal: AbortSignal, deadlineMs
|
|
30
|
+
export declare function mergeParentSignalWithDeadline(parentSignal: AbortSignal, deadlineMs: number): MergedDeadlineHandles;
|
|
39
31
|
//# sourceMappingURL=networkRequestPolicy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"networkRequestPolicy.d.ts","sourceRoot":"","sources":["../../../src/helpers/network/networkRequestPolicy.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"networkRequestPolicy.d.ts","sourceRoot":"","sources":["../../../src/helpers/network/networkRequestPolicy.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAE7E,8EAA8E;AAC9E,eAAO,MAAM,iCAAiC,8BAA8B,CAAC;AAE7E,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAIhD;AAED,qGAAqG;AACrG,wBAAgB,uBAAuB,CAAC,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASnF;AAED,MAAM,MAAM,kCAAkC,GAAG;IAC/C,QAAQ,EAAE,MAAM,OAAO,CAAC;IACxB,kBAAkB,EAAE,CAAC,gBAAgB,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,uBAAuB,EAAE,MAAM,IAAI,CAAC;IACpC,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,kBAAkB,EAAE,MAAM,EAC1B,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,kCAAkC,GAC5C,MAAM,IAAI,CAuCZ;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,iBAAiB,EAAE,MAAM,OAAO,CAAC;CAClC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,WAAW,EACzB,UAAU,EAAE,MAAM,GACjB,qBAAqB,CAqCvB"}
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Defaults for HTTP wrappers and other network clients (see plan: mobile-network-resilience).
|
|
4
|
-
* Apps may pass their own deadline via `timeoutAfterSeconds` on components; when omitted,
|
|
5
|
-
* {@link NETWORK_REQUEST_DEFAULT_TIMEOUT_SECONDS} applies.
|
|
6
|
-
*/
|
|
2
|
+
/** Network helpers for optional request deadlines and timeout countdowns. */
|
|
7
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE =
|
|
4
|
+
exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE = void 0;
|
|
9
5
|
exports.isNetworkRequestTimeoutError = isNetworkRequestTimeoutError;
|
|
10
6
|
exports.isAbortError = isAbortError;
|
|
11
7
|
exports.resolveRequestTimeoutMs = resolveRequestTimeoutMs;
|
|
12
8
|
exports.installNetworkRequestPolicyTimers = installNetworkRequestPolicyTimers;
|
|
13
9
|
exports.mergeParentSignalWithDeadline = mergeParentSignalWithDeadline;
|
|
14
|
-
exports.NETWORK_REQUEST_DEFAULT_TIMEOUT_SECONDS = 30;
|
|
15
|
-
exports.NETWORK_REQUEST_HARD_TIMEOUT_MS = exports.NETWORK_REQUEST_DEFAULT_TIMEOUT_SECONDS * 1000;
|
|
16
|
-
/** Use when showing “slow network” UI before the full countdown is surfaced (e.g. toasts). */
|
|
17
|
-
exports.NETWORK_REQUEST_SLOW_THRESHOLD_MS = 15000;
|
|
18
10
|
/** Use this exact message so callers can detect timeout vs other failures. */
|
|
19
11
|
exports.NETWORK_REQUEST_TIMED_OUT_MESSAGE = "Network request timed out";
|
|
20
12
|
function isNetworkRequestTimeoutError(e) {
|
|
@@ -27,14 +19,14 @@ function isAbortError(e) {
|
|
|
27
19
|
return true;
|
|
28
20
|
return false;
|
|
29
21
|
}
|
|
30
|
-
/** Milliseconds for `timeoutAfterSeconds` on request components
|
|
22
|
+
/** Milliseconds for `timeoutAfterSeconds` on request components; `null` when timeout is disabled. */
|
|
31
23
|
function resolveRequestTimeoutMs(timeoutAfterSeconds) {
|
|
32
24
|
if (timeoutAfterSeconds != null &&
|
|
33
25
|
Number.isFinite(timeoutAfterSeconds) &&
|
|
34
26
|
timeoutAfterSeconds > 0) {
|
|
35
27
|
return Math.floor(timeoutAfterSeconds) * 1000;
|
|
36
28
|
}
|
|
37
|
-
return
|
|
29
|
+
return null;
|
|
38
30
|
}
|
|
39
31
|
/**
|
|
40
32
|
* Emits whole seconds until {@link hardTimeoutMs} on install and roughly every second after
|
|
@@ -85,7 +77,7 @@ function installNetworkRequestPolicyTimers(requestStartedAtMs, hardTimeoutMs, ca
|
|
|
85
77
|
* Call `dispose()` after the request settles to clear the timer; then `consumeDidTimeout()` to see
|
|
86
78
|
* whether the deadline fired (vs parent abort only).
|
|
87
79
|
*/
|
|
88
|
-
function mergeParentSignalWithDeadline(parentSignal, deadlineMs
|
|
80
|
+
function mergeParentSignalWithDeadline(parentSignal, deadlineMs) {
|
|
89
81
|
const controller = new AbortController();
|
|
90
82
|
let didTimeout = false;
|
|
91
83
|
const onParentAbort = () => {
|