/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { InternalCoreInterfacesUtilityTypes, OpaqueJsonDeserialized } from "@fluidframework/core-interfaces/internal"; import type { InternalTypes } from "./exposedInternalTypes.js"; /** * Metadata for a value that may have been validated by a {@link StateSchemaValidator} function. */ interface ValidatableMetadata { /** * Contains a validated value or undefined if `value` is invalid. * * This property will not be present if the data has not been validated. * If it is present and `undefined`, the value has been checked and found to be invalid. * Otherwise it will be the validated value. */ validatedValue?: OpaqueJsonDeserialized | undefined; } /** * Represents data with optional value that may have been validated by a * {@link @fluidframework/presence#StateSchemaValidator} function. * * @internal */ export interface ValidatableOptionalState extends Omit, keyof ValidatableMetadata>, ValidatableMetadata { } /** * Represents data with required value that may have been validated by a * {@link @fluidframework/presence#StateSchemaValidator} function. * * @internal */ export interface ValidatableRequiredState extends Omit, keyof ValidatableMetadata>, ValidatableMetadata { } /** * A directory of validatable values, where each value may be an optional * state or another directory. * * @remarks * The is the validatable version of {@link InternalTypes.ValueDirectory}. * * @internal */ export interface ValidatableValueDirectory { rev: number; items: { [name: string | number]: ValidatableOptionalState | ValidatableValueDirectory; }; } /** * Convenience type for a validatable required state or a directory of values. * * @remarks * This is the validatable version of {@link InternalTypes.ValueDirectoryOrState}. * * @internal */ export type ValidatableValueDirectoryOrState = ValidatableRequiredState | ValidatableValueDirectory; /** * Transforms basic value datastore / protocol type into equivalent type * with validation support. * * @remarks * Use when some more specific or parameterized type equivalent of * `InternalTypes.Value(Directory|RequiredState|OptionalState)` is needed. * * Basically, wherever a `*ValueState` appears it is extended with * {@link ValidatableMetadata} to support validation. * * @internal */ export type ValidatableValueStructure | InternalTypes.ValueRequiredState | InternalTypes.ValueOptionalState> = T extends InternalTypes.ValueDirectory ? InternalCoreInterfacesUtilityTypes.IfSameType, ValidatableValueDirectory, InternalCoreInterfacesUtilityTypes.FlattenIntersection & { items: { [KItems in keyof T["items"]]: ValidatableValueStructure; }; }>> : T extends InternalTypes.ValueRequiredState | InternalTypes.ValueOptionalState ? InternalCoreInterfacesUtilityTypes.FlattenIntersection> & ValidatableMetadata> : never; export {}; //# sourceMappingURL=validatableTypes.d.ts.map