@trismegisto/spine 2.1.2 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) 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-dKM4fG42.mjs +89 -0
  5. package/fesm2022/trismegisto-spine-auto-service-apps.technical-dKM4fG42.mjs.map +1 -0
  6. package/fesm2022/trismegisto-spine-auto-service-apps.usage-VMrCG5o3.mjs +91 -0
  7. package/fesm2022/trismegisto-spine-auto-service-apps.usage-VMrCG5o3.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-BNtNWfiu.mjs +37 -0
  13. package/fesm2022/{trismegisto-spine-auto-service-auto-service-audit.component-CCiz-q8o.mjs.map → trismegisto-spine-auto-service-auto-service-audit.component-BNtNWfiu.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-DdtDk_xl.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-DdtDk_xl.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-DXl1y6Sx.mjs} +123 -27
  17. package/fesm2022/trismegisto-spine-auto-service-auto-service-client.component-DXl1y6Sx.mjs.map +1 -0
  18. package/fesm2022/trismegisto-spine-auto-service-auto-service-delete-B1tXgMvi.mjs +88 -0
  19. package/fesm2022/trismegisto-spine-auto-service-auto-service-delete-B1tXgMvi.mjs.map +1 -0
  20. package/fesm2022/trismegisto-spine-auto-service-auto-service-groups.component-C4iQ2GPX.mjs +599 -0
  21. package/fesm2022/trismegisto-spine-auto-service-auto-service-groups.component-C4iQ2GPX.mjs.map +1 -0
  22. package/fesm2022/trismegisto-spine-auto-service-auto-service-login-attempts.component-B87vibNB.mjs +37 -0
  23. package/fesm2022/trismegisto-spine-auto-service-auto-service-login-attempts.component-B87vibNB.mjs.map +1 -0
  24. package/fesm2022/trismegisto-spine-auto-service-auto-service.component-DV88Uger.mjs +941 -0
  25. package/fesm2022/trismegisto-spine-auto-service-auto-service.component-DV88Uger.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-D05838rU.mjs +69 -0
  31. package/fesm2022/trismegisto-spine-auto-service-groups.technical-D05838rU.mjs.map +1 -0
  32. package/fesm2022/trismegisto-spine-auto-service-groups.usage-ChGMgYU3.mjs +80 -0
  33. package/fesm2022/trismegisto-spine-auto-service-groups.usage-ChGMgYU3.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 +1175 -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 +506 -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-audit.component-CCiz-q8o.mjs +0 -37
  66. package/fesm2022/trismegisto-spine-auto-service-auto-service-client.component-C7SPavrX.mjs.map +0 -1
  67. package/fesm2022/trismegisto-spine-auto-service-auto-service-delete-6Bk46MOf.mjs +0 -39
  68. package/fesm2022/trismegisto-spine-auto-service-auto-service-delete-6Bk46MOf.mjs.map +0 -1
  69. package/fesm2022/trismegisto-spine-auto-service-auto-service-groups.component-CqIVe2LU.mjs +0 -357
  70. package/fesm2022/trismegisto-spine-auto-service-auto-service-groups.component-CqIVe2LU.mjs.map +0 -1
  71. package/fesm2022/trismegisto-spine-auto-service-auto-service.component-BLN49F4a.mjs +0 -502
  72. package/fesm2022/trismegisto-spine-auto-service-auto-service.component-BLN49F4a.mjs.map +0 -1
  73. package/fesm2022/trismegisto-spine-auto-service-client.technical-BHWhpyWv.mjs.map +0 -1
  74. package/fesm2022/trismegisto-spine-auto-service-client.usage-CM2WB2e2.mjs.map +0 -1
  75. package/fesm2022/trismegisto-spine-auto-service-groups.technical-jQlwaQPn.mjs +0 -39
  76. package/fesm2022/trismegisto-spine-auto-service-groups.technical-jQlwaQPn.mjs.map +0 -1
  77. package/fesm2022/trismegisto-spine-auto-service-groups.usage-Bh7ig2zZ.mjs +0 -54
  78. package/fesm2022/trismegisto-spine-auto-service-groups.usage-Bh7ig2zZ.mjs.map +0 -1
  79. package/fesm2022/trismegisto-spine-auto-service-home.component-vl3BPFnk.mjs.map +0 -1
@@ -0,0 +1,941 @@
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-DdtDk_xl.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-B1tXgMvi.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
+ /** A operação depende de permissão para esse modo (a caixa fica escolhível). */
144
+ function requiresPermission(level, mode = 'group') {
145
+ if (mode === 'token')
146
+ return level !== 'public';
147
+ return level === 'protected';
148
+ }
149
+ /** Por que a operação não precisa de permissão (no idioma ativo); vazio quando precisa. */
150
+ function freeAccessText(level, text, mode = 'group') {
151
+ if (requiresPermission(level, mode))
152
+ return '';
153
+ if (mode === 'token')
154
+ return text.publicNoToken;
155
+ if (level === 'private')
156
+ return text.freeForAuthenticated;
157
+ if (level === 'public' || level === 'optional')
158
+ return text.freeForAll;
159
+ return text.freeNoPermission;
160
+ }
161
+ /**
162
+ * Estado inicial da caixa de uma operação que NÃO depende de permissão: no grupo vem marcada (já vale para ele); no token
163
+ * vem desmarcada (pública não passa pelo token). Nos dois casos desabilitada.
164
+ */
165
+ function freeChecked(mode) {
166
+ return mode === 'group';
167
+ }
168
+ /** Cor do selo de nível, a mesma da aba Operações: pública em verde, protegida em amarelo; o resto neutro. */
169
+ function levelTagColor(level) {
170
+ if (level === 'public')
171
+ return 'success';
172
+ if (level === 'protected')
173
+ return 'warning';
174
+ return 'neutral';
175
+ }
176
+
177
+ /**
178
+ * "Gerenciar operações" de um consumer da aplicação: a caixa de cada operação e a diferença gravada ao confirmar.
179
+ * `mode` diz de quem é o consumer: `group` (aba Acessos; public/private já valem e vêm marcadas e travadas) ou `token`
180
+ * (aba Tokens; nada vem marcado, protected e private são escolhíveis e public fica travada e desmarcada).
181
+ */
182
+ class AutoServiceConsumerPermissionsComponent {
183
+ constructor(service) {
184
+ this.service = service;
185
+ this.text = inject(SPINE_MESSAGES).autoService;
186
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
187
+ this.cdr = inject(ChangeDetectorRef);
188
+ this.fmt = formatMessage;
189
+ this.levelTagColor = levelTagColor;
190
+ this.toast = inject(HermesToastService);
191
+ this.clientId = '';
192
+ this.appId = '';
193
+ this.consumer = null;
194
+ this.mode = 'group';
195
+ this.open = false;
196
+ this.openChange = new EventEmitter();
197
+ this.rows = [];
198
+ this.loading = false;
199
+ this.saving = false;
200
+ }
201
+ ngOnChanges(changes) { if (changes['open'] && this.open) {
202
+ this.reset();
203
+ } }
204
+ close() { this.open = false; this.openChange.emit(false); }
205
+ async reset() {
206
+ this.loading = true;
207
+ try {
208
+ const [opsRes, permsRes] = await Promise.all([
209
+ this.service.getAppOperations(this.clientId, this.appId),
210
+ this.service.getAppPermissions(this.clientId, this.consumer.consumer_id),
211
+ ]);
212
+ const operations = opsRes.operations ?? [];
213
+ const permissions = permsRes.permissions ?? [];
214
+ this.rows = operations.map((op) => {
215
+ const perm = permissions.find((p) => p.operation_id === op.operation_id);
216
+ // Operação que não depende de permissão neste modo (o servidor recusa liberá-la): sem permissão gravada, a caixa
217
+ // vem travada (marcada no grupo, desmarcada no token); com uma antiga, fica editável para dar para retirar.
218
+ const free = !perm && !requiresPermission(op.level, this.mode) ? freeAccessText(op.level, this.text, this.mode) : '';
219
+ return {
220
+ operation_id: op.operation_id, identifier: op.identifier, method: op.method, level: op.level,
221
+ description: op.description, permissionId: perm?.permission_id, free,
222
+ control: free
223
+ ? new FormControl({ value: freeChecked(this.mode), disabled: true }, { nonNullable: true })
224
+ : new FormControl(!!perm, { nonNullable: true }),
225
+ };
226
+ });
227
+ }
228
+ finally {
229
+ this.loading = false;
230
+ this.cdr.markForCheck();
231
+ }
232
+ }
233
+ get hasChanges() { return this.rows.some(r => !r.free && r.control.value !== !!r.permissionId); }
234
+ async confirm() {
235
+ const toAdd = this.rows.filter(r => !r.free && r.control.value && !r.permissionId);
236
+ const toRemove = this.rows.filter(r => !r.free && !r.control.value && r.permissionId);
237
+ if (toAdd.length === 0 && toRemove.length === 0) {
238
+ this.close();
239
+ return;
240
+ }
241
+ this.saving = true;
242
+ try {
243
+ for (const r of toAdd) {
244
+ await this.service.addAppPermission(this.clientId, this.consumer.consumer_id, r.operation_id);
245
+ }
246
+ for (const r of toRemove) {
247
+ await this.service.removeAppPermission(this.clientId, this.consumer.consumer_id, r.permissionId);
248
+ }
249
+ this.close();
250
+ }
251
+ catch (err) {
252
+ // O drawer fica aberto; reabrir relê o que de fato ficou gravado.
253
+ this.toast.error(autoServiceErrorText(err, this.text, this.text.permissionsSaveError));
254
+ }
255
+ finally {
256
+ this.saving = false;
257
+ this.cdr.markForCheck();
258
+ }
259
+ }
260
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceConsumerPermissionsComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
261
+ 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", mode: "mode", 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 <p class=\"op-note muted\" *ngIf=\"!loading && mode === 'token' && rows.length\">{{ text.tokenOperationsNote }}</p>\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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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-note{margin:0 0 var(--hm-space-sm);font-size:var(--hm-font-size-sm)}.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 }); }
262
+ }
263
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceConsumerPermissionsComponent, decorators: [{
264
+ type: Component,
265
+ 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 <p class=\"op-note muted\" *ngIf=\"!loading && mode === 'token' && rows.length\">{{ text.tokenOperationsNote }}</p>\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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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-note{margin:0 0 var(--hm-space-sm);font-size:var(--hm-font-size-sm)}.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"] }]
266
+ }], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
267
+ type: Input
268
+ }], appId: [{
269
+ type: Input
270
+ }], consumer: [{
271
+ type: Input
272
+ }], mode: [{
273
+ type: Input
274
+ }], open: [{
275
+ type: Input
276
+ }], openChange: [{
277
+ type: Output
278
+ }] } });
279
+
280
+ class AutoServiceAppAccessComponent {
281
+ constructor(service) {
282
+ this.service = service;
283
+ this.text = inject(SPINE_MESSAGES).autoService;
284
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
285
+ this.cdr = inject(ChangeDetectorRef);
286
+ this.deletion = inject(AutoServiceDeleteFeedback);
287
+ this.clientId = '';
288
+ this.appId = '';
289
+ this.entries = [];
290
+ this.availableGroups = [];
291
+ this.loading = false;
292
+ this.showCreate = false;
293
+ this.showPermissions = false;
294
+ this.activeConsumer = null;
295
+ this.rowId = (c) => c.consumer_id;
296
+ this.columns = computed(() => [
297
+ { key: 'group_name', title: this.text.colGroup, value: (c) => c.group_name, sortable: true },
298
+ { key: 'group_type_name', title: this.text.colType, value: (c) => c.group_type_name, sortable: true },
299
+ ], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
300
+ this.rowActions = computed(() => [
301
+ { id: 'permissions', icon: 'shield', label: this.text.manageOperations },
302
+ {
303
+ id: 'delete', icon: 'trash', label: this.text.remove, danger: true, separatorAbove: true,
304
+ confirm: (c) => ({ heading: this.text.confirmRemoveConsumerHeading, message: formatMessage(this.text.confirmRemoveConsumer, { group: c.group_name }) }),
305
+ },
306
+ ], ...(ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []));
307
+ }
308
+ ngOnChanges(changes) {
309
+ if (changes['appId']) {
310
+ this.load();
311
+ }
312
+ if (changes['clientId']) {
313
+ this.loadGroups();
314
+ }
315
+ }
316
+ async load() {
317
+ if (!this.appId) {
318
+ this.entries = [];
319
+ return;
320
+ }
321
+ this.loading = true;
322
+ try {
323
+ const res = await this.service.getAppConsumers(this.clientId, this.appId);
324
+ this.entries = (res.consumers ?? []).filter((c) => !c.group_is_admin);
325
+ }
326
+ finally {
327
+ this.loading = false;
328
+ this.cdr.markForCheck();
329
+ }
330
+ }
331
+ async loadGroups() {
332
+ if (!this.clientId) {
333
+ this.availableGroups = [];
334
+ return;
335
+ }
336
+ const res = await this.service.getGroups(this.clientId);
337
+ this.availableGroups = (res.groups ?? []).filter((g) => !g.is_admin);
338
+ this.cdr.markForCheck();
339
+ }
340
+ openCreate() { this.showCreate = true; }
341
+ async onCreated() { await this.load(); }
342
+ /** Já confirmado pelo `confirm` da ação na grade. */
343
+ async deleteConsumer(consumerId) {
344
+ if (await this.deletion.run(() => this.service.deleteAppConsumer(this.clientId, consumerId)))
345
+ await this.load();
346
+ }
347
+ openPermissions(consumer) { this.activeConsumer = consumer; this.showPermissions = true; }
348
+ onAction(e) {
349
+ if (e.action === 'permissions')
350
+ this.openPermissions(e.row);
351
+ if (e.action === 'delete')
352
+ void this.deleteConsumer(e.row.consumer_id);
353
+ }
354
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppAccessComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
355
+ 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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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", "mode", "open"], outputs: ["openChange"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
356
+ }
357
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppAccessComponent, decorators: [{
358
+ type: Component,
359
+ 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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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"] }]
360
+ }], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
361
+ type: Input
362
+ }], appId: [{
363
+ type: Input
364
+ }] } });
365
+
366
+ class AutoServiceAppOperationsComponent {
367
+ constructor(service) {
368
+ this.service = service;
369
+ this.text = inject(SPINE_MESSAGES).autoService;
370
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
371
+ this.cdr = inject(ChangeDetectorRef);
372
+ this.messages = inject(SPINE_MESSAGES);
373
+ this.clientId = '';
374
+ this.appId = '';
375
+ this.operations = [];
376
+ this.loading = false;
377
+ this.rowId = (op) => op.operation_id;
378
+ this.columns = computed(() => [
379
+ { key: 'identifier', title: this.text.colIdentifier, value: (op) => op.identifier, sortable: true },
380
+ { key: 'method', title: this.text.colMethod, value: (op) => op.method, sortable: true },
381
+ { key: 'level', title: this.text.colLevel, value: (op) => op.level, sortable: true },
382
+ { key: 'description', title: this.text.colDescription, value: (op) => op.description || '—' },
383
+ {
384
+ key: 'allowed_groups', title: this.text.colAllowedGroups,
385
+ value: (op) => op.allowed_groups?.length ? pluralMessage(this.text.groupCount, op.allowed_groups.length, this.messages.meta.locale) : '—',
386
+ },
387
+ ], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
388
+ }
389
+ ngOnChanges(changes) { if (changes['appId']) {
390
+ this.load();
391
+ } }
392
+ async load() {
393
+ if (!this.appId) {
394
+ this.operations = [];
395
+ return;
396
+ }
397
+ this.loading = true;
398
+ try {
399
+ const res = await this.service.getAppOperations(this.clientId, this.appId);
400
+ this.operations = res.operations;
401
+ }
402
+ finally {
403
+ this.loading = false;
404
+ this.cdr.markForCheck();
405
+ }
406
+ }
407
+ /** Nível da operação no selo: pública em verde, protegida em amarelo; o resto neutro. */
408
+ levelTagColor(level) {
409
+ if (level === 'public')
410
+ return 'success';
411
+ if (level === 'protected')
412
+ return 'warning';
413
+ return 'neutral';
414
+ }
415
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppOperationsComponent, deps: [{ token: AutoServiceService }], target: i0.ɵɵFactoryTarget.Component }); }
416
+ 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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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 }); }
417
+ }
418
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppOperationsComponent, decorators: [{
419
+ type: Component,
420
+ 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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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"] }]
421
+ }], ctorParameters: () => [{ type: AutoServiceService }], propDecorators: { clientId: [{
422
+ type: Input
423
+ }], appId: [{
424
+ type: Input
425
+ }] } });
426
+
427
+ /** Teto de validade aceito pelo servidor (`APP_TOKEN_MAX_DAYS` do argos-admin). */
428
+ const APP_TOKEN_MAX_DAYS = 365;
429
+ /** Validade sugerida ao abrir o modal. */
430
+ const APP_TOKEN_DEFAULT_DAYS = 90;
431
+ /** Limite do nome no formulário. */
432
+ const APP_TOKEN_NAME_MAX = 100;
433
+ /** Data LOCAL em AAAA-MM-DD (`toISOString()` daria a data em UTC: em UTC-3, depois das 21h já é amanhã). */
434
+ function localIsoDate(date) {
435
+ const y = date.getFullYear();
436
+ const m = String(date.getMonth() + 1).padStart(2, '0');
437
+ const d = String(date.getDate()).padStart(2, '0');
438
+ return `${y}-${m}-${d}`;
439
+ }
440
+ /** Hoje + `days` dias, em data local (`setDate` cuida da virada de mês e ano). */
441
+ function addLocalDays(base, days) {
442
+ const date = new Date(base.getFullYear(), base.getMonth(), base.getDate());
443
+ date.setDate(date.getDate() + days);
444
+ return localIsoDate(date);
445
+ }
446
+ /**
447
+ * Meia-noite LOCAL do dia escolhido (AAAA-MM-DD), em ISO com fuso. Mandar só a data fazia o servidor ler meia-noite
448
+ * UTC (em UTC-3 "amanhã" podia já ter passado). Meia-noite local de amanhã é sempre futura e a de hoje + 365 nunca
449
+ * passa de agora + 365 dias.
450
+ */
451
+ function localDayStartIso(value) {
452
+ const [y, m, d] = value.split('-').map(Number);
453
+ return new Date(y, m - 1, d).toISOString();
454
+ }
455
+ /** Intervalo [min, max] comparando AAAA-MM-DD (ordem do texto = ordem das datas). */
456
+ function dateRangeValidator(min, max) {
457
+ return (control) => {
458
+ const value = control.value;
459
+ if (!value)
460
+ return null;
461
+ if (value < min)
462
+ return { minDate: { min, actual: value } };
463
+ if (value > max)
464
+ return { maxDate: { max, actual: value } };
465
+ return null;
466
+ };
467
+ }
468
+ /**
469
+ * "Novo token" de uma aplicação: nome, descrição, validade (de amanhã até 365 dias) e as operações liberadas ao token.
470
+ * Nada vem marcado: o token não tem login, então `protected` e `private` (e `optional`) só valem se marcadas aqui; as
471
+ * `public` aparecem desmarcadas e desabilitadas (não precisam de token) e nunca vão em `operation_ids`. Criado, o valor aparece uma única vez, com copiar; fechar o descarta.
472
+ * Mirror de admin/ui/.../apps/tabs/app-tokens/modals/token-create (argos-admin), escopado em `/auto-service/:clientId`.
473
+ */
474
+ class AutoServiceTokenCreateComponent {
475
+ constructor() {
476
+ this.text = inject(SPINE_MESSAGES).autoService;
477
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
478
+ this.cdr = inject(ChangeDetectorRef);
479
+ this.service = inject(AutoServiceService);
480
+ this.levelTagColor = levelTagColor;
481
+ this.nameMax = APP_TOKEN_NAME_MAX;
482
+ this.clientId = '';
483
+ this.appId = '';
484
+ this.open = false;
485
+ this.openChange = new EventEmitter();
486
+ /** Token criado (a lista recarrega na hora, sem esperar o modal fechar). */
487
+ this.created = new EventEmitter();
488
+ this.minDate = addLocalDays(new Date(), 1);
489
+ this.maxDate = addLocalDays(new Date(), APP_TOKEN_MAX_DAYS);
490
+ this.name = new FormControl('', { nonNullable: true, validators: [Validators.required, Validators.maxLength(APP_TOKEN_NAME_MAX)] });
491
+ this.description = new FormControl('', { nonNullable: true });
492
+ this.expiresAt = new FormControl(null, { validators: [Validators.required] });
493
+ this.rows = [];
494
+ this.loading = false;
495
+ this.saving = false;
496
+ this.saveError = null;
497
+ /** Valor recém-criado: aparece uma única vez, só enquanto o modal está aberto. */
498
+ this.createdToken = null;
499
+ }
500
+ /** Mensagens de validação da data no idioma ativo (o `hm-date-picker` mostra pelo `messages`). */
501
+ get dateMessages() {
502
+ return { minDate: this.text.tokenExpiresInvalid, maxDate: this.text.tokenExpiresInvalid };
503
+ }
504
+ get canSave() {
505
+ return !this.saving && !this.loading && this.name.valid && !!this.name.value.trim() && this.expiresAt.valid;
506
+ }
507
+ get hasFreeRows() { return this.rows.some((r) => !!r.free); }
508
+ ngOnChanges(changes) { if (changes['open'] && this.open)
509
+ void this.reset(); }
510
+ /** Abre limpo: datas recalculadas (o modal pode ficar montado de um dia para o outro) e operações relidas. */
511
+ async reset() {
512
+ this.minDate = addLocalDays(new Date(), 1);
513
+ this.maxDate = addLocalDays(new Date(), APP_TOKEN_MAX_DAYS);
514
+ this.expiresAt.setValidators([Validators.required, dateRangeValidator(this.minDate, this.maxDate)]);
515
+ this.name.reset('');
516
+ this.description.reset('');
517
+ this.expiresAt.reset(addLocalDays(new Date(), APP_TOKEN_DEFAULT_DAYS));
518
+ this.createdToken = null;
519
+ this.saveError = null;
520
+ this.rows = [];
521
+ this.loading = true;
522
+ this.cdr.markForCheck();
523
+ try {
524
+ const res = await this.service.getAppOperations(this.clientId, this.appId);
525
+ this.rows = (res.operations ?? []).map((op) => ({
526
+ operation_id: op.operation_id,
527
+ identifier: op.identifier,
528
+ method: op.method,
529
+ level: op.level,
530
+ description: op.description,
531
+ free: freeAccessText(op.level, this.text, 'token'),
532
+ control: requiresPermission(op.level, 'token')
533
+ ? new FormControl(false, { nonNullable: true })
534
+ : new FormControl({ value: false, disabled: true }, { nonNullable: true }),
535
+ }));
536
+ }
537
+ catch (err) {
538
+ this.saveError = autoServiceErrorText(err, this.text, this.text.tokenSaveError);
539
+ }
540
+ finally {
541
+ this.loading = false;
542
+ this.cdr.markForCheck();
543
+ }
544
+ }
545
+ onModalOpenChange(value) {
546
+ this.open = value;
547
+ if (!value)
548
+ this.createdToken = null;
549
+ this.openChange.emit(value);
550
+ }
551
+ close() { this.onModalOpenChange(false); }
552
+ async save() {
553
+ this.name.markAsTouched();
554
+ this.expiresAt.markAsTouched();
555
+ if (!this.canSave || !this.expiresAt.value)
556
+ return;
557
+ this.saving = true;
558
+ this.saveError = null;
559
+ this.cdr.markForCheck();
560
+ try {
561
+ const name = this.name.value.trim();
562
+ const description = this.description.value.trim();
563
+ const res = await this.service.createAppToken(this.clientId, this.appId, {
564
+ name,
565
+ ...(description ? { description } : {}),
566
+ expires_at: localDayStartIso(this.expiresAt.value),
567
+ // Só as escolhidas (protected/private): public não vira permissão (o servidor recusa com operation_public).
568
+ operation_ids: this.rows.filter((r) => !r.free && r.control.value).map((r) => r.operation_id),
569
+ });
570
+ this.createdToken = { name: res.name ?? name, token: res.token };
571
+ this.created.emit();
572
+ }
573
+ catch (err) {
574
+ this.saveError = autoServiceErrorText(err, this.text, this.text.tokenSaveError);
575
+ }
576
+ finally {
577
+ this.saving = false;
578
+ this.cdr.markForCheck();
579
+ }
580
+ }
581
+ createdHeading(name) { return formatMessage(this.text.tokenCreatedHeading, { name }); }
582
+ valueLabel(name) { return formatMessage(this.text.tokenValueLabel, { name }); }
583
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceTokenCreateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
584
+ 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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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 }); }
585
+ }
586
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceTokenCreateComponent, decorators: [{
587
+ type: Component,
588
+ args: [{ selector: 'spine-auto-service-token-create', standalone: true, imports: [
589
+ CommonModule, ReactiveFormsModule, AlertComponent, ButtonComponent, CheckboxComponent, CopyButtonComponent, DatePickerComponent,
590
+ InputComponent, ModalComponent, TagComponent, TextareaComponent,
591
+ ], 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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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"] }]
592
+ }], propDecorators: { clientId: [{
593
+ type: Input
594
+ }], appId: [{
595
+ type: Input
596
+ }], open: [{
597
+ type: Input
598
+ }], openChange: [{
599
+ type: Output
600
+ }], created: [{
601
+ type: Output
602
+ }] } });
603
+
604
+ /**
605
+ * Aba Tokens da aplicação: os tokens de API (`x-api-token`) com situação, validade e último uso; "Novo token" (modal com
606
+ * as operações liberadas) e, no menu da linha, "Gerenciar operações" (o token também é um consumer) e "Revogar" (com
607
+ * confirmação; o token para de valer na hora e fica na lista como revogado).
608
+ * Mirror de admin/ui/.../apps/tabs/app-tokens (argos-admin), escopado em `/auto-service/:clientId`.
609
+ */
610
+ class AutoServiceAppTokensComponent {
611
+ constructor() {
612
+ this.text = inject(SPINE_MESSAGES).autoService;
613
+ this.catalog = inject(SPINE_MESSAGES);
614
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
615
+ this.cdr = inject(ChangeDetectorRef);
616
+ this.service = inject(AutoServiceService);
617
+ this.toast = inject(HermesToastService);
618
+ this.clientId = '';
619
+ this.appId = '';
620
+ this.tokens = [];
621
+ this.loading = false;
622
+ this.showCreate = false;
623
+ this.showPermissions = false;
624
+ /** Token aberto em "Gerenciar operações", no formato que o painel de permissões espera (o nome no lugar do grupo). */
625
+ this.permissionsConsumer = null;
626
+ this.rowId = (tk) => tk.id;
627
+ this.columns = computed(() => [
628
+ { key: 'name', title: this.text.colName, value: (tk) => tk.name, sortable: true, searchable: true },
629
+ { key: 'prefix', title: this.text.colTokenPrefix, value: (tk) => tk.token_prefix ?? '' },
630
+ { key: 'status', title: this.text.colStatus, value: (tk) => this.statusLabel(this.status(tk)), sortable: true },
631
+ { key: 'expires_at', title: this.text.colExpiresAt, value: (tk) => tk.expires_at ?? '', sortable: true },
632
+ { key: 'last_used_at', title: this.text.colLastUsed, value: (tk) => tk.last_used_at ?? '', sortable: true },
633
+ ], ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
634
+ // Revogado não tem mais o que fazer: a linha fica sem o menu.
635
+ this.rowActions = computed(() => [
636
+ { id: 'operations', icon: 'shield', label: this.text.manageOperations, available: (tk) => !tk.revoked_at },
637
+ {
638
+ id: 'revoke', icon: 'ban', label: this.text.revokeToken, danger: true, separatorAbove: true,
639
+ available: (tk) => !tk.revoked_at,
640
+ confirm: (tk) => ({
641
+ heading: this.text.confirmRevokeTokenHeading,
642
+ message: formatMessage(this.text.confirmRevokeToken, { name: tk.name }),
643
+ confirmLabel: this.text.revokeToken,
644
+ }),
645
+ },
646
+ ], ...(ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []));
647
+ }
648
+ ngOnChanges(changes) { if (changes['appId'] || changes['clientId'])
649
+ void this.load(); }
650
+ async load() {
651
+ const { clientId, appId } = this;
652
+ if (!clientId || !appId) {
653
+ this.tokens = [];
654
+ return;
655
+ }
656
+ this.loading = true;
657
+ this.cdr.markForCheck();
658
+ try {
659
+ const res = await this.service.getAppTokens(clientId, appId);
660
+ if (this.appId !== appId || this.clientId !== clientId)
661
+ return;
662
+ this.tokens = res.tokens ?? [];
663
+ }
664
+ catch (err) {
665
+ this.tokens = [];
666
+ this.toast.error(autoServiceErrorText(err, this.text, this.text.tokensLoadError));
667
+ }
668
+ finally {
669
+ this.loading = false;
670
+ this.cdr.markForCheck();
671
+ }
672
+ }
673
+ status(tk, now = Date.now()) {
674
+ if (tk.revoked_at)
675
+ return 'revoked';
676
+ if (new Date(tk.expires_at).getTime() <= now)
677
+ return 'expired';
678
+ return 'active';
679
+ }
680
+ statusLabel(status) {
681
+ if (status === 'revoked')
682
+ return this.text.tokenRevoked;
683
+ if (status === 'expired')
684
+ return this.text.tokenExpired;
685
+ return this.text.active;
686
+ }
687
+ /** Ativo em verde, expirado em amarelo, revogado neutro; o texto do selo diz qual (a cor só reforça). */
688
+ statusColor(status) {
689
+ if (status === 'revoked')
690
+ return 'neutral';
691
+ if (status === 'expired')
692
+ return 'warning';
693
+ return 'success';
694
+ }
695
+ formatDate(value) {
696
+ if (!value)
697
+ return '';
698
+ return new Intl.DateTimeFormat(this.catalog.meta.locale, { dateStyle: 'short', timeStyle: 'short' }).format(new Date(value));
699
+ }
700
+ openCreate() { this.showCreate = true; this.cdr.markForCheck(); }
701
+ openPermissions(tk) {
702
+ this.permissionsConsumer = { consumer_id: tk.consumer_id, group_name: tk.name };
703
+ this.showPermissions = true;
704
+ this.cdr.markForCheck();
705
+ }
706
+ /** Já confirmado pelo `confirm` da ação na grade. Sucesso e falha viram toast. */
707
+ async revoke(tk) {
708
+ if (tk.revoked_at)
709
+ return;
710
+ try {
711
+ await this.service.revokeAppToken(this.clientId, this.appId, tk.id);
712
+ this.toast.success(formatMessage(this.text.tokenRevokedDone, { name: tk.name }));
713
+ }
714
+ catch (err) {
715
+ this.toast.error(autoServiceErrorText(err, this.text, this.text.tokenRevokeError));
716
+ return;
717
+ }
718
+ await this.load();
719
+ }
720
+ onAction(e) {
721
+ if (e.action === 'operations')
722
+ this.openPermissions(e.row);
723
+ if (e.action === 'revoke')
724
+ void this.revoke(e.row);
725
+ }
726
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppTokensComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
727
+ 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\" mode=\"token\" [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", "mode", "open"], outputs: ["openChange"] }], changeDetection: i0.ChangeDetectionStrategy.Eager }); }
728
+ }
729
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppTokensComponent, decorators: [{
730
+ type: Component,
731
+ args: [{ selector: 'spine-auto-service-app-tokens', standalone: true, imports: [
732
+ CommonModule, ButtonComponent, DataGridComponent, DataGridCellDirective, TagComponent,
733
+ AutoServiceTokenCreateComponent, AutoServiceConsumerPermissionsComponent,
734
+ ], 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\" mode=\"token\" [open]=\"showPermissions\" (openChange)=\"showPermissions = $event\">\n</spine-auto-service-consumer-permissions>\n", styles: [":host{display:block}\n"] }]
735
+ }], propDecorators: { clientId: [{
736
+ type: Input
737
+ }], appId: [{
738
+ type: Input
739
+ }] } });
740
+
741
+ /**
742
+ * Aplicações (client_credentials) do projeto do client: Cadastrar e um cartão com o seletor das aplicações e Consultar.
743
+ * A aplicação consultada abre embaixo: o resumo com Editar, Ativar/Desativar, Gerar novo segredo e Excluir, e as abas
744
+ * Operações, Acessos e Tokens. Mesmo molde da tela Grupos.
745
+ */
746
+ class AutoServiceAppsComponent {
747
+ constructor() {
748
+ this.text = inject(SPINE_MESSAGES).autoService;
749
+ /** Telas com estado em campo comum, preenchido depois de `await`: marca a view ao terminar (app sem zone.js). */
750
+ this.cdr = inject(ChangeDetectorRef);
751
+ this.dialogs = inject(HermesDialogService);
752
+ this.deletion = inject(AutoServiceDeleteFeedback);
753
+ this.toast = inject(HermesToastService);
754
+ this.service = inject(AutoServiceService);
755
+ this.clientId = '';
756
+ this.apps = [];
757
+ this.loading = false;
758
+ /** Aplicação escolhida no seletor (só abre ao Consultar). */
759
+ this.selectedAppId = '';
760
+ /** Aplicação aberta (resumo + abas embaixo do seletor). */
761
+ this.app = null;
762
+ this.modalApp = null;
763
+ this.showAppModal = false;
764
+ this.activeTab = 'operations';
765
+ this.newSecret = null;
766
+ /** Segredo gerado por "Gerar novo segredo", mostrado uma vez na janela até "Concluir". */
767
+ this.rotatedSecret = null;
768
+ this.rotatingSecret = false;
769
+ /** Opções do seletor, recalculadas na carga (o `hm-combobox` recebe sempre o mesmo array). */
770
+ this.appComboOptions = [];
771
+ }
772
+ // Trocar de client fecha a aplicação aberta e esconde o segredo recém-criado: ele é de uma aplicação do client anterior.
773
+ ngOnChanges(changes) {
774
+ if (changes['clientId']) {
775
+ this.app = null;
776
+ this.selectedAppId = '';
777
+ this.apps = [];
778
+ this.appComboOptions = [];
779
+ this.newSecret = null;
780
+ this.rotatedSecret = null;
781
+ void this.load();
782
+ }
783
+ }
784
+ async load() {
785
+ const clientId = this.clientId;
786
+ if (!clientId) {
787
+ this.apps = [];
788
+ this.appComboOptions = [];
789
+ return;
790
+ }
791
+ this.loading = true;
792
+ this.cdr.markForCheck();
793
+ try {
794
+ const res = await this.service.getApps(clientId);
795
+ if (this.clientId !== clientId)
796
+ return;
797
+ this.apps = res.apps ?? [];
798
+ this.appComboOptions = this.apps.map((a) => ({ value: a.id, label: a.name ?? a.id }));
799
+ // A aplicação aberta acompanha o que o servidor devolveu (nome/situação novos) ou fecha se sumiu.
800
+ if (this.app)
801
+ this.app = this.apps.find((a) => a.id === this.app.id) ?? null;
802
+ if (this.selectedAppId && !this.apps.some((a) => a.id === this.selectedAppId))
803
+ this.selectedAppId = '';
804
+ }
805
+ finally {
806
+ this.loading = false;
807
+ this.cdr.markForCheck();
808
+ }
809
+ }
810
+ /** Consultar: abre a aplicação escolhida no seletor. */
811
+ searchApp() {
812
+ const a = this.apps.find((x) => x.id === this.selectedAppId);
813
+ if (a)
814
+ this.openApp(a);
815
+ }
816
+ /** Abre a aplicação embaixo do seletor; outra aplicação volta para a aba Operações. */
817
+ openApp(a) {
818
+ if (this.app?.id !== a.id)
819
+ this.activeTab = 'operations';
820
+ this.app = a;
821
+ this.selectedAppId = a.id;
822
+ this.cdr.markForCheck();
823
+ }
824
+ setTab(tab) { this.activeTab = tab; }
825
+ openCreate() { this.modalApp = null; this.showAppModal = true; this.cdr.markForCheck(); }
826
+ openEdit(a = this.app) { if (!a)
827
+ return; this.modalApp = a; this.showAppModal = true; this.cdr.markForCheck(); }
828
+ async onAppSaved(secret) {
829
+ if (secret)
830
+ this.newSecret = secret;
831
+ await this.load();
832
+ this.cdr.markForCheck();
833
+ }
834
+ async toggleEnabled(a = this.app) {
835
+ if (!a)
836
+ return;
837
+ await this.service.updateApp(this.clientId, a.id, { enabled: !a.enabled });
838
+ await this.load();
839
+ }
840
+ /**
841
+ * "Gerar novo segredo": confirmação (o atual para de valer na hora), POST e o segredo novo numa janela,
842
+ * mostrado uma única vez. Falha vira toast (404: aplicação de outro client; 403: client que a pessoa não
843
+ * administra; senão o `detail` do servidor ou a mensagem genérica).
844
+ */
845
+ async rotateSecret(a = this.app) {
846
+ if (!a || this.rotatingSecret)
847
+ return;
848
+ const ok = await this.dialogs.confirm({
849
+ heading: this.text.confirmRotateSecretHeading,
850
+ message: this.text.confirmRotateSecret,
851
+ confirmLabel: this.text.rotateSecret,
852
+ danger: true,
853
+ });
854
+ if (!ok)
855
+ return;
856
+ this.rotatingSecret = true;
857
+ this.cdr.markForCheck();
858
+ try {
859
+ const res = await this.service.rotateAppSecret(this.clientId, a.id);
860
+ this.rotatedSecret = { name: a.name ?? a.id, secret: res.secret };
861
+ }
862
+ catch (err) {
863
+ this.toast.error(this.rotateErrorText(err));
864
+ }
865
+ finally {
866
+ this.rotatingSecret = false;
867
+ this.cdr.markForCheck();
868
+ }
869
+ }
870
+ /** Fecha a janela do segredo: depois dela não há como ver o segredo de novo. */
871
+ closeRotatedSecret() { this.rotatedSecret = null; this.cdr.markForCheck(); }
872
+ rotatedSecretHeading(name) { return formatMessage(this.text.rotatedSecretHeading, { name }); }
873
+ rotatedSecretLabel(name) { return formatMessage(this.text.rotatedSecretLabel, { name }); }
874
+ rotateErrorText(err) {
875
+ if (err instanceof HttpErrorResponse) {
876
+ if (err.status === 404)
877
+ return this.text.rotateSecretNotFound;
878
+ if (err.status === 403)
879
+ return this.text.rotateSecretForbidden;
880
+ const detail = err.error?.detail;
881
+ if (typeof detail === 'string' && detail)
882
+ return detail;
883
+ }
884
+ return this.text.rotateSecretError;
885
+ }
886
+ /** Botão Excluir do resumo: pede confirmação e só então exclui. */
887
+ async deleteApp(a = this.app) {
888
+ if (!a)
889
+ return;
890
+ const ok = await this.dialogs.confirm({
891
+ heading: this.text.confirmDeleteAppHeading,
892
+ message: formatMessage(this.text.confirmDeleteApp, { name: a.name ?? a.id }),
893
+ confirmLabel: this.text.delete,
894
+ danger: true,
895
+ });
896
+ if (ok)
897
+ await this.removeApp(a);
898
+ }
899
+ /** DELETE com toast de sucesso/erro; a aplicação aberta fecha e o segredo recém-criado some. */
900
+ async removeApp(a) {
901
+ if (!(await this.deletion.run(() => this.service.deleteApp(this.clientId, a.id))))
902
+ return;
903
+ if (this.app?.id === a.id) {
904
+ this.app = null;
905
+ this.selectedAppId = '';
906
+ }
907
+ this.newSecret = null;
908
+ await this.load();
909
+ }
910
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
911
+ 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 <div class=\"as-actions\">\n <hm-button icon=\"plus\" (clicked)=\"openCreate()\">{{ text.register }}</hm-button>\n </div>\n\n <hm-alert *ngIf=\"newSecret\" variant=\"success\" [closable]=\"true\" (closed)=\"newSecret = null\">\n {{ text.secretCreated }} <strong>{{ newSecret }}</strong>\n </hm-alert>\n\n <!-- Escolher a aplica\u00E7\u00E3o no seletor e Consultar abre o resumo (com as a\u00E7\u00F5es) e as abas embaixo. -->\n <hm-card>\n <div class=\"as-field-row\">\n <hm-combobox [label]=\"text.pickApp\" [options]=\"appComboOptions\" [value]=\"selectedAppId\"\n (valueChange)=\"selectedAppId = $event\" [disabled]=\"loading\">\n </hm-combobox>\n <hm-button [disabled]=\"!selectedAppId\" (clicked)=\"searchApp()\" icon=\"search\">{{ text.search }}</hm-button>\n </div>\n <p class=\"as-empty muted\" *ngIf=\"!loading && apps.length === 0\">{{ text.noApps }}</p>\n </hm-card>\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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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: 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: ComboboxComponent, selector: "hm-combobox", inputs: ["label", "options", "value", "placeholder", "icon", "hint", "help", "size", "labelHidden", "clearable", "requiredManual", "loading", "allowCustomValue"], outputs: ["valueChange"] }, { kind: "component", type: CopyButtonComponent, selector: "hm-copy-button", inputs: ["value", "label", "copiedLabel", "variant", "size", "disabled", "feedbackDuration"], outputs: ["copied", "copyFailed"] }, { 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 }); }
912
+ }
913
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceAppsComponent, decorators: [{
914
+ type: Component,
915
+ args: [{ selector: 'spine-auto-service-apps', standalone: true, imports: [
916
+ CommonModule, AlertComponent, ButtonComponent, CardComponent, ComboboxComponent, CopyButtonComponent, ModalComponent, TabsComponent, TabComponent, TabContentDirective, TagComponent,
917
+ AutoServiceAppsModalComponent, AutoServiceAppOperationsComponent, AutoServiceAppAccessComponent, AutoServiceAppTokensComponent,
918
+ ], changeDetection: ChangeDetectionStrategy.Eager, template: "<div class=\"as-stack\">\n <div class=\"as-actions\">\n <hm-button icon=\"plus\" (clicked)=\"openCreate()\">{{ text.register }}</hm-button>\n </div>\n\n <hm-alert *ngIf=\"newSecret\" variant=\"success\" [closable]=\"true\" (closed)=\"newSecret = null\">\n {{ text.secretCreated }} <strong>{{ newSecret }}</strong>\n </hm-alert>\n\n <!-- Escolher a aplica\u00E7\u00E3o no seletor e Consultar abre o resumo (com as a\u00E7\u00F5es) e as abas embaixo. -->\n <hm-card>\n <div class=\"as-field-row\">\n <hm-combobox [label]=\"text.pickApp\" [options]=\"appComboOptions\" [value]=\"selectedAppId\"\n (valueChange)=\"selectedAppId = $event\" [disabled]=\"loading\">\n </hm-combobox>\n <hm-button [disabled]=\"!selectedAppId\" (clicked)=\"searchApp()\" icon=\"search\">{{ text.search }}</hm-button>\n </div>\n <p class=\"as-empty muted\" *ngIf=\"!loading && apps.length === 0\">{{ text.noApps }}</p>\n </hm-card>\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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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"] }]
919
+ }], propDecorators: { clientId: [{
920
+ type: Input
921
+ }] } });
922
+
923
+ /**
924
+ * Página "Aplicações" do auto-serviço: o seletor de client e as aplicações dele. A auditoria tem página
925
+ * própria no menu Administração (`AUTO_SERVICE_SCREENS.audit`) — a aba que existia aqui duplicava a tela.
926
+ */
927
+ class AutoServiceComponent {
928
+ constructor() {
929
+ this.client = null;
930
+ }
931
+ onClientChange(c) { this.client = c; }
932
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
933
+ 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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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 }); }
934
+ }
935
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImport: i0, type: AutoServiceComponent, decorators: [{
936
+ type: Component,
937
+ 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>hm-combobox{flex:1 1 16rem;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-empty{margin:var(--hm-space-xs) 0 0;font-size:var(--hm-font-size-sm)}.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"] }]
938
+ }] });
939
+
940
+ export { AutoServiceComponent };
941
+ //# sourceMappingURL=trismegisto-spine-auto-service-auto-service.component-DV88Uger.mjs.map