Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a framework-agnostic “core” API surface for AuditKit by defining domain types, DTO schemas, ports (interfaces), and domain errors, then re-exporting them via src/core/index.ts.
Changes:
- Added core domain model types (audit log entity, pagination/filter types, enums, type guards).
- Added core ports for persistence, change detection, ID generation, and timestamp abstraction (with a ports barrel export).
- Added Zod DTO schemas for create/query/response shapes plus domain error classes, and re-exported them from the core index.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/core/types.ts | Adds core domain types/enums plus runtime type guards. |
| src/core/ports/timestamp-provider.port.ts | Defines timestamp abstraction port and related option types. |
| src/core/ports/index.ts | Barrel exports for core port interfaces and helper types. |
| src/core/ports/id-generator.port.ts | Defines ID generation abstraction port and option/info types. |
| src/core/ports/change-detector.port.ts | Defines change detection abstraction port and options. |
| src/core/ports/audit-repository.port.ts | Defines audit log persistence abstraction port and query methods. |
| src/core/index.ts | Establishes the public export surface for core types/DTOs/ports/errors. |
| src/core/errors/invalid-changeset.error.ts | Adds domain error for invalid/missing changeset scenarios. |
| src/core/errors/invalid-actor.error.ts | Adds domain error for invalid/missing actor scenarios. |
| src/core/errors/index.ts | Barrel exports for core domain errors. |
| src/core/errors/audit-not-found.error.ts | Adds domain error for missing audit logs. |
| src/core/dtos/query-audit-logs.dto.ts | Adds Zod schema/types/constants for query filter validation. |
| src/core/dtos/index.ts | Barrel exports for all DTO schemas and inferred types. |
| src/core/dtos/create-audit-log.dto.ts | Adds Zod schema/types for create-audit-log input (+ before/after variant). |
| src/core/dtos/audit-log-response.dto.ts | Adds Zod schema/types for response shapes (single/paginated/stats/errors). |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
There was a problem hiding this comment.
Pull request overview
Introduces a framework-free “core” API surface for AuditKit by adding domain types, DTO schemas (Zod), ports (hexagonal interfaces), and domain errors, then re-exporting them from src/core/index.ts for consumption via the package root.
Changes:
- Added core domain model types (audit log entity, enums, pagination/filter types) plus runtime type guards.
- Added core ports (repository, change detector, ID generator, timestamp provider) and centralized port exports.
- Added Zod DTO schemas for create/query/response shapes and added domain-specific error types; expanded
src/core/index.tspublic exports.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/core/types.ts | Adds core domain types/enums and type guards for audit logging. |
| src/core/ports/audit-repository.port.ts | Defines persistence port contract for audit logs. |
| src/core/ports/change-detector.port.ts | Defines change detection port contract and options. |
| src/core/ports/id-generator.port.ts | Defines ID generation port contract and option types. |
| src/core/ports/timestamp-provider.port.ts | Defines timestamp provider port contract and related types. |
| src/core/ports/index.ts | Central export surface for all core ports. |
| src/core/dtos/create-audit-log.dto.ts | Zod schema + inferred types for create-audit-log input. |
| src/core/dtos/query-audit-logs.dto.ts | Zod schema + inferred types for querying/filtering audit logs. |
| src/core/dtos/audit-log-response.dto.ts | Zod schema + inferred types for consistent response formatting. |
| src/core/dtos/index.ts | Central export surface for DTO schemas/types. |
| src/core/errors/audit-not-found.error.ts | Domain error for missing audit logs. |
| src/core/errors/invalid-actor.error.ts | Domain error for invalid actor payloads. |
| src/core/errors/invalid-changeset.error.ts | Domain error for invalid or missing changesets. |
| src/core/errors/index.ts | Central export surface for domain errors. |
| src/core/index.ts | Replaces placeholder with full public core exports (types, DTOs, ports, errors). |
| * CreateAuditLogDto, | ||
| * IAuditLogRepository, | ||
| * AuditNotFoundError | ||
| * } from '@core'; |
| .number() | ||
| .int("Limit must be an integer") | ||
| .min(1, "Limit must be at least 1") | ||
| .max(MAX_PAGE_SIZE, `Limit cannot exceed ${MAX_PAGE_SIZE}`) | ||
| .default(DEFAULT_PAGE_SIZE), | ||
|
|
||
| /** | ||
| * Sort order. |
| // WHO - Actor Information | ||
| // ───────────────────────────────────────────────────────────────────────── | ||
|
|
| * | ||
| * All filters are optional - can be combined for complex queries. | ||
| */ |
| /** | ||
| * Timezone options for timestamp generation. | ||
| */ | ||
| export type TimezoneOption = "utc" | "local" | string; // string for IANA tz (e.g., 'America/New_York') |
| customComparators?: Record< | ||
| string, | ||
| (a: unknown, b: unknown) => boolean | ||
| >; |
| * | ||
| * Usage: | ||
| * ```typescript | ||
| * import { IAuditLogRepository, IChangeDetector } from '@core/ports'; |
| * | ||
| * Usage: | ||
| * ```typescript | ||
| * import { CreateAuditLogDto, QueryAuditLogsDto } from '@core/dtos'; |
| * AuditNotFoundError, | ||
| * InvalidActorError, | ||
| * InvalidChangeSetError | ||
| * } from '@core/errors'; |
| page: z | ||
| .number() | ||
| .int("Page must be an integer") | ||
| .min(1, "Page must be at least 1") | ||
| .default(1), | ||
|
|
||
| /** |



Summary
Why
Checklist
npm run lintpassesnpm run typecheckpassesnpm testpassesnpm run buildpassesnpx changeset) if this affects consumersNotes