github.com/perses/shared/cue@v0.54.0-beta.8

common/format.cue raw

 1// Copyright The Perses Authors
 2// Licensed under the Apache License, Version 2.0 (the "License");
 3// you may not use this file except in compliance with the License.
 4// You may obtain a copy of the License at
 5//
 6// http://www.apache.org/licenses/LICENSE-2.0
 7//
 8// Unless required by applicable law or agreed to in writing, software
 9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14package common
15
16#format: #simpleFormat | #floatFormat | #shortenableFormat
17
18#simpleFormat: {
19    unit?: #dateFormat.unit
20}
21
22#floatFormat: {
23    unit?: #timeFormat.unit | #percentFormat.unit | #currencyFormat.unit | #temperatureFormat.unit
24    decimalPlaces?: number
25}
26
27#shortenableFormat: {
28    unit?: #decimalFormat.unit | #bitsFormat.unit | #bytesFormat.unit | #throughputFormat.unit
29	decimalPlaces?: number
30	shortValues?:   bool
31}
32
33#timeFormat: {
34	unit:          "nanoseconds" | "microseconds" | "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years"
35	decimalPlaces?: number
36}
37
38#percentFormat: {
39	unit:          "percent" | "percent-decimal"
40	decimalPlaces?: number
41}
42
43#decimalFormat: {
44	unit:          "decimal"
45	decimalPlaces?: number
46	shortValues?:   bool
47}
48
49#bitsFormat: {
50	unit:          "bits" | "decbits"
51	decimalPlaces?: number
52	shortValues?:   bool
53}
54
55#bytesFormat: {
56	unit:          "bytes" | "decbytes"
57	decimalPlaces?: number
58	shortValues?:   bool
59}
60
61#throughputFormat: {
62	unit:          "bits/sec" | "decbits/sec" | "bytes/sec" | "decbytes/sec" | "counts/sec" | "events/sec" | "messages/sec" | "ops/sec" | "packets/sec" | "reads/sec" | "records/sec" | "requests/sec" | "rows/sec" | "writes/sec"
63	decimalPlaces?: number
64	shortValues?:   bool
65}
66
67#currencyFormat: {
68	unit:          "aud" | "cad" | "chf" | "cny" | "eur" | "gbp" | "hkd" | "inr" | "jpy" | "krw" | "nok" | "nzd" | "sek" | "sgd" | "usd"
69	decimalPlaces?: number
70}
71
72#temperatureFormat: {
73	unit: "celsius" | "fahrenheit"
74	decimalPlaces?: number
75}
76
77#dateFormat: {
78	unit: "datetime-iso" | "datetime-us" | "datetime-local" | "date-iso" | "date-us" | "date-local" | "time-local" | "time-iso" | "time-us" | "relative-time" | "unix-timestamp" | "unix-timestamp-ms"
79}