Skip to content

Conversation

@transphorm
Copy link
Member

@transphorm transphorm commented Aug 14, 2025

Summary

  • stub mrz, nfc, and qr feature modules
  • re-export feature stubs from SDK entry point
  • document modular directories in architecture and migration guides

Testing

  • yarn workspaces foreach -A -p -v --topological-dev --since=HEAD run nice --if-present (fails: Invalid option schema)
  • yarn workspace @selfxyz/mobile-sdk-alpha nice
  • yarn workspace @selfxyz/mobile-sdk-alpha types --listFiles
  • yarn workspace @selfxyz/mobile-sdk-alpha test
  • yarn workspace @selfxyz/mobile-sdk-alpha build
  • yarn workspace @selfxyz/mobile-sdk-alpha validate:exports
  • yarn workspace @selfxyz/mobile-sdk-alpha validate:pkg
  • yarn lint
  • yarn build
  • yarn workspace @selfxyz/contracts build (fails: Invalid account for network)
  • yarn types

https://chatgpt.com/codex/tasks/task_b_689d171ebc54832d8caa061115a41d47

Summary by CodeRabbit

  • New Features
    • Introduced unified NFC, MRZ, and QR scanning interfaces in the SDK, available from the top-level API.
    • Added a mergeConfig utility for combining configuration options.
  • Documentation
    • Updated architecture and prompts to standardize feature directories (mrz, nfc, qr) and encourage explicit named exports for better tree-shaking.
    • Expanded migration guides with a checklist for organizing new capabilities and re-exporting them via named exports.
    • Added guidance on grouping capabilities (processing, validation, mrz, nfc, qr) before starting migrations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 14, 2025

Walkthrough

Adds new public modules for NFC, MRZ, and QR with scan stubs and explicit exports. Reorganizes top-level and browser barrels to re-export from ./nfc, ./mrz, ./qr, and adds mergeConfig. Updates documentation to reflect modular capability directories and explicit named exports.

Changes

Cohort / File(s) Summary
Docs: architecture and migration
packages/mobile-sdk-alpha/docs/ARCHITECTURE.md, .../ARCHITECTURE_PROMPTS.md, .../MIGRATION_CHECKLIST.md, .../MIGRATION_PROMPTS.md
Update guidance to modularize capabilities (mrz/, nfc/, qr/) and use explicit named exports from src/index.ts; add migration checklist/prompt notes.
Barrels: public API reorg
packages/mobile-sdk-alpha/src/index.ts, packages/mobile-sdk-alpha/src/browser.ts
Move NFC/MRZ/QR exports from processing/* to nfc/, mrz/, qr/; add NFC types, MRZ helpers, QR proof API; add mergeConfig; remove legacy processing/* exports.
New capability modules
packages/mobile-sdk-alpha/src/nfc/index.ts, .../mrz/index.ts, .../qr/index.ts
Introduce public NFC/MRZ/QR modules with option interfaces and scan stubs; re-export existing processing helpers/types (parseNFCResponse, DG1/DG2, MRZ helpers).

Sequence Diagram(s)

sequenceDiagram
  participant App
  participant SDK as mobile-sdk-alpha (nfc/mrz/qr)
  participant Processing as processing/*
  App->>SDK: scanNFC(opts)
  SDK->>Processing: parseNFCResponse(...)
  Processing-->>SDK: ParsedNFCResponse
  SDK-->>App: ScanResult (stub)

  App->>SDK: scanMRZ(opts)
  SDK->>Processing: extractMRZInfo / formatDateToYYMMDD
  Processing-->>SDK: MRZ data
  SDK-->>App: ScanResult (stub)

  App->>SDK: scanQRProof(opts)
  SDK-->>App: ScanResult (stub)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • remicolin
  • aaronmgdr

Poem

New paths for scans, neat and clear,
NFC, MRZ, QR appear.
Barrels trimmed, exports named,
Processing tamed and cleanly framed.
One config merge to tie the bow—
Stubbed today, tomorrow go! 🚀

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/implement-modular-feature-directories

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@transphorm transphorm marked this pull request as ready for review August 14, 2025 04:13
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (3)
packages/mobile-sdk-alpha/docs/ARCHITECTURE_PROMPTS.md (1)

25-26: Add a brief example to cement the guidance

A short example makes the “explicit named exports” directive actionable and consistent across contributors.

You can append an example block after the list:

// src/index.ts
export { scanMRZ } from './mrz';
export { scanNFC } from './nfc';
export { scanQRProof } from './qr';
// type-only re-exports to preserve tree-shaking
export type { MRZScanOptions } from './mrz';
export type { NFCScanOptions } from './nfc';
export type { QRProofOptions } from './qr';

// Consumer usage
import { scanMRZ, scanNFC, scanQRProof } from '@selfxyz/mobile-sdk-alpha';
packages/mobile-sdk-alpha/docs/MIGRATION_PROMPTS.md (1)

10-10: Strengthen export guidance for tree-shaking

Explicitly discourage export * and suggest export type for types to prevent bundlers from pulling values.

Apply this diff:

-- Group new capabilities in their own directories (e.g., `processing/`, `validation/`, `mrz/`, `nfc/`, `qr/`) and re-export them from `src/index.ts` using explicit named exports.
+- Group new capabilities in their own directories (e.g., `processing/`, `validation/`, `mrz/`, `nfc/`, `qr/`) and re-export them from `src/index.ts` using explicit named exports (avoid `export *`). Use `export type { ... }` for type-only re-exports.
packages/mobile-sdk-alpha/src/qr/index.ts (1)

7-9: Prefer a clearer, consistent not-implemented error and add TSDoc

Improve debuggability with a specific message and TSDoc. Longer term, unify on a typed error (e.g., FeatureUnavailableError) across MRZ/NFC/QR.

Apply this diff to clarify the error:

-export async function scanQRProof(_opts: QRProofOptions): Promise<ScanResult> {
-  throw new Error('Not implemented');
-}
+export async function scanQRProof(_opts: QRProofOptions): Promise<ScanResult> {
+  throw new Error('scanQRProof is not implemented yet in @selfxyz/mobile-sdk-alpha');
+}

Optionally add TSDoc (outside the selected range) for API clarity:

/**
 * Scans and parses a QR proof payload.
 * @throws Error with message "scanQRProof is not implemented yet in @selfxyz/mobile-sdk-alpha"
 * until the capability is delivered.
 * @public
 */
export async function scanQRProof(_opts: QRProofOptions): Promise<ScanResult> { /* ... */ }

Also consider introducing a shared typed error in src/errors/ (e.g., FeatureUnavailableError) and reuse it across mrz, nfc, and qr stubs for consistency and easier client-side handling.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae5e8cc and 94a60d0.

📒 Files selected for processing (9)
  • packages/mobile-sdk-alpha/docs/ARCHITECTURE.md (1 hunks)
  • packages/mobile-sdk-alpha/docs/ARCHITECTURE_PROMPTS.md (1 hunks)
  • packages/mobile-sdk-alpha/docs/MIGRATION_CHECKLIST.md (1 hunks)
  • packages/mobile-sdk-alpha/docs/MIGRATION_PROMPTS.md (1 hunks)
  • packages/mobile-sdk-alpha/src/browser.ts (1 hunks)
  • packages/mobile-sdk-alpha/src/index.ts (1 hunks)
  • packages/mobile-sdk-alpha/src/mrz/index.ts (1 hunks)
  • packages/mobile-sdk-alpha/src/nfc/index.ts (1 hunks)
  • packages/mobile-sdk-alpha/src/qr/index.ts (1 hunks)
🧰 Additional context used
🪛 LanguageTool
packages/mobile-sdk-alpha/docs/ARCHITECTURE.md

[grammar] ~11-~11: There might be a mistake here.
Context: ...plicit named exports (avoid export *). 2. Bridge layer for native events – wrap ...

(QB_NEW_EN)

🪛 Biome (2.1.2)
packages/mobile-sdk-alpha/src/qr/index.ts

[error] 3-5: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

packages/mobile-sdk-alpha/src/nfc/index.ts

[error] 5-7: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

packages/mobile-sdk-alpha/src/mrz/index.ts

[error] 3-5: An empty interface is equivalent to {}.

Safe fix: Use a type alias instead.

(lint/suspicious/noEmptyInterface)

🔇 Additional comments (5)
packages/mobile-sdk-alpha/docs/MIGRATION_CHECKLIST.md (1)

5-6: No change needed — entry barrels already use explicit named exports and type-only re-exports

Verified packages/mobile-sdk-alpha/src/index.ts and packages/mobile-sdk-alpha/src/browser.ts:

  • Both files use export type { ... } from './types/public' for types.
  • MRZ/NFC/QR are re-exported with explicit named exports (e.g. export { type ..., scanMRZ } from './mrz', export { type ..., scanNFC } from './nfc', export { type ..., scanQRProof } from './qr').
  • mergeConfig is explicitly exported (export { mergeConfig } from './config/merge').
  • No export * from patterns were found.

Conclusion: the proposed diff is unnecessary — the barrels already follow the recommended tree-shaking-friendly pattern. Leave as-is.

packages/mobile-sdk-alpha/docs/ARCHITECTURE.md (1)

11-11: LGTM: Clear guidance toward modular, tree-shakable exports

Calling out explicit named exports and avoiding export * here aligns with best practices and the PR’s reorganization.

packages/mobile-sdk-alpha/src/qr/index.ts (1)

1-1: Good: type-only import for ScanResult

Using import type ensures no runtime footprint and keeps the bundle lean.

packages/mobile-sdk-alpha/src/index.ts (1)

35-37: LGTM: modularized re-exports with type-only specifiers

The re-exports from ./nfc, ./mrz, ./qr, and ./config/merge cleanly expose public surfaces and the type specifiers avoid runtime emissions. This improves tree-shaking and clarifies the intended import paths for consumers.

Also applies to: 41-41

packages/mobile-sdk-alpha/src/browser.ts (1)

37-39: LGTM: browser barrel mirrors the modular export surface

The browser-focused barrel re-exports align with the new modular structure and use type-only specifiers for better treeshaking. Keeping browser and universal entrypoints in sync mitigates drift.

Also applies to: 44-44

@transphorm
Copy link
Member Author

fyi @shazarre @aaronmgdr first pr that updates our sdk structure based on the architecture checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants