Skip to content
This repository was archived by the owner on Mar 20, 2022. It is now read-only.

Commit 2ca4089

Browse files
committed
Add type declarations
1 parent 81d95dd commit 2ca4089

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "2.0.1",
44
"description": "Normalizes JSON according to schema for Flux application",
55
"main": "lib/index.js",
6+
"typings": "typings.d.ts",
67
"repository": {
78
"type": "git",
89
"url": "https://github.com/gaearon/normalizr.git"

typings.d.ts

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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};

0 commit comments

Comments
 (0)