mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-06-12 01:10:15 +00:00
add type defs for community automatic review
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
import type { DatabaseFileAccess } from "@lib/interfaces/DatabaseFileAccess.ts";
|
||||
import { ServiceDatabaseFileAccessBase } from "@lib/serviceModules/ServiceDatabaseFileAccessBase";
|
||||
export declare class ServiceDatabaseFileAccess extends ServiceDatabaseFileAccessBase implements DatabaseFileAccess {
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { type App } from "@/deps";
|
||||
import { FileAccessBase, type FileAccessBaseDependencies } from "@lib/serviceModules/FileAccessBase.ts";
|
||||
import { ObsidianFileSystemAdapter } from "./FileSystemAdapters/ObsidianFileSystemAdapter";
|
||||
/**
|
||||
* Obsidian-specific implementation of FileAccessBase
|
||||
* Uses ObsidianFileSystemAdapter for platform-specific operations
|
||||
*/
|
||||
export declare class FileAccessObsidian extends FileAccessBase<ObsidianFileSystemAdapter> {
|
||||
constructor(app: App, dependencies: FileAccessBaseDependencies);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { ServiceFileHandlerBase } from "@lib/serviceModules/ServiceFileHandlerBase";
|
||||
export declare class ServiceFileHandler extends ServiceFileHandlerBase {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { UXFileInfoStub, UXFolderInfo } from "@lib/common/models/fileaccess.type";
|
||||
import type { IConversionAdapter } from "@lib/serviceModules/adapters";
|
||||
import type { TFile, TFolder } from "obsidian";
|
||||
/**
|
||||
* Conversion adapter implementation for Obsidian
|
||||
*/
|
||||
export declare class ObsidianConversionAdapter implements IConversionAdapter<TFile, TFolder> {
|
||||
nativeFileToUXFileInfoStub(file: TFile): UXFileInfoStub;
|
||||
nativeFolderToUXFolder(folder: TFolder): UXFolderInfo;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { FilePath } from "@lib/common/models/db.type";
|
||||
import type { UXStat } from "@lib/common/models/fileaccess.type";
|
||||
import type { IFileSystemAdapter, IPathAdapter, ITypeGuardAdapter, IConversionAdapter, IStorageAdapter, IVaultAdapter } from "@lib/serviceModules/adapters";
|
||||
import type { TAbstractFile, TFile, TFolder, Stat, App } from "obsidian";
|
||||
declare module "obsidian" {
|
||||
interface Vault {
|
||||
getAbstractFileByPathInsensitive(path: string): TAbstractFile | null;
|
||||
}
|
||||
interface DataAdapter {
|
||||
reconcileInternalFile?(path: string): Promise<void>;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Complete file system adapter implementation for Obsidian
|
||||
*/
|
||||
export declare class ObsidianFileSystemAdapter implements IFileSystemAdapter<TAbstractFile, TFile, TFolder, Stat> {
|
||||
private app;
|
||||
readonly path: IPathAdapter<TAbstractFile>;
|
||||
readonly typeGuard: ITypeGuardAdapter<TFile, TFolder>;
|
||||
readonly conversion: IConversionAdapter<TFile, TFolder>;
|
||||
readonly storage: IStorageAdapter<Stat>;
|
||||
readonly vault: IVaultAdapter<TFile>;
|
||||
constructor(app: App);
|
||||
getAbstractFileByPath(path: FilePath | string): Promise<TAbstractFile | null>;
|
||||
getAbstractFileByPathInsensitive(path: FilePath | string): Promise<TAbstractFile | null>;
|
||||
getFiles(): Promise<TFile[]>;
|
||||
statFromNative(file: TFile): Promise<UXStat>;
|
||||
reconcileInternalFile(path: string): Promise<void>;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { type TAbstractFile } from "@/deps";
|
||||
import type { FilePath } from "@lib/common/models/db.type";
|
||||
import type { IPathAdapter } from "@lib/serviceModules/adapters";
|
||||
/**
|
||||
* Path adapter implementation for Obsidian
|
||||
*/
|
||||
export declare class ObsidianPathAdapter implements IPathAdapter<TAbstractFile> {
|
||||
getPath(file: string | TAbstractFile): FilePath;
|
||||
normalisePath(path: string): string;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import type { UXDataWriteOptions } from "@lib/common/models/fileaccess.type";
|
||||
import type { IStorageAdapter } from "@lib/serviceModules/adapters";
|
||||
import type { Stat, App } from "obsidian";
|
||||
/**
|
||||
* Storage adapter implementation for Obsidian
|
||||
*/
|
||||
export declare class ObsidianStorageAdapter implements IStorageAdapter<Stat> {
|
||||
private app;
|
||||
constructor(app: App);
|
||||
exists(path: string): Promise<boolean>;
|
||||
trystat(path: string): Promise<Stat | null>;
|
||||
stat(path: string): Promise<Stat | null>;
|
||||
mkdir(path: string): Promise<void>;
|
||||
remove(path: string): Promise<void>;
|
||||
read(path: string): Promise<string>;
|
||||
readBinary(path: string): Promise<ArrayBuffer>;
|
||||
write(path: string, data: string, options?: UXDataWriteOptions): Promise<void>;
|
||||
writeBinary(path: string, data: ArrayBuffer, options?: UXDataWriteOptions): Promise<void>;
|
||||
append(path: string, data: string, options?: UXDataWriteOptions): Promise<void>;
|
||||
list(basePath: string): Promise<{
|
||||
files: string[];
|
||||
folders: string[];
|
||||
}>;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { ITypeGuardAdapter } from "@lib/serviceModules/adapters";
|
||||
import { TFile, TFolder } from "obsidian";
|
||||
/**
|
||||
* Type guard adapter implementation for Obsidian
|
||||
*/
|
||||
export declare class ObsidianTypeGuardAdapter implements ITypeGuardAdapter<TFile, TFolder> {
|
||||
isFile(file: unknown): file is TFile;
|
||||
isFolder(item: unknown): item is TFolder;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { UXDataWriteOptions } from "@lib/common/models/fileaccess.type";
|
||||
import type { IVaultAdapter } from "@lib/serviceModules/adapters";
|
||||
import type { TFile, App, TFolder } from "obsidian";
|
||||
/**
|
||||
* Vault adapter implementation for Obsidian
|
||||
*/
|
||||
export declare class ObsidianVaultAdapter implements IVaultAdapter<TFile> {
|
||||
private app;
|
||||
constructor(app: App);
|
||||
read(file: TFile): Promise<string>;
|
||||
cachedRead(file: TFile): Promise<string>;
|
||||
readBinary(file: TFile): Promise<ArrayBuffer>;
|
||||
modify(file: TFile, data: string, options?: UXDataWriteOptions): Promise<void>;
|
||||
modifyBinary(file: TFile, data: ArrayBuffer, options?: UXDataWriteOptions): Promise<void>;
|
||||
create(path: string, data: string, options?: UXDataWriteOptions): Promise<TFile>;
|
||||
createBinary(path: string, data: ArrayBuffer, options?: UXDataWriteOptions): Promise<TFile>;
|
||||
delete(file: TFile | TFolder, force?: boolean): Promise<void>;
|
||||
trash(file: TFile | TFolder, force?: boolean): Promise<void>;
|
||||
trigger(name: string, ...data: any[]): any;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { ServiceFileAccessBase } from "@lib/serviceModules/ServiceFileAccessBase";
|
||||
import type { ObsidianFileSystemAdapter } from "./FileSystemAdapters/ObsidianFileSystemAdapter";
|
||||
export declare class ServiceFileAccessObsidian extends ServiceFileAccessBase<ObsidianFileSystemAdapter> {
|
||||
}
|
||||
Reference in New Issue
Block a user