react-native-genesisdb
v0.1.2
Published
Embedded GenesisBlockDB for React Native (MARK XVI Phase B-3) — local-first hybrid semantic-graph engine, no server required.
Maintainers
Readme
react-native-genesisdb
Embedded GenesisBlockDB for React Native (MARK XVI Phase B-3) — local-first hybrid semantic-graph engine, no server required. See docs/SPEC--MOBILE-SDK.md §B-3.
import { GenesisDB } from 'react-native-genesisdb';
const db = await GenesisDB.open(`${DocumentDirectoryPath}/genesisdb`);
const node = await db.addNode({ labels: ['Person'], props: { name: 'Ada' } });
const ctx = await db.retrieveContext(node.id, 'H1');
await db.close();Platform status
| Platform | Status |
|---|---|
| Android | Working — npm install is enough. Bridges to io.github.freshair129:genesisdb-android (Phase B-2) on Maven Central, which resolves anonymously. No GitHub token, no extra repository declaration. |
| iOS | Working — pod install is enough. The Swift SDK sources are vendored into this pod (ios/vendor/), so it is self-contained: no Swift Package to add in Xcode, no monorepo checkout required. See iOS integration status. |
Installation — Android
npm install react-native-genesisdb is all it takes. The native .aar this
package bridges to is on Maven Central
(io.github.freshair129:genesisdb-android:0.1.1), which resolves anonymously,
so mavenCentral() — already in every React Native app's Gradle setup — is
enough. There is nothing to add to gradle.properties.
(0.1.1 is the first version carrying the x86_64 slice the standard Android
Studio emulator needs — see android/README.md.)
This used to require a GitHub personal access token. Until 0.1.1 was published to Central, the
.aarwas only on GitHub Packages, which demands authentication for every read even from a public repository — so every consumer had to create aread:packagesPAT and putgpr.user/gpr.keyin~/.gradle/gradle.properties. If you set that up for an earlier version you can delete both lines; this package no longer declares that repository.The Maven groupId (
io.github.freshair129) differs from the Kotlin package (dev.genesisblock) because Central requires a namespace whose ownership can be proven, andgenesisblock.devbelongs to an unrelated business. The two are independent identifiers — renaming the package to match would break the JNI symbols, which mangle from the class's fully-qualified name. Your imports are unaffected.
iOS integration status
GenesisDbModule.swift is real code, not a stub, and its logic mirrors the
Android bridge method-for-method. pod install is now sufficient on its own —
both of the pieces that previously were not are resolved:
~~
GenesisBlockDB.xcframeworkneeds aprepare_commandto fetch it duringpod install.~~ Done (issue #125):react-native-genesisdb.podspec'sprepare_commandnow downloads, SHA256-verifies, and unzips the v0.2.0 release'sGenesisBlockDB.xcframework.zipautomatically — no manual step. (An earlier version of this doc also said the podspec would need a CocoaPods Trunk publish first; that was wrong — RN autolinking'suse_native_modules!picks up this podspec directly fromnode_modules, the same way virtually every third-party RN native module ships its iOS half, with zero Trunk publish involved.)~~The Swift package this module imports is not in the npm tarball.~~ Fixed.
GenesisDbModule.swiftused to doimport GenesisDB/import GenesisDBTypes— products of the monorepo'sios/genesisdbpackage, which sits one level above this package's root and so could never be included by npm. The result was thatpod installsucceeded and the build then failed with "no such module 'GenesisDB'" for everyone who installed from npm; only a monorepo checkout worked, via a manual "Add Package Dependency" step in Xcode.CocoaPods cannot express a dependency on a Swift Package, so there was no podspec-level fix. Instead the SDK sources are now vendored into this pod at
ios/vendor/, generated byscripts/vendor-rn-ios-sdk.mjs. Sinces.source_filesalready globsios/**/*.swift, they compile into this pod's own module — so the bridge needs no import at all, and the pod is self-contained.The vendoring rewrites the SPM module imports:
import GenesisDBTypesis dropped (same module now) andimport CGenesisDBFFIbecomesimport GenesisBlockDB, the Clang module the published xcframework vends viainclude/module.modulemap.Do not edit
ios/vendor/*.swift— edit the originals under../ios/genesisdb/Sources/and re-run the script. CI jobrn-ios-vendor-freshnessfails if the copies drift.
What CI does and does not verify
rn-ios-vendor-freshness proves the vendored copies match their originals, and
rn-ios-pod-typecheck compiles them for the iOS Simulator against the
published xcframework the podspec actually downloads — the combination that a
real pod install produces, and the gate that would have caught the bug above.
Still not covered: a full pod install in a real RN host app (there is none in
this monorepo), and android/build.gradle's Maven resolution. That gap is why
both 0.1.0 breakages shipped unnoticed.
Publishing
.github/workflows/release.yml's rn-npm-publish job publishes this package
to npm (unscoped react-native-genesisdb, --tag beta) on every v* tag
push, reusing the same NPM_TOKEN secret the main native-addon package
publishes with (issue #125).
That job has run: [email protected] was published from the
v0.2.2 tag. Re-publishing an unchanged version is correctly rejected by the
registry with 403 You cannot publish over the previously published
versions, so later tags no-op unless the version in package.json is bumped.
That is why this package is at 0.1.1. 0.1.0 is the version currently
on npm, and it is the one with both integration breakages — the Android
repository declaration and the iOS module imports were fixed on main after
it shipped, so those fixes do not reach a single npm consumer until a tag
push publishes 0.1.1. Bumping the version is the delivery mechanism, not
bookkeeping.
Wire format
All types in src/types.ts are snake_case, matching the engine's raw
serde_json output (valid_from, query_vector, ...) — not the camelCase
used by the Node addon's index.d.ts (a napi-rs-only convention). See the
doc comment at the top of src/types.ts for why a generic camelCase
conversion layer was deliberately not built (it would corrupt keys inside the
opaque props field).
Testing
src/__tests__/index.test.ts runs under plain Jest against a stubbed
react-native module (src/__mocks__/react-native.ts) — no native build,
no simulator/emulator, no RN runtime. Run with npm test.
The vendored iOS SDK sources are type-checked against the published
xcframework by rn-ios-pod-typecheck (see "What CI does and does not
verify" above). Beyond that, the android/ and ios/ native module sources
are validated only by building them inside a real RN host app, which this
monorepo has none of — the same host-only carve-out as the rest of the
mobile SDK (see .github/workflows/mobile-build.yml).
