-
Notifications
You must be signed in to change notification settings - Fork 163
/
primitives.go
61 lines (58 loc) · 1.56 KB
/
primitives.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
package types
import (
"github.com/google/cel-go/cel"
openfgav1 "github.com/openfga/api/proto/openfga/v1"
)
const startingGenericTypeCount = 1
var (
AnyParamType = registerParamType(
openfgav1.ConditionParamTypeRef_TYPE_NAME_ANY,
cel.AnyType,
anyTypeConverterFunc,
)
BoolParamType = registerParamType(
openfgav1.ConditionParamTypeRef_TYPE_NAME_BOOL,
cel.BoolType,
primitiveTypeConverterFunc[bool],
)
StringParamType = registerParamType(
openfgav1.ConditionParamTypeRef_TYPE_NAME_STRING,
cel.StringType,
primitiveTypeConverterFunc[string],
)
IntParamType = registerParamType(
openfgav1.ConditionParamTypeRef_TYPE_NAME_INT,
cel.IntType,
numericTypeConverterFunc[int64],
)
UIntParamType = registerParamType(
openfgav1.ConditionParamTypeRef_TYPE_NAME_UINT,
cel.UintType,
numericTypeConverterFunc[uint64],
)
DoubleParamType = registerParamType(
openfgav1.ConditionParamTypeRef_TYPE_NAME_DOUBLE,
cel.DoubleType,
numericTypeConverterFunc[float64],
)
DurationParamType = registerParamType(
openfgav1.ConditionParamTypeRef_TYPE_NAME_DURATION,
cel.DurationType,
durationTypeConverterFunc,
)
TimestampParamType = registerParamType(
openfgav1.ConditionParamTypeRef_TYPE_NAME_TIMESTAMP,
cel.TimestampType,
timestampTypeConverterFunc,
)
MapParamType = registerParamTypeWithGenerics(
openfgav1.ConditionParamTypeRef_TYPE_NAME_MAP,
startingGenericTypeCount,
mapTypeConverterFunc,
)
ListParamType = registerParamTypeWithGenerics(
openfgav1.ConditionParamTypeRef_TYPE_NAME_LIST,
startingGenericTypeCount,
listTypeConverterFunc,
)
)