ag-common 0.0.27 → 0.0.28

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.
@@ -2,5 +2,6 @@ export * from './api';
2
2
  export * from './dynamo';
3
3
  export * from './dynamoInfra';
4
4
  export * from './openApiHelpers';
5
+ export * from './s3';
5
6
  export * from './validateOpenApi';
6
7
  export * from './validations';
@@ -14,5 +14,6 @@ __exportStar(require("./api"), exports);
14
14
  __exportStar(require("./dynamo"), exports);
15
15
  __exportStar(require("./dynamoInfra"), exports);
16
16
  __exportStar(require("./openApiHelpers"), exports);
17
+ __exportStar(require("./s3"), exports);
17
18
  __exportStar(require("./validateOpenApi"), exports);
18
19
  __exportStar(require("./validations"), exports);
@@ -0,0 +1,14 @@
1
+ import { Blob } from 'aws-sdk/lib/dynamodb/document_client';
2
+ import AWS from 'aws-sdk';
3
+ export declare const getS3Object: ({ fileurl, }: {
4
+ fileurl: {
5
+ Bucket: string;
6
+ Key: string;
7
+ };
8
+ }) => Promise<import("aws-sdk/lib/request").PromiseResult<AWS.S3.GetObjectOutput, AWS.AWSError>>;
9
+ export declare const putS3Object: ({ Body, Bucket, Key, ContentType, }: {
10
+ ContentType?: string | undefined;
11
+ Body: string | Blob;
12
+ Bucket: string;
13
+ Key: string;
14
+ }) => Promise<void>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.putS3Object = exports.getS3Object = void 0;
16
+ const aws_sdk_1 = __importDefault(require("aws-sdk"));
17
+ const s3 = new aws_sdk_1.default.S3();
18
+ const getS3Object = ({ fileurl, }) => __awaiter(void 0, void 0, void 0, function* () {
19
+ const content = yield s3.getObject(fileurl).promise();
20
+ return content;
21
+ });
22
+ exports.getS3Object = getS3Object;
23
+ const putS3Object = ({ Body, Bucket, Key, ContentType, }) => __awaiter(void 0, void 0, void 0, function* () {
24
+ yield s3
25
+ .putObject({
26
+ Body,
27
+ Bucket,
28
+ Key,
29
+ ContentType,
30
+ })
31
+ .promise();
32
+ });
33
+ exports.putS3Object = putS3Object;
@@ -0,0 +1 @@
1
+ export declare function runGenerator<T>(iter: AsyncGenerator<T[], T[], unknown>, partialRun: (value: T[]) => Promise<void>): Promise<void>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.runGenerator = void 0;
13
+ /* eslint-disable no-await-in-loop */
14
+ function runGenerator(iter, partialRun) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ let curr;
17
+ do {
18
+ curr = yield iter.next();
19
+ if (!(curr === null || curr === void 0 ? void 0 : curr.value) || curr.value.length === 0) {
20
+ return;
21
+ }
22
+ yield partialRun(curr.value);
23
+ } while (!curr.done);
24
+ });
25
+ }
26
+ exports.runGenerator = runGenerator;
@@ -3,6 +3,7 @@ export * from './async';
3
3
  export * from './date';
4
4
  export * from './distinctBy';
5
5
  export * from './email';
6
+ export * from './generator';
6
7
  export * from './groupBy';
7
8
  export * from './hashCode';
8
9
  export * from './i18n';
@@ -15,6 +15,7 @@ __exportStar(require("./async"), exports);
15
15
  __exportStar(require("./date"), exports);
16
16
  __exportStar(require("./distinctBy"), exports);
17
17
  __exportStar(require("./email"), exports);
18
+ __exportStar(require("./generator"), exports);
18
19
  __exportStar(require("./groupBy"), exports);
19
20
  __exportStar(require("./hashCode"), exports);
20
21
  __exportStar(require("./i18n"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",