chore: add mobile app

This commit is contained in:
2026-02-07 22:33:02 +01:00
parent db34640acc
commit e89384ad4e
29327 changed files with 3886944 additions and 12 deletions
+225
View File
@@ -0,0 +1,225 @@
# Changelog
## 1.3.2
### Patch Changes
- Mark options argument as optional (`retryExchange()`)
Submitted by [@jtomaszewski](https://github.com/jtomaszewski) (See [#3775](https://github.com/urql-graphql/urql/pull/3775))
- Updated dependencies (See [#3773](https://github.com/urql-graphql/urql/pull/3773), [#3767](https://github.com/urql-graphql/urql/pull/3767), [#3730](https://github.com/urql-graphql/urql/pull/3730), and [#3770](https://github.com/urql-graphql/urql/pull/3770))
- @urql/core@5.1.2
## 1.3.1
### Patch Changes
- Omit minified files and sourcemaps' `sourcesContent` in published packages
Submitted by [@kitten](https://github.com/kitten) (See [#3755](https://github.com/urql-graphql/urql/pull/3755))
- Updated dependencies (See [#3755](https://github.com/urql-graphql/urql/pull/3755))
- @urql/core@5.1.1
## 1.3.0
### Minor Changes
- Mark `@urql/core` as a peer dependency as well as a regular dependency
Submitted by [@kitten](https://github.com/kitten) (See [#3579](https://github.com/urql-graphql/urql/pull/3579))
## 1.2.1
### Patch Changes
---
Fixed the delay amount not increasing as retry count increases
Submitted by [@DoisKoh](https://github.com/DoisKoh) (See [#3478](https://github.com/urql-graphql/urql/pull/3478))
## 1.2.0
### Minor Changes
- Reset `retryExchange`s previous attempts and delay if an operation succeeds. This prevents the exchange from keeping its old retry count and delay if the operation delivered a result in the meantime. This is important for it to help recover from failing subscriptions
Submitted by [@kitten](https://github.com/kitten) (See [#3229](https://github.com/urql-graphql/urql/pull/3229))
## 1.1.1
### Patch Changes
- Publish with npm provenance
Submitted by [@kitten](https://github.com/kitten) (See [#3180](https://github.com/urql-graphql/urql/pull/3180))
## 1.1.0
### Minor Changes
- Update exchanges to drop redundant `share` calls, since `@urql/core`s `composeExchanges` utility now automatically does so for us
Submitted by [@kitten](https://github.com/kitten) (See [#3082](https://github.com/urql-graphql/urql/pull/3082))
### Patch Changes
- Upgrade to `wonka@^6.3.0`
Submitted by [@kitten](https://github.com/kitten) (See [#3104](https://github.com/urql-graphql/urql/pull/3104))
- Add TSDocs for all exchanges, documenting API internals
Submitted by [@kitten](https://github.com/kitten) (See [#3072](https://github.com/urql-graphql/urql/pull/3072))
- Updated dependencies (See [#3101](https://github.com/urql-graphql/urql/pull/3101), [#3033](https://github.com/urql-graphql/urql/pull/3033), [#3054](https://github.com/urql-graphql/urql/pull/3054), [#3053](https://github.com/urql-graphql/urql/pull/3053), [#3060](https://github.com/urql-graphql/urql/pull/3060), [#3081](https://github.com/urql-graphql/urql/pull/3081), [#3039](https://github.com/urql-graphql/urql/pull/3039), [#3104](https://github.com/urql-graphql/urql/pull/3104), [#3082](https://github.com/urql-graphql/urql/pull/3082), [#3097](https://github.com/urql-graphql/urql/pull/3097), [#3061](https://github.com/urql-graphql/urql/pull/3061), [#3055](https://github.com/urql-graphql/urql/pull/3055), [#3085](https://github.com/urql-graphql/urql/pull/3085), [#3079](https://github.com/urql-graphql/urql/pull/3079), [#3087](https://github.com/urql-graphql/urql/pull/3087), [#3059](https://github.com/urql-graphql/urql/pull/3059), [#3055](https://github.com/urql-graphql/urql/pull/3055), [#3057](https://github.com/urql-graphql/urql/pull/3057), [#3050](https://github.com/urql-graphql/urql/pull/3050), [#3062](https://github.com/urql-graphql/urql/pull/3062), [#3051](https://github.com/urql-graphql/urql/pull/3051), [#3043](https://github.com/urql-graphql/urql/pull/3043), [#3063](https://github.com/urql-graphql/urql/pull/3063), [#3054](https://github.com/urql-graphql/urql/pull/3054), [#3102](https://github.com/urql-graphql/urql/pull/3102), [#3097](https://github.com/urql-graphql/urql/pull/3097), [#3106](https://github.com/urql-graphql/urql/pull/3106), [#3058](https://github.com/urql-graphql/urql/pull/3058), and [#3062](https://github.com/urql-graphql/urql/pull/3062))
- @urql/core@4.0.0
## 1.0.0
### Major Changes
- **Goodbye IE11!** 👋 This major release removes support for IE11. All code that is shipped will be transpiled much less and will _not_ be ES5-compatible anymore, by [@kitten](https://github.com/kitten) (See [#2504](https://github.com/FormidableLabs/urql/pull/2504))
- Upgrade to [Wonka v6](https://github.com/0no-co/wonka) (`wonka@^6.0.0`), which has no breaking changes but is built to target ES2015 and comes with other minor improvements.
The library has fully been migrated to TypeScript which will hopefully help with making contributions easier!, by [@kitten](https://github.com/kitten) (See [#2504](https://github.com/FormidableLabs/urql/pull/2504))
### Patch Changes
- make `randomDelay` work correctly, by [@JoviDeCroock](https://github.com/JoviDeCroock) (See [#2615](https://github.com/FormidableLabs/urql/pull/2615))
- Updated dependencies (See [#2551](https://github.com/FormidableLabs/urql/pull/2551), [#2504](https://github.com/FormidableLabs/urql/pull/2504), [#2619](https://github.com/FormidableLabs/urql/pull/2619), [#2607](https://github.com/FormidableLabs/urql/pull/2607), and [#2504](https://github.com/FormidableLabs/urql/pull/2504))
- @urql/core@3.0.0
## 0.3.3
### Patch Changes
- Export `RetryExchangeOption` type from top level export, by [@KoltonG](https://github.com/KoltonG) (See [#2351](https://github.com/FormidableLabs/urql/pull/2351))
- Updated dependencies (See [#2384](https://github.com/FormidableLabs/urql/pull/2384) and [#2386](https://github.com/FormidableLabs/urql/pull/2386))
- @urql/core@2.4.4
## 0.3.2
### Patch Changes
- Extend peer dependency range of `graphql` to include `^16.0.0`.
As always when upgrading across many packages of `urql`, especially including `@urql/core` we recommend you to deduplicate dependencies after upgrading, using `npm dedupe` or `npx yarn-deduplicate`, by [@kitten](https://github.com/kitten) (See [#2133](https://github.com/FormidableLabs/urql/pull/2133))
- Updated dependencies (See [#2133](https://github.com/FormidableLabs/urql/pull/2133))
- @urql/core@2.3.6
## 0.3.1
### Patch Changes
- ⚠️ Fix operations sometimes not being executed after a retry is supposed to be triggered, due to a `setTimeout` reordering issue when the timer isn't as predictable as it should be, by [@kitten](https://github.com/kitten) (See [#2124](https://github.com/FormidableLabs/urql/pull/2124))
## 0.3.0
### Minor Changes
- Add a new `retryWith` option which allows operations to be updated when a request is being retried, by [@kitten](https://github.com/kitten) (See [#1881](https://github.com/FormidableLabs/urql/pull/1881))
### Patch Changes
- Updated dependencies (See [#1870](https://github.com/FormidableLabs/urql/pull/1870) and [#1880](https://github.com/FormidableLabs/urql/pull/1880))
- @urql/core@2.3.1
## 0.2.1
### Patch Changes
- Remove closure-compiler from the build step (See [#1570](https://github.com/FormidableLabs/urql/pull/1570))
- Updated dependencies (See [#1570](https://github.com/FormidableLabs/urql/pull/1570), [#1509](https://github.com/FormidableLabs/urql/pull/1509), [#1600](https://github.com/FormidableLabs/urql/pull/1600), and [#1515](https://github.com/FormidableLabs/urql/pull/1515))
- @urql/core@2.1.0
## 0.2.0
### Minor Changes
- Add a second `Operation` input argument to the `retryIf` predicate, so that retrying can be actively avoided for specific types of operations, e.g. mutations or subscriptions, in certain user-defined cases, by [@kitten](https://github.com/kitten) (See [#1117](https://github.com/FormidableLabs/urql/pull/1117))
### Patch Changes
- Updated dependencies (See [#1119](https://github.com/FormidableLabs/urql/pull/1119), [#1113](https://github.com/FormidableLabs/urql/pull/1113), [#1104](https://github.com/FormidableLabs/urql/pull/1104), and [#1123](https://github.com/FormidableLabs/urql/pull/1123))
- @urql/core@1.15.0
## 0.1.10
### Patch Changes
- ⚠️ Fix the production build overwriting the development build. Specifically in the previous release we mistakenly replaced all development bundles with production bundles. This doesn't have any direct influence on how these packages work, but prevented development warnings from being logged or full errors from being thrown, by [@kitten](https://github.com/kitten) (See [#1097](https://github.com/FormidableLabs/urql/pull/1097))
- Updated dependencies (See [#1097](https://github.com/FormidableLabs/urql/pull/1097))
- @urql/core@1.14.1
## 0.1.9
### Patch Changes
- Deprecate the `Operation.operationName` property in favor of `Operation.kind`. This name was
previously confusing as `operationName` was effectively referring to two different things. You can
safely upgrade to this new version, however to mute all deprecation warnings you will have to
**upgrade** all `urql` packages you use. If you have custom exchanges that spread operations, please
use [the new `makeOperation` helper
function](https://formidable.com/open-source/urql/docs/api/core/#makeoperation) instead, by [@bkonkle](https://github.com/bkonkle) (See [#1045](https://github.com/FormidableLabs/urql/pull/1045))
- Updated dependencies (See [#1094](https://github.com/FormidableLabs/urql/pull/1094) and [#1045](https://github.com/FormidableLabs/urql/pull/1045))
- @urql/core@1.14.0
## 0.1.8
### Patch Changes
- Upgrade to a minimum version of wonka@^4.0.14 to work around issues with React Native's minification builds, which use uglify-es and could lead to broken bundles, by [@kitten](https://github.com/kitten) (See [#842](https://github.com/FormidableLabs/urql/pull/842))
- Updated dependencies (See [#838](https://github.com/FormidableLabs/urql/pull/838) and [#842](https://github.com/FormidableLabs/urql/pull/842))
- @urql/core@1.12.0
## 0.1.7
### Patch Changes
- Add `source` debug name to all `dispatchDebug` calls during build time to identify events by which exchange dispatched them, by [@JoviDeCroock](https://github.com/JoviDeCroock) (See [#780](https://github.com/FormidableLabs/urql/pull/780))
- Updated dependencies (See [#780](https://github.com/FormidableLabs/urql/pull/780))
- @urql/core@1.11.7
## 0.1.6
### Patch Changes
- Add a `"./package.json"` entry to the `package.json`'s `"exports"` field for Node 14. This seems to be required by packages like `rollup-plugin-svelte` to function properly, by [@JoviDeCroock](https://github.com/JoviDeCroock) (See [#771](https://github.com/FormidableLabs/urql/pull/771))
- Updated dependencies (See [#771](https://github.com/FormidableLabs/urql/pull/771))
- @urql/core@1.11.6
## 0.1.5
### Patch Changes
- Add debugging events to exchanges that add more detailed information on what is happening
internally, which will be displayed by devtools like the urql [Chrome / Firefox extension](https://github.com/FormidableLabs/urql-devtools), by [@andyrichardson](https://github.com/andyrichardson) (See [#608](https://github.com/FormidableLabs/urql/pull/608))
- Updated dependencies (See [#608](https://github.com/FormidableLabs/urql/pull/608), [#718](https://github.com/FormidableLabs/urql/pull/718), and [#722](https://github.com/FormidableLabs/urql/pull/722))
- @urql/core@1.11.0
## 0.1.4
### Patch Changes
- Add graphql@^15.0.0 to peer dependency range, by [@kitten](https://github.com/kitten) (See [#688](https://github.com/FormidableLabs/urql/pull/688))
- Updated dependencies (See [#688](https://github.com/FormidableLabs/urql/pull/688) and [#678](https://github.com/FormidableLabs/urql/pull/678))
- @urql/core@1.10.8
## 0.1.3
### Patch Changes
- ⚠️ Fix node resolution when using Webpack, which experiences a bug where it only resolves
`package.json:main` instead of `module` when an `.mjs` file imports a package, by [@JoviDeCroock](https://github.com/JoviDeCroock) (See [#642](https://github.com/FormidableLabs/urql/pull/642))
- Updated dependencies (See [#642](https://github.com/FormidableLabs/urql/pull/642))
- @urql/core@1.10.4
## 0.1.2
### Patch Changes
- ⚠️ Fix Node.js Module support for v13 (experimental-modules) and v14. If your bundler doesn't support
`.mjs` files and fails to resolve the new version, please double check your configuration for
Webpack, or similar tools, by [@JoviDeCroock](https://github.com/JoviDeCroock) (See [#637](https://github.com/FormidableLabs/urql/pull/637))
- Updated dependencies (See [#637](https://github.com/FormidableLabs/urql/pull/637))
- @urql/core@1.10.3
## 0.1.1
### Patch Changes
- ⚠️ Fix Rollup bundle output being written to .es.js instead of .esm.js, by [@kitten](https://github.com/kitten) (See [#609](https://github.com/FormidableLabs/urql/pull/609))
- Updated dependencies (See [#609](https://github.com/FormidableLabs/urql/pull/609))
- @urql/core@1.10.1
## v0.1.0
**Initial Release**
+22
View File
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 20182020 Formidable,
Copyright (c) urql GraphQL Team and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+15
View File
@@ -0,0 +1,15 @@
# @urql/exchange-retry (Exchange factory)
`@urql/exchange-retry` is an exchange for the [`urql`](../../README.md) GraphQL client that allows operations (queries, mutations, subscriptions) to be retried based on an `options` parameter.
## Quick Start Guide
First install `@urql/exchange-retry` alongside `urql`:
```sh
yarn add @urql/exchange-retry
# or
npm install --save @urql/exchange-retry
```
Read more about the [retry exchange](https://formidable.com/open-source/urql/docs/advanced/retry-operations).
@@ -0,0 +1,92 @@
import { CombinedError, Operation, Exchange } from '@urql/core';
/** Input parameters for the {@link retryExchange}. */
interface RetryExchangeOptions {
/** Specify the minimum time to wait until retrying.
*
* @remarks
* `initialDelayMs` specifies the minimum time (in milliseconds) to wait
* until a failed operation is retried.
*
* @defaultValue `1_000` - one second
*/
initialDelayMs?: number;
/** Specifies the maximum time to wait until retrying.
*
* @remarks
* `maxDelayMs` specifies the maximum time (in milliseconds) to wait
* until a failed operation is retried. While `initialDelayMs`
* specifies the minimum amount of time, `randomDelay` may cause
* the delay to increase over multiple attempts.
*
* @defaultValue `15_000` - 15 seconds
*/
maxDelayMs?: number;
/** Enables a random exponential backoff to increase the delay over multiple retries.
*
* @remarks
* `randomDelay`, unless disabled, increases the time until a failed
* operation is retried over multiple attempts. It increases the time
* starting at `initialDelayMs` by 1.5x with an added factor of 01,
* until `maxDelayMs` is reached.
*
* @defaultValue `true` - enables random exponential backoff
*/
randomDelay?: boolean;
/** Specifies the maximum times an operation should be sent to the API.
*
* @remarks
* `maxNumberAttempts` defines the number of attempts an operation should
* be retried until it's considered failed.
*
* @defaultValue `2` - Retry once, i.e. two attempts
*/
maxNumberAttempts?: number;
/** Predicate allowing you to selectively not retry `Operation`s.
*
* @remarks
* `retryIf` is called with a {@link CombinedError} and the {@link Operation} that
* failed. If this function returns false the failed `Operation` is not retried.
*
* @defaultValue `(error) => !!error.networkError` - retries only on network errors.
*/
retryIf?(error: CombinedError, operation: Operation): boolean;
/** Transform function allowing you to selectively replace a retried `Operation` or return nullish value.
*
* @remarks
* `retryWhen` is called with a {@link CombinedError} and the {@link Operation} that
* failed. If this function returns an `Operation`, `retryExchange` will replace the
* failed `Operation` and retry. It won't retry the `Operation` if a nullish value
* is returned.
*
* The `retryIf` function, if defined, takes precedence and overrides this option.
*/
retryWith?(error: CombinedError, operation: Operation): Operation | null | undefined;
}
/** Exchange factory that retries failed operations.
*
* @param options - A {@link RetriesExchangeOptions} configuration object.
* @returns the created retry {@link Exchange}.
*
* @remarks
* The `retryExchange` retries failed operations with specified delays
* and exponential backoff.
*
* You may define a {@link RetryExchangeOptions.retryIf} or
* {@link RetryExchangeOptions.retryWhen} function to only retry
* certain kinds of operations, e.g. only queries.
*
* @example
* ```ts
* retryExchange({
* initialDelayMs: 1000,
* maxDelayMs: 15000,
* randomDelay: true,
* maxNumberAttempts: 2,
* retryIf: err => err && err.networkError,
* });
* ```
*/
declare const retryExchange: (options?: RetryExchangeOptions) => Exchange;
export { RetryExchangeOptions, retryExchange };
@@ -0,0 +1,133 @@
Object.defineProperty(exports, '__esModule', { value: true });
var wonka = require('wonka');
var core = require('@urql/core');
/** Input parameters for the {@link retryExchange}. */
/** Exchange factory that retries failed operations.
*
* @param options - A {@link RetriesExchangeOptions} configuration object.
* @returns the created retry {@link Exchange}.
*
* @remarks
* The `retryExchange` retries failed operations with specified delays
* and exponential backoff.
*
* You may define a {@link RetryExchangeOptions.retryIf} or
* {@link RetryExchangeOptions.retryWhen} function to only retry
* certain kinds of operations, e.g. only queries.
*
* @example
* ```ts
* retryExchange({
* initialDelayMs: 1000,
* maxDelayMs: 15000,
* randomDelay: true,
* maxNumberAttempts: 2,
* retryIf: err => err && err.networkError,
* });
* ```
*/
var retryExchange = (options = {}) => {
var {
retryIf,
retryWith
} = options;
var MIN_DELAY = options.initialDelayMs || 1000;
var MAX_DELAY = options.maxDelayMs || 15_000;
var MAX_ATTEMPTS = options.maxNumberAttempts || 2;
var RANDOM_DELAY = options.randomDelay != null ? !!options.randomDelay : true;
return ({
forward,
dispatchDebug
}) => operations$ => {
var {
source: retry$,
next: nextRetryOperation
} = wonka.makeSubject();
var retryWithBackoff$ = wonka.mergeMap(operation => {
var retry = operation.context.retry || {
count: 0,
delay: null
};
var retryCount = ++retry.count;
var delayAmount = retry.delay || MIN_DELAY;
var backoffFactor = Math.random() + 1.5;
if (RANDOM_DELAY) {
// if randomDelay is enabled and it won't exceed the max delay, apply a random
// amount to the delay to avoid thundering herd problem
if (delayAmount * backoffFactor < MAX_DELAY) {
delayAmount *= backoffFactor;
} else {
delayAmount = MAX_DELAY;
}
} else {
// otherwise, increase the delay proportionately by the initial delay
delayAmount = Math.min(retryCount * MIN_DELAY, MAX_DELAY);
}
// ensure the delay is carried over to the next context
retry.delay = delayAmount;
// We stop the retries if a teardown event for this operation comes in
// But if this event comes through regularly we also stop the retries, since it's
// basically the query retrying itself, no backoff should be added!
var teardown$ = wonka.filter(op => {
return (op.kind === 'query' || op.kind === 'teardown') && op.key === operation.key;
})(operations$);
process.env.NODE_ENV !== 'production' ? dispatchDebug({
type: 'retryAttempt',
message: `The operation has failed and a retry has been triggered (${retryCount} / ${MAX_ATTEMPTS})`,
operation,
data: {
retryCount,
delayAmount
},
"source": "retryExchange"
}) : undefined;
// Add new retryDelay and retryCount to operation
return (
// Stop retry if a teardown comes in
wonka.takeUntil(teardown$)(wonka.debounce(() => delayAmount)(wonka.fromValue(core.makeOperation(operation.kind, operation, {
...operation.context,
retry
}))))
);
})(retry$);
return wonka.filter(res => {
var retry = res.operation.context.retry;
// Only retry if the error passes the conditional retryIf function (if passed)
// or if the error contains a networkError
if (!res.error || (retryIf ? !retryIf(res.error, res.operation) : !retryWith && !res.error.networkError)) {
// Reset the delay state for a successful operation
if (retry) {
retry.count = 0;
retry.delay = null;
}
return true;
}
var maxNumberAttemptsExceeded = (retry && retry.count || 0) >= MAX_ATTEMPTS - 1;
if (!maxNumberAttemptsExceeded) {
var _operation = retryWith ? retryWith(res.error, res.operation) : res.operation;
if (!_operation) return true;
// Send failed responses to be retried by calling next on the retry$ subject
// Exclude operations that have been retried more than the specified max
nextRetryOperation(_operation);
return false;
}
process.env.NODE_ENV !== 'production' ? dispatchDebug({
type: 'retryExhausted',
message: 'Maximum number of retries has been reached. No further retries will be performed.',
operation: res.operation,
"source": "retryExchange"
}) : undefined;
return true;
})(forward(wonka.merge([operations$, retryWithBackoff$])));
};
};
exports.retryExchange = retryExchange;
//# sourceMappingURL=urql-exchange-retry.js.map
@@ -0,0 +1 @@
{"version":3,"file":"urql-exchange-retry.js","sources":["../src/retryExchange.ts"],"sourcesContent":null,"names":["retryExchange","options","retryIf","retryWith","MIN_DELAY","initialDelayMs","MAX_DELAY","maxDelayMs","MAX_ATTEMPTS","maxNumberAttempts","RANDOM_DELAY","randomDelay","forward","dispatchDebug","operations$","source","retry$","next","nextRetryOperation","makeSubject","retryWithBackoff$","mergeMap","operation","retry","context","count","delay","retryCount","delayAmount","backoffFactor","Math","random","min","teardown$","filter","op","kind","key","process","env","NODE_ENV","type","message","data","undefined","takeUntil","debounce","fromValue","makeOperation","res","error","networkError","maxNumberAttemptsExceeded","merge"],"mappings":";;;;;AAcA;;AAwEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,aAAa,GAAGA,CAACC,OAA6B,GAAG,EAAE,KAAe;EAC7E,IAAM;IAAEC,OAAO;AAAEC,IAAAA,SAAAA;AAAU,GAAC,GAAGF,OAAO,CAAA;AACtC,EAAA,IAAMG,SAAS,GAAGH,OAAO,CAACI,cAAc,IAAI,IAAI,CAAA;AAChD,EAAA,IAAMC,SAAS,GAAGL,OAAO,CAACM,UAAU,IAAI,MAAM,CAAA;AAC9C,EAAA,IAAMC,YAAY,GAAGP,OAA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,KAAK,CAACE,KAAK,GAAG,CAAC,CAAA;UACfF,KAAK,CAACG,KAAK,GAAG,IAAI,CAAA;AACpB,SAAA;AACA,QAAA,OAAO,IAAI,CAAA;AACb,OAAA;AAEA,MAAA,IAAM0B,yBAAyB,GAC7B,CAAE7B,KAAK,IAAIA,KAAK,CAACE,KAAK,IAAK,CAAC,KAAKjB,YAAY,GAAG,CAAC,CAAA;MACnD,IAAI,CAAC4C,yBAAyB,EAAE;AAC9B,QAAA,IAAM9B,UAAS,GAAGnB,SAAS,GACvBA,SAAS,CAAC8C,GAAG,CAACC,KAAK,EAAED,GAAG,CAAC3B,SAAS,CAAC,GACnC2B,GAAG,CAAC3B,SAAS,CAAA;AACjB,QAAA,IAAI,CAACA,UAAS,EAAE,OAAO,IAAI,CAAA;;AAE3B;AACA;QACAJ,kBAAkB,CAACI,UAAS,CAAC,CAAA;AAC7B,QAAA,OAAO,KAAK,CAAA;AACd,OAAA;AAEAgB,MAAAA,OAAA,CAAAC,GAAA,CAAAC,QAAA,KAAA,YAAA,GAAA3B,aAAa,CAAC;AACZ4B,QAAAA,IAAI,EAAE,gBAAgB;AACtBC,QAAAA,OAAO,EACL,mFAAmF;QACrFpB,SAAS,EAAE2B,GAAG,CAAC3B,SAAS;AAAA,QAAA,QAAA,EAAA,eAAA;OACzB,CAAC,GAAAsB,SAAA,CAAA;AAEF,MAAA,OAAO,IAAI,CAAA;KACZ,CAAC,CAzCFhC,OAAO,CADPyC,WAAK,CAAC,CAACvC,WAAW,EAAEM,iBAAiB,CAAC,CAAC,CAAA,CAAA,CAAA;GA4C1C,CAAA;AACL;;;;"}
@@ -0,0 +1,76 @@
import { makeSubject as r, mergeMap as e, filter as t, takeUntil as a, debounce as o, fromValue as n, merge as i } from "wonka";
import { makeOperation as u } from "@urql/core";
var retryExchange = (y = {}) => {
var {retryIf: d, retryWith: s} = y;
var l = y.initialDelayMs || 1e3;
var p = y.maxDelayMs || 15e3;
var m = y.maxNumberAttempts || 2;
var c = null != y.randomDelay ? !!y.randomDelay : !0;
return ({forward: y, dispatchDebug: v}) => f => {
var {source: h, next: x} = r();
var E = e((r => {
var e = r.context.retry || {
count: 0,
delay: null
};
var i = ++e.count;
var y = e.delay || l;
var d = Math.random() + 1.5;
if (c) {
if (y * d < p) {
y *= d;
} else {
y = p;
}
} else {
y = Math.min(i * l, p);
}
e.delay = y;
var s = t((e => ("query" === e.kind || "teardown" === e.kind) && e.key === r.key))(f);
"production" !== process.env.NODE_ENV && v({
type: "retryAttempt",
message: `The operation has failed and a retry has been triggered (${i} / ${m})`,
operation: r,
data: {
retryCount: i,
delayAmount: y
},
source: "retryExchange"
});
return a(s)(o((() => y))(n(u(r.kind, r, {
...r.context,
retry: e
}))));
}))(h);
return t((r => {
var e = r.operation.context.retry;
if (!(r.error && (d ? d(r.error, r.operation) : s || r.error.networkError))) {
if (e) {
e.count = 0;
e.delay = null;
}
return !0;
}
if (!((e && e.count || 0) >= m - 1)) {
var t = s ? s(r.error, r.operation) : r.operation;
if (!t) {
return !0;
}
x(t);
return !1;
}
"production" !== process.env.NODE_ENV && v({
type: "retryExhausted",
message: "Maximum number of retries has been reached. No further retries will be performed.",
operation: r.operation,
source: "retryExchange"
});
return !0;
}))(y(i([ f, E ])));
};
};
export { retryExchange };
//# sourceMappingURL=urql-exchange-retry.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"urql-exchange-retry.mjs","sources":["../src/retryExchange.ts"],"sourcesContent":null,"names":["retryExchange","options","retryIf","retryWith","MIN_DELAY","initialDelayMs","MAX_DELAY","maxDelayMs","MAX_ATTEMPTS","maxNumberAttempts","RANDOM_DELAY","randomDelay","forward","dispatchDebug","operations$","source","retry$","next","nextRetryOperation","makeSubject","retryWithBackoff$","mergeMap","operation","retry","context","count","delay","retryCount","delayAmount","backoffFactor","Math","random","min","teardown$","filter","op","kind","key","process","env","NODE_ENV","type","message","data","takeUntil","debounce","fromValue","makeOperation","res","error","networkError","merge"],"mappings":";;;;AA8GO,IAAMA,gBA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AAO;UACTA,EAAME,QAAQ;UACdF,EAAMG,QAAQ;AAChB;QACA,QAAO;AACT;MAIA,OADIH,KAASA,EAAME,SAAU,MAAMjB,IAAe,IAClB;QAC9B,IAAMc,IAAYnB,IACdA,EAAU6C,EAAIC,OAAOD,EAAI1B,aACzB0B,EAAI1B;QACR,KAAKA;UAAW,QAAO;;QAIvBJ,EAAmBI;QACnB,QAAO;AACT;MAEA,iBAAAgB,QAAAC,IAAAC,YAAA3B,EAAc;QACZ4B,MAAM;QACNC,SACE;QACFpB,WAAW0B,EAAI1B;QAASP,QAAA;;MAG1B,QAAO;AAAI,OAvCbmB,CADAtB,EADAuC,EAAM,EAACrC,GAAaM;AAAmB;AA4C1C;;"}
+63
View File
@@ -0,0 +1,63 @@
{
"name": "@urql/exchange-retry",
"version": "1.3.2",
"description": "An exchange for operation retry support in urql",
"sideEffects": false,
"homepage": "https://formidable.com/open-source/urql/docs/",
"bugs": "https://github.com/urql-graphql/urql/issues",
"license": "MIT",
"author": "urql GraphQL Contributors",
"repository": {
"type": "git",
"url": "https://github.com/urql-graphql/urql.git",
"directory": "exchanges/retry"
},
"keywords": [
"urql",
"graphql client",
"graphql",
"exchanges",
"retry"
],
"main": "dist/urql-exchange-retry",
"module": "dist/urql-exchange-retry.mjs",
"types": "dist/urql-exchange-retry.d.ts",
"source": "src/index.ts",
"exports": {
".": {
"types": "./dist/urql-exchange-retry.d.ts",
"import": "./dist/urql-exchange-retry.mjs",
"require": "./dist/urql-exchange-retry.js",
"source": "./src/index.ts"
},
"./package.json": "./package.json"
},
"files": [
"LICENSE",
"CHANGELOG.md",
"README.md",
"dist/"
],
"devDependencies": {
"graphql": "^16.0.0",
"@urql/core": "5.1.2"
},
"peerDependencies": {
"@urql/core": "^5.0.0"
},
"dependencies": {
"@urql/core": "^5.1.2",
"wonka": "^6.3.2"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"scripts": {
"test": "vitest",
"clean": "rimraf dist",
"check": "tsc --noEmit",
"lint": "eslint --ext=js,jsx,ts,tsx .",
"build": "rollup -c ../../scripts/rollup/config.mjs"
}
}