qdadm 1.10.1 → 1.10.3
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 +1 -1
- package/src/entity/EntityManager.ts +33 -6
package/package.json
CHANGED
|
@@ -1100,9 +1100,28 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
|
|
|
1100
1100
|
// 2. Fetch from API
|
|
1101
1101
|
let response: { items?: T[]; data?: T[] | { items?: T[]; data?: T[] }; total?: number; pagination?: { total?: number } }
|
|
1102
1102
|
if (endpoint && storage.request) {
|
|
1103
|
-
// Use request() with endpoint for multi-storage routing
|
|
1103
|
+
// Use request() with endpoint for multi-storage routing.
|
|
1104
|
+
// When using a dynamic endpoint, parent IDs are already encoded in the URL.
|
|
1105
|
+
// Strip parent-related filters to avoid duplication in query params.
|
|
1106
|
+
let requestParams = mergedParams
|
|
1107
|
+
if (context?.parentChain && mergedParams.filters) {
|
|
1108
|
+
const parentIds = new Set(
|
|
1109
|
+
context.parentChain.map((p: { id: string | number }) => String(p.id))
|
|
1110
|
+
)
|
|
1111
|
+
const cleaned = Object.fromEntries(
|
|
1112
|
+
Object.entries(mergedParams.filters as Record<string, unknown>).filter(
|
|
1113
|
+
([, value]) => !parentIds.has(String(value))
|
|
1114
|
+
)
|
|
1115
|
+
)
|
|
1116
|
+
requestParams = { ...mergedParams }
|
|
1117
|
+
if (Object.keys(cleaned).length > 0) {
|
|
1118
|
+
requestParams.filters = cleaned
|
|
1119
|
+
} else {
|
|
1120
|
+
delete requestParams.filters
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1104
1123
|
const apiResponse = (await storage.request('GET', endpoint, {
|
|
1105
|
-
params:
|
|
1124
|
+
params: requestParams,
|
|
1106
1125
|
context,
|
|
1107
1126
|
})) as { data?: unknown }
|
|
1108
1127
|
// Normalize response
|
|
@@ -1894,8 +1913,16 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
|
|
|
1894
1913
|
): Promise<ListResult<T>> {
|
|
1895
1914
|
const { context = {}, routingContext = null } = options
|
|
1896
1915
|
|
|
1897
|
-
//
|
|
1898
|
-
|
|
1916
|
+
// Check if this context uses a dynamic endpoint (no caching possible)
|
|
1917
|
+
const resolved = this._normalizeResolveResult(
|
|
1918
|
+
this.resolveStorage('list', routingContext ?? undefined),
|
|
1919
|
+
routingContext ?? undefined
|
|
1920
|
+
)
|
|
1921
|
+
const isDynamicEndpoint = !!resolved.endpoint
|
|
1922
|
+
|
|
1923
|
+
// Ensure cache is filled (via list) — skip for dynamic endpoints
|
|
1924
|
+
// since list() disables caching when resolveStorage provides an endpoint
|
|
1925
|
+
if (!isDynamicEndpoint && !this._cache.valid && this.isCacheEnabled) {
|
|
1899
1926
|
await this.list(
|
|
1900
1927
|
{ page_size: this.effectiveThreshold },
|
|
1901
1928
|
routingContext ?? undefined
|
|
@@ -1904,8 +1931,8 @@ export class EntityManager<T extends EntityRecord = EntityRecord> {
|
|
|
1904
1931
|
|
|
1905
1932
|
let result: ListResult<T>
|
|
1906
1933
|
|
|
1907
|
-
//
|
|
1908
|
-
if (this.overflow || !this.isCacheEnabled) {
|
|
1934
|
+
// Dynamic endpoint, overflow, or cache disabled → use API directly
|
|
1935
|
+
if (isDynamicEndpoint || this.overflow || !this.isCacheEnabled) {
|
|
1909
1936
|
result = await this.list(params, routingContext ?? undefined)
|
|
1910
1937
|
} else {
|
|
1911
1938
|
// Full cache available - filter locally
|