forlogic-core 2.5.2 → 2.5.4

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.
@@ -17,6 +17,7 @@ interface AuthContextType extends AuthState {
17
17
  */
18
18
  export declare const AuthProvider: React.FC<{
19
19
  children: React.ReactNode;
20
+ moduleAlias?: string;
20
21
  }>;
21
22
  /**
22
23
  * Hook para acessar informações de autenticação e gerenciar sessão
@@ -24,6 +24,11 @@ export interface EnvironmentConfig {
24
24
  scope: string;
25
25
  };
26
26
  qualiexApiUrl: string;
27
+ /**
28
+ * Base da Documents API (v4). Usada por `forlogic-core/documents` (upload/download de
29
+ * anexos de registro, files_associations). Sem barra nem `/api` no final.
30
+ */
31
+ documentsApiUrl: string;
27
32
  /**
28
33
  * Override explícito da base do ident-api. Vazio (`''`) = deriva da common-v4
29
34
  * (ver `getIdentBaseUrl`). Sem barra nem `/api` no final.
@@ -45,6 +45,8 @@ export declare const shouldUseDevTokens: () => boolean;
45
45
  export declare const isDevEnvironment: () => boolean;
46
46
  export { isDevEnv, getAppEnv, type AppEnv } from './environments';
47
47
  export declare const getQualiexApiUrl: () => string;
48
+ /** Base da Documents API v4 (anexos de registro / files_associations). */
49
+ export declare const getDocumentsApiUrl: () => string;
48
50
  /** Override explícito da base do ident-api (`''` = derivar da common-v4). */
49
51
  export declare const getIdentApiUrlOverride: () => string;
50
52
  /** Override explícito da base do login-api (`''` = derivar da common-v4). */
@@ -0,0 +1,44 @@
1
+ import { type DocumentAssociationType } from '../documentsApi';
2
+ /**
3
+ * "Quem está implementando": a QUAL registro os arquivos se vinculam. É o análogo do
4
+ * `IQexFileAssociation` do Angular — o módulo consumidor passa isto e o componente
5
+ * cuida de todo o resto (listar/subir/ver/baixar/remover) contra a Documents API.
6
+ */
7
+ export interface DocumentFileAssociation {
8
+ type: DocumentAssociationType;
9
+ associationId: string;
10
+ associationFieldId?: string;
11
+ }
12
+ export interface DocumentFileUploadProps {
13
+ association: DocumentFileAssociation;
14
+ canUpload?: boolean;
15
+ canRemove?: boolean;
16
+ canDownload?: boolean;
17
+ canView?: boolean;
18
+ /** Limite de arquivos (ex.: 1 para "evidência única"). Sem limite se omitido. */
19
+ maxFiles?: number;
20
+ /** Extensões permitidas (ex.: ['pdf','png']). Vazio = todas. */
21
+ allowedExtensions?: string[];
22
+ /** Tamanho máximo por arquivo (default 300MB, igual ao backend). */
23
+ maxSizeInBytes?: number;
24
+ disabled?: boolean;
25
+ /** Rótulo opcional exibido acima da área. */
26
+ label?: string;
27
+ /** Chamado após upload/remove com a contagem atual de anexos. */
28
+ onFilesChanged?: (count: number) => void;
29
+ className?: string;
30
+ }
31
+ /**
32
+ * `DocumentFileUpload` — gestor de anexos de registro (Documents API), equivalente React
33
+ * do `qex-file-upload` do Angular. Self-contained: recebe apenas a `association` e faz
34
+ * list/upload/view/download/remove sozinho. Compõe o `SingleFileUpload` (primitiva de UI).
35
+ *
36
+ * @example
37
+ * <DocumentFileUpload
38
+ * association={{ type: EDocumentAssociationType.Trainings, associationId: evaluationId }}
39
+ * maxFiles={1}
40
+ * allowedExtensions={['pdf','png','jpg']}
41
+ * onFilesChanged={(n) => setHasEvidence(n > 0)}
42
+ * />
43
+ */
44
+ export declare function DocumentFileUpload({ association, canUpload, canRemove, canDownload, canView, maxFiles, allowedExtensions, maxSizeInBytes, disabled, label, onFilesChanged, className, }: DocumentFileUploadProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * forlogic-core/documents — cliente da Documents API v4 para ANEXOS DE REGISTRO
3
+ * (`files_associations`: par `type` + `associationId`). É a camada de dados por trás
4
+ * do componente `DocumentFileUpload` (equivalente React do `@forlogic/qex`).
5
+ *
6
+ * NÃO cobre documento controlado (type = Docs = 17, com pasta/categoria/fluxo de
7
+ * aprovação) — para isso o app consumidor usa seu próprio DocumentUploadService.
8
+ * Aqui é só o anexo solto vinculado a um registro (type != Docs).
9
+ *
10
+ * Auth: Bearer (TokenManager) + header `un-alias` (obrigatório na stack Qualiex v4).
11
+ * Base: `getDocumentsApiUrl()` (config central por VITE_APP_ENV) + `/api/documents/v1`.
12
+ *
13
+ * Contrato derivado do backend `api/src/Documents` + paridade com o qex-file-upload
14
+ * (Angular). NÃO testado em runtime; validar contra a Documents API real antes de prod.
15
+ */
16
+ /** Subconjunto de `EAssociationType` (backend Documents) usado no front React. */
17
+ export declare const EDocumentAssociationType: {
18
+ /** Documento controlado (pasta/categoria/fluxo) — NÃO tratado por este cliente. */
19
+ readonly Docs: 17;
20
+ /** Anexo de registro do módulo Treinamentos. */
21
+ readonly Trainings: 19;
22
+ };
23
+ export type DocumentAssociationType = (typeof EDocumentAssociationType)[keyof typeof EDocumentAssociationType];
24
+ /** Link SAS temporário devolvido pelo Download (`QueryResult<FileLink>`, onlyOne). */
25
+ export interface DocumentFileLink {
26
+ code: string;
27
+ revisionId: string;
28
+ revisionName: string;
29
+ name: string;
30
+ extension: string;
31
+ url: string;
32
+ }
33
+ /** Referência de um arquivo associado (lista). */
34
+ export interface DocumentFileRef {
35
+ /** Id do arquivo (usado no Download). */
36
+ id: string;
37
+ name: string;
38
+ extension: string;
39
+ size?: number;
40
+ /**
41
+ * Id da linha `files_associations` (o vínculo arquivo↔registro) — é o que o
42
+ * DELETE `/files/associations` espera (`filesAssociationsIds`), NÃO o id do arquivo.
43
+ */
44
+ associationRowId?: string;
45
+ }
46
+ /** Resultado do upload (`resultData` do CommandResult). */
47
+ export interface DocumentUploadResult {
48
+ id: string;
49
+ code?: string;
50
+ size?: number;
51
+ }
52
+ export declare const documentsFilesApi: {
53
+ /**
54
+ * Sobe um anexo vinculado a um registro. Multipart com duas chaves: `command`
55
+ * (JSON) e o arquivo (chave = nome do arquivo). Devolve `{ id }` (resultData.id).
56
+ */
57
+ upload(associationType: DocumentAssociationType, associationId: string, file: File, associationFieldId?: string): Promise<DocumentUploadResult>;
58
+ /** URL SAS temporária para abrir/baixar o arquivo (null se falhar). */
59
+ downloadUrl(fileId: string, minutesToExpire?: number): Promise<string | null>;
60
+ /** Lista os anexos ativos de um registro (id do arquivo + nome + id da associação). */
61
+ listByAssociation(associationType: DocumentAssociationType, associationId: string, associationFieldId?: string): Promise<DocumentFileRef[]>;
62
+ /**
63
+ * Remove o VÍNCULO arquivo↔registro (não apaga o arquivo, que pode estar associado a
64
+ * outros registros). `associationRowId` vem do `listByAssociation`.
65
+ */
66
+ remove(associationRowId: string, justification?: string): Promise<boolean>;
67
+ /** Conta os anexos de um registro (badge "tem N anexos"). */
68
+ count(associationType: DocumentAssociationType, associationId: string, associationFieldId?: string): Promise<number>;
69
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * forlogic-core/documents — anexos de registro (Documents API v4).
3
+ *
4
+ * - `documentsFilesApi` — cliente HTTP (upload/download/list/count/remove).
5
+ * - `DocumentFileUpload` — componente self-contained (equivalente React do qex-file-upload):
6
+ * recebe a `association` e cuida de listar/subir/ver/baixar/remover sozinho.
7
+ *
8
+ * Reexportado no barrel principal (`forlogic-core`) — usa TokenManager/config do próprio
9
+ * barrel, sem duplicação. NÃO cobre documento controlado (type=Docs=17).
10
+ */
11
+ export { documentsFilesApi, EDocumentAssociationType, type DocumentAssociationType, type DocumentFileLink, type DocumentFileRef, type DocumentUploadResult, } from './documentsApi';
12
+ export { DocumentFileUpload, type DocumentFileUploadProps, type DocumentFileAssociation, } from './components/DocumentFileUpload';
package/dist/index.d.ts CHANGED
@@ -105,6 +105,7 @@ export * from './components/modules';
105
105
  export * from './media';
106
106
  export * from './updates';
107
107
  export * from './file-upload';
108
+ export { documentsFilesApi, EDocumentAssociationType, DocumentFileUpload, type DocumentAssociationType, type DocumentFileLink, type DocumentFileRef, type DocumentUploadResult, type DocumentFileUploadProps, type DocumentFileAssociation, } from './documents';
108
109
  export * from './custom-form-fields';
109
110
  export * from './approval-flow';
110
111
  export * from './team-selector';