Skip to content

Refactor: extract GoogleOAuthClient service and adopt interface/type naming conventions#10

Merged
ltyu merged 3 commits intomasterfrom
leyu00/refactor-google-oauth-and-type-conventions
Mar 18, 2026
Merged

Refactor: extract GoogleOAuthClient service and adopt interface/type naming conventions#10
ltyu merged 3 commits intomasterfrom
leyu00/refactor-google-oauth-and-type-conventions

Conversation

@ltyu
Copy link
Copy Markdown
Owner

@ltyu ltyu commented Mar 18, 2026

Summary

  • Extract GoogleOAuthClient service — moves three hanging module-level functions (exchangeCodeForTokens, getGoogleAccountProfile, buildConsentUrl) out of googleOAuthCallback.ts and startGoogleOAuth.ts into a dedicated GoogleOAuthClient class in src/services/. Handlers now depend on the IGoogleOAuthClient interface, keeping Google SDK details out of handler files.

  • Adopt interface vs type naming conventions — all exported public-contract interfaces are prefixed with I (e.g. IGmailService, IOAuthStateRepository). File-local dependency bags, config objects, and internal DynamoDB item shapes are converted from interface to type and drop the I prefix, since they are never implemented or extended.

  • Update AGENTS.md — documents the interface/type distinction so future agents and contributors follow the same pattern.

Changed files

File Change
src/services/googleOAuthClient.ts New — GoogleOAuthClient class with 3 methods
src/types.ts Add IGoogleOAuthClient, ITokenExchangeResult, IGoogleAccountProfile; prefix all 23 exported interfaces with I
src/handlers/googleOAuthCallback.ts Replace two function deps with googleOAuthClient; config/deps shapes → type
src/handlers/startGoogleOAuth.ts Thread googleOAuthClient through deps; config/deps shapes → type
src/repositories/dynamoDb*.ts Internal item shapes → type, drop I prefix
src/services/*.ts, src/utils/*.ts, src/handler.ts Update imports to renamed I-prefixed interfaces
src/handler.test.ts, src/handlers/*.test.ts Update mocks to match new dep shape
AGENTS.md Document interface vs type rule

ltyu added 3 commits March 18, 2026 13:27
Move exchangeCodeForTokens, getGoogleAccountProfile, and buildConsentUrl
out of googleOAuthCallback.ts and startGoogleOAuth.ts into a dedicated
GoogleOAuthClient class in src/services/. Add IGoogleOAuthClient interface
to types.ts so handlers depend on the abstraction, not the concrete class.
Prefix all exported public-contract interfaces with I (IGmailService,
IOAuthStateRepository, etc.) per the updated Type Guidance in AGENTS.md.
Convert file-local dependency bags and internal data shapes (config objects,
DynamoDB item shapes, handler deps) from interface to type and drop the I
prefix, since they are never implemented or extended.
Input shapes, result shapes, config records, and context objects that are
never implemented or extended (UpsertPrimaryGmailConnectionInput, SendReplyInput,
AppConfig, AppSecrets, GmailConnectionRecord, etc.) are converted from
interface to type and the I prefix is removed. Public service and repository
contracts that classes implement retain the interface keyword and I prefix.
@ltyu ltyu merged commit 19d1f00 into master Mar 18, 2026
1 check passed
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.

1 participant