import type { schema, Collection } from './index.js'; import type { SchemaSimple, Schema, PolymorphicInterface, IDenormalizeDelegate, INormalizeDelegate } from './interface.js'; import type { EntityMap } from './normal.js'; import { CollectionOptions } from './schemas/Collection.js'; import { default as Invalidate } from './schemas/Invalidate.js'; export { EntityMap, Invalidate }; export { EntityInterface } from './interface.js'; /** Schema when adding to an Array Collection * Conceptually only returns a single item */ export type CollectionArrayAdder = S extends ({ denormalize(...args: any): any[]; schema: infer T; }) ? T : never; /** Schema when assigning to a Values Collection * Conceptually only returns a single item */ export type CollectionValuesAdder = S extends ({ denormalize(...args: any): Record; schema: infer T; }) ? T : never; /** Schema to remove/move (by value) from a Collection(Array|Values) * Conceptually only returns a single item */ export type CollectionArrayOrValuesAdder = S extends ({ denormalize(...args: any): any; schema: infer T; }) ? T : never; export interface CollectionInterface { /** Constructs a custom creation schema for this collection * * @see https://dataclient.io/rest/api/Collection#addWith */ addWith

(merge: (existing: any, incoming: any) => any, createCollectionFilter?: (...args: P) => (collectionKey: Record) => boolean): Collection; /** Constructs a custom move schema for this collection * * @see https://dataclient.io/rest/api/Collection#moveWith */ moveWith

(merge: (existing: any, incoming: any) => any): Collection; readonly cacheWith: object; readonly schema: S; readonly key: string; /** * A unique identifier for each Collection * * Calls nestKey when nested in an Entity and available; otherwise calls * argsKey. The resulting object is serialized for the pk string. * * @param [parent] When normalizing, the object which included the entity * @param [key] When normalizing, the key where this entity was found * @param [args] ...args sent to Endpoint * @param [parentEntity] Entity class containing this Collection when nested * @see https://dataclient.io/docs/api/Collection#pk */ pk(value: any, parent: any, key: string, args: any[], parentEntity?: any): string; normalize(input: any, parent: Parent, key: string, delegate: INormalizeDelegate, parentEntity?: any): string; /** Creates new instance copying over defined values of arguments * * @see https://dataclient.io/docs/api/Collection#merge */ merge(existing: any, incoming: any): any; /** Determines the order of incoming Collection vs Collection already in store * * @see https://dataclient.io/docs/api/Collection#shouldReorder * @returns true if incoming Collection should be first argument of merge() */ shouldReorder(existingMeta: { date: number; fetchedAt: number; }, incomingMeta: { date: number; fetchedAt: number; }, existing: any, incoming: any): boolean; /** Run when an existing Collection is found in the store * * @see https://dataclient.io/docs/api/Collection#mergeWithStore */ mergeWithStore(existingMeta: { date: number; fetchedAt: number; }, incomingMeta: { date: number; fetchedAt: number; }, existing: any, incoming: any): any; mergeMetaWithStore(existingMeta: { expiresAt: number; date: number; fetchedAt: number; }, incomingMeta: { expiresAt: number; date: number; fetchedAt: number; }, existing: any, incoming: any): { expiresAt: number; date: number; fetchedAt: number; }; /** Builds a key access the Collection without endpoint results * * @see https://dataclient.io/rest/api/Collection#queryKey */ queryKey(args: Args, unvisit: unknown, delegate: unknown): any; createIfValid: (value: any) => any | undefined; denormalize(input: any, delegate: IDenormalizeDelegate): ReturnType; _denormalizeNullable(): ReturnType; _normalizeNullable(): ReturnType; /** Schema to place at the *end* of this Collection * @see https://dataclient.io/rest/api/Collection#push */ push: CollectionArrayAdder; /** Schema to place at the *beginning* of this Collection * @see https://dataclient.io/rest/api/Collection#unshift */ unshift: CollectionArrayAdder; /** Schema to merge with a Values Collection * @see https://dataclient.io/rest/api/Collection#assign */ assign: CollectionValuesAdder; /** Schema to remove (by value) from a Collection(Array|Values) * @see https://dataclient.io/rest/api/Collection#remove */ remove: CollectionArrayOrValuesAdder; /** Schema to move items between Collections (remove from old, add to new) * @see https://dataclient.io/rest/api/Collection#move */ move: CollectionArrayOrValuesAdder; } export type CollectionFromSchema = CollectionInterface : S, Args, Parent>; export interface CollectionConstructor { /** * Entities but for Arrays instead of classes * @see https://dataclient.io/rest/api/Collection */ new (schema: S, options?: CollectionOptions): CollectionFromSchema; readonly prototype: CollectionInterface; } export type StrategyFunction = (value: any, parent: any, key: string) => T; export type SchemaFunction = (value: Args, parent: any, key: string) => K; export type SchemaAttribute = K | SchemaFunction; export type MergeFunction = (entityA: any, entityB: any) => any; export type SchemaAttributeFunction = (value: any, parent: any, key: string) => S; export type UnionResult = { id: string; schema: keyof Choices; }; export type DefaultArgs = [ ] | [ urlParams: Record ] | [ urlParams: Record, body: any ]; //# sourceMappingURL=schemaTypes.d.ts.map