@pi-r/aws 0.3.5 → 0.3.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 +6 -6
- package/README.md +4 -6
- package/client/index.d.ts +37 -37
- package/client/index.js +45 -39
- package/download/index.js +1 -1
- package/package.json +29 -29
- package/types/index.d.ts +23 -23
- package/upload/index.js +1 -1
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Copyright
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
1
|
+
Copyright 2023 An Pham
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
7
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
package/client/index.d.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import type { ICloud, IModule } from '@e-mc/types/lib';
|
|
2
|
-
import type { BucketWebsiteOptions, CloudDatabase } from '@e-mc/types/lib/cloud';
|
|
3
|
-
import type { BatchQueryResult, QueryResult } from '@e-mc/types/lib/db';
|
|
4
|
-
|
|
5
|
-
import type { AWSDatabaseCredential, AWSDatabaseQuery, AWSStorageCredential, BucketCannedACL, ConfigureBucketOptions } from '../types';
|
|
6
|
-
|
|
7
|
-
import type { ConfigurationOptions } from 'aws-sdk/lib/core';
|
|
8
|
-
import type { ServiceConfigurationOptions } from 'aws-sdk/lib/service';
|
|
9
|
-
import type { DocumentClient } from 'aws-sdk/clients/dynamodb';
|
|
10
|
-
import type { DynamoDBClientConfig } from '@aws-sdk/client-dynamodb';
|
|
11
|
-
import type { CreateBucketRequest } from 'aws-sdk/clients/s3';
|
|
12
|
-
|
|
13
|
-
declare namespace AWS {
|
|
14
|
-
function isAccessDefined(credential: Pick<ConfigurationOptions, "accessKeyId" | "secretAccessKey" | "sessionToken">): boolean;
|
|
15
|
-
function isEnvDefined(): boolean;
|
|
16
|
-
function isDatabaseDefined(credential: AWSDatabaseCredential, data: CloudDatabase): boolean;
|
|
17
|
-
function getPublicReadPolicy(bucket: string, authenticated?: boolean, write?: boolean): string;
|
|
18
|
-
function getBucketPublicReadPolicy(bucket: string): string;
|
|
19
|
-
function getPrivatePolicy(bucket: string): string;
|
|
20
|
-
function validateStorage(credential: AWSStorageCredential): boolean;
|
|
21
|
-
function validateDatabase(credential: AWSDatabaseCredential, data: CloudDatabase): boolean;
|
|
22
|
-
function createStorageClient(this: IModule, credential: AWSStorageCredential, service?: string, sdk?: string): boolean;
|
|
23
|
-
function createDatabaseClient(this: IModule, credential: AWSDatabaseCredential): DocumentClient;
|
|
24
|
-
function createBucket(this: IModule, credential: AWSStorageCredential, Bucket: string, publicRead?: boolean, service?: string, sdk?: string): Promise<boolean>;
|
|
25
|
-
function createBucketV2(this: IModule, credential: AWSStorageCredential, Bucket: string, ACL?: BucketCannedACL | 1, options?: CreateBucketRequest, service?: string, sdk?: string): Promise<boolean>;
|
|
26
|
-
function setBucketPolicy(this: IModule, credential: AWSStorageCredential, Bucket: string, options: ConfigureBucketOptions, service?: string, sdk?: string): Promise<boolean>;
|
|
27
|
-
function setBucketWebsite(this: IModule, credential: AWSStorageCredential, Bucket: string, options: BucketWebsiteOptions, service?: string, sdk?: string): Promise<boolean>;
|
|
28
|
-
function deleteObjects(this: IModule, credential: AWSStorageCredential, Bucket: string, service?: string, sdk?: string): Promise<void>;
|
|
29
|
-
function deleteObjectsV2(this: IModule, credential: AWSStorageCredential, Bucket: string, recursive?: boolean, service?: string, sdk?: string): Promise<void>;
|
|
30
|
-
function executeQuery(this: ICloud, credential: AWSDatabaseCredential, data: AWSDatabaseQuery, sessionKey?: string): Promise<QueryResult>;
|
|
31
|
-
function executeBatchQuery(this: ICloud, credential: AWSDatabaseCredential, batch: AWSDatabaseQuery[], sessionKey?: string): Promise<BatchQueryResult>;
|
|
32
|
-
function setDatabaseEndpoint(config: ServiceConfigurationOptions | DynamoDBClientConfig): void;
|
|
33
|
-
function checkBucketCannedACL(value: unknown): BucketCannedACL | undefined;
|
|
34
|
-
function getBucketKey(credential: unknown, Bucket: string, acl: string | undefined, service: string, sdk: string): string;
|
|
35
|
-
function isNoSuchBucket(err: unknown): boolean;
|
|
36
|
-
}
|
|
37
|
-
|
|
1
|
+
import type { ICloud, IModule } from '@e-mc/types/lib';
|
|
2
|
+
import type { BucketWebsiteOptions, CloudDatabase } from '@e-mc/types/lib/cloud';
|
|
3
|
+
import type { BatchQueryResult, QueryResult } from '@e-mc/types/lib/db';
|
|
4
|
+
|
|
5
|
+
import type { AWSDatabaseCredential, AWSDatabaseQuery, AWSStorageCredential, BucketCannedACL, ConfigureBucketOptions } from '../types';
|
|
6
|
+
|
|
7
|
+
import type { ConfigurationOptions } from 'aws-sdk/lib/core';
|
|
8
|
+
import type { ServiceConfigurationOptions } from 'aws-sdk/lib/service';
|
|
9
|
+
import type { DocumentClient } from 'aws-sdk/clients/dynamodb';
|
|
10
|
+
import type { DynamoDBClientConfig } from '@aws-sdk/client-dynamodb';
|
|
11
|
+
import type { CreateBucketRequest } from 'aws-sdk/clients/s3';
|
|
12
|
+
|
|
13
|
+
declare namespace AWS {
|
|
14
|
+
function isAccessDefined(credential: Pick<ConfigurationOptions, "accessKeyId" | "secretAccessKey" | "sessionToken">): boolean;
|
|
15
|
+
function isEnvDefined(): boolean;
|
|
16
|
+
function isDatabaseDefined(credential: AWSDatabaseCredential, data: CloudDatabase): boolean;
|
|
17
|
+
function getPublicReadPolicy(bucket: string, authenticated?: boolean, write?: boolean): string;
|
|
18
|
+
function getBucketPublicReadPolicy(bucket: string): string;
|
|
19
|
+
function getPrivatePolicy(bucket: string): string;
|
|
20
|
+
function validateStorage(credential: AWSStorageCredential): boolean;
|
|
21
|
+
function validateDatabase(credential: AWSDatabaseCredential, data: CloudDatabase): boolean;
|
|
22
|
+
function createStorageClient(this: IModule, credential: AWSStorageCredential, service?: string, sdk?: string): boolean;
|
|
23
|
+
function createDatabaseClient(this: IModule, credential: AWSDatabaseCredential): DocumentClient;
|
|
24
|
+
function createBucket(this: IModule, credential: AWSStorageCredential, Bucket: string, publicRead?: boolean, service?: string, sdk?: string): Promise<boolean>;
|
|
25
|
+
function createBucketV2(this: IModule, credential: AWSStorageCredential, Bucket: string, ACL?: BucketCannedACL | 1, options?: CreateBucketRequest, service?: string, sdk?: string): Promise<boolean>;
|
|
26
|
+
function setBucketPolicy(this: IModule, credential: AWSStorageCredential, Bucket: string, options: ConfigureBucketOptions, service?: string, sdk?: string): Promise<boolean>;
|
|
27
|
+
function setBucketWebsite(this: IModule, credential: AWSStorageCredential, Bucket: string, options: BucketWebsiteOptions, service?: string, sdk?: string): Promise<boolean>;
|
|
28
|
+
function deleteObjects(this: IModule, credential: AWSStorageCredential, Bucket: string, service?: string, sdk?: string): Promise<void>;
|
|
29
|
+
function deleteObjectsV2(this: IModule, credential: AWSStorageCredential, Bucket: string, recursive?: boolean, service?: string, sdk?: string): Promise<void>;
|
|
30
|
+
function executeQuery(this: ICloud, credential: AWSDatabaseCredential, data: AWSDatabaseQuery, sessionKey?: string): Promise<QueryResult>;
|
|
31
|
+
function executeBatchQuery(this: ICloud, credential: AWSDatabaseCredential, batch: AWSDatabaseQuery[], sessionKey?: string): Promise<BatchQueryResult>;
|
|
32
|
+
function setDatabaseEndpoint(config: ServiceConfigurationOptions | DynamoDBClientConfig): void;
|
|
33
|
+
function checkBucketCannedACL(value: unknown): BucketCannedACL | undefined;
|
|
34
|
+
function getBucketKey(credential: unknown, Bucket: string, acl: string | undefined, service: string, sdk: string): string;
|
|
35
|
+
function isNoSuchBucket(err: unknown): boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
38
|
export = AWS;
|
package/client/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isNoSuchBucket = exports.getBucketKey = exports.checkBucketCannedACL = exports.setDatabaseEndpoint = exports.executeBatchQuery = exports.executeQuery = exports.deleteObjectsV2 = exports.deleteObjects = exports.setBucketWebsite = exports.setBucketPolicy = exports.createBucketV2 = exports.createBucket = exports.createDatabaseClient = exports.createStorageClient = exports.validateDatabase = exports.validateStorage = exports.getPrivatePolicy = exports.getBucketPublicReadPolicy = exports.getPublicReadPolicy = exports.isDatabaseDefined = exports.isEnvDefined = exports.isAccessDefined = void 0;
|
|
4
|
-
const aws = require("aws-sdk");
|
|
5
4
|
const types_1 = require("@e-mc/types");
|
|
6
5
|
const util_1 = require("@e-mc/cloud/util");
|
|
7
6
|
const Module = require("@e-mc/module");
|
|
@@ -124,18 +123,20 @@ exports.validateDatabase = validateDatabase;
|
|
|
124
123
|
function createStorageClient(credential, service = 'aws', sdk = 'aws-sdk/clients/s3') {
|
|
125
124
|
try {
|
|
126
125
|
if (service === 'aws') {
|
|
127
|
-
const
|
|
128
|
-
if (fromPath) {
|
|
129
|
-
const client = new
|
|
130
|
-
client.config.loadFromPath(fromPath);
|
|
126
|
+
const S3 = require('aws-sdk/clients/s3');
|
|
127
|
+
if (credential.fromPath) {
|
|
128
|
+
const client = new S3();
|
|
129
|
+
client.config.loadFromPath(credential.fromPath);
|
|
131
130
|
return client;
|
|
132
131
|
}
|
|
133
|
-
if (profile || process.env.AWS_SDK_LOAD_CONFIG === '1' && !isAccessDefined(credential) && !isEnvDefined()) {
|
|
134
|
-
|
|
132
|
+
if (credential.profile || process.env.AWS_SDK_LOAD_CONFIG === '1' && !isAccessDefined(credential) && !isEnvDefined()) {
|
|
133
|
+
const { SharedIniFileCredentials } = require('aws-sdk');
|
|
134
|
+
credential = new SharedIniFileCredentials({ profile: credential.profile });
|
|
135
135
|
}
|
|
136
|
-
return new
|
|
136
|
+
return new S3(credential);
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
const S3 = require(sdk);
|
|
139
|
+
return new S3(credential);
|
|
139
140
|
}
|
|
140
141
|
catch (err) {
|
|
141
142
|
this.checkPackage(err, sdk.split('/')[0], { passThrough: true });
|
|
@@ -144,18 +145,26 @@ function createStorageClient(credential, service = 'aws', sdk = 'aws-sdk/clients
|
|
|
144
145
|
}
|
|
145
146
|
exports.createStorageClient = createStorageClient;
|
|
146
147
|
function createDatabaseClient(credential) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
try {
|
|
149
|
+
let options;
|
|
150
|
+
if (credential.fromPath) {
|
|
151
|
+
const AWS = require('aws-sdk');
|
|
152
|
+
AWS.config.loadFromPath(credential.fromPath);
|
|
153
|
+
}
|
|
154
|
+
else if (credential.profile || process.env.AWS_SDK_LOAD_CONFIG === '1' && !isAccessDefined(credential) && !isEnvDefined()) {
|
|
155
|
+
const { SharedIniFileCredentials } = require('aws-sdk');
|
|
156
|
+
options = new SharedIniFileCredentials({ profile: credential.profile });
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
options = credential;
|
|
160
|
+
}
|
|
161
|
+
const DynamoDB = require('aws-sdk/clients/dynamodb');
|
|
162
|
+
return new DynamoDB.DocumentClient(options);
|
|
154
163
|
}
|
|
155
|
-
|
|
156
|
-
|
|
164
|
+
catch (err) {
|
|
165
|
+
this.checkPackage(err, 'aws-sdk', { passThrough: true });
|
|
166
|
+
throw err;
|
|
157
167
|
}
|
|
158
|
-
return new aws.DynamoDB.DocumentClient(options);
|
|
159
168
|
}
|
|
160
169
|
exports.createDatabaseClient = createDatabaseClient;
|
|
161
170
|
function createBucket(credential, Bucket, publicRead, service = 'aws', sdk = 'aws-sdk/clients/s3') {
|
|
@@ -175,8 +184,8 @@ function createBucketV2(credential, Bucket, ACL, options, service = 'aws', sdk =
|
|
|
175
184
|
.catch(() => {
|
|
176
185
|
const input = { ...options, Bucket };
|
|
177
186
|
const region = credential.region;
|
|
178
|
-
if (region && (region !== 'us-east-1' || service !== 'aws')) {
|
|
179
|
-
input.CreateBucketConfiguration
|
|
187
|
+
if (!input.CreateBucketConfiguration && typeof region === 'string' && (region !== 'us-east-1' || service !== 'aws')) {
|
|
188
|
+
input.CreateBucketConfiguration = { LocationConstraint: region };
|
|
180
189
|
}
|
|
181
190
|
return S3.createBucket(input).promise()
|
|
182
191
|
.then(async () => {
|
|
@@ -226,12 +235,11 @@ exports.setBucketPolicy = setBucketPolicy;
|
|
|
226
235
|
function setBucketWebsite(credential, Bucket, options, service = 'aws', sdk = 'aws-sdk/clients/s3') {
|
|
227
236
|
const S3 = createStorageClient.call(this, credential, service, sdk);
|
|
228
237
|
const WebsiteConfiguration = {};
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
WebsiteConfiguration.IndexDocument = { Suffix };
|
|
238
|
+
if ((0, types_1.isString)(options.indexPage)) {
|
|
239
|
+
WebsiteConfiguration.IndexDocument = { Suffix: options.indexPage };
|
|
232
240
|
}
|
|
233
|
-
if ((0, types_1.isString)(
|
|
234
|
-
WebsiteConfiguration.ErrorDocument = { Key };
|
|
241
|
+
if ((0, types_1.isString)(options.errorPage)) {
|
|
242
|
+
WebsiteConfiguration.ErrorDocument = { Key: options.errorPage };
|
|
235
243
|
}
|
|
236
244
|
return S3.putBucketWebsite({ Bucket, WebsiteConfiguration }).promise()
|
|
237
245
|
.then(() => {
|
|
@@ -261,9 +269,8 @@ async function deleteObjectsV2(credential, Bucket, recursive = true, service = '
|
|
|
261
269
|
}
|
|
262
270
|
return S3.deleteObjects({ Bucket, Delete: { Objects } }).promise()
|
|
263
271
|
.then(data => {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const files = Deleted.length + ' files';
|
|
272
|
+
if ((0, types_1.isArray)(data.Deleted)) {
|
|
273
|
+
const files = data.Deleted.length + ' files';
|
|
267
274
|
this.formatMessage(64, service, ["Bucket emptied" + ` (${recursive ? 'recursive' : files})`, Bucket], recursive ? files : '', { ...Cloud.LOG_CLOUD_COMMAND });
|
|
268
275
|
}
|
|
269
276
|
})
|
|
@@ -322,9 +329,9 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
322
329
|
if (update) {
|
|
323
330
|
await client.update({ ...command, ...update }).promise();
|
|
324
331
|
}
|
|
325
|
-
const
|
|
326
|
-
if (Item) {
|
|
327
|
-
rows = [Item];
|
|
332
|
+
const output = await client.get(command).promise();
|
|
333
|
+
if (output.Item) {
|
|
334
|
+
rows = [output.Item];
|
|
328
335
|
}
|
|
329
336
|
}
|
|
330
337
|
else if ((0, types_1.isPlainObject)(query)) {
|
|
@@ -336,9 +343,9 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
336
343
|
if (limit > 0) {
|
|
337
344
|
query.Limit = limit;
|
|
338
345
|
}
|
|
339
|
-
const
|
|
340
|
-
if (Count && Items) {
|
|
341
|
-
rows = Items;
|
|
346
|
+
const output = await createClient().query(query).promise();
|
|
347
|
+
if (output.Count && output.Items) {
|
|
348
|
+
rows = output.Items;
|
|
342
349
|
}
|
|
343
350
|
}
|
|
344
351
|
else {
|
|
@@ -351,10 +358,9 @@ async function executeBatchQuery(credential, batch, sessionKey) {
|
|
|
351
358
|
exports.executeBatchQuery = executeBatchQuery;
|
|
352
359
|
function setDatabaseEndpoint(config) {
|
|
353
360
|
var _a, _b;
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
region = (_b = (((_a = /dynamodb\.([^.]+)\./i.exec(config.endpoint)) === null || _a === void 0 ? void 0 : _a[1]) || process.env.AWS_DEFAULT_REGION)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
361
|
+
config.endpoint || (config.endpoint = `https://dynamodb.${(0, types_1.isString)(config.region) ? config.region : process.env.AWS_DEFAULT_REGION || 'us-east-1'}.amazonaws.com`);
|
|
362
|
+
if (!config.region && (0, types_1.isString)(config.endpoint)) {
|
|
363
|
+
const region = (_b = (((_a = /dynamodb\.([^.]+)\./i.exec(config.endpoint)) === null || _a === void 0 ? void 0 : _a[1]) || process.env.AWS_DEFAULT_REGION)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
358
364
|
if (region && region !== 'us-east-1') {
|
|
359
365
|
config.region = region;
|
|
360
366
|
}
|
package/download/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const client_1 = require("@pi-r/aws");
|
|
2
3
|
const types_1 = require("@e-mc/types");
|
|
3
4
|
const Module = require("@e-mc/module");
|
|
4
5
|
const Cloud = require("@e-mc/cloud");
|
|
5
|
-
const client_1 = require("@pi-r/aws");
|
|
6
6
|
function download(credential, service = 'aws', sdk = 'aws-sdk/clients/s3') {
|
|
7
7
|
const s3 = client_1.createStorageClient.call(this, credential, service, sdk);
|
|
8
8
|
return (data, callback) => {
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@pi-r/aws",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "AWS V2 cloud functions for E-mc.",
|
|
5
|
-
"main": "client/index.js",
|
|
6
|
-
"types": "client/index.d.ts",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/anpham6/pi-r.git",
|
|
13
|
-
"directory": "src/cloud/aws"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"squared",
|
|
17
|
-
"e-mc",
|
|
18
|
-
"squared-functions"
|
|
19
|
-
],
|
|
20
|
-
"author": "An Pham <anpham6@gmail.com>",
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@e-mc/cloud": "^0.6.
|
|
25
|
-
"@e-mc/module": "^0.6.
|
|
26
|
-
"@e-mc/types": "^0.6.
|
|
27
|
-
"aws-sdk": "^2.1659.0"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@pi-r/aws",
|
|
3
|
+
"version": "0.3.6",
|
|
4
|
+
"description": "AWS V2 cloud functions for E-mc.",
|
|
5
|
+
"main": "client/index.js",
|
|
6
|
+
"types": "client/index.d.ts",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/anpham6/pi-r.git",
|
|
13
|
+
"directory": "src/cloud/aws"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"squared",
|
|
17
|
+
"e-mc",
|
|
18
|
+
"squared-functions"
|
|
19
|
+
],
|
|
20
|
+
"author": "An Pham <anpham6@gmail.com>",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"homepage": "https://github.com/anpham6/pi-r#readme",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@e-mc/cloud": "^0.6.16",
|
|
25
|
+
"@e-mc/module": "^0.6.16",
|
|
26
|
+
"@e-mc/types": "^0.6.16",
|
|
27
|
+
"aws-sdk": "^2.1659.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
import type { CloudDatabase } from '@e-mc/types/lib/cloud';
|
|
3
|
-
|
|
4
|
-
import type { ConfigurationOptions } from 'aws-sdk/lib/core';
|
|
5
|
-
import type { ServiceConfigurationOptions } from 'aws-sdk/lib/service';
|
|
6
|
-
import type { Key, QueryInput, UpdateItemInput } from 'aws-sdk/clients/dynamodb';
|
|
7
|
-
import type { PutBucketAclRequest, PutBucketPolicyRequest, PutPublicAccessBlockRequest } from 'aws-sdk/clients/s3';
|
|
8
|
-
|
|
9
|
-
export type BucketCannedACL = "authenticated-read" | "private" | "public-read" | "public-read-write";
|
|
10
|
-
export type ObjectCannedACL = BucketCannedACL | "aws-exec-read" | "bucket-owner-full-control" | "bucket-owner-read";
|
|
11
|
-
export type ConfigureBucketOptions = PutBucketAclRequest | PutBucketPolicyRequest | PutPublicAccessBlockRequest;
|
|
12
|
-
|
|
13
|
-
export interface AWSStorageCredential extends ConfigurationOptions {
|
|
14
|
-
profile?: string;
|
|
15
|
-
fromPath?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface AWSDatabaseQuery extends CloudDatabase<QueryInput, PlainObject, UpdateItemInput> {
|
|
19
|
-
key?: string | Key;
|
|
20
|
-
partitionKey?: string | Key;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface AWSDatabaseCredential extends AWSStorageCredential, ServiceConfigurationOptions {}
|
|
1
|
+
|
|
2
|
+
import type { CloudDatabase } from '@e-mc/types/lib/cloud';
|
|
3
|
+
|
|
4
|
+
import type { ConfigurationOptions } from 'aws-sdk/lib/core';
|
|
5
|
+
import type { ServiceConfigurationOptions } from 'aws-sdk/lib/service';
|
|
6
|
+
import type { Key, QueryInput, UpdateItemInput } from 'aws-sdk/clients/dynamodb';
|
|
7
|
+
import type { PutBucketAclRequest, PutBucketPolicyRequest, PutPublicAccessBlockRequest } from 'aws-sdk/clients/s3';
|
|
8
|
+
|
|
9
|
+
export type BucketCannedACL = "authenticated-read" | "private" | "public-read" | "public-read-write";
|
|
10
|
+
export type ObjectCannedACL = BucketCannedACL | "aws-exec-read" | "bucket-owner-full-control" | "bucket-owner-read";
|
|
11
|
+
export type ConfigureBucketOptions = PutBucketAclRequest | PutBucketPolicyRequest | PutPublicAccessBlockRequest;
|
|
12
|
+
|
|
13
|
+
export interface AWSStorageCredential extends ConfigurationOptions {
|
|
14
|
+
profile?: string;
|
|
15
|
+
fromPath?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface AWSDatabaseQuery extends CloudDatabase<QueryInput, PlainObject, UpdateItemInput> {
|
|
19
|
+
key?: string | Key;
|
|
20
|
+
partitionKey?: string | Key;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AWSDatabaseCredential extends AWSStorageCredential, ServiceConfigurationOptions {}
|
package/upload/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const fs = require("fs");
|
|
4
|
+
const client_1 = require("@pi-r/aws");
|
|
4
5
|
const util_1 = require("@e-mc/cloud/util");
|
|
5
6
|
const types_1 = require("@e-mc/types");
|
|
6
7
|
const Module = require("@e-mc/module");
|
|
7
8
|
const Cloud = require("@e-mc/cloud");
|
|
8
|
-
const client_1 = require("@pi-r/aws");
|
|
9
9
|
const BUCKET_SESSION = new Set();
|
|
10
10
|
const BUCKET_RESPONSE = {};
|
|
11
11
|
function upload(credential, service = 'aws', sdk = 'aws-sdk/clients/s3') {
|