@agentunion/fastaun 0.4.12 → 0.5.0
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/CHANGELOG.md +488 -366
- package/_packed_docs/CHANGELOG.md +488 -366
- package/_packed_docs/INDEX.md +111 -53
- package/_packed_docs/KITE_DOCS_GUIDE.md +43 -29
- package/_packed_docs/agent.md/SCHEMA.md +2 -0
- package/_packed_docs/agent.md/examples/codeagent-claudecode.md +2 -0
- package/_packed_docs/agent.md/examples/human-developer.md +2 -0
- package/_packed_docs/agent.md/examples/openclaw-lobster.md +2 -0
- package/_packed_docs/agent.md/examples/signed-openclaw-lobster.md +2 -0
- package/_packed_docs/agent.md//350/277/234/347/250/213agent.md/347/274/223/345/255/230/344/270/216etag/351/200/217/344/274/240/346/226/271/346/241/210.md +2 -0
- package/_packed_docs/cli/AUN-CLI/350/256/276/350/256/241/346/226/207/346/241/243.md +265 -686
- package/_packed_docs/collab-gateway-boundary-test-report.md +164 -0
- package/_packed_docs/design/2026-05-22-aun-rpc-trace-enhancement.md +2 -0
- package/_packed_docs/design/AUNClient/346/213/206/345/210/206/351/207/215/346/236/204/346/211/247/350/241/214/346/226/271/346/241/210.md +2 -0
- package/_packed_docs/design/E2EE_V2/347/256/200/345/214/226/344/270/2721DH/345/212/240Per-AID_Wrap/346/226/271/346/241/210.md +2 -0
- package/_packed_docs/design//350/267/250/350/257/255/350/250/200/345/256/271/345/231/250E2E/346/265/213/350/257/225/346/226/271/346/241/210.md +2 -0
- package/_packed_docs/protocol/00-/346/200/273/350/247/210/344/270/216/345/210/206/345/261/202.md +2 -0
- package/_packed_docs/protocol/00A-/350/256/276/350/256/241/345/216/237/345/210/231-/344/270/272Agent/350/200/214/347/224/237.md +2 -0
- package/_packed_docs/protocol/01-/350/272/253/344/273/275/344/270/216/345/207/255/350/257/201/345/215/217/350/256/256-auth.md +2 -0
- package/_packed_docs/protocol/02-/350/257/201/344/271/246/344/270/216/344/277/241/344/273/273/344/275/223/347/263/273.md +2 -0
- package/_packed_docs/protocol/03-Gateway-/350/277/236/346/216/245/346/250/241/345/274/217.md +2 -0
- package/_packed_docs/protocol/04-Peer-/345/255/220/345/215/217/350/256/256.md +2 -0
- package/_packed_docs/protocol/05-Relay-/345/255/220/345/215/217/350/256/256.md +2 -0
- package/_packed_docs/protocol/07-/351/224/231/350/257/257/347/240/201/344/270/216/347/212/266/346/200/201/346/234/272.md +2 -0
- package/_packed_docs/protocol/08-AUN-E2EE-Group.md +2 -0
- package/_packed_docs/protocol/08-AUN-E2EE.md +2 -0
- package/_packed_docs/protocol/09-/345/256/211/345/205/250/350/200/203/350/231/221.md +2 -0
- package/_packed_docs/protocol/10-Group-/345/255/220/345/215/217/350/256/256.md +28 -85
- package/_packed_docs/protocol/11-Storage-/345/255/220/345/215/217/350/256/256.md +49 -0
- package/_packed_docs/protocol/12-Stream-/345/255/220/345/215/217/350/256/256.md +2 -0
- package/_packed_docs/protocol/13-Agent/350/241/214/344/270/272/350/247/204/350/214/203.md +2 -0
- package/_packed_docs/protocol/14-/344/272/244/344/272/222/346/234/272/345/210/266-/345/223/215/345/272/224/346/250/241/345/274/217/344/270/216/350/207/252/344/270/273/346/250/241/345/274/217.md +2 -0
- package/_packed_docs/protocol/15-/347/246/273/347/272/277/346/216/250/351/200/201/351/200/232/347/237/245/345/215/217/350/256/256.md +2 -0
- package/_packed_docs/protocol/README.md +2 -0
- package/_packed_docs/protocol/agent.md/SCHEMA.md +2 -0
- package/_packed_docs/protocol/agent.md/examples/codeagent-claudecode.md +2 -0
- package/_packed_docs/protocol/agent.md/examples/human-developer.md +2 -0
- package/_packed_docs/protocol/agent.md/examples/openclaw-lobster.md +2 -0
- package/_packed_docs/protocol/aun-docs-guide.md +2 -0
- package/_packed_docs/protocol/index.md +3 -1
- package/_packed_docs/protocol//350/215/211/346/241/210-agent.md/347/255/276/345/220/215/345/215/217/350/256/256.md +2 -0
- package/_packed_docs/protocol//350/215/211/346/241/210-/346/213/222/347/273/235/344/277/241/345/217/267/345/215/217/350/256/256.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225A-/346/234/257/350/257/255/350/241/250.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225B-/346/211/251/345/261/225/346/200/247/346/214/207/345/215/227.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225C-/347/247/201/351/222/245/347/256/241/347/220/206/344/270/216/350/272/253/344/273/275/346/201/242/345/244/215.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225D-Root_CA_/346/262/273/347/220/206/346/234/272/345/210/266.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225E-Root_CA_/345/207/206/345/205/245/346/265/201/347/250/213.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225F-Issuer_CA_/347/224/263/350/257/267/346/265/201/347/250/213.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225G-AID_/345/255/244/345/204/277/351/242/204/351/230/262/344/270/216/346/225/221/346/217/264/346/234/272/345/210/266.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225H-Identity/346/234/215/345/212/241/345/256/236/347/216/260/346/214/207/345/215/227.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225I-/350/267/250/345/237/237/346/266/210/346/201/257/350/267/257/347/224/261/345/256/236/347/216/260/346/214/207/345/215/227.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225J-/345/256/242/346/210/267/347/253/257/346/216/245/345/205/245/347/244/272/344/276/213.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225K-Agent_Web/345/217/221/347/216/260/345/215/217/350/256/256.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225L-E2EE/345/256/236/347/216/260/346/214/207/345/215/227.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225M-JWT/350/256/244/350/257/201/345/256/236/347/216/260/346/214/207/345/215/227.md +2 -0
- package/_packed_docs/protocol//351/231/204/345/275/225N-/345/210/206/345/270/203/345/274/217Trace/345/215/217/350/256/256.md +2 -0
- package/_packed_docs/sdk/01-/345/277/253/351/200/237/345/274/200/345/247/213.md +2 -0
- package/_packed_docs/sdk/02-WebSocket/345/215/217/350/256/256.md +2 -0
- package/_packed_docs/sdk/03-/346/240/270/345/277/203/346/246/202/345/277/265.md +2 -0
- package/_packed_docs/sdk/04-/350/277/236/346/216/245/344/270/216/350/256/244/350/257/201.md +2 -0
- package/_packed_docs/sdk/05-E2EE/345/212/240/345/257/206/351/200/232/344/277/241.md +2 -0
- package/_packed_docs/sdk/06-API/346/211/213/345/206/214.md +283 -267
- package/_packed_docs/sdk/07-/351/224/231/350/257/257/345/244/204/347/220/206.md +4 -1
- package/_packed_docs/sdk/08-/346/234/200/344/275/263/345/256/236/350/267/265.md +2 -0
- package/_packed_docs/sdk/09-collab-rpc-manual.md +550 -0
- package/_packed_docs/sdk/09-custody-api-manual.md +2 -0
- package/_packed_docs/sdk/09-group-rpc-manual.md +197 -445
- package/_packed_docs/sdk/09-message-rpc-manual.md +8 -7
- package/_packed_docs/sdk/09-meta-rpc-manual.md +2 -0
- package/_packed_docs/sdk/09-payload-reference.md +2 -0
- package/_packed_docs/sdk/09-proxy-rpc-manual.md +2 -0
- package/_packed_docs/sdk/09-storage-rpc-manual.md +952 -279
- package/_packed_docs/sdk/09-stream-rpc-manual.md +2 -0
- package/_packed_docs/sdk/AUN_DOCS_GUIDE.md +33 -20
- package/_packed_docs/sdk/E2EE_V2/346/266/210/346/201/257/351/200/232/344/277/241/346/227/266/345/272/217/345/233/276.md +2 -0
- package/_packed_docs/sdk/INDEX.md +46 -29
- package/_packed_docs/sdk/Notify/351/200/232/347/237/245/346/226/271/346/241/210.md +2 -0
- package/_packed_docs/sdk/README.md +17 -15
- package/dist/aid-store.d.ts +25 -0
- package/dist/aid-store.js +80 -0
- package/dist/aid-store.js.map +1 -1
- package/dist/auth.d.ts +2 -0
- package/dist/auth.js +99 -8
- package/dist/auth.js.map +1 -1
- package/dist/client/delivery.d.ts +5 -0
- package/dist/client/delivery.js +169 -8
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/rpc-pipeline.js +58 -26
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/v2-e2ee.js +67 -8
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.d.ts +29 -0
- package/dist/client.js +301 -20
- package/dist/client.js.map +1 -1
- package/dist/collab/client.d.ts +38 -0
- package/dist/collab/client.js +124 -0
- package/dist/collab/client.js.map +1 -0
- package/dist/collab/errors.d.ts +15 -0
- package/dist/collab/errors.js +60 -0
- package/dist/collab/errors.js.map +1 -0
- package/dist/collab/index.d.ts +3 -0
- package/dist/collab/index.js +4 -0
- package/dist/collab/index.js.map +1 -0
- package/dist/collab/types.d.ts +110 -0
- package/dist/collab/types.js +2 -0
- package/dist/collab/types.js.map +1 -0
- package/dist/crypto.d.ts +2 -0
- package/dist/crypto.js +6 -0
- package/dist/crypto.js.map +1 -1
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +30 -1
- package/dist/errors.js.map +1 -1
- package/dist/facades.d.ts +89 -0
- package/dist/facades.js +133 -0
- package/dist/facades.js.map +1 -0
- package/dist/group-fs.d.ts +105 -0
- package/dist/group-fs.js +467 -0
- package/dist/group-fs.js.map +1 -0
- package/dist/group-resources.d.ts +31 -0
- package/dist/group-resources.js +84 -0
- package/dist/group-resources.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/register-flow.d.ts +1 -0
- package/dist/register-flow.js +3 -0
- package/dist/register-flow.js.map +1 -1
- package/dist/service-proxy.d.ts +1 -0
- package/dist/service-proxy.js +17 -4
- package/dist/service-proxy.js.map +1 -1
- package/dist/storage/errors.d.ts +27 -0
- package/dist/storage/errors.js +65 -0
- package/dist/storage/errors.js.map +1 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/lowlevel.d.ts +313 -0
- package/dist/storage/lowlevel.js +464 -0
- package/dist/storage/lowlevel.js.map +1 -0
- package/dist/storage/types.d.ts +58 -0
- package/dist/storage/types.js +116 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/storage/vfs.d.ts +147 -0
- package/dist/storage/vfs.js +489 -0
- package/dist/storage/vfs.js.map +1 -0
- package/dist/tools/cross-sdk-agent.js +421 -1
- package/dist/tools/cross-sdk-agent.js.map +1 -1
- package/dist/transport.d.ts +3 -0
- package/dist/transport.js +76 -22
- package/dist/transport.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/storage/types.ts"],"names":[],"mappings":"AAEA,SAAS,IAAI,CAAC,KAAc,EAAE,QAAQ,GAAG,EAAE;IACzC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC3D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc,EAAE,QAAQ,GAAG,CAAC;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjE,CAAC;AAED,SAAS,SAAS,CAAC,KAAc,EAAE,QAAQ,GAAG,KAAK;IACjD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC3D,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAe;IACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC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C5E,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,IAAI,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC;IACzE,OAAO;QACL,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC;QACnC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;QAC7D,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,SAAS,CAAC;QACxF,IAAI;QACJ,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { StorageLowLevel, type StorageRpcClient } from './lowlevel.js';
|
|
2
|
+
import { type DownloadResult, type NodeView, type RemoveResult, type StorageRaw, type UnmountResult, type UsageView } from './types.js';
|
|
3
|
+
export { StorageLowLevel } from './lowlevel.js';
|
|
4
|
+
export * from './errors.js';
|
|
5
|
+
export * from './types.js';
|
|
6
|
+
export interface StorageOptions {
|
|
7
|
+
owner?: string | null;
|
|
8
|
+
bucket?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface WriteBytesOptions extends StorageOptions {
|
|
11
|
+
contentType?: string;
|
|
12
|
+
overwrite?: boolean;
|
|
13
|
+
expectedVersion?: number;
|
|
14
|
+
public?: boolean;
|
|
15
|
+
metadata?: StorageRaw;
|
|
16
|
+
}
|
|
17
|
+
export interface ReadOptions extends StorageOptions {
|
|
18
|
+
token?: string;
|
|
19
|
+
offset?: number;
|
|
20
|
+
limit?: number;
|
|
21
|
+
overwrite?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ListOptions extends StorageOptions {
|
|
24
|
+
page?: number;
|
|
25
|
+
size?: number;
|
|
26
|
+
marker?: string;
|
|
27
|
+
long?: boolean;
|
|
28
|
+
recursive?: boolean;
|
|
29
|
+
token?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface StatOptions extends StorageOptions {
|
|
32
|
+
token?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface StoragePathRef {
|
|
35
|
+
owner?: string | null;
|
|
36
|
+
path: string;
|
|
37
|
+
}
|
|
38
|
+
export type StoragePathLike = string | StoragePathRef;
|
|
39
|
+
export interface MountOptions extends StorageOptions {
|
|
40
|
+
sourceOwner?: string | null;
|
|
41
|
+
sourceBucket?: string;
|
|
42
|
+
readonly?: boolean;
|
|
43
|
+
expires?: number;
|
|
44
|
+
expiresAt?: number;
|
|
45
|
+
requireApproval?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare class StorageVFS {
|
|
48
|
+
readonly lowlevel: StorageLowLevel;
|
|
49
|
+
useFsRpc: boolean;
|
|
50
|
+
private readonly client;
|
|
51
|
+
constructor(client: StorageRpcClient, options?: {
|
|
52
|
+
lowlevel?: StorageLowLevel;
|
|
53
|
+
useFsRpc?: boolean;
|
|
54
|
+
});
|
|
55
|
+
get defaultOwner(): string | null;
|
|
56
|
+
private owner;
|
|
57
|
+
writeBytes(path: string, input: Uint8Array | ArrayBuffer | string, options?: WriteBytesOptions): Promise<NodeView>;
|
|
58
|
+
uploadFile(localPath: string, remotePath: string, options?: WriteBytesOptions): Promise<NodeView>;
|
|
59
|
+
readBytes(path: string, options?: ReadOptions): Promise<Uint8Array>;
|
|
60
|
+
private readBytesWithMetadata;
|
|
61
|
+
downloadFile(path: string, options?: ReadOptions & {
|
|
62
|
+
verifyHash?: boolean;
|
|
63
|
+
}): Promise<DownloadResult>;
|
|
64
|
+
downloadFile(path: string, localPath: string, options?: ReadOptions & {
|
|
65
|
+
verifyHash?: boolean;
|
|
66
|
+
}): Promise<DownloadResult>;
|
|
67
|
+
list(path: string, options?: ListOptions): Promise<NodeView[]>;
|
|
68
|
+
stat(path: string, options?: StatOptions): Promise<NodeView>;
|
|
69
|
+
lstat(path: string, options?: StatOptions): Promise<NodeView>;
|
|
70
|
+
mkdir(path: string, options?: StorageOptions & {
|
|
71
|
+
parents?: boolean;
|
|
72
|
+
}): Promise<NodeView>;
|
|
73
|
+
remove(path: string, options?: StorageOptions & {
|
|
74
|
+
recursive?: boolean;
|
|
75
|
+
}): Promise<RemoveResult>;
|
|
76
|
+
rename(src: string, dst: string, options?: StorageOptions & {
|
|
77
|
+
overwrite?: boolean;
|
|
78
|
+
expectedVersion?: number;
|
|
79
|
+
}): Promise<NodeView>;
|
|
80
|
+
copy(src: string, dst: string, options?: StorageOptions & {
|
|
81
|
+
overwrite?: boolean;
|
|
82
|
+
followSymlinks?: boolean;
|
|
83
|
+
recursive?: boolean;
|
|
84
|
+
dstOwner?: string | null;
|
|
85
|
+
dstBucket?: string;
|
|
86
|
+
}): Promise<NodeView>;
|
|
87
|
+
find(path: string, options?: StorageOptions & {
|
|
88
|
+
name?: string;
|
|
89
|
+
nodeType?: string;
|
|
90
|
+
size?: string;
|
|
91
|
+
mtime?: string;
|
|
92
|
+
page?: number;
|
|
93
|
+
pageSize?: number;
|
|
94
|
+
token?: string;
|
|
95
|
+
}): Promise<NodeView[]>;
|
|
96
|
+
df(options?: StorageOptions): Promise<UsageView>;
|
|
97
|
+
mount(source: StoragePathLike, mountPath: StoragePathLike, options?: MountOptions): Promise<NodeView>;
|
|
98
|
+
mountVolume(volumeId: string, mountPath: StoragePathLike, options?: MountOptions): Promise<NodeView>;
|
|
99
|
+
approveMount(mountPath: StoragePathLike, options?: StorageOptions & {
|
|
100
|
+
mountId?: string;
|
|
101
|
+
requestId?: string;
|
|
102
|
+
}): Promise<StorageRaw>;
|
|
103
|
+
rejectMount(mountPath: StoragePathLike, options?: StorageOptions & {
|
|
104
|
+
mountId?: string;
|
|
105
|
+
requestId?: string;
|
|
106
|
+
}): Promise<StorageRaw>;
|
|
107
|
+
unmount(mountPath: StoragePathLike, options?: StorageOptions): Promise<UnmountResult>;
|
|
108
|
+
symlink(target: string, linkPath: string, options?: StorageOptions & {
|
|
109
|
+
overwrite?: boolean;
|
|
110
|
+
}): Promise<NodeView>;
|
|
111
|
+
readlink(path: string, options?: StorageOptions): Promise<NodeView>;
|
|
112
|
+
repoint(path: string, newTarget: string, options?: StorageOptions & {
|
|
113
|
+
expectedVersion?: number;
|
|
114
|
+
}): Promise<NodeView>;
|
|
115
|
+
renameSymlink(src: string, dst: string, options?: StorageOptions & {
|
|
116
|
+
overwrite?: boolean;
|
|
117
|
+
expectedVersion?: number;
|
|
118
|
+
}): Promise<NodeView>;
|
|
119
|
+
setAcl(path: string, options: StorageOptions & {
|
|
120
|
+
granteeAid: string;
|
|
121
|
+
perms: string;
|
|
122
|
+
expiresAt?: number;
|
|
123
|
+
maxUses?: number;
|
|
124
|
+
}): Promise<StorageRaw>;
|
|
125
|
+
removeAcl(path: string, options: StorageOptions & {
|
|
126
|
+
granteeAid: string;
|
|
127
|
+
}): Promise<StorageRaw>;
|
|
128
|
+
listAcl(path: string, options?: StorageOptions): Promise<StorageRaw>;
|
|
129
|
+
setVisibility(path: string, options: StorageOptions & {
|
|
130
|
+
visibility: string;
|
|
131
|
+
allowRoles?: string[];
|
|
132
|
+
}): Promise<NodeView>;
|
|
133
|
+
checkAccess(path: string, options?: StorageOptions & {
|
|
134
|
+
operation?: string;
|
|
135
|
+
token?: string;
|
|
136
|
+
followSymlinks?: boolean;
|
|
137
|
+
}): Promise<StorageRaw>;
|
|
138
|
+
issueToken(path: string, options?: StorageOptions & {
|
|
139
|
+
expiresAt?: number;
|
|
140
|
+
maxReads?: number;
|
|
141
|
+
}): Promise<StorageRaw>;
|
|
142
|
+
revokeToken(path: string, options: StorageOptions & {
|
|
143
|
+
token: string;
|
|
144
|
+
}): Promise<StorageRaw>;
|
|
145
|
+
listTokens(path: string, options?: StorageOptions): Promise<StorageRaw>;
|
|
146
|
+
getUsage(options?: StorageOptions): Promise<UsageView>;
|
|
147
|
+
}
|
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { mapStorageError, StorageConflictError, StorageError, StorageExistsError } from './errors.js';
|
|
2
|
+
import { base64ToBytes, StorageLowLevel } from './lowlevel.js';
|
|
3
|
+
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { basename, dirname, extname, join } from 'node:path';
|
|
5
|
+
import { nodeFromAny, pathToKey, unmountFromAny, usageFromAny, } from './types.js';
|
|
6
|
+
export { StorageLowLevel } from './lowlevel.js';
|
|
7
|
+
export * from './errors.js';
|
|
8
|
+
export * from './types.js';
|
|
9
|
+
async function sha256Hex(data) {
|
|
10
|
+
const copy = new Uint8Array(data.byteLength);
|
|
11
|
+
copy.set(data);
|
|
12
|
+
const subtle = globalThis.crypto?.subtle;
|
|
13
|
+
if (!subtle?.digest)
|
|
14
|
+
throw new StorageError('SHA-256 unavailable', 'EUNSUPPORTED');
|
|
15
|
+
const digest = await subtle.digest('SHA-256', copy.buffer);
|
|
16
|
+
return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
17
|
+
}
|
|
18
|
+
function toBytes(data) {
|
|
19
|
+
if (typeof data === 'string')
|
|
20
|
+
return new TextEncoder().encode(data);
|
|
21
|
+
if (data instanceof Uint8Array)
|
|
22
|
+
return data;
|
|
23
|
+
return new Uint8Array(data);
|
|
24
|
+
}
|
|
25
|
+
function contentTypeForPath(path) {
|
|
26
|
+
const ext = extname(path).toLowerCase();
|
|
27
|
+
const known = {
|
|
28
|
+
'.txt': 'text/plain',
|
|
29
|
+
'.json': 'application/json',
|
|
30
|
+
'.md': 'text/markdown',
|
|
31
|
+
'.html': 'text/html',
|
|
32
|
+
'.csv': 'text/csv',
|
|
33
|
+
'.png': 'image/png',
|
|
34
|
+
'.jpg': 'image/jpeg',
|
|
35
|
+
'.jpeg': 'image/jpeg',
|
|
36
|
+
'.gif': 'image/gif',
|
|
37
|
+
'.webp': 'image/webp',
|
|
38
|
+
'.pdf': 'application/pdf',
|
|
39
|
+
};
|
|
40
|
+
return known[ext] ?? 'application/octet-stream';
|
|
41
|
+
}
|
|
42
|
+
function textValue(value) {
|
|
43
|
+
if (value === undefined || value === null)
|
|
44
|
+
return '';
|
|
45
|
+
return String(value).trim();
|
|
46
|
+
}
|
|
47
|
+
function isInlineFallbackError(error) {
|
|
48
|
+
const code = String(error.code).toUpperCase();
|
|
49
|
+
if (['EINLINE', 'EINLINE_LIMIT', 'ERR_INLINE_LIMIT', 'INLINE_LIMIT', '-32033'].includes(code))
|
|
50
|
+
return true;
|
|
51
|
+
// 当前服务端把 inline 过大映射为通用 -32602;只保留协议术语 inline 兜底,不再依赖中文文案。
|
|
52
|
+
return error.code === -32602 && error.message.toLowerCase().includes('inline');
|
|
53
|
+
}
|
|
54
|
+
async function statOrNull(path) {
|
|
55
|
+
try {
|
|
56
|
+
return await stat(path);
|
|
57
|
+
}
|
|
58
|
+
catch (exc) {
|
|
59
|
+
if (exc?.code === 'ENOENT')
|
|
60
|
+
return null;
|
|
61
|
+
throw exc;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function parsePathLike(input, fallbackOwner) {
|
|
65
|
+
if (typeof input !== 'string') {
|
|
66
|
+
return { owner: input.owner ?? fallbackOwner ?? null, path: input.path };
|
|
67
|
+
}
|
|
68
|
+
const match = input.match(/^([^:]+):(\/.*)$/);
|
|
69
|
+
if (match) {
|
|
70
|
+
return { owner: match[1], path: match[2] };
|
|
71
|
+
}
|
|
72
|
+
return { owner: fallbackOwner ?? null, path: input };
|
|
73
|
+
}
|
|
74
|
+
export class StorageVFS {
|
|
75
|
+
lowlevel;
|
|
76
|
+
useFsRpc;
|
|
77
|
+
client;
|
|
78
|
+
constructor(client, options = {}) {
|
|
79
|
+
this.client = client;
|
|
80
|
+
this.lowlevel = options.lowlevel ?? new StorageLowLevel(client);
|
|
81
|
+
this.useFsRpc = options.useFsRpc ?? true;
|
|
82
|
+
}
|
|
83
|
+
get defaultOwner() {
|
|
84
|
+
return this.client.aid ?? null;
|
|
85
|
+
}
|
|
86
|
+
owner(owner) {
|
|
87
|
+
return owner || this.defaultOwner;
|
|
88
|
+
}
|
|
89
|
+
async writeBytes(path, input, options = {}) {
|
|
90
|
+
const data = toBytes(input);
|
|
91
|
+
const owner = this.owner(options.owner);
|
|
92
|
+
const bucket = options.bucket ?? 'default';
|
|
93
|
+
const objectKey = pathToKey(path);
|
|
94
|
+
const sha256 = await sha256Hex(data);
|
|
95
|
+
const overwrite = options.overwrite ?? false;
|
|
96
|
+
try {
|
|
97
|
+
const check = await this.lowlevel.checkUpload({ owner, bucket, objectKey, size: data.length, sha256 });
|
|
98
|
+
if (check.within_limit === false) {
|
|
99
|
+
throw new StorageError(`file size exceeds max_file_size_bytes: ${data.length}`, 'E2BIG', path, check);
|
|
100
|
+
}
|
|
101
|
+
if (check.target_exists && !overwrite && options.expectedVersion === undefined) {
|
|
102
|
+
throw new StorageExistsError(`remote path already exists: ${path}`, 'EEXIST', path, check.target);
|
|
103
|
+
}
|
|
104
|
+
if (check.dedup_hit || check.skip_upload) {
|
|
105
|
+
const completed = await this.lowlevel.completeUpload({
|
|
106
|
+
owner,
|
|
107
|
+
bucket,
|
|
108
|
+
objectKey,
|
|
109
|
+
size: data.length,
|
|
110
|
+
sha256,
|
|
111
|
+
contentType: options.contentType ?? 'application/octet-stream',
|
|
112
|
+
metadata: options.metadata,
|
|
113
|
+
isPublic: options.public ?? false,
|
|
114
|
+
expectedVersion: options.expectedVersion,
|
|
115
|
+
skipBlob: true,
|
|
116
|
+
overwrite,
|
|
117
|
+
});
|
|
118
|
+
return nodeFromAny(completed);
|
|
119
|
+
}
|
|
120
|
+
if (check.inline === true) {
|
|
121
|
+
return nodeFromAny(await this.lowlevel.putObject({
|
|
122
|
+
owner,
|
|
123
|
+
bucket,
|
|
124
|
+
objectKey,
|
|
125
|
+
content: data,
|
|
126
|
+
contentType: options.contentType ?? 'application/octet-stream',
|
|
127
|
+
metadata: options.metadata,
|
|
128
|
+
isPublic: options.public ?? false,
|
|
129
|
+
expectedVersion: options.expectedVersion,
|
|
130
|
+
overwrite,
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
const session = await this.lowlevel.createUploadSession({
|
|
134
|
+
owner,
|
|
135
|
+
bucket,
|
|
136
|
+
objectKey,
|
|
137
|
+
size: data.length,
|
|
138
|
+
contentType: options.contentType,
|
|
139
|
+
expectedVersion: options.expectedVersion,
|
|
140
|
+
overwrite,
|
|
141
|
+
});
|
|
142
|
+
const uploadUrl = String(session.upload_url ?? '');
|
|
143
|
+
if (!uploadUrl)
|
|
144
|
+
throw new StorageError(`create_upload_session did not return upload_url`, 'ESTORAGE', path);
|
|
145
|
+
await this.lowlevel.httpPut(uploadUrl, data, session.headers);
|
|
146
|
+
return nodeFromAny(await this.lowlevel.completeUpload({
|
|
147
|
+
owner,
|
|
148
|
+
bucket,
|
|
149
|
+
objectKey,
|
|
150
|
+
sessionId: String(session.session_id ?? ''),
|
|
151
|
+
size: data.length,
|
|
152
|
+
sha256,
|
|
153
|
+
contentType: options.contentType,
|
|
154
|
+
metadata: options.metadata,
|
|
155
|
+
isPublic: options.public ?? false,
|
|
156
|
+
expectedVersion: options.expectedVersion,
|
|
157
|
+
overwrite,
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
catch (exc) {
|
|
161
|
+
throw mapStorageError(exc, path);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async uploadFile(localPath, remotePath, options = {}) {
|
|
165
|
+
const data = await readFile(localPath);
|
|
166
|
+
return this.writeBytes(remotePath, data, {
|
|
167
|
+
...options,
|
|
168
|
+
contentType: options.contentType ?? contentTypeForPath(localPath),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
async readBytes(path, options = {}) {
|
|
172
|
+
return (await this.readBytesWithMetadata(path, options)).data;
|
|
173
|
+
}
|
|
174
|
+
async readBytesWithMetadata(path, options = {}) {
|
|
175
|
+
const owner = this.owner(options.owner);
|
|
176
|
+
const bucket = options.bucket ?? 'default';
|
|
177
|
+
const objectKey = pathToKey(path);
|
|
178
|
+
try {
|
|
179
|
+
const result = await this.lowlevel.getObject({ owner, bucket, objectKey, token: options.token, offset: options.offset, limit: options.limit });
|
|
180
|
+
return {
|
|
181
|
+
data: base64ToBytes(String(result.content ?? '')),
|
|
182
|
+
sha256: textValue(result.sha256),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
catch (exc) {
|
|
186
|
+
const mapped = mapStorageError(exc, path);
|
|
187
|
+
if (options.offset !== undefined || options.limit !== undefined)
|
|
188
|
+
throw mapped;
|
|
189
|
+
if (!isInlineFallbackError(mapped))
|
|
190
|
+
throw mapped;
|
|
191
|
+
}
|
|
192
|
+
const ticket = await this.lowlevel.createDownloadTicket({ owner, bucket, objectKey, token: options.token });
|
|
193
|
+
const downloadUrl = String(ticket.download_url ?? '');
|
|
194
|
+
if (!downloadUrl)
|
|
195
|
+
throw new StorageError(`create_download_ticket did not return download_url`, 'ESTORAGE', path);
|
|
196
|
+
return {
|
|
197
|
+
data: await this.lowlevel.httpGet(downloadUrl),
|
|
198
|
+
sha256: textValue(ticket.sha256),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
async downloadFile(path, localPathOrOptions = {}, maybeOptions = {}) {
|
|
202
|
+
if (typeof localPathOrOptions === 'string') {
|
|
203
|
+
const localPath = localPathOrOptions;
|
|
204
|
+
const options = maybeOptions;
|
|
205
|
+
const owner = this.owner(options.owner);
|
|
206
|
+
const bucket = options.bucket ?? 'default';
|
|
207
|
+
const objectKey = pathToKey(path);
|
|
208
|
+
const ticket = await this.lowlevel.createDownloadTicket({ owner, bucket, objectKey, token: options.token });
|
|
209
|
+
const downloadUrl = String(ticket.download_url ?? '');
|
|
210
|
+
if (!downloadUrl)
|
|
211
|
+
throw new StorageError(`create_download_ticket did not return download_url`, 'ESTORAGE', path);
|
|
212
|
+
let targetPath = localPath;
|
|
213
|
+
const localInfo = await statOrNull(targetPath);
|
|
214
|
+
if (localInfo?.isDirectory()) {
|
|
215
|
+
targetPath = join(targetPath, textValue(ticket.file_name) || basename(objectKey));
|
|
216
|
+
}
|
|
217
|
+
const targetInfo = await statOrNull(targetPath);
|
|
218
|
+
const overwrite = options.overwrite ?? false;
|
|
219
|
+
if (targetInfo) {
|
|
220
|
+
if (targetInfo.isDirectory())
|
|
221
|
+
throw new StorageError(`local path is a directory: ${targetPath}`, 'EISDIR', targetPath);
|
|
222
|
+
if (!overwrite)
|
|
223
|
+
throw new StorageExistsError(`local path already exists: ${targetPath}`, 'EEXIST', targetPath);
|
|
224
|
+
}
|
|
225
|
+
const data = await this.lowlevel.httpGet(downloadUrl);
|
|
226
|
+
const actualSha = await sha256Hex(data);
|
|
227
|
+
const expectedSha = textValue(ticket.sha256);
|
|
228
|
+
const expected = expectedSha.toLowerCase();
|
|
229
|
+
const verified = !expected || actualSha.toLowerCase() === expected;
|
|
230
|
+
if (!verified && (options.verifyHash ?? true)) {
|
|
231
|
+
throw new StorageError(`hash mismatch: expected=${expected} actual=${actualSha.toLowerCase()}`, 'EHASH', path);
|
|
232
|
+
}
|
|
233
|
+
await mkdir(dirname(targetPath), { recursive: true });
|
|
234
|
+
try {
|
|
235
|
+
await writeFile(targetPath, data, { flag: overwrite ? 'w' : 'wx' });
|
|
236
|
+
}
|
|
237
|
+
catch (exc) {
|
|
238
|
+
if (!overwrite && exc?.code === 'EEXIST') {
|
|
239
|
+
throw new StorageExistsError(`local path already exists: ${targetPath}`, 'EEXIST', targetPath);
|
|
240
|
+
}
|
|
241
|
+
throw exc;
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
path,
|
|
245
|
+
localPath: targetPath,
|
|
246
|
+
size: data.length,
|
|
247
|
+
sha256: expectedSha || actualSha,
|
|
248
|
+
verified,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const options = localPathOrOptions;
|
|
252
|
+
const { data, sha256: expectedSha } = await this.readBytesWithMetadata(path, options);
|
|
253
|
+
const actualSha = await sha256Hex(data);
|
|
254
|
+
const expected = expectedSha.toLowerCase();
|
|
255
|
+
const verified = Boolean(expected) && actualSha.toLowerCase() === expected;
|
|
256
|
+
if (!verified && expected && (options.verifyHash ?? true)) {
|
|
257
|
+
throw new StorageError(`hash mismatch: expected=${expected} actual=${actualSha.toLowerCase()}`, 'EHASH', path);
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
path,
|
|
261
|
+
size: data.length,
|
|
262
|
+
sha256: expectedSha || actualSha,
|
|
263
|
+
verified,
|
|
264
|
+
data,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
async list(path, options = {}) {
|
|
268
|
+
if (options.recursive) {
|
|
269
|
+
const result = [];
|
|
270
|
+
const pending = [path];
|
|
271
|
+
while (pending.length) {
|
|
272
|
+
const current = pending.shift();
|
|
273
|
+
const children = await this.list(current, { ...options, recursive: false });
|
|
274
|
+
result.push(...children);
|
|
275
|
+
pending.push(...children.filter((node) => node.type === 'dir').map((node) => node.path));
|
|
276
|
+
}
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
const owner = this.owner(options.owner);
|
|
280
|
+
const bucket = options.bucket ?? 'default';
|
|
281
|
+
const key = pathToKey(path);
|
|
282
|
+
const raw = await this.lowlevel.fsList({
|
|
283
|
+
owner,
|
|
284
|
+
bucket,
|
|
285
|
+
path: key,
|
|
286
|
+
page: options.page,
|
|
287
|
+
size: options.size,
|
|
288
|
+
marker: options.marker,
|
|
289
|
+
token: options.token,
|
|
290
|
+
});
|
|
291
|
+
const items = (raw.nodes ?? raw.items ?? []);
|
|
292
|
+
return items.map((item) => nodeFromAny(item));
|
|
293
|
+
}
|
|
294
|
+
async stat(path, options = {}) {
|
|
295
|
+
const owner = this.owner(options.owner);
|
|
296
|
+
const raw = await this.lowlevel.fsStat({ owner, bucket: options.bucket ?? 'default', path: pathToKey(path), token: options.token });
|
|
297
|
+
return nodeFromAny(raw);
|
|
298
|
+
}
|
|
299
|
+
async lstat(path, options = {}) {
|
|
300
|
+
const owner = this.owner(options.owner);
|
|
301
|
+
const raw = await this.lowlevel.fsLstat({ owner, bucket: options.bucket ?? 'default', path: pathToKey(path), token: options.token });
|
|
302
|
+
return nodeFromAny(raw);
|
|
303
|
+
}
|
|
304
|
+
async mkdir(path, options = {}) {
|
|
305
|
+
const raw = await this.lowlevel.fsMkdir({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', path: pathToKey(path), parents: options.parents });
|
|
306
|
+
return nodeFromAny(raw.node ?? raw);
|
|
307
|
+
}
|
|
308
|
+
async remove(path, options = {}) {
|
|
309
|
+
const raw = await this.lowlevel.fsRemove({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', path: pathToKey(path), recursive: options.recursive });
|
|
310
|
+
return { path, removedCount: Number(raw.removed_count ?? raw.deleted_count ?? 0) };
|
|
311
|
+
}
|
|
312
|
+
async rename(src, dst, options = {}) {
|
|
313
|
+
const raw = await this.lowlevel.fsRename({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', src: pathToKey(src), dst: pathToKey(dst), overwrite: options.overwrite, expectedVersion: options.expectedVersion });
|
|
314
|
+
return nodeFromAny(raw.node ?? raw);
|
|
315
|
+
}
|
|
316
|
+
async copy(src, dst, options = {}) {
|
|
317
|
+
const raw = await this.lowlevel.fsCopy({
|
|
318
|
+
owner: this.owner(options.owner),
|
|
319
|
+
bucket: options.bucket ?? 'default',
|
|
320
|
+
src: pathToKey(src),
|
|
321
|
+
dst: pathToKey(dst),
|
|
322
|
+
overwrite: options.overwrite,
|
|
323
|
+
followSymlinks: options.followSymlinks,
|
|
324
|
+
recursive: options.recursive,
|
|
325
|
+
dstOwner: options.dstOwner,
|
|
326
|
+
dstBucket: options.dstBucket,
|
|
327
|
+
});
|
|
328
|
+
return nodeFromAny(raw.node ?? raw);
|
|
329
|
+
}
|
|
330
|
+
async find(path, options = {}) {
|
|
331
|
+
const raw = await this.lowlevel.fsFind({
|
|
332
|
+
owner: this.owner(options.owner),
|
|
333
|
+
bucket: options.bucket ?? 'default',
|
|
334
|
+
path: pathToKey(path),
|
|
335
|
+
name: options.name,
|
|
336
|
+
nodeType: options.nodeType,
|
|
337
|
+
size: options.size,
|
|
338
|
+
mtime: options.mtime,
|
|
339
|
+
page: options.page,
|
|
340
|
+
pageSize: options.pageSize,
|
|
341
|
+
token: options.token,
|
|
342
|
+
});
|
|
343
|
+
const items = (raw.nodes ?? raw.items ?? []);
|
|
344
|
+
return items.map((item) => nodeFromAny(item));
|
|
345
|
+
}
|
|
346
|
+
async df(options = {}) {
|
|
347
|
+
const owner = this.owner(options.owner);
|
|
348
|
+
const raw = await this.lowlevel.fsDf({ owner, bucket: options.bucket ?? 'default' });
|
|
349
|
+
return usageFromAny(raw, owner ?? undefined);
|
|
350
|
+
}
|
|
351
|
+
async mount(source, mountPath, options = {}) {
|
|
352
|
+
const owner = this.owner(options.owner);
|
|
353
|
+
const mountRef = parsePathLike(mountPath, owner);
|
|
354
|
+
const sourceRef = parsePathLike(source, options.sourceOwner ?? this.defaultOwner);
|
|
355
|
+
const raw = await this.lowlevel.fsMount({
|
|
356
|
+
owner: mountRef.owner,
|
|
357
|
+
bucket: options.bucket ?? 'default',
|
|
358
|
+
mountPath: pathToKey(mountRef.path),
|
|
359
|
+
sourceAid: String(sourceRef.owner ?? ''),
|
|
360
|
+
sourceBucket: options.sourceBucket,
|
|
361
|
+
sourcePath: pathToKey(sourceRef.path),
|
|
362
|
+
readonly: options.readonly,
|
|
363
|
+
expiresAt: options.expiresAt ?? options.expires,
|
|
364
|
+
requireApproval: options.requireApproval,
|
|
365
|
+
});
|
|
366
|
+
return nodeFromAny(raw.node ?? raw.mount ?? raw);
|
|
367
|
+
}
|
|
368
|
+
async mountVolume(volumeId, mountPath, options = {}) {
|
|
369
|
+
const owner = this.owner(options.owner);
|
|
370
|
+
const mountRef = parsePathLike(mountPath, owner);
|
|
371
|
+
const raw = await this.lowlevel.fsMount({
|
|
372
|
+
owner: mountRef.owner,
|
|
373
|
+
bucket: options.bucket ?? 'default',
|
|
374
|
+
mountPath: pathToKey(mountRef.path),
|
|
375
|
+
readonly: options.readonly,
|
|
376
|
+
expiresAt: options.expiresAt ?? options.expires,
|
|
377
|
+
requireApproval: options.requireApproval,
|
|
378
|
+
volumeId,
|
|
379
|
+
});
|
|
380
|
+
return nodeFromAny(raw.node ?? raw.mount ?? raw);
|
|
381
|
+
}
|
|
382
|
+
approveMount(mountPath, options = {}) {
|
|
383
|
+
const owner = this.owner(options.owner);
|
|
384
|
+
const mountRef = parsePathLike(mountPath, owner);
|
|
385
|
+
return this.lowlevel.fsApprove({
|
|
386
|
+
owner: mountRef.owner,
|
|
387
|
+
bucket: options.bucket ?? 'default',
|
|
388
|
+
mountPath: pathToKey(mountRef.path),
|
|
389
|
+
mountId: options.mountId,
|
|
390
|
+
requestId: options.requestId,
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
rejectMount(mountPath, options = {}) {
|
|
394
|
+
const owner = this.owner(options.owner);
|
|
395
|
+
const mountRef = parsePathLike(mountPath, owner);
|
|
396
|
+
return this.lowlevel.fsReject({
|
|
397
|
+
owner: mountRef.owner,
|
|
398
|
+
bucket: options.bucket ?? 'default',
|
|
399
|
+
mountPath: pathToKey(mountRef.path),
|
|
400
|
+
mountId: options.mountId,
|
|
401
|
+
requestId: options.requestId,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
async unmount(mountPath, options = {}) {
|
|
405
|
+
const owner = this.owner(options.owner);
|
|
406
|
+
const mountRef = parsePathLike(mountPath, owner);
|
|
407
|
+
const raw = await this.lowlevel.fsUnmount({
|
|
408
|
+
owner: mountRef.owner,
|
|
409
|
+
bucket: options.bucket ?? 'default',
|
|
410
|
+
mountPath: pathToKey(mountRef.path),
|
|
411
|
+
});
|
|
412
|
+
return unmountFromAny(raw, {
|
|
413
|
+
owner: mountRef.owner,
|
|
414
|
+
bucket: options.bucket ?? 'default',
|
|
415
|
+
mountPath: pathToKey(mountRef.path),
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
async symlink(target, linkPath, options = {}) {
|
|
419
|
+
const raw = await this.lowlevel.createSymlink({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', path: pathToKey(linkPath), target, overwrite: options.overwrite });
|
|
420
|
+
return nodeFromAny(raw.symlink ?? raw);
|
|
421
|
+
}
|
|
422
|
+
async readlink(path, options = {}) {
|
|
423
|
+
const raw = await this.lowlevel.readlink({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', path: pathToKey(path) });
|
|
424
|
+
return nodeFromAny(raw.symlink ?? raw);
|
|
425
|
+
}
|
|
426
|
+
async repoint(path, newTarget, options = {}) {
|
|
427
|
+
const raw = await this.lowlevel.atomicRepoint({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', path: pathToKey(path), newTarget, expectedVersion: options.expectedVersion });
|
|
428
|
+
if (raw.ok === false)
|
|
429
|
+
throw new StorageConflictError('symlink version conflict', 'ECONFLICT', path, raw);
|
|
430
|
+
return nodeFromAny(raw.symlink ?? raw);
|
|
431
|
+
}
|
|
432
|
+
async renameSymlink(src, dst, options = {}) {
|
|
433
|
+
const raw = await this.lowlevel.renameSymlink({
|
|
434
|
+
owner: this.owner(options.owner),
|
|
435
|
+
bucket: options.bucket ?? 'default',
|
|
436
|
+
path: pathToKey(src),
|
|
437
|
+
newPath: pathToKey(dst),
|
|
438
|
+
overwrite: options.overwrite,
|
|
439
|
+
expectedVersion: options.expectedVersion,
|
|
440
|
+
});
|
|
441
|
+
if (raw.ok === false)
|
|
442
|
+
throw new StorageConflictError('symlink version conflict', 'ECONFLICT', src, raw);
|
|
443
|
+
return nodeFromAny(raw.symlink ?? raw);
|
|
444
|
+
}
|
|
445
|
+
setAcl(path, options) {
|
|
446
|
+
return this.lowlevel.setAcl({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', path: pathToKey(path), granteeAid: options.granteeAid, perms: options.perms, expiresAt: options.expiresAt, maxUses: options.maxUses });
|
|
447
|
+
}
|
|
448
|
+
removeAcl(path, options) {
|
|
449
|
+
return this.lowlevel.removeAcl({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', path: pathToKey(path), granteeAid: options.granteeAid });
|
|
450
|
+
}
|
|
451
|
+
listAcl(path, options = {}) {
|
|
452
|
+
return this.lowlevel.listAcl({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', path: pathToKey(path) });
|
|
453
|
+
}
|
|
454
|
+
async setVisibility(path, options) {
|
|
455
|
+
const raw = await this.lowlevel.setVisibility({
|
|
456
|
+
owner: this.owner(options.owner),
|
|
457
|
+
bucket: options.bucket ?? 'default',
|
|
458
|
+
path: pathToKey(path),
|
|
459
|
+
visibility: options.visibility,
|
|
460
|
+
allowRoles: options.allowRoles,
|
|
461
|
+
});
|
|
462
|
+
return nodeFromAny(raw.node ?? raw);
|
|
463
|
+
}
|
|
464
|
+
checkAccess(path, options = {}) {
|
|
465
|
+
return this.lowlevel.checkAccess({
|
|
466
|
+
owner: this.owner(options.owner),
|
|
467
|
+
bucket: options.bucket ?? 'default',
|
|
468
|
+
path: pathToKey(path),
|
|
469
|
+
operation: options.operation ?? 'read',
|
|
470
|
+
token: options.token,
|
|
471
|
+
followSymlinks: options.followSymlinks ?? true,
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
issueToken(path, options = {}) {
|
|
475
|
+
return this.lowlevel.issueToken({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', path: pathToKey(path), expiresAt: options.expiresAt, maxReads: options.maxReads });
|
|
476
|
+
}
|
|
477
|
+
revokeToken(path, options) {
|
|
478
|
+
return this.lowlevel.revokeToken({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', path: pathToKey(path), token: options.token });
|
|
479
|
+
}
|
|
480
|
+
listTokens(path, options = {}) {
|
|
481
|
+
return this.lowlevel.listTokens({ owner: this.owner(options.owner), bucket: options.bucket ?? 'default', path: pathToKey(path) });
|
|
482
|
+
}
|
|
483
|
+
async getUsage(options = {}) {
|
|
484
|
+
const owner = this.owner(options.owner);
|
|
485
|
+
const raw = await this.lowlevel.getQuota({ owner, bucket: options.bucket ?? 'default' });
|
|
486
|
+
return usageFromAny(raw, owner ?? '');
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
//# sourceMappingURL=vfs.js.map
|