import type { Cache } from "@warp-drive/core/types/cache"; import type { ResourceKey } from "@warp-drive/core/types/identifier"; import type { Value } from "@warp-drive/core/types/json/raw"; import type { InnerRelationshipDocument, ResourceObject } from "@warp-drive/core/types/spec/json-api-raw"; type ChangedRelationshipData = InnerRelationshipDocument; export type JsonApiResourcePatch = { type: string; id: string; attributes?: Record; relationships?: Record; } | { type: string; id: null; lid: string; attributes?: Record; relationships?: Record; }; /** * :::warning ⚠️ **This util often won't produce the necessary body for a {json:api} request** * * While this may come as a surprise, they are intended to serialize cache state for more * generalized usage. {json:api} has a large variance in acceptable shapes, and only your * app can ensure that the body is correctly formatted and contains all necessary data. * ::: * * Serializes the current state of a resource or array of resources for use with POST or PUT requests. * * @public * @param {Cache} cache} * @param {ResourceKey} identifier * @return {Object} An object with a `data` property containing the serialized resource patch */ export declare function serializeResources(cache: Cache, identifiers: ResourceKey): { data: ResourceObject; }; export declare function serializeResources(cache: Cache, identifiers: ResourceKey[]): { data: ResourceObject[]; }; /** * :::warning ⚠️ **This util often won't produce the necessary body for a {json:api} request** * * While this may come as a surprise, they are intended to serialize cache state for more * generalized usage. {json:api} has a large variance in acceptable shapes, and only your * app can ensure that the body is correctly formatted and contains all necessary data. * ::: * * Serializes changes to a resource. Useful for use with building bodies for PATCH requests. * * Only attributes which are changed are serialized. * Only relationships which are changed are serialized. * * Collection relationships serialize the collection as a whole. * * If you would like to serialize updates to a collection more granularly * (for instance, as operations) request the diff from the store and * serialize as desired: * * ```ts * const relationshipDiffMap = cache.changedRelationships(identifier); * ``` * * @public * @param {Cache} cache} * @param {ResourceKey} identifier * @return {Object} An object with a `data` property containing the serialized resource patch */ export declare function serializePatch(cache: Cache, identifier: ResourceKey): { data: JsonApiResourcePatch; }; export {};