@zenfs/core 0.3.1 → 0.3.3

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,7 +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
- readonly metadata: import("./filesystem.js").FileSystemMetadata;
157
+ metadata(): import("./filesystem.js").FileSystemMetadata;
158
158
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
159
159
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
160
160
  createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<import("./file.js").File>;
@@ -180,12 +180,12 @@ export declare abstract class FileIndexFS<TIndex> extends FileIndexFS_base {
180
180
  readdir(path: string): Promise<string[]>;
181
181
  readdirSync(path: string): string[];
182
182
  protected abstract statFileInode(inode: IndexFileInode<TIndex>): Promise<Stats>;
183
- protected abstract fileForFileInode(inode: IndexFileInode<TIndex>): Promise<NoSyncFile<this>>;
184
183
  protected abstract statFileInodeSync(inode: IndexFileInode<TIndex>): Stats;
185
- protected abstract fileForFileInodeSync(inode: IndexFileInode<TIndex>): NoSyncFile<this>;
184
+ protected abstract fileForFileInode(inode: IndexFileInode<TIndex>, path: string, flag: FileFlag): Promise<NoSyncFile<this>>;
185
+ protected abstract fileForFileInodeSync(inode: IndexFileInode<TIndex>, path: string, flag: FileFlag): NoSyncFile<this>;
186
186
  }
187
187
  declare const SyncFileIndexFS_base: (abstract new (...args: any[]) => {
188
- readonly metadata: import("./filesystem.js").FileSystemMetadata;
188
+ metadata(): import("./filesystem.js").FileSystemMetadata;
189
189
  ready(): Promise<any>;
190
190
  exists(path: string, cred: Cred): Promise<boolean>;
191
191
  rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
@@ -212,10 +212,10 @@ declare const SyncFileIndexFS_base: (abstract new (...args: any[]) => {
212
212
  }) & (abstract new (index: ListingTree) => FileIndexFS<unknown>);
213
213
  export declare abstract class SyncFileIndexFS<TIndex> extends SyncFileIndexFS_base {
214
214
  protected statFileInode(inode: IndexFileInode<TIndex>): Promise<Stats>;
215
- protected fileForFileInode(inode: IndexFileInode<TIndex>): Promise<NoSyncFile<this>>;
215
+ protected fileForFileInode(inode: IndexFileInode<TIndex>, path: string, flag: FileFlag): Promise<NoSyncFile<this>>;
216
216
  }
217
217
  declare const AsyncFileIndexFS_base: (abstract new (...args: any[]) => {
218
- readonly metadata: import("./filesystem.js").FileSystemMetadata;
218
+ metadata(): import("./filesystem.js").FileSystemMetadata;
219
219
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
220
220
  statSync(path: string, cred: Cred): Stats;
221
221
  createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): import("./file.js").File;
package/dist/FileIndex.js CHANGED
@@ -346,7 +346,7 @@ export class FileIndexFS extends Readonly(FileSystem) {
346
346
  const stats = inode.stats;
347
347
  return new NoSyncFile(this, path, flag, stats, stats.fileData);
348
348
  }
349
- return this.fileForFileInode(inode);
349
+ return this.fileForFileInode(inode, path, flag);
350
350
  }
351
351
  openFileSync(path, flag, cred) {
352
352
  if (flag.isWriteable()) {
@@ -365,7 +365,7 @@ export class FileIndexFS extends Readonly(FileSystem) {
365
365
  const stats = inode.stats;
366
366
  return new NoSyncFile(this, path, flag, stats, stats.fileData);
367
367
  }
368
- return this.fileForFileInodeSync(inode);
368
+ return this.fileForFileInodeSync(inode, path, flag);
369
369
  }
370
370
  async readdir(path) {
371
371
  // Check if it exists.
@@ -394,8 +394,8 @@ export class SyncFileIndexFS extends Sync((FileIndexFS)) {
394
394
  async statFileInode(inode) {
395
395
  return this.statFileInodeSync(inode);
396
396
  }
397
- async fileForFileInode(inode) {
398
- return this.fileForFileInodeSync(inode);
397
+ async fileForFileInode(inode, path, flag) {
398
+ return this.fileForFileInodeSync(inode, path, flag);
399
399
  }
400
400
  }
401
401
  export class AsyncFileIndexFS extends Async((FileIndexFS)) {
@@ -13,23 +13,21 @@ 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 {
20
+ /**
21
+ * The synchronous file system to mirror the asynchronous file system to.
22
+ */
23
+ sync: FileSystem;
17
24
  /**
18
- * Configuration options for the AsyncMirror file system.
25
+ * The asynchronous file system to mirror.
19
26
  */
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
- }
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>;
@@ -43,6 +41,9 @@ declare const AsyncMirrorFS_base: (abstract new (...args: any[]) => {
43
41
  link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
44
42
  sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
45
43
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
44
+ /**
45
+ * Queue of pending asynchronous operations.
46
+ */
46
47
  statSync(path: string, cred: Cred): Stats;
47
48
  openFileSync(path: string, flag: FileFlag, cred: Cred): File;
48
49
  createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
@@ -85,8 +86,8 @@ export declare class AsyncMirrorFS extends AsyncMirrorFS_base {
85
86
  * @param sync The synchronous file system to mirror the asynchronous file system to.
86
87
  * @param async The asynchronous file system to mirror.
87
88
  */
88
- constructor({ sync, async }: AsyncMirror.Options);
89
- get metadata(): FileSystemMetadata;
89
+ constructor({ sync, async }: AsyncMirrorOptions);
90
+ metadata(): FileSystemMetadata;
90
91
  syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
91
92
  openFileSync(path: string, flag: FileFlag, cred: Cred): File;
92
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,8 +79,8 @@ export interface AsyncStoreFileSystemOptions {
79
79
  */
80
80
  cacheSize?: number;
81
81
  }
82
- declare const AsyncStoreFileSystem_base: (abstract new (...args: any[]) => {
83
- readonly metadata: FileSystemMetadata;
82
+ declare const AsyncStoreFS_base: (abstract new (...args: any[]) => {
83
+ metadata(): FileSystemMetadata;
84
84
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
85
85
  statSync(path: string, cred: Cred): Stats;
86
86
  createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
@@ -96,13 +96,13 @@ declare const AsyncStoreFileSystem_base: (abstract new (...args: any[]) => {
96
96
  * An "Asynchronous key-value file system". Stores data to/retrieves data from
97
97
  * an underlying asynchronous key-value store.
98
98
  */
99
- export declare class AsyncStoreFileSystem extends AsyncStoreFileSystem_base {
99
+ export declare class AsyncStoreFS extends AsyncStoreFS_base {
100
100
  protected store: AsyncStore;
101
101
  private _cache?;
102
102
  protected _ready: Promise<this>;
103
103
  ready(): Promise<this>;
104
- get metadata(): FileSystemMetadata;
105
- constructor({ store, cacheSize }: AsyncStoreFileSystemOptions);
104
+ metadata(): FileSystemMetadata;
105
+ constructor({ store, cacheSize }: AsyncStoreOptions);
106
106
  /**
107
107
  * Initializes the file system. Typically called by subclasses' async
108
108
  * constructors.
@@ -69,14 +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
- // @ts-expect-error 2611
77
- get metadata() {
76
+ metadata() {
78
77
  return {
79
- ...super.metadata,
78
+ ...super.metadata(),
80
79
  name: this.store.name,
81
80
  };
82
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
  }