-
Notifications
You must be signed in to change notification settings - Fork 11
/
Migration.d.ts
75 lines (66 loc) · 2.62 KB
/
Migration.d.ts
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
import { ABFItemBaseDataSource } from '../../../animabf.types';
import { TokenData } from '../../../types/foundry-vtt-types/src/foundry/common/data/module.mjs';
import { ABFActor } from '../../actor/ABFActor';
import ABFItem from '../../items/ABFItem';
import { ABFActorDataSourceData } from '../../types/Actor';
/**
* This is the base class for a migration, coppied and modified from pf2e system.
* If you make a change to the database schema (i.e. anything in template.json),
* you probably should create a migration. To do so, there are several steps:
* - Make a class that inherits this base class and implements `updateActor` or `updateItem` using a
* new value for the version
* - Add this class to getAllMigrations() in src/module/migrations/index.js
* - Test that your changes work.
*/
export interface Migration {
/**
* This is the migration version.
*/
readonly version: number;
/**
* This is a short title describing the purpose of the migration.
* The title is displayed on the warning dialog before applying the migration.
*/
readonly title: string;
/**
* This is a longer description of the changes in the migration, supposed to be detailed but concise.
* To be displayed on the warning dialog before applying the migration.
*/
readonly description: string;
/**
* Update the actor to the latest schema version.
* @param actor - The actor to migrate
* @returns The actor after the changes in the migration.
*/
updateActor?(actor: ABFActor): ABFActor | Promise<ABFActor>;
/**
* Update the item to the latest schema version.
* @param item - Item to update.
* @returns The item after the changes in the migration
*/
updateItem?(item: ABFItem): ABFItem | Promise<ABFItem>;
/**
* Update the token to the latest schema version.
* @param tokenData Token data to update. This should be a `TokenData` from the previous version.
* @returns The updated version of `TokenData`.
*/
updateToken?(
tokenData: TokenData,
actor: Readonly<ABFActor | null>,
scene: Readonly<Scene | null>
): TokenData;
/**
* Run migrations for this schema version.
* Sometimes there needs to be custom steps run during a migration. For instance, if the change
* isn't actor or item related. This function will be called during the migration.
*/
migrate?(): void;
/**
* Filter determining which items should be migrated. The filter is used inside Array.filter(...)
*/
filterItems?(item: ABFItem): boolean;
/**
* Filter determining which actors should be migrated. The filter is used inside Array.filter(...)
*/
filterActors?(actor: ABFActor): boolean;
}