@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.
Files changed (75) hide show
  1. package/dist/base/base-component.d.ts +18 -0
  2. package/dist/base/base-component.js +36 -0
  3. package/dist/base/interaction.utils.d.ts +7 -0
  4. package/dist/base/interaction.utils.js +34 -0
  5. package/dist/base/interaction.utils.test.d.ts +1 -0
  6. package/dist/base/interaction.utils.test.js +25 -0
  7. package/dist/components/accordion.component.d.ts +32 -0
  8. package/dist/components/accordion.component.js +337 -0
  9. package/dist/components/badge.component.d.ts +10 -0
  10. package/dist/components/badge.component.js +112 -0
  11. package/dist/components/button.component.d.ts +33 -0
  12. package/dist/components/button.component.js +272 -0
  13. package/dist/components/card.component.d.ts +29 -0
  14. package/dist/components/card.component.js +236 -0
  15. package/dist/components/chart.component.d.ts +39 -0
  16. package/dist/components/chart.component.js +307 -0
  17. package/dist/components/icon.component.d.ts +18 -0
  18. package/dist/components/icon.component.js +144 -0
  19. package/dist/components/input.component.d.ts +50 -0
  20. package/dist/components/input.component.js +383 -0
  21. package/dist/components/modal.component.d.ts +46 -0
  22. package/dist/components/modal.component.js +404 -0
  23. package/dist/components/nav-link.component.d.ts +11 -0
  24. package/dist/components/nav-link.component.js +121 -0
  25. package/dist/components/notification-menu.component.d.ts +68 -0
  26. package/dist/components/notification-menu.component.js +695 -0
  27. package/dist/components/select.component.d.ts +52 -0
  28. package/dist/components/select.component.js +395 -0
  29. package/dist/components/table.component.d.ts +55 -0
  30. package/dist/components/table.component.js +643 -0
  31. package/dist/components/text.component.d.ts +8 -0
  32. package/dist/components/text.component.js +58 -0
  33. package/dist/components/toast.component.d.ts +27 -0
  34. package/dist/components/toast.component.js +260 -0
  35. package/dist/directives/animation.directive.d.ts +5 -0
  36. package/dist/directives/animation.directive.js +34 -0
  37. package/dist/directives/theme-vars.directive.d.ts +7 -0
  38. package/dist/directives/theme-vars.directive.js +70 -0
  39. package/dist/directives/wallpaper.directive.d.ts +28 -0
  40. package/dist/directives/wallpaper.directive.js +195 -0
  41. package/dist/effects/confetti.plugin.d.ts +1 -0
  42. package/dist/effects/confetti.plugin.js +151 -0
  43. package/dist/effects/extra-effects.plugin.d.ts +3 -0
  44. package/dist/effects/extra-effects.plugin.js +288 -0
  45. package/dist/effects/hearts.plugin.d.ts +1 -0
  46. package/dist/effects/hearts.plugin.js +172 -0
  47. package/dist/effects/register-all.d.ts +1 -0
  48. package/dist/effects/register-all.js +16 -0
  49. package/dist/effects/ui-effects.plugin.d.ts +1 -0
  50. package/dist/effects/ui-effects.plugin.js +134 -0
  51. package/dist/icons/providers/fontawesome.provider.d.ts +3 -0
  52. package/dist/icons/providers/fontawesome.provider.js +25 -0
  53. package/dist/icons/providers/mdi.provider.d.ts +3 -0
  54. package/dist/icons/providers/mdi.provider.js +13 -0
  55. package/dist/icons/providers/phosphor.provider.d.ts +3 -0
  56. package/dist/icons/providers/phosphor.provider.js +17 -0
  57. package/dist/icons/registry.d.ts +22 -0
  58. package/dist/icons/registry.js +12 -0
  59. package/dist/index.d.ts +29 -0
  60. package/dist/index.js +29 -0
  61. package/dist/layouts/layout.component.d.ts +24 -0
  62. package/dist/layouts/layout.component.js +255 -0
  63. package/dist/layouts/slot.component.d.ts +61 -0
  64. package/dist/layouts/slot.component.js +937 -0
  65. package/dist/providers.d.ts +12 -0
  66. package/dist/providers.js +18 -0
  67. package/dist/services/fylib.service.d.ts +31 -0
  68. package/dist/services/fylib.service.js +214 -0
  69. package/dist/services/notification.service.d.ts +27 -0
  70. package/dist/services/notification.service.js +118 -0
  71. package/dist/services/sse.service.d.ts +16 -0
  72. package/dist/services/sse.service.js +109 -0
  73. package/dist/services/webclient.service.d.ts +38 -0
  74. package/dist/services/webclient.service.js +144 -0
  75. 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
+ }