@punks/backend-entity-manager 0.0.216 → 0.0.218

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/cjs/index.js CHANGED
@@ -21285,6 +21285,7 @@ exports.MediaLibraryService = class MediaLibraryService {
21285
21285
  fileName: input.fileName,
21286
21286
  contentType: input.contentType,
21287
21287
  folderId: input.folderId,
21288
+ providerId: this.defaultMediaProvider.getProviderId(),
21288
21289
  });
21289
21290
  return reference;
21290
21291
  }
@@ -21295,6 +21296,24 @@ exports.MediaLibraryService = class MediaLibraryService {
21295
21296
  async mediaDownload(input) {
21296
21297
  return await this.getMediaProvider(this.parseReferenceProviderId(input)).mediaDownload(input);
21297
21298
  }
21299
+ async folderEnsure(input) {
21300
+ let parentFolder;
21301
+ let folder;
21302
+ for (const folderName of input.path) {
21303
+ folder = await this.mediaFolderRepository.folderFind(folderName, parentFolder?.id);
21304
+ if (!folder) {
21305
+ folder = await this.mediaFolderRepository.folderCreate({
21306
+ name: folderName,
21307
+ parentId: parentFolder?.id,
21308
+ });
21309
+ }
21310
+ parentFolder = folder;
21311
+ }
21312
+ if (!folder) {
21313
+ throw new Error("Cannot create folder");
21314
+ }
21315
+ return folder;
21316
+ }
21298
21317
  async folderCreate(input) {
21299
21318
  return await this.mediaFolderRepository.folderCreate({
21300
21319
  name: input.folderName,
@@ -28965,6 +28984,9 @@ exports.AwsS3MediaProvider = class AwsS3MediaProvider {
28965
28984
  constructor() {
28966
28985
  this.client = createClient$1(awsMediaSettings.value);
28967
28986
  }
28987
+ getProviderId() {
28988
+ return "awsS3";
28989
+ }
28968
28990
  getFileName(input) {
28969
28991
  const parsedRef = parseRef(input.ref);
28970
28992
  return parsedRef.path.split("/").pop() ?? "";