@aigne/afs-s3 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 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
@@ -0,0 +1,282 @@
1
+ import { AFSAccessMode, AFSBaseProvider, AFSDeleteResult, AFSEntry, AFSExecResult, AFSListResult, AFSModuleLoadParams, AFSStatResult, AFSWriteEntryPayload, AFSWriteResult, RouteContext } from "@aigne/afs";
2
+ import { S3Client } from "@aws-sdk/client-s3";
3
+ import * as zod0 from "zod";
4
+ import { z } from "zod";
5
+
6
+ //#region src/types.d.ts
7
+ /**
8
+ * Configuration options for AFSS3
9
+ */
10
+ interface AFSS3Options {
11
+ /** Module name (used as mount path segment) */
12
+ name?: string;
13
+ /** Module description */
14
+ description?: string;
15
+ /** S3 bucket name */
16
+ bucket: string;
17
+ /** Key prefix (optional) */
18
+ prefix?: string;
19
+ /** AWS region (defaults to environment) */
20
+ region?: string;
21
+ /** Access mode */
22
+ accessMode?: "readonly" | "readwrite";
23
+ /** Custom endpoint for S3-compatible services (MinIO, R2, B2) */
24
+ endpoint?: string;
25
+ /** Force path-style URLs (needed for some S3-compatible services) */
26
+ forcePathStyle?: boolean;
27
+ /** AWS credentials profile name */
28
+ profile?: string;
29
+ /** Explicit credentials (for testing or non-AWS environments) */
30
+ credentials?: {
31
+ accessKeyId: string;
32
+ secretAccessKey: string;
33
+ sessionToken?: string;
34
+ };
35
+ /** Cache TTL in seconds (0 = no cache, Phase 4) */
36
+ cacheTtl?: number;
37
+ /**
38
+ * Pre-configured S3 client (for testing or advanced use cases)
39
+ * If provided, endpoint/region/credentials/profile options are ignored.
40
+ */
41
+ client?: S3Client;
42
+ }
43
+ /**
44
+ * Parsed S3 URI
45
+ */
46
+ interface ParsedS3Uri {
47
+ bucket: string;
48
+ prefix: string;
49
+ }
50
+ //#endregion
51
+ //#region src/s3-afs.d.ts
52
+ /**
53
+ * AFSS3 Provider using Base Provider pattern
54
+ *
55
+ * Provides access to AWS S3 and S3-compatible storage through AFS.
56
+ * Uses decorator routing (@List, @Read, @Write, @Delete, @Meta, @Actions).
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const s3 = new AFSS3({
61
+ * bucket: "my-bucket",
62
+ * prefix: "data",
63
+ * region: "us-east-1",
64
+ * });
65
+ *
66
+ * // Mount to AFS
67
+ * afs.mount(s3);
68
+ *
69
+ * // List objects
70
+ * const result = await afs.list("/modules/my-bucket/data");
71
+ *
72
+ * // Read object
73
+ * const content = await afs.read("/modules/my-bucket/data/file.json");
74
+ * ```
75
+ */
76
+ declare class AFSS3 extends AFSBaseProvider {
77
+ readonly name: string;
78
+ readonly description?: string;
79
+ readonly accessMode: AFSAccessMode;
80
+ private options;
81
+ private client;
82
+ private listCache?;
83
+ private statCache?;
84
+ constructor(options: AFSS3Options);
85
+ /**
86
+ * Schema for configuration validation
87
+ */
88
+ static schema(): zod0.ZodEffects<zod0.ZodObject<{
89
+ name: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
90
+ description: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
91
+ bucket: zod0.ZodString;
92
+ prefix: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
93
+ region: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
94
+ accessMode: zod0.ZodType<"readonly" | "readwrite" | undefined, zod0.ZodTypeDef, "readonly" | "readwrite" | undefined>;
95
+ endpoint: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
96
+ forcePathStyle: zod0.ZodType<boolean | undefined, zod0.ZodTypeDef, boolean | undefined>;
97
+ profile: zod0.ZodType<string | undefined, zod0.ZodTypeDef, string | undefined>;
98
+ credentials: zod0.ZodType<{
99
+ accessKeyId: string;
100
+ secretAccessKey: string;
101
+ sessionToken?: string | undefined;
102
+ } | undefined, zod0.ZodTypeDef, {
103
+ accessKeyId: string;
104
+ secretAccessKey: string;
105
+ sessionToken?: string | undefined;
106
+ } | undefined>;
107
+ cacheTtl: zod0.ZodType<number | undefined, zod0.ZodTypeDef, number | undefined>;
108
+ }, "strict", zod0.ZodTypeAny, {
109
+ bucket: string;
110
+ name?: string | undefined;
111
+ description?: string | undefined;
112
+ prefix?: string | undefined;
113
+ region?: string | undefined;
114
+ accessMode?: "readonly" | "readwrite" | undefined;
115
+ endpoint?: string | undefined;
116
+ forcePathStyle?: boolean | undefined;
117
+ profile?: string | undefined;
118
+ credentials?: {
119
+ accessKeyId: string;
120
+ secretAccessKey: string;
121
+ sessionToken?: string | undefined;
122
+ } | undefined;
123
+ cacheTtl?: number | undefined;
124
+ }, {
125
+ bucket: string;
126
+ name?: string | undefined;
127
+ description?: string | undefined;
128
+ prefix?: string | undefined;
129
+ region?: string | undefined;
130
+ accessMode?: "readonly" | "readwrite" | undefined;
131
+ endpoint?: string | undefined;
132
+ forcePathStyle?: boolean | undefined;
133
+ profile?: string | undefined;
134
+ credentials?: {
135
+ accessKeyId: string;
136
+ secretAccessKey: string;
137
+ sessionToken?: string | undefined;
138
+ } | undefined;
139
+ cacheTtl?: number | undefined;
140
+ }>, {
141
+ bucket: string;
142
+ name?: string | undefined;
143
+ description?: string | undefined;
144
+ prefix?: string | undefined;
145
+ region?: string | undefined;
146
+ accessMode?: "readonly" | "readwrite" | undefined;
147
+ endpoint?: string | undefined;
148
+ forcePathStyle?: boolean | undefined;
149
+ profile?: string | undefined;
150
+ credentials?: {
151
+ accessKeyId: string;
152
+ secretAccessKey: string;
153
+ sessionToken?: string | undefined;
154
+ } | undefined;
155
+ cacheTtl?: number | undefined;
156
+ }, any>;
157
+ /**
158
+ * Load from configuration file
159
+ */
160
+ static load(params: AFSModuleLoadParams): Promise<AFSS3>;
161
+ /**
162
+ * Build the full S3 key from a path
163
+ */
164
+ private buildS3Key;
165
+ /**
166
+ * Generate a unique ID for an S3 object
167
+ */
168
+ private generateId;
169
+ /**
170
+ * Invalidate caches for a given path
171
+ */
172
+ private invalidateCache;
173
+ /**
174
+ * Clear all caches
175
+ */
176
+ clearCache(): void;
177
+ listHandler(ctx: RouteContext<{
178
+ path?: string;
179
+ }>): Promise<AFSListResult>;
180
+ /**
181
+ * List with delimiter (single level)
182
+ */
183
+ private listWithDelimiter;
184
+ listVersionsHandler(ctx: RouteContext<{
185
+ path: string;
186
+ }>): Promise<AFSListResult>;
187
+ readHandler(ctx: RouteContext<{
188
+ path: string;
189
+ }>): Promise<AFSEntry>;
190
+ readVersionHandler(ctx: RouteContext<{
191
+ path: string;
192
+ versionId: string;
193
+ }>): Promise<AFSEntry>;
194
+ metaHandler(ctx: RouteContext<{
195
+ path?: string;
196
+ }>): Promise<AFSEntry>;
197
+ statHandler(ctx: RouteContext<{
198
+ path?: string;
199
+ }>): Promise<AFSStatResult>;
200
+ writeHandler(ctx: RouteContext<{
201
+ path: string;
202
+ }>, payload: AFSWriteEntryPayload): Promise<AFSWriteResult>;
203
+ deleteHandler(ctx: RouteContext<{
204
+ path: string;
205
+ }>): Promise<AFSDeleteResult>;
206
+ listActionsHandler(ctx: RouteContext<{
207
+ path: string;
208
+ }>): Promise<AFSListResult>;
209
+ selectActionHandler(ctx: RouteContext<{
210
+ path: string;
211
+ }>, args: Record<string, unknown>): Promise<AFSExecResult>;
212
+ presignDownloadActionHandler(ctx: RouteContext<{
213
+ path: string;
214
+ }>, args: Record<string, unknown>): Promise<AFSExecResult>;
215
+ presignUploadActionHandler(ctx: RouteContext<{
216
+ path: string;
217
+ }>, args: Record<string, unknown>): Promise<AFSExecResult>;
218
+ /**
219
+ * Generate a presigned URL for downloading an object
220
+ * @deprecated Use action /.actions/presign-download instead
221
+ */
222
+ getPresignedDownloadUrl(path: string, options?: {
223
+ expiresIn?: number;
224
+ }): Promise<string>;
225
+ /**
226
+ * Generate a presigned URL for uploading an object
227
+ * @deprecated Use action /.actions/presign-upload instead
228
+ */
229
+ getPresignedUploadUrl(path: string, options?: {
230
+ expiresIn?: number;
231
+ contentType?: string;
232
+ }): Promise<string>;
233
+ /**
234
+ * List all versions of an object
235
+ * @deprecated Use list on /:path/@versions instead
236
+ */
237
+ listVersions(path: string): Promise<Array<{
238
+ versionId: string;
239
+ isLatest: boolean;
240
+ lastModified?: Date;
241
+ size: number;
242
+ etag?: string;
243
+ }>>;
244
+ /**
245
+ * Read a specific version of an object
246
+ * @deprecated Use read on /:path/@versions/:versionId instead
247
+ */
248
+ readVersion(path: string, versionId: string): Promise<{
249
+ content: string;
250
+ metadata: Record<string, unknown>;
251
+ }>;
252
+ /**
253
+ * Run a SQL-like query on a CSV/JSON/Parquet file (S3 Select)
254
+ * @deprecated Use action /.actions/select instead
255
+ */
256
+ select(path: string, query: string, options?: {
257
+ inputFormat?: "CSV" | "JSON" | "Parquet";
258
+ csv?: {
259
+ fieldDelimiter?: string;
260
+ recordDelimiter?: string;
261
+ fileHeaderInfo?: "USE" | "IGNORE" | "NONE";
262
+ };
263
+ json?: {
264
+ type?: "DOCUMENT" | "LINES";
265
+ };
266
+ }): Promise<{
267
+ records: unknown[];
268
+ stats?: {
269
+ bytesScanned: number;
270
+ bytesProcessed: number;
271
+ bytesReturned: number;
272
+ };
273
+ }>;
274
+ /**
275
+ * Create a directory marker
276
+ * @deprecated Use write with empty content instead
277
+ */
278
+ mkdir(path: string): Promise<void>;
279
+ }
280
+ //#endregion
281
+ export { AFSS3, type AFSS3Options, type ParsedS3Uri };
282
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/s3-afs.ts"],"mappings":";;;;;;;AAWA;;UAAiB,YAAA;EA0CE;EAxCjB,IAAA;EAGA;EAAA,WAAA;EAMA;EAHA,MAAA;EASA;EANA,MAAA;EAYA;EATA,MAAA;EAeA;EAZA,UAAA;EAcE;EAXF,QAAA;EAgBA;EAbA,cAAA;EAmBS;EAhBT,OAAA;EAgBiB;EAbjB,WAAA;IACE,WAAA;IACA,eAAA;IACA,YAAA;EAAA;;EAIF,QAAA;;ACoCF;;;ED9BE,MAAA,GAAS,QAAA;AAAA;;;;UAyCM,WAAA;EACf,MAAA;EACA,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;AAFF;;;;cCXa,KAAA,SAAc,eAAA;EAAA,SACP,IAAA;EAAA,SACA,WAAA;EAAA,SACA,UAAA,EAAY,aAAA;EAAA,QAEtB,OAAA;EAAA,QACA,MAAA;EAAA,QACA,SAAA;EAAA,QACA,SAAA;cAEI,OAAA,EAAS,YAAA;EAAY;;;EAAA,OAiC1B,MAAA,CAAA,GAAM,IAAA,CAAA,UAAA,MAAA,SAAA;2CAjCoB,IAAA,CAAA,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0hCO;;;EAAA,OAl/B3B,IAAA,CAAK,MAAA,EAAQ,mBAAA,GAAsB,OAAA,CAAQ,KAAA;EAlD/B;;;EAAA,QA4DjB,UAAA;EA3DU;;;EAAA,QAmEV,UAAA;EA/DA;;;EAAA,QAsEA,eAAA;;;;EAiBR,UAAA,CAAA;EASM,WAAA,CAAY,GAAA,EAAK,YAAA;IAAe,IAAA;E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