@perses-dev/core 0.53.0-beta.1 → 0.53.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/base-metadata.js +16 -0
- package/dist/cjs/model/profile-data.js +1 -5
- package/dist/cjs/model/units/bits.js +105 -0
- package/dist/cjs/model/units/date.js +297 -0
- package/dist/cjs/model/units/temperature.js +64 -0
- package/dist/cjs/model/units/throughput.js +22 -1
- package/dist/cjs/model/units/time.js +16 -2
- package/dist/cjs/model/units/units.js +39 -3
- package/dist/model/base-metadata.d.ts +17 -0
- package/dist/model/base-metadata.d.ts.map +1 -0
- package/dist/model/base-metadata.js +15 -0
- package/dist/model/base-metadata.js.map +1 -0
- package/dist/model/log-data.d.ts +2 -9
- package/dist/model/log-data.d.ts.map +1 -1
- package/dist/model/log-data.js.map +1 -1
- package/dist/model/profile-data.d.ts +2 -1
- package/dist/model/profile-data.d.ts.map +1 -1
- package/dist/model/profile-data.js +1 -5
- package/dist/model/profile-data.js.map +1 -1
- package/dist/model/time-series-data.d.ts +3 -9
- package/dist/model/time-series-data.d.ts.map +1 -1
- package/dist/model/time-series-data.js.map +1 -1
- package/dist/model/trace-data.d.ts +5 -2
- package/dist/model/trace-data.d.ts.map +1 -1
- package/dist/model/trace-data.js.map +1 -1
- package/dist/model/units/bits.d.ts +12 -0
- package/dist/model/units/bits.d.ts.map +1 -0
- package/dist/model/units/bits.js +81 -0
- package/dist/model/units/bits.js.map +1 -0
- package/dist/model/units/date.d.ts +28 -0
- package/dist/model/units/date.d.ts.map +1 -0
- package/dist/model/units/date.js +278 -0
- package/dist/model/units/date.js.map +1 -0
- package/dist/model/units/temperature.d.ts +11 -0
- package/dist/model/units/temperature.d.ts.map +1 -0
- package/dist/model/units/temperature.js +45 -0
- package/dist/model/units/temperature.js.map +1 -0
- package/dist/model/units/throughput.d.ts +1 -1
- package/dist/model/units/throughput.d.ts.map +1 -1
- package/dist/model/units/throughput.js +22 -1
- package/dist/model/units/throughput.js.map +1 -1
- package/dist/model/units/time.d.ts +3 -1
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +16 -2
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/types.d.ts +1 -1
- package/dist/model/units/types.d.ts.map +1 -1
- package/dist/model/units/types.js.map +1 -1
- package/dist/model/units/units.d.ts +26 -1
- package/dist/model/units/units.d.ts.map +1 -1
- package/dist/model/units/units.js +30 -3
- package/dist/model/units/units.js.map +1 -1
- package/dist/schema/datasource.d.ts +4 -4
- package/dist/schema/metadata.d.ts +2 -2
- package/dist/schema/role.d.ts +4 -4
- package/dist/schema/rolebinding.d.ts +4 -4
- package/dist/schema/secret.d.ts +8 -8
- package/dist/schema/variable.d.ts +8 -8
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/model/units/types.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Common types needed across individual unit groups and the overall combined\n// units.\n\nimport { Duration } from 'date-fns';\nimport { AbsoluteTimeRange, DurationString } from '../time';\nimport { FormatOptions } from './units';\n\nexport type UnitGroup
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/types.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Common types needed across individual unit groups and the overall combined\n// units.\n\nimport { Duration } from 'date-fns';\nimport { AbsoluteTimeRange, DurationString } from '../time';\nimport { FormatOptions } from './units';\n\nexport type UnitGroup =\n | 'Time'\n | 'Percent'\n | 'Decimal'\n | 'Bytes'\n | 'Bits'\n | 'Throughput'\n | 'Currency'\n | 'Temperature'\n | 'Date';\n\n/**\n * Configuration for rendering units that are part of a group.\n */\nexport type UnitGroupConfig = {\n /**\n * The label that is shown in the UI.\n */\n label: string;\n /**\n * When true, the unit group supports setting decimal places.\n */\n decimalPlaces?: boolean;\n /**\n * When true, the unit group supports enabling shortValues.\n */\n shortValues?: boolean;\n};\n\n/**\n * Configuration for rendering a specific unit.\n */\nexport type UnitConfig = {\n /**\n * The group the unit is part of. This will inform common rendering behavior.\n */\n group?: UnitGroup;\n\n /**\n * When true, this unit will not be displayed in the unit selector. This is\n * useful for units that are shorthand variants of other units.\n */\n disableSelectorOption?: boolean;\n\n /**\n * The label that is shown in the UI.\n */\n label: string;\n};\n\n/**\n * Used in the tests for each type of unit.\n */\nexport interface UnitTestCase {\n value: number;\n format: FormatOptions;\n expected: string;\n}\n\nexport interface IntervalTestCase {\n timeRange: AbsoluteTimeRange;\n expected: Duration;\n}\n\nexport interface FormatTestCase {\n duration: Duration;\n expected: DurationString;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6EAA6E;AAC7E,SAAS;AAsET,WAGC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { BytesFormatOptions as BytesFormatOptions } from './bytes';
|
|
2
|
+
import { BitsFormatOptions as BitsFormatOptions } from './bits';
|
|
2
3
|
import { DecimalFormatOptions as DecimalFormatOptions } from './decimal';
|
|
3
4
|
import { PercentFormatOptions as PercentFormatOptions } from './percent';
|
|
5
|
+
import { TemperatureFormatOptions } from './temperature';
|
|
4
6
|
import { TimeFormatOptions as TimeFormatOptions } from './time';
|
|
5
7
|
import { UnitGroup, UnitGroupConfig, UnitConfig } from './types';
|
|
6
8
|
import { ThroughputFormatOptions } from './throughput';
|
|
7
9
|
import { CurrencyFormatOptions } from './currency';
|
|
10
|
+
import { DateFormatOptions } from './date';
|
|
8
11
|
/**
|
|
9
12
|
* Most of the number formatting is based on Intl.NumberFormat, which is built into JavaScript.
|
|
10
13
|
* Prefer Intl.NumbeFormat because it covers most use cases and will continue to be supported with time.
|
|
@@ -14,6 +17,20 @@ import { CurrencyFormatOptions } from './currency';
|
|
|
14
17
|
*/
|
|
15
18
|
export declare const UNIT_GROUP_CONFIG: Readonly<Record<UnitGroup, UnitGroupConfig>>;
|
|
16
19
|
export declare const UNIT_CONFIG: {
|
|
20
|
+
readonly "datetime-iso": UnitConfig;
|
|
21
|
+
readonly "datetime-us": UnitConfig;
|
|
22
|
+
readonly "datetime-local": UnitConfig;
|
|
23
|
+
readonly "date-iso": UnitConfig;
|
|
24
|
+
readonly "date-us": UnitConfig;
|
|
25
|
+
readonly "date-local": UnitConfig;
|
|
26
|
+
readonly "time-local": UnitConfig;
|
|
27
|
+
readonly "time-iso": UnitConfig;
|
|
28
|
+
readonly "time-us": UnitConfig;
|
|
29
|
+
readonly "relative-time": UnitConfig;
|
|
30
|
+
readonly "unix-timestamp": UnitConfig;
|
|
31
|
+
readonly "unix-timestamp-ms": UnitConfig;
|
|
32
|
+
readonly celsius: UnitConfig;
|
|
33
|
+
readonly fahrenheit: UnitConfig;
|
|
17
34
|
readonly aud: UnitConfig;
|
|
18
35
|
readonly cad: UnitConfig;
|
|
19
36
|
readonly chf: UnitConfig;
|
|
@@ -30,6 +47,7 @@ export declare const UNIT_CONFIG: {
|
|
|
30
47
|
readonly sgd: UnitConfig;
|
|
31
48
|
readonly usd: UnitConfig;
|
|
32
49
|
readonly "bits/sec": UnitConfig;
|
|
50
|
+
readonly "decbits/sec": UnitConfig;
|
|
33
51
|
readonly "bytes/sec": UnitConfig;
|
|
34
52
|
readonly "decbytes/sec": UnitConfig;
|
|
35
53
|
readonly "counts/sec": UnitConfig;
|
|
@@ -42,12 +60,16 @@ export declare const UNIT_CONFIG: {
|
|
|
42
60
|
readonly "requests/sec": UnitConfig;
|
|
43
61
|
readonly "rows/sec": UnitConfig;
|
|
44
62
|
readonly "writes/sec": UnitConfig;
|
|
63
|
+
readonly bits: UnitConfig;
|
|
64
|
+
readonly decbits: UnitConfig;
|
|
45
65
|
readonly bytes: UnitConfig;
|
|
46
66
|
readonly decbytes: UnitConfig;
|
|
47
67
|
readonly decimal: UnitConfig;
|
|
48
68
|
readonly percent: UnitConfig;
|
|
49
69
|
readonly "percent-decimal": UnitConfig;
|
|
50
70
|
readonly "%": UnitConfig;
|
|
71
|
+
readonly nanoseconds: UnitConfig;
|
|
72
|
+
readonly microseconds: UnitConfig;
|
|
51
73
|
readonly milliseconds: UnitConfig;
|
|
52
74
|
readonly seconds: UnitConfig;
|
|
53
75
|
readonly minutes: UnitConfig;
|
|
@@ -57,7 +79,7 @@ export declare const UNIT_CONFIG: {
|
|
|
57
79
|
readonly months: UnitConfig;
|
|
58
80
|
readonly years: UnitConfig;
|
|
59
81
|
};
|
|
60
|
-
export type FormatOptions = TimeFormatOptions | PercentFormatOptions | DecimalFormatOptions | BytesFormatOptions | ThroughputFormatOptions | CurrencyFormatOptions;
|
|
82
|
+
export type FormatOptions = TimeFormatOptions | PercentFormatOptions | DecimalFormatOptions | BytesFormatOptions | BitsFormatOptions | ThroughputFormatOptions | CurrencyFormatOptions | TemperatureFormatOptions | DateFormatOptions;
|
|
61
83
|
type HasDecimalPlaces<UnitOpt> = UnitOpt extends {
|
|
62
84
|
decimalPlaces?: number;
|
|
63
85
|
} ? UnitOpt : never;
|
|
@@ -72,9 +94,12 @@ export declare function isTimeUnit(formatOptions: FormatOptions): formatOptions
|
|
|
72
94
|
export declare function isPercentUnit(formatOptions: FormatOptions): formatOptions is PercentFormatOptions;
|
|
73
95
|
export declare function isDecimalUnit(formatOptions: FormatOptions): formatOptions is DecimalFormatOptions;
|
|
74
96
|
export declare function isBytesUnit(formatOptions: FormatOptions): formatOptions is BytesFormatOptions;
|
|
97
|
+
export declare function isBitsUnit(formatOptions: FormatOptions): formatOptions is BitsFormatOptions;
|
|
75
98
|
export declare function isUnitWithDecimalPlaces(formatOptions: FormatOptions): formatOptions is HasDecimalPlaces<FormatOptions>;
|
|
76
99
|
export declare function isUnitWithShortValues(formatOptions: FormatOptions): formatOptions is HasShortValues<FormatOptions>;
|
|
77
100
|
export declare function isThroughputUnit(formatOptions: FormatOptions): formatOptions is ThroughputFormatOptions;
|
|
78
101
|
export declare function isCurrencyUnit(formatOptions: FormatOptions): formatOptions is CurrencyFormatOptions;
|
|
102
|
+
export declare function isDateUnit(formatOptions: FormatOptions): formatOptions is DateFormatOptions;
|
|
103
|
+
export declare function isTemperatureUnit(formatOptions: FormatOptions): formatOptions is TemperatureFormatOptions;
|
|
79
104
|
export {};
|
|
80
105
|
//# sourceMappingURL=units.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../../src/model/units/units.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,kBAAkB,IAAI,kBAAkB,EAAyC,MAAM,SAAS,CAAC;AACvH,OAAO,EAEL,oBAAoB,IAAI,oBAAoB,EAG7C,MAAM,WAAW,CAAC;AACnB,OAAO,EAEL,oBAAoB,IAAI,oBAAoB,EAG7C,MAAM,WAAW,CAAC;AACnB,OAAO,EAAc,iBAAiB,IAAI,iBAAiB,EAAuC,MAAM,QAAQ,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAIL,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aAAa,GAAG,aAAa,IAAI,iBAAiB,CAE3F;AAED,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,IAAI,wBAAwB,CAEzG"}
|
|
@@ -11,11 +11,14 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { formatBytes, BYTES_GROUP_CONFIG, BYTES_UNIT_CONFIG } from './bytes';
|
|
14
|
+
import { formatBits, BITS_GROUP_CONFIG, BITS_UNIT_CONFIG } from './bits';
|
|
14
15
|
import { formatDecimal, DECIMAL_GROUP_CONFIG, DECIMAL_UNIT_CONFIG } from './decimal';
|
|
15
16
|
import { formatPercent, PERCENT_GROUP_CONFIG, PERCENT_UNIT_CONFIG } from './percent';
|
|
17
|
+
import { TEMPERATURE_GROUP_CONFIG, formatTemperature, TEMPERATURE_UNIT_CONFIG } from './temperature';
|
|
16
18
|
import { formatTime, TIME_GROUP_CONFIG, TIME_UNIT_CONFIG } from './time';
|
|
17
19
|
import { formatThroughput, THROUGHPUT_GROUP_CONFIG, THROUGHPUT_UNIT_CONFIG } from './throughput';
|
|
18
20
|
import { formatCurrency, CURRENCY_GROUP_CONFIG, CURRENCY_UNIT_CONFIG } from './currency';
|
|
21
|
+
import { formatDate, DATE_GROUP_CONFIG, DATE_UNIT_CONFIG } from './date';
|
|
19
22
|
/**
|
|
20
23
|
* Most of the number formatting is based on Intl.NumberFormat, which is built into JavaScript.
|
|
21
24
|
* Prefer Intl.NumbeFormat because it covers most use cases and will continue to be supported with time.
|
|
@@ -27,24 +30,33 @@ import { formatCurrency, CURRENCY_GROUP_CONFIG, CURRENCY_UNIT_CONFIG } from './c
|
|
|
27
30
|
Percent: PERCENT_GROUP_CONFIG,
|
|
28
31
|
Decimal: DECIMAL_GROUP_CONFIG,
|
|
29
32
|
Bytes: BYTES_GROUP_CONFIG,
|
|
33
|
+
Bits: BITS_GROUP_CONFIG,
|
|
30
34
|
Throughput: THROUGHPUT_GROUP_CONFIG,
|
|
31
|
-
Currency: CURRENCY_GROUP_CONFIG
|
|
35
|
+
Currency: CURRENCY_GROUP_CONFIG,
|
|
36
|
+
Temperature: TEMPERATURE_GROUP_CONFIG,
|
|
37
|
+
Date: DATE_GROUP_CONFIG
|
|
32
38
|
};
|
|
33
39
|
export const UNIT_CONFIG = {
|
|
34
40
|
...TIME_UNIT_CONFIG,
|
|
35
41
|
...PERCENT_UNIT_CONFIG,
|
|
36
42
|
...DECIMAL_UNIT_CONFIG,
|
|
37
43
|
...BYTES_UNIT_CONFIG,
|
|
44
|
+
...BITS_UNIT_CONFIG,
|
|
38
45
|
...THROUGHPUT_UNIT_CONFIG,
|
|
39
|
-
...CURRENCY_UNIT_CONFIG
|
|
46
|
+
...CURRENCY_UNIT_CONFIG,
|
|
47
|
+
...TEMPERATURE_UNIT_CONFIG,
|
|
48
|
+
...DATE_UNIT_CONFIG
|
|
40
49
|
};
|
|
41
50
|
export function formatValue(value, formatOptions) {
|
|
42
|
-
if (formatOptions
|
|
51
|
+
if (!formatOptions) {
|
|
43
52
|
return value.toString();
|
|
44
53
|
}
|
|
45
54
|
if (isBytesUnit(formatOptions)) {
|
|
46
55
|
return formatBytes(value, formatOptions);
|
|
47
56
|
}
|
|
57
|
+
if (isBitsUnit(formatOptions)) {
|
|
58
|
+
return formatBits(value, formatOptions);
|
|
59
|
+
}
|
|
48
60
|
if (isDecimalUnit(formatOptions)) {
|
|
49
61
|
return formatDecimal(value, formatOptions);
|
|
50
62
|
}
|
|
@@ -60,6 +72,12 @@ export function formatValue(value, formatOptions) {
|
|
|
60
72
|
if (isCurrencyUnit(formatOptions)) {
|
|
61
73
|
return formatCurrency(value, formatOptions);
|
|
62
74
|
}
|
|
75
|
+
if (isDateUnit(formatOptions)) {
|
|
76
|
+
return formatDate(value, formatOptions);
|
|
77
|
+
}
|
|
78
|
+
if (isTemperatureUnit(formatOptions)) {
|
|
79
|
+
return formatTemperature(value, formatOptions);
|
|
80
|
+
}
|
|
63
81
|
const exhaustive = formatOptions;
|
|
64
82
|
throw new Error(`Unknown unit options ${exhaustive}`);
|
|
65
83
|
}
|
|
@@ -87,6 +105,9 @@ export function isDecimalUnit(formatOptions) {
|
|
|
87
105
|
export function isBytesUnit(formatOptions) {
|
|
88
106
|
return getUnitGroup(formatOptions) === 'Bytes';
|
|
89
107
|
}
|
|
108
|
+
export function isBitsUnit(formatOptions) {
|
|
109
|
+
return getUnitGroup(formatOptions) === 'Bits';
|
|
110
|
+
}
|
|
90
111
|
export function isUnitWithDecimalPlaces(formatOptions) {
|
|
91
112
|
const groupConfig = getUnitGroupConfig(formatOptions);
|
|
92
113
|
return !!groupConfig.decimalPlaces;
|
|
@@ -101,5 +122,11 @@ export function isThroughputUnit(formatOptions) {
|
|
|
101
122
|
export function isCurrencyUnit(formatOptions) {
|
|
102
123
|
return getUnitGroup(formatOptions) === 'Currency';
|
|
103
124
|
}
|
|
125
|
+
export function isDateUnit(formatOptions) {
|
|
126
|
+
return getUnitGroup(formatOptions) === 'Date';
|
|
127
|
+
}
|
|
128
|
+
export function isTemperatureUnit(formatOptions) {
|
|
129
|
+
return getUnitGroup(formatOptions) === 'Temperature';
|
|
130
|
+
}
|
|
104
131
|
|
|
105
132
|
//# sourceMappingURL=units.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/model/units/units.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { formatBytes, BytesFormatOptions as BytesFormatOptions, BYTES_GROUP_CONFIG, BYTES_UNIT_CONFIG } from './bytes';\nimport {\n formatDecimal,\n DecimalFormatOptions as DecimalFormatOptions,\n DECIMAL_GROUP_CONFIG,\n DECIMAL_UNIT_CONFIG,\n} from './decimal';\nimport {\n formatPercent,\n PercentFormatOptions as PercentFormatOptions,\n PERCENT_GROUP_CONFIG,\n PERCENT_UNIT_CONFIG,\n} from './percent';\nimport { formatTime, TimeFormatOptions as TimeFormatOptions, TIME_GROUP_CONFIG, TIME_UNIT_CONFIG } from './time';\nimport { UnitGroup, UnitGroupConfig, UnitConfig } from './types';\nimport {\n formatThroughput,\n THROUGHPUT_GROUP_CONFIG,\n THROUGHPUT_UNIT_CONFIG,\n ThroughputFormatOptions,\n} from './throughput';\nimport { formatCurrency, CURRENCY_GROUP_CONFIG, CURRENCY_UNIT_CONFIG, CurrencyFormatOptions } from './currency';\n\n/**\n * Most of the number formatting is based on Intl.NumberFormat, which is built into JavaScript.\n * Prefer Intl.NumbeFormat because it covers most use cases and will continue to be supported with time.\n *\n * To format bytes, we also make use of the `numbro` package,\n * because it can handle adding units like KB, MB, GB, etc. correctly.\n */\n\nexport const UNIT_GROUP_CONFIG: Readonly<Record<UnitGroup, UnitGroupConfig>> = {\n Time: TIME_GROUP_CONFIG,\n Percent: PERCENT_GROUP_CONFIG,\n Decimal: DECIMAL_GROUP_CONFIG,\n Bytes: BYTES_GROUP_CONFIG,\n Throughput: THROUGHPUT_GROUP_CONFIG,\n Currency: CURRENCY_GROUP_CONFIG,\n};\nexport const UNIT_CONFIG = {\n ...TIME_UNIT_CONFIG,\n ...PERCENT_UNIT_CONFIG,\n ...DECIMAL_UNIT_CONFIG,\n ...BYTES_UNIT_CONFIG,\n ...THROUGHPUT_UNIT_CONFIG,\n ...CURRENCY_UNIT_CONFIG,\n} as const;\n\nexport type FormatOptions =\n | TimeFormatOptions\n | PercentFormatOptions\n | DecimalFormatOptions\n | BytesFormatOptions\n | ThroughputFormatOptions\n | CurrencyFormatOptions;\n\ntype HasDecimalPlaces<UnitOpt> = UnitOpt extends { decimalPlaces?: number } ? UnitOpt : never;\ntype HasShortValues<UnitOpt> = UnitOpt extends { shortValues?: boolean } ? UnitOpt : never;\n\nexport function formatValue(value: number, formatOptions?: FormatOptions): string {\n if (formatOptions === undefined) {\n return value.toString();\n }\n\n if (isBytesUnit(formatOptions)) {\n return formatBytes(value, formatOptions);\n }\n\n if (isDecimalUnit(formatOptions)) {\n return formatDecimal(value, formatOptions);\n }\n\n if (isPercentUnit(formatOptions)) {\n return formatPercent(value, formatOptions);\n }\n\n if (isTimeUnit(formatOptions)) {\n return formatTime(value, formatOptions);\n }\n\n if (isThroughputUnit(formatOptions)) {\n return formatThroughput(value, formatOptions);\n }\n\n if (isCurrencyUnit(formatOptions)) {\n return formatCurrency(value, formatOptions);\n }\n\n const exhaustive: never = formatOptions;\n throw new Error(`Unknown unit options ${exhaustive}`);\n}\n\nexport function getUnitConfig(formatOptions: FormatOptions): UnitConfig {\n const unit = formatOptions.unit ?? 'decimal';\n return UNIT_CONFIG[unit];\n}\n\nexport function getUnitGroup(formatOptions: FormatOptions): UnitGroup {\n return getUnitConfig(formatOptions).group ?? 'Decimal';\n}\n\nexport function getUnitGroupConfig(formatOptions: FormatOptions): UnitGroupConfig {\n const unitConfig = getUnitConfig(formatOptions);\n return UNIT_GROUP_CONFIG[unitConfig.group ?? 'Decimal'];\n}\n\n// Type guards\nexport function isTimeUnit(formatOptions: FormatOptions): formatOptions is TimeFormatOptions {\n return getUnitGroup(formatOptions) === 'Time';\n}\n\nexport function isPercentUnit(formatOptions: FormatOptions): formatOptions is PercentFormatOptions {\n return getUnitGroup(formatOptions) === 'Percent';\n}\n\nexport function isDecimalUnit(formatOptions: FormatOptions): formatOptions is DecimalFormatOptions {\n return getUnitGroup(formatOptions) === 'Decimal';\n}\n\nexport function isBytesUnit(formatOptions: FormatOptions): formatOptions is BytesFormatOptions {\n return getUnitGroup(formatOptions) === 'Bytes';\n}\n\nexport function isUnitWithDecimalPlaces(\n formatOptions: FormatOptions\n): formatOptions is HasDecimalPlaces<FormatOptions> {\n const groupConfig = getUnitGroupConfig(formatOptions);\n\n return !!groupConfig.decimalPlaces;\n}\n\nexport function isUnitWithShortValues(formatOptions: FormatOptions): formatOptions is HasShortValues<FormatOptions> {\n const groupConfig = getUnitGroupConfig(formatOptions);\n\n return !!groupConfig.shortValues;\n}\n\nexport function isThroughputUnit(formatOptions: FormatOptions): formatOptions is ThroughputFormatOptions {\n return getUnitGroup(formatOptions) === 'Throughput';\n}\n\nexport function isCurrencyUnit(formatOptions: FormatOptions): formatOptions is CurrencyFormatOptions {\n return getUnitGroup(formatOptions) === 'Currency';\n}\n"],"names":["formatBytes","BYTES_GROUP_CONFIG","BYTES_UNIT_CONFIG","formatDecimal","DECIMAL_GROUP_CONFIG","DECIMAL_UNIT_CONFIG","formatPercent","PERCENT_GROUP_CONFIG","PERCENT_UNIT_CONFIG","formatTime","TIME_GROUP_CONFIG","TIME_UNIT_CONFIG","formatThroughput","THROUGHPUT_GROUP_CONFIG","THROUGHPUT_UNIT_CONFIG","formatCurrency","CURRENCY_GROUP_CONFIG","CURRENCY_UNIT_CONFIG","UNIT_GROUP_CONFIG","Time","Percent","Decimal","Bytes","Throughput","Currency","UNIT_CONFIG","formatValue","value","formatOptions","undefined","toString","isBytesUnit","isDecimalUnit","isPercentUnit","isTimeUnit","isThroughputUnit","isCurrencyUnit","exhaustive","Error","getUnitConfig","unit","getUnitGroup","group","getUnitGroupConfig","unitConfig","isUnitWithDecimalPlaces","groupConfig","decimalPlaces","isUnitWithShortValues","shortValues"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAA4CC,kBAAkB,EAAEC,iBAAiB,QAAQ,UAAU;AACvH,SACEC,aAAa,EAEbC,oBAAoB,EACpBC,mBAAmB,QACd,YAAY;AACnB,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WAAW,CAACe,KAAK;AAC1B;AAEA,OAAO,SAASC,aAAab,aAA4B;IACvD,OAAOW,cAAcX,eAAec,KAAK,IAAI;AAC/C;AAEA,OAAO,SAASC,mBAAmBf,aAA4B;IAC7D,MAAMgB,aAAaL,cAAcX;IACjC,OAAOV,iBAAiB,CAAC0B,WAAWF,KAAK,IAAI,UAAU;AACzD;AAEA,cAAc;AACd,OAAO,SAASR,WAAWN,aAA4B;IACrD,OAAOa,aAAab,mBAAmB;AACzC;AAEA,OAAO,SAASK,cAAcL,aAA4B;IACxD,OAAOa,aAAab,mBAAmB;AACzC;AAEA,OAAO,SAASI,cAAcJ,aAA4B;IACxD,OAAOa,aAAab,mBAAmB;AACzC;AAEA,OAAO,SAASG,YAAYH,aAA4B;IACtD,OAAOa,aAAab,mBAAmB;AACzC;AAEA,OAAO,SAASiB,wBACdjB,aAA4B;IAE5B,MAAMkB,cAAcH,mBAAmBf;IAEvC,OAAO,CAAC,CAACkB,YAAYC,aAAa;AACpC;AAEA,OAAO,SAASC,sBAAsBpB,aAA4B;IAChE,MAAMkB,cAAcH,mBAAmBf;IAEvC,OAAO,CAAC,CAACkB,YAAYG,WAAW;AAClC;AAEA,OAAO,SAASd,iBAAiBP,aAA4B;IAC3D,OAAOa,aAAab,mBAAmB;AACzC;AAEA,OAAO,SAASQ,eAAeR,aAA4B;IACzD,OAAOa,aAAab,mBAAmB;AACzC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/units.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { formatBytes, BytesFormatOptions as BytesFormatOptions, BYTES_GROUP_CONFIG, BYTES_UNIT_CONFIG } from './bytes';\nimport { formatBits, BitsFormatOptions as BitsFormatOptions, BITS_GROUP_CONFIG, BITS_UNIT_CONFIG } from './bits';\nimport {\n formatDecimal,\n DecimalFormatOptions as DecimalFormatOptions,\n DECIMAL_GROUP_CONFIG,\n DECIMAL_UNIT_CONFIG,\n} from './decimal';\nimport {\n formatPercent,\n PercentFormatOptions as PercentFormatOptions,\n PERCENT_GROUP_CONFIG,\n PERCENT_UNIT_CONFIG,\n} from './percent';\nimport {\n TEMPERATURE_GROUP_CONFIG,\n formatTemperature,\n TEMPERATURE_UNIT_CONFIG,\n TemperatureFormatOptions,\n} from './temperature';\nimport { formatTime, TimeFormatOptions as TimeFormatOptions, TIME_GROUP_CONFIG, TIME_UNIT_CONFIG } from './time';\nimport { UnitGroup, UnitGroupConfig, UnitConfig } from './types';\nimport {\n formatThroughput,\n THROUGHPUT_GROUP_CONFIG,\n THROUGHPUT_UNIT_CONFIG,\n ThroughputFormatOptions,\n} from './throughput';\nimport { formatCurrency, CURRENCY_GROUP_CONFIG, CURRENCY_UNIT_CONFIG, CurrencyFormatOptions } from './currency';\nimport { formatDate, DateFormatOptions, DATE_GROUP_CONFIG, DATE_UNIT_CONFIG } from './date';\n\n/**\n * Most of the number formatting is based on Intl.NumberFormat, which is built into JavaScript.\n * Prefer Intl.NumbeFormat because it covers most use cases and will continue to be supported with time.\n *\n * To format bytes, we also make use of the `numbro` package,\n * because it can handle adding units like KB, MB, GB, etc. correctly.\n */\n\nexport const UNIT_GROUP_CONFIG: Readonly<Record<UnitGroup, UnitGroupConfig>> = {\n Time: TIME_GROUP_CONFIG,\n Percent: PERCENT_GROUP_CONFIG,\n Decimal: DECIMAL_GROUP_CONFIG,\n Bytes: BYTES_GROUP_CONFIG,\n Bits: BITS_GROUP_CONFIG,\n Throughput: THROUGHPUT_GROUP_CONFIG,\n Currency: CURRENCY_GROUP_CONFIG,\n Temperature: TEMPERATURE_GROUP_CONFIG,\n Date: DATE_GROUP_CONFIG,\n};\nexport const UNIT_CONFIG = {\n ...TIME_UNIT_CONFIG,\n ...PERCENT_UNIT_CONFIG,\n ...DECIMAL_UNIT_CONFIG,\n ...BYTES_UNIT_CONFIG,\n ...BITS_UNIT_CONFIG,\n ...THROUGHPUT_UNIT_CONFIG,\n ...CURRENCY_UNIT_CONFIG,\n ...TEMPERATURE_UNIT_CONFIG,\n ...DATE_UNIT_CONFIG,\n} as const;\n\nexport type FormatOptions =\n | TimeFormatOptions\n | PercentFormatOptions\n | DecimalFormatOptions\n | BytesFormatOptions\n | BitsFormatOptions\n | ThroughputFormatOptions\n | CurrencyFormatOptions\n | TemperatureFormatOptions\n | DateFormatOptions;\n\ntype HasDecimalPlaces<UnitOpt> = UnitOpt extends { decimalPlaces?: number } ? UnitOpt : never;\ntype HasShortValues<UnitOpt> = UnitOpt extends { shortValues?: boolean } ? UnitOpt : never;\n\nexport function formatValue(value: number, formatOptions?: FormatOptions): string {\n if (!formatOptions) {\n return value.toString();\n }\n\n if (isBytesUnit(formatOptions)) {\n return formatBytes(value, formatOptions);\n }\n\n if (isBitsUnit(formatOptions)) {\n return formatBits(value, formatOptions);\n }\n\n if (isDecimalUnit(formatOptions)) {\n return formatDecimal(value, formatOptions);\n }\n\n if (isPercentUnit(formatOptions)) {\n return formatPercent(value, formatOptions);\n }\n\n if (isTimeUnit(formatOptions)) {\n return formatTime(value, formatOptions);\n }\n\n if (isThroughputUnit(formatOptions)) {\n return formatThroughput(value, formatOptions);\n }\n\n if (isCurrencyUnit(formatOptions)) {\n return formatCurrency(value, formatOptions);\n }\n\n if (isDateUnit(formatOptions)) {\n return formatDate(value, formatOptions);\n }\n\n if (isTemperatureUnit(formatOptions)) {\n return formatTemperature(value, formatOptions);\n }\n\n const exhaustive: never = formatOptions;\n throw new Error(`Unknown unit options ${exhaustive}`);\n}\n\nexport function getUnitConfig(formatOptions: FormatOptions): UnitConfig {\n const unit = formatOptions.unit ?? 'decimal';\n return UNIT_CONFIG[unit];\n}\n\nexport function getUnitGroup(formatOptions: FormatOptions): UnitGroup {\n return getUnitConfig(formatOptions).group ?? 'Decimal';\n}\n\nexport function getUnitGroupConfig(formatOptions: FormatOptions): UnitGroupConfig {\n const unitConfig = getUnitConfig(formatOptions);\n return UNIT_GROUP_CONFIG[unitConfig.group ?? 'Decimal'];\n}\n\n// Type guards\nexport function isTimeUnit(formatOptions: FormatOptions): formatOptions is TimeFormatOptions {\n return getUnitGroup(formatOptions) === 'Time';\n}\n\nexport function isPercentUnit(formatOptions: FormatOptions): formatOptions is PercentFormatOptions {\n return getUnitGroup(formatOptions) === 'Percent';\n}\n\nexport function isDecimalUnit(formatOptions: FormatOptions): formatOptions is DecimalFormatOptions {\n return getUnitGroup(formatOptions) === 'Decimal';\n}\n\nexport function isBytesUnit(formatOptions: FormatOptions): formatOptions is BytesFormatOptions {\n return getUnitGroup(formatOptions) === 'Bytes';\n}\n\nexport function isBitsUnit(formatOptions: FormatOptions): formatOptions is BitsFormatOptions {\n return getUnitGroup(formatOptions) === 'Bits';\n}\n\nexport function isUnitWithDecimalPlaces(\n formatOptions: FormatOptions\n): formatOptions is HasDecimalPlaces<FormatOptions> {\n const groupConfig = getUnitGroupConfig(formatOptions);\n\n return !!groupConfig.decimalPlaces;\n}\n\nexport function isUnitWithShortValues(formatOptions: FormatOptions): formatOptions is HasShortValues<FormatOptions> {\n const groupConfig = getUnitGroupConfig(formatOptions);\n\n return !!groupConfig.shortValues;\n}\n\nexport function isThroughputUnit(formatOptions: FormatOptions): formatOptions is ThroughputFormatOptions {\n return getUnitGroup(formatOptions) === 'Throughput';\n}\n\nexport function isCurrencyUnit(formatOptions: FormatOptions): formatOptions is CurrencyFormatOptions {\n return getUnitGroup(formatOptions) === 'Currency';\n}\n\nexport function isDateUnit(formatOptions: FormatOptions): formatOptions is DateFormatOptions {\n return getUnitGroup(formatOptions) === 'Date';\n}\n\nexport function isTemperatureUnit(formatOptions: FormatOptions): formatOptions is TemperatureFormatOptions {\n return getUnitGroup(formatOptions) === 'Temperature';\n}\n"],"names":["formatBytes","BYTES_GROUP_CONFIG","BYTES_UNIT_CONFIG","formatBits","BITS_GROUP_CONFIG","BITS_UNIT_CONFIG","formatDecimal","DECIMAL_GROUP_CONFIG","DECIMAL_UNIT_CONFIG","formatPercent","PERCENT_GROUP_CONFIG","PERCENT_UNIT_CONFIG","TEMPERATURE_GROUP_CONFIG","formatTemperature","TEMPERATURE_UNIT_CONFIG","formatTime","TIME_GROUP_CONFIG","TIME_UNIT_CONFIG","formatThroughput","THROUGHPUT_GROUP_CONFIG","THROUGHPUT_UNIT_CONFIG","formatCurrency","CURRENCY_GROUP_CONFIG","CURRENCY_UNIT_CONFIG","formatDate","DATE_GROUP_CONFIG","DATE_UNIT_CONFIG","UNIT_GROUP_CONFIG","Time","Percent","Decimal","Bytes","Bits","Throughput","Currency","Temperature","Date","UNIT_CONFIG","formatValue","value","formatOptions","toString","isBytesUnit","isBitsUnit","isDecimalUnit","isPercentUnit","isTimeUnit","isThroughputUnit","isCurrencyUnit","isDateUnit","isTemperatureUnit","exhaustive","Error","getUnitConfig","unit","getUnitGroup","group","getUnitGroupConfig","unitConfig","isUnitWithDecimalPlaces","groupConfig","decimalPlaces","isUnitWithShortValues","shortValues"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAA4CC,kBAAkB,EAAEC,iBAAiB,QAAQ,UAAU;AACvH,SAASC,UAAU,EAA0CC,iBAAiB,EAAEC,gBAAgB,QAAQ,SAAS;AACjH,SACEC,aAAa,EAEbC,oBAAoB,EACpBC,mBAAmB,QACd,YAAY;AACnB,SACEC,aAAa,EAEbC,oBAAoB,EACpBC,mBAAmB,QACd,YAAY;AACnB,SACEC,wBAAwB,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af,mBAAmB;AACzC;AAEA,OAAO,SAASQ,eAAeR,aAA4B;IACzD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASS,WAAWT,aAA4B;IACrD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASU,kBAAkBV,aAA4B;IAC5D,OAAOe,aAAaf,mBAAmB;AACzC"}
|
|
@@ -10,26 +10,26 @@ export declare const datasourceSchema: z.ZodObject<{
|
|
|
10
10
|
} & {
|
|
11
11
|
project: z.ZodString;
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
project: string;
|
|
14
13
|
name: string;
|
|
15
|
-
}, {
|
|
16
14
|
project: string;
|
|
15
|
+
}, {
|
|
17
16
|
name: string;
|
|
17
|
+
project: string;
|
|
18
18
|
}>;
|
|
19
19
|
spec: z.ZodType<DatasourceSpec<import("../model").UnknownSpec>, z.ZodTypeDef, DatasourceSpec<import("../model").UnknownSpec>>;
|
|
20
20
|
}, "strip", z.ZodTypeAny, {
|
|
21
21
|
kind: "Datasource";
|
|
22
22
|
spec: DatasourceSpec<import("../model").UnknownSpec>;
|
|
23
23
|
metadata: {
|
|
24
|
-
project: string;
|
|
25
24
|
name: string;
|
|
25
|
+
project: string;
|
|
26
26
|
};
|
|
27
27
|
}, {
|
|
28
28
|
kind: "Datasource";
|
|
29
29
|
spec: DatasourceSpec<import("../model").UnknownSpec>;
|
|
30
30
|
metadata: {
|
|
31
|
-
project: string;
|
|
32
31
|
name: string;
|
|
32
|
+
project: string;
|
|
33
33
|
};
|
|
34
34
|
}>;
|
|
35
35
|
export declare const globalDatasourceSchema: z.ZodObject<{
|
|
@@ -12,10 +12,10 @@ export declare const projectMetadataSchema: z.ZodObject<{
|
|
|
12
12
|
} & {
|
|
13
13
|
project: z.ZodString;
|
|
14
14
|
}, "strip", z.ZodTypeAny, {
|
|
15
|
-
project: string;
|
|
16
15
|
name: string;
|
|
17
|
-
}, {
|
|
18
16
|
project: string;
|
|
17
|
+
}, {
|
|
19
18
|
name: string;
|
|
19
|
+
project: string;
|
|
20
20
|
}>;
|
|
21
21
|
//# sourceMappingURL=metadata.d.ts.map
|
package/dist/schema/role.d.ts
CHANGED
|
@@ -9,26 +9,26 @@ export declare const roleSchema: z.ZodObject<{
|
|
|
9
9
|
} & {
|
|
10
10
|
project: z.ZodString;
|
|
11
11
|
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
project: string;
|
|
13
12
|
name: string;
|
|
14
|
-
}, {
|
|
15
13
|
project: string;
|
|
14
|
+
}, {
|
|
16
15
|
name: string;
|
|
16
|
+
project: string;
|
|
17
17
|
}>;
|
|
18
18
|
spec: z.ZodType<RoleSpec, z.ZodTypeDef, RoleSpec>;
|
|
19
19
|
}, "strip", z.ZodTypeAny, {
|
|
20
20
|
kind: "Role";
|
|
21
21
|
spec: RoleSpec;
|
|
22
22
|
metadata: {
|
|
23
|
-
project: string;
|
|
24
23
|
name: string;
|
|
24
|
+
project: string;
|
|
25
25
|
};
|
|
26
26
|
}, {
|
|
27
27
|
kind: "Role";
|
|
28
28
|
spec: RoleSpec;
|
|
29
29
|
metadata: {
|
|
30
|
-
project: string;
|
|
31
30
|
name: string;
|
|
31
|
+
project: string;
|
|
32
32
|
};
|
|
33
33
|
}>;
|
|
34
34
|
export declare const globalRoleSchema: z.ZodObject<{
|
|
@@ -9,26 +9,26 @@ export declare const roleBindingSchema: z.ZodObject<{
|
|
|
9
9
|
} & {
|
|
10
10
|
project: z.ZodString;
|
|
11
11
|
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
project: string;
|
|
13
12
|
name: string;
|
|
14
|
-
}, {
|
|
15
13
|
project: string;
|
|
14
|
+
}, {
|
|
16
15
|
name: string;
|
|
16
|
+
project: string;
|
|
17
17
|
}>;
|
|
18
18
|
spec: z.ZodType<RoleBindingSpec, z.ZodTypeDef, RoleBindingSpec>;
|
|
19
19
|
}, "strip", z.ZodTypeAny, {
|
|
20
20
|
kind: "RoleBinding";
|
|
21
21
|
spec: RoleBindingSpec;
|
|
22
22
|
metadata: {
|
|
23
|
-
project: string;
|
|
24
23
|
name: string;
|
|
24
|
+
project: string;
|
|
25
25
|
};
|
|
26
26
|
}, {
|
|
27
27
|
kind: "RoleBinding";
|
|
28
28
|
spec: RoleBindingSpec;
|
|
29
29
|
metadata: {
|
|
30
|
-
project: string;
|
|
31
30
|
name: string;
|
|
31
|
+
project: string;
|
|
32
32
|
};
|
|
33
33
|
}>;
|
|
34
34
|
export declare const globalRoleBindingSchema: z.ZodObject<{
|
package/dist/schema/secret.d.ts
CHANGED
|
@@ -257,11 +257,11 @@ export declare const secretSchema: z.ZodObject<{
|
|
|
257
257
|
} & {
|
|
258
258
|
project: z.ZodString;
|
|
259
259
|
}, "strip", z.ZodTypeAny, {
|
|
260
|
-
project: string;
|
|
261
260
|
name: string;
|
|
262
|
-
}, {
|
|
263
261
|
project: string;
|
|
262
|
+
}, {
|
|
264
263
|
name: string;
|
|
264
|
+
project: string;
|
|
265
265
|
}>;
|
|
266
266
|
spec: z.ZodEffects<z.ZodObject<{
|
|
267
267
|
basicAuth: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
@@ -548,8 +548,8 @@ export declare const secretSchema: z.ZodObject<{
|
|
|
548
548
|
} | undefined;
|
|
549
549
|
};
|
|
550
550
|
metadata: {
|
|
551
|
-
project: string;
|
|
552
551
|
name: string;
|
|
552
|
+
project: string;
|
|
553
553
|
};
|
|
554
554
|
}, {
|
|
555
555
|
kind: "Secret";
|
|
@@ -585,8 +585,8 @@ export declare const secretSchema: z.ZodObject<{
|
|
|
585
585
|
} | undefined;
|
|
586
586
|
};
|
|
587
587
|
metadata: {
|
|
588
|
-
project: string;
|
|
589
588
|
name: string;
|
|
589
|
+
project: string;
|
|
590
590
|
};
|
|
591
591
|
}>;
|
|
592
592
|
export declare const globalSecretSchema: z.ZodObject<{
|
|
@@ -929,11 +929,11 @@ export declare const secretsEditorSchema: z.ZodDiscriminatedUnion<"kind", [z.Zod
|
|
|
929
929
|
} & {
|
|
930
930
|
project: z.ZodString;
|
|
931
931
|
}, "strip", z.ZodTypeAny, {
|
|
932
|
-
project: string;
|
|
933
932
|
name: string;
|
|
934
|
-
}, {
|
|
935
933
|
project: string;
|
|
934
|
+
}, {
|
|
936
935
|
name: string;
|
|
936
|
+
project: string;
|
|
937
937
|
}>;
|
|
938
938
|
spec: z.ZodEffects<z.ZodObject<{
|
|
939
939
|
basicAuth: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
@@ -1220,8 +1220,8 @@ export declare const secretsEditorSchema: z.ZodDiscriminatedUnion<"kind", [z.Zod
|
|
|
1220
1220
|
} | undefined;
|
|
1221
1221
|
};
|
|
1222
1222
|
metadata: {
|
|
1223
|
-
project: string;
|
|
1224
1223
|
name: string;
|
|
1224
|
+
project: string;
|
|
1225
1225
|
};
|
|
1226
1226
|
}, {
|
|
1227
1227
|
kind: "Secret";
|
|
@@ -1257,8 +1257,8 @@ export declare const secretsEditorSchema: z.ZodDiscriminatedUnion<"kind", [z.Zod
|
|
|
1257
1257
|
} | undefined;
|
|
1258
1258
|
};
|
|
1259
1259
|
metadata: {
|
|
1260
|
-
project: string;
|
|
1261
1260
|
name: string;
|
|
1261
|
+
project: string;
|
|
1262
1262
|
};
|
|
1263
1263
|
}>, z.ZodObject<{
|
|
1264
1264
|
kind: z.ZodLiteral<"GlobalSecret">;
|
|
@@ -35,26 +35,26 @@ export declare const variableSchema: z.ZodObject<{
|
|
|
35
35
|
} & {
|
|
36
36
|
project: z.ZodString;
|
|
37
37
|
}, "strip", z.ZodTypeAny, {
|
|
38
|
-
project: string;
|
|
39
38
|
name: string;
|
|
40
|
-
}, {
|
|
41
39
|
project: string;
|
|
40
|
+
}, {
|
|
42
41
|
name: string;
|
|
42
|
+
project: string;
|
|
43
43
|
}>;
|
|
44
44
|
spec: z.ZodType<TextVariableDefinition | ListVariableDefinition, z.ZodTypeDef, TextVariableDefinition | ListVariableDefinition>;
|
|
45
45
|
}, "strip", z.ZodTypeAny, {
|
|
46
46
|
kind: "Variable";
|
|
47
47
|
spec: TextVariableDefinition | ListVariableDefinition;
|
|
48
48
|
metadata: {
|
|
49
|
-
project: string;
|
|
50
49
|
name: string;
|
|
50
|
+
project: string;
|
|
51
51
|
};
|
|
52
52
|
}, {
|
|
53
53
|
kind: "Variable";
|
|
54
54
|
spec: TextVariableDefinition | ListVariableDefinition;
|
|
55
55
|
metadata: {
|
|
56
|
-
project: string;
|
|
57
56
|
name: string;
|
|
57
|
+
project: string;
|
|
58
58
|
};
|
|
59
59
|
}>;
|
|
60
60
|
export declare const globalVariableSchema: z.ZodObject<{
|
|
@@ -64,26 +64,26 @@ export declare const globalVariableSchema: z.ZodObject<{
|
|
|
64
64
|
} & {
|
|
65
65
|
project: z.ZodString;
|
|
66
66
|
}, "strip", z.ZodTypeAny, {
|
|
67
|
-
project: string;
|
|
68
67
|
name: string;
|
|
69
|
-
}, {
|
|
70
68
|
project: string;
|
|
69
|
+
}, {
|
|
71
70
|
name: string;
|
|
71
|
+
project: string;
|
|
72
72
|
}>;
|
|
73
73
|
spec: z.ZodType<TextVariableDefinition | ListVariableDefinition, z.ZodTypeDef, TextVariableDefinition | ListVariableDefinition>;
|
|
74
74
|
}, "strip", z.ZodTypeAny, {
|
|
75
75
|
kind: "GlobalVariable";
|
|
76
76
|
spec: TextVariableDefinition | ListVariableDefinition;
|
|
77
77
|
metadata: {
|
|
78
|
-
project: string;
|
|
79
78
|
name: string;
|
|
79
|
+
project: string;
|
|
80
80
|
};
|
|
81
81
|
}, {
|
|
82
82
|
kind: "GlobalVariable";
|
|
83
83
|
spec: TextVariableDefinition | ListVariableDefinition;
|
|
84
84
|
metadata: {
|
|
85
|
-
project: string;
|
|
86
85
|
name: string;
|
|
86
|
+
project: string;
|
|
87
87
|
};
|
|
88
88
|
}>;
|
|
89
89
|
export declare const variablesSchema: z.ZodSchema<Variable>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/core",
|
|
3
|
-
"version": "0.53.0-beta.
|
|
3
|
+
"version": "0.53.0-beta.3",
|
|
4
4
|
"description": "Core functionality consumed by both the Perses UI and plugins",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|