@perses-dev/core 0.52.0-beta.2 → 0.52.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/constants/dashboard-defaults.js.map +1 -0
- package/dist/{src/model/notice.js.map → constants/index.js.map} +1 -1
- package/dist/index.js.map +1 -0
- package/dist/model/calculations.js.map +1 -0
- package/dist/model/dashboard.js.map +1 -0
- package/dist/model/datasource.js.map +1 -0
- package/dist/model/definitions.js.map +1 -0
- package/dist/{src/model/http.js.map → model/display.js.map} +1 -1
- package/dist/model/ephemeraldashboard.js.map +1 -0
- package/dist/model/http-proxy.js.map +1 -0
- package/dist/model/http.js.map +1 -0
- package/dist/model/index.js.map +1 -0
- package/dist/model/kind.js.map +1 -0
- package/dist/model/layout.js.map +1 -0
- package/dist/model/legend.js.map +1 -0
- package/dist/model/notice.js.map +1 -0
- package/dist/model/otlp/common/v1/common.js.map +1 -0
- package/dist/model/otlp/index.js.map +1 -0
- package/dist/model/otlp/resource/v1/resource.js.map +1 -0
- package/dist/model/otlp/trace/v1/trace.js.map +1 -0
- package/dist/model/panels.js.map +1 -0
- package/dist/model/profile-data.js.map +1 -0
- package/dist/model/project.js.map +1 -0
- package/dist/model/query.js.map +1 -0
- package/dist/model/resource.js.map +1 -0
- package/dist/model/rolebindings.js.map +1 -0
- package/dist/model/roles.js.map +1 -0
- package/dist/model/secrets.js.map +1 -0
- package/dist/model/thresholds.js.map +1 -0
- package/dist/model/time-series-data.js.map +1 -0
- package/dist/model/time-series-queries.js.map +1 -0
- package/dist/model/time.js.map +1 -0
- package/dist/model/trace-data.js.map +1 -0
- package/dist/model/transforms.js.map +1 -0
- package/dist/model/units/bytes.js.map +1 -0
- package/dist/model/units/constants.js.map +1 -0
- package/dist/model/units/currency.js.map +1 -0
- package/dist/model/units/decimal.js.map +1 -0
- package/dist/model/units/index.js.map +1 -0
- package/dist/model/units/percent.js.map +1 -0
- package/dist/model/units/throughput.js.map +1 -0
- package/dist/model/units/time.js.map +1 -0
- package/dist/model/units/types.js.map +1 -0
- package/dist/model/units/units.js.map +1 -0
- package/dist/model/units/utils.js.map +1 -0
- package/dist/model/user.js.map +1 -0
- package/dist/model/value-mapping.js.map +1 -0
- package/dist/model/variables.js.map +1 -0
- package/dist/schema/datasource.js.map +1 -0
- package/dist/schema/display.js.map +1 -0
- package/dist/schema/duration.js.map +1 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/metadata.js.map +1 -0
- package/dist/schema/panel.js.map +1 -0
- package/dist/schema/plugin.js.map +1 -0
- package/dist/schema/role.js.map +1 -0
- package/dist/schema/rolebinding.js.map +1 -0
- package/dist/schema/secret.js.map +1 -0
- package/dist/schema/user.js.map +1 -0
- package/dist/schema/variable.js.map +1 -0
- package/dist/{src/model/display.js.map → test/setup-tests.js.map} +1 -1
- package/dist/utils/event.js.map +1 -0
- package/dist/utils/fetch.js.map +1 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/is-empty-object.js.map +1 -0
- package/dist/utils/mathjs.js.map +1 -0
- package/dist/utils/memo.js.map +1 -0
- package/dist/utils/panel-refs.js.map +1 -0
- package/dist/utils/regexp.js.map +1 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/time-series-data.js.map +1 -0
- package/dist/utils/transform-data.js.map +1 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/value-mapping.js.map +1 -0
- package/package.json +3 -3
- package/dist/src/constants/dashboard-defaults.js.map +0 -1
- package/dist/src/constants/index.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/model/calculations.js.map +0 -1
- package/dist/src/model/dashboard.js.map +0 -1
- package/dist/src/model/datasource.js.map +0 -1
- package/dist/src/model/definitions.js.map +0 -1
- package/dist/src/model/ephemeraldashboard.js.map +0 -1
- package/dist/src/model/http-proxy.js.map +0 -1
- package/dist/src/model/index.js.map +0 -1
- package/dist/src/model/kind.js.map +0 -1
- package/dist/src/model/layout.js.map +0 -1
- package/dist/src/model/legend.js.map +0 -1
- package/dist/src/model/otlp/common/v1/common.js.map +0 -1
- package/dist/src/model/otlp/index.js.map +0 -1
- package/dist/src/model/otlp/resource/v1/resource.js.map +0 -1
- package/dist/src/model/otlp/trace/v1/trace.js.map +0 -1
- package/dist/src/model/panels.js.map +0 -1
- package/dist/src/model/profile-data.js.map +0 -1
- package/dist/src/model/project.js.map +0 -1
- package/dist/src/model/query.js.map +0 -1
- package/dist/src/model/resource.js.map +0 -1
- package/dist/src/model/rolebindings.js.map +0 -1
- package/dist/src/model/roles.js.map +0 -1
- package/dist/src/model/secrets.js.map +0 -1
- package/dist/src/model/thresholds.js.map +0 -1
- package/dist/src/model/time-series-data.js.map +0 -1
- package/dist/src/model/time-series-queries.js.map +0 -1
- package/dist/src/model/time.js.map +0 -1
- package/dist/src/model/trace-data.js.map +0 -1
- package/dist/src/model/transforms.js.map +0 -1
- package/dist/src/model/units/bytes.js.map +0 -1
- package/dist/src/model/units/constants.js.map +0 -1
- package/dist/src/model/units/currency.js.map +0 -1
- package/dist/src/model/units/decimal.js.map +0 -1
- package/dist/src/model/units/index.js.map +0 -1
- package/dist/src/model/units/percent.js.map +0 -1
- package/dist/src/model/units/throughput.js.map +0 -1
- package/dist/src/model/units/time.js.map +0 -1
- package/dist/src/model/units/types.js.map +0 -1
- package/dist/src/model/units/units.js.map +0 -1
- package/dist/src/model/units/utils.js.map +0 -1
- package/dist/src/model/user.js.map +0 -1
- package/dist/src/model/value-mapping.js.map +0 -1
- package/dist/src/model/variables.js.map +0 -1
- package/dist/src/schema/datasource.js.map +0 -1
- package/dist/src/schema/display.js.map +0 -1
- package/dist/src/schema/duration.js.map +0 -1
- package/dist/src/schema/index.js.map +0 -1
- package/dist/src/schema/metadata.js.map +0 -1
- package/dist/src/schema/panel.js.map +0 -1
- package/dist/src/schema/plugin.js.map +0 -1
- package/dist/src/schema/role.js.map +0 -1
- package/dist/src/schema/rolebinding.js.map +0 -1
- package/dist/src/schema/secret.js.map +0 -1
- package/dist/src/schema/user.js.map +0 -1
- package/dist/src/schema/variable.js.map +0 -1
- package/dist/src/test/setup-tests.js.map +0 -1
- package/dist/src/utils/event.js.map +0 -1
- package/dist/src/utils/fetch.js.map +0 -1
- package/dist/src/utils/index.js.map +0 -1
- package/dist/src/utils/is-empty-object.js.map +0 -1
- package/dist/src/utils/mathjs.js.map +0 -1
- package/dist/src/utils/memo.js.map +0 -1
- package/dist/src/utils/panel-refs.js.map +0 -1
- package/dist/src/utils/regexp.js.map +0 -1
- package/dist/src/utils/text.js.map +0 -1
- package/dist/src/utils/time-series-data.js.map +0 -1
- package/dist/src/utils/transform-data.js.map +0 -1
- package/dist/src/utils/types.js.map +0 -1
- package/dist/src/utils/value-mapping.js.map +0 -1
- /package/dist/cjs/{src/constants → constants}/dashboard-defaults.js +0 -0
- /package/dist/cjs/{src/constants → constants}/index.js +0 -0
- /package/dist/cjs/{src/index.js → index.js} +0 -0
- /package/dist/cjs/{src/model → model}/calculations.js +0 -0
- /package/dist/cjs/{src/model → model}/dashboard.js +0 -0
- /package/dist/cjs/{src/model → model}/datasource.js +0 -0
- /package/dist/cjs/{src/model → model}/definitions.js +0 -0
- /package/dist/cjs/{src/model → model}/display.js +0 -0
- /package/dist/cjs/{src/model → model}/ephemeraldashboard.js +0 -0
- /package/dist/cjs/{src/model → model}/http-proxy.js +0 -0
- /package/dist/cjs/{src/model → model}/http.js +0 -0
- /package/dist/cjs/{src/model → model}/index.js +0 -0
- /package/dist/cjs/{src/model → model}/kind.js +0 -0
- /package/dist/cjs/{src/model → model}/layout.js +0 -0
- /package/dist/cjs/{src/model → model}/legend.js +0 -0
- /package/dist/cjs/{src/model → model}/notice.js +0 -0
- /package/dist/cjs/{src/model → model}/otlp/common/v1/common.js +0 -0
- /package/dist/cjs/{src/model → model}/otlp/index.js +0 -0
- /package/dist/cjs/{src/model → model}/otlp/resource/v1/resource.js +0 -0
- /package/dist/cjs/{src/model → model}/otlp/trace/v1/trace.js +0 -0
- /package/dist/cjs/{src/model → model}/panels.js +0 -0
- /package/dist/cjs/{src/model → model}/profile-data.js +0 -0
- /package/dist/cjs/{src/model → model}/project.js +0 -0
- /package/dist/cjs/{src/model → model}/query.js +0 -0
- /package/dist/cjs/{src/model → model}/resource.js +0 -0
- /package/dist/cjs/{src/model → model}/rolebindings.js +0 -0
- /package/dist/cjs/{src/model → model}/roles.js +0 -0
- /package/dist/cjs/{src/model → model}/secrets.js +0 -0
- /package/dist/cjs/{src/model → model}/thresholds.js +0 -0
- /package/dist/cjs/{src/model → model}/time-series-data.js +0 -0
- /package/dist/cjs/{src/model → model}/time-series-queries.js +0 -0
- /package/dist/cjs/{src/model → model}/time.js +0 -0
- /package/dist/cjs/{src/model → model}/trace-data.js +0 -0
- /package/dist/cjs/{src/model → model}/transforms.js +0 -0
- /package/dist/cjs/{src/model → model}/units/bytes.js +0 -0
- /package/dist/cjs/{src/model → model}/units/constants.js +0 -0
- /package/dist/cjs/{src/model → model}/units/currency.js +0 -0
- /package/dist/cjs/{src/model → model}/units/decimal.js +0 -0
- /package/dist/cjs/{src/model → model}/units/index.js +0 -0
- /package/dist/cjs/{src/model → model}/units/percent.js +0 -0
- /package/dist/cjs/{src/model → model}/units/throughput.js +0 -0
- /package/dist/cjs/{src/model → model}/units/time.js +0 -0
- /package/dist/cjs/{src/model → model}/units/types.js +0 -0
- /package/dist/cjs/{src/model → model}/units/units.js +0 -0
- /package/dist/cjs/{src/model → model}/units/utils.js +0 -0
- /package/dist/cjs/{src/model → model}/user.js +0 -0
- /package/dist/cjs/{src/model → model}/value-mapping.js +0 -0
- /package/dist/cjs/{src/model → model}/variables.js +0 -0
- /package/dist/cjs/{src/schema → schema}/datasource.js +0 -0
- /package/dist/cjs/{src/schema → schema}/display.js +0 -0
- /package/dist/cjs/{src/schema → schema}/duration.js +0 -0
- /package/dist/cjs/{src/schema → schema}/index.js +0 -0
- /package/dist/cjs/{src/schema → schema}/metadata.js +0 -0
- /package/dist/cjs/{src/schema → schema}/panel.js +0 -0
- /package/dist/cjs/{src/schema → schema}/plugin.js +0 -0
- /package/dist/cjs/{src/schema → schema}/role.js +0 -0
- /package/dist/cjs/{src/schema → schema}/rolebinding.js +0 -0
- /package/dist/cjs/{src/schema → schema}/secret.js +0 -0
- /package/dist/cjs/{src/schema → schema}/user.js +0 -0
- /package/dist/cjs/{src/schema → schema}/variable.js +0 -0
- /package/dist/cjs/{src/test → test}/setup-tests.js +0 -0
- /package/dist/cjs/{src/utils → utils}/event.js +0 -0
- /package/dist/cjs/{src/utils → utils}/fetch.js +0 -0
- /package/dist/cjs/{src/utils → utils}/index.js +0 -0
- /package/dist/cjs/{src/utils → utils}/is-empty-object.js +0 -0
- /package/dist/cjs/{src/utils → utils}/mathjs.js +0 -0
- /package/dist/cjs/{src/utils → utils}/memo.js +0 -0
- /package/dist/cjs/{src/utils → utils}/panel-refs.js +0 -0
- /package/dist/cjs/{src/utils → utils}/regexp.js +0 -0
- /package/dist/cjs/{src/utils → utils}/text.js +0 -0
- /package/dist/cjs/{src/utils → utils}/time-series-data.js +0 -0
- /package/dist/cjs/{src/utils → utils}/transform-data.js +0 -0
- /package/dist/cjs/{src/utils → utils}/types.js +0 -0
- /package/dist/cjs/{src/utils → utils}/value-mapping.js +0 -0
- /package/dist/{src/constants → constants}/dashboard-defaults.js +0 -0
- /package/dist/{src/constants → constants}/index.js +0 -0
- /package/dist/{src/index.js → index.js} +0 -0
- /package/dist/{src/model → model}/calculations.js +0 -0
- /package/dist/{src/model → model}/dashboard.js +0 -0
- /package/dist/{src/model → model}/datasource.js +0 -0
- /package/dist/{src/model → model}/definitions.js +0 -0
- /package/dist/{src/model → model}/display.js +0 -0
- /package/dist/{src/model → model}/ephemeraldashboard.js +0 -0
- /package/dist/{src/model → model}/http-proxy.js +0 -0
- /package/dist/{src/model → model}/http.js +0 -0
- /package/dist/{src/model → model}/index.js +0 -0
- /package/dist/{src/model → model}/kind.js +0 -0
- /package/dist/{src/model → model}/layout.js +0 -0
- /package/dist/{src/model → model}/legend.js +0 -0
- /package/dist/{src/model → model}/notice.js +0 -0
- /package/dist/{src/model → model}/otlp/common/v1/common.js +0 -0
- /package/dist/{src/model → model}/otlp/index.js +0 -0
- /package/dist/{src/model → model}/otlp/resource/v1/resource.js +0 -0
- /package/dist/{src/model → model}/otlp/trace/v1/trace.js +0 -0
- /package/dist/{src/model → model}/panels.js +0 -0
- /package/dist/{src/model → model}/profile-data.js +0 -0
- /package/dist/{src/model → model}/project.js +0 -0
- /package/dist/{src/model → model}/query.js +0 -0
- /package/dist/{src/model → model}/resource.js +0 -0
- /package/dist/{src/model → model}/rolebindings.js +0 -0
- /package/dist/{src/model → model}/roles.js +0 -0
- /package/dist/{src/model → model}/secrets.js +0 -0
- /package/dist/{src/model → model}/thresholds.js +0 -0
- /package/dist/{src/model → model}/time-series-data.js +0 -0
- /package/dist/{src/model → model}/time-series-queries.js +0 -0
- /package/dist/{src/model → model}/time.js +0 -0
- /package/dist/{src/model → model}/trace-data.js +0 -0
- /package/dist/{src/model → model}/transforms.js +0 -0
- /package/dist/{src/model → model}/units/bytes.js +0 -0
- /package/dist/{src/model → model}/units/constants.js +0 -0
- /package/dist/{src/model → model}/units/currency.js +0 -0
- /package/dist/{src/model → model}/units/decimal.js +0 -0
- /package/dist/{src/model → model}/units/index.js +0 -0
- /package/dist/{src/model → model}/units/percent.js +0 -0
- /package/dist/{src/model → model}/units/throughput.js +0 -0
- /package/dist/{src/model → model}/units/time.js +0 -0
- /package/dist/{src/model → model}/units/types.js +0 -0
- /package/dist/{src/model → model}/units/units.js +0 -0
- /package/dist/{src/model → model}/units/utils.js +0 -0
- /package/dist/{src/model → model}/user.js +0 -0
- /package/dist/{src/model → model}/value-mapping.js +0 -0
- /package/dist/{src/model → model}/variables.js +0 -0
- /package/dist/{src/schema → schema}/datasource.js +0 -0
- /package/dist/{src/schema → schema}/display.js +0 -0
- /package/dist/{src/schema → schema}/duration.js +0 -0
- /package/dist/{src/schema → schema}/index.js +0 -0
- /package/dist/{src/schema → schema}/metadata.js +0 -0
- /package/dist/{src/schema → schema}/panel.js +0 -0
- /package/dist/{src/schema → schema}/plugin.js +0 -0
- /package/dist/{src/schema → schema}/role.js +0 -0
- /package/dist/{src/schema → schema}/rolebinding.js +0 -0
- /package/dist/{src/schema → schema}/secret.js +0 -0
- /package/dist/{src/schema → schema}/user.js +0 -0
- /package/dist/{src/schema → schema}/variable.js +0 -0
- /package/dist/{src/test → test}/setup-tests.js +0 -0
- /package/dist/{src/utils → utils}/event.js +0 -0
- /package/dist/{src/utils → utils}/fetch.js +0 -0
- /package/dist/{src/utils → utils}/index.js +0 -0
- /package/dist/{src/utils → utils}/is-empty-object.js +0 -0
- /package/dist/{src/utils → utils}/mathjs.js +0 -0
- /package/dist/{src/utils → utils}/memo.js +0 -0
- /package/dist/{src/utils → utils}/panel-refs.js +0 -0
- /package/dist/{src/utils → utils}/regexp.js +0 -0
- /package/dist/{src/utils → utils}/text.js +0 -0
- /package/dist/{src/utils → utils}/time-series-data.js +0 -0
- /package/dist/{src/utils → utils}/transform-data.js +0 -0
- /package/dist/{src/utils → utils}/types.js +0 -0
- /package/dist/{src/utils → utils}/value-mapping.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/constants/dashboard-defaults.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 { DurationString } from '../model';\n\nexport const DEFAULT_DASHBOARD_DURATION: DurationString = '1h';\n\nexport const DEFAULT_REFRESH_INTERVAL: DurationString = '0s';\n"],"names":["DEFAULT_DASHBOARD_DURATION","DEFAULT_REFRESH_INTERVAL"],"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;AAIjC,OAAO,MAAMA,6BAA6C,KAAK;AAE/D,OAAO,MAAMC,2BAA2C,KAAK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../src/constants/index.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\nexport * from './dashboard-defaults';\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,cAAc,uBAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.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\nexport * from './constants';\nexport * from './model';\nexport * from './schema';\nexport * from './utils';\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,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/calculations.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 { TimeSeriesValueTuple } from './time-series-queries';\n\nexport const DEFAULT_CALCULATION: CalculationType = 'last'; // aligned with cue\n\nexport const CalculationsMap = {\n first: first,\n last: last,\n 'first-number': firstNumber,\n 'last-number': lastNumber,\n mean: mean,\n sum: sum,\n min: min,\n max: max,\n};\n\nexport type CalculationType = keyof typeof CalculationsMap;\n\nexport type CalculationConfig = {\n label: string;\n description: string;\n};\n\nexport const CALCULATIONS_CONFIG: Readonly<Record<CalculationType, CalculationConfig>> = {\n first: {\n label: 'First',\n description: 'First value',\n },\n last: {\n label: 'Last',\n description: 'Last value',\n },\n 'first-number': {\n label: 'First *',\n description: 'First numeric value',\n },\n 'last-number': {\n label: 'Last *',\n description: 'Last numeric value',\n },\n mean: {\n label: 'Avg',\n description: 'Average value excluding nulls',\n },\n sum: {\n label: 'Sum',\n description: 'The sum of all values',\n },\n min: {\n label: 'Min',\n description: 'Minimum value',\n },\n max: {\n label: 'Max',\n description: 'Maximum value',\n },\n} as const;\n\ntype CalculationValue = number | null | undefined;\n\n/**\n * Calculate a multiple values for a set of time series data.\n *\n * @param values - Array of time series data.\n * @param includeCalculations - Array of calculations to include.\n */\nexport function getCalculations<IncludeCalcs extends CalculationType[]>(\n values: TimeSeriesValueTuple[],\n includeCalculations: IncludeCalcs\n): Record<\n // This extract combined with the generics above keeps the key of the returned\n // record to *just* the specified calculations.\n Extract<CalculationType, IncludeCalcs[number]>,\n CalculationValue\n> {\n const calculations = includeCalculations.reduce(\n (initResult, calculation) => {\n initResult[calculation] = undefined;\n return initResult;\n },\n {} as Record<string, CalculationValue>\n );\n\n // We save these values as separate values instead of directly setting them\n // in the calculations because they are needed by multiple calculations.\n let nonNullCount = 0;\n let sum = 0;\n\n // We use this large function capable of performing one or more calculations\n // in a single iteration of the data to minimize the performance impact of\n // generating multiple calculations for large timeseries values. This is\n // less optimized for certain single calculations when done in isolation (e.g.\n // `last`), but will be more performant in the more expensive cases where\n // multiple values are being used (e.g. table legend).\n values.forEach((tuple, i) => {\n const value = tuple[1];\n\n if (i === 0 && 'first' in calculations) {\n calculations.first = value;\n }\n if (i === values.length - 1 && 'last' in calculations) {\n calculations.last = value;\n }\n\n // Handling specific to non-null values.\n if (typeof value === 'number') {\n nonNullCount += 1;\n sum += value;\n\n if ('first-number' in calculations && calculations['first-number'] === undefined) {\n // Save the first number we see.\n calculations['first-number'] = value;\n }\n\n if ('last-number' in calculations) {\n // Keep setting the numbers we see, which will eventually be set to the\n // last number when finished iterating.\n calculations['last-number'] = value;\n }\n\n if ('min' in calculations) {\n if (typeof calculations.min !== 'number') {\n // Init the first time we see a number\n calculations.min = value;\n } else {\n // Use lowest value once initialized\n calculations.min = Math.min(calculations.min, value);\n }\n }\n\n if ('max' in calculations) {\n if (typeof calculations.max !== 'number') {\n // Init the first time we see a number\n calculations.max = value;\n } else {\n // Use highest value once initialized\n calculations.max = Math.max(calculations.max, value);\n }\n }\n }\n });\n\n // Set calculations that require iterating over all values.\n if (nonNullCount > 0 && 'sum' in calculations) {\n calculations.sum = sum;\n }\n\n if (nonNullCount > 0 && 'mean' in calculations) {\n calculations.mean = sum / nonNullCount;\n }\n\n return calculations;\n}\n\n/**\n * Calculate a single value for a set of time series data.\n *\n * Use `getCalculations` instead if you need multiple calculations.\n *\n * @param values - Array of time series data.\n * @param calculation - Name of the calculation to calculate.\n */\nexport function getCalculation(values: TimeSeriesValueTuple[], calculation: CalculationType): CalculationValue {\n return getCalculations(values, [calculation])[calculation];\n}\n\nfunction first(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'first');\n}\n\nfunction last(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'last');\n}\n\nfunction firstNumber(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'first-number');\n}\n\nfunction lastNumber(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'last-number');\n}\n\nfunction mean(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'mean');\n}\n\nfunction sum(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'sum');\n}\n\nfunction min(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'min');\n}\n\nfunction max(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'max');\n}\n"],"names":["DEFAULT_CALCULATION","CalculationsMap","first","last","firstNumber","lastNumber","mean","sum","min","max","CALCULATIONS_CONFIG","label","description","getCalculations","values","includeCalculations","calculations","reduce","initResult","calculation","undefined","nonNullCount","forEach","tuple","i","value","length","Math","getCalculation"],"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;AAIjC,OAAO,MAAMA,sBAAuC,OAAO,CAAC,mBAAmB;AAE/E,OAAO,M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;AAChC;AAEA,SAASP,IAAIO,MAA8B;IACzC,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASN,IAAIM,MAA8B;IACzC,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASL,IAAIK,MAA8B;IACzC,OAAOc,eAAed,QAAQ;AAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/dashboard.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 { DatasourceSpec } from './datasource';\nimport { LayoutDefinition } from './layout';\nimport { PanelDefinition } from './panels';\nimport { ProjectMetadata } from './resource';\nimport { DurationString } from './time';\nimport { VariableDefinition } from './variables';\nimport { Display } from './display';\n\nexport interface DashboardResource {\n kind: 'Dashboard';\n metadata: ProjectMetadata;\n spec: DashboardSpec;\n}\n\nexport interface DashboardSpec {\n display?: Display;\n datasources?: Record<string, DatasourceSpec>;\n duration: DurationString;\n refreshInterval?: DurationString;\n variables: VariableDefinition[];\n layouts: LayoutDefinition[];\n panels: Record<string, PanelDefinition>;\n}\n\nexport interface DashboardSelector {\n project: string;\n dashboard: string;\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;AA0BjC,WAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/datasource.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 { Definition, UnknownSpec } from './definitions';\nimport { Metadata, ProjectMetadata } from './resource';\nimport { Display } from './display';\n\nexport interface DatasourceSpec<PluginSpec = UnknownSpec> {\n display?: Display;\n default: boolean;\n plugin: Definition<PluginSpec>;\n}\n\n/**\n * A Datasource that's available across all projects.\n */\nexport interface GlobalDatasourceResource {\n kind: 'GlobalDatasource';\n metadata: Metadata;\n spec: DatasourceSpec;\n}\n\n/**\n * A Datasource resource, that belongs to a project.\n */\nexport interface DatasourceResource {\n kind: 'Datasource';\n metadata: ProjectMetadata;\n spec: DatasourceSpec;\n}\n\nexport type Datasource = DatasourceResource | GlobalDatasourceResource;\n\n/**\n * A selector for pointing at a specific Datasource.\n */\nexport interface DatasourceSelector {\n /**\n * Kind of the datasource.\n */\n kind: string;\n\n /**\n * Name of the datasource.\n * If omitted, it's assumed that you target the default datasource for the specified kind (and group, if set)\n */\n name?: string;\n}\n\n/**\n * An intermediary type to regroup the name and the spec of a datasource.\n */\nexport interface DatasourceDefinition {\n name: string;\n spec: DatasourceSpec;\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;AAgDjC;;CAEC,GACD,WAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/definitions.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/**\n * Base type for definitions in JSON config resources.\n */\nexport interface Definition<Spec> {\n kind: string;\n spec: Spec;\n}\n\n/**\n * Type to represent specs at runtime in framework code where we don't know the spec's real type, probably because it's\n * part of a plugin.\n */\nexport type UnknownSpec = Record<string, unknown>;\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;;CAEC,GAMD;;;CAGC,GACD,WAAkD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../src/model/display.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\nexport interface Display {\n name?: string;\n description?: string;\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,WAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/ephemeraldashboard.ts"],"sourcesContent":["// Copyright 2024 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 { ProjectMetadata } from './resource';\nimport { DurationString } from './time';\nimport { DashboardSelector, DashboardSpec } from './dashboard';\n\nexport interface EphemeralDashboardResource {\n kind: 'EphemeralDashboard';\n metadata: ProjectMetadata;\n spec: EphemeralDashboardSpec;\n}\n\nexport interface EphemeralDashboardSpec extends DashboardSpec {\n ttl: DurationString;\n}\n\nexport interface EphemeralDashboardInfo extends DashboardSelector {\n ttl: 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;AAgBjC,WAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/http-proxy.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 { RequestHeaders } from './http';\n\nexport interface HTTPProxy {\n kind: 'HTTPProxy';\n spec: HTTPProxySpec;\n}\nexport interface HTTPProxySpec {\n // url is the url of the datasource. It is not the url of the proxy.\n // The Perses server is the proxy, so it needs to know where to redirect the request.\n url: string;\n // allowedEndpoints is a list of tuples of http methods and http endpoints that will be accessible.\n // Leave it empty if you don't want to restrict the access to the datasource.\n allowedEndpoints?: HTTPAllowedEndpoint[];\n // headers can be used to provide additional headers that need to be forwarded when requesting the datasource\n headers?: RequestHeaders;\n // secret is the name of the secret that should be used for the proxy or discovery configuration\n // It will contain any sensitive information such as password, token, certificate.\n secret?: string;\n}\n\nexport interface HTTPAllowedEndpoint {\n endpointPattern: string;\n method: string;\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;AAsBjC,WAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/http.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 { HTTPProxy } from './http-proxy';\n\nexport type RequestHeaders = Record<string, string>;\n\nexport interface HTTPDatasourceSpec {\n directUrl?: string;\n proxy?: HTTPProxy;\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;AAMjC,WAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/index.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\nexport * from './calculations';\nexport * from './dashboard';\nexport * from './datasource';\nexport * from './definitions';\nexport * from './display';\nexport * from './ephemeraldashboard';\nexport * from './http';\nexport * from './http-proxy';\nexport * from './kind';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\nexport * from './otlp';\nexport * from './panels';\nexport * from './project';\nexport * from './query';\nexport * from './resource';\nexport * from './roles';\nexport * from './rolebindings';\nexport * from './secrets';\nexport * from './thresholds';\nexport * from './time';\nexport * from './time-series-data';\nexport * from './time-series-queries';\nexport * from './trace-data';\nexport * from './profile-data';\nexport * from './transforms';\nexport * from './units';\nexport * from './user';\nexport * from './variables';\nexport * from './value-mapping';\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,cAAc,iBAAiB;AAC/B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,kBAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/kind.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\nexport type Kind =\n | 'Dashboard'\n | 'Datasource'\n | 'EphemeralDashboard'\n | 'Folder'\n | 'GlobalDatasource'\n | 'GlobalRole'\n | 'GlobalRoleBinding'\n | 'GlobalSecret'\n | 'GlobalVariable'\n | 'Project'\n | 'Role'\n | 'RoleBinding'\n | 'Secret'\n | 'User'\n | 'Variable';\n\nexport const KINDS: Kind[] = [\n 'Dashboard',\n 'Datasource',\n 'EphemeralDashboard',\n 'Folder',\n 'GlobalDatasource',\n 'GlobalRole',\n 'GlobalRoleBinding',\n 'GlobalSecret',\n 'GlobalVariable',\n 'Project',\n 'Role',\n 'RoleBinding',\n 'Secret',\n 'User',\n 'Variable',\n];\n"],"names":["KINDS"],"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;AAmBjC,OAAO,MAAMA,QAAgB;IAC3B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/layout.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 { PanelRef } from './panels';\n\nexport type LayoutDefinition = GridDefinition;\n\nexport interface GridDefinition {\n kind: 'Grid';\n spec: {\n display?: {\n title: string;\n collapse?: {\n open: boolean;\n };\n };\n items: GridItemDefinition[];\n };\n}\n\nexport interface GridItemDefinition {\n x: number;\n y: number;\n width: number;\n height: number;\n content: PanelRef;\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;AAmBjC,WAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/legend.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// This file contains common/shared legend model code.\n// See the `components` package for legend model code specific to the Legend\n// component and the `plugin-system` package for legend model code specific to\n// panel plugin specs.\n\nexport const legendPositions = ['bottom', 'right'] as const;\nexport type LegendPositions = (typeof legendPositions)[number];\n\nexport const legendModes = ['list', 'table'] as const;\nexport type LegendMode = (typeof legendModes)[number];\n\nexport const legendSizes = ['small', 'medium'] as const;\nexport type LegendSize = (typeof legendSizes)[number];\n\n// Common legend options used across some UI components and panel specifications\nexport interface LegendOptionsBase {\n position: LegendPositions;\n mode?: LegendMode;\n size?: LegendSize;\n}\n\nexport function isValidLegendPosition(position: LegendPositions): boolean {\n return (legendPositions as readonly string[]).includes(position);\n}\n\nexport function isValidLegendMode(mode: LegendMode): boolean {\n return (legendModes as readonly string[]).includes(mode);\n}\n\nexport function isValidLegendSize(size: LegendSize): boolean {\n return (legendSizes as readonly string[]).includes(size);\n}\n\nexport const DEFAULT_LEGEND: Required<LegendOptionsBase> = {\n position: 'bottom',\n mode: 'list',\n size: 'medium',\n};\n\nexport function getLegendPosition(position?: LegendPositions): 'bottom' | 'right' {\n if (position === undefined) {\n return DEFAULT_LEGEND.position;\n }\n if (isValidLegendPosition(position)) {\n return position;\n }\n return DEFAULT_LEGEND.position;\n}\n\nexport function getLegendMode(mode?: LegendMode): 'list' | 'table' {\n if (!mode || !isValidLegendMode(mode)) {\n return DEFAULT_LEGEND.mode;\n }\n\n return mode;\n}\n\nexport function getLegendSize(size?: LegendSize): 'small' | 'medium' {\n if (!size || !isValidLegendSize(size)) {\n return DEFAULT_LEGEND.size;\n }\n\n return size;\n}\n"],"names":["legendPositions","legendModes","legendSizes","isValidLegendPosition","position","includes","isValidLegendMode","mode","isValidLegendSize","size","DEFAULT_LEGEND","getLegendPosition","undefined","getLegendMode","getLegendSize"],"mappings":"AAAA,oCAAoC;AACpC,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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\nexport interface Notice {\n type: 'error' | 'info' | 'warning';\n message: string;\n display?: 'tag'; // TODO: define other action types and alternate display options\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,WAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/model/otlp/common/v1/common.ts"],"sourcesContent":["// Copyright 2025 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// https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/opentelemetry/proto/common/v1/common.proto\n\nexport interface KeyValue {\n key: string;\n value: AnyValue;\n}\n\nexport type AnyValue =\n | { stringValue: string }\n | { intValue: string }\n | { boolValue: boolean }\n | { arrayValue: { values: AnyValue[] } };\n\nexport interface InstrumentationScope {\n name?: string;\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,+GAA+G;AAa/G,WAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/otlp/index.ts"],"sourcesContent":["// Copyright 2025 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\nexport * as otlpcommonv1 from './common/v1/common';\nexport * as otlpresourcev1 from './resource/v1/resource';\nexport * as otlptracev1 from './trace/v1/trace';\n"],"names":["otlpcommonv1","otlpresourcev1","otlptracev1"],"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,OAAO,KAAKA,YAAY,MAAM,qBAAqB;AACnD,OAAO,KAAKC,cAAc,MAAM,yBAAyB;AACzD,OAAO,KAAKC,WAAW,MAAM,mBAAmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/model/otlp/resource/v1/resource.ts"],"sourcesContent":["// Copyright 2025 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 { KeyValue } from '../../common/v1/common';\n\n// https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/opentelemetry/proto/resource/v1/resource.proto\n\nexport interface Resource {\n attributes?: KeyValue[];\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;AAIjC,mHAAmH;AAEnH,WAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/model/otlp/trace/v1/trace.ts"],"sourcesContent":["// Copyright 2025 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 { InstrumentationScope, KeyValue } from '../../common/v1/common';\nimport { Resource } from '../../resource/v1/resource';\n\n// https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/examples/trace.json\n\nexport interface TracesData {\n resourceSpans: ResourceSpan[];\n}\n\nexport interface ResourceSpan {\n resource?: Resource;\n scopeSpans: ScopeSpans[];\n}\n\nexport interface ScopeSpans {\n scope?: InstrumentationScope;\n spans: Span[];\n}\n\nexport interface Span {\n traceId: string;\n spanId: string;\n parentSpanId?: string;\n name: string;\n kind?: string;\n startTimeUnixNano: string;\n endTimeUnixNano: string;\n attributes?: KeyValue[];\n events?: Event[];\n links?: Link[];\n status?: Status;\n}\n\nexport interface Event {\n timeUnixNano: string;\n name: string;\n attributes?: KeyValue[];\n}\n\nexport interface Link {\n traceId: string;\n spanId: string;\n attributes?: KeyValue[];\n}\n\nexport interface Status {\n code?: typeof StatusCodeUnset | typeof StatusCodeOk | typeof StatusCodeError;\n message?: string;\n}\n\nexport const StatusCodeUnset = 'STATUS_CODE_UNSET';\nexport const StatusCodeOk = 'STATUS_CODE_OK';\nexport const StatusCodeError = 'STATUS_CODE_ERROR';\n"],"names":["StatusCodeUnset","StatusCodeOk","StatusCodeError"],"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;AAqDjC,OAAO,MAAMA,kBAAkB,oBAAoB;AACnD,OAAO,MAAMC,eAAe,iBAAiB;AAC7C,OAAO,MAAMC,kBAAkB,oBAAoB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/panels.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 { Definition, UnknownSpec } from './definitions';\nimport { QueryDefinition } from './query';\n\nexport interface Link {\n name?: string;\n url: string;\n tooltip?: string;\n renderVariables?: boolean;\n targetBlank?: boolean;\n}\n\nexport interface PanelDisplay {\n name: string;\n description?: string;\n}\n\nexport interface PanelDefinition<PluginSpec = UnknownSpec> extends Definition<PanelSpec<PluginSpec>> {\n kind: 'Panel';\n}\n\nexport interface PanelSpec<PluginSpec = UnknownSpec> {\n display: PanelDisplay;\n plugin: Definition<PluginSpec>;\n queries?: QueryDefinition[];\n links?: Link[];\n}\n\n/**\n * A reference to a panel defined in the DashboardSpec.\n */\nexport interface PanelRef {\n $ref: `#/spec/panels/${string}`;\n}\n\nexport type PanelGroupId = number;\n\n/**\n * Panel values that can be edited in the panel editor.\n */\nexport interface PanelEditorValues {\n groupId: PanelGroupId;\n panelDefinition: PanelDefinition;\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;AAsCjC;;CAEC,GACD,WAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/profile-data.ts"],"sourcesContent":["// Copyright 2025 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/**\n * A stackTrace\n * It corresponds to a function called during a program execution.\n * Children of a function are functions called by the parent function during its execution.\n */\nexport interface StackTrace {\n id: number; // index of function's name in names array\n name: string; // function's name\n level: number; // level of the function in the flame graph\n start: number; // time at which the function starts\n end: number; // time at which the function ends\n total: number; // total samples (including the samples in its children nodes)\n self: number; // self samples (excluding the samples in its children nodes)\n children: StackTrace[];\n}\n\n/**\n * Timeline attribute contains data to draw the chart showing the evolution of the profiled resource over time (CPU, memory, etc.).\n * It is like a metric and it helps to identify bottlenecks.\n */\nexport interface Timeline {\n startTime: number; // Time at which the timeline starts, as a Unix timestamp\n samples: number[]; // A sequence of samples starting at startTime, spaced by durationDelta seconds\n durationDelta: number; // Time delta between samples, in seconds\n}\n\n/**\n * An entire profile\n * It is the stacktrace of the root function.\n */\nexport interface Profile {\n stackTrace: StackTrace;\n}\n\n/**\n * A generalized data-model that will be used by Panel components\n * to display profiles.\n */\nexport interface ProfileData {\n profile: Profile;\n timeline?: Timeline;\n\n numTicks?: number; // Total number of samples\n maxSelf?: number; // Maximum self value in any node\n\n metadata?: ProfileMetaData;\n}\n\nexport interface ProfileMetaData {\n spyName: string; // Name of the spy / profiler used to generate the profile, if any\n sampleRate: number; // Sample rate at which the profiler was operating\n units: string; // The unit of measurement for the profiled data\n name: string; // A name that identifies the profile. [Is this really necessary?]\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;;;;CAIC,GA4CD,WAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/project.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 { Metadata } from './resource';\nimport { Display } from './display';\n\nexport interface ProjectResource {\n kind: 'Project';\n metadata: Metadata;\n spec: ProjectSpec;\n}\n\nexport interface ProjectSpec {\n display?: Display;\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;AAWjC,WAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/query.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 { Definition, UnknownSpec } from './definitions';\nimport { TimeSeriesData } from './time-series-data';\nimport { TraceData } from './trace-data';\nimport { ProfileData } from './profile-data';\n\ninterface QuerySpec<PluginSpec> {\n plugin: Definition<PluginSpec>;\n}\n/**\n * A generic query definition interface that can be extended to support more than just TimeSeriesQuery\n */\n// Kind needs to be `any` because otherwise typescript will complain 'unknown' is not assignable to type '\"TimeSeriesQuery\"' in a few places\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface QueryDefinition<Kind = any, PluginSpec = UnknownSpec> {\n kind: Kind;\n spec: QuerySpec<PluginSpec>;\n}\n\n/**\n * Mapping the query plugin to the data type it returns\n */\nexport interface QueryType {\n TimeSeriesQuery: TimeSeriesData;\n TraceQuery: TraceData;\n ProfileQuery: ProfileData;\n // in the future we can add other query plugin and data types\n // for example: we can add something like `LogsQuery: LogsData;`\n}\n\n/**\n * Check if the given type is a valid {@link QueryPluginType} with compile time safety\n * @param type\n */\nexport function isValidQueryPluginType(type: string): type is QueryPluginType {\n return ['TimeSeriesQuery', 'TraceQuery', 'ProfileQuery'].includes(type as QueryPluginType);\n}\n\n/**\n * Extract the keys of QueryType\n * ex: 'TimeSeriesQuery'\n */\nexport type QueryPluginType = keyof QueryType;\n\n/**\n * Values of QueryType\n * ex: 'TimeSeriesData'\n */\nexport type QueryDataType = QueryType[keyof QueryType];\n"],"names":["isValidQueryPluginType","type","includes"],"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;AA+BjC;;;CAGC,GACD,OAAO,SAASA,uBAAuBC,IAAY;IACjD,OAAO;QAAC;QAAmB;QAAc;KAAe,CAACC,QAAQ,CAACD;AACpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/resource.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 { Kind } from './kind';\n\nexport function isProjectMetadata(metadata: Metadata | ProjectMetadata): metadata is ProjectMetadata {\n return 'project' in metadata;\n}\n\nexport interface Metadata {\n name: string;\n createdAt?: string;\n updatedAt?: string;\n version?: number;\n}\n\nexport interface ProjectMetadata extends Metadata {\n project: string;\n}\n\nexport interface Resource {\n kind: Kind;\n metadata: Metadata | ProjectMetadata;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n spec: any;\n}\n\nexport function getMetadataProject(metadata: ProjectMetadata | Metadata): string | undefined {\n return 'project' in metadata ? metadata.project : undefined;\n}\n"],"names":["isProjectMetadata","metadata","getMetadataProject","project","undefined"],"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;AAIjC,OAAO,SAASA,kBAAkBC,QAAoC;IACpE,OAAO,aAAaA;AACtB;AAoBA,OAAO,SAASC,mBAAmBD,QAAoC;IACrE,OAAO,aAAaA,WAAWA,SAASE,OAAO,GAAGC;AACpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/rolebindings.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 { Metadata, ProjectMetadata } from './resource';\n\nexport interface Subject {\n kind: 'User';\n name: string;\n}\n\nexport interface RoleBindingSpec {\n // name of the role or global role (metadata.name)\n role: string;\n subjects: Subject[];\n}\n\n/**\n * A role binding that belongs to a project.\n */\nexport interface RoleBindingResource {\n kind: 'RoleBinding';\n metadata: ProjectMetadata;\n spec: RoleBindingSpec;\n}\n\n/**\n * A global role binding that doesn´t belong to a project.\n */\nexport interface GlobalRoleBindingResource {\n kind: 'GlobalRoleBinding';\n metadata: Metadata;\n spec: RoleBindingSpec;\n}\n\nexport type RoleBinding = RoleBindingResource | GlobalRoleBindingResource;\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;AAiCjC,WAA0E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/roles.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 { Metadata, ProjectMetadata } from './resource';\nimport { Kind } from './kind';\n\nexport type Action = 'create' | 'read' | 'update' | 'delete' | '*';\nexport const ACTIONS = ['*', 'create', 'read', 'update', 'delete'];\nexport type Scope = Kind | '*';\nexport const PROJECT_SCOPES = [\n '*',\n 'Dashboard',\n 'Datasource',\n 'EphemeralDashboard',\n 'Folder',\n 'Project',\n 'Role',\n 'RoleBinding',\n 'Secret',\n 'Variable',\n];\n\nexport const GLOBAL_SCOPES = [\n 'GlobalDatasource',\n 'GlobalRole',\n 'GlobalRoleBinding',\n 'GlobalSecret',\n 'GlobalVariable',\n 'User',\n];\n\nexport interface Permission {\n actions: Action[];\n scopes: Scope[];\n}\n\nexport interface RoleSpec {\n permissions: Permission[];\n}\n\n/**\n * A role that belongs to a project.\n */\nexport interface RoleResource {\n kind: 'Role';\n metadata: ProjectMetadata;\n spec: RoleSpec;\n}\n\n/**\n * A global role that doesn´t belong to a project.\n */\nexport interface GlobalRoleResource {\n kind: 'GlobalRole';\n metadata: Metadata;\n spec: RoleSpec;\n}\n\nexport type Role = RoleResource | GlobalRoleResource;\n"],"names":["ACTIONS","PROJECT_SCOPES","GLOBAL_SCOPES"],"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;AAMjC,OAAO,MAAMA,UAAU;IAAC;IAAK;IAAU;IAAQ;IAAU;CAAS,CAAC;AAEnE,OAAO,MAAMC,iBAAiB;IAC5B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAC;AAEF,OAAO,MAAMC,gBAAgB;IAC3B;IACA;IACA;IACA;IACA;IACA;CACD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/secrets.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 { Metadata, ProjectMetadata } from './resource';\n\nexport interface BasicAuth {\n username: string;\n password?: string;\n passwordFile?: string;\n}\n\nexport interface Authorization {\n type?: string;\n credentials?: string;\n credentialsFile?: string;\n}\n\nexport interface OAuth {\n clientID: string;\n clientSecret?: string;\n clientSecretFile?: string;\n tokenURL: string;\n scopes?: string[];\n endpointParams?: Record<string, string[]>;\n authStyle?: 0 | 1 | 2;\n}\n\nexport interface TLSConfig {\n ca?: string;\n cert?: string;\n key?: string;\n caFile?: string;\n certFile?: string;\n keyFile?: string;\n serverName?: string;\n insecureSkipVerify?: boolean;\n}\n\nexport interface SecretSpec {\n basicAuth?: BasicAuth;\n authorization?: Authorization;\n oauth?: OAuth;\n tlsConfig?: TLSConfig;\n}\n\n/**\n * A secret that belongs to a project.\n */\nexport interface SecretResource {\n kind: 'Secret';\n metadata: ProjectMetadata;\n spec: SecretSpec;\n}\n\n/**\n * A global secret that doesn´t belong to a project.\n */\nexport interface GlobalSecretResource {\n kind: 'GlobalSecret';\n metadata: Metadata;\n spec: SecretSpec;\n}\n\nexport type Secret = SecretResource | GlobalSecretResource;\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;AA8DjC,WAA2D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/thresholds.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\nexport interface StepOptions {\n value: number;\n color?: string;\n name?: string;\n}\n\nexport interface ThresholdOptions {\n mode?: 'percent' | 'absolute';\n defaultColor?: string;\n max?: number; // is this same as the max in GaugeChartOptions? can we remove?\n steps?: StepOptions[];\n}\n\nexport interface ThresholdColorPalette {\n defaultColor: string;\n palette: string[];\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,WAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/time-series-data.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 { Notice } from './notice';\nimport { AbsoluteTimeRange } from './time';\nimport { Labels, TimeSeriesValueTuple, TimeSeriesHistogramTuple } from './time-series-queries';\n\nexport interface TimeScale {\n startMs: number;\n endMs: number;\n stepMs: number;\n rangeMs: number;\n}\n\nexport interface TimeSeriesData {\n timeRange?: AbsoluteTimeRange;\n stepMs?: number;\n series: TimeSeries[];\n metadata?: TimeSeriesMetadata;\n}\n\nexport interface TimeSeries {\n name: string;\n values: TimeSeriesValueTuple[];\n histograms?: TimeSeriesHistogramTuple[];\n formattedName?: string;\n labels?: Labels;\n}\n\nexport interface TimeSeriesMetadata {\n notices?: Notice[];\n\n /**\n * The raw query that is executed to generate this data.\n * Useful when needing to inspect the query that was executed\n * after variables and other context modifications have been applied.\n */\n executedQueryString?: string;\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;AA4BjC,WASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/time-series-queries.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 { UnknownSpec } from './definitions';\nimport { QueryDefinition } from './query';\nimport { UnixTimeMs } from './time';\n\nexport type TimeSeriesQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'TimeSeriesQuery', PluginSpec>;\n\nexport type TimeSeriesValueTuple = [timestamp: UnixTimeMs, value: number | null];\n\nexport type BucketTuple = [number, string, string, string]; // [bucket, upperBound, lowerBound, count]\n\nexport type HistogramValue = { count: number; sum: string; buckets?: BucketTuple[] };\n\nexport type TimeSeriesHistogramTuple = [unixTimeSeconds: UnixTimeMs, value: HistogramValue];\n\nexport function isTimeSeriesValueTuple(data: TimeSeriesValueTuple): data is TimeSeriesValueTuple {\n if (data.length !== 2) return false;\n return true;\n}\n\nexport type Labels = Record<string, string>;\n"],"names":["isTimeSeriesValueTuple","data","length"],"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;AAgBjC,OAAO,SAASA,uBAAuBC,IAA0B;IAC/D,IAAIA,KAAKC,MAAM,KAAK,GAAG,OAAO;IAC9B,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/time.ts"],"sourcesContent":["// Copyright 2024 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 { Duration, sub } from 'date-fns';\n\nconst ONE_SECOND_IN_MS = 1000;\nconst ONE_MINUTE_IN_MS = 60000;\nconst ONE_HOUR_IN_MS = 3600000;\nconst ONE_DAY_IN_MS = 86400000; // assuming a day has always 24h\nconst ONE_WEEK_IN_MS = 604800000; // assuming a week has always 7d\nconst ONE_YEAR_IN_MS = 31536000000; // assuming a year has always 365d\n\nexport type UnixTimeMs = number;\n\nexport type DateTimeFormat = number | string;\n\nexport interface AbsoluteTimeRange {\n start: Date;\n end: Date;\n}\n\nexport interface RelativeTimeRange {\n // End date or undefined if relative to the current Date\n end?: Date;\n pastDuration: DurationString;\n}\n\nexport type TimeRangeValue = AbsoluteTimeRange | RelativeTimeRange;\n\n/**\n * Determine whether a given time range is relative\n */\nexport function isRelativeTimeRange(timeRange: TimeRangeValue): timeRange is RelativeTimeRange {\n return (timeRange as RelativeTimeRange).pastDuration !== undefined;\n}\n\n/**\n * Determine whether a given time range is absolute\n */\nexport function isAbsoluteTimeRange(timeRange: TimeRangeValue): timeRange is AbsoluteTimeRange {\n return (timeRange as AbsoluteTimeRange).start !== undefined && (timeRange as AbsoluteTimeRange).end !== undefined;\n}\n\n/**\n * Returns an absolute time range from a RelativeTimeRange.\n */\nexport function toAbsoluteTimeRange(timeRange: RelativeTimeRange): AbsoluteTimeRange {\n const end = timeRange.end ?? new Date();\n\n return {\n start: sub(end, parseDurationString(timeRange.pastDuration)),\n end,\n };\n}\n\ntype MillisecondsDurationString = `${number}ms`;\ntype SecondsDurationString = `${number}s`;\ntype MinutesDurationString = `${number}m`;\ntype HoursDurationString = `${number}h`;\ntype DaysDurationString = `${number}d`;\ntype WeeksDurationString = `${number}w`;\ntype YearsDurationString = `${number}y`;\n\nexport type DurationString = Exclude<\n `${YearsDurationString | ''}${WeeksDurationString | ''}${DaysDurationString | ''}${HoursDurationString | ''}${\n | MinutesDurationString\n | ''}${SecondsDurationString | ''}${MillisecondsDurationString | ''}`,\n ''\n>;\n\nexport const DURATION_REGEX = /^(?:(\\d+)y)?(?:(\\d+)w)?(?:(\\d+)d)?(?:(\\d+)h)?(?:(\\d+)m)?(?:(\\d+)s)?(?:(\\d+)ms)?$/;\n\n/**\n * Parses a DurationString into a Duration object with numeric values that can\n * be used to do Date math. Throws if not a valid duration string.\n */\nexport function parseDurationString(durationString: string): Duration {\n const matches = DURATION_REGEX.exec(durationString);\n if (matches === null) {\n throw new Error(`Invalid duration string '${durationString}'`);\n }\n\n return {\n years: parseInt(matches[1] ?? '0'),\n months: 0,\n weeks: parseInt(matches[2] ?? '0'),\n days: parseInt(matches[3] ?? '0'),\n hours: parseInt(matches[4] ?? '0'),\n minutes: parseInt(matches[5] ?? '0'),\n seconds: parseInt(matches[6] ?? '0') + parseInt(matches[7] ?? '0') / 1000,\n };\n}\n\n/**\n * Returns true if the given string is a valid DurationString.\n */\nexport function isDurationString(maybeDuration: string): maybeDuration is DurationString {\n if (maybeDuration === '') return false;\n return DURATION_REGEX.test(maybeDuration);\n}\n\nexport function intervalToPrometheusDuration(timeRange: AbsoluteTimeRange): Duration {\n const durationInMs = timeRange.end.valueOf() - timeRange.start.valueOf();\n return msToPrometheusDuration(durationInMs);\n}\n\nexport function msToPrometheusDuration(durationInMs: number): Duration {\n const years = Math.trunc(durationInMs / ONE_YEAR_IN_MS);\n if (years > 0) durationInMs -= years * ONE_YEAR_IN_MS;\n const weeks = Math.trunc(durationInMs / ONE_WEEK_IN_MS);\n if (weeks > 0) durationInMs -= weeks * ONE_WEEK_IN_MS;\n const days = Math.trunc(durationInMs / ONE_DAY_IN_MS);\n if (days > 0) durationInMs -= days * ONE_DAY_IN_MS;\n const hours = Math.trunc(durationInMs / ONE_HOUR_IN_MS);\n if (hours > 0) durationInMs -= hours * ONE_HOUR_IN_MS;\n const minutes = Math.trunc(durationInMs / ONE_MINUTE_IN_MS);\n if (minutes > 0) durationInMs -= minutes * ONE_MINUTE_IN_MS;\n\n return {\n years: years,\n months: 0,\n weeks: weeks,\n days: days,\n hours: hours,\n minutes: minutes,\n seconds: durationInMs / 1000,\n };\n}\n\nexport function formatDuration(duration: Duration): DurationString {\n const result: string[] = [];\n if (duration.years) {\n result.push(`${duration.years}y`);\n }\n if (duration.weeks) {\n result.push(`${duration.weeks}w`);\n }\n if (duration.days) {\n result.push(`${duration.days}d`);\n }\n if (duration.hours) {\n result.push(`${duration.hours}h`);\n }\n if (duration.minutes) {\n result.push(`${duration.minutes}m`);\n }\n if (duration.seconds) {\n const seconds = Math.trunc(duration.seconds);\n if (seconds) {\n result.push(`${seconds}s`);\n }\n const ms = Math.round((duration.seconds - seconds) * 1000);\n if (ms) {\n result.push(`${ms}ms`);\n }\n }\n return result.join('') as DurationString;\n}\n\nconst DEFAULT_STEP_MS = 15000;\n\nconst ROUNDED_STEP_INTERVALS = [\n // max: 0.015s\n { maxMs: 15, roundedStepMs: 10, display: '0.01s' },\n // max: 0.035s\n { maxMs: 35, roundedStepMs: 20, display: '0.02s' },\n // max: 0.075s\n { maxMs: 75, roundedStepMs: 50, display: '0.05s' },\n // max: 0.15s\n { maxMs: 150, roundedStepMs: 100, display: '0.1s' },\n // max: 0.35s\n { maxMs: 350, roundedStepMs: 200, display: '0.2s' },\n // max: 0.75s\n { maxMs: 750, roundedStepMs: 500, display: '0.5s' },\n // max: 1.5s\n { maxMs: ONE_SECOND_IN_MS * 1.5, roundedStepMs: ONE_SECOND_IN_MS, display: '1s' },\n // max: 3.5s\n { maxMs: ONE_SECOND_IN_MS * 3.5, roundedStepMs: ONE_SECOND_IN_MS * 2, display: '2s' },\n // max: 7.5s\n { maxMs: ONE_SECOND_IN_MS * 7.5, roundedStepMs: ONE_SECOND_IN_MS * 5, display: '5s' },\n // max: 12.5s\n { maxMs: ONE_SECOND_IN_MS * 12.5, roundedStepMs: ONE_SECOND_IN_MS * 10, display: '10s' },\n // max: 17.5s\n { maxMs: ONE_SECOND_IN_MS * 17.5, roundedStepMs: ONE_SECOND_IN_MS * 15, display: '15s' },\n // max: 25s\n { maxMs: ONE_SECOND_IN_MS * 25, roundedStepMs: ONE_SECOND_IN_MS * 20, display: '20s' },\n // max: 45s\n { maxMs: ONE_SECOND_IN_MS * 45, roundedStepMs: ONE_SECOND_IN_MS * 30, display: '30s' },\n // max: 1.5m\n { maxMs: ONE_MINUTE_IN_MS * 1.5, roundedStepMs: ONE_MINUTE_IN_MS, display: '1m' },\n // max: 3.5m\n { maxMs: ONE_MINUTE_IN_MS * 3.5, roundedStepMs: ONE_MINUTE_IN_MS * 2, display: '2m' },\n // max: 7.5m\n { maxMs: ONE_MINUTE_IN_MS * 7.5, roundedStepMs: ONE_MINUTE_IN_MS * 5, display: '5m' },\n // max: 12.5m\n { maxMs: ONE_MINUTE_IN_MS * 12.5, roundedStepMs: ONE_MINUTE_IN_MS * 10, display: '10m' },\n // max: 12.5m\n { maxMs: ONE_MINUTE_IN_MS * 12.5, roundedStepMs: ONE_MINUTE_IN_MS * 15, display: '15m' },\n // max: 25m\n { maxMs: ONE_MINUTE_IN_MS * 25, roundedStepMs: ONE_MINUTE_IN_MS * 20, display: '20m' },\n // max: 45m\n { maxMs: ONE_MINUTE_IN_MS * 45, roundedStepMs: ONE_MINUTE_IN_MS * 30, display: '30m' },\n // max: 1.5h\n { maxMs: ONE_HOUR_IN_MS * 1.5, roundedStepMs: ONE_HOUR_IN_MS, display: '1h' },\n // max: 2.5h\n { maxMs: ONE_HOUR_IN_MS * 2.5, roundedStepMs: ONE_HOUR_IN_MS * 2, display: '2h' },\n // max: 4.5h\n { maxMs: ONE_HOUR_IN_MS * 4.5, roundedStepMs: ONE_HOUR_IN_MS * 3, display: '3h' },\n // max: 9h\n { maxMs: ONE_HOUR_IN_MS * 9, roundedStepMs: ONE_HOUR_IN_MS * 6, display: '6h' },\n // max: 1d\n { maxMs: ONE_DAY_IN_MS, roundedStepMs: ONE_HOUR_IN_MS * 12, display: '12h' },\n // max: 1w\n { maxMs: ONE_WEEK_IN_MS, roundedStepMs: ONE_DAY_IN_MS, display: '1d' },\n // max: 3w\n { maxMs: ONE_WEEK_IN_MS * 3, roundedStepMs: ONE_WEEK_IN_MS, display: '1w' },\n // max: 6w\n { maxMs: ONE_WEEK_IN_MS * 6, roundedStepMs: ONE_DAY_IN_MS * 30, display: '30d' },\n // max: 2y\n { maxMs: ONE_YEAR_IN_MS * 2, roundedStepMs: ONE_YEAR_IN_MS, display: '1y' },\n];\n\n/**\n * Round interval to clearer increments\n */\nexport function roundStepInterval(stepMs: number): number {\n for (const { maxMs, roundedStepMs } of ROUNDED_STEP_INTERVALS) {\n if (stepMs < maxMs) {\n return roundedStepMs;\n }\n }\n return DEFAULT_STEP_MS;\n}\n\n/**\n * Gets a suggested step/interval size for a time range based on the width of a visual component.\n */\nexport function getSuggestedStepMs(timeRange: AbsoluteTimeRange, width: number): number {\n const queryRangeMs = timeRange.end.valueOf() - timeRange.start.valueOf();\n const stepMs = Math.floor(queryRangeMs / width);\n return roundStepInterval(stepMs);\n}\n"],"names":["sub","ONE_SECOND_IN_MS","ONE_MINUTE_IN_MS","ONE_HOUR_IN_MS","ONE_DAY_IN_MS","ONE_WEEK_IN_MS","ONE_YEAR_IN_MS","isRelativeTimeRange","timeRange","pastDuration","undefined","isAbsoluteTimeRange","start","end","toAbsoluteTimeRange","Date","parseDurationString","DURATION_REGEX","durationString","matches","exec","Error","years","parseInt","months","weeks","days","hours","minutes","seconds","isDurationString","maybeDuration","test","intervalToPrometheusDuration","durationInMs","valueOf","msToPrometheusDuration","Math","trunc","formatDuration","duration","result","push","ms","round","join","DEFAULT_STEP_MS","ROUNDED_STEP_INTERVALS","maxMs","roundedStepMs","display","roundStepInterval","stepMs","getSuggestedStepMs","width","queryRangeMs","floor"],"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,SAAmBA,GAAG,QAAQ,WAAW;AAEzC,MAAMC,mBAAmB;AACzB,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;AACvB,MAAMC,gBAAgB,UAAU,gCAAgC;AAChE,MAAMC,iBAAiB,WAAW,gCAAgC;AAClE,MAAMC,iBAAiB,aAAa,kCAAkC;AAmBtE;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SAAS;IAAK;IACrE,UAAU;IACV;QAAEF,OAAO3C,iBAAiB;QAAG4C,eAAe5C;QAAgB6C,SAAS;IAAK;IAC1E,UAAU;IACV;QAAEF,OAAO3C,iBAAiB;QAAG4C,eAAe7C,gBAAgB;QAAI8C,SAAS;IAAM;IAC/E,UAAU;IACV;QAAEF,OAAO1C,iBAAiB;QAAG2C,eAAe3C;QAAgB4C,SAAS;IAAK;CAC3E;AAED;;CAEC,GACD,OAAO,SAASC,kBAAkBC,MAAc;IAC9C,KAAK,MAAM,EAAEJ,KAAK,EAAEC,aAAa,EAAE,IAAIF,uBAAwB;QAC7D,IAAIK,SAASJ,OAAO;YAClB,OAAOC;QACT;IACF;IACA,OAAOH;AACT;AAEA;;CAEC,GACD,OAAO,SAASO,mBAAmB7C,SAA4B,EAAE8C,KAAa;IAC5E,MAAMC,eAAe/C,UAAUK,GAAG,CAACsB,OAAO,KAAK3B,UAAUI,KAAK,CAACuB,OAAO;IACtE,MAAMiB,SAASf,KAAKmB,KAAK,CAACD,eAAeD;IACzC,OAAOH,kBAAkBC;AAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/trace-data.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 { TracesData } from './otlp/trace/v1/trace';\n\n/**\n * Partial trace information returned by search endpoint\n */\nexport interface TraceSearchResult {\n traceId: string;\n rootServiceName: string;\n rootTraceName: string;\n startTimeUnixMs: number;\n durationMs: number;\n serviceStats: Record<string, ServiceStats>;\n}\n\nexport interface ServiceStats {\n spanCount: number;\n /** number of spans with errors, unset if zero */\n errorCount?: number;\n}\n\n/**\n * A generalized data-model that will be used by Panel components\n * to display traces.\n *\n * If the query contains a valid trace ID, the 'trace' attribute will contain the entire trace.\n * If the query contains a TraceQL query, the 'searchResult' attribute will contain the search results.\n */\nexport interface TraceData {\n trace?: TracesData;\n searchResult?: TraceSearchResult[];\n\n metadata?: TraceMetaData;\n}\n\nexport interface TraceMetaData {\n executedQueryString?: string;\n}\n\nexport function isValidTraceId(traceId: string): boolean {\n return /^[0-9a-fA-F]+$/.test(traceId);\n}\n"],"names":["isValidTraceId","traceId","test"],"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;AAwCjC,OAAO,SAASA,eAAeC,OAAe;IAC5C,OAAO,iBAAiBC,IAAI,CAACD;AAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/transforms.ts"],"sourcesContent":["// Copyright 2024 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\nexport interface TransformCommonSpec {\n disabled?: boolean;\n}\n\nexport interface JoinByColumnValueTransform {\n kind: 'JoinByColumnValue';\n spec: TransformCommonSpec & {\n columns: string[];\n };\n}\n\nexport interface MergeColumnsTransform {\n kind: 'MergeColumns';\n spec: TransformCommonSpec & {\n columns: string[];\n name: string;\n };\n}\n\nexport interface MergeIndexedColumnsTransform {\n kind: 'MergeIndexedColumns';\n spec: TransformCommonSpec & {\n column: string;\n };\n}\n\nexport interface MergeSeriesTransform {\n kind: 'MergeSeries';\n spec: TransformCommonSpec;\n}\n\nexport type Transform =\n | JoinByColumnValueTransform\n | MergeColumnsTransform\n | MergeIndexedColumnsTransform\n | MergeSeriesTransform;\n\n// Can be moved somewhere else\nexport const TRANSFORM_TEXT = {\n JoinByColumnValue: 'Join by column value',\n MergeColumns: 'Merge columns',\n MergeIndexedColumns: 'Merge indexed columns',\n MergeSeries: 'Merge series',\n};\n"],"names":["TRANSFORM_TEXT","JoinByColumnValue","MergeColumns","MergeIndexedColumns","MergeSeries"],"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;AAuCjC,8BAA8B;AAC9B,OAAO,MAAMA,iBAAiB;IAC5BC,mBAAmB;IACnBC,cAAc;IACdC,qBAAqB;IACrBC,aAAa;AACf,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/bytes.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 numbro from 'numbro';\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';\n\n/**\n * We consider the units for bytes to be powers of 1000.\n * In other words:\n * 1 KB = 1000 bytes (1000^1 bytes)\n * 1 MB = 1,000,000 bytes (1000^2 bytes)\n * etc.\n */\n\nconst DEFAULT_NUMBRO_MANTISSA = 2;\n\ntype BytesUnit = 'bytes';\nexport type BytesFormatOptions = {\n unit?: BytesUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\nexport const BYTES_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Bytes',\n decimalPlaces: true,\n shortValues: true,\n};\nexport const BYTES_UNIT_CONFIG: Readonly<Record<BytesUnit, UnitConfig>> = {\n bytes: {\n group: 'Bytes',\n label: 'Bytes',\n },\n};\n\nexport function formatBytes(bytes: number, { shortValues, decimalPlaces }: BytesFormatOptions): string {\n // If we're showing the entire value, we can use Intl.NumberFormat.\n if (!shouldShortenValues(shortValues) || Math.abs(bytes) < 1000) {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'unit',\n unit: 'byte',\n unitDisplay: 'long',\n useGrouping: true,\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n // This can happen if bytes is between -1000 and 1000\n if (shouldShortenValues(shortValues)) {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n }\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(bytes);\n }\n\n // If we're showing the shorten value, we use numbro.\n // numbro is able to add units like KB, MB, GB, etc. correctly.\n return numbro(bytes).format({\n output: 'byte',\n base: 'decimal',\n spaceSeparated: true,\n mantissa: hasDecimalPlaces(decimalPlaces) ? decimalPlaces : DEFAULT_NUMBRO_MANTISSA,\n // trimMantissa trims trailing 0s\n trimMantissa: !hasDecimalPlaces(decimalPlaces),\n // optionalMantissa excludes all the decimal places if they're all zeros\n optionalMantissa: !hasDecimalPlaces(decimalPlaces),\n });\n}\n"],"names":["numbro","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","DEFAULT_NUMBRO_MANTISSA","BYTES_GROUP_CONFIG","label","decimalPlaces","shortValues","BYTES_UNIT_CONFIG","bytes","group","formatBytes","Math","abs","formatterOptions","style","unit","unitDisplay","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format","output","base","spaceSeparated","mantissa","trimMantissa","optionalMantissa"],"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,OAAOA,YAAY,SAAS;AAE5B,SAASC,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,UAAU;AAEpF;;;;;;CAMC,GAED,MAAMC,0BAA0B;AAQhC,OAAO,MAAMC,qBAAsC;IACjDC,OAAO;IACPC,eAAe;IACfC,aAAa;AACf,EAAE;AACF,OAAO,MAAMC,oBAA6D;IACxEC,OAAO;QACLC,OAAO;QACPL,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASM,YAAYF,KAAa,EAAE,EAAEF,WAAW,EAAED,aAAa,EAAsB;IAC3F,mEAAmE;IACnE,IAAI,CAACJ,oBAAoBK,gBAAgBK,KAAKC,GAAG,CAACJ,SAAS,MAAM;QAC/D,MAAMK,mBAA6C;YACjDC,OAAO;YACPC,MAAM;YACNC,aAAa;YACbC,aAAa;QACf;QAEA,IAAIlB,iBAAiBM,gBAAgB;YACnCQ,iBAAiBK,qBAAqB,GAAGlB,mBAAmBK;YAC5DQ,iBAAiBM,qBAAqB,GAAGnB,mBAAmBK;QAC9D,OAAO;YACL,qDAAqD;YACrD,IAAIJ,oBAAoBK,cAAc;gBACpCO,iBAAiBO,wBAAwB,GAAGtB;YAC9C;QACF;QACA,MAAMuB,YAAYC,KAAKC,YAAY,CAAC,SAASV;QAC7C,OAAOQ,UAAUG,MAAM,CAAChB;IAC1B;IAEA,qDAAqD;IACrD,+DAA+D;IAC/D,OAAOX,OAAOW,OAAOgB,MAAM,CAAC;QAC1BC,QAAQ;QACRC,MAAM;QACNC,gBAAgB;QAChBC,UAAU7B,iBAAiBM,iBAAiBA,gBAAgBH;QAC5D,iCAAiC;QACjC2B,cAAc,CAAC9B,iBAAiBM;QAChC,wEAAwE;QACxEyB,kBAAkB,CAAC/B,iBAAiBM;IACtC;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/constants.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 constants needed across individual unit groups and the overall\n// combined units.\nexport const MAX_SIGNIFICANT_DIGITS = 3;\n"],"names":["MAX_SIGNIFICANT_DIGITS"],"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,wEAAwE;AACxE,kBAAkB;AAClB,OAAO,MAAMA,yBAAyB,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/currency.ts"],"sourcesContent":["// Copyright 2025 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 { toUpper } from 'lodash';\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitConfig, UnitGroupConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\n// See Intl.supportedValuesOf(\"currency\") for valid options, key names will\n// be converted to uppercase to match the expectation of Intl.NumberFormat\ntype CurrencyUnits =\n | 'aud'\n | 'cad'\n | 'chf'\n | 'cny'\n | 'eur'\n | 'gbp'\n | 'hkd'\n | 'inr'\n | 'jpy'\n | 'krw'\n | 'nok'\n | 'nzd'\n | 'sek'\n | 'sgd'\n | 'usd';\nexport type CurrencyFormatOptions = {\n unit: CurrencyUnits;\n decimalPlaces?: number;\n};\n\nconst CURRENCY_GROUP = 'Currency';\nexport const CURRENCY_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Currency',\n decimalPlaces: true,\n};\nexport const CURRENCY_UNIT_CONFIG: Readonly<Record<CurrencyUnits, UnitConfig>> = {\n aud: {\n group: CURRENCY_GROUP,\n label: 'Australian Dollar (A$)',\n },\n cad: {\n group: CURRENCY_GROUP,\n label: 'Canadian Dollar (CA$)',\n },\n chf: {\n group: CURRENCY_GROUP,\n label: 'Swiss Franc (CHF)',\n },\n cny: {\n group: CURRENCY_GROUP,\n label: 'Renminbi (CN¥)',\n },\n eur: {\n group: CURRENCY_GROUP,\n label: 'Euro (€)',\n },\n gbp: {\n group: CURRENCY_GROUP,\n label: 'Pound (£)',\n },\n hkd: {\n group: CURRENCY_GROUP,\n label: 'Hong Kong Dollar (HK$)',\n },\n inr: {\n group: CURRENCY_GROUP,\n label: 'Indian Rupee (₹)',\n },\n jpy: {\n group: CURRENCY_GROUP,\n label: 'Yen (¥)',\n },\n krw: {\n group: CURRENCY_GROUP,\n label: 'South Korean Won (₩)',\n },\n nok: {\n group: CURRENCY_GROUP,\n label: 'Norwegian Krone (NOK)',\n },\n nzd: {\n group: CURRENCY_GROUP,\n label: 'New Zealand Dollar (NZ$)',\n },\n sek: {\n group: CURRENCY_GROUP,\n label: 'Swedish Krona (SEK)',\n },\n sgd: {\n group: CURRENCY_GROUP,\n label: 'Singapore Dollar (S$)',\n },\n usd: {\n group: CURRENCY_GROUP,\n label: 'US Dollar ($)',\n },\n};\n\nexport function formatCurrency(value: number, { unit, decimalPlaces }: CurrencyFormatOptions): string {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'currency',\n currency: toUpper(unit),\n currencyDisplay: 'symbol',\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value);\n}\n"],"names":["toUpper","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","CURRENCY_GROUP","CURRENCY_GROUP_CONFIG","label","decimalPlaces","CURRENCY_UNIT_CONFIG","aud","group","cad","chf","cny","eur","gbp","hkd","inr","jpy","krw","nok","nzd","sek","sgd","usd","formatCurrency","value","unit","formatterOptions","style","currency","currencyDisplay","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"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,OAAO,QAAQ,SAAS;AACjC,SAASC,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,UAAU;AAyB/D,MAAMC,iBAAiB;AACvB,OAAO,MAAMC,wBAAyC;IACpDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,OAAO,MAAMC,uBAAoE;IAC/EC,KAAK;QACHC,OAAON;QACPE,OAAO;IACT;IACAK,KAAK;QACHD,OAAON;QACPE,OAAO;IACT;IACAM,KAAK;QACHF,OAAON;QACPE,OAAO;IACT;IACAO,KAAK;QACHH,OAAON;QACPE,OAAO;IACT;IACAQ,KAAK;QACHJ,OAAON;QACPE,OAAO;IACT;IACAS,KAAK;QACHL,OAAON;QACPE,OAAO;IACT;IACAU,KAAK;QACHN,OAAON;QACPE,OAAO;IACT;IACAW,KAAK;QACHP,OAAON;QACPE,OAAO;IACT;IACAY,KAAK;QACHR,OAAON;QACPE,OAAO;IACT;IACAa,KAAK;QACHT,OAAON;QACPE,OAAO;IACT;IACAc,KAAK;QACHV,OAAON;QACPE,OAAO;IACT;IACAe,KAAK;QACHX,OAAON;QACPE,OAAO;IACT;IACAgB,KAAK;QACHZ,OAAON;QACPE,OAAO;IACT;IACAiB,KAAK;QACHb,OAAON;QACPE,OAAO;IACT;IACAkB,KAAK;QACHd,OAAON;QACPE,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASmB,eAAeC,KAAa,EAAE,EAAEC,IAAI,EAAEpB,aAAa,EAAyB;IAC1F,MAAMqB,mBAA6C;QACjDC,OAAO;QACPC,UAAU9B,QAAQ2B;QAClBI,iBAAiB;IACnB;IAEA,IAAI7B,iBAAiBK,gBAAgB;QACnCqB,iBAAiBI,qBAAqB,GAAG7B,mBAAmBI;QAC5DqB,iBAAiBK,qBAAqB,GAAG9B,mBAAmBI;IAC9D,OAAO;QACLqB,iBAAiBM,wBAAwB,GAAGjC;IAC9C;IAEA,MAAMkC,YAAYC,KAAKC,YAAY,CAAC,SAAST;IAC7C,OAAOO,UAAUG,MAAM,CAACZ;AAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/decimal.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 { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';\n\ntype DecimalUnit = 'decimal';\nexport type DecimalFormatOptions = {\n unit?: DecimalUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\nexport const DECIMAL_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Decimal',\n decimalPlaces: true,\n shortValues: true,\n};\nexport const DECIMAL_UNIT_CONFIG: Readonly<Record<DecimalUnit, UnitConfig>> = {\n decimal: {\n group: 'Decimal',\n label: 'Decimal',\n },\n};\n\nexport function formatDecimal(value: number, { shortValues, decimalPlaces }: DecimalFormatOptions): string {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n useGrouping: true,\n };\n\n if (shouldShortenValues(shortValues)) {\n formatterOptions.notation = 'compact';\n }\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n if (shouldShortenValues(shortValues)) {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","DECIMAL_GROUP_CONFIG","label","decimalPlaces","shortValues","DECIMAL_UNIT_CONFIG","decimal","group","formatDecimal","value","formatterOptions","style","useGrouping","notation","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"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,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,UAAU;AAQpF,OAAO,MAAMC,uBAAwC;IACnDC,OAAO;IACPC,eAAe;IACfC,aAAa;AACf,EAAE;AACF,OAAO,MAAMC,sBAAiE;IAC5EC,SAAS;QACPC,OAAO;QACPL,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASM,cAAcC,KAAa,EAAE,EAAEL,WAAW,EAAED,aAAa,EAAwB;IAC/F,MAAMO,mBAA6C;QACjDC,OAAO;QACPC,aAAa;IACf;IAEA,IAAIZ,oBAAoBI,cAAc;QACpCM,iBAAiBG,QAAQ,GAAG;IAC9B;IAEA,IAAIf,iBAAiBK,gBAAgB;QACnCO,iBAAiBI,qBAAqB,GAAGf,mBAAmBI;QAC5DO,iBAAiBK,qBAAqB,GAAGhB,mBAAmBI;IAC9D,OAAO;QACL,IAAIH,oBAAoBI,cAAc;YACpCM,iBAAiBM,wBAAwB,GAAGnB;QAC9C;IACF;IAEA,MAAMoB,YAAYC,KAAKC,YAAY,CAAC,SAAST;IAC7C,OAAOO,UAAUG,MAAM,CAACX;AAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/index.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\nexport * from './utils';\nexport * from './units';\nexport * from './constants';\nexport * from './types';\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,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,cAAc;AAC5B,cAAc,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/percent.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 { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\ntype PercentUnit = 'percent' | 'percent-decimal' | '%';\nexport type PercentFormatOptions = {\n unit?: PercentUnit;\n decimalPlaces?: number;\n};\nexport const PERCENT_GROUP_CONFIG: UnitGroupConfig = {\n label: 'percent',\n decimalPlaces: true,\n};\nconst PERCENT_GROUP = 'Percent';\nexport const PERCENT_UNIT_CONFIG: Readonly<Record<PercentUnit, UnitConfig>> = {\n percent: {\n group: PERCENT_GROUP,\n label: 'Percent (0-100)',\n },\n 'percent-decimal': {\n group: PERCENT_GROUP,\n label: 'Percent (0.0-1.0)',\n },\n '%': {\n // This option is not shown in the selector because it is a shorthand\n // duplicate of `Percent`.\n disableSelectorOption: true,\n group: PERCENT_GROUP,\n label: '%',\n },\n};\n\nexport function formatPercent(value: number, { unit, decimalPlaces }: PercentFormatOptions): string {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'percent',\n useGrouping: true,\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n // Intl.NumberFormat translates 0 -> 0%, 0.5 -> 50%, 1 -> 100%, etc.\n if (unit === 'percent') {\n value = value / 100;\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","PERCENT_GROUP_CONFIG","label","decimalPlaces","PERCENT_GROUP","PERCENT_UNIT_CONFIG","percent","group","disableSelectorOption","formatPercent","value","unit","formatterOptions","style","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"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,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,UAAU;AAO/D,OAAO,MAAMC,uBAAwC;IACnDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,MAAMC,gBAAgB;AACtB,OAAO,MAAMC,sBAAiE;IAC5EC,SAAS;QACPC,OAAOH;QACPF,OAAO;IACT;IACA,mBAAmB;QACjBK,OAAOH;QACPF,OAAO;IACT;IACA,KAAK;QACH,qEAAqE;QACrE,0BAA0B;QAC1BM,uBAAuB;QACvBD,OAAOH;QACPF,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASO,cAAcC,KAAa,EAAE,EAAEC,IAAI,EAAER,aAAa,EAAwB;IACxF,MAAMS,mBAA6C;QACjDC,OAAO;QACPC,aAAa;IACf;IAEA,IAAIf,iBAAiBI,gBAAgB;QACnCS,iBAAiBG,qBAAqB,GAAGf,mBAAmBG;QAC5DS,iBAAiBI,qBAAqB,GAAGhB,mBAAmBG;IAC9D,OAAO;QACLS,iBAAiBK,wBAAwB,GAAGnB;IAC9C;IAEA,oEAAoE;IACpE,IAAIa,SAAS,WAAW;QACtBD,QAAQA,QAAQ;IAClB;IAEA,MAAMQ,YAAYC,KAAKC,YAAY,CAAC,SAASR;IAC7C,OAAOM,UAAUG,MAAM,CAACX;AAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/throughput.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 } from './bytes';\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';\n\ntype ThroughputUnit =\n | 'bits/sec'\n | 'bytes/sec'\n | 'counts/sec'\n | 'events/sec'\n | 'messages/sec'\n | 'ops/sec'\n | 'packets/sec'\n | 'reads/sec'\n | 'records/sec'\n | 'requests/sec'\n | 'rows/sec'\n | 'writes/sec';\nexport type ThroughputFormatOptions = {\n unit?: ThroughputUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\nexport const THROUGHPUT_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Throughput',\n decimalPlaces: true,\n};\nconst THROUGHPUT_GROUP = 'Throughput';\nexport const THROUGHPUT_UNIT_CONFIG: Readonly<Record<ThroughputUnit, UnitConfig>> = {\n 'bits/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Bits/sec',\n },\n 'bytes/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Bytes/sec',\n },\n 'counts/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Counts/sec',\n },\n 'events/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Events/sec',\n },\n 'messages/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Messages/sec',\n },\n 'ops/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Ops/sec',\n },\n 'packets/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Packets/sec',\n },\n 'reads/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Reads/sec',\n },\n 'requests/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Requests/sec',\n },\n 'records/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Records/sec',\n },\n 'rows/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Rows/sec',\n },\n 'writes/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Writes/sec',\n },\n};\n\nexport function formatThroughput(value: number, { unit, shortValues, decimalPlaces }: ThroughputFormatOptions): string {\n // special case for data throughput\n if (unit === 'bytes/sec') {\n const denominator = Math.abs(value) < 1000 ? 'sec' : 's';\n return formatBytes(value, { unit: 'bytes', shortValues, decimalPlaces }) + '/' + denominator;\n }\n\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n useGrouping: true,\n };\n\n if (shouldShortenValues(shortValues)) {\n formatterOptions.notation = 'compact';\n }\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n if (shouldShortenValues(shortValues)) {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value) + ' ' + unit;\n}\n"],"names":["formatBytes","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","THROUGHPUT_GROUP_CONFIG","label","decimalPlaces","THROUGHPUT_GROUP","THROUGHPUT_UNIT_CONFIG","group","formatThroughput","value","unit","shortValues","denominator","Math","abs","formatterOptions","style","useGrouping","notation","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"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,QAAQ,UAAU;AACtC,SAASC,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,UAAU;AAoBpF,OAAO,MAAMC,0BAA2C;IACtDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,MAAMC,mBAAmB;AACzB,OAAO,MAAMC,yBAAuE;IAClF,YAAY;QACVC,OAAOF;QACPF,OAAO;IACT;IACA,aAAa;QACXI,OAAOF;QACPF,OAAO;IACT;IACA,cAAc;QACZI,OAAOF;QACPF,OAAO;IACT;IACA,cAAc;QACZI,OAAOF;QACPF,OAAO;IACT;IACA,gBAAgB;QACdI,OAAOF;QACPF,OAAO;IACT;IACA,WAAW;QACTI,OAAOF;QACPF,OAAO;IACT;IACA,eAAe;QACbI,OAAOF;QACPF,OAAO;IACT;IACA,aAAa;QACXI,OAAOF;QACPF,OAAO;IACT;IACA,gBAAgB;QACdI,OAAOF;QACPF,OAAO;IACT;IACA,eAAe;QACbI,OAAOF;QACPF,OAAO;IACT;IACA,YAAY;QACVI,OAAOF;QACPF,OAAO;IACT;IACA,cAAc;QACZI,OAAOF;QACPF,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASK,iBAAiBC,KAAa,EAAE,EAAEC,IAAI,EAAEC,WAAW,EAAEP,aAAa,EAA2B;IAC3G,mCAAmC;IACnC,IAAIM,SAAS,aAAa;QACxB,MAAME,cAAcC,KAAKC,GAAG,CAACL,SAAS,OAAO,QAAQ;QACrD,OAAOZ,YAAYY,OAAO;YAAEC,MAAM;YAASC;YAAaP;QAAc,KAAK,MAAMQ;IACnF;IAEA,MAAMG,mBAA6C;QACjDC,OAAO;QACPC,aAAa;IACf;IAEA,IAAIhB,oBAAoBU,cAAc;QACpCI,iBAAiBG,QAAQ,GAAG;IAC9B;IAEA,IAAInB,iBAAiBK,gBAAgB;QACnCW,iBAAiBI,qBAAqB,GAAGnB,mBAAmBI;QAC5DW,iBAAiBK,qBAAqB,GAAGpB,mBAAmBI;IAC9D,OAAO;QACL,IAAIH,oBAAoBU,cAAc;YACpCI,iBAAiBM,wBAAwB,GAAGvB;QAC9C;IACF;IAEA,MAAMwB,YAAYC,KAAKC,YAAY,CAAC,SAAST;IAC7C,OAAOO,UAAUG,MAAM,CAAChB,SAAS,MAAMC;AACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/time.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 { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\ntype TimeUnits = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'years';\nexport type TimeFormatOptions = {\n unit?: TimeUnits;\n decimalPlaces?: number;\n};\nconst TIME_GROUP = 'Time';\nexport const TIME_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Time',\n decimalPlaces: true,\n};\nexport const TIME_UNIT_CONFIG: Readonly<Record<TimeUnits, UnitConfig>> = {\n milliseconds: {\n group: TIME_GROUP,\n label: 'Milliseconds',\n },\n seconds: {\n group: TIME_GROUP,\n label: 'Seconds',\n },\n minutes: {\n group: TIME_GROUP,\n label: 'Minutes',\n },\n hours: {\n group: TIME_GROUP,\n label: 'Hours',\n },\n days: {\n group: TIME_GROUP,\n label: 'Days',\n },\n weeks: {\n group: TIME_GROUP,\n label: 'Weeks',\n },\n months: {\n group: TIME_GROUP,\n label: 'Months',\n },\n years: {\n group: TIME_GROUP,\n label: 'Years',\n },\n};\n\n// Mapping of time units to what Intl.NumberFormat formatter expects\n// https://v8.dev/features/intl-numberformat#units\nexport enum PersesTimeToIntlTime {\n milliseconds = 'millisecond',\n seconds = 'second',\n minutes = 'minute',\n hours = 'hour',\n days = 'day',\n weeks = 'week',\n months = 'month',\n years = 'year',\n}\n\n/**\n * Note: This conversion will not be exactly accurate for months and years,\n * due variations in the lengths of months (i.e. 28 - 31 days) and years (i.e. leap years).\n * For precision with months and years, we would need more complex algorithms and/or external libraries.\n * However, we expect that measurements in months and years will be rare.\n */\nconst TIME_UNITS_IN_SECONDS: Record<TimeUnits, number> = {\n years: 31536000, // 365 days\n months: 2592000, // 30 days\n weeks: 604800, // 7 days\n days: 86400,\n hours: 3600,\n minutes: 60,\n seconds: 1,\n milliseconds: 0.001,\n};\n\nconst LARGEST_TO_SMALLEST_TIME_UNITS: TimeUnits[] = [\n 'years',\n 'months',\n 'weeks',\n 'days',\n 'hours',\n 'minutes',\n 'seconds',\n 'milliseconds',\n];\n\n/**\n * Choose the first time unit that produces a number greater than 1, starting from the biggest time unit.\n */\nfunction getValueAndKindForNaturalNumbers(value: number, unit: TimeUnits): { value: number; unit: TimeUnits } {\n const valueInSeconds = value * TIME_UNITS_IN_SECONDS[unit];\n\n // Initialize for TS\n const largestTimeUnit = LARGEST_TO_SMALLEST_TIME_UNITS[0] || 'years';\n let timeUnit: TimeUnits = largestTimeUnit;\n let valueInTimeUnit: number = valueInSeconds / TIME_UNITS_IN_SECONDS[largestTimeUnit];\n\n for (timeUnit of LARGEST_TO_SMALLEST_TIME_UNITS) {\n valueInTimeUnit = valueInSeconds / TIME_UNITS_IN_SECONDS[timeUnit];\n if (valueInTimeUnit >= 1) {\n return { value: valueInTimeUnit, unit: timeUnit };\n }\n }\n\n // If we didn't find a time unit, we have to settle for the smallest time unit (which is the last time unit).\n return { value: valueInTimeUnit, unit: timeUnit };\n}\n\nfunction isMonthOrYear(unit: TimeUnits): boolean {\n return unit === 'months' || unit === 'years';\n}\n\nexport function formatTime(value: number, { unit, decimalPlaces }: TimeFormatOptions): string {\n if (value === 0) return '0s';\n\n const results = getValueAndKindForNaturalNumbers(value, unit ?? 'seconds');\n\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'unit',\n unit: PersesTimeToIntlTime[results.unit],\n unitDisplay: isMonthOrYear(results.unit) ? 'long' : 'narrow',\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(results.value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","TIME_GROUP","TIME_GROUP_CONFIG","label","decimalPlaces","TIME_UNIT_CONFIG","milliseconds","group","seconds","minutes","hours","days","weeks","months","years","PersesTimeToIntlTime","TIME_UNITS_IN_SECONDS","LARGEST_TO_SMALLEST_TIME_UNITS","getValueAndKindForNaturalNumbers","value","unit","valueInSeconds","largestTimeUnit","timeUnit","valueInTimeUnit","isMonthOrYear","formatTime","results","formatterOptions","style","unitDisplay","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"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,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,UAAU;AAO/D,MAAMC,aAAa;AACnB,OAAO,MAAMC,oBAAqC;IAChDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,OAAO,MAAMC,mBAA4D;IACvEC,cAAc;QACZC,OAAON;QACPE,OAAO;IACT;IACAK,SAAS;QACPD,OAAON;QACPE,OAAO;IACT;IACAM,SAAS;QACPF,OAAON;QACPE,OAAO;IACT;IACAO,OAAO;QACLH,OAAON;QACPE,OAAO;IACT;IACAQ,MAAM;QACJJ,OAAON;QACPE,OAAO;IACT;IACAS,OAAO;QACLL,OAAON;QACPE,OAAO;IACT;IACAU,QAAQ;QACNN,OAAON;QACPE,OAAO;IACT;IACAW,OAAO;QACLP,OAAON;QACPE,OAAO;IACT;AACF,EAAE;AAEF,oEAAoE;AACpE,kDAAkD;AAClD,OAAO,IAAA,AAAKY,8CAAAA;;;;;;;;;WAAAA;MASX;AAED;;;;;CAKC,GACD,MAAMC,wBAAmD;IACvDF,OAAO;IACPD,QAAQ;IACRD,OAAO;IACPD,MAAM;IACND,OA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 -0,0 +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 = 'Time' | 'Percent' | 'Decimal' | 'Bytes' | 'Throughput' | 'Currency';\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;AA6DT,WAGC"}
|
|
@@ -0,0 +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,SACEC,aAAa,EAEbC,oBAAoB,EACpBC,mBAAmB,QACd,YAAY;AACnB,SAASC,UAAU,EAA0CC,iBAAiB,EAAEC,gBAAgB,QAAQ,SAAS;AAEjH,SACEC,gBAAgB,EAChBC,uBAAuB,EACvBC,sBAAsB,QAEjB,eAAe;AACtB,SAASC,cAAc,EAAEC,qBAAqB,EAAEC,oBAAoB,QAA+B,aAAa;AAEhH;;;;;;CAMC,GAED,OAAO,MAAMC,oBAAkE;IAC7EC,MAAMT;IACNU,SAASb;IACTc,SAASjB;IACTkB,OAAOrB;IACPsB,YAAYV;IACZW,UAAUR;AACZ,EAAE;AACF,OAAO,MAAMS,cAAc;IACzB,GAAGd,gBAAgB;IACnB,GAAGH,mBAAmB;IACtB,GAAGH,mBAAmB;IACtB,GAAGH,iBAAiB;IACpB,GAAGY,sBAAsB;IACzB,GAAGG,oBAAoB;AACzB,EAAW;AAaX,OAAO,SAASS,YAAYC,KAAa,EAAEC,aAA6B;IACtE,IAAIA,kBAAkBC,WAAW;QAC/B,OAAOF,MAAMG,QAAQ;IACvB;IAEA,IAAI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,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/utils.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\nexport function shouldShortenValues(shortValues?: boolean): boolean {\n return shortValues !== false;\n}\n\nexport function hasDecimalPlaces(decimalPlaces?: number): boolean {\n return typeof decimalPlaces === 'number';\n}\n\n// Avoids maximumFractionDigits out-of-range error.\n// Allowed values are 0 to 20.\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits\nexport function limitDecimalPlaces(num?: number): number | undefined {\n if (!num) return num;\n\n if (num < 0) {\n num = 0;\n } else if (num > 20) {\n num = 20;\n }\n\n return num;\n}\n"],"names":["shouldShortenValues","shortValues","hasDecimalPlaces","decimalPlaces","limitDecimalPlaces","num"],"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,OAAO,SAASA,oBAAoBC,WAAqB;IACvD,OAAOA,gBAAgB;AACzB;AAEA,OAAO,SAASC,iBAAiBC,aAAsB;IACrD,OAAO,OAAOA,kBAAkB;AAClC;AAEA,mDAAmD;AACnD,8BAA8B;AAC9B,wIAAwI;AACxI,OAAO,SAASC,mBAAmBC,GAAY;IAC7C,IAAI,CAACA,KAAK,OAAOA;IAEjB,IAAIA,MAAM,GAAG;QACXA,MAAM;IACR,OAAO,IAAIA,MAAM,IAAI;QACnBA,MAAM;IACR;IAEA,OAAOA;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/user.ts"],"sourcesContent":["// Copyright 2024 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 { Metadata } from './resource';\n\nexport interface NativeProvider {\n password?: string;\n}\n\nexport interface OAuthProvider {\n issuer?: string;\n email?: string;\n subject?: string;\n}\n\nexport interface UserSpec {\n firstName?: string;\n lastName?: string;\n nativeProvider?: NativeProvider;\n oauthProviders?: OAuthProvider[];\n}\n\nexport interface UserResource {\n kind: 'User';\n metadata: Metadata;\n spec: UserSpec;\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;AAqBjC,WAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/value-mapping.ts"],"sourcesContent":["// Copyright 2024 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\nexport type ValueMapping =\n | ValueMappingOptions\n | ValueMappingOptionsRange\n | ValueMappingOptionsRegex\n | ValueMappingOptionsMisc;\n\nexport interface ValueMappingOptions {\n kind: 'Value';\n spec: {\n value: string | number;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsRange {\n kind: 'Range';\n spec: {\n from?: number;\n to?: number;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsRegex {\n kind: 'Regex';\n spec: {\n pattern: string;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsMisc {\n kind: 'Misc';\n spec: {\n value: 'empty' | 'null' | 'NaN' | 'true' | 'false';\n result: MappedValue;\n };\n}\n\nexport interface MappedValue {\n value: number | string;\n color?: string;\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;AAyCjC,WAGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/variables.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 { Definition, UnknownSpec } from './definitions';\nimport { Display } from './display';\nimport { Metadata, ProjectMetadata } from './resource';\n\nexport type VariableName = string;\n\nexport type VariableValue = string | string[] | null;\n\nexport interface VariableDisplay extends Display {\n hidden?: boolean;\n}\n\nexport interface VariableSpec {\n name: VariableName;\n display?: VariableDisplay;\n}\n\nexport interface TextVariableDefinition extends Definition<TextVariableSpec> {\n kind: 'TextVariable';\n}\n\nexport interface TextVariableSpec extends VariableSpec {\n value: string;\n constant?: boolean;\n}\n\nexport interface ListVariableDefinition extends Definition<ListVariableSpec> {\n kind: 'ListVariable';\n}\n\nexport interface ListVariableSpec<PluginSpec = UnknownSpec> extends VariableSpec {\n defaultValue?: VariableValue;\n allowMultiple: boolean;\n allowAllValue: boolean;\n customAllValue?: string;\n capturingRegexp?: string;\n sort?: string;\n plugin: Definition<PluginSpec>;\n}\n\nexport interface BuiltinVariableDefinition extends Definition<BuiltinVariableSpec> {\n kind: 'BuiltinVariable';\n}\n\nexport interface BuiltinVariableSpec extends VariableSpec {\n value: () => string;\n source: string;\n}\n\nexport type VariableDefinition = TextVariableDefinition | ListVariableDefinition;\n\n/**\n * A variable that belongs to a project.\n */\nexport interface VariableResource {\n kind: 'Variable';\n metadata: ProjectMetadata;\n spec: VariableDefinition;\n}\n\n/**\n * A global variable that doesn´t belong to a project.\n */\nexport interface GlobalVariableResource {\n kind: 'GlobalVariable';\n metadata: Metadata;\n spec: VariableDefinition;\n}\n\nexport type Variable = VariableResource | GlobalVariableResource;\n\nexport function getVariableProject(variable: Variable): string | undefined {\n return 'project' in variable.metadata ? variable.metadata.project : undefined;\n}\n\nexport const DEFAULT_ALL_VALUE = '$__all' as const;\n"],"names":["getVariableProject","variable","metadata","project","undefined","DEFAULT_ALL_VALUE"],"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;AAyEjC,OAAO,SAASA,mBAAmBC,QAAkB;IACnD,OAAO,aAAaA,SAASC,QAAQ,GAAGD,SAASC,QAAQ,CAACC,OAAO,GAAGC;AACtE;AAEA,OAAO,MAAMC,oBAAoB,SAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/datasource.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 { z } from 'zod';\nimport { Datasource, DatasourceDefinition, DatasourceSpec } from '../model';\nimport { metadataSchema, projectMetadataSchema } from './metadata';\nimport { PluginSchema, pluginSchema } from './plugin';\nimport { displaySchema } from './display';\n\nexport const datasourceSpecSchema: z.ZodSchema<DatasourceSpec> = z.object({\n display: displaySchema.optional(),\n default: z.boolean(),\n plugin: pluginSchema,\n});\n\nexport function buildDatasourceSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<DatasourceSpec> {\n return z.object({\n display: displaySchema.optional(),\n default: z.boolean(),\n plugin: pluginSchema,\n });\n}\n\nexport const datasourceSchema = z.object({\n kind: z.literal('Datasource'),\n metadata: projectMetadataSchema,\n spec: datasourceSpecSchema,\n});\n\nexport const globalDatasourceSchema = z.object({\n kind: z.literal('GlobalDatasource'),\n metadata: metadataSchema,\n spec: datasourceSpecSchema,\n});\n\nexport const datasourcesSchema: z.Schema<Datasource> = z.discriminatedUnion('kind', [\n datasourceSchema,\n globalDatasourceSchema,\n]);\n\nexport const datasourceDefinitionSchema: z.Schema<DatasourceDefinition> = z.object({\n name: z.string().min(1),\n spec: datasourceSpecSchema,\n});\n\nexport function buildDatasourceDefinitionSchema(pluginSchema: PluginSchema): z.Schema<DatasourceDefinition> {\n return z.object({\n name: z.string().min(1),\n spec: buildDatasourceSpecSchema(pluginSchema),\n });\n}\n"],"names":["z","metadataSchema","projectMetadataSchema","pluginSchema","displaySchema","datasourceSpecSchema","object","display","optional","default","boolean","plugin","buildDatasourceSpecSchema","datasourceSchema","kind","literal","metadata","spec","globalDatasourceSchema","datasourcesSchema","discriminatedUnion","datasourceDefinitionSchema","name","string","min","buildDatasourceDefinitionSchema"],"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,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,aAAa;AACnE,SAAuBC,YAAY,QAAQ,WAAW;AACtD,SAASC,aAAa,QAAQ,YAAY;AAE1C,OAAO,MAAMC,uBAAoDL,EAAEM,MAAM,CAAC;IACxEC,SAASH,cAAcI,QAAQ;IAC/BC,SAAST,EAAEU,OAAO;IAClBC,QAAQR;AACV,GAAG;AAEH,OAAO,SAASS,0BAA0BT,YAA0B;IAClE,OAAOH,EAAEM,MAAM,CAAC;QACdC,SAASH,cAAcI,QAAQ;QAC/BC,SAAST,EAAEU,OAAO;QAClBC,QAAQR;IACV;AACF;AAEA,OAAO,MAAMU,mBAAmBb,EAAEM,MAAM,CAAC;IACvCQ,MAAMd,EAAEe,OAAO,CAAC;IAChBC,UAAUd;IACVe,MAAMZ;AACR,GAAG;AAEH,OAAO,MAAMa,yBAAyBlB,EAAEM,MAAM,CAAC;IAC7CQ,MAAMd,EAAEe,OAAO,CAAC;IAChBC,UAAUf;IACVgB,MAAMZ;AACR,GAAG;AAEH,OAAO,MAAMc,oBAA0CnB,EAAEoB,kBAAkB,CAAC,QAAQ;IAClFP;IACAK;CACD,EAAE;AAEH,OAAO,MAAMG,6BAA6DrB,EAAEM,MAAM,CAAC;IACjFgB,MAAMtB,EAAEuB,MAAM,GAAGC,GAAG,CAAC;IACrBP,MAAMZ;AACR,GAAG;AAEH,OAAO,SAASoB,gCAAgCtB,YAA0B;IACxE,OAAOH,EAAEM,MAAM,CAAC;QACdgB,MAAMtB,EAAEuB,MAAM,GAAGC,GAAG,CAAC;QACrBP,MAAML,0BAA0BT;IAClC;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/display.ts"],"sourcesContent":["// Copyright 2024 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 { z } from 'zod';\n\nexport const displaySchema = z.object({\n name: z.string().optional(),\n description: z.string().optional(),\n});\n"],"names":["z","displaySchema","object","name","string","optional","description"],"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,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,gBAAgBD,EAAEE,MAAM,CAAC;IACpCC,MAAMH,EAAEI,MAAM,GAAGC,QAAQ;IACzBC,aAAaN,EAAEI,MAAM,GAAGC,QAAQ;AAClC,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/duration.ts"],"sourcesContent":["// Copyright 2024 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 { z } from 'zod';\nimport { DURATION_REGEX } from '../model';\n\nexport const durationValidationSchema = z\n .string()\n .min(1, 'Required')\n .regex(DURATION_REGEX, 'Must be a valid duration string');\n"],"names":["z","DURATION_REGEX","durationValidationSchema","string","min","regex"],"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,CAAC,QAAQ,MAAM;AACxB,SAASC,cAAc,QAAQ,WAAW;AAE1C,OAAO,MAAMC,2BAA2BF,EACrCG,MAAM,GACNC,GAAG,CAAC,GAAG,YACPC,KAAK,CAACJ,gBAAgB,mCAAmC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/index.ts"],"sourcesContent":["// Copyright 2024 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\nexport * from './datasource';\nexport * from './display';\nexport * from './duration';\nexport * from './metadata';\nexport * from './panel';\nexport * from './plugin';\nexport * from './role';\nexport * from './rolebinding';\nexport * from './secret';\nexport * from './user';\nexport * from './variable';\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,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,gBAAgB;AAC9B,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/metadata.ts"],"sourcesContent":["// Copyright 2024 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 { z } from 'zod';\n\nexport const nameSchema = z\n .string()\n .min(1, 'Required')\n .max(75, 'Must be 75 or fewer characters long')\n .regex(/^[a-zA-Z0-9_.-]+$/, 'Must only contains alphanumerical characters and special characters _ . -');\n\nexport const metadataSchema = z.object({\n name: nameSchema,\n});\n\nexport const projectMetadataSchema = metadataSchema.extend({\n project: nameSchema,\n});\n"],"names":["z","nameSchema","string","min","max","regex","metadataSchema","object","name","projectMetadataSchema","extend","project"],"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,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,aAAaD,EACvBE,MAAM,GACNC,GAAG,CAAC,GAAG,YACPC,GAAG,CAAC,IAAI,uCACRC,KAAK,CAAC,qBAAqB,6EAA6E;AAE3G,OAAO,MAAMC,iBAAiBN,EAAEO,MAAM,CAAC;IACrCC,MAAMP;AACR,GAAG;AAEH,OAAO,MAAMQ,wBAAwBH,eAAeI,MAAM,CAAC;IACzDC,SAASV;AACX,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/panel.ts"],"sourcesContent":["// Copyright 2024 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 { z } from 'zod';\nimport { Link, PanelDefinition, PanelDisplay, PanelEditorValues, PanelSpec, QueryDefinition } from '../model';\nimport { PluginSchema, pluginSchema } from './plugin';\n\nexport const panelDisplaySpec: z.ZodSchema<PanelDisplay> = z.object({\n name: z.string().min(1, { message: 'Required' }),\n description: z.string().optional(),\n});\n\nexport const querySpecSchema: z.ZodSchema<QueryDefinition> = z.object({\n kind: z.string().min(1),\n spec: z.object({\n plugin: pluginSchema,\n }),\n});\n\nexport const linkSchema: z.ZodSchema<Link> = z.object({\n name: z.string().optional(),\n url: z.string().min(1),\n tooltip: z.string().optional(),\n renderVariables: z.boolean().optional(),\n targetBlank: z.boolean().optional(),\n});\n\nexport const panelSpecSchema: z.ZodSchema<PanelSpec> = z.object({\n display: panelDisplaySpec,\n plugin: pluginSchema,\n queries: z.array(querySpecSchema).optional(),\n links: z.array(linkSchema).optional(),\n});\n\nexport function buildPanelSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<PanelSpec> {\n return z.object({\n display: panelDisplaySpec,\n plugin: pluginSchema,\n queries: z.array(querySpecSchema).optional(),\n links: z.array(linkSchema).optional(),\n });\n}\n\nexport const panelDefinitionSchema: z.ZodSchema<PanelDefinition> = z.object({\n kind: z.literal('Panel'),\n spec: panelSpecSchema,\n});\n\nexport function buildPanelDefinitionSchema(pluginSchema: PluginSchema): z.ZodSchema<PanelDefinition> {\n return z.object({\n kind: z.literal('Panel'),\n spec: buildPanelSpecSchema(pluginSchema),\n });\n}\n\nexport const panelEditorSchema: z.ZodSchema<PanelEditorValues> = z.object({\n groupId: z.number(),\n panelDefinition: panelDefinitionSchema,\n});\n\nexport function buildPanelEditorSchema(pluginSchema: PluginSchema): z.ZodSchema<PanelEditorValues> {\n return z.object({\n groupId: z.number(),\n panelDefinition: buildPanelDefinitionSchema(pluginSchema),\n });\n}\n"],"names":["z","pluginSchema","panelDisplaySpec","object","name","string","min","message","description","optional","querySpecSchema","kind","spec","plugin","linkSchema","url","tooltip","renderVariables","boolean","targetBlank","panelSpecSchema","display","queries","array","links","buildPanelSpecSchema","panelDefinitionSchema","literal","buildPanelDefinitionSchema","panelEditorSchema","groupId","number","panelDefinition","buildPanelEditorSchema"],"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,CAAC,QAAQ,MAAM;AAExB,SAAuBC,YAAY,QAAQ,WAAW;AAEtD,OAAO,MAAMC,mBAA8CF,EAAEG,MAAM,CAAC;IAClEC,MAAMJ,EAAEK,MAAM,GAAGC,GAAG,CAAC,GAAG;QAAEC,SAAS;IAAW;IAC9CC,aAAaR,EAAEK,MAAM,GAAGI,QAAQ;AAClC,GAAG;AAEH,OAAO,MAAMC,kBAAgDV,EAAEG,MAAM,CAAC;IACpEQ,MAAMX,EAAEK,MAAM,GAAGC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+B,MAAM;QACjBC,iBAAiBJ,2BAA2B3B;IAC9C;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/schema/plugin.ts"],"sourcesContent":["// Copyright 2024 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 { z } from 'zod';\n\nexport const pluginSchema = z.object({\n kind: z.string().min(1, 'Required'),\n spec: z.record(z.string(), z.any()),\n});\n\nexport type PluginSchemaType = z.infer<typeof pluginSchema>;\nexport type PluginSchema = typeof pluginSchema;\n"],"names":["z","pluginSchema","object","kind","string","min","spec","record","any"],"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,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,eAAeD,EAAEE,MAAM,CAAC;IACnCC,MAAMH,EAAEI,MAAM,GAAGC,GAAG,CAAC,GAAG;IACxBC,MAAMN,EAAEO,MAAM,CAACP,EAAEI,MAAM,IAAIJ,EAAEQ,GAAG;AAClC,GAAG"}
|