refactor: normalize AccountRepo to canonical Effect service pattern (#22991)

This commit is contained in:
Kit Langton
2026-04-17 01:43:57 +00:00
committed by GitHub
parent 5b9fa32255
commit 9c87a144e8
5 changed files with 184 additions and 184 deletions
+10 -10
View File
@@ -122,7 +122,7 @@ it.live("login maps transport failures to account transport errors", () =>
it.live("orgsByAccount groups orgs per account", () =>
Effect.gen(function* () {
yield* AccountRepo.use((r) =>
yield* AccountRepo.Service.use((r) =>
r.persistAccount({
id: AccountID.make("user-1"),
email: "one@example.com",
@@ -134,7 +134,7 @@ it.live("orgsByAccount groups orgs per account", () =>
}),
)
yield* AccountRepo.use((r) =>
yield* AccountRepo.Service.use((r) =>
r.persistAccount({
id: AccountID.make("user-2"),
email: "two@example.com",
@@ -177,7 +177,7 @@ it.live("token refresh persists the new token", () =>
Effect.gen(function* () {
const id = AccountID.make("user-1")
yield* AccountRepo.use((r) =>
yield* AccountRepo.Service.use((r) =>
r.persistAccount({
id,
email: "user@example.com",
@@ -206,7 +206,7 @@ it.live("token refresh persists the new token", () =>
expect(Option.getOrThrow(token)).toBeDefined()
expect(String(Option.getOrThrow(token))).toBe("at_new")
const row = yield* AccountRepo.use((r) => r.getRow(id))
const row = yield* AccountRepo.Service.use((r) => r.getRow(id))
const value = Option.getOrThrow(row)
expect(value.access_token).toBe(AccessToken.make("at_new"))
expect(value.refresh_token).toBe(RefreshToken.make("rt_new"))
@@ -218,7 +218,7 @@ it.live("token refreshes before expiry when inside the eager refresh window", ()
Effect.gen(function* () {
const id = AccountID.make("user-1")
yield* AccountRepo.use((r) =>
yield* AccountRepo.Service.use((r) =>
r.persistAccount({
id,
email: "user@example.com",
@@ -251,7 +251,7 @@ it.live("token refreshes before expiry when inside the eager refresh window", ()
expect(String(Option.getOrThrow(token))).toBe("at_new")
expect(refreshCalls).toBe(1)
const row = yield* AccountRepo.use((r) => r.getRow(id))
const row = yield* AccountRepo.Service.use((r) => r.getRow(id))
const value = Option.getOrThrow(row)
expect(value.access_token).toBe(AccessToken.make("at_new"))
expect(value.refresh_token).toBe(RefreshToken.make("rt_new"))
@@ -262,7 +262,7 @@ it.live("concurrent config and token requests coalesce token refresh", () =>
Effect.gen(function* () {
const id = AccountID.make("user-1")
yield* AccountRepo.use((r) =>
yield* AccountRepo.Service.use((r) =>
r.persistAccount({
id,
email: "user@example.com",
@@ -315,7 +315,7 @@ it.live("concurrent config and token requests coalesce token refresh", () =>
expect(String(Option.getOrThrow(token))).toBe("at_new")
expect(refreshCalls).toBe(1)
const row = yield* AccountRepo.use((r) => r.getRow(id))
const row = yield* AccountRepo.Service.use((r) => r.getRow(id))
const value = Option.getOrThrow(row)
expect(value.access_token).toBe(AccessToken.make("at_new"))
expect(value.refresh_token).toBe(RefreshToken.make("rt_new"))
@@ -326,7 +326,7 @@ it.live("config sends the selected org header", () =>
Effect.gen(function* () {
const id = AccountID.make("user-1")
yield* AccountRepo.use((r) =>
yield* AccountRepo.Service.use((r) =>
r.persistAccount({
id,
email: "user@example.com",
@@ -388,7 +388,7 @@ it.live("poll stores the account and first org on success", () =>
expect(res.email).toBe("user@example.com")
}
const active = yield* AccountRepo.use((r) => r.active())
const active = yield* AccountRepo.Service.use((r) => r.active())
expect(Option.getOrThrow(active)).toEqual(
expect.objectContaining({
id: "user-1",