@juice-js/observability 1.1.0 → 1.2.0

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 (66) hide show
  1. package/README.md +4 -2
  2. package/fesm2022/juice-js-observability-agent.page-Vb7LDThl.mjs +1144 -0
  3. package/fesm2022/juice-js-observability-agent.page-Vb7LDThl.mjs.map +1 -0
  4. package/fesm2022/juice-js-observability-agents.page-Ch-tBwQO.mjs +413 -0
  5. package/fesm2022/juice-js-observability-agents.page-Ch-tBwQO.mjs.map +1 -0
  6. package/fesm2022/{juice-js-observability-alert.page-nEy5Gc6j.mjs → juice-js-observability-alert.page-2kfKksIG.mjs} +200 -4
  7. package/fesm2022/juice-js-observability-alert.page-2kfKksIG.mjs.map +1 -0
  8. package/fesm2022/{juice-js-observability-alerts.page-DUXXBanH.mjs → juice-js-observability-alerts.page-BNmez0Ak.mjs} +2 -2
  9. package/fesm2022/{juice-js-observability-alerts.page-DUXXBanH.mjs.map → juice-js-observability-alerts.page-BNmez0Ak.mjs.map} +1 -1
  10. package/fesm2022/juice-js-observability-approvals.page-DBLw-vl1.mjs +387 -0
  11. package/fesm2022/juice-js-observability-approvals.page-DBLw-vl1.mjs.map +1 -0
  12. package/fesm2022/juice-js-observability-incident.page-D2GvuIft.mjs +436 -0
  13. package/fesm2022/juice-js-observability-incident.page-D2GvuIft.mjs.map +1 -0
  14. package/fesm2022/juice-js-observability-incidents.page-DhC3BkBo.mjs +438 -0
  15. package/fesm2022/juice-js-observability-incidents.page-DhC3BkBo.mjs.map +1 -0
  16. package/fesm2022/juice-js-observability-load-runs.page-DVuO4zFp.mjs +349 -0
  17. package/fesm2022/juice-js-observability-load-runs.page-DVuO4zFp.mjs.map +1 -0
  18. package/fesm2022/{juice-js-observability-logs.page-i76xbJLH.mjs → juice-js-observability-logs.page-PXWQMcvL.mjs} +3 -3
  19. package/fesm2022/{juice-js-observability-logs.page-i76xbJLH.mjs.map → juice-js-observability-logs.page-PXWQMcvL.mjs.map} +1 -1
  20. package/fesm2022/{juice-js-observability-metrics.page-Cq5S0yGJ.mjs → juice-js-observability-metrics.page-Ctm_EEFb.mjs} +3 -3
  21. package/fesm2022/{juice-js-observability-metrics.page-Cq5S0yGJ.mjs.map → juice-js-observability-metrics.page-Ctm_EEFb.mjs.map} +1 -1
  22. package/fesm2022/juice-js-observability-notifications.page-CtcV3Ei4.mjs +758 -0
  23. package/fesm2022/juice-js-observability-notifications.page-CtcV3Ei4.mjs.map +1 -0
  24. package/fesm2022/{juice-js-observability-overview.page-DXZl_fUh.mjs → juice-js-observability-overview.page-BRGpTOyc.mjs} +3 -3
  25. package/fesm2022/{juice-js-observability-overview.page-DXZl_fUh.mjs.map → juice-js-observability-overview.page-BRGpTOyc.mjs.map} +1 -1
  26. package/fesm2022/{juice-js-observability-resource.page-CauDE6kK.mjs → juice-js-observability-resource.page-O4GGdirR.mjs} +2 -2
  27. package/fesm2022/{juice-js-observability-resource.page-CauDE6kK.mjs.map → juice-js-observability-resource.page-O4GGdirR.mjs.map} +1 -1
  28. package/fesm2022/{juice-js-observability-resources.page-CukW8vVc.mjs → juice-js-observability-resources.page-B_AVPpes.mjs} +2 -2
  29. package/fesm2022/{juice-js-observability-resources.page-CukW8vVc.mjs.map → juice-js-observability-resources.page-B_AVPpes.mjs.map} +1 -1
  30. package/fesm2022/juice-js-observability-rules.page-CARCWaw_.mjs +581 -0
  31. package/fesm2022/juice-js-observability-rules.page-CARCWaw_.mjs.map +1 -0
  32. package/fesm2022/juice-js-observability-service.page-DRj1GO0Q.mjs +1257 -0
  33. package/fesm2022/juice-js-observability-service.page-DRj1GO0Q.mjs.map +1 -0
  34. package/fesm2022/{juice-js-observability-services.page-B1huLe_a.mjs → juice-js-observability-services.page-BbFbbvyH.mjs} +3 -3
  35. package/fesm2022/{juice-js-observability-services.page-B1huLe_a.mjs.map → juice-js-observability-services.page-BbFbbvyH.mjs.map} +1 -1
  36. package/fesm2022/juice-js-observability-silences.page-CoTqfGxY.mjs +523 -0
  37. package/fesm2022/juice-js-observability-silences.page-CoTqfGxY.mjs.map +1 -0
  38. package/fesm2022/juice-js-observability-slo.page-l7TOat-D.mjs +414 -0
  39. package/fesm2022/juice-js-observability-slo.page-l7TOat-D.mjs.map +1 -0
  40. package/fesm2022/juice-js-observability-slos.page-DNG6g6_R.mjs +267 -0
  41. package/fesm2022/juice-js-observability-slos.page-DNG6g6_R.mjs.map +1 -0
  42. package/fesm2022/juice-js-observability-suggestions-eQK_z0Nd.mjs +367 -0
  43. package/fesm2022/juice-js-observability-suggestions-eQK_z0Nd.mjs.map +1 -0
  44. package/fesm2022/{juice-js-observability-telemetry-BftWSOaQ.mjs → juice-js-observability-telemetry-DVwUTHSz.mjs} +101 -91
  45. package/fesm2022/juice-js-observability-telemetry-DVwUTHSz.mjs.map +1 -0
  46. package/fesm2022/juice-js-observability-timeline.page-CFSigOgk.mjs +213 -0
  47. package/fesm2022/juice-js-observability-timeline.page-CFSigOgk.mjs.map +1 -0
  48. package/fesm2022/{juice-js-observability-topology.page-aMWEXyMB.mjs → juice-js-observability-topology.page-BDfNpiql.mjs} +56 -4
  49. package/fesm2022/juice-js-observability-topology.page-BDfNpiql.mjs.map +1 -0
  50. package/fesm2022/{juice-js-observability-trace.page-DUCWnZL5.mjs → juice-js-observability-trace.page-CdW09ADY.mjs} +10 -8
  51. package/fesm2022/juice-js-observability-trace.page-CdW09ADY.mjs.map +1 -0
  52. package/fesm2022/{juice-js-observability-traces.page-DXSDdeTH.mjs → juice-js-observability-traces.page-CMuItN_m.mjs} +3 -3
  53. package/fesm2022/{juice-js-observability-traces.page-DXSDdeTH.mjs.map → juice-js-observability-traces.page-CMuItN_m.mjs.map} +1 -1
  54. package/fesm2022/juice-js-observability.mjs +507 -110
  55. package/fesm2022/juice-js-observability.mjs.map +1 -1
  56. package/package.json +1 -1
  57. package/styles/_observability.scss +26 -3
  58. package/types/juice-js-observability.d.ts +623 -1
  59. package/fesm2022/juice-js-observability-alert.page-nEy5Gc6j.mjs.map +0 -1
  60. package/fesm2022/juice-js-observability-rules.page-Crb07uWm.mjs +0 -175
  61. package/fesm2022/juice-js-observability-rules.page-Crb07uWm.mjs.map +0 -1
  62. package/fesm2022/juice-js-observability-service.page-Dt8bN2Ry.mjs +0 -726
  63. package/fesm2022/juice-js-observability-service.page-Dt8bN2Ry.mjs.map +0 -1
  64. package/fesm2022/juice-js-observability-telemetry-BftWSOaQ.mjs.map +0 -1
  65. package/fesm2022/juice-js-observability-topology.page-aMWEXyMB.mjs.map +0 -1
  66. package/fesm2022/juice-js-observability-trace.page-DUCWnZL5.mjs.map +0 -1
@@ -1,108 +1,24 @@
1
1
  import * as i0 from "@angular/core";
2
- import { Injectable, InjectionToken, Pipe, computed, inject, makeEnvironmentProviders } from "@angular/core";
2
+ import { DestroyRef, Injectable, InjectionToken, Pipe, computed, effect, inject, makeEnvironmentProviders, provideEnvironmentInitializer, signal, untracked } from "@angular/core";
3
+ import { NavigationEnd, Router } from "@angular/router";
4
+ import { EMPTY, expand, filter, map, reduce, shareReplay, startWith, switchMap, tap, timer } from "rxjs";
3
5
  import { HttpClient, HttpParams } from "@angular/common/http";
4
- import { EMPTY, expand, filter, map, reduce, shareReplay, startWith, switchMap } from "rxjs";
5
6
  import { toSignal } from "@angular/core/rxjs-interop";
6
- import { NavigationEnd, Router } from "@angular/router";
7
- const OBSERVABILITY_OPTIONS = new InjectionToken("OBSERVABILITY_OPTIONS", {
8
- providedIn: "root",
9
- factory: () => ({
10
- apiBase: "",
11
- basePath: "/",
12
- auditLink: null
13
- })
14
- });
15
- function provideJuiceObservability(options = {}) {
16
- return makeEnvironmentProviders([{
17
- provide: OBSERVABILITY_OPTIONS,
18
- useValue: {
19
- apiBase: options.apiBase ?? "",
20
- basePath: options.basePath ?? "/",
21
- auditLink: options.auditLink ?? null
22
- }
23
- }]);
7
+ function idempotencyKey() {
8
+ const b = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
9
+ b[6] = b[6] & 15 | 64;
10
+ b[8] = b[8] & 63 | 128;
11
+ const hex = Array.from(b, (x) => x.toString(16).padStart(2, "0")).join("");
12
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
24
13
  }
25
- function normalizeBasePath(basePath) {
26
- const trimmed = basePath.trim().replace(/^\/+|\/+$/g, "");
27
- return trimmed ? `/${trimmed}` : "/";
28
- }
29
- var ObservabilityLinks = class ObservabilityLinks {
30
- options = inject(OBSERVABILITY_OPTIONS);
31
- base = normalizeBasePath(this.options.basePath);
32
- to(...segments) {
33
- return [this.base, ...segments];
34
- }
35
- audit(traceId) {
36
- if (!traceId || !this.options.auditLink) return null;
37
- const link = this.options.auditLink(traceId);
38
- if (!link) return null;
39
- return typeof link === "string" ? { href: link } : { route: link };
40
- }
41
- static ɵfac = i0.ɵɵngDeclareFactory({
42
- minVersion: "12.0.0",
43
- version: "22.2.4",
44
- ngImport: i0,
45
- type: ObservabilityLinks,
46
- deps: [],
47
- target: i0.ɵɵFactoryTarget.Injectable
48
- });
49
- static ɵprov = i0.ɵɵngDeclareInjectable({
50
- minVersion: "12.0.0",
51
- version: "22.2.4",
52
- ngImport: i0,
53
- type: ObservabilityLinks,
54
- providedIn: "root"
55
- });
56
- };
57
- i0.ɵɵngDeclareClassMetadata({
58
- minVersion: "12.0.0",
59
- version: "22.2.4",
60
- ngImport: i0,
61
- type: ObservabilityLinks,
62
- decorators: [{
63
- type: Injectable,
64
- args: [{ providedIn: "root" }]
65
- }]
66
- });
67
- var LinkPipe = class LinkPipe {
68
- links = inject(ObservabilityLinks);
69
- transform(segments) {
70
- return this.links.to(...segments);
71
- }
72
- static ɵfac = i0.ɵɵngDeclareFactory({
73
- minVersion: "12.0.0",
74
- version: "22.2.4",
75
- ngImport: i0,
76
- type: LinkPipe,
77
- deps: [],
78
- target: i0.ɵɵFactoryTarget.Pipe
79
- });
80
- static ɵpipe = i0.ɵɵngDeclarePipe({
81
- minVersion: "14.0.0",
82
- version: "22.2.4",
83
- ngImport: i0,
84
- type: LinkPipe,
85
- isStandalone: true,
86
- name: "jcLink"
87
- });
88
- };
89
- i0.ɵɵngDeclareClassMetadata({
90
- minVersion: "12.0.0",
91
- version: "22.2.4",
92
- ngImport: i0,
93
- type: LinkPipe,
94
- decorators: [{
95
- type: Pipe,
96
- args: [{ name: "jcLink" }]
97
- }]
98
- });
99
14
  var ApiService = class ApiService {
100
15
  http = inject(HttpClient);
101
16
  base = `${inject(OBSERVABILITY_OPTIONS).apiBase}/api/v1`;
17
+ tenantKnown = signal(false, ...ngDevMode ? [{ debugName: "tenantKnown" }] : /* istanbul ignore next */ []);
102
18
  tenant$ = this.http.get(`${this.base}/tenants`).pipe(map((page) => {
103
19
  if (page.items.length === 0) throw new Error("No tenant is authorized for this user.");
104
20
  return page.items[0];
105
- }), shareReplay(1));
21
+ }), tap(() => this.tenantKnown.set(true)), shareReplay(1));
106
22
  get(path, query = {}) {
107
23
  let params = new HttpParams();
108
24
  for (const [key, value] of Object.entries(query)) {
@@ -111,6 +27,15 @@ var ApiService = class ApiService {
111
27
  }
112
28
  return this.tenant$.pipe(switchMap((t) => this.http.get(`${this.base}/tenants/${t.id}${path}`, { params })));
113
29
  }
30
+ send(method, path, body, headers = {}) {
31
+ return this.tenant$.pipe(switchMap((t) => this.http.request(method, `${this.base}/tenants/${t.id}${path}`, {
32
+ body,
33
+ headers
34
+ })));
35
+ }
36
+ once(path, body) {
37
+ return this.send("POST", path, body, { "Idempotency-Key": idempotencyKey() });
38
+ }
114
39
  all(path, query = {}, maxPages = 25) {
115
40
  let pages = 0;
116
41
  return this.get(path, {
@@ -149,6 +74,164 @@ var ApiService = class ApiService {
149
74
  rules() {
150
75
  return this.get("/rules", { limit: 200 });
151
76
  }
77
+ createRule(definition) {
78
+ return this.send("POST", "/rules", definition);
79
+ }
80
+ updateRule(key, definition, etag) {
81
+ return this.send("PUT", `/rules/${key}`, definition, { "If-Match": `"${etag}"` });
82
+ }
83
+ channels() {
84
+ return this.get("/webhooks");
85
+ }
86
+ createChannel(body) {
87
+ return this.send("POST", "/webhooks", body);
88
+ }
89
+ updateChannel(id, body) {
90
+ return this.send("PUT", `/webhooks/${id}`, body);
91
+ }
92
+ deliveries(id, query = {}) {
93
+ return this.get(`/webhooks/${id}/deliveries`, {
94
+ limit: 50,
95
+ ...query
96
+ });
97
+ }
98
+ testChannel(id) {
99
+ return this.send("POST", `/webhooks/${id}/test`);
100
+ }
101
+ retryDelivery(channelId, deliveryId) {
102
+ return this.send("POST", `/webhooks/${channelId}/deliveries/${deliveryId}/retry`);
103
+ }
104
+ allowlist() {
105
+ return this.get("/webhooks/allowlist");
106
+ }
107
+ putAllowlist(destination, ports) {
108
+ return this.send("PUT", "/webhooks/allowlist", {
109
+ destination,
110
+ ports
111
+ });
112
+ }
113
+ removeAllowlist(destination) {
114
+ return this.send("DELETE", `/webhooks/allowlist?destination=${encodeURIComponent(destination)}`);
115
+ }
116
+ escalationPolicies() {
117
+ return this.get("/escalation-policies");
118
+ }
119
+ createEscalationPolicy(body) {
120
+ return this.send("POST", "/escalation-policies", body);
121
+ }
122
+ updateEscalationPolicy(key, body) {
123
+ return this.send("PUT", `/escalation-policies/${key}`, body);
124
+ }
125
+ silences(query = {}) {
126
+ return this.get("/silences", {
127
+ limit: 200,
128
+ ...query
129
+ });
130
+ }
131
+ createSilence(body) {
132
+ return this.once("/silences", body);
133
+ }
134
+ cancelSilence(id) {
135
+ return this.send("DELETE", `/silences/${id}`);
136
+ }
137
+ incidents(query = {}) {
138
+ return this.get("/incidents", {
139
+ limit: 100,
140
+ ...query
141
+ });
142
+ }
143
+ incident(id) {
144
+ return this.get(`/incidents/${id}`);
145
+ }
146
+ createIncident(body) {
147
+ return this.once("/incidents", body);
148
+ }
149
+ moveIncident(id, to, comment) {
150
+ return this.once(`/incidents/${id}/transitions`, {
151
+ to,
152
+ comment
153
+ });
154
+ }
155
+ addIncidentNote(id, text) {
156
+ return this.once(`/incidents/${id}/notes`, { text });
157
+ }
158
+ removeIncidentAlert(id, alertId) {
159
+ return this.send("DELETE", `/incidents/${id}/alerts/${alertId}`);
160
+ }
161
+ agents(all = false) {
162
+ return this.get("/agents", { all: all || null });
163
+ }
164
+ agent(id) {
165
+ return this.get(`/agents/${id}`);
166
+ }
167
+ createEnrollmentToken(purpose, expiresInMinutes) {
168
+ return this.send("POST", "/agents/enrollment-tokens", {
169
+ purpose,
170
+ expiresInMinutes
171
+ });
172
+ }
173
+ revokeAgent(id, reason) {
174
+ return this.send("POST", `/agents/${id}/revocation`, { reason });
175
+ }
176
+ agentActions(id) {
177
+ return this.get(`/agents/${id}/actions`);
178
+ }
179
+ agentPackages() {
180
+ return this.get("/agents/packages");
181
+ }
182
+ issueCommand(id, action, parameters) {
183
+ return this.once(`/agents/${id}/commands`, {
184
+ action,
185
+ parameters
186
+ });
187
+ }
188
+ requestAction(agentId, action, parameters, reason, target = null) {
189
+ return this.once(`/agents/${agentId}/action-requests`, {
190
+ action,
191
+ parameters,
192
+ reason,
193
+ target
194
+ });
195
+ }
196
+ actionRequests(query = {}) {
197
+ return this.get("/action-requests", {
198
+ limit: 100,
199
+ ...query
200
+ });
201
+ }
202
+ downloadBundle(agentId, bundleId) {
203
+ return this.tenant$.pipe(switchMap((t) => this.http.get(`${this.base}/tenants/${t.id}/agents/${agentId}/bundles/${bundleId}`, {
204
+ responseType: "blob",
205
+ observe: "response"
206
+ })));
207
+ }
208
+ slos(category) {
209
+ return this.get("/slos", { category });
210
+ }
211
+ slo(key) {
212
+ return this.get(`/slos/${encodeURIComponent(key)}`);
213
+ }
214
+ waitingRequests() {
215
+ return this.get("/action-requests/waiting");
216
+ }
217
+ approveRequest(id, comment) {
218
+ return this.send("POST", `/action-requests/${id}/approval`, { comment });
219
+ }
220
+ rejectRequest(id, comment) {
221
+ return this.send("POST", `/action-requests/${id}/rejection`, { comment });
222
+ }
223
+ cancelRequest(id) {
224
+ return this.send("POST", `/action-requests/${id}/cancellation`, {});
225
+ }
226
+ agentCommands(id, cursor) {
227
+ return this.get(`/agents/${id}/commands`, {
228
+ limit: 25,
229
+ cursor
230
+ });
231
+ }
232
+ alertNotifications(id) {
233
+ return this.get(`/alerts/${id}/notifications`);
234
+ }
152
235
  alerts(query) {
153
236
  return this.get("/alerts", {
154
237
  limit: 100,
@@ -162,7 +245,7 @@ var ApiService = class ApiService {
162
245
  return this.get(`/alerts/${id}`);
163
246
  }
164
247
  acknowledge(id, comment) {
165
- return this.tenant$.pipe(switchMap((t) => this.http.post(`${this.base}/tenants/${t.id}/alerts/${id}/acknowledgement`, { comment }, { headers: { "Idempotency-Key": crypto.randomUUID() } })));
248
+ return this.tenant$.pipe(switchMap((t) => this.http.post(`${this.base}/tenants/${t.id}/alerts/${id}/acknowledgement`, { comment }, { headers: { "Idempotency-Key": idempotencyKey() } })));
166
249
  }
167
250
  traces(query) {
168
251
  return this.get("/telemetry/traces", query);
@@ -185,6 +268,36 @@ var ApiService = class ApiService {
185
268
  serviceStats(query) {
186
269
  return this.get("/telemetry/service-stats", query);
187
270
  }
271
+ capacity(query) {
272
+ return this.get("/telemetry/capacity", query);
273
+ }
274
+ timeline(query) {
275
+ return this.get("/timeline", query);
276
+ }
277
+ relatedToAlert(id) {
278
+ return this.get(`/alerts/${id}/related`);
279
+ }
280
+ alertSuggestions(id) {
281
+ return this.get(`/alerts/${id}/suggestions`);
282
+ }
283
+ incidentSuggestions(id) {
284
+ return this.get(`/incidents/${id}/suggestions`);
285
+ }
286
+ acceptSuggestion(alertId, otherId) {
287
+ return this.once(`/alerts/${alertId}/suggestions/${otherId}/accept`, {});
288
+ }
289
+ dismissSuggestion(alertId, otherId, reason) {
290
+ return this.once(`/alerts/${alertId}/suggestions/${otherId}/dismiss`, { reason });
291
+ }
292
+ loadRuns(query) {
293
+ return this.get("/load-runs", query);
294
+ }
295
+ loadRunResults(id) {
296
+ return this.get(`/load-runs/${id}/results`);
297
+ }
298
+ dependencyStats(query) {
299
+ return this.get("/telemetry/dependencies", query);
300
+ }
188
301
  dependency(id, query) {
189
302
  return this.get(`/telemetry/dependencies/${id}`, query);
190
303
  }
@@ -217,6 +330,231 @@ i0.ɵɵngDeclareClassMetadata({
217
330
  args: [{ providedIn: "root" }]
218
331
  }]
219
332
  });
333
+ var ApprovalCount = class ApprovalCount {
334
+ static Every = 3e4;
335
+ api = inject(ApiService);
336
+ polling = null;
337
+ forYou = signal(0, ...ngDevMode ? [{ debugName: "forYou" }] : /* istanbul ignore next */ []);
338
+ constructor() {
339
+ effect(() => {
340
+ if (this.api.tenantKnown() && !untracked(() => this.polling)) untracked(() => this.start());
341
+ });
342
+ const navigations = inject(Router).events.pipe(filter((e) => e instanceof NavigationEnd)).subscribe(() => {
343
+ if (!this.polling && this.api.tenantKnown()) this.start();
344
+ });
345
+ inject(DestroyRef).onDestroy(() => {
346
+ navigations.unsubscribe();
347
+ this.polling?.unsubscribe();
348
+ });
349
+ }
350
+ refresh() {
351
+ if (this.api.tenantKnown()) this.start();
352
+ }
353
+ start() {
354
+ this.polling?.unsubscribe();
355
+ this.polling = timer(0, ApprovalCount.Every).pipe(switchMap(() => this.api.waitingRequests())).subscribe({
356
+ next: (w) => this.forYou.set(w.forYou),
357
+ error: () => {
358
+ this.forYou.set(0);
359
+ this.polling = null;
360
+ }
361
+ });
362
+ }
363
+ static ɵfac = i0.ɵɵngDeclareFactory({
364
+ minVersion: "12.0.0",
365
+ version: "22.2.4",
366
+ ngImport: i0,
367
+ type: ApprovalCount,
368
+ deps: [],
369
+ target: i0.ɵɵFactoryTarget.Injectable
370
+ });
371
+ static ɵprov = i0.ɵɵngDeclareInjectable({
372
+ minVersion: "12.0.0",
373
+ version: "22.2.4",
374
+ ngImport: i0,
375
+ type: ApprovalCount,
376
+ providedIn: "root"
377
+ });
378
+ };
379
+ i0.ɵɵngDeclareClassMetadata({
380
+ minVersion: "12.0.0",
381
+ version: "22.2.4",
382
+ ngImport: i0,
383
+ type: ApprovalCount,
384
+ decorators: [{
385
+ type: Injectable,
386
+ args: [{ providedIn: "root" }]
387
+ }],
388
+ ctorParameters: () => []
389
+ });
390
+ var ApprovalMenuBadge = class ApprovalMenuBadge {
391
+ static Icon = "approval";
392
+ count = inject(ApprovalCount);
393
+ observer = null;
394
+ constructor() {
395
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") return;
396
+ effect(() => this.apply(this.count.forYou()));
397
+ let scheduled = false;
398
+ this.observer = new MutationObserver(() => {
399
+ if (scheduled) return;
400
+ scheduled = true;
401
+ requestAnimationFrame(() => {
402
+ scheduled = false;
403
+ this.apply(this.count.forYou());
404
+ });
405
+ });
406
+ this.observer.observe(document.body, {
407
+ childList: true,
408
+ subtree: true
409
+ });
410
+ inject(DestroyRef).onDestroy(() => this.observer?.disconnect());
411
+ }
412
+ apply(count) {
413
+ for (const icon of Array.from(document.querySelectorAll("juice-nav-menu mat-icon"))) {
414
+ if (icon.textContent?.trim() !== ApprovalMenuBadge.Icon) continue;
415
+ const item = icon.closest("mat-list-item, .mat-mdc-list-item");
416
+ const title = item?.querySelector("[matListItemTitle], .mdc-list-item__primary-text");
417
+ if (!item || !title) continue;
418
+ let badge = title.querySelector(".jc-menu-badge");
419
+ if (count <= 0) {
420
+ badge?.remove();
421
+ item.removeAttribute("title");
422
+ continue;
423
+ }
424
+ if (!badge) {
425
+ badge = document.createElement("span");
426
+ badge.className = "jc-menu-badge";
427
+ badge.setAttribute("data-testid", "approvals-badge");
428
+ badge.style.cssText = "display:inline-block;min-width:1.25rem;margin-left:.5rem;padding:0 .375rem;border-radius:999px;font-size:.75rem;line-height:1.25rem;text-align:center;font-weight:600;background:var(--mat-sys-error,#b3261e);color:var(--mat-sys-on-error,#fff)";
429
+ title.appendChild(badge);
430
+ }
431
+ const text = count > 99 ? "99+" : String(count);
432
+ if (badge.textContent !== text) badge.textContent = text;
433
+ const hint = `${count} request${count === 1 ? "" : "s"} waiting for your approval`;
434
+ if (item.getAttribute("title") !== hint) item.setAttribute("title", hint);
435
+ }
436
+ }
437
+ static ɵfac = i0.ɵɵngDeclareFactory({
438
+ minVersion: "12.0.0",
439
+ version: "22.2.4",
440
+ ngImport: i0,
441
+ type: ApprovalMenuBadge,
442
+ deps: [],
443
+ target: i0.ɵɵFactoryTarget.Injectable
444
+ });
445
+ static ɵprov = i0.ɵɵngDeclareInjectable({
446
+ minVersion: "12.0.0",
447
+ version: "22.2.4",
448
+ ngImport: i0,
449
+ type: ApprovalMenuBadge,
450
+ providedIn: "root"
451
+ });
452
+ };
453
+ i0.ɵɵngDeclareClassMetadata({
454
+ minVersion: "12.0.0",
455
+ version: "22.2.4",
456
+ ngImport: i0,
457
+ type: ApprovalMenuBadge,
458
+ decorators: [{
459
+ type: Injectable,
460
+ args: [{ providedIn: "root" }]
461
+ }],
462
+ ctorParameters: () => []
463
+ });
464
+ const OBSERVABILITY_OPTIONS = new InjectionToken("OBSERVABILITY_OPTIONS", {
465
+ providedIn: "root",
466
+ factory: () => ({
467
+ apiBase: "",
468
+ basePath: "/",
469
+ auditLink: null
470
+ })
471
+ });
472
+ function provideJuiceObservability(options = {}) {
473
+ return makeEnvironmentProviders([{
474
+ provide: OBSERVABILITY_OPTIONS,
475
+ useValue: {
476
+ apiBase: options.apiBase ?? "",
477
+ basePath: options.basePath ?? "/",
478
+ auditLink: options.auditLink ?? null
479
+ }
480
+ }, ...options.approvalCount === false ? [] : [provideEnvironmentInitializer(() => {
481
+ inject(ApprovalMenuBadge);
482
+ })]]);
483
+ }
484
+ function normalizeBasePath(basePath) {
485
+ const trimmed = basePath.trim().replace(/^\/+|\/+$/g, "");
486
+ return trimmed ? `/${trimmed}` : "/";
487
+ }
488
+ var ObservabilityLinks = class ObservabilityLinks {
489
+ options = inject(OBSERVABILITY_OPTIONS);
490
+ base = normalizeBasePath(this.options.basePath);
491
+ to(...segments) {
492
+ return [this.base, ...segments];
493
+ }
494
+ audit(traceId) {
495
+ if (!traceId || !this.options.auditLink) return null;
496
+ const link = this.options.auditLink(traceId);
497
+ if (!link) return null;
498
+ return typeof link === "string" ? { href: link } : { route: link };
499
+ }
500
+ static ɵfac = i0.ɵɵngDeclareFactory({
501
+ minVersion: "12.0.0",
502
+ version: "22.2.4",
503
+ ngImport: i0,
504
+ type: ObservabilityLinks,
505
+ deps: [],
506
+ target: i0.ɵɵFactoryTarget.Injectable
507
+ });
508
+ static ɵprov = i0.ɵɵngDeclareInjectable({
509
+ minVersion: "12.0.0",
510
+ version: "22.2.4",
511
+ ngImport: i0,
512
+ type: ObservabilityLinks,
513
+ providedIn: "root"
514
+ });
515
+ };
516
+ i0.ɵɵngDeclareClassMetadata({
517
+ minVersion: "12.0.0",
518
+ version: "22.2.4",
519
+ ngImport: i0,
520
+ type: ObservabilityLinks,
521
+ decorators: [{
522
+ type: Injectable,
523
+ args: [{ providedIn: "root" }]
524
+ }]
525
+ });
526
+ var LinkPipe = class LinkPipe {
527
+ links = inject(ObservabilityLinks);
528
+ transform(segments) {
529
+ return this.links.to(...segments);
530
+ }
531
+ static ɵfac = i0.ɵɵngDeclareFactory({
532
+ minVersion: "12.0.0",
533
+ version: "22.2.4",
534
+ ngImport: i0,
535
+ type: LinkPipe,
536
+ deps: [],
537
+ target: i0.ɵɵFactoryTarget.Pipe
538
+ });
539
+ static ɵpipe = i0.ɵɵngDeclarePipe({
540
+ minVersion: "14.0.0",
541
+ version: "22.2.4",
542
+ ngImport: i0,
543
+ type: LinkPipe,
544
+ isStandalone: true,
545
+ name: "jcLink"
546
+ });
547
+ };
548
+ i0.ɵɵngDeclareClassMetadata({
549
+ minVersion: "12.0.0",
550
+ version: "22.2.4",
551
+ ngImport: i0,
552
+ type: LinkPipe,
553
+ decorators: [{
554
+ type: Pipe,
555
+ args: [{ name: "jcLink" }]
556
+ }]
557
+ });
220
558
  const RANGES = {
221
559
  "15m": 9e5,
222
560
  "1h": 36e5,
@@ -323,19 +661,30 @@ function page(path, title, load) {
323
661
  };
324
662
  }
325
663
  const OBSERVABILITY_ROUTES = [
326
- page("", "Overview", () => import("./juice-js-observability-overview.page-DXZl_fUh.mjs").then((m) => m.OverviewPage)),
327
- page("services", "Services", () => import("./juice-js-observability-services.page-B1huLe_a.mjs").then((m) => m.ServicesPage)),
328
- page("services/:id", "Service", () => import("./juice-js-observability-service.page-Dt8bN2Ry.mjs").then((m) => m.ServicePage)),
329
- page("traces", "Traces", () => import("./juice-js-observability-traces.page-DXSDdeTH.mjs").then((m) => m.TracesPage)),
330
- page("traces/:traceId", "Trace", () => import("./juice-js-observability-trace.page-DUCWnZL5.mjs").then((m) => m.TracePage)),
331
- page("topology", "Dependencies", () => import("./juice-js-observability-topology.page-aMWEXyMB.mjs").then((m) => m.TopologyPage)),
332
- page("logs", "Logs", () => import("./juice-js-observability-logs.page-i76xbJLH.mjs").then((m) => m.LogsPage)),
333
- page("metrics", "Metrics", () => import("./juice-js-observability-metrics.page-Cq5S0yGJ.mjs").then((m) => m.MetricsPage)),
334
- page("resources", "Resources", () => import("./juice-js-observability-resources.page-CukW8vVc.mjs").then((m) => m.ResourcesPage)),
335
- page("resources/:id", "Resource", () => import("./juice-js-observability-resource.page-CauDE6kK.mjs").then((m) => m.ResourcePage)),
336
- page("alerts", "Alerts", () => import("./juice-js-observability-alerts.page-DUXXBanH.mjs").then((m) => m.AlertsPage)),
337
- page("alerts/:id", "Alert", () => import("./juice-js-observability-alert.page-nEy5Gc6j.mjs").then((m) => m.AlertPage)),
338
- page("rules", "Rules", () => import("./juice-js-observability-rules.page-Crb07uWm.mjs").then((m) => m.RulesPage))
664
+ page("", "Overview", () => import("./juice-js-observability-overview.page-BRGpTOyc.mjs").then((m) => m.OverviewPage)),
665
+ page("services", "Services", () => import("./juice-js-observability-services.page-BbFbbvyH.mjs").then((m) => m.ServicesPage)),
666
+ page("services/:id", "Service", () => import("./juice-js-observability-service.page-DRj1GO0Q.mjs").then((m) => m.ServicePage)),
667
+ page("traces", "Traces", () => import("./juice-js-observability-traces.page-CMuItN_m.mjs").then((m) => m.TracesPage)),
668
+ page("traces/:traceId", "Trace", () => import("./juice-js-observability-trace.page-CdW09ADY.mjs").then((m) => m.TracePage)),
669
+ page("topology", "Dependencies", () => import("./juice-js-observability-topology.page-BDfNpiql.mjs").then((m) => m.TopologyPage)),
670
+ page("logs", "Logs", () => import("./juice-js-observability-logs.page-PXWQMcvL.mjs").then((m) => m.LogsPage)),
671
+ page("metrics", "Metrics", () => import("./juice-js-observability-metrics.page-Ctm_EEFb.mjs").then((m) => m.MetricsPage)),
672
+ page("resources", "Resources", () => import("./juice-js-observability-resources.page-B_AVPpes.mjs").then((m) => m.ResourcesPage)),
673
+ page("resources/:id", "Resource", () => import("./juice-js-observability-resource.page-O4GGdirR.mjs").then((m) => m.ResourcePage)),
674
+ page("alerts", "Alerts", () => import("./juice-js-observability-alerts.page-BNmez0Ak.mjs").then((m) => m.AlertsPage)),
675
+ page("alerts/:id", "Alert", () => import("./juice-js-observability-alert.page-2kfKksIG.mjs").then((m) => m.AlertPage)),
676
+ page("rules", "Rules", () => import("./juice-js-observability-rules.page-CARCWaw_.mjs").then((m) => m.RulesPage)),
677
+ page("notifications", "Notifications", () => import("./juice-js-observability-notifications.page-CtcV3Ei4.mjs").then((m) => m.NotificationsPage)),
678
+ page("silences", "Silences", () => import("./juice-js-observability-silences.page-CoTqfGxY.mjs").then((m) => m.SilencesPage)),
679
+ page("incidents", "Incidents", () => import("./juice-js-observability-incidents.page-DhC3BkBo.mjs").then((m) => m.IncidentsPage)),
680
+ page("incidents/:id", "Incident", () => import("./juice-js-observability-incident.page-D2GvuIft.mjs").then((m) => m.IncidentPage)),
681
+ page("agents", "Agents", () => import("./juice-js-observability-agents.page-Ch-tBwQO.mjs").then((m) => m.AgentsPage)),
682
+ page("agents/:id", "Agent", () => import("./juice-js-observability-agent.page-Vb7LDThl.mjs").then((m) => m.AgentPage)),
683
+ page("approvals", "Approvals", () => import("./juice-js-observability-approvals.page-DBLw-vl1.mjs").then((m) => m.ApprovalsPage)),
684
+ page("slos", "SLOs", () => import("./juice-js-observability-slos.page-DNG6g6_R.mjs").then((m) => m.SlosPage)),
685
+ page("slos/:key", "SLO", () => import("./juice-js-observability-slo.page-l7TOat-D.mjs").then((m) => m.SloPage)),
686
+ page("timeline", "Timeline", () => import("./juice-js-observability-timeline.page-CFSigOgk.mjs").then((m) => m.TimelinePage)),
687
+ page("load-runs", "Load runs", () => import("./juice-js-observability-load-runs.page-DVuO4zFp.mjs").then((m) => m.LoadRunsPage))
339
688
  ];
340
689
  function observabilityMenus(basePath = "/", order = 1) {
341
690
  const base = normalizeBasePath(basePath);
@@ -389,17 +738,65 @@ function observabilityMenus(basePath = "/", order = 1) {
389
738
  icon: "notifications",
390
739
  routerLink: link("alerts")
391
740
  },
741
+ {
742
+ id: "incidents",
743
+ label: "Incidents",
744
+ icon: "emergency",
745
+ routerLink: link("incidents")
746
+ },
392
747
  {
393
748
  id: "rules",
394
749
  label: "Rules",
395
750
  icon: "rule",
396
751
  routerLink: link("rules")
752
+ },
753
+ {
754
+ id: "silences",
755
+ label: "Silences",
756
+ icon: "notifications_paused",
757
+ routerLink: link("silences")
758
+ },
759
+ {
760
+ id: "notifications",
761
+ label: "Notifications",
762
+ icon: "campaign",
763
+ routerLink: link("notifications")
764
+ },
765
+ {
766
+ id: "slos",
767
+ label: "SLOs",
768
+ icon: "track_changes",
769
+ routerLink: link("slos")
770
+ },
771
+ {
772
+ id: "agents",
773
+ label: "Agents",
774
+ icon: "smart_toy",
775
+ routerLink: link("agents")
776
+ },
777
+ {
778
+ id: "approvals",
779
+ label: "Approvals",
780
+ icon: "approval",
781
+ routerLink: link("approvals")
782
+ },
783
+ {
784
+ id: "timeline",
785
+ label: "Timeline",
786
+ icon: "history",
787
+ routerLink: link("timeline")
788
+ },
789
+ {
790
+ id: "load-runs",
791
+ label: "Load runs",
792
+ icon: "speed",
793
+ routerLink: link("load-runs")
397
794
  }
398
795
  ].map((menu, index) => ({
399
796
  ...menu,
400
797
  order: order + index
401
798
  }));
402
799
  }
403
- export { ApiService, ContextService, LinkPipe, MAX_SEARCH_MS, OBSERVABILITY_OPTIONS, OBSERVABILITY_ROUTES, ObservabilityLinks, RANGES, normalizeBasePath, observabilityMenus, provideJuiceObservability };
800
+ export { ApiService, ApprovalCount, ApprovalMenuBadge, ContextService, LinkPipe, MAX_SEARCH_MS, OBSERVABILITY_OPTIONS, OBSERVABILITY_ROUTES, ObservabilityLinks, RANGES, idempotencyKey, normalizeBasePath, observabilityMenus, provideJuiceObservability };
404
801
 
405
802
  //# sourceMappingURL=juice-js-observability.mjs.map