@perses-dev/components 0.54.0-beta.3 → 0.54.0-beta.5

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.
@@ -30,6 +30,9 @@ _export_star(require("./value-mapping"), exports);
30
30
  _export_star(require("./regexp"), exports);
31
31
  _export_star(require("./transform-data"), exports);
32
32
  _export_star(require("./time-series-data"), exports);
33
+ _export_star(require("./trace-data"), exports);
34
+ _export_star(require("./types"), exports);
35
+ _export_star(require("./text"), exports);
33
36
  function _export_star(from, to) {
34
37
  Object.keys(from).forEach(function(k) {
35
38
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -29,6 +29,38 @@ _export(exports, {
29
29
  }
30
30
  });
31
31
  const _variableinterpolation = require("./variable-interpolation");
32
+ function expandQueryParamValue(value, variableState) {
33
+ // If value is an array, process each element
34
+ if (Array.isArray(value)) {
35
+ return value.map((v)=>expandQueryParamValue(v, variableState));
36
+ }
37
+ // Now we know value is a string, so we can safely use string methods
38
+ const valueString = value;
39
+ const variablesMap = (0, _variableinterpolation.parseVariablesAndFormat)(valueString);
40
+ // Find the first multi-value variable that should expand to repeated keys
41
+ for (const [varName, format] of variablesMap){
42
+ const varState = variableState[varName];
43
+ if (!varState || !Array.isArray(varState.value)) continue;
44
+ // If format is queryparam or not specified (default for query params), expand to array
45
+ if (!format || format === _variableinterpolation.InterpolationFormat.QUERYPARAM) {
46
+ // Build syntax patterns for this variable reference
47
+ const simpleSyntax = '$' + varName;
48
+ const bracketSyntax = format ? '${' + varName + ':' + format + '}' : '${' + varName + '}';
49
+ return varState.value.map((singleValue)=>{
50
+ let text = valueString;
51
+ // Replace the variable reference with the raw value directly.
52
+ // We cannot use replaceVariables here because it would apply QUERYPARAM format
53
+ // to the single value, producing "varName=val" instead of just "val".
54
+ text = text.replaceAll(bracketSyntax, singleValue);
55
+ text = text.replaceAll(simpleSyntax, singleValue);
56
+ // Replace any remaining variables (other than the expanded one) using standard interpolation
57
+ return (0, _variableinterpolation.replaceVariables)(text, variableState);
58
+ });
59
+ }
60
+ }
61
+ // No multi-value expansion needed — use standard interpolation
62
+ return (0, _variableinterpolation.replaceVariables)(valueString, variableState);
63
+ }
32
64
  function interpolateHeaders(headers, variableState) {
33
65
  const result = {};
34
66
  for (const [key, value] of Object.entries(headers)){
@@ -42,7 +74,7 @@ function interpolateQueryParams(queryParams, variableState) {
42
74
  if (Array.isArray(value)) {
43
75
  result[key] = value.map((v)=>(0, _variableinterpolation.replaceVariables)(v, variableState));
44
76
  } else {
45
- result[key] = (0, _variableinterpolation.replaceVariables)(value, variableState);
77
+ result[key] = expandQueryParamValue(value, variableState);
46
78
  }
47
79
  }
48
80
  return result;
@@ -0,0 +1,52 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "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: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get getResourceDisplayName () {
25
+ return getResourceDisplayName;
26
+ },
27
+ get getResourceExtendedDisplayName () {
28
+ return getResourceExtendedDisplayName;
29
+ }
30
+ });
31
+ function getResourceDisplayName(resource) {
32
+ // Variables
33
+ if (resource.spec?.spec?.display?.name) {
34
+ return resource.spec.spec.display.name;
35
+ }
36
+ // Other resources with display
37
+ if (resource.spec?.display?.name) {
38
+ return resource.spec.display.name;
39
+ }
40
+ return resource.metadata.name;
41
+ }
42
+ function getResourceExtendedDisplayName(resource) {
43
+ // Variables
44
+ if (resource.spec?.spec?.display?.name) {
45
+ return `${resource.spec.spec.display.name} (ID: ${resource.metadata.name})`;
46
+ }
47
+ // Other resources with display
48
+ if (resource.spec?.display?.name) {
49
+ return `${resource.spec.display.name} (ID: ${resource.metadata.name})`;
50
+ }
51
+ return resource.metadata.name;
52
+ }
@@ -0,0 +1,25 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "isValidTraceId", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return isValidTraceId;
21
+ }
22
+ });
23
+ function isValidTraceId(traceId) {
24
+ return /^[0-9a-fA-F]+$/.test(traceId);
25
+ }
@@ -0,0 +1,16 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
@@ -14,4 +14,7 @@ export * from './value-mapping';
14
14
  export * from './regexp';
15
15
  export * from './transform-data';
16
16
  export * from './time-series-data';
17
+ export * from './trace-data';
18
+ export * from './types';
19
+ export * from './text';
17
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -26,5 +26,8 @@ export * from './value-mapping';
26
26
  export * from './regexp';
27
27
  export * from './transform-data';
28
28
  export * from './time-series-data';
29
+ export * from './trace-data';
30
+ export * from './types';
31
+ export * from './text';
29
32
 
30
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.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 * from './axis';\nexport * from './browser-storage';\nexport * from './chart-actions';\nexport * from './combine-sx';\nexport * from './component-ids';\nexport * from './data-field-interpolation';\nexport * from './format';\nexport * from './memo';\nexport * from './request-interpolation';\nexport * from './selection-interpolation';\nexport * from './theme-gen';\nexport * from './variable-interpolation';\nexport * from './value-mapping';\nexport * from './regexp';\nexport * from './transform-data';\nexport * from './time-series-data';\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,cAAc,SAAS;AACvB,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,6BAA6B;AAC3C,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,0BAA0B;AACxC,cAAc,4BAA4B;AAC1C,cAAc,cAAc;AAC5B,cAAc,2BAA2B;AACzC,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,mBAAmB;AACjC,cAAc,qBAAqB"}
1
+ {"version":3,"sources":["../../src/utils/index.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 * from './axis';\nexport * from './browser-storage';\nexport * from './chart-actions';\nexport * from './combine-sx';\nexport * from './component-ids';\nexport * from './data-field-interpolation';\nexport * from './format';\nexport * from './memo';\nexport * from './request-interpolation';\nexport * from './selection-interpolation';\nexport * from './theme-gen';\nexport * from './variable-interpolation';\nexport * from './value-mapping';\nexport * from './regexp';\nexport * from './transform-data';\nexport * from './time-series-data';\nexport * from './trace-data';\nexport * from './types';\nexport * from './text';\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,cAAc,SAAS;AACvB,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,eAAe;AAC7B,cAAc,kBAAkB;AAChC,cAAc,6BAA6B;AAC3C,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,0BAA0B;AACxC,cAAc,4BAA4B;AAC1C,cAAc,cAAc;AAC5B,cAAc,2BAA2B;AACzC,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,mBAAmB;AACjC,cAAc,qBAAqB;AACnC,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"request-interpolation.d.ts","sourceRoot":"","sources":["../../src/utils/request-interpolation.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAoB,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE9E,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEjE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,gBAAgB,GAAG,cAAc,CAMnH;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,gBAAgB,EAC7B,aAAa,EAAE,gBAAgB,GAC9B,gBAAgB,CAUlB"}
1
+ {"version":3,"file":"request-interpolation.d.ts","sourceRoot":"","sources":["../../src/utils/request-interpolation.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAEL,gBAAgB,EAGjB,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAwCjE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,EAAE,gBAAgB,GAAG,cAAc,CAMnH;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,gBAAgB,EAC7B,aAAa,EAAE,gBAAgB,GAC9B,gBAAgB,CAUlB"}
@@ -10,7 +10,39 @@
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 { replaceVariables } from './variable-interpolation';
13
+ import { replaceVariables, parseVariablesAndFormat, InterpolationFormat } from './variable-interpolation';
14
+ function expandQueryParamValue(value, variableState) {
15
+ // If value is an array, process each element
16
+ if (Array.isArray(value)) {
17
+ return value.map((v)=>expandQueryParamValue(v, variableState));
18
+ }
19
+ // Now we know value is a string, so we can safely use string methods
20
+ const valueString = value;
21
+ const variablesMap = parseVariablesAndFormat(valueString);
22
+ // Find the first multi-value variable that should expand to repeated keys
23
+ for (const [varName, format] of variablesMap){
24
+ const varState = variableState[varName];
25
+ if (!varState || !Array.isArray(varState.value)) continue;
26
+ // If format is queryparam or not specified (default for query params), expand to array
27
+ if (!format || format === InterpolationFormat.QUERYPARAM) {
28
+ // Build syntax patterns for this variable reference
29
+ const simpleSyntax = '$' + varName;
30
+ const bracketSyntax = format ? '${' + varName + ':' + format + '}' : '${' + varName + '}';
31
+ return varState.value.map((singleValue)=>{
32
+ let text = valueString;
33
+ // Replace the variable reference with the raw value directly.
34
+ // We cannot use replaceVariables here because it would apply QUERYPARAM format
35
+ // to the single value, producing "varName=val" instead of just "val".
36
+ text = text.replaceAll(bracketSyntax, singleValue);
37
+ text = text.replaceAll(simpleSyntax, singleValue);
38
+ // Replace any remaining variables (other than the expanded one) using standard interpolation
39
+ return replaceVariables(text, variableState);
40
+ });
41
+ }
42
+ }
43
+ // No multi-value expansion needed — use standard interpolation
44
+ return replaceVariables(valueString, variableState);
45
+ }
14
46
  export function interpolateHeaders(headers, variableState) {
15
47
  const result = {};
16
48
  for (const [key, value] of Object.entries(headers)){
@@ -24,7 +56,7 @@ export function interpolateQueryParams(queryParams, variableState) {
24
56
  if (Array.isArray(value)) {
25
57
  result[key] = value.map((v)=>replaceVariables(v, variableState));
26
58
  } else {
27
- result[key] = replaceVariables(value, variableState);
59
+ result[key] = expandQueryParamValue(value, variableState);
28
60
  }
29
61
  }
30
62
  return result;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/request-interpolation.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 { RequestHeaders } from '@perses-dev/client';\nimport { replaceVariables, VariableStateMap } from './variable-interpolation';\n\nexport type QueryParamValues = Record<string, string | string[]>;\n\nexport function interpolateHeaders(headers: Record<string, string>, variableState: VariableStateMap): RequestHeaders {\n const result: RequestHeaders = {};\n for (const [key, value] of Object.entries(headers)) {\n result[key] = replaceVariables(value, variableState);\n }\n return result;\n}\n\nexport function interpolateQueryParams(\n queryParams: QueryParamValues,\n variableState: VariableStateMap\n): QueryParamValues {\n const result: QueryParamValues = {};\n for (const [key, value] of Object.entries(queryParams)) {\n if (Array.isArray(value)) {\n result[key] = value.map((v) => replaceVariables(v, variableState));\n } else {\n result[key] = replaceVariables(value, variableState);\n }\n }\n return result;\n}\n"],"names":["replaceVariables","interpolateHeaders","headers","variableState","result","key","value","Object","entries","interpolateQueryParams","queryParams","Array","isArray","map","v"],"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;AAGjC,SAASA,gBAAgB,QAA0B,2BAA2B;AAI9E,OAAO,SAASC,mBAAmBC,OAA+B,EAAEC,aAA+B;IACjG,MAAMC,SAAyB,CAAC;IAChC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACN,SAAU;QAClDE,MAAM,CAACC,IAAI,GAAGL,iBAAiBM,OAAOH;IACxC;IACA,OAAOC;AACT;AAEA,OAAO,SAASK,uBACdC,WAA6B,EAC7BP,aAA+B;IAE/B,MAAMC,SAA2B,CAAC;IAClC,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACE,aAAc;QACtD,IAAIC,MAAMC,OAAO,CAACN,QAAQ;YACxBF,MAAM,CAACC,IAAI,GAAGC,MAAMO,GAAG,CAAC,CAACC,IAAMd,iBAAiBc,GAAGX;QACrD,OAAO;YACLC,MAAM,CAACC,IAAI,GAAGL,iBAAiBM,OAAOH;QACxC;IACF;IACA,OAAOC;AACT"}
1
+ {"version":3,"sources":["../../src/utils/request-interpolation.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 { RequestHeaders } from '@perses-dev/client';\nimport {\n replaceVariables,\n VariableStateMap,\n parseVariablesAndFormat,\n InterpolationFormat,\n} from './variable-interpolation';\n\nexport type QueryParamValues = Record<string, string | string[]>;\n\nfunction expandQueryParamValue(value: string | string[], variableState: VariableStateMap): string | string[] {\n // If value is an array, process each element\n if (Array.isArray(value)) {\n return value.map((v) => expandQueryParamValue(v, variableState) as string);\n }\n\n // Now we know value is a string, so we can safely use string methods\n const valueString = value as string;\n const variablesMap = parseVariablesAndFormat(valueString);\n\n // Find the first multi-value variable that should expand to repeated keys\n for (const [varName, format] of variablesMap) {\n const varState = variableState[varName];\n if (!varState || !Array.isArray(varState.value)) continue;\n\n // If format is queryparam or not specified (default for query params), expand to array\n if (!format || format === InterpolationFormat.QUERYPARAM) {\n // Build syntax patterns for this variable reference\n const simpleSyntax = '$' + varName;\n const bracketSyntax = format ? '${' + varName + ':' + format + '}' : '${' + varName + '}';\n\n return varState.value.map((singleValue) => {\n let text = valueString;\n // Replace the variable reference with the raw value directly.\n // We cannot use replaceVariables here because it would apply QUERYPARAM format\n // to the single value, producing \"varName=val\" instead of just \"val\".\n text = text.replaceAll(bracketSyntax, singleValue);\n text = text.replaceAll(simpleSyntax, singleValue);\n // Replace any remaining variables (other than the expanded one) using standard interpolation\n return replaceVariables(text, variableState);\n });\n }\n }\n\n // No multi-value expansion needed — use standard interpolation\n return replaceVariables(valueString, variableState);\n}\n\nexport function interpolateHeaders(headers: Record<string, string>, variableState: VariableStateMap): RequestHeaders {\n const result: RequestHeaders = {};\n for (const [key, value] of Object.entries(headers)) {\n result[key] = replaceVariables(value, variableState);\n }\n return result;\n}\n\nexport function interpolateQueryParams(\n queryParams: QueryParamValues,\n variableState: VariableStateMap\n): QueryParamValues {\n const result: QueryParamValues = {};\n for (const [key, value] of Object.entries(queryParams)) {\n if (Array.isArray(value)) {\n result[key] = value.map((v) => replaceVariables(v, variableState));\n } else {\n result[key] = expandQueryParamValue(value, variableState);\n }\n }\n return result;\n}\n"],"names":["replaceVariables","parseVariablesAndFormat","InterpolationFormat","expandQueryParamValue","value","variableState","Array","isArray","map","v","valueString","variablesMap","varName","format","varState","QUERYPARAM","simpleSyntax","bracketSyntax","singleValue","text","replaceAll","interpolateHeaders","headers","result","key","Object","entries","interpolateQueryParams","queryParams"],"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;AAGjC,SACEA,gBAAgB,EAEhBC,uBAAuB,EACvBC,mBAAmB,QACd,2BAA2B;AAIlC,SAASC,sBAAsBC,KAAwB,EAAEC,aAA+B;IACtF,6CAA6C;IAC7C,IAAIC,MAAMC,OAAO,CAACH,QAAQ;QACxB,OAAOA,MAAMI,GAAG,CAAC,CAACC,IAAMN,sBAAsBM,GAAGJ;IACnD;IAEA,qEAAqE;IACrE,MAAMK,cAAcN;IACpB,MAAMO,eAAeV,wBAAwBS;IAE7C,0EAA0E;IAC1E,KAAK,MAAM,CAACE,SAASC,OAAO,IAAIF,aAAc;QAC5C,MAAMG,WAAWT,aAAa,CAACO,QAAQ;QACvC,IAAI,CAACE,YAAY,CAACR,MAAMC,OAAO,CAACO,SAASV,KAAK,GAAG;QAEjD,uFAAuF;QACvF,IAAI,CAACS,UAAUA,WAAWX,oBAAoBa,UAAU,EAAE;YACxD,oDAAoD;YACpD,MAAMC,eAAe,MAAMJ;YAC3B,MAAMK,gBAAgBJ,SAAS,OAAOD,UAAU,MAAMC,SAAS,MAAM,OAAOD,UAAU;YAEtF,OAAOE,SAASV,KAAK,CAACI,GAAG,CAAC,CAACU;gBACzB,IAAIC,OAAOT;gBACX,8DAA8D;gBAC9D,+EAA+E;gBAC/E,sEAAsE;gBACtES,OAAOA,KAAKC,UAAU,CAACH,eAAeC;gBACtCC,OAAOA,KAAKC,UAAU,CAACJ,cAAcE;gBACrC,6FAA6F;gBAC7F,OAAOlB,iBAAiBmB,MAAMd;YAChC;QACF;IACF;IAEA,+DAA+D;IAC/D,OAAOL,iBAAiBU,aAAaL;AACvC;AAEA,OAAO,SAASgB,mBAAmBC,OAA+B,EAAEjB,aAA+B;IACjG,MAAMkB,SAAyB,CAAC;IAChC,KAAK,MAAM,CAACC,KAAKpB,MAAM,IAAIqB,OAAOC,OAAO,CAACJ,SAAU;QAClDC,MAAM,CAACC,IAAI,GAAGxB,iBAAiBI,OAAOC;IACxC;IACA,OAAOkB;AACT;AAEA,OAAO,SAASI,uBACdC,WAA6B,EAC7BvB,aAA+B;IAE/B,MAAMkB,SAA2B,CAAC;IAClC,KAAK,MAAM,CAACC,KAAKpB,MAAM,IAAIqB,OAAOC,OAAO,CAACE,aAAc;QACtD,IAAItB,MAAMC,OAAO,CAACH,QAAQ;YACxBmB,MAAM,CAACC,IAAI,GAAGpB,MAAMI,GAAG,CAAC,CAACC,IAAMT,iBAAiBS,GAAGJ;QACrD,OAAO;YACLkB,MAAM,CAACC,IAAI,GAAGrB,sBAAsBC,OAAOC;QAC7C;IACF;IACA,OAAOkB;AACT"}
@@ -0,0 +1,8 @@
1
+ import { Resource } from '@perses-dev/client';
2
+ export declare function getResourceDisplayName<T extends Resource>(resource: T): string;
3
+ /**
4
+ * If the resource has a display name, return the resource display name with the resource name too
5
+ * Else, only return the resource name
6
+ */
7
+ export declare function getResourceExtendedDisplayName<T extends Resource>(resource: T): string;
8
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAY9E;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAYtF"}
@@ -0,0 +1,39 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export function getResourceDisplayName(resource) {
14
+ // Variables
15
+ if (resource.spec?.spec?.display?.name) {
16
+ return resource.spec.spec.display.name;
17
+ }
18
+ // Other resources with display
19
+ if (resource.spec?.display?.name) {
20
+ return resource.spec.display.name;
21
+ }
22
+ return resource.metadata.name;
23
+ }
24
+ /**
25
+ * If the resource has a display name, return the resource display name with the resource name too
26
+ * Else, only return the resource name
27
+ */ export function getResourceExtendedDisplayName(resource) {
28
+ // Variables
29
+ if (resource.spec?.spec?.display?.name) {
30
+ return `${resource.spec.spec.display.name} (ID: ${resource.metadata.name})`;
31
+ }
32
+ // Other resources with display
33
+ if (resource.spec?.display?.name) {
34
+ return `${resource.spec.display.name} (ID: ${resource.metadata.name})`;
35
+ }
36
+ return resource.metadata.name;
37
+ }
38
+
39
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/text.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 { Resource } from '@perses-dev/client';\n\nexport function getResourceDisplayName<T extends Resource>(resource: T): string {\n // Variables\n if (resource.spec?.spec?.display?.name) {\n return resource.spec.spec.display.name;\n }\n\n // Other resources with display\n if (resource.spec?.display?.name) {\n return resource.spec.display.name;\n }\n\n return resource.metadata.name;\n}\n\n/**\n * If the resource has a display name, return the resource display name with the resource name too\n * Else, only return the resource name\n */\nexport function getResourceExtendedDisplayName<T extends Resource>(resource: T): string {\n // Variables\n if (resource.spec?.spec?.display?.name) {\n return `${resource.spec.spec.display.name} (ID: ${resource.metadata.name})`;\n }\n\n // Other resources with display\n if (resource.spec?.display?.name) {\n return `${resource.spec.display.name} (ID: ${resource.metadata.name})`;\n }\n\n return resource.metadata.name;\n}\n"],"names":["getResourceDisplayName","resource","spec","display","name","metadata","getResourceExtendedDisplayName"],"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,uBAA2CC,QAAW;IACpE,YAAY;IACZ,IAAIA,SAASC,IAAI,EAAEA,MAAMC,SAASC,MAAM;QACtC,OAAOH,SAASC,IAAI,CAACA,IAAI,CAACC,OAAO,CAACC,IAAI;IACxC;IAEA,+BAA+B;IAC/B,IAAIH,SAASC,IAAI,EAAEC,SAASC,MAAM;QAChC,OAAOH,SAASC,IAAI,CAACC,OAAO,CAACC,IAAI;IACnC;IAEA,OAAOH,SAASI,QAAQ,CAACD,IAAI;AAC/B;AAEA;;;CAGC,GACD,OAAO,SAASE,+BAAmDL,QAAW;IAC5E,YAAY;IACZ,IAAIA,SAASC,IAAI,EAAEA,MAAMC,SAASC,MAAM;QACtC,OAAO,GAAGH,SAASC,IAAI,CAACA,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,MAAM,EAAEH,SAASI,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC;IAC7E;IAEA,+BAA+B;IAC/B,IAAIH,SAASC,IAAI,EAAEC,SAASC,MAAM;QAChC,OAAO,GAAGH,SAASC,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,MAAM,EAAEH,SAASI,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC;IACxE;IAEA,OAAOH,SAASI,QAAQ,CAACD,IAAI;AAC/B"}
@@ -0,0 +1,37 @@
1
+ import { BaseMetadata } from '@perses-dev/spec';
2
+ import { TracesData } from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace';
3
+ /**
4
+ * Partial trace information returned by search endpoint
5
+ */
6
+ export interface TraceSearchResult {
7
+ traceId: string;
8
+ rootServiceName: string;
9
+ rootTraceName: string;
10
+ startTimeUnixMs: number;
11
+ durationMs: number;
12
+ serviceStats: Record<string, ServiceStats>;
13
+ }
14
+ export interface ServiceStats {
15
+ spanCount: number;
16
+ /** number of spans with errors, unset if zero */
17
+ errorCount?: number;
18
+ }
19
+ /**
20
+ * A generalized data-model that will be used by Panel components
21
+ * to display traces.
22
+ *
23
+ * If the query contains a valid trace ID, the 'trace' attribute will contain the entire trace.
24
+ * If the query contains a TraceQL query, the 'searchResult' attribute will contain the search results.
25
+ */
26
+ export interface TraceData {
27
+ trace?: TracesData;
28
+ searchResult?: TraceSearchResult[];
29
+ metadata?: TraceMetaData;
30
+ }
31
+ export interface TraceMetaData extends BaseMetadata {
32
+ /** this field indicates if there are more traces matching the search query, however not all traces were returned */
33
+ hasMoreResults?: boolean;
34
+ [key: string]: unknown;
35
+ }
36
+ export declare function isValidTraceId(traceId: string): boolean;
37
+ //# sourceMappingURL=trace-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-data.d.ts","sourceRoot":"","sources":["../../src/utils/trace-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gEAAgE,CAAC;AAE5F;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEnC,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,oHAAoH;IACpH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD"}
@@ -0,0 +1,17 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export function isValidTraceId(traceId) {
14
+ return /^[0-9a-fA-F]+$/.test(traceId);
15
+ }
16
+
17
+ //# sourceMappingURL=trace-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/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 '@perses-dev/spec';\nimport { TracesData } from '@perses-dev/spec/dist/dashboard/query-type/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"}
@@ -0,0 +1,2 @@
1
+ export type DispatchWithPromise<A> = (value: A) => Promise<void>;
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export { };
14
+
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/types.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 type DispatchWithPromise<A> = (value: A) => Promise<void>;\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,WAAiE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.54.0-beta.3",
3
+ "version": "0.54.0-beta.5",
4
4
  "description": "Common UI components used across Perses features",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -34,8 +34,8 @@
34
34
  "@date-fns/tz": "^1.4.1",
35
35
  "@fontsource/inter": "^5.0.0",
36
36
  "@mui/x-date-pickers": "^7.23.1",
37
- "@perses-dev/spec": "0.2.0-beta.0",
38
- "@perses-dev/client": "0.54.0-beta.3",
37
+ "@perses-dev/spec": "0.2.0-beta.2",
38
+ "@perses-dev/client": "0.54.0-beta.5",
39
39
  "numbro": "^2.3.6",
40
40
  "@tanstack/match-sorter-utils": "^8.19.4",
41
41
  "@tanstack/react-table": "^8.20.5",