Skip to main content

SnapshotFileSystem Interface

The file system methods required by snapshotSchemaCompatibility(options).

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Input

This type is "input," meaning that code outside of the library defining it should not read from it. Future versions of this type may add optional members or make typing of members more general.

Signature​

export interface SnapshotFileSystem

Remarks​

Implemented by both Node.js fs and path modules, but other implementations can be provided as needed.

Example​

import path from "node:path";
import fs from "node:fs";

const nodeFileSystem: SnapshotFileSystem = { ...fs, ...path };

Methods​

MethodAlertsReturn TypeDescription
join(parentPath, childPath)BetastringJoins two path segments into a single path string.
mkdirSync(dir, options)BetavoidHow a TreeView using the snapshotted schema would report its compatibility with a document created with the current schema.
readdirSync(dir)Betareadonly string[]Reads the contents of a directory.
readFileSync(file, encoding)BetastringReads a UTF-8 encoded file from disk and returns its contents as a string.
writeFileSync(file, data, options)BetavoidWrites a UTF-8 encoded file to disk, replacing the file if it already exists.

Method Details​

join​

Joins two path segments into a single path string.

This API is provided as a beta preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

join(parentPath: string, childPath: string): string;

Parameters​

ParameterTypeDescription
parentPathstringThe directory path.
childPathstringFilename within parentPath directory.

Returns​

The combined path string.

Return type: string

mkdirSync​

How a TreeView using the snapshotted schema would report its compatibility with a document created with the current schema.

This API is provided as a beta preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

mkdirSync(dir: string, options: {
recursive: true;
}): void;

Parameters​

ParameterTypeDescription
dirstringPath of the directory to create.
options{ recursive: true; }Options indicating that creation should be recursive.

readdirSync​

Reads the contents of a directory.

This API is provided as a beta preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

readdirSync(dir: string): readonly string[];

Parameters​

ParameterTypeDescription
dirstringPath of the directory to read.

Returns​

An array of names of the directory entries.

Return type: readonly string[]

readFileSync​

Reads a UTF-8 encoded file from disk and returns its contents as a string.

This API is provided as a beta preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

readFileSync(file: string, encoding: "utf8"): string;

Parameters​

ParameterTypeDescription
filestringPath to the file to read.
encoding"utf8"The text encoding to use when reading the file. Must be "utf8".

Returns​

The contents of the file as a string.

Return type: string

writeFileSync​

Writes a UTF-8 encoded file to disk, replacing the file if it already exists.

This API is provided as a beta preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

writeFileSync(file: string, data: string, options: {
encoding: "utf8";
}): void;

Parameters​

ParameterTypeDescription
filestringPath to the file to write.
datastringString data to be written.
options{ encoding: "utf8"; }Options specifying that the encoding is UTF-8.