@perses-dev/core 0.53.0-beta.0 → 0.53.0-beta.1

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 (43) hide show
  1. package/dist/cjs/model/datasource-api.js +16 -0
  2. package/dist/cjs/model/external-variable.js +16 -0
  3. package/dist/cjs/model/index.js +4 -1
  4. package/dist/cjs/{utils/event.js → model/panel-group.js} +5 -10
  5. package/dist/cjs/utils/index.js +0 -2
  6. package/dist/cjs/utils/transform-data.js +0 -10
  7. package/dist/model/datasource-api.d.ts +41 -0
  8. package/dist/model/datasource-api.d.ts.map +1 -0
  9. package/dist/model/datasource-api.js +19 -0
  10. package/dist/model/datasource-api.js.map +1 -0
  11. package/dist/model/external-variable.d.ts +29 -0
  12. package/dist/model/external-variable.d.ts.map +1 -0
  13. package/dist/model/external-variable.js +20 -0
  14. package/dist/model/external-variable.js.map +1 -0
  15. package/dist/model/index.d.ts +3 -0
  16. package/dist/model/index.d.ts.map +1 -1
  17. package/dist/model/index.js +4 -1
  18. package/dist/model/index.js.map +1 -1
  19. package/dist/model/otlp/common/v1/common.d.ts +3 -1
  20. package/dist/model/otlp/common/v1/common.d.ts.map +1 -1
  21. package/dist/model/otlp/common/v1/common.js.map +1 -1
  22. package/dist/model/panel-group.d.ts +63 -0
  23. package/dist/model/panel-group.d.ts.map +1 -0
  24. package/dist/model/panel-group.js +19 -0
  25. package/dist/model/panel-group.js.map +1 -0
  26. package/dist/utils/index.d.ts +0 -2
  27. package/dist/utils/index.d.ts.map +1 -1
  28. package/dist/utils/index.js +0 -2
  29. package/dist/utils/index.js.map +1 -1
  30. package/dist/utils/transform-data.d.ts +0 -1
  31. package/dist/utils/transform-data.d.ts.map +1 -1
  32. package/dist/utils/transform-data.js +0 -7
  33. package/dist/utils/transform-data.js.map +1 -1
  34. package/package.json +1 -5
  35. package/dist/cjs/utils/memo.js +0 -64
  36. package/dist/utils/event.d.ts +0 -8
  37. package/dist/utils/event.d.ts.map +0 -1
  38. package/dist/utils/event.js +0 -27
  39. package/dist/utils/event.js.map +0 -1
  40. package/dist/utils/memo.d.ts +0 -13
  41. package/dist/utils/memo.d.ts.map +0 -1
  42. package/dist/utils/memo.js +0 -50
  43. package/dist/utils/memo.js.map +0 -1
@@ -0,0 +1,16 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
@@ -0,0 +1,16 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 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
@@ -17,9 +17,11 @@ Object.defineProperty(exports, "__esModule", {
17
17
  _export_star(require("./calculations"), exports);
18
18
  _export_star(require("./dashboard"), exports);
19
19
  _export_star(require("./datasource"), exports);
20
+ _export_star(require("./datasource-api"), exports);
20
21
  _export_star(require("./definitions"), exports);
21
22
  _export_star(require("./display"), exports);
22
23
  _export_star(require("./ephemeraldashboard"), exports);
24
+ _export_star(require("./external-variable"), exports);
23
25
  _export_star(require("./http"), exports);
24
26
  _export_star(require("./http-proxy"), exports);
25
27
  _export_star(require("./kind"), exports);
@@ -27,6 +29,7 @@ _export_star(require("./layout"), exports);
27
29
  _export_star(require("./legend"), exports);
28
30
  _export_star(require("./notice"), exports);
29
31
  _export_star(require("./otlp"), exports);
32
+ _export_star(require("./panel-group"), exports);
30
33
  _export_star(require("./panels"), exports);
31
34
  _export_star(require("./project"), exports);
32
35
  _export_star(require("./query"), exports);
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 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
@@ -14,17 +14,12 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "useEvent", {
17
+ Object.defineProperty(exports, "isPanelGroupItemIdEqual", {
18
18
  enumerable: true,
19
19
  get: function() {
20
- return useEvent;
20
+ return isPanelGroupItemIdEqual;
21
21
  }
22
22
  });
23
- const _react = require("react");
24
- function useEvent(handler) {
25
- const handlerRef = (0, _react.useRef)(handler);
26
- (0, _react.useLayoutEffect)(()=>{
27
- handlerRef.current = handler;
28
- });
29
- return (0, _react.useCallback)((...args)=>handlerRef.current(...args), []);
23
+ function isPanelGroupItemIdEqual(a, b) {
24
+ return a?.panelGroupId === b?.panelGroupId && a?.panelGroupItemLayoutId === b?.panelGroupItemLayoutId;
30
25
  }
@@ -14,10 +14,8 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _export_star(require("./event"), exports);
18
17
  _export_star(require("./fetch"), exports);
19
18
  _export_star(require("./is-empty-object"), exports);
20
- _export_star(require("./memo"), exports);
21
19
  _export_star(require("./panel-refs"), exports);
22
20
  _export_star(require("./text"), exports);
23
21
  _export_star(require("./time-series-data"), exports);
@@ -35,12 +35,8 @@ _export(exports, {
35
35
  },
36
36
  transformData: function() {
37
37
  return transformData;
38
- },
39
- useTransformData: function() {
40
- return useTransformData;
41
38
  }
42
39
  });
43
- const _react = require("react");
44
40
  function applyJoinTransform(data, columns) {
45
41
  // If column is undefined or empty, return data as is
46
42
  if (columns.length === 0) {
@@ -159,9 +155,3 @@ function transformData(data, transforms) {
159
155
  });
160
156
  return result;
161
157
  }
162
- function useTransformData(data, transforms) {
163
- return (0, _react.useMemo)(()=>transformData(data, transforms), [
164
- data,
165
- transforms
166
- ]);
167
- }
@@ -0,0 +1,41 @@
1
+ import { DatasourceResource, DatasourceSelector, GlobalDatasourceResource } from './datasource';
2
+ /**
3
+ * Parameters for building a datasource proxy URL
4
+ */
5
+ export interface BuildDatasourceProxyUrlParams {
6
+ project?: string;
7
+ dashboard?: string;
8
+ name: string;
9
+ }
10
+ /**
11
+ * Function type for building datasource proxy URLs
12
+ */
13
+ export type BuildDatasourceProxyUrlFunc = (params: BuildDatasourceProxyUrlParams) => string;
14
+ /**
15
+ * The external API contract for fetching datasource resources.
16
+ * This defines the interface that must be implemented to provide
17
+ * datasource functionality to the dashboard.
18
+ */
19
+ export interface DatasourceApi {
20
+ /**
21
+ * Optional function to build proxy URLs for datasources
22
+ */
23
+ buildProxyUrl?: BuildDatasourceProxyUrlFunc;
24
+ /**
25
+ * Get a datasource resource for a specific project
26
+ */
27
+ getDatasource: (project: string, selector: DatasourceSelector) => Promise<DatasourceResource | undefined>;
28
+ /**
29
+ * Get a global datasource resource
30
+ */
31
+ getGlobalDatasource: (selector: DatasourceSelector) => Promise<GlobalDatasourceResource | undefined>;
32
+ /**
33
+ * List all datasources for a project, optionally filtered by plugin kind
34
+ */
35
+ listDatasources: (project: string, pluginKind?: string) => Promise<DatasourceResource[]>;
36
+ /**
37
+ * List all global datasources, optionally filtered by plugin kind
38
+ */
39
+ listGlobalDatasources: (pluginKind?: string) => Promise<GlobalDatasourceResource[]>;
40
+ }
41
+ //# sourceMappingURL=datasource-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datasource-api.d.ts","sourceRoot":"","sources":["../../src/model/datasource-api.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAEhG;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,MAAM,EAAE,6BAA6B,KAAK,MAAM,CAAC;AAE5F;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,aAAa,CAAC,EAAE,2BAA2B,CAAC;IAC5C;;OAEG;IACH,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAAC;IAC1G;;OAEG;IACH,mBAAmB,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC,CAAC;IACrG;;OAEG;IACH,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACzF;;OAEG;IACH,qBAAqB,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;CACrF"}
@@ -0,0 +1,19 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /**
14
+ * The external API contract for fetching datasource resources.
15
+ * This defines the interface that must be implemented to provide
16
+ * datasource functionality to the dashboard.
17
+ */ export { };
18
+
19
+ //# sourceMappingURL=datasource-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/datasource-api.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 { DatasourceResource, DatasourceSelector, GlobalDatasourceResource } from './datasource';\n\n/**\n * Parameters for building a datasource proxy URL\n */\nexport interface BuildDatasourceProxyUrlParams {\n project?: string;\n dashboard?: string;\n name: string;\n}\n\n/**\n * Function type for building datasource proxy URLs\n */\nexport type BuildDatasourceProxyUrlFunc = (params: BuildDatasourceProxyUrlParams) => string;\n\n/**\n * The external API contract for fetching datasource resources.\n * This defines the interface that must be implemented to provide\n * datasource functionality to the dashboard.\n */\nexport interface DatasourceApi {\n /**\n * Optional function to build proxy URLs for datasources\n */\n buildProxyUrl?: BuildDatasourceProxyUrlFunc;\n /**\n * Get a datasource resource for a specific project\n */\n getDatasource: (project: string, selector: DatasourceSelector) => Promise<DatasourceResource | undefined>;\n /**\n * Get a global datasource resource\n */\n getGlobalDatasource: (selector: DatasourceSelector) => Promise<GlobalDatasourceResource | undefined>;\n /**\n * List all datasources for a project, optionally filtered by plugin kind\n */\n listDatasources: (project: string, pluginKind?: string) => Promise<DatasourceResource[]>;\n /**\n * List all global datasources, optionally filtered by plugin kind\n */\n listGlobalDatasources: (pluginKind?: string) => Promise<GlobalDatasourceResource[]>;\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;AAkBjC;;;;CAIC,GACD,WAqBC"}
@@ -0,0 +1,29 @@
1
+ import { VariableDefinition } from './variables';
2
+ /**
3
+ * External variable definition that can be provided from an external source.
4
+ * Multiple external variable definitions can be provided to a dashboard, and
5
+ * the order of the sources is important as first one will take precedence on
6
+ * the following ones, in case they have same names.
7
+ */
8
+ export interface ExternalVariableDefinition {
9
+ /**
10
+ * Source identifier for this set of external variables
11
+ */
12
+ source: string;
13
+ /**
14
+ * Optional tooltip information for the external variables
15
+ */
16
+ tooltip?: {
17
+ title?: string;
18
+ description?: string;
19
+ };
20
+ /**
21
+ * Optional link to edit these external variables
22
+ */
23
+ editLink?: string;
24
+ /**
25
+ * The variable definitions from this external source
26
+ */
27
+ definitions: VariableDefinition[];
28
+ }
29
+ //# sourceMappingURL=external-variable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-variable.d.ts","sourceRoot":"","sources":["../../src/model/external-variable.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC"}
@@ -0,0 +1,20 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /**
14
+ * External variable definition that can be provided from an external source.
15
+ * Multiple external variable definitions can be provided to a dashboard, and
16
+ * the order of the sources is important as first one will take precedence on
17
+ * the following ones, in case they have same names.
18
+ */ export { };
19
+
20
+ //# sourceMappingURL=external-variable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/external-variable.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 { VariableDefinition } from './variables';\n\n/**\n * External variable definition that can be provided from an external source.\n * Multiple external variable definitions can be provided to a dashboard, and\n * the order of the sources is important as first one will take precedence on\n * the following ones, in case they have same names.\n */\nexport interface ExternalVariableDefinition {\n /**\n * Source identifier for this set of external variables\n */\n source: string;\n /**\n * Optional tooltip information for the external variables\n */\n tooltip?: {\n title?: string;\n description?: string;\n };\n /**\n * Optional link to edit these external variables\n */\n editLink?: string;\n /**\n * The variable definitions from this external source\n */\n definitions: VariableDefinition[];\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC;;;;;CAKC,GACD,WAoBC"}
@@ -1,9 +1,11 @@
1
1
  export * from './calculations';
2
2
  export * from './dashboard';
3
3
  export * from './datasource';
4
+ export * from './datasource-api';
4
5
  export * from './definitions';
5
6
  export * from './display';
6
7
  export * from './ephemeraldashboard';
8
+ export * from './external-variable';
7
9
  export * from './http';
8
10
  export * from './http-proxy';
9
11
  export * from './kind';
@@ -11,6 +13,7 @@ export * from './layout';
11
13
  export * from './legend';
12
14
  export * from './notice';
13
15
  export * from './otlp';
16
+ export * from './panel-group';
14
17
  export * from './panels';
15
18
  export * from './project';
16
19
  export * from './query';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAA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 2025 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
@@ -13,9 +13,11 @@
13
13
  export * from './calculations';
14
14
  export * from './dashboard';
15
15
  export * from './datasource';
16
+ export * from './datasource-api';
16
17
  export * from './definitions';
17
18
  export * from './display';
18
19
  export * from './ephemeraldashboard';
20
+ export * from './external-variable';
19
21
  export * from './http';
20
22
  export * from './http-proxy';
21
23
  export * from './kind';
@@ -23,6 +25,7 @@ export * from './layout';
23
25
  export * from './legend';
24
26
  export * from './notice';
25
27
  export * from './otlp';
28
+ export * from './panel-group';
26
29
  export * from './panels';
27
30
  export * from './project';
28
31
  export * from './query';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './calculations';\nexport * from './dashboard';\nexport * from './datasource';\nexport * from './definitions';\nexport * from './display';\nexport * from './ephemeraldashboard';\nexport * from './http';\nexport * from './http-proxy';\nexport * from './kind';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\nexport * from './otlp';\nexport * from './panels';\nexport * from './project';\nexport * from './query';\nexport * from './resource';\nexport * from './roles';\nexport * from './rolebindings';\nexport * from './secrets';\nexport * from './thresholds';\nexport * from './time';\nexport * from './time-series-data';\nexport * from './time-series-queries';\nexport * from './trace-data';\nexport * from './profile-data';\nexport * from './log-data';\nexport * from './transforms';\nexport * from './units';\nexport * from './user';\nexport * from './variables';\nexport * from './value-mapping';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,iBAAiB;AAC/B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,kBAAkB"}
1
+ {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './calculations';\nexport * from './dashboard';\nexport * from './datasource';\nexport * from './datasource-api';\nexport * from './definitions';\nexport * from './display';\nexport * from './ephemeraldashboard';\nexport * from './external-variable';\nexport * from './http';\nexport * from './http-proxy';\nexport * from './kind';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\nexport * from './otlp';\nexport * from './panel-group';\nexport * from './panels';\nexport * from './project';\nexport * from './query';\nexport * from './resource';\nexport * from './roles';\nexport * from './rolebindings';\nexport * from './secrets';\nexport * from './thresholds';\nexport * from './time';\nexport * from './time-series-data';\nexport * from './time-series-queries';\nexport * from './trace-data';\nexport * from './profile-data';\nexport * from './log-data';\nexport * from './transforms';\nexport * from './units';\nexport * from './user';\nexport * from './variables';\nexport * from './value-mapping';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,iBAAiB;AAC/B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,mBAAmB;AACjC,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,gBAAgB;AAC9B,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,kBAAkB"}
@@ -6,11 +6,13 @@ export type AnyValue = {
6
6
  stringValue: string;
7
7
  } | {
8
8
  intValue: string;
9
+ } | {
10
+ doubleValue: number;
9
11
  } | {
10
12
  boolValue: boolean;
11
13
  } | {
12
14
  arrayValue: {
13
- values: AnyValue[];
15
+ values?: AnyValue[];
14
16
  };
15
17
  };
16
18
  export interface InstrumentationScope {
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/model/otlp/common/v1/common.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,MAAM,MAAM,QAAQ,GAChB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GACvB;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GACpB;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,GACtB;IAAE,UAAU,EAAE;QAAE,MAAM,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAA;CAAE,CAAC;AAE3C,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/model/otlp/common/v1/common.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,MAAM,MAAM,QAAQ,GAChB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GACvB;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,GACpB;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GACvB;IAAE,SAAS,EAAE,OAAO,CAAA;CAAE,GACtB;IAAE,UAAU,EAAE;QAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAA;CAAE,CAAC;AAE5C,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/model/otlp/common/v1/common.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/opentelemetry/proto/common/v1/common.proto\n\nexport interface KeyValue {\n key: string;\n value: AnyValue;\n}\n\nexport type AnyValue =\n | { stringValue: string }\n | { intValue: string }\n | { boolValue: boolean }\n | { arrayValue: { values: AnyValue[] } };\n\nexport interface InstrumentationScope {\n name?: string;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,+GAA+G;AAa/G,WAEC"}
1
+ {"version":3,"sources":["../../../../../src/model/otlp/common/v1/common.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/opentelemetry/proto/common/v1/common.proto\n\nexport interface KeyValue {\n key: string;\n value: AnyValue;\n}\n\nexport type AnyValue =\n | { stringValue: string }\n | { intValue: string }\n | { doubleValue: number }\n | { boolValue: boolean }\n | { arrayValue: { values?: AnyValue[] } };\n\nexport interface InstrumentationScope {\n name?: string;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,+GAA+G;AAc/G,WAEC"}
@@ -0,0 +1,63 @@
1
+ import { PanelGroupId } from './panels';
2
+ /**
3
+ * Panel Group Item Layout ID type. String identifier for items within a panel group.
4
+ */
5
+ export type PanelGroupItemLayoutId = string;
6
+ /**
7
+ * Base layout properties for positioning and sizing items in a grid.
8
+ * This is a framework-agnostic representation that can be used with various grid systems.
9
+ */
10
+ export interface BaseLayout {
11
+ /**
12
+ * Item identifier
13
+ */
14
+ i: string;
15
+ /**
16
+ * X position in grid units
17
+ */
18
+ x: number;
19
+ /**
20
+ * Y position in grid units
21
+ */
22
+ y: number;
23
+ /**
24
+ * Width in grid units
25
+ */
26
+ w: number;
27
+ /**
28
+ * Height in grid units
29
+ */
30
+ h: number;
31
+ }
32
+ /**
33
+ * Layout information for an item within a panel group.
34
+ * Extends BaseLayout with a typed identifier.
35
+ */
36
+ export interface PanelGroupItemLayout extends BaseLayout {
37
+ i: PanelGroupItemLayoutId;
38
+ }
39
+ /**
40
+ * Uniquely identifies an item in a PanelGroup.
41
+ */
42
+ export interface PanelGroupItemId {
43
+ panelGroupId: PanelGroupId;
44
+ panelGroupItemLayoutId: PanelGroupItemLayoutId;
45
+ repeatVariable?: [string, string];
46
+ }
47
+ /**
48
+ * Definition of a panel group, containing layout and panel information.
49
+ */
50
+ export interface PanelGroupDefinition {
51
+ id: PanelGroupId;
52
+ isCollapsed: boolean;
53
+ title?: string;
54
+ repeatedOriginId?: PanelGroupId;
55
+ repeatVariable?: string;
56
+ itemLayouts: PanelGroupItemLayout[];
57
+ itemPanelKeys: Record<PanelGroupItemLayoutId, string>;
58
+ }
59
+ /**
60
+ * Check if two PanelGroupItemId are equal
61
+ */
62
+ export declare function isPanelGroupItemIdEqual(a?: PanelGroupItemId, b?: PanelGroupItemId): boolean;
63
+ //# sourceMappingURL=panel-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-group.d.ts","sourceRoot":"","sources":["../../src/model/panel-group.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;IACV;;OAEG;IACH,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD,CAAC,EAAE,sBAAsB,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,YAAY,CAAC;IAC3B,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,YAAY,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,YAAY,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;CACvD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAE3F"}
@@ -0,0 +1,19 @@
1
+ // Copyright 2025 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /**
14
+ * Check if two PanelGroupItemId are equal
15
+ */ export function isPanelGroupItemIdEqual(a, b) {
16
+ return a?.panelGroupId === b?.panelGroupId && a?.panelGroupItemLayoutId === b?.panelGroupItemLayoutId;
17
+ }
18
+
19
+ //# sourceMappingURL=panel-group.js.map
@@ -0,0 +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,7 +1,5 @@
1
- export * from './event';
2
1
  export * from './fetch';
3
2
  export * from './is-empty-object';
4
- export * from './memo';
5
3
  export * from './panel-refs';
6
4
  export * from './text';
7
5
  export * from './time-series-data';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
@@ -10,10 +10,8 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- export * from './event';
14
13
  export * from './fetch';
15
14
  export * from './is-empty-object';
16
- export * from './memo';
17
15
  export * from './panel-refs';
18
16
  export * from './text';
19
17
  export * from './time-series-data';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './event';\nexport * from './fetch';\nexport * from './is-empty-object';\nexport * from './memo';\nexport * from './panel-refs';\nexport * from './text';\nexport * from './time-series-data';\nexport * from './transform-data';\nexport * from './value-mapping';\nexport * from './types';\nexport * from './regexp';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,qBAAqB;AACnC,cAAc,mBAAmB;AACjC,cAAc,kBAAkB;AAChC,cAAc,UAAU;AACxB,cAAc,WAAW"}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './fetch';\nexport * from './is-empty-object';\nexport * from './panel-refs';\nexport * from './text';\nexport * from './time-series-data';\nexport * from './transform-data';\nexport * from './value-mapping';\nexport * from './types';\nexport * from './regexp';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,qBAAqB;AACnC,cAAc,mBAAmB;AACjC,cAAc,kBAAkB;AAChC,cAAc,UAAU;AACxB,cAAc,WAAW"}
@@ -4,5 +4,4 @@ export declare function applyMergeColumnsTransform(data: Array<Record<string, un
4
4
  export declare function applyMergeIndexedColumnsTransform(data: Array<Record<string, unknown>>, column: string): Array<Record<string, unknown>>;
5
5
  export declare function applyMergeSeriesTransform(data: Array<Record<string, unknown>>): Array<Record<string, unknown>>;
6
6
  export declare function transformData(data: Array<Record<string, unknown>>, transforms: Transform[]): Array<Record<string, unknown>>;
7
- export declare function useTransformData(data: Array<Record<string, unknown>>, transforms: Transform[]): Array<Record<string, unknown>>;
8
7
  //# sourceMappingURL=transform-data.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform-data.d.ts","sourceRoot":"","sources":["../../src/utils/transform-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAsB7C,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACpC,OAAO,EAAE,MAAM,EAAE,GAChB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAsBhC;AA0BD,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACpC,eAAe,EAAE,MAAM,EAAE,EACzB,UAAU,EAAE,MAAM,GACjB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAuBhC;AA0BD,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACpC,MAAM,EAAE,MAAM,GACb,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAwBhC;AAmBD,wBAA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,MAAM,EAAE,OAAO,CAAC,CAAC,CAwBhC;AAmBD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAmB9G;AAKD,wBAAgB,aAAa,CAC3B,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACpC,UAAU,EAAE,SAAS,EAAE,GACtB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2ChC"}
@@ -10,7 +10,6 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { useMemo } from 'react';
14
13
  /*
15
14
  * Join: Regroup rows with equal cell value in a column.
16
15
  * If there are multiple line with same value, next row values override the current one
@@ -211,11 +210,5 @@ import { useMemo } from 'react';
211
210
  });
212
211
  return result;
213
212
  }
214
- export function useTransformData(data, transforms) {
215
- return useMemo(()=>transformData(data, transforms), [
216
- data,
217
- transforms
218
- ]);
219
- }
220
213
 
221
214
  //# sourceMappingURL=transform-data.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/transform-data.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 { Transform } from '@perses-dev/core';\nimport { useMemo } from 'react';\n\n/*\n * Join: Regroup rows with equal cell value in a column.\n * If there are multiple line with same value, next row values override the current one\n *\n * Example: Join on 'mount' column\n * INPUT:\n * | timestamp | value #1 | value #3 | mount |\n * |------------|----------|----------|-----------|\n * | 1630000000 | 1 | | / |\n * | 1630000000 | 2 | | /boot/efi |\n * | 1630000000 | | 3 | / |\n * | 1630000000 | | 4 | /boot/efi |\n *\n * OUTPUT:\n * | timestamp | value #1 | value #3 | mount |\n * |------------|----------|----------|-----------|\n * | 1630000000 | 1 | 3 | / |\n * | 1630000000 | 2 | 4 | /boot/efi |\n */\nexport function applyJoinTransform(\n data: Array<Record<string, unknown>>,\n columns: string[]\n): Array<Record<string, unknown>> {\n // If column is undefined or empty, return data as is\n if (columns.length === 0) {\n return data;\n }\n\n const rowHashed: { [key: string]: Record<string, unknown> } = {};\n\n for (const row of data) {\n const rowHash = Object.keys(row)\n .filter((k) => columns.includes(k))\n .map((k) => row[k])\n .join('|');\n\n const rowHashedValue = rowHashed[rowHash];\n if (rowHashedValue) {\n rowHashed[rowHash] = { ...rowHashedValue, ...row };\n } else {\n rowHashed[rowHash] = { ...row };\n }\n }\n return Object.values(rowHashed);\n}\n\n/*\n * Merges selected columns into a single column.\n *\n * Example: Merge columns 'value #1' and 'value #2' into a single column 'MERGED'\n * INPUT:\n * +------------+----------+----------+-----------+-----------+\n * | timestamp | value #1 | value #2 | mount #1 | mount #2 |\n * +------------+----------+----------+-----------+-----------+\n * | 1630000000 | 1 | | / | |\n * | 1630000000 | 2 | | /boot/efi | |\n * | 1630000000 | | 3 | | / |\n * | 1630000000 | | 4 | | /boot/efi |\n * +------------+----------+----------+-----------+-----------+\n *\n * OUTPUT:\n * +------------+--------+-----------+-----------+\n * | timestamp | MERGED | mount #1 | mount #2 |\n * +------------+--------+-----------+-----------+\n * | 1630000000 | 1 | / | |\n * | 1630000000 | 2 | /boot/efi | |\n * | 1630000000 | 2 | | / |\n * | 1630000000 | 3 | | /boot/efi |\n * +------------+--------+-----------+-----------+\n */\nexport function applyMergeColumnsTransform(\n data: Array<Record<string, unknown>>,\n selectedColumns: string[],\n outputName: string\n): Array<Record<string, unknown>> {\n const result: Array<Record<string, unknown>> = [];\n\n for (const row of data) {\n const columns = Object.keys(row).filter((k) => selectedColumns.includes(k));\n\n const selectedColumnValues: Record<string, unknown> = {};\n\n for (const column of columns) {\n selectedColumnValues[column] = row[column];\n delete row[column];\n }\n\n for (const column of columns) {\n result.push({ ...row, [outputName]: selectedColumnValues[column] });\n }\n\n if (columns.length === 0) {\n result.push(row);\n }\n }\n\n return result;\n}\n\n/*\n * Merge Indexed Columns: All indexed columns are merged to one column\n *\n * Example: Join on 'value' column\n * INPUT:\n * | timestamp #1 | timestamp #2 | value #1 | value #2 | instance #1 | instance #2 |\n * |--------------|--------------|----------|----------|-------------|-------------|\n * | 1630000000 | | 55 | | toto | |\n * | 1630000000 | | 33 | | toto | |\n * | 1630000000 | | 45 | | toto | |\n * | | 1630000000 | | 112 | | titi |\n * | | 1630000000 | | 20 | | titi |\n * | | 1630000000 | | 10 | | titi |\n *\n * OUTPUT:\n * | timestamp #1 | timestamp #2 | value | instance #1 | instance #2 |\n * |--------------|--------------|-------|-------------|-------------|\n * | 1630000000 | | 55 | toto | |\n * | 1630000000 | | 33 | toto | |\n * | 1630000000 | | 45 | toto | |\n * | | 1630000000 | 112 | | titi |\n * | | 1630000000 | 20 | | titi |\n * | | 1630000000 | 10 | | titi |\n */\nexport function applyMergeIndexedColumnsTransform(\n data: Array<Record<string, unknown>>,\n column: string\n): Array<Record<string, unknown>> {\n const result: Array<Record<string, unknown>> = [];\n\n for (const entry of data) {\n const indexedColumns = Object.keys(entry).filter((k) =>\n new RegExp('^((' + column + ' #\\\\d+)|(' + column + '))$').test(k)\n );\n const indexedColumnValues: Record<string, unknown> = {};\n\n for (const indexedColumn of indexedColumns) {\n indexedColumnValues[indexedColumn] = entry[indexedColumn];\n delete entry[indexedColumn];\n }\n\n for (const indexedColumn of indexedColumns) {\n result.push({ ...entry, [column]: indexedColumnValues[indexedColumn] });\n }\n\n if (indexedColumns.length === 0) {\n result.push(entry);\n }\n }\n\n return result;\n}\n\n/*\n * Merge Indexed Columns: All indexed columns are merged to one column\n *\n * INPUT:\n * | timestamp | value #1 | value #2 | mount #1 | mount #2 | instance #1 | instance #2 | env #1 | env #2 |\n * |------------|----------|----------|-----------|-----------|-------------|-------------|--------|--------|\n * | 1630000000 | 1 | | / | | test:44 | | prd | |\n * | 1630000000 | 2 | | /boot/efi | | test:44 | | prd | |\n * | 1630000000 | | 5 | | / | | test:44 | | prd |\n * | 1630000000 | | 6 | | /boot/efi | | test:44 | | prd |\n *\n * OUTPUT:\n * | timestamp | value #1 | value #2 | mount | instance | env |\n * |------------|----------|----------|-----------|----------|-----|\n * | 1630000000 | 1 | 5 | / | test:44 | prd |\n * | 1630000000 | 2 | 6 | /boot/efi | test:44 | prd |\n */\nexport function applyMergeSeriesTransform(data: Array<Record<string, unknown>>): Array<Record<string, unknown>> {\n let result: Array<Record<string, unknown>> = [...data];\n\n const labelColumns = Array.from(\n new Set(\n data\n .flatMap(Object.keys)\n .map((label) => label.replace(/ #\\d+/, ''))\n .filter((label) => label !== 'value')\n )\n );\n\n for (const label of labelColumns) {\n result = applyMergeIndexedColumnsTransform(result, label);\n }\n\n result = applyJoinTransform(result, labelColumns);\n\n return result;\n}\n\n/*\n * Transforms query data with the given transforms\n */\nexport function transformData(\n data: Array<Record<string, unknown>>,\n transforms: Transform[]\n): Array<Record<string, unknown>> {\n let result: Array<Record<string, unknown>> = data;\n\n // Apply transforms by their orders\n for (const transform of transforms ?? []) {\n if (transform.spec.disabled) continue;\n\n switch (transform.kind) {\n case 'JoinByColumnValue': {\n if (transform.spec.columns && transform.spec.columns.length > 0) {\n result = applyJoinTransform(result, transform.spec.columns);\n }\n break;\n }\n case 'MergeIndexedColumns': {\n if (transform.spec.column) {\n result = applyMergeIndexedColumnsTransform(result, transform.spec.column);\n }\n break;\n }\n case 'MergeColumns': {\n if (transform.spec.columns && transform.spec.columns.length > 0 && transform.spec.name) {\n result = applyMergeColumnsTransform(result, transform.spec.columns, transform.spec.name);\n }\n break;\n }\n case 'MergeSeries': {\n result = applyMergeSeriesTransform(result);\n break;\n }\n }\n }\n\n // Ordering data column alphabetically\n result = result.map((row) => {\n return Object.keys(row)\n .sort()\n .reduce((obj: Record<string, unknown>, key: string) => {\n obj[key] = row[key];\n return obj;\n }, {});\n });\n return result;\n}\n\nexport function useTransformData(\n data: Array<Record<string, unknown>>,\n transforms: Transform[]\n): Array<Record<string, unknown>> {\n return useMemo(() => transformData(data, transforms), [data, transforms]);\n}\n"],"names":["useMemo","applyJoinTransform","data","columns","length","rowHashed","row","rowHash","Object","keys","filter","k","includes","map","join","rowHashedValue","values","applyMergeColumnsTransform","selectedColumns","outputName","result","selectedColumnValues","column","push","applyMergeIndexedColumnsTransform","entry","indexedColumns","RegExp","test","indexedColumnValues","indexedColumn","applyMergeSeriesTransform","labelColumns","Array","from","Set","flatMap","label","replace","transformData","transforms","transform","spec","disabled","kind","name","sort","reduce","obj","key","useTransformData"],"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;AAGjC,SAASA,OAAO,QAAQ,QAAQ;AAEhC;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,mBACdC,IAAoC,EACpCC,OAAiB;IAEjB,qDAAqD;IACrD,IAAIA,QAAQC,MAAM,KAAK,GAAG;QACxB,OAAOF;IACT;IAEA,MAAMG,YAAwD,CAAC;IAE/D,KAAK,MAAMC,OAAOJ,KAAM;QACtB,MAAMK,UAAUC,OAAOC,IAAI,CAACH,KACzBI,MAAM,CAAC,CAACC,IAAMR,QAAQS,QAAQ,CAACD,IAC/BE,GAAG,CAAC,CAACF,IAAML,GAAG,CAACK,EAAE,EACjBG,IAAI,CAAC;QAER,MAAMC,iBAAiBV,SAAS,CAACE,QAAQ;QACzC,IAAI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,EAAE;wBACzBF,SAASI,kCAAkCJ,QAAQqB,UAAUC,IAAI,CAACpB,MAAM;oBAC1E;oBACA;gBACF;YACA,KAAK;gBAAgB;oBACnB,IAAImB,UAAUC,IAAI,CAACvC,OAAO,IAAIsC,UAAUC,IAAI,CAACvC,OAAO,CAACC,MAAM,GAAG,KAAKqC,UAAUC,IAAI,CAACG,IAAI,EAAE;wBACtFzB,SAASH,2BAA2BG,QAAQqB,UAAUC,IAAI,CAACvC,OAAO,EAAEsC,UAAUC,IAAI,CAACG,IAAI;oBACzF;oBACA;gBACF;YACA,KAAK;gBAAe;oBAClBzB,SAASW,0BAA0BX;oBACnC;gBACF;QACF;IACF;IAEA,sCAAsC;IACtCA,SAASA,OAAOP,GAAG,CAAC,CAACP;QACnB,OAAOE,OAAOC,IAAI,CAACH,KAChBwC,IAAI,GACJC,MAAM,CAAC,CAACC,KAA8BC;YACrCD,GAAG,CAACC,IAAI,GAAG3C,GAAG,CAAC2C,IAAI;YACnB,OAAOD;QACT,GAAG,CAAC;IACR;IACA,OAAO5B;AACT;AAEA,OAAO,SAAS8B,iBACdhD,IAAoC,EACpCsC,UAAuB;IAEvB,OAAOxC,QAAQ,IAAMuC,cAAcrC,MAAMsC,aAAa;QAACtC;QAAMsC;KAAW;AAC1E"}
1
+ {"version":3,"sources":["../../src/utils/transform-data.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 { Transform } from '@perses-dev/core';\n\n/*\n * Join: Regroup rows with equal cell value in a column.\n * If there are multiple line with same value, next row values override the current one\n *\n * Example: Join on 'mount' column\n * INPUT:\n * | timestamp | value #1 | value #3 | mount |\n * |------------|----------|----------|-----------|\n * | 1630000000 | 1 | | / |\n * | 1630000000 | 2 | | /boot/efi |\n * | 1630000000 | | 3 | / |\n * | 1630000000 | | 4 | /boot/efi |\n *\n * OUTPUT:\n * | timestamp | value #1 | value #3 | mount |\n * |------------|----------|----------|-----------|\n * | 1630000000 | 1 | 3 | / |\n * | 1630000000 | 2 | 4 | /boot/efi |\n */\nexport function applyJoinTransform(\n data: Array<Record<string, unknown>>,\n columns: string[]\n): Array<Record<string, unknown>> {\n // If column is undefined or empty, return data as is\n if (columns.length === 0) {\n return data;\n }\n\n const rowHashed: { [key: string]: Record<string, unknown> } = {};\n\n for (const row of data) {\n const rowHash = Object.keys(row)\n .filter((k) => columns.includes(k))\n .map((k) => row[k])\n .join('|');\n\n const rowHashedValue = rowHashed[rowHash];\n if (rowHashedValue) {\n rowHashed[rowHash] = { ...rowHashedValue, ...row };\n } else {\n rowHashed[rowHash] = { ...row };\n }\n }\n return Object.values(rowHashed);\n}\n\n/*\n * Merges selected columns into a single column.\n *\n * Example: Merge columns 'value #1' and 'value #2' into a single column 'MERGED'\n * INPUT:\n * +------------+----------+----------+-----------+-----------+\n * | timestamp | value #1 | value #2 | mount #1 | mount #2 |\n * +------------+----------+----------+-----------+-----------+\n * | 1630000000 | 1 | | / | |\n * | 1630000000 | 2 | | /boot/efi | |\n * | 1630000000 | | 3 | | / |\n * | 1630000000 | | 4 | | /boot/efi |\n * +------------+----------+----------+-----------+-----------+\n *\n * OUTPUT:\n * +------------+--------+-----------+-----------+\n * | timestamp | MERGED | mount #1 | mount #2 |\n * +------------+--------+-----------+-----------+\n * | 1630000000 | 1 | / | |\n * | 1630000000 | 2 | /boot/efi | |\n * | 1630000000 | 2 | | / |\n * | 1630000000 | 3 | | /boot/efi |\n * +------------+--------+-----------+-----------+\n */\nexport function applyMergeColumnsTransform(\n data: Array<Record<string, unknown>>,\n selectedColumns: string[],\n outputName: string\n): Array<Record<string, unknown>> {\n const result: Array<Record<string, unknown>> = [];\n\n for (const row of data) {\n const columns = Object.keys(row).filter((k) => selectedColumns.includes(k));\n\n const selectedColumnValues: Record<string, unknown> = {};\n\n for (const column of columns) {\n selectedColumnValues[column] = row[column];\n delete row[column];\n }\n\n for (const column of columns) {\n result.push({ ...row, [outputName]: selectedColumnValues[column] });\n }\n\n if (columns.length === 0) {\n result.push(row);\n }\n }\n\n return result;\n}\n\n/*\n * Merge Indexed Columns: All indexed columns are merged to one column\n *\n * Example: Join on 'value' column\n * INPUT:\n * | timestamp #1 | timestamp #2 | value #1 | value #2 | instance #1 | instance #2 |\n * |--------------|--------------|----------|----------|-------------|-------------|\n * | 1630000000 | | 55 | | toto | |\n * | 1630000000 | | 33 | | toto | |\n * | 1630000000 | | 45 | | toto | |\n * | | 1630000000 | | 112 | | titi |\n * | | 1630000000 | | 20 | | titi |\n * | | 1630000000 | | 10 | | titi |\n *\n * OUTPUT:\n * | timestamp #1 | timestamp #2 | value | instance #1 | instance #2 |\n * |--------------|--------------|-------|-------------|-------------|\n * | 1630000000 | | 55 | toto | |\n * | 1630000000 | | 33 | toto | |\n * | 1630000000 | | 45 | toto | |\n * | | 1630000000 | 112 | | titi |\n * | | 1630000000 | 20 | | titi |\n * | | 1630000000 | 10 | | titi |\n */\nexport function applyMergeIndexedColumnsTransform(\n data: Array<Record<string, unknown>>,\n column: string\n): Array<Record<string, unknown>> {\n const result: Array<Record<string, unknown>> = [];\n\n for (const entry of data) {\n const indexedColumns = Object.keys(entry).filter((k) =>\n new RegExp('^((' + column + ' #\\\\d+)|(' + column + '))$').test(k)\n );\n const indexedColumnValues: Record<string, unknown> = {};\n\n for (const indexedColumn of indexedColumns) {\n indexedColumnValues[indexedColumn] = entry[indexedColumn];\n delete entry[indexedColumn];\n }\n\n for (const indexedColumn of indexedColumns) {\n result.push({ ...entry, [column]: indexedColumnValues[indexedColumn] });\n }\n\n if (indexedColumns.length === 0) {\n result.push(entry);\n }\n }\n\n return result;\n}\n\n/*\n * Merge Indexed Columns: All indexed columns are merged to one column\n *\n * INPUT:\n * | timestamp | value #1 | value #2 | mount #1 | mount #2 | instance #1 | instance #2 | env #1 | env #2 |\n * |------------|----------|----------|-----------|-----------|-------------|-------------|--------|--------|\n * | 1630000000 | 1 | | / | | test:44 | | prd | |\n * | 1630000000 | 2 | | /boot/efi | | test:44 | | prd | |\n * | 1630000000 | | 5 | | / | | test:44 | | prd |\n * | 1630000000 | | 6 | | /boot/efi | | test:44 | | prd |\n *\n * OUTPUT:\n * | timestamp | value #1 | value #2 | mount | instance | env |\n * |------------|----------|----------|-----------|----------|-----|\n * | 1630000000 | 1 | 5 | / | test:44 | prd |\n * | 1630000000 | 2 | 6 | /boot/efi | test:44 | prd |\n */\nexport function applyMergeSeriesTransform(data: Array<Record<string, unknown>>): Array<Record<string, unknown>> {\n let result: Array<Record<string, unknown>> = [...data];\n\n const labelColumns = Array.from(\n new Set(\n data\n .flatMap(Object.keys)\n .map((label) => label.replace(/ #\\d+/, ''))\n .filter((label) => label !== 'value')\n )\n );\n\n for (const label of labelColumns) {\n result = applyMergeIndexedColumnsTransform(result, label);\n }\n\n result = applyJoinTransform(result, labelColumns);\n\n return result;\n}\n\n/*\n * Transforms query data with the given transforms\n */\nexport function transformData(\n data: Array<Record<string, unknown>>,\n transforms: Transform[]\n): Array<Record<string, unknown>> {\n let result: Array<Record<string, unknown>> = data;\n\n // Apply transforms by their orders\n for (const transform of transforms ?? []) {\n if (transform.spec.disabled) continue;\n\n switch (transform.kind) {\n case 'JoinByColumnValue': {\n if (transform.spec.columns && transform.spec.columns.length > 0) {\n result = applyJoinTransform(result, transform.spec.columns);\n }\n break;\n }\n case 'MergeIndexedColumns': {\n if (transform.spec.column) {\n result = applyMergeIndexedColumnsTransform(result, transform.spec.column);\n }\n break;\n }\n case 'MergeColumns': {\n if (transform.spec.columns && transform.spec.columns.length > 0 && transform.spec.name) {\n result = applyMergeColumnsTransform(result, transform.spec.columns, transform.spec.name);\n }\n break;\n }\n case 'MergeSeries': {\n result = applyMergeSeriesTransform(result);\n break;\n }\n }\n }\n\n // Ordering data column alphabetically\n result = result.map((row) => {\n return Object.keys(row)\n .sort()\n .reduce((obj: Record<string, unknown>, key: string) => {\n obj[key] = row[key];\n return obj;\n }, {});\n });\n return result;\n}\n"],"names":["applyJoinTransform","data","columns","length","rowHashed","row","rowHash","Object","keys","filter","k","includes","map","join","rowHashedValue","values","applyMergeColumnsTransform","selectedColumns","outputName","result","selectedColumnValues","column","push","applyMergeIndexedColumnsTransform","entry","indexedColumns","RegExp","test","indexedColumnValues","indexedColumn","applyMergeSeriesTransform","labelColumns","Array","from","Set","flatMap","label","replace","transformData","transforms","transform","spec","disabled","kind","name","sort","reduce","obj","key"],"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;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASA,mBACdC,IAAoC,EACpCC,OAAiB;IAEjB,qDAAqD;IACrD,IAAIA,QAAQC,MAAM,KAAK,GAAG;QACxB,OAAOF;IACT;IAEA,MAAMG,YAAwD,CAAC;IAE/D,KAAK,MAAMC,OAAOJ,KAAM;QACtB,MAAMK,UAAUC,OAAOC,IAAI,CAACH,KACzBI,MAAM,CAAC,CAACC,IAAMR,QAAQS,QAAQ,CAACD,IAC/BE,GAAG,CAAC,CAACF,IAAML,GAAG,CAACK,EAAE,EACjBG,IAAI,CAAC;QAER,MAAMC,iBAAiBV,SAAS,CAACE,QAAQ;QACzC,IAAIQ,gBAAgB;YAClBV,SAAS,CAACE,QAAQ,GAAG;gBAAE,GAAGQ,cAAc;gBAAE,GAAGT,GAAG;YAAC;QACnD,OAAO;YACLD,SAAS,CAACE,QAAQ,GAAG;gBAAE,GAAGD,GAAG;YAAC;QAChC;IACF;IAC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,OAAO,CAACC,MAAM,GAAG,KAAKqC,UAAUC,IAAI,CAACG,IAAI,EAAE;wBACtFzB,SAASH,2BAA2BG,QAAQqB,UAAUC,IAAI,CAACvC,OAAO,EAAEsC,UAAUC,IAAI,CAACG,IAAI;oBACzF;oBACA;gBACF;YACA,KAAK;gBAAe;oBAClBzB,SAASW,0BAA0BX;oBACnC;gBACF;QACF;IACF;IAEA,sCAAsC;IACtCA,SAASA,OAAOP,GAAG,CAAC,CAACP;QACnB,OAAOE,OAAOC,IAAI,CAACH,KAChBwC,IAAI,GACJC,MAAM,CAAC,CAACC,KAA8BC;YACrCD,GAAG,CAACC,IAAI,GAAG3C,GAAG,CAAC2C,IAAI;YACnB,OAAOD;QACT,GAAG,CAAC;IACR;IACA,OAAO5B;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/core",
3
- "version": "0.53.0-beta.0",
3
+ "version": "0.53.0-beta.1",
4
4
  "description": "Core functionality consumed by both the Perses UI and plugins",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -35,10 +35,6 @@
35
35
  "numbro": "^2.3.6",
36
36
  "zod": "^3.21.4"
37
37
  },
38
- "peerDependencies": {
39
- "react": "^17.0.2 || ^18.0.0",
40
- "react-dom": "^17.0.2 || ^18.0.0"
41
- },
42
38
  "devDependencies": {
43
39
  "@types/lodash": "^4.17.16"
44
40
  },
@@ -1,64 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- useDeepMemo: function() {
25
- return useDeepMemo;
26
- },
27
- useMemoized: function() {
28
- return useMemoized;
29
- }
30
- });
31
- const _react = require("react");
32
- const _isEqual = /*#__PURE__*/ _interop_require_default(require("lodash/isEqual"));
33
- function _interop_require_default(obj) {
34
- return obj && obj.__esModule ? obj : {
35
- default: obj
36
- };
37
- }
38
- function useMemoized(factory, deps) {
39
- const ref = (0, _react.useRef)();
40
- let areEqual = true;
41
- for(let i = 0; i < deps.length; i++){
42
- if (ref.current?.deps[i] !== deps[i]) {
43
- areEqual = false;
44
- break;
45
- }
46
- }
47
- if (ref.current === undefined || areEqual === false) {
48
- ref.current = {
49
- value: factory(),
50
- deps: deps
51
- };
52
- }
53
- return ref.current.value;
54
- }
55
- function useDeepMemo(factory, deps) {
56
- const ref = (0, _react.useRef)();
57
- if (ref.current === undefined || (0, _isEqual.default)(deps, ref.current.deps) === false) {
58
- ref.current = {
59
- value: factory(),
60
- deps
61
- };
62
- }
63
- return ref.current.value;
64
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * A (temporary) userland implementation of `useEvent` from this React RFC: https://github.com/reactjs/rfcs/pull/220.
3
- *
4
- * Typically useful for getting a stable reference to an "event" function (i.e. one that isn't called during render
5
- * but is called later in a useEffect or event handler) that accesses state or props.
6
- */
7
- export declare function useEvent<T extends unknown[], U>(handler: (...args: T) => U): (...args: T) => U;
8
- //# sourceMappingURL=event.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/utils/event.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAO9F"}
@@ -1,27 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- import { useRef, useLayoutEffect, useCallback } from 'react';
14
- /**
15
- * A (temporary) userland implementation of `useEvent` from this React RFC: https://github.com/reactjs/rfcs/pull/220.
16
- *
17
- * Typically useful for getting a stable reference to an "event" function (i.e. one that isn't called during render
18
- * but is called later in a useEffect or event handler) that accesses state or props.
19
- */ export function useEvent(handler) {
20
- const handlerRef = useRef(handler);
21
- useLayoutEffect(()=>{
22
- handlerRef.current = handler;
23
- });
24
- return useCallback((...args)=>handlerRef.current(...args), []);
25
- }
26
-
27
- //# sourceMappingURL=event.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/event.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 { useRef, useLayoutEffect, useCallback } from 'react';\n\n/**\n * A (temporary) userland implementation of `useEvent` from this React RFC: https://github.com/reactjs/rfcs/pull/220.\n *\n * Typically useful for getting a stable reference to an \"event\" function (i.e. one that isn't called during render\n * but is called later in a useEffect or event handler) that accesses state or props.\n */\nexport function useEvent<T extends unknown[], U>(handler: (...args: T) => U): (...args: T) => U {\n const handlerRef = useRef(handler);\n useLayoutEffect(() => {\n handlerRef.current = handler;\n });\n\n return useCallback((...args) => handlerRef.current(...args), []);\n}\n"],"names":["useRef","useLayoutEffect","useCallback","useEvent","handler","handlerRef","current","args"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,MAAM,EAAEC,eAAe,EAAEC,WAAW,QAAQ,QAAQ;AAE7D;;;;;CAKC,GACD,OAAO,SAASC,SAAiCC,OAA0B;IACzE,MAAMC,aAAaL,OAAOI;IAC1BH,gBAAgB;QACdI,WAAWC,OAAO,GAAGF;IACvB;IAEA,OAAOF,YAAY,CAAC,GAAGK,OAASF,WAAWC,OAAO,IAAIC,OAAO,EAAE;AACjE"}
@@ -1,13 +0,0 @@
1
- import { DependencyList } from 'react';
2
- /**
3
- * Like React's useMemo, but guarantees the value will only be recalulated if
4
- * a dependency changes. Uses strict equality (===) for comparison. (React's
5
- * useMemo does not offer this guarantee, it's only a performance optimization).
6
- */
7
- export declare function useMemoized<T>(factory: () => T, deps: DependencyList): T;
8
- /**
9
- * Like React's useMemo, except it does a deep equality comparison with lodash's
10
- * isEqual on the dependency list.
11
- */
12
- export declare function useDeepMemo<T>(factory: () => T, deps: DependencyList): T;
13
- //# sourceMappingURL=memo.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memo.d.ts","sourceRoot":"","sources":["../../src/utils/memo.ts"],"names":[],"mappings":"AAaA,OAAO,EAAU,cAAc,EAAE,MAAM,OAAO,CAAC;AAQ/C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,CAAC,CAgBxE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,CAAC,CAMxE"}
@@ -1,50 +0,0 @@
1
- // Copyright 2023 The Perses Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- import { useRef } from 'react';
14
- import isEqual from 'lodash/isEqual';
15
- /**
16
- * Like React's useMemo, but guarantees the value will only be recalulated if
17
- * a dependency changes. Uses strict equality (===) for comparison. (React's
18
- * useMemo does not offer this guarantee, it's only a performance optimization).
19
- */ export function useMemoized(factory, deps) {
20
- const ref = useRef();
21
- let areEqual = true;
22
- for(let i = 0; i < deps.length; i++){
23
- if (ref.current?.deps[i] !== deps[i]) {
24
- areEqual = false;
25
- break;
26
- }
27
- }
28
- if (ref.current === undefined || areEqual === false) {
29
- ref.current = {
30
- value: factory(),
31
- deps: deps
32
- };
33
- }
34
- return ref.current.value;
35
- }
36
- /**
37
- * Like React's useMemo, except it does a deep equality comparison with lodash's
38
- * isEqual on the dependency list.
39
- */ export function useDeepMemo(factory, deps) {
40
- const ref = useRef();
41
- if (ref.current === undefined || isEqual(deps, ref.current.deps) === false) {
42
- ref.current = {
43
- value: factory(),
44
- deps
45
- };
46
- }
47
- return ref.current.value;
48
- }
49
-
50
- //# sourceMappingURL=memo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/memo.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 { useRef, DependencyList } from 'react';\nimport isEqual from 'lodash/isEqual';\n\ntype MemoRef<T> = {\n value: T;\n deps: DependencyList;\n};\n\n/**\n * Like React's useMemo, but guarantees the value will only be recalulated if\n * a dependency changes. Uses strict equality (===) for comparison. (React's\n * useMemo does not offer this guarantee, it's only a performance optimization).\n */\nexport function useMemoized<T>(factory: () => T, deps: DependencyList): T {\n const ref = useRef<MemoRef<T>>();\n\n let areEqual = true;\n for (let i = 0; i < deps.length; i++) {\n if (ref.current?.deps[i] !== deps[i]) {\n areEqual = false;\n break;\n }\n }\n\n if (ref.current === undefined || areEqual === false) {\n ref.current = { value: factory(), deps: deps };\n }\n\n return ref.current.value;\n}\n\n/**\n * Like React's useMemo, except it does a deep equality comparison with lodash's\n * isEqual on the dependency list.\n */\nexport function useDeepMemo<T>(factory: () => T, deps: DependencyList): T {\n const ref = useRef<MemoRef<T>>();\n if (ref.current === undefined || isEqual(deps, ref.current.deps) === false) {\n ref.current = { value: factory(), deps };\n }\n return ref.current.value;\n}\n"],"names":["useRef","isEqual","useMemoized","factory","deps","ref","areEqual","i","length","current","undefined","value","useDeepMemo"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,MAAM,QAAwB,QAAQ;AAC/C,OAAOC,aAAa,iBAAiB;AAOrC;;;;CAIC,GACD,OAAO,SAASC,YAAeC,OAAgB,EAAEC,IAAoB;IACnE,MAAMC,MAAML;IAEZ,IAAIM,WAAW;IACf,IAAK,IAAIC,IAAI,GAAGA,IAAIH,KAAKI,MAAM,EAAED,IAAK;QACpC,IAAIF,IAAII,OAAO,EAAEL,IAAI,CAACG,EAAE,KAAKH,IAAI,CAACG,EAAE,EAAE;YACpCD,WAAW;YACX;QACF;IACF;IAEA,IAAID,IAAII,OAAO,KAAKC,aAAaJ,aAAa,OAAO;QACnDD,IAAII,OAAO,GAAG;YAAEE,OAAOR;YAAWC,MAAMA;QAAK;IAC/C;IAEA,OAAOC,IAAII,OAAO,CAACE,KAAK;AAC1B;AAEA;;;CAGC,GACD,OAAO,SAASC,YAAeT,OAAgB,EAAEC,IAAoB;IACnE,MAAMC,MAAML;IACZ,IAAIK,IAAII,OAAO,KAAKC,aAAaT,QAAQG,MAAMC,IAAII,OAAO,CAACL,IAAI,MAAM,OAAO;QAC1EC,IAAII,OAAO,GAAG;YAAEE,OAAOR;YAAWC;QAAK;IACzC;IACA,OAAOC,IAAII,OAAO,CAACE,KAAK;AAC1B"}