-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.ts
86 lines (75 loc) · 1.53 KB
/
interface.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
type ParameterLiteral = {
type: "string" | "number" | "boolean";
required: boolean;
};
type ParameterObject = {
type: "object";
required: boolean;
fields: Parameter | Scheme | Scheme[];
};
type ParameterTimeStamp = {
type: "timestamp";
required: boolean;
};
type ParameterReference = {
type: "reference";
required: boolean;
collection: string;
};
type ParameterArray = {
type: "array";
required: boolean;
fields: Parameter | Scheme | Scheme[];
};
export type Parameter =
| ParameterLiteral
| ParameterObject
| ParameterArray
| ParameterTimeStamp
| ParameterReference;
export interface Scheme {
[key: string]: Parameter | Scheme | Scheme[];
}
export interface Document {
data: Scheme;
}
export type PresetSecurityRules =
| "isOwner"
| "isAuthenticated"
| "isPublic"
| "isValidData";
export type Rule = {
preset: PresetSecurityRules;
} | {
rule: string;
};
export interface SecurityRules {
read: Rule[];
write: Rule[];
create: Rule[];
update: Rule[];
delete: Rule[];
}
interface FieldValidation {
[fieldName: string]: string;
}
export interface Collection {
name: string;
collectionName: string;
parent?: Collection;
document: Document;
security: SecurityRules;
fieldValidations?: FieldValidation;
}
export interface GenerateFirestoreCodeOptions {
/**
* only support "typescript" for now
* but can be extended to other languages
* e.g. "admin-ts", "go", "flutter"
*/
lang: "web-ts";
/**
* absolute path to the output directory
*/
outputDir: string;
}