@aspan-corporation/ac-shared 1.0.4 → 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 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({
@@ -35741,7 +35758,7 @@ var SSMService = class {
35741
35758
  logger,
35742
35759
  client,
35743
35760
  assumeRoleCommandOutput
35744
- }) {
35761
+ } = {}) {
35745
35762
  this.logger = getLoggerWithScope("ac-shared:ssm", logger);
35746
35763
  if (assumeRoleCommandOutput) {
35747
35764
  this.client = new import_client_ssm.SSMClient({
@@ -35777,7 +35794,7 @@ var SQSService = class {
35777
35794
  logger,
35778
35795
  client,
35779
35796
  assumeRoleCommandOutput
35780
- }) {
35797
+ } = {}) {
35781
35798
  this.logger = getLoggerWithScope("ac-shared:sqs", logger);
35782
35799
  if (assumeRoleCommandOutput) {
35783
35800
  this.client = new import_client_sqs.SQSClient({
@@ -35815,7 +35832,7 @@ var import_client_sts = __toESM(require_dist_cjs61(), 1);
35815
35832
  var STSService = class {
35816
35833
  logger;
35817
35834
  client;
35818
- constructor({ logger }) {
35835
+ constructor({ logger } = {}) {
35819
35836
  this.logger = getLoggerWithScope("ac-shared:sts", logger);
35820
35837
  this.client = new import_client_sts.STSClient({
35821
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;
@@ -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
  }
@@ -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;
@@ -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;
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspan-corporation/ac-shared",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "lib/index.js",