@league-of-foundry-developers/foundry-vtt-types 13.346.0-beta.20250823115730 → 13.346.0-beta.20250825015921
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/configuration/configuration.d.mts +1 -3
- package/src/configuration/globals.d.mts +1 -1
- package/src/foundry/client/_types.d.mts +2 -2
- package/src/foundry/client/applications/ui/scene-controls.d.mts +52 -2
- package/src/foundry/client/canvas/containers/elements/door-mesh.d.mts +3 -2
- package/src/foundry/client/canvas/interaction/render-flags.d.mts +11 -8
- package/src/foundry/client/canvas/perception/vision-mode.d.mts +10 -65
- package/src/foundry/client/canvas/primary/primary-graphics.d.mts +1 -8
- package/src/foundry/client/canvas/rendering/filters/_module.d.mts +1 -0
- package/src/foundry/client/canvas/rendering/shaders/base-shader.d.mts +7 -0
- package/src/foundry/client/client.d.mts +24 -0
- package/src/foundry/client/data/_module.d.mts +4 -2
- package/src/foundry/client/data/_types.d.mts +11 -0
- package/src/foundry/client/data/fields.d.mts +72 -0
- package/src/foundry/client/documents/abstract/canvas-document.d.mts +1 -1
- package/src/foundry/client/documents/abstract/client-document.d.mts +31 -6
- package/src/foundry/client/documents/actor.d.mts +3 -2
- package/src/foundry/client/documents/collections/compendium-collection.d.mts +111 -50
- package/src/foundry/client/documents/token.d.mts +6 -0
- package/src/foundry/client/helpers/localization.d.mts +2 -37
- package/src/foundry/client/packages/system.d.mts +5 -5
- package/src/foundry/client/utils/_module.d.mts +6 -5
- package/src/foundry/common/abstract/data.d.mts +87 -3
- package/src/foundry/common/abstract/embedded-collection.d.mts +5 -4
- package/src/foundry/common/abstract/type-data.d.mts +53 -11
- package/src/foundry/common/data/fields.d.mts +16 -2
- package/src/foundry/common/packages/_module.d.mts +2 -2
- package/src/foundry/common/packages/base-package.d.mts +12 -3
- package/src/foundry/common/packages/sub-types.d.mts +6 -3
@@ -1,15 +1,17 @@
|
|
1
1
|
import type { DeepPartial, EmptyObject, InexactPartial, PrettifyType, SimpleMerge, UnionToIntersection } from "#utils";
|
2
|
+
import type { fields } from "#client/data/_module.d.mts";
|
2
3
|
import type Document from "#common/abstract/document.d.mts";
|
3
|
-
|
4
|
-
import
|
5
|
-
import Game
|
6
|
-
import type
|
4
|
+
import type { ApplicationV2, DialogV2 } from "#client/applications/api/_module.d.mts";
|
5
|
+
import type { Application } from "#client/appv1/api/_module.d.mts";
|
6
|
+
import type { Game } from "#client/_module.d.mts";
|
7
|
+
import type { SocketInterface } from "#client/helpers/_module.d.mts";
|
8
|
+
import type { BasePackage } from "#common/packages/_module.d.mts";
|
7
9
|
|
8
10
|
/**
|
9
11
|
* A collection of Document objects contained within a specific compendium pack.
|
10
12
|
* Each Compendium pack has its own associated instance of the CompendiumCollection class which contains its contents.
|
11
13
|
*
|
12
|
-
* @see {@
|
14
|
+
* @see {@linkcode Game.packs | Game#packs}
|
13
15
|
*/
|
14
16
|
declare class CompendiumCollection<
|
15
17
|
Type extends CompendiumCollection.DocumentName,
|
@@ -38,6 +40,11 @@ declare class CompendiumCollection<
|
|
38
40
|
*/
|
39
41
|
static CONFIG_SETTING: "compendiumConfiguration";
|
40
42
|
|
43
|
+
/**
|
44
|
+
* The DataField definition for the configuration Setting
|
45
|
+
*/
|
46
|
+
static CONFIG_FIELD: CompendiumCollection.SettingField;
|
47
|
+
|
41
48
|
/** The canonical Compendium name - comprised of the originating package and the pack name */
|
42
49
|
get collection(): this["metadata"]["id"];
|
43
50
|
|
@@ -48,9 +55,7 @@ declare class CompendiumCollection<
|
|
48
55
|
* A reference to the Application class which provides an interface to interact with this compendium content.
|
49
56
|
* @defaultValue `Compendium`
|
50
57
|
*/
|
51
|
-
applicationClass:
|
52
|
-
| foundry.appv1.api.Application.AnyConstructor
|
53
|
-
| foundry.applications.api.ApplicationV2.AnyConstructor;
|
58
|
+
applicationClass: Application.AnyConstructor | ApplicationV2.AnyConstructor;
|
54
59
|
|
55
60
|
/**
|
56
61
|
* A subsidiary collection which contains the folders within the pack
|
@@ -59,7 +64,7 @@ declare class CompendiumCollection<
|
|
59
64
|
|
60
65
|
/**
|
61
66
|
* @remarks 1 less than in-world
|
62
|
-
* @defaultValue
|
67
|
+
* @defaultValue {@linkcode CONST.FOLDER_MAX_DEPTH}`- 1`
|
63
68
|
*/
|
64
69
|
get maxFolderDepth(): number;
|
65
70
|
|
@@ -83,7 +88,7 @@ declare class CompendiumCollection<
|
|
83
88
|
// Note(LukeAbby): The override for `_getVisibleTreeContents` become unreasonably long and don't add any changes and so has been omitted.
|
84
89
|
|
85
90
|
/** Access the compendium configuration data for this pack */
|
86
|
-
get config(): CompendiumCollection.
|
91
|
+
get config(): CompendiumCollection.StoredConfiguration | EmptyObject;
|
87
92
|
|
88
93
|
get documentName(): Type;
|
89
94
|
|
@@ -93,7 +98,7 @@ declare class CompendiumCollection<
|
|
93
98
|
/**
|
94
99
|
* The visibility configuration of this compendium pack.
|
95
100
|
*/
|
96
|
-
get ownership():
|
101
|
+
get ownership(): BasePackage.OwnershipRecord;
|
97
102
|
|
98
103
|
/** Is this Compendium pack visible to the current game User? */
|
99
104
|
get visible(): boolean;
|
@@ -139,21 +144,23 @@ declare class CompendiumCollection<
|
|
139
144
|
|
140
145
|
/**
|
141
146
|
* Load multiple documents from the Compendium pack using a provided query object.
|
142
|
-
* @param query - A database query used to retrieve documents from the underlying database
|
143
|
-
* default: `{}`
|
147
|
+
* @param query - A database query used to retrieve documents from the underlying database (default: `{}`)
|
144
148
|
* @returns The retrieved Document instances
|
145
149
|
*
|
146
|
-
* @example
|
150
|
+
* @example
|
151
|
+
* Get Documents that match the given value only.
|
147
152
|
* ```js
|
148
153
|
* await pack.getDocuments({ type: "weapon" });
|
149
154
|
* ```
|
150
155
|
*
|
151
|
-
* @example
|
156
|
+
* @example
|
157
|
+
* Get several Documents by their IDs.
|
152
158
|
* ```js
|
153
159
|
* await pack.getDocuments({ _id__in: arrayOfIds });
|
154
160
|
* ```
|
155
161
|
*
|
156
|
-
* @example
|
162
|
+
* @example
|
163
|
+
* Get Documents by their sub-types.
|
157
164
|
* ```js
|
158
165
|
* await pack.getDocuments({ type__in: ["weapon", "armor"] });
|
159
166
|
* ```
|
@@ -163,15 +170,14 @@ declare class CompendiumCollection<
|
|
163
170
|
/**
|
164
171
|
* Get the ownership level that a User has for this Compendium pack.
|
165
172
|
* @param user - The user being tested (default: `game.user`)
|
166
|
-
* @returns The ownership level in {@
|
173
|
+
* @returns The ownership level in {@linkcode CONST.DOCUMENT_OWNERSHIP_LEVELS}
|
167
174
|
*/
|
168
|
-
// user: not null (parameter default only)
|
169
175
|
getUserLevel(user?: User.Implementation): CONST.DOCUMENT_OWNERSHIP_LEVELS;
|
170
176
|
|
171
177
|
/**
|
172
178
|
* Test whether a certain User has a requested permission level (or greater) over the Compendium pack
|
173
179
|
* @param user - The User being tested
|
174
|
-
* @param permission - The permission level from DOCUMENT_OWNERSHIP_LEVELS to test
|
180
|
+
* @param permission - The permission level from {@linkcode CONST.DOCUMENT_OWNERSHIP_LEVELS} to test
|
175
181
|
* @param options - Additional options involved in the permission test
|
176
182
|
* @returns Does the user have this permission level over the Compendium pack?
|
177
183
|
*/
|
@@ -184,8 +190,7 @@ declare class CompendiumCollection<
|
|
184
190
|
/**
|
185
191
|
* Import a Document into this Compendium Collection.
|
186
192
|
* @param document - The existing Document you wish to import
|
187
|
-
* @param options - Additional options which modify how the data is imported. See {@
|
188
|
-
* (default: `{}`)
|
193
|
+
* @param options - Additional options which modify how the data is imported. See {@linkcode foundry.documents.abstract.ClientDocumentMixin.AnyMixed.toCompendium | ClientDocument#toCompendium} (default: `{}`)
|
189
194
|
* @returns The imported Document instance
|
190
195
|
*/
|
191
196
|
importDocument(
|
@@ -209,32 +214,29 @@ declare class CompendiumCollection<
|
|
209
214
|
|
210
215
|
/**
|
211
216
|
* Fully import the contents of a Compendium pack into a World folder.
|
212
|
-
* @param options - Options which modify the import operation. Additional options are forwarded to {@
|
217
|
+
* @param options - Options which modify the import operation. Additional options are forwarded to {@linkcode WorldCollection.fromCompendium | WorldCollection#fromCompendium} and {@linkcode Document.createDocuments} (default: `{}`)
|
213
218
|
* @returns The imported Documents, now existing within the World
|
214
219
|
*/
|
215
220
|
importAll(options?: CompendiumCollection.ImportAllOptions<Type>): Promise<Document.StoredForName<Type>[]>;
|
216
221
|
|
217
222
|
/**
|
218
223
|
* Provide a dialog form that prompts the user to import the full contents of a Compendium pack into the World.
|
219
|
-
* @param options - Additional options passed to the DialogV2.confirm method
|
220
|
-
*
|
221
|
-
*
|
222
|
-
* Documents if the "yes" button was pressed, false if the "no" button was pressed, or
|
223
|
-
* null if the dialog was closed without making a choice.
|
224
|
+
* @param options - Additional options passed to the DialogV2.confirm method (default: `{}`)
|
225
|
+
* @returns A promise which resolves in the following ways: an array of imported Documents if the "yes" button was pressed,
|
226
|
+
* false if the "no" button was pressed, or null if the dialog was closed without making a choice.
|
224
227
|
*/
|
225
|
-
importDialog(
|
226
|
-
options?: foundry.applications.api.DialogV2.ConfirmConfig,
|
227
|
-
): Promise<Document.StoredForName<Type>[] | null | false>;
|
228
|
+
importDialog(options?: DialogV2.ConfirmConfig): Promise<Document.StoredForName<Type>[] | null | false>;
|
228
229
|
|
229
230
|
/**
|
230
231
|
* Add a Document to the index, capturing it's relevant index attributes
|
231
|
-
* @param document -The document to index
|
232
|
+
* @param document - The document to index
|
232
233
|
*/
|
233
234
|
indexDocument(document: Document.StoredForName<Type>): void;
|
234
235
|
|
235
236
|
/**
|
236
237
|
* Prompt the gamemaster with a dialog to configure ownership of this Compendium pack.
|
237
238
|
* @returns The configured ownership for the pack
|
239
|
+
* @remarks As of 13.347, any choices made here will not be saved (see {@link https://github.com/foundryvtt/foundryvtt/issues/13283}).
|
238
240
|
*/
|
239
241
|
configureOwnershipDialog(): Promise<foundry.packages.BasePackage.OwnershipRecord>;
|
240
242
|
|
@@ -248,8 +250,7 @@ declare class CompendiumCollection<
|
|
248
250
|
/**
|
249
251
|
* Create a new Compendium Collection using provided metadata.
|
250
252
|
* @param metadata - The compendium metadata used to create the new pack
|
251
|
-
* @param options
|
252
|
-
* (default: `{}`)
|
253
|
+
* @param options - Additional options which modify the Compendium creation request (default: `{}`)
|
253
254
|
*/
|
254
255
|
static createCompendium<T extends CompendiumCollection.DocumentName>(
|
255
256
|
this: abstract new (...args: never) => CompendiumCollection<NoInfer<T>>,
|
@@ -266,13 +267,13 @@ declare class CompendiumCollection<
|
|
266
267
|
|
267
268
|
/**
|
268
269
|
* Assign configuration metadata settings to the compendium pack
|
269
|
-
* @param configuration - The object of compendium settings to define
|
270
|
-
* (default: `{}`)
|
270
|
+
* @param configuration - The object of compendium settings to define (default: `{}`)
|
271
271
|
* @returns A Promise which resolves once the setting is updated
|
272
272
|
*/
|
273
|
-
configure(
|
274
|
-
|
275
|
-
|
273
|
+
configure(configuration?: CompendiumCollection.Configuration): Promise<void>;
|
274
|
+
|
275
|
+
/** @deprecated The `ownership` key is currently non-functional, see {@link https://github.com/foundryvtt/foundryvtt/issues/13283} */
|
276
|
+
configure(configuration: CompendiumCollection.ConfigurationBroken): Promise<void>;
|
276
277
|
|
277
278
|
/**
|
278
279
|
* Delete an existing world-level Compendium Collection.
|
@@ -291,7 +292,7 @@ declare class CompendiumCollection<
|
|
291
292
|
* This operation re-saves all documents within the compendium pack to disk, applying the current data model.
|
292
293
|
* If the document type has system data, the latest system data template will also be applied to all documents.
|
293
294
|
*/
|
294
|
-
migrate(): Promise<this>;
|
295
|
+
migrate(options?: CompendiumCollection.MigrateOptions): Promise<this>;
|
295
296
|
|
296
297
|
// Note(LukeAbby): The override for `updateAll` and `_onModifyContents` become unreasonably long and don't add any changes and so has been omitted.
|
297
298
|
|
@@ -299,20 +300,71 @@ declare class CompendiumCollection<
|
|
299
300
|
|
300
301
|
/**
|
301
302
|
* Handle changes to the world compendium configuration setting.
|
303
|
+
* @remarks As the setting's {@linkcode foundry.helpers.ClientSettings.SettingConfig.onChange | onChange} function, this gets passed the new value after
|
304
|
+
* it's been cleaned and validated by the field in `ClientSettings##cleanJSON`
|
302
305
|
*/
|
303
|
-
protected static _onConfigure(config: CompendiumCollection.
|
306
|
+
protected static _onConfigure(config: CompendiumCollection.StoredConfiguration): void;
|
307
|
+
|
308
|
+
#CompendiumCollection: true;
|
304
309
|
}
|
305
310
|
|
306
311
|
declare namespace CompendiumCollection {
|
307
312
|
interface Any extends CompendiumCollection<DocumentName> {}
|
308
313
|
|
309
|
-
type DocumentName =
|
314
|
+
type DocumentName = CONST.COMPENDIUM_DOCUMENT_TYPES;
|
310
315
|
|
311
|
-
interface
|
312
|
-
|
313
|
-
|
316
|
+
interface ConfigSettingElementSchema extends fields.DataSchema {
|
317
|
+
/**
|
318
|
+
* @defaultValue `undefined`
|
319
|
+
* @remarks The `id` of the folder this is in in the {@linkcode foundry.applications.sidebar.apps.Compendium | Compendium directory}.
|
320
|
+
* `undefined` and `null` should behave
|
321
|
+
*/
|
322
|
+
folder: fields.StringField<{
|
323
|
+
required: false;
|
324
|
+
blank: false;
|
325
|
+
nullable: true;
|
326
|
+
validate: (value: unknown) => boolean;
|
327
|
+
}>;
|
328
|
+
|
329
|
+
/** @remarks Integer sort value, for if this pack is either not in a folder, or is in one set to manual sort */
|
330
|
+
sort: fields.NumberField<{
|
331
|
+
required: false;
|
332
|
+
nullable: false;
|
333
|
+
integer: true;
|
334
|
+
min: 0;
|
335
|
+
initial: undefined;
|
336
|
+
}>;
|
337
|
+
|
338
|
+
/** @remarks Is the compendium edit lock engaged? */
|
339
|
+
locked: fields.BooleanField<{ required: false; initial: undefined }>;
|
340
|
+
|
341
|
+
// Presumably the resolution to https://github.com/foundryvtt/foundryvtt/issues/13283 will be a CompendiumOwnershipField here
|
314
342
|
}
|
315
343
|
|
344
|
+
interface StoredConfiguration extends fields.SchemaField.InitializedData<ConfigSettingElementSchema> {}
|
345
|
+
|
346
|
+
/** @remarks The partial'd interface for passing to {@linkcode CompendiumCollection.configure}, if you want the stored interface see {@linkcode CompendiumCollection.StoredConfiguration} */
|
347
|
+
interface Configuration extends InexactPartial<StoredConfiguration> {}
|
348
|
+
|
349
|
+
/** @internal */
|
350
|
+
type _Ownership = InexactPartial<{
|
351
|
+
/**
|
352
|
+
* @deprecated As of 13.347, an implementation change has rendered this key (presumably temporarily) non-functional
|
353
|
+
* (see {@link https://github.com/foundryvtt/foundryvtt/issues/13283}).
|
354
|
+
*/
|
355
|
+
ownership: foundry.packages.BasePackage.OwnershipRecord;
|
356
|
+
}>;
|
357
|
+
|
358
|
+
/** @privateRemarks See {@linkcode _Ownership.ownership} */
|
359
|
+
interface ConfigurationBroken extends Configuration, _Ownership {}
|
360
|
+
|
361
|
+
type SettingFieldElement = fields.SchemaField<ConfigSettingElementSchema>;
|
362
|
+
|
363
|
+
type SettingField = fields.TypedObjectField<SettingFieldElement>;
|
364
|
+
|
365
|
+
interface SettingData
|
366
|
+
extends fields.TypedObjectField.InitializedType<SettingFieldElement, fields.TypedObjectField.DefaultOptions> {}
|
367
|
+
|
316
368
|
// The type that's passed to `createCompendium`.
|
317
369
|
interface CreateCompendiumMetadata<Type extends DocumentName> {
|
318
370
|
type: Type;
|
@@ -442,13 +494,22 @@ declare namespace CompendiumCollection {
|
|
442
494
|
label?: string | undefined;
|
443
495
|
}
|
444
496
|
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
497
|
+
/** @deprecated Use {@linkcode CompendiumCollection.StoredConfiguration} instead. */
|
498
|
+
type WorldCompendiumPackConfiguration = CompendiumCollection.StoredConfiguration;
|
499
|
+
|
500
|
+
/** @deprecated Use {@linkcode CompendiumCollection.SettingData} instead. */
|
501
|
+
type WorldCompendiumConfiguration = CompendiumCollection.SettingData;
|
502
|
+
|
503
|
+
/** @internal */
|
504
|
+
type _MigrateOptions = InexactPartial<{
|
505
|
+
/**
|
506
|
+
* Display notifications
|
507
|
+
* @defaultValue `true`
|
508
|
+
*/
|
509
|
+
notify: boolean;
|
510
|
+
}>;
|
450
511
|
|
451
|
-
interface
|
512
|
+
interface MigrateOptions extends _MigrateOptions {}
|
452
513
|
|
453
514
|
// Note(LukeAbby): One neat possibility for this type would be making something like `type: "foo"`,
|
454
515
|
// `type__ne: "foo"`, and `type__in: ["foo", "bar"]` all narrow `system`.
|
@@ -1650,6 +1650,12 @@ declare class TokenDocument extends BaseToken.Internal.CanvasDocument {
|
|
1650
1650
|
*/
|
1651
1651
|
stopMovement(): boolean;
|
1652
1652
|
|
1653
|
+
/**
|
1654
|
+
* This function is called on Token documents that are still being moved by a User that just disconnected.
|
1655
|
+
* @internal
|
1656
|
+
*/
|
1657
|
+
_stopMovementOnDisconnect(): void;
|
1658
|
+
|
1653
1659
|
/**
|
1654
1660
|
* Pause the movement of this Token document. The movement can be resumed after being paused.
|
1655
1661
|
* Only the User that initiated the movement can pause it.
|
@@ -46,43 +46,8 @@ declare class Localization {
|
|
46
46
|
* @param model - The DataModel class to localize
|
47
47
|
* @param options - Options which configure how localization is performed
|
48
48
|
*
|
49
|
-
* @example
|
50
|
-
*
|
51
|
-
* ```js
|
52
|
-
* class MyDataModel extends foundry.abstract.DataModel {
|
53
|
-
* static defineSchema() {
|
54
|
-
* return {
|
55
|
-
* foo: new foundry.data.fields.StringField(),
|
56
|
-
* bar: new foundry.data.fields.NumberField()
|
57
|
-
* };
|
58
|
-
* }
|
59
|
-
* static LOCALIZATION_PREFIXES = ["MYMODULE.MYDATAMODEL"];
|
60
|
-
* }
|
61
|
-
*
|
62
|
-
* Hooks.on("i18nInit", () => {
|
63
|
-
* Localization.localizeDataModel(MyDataModel);
|
64
|
-
* });
|
65
|
-
* ```
|
66
|
-
*
|
67
|
-
* JSON localization file
|
68
|
-
* ```json
|
69
|
-
* {
|
70
|
-
* "MYMODULE": {
|
71
|
-
* "MYDATAMODEL": {
|
72
|
-
* "FIELDS" : {
|
73
|
-
* "foo": {
|
74
|
-
* "label": "Foo",
|
75
|
-
* "hint": "Instructions for foo"
|
76
|
-
* },
|
77
|
-
* "bar": {
|
78
|
-
* "label": "Bar",
|
79
|
-
* "hint": "Instructions for bar"
|
80
|
-
* }
|
81
|
-
* }
|
82
|
-
* }
|
83
|
-
* }
|
84
|
-
* }
|
85
|
-
* ```
|
49
|
+
* @see {@linkcode foundry.abstract.DataModel.LOCALIZATION_PREFIXES} for an example of the class definition and
|
50
|
+
* localization file structure.
|
86
51
|
*/
|
87
52
|
static localizeDataModel(
|
88
53
|
model: foundry.abstract.DataModel.AnyConstructor,
|
@@ -94,17 +94,17 @@ declare namespace System {
|
|
94
94
|
initiative: fields.StringField;
|
95
95
|
|
96
96
|
/**
|
97
|
-
* The default grid settings to use for Scenes in this system
|
97
|
+
* The default grid settings to use for Scenes in this system.
|
98
98
|
*/
|
99
99
|
grid: fields.SchemaField<{
|
100
|
-
/** A default grid type to use for Scenes in this system */
|
100
|
+
/** A default grid type to use for Scenes in this system. */
|
101
101
|
type: fields.NumberField<{
|
102
102
|
required: true;
|
103
103
|
choices: typeof foundry.CONST.GRID_TYPES;
|
104
104
|
initial: typeof foundry.CONST.GRID_TYPES.SQUARE;
|
105
105
|
}>;
|
106
106
|
|
107
|
-
/** A default distance measurement to use for Scenes in this system */
|
107
|
+
/** A default distance measurement to use for Scenes in this system. */
|
108
108
|
distance: fields.NumberField<{
|
109
109
|
required: true;
|
110
110
|
nullable: false;
|
@@ -112,12 +112,12 @@ declare namespace System {
|
|
112
112
|
initial: 1;
|
113
113
|
}>;
|
114
114
|
|
115
|
-
/** A default unit of measure to use for distance measurement in this system */
|
115
|
+
/** A default unit of measure to use for distance measurement in this system. */
|
116
116
|
units: fields.StringField<{
|
117
117
|
required: true;
|
118
118
|
}>;
|
119
119
|
|
120
|
-
/** The default rule used by this system for diagonal measurement on square grids */
|
120
|
+
/** The default rule used by this system for diagonal measurement on square grids. */
|
121
121
|
diagonals: fields.NumberField<{
|
122
122
|
required: true;
|
123
123
|
choices: typeof foundry.CONST.GRID_DIAGONALS;
|
@@ -3,7 +3,7 @@
|
|
3
3
|
// While `.mts` could work, to avoid `import-x/no-unresolved` from erroring `.mjs` is used.
|
4
4
|
/* eslint-disable import-x/extensions */
|
5
5
|
|
6
|
-
import type {
|
6
|
+
import type { performIntegerSort } from "./helpers.mjs";
|
7
7
|
|
8
8
|
// eslint-disable-next-line import-x/export
|
9
9
|
export * from "./_types.mjs";
|
@@ -15,11 +15,12 @@ export * from "./helpers.mjs";
|
|
15
15
|
* @remarks With the move to ESM, foundry no longer appears to need/want classes that only exist to host static functions in a namespace
|
16
16
|
*/
|
17
17
|
declare const SortingHelpers: {
|
18
|
+
/**
|
19
|
+
* Given a source object to sort, a target to sort relative to, and an Array of siblings in the container.
|
20
|
+
* @deprecated "`foundry.utils.SortingHelpers.performIntegerSort` has been deprecated. Access this helper at {@linkcode foundry.utils.performIntegerSort} instead." (since v13, until v15)
|
21
|
+
* @ignore
|
22
|
+
*/
|
18
23
|
performIntegerSort: typeof performIntegerSort;
|
19
24
|
};
|
20
25
|
|
21
|
-
declare namespace SortingHelpers {
|
22
|
-
interface SortOptions<T, SortKey extends string = "sort"> extends OriginalSortOptions<T, SortKey> {}
|
23
|
-
}
|
24
|
-
|
25
26
|
export { SortingHelpers };
|
@@ -17,7 +17,17 @@ declare class _InternalDataModel<
|
|
17
17
|
export default DataModel;
|
18
18
|
|
19
19
|
/**
|
20
|
-
*
|
20
|
+
* An abstract class which is a fundamental building block of numerous structures and concepts in Foundry Virtual
|
21
|
+
* Tabletop. Data models perform several essential roles:
|
22
|
+
*
|
23
|
+
* - A static schema definition that all instances of that model adhere to.
|
24
|
+
* - A workflow for data migration, cleaning, validation, and initialization such that provided input data is structured
|
25
|
+
* according to the rules of the model's declared schema.
|
26
|
+
* - A workflow for transacting differential updates to the instance data and serializing its data into format suitable
|
27
|
+
* for storage or transport.
|
28
|
+
*
|
29
|
+
* DataModel subclasses can be used for a wide variety of purposes ranging from simple game settings to high complexity
|
30
|
+
* objects like `Scene` documents. Data models are often nested; see the {@linkcode DataModel.parent} property for more.
|
21
31
|
*/
|
22
32
|
declare abstract class DataModel<
|
23
33
|
Schema extends DataSchema,
|
@@ -69,8 +79,40 @@ declare abstract class DataModel<
|
|
69
79
|
readonly parent: Parent;
|
70
80
|
|
71
81
|
/**
|
72
|
-
* Define the data schema for
|
82
|
+
* Define the data schema for models of this type.
|
73
83
|
* The schema is populated the first time it is accessed and cached for future reuse.
|
84
|
+
*
|
85
|
+
* The schema, through its fields, provide the essential cleaning, validation, and initialization methods to turn the
|
86
|
+
* {@linkcode _source} values into direct properties of the data model. The schema is a static property of the model and
|
87
|
+
* is reused by all instances to perform validation.
|
88
|
+
*
|
89
|
+
* The schemas defined by the core software in classes like {@linkcode foundry.documents.BaseActor} are validated by the
|
90
|
+
* server, where user code does not run. However, almost all documents have a `flags` field to store data, and many
|
91
|
+
* have a `system` field that can be configured to be a {@linkcode foundry.abstract.TypeDataModel} instance. Those models
|
92
|
+
* are *not* constructed on the server and rely purely on client-side code, which means certain extra-sensitive fields
|
93
|
+
* must be also be registered through your package manifest. {@linkcode foundry.packages.AdditionalTypesField.ServerSanitizationFields | ServerSanitizationFields}
|
94
|
+
*
|
95
|
+
* @example
|
96
|
+
* ```js
|
97
|
+
* class SomeModel extends foundry.abstract.DataModel {
|
98
|
+
* static defineSchema() {
|
99
|
+
* return {
|
100
|
+
* foo: new foundry.data.fields.StringField()
|
101
|
+
* }
|
102
|
+
* }
|
103
|
+
* }
|
104
|
+
*
|
105
|
+
* class AnotherModel extends SomeModel {
|
106
|
+
* static defineSchema() {
|
107
|
+
* // Inheritance and object oriented principles apply to schema definition
|
108
|
+
* const schema = super.defineSchema()
|
109
|
+
*
|
110
|
+
* schema.bar = new foundry.data.fields.NumberField()
|
111
|
+
*
|
112
|
+
* return schema;
|
113
|
+
* }
|
114
|
+
* }
|
115
|
+
* ```
|
74
116
|
* @remarks The returned value MUST be kept up to sync with the `Schema` type parameter.
|
75
117
|
*/
|
76
118
|
static defineSchema(): DataSchema;
|
@@ -100,7 +142,49 @@ declare abstract class DataModel<
|
|
100
142
|
#validationFailures: { fields: DataModelValidationFailure | null; joint: DataModelValidationFailure | null };
|
101
143
|
|
102
144
|
/**
|
103
|
-
* A set of localization prefix paths which are used by this DataModel.
|
145
|
+
* A set of localization prefix paths which are used by this DataModel. This provides an alternative to defining the
|
146
|
+
* `label` and `hint` property of each field by having foundry map the labels to a structure inside the path
|
147
|
+
* provided by the prefix.
|
148
|
+
*
|
149
|
+
* @example
|
150
|
+
* JavaScript class definition and localization call.
|
151
|
+
* ```js
|
152
|
+
* class MyDataModel extends foundry.abstract.DataModel {
|
153
|
+
* static defineSchema() {
|
154
|
+
* return {
|
155
|
+
* foo: new foundry.data.fields.StringField(),
|
156
|
+
* bar: new foundry.data.fields.NumberField()
|
157
|
+
* };
|
158
|
+
* }
|
159
|
+
* static LOCALIZATION_PREFIXES = ["MYMODULE.MYDATAMODEL"];
|
160
|
+
* }
|
161
|
+
*
|
162
|
+
* Hooks.on("i18nInit", () => {
|
163
|
+
* // Foundry will attempt to automatically localize models registered for a document subtype, so this step is only
|
164
|
+
* // needed for other data model usage, e.g. for a Setting.
|
165
|
+
* Localization.localizeDataModel(MyDataModel);
|
166
|
+
* });
|
167
|
+
* ```
|
168
|
+
*
|
169
|
+
* JSON localization file
|
170
|
+
* ```json
|
171
|
+
* {
|
172
|
+
* "MYMODULE": {
|
173
|
+
* "MYDATAMODEL": {
|
174
|
+
* "FIELDS" : {
|
175
|
+
* "foo": {
|
176
|
+
* "label": "Foo",
|
177
|
+
* "hint": "Instructions for foo"
|
178
|
+
* },
|
179
|
+
* "bar": {
|
180
|
+
* "label": "Bar",
|
181
|
+
* "hint": "Instructions for bar"
|
182
|
+
* }
|
183
|
+
* }
|
184
|
+
* }
|
185
|
+
* }
|
186
|
+
* }
|
187
|
+
* ```
|
104
188
|
*/
|
105
189
|
static LOCALIZATION_PREFIXES: string[];
|
106
190
|
|
@@ -107,7 +107,7 @@ declare class EmbeddedCollection<
|
|
107
107
|
): void;
|
108
108
|
|
109
109
|
/**
|
110
|
-
* Get
|
110
|
+
* Get a document from the EmbeddedCollection by its ID.
|
111
111
|
* @param id - The ID of the Embedded Document to retrieve.
|
112
112
|
* @param options - Additional options to configure retrieval.
|
113
113
|
*/
|
@@ -129,21 +129,21 @@ declare class EmbeddedCollection<
|
|
129
129
|
): ContainedDocument | undefined;
|
130
130
|
|
131
131
|
/**
|
132
|
-
* Get
|
132
|
+
* Get a document from the EmbeddedCollection by its ID.
|
133
133
|
* @param id - The ID of the Embedded Document to retrieve.
|
134
134
|
* @param options - Additional options to configure retrieval.
|
135
135
|
*/
|
136
136
|
get(id: string, options: { strict: true; invalid?: false }): ContainedDocument;
|
137
137
|
|
138
138
|
/**
|
139
|
-
* Get
|
139
|
+
* Get a document from the EmbeddedCollection by its ID.
|
140
140
|
* @param id - The ID of the Embedded Document to retrieve.
|
141
141
|
* @param options - Additional options to configure retrieval.
|
142
142
|
*/
|
143
143
|
get(id: string, options: { strict?: boolean; invalid: true }): unknown;
|
144
144
|
|
145
145
|
/**
|
146
|
-
* Add
|
146
|
+
* Add a document to the collection
|
147
147
|
* @param key - The embedded Document ID
|
148
148
|
* @param value - The embedded Document instance
|
149
149
|
* @param options - Additional options to the set operation
|
@@ -168,6 +168,7 @@ declare class EmbeddedCollection<
|
|
168
168
|
protected _set(key: string, value: ContainedDocument): void;
|
169
169
|
|
170
170
|
/**
|
171
|
+
* Remove a document from the collection.
|
171
172
|
* @param key - The embedded Document ID.
|
172
173
|
* @param options - Additional options to the delete operation.
|
173
174
|
*/
|