import { ZodType } from 'zod'; import { ModelReferenceType, ModelInstance, ModelType, PropertyInstance, DataValue, PropertyConfig, ValueGetter, MaybeFunction, Arrayable, PropertyValidator, ModelReferencePropertyInstance, DataDescription, JsonAble, CalculateDenormalization, PropertyType, DateValueType, PrimitiveValueType, CanBeNullableType } from './types.js'; /** * The base function that creates a fully loaded instance of a property. All standard issue properties use this function. * @param propertyType - The property's value type. * @param config - Configurations * @param additionalMetadata - Additional metadata that you want to add to a given property. * @typeParam TValue - The typescript value that the property produces. * @typeParam TData - The DataDescription that this property instance belongs to. * @typeParam TModelExtensions - Any additional model extensions * @typeParam TModelInstanceExtensions - Any additional model instance extensions */ export declare const Property: , TData extends DataDescription = Readonly<{ [s: string]: any; }>, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object>(propertyType: PropertyType | string, config?: PropertyConfig, additionalMetadata?: {}) => PropertyInstance; /** * Config object for a date property */ type DatePropertyConfig> = { /** * A function that can format the date into a string. * Can use date-fns, moment, or any other function. * @param date - The date will be a date object * @param format - The format property passed in if provided. */ formatFunction?: (date: Date, format?: string) => string; /** * The format the date should be in. This is a framework agnostic format, and should be based on your format function. * NOTE: If a formatFunction is not provided, this is completely ignored. For dates YYYY-MM-DD is the default and for Datetimes it is ISOString() */ format?: string; } & PropertyConfig; /** * A Property for Dates. Supports both strings and Date objects. * This does NOT include time information. * @param config - A configuration that enables overriding of date formatting * @param additionalMetadata */ export declare const DateProperty: = DateValueType>(config?: DatePropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property for Date AND Times. Supports both strings and Date Objects. * @param config - A configuration that enables overriding of date and time formatting * @param additionalMetadata */ export declare const DatetimeProperty: = DateValueType>(config?: DatePropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property that has an array of sub values. * @param config * @param additionalMetadata */ export declare const ArrayProperty: = DataValue>(config?: {}, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => readonly T[] | undefined; getConstantValue: () => readonly T[] | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: readonly T[], modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property that is an array, but only of a single value type. This is an {@link ArrayProperty} but with a validator for the type. * @param valueType - The type. (Only supports primitive data types, no objects) * @param config * @param additionalMetadata */ export declare const SingleTypeArrayProperty: >(valueType: TValue, config?: {}, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => readonly TValue[] | undefined; getConstantValue: () => readonly TValue[] | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: readonly TValue[], modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property that has simple objects. These must be JSON compliant. These are validated. * @param config * @param additionalMetadata */ export declare const ObjectProperty: >> = Readonly>>(config?: {}, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => TObject | undefined; getConstantValue: () => TObject | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: TObject, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A simple text property. If it's possible to put ALOT of text in this field consider using the {@link BigTextProperty} * @param config - Additional Configurations * @param additionalMetadata - Additional Metadata */ export declare const TextProperty: = string>(config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property for large blocks of strings. * @param config - Additional configurations * @param additionalMetadata - Additional metadata */ export declare const BigTextProperty: = string>(config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property that houses integers. No floats allowed. * @param config * @param additionalMetadata */ export declare const IntegerProperty: = number>(config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * An integer property that represents a year. NOTE: This is exclusively focused on a year in a modern context. * Validates from 0 to 3000 * @param config * @param additionalMetadata */ export declare const YearProperty: = number>(config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property for numbers. This could be integers or float values. * @param config * @param additionalMetadata */ export declare const NumberProperty: = number>(config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property that has a fixed value that can never be changed. Can be useful for things like embedding the name of a model into JSONified objects. * @param valueType - The value type for this property. * @param value - The value to fix. * @param config * @param additionalMetadata */ export declare const ConstantValueProperty: > = Arrayable>(valueType: PropertyType | string, value: TDataValue, config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => TDataValue | undefined; getConstantValue: () => TDataValue | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: TDataValue, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property that encapsulates email addresses. Provides validation for making sure an email is valid. * @param config * @param additionalMetadata */ export declare const EmailProperty: = string>(config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property that has a true or false value. * @param config * @param additionalMetadata */ export declare const BooleanProperty: = boolean>(config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property that is used for Primary Keys. If no value is provided a UUID is automatically created. * This property has required on it. * @param config - Additional configurations. NOTE: required is ALWAYS true. * @param additionalMetadata - Any additional metadata. */ export declare const PrimaryKeyUuidProperty: = string>(config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property that has a uuid. * This property has required on it. * If you want it to automatically create a uuid add { autoNow: true } to the config. * @param config - Additional configurations. * @param additionalMetadata - Any additional metadata. */ export declare const UuidProperty: = string>(config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; /** * A property that has a reference to another model instance. A "Foreign Key" if you will. * For full functionality a {@link ModelInstanceFetcher} must be provided in the config. * This property has complex functionalities. * * When a model calls "instance.get.whatever()" to get the value of a ModelReferenceProperty, it uses the model fetcher * to retrieve the model. (Could be saved elsewhere, or a database). When the promise is awaited, the value returned * is a ModelInstance object. * * However, when `toObj()` is called on that same instance, only the primary key value is returned. This is so that * when you call `toObj()` on the main instance, the "foreign key" gets filled in. * * This is useful for a save function with an ORM. * @param model - Either the model itself or a function that creates the model when needed (lazy). * @param config * @param additionalMetadata */ export declare const ModelReferenceProperty: (model: MaybeFunction>, config?: PropertyConfig>, additionalMetadata?: {}) => ModelReferencePropertyInstance, object, object>; /** * The full implementation of a ModelReference, useful for typing certain extended functionalities. * For a full description see {@link ModelReferenceProperty} * @param model - A model or a function that returns the model. * @param config * @param additionalMetadata */ export declare const AdvancedModelReferenceProperty: (model: MaybeFunction>, config?: PropertyConfig>, additionalMetadata?: {}) => ModelReferencePropertyInstance, TModelExtensions, TModelInstanceExtensions>; /** * A property for Denormalizing. This represents a complex value that has been simplified for ease of use. * One common use is for creating "Display Values" in a GUI. This process can be extremely expensive, such as having to * get selected values 2 or 3 Foreign Keys deep. * * This property allows passing in a calculate function that will only be executed once, and only if there is no value, and then only when asked. * * To recalculate the value, you need to run the calculate function on the property itself, passing in new model data. * @param propertyType - A property type. * @param calculate - A function for calculating the denormalized value. * @param config - A Config * @param additionalMetadata _ Any additional metadata. */ export declare const DenormalizedProperty: , T extends DataDescription>(propertyType: string, calculate: CalculateDenormalization, config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => TValue | undefined; getConstantValue: () => TValue | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: TValue, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }> & { calculate: CalculateDenormalization; }; /** * A Denormalized Property that is for text. * @param calculate - A function that can get a string * @param config - Any configs * @param additionalMetadata - Optional Metadata */ export declare const DenormalizedTextProperty: = string>(calculate: CalculateDenormalization, config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => TData | undefined; getConstantValue: () => TData | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: TData, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }> & { calculate: CalculateDenormalization; }; /** * A Denormalized Property that is for numbers. * @param calculate - A function that can get a string * @param config - Any configs * @param additionalMetadata - Optional Metadata */ export declare const DenormalizedNumberProperty: = number>(calculate: CalculateDenormalization, config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => TData | undefined; getConstantValue: () => TData | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: TData, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }> & { calculate: CalculateDenormalization; }; /** * A Denormalized Property that is for integers. * @param calculate - A function that can get a string * @param config - Any configs * @param additionalMetadata - Optional Metadata */ export declare const DenormalizedIntegerProperty: = number>(calculate: CalculateDenormalization, config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => TData | undefined; getConstantValue: () => TData | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: TData, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }> & { calculate: CalculateDenormalization; }; /** * An id that is naturally formed by other properties within a model. * Instead of having a "globally unique" id the model is unique because the composition of values of properties. * @param propertyKeys A list (in order) of property keys needed to make the id. These keys can take nested paths * if a property is an object, array, or even a model instance object. Example: 'nested.path.here'. * Note: If ANY of the properties are undefined, the key becomes undefined. This is to ensure key structure integrity. * Additionally, if the property key points to a referenced model 1 of 2 things will happen. * 1. If the key is not nested (Example: model.myReferenceObj) then the key to the referenced model will be used. * 2. If the key IS nested (Example: model.myReferenceObj.name) then the instance will be retrieved and then the * property for that model instance is used. * @param joiner A string that will be passed to ".join()" for creating a single string. * @param config * @param additionalMetadata */ export declare const NaturalIdProperty: = string>(propertyKeys: readonly string[], joiner: string, config?: PropertyConfig, additionalMetadata?: {}) => Readonly<{ getConfig: () => object; getChoices: () => readonly import("./types.js").ChoiceTypes[]; getDefaultValue: () => T | undefined; getConstantValue: () => T | undefined; getPropertyType: () => PropertyType | string; createGetter: (value: T, modelData: Readonly<{ [s: string]: any; }>, modelInstance: ModelInstance, object, object>) => ValueGetter, object, object>; getZod: () => ZodType>; getValidator: (valueGetter: ValueGetter, object, object>) => PropertyValidator>; }>; export {};