@webiny/api-file-manager 5.37.8 → 5.38.0-beta.1
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/FileManagerContextSetup.js +3 -1
- package/cmsFileStorage/CmsFilesStorage.js +3 -1
- package/cmsFileStorage/ListFilesWhereProcessor.js +3 -1
- package/cmsFileStorage/ListTagsWhereProcessor.js +3 -1
- package/cmsFileStorage/createFileManagerPlugins.js +3 -1
- package/cmsFileStorage/createModelField.js +3 -1
- package/cmsFileStorage/file.model.js +3 -1
- package/cmsFileStorage/isInstallationPending.js +3 -1
- package/contants.js +3 -1
- package/createFileManager/files.crud.js +8 -1
- package/createFileManager/files.crud.js.map +1 -1
- package/createFileManager/filevalidation.disabled.js +3 -1
- package/createFileManager/index.js +3 -1
- package/createFileManager/permissions/FilesPermissions.js +3 -1
- package/createFileManager/settings.crud.js +23 -8
- package/createFileManager/settings.crud.js.map +1 -1
- package/createFileManager/system.crud.js +3 -1
- package/graphql/baseSchema.js +3 -1
- package/graphql/createFilesTypeDefs.js +3 -1
- package/graphql/filesSchema.js +3 -1
- package/graphql/index.js +3 -1
- package/graphql/utils.d.ts +1 -1
- package/graphql/utils.js +3 -1
- package/handlers/download/byAlias.js +3 -1
- package/handlers/download/byExactKey.js +3 -1
- package/handlers/download/extractFileInformation.js +3 -1
- package/handlers/download/getS3Object.js +3 -1
- package/handlers/download/index.js +3 -1
- package/handlers/manage/index.js +3 -1
- package/handlers/transform/index.js +3 -1
- package/handlers/transform/legacyUtils.js +3 -1
- package/handlers/transform/loaders/imageLoader.js +3 -1
- package/handlers/transform/loaders/index.js +3 -1
- package/handlers/transform/loaders/sanitizeImageTransformations.js +3 -1
- package/handlers/transform/managers/imageManager.js +3 -1
- package/handlers/transform/managers/index.js +3 -1
- package/handlers/transform/optimizeImage.js +3 -1
- package/handlers/transform/transformImage.js +3 -1
- package/handlers/transform/utils.js +3 -1
- package/handlers/types.js +3 -1
- package/handlers/utils/getEnvironment.js +3 -1
- package/handlers/utils/getObjectParams.js +3 -1
- package/handlers/utils/index.js +3 -1
- package/index.js +3 -1
- package/modelModifier/CmsModelModifier.js +3 -1
- package/package.json +18 -18
- package/plugins/FilePhysicalStoragePlugin.js +3 -1
- package/plugins/FileStorageTransformPlugin.js +3 -1
- package/plugins/index.js +3 -1
- package/storage/FileStorage.js +3 -1
- package/types/file.js +3 -1
- package/types/file.lifecycle.js +3 -1
- package/types.d.ts +12 -0
- package/types.js +3 -1
- package/types.js.map +1 -1
|
@@ -31,4 +31,6 @@ const createFileManagerPlugins = () => {
|
|
|
31
31
|
fileModelDefinition: (0, _file.createFileModelDefinition)(groupPlugin.contentModelGroup)
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
exports.createFileManagerPlugins = createFileManagerPlugins;
|
|
34
|
+
exports.createFileManagerPlugins = createFileManagerPlugins;
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=createFileManagerPlugins.js.map
|
|
@@ -121,4 +121,6 @@ const createFileModelDefinition = group => {
|
|
|
121
121
|
noValidate: true
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
|
-
exports.createFileModelDefinition = createFileModelDefinition;
|
|
124
|
+
exports.createFileModelDefinition = createFileModelDefinition;
|
|
125
|
+
|
|
126
|
+
//# sourceMappingURL=file.model.js.map
|
package/contants.js
CHANGED
|
@@ -10,6 +10,7 @@ var _handlerGraphql = require("@webiny/handler-graphql");
|
|
|
10
10
|
var _pubsub = require("@webiny/pubsub");
|
|
11
11
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
12
12
|
var _contants = require("../contants");
|
|
13
|
+
var _apiSecurity = require("@webiny/api-security");
|
|
13
14
|
const createFilesCrud = config => {
|
|
14
15
|
const {
|
|
15
16
|
storageOperations,
|
|
@@ -91,6 +92,10 @@ const createFilesCrud = config => {
|
|
|
91
92
|
});
|
|
92
93
|
return result;
|
|
93
94
|
} catch (ex) {
|
|
95
|
+
// If a `NotAuthorizedError` error was thrown, then we just want to rethrow it.
|
|
96
|
+
if (ex instanceof _apiSecurity.NotAuthorizedError) {
|
|
97
|
+
throw ex;
|
|
98
|
+
}
|
|
94
99
|
throw new _error.default(ex.message || "Could not create a file.", ex.code || "CREATE_FILE_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
|
|
95
100
|
file
|
|
96
101
|
}));
|
|
@@ -297,4 +302,6 @@ const createFilesCrud = config => {
|
|
|
297
302
|
}
|
|
298
303
|
};
|
|
299
304
|
};
|
|
300
|
-
exports.createFilesCrud = createFilesCrud;
|
|
305
|
+
exports.createFilesCrud = createFilesCrud;
|
|
306
|
+
|
|
307
|
+
//# sourceMappingURL=files.crud.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerGraphql","require","_pubsub","_error","_interopRequireDefault","_contants","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","_input$location","identity","key","split","_objectSpread2","default","tags","Array","isArray","aliases","location","folderId","ROOT_FOLDER","private","createdOn","Date","toISOString","savedOn","displayName","type","webinyVersion","publish","result","create","ex","WebinyError","message","code","data","updateFile","original","update","deleteFile","delete","createFilesInBatch","inputs","map","_input$location2","results","createBatch","listFiles","params","limit","after","initialWhere","sort","initialSort","search","private_not","canAccessOnlyOwnRecords","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 CreatedBy,\n File,\n FileManagerFilesStorageOperationsListParamsWhere,\n FileManagerFilesStorageOperationsTagsParamsWhere,\n FilesCRUD,\n FilesListOpts\n} from \"~/types\";\nimport { FileManagerConfig } from \"~/createFileManager/index\";\nimport { ROOT_FOLDER } from \"~/contants\";\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 const identity = getIdentity();\n\n // Extract ID from file key\n const [id] = input.key.split(\"/\");\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 tenant: getTenantId(),\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\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 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 file: File = {\n ...original,\n ...input,\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 identity = getIdentity();\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n const createdBy: CreatedBy = {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n };\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 tenant,\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n createdBy,\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;AAUA,IAAAI,SAAA,GAAAJ,OAAA;AAEO,MAAMK,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,CAAC;IAC/DE,uBAAuB,EAAE,IAAAF,mBAAW,EAAC,qCAAqC,CAAC;IAC3EG,sBAAsB,EAAE,IAAAH,mBAAW,EAAC,oCAAoC,CAAC;IACzEI,kBAAkB,EAAE,IAAAJ,mBAAW,EAAC,gCAAgC,CAAC;IACjEK,iBAAiB,EAAE,IAAAL,mBAAW,EAAC,+BAA+B,CAAC;IAC/DM,kBAAkB,EAAE,IAAAN,mBAAW,EAAC,gCAAgC,CAAC;IACjEO,iBAAiB,EAAE,IAAAP,mBAAW,EAAC,+BAA+B,CAAC;IAC/D,MAAMQ,OAAOA,CAACC,EAAU,EAAE;MACtB,MAAMf,gBAAgB,CAACgB,MAAM,CA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AE/B,MAAMK,KAAuD,OAAAa,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MACtDuC,YAAY;QACfpD,MAAM,EAAEpB,WAAW,CAAC,CAAC;QACrBqB,MAAM,EAAEtB,aAAa,CAAC;MAAC,EAC1B;MAED,MAAMsE,MAAM,GAAG;QACXlD,KAAK;QACLmD,KAAK,EAAEA,KAAK,IAAI,OAAO;QACvBC;MACJ,CAAC;MAED,IAAI;QACA,OAAO,MAAM1E,iBAAiB,CAACoB,KAAK,CAACiB,IAAI,CAACmC,MAAM,CAAC;MACrD,CAAC,CAAC,OAAOjB,EAAE,EAAE;QACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,4BAA4B,EAC1CF,EAAE,CAACG,IAAI,IAAI,uBAAuB,MAAAvB,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MAE1BmB,EAAE,CAACI,IAAI,IAAI,CAAC,CAAC;UACjBa;QAAM,EAEd,CAAC;MACL;IACJ;EACJ,CAAC;AACL,CAAC;AAACY,OAAA,CAAAtF,eAAA,GAAAA,eAAA"}
|
|
1
|
+
{"version":3,"names":["_handlerGraphql","require","_pubsub","_error","_interopRequireDefault","_contants","_apiSecurity","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","_input$location","identity","key","split","_objectSpread2","default","tags","Array","isArray","aliases","location","folderId","ROOT_FOLDER","private","createdOn","Date","toISOString","savedOn","displayName","type","webinyVersion","publish","result","create","ex","NotAuthorizedError","WebinyError","message","code","data","updateFile","original","update","deleteFile","delete","createFilesInBatch","inputs","map","_input$location2","results","createBatch","listFiles","params","limit","after","initialWhere","sort","initialSort","search","private_not","canAccessOnlyOwnRecords","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 CreatedBy,\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\";\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 const identity = getIdentity();\n\n // Extract ID from file key\n const [id] = input.key.split(\"/\");\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 tenant: getTenantId(),\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\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 file: File = {\n ...original,\n ...input,\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 identity = getIdentity();\n const tenant = getTenantId();\n const locale = getLocaleCode();\n\n const createdBy: CreatedBy = {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n };\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 tenant,\n createdOn: new Date().toISOString(),\n savedOn: new Date().toISOString(),\n createdBy,\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;AAUA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AAEO,MAAMM,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,CAAC;IAC/DE,uBAAuB,EAAE,I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FilesPermissions = void 0;
|
|
7
7
|
var _AppPermissions = require("@webiny/api-security/utils/AppPermissions");
|
|
8
8
|
class FilesPermissions extends _AppPermissions.AppPermissions {}
|
|
9
|
-
exports.FilesPermissions = FilesPermissions;
|
|
9
|
+
exports.FilesPermissions = FilesPermissions;
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=FilesPermissions.js.map
|
|
@@ -6,13 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.createSettingsCrud = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _pubsub = require("@webiny/pubsub");
|
|
9
10
|
var _fields = require("@commodo/fields");
|
|
10
11
|
var _validation = require("@webiny/validation");
|
|
11
12
|
/**
|
|
12
13
|
* Package @commodo/fields does not have types.
|
|
13
|
-
*/
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
|
|
14
|
+
*/ // @ts-ignore
|
|
16
15
|
const CreateDataModel = (0, _fields.withFields)({
|
|
17
16
|
uploadMinFileSize: (0, _fields.number)({
|
|
18
17
|
value: 0,
|
|
@@ -49,6 +48,8 @@ const createSettingsCrud = ({
|
|
|
49
48
|
getTenantId
|
|
50
49
|
}) => {
|
|
51
50
|
return {
|
|
51
|
+
onSettingsBeforeUpdate: (0, _pubsub.createTopic)("fileManager.onSettingsBeforeUpdate"),
|
|
52
|
+
onSettingsAfterUpdate: (0, _pubsub.createTopic)("fileManager.onSettingsAfterUpdate"),
|
|
52
53
|
async getSettings() {
|
|
53
54
|
return storageOperations.settings.get({
|
|
54
55
|
tenant: getTenantId()
|
|
@@ -73,12 +74,24 @@ const createSettingsCrud = ({
|
|
|
73
74
|
const updatedSettings = await updatedValue.toJSON({
|
|
74
75
|
onlyDirty: true
|
|
75
76
|
});
|
|
76
|
-
|
|
77
|
+
const settings = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingSettings), updatedSettings), {}, {
|
|
78
|
+
tenant: getTenantId()
|
|
79
|
+
});
|
|
80
|
+
await this.onSettingsBeforeUpdate.publish({
|
|
81
|
+
input: data,
|
|
77
82
|
original: existingSettings,
|
|
78
|
-
|
|
79
|
-
tenant: getTenantId()
|
|
80
|
-
})
|
|
83
|
+
settings
|
|
81
84
|
});
|
|
85
|
+
const result = await storageOperations.settings.update({
|
|
86
|
+
original: existingSettings,
|
|
87
|
+
data: settings
|
|
88
|
+
});
|
|
89
|
+
await this.onSettingsAfterUpdate.publish({
|
|
90
|
+
input: data,
|
|
91
|
+
original: existingSettings,
|
|
92
|
+
settings: result
|
|
93
|
+
});
|
|
94
|
+
return result;
|
|
82
95
|
},
|
|
83
96
|
async deleteSettings() {
|
|
84
97
|
await storageOperations.settings.delete({
|
|
@@ -88,4 +101,6 @@ const createSettingsCrud = ({
|
|
|
88
101
|
}
|
|
89
102
|
};
|
|
90
103
|
};
|
|
91
|
-
exports.createSettingsCrud = createSettingsCrud;
|
|
104
|
+
exports.createSettingsCrud = createSettingsCrud;
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=settings.crud.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_pubsub","require","_fields","_validation","CreateDataModel","withFields","uploadMinFileSize","number","value","validation","create","uploadMaxFileSize","srcPrefix","onSet","endsWith","string","UpdateDataModel","createSettingsCrud","storageOperations","getTenantId","onSettingsBeforeUpdate","createTopic","onSettingsAfterUpdate","getSettings","settings","get","tenant","createSettings","data","populate","validate","settingsData","toJSON","_objectSpread2","default","updateSettings","updatedValue","existingSettings","updatedSettings","onlyDirty","publish","input","original","result","update","deleteSettings","delete","exports"],"sources":["settings.crud.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\n/**\n * Package @commodo/fields does not have types.\n */\n// @ts-ignore\nimport { withFields, string, number, onSet } from \"@commodo/fields\";\nimport { validation } from \"@webiny/validation\";\nimport { FileManagerSettings, SettingsCRUD } from \"~/types\";\nimport { FileManagerConfig } from \"~/createFileManager/index\";\n\nconst CreateDataModel = withFields({\n uploadMinFileSize: number({ value: 0, validation: validation.create(\"gte:0\") }),\n uploadMaxFileSize: number({ value: 10737418240 }),\n srcPrefix: onSet((value?: string) => {\n // Make sure srcPrefix always ends with forward slash.\n if (typeof value === \"string\") {\n return value.endsWith(\"/\") ? value : value + \"/\";\n }\n return value;\n })(string({ value: \"/files/\" }))\n})();\n\nconst UpdateDataModel = withFields({\n uploadMinFileSize: number({\n validation: validation.create(\"gte:0\")\n }),\n uploadMaxFileSize: number(),\n srcPrefix: onSet((value?: string) => {\n // Make sure srcPrefix always ends with forward slash.\n if (typeof value === \"string\") {\n return value.endsWith(\"/\") ? value : value + \"/\";\n }\n return value;\n })(string())\n})();\n\nexport const createSettingsCrud = ({\n storageOperations,\n getTenantId\n}: FileManagerConfig): SettingsCRUD => {\n return {\n onSettingsBeforeUpdate: createTopic(\"fileManager.onSettingsBeforeUpdate\"),\n onSettingsAfterUpdate: createTopic(\"fileManager.onSettingsAfterUpdate\"),\n async getSettings() {\n return storageOperations.settings.get({ tenant: getTenantId() });\n },\n async createSettings(data) {\n const settings = new CreateDataModel().populate(data);\n await settings.validate();\n\n const settingsData: FileManagerSettings = await settings.toJSON();\n\n return storageOperations.settings.create({\n data: { ...settingsData, tenant: getTenantId() }\n });\n },\n async updateSettings(data) {\n const updatedValue = new UpdateDataModel().populate(data);\n await updatedValue.validate();\n\n const existingSettings = (await storageOperations.settings.get({\n tenant: getTenantId()\n })) as FileManagerSettings;\n\n const updatedSettings: Partial<FileManagerSettings> = await updatedValue.toJSON({\n onlyDirty: true\n });\n\n const settings: FileManagerSettings = {\n ...existingSettings,\n ...updatedSettings,\n tenant: getTenantId()\n };\n\n await this.onSettingsBeforeUpdate.publish({\n input: data,\n original: existingSettings,\n settings\n });\n const result = await storageOperations.settings.update({\n original: existingSettings,\n data: settings\n });\n await this.onSettingsAfterUpdate.publish({\n input: data,\n original: existingSettings,\n settings: result\n });\n\n return result;\n },\n async deleteSettings() {\n await storageOperations.settings.delete({ tenant: getTenantId() });\n\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AALA;AACA;AACA,GAFA,CAGA;AAMA,MAAMG,eAAe,GAAG,IAAAC,kBAAU,EAAC;EAC/BC,iBAAiB,EAAE,IAAAC,cAAM,EAAC;IAAEC,KAAK,EAAE,CAAC;IAAEC,UAAU,EAAEA,sBAAU,CAACC,MAAM,CAAC,OAAO;EAAE,CAAC,CAAC;EAC/EC,iBAAiB,EAAE,IAAAJ,cAAM,EAAC;IAAEC,KAAK,EAAE;EAAY,CAAC,CAAC;EACjDI,SAAS,EAAE,IAAAC,aAAK,EAAEL,KAAc,IAAK;IACjC;IACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC3B,OAAOA,KAAK,CAACM,QAAQ,CAAC,GAAG,CAAC,GAAGN,KAAK,GAAGA,KAAK,GAAG,GAAG;IACpD;IACA,OAAOA,KAAK;EAChB,CAAC,CAAC,CAAC,IAAAO,cAAM,EAAC;IAAEP,KAAK,EAAE;EAAU,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAMQ,eAAe,GAAG,IAAAX,kBAAU,EAAC;EAC/BC,iBAAiB,EAAE,IAAAC,cAAM,EAAC;IACtBE,UAAU,EAAEA,sBAAU,CAACC,MAAM,CAAC,OAAO;EACzC,CAAC,CAAC;EACFC,iBAAiB,EAAE,IAAAJ,cAAM,EAAC,CAAC;EAC3BK,SAAS,EAAE,IAAAC,aAAK,EAAEL,KAAc,IAAK;IACjC;IACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC3B,OAAOA,KAAK,CAACM,QAAQ,CAAC,GAAG,CAAC,GAAGN,KAAK,GAAGA,KAAK,GAAG,GAAG;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AACJ,MAAM,CAAC;QAC5EO,SAAS,EAAE;MACf,CAAC,CAAC;MAEF,MAAMf,QAA6B,OAAAS,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MAC5BG,gBAAgB,GAChBC,eAAe;QAClBZ,MAAM,EAAEP,WAAW,CAAC;MAAC,EACxB;MAED,MAAM,IAAI,CAACC,sBAAsB,CAACoB,OAAO,CAAC;QACtCC,KAAK,EAAEb,IAAI;QACXc,QAAQ,EAAEL,gBAAgB;QAC1Bb;MACJ,CAAC,CAAC;MACF,MAAMmB,MAAM,GAAG,MAAMzB,iBAAiB,CAACM,QAAQ,CAACoB,MAAM,CAAC;QACnDF,QAAQ,EAAEL,gBAAgB;QAC1BT,IAAI,EAAEJ;MACV,CAAC,CAAC;MACF,MAAM,IAAI,CAACF,qBAAqB,CAACkB,OAAO,CAAC;QACrCC,KAAK,EAAEb,IAAI;QACXc,QAAQ,EAAEL,gBAAgB;QAC1Bb,QAAQ,EAAEmB;MACd,CAAC,CAAC;MAEF,OAAOA,MAAM;IACjB,CAAC;IACD,MAAME,cAAcA,CAAA,EAAG;MACnB,MAAM3B,iBAAiB,CAACM,QAAQ,CAACsB,MAAM,CAAC;QAAEpB,MAAM,EAAEP,WAAW,CAAC;MAAE,CAAC,CAAC;MAElE,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC4B,OAAA,CAAA9B,kBAAA,GAAAA,kBAAA"}
|
package/graphql/baseSchema.js
CHANGED
|
@@ -114,4 +114,6 @@ const createBaseSchema = () => {
|
|
|
114
114
|
fileManagerGraphQL.name = "fm.graphql.base";
|
|
115
115
|
return fileManagerGraphQL;
|
|
116
116
|
};
|
|
117
|
-
exports.createBaseSchema = createBaseSchema;
|
|
117
|
+
exports.createBaseSchema = createBaseSchema;
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=baseSchema.js.map
|
package/graphql/filesSchema.js
CHANGED
|
@@ -80,4 +80,6 @@ const createFilesSchema = params => {
|
|
|
80
80
|
fileManagerGraphQL.name = "fm.graphql.files";
|
|
81
81
|
return fileManagerGraphQL;
|
|
82
82
|
};
|
|
83
|
-
exports.createFilesSchema = createFilesSchema;
|
|
83
|
+
exports.createFilesSchema = createFilesSchema;
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=filesSchema.js.map
|
package/graphql/index.js
CHANGED
package/graphql/utils.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare const emptyResolver: () => {};
|
|
|
7
7
|
interface ResolveCallable {
|
|
8
8
|
(): Promise<any>;
|
|
9
9
|
}
|
|
10
|
-
export declare const resolve: (fn: ResolveCallable) => Promise<Response<any
|
|
10
|
+
export declare const resolve: (fn: ResolveCallable) => Promise<ErrorResponse | Response<any>>;
|
|
11
11
|
export {};
|
package/graphql/utils.js
CHANGED
|
@@ -86,4 +86,6 @@ const createDownloadFileByAliasPlugins = ({
|
|
|
86
86
|
});
|
|
87
87
|
})];
|
|
88
88
|
};
|
|
89
|
-
exports.createDownloadFileByAliasPlugins = createDownloadFileByAliasPlugins;
|
|
89
|
+
exports.createDownloadFileByAliasPlugins = createDownloadFileByAliasPlugins;
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=byAlias.js.map
|
|
@@ -54,4 +54,6 @@ const createDownloadFileByExactKeyPlugins = () => {
|
|
|
54
54
|
});
|
|
55
55
|
})];
|
|
56
56
|
};
|
|
57
|
-
exports.createDownloadFileByExactKeyPlugins = createDownloadFileByExactKeyPlugins;
|
|
57
|
+
exports.createDownloadFileByExactKeyPlugins = createDownloadFileByExactKeyPlugins;
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=byExactKey.js.map
|
|
@@ -17,4 +17,6 @@ const extractFileInformation = request => {
|
|
|
17
17
|
extension: _path.default.extname(path)
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
exports.extractFileInformation = extractFileInformation;
|
|
20
|
+
exports.extractFileInformation = extractFileInformation;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=extractFileInformation.js.map
|
package/handlers/manage/index.js
CHANGED
|
@@ -39,4 +39,6 @@ const getImageKey = ({
|
|
|
39
39
|
const prefix = getOptimizedTransformedImageKeyPrefix(key);
|
|
40
40
|
return `${prefix}${(0, _objectHash.default)(transformations)}-${key}`;
|
|
41
41
|
};
|
|
42
|
-
exports.getImageKey = getImageKey;
|
|
42
|
+
exports.getImageKey = getImageKey;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=legacyUtils.js.map
|
|
@@ -7,4 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _imageLoader = _interopRequireDefault(require("./imageLoader"));
|
|
9
9
|
var _default = [_imageLoader.default];
|
|
10
|
-
exports.default = _default;
|
|
10
|
+
exports.default = _default;
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -7,4 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _imageManager = _interopRequireDefault(require("./imageManager"));
|
|
9
9
|
var _default = [_imageManager.default];
|
|
10
|
-
exports.default = _default;
|
|
10
|
+
exports.default = _default;
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
package/handlers/types.js
CHANGED
package/handlers/utils/index.js
CHANGED
|
@@ -17,4 +17,6 @@ Object.defineProperty(exports, "getObjectParams", {
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
var _getEnvironment = _interopRequireDefault(require("./getEnvironment"));
|
|
20
|
-
var _getObjectParams = _interopRequireDefault(require("./getObjectParams"));
|
|
20
|
+
var _getObjectParams = _interopRequireDefault(require("./getObjectParams"));
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
package/index.js
CHANGED
|
@@ -49,4 +49,6 @@ exports.createFileManagerContext = createFileManagerContext;
|
|
|
49
49
|
const createFileManagerGraphQL = () => {
|
|
50
50
|
return (0, _graphql.createGraphQLSchemaPlugin)();
|
|
51
51
|
};
|
|
52
|
-
exports.createFileManagerGraphQL = createFileManagerGraphQL;
|
|
52
|
+
exports.createFileManagerGraphQL = createFileManagerGraphQL;
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -56,4 +56,6 @@ exports.CmsModelModifierPlugin = CmsModelModifierPlugin;
|
|
|
56
56
|
const createFileModelModifier = cb => {
|
|
57
57
|
return new CmsModelModifierPlugin(_file.FILE_MODEL_ID, cb);
|
|
58
58
|
};
|
|
59
|
-
exports.createFileModelModifier = createFileModelModifier;
|
|
59
|
+
exports.createFileModelModifier = createFileModelModifier;
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=CmsModelModifier.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-file-manager",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.38.0-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fm:base"
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@babel/runtime": "7.22.6",
|
|
22
22
|
"@commodo/fields": "1.1.2-beta.20",
|
|
23
|
-
"@webiny/api": "5.
|
|
24
|
-
"@webiny/api-headless-cms": "5.
|
|
25
|
-
"@webiny/api-security": "5.
|
|
26
|
-
"@webiny/api-tenancy": "5.
|
|
27
|
-
"@webiny/error": "5.
|
|
28
|
-
"@webiny/handler": "5.
|
|
29
|
-
"@webiny/handler-aws": "5.
|
|
30
|
-
"@webiny/handler-client": "5.
|
|
31
|
-
"@webiny/handler-graphql": "5.
|
|
32
|
-
"@webiny/plugins": "5.
|
|
33
|
-
"@webiny/project-utils": "5.
|
|
34
|
-
"@webiny/pubsub": "5.
|
|
35
|
-
"@webiny/validation": "5.
|
|
23
|
+
"@webiny/api": "5.38.0-beta.1",
|
|
24
|
+
"@webiny/api-headless-cms": "5.38.0-beta.1",
|
|
25
|
+
"@webiny/api-security": "5.38.0-beta.1",
|
|
26
|
+
"@webiny/api-tenancy": "5.38.0-beta.1",
|
|
27
|
+
"@webiny/error": "5.38.0-beta.1",
|
|
28
|
+
"@webiny/handler": "5.38.0-beta.1",
|
|
29
|
+
"@webiny/handler-aws": "5.38.0-beta.1",
|
|
30
|
+
"@webiny/handler-client": "5.38.0-beta.1",
|
|
31
|
+
"@webiny/handler-graphql": "5.38.0-beta.1",
|
|
32
|
+
"@webiny/plugins": "5.38.0-beta.1",
|
|
33
|
+
"@webiny/project-utils": "5.38.0-beta.1",
|
|
34
|
+
"@webiny/pubsub": "5.38.0-beta.1",
|
|
35
|
+
"@webiny/validation": "5.38.0-beta.1",
|
|
36
36
|
"aws-sdk": "2.1310.0",
|
|
37
37
|
"lodash": "4.17.21",
|
|
38
38
|
"object-hash": "2.2.0"
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"@babel/plugin-transform-runtime": "7.22.7",
|
|
45
45
|
"@babel/preset-env": "7.22.7",
|
|
46
46
|
"@babel/preset-typescript": "7.22.5",
|
|
47
|
-
"@webiny/api-i18n": "5.
|
|
48
|
-
"@webiny/cli": "5.
|
|
49
|
-
"@webiny/utils": "5.
|
|
47
|
+
"@webiny/api-i18n": "5.38.0-beta.1",
|
|
48
|
+
"@webiny/cli": "5.38.0-beta.1",
|
|
49
|
+
"@webiny/utils": "5.38.0-beta.1",
|
|
50
50
|
"jest": "29.5.0",
|
|
51
51
|
"rimraf": "3.0.2",
|
|
52
52
|
"ttypescript": "1.5.15",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
]
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "6daf38d3ed0c029a8fea005c2b6246e5b325a09c"
|
|
75
75
|
}
|
|
@@ -28,4 +28,6 @@ class FilePhysicalStoragePlugin extends _plugins.Plugin {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
exports.FilePhysicalStoragePlugin = FilePhysicalStoragePlugin;
|
|
31
|
-
(0, _defineProperty2.default)(FilePhysicalStoragePlugin, "type", "api-file-manager-storage");
|
|
31
|
+
(0, _defineProperty2.default)(FilePhysicalStoragePlugin, "type", "api-file-manager-storage");
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=FilePhysicalStoragePlugin.js.map
|
|
@@ -37,4 +37,6 @@ class FileStorageTransformPlugin extends _plugins.Plugin {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
exports.FileStorageTransformPlugin = FileStorageTransformPlugin;
|
|
40
|
-
(0, _defineProperty2.default)(FileStorageTransformPlugin, "type", "fm.files.storage.transform");
|
|
40
|
+
(0, _defineProperty2.default)(FileStorageTransformPlugin, "type", "fm.files.storage.transform");
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=FileStorageTransformPlugin.js.map
|
package/plugins/index.js
CHANGED
package/storage/FileStorage.js
CHANGED
package/types/file.js
CHANGED
package/types/file.lifecycle.js
CHANGED
package/types.d.ts
CHANGED
|
@@ -96,11 +96,23 @@ export interface FileManagerSystem {
|
|
|
96
96
|
version: string;
|
|
97
97
|
tenant: string;
|
|
98
98
|
}
|
|
99
|
+
export interface OnSettingsBeforeUpdateTopicParams {
|
|
100
|
+
input: Partial<FileManagerSettings>;
|
|
101
|
+
original: FileManagerSettings;
|
|
102
|
+
settings: FileManagerSettings;
|
|
103
|
+
}
|
|
104
|
+
export interface OnSettingsAfterUpdateTopicParams {
|
|
105
|
+
input: Partial<FileManagerSettings>;
|
|
106
|
+
original: FileManagerSettings;
|
|
107
|
+
settings: FileManagerSettings;
|
|
108
|
+
}
|
|
99
109
|
export declare type SettingsCRUD = {
|
|
100
110
|
getSettings(): Promise<FileManagerSettings | null>;
|
|
101
111
|
createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
|
|
102
112
|
updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
|
|
103
113
|
deleteSettings(): Promise<boolean>;
|
|
114
|
+
onSettingsBeforeUpdate: Topic<OnSettingsBeforeUpdateTopicParams>;
|
|
115
|
+
onSettingsAfterUpdate: Topic<OnSettingsAfterUpdateTopicParams>;
|
|
104
116
|
};
|
|
105
117
|
/********
|
|
106
118
|
* Storage operations
|
package/types.js
CHANGED
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 { File } from \"./types/file\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nexport * from \"./types/file.lifecycle\";\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 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 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 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/********\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":";;;;;AASA,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;AAAAC,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"}
|
|
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 { File } from \"./types/file\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nexport * from \"./types/file.lifecycle\";\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 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 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":";;;;;AASA,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;AAAAC,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"}
|