|
1 | 1 | import { UmzugStorage } from './contract';
|
2 | 2 | import { SetRequired } from 'type-fest';
|
3 |
| -// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error |
4 |
| -// @ts-ignore (Avoid type errors for non-sequelize users. Can't use ts-expect-error; this _won't_ be an error when sequelize is installed) |
5 |
| -import type { Sequelize as SequelizeType, Model as ModelClass } from 'sequelize'; |
6 | 3 |
|
7 | 4 | interface ModelTempInterface extends ModelClass, Record<string, any> {}
|
8 | 5 |
|
9 |
| -type ModelClassType = typeof ModelClass & (new (values?: object, options?: any) => ModelTempInterface); |
| 6 | +/** |
| 7 | + * Minimal structure of a sequelize model, defined here to avoid a hard dependency. |
| 8 | + * The type expected is `import { Model } from 'sequelize'` |
| 9 | + */ |
| 10 | +export interface ModelClass { |
| 11 | + tableName: string; |
| 12 | + sequelize?: SequelizeType; |
| 13 | + getTableName(): string; |
| 14 | + sync(): Promise<void>; |
| 15 | + findAll(options?: {}): Promise<any[]>; |
| 16 | + create(options: {}): Promise<void>; |
| 17 | + destroy(options: {}): Promise<void>; |
| 18 | +} |
| 19 | + |
| 20 | +/** |
| 21 | + * Minimal structure of a sequelize model, defined here to avoid a hard dependency. |
| 22 | + * The type expected is `import { Sequelize } from 'sequelize'` |
| 23 | + */ |
| 24 | +export interface SequelizeType { |
| 25 | + getQueryInterface(): any; |
| 26 | + isDefined(modelName: string): boolean; |
| 27 | + model(modelName: string): any; |
| 28 | + define(modelName: string, columns: {}, options: {}): {}; |
| 29 | +} |
| 30 | + |
| 31 | +type ModelClassType = ModelClass & (new (values?: object, options?: any) => ModelTempInterface); |
10 | 32 |
|
11 | 33 | interface _SequelizeStorageConstructorOptions {
|
12 | 34 | /**
|
|
0 commit comments