@twin.org/blob-storage-service 0.0.1-next.35 → 0.0.1-next.36

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.
@@ -427,7 +427,7 @@ async function blobStorageGet(httpRequestContext, componentName, request) {
427
427
  const component = core.ComponentFactory.get(componentName);
428
428
  const result = await component.get(request.pathParams.id, {
429
429
  includeContent: core.Coerce.boolean(request.query?.includeContent),
430
- disableDecryption: core.Coerce.boolean(request.query?.disableDecryption),
430
+ decompress: core.Coerce.boolean(request.query?.decompress),
431
431
  overrideVaultKeyId: request.query?.overrideVaultKeyId
432
432
  }, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
433
433
  return {
@@ -449,20 +449,31 @@ async function blobStorageGetContent(httpRequestContext, componentName, request)
449
449
  core.Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
450
450
  core.Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
451
451
  const component = core.ComponentFactory.get(componentName);
452
+ const decompress = core.Coerce.boolean(request.query?.decompress);
452
453
  const result = await component.get(request.pathParams.id, {
453
454
  includeContent: true,
454
- disableDecryption: core.Coerce.boolean(request.query?.disableDecryption),
455
+ decompress,
455
456
  overrideVaultKeyId: request.query?.overrideVaultKeyId
456
457
  }, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
457
458
  const encodingFormat = result?.encodingFormat ?? web.MimeTypes.OctetStream;
459
+ let compressedEncodingFormat;
460
+ let compressedExtension = "";
461
+ // If the entry is compressed and we are not decompressing
462
+ // we need to override the encoding format to the compressed type
463
+ // and append an additional extension to the filename.
464
+ if (result.compression && !decompress) {
465
+ compressedEncodingFormat =
466
+ result.compression === blobStorageModels.BlobStorageCompressionType.Gzip ? web.MimeTypes.Gzip : web.MimeTypes.Zlib;
467
+ compressedExtension = `.${web.MimeTypeHelper.defaultExtension(compressedEncodingFormat)}`;
468
+ }
458
469
  let filename = request.query?.filename;
459
470
  if (!core.Is.stringValue(filename)) {
460
- filename = `file.${result.fileExtension ?? web.MimeTypeHelper.defaultExtension(encodingFormat)}`;
471
+ filename = `file.${result.fileExtension ?? web.MimeTypeHelper.defaultExtension(encodingFormat)}${compressedExtension}`;
461
472
  }
462
473
  return {
463
474
  body: core.Is.stringBase64(result.blob) ? core.Converter.base64ToBytes(result.blob) : new Uint8Array(),
464
475
  attachment: {
465
- mimeType: encodingFormat,
476
+ mimeType: compressedEncodingFormat ?? encodingFormat,
466
477
  filename,
467
478
  inline: !(request.query?.download ?? false)
468
479
  }
@@ -595,6 +606,7 @@ class BlobStorageService {
595
606
  * @param options Optional options for the creation of the blob.
596
607
  * @param options.disableEncryption Disables encryption if enabled by default.
597
608
  * @param options.overrideVaultKeyId Use a different vault key id for encryption, if not provided the default vault key id will be used.
609
+ * @param options.compress Optional compression type to use for the blob, defaults to no compression.*
598
610
  * @param options.namespace The namespace to use for storing, defaults to component configured namespace.
599
611
  * @param userIdentity The user identity to use with storage operations.
600
612
  * @param nodeIdentity The node identity to use with storage operations.
@@ -632,6 +644,9 @@ class BlobStorageService {
632
644
  core.Validation.asValidationError(this.CLASS_NAME, "metadata", validationFailures);
633
645
  }
634
646
  const blobHash = `sha256:${core.Converter.bytesToBase64(crypto.Sha256.sum256(storeBlob))}`;
647
+ if (!core.Is.empty(options?.compress)) {
648
+ storeBlob = await core.Compression.compress(storeBlob, options.compress);
649
+ }
635
650
  // If we have a vault connector then encrypt the data.
636
651
  if (encryptionEnabled) {
637
652
  if (core.Is.empty(this._vaultConnector)) {
@@ -650,7 +665,8 @@ class BlobStorageService {
650
665
  encodingFormat,
651
666
  fileExtension,
652
667
  metadata,
653
- isEncrypted: encryptionEnabled
668
+ isEncrypted: encryptionEnabled,
669
+ compression: options?.compress
654
670
  };
655
671
  const conditions = [];
656
672
  if (this._includeUserIdentity) {
@@ -673,8 +689,8 @@ class BlobStorageService {
673
689
  * @param id The id of the blob to get in urn format.
674
690
  * @param options Optional options for the retrieval of the blob.
675
691
  * @param options.includeContent Include the content, or just get the metadata.
676
- * @param options.disableDecryption Disables decryption if enabled by default.
677
692
  * @param options.overrideVaultKeyId Use a different vault key id for decryption, if not provided the default vault key id will be used.
693
+ * @param options.decompress If the content should be decompressed, if it was compressed when stored, defaults to true.
678
694
  * @param userIdentity The user identity to use with storage operations.
679
695
  * @param nodeIdentity The node identity to use with storage operations.
680
696
  * @returns The entry and data for the blob if it can be found.
@@ -683,9 +699,7 @@ class BlobStorageService {
683
699
  async get(id, options, userIdentity, nodeIdentity) {
684
700
  core.Urn.guard(this.CLASS_NAME, "id", id);
685
701
  const includeContent = options?.includeContent ?? false;
686
- const disableEncryption = options?.disableDecryption ?? false;
687
702
  const vaultKeyId = options?.overrideVaultKeyId ?? this._vaultKeyId;
688
- const decryptionEnabled = !disableEncryption && core.Is.stringValue(vaultKeyId);
689
703
  const conditions = [];
690
704
  if (this._includeUserIdentity) {
691
705
  core.Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
@@ -712,13 +726,17 @@ class BlobStorageService {
712
726
  if (core.Is.undefined(returnBlob)) {
713
727
  throw new core.NotFoundError(this.CLASS_NAME, "blobNotFound", id);
714
728
  }
715
- // If we have a vault connector then decrypt the data.
729
+ // If the data is encrypted then decrypt it.
730
+ const decryptionEnabled = blobEntry.isEncrypted && core.Is.stringValue(vaultKeyId);
716
731
  if (decryptionEnabled) {
717
732
  if (core.Is.empty(this._vaultConnector)) {
718
733
  throw new core.GeneralError(this.CLASS_NAME, "vaultConnectorNotConfigured");
719
734
  }
720
735
  returnBlob = await this._vaultConnector.decrypt(`${nodeIdentity}/${vaultKeyId}`, vaultModels.VaultEncryptionType.ChaCha20Poly1305, returnBlob);
721
736
  }
737
+ if (!core.Is.empty(blobEntry.compression) && (options?.decompress ?? true)) {
738
+ returnBlob = await core.Compression.decompress(returnBlob, blobEntry.compression);
739
+ }
722
740
  }
723
741
  const jsonLd = this.entryToJsonLd(blobEntry, returnBlob);
724
742
  return dataJsonLd.JsonLdProcessor.compact(jsonLd, jsonLd["@context"]);
@@ -766,7 +784,8 @@ class BlobStorageService {
766
784
  encodingFormat: encodingFormat ?? blobEntry.encodingFormat,
767
785
  fileExtension: fileExtension ?? blobEntry.fileExtension,
768
786
  metadata: metadata ?? blobEntry.metadata,
769
- isEncrypted: blobEntry.isEncrypted
787
+ isEncrypted: blobEntry.isEncrypted,
788
+ compression: blobEntry.compression
770
789
  };
771
790
  const conditions = [];
772
791
  if (this._includeUserIdentity) {
@@ -861,10 +880,6 @@ class BlobStorageService {
861
880
  sortDirection: orderDirection
862
881
  }
863
882
  ], undefined, cursor, pageSize);
864
- for (const entity of result.entities) {
865
- core.ObjectHelper.propertyDelete(entity, "nodeIdentity");
866
- core.ObjectHelper.propertyDelete(entity, "userIdentity");
867
- }
868
883
  let context = [
869
884
  standardsSchemaOrg.SchemaOrgContexts.ContextRoot,
870
885
  blobStorageModels.BlobStorageContexts.ContextRoot,
@@ -948,9 +963,7 @@ class BlobStorageService {
948
963
  if (core.Is.empty(entity$1)) {
949
964
  throw new core.NotFoundError(this.CLASS_NAME, "entityNotFound", id);
950
965
  }
951
- core.ObjectHelper.propertyDelete(entity$1, "nodeIdentity");
952
- core.ObjectHelper.propertyDelete(entity$1, "userIdentity");
953
- return entity$1;
966
+ return core.ObjectHelper.omit(entity$1, ["nodeIdentity", "userIdentity"]);
954
967
  }
955
968
  /**
956
969
  * Convert the entry to JSON-LD.
@@ -975,7 +988,9 @@ class BlobStorageService {
975
988
  encodingFormat: entry?.encodingFormat,
976
989
  fileExtension: entry?.fileExtension,
977
990
  metadata: entry?.metadata,
978
- blob: core.Is.uint8Array(blob) ? core.Converter.bytesToBase64(blob) : undefined
991
+ blob: core.Is.uint8Array(blob) ? core.Converter.bytesToBase64(blob) : undefined,
992
+ isEncrypted: entry.isEncrypted,
993
+ compression: entry.compression
979
994
  };
980
995
  return jsonLd;
981
996
  }
@@ -1021,6 +1036,10 @@ exports.BlobStorageEntry = class BlobStorageEntry {
1021
1036
  * Is the entry encrypted.
1022
1037
  */
1023
1038
  isEncrypted;
1039
+ /**
1040
+ * Is the entry compressed.
1041
+ */
1042
+ compression;
1024
1043
  /**
1025
1044
  * The user identity that created the blob.
1026
1045
  */
@@ -1071,6 +1090,10 @@ __decorate([
1071
1090
  entity.property({ type: "boolean" }),
1072
1091
  __metadata("design:type", Boolean)
1073
1092
  ], exports.BlobStorageEntry.prototype, "isEncrypted", void 0);
1093
+ __decorate([
1094
+ entity.property({ type: "string", optional: true }),
1095
+ __metadata("design:type", String)
1096
+ ], exports.BlobStorageEntry.prototype, "compression", void 0);
1074
1097
  __decorate([
1075
1098
  entity.property({ type: "string", optional: true }),
1076
1099
  __metadata("design:type", String)
@@ -1,6 +1,6 @@
1
1
  import { HttpParameterHelper } from '@twin.org/api-models';
2
- import { BlobStorageTypes, BlobStorageContexts, BlobStorageConnectorFactory } from '@twin.org/blob-storage-models';
3
- import { StringHelper, Guards, ComponentFactory, Coerce, Is, Converter, GeneralError, Validation, ObjectHelper, Urn, NotFoundError } from '@twin.org/core';
2
+ import { BlobStorageTypes, BlobStorageContexts, BlobStorageCompressionType, BlobStorageConnectorFactory } from '@twin.org/blob-storage-models';
3
+ import { StringHelper, Guards, ComponentFactory, Coerce, Is, Converter, GeneralError, Validation, Compression, ObjectHelper, Urn, NotFoundError } from '@twin.org/core';
4
4
  import { SchemaOrgContexts, SchemaOrgTypes, SchemaOrgDataTypes } from '@twin.org/standards-schema-org';
5
5
  import { HttpStatusCode, HeaderTypes, MimeTypes, MimeTypeHelper } from '@twin.org/web';
6
6
  import { Sha256 } from '@twin.org/crypto';
@@ -425,7 +425,7 @@ async function blobStorageGet(httpRequestContext, componentName, request) {
425
425
  const component = ComponentFactory.get(componentName);
426
426
  const result = await component.get(request.pathParams.id, {
427
427
  includeContent: Coerce.boolean(request.query?.includeContent),
428
- disableDecryption: Coerce.boolean(request.query?.disableDecryption),
428
+ decompress: Coerce.boolean(request.query?.decompress),
429
429
  overrideVaultKeyId: request.query?.overrideVaultKeyId
430
430
  }, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
431
431
  return {
@@ -447,20 +447,31 @@ async function blobStorageGetContent(httpRequestContext, componentName, request)
447
447
  Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
448
448
  Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
449
449
  const component = ComponentFactory.get(componentName);
450
+ const decompress = Coerce.boolean(request.query?.decompress);
450
451
  const result = await component.get(request.pathParams.id, {
451
452
  includeContent: true,
452
- disableDecryption: Coerce.boolean(request.query?.disableDecryption),
453
+ decompress,
453
454
  overrideVaultKeyId: request.query?.overrideVaultKeyId
454
455
  }, httpRequestContext.userIdentity, httpRequestContext.nodeIdentity);
455
456
  const encodingFormat = result?.encodingFormat ?? MimeTypes.OctetStream;
457
+ let compressedEncodingFormat;
458
+ let compressedExtension = "";
459
+ // If the entry is compressed and we are not decompressing
460
+ // we need to override the encoding format to the compressed type
461
+ // and append an additional extension to the filename.
462
+ if (result.compression && !decompress) {
463
+ compressedEncodingFormat =
464
+ result.compression === BlobStorageCompressionType.Gzip ? MimeTypes.Gzip : MimeTypes.Zlib;
465
+ compressedExtension = `.${MimeTypeHelper.defaultExtension(compressedEncodingFormat)}`;
466
+ }
456
467
  let filename = request.query?.filename;
457
468
  if (!Is.stringValue(filename)) {
458
- filename = `file.${result.fileExtension ?? MimeTypeHelper.defaultExtension(encodingFormat)}`;
469
+ filename = `file.${result.fileExtension ?? MimeTypeHelper.defaultExtension(encodingFormat)}${compressedExtension}`;
459
470
  }
460
471
  return {
461
472
  body: Is.stringBase64(result.blob) ? Converter.base64ToBytes(result.blob) : new Uint8Array(),
462
473
  attachment: {
463
- mimeType: encodingFormat,
474
+ mimeType: compressedEncodingFormat ?? encodingFormat,
464
475
  filename,
465
476
  inline: !(request.query?.download ?? false)
466
477
  }
@@ -593,6 +604,7 @@ class BlobStorageService {
593
604
  * @param options Optional options for the creation of the blob.
594
605
  * @param options.disableEncryption Disables encryption if enabled by default.
595
606
  * @param options.overrideVaultKeyId Use a different vault key id for encryption, if not provided the default vault key id will be used.
607
+ * @param options.compress Optional compression type to use for the blob, defaults to no compression.*
596
608
  * @param options.namespace The namespace to use for storing, defaults to component configured namespace.
597
609
  * @param userIdentity The user identity to use with storage operations.
598
610
  * @param nodeIdentity The node identity to use with storage operations.
@@ -630,6 +642,9 @@ class BlobStorageService {
630
642
  Validation.asValidationError(this.CLASS_NAME, "metadata", validationFailures);
631
643
  }
632
644
  const blobHash = `sha256:${Converter.bytesToBase64(Sha256.sum256(storeBlob))}`;
645
+ if (!Is.empty(options?.compress)) {
646
+ storeBlob = await Compression.compress(storeBlob, options.compress);
647
+ }
633
648
  // If we have a vault connector then encrypt the data.
634
649
  if (encryptionEnabled) {
635
650
  if (Is.empty(this._vaultConnector)) {
@@ -648,7 +663,8 @@ class BlobStorageService {
648
663
  encodingFormat,
649
664
  fileExtension,
650
665
  metadata,
651
- isEncrypted: encryptionEnabled
666
+ isEncrypted: encryptionEnabled,
667
+ compression: options?.compress
652
668
  };
653
669
  const conditions = [];
654
670
  if (this._includeUserIdentity) {
@@ -671,8 +687,8 @@ class BlobStorageService {
671
687
  * @param id The id of the blob to get in urn format.
672
688
  * @param options Optional options for the retrieval of the blob.
673
689
  * @param options.includeContent Include the content, or just get the metadata.
674
- * @param options.disableDecryption Disables decryption if enabled by default.
675
690
  * @param options.overrideVaultKeyId Use a different vault key id for decryption, if not provided the default vault key id will be used.
691
+ * @param options.decompress If the content should be decompressed, if it was compressed when stored, defaults to true.
676
692
  * @param userIdentity The user identity to use with storage operations.
677
693
  * @param nodeIdentity The node identity to use with storage operations.
678
694
  * @returns The entry and data for the blob if it can be found.
@@ -681,9 +697,7 @@ class BlobStorageService {
681
697
  async get(id, options, userIdentity, nodeIdentity) {
682
698
  Urn.guard(this.CLASS_NAME, "id", id);
683
699
  const includeContent = options?.includeContent ?? false;
684
- const disableEncryption = options?.disableDecryption ?? false;
685
700
  const vaultKeyId = options?.overrideVaultKeyId ?? this._vaultKeyId;
686
- const decryptionEnabled = !disableEncryption && Is.stringValue(vaultKeyId);
687
701
  const conditions = [];
688
702
  if (this._includeUserIdentity) {
689
703
  Guards.stringValue(this.CLASS_NAME, "userIdentity", userIdentity);
@@ -710,13 +724,17 @@ class BlobStorageService {
710
724
  if (Is.undefined(returnBlob)) {
711
725
  throw new NotFoundError(this.CLASS_NAME, "blobNotFound", id);
712
726
  }
713
- // If we have a vault connector then decrypt the data.
727
+ // If the data is encrypted then decrypt it.
728
+ const decryptionEnabled = blobEntry.isEncrypted && Is.stringValue(vaultKeyId);
714
729
  if (decryptionEnabled) {
715
730
  if (Is.empty(this._vaultConnector)) {
716
731
  throw new GeneralError(this.CLASS_NAME, "vaultConnectorNotConfigured");
717
732
  }
718
733
  returnBlob = await this._vaultConnector.decrypt(`${nodeIdentity}/${vaultKeyId}`, VaultEncryptionType.ChaCha20Poly1305, returnBlob);
719
734
  }
735
+ if (!Is.empty(blobEntry.compression) && (options?.decompress ?? true)) {
736
+ returnBlob = await Compression.decompress(returnBlob, blobEntry.compression);
737
+ }
720
738
  }
721
739
  const jsonLd = this.entryToJsonLd(blobEntry, returnBlob);
722
740
  return JsonLdProcessor.compact(jsonLd, jsonLd["@context"]);
@@ -764,7 +782,8 @@ class BlobStorageService {
764
782
  encodingFormat: encodingFormat ?? blobEntry.encodingFormat,
765
783
  fileExtension: fileExtension ?? blobEntry.fileExtension,
766
784
  metadata: metadata ?? blobEntry.metadata,
767
- isEncrypted: blobEntry.isEncrypted
785
+ isEncrypted: blobEntry.isEncrypted,
786
+ compression: blobEntry.compression
768
787
  };
769
788
  const conditions = [];
770
789
  if (this._includeUserIdentity) {
@@ -859,10 +878,6 @@ class BlobStorageService {
859
878
  sortDirection: orderDirection
860
879
  }
861
880
  ], undefined, cursor, pageSize);
862
- for (const entity of result.entities) {
863
- ObjectHelper.propertyDelete(entity, "nodeIdentity");
864
- ObjectHelper.propertyDelete(entity, "userIdentity");
865
- }
866
881
  let context = [
867
882
  SchemaOrgContexts.ContextRoot,
868
883
  BlobStorageContexts.ContextRoot,
@@ -946,9 +961,7 @@ class BlobStorageService {
946
961
  if (Is.empty(entity)) {
947
962
  throw new NotFoundError(this.CLASS_NAME, "entityNotFound", id);
948
963
  }
949
- ObjectHelper.propertyDelete(entity, "nodeIdentity");
950
- ObjectHelper.propertyDelete(entity, "userIdentity");
951
- return entity;
964
+ return ObjectHelper.omit(entity, ["nodeIdentity", "userIdentity"]);
952
965
  }
953
966
  /**
954
967
  * Convert the entry to JSON-LD.
@@ -973,7 +986,9 @@ class BlobStorageService {
973
986
  encodingFormat: entry?.encodingFormat,
974
987
  fileExtension: entry?.fileExtension,
975
988
  metadata: entry?.metadata,
976
- blob: Is.uint8Array(blob) ? Converter.bytesToBase64(blob) : undefined
989
+ blob: Is.uint8Array(blob) ? Converter.bytesToBase64(blob) : undefined,
990
+ isEncrypted: entry.isEncrypted,
991
+ compression: entry.compression
977
992
  };
978
993
  return jsonLd;
979
994
  }
@@ -1019,6 +1034,10 @@ let BlobStorageEntry = class BlobStorageEntry {
1019
1034
  * Is the entry encrypted.
1020
1035
  */
1021
1036
  isEncrypted;
1037
+ /**
1038
+ * Is the entry compressed.
1039
+ */
1040
+ compression;
1022
1041
  /**
1023
1042
  * The user identity that created the blob.
1024
1043
  */
@@ -1069,6 +1088,10 @@ __decorate([
1069
1088
  property({ type: "boolean" }),
1070
1089
  __metadata("design:type", Boolean)
1071
1090
  ], BlobStorageEntry.prototype, "isEncrypted", void 0);
1091
+ __decorate([
1092
+ property({ type: "string", optional: true }),
1093
+ __metadata("design:type", String)
1094
+ ], BlobStorageEntry.prototype, "compression", void 0);
1072
1095
  __decorate([
1073
1096
  property({ type: "string", optional: true }),
1074
1097
  __metadata("design:type", String)
@@ -1,4 +1,4 @@
1
- import { type IBlobStorageComponent, type IBlobStorageEntry, type IBlobStorageEntryList } from "@twin.org/blob-storage-models";
1
+ import { type BlobStorageCompressionType, type IBlobStorageComponent, type IBlobStorageEntry, type IBlobStorageEntryList } from "@twin.org/blob-storage-models";
2
2
  import { type IJsonLdNodeObject } from "@twin.org/data-json-ld";
3
3
  import { SortDirection, type EntityCondition } from "@twin.org/entity";
4
4
  import type { IBlobStorageServiceConstructorOptions } from "./models/IBlobStorageServiceConstructorOptions";
@@ -28,6 +28,7 @@ export declare class BlobStorageService implements IBlobStorageComponent {
28
28
  * @param options Optional options for the creation of the blob.
29
29
  * @param options.disableEncryption Disables encryption if enabled by default.
30
30
  * @param options.overrideVaultKeyId Use a different vault key id for encryption, if not provided the default vault key id will be used.
31
+ * @param options.compress Optional compression type to use for the blob, defaults to no compression.*
31
32
  * @param options.namespace The namespace to use for storing, defaults to component configured namespace.
32
33
  * @param userIdentity The user identity to use with storage operations.
33
34
  * @param nodeIdentity The node identity to use with storage operations.
@@ -36,6 +37,7 @@ export declare class BlobStorageService implements IBlobStorageComponent {
36
37
  create(blob: string, encodingFormat?: string, fileExtension?: string, metadata?: IJsonLdNodeObject, options?: {
37
38
  disableEncryption?: boolean;
38
39
  overrideVaultKeyId?: string;
40
+ compress?: BlobStorageCompressionType;
39
41
  namespace?: string;
40
42
  }, userIdentity?: string, nodeIdentity?: string): Promise<string>;
41
43
  /**
@@ -43,8 +45,8 @@ export declare class BlobStorageService implements IBlobStorageComponent {
43
45
  * @param id The id of the blob to get in urn format.
44
46
  * @param options Optional options for the retrieval of the blob.
45
47
  * @param options.includeContent Include the content, or just get the metadata.
46
- * @param options.disableDecryption Disables decryption if enabled by default.
47
48
  * @param options.overrideVaultKeyId Use a different vault key id for decryption, if not provided the default vault key id will be used.
49
+ * @param options.decompress If the content should be decompressed, if it was compressed when stored, defaults to true.
48
50
  * @param userIdentity The user identity to use with storage operations.
49
51
  * @param nodeIdentity The node identity to use with storage operations.
50
52
  * @returns The entry and data for the blob if it can be found.
@@ -52,7 +54,7 @@ export declare class BlobStorageService implements IBlobStorageComponent {
52
54
  */
53
55
  get(id: string, options?: {
54
56
  includeContent?: boolean;
55
- disableDecryption?: boolean;
57
+ decompress?: boolean;
56
58
  overrideVaultKeyId?: string;
57
59
  }, userIdentity?: string, nodeIdentity?: string): Promise<IBlobStorageEntry>;
58
60
  /**
@@ -1,3 +1,4 @@
1
+ import type { BlobStorageCompressionType } from "@twin.org/blob-storage-models";
1
2
  import type { IJsonLdNodeObject } from "@twin.org/data-json-ld";
2
3
  /**
3
4
  * Class representing entry for the blob storage.
@@ -39,6 +40,10 @@ export declare class BlobStorageEntry {
39
40
  * Is the entry encrypted.
40
41
  */
41
42
  isEncrypted: boolean;
43
+ /**
44
+ * Is the entry compressed.
45
+ */
46
+ compression?: BlobStorageCompressionType;
42
47
  /**
43
48
  * The user identity that created the blob.
44
49
  */
package/docs/changelog.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @twin.org/blob-storage-service - Changelog
2
2
 
3
+ ## [0.0.1-next.36](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.1-next.35...blob-storage-service-v0.0.1-next.36) (2025-06-19)
4
+
5
+
6
+ ### Features
7
+
8
+ * add compression support ([67d239b](https://github.com/twinfoundation/blob-storage/commit/67d239bca8321bd90bf4ff93167c564130309730))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/blob-storage-models bumped from 0.0.1-next.35 to 0.0.1-next.36
16
+ * devDependencies
17
+ * @twin.org/blob-storage-connector-memory bumped from 0.0.1-next.35 to 0.0.1-next.36
18
+
3
19
  ## [0.0.1-next.35](https://github.com/twinfoundation/blob-storage/compare/blob-storage-service-v0.0.1-next.34...blob-storage-service-v0.0.1-next.35) (2025-06-17)
4
20
 
5
21
 
@@ -393,8 +393,8 @@
393
393
  "example": "true"
394
394
  },
395
395
  {
396
- "name": "disableDecryption",
397
- "description": "Disables decryption if enabled by default.",
396
+ "name": "decompress",
397
+ "description": "If the content should be decompressed, if it was compressed when stored, defaults to true.",
398
398
  "in": "query",
399
399
  "required": false,
400
400
  "schema": {
@@ -914,6 +914,21 @@
914
914
  },
915
915
  "components": {
916
916
  "schemas": {
917
+ "BlobStorageCompressionType": {
918
+ "anyOf": [
919
+ {
920
+ "type": "string",
921
+ "const": "gzip",
922
+ "description": "Gzip."
923
+ },
924
+ {
925
+ "type": "string",
926
+ "const": "deflate",
927
+ "description": "Deflate."
928
+ }
929
+ ],
930
+ "description": "The types of compression for blob storage data."
931
+ },
917
932
  "BlobStorageCreateRequest": {
918
933
  "type": "object",
919
934
  "properties": {
@@ -937,6 +952,9 @@
937
952
  "description": "Disables encryption if enabled by default.",
938
953
  "default": false
939
954
  },
955
+ "compress": {
956
+ "$ref": "#/components/schemas/BlobStorageCompressionType"
957
+ },
940
958
  "overrideVaultKeyId": {
941
959
  "type": "string",
942
960
  "description": "Use a different vault key id for encryption, if not provided the default vault key id will be used.",
@@ -1007,6 +1025,9 @@
1007
1025
  "type": "boolean",
1008
1026
  "description": "Indicates if the blob is encrypted."
1009
1027
  },
1028
+ "compression": {
1029
+ "$ref": "#/components/schemas/BlobStorageCompressionType"
1030
+ },
1010
1031
  "fileExtension": {
1011
1032
  "type": "string",
1012
1033
  "description": "The extension."
@@ -1095,16 +1116,6 @@
1095
1116
  },
1096
1117
  "metadata": {
1097
1118
  "$ref": "https://schema.twindev.org/json-ld/JsonLdNodeObject"
1098
- },
1099
- "disableEncryption": {
1100
- "type": "boolean",
1101
- "description": "Disables encryption if enabled by default.",
1102
- "default": false
1103
- },
1104
- "overrideVaultKeyId": {
1105
- "type": "string",
1106
- "description": "Use a different vault key id for encryption, if not provided the default vault key id will be used.",
1107
- "default": "undefined"
1108
1119
  }
1109
1120
  },
1110
1121
  "additionalProperties": false,
@@ -86,6 +86,14 @@ Is the entry encrypted.
86
86
 
87
87
  ***
88
88
 
89
+ ### compression?
90
+
91
+ > `optional` **compression**: `BlobStorageCompressionType`
92
+
93
+ Is the entry compressed.
94
+
95
+ ***
96
+
89
97
  ### userIdentity?
90
98
 
91
99
  > `optional` **userIdentity**: `string`
@@ -96,6 +96,12 @@ Disables encryption if enabled by default.
96
96
 
97
97
  Use a different vault key id for encryption, if not provided the default vault key id will be used.
98
98
 
99
+ ###### compress?
100
+
101
+ `BlobStorageCompressionType`
102
+
103
+ Optional compression type to use for the blob, defaults to no compression.*
104
+
99
105
  ###### namespace?
100
106
 
101
107
  `string`
@@ -150,11 +156,11 @@ Optional options for the retrieval of the blob.
150
156
 
151
157
  Include the content, or just get the metadata.
152
158
 
153
- ###### disableDecryption?
159
+ ###### decompress?
154
160
 
155
161
  `boolean`
156
162
 
157
- Disables decryption if enabled by default.
163
+ If the content should be decompressed, if it was compressed when stored, defaults to true.
158
164
 
159
165
  ###### overrideVaultKeyId?
160
166
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/blob-storage-service",
3
- "version": "0.0.1-next.35",
3
+ "version": "0.0.1-next.36",
4
4
  "description": "Blob storage contract implementation and REST endpoint definitions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@twin.org/api-models": "next",
18
- "@twin.org/blob-storage-models": "0.0.1-next.35",
18
+ "@twin.org/blob-storage-models": "0.0.1-next.36",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/crypto": "next",
21
21
  "@twin.org/data-json-ld": "next",