-
Notifications
You must be signed in to change notification settings - Fork 80
/
entity.ts
33 lines (26 loc) · 1.27 KB
/
entity.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
/** The Symbol used to access the entity ID of an {@link Entity}. */
export const EntityId = Symbol('entityId')
/** The Symbol used to access the keyname of an {@link Entity}. */
export const EntityKeyName = Symbol('entityKeyName')
export type EntityInternal = {
/** The unique ID of the {@link Entity}. Access using the {@link EntityId} Symbol. */
[EntityId]?: string
/** The key the {@link Entity} is stored under inside of Redis. Access using the {@link EntityKeyName} Symbol. */
[EntityKeyName]?: string
}
/** Defines the objects returned from calls to {@link Repository | repositories }. */
export type Entity = EntityData & EntityInternal
export type EntityKeys<T extends Entity> = Exclude<keyof T, keyof EntityInternal>;
/** The free-form data associated with an {@link Entity}. */
export type EntityData = {
[key: string]: EntityDataValue | EntityData | Array<EntityDataValue | EntityData>
}
/** Valid types for values in an {@link Entity}. */
export type EntityDataValue = string | number | boolean | Date | Point | null | undefined | Array<EntityDataValue | EntityData>
/** Defines a point on the globe using longitude and latitude. */
export type Point = {
/** The longitude of the point. */
longitude: number
/** The latitude of the point. */
latitude: number
}