@perses-dev/core 0.53.1 → 0.54.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 (104) hide show
  1. package/dist/cjs/constants/dashboard-defaults.js +3 -3
  2. package/dist/cjs/model/calculations.js +6 -6
  3. package/dist/cjs/model/definitions.js +1 -3
  4. package/dist/cjs/model/folder.js +16 -0
  5. package/dist/cjs/model/index.js +1 -0
  6. package/dist/cjs/model/legend.js +11 -11
  7. package/dist/cjs/model/otlp/index.js +4 -4
  8. package/dist/cjs/model/otlp/trace/v1/trace.js +4 -4
  9. package/dist/cjs/model/resource.js +3 -3
  10. package/dist/cjs/model/roles.js +4 -4
  11. package/dist/cjs/model/time.js +21 -309
  12. package/dist/cjs/model/units/bits.js +4 -4
  13. package/dist/cjs/model/units/bytes.js +4 -4
  14. package/dist/cjs/model/units/currency.js +4 -4
  15. package/dist/cjs/model/units/date.js +4 -4
  16. package/dist/cjs/model/units/decimal.js +4 -4
  17. package/dist/cjs/model/units/formatterCache.js +3 -3
  18. package/dist/cjs/model/units/percent.js +4 -4
  19. package/dist/cjs/model/units/temperature.js +4 -4
  20. package/dist/cjs/model/units/throughput.js +4 -4
  21. package/dist/cjs/model/units/time.js +5 -5
  22. package/dist/cjs/model/units/units.js +18 -18
  23. package/dist/cjs/model/units/utils.js +4 -4
  24. package/dist/cjs/model/variables.js +3 -3
  25. package/dist/cjs/schema/datasource.js +13 -29
  26. package/dist/cjs/schema/display.js +2 -6
  27. package/dist/cjs/schema/duration.js +2 -4
  28. package/dist/cjs/schema/metadata.js +4 -4
  29. package/dist/cjs/schema/panel.js +20 -73
  30. package/dist/cjs/schema/plugin.js +2 -6
  31. package/dist/cjs/schema/role.js +6 -6
  32. package/dist/cjs/schema/rolebinding.js +6 -6
  33. package/dist/cjs/schema/secret.js +5 -5
  34. package/dist/cjs/schema/user.js +5 -5
  35. package/dist/cjs/schema/variable.js +24 -137
  36. package/dist/cjs/utils/fetch.js +5 -5
  37. package/dist/cjs/utils/panel-refs.js +4 -4
  38. package/dist/cjs/utils/regexp.js +3 -3
  39. package/dist/cjs/utils/text.js +7 -7
  40. package/dist/cjs/utils/time-series-data.js +4 -4
  41. package/dist/cjs/utils/transform-data.js +6 -6
  42. package/dist/model/dashboard.d.ts +2 -21
  43. package/dist/model/dashboard.d.ts.map +1 -1
  44. package/dist/model/dashboard.js.map +1 -1
  45. package/dist/model/datasource.d.ts +3 -22
  46. package/dist/model/datasource.d.ts.map +1 -1
  47. package/dist/model/datasource.js +1 -3
  48. package/dist/model/datasource.js.map +1 -1
  49. package/dist/model/definitions.d.ts +1 -12
  50. package/dist/model/definitions.d.ts.map +1 -1
  51. package/dist/model/definitions.js +1 -6
  52. package/dist/model/definitions.js.map +1 -1
  53. package/dist/model/display.d.ts +1 -4
  54. package/dist/model/display.d.ts.map +1 -1
  55. package/dist/model/display.js.map +1 -1
  56. package/dist/model/folder.d.ts +19 -0
  57. package/dist/model/folder.d.ts.map +1 -0
  58. package/dist/model/folder.js +15 -0
  59. package/dist/model/folder.js.map +1 -0
  60. package/dist/model/index.d.ts +1 -0
  61. package/dist/model/index.d.ts.map +1 -1
  62. package/dist/model/index.js +1 -0
  63. package/dist/model/index.js.map +1 -1
  64. package/dist/model/project.d.ts +1 -1
  65. package/dist/model/project.d.ts.map +1 -1
  66. package/dist/model/project.js.map +1 -1
  67. package/dist/model/resource.d.ts +1 -1
  68. package/dist/model/resource.d.ts.map +1 -1
  69. package/dist/model/resource.js.map +1 -1
  70. package/dist/model/time.d.ts +3 -54
  71. package/dist/model/time.d.ts.map +1 -1
  72. package/dist/model/time.js +2 -299
  73. package/dist/model/time.js.map +1 -1
  74. package/dist/schema/datasource.d.ts +10 -9
  75. package/dist/schema/datasource.d.ts.map +1 -1
  76. package/dist/schema/datasource.js +2 -14
  77. package/dist/schema/datasource.js.map +1 -1
  78. package/dist/schema/display.d.ts +1 -11
  79. package/dist/schema/display.d.ts.map +1 -1
  80. package/dist/schema/display.js +1 -5
  81. package/dist/schema/display.js.map +1 -1
  82. package/dist/schema/duration.d.ts +1 -2
  83. package/dist/schema/duration.d.ts.map +1 -1
  84. package/dist/schema/duration.js +1 -3
  85. package/dist/schema/duration.js.map +1 -1
  86. package/dist/schema/panel.d.ts +1 -12
  87. package/dist/schema/panel.d.ts.map +1 -1
  88. package/dist/schema/panel.js +1 -54
  89. package/dist/schema/panel.js.map +1 -1
  90. package/dist/schema/plugin.d.ts +2 -13
  91. package/dist/schema/plugin.d.ts.map +1 -1
  92. package/dist/schema/plugin.js +1 -5
  93. package/dist/schema/plugin.js.map +1 -1
  94. package/dist/schema/role.d.ts +4 -4
  95. package/dist/schema/rolebinding.d.ts +4 -4
  96. package/dist/schema/secret.d.ts +70 -70
  97. package/dist/schema/variable.d.ts +1 -91
  98. package/dist/schema/variable.d.ts.map +1 -1
  99. package/dist/schema/variable.js +1 -105
  100. package/dist/schema/variable.js.map +1 -1
  101. package/dist/utils/fetch.js.map +1 -1
  102. package/dist/utils/text.js +4 -4
  103. package/dist/utils/text.js.map +1 -1
  104. package/package.json +3 -2
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/model/project.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/model/project.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/project.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Metadata } from './resource';\nimport { Display } from './display';\n\nexport interface ProjectResource {\n kind: 'Project';\n metadata: Metadata;\n spec: ProjectSpec;\n}\n\nexport interface ProjectSpec {\n display?: Display;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAWjC,WAEC"}
1
+ {"version":3,"sources":["../../src/model/project.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Metadata } from './resource';\nimport { Display } from './display';\n\nexport interface ProjectResource {\n kind: 'Project';\n metadata: Metadata;\n spec?: ProjectSpec;\n}\n\nexport interface ProjectSpec {\n display?: Display;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAWjC,WAEC"}
@@ -13,7 +13,7 @@ export interface ProjectMetadata extends Metadata {
13
13
  export interface Resource {
14
14
  kind: Kind;
15
15
  metadata: Metadata | ProjectMetadata;
16
- spec: any;
16
+ spec?: any;
17
17
  }
18
18
  export declare function getMetadataProject(metadata: ProjectMetadata | Metadata): string | undefined;
19
19
  //# sourceMappingURL=resource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/model/resource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,eAAe,GAAG,QAAQ,IAAI,eAAe,CAEnG;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,QAAQ,GAAG,eAAe,CAAC;IAErC,IAAI,EAAE,GAAG,CAAC;CACX;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAE3F"}
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/model/resource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,eAAe,GAAG,QAAQ,IAAI,eAAe,CAEnG;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,QAAQ,GAAG,eAAe,CAAC;IAErC,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAE3F"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/resource.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Kind } from './kind';\n\nexport function isProjectMetadata(metadata: Metadata | ProjectMetadata): metadata is ProjectMetadata {\n return 'project' in metadata;\n}\n\nexport interface Metadata {\n name: string;\n createdAt?: string;\n updatedAt?: string;\n version?: number;\n tags?: string[];\n}\n\nexport interface ProjectMetadata extends Metadata {\n project: string;\n}\n\nexport interface Resource {\n kind: Kind;\n metadata: Metadata | ProjectMetadata;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n spec: any;\n}\n\nexport function getMetadataProject(metadata: ProjectMetadata | Metadata): string | undefined {\n return 'project' in metadata ? metadata.project : undefined;\n}\n"],"names":["isProjectMetadata","metadata","getMetadataProject","project","undefined"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,SAASA,kBAAkBC,QAAoC;IACpE,OAAO,aAAaA;AACtB;AAqBA,OAAO,SAASC,mBAAmBD,QAAoC;IACrE,OAAO,aAAaA,WAAWA,SAASE,OAAO,GAAGC;AACpD"}
1
+ {"version":3,"sources":["../../src/model/resource.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Kind } from './kind';\n\nexport function isProjectMetadata(metadata: Metadata | ProjectMetadata): metadata is ProjectMetadata {\n return 'project' in metadata;\n}\n\nexport interface Metadata {\n name: string;\n createdAt?: string;\n updatedAt?: string;\n version?: number;\n tags?: string[];\n}\n\nexport interface ProjectMetadata extends Metadata {\n project: string;\n}\n\nexport interface Resource {\n kind: Kind;\n metadata: Metadata | ProjectMetadata;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n spec?: any;\n}\n\nexport function getMetadataProject(metadata: ProjectMetadata | Metadata): string | undefined {\n return 'project' in metadata ? metadata.project : undefined;\n}\n"],"names":["isProjectMetadata","metadata","getMetadataProject","project","undefined"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,SAASA,kBAAkBC,QAAoC;IACpE,OAAO,aAAaA;AACtB;AAqBA,OAAO,SAASC,mBAAmBD,QAAoC;IACrE,OAAO,aAAaA,WAAWA,SAASE,OAAO,GAAGC;AACpD"}
@@ -1,55 +1,4 @@
1
- import { Duration } from 'date-fns';
2
- export type UnixTimeMs = number;
3
- export type DateTimeFormat = number | string;
4
- export interface AbsoluteTimeRange {
5
- start: Date;
6
- end: Date;
7
- }
8
- export interface RelativeTimeRange {
9
- end?: Date;
10
- pastDuration: DurationString;
11
- }
12
- export type TimeRangeValue = AbsoluteTimeRange | RelativeTimeRange;
13
- /**
14
- * Determine whether a given time range is relative
15
- */
16
- export declare function isRelativeTimeRange(timeRange: TimeRangeValue): timeRange is RelativeTimeRange;
17
- /**
18
- * Determine whether a given time range is absolute
19
- */
20
- export declare function isAbsoluteTimeRange(timeRange: TimeRangeValue): timeRange is AbsoluteTimeRange;
21
- /**
22
- * Returns an absolute time range from a RelativeTimeRange.
23
- */
24
- export declare function toAbsoluteTimeRange(timeRange: RelativeTimeRange): AbsoluteTimeRange;
25
- type MillisecondsDurationString = `${number}ms`;
26
- type SecondsDurationString = `${number}s`;
27
- type MinutesDurationString = `${number}m`;
28
- type HoursDurationString = `${number}h`;
29
- type DaysDurationString = `${number}d`;
30
- type WeeksDurationString = `${number}w`;
31
- type YearsDurationString = `${number}y`;
32
- export type DurationString = Exclude<`${YearsDurationString | ''}${WeeksDurationString | ''}${DaysDurationString | ''}${HoursDurationString | ''}${MinutesDurationString | ''}${SecondsDurationString | ''}${MillisecondsDurationString | ''}`, ''>;
33
- export declare const DURATION_REGEX: RegExp;
34
- /**
35
- * Parses a DurationString into a Duration object with numeric values that can
36
- * be used to do Date math. Throws if not a valid duration string.
37
- */
38
- export declare function parseDurationString(durationString: string): Duration;
39
- /**
40
- * Returns true if the given string is a valid DurationString.
41
- */
42
- export declare function isDurationString(maybeDuration: string): maybeDuration is DurationString;
43
- export declare function intervalToPrometheusDuration(timeRange: AbsoluteTimeRange): Duration;
44
- export declare function msToPrometheusDuration(durationInMs: number): Duration;
45
- export declare function formatDuration(duration: Duration): DurationString;
46
- /**
47
- * Round interval to clearer increments
48
- */
49
- export declare function roundStepInterval(stepMs: number): number;
50
- /**
51
- * Gets a suggested step/interval size for a time range based on the width of a visual component.
52
- */
53
- export declare function getSuggestedStepMs(timeRange: AbsoluteTimeRange, width: number): number;
54
- export {};
1
+ export { intervalToDuration as intervalToPrometheusDuration, //It has been renamed in spec
2
+ formatDuration, parseDurationString, isRelativeTimeRange, isAbsoluteTimeRange, toAbsoluteTimeRange, roundStepInterval, getSuggestedStepMs, DURATION_REGEX, } from '@perses-dev/spec';
3
+ export type { UnixTimeMs, DateTimeFormat, AbsoluteTimeRange, RelativeTimeRange, TimeRangeValue, DurationString, } from '@perses-dev/spec';
55
4
  //# sourceMappingURL=time.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/model/time.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAO,MAAM,UAAU,CAAC;AASzC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACX;AAED,MAAM,WAAW,iBAAiB;IAEhC,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,cAAc,CAAC;CAC9B;AAED,MAAM,MAAM,cAA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AAM,GAAG,QAAQ,CAqBrE;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,CA4BjE;AAiED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAOxD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAItF"}
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/model/time.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,kBAAkB,IAAI,4BAA4B,EAAE,6BAA6B;AACjF,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EACV,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,cAAc,GACf,MAAM,kBAAkB,CAAC"}
@@ -10,304 +10,7 @@
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 { sub } from 'date-fns';
14
- const ONE_SECOND_IN_MS = 1000;
15
- const ONE_MINUTE_IN_MS = 60000;
16
- const ONE_HOUR_IN_MS = 3600000;
17
- const ONE_DAY_IN_MS = 86400000; // assuming a day has always 24h
18
- const ONE_WEEK_IN_MS = 604800000; // assuming a week has always 7d
19
- const ONE_YEAR_IN_MS = 31536000000; // assuming a year has always 365d
20
- /**
21
- * Determine whether a given time range is relative
22
- */ export function isRelativeTimeRange(timeRange) {
23
- return timeRange.pastDuration !== undefined;
24
- }
25
- /**
26
- * Determine whether a given time range is absolute
27
- */ export function isAbsoluteTimeRange(timeRange) {
28
- return timeRange.start !== undefined && timeRange.end !== undefined;
29
- }
30
- /**
31
- * Returns an absolute time range from a RelativeTimeRange.
32
- */ export function toAbsoluteTimeRange(timeRange) {
33
- const end = timeRange.end ?? new Date();
34
- return {
35
- start: sub(end, parseDurationString(timeRange.pastDuration)),
36
- end
37
- };
38
- }
39
- export const DURATION_REGEX = /^(?:(\d+)y)?(?:(\d+)w)?(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?(?:(\d+)ms)?$/;
40
- /**
41
- * Parses a DurationString into a Duration object with numeric values that can
42
- * be used to do Date math. Throws if not a valid duration string.
43
- */ export function parseDurationString(durationString) {
44
- const matches = DURATION_REGEX.exec(durationString);
45
- if (matches === null) {
46
- throw new Error(`Invalid duration string '${durationString}'`);
47
- }
48
- return {
49
- years: parseInt(matches[1] ?? '0'),
50
- months: 0,
51
- weeks: parseInt(matches[2] ?? '0'),
52
- days: parseInt(matches[3] ?? '0'),
53
- hours: parseInt(matches[4] ?? '0'),
54
- minutes: parseInt(matches[5] ?? '0'),
55
- seconds: parseInt(matches[6] ?? '0') + parseInt(matches[7] ?? '0') / 1000
56
- };
57
- }
58
- /**
59
- * Returns true if the given string is a valid DurationString.
60
- */ export function isDurationString(maybeDuration) {
61
- if (maybeDuration === '') return false;
62
- return DURATION_REGEX.test(maybeDuration);
63
- }
64
- export function intervalToPrometheusDuration(timeRange) {
65
- const durationInMs = timeRange.end.valueOf() - timeRange.start.valueOf();
66
- return msToPrometheusDuration(durationInMs);
67
- }
68
- export function msToPrometheusDuration(durationInMs) {
69
- const years = Math.trunc(durationInMs / ONE_YEAR_IN_MS);
70
- if (years > 0) durationInMs -= years * ONE_YEAR_IN_MS;
71
- const weeks = Math.trunc(durationInMs / ONE_WEEK_IN_MS);
72
- if (weeks > 0) durationInMs -= weeks * ONE_WEEK_IN_MS;
73
- const days = Math.trunc(durationInMs / ONE_DAY_IN_MS);
74
- if (days > 0) durationInMs -= days * ONE_DAY_IN_MS;
75
- const hours = Math.trunc(durationInMs / ONE_HOUR_IN_MS);
76
- if (hours > 0) durationInMs -= hours * ONE_HOUR_IN_MS;
77
- const minutes = Math.trunc(durationInMs / ONE_MINUTE_IN_MS);
78
- if (minutes > 0) durationInMs -= minutes * ONE_MINUTE_IN_MS;
79
- return {
80
- years: years,
81
- months: 0,
82
- weeks: weeks,
83
- days: days,
84
- hours: hours,
85
- minutes: minutes,
86
- seconds: durationInMs / 1000
87
- };
88
- }
89
- export function formatDuration(duration) {
90
- const result = [];
91
- if (duration.years) {
92
- result.push(`${duration.years}y`);
93
- }
94
- if (duration.weeks) {
95
- result.push(`${duration.weeks}w`);
96
- }
97
- if (duration.days) {
98
- result.push(`${duration.days}d`);
99
- }
100
- if (duration.hours) {
101
- result.push(`${duration.hours}h`);
102
- }
103
- if (duration.minutes) {
104
- result.push(`${duration.minutes}m`);
105
- }
106
- if (duration.seconds) {
107
- const seconds = Math.trunc(duration.seconds);
108
- if (seconds) {
109
- result.push(`${seconds}s`);
110
- }
111
- const ms = Math.round((duration.seconds - seconds) * 1000);
112
- if (ms) {
113
- result.push(`${ms}ms`);
114
- }
115
- }
116
- return result.join('');
117
- }
118
- const DEFAULT_STEP_MS = 15000;
119
- const ROUNDED_STEP_INTERVALS = [
120
- // max: 0.015s
121
- {
122
- maxMs: 15,
123
- roundedStepMs: 10,
124
- display: '0.01s'
125
- },
126
- // max: 0.035s
127
- {
128
- maxMs: 35,
129
- roundedStepMs: 20,
130
- display: '0.02s'
131
- },
132
- // max: 0.075s
133
- {
134
- maxMs: 75,
135
- roundedStepMs: 50,
136
- display: '0.05s'
137
- },
138
- // max: 0.15s
139
- {
140
- maxMs: 150,
141
- roundedStepMs: 100,
142
- display: '0.1s'
143
- },
144
- // max: 0.35s
145
- {
146
- maxMs: 350,
147
- roundedStepMs: 200,
148
- display: '0.2s'
149
- },
150
- // max: 0.75s
151
- {
152
- maxMs: 750,
153
- roundedStepMs: 500,
154
- display: '0.5s'
155
- },
156
- // max: 1.5s
157
- {
158
- maxMs: ONE_SECOND_IN_MS * 1.5,
159
- roundedStepMs: ONE_SECOND_IN_MS,
160
- display: '1s'
161
- },
162
- // max: 3.5s
163
- {
164
- maxMs: ONE_SECOND_IN_MS * 3.5,
165
- roundedStepMs: ONE_SECOND_IN_MS * 2,
166
- display: '2s'
167
- },
168
- // max: 7.5s
169
- {
170
- maxMs: ONE_SECOND_IN_MS * 7.5,
171
- roundedStepMs: ONE_SECOND_IN_MS * 5,
172
- display: '5s'
173
- },
174
- // max: 12.5s
175
- {
176
- maxMs: ONE_SECOND_IN_MS * 12.5,
177
- roundedStepMs: ONE_SECOND_IN_MS * 10,
178
- display: '10s'
179
- },
180
- // max: 17.5s
181
- {
182
- maxMs: ONE_SECOND_IN_MS * 17.5,
183
- roundedStepMs: ONE_SECOND_IN_MS * 15,
184
- display: '15s'
185
- },
186
- // max: 25s
187
- {
188
- maxMs: ONE_SECOND_IN_MS * 25,
189
- roundedStepMs: ONE_SECOND_IN_MS * 20,
190
- display: '20s'
191
- },
192
- // max: 45s
193
- {
194
- maxMs: ONE_SECOND_IN_MS * 45,
195
- roundedStepMs: ONE_SECOND_IN_MS * 30,
196
- display: '30s'
197
- },
198
- // max: 1.5m
199
- {
200
- maxMs: ONE_MINUTE_IN_MS * 1.5,
201
- roundedStepMs: ONE_MINUTE_IN_MS,
202
- display: '1m'
203
- },
204
- // max: 3.5m
205
- {
206
- maxMs: ONE_MINUTE_IN_MS * 3.5,
207
- roundedStepMs: ONE_MINUTE_IN_MS * 2,
208
- display: '2m'
209
- },
210
- // max: 7.5m
211
- {
212
- maxMs: ONE_MINUTE_IN_MS * 7.5,
213
- roundedStepMs: ONE_MINUTE_IN_MS * 5,
214
- display: '5m'
215
- },
216
- // max: 12.5m
217
- {
218
- maxMs: ONE_MINUTE_IN_MS * 12.5,
219
- roundedStepMs: ONE_MINUTE_IN_MS * 10,
220
- display: '10m'
221
- },
222
- // max: 12.5m
223
- {
224
- maxMs: ONE_MINUTE_IN_MS * 12.5,
225
- roundedStepMs: ONE_MINUTE_IN_MS * 15,
226
- display: '15m'
227
- },
228
- // max: 25m
229
- {
230
- maxMs: ONE_MINUTE_IN_MS * 25,
231
- roundedStepMs: ONE_MINUTE_IN_MS * 20,
232
- display: '20m'
233
- },
234
- // max: 45m
235
- {
236
- maxMs: ONE_MINUTE_IN_MS * 45,
237
- roundedStepMs: ONE_MINUTE_IN_MS * 30,
238
- display: '30m'
239
- },
240
- // max: 1.5h
241
- {
242
- maxMs: ONE_HOUR_IN_MS * 1.5,
243
- roundedStepMs: ONE_HOUR_IN_MS,
244
- display: '1h'
245
- },
246
- // max: 2.5h
247
- {
248
- maxMs: ONE_HOUR_IN_MS * 2.5,
249
- roundedStepMs: ONE_HOUR_IN_MS * 2,
250
- display: '2h'
251
- },
252
- // max: 4.5h
253
- {
254
- maxMs: ONE_HOUR_IN_MS * 4.5,
255
- roundedStepMs: ONE_HOUR_IN_MS * 3,
256
- display: '3h'
257
- },
258
- // max: 9h
259
- {
260
- maxMs: ONE_HOUR_IN_MS * 9,
261
- roundedStepMs: ONE_HOUR_IN_MS * 6,
262
- display: '6h'
263
- },
264
- // max: 1d
265
- {
266
- maxMs: ONE_DAY_IN_MS,
267
- roundedStepMs: ONE_HOUR_IN_MS * 12,
268
- display: '12h'
269
- },
270
- // max: 1w
271
- {
272
- maxMs: ONE_WEEK_IN_MS,
273
- roundedStepMs: ONE_DAY_IN_MS,
274
- display: '1d'
275
- },
276
- // max: 3w
277
- {
278
- maxMs: ONE_WEEK_IN_MS * 3,
279
- roundedStepMs: ONE_WEEK_IN_MS,
280
- display: '1w'
281
- },
282
- // max: 6w
283
- {
284
- maxMs: ONE_WEEK_IN_MS * 6,
285
- roundedStepMs: ONE_DAY_IN_MS * 30,
286
- display: '30d'
287
- },
288
- // max: 2y
289
- {
290
- maxMs: ONE_YEAR_IN_MS * 2,
291
- roundedStepMs: ONE_YEAR_IN_MS,
292
- display: '1y'
293
- }
294
- ];
295
- /**
296
- * Round interval to clearer increments
297
- */ export function roundStepInterval(stepMs) {
298
- for (const { maxMs, roundedStepMs } of ROUNDED_STEP_INTERVALS){
299
- if (stepMs < maxMs) {
300
- return roundedStepMs;
301
- }
302
- }
303
- return DEFAULT_STEP_MS;
304
- }
305
- /**
306
- * Gets a suggested step/interval size for a time range based on the width of a visual component.
307
- */ export function getSuggestedStepMs(timeRange, width) {
308
- const queryRangeMs = timeRange.end.valueOf() - timeRange.start.valueOf();
309
- const stepMs = Math.floor(queryRangeMs / width);
310
- return roundStepInterval(stepMs);
311
- }
13
+ // 1. Runtime code like functions and consts
14
+ export { intervalToDuration as intervalToPrometheusDuration, formatDuration, parseDurationString, isRelativeTimeRange, isAbsoluteTimeRange, toAbsoluteTimeRange, roundStepInterval, getSuggestedStepMs, DURATION_REGEX } from '@perses-dev/spec';
312
15
 
313
16
  //# sourceMappingURL=time.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/time.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Duration, sub } from 'date-fns';\n\nconst ONE_SECOND_IN_MS = 1000;\nconst ONE_MINUTE_IN_MS = 60000;\nconst ONE_HOUR_IN_MS = 3600000;\nconst ONE_DAY_IN_MS = 86400000; // assuming a day has always 24h\nconst ONE_WEEK_IN_MS = 604800000; // assuming a week has always 7d\nconst ONE_YEAR_IN_MS = 31536000000; // assuming a year has always 365d\n\nexport type UnixTimeMs = number;\n\nexport type DateTimeFormat = number | string;\n\nexport interface AbsoluteTimeRange {\n start: Date;\n end: Date;\n}\n\nexport interface RelativeTimeRange {\n // End date or undefined if relative to the current Date\n end?: Date;\n pastDuration: DurationString;\n}\n\nexport type TimeRangeValue = AbsoluteTimeRange | RelativeTimeRange;\n\n/**\n * Determine whether a given time range is relative\n */\nexport function isRelativeTimeRange(timeRange: TimeRangeValue): timeRange is RelativeTimeRange {\n return (timeRange as RelativeTimeRange).pastDuration !== undefined;\n}\n\n/**\n * Determine whether a given time range is absolute\n */\nexport function isAbsoluteTimeRange(timeRange: TimeRangeValue): timeRange is AbsoluteTimeRange {\n return (timeRange as AbsoluteTimeRange).start !== undefined && (timeRange as AbsoluteTimeRange).end !== undefined;\n}\n\n/**\n * Returns an absolute time range from a RelativeTimeRange.\n */\nexport function toAbsoluteTimeRange(timeRange: RelativeTimeRange): AbsoluteTimeRange {\n const end = timeRange.end ?? new Date();\n\n return {\n start: sub(end, parseDurationString(timeRange.pastDuration)),\n end,\n };\n}\n\ntype MillisecondsDurationString = `${number}ms`;\ntype SecondsDurationString = `${number}s`;\ntype MinutesDurationString = `${number}m`;\ntype HoursDurationString = `${number}h`;\ntype DaysDurationString = `${number}d`;\ntype WeeksDurationString = `${number}w`;\ntype YearsDurationString = `${number}y`;\n\nexport type DurationString = Exclude<\n `${YearsDurationString | ''}${WeeksDurationString | ''}${DaysDurationString | ''}${HoursDurationString | ''}${\n | MinutesDurationString\n | ''}${SecondsDurationString | ''}${MillisecondsDurationString | ''}`,\n ''\n>;\n\nexport const DURATION_REGEX = /^(?:(\\d+)y)?(?:(\\d+)w)?(?:(\\d+)d)?(?:(\\d+)h)?(?:(\\d+)m)?(?:(\\d+)s)?(?:(\\d+)ms)?$/;\n\n/**\n * Parses a DurationString into a Duration object with numeric values that can\n * be used to do Date math. Throws if not a valid duration string.\n */\nexport function parseDurationString(durationString: string): Duration {\n const matches = DURATION_REGEX.exec(durationString);\n if (matches === null) {\n throw new Error(`Invalid duration string '${durationString}'`);\n }\n\n return {\n years: parseInt(matches[1] ?? '0'),\n months: 0,\n weeks: parseInt(matches[2] ?? '0'),\n days: parseInt(matches[3] ?? '0'),\n hours: parseInt(matches[4] ?? '0'),\n minutes: parseInt(matches[5] ?? '0'),\n seconds: parseInt(matches[6] ?? '0') + parseInt(matches[7] ?? '0') / 1000,\n };\n}\n\n/**\n * Returns true if the given string is a valid DurationString.\n */\nexport function isDurationString(maybeDuration: string): maybeDuration is DurationString {\n if (maybeDuration === '') return false;\n return DURATION_REGEX.test(maybeDuration);\n}\n\nexport function intervalToPrometheusDuration(timeRange: AbsoluteTimeRange): Duration {\n const durationInMs = timeRange.end.valueOf() - timeRange.start.valueOf();\n return msToPrometheusDuration(durationInMs);\n}\n\nexport function msToPrometheusDuration(durationInMs: number): Duration {\n const years = Math.trunc(durationInMs / ONE_YEAR_IN_MS);\n if (years > 0) durationInMs -= years * ONE_YEAR_IN_MS;\n const weeks = Math.trunc(durationInMs / ONE_WEEK_IN_MS);\n if (weeks > 0) durationInMs -= weeks * ONE_WEEK_IN_MS;\n const days = Math.trunc(durationInMs / ONE_DAY_IN_MS);\n if (days > 0) durationInMs -= days * ONE_DAY_IN_MS;\n const hours = Math.trunc(durationInMs / ONE_HOUR_IN_MS);\n if (hours > 0) durationInMs -= hours * ONE_HOUR_IN_MS;\n const minutes = Math.trunc(durationInMs / ONE_MINUTE_IN_MS);\n if (minutes > 0) durationInMs -= minutes * ONE_MINUTE_IN_MS;\n\n return {\n years: years,\n months: 0,\n weeks: weeks,\n days: days,\n hours: hours,\n minutes: minutes,\n seconds: durationInMs / 1000,\n };\n}\n\nexport function formatDuration(duration: Duration): DurationString {\n const result: string[] = [];\n if (duration.years) {\n result.push(`${duration.years}y`);\n }\n if (duration.weeks) {\n result.push(`${duration.weeks}w`);\n }\n if (duration.days) {\n result.push(`${duration.days}d`);\n }\n if (duration.hours) {\n result.push(`${duration.hours}h`);\n }\n if (duration.minutes) {\n result.push(`${duration.minutes}m`);\n }\n if (duration.seconds) {\n const seconds = Math.trunc(duration.seconds);\n if (seconds) {\n result.push(`${seconds}s`);\n }\n const ms = Math.round((duration.seconds - seconds) * 1000);\n if (ms) {\n result.push(`${ms}ms`);\n }\n }\n return result.join('') as DurationString;\n}\n\nconst DEFAULT_STEP_MS = 15000;\n\nconst ROUNDED_STEP_INTERVALS = [\n // max: 0.015s\n { maxMs: 15, roundedStepMs: 10, display: '0.01s' },\n // max: 0.035s\n { maxMs: 35, roundedStepMs: 20, display: '0.02s' },\n // max: 0.075s\n { maxMs: 75, roundedStepMs: 50, display: '0.05s' },\n // max: 0.15s\n { maxMs: 150, roundedStepMs: 100, display: '0.1s' },\n // max: 0.35s\n { maxMs: 350, roundedStepMs: 200, display: '0.2s' },\n // max: 0.75s\n { maxMs: 750, roundedStepMs: 500, display: '0.5s' },\n // max: 1.5s\n { maxMs: ONE_SECOND_IN_MS * 1.5, roundedStepMs: ONE_SECOND_IN_MS, display: '1s' },\n // max: 3.5s\n { maxMs: ONE_SECOND_IN_MS * 3.5, roundedStepMs: ONE_SECOND_IN_MS * 2, display: '2s' },\n // max: 7.5s\n { maxMs: ONE_SECOND_IN_MS * 7.5, roundedStepMs: ONE_SECOND_IN_MS * 5, display: '5s' },\n // max: 12.5s\n { maxMs: ONE_SECOND_IN_MS * 12.5, roundedStepMs: ONE_SECOND_IN_MS * 10, display: '10s' },\n // max: 17.5s\n { maxMs: ONE_SECOND_IN_MS * 17.5, roundedStepMs: ONE_SECOND_IN_MS * 15, display: '15s' },\n // max: 25s\n { maxMs: ONE_SECOND_IN_MS * 25, roundedStepMs: ONE_SECOND_IN_MS * 20, display: '20s' },\n // max: 45s\n { maxMs: ONE_SECOND_IN_MS * 45, roundedStepMs: ONE_SECOND_IN_MS * 30, display: '30s' },\n // max: 1.5m\n { maxMs: ONE_MINUTE_IN_MS * 1.5, roundedStepMs: ONE_MINUTE_IN_MS, display: '1m' },\n // max: 3.5m\n { maxMs: ONE_MINUTE_IN_MS * 3.5, roundedStepMs: ONE_MINUTE_IN_MS * 2, display: '2m' },\n // max: 7.5m\n { maxMs: ONE_MINUTE_IN_MS * 7.5, roundedStepMs: ONE_MINUTE_IN_MS * 5, display: '5m' },\n // max: 12.5m\n { maxMs: ONE_MINUTE_IN_MS * 12.5, roundedStepMs: ONE_MINUTE_IN_MS * 10, display: '10m' },\n // max: 12.5m\n { maxMs: ONE_MINUTE_IN_MS * 12.5, roundedStepMs: ONE_MINUTE_IN_MS * 15, display: '15m' },\n // max: 25m\n { maxMs: ONE_MINUTE_IN_MS * 25, roundedStepMs: ONE_MINUTE_IN_MS * 20, display: '20m' },\n // max: 45m\n { maxMs: ONE_MINUTE_IN_MS * 45, roundedStepMs: ONE_MINUTE_IN_MS * 30, display: '30m' },\n // max: 1.5h\n { maxMs: ONE_HOUR_IN_MS * 1.5, roundedStepMs: ONE_HOUR_IN_MS, display: '1h' },\n // max: 2.5h\n { maxMs: ONE_HOUR_IN_MS * 2.5, roundedStepMs: ONE_HOUR_IN_MS * 2, display: '2h' },\n // max: 4.5h\n { maxMs: ONE_HOUR_IN_MS * 4.5, roundedStepMs: ONE_HOUR_IN_MS * 3, display: '3h' },\n // max: 9h\n { maxMs: ONE_HOUR_IN_MS * 9, roundedStepMs: ONE_HOUR_IN_MS * 6, display: '6h' },\n // max: 1d\n { maxMs: ONE_DAY_IN_MS, roundedStepMs: ONE_HOUR_IN_MS * 12, display: '12h' },\n // max: 1w\n { maxMs: ONE_WEEK_IN_MS, roundedStepMs: ONE_DAY_IN_MS, display: '1d' },\n // max: 3w\n { maxMs: ONE_WEEK_IN_MS * 3, roundedStepMs: ONE_WEEK_IN_MS, display: '1w' },\n // max: 6w\n { maxMs: ONE_WEEK_IN_MS * 6, roundedStepMs: ONE_DAY_IN_MS * 30, display: '30d' },\n // max: 2y\n { maxMs: ONE_YEAR_IN_MS * 2, roundedStepMs: ONE_YEAR_IN_MS, display: '1y' },\n];\n\n/**\n * Round interval to clearer increments\n */\nexport function roundStepInterval(stepMs: number): number {\n for (const { maxMs, roundedStepMs } of ROUNDED_STEP_INTERVALS) {\n if (stepMs < maxMs) {\n return roundedStepMs;\n }\n }\n return DEFAULT_STEP_MS;\n}\n\n/**\n * Gets a suggested step/interval size for a time range based on the width of a visual component.\n */\nexport function getSuggestedStepMs(timeRange: AbsoluteTimeRange, width: number): number {\n const queryRangeMs = timeRange.end.valueOf() - timeRange.start.valueOf();\n const stepMs = Math.floor(queryRangeMs / width);\n return roundStepInterval(stepMs);\n}\n"],"names":["sub","ONE_SECOND_IN_MS","ONE_MINUTE_IN_MS","ONE_HOUR_IN_MS","ONE_DAY_IN_MS","ONE_WEEK_IN_MS","ONE_YEAR_IN_MS","isRelativeTimeRange","timeRange","pastDuration","undefined","isAbsoluteTimeRange","start","end","toAbsoluteTimeRange","Date","parseDurationString","DURATION_REGEX","durationString","matches","exec","Error","years","parseInt","months","weeks","days","hours","minutes","seconds","isDurationString","maybeDuration","test","intervalToPrometheusDuration","durationInMs","valueOf","msToPrometheusDuration","Math","trunc","formatDuration","duration","result","push","ms","round","join","DEFAULT_STEP_MS","ROUNDED_STEP_INTERVALS","maxMs","roundedStepMs","display","roundStepInterval","stepMs","getSuggestedStepMs","width","queryRangeMs","floor"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAmBA,GAAG,QAAQ,WAAW;AAEzC,MAAMC,mBAAmB;AACzB,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;AACvB,MAAMC,gBAAgB,UAAU,gCAAgC;AAChE,MAAMC,iBAAiB,WAAW,gCAAgC;AAClE,MAAMC,iBAAiB,aAAa,kCAAkC;AAmBtE;;CAEC,GACD,OAAO,SAASC,oBAAoBC,SAAyB;IAC3D,OAAO,AAACA,UAAgCC,YAAY,KAAKC;AAC3D;AAEA;;CAEC,GACD,OAAO,SAASC,oBAAoBH,SAAyB;IAC3D,OAAO,AAACA,UAAgCI,KAAK,KAAKF,aAAa,AAACF,UAAgCK,GAAG,KAAKH;AAC1G;AAEA;;CAEC,GACD,OAAO,SAASI,oBAA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;IAAK;CAC3E;AAED;;CAEC,GACD,OAAO,SAASC,kBAAkBC,MAAc;IAC9C,KAAK,MAAM,EAAEJ,KAAK,EAAEC,aAAa,EAAE,IAAIF,uBAAwB;QAC7D,IAAIK,SAASJ,OAAO;YAClB,OAAOC;QACT;IACF;IACA,OAAOH;AACT;AAEA;;CAEC,GACD,OAAO,SAASO,mBAAmB7C,SAA4B,EAAE8C,KAAa;IAC5E,MAAMC,eAAe/C,UAAUK,GAAG,CAACsB,OAAO,KAAK3B,UAAUI,KAAK,CAACuB,OAAO;IACtE,MAAMiB,SAASf,KAAKmB,KAAK,CAACD,eAAeD;IACzC,OAAOH,kBAAkBC;AAC3B"}
1
+ {"version":3,"sources":["../../src/model/time.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// 1. Runtime code like functions and consts\nexport {\n intervalToDuration as intervalToPrometheusDuration, //It has been renamed in spec\n formatDuration,\n parseDurationString,\n isRelativeTimeRange,\n isAbsoluteTimeRange,\n toAbsoluteTimeRange,\n roundStepInterval,\n getSuggestedStepMs,\n DURATION_REGEX,\n} from '@perses-dev/spec';\n\n// 2. Types (Compile-time only)\nexport type {\n UnixTimeMs,\n DateTimeFormat,\n AbsoluteTimeRange,\n RelativeTimeRange,\n TimeRangeValue,\n DurationString,\n} from '@perses-dev/spec';\n"],"names":["intervalToDuration","intervalToPrometheusDuration","formatDuration","parseDurationString","isRelativeTimeRange","isAbsoluteTimeRange","toAbsoluteTimeRange","roundStepInterval","getSuggestedStepMs","DURATION_REGEX"],"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,4CAA4C;AAC5C,SACEA,sBAAsBC,4BAA4B,EAClDC,cAAc,EACdC,mBAAmB,EACnBC,mBAAmB,EACnBC,mBAAmB,EACnBC,mBAAmB,EACnBC,iBAAiB,EACjBC,kBAAkB,EAClBC,cAAc,QACT,mBAAmB"}
@@ -1,8 +1,9 @@
1
+ import { datasourceSpecSchema, buildDatasourceSpecSchema } from '@perses-dev/spec';
1
2
  import { z } from 'zod';
2
- import { Datasource, DatasourceDefinition, DatasourceSpec } from '../model';
3
+ import { Datasource, DatasourceDefinition } from '../model';
3
4
  import { PluginSchema } from './plugin';
4
- export declare const datasourceSpecSchema: z.ZodSchema<DatasourceSpec>;
5
- export declare function buildDatasourceSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<DatasourceSpec>;
5
+ export type { datasourceSpecSchema };
6
+ export { buildDatasourceSpecSchema };
6
7
  export declare const datasourceSchema: z.ZodObject<{
7
8
  kind: z.ZodLiteral<"Datasource">;
8
9
  metadata: z.ZodObject<{
@@ -16,21 +17,21 @@ export declare const datasourceSchema: z.ZodObject<{
16
17
  name: string;
17
18
  project: string;
18
19
  }>;
19
- spec: z.ZodType<DatasourceSpec<import("../model").UnknownSpec>, z.ZodTypeDef, DatasourceSpec<import("../model").UnknownSpec>>;
20
+ spec: z.ZodType<import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>, z.ZodTypeDef, import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>>;
20
21
  }, "strip", z.ZodTypeAny, {
21
22
  kind: "Datasource";
22
- spec: DatasourceSpec<import("../model").UnknownSpec>;
23
23
  metadata: {
24
24
  name: string;
25
25
  project: string;
26
26
  };
27
+ spec: import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>;
27
28
  }, {
28
29
  kind: "Datasource";
29
- spec: DatasourceSpec<import("../model").UnknownSpec>;
30
30
  metadata: {
31
31
  name: string;
32
32
  project: string;
33
33
  };
34
+ spec: import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>;
34
35
  }>;
35
36
  export declare const globalDatasourceSchema: z.ZodObject<{
36
37
  kind: z.ZodLiteral<"GlobalDatasource">;
@@ -41,19 +42,19 @@ export declare const globalDatasourceSchema: z.ZodObject<{
41
42
  }, {
42
43
  name: string;
43
44
  }>;
44
- spec: z.ZodType<DatasourceSpec<import("../model").UnknownSpec>, z.ZodTypeDef, DatasourceSpec<import("../model").UnknownSpec>>;
45
+ spec: z.ZodType<import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>, z.ZodTypeDef, import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>>;
45
46
  }, "strip", z.ZodTypeAny, {
46
47
  kind: "GlobalDatasource";
47
- spec: DatasourceSpec<import("../model").UnknownSpec>;
48
48
  metadata: {
49
49
  name: string;
50
50
  };
51
+ spec: import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>;
51
52
  }, {
52
53
  kind: "GlobalDatasource";
53
- spec: DatasourceSpec<import("../model").UnknownSpec>;
54
54
  metadata: {
55
55
  name: string;
56
56
  };
57
+ spec: import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>;
57
58
  }>;
58
59
  export declare const datasourcesSchema: z.Schema<Datasource>;
59
60
  export declare const datasourceDefinitionSchema: z.Schema<DatasourceDefinition>;
@@ -1 +1 @@
1
- {"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/schema/datasource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE5E,OA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AC,CAAC,MAAM,CAAC,oBAAoB,CAGpE,CAAC;AAEH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAK1G"}
@@ -10,22 +10,10 @@
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 { datasourceSpecSchema, buildDatasourceSpecSchema } from '@perses-dev/spec';
13
14
  import { z } from 'zod';
14
15
  import { metadataSchema, projectMetadataSchema } from './metadata';
15
- import { pluginSchema } from './plugin';
16
- import { displaySchema } from './display';
17
- export const datasourceSpecSchema = z.object({
18
- display: displaySchema.optional(),
19
- default: z.boolean(),
20
- plugin: pluginSchema
21
- });
22
- export function buildDatasourceSpecSchema(pluginSchema) {
23
- return z.object({
24
- display: displaySchema.optional(),
25
- default: z.boolean(),
26
- plugin: pluginSchema
27
- });
28
- }
16
+ export { buildDatasourceSpecSchema };
29
17
  export const datasourceSchema = z.object({
30
18
  kind: z.literal('Datasource'),
31
19
  metadata: projectMetadataSchema,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/datasource.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 { z } from 'zod';\nimport { Datasource, DatasourceDefinition, DatasourceSpec } from '../model';\nimport { metadataSchema, projectMetadataSchema } from './metadata';\nimport { PluginSchema, pluginSchema } from './plugin';\nimport { displaySchema } from './display';\n\nexport const datasourceSpecSchema: z.ZodSchema<DatasourceSpec> = z.object({\n display: displaySchema.optional(),\n default: z.boolean(),\n plugin: pluginSchema,\n});\n\nexport function buildDatasourceSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<DatasourceSpec> {\n return z.object({\n display: displaySchema.optional(),\n default: z.boolean(),\n plugin: pluginSchema,\n });\n}\n\nexport const datasourceSchema = z.object({\n kind: z.literal('Datasource'),\n metadata: projectMetadataSchema,\n spec: datasourceSpecSchema,\n});\n\nexport const globalDatasourceSchema = z.object({\n kind: z.literal('GlobalDatasource'),\n metadata: metadataSchema,\n spec: datasourceSpecSchema,\n});\n\nexport const datasourcesSchema: z.Schema<Datasource> = z.discriminatedUnion('kind', [\n datasourceSchema,\n globalDatasourceSchema,\n]);\n\nexport const datasourceDefinitionSchema: z.Schema<DatasourceDefinition> = z.object({\n name: z.string().min(1),\n spec: datasourceSpecSchema,\n});\n\nexport function buildDatasourceDefinitionSchema(pluginSchema: PluginSchema): z.Schema<DatasourceDefinition> {\n return z.object({\n name: z.string().min(1),\n spec: buildDatasourceSpecSchema(pluginSchema),\n });\n}\n"],"names":["z","metadataSchema","projectMetadataSchema","pluginSchema","displaySchema","datasourceSpecSchema","object","display","optional","default","boolean","plugin","buildDatasourceSpecSchema","datasourceSchema","kind","literal","metadata","spec","globalDatasourceSchema","datasourcesSchema","discriminatedUnion","datasourceDefinitionSchema","name","string","min","buildDatasourceDefinitionSchema"],"mappings":"AAAA,+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,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,aAAa;AACnE,SAAuBC,YAAY,QAAQ,WAAW;AACtD,SAASC,aAAa,QAAQ,YAAY;AAE1C,OAAO,MAAMC,uBAAoDL,EAAEM,MAAM,CAAC;IACxEC,SAASH,cAAcI,QAAQ;IAC/BC,SAAST,EAAEU,OAAO;IAClBC,QAAQR;AACV,GAAG;AAEH,OAAO,SAASS,0BAA0BT,YAA0B;IAClE,OAAOH,EAAEM,MAAM,CAAC;QACdC,SAASH,cAAcI,QAAQ;QAC/BC,SAAST,EAAEU,OAAO;QAClBC,QAAQR;IACV;AACF;AAEA,OAAO,MAAMU,mBAAmBb,EAAEM,MAAM,CAAC;IACvCQ,MAAMd,EAAEe,OAAO,CAAC;IAChBC,UAAUd;IACVe,MAAMZ;AACR,GAAG;AAEH,OAAO,MAAMa,yBAAyBlB,EAAEM,MAAM,CAAC;IAC7CQ,MAAMd,EAAEe,OAAO,CAAC;IAChBC,UAAUf;IACVgB,MAAMZ;AACR,GAAG;AAEH,OAAO,MAAMc,oBAA0CnB,EAAEoB,kBAAkB,CAAC,QAAQ;IAClFP;IACAK;CACD,EAAE;AAEH,OAAO,MAAMG,6BAA6DrB,EAAEM,MAAM,CAAC;IACjFgB,MAAMtB,EAAEuB,MAAM,GAAGC,GAAG,CAAC;IACrBP,MAAMZ;AACR,GAAG;AAEH,OAAO,SAASoB,gCAAgCtB,YAA0B;IACxE,OAAOH,EAAEM,MAAM,CAAC;QACdgB,MAAMtB,EAAEuB,MAAM,GAAGC,GAAG,CAAC;QACrBP,MAAML,0BAA0BT;IAClC;AACF"}
1
+ {"version":3,"sources":["../../src/schema/datasource.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 { datasourceSpecSchema, buildDatasourceSpecSchema } from '@perses-dev/spec';\nimport { z } from 'zod';\nimport { Datasource, DatasourceDefinition } from '../model';\nimport { metadataSchema, projectMetadataSchema } from './metadata';\nimport { PluginSchema } from './plugin';\nexport type { datasourceSpecSchema };\nexport { buildDatasourceSpecSchema };\n\nexport const datasourceSchema = z.object({\n kind: z.literal('Datasource'),\n metadata: projectMetadataSchema,\n spec: datasourceSpecSchema,\n});\n\nexport const globalDatasourceSchema = z.object({\n kind: z.literal('GlobalDatasource'),\n metadata: metadataSchema,\n spec: datasourceSpecSchema,\n});\n\nexport const datasourcesSchema: z.Schema<Datasource> = z.discriminatedUnion('kind', [\n datasourceSchema,\n globalDatasourceSchema,\n]);\n\nexport const datasourceDefinitionSchema: z.Schema<DatasourceDefinition> = z.object({\n name: z.string().min(1),\n spec: datasourceSpecSchema,\n});\n\nexport function buildDatasourceDefinitionSchema(pluginSchema: PluginSchema): z.Schema<DatasourceDefinition> {\n return z.object({\n name: z.string().min(1),\n spec: buildDatasourceSpecSchema(pluginSchema),\n });\n}\n"],"names":["datasourceSpecSchema","buildDatasourceSpecSchema","z","metadataSchema","projectMetadataSchema","datasourceSchema","object","kind","literal","metadata","spec","globalDatasourceSchema","datasourcesSchema","discriminatedUnion","datasourceDefinitionSchema","name","string","min","buildDatasourceDefinitionSchema","pluginSchema"],"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,SAASA,oBAAoB,EAAEC,yBAAyB,QAAQ,mBAAmB;AACnF,SAASC,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,aAAa;AAGnE,SAASH,yBAAyB,GAAG;AAErC,OAAO,MAAMI,mBAAmBH,EAAEI,MAAM,CAAC;IACvCC,MAAML,EAAEM,OAAO,CAAC;IAChBC,UAAUL;IACVM,MAAMV;AACR,GAAG;AAEH,OAAO,MAAMW,yBAAyBT,EAAEI,MAAM,CAAC;IAC7CC,MAAML,EAAEM,OAAO,CAAC;IAChBC,UAAUN;IACVO,MAAMV;AACR,GAAG;AAEH,OAAO,MAAMY,oBAA0CV,EAAEW,kBAAkB,CAAC,QAAQ;IAClFR;IACAM;CACD,EAAE;AAEH,OAAO,MAAMG,6BAA6DZ,EAAEI,MAAM,CAAC;IACjFS,MAAMb,EAAEc,MAAM,GAAGC,GAAG,CAAC;IACrBP,MAAMV;AACR,GAAG;AAEH,OAAO,SAASkB,gCAAgCC,YAA0B;IACxE,OAAOjB,EAAEI,MAAM,CAAC;QACdS,MAAMb,EAAEc,MAAM,GAAGC,GAAG,CAAC;QACrBP,MAAMT,0BAA0BkB;IAClC;AACF"}
@@ -1,12 +1,2 @@
1
- import { z } from 'zod';
2
- export declare const displaySchema: z.ZodObject<{
3
- name: z.ZodOptional<z.ZodString>;
4
- description: z.ZodOptional<z.ZodString>;
5
- }, "strip", z.ZodTypeAny, {
6
- name?: string | undefined;
7
- description?: string | undefined;
8
- }, {
9
- name?: string | undefined;
10
- description?: string | undefined;
11
- }>;
1
+ export { displaySchema } from '@perses-dev/spec';
12
2
  //# sourceMappingURL=display.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/schema/display.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa;;;;;;;;;EAGxB,CAAC"}
1
+ {"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/schema/display.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -10,10 +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 { z } from 'zod';
14
- export const displaySchema = z.object({
15
- name: z.string().optional(),
16
- description: z.string().optional()
17
- });
13
+ export { displaySchema } from '@perses-dev/spec';
18
14
 
19
15
  //# sourceMappingURL=display.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/display.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 { z } from 'zod';\n\nexport const displaySchema = z.object({\n name: z.string().optional(),\n description: z.string().optional(),\n});\n"],"names":["z","displaySchema","object","name","string","optional","description"],"mappings":"AAAA,+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,SAASA,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,gBAAgBD,EAAEE,MAAM,CAAC;IACpCC,MAAMH,EAAEI,MAAM,GAAGC,QAAQ;IACzBC,aAAaN,EAAEI,MAAM,GAAGC,QAAQ;AAClC,GAAG"}
1
+ {"version":3,"sources":["../../src/schema/display.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 { displaySchema } from '@perses-dev/spec';\n"],"names":["displaySchema"],"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,SAASA,aAAa,QAAQ,mBAAmB"}
@@ -1,3 +1,2 @@
1
- import { z } from 'zod';
2
- export declare const durationValidationSchema: z.ZodString;
1
+ export { durationValidationSchema } from '@perses-dev/spec';
3
2
  //# sourceMappingURL=duration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/schema/duration.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,wBAAwB,aAGsB,CAAC"}
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/schema/duration.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -10,8 +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 { z } from 'zod';
14
- import { DURATION_REGEX } from '../model';
15
- export const durationValidationSchema = z.string().min(1, 'Required').regex(DURATION_REGEX, 'Must be a valid duration string');
13
+ export { durationValidationSchema } from '@perses-dev/spec';
16
14
 
17
15
  //# sourceMappingURL=duration.js.map