@archildata/client 0.1.7 → 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,
|
|
72
|
-
- `lookupInode(parentInodeId, name,
|
|
73
|
-
- `readDirectory(inodeId,
|
|
74
|
-
- `getExtendedAttribute(inodeId, name,
|
|
75
|
-
- `listExtendedAttributes(inodeId,
|
|
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,
|
|
80
|
-
- `writeData(inodeId, offset, data,
|
|
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,
|
|
86
|
-
- `checkin(inodeId,
|
|
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,
|
|
93
|
-
- `unlink(parentInodeId, name,
|
|
94
|
-
- `rename(parentInodeId, name, newParentInodeId, newName,
|
|
95
|
-
- `setattr(inodeId, options
|
|
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
|
|
Binary file
|
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -148,6 +148,18 @@ 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
|
+
}
|
|
156
|
+
/** Options for checkout operation */
|
|
157
|
+
export interface CheckoutOptions {
|
|
158
|
+
/** Force revoke existing delegations held by other clients (default: false) */
|
|
159
|
+
force?: boolean
|
|
160
|
+
/** Unix user context for permission checks */
|
|
161
|
+
user?: UnixUser
|
|
162
|
+
}
|
|
151
163
|
/**
|
|
152
164
|
* Options for setattr operation
|
|
153
165
|
*
|
|
@@ -169,6 +181,8 @@ export interface SetAttrOptions {
|
|
|
169
181
|
mtimeMs?: number
|
|
170
182
|
/** New change time in milliseconds since epoch */
|
|
171
183
|
ctimeMs?: number
|
|
184
|
+
/** Unix user context for permission checks (required for setattr) */
|
|
185
|
+
user?: UnixUser
|
|
172
186
|
}
|
|
173
187
|
/**
|
|
174
188
|
* ArchilClient provides low-level access to Archil filesystem operations.
|
|
@@ -205,9 +219,9 @@ export declare class ArchilClient {
|
|
|
205
219
|
*/
|
|
206
220
|
close(): Promise<number>
|
|
207
221
|
/** Get attributes for an inode (uses cache). */
|
|
208
|
-
getAttributes(inodeId: number,
|
|
222
|
+
getAttributes(inodeId: number, options?: OperationOptions | undefined | null): Promise<InodeAttributes>
|
|
209
223
|
/** Lookup an entry by name in a directory (uses cache). */
|
|
210
|
-
lookupInode(parentInodeId: number, name: string,
|
|
224
|
+
lookupInode(parentInodeId: number, name: string, options?: OperationOptions | undefined | null): Promise<LookupResponse>
|
|
211
225
|
/**
|
|
212
226
|
* Read directory entries.
|
|
213
227
|
*
|
|
@@ -215,30 +229,42 @@ export declare class ArchilClient {
|
|
|
215
229
|
* the dirent cache is properly populated. This ensures that subsequent
|
|
216
230
|
* lookup_inode calls can find the entries returned here.
|
|
217
231
|
*/
|
|
218
|
-
readDirectory(inodeId: number,
|
|
232
|
+
readDirectory(inodeId: number, options?: OperationOptions | undefined | null): Promise<Array<DirectoryEntry>>
|
|
219
233
|
/** Get an extended attribute value. */
|
|
220
|
-
getExtendedAttribute(inodeId: number, name: string,
|
|
234
|
+
getExtendedAttribute(inodeId: number, name: string, options?: OperationOptions | undefined | null): Promise<Buffer | null>
|
|
221
235
|
/** List all extended attribute names. */
|
|
222
|
-
listExtendedAttributes(inodeId: number,
|
|
236
|
+
listExtendedAttributes(inodeId: number, options?: OperationOptions | undefined | null): Promise<Array<string>>
|
|
223
237
|
/**
|
|
224
238
|
* Read data from a file (uses cache).
|
|
225
239
|
*
|
|
226
240
|
* Returns zero-copy Buffer when possible for optimal performance.
|
|
227
241
|
*/
|
|
228
|
-
readInode(inodeId: number, offset: number, length: number,
|
|
242
|
+
readInode(inodeId: number, offset: number, length: number, options?: OperationOptions | undefined | null): Promise<Buffer>
|
|
229
243
|
/**
|
|
230
244
|
* Checkout (acquire delegation for) an inode for writing.
|
|
231
245
|
*
|
|
232
246
|
* This tracks the delegation locally so that subsequent write operations
|
|
233
247
|
* can proceed without additional server round-trips for permission checks.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* // Basic checkout
|
|
252
|
+
* await client.checkout(inodeId);
|
|
253
|
+
*
|
|
254
|
+
* // Force revoke existing delegations from other clients
|
|
255
|
+
* await client.checkout(inodeId, { force: true });
|
|
256
|
+
*
|
|
257
|
+
* // With user context
|
|
258
|
+
* await client.checkout(inodeId, { force: true, user: { uid: 1000, gid: 1000 } });
|
|
259
|
+
* ```
|
|
234
260
|
*/
|
|
235
|
-
checkout(inodeId: number,
|
|
261
|
+
checkout(inodeId: number, options?: CheckoutOptions | undefined | null): Promise<void>
|
|
236
262
|
/**
|
|
237
263
|
* Checkin (release delegation for) an inode.
|
|
238
264
|
*
|
|
239
265
|
* This syncs any pending writes and releases the local delegation tracking.
|
|
240
266
|
*/
|
|
241
|
-
checkin(inodeId: number,
|
|
267
|
+
checkin(inodeId: number, options?: OperationOptions | undefined | null): Promise<void>
|
|
242
268
|
/** Release all delegations held by this client. */
|
|
243
269
|
checkinAll(): Promise<number>
|
|
244
270
|
/**
|
|
@@ -258,14 +284,14 @@ export declare class ArchilClient {
|
|
|
258
284
|
* @example
|
|
259
285
|
* ```typescript
|
|
260
286
|
* // First checkout to get write delegation
|
|
261
|
-
* await client.checkout(inodeId
|
|
287
|
+
* await client.checkout(inodeId);
|
|
262
288
|
* // Then write data
|
|
263
|
-
* await client.writeData(inodeId,
|
|
289
|
+
* await client.writeData(inodeId, 0, Buffer.from('Hello World'));
|
|
264
290
|
* // Optionally checkin when done
|
|
265
|
-
* await client.checkin(inodeId
|
|
291
|
+
* await client.checkin(inodeId);
|
|
266
292
|
* ```
|
|
267
293
|
*/
|
|
268
|
-
writeData(inodeId: number, offset: number, data: Buffer,
|
|
294
|
+
writeData(inodeId: number, offset: number, data: Buffer, options?: OperationOptions | undefined | null): Promise<void>
|
|
269
295
|
/**
|
|
270
296
|
* Set attributes on an inode.
|
|
271
297
|
*
|
|
@@ -277,23 +303,23 @@ export declare class ArchilClient {
|
|
|
277
303
|
* @example
|
|
278
304
|
* ```typescript
|
|
279
305
|
* // First checkout to get write delegation
|
|
280
|
-
* await client.checkout(inodeId
|
|
306
|
+
* await client.checkout(inodeId);
|
|
281
307
|
* // Update timestamps (touch)
|
|
282
|
-
* await client.setattr(inodeId, { atimeMs: -1, mtimeMs: -1
|
|
308
|
+
* await client.setattr(inodeId, { atimeMs: -1, mtimeMs: -1, user: { uid: 1000, gid: 1000 } });
|
|
283
309
|
* // Or change mode
|
|
284
|
-
* await client.setattr(inodeId, { mode: 0o755
|
|
310
|
+
* await client.setattr(inodeId, { mode: 0o755, user: { uid: 1000, gid: 1000 } });
|
|
285
311
|
* // Checkin when done
|
|
286
|
-
* await client.checkin(inodeId
|
|
312
|
+
* await client.checkin(inodeId);
|
|
287
313
|
* ```
|
|
288
314
|
*/
|
|
289
|
-
setattr(inodeId: number, options: SetAttrOptions
|
|
315
|
+
setattr(inodeId: number, options: SetAttrOptions): Promise<InodeAttributes>
|
|
290
316
|
/**
|
|
291
317
|
* Unlink (delete) a file or empty directory.
|
|
292
318
|
*
|
|
293
319
|
* Removes the directory entry from the parent directory. Requires
|
|
294
320
|
* write permission on the parent directory.
|
|
295
321
|
*/
|
|
296
|
-
unlink(parentInodeId: number, name: string,
|
|
322
|
+
unlink(parentInodeId: number, name: string, options?: OperationOptions | undefined | null): Promise<void>
|
|
297
323
|
/**
|
|
298
324
|
* Rename (move) a file or directory.
|
|
299
325
|
*
|
|
@@ -303,10 +329,10 @@ export declare class ArchilClient {
|
|
|
303
329
|
* @example
|
|
304
330
|
* ```typescript
|
|
305
331
|
* // Move a file
|
|
306
|
-
* await client.rename(srcParentInodeId, 'oldname.txt', destParentInodeId, 'newname.txt'
|
|
332
|
+
* await client.rename(srcParentInodeId, 'oldname.txt', destParentInodeId, 'newname.txt');
|
|
307
333
|
* ```
|
|
308
334
|
*/
|
|
309
|
-
rename(parentInodeId: number, name: string, newParentInodeId: number, newName: string,
|
|
335
|
+
rename(parentInodeId: number, name: string, newParentInodeId: number, newName: string, options?: OperationOptions | undefined | null): Promise<void>
|
|
310
336
|
/**
|
|
311
337
|
* Create a new file or directory.
|
|
312
338
|
*
|
|
@@ -315,7 +341,7 @@ export declare class ArchilClient {
|
|
|
315
341
|
*
|
|
316
342
|
* Returns the inode ID of the created file.
|
|
317
343
|
*/
|
|
318
|
-
create(parentInodeId: number, name: string, attributes: InodeAttributes,
|
|
344
|
+
create(parentInodeId: number, name: string, attributes: InodeAttributes, options?: OperationOptions | undefined | null): Promise<number>
|
|
319
345
|
/** Mark an inode subtree as immutable. */
|
|
320
346
|
setImmutable(inodeId: number): Promise<void>
|
|
321
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.
|
|
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.
|
|
54
|
-
"@archildata/client-darwin-x64": "0.1.
|
|
55
|
-
"@archildata/client-linux-x64-gnu": "0.1.
|
|
56
|
-
"@archildata/client-darwin-arm64": "0.1.
|
|
57
|
-
"@archildata/client-linux-arm64-gnu": "0.1.
|
|
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
|
}
|