@aspan-corporation/ac-shared 1.0.3 → 1.0.5
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 +24 -14
- package/lib/services/dynamoDB.d.ts +2 -5
- package/lib/services/s3.d.ts +4 -2
- 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";
|
|
@@ -35623,7 +35624,7 @@ var S3Service = class {
|
|
|
35623
35624
|
logger,
|
|
35624
35625
|
client,
|
|
35625
35626
|
assumeRoleCommandOutput
|
|
35626
|
-
}) {
|
|
35627
|
+
} = {}) {
|
|
35627
35628
|
this.logger = getLoggerWithScope("ac-shared:s3", logger);
|
|
35628
35629
|
if (assumeRoleCommandOutput) {
|
|
35629
35630
|
this.client = new S3Client({
|
|
@@ -35673,6 +35674,22 @@ var S3Service = class {
|
|
|
35673
35674
|
const stream = await this.createS3DownloadStream(getObjectCommandInput);
|
|
35674
35675
|
return Buffer.from(await stream.transformToByteArray());
|
|
35675
35676
|
}
|
|
35677
|
+
async headObject(headObjectCommandInput) {
|
|
35678
|
+
return await this.client.send(
|
|
35679
|
+
new HeadObjectCommand(headObjectCommandInput)
|
|
35680
|
+
);
|
|
35681
|
+
}
|
|
35682
|
+
async checkIfObjectExists(headObjectCommandInput) {
|
|
35683
|
+
try {
|
|
35684
|
+
await this.client.send(new HeadObjectCommand(headObjectCommandInput));
|
|
35685
|
+
return true;
|
|
35686
|
+
} catch (error) {
|
|
35687
|
+
if (error.name === "NotFound") {
|
|
35688
|
+
return false;
|
|
35689
|
+
}
|
|
35690
|
+
throw error;
|
|
35691
|
+
}
|
|
35692
|
+
}
|
|
35676
35693
|
};
|
|
35677
35694
|
|
|
35678
35695
|
// src/services/dynamoDB.ts
|
|
@@ -35692,7 +35709,7 @@ var DynamoDBService = class {
|
|
|
35692
35709
|
logger,
|
|
35693
35710
|
client,
|
|
35694
35711
|
assumeRoleCommandOutput
|
|
35695
|
-
}) {
|
|
35712
|
+
} = {}) {
|
|
35696
35713
|
this.logger = getLoggerWithScope("ac-shared:dynamodb", logger);
|
|
35697
35714
|
if (assumeRoleCommandOutput) {
|
|
35698
35715
|
this.client = new DynamoDBClient({
|
|
@@ -35726,15 +35743,8 @@ var DynamoDBService = class {
|
|
|
35726
35743
|
async putCommand(putCommandInput) {
|
|
35727
35744
|
return await this.documentClient.send(new PutCommand(putCommandInput));
|
|
35728
35745
|
}
|
|
35729
|
-
async checkIfItemExists({
|
|
35730
|
-
|
|
35731
|
-
key
|
|
35732
|
-
}) {
|
|
35733
|
-
const params = {
|
|
35734
|
-
TableName: tableName,
|
|
35735
|
-
Key: key
|
|
35736
|
-
};
|
|
35737
|
-
const result = await this.getCommand(params);
|
|
35746
|
+
async checkIfItemExists(checkInput) {
|
|
35747
|
+
const result = await this.getCommand(checkInput);
|
|
35738
35748
|
return !!result.Item;
|
|
35739
35749
|
}
|
|
35740
35750
|
};
|
|
@@ -35748,7 +35758,7 @@ var SSMService = class {
|
|
|
35748
35758
|
logger,
|
|
35749
35759
|
client,
|
|
35750
35760
|
assumeRoleCommandOutput
|
|
35751
|
-
}) {
|
|
35761
|
+
} = {}) {
|
|
35752
35762
|
this.logger = getLoggerWithScope("ac-shared:ssm", logger);
|
|
35753
35763
|
if (assumeRoleCommandOutput) {
|
|
35754
35764
|
this.client = new import_client_ssm.SSMClient({
|
|
@@ -35784,7 +35794,7 @@ var SQSService = class {
|
|
|
35784
35794
|
logger,
|
|
35785
35795
|
client,
|
|
35786
35796
|
assumeRoleCommandOutput
|
|
35787
|
-
}) {
|
|
35797
|
+
} = {}) {
|
|
35788
35798
|
this.logger = getLoggerWithScope("ac-shared:sqs", logger);
|
|
35789
35799
|
if (assumeRoleCommandOutput) {
|
|
35790
35800
|
this.client = new import_client_sqs.SQSClient({
|
|
@@ -35822,7 +35832,7 @@ var import_client_sts = __toESM(require_dist_cjs61(), 1);
|
|
|
35822
35832
|
var STSService = class {
|
|
35823
35833
|
logger;
|
|
35824
35834
|
client;
|
|
35825
|
-
constructor({ logger }) {
|
|
35835
|
+
constructor({ logger } = {}) {
|
|
35826
35836
|
this.logger = getLoggerWithScope("ac-shared:sts", logger);
|
|
35827
35837
|
this.client = new import_client_sts.STSClient({
|
|
35828
35838
|
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;
|
|
@@ -15,8 +15,5 @@ export declare class DynamoDBService {
|
|
|
15
15
|
updateCommand(updateCommandInput: UpdateCommandInput): Promise<UpdateCommandOutput>;
|
|
16
16
|
queryCommand(queryCommandInput: QueryCommandInput): Promise<QueryCommandOutput>;
|
|
17
17
|
putCommand(putCommandInput: PutCommandInput): Promise<PutCommandOutput>;
|
|
18
|
-
checkIfItemExists(
|
|
19
|
-
tableName: string;
|
|
20
|
-
key: any;
|
|
21
|
-
}): Promise<boolean>;
|
|
18
|
+
checkIfItemExists(checkInput: Pick<GetCommandInput, "TableName" | "Key">): Promise<boolean>;
|
|
22
19
|
}
|
package/lib/services/s3.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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;
|
|
@@ -16,4 +16,6 @@ export declare class S3Service {
|
|
|
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>;
|