@trismegisto/spine 2.1.2 → 3.0.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 (78) hide show
  1. package/README.md +74 -17
  2. package/fesm2022/trismegisto-spine-audit.mjs +264 -10
  3. package/fesm2022/trismegisto-spine-audit.mjs.map +1 -1
  4. package/fesm2022/trismegisto-spine-auto-service-apps.technical-BAKdkVdz.mjs +84 -0
  5. package/fesm2022/trismegisto-spine-auto-service-apps.technical-BAKdkVdz.mjs.map +1 -0
  6. package/fesm2022/trismegisto-spine-auto-service-apps.usage-CAXMP5r8.mjs +87 -0
  7. package/fesm2022/trismegisto-spine-auto-service-apps.usage-CAXMP5r8.mjs.map +1 -0
  8. package/fesm2022/{trismegisto-spine-auto-service-audit.technical-C901aIIQ.mjs → trismegisto-spine-auto-service-audit.technical-B75d4mh2.mjs} +6 -5
  9. package/fesm2022/trismegisto-spine-auto-service-audit.technical-B75d4mh2.mjs.map +1 -0
  10. package/fesm2022/{trismegisto-spine-auto-service-audit.usage-GIJ2RwuH.mjs → trismegisto-spine-auto-service-audit.usage-IdXMruv5.mjs} +9 -8
  11. package/fesm2022/trismegisto-spine-auto-service-audit.usage-IdXMruv5.mjs.map +1 -0
  12. package/fesm2022/{trismegisto-spine-auto-service-auto-service-audit.component-CCiz-q8o.mjs → trismegisto-spine-auto-service-auto-service-audit.component-BIL8tH1I.mjs} +4 -4
  13. package/fesm2022/{trismegisto-spine-auto-service-auto-service-audit.component-CCiz-q8o.mjs.map → trismegisto-spine-auto-service-auto-service-audit.component-BIL8tH1I.mjs.map} +1 -1
  14. package/fesm2022/{trismegisto-spine-auto-service-auto-service-client-picker.component-Z0wCANF6.mjs → trismegisto-spine-auto-service-auto-service-client-picker.component-CBt_0Uli.mjs} +3 -3
  15. package/fesm2022/{trismegisto-spine-auto-service-auto-service-client-picker.component-Z0wCANF6.mjs.map → trismegisto-spine-auto-service-auto-service-client-picker.component-CBt_0Uli.mjs.map} +1 -1
  16. package/fesm2022/{trismegisto-spine-auto-service-auto-service-client.component-C7SPavrX.mjs → trismegisto-spine-auto-service-auto-service-client.component-DAxhZC-a.mjs} +123 -27
  17. package/fesm2022/trismegisto-spine-auto-service-auto-service-client.component-DAxhZC-a.mjs.map +1 -0
  18. package/fesm2022/trismegisto-spine-auto-service-auto-service-delete-CoJYTtBU.mjs +87 -0
  19. package/fesm2022/trismegisto-spine-auto-service-auto-service-delete-CoJYTtBU.mjs.map +1 -0
  20. package/fesm2022/trismegisto-spine-auto-service-auto-service-groups.component-UVMGF7-B.mjs +544 -0
  21. package/fesm2022/trismegisto-spine-auto-service-auto-service-groups.component-UVMGF7-B.mjs.map +1 -0
  22. package/fesm2022/trismegisto-spine-auto-service-auto-service-login-attempts.component-Boi-kG0G.mjs +37 -0
  23. package/fesm2022/trismegisto-spine-auto-service-auto-service-login-attempts.component-Boi-kG0G.mjs.map +1 -0
  24. package/fesm2022/trismegisto-spine-auto-service-auto-service.component-DmLafUkX.mjs +943 -0
  25. package/fesm2022/trismegisto-spine-auto-service-auto-service.component-DmLafUkX.mjs.map +1 -0
  26. package/fesm2022/{trismegisto-spine-auto-service-client.technical-BHWhpyWv.mjs → trismegisto-spine-auto-service-client.technical-DP5G8i3o.mjs} +24 -3
  27. package/fesm2022/trismegisto-spine-auto-service-client.technical-DP5G8i3o.mjs.map +1 -0
  28. package/fesm2022/{trismegisto-spine-auto-service-client.usage-CM2WB2e2.mjs → trismegisto-spine-auto-service-client.usage-CcJANb20.mjs} +15 -6
  29. package/fesm2022/trismegisto-spine-auto-service-client.usage-CcJANb20.mjs.map +1 -0
  30. package/fesm2022/trismegisto-spine-auto-service-groups.technical-BlktCM70.mjs +65 -0
  31. package/fesm2022/trismegisto-spine-auto-service-groups.technical-BlktCM70.mjs.map +1 -0
  32. package/fesm2022/trismegisto-spine-auto-service-groups.usage-Cz5sCKgn.mjs +81 -0
  33. package/fesm2022/trismegisto-spine-auto-service-groups.usage-Cz5sCKgn.mjs.map +1 -0
  34. package/fesm2022/{trismegisto-spine-auto-service-home.component-vl3BPFnk.mjs → trismegisto-spine-auto-service-home.component-5_aji1hf.mjs} +5 -4
  35. package/fesm2022/trismegisto-spine-auto-service-home.component-5_aji1hf.mjs.map +1 -0
  36. package/fesm2022/trismegisto-spine-auto-service-login-attempts.technical-CasKIIws.mjs +37 -0
  37. package/fesm2022/trismegisto-spine-auto-service-login-attempts.technical-CasKIIws.mjs.map +1 -0
  38. package/fesm2022/trismegisto-spine-auto-service-login-attempts.usage-BMgLNu7W.mjs +60 -0
  39. package/fesm2022/trismegisto-spine-auto-service-login-attempts.usage-BMgLNu7W.mjs.map +1 -0
  40. package/fesm2022/trismegisto-spine-auto-service.mjs +49 -29
  41. package/fesm2022/trismegisto-spine-auto-service.mjs.map +1 -1
  42. package/fesm2022/trismegisto-spine-layout.mjs +1698 -156
  43. package/fesm2022/trismegisto-spine-layout.mjs.map +1 -1
  44. package/fesm2022/trismegisto-spine-shell.mjs +17 -1
  45. package/fesm2022/trismegisto-spine-shell.mjs.map +1 -1
  46. package/fesm2022/trismegisto-spine.mjs +1157 -85
  47. package/fesm2022/trismegisto-spine.mjs.map +1 -1
  48. package/package.json +6 -6
  49. package/types/trismegisto-spine-audit.d.ts +180 -5
  50. package/types/trismegisto-spine-audit.d.ts.map +1 -1
  51. package/types/trismegisto-spine-auto-service.d.ts +100 -7
  52. package/types/trismegisto-spine-auto-service.d.ts.map +1 -1
  53. package/types/trismegisto-spine-layout.d.ts +833 -13
  54. package/types/trismegisto-spine-layout.d.ts.map +1 -1
  55. package/types/trismegisto-spine-shell.d.ts +8 -0
  56. package/types/trismegisto-spine-shell.d.ts.map +1 -1
  57. package/types/trismegisto-spine.d.ts +491 -32
  58. package/types/trismegisto-spine.d.ts.map +1 -1
  59. package/fesm2022/trismegisto-spine-auto-service-apps.technical-ClMKB9cK.mjs +0 -48
  60. package/fesm2022/trismegisto-spine-auto-service-apps.technical-ClMKB9cK.mjs.map +0 -1
  61. package/fesm2022/trismegisto-spine-auto-service-apps.usage-Cf5SG-oQ.mjs +0 -55
  62. package/fesm2022/trismegisto-spine-auto-service-apps.usage-Cf5SG-oQ.mjs.map +0 -1
  63. package/fesm2022/trismegisto-spine-auto-service-audit.technical-C901aIIQ.mjs.map +0 -1
  64. package/fesm2022/trismegisto-spine-auto-service-audit.usage-GIJ2RwuH.mjs.map +0 -1
  65. package/fesm2022/trismegisto-spine-auto-service-auto-service-client.component-C7SPavrX.mjs.map +0 -1
  66. package/fesm2022/trismegisto-spine-auto-service-auto-service-delete-6Bk46MOf.mjs +0 -39
  67. package/fesm2022/trismegisto-spine-auto-service-auto-service-delete-6Bk46MOf.mjs.map +0 -1
  68. package/fesm2022/trismegisto-spine-auto-service-auto-service-groups.component-CqIVe2LU.mjs +0 -357
  69. package/fesm2022/trismegisto-spine-auto-service-auto-service-groups.component-CqIVe2LU.mjs.map +0 -1
  70. package/fesm2022/trismegisto-spine-auto-service-auto-service.component-BLN49F4a.mjs +0 -502
  71. package/fesm2022/trismegisto-spine-auto-service-auto-service.component-BLN49F4a.mjs.map +0 -1
  72. package/fesm2022/trismegisto-spine-auto-service-client.technical-BHWhpyWv.mjs.map +0 -1
  73. package/fesm2022/trismegisto-spine-auto-service-client.usage-CM2WB2e2.mjs.map +0 -1
  74. package/fesm2022/trismegisto-spine-auto-service-groups.technical-jQlwaQPn.mjs +0 -39
  75. package/fesm2022/trismegisto-spine-auto-service-groups.technical-jQlwaQPn.mjs.map +0 -1
  76. package/fesm2022/trismegisto-spine-auto-service-groups.usage-Bh7ig2zZ.mjs +0 -54
  77. package/fesm2022/trismegisto-spine-auto-service-groups.usage-Bh7ig2zZ.mjs.map +0 -1
  78. package/fesm2022/trismegisto-spine-auto-service-home.component-vl3BPFnk.mjs.map +0 -1
@@ -0,0 +1,943 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, ChangeDetectorRef, EventEmitter, Output, Input, ChangeDetectionStrategy, Component, computed } from '@angular/core';
3
+ import * as i2 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import { A as AutoServiceClientPickerComponent } from './trismegisto-spine-auto-service-auto-service-client-picker.component-CBt_0Uli.mjs';
6
+ import { HttpErrorResponse } from '@angular/common/http';
7
+ import { ButtonComponent, CheckboxComponent, InputComponent, ModalComponent, ComboboxComponent, HermesToastService, DrawerComponent, IconComponent, TagComponent, DataGridComponent, DataGridCellDirective, AlertComponent, CopyButtonComponent, DatePickerComponent, TextareaComponent, HermesDialogService, CardComponent, TabsComponent, TabComponent, TabContentDirective } from '@trismegisto/angular';
8
+ import { formatMessage, pluralMessage } from '@trismegisto/primitives';
9
+ import { SPINE_MESSAGES } from '@trismegisto/spine';
10
+ import { a as autoServiceErrorText, A as AutoServiceDeleteFeedback } from './trismegisto-spine-auto-service-auto-service-delete-CoJYTtBU.mjs';
11
+ import { AutoServiceService } from './trismegisto-spine-auto-service.mjs';
12
+ import * as i3 from '@angular/forms';
13
+ import { FormControl, Validators, ReactiveFormsModule } from '@angular/forms';
14
+
15
+ class AutoServiceAppsModalComponent {
16
+ constructor(service) {
17
+ this.service = service;
18
+ this.text = inject(SPINE_MESSAGES).autoService;
19
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
20
+ this.cdr = inject(ChangeDetectorRef);
21
+ this.app = null;
22
+ this.clientId = '';
23
+ this.open = false;
24
+ this.openChange = new EventEmitter();
25
+ this.saved = new EventEmitter();
26
+ this.name = new FormControl('', { nonNullable: true, validators: [Validators.required] });
27
+ this.grants = new FormControl('client_credentials', { nonNullable: true });
28
+ this.enabled = new FormControl(true, { nonNullable: true });
29
+ this.saving = false;
30
+ }
31
+ get isEdit() { return !!this.app?.id; }
32
+ ngOnChanges(changes) { if (changes['open'] && this.open) {
33
+ this.resetForm();
34
+ } }
35
+ resetForm() {
36
+ if (this.isEdit) {
37
+ this.name.setValue(this.app.name);
38
+ this.grants.setValue(this.app.allowed_grants?.join(', ') ?? '');
39
+ this.enabled.setValue(this.app.enabled);
40
+ }
41
+ else {
42
+ this.name.setValue('');
43
+ this.grants.setValue('client_credentials');
44
+ this.enabled.setValue(true);
45
+ }
46
+ }
47
+ onModalOpenChange(value) { this.open = value; this.openChange.emit(value); }
48
+ close() { this.onModalOpenChange(false); }
49
+ async save() {
50
+ this.saving = true;
51
+ try {
52
+ const allowed_grants = this.grants.value.split(',').map(s => s.trim()).filter(Boolean);
53
+ if (this.isEdit) {
54
+ await this.service.updateApp(this.clientId, this.app.id, { name: this.name.value, allowed_grants, enabled: this.enabled.value });
55
+ this.saved.emit();
56
+ }
57
+ else {
58
+ const res = await this.service.createApp(this.clientId, { name: this.name.value, allowed_grants });
59
+ this.saved.emit(res.secret);
60
+ }
61
+ this.close();
62
+ }
63
+ finally {
64
+ this.saving = false;
65
+ this.cdr.markForCheck();
66
+ }
67
+ }
68
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppsModalComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
69
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceAppsModalComponent, isStandalone: true, selector: "spine-auto-service-apps-modal", inputs: { app: "app", clientId: "clientId", open: "open" }, outputs: { openChange: "openChange", saved: "saved" }, usesOnChanges: true, ngImport: i0, template: "<hm-modal [open]=\"open\" (openChange)=\"onModalOpenChange($event)\" [heading]=\"isEdit ? text.editApp : text.newApp\" (closed)=\"close()\">\n <div class=\"form-stack\">\n <hm-input [formControl]=\"name\" [label]=\"text.name\" />\n <hm-input [formControl]=\"grants\" [label]=\"text.grants\" placeholder=\"client_credentials\" />\n <hm-checkbox *ngIf=\"isEdit\" [formControl]=\"enabled\" [label]=\"text.active\" />\n </div>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!name.value\" [loading]=\"saving\" (clicked)=\"save()\">{{ text.save }}</hm-button>\n </ng-container>\n</hm-modal>\n", styles: [".form-stack{display:flex;flex-direction:column;gap:var(--hm-space-sm)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: CheckboxComponent, selector: "hm-checkbox", inputs: ["label", "labelHidden", "checked", "indeterminate"], outputs: ["checkedChange"] }, { kind: "component", type: InputComponent, selector: "hm-input", inputs: ["value", "label", "type", "placeholder", "icon", "labelHidden", "hint", "prefix", "suffix", "prefixIcon", "mask", "maskValue", "min", "max", "step", "stepButtons", "maxLength", "autocomplete", "inputMode"], outputs: ["valueChange"] }, { kind: "component", type: ModalComponent, selector: "hm-modal", inputs: ["open", "heading", "size", "closeLabel", "closable", "beforeClose"], outputs: ["openChange", "closed"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
70
+ }
71
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppsModalComponent, decorators: [{
72
+ type: Component,
73
+ args: [{ selector: 'spine-auto-service-apps-modal', standalone: true, imports: [CommonModule, ReactiveFormsModule, ButtonComponent, CheckboxComponent, InputComponent, ModalComponent], changeDetection: ChangeDetectionStrategy.Eager, template: "<hm-modal [open]=\"open\" (openChange)=\"onModalOpenChange($event)\" [heading]=\"isEdit ? text.editApp : text.newApp\" (closed)=\"close()\">\n <div class=\"form-stack\">\n <hm-input [formControl]=\"name\" [label]=\"text.name\" />\n <hm-input [formControl]=\"grants\" [label]=\"text.grants\" placeholder=\"client_credentials\" />\n <hm-checkbox *ngIf=\"isEdit\" [formControl]=\"enabled\" [label]=\"text.active\" />\n </div>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!name.value\" [loading]=\"saving\" (clicked)=\"save()\">{{ text.save }}</hm-button>\n </ng-container>\n</hm-modal>\n", styles: [".form-stack{display:flex;flex-direction:column;gap:var(--hm-space-sm)}\n"] }]
74
+ }], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { app: [{
75
+ type: Input
76
+ }], clientId: [{
77
+ type: Input
78
+ }], open: [{
79
+ type: Input
80
+ }], openChange: [{
81
+ type: Output
82
+ }], saved: [{
83
+ type: Output
84
+ }] } });
85
+
86
+ class AutoServiceConsumerCreateComponent {
87
+ constructor(service) {
88
+ this.service = service;
89
+ this.text = inject(SPINE_MESSAGES).autoService;
90
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
91
+ this.cdr = inject(ChangeDetectorRef);
92
+ this.clientId = '';
93
+ this.appId = '';
94
+ this.availableGroups = [];
95
+ this.open = false;
96
+ this.openChange = new EventEmitter();
97
+ this.created = new EventEmitter();
98
+ this.groupId = '';
99
+ this.saving = false;
100
+ }
101
+ get groupOptions() {
102
+ return this.availableGroups.map((g) => ({ value: g.id, label: g.type ? `${g.name} (${g.type.name})` : g.name }));
103
+ }
104
+ ngOnChanges(changes) { if (changes['open'] && this.open) {
105
+ this.groupId = '';
106
+ } }
107
+ onModalOpenChange(value) { this.open = value; this.openChange.emit(value); }
108
+ close() { this.onModalOpenChange(false); }
109
+ async save() {
110
+ if (!this.groupId)
111
+ return;
112
+ this.saving = true;
113
+ try {
114
+ await this.service.createAppConsumer(this.clientId, this.appId, this.groupId);
115
+ this.created.emit();
116
+ this.close();
117
+ }
118
+ finally {
119
+ this.saving = false;
120
+ this.cdr.markForCheck();
121
+ }
122
+ }
123
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceConsumerCreateComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
124
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceConsumerCreateComponent, isStandalone: true, selector: "spine-auto-service-consumer-create", inputs: { clientId: "clientId", appId: "appId", availableGroups: "availableGroups", open: "open" }, outputs: { openChange: "openChange", created: "created" }, usesOnChanges: true, ngImport: i0, template: "<hm-modal [open]=\"open\" (openChange)=\"onModalOpenChange($event)\" [heading]=\"text.newAccessHeading\" (closed)=\"close()\">\n <hm-combobox [label]=\"text.group\" [options]=\"groupOptions\" [value]=\"groupId\" (valueChange)=\"groupId = $event\"></hm-combobox>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!groupId\" [loading]=\"saving\" (clicked)=\"save()\">{{ text.create }}</hm-button>\n </ng-container>\n</hm-modal>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: ComboboxComponent, selector: "hm-combobox", inputs: ["label", "options", "value", "placeholder", "icon", "hint", "help", "size", "labelHidden", "clearable", "requiredManual", "loading", "allowCustomValue"], outputs: ["valueChange"] }, { kind: "component", type: ModalComponent, selector: "hm-modal", inputs: ["open", "heading", "size", "closeLabel", "closable", "beforeClose"], outputs: ["openChange", "closed"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
125
+ }
126
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceConsumerCreateComponent, decorators: [{
127
+ type: Component,
128
+ args: [{ selector: 'spine-auto-service-consumer-create', standalone: true, imports: [CommonModule, ButtonComponent, ComboboxComponent, ModalComponent], changeDetection: ChangeDetectionStrategy.Eager, template: "<hm-modal [open]=\"open\" (openChange)=\"onModalOpenChange($event)\" [heading]=\"text.newAccessHeading\" (closed)=\"close()\">\n <hm-combobox [label]=\"text.group\" [options]=\"groupOptions\" [value]=\"groupId\" (valueChange)=\"groupId = $event\"></hm-combobox>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!groupId\" [loading]=\"saving\" (clicked)=\"save()\">{{ text.create }}</hm-button>\n </ng-container>\n</hm-modal>\n" }]
129
+ }], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
130
+ type: Input
131
+ }], appId: [{
132
+ type: Input
133
+ }], availableGroups: [{
134
+ type: Input
135
+ }], open: [{
136
+ type: Input
137
+ }], openChange: [{
138
+ type: Output
139
+ }], created: [{
140
+ type: Output
141
+ }] } });
142
+
143
+ /**
144
+ * Só operação `protected` depende de permissão (grupo ou token com a operação liberada). `public` roda para qualquer um,
145
+ * `optional` também (com credencial vale como private) e `private` para qualquer autenticado: liberar uma delas a um
146
+ * token não muda nada, e o admin-server recusa (400 `operation_not_protected`).
147
+ */
148
+ function requiresPermission(level) {
149
+ return level === 'protected';
150
+ }
151
+ /** Por que a operação não precisa de permissão (no idioma ativo); vazio para `protected`. */
152
+ function freeAccessText(level, text) {
153
+ if (requiresPermission(level))
154
+ return '';
155
+ if (level === 'private')
156
+ return text.freeForAuthenticated;
157
+ if (level === 'public' || level === 'optional')
158
+ return text.freeForAll;
159
+ return text.freeNoPermission;
160
+ }
161
+ /** Cor do selo de nível, a mesma da aba Operações: pública em verde, protegida em amarelo; o resto neutro. */
162
+ function levelTagColor(level) {
163
+ if (level === 'public')
164
+ return 'success';
165
+ if (level === 'protected')
166
+ return 'warning';
167
+ return 'neutral';
168
+ }
169
+
170
+ class AutoServiceConsumerPermissionsComponent {
171
+ constructor(service) {
172
+ this.service = service;
173
+ this.text = inject(SPINE_MESSAGES).autoService;
174
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
175
+ this.cdr = inject(ChangeDetectorRef);
176
+ this.fmt = formatMessage;
177
+ this.levelTagColor = levelTagColor;
178
+ this.toast = inject(HermesToastService);
179
+ this.clientId = '';
180
+ this.appId = '';
181
+ this.consumer = null;
182
+ this.open = false;
183
+ this.openChange = new EventEmitter();
184
+ this.rows = [];
185
+ this.loading = false;
186
+ this.saving = false;
187
+ }
188
+ ngOnChanges(changes) { if (changes['open'] && this.open) {
189
+ this.reset();
190
+ } }
191
+ close() { this.open = false; this.openChange.emit(false); }
192
+ async reset() {
193
+ this.loading = true;
194
+ try {
195
+ const [opsRes, permsRes] = await Promise.all([
196
+ this.service.getAppOperations(this.clientId, this.appId),
197
+ this.service.getAppPermissions(this.clientId, this.consumer.consumer_id),
198
+ ]);
199
+ const operations = opsRes.operations ?? [];
200
+ const permissions = permsRes.permissions ?? [];
201
+ this.rows = operations.map((op) => {
202
+ const perm = permissions.find((p) => p.operation_id === op.operation_id);
203
+ // Só `protected` depende de permissão (o servidor recusa as outras com 400 operation_not_protected): sem
204
+ // permissão gravada, a caixa vem marcada e travada; com uma antiga, fica editável para dar para retirar.
205
+ const free = !perm && !requiresPermission(op.level) ? freeAccessText(op.level, this.text) : '';
206
+ return {
207
+ operation_id: op.operation_id, identifier: op.identifier, method: op.method, level: op.level,
208
+ description: op.description, permissionId: perm?.permission_id, free,
209
+ control: free
210
+ ? new FormControl({ value: true, disabled: true }, { nonNullable: true })
211
+ : new FormControl(!!perm, { nonNullable: true }),
212
+ };
213
+ });
214
+ }
215
+ finally {
216
+ this.loading = false;
217
+ this.cdr.markForCheck();
218
+ }
219
+ }
220
+ get hasChanges() { return this.rows.some(r => !r.free && r.control.value !== !!r.permissionId); }
221
+ async confirm() {
222
+ const toAdd = this.rows.filter(r => !r.free && r.control.value && !r.permissionId);
223
+ const toRemove = this.rows.filter(r => !r.free && !r.control.value && r.permissionId);
224
+ if (toAdd.length === 0 && toRemove.length === 0) {
225
+ this.close();
226
+ return;
227
+ }
228
+ this.saving = true;
229
+ try {
230
+ for (const r of toAdd) {
231
+ await this.service.addAppPermission(this.clientId, this.consumer.consumer_id, r.operation_id);
232
+ }
233
+ for (const r of toRemove) {
234
+ await this.service.removeAppPermission(this.clientId, this.consumer.consumer_id, r.permissionId);
235
+ }
236
+ this.close();
237
+ }
238
+ catch (err) {
239
+ // O drawer fica aberto; reabrir relê o que de fato ficou gravado.
240
+ this.toast.error(autoServiceErrorText(err, this.text, this.text.permissionsSaveError));
241
+ }
242
+ finally {
243
+ this.saving = false;
244
+ this.cdr.markForCheck();
245
+ }
246
+ }
247
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceConsumerPermissionsComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
248
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceConsumerPermissionsComponent, isStandalone: true, selector: "spine-auto-service-consumer-permissions", inputs: { clientId: "clientId", appId: "appId", consumer: "consumer", open: "open" }, outputs: { openChange: "openChange" }, usesOnChanges: true, ngImport: i0, template: "<hm-drawer [open]=\"open\" (openChange)=\"open = $event\" [heading]=\"fmt(text.operationsOf, { group: consumer?.group_name ?? '' })\" (closed)=\"close()\">\n <div *ngIf=\"loading\" class=\"loading-row\">{{ text.loading }}</div>\n\n <div class=\"op-list\" *ngIf=\"!loading\">\n <label class=\"op-row\" *ngFor=\"let row of rows\">\n <input type=\"checkbox\" class=\"hm-check\" [formControl]=\"row.control\" />\n <span class=\"op-row__body\">\n <code>{{ row.identifier }}</code>\n <hm-tag [name]=\"row.method\" />\n <hm-tag [name]=\"row.level\" [color]=\"levelTagColor(row.level)\" />\n <span class=\"op-row__free\" *ngIf=\"row.free\">{{ row.free }}</span>\n <span class=\"op-row__desc muted\" *ngIf=\"row.description\">{{ row.description }}</span>\n </span>\n </label>\n </div>\n\n <div class=\"empty-state\" *ngIf=\"!loading && rows.length === 0\">\n <hm-icon shape=\"filter-grid\" size=\"xl\"></hm-icon>\n <p>{{ text.noOperations }}</p>\n </div>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!hasChanges\" [loading]=\"saving\" (clicked)=\"confirm()\">{{ text.confirmChanges }}</hm-button>\n </ng-container>\n</hm-drawer>\n", styles: ["@charset \"UTF-8\";.as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}.loading-row{display:flex;justify-content:center;padding:var(--hm-space-xl);color:var(--hm-muted)}.op-list{display:flex;flex-direction:column;gap:var(--hm-space-micro)}.op-row{display:flex;align-items:flex-start;gap:var(--hm-space-sm);padding:var(--hm-space-xs);border-radius:var(--hm-radius-control);cursor:pointer}.op-row:hover{background:var(--hm-hover)}.op-row input[type=checkbox]{margin-top:var(--hm-space-micro)}.op-row__body{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.op-row__free{color:var(--hm-muted);font-size:var(--hm-font-size-xs);font-style:italic}.op-row__desc{flex-basis:100%;font-size:var(--hm-font-size-xs)}.empty-state{display:flex;flex-direction:column;align-items:center;gap:var(--hm-space-xs);padding:var(--hm-space-xl);color:var(--hm-muted);text-align:center}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i3.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: DrawerComponent, selector: "hm-drawer", inputs: ["open", "heading", "size", "position", "pinned", "closeLabel", "closable", "beforeClose"], outputs: ["openChange", "closed"] }, { kind: "component", type: IconComponent, selector: "hm-icon", inputs: ["shape", "direction", "size", "solid", "badge", "status", "flip", "inverse", "label"] }, { kind: "component", type: TagComponent, selector: "hm-tag", inputs: ["name", "color", "compact"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
249
+ }
250
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceConsumerPermissionsComponent, decorators: [{
251
+ type: Component,
252
+ args: [{ selector: 'spine-auto-service-consumer-permissions', standalone: true, imports: [CommonModule, ReactiveFormsModule, ButtonComponent, DrawerComponent, IconComponent, TagComponent], changeDetection: ChangeDetectionStrategy.Eager, template: "<hm-drawer [open]=\"open\" (openChange)=\"open = $event\" [heading]=\"fmt(text.operationsOf, { group: consumer?.group_name ?? '' })\" (closed)=\"close()\">\n <div *ngIf=\"loading\" class=\"loading-row\">{{ text.loading }}</div>\n\n <div class=\"op-list\" *ngIf=\"!loading\">\n <label class=\"op-row\" *ngFor=\"let row of rows\">\n <input type=\"checkbox\" class=\"hm-check\" [formControl]=\"row.control\" />\n <span class=\"op-row__body\">\n <code>{{ row.identifier }}</code>\n <hm-tag [name]=\"row.method\" />\n <hm-tag [name]=\"row.level\" [color]=\"levelTagColor(row.level)\" />\n <span class=\"op-row__free\" *ngIf=\"row.free\">{{ row.free }}</span>\n <span class=\"op-row__desc muted\" *ngIf=\"row.description\">{{ row.description }}</span>\n </span>\n </label>\n </div>\n\n <div class=\"empty-state\" *ngIf=\"!loading && rows.length === 0\">\n <hm-icon shape=\"filter-grid\" size=\"xl\"></hm-icon>\n <p>{{ text.noOperations }}</p>\n </div>\n\n <ng-container footer>\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!hasChanges\" [loading]=\"saving\" (clicked)=\"confirm()\">{{ text.confirmChanges }}</hm-button>\n </ng-container>\n</hm-drawer>\n", styles: ["@charset \"UTF-8\";.as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}.loading-row{display:flex;justify-content:center;padding:var(--hm-space-xl);color:var(--hm-muted)}.op-list{display:flex;flex-direction:column;gap:var(--hm-space-micro)}.op-row{display:flex;align-items:flex-start;gap:var(--hm-space-sm);padding:var(--hm-space-xs);border-radius:var(--hm-radius-control);cursor:pointer}.op-row:hover{background:var(--hm-hover)}.op-row input[type=checkbox]{margin-top:var(--hm-space-micro)}.op-row__body{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.op-row__free{color:var(--hm-muted);font-size:var(--hm-font-size-xs);font-style:italic}.op-row__desc{flex-basis:100%;font-size:var(--hm-font-size-xs)}.empty-state{display:flex;flex-direction:column;align-items:center;gap:var(--hm-space-xs);padding:var(--hm-space-xl);color:var(--hm-muted);text-align:center}\n"] }]
253
+ }], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
254
+ type: Input
255
+ }], appId: [{
256
+ type: Input
257
+ }], consumer: [{
258
+ type: Input
259
+ }], open: [{
260
+ type: Input
261
+ }], openChange: [{
262
+ type: Output
263
+ }] } });
264
+
265
+ class AutoServiceAppAccessComponent {
266
+ constructor(service) {
267
+ this.service = service;
268
+ this.text = inject(SPINE_MESSAGES).autoService;
269
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
270
+ this.cdr = inject(ChangeDetectorRef);
271
+ this.deletion = inject(AutoServiceDeleteFeedback);
272
+ this.clientId = '';
273
+ this.appId = '';
274
+ this.entries = [];
275
+ this.availableGroups = [];
276
+ this.loading = false;
277
+ this.showCreate = false;
278
+ this.showPermissions = false;
279
+ this.activeConsumer = null;
280
+ this.rowId = (c) => c.consumer_id;
281
+ this.columns = computed(() => [
282
+ { key: 'group_name', title: this.text.colGroup, value: (c) => c.group_name, sortable: true },
283
+ { key: 'group_type_name', title: this.text.colType, value: (c) => c.group_type_name, sortable: true },
284
+ ], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
285
+ this.rowActions = computed(() => [
286
+ { id: 'permissions', icon: 'shield', label: this.text.manageOperations },
287
+ {
288
+ id: 'delete', icon: 'trash', label: this.text.remove, danger: true, separatorAbove: true,
289
+ confirm: (c) => ({ heading: this.text.confirmRemoveConsumerHeading, message: formatMessage(this.text.confirmRemoveConsumer, { group: c.group_name }) }),
290
+ },
291
+ ], ...(ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []));
292
+ }
293
+ ngOnChanges(changes) {
294
+ if (changes['appId']) {
295
+ this.load();
296
+ }
297
+ if (changes['clientId']) {
298
+ this.loadGroups();
299
+ }
300
+ }
301
+ async load() {
302
+ if (!this.appId) {
303
+ this.entries = [];
304
+ return;
305
+ }
306
+ this.loading = true;
307
+ try {
308
+ const res = await this.service.getAppConsumers(this.clientId, this.appId);
309
+ this.entries = (res.consumers ?? []).filter((c) => !c.group_is_admin);
310
+ }
311
+ finally {
312
+ this.loading = false;
313
+ this.cdr.markForCheck();
314
+ }
315
+ }
316
+ async loadGroups() {
317
+ if (!this.clientId) {
318
+ this.availableGroups = [];
319
+ return;
320
+ }
321
+ const res = await this.service.getGroups(this.clientId);
322
+ this.availableGroups = (res.groups ?? []).filter((g) => !g.is_admin);
323
+ this.cdr.markForCheck();
324
+ }
325
+ openCreate() { this.showCreate = true; }
326
+ async onCreated() { await this.load(); }
327
+ /** Já confirmado pelo `confirm` da ação na grade. */
328
+ async deleteConsumer(consumerId) {
329
+ if (await this.deletion.run(() => this.service.deleteAppConsumer(this.clientId, consumerId)))
330
+ await this.load();
331
+ }
332
+ openPermissions(consumer) { this.activeConsumer = consumer; this.showPermissions = true; }
333
+ onAction(e) {
334
+ if (e.action === 'permissions')
335
+ this.openPermissions(e.row);
336
+ if (e.action === 'delete')
337
+ void this.deleteConsumer(e.row.consumer_id);
338
+ }
339
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppAccessComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
340
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceAppAccessComponent, isStandalone: true, selector: "spine-auto-service-app-access", inputs: { clientId: "clientId", appId: "appId" }, usesOnChanges: true, ngImport: i0, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"entries\"\n [rowId]=\"rowId\"\n [caption]=\"text.appAccessCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n (actionTriggered)=\"onAction($event)\"\n [emptyMessage]=\"text.noAppAccess\"\n>\n <hm-button dataGridActions icon=\"plus\" (clicked)=\"openCreate()\">{{ text.newAccess }}</hm-button>\n</hm-data-grid>\n\n<spine-auto-service-consumer-create\n [clientId]=\"clientId\"\n [appId]=\"appId\"\n [availableGroups]=\"availableGroups\"\n [open]=\"showCreate\"\n (openChange)=\"showCreate = $event\"\n (created)=\"onCreated()\">\n</spine-auto-service-consumer-create>\n\n<spine-auto-service-consumer-permissions\n *ngIf=\"activeConsumer\"\n [clientId]=\"clientId\"\n [appId]=\"appId\"\n [consumer]=\"activeConsumer\"\n [open]=\"showPermissions\"\n (openChange)=\"showPermissions = $event\">\n</spine-auto-service-consumer-permissions>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}:host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: DataGridComponent, selector: "hm-data-grid", inputs: ["columns", "rows", "rowId", "caption", "rowActions", "loading", "error", "emptyMessage", "noResultsMessage", "filterable", "paginated", "pageState", "pagination", "totalItems", "sort", "selectable", "selectionMode", "selection", "rowSelectable", "rowSelectableReason", "rowDetailDisabled", "rowDetailHidden", "virtual", "rowHeight", "pinnedColumns", "columnState", "pageSizes", "fillHeight", "maxHeight", "bordered", "rowState", "rowClickable", "remoteSearch", "remoteSort", "itemsLabel", "pageSizeLabel", "exportable", "exportFileName", "groupBy", "aggregates", "aggregateFormatter", "persistKey", "persistStorage", "advancedFilter", "filterQuery", "columnManager", "columnOrder", "searchTerm"], outputs: ["pageStateChange", "sortChange", "selectionChange", "pinnedColumnsChange", "columnStateChange", "actionTriggered", "detailToggled", "rowClicked", "clearFiltersRequested", "filteredChange", "searchTermChanged", "groupByChange", "filterQueryChange", "columnOrderChange", "searchTermChange", "detailPaneToggled"] }, { kind: "component", type: AutoServiceConsumerCreateComponent, selector: "spine-auto-service-consumer-create", inputs: ["clientId", "appId", "availableGroups", "open"], outputs: ["openChange", "created"] }, { kind: "component", type: AutoServiceConsumerPermissionsComponent, selector: "spine-auto-service-consumer-permissions", inputs: ["clientId", "appId", "consumer", "open"], outputs: ["openChange"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
341
+ }
342
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppAccessComponent, decorators: [{
343
+ type: Component,
344
+ args: [{ selector: 'spine-auto-service-app-access', standalone: true, imports: [CommonModule, ButtonComponent, IconComponent, DataGridComponent, AutoServiceConsumerCreateComponent, AutoServiceConsumerPermissionsComponent], changeDetection: ChangeDetectionStrategy.Eager, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"entries\"\n [rowId]=\"rowId\"\n [caption]=\"text.appAccessCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n (actionTriggered)=\"onAction($event)\"\n [emptyMessage]=\"text.noAppAccess\"\n>\n <hm-button dataGridActions icon=\"plus\" (clicked)=\"openCreate()\">{{ text.newAccess }}</hm-button>\n</hm-data-grid>\n\n<spine-auto-service-consumer-create\n [clientId]=\"clientId\"\n [appId]=\"appId\"\n [availableGroups]=\"availableGroups\"\n [open]=\"showCreate\"\n (openChange)=\"showCreate = $event\"\n (created)=\"onCreated()\">\n</spine-auto-service-consumer-create>\n\n<spine-auto-service-consumer-permissions\n *ngIf=\"activeConsumer\"\n [clientId]=\"clientId\"\n [appId]=\"appId\"\n [consumer]=\"activeConsumer\"\n [open]=\"showPermissions\"\n (openChange)=\"showPermissions = $event\">\n</spine-auto-service-consumer-permissions>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}:host{display:block}\n"] }]
345
+ }], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
346
+ type: Input
347
+ }], appId: [{
348
+ type: Input
349
+ }] } });
350
+
351
+ class AutoServiceAppOperationsComponent {
352
+ constructor(service) {
353
+ this.service = service;
354
+ this.text = inject(SPINE_MESSAGES).autoService;
355
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
356
+ this.cdr = inject(ChangeDetectorRef);
357
+ this.messages = inject(SPINE_MESSAGES);
358
+ this.clientId = '';
359
+ this.appId = '';
360
+ this.operations = [];
361
+ this.loading = false;
362
+ this.rowId = (op) => op.operation_id;
363
+ this.columns = computed(() => [
364
+ { key: 'identifier', title: this.text.colIdentifier, value: (op) => op.identifier, sortable: true },
365
+ { key: 'method', title: this.text.colMethod, value: (op) => op.method, sortable: true },
366
+ { key: 'level', title: this.text.colLevel, value: (op) => op.level, sortable: true },
367
+ { key: 'description', title: this.text.colDescription, value: (op) => op.description || '—' },
368
+ {
369
+ key: 'allowed_groups', title: this.text.colAllowedGroups,
370
+ value: (op) => op.allowed_groups?.length ? pluralMessage(this.text.groupCount, op.allowed_groups.length, this.messages.meta.locale) : '—',
371
+ },
372
+ ], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
373
+ }
374
+ ngOnChanges(changes) { if (changes['appId']) {
375
+ this.load();
376
+ } }
377
+ async load() {
378
+ if (!this.appId) {
379
+ this.operations = [];
380
+ return;
381
+ }
382
+ this.loading = true;
383
+ try {
384
+ const res = await this.service.getAppOperations(this.clientId, this.appId);
385
+ this.operations = res.operations;
386
+ }
387
+ finally {
388
+ this.loading = false;
389
+ this.cdr.markForCheck();
390
+ }
391
+ }
392
+ /** Nível da operação no selo: pública em verde, protegida em amarelo; o resto neutro. */
393
+ levelTagColor(level) {
394
+ if (level === 'public')
395
+ return 'success';
396
+ if (level === 'protected')
397
+ return 'warning';
398
+ return 'neutral';
399
+ }
400
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppOperationsComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
401
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceAppOperationsComponent, isStandalone: true, selector: "spine-auto-service-app-operations", inputs: { clientId: "clientId", appId: "appId" }, usesOnChanges: true, ngImport: i0, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"operations\"\n [rowId]=\"rowId\"\n [caption]=\"text.operationsCaption\"\n [loading]=\"loading\"\n [emptyMessage]=\"text.noOperations\"\n>\n <ng-template hmCell=\"identifier\" let-op>\n <code>{{ op.identifier }}</code>\n </ng-template>\n\n <ng-template hmCell=\"method\" let-op>\n <hm-tag [name]=\"op.method\" />\n </ng-template>\n\n <ng-template hmCell=\"level\" let-op>\n <hm-tag [name]=\"op.level\" [color]=\"levelTagColor(op.level)\" />\n </ng-template>\n</hm-data-grid>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}:host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: DataGridComponent, selector: "hm-data-grid", inputs: ["columns", "rows", "rowId", "caption", "rowActions", "loading", "error", "emptyMessage", "noResultsMessage", "filterable", "paginated", "pageState", "pagination", "totalItems", "sort", "selectable", "selectionMode", "selection", "rowSelectable", "rowSelectableReason", "rowDetailDisabled", "rowDetailHidden", "virtual", "rowHeight", "pinnedColumns", "columnState", "pageSizes", "fillHeight", "maxHeight", "bordered", "rowState", "rowClickable", "remoteSearch", "remoteSort", "itemsLabel", "pageSizeLabel", "exportable", "exportFileName", "groupBy", "aggregates", "aggregateFormatter", "persistKey", "persistStorage", "advancedFilter", "filterQuery", "columnManager", "columnOrder", "searchTerm"], outputs: ["pageStateChange", "sortChange", "selectionChange", "pinnedColumnsChange", "columnStateChange", "actionTriggered", "detailToggled", "rowClicked", "clearFiltersRequested", "filteredChange", "searchTermChanged", "groupByChange", "filterQueryChange", "columnOrderChange", "searchTermChange", "detailPaneToggled"] }, { kind: "directive", type: DataGridCellDirective, selector: "ng-template[hmCell]", inputs: ["hmCell"] }, { kind: "component", type: TagComponent, selector: "hm-tag", inputs: ["name", "color", "compact"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
402
+ }
403
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppOperationsComponent, decorators: [{
404
+ type: Component,
405
+ args: [{ selector: 'spine-auto-service-app-operations', standalone: true, imports: [CommonModule, DataGridComponent, DataGridCellDirective, TagComponent], changeDetection: ChangeDetectionStrategy.Eager, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"operations\"\n [rowId]=\"rowId\"\n [caption]=\"text.operationsCaption\"\n [loading]=\"loading\"\n [emptyMessage]=\"text.noOperations\"\n>\n <ng-template hmCell=\"identifier\" let-op>\n <code>{{ op.identifier }}</code>\n </ng-template>\n\n <ng-template hmCell=\"method\" let-op>\n <hm-tag [name]=\"op.method\" />\n </ng-template>\n\n <ng-template hmCell=\"level\" let-op>\n <hm-tag [name]=\"op.level\" [color]=\"levelTagColor(op.level)\" />\n </ng-template>\n</hm-data-grid>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}:host{display:block}\n"] }]
406
+ }], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
407
+ type: Input
408
+ }], appId: [{
409
+ type: Input
410
+ }] } });
411
+
412
+ /** Teto de validade aceito pelo servidor (`APP_TOKEN_MAX_DAYS` do argos-admin). */
413
+ const APP_TOKEN_MAX_DAYS = 365;
414
+ /** Validade sugerida ao abrir o modal. */
415
+ const APP_TOKEN_DEFAULT_DAYS = 90;
416
+ /** Limite do nome no formulário. */
417
+ const APP_TOKEN_NAME_MAX = 100;
418
+ /** Data LOCAL em AAAA-MM-DD (`toISOString()` daria a data em UTC: em UTC-3, depois das 21h já é amanhã). */
419
+ function localIsoDate(date) {
420
+ const y = date.getFullYear();
421
+ const m = String(date.getMonth() + 1).padStart(2, '0');
422
+ const d = String(date.getDate()).padStart(2, '0');
423
+ return `${y}-${m}-${d}`;
424
+ }
425
+ /** Hoje + `days` dias, em data local (`setDate` cuida da virada de mês e ano). */
426
+ function addLocalDays(base, days) {
427
+ const date = new Date(base.getFullYear(), base.getMonth(), base.getDate());
428
+ date.setDate(date.getDate() + days);
429
+ return localIsoDate(date);
430
+ }
431
+ /**
432
+ * Meia-noite LOCAL do dia escolhido (AAAA-MM-DD), em ISO com fuso. Mandar só a data fazia o servidor ler meia-noite
433
+ * UTC (em UTC-3 "amanhã" podia já ter passado). Meia-noite local de amanhã é sempre futura e a de hoje + 365 nunca
434
+ * passa de agora + 365 dias.
435
+ */
436
+ function localDayStartIso(value) {
437
+ const [y, m, d] = value.split('-').map(Number);
438
+ return new Date(y, m - 1, d).toISOString();
439
+ }
440
+ /** Intervalo [min, max] comparando AAAA-MM-DD (ordem do texto = ordem das datas). */
441
+ function dateRangeValidator(min, max) {
442
+ return (control) => {
443
+ const value = control.value;
444
+ if (!value)
445
+ return null;
446
+ if (value < min)
447
+ return { minDate: { min, actual: value } };
448
+ if (value > max)
449
+ return { maxDate: { max, actual: value } };
450
+ return null;
451
+ };
452
+ }
453
+ /**
454
+ * "Novo token" de uma aplicação: nome, descrição, validade (de amanhã até 365 dias) e as operações liberadas ao token.
455
+ * Só as `protected` dependem de permissão e podem ser marcadas; as outras aparecem marcadas e desabilitadas (já valem
456
+ * para o token) e nunca vão em `operation_ids`. Criado, o valor aparece uma única vez, com copiar; fechar o descarta.
457
+ * Mirror de admin/ui/.../apps/tabs/app-tokens/modals/token-create (argos-admin), escopado em `/auto-service/:clientId`.
458
+ */
459
+ class AutoServiceTokenCreateComponent {
460
+ constructor() {
461
+ this.text = inject(SPINE_MESSAGES).autoService;
462
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
463
+ this.cdr = inject(ChangeDetectorRef);
464
+ this.service = inject(AutoServiceService);
465
+ this.levelTagColor = levelTagColor;
466
+ this.nameMax = APP_TOKEN_NAME_MAX;
467
+ this.clientId = '';
468
+ this.appId = '';
469
+ this.open = false;
470
+ this.openChange = new EventEmitter();
471
+ /** Token criado (a lista recarrega na hora, sem esperar o modal fechar). */
472
+ this.created = new EventEmitter();
473
+ this.minDate = addLocalDays(new Date(), 1);
474
+ this.maxDate = addLocalDays(new Date(), APP_TOKEN_MAX_DAYS);
475
+ this.name = new FormControl('', { nonNullable: true, validators: [Validators.required, Validators.maxLength(APP_TOKEN_NAME_MAX)] });
476
+ this.description = new FormControl('', { nonNullable: true });
477
+ this.expiresAt = new FormControl(null, { validators: [Validators.required] });
478
+ this.rows = [];
479
+ this.loading = false;
480
+ this.saving = false;
481
+ this.saveError = null;
482
+ /** Valor recém-criado: aparece uma única vez, só enquanto o modal está aberto. */
483
+ this.createdToken = null;
484
+ }
485
+ /** Mensagens de validação da data no idioma ativo (o `hm-date-picker` mostra pelo `messages`). */
486
+ get dateMessages() {
487
+ return { minDate: this.text.tokenExpiresInvalid, maxDate: this.text.tokenExpiresInvalid };
488
+ }
489
+ get canSave() {
490
+ return !this.saving && !this.loading && this.name.valid && !!this.name.value.trim() && this.expiresAt.valid;
491
+ }
492
+ get hasFreeRows() { return this.rows.some((r) => !!r.free); }
493
+ ngOnChanges(changes) { if (changes['open'] && this.open)
494
+ void this.reset(); }
495
+ /** Abre limpo: datas recalculadas (o modal pode ficar montado de um dia para o outro) e operações relidas. */
496
+ async reset() {
497
+ this.minDate = addLocalDays(new Date(), 1);
498
+ this.maxDate = addLocalDays(new Date(), APP_TOKEN_MAX_DAYS);
499
+ this.expiresAt.setValidators([Validators.required, dateRangeValidator(this.minDate, this.maxDate)]);
500
+ this.name.reset('');
501
+ this.description.reset('');
502
+ this.expiresAt.reset(addLocalDays(new Date(), APP_TOKEN_DEFAULT_DAYS));
503
+ this.createdToken = null;
504
+ this.saveError = null;
505
+ this.rows = [];
506
+ this.loading = true;
507
+ this.cdr.markForCheck();
508
+ try {
509
+ const res = await this.service.getAppOperations(this.clientId, this.appId);
510
+ this.rows = (res.operations ?? []).map((op) => ({
511
+ operation_id: op.operation_id,
512
+ identifier: op.identifier,
513
+ method: op.method,
514
+ level: op.level,
515
+ description: op.description,
516
+ free: freeAccessText(op.level, this.text),
517
+ control: requiresPermission(op.level)
518
+ ? new FormControl(false, { nonNullable: true })
519
+ : new FormControl({ value: true, disabled: true }, { nonNullable: true }),
520
+ }));
521
+ }
522
+ catch (err) {
523
+ this.saveError = autoServiceErrorText(err, this.text, this.text.tokenSaveError);
524
+ }
525
+ finally {
526
+ this.loading = false;
527
+ this.cdr.markForCheck();
528
+ }
529
+ }
530
+ onModalOpenChange(value) {
531
+ this.open = value;
532
+ if (!value)
533
+ this.createdToken = null;
534
+ this.openChange.emit(value);
535
+ }
536
+ close() { this.onModalOpenChange(false); }
537
+ async save() {
538
+ this.name.markAsTouched();
539
+ this.expiresAt.markAsTouched();
540
+ if (!this.canSave || !this.expiresAt.value)
541
+ return;
542
+ this.saving = true;
543
+ this.saveError = null;
544
+ this.cdr.markForCheck();
545
+ try {
546
+ const name = this.name.value.trim();
547
+ const description = this.description.value.trim();
548
+ const res = await this.service.createAppToken(this.clientId, this.appId, {
549
+ name,
550
+ ...(description ? { description } : {}),
551
+ expires_at: localDayStartIso(this.expiresAt.value),
552
+ // Só as protegidas escolhidas: public/private não viram permissão (o servidor recusa).
553
+ operation_ids: this.rows.filter((r) => !r.free && r.control.value).map((r) => r.operation_id),
554
+ });
555
+ this.createdToken = { name: res.name ?? name, token: res.token };
556
+ this.created.emit();
557
+ }
558
+ catch (err) {
559
+ this.saveError = autoServiceErrorText(err, this.text, this.text.tokenSaveError);
560
+ }
561
+ finally {
562
+ this.saving = false;
563
+ this.cdr.markForCheck();
564
+ }
565
+ }
566
+ createdHeading(name) { return formatMessage(this.text.tokenCreatedHeading, { name }); }
567
+ valueLabel(name) { return formatMessage(this.text.tokenValueLabel, { name }); }
568
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceTokenCreateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
569
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceTokenCreateComponent, isStandalone: true, selector: "spine-auto-service-token-create", inputs: { clientId: "clientId", appId: "appId", open: "open" }, outputs: { openChange: "openChange", created: "created" }, usesOnChanges: true, ngImport: i0, template: "<!-- Depois de criar, o modal s\u00F3 mostra o valor (uma vez); fechar (Concluir, Esc ou \u2715) o descarta. -->\n<hm-modal [open]=\"open\" (openChange)=\"onModalOpenChange($event)\"\n [heading]=\"createdToken ? createdHeading(createdToken.name) : text.newToken\" size=\"large\" (closed)=\"close()\">\n <div class=\"form-stack\" *ngIf=\"createdToken as created; else formTpl\">\n <hm-alert variant=\"warning\" [heading]=\"text.tokenCreatedWarning\">{{ text.tokenCreatedNote }}</hm-alert>\n <div class=\"as-secret\">\n <span class=\"as-secret__label\" id=\"as-created-token-label\">{{ valueLabel(created.name) }}</span>\n <div class=\"as-secret__row\">\n <code class=\"as-secret__value\" aria-labelledby=\"as-created-token-label\">{{ created.token }}</code>\n <hm-copy-button variant=\"text\" [value]=\"created.token\" [label]=\"text.copyToken\" [copiedLabel]=\"text.tokenCopied\" />\n </div>\n </div>\n </div>\n\n <ng-template #formTpl>\n <div class=\"form-stack\">\n <hm-alert *ngIf=\"saveError\" variant=\"error\">{{ saveError }}</hm-alert>\n <hm-input [formControl]=\"name\" [label]=\"text.tokenName\" [maxLength]=\"nameMax\" />\n <hm-textarea [formControl]=\"description\" [label]=\"text.tokenDescription\" [rows]=\"2\" />\n <hm-date-picker [formControl]=\"expiresAt\" [label]=\"text.tokenExpiresAt\" [min]=\"minDate\" [max]=\"maxDate\"\n [hint]=\"text.tokenExpiresHint\" [messages]=\"dateMessages\" />\n\n <fieldset class=\"token-ops\">\n <legend class=\"token-ops__legend\">{{ text.tokenOperations }}</legend>\n <p class=\"token-ops__note muted\" *ngIf=\"hasFreeRows || rows.length\">{{ text.tokenOperationsNote }}</p>\n <p class=\"token-ops__empty muted\" *ngIf=\"loading\">{{ text.loading }}</p>\n <p class=\"token-ops__empty muted\" *ngIf=\"!loading && rows.length === 0\">{{ text.noOperations }}</p>\n <div class=\"token-ops__row\" *ngFor=\"let row of rows\">\n <hm-checkbox [formControl]=\"row.control\" [label]=\"row.identifier\" />\n <div class=\"token-ops__meta\">\n <hm-tag [name]=\"row.method\" />\n <hm-tag [name]=\"row.level\" [color]=\"levelTagColor(row.level)\" />\n <span class=\"token-ops__free\" *ngIf=\"row.free\">{{ row.free }}</span>\n <span class=\"token-ops__desc muted\" *ngIf=\"row.description\">{{ row.description }}</span>\n </div>\n </div>\n </fieldset>\n </div>\n </ng-template>\n\n <ng-container footer>\n <ng-container *ngIf=\"!createdToken\">\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!canSave\" [loading]=\"saving\" (clicked)=\"save()\">{{ text.createToken }}</hm-button>\n </ng-container>\n <hm-button *ngIf=\"createdToken\" (clicked)=\"close()\">{{ text.rotatedSecretDone }}</hm-button>\n </ng-container>\n</hm-modal>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}.form-stack{display:flex;flex-direction:column;gap:var(--hm-space-sm)}.token-ops{display:flex;flex-direction:column;gap:var(--hm-space-xs);min-inline-size:0;margin:0;padding:0;border:0}.token-ops__legend{margin-bottom:var(--hm-space-micro);padding:0;color:var(--hm-text);font-size:var(--hm-font-size-sm);font-weight:var(--hm-font-weight-semibold)}.token-ops__note,.token-ops__empty{margin:0;font-size:var(--hm-font-size-sm)}.token-ops__row{display:flex;flex-direction:column;gap:var(--hm-space-micro);padding-bottom:var(--hm-space-xs);border-bottom:var(--hm-border-hairline) solid var(--hm-divider)}.token-ops__row:last-child{border-bottom:0}.token-ops__meta{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);padding-inline-start:calc(var(--hm-check-size) + var(--hm-space-xs))}.token-ops__free{color:var(--hm-muted);font-size:var(--hm-font-size-xs);font-style:italic}.token-ops__desc{font-size:var(--hm-font-size-xs)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: AlertComponent, selector: "hm-alert", inputs: ["variant", "appearance", "heading", "closable", "size", "showIcon", "link", "linkLabel", "linkTarget", "dismissKey", "duration"], outputs: ["closed"] }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: CheckboxComponent, selector: "hm-checkbox", inputs: ["label", "labelHidden", "checked", "indeterminate"], outputs: ["checkedChange"] }, { kind: "component", type: CopyButtonComponent, selector: "hm-copy-button", inputs: ["value", "label", "copiedLabel", "variant", "size", "disabled", "feedbackDuration"], outputs: ["copied", "copyFailed"] }, { kind: "component", type: DatePickerComponent, selector: "hm-date-picker", inputs: ["value", "label", "labelHidden", "hint", "placeholder", "min", "max", "valueFormat"], outputs: ["valueChange"] }, { kind: "component", type: InputComponent, selector: "hm-input", inputs: ["value", "label", "type", "placeholder", "icon", "labelHidden", "hint", "prefix", "suffix", "prefixIcon", "mask", "maskValue", "min", "max", "step", "stepButtons", "maxLength", "autocomplete", "inputMode"], outputs: ["valueChange"] }, { kind: "component", type: ModalComponent, selector: "hm-modal", inputs: ["open", "heading", "size", "closeLabel", "closable", "beforeClose"], outputs: ["openChange", "closed"] }, { kind: "component", type: TagComponent, selector: "hm-tag", inputs: ["name", "color", "compact"] }, { kind: "component", type: TextareaComponent, selector: "hm-textarea", inputs: ["value", "label", "hint", "help", "placeholder", "maxLength", "rows", "autoGrow", "labelHidden", "loading", "maxRows", "submitKey"], outputs: ["valueChange", "submitted"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
570
+ }
571
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceTokenCreateComponent, decorators: [{
572
+ type: Component,
573
+ args: [{ selector: 'spine-auto-service-token-create', standalone: true, imports: [
574
+ CommonModule, ReactiveFormsModule, AlertComponent, ButtonComponent, CheckboxComponent, CopyButtonComponent, DatePickerComponent,
575
+ InputComponent, ModalComponent, TagComponent, TextareaComponent,
576
+ ], changeDetection: ChangeDetectionStrategy.Eager, template: "<!-- Depois de criar, o modal s\u00F3 mostra o valor (uma vez); fechar (Concluir, Esc ou \u2715) o descarta. -->\n<hm-modal [open]=\"open\" (openChange)=\"onModalOpenChange($event)\"\n [heading]=\"createdToken ? createdHeading(createdToken.name) : text.newToken\" size=\"large\" (closed)=\"close()\">\n <div class=\"form-stack\" *ngIf=\"createdToken as created; else formTpl\">\n <hm-alert variant=\"warning\" [heading]=\"text.tokenCreatedWarning\">{{ text.tokenCreatedNote }}</hm-alert>\n <div class=\"as-secret\">\n <span class=\"as-secret__label\" id=\"as-created-token-label\">{{ valueLabel(created.name) }}</span>\n <div class=\"as-secret__row\">\n <code class=\"as-secret__value\" aria-labelledby=\"as-created-token-label\">{{ created.token }}</code>\n <hm-copy-button variant=\"text\" [value]=\"created.token\" [label]=\"text.copyToken\" [copiedLabel]=\"text.tokenCopied\" />\n </div>\n </div>\n </div>\n\n <ng-template #formTpl>\n <div class=\"form-stack\">\n <hm-alert *ngIf=\"saveError\" variant=\"error\">{{ saveError }}</hm-alert>\n <hm-input [formControl]=\"name\" [label]=\"text.tokenName\" [maxLength]=\"nameMax\" />\n <hm-textarea [formControl]=\"description\" [label]=\"text.tokenDescription\" [rows]=\"2\" />\n <hm-date-picker [formControl]=\"expiresAt\" [label]=\"text.tokenExpiresAt\" [min]=\"minDate\" [max]=\"maxDate\"\n [hint]=\"text.tokenExpiresHint\" [messages]=\"dateMessages\" />\n\n <fieldset class=\"token-ops\">\n <legend class=\"token-ops__legend\">{{ text.tokenOperations }}</legend>\n <p class=\"token-ops__note muted\" *ngIf=\"hasFreeRows || rows.length\">{{ text.tokenOperationsNote }}</p>\n <p class=\"token-ops__empty muted\" *ngIf=\"loading\">{{ text.loading }}</p>\n <p class=\"token-ops__empty muted\" *ngIf=\"!loading && rows.length === 0\">{{ text.noOperations }}</p>\n <div class=\"token-ops__row\" *ngFor=\"let row of rows\">\n <hm-checkbox [formControl]=\"row.control\" [label]=\"row.identifier\" />\n <div class=\"token-ops__meta\">\n <hm-tag [name]=\"row.method\" />\n <hm-tag [name]=\"row.level\" [color]=\"levelTagColor(row.level)\" />\n <span class=\"token-ops__free\" *ngIf=\"row.free\">{{ row.free }}</span>\n <span class=\"token-ops__desc muted\" *ngIf=\"row.description\">{{ row.description }}</span>\n </div>\n </div>\n </fieldset>\n </div>\n </ng-template>\n\n <ng-container footer>\n <ng-container *ngIf=\"!createdToken\">\n <hm-button emphasis=\"medium\" (clicked)=\"close()\">{{ text.cancel }}</hm-button>\n <hm-button [disabled]=\"!canSave\" [loading]=\"saving\" (clicked)=\"save()\">{{ text.createToken }}</hm-button>\n </ng-container>\n <hm-button *ngIf=\"createdToken\" (clicked)=\"close()\">{{ text.rotatedSecretDone }}</hm-button>\n </ng-container>\n</hm-modal>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}.form-stack{display:flex;flex-direction:column;gap:var(--hm-space-sm)}.token-ops{display:flex;flex-direction:column;gap:var(--hm-space-xs);min-inline-size:0;margin:0;padding:0;border:0}.token-ops__legend{margin-bottom:var(--hm-space-micro);padding:0;color:var(--hm-text);font-size:var(--hm-font-size-sm);font-weight:var(--hm-font-weight-semibold)}.token-ops__note,.token-ops__empty{margin:0;font-size:var(--hm-font-size-sm)}.token-ops__row{display:flex;flex-direction:column;gap:var(--hm-space-micro);padding-bottom:var(--hm-space-xs);border-bottom:var(--hm-border-hairline) solid var(--hm-divider)}.token-ops__row:last-child{border-bottom:0}.token-ops__meta{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);padding-inline-start:calc(var(--hm-check-size) + var(--hm-space-xs))}.token-ops__free{color:var(--hm-muted);font-size:var(--hm-font-size-xs);font-style:italic}.token-ops__desc{font-size:var(--hm-font-size-xs)}\n"] }]
577
+ }], propDecorators: { clientId: [{
578
+ type: Input
579
+ }], appId: [{
580
+ type: Input
581
+ }], open: [{
582
+ type: Input
583
+ }], openChange: [{
584
+ type: Output
585
+ }], created: [{
586
+ type: Output
587
+ }] } });
588
+
589
+ /**
590
+ * Aba Tokens da aplicação: os tokens de API (`x-api-token`) com situação, validade e último uso; "Novo token" (modal com
591
+ * as operações liberadas) e, no menu da linha, "Gerenciar operações" (o token também é um consumer) e "Revogar" (com
592
+ * confirmação; o token para de valer na hora e fica na lista como revogado).
593
+ * Mirror de admin/ui/.../apps/tabs/app-tokens (argos-admin), escopado em `/auto-service/:clientId`.
594
+ */
595
+ class AutoServiceAppTokensComponent {
596
+ constructor() {
597
+ this.text = inject(SPINE_MESSAGES).autoService;
598
+ this.catalog = inject(SPINE_MESSAGES);
599
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
600
+ this.cdr = inject(ChangeDetectorRef);
601
+ this.service = inject(AutoServiceService);
602
+ this.toast = inject(HermesToastService);
603
+ this.clientId = '';
604
+ this.appId = '';
605
+ this.tokens = [];
606
+ this.loading = false;
607
+ this.showCreate = false;
608
+ this.showPermissions = false;
609
+ /** Token aberto em "Gerenciar operações", no formato que o painel de permissões espera (o nome no lugar do grupo). */
610
+ this.permissionsConsumer = null;
611
+ this.rowId = (tk) => tk.id;
612
+ this.columns = computed(() => [
613
+ { key: 'name', title: this.text.colName, value: (tk) => tk.name, sortable: true, searchable: true },
614
+ { key: 'prefix', title: this.text.colTokenPrefix, value: (tk) => tk.token_prefix ?? '' },
615
+ { key: 'status', title: this.text.colStatus, value: (tk) => this.statusLabel(this.status(tk)), sortable: true },
616
+ { key: 'expires_at', title: this.text.colExpiresAt, value: (tk) => tk.expires_at ?? '', sortable: true },
617
+ { key: 'last_used_at', title: this.text.colLastUsed, value: (tk) => tk.last_used_at ?? '', sortable: true },
618
+ ], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
619
+ // Revogado não tem mais o que fazer: a linha fica sem o menu.
620
+ this.rowActions = computed(() => [
621
+ { id: 'operations', icon: 'shield', label: this.text.manageOperations, available: (tk) => !tk.revoked_at },
622
+ {
623
+ id: 'revoke', icon: 'ban', label: this.text.revokeToken, danger: true, separatorAbove: true,
624
+ available: (tk) => !tk.revoked_at,
625
+ confirm: (tk) => ({
626
+ heading: this.text.confirmRevokeTokenHeading,
627
+ message: formatMessage(this.text.confirmRevokeToken, { name: tk.name }),
628
+ confirmLabel: this.text.revokeToken,
629
+ }),
630
+ },
631
+ ], ...(ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []));
632
+ }
633
+ ngOnChanges(changes) { if (changes['appId'] || changes['clientId'])
634
+ void this.load(); }
635
+ async load() {
636
+ const { clientId, appId } = this;
637
+ if (!clientId || !appId) {
638
+ this.tokens = [];
639
+ return;
640
+ }
641
+ this.loading = true;
642
+ this.cdr.markForCheck();
643
+ try {
644
+ const res = await this.service.getAppTokens(clientId, appId);
645
+ if (this.appId !== appId || this.clientId !== clientId)
646
+ return;
647
+ this.tokens = res.tokens ?? [];
648
+ }
649
+ catch (err) {
650
+ this.tokens = [];
651
+ this.toast.error(autoServiceErrorText(err, this.text, this.text.tokensLoadError));
652
+ }
653
+ finally {
654
+ this.loading = false;
655
+ this.cdr.markForCheck();
656
+ }
657
+ }
658
+ status(tk, now = Date.now()) {
659
+ if (tk.revoked_at)
660
+ return 'revoked';
661
+ if (new Date(tk.expires_at).getTime() <= now)
662
+ return 'expired';
663
+ return 'active';
664
+ }
665
+ statusLabel(status) {
666
+ if (status === 'revoked')
667
+ return this.text.tokenRevoked;
668
+ if (status === 'expired')
669
+ return this.text.tokenExpired;
670
+ return this.text.active;
671
+ }
672
+ /** Ativo em verde, expirado em amarelo, revogado neutro; o texto do selo diz qual (a cor só reforça). */
673
+ statusColor(status) {
674
+ if (status === 'revoked')
675
+ return 'neutral';
676
+ if (status === 'expired')
677
+ return 'warning';
678
+ return 'success';
679
+ }
680
+ formatDate(value) {
681
+ if (!value)
682
+ return '';
683
+ return new Intl.DateTimeFormat(this.catalog.meta.locale, { dateStyle: 'short', timeStyle: 'short' }).format(new Date(value));
684
+ }
685
+ openCreate() { this.showCreate = true; this.cdr.markForCheck(); }
686
+ openPermissions(tk) {
687
+ this.permissionsConsumer = { consumer_id: tk.consumer_id, group_name: tk.name };
688
+ this.showPermissions = true;
689
+ this.cdr.markForCheck();
690
+ }
691
+ /** Já confirmado pelo `confirm` da ação na grade. Sucesso e falha viram toast. */
692
+ async revoke(tk) {
693
+ if (tk.revoked_at)
694
+ return;
695
+ try {
696
+ await this.service.revokeAppToken(this.clientId, this.appId, tk.id);
697
+ this.toast.success(formatMessage(this.text.tokenRevokedDone, { name: tk.name }));
698
+ }
699
+ catch (err) {
700
+ this.toast.error(autoServiceErrorText(err, this.text, this.text.tokenRevokeError));
701
+ return;
702
+ }
703
+ await this.load();
704
+ }
705
+ onAction(e) {
706
+ if (e.action === 'operations')
707
+ this.openPermissions(e.row);
708
+ if (e.action === 'revoke')
709
+ void this.revoke(e.row);
710
+ }
711
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppTokensComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
712
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceAppTokensComponent, isStandalone: true, selector: "spine-auto-service-app-tokens", inputs: { clientId: "clientId", appId: "appId" }, usesOnChanges: true, ngImport: i0, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"tokens\"\n [rowId]=\"rowId\"\n [caption]=\"text.tokensCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n [emptyMessage]=\"text.noTokens\"\n (actionTriggered)=\"onAction($event)\"\n>\n <hm-button dataGridActions icon=\"plus\" (clicked)=\"openCreate()\">{{ text.newToken }}</hm-button>\n <ng-template hmCell=\"prefix\" let-tk>\n <code *ngIf=\"tk.token_prefix; else noPrefix\">{{ tk.token_prefix }}\u2026</code>\n <ng-template #noPrefix>\u2014</ng-template>\n </ng-template>\n <ng-template hmCell=\"status\" let-tk>\n <hm-tag [name]=\"statusLabel(status(tk))\" [color]=\"statusColor(status(tk))\" />\n </ng-template>\n <ng-template hmCell=\"expires_at\" let-tk>{{ formatDate(tk.expires_at) || '\u2014' }}</ng-template>\n <ng-template hmCell=\"last_used_at\" let-tk>{{ tk.last_used_at ? formatDate(tk.last_used_at) : text.neverUsed }}</ng-template>\n</hm-data-grid>\n\n<spine-auto-service-token-create [clientId]=\"clientId\" [appId]=\"appId\" [open]=\"showCreate\"\n (openChange)=\"showCreate = $event\" (created)=\"load()\">\n</spine-auto-service-token-create>\n\n<spine-auto-service-consumer-permissions *ngIf=\"permissionsConsumer as consumer\" [clientId]=\"clientId\" [appId]=\"appId\"\n [consumer]=\"consumer\" [open]=\"showPermissions\" (openChange)=\"showPermissions = $event\">\n</spine-auto-service-consumer-permissions>\n", styles: [":host{display:block}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: DataGridComponent, selector: "hm-data-grid", inputs: ["columns", "rows", "rowId", "caption", "rowActions", "loading", "error", "emptyMessage", "noResultsMessage", "filterable", "paginated", "pageState", "pagination", "totalItems", "sort", "selectable", "selectionMode", "selection", "rowSelectable", "rowSelectableReason", "rowDetailDisabled", "rowDetailHidden", "virtual", "rowHeight", "pinnedColumns", "columnState", "pageSizes", "fillHeight", "maxHeight", "bordered", "rowState", "rowClickable", "remoteSearch", "remoteSort", "itemsLabel", "pageSizeLabel", "exportable", "exportFileName", "groupBy", "aggregates", "aggregateFormatter", "persistKey", "persistStorage", "advancedFilter", "filterQuery", "columnManager", "columnOrder", "searchTerm"], outputs: ["pageStateChange", "sortChange", "selectionChange", "pinnedColumnsChange", "columnStateChange", "actionTriggered", "detailToggled", "rowClicked", "clearFiltersRequested", "filteredChange", "searchTermChanged", "groupByChange", "filterQueryChange", "columnOrderChange", "searchTermChange", "detailPaneToggled"] }, { kind: "directive", type: DataGridCellDirective, selector: "ng-template[hmCell]", inputs: ["hmCell"] }, { kind: "component", type: TagComponent, selector: "hm-tag", inputs: ["name", "color", "compact"] }, { kind: "component", type: AutoServiceTokenCreateComponent, selector: "spine-auto-service-token-create", inputs: ["clientId", "appId", "open"], outputs: ["openChange", "created"] }, { kind: "component", type: AutoServiceConsumerPermissionsComponent, selector: "spine-auto-service-consumer-permissions", inputs: ["clientId", "appId", "consumer", "open"], outputs: ["openChange"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
713
+ }
714
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppTokensComponent, decorators: [{
715
+ type: Component,
716
+ args: [{ selector: 'spine-auto-service-app-tokens', standalone: true, imports: [
717
+ CommonModule, ButtonComponent, DataGridComponent, DataGridCellDirective, TagComponent,
718
+ AutoServiceTokenCreateComponent, AutoServiceConsumerPermissionsComponent,
719
+ ], changeDetection: ChangeDetectionStrategy.Eager, template: "<hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"tokens\"\n [rowId]=\"rowId\"\n [caption]=\"text.tokensCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n [emptyMessage]=\"text.noTokens\"\n (actionTriggered)=\"onAction($event)\"\n>\n <hm-button dataGridActions icon=\"plus\" (clicked)=\"openCreate()\">{{ text.newToken }}</hm-button>\n <ng-template hmCell=\"prefix\" let-tk>\n <code *ngIf=\"tk.token_prefix; else noPrefix\">{{ tk.token_prefix }}\u2026</code>\n <ng-template #noPrefix>\u2014</ng-template>\n </ng-template>\n <ng-template hmCell=\"status\" let-tk>\n <hm-tag [name]=\"statusLabel(status(tk))\" [color]=\"statusColor(status(tk))\" />\n </ng-template>\n <ng-template hmCell=\"expires_at\" let-tk>{{ formatDate(tk.expires_at) || '\u2014' }}</ng-template>\n <ng-template hmCell=\"last_used_at\" let-tk>{{ tk.last_used_at ? formatDate(tk.last_used_at) : text.neverUsed }}</ng-template>\n</hm-data-grid>\n\n<spine-auto-service-token-create [clientId]=\"clientId\" [appId]=\"appId\" [open]=\"showCreate\"\n (openChange)=\"showCreate = $event\" (created)=\"load()\">\n</spine-auto-service-token-create>\n\n<spine-auto-service-consumer-permissions *ngIf=\"permissionsConsumer as consumer\" [clientId]=\"clientId\" [appId]=\"appId\"\n [consumer]=\"consumer\" [open]=\"showPermissions\" (openChange)=\"showPermissions = $event\">\n</spine-auto-service-consumer-permissions>\n", styles: [":host{display:block}\n"] }]
720
+ }], propDecorators: { clientId: [{
721
+ type: Input
722
+ }], appId: [{
723
+ type: Input
724
+ }] } });
725
+
726
+ /**
727
+ * Aplicações (client_credentials) do projeto do client: tabela (Nome/Grants/Situação) com cadastrar e, no menu da linha,
728
+ * editar, ativar/desativar, gerar novo segredo e excluir. Clicar na linha abre a aplicação embaixo da tabela: o resumo
729
+ * (com as mesmas ações) e as abas Operações, Acessos e Tokens. Mesmo molde da tela Grupos.
730
+ */
731
+ class AutoServiceAppsComponent {
732
+ constructor() {
733
+ this.text = inject(SPINE_MESSAGES).autoService;
734
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
735
+ this.cdr = inject(ChangeDetectorRef);
736
+ this.dialogs = inject(HermesDialogService);
737
+ this.deletion = inject(AutoServiceDeleteFeedback);
738
+ this.toast = inject(HermesToastService);
739
+ this.service = inject(AutoServiceService);
740
+ this.clientId = '';
741
+ this.apps = [];
742
+ this.loading = false;
743
+ /** Aplicação aberta (resumo + abas embaixo da tabela). */
744
+ this.app = null;
745
+ this.modalApp = null;
746
+ this.showAppModal = false;
747
+ this.activeTab = 'operations';
748
+ this.newSecret = null;
749
+ /** Segredo gerado por "Gerar novo segredo", mostrado uma vez na janela até "Concluir". */
750
+ this.rotatedSecret = null;
751
+ this.rotatingSecret = false;
752
+ this.rowId = (a) => a.id;
753
+ this.columns = computed(() => [
754
+ { key: 'name', title: this.text.colName, value: (a) => a.name, sortable: true, searchable: true },
755
+ { key: 'grants', title: this.text.colGrants, value: (a) => this.grantsText(a) },
756
+ { key: 'status', title: this.text.colStatus, value: (a) => (a.enabled ? this.text.active : this.text.inactive), sortable: true },
757
+ ], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
758
+ this.rowActions = computed(() => [
759
+ { id: 'edit', icon: 'pencil', label: this.text.edit },
760
+ { id: 'disable', icon: 'pause', label: this.text.disable, available: (a) => !!a.enabled },
761
+ { id: 'enable', icon: 'play', label: this.text.enable, available: (a) => !a.enabled },
762
+ { id: 'rotate', icon: 'key', label: this.text.rotateSecret },
763
+ {
764
+ id: 'delete', icon: 'trash', label: this.text.delete, danger: true, separatorAbove: true,
765
+ confirm: (a) => ({ heading: this.text.confirmDeleteAppHeading, message: formatMessage(this.text.confirmDeleteApp, { name: a.name ?? a.id }) }),
766
+ },
767
+ ], ...(ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []));
768
+ }
769
+ // Trocar de client fecha a aplicação aberta e esconde o segredo recém-criado: ele é de uma aplicação do client anterior.
770
+ ngOnChanges(changes) {
771
+ if (changes['clientId']) {
772
+ this.app = null;
773
+ this.apps = [];
774
+ this.newSecret = null;
775
+ this.rotatedSecret = null;
776
+ void this.load();
777
+ }
778
+ }
779
+ grantsText(a) { return a.allowed_grants?.length ? a.allowed_grants.join(', ') : '—'; }
780
+ openAppLabel(a) { return formatMessage(this.text.openApp, { name: a.name }); }
781
+ async load() {
782
+ const clientId = this.clientId;
783
+ if (!clientId) {
784
+ this.apps = [];
785
+ return;
786
+ }
787
+ this.loading = true;
788
+ this.cdr.markForCheck();
789
+ try {
790
+ const res = await this.service.getApps(clientId);
791
+ if (this.clientId !== clientId)
792
+ return;
793
+ this.apps = res.apps ?? [];
794
+ // A aplicação aberta acompanha o que o servidor devolveu (nome/situação novos) ou fecha se sumiu.
795
+ if (this.app)
796
+ this.app = this.apps.find((a) => a.id === this.app.id) ?? null;
797
+ }
798
+ finally {
799
+ this.loading = false;
800
+ this.cdr.markForCheck();
801
+ }
802
+ }
803
+ /** Abre a aplicação embaixo da tabela; outra aplicação volta para a aba Operações. */
804
+ openApp(a) {
805
+ if (this.app?.id !== a.id)
806
+ this.activeTab = 'operations';
807
+ this.app = a;
808
+ this.cdr.markForCheck();
809
+ }
810
+ setTab(tab) { this.activeTab = tab; }
811
+ openCreate() { this.modalApp = null; this.showAppModal = true; this.cdr.markForCheck(); }
812
+ openEdit(a = this.app) { if (!a)
813
+ return; this.modalApp = a; this.showAppModal = true; this.cdr.markForCheck(); }
814
+ async onAppSaved(secret) {
815
+ if (secret)
816
+ this.newSecret = secret;
817
+ await this.load();
818
+ this.cdr.markForCheck();
819
+ }
820
+ async toggleEnabled(a = this.app) {
821
+ if (!a)
822
+ return;
823
+ await this.service.updateApp(this.clientId, a.id, { enabled: !a.enabled });
824
+ await this.load();
825
+ }
826
+ /**
827
+ * "Gerar novo segredo": confirmação (o atual para de valer na hora), POST e o segredo novo numa janela,
828
+ * mostrado uma única vez. Falha vira toast (404: aplicação de outro client; 403: client que a pessoa não
829
+ * administra; senão o `detail` do servidor ou a mensagem genérica).
830
+ */
831
+ async rotateSecret(a = this.app) {
832
+ if (!a || this.rotatingSecret)
833
+ return;
834
+ const ok = await this.dialogs.confirm({
835
+ heading: this.text.confirmRotateSecretHeading,
836
+ message: this.text.confirmRotateSecret,
837
+ confirmLabel: this.text.rotateSecret,
838
+ danger: true,
839
+ });
840
+ if (!ok)
841
+ return;
842
+ this.rotatingSecret = true;
843
+ this.cdr.markForCheck();
844
+ try {
845
+ const res = await this.service.rotateAppSecret(this.clientId, a.id);
846
+ this.rotatedSecret = { name: a.name ?? a.id, secret: res.secret };
847
+ }
848
+ catch (err) {
849
+ this.toast.error(this.rotateErrorText(err));
850
+ }
851
+ finally {
852
+ this.rotatingSecret = false;
853
+ this.cdr.markForCheck();
854
+ }
855
+ }
856
+ /** Fecha a janela do segredo: depois dela não há como ver o segredo de novo. */
857
+ closeRotatedSecret() { this.rotatedSecret = null; this.cdr.markForCheck(); }
858
+ rotatedSecretHeading(name) { return formatMessage(this.text.rotatedSecretHeading, { name }); }
859
+ rotatedSecretLabel(name) { return formatMessage(this.text.rotatedSecretLabel, { name }); }
860
+ rotateErrorText(err) {
861
+ if (err instanceof HttpErrorResponse) {
862
+ if (err.status === 404)
863
+ return this.text.rotateSecretNotFound;
864
+ if (err.status === 403)
865
+ return this.text.rotateSecretForbidden;
866
+ const detail = err.error?.detail;
867
+ if (typeof detail === 'string' && detail)
868
+ return detail;
869
+ }
870
+ return this.text.rotateSecretError;
871
+ }
872
+ /** Botão Excluir do resumo: pede confirmação e só então exclui. A ação da tabela já confirma pelo `confirm` dela. */
873
+ async deleteApp(a = this.app) {
874
+ if (!a)
875
+ return;
876
+ const ok = await this.dialogs.confirm({
877
+ heading: this.text.confirmDeleteAppHeading,
878
+ message: formatMessage(this.text.confirmDeleteApp, { name: a.name ?? a.id }),
879
+ confirmLabel: this.text.delete,
880
+ danger: true,
881
+ });
882
+ if (ok)
883
+ await this.removeApp(a);
884
+ }
885
+ /** DELETE com toast de sucesso/erro; a aplicação aberta fecha e o segredo recém-criado some. */
886
+ async removeApp(a) {
887
+ if (!(await this.deletion.run(() => this.service.deleteApp(this.clientId, a.id))))
888
+ return;
889
+ if (this.app?.id === a.id)
890
+ this.app = null;
891
+ this.newSecret = null;
892
+ await this.load();
893
+ }
894
+ onAction(e) {
895
+ switch (e.action) {
896
+ case 'edit':
897
+ this.openEdit(e.row);
898
+ break;
899
+ case 'enable':
900
+ case 'disable':
901
+ void this.toggleEnabled(e.row);
902
+ break;
903
+ case 'rotate':
904
+ void this.rotateSecret(e.row);
905
+ break;
906
+ case 'delete':
907
+ void this.removeApp(e.row);
908
+ break;
909
+ }
910
+ }
911
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
912
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceAppsComponent, isStandalone: true, selector: "spine-auto-service-apps", inputs: { clientId: "clientId" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"as-stack\">\n <hm-alert *ngIf=\"newSecret\" variant=\"success\" [closable]=\"true\" (closed)=\"newSecret = null\">\n {{ text.secretCreated }} <strong>{{ newSecret }}</strong>\n </hm-alert>\n\n <!-- Clicar na linha (ou no nome, pelo teclado) abre a aplica\u00E7\u00E3o embaixo da tabela. -->\n <hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"apps\"\n [rowId]=\"rowId\"\n [caption]=\"text.appsCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n [emptyMessage]=\"text.noApps\"\n rowClickable\n (rowClicked)=\"openApp($event)\"\n (actionTriggered)=\"onAction($event)\"\n >\n <hm-button dataGridActions icon=\"plus\" (clicked)=\"openCreate()\">{{ text.register }}</hm-button>\n <ng-template hmCell=\"name\" let-a>\n <button type=\"button\" class=\"name-cell__open\" [attr.aria-label]=\"openAppLabel(a)\"\n [attr.aria-current]=\"app?.id === a.id ? 'true' : null\" (click)=\"openApp(a)\">{{ a.name }}</button>\n </ng-template>\n <ng-template hmCell=\"grants\" let-a>\n <code *ngIf=\"a.allowed_grants?.length; else noGrants\">{{ grantsText(a) }}</code>\n <ng-template #noGrants>\u2014</ng-template>\n </ng-template>\n <ng-template hmCell=\"status\" let-a>\n <hm-tag [name]=\"a.enabled ? text.active : text.inactive\" [color]=\"a.enabled ? 'success' : 'danger'\" />\n </ng-template>\n </hm-data-grid>\n\n <ng-container *ngIf=\"app as a\">\n <hm-card>\n <div class=\"as-summary\">\n <div class=\"as-summary__info\">\n <p class=\"as-summary__title app-title\">\n {{ a.name }}\n <hm-tag [name]=\"a.enabled ? text.active : text.inactive\" [color]=\"a.enabled ? 'success' : 'danger'\" />\n </p>\n <p class=\"as-summary__detail\">{{ a.allowed_grants?.join(', ') }}</p>\n </div>\n <div class=\"as-actions\">\n <hm-button emphasis=\"medium\" icon=\"pencil\" (clicked)=\"openEdit(a)\">{{ text.edit }}</hm-button>\n <hm-button emphasis=\"medium\" (clicked)=\"toggleEnabled(a)\">{{ a.enabled ? text.disable : text.enable }}</hm-button>\n <hm-button emphasis=\"medium\" icon=\"key\" [loading]=\"rotatingSecret\" (clicked)=\"rotateSecret(a)\">{{ text.rotateSecret }}</hm-button>\n <hm-button intent=\"danger\" emphasis=\"medium\" icon=\"trash\" (clicked)=\"deleteApp(a)\">{{ text.delete }}</hm-button>\n </div>\n </div>\n </hm-card>\n\n <!-- Conte\u00FAdo de cada aba \u00E9 pregui\u00E7oso (*hmTabContent): s\u00F3 busca na API quando a aba \u00E9 aberta. -->\n <hm-tabs [label]=\"text.appSections\" [active]=\"activeTab\" (activeChange)=\"setTab($any($event))\">\n <hm-tab id=\"operations\" [label]=\"text.tabOperations\">\n <spine-auto-service-app-operations *hmTabContent [clientId]=\"clientId\" [appId]=\"a.id\"></spine-auto-service-app-operations>\n </hm-tab>\n <hm-tab id=\"access\" [label]=\"text.tabAccesses\">\n <spine-auto-service-app-access *hmTabContent [clientId]=\"clientId\" [appId]=\"a.id\"></spine-auto-service-app-access>\n </hm-tab>\n <hm-tab id=\"tokens\" [label]=\"text.tabTokens\">\n <spine-auto-service-app-tokens *hmTabContent [clientId]=\"clientId\" [appId]=\"a.id\"></spine-auto-service-app-tokens>\n </hm-tab>\n </hm-tabs>\n </ng-container>\n</div>\n\n<!-- Segredo novo (\"Gerar novo segredo\"): aparece uma vez; fechar (Concluir, Esc ou \u2715) o descarta. -->\n<hm-modal\n [open]=\"!!rotatedSecret\"\n (openChange)=\"$event || closeRotatedSecret()\"\n [heading]=\"rotatedSecret ? rotatedSecretHeading(rotatedSecret.name) : ''\"\n (closed)=\"closeRotatedSecret()\">\n <div class=\"as-stack\" *ngIf=\"rotatedSecret as rotated\">\n <hm-alert variant=\"warning\" [heading]=\"text.rotatedSecretWarning\">{{ text.rotatedSecretNote }}</hm-alert>\n <div class=\"as-secret\">\n <span class=\"as-secret__label\" id=\"as-rotated-secret-label\">{{ rotatedSecretLabel(rotated.name) }}</span>\n <div class=\"as-secret__row\">\n <code class=\"as-secret__value\" aria-labelledby=\"as-rotated-secret-label\">{{ rotated.secret }}</code>\n <hm-copy-button variant=\"text\" [value]=\"rotated.secret\" [label]=\"text.copySecret\" [copiedLabel]=\"text.secretCopied\" />\n </div>\n </div>\n </div>\n <ng-container footer>\n <hm-button (clicked)=\"closeRotatedSecret()\">{{ text.rotatedSecretDone }}</hm-button>\n </ng-container>\n</hm-modal>\n\n<spine-auto-service-apps-modal\n [app]=\"modalApp\"\n [clientId]=\"clientId\"\n [open]=\"showAppModal\"\n (openChange)=\"showAppModal = $event\"\n (saved)=\"onAppSaved($event)\">\n</spine-auto-service-apps-modal>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}:host{display:block}.name-cell__open{padding:0;border:0;background:none;color:inherit;font:inherit;font-weight:var(--hm-font-weight-semibold);text-align:start;cursor:pointer}.name-cell__open:hover,.name-cell__open[aria-current=true]{text-decoration:underline}.name-cell__open:focus-visible{border-radius:var(--hm-radius-micro);outline:var(--hm-border-thin) solid var(--hm-accent);outline-offset:var(--hm-space-micro)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: AlertComponent, selector: "hm-alert", inputs: ["variant", "appearance", "heading", "closable", "size", "showIcon", "link", "linkLabel", "linkTarget", "dismissKey", "duration"], outputs: ["closed"] }, { kind: "component", type: ButtonComponent, selector: "hm-button", inputs: ["emphasis", "intent", "size", "type", "icon", "iconDirection", "iconEnd", "disabled", "loading", "busy", "loadingState", "block", "link", "newTab", "caret", "inMenu", "toggle", "pressed"], outputs: ["loadingStateChange", "pressedChange", "clicked"] }, { kind: "component", type: CardComponent, selector: "hm-card", inputs: ["heading", "icon", "selected", "fill", "media", "mediaAlt", "mediaDecorative", "mediaPosition"] }, { kind: "component", type: CopyButtonComponent, selector: "hm-copy-button", inputs: ["value", "label", "copiedLabel", "variant", "size", "disabled", "feedbackDuration"], outputs: ["copied", "copyFailed"] }, { kind: "component", type: DataGridComponent, selector: "hm-data-grid", inputs: ["columns", "rows", "rowId", "caption", "rowActions", "loading", "error", "emptyMessage", "noResultsMessage", "filterable", "paginated", "pageState", "pagination", "totalItems", "sort", "selectable", "selectionMode", "selection", "rowSelectable", "rowSelectableReason", "rowDetailDisabled", "rowDetailHidden", "virtual", "rowHeight", "pinnedColumns", "columnState", "pageSizes", "fillHeight", "maxHeight", "bordered", "rowState", "rowClickable", "remoteSearch", "remoteSort", "itemsLabel", "pageSizeLabel", "exportable", "exportFileName", "groupBy", "aggregates", "aggregateFormatter", "persistKey", "persistStorage", "advancedFilter", "filterQuery", "columnManager", "columnOrder", "searchTerm"], outputs: ["pageStateChange", "sortChange", "selectionChange", "pinnedColumnsChange", "columnStateChange", "actionTriggered", "detailToggled", "rowClicked", "clearFiltersRequested", "filteredChange", "searchTermChanged", "groupByChange", "filterQueryChange", "columnOrderChange", "searchTermChange", "detailPaneToggled"] }, { kind: "directive", type: DataGridCellDirective, selector: "ng-template[hmCell]", inputs: ["hmCell"] }, { kind: "component", type: ModalComponent, selector: "hm-modal", inputs: ["open", "heading", "size", "closeLabel", "closable", "beforeClose"], outputs: ["openChange", "closed"] }, { kind: "component", type: TabsComponent, selector: "hm-tabs", inputs: ["label", "active", "orientation", "mode", "overflow", "fillHeight", "noPanelGap"], outputs: ["activeChange"] }, { kind: "component", type: TabComponent, selector: "hm-tab", inputs: ["id", "label", "disabled", "count", "route", "exact", "destroyOnHide"] }, { kind: "directive", type: TabContentDirective, selector: "ng-template[hmTabContent]" }, { kind: "component", type: TagComponent, selector: "hm-tag", inputs: ["name", "color", "compact"] }, { kind: "component", type: AutoServiceAppsModalComponent, selector: "spine-auto-service-apps-modal", inputs: ["app", "clientId", "open"], outputs: ["openChange", "saved"] }, { kind: "component", type: AutoServiceAppOperationsComponent, selector: "spine-auto-service-app-operations", inputs: ["clientId", "appId"] }, { kind: "component", type: AutoServiceAppAccessComponent, selector: "spine-auto-service-app-access", inputs: ["clientId", "appId"] }, { kind: "component", type: AutoServiceAppTokensComponent, selector: "spine-auto-service-app-tokens", inputs: ["clientId", "appId"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
913
+ }
914
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppsComponent, decorators: [{
915
+ type: Component,
916
+ args: [{ selector: 'spine-auto-service-apps', standalone: true, imports: [
917
+ CommonModule, AlertComponent, ButtonComponent, CardComponent, CopyButtonComponent, DataGridComponent, DataGridCellDirective,
918
+ ModalComponent, TabsComponent, TabComponent, TabContentDirective, TagComponent,
919
+ AutoServiceAppsModalComponent, AutoServiceAppOperationsComponent, AutoServiceAppAccessComponent, AutoServiceAppTokensComponent,
920
+ ], changeDetection: ChangeDetectionStrategy.Eager, template: "<div class=\"as-stack\">\n <hm-alert *ngIf=\"newSecret\" variant=\"success\" [closable]=\"true\" (closed)=\"newSecret = null\">\n {{ text.secretCreated }} <strong>{{ newSecret }}</strong>\n </hm-alert>\n\n <!-- Clicar na linha (ou no nome, pelo teclado) abre a aplica\u00E7\u00E3o embaixo da tabela. -->\n <hm-data-grid\n [columns]=\"columns()\"\n [rows]=\"apps\"\n [rowId]=\"rowId\"\n [caption]=\"text.appsCaption\"\n [loading]=\"loading\"\n [rowActions]=\"rowActions()\"\n [emptyMessage]=\"text.noApps\"\n rowClickable\n (rowClicked)=\"openApp($event)\"\n (actionTriggered)=\"onAction($event)\"\n >\n <hm-button dataGridActions icon=\"plus\" (clicked)=\"openCreate()\">{{ text.register }}</hm-button>\n <ng-template hmCell=\"name\" let-a>\n <button type=\"button\" class=\"name-cell__open\" [attr.aria-label]=\"openAppLabel(a)\"\n [attr.aria-current]=\"app?.id === a.id ? 'true' : null\" (click)=\"openApp(a)\">{{ a.name }}</button>\n </ng-template>\n <ng-template hmCell=\"grants\" let-a>\n <code *ngIf=\"a.allowed_grants?.length; else noGrants\">{{ grantsText(a) }}</code>\n <ng-template #noGrants>\u2014</ng-template>\n </ng-template>\n <ng-template hmCell=\"status\" let-a>\n <hm-tag [name]=\"a.enabled ? text.active : text.inactive\" [color]=\"a.enabled ? 'success' : 'danger'\" />\n </ng-template>\n </hm-data-grid>\n\n <ng-container *ngIf=\"app as a\">\n <hm-card>\n <div class=\"as-summary\">\n <div class=\"as-summary__info\">\n <p class=\"as-summary__title app-title\">\n {{ a.name }}\n <hm-tag [name]=\"a.enabled ? text.active : text.inactive\" [color]=\"a.enabled ? 'success' : 'danger'\" />\n </p>\n <p class=\"as-summary__detail\">{{ a.allowed_grants?.join(', ') }}</p>\n </div>\n <div class=\"as-actions\">\n <hm-button emphasis=\"medium\" icon=\"pencil\" (clicked)=\"openEdit(a)\">{{ text.edit }}</hm-button>\n <hm-button emphasis=\"medium\" (clicked)=\"toggleEnabled(a)\">{{ a.enabled ? text.disable : text.enable }}</hm-button>\n <hm-button emphasis=\"medium\" icon=\"key\" [loading]=\"rotatingSecret\" (clicked)=\"rotateSecret(a)\">{{ text.rotateSecret }}</hm-button>\n <hm-button intent=\"danger\" emphasis=\"medium\" icon=\"trash\" (clicked)=\"deleteApp(a)\">{{ text.delete }}</hm-button>\n </div>\n </div>\n </hm-card>\n\n <!-- Conte\u00FAdo de cada aba \u00E9 pregui\u00E7oso (*hmTabContent): s\u00F3 busca na API quando a aba \u00E9 aberta. -->\n <hm-tabs [label]=\"text.appSections\" [active]=\"activeTab\" (activeChange)=\"setTab($any($event))\">\n <hm-tab id=\"operations\" [label]=\"text.tabOperations\">\n <spine-auto-service-app-operations *hmTabContent [clientId]=\"clientId\" [appId]=\"a.id\"></spine-auto-service-app-operations>\n </hm-tab>\n <hm-tab id=\"access\" [label]=\"text.tabAccesses\">\n <spine-auto-service-app-access *hmTabContent [clientId]=\"clientId\" [appId]=\"a.id\"></spine-auto-service-app-access>\n </hm-tab>\n <hm-tab id=\"tokens\" [label]=\"text.tabTokens\">\n <spine-auto-service-app-tokens *hmTabContent [clientId]=\"clientId\" [appId]=\"a.id\"></spine-auto-service-app-tokens>\n </hm-tab>\n </hm-tabs>\n </ng-container>\n</div>\n\n<!-- Segredo novo (\"Gerar novo segredo\"): aparece uma vez; fechar (Concluir, Esc ou \u2715) o descarta. -->\n<hm-modal\n [open]=\"!!rotatedSecret\"\n (openChange)=\"$event || closeRotatedSecret()\"\n [heading]=\"rotatedSecret ? rotatedSecretHeading(rotatedSecret.name) : ''\"\n (closed)=\"closeRotatedSecret()\">\n <div class=\"as-stack\" *ngIf=\"rotatedSecret as rotated\">\n <hm-alert variant=\"warning\" [heading]=\"text.rotatedSecretWarning\">{{ text.rotatedSecretNote }}</hm-alert>\n <div class=\"as-secret\">\n <span class=\"as-secret__label\" id=\"as-rotated-secret-label\">{{ rotatedSecretLabel(rotated.name) }}</span>\n <div class=\"as-secret__row\">\n <code class=\"as-secret__value\" aria-labelledby=\"as-rotated-secret-label\">{{ rotated.secret }}</code>\n <hm-copy-button variant=\"text\" [value]=\"rotated.secret\" [label]=\"text.copySecret\" [copiedLabel]=\"text.secretCopied\" />\n </div>\n </div>\n </div>\n <ng-container footer>\n <hm-button (clicked)=\"closeRotatedSecret()\">{{ text.rotatedSecretDone }}</hm-button>\n </ng-container>\n</hm-modal>\n\n<spine-auto-service-apps-modal\n [app]=\"modalApp\"\n [clientId]=\"clientId\"\n [open]=\"showAppModal\"\n (openChange)=\"showAppModal = $event\"\n (saved)=\"onAppSaved($event)\">\n</spine-auto-service-apps-modal>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}:host{display:block}.name-cell__open{padding:0;border:0;background:none;color:inherit;font:inherit;font-weight:var(--hm-font-weight-semibold);text-align:start;cursor:pointer}.name-cell__open:hover,.name-cell__open[aria-current=true]{text-decoration:underline}.name-cell__open:focus-visible{border-radius:var(--hm-radius-micro);outline:var(--hm-border-thin) solid var(--hm-accent);outline-offset:var(--hm-space-micro)}\n"] }]
921
+ }], propDecorators: { clientId: [{
922
+ type: Input
923
+ }] } });
924
+
925
+ /**
926
+ * Página "Aplicações" do auto-serviço: o seletor de client e as aplicações dele. A auditoria tem página
927
+ * própria no menu Administração (`AUTO_SERVICE_SCREENS.audit`) — a aba que existia aqui duplicava a tela.
928
+ */
929
+ class AutoServiceComponent {
930
+ constructor() {
931
+ this.client = null;
932
+ }
933
+ onClientChange(c) { this.client = c; }
934
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
935
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.24", type: AutoServiceComponent, isStandalone: true, selector: "spine-auto-service", ngImport: i0, template: "<!-- T\u00EDtulo e descri\u00E7\u00E3o da tela v\u00EAm da barra da p\u00E1gina (nome + description do router). -->\n<div class=\"as-stack\">\n <spine-auto-service-client-picker (clientChange)=\"onClientChange($event)\"></spine-auto-service-client-picker>\n <spine-auto-service-apps *ngIf=\"client as c\" [clientId]=\"c.id\"></spine-auto-service-apps>\n</div>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: AutoServiceClientPickerComponent, selector: "spine-auto-service-client-picker", outputs: ["clientChange"] }, { kind: "component", type: AutoServiceAppsComponent, selector: "spine-auto-service-apps", inputs: ["clientId"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
936
+ }
937
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceComponent, decorators: [{
938
+ type: Component,
939
+ args: [{ selector: 'spine-auto-service', standalone: true, imports: [CommonModule, AutoServiceClientPickerComponent, AutoServiceAppsComponent], changeDetection: ChangeDetectionStrategy.Eager, template: "<!-- T\u00EDtulo e descri\u00E7\u00E3o da tela v\u00EAm da barra da p\u00E1gina (nome + description do router). -->\n<div class=\"as-stack\">\n <spine-auto-service-client-picker (clientChange)=\"onClientChange($event)\"></spine-auto-service-client-picker>\n <spine-auto-service-apps *ngIf=\"client as c\" [clientId]=\"c.id\"></spine-auto-service-apps>\n</div>\n", styles: [".as-stack{display:flex;flex-direction:column;gap:var(--hm-space-md);min-inline-size:0}.as-actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:var(--hm-space-xs)}.as-field-row{display:flex;flex-wrap:wrap;align-items:flex-end;gap:var(--hm-space-sm)}.as-field-row>:first-child{flex:1 1 20rem;min-inline-size:0}.as-summary{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-sm)}.as-summary__info{display:flex;flex:1 1 16rem;flex-direction:column;gap:var(--hm-space-micro);min-inline-size:0}.as-summary__title{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs);margin:0;color:var(--hm-text);font-size:var(--hm-font-size-md);font-weight:var(--hm-font-weight-semibold)}.as-summary__detail{margin:0;color:var(--hm-muted);font-size:var(--hm-font-size-sm)}.muted{color:var(--hm-muted)}.as-secret{display:grid;gap:var(--hm-space-micro)}.as-secret__label{color:var(--hm-muted);font-size:var(--hm-font-size-xs)}.as-secret__row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--hm-space-xs)}.as-secret__value{flex:1 1 240px;min-width:0;border:var(--hm-border-hairline) solid var(--hm-divider);border-radius:var(--hm-radius-control);padding:var(--hm-space-xs) var(--hm-space-sm);background:var(--hm-surface);color:var(--hm-text);font-family:var(--hm-font-mono);font-size:var(--hm-font-size-sm);overflow-wrap:anywhere;-webkit-user-select:all;user-select:all}\n"] }]
940
+ }] });
941
+
942
+ export { AutoServiceComponent };
943
+ //# sourceMappingURL=trismegisto-spine-auto-service-auto-service.component-DmLafUkX.mjs.map