@spoosh/core 0.11.0 → 0.12.0
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/index.d.mts +9 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.js +8 -8
- package/dist/index.mjs +8 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -279,13 +279,16 @@ type PluginContext = {
|
|
|
279
279
|
readonly method: HttpMethod;
|
|
280
280
|
readonly queryKey: string;
|
|
281
281
|
readonly tags: string[];
|
|
282
|
-
/** Timestamp when this request was initiated. Useful for tracing and debugging. */
|
|
283
282
|
readonly requestTimestamp: number;
|
|
284
|
-
/** Unique identifier for
|
|
285
|
-
readonly
|
|
283
|
+
/** Unique identifier for this usage instance. Persists across queryKey changes. */
|
|
284
|
+
readonly instanceId?: string;
|
|
285
|
+
/** Request options with resolved headers. Modify to customize the request (e.g., add headers, signal, body). */
|
|
286
286
|
request: PluginRequestOptions;
|
|
287
|
-
|
|
287
|
+
/** Temporary storage for inter-plugin communication during a single request lifecycle. Data stored here doesn't persist beyond the request. */
|
|
288
|
+
temp: Map<string, unknown>;
|
|
289
|
+
/** State manager for accessing and modifying cache entries. */
|
|
288
290
|
stateManager: StateManager;
|
|
291
|
+
/** Event emitter for triggering refetch, invalidation, and other events. */
|
|
289
292
|
eventEmitter: EventEmitter;
|
|
290
293
|
/** Access other plugins' exported APIs */
|
|
291
294
|
plugins: PluginAccessor;
|
|
@@ -1610,7 +1613,7 @@ type CreateOperationOptions<TData, TError> = {
|
|
|
1610
1613
|
pluginExecutor: PluginExecutor;
|
|
1611
1614
|
fetchFn: (options: AnyRequestOptions) => Promise<SpooshResponse<TData, TError>>;
|
|
1612
1615
|
/** Unique identifier for the hook instance. Persists across queryKey changes. */
|
|
1613
|
-
|
|
1616
|
+
instanceId?: string;
|
|
1614
1617
|
};
|
|
1615
1618
|
declare function createOperationController<TData, TError>(options: CreateOperationOptions<TData, TError>): OperationController<TData, TError>;
|
|
1616
1619
|
|
|
@@ -1663,7 +1666,7 @@ type CreateInfiniteReadOptions<TData, TItem, TError, TRequest> = {
|
|
|
1663
1666
|
pluginExecutor: PluginExecutor;
|
|
1664
1667
|
fetchFn: (options: InfiniteRequestOptions, signal: AbortSignal) => Promise<SpooshResponse<TData, TError>>;
|
|
1665
1668
|
/** Unique identifier for the hook instance. Persists across queryKey changes. */
|
|
1666
|
-
|
|
1669
|
+
instanceId?: string;
|
|
1667
1670
|
};
|
|
1668
1671
|
declare function createInfiniteReadController<TData, TItem, TError, TRequest extends InfiniteRequestOptions = InfiniteRequestOptions>(options: CreateInfiniteReadOptions<TData, TItem, TError, TRequest>): InfiniteReadController<TData, TItem, TError>;
|
|
1669
1672
|
|
package/dist/index.d.ts
CHANGED
|
@@ -279,13 +279,16 @@ type PluginContext = {
|
|
|
279
279
|
readonly method: HttpMethod;
|
|
280
280
|
readonly queryKey: string;
|
|
281
281
|
readonly tags: string[];
|
|
282
|
-
/** Timestamp when this request was initiated. Useful for tracing and debugging. */
|
|
283
282
|
readonly requestTimestamp: number;
|
|
284
|
-
/** Unique identifier for
|
|
285
|
-
readonly
|
|
283
|
+
/** Unique identifier for this usage instance. Persists across queryKey changes. */
|
|
284
|
+
readonly instanceId?: string;
|
|
285
|
+
/** Request options with resolved headers. Modify to customize the request (e.g., add headers, signal, body). */
|
|
286
286
|
request: PluginRequestOptions;
|
|
287
|
-
|
|
287
|
+
/** Temporary storage for inter-plugin communication during a single request lifecycle. Data stored here doesn't persist beyond the request. */
|
|
288
|
+
temp: Map<string, unknown>;
|
|
289
|
+
/** State manager for accessing and modifying cache entries. */
|
|
288
290
|
stateManager: StateManager;
|
|
291
|
+
/** Event emitter for triggering refetch, invalidation, and other events. */
|
|
289
292
|
eventEmitter: EventEmitter;
|
|
290
293
|
/** Access other plugins' exported APIs */
|
|
291
294
|
plugins: PluginAccessor;
|
|
@@ -1610,7 +1613,7 @@ type CreateOperationOptions<TData, TError> = {
|
|
|
1610
1613
|
pluginExecutor: PluginExecutor;
|
|
1611
1614
|
fetchFn: (options: AnyRequestOptions) => Promise<SpooshResponse<TData, TError>>;
|
|
1612
1615
|
/** Unique identifier for the hook instance. Persists across queryKey changes. */
|
|
1613
|
-
|
|
1616
|
+
instanceId?: string;
|
|
1614
1617
|
};
|
|
1615
1618
|
declare function createOperationController<TData, TError>(options: CreateOperationOptions<TData, TError>): OperationController<TData, TError>;
|
|
1616
1619
|
|
|
@@ -1663,7 +1666,7 @@ type CreateInfiniteReadOptions<TData, TItem, TError, TRequest> = {
|
|
|
1663
1666
|
pluginExecutor: PluginExecutor;
|
|
1664
1667
|
fetchFn: (options: InfiniteRequestOptions, signal: AbortSignal) => Promise<SpooshResponse<TData, TError>>;
|
|
1665
1668
|
/** Unique identifier for the hook instance. Persists across queryKey changes. */
|
|
1666
|
-
|
|
1669
|
+
instanceId?: string;
|
|
1667
1670
|
};
|
|
1668
1671
|
declare function createInfiniteReadController<TData, TItem, TError, TRequest extends InfiniteRequestOptions = InfiniteRequestOptions>(options: CreateInfiniteReadOptions<TData, TItem, TError, TRequest>): InfiniteReadController<TData, TItem, TError>;
|
|
1669
1672
|
|
package/dist/index.js
CHANGED
|
@@ -1232,7 +1232,7 @@ function createOperationController(options) {
|
|
|
1232
1232
|
eventEmitter,
|
|
1233
1233
|
pluginExecutor,
|
|
1234
1234
|
fetchFn,
|
|
1235
|
-
|
|
1235
|
+
instanceId
|
|
1236
1236
|
} = options;
|
|
1237
1237
|
const queryKey = stateManager.createQueryKey({
|
|
1238
1238
|
path,
|
|
@@ -1240,7 +1240,7 @@ function createOperationController(options) {
|
|
|
1240
1240
|
options: initialRequestOptions
|
|
1241
1241
|
});
|
|
1242
1242
|
let abortController = null;
|
|
1243
|
-
const
|
|
1243
|
+
const temp = /* @__PURE__ */ new Map();
|
|
1244
1244
|
let pluginOptions = void 0;
|
|
1245
1245
|
const initialState = createInitialState();
|
|
1246
1246
|
let cachedState = initialState;
|
|
@@ -1255,13 +1255,13 @@ function createOperationController(options) {
|
|
|
1255
1255
|
queryKey,
|
|
1256
1256
|
tags: resolvedTags,
|
|
1257
1257
|
requestTimestamp,
|
|
1258
|
-
|
|
1258
|
+
instanceId,
|
|
1259
1259
|
request: {
|
|
1260
1260
|
...initialRequestOptions,
|
|
1261
1261
|
...requestOptions,
|
|
1262
1262
|
headers: resolvedHeaders ?? {}
|
|
1263
1263
|
},
|
|
1264
|
-
|
|
1264
|
+
temp,
|
|
1265
1265
|
pluginOptions,
|
|
1266
1266
|
stateManager,
|
|
1267
1267
|
eventEmitter
|
|
@@ -1382,7 +1382,7 @@ function createOperationController(options) {
|
|
|
1382
1382
|
pluginOptions = options2;
|
|
1383
1383
|
},
|
|
1384
1384
|
setMetadata(key, value) {
|
|
1385
|
-
|
|
1385
|
+
temp.set(key, value);
|
|
1386
1386
|
}
|
|
1387
1387
|
};
|
|
1388
1388
|
return controller;
|
|
@@ -1450,7 +1450,7 @@ function createInfiniteReadController(options) {
|
|
|
1450
1450
|
eventEmitter,
|
|
1451
1451
|
pluginExecutor,
|
|
1452
1452
|
fetchFn,
|
|
1453
|
-
|
|
1453
|
+
instanceId
|
|
1454
1454
|
} = options;
|
|
1455
1455
|
let pageKeys = [];
|
|
1456
1456
|
let pageRequests = /* @__PURE__ */ new Map();
|
|
@@ -1550,9 +1550,9 @@ function createInfiniteReadController(options) {
|
|
|
1550
1550
|
queryKey: pageKey,
|
|
1551
1551
|
tags,
|
|
1552
1552
|
requestTimestamp: Date.now(),
|
|
1553
|
-
|
|
1553
|
+
instanceId,
|
|
1554
1554
|
request: { headers: {} },
|
|
1555
|
-
|
|
1555
|
+
temp: /* @__PURE__ */ new Map(),
|
|
1556
1556
|
pluginOptions,
|
|
1557
1557
|
stateManager,
|
|
1558
1558
|
eventEmitter
|
package/dist/index.mjs
CHANGED
|
@@ -1171,7 +1171,7 @@ function createOperationController(options) {
|
|
|
1171
1171
|
eventEmitter,
|
|
1172
1172
|
pluginExecutor,
|
|
1173
1173
|
fetchFn,
|
|
1174
|
-
|
|
1174
|
+
instanceId
|
|
1175
1175
|
} = options;
|
|
1176
1176
|
const queryKey = stateManager.createQueryKey({
|
|
1177
1177
|
path,
|
|
@@ -1179,7 +1179,7 @@ function createOperationController(options) {
|
|
|
1179
1179
|
options: initialRequestOptions
|
|
1180
1180
|
});
|
|
1181
1181
|
let abortController = null;
|
|
1182
|
-
const
|
|
1182
|
+
const temp = /* @__PURE__ */ new Map();
|
|
1183
1183
|
let pluginOptions = void 0;
|
|
1184
1184
|
const initialState = createInitialState();
|
|
1185
1185
|
let cachedState = initialState;
|
|
@@ -1194,13 +1194,13 @@ function createOperationController(options) {
|
|
|
1194
1194
|
queryKey,
|
|
1195
1195
|
tags: resolvedTags,
|
|
1196
1196
|
requestTimestamp,
|
|
1197
|
-
|
|
1197
|
+
instanceId,
|
|
1198
1198
|
request: {
|
|
1199
1199
|
...initialRequestOptions,
|
|
1200
1200
|
...requestOptions,
|
|
1201
1201
|
headers: resolvedHeaders ?? {}
|
|
1202
1202
|
},
|
|
1203
|
-
|
|
1203
|
+
temp,
|
|
1204
1204
|
pluginOptions,
|
|
1205
1205
|
stateManager,
|
|
1206
1206
|
eventEmitter
|
|
@@ -1321,7 +1321,7 @@ function createOperationController(options) {
|
|
|
1321
1321
|
pluginOptions = options2;
|
|
1322
1322
|
},
|
|
1323
1323
|
setMetadata(key, value) {
|
|
1324
|
-
|
|
1324
|
+
temp.set(key, value);
|
|
1325
1325
|
}
|
|
1326
1326
|
};
|
|
1327
1327
|
return controller;
|
|
@@ -1389,7 +1389,7 @@ function createInfiniteReadController(options) {
|
|
|
1389
1389
|
eventEmitter,
|
|
1390
1390
|
pluginExecutor,
|
|
1391
1391
|
fetchFn,
|
|
1392
|
-
|
|
1392
|
+
instanceId
|
|
1393
1393
|
} = options;
|
|
1394
1394
|
let pageKeys = [];
|
|
1395
1395
|
let pageRequests = /* @__PURE__ */ new Map();
|
|
@@ -1489,9 +1489,9 @@ function createInfiniteReadController(options) {
|
|
|
1489
1489
|
queryKey: pageKey,
|
|
1490
1490
|
tags,
|
|
1491
1491
|
requestTimestamp: Date.now(),
|
|
1492
|
-
|
|
1492
|
+
instanceId,
|
|
1493
1493
|
request: { headers: {} },
|
|
1494
|
-
|
|
1494
|
+
temp: /* @__PURE__ */ new Map(),
|
|
1495
1495
|
pluginOptions,
|
|
1496
1496
|
stateManager,
|
|
1497
1497
|
eventEmitter
|