/** * Public scalar entity descriptor and the `defineTypedSheetsEntity()` builder. * * The descriptor is intentionally scalar-only and provider-neutral: it describes * a local entity table without referencing any ORM, Sheet route, or storage- * execution type. Remote projection configuration is an internal service concern, * so descriptor validation never depends on it. * * The returned `HikouteiEntity` token carries the runtime descriptor and a * phantom entity type so `em.create(User, { ... })` infers the entity shape. */ /** Runtime tags for the scalar property types supported in v1. */ export declare const HIKOUTEI_SCALAR_TYPES: { readonly STRING: "string"; readonly NUMBER: "number"; readonly BOOLEAN: "boolean"; readonly DATE: "date"; }; /** Closed set of scalar property types accepted by `defineTypedSheetsEntity`. */ export type HikouteiScalarType = (typeof HIKOUTEI_SCALAR_TYPES)[keyof typeof HIKOUTEI_SCALAR_TYPES]; /** SQLite storage affinity derived from one scalar property type. */ export type HikouteiScalarStorageType = "TEXT" | "REAL" | "INTEGER"; /** Property descriptor options accepted for one scalar entity field. */ export interface HikouteiPropertyOptions { /** Scalar value type stored in the entity table. */ readonly type: HikouteiScalarType; /** Marks this field as the single immutable primary-key/business-key column. */ readonly primary?: boolean; /** Allows `null` values and types the TypeScript property as `T | null`. */ readonly nullable?: boolean; /** Equivalent positive spelling for callers that prefer required fields. */ readonly required?: boolean; /** v1 permits uniqueness only on the primary/business key. */ readonly unique?: boolean; } /** Map of property name to scalar options declared by one entity descriptor. */ export type HikouteiPropertyDescriptorMap = Readonly>; /** User-facing entity descriptor accepted by `defineTypedSheetsEntity`. */ export interface HikouteiEntityDescriptorInput { /** Stable entity name used by the manager and internal service mappings. */ readonly name: Name; /** SQLite table name that stores this entity's rows. */ readonly tableName: string; /** Scalar property declarations keyed by property name. */ readonly properties: Properties; } /** Validated scalar property metadata consumed by the local runtime. */ export interface ResolvedHikouteiProperty { readonly name: string; readonly type: HikouteiScalarType; readonly storageType: HikouteiScalarStorageType; readonly primary: boolean; readonly nullable: boolean; readonly unique: boolean; } /** Validated entity descriptor consumed by the local runtime. */ export interface ResolvedHikouteiEntityDescriptor { readonly name: string; readonly tableName: string; /** Property name of the single primary-key/business-key column. */ readonly primaryKey: string; readonly properties: readonly ResolvedHikouteiProperty[]; } /** TypeScript value type stored for one declared scalar property type. */ export type HikouteiScalarValueType = Type extends typeof HIKOUTEI_SCALAR_TYPES.STRING ? string : Type extends typeof HIKOUTEI_SCALAR_TYPES.NUMBER ? number : Type extends typeof HIKOUTEI_SCALAR_TYPES.BOOLEAN ? boolean : Type extends typeof HIKOUTEI_SCALAR_TYPES.DATE ? Date : never; /** TypeScript property type for one property descriptor, honoring `nullable`. */ export type HikouteiPropertyValueType = Options extends { readonly nullable: true; } | { readonly required: false; } ? HikouteiScalarValueType | null : HikouteiScalarValueType; /** Inferred mutable entity instance shape derived from a property map. */ export type HikouteiEntityInstance = { -readonly [Property in keyof Properties]: HikouteiPropertyValueType; }; export declare class HikouteiEntity { /** @internal phantom marker that carries the inferred entity type. */ private readonly __entityType; /** @internal phantom marker that preserves the descriptor name. */ private readonly __entityName; constructor(descriptor: ResolvedHikouteiEntityDescriptor); } /** Reads an opaque token's descriptor for internal runtime/provider wiring. */ export declare function getEntityDescriptor(entity: HikouteiEntity): ResolvedHikouteiEntityDescriptor; /** * Returns the registered entity tokens in registration order. * * Internal factory support, not part of the application-facing contract. The * returned array is a snapshot so callers cannot mutate the registry. */ export declare function getRegisteredEntityTokens(): readonly HikouteiEntity[]; /** * Empties the entity registry. * * Test-only helper for isolated factory tests; not exported from the root * entrypoint and never called by production code. */ export declare function clearRegisteredEntityTokens(): void; /** * Validates a scalar entity descriptor and returns a stable entity token. * * Throws a typed `HikouteiError` for an empty name or table name, an invalid * table identifier, a missing or duplicate primary key, a non-string/number * primary key, a non-scalar property type, or any unsupported * relation/provider option. The returned token is safe to pass to * `createTypedSheets({ entities })`, and is also registered so a later * `createTypedSheets()` call that omits `entities` can use it as the default * entity set. * * A `string` primary key stays a TEXT column with application-assigned IDs. * A `number` primary key becomes an INTEGER AUTOINCREMENT column so SQLite * assigns the numeric ID when the app omits it at insert. */ export declare function defineTypedSheetsEntity(input: HikouteiEntityDescriptorInput): HikouteiEntity, Name>; /** * Validates and normalizes one entity descriptor input. * * Exported for focused contract tests; application code uses the typed * `defineTypedSheetsEntity` wrapper instead. */ export declare function resolveEntityDescriptor(input: HikouteiEntityDescriptorInput): ResolvedHikouteiEntityDescriptor; /** Names owned by Hikoutei's SQLite sync schema and SQLite itself. */ export declare const RESERVED_TABLE_NAMES: Set; //# sourceMappingURL=entity.d.ts.map