//#region ../blade-compiler/dist/index.d.ts /** Query types used for interacting with data. */ declare const DML_QUERY_TYPES: readonly ["get", "count", "set", "add", "remove"]; /** Query types used for reading the database schema. */ /** Query types used for interacting with the database schema. */ declare const DDL_QUERY_TYPES: readonly ["list", "create", "alter", "drop"]; /** All read query types. */ /** * 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 VALUE: "__RONIN_VALUE"; }; //#endregion //#region src/types/query.d.ts type QueryTypeEnum = (typeof DML_QUERY_TYPES)[number]; type ModelQueryTypeEnum = (typeof DDL_QUERY_TYPES)[number]; type ModelEntityEnum = 'field' | 'index' | '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 InstructionSchema = 'with' | 'to' | 'including' | 'selecting' | 'orderedBy' | 'orderedBy.ascending' | 'orderedBy.descending' | 'before' | 'after' | 'limitedTo' | 'using'; 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 SetInstructions = Omit & { to: FieldSelector; }; type AddInstructions = Omit & { to: FieldSelector; }; type RemoveInstructions = Omit; type CountInstructions = 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; preset?: Omit; }; alter?: { field?: string; to?: Partial>; } | { index?: string; to?: Partial>; } | { 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 QueryType = QueryTypeEnum | ModelQueryTypeEnum; type QueryInstructionType = InstructionSchema; interface Statement { sql: string; params: Array; returning?: boolean; } //#endregion //#region src/types/model.d.ts 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; /** * 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'; }); /** An extended version of `ModelField`, for internal use within the compiler. */ 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$1; } | { /** 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 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$1 extends infer U ? Omit : never>; interface Model = ModelEntityList> { id: string; name: string; pluralName: string; slug: string; pluralSlug: string; identifiers: { name: keyof T$1; slug: keyof T$1; }; 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$1; indexes?: ModelEntityList>; presets?: ModelEntityList; } type PublicModel = ModelEntityList> = Omit>, 'slug' | 'identifiers' | 'system' | 'tableAlias'> & { slug: Required; identifiers?: Partial; }; //#endregion //#region src/model/defaults.d.ts /** * Generates a unique identifier for a newly created record. * * @returns A string containing the ID. */ declare const getRecordIdentifier: (prefix: string) => string; //#endregion //#region src/types/result.d.ts type RawRow = Array; type ObjectRow = Record; type ResultRecordBase = { /** * The unique identifier of the record. */ id: string; ronin: { /** * The timestamp of when the record was created. */ createdAt: T$1; /** * The ID of the user who created the record. */ createdBy: string | null; /** * The timestamp of the last time the record was updated. */ updatedAt: T$1; /** * The ID of the user who last updated the record. */ updatedBy: string | null; }; }; type ResultRecord = Record & ResultRecordBase; type DatabaseResult = { results: Array>; raw: true; } | { results: Array>; raw: false; } | { results: Array>; }; //#endregion //#region src/utils/helpers.d.ts type CompilerErrorCode = 'MODEL_NOT_FOUND' | 'FIELD_NOT_FOUND' | 'INDEX_NOT_FOUND' | 'TRIGGER_NOT_FOUND' | 'PRESET_NOT_FOUND' | 'INVALID_WITH_VALUE' | 'INVALID_TO_VALUE' | 'INVALID_INCLUDING_VALUE' | 'INVALID_FOR_VALUE' | 'INVALID_BEFORE_OR_AFTER_INSTRUCTION' | 'INVALID_MODEL_VALUE' | 'INVALID_FIELD_VALUE' | 'EXISTING_MODEL_ENTITY' | 'REQUIRED_MODEL_ENTITY' | 'MUTUALLY_EXCLUSIVE_INSTRUCTIONS' | 'MISSING_INSTRUCTION' | 'MISSING_FIELD' | 'QUERY_EXECUTION_FAILED'; interface Issue { message: string; path: Array; } interface Details { message: string; code: CompilerErrorCode; field?: string; fields?: Array; issues?: Array; queries?: Array | null; } declare class CompilerError extends Error { code: Details['code']; field?: Details['field']; fields?: Details['fields']; issues?: Details['issues']; queries?: Details['queries']; constructor(details: Details); } /** * Checks if the provided value contains a RONIN model symbol (a represenation of a * particular entity inside a query, such as an expression or a sub query) and returns * its type and value. * * @param value - The value that should be checked. * * @returns The type and value of the symbol, if the provided value contains one. */ //#endregion export { ResultRecord as C, StoredObject as D, Statement as E, WithInstruction as O, RemoveQuery as S, SetQuery as T, PublicModel as _, CompilerError as a, QueryType as b, CreateQuery as c, GetInstructions as d, GetQuery as f, ModelPreset as g, ModelIndex as h, CombinedInstructions as i, getRecordIdentifier as k, DatabaseResult as l, ModelField as m, AddQuery as n, CountInstructions as o, ListQuery as p, AlterQuery as r, CountQuery as s, AddInstructions as t, DropQuery as u, Query as v, SetInstructions as w, RemoveInstructions as x, QueryInstructionType as y };