disk 0.8.20 → 0.8.21
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/dist/cli.mjs +1 -1
- package/dist/{disk-BLF7FFqG.d.cts → disk-BhRejJas.d.cts} +44 -10
- package/dist/{disk-BLF7FFqG.d.mts → disk-BhRejJas.d.mts} +44 -10
- package/dist/index.cjs +57 -18
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/internal/tools.d.cts +1 -1
- package/dist/internal/tools.d.mts +1 -1
- package/dist/{src-BuqSzAcO.mjs → src-CrK7pSLW.mjs} +57 -18
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as listDisks, i as deleteApiKey, n as createApiKey, o as getDisk, r as createDisk, s as listApiKeys, t as configure, y as ArchilApiError } from "./src-
|
|
2
|
+
import { c as listDisks, i as deleteApiKey, n as createApiKey, o as getDisk, r as createDisk, s as listApiKeys, t as configure, y as ArchilApiError } from "./src-CrK7pSLW.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { Command, Option } from "commander";
|
|
5
5
|
//#region bin/cli.ts
|
|
@@ -25,7 +25,7 @@ interface FileSystem {
|
|
|
25
25
|
/** Read an object's full contents. Throws `ArchilS3Error` (404) if absent. */
|
|
26
26
|
getObject(key: string): Promise<Uint8Array>;
|
|
27
27
|
/** Create or overwrite an object. */
|
|
28
|
-
putObject(key: string, body: string | Uint8Array | ArrayBuffer,
|
|
28
|
+
putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
|
|
29
29
|
/** Delete an object (idempotent). */
|
|
30
30
|
deleteObject(key: string): Promise<void>;
|
|
31
31
|
/** List objects and common (directory) prefixes under a key prefix. */
|
|
@@ -305,7 +305,20 @@ interface DeleteObjectsResult {
|
|
|
305
305
|
/** Per-key failures; empty when every key was deleted. */
|
|
306
306
|
errors: DeleteObjectsError[];
|
|
307
307
|
}
|
|
308
|
-
|
|
308
|
+
/**
|
|
309
|
+
* POSIX attributes to set on a newly created object, sent to the S3 gateway as
|
|
310
|
+
* `x-archil-*` headers. All optional — anything omitted falls back to the
|
|
311
|
+
* server-side defaults (currently `root:root`, mode `0644`).
|
|
312
|
+
*/
|
|
313
|
+
interface PosixCreateAttrs {
|
|
314
|
+
/** POSIX mode bits for the created file, e.g. `0o644`. Sent in octal. */
|
|
315
|
+
mode?: number;
|
|
316
|
+
/** Owning user id, e.g. `1000`. */
|
|
317
|
+
uid?: number;
|
|
318
|
+
/** Owning group id, e.g. `1000`. */
|
|
319
|
+
gid?: number;
|
|
320
|
+
}
|
|
321
|
+
interface PutObjectOptions extends PosixCreateAttrs {
|
|
309
322
|
/** MIME type to store the object with. Default "application/octet-stream". */
|
|
310
323
|
contentType?: string;
|
|
311
324
|
/**
|
|
@@ -323,6 +336,13 @@ interface PutObjectOptions {
|
|
|
323
336
|
/** Max parts uploaded in parallel on the multipart path. Default 4. */
|
|
324
337
|
concurrency?: number;
|
|
325
338
|
}
|
|
339
|
+
interface AppendObjectOptions extends PosixCreateAttrs {
|
|
340
|
+
/**
|
|
341
|
+
* MIME type, applied only when the object is newly created. Default
|
|
342
|
+
* "application/octet-stream".
|
|
343
|
+
*/
|
|
344
|
+
contentType?: string;
|
|
345
|
+
}
|
|
326
346
|
/**
|
|
327
347
|
* The S3 transport function {@link DiskMultipart} uses, supplied by the owning
|
|
328
348
|
* {@link Disk} so the namespace shares the disk's credential and endpoint.
|
|
@@ -333,6 +353,7 @@ type S3RequestFn = (method: "GET" | "PUT" | "DELETE" | "HEAD" | "POST", key: str
|
|
|
333
353
|
contentType?: string;
|
|
334
354
|
query?: Record<string, string | number>;
|
|
335
355
|
retry?: boolean;
|
|
356
|
+
extraHeaders?: Record<string, string>;
|
|
336
357
|
}) => Promise<{
|
|
337
358
|
ok: boolean;
|
|
338
359
|
status: number;
|
|
@@ -439,12 +460,16 @@ declare class Disk implements FileSystem {
|
|
|
439
460
|
* limits. Returns the entity tag the server assigned (a multipart upload's tag
|
|
440
461
|
* is S3's `md5(concat(partMd5s))-N` form rather than a plain MD5).
|
|
441
462
|
*
|
|
463
|
+
* Optional `mode` / `uid` / `gid` set the POSIX attributes of the published
|
|
464
|
+
* file (e.g. `{ mode: 0o644, uid: 1000, gid: 1000 }` for a non-root agent
|
|
465
|
+
* sandbox). Defaults are server-side (currently `root:root` mode `0644`).
|
|
466
|
+
*
|
|
442
467
|
* @param key Path on the disk (e.g. "reports/2026-01/data.json")
|
|
443
468
|
* @param body Contents as a string, Uint8Array/Buffer, or ArrayBuffer
|
|
444
469
|
* @param options Either a content-type string, or {@link PutObjectOptions}
|
|
445
470
|
* (`contentType`, `multipartThreshold`, `partSize`,
|
|
446
|
-
* `concurrency`). Content type defaults
|
|
447
|
-
* "application/octet-stream".
|
|
471
|
+
* `concurrency`, `mode`, `uid`, `gid`). Content type defaults
|
|
472
|
+
* to "application/octet-stream".
|
|
448
473
|
*/
|
|
449
474
|
putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
|
|
450
475
|
/**
|
|
@@ -468,11 +493,18 @@ declare class Disk implements FileSystem {
|
|
|
468
493
|
* would duplicate the bytes. On a transient failure, re-append yourself only
|
|
469
494
|
* after confirming the object's size.
|
|
470
495
|
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
* @
|
|
496
|
+
* When the object does not yet exist, optional `mode` / `uid` / `gid` set the
|
|
497
|
+
* POSIX attributes of the newly created file (same headers as
|
|
498
|
+
* {@link putObject}); they have no effect on an append to an existing object.
|
|
499
|
+
*
|
|
500
|
+
* @param key Path on the disk (e.g. "logs/app.log")
|
|
501
|
+
* @param body Bytes to append (string, Uint8Array/Buffer, or ArrayBuffer)
|
|
502
|
+
* @param options Either a content-type string, or {@link AppendObjectOptions}
|
|
503
|
+
* (`contentType`, `mode`, `uid`, `gid`). Content type defaults
|
|
504
|
+
* to "application/octet-stream" and applies only when the
|
|
505
|
+
* object is newly created.
|
|
474
506
|
*/
|
|
475
|
-
appendObject(key: string, body: string | Uint8Array | ArrayBuffer,
|
|
507
|
+
appendObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | AppendObjectOptions): Promise<PutObjectResult>;
|
|
476
508
|
/**
|
|
477
509
|
* Delete an object from the disk via the S3-compatible DeleteObject API.
|
|
478
510
|
* Idempotent: deleting a key that doesn't exist resolves successfully, per
|
|
@@ -572,8 +604,10 @@ declare class DiskMultipart {
|
|
|
572
604
|
*
|
|
573
605
|
* @param key Path on the disk the finished object will live at.
|
|
574
606
|
* @param contentType MIME type to store the object with.
|
|
607
|
+
* @param attrs Optional POSIX `mode` / `uid` / `gid` for the completed
|
|
608
|
+
* object (see {@link PosixCreateAttrs}).
|
|
575
609
|
*/
|
|
576
|
-
create(key: string, contentType?: string): Promise<MultipartUpload>;
|
|
610
|
+
create(key: string, contentType?: string, attrs?: PosixCreateAttrs): Promise<MultipartUpload>;
|
|
577
611
|
/**
|
|
578
612
|
* Upload one part (UploadPart) and return its entity tag, which you must
|
|
579
613
|
* collect (with its part number) and pass to {@link complete}. Every part
|
|
@@ -638,4 +672,4 @@ declare class DiskMultipart {
|
|
|
638
672
|
*/
|
|
639
673
|
declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
|
|
640
674
|
//#endregion
|
|
641
|
-
export {
|
|
675
|
+
export { FileSystem as $, ApiTokenResponse as A, DiskUser as B, PutObjectOptions as C, ShareUrlResult as D, ShareUrlOptions as E, CreateApiTokenRequest as F, GrepStoppedReason as G, ExecRequest as H, CreateDiskRequest as I, MountResponse as J, MountConfig as K, DiskMetrics as L, AwsStsUser as M, AzureBlobMount as N, UploadPart as O, ConnectedClient as P, TokenUser as Q, DiskResponse as R, PosixCreateAttrs as S, S3Object as T, GCSMount as U, ExecDiskResult as V, GrepMatch as W, S3CompatibleMount as X, R2Mount as Y, S3Mount as Z, MultipartUploadListing as _, DeleteObjectsResult as a, PartInfo as b, ExecResult as c, ListMultipartUploadsOptions as d, ApiClient as et, ListObjectsOptions as f, MultipartUpload as g, MountOptions as h, DeleteObjectsOptions as i, AuthorizedUser as j, effectiveUploadPartSize as k, GrepOptions as l, ListPartsOptions as m, CompletedMultipartUpload as n, Disk as o, ListObjectsResult as p, MountConfigResponse as q, DeleteObjectsError as r, DiskMultipart as s, AppendObjectOptions as t, GrepResult as u, MultipartUploadSummary as v, PutObjectResult as w, PartListing as x, ObjectMetadata as y, DiskStatus as z };
|
|
@@ -25,7 +25,7 @@ interface FileSystem {
|
|
|
25
25
|
/** Read an object's full contents. Throws `ArchilS3Error` (404) if absent. */
|
|
26
26
|
getObject(key: string): Promise<Uint8Array>;
|
|
27
27
|
/** Create or overwrite an object. */
|
|
28
|
-
putObject(key: string, body: string | Uint8Array | ArrayBuffer,
|
|
28
|
+
putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
|
|
29
29
|
/** Delete an object (idempotent). */
|
|
30
30
|
deleteObject(key: string): Promise<void>;
|
|
31
31
|
/** List objects and common (directory) prefixes under a key prefix. */
|
|
@@ -305,7 +305,20 @@ interface DeleteObjectsResult {
|
|
|
305
305
|
/** Per-key failures; empty when every key was deleted. */
|
|
306
306
|
errors: DeleteObjectsError[];
|
|
307
307
|
}
|
|
308
|
-
|
|
308
|
+
/**
|
|
309
|
+
* POSIX attributes to set on a newly created object, sent to the S3 gateway as
|
|
310
|
+
* `x-archil-*` headers. All optional — anything omitted falls back to the
|
|
311
|
+
* server-side defaults (currently `root:root`, mode `0644`).
|
|
312
|
+
*/
|
|
313
|
+
interface PosixCreateAttrs {
|
|
314
|
+
/** POSIX mode bits for the created file, e.g. `0o644`. Sent in octal. */
|
|
315
|
+
mode?: number;
|
|
316
|
+
/** Owning user id, e.g. `1000`. */
|
|
317
|
+
uid?: number;
|
|
318
|
+
/** Owning group id, e.g. `1000`. */
|
|
319
|
+
gid?: number;
|
|
320
|
+
}
|
|
321
|
+
interface PutObjectOptions extends PosixCreateAttrs {
|
|
309
322
|
/** MIME type to store the object with. Default "application/octet-stream". */
|
|
310
323
|
contentType?: string;
|
|
311
324
|
/**
|
|
@@ -323,6 +336,13 @@ interface PutObjectOptions {
|
|
|
323
336
|
/** Max parts uploaded in parallel on the multipart path. Default 4. */
|
|
324
337
|
concurrency?: number;
|
|
325
338
|
}
|
|
339
|
+
interface AppendObjectOptions extends PosixCreateAttrs {
|
|
340
|
+
/**
|
|
341
|
+
* MIME type, applied only when the object is newly created. Default
|
|
342
|
+
* "application/octet-stream".
|
|
343
|
+
*/
|
|
344
|
+
contentType?: string;
|
|
345
|
+
}
|
|
326
346
|
/**
|
|
327
347
|
* The S3 transport function {@link DiskMultipart} uses, supplied by the owning
|
|
328
348
|
* {@link Disk} so the namespace shares the disk's credential and endpoint.
|
|
@@ -333,6 +353,7 @@ type S3RequestFn = (method: "GET" | "PUT" | "DELETE" | "HEAD" | "POST", key: str
|
|
|
333
353
|
contentType?: string;
|
|
334
354
|
query?: Record<string, string | number>;
|
|
335
355
|
retry?: boolean;
|
|
356
|
+
extraHeaders?: Record<string, string>;
|
|
336
357
|
}) => Promise<{
|
|
337
358
|
ok: boolean;
|
|
338
359
|
status: number;
|
|
@@ -439,12 +460,16 @@ declare class Disk implements FileSystem {
|
|
|
439
460
|
* limits. Returns the entity tag the server assigned (a multipart upload's tag
|
|
440
461
|
* is S3's `md5(concat(partMd5s))-N` form rather than a plain MD5).
|
|
441
462
|
*
|
|
463
|
+
* Optional `mode` / `uid` / `gid` set the POSIX attributes of the published
|
|
464
|
+
* file (e.g. `{ mode: 0o644, uid: 1000, gid: 1000 }` for a non-root agent
|
|
465
|
+
* sandbox). Defaults are server-side (currently `root:root` mode `0644`).
|
|
466
|
+
*
|
|
442
467
|
* @param key Path on the disk (e.g. "reports/2026-01/data.json")
|
|
443
468
|
* @param body Contents as a string, Uint8Array/Buffer, or ArrayBuffer
|
|
444
469
|
* @param options Either a content-type string, or {@link PutObjectOptions}
|
|
445
470
|
* (`contentType`, `multipartThreshold`, `partSize`,
|
|
446
|
-
* `concurrency`). Content type defaults
|
|
447
|
-
* "application/octet-stream".
|
|
471
|
+
* `concurrency`, `mode`, `uid`, `gid`). Content type defaults
|
|
472
|
+
* to "application/octet-stream".
|
|
448
473
|
*/
|
|
449
474
|
putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
|
|
450
475
|
/**
|
|
@@ -468,11 +493,18 @@ declare class Disk implements FileSystem {
|
|
|
468
493
|
* would duplicate the bytes. On a transient failure, re-append yourself only
|
|
469
494
|
* after confirming the object's size.
|
|
470
495
|
*
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
* @
|
|
496
|
+
* When the object does not yet exist, optional `mode` / `uid` / `gid` set the
|
|
497
|
+
* POSIX attributes of the newly created file (same headers as
|
|
498
|
+
* {@link putObject}); they have no effect on an append to an existing object.
|
|
499
|
+
*
|
|
500
|
+
* @param key Path on the disk (e.g. "logs/app.log")
|
|
501
|
+
* @param body Bytes to append (string, Uint8Array/Buffer, or ArrayBuffer)
|
|
502
|
+
* @param options Either a content-type string, or {@link AppendObjectOptions}
|
|
503
|
+
* (`contentType`, `mode`, `uid`, `gid`). Content type defaults
|
|
504
|
+
* to "application/octet-stream" and applies only when the
|
|
505
|
+
* object is newly created.
|
|
474
506
|
*/
|
|
475
|
-
appendObject(key: string, body: string | Uint8Array | ArrayBuffer,
|
|
507
|
+
appendObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | AppendObjectOptions): Promise<PutObjectResult>;
|
|
476
508
|
/**
|
|
477
509
|
* Delete an object from the disk via the S3-compatible DeleteObject API.
|
|
478
510
|
* Idempotent: deleting a key that doesn't exist resolves successfully, per
|
|
@@ -572,8 +604,10 @@ declare class DiskMultipart {
|
|
|
572
604
|
*
|
|
573
605
|
* @param key Path on the disk the finished object will live at.
|
|
574
606
|
* @param contentType MIME type to store the object with.
|
|
607
|
+
* @param attrs Optional POSIX `mode` / `uid` / `gid` for the completed
|
|
608
|
+
* object (see {@link PosixCreateAttrs}).
|
|
575
609
|
*/
|
|
576
|
-
create(key: string, contentType?: string): Promise<MultipartUpload>;
|
|
610
|
+
create(key: string, contentType?: string, attrs?: PosixCreateAttrs): Promise<MultipartUpload>;
|
|
577
611
|
/**
|
|
578
612
|
* Upload one part (UploadPart) and return its entity tag, which you must
|
|
579
613
|
* collect (with its part number) and pass to {@link complete}. Every part
|
|
@@ -638,4 +672,4 @@ declare class DiskMultipart {
|
|
|
638
672
|
*/
|
|
639
673
|
declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
|
|
640
674
|
//#endregion
|
|
641
|
-
export {
|
|
675
|
+
export { FileSystem as $, ApiTokenResponse as A, DiskUser as B, PutObjectOptions as C, ShareUrlResult as D, ShareUrlOptions as E, CreateApiTokenRequest as F, GrepStoppedReason as G, ExecRequest as H, CreateDiskRequest as I, MountResponse as J, MountConfig as K, DiskMetrics as L, AwsStsUser as M, AzureBlobMount as N, UploadPart as O, ConnectedClient as P, TokenUser as Q, DiskResponse as R, PosixCreateAttrs as S, S3Object as T, GCSMount as U, ExecDiskResult as V, GrepMatch as W, S3CompatibleMount as X, R2Mount as Y, S3Mount as Z, MultipartUploadListing as _, DeleteObjectsResult as a, PartInfo as b, ExecResult as c, ListMultipartUploadsOptions as d, ApiClient as et, ListObjectsOptions as f, MultipartUpload as g, MountOptions as h, DeleteObjectsOptions as i, AuthorizedUser as j, effectiveUploadPartSize as k, GrepOptions as l, ListPartsOptions as m, CompletedMultipartUpload as n, Disk as o, ListObjectsResult as p, MountConfigResponse as q, DeleteObjectsError as r, DiskMultipart as s, AppendObjectOptions as t, GrepResult as u, MultipartUploadSummary as v, PutObjectResult as w, PartListing as x, ObjectMetadata as y, DiskStatus as z };
|
package/dist/index.cjs
CHANGED
|
@@ -134,7 +134,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
|
|
|
134
134
|
}
|
|
135
135
|
//#endregion
|
|
136
136
|
//#region src/version.ts
|
|
137
|
-
const VERSION = "0.8.
|
|
137
|
+
const VERSION = "0.8.21";
|
|
138
138
|
const USER_AGENT = `archil-js/${VERSION}`;
|
|
139
139
|
//#endregion
|
|
140
140
|
//#region src/client.ts
|
|
@@ -394,12 +394,16 @@ var Disk = class {
|
|
|
394
394
|
* limits. Returns the entity tag the server assigned (a multipart upload's tag
|
|
395
395
|
* is S3's `md5(concat(partMd5s))-N` form rather than a plain MD5).
|
|
396
396
|
*
|
|
397
|
+
* Optional `mode` / `uid` / `gid` set the POSIX attributes of the published
|
|
398
|
+
* file (e.g. `{ mode: 0o644, uid: 1000, gid: 1000 }` for a non-root agent
|
|
399
|
+
* sandbox). Defaults are server-side (currently `root:root` mode `0644`).
|
|
400
|
+
*
|
|
397
401
|
* @param key Path on the disk (e.g. "reports/2026-01/data.json")
|
|
398
402
|
* @param body Contents as a string, Uint8Array/Buffer, or ArrayBuffer
|
|
399
403
|
* @param options Either a content-type string, or {@link PutObjectOptions}
|
|
400
404
|
* (`contentType`, `multipartThreshold`, `partSize`,
|
|
401
|
-
* `concurrency`). Content type defaults
|
|
402
|
-
* "application/octet-stream".
|
|
405
|
+
* `concurrency`, `mode`, `uid`, `gid`). Content type defaults
|
|
406
|
+
* to "application/octet-stream".
|
|
403
407
|
*/
|
|
404
408
|
async putObject(key, body, options) {
|
|
405
409
|
const opts = typeof options === "string" ? { contentType: options } : options ?? {};
|
|
@@ -410,22 +414,23 @@ var Disk = class {
|
|
|
410
414
|
if (bytes.length <= threshold) {
|
|
411
415
|
const resp = await this._s3Request("PUT", key, {
|
|
412
416
|
body,
|
|
413
|
-
contentType
|
|
417
|
+
contentType,
|
|
418
|
+
extraHeaders: posixCreateHeaders(opts)
|
|
414
419
|
});
|
|
415
420
|
if (!resp.ok) throw parseS3Error("PutObject", resp.status, resp.statusText, decodeText(resp.body));
|
|
416
421
|
return { etag: resp.headers.get("etag") ?? void 0 };
|
|
417
422
|
}
|
|
418
|
-
return this._putMultipart(key, bytes, contentType, partSize, Math.max(1, opts.concurrency ?? DEFAULT_UPLOAD_CONCURRENCY));
|
|
423
|
+
return this._putMultipart(key, bytes, contentType, partSize, Math.max(1, opts.concurrency ?? DEFAULT_UPLOAD_CONCURRENCY), opts);
|
|
419
424
|
}
|
|
420
425
|
/**
|
|
421
426
|
* Upload a large body through the multipart lifecycle: split into `partSize`
|
|
422
427
|
* parts, upload them with bounded concurrency, then complete — aborting the
|
|
423
428
|
* upload if any part fails so nothing is left half-staged. @internal
|
|
424
429
|
*/
|
|
425
|
-
async _putMultipart(key, bytes, contentType, partSize, concurrency) {
|
|
430
|
+
async _putMultipart(key, bytes, contentType, partSize, concurrency, attrs = {}) {
|
|
426
431
|
const effectivePartSize = effectiveUploadPartSize(bytes.length, partSize);
|
|
427
432
|
const mp = this.multipart;
|
|
428
|
-
const upload = await mp.create(key, contentType);
|
|
433
|
+
const upload = await mp.create(key, contentType, attrs);
|
|
429
434
|
try {
|
|
430
435
|
const partCount = Math.ceil(bytes.length / effectivePartSize);
|
|
431
436
|
const parts = new Array(partCount);
|
|
@@ -461,16 +466,25 @@ var Disk = class {
|
|
|
461
466
|
* would duplicate the bytes. On a transient failure, re-append yourself only
|
|
462
467
|
* after confirming the object's size.
|
|
463
468
|
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
* @
|
|
469
|
+
* When the object does not yet exist, optional `mode` / `uid` / `gid` set the
|
|
470
|
+
* POSIX attributes of the newly created file (same headers as
|
|
471
|
+
* {@link putObject}); they have no effect on an append to an existing object.
|
|
472
|
+
*
|
|
473
|
+
* @param key Path on the disk (e.g. "logs/app.log")
|
|
474
|
+
* @param body Bytes to append (string, Uint8Array/Buffer, or ArrayBuffer)
|
|
475
|
+
* @param options Either a content-type string, or {@link AppendObjectOptions}
|
|
476
|
+
* (`contentType`, `mode`, `uid`, `gid`). Content type defaults
|
|
477
|
+
* to "application/octet-stream" and applies only when the
|
|
478
|
+
* object is newly created.
|
|
467
479
|
*/
|
|
468
|
-
async appendObject(key, body,
|
|
480
|
+
async appendObject(key, body, options) {
|
|
481
|
+
const opts = typeof options === "string" ? { contentType: options } : options ?? {};
|
|
469
482
|
const resp = await this._s3Request("PUT", key, {
|
|
470
483
|
body,
|
|
471
|
-
contentType,
|
|
484
|
+
contentType: opts.contentType ?? "application/octet-stream",
|
|
472
485
|
query: { append: "true" },
|
|
473
|
-
retry: false
|
|
486
|
+
retry: false,
|
|
487
|
+
extraHeaders: posixCreateHeaders(opts)
|
|
474
488
|
});
|
|
475
489
|
if (!resp.ok) throw parseS3Error("AppendObject", resp.status, resp.statusText, decodeText(resp.body));
|
|
476
490
|
return { etag: resp.headers.get("etag") ?? void 0 };
|
|
@@ -636,7 +650,10 @@ var Disk = class {
|
|
|
636
650
|
body: opts.body,
|
|
637
651
|
bodySerializer: (b) => b
|
|
638
652
|
} : {},
|
|
639
|
-
...opts.contentType
|
|
653
|
+
...opts.contentType || opts.extraHeaders ? { headers: {
|
|
654
|
+
...opts.contentType ? { "Content-Type": opts.contentType } : {},
|
|
655
|
+
...opts.extraHeaders
|
|
656
|
+
} } : {}
|
|
640
657
|
};
|
|
641
658
|
const hasBody = method === "GET" || method === "POST";
|
|
642
659
|
const maxRetries = opts.retry === false ? 0 : MAX_S3_RETRIES;
|
|
@@ -722,11 +739,14 @@ var DiskMultipart = class {
|
|
|
722
739
|
*
|
|
723
740
|
* @param key Path on the disk the finished object will live at.
|
|
724
741
|
* @param contentType MIME type to store the object with.
|
|
742
|
+
* @param attrs Optional POSIX `mode` / `uid` / `gid` for the completed
|
|
743
|
+
* object (see {@link PosixCreateAttrs}).
|
|
725
744
|
*/
|
|
726
|
-
async create(key, contentType) {
|
|
745
|
+
async create(key, contentType, attrs = {}) {
|
|
727
746
|
const resp = await this.s3Request("POST", key, {
|
|
728
747
|
query: { uploads: "" },
|
|
729
|
-
contentType
|
|
748
|
+
contentType,
|
|
749
|
+
extraHeaders: posixCreateHeaders(attrs)
|
|
730
750
|
});
|
|
731
751
|
if (!resp.ok) throw parseS3Error("CreateMultipartUpload", resp.status, resp.statusText, decodeText(resp.body));
|
|
732
752
|
const root = parseXml(decodeText(resp.body)).InitiateMultipartUploadResult ?? {};
|
|
@@ -847,6 +867,25 @@ var DiskMultipart = class {
|
|
|
847
867
|
return parseListMultipartUploadsResult(decodeText(resp.body));
|
|
848
868
|
}
|
|
849
869
|
};
|
|
870
|
+
/**
|
|
871
|
+
* Headers the S3 gateway accepts to set POSIX mode/owner on newly created
|
|
872
|
+
* objects (see fshandler `x-archil-*` PutObject attrs).
|
|
873
|
+
*/
|
|
874
|
+
const ARCHIL_MODE_HEADER = "x-archil-mode";
|
|
875
|
+
const ARCHIL_UID_HEADER = "x-archil-uid";
|
|
876
|
+
const ARCHIL_GID_HEADER = "x-archil-gid";
|
|
877
|
+
/**
|
|
878
|
+
* Build the `x-archil-*` headers for {@link PosixCreateAttrs}. `mode` is sent
|
|
879
|
+
* in octal (`0o640` → "640"), matching the gateway's parser and the Python SDK.
|
|
880
|
+
* Returns undefined when no attribute is set, so no headers are added.
|
|
881
|
+
*/
|
|
882
|
+
function posixCreateHeaders(attrs) {
|
|
883
|
+
const headers = {};
|
|
884
|
+
if (attrs.mode !== void 0) headers[ARCHIL_MODE_HEADER] = attrs.mode.toString(8);
|
|
885
|
+
if (attrs.uid !== void 0) headers[ARCHIL_UID_HEADER] = String(attrs.uid);
|
|
886
|
+
if (attrs.gid !== void 0) headers[ARCHIL_GID_HEADER] = String(attrs.gid);
|
|
887
|
+
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
888
|
+
}
|
|
850
889
|
/** S3's per-request cap on DeleteObjects keys; larger inputs are batched. */
|
|
851
890
|
const MAX_DELETE_OBJECTS_PER_REQUEST = 1e3;
|
|
852
891
|
/** Automatic retries for a transient S3 failure (5xx / 429 / network error). */
|
|
@@ -1226,10 +1265,10 @@ var Workspace = class {
|
|
|
1226
1265
|
const { entry, diskKey } = this.route(key);
|
|
1227
1266
|
return entry.disk.getObject(diskKey);
|
|
1228
1267
|
}
|
|
1229
|
-
async putObject(key, body,
|
|
1268
|
+
async putObject(key, body, options) {
|
|
1230
1269
|
const { entry, diskKey } = this.route(key);
|
|
1231
1270
|
if (entry.readOnly) throw new Error(`${key} is on a read-only disk and cannot be written.`);
|
|
1232
|
-
return entry.disk.putObject(diskKey, body,
|
|
1271
|
+
return entry.disk.putObject(diskKey, body, options);
|
|
1233
1272
|
}
|
|
1234
1273
|
async deleteObject(key) {
|
|
1235
1274
|
const { entry, diskKey } = this.route(key);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { $ as FileSystem, A as ApiTokenResponse, B as DiskUser, C as PutObjectOptions, D as ShareUrlResult, E as ShareUrlOptions, F as CreateApiTokenRequest, G as GrepStoppedReason, H as ExecRequest, I as CreateDiskRequest, J as MountResponse, K as MountConfig, L as DiskMetrics, M as AwsStsUser, N as AzureBlobMount, O as UploadPart, P as ConnectedClient, Q as TokenUser, R as DiskResponse, S as PosixCreateAttrs, T as S3Object, U as GCSMount, V as ExecDiskResult, W as GrepMatch, X as S3CompatibleMount, Y as R2Mount, Z as S3Mount, _ as MultipartUploadListing, a as DeleteObjectsResult, b as PartInfo, c as ExecResult, d as ListMultipartUploadsOptions, et as ApiClient, f as ListObjectsOptions, g as MultipartUpload, h as MountOptions, i as DeleteObjectsOptions, j as AuthorizedUser, k as effectiveUploadPartSize, l as GrepOptions, m as ListPartsOptions, n as CompletedMultipartUpload, o as Disk, p as ListObjectsResult, q as MountConfigResponse, r as DeleteObjectsError, s as DiskMultipart, t as AppendObjectOptions, u as GrepResult, v as MultipartUploadSummary, w as PutObjectResult, x as PartListing, y as ObjectMetadata, z as DiskStatus } from "./disk-BhRejJas.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/disks.d.ts
|
|
4
4
|
interface ListDisksOptions {
|
|
@@ -114,7 +114,7 @@ declare class Workspace implements FileSystem {
|
|
|
114
114
|
/** Map a disk key back to its workspace key (`<name>/...`), stripping the mount subdirectory. */
|
|
115
115
|
private abs;
|
|
116
116
|
getObject(key: string): Promise<Uint8Array>;
|
|
117
|
-
putObject(key: string, body: string | Uint8Array | ArrayBuffer,
|
|
117
|
+
putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
|
|
118
118
|
deleteObject(key: string): Promise<void>;
|
|
119
119
|
listObjects(prefix?: string, opts?: ListObjectsOptions): Promise<ListObjectsResult>;
|
|
120
120
|
grep(opts: GrepOptions): Promise<GrepResult>;
|
|
@@ -284,4 +284,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
284
284
|
*/
|
|
285
285
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
286
286
|
//#endregion
|
|
287
|
-
export { type ApiTokenResponse, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PutObjectOptions, type PutObjectResult, type R2Mount, type S3CompatibleMount, type S3Mount, type S3Object, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
|
|
287
|
+
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type S3CompatibleMount, type S3Mount, type S3Object, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { $ as FileSystem, A as ApiTokenResponse, B as DiskUser, C as PutObjectOptions, D as ShareUrlResult, E as ShareUrlOptions, F as CreateApiTokenRequest, G as GrepStoppedReason, H as ExecRequest, I as CreateDiskRequest, J as MountResponse, K as MountConfig, L as DiskMetrics, M as AwsStsUser, N as AzureBlobMount, O as UploadPart, P as ConnectedClient, Q as TokenUser, R as DiskResponse, S as PosixCreateAttrs, T as S3Object, U as GCSMount, V as ExecDiskResult, W as GrepMatch, X as S3CompatibleMount, Y as R2Mount, Z as S3Mount, _ as MultipartUploadListing, a as DeleteObjectsResult, b as PartInfo, c as ExecResult, d as ListMultipartUploadsOptions, et as ApiClient, f as ListObjectsOptions, g as MultipartUpload, h as MountOptions, i as DeleteObjectsOptions, j as AuthorizedUser, k as effectiveUploadPartSize, l as GrepOptions, m as ListPartsOptions, n as CompletedMultipartUpload, o as Disk, p as ListObjectsResult, q as MountConfigResponse, r as DeleteObjectsError, s as DiskMultipart, t as AppendObjectOptions, u as GrepResult, v as MultipartUploadSummary, w as PutObjectResult, x as PartListing, y as ObjectMetadata, z as DiskStatus } from "./disk-BhRejJas.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/disks.d.ts
|
|
4
4
|
interface ListDisksOptions {
|
|
@@ -114,7 +114,7 @@ declare class Workspace implements FileSystem {
|
|
|
114
114
|
/** Map a disk key back to its workspace key (`<name>/...`), stripping the mount subdirectory. */
|
|
115
115
|
private abs;
|
|
116
116
|
getObject(key: string): Promise<Uint8Array>;
|
|
117
|
-
putObject(key: string, body: string | Uint8Array | ArrayBuffer,
|
|
117
|
+
putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
|
|
118
118
|
deleteObject(key: string): Promise<void>;
|
|
119
119
|
listObjects(prefix?: string, opts?: ListObjectsOptions): Promise<ListObjectsResult>;
|
|
120
120
|
grep(opts: GrepOptions): Promise<GrepResult>;
|
|
@@ -284,4 +284,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
284
284
|
*/
|
|
285
285
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
286
286
|
//#endregion
|
|
287
|
-
export { type ApiTokenResponse, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PutObjectOptions, type PutObjectResult, type R2Mount, type S3CompatibleMount, type S3Mount, type S3Object, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
|
|
287
|
+
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type S3CompatibleMount, type S3Mount, type S3Object, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as USER_AGENT, a as exec, b as ArchilError, c as listDisks, d as Workspace, f as Tokens, g as effectiveUploadPartSize, h as DiskMultipart, i as deleteApiKey, l as workspace, m as Disk, n as createApiKey, o as getDisk, p as Disks, r as createDisk, s as listApiKeys, t as configure, u as Archil, v as VERSION, x as ArchilS3Error, y as ArchilApiError } from "./src-
|
|
1
|
+
import { _ as USER_AGENT, a as exec, b as ArchilError, c as listDisks, d as Workspace, f as Tokens, g as effectiveUploadPartSize, h as DiskMultipart, i as deleteApiKey, l as workspace, m as Disk, n as createApiKey, o as getDisk, p as Disks, r as createDisk, s as listApiKeys, t as configure, u as Archil, v as VERSION, x as ArchilS3Error, y as ArchilApiError } from "./src-CrK7pSLW.mjs";
|
|
2
2
|
export { Archil, ArchilApiError, ArchilError, ArchilS3Error, Disk, DiskMultipart, Disks, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, deleteApiKey, effectiveUploadPartSize, exec, getDisk, listApiKeys, listDisks, workspace };
|
|
@@ -111,7 +111,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
|
|
|
111
111
|
}
|
|
112
112
|
//#endregion
|
|
113
113
|
//#region src/version.ts
|
|
114
|
-
const VERSION = "0.8.
|
|
114
|
+
const VERSION = "0.8.21";
|
|
115
115
|
const USER_AGENT = `archil-js/${VERSION}`;
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/client.ts
|
|
@@ -371,12 +371,16 @@ var Disk = class {
|
|
|
371
371
|
* limits. Returns the entity tag the server assigned (a multipart upload's tag
|
|
372
372
|
* is S3's `md5(concat(partMd5s))-N` form rather than a plain MD5).
|
|
373
373
|
*
|
|
374
|
+
* Optional `mode` / `uid` / `gid` set the POSIX attributes of the published
|
|
375
|
+
* file (e.g. `{ mode: 0o644, uid: 1000, gid: 1000 }` for a non-root agent
|
|
376
|
+
* sandbox). Defaults are server-side (currently `root:root` mode `0644`).
|
|
377
|
+
*
|
|
374
378
|
* @param key Path on the disk (e.g. "reports/2026-01/data.json")
|
|
375
379
|
* @param body Contents as a string, Uint8Array/Buffer, or ArrayBuffer
|
|
376
380
|
* @param options Either a content-type string, or {@link PutObjectOptions}
|
|
377
381
|
* (`contentType`, `multipartThreshold`, `partSize`,
|
|
378
|
-
* `concurrency`). Content type defaults
|
|
379
|
-
* "application/octet-stream".
|
|
382
|
+
* `concurrency`, `mode`, `uid`, `gid`). Content type defaults
|
|
383
|
+
* to "application/octet-stream".
|
|
380
384
|
*/
|
|
381
385
|
async putObject(key, body, options) {
|
|
382
386
|
const opts = typeof options === "string" ? { contentType: options } : options ?? {};
|
|
@@ -387,22 +391,23 @@ var Disk = class {
|
|
|
387
391
|
if (bytes.length <= threshold) {
|
|
388
392
|
const resp = await this._s3Request("PUT", key, {
|
|
389
393
|
body,
|
|
390
|
-
contentType
|
|
394
|
+
contentType,
|
|
395
|
+
extraHeaders: posixCreateHeaders(opts)
|
|
391
396
|
});
|
|
392
397
|
if (!resp.ok) throw parseS3Error("PutObject", resp.status, resp.statusText, decodeText(resp.body));
|
|
393
398
|
return { etag: resp.headers.get("etag") ?? void 0 };
|
|
394
399
|
}
|
|
395
|
-
return this._putMultipart(key, bytes, contentType, partSize, Math.max(1, opts.concurrency ?? DEFAULT_UPLOAD_CONCURRENCY));
|
|
400
|
+
return this._putMultipart(key, bytes, contentType, partSize, Math.max(1, opts.concurrency ?? DEFAULT_UPLOAD_CONCURRENCY), opts);
|
|
396
401
|
}
|
|
397
402
|
/**
|
|
398
403
|
* Upload a large body through the multipart lifecycle: split into `partSize`
|
|
399
404
|
* parts, upload them with bounded concurrency, then complete — aborting the
|
|
400
405
|
* upload if any part fails so nothing is left half-staged. @internal
|
|
401
406
|
*/
|
|
402
|
-
async _putMultipart(key, bytes, contentType, partSize, concurrency) {
|
|
407
|
+
async _putMultipart(key, bytes, contentType, partSize, concurrency, attrs = {}) {
|
|
403
408
|
const effectivePartSize = effectiveUploadPartSize(bytes.length, partSize);
|
|
404
409
|
const mp = this.multipart;
|
|
405
|
-
const upload = await mp.create(key, contentType);
|
|
410
|
+
const upload = await mp.create(key, contentType, attrs);
|
|
406
411
|
try {
|
|
407
412
|
const partCount = Math.ceil(bytes.length / effectivePartSize);
|
|
408
413
|
const parts = new Array(partCount);
|
|
@@ -438,16 +443,25 @@ var Disk = class {
|
|
|
438
443
|
* would duplicate the bytes. On a transient failure, re-append yourself only
|
|
439
444
|
* after confirming the object's size.
|
|
440
445
|
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
* @
|
|
446
|
+
* When the object does not yet exist, optional `mode` / `uid` / `gid` set the
|
|
447
|
+
* POSIX attributes of the newly created file (same headers as
|
|
448
|
+
* {@link putObject}); they have no effect on an append to an existing object.
|
|
449
|
+
*
|
|
450
|
+
* @param key Path on the disk (e.g. "logs/app.log")
|
|
451
|
+
* @param body Bytes to append (string, Uint8Array/Buffer, or ArrayBuffer)
|
|
452
|
+
* @param options Either a content-type string, or {@link AppendObjectOptions}
|
|
453
|
+
* (`contentType`, `mode`, `uid`, `gid`). Content type defaults
|
|
454
|
+
* to "application/octet-stream" and applies only when the
|
|
455
|
+
* object is newly created.
|
|
444
456
|
*/
|
|
445
|
-
async appendObject(key, body,
|
|
457
|
+
async appendObject(key, body, options) {
|
|
458
|
+
const opts = typeof options === "string" ? { contentType: options } : options ?? {};
|
|
446
459
|
const resp = await this._s3Request("PUT", key, {
|
|
447
460
|
body,
|
|
448
|
-
contentType,
|
|
461
|
+
contentType: opts.contentType ?? "application/octet-stream",
|
|
449
462
|
query: { append: "true" },
|
|
450
|
-
retry: false
|
|
463
|
+
retry: false,
|
|
464
|
+
extraHeaders: posixCreateHeaders(opts)
|
|
451
465
|
});
|
|
452
466
|
if (!resp.ok) throw parseS3Error("AppendObject", resp.status, resp.statusText, decodeText(resp.body));
|
|
453
467
|
return { etag: resp.headers.get("etag") ?? void 0 };
|
|
@@ -613,7 +627,10 @@ var Disk = class {
|
|
|
613
627
|
body: opts.body,
|
|
614
628
|
bodySerializer: (b) => b
|
|
615
629
|
} : {},
|
|
616
|
-
...opts.contentType
|
|
630
|
+
...opts.contentType || opts.extraHeaders ? { headers: {
|
|
631
|
+
...opts.contentType ? { "Content-Type": opts.contentType } : {},
|
|
632
|
+
...opts.extraHeaders
|
|
633
|
+
} } : {}
|
|
617
634
|
};
|
|
618
635
|
const hasBody = method === "GET" || method === "POST";
|
|
619
636
|
const maxRetries = opts.retry === false ? 0 : MAX_S3_RETRIES;
|
|
@@ -699,11 +716,14 @@ var DiskMultipart = class {
|
|
|
699
716
|
*
|
|
700
717
|
* @param key Path on the disk the finished object will live at.
|
|
701
718
|
* @param contentType MIME type to store the object with.
|
|
719
|
+
* @param attrs Optional POSIX `mode` / `uid` / `gid` for the completed
|
|
720
|
+
* object (see {@link PosixCreateAttrs}).
|
|
702
721
|
*/
|
|
703
|
-
async create(key, contentType) {
|
|
722
|
+
async create(key, contentType, attrs = {}) {
|
|
704
723
|
const resp = await this.s3Request("POST", key, {
|
|
705
724
|
query: { uploads: "" },
|
|
706
|
-
contentType
|
|
725
|
+
contentType,
|
|
726
|
+
extraHeaders: posixCreateHeaders(attrs)
|
|
707
727
|
});
|
|
708
728
|
if (!resp.ok) throw parseS3Error("CreateMultipartUpload", resp.status, resp.statusText, decodeText(resp.body));
|
|
709
729
|
const root = parseXml(decodeText(resp.body)).InitiateMultipartUploadResult ?? {};
|
|
@@ -824,6 +844,25 @@ var DiskMultipart = class {
|
|
|
824
844
|
return parseListMultipartUploadsResult(decodeText(resp.body));
|
|
825
845
|
}
|
|
826
846
|
};
|
|
847
|
+
/**
|
|
848
|
+
* Headers the S3 gateway accepts to set POSIX mode/owner on newly created
|
|
849
|
+
* objects (see fshandler `x-archil-*` PutObject attrs).
|
|
850
|
+
*/
|
|
851
|
+
const ARCHIL_MODE_HEADER = "x-archil-mode";
|
|
852
|
+
const ARCHIL_UID_HEADER = "x-archil-uid";
|
|
853
|
+
const ARCHIL_GID_HEADER = "x-archil-gid";
|
|
854
|
+
/**
|
|
855
|
+
* Build the `x-archil-*` headers for {@link PosixCreateAttrs}. `mode` is sent
|
|
856
|
+
* in octal (`0o640` → "640"), matching the gateway's parser and the Python SDK.
|
|
857
|
+
* Returns undefined when no attribute is set, so no headers are added.
|
|
858
|
+
*/
|
|
859
|
+
function posixCreateHeaders(attrs) {
|
|
860
|
+
const headers = {};
|
|
861
|
+
if (attrs.mode !== void 0) headers[ARCHIL_MODE_HEADER] = attrs.mode.toString(8);
|
|
862
|
+
if (attrs.uid !== void 0) headers[ARCHIL_UID_HEADER] = String(attrs.uid);
|
|
863
|
+
if (attrs.gid !== void 0) headers[ARCHIL_GID_HEADER] = String(attrs.gid);
|
|
864
|
+
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
865
|
+
}
|
|
827
866
|
/** S3's per-request cap on DeleteObjects keys; larger inputs are batched. */
|
|
828
867
|
const MAX_DELETE_OBJECTS_PER_REQUEST = 1e3;
|
|
829
868
|
/** Automatic retries for a transient S3 failure (5xx / 429 / network error). */
|
|
@@ -1203,10 +1242,10 @@ var Workspace = class {
|
|
|
1203
1242
|
const { entry, diskKey } = this.route(key);
|
|
1204
1243
|
return entry.disk.getObject(diskKey);
|
|
1205
1244
|
}
|
|
1206
|
-
async putObject(key, body,
|
|
1245
|
+
async putObject(key, body, options) {
|
|
1207
1246
|
const { entry, diskKey } = this.route(key);
|
|
1208
1247
|
if (entry.readOnly) throw new Error(`${key} is on a read-only disk and cannot be written.`);
|
|
1209
|
-
return entry.disk.putObject(diskKey, body,
|
|
1248
|
+
return entry.disk.putObject(diskKey, body, options);
|
|
1210
1249
|
}
|
|
1211
1250
|
async deleteObject(key) {
|
|
1212
1251
|
const { entry, diskKey } = this.route(key);
|