All files / src/associations mixin-types.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
// oxlint-disable typescript/no-explicit-any -- the Sequelize v6 mixin types are declared with `any` attributes.
import type { AnyModel, CreationAttributes } from '../model/options.ts';
import type {
  BulkCreateOptions,
  CreateOptions,
  InstanceDestroyOptions,
  InstanceUpdateOptions,
  SaveOptions,
} from '../model/options.ts';
import type { FindOptions } from '../model/find-options.ts';
import type { QueryOptionsBase } from '../model/runtime.ts';
import type { FindAttributeOptions } from '../model/select-options.ts';
import type { WhereOptions } from '../model/types.ts';
 
/**
 * Attributes of a junction row (Sequelize v6 `JoinTableAttributes`).
 *
 * @example
 * ```ts
 * const through: JoinTableAttributes = { role: 'owner' };
 * ```
 */
export interface JoinTableAttributes {
  [attribute: string]: unknown;
}
 
/**
 * Options of the `getX` accessor of a belongsTo association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToGetAssociationMixinOptions = { scope: false, transaction };
 * ```
 */
export interface BelongsToGetAssociationMixinOptions extends FindOptions<any> {
  /** Scope to apply on the associated model, or `false` to remove its default scope. */
  scope?: string | string[] | boolean;
}
 
/**
 * Options of the `setX` accessor of a belongsTo association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToSetAssociationMixinOptions = { save: false };
 * ```
 */
export interface BelongsToSetAssociationMixinOptions extends SaveOptions<any> {
  /** Skip saving the source after setting the foreign key when `false`. */
  save?: boolean;
}
 
/**
 * Options of the `createX` accessor of a belongsTo association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToCreateAssociationMixinOptions = { save: true, transaction };
 * ```
 */
export interface BelongsToCreateAssociationMixinOptions
  extends CreateOptions<any>, BelongsToSetAssociationMixinOptions {}
 
/**
 * Options of the `getX` accessor of a hasOne association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasOneGetAssociationMixinOptions = { scope: false };
 * ```
 */
export interface HasOneGetAssociationMixinOptions extends FindOptions<any> {
  /** Scope to apply on the associated model, or `false` to remove its default scope. */
  scope?: string | string[] | boolean;
}
 
/**
 * Options of the `setX` accessor of a hasOne association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasOneSetAssociationMixinOptions = { save: false };
 * ```
 */
export interface HasOneSetAssociationMixinOptions
  extends HasOneGetAssociationMixinOptions, SaveOptions<any> {
  /** Skip saving the associated instance after setting the foreign key when `false`. */
  save?: boolean;
}
 
/**
 * Options of the `createX` accessor of a hasOne association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasOneCreateAssociationMixinOptions = { transaction };
 * ```
 */
export interface HasOneCreateAssociationMixinOptions
  extends HasOneSetAssociationMixinOptions, CreateOptions<any> {}
 
/**
 * Options of the `getXs` accessor of a hasMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasManyGetAssociationsMixinOptions = { where: { active: true }, scope: false };
 * ```
 */
export interface HasManyGetAssociationsMixinOptions extends FindOptions<any> {
  /** Scope to apply on the associated model, or `false` to remove its default scope. */
  scope?: string | string[] | boolean;
}
 
/**
 * Options of the `setXs` accessor of a hasMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasManySetAssociationsMixinOptions = { transaction };
 * ```
 */
export interface HasManySetAssociationsMixinOptions
  extends FindOptions<any>, InstanceUpdateOptions<any> {}
 
/**
 * Options of the `addXs` accessor of a hasMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasManyAddAssociationsMixinOptions = { transaction };
 * ```
 */
export interface HasManyAddAssociationsMixinOptions extends InstanceUpdateOptions<any> {}
 
/**
 * Options of the `addX` accessor of a hasMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasManyAddAssociationMixinOptions = { transaction };
 * ```
 */
export interface HasManyAddAssociationMixinOptions extends InstanceUpdateOptions<any> {}
 
/**
 * Options of the `createX` accessor of a hasMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasManyCreateAssociationMixinOptions = { transaction };
 * ```
 */
export interface HasManyCreateAssociationMixinOptions extends CreateOptions<any> {}
 
/**
 * Options of the `removeX` accessor of a hasMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasManyRemoveAssociationMixinOptions = { transaction };
 * ```
 */
export interface HasManyRemoveAssociationMixinOptions extends InstanceUpdateOptions<any> {}
 
/**
 * Options of the `removeXs` accessor of a hasMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasManyRemoveAssociationsMixinOptions = { transaction };
 * ```
 */
export interface HasManyRemoveAssociationsMixinOptions extends InstanceUpdateOptions<any> {}
 
/**
 * Options of the `hasX` accessor of a hasMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasManyHasAssociationMixinOptions = { transaction };
 * ```
 */
export interface HasManyHasAssociationMixinOptions extends HasManyGetAssociationsMixinOptions {}
 
/**
 * Options of the `hasXs` accessor of a hasMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasManyHasAssociationsMixinOptions = { transaction };
 * ```
 */
export interface HasManyHasAssociationsMixinOptions extends HasManyGetAssociationsMixinOptions {}
 
/**
 * Options of the `countXs` accessor of a hasMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: HasManyCountAssociationsMixinOptions = { where: { active: true } };
 * ```
 */
export interface HasManyCountAssociationsMixinOptions extends QueryOptionsBase {
  /** Filter on the counted rows. */
  where?: WhereOptions<any>;
  /** Scope to apply on the associated model, or `false` to remove its default scope. */
  scope?: string | boolean;
}
 
/**
 * Options of the `getXs` accessor of a belongsToMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToManyGetAssociationsMixinOptions = { joinTableAttributes: [] };
 * ```
 */
export interface BelongsToManyGetAssociationsMixinOptions extends FindOptions<any> {
  /** Junction attributes to select. */
  joinTableAttributes?: FindAttributeOptions;
  /** Scope to apply on the associated model, or `false` to remove its default scope. */
  scope?: string | boolean;
}
 
/**
 * Options of the `setXs` accessor of a belongsToMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToManySetAssociationsMixinOptions = { through: { role: 'owner' } };
 * ```
 */
export interface BelongsToManySetAssociationsMixinOptions
  extends
    FindOptions<any>,
    BulkCreateOptions<any>,
    InstanceUpdateOptions<any>,
    InstanceDestroyOptions {
  /** Attributes of the junction row. */
  through?: JoinTableAttributes;
}
 
/**
 * Options of the `addXs` accessor of a belongsToMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToManyAddAssociationsMixinOptions = { through: { role: 'member' } };
 * ```
 */
export interface BelongsToManyAddAssociationsMixinOptions
  extends
    FindOptions<any>,
    BulkCreateOptions<any>,
    InstanceUpdateOptions<any>,
    InstanceDestroyOptions {
  /** Attributes of the junction row. */
  through?: JoinTableAttributes;
}
 
/**
 * Options of the `addX` accessor of a belongsToMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToManyAddAssociationMixinOptions = { through: { role: 'member' } };
 * ```
 */
export interface BelongsToManyAddAssociationMixinOptions
  extends
    FindOptions<any>,
    BulkCreateOptions<any>,
    InstanceUpdateOptions<any>,
    InstanceDestroyOptions {
  /** Attributes of the junction row. */
  through?: JoinTableAttributes;
}
 
/**
 * Options of the `createX` accessor of a belongsToMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToManyCreateAssociationMixinOptions = { through: { role: 'member' } };
 * ```
 */
export interface BelongsToManyCreateAssociationMixinOptions extends CreateOptions<any> {
  /** Attributes of the junction row. */
  through?: JoinTableAttributes;
}
 
/**
 * Options of the `removeX` accessor of a belongsToMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToManyRemoveAssociationMixinOptions = { transaction };
 * ```
 */
export interface BelongsToManyRemoveAssociationMixinOptions extends InstanceDestroyOptions {}
 
/**
 * Options of the `removeXs` accessor of a belongsToMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToManyRemoveAssociationsMixinOptions = { transaction };
 * ```
 */
export interface BelongsToManyRemoveAssociationsMixinOptions extends InstanceDestroyOptions {}
 
/**
 * Options of the `hasX` accessor of a belongsToMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToManyHasAssociationMixinOptions = { transaction };
 * ```
 */
export interface BelongsToManyHasAssociationMixinOptions extends BelongsToManyGetAssociationsMixinOptions {}
 
/**
 * Options of the `hasXs` accessor of a belongsToMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToManyHasAssociationsMixinOptions = { transaction };
 * ```
 */
export interface BelongsToManyHasAssociationsMixinOptions extends BelongsToManyGetAssociationsMixinOptions {}
 
/**
 * Options of the `countXs` accessor of a belongsToMany association (Sequelize v6).
 *
 * @example
 * ```ts
 * const options: BelongsToManyCountAssociationsMixinOptions = { where: { active: true } };
 * ```
 */
export interface BelongsToManyCountAssociationsMixinOptions extends QueryOptionsBase {
  /** Filter on the counted rows. */
  where?: WhereOptions<any>;
  /** Scope to apply on the associated model, or `false` to remove its default scope. */
  scope?: string | boolean;
}
 
/** Type of the `getX` accessor of a belongsTo association: `declare getClient: BelongsToGetAssociationMixin<Client>;` (Sequelize v6). */
export type BelongsToGetAssociationMixin<TModel> = (
  options?: BelongsToGetAssociationMixinOptions,
) => Promise<TModel>;
 
/** Type of the `setX` accessor of a belongsTo association (Sequelize v6). */
export type BelongsToSetAssociationMixin<TModel, TPrimaryKey> = (
  newAssociation?: TModel | TPrimaryKey,
  options?: BelongsToSetAssociationMixinOptions,
) => Promise<void>;
 
/** Type of the `createX` accessor of a belongsTo association (Sequelize v6). */
export type BelongsToCreateAssociationMixin<TModel extends AnyModel> = (
  values?: CreationAttributes<TModel>,
  options?: BelongsToCreateAssociationMixinOptions,
) => Promise<TModel>;
 
/** Type of the `getX` accessor of a hasOne association (Sequelize v6). */
export type HasOneGetAssociationMixin<TModel> = (
  options?: HasOneGetAssociationMixinOptions,
) => Promise<TModel>;
 
/** Type of the `setX` accessor of a hasOne association (Sequelize v6). */
export type HasOneSetAssociationMixin<TModel, TModelPrimaryKey> = (
  newAssociation?: TModel | TModelPrimaryKey,
  options?: HasOneSetAssociationMixinOptions,
) => Promise<void>;
 
/** Type of the `createX` accessor of a hasOne association (Sequelize v6). */
export type HasOneCreateAssociationMixin<TModel extends AnyModel> = (
  values?: CreationAttributes<TModel>,
  options?: HasOneCreateAssociationMixinOptions,
) => Promise<TModel>;
 
/** Type of the `getXs` accessor of a hasMany association: `declare getFiles: HasManyGetAssociationsMixin<File>;` (Sequelize v6). */
export type HasManyGetAssociationsMixin<TModel> = (
  options?: HasManyGetAssociationsMixinOptions,
) => Promise<TModel[]>;
 
/** Type of the `setXs` accessor of a hasMany association (Sequelize v6). */
export type HasManySetAssociationsMixin<TModel, TModelPrimaryKey> = (
  newAssociations?: (TModel | TModelPrimaryKey)[],
  options?: HasManySetAssociationsMixinOptions,
) => Promise<void>;
 
/** Type of the `addXs` accessor of a hasMany association (Sequelize v6). */
export type HasManyAddAssociationsMixin<TModel, TModelPrimaryKey> = (
  newAssociations?: (TModel | TModelPrimaryKey)[],
  options?: HasManyAddAssociationsMixinOptions,
) => Promise<void>;
 
/** Type of the `addX` accessor of a hasMany association (Sequelize v6). */
export type HasManyAddAssociationMixin<TModel, TModelPrimaryKey> = (
  newAssociation?: TModel | TModelPrimaryKey,
  options?: HasManyAddAssociationMixinOptions,
) => Promise<void>;
 
/** Type of the `createX` accessor of a hasMany association; the foreign key and scope attributes are filled in for you (Sequelize v6). */
export type HasManyCreateAssociationMixin<
  TModel extends AnyModel,
  TForeignKey extends keyof CreationAttributes<TModel> = never,
  TScope extends keyof CreationAttributes<TModel> = never,
> = (
  values?: Omit<CreationAttributes<TModel>, TForeignKey | TScope>,
  options?: HasManyCreateAssociationMixinOptions,
) => Promise<TModel>;
 
/** Type of the `removeX` accessor of a hasMany association (Sequelize v6). */
export type HasManyRemoveAssociationMixin<TModel, TModelPrimaryKey> = (
  oldAssociated?: TModel | TModelPrimaryKey,
  options?: HasManyRemoveAssociationMixinOptions,
) => Promise<void>;
 
/** Type of the `removeXs` accessor of a hasMany association (Sequelize v6). */
export type HasManyRemoveAssociationsMixin<TModel, TModelPrimaryKey> = (
  oldAssociateds?: (TModel | TModelPrimaryKey)[],
  options?: HasManyRemoveAssociationsMixinOptions,
) => Promise<void>;
 
/** Type of the `hasX` accessor of a hasMany association (Sequelize v6). */
export type HasManyHasAssociationMixin<TModel, TModelPrimaryKey> = (
  target: TModel | TModelPrimaryKey,
  options?: HasManyHasAssociationMixinOptions,
) => Promise<boolean>;
 
/** Type of the `hasXs` accessor of a hasMany association (Sequelize v6). */
export type HasManyHasAssociationsMixin<TModel, TModelPrimaryKey> = (
  targets: (TModel | TModelPrimaryKey)[],
  options?: HasManyHasAssociationsMixinOptions,
) => Promise<boolean>;
 
/** Type of the `countXs` accessor of a hasMany association (Sequelize v6). */
export type HasManyCountAssociationsMixin = (
  options?: HasManyCountAssociationsMixinOptions,
) => Promise<number>;
 
/** Type of the `getXs` accessor of a belongsToMany association (Sequelize v6). */
export type BelongsToManyGetAssociationsMixin<TModel> = (
  options?: BelongsToManyGetAssociationsMixinOptions,
) => Promise<TModel[]>;
 
/** Type of the `setXs` accessor of a belongsToMany association (Sequelize v6). */
export type BelongsToManySetAssociationsMixin<TModel, TModelPrimaryKey> = (
  newAssociations?: (TModel | TModelPrimaryKey)[],
  options?: BelongsToManySetAssociationsMixinOptions,
) => Promise<void>;
 
/** Type of the `addXs` accessor of a belongsToMany association (Sequelize v6). */
export type BelongsToManyAddAssociationsMixin<TModel, TModelPrimaryKey> = (
  newAssociations?: (TModel | TModelPrimaryKey)[],
  options?: BelongsToManyAddAssociationsMixinOptions,
) => Promise<void>;
 
/** Type of the `addX` accessor of a belongsToMany association (Sequelize v6). */
export type BelongsToManyAddAssociationMixin<TModel, TModelPrimaryKey> = (
  newAssociation?: TModel | TModelPrimaryKey,
  options?: BelongsToManyAddAssociationMixinOptions,
) => Promise<void>;
 
/** Type of the `createX` accessor of a belongsToMany association (Sequelize v6). */
export type BelongsToManyCreateAssociationMixin<TModel extends AnyModel> = (
  values?: CreationAttributes<TModel>,
  options?: BelongsToManyCreateAssociationMixinOptions,
) => Promise<TModel>;
 
/** Type of the `removeX` accessor of a belongsToMany association (Sequelize v6). */
export type BelongsToManyRemoveAssociationMixin<TModel, TModelPrimaryKey> = (
  oldAssociated?: TModel | TModelPrimaryKey,
  options?: BelongsToManyRemoveAssociationMixinOptions,
) => Promise<void>;
 
/** Type of the `removeXs` accessor of a belongsToMany association (Sequelize v6). */
export type BelongsToManyRemoveAssociationsMixin<TModel, TModelPrimaryKey> = (
  oldAssociateds?: (TModel | TModelPrimaryKey)[],
  options?: BelongsToManyRemoveAssociationsMixinOptions,
) => Promise<void>;
 
/** Type of the `hasX` accessor of a belongsToMany association (Sequelize v6). */
export type BelongsToManyHasAssociationMixin<TModel, TModelPrimaryKey> = (
  target: TModel | TModelPrimaryKey,
  options?: BelongsToManyHasAssociationMixinOptions,
) => Promise<boolean>;
 
/** Type of the `hasXs` accessor of a belongsToMany association (Sequelize v6). */
export type BelongsToManyHasAssociationsMixin<TModel, TModelPrimaryKey> = (
  targets: (TModel | TModelPrimaryKey)[],
  options?: BelongsToManyHasAssociationsMixinOptions,
) => Promise<boolean>;
 
/** Type of the `countXs` accessor of a belongsToMany association (Sequelize v6). */
export type BelongsToManyCountAssociationsMixin = (
  options?: BelongsToManyCountAssociationsMixinOptions,
) => Promise<number>;