@perses-dev/core 0.0.0-snapshot-scatter-chart-embed-8efdfab → 0.0.0-snapshot-explorer-plugin-c4a7621

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 (257) hide show
  1. package/dist/cjs/index.js +1 -0
  2. package/dist/cjs/model/calculations.js +8 -8
  3. package/dist/cjs/model/ephemeraldashboard.js +16 -0
  4. package/dist/cjs/model/index.js +4 -0
  5. package/dist/cjs/model/kind.js +1 -0
  6. package/dist/cjs/model/legend.js +17 -17
  7. package/dist/cjs/model/query.js +12 -0
  8. package/dist/cjs/model/resource.js +14 -3
  9. package/dist/cjs/model/roles.js +4 -3
  10. package/dist/cjs/model/time.js +27 -26
  11. package/dist/cjs/model/trace-data.js +29 -1
  12. package/dist/cjs/model/transforms.js +28 -0
  13. package/dist/cjs/model/units/bytes.js +1 -4
  14. package/dist/cjs/model/units/decimal.js +1 -4
  15. package/dist/cjs/model/units/percent.js +1 -6
  16. package/dist/cjs/model/units/throughput.js +19 -13
  17. package/dist/cjs/model/units/time.js +9 -19
  18. package/dist/cjs/model/units/types.js +0 -13
  19. package/dist/cjs/model/units/units.js +13 -13
  20. package/dist/cjs/model/units/utils.js +3 -3
  21. package/dist/cjs/model/user.js +16 -0
  22. package/dist/cjs/model/value-mapping.js +16 -0
  23. package/dist/cjs/model/variables.js +3 -3
  24. package/dist/cjs/schema/datasource.js +85 -0
  25. package/dist/cjs/schema/display.js +27 -0
  26. package/dist/cjs/schema/duration.js +25 -0
  27. package/dist/cjs/schema/index.js +40 -0
  28. package/dist/cjs/schema/metadata.js +41 -0
  29. package/dist/cjs/schema/panel.js +106 -0
  30. package/dist/cjs/schema/plugin.js +27 -0
  31. package/dist/cjs/schema/role.js +86 -0
  32. package/dist/cjs/schema/rolebinding.js +65 -0
  33. package/dist/cjs/schema/secret.js +174 -0
  34. package/dist/cjs/schema/user.js +57 -0
  35. package/dist/cjs/schema/variable.js +171 -0
  36. package/dist/cjs/utils/fetch.js +20 -26
  37. package/dist/cjs/utils/index.js +3 -0
  38. package/dist/cjs/utils/mathjs.js +1 -1
  39. package/dist/cjs/utils/memo.js +4 -5
  40. package/dist/cjs/utils/panel-refs.js +4 -4
  41. package/dist/cjs/utils/regexp.js +54 -0
  42. package/dist/cjs/utils/text.js +21 -46
  43. package/dist/cjs/utils/time-series-data.js +5 -5
  44. package/dist/cjs/utils/transform-data.js +167 -0
  45. package/dist/cjs/utils/value-mapping.js +105 -0
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +1 -0
  49. package/dist/index.js.map +1 -1
  50. package/dist/model/calculations.d.ts +4 -4
  51. package/dist/model/calculations.d.ts.map +1 -1
  52. package/dist/model/calculations.js +1 -1
  53. package/dist/model/calculations.js.map +1 -1
  54. package/dist/model/dashboard.js.map +1 -1
  55. package/dist/model/datasource.d.ts +15 -8
  56. package/dist/model/datasource.d.ts.map +1 -1
  57. package/dist/model/datasource.js +3 -1
  58. package/dist/model/datasource.js.map +1 -1
  59. package/dist/model/definitions.d.ts +1 -1
  60. package/dist/model/definitions.d.ts.map +1 -1
  61. package/dist/model/definitions.js +3 -0
  62. package/dist/model/definitions.js.map +1 -1
  63. package/dist/model/ephemeraldashboard.d.ts +15 -0
  64. package/dist/model/ephemeraldashboard.d.ts.map +1 -0
  65. package/dist/model/ephemeraldashboard.js +15 -0
  66. package/dist/model/ephemeraldashboard.js.map +1 -0
  67. package/dist/model/http-proxy.js.map +1 -1
  68. package/dist/model/http.d.ts +6 -1
  69. package/dist/model/http.d.ts.map +1 -1
  70. package/dist/model/http.js.map +1 -1
  71. package/dist/model/index.d.ts +4 -0
  72. package/dist/model/index.d.ts.map +1 -1
  73. package/dist/model/index.js +4 -0
  74. package/dist/model/index.js.map +1 -1
  75. package/dist/model/kind.d.ts +1 -1
  76. package/dist/model/kind.d.ts.map +1 -1
  77. package/dist/model/kind.js +1 -0
  78. package/dist/model/kind.js.map +1 -1
  79. package/dist/model/layout.d.ts +1 -1
  80. package/dist/model/layout.d.ts.map +1 -1
  81. package/dist/model/layout.js.map +1 -1
  82. package/dist/model/legend.d.ts +6 -6
  83. package/dist/model/legend.d.ts.map +1 -1
  84. package/dist/model/legend.js.map +1 -1
  85. package/dist/model/panels.d.ts +17 -1
  86. package/dist/model/panels.d.ts.map +1 -1
  87. package/dist/model/panels.js +3 -1
  88. package/dist/model/panels.js.map +1 -1
  89. package/dist/model/project.d.ts +5 -0
  90. package/dist/model/project.d.ts.map +1 -1
  91. package/dist/model/project.js.map +1 -1
  92. package/dist/model/query.d.ts +11 -1
  93. package/dist/model/query.d.ts.map +1 -1
  94. package/dist/model/query.js +9 -1
  95. package/dist/model/query.js.map +1 -1
  96. package/dist/model/resource.d.ts +7 -0
  97. package/dist/model/resource.d.ts.map +1 -1
  98. package/dist/model/resource.js +3 -0
  99. package/dist/model/resource.js.map +1 -1
  100. package/dist/model/rolebindings.d.ts +1 -1
  101. package/dist/model/rolebindings.d.ts.map +1 -1
  102. package/dist/model/rolebindings.js.map +1 -1
  103. package/dist/model/roles.d.ts +3 -3
  104. package/dist/model/roles.d.ts.map +1 -1
  105. package/dist/model/roles.js +1 -0
  106. package/dist/model/roles.js.map +1 -1
  107. package/dist/model/secrets.d.ts +1 -1
  108. package/dist/model/secrets.d.ts.map +1 -1
  109. package/dist/model/secrets.js.map +1 -1
  110. package/dist/model/thresholds.js.map +1 -1
  111. package/dist/model/time-series-data.d.ts +1 -0
  112. package/dist/model/time-series-data.d.ts.map +1 -1
  113. package/dist/model/time-series-data.js.map +1 -1
  114. package/dist/model/time-series-queries.d.ts +3 -3
  115. package/dist/model/time-series-queries.d.ts.map +1 -1
  116. package/dist/model/time-series-queries.js.map +1 -1
  117. package/dist/model/time.d.ts +12 -11
  118. package/dist/model/time.d.ts.map +1 -1
  119. package/dist/model/time.js +11 -13
  120. package/dist/model/time.js.map +1 -1
  121. package/dist/model/trace-data.d.ts +80 -7
  122. package/dist/model/trace-data.d.ts.map +1 -1
  123. package/dist/model/trace-data.js +8 -1
  124. package/dist/model/trace-data.js.map +1 -1
  125. package/dist/model/transforms.d.ts +34 -0
  126. package/dist/model/transforms.d.ts.map +1 -0
  127. package/dist/model/transforms.js +21 -0
  128. package/dist/model/transforms.js.map +1 -0
  129. package/dist/model/units/bytes.d.ts +2 -3
  130. package/dist/model/units/bytes.d.ts.map +1 -1
  131. package/dist/model/units/bytes.js +1 -4
  132. package/dist/model/units/bytes.js.map +1 -1
  133. package/dist/model/units/decimal.d.ts +2 -3
  134. package/dist/model/units/decimal.d.ts.map +1 -1
  135. package/dist/model/units/decimal.js +1 -4
  136. package/dist/model/units/decimal.js.map +1 -1
  137. package/dist/model/units/percent.d.ts +2 -3
  138. package/dist/model/units/percent.d.ts.map +1 -1
  139. package/dist/model/units/percent.js +1 -6
  140. package/dist/model/units/percent.js.map +1 -1
  141. package/dist/model/units/throughput.d.ts +2 -3
  142. package/dist/model/units/throughput.d.ts.map +1 -1
  143. package/dist/model/units/throughput.js +19 -13
  144. package/dist/model/units/throughput.js.map +1 -1
  145. package/dist/model/units/time.d.ts +2 -3
  146. package/dist/model/units/time.d.ts.map +1 -1
  147. package/dist/model/units/time.js +9 -19
  148. package/dist/model/units/time.js.map +1 -1
  149. package/dist/model/units/types.d.ts +3 -4
  150. package/dist/model/units/types.d.ts.map +1 -1
  151. package/dist/model/units/types.js +1 -7
  152. package/dist/model/units/types.js.map +1 -1
  153. package/dist/model/units/units.d.ts +5 -3
  154. package/dist/model/units/units.d.ts.map +1 -1
  155. package/dist/model/units/units.js +1 -1
  156. package/dist/model/units/units.js.map +1 -1
  157. package/dist/model/units/utils.d.ts.map +1 -1
  158. package/dist/model/units/utils.js.map +1 -1
  159. package/dist/model/user.d.ts +21 -0
  160. package/dist/model/user.d.ts.map +1 -0
  161. package/dist/model/user.js +15 -0
  162. package/dist/model/user.js.map +1 -0
  163. package/dist/model/value-mapping.d.ts +35 -0
  164. package/dist/model/value-mapping.d.ts.map +1 -0
  165. package/dist/model/value-mapping.js +15 -0
  166. package/dist/model/value-mapping.js.map +1 -0
  167. package/dist/model/variables.d.ts +12 -11
  168. package/dist/model/variables.d.ts.map +1 -1
  169. package/dist/model/variables.js.map +1 -1
  170. package/dist/schema/datasource.d.ts +61 -0
  171. package/dist/schema/datasource.d.ts.map +1 -0
  172. package/dist/schema/datasource.js +54 -0
  173. package/dist/schema/datasource.js.map +1 -0
  174. package/dist/schema/display.d.ts +12 -0
  175. package/dist/schema/display.d.ts.map +1 -0
  176. package/dist/schema/display.js +19 -0
  177. package/dist/schema/display.js.map +1 -0
  178. package/dist/schema/duration.d.ts +3 -0
  179. package/dist/schema/duration.d.ts.map +1 -0
  180. package/dist/schema/duration.js +17 -0
  181. package/dist/schema/duration.js.map +1 -0
  182. package/dist/schema/index.d.ts +12 -0
  183. package/dist/schema/index.d.ts.map +1 -0
  184. package/dist/schema/index.js +25 -0
  185. package/dist/schema/index.js.map +1 -0
  186. package/dist/schema/metadata.d.ts +21 -0
  187. package/dist/schema/metadata.d.ts.map +1 -0
  188. package/dist/schema/metadata.js +22 -0
  189. package/dist/schema/metadata.js.map +1 -0
  190. package/dist/schema/panel.d.ts +13 -0
  191. package/dist/schema/panel.d.ts.map +1 -0
  192. package/dist/schema/panel.js +69 -0
  193. package/dist/schema/panel.js.map +1 -0
  194. package/dist/schema/plugin.d.ts +14 -0
  195. package/dist/schema/plugin.d.ts.map +1 -0
  196. package/dist/schema/plugin.js +19 -0
  197. package/dist/schema/plugin.js.map +1 -0
  198. package/dist/schema/role.d.ts +58 -0
  199. package/dist/schema/role.d.ts.map +1 -0
  200. package/dist/schema/role.js +61 -0
  201. package/dist/schema/role.js.map +1 -0
  202. package/dist/schema/rolebinding.d.ts +58 -0
  203. package/dist/schema/rolebinding.d.ts.map +1 -0
  204. package/dist/schema/rolebinding.js +40 -0
  205. package/dist/schema/rolebinding.js.map +1 -0
  206. package/dist/schema/secret.d.ts +1140 -0
  207. package/dist/schema/secret.d.ts.map +1 -0
  208. package/dist/schema/secret.js +152 -0
  209. package/dist/schema/secret.js.map +1 -0
  210. package/dist/schema/user.d.ts +8 -0
  211. package/dist/schema/user.d.ts.map +1 -0
  212. package/dist/schema/user.js +36 -0
  213. package/dist/schema/user.js.map +1 -0
  214. package/dist/schema/variable.d.ts +92 -0
  215. package/dist/schema/variable.d.ts.map +1 -0
  216. package/dist/schema/variable.js +119 -0
  217. package/dist/schema/variable.js.map +1 -0
  218. package/dist/utils/event.js.map +1 -1
  219. package/dist/utils/fetch.d.ts +5 -2
  220. package/dist/utils/fetch.d.ts.map +1 -1
  221. package/dist/utils/fetch.js +15 -21
  222. package/dist/utils/fetch.js.map +1 -1
  223. package/dist/utils/index.d.ts +3 -0
  224. package/dist/utils/index.d.ts.map +1 -1
  225. package/dist/utils/index.js +3 -0
  226. package/dist/utils/index.js.map +1 -1
  227. package/dist/utils/is-empty-object.d.ts.map +1 -1
  228. package/dist/utils/is-empty-object.js.map +1 -1
  229. package/dist/utils/mathjs.js +1 -1
  230. package/dist/utils/mathjs.js.map +1 -1
  231. package/dist/utils/memo.d.ts.map +1 -1
  232. package/dist/utils/memo.js +1 -2
  233. package/dist/utils/memo.js.map +1 -1
  234. package/dist/utils/panel-refs.d.ts +2 -2
  235. package/dist/utils/panel-refs.d.ts.map +1 -1
  236. package/dist/utils/panel-refs.js.map +1 -1
  237. package/dist/utils/regexp.d.ts +11 -0
  238. package/dist/utils/regexp.d.ts.map +1 -0
  239. package/dist/utils/regexp.js +42 -0
  240. package/dist/utils/regexp.js.map +1 -0
  241. package/dist/utils/text.d.ts +7 -33
  242. package/dist/utils/text.d.ts.map +1 -1
  243. package/dist/utils/text.js +21 -52
  244. package/dist/utils/text.js.map +1 -1
  245. package/dist/utils/time-series-data.d.ts.map +1 -1
  246. package/dist/utils/time-series-data.js.map +1 -1
  247. package/dist/utils/transform-data.d.ts +8 -0
  248. package/dist/utils/transform-data.d.ts.map +1 -0
  249. package/dist/utils/transform-data.js +221 -0
  250. package/dist/utils/transform-data.js.map +1 -0
  251. package/dist/utils/types.d.ts +1 -1
  252. package/dist/utils/types.d.ts.map +1 -1
  253. package/dist/utils/value-mapping.d.ts +3 -0
  254. package/dist/utils/value-mapping.d.ts.map +1 -0
  255. package/dist/utils/value-mapping.js +97 -0
  256. package/dist/utils/value-mapping.js.map +1 -0
  257. package/package.json +1 -1
@@ -0,0 +1,174 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ globalSecretSchema: function() {
25
+ return globalSecretSchema;
26
+ },
27
+ secretSchema: function() {
28
+ return secretSchema;
29
+ },
30
+ secretSpecSchema: function() {
31
+ return secretSpecSchema;
32
+ },
33
+ secretsEditorSchema: function() {
34
+ return secretsEditorSchema;
35
+ }
36
+ });
37
+ const _zod = require("zod");
38
+ const _metadata = require("./metadata");
39
+ const secretSpecSchema = _zod.z.object({
40
+ basicAuth: _zod.z.object({
41
+ username: _zod.z.string().min(1),
42
+ password: _zod.z.string().optional(),
43
+ passwordFile: _zod.z.string().optional()
44
+ }).superRefine((val, ctx)=>{
45
+ if (val.password && val.password.length > 0 && val.passwordFile && val.passwordFile.length > 0) {
46
+ ctx.addIssue({
47
+ code: _zod.z.ZodIssueCode.custom,
48
+ message: 'Only one of the fields must be defined',
49
+ path: [
50
+ 'password'
51
+ ]
52
+ });
53
+ ctx.addIssue({
54
+ code: _zod.z.ZodIssueCode.custom,
55
+ message: 'Only one of the fields must be defined',
56
+ path: [
57
+ 'passwordFile'
58
+ ]
59
+ });
60
+ }
61
+ }).optional(),
62
+ authorization: _zod.z.object({
63
+ type: _zod.z.string().optional(),
64
+ credentials: _zod.z.string().optional(),
65
+ credentialsFile: _zod.z.string().optional()
66
+ }).superRefine((val, ctx)=>{
67
+ if (val.credentials && val.credentials.length > 0 && val.credentialsFile && val.credentialsFile.length > 0) {
68
+ ctx.addIssue({
69
+ code: _zod.z.ZodIssueCode.custom,
70
+ message: 'Only one of the fields must be defined',
71
+ path: [
72
+ 'credentials'
73
+ ]
74
+ });
75
+ ctx.addIssue({
76
+ code: _zod.z.ZodIssueCode.custom,
77
+ message: 'Only one of the fields must be defined',
78
+ path: [
79
+ 'credentialsFile'
80
+ ]
81
+ });
82
+ }
83
+ }).optional(),
84
+ tlsConfig: _zod.z.object({
85
+ ca: _zod.z.string().optional(),
86
+ cert: _zod.z.string().optional(),
87
+ key: _zod.z.string().optional(),
88
+ caFile: _zod.z.string().optional(),
89
+ certFile: _zod.z.string().optional(),
90
+ keyFile: _zod.z.string().optional(),
91
+ serverName: _zod.z.string().optional(),
92
+ insecureSkipVerify: _zod.z.boolean()
93
+ }).superRefine((val, ctx)=>{
94
+ if (val.ca && val.ca.length > 0 && val.caFile && val.caFile.length > 0) {
95
+ ctx.addIssue({
96
+ code: _zod.z.ZodIssueCode.custom,
97
+ message: 'Only one of the fields must be defined',
98
+ path: [
99
+ 'ca'
100
+ ]
101
+ });
102
+ ctx.addIssue({
103
+ code: _zod.z.ZodIssueCode.custom,
104
+ message: 'Only one of the fields must be defined',
105
+ path: [
106
+ 'caFile'
107
+ ]
108
+ });
109
+ }
110
+ if (val.cert && val.cert.length > 0 && val.certFile && val.certFile.length > 0) {
111
+ ctx.addIssue({
112
+ code: _zod.z.ZodIssueCode.custom,
113
+ message: 'Only one of the fields must be defined',
114
+ path: [
115
+ 'cert'
116
+ ]
117
+ });
118
+ ctx.addIssue({
119
+ code: _zod.z.ZodIssueCode.custom,
120
+ message: 'Only one of the fields must be defined',
121
+ path: [
122
+ 'certFile'
123
+ ]
124
+ });
125
+ }
126
+ if (val.key && val.key.length > 0 && val.keyFile && val.keyFile.length > 0) {
127
+ ctx.addIssue({
128
+ code: _zod.z.ZodIssueCode.custom,
129
+ message: 'Only one of the fields must be defined',
130
+ path: [
131
+ 'key'
132
+ ]
133
+ });
134
+ ctx.addIssue({
135
+ code: _zod.z.ZodIssueCode.custom,
136
+ message: 'Only one of the fields must be defined',
137
+ path: [
138
+ 'keyFile'
139
+ ]
140
+ });
141
+ }
142
+ }).optional()
143
+ }).superRefine((val, ctx)=>{
144
+ if (val.basicAuth && val.authorization) {
145
+ ctx.addIssue({
146
+ code: _zod.z.ZodIssueCode.custom,
147
+ message: 'Only one of the fields must be defined',
148
+ path: [
149
+ 'basicAuth'
150
+ ]
151
+ });
152
+ ctx.addIssue({
153
+ code: _zod.z.ZodIssueCode.custom,
154
+ message: 'Only one of the fields must be defined',
155
+ path: [
156
+ 'authorization'
157
+ ]
158
+ });
159
+ }
160
+ });
161
+ const secretSchema = _zod.z.object({
162
+ kind: _zod.z.literal('Secret'),
163
+ metadata: _metadata.projectMetadataSchema,
164
+ spec: secretSpecSchema
165
+ });
166
+ const globalSecretSchema = _zod.z.object({
167
+ kind: _zod.z.literal('GlobalSecret'),
168
+ metadata: _metadata.metadataSchema,
169
+ spec: secretSpecSchema
170
+ });
171
+ const secretsEditorSchema = _zod.z.discriminatedUnion('kind', [
172
+ secretSchema,
173
+ globalSecretSchema
174
+ ]);
@@ -0,0 +1,57 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ nativeProviderSchema: function() {
25
+ return nativeProviderSchema;
26
+ },
27
+ oauthProvidersSchema: function() {
28
+ return oauthProvidersSchema;
29
+ },
30
+ userSchema: function() {
31
+ return userSchema;
32
+ },
33
+ userSpecSchema: function() {
34
+ return userSpecSchema;
35
+ }
36
+ });
37
+ const _zod = require("zod");
38
+ const _metadata = require("./metadata");
39
+ const nativeProviderSchema = _zod.z.object({
40
+ password: _zod.z.string().optional()
41
+ });
42
+ const oauthProvidersSchema = _zod.z.object({
43
+ issuer: _zod.z.string().optional(),
44
+ email: _zod.z.string().optional(),
45
+ subject: _zod.z.string().optional()
46
+ });
47
+ const userSpecSchema = _zod.z.object({
48
+ firstName: _zod.z.string().optional(),
49
+ lastName: _zod.z.string().optional(),
50
+ nativeProvider: nativeProviderSchema.optional(),
51
+ oauthProviders: _zod.z.array(oauthProvidersSchema).optional()
52
+ });
53
+ const userSchema = _zod.z.object({
54
+ kind: _zod.z.literal('User'),
55
+ metadata: _metadata.metadataSchema,
56
+ spec: userSpecSchema
57
+ });
@@ -0,0 +1,171 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ buildVariableDefinitionSchema: function() {
25
+ return buildVariableDefinitionSchema;
26
+ },
27
+ buildVariableListSchema: function() {
28
+ return buildVariableListSchema;
29
+ },
30
+ buildVariableListSpecSchema: function() {
31
+ return buildVariableListSpecSchema;
32
+ },
33
+ buildVariableSpecSchema: function() {
34
+ return buildVariableSpecSchema;
35
+ },
36
+ globalVariableSchema: function() {
37
+ return globalVariableSchema;
38
+ },
39
+ variableDefinitionSchema: function() {
40
+ return variableDefinitionSchema;
41
+ },
42
+ variableDisplaySchema: function() {
43
+ return variableDisplaySchema;
44
+ },
45
+ variableListSchema: function() {
46
+ return variableListSchema;
47
+ },
48
+ variableListSpecSchema: function() {
49
+ return variableListSpecSchema;
50
+ },
51
+ variableSchema: function() {
52
+ return variableSchema;
53
+ },
54
+ variableSpecSchema: function() {
55
+ return variableSpecSchema;
56
+ },
57
+ variableTextSchema: function() {
58
+ return variableTextSchema;
59
+ },
60
+ variableTextSpecSchema: function() {
61
+ return variableTextSpecSchema;
62
+ },
63
+ variablesSchema: function() {
64
+ return variablesSchema;
65
+ }
66
+ });
67
+ const _zod = require("zod");
68
+ const _metadata = require("./metadata");
69
+ const _plugin = require("./plugin");
70
+ const variableDisplaySchema = _zod.z.object({
71
+ name: _zod.z.string().optional(),
72
+ description: _zod.z.string().optional(),
73
+ hidden: _zod.z.boolean().optional()
74
+ });
75
+ const variableListSpecSchema = _zod.z.object({
76
+ name: _zod.z.string().min(1),
77
+ display: variableDisplaySchema.optional(),
78
+ defaultValue: _zod.z.string().or(_zod.z.array(_zod.z.string())).optional(),
79
+ allowAllValue: _zod.z.boolean(),
80
+ allowMultiple: _zod.z.boolean(),
81
+ customAllValue: _zod.z.string().optional(),
82
+ capturingRegexp: _zod.z.string().optional(),
83
+ sort: _zod.z.enum([
84
+ 'none',
85
+ 'alphabetical-asc',
86
+ 'alphabetical-desc',
87
+ 'numerical-asc',
88
+ 'numerical-desc',
89
+ 'alphabetical-ci-asc',
90
+ 'alphabetical-ci-desc'
91
+ ]).optional(),
92
+ plugin: _plugin.pluginSchema
93
+ });
94
+ function buildVariableListSpecSchema(pluginSchema) {
95
+ return _zod.z.object({
96
+ name: _zod.z.string().min(1),
97
+ display: variableDisplaySchema.optional(),
98
+ defaultValue: _zod.z.string().or(_zod.z.array(_zod.z.string())).optional(),
99
+ allowAllValue: _zod.z.boolean(),
100
+ allowMultiple: _zod.z.boolean(),
101
+ customAllValue: _zod.z.string().optional(),
102
+ capturingRegexp: _zod.z.string().optional(),
103
+ sort: _zod.z.enum([
104
+ 'none',
105
+ 'alphabetical-asc',
106
+ 'alphabetical-desc',
107
+ 'numerical-asc',
108
+ 'numerical-desc',
109
+ 'alphabetical-ci-asc',
110
+ 'alphabetical-ci-desc'
111
+ ]).optional(),
112
+ plugin: pluginSchema
113
+ });
114
+ }
115
+ const variableListSchema = _zod.z.object({
116
+ kind: _zod.z.literal('ListVariable'),
117
+ spec: variableListSpecSchema
118
+ });
119
+ function buildVariableListSchema(pluginSchema) {
120
+ return _zod.z.object({
121
+ kind: _zod.z.literal('ListVariable'),
122
+ spec: buildVariableListSpecSchema(pluginSchema)
123
+ });
124
+ }
125
+ const variableTextSpecSchema = _zod.z.object({
126
+ name: _zod.z.string().min(1),
127
+ display: variableDisplaySchema.optional(),
128
+ value: _zod.z.string(),
129
+ constant: _zod.z.boolean().optional()
130
+ });
131
+ const variableTextSchema = _zod.z.object({
132
+ kind: _zod.z.literal('TextVariable'),
133
+ spec: variableTextSpecSchema
134
+ });
135
+ const variableSpecSchema = _zod.z.discriminatedUnion('kind', [
136
+ variableTextSchema,
137
+ variableListSchema
138
+ ]);
139
+ function buildVariableSpecSchema(pluginSchema) {
140
+ return _zod.z.union([
141
+ variableTextSchema,
142
+ buildVariableListSchema(pluginSchema)
143
+ ]);
144
+ }
145
+ const variableSchema = _zod.z.object({
146
+ kind: _zod.z.literal('Variable'),
147
+ metadata: _metadata.projectMetadataSchema,
148
+ spec: variableSpecSchema
149
+ });
150
+ const globalVariableSchema = _zod.z.object({
151
+ kind: _zod.z.literal('GlobalVariable'),
152
+ metadata: _metadata.projectMetadataSchema,
153
+ spec: variableSpecSchema
154
+ });
155
+ const variablesSchema = _zod.z.discriminatedUnion('kind', [
156
+ variableSchema,
157
+ globalVariableSchema
158
+ ]);
159
+ const variableDefinitionSchema = variableSpecSchema;
160
+ function buildVariableDefinitionSchema(pluginSchema) {
161
+ return _zod.z.discriminatedUnion('kind', [
162
+ _zod.z.object({
163
+ kind: _zod.z.literal('ListVariable'),
164
+ spec: buildVariableListSpecSchema(pluginSchema)
165
+ }),
166
+ _zod.z.object({
167
+ kind: _zod.z.literal('TextVariable'),
168
+ spec: variableTextSpecSchema
169
+ })
170
+ ]);
171
+ }
@@ -23,41 +23,35 @@ function _export(target, all) {
23
23
  });
24
24
  }
25
25
  _export(exports, {
26
- fetch: function() {
27
- return fetch;
28
- },
29
- fetchJson: function() {
30
- return fetchJson;
31
- },
32
26
  FetchError: function() {
33
27
  return FetchError;
34
28
  },
35
29
  UserFriendlyError: function() {
36
30
  return UserFriendlyError;
31
+ },
32
+ fetch: function() {
33
+ return fetch;
34
+ },
35
+ fetchJson: function() {
36
+ return fetchJson;
37
37
  }
38
38
  });
39
- function _define_property(obj, key, value) {
40
- if (key in obj) {
41
- Object.defineProperty(obj, key, {
42
- value: value,
43
- enumerable: true,
44
- configurable: true,
45
- writable: true
46
- });
47
- } else {
48
- obj[key] = value;
49
- }
50
- return obj;
51
- }
52
39
  async function fetch(...args) {
53
40
  const response = await global.fetch(...args);
54
41
  if (response.ok === false) {
55
- const json = await response.json();
56
- if (json.error) {
57
- throw new UserFriendlyError(json.error, response.status);
42
+ const contentType = response.headers.get('content-type');
43
+ if (contentType?.includes('application/json')) {
44
+ const json = await response.json();
45
+ if (json.error) {
46
+ throw new UserFriendlyError(json.error, response.status);
47
+ }
48
+ if (json.message) {
49
+ throw new UserFriendlyError(json.message, response.status);
50
+ }
58
51
  }
59
- if (json.message) {
60
- throw new UserFriendlyError(json.message, response.status);
52
+ const text = await response.text();
53
+ if (text) {
54
+ throw new UserFriendlyError(text, response.status);
61
55
  }
62
56
  throw new FetchError(response);
63
57
  }
@@ -69,17 +63,17 @@ async function fetchJson(...args) {
69
63
  return json;
70
64
  }
71
65
  class FetchError extends Error {
66
+ status;
72
67
  constructor(response){
73
68
  super(`${response.status} ${response.statusText}`);
74
- _define_property(this, "status", void 0);
75
69
  this.status = response.status;
76
70
  Object.setPrototypeOf(this, FetchError.prototype);
77
71
  }
78
72
  }
79
73
  class UserFriendlyError extends Error {
74
+ status;
80
75
  constructor(message, status){
81
76
  super(message);
82
- _define_property(this, "status", void 0);
83
77
  this.status = status;
84
78
  Object.setPrototypeOf(this, UserFriendlyError.prototype);
85
79
  }
@@ -21,7 +21,10 @@ _export_star(require("./memo"), exports);
21
21
  _export_star(require("./panel-refs"), exports);
22
22
  _export_star(require("./text"), exports);
23
23
  _export_star(require("./time-series-data"), exports);
24
+ _export_star(require("./transform-data"), exports);
25
+ _export_star(require("./value-mapping"), exports);
24
26
  _export_star(require("./types"), exports);
27
+ _export_star(require("./regexp"), exports);
25
28
  function _export_star(from, to) {
26
29
  Object.keys(from).forEach(function(k) {
27
30
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -22,6 +22,6 @@ Object.defineProperty(exports, "gcd", {
22
22
  });
23
23
  const _mathjs = require("mathjs");
24
24
  // This ensures we get a minimal mathjs bundle for just what we need (see https://mathjs.org/docs/custom_bundling.html)
25
- const { gcd } = (0, _mathjs.create)({
25
+ const { gcd } = (0, _mathjs.create)({
26
26
  gcdDependencies: _mathjs.gcdDependencies
27
27
  });
@@ -21,11 +21,11 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- useMemoized: function() {
25
- return useMemoized;
26
- },
27
24
  useDeepMemo: function() {
28
25
  return useDeepMemo;
26
+ },
27
+ useMemoized: function() {
28
+ return useMemoized;
29
29
  }
30
30
  });
31
31
  const _react = require("react");
@@ -39,8 +39,7 @@ function useMemoized(factory, deps) {
39
39
  const ref = (0, _react.useRef)();
40
40
  let areEqual = true;
41
41
  for(let i = 0; i < deps.length; i++){
42
- var _ref_current;
43
- if (((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.deps[i]) !== deps[i]) {
42
+ if (ref.current?.deps[i] !== deps[i]) {
44
43
  areEqual = false;
45
44
  break;
46
45
  }
@@ -21,14 +21,14 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- resolvePanelRef: function() {
25
- return resolvePanelRef;
24
+ createPanelRef: function() {
25
+ return createPanelRef;
26
26
  },
27
27
  getPanelKeyFromRef: function() {
28
28
  return getPanelKeyFromRef;
29
29
  },
30
- createPanelRef: function() {
31
- return createPanelRef;
30
+ resolvePanelRef: function() {
31
+ return resolvePanelRef;
32
32
  }
33
33
  });
34
34
  function resolvePanelRef(spec, panelRef) {
@@ -0,0 +1,54 @@
1
+ // Copyright 2024 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
+ * Checks if a string is a regex pattern.
15
+ */ "use strict";
16
+ Object.defineProperty(exports, "__esModule", {
17
+ value: true
18
+ });
19
+ function _export(target, all) {
20
+ for(var name in all)Object.defineProperty(target, name, {
21
+ enumerable: true,
22
+ get: all[name]
23
+ });
24
+ }
25
+ _export(exports, {
26
+ createRegexFromString: function() {
27
+ return createRegexFromString;
28
+ },
29
+ isRegexPattern: function() {
30
+ return isRegexPattern;
31
+ }
32
+ });
33
+ function isRegexPattern(input) {
34
+ return Boolean(input?.startsWith('/'));
35
+ }
36
+ function createRegexFromString(input) {
37
+ if (!input) {
38
+ throw new Error('Input string cannot be empty');
39
+ }
40
+ if (!isRegexPattern(input)) {
41
+ return new RegExp(`^${input}$`);
42
+ }
43
+ const regexPattern = /^\/(.+)\/([gimy]*)$/;
44
+ const matches = input.match(regexPattern);
45
+ if (!matches) {
46
+ throw new Error(`Invalid regular expression format: ${input}`);
47
+ }
48
+ const [, pattern = '', flags = ''] = matches;
49
+ try {
50
+ return new RegExp(pattern, flags);
51
+ } catch (error) {
52
+ throw new Error(`Failed to create RegExp ${error}`);
53
+ }
54
+ }
@@ -21,57 +21,32 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- getDashboardDisplayName: function() {
25
- return getDashboardDisplayName;
24
+ getResourceDisplayName: function() {
25
+ return getResourceDisplayName;
26
26
  },
27
- getVariableDisplayName: function() {
28
- return getVariableDisplayName;
29
- },
30
- getDatasourceDisplayName: function() {
31
- return getDatasourceDisplayName;
32
- },
33
- getDashboardExtendedDisplayName: function() {
34
- return getDashboardExtendedDisplayName;
35
- },
36
- getVariableExtendedDisplayName: function() {
37
- return getVariableExtendedDisplayName;
38
- },
39
- getDatasourceExtendedDisplayName: function() {
40
- return getDatasourceExtendedDisplayName;
27
+ getResourceExtendedDisplayName: function() {
28
+ return getResourceExtendedDisplayName;
41
29
  }
42
30
  });
43
- function getDashboardDisplayName(dashboard) {
44
- var _dashboard_spec_display;
45
- var _dashboard_spec_display_name;
46
- return (_dashboard_spec_display_name = (_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) !== null && _dashboard_spec_display_name !== void 0 ? _dashboard_spec_display_name : dashboard.metadata.name;
47
- }
48
- function getVariableDisplayName(variable) {
49
- var _variable_spec_spec_display;
50
- var _variable_spec_spec_display_name;
51
- return (_variable_spec_spec_display_name = (_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) !== null && _variable_spec_spec_display_name !== void 0 ? _variable_spec_spec_display_name : variable.metadata.name;
52
- }
53
- function getDatasourceDisplayName(datasource) {
54
- var _datasource_spec_display;
55
- return ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) || datasource.metadata.name;
56
- }
57
- function getDashboardExtendedDisplayName(dashboard) {
58
- var _dashboard_spec_display;
59
- if ((_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) {
60
- return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;
31
+ function getResourceDisplayName(resource) {
32
+ // Variables
33
+ if (resource.spec.spec?.display?.name) {
34
+ return resource.spec.spec.display.name;
61
35
  }
62
- return dashboard.metadata.name;
63
- }
64
- function getVariableExtendedDisplayName(variable) {
65
- var _variable_spec_spec_display;
66
- if ((_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) {
67
- return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;
36
+ // Other resources with display
37
+ if (resource.spec.display?.name) {
38
+ return resource.spec.display.name;
68
39
  }
69
- return variable.metadata.name;
40
+ return resource.metadata.name;
70
41
  }
71
- function getDatasourceExtendedDisplayName(datasource) {
72
- var _datasource_spec_display;
73
- if ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) {
74
- return `${datasource.spec.display.name} (Name: ${datasource.metadata.name})`;
42
+ function getResourceExtendedDisplayName(resource) {
43
+ // Variables
44
+ if (resource.spec.spec?.display?.name) {
45
+ return `${resource.spec.spec.display.name} (ID: ${resource.metadata.name})`;
46
+ }
47
+ // Other resources with display
48
+ if (resource.spec.display?.name) {
49
+ return `${resource.spec.display.name} (ID: ${resource.metadata.name})`;
75
50
  }
76
- return datasource.metadata.name;
51
+ return resource.metadata.name;
77
52
  }