-
Notifications
You must be signed in to change notification settings - Fork 5
/
hayson.ts
102 lines (84 loc) · 1.69 KB
/
hayson.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Copyright (c) 2020, J2 Innovations. All Rights Reserved
*/
/* eslint @typescript-eslint/no-empty-interface: "off" */
/**
* Haystack JSON format types.
*
* As described in https://bitbucket.org/finproducts/hayson/src/master/
*
* @module
*/
import { Kind } from './Kind'
export type HaysonNumVal = number | string
export interface HaysonNum {
_kind?: Kind
val: HaysonNumVal
unit?: string
}
export interface HaysonSingleton {
_kind?: Kind
}
export type HaysonMarker = HaysonSingleton
export type HaysonNa = HaysonSingleton
export type HaysonRemove = HaysonSingleton
export interface HaysonRef {
_kind?: Kind
val: string
dis?: string
}
export interface HaysonKindVal {
_kind?: Kind
val: string
}
export type HaysonUri = HaysonKindVal
export type HaysonSymbol = HaysonKindVal
export type HaysonTime = HaysonKindVal
export type HaysonDate = HaysonKindVal
export interface HaysonDateTime {
_kind?: Kind
val: string
tz?: string
}
export interface HaysonCoord {
_kind?: Kind
lat: number
lng: number
}
export interface HaysonXStr {
_kind?: Kind
type: string
val: string
}
export type HaysonVal =
| string
| number
| boolean
| HaysonNum
| HaysonSingleton
| HaysonRef
| HaysonTime
| HaysonDate
| HaysonUri
| HaysonDateTime
| HaysonSymbol
| HaysonCoord
| HaysonXStr
| HaysonList
| HaysonDict
| HaysonGrid
| null
export interface HaysonList extends Array<HaysonVal> {}
export interface HaysonDict {
[prop: string]: HaysonVal
}
export interface HaysonGrid {
_kind?: Kind
meta?: HaysonDict
cols?: { name: string; meta?: HaysonDict }[]
rows?: HaysonDict[]
}
/**
* The MIME type for Haystack JSON (a.k.a Hayson)
*/
export const HAYSON_MIME_TYPE = 'application/vnd.haystack+json'