import type { AllowArray } from '@sequelize/utils'; import type { DynamicSqlExpression } from '../expression-builders/base-sql-expression.js'; import type { WhereOperators } from '../model.js'; import type { Op } from '../operators.js'; /** * This type allows using `Op.or`, `Op.and`, and `Op.not` recursively around another type. * It also supports using a plain Array as an alias for `Op.and`. (unlike {@link AllowNotOrAndRecursive}). * * Example of plain-array treated as `Op.and`: * ```ts * User.findAll({ where: [{ id: 1 }, { id: 2 }] }); * ``` * * Meant to be used by {@link WhereOptions}. */ export type AllowNotOrAndWithImplicitAndArrayRecursive = AllowArray>; } | { [Op.and]: AllowArray>; } | { [Op.not]: AllowNotOrAndWithImplicitAndArrayRecursive; }>; /** * The type accepted by every `where` option */ export type WhereOptions = undefined | AllowNotOrAndWithImplicitAndArrayRecursive | DynamicSqlExpression>; /** * This type allows using `Op.or`, `Op.and`, and `Op.not` recursively around another type. * Unlike {@link AllowNotOrAndWithImplicitAndArrayRecursive}, it does not allow the 'implicit AND Array'. * * Example of plain-array NOT treated as Op.and: * ```ts * User.findAll({ where: { id: [1, 2] } }); * ``` * * Meant to be used by {@link WhereAttributeHashValue}. */ type AllowNotOrAndRecursive = T | { [Op.or]: AllowArray>; } | { [Op.and]: AllowArray>; } | { [Op.not]: AllowNotOrAndRecursive; }; /** * Types that can be compared to an attribute in a WHERE context. */ export type WhereAttributeHashValue = AllowNotOrAndRecursive[typeof Op.eq] | WhereOperators : WhereOperators[typeof Op.in] | WhereOperators[typeof Op.eq] | WhereOperators> | WhereAttributeHash; /** * A hash of attributes to describe your search. * * Possible key values: * * - An attribute name: `{ id: 1 }` * - A nested attribute: `{ '$projects.id$': 1 }` * - A JSON key: `{ 'object.key': 1 }` * - A cast: `{ 'id::integer': 1 }` * * - A combination of the above: `{ '$join.attribute$.json.path::integer': 1 }` */ export type WhereAttributeHash = { [AttributeName in keyof TAttributes as AttributeName extends string ? AttributeName | `$${AttributeName}$` : never]?: WhereAttributeHashValue; } & { [AttributeName in keyof TAttributes as AttributeName extends string ? `${AttributeName}.${string}` | `$${AttributeName}$.${string}` | `${AttributeName}[${string}` | `$${AttributeName}$[${string}` | `${AttributeName | `$${AttributeName}$` | `${AttributeName}.${string}` | `$${AttributeName}$.${string}`}:${string}` : never]?: WhereAttributeHashValue; } & { [attribute: `$${string}.${string}$` | `$${string}.${string}$::${string}` | `$${string}.${string}$.${string}` | `$${string}.${string}$.${string}:${string}` | `$${string}.${string}$[${string}` | `$${string}.${string}$[${string}:${string}`]: WhereAttributeHashValue; }; export {}; //# sourceMappingURL=where-sql-builder-types.d.ts.map