@praxisui/core 0.0.1 → 1.0.0-beta.3
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/README.md +33 -21
- package/fesm2022/praxisui-core.mjs +29 -6
- package/fesm2022/praxisui-core.mjs.map +1 -1
- package/package.json +12 -1
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @praxisui/core
|
|
2
2
|
|
|
3
3
|
> Biblioteca central com interfaces e serviços fundamentais para o Praxis UI Workspace
|
|
4
4
|
|
|
5
5
|
## 🌟 Visão Geral
|
|
6
6
|
|
|
7
|
-
A biblioteca `@
|
|
7
|
+
A biblioteca `@praxisui/core` é o núcleo do Praxis UI Workspace, fornecendo interfaces robustas, serviços base e utilitários essenciais para todas as outras bibliotecas do ecossistema. Com a arquitetura unificada, oferece uma experiência de desenvolvimento consistente e type-safe.
|
|
8
8
|
|
|
9
9
|
### Concept Usage
|
|
10
10
|
|
|
11
|
-
- [Dynamic Component Rendering](
|
|
12
|
-
- [Headless UI & Design Systems](
|
|
13
|
-
- [Configuration‑driven development](
|
|
14
|
-
- [Declarative UI](
|
|
11
|
+
- [Dynamic Component Rendering](https://github.com/codexrodrigues/praxis/blob/main/docs/concepts/dynamic-component-rendering.md)
|
|
12
|
+
- [Headless UI & Design Systems](https://github.com/codexrodrigues/praxis/blob/main/docs/concepts/headless-ui-and-design-systems.md)
|
|
13
|
+
- [Configuration‑driven development](https://github.com/codexrodrigues/praxis/blob/main/docs/concepts/configuration-driven-development.md)
|
|
14
|
+
- [Declarative UI](https://github.com/codexrodrigues/praxis/blob/main/docs/concepts/declarative-ui.md)
|
|
15
15
|
|
|
16
16
|
## ✨ Características Principais
|
|
17
17
|
|
|
@@ -32,7 +32,7 @@ A biblioteca `@praxis/core` é o núcleo do Praxis UI Workspace, fornecendo inte
|
|
|
32
32
|
## 🚀 Instalação
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
npm install @
|
|
35
|
+
npm install @praxisui/core
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
### Peer dependencies (Angular v20)
|
|
@@ -48,7 +48,7 @@ npm install @praxis/core
|
|
|
48
48
|
```ts
|
|
49
49
|
import { Component } from '@angular/core';
|
|
50
50
|
import { MatIconModule } from '@angular/material/icon';
|
|
51
|
-
import { PraxisIconDirective } from '@
|
|
51
|
+
import { PraxisIconDirective } from '@praxisui/core';
|
|
52
52
|
|
|
53
53
|
@Component({
|
|
54
54
|
selector: 'app-icons-demo',
|
|
@@ -68,7 +68,7 @@ export class IconsDemoComponent {}
|
|
|
68
68
|
|
|
69
69
|
```ts
|
|
70
70
|
import { Component } from '@angular/core';
|
|
71
|
-
import { DynamicGridPageComponent, GridPageDefinition } from '@
|
|
71
|
+
import { DynamicGridPageComponent, GridPageDefinition } from '@praxisui/core';
|
|
72
72
|
|
|
73
73
|
@Component({
|
|
74
74
|
selector: 'app-grid-demo',
|
|
@@ -101,11 +101,23 @@ Observação: os IDs de widgets usados na página devem estar registrados via `C
|
|
|
101
101
|
|
|
102
102
|
## 📚 API Surface
|
|
103
103
|
|
|
104
|
-
- Exports públicos: consulte
|
|
104
|
+
- Exports públicos: consulte o arquivo
|
|
105
|
+
[`public-api.ts`](https://github.com/codexrodrigues/praxis/blob/main/frontend-libs/praxis-ui-workspace/projects/praxis-core/src/public-api.ts)
|
|
106
|
+
para a lista consolidada de serviços, tokens, modelos e utilitários disponíveis para importação.
|
|
105
107
|
|
|
106
108
|
## 🧩 Compatibilidade
|
|
107
109
|
|
|
108
|
-
- `@
|
|
110
|
+
- `@praxisui/core` `1.0.0-beta.x` → Angular `20.x`
|
|
111
|
+
|
|
112
|
+
## 📦 Publicação
|
|
113
|
+
|
|
114
|
+
- Pacote ESM, gerado via `ng-packagr`.
|
|
115
|
+
- Licença: Apache-2.0 (incluída no pacote).
|
|
116
|
+
- Repositório e issues: [GitHub](https://github.com/codexrodrigues/praxis).
|
|
117
|
+
|
|
118
|
+
## 📄 Licença
|
|
119
|
+
|
|
120
|
+
Apache-2.0 — veja o arquivo `LICENSE` incluído no pacote.
|
|
109
121
|
- Module format: `ESM2022`
|
|
110
122
|
|
|
111
123
|
## 📝 Interfaces Principais
|
|
@@ -485,7 +497,7 @@ class TableConfigService {
|
|
|
485
497
|
### Exemplo de Uso do Serviço
|
|
486
498
|
|
|
487
499
|
```typescript
|
|
488
|
-
import { TableConfigService } from '@
|
|
500
|
+
import { TableConfigService } from '@praxisui/core';
|
|
489
501
|
|
|
490
502
|
@Component({...})
|
|
491
503
|
export class MyComponent {
|
|
@@ -512,7 +524,7 @@ export class MyComponent {
|
|
|
512
524
|
### Configuração Padrão
|
|
513
525
|
|
|
514
526
|
```typescript
|
|
515
|
-
import { createDefaultTableConfig } from "@
|
|
527
|
+
import { createDefaultTableConfig } from "@praxisui/core";
|
|
516
528
|
|
|
517
529
|
// Criar configuração padrão
|
|
518
530
|
const defaultConfig = createDefaultTableConfig();
|
|
@@ -529,7 +541,7 @@ console.log(defaultConfig);
|
|
|
529
541
|
### Validação
|
|
530
542
|
|
|
531
543
|
```typescript
|
|
532
|
-
import { isValidTableConfig, isTableConfigV2 } from '@
|
|
544
|
+
import { isValidTableConfig, isTableConfigV2 } from '@praxisui/core';
|
|
533
545
|
|
|
534
546
|
// Validar configuração
|
|
535
547
|
const config = { columns: [...] };
|
|
@@ -546,7 +558,7 @@ if (isTableConfigV2(config)) {
|
|
|
546
558
|
### Manipulação de Configurações
|
|
547
559
|
|
|
548
560
|
```typescript
|
|
549
|
-
import { cloneTableConfig, mergeTableConfigs, getEssentialConfig } from "@
|
|
561
|
+
import { cloneTableConfig, mergeTableConfigs, getEssentialConfig } from "@praxisui/core";
|
|
550
562
|
|
|
551
563
|
// Clonar configuração
|
|
552
564
|
const clonedConfig = cloneTableConfig(originalConfig);
|
|
@@ -590,13 +602,13 @@ function mergeTableConfigs(base: TableConfig, override: Partial<TableConfig>): T
|
|
|
590
602
|
function getEssentialConfig(config: TableConfig): Partial<TableConfig>;
|
|
591
603
|
```
|
|
592
604
|
|
|
593
|
-
## 🧪 Testando com @
|
|
605
|
+
## 🧪 Testando com @praxisui/core
|
|
594
606
|
|
|
595
607
|
### Setup de Testes
|
|
596
608
|
|
|
597
609
|
```typescript
|
|
598
610
|
import { TestBed } from "@angular/core/testing";
|
|
599
|
-
import { TableConfigService } from "@
|
|
611
|
+
import { TableConfigService } from "@praxisui/core";
|
|
600
612
|
|
|
601
613
|
describe("TableConfigService", () => {
|
|
602
614
|
let service: TableConfigService;
|
|
@@ -626,7 +638,7 @@ describe("TableConfigService", () => {
|
|
|
626
638
|
### Testes de Helper Functions
|
|
627
639
|
|
|
628
640
|
```typescript
|
|
629
|
-
import { createDefaultTableConfig, isValidTableConfig, cloneTableConfig } from "@
|
|
641
|
+
import { createDefaultTableConfig, isValidTableConfig, cloneTableConfig } from "@praxisui/core";
|
|
630
642
|
|
|
631
643
|
describe("Helper Functions", () => {
|
|
632
644
|
it("should create valid default config", () => {
|
|
@@ -657,17 +669,17 @@ describe("Helper Functions", () => {
|
|
|
657
669
|
|
|
658
670
|
```typescript
|
|
659
671
|
// Antes
|
|
660
|
-
import { TableConfigV1, TableConfigV2, TableConfigUnified } from "@
|
|
672
|
+
import { TableConfigV1, TableConfigV2, TableConfigUnified } from "@praxisui/core";
|
|
661
673
|
|
|
662
674
|
// Depois
|
|
663
|
-
import { TableConfig } from "@
|
|
675
|
+
import { TableConfig } from "@praxisui/core";
|
|
664
676
|
```
|
|
665
677
|
|
|
666
678
|
2. **Serviços Simplificados**:
|
|
667
679
|
|
|
668
680
|
```typescript
|
|
669
681
|
// Antes
|
|
670
|
-
import { TableConfigAdapterService, TableConfigMigrationService } from "@
|
|
682
|
+
import { TableConfigAdapterService, TableConfigMigrationService } from "@praxisui/core";
|
|
671
683
|
|
|
672
684
|
// Depois
|
|
673
685
|
import { TableConfigService } from "@praxisui/core";
|
|
@@ -1004,7 +1004,7 @@ class GenericCrudService {
|
|
|
1004
1004
|
}
|
|
1005
1005
|
resource = resource.replace(/^\/+/, '');
|
|
1006
1006
|
// Normalize known suffixes accidentally passed as part of the resource path
|
|
1007
|
-
// Avoid cases like "
|
|
1007
|
+
// Avoid cases like "module/items/filter" which would lead to duplicate suffixes (e.g., "/filter/filter")
|
|
1008
1008
|
resource = resource.replace(/\/(?:filter|all)(?:\/?$)/i, '');
|
|
1009
1009
|
// Remove duplicated `api` segments only if base URL already contains `/api`
|
|
1010
1010
|
try {
|
|
@@ -1115,13 +1115,16 @@ class GenericCrudService {
|
|
|
1115
1115
|
.set('schemaType', schemaType);
|
|
1116
1116
|
// Resolve schemas/filtered honoring relative base (dev proxy) when applicable
|
|
1117
1117
|
let filteredUrl = '/schemas/filtered';
|
|
1118
|
+
let apiOrigin = '';
|
|
1118
1119
|
try {
|
|
1119
1120
|
const baseUrl = buildApiUrl(entry);
|
|
1120
1121
|
const u = new URL(baseUrl);
|
|
1121
|
-
|
|
1122
|
+
apiOrigin = u.origin;
|
|
1123
|
+
filteredUrl = `${apiOrigin}/schemas/filtered`;
|
|
1122
1124
|
}
|
|
1123
1125
|
catch { }
|
|
1124
|
-
|
|
1126
|
+
// Build cache key including the API origin (not the app origin)
|
|
1127
|
+
const schemaId = buildSchemaId({ path, operation, schemaType, includeInternalSchemas: false, tenant, locale, apiOrigin });
|
|
1125
1128
|
const headersBase = composeHeadersWithVersion(entry);
|
|
1126
1129
|
return from(this._schemaCache.get(schemaId)).pipe(concatMap((cached) => {
|
|
1127
1130
|
let headers = headersBase;
|
|
@@ -1167,6 +1170,11 @@ class GenericCrudService {
|
|
|
1167
1170
|
h = h.set('Accept-Language', locale);
|
|
1168
1171
|
if (tenant)
|
|
1169
1172
|
h = h.set('X-Tenant', tenant);
|
|
1173
|
+
// Force a fresh response to avoid intermediary caches when refetching
|
|
1174
|
+
try {
|
|
1175
|
+
h = h.set('Cache-Control', 'no-cache, no-store, max-age=0').set('Pragma', 'no-cache');
|
|
1176
|
+
}
|
|
1177
|
+
catch { }
|
|
1170
1178
|
return this.http.get(filteredUrl, { params: httpParams, headers: h }).pipe(tap((fresh) => {
|
|
1171
1179
|
const now = new Date().toISOString();
|
|
1172
1180
|
const entry = {
|
|
@@ -1179,7 +1187,7 @@ class GenericCrudService {
|
|
|
1179
1187
|
updatedAt: now,
|
|
1180
1188
|
resourcePath: this.resourcePath,
|
|
1181
1189
|
schemaId,
|
|
1182
|
-
apiOrigin
|
|
1190
|
+
apiOrigin,
|
|
1183
1191
|
},
|
|
1184
1192
|
};
|
|
1185
1193
|
this._schemaCache.set(schemaId, entry);
|
|
@@ -1198,7 +1206,7 @@ class GenericCrudService {
|
|
|
1198
1206
|
catch { }
|
|
1199
1207
|
this._schemaCache.set(schemaId, { schema: body, schemaHash, meta: {
|
|
1200
1208
|
version: '2.0.0', name: 'Grid/Response Schema', createdAt: nowIso, updatedAt: nowIso,
|
|
1201
|
-
resourcePath: this.resourcePath, idField: idFieldFromBody, schemaId, apiOrigin
|
|
1209
|
+
resourcePath: this.resourcePath, idField: idFieldFromBody, schemaId, apiOrigin,
|
|
1202
1210
|
} });
|
|
1203
1211
|
this._lastSchemaInfo = { schemaId, schemaHash };
|
|
1204
1212
|
// Extrai idField de x-ui.resource quando presente no body recebido
|
|
@@ -1231,6 +1239,11 @@ class GenericCrudService {
|
|
|
1231
1239
|
h = h.set('Accept-Language', locale);
|
|
1232
1240
|
if (tenant)
|
|
1233
1241
|
h = h.set('X-Tenant', tenant);
|
|
1242
|
+
// Force a fresh response to avoid intermediary caches when refetching
|
|
1243
|
+
try {
|
|
1244
|
+
h = h.set('Cache-Control', 'no-cache, no-store, max-age=0').set('Pragma', 'no-cache');
|
|
1245
|
+
}
|
|
1246
|
+
catch { }
|
|
1234
1247
|
return this.http
|
|
1235
1248
|
.get(filteredUrl, { params: httpParams, headers: h })
|
|
1236
1249
|
.pipe(tap((fresh) => {
|
|
@@ -1245,7 +1258,7 @@ class GenericCrudService {
|
|
|
1245
1258
|
updatedAt: now,
|
|
1246
1259
|
resourcePath: this.resourcePath,
|
|
1247
1260
|
schemaId,
|
|
1248
|
-
apiOrigin
|
|
1261
|
+
apiOrigin,
|
|
1249
1262
|
},
|
|
1250
1263
|
};
|
|
1251
1264
|
this._schemaCache.set(schemaId, entry);
|
|
@@ -1386,6 +1399,11 @@ class GenericCrudService {
|
|
|
1386
1399
|
h = h.set('Accept-Language', locale);
|
|
1387
1400
|
if (tenant)
|
|
1388
1401
|
h = h.set('X-Tenant', tenant);
|
|
1402
|
+
// Force a fresh response to avoid intermediary caches when refetching
|
|
1403
|
+
try {
|
|
1404
|
+
h = h.set('Cache-Control', 'no-cache, no-store, max-age=0').set('Pragma', 'no-cache');
|
|
1405
|
+
}
|
|
1406
|
+
catch { }
|
|
1389
1407
|
return this.http.get(url, { params: httpParams, headers: h }).pipe(tap((fresh) => {
|
|
1390
1408
|
const now = new Date().toISOString();
|
|
1391
1409
|
const entry = {
|
|
@@ -1437,6 +1455,11 @@ class GenericCrudService {
|
|
|
1437
1455
|
h = h.set('Accept-Language', locale);
|
|
1438
1456
|
if (tenant)
|
|
1439
1457
|
h = h.set('X-Tenant', tenant);
|
|
1458
|
+
// Force a fresh response to avoid intermediary caches when refetching
|
|
1459
|
+
try {
|
|
1460
|
+
h = h.set('Cache-Control', 'no-cache, no-store, max-age=0').set('Pragma', 'no-cache');
|
|
1461
|
+
}
|
|
1462
|
+
catch { }
|
|
1440
1463
|
return this.http.get(url, { params: httpParams, headers: h }).pipe(tap((fresh) => {
|
|
1441
1464
|
const now = new Date().toISOString();
|
|
1442
1465
|
const entry = { schema: fresh, schemaHash: '', meta: { version: '2.0.0', name: (schemaTypeParam === 'request' ? 'Filter/Request Schema' : 'Schema'), createdAt: now, updatedAt: now, resourcePath: this.resourcePath, schemaId, apiOrigin: origin } };
|