@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.cjs CHANGED
@@ -85,16 +85,19 @@ var index_exports = {};
85
85
  __export(index_exports, {
86
86
  ACLs: () => ACLs,
87
87
  AWSConfigSharingUtil: () => AWSConfigSharingUtil,
88
- IAMUtil: () => IAMUtil,
88
+ IamUtil: () => IamUtil,
89
89
  LambdaUtil: () => LambdaUtil,
90
90
  S3LocalstackUtil: () => S3LocalstackUtil,
91
91
  S3Util: () => S3Util,
92
- SNSUtil: () => SNSUtil,
93
- SUPPORTED_IFRAME_EXTENSIONS: () => SUPPORTED_IFRAME_EXTENSIONS
92
+ SUPPORTED_IFRAME_EXTENSIONS: () => SUPPORTED_IFRAME_EXTENSIONS,
93
+ SnsUtil: () => SnsUtil
94
94
  });
95
95
  module.exports = __toCommonJS(index_exports);
96
96
 
97
- // src/aws/iam.ts
97
+ // src/aws/iam/iam-commands.ts
98
+ var import_client_iam2 = require("@aws-sdk/client-iam");
99
+
100
+ // src/aws/iam/iam-base.ts
98
101
  var import_client_iam = require("@aws-sdk/client-iam");
99
102
 
100
103
  // src/aws/configuration.ts
@@ -127,149 +130,159 @@ __publicField(_AWSConfigSharingUtil, "endpoint");
127
130
  __publicField(_AWSConfigSharingUtil, "region");
128
131
  var AWSConfigSharingUtil = _AWSConfigSharingUtil;
129
132
 
130
- // src/aws/iam.ts
131
- var IAMUtil = class {
133
+ // src/aws/iam/iam-base.ts
134
+ var IamBase = class {
132
135
  constructor({
136
+ logger,
137
+ reqId,
133
138
  accessKeyId = AWSConfigSharingUtil.accessKeyId,
134
139
  secretAccessKey = AWSConfigSharingUtil.secretAccessKey,
135
140
  endpoint = AWSConfigSharingUtil.endpoint,
136
- region = AWSConfigSharingUtil.region,
137
- debug = false
138
- } = {}) {
141
+ region = AWSConfigSharingUtil.region
142
+ }) {
139
143
  __publicField(this, "iam");
144
+ __publicField(this, "endpoint");
145
+ __publicField(this, "region");
146
+ __publicField(this, "logger");
147
+ __publicField(this, "reqId");
140
148
  const credentials = { accessKeyId, secretAccessKey };
141
149
  const options = __spreadValues(__spreadValues(__spreadValues({}, accessKeyId && secretAccessKey && { credentials }), endpoint && { endpoint }), region && { region });
142
- if (debug) {
143
- console.log("IAMUtil client options", options);
144
- }
150
+ this.endpoint = endpoint;
151
+ this.region = region;
152
+ this.logger = logger;
153
+ this.reqId = reqId != null ? reqId : null;
145
154
  this.iam = new import_client_iam.IAMClient(options);
146
155
  }
147
- get client() {
148
- return this.iam;
149
- }
150
- getUserList() {
156
+ execute(command, options) {
151
157
  return __async(this, null, function* () {
152
- const command = new import_client_iam.ListUsersCommand({});
153
- return this.iam.send(command);
158
+ return this.iam.send(command, options);
154
159
  });
155
160
  }
161
+ };
162
+
163
+ // src/aws/iam/iam-commands.ts
164
+ var IamCommands = class extends IamBase {
165
+ constructor(_a) {
166
+ var props = __objRest(_a, []);
167
+ super(props);
168
+ }
156
169
  listUsers(maxItems) {
157
170
  return __async(this, null, function* () {
158
171
  try {
159
- const command = new import_client_iam.ListUsersCommand({ MaxItems: maxItems });
160
- const response = yield this.iam.send(command);
172
+ const command = new import_client_iam2.ListUsersCommand({ MaxItems: maxItems });
173
+ const response = yield this.execute(command);
161
174
  return response.Users;
162
175
  } catch (error) {
163
- console.error("Error listing IAM users:", error);
176
+ console.error("Error IAM users list:", error);
164
177
  return null;
165
178
  }
166
179
  });
167
180
  }
168
181
  };
169
182
 
170
- // src/aws/lambda.ts
171
- var import_client_lambda = require("@aws-sdk/client-lambda");
183
+ // src/aws/iam/iam-util.ts
184
+ var IamUtil = class extends IamCommands {
185
+ constructor(props) {
186
+ super(props);
187
+ }
188
+ get client() {
189
+ return this.iam;
190
+ }
191
+ };
172
192
 
173
- // src/utils/logger.ts
174
- var import_stack_trace_logger = require("stack-trace-logger");
175
- 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;
176
- var _a;
177
- var logger = new import_stack_trace_logger.Logger(__spreadValues({
178
- serviceName: process.env.SERVICE_NAME || "SERVER",
179
- loggingModeLevel: process.env.LOGGING_MODE,
180
- lineTraceLevels: (_a = process.env.LOGGING_STACK_TRACE_LEVELS) == null ? void 0 : _a.split(","),
181
- stackTraceLines: { error: 3, warn: 3, info: 1 },
182
- tags: ["reqId?", "url?"],
183
- runLocally: true
184
- }, includeCloudWatchOptions && {
185
- transportCloudWatchOptions: {
186
- awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID,
187
- awsSecretKey: process.env.AWS_SECRET_ACCESS_KEY,
188
- awsRegion: process.env.AWS_REGION,
189
- logGroupName: process.env.AWS_LOG_GROUP_NAME,
190
- logStreamName: process.env.AWS_LOG_STREAM_NAME,
191
- retentionInDays: +process.env.AWS_LOG_RETENTION_IN_DAY
192
- }
193
- }));
193
+ // src/aws/lambda/lambda-events.ts
194
+ var import_client_lambda2 = require("@aws-sdk/client-lambda");
194
195
 
195
- // src/aws/lambda.ts
196
- var LambdaUtil = class {
196
+ // src/aws/lambda/lambda-base.ts
197
+ var import_client_lambda = require("@aws-sdk/client-lambda");
198
+ var LambdaBase = class {
197
199
  constructor({
200
+ logger,
201
+ reqId,
198
202
  accessKeyId = AWSConfigSharingUtil.accessKeyId,
199
203
  secretAccessKey = AWSConfigSharingUtil.secretAccessKey,
200
204
  endpoint = AWSConfigSharingUtil.endpoint,
201
- region = AWSConfigSharingUtil.region,
202
- serviceFunctionName,
203
- debug = false
205
+ region = AWSConfigSharingUtil.region
204
206
  }) {
205
207
  __publicField(this, "lambda");
206
- __publicField(this, "serviceFunctionName");
208
+ __publicField(this, "endpoint");
209
+ __publicField(this, "region");
210
+ __publicField(this, "logger");
211
+ __publicField(this, "reqId");
207
212
  const credentials = { accessKeyId, secretAccessKey };
208
213
  const options = __spreadValues(__spreadValues(__spreadValues({}, accessKeyId && secretAccessKey && { credentials }), endpoint && { endpoint }), region && { region });
209
- if (debug) {
210
- console.log("LambdaUtil client options", options);
211
- }
214
+ this.endpoint = endpoint;
215
+ this.region = region;
216
+ this.logger = logger;
217
+ this.reqId = reqId != null ? reqId : null;
218
+ this.lambda = new import_client_lambda.Lambda(__spreadValues({}, options));
219
+ }
220
+ };
221
+
222
+ // src/aws/lambda/lambda-events.ts
223
+ var LambdaEvents = class extends LambdaBase {
224
+ constructor(_a) {
225
+ var _b = _a, { serviceFunctionName } = _b, props = __objRest(_b, ["serviceFunctionName"]);
226
+ super(props);
227
+ __publicField(this, "serviceFunctionName");
212
228
  this.serviceFunctionName = serviceFunctionName;
213
- this.lambda = new import_client_lambda.Lambda(__spreadValues(__spreadValues(__spreadValues({}, credentials && { credentials }), endpoint && { endpoint }), region && { region }));
214
229
  }
215
230
  directInvoke(_0) {
216
231
  return __async(this, arguments, function* ({
217
232
  payload = {},
218
- invocationType = import_client_lambda.InvocationType.Event
233
+ invocationType = import_client_lambda2.InvocationType.Event
219
234
  }) {
220
- var _a2;
235
+ var _a, _b, _c;
236
+ const FunctionName = this.serviceFunctionName;
221
237
  const Payload = JSON.stringify(payload);
222
238
  try {
223
- const command = new import_client_lambda.InvokeCommand({
224
- FunctionName: this.serviceFunctionName,
225
- Payload,
226
- InvocationType: invocationType
227
- });
239
+ const command = new import_client_lambda2.InvokeCommand({ FunctionName, Payload, InvocationType: invocationType });
228
240
  const data = yield this.lambda.send(command);
229
- if (invocationType === import_client_lambda.InvocationType.RequestResponse) {
230
- logger.info(null, "directInvoke lambda function response", { FunctionName, data });
241
+ if (invocationType === import_client_lambda2.InvocationType.RequestResponse) {
242
+ (_a = this.logger) == null ? void 0 : _a.debug(null, "directInvoke lambda function response", {
243
+ FunctionName,
244
+ data,
245
+ InvocationType: import_client_lambda2.InvocationType
246
+ });
231
247
  }
232
- const status = (_a2 = data.StatusCode) != null ? _a2 : 200;
248
+ const status = (_b = data.StatusCode) != null ? _b : 200;
233
249
  const result = data.Payload;
234
250
  return status >= 200 && status < 300 ? result : Promise.reject(result);
235
251
  } catch (err) {
236
- logger.error(null, "failed to directInvoke lambda function", {
237
- err,
238
- Payload,
239
- FunctionName
240
- });
252
+ (_c = this.logger) == null ? void 0 : _c.error(null, "failed to directInvoke lambda function", { err, Payload, FunctionName });
241
253
  throw err;
242
254
  }
243
255
  });
244
256
  }
245
257
  runLambdaInDryRunMode(payload) {
246
258
  return __async(this, null, function* () {
247
- return this.directInvoke({
248
- payload,
249
- invocationType: import_client_lambda.InvocationType.DryRun
250
- });
259
+ return this.directInvoke({ payload, invocationType: import_client_lambda2.InvocationType.DryRun });
251
260
  });
252
261
  }
253
262
  triggerLambdaEvent(payload) {
254
263
  return __async(this, null, function* () {
255
- return this.directInvoke({
256
- payload,
257
- invocationType: import_client_lambda.InvocationType.Event
258
- });
264
+ return this.directInvoke({ payload, invocationType: import_client_lambda2.InvocationType.Event });
259
265
  });
260
266
  }
261
267
  runAndGetLambdaResponse(payload) {
262
268
  return __async(this, null, function* () {
263
- return this.directInvoke({
264
- payload,
265
- invocationType: import_client_lambda.InvocationType.RequestResponse
266
- });
269
+ return this.directInvoke({ payload, invocationType: import_client_lambda2.InvocationType.RequestResponse });
267
270
  });
268
271
  }
269
272
  };
270
273
 
274
+ // src/aws/lambda/lambda-util.ts
275
+ var LambdaUtil = class extends LambdaEvents {
276
+ constructor(props) {
277
+ super(props);
278
+ }
279
+ get client() {
280
+ return this.lambda;
281
+ }
282
+ };
283
+
271
284
  // src/aws/s3/s3-util.localstack.ts
272
- var import_client_s36 = require("@aws-sdk/client-s3");
285
+ var import_client_s37 = require("@aws-sdk/client-s3");
273
286
 
274
287
  // src/aws/s3/s3-stream.ts
275
288
  var import_pathe2 = require("pathe");
@@ -395,8 +408,8 @@ var getNormalizedPath = (directoryPath) => {
395
408
  return decodeURIComponent((directoryPath == null ? void 0 : directoryPath.trim().replace(/^\/+/, "").replace(/\/+$/, "").replace(/\/+/g, "/")) || "");
396
409
  };
397
410
  var getFileSize = (maxFileSize, defaultMaxFileSize) => {
398
- var _a2;
399
- const fileSizeUnitValue = (_a2 = maxFileSize != null ? maxFileSize : defaultMaxFileSize) != null ? _a2 : "";
411
+ var _a;
412
+ const fileSizeUnitValue = (_a = maxFileSize != null ? maxFileSize : defaultMaxFileSize) != null ? _a : "";
400
413
  const fileSize = typeof fileSizeUnitValue === "number" ? fileSizeUnitValue : (0, import_bytes.default)(fileSizeUnitValue);
401
414
  return fileSize != null ? fileSize : void 0;
402
415
  };
@@ -453,7 +466,7 @@ var import_node_http_handler = require("@smithy/node-http-handler");
453
466
  var import_client_s3 = require("@aws-sdk/client-s3");
454
467
  var S3Base = class {
455
468
  constructor({
456
- logger: logger2,
469
+ logger,
457
470
  reqId,
458
471
  accessKeyId = AWSConfigSharingUtil.accessKeyId,
459
472
  secretAccessKey = AWSConfigSharingUtil.secretAccessKey,
@@ -473,7 +486,7 @@ var S3Base = class {
473
486
  const options = __spreadValues(__spreadValues(__spreadValues({}, accessKeyId && secretAccessKey && { credentials }), endpoint && { endpoint }), region && { region });
474
487
  this.endpoint = endpoint;
475
488
  this.region = region;
476
- this.logger = logger2;
489
+ this.logger = logger;
477
490
  this.reqId = reqId != null ? reqId : null;
478
491
  this.localstack = localstack;
479
492
  const s3ClientParams = __spreadProps(__spreadValues(__spreadValues({}, options), s3ForcePathStyle && { forcePathStyle: s3ForcePathStyle }), {
@@ -495,8 +508,8 @@ var S3Base = class {
495
508
 
496
509
  // src/aws/s3/s3-bucket.ts
497
510
  var S3Bucket = class extends S3Base {
498
- constructor(_a2) {
499
- var _b = _a2, { bucket } = _b, props = __objRest(_b, ["bucket"]);
511
+ constructor(_a) {
512
+ var _b = _a, { bucket } = _b, props = __objRest(_b, ["bucket"]);
500
513
  super(props);
501
514
  __publicField(this, "_bucket");
502
515
  __publicField(this, "initializedBucket", "");
@@ -538,13 +551,13 @@ var S3Bucket = class extends S3Base {
538
551
  }
539
552
  isBucketExists() {
540
553
  return __async(this, null, function* () {
541
- var _a2, _b;
554
+ var _a, _b;
542
555
  const bucketName = this.bucket;
543
556
  try {
544
557
  yield this.execute(new import_client_s32.HeadBucketCommand({ Bucket: bucketName }));
545
558
  return true;
546
559
  } catch (err) {
547
- if (err.name !== "NotFound" && ((_a2 = err.$metadata) == null ? void 0 : _a2.httpStatusCode) !== 404) {
560
+ if (err.name !== "NotFound" && ((_a = err.$metadata) == null ? void 0 : _a.httpStatusCode) !== 404) {
548
561
  (_b = this.logger) == null ? void 0 : _b.error(this.reqId, "Error checking bucket:", err);
549
562
  throw err;
550
563
  } else {
@@ -555,11 +568,11 @@ var S3Bucket = class extends S3Base {
555
568
  }
556
569
  initAsPublicBucket() {
557
570
  return __async(this, null, function* () {
558
- var _a2, _b;
571
+ var _a, _b;
559
572
  const bucketName = this.bucket;
560
573
  const isExists = yield this.isBucketExists();
561
574
  if (isExists) {
562
- (_a2 = this.logger) == null ? void 0 : _a2.info(this.reqId, `Bucket already exists.`, { bucketName });
575
+ (_a = this.logger) == null ? void 0 : _a.info(this.reqId, `Bucket already exists.`, { bucketName });
563
576
  return;
564
577
  }
565
578
  const data = yield this.execute(new import_client_s32.CreateBucketCommand({ Bucket: bucketName }));
@@ -597,11 +610,11 @@ var S3Bucket = class extends S3Base {
597
610
  }
598
611
  initAsPrivateBucket(includeConstraintLocation) {
599
612
  return __async(this, null, function* () {
600
- var _a2, _b;
613
+ var _a, _b;
601
614
  const bucketName = this.bucket;
602
615
  const isExists = yield this.isBucketExists();
603
616
  if (isExists) {
604
- (_a2 = this.logger) == null ? void 0 : _a2.info(this.reqId, `Bucket already exists.`, { bucketName });
617
+ (_a = this.logger) == null ? void 0 : _a.info(this.reqId, `Bucket already exists.`, { bucketName });
605
618
  return;
606
619
  }
607
620
  const createParams = __spreadValues({
@@ -619,14 +632,14 @@ var S3Bucket = class extends S3Base {
619
632
  includeConstraintLocation = false,
620
633
  skipInitializedBucket = false
621
634
  } = {}) {
622
- var _a2;
635
+ var _a;
623
636
  const bucketName = this.bucket;
624
637
  if (skipInitializedBucket && this.initializedBucket === bucketName) {
625
638
  return;
626
639
  }
627
640
  const isExists = yield this.isBucketExists();
628
641
  if (isExists) {
629
- (_a2 = this.logger) == null ? void 0 : _a2.info(this.reqId, `Bucket already exists.`, { bucketName });
642
+ (_a = this.logger) == null ? void 0 : _a.info(this.reqId, `Bucket already exists.`, { bucketName });
630
643
  return;
631
644
  }
632
645
  const data = acl === "private" /* private */ ? yield this.initAsPrivateBucket(includeConstraintLocation) : yield this.initAsPublicBucket();
@@ -660,7 +673,7 @@ var S3Bucket = class extends S3Base {
660
673
  }
661
674
  bucketInfo(options) {
662
675
  return __async(this, null, function* () {
663
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
676
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
664
677
  const bucketName = this.bucket;
665
678
  const info = {
666
679
  name: bucketName,
@@ -673,7 +686,7 @@ var S3Bucket = class extends S3Base {
673
686
  const headBucketResponse = yield this.execute(
674
687
  new import_client_s32.HeadBucketCommand(__spreadValues({ Bucket: bucketName }, options))
675
688
  );
676
- (_a2 = this.logger) == null ? void 0 : _a2.debug("bucketInfo", "HeadBucketCommandOutput", headBucketResponse);
689
+ (_a = this.logger) == null ? void 0 : _a.debug("bucketInfo", "HeadBucketCommandOutput", headBucketResponse);
677
690
  info.exists = true;
678
691
  info.bucketRegion = headBucketResponse.BucketRegion;
679
692
  info.accessPointAlias = headBucketResponse.AccessPointAlias;
@@ -699,9 +712,9 @@ var S3Bucket = class extends S3Base {
699
712
  );
700
713
  (_e = this.logger) == null ? void 0 : _e.debug("bucketInfo", "GetBucketAclCommandOutput", aclResponse);
701
714
  info.acl = (_f = aclResponse.Grants) == null ? void 0 : _f.map((grant) => {
702
- var _a3;
715
+ var _a2;
703
716
  return {
704
- grantee: (_a3 = grant.Grantee) == null ? void 0 : _a3.Type,
717
+ grantee: (_a2 = grant.Grantee) == null ? void 0 : _a2.Type,
705
718
  permission: grant.Permission
706
719
  };
707
720
  });
@@ -768,11 +781,11 @@ var S3Bucket = class extends S3Base {
768
781
  }
769
782
  destroyBucket(forceDeleteAllFilesBeforeDestroyBucket = false) {
770
783
  return __async(this, null, function* () {
771
- var _a2;
784
+ var _a;
772
785
  const bucketName = this.bucket;
773
786
  const isExists = yield this.isBucketExists();
774
787
  if (!isExists) {
775
- (_a2 = this.logger) == null ? void 0 : _a2.debug(this.reqId, `Bucket not exists.`, { bucketName });
788
+ (_a = this.logger) == null ? void 0 : _a.debug(this.reqId, `Bucket not exists.`, { bucketName });
776
789
  return;
777
790
  }
778
791
  if (forceDeleteAllFilesBeforeDestroyBucket) {
@@ -792,7 +805,7 @@ var S3Directory = class extends S3Bucket {
792
805
  }
793
806
  directoryExists(directoryPath) {
794
807
  return __async(this, null, function* () {
795
- var _a2;
808
+ var _a;
796
809
  try {
797
810
  const normalizedKey = getNormalizedPath(directoryPath);
798
811
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
@@ -800,7 +813,7 @@ var S3Directory = class extends S3Bucket {
800
813
  yield this.execute(command);
801
814
  return true;
802
815
  } catch (error) {
803
- if (error.name === "NotFound" || ((_a2 = error.$metadata) == null ? void 0 : _a2.httpStatusCode) === 404) {
816
+ if (error.name === "NotFound" || ((_a = error.$metadata) == null ? void 0 : _a.httpStatusCode) === 404) {
804
817
  return false;
805
818
  }
806
819
  throw error;
@@ -818,7 +831,7 @@ var S3Directory = class extends S3Bucket {
818
831
  }
819
832
  deleteDirectory(directoryPath) {
820
833
  return __async(this, null, function* () {
821
- var _a2, _b, _c, _d, _e, _f, _g;
834
+ var _a, _b, _c, _d, _e, _f, _g;
822
835
  let normalizedPath = getNormalizedPath(directoryPath);
823
836
  if (!normalizedPath) throw new Error("No directory path provided");
824
837
  if (normalizedPath === "/") normalizedPath = "";
@@ -842,7 +855,7 @@ var S3Directory = class extends S3Bucket {
842
855
  }
843
856
  })
844
857
  );
845
- totalDeletedCount += (_b = (_a2 = deleteResult.Deleted) == null ? void 0 : _a2.length) != null ? _b : 0;
858
+ totalDeletedCount += (_b = (_a = deleteResult.Deleted) == null ? void 0 : _a.length) != null ? _b : 0;
846
859
  if (deleteResult.Errors && deleteResult.Errors.length > 0) {
847
860
  (_c = this.logger) == null ? void 0 : _c.warn(this.reqId, `Some objects failed to delete`, {
848
861
  directoryPath: normalizedPath,
@@ -887,7 +900,7 @@ var S3Directory = class extends S3Bucket {
887
900
  }
888
901
  directoryList(directoryPath) {
889
902
  return __async(this, null, function* () {
890
- var _a2;
903
+ var _a;
891
904
  let normalizedPath = getNormalizedPath(directoryPath);
892
905
  if (normalizedPath !== "/" && directoryPath !== "" && directoryPath !== void 0) normalizedPath += "/";
893
906
  else normalizedPath = this.localstack ? "" : "/";
@@ -920,7 +933,7 @@ var S3Directory = class extends S3Bucket {
920
933
  })
921
934
  );
922
935
  }
923
- (_a2 = this.logger) == null ? void 0 : _a2.debug(null, "#### directoryList", {
936
+ (_a = this.logger) == null ? void 0 : _a.debug(null, "#### directoryList", {
924
937
  normalizedPath,
925
938
  CommonPrefixes: result.CommonPrefixes,
926
939
  ContentFile: result.Contents
@@ -931,8 +944,8 @@ var S3Directory = class extends S3Bucket {
931
944
  return dir;
932
945
  }).filter((dir) => dir);
933
946
  const files = (result.Contents || []).filter((content) => {
934
- var _a3;
935
- return content.Key !== normalizedPath && !((_a3 = content.Key) == null ? void 0 : _a3.endsWith("/"));
947
+ var _a2;
948
+ return content.Key !== normalizedPath && !((_a2 = content.Key) == null ? void 0 : _a2.endsWith("/"));
936
949
  }).map((content) => __spreadProps(__spreadValues({}, content), {
937
950
  Name: content.Key.replace(normalizedPath, "") || content.Key,
938
951
  Location: `${this.link}${content.Key.replace(/^\//, "")}`,
@@ -971,8 +984,8 @@ var S3Directory = class extends S3Bucket {
971
984
  return relativePath.replace(/\/$/, "");
972
985
  }).filter((dir) => dir);
973
986
  allFiles = (result.Contents || []).filter((content) => {
974
- var _a2;
975
- return content.Key !== normalizedPath && !((_a2 = content.Key) == null ? void 0 : _a2.endsWith("/"));
987
+ var _a;
988
+ return content.Key !== normalizedPath && !((_a = content.Key) == null ? void 0 : _a.endsWith("/"));
976
989
  }).map((content) => __spreadProps(__spreadValues({}, content), {
977
990
  Name: content.Key.replace(normalizedPath, "") || content.Key,
978
991
  Location: `${this.link}${content.Key.replace(/^\//, "")}`,
@@ -1075,7 +1088,7 @@ var S3File = class extends S3Directory {
1075
1088
  }
1076
1089
  fileList(directoryPath, fileNamePrefix) {
1077
1090
  return __async(this, null, function* () {
1078
- var _a2, _b;
1091
+ var _a, _b;
1079
1092
  let normalizedPath = getNormalizedPath(directoryPath);
1080
1093
  if (normalizedPath !== "/" && directoryPath !== "" && directoryPath !== void 0) normalizedPath += "/";
1081
1094
  else normalizedPath = this.localstack ? "" : "/";
@@ -1086,11 +1099,11 @@ var S3File = class extends S3Directory {
1086
1099
  Delimiter: "/"
1087
1100
  });
1088
1101
  const result = yield this.execute(command);
1089
- const files = ((_a2 = result.Contents) != null ? _a2 : []).filter((v) => v).map(
1102
+ const files = ((_a = result.Contents) != null ? _a : []).filter((v) => v).map(
1090
1103
  (content) => {
1091
- var _a3, _b2, _c;
1104
+ var _a2, _b2, _c;
1092
1105
  return __spreadProps(__spreadValues({}, content), {
1093
- Name: (_b2 = (_a3 = content.Key) == null ? void 0 : _a3.replace(prefix, "")) != null ? _b2 : content.Key,
1106
+ Name: (_b2 = (_a2 = content.Key) == null ? void 0 : _a2.replace(prefix, "")) != null ? _b2 : content.Key,
1094
1107
  Location: content.Key ? `${this.link}${(_c = content.Key) == null ? void 0 : _c.replace(/^\//, "")}` : "",
1095
1108
  LastModified: content.LastModified ? new Date(content.LastModified) : null
1096
1109
  });
@@ -1107,7 +1120,7 @@ var S3File = class extends S3Directory {
1107
1120
  // 0-based: page 0 = items 0-99, page 1 = items 100-199, page 2 = items 200-299
1108
1121
  pageSize = 100
1109
1122
  } = {}) {
1110
- var _a2, _b;
1123
+ var _a, _b;
1111
1124
  let normalizedPath = getNormalizedPath(directoryPath);
1112
1125
  if (normalizedPath !== "/" && directoryPath !== "" && directoryPath !== void 0) normalizedPath += "/";
1113
1126
  else normalizedPath = "";
@@ -1126,11 +1139,11 @@ var S3File = class extends S3Directory {
1126
1139
  })
1127
1140
  );
1128
1141
  if (currentPage === pageNumber) {
1129
- resultFiles = ((_a2 = result.Contents) != null ? _a2 : []).filter((v) => v).map(
1142
+ resultFiles = ((_a = result.Contents) != null ? _a : []).filter((v) => v).map(
1130
1143
  (content) => {
1131
- var _a3, _b2;
1144
+ var _a2, _b2;
1132
1145
  return __spreadProps(__spreadValues({}, content), {
1133
- Name: (_b2 = (_a3 = content.Key) == null ? void 0 : _a3.replace(prefix, "")) != null ? _b2 : content.Key,
1146
+ Name: (_b2 = (_a2 = content.Key) == null ? void 0 : _a2.replace(prefix, "")) != null ? _b2 : content.Key,
1134
1147
  Location: content.Key ? `${this.link}${content.Key.replace(/^\//, "")}` : "",
1135
1148
  LastModified: content.LastModified ? new Date(content.LastModified) : null
1136
1149
  });
@@ -1157,7 +1170,7 @@ var S3File = class extends S3Directory {
1157
1170
  }
1158
1171
  taggingFile(fileKey, tag) {
1159
1172
  return __async(this, null, function* () {
1160
- var _a2;
1173
+ var _a;
1161
1174
  let normalizedKey = "";
1162
1175
  const tags = [].concat(tag);
1163
1176
  try {
@@ -1171,25 +1184,25 @@ var S3File = class extends S3Directory {
1171
1184
  yield this.execute(command);
1172
1185
  return true;
1173
1186
  } catch (error) {
1174
- (_a2 = this.logger) == null ? void 0 : _a2.warn(null, "failed to tagging file", { errMsg: error.message, fileKey: normalizedKey, tags });
1187
+ (_a = this.logger) == null ? void 0 : _a.warn(null, "failed to tagging file", { errMsg: error.message, fileKey: normalizedKey, tags });
1175
1188
  return false;
1176
1189
  }
1177
1190
  });
1178
1191
  }
1179
1192
  fileVersion(fileKey) {
1180
1193
  return __async(this, null, function* () {
1181
- var _a2, _b;
1194
+ var _a, _b;
1182
1195
  const normalizedKey = getNormalizedPath(fileKey);
1183
1196
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
1184
1197
  const command = new import_client_s34.GetObjectTaggingCommand({ Bucket: this.bucket, Key: normalizedKey });
1185
1198
  const result = yield this.execute(command);
1186
- const tag = (_a2 = result.TagSet) == null ? void 0 : _a2.find((tag2) => tag2.Key === "version");
1199
+ const tag = (_a = result.TagSet) == null ? void 0 : _a.find((tag2) => tag2.Key === "version");
1187
1200
  return (_b = tag == null ? void 0 : tag.Value) != null ? _b : "";
1188
1201
  });
1189
1202
  }
1190
1203
  fileUrl(fileKey, expiresIn = "15m") {
1191
1204
  return __async(this, null, function* () {
1192
- var _a2;
1205
+ var _a;
1193
1206
  let normalizedKey = getNormalizedPath(fileKey);
1194
1207
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
1195
1208
  const expiresInSeconds = typeof expiresIn === "number" ? expiresIn : (0, import_ms2.default)(expiresIn) / 1e3;
@@ -1198,19 +1211,19 @@ var S3File = class extends S3Directory {
1198
1211
  expiresIn: expiresInSeconds
1199
1212
  // is using 3600 it's will expire in 1 hour (default is 900 seconds = 15 minutes)
1200
1213
  });
1201
- (_a2 = this.logger) == null ? void 0 : _a2.info(null, "generate signed file url", { url, fileKey: normalizedKey, expiresIn });
1214
+ (_a = this.logger) == null ? void 0 : _a.info(null, "generate signed file url", { url, fileKey: normalizedKey, expiresIn });
1202
1215
  return url;
1203
1216
  });
1204
1217
  }
1205
1218
  sizeOf(fileKey, unit = "b") {
1206
1219
  return __async(this, null, function* () {
1207
- var _a2, _b, _c;
1220
+ var _a, _b, _c;
1208
1221
  const normalizedKey = getNormalizedPath(fileKey);
1209
1222
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
1210
1223
  try {
1211
1224
  const command = new import_client_s34.HeadObjectCommand({ Bucket: this.bucket, Key: normalizedKey });
1212
1225
  const headObject = yield this.execute(command);
1213
- const bytes2 = (_a2 = headObject.ContentLength) != null ? _a2 : 0;
1226
+ const bytes2 = (_a = headObject.ContentLength) != null ? _a : 0;
1214
1227
  return getUnitBytes(bytes2, unit);
1215
1228
  } catch (error) {
1216
1229
  if (error.name === "NotFound" || ((_b = error.$metadata) == null ? void 0 : _b.httpStatusCode) === 404) {
@@ -1223,7 +1236,7 @@ var S3File = class extends S3Directory {
1223
1236
  }
1224
1237
  fileExists(fileKey) {
1225
1238
  return __async(this, null, function* () {
1226
- var _a2;
1239
+ var _a;
1227
1240
  try {
1228
1241
  const normalizedKey = getNormalizedPath(fileKey);
1229
1242
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
@@ -1231,7 +1244,7 @@ var S3File = class extends S3Directory {
1231
1244
  yield this.execute(command);
1232
1245
  return true;
1233
1246
  } catch (error) {
1234
- if (error.name === "NotFound" || ((_a2 = error.$metadata) == null ? void 0 : _a2.httpStatusCode) === 404) {
1247
+ if (error.name === "NotFound" || ((_a = error.$metadata) == null ? void 0 : _a.httpStatusCode) === 404) {
1235
1248
  return false;
1236
1249
  }
1237
1250
  throw error;
@@ -1323,8 +1336,8 @@ var S3File = class extends S3Directory {
1323
1336
  // src/aws/s3/s3-stream.ts
1324
1337
  var pump = (0, import_util.promisify)(import_stream.pipeline);
1325
1338
  var S3Stream = class _S3Stream extends S3File {
1326
- constructor(_a2) {
1327
- var _b = _a2, { maxUploadFileSizeRestriction = "10GB", concurrencyVideoLimit = 0 } = _b, props = __objRest(_b, ["maxUploadFileSizeRestriction", "concurrencyVideoLimit"]);
1339
+ constructor(_a) {
1340
+ var _b = _a, { maxUploadFileSizeRestriction = "10GB", concurrencyVideoLimit = 0 } = _b, props = __objRest(_b, ["maxUploadFileSizeRestriction", "concurrencyVideoLimit"]);
1328
1341
  super(props);
1329
1342
  __publicField(this, "maxUploadFileSizeRestriction");
1330
1343
  __publicField(this, "s3Limiter");
@@ -1336,8 +1349,8 @@ var S3Stream = class _S3Stream extends S3File {
1336
1349
  cachingAge: _cachingAge = "1y"
1337
1350
  } = {}) => {
1338
1351
  return (req, res, next) => __async(this, null, function* () {
1339
- var _a2, _b, _c, _d, _e, _f, _g, _h;
1340
- 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);
1352
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1353
+ 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);
1341
1354
  if (!fileKey || fileKey === "/") {
1342
1355
  (_g = this.logger) == null ? void 0 : _g.warn(req.id, "image fileKey is required");
1343
1356
  next(Error("image fileKey is required"));
@@ -1380,8 +1393,8 @@ var S3Stream = class _S3Stream extends S3File {
1380
1393
  cachingAge: _cachingAge = "1h"
1381
1394
  } = {}) => {
1382
1395
  return (req, res, next) => __async(this, null, function* () {
1383
- var _a2, _b, _c, _d, _e, _f, _g, _h;
1384
- 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);
1396
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1397
+ 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);
1385
1398
  if (!fileKey) {
1386
1399
  (_g = this.logger) == null ? void 0 : _g.warn(req.id, "iframe fileKey is required");
1387
1400
  next(Error("iframe fileKey is required"));
@@ -1449,7 +1462,7 @@ var S3Stream = class _S3Stream extends S3File {
1449
1462
  Range,
1450
1463
  abortSignal
1451
1464
  } = {}) {
1452
- var _a2;
1465
+ var _a;
1453
1466
  let normalizedKey = getNormalizedPath(fileKey);
1454
1467
  if (!normalizedKey || normalizedKey === "/") throw new Error("No file key provided");
1455
1468
  try {
@@ -1472,7 +1485,7 @@ var S3Stream = class _S3Stream extends S3File {
1472
1485
  }
1473
1486
  };
1474
1487
  } catch (error) {
1475
- (_a2 = this.logger) == null ? void 0 : _a2.warn(this.reqId, "streamVideoFile error", {
1488
+ (_a = this.logger) == null ? void 0 : _a.warn(this.reqId, "streamVideoFile error", {
1476
1489
  Bucket: this.bucket,
1477
1490
  fileKey: normalizedKey,
1478
1491
  Range,
@@ -1494,8 +1507,8 @@ var S3Stream = class _S3Stream extends S3File {
1494
1507
  streamTimeoutMS = 3e4
1495
1508
  } = {}) {
1496
1509
  return (req, res, next) => __async(this, null, function* () {
1497
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1498
- 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);
1510
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1511
+ 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);
1499
1512
  ((_e = req.headers) == null ? void 0 : _e[headerField]) ? (_f = req.headers) == null ? void 0 : _f[headerField] : void 0;
1500
1513
  if (!fileKey || fileKey === "/") {
1501
1514
  (_g = this.logger) == null ? void 0 : _g.warn(req.id, "fileKey video stream is required");
@@ -1572,9 +1585,9 @@ var S3Stream = class _S3Stream extends S3File {
1572
1585
  res.end();
1573
1586
  }, streamTimeoutMS);
1574
1587
  res.once("close", () => {
1575
- var _a3;
1588
+ var _a2;
1576
1589
  clearTimeout(timeout);
1577
- (_a3 = body.destroy) == null ? void 0 : _a3.call(body);
1590
+ (_a2 = body.destroy) == null ? void 0 : _a2.call(body);
1578
1591
  req.off("close", onClose);
1579
1592
  });
1580
1593
  yield pump(body, res);
@@ -1617,8 +1630,8 @@ var S3Stream = class _S3Stream extends S3File {
1617
1630
  cachingAge: _cachingAge = "1h"
1618
1631
  } = {}) {
1619
1632
  return (req, res, next) => __async(this, null, function* () {
1620
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
1621
- 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);
1633
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1634
+ 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);
1622
1635
  if (!fileKey || fileKey === "/") {
1623
1636
  (_g = this.logger) == null ? void 0 : _g.warn(req.id, "fileKey stream is required");
1624
1637
  next(Error("fileKey stream is required"));
@@ -1627,9 +1640,9 @@ var S3Stream = class _S3Stream extends S3File {
1627
1640
  const abort = new AbortController();
1628
1641
  let stream = null;
1629
1642
  const onClose = () => {
1630
- var _a3;
1643
+ var _a2;
1631
1644
  abort.abort();
1632
- (_a3 = stream == null ? void 0 : stream.destroy) == null ? void 0 : _a3.call(stream);
1645
+ (_a2 = stream == null ? void 0 : stream.destroy) == null ? void 0 : _a2.call(stream);
1633
1646
  };
1634
1647
  req.once("close", onClose);
1635
1648
  let normalizedKey = getNormalizedPath(fileKey);
@@ -1671,14 +1684,14 @@ var S3Stream = class _S3Stream extends S3File {
1671
1684
  }
1672
1685
  res.setHeader("Access-Control-Expose-Headers", "Content-Type, Content-Disposition, Content-Length");
1673
1686
  stream.on("error", (err) => {
1674
- var _a3, _b2;
1675
- (_a3 = this.logger) == null ? void 0 : _a3.warn(this.reqId, "Stream error", { fileKey: normalizedKey, error: err });
1687
+ var _a2, _b2;
1688
+ (_a2 = this.logger) == null ? void 0 : _a2.warn(this.reqId, "Stream error", { fileKey: normalizedKey, error: err });
1676
1689
  abort.abort();
1677
1690
  (_b2 = stream == null ? void 0 : stream.destroy) == null ? void 0 : _b2.call(stream);
1678
1691
  });
1679
1692
  res.once("close", () => {
1680
- var _a3;
1681
- (_a3 = stream == null ? void 0 : stream.destroy) == null ? void 0 : _a3.call(stream);
1693
+ var _a2;
1694
+ (_a2 = stream == null ? void 0 : stream.destroy) == null ? void 0 : _a2.call(stream);
1682
1695
  req.off("close", onClose);
1683
1696
  });
1684
1697
  streamMethod || (streamMethod = canDisplayInline ? "pipe" : "pipeline");
@@ -1722,11 +1735,11 @@ var S3Stream = class _S3Stream extends S3File {
1722
1735
  compressionLevel = 5
1723
1736
  } = {}) {
1724
1737
  return (req, res, next) => __async(this, null, function* () {
1725
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1738
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1726
1739
  const abort = new AbortController();
1727
1740
  const onClose = () => abort.abort();
1728
1741
  try {
1729
- 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);
1742
+ 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);
1730
1743
  if (!fileKey || fileKey === "/") {
1731
1744
  (_g = this.logger) == null ? void 0 : _g.warn(req.id, "fileKey video stream is required");
1732
1745
  next(Error("fileKey video stream is required"));
@@ -1741,12 +1754,12 @@ var S3Stream = class _S3Stream extends S3File {
1741
1754
  req.once("close", onClose);
1742
1755
  (_h = this.logger) == null ? void 0 : _h.info(this.reqId, "Starting parallel file download...", { fileCount: fileKeys.length });
1743
1756
  const downloadPromises = fileKeys.map((fileKey2) => __async(this, null, function* () {
1744
- var _a3, _b2, _c2;
1757
+ var _a2, _b2, _c2;
1745
1758
  try {
1746
1759
  if (abort.signal.aborted) return null;
1747
1760
  const stream = yield this.getObjectFileStream(fileKey2, { abortSignal: abort.signal });
1748
1761
  if (!stream) {
1749
- (_a3 = this.logger) == null ? void 0 : _a3.warn(this.reqId, "File not found", { fileKey: fileKey2 });
1762
+ (_a2 = this.logger) == null ? void 0 : _a2.warn(this.reqId, "File not found", { fileKey: fileKey2 });
1750
1763
  return null;
1751
1764
  }
1752
1765
  const chunks = [];
@@ -1817,8 +1830,8 @@ var S3Stream = class _S3Stream extends S3File {
1817
1830
  res.setHeader("Content-Length", String(actualZipSize));
1818
1831
  res.setHeader("Access-Control-Expose-Headers", "Content-Type, Content-Disposition, Content-Length");
1819
1832
  actualArchive.on("error", (err) => {
1820
- var _a3;
1821
- (_a3 = this.logger) == null ? void 0 : _a3.error(this.reqId, "Archive error", { error: err });
1833
+ var _a2;
1834
+ (_a2 = this.logger) == null ? void 0 : _a2.error(this.reqId, "Archive error", { error: err });
1822
1835
  abort.abort();
1823
1836
  if (!res.headersSent) {
1824
1837
  next(err);
@@ -1934,18 +1947,18 @@ var S3Stream = class _S3Stream extends S3File {
1934
1947
  * Adds the uploaded file info to req.s3File
1935
1948
  */
1936
1949
  uploadSingleFileMW(fieldName, directoryPath, options = {}) {
1937
- var _a2;
1950
+ var _a;
1938
1951
  let normalizedPath = getNormalizedPath(directoryPath);
1939
1952
  if (normalizedPath !== "/" && directoryPath !== "" && directoryPath !== void 0) normalizedPath += "/";
1940
1953
  else normalizedPath = "";
1941
- (_a2 = this.logger) == null ? void 0 : _a2.debug(null, "####### uploadSingleFile", { directoryPath, normalizedPath, fieldName });
1954
+ (_a = this.logger) == null ? void 0 : _a.debug(null, "####### uploadSingleFile", { directoryPath, normalizedPath, fieldName });
1942
1955
  const upload = this.getUploadFileMW(normalizedPath, options);
1943
1956
  return (req, res, next) => {
1944
1957
  const mw = upload.single(fieldName);
1945
1958
  mw(req, res, (err) => {
1946
- var _a3, _b;
1959
+ var _a2, _b;
1947
1960
  if (err) {
1948
- (_a3 = this.logger) == null ? void 0 : _a3.error(this.reqId, "Single file upload error", { fieldName, error: err.message });
1961
+ (_a2 = this.logger) == null ? void 0 : _a2.error(this.reqId, "Single file upload error", { fieldName, error: err.message });
1949
1962
  return next(err);
1950
1963
  }
1951
1964
  if (req.file) {
@@ -1974,9 +1987,9 @@ var S3Stream = class _S3Stream extends S3File {
1974
1987
  return (req, res, next) => {
1975
1988
  const mw = upload.array(fieldName, maxFilesCount || void 0);
1976
1989
  mw(req, res, (err) => {
1977
- var _a2, _b;
1990
+ var _a, _b;
1978
1991
  if (err) {
1979
- (_a2 = this.logger) == null ? void 0 : _a2.error(this.reqId, "Multiple files upload error", { fieldName, error: err.message });
1992
+ (_a = this.logger) == null ? void 0 : _a.error(this.reqId, "Multiple files upload error", { fieldName, error: err.message });
1980
1993
  return next(err);
1981
1994
  }
1982
1995
  if (Array.isArray(req.files)) {
@@ -2003,9 +2016,9 @@ var S3Stream = class _S3Stream extends S3File {
2003
2016
  return (req, res, next) => {
2004
2017
  const anyUpload = maxCount ? upload.any() : upload.any();
2005
2018
  anyUpload(req, res, (err) => {
2006
- var _a2, _b;
2019
+ var _a, _b;
2007
2020
  if (err) {
2008
- (_a2 = this.logger) == null ? void 0 : _a2.error(this.reqId, "Any files upload error", { error: err.message });
2021
+ (_a = this.logger) == null ? void 0 : _a.error(this.reqId, "Any files upload error", { error: err.message });
2009
2022
  return next(err);
2010
2023
  }
2011
2024
  if (req.files && Array.isArray(req.files)) {
@@ -2084,10 +2097,14 @@ var S3Stream = class _S3Stream extends S3File {
2084
2097
  };
2085
2098
 
2086
2099
  // src/aws/s3/s3-util.ts
2100
+ var import_client_s36 = require("@aws-sdk/client-s3");
2087
2101
  var S3Util = class extends S3Stream {
2088
2102
  constructor(props) {
2089
2103
  super(props);
2090
2104
  }
2105
+ get client() {
2106
+ return this.s3Client;
2107
+ }
2091
2108
  };
2092
2109
 
2093
2110
  // src/aws/s3/s3-util.localstack.ts
@@ -2095,21 +2112,24 @@ var S3LocalstackUtil = class extends S3Util {
2095
2112
  constructor(props) {
2096
2113
  super(__spreadProps(__spreadValues({}, props), { localstack: true }));
2097
2114
  }
2115
+ get client() {
2116
+ return this.s3Client;
2117
+ }
2098
2118
  directoryList(directoryPath) {
2099
2119
  return __async(this, null, function* () {
2100
- var _a2;
2120
+ var _a;
2101
2121
  let normalizedPath = getNormalizedPath(directoryPath);
2102
2122
  if (normalizedPath !== "/" && directoryPath !== "" && directoryPath !== void 0) normalizedPath += "/";
2103
2123
  else normalizedPath = "";
2104
2124
  let result;
2105
2125
  result = yield this.execute(
2106
- new import_client_s36.ListObjectsV2Command({
2126
+ new import_client_s37.ListObjectsV2Command({
2107
2127
  Bucket: this.bucket,
2108
2128
  Prefix: normalizedPath,
2109
2129
  Delimiter: "/"
2110
2130
  })
2111
2131
  );
2112
- (_a2 = this.logger) == null ? void 0 : _a2.debug(null, "#### directoryList", {
2132
+ (_a = this.logger) == null ? void 0 : _a.debug(null, "#### directoryList", {
2113
2133
  normalizedPath,
2114
2134
  CommonPrefixes: result.CommonPrefixes,
2115
2135
  ContentFile: result.Contents
@@ -2120,8 +2140,8 @@ var S3LocalstackUtil = class extends S3Util {
2120
2140
  return dir;
2121
2141
  }).filter((dir) => dir);
2122
2142
  const files = (result.Contents || []).filter((content) => {
2123
- var _a3;
2124
- return content.Key !== normalizedPath && !((_a3 = content.Key) == null ? void 0 : _a3.endsWith("/"));
2143
+ var _a2;
2144
+ return content.Key !== normalizedPath && !((_a2 = content.Key) == null ? void 0 : _a2.endsWith("/"));
2125
2145
  }).map((content) => __spreadProps(__spreadValues({}, content), {
2126
2146
  Name: content.Key.replace(normalizedPath, "") || content.Key,
2127
2147
  Location: `${this.link}${content.Key.replace(/^\//, "")}`,
@@ -2146,7 +2166,7 @@ var S3LocalstackUtil = class extends S3Util {
2146
2166
  while (currentPage <= pageNumber) {
2147
2167
  let result;
2148
2168
  result = yield this.execute(
2149
- new import_client_s36.ListObjectsV2Command({
2169
+ new import_client_s37.ListObjectsV2Command({
2150
2170
  Bucket: this.bucket,
2151
2171
  Prefix: normalizedPath,
2152
2172
  Delimiter: "/",
@@ -2160,8 +2180,8 @@ var S3LocalstackUtil = class extends S3Util {
2160
2180
  return relativePath.replace(/\/$/, "");
2161
2181
  }).filter((dir) => dir);
2162
2182
  allFiles = (result.Contents || []).filter((content) => {
2163
- var _a2;
2164
- return content.Key !== normalizedPath && !((_a2 = content.Key) == null ? void 0 : _a2.endsWith("/"));
2183
+ var _a;
2184
+ return content.Key !== normalizedPath && !((_a = content.Key) == null ? void 0 : _a.endsWith("/"));
2165
2185
  }).map((content) => __spreadProps(__spreadValues({}, content), {
2166
2186
  Name: content.Key.replace(normalizedPath, "") || content.Key,
2167
2187
  Location: `${this.link}${content.Key.replace(/^\//, "")}`,
@@ -2183,44 +2203,67 @@ var S3LocalstackUtil = class extends S3Util {
2183
2203
  }
2184
2204
  };
2185
2205
 
2186
- // src/aws/sns.ts
2206
+ // src/aws/sns/sns-base.ts
2187
2207
  var import_client_sns = require("@aws-sdk/client-sns");
2188
- var SNSUtil = class {
2208
+ var SnsBase = class {
2189
2209
  constructor({
2210
+ logger,
2211
+ reqId,
2190
2212
  accessKeyId = AWSConfigSharingUtil.accessKeyId,
2191
2213
  secretAccessKey = AWSConfigSharingUtil.secretAccessKey,
2192
2214
  endpoint = AWSConfigSharingUtil.endpoint,
2193
- region = AWSConfigSharingUtil.region,
2194
- topicArn,
2195
- debug = false
2215
+ region = AWSConfigSharingUtil.region
2196
2216
  }) {
2197
2217
  __publicField(this, "sns");
2198
- __publicField(this, "topicArn");
2218
+ __publicField(this, "endpoint");
2219
+ __publicField(this, "region");
2220
+ __publicField(this, "logger");
2221
+ __publicField(this, "reqId");
2199
2222
  const credentials = { accessKeyId, secretAccessKey };
2200
2223
  const options = __spreadValues(__spreadValues(__spreadValues({}, accessKeyId && secretAccessKey && { credentials }), endpoint && { endpoint }), region && { region });
2201
- if (debug) {
2202
- console.log("LambdaUtil client options", options);
2203
- }
2224
+ this.endpoint = endpoint;
2225
+ this.region = region;
2226
+ this.logger = logger;
2227
+ this.reqId = reqId != null ? reqId : null;
2228
+ this.sns = new import_client_sns.SNS(__spreadValues({}, options));
2229
+ }
2230
+ };
2231
+
2232
+ // src/aws/sns/sns-topic.ts
2233
+ var SnsTopic = class extends SnsBase {
2234
+ constructor(_a) {
2235
+ var _b = _a, { topicArn } = _b, props = __objRest(_b, ["topicArn"]);
2236
+ super(props);
2237
+ __publicField(this, "topicArn");
2204
2238
  this.topicArn = topicArn;
2205
- this.sns = new import_client_sns.SNS(__spreadValues(__spreadValues(__spreadValues({}, credentials && { credentials }), endpoint && { endpoint }), region && { region }));
2206
2239
  }
2207
- publishTopicMessage(message) {
2240
+ publishMessage(message) {
2208
2241
  return __async(this, null, function* () {
2209
- this.sns.publish({
2242
+ return this.sns.publish({
2210
2243
  Message: typeof message === "string" ? message : JSON.stringify(message),
2211
2244
  TopicArn: this.topicArn
2212
2245
  });
2213
2246
  });
2214
2247
  }
2215
2248
  };
2249
+
2250
+ // src/aws/sns/sns-util.ts
2251
+ var SnsUtil = class extends SnsTopic {
2252
+ constructor(props) {
2253
+ super(props);
2254
+ }
2255
+ get client() {
2256
+ return this.sns;
2257
+ }
2258
+ };
2216
2259
  // Annotate the CommonJS export names for ESM import in node:
2217
2260
  0 && (module.exports = {
2218
2261
  ACLs,
2219
2262
  AWSConfigSharingUtil,
2220
- IAMUtil,
2263
+ IamUtil,
2221
2264
  LambdaUtil,
2222
2265
  S3LocalstackUtil,
2223
2266
  S3Util,
2224
- SNSUtil,
2225
- SUPPORTED_IFRAME_EXTENSIONS
2267
+ SUPPORTED_IFRAME_EXTENSIONS,
2268
+ SnsUtil
2226
2269
  });