@aspan-corporation/ac-shared 1.0.4 → 1.0.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/lib/index.js +26 -7
- package/lib/services/dynamoDB.d.ts +1 -1
- package/lib/services/s3.d.ts +5 -3
- package/lib/services/sqs.d.ts +1 -1
- package/lib/services/ssm.d.ts +1 -1
- package/lib/services/sts.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -35600,6 +35600,7 @@ var require_dist_cjs61 = __commonJS({
|
|
|
35600
35600
|
// src/services/s3.ts
|
|
35601
35601
|
import {
|
|
35602
35602
|
GetObjectCommand,
|
|
35603
|
+
HeadObjectCommand,
|
|
35603
35604
|
ListObjectsV2Command,
|
|
35604
35605
|
S3Client
|
|
35605
35606
|
} from "@aws-sdk/client-s3";
|
|
@@ -35608,7 +35609,9 @@ import { PassThrough } from "node:stream";
|
|
|
35608
35609
|
|
|
35609
35610
|
// src/utils/logger.ts
|
|
35610
35611
|
import { Logger } from "@aws-lambda-powertools/logger";
|
|
35611
|
-
var rootLogger = new Logger(
|
|
35612
|
+
var rootLogger = new Logger({
|
|
35613
|
+
serviceName: process.env.POWERTOOLS_SERVICE_NAME ?? process.env.AWS_LAMBDA_FUNCTION_NAME ?? "ac-shared"
|
|
35614
|
+
});
|
|
35612
35615
|
var getLoggerWithScope = (scope, logger = rootLogger) => {
|
|
35613
35616
|
const childLogger = logger.createChild();
|
|
35614
35617
|
childLogger.appendKeys({ scope });
|
|
@@ -35623,7 +35626,7 @@ var S3Service = class {
|
|
|
35623
35626
|
logger,
|
|
35624
35627
|
client,
|
|
35625
35628
|
assumeRoleCommandOutput
|
|
35626
|
-
}) {
|
|
35629
|
+
} = {}) {
|
|
35627
35630
|
this.logger = getLoggerWithScope("ac-shared:s3", logger);
|
|
35628
35631
|
if (assumeRoleCommandOutput) {
|
|
35629
35632
|
this.client = new S3Client({
|
|
@@ -35642,7 +35645,7 @@ var S3Service = class {
|
|
|
35642
35645
|
});
|
|
35643
35646
|
}
|
|
35644
35647
|
}
|
|
35645
|
-
|
|
35648
|
+
createS3UploadStream(putObjectCommandInput) {
|
|
35646
35649
|
this.logger.debug("upload stream started");
|
|
35647
35650
|
const pass = new PassThrough();
|
|
35648
35651
|
const parallelUploads3 = new Upload({
|
|
@@ -35673,6 +35676,22 @@ var S3Service = class {
|
|
|
35673
35676
|
const stream = await this.createS3DownloadStream(getObjectCommandInput);
|
|
35674
35677
|
return Buffer.from(await stream.transformToByteArray());
|
|
35675
35678
|
}
|
|
35679
|
+
async headObject(headObjectCommandInput) {
|
|
35680
|
+
return await this.client.send(
|
|
35681
|
+
new HeadObjectCommand(headObjectCommandInput)
|
|
35682
|
+
);
|
|
35683
|
+
}
|
|
35684
|
+
async checkIfObjectExists(headObjectCommandInput) {
|
|
35685
|
+
try {
|
|
35686
|
+
await this.client.send(new HeadObjectCommand(headObjectCommandInput));
|
|
35687
|
+
return true;
|
|
35688
|
+
} catch (error) {
|
|
35689
|
+
if (error.name === "NotFound") {
|
|
35690
|
+
return false;
|
|
35691
|
+
}
|
|
35692
|
+
throw error;
|
|
35693
|
+
}
|
|
35694
|
+
}
|
|
35676
35695
|
};
|
|
35677
35696
|
|
|
35678
35697
|
// src/services/dynamoDB.ts
|
|
@@ -35692,7 +35711,7 @@ var DynamoDBService = class {
|
|
|
35692
35711
|
logger,
|
|
35693
35712
|
client,
|
|
35694
35713
|
assumeRoleCommandOutput
|
|
35695
|
-
}) {
|
|
35714
|
+
} = {}) {
|
|
35696
35715
|
this.logger = getLoggerWithScope("ac-shared:dynamodb", logger);
|
|
35697
35716
|
if (assumeRoleCommandOutput) {
|
|
35698
35717
|
this.client = new DynamoDBClient({
|
|
@@ -35741,7 +35760,7 @@ var SSMService = class {
|
|
|
35741
35760
|
logger,
|
|
35742
35761
|
client,
|
|
35743
35762
|
assumeRoleCommandOutput
|
|
35744
|
-
}) {
|
|
35763
|
+
} = {}) {
|
|
35745
35764
|
this.logger = getLoggerWithScope("ac-shared:ssm", logger);
|
|
35746
35765
|
if (assumeRoleCommandOutput) {
|
|
35747
35766
|
this.client = new import_client_ssm.SSMClient({
|
|
@@ -35777,7 +35796,7 @@ var SQSService = class {
|
|
|
35777
35796
|
logger,
|
|
35778
35797
|
client,
|
|
35779
35798
|
assumeRoleCommandOutput
|
|
35780
|
-
}) {
|
|
35799
|
+
} = {}) {
|
|
35781
35800
|
this.logger = getLoggerWithScope("ac-shared:sqs", logger);
|
|
35782
35801
|
if (assumeRoleCommandOutput) {
|
|
35783
35802
|
this.client = new import_client_sqs.SQSClient({
|
|
@@ -35815,7 +35834,7 @@ var import_client_sts = __toESM(require_dist_cjs61(), 1);
|
|
|
35815
35834
|
var STSService = class {
|
|
35816
35835
|
logger;
|
|
35817
35836
|
client;
|
|
35818
|
-
constructor({ logger }) {
|
|
35837
|
+
constructor({ logger } = {}) {
|
|
35819
35838
|
this.logger = getLoggerWithScope("ac-shared:sts", logger);
|
|
35820
35839
|
this.client = new import_client_sts.STSClient({
|
|
35821
35840
|
region: process.env.AWS_REGION,
|
|
@@ -6,7 +6,7 @@ export declare class DynamoDBService {
|
|
|
6
6
|
logger: Logger;
|
|
7
7
|
client: DynamoDBClient;
|
|
8
8
|
documentClient: DynamoDBDocumentClient;
|
|
9
|
-
constructor({ logger, client, assumeRoleCommandOutput }
|
|
9
|
+
constructor({ logger, client, assumeRoleCommandOutput }?: {
|
|
10
10
|
logger?: Logger;
|
|
11
11
|
client?: DynamoDBClient;
|
|
12
12
|
assumeRoleCommandOutput?: AssumeRoleCommandOutput;
|
package/lib/services/s3.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { Logger } from "@aws-lambda-powertools/logger";
|
|
4
|
-
import { GetObjectCommandInput, ListObjectsV2CommandInput, PutObjectCommandInput, S3Client } from "@aws-sdk/client-s3";
|
|
4
|
+
import { GetObjectCommandInput, HeadObjectCommandInput, ListObjectsV2CommandInput, PutObjectCommandInput, S3Client } from "@aws-sdk/client-s3";
|
|
5
5
|
import { AssumeRoleCommandOutput } from "@aws-sdk/client-sts";
|
|
6
6
|
import { PassThrough } from "node:stream";
|
|
7
7
|
export declare class S3Service {
|
|
8
8
|
logger: Logger;
|
|
9
9
|
client: S3Client;
|
|
10
|
-
constructor({ logger, client, assumeRoleCommandOutput }
|
|
10
|
+
constructor({ logger, client, assumeRoleCommandOutput }?: {
|
|
11
11
|
logger?: Logger;
|
|
12
12
|
client?: S3Client;
|
|
13
13
|
assumeRoleCommandOutput?: AssumeRoleCommandOutput;
|
|
14
14
|
});
|
|
15
|
-
createS3UploadStream(putObjectCommandInput: PutObjectCommandInput):
|
|
15
|
+
createS3UploadStream(putObjectCommandInput: PutObjectCommandInput): PassThrough;
|
|
16
16
|
createS3DownloadStream(getObjectCommandInput: GetObjectCommandInput): Promise<import("@smithy/types").StreamingBlobPayloadOutputTypes>;
|
|
17
17
|
listObjectsV2(listObjectsV2CommandInput: ListObjectsV2CommandInput): Promise<import("@aws-sdk/client-s3").ListObjectsV2CommandOutput>;
|
|
18
18
|
getObject(getObjectCommandInput: GetObjectCommandInput): Promise<Buffer>;
|
|
19
|
+
headObject(headObjectCommandInput: HeadObjectCommandInput): Promise<import("@aws-sdk/client-s3").HeadObjectCommandOutput>;
|
|
20
|
+
checkIfObjectExists(headObjectCommandInput: HeadObjectCommandInput): Promise<boolean>;
|
|
19
21
|
}
|
package/lib/services/sqs.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { AssumeRoleCommandOutput } from "@aws-sdk/client-sts";
|
|
|
4
4
|
export declare class SQSService {
|
|
5
5
|
logger: Logger;
|
|
6
6
|
client: SQSClient;
|
|
7
|
-
constructor({ logger, client, assumeRoleCommandOutput }
|
|
7
|
+
constructor({ logger, client, assumeRoleCommandOutput }?: {
|
|
8
8
|
logger?: Logger;
|
|
9
9
|
client?: SQSClient;
|
|
10
10
|
assumeRoleCommandOutput?: AssumeRoleCommandOutput;
|
package/lib/services/ssm.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { AssumeRoleCommandOutput } from "@aws-sdk/client-sts";
|
|
|
4
4
|
export declare class SSMService {
|
|
5
5
|
logger: Logger;
|
|
6
6
|
client: SSMClient;
|
|
7
|
-
constructor({ logger, client, assumeRoleCommandOutput }
|
|
7
|
+
constructor({ logger, client, assumeRoleCommandOutput }?: {
|
|
8
8
|
logger?: Logger;
|
|
9
9
|
client?: SSMClient;
|
|
10
10
|
assumeRoleCommandOutput?: AssumeRoleCommandOutput;
|
package/lib/services/sts.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Logger } from "@aws-lambda-powertools/logger";
|
|
|
3
3
|
export declare class STSService {
|
|
4
4
|
logger: Logger;
|
|
5
5
|
client: STSClient;
|
|
6
|
-
constructor({ logger }
|
|
6
|
+
constructor({ logger }?: {
|
|
7
7
|
logger?: Logger;
|
|
8
8
|
});
|
|
9
9
|
getCallerIdentity(): Promise<import("@aws-sdk/client-sts").GetCallerIdentityCommandOutput>;
|