@data-client/rest@0.15.0-beta-20251006024044-92bd01c4976f2921993b8c9f1e4dbb87af87ba7b
Pre-releaseMinor Changes
-
#3461
939a4b0Thanks @ntucker! - Add delegate.INVALID to queryKeyThis is used in schema.All.queryKey().
Before
queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { if (!found) return INVALID; }
After
queryKey(args: any, unvisit: any, delegate: IQueryDelegate): any { if (!found) return delegate.INVALID; }
-
#3461
939a4b0Thanks @ntucker! - Add delegate.invalidate() to normalizationBefore
normalize( input: any, parent: any, key: string | undefined, args: any[], visit: (...args: any) => any, delegate: INormalizeDelegate, ): string { delegate.setEntity(this as any, pk, INVALID); }
After
normalize( input: any, parent: any, key: string | undefined, args: any[], visit: (...args: any) => any, delegate: INormalizeDelegate, ): string { delegate.invalidate(this as any, pk); }
-
#3449
1f491a9Thanks @ntucker! - BREAKING CHANGE: schema.normalize(...args, addEntity, getEntity, checkLoop) -> schema.normalize(...args, delegate)We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument.
/** Helpers during schema.normalize() */ export interface INormalizeDelegate { /** Action meta-data for this normalize call */ readonly meta: { fetchedAt: number; date: number; expiresAt: number }; /** Gets any previously normalized entity from store */ getEntity: GetEntity; /** Updates an entity using merge lifecycles when it has previously been set */ mergeEntity( schema: Mergeable & { indexes?: any }, pk: string, incomingEntity: any, ): void; /** Sets an entity overwriting any previously set values */ setEntity( schema: { key: string; indexes?: any }, pk: string, entity: any, meta?: { fetchedAt: number; date: number; expiresAt: number }, ): void; /** Returns true when we're in a cycle, so we should not continue recursing */ checkLoop(key: string, pk: string, input: object): boolean; }
Before
addEntity(this, processedEntity, id);
After
delegate.mergeEntity(this, id, processedEntity);
-
#3461
939a4b0Thanks @ntucker! - RemoveINVALIDsymbol exportSchemas can use delegate.invalidate() in normalize() or return delegate.INVALID in queryKey().
-
#3449
1f491a9Thanks @ntucker! - BREAKING CHANGE: schema.queryKey(args, queryKey, getEntity, getIndex) -> schema.queryKey(args, unvisit, delegate)
BREAKING CHANGE: delegate.getIndex() returns the index directly, rather than object.We consolidate all 'callback' functions during recursion calls into a single 'delegate' argument.
Our recursive call is renamed from queryKey to unvisit, and does not require the last two arguments.
/** Accessors to the currently processing state while building query */ export interface IQueryDelegate { getEntity: GetEntity; getIndex: GetIndex; }
Before
queryKey(args, queryKey, getEntity, getIndex) { getIndex(schema.key, indexName, value)[value]; getEntity(this.key, id); return queryKey(this.schema, args, getEntity, getIndex); }
After
queryKey(args, unvisit, delegate) { delegate.getIndex(schema.key, indexName, value); delegate.getEntity(this.key, id); return unvisit(this.schema, args); }
Patch Changes
-
#3449
1f491a9Thanks @ntucker! - Fix: ensure string id in Entity set when process returns undefined (meaning INVALID) -
#3560
ba31c9bThanks @ntucker! - Add Collection.removectrl.set(MyResource.getList.schema.remove, { id });
const removeItem = MyResource.delete.extend({ schema: MyResource.getList.schema.remove, });
-
#3558
fcb7d7dThanks @ntucker! - Normalize delegate.invalidate() first argument only haskeyparam.indexesoptional param no longer provided as it was never used.normalize( input: any, parent: any, key: string | undefined, args: any[], visit: (...args: any) => any, delegate: INormalizeDelegate, ): string { delegate.invalidate({ key: this._entity.key }, pk); return pk; }
-
#3558
fcb7d7dThanks @ntucker! - Unions can query() without type discriminatorBefore
// @ts-expect-error const event = useQuery(EventUnion, { id }); // event is undefined const newsEvent = useQuery(EventUnion, { id, type: 'news' }); // newsEvent is found
After
const event = useQuery(EventUnion, { id }); // event is found const newsEvent = useQuery(EventUnion, { id, type: 'news' }); // newsEvent is found
-
Updated dependencies [
1f491a9,939a4b0,939a4b0,ba31c9b,fcb7d7d,1f491a9,4dde1d6,bab907c,5699005,939a4b0,fcb7d7d,1f491a9,35552c7]: