Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

FileSystem

class FileSystem implements API {
constructor({ account, dependencies, eventEmitter, root, localOnly }: ConstructorParams);
_publishing: false | [CID, true];
_publishWhenOnline: Array<[CID, Ucan.Ucan]>;
account: AssociatedIdentity;
dependencies: Dependencies;
eventEmitter: EventEmitter<Events.FileSystem>;
readonly localOnly: boolean;
proofs: {
[_: string]: Ucan.Ucan;
}
;
publishHooks: Array<PublishHook>;
root: RootTree;
 
_beforeLeaving(e: Event): void | string;
_whenOnline(): void;
acceptShare({ shareId, sharedBy }: {
shareId: string;
sharedBy: string;
}
): Promise<this>;
checkMutationPermissionAndAddProof(path: DistinctivePath<Partitioned<Partition>>, isMutation: boolean): Promise<void>;
deactivate(): void;
exists(path: Path.Distinctive<PartitionedNonEmpty<Partition>>): Promise<boolean>;
get(path: Path.Distinctive<Partitioned<Partition>>): Promise<PuttableUnixTree | File | null>;
historyStep(): Promise<void>;
loadShare({ shareId, sharedBy }: {
shareId: string;
sharedBy: string;
}
): Promise<UnixTree>;
ls(path: Path.Directory<Partitioned<Partition>>): Promise<Links>;
mkdir(path: Path.Directory<PartitionedNonEmpty<Partition>>, options?: MutationOptions): Promise<this>;
mv(from: Path.Distinctive<PartitionedNonEmpty<Partition>>, to: Path.Distinctive<PartitionedNonEmpty<Partition>>): Promise<this>;
publish(): Promise<CID>;
read(path: Path.File<PartitionedNonEmpty<Partition>>): Promise<Uint8Array>;
resolveSymlink(link: SoftLink): Promise<File | Tree | null>;
rm(path: DistinctivePath<Partitioned<Partition>>): Promise<this>;
runMutationOnNode(path: DistinctivePath<Partitioned<Partition>>, handlers: {
public(root: UnixTree, relPath: Path.Segments): Promise<void>;
private(node: PrivateTree | PrivateFile, relPath: Path.Segments): Promise<void>;
}
): Promise<void>;
runOnChildTree(
node: Tree,
relPath: Path.Segments,
fn: (tree: Tree) => Promise<Tree>,
): Promise<Tree>;
runOnNode<A>(path: DistinctivePath<Partitioned<Partition>>, handlers: {
public(root: UnixTree, relPath: Path.Segments): Promise<A>;
private(node: Tree | File, relPath: Path.Segments): Promise<A>;
}
): Promise<A>;
sharePrivate(paths: Path.Distinctive<Path.PartitionedNonEmpty<Path.Private>>[], { sharedBy, shareWith }: {
sharedBy?: SharedBy;
shareWith: string | string[];
}
): Promise<ShareDetails>;
symlink(args: {
at: Path.Directory<Partitioned<Partition>>;
referringTo: {
path: Path.Distinctive<Partitioned<Partition>>;
username?: string;
}
;
name: string;
}
): Promise<this>;
write(
path: Path.Distinctive<Partitioned<Partition>>,
content:
| Uint8Array
| SoftLink
| SoftLink[]
| Record<string, SoftLink>
,
options?: MutationOptions,
): Promise<this>;
 
static empty(opts: NewFileSystemOptions): Promise<FileSystem>;
static fromCID(cid: CID, opts: FileSystemOptions): Promise<FileSystem>;
}

§Implements

§Constructors

§
new FileSystem({ account, dependencies, eventEmitter, root, localOnly }: ConstructorParams)
[src]

§Properties

§
_publishing: false | [CID, true]
[src]
§
_publishWhenOnline: Array<[CID, Ucan.Ucan]>
[src]
§
account: AssociatedIdentity
[src]
§
dependencies: Dependencies
[src]
§
eventEmitter: EventEmitter<Events.FileSystem>
[src]
§
localOnly: boolean
[src]
§
proofs: {
[_: string]: Ucan.Ucan;
}
[src]
§
publishHooks: Array<PublishHook>
[src]
§
root: RootTree
[src]

§Methods

§
_beforeLeaving(e: Event): void | string
[src]
§
_whenOnline(): void
[src]
§
acceptShare({ shareId, sharedBy }: {
shareId: string;
sharedBy: string;
}
): Promise<this>
[src]

Accept a share. Copies the links to the items into your 'Shared with me' directory. eg. private/Shared with me/Sharer/

§
checkMutationPermissionAndAddProof(path: DistinctivePath<Partitioned<Partition>>, isMutation: boolean): Promise<void>
[src]
§
deactivate(): void
[src]

Deactivate a file system.

Use this when a user signs out. The only function of this is to stop listing to online/offline events.

§
exists(path: Path.Distinctive<PartitionedNonEmpty<Partition>>): Promise<boolean>
[src]
§
get(path: Path.Distinctive<Partitioned<Partition>>): Promise<PuttableUnixTree | File | null>
[src]
§
historyStep(): Promise<void>
[src]

Ensures the current version of your file system is "committed" and stepped forward, so the current version will always be persisted as an "step" in the history of the file system.

This function is implicitly called every time your file system changes are synced, so in most cases calling this is handled for you.

§
loadShare({ shareId, sharedBy }: {
shareId: string;
sharedBy: string;
}
): Promise<UnixTree>
[src]

Loads a share. Returns a "entry index", in other words, a private tree with symlinks (soft links) to the shared items.

§
ls(path: Path.Directory<Partitioned<Partition>>): Promise<Links>
[src]
§
mkdir(path: Path.Directory<PartitionedNonEmpty<Partition>>, options?: MutationOptions): Promise<this>
[src]
§
mv(from: Path.Distinctive<PartitionedNonEmpty<Partition>>, to: Path.Distinctive<PartitionedNonEmpty<Partition>>): Promise<this>
[src]
§
publish(): Promise<CID>
[src]

Ensures the latest version of the file system is added to IPFS, updates your data root, and returns the root CID.

§
read(path: Path.File<PartitionedNonEmpty<Partition>>): Promise<Uint8Array>
[src]
§
rm(path: DistinctivePath<Partitioned<Partition>>): Promise<this>
[src]
§
runMutationOnNode(path: DistinctivePath<Partitioned<Partition>>, handlers: {
public(root: UnixTree, relPath: Path.Segments): Promise<void>;
private(node: PrivateTree | PrivateFile, relPath: Path.Segments): Promise<void>;
}
): Promise<void>
[src]
§
runOnChildTree(node: Tree, relPath: Path.Segments, fn: (tree: Tree) => Promise<Tree>): Promise<Tree>
[src]
§
runOnNode<A>(path: DistinctivePath<Partitioned<Partition>>, handlers: {
public(root: UnixTree, relPath: Path.Segments): Promise<A>;
private(node: Tree | File, relPath: Path.Segments): Promise<A>;
}
): Promise<A>
[src]
§
sharePrivate(paths: Path.Distinctive<Path.PartitionedNonEmpty<Path.Private>>[], { sharedBy, shareWith }: {
sharedBy?: SharedBy;
shareWith: string | string[];
}
): Promise<ShareDetails>
[src]

Share a private file with a user.

§
write(path: Path.Distinctive<Partitioned<Partition>>, content: Uint8Array | SoftLink | SoftLink[] | Record<string, SoftLink>, options?: MutationOptions): Promise<this>
[src]

§Static Methods

§
empty(opts: NewFileSystemOptions): Promise<FileSystem>
[src]

Creates a file system with an empty public tree & an empty private tree at the root.

§
fromCID(cid: CID, opts: FileSystemOptions): Promise<FileSystem>
[src]

Loads an existing file system from a CID.