@juice-js/observability 1.1.0-alpha.32 → 1.1.0-alpha.35

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.
@@ -1,5 +1,6 @@
1
1
  import { ApiService, ContextService, LinkPipe } from "./juice-js-observability.mjs";
2
2
  import { c as ContextBar, g as AgoPipe, h as apiResource, l as HealthBadge, o as problemText, u as KeyValueTable, y as ReasonPipe } from "./juice-js-observability-telemetry-DVwUTHSz.mjs";
3
+ import { t as SuggestionsCard } from "./juice-js-observability-suggestions-eQK_z0Nd.mjs";
3
4
  import * as i0 from "@angular/core";
4
5
  import { ChangeDetectionStrategy, Component, computed, inject, input, signal } from "@angular/core";
5
6
  import { RouterLink } from "@angular/router";
@@ -36,6 +37,21 @@ var AlertPage = class AlertPage {
36
37
  stream: ({ params }) => this.api.alertNotifications(params)
37
38
  });
38
39
  notificationsError = computed(() => problemText(this.notifications.error()), ...ngDevMode ? [{ debugName: "notificationsError" }] : /* istanbul ignore next */ []);
40
+ suggestions = apiResource({
41
+ params: () => this.detail.value()?.alert.state === "Firing" ? this.id() : void 0,
42
+ stream: ({ params }) => this.api.alertSuggestions(params)
43
+ });
44
+ suggestionsError = computed(() => problemText(this.suggestions.error()), ...ngDevMode ? [{ debugName: "suggestionsError" }] : /* istanbul ignore next */ []);
45
+ mergedInto = signal(null, ...ngDevMode ? [{ debugName: "mergedInto" }] : /* istanbul ignore next */ []);
46
+ merged = computed(() => this.mergedInto()?.alert === this.id() ? this.mergedInto().incident : null, ...ngDevMode ? [{ debugName: "merged" }] : /* istanbul ignore next */ []);
47
+ decided(d) {
48
+ if (d?.incidentId) this.mergedInto.set({
49
+ alert: this.id(),
50
+ incident: d.incidentId
51
+ });
52
+ this.suggestions.reload();
53
+ this.notifications.reload();
54
+ }
39
55
  incidentLink(alert, rule, subject) {
40
56
  return this.ctx.keep({
41
57
  alert,
@@ -173,6 +189,14 @@ var AlertPage = class AlertPage {
173
189
  }
174
190
  @if (related.error()) { <p class="jc-error">{{ relatedError() }}</p> }
175
191
  </section>
192
+ @if (d.alert.state === 'Firing' || merged()) {
193
+ <section class="jc-card" data-testid="alert-suggestions">
194
+ <h2>Suggested with this alert</h2>
195
+ @if (merged(); as m) { <p data-testid="alert-suggestion-merged">Merged into <a [routerLink]="['incidents', m] | jcLink" [queryParams]="ctx.keep()">the incident</a>.</p> }
196
+ <jc-suggestions [suggestions]="suggestions.value()" (decided)="decided($event)" />
197
+ @if (suggestions.error()) { <p class="jc-error">{{ suggestionsError() }}</p> }
198
+ </section>
199
+ }
176
200
  <section class="jc-card" data-testid="alert-notifications">
177
201
  <h2>Notifications</h2>
178
202
  @if (notifications.value(); as n) {
@@ -381,6 +405,17 @@ var AlertPage = class AlertPage {
381
405
  selector: "jc-kv",
382
406
  inputs: ["values", "empty"]
383
407
  },
408
+ {
409
+ kind: "component",
410
+ type: SuggestionsCard,
411
+ selector: "jc-suggestions",
412
+ inputs: [
413
+ "suggestions",
414
+ "withAlert",
415
+ "incident"
416
+ ],
417
+ outputs: ["decided"]
418
+ },
384
419
  {
385
420
  kind: "pipe",
386
421
  type: LinkPipe,
@@ -433,7 +468,8 @@ i0.ɵɵngDeclareClassMetadata({
433
468
  HealthBadge,
434
469
  KeyValueTable,
435
470
  AgoPipe,
436
- ReasonPipe
471
+ ReasonPipe,
472
+ SuggestionsCard
437
473
  ],
438
474
  template: `
439
475
  <jc-context-bar>
@@ -495,6 +531,14 @@ i0.ɵɵngDeclareClassMetadata({
495
531
  }
496
532
  @if (related.error()) { <p class="jc-error">{{ relatedError() }}</p> }
497
533
  </section>
534
+ @if (d.alert.state === 'Firing' || merged()) {
535
+ <section class="jc-card" data-testid="alert-suggestions">
536
+ <h2>Suggested with this alert</h2>
537
+ @if (merged(); as m) { <p data-testid="alert-suggestion-merged">Merged into <a [routerLink]="['incidents', m] | jcLink" [queryParams]="ctx.keep()">the incident</a>.</p> }
538
+ <jc-suggestions [suggestions]="suggestions.value()" (decided)="decided($event)" />
539
+ @if (suggestions.error()) { <p class="jc-error">{{ suggestionsError() }}</p> }
540
+ </section>
541
+ }
498
542
  <section class="jc-card" data-testid="alert-notifications">
499
543
  <h2>Notifications</h2>
500
544
  @if (notifications.value(); as n) {
@@ -553,4 +597,4 @@ i0.ɵɵngDeclareClassMetadata({
553
597
  });
554
598
  export { AlertPage };
555
599
 
556
- //# sourceMappingURL=juice-js-observability-alert.page-BNlH9IdQ.mjs.map
600
+ //# sourceMappingURL=juice-js-observability-alert.page-2kfKksIG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"juice-js-observability-alert.page-2kfKksIG.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/alert.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, input, signal } from '@angular/core';\nimport { apiResource } from '../shared/resource';\nimport { DatePipe, LowerCasePipe } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { RouterLink } from '@angular/router';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { AgoPipe, ReasonPipe } from '../shared/format';\nimport { ContextBar, HealthBadge, KeyValueTable } from '../shared/ui';\nimport { problemText } from '../shared/telemetry';\nimport { SuggestionsCard } from '../shared/suggestions';\nimport { CorrelationDecision } from '../core/models';\n\n/**\n * One alert (Console requirements §14): evidence, lifecycle history, the subject's health and reasons, the way into\n * the investigation, and acknowledgement for operators.\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, DatePipe, LowerCasePipe, FormsModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatProgressBarModule,\n ContextBar, HealthBadge, KeyValueTable, AgoPipe, ReasonPipe, SuggestionsCard],\n template: `\n <jc-context-bar>\n <a [routerLink]=\"['alerts'] | jcLink\" [queryParams]=\"ctx.keep()\" class=\"jc-crumb\">Alerts</a><span class=\"jc-crumb-sep\">›</span>\n <h1>{{ detail.value()?.alert?.rule ?? '…' }}</h1>\n </jc-context-bar>\n @if (detail.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (detail.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n @if (detail.value(); as d) {\n <div class=\"jc-summary\">\n <span class=\"jc-badge\" [class.jc-health-unhealthy]=\"d.alert.severity === 'Critical'\" [class.jc-health-degraded]=\"d.alert.severity === 'Warning'\">{{ d.alert.severity }}</span>\n <strong>{{ d.alert.state }}</strong>\n <span>{{ d.alert.subjectKey }}</span>\n @if (d.alert.noData) { <span class=\"jc-muted\">no data at the last evaluation: state kept</span> }\n @if (d.alert.subjectType === 'service' && d.alert.subjectId) {\n <a mat-flat-button [routerLink]=\"['services', d.alert.subjectId] | jcLink\" [queryParams]=\"investigate(d.alert.environment)\">Investigate</a>\n <a mat-stroked-button [routerLink]=\"['services', d.alert.subjectId] | jcLink\" [queryParams]=\"investigate(d.alert.environment, { tab: 'traces', status: 'error' })\">Error traces</a>\n }\n @for (l of d.links; track l.url) { <a mat-button [href]=\"l.url\" target=\"_blank\" rel=\"noopener\">{{ l.title }} ↗</a> }\n @if (d.alert.state !== 'Resolved') {\n <a mat-stroked-button data-testid=\"alert-open-incident\" [routerLink]=\"['incidents'] | jcLink\" [queryParams]=\"incidentLink(d.alert.id, d.alert.rule, d.alert.subjectKey)\">Open an incident</a>\n <a mat-stroked-button data-testid=\"alert-silence\" [routerLink]=\"['silences'] | jcLink\" [queryParams]=\"silenceLink(d.alert.subjectKey, d.alert.environment, d.alert.subjectType)\">Silence this</a>\n }\n </div>\n @if (notifications.value(); as n) {\n @for (s of n.silences; track s.id) {\n <p class=\"jc-notice\" data-testid=\"alert-silenced\">Notifications are held until {{ s.endsAt | date: 'MMM d, HH:mm' }}: “{{ s.comment }}” ({{ s.createdBy }}). The alert itself still fires and resolves.</p>\n }\n @for (i of n.incidents; track i.id) {\n <p>In incident <a [routerLink]=\"['incidents', i.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ i.title }}</a> ({{ i.state }})</p>\n }\n }\n <div class=\"jc-grid-2\">\n <section class=\"jc-card\"><h2>Evidence</h2><jc-kv [values]=\"d.evidence\" /></section>\n <section class=\"jc-card\">\n <h2>Subject health</h2>\n @for (h of d.subjectHealth; track h.subjectId + h.environment) {\n <p><jc-health [state]=\"h.state\" [stale]=\"h.stale\" /> {{ h.environment }}</p>\n <ul class=\"jc-reasons\">@for (r of h.reasons; track r) { <li>{{ r | reason }}</li> }</ul>\n } @empty { <p class=\"jc-muted\">No health for this subject.</p> }\n </section>\n </div>\n <section class=\"jc-card\" data-testid=\"alert-related\">\n <h2>Around this alert</h2>\n @if (related.value(); as r) {\n <p class=\"jc-notice\" data-testid=\"alert-related-note\">{{ r.note }}</p>\n <table class=\"jc-table\"><tbody>\n @for (i of r.items; track i.type + i.id) {\n <tr>\n <td class=\"jc-nowrap\">{{ i.at | date: 'MMM d, HH:mm:ss' }}</td>\n <td><strong>{{ i.title }}</strong>@if (i.detail) { <div class=\"jc-muted jc-small\">{{ i.detail }}</div> }</td>\n <td class=\"jc-small\"><ul class=\"jc-reasons\">@for (x of i.reasons; track x.code) { <li>{{ x.text }} <span class=\"jc-muted\">(+{{ x.points }})</span></li> }</ul></td>\n </tr>\n } @empty { <tr><td class=\"jc-muted\">No changes or dependency health changes in the 2 hours before this alert.</td></tr> }\n </tbody></table>\n @if (d.alert.subjectId && d.alert.subjectType === 'service') {\n <a mat-stroked-button [routerLink]=\"['timeline'] | jcLink\" [queryParams]=\"timelineLink(d.alert.subjectId, d.alert.environment, r.breachStartedAt)\">Open the timeline</a>\n }\n }\n @if (related.error()) { <p class=\"jc-error\">{{ relatedError() }}</p> }\n </section>\n @if (d.alert.state === 'Firing' || merged()) {\n <section class=\"jc-card\" data-testid=\"alert-suggestions\">\n <h2>Suggested with this alert</h2>\n @if (merged(); as m) { <p data-testid=\"alert-suggestion-merged\">Merged into <a [routerLink]=\"['incidents', m] | jcLink\" [queryParams]=\"ctx.keep()\">the incident</a>.</p> }\n <jc-suggestions [suggestions]=\"suggestions.value()\" (decided)=\"decided($event)\" />\n @if (suggestions.error()) { <p class=\"jc-error\">{{ suggestionsError() }}</p> }\n </section>\n }\n <section class=\"jc-card\" data-testid=\"alert-notifications\">\n <h2>Notifications</h2>\n @if (notifications.value(); as n) {\n @for (e of n.escalations; track e.policy) {\n <p>Escalation <strong>{{ e.name }}</strong>: {{ e.stepsSent }} of {{ e.steps }} steps sent, {{ e.state | lowercase }}@if (e.stopReason) { ({{ e.stopReason | reason }}) }@if (e.nextAt) {, next at {{ e.nextAt | date: 'HH:mm:ss' }} }</p>\n }\n <table class=\"jc-table\">\n <thead><tr><th>To</th><th>Event</th><th>Status</th><th>Attempts</th><th>Detail</th><th>When</th></tr></thead>\n <tbody>\n @for (x of n.deliveries; track x.delivery.id) {\n <tr>\n <td>{{ x.endpointKey }} <span class=\"jc-muted jc-small\">{{ x.kind }}</span></td>\n <td>{{ x.delivery.event }}@if (x.delivery.escalationStep) { step {{ x.delivery.escalationStep }} }</td>\n <td [class.jc-bad]=\"x.delivery.status === 'Failed'\">{{ x.delivery.status }}</td>\n <td>{{ x.delivery.attempts }}</td>\n <td class=\"jc-small\">{{ x.delivery.lastError }}@if (x.delivery.nextAttemptAt && x.delivery.status === 'Retrying') { · next {{ x.delivery.nextAttemptAt | date: 'HH:mm:ss' }} }</td>\n <td class=\"jc-nowrap\">{{ x.delivery.createdAt | date: 'MMM d, HH:mm:ss' }}</td>\n </tr>\n } @empty { <tr><td colspan=\"6\" class=\"jc-muted\">Nothing sent about this alert: no channel takes it.</td></tr> }\n </tbody>\n </table>\n }\n @if (notifications.error()) { <p class=\"jc-error\">{{ notificationsError() }}</p> }\n </section>\n <section class=\"jc-card\">\n <h2>History</h2>\n <table class=\"jc-table\"><tbody>\n @for (t of d.history; track t.at + t.to) {\n <tr><td>{{ t.at | date: 'MMM d, HH:mm:ss' }}</td><td>{{ t.from ?? '—' }} → <strong>{{ t.to }}</strong></td><td>{{ t.reason | reason }}</td><td>{{ t.value ?? '—' }}</td></tr>\n }\n </tbody></table>\n </section>\n <section class=\"jc-card\">\n <h2>Acknowledgement</h2>\n @if (d.alert.acknowledgedAt) {\n <p>By <strong>{{ d.alert.acknowledgedBy }}</strong> {{ d.alert.acknowledgedAt | ago }}@if (d.acknowledgeComment) {: “{{ d.acknowledgeComment }}”}</p>\n } @else if (d.alert.state !== 'Resolved') {\n <form (ngSubmit)=\"acknowledge()\" class=\"jc-filter-form\">\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-wide\"><mat-label>Comment</mat-label><input matInput name=\"comment\" [(ngModel)]=\"comment\" maxlength=\"1000\"></mat-form-field>\n <button mat-flat-button type=\"submit\" [disabled]=\"sending()\">Acknowledge</button>\n </form>\n @if (ackError()) { <p class=\"jc-error\">{{ ackError() }}</p> }\n } @else { <p class=\"jc-muted\">Resolved without acknowledgement.</p> }\n </section>\n }`,\n})\nexport class AlertPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n readonly id = input.required<string>();\n protected comment = '';\n protected readonly sending = signal(false);\n protected readonly ackError = signal('');\n\n protected readonly detail = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.alert(params) });\n protected readonly error = computed(() => problemText(this.detail.error()));\n protected readonly related = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.relatedToAlert(params) });\n protected readonly relatedError = computed(() => problemText(this.related.error()));\n protected readonly notifications = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.alertNotifications(params) });\n protected readonly notificationsError = computed(() => problemText(this.notifications.error()));\n /** Only a firing alert is suggested with others, so only its page asks. */\n protected readonly suggestions = apiResource({\n params: () => (this.detail.value()?.alert.state === 'Firing' ? this.id() : undefined),\n stream: ({ params }) => this.api.alertSuggestions(params),\n });\n protected readonly suggestionsError = computed(() => problemText(this.suggestions.error()));\n /** The incident a suggestion on this page was merged into. Keyed by alert: the page is reused when a suggestion's link opens another alert. */\n private readonly mergedInto = signal<{ alert: string; incident: string } | null>(null);\n protected readonly merged = computed(() => (this.mergedInto()?.alert === this.id() ? this.mergedInto()!.incident : null));\n\n /** A decision, or null when one was refused because the list was stale: either way, read it again. */\n protected decided(d: CorrelationDecision | null) {\n if (d?.incidentId) this.mergedInto.set({ alert: this.id(), incident: d.incidentId });\n this.suggestions.reload();\n this.notifications.reload();\n }\n\n incidentLink(alert: string, rule: string, subject: string) { return this.ctx.keep({ alert, title: `${rule} on ${subject}` }); }\n\n /** The new-silence form, filled in for this alert's subject. */\n silenceLink(subject: string, environment: string | null, type: string) {\n const name = type === 'service' ? subject.replace(/^service:/, '').replace(/@[^@]*$/, '') : null;\n const host = type === 'host' ? subject.replace(/^host:/, '') : null;\n return this.ctx.keep({ service: name, environment, host });\n }\n\n /** The service page over the alert's environment, from shortly before the breach. */\n /** The service's timeline from 2 hours before the breach to 1 hour after. */\n timelineLink(service: string, environment: string | null, breach: string) {\n const at = new Date(breach).getTime();\n return this.ctx.keep({ service, env: environment, range: null, from: new Date(at - 2 * 3_600_000).toISOString(), to: new Date(at + 3_600_000).toISOString() });\n }\n\n investigate(environment: string | null, extra: Record<string, string> = {}) {\n const alert = this.detail.value()?.alert;\n const start = alert?.breachStartedAt ? new Date(alert.breachStartedAt).getTime() - 15 * 60_000 : null;\n const end = alert?.resolvedAt ? new Date(alert.resolvedAt).getTime() + 5 * 60_000 : Date.now();\n const window = start && end - start <= 24 * 3_600_000\n ? { from: new Date(start).toISOString(), to: new Date(end).toISOString(), range: null } : {};\n return this.ctx.keep({ env: environment, ...window, ...extra });\n }\n\n acknowledge() {\n this.sending.set(true);\n this.ackError.set('');\n this.api.acknowledge(this.id(), this.comment).subscribe({\n next: () => { this.sending.set(false); this.detail.reload(); this.notifications.reload(); },\n error: e => {\n this.sending.set(false);\n this.ackError.set((e as { status?: number }).status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IAAe;IAAa;IAAiB;IAAoB;IAAgB;IACzH;IAAY;IAAa;IAAe;IAAS;IAAY;GAAe;GAC9E,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiHX,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { ApiService, ContextService, LinkPipe } from "./juice-js-observability.mjs";
2
2
  import { c as ContextBar, h as apiResource, o as problemText } from "./juice-js-observability-telemetry-DVwUTHSz.mjs";
3
+ import { t as SuggestionsCard } from "./juice-js-observability-suggestions-eQK_z0Nd.mjs";
3
4
  import * as i0 from "@angular/core";
4
5
  import { ChangeDetectionStrategy, Component, computed, inject, input, signal } from "@angular/core";
5
6
  import { RouterLink } from "@angular/router";
@@ -36,6 +37,15 @@ var IncidentPage = class IncidentPage {
36
37
  stream: ({ params }) => this.api.incident(params)
37
38
  });
38
39
  error = computed(() => problemText(this.detail.error()), ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
40
+ suggestions = apiResource({
41
+ params: () => this.detail.value() && this.detail.value().incident.state !== "Resolved" ? this.id() : void 0,
42
+ stream: ({ params }) => this.api.incidentSuggestions(params)
43
+ });
44
+ suggestionsError = computed(() => problemText(this.suggestions.error()), ...ngDevMode ? [{ debugName: "suggestionsError" }] : /* istanbul ignore next */ []);
45
+ decided() {
46
+ this.detail.reload();
47
+ this.suggestions.reload();
48
+ }
39
49
  moves(state) {
40
50
  return MOVES[state] ?? [];
41
51
  }
@@ -134,6 +144,13 @@ var IncidentPage = class IncidentPage {
134
144
  } @empty { <tr><td class="jc-muted">None. Open an alert and use “Open an incident”, or add one through the API.</td></tr> }
135
145
  </tbody></table>
136
146
  </section>
147
+ @if (d.incident.state !== 'Resolved') {
148
+ <section class="jc-card" data-testid="incident-suggestions">
149
+ <h2>Suggested alerts</h2>
150
+ <jc-suggestions [suggestions]="suggestions.value()" [withAlert]="true" [incident]="d.incident.id" (decided)="decided()" />
151
+ @if (suggestions.error()) { <p class="jc-error">{{ suggestionsError() }}</p> }
152
+ </section>
153
+ }
137
154
  <section class="jc-card" data-testid="incident-events">
138
155
  <h2>What happened</h2>
139
156
  <table class="jc-table"><tbody>
@@ -298,6 +315,17 @@ var IncidentPage = class IncidentPage {
298
315
  type: ContextBar,
299
316
  selector: "jc-context-bar"
300
317
  },
318
+ {
319
+ kind: "component",
320
+ type: SuggestionsCard,
321
+ selector: "jc-suggestions",
322
+ inputs: [
323
+ "suggestions",
324
+ "withAlert",
325
+ "incident"
326
+ ],
327
+ outputs: ["decided"]
328
+ },
301
329
  {
302
330
  kind: "pipe",
303
331
  type: LinkPipe,
@@ -330,7 +358,8 @@ i0.ɵɵngDeclareClassMetadata({
330
358
  MatFormFieldModule,
331
359
  MatInputModule,
332
360
  MatProgressBarModule,
333
- ContextBar
361
+ ContextBar,
362
+ SuggestionsCard
334
363
  ],
335
364
  template: `
336
365
  <jc-context-bar>
@@ -371,6 +400,13 @@ i0.ɵɵngDeclareClassMetadata({
371
400
  } @empty { <tr><td class="jc-muted">None. Open an alert and use “Open an incident”, or add one through the API.</td></tr> }
372
401
  </tbody></table>
373
402
  </section>
403
+ @if (d.incident.state !== 'Resolved') {
404
+ <section class="jc-card" data-testid="incident-suggestions">
405
+ <h2>Suggested alerts</h2>
406
+ <jc-suggestions [suggestions]="suggestions.value()" [withAlert]="true" [incident]="d.incident.id" (decided)="decided()" />
407
+ @if (suggestions.error()) { <p class="jc-error">{{ suggestionsError() }}</p> }
408
+ </section>
409
+ }
374
410
  <section class="jc-card" data-testid="incident-events">
375
411
  <h2>What happened</h2>
376
412
  <table class="jc-table"><tbody>
@@ -397,4 +433,4 @@ i0.ɵɵngDeclareClassMetadata({
397
433
  });
398
434
  export { IncidentPage };
399
435
 
400
- //# sourceMappingURL=juice-js-observability-incident.page-C2ZK3MRh.mjs.map
436
+ //# sourceMappingURL=juice-js-observability-incident.page-D2GvuIft.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"juice-js-observability-incident.page-D2GvuIft.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/incident.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, input, signal } from '@angular/core';\nimport { DatePipe } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { RouterLink } from '@angular/router';\nimport { Observable } from 'rxjs';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { IncidentEvent } from '../core/models';\nimport { apiResource } from '../shared/resource';\nimport { problemText } from '../shared/telemetry';\nimport { ContextBar } from '../shared/ui';\nimport { SuggestionsCard } from '../shared/suggestions';\n\nconst MOVES: Record<string, string[]> = {\n Open: ['Investigating', 'Mitigated', 'Resolved'],\n Investigating: ['Mitigated', 'Resolved'],\n Mitigated: ['Investigating', 'Resolved'],\n Resolved: ['Investigating'],\n};\n\n/** One incident: its state and the moves from it, its alerts, and who did what. Resolving it changes no alert, and says so if some are still open. */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, DatePipe, FormsModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatProgressBarModule, ContextBar, SuggestionsCard],\n template: `\n <jc-context-bar>\n <a [routerLink]=\"['incidents'] | jcLink\" [queryParams]=\"ctx.keep()\" class=\"jc-crumb\">Incidents</a><span class=\"jc-crumb-sep\">›</span>\n <h1>{{ detail.value()?.incident?.title ?? '…' }}</h1>\n </jc-context-bar>\n @if (detail.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (detail.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n @if (detail.value(); as d) {\n <div class=\"jc-summary\">\n <span class=\"jc-badge\" [class.jc-health-unhealthy]=\"d.incident.severity === 'Critical'\" [class.jc-health-degraded]=\"d.incident.severity === 'Warning'\">{{ d.incident.severity }}</span>\n <strong data-testid=\"incident-state\">{{ d.incident.state }}</strong>\n <span class=\"jc-muted\">Opened by {{ d.incident.createdBy }} {{ d.incident.createdAt | date: 'MMM d, HH:mm' }}</span>\n </div>\n @if (d.incident.state !== 'Resolved' && d.openAlerts > 0) {\n <p class=\"jc-notice\" data-testid=\"incident-open-alerts\">{{ d.openAlerts }} of its alerts {{ d.openAlerts === 1 ? 'is' : 'are' }} still open. Resolving the incident won't change them.</p>\n }\n <section class=\"jc-card\">\n <h2>Move or note</h2>\n <form class=\"jc-form\" (ngSubmit)=\"note()\">\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-wide\"><mat-label>Comment or note</mat-label><input matInput name=\"text\" data-testid=\"incident-text\" [(ngModel)]=\"text\" maxlength=\"2000\"></mat-form-field>\n <button mat-stroked-button type=\"submit\" data-testid=\"incident-note\" [disabled]=\"sending()\">Add note</button>\n @for (m of moves(d.incident.state); track m) {\n <button mat-flat-button type=\"button\" [attr.data-testid]=\"'incident-move-' + m\" [disabled]=\"sending()\" (click)=\"move(m)\">{{ d.incident.state === 'Resolved' ? 'Reopen' : m }}</button>\n }\n @if (actionError()) { <span class=\"jc-error\" data-testid=\"incident-action-error\">{{ actionError() }}</span> }\n </form>\n </section>\n <section class=\"jc-card\" data-testid=\"incident-alerts\">\n <h2>Alerts</h2>\n <table class=\"jc-table\"><tbody>\n @for (a of d.alerts; track a.id) {\n <tr>\n <td><a [routerLink]=\"['alerts', a.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ a.rule }}</a></td>\n <td>{{ a.subjectKey }}</td><td>{{ a.severity }}</td><td>{{ a.state }}</td>\n <td class=\"jc-row-actions\"><button mat-button type=\"button\" (click)=\"removeAlert(a.id)\">Remove</button></td>\n </tr>\n } @empty { <tr><td class=\"jc-muted\">None. Open an alert and use “Open an incident”, or add one through the API.</td></tr> }\n </tbody></table>\n </section>\n @if (d.incident.state !== 'Resolved') {\n <section class=\"jc-card\" data-testid=\"incident-suggestions\">\n <h2>Suggested alerts</h2>\n <jc-suggestions [suggestions]=\"suggestions.value()\" [withAlert]=\"true\" [incident]=\"d.incident.id\" (decided)=\"decided()\" />\n @if (suggestions.error()) { <p class=\"jc-error\">{{ suggestionsError() }}</p> }\n </section>\n }\n <section class=\"jc-card\" data-testid=\"incident-events\">\n <h2>What happened</h2>\n <table class=\"jc-table\"><tbody>\n @for (e of d.events; track $index) {\n <tr>\n <td class=\"jc-nowrap\">{{ e.at | date: 'MMM d, HH:mm:ss' }}</td>\n <td>{{ e.actor }}</td>\n <td><strong>{{ describe(e) }}</strong>@if (e.text) { <div>{{ e.text }}</div> }</td>\n </tr>\n }\n </tbody></table>\n </section>\n }`,\n})\nexport class IncidentPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n readonly id = input.required<string>();\n protected text = '';\n protected readonly sending = signal(false);\n protected readonly actionError = signal('');\n\n protected readonly detail = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.incident(params) });\n protected readonly error = computed(() => problemText(this.detail.error()));\n /** A resolved incident is suggested nothing, so its page doesn't ask. */\n protected readonly suggestions = apiResource({\n params: () => (this.detail.value() && this.detail.value()!.incident.state !== 'Resolved' ? this.id() : undefined),\n stream: ({ params }) => this.api.incidentSuggestions(params),\n });\n protected readonly suggestionsError = computed(() => problemText(this.suggestions.error()));\n\n protected decided() { this.detail.reload(); this.suggestions.reload(); }\n\n protected moves(state: string): string[] { return MOVES[state] ?? []; }\n\n protected describe(e: IncidentEvent): string {\n switch (e.type) {\n case 'created': return 'Opened';\n case 'state': return `${e.from} → ${e.to}`;\n case 'note': return 'Note';\n case 'alert_added': return 'Alert added';\n case 'alert_removed': return 'Alert removed';\n default: return e.type;\n }\n }\n\n private run<T>(request: Observable<T>) {\n this.sending.set(true);\n this.actionError.set('');\n request.subscribe({\n next: () => { this.sending.set(false); this.text = ''; this.detail.reload(); },\n error: e => { this.sending.set(false); this.actionError.set((e as { status?: number }).status === 403 ? 'This needs the operator or admin role.' : problemText(e)); },\n });\n }\n\n protected move(to: string) { this.run(this.api.moveIncident(this.id(), to, this.text)); }\n protected note() { this.run(this.api.addIncidentNote(this.id(), this.text)); }\n protected removeAlert(alertId: string) { this.run(this.api.removeIncidentAlert(this.id(), alertId)); }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAM,QAAkC;CACtC,MAAM;EAAC;EAAiB;EAAa;CAAU;CAC/C,eAAe,CAAC,aAAa,UAAU;CACvC,WAAW,CAAC,iBAAiB,UAAU;CACvC,UAAU,CAAC,eAAe;AAC3B;AAkED,IAAa,eAAb,MAAa,aAAY;CACJ,MAAM,OAAO,cAAc;CAC7B,MAAM,OAAO,UAAU;CAC/B,KAAK,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAC5B,OAAO;CACE,UAAU,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CACvB,cAAc,OAAO,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAExB,SAAS,YAAY;EAAE,cAAc,KAAK,GAAE;EAAI,SAAS,EAAE,aAAa,KAAK,IAAI,SAAS,MAAM;CAAC,CAAE;CACnG,QAAQ,eAAe,YAAY,KAAK,OAAO,MAAK,CAAE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAExD,cAAc,YAAY;EAC3C,cAAe,KAAK,OAAO,MAAK,KAAM,KAAK,OAAO,MAAK,CAAG,CAAC,SAAS,UAAU,aAAa,KAAK,GAAE,IAAK;EACvG,SAAS,EAAE,aAAa,KAAK,IAAI,oBAAoB,MAAM;CAC5D,CAAA;CACkB,mBAAmB,eAAe,YAAY,K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ratio of failed deliveries, 0 to 1. Fires above the threshold.",
25
25
  HostMemory: "Ratio of host memory used, 0 to 1. Fires above the threshold.",
26
26
  MediatorErrors: "Mediator errors in the window. Fires above the threshold.",
27
- ConsumerFailures: "Failed consumer messages in the window. Fires above the threshold."
27
+ ConsumerFailures: "Failed consumer messages in the window. Fires above the threshold.",
28
+ SloBurn: "An SLO's burn rate over a long and a short window. Fires when both reach the rate; one alert per SLO."
28
29
  };
29
30
  function seconds(value) {
30
31
  const match = /^(?:(\d+)\.)?(\d+):(\d+):(\d+)/.exec(String(value ?? ""));
@@ -57,7 +58,7 @@ const NEW_RULE = {
57
58
  var RulesPage = class RulesPage {
58
59
  ctx = inject(ContextService);
59
60
  api = inject(ApiService);
60
- templates = Object.keys(TEMPLATES);
61
+ templates = Object.keys(TEMPLATES).filter((t) => t !== "SloBurn");
61
62
  form = signal(null, ...ngDevMode ? [{ debugName: "form" }] : /* istanbul ignore next */ []);
62
63
  editing = signal(null, ...ngDevMode ? [{ debugName: "editing" }] : /* istanbul ignore next */ []);
63
64
  saving = signal(false, ...ngDevMode ? [{ debugName: "saving" }] : /* istanbul ignore next */ []);
@@ -214,7 +215,7 @@ var RulesPage = class RulesPage {
214
215
  <tbody>
215
216
  @for (r of rows(); track r.key) {
216
217
  <tr [class.jc-muted]="!r.enabled">
217
- <td><strong>{{ r.name }}</strong><div class="jc-muted jc-small">{{ r.key }}@if (!r.enabled) { · disabled }@if (r.managedBy === 'config') { · from the rules file }</div></td>
218
+ <td><strong>{{ r.name }}</strong><div class="jc-muted jc-small">{{ r.key }}@if (!r.enabled) { · disabled }@if (r.managedBy === 'config') { · from the rules file }@if (r.managedBy === 'platform') { · the platform's, for SLOs }</div></td>
218
219
  <td>{{ r.template }}</td>
219
220
  <td>{{ r.severity }}</td>
220
221
  <td>{{ r.definition['threshold'] ?? '—' }}</td>
@@ -226,7 +227,7 @@ var RulesPage = class RulesPage {
226
227
  } @empty { <span class="jc-muted">none</span> }
227
228
  </td>
228
229
  <td>{{ r.lastEvaluatedAt | ago }}</td>
229
- <td class="jc-row-actions">@if (r.managedBy !== 'config') { <button mat-button type="button" [attr.data-testid]="'rule-edit-' + r.key" (click)="edit(r)">Change</button> }</td>
230
+ <td class="jc-row-actions">@if (r.managedBy === 'api') { <button mat-button type="button" [attr.data-testid]="'rule-edit-' + r.key" (click)="edit(r)">Change</button> }</td>
230
231
  </tr>
231
232
  }
232
233
  </tbody>
@@ -555,7 +556,7 @@ i0.ɵɵngDeclareClassMetadata({
555
556
  <tbody>
556
557
  @for (r of rows(); track r.key) {
557
558
  <tr [class.jc-muted]="!r.enabled">
558
- <td><strong>{{ r.name }}</strong><div class="jc-muted jc-small">{{ r.key }}@if (!r.enabled) { · disabled }@if (r.managedBy === 'config') { · from the rules file }</div></td>
559
+ <td><strong>{{ r.name }}</strong><div class="jc-muted jc-small">{{ r.key }}@if (!r.enabled) { · disabled }@if (r.managedBy === 'config') { · from the rules file }@if (r.managedBy === 'platform') { · the platform's, for SLOs }</div></td>
559
560
  <td>{{ r.template }}</td>
560
561
  <td>{{ r.severity }}</td>
561
562
  <td>{{ r.definition['threshold'] ?? '—' }}</td>
@@ -567,7 +568,7 @@ i0.ɵɵngDeclareClassMetadata({
567
568
  } @empty { <span class="jc-muted">none</span> }
568
569
  </td>
569
570
  <td>{{ r.lastEvaluatedAt | ago }}</td>
570
- <td class="jc-row-actions">@if (r.managedBy !== 'config') { <button mat-button type="button" [attr.data-testid]="'rule-edit-' + r.key" (click)="edit(r)">Change</button> }</td>
571
+ <td class="jc-row-actions">@if (r.managedBy === 'api') { <button mat-button type="button" [attr.data-testid]="'rule-edit-' + r.key" (click)="edit(r)">Change</button> }</td>
571
572
  </tr>
572
573
  }
573
574
  </tbody>
@@ -577,4 +578,4 @@ i0.ɵɵngDeclareClassMetadata({
577
578
  });
578
579
  export { RulesPage };
579
580
 
580
- //# sourceMappingURL=juice-js-observability-rules.page-CWaADAe4.mjs.map
581
+ //# sourceMappingURL=juice-js-observability-rules.page-CARCWaw_.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"juice-js-observability-rules.page-CARCWaw_.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/rules.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core';\nimport { FormsModule } from '@angular/forms';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatCheckboxModule } from '@angular/material/checkbox';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { MatSelectModule } from '@angular/material/select';\nimport { apiResource } from '../shared/resource';\nimport { RouterLink } from '@angular/router';\nimport { Observable, forkJoin, map } from 'rxjs';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { Rule } from '../core/models';\nimport { AgoPipe } from '../shared/format';\nimport { ContextBar } from '../shared/ui';\nimport { problemText } from '../shared/telemetry';\n\nconst TEMPLATES: Record<string, string> = {\n ErrorRate: 'Ratio of failed requests, 0 to 1. Fires above the threshold.',\n LatencyP95: 'Milliseconds at the 95th percentile. Fires above the threshold.',\n ThroughputAbsent: 'Requests in the window, for a service that had traffic. Fires at or below the threshold.',\n DeliveryFailureRate: 'Ratio of failed deliveries, 0 to 1. Fires above the threshold.',\n HostMemory: 'Ratio of host memory used, 0 to 1. Fires above the threshold.',\n MediatorErrors: 'Mediator errors in the window. Fires above the threshold.',\n ConsumerFailures: 'Failed consumer messages in the window. Fires above the threshold.',\n SloBurn: \"An SLO's burn rate over a long and a short window. Fires when both reach the rate; one alert per SLO.\",\n};\n\n/** A TimeSpan as the API writes it (`1.02:03:04`) in seconds. */\nfunction seconds(value: unknown): number {\n const match = /^(?:(\\d+)\\.)?(\\d+):(\\d+):(\\d+)/.exec(String(value ?? ''));\n return match ? (+(match[1] ?? 0)) * 86400 + +match[2] * 3600 + +match[3] * 60 + +match[4] : 0;\n}\n\nfunction span(total: number): string {\n const s = Math.max(0, Math.round(total || 0));\n const pad = (n: number) => String(n).padStart(2, '0');\n const days = Math.floor(s / 86400);\n return `${days ? `${days}.` : ''}${pad(Math.floor(s / 3600) % 24)}:${pad(Math.floor(s / 60) % 60)}:${pad(s % 60)}`;\n}\n\ninterface RuleForm {\n key: string; name: string; template: string; severity: string; service: string; environment: string; host: string; threshold: number | null; recoveryThreshold: number | null;\n minimumSamples: number; scheduleSeconds: number; windowSeconds: number; forSeconds: number; recoverySeconds: number; cooldownSeconds: number; enabled: boolean;\n}\n\nconst NEW_RULE: RuleForm = {\n key: '', name: '', template: 'ErrorRate', severity: 'Warning', service: '', environment: '', host: '', threshold: null, recoveryThreshold: null,\n minimumSamples: 10, scheduleSeconds: 60, windowSeconds: 300, forSeconds: 120, recoverySeconds: 120, cooldownSeconds: 600, enabled: true,\n};\n\n/**\n * Rules and their current state (Console requirements §14), and changing them for admins. They stay typed templates (D5): this page never takes a query.\n * A rule in the deployment's file is shown but changed there. Disabling one, or changing what it watches, closes its open alerts, which the form says first.\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, FormsModule, MatButtonModule, MatCheckboxModule, MatFormFieldModule, MatInputModule, MatProgressBarModule, MatSelectModule, ContextBar, AgoPipe],\n template: `\n <jc-context-bar>\n <h1>Rules</h1>\n <span class=\"jc-spacer\"></span>\n <button mat-flat-button type=\"button\" data-testid=\"rule-new\" (click)=\"startNew()\">New rule</button>\n </jc-context-bar>\n @if (data.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (data.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n @if (form(); as f) {\n <section class=\"jc-card\" data-testid=\"rule-form\">\n <h2>{{ editing() ? 'Change ' + editing()!.key : 'New rule' }}</h2>\n <form class=\"jc-form\" (ngSubmit)=\"save(f)\">\n @if (!editing()) { <mat-form-field subscriptSizing=\"dynamic\"><mat-label>Key</mat-label><input matInput name=\"key\" [(ngModel)]=\"f.key\" required></mat-form-field> }\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-wide\"><mat-label>Name</mat-label><input matInput name=\"name\" [(ngModel)]=\"f.name\" required></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\"><mat-label>Template</mat-label>\n <mat-select name=\"template\" [(ngModel)]=\"f.template\">@for (t of templates; track t) { <mat-option [value]=\"t\">{{ t }}</mat-option> }</mat-select>\n </mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Severity</mat-label>\n <mat-select name=\"severity\" [(ngModel)]=\"f.severity\"><mat-option value=\"Info\">Info</mat-option><mat-option value=\"Warning\">Warning</mat-option><mat-option value=\"Critical\">Critical</mat-option></mat-select>\n </mat-form-field>\n @if (f.template === 'HostMemory') {\n <mat-form-field subscriptSizing=\"dynamic\"><mat-label>Host (all if empty)</mat-label><input matInput name=\"host\" [(ngModel)]=\"f.host\"></mat-form-field>\n } @else {\n <mat-form-field subscriptSizing=\"dynamic\"><mat-label>Service (all if empty)</mat-label><input matInput name=\"service\" [(ngModel)]=\"f.service\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\"><mat-label>Environment (all if empty)</mat-label><input matInput name=\"environment\" [(ngModel)]=\"f.environment\"></mat-form-field>\n }\n <p class=\"jc-muted jc-small jc-form-actions\">{{ hint(f.template) }}</p>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Threshold</mat-label><input matInput type=\"number\" step=\"any\" name=\"threshold\" [(ngModel)]=\"f.threshold\" required></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Recovery threshold</mat-label><input matInput type=\"number\" step=\"any\" name=\"recoveryThreshold\" [(ngModel)]=\"f.recoveryThreshold\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Minimum samples</mat-label><input matInput type=\"number\" name=\"minimumSamples\" [(ngModel)]=\"f.minimumSamples\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Every (s)</mat-label><input matInput type=\"number\" name=\"schedule\" [(ngModel)]=\"f.scheduleSeconds\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Window (s)</mat-label><input matInput type=\"number\" name=\"window\" [(ngModel)]=\"f.windowSeconds\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Fire after (s)</mat-label><input matInput type=\"number\" name=\"for\" [(ngModel)]=\"f.forSeconds\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Recover after (s)</mat-label><input matInput type=\"number\" name=\"recovery\" [(ngModel)]=\"f.recoverySeconds\"></mat-form-field>\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-sm\"><mat-label>Cooldown (s)</mat-label><input matInput type=\"number\" name=\"cooldown\" [(ngModel)]=\"f.cooldownSeconds\"></mat-form-field>\n <mat-checkbox name=\"enabled\" [(ngModel)]=\"f.enabled\">Enabled</mat-checkbox>\n @if (editing()) { <p class=\"jc-muted jc-small jc-form-actions\">Disabling this rule, or changing its template or scope, resolves its open alerts: nothing would be watching them any more.</p> }\n <div class=\"jc-form-actions\">\n <button mat-flat-button type=\"submit\" data-testid=\"rule-save\" [disabled]=\"saving()\">Save</button>\n <button mat-button type=\"button\" (click)=\"form.set(null)\">Cancel</button>\n @if (saveError()) { <span class=\"jc-error\" data-testid=\"rule-error\">{{ saveError() }}</span> }\n </div>\n </form>\n </section>\n }\n <table class=\"jc-table\" data-testid=\"rules\">\n <thead><tr><th>Rule</th><th>Template</th><th>Severity</th><th>Threshold</th><th>Recovery</th><th>Wait</th><th>Open alerts</th><th>Last evaluation</th><th></th></tr></thead>\n <tbody>\n @for (r of rows(); track r.key) {\n <tr [class.jc-muted]=\"!r.enabled\">\n <td><strong>{{ r.name }}</strong><div class=\"jc-muted jc-small\">{{ r.key }}@if (!r.enabled) { · disabled }@if (r.managedBy === 'config') { · from the rules file }@if (r.managedBy === 'platform') { · the platform's, for SLOs }</div></td>\n <td>{{ r.template }}</td>\n <td>{{ r.severity }}</td>\n <td>{{ r.definition['threshold'] ?? '—' }}</td>\n <td>{{ r.definition['recoveryThreshold'] ?? '—' }}</td>\n <td>{{ r.definition['forDuration'] ?? '—' }}</td>\n <td>\n @for (a of r.open; track a.id) {\n <div><a [routerLink]=\"['alerts', a.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ a.state }}</a> {{ a.subjectKey }} = {{ a.lastValue ?? 'no data' }}</div>\n } @empty { <span class=\"jc-muted\">none</span> }\n </td>\n <td>{{ r.lastEvaluatedAt | ago }}</td>\n <td class=\"jc-row-actions\">@if (r.managedBy === 'api') { <button mat-button type=\"button\" [attr.data-testid]=\"'rule-edit-' + r.key\" (click)=\"edit(r)\">Change</button> }</td>\n </tr>\n }\n </tbody>\n </table>`,\n})\nexport class RulesPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n /** What a rule can be made from: SloBurn is described, but its rules are the platform's own, made for SLOs. */\n protected readonly templates = Object.keys(TEMPLATES).filter(t => t !== 'SloBurn');\n protected readonly form = signal<RuleForm | null>(null);\n protected readonly editing = signal<Rule | null>(null);\n protected readonly saving = signal(false);\n protected readonly saveError = signal('');\n protected readonly data = apiResource({\n stream: () => forkJoin({\n rules: this.api.rules().pipe(map(p => p.items)),\n firing: this.api.allAlerts({ state: 'firing' }).pipe(map(p => p.items)),\n pending: this.api.allAlerts({ state: 'pending' }).pipe(map(p => p.items)),\n }),\n });\n protected readonly error = computed(() => problemText(this.data.error()));\n protected readonly rows = computed(() => {\n const d = this.data.value();\n if (!d) return [];\n const open = [...d.firing, ...d.pending];\n return d.rules.map(r => {\n const mine = open.filter(a => a.rule === r.key);\n const last = mine.map(a => a.lastEvaluatedAt).sort().at(-1) ?? null;\n return { ...r, open: mine, lastEvaluatedAt: last };\n });\n });\n\n protected hint(template: string): string { return TEMPLATES[template] ?? ''; }\n\n protected startNew() { this.editing.set(null); this.saveError.set(''); this.form.set({ ...NEW_RULE }); }\n\n protected edit(rule: Rule) {\n const d = rule.definition;\n this.editing.set(rule);\n this.saveError.set('');\n this.form.set({\n key: rule.key, name: rule.name, template: rule.template, severity: rule.severity, service: String(d['service'] ?? ''), environment: String(d['environment'] ?? ''), host: String(d['host'] ?? ''),\n threshold: d['threshold'] as number, recoveryThreshold: (d['recoveryThreshold'] as number | null) ?? null, minimumSamples: d['minimumSamples'] as number, scheduleSeconds: seconds(d['schedule']), windowSeconds: seconds(d['window']),\n forSeconds: seconds(d['forDuration']), recoverySeconds: seconds(d['recoveryDuration']), cooldownSeconds: seconds(d['cooldown']), enabled: rule.enabled,\n });\n }\n\n protected save(f: RuleForm) {\n const host = f.template === 'HostMemory';\n const body = {\n key: f.key, name: f.name, template: f.template, severity: f.severity, service: host ? '' : f.service.trim(), environment: host ? '' : f.environment.trim().toLowerCase(), host: host ? f.host.trim() : '',\n threshold: f.threshold, recoveryThreshold: f.recoveryThreshold, minimumSamples: f.minimumSamples, schedule: span(f.scheduleSeconds), window: span(f.windowSeconds), forDuration: span(f.forSeconds),\n recoveryDuration: span(f.recoverySeconds), cooldown: span(f.cooldownSeconds), enabled: f.enabled,\n };\n const editing = this.editing();\n const request: Observable<Rule> = editing ? this.api.updateRule(editing.key, body, editing.etag) : this.api.createRule(body);\n this.saving.set(true);\n this.saveError.set('');\n request.subscribe({\n next: () => { this.saving.set(false); this.form.set(null); this.data.reload(); },\n error: e => { this.saving.set(false); this.saveError.set(problemText(e)); },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,YAAoC;CACxC,WAAW;CACX,YAAY;CACZ,kBAAkB;CAClB,qBAAqB;CACrB,YAAY;CACZ,gBAAgB;CAChB,kBAAkB;CAClB,SAAS;AACV;AAGD,SAAS,QAAQ,OAAc;C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e;GAAA;IAAA,MAAA;IAAA,MAAA,GAAA;IAAA,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IAAA;IAAA,SAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IAAA;IAAA,UAAA,CAAA,WAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAA,GAAA;IAAA,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;IAAA;IAAA,SAAA,CAAA,mBAAA;IAAA,UAAA,CAAA,WAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAU,UAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAA5J;IAAQ,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAsJ;IAAO,MAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAqEpK,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EAvErB,MAAA;EAAU,MAAA,CAAA;GACT,iBAAiB,wBAAwB;GACzC,SAAS;IAAC;IAAU;IAAY;IAAa;IAAiB;IAAmB;IAAoB;IAAgB;IAAsB;IAAiB;IAAY;GAAO;GAC/K,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmEX,CAAA"}
@@ -125,6 +125,29 @@ var SloPage = class SloPage {
125
125
  </table>
126
126
  </section>
127
127
 
128
+ <section class="jc-card" data-testid="slo-alerts">
129
+ <h2>Burn alerts</h2>
130
+ <p class="jc-muted jc-small">Fast burn (14.4× over 1 hour and 5 minutes) is critical; slow burn (6× over 6 hours and 30 minutes, 1× over 3 days and 6 hours) a warning.
131
+ Each fires when both its windows reach the rate and resolves when its short window is under it, then waits at least 10 minutes before firing
132
+ again. A window without a rate holds the alert as it is.</p>
133
+ @if (d.alerts.length) {
134
+ <table class="jc-table">
135
+ <thead><tr><th>Alert</th><th>State</th><th>Fired</th><th>Resolved</th><th>Burn rate</th></tr></thead>
136
+ <tbody>
137
+ @for (a of d.alerts; track a.id) {
138
+ <tr [attr.data-testid]="'slo-alert-' + a.rule">
139
+ <td><a [routerLink]="['alerts', a.id] | jcLink" [queryParams]="ctx.keep()">{{ a.rule }}</a> <span class="jc-muted jc-small">{{ a.severity }}</span></td>
140
+ <td>{{ a.state }}@if (a.noData && a.state !== 'Resolved') { <span class="jc-muted jc-small"> · held: a window has no rate</span> }</td>
141
+ <td class="jc-nowrap">{{ a.firedAt | date: 'MMM d, HH:mm' }}</td>
142
+ <td class="jc-nowrap">{{ a.resolvedAt ? (a.resolvedAt | date: 'MMM d, HH:mm') : '—' }}</td>
143
+ <td>{{ a.burnRate === null ? '—' : times(a.burnRate) }}</td>
144
+ </tr>
145
+ }
146
+ </tbody>
147
+ </table>
148
+ } @else { <p class="jc-muted">No burn alerts yet.</p> }
149
+ </section>
150
+
128
151
  <section class="jc-card" data-testid="slo-days">
129
152
  <h2>By day</h2>
130
153
  @if (d.days.length) {
@@ -301,6 +324,29 @@ i0.ɵɵngDeclareClassMetadata({
301
324
  </table>
302
325
  </section>
303
326
 
327
+ <section class="jc-card" data-testid="slo-alerts">
328
+ <h2>Burn alerts</h2>
329
+ <p class="jc-muted jc-small">Fast burn (14.4× over 1 hour and 5 minutes) is critical; slow burn (6× over 6 hours and 30 minutes, 1× over 3 days and 6 hours) a warning.
330
+ Each fires when both its windows reach the rate and resolves when its short window is under it, then waits at least 10 minutes before firing
331
+ again. A window without a rate holds the alert as it is.</p>
332
+ @if (d.alerts.length) {
333
+ <table class="jc-table">
334
+ <thead><tr><th>Alert</th><th>State</th><th>Fired</th><th>Resolved</th><th>Burn rate</th></tr></thead>
335
+ <tbody>
336
+ @for (a of d.alerts; track a.id) {
337
+ <tr [attr.data-testid]="'slo-alert-' + a.rule">
338
+ <td><a [routerLink]="['alerts', a.id] | jcLink" [queryParams]="ctx.keep()">{{ a.rule }}</a> <span class="jc-muted jc-small">{{ a.severity }}</span></td>
339
+ <td>{{ a.state }}@if (a.noData && a.state !== 'Resolved') { <span class="jc-muted jc-small"> · held: a window has no rate</span> }</td>
340
+ <td class="jc-nowrap">{{ a.firedAt | date: 'MMM d, HH:mm' }}</td>
341
+ <td class="jc-nowrap">{{ a.resolvedAt ? (a.resolvedAt | date: 'MMM d, HH:mm') : '—' }}</td>
342
+ <td>{{ a.burnRate === null ? '—' : times(a.burnRate) }}</td>
343
+ </tr>
344
+ }
345
+ </tbody>
346
+ </table>
347
+ } @else { <p class="jc-muted">No burn alerts yet.</p> }
348
+ </section>
349
+
304
350
  <section class="jc-card" data-testid="slo-days">
305
351
  <h2>By day</h2>
306
352
  @if (d.days.length) {
@@ -365,4 +411,4 @@ i0.ɵɵngDeclareClassMetadata({
365
411
  });
366
412
  export { SloPage };
367
413
 
368
- //# sourceMappingURL=juice-js-observability-slo.page-DZGsui_P.mjs.map
414
+ //# sourceMappingURL=juice-js-observability-slo.page-l7TOat-D.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"juice-js-observability-slo.page-l7TOat-D.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/slo.page.ts"],"sourcesContent":["import { DatePipe } from '@angular/common';\nimport { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { RouterLink } from '@angular/router';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { SloDay, SloDefinition, SloSummary } from '../core/models';\nimport { LinkPipe } from '../core/options';\nimport { apiResource } from '../shared/resource';\nimport { problemText } from '../shared/telemetry';\nimport { ContextBar } from '../shared/ui';\nimport { burnText, objective, percent, sloState, times } from './slos.page';\n\nconst WINDOWS: Record<string, string> = { '5m': '5 minutes', '30m': '30 minutes', '1h': '1 hour', '6h': '6 hours', '3d': '3 days' };\n\n/**\n * One SLO (roadmap Phase 9): its budget over the last 30 days, how fast it burns in each window, its days, what counts as a request, and its versions.\n * A window with too few requests, or too many minutes that weren't counted, says so instead of a figure.\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [RouterLink, LinkPipe, DatePipe, MatProgressBarModule, ContextBar],\n template: `\n <jc-context-bar>\n <a class=\"jc-crumb\" [routerLink]=\"['slos'] | jcLink\" [queryParams]=\"ctx.keep()\">SLOs</a><span class=\"jc-crumb-sep\">›</span>\n <h1>{{ detail.value()?.slo?.name ?? key() }}</h1>\n </jc-context-bar>\n @if (detail.isLoading() && !detail.value()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (detail.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n @if (detail.value(); as d) {\n <p class=\"jc-summary\">\n <span class=\"jc-badge\" [class]=\"state(d.slo.state).css\" data-testid=\"slo-state\">{{ state(d.slo.state).text }}</span>\n <strong>{{ objective(d.slo) }}</strong> · {{ d.slo.category }} · {{ d.slo.service }} in {{ d.slo.environment }} · version {{ d.slo.version }}\n @if (d.slo.pendingVersion) { <span class=\"jc-muted\"> (version {{ d.slo.pendingVersion }} pending)</span> }\n @if (d.slo.retired) { <span class=\"jc-muted\"> · retired</span> }\n </p>\n\n <section class=\"jc-card\" data-testid=\"slo-budget\">\n <h2>Error budget, last 30 days</h2>\n @switch (d.slo.state) {\n @case ('Unknown') {\n <p data-testid=\"slo-budget-unknown\">Only {{ percent(d.slo.coverage, 1) }} of the last 30 days' minutes are counted, so there's no budget to show yet. Minutes that weren't\n read are never taken as good: either counting is still catching up, or telemetry didn't arrive.</p>\n }\n @case ('InsufficientData') {\n <p>{{ d.slo.total.toLocaleString() }} requests in 30 days: too few to say whether the objective is met.</p>\n }\n @default {\n <p><strong>{{ percent(d.slo.attainment, 3) }}</strong> of {{ d.slo.total.toLocaleString() }} requests were good, against an objective of {{ d.slo.target }}%.</p>\n @if ((d.slo.budgetUsed ?? 0) <= 1) {\n <p>{{ percent(d.slo.budgetUsed, 1) }} of the budget is used ({{ d.slo.bad.toLocaleString() }} bad of {{ allowed(d.slo).toLocaleString() }} allowed),\n {{ percent(d.slo.budgetRemaining, 1) }} left.</p>\n } @else {\n <p class=\"jc-bad\">The budget is overspent: {{ d.slo.bad.toLocaleString() }} bad requests against {{ allowed(d.slo).toLocaleString() }} allowed, {{ times(d.slo.budgetUsed!) }} the budget.</p>\n }\n }\n }\n </section>\n\n <section class=\"jc-card\" data-testid=\"slo-burn\">\n <h2>Burn rate</h2>\n <p class=\"jc-muted jc-small\">How fast the budget is being spent: 1× spends it exactly over 30 days. A window needs enough requests, and nearly all its minutes counted.</p>\n <table class=\"jc-table\">\n <thead><tr><th>Window</th><th>Requests</th><th>Good</th><th>Burn rate</th></tr></thead>\n <tbody>\n @for (w of d.slo.burn; track w.name) {\n <tr [attr.data-testid]=\"'slo-burn-' + w.name\">\n <td>{{ windowName(w.name) }}</td><td>{{ w.total.toLocaleString() }}</td><td>{{ percent(w.attainment, 2) }}</td><td>{{ burn(w) }}</td>\n </tr>\n }\n </tbody>\n </table>\n </section>\n\n <section class=\"jc-card\" data-testid=\"slo-alerts\">\n <h2>Burn alerts</h2>\n <p class=\"jc-muted jc-small\">Fast burn (14.4× over 1 hour and 5 minutes) is critical; slow burn (6× over 6 hours and 30 minutes, 1× over 3 days and 6 hours) a warning.\n Each fires when both its windows reach the rate and resolves when its short window is under it, then waits at least 10 minutes before firing\n again. A window without a rate holds the alert as it is.</p>\n @if (d.alerts.length) {\n <table class=\"jc-table\">\n <thead><tr><th>Alert</th><th>State</th><th>Fired</th><th>Resolved</th><th>Burn rate</th></tr></thead>\n <tbody>\n @for (a of d.alerts; track a.id) {\n <tr [attr.data-testid]=\"'slo-alert-' + a.rule\">\n <td><a [routerLink]=\"['alerts', a.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ a.rule }}</a> <span class=\"jc-muted jc-small\">{{ a.severity }}</span></td>\n <td>{{ a.state }}@if (a.noData && a.state !== 'Resolved') { <span class=\"jc-muted jc-small\"> · held: a window has no rate</span> }</td>\n <td class=\"jc-nowrap\">{{ a.firedAt | date: 'MMM d, HH:mm' }}</td>\n <td class=\"jc-nowrap\">{{ a.resolvedAt ? (a.resolvedAt | date: 'MMM d, HH:mm') : '—' }}</td>\n <td>{{ a.burnRate === null ? '—' : times(a.burnRate) }}</td>\n </tr>\n }\n </tbody>\n </table>\n } @else { <p class=\"jc-muted\">No burn alerts yet.</p> }\n </section>\n\n <section class=\"jc-card\" data-testid=\"slo-days\">\n <h2>By day</h2>\n @if (d.days.length) {\n <table class=\"jc-table\">\n <thead><tr><th>Day</th><th>Requests</th><th>Good</th><th>Left out</th><th>Minutes counted</th></tr></thead>\n <tbody>\n @for (day of daysNewestFirst(d.days); track day.day) {\n <tr>\n <td class=\"jc-nowrap\">{{ day.day | date: 'MMM d' : 'UTC' }}</td>\n <td>{{ day.total.toLocaleString() }}</td>\n <td [class.jc-bad]=\"day.attainment !== null && day.attainment * 100 < d.slo.target\">{{ percent(day.attainment, 3) }}</td>\n <td class=\"jc-small\">{{ excluded(day) }}</td>\n <td [class.jc-bad]=\"day.minutes < day.expectedMinutes && !isToday(day)\">{{ day.minutes }} of {{ day.expectedMinutes }}</td>\n </tr>\n }\n </tbody>\n </table>\n } @else { <p class=\"jc-muted\">Nothing counted yet.</p> }\n </section>\n\n <section class=\"jc-card\" data-testid=\"slo-eligibility\">\n <h2>What counts</h2>\n <ul class=\"jc-small\">\n <li>Requests to <strong>{{ d.definition.service }}</strong> in {{ d.definition.environment }}: its server and consumer spans,\n {{ d.definition.operations.length ? 'only ' + d.definition.operations.join(', ') : 'every operation' }}.</li>\n <li>Never counted: {{ d.definition.excludeOperations.join(', ') || 'nothing' }} (health checks and the like).</li>\n <li>5xx, 429, a failed span and a failed message are bad.</li>\n <li>Other 4xx (the client's mistake): {{ clientErrors(d.definition) }}.</li>\n <li>408 and 499 (the client gave up): {{ d.definition.cancellations === 'Bad' ? 'counted as bad' : 'not counted' }}.</li>\n <li>Retries: each attempt the service received is its own request.</li>\n @if (d.definition.sli === 'Latency') { <li>Latency counts requests that succeeded: good at {{ d.definition.thresholdMs }} ms or less.</li> }\n </ul>\n </section>\n\n <section class=\"jc-card\" data-testid=\"slo-versions\">\n <h2>Versions</h2>\n <table class=\"jc-table\">\n <thead><tr><th>Version</th><th>Objective</th><th>From</th><th>Status</th><th>Loaded</th></tr></thead>\n <tbody>\n @for (v of d.versions; track v.version) {\n <tr [attr.data-testid]=\"'slo-version-' + v.version\">\n <td>{{ v.version }}</td><td>{{ objective(v.definition) }}</td><td class=\"jc-nowrap\">{{ v.effectiveFrom | date: 'MMM d, HH:mm' }}</td>\n <td>{{ v.status }}</td><td class=\"jc-small\">{{ v.createdAt | date: 'MMM d, HH:mm' }} by {{ v.createdBy }}</td>\n </tr>\n }\n </tbody>\n </table>\n <p class=\"jc-muted jc-small\">Each minute is counted under the version in effect then, so a new objective doesn't rewrite the past.</p>\n </section>\n }\n `,\n})\nexport class SloPage {\n readonly key = input.required<string>();\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n protected readonly detail = apiResource({ params: () => this.key(), stream: ({ params }) => this.api.slo(params) });\n protected readonly error = computed(() => problemText(this.detail.error()));\n protected readonly objective = objective;\n protected readonly percent = percent;\n protected readonly burn = burnText;\n\n protected readonly state = sloState;\n protected readonly times = times;\n protected windowName(name: string) { return WINDOWS[name] ?? name; }\n /** The API's allowance: each version's requests at its own target, so it agrees with the budget used. */\n protected allowed(s: SloSummary) { return Math.round(s.budgetAllowed); }\n protected daysNewestFirst(days: SloDay[]) { return [...days].reverse(); }\n protected isToday(day: SloDay) { return day.day.slice(0, 10) === new Date().toISOString().slice(0, 10); }\n protected excluded(day: SloDay) {\n const parts = [[day.excludedHealth, 'health checks'], [day.excludedCancelled, 'given up'], [day.excludedClientErrors, 'client errors']]\n .filter(([n]) => (n as number) > 0).map(([n, what]) => `${(n as number).toLocaleString()} ${what}`);\n return parts.length ? parts.join(', ') : '—';\n }\n protected clientErrors(d: SloDefinition) { return d.clientErrors === 'Bad' ? 'bad' : d.clientErrors === 'Exclude' ? 'not counted' : 'counted as good'; }\n}\n"],"mappings":";;;;;;;;;AAaA,MAAM,UAAkC;CAAE,MAAM;CAAa,OAAO;CAAc,MAAM;CAAU,MAAM;CAAW,MAAM;AAAQ;AAwIjI,IAAa,UAAb,MAAa,QAAO;CACT,MAAM,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,MAAA,CAAA,+BAAA,CAAA,CAAA;CACpB,MAAM,OAAO,cAAc;CAC7B,MAAM,OAAO,UAAU;CACrB,SAAS,YAAY;EAAE,cAAc,KAAK,IAAG;EAAI,SAAS,EAAE,aAAa,KAAK,IAAI,IAAI,MAAM;CAAC,CAAE;CAC/F,QAAQ,eAAe,YAAY,KAAK,OAAO,MAAK,CAAE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACxD,YAAY;CACZ,UAAU;CACV,OAAO;CAEP,QAAQ;CACR,QAAQ;CACjB,WAAW,MAAY;EAAI,OAAO,QAAQ,SAAS;CAAM;CAEzD,QAAQ,GAAa;EAAI,OAAO,KAAK,MAAM,EAAE,aAAa;CAAG;CAC7D,gBAAgB,MAAc;EAAI,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,QAAO;CAAI;CAC9D,QAAQ,KAAW;EAAI,OAAO,IAAI,IAAI,MAAM,GAAG,EAAE,uBAAM,IAAI,KAAI,EAAE,CAAC,YAAW,CAAE,CAAC,MAAM,GAAG,EAAE;CAAG;CAC9F,SAAS,KAAW;EAC5B,MAAM,QAAQ;GAAC,CAAC,IAAI,gBAAgB,eAAe;GAAG,CAAC,IAAI,mBAAmB,UAAU;GAAG,CAAC,IAAI,sBAAsB,eAAe;EAAC,CAAC,CACpI,QAAQ,CAAC,OAAQ,IAAe,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,UAAU,GAA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