@hdriel/aws-utils 1.2.4 → 1.3.0

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/dist/index.js CHANGED
@@ -54,8 +54,11 @@ var __async = (__this, __arguments, generator) => {
54
54
  };
55
55
  var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
56
56
 
57
- // src/aws/iam.ts
58
- import { IAMClient, ListUsersCommand } from "@aws-sdk/client-iam";
57
+ // src/aws/iam/iam-commands.ts
58
+ import { ListUsersCommand } from "@aws-sdk/client-iam";
59
+
60
+ // src/aws/iam/iam-base.ts
61
+ import { IAMClient } from "@aws-sdk/client-iam";
59
62
 
60
63
  // src/aws/configuration.ts
61
64
  var _AWSConfigSharingUtil = class _AWSConfigSharingUtil {
@@ -87,147 +90,157 @@ __publicField(_AWSConfigSharingUtil, "endpoint");
87
90
  __publicField(_AWSConfigSharingUtil, "region");
88
91
  var AWSConfigSharingUtil = _AWSConfigSharingUtil;
89
92
 
90
- // src/aws/iam.ts
91
- var IAMUtil = class {
93
+ // src/aws/iam/iam-base.ts
94
+ var IamBase = class {
92
95
  constructor({
96
+ logger,
97
+ reqId,
93
98
  accessKeyId = AWSConfigSharingUtil.accessKeyId,
94
99
  secretAccessKey = AWSConfigSharingUtil.secretAccessKey,
95
100
  endpoint = AWSConfigSharingUtil.endpoint,
96
- region = AWSConfigSharingUtil.region,
97
- debug = false
98
- } = {}) {
101
+ region = AWSConfigSharingUtil.region
102
+ }) {
99
103
  __publicField(this, "iam");
104
+ __publicField(this, "endpoint");
105
+ __publicField(this, "region");
106
+ __publicField(this, "logger");
107
+ __publicField(this, "reqId");
100
108
  const credentials = { accessKeyId, secretAccessKey };
101
109
  const options = __spreadValues(__spreadValues(__spreadValues({}, accessKeyId && secretAccessKey && { credentials }), endpoint && { endpoint }), region && { region });
102
- if (debug) {
103
- console.log("IAMUtil client options", options);
104
- }
110
+ this.endpoint = endpoint;
111
+ this.region = region;
112
+ this.logger = logger;
113
+ this.reqId = reqId != null ? reqId : null;
105
114
  this.iam = new IAMClient(options);
106
115
  }
107
- get client() {
108
- return this.iam;
109
- }
110
- getUserList() {
116
+ execute(command, options) {
111
117
  return __async(this, null, function* () {
112
- const command = new ListUsersCommand({});
113
- return this.iam.send(command);
118
+ return this.iam.send(command, options);
114
119
  });
115
120
  }
121
+ };
122
+
123
+ // src/aws/iam/iam-commands.ts
124
+ var IamCommands = class extends IamBase {
125
+ constructor(_a) {
126
+ var props = __objRest(_a, []);
127
+ super(props);
128
+ }
116
129
  listUsers(maxItems) {
117
130
  return __async(this, null, function* () {
118
131
  try {
119
132
  const command = new ListUsersCommand({ MaxItems: maxItems });
120
- const response = yield this.iam.send(command);
133
+ const response = yield this.execute(command);
121
134
  return response.Users;
122
135
  } catch (error) {
123
- console.error("Error listing IAM users:", error);
136
+ console.error("Error IAM users list:", error);
124
137
  return null;
125
138
  }
126
139
  });
127
140
  }
128
141
  };
129
142
 
130
- // src/aws/lambda.ts
131
- import { Lambda, InvocationType, InvokeCommand } from "@aws-sdk/client-lambda";
143
+ // src/aws/iam/iam-util.ts
144
+ var IamUtil = class extends IamCommands {
145
+ constructor(props) {
146
+ super(props);
147
+ }
148
+ get client() {
149
+ return this.iam;
150
+ }
151
+ };
132
152
 
133
- // src/utils/logger.ts
134
- import { Logger } from "stack-trace-logger";
135
- var includeCloudWatchOptions = process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY && process.env.AWS_REGION && process.env.AWS_LOG_GROUP_NAME && process.env.AWS_LOG_STREAM_NAME;
136
- var _a;
137
- var logger = new Logger(__spreadValues({
138
- serviceName: process.env.SERVICE_NAME || "SERVER",
139
- loggingModeLevel: process.env.LOGGING_MODE,
140
- lineTraceLevels: (_a = process.env.LOGGING_STACK_TRACE_LEVELS) == null ? void 0 : _a.split(","),
141
- stackTraceLines: { error: 3, warn: 3, info: 1 },
142
- tags: ["reqId?", "url?"],
143
- runLocally: true
144
- }, includeCloudWatchOptions && {
145
- transportCloudWatchOptions: {
146
- awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
147
- awsSecretKey: process.env.AWS_SECRET_ACCESS_KEY,
148
- awsRegion: process.env.AWS_REGION,
149
- logGroupName: process.env.AWS_LOG_GROUP_NAME,
150
- logStreamName: process.env.AWS_LOG_STREAM_NAME,
151
- retentionInDays: +process.env.AWS_LOG_RETENTION_IN_DAY
152
- }
153
- }));
153
+ // src/aws/lambda/lambda-events.ts
154
+ import { InvocationType, InvokeCommand } from "@aws-sdk/client-lambda";
154
155
 
155
- // src/aws/lambda.ts
156
- var LambdaUtil = class {
156
+ // src/aws/lambda/lambda-base.ts
157
+ import { Lambda } from "@aws-sdk/client-lambda";
158
+ var LambdaBase = class {
157
159
  constructor({
160
+ logger,
161
+ reqId,
158
162
  accessKeyId = AWSConfigSharingUtil.accessKeyId,
159
163
  secretAccessKey = AWSConfigSharingUtil.secretAccessKey,
160
164
  endpoint = AWSConfigSharingUtil.endpoint,
161
- region = AWSConfigSharingUtil.region,
162
- serviceFunctionName,
163
- debug = false
165
+ region = AWSConfigSharingUtil.region
164
166
  }) {
165
167
  __publicField(this, "lambda");
166
- __publicField(this, "serviceFunctionName");
168
+ __publicField(this, "endpoint");
169
+ __publicField(this, "region");
170
+ __publicField(this, "logger");
171
+ __publicField(this, "reqId");
167
172
  const credentials = { accessKeyId, secretAccessKey };
168
173
  const options = __spreadValues(__spreadValues(__spreadValues({}, accessKeyId && secretAccessKey && { credentials }), endpoint && { endpoint }), region && { region });
169
- if (debug) {
170
- console.log("LambdaUtil client options", options);
171
- }
174
+ this.endpoint = endpoint;
175
+ this.region = region;
176
+ this.logger = logger;
177
+ this.reqId = reqId != null ? reqId : null;
178
+ this.lambda = new Lambda(__spreadValues({}, options));
179
+ }
180
+ };
181
+
182
+ // src/aws/lambda/lambda-events.ts
183
+ var LambdaEvents = class extends LambdaBase {
184
+ constructor(_a) {
185
+ var _b = _a, { serviceFunctionName } = _b, props = __objRest(_b, ["serviceFunctionName"]);
186
+ super(props);
187
+ __publicField(this, "serviceFunctionName");
172
188
  this.serviceFunctionName = serviceFunctionName;
173
- this.lambda = new Lambda(__spreadValues(__spreadValues(__spreadValues({}, credentials && { credentials }), endpoint && { endpoint }), region && { region }));
174
189
  }
175
190
  directInvoke(_0) {
176
191
  return __async(this, arguments, function* ({
177
192
  payload = {},
178
193
  invocationType = InvocationType.Event
179
194
  }) {
180
- var _a2;
195
+ var _a, _b, _c;
196
+ const FunctionName = this.serviceFunctionName;
181
197
  const Payload = JSON.stringify(payload);
182
198
  try {
183
- const command = new InvokeCommand({
184
- FunctionName: this.serviceFunctionName,
185
- Payload,
186
- InvocationType: invocationType
187
- });
199
+ const command = new InvokeCommand({ FunctionName, Payload, InvocationType: invocationType });
188
200
  const data = yield this.lambda.send(command);
189
201
  if (invocationType === InvocationType.RequestResponse) {
190
- logger.info(null, "directInvoke lambda function response", { FunctionName, data });
202
+ (_a = this.logger) == null ? void 0 : _a.debug(null, "directInvoke lambda function response", {
203
+ FunctionName,
204
+ data,
205
+ InvocationType
206
+ });
191
207
  }
192
- const status = (_a2 = data.StatusCode) != null ? _a2 : 200;
208
+ const status = (_b = data.StatusCode) != null ? _b : 200;
193
209
  const result = data.Payload;
194
210
  return status >= 200 && status < 300 ? result : Promise.reject(result);
195
211
  } catch (err) {
196
- logger.error(null, "failed to directInvoke lambda function", {
197
- err,
198
- Payload,
199
- FunctionName
200
- });
212
+ (_c = this.logger) == null ? void 0 : _c.error(null, "failed to directInvoke lambda function", { err, Payload, FunctionName });
201
213
  throw err;
202
214
  }
203
215
  });
204
216
  }
205
217
  runLambdaInDryRunMode(payload) {
206
218
  return __async(this, null, function* () {
207
- return this.directInvoke({
208
- payload,
209
- invocationType: InvocationType.DryRun
210
- });
219
+ return this.directInvoke({ payload, invocationType: InvocationType.DryRun });
211
220
  });
212
221
  }
213
222
  triggerLambdaEvent(payload) {
214
223
  return __async(this, null, function* () {
215
- return this.directInvoke({
216
- payload,
217
- invocationType: InvocationType.Event
218
- });
224
+ return this.directInvoke({ payload, invocationType: InvocationType.Event });
219
225
  });
220
226
  }
221
227
  runAndGetLambdaResponse(payload) {
222
228
  return __async(this, null, function* () {
223
- return this.directInvoke({
224
- payload,
225
- invocationType: InvocationType.RequestResponse
226
- });
229
+ return this.directInvoke({ payload, invocationType: InvocationType.RequestResponse });
227
230
  });
228
231
  }
229
232
  };
230
233
 
234
+ // src/aws/lambda/lambda-util.ts
235
+ var LambdaUtil = class extends LambdaEvents {
236
+ constructor(props) {
237
+ super(props);
238
+ }
239
+ get client() {
240
+ return this.lambda;
241
+ }
242
+ };
243
+
231
244
  // src/aws/s3/s3-util.localstack.ts
232
245
  import { ListObjectsV2Command as ListObjectsV2Command4 } from "@aws-sdk/client-s3";
233
246
 
@@ -355,8 +368,8 @@ var getNormalizedPath = (directoryPath) => {
355
368
  return decodeURIComponent((directoryPath == null ? void 0 : directoryPath.trim().replace(/^\/+/, "").replace(/\/+$/, "").replace(/\/+/g, "/")) || "");
356
369
  };
357
370
  var getFileSize = (maxFileSize, defaultMaxFileSize) => {
358
- var _a2;
359
- const fileSizeUnitValue = (_a2 = maxFileSize != null ? maxFileSize : defaultMaxFileSize) != null ? _a2 : "";
371
+ var _a;
372
+ const fileSizeUnitValue = (_a = maxFileSize != null ? maxFileSize : defaultMaxFileSize) != null ? _a : "";
360
373
  const fileSize = typeof fileSizeUnitValue === "number" ? fileSizeUnitValue : bytes(fileSizeUnitValue);
361
374
  return fileSize != null ? fileSize : void 0;
362
375
  };
@@ -441,7 +454,7 @@ import { NodeHttpHandler } from "@smithy/node-http-handler";
441
454
  import { S3Client } from "@aws-sdk/client-s3";
442
455
  var S3Base = class {
443
456
  constructor({
444
- logger: logger2,
457
+ logger,
445
458
  reqId,
446
459
  accessKeyId = AWSConfigSharingUtil.accessKeyId,
447
460
  secretAccessKey = AWSConfigSharingUtil.secretAccessKey,
@@ -461,7 +474,7 @@ var S3Base = class {
461
474
  const options = __spreadValues(__spreadValues(__spreadValues({}, accessKeyId && secretAccessKey && { credentials }), endpoint && { endpoint }), region && { region });
462
475
  this.endpoint = endpoint;
463
476
  this.region = region;
464
- this.logger = logger2;
477
+ this.logger = logger;
465
478
  this.reqId = reqId != null ? reqId : null;
466
479
  this.localstack = localstack;
467
480
  const s3ClientParams = __spreadProps(__spreadValues(__spreadValues({}, options), s3ForcePathStyle && { forcePathStyle: s3ForcePathStyle }), {
@@ -483,8 +496,8 @@ var S3Base = class {
483
496
 
484
497
  // src/aws/s3/s3-bucket.ts
485
498
  var S3Bucket = class extends S3Base {
486
- constructor(_a2) {
487
- var _b = _a2, { bucket } = _b, props = __objRest(_b, ["bucket"]);
499
+ constructor(_a) {
500
+ var _b = _a, { bucket } = _b, props = __objRest(_b, ["bucket"]);
488
501
  super(props);
489
502
  __publicField(this, "_bucket");
490
503
  __publicField(this, "initializedBucket", "");
@@ -526,13 +539,13 @@ var S3Bucket = class extends S3Base {
526
539
  }
527
540
  isBucketExists() {
528
541
  return __async(this, null, function* () {
529
- var _a2, _b;
542
+ var _a, _b;
530
543
  const bucketName = this.bucket;
531
544
  try {
532
545
  yield this.execute(new HeadBucketCommand({ Bucket: bucketName }));
533
546
  return true;
534
547
  } catch (err) {
535
- if (err.name !== "NotFound" && ((_a2 = err.$metadata) == null ? void 0 : _a2.httpStatusCode) !== 404) {
548
+ if (err.name !== "NotFound" && ((_a = err.$metadata) == null ? void 0 : _a.httpStatusCode) !== 404) {
536
549
  (_b = this.logger) == null ? void 0 : _b.error(this.reqId, "Error checking bucket:", err);
537
550
  throw err;
538
551
  } else {
@@ -543,11 +556,11 @@ var S3Bucket = class extends S3Base {
543
556
  }
544
557
  initAsPublicBucket() {
545
558
  return __async(this, null, function* () {
546
- var _a2, _b;
559
+ var _a, _b;
547
560
  const bucketName = this.bucket;
548
561
  const isExists = yield this.isBucketExists();
549
562
  if (isExists) {
550
- (_a2 = this.logger) == null ? void 0 : _a2.info(this.reqId, `Bucket already exists.`, { bucketName });
563
+ (_a = this.logger) == null ? void 0 : _a.info(this.reqId, `Bucket already exists.`, { bucketName });
551
564
  return;
552
565
  }
553
566
  const data = yield this.execute(new CreateBucketCommand({ Bucket: bucketName }));
@@ -585,11 +598,11 @@ var S3Bucket = class extends S3Base {
585
598
  }
586
599
  initAsPrivateBucket(includeConstraintLocation) {
587
600
  return __async(this, null, function* () {
588
- var _a2, _b;
601
+ var _a, _b;
589
602
  const bucketName = this.bucket;
590
603
  const isExists = yield this.isBucketExists();
591
604
  if (isExists) {
592
- (_a2 = this.logger) == null ? void 0 : _a2.info(this.reqId, `Bucket already exists.`, { bucketName });
605
+ (_a = this.logger) == null ? void 0 : _a.info(this.reqId, `Bucket already exists.`, { bucketName });
593
606
  return;
594
607
  }
595
608
  const createParams = __spreadValues({
@@ -607,14 +620,14 @@ var S3Bucket = class extends S3Base {
607
620
  includeConstraintLocation = false,
608
621
  skipInitializedBucket = false
609
622
  } = {}) {
610
- var _a2;
623
+ var _a;
611
624
  const bucketName = this.bucket;
612
625
  if (skipInitializedBucket && this.initializedBucket === bucketName) {
613
626
  return;
614
627
  }
615
628
  const isExists = yield this.isBucketExists();
616
629
  if (isExists) {
617
- (_a2 = this.logger) == null ? void 0 : _a2.info(this.reqId, `Bucket already exists.`, { bucketName });
630
+ (_a = this.logger) == null ? void 0 : _a.info(this.reqId, `Bucket already exists.`, { bucketName });
618
631
  return;
619
632
  }
620
633
  const data = acl === "private" /* private */ ? yield this.initAsPrivateBucket(includeConstraintLocation) : yield this.initAsPublicBucket();
@@ -648,7 +661,7 @@ var S3Bucket = class extends S3Base {
648
661
  }
649
662
  bucketInfo(options) {
650
663
  return __async(this, null, function* () {
651
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
664
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
652
665
  const bucketName = this.bucket;
653
666
  const info = {
654
667
  name: bucketName,
@@ -661,7 +674,7 @@ var S3Bucket = class extends S3Base {
661
674
  const headBucketResponse = yield this.execute(
662
675
  new HeadBucketCommand(__spreadValues({ Bucket: bucketName }, options))
663
676
  );
664
- (_a2 = this.logger) == null ? void 0 : _a2.debug("bucketInfo", "HeadBucketCommandOutput", headBucketResponse);
677
+ (_a = this.logger) == null ? void 0 : _a.debug("bucketInfo", "HeadBucketCommandOutput", headBucketResponse);
665
678
  info.exists = true;
666
679
  info.bucketRegion = headBucketResponse.BucketRegion;
667
680
  info.accessPointAlias = headBucketResponse.AccessPointAlias;
@@ -687,9 +700,9 @@ var S3Bucket = class extends S3Base {
687
700
  );
688
701
  (_e = this.logger) == null ? void 0 : _e.debug("bucketInfo", "GetBucketAclCommandOutput", aclResponse);
689
702
  info.acl = (_f = aclResponse.Grants) == null ? void 0 : _f.map((grant) => {
690
- var _a3;
703
+ var _a2;
691
704
  return {
692
- grantee: (_a3 = grant.Grantee) == null ? void 0 : _a3.Type,
705
+ grantee: (_a2 = grant.Grantee) == null ? void 0 : _a2.Type,
693
706
  permission: grant.Permission
694
707
  };
695
708
  });
@@ -756,11 +769,11 @@ var S3Bucket = class extends S3Base {
756
769
  }
757
770
  destroyBucket(forceDeleteAllFilesBeforeDestroyBucket = false) {
758
771
  return __async(this, null, function* () {
759
- var _a2;
772
+ var _a;
760
773
  const bucketName = this.bucket;
761
774
  const isExists = yield this.isBucketExists();
762
775
  if (!isExists) {
763
- (_a2 = this.logger) == null ? void 0 : _a2.debug(this.reqId, `Bucket not exists.`, { bucketName });
776
+ (_a = this.logger) == null ? void 0 : _a.debug(this.reqId, `Bucket not exists.`, { bucketName });
764
777
  return;
765
778
  }
766
779
  if (forceDeleteAllFilesBeforeDestroyBucket) {
@@ -780,7 +793,7 @@ var S3Directory = class extends S3Bucket {
780
793
  }
781
794
  directoryExists(directoryPath) {
782
795
  return __async(this, null, function* () {
783
- var _a2;
796
+ var _a;
784
797
  try {
785
798
  const normalizedKey = getNormalizedPath(directoryPath);
786
799
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
@@ -788,7 +801,7 @@ var S3Directory = class extends S3Bucket {
788
801
  yield this.execute(command);
789
802
  return true;
790
803
  } catch (error) {
791
- if (error.name === "NotFound" || ((_a2 = error.$metadata) == null ? void 0 : _a2.httpStatusCode) === 404) {
804
+ if (error.name === "NotFound" || ((_a = error.$metadata) == null ? void 0 : _a.httpStatusCode) === 404) {
792
805
  return false;
793
806
  }
794
807
  throw error;
@@ -806,7 +819,7 @@ var S3Directory = class extends S3Bucket {
806
819
  }
807
820
  deleteDirectory(directoryPath) {
808
821
  return __async(this, null, function* () {
809
- var _a2, _b, _c, _d, _e, _f, _g;
822
+ var _a, _b, _c, _d, _e, _f, _g;
810
823
  let normalizedPath = getNormalizedPath(directoryPath);
811
824
  if (!normalizedPath) throw new Error("No directory path provided");
812
825
  if (normalizedPath === "/") normalizedPath = "";
@@ -830,7 +843,7 @@ var S3Directory = class extends S3Bucket {
830
843
  }
831
844
  })
832
845
  );
833
- totalDeletedCount += (_b = (_a2 = deleteResult.Deleted) == null ? void 0 : _a2.length) != null ? _b : 0;
846
+ totalDeletedCount += (_b = (_a = deleteResult.Deleted) == null ? void 0 : _a.length) != null ? _b : 0;
834
847
  if (deleteResult.Errors && deleteResult.Errors.length > 0) {
835
848
  (_c = this.logger) == null ? void 0 : _c.warn(this.reqId, `Some objects failed to delete`, {
836
849
  directoryPath: normalizedPath,
@@ -875,7 +888,7 @@ var S3Directory = class extends S3Bucket {
875
888
  }
876
889
  directoryList(directoryPath) {
877
890
  return __async(this, null, function* () {
878
- var _a2;
891
+ var _a;
879
892
  let normalizedPath = getNormalizedPath(directoryPath);
880
893
  if (normalizedPath !== "/" && directoryPath !== "" && directoryPath !== void 0) normalizedPath += "/";
881
894
  else normalizedPath = this.localstack ? "" : "/";
@@ -908,7 +921,7 @@ var S3Directory = class extends S3Bucket {
908
921
  })
909
922
  );
910
923
  }
911
- (_a2 = this.logger) == null ? void 0 : _a2.debug(null, "#### directoryList", {
924
+ (_a = this.logger) == null ? void 0 : _a.debug(null, "#### directoryList", {
912
925
  normalizedPath,
913
926
  CommonPrefixes: result.CommonPrefixes,
914
927
  ContentFile: result.Contents
@@ -919,8 +932,8 @@ var S3Directory = class extends S3Bucket {
919
932
  return dir;
920
933
  }).filter((dir) => dir);
921
934
  const files = (result.Contents || []).filter((content) => {
922
- var _a3;
923
- return content.Key !== normalizedPath && !((_a3 = content.Key) == null ? void 0 : _a3.endsWith("/"));
935
+ var _a2;
936
+ return content.Key !== normalizedPath && !((_a2 = content.Key) == null ? void 0 : _a2.endsWith("/"));
924
937
  }).map((content) => __spreadProps(__spreadValues({}, content), {
925
938
  Name: content.Key.replace(normalizedPath, "") || content.Key,
926
939
  Location: `${this.link}${content.Key.replace(/^\//, "")}`,
@@ -959,8 +972,8 @@ var S3Directory = class extends S3Bucket {
959
972
  return relativePath.replace(/\/$/, "");
960
973
  }).filter((dir) => dir);
961
974
  allFiles = (result.Contents || []).filter((content) => {
962
- var _a2;
963
- return content.Key !== normalizedPath && !((_a2 = content.Key) == null ? void 0 : _a2.endsWith("/"));
975
+ var _a;
976
+ return content.Key !== normalizedPath && !((_a = content.Key) == null ? void 0 : _a.endsWith("/"));
964
977
  }).map((content) => __spreadProps(__spreadValues({}, content), {
965
978
  Name: content.Key.replace(normalizedPath, "") || content.Key,
966
979
  Location: `${this.link}${content.Key.replace(/^\//, "")}`,
@@ -1063,7 +1076,7 @@ var S3File = class extends S3Directory {
1063
1076
  }
1064
1077
  fileList(directoryPath, fileNamePrefix) {
1065
1078
  return __async(this, null, function* () {
1066
- var _a2, _b;
1079
+ var _a, _b;
1067
1080
  let normalizedPath = getNormalizedPath(directoryPath);
1068
1081
  if (normalizedPath !== "/" && directoryPath !== "" && directoryPath !== void 0) normalizedPath += "/";
1069
1082
  else normalizedPath = this.localstack ? "" : "/";
@@ -1074,11 +1087,11 @@ var S3File = class extends S3Directory {
1074
1087
  Delimiter: "/"
1075
1088
  });
1076
1089
  const result = yield this.execute(command);
1077
- const files = ((_a2 = result.Contents) != null ? _a2 : []).filter((v) => v).map(
1090
+ const files = ((_a = result.Contents) != null ? _a : []).filter((v) => v).map(
1078
1091
  (content) => {
1079
- var _a3, _b2, _c;
1092
+ var _a2, _b2, _c;
1080
1093
  return __spreadProps(__spreadValues({}, content), {
1081
- Name: (_b2 = (_a3 = content.Key) == null ? void 0 : _a3.replace(prefix, "")) != null ? _b2 : content.Key,
1094
+ Name: (_b2 = (_a2 = content.Key) == null ? void 0 : _a2.replace(prefix, "")) != null ? _b2 : content.Key,
1082
1095
  Location: content.Key ? `${this.link}${(_c = content.Key) == null ? void 0 : _c.replace(/^\//, "")}` : "",
1083
1096
  LastModified: content.LastModified ? new Date(content.LastModified) : null
1084
1097
  });
@@ -1095,7 +1108,7 @@ var S3File = class extends S3Directory {
1095
1108
  // 0-based: page 0 = items 0-99, page 1 = items 100-199, page 2 = items 200-299
1096
1109
  pageSize = 100
1097
1110
  } = {}) {
1098
- var _a2, _b;
1111
+ var _a, _b;
1099
1112
  let normalizedPath = getNormalizedPath(directoryPath);
1100
1113
  if (normalizedPath !== "/" && directoryPath !== "" && directoryPath !== void 0) normalizedPath += "/";
1101
1114
  else normalizedPath = "";
@@ -1114,11 +1127,11 @@ var S3File = class extends S3Directory {
1114
1127
  })
1115
1128
  );
1116
1129
  if (currentPage === pageNumber) {
1117
- resultFiles = ((_a2 = result.Contents) != null ? _a2 : []).filter((v) => v).map(
1130
+ resultFiles = ((_a = result.Contents) != null ? _a : []).filter((v) => v).map(
1118
1131
  (content) => {
1119
- var _a3, _b2;
1132
+ var _a2, _b2;
1120
1133
  return __spreadProps(__spreadValues({}, content), {
1121
- Name: (_b2 = (_a3 = content.Key) == null ? void 0 : _a3.replace(prefix, "")) != null ? _b2 : content.Key,
1134
+ Name: (_b2 = (_a2 = content.Key) == null ? void 0 : _a2.replace(prefix, "")) != null ? _b2 : content.Key,
1122
1135
  Location: content.Key ? `${this.link}${content.Key.replace(/^\//, "")}` : "",
1123
1136
  LastModified: content.LastModified ? new Date(content.LastModified) : null
1124
1137
  });
@@ -1145,7 +1158,7 @@ var S3File = class extends S3Directory {
1145
1158
  }
1146
1159
  taggingFile(fileKey, tag) {
1147
1160
  return __async(this, null, function* () {
1148
- var _a2;
1161
+ var _a;
1149
1162
  let normalizedKey = "";
1150
1163
  const tags = [].concat(tag);
1151
1164
  try {
@@ -1159,25 +1172,25 @@ var S3File = class extends S3Directory {
1159
1172
  yield this.execute(command);
1160
1173
  return true;
1161
1174
  } catch (error) {
1162
- (_a2 = this.logger) == null ? void 0 : _a2.warn(null, "failed to tagging file", { errMsg: error.message, fileKey: normalizedKey, tags });
1175
+ (_a = this.logger) == null ? void 0 : _a.warn(null, "failed to tagging file", { errMsg: error.message, fileKey: normalizedKey, tags });
1163
1176
  return false;
1164
1177
  }
1165
1178
  });
1166
1179
  }
1167
1180
  fileVersion(fileKey) {
1168
1181
  return __async(this, null, function* () {
1169
- var _a2, _b;
1182
+ var _a, _b;
1170
1183
  const normalizedKey = getNormalizedPath(fileKey);
1171
1184
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
1172
1185
  const command = new GetObjectTaggingCommand({ Bucket: this.bucket, Key: normalizedKey });
1173
1186
  const result = yield this.execute(command);
1174
- const tag = (_a2 = result.TagSet) == null ? void 0 : _a2.find((tag2) => tag2.Key === "version");
1187
+ const tag = (_a = result.TagSet) == null ? void 0 : _a.find((tag2) => tag2.Key === "version");
1175
1188
  return (_b = tag == null ? void 0 : tag.Value) != null ? _b : "";
1176
1189
  });
1177
1190
  }
1178
1191
  fileUrl(fileKey, expiresIn = "15m") {
1179
1192
  return __async(this, null, function* () {
1180
- var _a2;
1193
+ var _a;
1181
1194
  let normalizedKey = getNormalizedPath(fileKey);
1182
1195
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
1183
1196
  const expiresInSeconds = typeof expiresIn === "number" ? expiresIn : ms2(expiresIn) / 1e3;
@@ -1186,19 +1199,19 @@ var S3File = class extends S3Directory {
1186
1199
  expiresIn: expiresInSeconds
1187
1200
  // is using 3600 it's will expire in 1 hour (default is 900 seconds = 15 minutes)
1188
1201
  });
1189
- (_a2 = this.logger) == null ? void 0 : _a2.info(null, "generate signed file url", { url, fileKey: normalizedKey, expiresIn });
1202
+ (_a = this.logger) == null ? void 0 : _a.info(null, "generate signed file url", { url, fileKey: normalizedKey, expiresIn });
1190
1203
  return url;
1191
1204
  });
1192
1205
  }
1193
1206
  sizeOf(fileKey, unit = "b") {
1194
1207
  return __async(this, null, function* () {
1195
- var _a2, _b, _c;
1208
+ var _a, _b, _c;
1196
1209
  const normalizedKey = getNormalizedPath(fileKey);
1197
1210
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
1198
1211
  try {
1199
1212
  const command = new HeadObjectCommand2({ Bucket: this.bucket, Key: normalizedKey });
1200
1213
  const headObject = yield this.execute(command);
1201
- const bytes2 = (_a2 = headObject.ContentLength) != null ? _a2 : 0;
1214
+ const bytes2 = (_a = headObject.ContentLength) != null ? _a : 0;
1202
1215
  return getUnitBytes(bytes2, unit);
1203
1216
  } catch (error) {
1204
1217
  if (error.name === "NotFound" || ((_b = error.$metadata) == null ? void 0 : _b.httpStatusCode) === 404) {
@@ -1211,7 +1224,7 @@ var S3File = class extends S3Directory {
1211
1224
  }
1212
1225
  fileExists(fileKey) {
1213
1226
  return __async(this, null, function* () {
1214
- var _a2;
1227
+ var _a;
1215
1228
  try {
1216
1229
  const normalizedKey = getNormalizedPath(fileKey);
1217
1230
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
@@ -1219,7 +1232,7 @@ var S3File = class extends S3Directory {
1219
1232
  yield this.execute(command);
1220
1233
  return true;
1221
1234
  } catch (error) {
1222
- if (error.name === "NotFound" || ((_a2 = error.$metadata) == null ? void 0 : _a2.httpStatusCode) === 404) {
1235
+ if (error.name === "NotFound" || ((_a = error.$metadata) == null ? void 0 : _a.httpStatusCode) === 404) {
1223
1236
  return false;
1224
1237
  }
1225
1238
  throw error;
@@ -1311,8 +1324,8 @@ var S3File = class extends S3Directory {
1311
1324
  // src/aws/s3/s3-stream.ts
1312
1325
  var pump = promisify(pipeline);
1313
1326
  var S3Stream = class _S3Stream extends S3File {
1314
- constructor(_a2) {
1315
- var _b = _a2, { maxUploadFileSizeRestriction = "10GB", concurrencyVideoLimit = 0 } = _b, props = __objRest(_b, ["maxUploadFileSizeRestriction", "concurrencyVideoLimit"]);
1327
+ constructor(_a) {
1328
+ var _b = _a, { maxUploadFileSizeRestriction = "10GB", concurrencyVideoLimit = 0 } = _b, props = __objRest(_b, ["maxUploadFileSizeRestriction", "concurrencyVideoLimit"]);
1316
1329
  super(props);
1317
1330
  __publicField(this, "maxUploadFileSizeRestriction");
1318
1331
  __publicField(this, "s3Limiter");
@@ -1324,8 +1337,8 @@ var S3Stream = class _S3Stream extends S3File {
1324
1337
  cachingAge: _cachingAge = "1y"
1325
1338
  } = {}) => {
1326
1339
  return (req, res, next) => __async(this, null, function* () {
1327
- var _a2, _b, _c, _d, _e, _f, _g, _h;
1328
- let fileKey = _fileKey || (((_a2 = req.params) == null ? void 0 : _a2[paramsField]) ? decodeURIComponent((_b = req.params) == null ? void 0 : _b[paramsField]) : void 0) || (((_c = req.query) == null ? void 0 : _c[queryField]) ? decodeURIComponent((_d = req.query) == null ? void 0 : _d[queryField]) : void 0) || (((_e = req.headers) == null ? void 0 : _e[headerField]) ? decodeURIComponent((_f = req.headers) == null ? void 0 : _f[headerField]) : void 0);
1340
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1341
+ let fileKey = _fileKey || (((_a = req.params) == null ? void 0 : _a[paramsField]) ? decodeURIComponent((_b = req.params) == null ? void 0 : _b[paramsField]) : void 0) || (((_c = req.query) == null ? void 0 : _c[queryField]) ? decodeURIComponent((_d = req.query) == null ? void 0 : _d[queryField]) : void 0) || (((_e = req.headers) == null ? void 0 : _e[headerField]) ? decodeURIComponent((_f = req.headers) == null ? void 0 : _f[headerField]) : void 0);
1329
1342
  if (!fileKey || fileKey === "/") {
1330
1343
  (_g = this.logger) == null ? void 0 : _g.warn(req.id, "image fileKey is required");
1331
1344
  next(Error("image fileKey is required"));
@@ -1368,8 +1381,8 @@ var S3Stream = class _S3Stream extends S3File {
1368
1381
  cachingAge: _cachingAge = "1h"
1369
1382
  } = {}) => {
1370
1383
  return (req, res, next) => __async(this, null, function* () {
1371
- var _a2, _b, _c, _d, _e, _f, _g, _h;
1372
- let fileKey = _fileKey || (((_a2 = req.params) == null ? void 0 : _a2[paramsField]) ? decodeURIComponent((_b = req.params) == null ? void 0 : _b[paramsField]) : void 0) || (((_c = req.query) == null ? void 0 : _c[queryField]) ? decodeURIComponent((_d = req.query) == null ? void 0 : _d[queryField]) : void 0) || (((_e = req.headers) == null ? void 0 : _e[headerField]) ? decodeURIComponent((_f = req.headers) == null ? void 0 : _f[headerField]) : void 0);
1384
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1385
+ let fileKey = _fileKey || (((_a = req.params) == null ? void 0 : _a[paramsField]) ? decodeURIComponent((_b = req.params) == null ? void 0 : _b[paramsField]) : void 0) || (((_c = req.query) == null ? void 0 : _c[queryField]) ? decodeURIComponent((_d = req.query) == null ? void 0 : _d[queryField]) : void 0) || (((_e = req.headers) == null ? void 0 : _e[headerField]) ? decodeURIComponent((_f = req.headers) == null ? void 0 : _f[headerField]) : void 0);
1373
1386
  if (!fileKey) {
1374
1387
  (_g = this.logger) == null ? void 0 : _g.warn(req.id, "iframe fileKey is required");
1375
1388
  next(Error("iframe fileKey is required"));
@@ -1437,7 +1450,7 @@ var S3Stream = class _S3Stream extends S3File {
1437
1450
  Range,
1438
1451
  abortSignal
1439
1452
  } = {}) {
1440
- var _a2;
1453
+ var _a;
1441
1454
  let normalizedKey = getNormalizedPath(fileKey);
1442
1455
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
1443
1456
  try {
@@ -1460,7 +1473,7 @@ var S3Stream = class _S3Stream extends S3File {
1460
1473
  }
1461
1474
  };
1462
1475
  } catch (error) {
1463
- (_a2 = this.logger) == null ? void 0 : _a2.warn(this.reqId, "streamVideoFile error", {
1476
+ (_a = this.logger) == null ? void 0 : _a.warn(this.reqId, "streamVideoFile error", {
1464
1477
  Bucket: this.bucket,
1465
1478
  fileKey: normalizedKey,
1466
1479
  Range,
@@ -1482,8 +1495,8 @@ var S3Stream = class _S3Stream extends S3File {
1482
1495
  streamTimeoutMS = 3e4
1483
1496
  } = {}) {
1484
1497
  return (req, res, next) => __async(this, null, function* () {
1485
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1486
- let fileKey = _fileKey || (((_a2 = req.params) == null ? void 0 : _a2[paramsField]) ? (_b = req.params) == null ? void 0 : _b[paramsField] : void 0) || (((_c = req.query) == null ? void 0 : _c[queryField]) ? (_d = req.query) == null ? void 0 : _d[queryField] : void 0);
1498
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1499
+ let fileKey = _fileKey || (((_a = req.params) == null ? void 0 : _a[paramsField]) ? (_b = req.params) == null ? void 0 : _b[paramsField] : void 0) || (((_c = req.query) == null ? void 0 : _c[queryField]) ? (_d = req.query) == null ? void 0 : _d[queryField] : void 0);
1487
1500
  ((_e = req.headers) == null ? void 0 : _e[headerField]) ? (_f = req.headers) == null ? void 0 : _f[headerField] : void 0;
1488
1501
  if (!fileKey || fileKey === "/") {
1489
1502
  (_g = this.logger) == null ? void 0 : _g.warn(req.id, "fileKey video stream is required");
@@ -1560,9 +1573,9 @@ var S3Stream = class _S3Stream extends S3File {
1560
1573
  res.end();
1561
1574
  }, streamTimeoutMS);
1562
1575
  res.once("close", () => {
1563
- var _a3;
1576
+ var _a2;
1564
1577
  clearTimeout(timeout);
1565
- (_a3 = body.destroy) == null ? void 0 : _a3.call(body);
1578
+ (_a2 = body.destroy) == null ? void 0 : _a2.call(body);
1566
1579
  req.off("close", onClose);
1567
1580
  });
1568
1581
  yield pump(body, res);
@@ -1605,8 +1618,8 @@ var S3Stream = class _S3Stream extends S3File {
1605
1618
  cachingAge: _cachingAge = "1h"
1606
1619
  } = {}) {
1607
1620
  return (req, res, next) => __async(this, null, function* () {
1608
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
1609
- const fileKey = _fileKey || (((_a2 = req.params) == null ? void 0 : _a2[paramsField]) ? (_b = req.params) == null ? void 0 : _b[paramsField] : void 0) || (((_c = req.query) == null ? void 0 : _c[queryField]) ? (_d = req.query) == null ? void 0 : _d[queryField] : void 0) || (((_e = req.headers) == null ? void 0 : _e[headerField]) ? decodeURIComponent((_f = req.headers) == null ? void 0 : _f[headerField]) : void 0);
1621
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1622
+ const fileKey = _fileKey || (((_a = req.params) == null ? void 0 : _a[paramsField]) ? (_b = req.params) == null ? void 0 : _b[paramsField] : void 0) || (((_c = req.query) == null ? void 0 : _c[queryField]) ? (_d = req.query) == null ? void 0 : _d[queryField] : void 0) || (((_e = req.headers) == null ? void 0 : _e[headerField]) ? decodeURIComponent((_f = req.headers) == null ? void 0 : _f[headerField]) : void 0);
1610
1623
  if (!fileKey || fileKey === "/") {
1611
1624
  (_g = this.logger) == null ? void 0 : _g.warn(req.id, "fileKey stream is required");
1612
1625
  next(Error("fileKey stream is required"));
@@ -1615,9 +1628,9 @@ var S3Stream = class _S3Stream extends S3File {
1615
1628
  const abort = new AbortController();
1616
1629
  let stream = null;
1617
1630
  const onClose = () => {
1618
- var _a3;
1631
+ var _a2;
1619
1632
  abort.abort();
1620
- (_a3 = stream == null ? void 0 : stream.destroy) == null ? void 0 : _a3.call(stream);
1633
+ (_a2 = stream == null ? void 0 : stream.destroy) == null ? void 0 : _a2.call(stream);
1621
1634
  };
1622
1635
  req.once("close", onClose);
1623
1636
  let normalizedKey = getNormalizedPath(fileKey);
@@ -1659,14 +1672,14 @@ var S3Stream = class _S3Stream extends S3File {
1659
1672
  }
1660
1673
  res.setHeader("Access-Control-Expose-Headers", "Content-Type, Content-Disposition, Content-Length");
1661
1674
  stream.on("error", (err) => {
1662
- var _a3, _b2;
1663
- (_a3 = this.logger) == null ? void 0 : _a3.warn(this.reqId, "Stream error", { fileKey: normalizedKey, error: err });
1675
+ var _a2, _b2;
1676
+ (_a2 = this.logger) == null ? void 0 : _a2.warn(this.reqId, "Stream error", { fileKey: normalizedKey, error: err });
1664
1677
  abort.abort();
1665
1678
  (_b2 = stream == null ? void 0 : stream.destroy) == null ? void 0 : _b2.call(stream);
1666
1679
  });
1667
1680
  res.once("close", () => {
1668
- var _a3;
1669
- (_a3 = stream == null ? void 0 : stream.destroy) == null ? void 0 : _a3.call(stream);
1681
+ var _a2;
1682
+ (_a2 = stream == null ? void 0 : stream.destroy) == null ? void 0 : _a2.call(stream);
1670
1683
  req.off("close", onClose);
1671
1684
  });
1672
1685
  streamMethod || (streamMethod = canDisplayInline ? "pipe" : "pipeline");
@@ -1710,11 +1723,11 @@ var S3Stream = class _S3Stream extends S3File {
1710
1723
  compressionLevel = 5
1711
1724
  } = {}) {
1712
1725
  return (req, res, next) => __async(this, null, function* () {
1713
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1726
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1714
1727
  const abort = new AbortController();
1715
1728
  const onClose = () => abort.abort();
1716
1729
  try {
1717
- let fileKey = _fileKey || (((_a2 = req.params) == null ? void 0 : _a2[paramsField]) ? (_b = req.params) == null ? void 0 : _b[paramsField] : void 0) || (((_c = req.query) == null ? void 0 : _c[queryField]) ? (_d = req.query) == null ? void 0 : _d[queryField] : void 0) || (((_e = req.headers) == null ? void 0 : _e[headerField]) ? decodeURIComponent((_f = req.headers) == null ? void 0 : _f[headerField]) : void 0);
1730
+ let fileKey = _fileKey || (((_a = req.params) == null ? void 0 : _a[paramsField]) ? (_b = req.params) == null ? void 0 : _b[paramsField] : void 0) || (((_c = req.query) == null ? void 0 : _c[queryField]) ? (_d = req.query) == null ? void 0 : _d[queryField] : void 0) || (((_e = req.headers) == null ? void 0 : _e[headerField]) ? decodeURIComponent((_f = req.headers) == null ? void 0 : _f[headerField]) : void 0);
1718
1731
  if (!fileKey || fileKey === "/") {
1719
1732
  (_g = this.logger) == null ? void 0 : _g.warn(req.id, "fileKey video stream is required");
1720
1733
  next(Error("fileKey video stream is required"));
@@ -1729,12 +1742,12 @@ var S3Stream = class _S3Stream extends S3File {
1729
1742
  req.once("close", onClose);
1730
1743
  (_h = this.logger) == null ? void 0 : _h.info(this.reqId, "Starting parallel file download...", { fileCount: fileKeys.length });
1731
1744
  const downloadPromises = fileKeys.map((fileKey2) => __async(this, null, function* () {
1732
- var _a3, _b2, _c2;
1745
+ var _a2, _b2, _c2;
1733
1746
  try {
1734
1747
  if (abort.signal.aborted) return null;
1735
1748
  const stream = yield this.getObjectFileStream(fileKey2, { abortSignal: abort.signal });
1736
1749
  if (!stream) {
1737
- (_a3 = this.logger) == null ? void 0 : _a3.warn(this.reqId, "File not found", { fileKey: fileKey2 });
1750
+ (_a2 = this.logger) == null ? void 0 : _a2.warn(this.reqId, "File not found", { fileKey: fileKey2 });
1738
1751
  return null;
1739
1752
  }
1740
1753
  const chunks = [];
@@ -1805,8 +1818,8 @@ var S3Stream = class _S3Stream extends S3File {
1805
1818
  res.setHeader("Content-Length", String(actualZipSize));
1806
1819
  res.setHeader("Access-Control-Expose-Headers", "Content-Type, Content-Disposition, Content-Length");
1807
1820
  actualArchive.on("error", (err) => {
1808
- var _a3;
1809
- (_a3 = this.logger) == null ? void 0 : _a3.error(this.reqId, "Archive error", { error: err });
1821
+ var _a2;
1822
+ (_a2 = this.logger) == null ? void 0 : _a2.error(this.reqId, "Archive error", { error: err });
1810
1823
  abort.abort();
1811
1824
  if (!res.headersSent) {
1812
1825
  next(err);
@@ -1922,18 +1935,18 @@ var S3Stream = class _S3Stream extends S3File {
1922
1935
  * Adds the uploaded file info to req.s3File
1923
1936
  */
1924
1937
  uploadSingleFileMW(fieldName, directoryPath, options = {}) {
1925
- var _a2;
1938
+ var _a;
1926
1939
  let normalizedPath = getNormalizedPath(directoryPath);
1927
1940
  if (normalizedPath !== "/" && directoryPath !== "" && directoryPath !== void 0) normalizedPath += "/";
1928
1941
  else normalizedPath = "";
1929
- (_a2 = this.logger) == null ? void 0 : _a2.debug(null, "####### uploadSingleFile", { directoryPath, normalizedPath, fieldName });
1942
+ (_a = this.logger) == null ? void 0 : _a.debug(null, "####### uploadSingleFile", { directoryPath, normalizedPath, fieldName });
1930
1943
  const upload = this.getUploadFileMW(normalizedPath, options);
1931
1944
  return (req, res, next) => {
1932
1945
  const mw = upload.single(fieldName);
1933
1946
  mw(req, res, (err) => {
1934
- var _a3, _b;
1947
+ var _a2, _b;
1935
1948
  if (err) {
1936
- (_a3 = this.logger) == null ? void 0 : _a3.error(this.reqId, "Single file upload error", { fieldName, error: err.message });
1949
+ (_a2 = this.logger) == null ? void 0 : _a2.error(this.reqId, "Single file upload error", { fieldName, error: err.message });
1937
1950
  return next(err);
1938
1951
  }
1939
1952
  if (req.file) {
@@ -1962,9 +1975,9 @@ var S3Stream = class _S3Stream extends S3File {
1962
1975
  return (req, res, next) => {
1963
1976
  const mw = upload.array(fieldName, maxFilesCount || void 0);
1964
1977
  mw(req, res, (err) => {
1965
- var _a2, _b;
1978
+ var _a, _b;
1966
1979
  if (err) {
1967
- (_a2 = this.logger) == null ? void 0 : _a2.error(this.reqId, "Multiple files upload error", { fieldName, error: err.message });
1980
+ (_a = this.logger) == null ? void 0 : _a.error(this.reqId, "Multiple files upload error", { fieldName, error: err.message });
1968
1981
  return next(err);
1969
1982
  }
1970
1983
  if (Array.isArray(req.files)) {
@@ -1991,9 +2004,9 @@ var S3Stream = class _S3Stream extends S3File {
1991
2004
  return (req, res, next) => {
1992
2005
  const anyUpload = maxCount ? upload.any() : upload.any();
1993
2006
  anyUpload(req, res, (err) => {
1994
- var _a2, _b;
2007
+ var _a, _b;
1995
2008
  if (err) {
1996
- (_a2 = this.logger) == null ? void 0 : _a2.error(this.reqId, "Any files upload error", { error: err.message });
2009
+ (_a = this.logger) == null ? void 0 : _a.error(this.reqId, "Any files upload error", { error: err.message });
1997
2010
  return next(err);
1998
2011
  }
1999
2012
  if (req.files && Array.isArray(req.files)) {
@@ -2072,10 +2085,14 @@ var S3Stream = class _S3Stream extends S3File {
2072
2085
  };
2073
2086
 
2074
2087
  // src/aws/s3/s3-util.ts
2088
+ import "@aws-sdk/client-s3";
2075
2089
  var S3Util = class extends S3Stream {
2076
2090
  constructor(props) {
2077
2091
  super(props);
2078
2092
  }
2093
+ get client() {
2094
+ return this.s3Client;
2095
+ }
2079
2096
  };
2080
2097
 
2081
2098
  // src/aws/s3/s3-util.localstack.ts
@@ -2083,9 +2100,12 @@ var S3LocalstackUtil = class extends S3Util {
2083
2100
  constructor(props) {
2084
2101
  super(__spreadProps(__spreadValues({}, props), { localstack: true }));
2085
2102
  }
2103
+ get client() {
2104
+ return this.s3Client;
2105
+ }
2086
2106
  directoryList(directoryPath) {
2087
2107
  return __async(this, null, function* () {
2088
- var _a2;
2108
+ var _a;
2089
2109
  let normalizedPath = getNormalizedPath(directoryPath);
2090
2110
  if (normalizedPath !== "/" && directoryPath !== "" && directoryPath !== void 0) normalizedPath += "/";
2091
2111
  else normalizedPath = "";
@@ -2097,7 +2117,7 @@ var S3LocalstackUtil = class extends S3Util {
2097
2117
  Delimiter: "/"
2098
2118
  })
2099
2119
  );
2100
- (_a2 = this.logger) == null ? void 0 : _a2.debug(null, "#### directoryList", {
2120
+ (_a = this.logger) == null ? void 0 : _a.debug(null, "#### directoryList", {
2101
2121
  normalizedPath,
2102
2122
  CommonPrefixes: result.CommonPrefixes,
2103
2123
  ContentFile: result.Contents
@@ -2108,8 +2128,8 @@ var S3LocalstackUtil = class extends S3Util {
2108
2128
  return dir;
2109
2129
  }).filter((dir) => dir);
2110
2130
  const files = (result.Contents || []).filter((content) => {
2111
- var _a3;
2112
- return content.Key !== normalizedPath && !((_a3 = content.Key) == null ? void 0 : _a3.endsWith("/"));
2131
+ var _a2;
2132
+ return content.Key !== normalizedPath && !((_a2 = content.Key) == null ? void 0 : _a2.endsWith("/"));
2113
2133
  }).map((content) => __spreadProps(__spreadValues({}, content), {
2114
2134
  Name: content.Key.replace(normalizedPath, "") || content.Key,
2115
2135
  Location: `${this.link}${content.Key.replace(/^\//, "")}`,
@@ -2148,8 +2168,8 @@ var S3LocalstackUtil = class extends S3Util {
2148
2168
  return relativePath.replace(/\/$/, "");
2149
2169
  }).filter((dir) => dir);
2150
2170
  allFiles = (result.Contents || []).filter((content) => {
2151
- var _a2;
2152
- return content.Key !== normalizedPath && !((_a2 = content.Key) == null ? void 0 : _a2.endsWith("/"));
2171
+ var _a;
2172
+ return content.Key !== normalizedPath && !((_a = content.Key) == null ? void 0 : _a.endsWith("/"));
2153
2173
  }).map((content) => __spreadProps(__spreadValues({}, content), {
2154
2174
  Name: content.Key.replace(normalizedPath, "") || content.Key,
2155
2175
  Location: `${this.link}${content.Key.replace(/^\//, "")}`,
@@ -2171,43 +2191,66 @@ var S3LocalstackUtil = class extends S3Util {
2171
2191
  }
2172
2192
  };
2173
2193
 
2174
- // src/aws/sns.ts
2194
+ // src/aws/sns/sns-base.ts
2175
2195
  import { SNS } from "@aws-sdk/client-sns";
2176
- var SNSUtil = class {
2196
+ var SnsBase = class {
2177
2197
  constructor({
2198
+ logger,
2199
+ reqId,
2178
2200
  accessKeyId = AWSConfigSharingUtil.accessKeyId,
2179
2201
  secretAccessKey = AWSConfigSharingUtil.secretAccessKey,
2180
2202
  endpoint = AWSConfigSharingUtil.endpoint,
2181
- region = AWSConfigSharingUtil.region,
2182
- topicArn,
2183
- debug = false
2203
+ region = AWSConfigSharingUtil.region
2184
2204
  }) {
2185
2205
  __publicField(this, "sns");
2186
- __publicField(this, "topicArn");
2206
+ __publicField(this, "endpoint");
2207
+ __publicField(this, "region");
2208
+ __publicField(this, "logger");
2209
+ __publicField(this, "reqId");
2187
2210
  const credentials = { accessKeyId, secretAccessKey };
2188
2211
  const options = __spreadValues(__spreadValues(__spreadValues({}, accessKeyId && secretAccessKey && { credentials }), endpoint && { endpoint }), region && { region });
2189
- if (debug) {
2190
- console.log("LambdaUtil client options", options);
2191
- }
2212
+ this.endpoint = endpoint;
2213
+ this.region = region;
2214
+ this.logger = logger;
2215
+ this.reqId = reqId != null ? reqId : null;
2216
+ this.sns = new SNS(__spreadValues({}, options));
2217
+ }
2218
+ };
2219
+
2220
+ // src/aws/sns/sns-topic.ts
2221
+ var SnsTopic = class extends SnsBase {
2222
+ constructor(_a) {
2223
+ var _b = _a, { topicArn } = _b, props = __objRest(_b, ["topicArn"]);
2224
+ super(props);
2225
+ __publicField(this, "topicArn");
2192
2226
  this.topicArn = topicArn;
2193
- this.sns = new SNS(__spreadValues(__spreadValues(__spreadValues({}, credentials && { credentials }), endpoint && { endpoint }), region && { region }));
2194
2227
  }
2195
- publishTopicMessage(message) {
2228
+ publishMessage(message) {
2196
2229
  return __async(this, null, function* () {
2197
- this.sns.publish({
2230
+ return this.sns.publish({
2198
2231
  Message: typeof message === "string" ? message : JSON.stringify(message),
2199
2232
  TopicArn: this.topicArn
2200
2233
  });
2201
2234
  });
2202
2235
  }
2203
2236
  };
2237
+
2238
+ // src/aws/sns/sns-util.ts
2239
+ var SnsUtil = class extends SnsTopic {
2240
+ constructor(props) {
2241
+ super(props);
2242
+ }
2243
+ get client() {
2244
+ return this.sns;
2245
+ }
2246
+ };
2204
2247
  export {
2205
2248
  ACLs,
2206
2249
  AWSConfigSharingUtil,
2207
- IAMUtil,
2250
+ IamUtil,
2208
2251
  LambdaUtil,
2209
2252
  S3LocalstackUtil,
2210
2253
  S3Util,
2211
- SNSUtil,
2212
- SUPPORTED_IFRAME_EXTENSIONS
2254
+ SUPPORTED_IFRAME_EXTENSIONS,
2255
+ SnsUtil
2213
2256
  };