import type { Generated } from "kysely"; import type { LixGenerated } from "../../schema-definition/definition.js"; /** * Base type for cross-version entity views that include operational columns from the state table. * These views expose lixcol_version_id for version-specific operations and allow querying entities * across all versions in the database. * * @example * ```typescript * // Define an entity view type for cross-version operations * export type AccountByVersionView = { * id: Generated; * name: string; * } & StateEntityByVersionView; * * // Query entities across versions * const accounts = await lix.db * .selectFrom("account_by_version") * .where("lixcol_version_id", "=", "v1") * .selectAll() * .execute(); * ``` */ export type StateEntityByVersionView = { /** * The unique identifier for this entity within its schema and file. * * This is the primary identifier used to reference this specific entity. */ lixcol_entity_id: Generated; /** * The schema key that defines the structure and type of this entity. * * This references the schema definition that validates and types this entity. */ lixcol_schema_key: Generated; /** * File identifier where this entity is stored. * * This references the file_id in the state table and links the entity * to a specific file in the Lix file system. */ lixcol_file_id: Generated; /** * The plugin key that manages this entity type. * * This identifies which plugin is responsible for handling this entity. */ lixcol_plugin_key: Generated; /** * Version identifier for this specific state of the entity. * * This column allows you to query and modify entities in specific versions. * Each version may have its own state for the same entity. */ lixcol_version_id: Generated; /** * Version identifier this entity was inherited from during branching. * * - `null` if the entity was created in this version * - Contains the source version_id if the entity was inherited from another version * * This is useful for tracking entity lineage across version branches. */ lixcol_inherited_from_version_id: Generated; /** * Timestamp when this entity was created in this version. * * **Important**: This timestamp is relative to the version specified by lixcol_version_id. * - When an entity is first created, this is the actual creation time * - When an entity is inherited from another version, this is the time it was inherited * * Format: ISO 8601 string (e.g., "2024-03-20T10:30:00.000Z") */ lixcol_created_at: Generated; /** * Timestamp when this entity was last updated in this version. * * **Important**: This timestamp is relative to the version specified by lixcol_version_id. * - Updates only when the entity is modified within this specific version * - When first inherited, this equals lixcol_created_at * * Format: ISO 8601 string (e.g., "2024-03-20T10:30:00.000Z") */ lixcol_updated_at: Generated; /** * Change identifier for the last modification to this entity. * * This references the change.id that last modified this entity, enabling * blame and diff functionality. Useful for tracking who made changes * and when they were made. */ lixcol_change_id: Generated; /** * Whether this entity is stored as untracked state. * * - `false` (default): Entity follows normal change control and versioning * - `true`: Entity bypasses change control for UI state, temporary data, etc. * * Untracked entities don't create change records and have highest priority * in the state resolution order: untracked > tracked > inherited. */ lixcol_untracked: Generated; /** * Commit identifier that contains this entity's last change. * * This references the commit.id that contains the last change to this entity. * Useful for understanding which commit a particular entity state belongs to, * enabling history queries and version comparison. */ lixcol_commit_id: Generated; /** * Writer key associated with the last mutation that produced this entity state. * * Used to attribute writes to individual clients/sessions for echo suppression. * Null when no writer key was set for the mutation. */ lixcol_writer_key: Generated; /** * Arbitrary metadata attached to the change that produced this entity state. */ lixcol_metadata: Generated | null>; }; /** * Base type for cross-version cross-version entity views using LixGenerated markers instead of Kysely's Generated type. * This type is compatible with the Lix SDK's type transformation system and allows * cross-version entity operations. * * @example * ```typescript * // Define an entity type for cross-version operations * export type Account = { * id: LixGenerated; * name: string; * } & EntityStateByVersionColumns; * ``` */ export type EntityStateByVersionColumns = { /** * The unique identifier for this entity within its schema and file. * * This is the primary identifier used to reference this specific entity. */ lixcol_entity_id: LixGenerated; /** * The schema key that defines the structure and type of this entity. * * This references the schema definition that validates and types this entity. */ lixcol_schema_key: LixGenerated; /** * File identifier where this entity is stored. * * This references the file_id in the state table and links the entity * to a specific file in the Lix file system. */ lixcol_file_id: LixGenerated; /** * The plugin key that manages this entity type. * * This identifies which plugin is responsible for handling this entity. */ lixcol_plugin_key: LixGenerated; /** * Version identifier for this specific state of the entity. * * This column allows you to query and modify entities in specific versions. * Each version may have its own state for the same entity. */ lixcol_version_id: LixGenerated; /** * Timestamp when this entity was created in this version. * * **Important**: This timestamp is relative to the version specified by lixcol_version_id. * - When an entity is first created, this is the actual creation time * - When an entity is inherited from another version, this is the time it was inherited * * Format: ISO 8601 string (e.g., "2024-03-20T10:30:00.000Z") */ lixcol_created_at: LixGenerated; /** * Timestamp when this entity was last updated in this version. * * **Important**: This timestamp is relative to the version specified by lixcol_version_id. * - Updates only when the entity is modified within this specific version * - When first inherited, this equals lixcol_created_at * * Format: ISO 8601 string (e.g., "2024-03-20T10:30:00.000Z") */ lixcol_updated_at: LixGenerated; /** * Version identifier this entity was inherited from during branching. * * - `null` if the entity was created in this version * - Contains the source version_id if the entity was inherited from another version * * This is useful for tracking entity lineage across version branches. */ lixcol_inherited_from_version_id: LixGenerated; /** * Change identifier for the last modification to this entity. * * This references the change.id that last modified this entity, enabling * blame and diff functionality. Useful for tracking who made changes * and when they were made. */ lixcol_change_id: LixGenerated; /** * Whether this entity is stored as untracked state. * * - `false` (default): Entity follows normal change control and versioning * - `true`: Entity bypasses change control for UI state, temporary data, etc. * * Untracked entities don't create change records and have highest priority * in the state resolution order: untracked > tracked > inherited. */ lixcol_untracked: LixGenerated; /** * Commit identifier that contains this entity's last change. * * This references the commit.id that contains the last change to this entity. * Useful for understanding which commit a particular entity state belongs to, * enabling history queries and version comparison. */ lixcol_commit_id: LixGenerated; /** * Writer key associated with the last mutation that produced this entity state. * * Used to attribute writes to individual clients/sessions for echo suppression. * Null when no writer key was set for the mutation. */ lixcol_writer_key: LixGenerated; /** * Arbitrary metadata attached to the change that produced this entity state. */ lixcol_metadata: LixGenerated | null>; }; //# sourceMappingURL=entity-state-by-version.d.ts.map