Implementation:0xranx OpenContext NAPI TypeScript Definitions
| Knowledge Sources | |
|---|---|
| Domains | Native_Bindings, TypeScript |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
TypeScript type definitions for the NAPI-RS native bindings, providing fully typed interfaces for all OpenContext store, folder, document, search, and index sync operations.
Description
The index.d.ts file in crates/opencontext-node/ is auto-generated by NAPI-RS and declares TypeScript interfaces and function signatures for every exported binding. It covers folder operations (FolderOptions, RenameFolderOptions, MoveFolderOptions, RemoveFolderOptions), document operations (CreateDocOptions, SaveDocOptions, ManifestOptions), search (SearchOptions, Searcher class, Indexer class), and index sync (startIndexSync, isIndexSyncRunning, getIndexSyncStatus). All functions return NapiResult, a unified result wrapper.
Usage
Import these types in TypeScript projects that consume the native bindings directly, to get compile-time type checking on all store and search API calls.
Code Reference
Source Location
- Repository: 0xranx_OpenContext
- File: crates/opencontext-node/index.d.ts
- Lines: 1-134
Signature
export interface FolderOptions { path: string; description?: string }
export interface RenameFolderOptions { path: string; newName: string }
export interface MoveFolderOptions { path: string; destFolderPath: string }
export interface RemoveFolderOptions { path: string; force?: boolean }
export interface CreateDocOptions { folderPath: string; name: string; description?: string }
export interface SaveDocOptions { docPath: string; content: string; description?: string }
export interface ManifestOptions { folderPath: string; limit?: number }
export interface SearchOptions { query: string; limit?: number; mode?: string; aggregateBy?: string; docType?: string }
export declare function initEnvironment(): NapiResult
export declare function listFolders(options?: ListFolderOptions): NapiResult
export declare function createFolder(options: FolderOptions): NapiResult
export declare function createDoc(options: CreateDocOptions): NapiResult
export declare function saveDocContent(options: SaveDocOptions): NapiResult
export declare function generateManifest(options: ManifestOptions): NapiResult
export declare function loadSearchConfig(): any
export declare function startIndexSync(intervalSecs?: number | null): Promise<boolean>
export declare function isIndexSyncRunning(): boolean
export declare function getIndexSyncStatus(): any
export declare class Searcher {
static create(): Promise<Searcher>
search(options: SearchOptions): Promise<any>
}
export declare class Indexer {
static create(): Promise<Indexer>
buildAll(): Promise<any>
indexFile(relPath: string): Promise<number>
removeFile(relPath: string): Promise<void>
indexExists(): Promise<boolean>
getStats(): Promise<any>
clean(): Promise<void>
}
Import
import {
initEnvironment, listFolders, createFolder, createDoc,
Searcher, Indexer, startIndexSync, FolderOptions, SearchOptions
} from '@aicontextlab/core-native';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| options | FolderOptions / CreateDocOptions / etc. | Yes (most) | Typed options object per operation |
| intervalSecs | null | No | Index sync interval in seconds (default 300) |
Outputs
| Name | Type | Description |
|---|---|---|
| NapiResult | Unified result wrapper from native calls | |
| Searcher | Async search executor with search() method | |
| Indexer | Async index builder with buildAll, indexFile, removeFile, etc. |
Usage Examples
Typed Folder and Document Operations
import { initEnvironment, createFolder, createDoc } from '@aicontextlab/core-native';
initEnvironment();
const folder = createFolder({ path: 'project', description: 'My project' });
const doc = createDoc({ folderPath: 'project', name: 'readme', description: 'README' });
Typed Search
import { Searcher, SearchOptions } from '@aicontextlab/core-native';
const searcher = await Searcher.create();
const opts: SearchOptions = { query: 'neural network', limit: 5, mode: 'hybrid' };
const results = await searcher.search(opts);