# react-native-rook-sdk

## Purpose

This repo exposes the ROOK mobile SDKs to React Native APPs so they can configure ROOK, request permissions, read on-device health data, trigger sync flows, and manage API data_source connections on iOS and Android.

The same paragraph lives in `foundations/purpose.md`. Foundations is the source of truth.

## Context

Read these before changing anything:

* `foundations/`, the purpose, requirements, glossary, user stories, and AGENTS.md that govern this repo.
* `service-manifest.yaml`, the machine-readable inventory of components, dependencies, and public documentation links.
* `docs/CONTEXT.md`, the architecture diagram and data flow narrative for the SDK.

If you are an AI agent, read `foundations/AGENTS.md` first.

Top related repos:

* Upstream: none verified in this repo today; owner confirmation pending.
* Downstream: host React Native APP repos that integrate this package.
* Sibling: the underlying ROOK native SDK repos or package sources; exact repo mapping pending owner confirmation.
* Shared infra: `docs.tryrook.io` for public React Native SDK documentation.

If you change an exported API, permission flow, or native dependency, update the manifest and the example APP in the same PR.

## Architecture

The SDK has three main layers:

* A TypeScript surface that exports `RookSdk`, `RookSyncGate`, and `useRook*` hooks from `src/`.
* An iOS bridge in `ios/` backed by the `RookSDK` pod.
* An Android bridge in `android/` backed by ROOK Health Connect, Samsung Health, and API Sources libraries.

See `docs/CONTEXT.md` for the Mermaid diagram and flow details.

## Tech stack

* TypeScript, React Native, Turbo Modules, and Yarn workspaces.
* Kotlin for the Android bridge and Swift or Objective-C++ for the iOS bridge.
* Jest for unit tests.
* Bitbucket Pipelines for CI and npm publication.
* `react-native-builder-bob` for package builds.
* Public package distribution through npm.

## Setup

Prerequisites:

* Node.js `v22.20.0` from `.nvmrc`.
* Corepack, Yarn `4.11.0`, and the Node.js version from `.nvmrc` (`v22.20.0`).
* JDK 17 for Android builds.
* Xcode 26.0 and CocoaPods for iOS builds.

Local install:

```sh
yarn install --immutable
cd example
bundle install
bundle exec pod install --project-directory=ios
cd ..
```

## Run

Use the example APP for manual validation:

```sh
yarn example start
yarn example android
yarn example ios
```

## Test

```sh
yarn lint
yarn typecheck
yarn test --coverage
yarn prepare
```

CI also builds the example APP for Android and iOS through Turbo tasks defined in the repo workflow.

Coverage threshold for this repo: 60 percent on new code per the current SonarCloud Stage A target in the playbook. Current repo reality is lower because only `src/__tests__/index.test.tsx` exists today as a placeholder, so meaningful test work is still pending.

## Endpoints

This repo does not expose an HTTP API or an OpenAPI contract. It is an SDK package.

## Configuration

The main runtime inputs come from `RookSyncGate` and `NativeRookSdk`:

* `environment`: `sandbox` or `production`.
* `clientUUID`: ROOK client identifier.
* `secret`: ROOK client secret.
* `bundleId`: iOS host APP bundle identifier.
* `packageName`: Android host APP package name.
* `enableLogs`: opt-in local logging.
* `enableBackgroundSync`: background sync toggle for supported flows.

Do not commit real credentials. Keep secrets in local development tooling only.

Create the ignored example credentials file before running the example APP:

```sh
cp example/src/utils/credentials.example.ts example/src/utils/credentials.ts
```

Replace the placeholder values in `credentials.ts` with your local sandbox credentials. CI uses the committed template only for static type-checking and builds; it does not require or publish real credentials.

## Deployment

This repo is published as a versioned npm package. Bitbucket CI in `bitbucket-pipelines.yml` validates lint, typecheck, Jest coverage, package build, committed secrets, and both example APP builds before merge. Stable tags at the head of `release/X.Y` publish through the tag pipeline. See `docs/RELEASE_WORKFLOW.md` for the branch model and release procedure.

## Operational notes

* `README.md` was previously a generated placeholder and did not describe the real exported API.
* The test command is wired in CI, but the current suite is not representative of the SDK surface yet.
* Android `initRook` maps `environment=production` to production for Health Connect and API Sources, but Samsung still uses sandbox in `android/src/main/java/com/rooksdk/RookSdkModule.kt`; owner confirmation is still needed before that behavior is treated as intentional.
* Public docs are referenced from code at `docs.tryrook.io`, but the full page inventory still needs owner confirmation.

## Owners

Current inferred owner from package metadata:

* Javier Villanueva, `javier.villanueva@tryrook.io`

Tech lead and CODEOWNERS still need explicit confirmation in `repo-profile.yaml` and `service-manifest.yaml`.

## Related

* `CONTRIBUTING.md`
* `docs/RELEASE_WORKFLOW.md`
* `foundations/`
* `docs/CONTEXT.md`
* `service-manifest.yaml`
* `https://docs.tryrook.io/docs/category/reactnative`

## License

MIT
