@aigne/afs-gcs 1.11.0-beta.6
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/LICENSE.md +26 -0
- package/dist/index.d.mts +246 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1055 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +58 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Proprietary License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 ArcBlock, Inc. All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are proprietary
|
|
6
|
+
and confidential. Unauthorized copying, modification, distribution, or use of
|
|
7
|
+
this Software, via any medium, is strictly prohibited.
|
|
8
|
+
|
|
9
|
+
The Software is provided for internal use only within ArcBlock, Inc. and its
|
|
10
|
+
authorized affiliates.
|
|
11
|
+
|
|
12
|
+
## No License Granted
|
|
13
|
+
|
|
14
|
+
No license, express or implied, is granted to any party for any purpose.
|
|
15
|
+
All rights are reserved by ArcBlock, Inc.
|
|
16
|
+
|
|
17
|
+
## Public Artifact Distribution
|
|
18
|
+
|
|
19
|
+
Portions of this Software may be released publicly under separate open-source
|
|
20
|
+
licenses (such as MIT License) through designated public repositories. Such
|
|
21
|
+
public releases are governed by their respective licenses and do not affect
|
|
22
|
+
the proprietary nature of this repository.
|
|
23
|
+
|
|
24
|
+
## Contact
|
|
25
|
+
|
|
26
|
+
For licensing inquiries, contact: legal@arcblock.io
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { AFSAccessMode, AFSBaseProvider, AFSDeleteResult, AFSEntry, AFSExecResult, AFSListResult, AFSModuleLoadParams, AFSStatResult, AFSWriteEntryPayload, AFSWriteResult, RouteContext } from "@aigne/afs";
|
|
2
|
+
import * as zod0 from "zod";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Configuration options for AFSGCS
|
|
8
|
+
*/
|
|
9
|
+
interface AFSGCSOptions {
|
|
10
|
+
/** Module name (used as mount path segment) */
|
|
11
|
+
name?: string;
|
|
12
|
+
/** Module description */
|
|
13
|
+
description?: string;
|
|
14
|
+
/** GCS bucket name */
|
|
15
|
+
bucket: string;
|
|
16
|
+
/** Key prefix (optional) */
|
|
17
|
+
prefix?: string;
|
|
18
|
+
/** GCP project ID */
|
|
19
|
+
projectId?: string;
|
|
20
|
+
/** Access mode */
|
|
21
|
+
accessMode?: "readonly" | "readwrite";
|
|
22
|
+
/** Custom endpoint for GCS-compatible services (fake-gcs-server) */
|
|
23
|
+
endpoint?: string;
|
|
24
|
+
/** Path to service account key file */
|
|
25
|
+
keyFilename?: string;
|
|
26
|
+
/** Explicit credentials (for programmatic access) */
|
|
27
|
+
credentials?: {
|
|
28
|
+
clientEmail: string;
|
|
29
|
+
privateKey: string;
|
|
30
|
+
};
|
|
31
|
+
/** Cache TTL in seconds (0 = no cache) */
|
|
32
|
+
cacheTtl?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parsed GCS URI
|
|
36
|
+
*/
|
|
37
|
+
interface ParsedGCSUri {
|
|
38
|
+
bucket: string;
|
|
39
|
+
prefix: string;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/gcs-afs.d.ts
|
|
43
|
+
/**
|
|
44
|
+
* AFSGCS Provider using Base Provider pattern
|
|
45
|
+
*
|
|
46
|
+
* Provides access to Google Cloud Storage through AFS.
|
|
47
|
+
* Uses decorator routing (@List, @Read, @Write, @Delete, @Meta, @Actions).
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const gcs = new AFSGCS({
|
|
52
|
+
* bucket: "my-bucket",
|
|
53
|
+
* prefix: "data",
|
|
54
|
+
* projectId: "my-project",
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* // Mount to AFS
|
|
58
|
+
* afs.mount(gcs);
|
|
59
|
+
*
|
|
60
|
+
* // List objects
|
|
61
|
+
* const result = await afs.list("/modules/my-bucket/data");
|
|
62
|
+
*
|
|
63
|
+
* // Read object
|
|
64
|
+
* const content = await afs.read("/modules/my-bucket/data/file.json");
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
declare class AFSGCS extends AFSBaseProvider {
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly description?: string;
|
|
70
|
+
readonly accessMode: AFSAccessMode;
|
|
71
|
+
private options;
|
|
72
|
+
private storage;
|
|
73
|
+
private bucket;
|
|
74
|
+
private listCache?;
|
|
75
|
+
private statCache?;
|
|
76
|
+
constructor(options: AFSGCSOptions);
|
|
77
|
+
/**
|
|
78
|
+
* Schema for configuration validation
|
|
79
|
+
*/
|
|
80
|
+
static schema(): zod0.ZodEffects<zod0.ZodObject<{
|
|
81
|
+
name: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
|
|
82
|
+
description: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
|
|
83
|
+
bucket: zod0.ZodEffects<zod0.ZodString, string, string>;
|
|
84
|
+
prefix: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
|
|
85
|
+
projectId: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
|
|
86
|
+
accessMode: zod0.ZodType<"readonly" | "readwrite" | undefined, zod0.ZodTypeDef, "readonly" | "readwrite" | undefined>;
|
|
87
|
+
endpoint: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
|
|
88
|
+
keyFilename: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
|
|
89
|
+
credentials: zod0.ZodType<{
|
|
90
|
+
clientEmail: string;
|
|
91
|
+
privateKey: string;
|
|
92
|
+
} | undefined, zod0.ZodTypeDef, {
|
|
93
|
+
clientEmail: string;
|
|
94
|
+
privateKey: string;
|
|
95
|
+
} | undefined>;
|
|
96
|
+
cacheTtl: zod0.ZodType<number | undefined, zod0.ZodTypeDef, number | undefined>;
|
|
97
|
+
}, "strict", zod0.ZodTypeAny, {
|
|
98
|
+
bucket: string;
|
|
99
|
+
name?: string | undefined;
|
|
100
|
+
description?: string | undefined;
|
|
101
|
+
prefix?: string | undefined;
|
|
102
|
+
projectId?: string | undefined;
|
|
103
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
104
|
+
endpoint?: string | undefined;
|
|
105
|
+
keyFilename?: string | undefined;
|
|
106
|
+
credentials?: {
|
|
107
|
+
clientEmail: string;
|
|
108
|
+
privateKey: string;
|
|
109
|
+
} | undefined;
|
|
110
|
+
cacheTtl?: number | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
bucket: string;
|
|
113
|
+
name?: string | undefined;
|
|
114
|
+
description?: string | undefined;
|
|
115
|
+
prefix?: string | undefined;
|
|
116
|
+
projectId?: string | undefined;
|
|
117
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
118
|
+
endpoint?: string | undefined;
|
|
119
|
+
keyFilename?: string | undefined;
|
|
120
|
+
credentials?: {
|
|
121
|
+
clientEmail: string;
|
|
122
|
+
privateKey: string;
|
|
123
|
+
} | undefined;
|
|
124
|
+
cacheTtl?: number | undefined;
|
|
125
|
+
}>, {
|
|
126
|
+
bucket: string;
|
|
127
|
+
name?: string | undefined;
|
|
128
|
+
description?: string | undefined;
|
|
129
|
+
prefix?: string | undefined;
|
|
130
|
+
projectId?: string | undefined;
|
|
131
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
132
|
+
endpoint?: string | undefined;
|
|
133
|
+
keyFilename?: string | undefined;
|
|
134
|
+
credentials?: {
|
|
135
|
+
clientEmail: string;
|
|
136
|
+
privateKey: string;
|
|
137
|
+
} | undefined;
|
|
138
|
+
cacheTtl?: number | undefined;
|
|
139
|
+
}, any>;
|
|
140
|
+
/**
|
|
141
|
+
* Load from configuration file
|
|
142
|
+
*/
|
|
143
|
+
static load(params: AFSModuleLoadParams): Promise<AFSGCS>;
|
|
144
|
+
/**
|
|
145
|
+
* Build the full GCS key from a path
|
|
146
|
+
*/
|
|
147
|
+
private buildGCSKey;
|
|
148
|
+
/**
|
|
149
|
+
* Generate a unique ID for a GCS object
|
|
150
|
+
*/
|
|
151
|
+
private generateId;
|
|
152
|
+
/**
|
|
153
|
+
* Invalidate caches for a given path
|
|
154
|
+
*/
|
|
155
|
+
private invalidateCache;
|
|
156
|
+
/**
|
|
157
|
+
* Clear all caches
|
|
158
|
+
*/
|
|
159
|
+
clearCache(): void;
|
|
160
|
+
listHandler(ctx: RouteContext<{
|
|
161
|
+
path?: string;
|
|
162
|
+
}>): Promise<AFSListResult>;
|
|
163
|
+
/**
|
|
164
|
+
* List with delimiter (single level)
|
|
165
|
+
*/
|
|
166
|
+
private listWithDelimiter;
|
|
167
|
+
listVersionsHandler(ctx: RouteContext<{
|
|
168
|
+
path: string;
|
|
169
|
+
}>): Promise<AFSListResult>;
|
|
170
|
+
readHandler(ctx: RouteContext<{
|
|
171
|
+
path: string;
|
|
172
|
+
}>): Promise<AFSEntry>;
|
|
173
|
+
readVersionHandler(ctx: RouteContext<{
|
|
174
|
+
path: string;
|
|
175
|
+
generation: string;
|
|
176
|
+
}>): Promise<AFSEntry>;
|
|
177
|
+
metaHandler(ctx: RouteContext<{
|
|
178
|
+
path?: string;
|
|
179
|
+
}>): Promise<AFSEntry>;
|
|
180
|
+
statHandler(ctx: RouteContext<{
|
|
181
|
+
path?: string;
|
|
182
|
+
}>): Promise<AFSStatResult>;
|
|
183
|
+
writeHandler(ctx: RouteContext<{
|
|
184
|
+
path: string;
|
|
185
|
+
}>, payload: AFSWriteEntryPayload): Promise<AFSWriteResult>;
|
|
186
|
+
deleteHandler(ctx: RouteContext<{
|
|
187
|
+
path: string;
|
|
188
|
+
}>): Promise<AFSDeleteResult>;
|
|
189
|
+
listActionsHandler(ctx: RouteContext<{
|
|
190
|
+
path: string;
|
|
191
|
+
}>): Promise<AFSListResult>;
|
|
192
|
+
signDownloadActionHandler(ctx: RouteContext<{
|
|
193
|
+
path: string;
|
|
194
|
+
}>, args: Record<string, unknown>): Promise<AFSExecResult>;
|
|
195
|
+
signUploadActionHandler(ctx: RouteContext<{
|
|
196
|
+
path: string;
|
|
197
|
+
}>, args: Record<string, unknown>): Promise<AFSExecResult>;
|
|
198
|
+
composeActionHandler(ctx: RouteContext<{
|
|
199
|
+
path: string;
|
|
200
|
+
}>, args: Record<string, unknown>): Promise<AFSExecResult>;
|
|
201
|
+
rewriteActionHandler(ctx: RouteContext<{
|
|
202
|
+
path: string;
|
|
203
|
+
}>, args: Record<string, unknown>): Promise<AFSExecResult>;
|
|
204
|
+
/**
|
|
205
|
+
* Generate a signed URL for downloading an object
|
|
206
|
+
* @deprecated Use action /.actions/sign-download instead
|
|
207
|
+
*/
|
|
208
|
+
getSignedDownloadUrl(path: string, options?: {
|
|
209
|
+
expiresIn?: number;
|
|
210
|
+
}): Promise<string>;
|
|
211
|
+
/**
|
|
212
|
+
* Generate a signed URL for uploading an object
|
|
213
|
+
* @deprecated Use action /.actions/sign-upload instead
|
|
214
|
+
*/
|
|
215
|
+
getSignedUploadUrl(path: string, options?: {
|
|
216
|
+
expiresIn?: number;
|
|
217
|
+
contentType?: string;
|
|
218
|
+
}): Promise<string>;
|
|
219
|
+
/**
|
|
220
|
+
* List all versions (generations) of an object
|
|
221
|
+
* @deprecated Use list on /:path/@versions instead
|
|
222
|
+
*/
|
|
223
|
+
listVersions(path: string): Promise<Array<{
|
|
224
|
+
generation: string;
|
|
225
|
+
isLive: boolean;
|
|
226
|
+
timeCreated?: Date;
|
|
227
|
+
size: number;
|
|
228
|
+
etag?: string;
|
|
229
|
+
}>>;
|
|
230
|
+
/**
|
|
231
|
+
* Read a specific version (generation) of an object
|
|
232
|
+
* @deprecated Use read on /:path/@versions/:generation instead
|
|
233
|
+
*/
|
|
234
|
+
readVersion(path: string, generation: string): Promise<{
|
|
235
|
+
content: string;
|
|
236
|
+
metadata: Record<string, unknown>;
|
|
237
|
+
}>;
|
|
238
|
+
/**
|
|
239
|
+
* Create a directory marker
|
|
240
|
+
* @deprecated Use write with empty content instead
|
|
241
|
+
*/
|
|
242
|
+
mkdir(path: string): Promise<void>;
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
export { AFSGCS, type AFSGCSOptions, type ParsedGCSUri };
|
|
246
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/gcs-afs.ts"],"mappings":";;;;;;AAUA;;UAAiB,aAAA;EAAa;EAE5B,IAAA;EAGA;EAAA,WAAA;EAMA;EAHA,MAAA;EASA;EANA,MAAA;EAYA;EATA,SAAA;EAaE;EAVF,UAAA;EAeA;EAZA,QAAA;EAYQ;EATR,WAAA;EAgE2B;EA7D3B,WAAA;IACE,WAAA;IACA,UAAA;EAAA;;EAIF,QAAA;AAAA;;;;UAuDe,YAAA;EACf,MAAA;EACA,MAAA;AAAA;;;;;;;;;;;;;;;;;;AAFF;;;;;;;;ACpBA;cAAa,MAAA,SAAe,eAAA;EAAA,SACR,IAAA;EAAA,SACA,WAAA;EAAA,SACA,UAAA,EAAY,aAAA;EAAA,QAEtB,OAAA;EAAA,QACA,OAAA;EAAA,QACA,MAAA;EAAA,QACA,SAAA;EAAA,QACA,SAAA;cAEI,OAAA,EAAS,aAAA;;;;SA+Bd,MAAA,CAAA,GAAM,IAAA,CAAA,UAAA,MAAA,SAAA;2CA/BqB,IAAA,CAAA,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAy7B/B;;;EAAA,OAn5BU,IAAA,CAAK,MAAA,EAAQ,mBAAA,GAAsB,OAAA,CAAQ,MAAA;EAo+BtD;;;EAAA,QA19BM,WAAA;EAugCmB;;;EAAA,QA//BnB,UAAA;EAnEk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