-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
metaschema.d.ts
97 lines (85 loc) · 2.25 KB
/
metaschema.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
type Scope = 'global' | 'system' | 'local' | 'memory';
type Allow = 'read' | 'write' | 'append';
type Kind =
| 'dictionary'
| 'registry'
| 'entity'
| 'details'
| 'relation'
| 'form'
| 'view'
| 'projection'
| 'journal'
| 'struct'
| 'scalar';
type Cardinality =
| 'one-to-one'
| 'one-to-many'
| 'many-to-one'
| 'many-to-many';
interface Relation {
to: string;
type: Cardinality;
}
interface ValidationResult {
valid: boolean;
errors: string[];
}
export class Schema {
static KIND: Array<string>;
static KIND_STORED: Array<string>;
static KIND_MEMORY: Array<string>;
static SCOPE: Array<string>;
static STORE: Array<string>;
static ALLOW: Array<string>;
static from(raw: object, namespaces?: Array<Model>): Schema;
static extractSchema(def: object): Schema | null;
root: null;
kind: Kind;
references: Set<string>;
relations: Set<Relation>;
scope: Scope;
allow: Allow;
parent: string;
indexes: object;
options: {
validate: Function | null;
format: Function | null;
parse: Function | null;
serialize: Function | null;
};
custom: object;
fields: object;
name: string;
namespaces: Set<Model>;
constructor(name: string, raw: object, namespaces?: Array<Model>);
get types(): object;
checkConsistency(): Array<string>;
findReference(name: string): Schema;
check(value: any): ValidationResult;
toInterface(): string;
attach(...namespaces: Array<Model>): void;
detouch(...namespaces: Array<Model>): void;
toString(): string;
toJSON(): object;
validate(value: any, path: string): ValidationResult;
}
export function createSchema(name: string, src: string): Schema;
export function loadSchema(fileName: string): Promise<Schema>;
export function readDirectory(dirPath: string): Promise<Map<string, object>>;
export function loadModel(
modelPath: string,
systemTypes: object,
): Promise<Model>;
export function saveTypes(outputFile: string, model: Model): Promise<void>;
export class Model {
types: object;
entities: Map<string, object>;
database: object;
order: Set<string>;
warnings: Array<string>;
constructor(types: object, entities: Map<string, object>, database?: object);
preprocess(): void;
reorderEntity(name: string, base?: string): void;
get dts(): string;
}