@edgestore/server 0.4.0 → 0.5.1
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/adapters/astro/index.d.ts +1 -0
- package/adapters/astro/index.js +1 -0
- package/adapters/hono/index.d.ts +1 -0
- package/adapters/hono/index.js +1 -0
- package/adapters/remix/index.d.ts +1 -0
- package/adapters/remix/index.js +1 -0
- package/dist/adapters/astro/index.d.ts +14 -0
- package/dist/adapters/astro/index.d.ts.map +1 -0
- package/dist/adapters/astro/index.js +183 -0
- package/dist/adapters/astro/index.mjs +179 -0
- package/dist/adapters/express/index.js +3 -3
- package/dist/adapters/express/index.mjs +3 -3
- package/dist/adapters/fastify/index.js +3 -3
- package/dist/adapters/fastify/index.mjs +3 -3
- package/dist/adapters/hono/index.d.ts +82 -0
- package/dist/adapters/hono/index.d.ts.map +1 -0
- package/dist/adapters/hono/index.js +137 -0
- package/dist/adapters/hono/index.mjs +133 -0
- package/dist/adapters/next/app/index.js +3 -3
- package/dist/adapters/next/app/index.mjs +3 -3
- package/dist/adapters/next/pages/index.js +3 -3
- package/dist/adapters/next/pages/index.mjs +3 -3
- package/dist/adapters/remix/index.d.ts +18 -0
- package/dist/adapters/remix/index.d.ts.map +1 -0
- package/dist/adapters/remix/index.js +158 -0
- package/dist/adapters/remix/index.mjs +154 -0
- package/dist/adapters/shared.d.ts +2 -0
- package/dist/adapters/shared.d.ts.map +1 -1
- package/dist/adapters/start/index.js +3 -3
- package/dist/adapters/start/index.mjs +3 -3
- package/dist/core/index.js +3 -3
- package/dist/core/index.mjs +4 -4
- package/dist/core/sdk/index.d.ts.map +1 -1
- package/dist/{index-a7cc3cd3.mjs → index-2848cb40.mjs} +3 -2
- package/dist/{index-474a21c4.js → index-421c502f.js} +3 -2
- package/dist/{index-b689bf59.js → index-7b259533.js} +5 -4
- package/dist/libs/logger.d.ts +1 -1
- package/dist/libs/logger.d.ts.map +1 -1
- package/dist/providers/aws/index.d.ts +15 -1
- package/dist/providers/aws/index.d.ts.map +1 -1
- package/dist/providers/aws/index.js +28 -8
- package/dist/providers/aws/index.mjs +28 -8
- package/dist/providers/azure/index.d.ts.map +1 -1
- package/dist/providers/azure/index.js +6 -1
- package/dist/providers/azure/index.mjs +6 -1
- package/dist/providers/edgestore/index.d.ts.map +1 -1
- package/dist/providers/edgestore/index.js +13 -6
- package/dist/providers/edgestore/index.mjs +10 -3
- package/dist/{shared-d27101a7.js → shared-25dbfab4.js} +17 -4
- package/dist/{shared-c9442cbb.mjs → shared-4b199b96.mjs} +16 -4
- package/dist/{shared-6f6fd0bd.js → shared-685c8a0c.js} +17 -3
- package/dist/{utils-5819d5e1.js → utils-0aab6e3b.js} +3 -1
- package/dist/{utils-f6f56d38.mjs → utils-7349adab.mjs} +3 -1
- package/dist/{utils-461a2e3b.js → utils-b3d35894.js} +3 -2
- package/package.json +20 -3
- package/src/adapters/astro/index.ts +222 -0
- package/src/adapters/hono/index.ts +195 -0
- package/src/adapters/remix/index.ts +201 -0
- package/src/adapters/shared.ts +20 -3
- package/src/core/client/index.ts +2 -2
- package/src/core/sdk/index.ts +4 -3
- package/src/libs/logger.ts +4 -3
- package/src/providers/aws/index.ts +66 -14
- package/src/providers/azure/index.ts +5 -4
- package/src/providers/edgestore/index.ts +8 -3
- package/adapters/index.d.ts +0 -1
- package/adapters/index.js +0 -1
- package/providers/index.d.ts +0 -1
- package/providers/index.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/adapters/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC5B,MAAM,mBAAmB,CAAC;AAe3B,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE;IACvC,QAAQ,EAAE,QAA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M,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE;IAC7C,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE,cAAc,CAAC;CACtB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAwD/B;AA8CD,wBAAgB,SAAS,CAAC,MAAM,EAAE;IAChC,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACxC,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE;QACT,GAAG,EAAE,GAAG,CAAC;QACT,KAAK,EAAE,GAAG,CAAC;KACZ,CAAC;CACH;;;IA8BA;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE;;;EAU/D;AAwBD,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOtD;AAED,wBAAgB,KAAK,IAAI,OAAO,CAM/B"}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var shared = require('@edgestore/shared');
|
|
6
|
-
var utils = require('../../utils-
|
|
6
|
+
var utils = require('../../utils-0aab6e3b.js');
|
|
7
7
|
var providers_edgestore_index = require('../../providers/edgestore/index.js');
|
|
8
|
-
var shared$1 = require('../../shared-
|
|
9
|
-
require('../../index-
|
|
8
|
+
var shared$1 = require('../../shared-685c8a0c.js');
|
|
9
|
+
require('../../index-7b259533.js');
|
|
10
10
|
require('@panva/hkdf');
|
|
11
11
|
require('cookie');
|
|
12
12
|
require('jose');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
|
|
2
|
-
import { L as Logger, m as matchPath } from '../../utils-
|
|
2
|
+
import { L as Logger, m as matchPath } from '../../utils-7349adab.mjs';
|
|
3
3
|
import { EdgeStoreProvider } from '../../providers/edgestore/index.mjs';
|
|
4
|
-
import {
|
|
5
|
-
import '../../index-
|
|
4
|
+
import { a as init, r as requestUpload, c as requestUploadParts, d as completeMultipartUpload, e as confirmUpload, f as deleteFile } from '../../shared-4b199b96.mjs';
|
|
5
|
+
import '../../index-2848cb40.mjs';
|
|
6
6
|
import '@panva/hkdf';
|
|
7
7
|
import 'cookie';
|
|
8
8
|
import 'jose';
|
package/dist/core/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var shared = require('../shared-
|
|
6
|
-
var index = require('../index-
|
|
5
|
+
var shared = require('../shared-685c8a0c.js');
|
|
6
|
+
var index = require('../index-7b259533.js');
|
|
7
7
|
require('@edgestore/shared');
|
|
8
8
|
require('@panva/hkdf');
|
|
9
9
|
require('cookie');
|
|
@@ -160,7 +160,7 @@ function initEdgeStoreClient(config) {
|
|
|
160
160
|
* Since third party cookies don't work on localhost,
|
|
161
161
|
* we need to proxy the file through the server.
|
|
162
162
|
*/ function getUrl(url, baseUrl) {
|
|
163
|
-
if (
|
|
163
|
+
if (shared.isDev() && !url.includes('/_public/')) {
|
|
164
164
|
if (!baseUrl) {
|
|
165
165
|
throw new Error('Missing baseUrl. You need to pass the baseUrl to `initEdgeStoreClient` to get protected files in development.');
|
|
166
166
|
}
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { b as buildPath, p as parsePath } from '../shared-
|
|
2
|
-
import { i as initEdgeStoreSdk } from '../index-
|
|
3
|
-
export { e as edgeStoreRawSdk, i as initEdgeStoreSdk } from '../index-
|
|
1
|
+
import { b as buildPath, p as parsePath, i as isDev } from '../shared-4b199b96.mjs';
|
|
2
|
+
import { i as initEdgeStoreSdk } from '../index-2848cb40.mjs';
|
|
3
|
+
export { e as edgeStoreRawSdk, i as initEdgeStoreSdk } from '../index-2848cb40.mjs';
|
|
4
4
|
import '@edgestore/shared';
|
|
5
5
|
import '@panva/hkdf';
|
|
6
6
|
import 'cookie';
|
|
@@ -157,7 +157,7 @@ function initEdgeStoreClient(config) {
|
|
|
157
157
|
* Since third party cookies don't work on localhost,
|
|
158
158
|
* we need to proxy the file through the server.
|
|
159
159
|
*/ function getUrl(url, baseUrl) {
|
|
160
|
-
if (
|
|
160
|
+
if (isDev() && !url.includes('/_public/')) {
|
|
161
161
|
if (!baseUrl) {
|
|
162
162
|
throw new Error('Missing baseUrl. You need to pass the baseUrl to `initEdgeStoreClient` to get protected files in development.');
|
|
163
163
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,mBAAmB,CAAC;AAO3B,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,QAAQ,EAAE,WAAW,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,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E_ACCESS_KEY or EDGE_STORE_SECRET_KEY.
|
|
4
5
|
This can happen if you are trying to import something related to the backend of EdgeStore in a client component.`;
|
|
@@ -9,7 +10,7 @@ class EdgeStoreCredentialsError extends Error {
|
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
const API_ENDPOINT =
|
|
13
|
+
const API_ENDPOINT = getEnv('EDGE_STORE_API_ENDPOINT') ?? 'https://api.edgestore.dev';
|
|
13
14
|
async function makeRequest(params) {
|
|
14
15
|
const { body, accessKey, secretKey, path } = params;
|
|
15
16
|
const res = await fetch(`${API_ENDPOINT}${path}`, {
|
|
@@ -156,7 +157,7 @@ const edgeStoreRawSdk = {
|
|
|
156
157
|
}
|
|
157
158
|
};
|
|
158
159
|
function initEdgeStoreSdk(params) {
|
|
159
|
-
const { accessKey =
|
|
160
|
+
const { accessKey = getEnv('EDGE_STORE_ACCESS_KEY'), secretKey = getEnv('EDGE_STORE_SECRET_KEY') } = params ?? {};
|
|
160
161
|
if (!accessKey || !secretKey) {
|
|
161
162
|
throw new EdgeStoreCredentialsError();
|
|
162
163
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EdgeStoreError } from '@edgestore/shared';
|
|
2
|
+
import { g as getEnv } from './shared-25dbfab4.js';
|
|
2
3
|
|
|
3
4
|
const DEFAULT_MESSAGE = `Missing EDGE_STORE_ACCESS_KEY or EDGE_STORE_SECRET_KEY.
|
|
4
5
|
This can happen if you are trying to import something related to the backend of EdgeStore in a client component.`;
|
|
@@ -9,7 +10,7 @@ class EdgeStoreCredentialsError extends Error {
|
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
const API_ENDPOINT =
|
|
13
|
+
const API_ENDPOINT = getEnv('EDGE_STORE_API_ENDPOINT') ?? 'https://api.edgestore.dev';
|
|
13
14
|
async function makeRequest(params) {
|
|
14
15
|
const { body, accessKey, secretKey, path } = params;
|
|
15
16
|
const res = await fetch(`${API_ENDPOINT}${path}`, {
|
|
@@ -156,7 +157,7 @@ const edgeStoreRawSdk = {
|
|
|
156
157
|
},
|
|
157
158
|
};
|
|
158
159
|
function initEdgeStoreSdk(params) {
|
|
159
|
-
const { accessKey =
|
|
160
|
+
const { accessKey = getEnv('EDGE_STORE_ACCESS_KEY'), secretKey = getEnv('EDGE_STORE_SECRET_KEY'), } = params ?? {};
|
|
160
161
|
if (!accessKey || !secretKey) {
|
|
161
162
|
throw new EdgeStoreCredentialsError();
|
|
162
163
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var shared = require('@edgestore/shared');
|
|
3
|
+
var shared$1 = require('@edgestore/shared');
|
|
4
|
+
var shared = require('./shared-685c8a0c.js');
|
|
4
5
|
|
|
5
6
|
const DEFAULT_MESSAGE = `Missing EDGE_STORE_ACCESS_KEY or EDGE_STORE_SECRET_KEY.
|
|
6
7
|
This can happen if you are trying to import something related to the backend of EdgeStore in a client component.`;
|
|
@@ -11,7 +12,7 @@ class EdgeStoreCredentialsError extends Error {
|
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
const API_ENDPOINT =
|
|
15
|
+
const API_ENDPOINT = shared.getEnv('EDGE_STORE_API_ENDPOINT') ?? 'https://api.edgestore.dev';
|
|
15
16
|
async function makeRequest(params) {
|
|
16
17
|
const { body, accessKey, secretKey, path } = params;
|
|
17
18
|
const res = await fetch(`${API_ENDPOINT}${path}`, {
|
|
@@ -34,7 +35,7 @@ const edgeStoreRawSdk = {
|
|
|
34
35
|
path: bucket._def.path.map((p)=>{
|
|
35
36
|
const paramEntries = Object.entries(p);
|
|
36
37
|
if (paramEntries[0] === undefined) {
|
|
37
|
-
throw new shared.EdgeStoreError({
|
|
38
|
+
throw new shared$1.EdgeStoreError({
|
|
38
39
|
message: `Empty path param found in: ${JSON.stringify(bucket._def.path)}`,
|
|
39
40
|
code: 'SERVER_ERROR'
|
|
40
41
|
});
|
|
@@ -158,7 +159,7 @@ const edgeStoreRawSdk = {
|
|
|
158
159
|
}
|
|
159
160
|
};
|
|
160
161
|
function initEdgeStoreSdk(params) {
|
|
161
|
-
const { accessKey =
|
|
162
|
+
const { accessKey = shared.getEnv('EDGE_STORE_ACCESS_KEY'), secretKey = shared.getEnv('EDGE_STORE_SECRET_KEY') } = params ?? {};
|
|
162
163
|
if (!accessKey || !secretKey) {
|
|
163
164
|
throw new EdgeStoreCredentialsError();
|
|
164
165
|
}
|
package/dist/libs/logger.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/libs/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/libs/logger.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,QAAQ,qDAAsD,CAAC;AAErE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjD,cAAM,MAAM;IACV,OAAO,CAAC,QAAQ,CAAW;gBAEf,QAAQ,CAAC,EAAE,QAAQ;IAI/B,OAAO,CAAC,SAAS;IAIjB,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI;IAMpD,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI;IAMnD,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI;IAMnD,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI;CAKrD;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { type Provider } from '@edgestore/shared';
|
|
1
|
+
import { type MaybePromise, type Provider, type RequestUploadParams } from '@edgestore/shared';
|
|
2
|
+
type ProviderUploadedFileInfo = RequestUploadParams['fileInfo'];
|
|
3
|
+
export type AWSOverwritePathFnArgs = {
|
|
4
|
+
esBucketName: string;
|
|
5
|
+
fileInfo: ProviderUploadedFileInfo;
|
|
6
|
+
defaultAccessPath: string;
|
|
7
|
+
};
|
|
8
|
+
export type AWSOverwritePathFn = (args: AWSOverwritePathFnArgs) => MaybePromise<string>;
|
|
2
9
|
export type AWSProviderOptions = {
|
|
3
10
|
/**
|
|
4
11
|
* Access key for AWS credentials.
|
|
@@ -49,6 +56,13 @@ export type AWSProviderOptions = {
|
|
|
49
56
|
* It can also be set via the `EDGE_STORE_JWT_SECRET` environment variable.
|
|
50
57
|
*/
|
|
51
58
|
jwtSecret?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Optional function to overwrite the S3 key (object path) for uploads.
|
|
61
|
+
* This function receives the EdgeStore bucket name, fileInfo and the default S3 key
|
|
62
|
+
* and should return the desired S3 key string.
|
|
63
|
+
*/
|
|
64
|
+
overwritePath?: AWSOverwritePathFn;
|
|
52
65
|
};
|
|
53
66
|
export declare function AWSProvider(options?: AWSProviderOptions): Provider;
|
|
67
|
+
export {};
|
|
54
68
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/aws/index.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/aws/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAK3B,KAAK,wBAAwB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAEhE,MAAM,MAAM,sBAAsB,GAAG;IAEnC,YAAY,EAAE,MAAM,CAAC;IAErB,QAAQ,EAAE,wBAAwB,CAAC;IAEnC,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAC/B,IAAI,EAAE,sBAAsB,KACzB,YAAY,CAAC,MAAM,CAAC,CAAC;AAE1B,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC;AAEF,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,QAAQ,CAuIlE"}
|
|
@@ -5,10 +5,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var clientS3 = require('@aws-sdk/client-s3');
|
|
6
6
|
var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
|
|
7
7
|
var uuid = require('uuid');
|
|
8
|
+
var shared = require('../../shared-685c8a0c.js');
|
|
9
|
+
require('@edgestore/shared');
|
|
10
|
+
require('@panva/hkdf');
|
|
11
|
+
require('cookie');
|
|
12
|
+
require('jose');
|
|
8
13
|
|
|
9
14
|
function AWSProvider(options) {
|
|
10
|
-
const { accessKeyId =
|
|
11
|
-
const baseUrl = options?.baseUrl ??
|
|
15
|
+
const { accessKeyId = shared.getEnv('ES_AWS_ACCESS_KEY_ID'), secretAccessKey = shared.getEnv('ES_AWS_SECRET_ACCESS_KEY'), region = shared.getEnv('ES_AWS_REGION'), bucketName = shared.getEnv('ES_AWS_BUCKET_NAME'), endpoint = shared.getEnv('ES_AWS_ENDPOINT'), forcePathStyle = shared.getEnv('ES_AWS_FORCE_PATH_STYLE') === 'true', overwritePath } = options ?? {};
|
|
16
|
+
const baseUrl = options?.baseUrl ?? shared.getEnv('EDGE_STORE_BASE_URL') ?? (endpoint ? `${endpoint}/${bucketName}` : `https://${bucketName}.s3.${region}.amazonaws.com`);
|
|
12
17
|
const credentials = accessKeyId && secretAccessKey ? {
|
|
13
18
|
accessKeyId,
|
|
14
19
|
secretAccessKey
|
|
@@ -43,15 +48,27 @@ function AWSProvider(options) {
|
|
|
43
48
|
uploadedAt: LastModified
|
|
44
49
|
};
|
|
45
50
|
},
|
|
46
|
-
async requestUpload (
|
|
51
|
+
async requestUpload (params) {
|
|
52
|
+
const { bucketName: esBucketName, fileInfo } = params;
|
|
53
|
+
if (!bucketName) {
|
|
54
|
+
throw new Error('S3 bucketName is not configured in AWSProviderOptions.');
|
|
55
|
+
}
|
|
56
|
+
// Default S3 key (accessPath) construction logic
|
|
47
57
|
const pathPrefix = `${esBucketName}${fileInfo.isPublic ? '/_public' : ''}`;
|
|
48
58
|
const nameId = uuid.v4();
|
|
49
59
|
const extension = fileInfo.extension ? `.${fileInfo.extension.replace('.', '')}` : '';
|
|
50
|
-
const
|
|
51
|
-
const
|
|
60
|
+
const defaultResolvedFileName = fileInfo.fileName ?? `${nameId}${extension}`;
|
|
61
|
+
const defaultFilePathFromMetadata = fileInfo.path.reduce((acc, item)=>{
|
|
52
62
|
return `${acc}/${item.value}`;
|
|
53
63
|
}, '');
|
|
54
|
-
|
|
64
|
+
let accessPath = `${pathPrefix}${defaultFilePathFromMetadata}/${defaultResolvedFileName}`;
|
|
65
|
+
if (overwritePath) {
|
|
66
|
+
accessPath = await overwritePath({
|
|
67
|
+
esBucketName,
|
|
68
|
+
fileInfo,
|
|
69
|
+
defaultAccessPath: accessPath
|
|
70
|
+
});
|
|
71
|
+
}
|
|
55
72
|
const command = new clientS3.PutObjectCommand({
|
|
56
73
|
Bucket: bucketName,
|
|
57
74
|
Key: accessPath
|
|
@@ -59,10 +76,10 @@ function AWSProvider(options) {
|
|
|
59
76
|
const signedUrl = await s3RequestPresigner.getSignedUrl(s3Client, command, {
|
|
60
77
|
expiresIn: 60 * 60
|
|
61
78
|
});
|
|
62
|
-
const
|
|
79
|
+
const finalAccessUrl = `${baseUrl}/${accessPath.startsWith('/') ? accessPath.substring(1) : accessPath}`;
|
|
63
80
|
return {
|
|
64
81
|
uploadUrl: signedUrl,
|
|
65
|
-
accessUrl:
|
|
82
|
+
accessUrl: finalAccessUrl
|
|
66
83
|
};
|
|
67
84
|
},
|
|
68
85
|
async requestUploadParts () {
|
|
@@ -75,6 +92,9 @@ function AWSProvider(options) {
|
|
|
75
92
|
throw new Error('Not implemented');
|
|
76
93
|
},
|
|
77
94
|
async deleteFile ({ url }) {
|
|
95
|
+
if (!bucketName) {
|
|
96
|
+
throw new Error('S3 bucketName is not configured in AWSProviderOptions for deleteFile.');
|
|
97
|
+
}
|
|
78
98
|
const path = url.replace(`${baseUrl}/`, '');
|
|
79
99
|
await s3Client.send(new clientS3.DeleteObjectCommand({
|
|
80
100
|
Bucket: bucketName,
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { S3Client, HeadObjectCommand, PutObjectCommand, DeleteObjectCommand } from '@aws-sdk/client-s3';
|
|
2
2
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
3
3
|
import { v4 } from 'uuid';
|
|
4
|
+
import { g as getEnv } from '../../shared-4b199b96.mjs';
|
|
5
|
+
import '@edgestore/shared';
|
|
6
|
+
import '@panva/hkdf';
|
|
7
|
+
import 'cookie';
|
|
8
|
+
import 'jose';
|
|
4
9
|
|
|
5
10
|
function AWSProvider(options) {
|
|
6
|
-
const { accessKeyId =
|
|
7
|
-
const baseUrl = options?.baseUrl ??
|
|
11
|
+
const { accessKeyId = getEnv('ES_AWS_ACCESS_KEY_ID'), secretAccessKey = getEnv('ES_AWS_SECRET_ACCESS_KEY'), region = getEnv('ES_AWS_REGION'), bucketName = getEnv('ES_AWS_BUCKET_NAME'), endpoint = getEnv('ES_AWS_ENDPOINT'), forcePathStyle = getEnv('ES_AWS_FORCE_PATH_STYLE') === 'true', overwritePath } = options ?? {};
|
|
12
|
+
const baseUrl = options?.baseUrl ?? getEnv('EDGE_STORE_BASE_URL') ?? (endpoint ? `${endpoint}/${bucketName}` : `https://${bucketName}.s3.${region}.amazonaws.com`);
|
|
8
13
|
const credentials = accessKeyId && secretAccessKey ? {
|
|
9
14
|
accessKeyId,
|
|
10
15
|
secretAccessKey
|
|
@@ -39,15 +44,27 @@ function AWSProvider(options) {
|
|
|
39
44
|
uploadedAt: LastModified
|
|
40
45
|
};
|
|
41
46
|
},
|
|
42
|
-
async requestUpload (
|
|
47
|
+
async requestUpload (params) {
|
|
48
|
+
const { bucketName: esBucketName, fileInfo } = params;
|
|
49
|
+
if (!bucketName) {
|
|
50
|
+
throw new Error('S3 bucketName is not configured in AWSProviderOptions.');
|
|
51
|
+
}
|
|
52
|
+
// Default S3 key (accessPath) construction logic
|
|
43
53
|
const pathPrefix = `${esBucketName}${fileInfo.isPublic ? '/_public' : ''}`;
|
|
44
54
|
const nameId = v4();
|
|
45
55
|
const extension = fileInfo.extension ? `.${fileInfo.extension.replace('.', '')}` : '';
|
|
46
|
-
const
|
|
47
|
-
const
|
|
56
|
+
const defaultResolvedFileName = fileInfo.fileName ?? `${nameId}${extension}`;
|
|
57
|
+
const defaultFilePathFromMetadata = fileInfo.path.reduce((acc, item)=>{
|
|
48
58
|
return `${acc}/${item.value}`;
|
|
49
59
|
}, '');
|
|
50
|
-
|
|
60
|
+
let accessPath = `${pathPrefix}${defaultFilePathFromMetadata}/${defaultResolvedFileName}`;
|
|
61
|
+
if (overwritePath) {
|
|
62
|
+
accessPath = await overwritePath({
|
|
63
|
+
esBucketName,
|
|
64
|
+
fileInfo,
|
|
65
|
+
defaultAccessPath: accessPath
|
|
66
|
+
});
|
|
67
|
+
}
|
|
51
68
|
const command = new PutObjectCommand({
|
|
52
69
|
Bucket: bucketName,
|
|
53
70
|
Key: accessPath
|
|
@@ -55,10 +72,10 @@ function AWSProvider(options) {
|
|
|
55
72
|
const signedUrl = await getSignedUrl(s3Client, command, {
|
|
56
73
|
expiresIn: 60 * 60
|
|
57
74
|
});
|
|
58
|
-
const
|
|
75
|
+
const finalAccessUrl = `${baseUrl}/${accessPath.startsWith('/') ? accessPath.substring(1) : accessPath}`;
|
|
59
76
|
return {
|
|
60
77
|
uploadUrl: signedUrl,
|
|
61
|
-
accessUrl:
|
|
78
|
+
accessUrl: finalAccessUrl
|
|
62
79
|
};
|
|
63
80
|
},
|
|
64
81
|
async requestUploadParts () {
|
|
@@ -71,6 +88,9 @@ function AWSProvider(options) {
|
|
|
71
88
|
throw new Error('Not implemented');
|
|
72
89
|
},
|
|
73
90
|
async deleteFile ({ url }) {
|
|
91
|
+
if (!bucketName) {
|
|
92
|
+
throw new Error('S3 bucketName is not configured in AWSProviderOptions for deleteFile.');
|
|
93
|
+
}
|
|
74
94
|
const path = url.replace(`${baseUrl}/`, '');
|
|
75
95
|
await s3Client.send(new DeleteObjectCommand({
|
|
76
96
|
Bucket: bucketName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/azure/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/azure/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIlD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,QAAQ,CAoEtE"}
|
|
@@ -4,9 +4,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var storageBlob = require('@azure/storage-blob');
|
|
6
6
|
var uuid = require('uuid');
|
|
7
|
+
var shared = require('../../shared-685c8a0c.js');
|
|
8
|
+
require('@edgestore/shared');
|
|
9
|
+
require('@panva/hkdf');
|
|
10
|
+
require('cookie');
|
|
11
|
+
require('jose');
|
|
7
12
|
|
|
8
13
|
function AzureProvider(options) {
|
|
9
|
-
const { storageAccountName =
|
|
14
|
+
const { storageAccountName = shared.getEnv('ES_AZURE_ACCOUNT_NAME'), sasToken = shared.getEnv('ES_AZURE_SAS_TOKEN'), containerName = shared.getEnv('ES_AZURE_CONTAINER_NAME'), customBaseUrl = shared.getEnv('ES_AZURE_BASE_URL') } = options ?? {};
|
|
10
15
|
const baseUrl = customBaseUrl ?? `https://${storageAccountName}.blob.core.windows.net`;
|
|
11
16
|
const blobServiceClient = new storageBlob.BlobServiceClient(`${baseUrl}?${sasToken}`);
|
|
12
17
|
const containerClient = blobServiceClient.getContainerClient(containerName ?? '');
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { BlobServiceClient } from '@azure/storage-blob';
|
|
2
2
|
import { v4 } from 'uuid';
|
|
3
|
+
import { g as getEnv } from '../../shared-4b199b96.mjs';
|
|
4
|
+
import '@edgestore/shared';
|
|
5
|
+
import '@panva/hkdf';
|
|
6
|
+
import 'cookie';
|
|
7
|
+
import 'jose';
|
|
3
8
|
|
|
4
9
|
function AzureProvider(options) {
|
|
5
|
-
const { storageAccountName =
|
|
10
|
+
const { storageAccountName = getEnv('ES_AZURE_ACCOUNT_NAME'), sasToken = getEnv('ES_AZURE_SAS_TOKEN'), containerName = getEnv('ES_AZURE_CONTAINER_NAME'), customBaseUrl = getEnv('ES_AZURE_BASE_URL') } = options ?? {};
|
|
6
11
|
const baseUrl = customBaseUrl ?? `https://${storageAccountName}.blob.core.windows.net`;
|
|
7
12
|
const blobServiceClient = new BlobServiceClient(`${baseUrl}?${sasToken}`);
|
|
8
13
|
const containerClient = blobServiceClient.getContainerClient(containerName ?? '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/edgestore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/edgestore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,mBAAmB,CAAC;AAO3B,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,wBAAwB,GACjC,QAAQ,CAoJV"}
|
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var shared = require('@edgestore/shared');
|
|
6
|
-
var
|
|
5
|
+
var shared$1 = require('@edgestore/shared');
|
|
6
|
+
var shared = require('../../shared-685c8a0c.js');
|
|
7
|
+
var index = require('../../index-7b259533.js');
|
|
8
|
+
require('@panva/hkdf');
|
|
9
|
+
require('cookie');
|
|
10
|
+
require('jose');
|
|
11
|
+
require('uuid');
|
|
7
12
|
|
|
8
13
|
const DEFAULT_BASE_URL = 'https://files.edgestore.dev';
|
|
9
14
|
function EdgeStoreProvider(options) {
|
|
10
|
-
const { accessKey =
|
|
11
|
-
|
|
15
|
+
const { accessKey = shared.getEnv('EDGE_STORE_ACCESS_KEY') ?? // @ts-expect-error - In Vite/Astro, the env variables are available on `import.meta`.
|
|
16
|
+
undefined?.EDGE_STORE_ACCESS_KEY, secretKey = shared.getEnv('EDGE_STORE_SECRET_KEY') ?? // @ts-expect-error - In Vite/Astro, the env variables are available on `import.meta`.
|
|
17
|
+
undefined?.EDGE_STORE_SECRET_KEY } = options ?? {};
|
|
18
|
+
const baseUrl = shared.getEnv('EDGE_STORE_BASE_URL') ?? DEFAULT_BASE_URL;
|
|
12
19
|
if (!accessKey || !secretKey) {
|
|
13
20
|
throw new index.EdgeStoreCredentialsError();
|
|
14
21
|
}
|
|
@@ -82,7 +89,7 @@ function EdgeStoreProvider(options) {
|
|
|
82
89
|
thumbnailUrl: res.thumbnailUrl
|
|
83
90
|
};
|
|
84
91
|
} else {
|
|
85
|
-
throw new shared.EdgeStoreError({
|
|
92
|
+
throw new shared$1.EdgeStoreError({
|
|
86
93
|
message: 'Could not get upload url',
|
|
87
94
|
code: 'SERVER_ERROR'
|
|
88
95
|
});
|
|
@@ -100,7 +107,7 @@ function EdgeStoreProvider(options) {
|
|
|
100
107
|
thumbnailUrl: res.thumbnailUrl
|
|
101
108
|
};
|
|
102
109
|
}
|
|
103
|
-
throw new shared.EdgeStoreError({
|
|
110
|
+
throw new shared$1.EdgeStoreError({
|
|
104
111
|
message: 'Could not get upload url',
|
|
105
112
|
code: 'SERVER_ERROR'
|
|
106
113
|
});
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { EdgeStoreError } from '@edgestore/shared';
|
|
2
|
-
import {
|
|
2
|
+
import { g as getEnv } from '../../shared-4b199b96.mjs';
|
|
3
|
+
import { E as EdgeStoreCredentialsError, i as initEdgeStoreSdk } from '../../index-2848cb40.mjs';
|
|
4
|
+
import '@panva/hkdf';
|
|
5
|
+
import 'cookie';
|
|
6
|
+
import 'jose';
|
|
7
|
+
import 'uuid';
|
|
3
8
|
|
|
4
9
|
const DEFAULT_BASE_URL = 'https://files.edgestore.dev';
|
|
5
10
|
function EdgeStoreProvider(options) {
|
|
6
|
-
const { accessKey =
|
|
7
|
-
|
|
11
|
+
const { accessKey = getEnv('EDGE_STORE_ACCESS_KEY') ?? // @ts-expect-error - In Vite/Astro, the env variables are available on `import.meta`.
|
|
12
|
+
import.meta.env?.EDGE_STORE_ACCESS_KEY, secretKey = getEnv('EDGE_STORE_SECRET_KEY') ?? // @ts-expect-error - In Vite/Astro, the env variables are available on `import.meta`.
|
|
13
|
+
import.meta.env?.EDGE_STORE_SECRET_KEY } = options ?? {};
|
|
14
|
+
const baseUrl = getEnv('EDGE_STORE_BASE_URL') ?? DEFAULT_BASE_URL;
|
|
8
15
|
if (!accessKey || !secretKey) {
|
|
9
16
|
throw new EdgeStoreCredentialsError();
|
|
10
17
|
}
|
|
@@ -290,7 +290,7 @@ async function deleteFile(params) {
|
|
|
290
290
|
return res;
|
|
291
291
|
}
|
|
292
292
|
async function encryptJWT(ctx) {
|
|
293
|
-
const secret =
|
|
293
|
+
const secret = getEnv('EDGE_STORE_JWT_SECRET') ?? getEnv('EDGE_STORE_SECRET_KEY');
|
|
294
294
|
if (!secret) {
|
|
295
295
|
throw new EdgeStoreError({
|
|
296
296
|
message: 'EDGE_STORE_JWT_SECRET or EDGE_STORE_SECRET_KEY is not defined',
|
|
@@ -306,7 +306,7 @@ async function encryptJWT(ctx) {
|
|
|
306
306
|
.encrypt(encryptionSecret);
|
|
307
307
|
}
|
|
308
308
|
async function decryptJWT(token) {
|
|
309
|
-
const secret =
|
|
309
|
+
const secret = getEnv('EDGE_STORE_JWT_SECRET') ?? getEnv('EDGE_STORE_SECRET_KEY');
|
|
310
310
|
if (!secret) {
|
|
311
311
|
throw new EdgeStoreError({
|
|
312
312
|
message: 'EDGE_STORE_JWT_SECRET or EDGE_STORE_SECRET_KEY is not defined',
|
|
@@ -375,7 +375,7 @@ async function getContext(token) {
|
|
|
375
375
|
* so that we can delete or confirm the upload.
|
|
376
376
|
*/
|
|
377
377
|
function unproxyUrl(url) {
|
|
378
|
-
if (
|
|
378
|
+
if (isDev() && url.startsWith('http://')) {
|
|
379
379
|
// get the url param from the query string
|
|
380
380
|
const urlParam = new URL(url).searchParams.get('url');
|
|
381
381
|
if (urlParam) {
|
|
@@ -384,5 +384,18 @@ function unproxyUrl(url) {
|
|
|
384
384
|
}
|
|
385
385
|
return url;
|
|
386
386
|
}
|
|
387
|
+
function getEnv(key) {
|
|
388
|
+
if (typeof process !== 'undefined' && process.env) {
|
|
389
|
+
// @ts-expect-error - In Vite/Astro, the env variables are available on `import.meta`.
|
|
390
|
+
return process.env[key] ?? import.meta.env?.[key];
|
|
391
|
+
}
|
|
392
|
+
// @ts-expect-error - In Vite/Astro, the env variables are available on `import.meta`.
|
|
393
|
+
return import.meta.env?.[key];
|
|
394
|
+
}
|
|
395
|
+
function isDev() {
|
|
396
|
+
return (process?.env?.NODE_ENV === 'development' ||
|
|
397
|
+
// @ts-expect-error - In Vite/Astro, the env variables are available on `import.meta`.
|
|
398
|
+
import.meta.env?.DEV);
|
|
399
|
+
}
|
|
387
400
|
|
|
388
|
-
export {
|
|
401
|
+
export { init as a, buildPath as b, requestUploadParts as c, completeMultipartUpload as d, confirmUpload as e, deleteFile as f, getEnv as g, isDev as i, parsePath as p, requestUpload as r };
|
|
@@ -319,7 +319,7 @@ async function deleteFile(params) {
|
|
|
319
319
|
return res;
|
|
320
320
|
}
|
|
321
321
|
async function encryptJWT(ctx) {
|
|
322
|
-
const secret =
|
|
322
|
+
const secret = getEnv('EDGE_STORE_JWT_SECRET') ?? getEnv('EDGE_STORE_SECRET_KEY');
|
|
323
323
|
if (!secret) {
|
|
324
324
|
throw new EdgeStoreError({
|
|
325
325
|
message: 'EDGE_STORE_JWT_SECRET or EDGE_STORE_SECRET_KEY is not defined',
|
|
@@ -333,7 +333,7 @@ async function encryptJWT(ctx) {
|
|
|
333
333
|
}).setIssuedAt().setExpirationTime(Date.now() / 1000 + DEFAULT_MAX_AGE).setJti(v4()).encrypt(encryptionSecret);
|
|
334
334
|
}
|
|
335
335
|
async function decryptJWT(token) {
|
|
336
|
-
const secret =
|
|
336
|
+
const secret = getEnv('EDGE_STORE_JWT_SECRET') ?? getEnv('EDGE_STORE_SECRET_KEY');
|
|
337
337
|
if (!secret) {
|
|
338
338
|
throw new EdgeStoreError({
|
|
339
339
|
message: 'EDGE_STORE_JWT_SECRET or EDGE_STORE_SECRET_KEY is not defined',
|
|
@@ -399,7 +399,7 @@ async function getContext(token) {
|
|
|
399
399
|
* This function is used to get the original URL,
|
|
400
400
|
* so that we can delete or confirm the upload.
|
|
401
401
|
*/ function unproxyUrl(url) {
|
|
402
|
-
if (
|
|
402
|
+
if (isDev() && url.startsWith('http://')) {
|
|
403
403
|
// get the url param from the query string
|
|
404
404
|
const urlParam = new URL(url).searchParams.get('url');
|
|
405
405
|
if (urlParam) {
|
|
@@ -408,5 +408,17 @@ async function getContext(token) {
|
|
|
408
408
|
}
|
|
409
409
|
return url;
|
|
410
410
|
}
|
|
411
|
+
function getEnv(key) {
|
|
412
|
+
if (typeof process !== 'undefined' && process.env) {
|
|
413
|
+
// @ts-expect-error - In Vite/Astro, the env variables are available on `import.meta`.
|
|
414
|
+
return process.env[key] ?? import.meta.env?.[key];
|
|
415
|
+
}
|
|
416
|
+
// @ts-expect-error - In Vite/Astro, the env variables are available on `import.meta`.
|
|
417
|
+
return import.meta.env?.[key];
|
|
418
|
+
}
|
|
419
|
+
function isDev() {
|
|
420
|
+
return process?.env?.NODE_ENV === 'development' || // @ts-expect-error - In Vite/Astro, the env variables are available on `import.meta`.
|
|
421
|
+
import.meta.env?.DEV;
|
|
422
|
+
}
|
|
411
423
|
|
|
412
|
-
export {
|
|
424
|
+
export { init as a, buildPath as b, requestUploadParts as c, completeMultipartUpload as d, confirmUpload as e, deleteFile as f, getEnv as g, isDev as i, parsePath as p, requestUpload as r };
|