@fylib/adapter-angular 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base/base-component.d.ts +18 -0
- package/dist/base/base-component.js +36 -0
- package/dist/base/interaction.utils.d.ts +7 -0
- package/dist/base/interaction.utils.js +34 -0
- package/dist/base/interaction.utils.test.d.ts +1 -0
- package/dist/base/interaction.utils.test.js +25 -0
- package/dist/components/accordion.component.d.ts +32 -0
- package/dist/components/accordion.component.js +337 -0
- package/dist/components/badge.component.d.ts +10 -0
- package/dist/components/badge.component.js +112 -0
- package/dist/components/button.component.d.ts +33 -0
- package/dist/components/button.component.js +272 -0
- package/dist/components/card.component.d.ts +29 -0
- package/dist/components/card.component.js +236 -0
- package/dist/components/chart.component.d.ts +39 -0
- package/dist/components/chart.component.js +307 -0
- package/dist/components/icon.component.d.ts +18 -0
- package/dist/components/icon.component.js +144 -0
- package/dist/components/input.component.d.ts +50 -0
- package/dist/components/input.component.js +383 -0
- package/dist/components/modal.component.d.ts +46 -0
- package/dist/components/modal.component.js +404 -0
- package/dist/components/nav-link.component.d.ts +11 -0
- package/dist/components/nav-link.component.js +121 -0
- package/dist/components/notification-menu.component.d.ts +68 -0
- package/dist/components/notification-menu.component.js +695 -0
- package/dist/components/select.component.d.ts +52 -0
- package/dist/components/select.component.js +395 -0
- package/dist/components/table.component.d.ts +55 -0
- package/dist/components/table.component.js +643 -0
- package/dist/components/text.component.d.ts +8 -0
- package/dist/components/text.component.js +58 -0
- package/dist/components/toast.component.d.ts +27 -0
- package/dist/components/toast.component.js +260 -0
- package/dist/directives/animation.directive.d.ts +5 -0
- package/dist/directives/animation.directive.js +34 -0
- package/dist/directives/theme-vars.directive.d.ts +7 -0
- package/dist/directives/theme-vars.directive.js +70 -0
- package/dist/directives/wallpaper.directive.d.ts +28 -0
- package/dist/directives/wallpaper.directive.js +195 -0
- package/dist/effects/confetti.plugin.d.ts +1 -0
- package/dist/effects/confetti.plugin.js +151 -0
- package/dist/effects/extra-effects.plugin.d.ts +3 -0
- package/dist/effects/extra-effects.plugin.js +288 -0
- package/dist/effects/hearts.plugin.d.ts +1 -0
- package/dist/effects/hearts.plugin.js +172 -0
- package/dist/effects/register-all.d.ts +1 -0
- package/dist/effects/register-all.js +16 -0
- package/dist/effects/ui-effects.plugin.d.ts +1 -0
- package/dist/effects/ui-effects.plugin.js +134 -0
- package/dist/icons/providers/fontawesome.provider.d.ts +3 -0
- package/dist/icons/providers/fontawesome.provider.js +25 -0
- package/dist/icons/providers/mdi.provider.d.ts +3 -0
- package/dist/icons/providers/mdi.provider.js +13 -0
- package/dist/icons/providers/phosphor.provider.d.ts +3 -0
- package/dist/icons/providers/phosphor.provider.js +17 -0
- package/dist/icons/registry.d.ts +22 -0
- package/dist/icons/registry.js +12 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +29 -0
- package/dist/layouts/layout.component.d.ts +24 -0
- package/dist/layouts/layout.component.js +255 -0
- package/dist/layouts/slot.component.d.ts +61 -0
- package/dist/layouts/slot.component.js +937 -0
- package/dist/providers.d.ts +12 -0
- package/dist/providers.js +18 -0
- package/dist/services/fylib.service.d.ts +31 -0
- package/dist/services/fylib.service.js +214 -0
- package/dist/services/notification.service.d.ts +27 -0
- package/dist/services/notification.service.js +118 -0
- package/dist/services/sse.service.d.ts +16 -0
- package/dist/services/sse.service.js +109 -0
- package/dist/services/webclient.service.d.ts +38 -0
- package/dist/services/webclient.service.js +144 -0
- package/package.json +43 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Injectable, inject } from '@angular/core';
|
|
8
|
+
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
|
9
|
+
import { throwError, from } from 'rxjs';
|
|
10
|
+
import { catchError, retry, timeout, switchMap } from 'rxjs/operators';
|
|
11
|
+
import { FyLibService } from './fylib.service';
|
|
12
|
+
import { FyNotificationService } from './notification.service';
|
|
13
|
+
import { cryptoEngine } from '@fylib/crypto';
|
|
14
|
+
let FyWebClientService = class FyWebClientService {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.http = inject(HttpClient);
|
|
17
|
+
this.fylib = inject(FyLibService);
|
|
18
|
+
this.notify = inject(FyNotificationService);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Realiza uma requisição GET reativa
|
|
22
|
+
*/
|
|
23
|
+
get(url, options = {}) {
|
|
24
|
+
const finalUrl = this.buildUrl(url);
|
|
25
|
+
const finalOptions = this.mergeOptions(options);
|
|
26
|
+
return this.http.get(finalUrl, {
|
|
27
|
+
headers: finalOptions.headers,
|
|
28
|
+
params: finalOptions.params,
|
|
29
|
+
responseType: finalOptions.responseType
|
|
30
|
+
}).pipe(timeout(finalOptions.timeout || 10000), retry({
|
|
31
|
+
count: finalOptions.retries || 0,
|
|
32
|
+
delay: finalOptions.retryDelay || 1000
|
|
33
|
+
}), switchMap(data => from(this.processIncomingData(data, finalOptions))), catchError(err => this.handleError(err, finalOptions)));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Realiza uma requisição POST reativa
|
|
37
|
+
*/
|
|
38
|
+
post(url, body, options = {}) {
|
|
39
|
+
const finalUrl = this.buildUrl(url);
|
|
40
|
+
const finalOptions = this.mergeOptions(options);
|
|
41
|
+
return from(this.processOutgoingData(body, finalOptions)).pipe(switchMap(processedBody => this.http.post(finalUrl, processedBody, {
|
|
42
|
+
headers: finalOptions.headers,
|
|
43
|
+
params: finalOptions.params,
|
|
44
|
+
responseType: finalOptions.responseType
|
|
45
|
+
})), timeout(finalOptions.timeout || 10000), retry({
|
|
46
|
+
count: finalOptions.retries || 0,
|
|
47
|
+
delay: finalOptions.retryDelay || 1000
|
|
48
|
+
}), switchMap(data => from(this.processIncomingData(data, finalOptions))), catchError(err => this.handleError(err, finalOptions)));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Realiza uma requisição PUT reativa
|
|
52
|
+
*/
|
|
53
|
+
put(url, body, options = {}) {
|
|
54
|
+
const finalUrl = this.buildUrl(url);
|
|
55
|
+
const finalOptions = this.mergeOptions(options);
|
|
56
|
+
return from(this.processOutgoingData(body, finalOptions)).pipe(switchMap(processedBody => this.http.put(finalUrl, processedBody, {
|
|
57
|
+
headers: finalOptions.headers,
|
|
58
|
+
params: finalOptions.params,
|
|
59
|
+
responseType: finalOptions.responseType
|
|
60
|
+
})), timeout(finalOptions.timeout || 10000), switchMap(data => from(this.processIncomingData(data, finalOptions))), catchError(err => this.handleError(err, finalOptions)));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Realiza uma requisição DELETE reativa
|
|
64
|
+
*/
|
|
65
|
+
delete(url, options = {}) {
|
|
66
|
+
const finalUrl = this.buildUrl(url);
|
|
67
|
+
const finalOptions = this.mergeOptions(options);
|
|
68
|
+
return this.http.delete(finalUrl, {
|
|
69
|
+
headers: finalOptions.headers,
|
|
70
|
+
params: finalOptions.params,
|
|
71
|
+
responseType: finalOptions.responseType
|
|
72
|
+
}).pipe(timeout(finalOptions.timeout || 10000), switchMap(data => from(this.processIncomingData(data, finalOptions))), catchError(err => this.handleError(err, finalOptions)));
|
|
73
|
+
}
|
|
74
|
+
// --- Métodos Privados Auxiliares ---
|
|
75
|
+
buildUrl(url) {
|
|
76
|
+
const baseUrl = this.fylib.config().http?.baseUrl;
|
|
77
|
+
if (baseUrl && !url.startsWith('http')) {
|
|
78
|
+
return `${baseUrl.replace(/\/$/, '')}/${url.replace(/^\//, '')}`;
|
|
79
|
+
}
|
|
80
|
+
return url;
|
|
81
|
+
}
|
|
82
|
+
mergeOptions(options) {
|
|
83
|
+
const globalHttp = this.fylib.config().http || {};
|
|
84
|
+
return {
|
|
85
|
+
timeout: options.timeout ?? globalHttp.timeout ?? 15000,
|
|
86
|
+
retries: options.retries ?? globalHttp.retries ?? 0,
|
|
87
|
+
retryDelay: options.retryDelay ?? globalHttp.retryDelay ?? 1000,
|
|
88
|
+
cryptoEnabled: options.cryptoEnabled ?? globalHttp.cryptoEnabled ?? true,
|
|
89
|
+
autoNotify: options.autoNotify ?? globalHttp.autoNotify ?? true,
|
|
90
|
+
headers: {
|
|
91
|
+
...globalHttp.headers,
|
|
92
|
+
...options.headers
|
|
93
|
+
},
|
|
94
|
+
...options
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async processOutgoingData(body, options) {
|
|
98
|
+
const cryptoCfg = this.fylib.config().crypto;
|
|
99
|
+
if (options.cryptoEnabled && cryptoCfg?.enabled && body) {
|
|
100
|
+
const jsonStr = typeof body === 'string' ? body : JSON.stringify(body);
|
|
101
|
+
const encrypted = await cryptoEngine.encrypt(jsonStr, cryptoCfg);
|
|
102
|
+
return { payload: encrypted, encrypted: true };
|
|
103
|
+
}
|
|
104
|
+
return body;
|
|
105
|
+
}
|
|
106
|
+
async processIncomingData(data, options) {
|
|
107
|
+
const cryptoCfg = this.fylib.config().crypto;
|
|
108
|
+
let result = data;
|
|
109
|
+
// Se vier embrulhado em { payload: '...' } ou for uma string criptografada
|
|
110
|
+
if (options.cryptoEnabled && cryptoCfg?.enabled) {
|
|
111
|
+
const encryptedPayload = data?.payload || (typeof data === 'string' ? data : null);
|
|
112
|
+
if (encryptedPayload) {
|
|
113
|
+
try {
|
|
114
|
+
const decrypted = await cryptoEngine.decrypt(encryptedPayload, cryptoCfg);
|
|
115
|
+
result = JSON.parse(decrypted);
|
|
116
|
+
}
|
|
117
|
+
catch (e) {
|
|
118
|
+
console.error('[fyLib WebClient] Erro ao descriptografar resposta:', e);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (options.autoNotify) {
|
|
123
|
+
this.notify.success('Dados carregados com sucesso', 'WebClient');
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
handleError(error, options) {
|
|
128
|
+
let errorMessage = 'Ocorreu um erro na requisição';
|
|
129
|
+
if (error instanceof HttpErrorResponse) {
|
|
130
|
+
errorMessage = `Erro ${error.status}: ${error.statusText || error.message}`;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
errorMessage = error.message;
|
|
134
|
+
}
|
|
135
|
+
if (options.autoNotify) {
|
|
136
|
+
this.notify.error(errorMessage, 'Erro de Conexão');
|
|
137
|
+
}
|
|
138
|
+
return throwError(() => error);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
FyWebClientService = __decorate([
|
|
142
|
+
Injectable({ providedIn: 'root' })
|
|
143
|
+
], FyWebClientService);
|
|
144
|
+
export { FyWebClientService };
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fylib/adapter-angular",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.json",
|
|
14
|
+
"test": "vitest run --passWithNoTests"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@angular/common": "catalog:",
|
|
18
|
+
"@angular/core": "catalog:",
|
|
19
|
+
"chart.js": "catalog:",
|
|
20
|
+
"ng2-charts": "catalog:",
|
|
21
|
+
"rxjs": "catalog:"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@fylib/core": "workspace:*",
|
|
25
|
+
"@fylib/theme": "workspace:*",
|
|
26
|
+
"@fylib/animation": "workspace:*",
|
|
27
|
+
"@fylib/catalog": "workspace:*",
|
|
28
|
+
"@fylib/config": "workspace:*",
|
|
29
|
+
"@fylib/crypto": "workspace:*",
|
|
30
|
+
"@fylib/logger": "workspace:*",
|
|
31
|
+
"chart.js": "catalog:",
|
|
32
|
+
"ng2-charts": "catalog:",
|
|
33
|
+
"rxjs": "catalog:",
|
|
34
|
+
"tslib": "catalog:"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"typescript": "catalog:",
|
|
38
|
+
"@angular/common": "catalog:",
|
|
39
|
+
"@angular/core": "catalog:",
|
|
40
|
+
"@angular/compiler": "catalog:",
|
|
41
|
+
"@types/node": "catalog:"
|
|
42
|
+
}
|
|
43
|
+
}
|