@perses-dev/core 0.53.0-rc.0 → 0.53.0-rc.2

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.
Files changed (252) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cjs/constants/dashboard-defaults.js +1 -1
  3. package/dist/cjs/constants/index.js +1 -1
  4. package/dist/cjs/index.js +1 -1
  5. package/dist/cjs/model/base-metadata.js +1 -1
  6. package/dist/cjs/model/calculations.js +1 -1
  7. package/dist/cjs/model/dashboard.js +1 -1
  8. package/dist/cjs/model/datasource-api.js +1 -1
  9. package/dist/cjs/model/datasource.js +1 -1
  10. package/dist/cjs/model/definitions.js +1 -1
  11. package/dist/cjs/model/display.js +1 -1
  12. package/dist/cjs/model/ephemeraldashboard.js +1 -1
  13. package/dist/cjs/model/external-variable.js +1 -1
  14. package/dist/cjs/model/http-proxy.js +1 -1
  15. package/dist/cjs/model/http.js +1 -1
  16. package/dist/cjs/model/index.js +1 -1
  17. package/dist/cjs/model/kind.js +1 -1
  18. package/dist/cjs/model/layout.js +1 -1
  19. package/dist/cjs/model/legend.js +1 -1
  20. package/dist/cjs/model/log-data.js +1 -1
  21. package/dist/cjs/model/notice.js +1 -1
  22. package/dist/cjs/model/otlp/common/v1/common.js +1 -1
  23. package/dist/cjs/model/otlp/index.js +1 -1
  24. package/dist/cjs/model/otlp/resource/v1/resource.js +1 -1
  25. package/dist/cjs/model/otlp/trace/v1/trace.js +1 -1
  26. package/dist/cjs/model/panel-group.js +1 -1
  27. package/dist/cjs/model/panels.js +1 -1
  28. package/dist/cjs/model/profile-data.js +1 -1
  29. package/dist/cjs/model/project.js +1 -1
  30. package/dist/cjs/model/query.js +1 -1
  31. package/dist/cjs/model/resource.js +1 -1
  32. package/dist/cjs/model/rolebindings.js +1 -1
  33. package/dist/cjs/model/roles.js +1 -1
  34. package/dist/cjs/model/secrets.js +1 -1
  35. package/dist/cjs/model/thresholds.js +1 -1
  36. package/dist/cjs/model/time-series-data.js +1 -1
  37. package/dist/cjs/model/time-series-queries.js +1 -1
  38. package/dist/cjs/model/time.js +1 -1
  39. package/dist/cjs/model/trace-data.js +1 -1
  40. package/dist/cjs/model/transforms.js +3 -2
  41. package/dist/cjs/model/units/bits.js +1 -1
  42. package/dist/cjs/model/units/bytes.js +1 -1
  43. package/dist/cjs/model/units/constants.js +1 -1
  44. package/dist/cjs/model/units/currency.js +1 -1
  45. package/dist/cjs/model/units/date.js +1 -1
  46. package/dist/cjs/model/units/decimal.js +1 -1
  47. package/dist/cjs/model/units/index.js +1 -1
  48. package/dist/cjs/model/units/percent.js +1 -1
  49. package/dist/cjs/model/units/temperature.js +1 -1
  50. package/dist/cjs/model/units/throughput.js +1 -1
  51. package/dist/cjs/model/units/time.js +1 -1
  52. package/dist/cjs/model/units/types.js +1 -1
  53. package/dist/cjs/model/units/units.js +1 -1
  54. package/dist/cjs/model/units/utils.js +1 -1
  55. package/dist/cjs/model/user.js +1 -1
  56. package/dist/cjs/model/value-mapping.js +1 -1
  57. package/dist/cjs/model/variables.js +1 -1
  58. package/dist/cjs/schema/datasource.js +1 -1
  59. package/dist/cjs/schema/display.js +1 -1
  60. package/dist/cjs/schema/duration.js +1 -1
  61. package/dist/cjs/schema/index.js +1 -1
  62. package/dist/cjs/schema/metadata.js +1 -1
  63. package/dist/cjs/schema/panel.js +1 -1
  64. package/dist/cjs/schema/plugin.js +1 -1
  65. package/dist/cjs/schema/role.js +1 -1
  66. package/dist/cjs/schema/rolebinding.js +1 -1
  67. package/dist/cjs/schema/secret.js +1 -1
  68. package/dist/cjs/schema/user.js +1 -1
  69. package/dist/cjs/schema/variable.js +1 -1
  70. package/dist/cjs/test/setup-tests.js +1 -1
  71. package/dist/cjs/utils/fetch.js +1 -1
  72. package/dist/cjs/utils/index.js +1 -1
  73. package/dist/cjs/utils/is-empty-object.js +1 -1
  74. package/dist/cjs/utils/mathjs.js +1 -1
  75. package/dist/cjs/utils/panel-refs.js +1 -1
  76. package/dist/cjs/utils/regexp.js +1 -1
  77. package/dist/cjs/utils/text.js +1 -1
  78. package/dist/cjs/utils/time-series-data.js +1 -1
  79. package/dist/cjs/utils/transform-data.js +1 -1
  80. package/dist/cjs/utils/types.js +1 -1
  81. package/dist/cjs/utils/value-mapping.js +1 -1
  82. package/dist/constants/dashboard-defaults.js +1 -1
  83. package/dist/constants/dashboard-defaults.js.map +1 -1
  84. package/dist/constants/index.js +1 -1
  85. package/dist/constants/index.js.map +1 -1
  86. package/dist/index.js +1 -1
  87. package/dist/index.js.map +1 -1
  88. package/dist/model/base-metadata.js +1 -1
  89. package/dist/model/base-metadata.js.map +1 -1
  90. package/dist/model/calculations.js +1 -1
  91. package/dist/model/calculations.js.map +1 -1
  92. package/dist/model/dashboard.d.ts +1 -0
  93. package/dist/model/dashboard.d.ts.map +1 -1
  94. package/dist/model/dashboard.js +1 -1
  95. package/dist/model/dashboard.js.map +1 -1
  96. package/dist/model/datasource-api.js +1 -1
  97. package/dist/model/datasource-api.js.map +1 -1
  98. package/dist/model/datasource.js +1 -1
  99. package/dist/model/datasource.js.map +1 -1
  100. package/dist/model/definitions.js +1 -1
  101. package/dist/model/definitions.js.map +1 -1
  102. package/dist/model/display.js +1 -1
  103. package/dist/model/display.js.map +1 -1
  104. package/dist/model/ephemeraldashboard.js +1 -1
  105. package/dist/model/ephemeraldashboard.js.map +1 -1
  106. package/dist/model/external-variable.js +1 -1
  107. package/dist/model/external-variable.js.map +1 -1
  108. package/dist/model/http-proxy.js +1 -1
  109. package/dist/model/http-proxy.js.map +1 -1
  110. package/dist/model/http.js +1 -1
  111. package/dist/model/http.js.map +1 -1
  112. package/dist/model/index.js +1 -1
  113. package/dist/model/index.js.map +1 -1
  114. package/dist/model/kind.js +1 -1
  115. package/dist/model/kind.js.map +1 -1
  116. package/dist/model/layout.js +1 -1
  117. package/dist/model/layout.js.map +1 -1
  118. package/dist/model/legend.js +1 -1
  119. package/dist/model/legend.js.map +1 -1
  120. package/dist/model/log-data.js +1 -1
  121. package/dist/model/log-data.js.map +1 -1
  122. package/dist/model/notice.js +1 -1
  123. package/dist/model/notice.js.map +1 -1
  124. package/dist/model/otlp/common/v1/common.d.ts +13 -3
  125. package/dist/model/otlp/common/v1/common.d.ts.map +1 -1
  126. package/dist/model/otlp/common/v1/common.js +1 -1
  127. package/dist/model/otlp/common/v1/common.js.map +1 -1
  128. package/dist/model/otlp/index.js +1 -1
  129. package/dist/model/otlp/index.js.map +1 -1
  130. package/dist/model/otlp/resource/v1/resource.js +1 -1
  131. package/dist/model/otlp/resource/v1/resource.js.map +1 -1
  132. package/dist/model/otlp/trace/v1/trace.d.ts +4 -2
  133. package/dist/model/otlp/trace/v1/trace.d.ts.map +1 -1
  134. package/dist/model/otlp/trace/v1/trace.js +1 -1
  135. package/dist/model/otlp/trace/v1/trace.js.map +1 -1
  136. package/dist/model/panel-group.js +1 -1
  137. package/dist/model/panel-group.js.map +1 -1
  138. package/dist/model/panels.js +1 -1
  139. package/dist/model/panels.js.map +1 -1
  140. package/dist/model/profile-data.js +1 -1
  141. package/dist/model/profile-data.js.map +1 -1
  142. package/dist/model/project.js +1 -1
  143. package/dist/model/project.js.map +1 -1
  144. package/dist/model/query.js +1 -1
  145. package/dist/model/query.js.map +1 -1
  146. package/dist/model/resource.d.ts +1 -0
  147. package/dist/model/resource.d.ts.map +1 -1
  148. package/dist/model/resource.js +1 -1
  149. package/dist/model/resource.js.map +1 -1
  150. package/dist/model/rolebindings.js +1 -1
  151. package/dist/model/rolebindings.js.map +1 -1
  152. package/dist/model/roles.js +1 -1
  153. package/dist/model/roles.js.map +1 -1
  154. package/dist/model/secrets.js +1 -1
  155. package/dist/model/secrets.js.map +1 -1
  156. package/dist/model/thresholds.js +1 -1
  157. package/dist/model/thresholds.js.map +1 -1
  158. package/dist/model/time-series-data.js +1 -1
  159. package/dist/model/time-series-data.js.map +1 -1
  160. package/dist/model/time-series-queries.js +1 -1
  161. package/dist/model/time-series-queries.js.map +1 -1
  162. package/dist/model/time.js +1 -1
  163. package/dist/model/time.js.map +1 -1
  164. package/dist/model/trace-data.js +1 -1
  165. package/dist/model/trace-data.js.map +1 -1
  166. package/dist/model/transforms.d.ts +10 -1
  167. package/dist/model/transforms.d.ts.map +1 -1
  168. package/dist/model/transforms.js +3 -2
  169. package/dist/model/transforms.js.map +1 -1
  170. package/dist/model/units/bits.js +1 -1
  171. package/dist/model/units/bits.js.map +1 -1
  172. package/dist/model/units/bytes.js +1 -1
  173. package/dist/model/units/bytes.js.map +1 -1
  174. package/dist/model/units/constants.js +1 -1
  175. package/dist/model/units/constants.js.map +1 -1
  176. package/dist/model/units/currency.js +1 -1
  177. package/dist/model/units/currency.js.map +1 -1
  178. package/dist/model/units/date.js +1 -1
  179. package/dist/model/units/date.js.map +1 -1
  180. package/dist/model/units/decimal.js +1 -1
  181. package/dist/model/units/decimal.js.map +1 -1
  182. package/dist/model/units/index.js +1 -1
  183. package/dist/model/units/index.js.map +1 -1
  184. package/dist/model/units/percent.js +1 -1
  185. package/dist/model/units/percent.js.map +1 -1
  186. package/dist/model/units/temperature.js +1 -1
  187. package/dist/model/units/temperature.js.map +1 -1
  188. package/dist/model/units/throughput.js +1 -1
  189. package/dist/model/units/throughput.js.map +1 -1
  190. package/dist/model/units/time.js +1 -1
  191. package/dist/model/units/time.js.map +1 -1
  192. package/dist/model/units/types.js +1 -1
  193. package/dist/model/units/types.js.map +1 -1
  194. package/dist/model/units/units.js +1 -1
  195. package/dist/model/units/units.js.map +1 -1
  196. package/dist/model/units/utils.js +1 -1
  197. package/dist/model/units/utils.js.map +1 -1
  198. package/dist/model/user.js +1 -1
  199. package/dist/model/user.js.map +1 -1
  200. package/dist/model/value-mapping.js +1 -1
  201. package/dist/model/value-mapping.js.map +1 -1
  202. package/dist/model/variables.js +1 -1
  203. package/dist/model/variables.js.map +1 -1
  204. package/dist/schema/datasource.js +1 -1
  205. package/dist/schema/datasource.js.map +1 -1
  206. package/dist/schema/display.js +1 -1
  207. package/dist/schema/display.js.map +1 -1
  208. package/dist/schema/duration.js +1 -1
  209. package/dist/schema/duration.js.map +1 -1
  210. package/dist/schema/index.js +1 -1
  211. package/dist/schema/index.js.map +1 -1
  212. package/dist/schema/metadata.js +1 -1
  213. package/dist/schema/metadata.js.map +1 -1
  214. package/dist/schema/panel.js +1 -1
  215. package/dist/schema/panel.js.map +1 -1
  216. package/dist/schema/plugin.js +1 -1
  217. package/dist/schema/plugin.js.map +1 -1
  218. package/dist/schema/role.js +1 -1
  219. package/dist/schema/role.js.map +1 -1
  220. package/dist/schema/rolebinding.js +1 -1
  221. package/dist/schema/rolebinding.js.map +1 -1
  222. package/dist/schema/secret.js +1 -1
  223. package/dist/schema/secret.js.map +1 -1
  224. package/dist/schema/user.js +1 -1
  225. package/dist/schema/user.js.map +1 -1
  226. package/dist/schema/variable.js +1 -1
  227. package/dist/schema/variable.js.map +1 -1
  228. package/dist/test/setup-tests.js +1 -1
  229. package/dist/test/setup-tests.js.map +1 -1
  230. package/dist/utils/fetch.js +1 -1
  231. package/dist/utils/fetch.js.map +1 -1
  232. package/dist/utils/index.js +1 -1
  233. package/dist/utils/index.js.map +1 -1
  234. package/dist/utils/is-empty-object.js +1 -1
  235. package/dist/utils/is-empty-object.js.map +1 -1
  236. package/dist/utils/mathjs.js +1 -1
  237. package/dist/utils/mathjs.js.map +1 -1
  238. package/dist/utils/panel-refs.js +1 -1
  239. package/dist/utils/panel-refs.js.map +1 -1
  240. package/dist/utils/regexp.js +1 -1
  241. package/dist/utils/regexp.js.map +1 -1
  242. package/dist/utils/text.js +1 -1
  243. package/dist/utils/text.js.map +1 -1
  244. package/dist/utils/time-series-data.js +1 -1
  245. package/dist/utils/time-series-data.js.map +1 -1
  246. package/dist/utils/transform-data.js +1 -1
  247. package/dist/utils/transform-data.js.map +1 -1
  248. package/dist/utils/types.js +1 -1
  249. package/dist/utils/types.js.map +1 -1
  250. package/dist/utils/value-mapping.js +1 -1
  251. package/dist/utils/value-mapping.js.map +1 -1
  252. package/package.json +1 -1
@@ -1 +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"}
1
+ {"version":3,"sources":["../../../../../src/model/otlp/trace/v1/trace.ts"],"sourcesContent":["// Copyright 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: ScopeSpan[];\n}\n\nexport interface ScopeSpan {\n scope?: InstrumentationScope;\n spans: Span[];\n}\n\n/** @deprecated this type was renamed to ScopeSpan */\nexport type ScopeSpans = ScopeSpan;\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,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAwDjC,OAAO,MAAMA,kBAAkB,oBAAoB;AACnD,OAAO,MAAMC,eAAe,iBAAiB;AAC7C,OAAO,MAAMC,kBAAkB,oBAAoB"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/panel-group.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 { PanelGroupId } from './panels';\n\n/**\n * Panel Group Item Layout ID type. String identifier for items within a panel group.\n */\nexport type PanelGroupItemLayoutId = string;\n\n/**\n * Base layout properties for positioning and sizing items in a grid.\n * This is a framework-agnostic representation that can be used with various grid systems.\n */\nexport interface BaseLayout {\n /**\n * Item identifier\n */\n i: string;\n /**\n * X position in grid units\n */\n x: number;\n /**\n * Y position in grid units\n */\n y: number;\n /**\n * Width in grid units\n */\n w: number;\n /**\n * Height in grid units\n */\n h: number;\n}\n\n/**\n * Layout information for an item within a panel group.\n * Extends BaseLayout with a typed identifier.\n */\nexport interface PanelGroupItemLayout extends BaseLayout {\n i: PanelGroupItemLayoutId;\n}\n\n/**\n * Uniquely identifies an item in a PanelGroup.\n */\nexport interface PanelGroupItemId {\n panelGroupId: PanelGroupId;\n panelGroupItemLayoutId: PanelGroupItemLayoutId;\n repeatVariable?: [string, string]; // Optional, used for repeated panel groups. Variable name and value.\n}\n\n/**\n * Definition of a panel group, containing layout and panel information.\n */\nexport interface PanelGroupDefinition {\n id: PanelGroupId;\n isCollapsed: boolean;\n title?: string;\n repeatedOriginId?: PanelGroupId; // ID of the original panel group from which this repeated group is derived\n repeatVariable?: string; // Optional, used for repeated panel groups\n itemLayouts: PanelGroupItemLayout[];\n itemPanelKeys: Record<PanelGroupItemLayoutId, string>;\n}\n\n/**\n * Check if two PanelGroupItemId are equal\n */\nexport function isPanelGroupItemIdEqual(a?: PanelGroupItemId, b?: PanelGroupItemId): boolean {\n return a?.panelGroupId === b?.panelGroupId && a?.panelGroupItemLayoutId === b?.panelGroupItemLayoutId;\n}\n"],"names":["isPanelGroupItemIdEqual","a","b","panelGroupId","panelGroupItemLayoutId"],"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;AAkEjC;;CAEC,GACD,OAAO,SAASA,wBAAwBC,CAAoB,EAAEC,CAAoB;IAChF,OAAOD,GAAGE,iBAAiBD,GAAGC,gBAAgBF,GAAGG,2BAA2BF,GAAGE;AACjF"}
1
+ {"version":3,"sources":["../../src/model/panel-group.ts"],"sourcesContent":["// Copyright 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 { PanelGroupId } from './panels';\n\n/**\n * Panel Group Item Layout ID type. String identifier for items within a panel group.\n */\nexport type PanelGroupItemLayoutId = string;\n\n/**\n * Base layout properties for positioning and sizing items in a grid.\n * This is a framework-agnostic representation that can be used with various grid systems.\n */\nexport interface BaseLayout {\n /**\n * Item identifier\n */\n i: string;\n /**\n * X position in grid units\n */\n x: number;\n /**\n * Y position in grid units\n */\n y: number;\n /**\n * Width in grid units\n */\n w: number;\n /**\n * Height in grid units\n */\n h: number;\n}\n\n/**\n * Layout information for an item within a panel group.\n * Extends BaseLayout with a typed identifier.\n */\nexport interface PanelGroupItemLayout extends BaseLayout {\n i: PanelGroupItemLayoutId;\n}\n\n/**\n * Uniquely identifies an item in a PanelGroup.\n */\nexport interface PanelGroupItemId {\n panelGroupId: PanelGroupId;\n panelGroupItemLayoutId: PanelGroupItemLayoutId;\n repeatVariable?: [string, string]; // Optional, used for repeated panel groups. Variable name and value.\n}\n\n/**\n * Definition of a panel group, containing layout and panel information.\n */\nexport interface PanelGroupDefinition {\n id: PanelGroupId;\n isCollapsed: boolean;\n title?: string;\n repeatedOriginId?: PanelGroupId; // ID of the original panel group from which this repeated group is derived\n repeatVariable?: string; // Optional, used for repeated panel groups\n itemLayouts: PanelGroupItemLayout[];\n itemPanelKeys: Record<PanelGroupItemLayoutId, string>;\n}\n\n/**\n * Check if two PanelGroupItemId are equal\n */\nexport function isPanelGroupItemIdEqual(a?: PanelGroupItemId, b?: PanelGroupItemId): boolean {\n return a?.panelGroupId === b?.panelGroupId && a?.panelGroupItemLayoutId === b?.panelGroupItemLayoutId;\n}\n"],"names":["isPanelGroupItemIdEqual","a","b","panelGroupId","panelGroupItemLayoutId"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAkEjC;;CAEC,GACD,OAAO,SAASA,wBAAwBC,CAAoB,EAAEC,CAAoB;IAChF,OAAOD,GAAGE,iBAAiBD,GAAGC,gBAAgBF,GAAGG,2BAA2BF,GAAGE;AACjF"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/model/panels.ts"],"sourcesContent":["// Copyright 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,+BAA+B;AAC/B,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"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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\nimport { BaseMetadata } from './base-metadata';\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 extends BaseMetadata {\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;AAoDjC,WAKC"}
1
+ {"version":3,"sources":["../../src/model/profile-data.ts"],"sourcesContent":["// Copyright 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 { BaseMetadata } from './base-metadata';\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 extends BaseMetadata {\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,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAoDjC,WAKC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/model/project.ts"],"sourcesContent":["// Copyright 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,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAWjC,WAEC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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';\nimport { LogData } from './log-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 LogQuery: LogData;\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;AAiCjC;;;CAGC,GACD,OAAO,SAASA,uBAAuBC,IAAY;IACjD,OAAO;QAAC;QAAmB;QAAc;KAAe,CAACC,QAAQ,CAACD;AACpE"}
1
+ {"version":3,"sources":["../../src/model/query.ts"],"sourcesContent":["// Copyright 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';\nimport { LogData } from './log-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 LogQuery: LogData;\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,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAiCjC;;;CAGC,GACD,OAAO,SAASA,uBAAuBC,IAAY;IACjD,OAAO;QAAC;QAAmB;QAAc;KAAe,CAACC,QAAQ,CAACD;AACpE"}
@@ -5,6 +5,7 @@ export interface Metadata {
5
5
  createdAt?: string;
6
6
  updatedAt?: string;
7
7
  version?: number;
8
+ tags?: string[];
8
9
  }
9
10
  export interface ProjectMetadata extends Metadata {
10
11
  project: string;
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/model/resource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,eAAe,GAAG,QAAQ,IAAI,eAAe,CAEnG;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,QAAQ,GAAG,eAAe,CAAC;IAErC,IAAI,EAAE,GAAG,CAAC;CACX;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAE3F"}
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/model/resource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,eAAe,GAAG,QAAQ,IAAI,eAAe,CAEnG;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,QAAQ,GAAG,eAAe,CAAC;IAErC,IAAI,EAAE,GAAG,CAAC;CACX;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAE3F"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/model/resource.ts"],"sourcesContent":["// Copyright 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 tags?: string[];\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,+BAA+B;AAC/B,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;AAqBA,OAAO,SAASC,mBAAmBD,QAAoC;IACrE,OAAO,aAAaA,WAAWA,SAASE,OAAO,GAAGC;AACpD"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/model/rolebindings.ts"],"sourcesContent":["// Copyright 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,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAiCjC,WAA0E"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/model/roles.ts"],"sourcesContent":["// Copyright 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,+BAA+B;AAC/B,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"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/model/secrets.ts"],"sourcesContent":["// Copyright 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,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA8DjC,WAA2D"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/model/thresholds.ts"],"sourcesContent":["// Copyright 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,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAejC,WAGC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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 { BaseMetadata } from './base-metadata';\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 extends BaseMetadata {\n [key: string]: unknown;\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,WAEC"}
1
+ {"version":3,"sources":["../../src/model/time-series-data.ts"],"sourcesContent":["// Copyright 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 { BaseMetadata } from './base-metadata';\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 extends BaseMetadata {\n [key: string]: unknown;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA4BjC,WAEC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/model/time-series-queries.ts"],"sourcesContent":["// Copyright 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,+BAA+B;AAC/B,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"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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,gCAA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iB;QAAI+C,SAAS;IAAM;IAC3E,UAAU;IACV;QAAEF,OAAO3C;QAAgB4C,eAAe7C;QAAe8C,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"}
1
+ {"version":3,"sources":["../../src/model/time.ts"],"sourcesContent":["// Copyright 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,+BAA+B;AAC/B,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,iB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C;QAAgB4C,eAAe7C;QAAe8C,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"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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 { BaseMetadata } from './base-metadata';\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 extends BaseMetadata {\n /** this field indicates if there are more traces matching the search query, however not all traces were returned */\n hasMoreResults?: boolean;\n [key: string]: unknown;\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;AA2CjC,OAAO,SAASA,eAAeC,OAAe;IAC5C,OAAO,iBAAiBC,IAAI,CAACD;AAC/B"}
1
+ {"version":3,"sources":["../../src/model/trace-data.ts"],"sourcesContent":["// Copyright 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 { BaseMetadata } from './base-metadata';\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 extends BaseMetadata {\n /** this field indicates if there are more traces matching the search query, however not all traces were returned */\n hasMoreResults?: boolean;\n [key: string]: unknown;\n}\n\nexport function isValidTraceId(traceId: string): boolean {\n return /^[0-9a-fA-F]+$/.test(traceId);\n}\n"],"names":["isValidTraceId","traceId","test"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA2CjC,OAAO,SAASA,eAAeC,OAAe;IAC5C,OAAO,iBAAiBC,IAAI,CAACD;AAC/B"}
@@ -7,6 +7,14 @@ export interface JoinByColumnValueTransform {
7
7
  columns: string[];
8
8
  };
9
9
  }
10
+ export interface ExtractColumnFieldsTransform {
11
+ kind: 'ExtractColumnFields';
12
+ spec: TransformCommonSpec & {
13
+ column: string;
14
+ format: 'JSON' | 'Regex' | 'SplitByDelimiter' | 'KeyValuePairs';
15
+ matcher?: string;
16
+ };
17
+ }
10
18
  export interface MergeColumnsTransform {
11
19
  kind: 'MergeColumns';
12
20
  spec: TransformCommonSpec & {
@@ -24,11 +32,12 @@ export interface MergeSeriesTransform {
24
32
  kind: 'MergeSeries';
25
33
  spec: TransformCommonSpec;
26
34
  }
27
- export type Transform = JoinByColumnValueTransform | MergeColumnsTransform | MergeIndexedColumnsTransform | MergeSeriesTransform;
35
+ export type Transform = JoinByColumnValueTransform | MergeColumnsTransform | MergeIndexedColumnsTransform | MergeSeriesTransform | ExtractColumnFieldsTransform;
28
36
  export declare const TRANSFORM_TEXT: {
29
37
  JoinByColumnValue: string;
30
38
  MergeColumns: string;
31
39
  MergeIndexedColumns: string;
32
40
  MergeSeries: string;
41
+ ExtractColumnFields: string;
33
42
  };
34
43
  //# sourceMappingURL=transforms.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../../src/model/transforms.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,EAAE,mBAAmB,GAAG;QAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,mBAAmB,GAAG;QAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,mBAAmB,GAAG;QAC1B,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,MAAM,MAAM,SAAS,GACjB,0BAA0B,GAC1B,qBAAqB,GACrB,4BAA4B,GAC5B,oBAAoB,CAAC;AAGzB,eAAO,MAAM,cAAc;;;;;CAK1B,CAAC"}
1
+ {"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../../src/model/transforms.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,EAAE,mBAAmB,GAAG;QAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,mBAAmB,GAAG;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,kBAAkB,GAAG,eAAe,CAAC;QAChE,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,mBAAmB,GAAG;QAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,mBAAmB,GAAG;QAC1B,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,mBAAmB,CAAC;CAC3B;AAED,MAAM,MAAM,SAAS,GACjB,0BAA0B,GAC1B,qBAAqB,GACrB,4BAA4B,GAC5B,oBAAoB,GACpB,4BAA4B,CAAC;AAGjC,eAAO,MAAM,cAAc;;;;;;CAM1B,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -15,7 +15,8 @@ export const TRANSFORM_TEXT = {
15
15
  JoinByColumnValue: 'Join by column value',
16
16
  MergeColumns: 'Merge columns',
17
17
  MergeIndexedColumns: 'Merge indexed columns',
18
- MergeSeries: 'Merge series'
18
+ MergeSeries: 'Merge series',
19
+ ExtractColumnFields: 'Extract column fields'
19
20
  };
20
21
 
21
22
  //# sourceMappingURL=transforms.js.map
@@ -1 +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"}
1
+ {"version":3,"sources":["../../src/model/transforms.ts"],"sourcesContent":["// Copyright 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 ExtractColumnFieldsTransform {\n kind: 'ExtractColumnFields';\n spec: TransformCommonSpec & {\n column: string;\n format: 'JSON' | 'Regex' | 'SplitByDelimiter' | 'KeyValuePairs';\n matcher?: 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 | ExtractColumnFieldsTransform;\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 ExtractColumnFields: 'Extract column fields',\n};\n"],"names":["TRANSFORM_TEXT","JoinByColumnValue","MergeColumns","MergeIndexedColumns","MergeSeries","ExtractColumnFields"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAiDjC,8BAA8B;AAC9B,OAAO,MAAMA,iBAAiB;IAC5BC,mBAAmB;IACnBC,cAAc;IACdC,qBAAqB;IACrBC,aAAa;IACbC,qBAAqB;AACvB,EAAE"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/bits.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 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 support both SI (decimal) and IEC (binary) units for bits:\n *\n * SI/decimal (unit: 'decbits'):\n * 1 Kb = 1000 bits (1000^1 bits)\n * 1 Mb = 1,000,000 bits (1000^2 bits)\n * etc.\n *\n * IEC/binary (unit: 'bits'):\n * 1 Kib = 1024 bits (1024^1 bits)\n * 1 Mib = 1,048,576 bits (1024^2 bits)\n * etc.\n */\n\nconst DEFAULT_NUMBRO_MANTISSA = 2;\n\ntype BitsUnit = 'bits' | 'decbits';\n\nexport type BitsFormatOptions = {\n unit?: BitsUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\n\nexport const BITS_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Bits',\n decimalPlaces: true,\n shortValues: true,\n};\n\nexport const BITS_UNIT_CONFIG: Readonly<Record<BitsUnit, UnitConfig>> = {\n bits: {\n group: 'Bits',\n label: 'Bits (IEC)',\n },\n decbits: {\n group: 'Bits',\n label: 'Bits (SI)',\n },\n};\n\nexport function formatBits(bits: number, { unit = 'bits', shortValues, decimalPlaces }: BitsFormatOptions): string {\n const isDecimal = unit === 'decbits';\n const threshold = isDecimal ? 1000 : 1024;\n\n // If we're showing the entire value, we can use Intl.NumberFormat.\n if (!shouldShortenValues(shortValues) || Math.abs(bits) < threshold) {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\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 bits is between -threshold and threshold (1000 for SI, 1024 for IEC)\n if (shouldShortenValues(shortValues)) {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n }\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(bits) + ' bits';\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 const formatted = numbro(bits).format({\n output: 'byte', // numbro uses 'byte' output for bit formatting\n base: isDecimal ? 'decimal' : 'binary',\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 // Replace byte units with bit units\n return formatted\n .replace(/KB/g, 'Kb')\n .replace(/MB/g, 'Mb')\n .replace(/GB/g, 'Gb')\n .replace(/TB/g, 'Tb')\n .replace(/PB/g, 'Pb')\n .replace(/EB/g, 'Eb')\n .replace(/KiB/g, 'Kib')\n .replace(/MiB/g, 'Mib')\n .replace(/GiB/g, 'Gib')\n .replace(/TiB/g, 'Tib')\n .replace(/PiB/g, 'Pib')\n .replace(/EiB/g, 'Eib');\n}\n"],"names":["numbro","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","DEFAULT_NUMBRO_MANTISSA","BITS_GROUP_CONFIG","label","decimalPlaces","shortValues","BITS_UNIT_CONFIG","bits","group","decbits","formatBits","unit","isDecimal","threshold","Math","abs","formatterOptions","style","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format","formatted","output","base","spaceSeparated","mantissa","trimMantissa","optionalMantissa","replace"],"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;;;;;;;;;;;;CAYC,GAED,MAAMC,0BAA0B;AAUhC,OAAO,MAAMC,oBAAqC;IAChDC,OAAO;IACPC,eAAe;IACfC,aAAa;AACf,EAAE;AAEF,OAAO,MAAMC,mBAA2D;IACtE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AChBA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ;AACrB"}
1
+ {"version":3,"sources":["../../../src/model/units/bits.ts"],"sourcesContent":["// Copyright 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 support both SI (decimal) and IEC (binary) units for bits:\n *\n * SI/decimal (unit: 'decbits'):\n * 1 Kb = 1000 bits (1000^1 bits)\n * 1 Mb = 1,000,000 bits (1000^2 bits)\n * etc.\n *\n * IEC/binary (unit: 'bits'):\n * 1 Kib = 1024 bits (1024^1 bits)\n * 1 Mib = 1,048,576 bits (1024^2 bits)\n * etc.\n */\n\nconst DEFAULT_NUMBRO_MANTISSA = 2;\n\ntype BitsUnit = 'bits' | 'decbits';\n\nexport type BitsFormatOptions = {\n unit?: BitsUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\n\nexport const BITS_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Bits',\n decimalPlaces: true,\n shortValues: true,\n};\n\nexport const BITS_UNIT_CONFIG: Readonly<Record<BitsUnit, UnitConfig>> = {\n bits: {\n group: 'Bits',\n label: 'Bits (IEC)',\n },\n decbits: {\n group: 'Bits',\n label: 'Bits (SI)',\n },\n};\n\nexport function formatBits(bits: number, { unit = 'bits', shortValues, decimalPlaces }: BitsFormatOptions): string {\n const isDecimal = unit === 'decbits';\n const threshold = isDecimal ? 1000 : 1024;\n\n // If we're showing the entire value, we can use Intl.NumberFormat.\n if (!shouldShortenValues(shortValues) || Math.abs(bits) < threshold) {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\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 bits is between -threshold and threshold (1000 for SI, 1024 for IEC)\n if (shouldShortenValues(shortValues)) {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n }\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(bits) + ' bits';\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 const formatted = numbro(bits).format({\n output: 'byte', // numbro uses 'byte' output for bit formatting\n base: isDecimal ? 'decimal' : 'binary',\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 // Replace byte units with bit units\n return formatted\n .replace(/KB/g, 'Kb')\n .replace(/MB/g, 'Mb')\n .replace(/GB/g, 'Gb')\n .replace(/TB/g, 'Tb')\n .replace(/PB/g, 'Pb')\n .replace(/EB/g, 'Eb')\n .replace(/KiB/g, 'Kib')\n .replace(/MiB/g, 'Mib')\n .replace(/GiB/g, 'Gib')\n .replace(/TiB/g, 'Tib')\n .replace(/PiB/g, 'Pib')\n .replace(/EiB/g, 'Eib');\n}\n"],"names":["numbro","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","DEFAULT_NUMBRO_MANTISSA","BITS_GROUP_CONFIG","label","decimalPlaces","shortValues","BITS_UNIT_CONFIG","bits","group","decbits","formatBits","unit","isDecimal","threshold","Math","abs","formatterOptions","style","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format","formatted","output","base","spaceSeparated","mantissa","trimMantissa","optionalMantissa","replace"],"mappings":"AAAA,+BAA+B;AAC/B,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;;;;;;;;;;;;CAYC,GAED,MAAMC,0BAA0B;AAUhC,OAAO,MAAMC,oBAAqC;IAChDC,OAAO;IACPC,eAAe;IACfC,aAAa;AACf,EAAE;AAEF,OAAO,MAAMC,mBAA2D;IACtEC,MAAM;QACJC,OAAO;QACPL,OAAO;IACT;IACAM,SAAS;QACPD,OAAO;QACPL,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASO,WAAWH,IAAY,EAAE,EAAEI,OAAO,MAAM,EAAEN,WAAW,EAAED,aAAa,EAAqB;IACvG,MAAMQ,YAAYD,SAAS;IAC3B,MAAME,YAAYD,YAAY,OAAO;IAErC,mEAAmE;IACnE,IAAI,CAACZ,oBAAoBK,gBAAgBS,KAAKC,GAAG,CAACR,QAAQM,WAAW;QACnE,MAAMG,mBAA6C;YACjDC,OAAO;YACPC,aAAa;QACf;QAEA,IAAIpB,iBAAiBM,gBAAgB;YACnCY,iBAAiBG,qBAAqB,GAAGpB,mBAAmBK;YAC5DY,iBAAiBI,qBAAqB,GAAGrB,mBAAmBK;QAC9D,OAAO;YACL,0FAA0F;YAC1F,IAAIJ,oBAAoBK,cAAc;gBACpCW,iBAAiBK,wBAAwB,GAAGxB;YAC9C;QACF;QACA,MAAMyB,YAAYC,KAAKC,YAAY,CAAC,SAASR;QAC7C,OAAOM,UAAUG,MAAM,CAAClB,QAAQ;IAClC;IAEA,qDAAqD;IACrD,+DAA+D;IAC/D,MAAMmB,YAAY9B,OAAOW,MAAMkB,MAAM,CAAC;QACpCE,QAAQ;QACRC,MAAMhB,YAAY,YAAY;QAC9BiB,gBAAgB;QAChBC,UAAUhC,iBAAiBM,iBAAiBA,gBAAgBH;QAC5D,iCAAiC;QACjC8B,cAAc,CAACjC,iBAAiBM;QAChC,wEAAwE;QACxE4B,kBAAkB,CAAClC,iBAAiBM;IACtC;IAEA,oCAAoC;IACpC,OAAOsB,UACJO,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ;AACrB"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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 support both SI (decimal) and IEC (binary) units for bytes:\n *\n * SI/decimal (unit: 'decbytes'):\n * 1 KB = 1000 bytes (1000^1 bytes)\n * 1 MB = 1,000,000 bytes (1000^2 bytes)\n * etc.\n *\n * IEC/binary (unit: 'bytes'):\n * 1 KiB = 1024 bytes (1024^1 bytes)\n * 1 MiB = 1,048,576 bytes (1024^2 bytes)\n * etc.\n */\n\nconst DEFAULT_NUMBRO_MANTISSA = 2;\n\ntype BytesUnit = 'bytes' | 'decbytes';\n\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 (IEC)',\n },\n decbytes: {\n group: 'Bytes',\n label: 'Bytes (SI)',\n },\n};\n\nexport function formatBytes(bytes: number, { unit = 'bytes', shortValues, decimalPlaces }: BytesFormatOptions): string {\n const isDecimal = unit === 'decbytes';\n const threshold = isDecimal ? 1000 : 1024;\n\n // If we're showing the entire value, we can use Intl.NumberFormat.\n if (!shouldShortenValues(shortValues) || Math.abs(bytes) < threshold) {\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 -threshold and threshold (1000 for SI, 1024 for IEC)\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: isDecimal ? 'decimal' : 'binary',\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","decbytes","formatBytes","unit","isDecimal","threshold","Math","abs","formatterOptions","style","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;;;;;;;;;;;;CAYC,GAED,MAAMC,0BAA0B;AAShC,OAAO,MAAMC,qBAAsC;IACjDC,OAAO;IACPC,eAAe;IACfC,aAAa;AACf,EAAE;AACF,OAAO,MAAMC,oBAA6D;IACxEC,OAAO;QACLC,OAAO;QACPL,OAAO;IACT;IACAM,UAAU;QACRD,OAAO;QACPL,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASO,YAAYH,KAAa,EAAE,EAAEI,OAAO,OAAO,EAAEN,WAAW,EAAED,aAAa,EAAsB;IAC3G,MAAMQ,YAAYD,SAAS;IAC3B,MAAME,YAAYD,YAAY,OAAO;IAErC,mEAAmE;IACnE,IAAI,CAACZ,oBAAoBK,gBAAgBS,KAAKC,GAAG,CAACR,SAASM,WAAW;QACpE,MAAMG,mBAA6C;YACjDC,OAAO;YACPN,MAAM;YACNO,aAAa;YACbC,aAAa;QACf;QAEA,IAAIrB,iBAAiBM,gBAAgB;YACnCY,iBAAiBI,qBAAqB,GAAGrB,mBAAmBK;YAC5DY,iBAAiBK,qBAAqB,GAAGtB,mBAAmBK;QAC9D,OAAO;YACL,2FAA2F;YAC3F,IAAIJ,oBAAoBK,cAAc;gBACpCW,iBAAiBM,wBAAwB,GAAGzB;YAC9C;QACF;QACA,MAAM0B,YAAYC,KAAKC,YAAY,CAAC,SAAST;QAC7C,OAAOO,UAAUG,MAAM,CAACnB;IAC1B;IAEA,qDAAqD;IACrD,+DAA+D;IAC/D,OAAOX,OAAOW,OAAOmB,MAAM,CAAC;QAC1BC,QAAQ;QACRC,MAAMhB,YAAY,YAAY;QAC9BiB,gBAAgB;QAChBC,UAAUhC,iBAAiBM,iBAAiBA,gBAAgBH;QAC5D,iCAAiC;QACjC8B,cAAc,CAACjC,iBAAiBM;QAChC,wEAAwE;QACxE4B,kBAAkB,CAAClC,iBAAiBM;IACtC;AACF"}
1
+ {"version":3,"sources":["../../../src/model/units/bytes.ts"],"sourcesContent":["// Copyright 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 support both SI (decimal) and IEC (binary) units for bytes:\n *\n * SI/decimal (unit: 'decbytes'):\n * 1 KB = 1000 bytes (1000^1 bytes)\n * 1 MB = 1,000,000 bytes (1000^2 bytes)\n * etc.\n *\n * IEC/binary (unit: 'bytes'):\n * 1 KiB = 1024 bytes (1024^1 bytes)\n * 1 MiB = 1,048,576 bytes (1024^2 bytes)\n * etc.\n */\n\nconst DEFAULT_NUMBRO_MANTISSA = 2;\n\ntype BytesUnit = 'bytes' | 'decbytes';\n\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 (IEC)',\n },\n decbytes: {\n group: 'Bytes',\n label: 'Bytes (SI)',\n },\n};\n\nexport function formatBytes(bytes: number, { unit = 'bytes', shortValues, decimalPlaces }: BytesFormatOptions): string {\n const isDecimal = unit === 'decbytes';\n const threshold = isDecimal ? 1000 : 1024;\n\n // If we're showing the entire value, we can use Intl.NumberFormat.\n if (!shouldShortenValues(shortValues) || Math.abs(bytes) < threshold) {\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 -threshold and threshold (1000 for SI, 1024 for IEC)\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: isDecimal ? 'decimal' : 'binary',\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","decbytes","formatBytes","unit","isDecimal","threshold","Math","abs","formatterOptions","style","unitDisplay","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format","output","base","spaceSeparated","mantissa","trimMantissa","optionalMantissa"],"mappings":"AAAA,+BAA+B;AAC/B,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;;;;;;;;;;;;CAYC,GAED,MAAMC,0BAA0B;AAShC,OAAO,MAAMC,qBAAsC;IACjDC,OAAO;IACPC,eAAe;IACfC,aAAa;AACf,EAAE;AACF,OAAO,MAAMC,oBAA6D;IACxEC,OAAO;QACLC,OAAO;QACPL,OAAO;IACT;IACAM,UAAU;QACRD,OAAO;QACPL,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASO,YAAYH,KAAa,EAAE,EAAEI,OAAO,OAAO,EAAEN,WAAW,EAAED,aAAa,EAAsB;IAC3G,MAAMQ,YAAYD,SAAS;IAC3B,MAAME,YAAYD,YAAY,OAAO;IAErC,mEAAmE;IACnE,IAAI,CAACZ,oBAAoBK,gBAAgBS,KAAKC,GAAG,CAACR,SAASM,WAAW;QACpE,MAAMG,mBAA6C;YACjDC,OAAO;YACPN,MAAM;YACNO,aAAa;YACbC,aAAa;QACf;QAEA,IAAIrB,iBAAiBM,gBAAgB;YACnCY,iBAAiBI,qBAAqB,GAAGrB,mBAAmBK;YAC5DY,iBAAiBK,qBAAqB,GAAGtB,mBAAmBK;QAC9D,OAAO;YACL,2FAA2F;YAC3F,IAAIJ,oBAAoBK,cAAc;gBACpCW,iBAAiBM,wBAAwB,GAAGzB;YAC9C;QACF;QACA,MAAM0B,YAAYC,KAAKC,YAAY,CAAC,SAAST;QAC7C,OAAOO,UAAUG,MAAM,CAACnB;IAC1B;IAEA,qDAAqD;IACrD,+DAA+D;IAC/D,OAAOX,OAAOW,OAAOmB,MAAM,CAAC;QAC1BC,QAAQ;QACRC,MAAMhB,YAAY,YAAY;QAC9BiB,gBAAgB;QAChBC,UAAUhC,iBAAiBM,iBAAiBA,gBAAgBH;QAC5D,iCAAiC;QACjC8B,cAAc,CAACjC,iBAAiBM;QAChC,wEAAwE;QACxE4B,kBAAkB,CAAClC,iBAAiBM;IACtC;AACF"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +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"}
1
+ {"version":3,"sources":["../../../src/model/units/constants.ts"],"sourcesContent":["// Copyright 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,+BAA+B;AAC/B,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"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at