@perses-dev/core 0.53.0-beta.0 → 0.53.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/datasource-api.js +16 -0
- package/dist/cjs/model/external-variable.js +16 -0
- package/dist/cjs/model/index.js +4 -1
- package/dist/cjs/{utils/event.js → model/panel-group.js} +5 -10
- package/dist/cjs/model/units/date.js +297 -0
- package/dist/cjs/model/units/temperature.js +64 -0
- package/dist/cjs/model/units/time.js +16 -2
- package/dist/cjs/model/units/units.js +27 -3
- package/dist/cjs/utils/index.js +0 -2
- package/dist/cjs/utils/transform-data.js +0 -10
- package/dist/model/datasource-api.d.ts +41 -0
- package/dist/model/datasource-api.d.ts.map +1 -0
- package/dist/model/datasource-api.js +19 -0
- package/dist/model/datasource-api.js.map +1 -0
- package/dist/model/external-variable.d.ts +29 -0
- package/dist/model/external-variable.d.ts.map +1 -0
- package/dist/model/external-variable.js +20 -0
- package/dist/model/external-variable.js.map +1 -0
- package/dist/model/index.d.ts +3 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +4 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/otlp/common/v1/common.d.ts +3 -1
- package/dist/model/otlp/common/v1/common.d.ts.map +1 -1
- package/dist/model/otlp/common/v1/common.js.map +1 -1
- package/dist/model/panel-group.d.ts +63 -0
- package/dist/model/panel-group.d.ts.map +1 -0
- package/dist/model/panel-group.js +19 -0
- package/dist/model/panel-group.js.map +1 -0
- package/dist/model/units/date.d.ts +28 -0
- package/dist/model/units/date.d.ts.map +1 -0
- package/dist/model/units/date.js +278 -0
- package/dist/model/units/date.js.map +1 -0
- package/dist/model/units/temperature.d.ts +11 -0
- package/dist/model/units/temperature.d.ts.map +1 -0
- package/dist/model/units/temperature.js +45 -0
- package/dist/model/units/temperature.js.map +1 -0
- package/dist/model/units/time.d.ts +3 -1
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +16 -2
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/types.d.ts +1 -1
- package/dist/model/units/types.d.ts.map +1 -1
- package/dist/model/units/types.js.map +1 -1
- package/dist/model/units/units.d.ts +21 -1
- package/dist/model/units/units.d.ts.map +1 -1
- package/dist/model/units/units.js +21 -3
- package/dist/model/units/units.js.map +1 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/transform-data.d.ts +0 -1
- package/dist/utils/transform-data.d.ts.map +1 -1
- package/dist/utils/transform-data.js +0 -7
- package/dist/utils/transform-data.js.map +1 -1
- package/package.json +1 -5
- package/dist/cjs/utils/memo.js +0 -64
- package/dist/utils/event.d.ts +0 -8
- package/dist/utils/event.d.ts.map +0 -1
- package/dist/utils/event.js +0 -27
- package/dist/utils/event.js.map +0 -1
- package/dist/utils/memo.d.ts +0 -13
- package/dist/utils/memo.d.ts.map +0 -1
- package/dist/utils/memo.js +0 -50
- package/dist/utils/memo.js.map +0 -1
|
@@ -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"}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -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,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
|
|
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,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,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,eAAe,CAAC;AAC9B,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,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
|
package/dist/model/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
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
|
|
@@ -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';
|
package/dist/model/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright
|
|
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
|
|
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;
|
|
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
|
|
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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { UnitGroupConfig, UnitConfig } from './types';
|
|
2
|
+
type DateUnits = 'datetime-iso' | 'datetime-us' | 'datetime-local' | 'date-iso' | 'date-us' | 'date-local' | 'time-local' | 'time-iso' | 'time-us' | 'relative-time' | 'unix-timestamp' | 'unix-timestamp-ms';
|
|
3
|
+
export type DateFormatOptions = {
|
|
4
|
+
unit?: DateUnits;
|
|
5
|
+
/**
|
|
6
|
+
* The locale to use for formatting. Defaults to the system's locale.
|
|
7
|
+
*/
|
|
8
|
+
locale?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The timezone to use for formatting. Defaults to the user's local timezone.
|
|
11
|
+
*/
|
|
12
|
+
timeZone?: string;
|
|
13
|
+
/**
|
|
14
|
+
* For relative time formatting, the reference time to compare against.
|
|
15
|
+
* Defaults to current time.
|
|
16
|
+
*/
|
|
17
|
+
referenceTime?: number;
|
|
18
|
+
/**
|
|
19
|
+
* This property is not used for date formatting, but is included for
|
|
20
|
+
* compatibility with the FormatControls UI component.
|
|
21
|
+
*/
|
|
22
|
+
decimalPlaces?: number;
|
|
23
|
+
};
|
|
24
|
+
export declare const DATE_GROUP_CONFIG: UnitGroupConfig;
|
|
25
|
+
export declare const DATE_UNIT_CONFIG: Readonly<Record<DateUnits, UnitConfig>>;
|
|
26
|
+
export declare function formatDate(value: number, options?: DateFormatOptions): string;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/model/units/date.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtD,KAAK,SAAS,GACV,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,UAAU,GACV,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,SAAS,GACT,eAAe,GACf,gBAAgB,GAChB,mBAAmB,CAAC;AAExB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAIF,eAAO,MAAM,iBAAiB,EAAE,eAE/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAiDpE,CAAC;AAqGF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAwHjF"}
|
|
@@ -0,0 +1,278 @@
|
|
|
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
|
+
const DATE_GROUP = 'Date';
|
|
14
|
+
export const DATE_GROUP_CONFIG = {
|
|
15
|
+
label: 'Date & Time'
|
|
16
|
+
};
|
|
17
|
+
export const DATE_UNIT_CONFIG = {
|
|
18
|
+
'datetime-iso': {
|
|
19
|
+
group: DATE_GROUP,
|
|
20
|
+
label: 'DateTime (GMT)'
|
|
21
|
+
},
|
|
22
|
+
'datetime-us': {
|
|
23
|
+
group: DATE_GROUP,
|
|
24
|
+
label: 'DateTime (US-East)'
|
|
25
|
+
},
|
|
26
|
+
'datetime-local': {
|
|
27
|
+
group: DATE_GROUP,
|
|
28
|
+
label: 'DateTime (Browser Local)'
|
|
29
|
+
},
|
|
30
|
+
'date-iso': {
|
|
31
|
+
group: DATE_GROUP,
|
|
32
|
+
label: 'Date (GMT)'
|
|
33
|
+
},
|
|
34
|
+
'date-us': {
|
|
35
|
+
group: DATE_GROUP,
|
|
36
|
+
label: 'Date (US-East)'
|
|
37
|
+
},
|
|
38
|
+
'date-local': {
|
|
39
|
+
group: DATE_GROUP,
|
|
40
|
+
label: 'Date (Browser Local)'
|
|
41
|
+
},
|
|
42
|
+
'time-local': {
|
|
43
|
+
group: DATE_GROUP,
|
|
44
|
+
label: 'Time (Browser Local)'
|
|
45
|
+
},
|
|
46
|
+
'time-iso': {
|
|
47
|
+
group: DATE_GROUP,
|
|
48
|
+
label: 'Time (GMT)'
|
|
49
|
+
},
|
|
50
|
+
'time-us': {
|
|
51
|
+
group: DATE_GROUP,
|
|
52
|
+
label: 'Time (US-East)'
|
|
53
|
+
},
|
|
54
|
+
'relative-time': {
|
|
55
|
+
group: DATE_GROUP,
|
|
56
|
+
label: 'Relative Time'
|
|
57
|
+
},
|
|
58
|
+
'unix-timestamp': {
|
|
59
|
+
group: DATE_GROUP,
|
|
60
|
+
label: 'Unix Timestamp (s)'
|
|
61
|
+
},
|
|
62
|
+
'unix-timestamp-ms': {
|
|
63
|
+
group: DATE_GROUP,
|
|
64
|
+
label: 'Unix Timestamp (ms)'
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Converts a numeric value to a Date object.
|
|
69
|
+
* Handles both Unix timestamps (seconds) and millisecond timestamps.
|
|
70
|
+
*/ function valueToDate(value) {
|
|
71
|
+
// Timestamp detection logic with special case handling
|
|
72
|
+
// Main threshold stays at 10 billion to maintain existing behavior
|
|
73
|
+
// Handle special edge cases explicitly
|
|
74
|
+
// Special case: negative timestamps
|
|
75
|
+
if (value < 0) {
|
|
76
|
+
// For negative values, check magnitude to distinguish seconds vs milliseconds
|
|
77
|
+
// Large negative values (> 1 billion in magnitude) are likely milliseconds
|
|
78
|
+
// Small negative values are likely seconds (rare edge case)
|
|
79
|
+
if (Math.abs(value) > 10000000000) {
|
|
80
|
+
return new Date(value); // milliseconds
|
|
81
|
+
} else {
|
|
82
|
+
return new Date(value * 1000); // seconds
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Special case: year 9999 in seconds (~253402300799)
|
|
86
|
+
// This is a very specific edge case for far-future timestamps
|
|
87
|
+
if (value >= 250000000000 && value <= 260000000000) {
|
|
88
|
+
// Check if this looks like year 9999 in seconds
|
|
89
|
+
const asSeconds = new Date(value * 1000);
|
|
90
|
+
const year = asSeconds.getUTCFullYear();
|
|
91
|
+
if (year >= 9999) {
|
|
92
|
+
return asSeconds; // seconds
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const SECONDS_THRESHOLD = 10000000000; // ~year 2286 - original threshold
|
|
96
|
+
if (value < SECONDS_THRESHOLD) {
|
|
97
|
+
// Assume it's in seconds
|
|
98
|
+
return new Date(value * 1000);
|
|
99
|
+
} else {
|
|
100
|
+
// Assume it's in milliseconds
|
|
101
|
+
return new Date(value);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Formats a relative time string using the Intl.RelativeTimeFormat API.
|
|
106
|
+
*/ function formatRelativeTime(date, referenceTime, locale) {
|
|
107
|
+
const referenceDate = new Date(referenceTime);
|
|
108
|
+
const diffMs = date.getTime() - referenceDate.getTime();
|
|
109
|
+
const units = [
|
|
110
|
+
{
|
|
111
|
+
unit: 'year',
|
|
112
|
+
ms: 1000 * 60 * 60 * 24 * 365
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
unit: 'month',
|
|
116
|
+
ms: 1000 * 60 * 60 * 24 * 30
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
unit: 'week',
|
|
120
|
+
ms: 1000 * 60 * 60 * 24 * 7
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
unit: 'day',
|
|
124
|
+
ms: 1000 * 60 * 60 * 24
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
unit: 'hour',
|
|
128
|
+
ms: 1000 * 60 * 60
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
unit: 'minute',
|
|
132
|
+
ms: 1000 * 60
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
unit: 'second',
|
|
136
|
+
ms: 1000
|
|
137
|
+
}
|
|
138
|
+
];
|
|
139
|
+
for (const { unit, ms } of units){
|
|
140
|
+
// Determine the value for the current unit, ensuring it's an integer for Intl.RelativeTimeFormat
|
|
141
|
+
const value = Math.round(diffMs / ms);
|
|
142
|
+
// If the absolute value is 1 or more, use this unit
|
|
143
|
+
if (Math.abs(value) >= 1) {
|
|
144
|
+
const rtf = new Intl.RelativeTimeFormat(locale, {
|
|
145
|
+
numeric: 'auto'
|
|
146
|
+
});
|
|
147
|
+
return rtf.format(value, unit);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// If less than a second, show "now" or "0 seconds"
|
|
151
|
+
const rtf = new Intl.RelativeTimeFormat(locale, {
|
|
152
|
+
numeric: 'auto'
|
|
153
|
+
});
|
|
154
|
+
return rtf.format(0, 'second');
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Gets the browser's preferred locale with comprehensive fallbacks.
|
|
158
|
+
*/ const getBrowserLocale = ()=>{
|
|
159
|
+
if (typeof navigator !== 'undefined') {
|
|
160
|
+
if (navigator.language) return navigator.language;
|
|
161
|
+
if (navigator.languages && navigator.languages.length > 0) {
|
|
162
|
+
const firstLanguage = navigator.languages[0];
|
|
163
|
+
if (firstLanguage) return firstLanguage;
|
|
164
|
+
}
|
|
165
|
+
// Legacy fallbacks for older browsers
|
|
166
|
+
const nav = navigator;
|
|
167
|
+
if (nav.userLanguage) return nav.userLanguage;
|
|
168
|
+
if (nav.browserLanguage) return nav.browserLanguage;
|
|
169
|
+
if (nav.systemLanguage) return nav.systemLanguage;
|
|
170
|
+
}
|
|
171
|
+
// Node.js or server-side fallback, or if navigator is not available/empty
|
|
172
|
+
return Intl.DateTimeFormat().resolvedOptions().locale || 'en-US';
|
|
173
|
+
};
|
|
174
|
+
export function formatDate(value, options = {}) {
|
|
175
|
+
const systemTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
176
|
+
const { unit = 'datetime-local', locale = getBrowserLocale(), timeZone = systemTimeZone, referenceTime = Date.now() } = options;
|
|
177
|
+
// Handle raw timestamp display
|
|
178
|
+
if (unit === 'unix-timestamp') {
|
|
179
|
+
// Ensure it's in seconds. If it looks like milliseconds, convert.
|
|
180
|
+
const timestamp = value > 1000000000000 ? Math.floor(value / 1000) : value;
|
|
181
|
+
return timestamp.toString();
|
|
182
|
+
}
|
|
183
|
+
if (unit === 'unix-timestamp-ms') {
|
|
184
|
+
// Ensure it's in milliseconds. If it looks like seconds, convert.
|
|
185
|
+
// Use 100 billion as threshold - values < 100B are likely seconds, >= 100B are likely milliseconds
|
|
186
|
+
// This distinguishes between 999999999 (seconds) and 999999999000 (milliseconds)
|
|
187
|
+
const MILLISECONDS_THRESHOLD = 100000000000; // 100 billion
|
|
188
|
+
const timestamp = value < MILLISECONDS_THRESHOLD ? value * 1000 : value;
|
|
189
|
+
return Math.floor(timestamp).toString();
|
|
190
|
+
}
|
|
191
|
+
const date = valueToDate(value);
|
|
192
|
+
// Handle relative time
|
|
193
|
+
if (unit === 'relative-time') {
|
|
194
|
+
return formatRelativeTime(date, referenceTime, locale);
|
|
195
|
+
}
|
|
196
|
+
// Configure Intl.DateTimeFormat options based on unit
|
|
197
|
+
const formatOptions = {
|
|
198
|
+
timeZone
|
|
199
|
+
};
|
|
200
|
+
switch(unit){
|
|
201
|
+
case 'datetime-iso':
|
|
202
|
+
// datetime-iso should ALWAYS show GMT/UTC time
|
|
203
|
+
return date.toISOString();
|
|
204
|
+
case 'datetime-us':
|
|
205
|
+
{
|
|
206
|
+
// datetime-us should ALWAYS show date in US Eastern timezone
|
|
207
|
+
formatOptions.timeZone = 'America/New_York';
|
|
208
|
+
formatOptions.year = 'numeric';
|
|
209
|
+
formatOptions.month = '2-digit';
|
|
210
|
+
formatOptions.day = '2-digit';
|
|
211
|
+
formatOptions.hour = '2-digit';
|
|
212
|
+
formatOptions.minute = '2-digit';
|
|
213
|
+
formatOptions.second = '2-digit';
|
|
214
|
+
formatOptions.hour12 = true; // 12-hour format with AM/PM
|
|
215
|
+
const formatter = new Intl.DateTimeFormat('en-US', formatOptions);
|
|
216
|
+
return formatter.format(date);
|
|
217
|
+
}
|
|
218
|
+
case 'datetime-local':
|
|
219
|
+
// datetime-local should use the browser's local timezone (detected automatically)
|
|
220
|
+
// Don't override timeZone - let it use the detected system timezone
|
|
221
|
+
formatOptions.year = 'numeric';
|
|
222
|
+
formatOptions.month = '2-digit';
|
|
223
|
+
formatOptions.day = '2-digit';
|
|
224
|
+
formatOptions.hour = '2-digit';
|
|
225
|
+
formatOptions.minute = '2-digit';
|
|
226
|
+
formatOptions.second = '2-digit';
|
|
227
|
+
formatOptions.hour12 = false; // 24-hour format
|
|
228
|
+
break;
|
|
229
|
+
case 'date-iso':
|
|
230
|
+
// date-iso should ALWAYS show GMT/UTC date
|
|
231
|
+
return date.toISOString().split('T')[0];
|
|
232
|
+
case 'date-us':
|
|
233
|
+
{
|
|
234
|
+
// date-us should ALWAYS show date in US Eastern timezone
|
|
235
|
+
formatOptions.timeZone = 'America/New_York';
|
|
236
|
+
formatOptions.year = 'numeric';
|
|
237
|
+
formatOptions.month = '2-digit';
|
|
238
|
+
formatOptions.day = '2-digit';
|
|
239
|
+
const formatter = new Intl.DateTimeFormat('en-US', formatOptions);
|
|
240
|
+
return formatter.format(date);
|
|
241
|
+
}
|
|
242
|
+
case 'date-local':
|
|
243
|
+
formatOptions.year = 'numeric';
|
|
244
|
+
formatOptions.month = '2-digit';
|
|
245
|
+
formatOptions.day = '2-digit';
|
|
246
|
+
break;
|
|
247
|
+
case 'time-local':
|
|
248
|
+
formatOptions.hour = '2-digit';
|
|
249
|
+
formatOptions.minute = '2-digit';
|
|
250
|
+
formatOptions.second = '2-digit';
|
|
251
|
+
formatOptions.hour12 = false; // 24-hour format
|
|
252
|
+
break;
|
|
253
|
+
case 'time-iso':
|
|
254
|
+
// time-iso should ALWAYS show GMT/UTC time
|
|
255
|
+
return date.toISOString().split('T')[1].replace('Z', '');
|
|
256
|
+
case 'time-us':
|
|
257
|
+
{
|
|
258
|
+
// time-us should show time in US-East timezone (Eastern Time)
|
|
259
|
+
formatOptions.timeZone = 'America/New_York';
|
|
260
|
+
formatOptions.hour = '2-digit';
|
|
261
|
+
formatOptions.minute = '2-digit';
|
|
262
|
+
formatOptions.second = '2-digit';
|
|
263
|
+
formatOptions.hour12 = true;
|
|
264
|
+
return new Intl.DateTimeFormat('en-US', formatOptions).format(date);
|
|
265
|
+
}
|
|
266
|
+
default:
|
|
267
|
+
{
|
|
268
|
+
// This ensures that all DateUnits are handled at compile time.
|
|
269
|
+
const exhaustive = unit;
|
|
270
|
+
throw new Error(`Unknown date unit: ${exhaustive}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// For all other units, use Intl.DateTimeFormat with the specified locale and options
|
|
274
|
+
const formatter = new Intl.DateTimeFormat(locale, formatOptions);
|
|
275
|
+
return formatter.format(date);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/date.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 { UnitGroupConfig, UnitConfig } from './types';\n\ntype DateUnits =\n | 'datetime-iso'\n | 'datetime-us'\n | 'datetime-local'\n | 'date-iso'\n | 'date-us'\n | 'date-local'\n | 'time-local'\n | 'time-iso'\n | 'time-us'\n | 'relative-time'\n | 'unix-timestamp'\n | 'unix-timestamp-ms';\n\nexport type DateFormatOptions = {\n unit?: DateUnits;\n /**\n * The locale to use for formatting. Defaults to the system's locale.\n */\n locale?: string;\n /**\n * The timezone to use for formatting. Defaults to the user's local timezone.\n */\n timeZone?: string;\n /**\n * For relative time formatting, the reference time to compare against.\n * Defaults to current time.\n */\n referenceTime?: number;\n /**\n * This property is not used for date formatting, but is included for\n * compatibility with the FormatControls UI component.\n */\n decimalPlaces?: number;\n};\n\nconst DATE_GROUP = 'Date';\n\nexport const DATE_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Date & Time',\n};\n\nexport const DATE_UNIT_CONFIG: Readonly<Record<DateUnits, UnitConfig>> = {\n 'datetime-iso': {\n group: DATE_GROUP,\n label: 'DateTime (GMT)',\n },\n 'datetime-us': {\n group: DATE_GROUP,\n label: 'DateTime (US-East)',\n },\n 'datetime-local': {\n group: DATE_GROUP,\n label: 'DateTime (Browser Local)',\n },\n 'date-iso': {\n group: DATE_GROUP,\n label: 'Date (GMT)',\n },\n 'date-us': {\n group: DATE_GROUP,\n label: 'Date (US-East)',\n },\n 'date-local': {\n group: DATE_GROUP,\n label: 'Date (Browser Local)',\n },\n 'time-local': {\n group: DATE_GROUP,\n label: 'Time (Browser Local)',\n },\n 'time-iso': {\n group: DATE_GROUP,\n label: 'Time (GMT)',\n },\n 'time-us': {\n group: DATE_GROUP,\n label: 'Time (US-East)',\n },\n 'relative-time': {\n group: DATE_GROUP,\n label: 'Relative Time',\n },\n 'unix-timestamp': {\n group: DATE_GROUP,\n label: 'Unix Timestamp (s)',\n },\n 'unix-timestamp-ms': {\n group: DATE_GROUP,\n label: 'Unix Timestamp (ms)',\n },\n};\n\n/**\n * Converts a numeric value to a Date object.\n * Handles both Unix timestamps (seconds) and millisecond timestamps.\n */\nfunction valueToDate(value: number): Date {\n // Timestamp detection logic with special case handling\n // Main threshold stays at 10 billion to maintain existing behavior\n // Handle special edge cases explicitly\n\n // Special case: negative timestamps\n if (value < 0) {\n // For negative values, check magnitude to distinguish seconds vs milliseconds\n // Large negative values (> 1 billion in magnitude) are likely milliseconds\n // Small negative values are likely seconds (rare edge case)\n if (Math.abs(value) > 10000000000) {\n return new Date(value); // milliseconds\n } else {\n return new Date(value * 1000); // seconds\n }\n }\n\n // Special case: year 9999 in seconds (~253402300799)\n // This is a very specific edge case for far-future timestamps\n if (value >= 250000000000 && value <= 260000000000) {\n // Check if this looks like year 9999 in seconds\n const asSeconds = new Date(value * 1000);\n const year = asSeconds.getUTCFullYear();\n if (year >= 9999) {\n return asSeconds; // seconds\n }\n }\n\n const SECONDS_THRESHOLD = 10000000000; // ~year 2286 - original threshold\n\n if (value < SECONDS_THRESHOLD) {\n // Assume it's in seconds\n return new Date(value * 1000);\n } else {\n // Assume it's in milliseconds\n return new Date(value);\n }\n}\n\n/**\n * Formats a relative time string using the Intl.RelativeTimeFormat API.\n */\nfunction formatRelativeTime(date: Date, referenceTime: number, locale: string): string {\n const referenceDate = new Date(referenceTime);\n const diffMs = date.getTime() - referenceDate.getTime();\n\n const units = [\n { unit: 'year', ms: 1000 * 60 * 60 * 24 * 365 },\n { unit: 'month', ms: 1000 * 60 * 60 * 24 * 30 },\n { unit: 'week', ms: 1000 * 60 * 60 * 24 * 7 },\n { unit: 'day', ms: 1000 * 60 * 60 * 24 },\n { unit: 'hour', ms: 1000 * 60 * 60 },\n { unit: 'minute', ms: 1000 * 60 },\n { unit: 'second', ms: 1000 },\n ] as const;\n\n for (const { unit, ms } of units) {\n // Determine the value for the current unit, ensuring it's an integer for Intl.RelativeTimeFormat\n const value = Math.round(diffMs / ms);\n // If the absolute value is 1 or more, use this unit\n if (Math.abs(value) >= 1) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n return rtf.format(value, unit);\n }\n }\n\n // If less than a second, show \"now\" or \"0 seconds\"\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n return rtf.format(0, 'second');\n}\n\n/**\n * Gets the browser's preferred locale with comprehensive fallbacks.\n */\nconst getBrowserLocale = (): string => {\n if (typeof navigator !== 'undefined') {\n if (navigator.language) return navigator.language;\n if (navigator.languages && navigator.languages.length > 0) {\n const firstLanguage = navigator.languages[0];\n if (firstLanguage) return firstLanguage;\n }\n // Legacy fallbacks for older browsers\n const nav = navigator as Navigator & {\n userLanguage?: string;\n browserLanguage?: string;\n systemLanguage?: string;\n };\n if (nav.userLanguage) return nav.userLanguage;\n if (nav.browserLanguage) return nav.browserLanguage;\n if (nav.systemLanguage) return nav.systemLanguage;\n }\n // Node.js or server-side fallback, or if navigator is not available/empty\n return Intl.DateTimeFormat().resolvedOptions().locale || 'en-US';\n};\n\nexport function formatDate(value: number, options: DateFormatOptions = {}): string {\n const systemTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n\n const {\n unit = 'datetime-local',\n locale = getBrowserLocale(),\n timeZone = systemTimeZone,\n referenceTime = Date.now(),\n } = options;\n\n // Handle raw timestamp display\n if (unit === 'unix-timestamp') {\n // Ensure it's in seconds. If it looks like milliseconds, convert.\n const timestamp = value > 1000000000000 ? Math.floor(value / 1000) : value;\n return timestamp.toString();\n }\n\n if (unit === 'unix-timestamp-ms') {\n // Ensure it's in milliseconds. If it looks like seconds, convert.\n // Use 100 billion as threshold - values < 100B are likely seconds, >= 100B are likely milliseconds\n // This distinguishes between 999999999 (seconds) and 999999999000 (milliseconds)\n const MILLISECONDS_THRESHOLD = 100000000000; // 100 billion\n const timestamp = value < MILLISECONDS_THRESHOLD ? value * 1000 : value;\n return Math.floor(timestamp).toString();\n }\n\n const date = valueToDate(value);\n\n // Handle relative time\n if (unit === 'relative-time') {\n return formatRelativeTime(date, referenceTime, locale);\n }\n\n // Configure Intl.DateTimeFormat options based on unit\n const formatOptions: Intl.DateTimeFormatOptions = {\n timeZone, // This will be overridden for specific units that need different timezones\n };\n\n switch (unit) {\n case 'datetime-iso':\n // datetime-iso should ALWAYS show GMT/UTC time\n return date.toISOString();\n\n case 'datetime-us': {\n // datetime-us should ALWAYS show date in US Eastern timezone\n formatOptions.timeZone = 'America/New_York';\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = true; // 12-hour format with AM/PM\n const formatter = new Intl.DateTimeFormat('en-US', formatOptions);\n return formatter.format(date);\n }\n\n case 'datetime-local':\n // datetime-local should use the browser's local timezone (detected automatically)\n // Don't override timeZone - let it use the detected system timezone\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = false; // 24-hour format\n break;\n\n case 'date-iso':\n // date-iso should ALWAYS show GMT/UTC date\n return date.toISOString().split('T')[0]!;\n\n case 'date-us': {\n // date-us should ALWAYS show date in US Eastern timezone\n formatOptions.timeZone = 'America/New_York';\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n const formatter = new Intl.DateTimeFormat('en-US', formatOptions);\n return formatter.format(date);\n }\n\n case 'date-local':\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n break;\n\n case 'time-local':\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = false; // 24-hour format\n break;\n\n case 'time-iso':\n // time-iso should ALWAYS show GMT/UTC time\n return date.toISOString().split('T')[1]!.replace('Z', '');\n\n case 'time-us': {\n // time-us should show time in US-East timezone (Eastern Time)\n formatOptions.timeZone = 'America/New_York';\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = true;\n return new Intl.DateTimeFormat('en-US', formatOptions).format(date);\n }\n\n default: {\n // This ensures that all DateUnits are handled at compile time.\n const exhaustive: never = unit;\n throw new Error(`Unknown date unit: ${exhaustive}`);\n }\n }\n\n // For all other units, use Intl.DateTimeFormat with the specified locale and options\n const formatter = new Intl.DateTimeFormat(locale, formatOptions);\n return formatter.format(date);\n}\n"],"names":["DATE_GROUP","DATE_GROUP_CONFIG","label","DATE_UNIT_CONFIG","group","valueToDate","value","Math","abs","Date","asSeconds","year","getUTCFullYear","SECONDS_THRESHOLD","formatRelativeTime","date","referenceTime","locale","referenceDate","diffMs","getTime","units","unit","ms","round","rtf","Intl","RelativeTimeFormat","numeric","format","getBrowserLocale","navigator","language","languages","length","firstLanguage","nav","userLanguage","browserLanguage","systemLanguage","DateTimeFormat","resolvedOptions","formatDate","options","systemTimeZone","timeZone","now","timestamp","floor","toString","MILLISECONDS_THRESHOLD","formatOptions","toISOString","month","day","hour","minute","second","hour12","formatter","split","replace","exhaustive","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAwCjC,MAAMA,aAAa;AAEnB,OAAO,MAAMC,oBAAqC;IAChDC,OAAO;AACT,EAAE;AAEF,OAAO,MAAMC,mBAA4D;IACvE,gBAAgB;QACdC,OAAOJ;QACPE,OAAO;IACT;IACA,eAAe;QACbE,OAAOJ;QACPE,OAAO;IACT;IACA,kBAAkB;QAChBE,OAAOJ;QACPE,OAAO;IACT;IACA,YAAY;QACVE,OAAOJ;QACPE,OAAO;IACT;IACA,WAAW;Q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AG;gBACrBJ,cAAcK,MAAM,GAAG;gBACvBL,cAAcM,MAAM,GAAG;gBACvBN,cAAcO,MAAM,GAAG;gBACvB,OAAO,IAAIhC,KAAKc,cAAc,CAAC,SAASW,eAAetB,MAAM,CAACd;YAChE;QAEA;YAAS;gBACP,+DAA+D;gBAC/D,MAAM+C,aAAoBxC;gBAC1B,MAAM,IAAIyC,MAAM,CAAC,mBAAmB,EAAED,YAAY;YACpD;IACF;IAEA,qFAAqF;IACrF,MAAMH,YAAY,IAAIjC,KAAKc,cAAc,CAACvB,QAAQkC;IAClD,OAAOQ,UAAU9B,MAAM,CAACd;AAC1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UnitConfig, UnitGroupConfig } from './types';
|
|
2
|
+
type TemperatureUnits = 'celsius' | 'fahrenheit';
|
|
3
|
+
export type TemperatureFormatOptions = {
|
|
4
|
+
unit: TemperatureUnits;
|
|
5
|
+
decimalPlaces?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const TEMPERATURE_GROUP_CONFIG: UnitGroupConfig;
|
|
8
|
+
export declare const TEMPERATURE_UNIT_CONFIG: Readonly<Record<TemperatureUnits, UnitConfig>>;
|
|
9
|
+
export declare const formatTemperature: (value: number, { unit, decimalPlaces }: TemperatureFormatOptions) => string;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=temperature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temperature.d.ts","sourceRoot":"","sources":["../../../src/model/units/temperature.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAKtD,KAAK,gBAAgB,GAAG,SAAS,GAAG,YAAY,CAAC;AAEjD,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,gBAAgB,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,eAGtC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,UAAU,CAAC,CASlF,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAAW,MAAM,2BAA2B,wBAAwB,KAAG,MAepG,CAAC"}
|