- Emit Effect DateTime values from review and git diff previews - Tighten the contract to require UTC datetime output
Unified · Split
| @@ -1,4 +1,4 @@ | ||
| 1 | −import { Context, Effect, Layer } from "effect"; | |
| 1 | +import { Context, DateTime, Effect, Layer } from "effect"; | |
| 2 | 2 | |
| 3 | 3 | import { |
| 4 | 4 | VcsUnsupportedOperationError, |
| @@ -7,7 +7,7 @@ import { · 2 unmodified lines | ||
| 7 | 7 | type ReviewDiffPreviewResult, |
| 8 | 8 | } from "@t3tools/contracts"; |
| 9 | 9 | |
| 10 | −import { GitVcsDriver } from "../vcs/GitVcsDriver.ts"; | |
| 10 | +import * as GitVcsDriver from "../vcs/GitVcsDriver.ts"; | |
| 11 | 11 | import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts"; |
| 12 | 12 | |
| 13 | 13 | export interface ReviewServiceShape { |
| @@ -20,24 +20,20 @@ export class ReviewService extends Context.Service<ReviewService, ReviewServiceS · 6 unmodified lines | ||
| 20 | 20 | "t3/review/ReviewService", |
| 21 | 21 | ) {} |
| 22 | 22 | |
| 23 | −function emptyDiffPreview(input: ReviewDiffPreviewInput): ReviewDiffPreviewResult { | |
| 24 | − return { | |
| 25 | − cwd: input.cwd, | |
| 26 | − generatedAt: new Date().toISOString(), | |
| 27 | − sources: [], | |
| 28 | − }; | |
| 29 | −} | |
| 30 | − | |
| 31 | 23 | export const make = Effect.fn("makeReviewService")(function* () { |
| 32 | 24 | const vcsRegistry = yield* VcsDriverRegistry.VcsDriverRegistry; |
| 33 | − const git = yield* GitVcsDriver; | |
| 25 | + const git = yield* GitVcsDriver.GitVcsDriver; | |
| 34 | 26 | |
| 35 | 27 | const getDiffPreview: ReviewServiceShape["getDiffPreview"] = Effect.fn( |
| 36 | 28 | "ReviewService.getDiffPreview", |
| 37 | 29 | )(function* (input) { |
| 38 | 30 | const handle = yield* vcsRegistry.detect({ cwd: input.cwd, requestedKind: "auto" }); |
| 39 | 31 | if (!handle) { |
| 40 | − return emptyDiffPreview(input); | |
| 32 | + return { | |
| 33 | + cwd: input.cwd, | |
| 34 | + generatedAt: yield* DateTime.now, | |
| 35 | + sources: [], | |
| 36 | + }; | |
| 41 | 37 | } |
| 42 | 38 | |
| 43 | 39 | const getDriverDiffPreview = handle.driver.getDiffPreview; |
| @@ -2526,7 +2526,7 @@ it.layer(NodeServices.layer)("server router seam", (it) => { · 2525 unmodified lines | ||
| 2526 | 2526 | getDiffPreview: (input) => |
| 2527 | 2527 | Effect.succeed({ |
| 2528 | 2528 | cwd: input.cwd, |
| 2529 | − generatedAt: new Date(0).toISOString(), | |
| 2529 | + generatedAt: DateTime.nowUnsafe(), | |
| 2530 | 2530 | sources: [ |
| 2531 | 2531 | { |
| 2532 | 2532 | id: "working-tree", |
| @@ -1702,7 +1702,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* · 1701 unmodified lines | ||
| 1702 | 1702 | if (!details.isRepo) { |
| 1703 | 1703 | return { |
| 1704 | 1704 | cwd: input.cwd, |
| 1705 | − generatedAt: new Date().toISOString(), | |
| 1705 | + generatedAt: yield* DateTime.now, | |
| 1706 | 1706 | sources: [], |
| 1707 | 1707 | }; |
| 1708 | 1708 | } |
| @@ -1791,7 +1791,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function* · 82 unmodified lines | ||
| 1791 | 1791 | |
| 1792 | 1792 | return { |
| 1793 | 1793 | cwd: input.cwd, |
| 1794 | − generatedAt: new Date().toISOString(), | |
| 1794 | + generatedAt: yield* DateTime.now, | |
| 1795 | 1795 | sources, |
| 1796 | 1796 | }; |
| 1797 | 1797 | }); |
| @@ -26,7 +26,7 @@ export type ReviewDiffPreviewSource = typeof ReviewDiffPreviewSource.Type; · 25 unmodified lines | ||
| 26 | 26 | |
| 27 | 27 | export const ReviewDiffPreviewResult = Schema.Struct({ |
| 28 | 28 | cwd: TrimmedNonEmptyString, |
| 29 | − generatedAt: Schema.String, | |
| 29 | + generatedAt: Schema.DateTimeUtc, | |
| 30 | 30 | sources: Schema.Array(ReviewDiffPreviewSource), |
| 31 | 31 | }); |
| 32 | 32 | export type ReviewDiffPreviewResult = typeof ReviewDiffPreviewResult.Type; |