@webiny/api-file-manager 5.40.6 → 5.41.0-beta.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.
@@ -1 +1 @@
1
- {"version":3,"names":["_handlerGraphql","require","_pubsub","_error","_interopRequireDefault","_contants","_apiSecurity","_date","_identity","createFilesCrud","config","storageOperations","filesPermissions","getLocaleCode","getTenantId","getIdentity","WEBINY_VERSION","onFileBeforeCreate","createTopic","onFileAfterCreate","onFileBeforeBatchCreate","onFileAfterBatchCreate","onFileBeforeUpdate","onFileAfterUpdate","onFileBeforeDelete","onFileAfterDelete","getFile","id","ensure","rwd","file","files","get","where","tenant","locale","NotFoundError","owns","createdBy","createFile","input","meta","key","split","currentDateTime","Date","currentIdentity","tags","Array","isArray","aliases","location","folderId","ROOT_FOLDER","private","createdOn","getDate","modifiedOn","savedOn","utilsGetIdentity","modifiedBy","savedBy","webinyVersion","publish","result","create","ex","NotAuthorizedError","WebinyError","message","code","data","updateFile","original","update","deleteFile","delete","createFilesInBatch","inputs","map","results","createBatch","listFiles","params","limit","after","initialWhere","sort","initialSort","search","private_not","canAccessOnlyOwnRecords","identity","length","list","listTags","exports"],"sources":["files.crud.ts"],"sourcesContent":["import { NotFoundError } from \"@webiny/handler-graphql\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport WebinyError from \"@webiny/error\";\nimport {\n File,\n FileManagerFilesStorageOperationsListParamsWhere,\n FileManagerFilesStorageOperationsTagsParamsWhere,\n FilesCRUD,\n FilesListOpts\n} from \"~/types\";\nimport { FileManagerConfig } from \"~/createFileManager/index\";\nimport { ROOT_FOLDER } from \"~/contants\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport { getDate } from \"@webiny/api-headless-cms/utils/date\";\nimport { getIdentity as utilsGetIdentity } from \"@webiny/api-headless-cms/utils/identity\";\n\nexport const createFilesCrud = (config: FileManagerConfig): FilesCRUD => {\n const {\n storageOperations,\n filesPermissions,\n getLocaleCode,\n getTenantId,\n getIdentity,\n WEBINY_VERSION\n } = config;\n\n return {\n onFileBeforeCreate: createTopic(\"fileManager.onFileBeforeCreate\"),\n onFileAfterCreate: createTopic(\"fileManager.onFileAfterCreate\"),\n onFileBeforeBatchCreate: createTopic(\"fileManager.onFileBeforeBatchCreate\"),\n onFileAfterBatchCreate: createTopic(\"fileManager.onFileAfterBatchCreate\"),\n onFileBeforeUpdate: createTopic(\"fileManager.onFileBeforeUpdate\"),\n onFileAfterUpdate: createTopic(\"fileManager.onFileAfterUpdate\"),\n onFileBeforeDelete: createTopic(\"fileManager.onFileBeforeDelete\"),\n onFileAfterDelete: createTopic(\"fileManager.onFileAfterDelete\"),\n async getFile(id: string) {\n await filesPermissions.ensure({ rwd: \"r\" });\n\n const file = await storageOperations.files.get({\n where: {\n id,\n tenant: getTenantId(),\n locale: getLocaleCode()\n }\n });\n\n if (!file) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n await filesPermissions.ensure({ owns: file.createdBy });\n\n return file;\n },\n async createFile(input, meta) {\n await filesPermissions.ensure({ rwd: \"w\" });\n\n // Extract ID from file key\n const [id] = input.key.split(\"/\");\n\n const currentDateTime = new Date();\n const currentIdentity = getIdentity();\n\n const file: File = {\n ...input,\n tags: Array.isArray(input.tags) ? input.tags : [],\n aliases: Array.isArray(input.aliases) ? input.aliases : [],\n id: input.id || id,\n location: {\n folderId: input.location?.folderId ?? ROOT_FOLDER\n },\n meta: {\n private: false,\n ...(input.meta || {})\n },\n\n createdOn: getDate(input.createdOn, currentDateTime),\n modifiedOn: getDate(input.modifiedOn, null),\n savedOn: getDate(input.savedOn, currentDateTime),\n createdBy: utilsGetIdentity(input.createdBy, currentIdentity),\n modifiedBy: utilsGetIdentity(input.modifiedBy, null),\n savedBy: utilsGetIdentity(input.savedBy, currentIdentity),\n\n tenant: getTenantId(),\n locale: getLocaleCode(),\n webinyVersion: WEBINY_VERSION\n };\n\n try {\n await this.onFileBeforeCreate.publish({ file, meta });\n\n const result = await storageOperations.files.create({ file });\n\n await this.onFileAfterCreate.publish({ file, meta });\n return result;\n } catch (ex) {\n // If a `NotAuthorizedError` error was thrown, then we just want to rethrow it.\n if (ex instanceof NotAuthorizedError) {\n throw ex;\n }\n\n throw new WebinyError(\n ex.message || \"Could not create a file.\",\n ex.code || \"CREATE_FILE_ERROR\",\n {\n ...(ex.data || {}),\n file\n }\n );\n }\n },\n async updateFile(id, input) {\n await filesPermissions.ensure({ rwd: \"w\" });\n\n const original = await storageOperations.files.get({\n where: {\n id,\n tenant: getTenantId(),\n locale: getLocaleCode()\n }\n });\n\n if (!original) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n await filesPermissions.ensure({ owns: original.createdBy });\n\n const currentDateTime = new Date();\n const currentIdentity = getIdentity();\n\n const file: File = {\n ...original,\n ...input,\n\n createdOn: getDate(input.createdOn, original.createdOn),\n modifiedOn: getDate(input.modifiedOn, currentDateTime),\n savedOn: getDate(input.savedOn, currentDateTime),\n createdBy: utilsGetIdentity(input.createdBy, original.createdBy),\n modifiedBy: utilsGetIdentity(input.modifiedBy, currentIdentity),\n savedBy: utilsGetIdentity(input.savedBy, currentIdentity),\n\n tags: Array.isArray(input.tags)\n ? input.tags\n : Array.isArray(original.tags)\n ? original.tags\n : [],\n aliases: Array.isArray(input.aliases)\n ? input.aliases\n : Array.isArray(original.aliases)\n ? original.aliases\n : [],\n id: original.id,\n webinyVersion: WEBINY_VERSION\n };\n\n try {\n await this.onFileBeforeUpdate.publish({\n original,\n file,\n input\n });\n\n const result = await storageOperations.files.update({\n original,\n file\n });\n\n await this.onFileAfterUpdate.publish({\n original,\n file,\n input\n });\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update a file.\",\n ex.code || \"UPDATE_FILE_ERROR\",\n {\n ...(ex.data || {}),\n original,\n file\n }\n );\n }\n },\n async deleteFile(id) {\n await filesPermissions.ensure({ rwd: \"d\" });\n\n const file = await storageOperations.files.get({\n where: {\n id,\n tenant: getTenantId(),\n locale: getLocaleCode()\n }\n });\n\n if (!file) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n await filesPermissions.ensure({ owns: file.createdBy });\n\n try {\n await this.onFileBeforeDelete.publish({ file });\n\n await storageOperations.files.delete({\n file\n });\n\n await this.onFileAfterDelete.publish({ file });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete a file.\",\n ex.code || \"DELETE_FILE_ERROR\",\n {\n ...(ex.data || {}),\n id,\n file\n }\n );\n }\n\n return true;\n },\n async createFilesInBatch(inputs, meta) {\n await filesPermissions.ensure({ rwd: \"w\" });\n\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n const currentIdentity = getIdentity();\n const currentDateTime = new Date();\n\n const files: File[] = inputs.map(input => {\n return {\n ...input,\n tags: Array.isArray(input.tags) ? input.tags : [],\n aliases: Array.isArray(input.aliases) ? input.aliases : [],\n meta: {\n private: false,\n ...(input.meta || {})\n },\n location: {\n folderId: input.location?.folderId ?? ROOT_FOLDER\n },\n\n createdOn: getDate(currentDateTime),\n modifiedOn: null,\n savedOn: getDate(currentDateTime),\n createdBy: utilsGetIdentity(currentIdentity),\n modifiedBy: null,\n savedBy: utilsGetIdentity(currentIdentity),\n\n tenant,\n locale,\n webinyVersion: WEBINY_VERSION\n };\n });\n\n try {\n await this.onFileBeforeBatchCreate.publish({ files, meta });\n const results = await storageOperations.files.createBatch({\n files\n });\n await this.onFileAfterBatchCreate.publish({ files, meta });\n return results;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create a batch of files.\",\n ex.code || \"CREATE_FILES_ERROR\",\n {\n ...(ex.data || {}),\n files\n }\n );\n }\n },\n async listFiles(params: FilesListOpts = {}) {\n await filesPermissions.ensure({ rwd: \"r\" });\n\n const {\n limit = 40,\n after = null,\n where: initialWhere,\n sort: initialSort,\n search\n } = params;\n\n const where: FileManagerFilesStorageOperationsListParamsWhere = {\n ...{ meta: { private_not: true }, ...initialWhere },\n locale: getLocaleCode(),\n tenant: getTenantId()\n };\n\n /**\n * Always override the createdBy received from the user, if any.\n */\n if (await filesPermissions.canAccessOnlyOwnRecords()) {\n const identity = getIdentity();\n where.createdBy = identity.id;\n }\n\n const sort =\n Array.isArray(initialSort) && initialSort.length > 0 ? initialSort : [\"id_DESC\"];\n try {\n return await storageOperations.files.list({\n where,\n after,\n limit,\n sort,\n search\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list files by given parameters.\",\n ex.code || \"FILE_TAG_SEARCH_ERROR\",\n {\n ...(ex.data || {}),\n where,\n after,\n limit,\n sort\n }\n );\n }\n },\n async listTags({ where: initialWhere, after, limit }) {\n await filesPermissions.ensure();\n\n const where: FileManagerFilesStorageOperationsTagsParamsWhere = {\n ...initialWhere,\n tenant: getTenantId(),\n locale: getLocaleCode()\n };\n\n const params = {\n where,\n limit: limit || 1000000,\n after\n };\n\n try {\n return await storageOperations.files.tags(params);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not search for tags.\",\n ex.code || \"FILE_TAG_SEARCH_ERROR\",\n {\n ...(ex.data || {}),\n params\n }\n );\n }\n }\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AASA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAEO,MAAMQ,eAAe,GAAIC,MAAyB,IAAgB;EACrE,MAAM;IACFC,iBAAiB;IACjBC,gBAAgB;IAChBC,aAAa;IACbC,WAAW;IACXC,WAAW;IACXC;EACJ,CAAC,GAAGN,MAAM;EAEV,OAAO;IACHO,kBAAkB,EAAE,IAAAC,mBAAW,EAAC,gCAAgC,CAAC;IACjEC,iBAAiB,EAAE,IAAAD,mBAAW,EAAC,+BAA+B,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ACI,IAAI,IAAI,uBAAuB,EAClC;UACI,IAAIJ,EAAE,CAACK,IAAI,IAAI,CAAC,CAAC,CAAC;UAClBY;QACJ,CACJ,CAAC;MACL;IACJ;EACJ,CAAC;AACL,CAAC;AAACa,OAAA,CAAAvF,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_handlerGraphql","require","_pubsub","_error","_interopRequireDefault","_contants","_apiSecurity","_date","_identity","createFilesCrud","config","storageOperations","filesPermissions","getLocaleCode","getTenantId","getIdentity","WEBINY_VERSION","onFileBeforeCreate","createTopic","onFileAfterCreate","onFileBeforeBatchCreate","onFileAfterBatchCreate","onFileBeforeUpdate","onFileAfterUpdate","onFileBeforeDelete","onFileAfterDelete","getFile","id","ensure","rwd","file","files","get","where","tenant","locale","NotFoundError","owns","createdBy","createFile","input","meta","key","split","currentDateTime","Date","currentIdentity","tags","Array","isArray","aliases","location","folderId","ROOT_FOLDER","private","createdOn","getDate","modifiedOn","savedOn","utilsGetIdentity","modifiedBy","savedBy","webinyVersion","publish","result","create","ex","NotAuthorizedError","WebinyError","message","code","data","updateFile","original","update","deleteFile","delete","createFilesInBatch","inputs","map","results","createBatch","listFiles","params","limit","after","initialWhere","sort","initialSort","search","private_not","canAccessOnlyOwnRecords","identity","length","list","listTags","exports"],"sources":["files.crud.ts"],"sourcesContent":["import { NotFoundError } from \"@webiny/handler-graphql\";\nimport { createTopic } from \"@webiny/pubsub\";\nimport WebinyError from \"@webiny/error\";\nimport {\n File,\n FileManagerFilesStorageOperationsListParamsWhere,\n FileManagerFilesStorageOperationsTagsParamsWhere,\n FilesCRUD,\n FilesListOpts\n} from \"~/types\";\nimport { FileManagerConfig } from \"~/createFileManager/index\";\nimport { ROOT_FOLDER } from \"~/contants\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport { getDate } from \"@webiny/api-headless-cms/utils/date\";\nimport { getIdentity as utilsGetIdentity } from \"@webiny/api-headless-cms/utils/identity\";\nimport { CmsEntryListSort } from \"@webiny/api-headless-cms/types\";\n\nexport const createFilesCrud = (config: FileManagerConfig): FilesCRUD => {\n const {\n storageOperations,\n filesPermissions,\n getLocaleCode,\n getTenantId,\n getIdentity,\n WEBINY_VERSION\n } = config;\n\n return {\n onFileBeforeCreate: createTopic(\"fileManager.onFileBeforeCreate\"),\n onFileAfterCreate: createTopic(\"fileManager.onFileAfterCreate\"),\n onFileBeforeBatchCreate: createTopic(\"fileManager.onFileBeforeBatchCreate\"),\n onFileAfterBatchCreate: createTopic(\"fileManager.onFileAfterBatchCreate\"),\n onFileBeforeUpdate: createTopic(\"fileManager.onFileBeforeUpdate\"),\n onFileAfterUpdate: createTopic(\"fileManager.onFileAfterUpdate\"),\n onFileBeforeDelete: createTopic(\"fileManager.onFileBeforeDelete\"),\n onFileAfterDelete: createTopic(\"fileManager.onFileAfterDelete\"),\n async getFile(id: string) {\n await filesPermissions.ensure({ rwd: \"r\" });\n\n const file = await storageOperations.files.get({\n where: {\n id,\n tenant: getTenantId(),\n locale: getLocaleCode()\n }\n });\n\n if (!file) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n await filesPermissions.ensure({ owns: file.createdBy });\n\n return file;\n },\n async createFile(input, meta) {\n await filesPermissions.ensure({ rwd: \"w\" });\n\n // Extract ID from file key\n const [id] = input.key.split(\"/\");\n\n const currentDateTime = new Date();\n const currentIdentity = getIdentity();\n\n const file: File = {\n ...input,\n tags: Array.isArray(input.tags) ? input.tags : [],\n aliases: Array.isArray(input.aliases) ? input.aliases : [],\n id: input.id || id,\n location: {\n folderId: input.location?.folderId ?? ROOT_FOLDER\n },\n meta: {\n private: false,\n ...(input.meta || {})\n },\n\n createdOn: getDate(input.createdOn, currentDateTime),\n modifiedOn: getDate(input.modifiedOn, null),\n savedOn: getDate(input.savedOn, currentDateTime),\n createdBy: utilsGetIdentity(input.createdBy, currentIdentity),\n modifiedBy: utilsGetIdentity(input.modifiedBy, null),\n savedBy: utilsGetIdentity(input.savedBy, currentIdentity),\n\n tenant: getTenantId(),\n locale: getLocaleCode(),\n webinyVersion: WEBINY_VERSION\n };\n\n try {\n await this.onFileBeforeCreate.publish({ file, meta });\n\n const result = await storageOperations.files.create({ file });\n\n await this.onFileAfterCreate.publish({ file, meta });\n return result;\n } catch (ex) {\n // If a `NotAuthorizedError` error was thrown, then we just want to rethrow it.\n if (ex instanceof NotAuthorizedError) {\n throw ex;\n }\n\n throw new WebinyError(\n ex.message || \"Could not create a file.\",\n ex.code || \"CREATE_FILE_ERROR\",\n {\n ...(ex.data || {}),\n file\n }\n );\n }\n },\n async updateFile(id, input) {\n await filesPermissions.ensure({ rwd: \"w\" });\n\n const original = await storageOperations.files.get({\n where: {\n id,\n tenant: getTenantId(),\n locale: getLocaleCode()\n }\n });\n\n if (!original) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n await filesPermissions.ensure({ owns: original.createdBy });\n\n const currentDateTime = new Date();\n const currentIdentity = getIdentity();\n\n const file: File = {\n ...original,\n ...input,\n\n createdOn: getDate(input.createdOn, original.createdOn),\n modifiedOn: getDate(input.modifiedOn, currentDateTime),\n savedOn: getDate(input.savedOn, currentDateTime),\n createdBy: utilsGetIdentity(input.createdBy, original.createdBy),\n modifiedBy: utilsGetIdentity(input.modifiedBy, currentIdentity),\n savedBy: utilsGetIdentity(input.savedBy, currentIdentity),\n\n tags: Array.isArray(input.tags)\n ? input.tags\n : Array.isArray(original.tags)\n ? original.tags\n : [],\n aliases: Array.isArray(input.aliases)\n ? input.aliases\n : Array.isArray(original.aliases)\n ? original.aliases\n : [],\n id: original.id,\n webinyVersion: WEBINY_VERSION\n };\n\n try {\n await this.onFileBeforeUpdate.publish({\n original,\n file,\n input\n });\n\n const result = await storageOperations.files.update({\n original,\n file\n });\n\n await this.onFileAfterUpdate.publish({\n original,\n file,\n input\n });\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update a file.\",\n ex.code || \"UPDATE_FILE_ERROR\",\n {\n ...(ex.data || {}),\n original,\n file\n }\n );\n }\n },\n async deleteFile(id) {\n await filesPermissions.ensure({ rwd: \"d\" });\n\n const file = await storageOperations.files.get({\n where: {\n id,\n tenant: getTenantId(),\n locale: getLocaleCode()\n }\n });\n\n if (!file) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n await filesPermissions.ensure({ owns: file.createdBy });\n\n try {\n await this.onFileBeforeDelete.publish({ file });\n\n await storageOperations.files.delete({\n file\n });\n\n await this.onFileAfterDelete.publish({ file });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete a file.\",\n ex.code || \"DELETE_FILE_ERROR\",\n {\n ...(ex.data || {}),\n id,\n file\n }\n );\n }\n\n return true;\n },\n async createFilesInBatch(inputs, meta) {\n await filesPermissions.ensure({ rwd: \"w\" });\n\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n const currentIdentity = getIdentity();\n const currentDateTime = new Date();\n\n const files: File[] = inputs.map(input => {\n return {\n ...input,\n tags: Array.isArray(input.tags) ? input.tags : [],\n aliases: Array.isArray(input.aliases) ? input.aliases : [],\n meta: {\n private: false,\n ...(input.meta || {})\n },\n location: {\n folderId: input.location?.folderId ?? ROOT_FOLDER\n },\n\n createdOn: getDate(currentDateTime),\n modifiedOn: null,\n savedOn: getDate(currentDateTime),\n createdBy: utilsGetIdentity(currentIdentity),\n modifiedBy: null,\n savedBy: utilsGetIdentity(currentIdentity),\n\n tenant,\n locale,\n webinyVersion: WEBINY_VERSION\n };\n });\n\n try {\n await this.onFileBeforeBatchCreate.publish({ files, meta });\n const results = await storageOperations.files.createBatch({\n files\n });\n await this.onFileAfterBatchCreate.publish({ files, meta });\n return results;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create a batch of files.\",\n ex.code || \"CREATE_FILES_ERROR\",\n {\n ...(ex.data || {}),\n files\n }\n );\n }\n },\n async listFiles(params: FilesListOpts = {}) {\n await filesPermissions.ensure({ rwd: \"r\" });\n\n const {\n limit = 40,\n after = null,\n where: initialWhere,\n sort: initialSort,\n search\n } = params;\n\n const where: FileManagerFilesStorageOperationsListParamsWhere = {\n ...{ meta: { private_not: true }, ...initialWhere },\n locale: getLocaleCode(),\n tenant: getTenantId()\n };\n\n /**\n * Always override the createdBy received from the user, if any.\n */\n if (await filesPermissions.canAccessOnlyOwnRecords()) {\n const identity = getIdentity();\n where.createdBy = identity.id;\n }\n\n const sort: CmsEntryListSort =\n Array.isArray(initialSort) && initialSort.length > 0 ? initialSort : [\"id_DESC\"];\n try {\n return await storageOperations.files.list({\n where,\n after,\n limit,\n sort,\n search\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list files by given parameters.\",\n ex.code || \"FILE_TAG_SEARCH_ERROR\",\n {\n ...(ex.data || {}),\n where,\n after,\n limit,\n sort\n }\n );\n }\n },\n async listTags({ where: initialWhere, after, limit }) {\n await filesPermissions.ensure();\n\n const where: FileManagerFilesStorageOperationsTagsParamsWhere = {\n ...initialWhere,\n tenant: getTenantId(),\n locale: getLocaleCode()\n };\n\n const params = {\n where,\n limit: limit || 1000000,\n after\n };\n\n try {\n return await storageOperations.files.tags(params);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not search for tags.\",\n ex.code || \"FILE_TAG_SEARCH_ERROR\",\n {\n ...(ex.data || {}),\n params\n }\n );\n }\n }\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AASA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAGO,MAAMQ,eAAe,GAAIC,MAAyB,IAAgB;EACrE,MAAM;IACFC,iBAAiB;IACjBC,gBAAgB;IAChBC,aAAa;IACbC,WAAW;IACXC,WAAW;IACXC;EACJ,CAAC,GAAGN,MAAM;EA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ACrD,CAAC,CAAC,OAAOjB,EAAE,EAAE;QACT,MAAM,IAAIE,cAAW,CACjBF,EAAE,CAACG,OAAO,IAAI,4BAA4B,EAC1CH,EAAE,CAACI,IAAI,IAAI,uBAAuB,EAClC;UACI,IAAIJ,EAAE,CAACK,IAAI,IAAI,CAAC,CAAC,CAAC;UAClBY;QACJ,CACJ,CAAC;MACL;IACJ;EACJ,CAAC;AACL,CAAC;AAACa,OAAA,CAAAvF,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { AssetContentsReader, AssetOutputStrategy } from "..";
3
- declare type Setter<T> = (arg: T | undefined) => T;
4
+ type Setter<T> = (arg: T | undefined) => T;
4
5
  export interface AssetData {
5
6
  id: string;
6
7
  tenant: string;
@@ -1,18 +1,18 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  import { AssetRequestResolver, AssetResolver, AssetProcessor, AssetOutputStrategy, AssetRequest, Asset, AssetTransformationStrategy, ResponseHeadersSetter } from "..";
3
3
  import { FileManagerContext } from "../../types";
4
- declare type Setter<TParams, TReturn> = (params: TParams) => TReturn;
5
- export declare type AssetRequestResolverDecorator = Setter<{
4
+ type Setter<TParams, TReturn> = (params: TParams) => TReturn;
5
+ export type AssetRequestResolverDecorator = Setter<{
6
6
  assetRequestResolver: AssetRequestResolver;
7
7
  }, AssetRequestResolver>;
8
- export declare type AssetResolverDecorator = Setter<{
8
+ export type AssetResolverDecorator = Setter<{
9
9
  assetResolver: AssetResolver;
10
10
  }, AssetResolver>;
11
- export declare type AssetProcessorDecorator = Setter<{
11
+ export type AssetProcessorDecorator = Setter<{
12
12
  context: FileManagerContext;
13
13
  assetProcessor: AssetProcessor;
14
14
  }, AssetProcessor>;
15
- export declare type AssetTransformationDecorator = Setter<{
15
+ export type AssetTransformationDecorator = Setter<{
16
16
  context: FileManagerContext;
17
17
  assetTransformationStrategy: AssetTransformationStrategy;
18
18
  }, AssetTransformationStrategy>;
@@ -22,7 +22,7 @@ export interface AssetOutputStrategyDecoratorParams {
22
22
  asset: Asset;
23
23
  assetOutputStrategy: AssetOutputStrategy;
24
24
  }
25
- export declare type AssetOutputStrategyDecorator = Setter<AssetOutputStrategyDecoratorParams, AssetOutputStrategy>;
25
+ export type AssetOutputStrategyDecorator = Setter<AssetOutputStrategyDecoratorParams, AssetOutputStrategy>;
26
26
  export declare class AssetDeliveryConfigBuilder {
27
27
  private assetRequestResolverDecorators;
28
28
  private assetResolverDecorators;
@@ -1,8 +1,9 @@
1
+ import { GenericRecord } from "@webiny/api/types";
1
2
  export interface AssetRequestOptions {
2
3
  original?: boolean;
3
4
  width?: number;
4
5
  }
5
- export declare type AssetRequestContext<T extends Record<string, any> = Record<string, any>> = T & {
6
+ export type AssetRequestContext<T extends GenericRecord = GenericRecord> = T & {
6
7
  /**
7
8
  * Asset request URL.
8
9
  */
@@ -19,6 +20,6 @@ export declare class AssetRequest<TOptions extends AssetRequestOptions = AssetRe
19
20
  getKey(): string;
20
21
  getOptions(): TOptions;
21
22
  setOptions(options: TOptions): void;
22
- getContext<T>(): AssetRequestContext<T>;
23
+ getContext<T extends GenericRecord = GenericRecord>(): AssetRequestContext<T>;
23
24
  getExtension(): string | undefined;
24
25
  }
@@ -1 +1 @@
1
- {"version":3,"names":["AssetRequest","constructor","data","getKey","key","getOptions","options","setOptions","getContext","context","getExtension","split","pop","exports"],"sources":["AssetRequest.ts"],"sourcesContent":["export interface AssetRequestOptions {\n original?: boolean;\n width?: number;\n}\n\nexport type AssetRequestContext<T extends Record<string, any> = Record<string, any>> = T & {\n /**\n * Asset request URL.\n */\n url: string;\n};\n\nexport interface AssetRequestData<TOptions> {\n key: string;\n context: AssetRequestContext;\n options: TOptions;\n}\n\nexport class AssetRequest<TOptions extends AssetRequestOptions = AssetRequestOptions> {\n private data: AssetRequestData<TOptions>;\n\n constructor(data: AssetRequestData<TOptions>) {\n this.data = data;\n }\n\n getKey() {\n return this.data.key;\n }\n\n getOptions(): TOptions {\n return this.data.options;\n }\n\n setOptions(options: TOptions) {\n this.data.options = options;\n }\n\n getContext<T>() {\n return this.data.context as AssetRequestContext<T>;\n }\n\n getExtension() {\n return this.data.key.split(\".\").pop();\n }\n}\n"],"mappings":";;;;;;AAkBO,MAAMA,YAAY,CAA6D;EAGlFC,WAAWA,CAACC,IAAgC,EAAE;IAC1C,IAAI,CAACA,IAAI,GAAGA,IAAI;EACpB;EAEAC,MAAMA,CAAA,EAAG;IACL,OAAO,IAAI,CAACD,IAAI,CAACE,GAAG;EACxB;EAEAC,UAAUA,CAAA,EAAa;IACnB,OAAO,IAAI,CAACH,IAAI,CAACI,OAAO;EAC5B;EAEAC,UAAUA,CAACD,OAAiB,EAAE;IAC1B,IAAI,CAACJ,IAAI,CAACI,OAAO,GAAGA,OAAO;EAC/B;EAEAE,UAAUA,CAAA,EAAM;IACZ,OAAO,IAAI,CAACN,IAAI,CAACO,OAAO;EAC5B;EAEAC,YAAYA,CAAA,EAAG;IACX,OAAO,IAAI,CAACR,IAAI,CAACE,GAAG,CAACO,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC;EACzC;AACJ;AAACC,OAAA,CAAAb,YAAA,GAAAA,YAAA","ignoreList":[]}
1
+ {"version":3,"names":["AssetRequest","constructor","data","getKey","key","getOptions","options","setOptions","getContext","context","getExtension","split","pop","exports"],"sources":["AssetRequest.ts"],"sourcesContent":["import { GenericRecord } from \"@webiny/api/types\";\n\nexport interface AssetRequestOptions {\n original?: boolean;\n width?: number;\n}\n\nexport type AssetRequestContext<T extends GenericRecord = GenericRecord> = T & {\n /**\n * Asset request URL.\n */\n url: string;\n};\n\nexport interface AssetRequestData<TOptions> {\n key: string;\n context: AssetRequestContext;\n options: TOptions;\n}\n\nexport class AssetRequest<TOptions extends AssetRequestOptions = AssetRequestOptions> {\n private data: AssetRequestData<TOptions>;\n\n constructor(data: AssetRequestData<TOptions>) {\n this.data = data;\n }\n\n getKey() {\n return this.data.key;\n }\n\n getOptions(): TOptions {\n return this.data.options;\n }\n\n setOptions(options: TOptions) {\n this.data.options = options;\n }\n\n getContext<T extends GenericRecord = GenericRecord>() {\n return this.data.context as AssetRequestContext<T>;\n }\n\n getExtension() {\n return this.data.key.split(\".\").pop();\n }\n}\n"],"mappings":";;;;;;AAoBO,MAAMA,YAAY,CAA6D;EAGlFC,WAAWA,CAACC,IAAgC,EAAE;IAC1C,IAAI,CAACA,IAAI,GAAGA,IAAI;EACpB;EAEAC,MAAMA,CAAA,EAAG;IACL,OAAO,IAAI,CAACD,IAAI,CAACE,GAAG;EACxB;EAEAC,UAAUA,CAAA,EAAa;IACnB,OAAO,IAAI,CAACH,IAAI,CAACI,OAAO;EAC5B;EAEAC,UAAUA,CAACD,OAAiB,EAAE;IAC1B,IAAI,CAACJ,IAAI,CAACI,OAAO,GAAGA,OAAO;EAC/B;EAEAE,UAAUA,CAAA,EAA4C;IAClD,OAAO,IAAI,CAACN,IAAI,CAACO,OAAO;EAC5B;EAEAC,YAAYA,CAAA,EAAG;IACX,OAAO,IAAI,CAACR,IAAI,CAACE,GAAG,CAACO,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC;EACzC;AACJ;AAACC,OAAA,CAAAb,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Asset } from "../..";
3
4
  export interface AssetContentsReader {
4
5
  read(asset: Asset): Promise<Buffer>;
@@ -1,7 +1,7 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
2
  import { CmsModelField as BaseModelField } from "@webiny/api-headless-cms/types";
3
3
  import { CmsPrivateModelFull } from "@webiny/api-headless-cms";
4
- declare type CmsModelField = Omit<BaseModelField, "storageId"> & {
4
+ type CmsModelField = Omit<BaseModelField, "storageId"> & {
5
5
  bulkEdit?: boolean;
6
6
  };
7
7
  declare class CmsModelFieldsModifier {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-file-manager",
3
- "version": "5.40.6",
3
+ "version": "5.41.0-beta.0",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "fm:base"
@@ -20,20 +20,20 @@
20
20
  "dependencies": {
21
21
  "@babel/runtime": "7.24.1",
22
22
  "@commodo/fields": "1.1.2-beta.20",
23
- "@webiny/api": "5.40.6",
24
- "@webiny/api-headless-cms": "5.40.6",
25
- "@webiny/api-security": "5.40.6",
26
- "@webiny/api-tenancy": "5.40.6",
27
- "@webiny/aws-sdk": "5.40.6",
28
- "@webiny/error": "5.40.6",
29
- "@webiny/handler": "5.40.6",
30
- "@webiny/handler-aws": "5.40.6",
31
- "@webiny/handler-graphql": "5.40.6",
32
- "@webiny/plugins": "5.40.6",
33
- "@webiny/project-utils": "5.40.6",
34
- "@webiny/pubsub": "5.40.6",
35
- "@webiny/tasks": "5.40.6",
36
- "@webiny/validation": "5.40.6",
23
+ "@webiny/api": "5.41.0-beta.0",
24
+ "@webiny/api-headless-cms": "5.41.0-beta.0",
25
+ "@webiny/api-security": "5.41.0-beta.0",
26
+ "@webiny/api-tenancy": "5.41.0-beta.0",
27
+ "@webiny/aws-sdk": "5.41.0-beta.0",
28
+ "@webiny/error": "5.41.0-beta.0",
29
+ "@webiny/handler": "5.41.0-beta.0",
30
+ "@webiny/handler-aws": "5.41.0-beta.0",
31
+ "@webiny/handler-graphql": "5.41.0-beta.0",
32
+ "@webiny/plugins": "5.41.0-beta.0",
33
+ "@webiny/project-utils": "5.41.0-beta.0",
34
+ "@webiny/pubsub": "5.41.0-beta.0",
35
+ "@webiny/tasks": "5.41.0-beta.0",
36
+ "@webiny/validation": "5.41.0-beta.0",
37
37
  "cache-control-parser": "2.0.6",
38
38
  "lodash": "4.17.21",
39
39
  "object-hash": "3.0.0"
@@ -46,13 +46,13 @@
46
46
  "@babel/preset-env": "7.24.3",
47
47
  "@babel/preset-typescript": "7.24.1",
48
48
  "@types/sharp": "0.32.0",
49
- "@webiny/api-i18n": "5.40.6",
50
- "@webiny/cli": "5.40.6",
51
- "@webiny/utils": "5.40.6",
49
+ "@webiny/api-i18n": "5.41.0-beta.0",
50
+ "@webiny/cli": "5.41.0-beta.0",
51
+ "@webiny/utils": "5.41.0-beta.0",
52
52
  "jest": "29.7.0",
53
53
  "rimraf": "5.0.5",
54
54
  "ttypescript": "1.5.15",
55
- "typescript": "4.7.4"
55
+ "typescript": "4.9.5"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public",
@@ -72,5 +72,5 @@
72
72
  ]
73
73
  }
74
74
  },
75
- "gitHead": "f9da84b373e62f9f269599c4301e5e4418a98d51"
75
+ "gitHead": "9ce5e75fc577aa4de2cf08d5ca734b3c98fe65b6"
76
76
  }
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Plugin } from "@webiny/plugins";
3
4
  import { FileManagerSettings } from "../types";
4
5
  export interface FilePhysicalStoragePluginParams<U extends FilePhysicalStoragePluginUploadParams, D extends FilePhysicalStoragePluginDeleteParams> {
@@ -1,7 +1,8 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { FileManagerContext } from "../types";
3
4
  import { FilePhysicalStoragePlugin } from "../plugins/FilePhysicalStoragePlugin";
4
- export declare type Result = Record<string, any>;
5
+ export type Result = Record<string, any>;
5
6
  export interface FileStorageUploadParams {
6
7
  buffer: Buffer;
7
8
  hideInFileManager: boolean | string;
package/types/file.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- declare type PublicAccess = {
1
+ type PublicAccess = {
2
2
  type: "public";
3
3
  };
4
- declare type PrivateAuthenticatedAccess = {
4
+ type PrivateAuthenticatedAccess = {
5
5
  type: "private-authenticated";
6
6
  };
7
7
  export interface File {
@@ -23,6 +23,7 @@ export interface File {
23
23
  createdBy: CreatedBy;
24
24
  modifiedBy: CreatedBy | null;
25
25
  savedBy: CreatedBy;
26
+ extensions?: Record<string, any>;
26
27
  /**
27
28
  * Added with new storage operations refactoring.
28
29
  */
package/types/file.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["file.ts"],"sourcesContent":["type PublicAccess = {\n type: \"public\";\n};\n\ntype PrivateAuthenticatedAccess = {\n type: \"private-authenticated\";\n};\n\nexport interface File {\n id: string;\n key: string;\n size: number;\n type: string;\n name: string;\n meta: Record<string, any>;\n accessControl?: PublicAccess | PrivateAuthenticatedAccess;\n location: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n createdBy: CreatedBy;\n modifiedBy: CreatedBy | null;\n savedBy: CreatedBy;\n\n /**\n * Added with new storage operations refactoring.\n */\n tenant: string;\n locale: string;\n webinyVersion: string;\n /**\n * User can add new fields to the File object, so we must allow it in the types.\n */\n\n [key: string]: any;\n}\n\nexport interface FileAlias {\n tenant: string;\n locale: string;\n fileId: string;\n alias: string;\n}\n\nexport interface CreatedBy {\n id: string;\n displayName: string | null;\n type: string;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["file.ts"],"sourcesContent":["type PublicAccess = {\n type: \"public\";\n};\n\ntype PrivateAuthenticatedAccess = {\n type: \"private-authenticated\";\n};\n\nexport interface File {\n id: string;\n key: string;\n size: number;\n type: string;\n name: string;\n meta: Record<string, any>;\n accessControl?: PublicAccess | PrivateAuthenticatedAccess;\n location: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n\n createdOn: string;\n modifiedOn: string | null;\n savedOn: string;\n createdBy: CreatedBy;\n modifiedBy: CreatedBy | null;\n savedBy: CreatedBy;\n extensions?: Record<string, any>;\n\n /**\n * Added with new storage operations refactoring.\n */\n tenant: string;\n locale: string;\n webinyVersion: string;\n /**\n * User can add new fields to the File object, so we must allow it in the types.\n */\n\n [key: string]: any;\n}\n\nexport interface FileAlias {\n tenant: string;\n locale: string;\n fileId: string;\n alias: string;\n}\n\nexport interface CreatedBy {\n id: string;\n displayName: string | null;\n type: string;\n}\n"],"mappings":"","ignoreList":[]}
package/types.d.ts CHANGED
@@ -6,7 +6,7 @@ import { Context } from "@webiny/api/types";
6
6
  import { FileLifecycleEvents } from "./types/file.lifecycle";
7
7
  import { CreatedBy, File } from "./types/file";
8
8
  import { Topic } from "@webiny/pubsub/types";
9
- import { CmsContext } from "@webiny/api-headless-cms/types";
9
+ import { CmsContext, CmsEntryListSort } from "@webiny/api-headless-cms/types";
10
10
  import { Context as TasksContext } from "@webiny/tasks/types";
11
11
  export * from "./types/file.lifecycle";
12
12
  export * from "./types/file";
@@ -52,7 +52,7 @@ export interface FilesListOpts {
52
52
  limit?: number;
53
53
  after?: string;
54
54
  where?: FileListWhereParams;
55
- sort?: string[];
55
+ sort?: CmsEntryListSort;
56
56
  }
57
57
  export interface FileListMeta {
58
58
  cursor: string | null;
@@ -114,7 +114,7 @@ export interface OnSettingsAfterUpdateTopicParams {
114
114
  original: FileManagerSettings;
115
115
  settings: FileManagerSettings;
116
116
  }
117
- export declare type SettingsCRUD = {
117
+ export type SettingsCRUD = {
118
118
  getSettings(): Promise<FileManagerSettings | null>;
119
119
  createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
120
120
  updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
@@ -286,7 +286,7 @@ export interface FileManagerFilesStorageOperationsListParamsWhere {
286
286
  */
287
287
  export interface FileManagerFilesStorageOperationsListParams {
288
288
  where: FileManagerFilesStorageOperationsListParamsWhere;
289
- sort: string[];
289
+ sort: CmsEntryListSort;
290
290
  limit: number;
291
291
  after: string | null;
292
292
  search?: string;
@@ -301,7 +301,7 @@ export interface FileManagerFilesStorageOperationsListResponseMeta {
301
301
  totalCount: number;
302
302
  cursor: string | null;
303
303
  }
304
- export declare type FileManagerFilesStorageOperationsListResponse = [
304
+ export type FileManagerFilesStorageOperationsListResponse = [
305
305
  File[],
306
306
  FileManagerFilesStorageOperationsListResponseMeta
307
307
  ];
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_file","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_file2"],"sources":["types.ts"],"sourcesContent":["import { I18NContext } from \"@webiny/api-i18n/types\";\nimport { FileStorage } from \"./storage/FileStorage\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { SecurityContext, SecurityPermission } from \"@webiny/api-security/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { FileLifecycleEvents } from \"./types/file.lifecycle\";\nimport { CreatedBy, File } from \"./types/file\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { Context as TasksContext } from \"@webiny/tasks/types\";\n\nexport * from \"./types/file.lifecycle\";\nexport * from \"./types/file\";\nexport * from \"./types/file\";\n\nexport interface FileManagerContextObject extends FilesCRUD, SettingsCRUD, SystemCRUD {\n storage: FileStorage;\n}\n\nexport interface FileManagerContext\n extends Context,\n SecurityContext,\n TenancyContext,\n I18NContext,\n CmsContext,\n TasksContext {\n fileManager: FileManagerContextObject;\n}\n\nexport interface FilePermission extends SecurityPermission {\n name: \"fm.file\";\n rwd?: string;\n own?: boolean;\n}\n\nexport interface FileInput {\n id: string;\n\n // In the background, we're actually mapping these to entry-level fields.\n // This is fine since we don't use revisions for files.\n createdOn?: string | Date | null;\n modifiedOn?: string | Date | null;\n savedOn?: string | Date | null;\n createdBy?: CreatedBy | null;\n modifiedBy?: CreatedBy | null;\n savedBy?: CreatedBy | null;\n\n key: string;\n name: string;\n size: number;\n type: string;\n meta: Record<string, any>;\n location?: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n extensions?: Record<string, any>;\n}\n\nexport interface FileListWhereParams {\n AND?: FileListWhereParams[];\n OR?: FileListWhereParams[];\n [key: string]: any;\n}\nexport interface FilesListOpts {\n search?: string;\n limit?: number;\n after?: string;\n where?: FileListWhereParams;\n sort?: string[];\n}\n\nexport interface FileListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\ninterface FilesCrudListTagsWhere {\n tag?: string;\n tag_contains?: string;\n tag_in?: string[];\n tag_not_startsWith?: string;\n tag_startsWith?: string;\n}\ninterface FilesCrudListTagsParams {\n where?: FilesCrudListTagsWhere;\n limit?: number;\n after?: string;\n}\n\nexport interface ListTagsResponse {\n tag: string;\n count: number;\n}\nexport interface FilesCRUD extends FileLifecycleEvents {\n getFile(id: string): Promise<File>;\n listFiles(opts?: FilesListOpts): Promise<[File[], FileListMeta]>;\n listTags(params: FilesCrudListTagsParams): Promise<ListTagsResponse[]>;\n createFile(data: FileInput, meta?: Record<string, any>): Promise<File>;\n updateFile(id: string, data: Partial<FileInput>): Promise<File>;\n deleteFile(id: string): Promise<boolean>;\n createFilesInBatch(data: FileInput[], meta?: Record<string, any>): Promise<File[]>;\n}\n\nexport interface SystemCRUD {\n onSystemBeforeInstall: Topic;\n onSystemAfterInstall: Topic;\n getVersion(): Promise<string | null>;\n setVersion(version: string): Promise<void>;\n install(args: { srcPrefix: string }): Promise<boolean>;\n}\n\nexport interface FileManagerSettings {\n tenant: string;\n key: string;\n uploadMinFileSize: number;\n uploadMaxFileSize: number;\n srcPrefix: string;\n}\n\nexport interface FileManagerSystem {\n version: string;\n tenant: string;\n}\n\nexport interface OnSettingsBeforeUpdateTopicParams {\n input: Partial<FileManagerSettings>;\n original: FileManagerSettings;\n settings: FileManagerSettings;\n}\n\nexport interface OnSettingsAfterUpdateTopicParams {\n input: Partial<FileManagerSettings>;\n original: FileManagerSettings;\n settings: FileManagerSettings;\n}\n\nexport type SettingsCRUD = {\n getSettings(): Promise<FileManagerSettings | null>;\n createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n deleteSettings(): Promise<boolean>;\n\n onSettingsBeforeUpdate: Topic<OnSettingsBeforeUpdateTopicParams>;\n onSettingsAfterUpdate: Topic<OnSettingsAfterUpdateTopicParams>;\n};\n/********\n * Storage operations\n *******/\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsUpdateParams {\n /**\n * The system data to be updated.\n */\n original: FileManagerSystem;\n /**\n * The system data with the updated fields.\n */\n data: FileManagerSystem;\n}\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsCreateParams {\n /**\n * The system fields.\n */\n data: FileManagerSystem;\n}\n\nexport interface FileManagerSystemStorageOperationsGetParams {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n */\nexport interface FileManagerSystemStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (params: FileManagerSystemStorageOperationsGetParams) => Promise<FileManagerSystem | null>;\n /**\n * Update the FileManager system data..\n */\n update: (params: FileManagerSystemStorageOperationsUpdateParams) => Promise<FileManagerSystem>;\n /**\n * Create the FileManagerSystemData\n */\n create: (params: FileManagerSystemStorageOperationsCreateParams) => Promise<FileManagerSystem>;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsUpdateParams {\n /**\n * Original settings to be updated.\n */\n original: FileManagerSettings;\n /**\n * The settings with the updated fields.\n */\n data: FileManagerSettings;\n}\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsCreateParams {\n /**\n * The settings fields.\n */\n data: FileManagerSettings;\n}\n\nexport interface FileManagerStorageOperationsGetSettingsParams {\n tenant: string;\n}\n\nexport interface FileManagerStorageOperationsDeleteSettings {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n */\nexport interface FileManagerSettingsStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (\n params: FileManagerStorageOperationsGetSettingsParams\n ) => Promise<FileManagerSettings | null>;\n /**\n * Create the FileManagerSettingsData\n */\n create: (\n params: FileManagerSettingsStorageOperationsCreateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Update the FileManager system data..\n */\n update: (\n params: FileManagerSettingsStorageOperationsUpdateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Delete the existing settings.\n */\n delete: (params: FileManagerStorageOperationsDeleteSettings) => Promise<void>;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsUpdateParams {\n original: File;\n file: File;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsDeleteParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateBatchParams {\n files: File[];\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParamsWhere {\n [key: string]: any;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParams {\n where: FileManagerFilesStorageOperationsListParamsWhere;\n sort: string[];\n limit: number;\n after: string | null;\n search?: string;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListResponseMeta {\n hasMoreItems: boolean;\n totalCount: number;\n cursor: string | null;\n}\nexport type FileManagerFilesStorageOperationsListResponse = [\n File[],\n FileManagerFilesStorageOperationsListResponseMeta\n];\n\nexport interface FileManagerFilesStorageOperationsTagsResponse {\n tag: string;\n count: number;\n}\n\nexport interface FileManagerFilesStorageOperationsTagsParamsWhere extends FilesCrudListTagsWhere {\n locale: string;\n tenant: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsTagsParams {\n where: FileManagerFilesStorageOperationsTagsParamsWhere;\n limit: number;\n after?: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n */\nexport interface FileManagerFilesStorageOperations {\n /**\n * Get a single file with given ID from the storage.\n */\n get: (params: FileManagerFilesStorageOperationsGetParams) => Promise<File | null>;\n /**\n * Insert the file data into the database.\n */\n create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File>;\n /**\n * Update the file data in the database.\n */\n update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File>;\n /**\n * Delete the file from the database.\n */\n delete: (params: FileManagerFilesStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Store multiple files at once to the database.\n */\n createBatch: (params: FileManagerFilesStorageOperationsCreateBatchParams) => Promise<File[]>;\n /**\n * Get a list of files filtered by given parameters.\n */\n list: (\n params: FileManagerFilesStorageOperationsListParams\n ) => Promise<FileManagerFilesStorageOperationsListResponse>;\n /**\n * Get a list of all file tags filtered by given parameters.\n */\n tags: (\n params: FileManagerFilesStorageOperationsTagsParams\n ) => Promise<FileManagerFilesStorageOperationsTagsResponse[]>;\n}\n\nexport interface FileManagerAliasesStorageOperations {\n storeAliases(file: File): Promise<void>;\n deleteAliases(file: File): Promise<void>;\n}\n\nexport interface FileManagerStorageOperations<TContext = FileManagerContext> {\n beforeInit?: (context: TContext) => Promise<void>;\n files: FileManagerFilesStorageOperations;\n aliases: FileManagerAliasesStorageOperations;\n settings: FileManagerSettingsStorageOperations;\n system: FileManagerSystemStorageOperations;\n}\n"],"mappings":";;;;;AAWA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AACAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["_file","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_file2"],"sources":["types.ts"],"sourcesContent":["import { I18NContext } from \"@webiny/api-i18n/types\";\nimport { FileStorage } from \"./storage/FileStorage\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { SecurityContext, SecurityPermission } from \"@webiny/api-security/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { FileLifecycleEvents } from \"./types/file.lifecycle\";\nimport { CreatedBy, File } from \"./types/file\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { CmsContext, CmsEntryListSort } from \"@webiny/api-headless-cms/types\";\nimport { Context as TasksContext } from \"@webiny/tasks/types\";\n\nexport * from \"./types/file.lifecycle\";\nexport * from \"./types/file\";\nexport * from \"./types/file\";\n\nexport interface FileManagerContextObject extends FilesCRUD, SettingsCRUD, SystemCRUD {\n storage: FileStorage;\n}\n\nexport interface FileManagerContext\n extends Context,\n SecurityContext,\n TenancyContext,\n I18NContext,\n CmsContext,\n TasksContext {\n fileManager: FileManagerContextObject;\n}\n\nexport interface FilePermission extends SecurityPermission {\n name: \"fm.file\";\n rwd?: string;\n own?: boolean;\n}\n\nexport interface FileInput {\n id: string;\n\n // In the background, we're actually mapping these to entry-level fields.\n // This is fine since we don't use revisions for files.\n createdOn?: string | Date | null;\n modifiedOn?: string | Date | null;\n savedOn?: string | Date | null;\n createdBy?: CreatedBy | null;\n modifiedBy?: CreatedBy | null;\n savedBy?: CreatedBy | null;\n\n key: string;\n name: string;\n size: number;\n type: string;\n meta: Record<string, any>;\n location?: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n extensions?: Record<string, any>;\n}\n\nexport interface FileListWhereParams {\n AND?: FileListWhereParams[];\n OR?: FileListWhereParams[];\n [key: string]: any;\n}\nexport interface FilesListOpts {\n search?: string;\n limit?: number;\n after?: string;\n where?: FileListWhereParams;\n sort?: CmsEntryListSort;\n}\n\nexport interface FileListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\ninterface FilesCrudListTagsWhere {\n tag?: string;\n tag_contains?: string;\n tag_in?: string[];\n tag_not_startsWith?: string;\n tag_startsWith?: string;\n}\ninterface FilesCrudListTagsParams {\n where?: FilesCrudListTagsWhere;\n limit?: number;\n after?: string;\n}\n\nexport interface ListTagsResponse {\n tag: string;\n count: number;\n}\nexport interface FilesCRUD extends FileLifecycleEvents {\n getFile(id: string): Promise<File>;\n listFiles(opts?: FilesListOpts): Promise<[File[], FileListMeta]>;\n listTags(params: FilesCrudListTagsParams): Promise<ListTagsResponse[]>;\n createFile(data: FileInput, meta?: Record<string, any>): Promise<File>;\n updateFile(id: string, data: Partial<FileInput>): Promise<File>;\n deleteFile(id: string): Promise<boolean>;\n createFilesInBatch(data: FileInput[], meta?: Record<string, any>): Promise<File[]>;\n}\n\nexport interface SystemCRUD {\n onSystemBeforeInstall: Topic;\n onSystemAfterInstall: Topic;\n getVersion(): Promise<string | null>;\n setVersion(version: string): Promise<void>;\n install(args: { srcPrefix: string }): Promise<boolean>;\n}\n\nexport interface FileManagerSettings {\n tenant: string;\n key: string;\n uploadMinFileSize: number;\n uploadMaxFileSize: number;\n srcPrefix: string;\n}\n\nexport interface FileManagerSystem {\n version: string;\n tenant: string;\n}\n\nexport interface OnSettingsBeforeUpdateTopicParams {\n input: Partial<FileManagerSettings>;\n original: FileManagerSettings;\n settings: FileManagerSettings;\n}\n\nexport interface OnSettingsAfterUpdateTopicParams {\n input: Partial<FileManagerSettings>;\n original: FileManagerSettings;\n settings: FileManagerSettings;\n}\n\nexport type SettingsCRUD = {\n getSettings(): Promise<FileManagerSettings | null>;\n createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n deleteSettings(): Promise<boolean>;\n\n onSettingsBeforeUpdate: Topic<OnSettingsBeforeUpdateTopicParams>;\n onSettingsAfterUpdate: Topic<OnSettingsAfterUpdateTopicParams>;\n};\n/********\n * Storage operations\n *******/\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsUpdateParams {\n /**\n * The system data to be updated.\n */\n original: FileManagerSystem;\n /**\n * The system data with the updated fields.\n */\n data: FileManagerSystem;\n}\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsCreateParams {\n /**\n * The system fields.\n */\n data: FileManagerSystem;\n}\n\nexport interface FileManagerSystemStorageOperationsGetParams {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n */\nexport interface FileManagerSystemStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (params: FileManagerSystemStorageOperationsGetParams) => Promise<FileManagerSystem | null>;\n /**\n * Update the FileManager system data..\n */\n update: (params: FileManagerSystemStorageOperationsUpdateParams) => Promise<FileManagerSystem>;\n /**\n * Create the FileManagerSystemData\n */\n create: (params: FileManagerSystemStorageOperationsCreateParams) => Promise<FileManagerSystem>;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsUpdateParams {\n /**\n * Original settings to be updated.\n */\n original: FileManagerSettings;\n /**\n * The settings with the updated fields.\n */\n data: FileManagerSettings;\n}\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsCreateParams {\n /**\n * The settings fields.\n */\n data: FileManagerSettings;\n}\n\nexport interface FileManagerStorageOperationsGetSettingsParams {\n tenant: string;\n}\n\nexport interface FileManagerStorageOperationsDeleteSettings {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n */\nexport interface FileManagerSettingsStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (\n params: FileManagerStorageOperationsGetSettingsParams\n ) => Promise<FileManagerSettings | null>;\n /**\n * Create the FileManagerSettingsData\n */\n create: (\n params: FileManagerSettingsStorageOperationsCreateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Update the FileManager system data..\n */\n update: (\n params: FileManagerSettingsStorageOperationsUpdateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Delete the existing settings.\n */\n delete: (params: FileManagerStorageOperationsDeleteSettings) => Promise<void>;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsUpdateParams {\n original: File;\n file: File;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsDeleteParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateBatchParams {\n files: File[];\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParamsWhere {\n [key: string]: any;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParams {\n where: FileManagerFilesStorageOperationsListParamsWhere;\n sort: CmsEntryListSort;\n limit: number;\n after: string | null;\n search?: string;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListResponseMeta {\n hasMoreItems: boolean;\n totalCount: number;\n cursor: string | null;\n}\nexport type FileManagerFilesStorageOperationsListResponse = [\n File[],\n FileManagerFilesStorageOperationsListResponseMeta\n];\n\nexport interface FileManagerFilesStorageOperationsTagsResponse {\n tag: string;\n count: number;\n}\n\nexport interface FileManagerFilesStorageOperationsTagsParamsWhere extends FilesCrudListTagsWhere {\n locale: string;\n tenant: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsTagsParams {\n where: FileManagerFilesStorageOperationsTagsParamsWhere;\n limit: number;\n after?: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n */\nexport interface FileManagerFilesStorageOperations {\n /**\n * Get a single file with given ID from the storage.\n */\n get: (params: FileManagerFilesStorageOperationsGetParams) => Promise<File | null>;\n /**\n * Insert the file data into the database.\n */\n create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File>;\n /**\n * Update the file data in the database.\n */\n update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File>;\n /**\n * Delete the file from the database.\n */\n delete: (params: FileManagerFilesStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Store multiple files at once to the database.\n */\n createBatch: (params: FileManagerFilesStorageOperationsCreateBatchParams) => Promise<File[]>;\n /**\n * Get a list of files filtered by given parameters.\n */\n list: (\n params: FileManagerFilesStorageOperationsListParams\n ) => Promise<FileManagerFilesStorageOperationsListResponse>;\n /**\n * Get a list of all file tags filtered by given parameters.\n */\n tags: (\n params: FileManagerFilesStorageOperationsTagsParams\n ) => Promise<FileManagerFilesStorageOperationsTagsResponse[]>;\n}\n\nexport interface FileManagerAliasesStorageOperations {\n storeAliases(file: File): Promise<void>;\n deleteAliases(file: File): Promise<void>;\n}\n\nexport interface FileManagerStorageOperations<TContext = FileManagerContext> {\n beforeInit?: (context: TContext) => Promise<void>;\n files: FileManagerFilesStorageOperations;\n aliases: FileManagerAliasesStorageOperations;\n settings: FileManagerSettingsStorageOperations;\n system: FileManagerSystemStorageOperations;\n}\n"],"mappings":";;;;;AAWA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AACAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}