@visulima/storage 1.0.0-alpha.10 → 1.0.0-alpha.12

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/handler/http/fetch/index.js +3 -3
  3. package/dist/handler/http/hono/index.js +3 -3
  4. package/dist/handler/http/nextjs/index.js +3 -3
  5. package/dist/handler/http/node/index.js +3 -3
  6. package/dist/handler/http/solid-start/index.js +3 -3
  7. package/dist/handler/utils/upload-handlers.d.ts +2 -2
  8. package/dist/index.js +5 -5
  9. package/dist/openapi/index.js +5 -5
  10. package/dist/packem_shared/{AwsLightFile-tTneXZgG.js → AwsLightFile-C-Nd5rtl.js} +1 -1
  11. package/dist/packem_shared/{AwsLightMetaStorage-BWSOtVaN.js → AwsLightMetaStorage-BIDb5EPg.js} +1 -1
  12. package/dist/packem_shared/{AwsLightStorage-Blv-GP4v.js → AwsLightStorage-C893xyaW.js} +4 -4
  13. package/dist/packem_shared/{AzureFile-CesgFzps.js → AzureFile-C0kug4w4.js} +1 -1
  14. package/dist/packem_shared/{AzureSMetaStorage-CFs-OYJT.js → AzureSMetaStorage-BEbXX9Uk.js} +1 -0
  15. package/dist/packem_shared/{AzureStorage-B0v048hG.js → AzureStorage-CpvzFT4y.js} +9 -7
  16. package/dist/packem_shared/{BaseTransformer-C2gLib6v.js → BaseTransformer-9965D4pb.js} +1 -0
  17. package/dist/packem_shared/DiskStorage-BF10kayx.js +12 -0
  18. package/dist/packem_shared/{DiskStorageWithChecksum-BRl-V5x2.js → DiskStorageWithChecksum-pu9u6IF7.js} +20 -9
  19. package/dist/packem_shared/{File-Bb3P23dr.js → File-CPUhj3DI.js} +1 -1
  20. package/dist/packem_shared/{GCSFile-BIEunhAN.js → GCSFile-DaDiCKE2.js} +1 -1
  21. package/dist/packem_shared/{GCSMetaStorage-CNX_Nc7d.js → GCSMetaStorage-BH6j7TM2.js} +1 -1
  22. package/dist/packem_shared/{GCStorage-kdkXVebX.js → GCStorage-BBHFEg7F.js} +10 -6
  23. package/dist/packem_shared/{LocalMetaStorage-CZHhKkMd.js → LocalMetaStorage-BnllcjV9.js} +2 -2
  24. package/dist/packem_shared/{MediaTransformer-D6658DL1.js → MediaTransformer-BRRqYA0E.js} +9 -4
  25. package/dist/packem_shared/{Multipart-CRV21AUU.js → Multipart-BzzvNxt4.js} +3 -3
  26. package/dist/packem_shared/{Multipart-D2ryPMjD.js → Multipart-DLtFLQ8s.js} +2 -2
  27. package/dist/packem_shared/{NetlifyBlobFile-CXzyjqrD.js → NetlifyBlobFile-CfyJtGWN.js} +1 -1
  28. package/dist/packem_shared/{NetlifyBlobMetaStorage-DxZ5aDvD.js → NetlifyBlobMetaStorage-DIkZ2umW.js} +1 -1
  29. package/dist/packem_shared/{NetlifyBlobStorage-CLPtjHqd.js → NetlifyBlobStorage-pZX0_VdO.js} +4 -4
  30. package/dist/packem_shared/{Rest-DjwU3puo.js → Rest-DEa7IA9R.js} +3 -3
  31. package/dist/packem_shared/{Rest-DcxBMBjU.js → Rest-qhMbCn5a.js} +3 -3
  32. package/dist/packem_shared/{S3File-DZiyk9Qt.js → S3File-BXCuJaQZ.js} +1 -1
  33. package/dist/packem_shared/{S3MetaStorage-Dz9aDabA.js → S3MetaStorage-yT4CznlV.js} +1 -0
  34. package/dist/packem_shared/{S3Storage-DHmTk-hU.js → S3Storage-2ZiheyWz.js} +4 -3
  35. package/dist/packem_shared/{Tus-DaN0FmOy.js → Tus-Ck0Hdle5.js} +3 -3
  36. package/dist/packem_shared/{Tus-DFVlZHaX.js → Tus-_0vCdHyB.js} +1 -1
  37. package/dist/packem_shared/{VercelBlobFile-BCg4aTEq.js → VercelBlobFile-DkFIIb9Q.js} +1 -1
  38. package/dist/packem_shared/{VercelBlobMetaStorage-Bd9F-VFm.js → VercelBlobMetaStorage-c0M-TvAR.js} +1 -1
  39. package/dist/packem_shared/{VercelBlobStorage-DD9LMOS6.js → VercelBlobStorage-CwgI91cP.js} +4 -4
  40. package/dist/packem_shared/{aws-light-meta-storage-DKJBgbR6.js → aws-light-meta-storage-BGZEiY3y.js} +3 -2
  41. package/dist/packem_shared/{base-handler-core-BoAqTyz7.js → base-handler-core-lVB-D59L.js} +6 -3
  42. package/dist/packem_shared/{base-handler-fetch-D4u2xits.js → base-handler-fetch-CitgN-Aw.js} +2 -2
  43. package/dist/packem_shared/{base-handler-node-DGzcHHAy.js → base-handler-node-BiO2DF87.js} +6 -5
  44. package/dist/packem_shared/{defaultCloudStorageFileNameValidation-DUuacjWv.js → defaultCloudStorageFileNameValidation-CGoYrGB2.js} +3 -3
  45. package/dist/packem_shared/{disk-storage-CD47QI30.js → disk-storage-CC6-FUG9.js} +36 -21
  46. package/dist/packem_shared/{gcs-meta-storage-BiQ1dySn.js → gcs-meta-storage-MsUrkgP6.js} +3 -2
  47. package/dist/packem_shared/{local-meta-storage-By-3SNBI.js → local-meta-storage-BlOk6m7F.js} +5 -7
  48. package/dist/packem_shared/{part-match-BMNqHDYD.js → part-match-Dt738Ddb.js} +3 -3
  49. package/dist/packem_shared/{path-CR6YkPXX-7R1-9CMk.js → path-aV9lMdcn-DMU5H1-h.js} +4 -3
  50. package/dist/packem_shared/{rest-base-D9URIFkc.js → rest-base-k1ory8uB.js} +2 -2
  51. package/dist/packem_shared/{restOpenApiSpec-D1JC_Jto.js → restOpenApiSpec-BBJ_SiPE.js} +1 -1
  52. package/dist/packem_shared/{s3-base-storage-C1DIHTYY.js → s3-base-storage-DSMObtht.js} +3 -3
  53. package/dist/packem_shared/{sharedGet-Cpo7QUyu.js → sharedGet-CkSLSnMd.js} +6 -3
  54. package/dist/packem_shared/{storage-C6NSXb8h.js → storage-CpJpqLdn.js} +21 -12
  55. package/dist/packem_shared/{transformOpenApiSpec-DWM5WtnN.js → transformOpenApiSpec-BodFhFls.js} +1 -1
  56. package/dist/packem_shared/{tusOpenApiSpec-mBZkl7he.js → tusOpenApiSpec-DzppyJTW.js} +1 -1
  57. package/dist/packem_shared/{validator-BeX_lJet.js → validator-DuO17wFF.js} +1 -0
  58. package/dist/packem_shared/{xhrOpenApiSpec-B1V5Dxrj.js → xhrOpenApiSpec-CXz7BC5J.js} +1 -1
  59. package/dist/storage/aws/index.js +3 -3
  60. package/dist/storage/aws/s3-base-storage.d.ts +1 -1
  61. package/dist/storage/aws/s3-storage.d.ts +1 -1
  62. package/dist/storage/aws/types.d.ts +1 -2
  63. package/dist/storage/aws-light/aws-light-storage.d.ts +3 -2
  64. package/dist/storage/aws-light/index.js +3 -3
  65. package/dist/storage/aws-light/types.d.ts +1 -2
  66. package/dist/storage/azure/azure-storage.d.ts +2 -2
  67. package/dist/storage/azure/index.js +3 -3
  68. package/dist/storage/azure/types.d.ts +1 -2
  69. package/dist/storage/gcs/gcs-storage.d.ts +2 -2
  70. package/dist/storage/gcs/index.js +3 -3
  71. package/dist/storage/gcs/types.d.ts +1 -2
  72. package/dist/storage/local/disk-storage.d.ts +1 -1
  73. package/dist/storage/local/index.js +3 -3
  74. package/dist/storage/local/local-meta-storage.d.ts +2 -7
  75. package/dist/storage/meta-storage-options.d.ts +11 -0
  76. package/dist/storage/meta-storage.d.ts +1 -1
  77. package/dist/storage/netlify-blob/index.js +3 -3
  78. package/dist/storage/netlify-blob/netlify-blob-meta-storage.d.ts +1 -2
  79. package/dist/storage/netlify-blob/netlify-blob-storage.d.ts +2 -2
  80. package/dist/storage/netlify-blob/types.d.ts +1 -2
  81. package/dist/storage/types.d.ts +2 -6
  82. package/dist/storage/vercel-blob/index.js +3 -3
  83. package/dist/storage/vercel-blob/types.d.ts +1 -2
  84. package/dist/storage/vercel-blob/vercel-blob-meta-storage.d.ts +1 -2
  85. package/dist/storage/vercel-blob/vercel-blob-storage.d.ts +2 -2
  86. package/dist/transformer/audio-transformer.js +1 -1
  87. package/dist/transformer/base-transformer.d.ts +1 -1
  88. package/dist/transformer/image-transformer.js +1 -1
  89. package/dist/transformer/index.js +2 -2
  90. package/dist/transformer/transformer-config.d.ts +16 -0
  91. package/dist/transformer/types.d.ts +2 -15
  92. package/dist/transformer/video-transformer.js +1 -1
  93. package/dist/utils/types.d.ts +1 -1
  94. package/package.json +8 -9
  95. package/dist/packem_shared/DiskStorage-Ck5yGQsq.js +0 -12
@@ -1,8 +1,8 @@
1
1
  import { put, del, copy, list } from '@vercel/blob';
2
- import { g as getFileStatus, p as partMatch, a as detectFileTypeFromBuffer } from './part-match-BMNqHDYD.js';
3
- import { B as BaseStorage, t as toMilliseconds } from './storage-C6NSXb8h.js';
4
- import { L as LocalMetaStorage } from './local-meta-storage-By-3SNBI.js';
5
- import VercelBlobFile from './VercelBlobFile-BCg4aTEq.js';
2
+ import { g as getFileStatus, p as partMatch, a as detectFileTypeFromBuffer } from './part-match-Dt738Ddb.js';
3
+ import { B as BaseStorage, t as toMilliseconds } from './storage-CpJpqLdn.js';
4
+ import { L as LocalMetaStorage } from './local-meta-storage-BlOk6m7F.js';
5
+ import VercelBlobFile from './VercelBlobFile-DkFIIb9Q.js';
6
6
  import { u as updateSize } from './update-size-CCGm6i1J.js';
7
7
  import { h as hasContent } from './has-content-CY66ehMK.js';
8
8
 
@@ -11,7 +11,7 @@ const parseXml = (text) => {
11
11
  const matches = [...cleanText.matchAll(tagRegex)];
12
12
  for (const match of matches) {
13
13
  const [, tagName, content] = match;
14
- if (tagName && content && content.trim()) {
14
+ if (tagName && content?.trim()) {
15
15
  if (result[tagName]) {
16
16
  if (!Array.isArray(result[tagName])) {
17
17
  result[tagName] = [result[tagName]];
@@ -26,7 +26,7 @@ const parseXml = (text) => {
26
26
  let nestedMatch;
27
27
  while ((nestedMatch = nestedRegex.exec(cleanText)) !== null) {
28
28
  const [, tagName, innerContent] = nestedMatch;
29
- if (tagName && innerContent && innerContent.includes("<")) {
29
+ if (tagName && innerContent?.includes("<")) {
30
30
  const nested = parseXml(innerContent);
31
31
  if (Object.keys(nested).length > 0) {
32
32
  result[tagName] = nested;
@@ -396,6 +396,7 @@ class AwsLightMetaStorage extends MetaStorage {
396
396
  throw error;
397
397
  });
398
398
  }
399
+ config;
399
400
  adapter;
400
401
  bucket;
401
402
  async get(id) {
@@ -31,11 +31,14 @@ const readBody = (request, encoding = "utf8", limit) => new Promise((resolve, re
31
31
  request.setEncoding(encoding);
32
32
  request.on("data", (chunk) => {
33
33
  if (body.length + chunk.length > limit) {
34
- return reject(new Error("Request body length limit exceeded"));
34
+ reject(new Error("Request body length limit exceeded"));
35
+ return;
35
36
  }
36
37
  body += chunk;
37
38
  });
38
- request.once("end", () => resolve(body));
39
+ request.once("end", () => {
40
+ resolve(body);
41
+ });
39
42
  });
40
43
  const getHeader = (request, name, all = false) => {
41
44
  const raw = request.headers?.[name.toLowerCase()];
@@ -223,7 +226,7 @@ class BaseHandlerCore extends EventEmitter {
223
226
  */
224
227
  // eslint-disable-next-line class-methods-use-this
225
228
  parseRangeHeader(rangeHeader, fileSize) {
226
- if (!rangeHeader || !rangeHeader.startsWith("bytes=")) {
229
+ if (!rangeHeader?.startsWith("bytes=")) {
227
230
  return void 0;
228
231
  }
229
232
  const ranges = rangeHeader.slice(6).split(",");
@@ -1,7 +1,7 @@
1
1
  import { H as HeaderUtilities, h as httpErrorsExports } from './headers-YLRp1dLo.js';
2
2
  import { ERRORS, isUploadError } from './ERRORS-D0apMqnc.js';
3
- import { B as BaseHandlerCore, p as pick } from './base-handler-core-BoAqTyz7.js';
4
- import { i as isValidationError } from './validator-BeX_lJet.js';
3
+ import { B as BaseHandlerCore, p as pick } from './base-handler-core-lVB-D59L.js';
4
+ import { i as isValidationError } from './validator-DuO17wFF.js';
5
5
  import { waitForStorage } from './waitForStorage-Cscw85sx.js';
6
6
 
7
7
  class BaseHandlerFetch extends BaseHandlerCore {
@@ -3,8 +3,8 @@ import { H as HeaderUtilities, h as httpErrorsExports, c as createHttpError } fr
3
3
  import mime from 'mime';
4
4
  import { ERRORS, isUploadError } from './ERRORS-D0apMqnc.js';
5
5
  import { match } from 'path-to-regexp';
6
- import { p as pick, B as BaseHandlerCore, s as setHeaders, d as getRealPath, u as uuidRegex } from './base-handler-core-BoAqTyz7.js';
7
- import { i as isValidationError } from './validator-BeX_lJet.js';
6
+ import { p as pick, B as BaseHandlerCore, s as setHeaders, d as getRealPath, u as uuidRegex } from './base-handler-core-lVB-D59L.js';
7
+ import { i as isValidationError } from './validator-DuO17wFF.js';
8
8
  import { waitForStorage } from './waitForStorage-Cscw85sx.js';
9
9
  import { PassThrough } from 'node:stream';
10
10
  import { e as convertHeadersToString } from './response-builder-BtnRiBUI.js';
@@ -82,8 +82,9 @@ const createRangeLimitedStream = (sourceStream, start, end) => {
82
82
  const pipeWithBackpressure = (source, destination, sendError) => {
83
83
  let isDestroyed = false;
84
84
  const cleanup = () => {
85
- if (isDestroyed)
85
+ if (isDestroyed) {
86
86
  return;
87
+ }
87
88
  isDestroyed = true;
88
89
  source.destroy();
89
90
  };
@@ -522,7 +523,7 @@ class BaseHandlerNode extends BaseHandlerCore {
522
523
  // eslint-disable-next-line sonarjs/cognitive-complexity
523
524
  async get(request, _response) {
524
525
  const pathMatch = filePathUrlMatcher(getRealPath(request));
525
- if (pathMatch && pathMatch.params.uuid) {
526
+ if (pathMatch?.params.uuid) {
526
527
  const { ext, metadata, uuid: rawUuid } = pathMatch.params;
527
528
  const uuid = ext ? rawUuid.replace(new RegExp(String.raw`\.${ext}$`), "") : rawUuid;
528
529
  if (metadata === "metadata" && getRealPath(request).endsWith("/metadata")) {
@@ -675,7 +676,7 @@ class BaseHandlerNode extends BaseHandlerCore {
675
676
  */
676
677
  async download(request, response) {
677
678
  const pathMatch = filePathUrlMatcher(getRealPath(request));
678
- if (!pathMatch || !pathMatch.params.uuid || !uuidRegex.test(pathMatch.params.uuid)) {
679
+ if (!pathMatch?.params.uuid || !uuidRegex.test(pathMatch.params.uuid)) {
679
680
  throw createHttpError(404, "File not found");
680
681
  }
681
682
  const { ext, uuid } = pathMatch.params;
@@ -5,7 +5,7 @@ import 'type-is';
5
5
  import './NoOpMetrics-DhAk5rXc.js';
6
6
  import './cache-B88MXQ_2.js';
7
7
  import './ERRORS-D0apMqnc.js';
8
- export { B as BaseStorage, d as defaultCloudStorageFileNameValidation, a as defaultFilesystemFileNameValidation } from './storage-C6NSXb8h.js';
9
- import './validator-BeX_lJet.js';
10
- import './path-CR6YkPXX-7R1-9CMk.js';
8
+ export { B as BaseStorage, d as defaultCloudStorageFileNameValidation, a as defaultFilesystemFileNameValidation } from './storage-CpJpqLdn.js';
9
+ import './validator-DuO17wFF.js';
10
+ import './path-aV9lMdcn-DMU5H1-h.js';
11
11
  import './is-expired-CTThU1q5.js';
@@ -4,14 +4,14 @@ import { PassThrough, Transform, pipeline } from 'node:stream';
4
4
  import { g as getDefaultExportFromCjs } from './_commonjsHelpers-BqLXS_qQ.js';
5
5
  import require$$0 from 'crypto';
6
6
  import require$$1 from 'fs';
7
- import { g as getFileStatus, p as partMatch, d as detectFileTypeFromStream } from './part-match-BMNqHDYD.js';
7
+ import { g as getFileStatus, p as partMatch, d as detectFileTypeFromStream } from './part-match-Dt738Ddb.js';
8
8
  import { throwErrorCode, isUploadError, ERRORS } from './ERRORS-D0apMqnc.js';
9
9
  import { createHash } from 'node:crypto';
10
- import { B as BaseStorage, a as defaultFilesystemFileNameValidation, t as toMilliseconds } from './storage-C6NSXb8h.js';
11
- import { a as assertValidFileOrDirectoryPath, g as getFileInfoType, e as ensureDir, t as toPath, i as isAccessible, L as LocalMetaStorage, b as readFile, r as remove } from './local-meta-storage-By-3SNBI.js';
12
- import File from './File-Bb3P23dr.js';
10
+ import { B as BaseStorage, a as defaultFilesystemFileNameValidation, t as toMilliseconds } from './storage-CpJpqLdn.js';
11
+ import { a as assertValidFileOrDirectoryPath, g as getFileInfoType, e as ensureDir, t as toPath, i as isAccessible, L as LocalMetaStorage, b as readFile, r as remove } from './local-meta-storage-BlOk6m7F.js';
12
+ import File from './File-CPUhj3DI.js';
13
13
  import { createRequire } from 'node:module';
14
- import { d as dirname, r as resolve, j as join, n as normalize, b as basename, i as isAbsolute } from './path-CR6YkPXX-7R1-9CMk.js';
14
+ import { d as dirname, r as resolve, j as join, n as normalize, b as basename, i as isAbsolute } from './path-aV9lMdcn-DMU5H1-h.js';
15
15
  import { u as updateSize } from './update-size-CCGm6i1J.js';
16
16
  import { h as hasContent } from './has-content-CY66ehMK.js';
17
17
 
@@ -35,7 +35,7 @@ const ensureFile = async (filePath) => {
35
35
  try {
36
36
  const stat = await lstat(filePath);
37
37
  if (!stat.isFile()) {
38
- throw new Error(`Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`);
38
+ throw new Error(`Ensure path exists, expected 'file', got '${String(getFileInfoType(stat))}'`);
39
39
  }
40
40
  } catch (error) {
41
41
  if (error.code === "ENOENT") {
@@ -56,7 +56,7 @@ class WalkError extends Error {
56
56
  * @param root The root directory path where the walk operation started or encountered the error.
57
57
  */
58
58
  constructor(cause, root) {
59
- super(`${cause instanceof Error ? cause.message : cause} for path "${root}"`);
59
+ super(`${cause instanceof Error ? cause.message : String(cause)} for path "${root}"`);
60
60
  this.cause = cause;
61
61
  this.root = root;
62
62
  }
@@ -136,26 +136,28 @@ async function* walk(directory, {
136
136
  return;
137
137
  }
138
138
  try {
139
- for await (const entry of await readdir(directory, {
139
+ const entries = await readdir(directory, {
140
140
  withFileTypes: true
141
- })) {
141
+ });
142
+ for (const entry of entries) {
142
143
  let path = join(directory, entry.name);
143
144
  if (entry.isSymbolicLink()) {
144
145
  if (followSymlinks) {
145
146
  path = await realpath(path);
146
147
  } else if (includeSymlinks && walkInclude(path, extensions, mappedMatch, mappedSkip)) {
147
148
  yield {
148
- isDirectory: entry.isDirectory,
149
- isFile: entry.isFile,
150
- isSymbolicLink: entry.isSymbolicLink,
149
+ isDirectory: () => entry.isDirectory(),
150
+ isFile: () => entry.isFile(),
151
+ isSymbolicLink: () => entry.isSymbolicLink(),
151
152
  name: entry.name,
152
153
  path
153
154
  };
155
+ continue;
154
156
  } else {
155
157
  continue;
156
158
  }
157
159
  }
158
- if (entry.isSymbolicLink() || entry.isDirectory()) {
160
+ if (entry.isDirectory()) {
159
161
  yield* walk(path, {
160
162
  extensions,
161
163
  followSymlinks,
@@ -321,6 +323,9 @@ class StreamChecksum extends Transform {
321
323
  this.encoding = encoding;
322
324
  this.hash = createHash(algorithm);
323
325
  }
326
+ checksum;
327
+ algorithm;
328
+ encoding;
324
329
  length = 0;
325
330
  digest = "";
326
331
  hash;
@@ -369,6 +374,7 @@ class StreamLength extends Transform {
369
374
  super();
370
375
  this.limit = limit;
371
376
  }
377
+ limit;
372
378
  length = 0;
373
379
  /**
374
380
  * Transform method that counts bytes and enforces size limits.
@@ -770,15 +776,22 @@ class DiskStorage extends BaseStorage {
770
776
  cleanupStreams();
771
777
  resolve([Number.NaN, code]);
772
778
  };
773
- lengthChecker.on("error", () => failWithCode(ERRORS.FILE_CONFLICT));
774
- checksumChecker.on("error", () => failWithCode(ERRORS.CHECKSUM_MISMATCH));
775
- part.body.on("aborted", () => failWithCode(keepPartial ? void 0 : ERRORS.REQUEST_ABORTED));
779
+ lengthChecker.on("error", () => {
780
+ failWithCode(ERRORS.FILE_CONFLICT);
781
+ });
782
+ checksumChecker.on("error", () => {
783
+ failWithCode(ERRORS.CHECKSUM_MISMATCH);
784
+ });
785
+ part.body.on("aborted", () => {
786
+ failWithCode(keepPartial ? void 0 : ERRORS.REQUEST_ABORTED);
787
+ });
776
788
  part.body.on("error", (error) => {
777
789
  cleanupStreams();
778
790
  reject(error);
779
791
  });
780
792
  if (signal?.aborted) {
781
- return failWithCode(keepPartial ? void 0 : ERRORS.REQUEST_ABORTED);
793
+ failWithCode(keepPartial ? void 0 : ERRORS.REQUEST_ABORTED);
794
+ return;
782
795
  }
783
796
  if (signal) {
784
797
  signal.addEventListener("abort", () => {
@@ -793,12 +806,14 @@ class DiskStorage extends BaseStorage {
793
806
  pipeline(part.body, lengthChecker, checksumChecker, destination, (error) => {
794
807
  if (error) {
795
808
  cleanupStreams();
796
- if (signal && signal.aborted) {
797
- return resolve([Number.NaN, keepPartial ? void 0 : ERRORS.REQUEST_ABORTED]);
809
+ if (signal?.aborted) {
810
+ resolve([Number.NaN, keepPartial ? void 0 : ERRORS.REQUEST_ABORTED]);
811
+ return;
798
812
  }
799
- return resolve([Number.NaN, ERRORS.FILE_ERROR]);
813
+ resolve([Number.NaN, ERRORS.FILE_ERROR]);
814
+ return;
800
815
  }
801
- return resolve([part.start + destination.bytesWritten]);
816
+ resolve([part.start + destination.bytesWritten]);
802
817
  });
803
818
  });
804
819
  }
@@ -7,14 +7,14 @@ import GCSConfig from './GCSConfig-vPP22kN6.js';
7
7
  import { h as hasContent } from './has-content-CY66ehMK.js';
8
8
 
9
9
  var name = "@visulima/storage";
10
- var version = "1.0.0-alpha.9";
10
+ var version = "1.0.0-alpha.11";
11
11
  const package_ = {
12
12
  name: name,
13
13
  version: version};
14
14
 
15
15
  const getRangeEnd = (range) => {
16
16
  const match = range.match(/(\d+)-(\d+)/);
17
- const end = match && match[2] ? +match[2] : 0;
17
+ const end = match?.[2] ? +match[2] : 0;
18
18
  return end > 0 ? end + 1 : 0;
19
19
  };
20
20
  const buildContentRange = (part) => {
@@ -84,6 +84,7 @@ class GCSMetaStorage extends MetaStorage {
84
84
  });
85
85
  }
86
86
  }
87
+ config;
87
88
  authClient;
88
89
  storageBaseURI;
89
90
  uploadBaseURI;
@@ -3,7 +3,7 @@ import { tmpdir } from 'node:os';
3
3
  import { throwErrorCode, ERRORS } from './ERRORS-D0apMqnc.js';
4
4
  import MetaStorage from './MetaStorage-pECeFOad.js';
5
5
  import { stringifyMetadata, parseMetadata } from './Metadata-DRLXeJ0F.js';
6
- import { a as normalizeWindowsPath, d as dirname, n as normalize, j as join } from './path-CR6YkPXX-7R1-9CMk.js';
6
+ import { a as normalizeWindowsPath, d as dirname, n as normalize, j as join } from './path-aV9lMdcn-DMU5H1-h.js';
7
7
  import { createRequire } from 'node:module';
8
8
 
9
9
  const F_OK = 0;
@@ -48,7 +48,7 @@ const ensureDir = async (directory) => {
48
48
  try {
49
49
  const fileInfo = await lstat(directory);
50
50
  if (!fileInfo.isDirectory()) {
51
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
51
+ throw new Error(`Ensure path exists, expected 'dir', got '${String(getFileInfoType(fileInfo))}'`);
52
52
  }
53
53
  return;
54
54
  } catch (error) {
@@ -64,7 +64,7 @@ const ensureDir = async (directory) => {
64
64
  }
65
65
  const fileInfo = await lstat(directory);
66
66
  if (!fileInfo.isDirectory()) {
67
- throw new Error(`Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`);
67
+ throw new Error(`Ensure path exists, expected 'dir', got '${String(getFileInfoType(fileInfo))}'`, { cause: error });
68
68
  }
69
69
  }
70
70
  };
@@ -485,7 +485,7 @@ const remove = async (path, options = {}) => {
485
485
  } catch {
486
486
  }
487
487
  try {
488
- await rm(path, { force: true, maxRetries: options?.maxRetries, recursive: true, retryDelay: options?.retryDelay });
488
+ await rm(path, { force: true, maxRetries: options.maxRetries, recursive: true, retryDelay: options.retryDelay });
489
489
  } catch {
490
490
  }
491
491
  };
@@ -558,9 +558,7 @@ const writeFile = async (path, content, options) => {
558
558
  await writeFile$1(temporaryPath, toUint8Array(content), { encoding: options.encoding, flag: options.flag });
559
559
  if (pathExists && !options.overwrite) {
560
560
  stat$1 = await stat(path);
561
- if (options.chown === void 0) {
562
- options.chown = { gid: stat$1.gid, uid: stat$1.uid };
563
- }
561
+ options.chown ??= { gid: stat$1.gid, uid: stat$1.uid };
564
562
  await rename(path, `${path}.bak`);
565
563
  }
566
564
  if (options.chown) {
@@ -50,7 +50,7 @@ const detectFileTypeFromStream = async (stream, options) => {
50
50
  resolve();
51
51
  return;
52
52
  }
53
- const timeout = setTimeout(() => resolve(), 10);
53
+ const timeout = setTimeout(resolve, 10);
54
54
  peekStream.once("data", () => {
55
55
  clearTimeout(timeout);
56
56
  resolve();
@@ -61,14 +61,14 @@ const detectFileTypeFromStream = async (stream, options) => {
61
61
  });
62
62
  }),
63
63
  new Promise((resolve) => {
64
- setTimeout(() => resolve(), 10);
64
+ setTimeout(resolve, 10);
65
65
  })
66
66
  ]);
67
67
  if (detectionPromise) {
68
68
  await Promise.race([
69
69
  detectionPromise.then(() => void 0),
70
70
  new Promise((resolve) => {
71
- setTimeout(() => resolve(), 150);
71
+ setTimeout(resolve, 150);
72
72
  })
73
73
  ]).catch(() => {
74
74
  });
@@ -8,6 +8,7 @@ const normalizeWindowsPath = (input = "") => {
8
8
  const UNC_REGEX = /^[/\\]{2}/;
9
9
  const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
10
10
  const DRIVE_LETTER_RE = /^[A-Z]:$/i;
11
+ const TRAILING_SLASH_RE = /\/$/;
11
12
  const cwd = () => {
12
13
  if (typeof process.cwd === "function") {
13
14
  return process.cwd().replaceAll("\\", "/");
@@ -111,7 +112,7 @@ const join = (...segments) => {
111
112
  continue;
112
113
  }
113
114
  if (path2.length > 0) {
114
- const pathTrailing = path2[path2.length - 1] === "/";
115
+ const pathTrailing = path2.at(-1) === "/";
115
116
  const segLeading = seg[0] === "/";
116
117
  const both = pathTrailing && segLeading;
117
118
  if (both) {
@@ -144,9 +145,9 @@ const resolve = function(...arguments_) {
144
145
  return resolvedPath.length > 0 ? resolvedPath : ".";
145
146
  };
146
147
  const dirname = (path2) => {
147
- const segments = normalizeWindowsPath(path2).replace(/\/$/, "").split("/").slice(0, -1);
148
+ const segments = normalizeWindowsPath(path2).replace(TRAILING_SLASH_RE, "").split("/").slice(0, -1);
148
149
  if (segments.length === 1 && DRIVE_LETTER_RE.test(segments[0])) {
149
- segments[0] += "/";
150
+ segments[0] = `${segments[0]}/`;
150
151
  }
151
152
  return segments.join("/") || (isAbsolute(path2) ? "/" : ".");
152
153
  };
@@ -1,6 +1,6 @@
1
1
  import { c as createHttpError } from './headers-YLRp1dLo.js';
2
2
  import { hasBody } from 'type-is';
3
- import { a as getHeader } from './base-handler-core-BoAqTyz7.js';
3
+ import { a as getHeader } from './base-handler-core-lVB-D59L.js';
4
4
  import { ERRORS } from './ERRORS-D0apMqnc.js';
5
5
  import { b as buildResponseFile, a as buildFileHeaders, c as buildChunkedUploadHeaders, d as buildFileMetadataHeaders } from './response-builder-BtnRiBUI.js';
6
6
 
@@ -136,7 +136,7 @@ const isUploadComplete = (chunks, totalSize) => {
136
136
  }
137
137
  const sorted = [...chunks].toSorted((a, b) => a.offset - b.offset);
138
138
  const firstChunk = sorted[0];
139
- if (!firstChunk || firstChunk.offset !== 0) {
139
+ if (firstChunk?.offset !== 0) {
140
140
  return false;
141
141
  }
142
142
  let currentEnd = firstChunk.length;
@@ -1,6 +1,6 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { createPaginationMetaSchemaObject, createPaginationSchemaObject } from '@visulima/pagination';
3
- import { sharedFileMetaSchemaObject, sharedErrorSchemaObject, sharedFileMetaExampleObject, sharedGetList, sharedGet, sharedGetMeta } from './sharedGet-Cpo7QUyu.js';
3
+ import { sharedFileMetaSchemaObject, sharedErrorSchemaObject, sharedFileMetaExampleObject, sharedGetList, sharedGet, sharedGetMeta } from './sharedGet-CkSLSnMd.js';
4
4
 
5
5
  const swaggerSpec = (origin, path, options) => {
6
6
  const { supportedTransformerFormat, tags, transformer } = { tags: ["REST"], transformer: false, ...options };
@@ -1,9 +1,9 @@
1
1
  import { Readable } from 'node:stream';
2
- import { p as partMatch, d as detectFileTypeFromStream, g as getFileStatus } from './part-match-BMNqHDYD.js';
2
+ import { p as partMatch, d as detectFileTypeFromStream, g as getFileStatus } from './part-match-Dt738Ddb.js';
3
3
  import { throwErrorCode, ERRORS } from './ERRORS-D0apMqnc.js';
4
- import { p as parseDuration, B as BaseStorage, b as parseBytes, t as toMilliseconds } from './storage-C6NSXb8h.js';
4
+ import { p as parseDuration, B as BaseStorage, b as parseBytes, t as toMilliseconds } from './storage-CpJpqLdn.js';
5
5
  import { createRetryWrapper } from './isRetryableError-Dycp7127.js';
6
- import { L as LocalMetaStorage } from './local-meta-storage-By-3SNBI.js';
6
+ import { L as LocalMetaStorage } from './local-meta-storage-BlOk6m7F.js';
7
7
  import { u as updateSize } from './update-size-CCGm6i1J.js';
8
8
  import { h as hasContent } from './has-content-CY66ehMK.js';
9
9
  import { i as isExpired } from './is-expired-CTThU1q5.js';
@@ -14,8 +14,9 @@ const createParameterGroup = (parameters, groupName) => parameters.map((paramete
14
14
  };
15
15
  });
16
16
  const getTransformationParameters = (transform, format = ["jpeg", "png", "webp", "avif", "tiff", "gif", "mp4", "webm", "mkv", "ogg", "mp3", "wav", "aac", "flac"]) => {
17
- if (!transform)
17
+ if (!transform) {
18
18
  return [];
19
+ }
19
20
  const commonParameters = createParameterGroup(
20
21
  [
21
22
  {
@@ -519,8 +520,9 @@ const getOrganizedTransformationParameters = (transform, format = ["jpeg", "png"
519
520
  return { groups, parameters };
520
521
  };
521
522
  const getTransformationHeaders = (transform) => {
522
- if (!transform)
523
+ if (!transform) {
523
524
  return {};
525
+ }
524
526
  const headers = {
525
527
  "X-Media-Type": {
526
528
  description: "Type of media (image/video/audio)",
@@ -545,8 +547,9 @@ const getTransformationHeaders = (transform) => {
545
547
  return headers;
546
548
  };
547
549
  const getTransformationErrorResponses = (transform) => {
548
- if (!transform)
550
+ if (!transform) {
549
551
  return {};
552
+ }
550
553
  return {
551
554
  400: {
552
555
  content: {
@@ -6,10 +6,20 @@ import NoOpMetrics from './NoOpMetrics-DhAk5rXc.js';
6
6
  import { N as NoOpCache } from './cache-B88MXQ_2.js';
7
7
  import { ErrorMap, throwErrorCode, ERRORS } from './ERRORS-D0apMqnc.js';
8
8
  import { LRUCache } from 'lru-cache';
9
- import { a as Validator } from './validator-BeX_lJet.js';
10
- import { n as normalize, i as isAbsolute } from './path-CR6YkPXX-7R1-9CMk.js';
9
+ import { a as Validator } from './validator-DuO17wFF.js';
10
+ import { n as normalize, i as isAbsolute } from './path-aV9lMdcn-DMU5H1-h.js';
11
11
  import { i as isExpired } from './is-expired-CTThU1q5.js';
12
12
 
13
+ const PARSE_BYTES_REGEX = /^(?<value>-?(?:\d+(([.,])\d+)*)?[.,]?\d+) *(?<type>bytes?|b|kb|kib|mb|mib|gb|gib|tb|tib|pb|pib|eb|eib|zb|zib|yb|yib|(kilo|kibi|mega|mebi|giga|gibi|tera|tebi|peta|pebi|exa|exbi|zetta|zebi|yotta|yobi)?bytes)?$/i;
14
+ const KIBI_REGEX = /^KIBI/;
15
+ const MIBI_REGEX = /^MIBI/;
16
+ const GIBI_REGEX = /^GIBI/;
17
+ const TEBI_REGEX = /^TEBI/;
18
+ const PEBI_REGEX = /^PEBI/;
19
+ const EXBI_REGEX = /^EXBI/;
20
+ const ZEBI_REGEX = /^ZEBI/;
21
+ const YIBI_REGEX = /^YIBI/;
22
+ const IB_SUFFIX_REGEX = /^(.)IB$/;
13
23
  const BYTE_SIZES = {
14
24
  iec: [
15
25
  {
@@ -176,7 +186,7 @@ const fromBase = (base) => {
176
186
  if (base === 10) {
177
187
  return 1e3;
178
188
  }
179
- throw new TypeError(`Unsupported base.`);
189
+ throw new Error("Unsupported base.");
180
190
  };
181
191
  const parseBytes = (value, options) => {
182
192
  const config = {
@@ -191,15 +201,13 @@ const parseBytes = (value, options) => {
191
201
  if (value.length > 100) {
192
202
  throw new TypeError("Value exceeds the maximum length of 100 characters.");
193
203
  }
194
- const match = /^(?<value>-?(?:\d+(([.,])\d+)*)?[.,]?\d+) *(?<type>bytes?|b|kb|kib|mb|mib|gb|gib|tb|tib|pb|pib|eb|eib|zb|zib|yb|yib|(kilo|kibi|mega|mebi|giga|gibi|tera|tebi|peta|pebi|exa|exbi|zetta|zebi|yotta|yobi)?bytes)?$/i.exec(
195
- value
196
- );
204
+ const match = PARSE_BYTES_REGEX.exec(value);
197
205
  const groups = match?.groups;
198
206
  if (!groups) {
199
207
  return Number.NaN;
200
208
  }
201
209
  const localizedNumber = parseLocalizedNumber(groups.value, config.locale);
202
- const type = (groups.type ?? "Bytes").toUpperCase().replace(/^KIBI/, "KILO").replace(/^MIBI/, "MEGA").replace(/^GIBI/, "GIGA").replace(/^TEBI/, "TERA").replace(/^PEBI/, "PETA").replace(/^EXBI/, "EXA").replace(/^ZEBI/, "ZETTA").replace(/^YIBI/, "YOTTA").replace(/^(.)IB$/, "$1B");
210
+ const type = (groups.type ?? "Bytes").toUpperCase().replace(KIBI_REGEX, "KILO").replace(MIBI_REGEX, "MEGA").replace(GIBI_REGEX, "GIGA").replace(TEBI_REGEX, "TERA").replace(PEBI_REGEX, "PETA").replace(EXBI_REGEX, "EXA").replace(ZEBI_REGEX, "ZETTA").replace(YIBI_REGEX, "YOTTA").replace(IB_SUFFIX_REGEX, "$1B");
203
211
  const level = BYTE_SIZES[config.units].findIndex((unit) => unit.short[0].toUpperCase() === type[0]);
204
212
  const base = fromBase(config.base);
205
213
  return localizedNumber * base ** level;
@@ -294,14 +302,15 @@ const durationLanguage = createDurationLanguage(
294
302
  const validateDurationLanguage = (language) => {
295
303
  const requiredProperties = ["y", "mo", "w", "d", "h", "m", "s", "ms", "future", "past"];
296
304
  for (const property of requiredProperties) {
297
- if (!Object.prototype.hasOwnProperty.call(language, property)) {
305
+ if (!Object.hasOwn(language, property)) {
298
306
  throw new TypeError(`Missing required property: ${property}`);
299
307
  }
300
308
  }
301
309
  if (typeof language.future !== "string" || typeof language.past !== "string") {
302
310
  throw new TypeError("Properties future and past must be of type string");
303
311
  }
304
- for (const property of ["y", "mo", "w", "d", "h", "m", "s", "ms"]) {
312
+ const unitProperties = ["y", "mo", "w", "d", "h", "m", "s", "ms"];
313
+ for (const property of unitProperties) {
305
314
  if (typeof language[property] !== "string" && typeof language[property] !== "function") {
306
315
  throw new TypeError(`Property ${property} must be of type string or function`);
307
316
  }
@@ -340,6 +349,7 @@ const ESCAPE_REGEX = /[-/\\^$*+?.()|[\]{}]/g;
340
349
  const ISO_FORMAT = /^PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?$/i;
341
350
  const COLON_FORMAT = /^(?:(\d+):)?(?:(\d+):)?(\d+)$/;
342
351
  const NUMERIC_STRING_REGEX = /^[+-]?\d+(?:\.\d+)?$/;
352
+ const SIGN_PREFIX_REGEX = /^[-+]/;
343
353
  const parseDuration = (value, options) => {
344
354
  if (typeof value !== "string" || value.length === 0) {
345
355
  return void 0;
@@ -378,14 +388,13 @@ const parseDuration = (value, options) => {
378
388
  if (colonMatch) {
379
389
  let hours = 0;
380
390
  let minutes = 0;
381
- let seconds = 0;
382
391
  if (colonMatch[2] !== void 0) {
383
392
  hours = Number.parseInt(colonMatch[1] ?? "0", 10);
384
393
  minutes = Number.parseInt(colonMatch[2], 10);
385
394
  } else if (colonMatch[1] !== void 0) {
386
395
  minutes = Number.parseInt(colonMatch[1], 10);
387
396
  }
388
- seconds = Number.parseInt(colonMatch[3] ?? "0", 10);
397
+ const seconds = Number.parseInt(colonMatch[3] ?? "0", 10);
389
398
  return hours * 36e5 + minutes * 6e4 + seconds * 1e3;
390
399
  }
391
400
  const currentUnitMapKeys = Object.keys(currentUnitMap);
@@ -409,7 +418,7 @@ const parseDuration = (value, options) => {
409
418
  }
410
419
  const trimmedNumberString = numberString.trim();
411
420
  const sign = trimmedNumberString.startsWith("-") ? -1 : 1;
412
- const absNumberString = trimmedNumberString.replace(/^[-+]/, "");
421
+ const absNumberString = trimmedNumberString.replace(SIGN_PREFIX_REGEX, "");
413
422
  const parsedNumber = Number.parseFloat(absNumberString);
414
423
  const unitKey = currentUnitMap[unitString.toLowerCase()];
415
424
  if (unitKey === void 0) {
@@ -1,6 +1,6 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { createPaginationMetaSchemaObject, createPaginationSchemaObject } from '@visulima/pagination';
3
- import { sharedFileMetaSchemaObject, sharedErrorSchemaObject, sharedFileMetaExampleObject } from './sharedGet-Cpo7QUyu.js';
3
+ import { sharedFileMetaSchemaObject, sharedErrorSchemaObject, sharedFileMetaExampleObject } from './sharedGet-CkSLSnMd.js';
4
4
 
5
5
  const swaggerSpec = (path = "/", tags = ["Transform"]) => {
6
6
  const pathHash = createHash("sha256").update(path).digest("base64");
@@ -1,6 +1,6 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { createPaginationMetaSchemaObject, createPaginationSchemaObject } from '@visulima/pagination';
3
- import { sharedGet, sharedFileMetaSchemaObject, sharedErrorSchemaObject, sharedFileMetaExampleObject, sharedGetList, sharedGetMeta } from './sharedGet-Cpo7QUyu.js';
3
+ import { sharedGet, sharedFileMetaSchemaObject, sharedErrorSchemaObject, sharedFileMetaExampleObject, sharedGetList, sharedGetMeta } from './sharedGet-CkSLSnMd.js';
4
4
 
5
5
  const swaggerSpec = (path, options) => {
6
6
  const { supportedTransformerFormat, tags, transformer } = { tags: ["Tus"], transformer: false, ...options };
@@ -39,6 +39,7 @@ class Validator {
39
39
  constructor(prefix = "ValidationError") {
40
40
  this.prefix = prefix;
41
41
  }
42
+ prefix;
42
43
  validators = {};
43
44
  /**
44
45
  * Adds validation rules to the validator.
@@ -1,6 +1,6 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { createPaginationMetaSchemaObject, createPaginationSchemaObject } from '@visulima/pagination';
3
- import { sharedFileMetaSchemaObject, sharedErrorSchemaObject, sharedFileMetaExampleObject, sharedGetList, sharedGet, sharedGetMeta } from './sharedGet-Cpo7QUyu.js';
3
+ import { sharedFileMetaSchemaObject, sharedErrorSchemaObject, sharedFileMetaExampleObject, sharedGetList, sharedGet, sharedGetMeta } from './sharedGet-CkSLSnMd.js';
4
4
 
5
5
  const swaggerSpec = (origin, path, options) => {
6
6
  const { supportedTransformerFormat, tags, transformer } = { tags: ["Multipart"], transformer: false, ...options };
@@ -1,3 +1,3 @@
1
- export { default as S3File } from '../../packem_shared/S3File-DZiyk9Qt.js';
2
- export { default as S3MetaStorage } from '../../packem_shared/S3MetaStorage-Dz9aDabA.js';
3
- export { default as S3Storage } from '../../packem_shared/S3Storage-DHmTk-hU.js';
1
+ export { default as S3File } from '../../packem_shared/S3File-BXCuJaQZ.js';
2
+ export { default as S3MetaStorage } from '../../packem_shared/S3MetaStorage-yT4CznlV.js';
3
+ export { default as S3Storage } from '../../packem_shared/S3Storage-2ZiheyWz.js';
@@ -131,7 +131,7 @@ export interface S3ApiOperations {
131
131
  * Contains all shared business logic for S3 operations.
132
132
  * @template TFile The file type used by this storage backend.
133
133
  */
134
- export declare abstract class S3BaseStorage<TFile extends S3CompatibleFile = S3CompatibleFile> extends BaseStorage<TFile, FileReturn> {
134
+ export declare abstract class S3BaseStorage<TFile extends S3CompatibleFile = S3CompatibleFile> extends BaseStorage<TFile> {
135
135
  checksumTypes: string[];
136
136
  protected bucket: string;
137
137
  protected meta: MetaStorage<TFile>;
@@ -48,7 +48,7 @@ import type { AwsError, S3StorageOptions } from "./types.d.ts";
48
48
  * - ❌ getUrl: Not implemented (presigned URLs available via buildPresigned for clientDirectUpload)
49
49
  * - ❌ getUploadUrl: Not implemented (presigned URLs available via buildPresigned for clientDirectUpload)
50
50
  */
51
- declare class S3Storage extends S3BaseStorage<S3File> {
51
+ declare class S3Storage extends S3BaseStorage {
52
52
  static readonly name: string;
53
53
  private s3Api;
54
54
  constructor(config: S3StorageOptions);