This repository was archived by the owner on Mar 20, 2022. It is now read-only.
File tree 2 files changed +67
-0
lines changed
2 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 3
3
"version" : " 2.0.1" ,
4
4
"description" : " Normalizes JSON according to schema for Flux application" ,
5
5
"main" : " lib/index.js" ,
6
+ "typings" : " typings.d.ts" ,
6
7
"repository" : {
7
8
"type" : " git" ,
8
9
"url" : " https://github.com/gaearon/normalizr.git"
Original file line number Diff line number Diff line change
1
+ interface EntitySchemaOptions {
2
+ idAttribute ?: string | Function ;
3
+ }
4
+
5
+ interface IterableSchemaOptions {
6
+ schemaAttribute ?: string | Function ;
7
+ }
8
+
9
+ interface UnionSchemaOptions {
10
+ schemaAttribute ?: string | Function ;
11
+ }
12
+
13
+ type NormalizeOptions = {
14
+ assignEntity ?: Function ;
15
+ mergeIntoEntity ?: Function ;
16
+ }
17
+
18
+ type NormalizeInput = Object | Array < Object > ;
19
+
20
+ type NormalizeOutput = {
21
+ result : any ;
22
+ entities ?: any ;
23
+ }
24
+
25
+ class EntitySchema {
26
+ constructor ( key : string , options ?: EntitySchemaOptions ) ;
27
+
28
+ define ( schema : SchemaMap ) : void ;
29
+ getKey ( ) : string ;
30
+ getIdAttribute ( ) : string ;
31
+ }
32
+
33
+ class IterableSchema {
34
+ }
35
+
36
+ class UnionSchema {
37
+ }
38
+
39
+ type SchemaValue = EntitySchema | IterableSchema | UnionSchema | SchemaMap ;
40
+
41
+ interface SchemaMap {
42
+ [ key : string ] : SchemaValue ;
43
+ }
44
+
45
+ export function arrayOf (
46
+ schema : SchemaValue ,
47
+ options ?: IterableSchemaOptions
48
+ ) : IterableSchema ;
49
+
50
+ export function valuesOf (
51
+ schema : SchemaValue ,
52
+ options ?: IterableSchemaOptions
53
+ ) : IterableSchema ;
54
+
55
+ export function unionOf (
56
+ schema : SchemaValue ,
57
+ options ?: UnionSchemaOptions
58
+ ) : UnionSchema ;
59
+
60
+ export function normalize (
61
+ input : NormalizeInput ,
62
+ schema : SchemaValue ,
63
+ options ?: NormalizeOptions
64
+ ) : NormalizeOutput ;
65
+
66
+ export { EntitySchema as Schema } ;
You can’t perform that action at this time.
0 commit comments