@archildata/client 0.1.8 → 0.1.10

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.
package/README.md CHANGED
@@ -68,31 +68,31 @@ The main client class for interacting with Archil filesystems.
68
68
 
69
69
  #### Metadata Operations
70
70
 
71
- - `getAttributes(inodeId, user?)` - Get inode attributes
72
- - `lookupInode(parentInodeId, name, user?)` - Lookup entry by name
73
- - `readDirectory(inodeId, offset?, cookie?, user?)` - List directory entries
74
- - `getExtendedAttribute(inodeId, name, user?)` - Get xattr value
75
- - `listExtendedAttributes(inodeId, user?)` - List xattr names
71
+ - `getAttributes(inodeId, options?)` - Get inode attributes
72
+ - `lookupInode(parentInodeId, name, options?)` - Lookup entry by name
73
+ - `readDirectory(inodeId, options?)` - List directory entries
74
+ - `getExtendedAttribute(inodeId, name, options?)` - Get xattr value
75
+ - `listExtendedAttributes(inodeId, options?)` - List xattr names
76
76
 
77
77
  #### Data Operations
78
78
 
79
- - `readInode(inodeId, offset, length, user?)` - Read file data
80
- - `writeData(inodeId, offset, data, user?)` - Write file data (requires delegation)
79
+ - `readInode(inodeId, offset, length, options?)` - Read file data
80
+ - `writeData(inodeId, offset, data, options?)` - Write file data (requires delegation)
81
81
  - `sync()` - Sync all pending writes to server
82
82
 
83
83
  #### Delegation Operations
84
84
 
85
- - `checkout(inodeId, options?, user?)` - Acquire write delegation
86
- - `checkin(inodeId, user?)` - Release delegation
85
+ - `checkout(inodeId, options?)` - Acquire write delegation
86
+ - `checkin(inodeId, options?)` - Release delegation
87
87
  - `checkinAll()` - Release all delegations
88
88
  - `listDelegations()` - List currently held delegations
89
89
 
90
90
  #### Mutation Operations
91
91
 
92
- - `create(parentInodeId, name, attributes, user?)` - Create file/directory
93
- - `unlink(parentInodeId, name, user?)` - Delete file or empty directory
94
- - `rename(parentInodeId, name, newParentInodeId, newName, user?)` - Move/rename
95
- - `setattr(inodeId, options, user)` - Update file attributes
92
+ - `create(parentInodeId, name, attributes, options?)` - Create file/directory
93
+ - `unlink(parentInodeId, name, options?)` - Delete file or empty directory
94
+ - `rename(parentInodeId, name, newParentInodeId, newName, options?)` - Move/rename
95
+ - `setattr(inodeId, attributes, options)` - Update file attributes (user required in options)
96
96
  - `setImmutable(inodeId)` - Mark subtree as immutable
97
97
  - `setMutable(inodeId)` - Mark subtree as mutable
98
98
  - `listImmutableSubtrees()` - List immutable roots
@@ -134,7 +134,16 @@ interface DirectoryEntry {
134
134
  inodeType: string;
135
135
  }
136
136
 
137
- interface SetAttrOptions {
137
+ interface OperationOptions {
138
+ user?: UnixUser; // Unix user context for permission checks
139
+ }
140
+
141
+ interface CheckoutOptions {
142
+ force?: boolean; // Force revoke existing delegations (default: false)
143
+ user?: UnixUser; // Unix user context for permission checks
144
+ }
145
+
146
+ interface SetAttrAttributes {
138
147
  mode?: number;
139
148
  uid?: number;
140
149
  gid?: number;
Binary file
package/index.d.ts CHANGED
@@ -148,18 +148,25 @@ export interface DelegationInfo {
148
148
  /** State of the delegation: "Active", "Pending", or "Removing" */
149
149
  state: string
150
150
  }
151
+ /** Common options for operations that support user context */
152
+ export interface OperationOptions {
153
+ /** Unix user context for permission checks */
154
+ user?: UnixUser
155
+ }
151
156
  /** Options for checkout operation */
152
157
  export interface CheckoutOptions {
153
158
  /** Force revoke existing delegations held by other clients (default: false) */
154
159
  force?: boolean
160
+ /** Unix user context for permission checks */
161
+ user?: UnixUser
155
162
  }
156
163
  /**
157
- * Options for setattr operation
164
+ * Attributes to set in a setattr operation
158
165
  *
159
166
  * All fields are optional - only provided fields will be updated.
160
167
  * For atime/mtime: use timestamp in milliseconds, or -1 to set to current time.
161
168
  */
162
- export interface SetAttrOptions {
169
+ export interface SetAttrAttributes {
163
170
  /** New permission mode (e.g., 0o644) */
164
171
  mode?: number
165
172
  /** New owner user ID */
@@ -210,9 +217,9 @@ export declare class ArchilClient {
210
217
  */
211
218
  close(): Promise<number>
212
219
  /** Get attributes for an inode (uses cache). */
213
- getAttributes(inodeId: number, user?: UnixUser | undefined | null): Promise<InodeAttributes>
220
+ getAttributes(inodeId: number, options?: OperationOptions | undefined | null): Promise<InodeAttributes>
214
221
  /** Lookup an entry by name in a directory (uses cache). */
215
- lookupInode(parentInodeId: number, name: string, user?: UnixUser | undefined | null): Promise<LookupResponse>
222
+ lookupInode(parentInodeId: number, name: string, options?: OperationOptions | undefined | null): Promise<LookupResponse>
216
223
  /**
217
224
  * Read directory entries.
218
225
  *
@@ -220,17 +227,17 @@ export declare class ArchilClient {
220
227
  * the dirent cache is properly populated. This ensures that subsequent
221
228
  * lookup_inode calls can find the entries returned here.
222
229
  */
223
- readDirectory(inodeId: number, offset?: number | undefined | null, cookie?: number | undefined | null, user?: UnixUser | undefined | null): Promise<Array<DirectoryEntry>>
230
+ readDirectory(inodeId: number, options?: OperationOptions | undefined | null): Promise<Array<DirectoryEntry>>
224
231
  /** Get an extended attribute value. */
225
- getExtendedAttribute(inodeId: number, name: string, user?: UnixUser | undefined | null): Promise<Buffer | null>
232
+ getExtendedAttribute(inodeId: number, name: string, options?: OperationOptions | undefined | null): Promise<Buffer | null>
226
233
  /** List all extended attribute names. */
227
- listExtendedAttributes(inodeId: number, user?: UnixUser | undefined | null): Promise<Array<string>>
234
+ listExtendedAttributes(inodeId: number, options?: OperationOptions | undefined | null): Promise<Array<string>>
228
235
  /**
229
236
  * Read data from a file (uses cache).
230
237
  *
231
238
  * Returns zero-copy Buffer when possible for optimal performance.
232
239
  */
233
- readInode(inodeId: number, offset: number, length: number, user?: UnixUser | undefined | null): Promise<Buffer>
240
+ readInode(inodeId: number, offset: number, length: number, options?: OperationOptions | undefined | null): Promise<Buffer>
234
241
  /**
235
242
  * Checkout (acquire delegation for) an inode for writing.
236
243
  *
@@ -246,16 +253,16 @@ export declare class ArchilClient {
246
253
  * await client.checkout(inodeId, { force: true });
247
254
  *
248
255
  * // With user context
249
- * await client.checkout(inodeId, { force: false }, { uid: 1000, gid: 1000 });
256
+ * await client.checkout(inodeId, { force: true, user: { uid: 1000, gid: 1000 } });
250
257
  * ```
251
258
  */
252
- checkout(inodeId: number, options?: CheckoutOptions | undefined | null, user?: UnixUser | undefined | null): Promise<void>
259
+ checkout(inodeId: number, options?: CheckoutOptions | undefined | null): Promise<void>
253
260
  /**
254
261
  * Checkin (release delegation for) an inode.
255
262
  *
256
263
  * This syncs any pending writes and releases the local delegation tracking.
257
264
  */
258
- checkin(inodeId: number, user?: UnixUser | undefined | null): Promise<void>
265
+ checkin(inodeId: number, options?: OperationOptions | undefined | null): Promise<void>
259
266
  /** Release all delegations held by this client. */
260
267
  checkinAll(): Promise<number>
261
268
  /**
@@ -277,12 +284,12 @@ export declare class ArchilClient {
277
284
  * // First checkout to get write delegation
278
285
  * await client.checkout(inodeId);
279
286
  * // Then write data
280
- * await client.writeData(inodeId, 0, Buffer.from('Hello World'), user);
287
+ * await client.writeData(inodeId, 0, Buffer.from('Hello World'));
281
288
  * // Optionally checkin when done
282
289
  * await client.checkin(inodeId);
283
290
  * ```
284
291
  */
285
- writeData(inodeId: number, offset: number, data: Buffer, user?: UnixUser | undefined | null): Promise<void>
292
+ writeData(inodeId: number, offset: number, data: Buffer, options?: OperationOptions | undefined | null): Promise<void>
286
293
  /**
287
294
  * Set attributes on an inode.
288
295
  *
@@ -296,21 +303,21 @@ export declare class ArchilClient {
296
303
  * // First checkout to get write delegation
297
304
  * await client.checkout(inodeId);
298
305
  * // Update timestamps (touch)
299
- * await client.setattr(inodeId, { atimeMs: -1, mtimeMs: -1 }, user);
306
+ * await client.setattr(inodeId, { atimeMs: -1, mtimeMs: -1 }, { user: { uid: 1000, gid: 1000 } });
300
307
  * // Or change mode
301
- * await client.setattr(inodeId, { mode: 0o755 }, user);
308
+ * await client.setattr(inodeId, { mode: 0o755 }, { user: { uid: 1000, gid: 1000 } });
302
309
  * // Checkin when done
303
310
  * await client.checkin(inodeId);
304
311
  * ```
305
312
  */
306
- setattr(inodeId: number, options: SetAttrOptions, user: UnixUser): Promise<InodeAttributes>
313
+ setattr(inodeId: number, attributes: SetAttrAttributes, options?: OperationOptions | undefined | null): Promise<InodeAttributes>
307
314
  /**
308
315
  * Unlink (delete) a file or empty directory.
309
316
  *
310
317
  * Removes the directory entry from the parent directory. Requires
311
318
  * write permission on the parent directory.
312
319
  */
313
- unlink(parentInodeId: number, name: string, user?: UnixUser | undefined | null): Promise<void>
320
+ unlink(parentInodeId: number, name: string, options?: OperationOptions | undefined | null): Promise<void>
314
321
  /**
315
322
  * Rename (move) a file or directory.
316
323
  *
@@ -320,10 +327,10 @@ export declare class ArchilClient {
320
327
  * @example
321
328
  * ```typescript
322
329
  * // Move a file
323
- * await client.rename(srcParentInodeId, 'oldname.txt', destParentInodeId, 'newname.txt', user);
330
+ * await client.rename(srcParentInodeId, 'oldname.txt', destParentInodeId, 'newname.txt');
324
331
  * ```
325
332
  */
326
- rename(parentInodeId: number, name: string, newParentInodeId: number, newName: string, user?: UnixUser | undefined | null): Promise<void>
333
+ rename(parentInodeId: number, name: string, newParentInodeId: number, newName: string, options?: OperationOptions | undefined | null): Promise<void>
327
334
  /**
328
335
  * Create a new file or directory.
329
336
  *
@@ -332,7 +339,7 @@ export declare class ArchilClient {
332
339
  *
333
340
  * Returns the inode ID of the created file.
334
341
  */
335
- create(parentInodeId: number, name: string, attributes: InodeAttributes, user?: UnixUser | undefined | null): Promise<number>
342
+ create(parentInodeId: number, name: string, attributes: InodeAttributes, options?: OperationOptions | undefined | null): Promise<number>
336
343
  /** Mark an inode subtree as immutable. */
337
344
  setImmutable(inodeId: number): Promise<void>
338
345
  /** Mark an inode subtree as mutable (reverse of set_immutable). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archildata/client",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "High-performance Node.js client for Archil distributed filesystem",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -50,10 +50,10 @@
50
50
  "native"
51
51
  ],
52
52
  "optionalDependencies": {
53
- "@archildata/client-win32-x64-msvc": "0.1.8",
54
- "@archildata/client-darwin-x64": "0.1.8",
55
- "@archildata/client-linux-x64-gnu": "0.1.8",
56
- "@archildata/client-darwin-arm64": "0.1.8",
57
- "@archildata/client-linux-arm64-gnu": "0.1.8"
53
+ "@archildata/client-win32-x64-msvc": "0.1.10",
54
+ "@archildata/client-darwin-x64": "0.1.10",
55
+ "@archildata/client-linux-x64-gnu": "0.1.10",
56
+ "@archildata/client-darwin-arm64": "0.1.10",
57
+ "@archildata/client-linux-arm64-gnu": "0.1.10"
58
58
  }
59
59
  }