@archildata/client 0.1.8 → 0.1.9

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, 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,6 +134,15 @@ interface DirectoryEntry {
134
134
  inodeType: string;
135
135
  }
136
136
 
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
+
137
146
  interface SetAttrOptions {
138
147
  mode?: number;
139
148
  uid?: number;
@@ -141,6 +150,7 @@ interface SetAttrOptions {
141
150
  size?: number;
142
151
  atimeMs?: number; // use -1 for current time
143
152
  mtimeMs?: number; // use -1 for current time
153
+ user: UnixUser; // required for setattr
144
154
  }
145
155
  ```
146
156
 
Binary file
package/index.d.ts CHANGED
@@ -148,10 +148,17 @@ 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
164
  * Options for setattr operation
@@ -174,6 +181,8 @@ export interface SetAttrOptions {
174
181
  mtimeMs?: number
175
182
  /** New change time in milliseconds since epoch */
176
183
  ctimeMs?: number
184
+ /** Unix user context for permission checks (required for setattr) */
185
+ user?: UnixUser
177
186
  }
178
187
  /**
179
188
  * ArchilClient provides low-level access to Archil filesystem operations.
@@ -210,9 +219,9 @@ export declare class ArchilClient {
210
219
  */
211
220
  close(): Promise<number>
212
221
  /** Get attributes for an inode (uses cache). */
213
- getAttributes(inodeId: number, user?: UnixUser | undefined | null): Promise<InodeAttributes>
222
+ getAttributes(inodeId: number, options?: OperationOptions | undefined | null): Promise<InodeAttributes>
214
223
  /** Lookup an entry by name in a directory (uses cache). */
215
- lookupInode(parentInodeId: number, name: string, user?: UnixUser | undefined | null): Promise<LookupResponse>
224
+ lookupInode(parentInodeId: number, name: string, options?: OperationOptions | undefined | null): Promise<LookupResponse>
216
225
  /**
217
226
  * Read directory entries.
218
227
  *
@@ -220,17 +229,17 @@ export declare class ArchilClient {
220
229
  * the dirent cache is properly populated. This ensures that subsequent
221
230
  * lookup_inode calls can find the entries returned here.
222
231
  */
223
- readDirectory(inodeId: number, offset?: number | undefined | null, cookie?: number | undefined | null, user?: UnixUser | undefined | null): Promise<Array<DirectoryEntry>>
232
+ readDirectory(inodeId: number, options?: OperationOptions | undefined | null): Promise<Array<DirectoryEntry>>
224
233
  /** Get an extended attribute value. */
225
- getExtendedAttribute(inodeId: number, name: string, user?: UnixUser | undefined | null): Promise<Buffer | null>
234
+ getExtendedAttribute(inodeId: number, name: string, options?: OperationOptions | undefined | null): Promise<Buffer | null>
226
235
  /** List all extended attribute names. */
227
- listExtendedAttributes(inodeId: number, user?: UnixUser | undefined | null): Promise<Array<string>>
236
+ listExtendedAttributes(inodeId: number, options?: OperationOptions | undefined | null): Promise<Array<string>>
228
237
  /**
229
238
  * Read data from a file (uses cache).
230
239
  *
231
240
  * Returns zero-copy Buffer when possible for optimal performance.
232
241
  */
233
- readInode(inodeId: number, offset: number, length: number, user?: UnixUser | undefined | null): Promise<Buffer>
242
+ readInode(inodeId: number, offset: number, length: number, options?: OperationOptions | undefined | null): Promise<Buffer>
234
243
  /**
235
244
  * Checkout (acquire delegation for) an inode for writing.
236
245
  *
@@ -246,16 +255,16 @@ export declare class ArchilClient {
246
255
  * await client.checkout(inodeId, { force: true });
247
256
  *
248
257
  * // With user context
249
- * await client.checkout(inodeId, { force: false }, { uid: 1000, gid: 1000 });
258
+ * await client.checkout(inodeId, { force: true, user: { uid: 1000, gid: 1000 } });
250
259
  * ```
251
260
  */
252
- checkout(inodeId: number, options?: CheckoutOptions | undefined | null, user?: UnixUser | undefined | null): Promise<void>
261
+ checkout(inodeId: number, options?: CheckoutOptions | undefined | null): Promise<void>
253
262
  /**
254
263
  * Checkin (release delegation for) an inode.
255
264
  *
256
265
  * This syncs any pending writes and releases the local delegation tracking.
257
266
  */
258
- checkin(inodeId: number, user?: UnixUser | undefined | null): Promise<void>
267
+ checkin(inodeId: number, options?: OperationOptions | undefined | null): Promise<void>
259
268
  /** Release all delegations held by this client. */
260
269
  checkinAll(): Promise<number>
261
270
  /**
@@ -277,12 +286,12 @@ export declare class ArchilClient {
277
286
  * // First checkout to get write delegation
278
287
  * await client.checkout(inodeId);
279
288
  * // Then write data
280
- * await client.writeData(inodeId, 0, Buffer.from('Hello World'), user);
289
+ * await client.writeData(inodeId, 0, Buffer.from('Hello World'));
281
290
  * // Optionally checkin when done
282
291
  * await client.checkin(inodeId);
283
292
  * ```
284
293
  */
285
- writeData(inodeId: number, offset: number, data: Buffer, user?: UnixUser | undefined | null): Promise<void>
294
+ writeData(inodeId: number, offset: number, data: Buffer, options?: OperationOptions | undefined | null): Promise<void>
286
295
  /**
287
296
  * Set attributes on an inode.
288
297
  *
@@ -296,21 +305,21 @@ export declare class ArchilClient {
296
305
  * // First checkout to get write delegation
297
306
  * await client.checkout(inodeId);
298
307
  * // Update timestamps (touch)
299
- * await client.setattr(inodeId, { atimeMs: -1, mtimeMs: -1 }, user);
308
+ * await client.setattr(inodeId, { atimeMs: -1, mtimeMs: -1, user: { uid: 1000, gid: 1000 } });
300
309
  * // Or change mode
301
- * await client.setattr(inodeId, { mode: 0o755 }, user);
310
+ * await client.setattr(inodeId, { mode: 0o755, user: { uid: 1000, gid: 1000 } });
302
311
  * // Checkin when done
303
312
  * await client.checkin(inodeId);
304
313
  * ```
305
314
  */
306
- setattr(inodeId: number, options: SetAttrOptions, user: UnixUser): Promise<InodeAttributes>
315
+ setattr(inodeId: number, options: SetAttrOptions): Promise<InodeAttributes>
307
316
  /**
308
317
  * Unlink (delete) a file or empty directory.
309
318
  *
310
319
  * Removes the directory entry from the parent directory. Requires
311
320
  * write permission on the parent directory.
312
321
  */
313
- unlink(parentInodeId: number, name: string, user?: UnixUser | undefined | null): Promise<void>
322
+ unlink(parentInodeId: number, name: string, options?: OperationOptions | undefined | null): Promise<void>
314
323
  /**
315
324
  * Rename (move) a file or directory.
316
325
  *
@@ -320,10 +329,10 @@ export declare class ArchilClient {
320
329
  * @example
321
330
  * ```typescript
322
331
  * // Move a file
323
- * await client.rename(srcParentInodeId, 'oldname.txt', destParentInodeId, 'newname.txt', user);
332
+ * await client.rename(srcParentInodeId, 'oldname.txt', destParentInodeId, 'newname.txt');
324
333
  * ```
325
334
  */
326
- rename(parentInodeId: number, name: string, newParentInodeId: number, newName: string, user?: UnixUser | undefined | null): Promise<void>
335
+ rename(parentInodeId: number, name: string, newParentInodeId: number, newName: string, options?: OperationOptions | undefined | null): Promise<void>
327
336
  /**
328
337
  * Create a new file or directory.
329
338
  *
@@ -332,7 +341,7 @@ export declare class ArchilClient {
332
341
  *
333
342
  * Returns the inode ID of the created file.
334
343
  */
335
- create(parentInodeId: number, name: string, attributes: InodeAttributes, user?: UnixUser | undefined | null): Promise<number>
344
+ create(parentInodeId: number, name: string, attributes: InodeAttributes, options?: OperationOptions | undefined | null): Promise<number>
336
345
  /** Mark an inode subtree as immutable. */
337
346
  setImmutable(inodeId: number): Promise<void>
338
347
  /** 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.9",
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.9",
54
+ "@archildata/client-darwin-x64": "0.1.9",
55
+ "@archildata/client-linux-x64-gnu": "0.1.9",
56
+ "@archildata/client-darwin-arm64": "0.1.9",
57
+ "@archildata/client-linux-arm64-gnu": "0.1.9"
58
58
  }
59
59
  }