@aigne/afs-s3 1.11.0-beta.10

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,202 @@
1
+ import { AFSAccessMode, AFSBaseProvider, AFSDeleteResult, AFSEntry, AFSExecResult, AFSExplainResult, AFSListResult, AFSModuleLoadParams, AFSSearchResult, AFSStatResult, AFSWriteEntryPayload, AFSWriteResult, ProviderManifest, RouteContext } from "@aigne/afs";
2
+ import { S3Client } from "@aws-sdk/client-s3";
3
+ import { z } from "zod";
4
+
5
+ //#region src/types.d.ts
6
+ /**
7
+ * Configuration options for AFSS3
8
+ */
9
+ interface AFSS3Options {
10
+ /** Module name (used as mount path segment) */
11
+ name?: string;
12
+ /** Module description */
13
+ description?: string;
14
+ /** S3 bucket name */
15
+ bucket: string;
16
+ /** Key prefix (optional) */
17
+ prefix?: string;
18
+ /** AWS region (defaults to environment) */
19
+ region?: string;
20
+ /** Access mode */
21
+ accessMode?: "readonly" | "readwrite";
22
+ /** Custom endpoint for S3-compatible services (MinIO, R2, B2) */
23
+ endpoint?: string;
24
+ /** Force path-style URLs (needed for some S3-compatible services) */
25
+ forcePathStyle?: boolean;
26
+ /** AWS credentials profile name */
27
+ profile?: string;
28
+ /** Explicit credentials (for testing or non-AWS environments) */
29
+ credentials?: {
30
+ accessKeyId: string;
31
+ secretAccessKey: string;
32
+ sessionToken?: string;
33
+ };
34
+ /** Cache TTL in seconds (0 = no cache, Phase 4) */
35
+ cacheTtl?: number;
36
+ /**
37
+ * Pre-configured S3 client (for testing or advanced use cases)
38
+ * If provided, endpoint/region/credentials/profile options are ignored.
39
+ */
40
+ client?: S3Client;
41
+ }
42
+ /**
43
+ * Parsed S3 URI
44
+ */
45
+ interface ParsedS3Uri {
46
+ bucket: string;
47
+ prefix: string;
48
+ }
49
+ //#endregion
50
+ //#region src/s3-afs.d.ts
51
+ /**
52
+ * AFSS3 Provider using Base Provider pattern
53
+ *
54
+ * Provides access to AWS S3 and S3-compatible storage through AFS.
55
+ * Uses decorator routing (@List, @Read, @Write, @Delete, @Meta, @Actions).
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const s3 = new AFSS3({
60
+ * bucket: "my-bucket",
61
+ * prefix: "data",
62
+ * region: "us-east-1",
63
+ * });
64
+ *
65
+ * // Mount to AFS
66
+ * afs.mount(s3);
67
+ *
68
+ * // List objects
69
+ * const result = await afs.list("/modules/my-bucket/data");
70
+ *
71
+ * // Read object
72
+ * const content = await afs.read("/modules/my-bucket/data/file.json");
73
+ * ```
74
+ */
75
+ declare class AFSS3 extends AFSBaseProvider {
76
+ readonly name: string;
77
+ readonly description?: string;
78
+ readonly accessMode: AFSAccessMode;
79
+ private options;
80
+ private client;
81
+ private listCache?;
82
+ private statCache?;
83
+ constructor(options: AFSS3Options & {
84
+ uri?: string;
85
+ token?: string;
86
+ auth?: unknown;
87
+ });
88
+ /**
89
+ * Schema for configuration validation
90
+ */
91
+ static schema(): z.ZodType<{
92
+ name: string | undefined;
93
+ description: string | undefined;
94
+ bucket: string;
95
+ prefix: string | undefined;
96
+ region: string | undefined;
97
+ accessMode: "readonly" | "readwrite" | undefined;
98
+ endpoint: string | undefined;
99
+ forcePathStyle: boolean | undefined;
100
+ profile: string | undefined;
101
+ credentials: {
102
+ accessKeyId: string;
103
+ secretAccessKey: string;
104
+ sessionToken: string | undefined;
105
+ } | undefined;
106
+ cacheTtl: number | undefined;
107
+ }, unknown, z.core.$ZodTypeInternals<{
108
+ name: string | undefined;
109
+ description: string | undefined;
110
+ bucket: string;
111
+ prefix: string | undefined;
112
+ region: string | undefined;
113
+ accessMode: "readonly" | "readwrite" | undefined;
114
+ endpoint: string | undefined;
115
+ forcePathStyle: boolean | undefined;
116
+ profile: string | undefined;
117
+ credentials: {
118
+ accessKeyId: string;
119
+ secretAccessKey: string;
120
+ sessionToken: string | undefined;
121
+ } | undefined;
122
+ cacheTtl: number | undefined;
123
+ }, unknown>>;
124
+ /**
125
+ * Provider manifest for URI-based discovery
126
+ */
127
+ static manifest(): ProviderManifest;
128
+ /**
129
+ * Load from configuration file
130
+ */
131
+ static load({
132
+ basePath,
133
+ config
134
+ }?: AFSModuleLoadParams): Promise<AFSS3>;
135
+ /**
136
+ * Build the full S3 key from a path
137
+ */
138
+ private buildS3Key;
139
+ /**
140
+ * Generate a unique ID for an S3 object
141
+ */
142
+ private generateId;
143
+ /**
144
+ * Invalidate caches for a given path
145
+ */
146
+ private invalidateCache;
147
+ /**
148
+ * Clear all caches
149
+ */
150
+ clearCache(): void;
151
+ listHandler(ctx: RouteContext<{
152
+ path?: string;
153
+ }>): Promise<AFSListResult>;
154
+ /**
155
+ * List with delimiter (single level)
156
+ */
157
+ private listWithDelimiter;
158
+ listVersionsHandler(ctx: RouteContext<{
159
+ path: string;
160
+ }>): Promise<AFSListResult>;
161
+ readHandler(ctx: RouteContext<{
162
+ path: string;
163
+ }>): Promise<AFSEntry>;
164
+ readVersionHandler(ctx: RouteContext<{
165
+ path: string;
166
+ versionId: string;
167
+ }>): Promise<AFSEntry>;
168
+ metaHandler(ctx: RouteContext<{
169
+ path?: string;
170
+ }>): Promise<AFSEntry>;
171
+ statHandler(ctx: RouteContext<{
172
+ path?: string;
173
+ }>): Promise<AFSStatResult>;
174
+ writeHandler(ctx: RouteContext<{
175
+ path: string;
176
+ }>, payload: AFSWriteEntryPayload): Promise<AFSWriteResult>;
177
+ deleteHandler(ctx: RouteContext<{
178
+ path: string;
179
+ }>): Promise<AFSDeleteResult>;
180
+ listActionsHandler(ctx: RouteContext<{
181
+ path: string;
182
+ }>): Promise<AFSListResult>;
183
+ selectActionHandler(ctx: RouteContext<{
184
+ path: string;
185
+ }>, args: Record<string, unknown>): Promise<AFSExecResult>;
186
+ presignDownloadActionHandler(ctx: RouteContext<{
187
+ path: string;
188
+ }>, args: Record<string, unknown>): Promise<AFSExecResult>;
189
+ presignUploadActionHandler(ctx: RouteContext<{
190
+ path: string;
191
+ }>, args: Record<string, unknown>): Promise<AFSExecResult>;
192
+ explainHandler(ctx: RouteContext<{
193
+ path?: string;
194
+ }>): Promise<AFSExplainResult>;
195
+ searchHandler(ctx: RouteContext<{
196
+ path?: string;
197
+ }>, query: string): Promise<AFSSearchResult>;
198
+ readCapabilities(_ctx: RouteContext): Promise<AFSEntry>;
199
+ }
200
+ //#endregion
201
+ export { AFSS3, AFSS3 as default, type AFSS3Options, type ParsedS3Uri };
202
+ //# 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;;;AAAA,UAAiB,YAAA;EAEf;EAAA,IAAA;EAMA;EAHA,WAAA;EASA;EANA,MAAA;EAYA;EATA,MAAA;EAeA;EAZA,MAAA;EAgBE;EAbF,UAAA;EAeE;EAZF,QAAA;EAsBA;EAnBA,cAAA;EAmBiB;EAhBjB,OAAA;EAuEe;EApEf,WAAA;IACE,WAAA;IACA,eAAA;IACA,YAAA;EAAA;;EAIF,QAAA;EC4CW;;;;EDtCX,MAAA,GAAS,QAAA;AAAA;;;;UAuDM,WAAA;E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