-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.ts
83 lines (71 loc) · 1.82 KB
/
resources.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
76
77
78
79
80
81
82
83
import type { StringTableLocale } from "@s4tk/models/enums";
import type { Resource, ResourceKey } from "@s4tk/models/types";
import { DiagnosticInfo } from "./diagnostics";
//#region Private Types
interface _ValidatedResourceBase {
readonly id: number;
schema: ValidationSchema;
key: ResourceKey;
resource: Resource;
modelLoaded: boolean;
diagnostics: DiagnosticInfo[];
isDeleted?: boolean;
}
//#endregion
//#region Public Types
/**
* Types of schemas used to validate resources.
*/
export enum ValidationSchema {
Unspecified,
Tuning,
SimData,
StringTable,
}
/**
* A resource validated with an unspecified schema.
*/
export interface ValidatedUnspecified extends _ValidatedResourceBase {
schema: ValidationSchema.Unspecified;
}
/**
* A resource validated with the `Tuning` schema.
*/
export interface ValidatedTuning extends _ValidatedResourceBase {
schema: ValidationSchema.Tuning;
domValid: boolean;
pairedSimDataId?: number;
}
/**
* A resource validated with the `SimData` schema.
*/
export interface ValidatedSimData extends _ValidatedResourceBase {
schema: ValidationSchema.SimData;
pairedTuningId?: number;
}
/**
* A resource validated with the `StringTable` schema.
*/
export interface ValidatedStringTable extends _ValidatedResourceBase {
schema: ValidationSchema.StringTable;
locale: StringTableLocale;
instanceBase: bigint;
primary: boolean;
otherLocaleIds: number[];
}
/**
* A resource validated with some schema.
*/
export type ValidatedResource =
ValidatedUnspecified |
ValidatedTuning |
ValidatedSimData |
ValidatedStringTable;
/**
* Validated resources organized by ID and schema.
*/
export interface OrganizedResources {
readonly resources: readonly ValidatedResource[];
readonly schemas: ReadonlyMap<ValidationSchema, readonly ValidatedResource[]>;
}
//#endregion