@v1ct0rbr/minivault-web 0.4.3 → 0.6.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/README.md CHANGED
@@ -1,75 +1,75 @@
1
- # minivault-web
2
-
3
- Módulo independente de **gestão de backups** (cliente do serviço
4
- [minivault](../minivault)). Consumível como pacote npm em qualquer app React,
5
- estilizado com Bootstrap. Comunica-se com a API REST do minivault — normalmente
6
- através de um **proxy autenticado** (ex.: `/minivault` no backend do Siga+), de
7
- modo que a `X-API-Key` do minivault jamais trafega no browser.
8
-
9
- ## Recursos
10
-
11
- - Lista de backups com paginação, status, tamanho e data.
12
- - Criação de backup (com origem de arquivos LOCAL ou S3, opcional).
13
- - Restauração de backup em um banco informado.
14
- - Importação de dump SQL em texto (`psql`/`mysql`) via upload.
15
- - Download e exclusão de backups.
16
- - Tema claro/escuro e auto-refresh.
17
-
18
- ## Instalação
19
-
20
- ```bash
21
- npm install @v1ct0rbr/minivault-web
22
- ```
23
-
24
- Como dependência local durante o desenvolvimento:
25
-
26
- ```bash
27
- npm install file:../minivault-web
28
- ```
29
-
30
- ## Uso no Siga+ (proxy autenticado)
31
-
32
- ```tsx
33
- import { MinivaultModule } from '@v1ct0rbr/minivault-web'
34
- import '@v1ct0rbr/minivault-web/style.css'
35
- import { useAuthStore } from '@/store/useAuthStore'
36
-
37
- const apiBase = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8080'
38
-
39
- export function MinivaultPage() {
40
- const getToken = () => useAuthStore.getState().token
41
- return <MinivaultModule baseUrl={apiBase + '/minivault'} getToken={getToken} />
42
- }
43
- ```
44
-
45
- ## Uso standalone (desenvolvimento)
46
-
47
- ```tsx
48
- <MinivaultModule baseUrl="http://localhost:8081" token="api-key-do-minivault" />
49
- ```
50
-
51
- > Em produção o token do minivault deve ficar apenas no proxy do backend, nunca
52
- > no bundle do frontend.
53
-
54
- ## Desenvolvimento
55
-
56
- ```bash
57
- npm install
58
- npm run dev # playground standalone (porta 5176)
59
- npm run build:lib # gera dist/ (lib ES + types)
60
- npm test # vitest
61
- npm run typecheck # tsc --noEmit
62
- ```
63
-
64
- ### Playground standalone
65
-
66
- ```bash
67
- VITE_MINIVAULT_API_URL=http://localhost:8081 VITE_MINIVAULT_API_TOKEN=chave npm run dev
68
- ```
69
-
70
- ## Publicação
71
-
72
- ```bash
73
- npm run build:lib && npm test
74
- npm publish --access public
1
+ # minivault-web
2
+
3
+ Módulo independente de **gestão de backups** (cliente do serviço
4
+ [minivault](../minivault)). Consumível como pacote npm em qualquer app React,
5
+ estilizado com Bootstrap. Comunica-se com a API REST do minivault — normalmente
6
+ através de um **proxy autenticado** (ex.: `/minivault` no backend do Siga+), de
7
+ modo que a `X-API-Key` do minivault jamais trafega no browser.
8
+
9
+ ## Recursos
10
+
11
+ - Lista de backups com paginação, status, tamanho e data.
12
+ - Criação de backup (com origem de arquivos LOCAL ou S3, opcional).
13
+ - Restauração de backup em um banco informado.
14
+ - Importação de dump SQL em texto (`psql`/`mysql`) via upload.
15
+ - Download e exclusão de backups.
16
+ - Tema claro/escuro e auto-refresh.
17
+
18
+ ## Instalação
19
+
20
+ ```bash
21
+ npm install @v1ct0rbr/minivault-web
22
+ ```
23
+
24
+ Como dependência local durante o desenvolvimento:
25
+
26
+ ```bash
27
+ npm install file:../minivault-web
28
+ ```
29
+
30
+ ## Uso no Siga+ (proxy autenticado)
31
+
32
+ ```tsx
33
+ import { MinivaultModule } from '@v1ct0rbr/minivault-web'
34
+ import '@v1ct0rbr/minivault-web/style.css'
35
+ import { useAuthStore } from '@/store/useAuthStore'
36
+
37
+ const apiBase = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8080'
38
+
39
+ export function MinivaultPage() {
40
+ const getToken = () => useAuthStore.getState().token
41
+ return <MinivaultModule baseUrl={apiBase + '/minivault'} getToken={getToken} />
42
+ }
43
+ ```
44
+
45
+ ## Uso standalone (desenvolvimento)
46
+
47
+ ```tsx
48
+ <MinivaultModule baseUrl="http://localhost:8081" token="api-key-do-minivault" />
49
+ ```
50
+
51
+ > Em produção o token do minivault deve ficar apenas no proxy do backend, nunca
52
+ > no bundle do frontend.
53
+
54
+ ## Desenvolvimento
55
+
56
+ ```bash
57
+ npm install
58
+ npm run dev # playground standalone (porta 5176)
59
+ npm run build:lib # gera dist/ (lib ES + types)
60
+ npm test # vitest
61
+ npm run typecheck # tsc --noEmit
62
+ ```
63
+
64
+ ### Playground standalone
65
+
66
+ ```bash
67
+ VITE_MINIVAULT_API_URL=http://localhost:8081 VITE_MINIVAULT_API_TOKEN=chave npm run dev
68
+ ```
69
+
70
+ ## Publicação
71
+
72
+ ```bash
73
+ npm run build:lib && npm test
74
+ npm publish --access public
75
75
  ```
@@ -1,4 +1,4 @@
1
- import { Backup, DatabaseCredentials, DbInfo, DumpOptions, ImportResult, OriginStorageConfig, PageResponse, RelationshipInfo, StorageFileItem, TableDetail, TableInfo, VerifyResult } from '../types/minivault';
1
+ import { Backup, BackupType, ConnectionCheck, DatabaseCredentials, DbInfo, DumpOptions, ImportResult, OriginStorageConfig, PageResponse, RelationshipInfo, StorageFileItem, TableDetail, TableInfo, VerifyResult } from '../types/minivault';
2
2
  export interface MinivaultApiOptions {
3
3
  /**
4
4
  * URL base da API. Exemplos:
@@ -33,7 +33,7 @@ export declare class MinivaultApi {
33
33
  private request;
34
34
  listBackups(page?: number, size?: number): Promise<PageResponse<Backup>>;
35
35
  getBackup(id: number): Promise<Backup>;
36
- createBackup(database?: DatabaseCredentials, originStorage?: OriginStorageConfig, dumpOptions?: DumpOptions): Promise<Backup>;
36
+ createBackup(database?: DatabaseCredentials, originStorage?: OriginStorageConfig, dumpOptions?: DumpOptions, backupType?: BackupType): Promise<Backup>;
37
37
  restoreBackup(id: number, database?: DatabaseCredentials, originStorage?: OriginStorageConfig): Promise<void>;
38
38
  deleteBackup(id: number): Promise<void>;
39
39
  verifyBackup(id: number): Promise<VerifyResult>;
@@ -44,6 +44,7 @@ export declare class MinivaultApi {
44
44
  listDbTables(): Promise<TableInfo[]>;
45
45
  getDbTable(ref: string): Promise<TableDetail>;
46
46
  listDbRelationships(): Promise<RelationshipInfo[]>;
47
+ getDiagnostics(): Promise<ConnectionCheck[]>;
47
48
  listStorageFiles(type: string, prefix?: string, storageConfig?: OriginStorageConfig): Promise<StorageFileItem[]>;
48
49
  downloadStorageFile(key: string, type: string, storageConfig?: OriginStorageConfig): Promise<Blob>;
49
50
  deleteStorageFile(key: string, type: string, storageConfig?: OriginStorageConfig): Promise<void>;
@@ -5,5 +5,7 @@ export interface DatabaseBannerProps {
5
5
  error?: unknown;
6
6
  /** Rótulo contextual, ex.: 'banco de origem' / 'banco de destino'. */
7
7
  label: string;
8
+ /** Modo compacto: não expõe host/porta/nome do banco nem detalhes de configuração. */
9
+ compact?: boolean;
8
10
  }
9
- export declare function DatabaseBanner({ dbInfo, isLoading, error, label }: DatabaseBannerProps): import("react").JSX.Element;
11
+ export declare function DatabaseBanner({ dbInfo, isLoading, error, label, compact }: DatabaseBannerProps): import("react").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function DiagnosticsTab(): import("react").JSX.Element;
@@ -1,10 +1,5 @@
1
1
  import { MinivaultApiProviderProps } from './MinivaultApiProvider';
2
2
  export interface MinivaultModuleProps extends Omit<MinivaultApiProviderProps, 'children'> {
3
- /**
4
- * Força o tema ('light' | 'dark'). Quando omitido, o módulo segue
5
- * automaticamente o tema do host (classe `.dark` no <html> ou
6
- * prefers-color-scheme do sistema).
7
- */
8
3
  theme?: 'light' | 'dark';
9
4
  refetchIntervalMs?: number;
10
5
  companyAcronym?: string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Aba de backup apenas de storage: envia o storage de origem (ORIGIN_STORAGE_*)
3
+ * para o storage de destino (OUTPUT_STORAGE_*). Ambos são configurados no
4
+ * servidor via variáveis de ambiente — não é necessário informar dados aqui.
5
+ */
6
+ export declare function StorageBackupTab(): import("react").JSX.Element;
@@ -1,8 +1,10 @@
1
- import { DatabaseCredentials, DumpOptions, OriginStorageConfig } from '../types/minivault';
1
+ import { BackupType, DatabaseCredentials, DumpOptions, OriginStorageConfig } from '../types/minivault';
2
2
  export declare const backupsKeys: {
3
3
  all: readonly ["minivault", "backups"];
4
4
  db: readonly ["minivault", "db"];
5
+ diagnostics: readonly ["minivault", "diagnostics"];
5
6
  };
7
+ export declare function useDiagnostics(enabled?: boolean): import('@tanstack/react-query').UseQueryResult<import('../types/minivault').ConnectionCheck[], Error>;
6
8
  export declare function useBackups(page?: number, size?: number, enabled?: boolean): import('@tanstack/react-query').UseQueryResult<import('../types/minivault').PageResponse<import('../types/minivault').Backup>, Error>;
7
9
  export declare function useDbInfo(enabled?: boolean): import('@tanstack/react-query').UseQueryResult<import('../types/minivault').DbInfo, Error>;
8
10
  export declare function useDbTables(enabled?: boolean): import('@tanstack/react-query').UseQueryResult<import('../types/minivault').TableInfo[], Error>;
@@ -12,6 +14,7 @@ export declare function useCreateBackup(): import('@tanstack/react-query').UseMu
12
14
  database?: DatabaseCredentials;
13
15
  originStorage?: OriginStorageConfig;
14
16
  dumpOptions?: DumpOptions;
17
+ backupType?: BackupType;
15
18
  }, unknown>;
16
19
  export declare function useRestoreBackup(): import('@tanstack/react-query').UseMutationResult<void, Error, {
17
20
  id: number;
package/dist/index.d.ts CHANGED
@@ -5,12 +5,14 @@ export { MinivaultApi, MinivaultApiError } from './api/MinivaultApi';
5
5
  export type { MinivaultApiOptions } from './api/MinivaultApi';
6
6
  export { BackupsTab } from './components/BackupsTab';
7
7
  export { CreateBackupTab } from './components/CreateBackupTab';
8
+ export { DiagnosticsTab } from './components/DiagnosticsTab';
8
9
  export { ImportDumpTab } from './components/ImportDumpTab';
10
+ export { StorageBackupTab } from './components/StorageBackupTab';
9
11
  export { StorageExplorerTab } from './components/StorageExplorerTab';
10
12
  export { RestoreModal } from './components/RestoreModal';
11
13
  export { CredentialsFields } from './components/CredentialsFields';
12
14
  export { DatabaseBanner } from './components/DatabaseBanner';
13
15
  export { StatusBadge } from './components/StatusBadge';
14
- export { useBackups, useCreateBackup, useRestoreBackup, useDeleteBackup, useDownloadBackup, useImportDump, useImportFromStorage, useDbInfo, useDbTables, useDbTableDetail, useDbRelationships, } from './hooks/useBackups';
16
+ export { useBackups, useCreateBackup, useRestoreBackup, useDeleteBackup, useDownloadBackup, useImportDump, useImportFromStorage, useDbInfo, useDbTables, useDbTableDetail, useDbRelationships, useDiagnostics, } from './hooks/useBackups';
15
17
  export { formatFileSize, formatDate, STATUS_LABELS, STATUS_BADGE, DATABASE_TYPE_LABELS } from './utils/format';
16
- export type { Backup, BackupRequest, BackupStatus, ColumnInfo, DatabaseCredentials, DatabaseType, DbInfo, DumpOptions, DumpFormat, ImportResult, ImportFromStorageRequest, OriginStorageConfig, PageResponse, RelationshipInfo, RestoreRequest, StorageFileItem, TableDetail, TableInfo, } from './types/minivault';
18
+ export type { Backup, BackupRequest, BackupStatus, BackupType, ColumnInfo, ConnectionCheck, DatabaseCredentials, DatabaseType, DbInfo, DumpOptions, DumpFormat, ImportResult, ImportFromStorageRequest, OriginStorageConfig, PageResponse, RelationshipInfo, RestoreRequest, StorageFileItem, TableDetail, TableInfo, VerifyResult, } from './types/minivault';