@praxisui/files-upload 1.0.0-beta.61 → 1.0.0-beta.64

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 CHANGED
@@ -41,14 +41,19 @@ last_updated: "2026-03-07"
41
41
 
42
42
  # Praxis Files Upload
43
43
 
44
- ## 🔰 Exemplos / Quickstart
44
+ Components and services for integrating file uploads with the Praxis backend. Configuration is provided as JSON and can be edited at runtime through the Settings Panel.
45
45
 
46
- Para ver esta biblioteca em funcionamento em uma aplicação completa, utilize o projeto de exemplo (Quickstart):
46
+ ## Documentation
47
47
 
48
- - Repositório: https://github.com/codexrodrigues/praxis-ui-quickstart
49
- - O Quickstart demonstra a integração das bibliotecas `@praxisui/*` em um app Angular, incluindo instalação, configuração e uso em telas reais.
48
+ - Official documentation: https://praxisui.dev
49
+ - Quickstart reference app: https://github.com/codexrodrigues/praxis-ui-quickstart
50
+ - Recommended for: enterprise upload flows with direct upload, presigned URLs, quotas and operational feedback
50
51
 
51
- Components and services for integrating file uploads with the Praxis backend. Configuration is provided as JSON and can be edited at runtime through the Settings Panel.
52
+ ## When to use
53
+
54
+ - Implement file upload with operational feedback and quota-aware UX
55
+ - Support direct and presigned upload strategies from the same component set
56
+ - Keep upload configuration editable at runtime in Praxis-based hosts
52
57
 
53
58
  ## Component Overview
54
59
 
@@ -62,14 +67,104 @@ Inputs
62
67
  - `displayMode: 'full' | 'compact'` Controls UI density and overlays (default: `full`).
63
68
 
64
69
  Outputs
65
- - `uploadSuccess: { file: FileMetadata }` Emitted per successful single upload.
66
- - `bulkComplete: BulkUploadResponse` Summary for batch uploads.
70
+ - `uploadSuccess: FileMetadata` Emitted per successful single upload.
71
+ - `bulkComplete: BulkUploadResponseData` Summary payload for batch uploads.
67
72
  - `error: ErrorResponse` Error information for failed requests.
68
73
  - `rateLimited: RateLimitInfo` Emits when 429 is detected (with reset hints).
69
74
  - `retry | download | copyLink | detailsOpened | detailsClosed: BulkUploadFileResult` Advanced list actions.
70
- - `pendingFilesChange: File[]` Current selected (pending) files.
75
+ - `pendingStateChange: PendingFilesState` Current manual-selection state (`files`, `count`, `hasPending`).
71
76
  - `proximityChange: boolean` Proximity overlay visibility toggles.
72
77
 
78
+ ## Backend Contract
79
+
80
+ `@praxisui/files-upload` consome o contrato final do backend Praxis sem camadas de compatibilidade.
81
+
82
+ Success envelope:
83
+
84
+ ```json
85
+ {
86
+ "status": "success",
87
+ "message": "Upload realizado com sucesso",
88
+ "timestamp": "2026-03-15T11:00:00Z",
89
+ "data": {
90
+ "originalFilename": "contract.pdf",
91
+ "serverFilename": "stored-contract.pdf",
92
+ "fileId": "f-123",
93
+ "fileSize": 1024,
94
+ "mimeType": "application/pdf",
95
+ "uploadTimestamp": "2026-03-15T11:00:00Z"
96
+ }
97
+ }
98
+ ```
99
+
100
+ Bulk success and partial success:
101
+
102
+ ```json
103
+ {
104
+ "status": "partial_success",
105
+ "message": "Upload em lote processado com sucesso parcial",
106
+ "timestamp": "2026-03-15T11:00:00Z",
107
+ "data": {
108
+ "totalProcessed": 2,
109
+ "totalSuccess": 1,
110
+ "totalFailed": 1,
111
+ "overallSuccess": false,
112
+ "results": [
113
+ {
114
+ "fileName": "ok.pdf",
115
+ "status": "SUCCESS",
116
+ "file": {
117
+ "id": "f-123",
118
+ "fileName": "ok.pdf",
119
+ "contentType": "application/pdf",
120
+ "fileSize": 1024,
121
+ "uploadedAt": "2026-03-15T11:00:00Z",
122
+ "tenantId": "tenant-a",
123
+ "scanStatus": "PENDING"
124
+ }
125
+ },
126
+ {
127
+ "fileName": "bad.exe",
128
+ "status": "FAILED",
129
+ "error": {
130
+ "status": "failure",
131
+ "message": "Falha de validacao",
132
+ "errors": [
133
+ {
134
+ "code": "TIPO_ARQUIVO_INVALIDO",
135
+ "message": "Tipo de arquivo invalido."
136
+ }
137
+ ],
138
+ "traceId": "trace-1"
139
+ }
140
+ }
141
+ ]
142
+ }
143
+ }
144
+ ```
145
+
146
+ Error envelope:
147
+
148
+ ```json
149
+ {
150
+ "status": "failure",
151
+ "message": "Falha de validacao",
152
+ "errors": [
153
+ {
154
+ "code": "QUOTA_EXCEEDED",
155
+ "message": "Quota reached."
156
+ }
157
+ ],
158
+ "timestamp": "2026-03-15T11:00:00Z",
159
+ "traceId": "trace-1"
160
+ }
161
+ ```
162
+
163
+ Leituras feitas pelo componente:
164
+ - upload simples: `data`
165
+ - upload em lote: `data.results`
166
+ - erro: `errors[0]`
167
+
73
168
  ## Components
74
169
 
75
170
  ### `PraxisFilesUpload`
@@ -89,25 +184,39 @@ export class DemoComponent {
89
184
  ui: { showDropzone: true },
90
185
  };
91
186
 
92
- onSuccess(event: { file: FileMetadata }) {
93
- console.log("uploaded", event.file);
187
+ onSuccess(file: FileMetadata) {
188
+ console.log("uploaded", file);
94
189
  }
95
190
  }
96
191
  ```
97
192
 
98
193
  ### `PdxFilesUploadFieldComponent`
99
194
 
100
- Wrapper for dynamic forms that implements `ControlValueAccessor` and emits either file metadata or the uploaded id according to the configured `valueMode`.
195
+ Wrapper for dynamic forms that implements `ControlValueAccessor` and resolves the field value according to the configured `valueMode`.
101
196
 
102
197
  ```ts
103
198
  <form [formGroup]="form">
104
- <pdx-material-files-upload formControlName="attachment" />
199
+ <pdx-material-files-upload
200
+ formControlName="attachment"
201
+ valueMode="metadata[]"
202
+ />
105
203
  </form>
106
204
  ```
107
205
 
206
+ Array modes keep a stable shape in both single and bulk uploads:
207
+ - `metadata[]` always resolves to `FileMetadata[]`
208
+ - `id[]` always resolves to `string[]`
209
+
108
210
  ## Configuration options
109
211
 
110
- The editor allows adjusting UI behavior, bulk parameters, limits, quotas, rate limit handling, headers and messages for individual error codes.
212
+ The editor allows adjusting the config in separated responsibility groups:
213
+
214
+ - `ui`: visual presentation and interaction only
215
+ - `limits`: client-side validation and local flow guards
216
+ - `options`: backend-facing upload options serialized into the request
217
+ - `bulk`: execution policy such as retries and parallelism
218
+ - `quotas`, `rateLimit`, `messages`: feedback and UX behavior
219
+ - `headers`: host-specific contextual header naming
111
220
 
112
221
  - `strategy`: `direct` | `presign` | `auto` — `auto` tenta upload pré-assinado e recorre ao modo direto se a etapa de presign falhar.
113
222
 
@@ -132,7 +241,7 @@ Client-side constraints can be enforced via `config` and validated by built-in v
132
241
 
133
242
  - Types: `ui.accept: string[]` (e.g., `['image/png','application/pdf']`)
134
243
  - Extensions/MIME: `options.allowedExtensions`, `options.acceptMimeTypes`
135
- - Size per file: `limits.maxFileSizeBytes` (bytes) or `limits.maxUploadSizeMb`
244
+ - Size per file: `limits.maxFileSizeBytes` (bytes) or `options.maxUploadSizeMb`
136
245
  - Count per batch: `limits.maxFilesPerBulk`
137
246
  - Total size per batch: `limits.maxBulkSizeBytes`
138
247
 
@@ -161,7 +270,7 @@ const cfg: FilesUploadConfig = {
161
270
 
162
271
  ## Error handling
163
272
 
164
- `ErrorMapperService` translates backend `ErrorCode` values into user-facing messages and exposes rate limit information.
273
+ `ErrorMapperService` translates backend error codes from `errors[0]` into user-facing messages and exposes rate limit information.
165
274
 
166
275
  Default messages are provided in Portuguese but can be overridden globally by
167
276
  providing the `FILES_UPLOAD_ERROR_MESSAGES` injection token:
@@ -176,36 +285,26 @@ The configuration editor stores settings in `ASYNC_CONFIG_STORAGE`, using the ke
176
285
 
177
286
  ## Internationalização
178
287
 
179
- Todas as mensagens do componente são fornecidas em Português Brasileiro. Para cenários multilíngues, o componente integra-se opcionalmente ao `@ngx-translate/core` e expõe um conjunto de chaves `praxis.filesUpload.*`.
288
+ `@praxisui/files-upload` usa a infraestrutura oficial de i18n do `@praxisui/core`.
180
289
 
181
- As traduções padrão podem ser registradas com o objeto `FILES_UPLOAD_PT_BR`:
290
+ As chaves internas da lib vivem no namespace `praxis.filesUpload.*` e podem ser registradas com `providePraxisFilesUploadI18n(...)`:
182
291
 
183
292
  ```ts
184
- import { TranslateService } from '@ngx-translate/core';
185
- import { FILES_UPLOAD_PT_BR } from '@praxisui/files-upload';
186
-
187
- constructor(private translate: TranslateService) {
188
- translate.setTranslation('pt-BR', FILES_UPLOAD_PT_BR, true);
189
- }
190
- ```
191
-
192
- Se nenhuma tradução estiver disponível, o componente utiliza o token `FILES_UPLOAD_TEXTS` como fallback. Para sobrescrever os textos manualmente:
193
-
194
- ```ts
195
- import { FILES_UPLOAD_TEXTS } from "@praxisui/files-upload";
293
+ import { providePraxisFilesUploadI18n } from '@praxisui/files-upload';
196
294
 
197
295
  providers: [
198
- {
199
- provide: FILES_UPLOAD_TEXTS,
200
- useValue: {
201
- settingsAriaLabel: "Open settings",
202
- dropzoneLabel: "Drag files here or",
203
- dropzoneButton: "select",
204
- conflictPolicyLabel: "Conflict policy",
205
- metadataLabel: "Metadata (JSON)",
206
- progressAriaLabel: "Upload progress",
207
- rateLimitBanner: "Rate limit exceeded. Try again at",
296
+ providePraxisFilesUploadI18n({
297
+ locale: 'en-US',
298
+ fallbackLocale: 'pt-BR',
299
+ dictionaries: {
300
+ 'en-US': {
301
+ 'praxis.filesUpload.dropzoneLabel': 'Drag files or',
302
+ },
208
303
  },
209
- },
304
+ }),
210
305
  ];
211
306
  ```
307
+
308
+ O caminho recomendado para hosts e libs consumidoras e usar esse provider ou a infraestrutura compartilhada do `PraxisI18nService`.
309
+
310
+ `FILES_UPLOAD_TEXTS` e `TRANSLATE_LIKE` permanecem exportados apenas como camada transitoria de compatibilidade. Quando usados, eles funcionam como fallback para chaves planas da lib, inclusive chaves novas como `fieldPendingSummary` e overrides legados baseados em `instant(...)` ou `t(...)`. Novo codigo nao deve depender desses tokens, e eles devem ser tratados como legado/deprecado.