Skip to content

docs(adr): add ADR 0001 for SDK API design principles (#144) - #170

Merged
El-swaggerito merged 1 commit into
Axionvera:mainfrom
mubking:docs/issue-144-adr-api-design-principles
Jul 21, 2026
Merged

docs(adr): add ADR 0001 for SDK API design principles (#144)#170
El-swaggerito merged 1 commit into
Axionvera:mainfrom
mubking:docs/issue-144-adr-api-design-principles

Conversation

@mubking

@mubking mubking commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Add ADR for SDK API design principles

Closes #144

Summary

Adds an Architecture Decision Record documenting the SDK's API design principles, so future contributions and reviews have a shared reference instead of re-deciding these questions case by case. This is a documentation-only change: it records current practice and introduces no code changes.

What it adds

  • docs/adr/0001-api-design-principles.md — the ADR itself, covering the five areas the issue calls for:
    • NamingcamelCase action verbs grouped by domain module, a single package entry point, and the doThing / safeDoThing / enhancedDoThing / safeEnhancedDoThing prefix convention that communicates a function's error behavior from its name.
    • Error handling — the single PocketPayError(message, code, details?, cause?) class with stable machine-readable codes, and the two consumption styles (throwing base functions vs. safe* functions returning a { ok, value } / { ok, error } discriminated union).
    • Configuration — centralized SDKConfig, resolved through resolveConfig with a clear override → environment → default precedence, and fail-fast validation.
    • Async operations — network operations return promises; pure helpers stay synchronous; enriched variants carry non-fatal ResultWarnings and actionable RecoveryHints.
    • Backwards compatibility — SemVer, changelog discipline, additive change preference, and the supported Node/TypeScript/Stellar SDK baselines.
  • docs/adr/README.md — an ADR index describing what ADRs are and listing the records.
  • README link — the Documentation section now links the ADR directory.

Acceptance criteria

  • An ADR is added for SDK API design principles
  • The ADR covers naming, errors, config, async behaviour, and compatibility
  • The README links to the ADR
  • The ADR is written clearly for contributors

Notes

The ADR documents the API patterns as they exist in the current source (the result union, PocketPayError shape, the safe*/enhanced* naming family, Partial<SDKConfig> overrides, and the ResultWarning/RecoveryHint enrichment). No source files were modified.

Separately, while preparing this ADR I noticed main currently does not type-check: src/types/index.ts is missing exports that many modules import from ../types (PocketPayError, SDKConfig, StellarNetwork, SuccessResult, PocketPayResult, and others), so tsc --noEmit fails project-wide. That is a pre-existing issue unrelated to this documentation change and is not addressed here; I'd suggest tracking it as its own bug.

Add an Architecture Decision Record documenting the SDK's API design
principles across naming, error handling, configuration, async operations,
and backwards compatibility, plus an ADR index and a README link.

Closes Axionvera#144
@El-swaggerito
El-swaggerito merged commit 19d1b4a into Axionvera:main Jul 21, 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.

Add SDK architecture decision record for API design principles

2 participants