Skip to content

@data-client/rest@0.15.0-beta-20251006024044-92bd01c4976f2921993b8c9f1e4dbb87af87ba7b

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 06 Oct 02:47
· 127 commits to master since this release
742a7c1

Minor Changes

  • #3461 939a4b0 Thanks @ntucker! - Add delegate.INVALID to queryKey

    This 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 939a4b0 Thanks @ntucker! - Add delegate.invalidate() to normalization

    Before

    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 1f491a9 Thanks @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 939a4b0 Thanks @ntucker! - Remove INVALID symbol export

    Schemas can use delegate.invalidate() in normalize() or return delegate.INVALID in queryKey().

  • #3449 1f491a9 Thanks @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 1f491a9 Thanks @ntucker! - Fix: ensure string id in Entity set when process returns undefined (meaning INVALID)

  • #3560 ba31c9b Thanks @ntucker! - Add Collection.remove

    ctrl.set(MyResource.getList.schema.remove, { id });
    const removeItem = MyResource.delete.extend({
      schema: MyResource.getList.schema.remove,
    });
  • #3558 fcb7d7d Thanks @ntucker! - Normalize delegate.invalidate() first argument only has key param.

    indexes optional 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 fcb7d7d Thanks @ntucker! - Unions can query() without type discriminator

    Before

    // @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
  • 35552c7 Thanks @ntucker! - Include GPT link badge in readme

  • Updated dependencies [1f491a9, 939a4b0, 939a4b0, ba31c9b, fcb7d7d, 1f491a9, 4dde1d6, bab907c, 5699005, 939a4b0, fcb7d7d, 1f491a9, 35552c7]: