import { PermissionConfig, RoleDeclaration } from './options.js'; /** @internal Metadata symbol used to store entity configuration. */ export declare const RayfinEntity: unique symbol; /** @internal Marker symbol set only by the `@entity()` decorator. */ export declare const RayfinEntityMarker: unique symbol; /** @internal Metadata symbol used to store storage folder configuration. */ export declare const RayfinStorageFolder: unique symbol; /** @internal Type guard that returns whether a value is a decorated entity class. */ export declare const isRayfinEntity: (obj: unknown) => obj is EntityClass; /** @internal Resolved storage folder configuration stored in metadata. */ export interface StorageFolderMetadata { name: string; folderName: string; permissions: PermissionConfig; roles?: RoleDeclaration[]; } /** @internal Constructor type carrying storage folder metadata. */ export interface StorageFolderClass extends constructor { [Symbol.metadata]: (DecoratorMetadataObject & { [RayfinStorageFolder]?: StorageFolderMetadata; }) | null; } /** @internal Type guard that returns whether a value is a decorated storage folder class. */ export declare const isRayfinStorageFolder: (obj: unknown) => obj is StorageFolderClass; /** * Field format enum for decorator metadata. * * Defines the set of supported field formats that decorators can use * to specify the database column type and serialization format. */ export declare enum FieldFormat { /** Free-form string text (maps to a variable-length string column). */ Text = "text", /** UUID/GUID identifier. */ Uuid = "uuid", /** Integer number. */ Int = "int", /** Fixed-point decimal number. */ Decimal = "decimal", /** Boolean true/false value. */ Boolean = "boolean", /** Date or date-time value. */ Date = "date", /** Email address (validated string). */ Email = "email" } /** * Canonical primary key field name as a string literal type. * * All type-level references to the PK field name across rayfin-core and * rayfin-data use this alias instead of hardcoded `'id'` literals. */ export type PrimaryKeyField = 'id'; /** * Return the canonical primary key field name at runtime. * * All runtime references to the PK field name across rayfin-core and * rayfin-data call this function instead of using hardcoded `'id'` literals. */ export declare function getPrimaryKeyField(): PrimaryKeyField; /** * Structural contract for all entity classes decorated with \@entity(). * * Entities must either omit `id` entirely (database-generated) * or declare `id` as a `string`. Non-string IDs are rejected at compile time. * * The property name `id` aligns with the {@link PrimaryKeyField} type alias, * which is the single source of truth for the PK field name. */ export interface IEntity { /** Optional primary key; omit for database-generated IDs. */ id?: string; /** Arbitrary additional entity properties. */ [key: string]: any; } /** Constructor type for a class producing instances of `T`. */ export type constructor = new (...args: unknown[]) => T; /** * Constructor type for a class decorated with `@entity()`, carrying entity metadata. * * @typeParam T - The entity instance type. */ export interface EntityClass extends constructor { [Symbol.metadata]: (DecoratorMetadataObject & { [RayfinEntity]?: EntityMetadata; }) | null; } /** * An instance of a decorated entity class. * * @typeParam T - The entity instance type. */ export interface EntityInstance extends Object { /** The entity class that produced this instance. */ constructor: EntityClass; } /** * Extracts the entity instance type from an {@link EntityClass}. * * @typeParam T - The entity class type. */ export type FromEntityClass = T extends EntityClass ? U : never; /** Maps Rayfin scalar keys to their corresponding TypeScript types. */ export interface ScalarMapping { /** The `string` scalar maps to TypeScript `string`. */ string: string; /** The `number` scalar maps to TypeScript `number`. */ number: number; /** The `boolean` scalar maps to TypeScript `boolean`. */ boolean: boolean; /** The `Date` scalar maps to the JavaScript `Date` object. */ Date: Date; /** The `Buffer` scalar maps to a Node.js `Buffer`. */ Buffer: Buffer; } /** @internal Mapping from scalar key to its string tag, used by the schema analyzer. */ export declare const ScalarToStringTags: Record; /** * Resolves a scalar key (such as `'string'`) to the canonical scalar type name * (such as `'String'`) used by the generated schema. * * @typeParam T - The scalar key to resolve. */ export type Scalar = ScalarMapping[T]; /** Union of all canonical scalar type names supported by Rayfin fields. */ export type Scalars = ScalarMapping[keyof ScalarMapping]; /** Union of all scalar key identifiers (the keys of {@link ScalarMapping}). */ export type ScalarTypes = keyof ScalarMapping; /** Base structural type for an entity used as a relationship target. */ export type EntityBase = Object; /** * Any value a field's type parameter may take: a scalar, an enum (array of * string literals), or a related entity. */ export type FieldType = ScalarTypes | Scalars[] | EntityBase; /** * Narrows a {@link FieldType} to its scalar form, or `never` if it is not a * scalar field. * * @typeParam T - The field type to narrow. */ export type ScalarFieldType = T extends ScalarTypes ? T : never; /** * Resolves a scalar field type to its runtime value type (for example, the * `'string'` scalar resolves to `string`). * * @typeParam T - The scalar field type to resolve. */ export type ScalarValueType> = T extends ScalarTypes ? Scalar : never; /** * Narrows a {@link FieldType} to its enum form (an array of string literals), * or `never` if it is not an enum field. * * @typeParam T - The field type to narrow. */ export type EnumFieldType = T extends Scalars[] ? NoInfer : never; /** * Resolves an enum field type to the union of its allowed member values. * * @typeParam T - The enum field type to resolve. */ export type EnumValueType> = T extends (infer U)[] ? U : never; /** * Narrows a {@link FieldType} to the entity class it relates to, or `never` if * it is not a relationship field. * * @typeParam T - The field type to narrow. */ export type RelationFieldType = T extends EntityBase ? EntityClass : never; /** * Resolves the type permitted for a field's `default` value, derived from * whether the field is a scalar or an enum. * * @typeParam T - The field type whose default value type is being resolved. */ export type DefaultFieldType = T extends ScalarFieldType ? ScalarValueType : T extends EnumFieldType ? EnumValueType : never; /** The set of supported relationship cardinalities. */ export declare enum RelationshipTypes { /** A to-one relationship (references a single related entity). */ one = "one", /** A to-many relationship (references a collection of related entities). */ many = "many" } /** * Metadata describing a single entity field, captured by field decorators. * * @typeParam T - The field's underlying type. * @typeParam TPropType - The resolved scalar type of the field. */ export interface FieldMetadata> { /** The field's logical format (for example, `string`, `int`, or `uuid`). */ format: FieldFormat; /** The resolved TypeScript scalar type of the field, when applicable. */ jsType?: TPropType; /** Minimum allowed value (for numeric fields) or length (for string fields). */ min?: number; /** Maximum allowed value (for numeric fields) or length (for string fields). */ max?: number; /** Total number of significant digits for decimal/numeric fields. */ precision?: number; /** Number of digits to the right of the decimal point for decimal fields. */ scale?: number; /** Regular expression the field value must match. */ regex?: RegExp; /** The set of allowed values when the field is constrained to an enum. */ enum?: EnumFieldType; /** Whether the field may be omitted (nullable). */ isOptional?: boolean; /** Whether the field's value must be unique across the entity. */ isUnique?: boolean; /** Default value applied when none is provided. */ default?: DefaultFieldType; /** Relationship metadata when the field references another entity. */ relationship?: { /** Resolver returning the related entity class. */ target: () => RelationFieldType; /** The cardinality of the relationship. */ type: RelationshipTypes; }; /** Whether the field is a Rayfin-managed system type rather than user data. */ isSystemType?: boolean; } /** @internal Type guard that returns whether a value is {@link FieldMetadata}. */ export declare const isFieldMetadata: (obj: unknown) => obj is FieldMetadata; /** Metadata describing a decorated entity: its name, fields, permissions, and roles. */ export interface EntityMetadata { /** The entity's name. */ name: string; /** Field metadata keyed by field name. */ fields: Record>; /** Access-control configuration for the entity. */ permissions: PermissionConfig; /** Role declarations associated with the entity, when present. */ roles?: RoleDeclaration[]; } /** @internal Merges incoming field metadata into existing metadata. */ export declare const upsertFieldMetadata: (existing: FieldMetadata | undefined, incoming: Partial>) => FieldMetadata; /** @internal Merges incoming permissions into existing permissions. */ export declare const upsertPermissions: (existing: PermissionConfig, incoming: PermissionConfig) => PermissionConfig; /** @internal Returns (creating if needed) the entity metadata for a class. */ export declare const getEntityMetadata: (entity: T) => EntityMetadata; /** @internal Returns the storage folder metadata for a class, if present. */ export declare const tryGetStorageFolderMetadata: (folder: T) => StorageFolderMetadata | undefined; /** @internal Returns (creating if needed) the storage folder metadata for a class. */ export declare const getStorageFolderMetadata: (folder: T) => StorageFolderMetadata; //# sourceMappingURL=schema.d.ts.map