-
Notifications
You must be signed in to change notification settings - Fork 0
/
annotations.go
93 lines (73 loc) · 2.79 KB
/
annotations.go
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
90
91
92
93
package enthasura
import (
"github.com/minskylab/hasura-api/metadata"
)
const (
// hasuraPermissionsAnnotationName = "hasura-permissions"
hasuraPermissionsRoleAnnotationName = "hasura-permissions-role"
// hasuraNotInheritedAnnotationName = "hasura-not-inherited"
)
type M map[string]interface{}
func Eq(val string) M {
return M{
"_eq": val,
}
}
type A []string
// type PermissionsRoleAnnotation struct {
// Role string `json:"role"`
// InsertPermission *PermissionInsertAnnotation `json:"insert_permission,omitempty"`
// SelectPermission *PermissionSelectAnnotation `json:"select_permission,omitempty"`
// UpdatePermission *PermissionUpdateAnnotation `json:"update_permission,omitempty"`
// DeletePermission *PermissionDeleteAnnotation `json:"delete_permission,omitempty"`
// }
type PermissionsRoleAnnotation struct {
Role string `json:"role"`
InsertPermission *InsertPermission `json:"insert_permission,omitempty"`
SelectPermission *SelectPermission `json:"select_permission,omitempty"`
UpdatePermission *UpdatePermission `json:"update_permission,omitempty"`
DeletePermission *DeletePermission `json:"delete_permission,omitempty"`
}
type NotInheritedPermissionsAnnotation struct{}
// func (PermissionsAnnotation) Name() string {
// return hasuraPermissionsAnnotationName
// }
func (PermissionsRoleAnnotation) Name() string {
return hasuraPermissionsRoleAnnotationName
}
// func (NotInheritedPermissionsAnnotation) Name() string {
// return hasuraNotInheritedAnnotationName
// }
type InsertPermission struct {
Check M `json:"check"`
Set M `json:"set,omitempty"`
Columns metadata.PermissionColumns `json:"columns,omitempty"`
BackendOnly bool `json:"backend_only,omitempty"`
}
type SelectPermission struct {
Columns metadata.PermissionColumns `json:"columns,omitempty"`
ComputedFields []string `json:"computed_fields,omitempty"`
Filter M `json:"filter"`
Limit int `json:"limit,omitempty"`
AllowAggregations bool `json:"allow_aggregations,omitempty"`
}
type UpdatePermission struct {
Columns metadata.PermissionColumns `json:"columns"`
Filter M `json:"filter"`
Check M `json:"check,omitempty"`
Set M `json:"set,omitempty"`
}
type DeletePermission struct {
Filter M `json:"filter"`
}
type AllColumnsType string
func (s AllColumnsType) GetColumns() interface{} {
return s
}
const AllColumns AllColumnsType = "*"
// func AllColumns() metadata.PermissionColumns {
// return allColumns
// }
func Columns(cols ...string) metadata.PGColumns {
return cols
}