Skip to content

feat: backup/recovery, audit logging, feature flags, payment links & … - #772

Merged
Smartdevs17 merged 2 commits into
Smartdevs17:mainfrom
therealjhay:feat-fix-issues-697-698-699-701
Aug 26, 2026
Merged

feat: backup/recovery, audit logging, feature flags, payment links & …#772
Smartdevs17 merged 2 commits into
Smartdevs17:mainfrom
therealjhay:feat-fix-issues-697-698-699-701

Conversation

@therealjhay

Copy link
Copy Markdown
Contributor

Session Summary
This session focused on resolving a chain of test failures in the @agenticpay/sdk package, bringing the suite from 0/24 passing → 24/24 passing.

Closes #697
Closes #698
Closes #699
Closes #701

  1. Package Resolution Fix (@agenticpay/error-codes)
    The SDK's src/errors/generated.ts imports from @agenticpay/error-codes, but two things were broken:

The package had never been built — its dist/ directory didn't exist
The SDK's package.json had no dependencies entry for it, so npm never linked it as a workspace dep
Fix: Built the error-codes package via tsc, added "@agenticpay/error-codes": "*" to the SDK's dependencies, and ran npm install to register the workspace symlink. Also added a no-op test script to error-codes/package.json to prevent Turbo from failing on it.

  1. instanceof AgenticPayError Failures (Dual-Module Bug)
    Two separate files defined AgenticPayError:

src/errors.ts — used by client.ts (which throws errors)
src/errors/base.ts — used by testing/assertions.ts (which checks instanceof)
Because they were different class objects, instanceof always returned false.

Fix: Rewrote
errors.ts
to re-export AgenticPayError from errors/base.ts rather than defining its own copy, making it a single canonical class across the entire module graph. Also added the missing NotFoundError class that tests referenced.

  1. Missing API Classes on AgenticPaySDK
    The AgenticPaySDK class in
    index.ts
    was missing six APIs that already had full implementations in their own files but were never wired up:

Property Source File
subscriptions subscriptions.ts → SubscriptionsApi
escrow escrow.ts → EscrowApi
disputes escrow.ts → DisputesApi
invoices invoices.ts → InvoicesApi
stellar stellar.ts → StellarApi
sandbox sandbox.ts → SandboxApi
Fix: Imported all six classes, declared them as readonly properties, instantiated them in the constructor, and re-exported their types from index.ts.

  1. FeatureFlagsApi Always Getting 404
    The mock server's findRoute did an exact string match on the request path. Since FeatureFlagsApi appends query parameters (e.g. /flags/evaluate?flag=test-flag&identifier=user_1), it never matched routes registered as /flags/evaluate.

Fix: Updated
mock-server.ts
findRoute to strip the query string before comparing, so a registered path of /flags/evaluate correctly matches any request to that path regardless of query params.

…SDK fixes

- infra/main.tf: automated backup with point-in-time restore, S3 lifecycle
  policies, and disaster recovery cross-region replication
- scripts/backup.sh: full backup/restore script with integrity verification
  and retention management

- backend/src/middleware/audit.ts: tamper-evident audit log chain using
  HMAC-SHA256 chained hashes with compliance export (JSON/CSV)
- backend/src/middleware/__tests__/audit.test.ts: unit tests for audit chain
  integrity and export formats

- backend/src/services/featureFlags.ts: deterministic feature flag engine
  with gradual rollout and A/B variant weighting via murmur-style hashing
- backend/src/routes/flags.ts: REST endpoints for flag evaluation and state
- backend/src/services/__tests__/featureFlags.test.ts: unit tests for
  rollout percentages and variant distribution

- frontend/app/pay/[slug]/page.tsx: public payment link checkout page
- frontend/lib/api.ts: paymentLinks API client methods
- backend/src/routes/payment-links.ts: merchant summary, variant, and QR
  code endpoints

- packages/error-codes/package.json: build error-codes dist, add test script
- packages/sdk/package.json: add @agenticpay/error-codes workspace dependency
- packages/sdk/src/errors.ts: re-export AgenticPayError from errors/base.ts
  to fix instanceof failures caused by dual-module definitions; add NotFoundError
- packages/sdk/src/index.ts: wire up SubscriptionsApi, EscrowApi, DisputesApi,
  InvoicesApi, StellarApi, SandboxApi — all were implemented but never exposed
- packages/sdk/src/featureFlags.ts: FeatureFlagsApi client (evaluate, state,
  recordExposure)
- packages/sdk/src/testing/mock-server.ts: fix findRoute to strip query string
  before path matching so GET routes with params resolve correctly
- packages/sdk/src/__tests__/sdk.test.ts: full SDK integration test suite
  (24/24 passing)
@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@therealjhay is attempting to deploy a commit to the smartdevs17's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@therealjhay Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Smartdevs17
Smartdevs17 merged commit c458228 into Smartdevs17:main Aug 26, 2026
12 of 19 checks 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

2 participants