export const isMergeFieldOptions = ( options: CacheUpdateOptions ): options is MergeFieldOptions => { return ( (options as MergeFieldOptions).mergeFields !== null && Array.isArray((options as MergeFieldOptions).mergeFields) ) } export const isMergeOptions = ( options: CacheUpdateOptions ): options is MergeOptions => { return ( (options as MergeOptions).merge !== null && (options as MergeOptions).merge === true ) } export type MergeOptions = { /** * Granular merges instead of overwriting the target documents in their entirety. */ merge: boolean /** * Allow dot-notation mask fields styles to be updated. Intended to use * when updating documents with `updateDoc`. */ allowDotNotation?: boolean } type AllowString = T extends string ? T : never export type MergeFieldOptions> = { /** * Only replace the specified field paths. * Any field path that is not specified is ignored and remains untouched. * If your input sets any field to an empty map, all nested fields are overwritten. */ mergeFields: Array> } export type CacheUpdateOptions> = | Partial | Partial>