forked from paularmstrong/normalizr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
64 lines (55 loc) · 1.51 KB
/
index.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
declare namespace schema {
export type StrategyFunction = (value: any, parent: any, key: string) => any;
export type SchemaFunction = (value: any, parent: any, key: string) => string;
export type MergeFunction = (entityA: any, entityB: any) => any;
export class Array {
constructor(definition: Schema, schemaAttribute?: string | SchemaFunction)
define(definition: Schema): void
}
export interface EntityOptions {
idAttribute?: string | SchemaFunction
mergeStrategy?: MergeFunction
processStrategy?: StrategyFunction
}
export class Entity {
constructor(key: string, definition?: Schema, options?: EntityOptions)
define(definition: Schema): void
key: string
}
export class Object {
constructor(definition: {[key: string]: Schema})
define(definition: Schema): void
}
export class Union {
constructor(definition: Schema, schemaAttribute?: string | SchemaFunction)
define(definition: Schema): void
}
export class Values {
constructor(definition: Schema, schemaAttribute?: string | SchemaFunction)
define(definition: Schema): void
}
}
export type Schema =
schema.Array |
schema.Entity |
schema.Object |
schema.Union |
schema.Values |
schema.Array[] |
schema.Entity[] |
schema.Object[] |
schema.Union[] |
schema.Values[] |
{[key: string]: Schema | Schema[]};
export function normalize(
data: any,
schema: Schema
): {
entities: any,
result: any
};
export function denormalize(
input: any,
schema: Schema,
entities: any
): any;