@seedgrid/fe-audit 2026.7.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 ADDED
@@ -0,0 +1,71 @@
1
+ # @seedgrid/fe-audit
2
+
3
+ [![npm version](https://img.shields.io/npm/v/%40seedgrid%2Ffe-audit)](https://www.npmjs.com/package/@seedgrid/fe-audit)
4
+ [![npm downloads](https://img.shields.io/npm/dm/%40seedgrid%2Ffe-audit)](https://www.npmjs.com/package/@seedgrid/fe-audit)
5
+ [![TypeScript](https://img.shields.io/badge/types-TypeScript-blue)](https://www.typescriptlang.org/)
6
+
7
+ Módulo front de **auditoria** do SeedGrid: consulta do trilho de auditoria (audit log) com filtros ricos e detalhe com estado antes/depois para diff. Compõe sobre o motor de sessão do [`@seedgrid/fe-security`](https://www.npmjs.com/package/@seedgrid/fe-security).
8
+
9
+ ## Sumário
10
+
11
+ - [Funcionalidades](#funcionalidades)
12
+ - [Tela de busca](#tela-de-busca)
13
+ - [Instalação](#instalação)
14
+ - [Uso rápido](#uso-rápido)
15
+ - [Backend correspondente](#backend-correspondente)
16
+ - [Suporte](#suporte)
17
+
18
+ ## Funcionalidades
19
+
20
+ - **Listagem paginada de logs** com filtros: entidade, operação (`CREATE`/`UPDATE`/`DELETE`/`READ`/`OTHER`), usuário, faixa de datas, faixa de ids, descrição e metadados (`metaKey`/`metaValue`).
21
+ - **Combos de filtro dinâmicos** — endpoints de entidades distintas e usuários distintos alimentam os selects da tela.
22
+ - **Detalhe do registro** — cada `AuditLogEntry` traz `beforeState`/`afterState` (JSON serializado) para renderizar o diff da alteração, além de origem, IP, user-agent e operação técnica.
23
+
24
+ O pacote exporta:
25
+
26
+ - `AuditPaths` — contrato dos endpoints REST (`/audit-logs`, `/audit-logs/entities`, `/audit-logs/users`, `/audit-logs/{id}`).
27
+ - DTOs client-safe: `AuditLogEntry`, `AuditLogFilters`, `AuditLogEntityOption`, `AuditLogUserOption`, `AuditOperation`.
28
+ - `createAuditServer` (em `@seedgrid/fe-audit/server`, SERVER-ONLY) — engine tipado de consulta sobre a sessão do fe-security.
29
+
30
+ ## Tela de busca
31
+
32
+ A tela de busca de auditoria é **scaffold** (o app é dono do código) e é entregue pelo SeedGrid CLI ao adicionar o módulo (`module.json`: `id: "audit"`, `requires: ["security"]`): grid paginado com os filtros acima e painel de detalhe com o diff antes/depois.
33
+
34
+ ## Instalação
35
+
36
+ ```bash
37
+ pnpm add @seedgrid/fe-audit @seedgrid/fe-security @seedgrid/fe-core
38
+ ```
39
+
40
+ ## Uso rápido
41
+
42
+ ```ts
43
+ // server-only — compõe sobre a sessão do fe-security
44
+ import { createSecurityServer } from "@seedgrid/fe-security/server";
45
+ import { createAuditServer } from "@seedgrid/fe-audit/server";
46
+
47
+ const session = createSecurityServer({ /* ... */ });
48
+ export const audit = createAuditServer(session);
49
+
50
+ // Em uma rota/action:
51
+ const page = await audit.searchLogs({
52
+ entity: "User",
53
+ operation: "UPDATE",
54
+ operationDateFrom: "2026-07-01",
55
+ page: 0,
56
+ size: 20,
57
+ });
58
+ ```
59
+
60
+ ## Backend correspondente
61
+
62
+ Audit Log Controller do `seedgrid-report-api` (motor de auditoria da lib `seedgrid-quarkus-lib-audit`). `AuditPaths` é o contrato único front/back.
63
+
64
+ ## Suporte
65
+
66
+ - Issues: https://github.com/SeedGrid/seedgrid-fe-components/issues
67
+ - Repositório: https://github.com/SeedGrid/seedgrid-fe-components
68
+
69
+ ## Licença
70
+
71
+ MIT
@@ -0,0 +1,48 @@
1
+ /** Operações auditadas (AuditOperationEnum). */
2
+ export type AuditOperation = "CREATE" | "UPDATE" | "DELETE" | "READ" | "OTHER";
3
+ /** Registro de auditoria (schema AuditLog). */
4
+ export interface AuditLogEntry {
5
+ id: number;
6
+ entity: string;
7
+ /** AuditOperationEnum; `string` tolera valores futuros. */
8
+ operation: AuditOperation | string;
9
+ description: string | null;
10
+ techOperation: string | null;
11
+ origin: string | null;
12
+ ipAddress: string | null;
13
+ userAgent: string | null;
14
+ /** LocalDateTime ISO. */
15
+ operationDateTime: string;
16
+ userName: string | null;
17
+ /** Estado antes/depois (JSON serializado, pra o diff na tela de detalhe). */
18
+ beforeState: string | null;
19
+ afterState: string | null;
20
+ metadata?: Record<string, string>;
21
+ }
22
+ /** Filtros do GET /audit-logs (+ page/size quando paginado). */
23
+ export interface AuditLogFilters {
24
+ description?: string;
25
+ entity?: string;
26
+ idFrom?: number;
27
+ idTo?: number;
28
+ metaKey?: string;
29
+ metaValue?: string;
30
+ operation?: AuditOperation | string;
31
+ /** LocalDate "yyyy-MM-dd". */
32
+ operationDateFrom?: string;
33
+ operationDateTo?: string;
34
+ userName?: string;
35
+ page?: number;
36
+ size?: number;
37
+ }
38
+ /** Opção de entidade pro combo de filtro (GET /audit-logs/entities). */
39
+ export interface AuditLogEntityOption {
40
+ id: number;
41
+ entity: string;
42
+ }
43
+ /** Opção de usuário pro combo de filtro (GET /audit-logs/users). */
44
+ export interface AuditLogUserOption {
45
+ id: number;
46
+ userName: string;
47
+ }
48
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":"AAEA,gDAAgD;AAChD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/E,+CAA+C;AAC/C,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,SAAS,EAAE,cAAc,GAAG,MAAM,CAAC;IACnC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,yBAAyB;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,gEAAgE;AAChE,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACpC,8BAA8B;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wEAAwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oEAAoE;AACpE,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB"}
package/dist/audit.js ADDED
@@ -0,0 +1,2 @@
1
+ // DTOs de audit (espelham o Audit Log Controller do report-api). Client-safe.
2
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from "./audit";
2
+ export * from "./paths";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // Barrel client-safe (@seedgrid/fe-audit). Tipos + paths. Server helper em /server.
2
+ // A tela de busca de audit é SCAFFOLD (app owns), entregue pelo CLI — não é da lib.
3
+ export * from "./audit";
4
+ export * from "./paths";
@@ -0,0 +1,3 @@
1
+ import type { SeedGridCliModuleManifest } from "@seedgrid/fe-core";
2
+ export declare const module: SeedGridCliModuleManifest;
3
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAanE,eAAO,MAAM,MAAM,EAAE,yBAIpB,CAAC"}
package/dist/module.js ADDED
@@ -0,0 +1,16 @@
1
+ // Reference-adjacent implementation of the manifest read by the SeedGrid CLI
2
+ // (Rust). See seedgrid-cli/docs/adr/0004-module-manifest-contract.md.
3
+ //
4
+ // No `scaffold/` yet: the CLI's old template for this module
5
+ // (templates/modules/audit/src/modules/audit/index.ts.hbs) was a 6-line
6
+ // stub (`export const auditModule = { name, description }`) — no real
7
+ // screens were ever built for audit in the CLI, so there is nothing
8
+ // meaningful to extract. This package already has real logic (DTOs, paths,
9
+ // server engine); the audit list/detail screens themselves are a genuine
10
+ // gap (see the "example apps program" note tracked separately), not
11
+ // something lost in this extraction.
12
+ export const module = {
13
+ id: "audit",
14
+ requires: ["security"],
15
+ configKey: "audit",
16
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "id": "audit",
3
+ "requires": [
4
+ "security"
5
+ ],
6
+ "configKey": "audit"
7
+ }
@@ -0,0 +1,11 @@
1
+ export declare const AuditPaths: {
2
+ /** GET — lista/paginação de logs (aceita os filtros de AuditLogFilters via query). */
3
+ readonly logs: "/audit-logs";
4
+ /** GET — entidades distintas (combo de filtro). */
5
+ readonly entities: "/audit-logs/entities";
6
+ /** GET — usuários distintos (combo de filtro). */
7
+ readonly users: "/audit-logs/users";
8
+ /** GET — log por id. */
9
+ readonly byId: (id: number | string) => string;
10
+ };
11
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU;IACrB,sFAAsF;;IAEtF,mDAAmD;;IAEnD,kDAAkD;;IAElD,wBAAwB;wBACb,MAAM,GAAG,MAAM;CAClB,CAAC"}
package/dist/paths.js ADDED
@@ -0,0 +1,12 @@
1
+ // Paths do Audit Log Controller (report-api). Contrato único front/back.
2
+ const seg = (value) => encodeURIComponent(value);
3
+ export const AuditPaths = {
4
+ /** GET — lista/paginação de logs (aceita os filtros de AuditLogFilters via query). */
5
+ logs: "/audit-logs",
6
+ /** GET — entidades distintas (combo de filtro). */
7
+ entities: "/audit-logs/entities",
8
+ /** GET — usuários distintos (combo de filtro). */
9
+ users: "/audit-logs/users",
10
+ /** GET — log por id. */
11
+ byId: (id) => `/audit-logs/${seg(String(id))}`,
12
+ };
@@ -0,0 +1,14 @@
1
+ import type { PaginatedResult, SecurityServer } from "@seedgrid/fe-security";
2
+ import type { AuditLogEntry, AuditLogEntityOption, AuditLogFilters, AuditLogUserOption } from "../audit";
3
+ export interface AuditServer {
4
+ /** Busca paginada de logs (passe page/size). Filtros viram query string. */
5
+ searchLogs(filters?: AuditLogFilters): Promise<PaginatedResult<AuditLogEntry>>;
6
+ /** Entidades distintas pro combo de filtro. */
7
+ listEntities(): Promise<AuditLogEntityOption[]>;
8
+ /** Usuários distintos pro combo de filtro. */
9
+ listUsers(): Promise<AuditLogUserOption[]>;
10
+ /** Log por id (detalhe before/after). */
11
+ getById(id: number | string): Promise<AuditLogEntry>;
12
+ }
13
+ export declare function createAuditServer(session: SecurityServer): AuditServer;
14
+ //# sourceMappingURL=create-audit-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-audit-server.d.ts","sourceRoot":"","sources":["../../src/server/create-audit-server.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG7E,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAalB,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,UAAU,CACR,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAAC;IAC3C,+CAA+C;IAC/C,YAAY,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAChD,8CAA8C;IAC9C,SAAS,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC3C,yCAAyC;IACzC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACtD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAatE"}
@@ -0,0 +1,24 @@
1
+ // Helpers server-side de audit, sobre o motor de sessão do fe-security. SERVER-ONLY
2
+ // (roda em action/route). Só leitura — audit não muta nada.
3
+ //
4
+ // const session = createSecurityServer({ ... });
5
+ // export const audit = createAuditServer(session);
6
+ import { AuditPaths } from "../paths";
7
+ function buildQuery(filters) {
8
+ const params = new URLSearchParams();
9
+ for (const [key, value] of Object.entries(filters)) {
10
+ if (value !== undefined && value !== null && value !== "") {
11
+ params.set(key, String(value));
12
+ }
13
+ }
14
+ const qs = params.toString();
15
+ return qs ? `?${qs}` : "";
16
+ }
17
+ export function createAuditServer(session) {
18
+ return {
19
+ searchLogs: (filters = {}) => session.apiFetchSecurity(`${AuditPaths.logs}${buildQuery(filters)}`),
20
+ listEntities: () => session.apiFetchSecurity(AuditPaths.entities),
21
+ listUsers: () => session.apiFetchSecurity(AuditPaths.users),
22
+ getById: (id) => session.apiFetchSecurity(AuditPaths.byId(id)),
23
+ };
24
+ }
@@ -0,0 +1,2 @@
1
+ export { createAuditServer, type AuditServer, } from "./create-audit-server";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,GACjB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ // Barrel SERVER (@seedgrid/fe-audit/server). Roda em action/route.
2
+ export { createAuditServer, } from "./create-audit-server";
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@seedgrid/fe-audit",
3
+ "version": "2026.7.0",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/SeedGrid/seedgrid-fe-components.git"
10
+ },
11
+ "homepage": "https://github.com/SeedGrid/seedgrid-fe-components",
12
+ "bugs": {
13
+ "url": "https://github.com/SeedGrid/seedgrid-fe-components/issues"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./server": {
21
+ "types": "./dist/server/index.d.ts",
22
+ "default": "./dist/server/index.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "peerDependencies": {
29
+ "@seedgrid/fe-core": "*",
30
+ "@seedgrid/fe-security": "*"
31
+ },
32
+ "devDependencies": {
33
+ "@seedgrid/fe-core": "2026.7.1",
34
+ "@seedgrid/fe-security": "2026.7.2"
35
+ },
36
+ "scripts": {
37
+ "build": "tsc -p tsconfig.json",
38
+ "postbuild": "node scripts/emit-module-manifest.mjs",
39
+ "typecheck": "tsc -p tsconfig.json --noEmit",
40
+ "test": "pnpm run build && node --test tests/module-manifest.test.mjs"
41
+ }
42
+ }