/
options.ts
89 lines (80 loc) · 2.21 KB
/
options.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
import {
IJsonArrayMemberOptions,
IJsonMapMemberOptions,
IJsonMemberOptions,
IJsonObjectOptions,
IJsonSetMemberOptions,
Serializable,
} from 'typedjson';
import type { TypeDescriptor } from 'typedjson/lib/types/type-descriptor';
export interface CustomDeserializerParams {
fallback: (sourceObject: any, constructor: Serializable<any> | TypeDescriptor) => any;
}
export interface CustomSerializerParams {
fallback: (sourceObject: any, constructor: Serializable<any> | TypeDescriptor) => any;
}
export interface MemberOptionsBase extends IJsonMemberOptions {
/**
* Custom deserializer for member
*/
deserializer?: ((json: any, params: CustomDeserializerParams) => any) | null;
/**
* Custom serialized for member
*/
serializer?: ((value: any, params: CustomSerializerParams) => any) | null;
}
export interface SerializableObjectOptions<T> extends IJsonObjectOptions<T> {}
export interface SerializableMemberOptions extends MemberOptionsBase {
/**
* Identify this attribute as unique
*/
unique?: boolean;
/**
* Identify this attribute as a primary key
*/
primaryKey?: boolean;
/**
* Create an index on this attribute. Possible values
* are true/false or a string for specifying this attribute
* as part of multiple attributes in an index.
*/
index?: string | boolean;
/**
* Experimental number type
*/
numberType?: NumberType;
}
export interface SerializableArrayMemberOptions extends MemberOptionsBase, IJsonArrayMemberOptions {
/**
* Experimental number type
*/
numberType?: NumberType;
}
export interface SerializableSetMemberOptions extends MemberOptionsBase, IJsonSetMemberOptions {
/**
* Experimental number type
*/
numberType?: NumberType;
}
export interface SerializableMapMemberOptions extends MemberOptionsBase, IJsonMapMemberOptions {
key?: {
/**
* Experimental number type
*/
numberType?: NumberType;
};
value?: {
/**
* Experimental number type
*/
numberType?: NumberType;
};
}
export enum NumberType {
INTEGER,
FLOAT,
DOUBLE,
DECIMAL,
LONG,
SHORT,
}