@sqliteai/sqlite-sync
Version:
SQLite Sync extension for Node.js - Sync on-device databases with the cloud
85 lines (82 loc) • 2.69 kB
TypeScript
/**
* Supported platform identifiers
*/
type Platform = 'darwin-arm64' | 'darwin-x86_64' | 'linux-arm64' | 'linux-arm64-musl' | 'linux-x86_64' | 'linux-x86_64-musl' | 'win32-x86_64';
/**
* Detects if the system uses musl libc (Alpine Linux, etc.)
* Uses multiple detection strategies for reliability
*/
declare function isMusl(): boolean;
/**
* Gets the current platform identifier
* @throws {Error} If the platform is unsupported
*/
declare function getCurrentPlatform(): Platform;
/**
* Gets the package name for the current platform
*/
declare function getPlatformPackageName(): string;
/**
* Gets the binary filename for the current platform
*/
declare function getBinaryName(): string;
/**
* Error thrown when the SQLite Sync extension cannot be found
*/
declare class ExtensionNotFoundError extends Error {
constructor(message: string);
}
/**
* Gets the absolute path to the SQLite Sync extension binary for the current platform
*
* @returns Absolute path to the extension binary (.so, .dylib, or .dll)
* @throws {ExtensionNotFoundError} If the extension binary cannot be found
*
* @example
* ```typescript
* import { getExtensionPath } from '@sqliteai/sqlite-sync';
*
* const extensionPath = getExtensionPath();
* // On macOS ARM64: /path/to/node_modules/@sqliteai/sqlite-sync-darwin-arm64/cloudsync.dylib
* ```
*/
declare function getExtensionPath(): string;
/**
* Information about the current platform and extension
*/
interface ExtensionInfo {
/** Current platform identifier (e.g., 'darwin-arm64') */
platform: Platform;
/** Name of the platform-specific npm package */
packageName: string;
/** Filename of the binary (e.g., 'cloudsync.dylib') */
binaryName: string;
/** Full path to the extension binary */
path: string;
}
/**
* Gets detailed information about the SQLite Sync extension
*
* @returns Extension information object
*
* @example
* ```typescript
* import { getExtensionInfo } from '@sqliteai/sqlite-sync';
*
* const info = getExtensionInfo();
* console.log(info);
* // {
* // platform: 'darwin-arm64',
* // packageName: '@sqliteai/sqlite-sync-darwin-arm64',
* // binaryName: 'cloudsync.dylib',
* // path: '/path/to/cloudsync.dylib'
* // }
* ```
*/
declare function getExtensionInfo(): ExtensionInfo;
declare const _default: {
getExtensionPath: typeof getExtensionPath;
getExtensionInfo: typeof getExtensionInfo;
ExtensionNotFoundError: typeof ExtensionNotFoundError;
};
export { type ExtensionInfo, ExtensionNotFoundError, type Platform, _default as default, getBinaryName, getCurrentPlatform, getExtensionInfo, getExtensionPath, getPlatformPackageName, isMusl };