Merged
Conversation
|
There was a problem hiding this comment.
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, andDeepDiffChangeDetector. - Added barrel exports for
src/infra/providers/**and re-exported providers fromsrc/infra/index.ts. - Updated
package.json/package-lock.jsonto includedate-fnsandnanoidas 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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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