import type { IDenormalizeDelegate, INormalizeDelegate, IQueryDelegate, Mergeable } from '../interface.js'; interface ScalarOptions { /** * Selects the lens value from Endpoint args. * * The returned value is part of the stored cell key, so it must be stable * for a given lens selection. */ lens: (args: readonly any[]) => string | undefined; /** * Unique namespace for this Scalar's internal entity table. */ key: string; /** * Entity class this Scalar stores cells for. * * Optional when used as a field on `Entity.schema`, where the parent Entity * is inferred. Required for standalone usage such as `schema.Values`. */ entity?: { key: string; pk?: (...args: any[]) => string | number | undefined; }; } /** * Represents lens-dependent scalar fields on entities. * * Scalar stores values that belong to an Entity but vary by Endpoint args, * such as portfolio-, currency-, or locale-specific columns. Use it as an * `Entity.schema` field, or bind `entity` when using it standalone in * `schema.Values`. * * @see https://dataclient.io/rest/api/Scalar */ export default class Scalar implements Mergeable { readonly key: string; readonly lensSelector: (args: readonly any[]) => string | undefined; readonly entity: ScalarOptions['entity']; readonly entityKey: string | undefined; /** * Allow normalize to receive primitive field values. * * Scalar stores per-cell values like `0.5`, so the visit walker must not * apply its primitive short-circuit before dispatching to `normalize()`. */ readonly acceptsPrimitives = true; /** * Represents lens-dependent scalar fields on entities. * * @see https://dataclient.io/rest/api/Scalar */ constructor(options: ScalarOptions); /** * The bound Entity's pk for a standalone scalar cell. * * Prefers the surrounding map key (authoritative for `Values(Scalar)`, * where `parent[key] === input`), then falls back to the bound * `Entity.pk(...)`. Other shapes — `[Scalar]` top-level (where `key` is * `undefined`) or nested under a plain object schema like * `{ stock: [Scalar] }` (where `Array.normalize` forwards the parent * object's field name as `key`, but `parent[key]` is the enclosing array, * not the item) — must derive pk from the item itself. * * @see https://dataclient.io/rest/api/Scalar#entityPk * @param [input] the scalar cell input * @param [parent] When normalizing, the object which included the cell * @param [key] When normalizing, the surrounding map key (if any) * @param [args] ...args sent to Endpoint */ entityPk(input: any, parent: any, key: string | undefined, args: readonly any[]): string | number | undefined; createIfValid(props: any): any; merge(existing: any, incoming: any): any; /** * Determines whether an incoming write is older than the stored cell. * * Defaults to comparing `fetchedAt`, matching Entity behavior so older * responses do not overwrite newer values. */ shouldReorder(existingMeta: { date: number; fetchedAt: number; }, incomingMeta: { date: number; fetchedAt: number; }, existing: any, incoming: any): boolean; mergeWithStore(existingMeta: { date: number; fetchedAt: number; }, incomingMeta: { date: number; fetchedAt: number; }, existing: any, incoming: any): any; mergeMetaWithStore(existingMeta: { fetchedAt: number; date: number; expiresAt: number; }, incomingMeta: { fetchedAt: number; date: number; expiresAt: number; }, existing: any, incoming: any): { fetchedAt: number; date: number; expiresAt: number; }; normalize(input: any, parent: any, key: any, delegate: INormalizeDelegate, parentEntity: any): any; denormalize(input: any, delegate: IDenormalizeDelegate): any; /** * Returns the cpks of cells matching the current lens, or undefined. * * Only consulted when `Scalar` is an endpoint's top-level schema; field * usage resolves through the parent entity. Relies on `lens` not * containing the cpk delimiter `|`. */ queryKey(args: readonly any[], unvisit: any, delegate: IQueryDelegate): string[] | undefined; } export {}; //# sourceMappingURL=Scalar.d.ts.map