@red-hat-developer-hub/plugin-cost-management-common 2.0.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.
- package/CHANGELOG.md +49 -0
- package/README.md +17 -0
- package/dist/DefaultApiClient.cjs.js +8 -0
- package/dist/DefaultApiClient.cjs.js.map +1 -0
- package/dist/DefaultApiClient.d.ts +83 -0
- package/dist/DefaultApiClient.esm.js +2 -0
- package/dist/DefaultApiClient.esm.js.map +1 -0
- package/dist/clients/cost-management/CostManagementSlimClient.cjs.js +378 -0
- package/dist/clients/cost-management/CostManagementSlimClient.cjs.js.map +1 -0
- package/dist/clients/cost-management/CostManagementSlimClient.esm.js +372 -0
- package/dist/clients/cost-management/CostManagementSlimClient.esm.js.map +1 -0
- package/dist/clients/optimizations/OptimizationsClient.cjs.js +99 -0
- package/dist/clients/optimizations/OptimizationsClient.cjs.js.map +1 -0
- package/dist/clients/optimizations/OptimizationsClient.esm.js +92 -0
- package/dist/clients/optimizations/OptimizationsClient.esm.js.map +1 -0
- package/dist/clients/orchestrator-slim/OrchestratorSlimClient.cjs.js +107 -0
- package/dist/clients/orchestrator-slim/OrchestratorSlimClient.cjs.js.map +1 -0
- package/dist/clients/orchestrator-slim/OrchestratorSlimClient.esm.js +105 -0
- package/dist/clients/orchestrator-slim/OrchestratorSlimClient.esm.js.map +1 -0
- package/dist/clients.cjs.js +12 -0
- package/dist/clients.cjs.js.map +1 -0
- package/dist/clients.d.ts +432 -0
- package/dist/clients.esm.js +4 -0
- package/dist/clients.esm.js.map +1 -0
- package/dist/generated/apis/DefaultApi.client.cjs.js +91 -0
- package/dist/generated/apis/DefaultApi.client.cjs.js.map +1 -0
- package/dist/generated/apis/DefaultApi.client.esm.js +66 -0
- package/dist/generated/apis/DefaultApi.client.esm.js.map +1 -0
- package/dist/generated/pluginId.cjs.js +6 -0
- package/dist/generated/pluginId.cjs.js.map +1 -0
- package/dist/generated/pluginId.esm.js +4 -0
- package/dist/generated/pluginId.esm.js.map +1 -0
- package/dist/index.cjs.js +14 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.esm.js +5 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/json-utils.cjs.js +22 -0
- package/dist/json-utils.cjs.js.map +1 -0
- package/dist/json-utils.d.ts +46 -0
- package/dist/json-utils.esm.js +20 -0
- package/dist/json-utils.esm.js.map +1 -0
- package/dist/models.cjs.js +3 -0
- package/dist/models.cjs.js.map +1 -0
- package/dist/models.d.ts +25 -0
- package/dist/models.esm.js +2 -0
- package/dist/models.esm.js.map +1 -0
- package/dist/permissions.cjs.js +47 -0
- package/dist/permissions.cjs.js.map +1 -0
- package/dist/permissions.d.ts +24 -0
- package/dist/permissions.esm.js +36 -0
- package/dist/permissions.esm.js.map +1 -0
- package/dist/types/RecommendationList.model.d-J74WXrJI.d.ts +414 -0
- package/dist/util/lib/json.cjs.js +20 -0
- package/dist/util/lib/json.cjs.js.map +1 -0
- package/dist/util/lib/json.esm.js +15 -0
- package/dist/util/lib/json.esm.js.map +1 -0
- package/dist/util/lib/json_node.cjs.js +191 -0
- package/dist/util/lib/json_node.cjs.js.map +1 -0
- package/dist/util/lib/json_node.esm.js +189 -0
- package/dist/util/lib/json_node.esm.js.map +1 -0
- package/package.json +124 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
interface CostRecommendationConfigLimitsCpu {
|
|
3
|
+
amount?: number;
|
|
4
|
+
format?: string | null;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** @public */
|
|
8
|
+
interface CostRecommendationConfigLimitsMemory {
|
|
9
|
+
amount?: number;
|
|
10
|
+
format?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** @public */
|
|
14
|
+
interface CostRecommendationConfigLimits {
|
|
15
|
+
cpu?: CostRecommendationConfigLimitsCpu;
|
|
16
|
+
memory?: CostRecommendationConfigLimitsMemory;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** @public */
|
|
20
|
+
interface CostRecommendationConfigRequestsCpu {
|
|
21
|
+
amount?: number;
|
|
22
|
+
format?: string | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @public */
|
|
26
|
+
interface CostRecommendationConfigRequestsMemory {
|
|
27
|
+
amount?: number;
|
|
28
|
+
format?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @public */
|
|
32
|
+
interface CostRecommendationConfigRequests {
|
|
33
|
+
cpu?: CostRecommendationConfigRequestsCpu;
|
|
34
|
+
memory?: CostRecommendationConfigRequestsMemory;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** @public */
|
|
38
|
+
interface CostRecommendationConfig {
|
|
39
|
+
limits?: CostRecommendationConfigLimits;
|
|
40
|
+
requests?: CostRecommendationConfigRequests;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** @public */
|
|
44
|
+
interface CPULimitOptimisedNotification323005 {
|
|
45
|
+
code?: number;
|
|
46
|
+
message?: string;
|
|
47
|
+
type?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** @public */
|
|
51
|
+
interface CPURequestOptimisedNotification323004 {
|
|
52
|
+
code?: number;
|
|
53
|
+
message?: string;
|
|
54
|
+
type?: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @public */
|
|
58
|
+
interface MemoryLimitOptimisedNotification324004 {
|
|
59
|
+
code?: number;
|
|
60
|
+
message?: string;
|
|
61
|
+
type?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** @public */
|
|
65
|
+
interface MemoryRequestOptimisedNotification324003 {
|
|
66
|
+
code?: number;
|
|
67
|
+
message?: string;
|
|
68
|
+
type?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** @public */
|
|
72
|
+
interface CostRecommendationNotifications {
|
|
73
|
+
_323004?: CPURequestOptimisedNotification323004;
|
|
74
|
+
_323005?: CPULimitOptimisedNotification323005;
|
|
75
|
+
_324003?: MemoryRequestOptimisedNotification324003;
|
|
76
|
+
_324004?: MemoryLimitOptimisedNotification324004;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** @public */
|
|
80
|
+
interface CostRecommendationVariationLimitsCpu {
|
|
81
|
+
amount?: number;
|
|
82
|
+
format?: string | null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** @public */
|
|
86
|
+
interface CostRecommendationVariationLimitsMemory {
|
|
87
|
+
amount?: number;
|
|
88
|
+
format?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** @public */
|
|
92
|
+
interface CostRecommendationVariationLimits {
|
|
93
|
+
cpu?: CostRecommendationVariationLimitsCpu;
|
|
94
|
+
memory?: CostRecommendationVariationLimitsMemory;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** @public */
|
|
98
|
+
interface CostRecommendationVariationRequestsCpu {
|
|
99
|
+
amount?: number;
|
|
100
|
+
format?: string | null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** @public */
|
|
104
|
+
interface CostRecommendationVariationRequestsMemory {
|
|
105
|
+
amount?: number;
|
|
106
|
+
format?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** @public */
|
|
110
|
+
interface CostRecommendationVariationRequests {
|
|
111
|
+
cpu?: CostRecommendationVariationRequestsCpu;
|
|
112
|
+
memory?: CostRecommendationVariationRequestsMemory;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** @public */
|
|
116
|
+
interface CostRecommendationVariation {
|
|
117
|
+
limits?: CostRecommendationVariationLimits;
|
|
118
|
+
requests?: CostRecommendationVariationRequests;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** @public */
|
|
122
|
+
interface CostRecommendation {
|
|
123
|
+
config?: CostRecommendationConfig;
|
|
124
|
+
notifications?: CostRecommendationNotifications;
|
|
125
|
+
podsCount?: number;
|
|
126
|
+
variation?: CostRecommendationVariation;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** @public */
|
|
130
|
+
interface PerformanceRecommendationConfigLimitsCpu {
|
|
131
|
+
amount?: number;
|
|
132
|
+
format?: string | null;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** @public */
|
|
136
|
+
interface PerformanceRecommendationConfigLimitsMemory {
|
|
137
|
+
amount?: number;
|
|
138
|
+
format?: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** @public */
|
|
142
|
+
interface PerformanceRecommendationConfigLimits {
|
|
143
|
+
cpu?: PerformanceRecommendationConfigLimitsCpu;
|
|
144
|
+
memory?: PerformanceRecommendationConfigLimitsMemory;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** @public */
|
|
148
|
+
interface PerformanceRecommendationConfigRequestsCpu {
|
|
149
|
+
amount?: number;
|
|
150
|
+
format?: string | null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** @public */
|
|
154
|
+
interface PerformanceRecommendationConfigRequestsMemory {
|
|
155
|
+
amount?: number;
|
|
156
|
+
format?: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** @public */
|
|
160
|
+
interface PerformanceRecommendationConfigRequests {
|
|
161
|
+
cpu?: PerformanceRecommendationConfigRequestsCpu;
|
|
162
|
+
memory?: PerformanceRecommendationConfigRequestsMemory;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** @public */
|
|
166
|
+
interface PerformanceRecommendationConfig {
|
|
167
|
+
limits?: PerformanceRecommendationConfigLimits;
|
|
168
|
+
requests?: PerformanceRecommendationConfigRequests;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** @public */
|
|
172
|
+
interface PerformanceRecommendationVariationLimitsCpu {
|
|
173
|
+
amount?: number;
|
|
174
|
+
format?: string | null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** @public */
|
|
178
|
+
interface PerformanceRecommendationVariationLimitsMemory {
|
|
179
|
+
amount?: number;
|
|
180
|
+
format?: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** @public */
|
|
184
|
+
interface PerformanceRecommendationVariationLimits {
|
|
185
|
+
cpu?: PerformanceRecommendationVariationLimitsCpu;
|
|
186
|
+
memory?: PerformanceRecommendationVariationLimitsMemory;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** @public */
|
|
190
|
+
interface PerformanceRecommendationVariationRequestsCpu {
|
|
191
|
+
amount?: number;
|
|
192
|
+
format?: string | null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** @public */
|
|
196
|
+
interface PerformanceRecommendationVariationRequests {
|
|
197
|
+
cpu?: PerformanceRecommendationVariationRequestsCpu;
|
|
198
|
+
memory?: CostRecommendationVariationLimitsMemory;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** @public */
|
|
202
|
+
interface PerformanceRecommendationVariation {
|
|
203
|
+
limits?: PerformanceRecommendationVariationLimits;
|
|
204
|
+
requests?: PerformanceRecommendationVariationRequests;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** @public */
|
|
208
|
+
interface PerformanceRecommendation {
|
|
209
|
+
config?: PerformanceRecommendationConfig;
|
|
210
|
+
notifications?: CostRecommendationNotifications;
|
|
211
|
+
podsCount?: number;
|
|
212
|
+
variation?: PerformanceRecommendationVariation;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** @public */
|
|
216
|
+
interface LongTermRecommendationRecommendationEngines {
|
|
217
|
+
cost?: CostRecommendation;
|
|
218
|
+
performance?: PerformanceRecommendation;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** @public */
|
|
222
|
+
interface CpuUsage {
|
|
223
|
+
format?: string;
|
|
224
|
+
max?: number;
|
|
225
|
+
median?: number;
|
|
226
|
+
min?: number;
|
|
227
|
+
q1?: number;
|
|
228
|
+
q3?: number;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** @public */
|
|
232
|
+
interface MemoryUsage {
|
|
233
|
+
format?: string;
|
|
234
|
+
max?: number;
|
|
235
|
+
median?: number;
|
|
236
|
+
min?: number;
|
|
237
|
+
q1?: number;
|
|
238
|
+
q3?: number;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** @public */
|
|
242
|
+
interface PlotDetailsValue {
|
|
243
|
+
cpuUsage?: CpuUsage;
|
|
244
|
+
memoryUsage?: MemoryUsage;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** @public */
|
|
248
|
+
interface PlotsData {
|
|
249
|
+
datapoints?: number;
|
|
250
|
+
plotsData?: {
|
|
251
|
+
[key: string]: PlotDetailsValue;
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** @public */
|
|
256
|
+
interface LongTermRecommendationBoxPlots {
|
|
257
|
+
durationInHours?: number;
|
|
258
|
+
monitoringStartTime?: Date;
|
|
259
|
+
plots?: PlotsData;
|
|
260
|
+
recommendationEngines?: LongTermRecommendationRecommendationEngines;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** @public */
|
|
264
|
+
interface MediumTermRecommendationBoxPlots {
|
|
265
|
+
durationInHours?: number;
|
|
266
|
+
monitoringStartTime?: Date;
|
|
267
|
+
plots?: PlotsData;
|
|
268
|
+
recommendationEngines?: LongTermRecommendationRecommendationEngines;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** @public */
|
|
272
|
+
interface ShortTermRecommendationBoxPlots {
|
|
273
|
+
durationInHours?: number;
|
|
274
|
+
monitoringStartTime?: Date;
|
|
275
|
+
plots?: PlotsData;
|
|
276
|
+
recommendationEngines?: LongTermRecommendationRecommendationEngines;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** @public */
|
|
280
|
+
interface RecommendationBoxPlotsRecommendationsRecommendationTerms {
|
|
281
|
+
longTerm?: LongTermRecommendationBoxPlots;
|
|
282
|
+
mediumTerm?: MediumTermRecommendationBoxPlots;
|
|
283
|
+
shortTerm?: ShortTermRecommendationBoxPlots;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** @public */
|
|
287
|
+
interface RecommendationsRecommendationsCurrentLimitsCpu {
|
|
288
|
+
amount?: number;
|
|
289
|
+
format?: string | null;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** @public */
|
|
293
|
+
interface RecommendationsRecommendationsCurrentLimitsMemory {
|
|
294
|
+
amount?: number;
|
|
295
|
+
format?: string;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** @public */
|
|
299
|
+
interface RecommendationsRecommendationsCurrentLimits {
|
|
300
|
+
cpu?: RecommendationsRecommendationsCurrentLimitsCpu;
|
|
301
|
+
memory?: RecommendationsRecommendationsCurrentLimitsMemory;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** @public */
|
|
305
|
+
interface RecommendationsRecommendationsCurrentRequestsMemory {
|
|
306
|
+
amount?: number;
|
|
307
|
+
format?: string;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** @public */
|
|
311
|
+
interface RecommendationsRecommendationsCurrentRequests {
|
|
312
|
+
cpu?: RecommendationsRecommendationsCurrentLimitsCpu;
|
|
313
|
+
memory?: RecommendationsRecommendationsCurrentRequestsMemory;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** @public */
|
|
317
|
+
interface RecommendationsRecommendationsCurrent {
|
|
318
|
+
limits?: RecommendationsRecommendationsCurrentLimits;
|
|
319
|
+
requests?: RecommendationsRecommendationsCurrentRequests;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** @public */
|
|
323
|
+
interface RecommendationBoxPlotsRecommendations {
|
|
324
|
+
current?: RecommendationsRecommendationsCurrent;
|
|
325
|
+
monitoringEndTime?: Date;
|
|
326
|
+
recommendationTerms?: RecommendationBoxPlotsRecommendationsRecommendationTerms;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** @public */
|
|
330
|
+
interface RecommendationBoxPlots {
|
|
331
|
+
clusterAlias?: string;
|
|
332
|
+
clusterUuid?: string;
|
|
333
|
+
container?: string;
|
|
334
|
+
id?: string;
|
|
335
|
+
lastReported?: Date;
|
|
336
|
+
project?: string;
|
|
337
|
+
recommendations?: RecommendationBoxPlotsRecommendations;
|
|
338
|
+
sourceId?: string;
|
|
339
|
+
workload?: string;
|
|
340
|
+
workloadType?: string;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** @public */
|
|
344
|
+
interface RecommendationListLinks {
|
|
345
|
+
first?: string;
|
|
346
|
+
previous?: string;
|
|
347
|
+
next?: string;
|
|
348
|
+
last?: string;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** @public */
|
|
352
|
+
interface RecommendationListMeta {
|
|
353
|
+
count?: number;
|
|
354
|
+
limit?: number;
|
|
355
|
+
offset?: number;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** @public */
|
|
359
|
+
interface LongTermRecommendation {
|
|
360
|
+
durationInHours?: number;
|
|
361
|
+
monitoringStartTime?: Date;
|
|
362
|
+
recommendationEngines?: LongTermRecommendationRecommendationEngines;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** @public */
|
|
366
|
+
interface MediumTermRecommendation {
|
|
367
|
+
durationInHours?: number;
|
|
368
|
+
monitoringStartTime?: Date;
|
|
369
|
+
recommendationEngines?: LongTermRecommendationRecommendationEngines;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** @public */
|
|
373
|
+
interface ShortTermRecommendation {
|
|
374
|
+
durationInHours?: number;
|
|
375
|
+
monitoringStartTime?: Date;
|
|
376
|
+
recommendationEngines?: LongTermRecommendationRecommendationEngines;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** @public */
|
|
380
|
+
interface RecommendationsRecommendationsRecommendationTerms {
|
|
381
|
+
longTerm?: LongTermRecommendation;
|
|
382
|
+
mediumTerm?: MediumTermRecommendation;
|
|
383
|
+
shortTerm?: ShortTermRecommendation;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** @public */
|
|
387
|
+
interface RecommendationsRecommendations {
|
|
388
|
+
current?: RecommendationsRecommendationsCurrent;
|
|
389
|
+
monitoringEndTime?: Date;
|
|
390
|
+
recommendationTerms?: RecommendationsRecommendationsRecommendationTerms;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** @public */
|
|
394
|
+
interface Recommendations {
|
|
395
|
+
clusterAlias?: string;
|
|
396
|
+
clusterUuid?: string;
|
|
397
|
+
container?: string;
|
|
398
|
+
id?: string;
|
|
399
|
+
lastReported?: Date;
|
|
400
|
+
project?: string;
|
|
401
|
+
recommendations?: RecommendationsRecommendations;
|
|
402
|
+
sourceId?: string;
|
|
403
|
+
workload?: string;
|
|
404
|
+
workloadType?: string;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/** @public */
|
|
408
|
+
interface RecommendationList {
|
|
409
|
+
data?: Array<Recommendations>;
|
|
410
|
+
meta?: RecommendationListMeta;
|
|
411
|
+
links?: RecommendationListLinks;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export type { RecommendationsRecommendationsCurrentLimitsCpu as $, PerformanceRecommendationConfigLimitsCpu as A, PerformanceRecommendationConfigLimitsMemory as B, CPULimitOptimisedNotification323005 as C, PerformanceRecommendationConfigRequests as D, PerformanceRecommendationConfigRequestsCpu as E, PerformanceRecommendationConfigRequestsMemory as F, PerformanceRecommendationVariation as G, PerformanceRecommendationVariationLimits as H, PerformanceRecommendationVariationLimitsCpu as I, PerformanceRecommendationVariationLimitsMemory as J, PerformanceRecommendationVariationRequests as K, LongTermRecommendation as L, MediumTermRecommendation as M, PerformanceRecommendationVariationRequestsCpu as N, PlotDetailsValue as O, PerformanceRecommendation as P, PlotsData as Q, RecommendationBoxPlots as R, RecommendationBoxPlotsRecommendations as S, RecommendationBoxPlotsRecommendationsRecommendationTerms as T, RecommendationList as U, RecommendationListLinks as V, RecommendationListMeta as W, Recommendations as X, RecommendationsRecommendations as Y, RecommendationsRecommendationsCurrent as Z, RecommendationsRecommendationsCurrentLimits as _, CPURequestOptimisedNotification323004 as a, RecommendationsRecommendationsCurrentLimitsMemory as a0, RecommendationsRecommendationsCurrentRequests as a1, RecommendationsRecommendationsCurrentRequestsMemory as a2, RecommendationsRecommendationsRecommendationTerms as a3, ShortTermRecommendation as a4, ShortTermRecommendationBoxPlots as a5, CostRecommendation as b, CostRecommendationConfig as c, CostRecommendationConfigLimits as d, CostRecommendationConfigLimitsCpu as e, CostRecommendationConfigLimitsMemory as f, CostRecommendationConfigRequests as g, CostRecommendationConfigRequestsCpu as h, CostRecommendationConfigRequestsMemory as i, CostRecommendationNotifications as j, CostRecommendationVariation as k, CostRecommendationVariationLimits as l, CostRecommendationVariationLimitsCpu as m, CostRecommendationVariationLimitsMemory as n, CostRecommendationVariationRequests as o, CostRecommendationVariationRequestsCpu as p, CostRecommendationVariationRequestsMemory as q, CpuUsage as r, LongTermRecommendationBoxPlots as s, LongTermRecommendationRecommendationEngines as t, MediumTermRecommendationBoxPlots as u, MemoryLimitOptimisedNotification324004 as v, MemoryRequestOptimisedNotification324003 as w, MemoryUsage as x, PerformanceRecommendationConfig as y, PerformanceRecommendationConfigLimits as z };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isJsonScalar(value) {
|
|
4
|
+
return typeof value === "number" || typeof value === "string" || typeof value === "boolean" || value === null;
|
|
5
|
+
}
|
|
6
|
+
function maybeJsonObject(value) {
|
|
7
|
+
return value?.constructor.name === "Object";
|
|
8
|
+
}
|
|
9
|
+
function maybeJsonArray(value) {
|
|
10
|
+
return Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
function maybeJsonValue(value) {
|
|
13
|
+
return typeof value !== "undefined" && (isJsonScalar(value) || maybeJsonObject(value) || maybeJsonArray(value));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.isJsonScalar = isJsonScalar;
|
|
17
|
+
exports.maybeJsonArray = maybeJsonArray;
|
|
18
|
+
exports.maybeJsonObject = maybeJsonObject;
|
|
19
|
+
exports.maybeJsonValue = maybeJsonValue;
|
|
20
|
+
//# sourceMappingURL=json.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.cjs.js","sources":["../../../src/util/lib/json.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\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\nexport type JsonScalar = number | string | boolean | null;\n\n/** Asserts `value` is a JsonScalar */\nexport function isJsonScalar(value: unknown): value is JsonScalar {\n return (\n typeof value === 'number' ||\n typeof value === 'string' ||\n typeof value === 'boolean' ||\n value === null\n );\n}\n\n/** A type representing a JSON object */\nexport type JsonObject = {\n [key in string]?: JsonValue;\n};\n\n/** Asserts non-recursively that `value` may be a JsonObject */\nexport function maybeJsonObject(value: unknown): value is JsonObject {\n return value?.constructor.name === 'Object';\n}\n\n/** A type representing JSON array */\nexport type JsonArray = Array<JsonValue>;\n\n/** Asserts non-recursively that `value` may be a JsonArray */\nexport function maybeJsonArray(value: unknown): value is JsonArray {\n return Array.isArray(value);\n}\n\n/** A type representing all valid JSON serializable values. */\nexport type JsonValue = JsonObject | JsonArray | JsonScalar;\n\n/** Asserts that `value` may be a JsonValue */\nexport function maybeJsonValue(value: unknown): value is JsonValue {\n return (\n typeof value !== 'undefined' &&\n (isJsonScalar(value) || maybeJsonObject(value) || maybeJsonArray(value))\n );\n}\n"],"names":[],"mappings":";;AAmBO,SAAS,aAAa,KAAqC,EAAA;AAChE,EACE,OAAA,OAAO,UAAU,QACjB,IAAA,OAAO,UAAU,QACjB,IAAA,OAAO,KAAU,KAAA,SAAA,IACjB,KAAU,KAAA,IAAA;AAEd;AAQO,SAAS,gBAAgB,KAAqC,EAAA;AACnE,EAAO,OAAA,KAAA,EAAO,YAAY,IAAS,KAAA,QAAA;AACrC;AAMO,SAAS,eAAe,KAAoC,EAAA;AACjE,EAAO,OAAA,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5B;AAMO,SAAS,eAAe,KAAoC,EAAA;AACjE,EACE,OAAA,OAAO,KAAU,KAAA,WAAA,KAChB,YAAa,CAAA,KAAK,KAAK,eAAgB,CAAA,KAAK,CAAK,IAAA,cAAA,CAAe,KAAK,CAAA,CAAA;AAE1E;;;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function isJsonScalar(value) {
|
|
2
|
+
return typeof value === "number" || typeof value === "string" || typeof value === "boolean" || value === null;
|
|
3
|
+
}
|
|
4
|
+
function maybeJsonObject(value) {
|
|
5
|
+
return value?.constructor.name === "Object";
|
|
6
|
+
}
|
|
7
|
+
function maybeJsonArray(value) {
|
|
8
|
+
return Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function maybeJsonValue(value) {
|
|
11
|
+
return typeof value !== "undefined" && (isJsonScalar(value) || maybeJsonObject(value) || maybeJsonArray(value));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { isJsonScalar, maybeJsonArray, maybeJsonObject, maybeJsonValue };
|
|
15
|
+
//# sourceMappingURL=json.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.esm.js","sources":["../../../src/util/lib/json.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\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\nexport type JsonScalar = number | string | boolean | null;\n\n/** Asserts `value` is a JsonScalar */\nexport function isJsonScalar(value: unknown): value is JsonScalar {\n return (\n typeof value === 'number' ||\n typeof value === 'string' ||\n typeof value === 'boolean' ||\n value === null\n );\n}\n\n/** A type representing a JSON object */\nexport type JsonObject = {\n [key in string]?: JsonValue;\n};\n\n/** Asserts non-recursively that `value` may be a JsonObject */\nexport function maybeJsonObject(value: unknown): value is JsonObject {\n return value?.constructor.name === 'Object';\n}\n\n/** A type representing JSON array */\nexport type JsonArray = Array<JsonValue>;\n\n/** Asserts non-recursively that `value` may be a JsonArray */\nexport function maybeJsonArray(value: unknown): value is JsonArray {\n return Array.isArray(value);\n}\n\n/** A type representing all valid JSON serializable values. */\nexport type JsonValue = JsonObject | JsonArray | JsonScalar;\n\n/** Asserts that `value` may be a JsonValue */\nexport function maybeJsonValue(value: unknown): value is JsonValue {\n return (\n typeof value !== 'undefined' &&\n (isJsonScalar(value) || maybeJsonObject(value) || maybeJsonArray(value))\n );\n}\n"],"names":[],"mappings":"AAmBO,SAAS,aAAa,KAAqC,EAAA;AAChE,EACE,OAAA,OAAO,UAAU,QACjB,IAAA,OAAO,UAAU,QACjB,IAAA,OAAO,KAAU,KAAA,SAAA,IACjB,KAAU,KAAA,IAAA;AAEd;AAQO,SAAS,gBAAgB,KAAqC,EAAA;AACnE,EAAO,OAAA,KAAA,EAAO,YAAY,IAAS,KAAA,QAAA;AACrC;AAMO,SAAS,eAAe,KAAoC,EAAA;AACjE,EAAO,OAAA,KAAA,CAAM,QAAQ,KAAK,CAAA;AAC5B;AAMO,SAAS,eAAe,KAAoC,EAAA;AACjE,EACE,OAAA,OAAO,KAAU,KAAA,WAAA,KAChB,YAAa,CAAA,KAAK,KAAK,eAAgB,CAAA,KAAK,CAAK,IAAA,cAAA,CAAe,KAAK,CAAA,CAAA;AAE1E;;;;"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var json = require('./json.cjs.js');
|
|
4
|
+
|
|
5
|
+
const refs = /* @__PURE__ */ new Set();
|
|
6
|
+
function detectCircularReference(nodeValue) {
|
|
7
|
+
if (refs.has(nodeValue)) {
|
|
8
|
+
throw new TypeError("Converting circular structure");
|
|
9
|
+
} else {
|
|
10
|
+
refs.add(nodeValue);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
class Visitor {
|
|
14
|
+
#onVisitObjectKey;
|
|
15
|
+
#skipList;
|
|
16
|
+
#isDebugEnabled;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.#onVisitObjectKey = options?.onVisitJsonObjectKey;
|
|
19
|
+
this.#skipList = options?.skipList ?? [];
|
|
20
|
+
this.#isDebugEnabled = options?.debug ?? false;
|
|
21
|
+
}
|
|
22
|
+
visitScalar(node) {
|
|
23
|
+
if (this.#isDebugEnabled) {
|
|
24
|
+
console.log(node.jsonpath);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
visitArray(node) {
|
|
28
|
+
if (this.#isDebugEnabled) {
|
|
29
|
+
console.log(node.jsonpath);
|
|
30
|
+
}
|
|
31
|
+
node.children?.forEach((child) => child.accept(this));
|
|
32
|
+
}
|
|
33
|
+
visitObject(node) {
|
|
34
|
+
if (this.#isDebugEnabled) {
|
|
35
|
+
console.log(node.jsonpath);
|
|
36
|
+
}
|
|
37
|
+
node.children?.forEach((child) => {
|
|
38
|
+
const newKey = this.#skipList.some((regex) => regex.test(child.jsonpath)) ? child.key : this.#onVisitObjectKey?.(child.key) ?? child.key;
|
|
39
|
+
child.key = newKey;
|
|
40
|
+
child.accept(this);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
class JsonNode {
|
|
45
|
+
static Visitor = Visitor;
|
|
46
|
+
static #toJsonPathSegment(value) {
|
|
47
|
+
if (typeof value === "number") {
|
|
48
|
+
return `[${value}]`;
|
|
49
|
+
}
|
|
50
|
+
const regex = /(\s|\.)/;
|
|
51
|
+
return regex.test(value) ? `['${value}']` : `.${value}`;
|
|
52
|
+
}
|
|
53
|
+
#parent;
|
|
54
|
+
#children;
|
|
55
|
+
#kind;
|
|
56
|
+
#value;
|
|
57
|
+
#jsonpath;
|
|
58
|
+
key;
|
|
59
|
+
/**
|
|
60
|
+
* Constructs a new Node instance.
|
|
61
|
+
*
|
|
62
|
+
* @param key - The key associated with this node, which can be a string or number.
|
|
63
|
+
* @param value - The value associated with this node.
|
|
64
|
+
* @param parent - The parent node of this node, if any.
|
|
65
|
+
*
|
|
66
|
+
* @throws {TypeError} If the key is not "$" and the parent node is not provided.
|
|
67
|
+
*/
|
|
68
|
+
constructor(key, value, parent) {
|
|
69
|
+
this.key = key;
|
|
70
|
+
this.#value = value;
|
|
71
|
+
this.#jsonpath = [];
|
|
72
|
+
if (key === "$") {
|
|
73
|
+
this.#parent = null;
|
|
74
|
+
this.#jsonpath.push(key);
|
|
75
|
+
} else {
|
|
76
|
+
if (!parent) {
|
|
77
|
+
throw new TypeError("Parent node is required");
|
|
78
|
+
}
|
|
79
|
+
this.#parent = parent;
|
|
80
|
+
this.#jsonpath.push(
|
|
81
|
+
...this.#parent.jsonpath,
|
|
82
|
+
`${JsonNode.#toJsonPathSegment(key)}`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
switch (true) {
|
|
86
|
+
case json.maybeJsonArray(value):
|
|
87
|
+
detectCircularReference(value);
|
|
88
|
+
this.#kind = "array";
|
|
89
|
+
this.#children = value.map(
|
|
90
|
+
(jsonValue, idx) => new JsonNode(idx, jsonValue, this)
|
|
91
|
+
);
|
|
92
|
+
break;
|
|
93
|
+
case json.maybeJsonObject(value):
|
|
94
|
+
detectCircularReference(value);
|
|
95
|
+
this.#kind = "object";
|
|
96
|
+
this.#children = [];
|
|
97
|
+
for (const [k, jsonValue] of Object.entries(value)) {
|
|
98
|
+
if (typeof jsonValue !== "undefined") {
|
|
99
|
+
this.#children.push(new JsonNode(k, jsonValue, this));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
this.#kind = "scalar";
|
|
105
|
+
this.#children = null;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
if (this.parent === null) {
|
|
109
|
+
refs.clear();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
get value() {
|
|
113
|
+
return this.#value;
|
|
114
|
+
}
|
|
115
|
+
get kind() {
|
|
116
|
+
return this.#kind;
|
|
117
|
+
}
|
|
118
|
+
get parent() {
|
|
119
|
+
return this.#parent;
|
|
120
|
+
}
|
|
121
|
+
get children() {
|
|
122
|
+
return this.#children;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Returns the JSONPath expression corresponding to this node's location in the data structure.
|
|
126
|
+
*
|
|
127
|
+
* @returns {string} The JSONPath expression.
|
|
128
|
+
*/
|
|
129
|
+
get jsonpath() {
|
|
130
|
+
return this.#jsonpath.join("");
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Accepts a visitor and calls the appropriate visit method based on the node's kind.
|
|
134
|
+
*
|
|
135
|
+
* @param visitor - The visitor instance that will process the node.
|
|
136
|
+
*
|
|
137
|
+
* The method will call one of the following visitor methods based on the node's kind:
|
|
138
|
+
* - `visitScalar` if the node is a scalar.
|
|
139
|
+
* - `visitArray` if the node is an array.
|
|
140
|
+
* - `visitObject` if the node is an object.
|
|
141
|
+
*/
|
|
142
|
+
accept(visitor) {
|
|
143
|
+
switch (this.#kind) {
|
|
144
|
+
case "scalar":
|
|
145
|
+
visitor.visitScalar(this);
|
|
146
|
+
break;
|
|
147
|
+
case "array":
|
|
148
|
+
visitor.visitArray(this);
|
|
149
|
+
break;
|
|
150
|
+
case "object":
|
|
151
|
+
visitor.visitObject(this);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Converts the current instance to a JSON value.
|
|
157
|
+
*
|
|
158
|
+
* Depending on the type of the instance (`scalar`, `array`, or `object`),
|
|
159
|
+
* this method will return the corresponding JSON representation.
|
|
160
|
+
*
|
|
161
|
+
* - If the instance is a scalar, it returns the scalar value.
|
|
162
|
+
* - If the instance is an array, it returns an array of JSON values by
|
|
163
|
+
* recursively calling `toJsonValue` on each child.
|
|
164
|
+
* - If the instance is an object, it returns a JSON object by recursively
|
|
165
|
+
* calling `toJsonValue` on each child and using their keys as the object's keys.
|
|
166
|
+
*
|
|
167
|
+
* @returns {JsonValue} The JSON representation of the current instance.
|
|
168
|
+
*/
|
|
169
|
+
toJsonValue() {
|
|
170
|
+
let obj = {};
|
|
171
|
+
switch (this.#kind) {
|
|
172
|
+
case "scalar":
|
|
173
|
+
obj = this.#value;
|
|
174
|
+
break;
|
|
175
|
+
case "array":
|
|
176
|
+
obj = this.#children.map((child) => child.toJsonValue());
|
|
177
|
+
break;
|
|
178
|
+
case "object": {
|
|
179
|
+
const tmpObj = {};
|
|
180
|
+
for (const child of this.#children ?? []) {
|
|
181
|
+
tmpObj[child.key] = child.toJsonValue();
|
|
182
|
+
}
|
|
183
|
+
obj = tmpObj;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return obj;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
exports.JsonNode = JsonNode;
|
|
191
|
+
//# sourceMappingURL=json_node.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json_node.cjs.js","sources":["../../../src/util/lib/json_node.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\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\n/* eslint-disable no-console */\n/* eslint-disable default-case */\n/*\n * Copyright 2025 The Backstage Authors\n *\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 {\n type JsonArray,\n type JsonObject,\n type JsonScalar,\n type JsonValue,\n maybeJsonArray,\n maybeJsonObject,\n} from './json';\nimport type { JsonNodeVisitor } from './json_node_visitor';\n\nconst refs = new Set<JsonObject | JsonArray>();\nfunction detectCircularReference(nodeValue: JsonObject | JsonArray): void {\n if (refs.has(nodeValue)) {\n throw new TypeError('Converting circular structure');\n } else {\n refs.add(nodeValue);\n }\n}\n\nexport type ObjectKeyMutatorFunction = (key: string | number) => string;\n\n/**\n * Options for configuring the JSON visitor.\n */\nexport interface JsonNodeVisitorOptions {\n /**\n * A list of regular expression matching the JSONPath (RFC 9535) of a key in the data structure.\n * Every time a key is found in the data structure, its JSONPath is tested for a match against the entries in the list.\n * If at least one match is found, then that key won't be processed by the `JsonNodeVisitorOptions#onVisitJsonObjectKey` callback.\n */\n skipList?: Array<RegExp>;\n\n /**\n * An optional flag to enable debug mode.\n * When set to true, each time a node is visited, its JSONPath will be logged.\n */\n debug?: boolean;\n\n /**\n * A function that can be used to process the object keys names.\n * The string returned by this function will be used to replace the name of the object key being visited.\n */\n onVisitJsonObjectKey?: ObjectKeyMutatorFunction;\n}\n\nclass Visitor implements JsonNodeVisitor {\n readonly #onVisitObjectKey?: ObjectKeyMutatorFunction;\n readonly #skipList: Array<RegExp>;\n readonly #isDebugEnabled: boolean;\n\n constructor(options?: JsonNodeVisitorOptions) {\n this.#onVisitObjectKey = options?.onVisitJsonObjectKey;\n this.#skipList = options?.skipList ?? [];\n this.#isDebugEnabled = options?.debug ?? false;\n }\n\n visitScalar(node: JsonNode<JsonScalar>): void {\n if (this.#isDebugEnabled) {\n console.log(node.jsonpath);\n }\n }\n\n visitArray(node: JsonNode<JsonArray>): void {\n if (this.#isDebugEnabled) {\n console.log(node.jsonpath);\n }\n\n node.children?.forEach(child => child.accept(this));\n }\n\n visitObject(node: JsonNode<JsonObject>): void {\n if (this.#isDebugEnabled) {\n console.log(node.jsonpath);\n }\n\n node.children?.forEach(child => {\n const newKey = this.#skipList.some(regex => regex.test(child.jsonpath))\n ? child.key\n : this.#onVisitObjectKey?.(child.key) ?? child.key;\n child.key = newKey;\n child.accept(this);\n });\n }\n}\n\n/** Represents a node in a tree structure where each node can be a scalar, array, or object. */\nexport class JsonNode<T extends JsonValue> {\n static readonly Visitor = Visitor;\n static #toJsonPathSegment(value: string | number): string {\n if (typeof value === 'number') {\n return `[${value}]`;\n }\n\n const regex = /(\\s|\\.)/;\n return regex.test(value) ? `['${value}']` : `.${value}`;\n }\n\n readonly #parent: JsonNode<JsonValue> | null;\n readonly #children: Array<JsonNode<JsonValue>> | null;\n readonly #kind: 'scalar' | 'array' | 'object';\n readonly #value: T;\n readonly #jsonpath: Array<string>;\n key: string | number;\n\n /**\n * Constructs a new Node instance.\n *\n * @param key - The key associated with this node, which can be a string or number.\n * @param value - The value associated with this node.\n * @param parent - The parent node of this node, if any.\n *\n * @throws {TypeError} If the key is not \"$\" and the parent node is not provided.\n */\n constructor(key: string | number, value: T, parent?: JsonNode<T>) {\n this.key = key;\n this.#value = value;\n this.#jsonpath = [];\n\n if (key === '$') {\n this.#parent = null;\n this.#jsonpath.push(key);\n } else {\n if (!parent) {\n throw new TypeError('Parent node is required');\n }\n\n this.#parent = parent;\n this.#jsonpath.push(\n ...this.#parent.jsonpath,\n `${JsonNode.#toJsonPathSegment(key)}`,\n );\n }\n\n switch (true) {\n case maybeJsonArray(value):\n detectCircularReference(value);\n this.#kind = 'array';\n this.#children = value.map(\n (jsonValue, idx) => new JsonNode(idx, jsonValue, this),\n );\n break;\n case maybeJsonObject(value):\n detectCircularReference(value);\n this.#kind = 'object';\n this.#children = [];\n for (const [k, jsonValue] of Object.entries(value)) {\n if (typeof jsonValue !== 'undefined') {\n this.#children.push(new JsonNode(k, jsonValue, this));\n }\n }\n break;\n default:\n this.#kind = 'scalar';\n this.#children = null;\n break;\n }\n\n if (this.parent === null) {\n refs.clear();\n }\n }\n\n get value(): T {\n return this.#value;\n }\n\n get kind(): 'scalar' | 'array' | 'object' {\n return this.#kind;\n }\n\n get parent(): JsonNode<JsonValue> | null {\n return this.#parent;\n }\n\n get children(): Array<JsonNode<JsonValue>> | null {\n return this.#children;\n }\n\n /**\n * Returns the JSONPath expression corresponding to this node's location in the data structure.\n *\n * @returns {string} The JSONPath expression.\n */\n get jsonpath(): string {\n return this.#jsonpath.join('');\n }\n\n /**\n * Accepts a visitor and calls the appropriate visit method based on the node's kind.\n *\n * @param visitor - The visitor instance that will process the node.\n *\n * The method will call one of the following visitor methods based on the node's kind:\n * - `visitScalar` if the node is a scalar.\n * - `visitArray` if the node is an array.\n * - `visitObject` if the node is an object.\n */\n accept(visitor: Visitor) {\n switch (this.#kind) {\n case 'scalar':\n visitor.visitScalar(this as JsonNode<JsonScalar>);\n break;\n case 'array':\n visitor.visitArray(this as JsonNode<JsonArray>);\n break;\n case 'object':\n visitor.visitObject(this as JsonNode<JsonObject>);\n break;\n }\n }\n\n /**\n * Converts the current instance to a JSON value.\n *\n * Depending on the type of the instance (`scalar`, `array`, or `object`),\n * this method will return the corresponding JSON representation.\n *\n * - If the instance is a scalar, it returns the scalar value.\n * - If the instance is an array, it returns an array of JSON values by\n * recursively calling `toJsonValue` on each child.\n * - If the instance is an object, it returns a JSON object by recursively\n * calling `toJsonValue` on each child and using their keys as the object's keys.\n *\n * @returns {JsonValue} The JSON representation of the current instance.\n */\n toJsonValue(): JsonValue {\n let obj: JsonValue = {};\n switch (this.#kind) {\n case 'scalar':\n obj = this.#value;\n break;\n case 'array':\n obj = this.#children!.map(child => child.toJsonValue());\n break;\n case 'object': {\n const tmpObj: JsonObject = {};\n for (const child of this.#children ?? []) {\n tmpObj[child.key] = child.toJsonValue();\n }\n obj = tmpObj;\n }\n }\n return obj;\n }\n}\n"],"names":["maybeJsonArray","maybeJsonObject"],"mappings":";;;;AA2CA,MAAM,IAAA,uBAAW,GAA4B,EAAA;AAC7C,SAAS,wBAAwB,SAAyC,EAAA;AACxE,EAAI,IAAA,IAAA,CAAK,GAAI,CAAA,SAAS,CAAG,EAAA;AACvB,IAAM,MAAA,IAAI,UAAU,+BAA+B,CAAA;AAAA,GAC9C,MAAA;AACL,IAAA,IAAA,CAAK,IAAI,SAAS,CAAA;AAAA;AAEtB;AA4BA,MAAM,OAAmC,CAAA;AAAA,EAC9B,iBAAA;AAAA,EACA,SAAA;AAAA,EACA,eAAA;AAAA,EAET,YAAY,OAAkC,EAAA;AAC5C,IAAA,IAAA,CAAK,oBAAoB,OAAS,EAAA,oBAAA;AAClC,IAAK,IAAA,CAAA,SAAA,GAAY,OAAS,EAAA,QAAA,IAAY,EAAC;AACvC,IAAK,IAAA,CAAA,eAAA,GAAkB,SAAS,KAAS,IAAA,KAAA;AAAA;AAC3C,EAEA,YAAY,IAAkC,EAAA;AAC5C,IAAA,IAAI,KAAK,eAAiB,EAAA;AACxB,MAAQ,OAAA,CAAA,GAAA,CAAI,KAAK,QAAQ,CAAA;AAAA;AAC3B;AACF,EAEA,WAAW,IAAiC,EAAA;AAC1C,IAAA,IAAI,KAAK,eAAiB,EAAA;AACxB,MAAQ,OAAA,CAAA,GAAA,CAAI,KAAK,QAAQ,CAAA;AAAA;AAG3B,IAAA,IAAA,CAAK,UAAU,OAAQ,CAAA,CAAA,KAAA,KAAS,KAAM,CAAA,MAAA,CAAO,IAAI,CAAC,CAAA;AAAA;AACpD,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