-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.d.ts
45 lines (37 loc) · 1.09 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
declare function wormalize(): any;
/*!
* Copyright 2018 yangjunbao <yangjunbao@shimo.im>. All rights reserved.
* @since 2018-08-14 14:58:08
*/
declare module 'wormalize' {
export class Schema {
readonly name: string;
readonly idProperty: string;
readonly isPlain: boolean;
constructor(name: string, idProperty?: string);
define(properties: Record<string, Schema | [Schema]>): void;
forEachNestedSchema(
iter: (
value: [string, Schema | [Schema]],
index: number,
context: this,
) => void,
): void;
}
export type TSchema = { [P: string]: TSchema } | [Schema] | Schema;
export interface Entity<K extends string | number = string> {
result: K[];
entities: Record<string, Record<string, any>>;
}
export function wormalize<K extends string | number>(
input: any,
schema: TSchema,
): Entity<K>;
export function dewormalize<K extends string | number>(
result: K[],
schema: TSchema,
entities:
| Record<string, Record<string, any>>
| ((name: string, id: number | string) => any),
): any;
}