@zenfs/core 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -154,6 +154,7 @@ export declare class IndexDirInode<T> extends IndexInode<T> {
154
154
  remove(p: string): IndexInode<T> | null;
155
155
  }
156
156
  declare const FileIndexFS_base: (abstract new (...args: any[]) => {
157
+ metadata(): import("./filesystem.js").FileSystemMetadata;
157
158
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
158
159
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
159
160
  createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<import("./file.js").File>;
@@ -168,16 +169,6 @@ declare const FileIndexFS_base: (abstract new (...args: any[]) => {
168
169
  linkSync(srcpath: string, dstpath: string, cred: Cred): void;
169
170
  sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
170
171
  syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
171
- readonly metadata: import("./filesystem.js").FileSystemMetadata;
172
- ready(): Promise<any>;
173
- stat(path: string, cred: Cred): Promise<Stats>;
174
- statSync(path: string, cred: Cred): Stats;
175
- openFile(path: string, flag: FileFlag, cred: Cred): Promise<import("./file.js").File>;
176
- openFileSync(path: string, flag: FileFlag, cred: Cred): import("./file.js").File;
177
- readdir(path: string, cred: Cred): Promise<string[]>;
178
- readdirSync(path: string, cred: Cred): string[];
179
- exists(path: string, cred: Cred): Promise<boolean>;
180
- existsSync(path: string, cred: Cred): boolean;
181
172
  }) & typeof FileSystem;
182
173
  export declare abstract class FileIndexFS<TIndex> extends FileIndexFS_base {
183
174
  protected _index: FileIndex<TIndex>;
@@ -194,7 +185,7 @@ export declare abstract class FileIndexFS<TIndex> extends FileIndexFS_base {
194
185
  protected abstract fileForFileInodeSync(inode: IndexFileInode<TIndex>): NoSyncFile<this>;
195
186
  }
196
187
  declare const SyncFileIndexFS_base: (abstract new (...args: any[]) => {
197
- readonly metadata: import("./filesystem.js").FileSystemMetadata;
188
+ metadata(): import("./filesystem.js").FileSystemMetadata;
198
189
  ready(): Promise<any>;
199
190
  exists(path: string, cred: Cred): Promise<boolean>;
200
191
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
@@ -224,6 +215,7 @@ export declare abstract class SyncFileIndexFS<TIndex> extends SyncFileIndexFS_ba
224
215
  protected fileForFileInode(inode: IndexFileInode<TIndex>): Promise<NoSyncFile<this>>;
225
216
  }
226
217
  declare const AsyncFileIndexFS_base: (abstract new (...args: any[]) => {
218
+ metadata(): import("./filesystem.js").FileSystemMetadata;
227
219
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
228
220
  statSync(path: string, cred: Cred): Stats;
229
221
  createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): import("./file.js").File;
@@ -234,20 +226,6 @@ declare const AsyncFileIndexFS_base: (abstract new (...args: any[]) => {
234
226
  readdirSync(path: string, cred: Cred): string[];
235
227
  linkSync(srcpath: string, dstpath: string, cred: Cred): void;
236
228
  syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
237
- readonly metadata: import("./filesystem.js").FileSystemMetadata;
238
- ready(): Promise<any>;
239
- rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
240
- stat(path: string, cred: Cred): Promise<Stats>;
241
- openFile(path: string, flag: FileFlag, cred: Cred): Promise<import("./file.js").File>;
242
- createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<import("./file.js").File>;
243
- unlink(path: string, cred: Cred): Promise<void>;
244
- rmdir(path: string, cred: Cred): Promise<void>;
245
- mkdir(path: string, mode: number, cred: Cred): Promise<void>;
246
- readdir(path: string, cred: Cred): Promise<string[]>;
247
- exists(path: string, cred: Cred): Promise<boolean>;
248
- existsSync(path: string, cred: Cred): boolean;
249
- link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
250
- sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
251
229
  }) & (abstract new (index: ListingTree) => FileIndexFS<unknown>);
252
230
  export declare abstract class AsyncFileIndexFS<TIndex> extends AsyncFileIndexFS_base {
253
231
  protected statFileInodeSync(): Stats;
@@ -13,31 +13,26 @@ declare class MirrorFile extends PreloadFile<AsyncMirrorFS> {
13
13
  close(): Promise<void>;
14
14
  closeSync(): void;
15
15
  }
16
- export declare namespace AsyncMirror {
16
+ /**
17
+ * Configuration options for the AsyncMirror file system.
18
+ */
19
+ export interface AsyncMirrorOptions {
17
20
  /**
18
- * Configuration options for the AsyncMirror file system.
21
+ * The synchronous file system to mirror the asynchronous file system to.
19
22
  */
20
- interface Options {
21
- /**
22
- * The synchronous file system to mirror the asynchronous file system to.
23
- */
24
- sync: FileSystem;
25
- /**
26
- * The asynchronous file system to mirror.
27
- */
28
- async: FileSystem;
29
- }
23
+ sync: FileSystem;
24
+ /**
25
+ * The asynchronous file system to mirror.
26
+ */
27
+ async: FileSystem;
30
28
  }
31
29
  declare const AsyncMirrorFS_base: (abstract new (...args: any[]) => {
32
- readonly metadata: FileSystemMetadata;
30
+ metadata(): FileSystemMetadata;
33
31
  ready(): Promise<any>;
34
32
  exists(path: string, cred: Cred): Promise<boolean>;
35
33
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
36
34
  stat(path: string, cred: Cred): Promise<Stats>;
37
35
  createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
38
- /**
39
- * @internal
40
- */
41
36
  openFile(path: string, flag: FileFlag, cred: Cred): Promise<File>;
42
37
  unlink(path: string, cred: Cred): Promise<void>;
43
38
  rmdir(path: string, cred: Cred): Promise<void>;
@@ -46,6 +41,9 @@ declare const AsyncMirrorFS_base: (abstract new (...args: any[]) => {
46
41
  link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
47
42
  sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
48
43
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
44
+ /**
45
+ * Queue of pending asynchronous operations.
46
+ */
49
47
  statSync(path: string, cred: Cred): Stats;
50
48
  openFileSync(path: string, flag: FileFlag, cred: Cred): File;
51
49
  createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
@@ -88,8 +86,8 @@ export declare class AsyncMirrorFS extends AsyncMirrorFS_base {
88
86
  * @param sync The synchronous file system to mirror the asynchronous file system to.
89
87
  * @param async The asynchronous file system to mirror.
90
88
  */
91
- constructor({ sync, async }: AsyncMirror.Options);
92
- get metadata(): FileSystemMetadata;
89
+ constructor({ sync, async }: AsyncMirrorOptions);
90
+ metadata(): FileSystemMetadata;
93
91
  syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
94
92
  openFileSync(path: string, flag: FileFlag, cred: Cred): File;
95
93
  createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): MirrorFile;
@@ -63,13 +63,12 @@ export class AsyncMirrorFS extends Sync(FileSystem) {
63
63
  this._async = async;
64
64
  this._ready = this._initialize();
65
65
  }
66
- // @ts-expect-error 2611
67
- get metadata() {
66
+ metadata() {
68
67
  return {
69
- ...super.metadata,
68
+ ...super.metadata(),
70
69
  name: AsyncMirrorFS.name,
71
70
  synchronous: true,
72
- supportsProperties: this._sync.metadata.supportsProperties && this._async.metadata.supportsProperties,
71
+ supportsProperties: this._sync.metadata().supportsProperties && this._async.metadata().supportsProperties,
73
72
  };
74
73
  }
75
74
  syncSync(path, data, stats) {
@@ -232,7 +231,7 @@ export const AsyncMirror = {
232
231
  type: 'object',
233
232
  description: 'The synchronous file system to mirror the asynchronous file system to.',
234
233
  validator: async (v) => {
235
- if (!v?.metadata.synchronous) {
234
+ if (!v?.metadata().synchronous) {
236
235
  throw new ApiError(ErrorCode.EINVAL, `'sync' option must be a file system that supports synchronous operations`);
237
236
  }
238
237
  },
@@ -62,14 +62,14 @@ export interface AsyncRWTransaction extends AsyncROTransaction {
62
62
  */
63
63
  abort(): Promise<void>;
64
64
  }
65
- export declare class AsyncFile extends PreloadFile<AsyncStoreFileSystem> {
66
- constructor(_fs: AsyncStoreFileSystem, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array);
65
+ export declare class AsyncFile extends PreloadFile<AsyncStoreFS> {
66
+ constructor(_fs: AsyncStoreFS, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array);
67
67
  sync(): Promise<void>;
68
68
  syncSync(): void;
69
69
  close(): Promise<void>;
70
70
  closeSync(): void;
71
71
  }
72
- export interface AsyncStoreFileSystemOptions {
72
+ export interface AsyncStoreOptions {
73
73
  /**
74
74
  * Promise that resolves to the store
75
75
  */
@@ -79,7 +79,8 @@ export interface AsyncStoreFileSystemOptions {
79
79
  */
80
80
  cacheSize?: number;
81
81
  }
82
- declare const AsyncStoreFileSystem_base: (abstract new (...args: any[]) => {
82
+ declare const AsyncStoreFS_base: (abstract new (...args: any[]) => {
83
+ metadata(): FileSystemMetadata;
83
84
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
84
85
  statSync(path: string, cred: Cred): Stats;
85
86
  createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
@@ -90,32 +91,18 @@ declare const AsyncStoreFileSystem_base: (abstract new (...args: any[]) => {
90
91
  readdirSync(path: string, cred: Cred): string[];
91
92
  linkSync(srcpath: string, dstpath: string, cred: Cred): void;
92
93
  syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
93
- readonly metadata: FileSystemMetadata;
94
- ready(): Promise<any>;
95
- rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
96
- stat(path: string, cred: Cred): Promise<Stats>;
97
- openFile(path: string, flag: FileFlag, cred: Cred): Promise<File>;
98
- createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
99
- unlink(path: string, cred: Cred): Promise<void>;
100
- rmdir(path: string, cred: Cred): Promise<void>;
101
- mkdir(path: string, mode: number, cred: Cred): Promise<void>;
102
- readdir(path: string, cred: Cred): Promise<string[]>;
103
- exists(path: string, cred: Cred): Promise<boolean>;
104
- existsSync(path: string, cred: Cred): boolean;
105
- link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
106
- sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
107
94
  }) & typeof FileSystem;
108
95
  /**
109
96
  * An "Asynchronous key-value file system". Stores data to/retrieves data from
110
97
  * an underlying asynchronous key-value store.
111
98
  */
112
- export declare class AsyncStoreFileSystem extends AsyncStoreFileSystem_base {
99
+ export declare class AsyncStoreFS extends AsyncStoreFS_base {
113
100
  protected store: AsyncStore;
114
101
  private _cache?;
115
102
  protected _ready: Promise<this>;
116
103
  ready(): Promise<this>;
117
- get metadata(): FileSystemMetadata;
118
- constructor({ store, cacheSize }: AsyncStoreFileSystemOptions);
104
+ metadata(): FileSystemMetadata;
105
+ constructor({ store, cacheSize }: AsyncStoreOptions);
119
106
  /**
120
107
  * Initializes the file system. Typically called by subclasses' async
121
108
  * constructors.
@@ -69,13 +69,13 @@ export class AsyncFile extends PreloadFile {
69
69
  * An "Asynchronous key-value file system". Stores data to/retrieves data from
70
70
  * an underlying asynchronous key-value store.
71
71
  */
72
- export class AsyncStoreFileSystem extends Async(FileSystem) {
72
+ export class AsyncStoreFS extends Async(FileSystem) {
73
73
  ready() {
74
74
  return this._ready;
75
75
  }
76
- get metadata() {
76
+ metadata() {
77
77
  return {
78
- ...super.metadata,
78
+ ...super.metadata(),
79
79
  name: this.store.name,
80
80
  };
81
81
  }
@@ -1,4 +1,4 @@
1
- import { SimpleSyncRWTransaction, SyncStoreFileSystem } from './SyncStore.js';
1
+ import { SimpleSyncRWTransaction, SyncStoreFS } from './SyncStore.js';
2
2
  /**
3
3
  * A simple in-memory store
4
4
  */
@@ -43,6 +43,6 @@ export const InMemory = {
43
43
  },
44
44
  },
45
45
  create({ name }) {
46
- return new SyncStoreFileSystem({ store: new InMemoryStore(name) });
46
+ return new SyncStoreFS({ store: new InMemoryStore(name) });
47
47
  },
48
48
  };
@@ -17,7 +17,7 @@ export declare class LockedFS<T extends FileSystem> implements FileSystem {
17
17
  private _mu;
18
18
  constructor(fs: T);
19
19
  ready(): Promise<this>;
20
- get metadata(): FileSystemMetadata;
20
+ metadata(): FileSystemMetadata;
21
21
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
22
22
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
23
23
  stat(p: string, cred: Cred): Promise<Stats>;
@@ -17,10 +17,10 @@ export class LockedFS {
17
17
  await this.fs.ready();
18
18
  return this;
19
19
  }
20
- get metadata() {
20
+ metadata() {
21
21
  return {
22
- ...this.fs.metadata,
23
- name: 'Locked<' + this.fs.metadata.name + '>',
22
+ ...this.fs.metadata(),
23
+ name: 'Locked<' + this.fs.metadata().name + '>',
24
24
  };
25
25
  }
26
26
  async rename(oldPath, newPath, cred) {
@@ -37,7 +37,7 @@ export declare class UnlockedOverlayFS extends FileSystem {
37
37
  private _deleteLogError?;
38
38
  private _ready;
39
39
  constructor({ writable, readable }: OverlayOptions);
40
- get metadata(): FileSystemMetadata;
40
+ metadata(): FileSystemMetadata;
41
41
  getOverlayedFileSystems(): OverlayOptions;
42
42
  sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
43
43
  syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
@@ -64,17 +64,17 @@ export class UnlockedOverlayFS extends FileSystem {
64
64
  this._deleteLogUpdateNeeded = false;
65
65
  this._writable = writable;
66
66
  this._readable = readable;
67
- if (this._writable.metadata.readonly) {
67
+ if (this._writable.metadata().readonly) {
68
68
  throw new ApiError(ErrorCode.EINVAL, 'Writable file system must be writable.');
69
69
  }
70
70
  this._ready = this._initialize();
71
71
  }
72
- get metadata() {
72
+ metadata() {
73
73
  return {
74
- ...super.metadata,
74
+ ...super.metadata(),
75
75
  name: OverlayFS.name,
76
- synchronous: this._readable.metadata.synchronous && this._writable.metadata.synchronous,
77
- supportsProperties: this._readable.metadata.supportsProperties && this._writable.metadata.supportsProperties,
76
+ synchronous: this._readable.metadata().synchronous && this._writable.metadata().synchronous,
77
+ supportsProperties: this._readable.metadata().supportsProperties && this._writable.metadata().supportsProperties,
78
78
  };
79
79
  }
80
80
  getOverlayedFileSystems() {
@@ -106,21 +106,21 @@ export declare class SimpleSyncRWTransaction implements SyncRWTransaction {
106
106
  */
107
107
  protected markModified(ino: Ino): void;
108
108
  }
109
- export interface SyncStoreFileSystemOptions {
109
+ export interface SyncStoreOptions {
110
110
  /**
111
111
  * The actual key-value store to read from/write to.
112
112
  */
113
113
  store: SyncStore;
114
114
  }
115
- export declare class SyncStoreFile extends PreloadFile<SyncStoreFileSystem> {
116
- constructor(_fs: SyncStoreFileSystem, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array);
115
+ export declare class SyncStoreFile extends PreloadFile<SyncStoreFS> {
116
+ constructor(_fs: SyncStoreFS, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array);
117
117
  sync(): Promise<void>;
118
118
  syncSync(): void;
119
119
  close(): Promise<void>;
120
120
  closeSync(): void;
121
121
  }
122
- declare const SyncStoreFileSystem_base: (abstract new (...args: any[]) => {
123
- readonly metadata: FileSystemMetadata;
122
+ declare const SyncStoreFS_base: (abstract new (...args: any[]) => {
123
+ metadata(): FileSystemMetadata;
124
124
  ready(): Promise<any>;
125
125
  exists(path: string, cred: Cred): Promise<boolean>;
126
126
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
@@ -154,10 +154,10 @@ declare const SyncStoreFileSystem_base: (abstract new (...args: any[]) => {
154
154
  * @todo Introduce Node ID caching.
155
155
  * @todo Check modes.
156
156
  */
157
- export declare class SyncStoreFileSystem extends SyncStoreFileSystem_base {
157
+ export declare class SyncStoreFS extends SyncStoreFS_base {
158
158
  protected store: SyncStore;
159
- constructor(options: SyncStoreFileSystemOptions);
160
- get metadata(): FileSystemMetadata;
159
+ constructor(options: SyncStoreOptions);
160
+ metadata(): FileSystemMetadata;
161
161
  /**
162
162
  * Delete all contents stored in the file system.
163
163
  */
@@ -105,17 +105,16 @@ export class SyncStoreFile extends PreloadFile {
105
105
  * @todo Introduce Node ID caching.
106
106
  * @todo Check modes.
107
107
  */
108
- export class SyncStoreFileSystem extends Sync(FileSystem) {
108
+ export class SyncStoreFS extends Sync(FileSystem) {
109
109
  constructor(options) {
110
110
  super();
111
111
  this.store = options.store;
112
112
  // INVARIANT: Ensure that the root exists.
113
113
  this.makeRootDirectory();
114
114
  }
115
- // @ts-expect-error 2611
116
- get metadata() {
115
+ metadata() {
117
116
  return {
118
- ...super.metadata,
117
+ ...super.metadata(),
119
118
  name: this.store.name,
120
119
  };
121
120
  }