-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent-schema
98 lines (98 loc) · 5.92 KB
/
event-schema
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
94
95
96
97
98
{
"id": "http://github.com/joshalbrecht/memdam/master/schemas/event-schema#",
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Schema for a personal event. Events should be considered immutable.",
"type": "object",
"required": [ "time__time", "id__id", "type__namespace" ],
"properties": {
"id__id": {
"$ref": "#/definitions/uuid",
"description": "A unique identifier for the event. Required for each event."
},
"time__time": {
"$ref": "#/definitions/datetime",
"description": "A timestamp for when the event occurred. Microsecond precision. Please only use time stamps in UTC."
},
"type__namespace": {
"$ref": "#/definitions/namespace",
"description": "Information about the type of these events and where they came from."
},
"user__id": {
"$ref": "#/definitions/uuid",
"description": "A unique identifier for the user. Often simply left out for efficiency reasons and because the user is obviously you."
},
"source__id": {
"$ref": "#/definitions/uuid",
"description": "A unique identifier for the device or service that captured this data. Generally this will be something with a network interface, in which case you should exploit that to generate the UUID in a more stable fashion, and you should persist this UUID between runs of the program on the same device. Alternatively there will be a domain name (for a service), which again should be used to create the uuid. In the future, this device information should also be written, as a separate time series."
}
},
"patternProperties": {
"^[a-z][a-z0-9]*(_[a-z0-9]+)*__number(__[a-z][a-z0-9]*(_[a-z0-9]+)*){0,1}$": {
"type": "integer",
"description": "A numeric property. The second capture group (if present) should describe the units (example: 'newtons' or 'metric_tons_usd_per_degrees_celsius_miles'"
},
"^[a-z][a-z0-9]*(_[a-z0-9]+)*__string(__[a-z][a-z0-9]*(_[a-z0-9]+)*){0,1}$": {
"type": "string",
"description": "An unknown property, encoded as a string (UTF8). The second capture group (if present) should describe the format or meaning of the string (exampe: 'gps_coordinates' or 'iso_6709'). Because there is no format, is not indexed."
},
"^[a-z][a-z0-9]*(_[a-z0-9]+)*__raw(__[a-z][a-z0-9]*(_[a-z0-9]+)*){0,1}$$": {
"type": "string",
"description": "A blob. Use for storing small binary information that would be silly to make a separate file for. Optionally include the type information in the second capture group."
},
"^[a-z][a-z0-9]*(_[a-z0-9]+)*__text$": {
"type": "string",
"description": "A property with unstructured text. Will be indexed for full text (keyword matching, lowercased, normalized) search."
},
"^[a-z][a-z0-9]*(_[a-z0-9]+)*__enum(__[a-z][a-z0-9]*(_[a-z0-9]+)*){0,1}$": {
"type": "string",
"description": "A property with a fixed set of values (encoded here as strings). The second capture group (if present) should uniquely identify this enum, possibly across many different event types. The existing data should be queried to get possible values for the enum when asking for human input, but should never be used to limit additional new entries."
},
"^[a-z][a-z0-9]*(_[a-z0-9]+)*__bool$": {
"type": "boolean",
"description": "A property that is either true or false."
},
"^[a-z][a-z0-9]*(_[a-z0-9]+)*__namespace$": {
"$ref": "#/definitions/namespace",
"description": "A package name (like java package names, but no numbers or underscores.)"
},
"^[a-z][a-z0-9]*(_[a-z0-9]+)*__time$": {
"$ref": "#/definitions/datetime",
"description": "A property with time values."
},
"^[a-z][a-z0-9]*(_[a-z0-9]+)*__id$": {
"$ref": "#/definitions/uuid",
"description": "A property with unique id values."
},
"^[a-z][a-z0-9]*(_[a-z0-9]+)*__long$": {
"type": "string",
"pattern": "^[\-\+]{0,1}[0-9]+$",
"description": "A property that requires a huge integer value (beyond 2^53). Encoded as a string to prevent javascript and json from dying."
},
"^[a-z][a-z0-9]*(_[a-z0-9]+)*__file$": {
"type": "object",
"oneOf": [
{ "$ref": "#/definitions/fileData" },
{ "$ref": "#/definitions/fileReference" }
],
"description": "A property with binary data. The fileReference type should be preferred wherever possible. The fileData type only exists for transmitting binary data from clients to servers."
}
},
"additionalProperties": false,
"definitions": {
"datetime": {
"type": "string",
"pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-6][0-9]:[0-6][0-9]:[0-6][0-9](\.[0-9]{6})?(\+[0-1][0-9]:[0-6][0-9])?$",
"description": "ISO 8601 format, YYYY-MM-DDTHH:MM:SS.mmmmmm+HH:MM. The microsecond and timezone offset portions are optional. If given, the timezone offset must be +00:00 (ie, all times must be in UTC)"
},
"uuid": {
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
"description": "A UUID. http://en.wikipedia.org/wiki/Universally_unique_identifier"
},
"namespace": {
"type": "string",
"pattern": "[a-z0-9\.]+",
"description": "Should be a valid java package name, following the same conventions (eg: com.domain.package). Where possible (and only if willing to conform to the same schema), try to use the standard memdam namespaces. The fields in events should be predictable given the namespace."
}
}
}