Skip to content

core domain types#2

Closed
y-aithnini wants to merge 6 commits intodevelopfrom
feature/AK-001-core-domain-types
Closed

core domain types#2
y-aithnini wants to merge 6 commits intodevelopfrom
feature/AK-001-core-domain-types

Conversation

@y-aithnini
Copy link

Summary

  • What does this PR change?

Why

  • Why is this change needed?

Checklist

  • Added/updated tests (if behavior changed)
  • npm run lint passes
  • npm run typecheck passes
  • npm test passes
  • npm run build passes
  • Added a changeset (npx changeset) if this affects consumers

Notes

  • Anything reviewers should pay attention to?

Copilot AI review requested due to automatic review settings March 13, 2026 10:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings March 13, 2026 10:31
y-aithnini and others added 2 commits March 13, 2026 10:32
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>
y-aithnini and others added 2 commits March 13, 2026 10:32
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>
@sonarqubecloud
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts public 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';
Comment on lines +92 to +99
.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.
Comment on lines +189 to +191
// WHO - Actor Information
// ─────────────────────────────────────────────────────────────────────────

Comment on lines +303 to +305
*
* 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')
Comment on lines +91 to +94
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';
Comment on lines +81 to +87
page: z
.number()
.int("Page must be an integer")
.min(1, "Page must be at least 1")
.default(1),

/**
@y-aithnini y-aithnini closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants