Skip to content

implemented utility providers#6

Merged
y-aithnini merged 1 commit intodevelopfrom
feature/AK-004-utility-providers
Mar 17, 2026
Merged

implemented utility providers#6
y-aithnini merged 1 commit intodevelopfrom
feature/AK-004-utility-providers

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 17, 2026 14:36
@sonarqubecloud
Copy link

@y-aithnini y-aithnini merged commit a303774 into develop Mar 17, 2026
4 checks passed
@y-aithnini y-aithnini deleted the feature/AK-004-utility-providers branch March 17, 2026 14:37
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

This PR introduces infrastructure “utility providers” (timestamp, ID generation, change detection) and wires them into the infra/public export surface, including the necessary new peer dependencies.

Changes:

  • Added new infra provider implementations: SystemTimestampProvider, NanoidIdGenerator, and DeepDiffChangeDetector.
  • Added barrel exports for src/infra/providers/** and re-exported providers from src/infra/index.ts.
  • Updated package.json / package-lock.json to include date-fns and nanoid as required peers (and dev deps for local development).

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/infra/providers/timestamp/system-timestamp-provider.ts Adds a system-clock timestamp provider with parsing/formatting/diff and test-time controls.
src/infra/providers/timestamp/index.ts Exposes timestamp provider implementations via a barrel export.
src/infra/providers/index.ts Adds a top-level barrel for all infra utility providers.
src/infra/providers/id-generator/nanoid-id-generator.ts Adds a nanoid-based ID generator with validation and batch generation.
src/infra/providers/id-generator/index.ts Exposes ID generator implementations via a barrel export.
src/infra/providers/change-detector/deep-diff-change-detector.ts Adds a deep comparison change detector with masking utilities.
src/infra/providers/change-detector/index.ts Exposes change detector implementations via a barrel export.
src/infra/index.ts Re-exports providers from the infra layer (making them part of the public surface).
package.json Adds date-fns and nanoid as peer dependencies (and dev deps) to support the new providers.
package-lock.json Locks the added dependencies for development installs.

Comment on lines +82 to +86
* ```typescript
* const provider = new SystemTimestampProvider({ defaultTimezone: 'America/New_York' });
* const now = provider.now({ format: 'iso' });
* // '2026-03-16T05:30:00.000-05:00' (adjusted for EST/EDT)
* ```
Comment on lines +141 to +142
// Format output
const outputFormat = options?.format ?? "date";
Comment on lines +178 to +181
// Unix timestamp - detect if seconds or milliseconds
const isSeconds = timestamp < 10000000000; // Before year 2286
const ms = isSeconds ? timestamp * 1000 : timestamp;
return new Date(ms);
Comment on lines +219 to +223
return {
name: "NanoidIdGenerator",
version: "5.0.9", // nanoid version
defaultLength: this.defaultLength,
alphabet: this.defaultAlphabet ?? "A-Za-z0-9_-",
Comment on lines 46 to +50
"@nestjs/common": "^10 || ^11",
"@nestjs/core": "^10 || ^11",
"date-fns": "^4",
"mongoose": "^8",
"nanoid": "^5",
Comment on lines +241 to +245
if (tz !== "utc" && tz !== "local") {
throw new Error(`IANA timezone '${tz}' not supported. Use 'utc' or 'local' only.`);
}

return startOfDayFns(targetDate);
Comment on lines +260 to +264
if (tz !== "utc" && tz !== "local") {
throw new Error(`IANA timezone '${tz}' not supported. Use 'utc' or 'local' only.`);
}

return endOfDayFns(targetDate);
Comment on lines +243 to +244
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
Comment on lines +210 to +214
case "hash": {
// Simple hash implementation (non-crypto, for masking only)
// NOTE: This is NOT cryptographically secure, just for audit log display
return this.simpleHash(stringValue);
}
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