/** * A list of placeholders that can be located inside queries after those queries were * serialized into JSON objects. * * These placeholders are used to represent special keys and values. For example, if a * query is nested into a query, the nested query will be marked with `__RONIN_QUERY`, * which allows for distinguishing that nested query from an object of instructions. */ declare const QUERY_SYMBOLS: { readonly QUERY: "__RONIN_QUERY"; readonly EXPRESSION: "__RONIN_EXPRESSION"; readonly FIELD: "__RONIN_FIELD_"; readonly FIELD_PARENT: "__RONIN_FIELD_PARENT_"; readonly FIELD_PARENT_OLD: "__RONIN_FIELD_PARENT_OLD_"; readonly FIELD_PARENT_NEW: "__RONIN_FIELD_PARENT_NEW_"; readonly VALUE: "__RONIN_VALUE"; }; type ModelEntityEnum = 'field' | 'index' | 'trigger' | 'preset'; type FieldValue = string | number | boolean | null | unknown; type FieldSelector = Record; type StoredObject = { key: string; src: string; name: string | null; placeholder: { base64: string | null; } | null; meta: { size: number; type: string; width?: number; height?: number; }; }; type Expression = { [QUERY_SYMBOLS.EXPRESSION]: string; }; type WithInstructionRefinement = FieldValue | { being?: FieldValue | Array; notBeing?: FieldValue | Array; startingWith?: FieldValue | Array; notStartingWith?: FieldValue | Array; endingWith?: FieldValue | Array; notEndingWith?: FieldValue | Array; containing?: FieldValue | Array; notContaining?: FieldValue | Array; greaterThan?: FieldValue | Array; greaterOrEqual?: FieldValue | Array; lessThan?: FieldValue | Array; lessOrEqual?: FieldValue | Array; }; type WithInstruction = Record | Record> | Record> | Record>>; type IncludingInstruction = Record; type OrderedByInstruction = { ascending?: Array; descending?: Array; }; type UsingInstruction = Array | Record; type CombinedInstructions = { with?: WithInstruction | Array; to?: FieldSelector; including?: IncludingInstruction; selecting?: Array; orderedBy?: OrderedByInstruction; before?: string | null; after?: string | null; limitedTo?: number; using?: UsingInstruction; }; type GetQuery = Record | null>; type SetQuery = Record & { to: FieldSelector; }>; type AddQuery = Record & { with: FieldSelector; }>; type RemoveQuery = Record>; type CountQuery = Record | null>; type AllQueryInstructions = { /** * Limit the list of models for which queries should be generated to only the models * that the provided model links to. */ for?: PublicModel['slug']; /** * Provide query instructions for specific models. */ on?: Record | null>; }; type AllQuery = { all: AllQueryInstructions | null; }; type GetAllQuery = AllQuery; type CountAllQuery = AllQuery; type GetInstructions = Omit; type ListQuery = { models?: null; } | { model: string; }; type CreateQuery = { model: string | PublicModel; to?: PublicModel; }; type AlterQuery = { model: string; to?: Partial>; create?: { field?: Omit; index?: Omit; trigger?: Omit; preset?: Omit; }; alter?: { field?: string; to?: Partial>; } | { index?: string; to?: Partial>; } | { trigger?: string; to?: Omit; } | { preset?: string; to?: Omit; }; drop?: Partial>; }; type DropQuery = { model: string; }; type Query = { get?: GetQuery | GetAllQuery; set?: SetQuery; add?: AddQuery; remove?: RemoveQuery; count?: CountQuery | CountAllQuery; list?: ListQuery; create?: CreateQuery; alter?: AlterQuery; drop?: DropQuery; }; type ModelFieldCollation = 'BINARY' | 'NOCASE' | 'RTRIM'; type ModelFieldLinkAction = 'CASCADE' | 'RESTRICT' | 'SET NULL' | 'SET DEFAULT' | 'NO ACTION'; type ModelFieldBasics = { /** The label that should be used when displaying the field on the RONIN dashboard. */ name?: string; /** Allows for addressing the field programmatically. */ slug: string; /** How the field should be displayed visually on the RONIN dashboard. */ displayAs?: string; /** * If set, only one record of the same model will be allowed to exist with a given * value for the field. */ unique?: boolean; /** * Whether a value must be provided for the field. If this attribute is set and no * value is provided, an error will be thrown. */ required?: boolean; /** * The value that should be inserted into the field in the case that no value was * explicitly provided for it when a record is created. */ defaultValue?: Expression | unknown; /** * An expression that should be evaluated to form the value of the field. The * expression can either be VIRTUAL (evaluated whenever a record is read) or STORED * (evaluated whenever a record is created or updated). */ computedAs?: { kind: 'VIRTUAL' | 'STORED'; value: Expression; }; /** An expression that gets evaluated every time a value is provided for the field. */ check?: Expression; /** Whether the field was automatically added by RONIN. */ system?: boolean; }; type ModelField = ModelFieldBasics & ({ /** The kind of value that should be stored inside the field. */ type?: never; } | { /** The kind of value that should be stored inside the field. */ type: 'boolean'; } | { /** The kind of value that should be stored inside the field. */ type: 'date'; } | { /** The kind of value that should be stored inside the field. */ type: 'json'; } | { /** The kind of value that should be stored inside the field. */ type: 'blob'; } | { /** The kind of value that should be stored inside the field. */ type: 'string'; /** The collation sequence to use for the field value. */ collation?: ModelFieldCollation; } | { /** The kind of value that should be stored inside the field. */ type: 'number'; /** * Automatically increments the value of the field with every new inserted record. */ increment?: boolean; } | { /** The kind of value that should be stored inside the field. */ type: 'link'; /** The target model of the relationship that is being established. */ target: string; /** Whether the field should be related to one record, or many records. */ kind?: 'one'; /** * If the target record is updated or deleted, the defined actions maybe executed. */ actions?: { onDelete?: ModelFieldLinkAction; onUpdate?: ModelFieldLinkAction; }; } | { /** The kind of value that should be stored inside the field. */ type: 'link'; /** The target model of the relationship that is being established. */ target: string; /** Whether the field should be related to one record, or many records. */ kind: 'many'; }); type ModelIndexField = ModelEntityList> = { /** The collating sequence used for text placed inside the field. */ collation?: ModelFieldCollation; /** How the records in the index should be ordered. */ order?: 'ASC' | 'DESC'; } & ({ /** The field slug for which the index should be created. */ slug: keyof T; } | { /** The field expression for which the index should be created. */ expression: string; }); type ModelIndex = ModelEntityList> = { /** * The list of fields in the model for which the index should be created. */ fields: [ModelIndexField, ...Array>]; /** * The identifier of the index. */ slug: string; /** * Whether only one record with a unique value for the provided fields will be allowed. */ unique?: boolean; /** * An object containing query instructions that will be used to match the records that * should be included in the index. */ filter?: WithInstruction; }; type ModelTriggerField = ModelEntityList> = { /** * The slug of the field that should cause the trigger to fire if the value of the * field has changed. */ slug: keyof T; }; type ModelTrigger = ModelEntityList> = { /** The identifier of the trigger. */ slug: string; /** The type of query for which the trigger should fire. */ action: 'INSERT' | 'UPDATE' | 'DELETE'; /** When the trigger should fire in the case that a matching query is executed. */ when: 'BEFORE' | 'DURING' | 'AFTER'; /** A list of queries that should be executed when the trigger fires. */ effects: Array>; /** A list of field slugs for which the trigger should fire. */ fields?: Array>; /** * An object containing query instructions used to determine whether the trigger should * fire, or not. */ filter?: WithInstruction; }; type ModelPreset = { /** The visual display name of the preset. */ name?: string; /** The identifier that can be used for adding the preset to a query. */ slug: string; /** The query instructions that should be applied when the preset is used. */ instructions: GetInstructions; /** Whether the preset was automatically added by RONIN. */ system?: boolean; }; type ModelEntityList = Record, T extends infer U ? Omit : never>; interface Model$1 = ModelEntityList> { id: string; name: string; pluralName: string; slug: string; pluralSlug: string; identifiers: { name: keyof T; slug: keyof T; }; idPrefix: string; /** The name of the table in SQLite. */ table: string; /** * The table name to which the model was aliased. This will be set in the case that * multiple tables are being joined into one SQL statement. */ tableAlias?: string; /** * Details that identify the model as a model that was automatically created by RONIN, * instead of being manually created by a developer. */ system?: { /** The model that caused the system model to get created. */ model: string | 'root'; /** * If the model is used to associate two models with each other (in the case of * many-cardinality link fields), this property should contain the field slug to * which the associative model should be mounted on the source model. */ associationSlug?: string; }; fields: T; indexes?: ModelEntityList>; triggers?: ModelEntityList>; presets?: ModelEntityList; } type PublicModel = ModelEntityList> = Omit>, 'slug' | 'identifiers' | 'system' | 'tableAlias'> & { slug: Required; identifiers?: Partial; }; type RecursiveRequired = { [K in keyof T]-?: T[K] extends object ? RecursiveRequired : T[K]; }; interface BaseModel { identifiers: { name: string; slug: string; }; ronin: { createdAt: Date; updatedAt: Date; }; summary?: string; } type Model = Omit, 'identifiers'> & BaseModel; export type { Model as M };