@codeleap/query 5.8.9 → 5.8.11
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/package.json +4 -4
- package/package.json.bak +1 -1
- package/src/lib/Mutations.ts +7 -2
- package/src/lib/QueryKeys.ts +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeleap/query",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.11",
|
|
4
4
|
"main": "src/index.ts",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"directory": "packages/query"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@codeleap/config": "5.8.
|
|
13
|
-
"@codeleap/types": "5.8.
|
|
12
|
+
"@codeleap/config": "5.8.11",
|
|
13
|
+
"@codeleap/types": "5.8.11",
|
|
14
14
|
"ts-node-dev": "1.1.8"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "echo 'No build needed'"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@codeleap/types": "5.8.
|
|
20
|
+
"@codeleap/types": "5.8.11",
|
|
21
21
|
"typescript": "5.5.2",
|
|
22
22
|
"@tanstack/react-query": "5.89.0"
|
|
23
23
|
},
|
package/package.json.bak
CHANGED
package/src/lib/Mutations.ts
CHANGED
|
@@ -116,14 +116,19 @@ export class Mutations<T extends QueryItem, F> {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
* Removes an item from all cached list
|
|
119
|
+
* Removes an item from all or specific cached list query and returns the positions where it was found
|
|
120
120
|
* @param itemId - The ID of the item to remove
|
|
121
|
-
* @
|
|
121
|
+
* @param listFilters - Optional filters to target a specific list query. If omitted, removes from all list queries
|
|
122
|
+
* @returns A RemovedItemMap containing the query keys and positions where the item was found, or null if not found in any query
|
|
122
123
|
*
|
|
123
124
|
* @example
|
|
124
125
|
* ```typescript
|
|
126
|
+
* // Remove from all list queries
|
|
125
127
|
* const removedPositions = mutations.removeItem('user-123')
|
|
126
128
|
*
|
|
129
|
+
* // Remove from a specific filtered list
|
|
130
|
+
* const removedPositions = mutations.removeItem('user-123', { status: 'active' })
|
|
131
|
+
*
|
|
127
132
|
* // Later, restore the item to its original positions
|
|
128
133
|
* if (removedPositions) {
|
|
129
134
|
* mutations.addItem(restoredUser, removedPositions)
|
package/src/lib/QueryKeys.ts
CHANGED
|
@@ -337,6 +337,11 @@ export class QueryKeys<T extends QueryItem, F> {
|
|
|
337
337
|
return queries as Query<ListPaginationResponse<T>, Error, Omit<ListSelector<T>, 'allItems'>, QueryKey>[]
|
|
338
338
|
}
|
|
339
339
|
|
|
340
|
+
/**
|
|
341
|
+
* Gets a specific list query from the query cache
|
|
342
|
+
* @param listFilters - Optional filters to identify a specific list query. If omitted, returns the unfiltered list query
|
|
343
|
+
* @returns The matching list query, or undefined if not found
|
|
344
|
+
*/
|
|
340
345
|
getListQuery(listFilters?: F) {
|
|
341
346
|
const query = this.queryClient.getQueryCache().find({
|
|
342
347
|
queryKey: this.listKeyWithFilters(listFilters)
|