@geekmidas/storage 10.0.0-alpha.98 → 10.0.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 +79 -0
- package/README.md +13 -49
- package/dist/AmazonStorageClient-BHpWawGD.d.mts +45 -0
- package/dist/AmazonStorageClient-BHpWawGD.d.mts.map +1 -0
- package/dist/AmazonStorageClient-BNoY2PL6.d.cts +45 -0
- package/dist/AmazonStorageClient-BNoY2PL6.d.cts.map +1 -0
- package/dist/AmazonStorageClient-BvoZepKJ.cjs +161 -0
- package/dist/AmazonStorageClient-BvoZepKJ.cjs.map +1 -0
- package/dist/AmazonStorageClient-Dz-KCJ_4.mjs +127 -0
- package/dist/AmazonStorageClient-Dz-KCJ_4.mjs.map +1 -0
- package/dist/AmazonStorageClient.cjs +5 -0
- package/dist/AmazonStorageClient.d.cts +3 -0
- package/dist/AmazonStorageClient.d.mts +3 -0
- package/dist/AmazonStorageClient.mjs +4 -0
- package/dist/StorageClient-4ADnTPnJ.mjs +11 -0
- package/dist/StorageClient-4ADnTPnJ.mjs.map +1 -0
- package/dist/StorageClient-BDRVrMJj.cjs +17 -0
- package/dist/StorageClient-BDRVrMJj.cjs.map +1 -0
- package/dist/{registry-ClEvHGpM.d.cts → StorageClient-COs9SOsU.d.cts} +5 -27
- package/dist/StorageClient-COs9SOsU.d.cts.map +1 -0
- package/dist/{registry-ClEvHGpM.d.mts → StorageClient-DH4tP-Mf.d.mts} +5 -27
- package/dist/StorageClient-DH4tP-Mf.d.mts.map +1 -0
- package/dist/StorageClient.cjs +3 -0
- package/dist/StorageClient.d.cts +2 -0
- package/dist/StorageClient.d.mts +2 -0
- package/dist/StorageClient.mjs +3 -0
- package/dist/aws.cjs +4 -198
- package/dist/aws.d.cts +3 -50
- package/dist/aws.d.mts +3 -50
- package/dist/aws.mjs +3 -189
- package/dist/index.cjs +0 -55
- package/dist/index.d.cts +2 -87
- package/dist/index.d.mts +2 -87
- package/dist/index.mjs +0 -45
- package/package.json +9 -27
- package/src/AmazonStorageClient.ts +207 -0
- package/src/StorageClient.ts +108 -0
- package/src/__tests__/AmazonStorageClient.spec.ts +606 -0
- package/src/__tests__/StorageClient.spec.ts +98 -0
- package/src/aws.ts +11 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +9 -0
- package/tsdown.config.ts +9 -0
- package/dist/aws.cjs.map +0 -1
- package/dist/aws.d.cts.map +0 -1
- package/dist/aws.d.mts.map +0 -1
- package/dist/aws.mjs.map +0 -1
- package/dist/errors-BB8jdHif.cjs +0 -157
- package/dist/errors-BB8jdHif.cjs.map +0 -1
- package/dist/errors-COXs1iNg.mjs +0 -116
- package/dist/errors-COXs1iNg.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/registry-ClEvHGpM.d.cts.map +0 -1
- package/dist/registry-ClEvHGpM.d.mts.map +0 -1
- package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
- package/dist/s3Url.cjs +0 -109
- package/dist/s3Url.cjs.map +0 -1
- package/dist/s3Url.d.cts +0 -52
- package/dist/s3Url.d.cts.map +0 -1
- package/dist/s3Url.d.mts +0 -52
- package/dist/s3Url.d.mts.map +0 -1
- package/dist/s3Url.mjs +0 -90
- package/dist/s3Url.mjs.map +0 -1
package/dist/s3Url.d.mts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
declare namespace s3Url_d_exports {
|
|
2
|
-
export { S3Address, build, parse };
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* The `s3://` URL codec — how an S3 bucket is addressed as a single string.
|
|
6
|
-
*
|
|
7
|
-
* It lives beside the client rather than in a neutral package because `bucket`,
|
|
8
|
-
* `region`, and `forcePathStyle` are S3's vocabulary. The neutral layer only
|
|
9
|
-
* knows that a construct provides *one URL*; what that URL says is between the
|
|
10
|
-
* component that composes it and the client that parses it. A `gs://` codec
|
|
11
|
-
* would sit beside its own client and share nothing with this one.
|
|
12
|
-
*
|
|
13
|
-
* Both directions live here so they cannot drift: `parse(build(x))` is `x`.
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* What an S3 URL addresses, and optionally who it calls as.
|
|
17
|
-
*
|
|
18
|
-
* Credentials are optional and come as a pair. With them, the URL is a key
|
|
19
|
-
* scoped to this one bucket (`s3://KEY:SECRET@uploads`); without them the AWS
|
|
20
|
-
* SDK resolves its own chain — an execution role when deployed,
|
|
21
|
-
* `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY` otherwise. The URL's pair wins
|
|
22
|
-
* over that chain.
|
|
23
|
-
*/
|
|
24
|
-
export interface S3Address {
|
|
25
|
-
bucket: string;
|
|
26
|
-
/** Read off the bucket, never inherited: a bucket may live in another region. */
|
|
27
|
-
region?: string;
|
|
28
|
-
/** Set for S3-compatible backends such as MinIO. */
|
|
29
|
-
endpoint?: string;
|
|
30
|
-
/** MinIO and most S3-compatible servers need path-style addressing. */
|
|
31
|
-
forcePathStyle?: boolean;
|
|
32
|
-
/** The URL's own access key; always paired with `secretAccessKey`. */
|
|
33
|
-
accessKeyId?: string;
|
|
34
|
-
/** The URL's own secret; always paired with `accessKeyId`. */
|
|
35
|
-
secretAccessKey?: string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Compose an address into a URL.
|
|
39
|
-
*
|
|
40
|
-
* Credentials appear only when the address carries them, percent-encoded —
|
|
41
|
-
* AWS secrets routinely contain `/` and `+`. An address without them builds a
|
|
42
|
-
* URL with no userinfo, which leaves the caller to the SDK's own chain.
|
|
43
|
-
*/
|
|
44
|
-
export declare function build(address: S3Address): string;
|
|
45
|
-
/**
|
|
46
|
-
* Parse a URL back into an address. Throws if it is not an `s3://` URL, or if
|
|
47
|
-
* its userinfo carries only one half of a key pair.
|
|
48
|
-
*/
|
|
49
|
-
export declare function parse(url: string): S3Address;
|
|
50
|
-
//#endregion
|
|
51
|
-
export { s3Url_d_exports as t };
|
|
52
|
-
//# sourceMappingURL=s3Url.d.mts.map
|
package/dist/s3Url.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"s3Url.d.mts","names":[],"sources":["../src/s3Url.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;iBA4BiB;EAChB;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;wBAYe,MAAM,SAAS;;;;;wBAgCf,MAAM,cAAc"}
|
package/dist/s3Url.mjs
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { a as UnexpectedStorageScheme, n as MalformedStorageUrl, r as MissingStorageBucket, t as IncompleteStorageCredentials } from "./errors-COXs1iNg.mjs";
|
|
3
|
-
//#region src/s3Url.ts
|
|
4
|
-
/**
|
|
5
|
-
* The `s3://` URL codec — how an S3 bucket is addressed as a single string.
|
|
6
|
-
*
|
|
7
|
-
* It lives beside the client rather than in a neutral package because `bucket`,
|
|
8
|
-
* `region`, and `forcePathStyle` are S3's vocabulary. The neutral layer only
|
|
9
|
-
* knows that a construct provides *one URL*; what that URL says is between the
|
|
10
|
-
* component that composes it and the client that parses it. A `gs://` codec
|
|
11
|
-
* would sit beside its own client and share nothing with this one.
|
|
12
|
-
*
|
|
13
|
-
* Both directions live here so they cannot drift: `parse(build(x))` is `x`.
|
|
14
|
-
*/
|
|
15
|
-
var s3Url_exports = /* @__PURE__ */ __exportAll({
|
|
16
|
-
build: () => build,
|
|
17
|
-
parse: () => parse
|
|
18
|
-
});
|
|
19
|
-
const SCHEME = "s3:";
|
|
20
|
-
/**
|
|
21
|
-
* Compose an address into a URL.
|
|
22
|
-
*
|
|
23
|
-
* Credentials appear only when the address carries them, percent-encoded —
|
|
24
|
-
* AWS secrets routinely contain `/` and `+`. An address without them builds a
|
|
25
|
-
* URL with no userinfo, which leaves the caller to the SDK's own chain.
|
|
26
|
-
*/
|
|
27
|
-
function build(address) {
|
|
28
|
-
const { bucket, region, endpoint, forcePathStyle, accessKeyId, secretAccessKey } = address;
|
|
29
|
-
if (!bucket) throw new MissingStorageBucket("");
|
|
30
|
-
const url = new URL(`${SCHEME}//${bucket}`);
|
|
31
|
-
if (accessKeyId || secretAccessKey) {
|
|
32
|
-
if (!accessKeyId) throw new IncompleteStorageCredentials(url.toString(), "accessKeyId");
|
|
33
|
-
if (!secretAccessKey) throw new IncompleteStorageCredentials(url.toString(), "secretAccessKey");
|
|
34
|
-
url.username = encodeURIComponent(accessKeyId);
|
|
35
|
-
url.password = encodeURIComponent(secretAccessKey);
|
|
36
|
-
}
|
|
37
|
-
if (region) url.searchParams.set("region", region);
|
|
38
|
-
if (endpoint) url.searchParams.set("endpoint", endpoint);
|
|
39
|
-
if (forcePathStyle) url.searchParams.set("forcePathStyle", "true");
|
|
40
|
-
return url.toString();
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Parse a URL back into an address. Throws if it is not an `s3://` URL, or if
|
|
44
|
-
* its userinfo carries only one half of a key pair.
|
|
45
|
-
*/
|
|
46
|
-
function parse(url) {
|
|
47
|
-
let parsed;
|
|
48
|
-
try {
|
|
49
|
-
parsed = new URL(url);
|
|
50
|
-
} catch {
|
|
51
|
-
throw new MalformedStorageUrl(url);
|
|
52
|
-
}
|
|
53
|
-
if (parsed.protocol !== SCHEME) throw new UnexpectedStorageScheme(url, SCHEME, parsed.protocol);
|
|
54
|
-
const bucket = parsed.hostname;
|
|
55
|
-
if (!bucket) throw new MissingStorageBucket(url);
|
|
56
|
-
const region = parsed.searchParams.get("region") ?? void 0;
|
|
57
|
-
const endpoint = parsed.searchParams.get("endpoint") ?? void 0;
|
|
58
|
-
const forcePathStyle = parsed.searchParams.get("forcePathStyle") === "true" ? true : void 0;
|
|
59
|
-
const credentials = credentialsOf(url, parsed);
|
|
60
|
-
return {
|
|
61
|
-
bucket,
|
|
62
|
-
...region ? { region } : {},
|
|
63
|
-
...endpoint ? { endpoint } : {},
|
|
64
|
-
...forcePathStyle ? { forcePathStyle } : {},
|
|
65
|
-
...credentials
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/** The URL's userinfo as a key pair: both halves, or nothing. */
|
|
69
|
-
function credentialsOf(url, parsed) {
|
|
70
|
-
const accessKeyId = decode(url, parsed.username);
|
|
71
|
-
const secretAccessKey = decode(url, parsed.password);
|
|
72
|
-
if (!accessKeyId && !secretAccessKey) return {};
|
|
73
|
-
if (!accessKeyId) throw new IncompleteStorageCredentials(url, "accessKeyId");
|
|
74
|
-
if (!secretAccessKey) throw new IncompleteStorageCredentials(url, "secretAccessKey");
|
|
75
|
-
return {
|
|
76
|
-
accessKeyId,
|
|
77
|
-
secretAccessKey
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function decode(url, value) {
|
|
81
|
-
try {
|
|
82
|
-
return decodeURIComponent(value);
|
|
83
|
-
} catch {
|
|
84
|
-
throw new MalformedStorageUrl(url);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
export { build, parse, s3Url_exports as t };
|
|
89
|
-
|
|
90
|
-
//# sourceMappingURL=s3Url.mjs.map
|
package/dist/s3Url.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"s3Url.mjs","names":[],"sources":["../src/s3Url.ts"],"sourcesContent":["/**\n * The `s3://` URL codec — how an S3 bucket is addressed as a single string.\n *\n * It lives beside the client rather than in a neutral package because `bucket`,\n * `region`, and `forcePathStyle` are S3's vocabulary. The neutral layer only\n * knows that a construct provides *one URL*; what that URL says is between the\n * component that composes it and the client that parses it. A `gs://` codec\n * would sit beside its own client and share nothing with this one.\n *\n * Both directions live here so they cannot drift: `parse(build(x))` is `x`.\n */\n\nimport {\n\tIncompleteStorageCredentials,\n\tMalformedStorageUrl,\n\tMissingStorageBucket,\n\tUnexpectedStorageScheme,\n} from './errors';\n\n/**\n * What an S3 URL addresses, and optionally who it calls as.\n *\n * Credentials are optional and come as a pair. With them, the URL is a key\n * scoped to this one bucket (`s3://KEY:SECRET@uploads`); without them the AWS\n * SDK resolves its own chain — an execution role when deployed,\n * `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY` otherwise. The URL's pair wins\n * over that chain.\n */\nexport interface S3Address {\n\tbucket: string;\n\t/** Read off the bucket, never inherited: a bucket may live in another region. */\n\tregion?: string;\n\t/** Set for S3-compatible backends such as MinIO. */\n\tendpoint?: string;\n\t/** MinIO and most S3-compatible servers need path-style addressing. */\n\tforcePathStyle?: boolean;\n\t/** The URL's own access key; always paired with `secretAccessKey`. */\n\taccessKeyId?: string;\n\t/** The URL's own secret; always paired with `accessKeyId`. */\n\tsecretAccessKey?: string;\n}\n\nconst SCHEME = 's3:';\n\n/**\n * Compose an address into a URL.\n *\n * Credentials appear only when the address carries them, percent-encoded —\n * AWS secrets routinely contain `/` and `+`. An address without them builds a\n * URL with no userinfo, which leaves the caller to the SDK's own chain.\n */\nexport function build(address: S3Address): string {\n\tconst {\n\t\tbucket,\n\t\tregion,\n\t\tendpoint,\n\t\tforcePathStyle,\n\t\taccessKeyId,\n\t\tsecretAccessKey,\n\t} = address;\n\tif (!bucket) throw new MissingStorageBucket('');\n\n\tconst url = new URL(`${SCHEME}//${bucket}`);\n\tif (accessKeyId || secretAccessKey) {\n\t\tif (!accessKeyId) {\n\t\t\tthrow new IncompleteStorageCredentials(url.toString(), 'accessKeyId');\n\t\t}\n\t\tif (!secretAccessKey) {\n\t\t\tthrow new IncompleteStorageCredentials(url.toString(), 'secretAccessKey');\n\t\t}\n\t\turl.username = encodeURIComponent(accessKeyId);\n\t\turl.password = encodeURIComponent(secretAccessKey);\n\t}\n\tif (region) url.searchParams.set('region', region);\n\tif (endpoint) url.searchParams.set('endpoint', endpoint);\n\tif (forcePathStyle) url.searchParams.set('forcePathStyle', 'true');\n\treturn url.toString();\n}\n\n/**\n * Parse a URL back into an address. Throws if it is not an `s3://` URL, or if\n * its userinfo carries only one half of a key pair.\n */\nexport function parse(url: string): S3Address {\n\tlet parsed: URL;\n\ttry {\n\t\tparsed = new URL(url);\n\t} catch {\n\t\tthrow new MalformedStorageUrl(url);\n\t}\n\n\tif (parsed.protocol !== SCHEME) {\n\t\tthrow new UnexpectedStorageScheme(url, SCHEME, parsed.protocol);\n\t}\n\n\tconst bucket = parsed.hostname;\n\tif (!bucket) throw new MissingStorageBucket(url);\n\n\tconst region = parsed.searchParams.get('region') ?? undefined;\n\tconst endpoint = parsed.searchParams.get('endpoint') ?? undefined;\n\tconst forcePathStyle =\n\t\tparsed.searchParams.get('forcePathStyle') === 'true' ? true : undefined;\n\tconst credentials = credentialsOf(url, parsed);\n\n\treturn {\n\t\tbucket,\n\t\t...(region ? { region } : {}),\n\t\t...(endpoint ? { endpoint } : {}),\n\t\t...(forcePathStyle ? { forcePathStyle } : {}),\n\t\t...credentials,\n\t};\n}\n\n/** The URL's userinfo as a key pair: both halves, or nothing. */\nfunction credentialsOf(\n\turl: string,\n\tparsed: URL,\n): Pick<S3Address, 'accessKeyId' | 'secretAccessKey'> {\n\tconst accessKeyId = decode(url, parsed.username);\n\tconst secretAccessKey = decode(url, parsed.password);\n\tif (!accessKeyId && !secretAccessKey) return {};\n\tif (!accessKeyId) {\n\t\tthrow new IncompleteStorageCredentials(url, 'accessKeyId');\n\t}\n\tif (!secretAccessKey) {\n\t\tthrow new IncompleteStorageCredentials(url, 'secretAccessKey');\n\t}\n\treturn { accessKeyId, secretAccessKey };\n}\n\nfunction decode(url: string, value: string): string {\n\ttry {\n\t\treturn decodeURIComponent(value);\n\t} catch {\n\t\tthrow new MalformedStorageUrl(url);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0CA,MAAM,SAAS;;;;;;;;AASf,SAAgB,MAAM,SAA4B;CACjD,MAAM,EACL,QACA,QACA,UACA,gBACA,aACA,oBACG;CACJ,IAAI,CAAC,QAAQ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