SnapshotFileSystem Interface
The file system methods required by checkSchemaCompatibilitySnapshots(options).
To use, import via fluid-framework/alpha.
For more information about our API support guarantees, see here.
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
| Method | Alerts | Return Type | Description |
|---|---|---|---|
| join(parentPath, childPath) | Alpha | string | Joins two path segments into a single path string. |
| mkdirSync(dir, options) | Alpha | void | How a TreeView using the snapshotted schema would report its compatibility with a document created with the current schema. |
| readdirSync(dir) | Alpha | readonly string[] | Reads the contents of a directory. |
| readFileSync(file, encoding) | Alpha | string | Reads a UTF-8 encoded file from disk and returns its contents as a string. |
| writeFileSync(file, data, options) | Alpha | void | Writes 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.
For more information about our API support guarantees, see here.
Signature
join(parentPath: string, childPath: string): string;
Parameters
| Parameter | Type | Description |
|---|---|---|
| parentPath | string | The directory path. |
| childPath | string | Filename 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.
For more information about our API support guarantees, see here.
Signature
mkdirSync(dir: string, options: {
recursive: true;
}): void;
Parameters
| Parameter | Type | Description |
|---|---|---|
| dir | string | Path of the directory to create. |
| options | { recursive: true; } | Options indicating that creation should be recursive. |
readdirSync
Reads the contents of a directory.
For more information about our API support guarantees, see here.
Signature
readdirSync(dir: string): readonly string[];
Parameters
| Parameter | Type | Description |
|---|---|---|
| dir | string | Path 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.
For more information about our API support guarantees, see here.
Signature
readFileSync(file: string, encoding: "utf8"): string;
Parameters
| Parameter | Type | Description |
|---|---|---|
| file | string | Path 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.
For more information about our API support guarantees, see here.
Signature
writeFileSync(file: string, data: string, options: {
encoding: "utf8";
}): void;
Parameters
| Parameter | Type | Description |
|---|---|---|
| file | string | Path to the file to write. |
| data | string | String data to be written. |
| options | { encoding: "utf8"; } | Options specifying that the encoding is UTF-8. |