fetchium 0.2.3 → 0.2.4
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/CHANGELOG.md +6 -0
- package/dist/cjs/development/{QueryClient-Ce5Mnumb.js → QueryClient-DjKxdY2y.js} +2 -2
- package/dist/cjs/development/{QueryClient-Ce5Mnumb.js.map → QueryClient-DjKxdY2y.js.map} +1 -1
- package/dist/cjs/development/index.js +1 -1
- package/dist/cjs/{production/mutation-Bleah98u.js → development/mutation-CUV5TC93.js} +2 -2
- package/dist/cjs/{production/mutation-Bleah98u.js.map → development/mutation-CUV5TC93.js.map} +1 -1
- package/dist/cjs/development/react/index.js +1 -1
- package/dist/cjs/development/rest/index.js +1 -1
- package/dist/cjs/development/topic/index.js +1 -1
- package/dist/cjs/production/{QueryClient-BXGk-5PR.js → QueryClient-YzaJT_2g.js} +2 -2
- package/dist/cjs/production/{QueryClient-BXGk-5PR.js.map → QueryClient-YzaJT_2g.js.map} +1 -1
- package/dist/cjs/production/index.js +1 -1
- package/dist/cjs/{development/mutation-GI_gTQEB.js → production/mutation-LrsiDsl7.js} +2 -2
- package/dist/cjs/{development/mutation-GI_gTQEB.js.map → production/mutation-LrsiDsl7.js.map} +1 -1
- package/dist/cjs/production/react/index.js +1 -1
- package/dist/cjs/production/rest/index.js +1 -1
- package/dist/cjs/production/topic/index.js +1 -1
- package/dist/esm/QueryResult.d.ts +1 -0
- package/dist/esm/QueryResult.d.ts.map +1 -1
- package/dist/esm/development/{QueryClient-CmMSNSpt.js → QueryClient-WObL5AFz.js} +5 -3
- package/dist/esm/development/{QueryClient-CmMSNSpt.js.map → QueryClient-WObL5AFz.js.map} +1 -1
- package/dist/esm/development/index.js +2 -2
- package/dist/esm/development/{mutation-BAM3eYqd.js → mutation-C3e7FM9D.js} +2 -2
- package/dist/esm/development/{mutation-BAM3eYqd.js.map → mutation-C3e7FM9D.js.map} +1 -1
- package/dist/esm/development/react/index.js +1 -1
- package/dist/esm/development/rest/index.js +2 -2
- package/dist/esm/development/topic/index.js +1 -1
- package/dist/esm/production/{QueryClient-3aWu_mJE.js → QueryClient-DqHBCvA1.js} +5 -3
- package/dist/esm/production/{QueryClient-3aWu_mJE.js.map → QueryClient-DqHBCvA1.js.map} +1 -1
- package/dist/esm/production/index.js +2 -2
- package/dist/esm/production/{mutation-YpiJLNWU.js → mutation-BOc53DJi.js} +2 -2
- package/dist/esm/production/{mutation-YpiJLNWU.js.map → mutation-BOc53DJi.js.map} +1 -1
- package/dist/esm/production/react/index.js +1 -1
- package/dist/esm/production/rest/index.js +2 -2
- package/dist/esm/production/topic/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as r, E as s, G as t, L as o, a as n, M as i, N as M, b as g, c as u, d as y, e as f, Q as C, f as N, g as Q, h as d, R as k, i as l, j as p, k as m, q as E, r as R, t as w } from "./QueryClient-
|
|
1
|
+
import { A as r, E as s, G as t, L as o, a as n, M as i, N as M, b as g, c as u, d as y, e as f, Q as C, f as N, g as Q, h as d, R as k, i as l, j as p, k as m, q as E, r as R, t as w } from "./QueryClient-WObL5AFz.js";
|
|
2
2
|
import { Q as F } from "./QueryAdapter-Bu5UJjE4.js";
|
|
3
|
-
import { M as A, g as K, m as Y } from "./mutation-
|
|
3
|
+
import { M as A, g as K, m as Y } from "./mutation-C3e7FM9D.js";
|
|
4
4
|
export {
|
|
5
5
|
r as ARRAY_KEY,
|
|
6
6
|
s as Entity,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getContext as h } from "signalium";
|
|
2
|
-
import { l as y, h as D, m as w, V as u, t as d } from "./QueryClient-
|
|
2
|
+
import { l as y, h as D, m as w, V as u, t as d } from "./QueryClient-WObL5AFz.js";
|
|
3
3
|
class x {
|
|
4
4
|
static adapter;
|
|
5
5
|
params;
|
|
@@ -55,4 +55,4 @@ export {
|
|
|
55
55
|
S as g,
|
|
56
56
|
C as m
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=mutation-
|
|
58
|
+
//# sourceMappingURL=mutation-C3e7FM9D.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutation-
|
|
1
|
+
{"version":3,"file":"mutation-C3e7FM9D.js","sources":["../../../src/mutation.ts"],"sourcesContent":["import { getContext, ReactiveTask } from 'signalium';\nimport { ExtractType, InternalTypeDef, MutationEffects, TypeDef, RetryConfig, TypeDefShape } from './types.js';\nimport { QueryClientContext, type QueryContext } from './QueryClient.js';\nimport { ValidatorDef, t } from './typeDefs.js';\nimport { createDefinitionProxy, extractDefinition, type CapturedDefinition } from './fieldRef.js';\nimport type { QueryAdapter, QueryAdapterClass } from './QueryAdapter.js';\n\n// ================================\n// Mutation Definition Types\n// ================================\n\nexport interface MutationConfigOptions {\n retry?: RetryConfig | number | false;\n}\n\nexport interface MutationDefinition<Request, Response> {\n id: string;\n requestShape: InternalTypeDef;\n responseShape: InternalTypeDef | undefined;\n captured: CapturedDefinition<Mutation>;\n optimisticUpdates: boolean;\n config?: MutationConfigOptions;\n effects?: MutationEffects;\n hasGetEffects: boolean;\n adapterClass: QueryAdapterClass;\n}\n\n// ================================\n// Mutation base class\n// ================================\n\nexport abstract class Mutation {\n static adapter?: QueryAdapterClass;\n\n readonly params?: TypeDefShape;\n readonly result?: TypeDefShape;\n readonly optimisticUpdates?: boolean;\n readonly config?: MutationConfigOptions;\n readonly effects?: Readonly<MutationEffects>;\n\n declare context: QueryContext;\n\n abstract getIdentityKey(): unknown;\n\n getEffects?(): MutationEffects;\n\n constructor() {\n return createDefinitionProxy(this);\n }\n}\n\n// ================================\n// Mutation definition cache and lookup\n// ================================\n\nconst mutationDefCache = new WeakMap<new () => Mutation, () => MutationDefinition<any, any>>();\n\nexport const mutationKeyForClass = (cls: new () => Mutation): string => {\n const getMutationDef = mutationDefCache.get(cls);\n\n if (getMutationDef === undefined) {\n throw new Error('Mutation definition not found');\n }\n\n return getMutationDef().id;\n};\n\n// ================================\n// Internal: build mutation definition from class\n// ================================\n\nfunction buildMutationDefinition(MutationClass: new () => Mutation): () => MutationDefinition<any, any> {\n let cached = mutationDefCache.get(MutationClass);\n\n if (cached !== undefined) {\n return cached;\n }\n\n let mutationDefinition: MutationDefinition<any, any> | undefined;\n\n const getter = (): MutationDefinition<any, any> => {\n if (mutationDefinition !== undefined) {\n return mutationDefinition;\n }\n\n const instance = new MutationClass();\n const captured = extractDefinition(instance);\n const { fields } = captured;\n\n const id = `mutation:${String(captured.methods.getIdentityKey.call(fields))}`;\n\n const requestDef = fields.params ?? {};\n const requestShape = (requestDef instanceof ValidatorDef\n ? requestDef\n : t.object(requestDef)) as unknown as InternalTypeDef;\n const responseDef = fields.result;\n const responseShape =\n responseDef !== undefined\n ? ((responseDef instanceof ValidatorDef ? responseDef : t.object(responseDef)) as unknown as InternalTypeDef)\n : undefined;\n\n const adapterClass = (MutationClass as typeof Mutation).adapter;\n if (!adapterClass) {\n throw new Error(\n `Mutation class \"${MutationClass.name}\" must define a static \\`adapter\\` property. ` +\n `Extend RESTMutation (from fetchium/rest) or set \\`static adapter = MyAdapter\\` on your mutation class.`,\n );\n }\n\n mutationDefinition = {\n id,\n requestShape,\n responseShape,\n captured,\n optimisticUpdates: fields.optimisticUpdates ?? false,\n config: fields.config,\n effects: fields.effects,\n hasGetEffects: typeof captured.methods.getEffects === 'function',\n adapterClass,\n };\n\n return mutationDefinition;\n };\n\n mutationDefCache.set(MutationClass, getter);\n return getter;\n}\n\n// ================================\n// Public API\n// ================================\n\nexport function getMutation<T extends Mutation>(\n MutationClass: new () => T,\n): ReactiveTask<Readonly<ExtractType<T['result']>>, [ExtractType<T['params']>]> {\n const getMutationDef = buildMutationDefinition(MutationClass);\n\n const queryClient = getContext(QueryClientContext);\n\n if (queryClient === undefined) {\n throw new Error('QueryClient not found');\n }\n\n return queryClient.getMutation<any, any>(getMutationDef());\n}\n"],"names":["Mutation","createDefinitionProxy","mutationDefCache","mutationKeyForClass","cls","getMutationDef","buildMutationDefinition","MutationClass","cached","mutationDefinition","getter","instance","captured","extractDefinition","fields","id","requestDef","requestShape","ValidatorDef","t","responseDef","responseShape","adapterClass","getMutation","queryClient","getContext","QueryClientContext"],"mappings":";;AA+BO,MAAeA,EAAS;AAAA,EAC7B,OAAO;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAQT,cAAc;AACZ,WAAOC,EAAsB,IAAI;AAAA,EACnC;AACF;AAMA,MAAMC,wBAAuB,QAAA,GAEhBC,IAAsB,CAACC,MAAoC;AACtE,QAAMC,IAAiBH,EAAiB,IAAIE,CAAG;AAE/C,MAAIC,MAAmB;AACrB,UAAM,IAAI,MAAM,+BAA+B;AAGjD,SAAOA,IAAiB;AAC1B;AAMA,SAASC,EAAwBC,GAAuE;AACtG,MAAIC,IAASN,EAAiB,IAAIK,CAAa;AAE/C,MAAIC,MAAW;AACb,WAAOA;AAGT,MAAIC;AAEJ,QAAMC,IAAS,MAAoC;AACjD,QAAID,MAAuB;AACzB,aAAOA;AAGT,UAAME,IAAW,IAAIJ,EAAA,GACfK,IAAWC,EAAkBF,CAAQ,GACrC,EAAE,QAAAG,MAAWF,GAEbG,IAAK,YAAY,OAAOH,EAAS,QAAQ,eAAe,KAAKE,CAAM,CAAC,CAAC,IAErEE,IAAaF,EAAO,UAAU,CAAA,GAC9BG,IAAgBD,aAAsBE,IACxCF,IACAG,EAAE,OAAOH,CAAU,GACjBI,IAAcN,EAAO,QACrBO,IACJD,MAAgB,SACVA,aAAuBF,IAAeE,IAAcD,EAAE,OAAOC,CAAW,IAC1E,QAEAE,IAAgBf,EAAkC;AACxD,QAAI,CAACe;AACH,YAAM,IAAI;AAAA,QACR,mBAAmBf,EAAc,IAAI;AAAA,MAAA;AAKzC,WAAAE,IAAqB;AAAA,MACnB,IAAAM;AAAA,MACA,cAAAE;AAAA,MACA,eAAAI;AAAA,MACA,UAAAT;AAAA,MACA,mBAAmBE,EAAO,qBAAqB;AAAA,MAC/C,QAAQA,EAAO;AAAA,MACf,SAASA,EAAO;AAAA,MAChB,eAAe,OAAOF,EAAS,QAAQ,cAAe;AAAA,MACtD,cAAAU;AAAA,IAAA,GAGKb;AAAA,EACT;AAEA,SAAAP,EAAiB,IAAIK,GAAeG,CAAM,GACnCA;AACT;AAMO,SAASa,EACdhB,GAC8E;AAC9E,QAAMF,IAAiBC,EAAwBC,CAAa,GAEtDiB,IAAcC,EAAWC,CAAkB;AAEjD,MAAIF,MAAgB;AAClB,UAAM,IAAI,MAAM,uBAAuB;AAGzC,SAAOA,EAAY,YAAsBnB,GAAgB;AAC3D;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as v, o as U, f as O } from "../QueryClient-
|
|
1
|
+
import { n as v, o as U, f as O } from "../QueryClient-WObL5AFz.js";
|
|
2
2
|
import { Q as T } from "../QueryAdapter-Bu5UJjE4.js";
|
|
3
|
-
import { M as w } from "../mutation-
|
|
3
|
+
import { M as w } from "../mutation-C3e7FM9D.js";
|
|
4
4
|
class P extends T {
|
|
5
5
|
_fetch;
|
|
6
6
|
_baseUrl;
|
|
@@ -1380,6 +1380,7 @@ class di {
|
|
|
1380
1380
|
params = void 0;
|
|
1381
1381
|
unsubscribe = void 0;
|
|
1382
1382
|
_relayState = void 0;
|
|
1383
|
+
_isActive = !1;
|
|
1383
1384
|
wasPaused = !1;
|
|
1384
1385
|
currentParams = void 0;
|
|
1385
1386
|
debounceTimer = void 0;
|
|
@@ -1411,7 +1412,7 @@ class di {
|
|
|
1411
1412
|
(o) => {
|
|
1412
1413
|
this._relayState = o;
|
|
1413
1414
|
const a = () => {
|
|
1414
|
-
clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this._abortController?.abort(), this._abortController = void 0, this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.unsubscribe?.(), this.unsubscribe = void 0;
|
|
1415
|
+
this._isActive = !1, clearTimeout(this.debounceTimer), this.debounceTimer = void 0, this._abortController?.abort(), this._abortController = void 0, this._fetchNextAbort?.abort(), this._fetchNextAbort = void 0, this._fetchNextPromise = void 0, this.unsubscribe?.(), this.unsubscribe = void 0;
|
|
1415
1416
|
const f = this.config?.gcTime ?? Ft;
|
|
1416
1417
|
this.queryClient.gcManager.schedule(this.queryKey, f, z.Query);
|
|
1417
1418
|
}, c = (f = !1) => {
|
|
@@ -1420,6 +1421,7 @@ class di {
|
|
|
1420
1421
|
a();
|
|
1421
1422
|
return;
|
|
1422
1423
|
}
|
|
1424
|
+
this._isActive = !0;
|
|
1423
1425
|
const v = It(this.params), p = _t(this.def, v), g = p !== this.storageKey;
|
|
1424
1426
|
g && (this.currentParams = v, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? l || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), this.relayState.isPending && this._abortController === void 0 ? this.runQueryImmediately() : (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : g && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1425
1427
|
};
|
|
@@ -1527,7 +1529,7 @@ class di {
|
|
|
1527
1529
|
// ======================================================
|
|
1528
1530
|
refetch = () => this.relayState.isPending ? this.relay : (this.runQueryImmediately(), this.relay);
|
|
1529
1531
|
markStale() {
|
|
1530
|
-
this.updatedAt = 0;
|
|
1532
|
+
this.updatedAt = 0, this._isActive && !this.isPaused && this.runDebounced();
|
|
1531
1533
|
}
|
|
1532
1534
|
get resolvedParams() {
|
|
1533
1535
|
return this.currentParams;
|
|
@@ -2480,4 +2482,4 @@ export {
|
|
|
2480
2482
|
Wt as r,
|
|
2481
2483
|
Je as t
|
|
2482
2484
|
};
|
|
2483
|
-
//# sourceMappingURL=QueryClient-
|
|
2485
|
+
//# sourceMappingURL=QueryClient-DqHBCvA1.js.map
|