fetchium 0.4.0 → 0.4.1
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-CbG-qdpt.js → QueryClient-D_e76rYS.js} +2 -2
- package/dist/cjs/development/QueryClient-D_e76rYS.js.map +1 -0
- package/dist/cjs/development/index.js +1 -1
- package/dist/cjs/{production/mutation-B0wMYfHP.js → development/mutation-bq06T6Wg.js} +2 -2
- package/dist/cjs/{production/mutation-B0wMYfHP.js.map → development/mutation-bq06T6Wg.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-DGCBmyPp.js → QueryClient-BPdrfgtE.js} +2 -2
- package/dist/cjs/production/QueryClient-BPdrfgtE.js.map +1 -0
- package/dist/cjs/production/index.js +1 -1
- package/dist/cjs/{development/mutation-CFkoRirO.js → production/mutation-BVVlcTsK.js} +2 -2
- package/dist/cjs/{development/mutation-CFkoRirO.js.map → production/mutation-BVVlcTsK.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.map +1 -1
- package/dist/esm/development/{QueryClient-BZY2FTv3.js → QueryClient-CkO_s9Uh.js} +9 -5
- package/dist/esm/development/QueryClient-CkO_s9Uh.js.map +1 -0
- package/dist/esm/development/index.js +2 -2
- package/dist/esm/development/{mutation-Dot2Ejg6.js → mutation-SZTEGudR.js} +2 -2
- package/dist/esm/development/{mutation-Dot2Ejg6.js.map → mutation-SZTEGudR.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-WtzRneAd.js → QueryClient--PrsE8Kj.js} +9 -5
- package/dist/esm/production/QueryClient--PrsE8Kj.js.map +1 -0
- package/dist/esm/production/index.js +2 -2
- package/dist/esm/production/{mutation-AXg513Dg.js → mutation-20F2qe90.js} +2 -2
- package/dist/esm/production/{mutation-AXg513Dg.js.map → mutation-20F2qe90.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
- package/dist/cjs/development/QueryClient-CbG-qdpt.js.map +0 -1
- package/dist/cjs/production/QueryClient-DGCBmyPp.js.map +0 -1
- package/dist/esm/development/QueryClient-BZY2FTv3.js.map +0 -1
- package/dist/esm/production/QueryClient-WtzRneAd.js.map +0 -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-CkO_s9Uh.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-SZTEGudR.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-CkO_s9Uh.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-SZTEGudR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutation-
|
|
1
|
+
{"version":3,"file":"mutation-SZTEGudR.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-CkO_s9Uh.js";
|
|
2
2
|
import { Q as T } from "../QueryAdapter-Bu5UJjE4.js";
|
|
3
|
-
import { M as N } from "../mutation-
|
|
3
|
+
import { M as N } from "../mutation-SZTEGudR.js";
|
|
4
4
|
class P extends T {
|
|
5
5
|
_fetch;
|
|
6
6
|
_baseUrl;
|
|
@@ -1524,10 +1524,14 @@ class yi {
|
|
|
1524
1524
|
const i = this.getOrCreateExecutionContext(), n = this.queryClient.getAdapter(t.statics.adapterClass), s = this._abortController?.signal ?? new AbortController().signal;
|
|
1525
1525
|
return ft(
|
|
1526
1526
|
async () => {
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1527
|
+
try {
|
|
1528
|
+
const r = await n.send(i, s);
|
|
1529
|
+
this.updatedAt = Date.now();
|
|
1530
|
+
const o = this.applyData(r, !0);
|
|
1531
|
+
return this.saveQueryMetadata(), o;
|
|
1532
|
+
} finally {
|
|
1533
|
+
this.reconcileSubscription();
|
|
1534
|
+
}
|
|
1531
1535
|
},
|
|
1532
1536
|
this.retryConfig,
|
|
1533
1537
|
s
|
|
@@ -2501,4 +2505,4 @@ export {
|
|
|
2501
2505
|
Ht as r,
|
|
2502
2506
|
Ze as t
|
|
2503
2507
|
};
|
|
2504
|
-
//# sourceMappingURL=QueryClient
|
|
2508
|
+
//# sourceMappingURL=QueryClient--PrsE8Kj.js.map
|