@webiny/api-file-manager 5.38.0 → 5.39.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.
- package/cmsFileStorage/CmsFilesStorage.js +2 -1
- package/cmsFileStorage/CmsFilesStorage.js.map +1 -1
- package/createFileManager/files.crud.js +11 -7
- package/createFileManager/files.crud.js.map +1 -1
- package/graphql/baseSchema.js +1 -0
- package/graphql/baseSchema.js.map +1 -1
- package/graphql/createFilesTypeDefs.js +16 -1
- package/graphql/createFilesTypeDefs.js.map +1 -1
- package/graphql/filesSchema.js +9 -3
- package/graphql/filesSchema.js.map +1 -1
- package/graphql/utils.d.ts +1 -1
- package/modelModifier/CmsModelModifier.d.ts +3 -1
- package/modelModifier/CmsModelModifier.js +9 -1
- package/modelModifier/CmsModelModifier.js.map +1 -1
- package/package.json +18 -18
- package/types/file.d.ts +1 -0
- package/types/file.js.map +1 -1
- package/types.d.ts +5 -1
- package/types.js.map +1 -1
|
@@ -150,7 +150,7 @@ class CmsFilesStorage {
|
|
|
150
150
|
latest: true
|
|
151
151
|
}
|
|
152
152
|
});
|
|
153
|
-
const values = (0, _omit.default)(file, ["id", "
|
|
153
|
+
const values = (0, _omit.default)(file, ["id", "tenant", "locale", "webinyVersion"]);
|
|
154
154
|
const updatedEntry = await this.cms.updateEntry(model, entry.id, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, values), {}, {
|
|
155
155
|
wbyAco_location: values.location ?? entry.location
|
|
156
156
|
}));
|
|
@@ -162,6 +162,7 @@ class CmsFilesStorage {
|
|
|
162
162
|
return (0, _objectSpread2.default)({
|
|
163
163
|
id: entry.entryId,
|
|
164
164
|
createdBy: entry.createdBy,
|
|
165
|
+
modifiedBy: entry.modifiedBy || null,
|
|
165
166
|
createdOn: entry.createdOn,
|
|
166
167
|
savedOn: entry.savedOn,
|
|
167
168
|
locale: entry.locale,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_omit","_interopRequireDefault","require","_ListFilesWhereProcessor","_ListTagsWhereProcessor","_contants","CmsFilesStorage","create","params","fileModel","cms","security","aliases","constructor","_defineProperty2","default","model","filesWhereProcessor","ListFilesWhereProcessor","tagsWhereProcessor","ListTagsWhereProcessor","modelWithContext","tenant","locale","_objectSpread2","file","_file$location","location","folderId","ROOT_FOLDER","entry","withoutAuthorization","createEntry","wbyAco_location","storeAliases","getFileFieldValues","createBatch","files","Promise","all","map","delete","deleteEntry","id","deleteAliases","get","where","getEntry","entryId","latest","list","entries","meta","process","listLatestEntries","after","limit","sort","search","tags","uniqueValues","getUniqueFieldValues","fieldId","uv","tag","value","count","a","b","update","values","omit","updatedEntry","updateEntry","createdBy","createdOn","savedOn","webinyVersion","exports"],"sources":["CmsFilesStorage.ts"],"sourcesContent":["import omit from \"lodash/omit\";\nimport { CmsEntry, CmsModel, HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { Security } from \"@webiny/api-security/types\";\nimport {\n File,\n FileManagerAliasesStorageOperations,\n FileManagerFilesStorageOperations,\n FileManagerFilesStorageOperationsCreateBatchParams,\n FileManagerFilesStorageOperationsCreateParams,\n FileManagerFilesStorageOperationsDeleteParams,\n FileManagerFilesStorageOperationsGetParams,\n FileManagerFilesStorageOperationsListParams,\n FileManagerFilesStorageOperationsListResponse,\n FileManagerFilesStorageOperationsTagsParams,\n FileManagerFilesStorageOperationsTagsResponse,\n FileManagerFilesStorageOperationsUpdateParams\n} from \"~/types\";\nimport { ListFilesWhereProcessor } from \"~/cmsFileStorage/ListFilesWhereProcessor\";\nimport { ListTagsWhereProcessor } from \"~/cmsFileStorage/ListTagsWhereProcessor\";\nimport { ROOT_FOLDER } from \"~/contants\";\n\ninterface ModelContext {\n tenant: string;\n locale: string;\n}\n\nexport class CmsFilesStorage implements FileManagerFilesStorageOperations {\n private readonly cms: HeadlessCms;\n private readonly security: Security;\n private readonly model: CmsModel;\n private readonly aliases: FileManagerAliasesStorageOperations;\n private readonly filesWhereProcessor: ListFilesWhereProcessor;\n private readonly tagsWhereProcessor: ListTagsWhereProcessor;\n\n static async create(params: {\n fileModel: CmsModel;\n cms: HeadlessCms;\n security: Security;\n aliases: FileManagerAliasesStorageOperations;\n }) {\n return new CmsFilesStorage(params.fileModel, params.cms, params.security, params.aliases);\n }\n\n private constructor(\n fileModel: CmsModel,\n cms: HeadlessCms,\n security: Security,\n aliases: FileManagerAliasesStorageOperations\n ) {\n this.model = fileModel;\n this.aliases = aliases;\n this.cms = cms;\n this.security = security;\n this.filesWhereProcessor = new ListFilesWhereProcessor();\n this.tagsWhereProcessor = new ListTagsWhereProcessor();\n }\n\n private modelWithContext({ tenant, locale }: ModelContext): CmsModel {\n return { ...this.model, tenant, locale };\n }\n\n async create({ file }: FileManagerFilesStorageOperationsCreateParams): Promise<File> {\n const model = this.modelWithContext(file);\n\n if (!file.location?.folderId) {\n file.location = {\n ...file.location,\n folderId: ROOT_FOLDER\n };\n }\n\n const entry = await this.security.withoutAuthorization(() => {\n return this.cms.createEntry(model, { ...file, wbyAco_location: file.location });\n });\n\n await this.aliases.storeAliases(file);\n\n return this.getFileFieldValues(entry);\n }\n\n async createBatch({\n files\n }: FileManagerFilesStorageOperationsCreateBatchParams): Promise<File[]> {\n return await Promise.all(\n files.map(file => {\n return this.create({ file });\n })\n );\n }\n\n async delete({ file }: FileManagerFilesStorageOperationsDeleteParams): Promise<void> {\n const model = this.modelWithContext(file);\n await this.security.withoutAuthorization(() => {\n return this.cms.deleteEntry(model, file.id);\n });\n\n await this.aliases.deleteAliases(file);\n }\n\n async get({ where }: FileManagerFilesStorageOperationsGetParams): Promise<File | null> {\n const { id, tenant, locale } = where;\n const model = this.modelWithContext({ tenant, locale });\n const entry = await this.security.withoutAuthorization(() => {\n return this.cms.getEntry(model, { where: { entryId: id, latest: true } });\n });\n return entry ? this.getFileFieldValues(entry) : null;\n }\n\n async list(\n params: FileManagerFilesStorageOperationsListParams\n ): Promise<FileManagerFilesStorageOperationsListResponse> {\n const tenant = params.where.tenant;\n const locale = params.where.locale;\n\n const model = this.modelWithContext({ tenant, locale });\n const [entries, meta] = await this.security.withoutAuthorization(() => {\n const where = this.filesWhereProcessor.process(params.where);\n return this.cms.listLatestEntries(model, {\n after: params.after,\n limit: params.limit,\n sort: params.sort,\n where,\n search: params.search\n });\n });\n\n return [entries.map(entry => this.getFileFieldValues(entry)), meta];\n }\n\n async tags(\n params: FileManagerFilesStorageOperationsTagsParams\n ): Promise<FileManagerFilesStorageOperationsTagsResponse[]> {\n const tenant = params.where.tenant;\n const locale = params.where.locale;\n const model = this.modelWithContext({ tenant, locale });\n const uniqueValues = await this.security.withoutAuthorization(() => {\n return this.cms.getUniqueFieldValues(model, {\n fieldId: \"tags\",\n where: {\n ...this.tagsWhereProcessor.process(params.where),\n latest: true\n }\n });\n });\n\n return uniqueValues\n .map(uv => ({\n tag: uv.value,\n count: uv.count\n }))\n .sort((a, b) => {\n return a.tag < b.tag ? -1 : 1;\n })\n .sort((a, b) => {\n return a.count > b.count ? -1 : 1;\n });\n }\n\n async update({ file }: FileManagerFilesStorageOperationsUpdateParams): Promise<File> {\n const model = this.modelWithContext(file);\n\n return await this.security.withoutAuthorization(async () => {\n const entry = await this.cms.getEntry(model, {\n where: { entryId: file.id, latest: true }\n });\n\n const values = omit(file, [\n \"id\",\n \"createdOn\",\n \"createdBy\",\n \"tenant\",\n \"locale\",\n \"webinyVersion\"\n ]);\n\n const updatedEntry = await this.cms.updateEntry(model, entry.id, {\n ...values,\n wbyAco_location: values.location ?? entry.location\n });\n\n await this.aliases.storeAliases(file);\n\n return this.getFileFieldValues(updatedEntry);\n });\n }\n\n private getFileFieldValues(entry: CmsEntry) {\n return {\n id: entry.entryId,\n createdBy: entry.createdBy,\n createdOn: entry.createdOn,\n savedOn: entry.savedOn,\n locale: entry.locale,\n tenant: entry.tenant,\n webinyVersion: entry.webinyVersion,\n ...entry.values\n } as File;\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAA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AC+C;IAAa,GAC/B/C,KAAK,CAACwC,MAAM;EAEvB;AACJ;AAACQ,OAAA,CAAAxE,eAAA,GAAAA,eAAA"}
|
|
1
|
+
{"version":3,"names":["_omit","_interopRequireDefault","require","_ListFilesWhereProcessor","_ListTagsWhereProcessor","_contants","CmsFilesStorage","create","params","fileModel","cms","security","aliases","constructor","_defineProperty2","default","model","filesWhereProcessor","ListFilesWhereProcessor","tagsWhereProcessor","ListTagsWhereProcessor","modelWithContext","tenant","locale","_objectSpread2","file","_file$location","location","folderId","ROOT_FOLDER","entry","withoutAuthorization","createEntry","wbyAco_location","storeAliases","getFileFieldValues","createBatch","files","Promise","all","map","delete","deleteEntry","id","deleteAliases","get","where","getEntry","entryId","latest","list","entries","meta","process","listLatestEntries","after","limit","sort","search","tags","uniqueValues","getUniqueFieldValues","fieldId","uv","tag","value","count","a","b","update","values","omit","updatedEntry","updateEntry","createdBy","modifiedBy","createdOn","savedOn","webinyVersion","exports"],"sources":["CmsFilesStorage.ts"],"sourcesContent":["import omit from \"lodash/omit\";\nimport { CmsEntry, CmsModel, HeadlessCms } from \"@webiny/api-headless-cms/types\";\nimport { Security } from \"@webiny/api-security/types\";\nimport {\n File,\n FileManagerAliasesStorageOperations,\n FileManagerFilesStorageOperations,\n FileManagerFilesStorageOperationsCreateBatchParams,\n FileManagerFilesStorageOperationsCreateParams,\n FileManagerFilesStorageOperationsDeleteParams,\n FileManagerFilesStorageOperationsGetParams,\n FileManagerFilesStorageOperationsListParams,\n FileManagerFilesStorageOperationsListResponse,\n FileManagerFilesStorageOperationsTagsParams,\n FileManagerFilesStorageOperationsTagsResponse,\n FileManagerFilesStorageOperationsUpdateParams\n} from \"~/types\";\nimport { ListFilesWhereProcessor } from \"~/cmsFileStorage/ListFilesWhereProcessor\";\nimport { ListTagsWhereProcessor } from \"~/cmsFileStorage/ListTagsWhereProcessor\";\nimport { ROOT_FOLDER } from \"~/contants\";\n\ninterface ModelContext {\n tenant: string;\n locale: string;\n}\n\nexport class CmsFilesStorage implements FileManagerFilesStorageOperations {\n private readonly cms: HeadlessCms;\n private readonly security: Security;\n private readonly model: CmsModel;\n private readonly aliases: FileManagerAliasesStorageOperations;\n private readonly filesWhereProcessor: ListFilesWhereProcessor;\n private readonly tagsWhereProcessor: ListTagsWhereProcessor;\n\n static async create(params: {\n fileModel: CmsModel;\n cms: HeadlessCms;\n security: Security;\n aliases: FileManagerAliasesStorageOperations;\n }) {\n return new CmsFilesStorage(params.fileModel, params.cms, params.security, params.aliases);\n }\n\n private constructor(\n fileModel: CmsModel,\n cms: HeadlessCms,\n security: Security,\n aliases: FileManagerAliasesStorageOperations\n ) {\n this.model = fileModel;\n this.aliases = aliases;\n this.cms = cms;\n this.security = security;\n this.filesWhereProcessor = new ListFilesWhereProcessor();\n this.tagsWhereProcessor = new ListTagsWhereProcessor();\n }\n\n private modelWithContext({ tenant, locale }: ModelContext): CmsModel {\n return { ...this.model, tenant, locale };\n }\n\n async create({ file }: FileManagerFilesStorageOperationsCreateParams): Promise<File> {\n const model = this.modelWithContext(file);\n\n if (!file.location?.folderId) {\n file.location = {\n ...file.location,\n folderId: ROOT_FOLDER\n };\n }\n\n const entry = await this.security.withoutAuthorization(() => {\n return this.cms.createEntry(model, { ...file, wbyAco_location: file.location });\n });\n\n await this.aliases.storeAliases(file);\n\n return this.getFileFieldValues(entry);\n }\n\n async createBatch({\n files\n }: FileManagerFilesStorageOperationsCreateBatchParams): Promise<File[]> {\n return await Promise.all(\n files.map(file => {\n return this.create({ file });\n })\n );\n }\n\n async delete({ file }: FileManagerFilesStorageOperationsDeleteParams): Promise<void> {\n const model = this.modelWithContext(file);\n await this.security.withoutAuthorization(() => {\n return this.cms.deleteEntry(model, file.id);\n });\n\n await this.aliases.deleteAliases(file);\n }\n\n async get({ where }: FileManagerFilesStorageOperationsGetParams): Promise<File | null> {\n const { id, tenant, locale } = where;\n const model = this.modelWithContext({ tenant, locale });\n const entry = await this.security.withoutAuthorization(() => {\n return this.cms.getEntry(model, { where: { entryId: id, latest: true } });\n });\n return entry ? this.getFileFieldValues(entry) : null;\n }\n\n async list(\n params: FileManagerFilesStorageOperationsListParams\n ): Promise<FileManagerFilesStorageOperationsListResponse> {\n const tenant = params.where.tenant;\n const locale = params.where.locale;\n\n const model = this.modelWithContext({ tenant, locale });\n const [entries, meta] = await this.security.withoutAuthorization(() => {\n const where = this.filesWhereProcessor.process(params.where);\n return this.cms.listLatestEntries(model, {\n after: params.after,\n limit: params.limit,\n sort: params.sort,\n where,\n search: params.search\n });\n });\n\n return [entries.map(entry => this.getFileFieldValues(entry)), meta];\n }\n\n async tags(\n params: FileManagerFilesStorageOperationsTagsParams\n ): Promise<FileManagerFilesStorageOperationsTagsResponse[]> {\n const tenant = params.where.tenant;\n const locale = params.where.locale;\n const model = this.modelWithContext({ tenant, locale });\n const uniqueValues = await this.security.withoutAuthorization(() => {\n return this.cms.getUniqueFieldValues(model, {\n fieldId: \"tags\",\n where: {\n ...this.tagsWhereProcessor.process(params.where),\n latest: true\n }\n });\n });\n\n return uniqueValues\n .map(uv => ({\n tag: uv.value,\n count: uv.count\n }))\n .sort((a, b) => {\n return a.tag < b.tag ? -1 : 1;\n })\n .sort((a, b) => {\n return a.count > b.count ? -1 : 1;\n });\n }\n\n async update({ file }: FileManagerFilesStorageOperationsUpdateParams): Promise<File> {\n const model = this.modelWithContext(file);\n\n return await this.security.withoutAuthorization(async () => {\n const entry = await this.cms.getEntry(model, {\n where: { entryId: file.id, latest: true }\n });\n\n const values = omit(file, [\"id\", \"tenant\", \"locale\", \"webinyVersion\"]);\n\n const updatedEntry = await this.cms.updateEntry(model, entry.id, {\n ...values,\n wbyAco_location: values.location ?? entry.location\n });\n\n await this.aliases.storeAliases(file);\n\n return this.getFileFieldValues(updatedEntry);\n });\n }\n\n private getFileFieldValues(entry: CmsEntry) {\n return {\n id: entry.entryId,\n createdBy: entry.createdBy,\n modifiedBy: entry.modifiedBy || null,\n createdOn: entry.createdOn,\n savedOn: entry.savedOn,\n locale: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AAS;MAC1BC,OAAO,EAAE/C,KAAK,CAAC+C,OAAO;MACtBtD,MAAM,EAAEO,KAAK,CAACP,MAAM;MACpBD,MAAM,EAAEQ,KAAK,CAACR,MAAM;MACpBwD,aAAa,EAAEhD,KAAK,CAACgD;IAAa,GAC/BhD,KAAK,CAACwC,MAAM;EAEvB;AACJ;AAACS,OAAA,CAAAzE,eAAA,GAAAA,eAAA"}
|
|
@@ -11,6 +11,7 @@ var _pubsub = require("@webiny/pubsub");
|
|
|
11
11
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
12
12
|
var _contants = require("../contants");
|
|
13
13
|
var _apiSecurity = require("@webiny/api-security");
|
|
14
|
+
var _date = require("@webiny/api-headless-cms/utils/date");
|
|
14
15
|
const createFilesCrud = config => {
|
|
15
16
|
const {
|
|
16
17
|
storageOperations,
|
|
@@ -57,6 +58,7 @@ const createFilesCrud = config => {
|
|
|
57
58
|
|
|
58
59
|
// Extract ID from file key
|
|
59
60
|
const [id] = input.key.split("/");
|
|
61
|
+
const date = new Date();
|
|
60
62
|
const file = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
|
|
61
63
|
tags: Array.isArray(input.tags) ? input.tags : [],
|
|
62
64
|
aliases: Array.isArray(input.aliases) ? input.aliases : [],
|
|
@@ -68,13 +70,11 @@ const createFilesCrud = config => {
|
|
|
68
70
|
private: false
|
|
69
71
|
}, input.meta || {}),
|
|
70
72
|
tenant: getTenantId(),
|
|
71
|
-
createdOn:
|
|
72
|
-
savedOn:
|
|
73
|
-
createdBy:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
type: identity.type
|
|
77
|
-
},
|
|
73
|
+
createdOn: (0, _date.getDate)(input.createdOn, date),
|
|
74
|
+
savedOn: (0, _date.getDate)(input.savedOn, date),
|
|
75
|
+
createdBy: input.createdBy || identity,
|
|
76
|
+
ownedBy: input.createdBy || identity,
|
|
77
|
+
modifiedBy: input.modifiedBy,
|
|
78
78
|
locale: getLocaleCode(),
|
|
79
79
|
webinyVersion: WEBINY_VERSION
|
|
80
80
|
});
|
|
@@ -119,6 +119,10 @@ const createFilesCrud = config => {
|
|
|
119
119
|
owns: original.createdBy
|
|
120
120
|
});
|
|
121
121
|
const file = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), input), {}, {
|
|
122
|
+
createdBy: input.createdBy || original.createdBy,
|
|
123
|
+
modifiedBy: input.modifiedBy,
|
|
124
|
+
createdOn: (0, _date.getDate)(input.createdOn, original.createdOn),
|
|
125
|
+
savedOn: (0, _date.getDate)(input.savedOn, new Date()),
|
|
122
126
|
tags: Array.isArray(input.tags) ? input.tags : Array.isArray(original.tags) ? original.tags : [],
|
|
123
127
|
aliases: Array.isArray(input.aliases) ? input.aliases : Array.isArray(original.aliases) ? original.aliases : [],
|
|
124
128
|
id: original.id,
|
|
@@ -1 +1 @@
|
|
|
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,IAAAF,mBAAW,EAAC,qCAAqC,CAAC;IAC3EG,sBAAsB,EAAE,IAAAH,mBAAW,EAAC,oCAAoC,CAAC;IACzEI,kBAAkB,EAAE,IAAAJ,mBAAW,EAAC,gCAAgC,CAAC;IACjE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AAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MAE1BmB,EAAE,CAACK,IAAI,IAAI,CAAC,CAAC;UACjBtC,KAAK;UACLqD,KAAK;UACLD,KAAK;UACLG;QAAI,EAEZ,CAAC;MACL;IACJ,CAAC;IACD,MAAMO,QAAQA,CAAC;MAAE9D,KAAK,EAAEsD,YAAY;MAAED,KAAK;MAAED;IAAM,CAAC,EAAE;MAClD,MAAMzE,gBAAgB,CAACgB,MAAM,CAAC,CAAC;MAE/B,MAAMK,KAAuD,OAAAa,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MACtDwC,YAAY;QACfrD,MAAM,EAAEpB,WAAW,CAAC,CAAC;QACrBqB,MAAM,EAAEtB,aAAa,CAAC;MAAC,EAC1B;MAED,MAAMuE,MAAM,GAAG;QACXnD,KAAK;QACLoD,KAAK,EAAEA,KAAK,IAAI,OAAO;QACvBC;MACJ,CAAC;MAED,IAAI;QACA,OAAO,MAAM3E,iBAAiB,CAACoB,KAAK,CAACiB,IAAI,CAACoC,MAAM,CAAC;MACrD,CAAC,CAAC,OAAOlB,EAAE,EAAE;QACT,MAAM,IAAIE,cAAW,CACjBF,EAAE,CAACG,OAAO,IAAI,4BAA4B,EAC1CH,EAAE,CAACI,IAAI,IAAI,uBAAuB,MAAAxB,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MAE1BmB,EAAE,CAACK,IAAI,IAAI,CAAC,CAAC;UACjBa;QAAM,EAEd,CAAC;MACL;IACJ;EACJ,CAAC;AACL,CAAC;AAACY,OAAA,CAAAvF,eAAA,GAAAA,eAAA"}
|
|
1
|
+
{"version":3,"names":["_handlerGraphql","require","_pubsub","_error","_interopRequireDefault","_contants","_apiSecurity","_date","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","date","Date","_objectSpread2","default","tags","Array","isArray","aliases","location","folderId","ROOT_FOLDER","private","createdOn","getDate","savedOn","ownedBy","modifiedBy","webinyVersion","publish","result","create","ex","NotAuthorizedError","WebinyError","message","code","data","updateFile","original","update","deleteFile","delete","createFilesInBatch","inputs","displayName","type","map","_input$location2","toISOString","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\";\nimport { getDate } from \"@webiny/api-headless-cms/utils/date\";\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 date = new Date();\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: getDate(input.createdOn, date),\n savedOn: getDate(input.savedOn, date),\n createdBy: input.createdBy || identity,\n ownedBy: input.createdBy || identity,\n modifiedBy: input.modifiedBy,\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 createdBy: input.createdBy || original.createdBy,\n modifiedBy: input.modifiedBy,\n createdOn: getDate(input.createdOn, original.createdOn),\n savedOn: getDate(input.savedOn, new Date()),\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 }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C;MACL;IACJ,CAAC;IACD,MAAMO,QAAQA,CAAC;MAAElE,KAAK,EAAE0D,YAAY;MAAED,KAAK;MAAED;IAAM,CAAC,EAAE;MAClD,MAAM7E,gBAAgB,CAACgB,MAAM,CAAC,CAAC;MAE/B,MAAMK,KAAuD,OAAAe,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MACtD0C,YAAY;QACfzD,MAAM,EAAEpB,WAAW,CAAC,CAAC;QACrBqB,MAAM,EAAEtB,aAAa,CAAC;MAAC,EAC1B;MAED,MAAM2E,MAAM,GAAG;QACXvD,KAAK;QACLwD,KAAK,EAAEA,KAAK,IAAI,OAAO;QACvBC;MACJ,CAAC;MAED,IAAI;QACA,OAAO,MAAM/E,iBAAiB,CAACoB,KAAK,CAACmB,IAAI,CAACsC,MAAM,CAAC;MACrD,CAAC,CAAC,OAAOrB,EAAE,EAAE;QACT,MAAM,IAAIE,cAAW,CACjBF,EAAE,CAACG,OAAO,IAAI,4BAA4B,EAC1CH,EAAE,CAACI,IAAI,IAAI,uBAAuB,MAAAvB,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MAE1BkB,EAAE,CAACK,IAAI,IAAI,CAAC,CAAC;UACjBgB;QAAM,EAEd,CAAC;MACL;IACJ;EACJ,CAAC;AACL,CAAC;AAACY,OAAA,CAAA3F,eAAA,GAAAA,eAAA"}
|
package/graphql/baseSchema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerGraphql","require","_utils","createBaseSchema","fileManagerGraphQL","GraphQLSchemaPlugin","typeDefs","resolvers","Query","fileManager","emptyResolver","Mutation","FmQuery","version","_","__","context","i18n","tenancy","getCurrentTenant","getContentLocale","getVersion","getSettings","resolve","FmMutation","install","args","srcPrefix","updateSettings","data","name","exports"],"sources":["baseSchema.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { FileManagerContext } from \"~/types\";\nimport { emptyResolver, resolve } from \"./utils\";\n\nexport const createBaseSchema = () => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<FileManagerContext>({\n typeDefs: /* GraphQL */ `\n type FmError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type FmCreatedBy {\n id: ID\n displayName: String\n }\n\n type FmListMeta {\n cursor: String\n totalCount: Int\n hasMoreItems: Boolean\n }\n\n type FmBooleanResponse {\n data: Boolean\n error: FmError\n }\n\n type FmSettings {\n uploadMinFileSize: Number\n uploadMaxFileSize: Number\n srcPrefix: String\n }\n\n input FmSettingsInput {\n uploadMinFileSize: Number\n uploadMaxFileSize: Number\n srcPrefix: String\n }\n\n type FmSettingsResponse {\n data: FmSettings\n error: FmError\n }\n\n type FmQuery {\n version: String\n getSettings: FmSettingsResponse\n }\n\n type FmDeleteResponse {\n data: Boolean\n error: FmError\n }\n\n type FmMutation {\n install(srcPrefix: String): FmBooleanResponse\n updateSettings(data: FmSettingsInput): FmSettingsResponse\n }\n\n input FmInstallInput {\n srcPrefix: String!\n }\n\n extend type Query {\n fileManager: FmQuery\n }\n\n extend type Mutation {\n fileManager: FmMutation\n }\n `,\n resolvers: {\n Query: {\n fileManager: emptyResolver\n },\n Mutation: {\n fileManager: emptyResolver\n },\n FmQuery: {\n async version(_, __, context) {\n const { i18n, tenancy, fileManager } = context;\n if (!tenancy.getCurrentTenant() || !i18n.getContentLocale()) {\n return null;\n }\n\n return await fileManager.getVersion();\n },\n async getSettings(_, __, context) {\n return resolve(() => context.fileManager.getSettings());\n }\n },\n FmMutation: {\n async install(_, args: any, context) {\n return resolve(() =>\n context.fileManager.install({ srcPrefix: args.srcPrefix })\n );\n },\n async updateSettings(_, args: any, context) {\n return resolve(() => context.fileManager.updateSettings(args.data));\n }\n }\n }\n });\n fileManagerGraphQL.name = \"fm.graphql.base\";\n\n return fileManagerGraphQL;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AA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EE,SAAS,EAAED,IAAI,CAACC;UAAU,CAAC,CAC7D,CAAC;QACL,CAAC;QACD,MAAMC,cAAcA,CAACd,CAAC,EAAEY,IAAS,EAAEV,OAAO,EAAE;UACxC,OAAO,IAAAO,cAAO,EAAC,MAAMP,OAAO,CAACP,WAAW,CAACmB,cAAc,CAACF,IAAI,CAACG,IAAI,CAAC,CAAC;QACvE;MACJ;IACJ;EACJ,CAAC,CAAC;EACFzB,kBAAkB,CAAC0B,IAAI,GAAG,iBAAiB;EAE3C,OAAO1B,kBAAkB;AAC7B,CAAC;AAAC2B,OAAA,CAAA5B,gBAAA,GAAAA,gBAAA"}
|
|
1
|
+
{"version":3,"names":["_handlerGraphql","require","_utils","createBaseSchema","fileManagerGraphQL","GraphQLSchemaPlugin","typeDefs","resolvers","Query","fileManager","emptyResolver","Mutation","FmQuery","version","_","__","context","i18n","tenancy","getCurrentTenant","getContentLocale","getVersion","getSettings","resolve","FmMutation","install","args","srcPrefix","updateSettings","data","name","exports"],"sources":["baseSchema.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { FileManagerContext } from \"~/types\";\nimport { emptyResolver, resolve } from \"./utils\";\n\nexport const createBaseSchema = () => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<FileManagerContext>({\n typeDefs: /* GraphQL */ `\n type FmError {\n code: String\n message: String\n data: JSON\n stack: String\n }\n\n type FmCreatedBy {\n id: ID\n displayName: String\n type: String\n }\n\n type FmListMeta {\n cursor: String\n totalCount: Int\n hasMoreItems: Boolean\n }\n\n type FmBooleanResponse {\n data: Boolean\n error: FmError\n }\n\n type FmSettings {\n uploadMinFileSize: Number\n uploadMaxFileSize: Number\n srcPrefix: String\n }\n\n input FmSettingsInput {\n uploadMinFileSize: Number\n uploadMaxFileSize: Number\n srcPrefix: String\n }\n\n type FmSettingsResponse {\n data: FmSettings\n error: FmError\n }\n\n type FmQuery {\n version: String\n getSettings: FmSettingsResponse\n }\n\n type FmDeleteResponse {\n data: Boolean\n error: FmError\n }\n\n type FmMutation {\n install(srcPrefix: String): FmBooleanResponse\n updateSettings(data: FmSettingsInput): FmSettingsResponse\n }\n\n input FmInstallInput {\n srcPrefix: String!\n }\n\n extend type Query {\n fileManager: FmQuery\n }\n\n extend type Mutation {\n fileManager: FmMutation\n }\n `,\n resolvers: {\n Query: {\n fileManager: emptyResolver\n },\n Mutation: {\n fileManager: emptyResolver\n },\n FmQuery: {\n async version(_, __, context) {\n const { i18n, tenancy, fileManager } = context;\n if (!tenancy.getCurrentTenant() || !i18n.getContentLocale()) {\n return null;\n }\n\n return await fileManager.getVersion();\n },\n async getSettings(_, __, context) {\n return resolve(() => context.fileManager.getSettings());\n }\n },\n FmMutation: {\n async install(_, args: any, context) {\n return resolve(() =>\n context.fileManager.install({ srcPrefix: args.srcPrefix })\n );\n },\n async updateSettings(_, args: any, context) {\n return resolve(() => context.fileManager.updateSettings(args.data));\n }\n }\n }\n });\n fileManagerGraphQL.name = \"fm.graphql.base\";\n\n return fileManagerGraphQL;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,gBAAgB,GAAGA,CAAA,KAAM;EAClC,MAAMC,kBAAkB,GAAG,IAAIC,mCAAmB,CAAqB;IACnEC,QAAQ,EAAE,aAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDC,SAAS,EAAE;MACPC,KAAK,EAAE;QACHC,WAAW,EAA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
|
77
77
|
createdBy: FmCreatedBy!
|
|
78
|
+
modifiedBy: FmCreatedBy
|
|
78
79
|
src: String
|
|
79
80
|
${fieldTypes.map(f => f.fields).join("\n")}
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
${inputCreateFields.map(f => f.typeDefs).join("\n")}
|
|
84
|
+
|
|
85
|
+
input FmCreatedByInput {
|
|
86
|
+
id: ID!
|
|
87
|
+
displayName: String!
|
|
88
|
+
type: String!
|
|
89
|
+
}
|
|
83
90
|
|
|
84
91
|
input FmFileCreateInput {
|
|
85
92
|
id: ID!
|
|
93
|
+
createdOn: DateTime
|
|
94
|
+
savedOn: DateTime
|
|
95
|
+
createdBy: FmCreatedByInput
|
|
96
|
+
modifiedBy: FmCreatedByInput
|
|
86
97
|
${inputCreateFields.map(f => f.fields).join("\n")}
|
|
87
98
|
}
|
|
88
99
|
|
|
89
100
|
input FmFileUpdateInput {
|
|
101
|
+
createdOn: DateTime
|
|
102
|
+
savedOn: DateTime
|
|
103
|
+
createdBy: FmCreatedByInput
|
|
104
|
+
modifiedBy: FmCreatedByInput
|
|
90
105
|
${inputUpdateFields.map(f => f.fields).join("\n")}
|
|
91
106
|
}
|
|
92
107
|
|
|
@@ -131,7 +146,7 @@ const createFilesTypeDefs = params => {
|
|
|
131
146
|
data: [FmFile!]
|
|
132
147
|
error: FmError
|
|
133
148
|
}
|
|
134
|
-
|
|
149
|
+
|
|
135
150
|
type FmFileModelResponse {
|
|
136
151
|
data: JSON
|
|
137
152
|
error: FmError
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_renderFields","require","_renderInputFields","_renderListFilterFields","_renderSortEnum","removeFieldRequiredValidation","field","validation","filter","name","listValidation","v","createUpdateFields","fields","reduce","collection","push","_objectSpread2","default","createFilesTypeDefs","params","model","models","plugins","fieldTypePlugins","fieldTypes","renderFields","type","inputCreateFields","renderInputFields","inputUpdateFields","listFilterFieldsRender","renderListFilterFields","excludeFields","excludeFromSorterts","sortEnumRender","renderSortEnum","includes","fieldId","sorterPlugins","map","f","typeDefs","join","exports"],"sources":["createFilesTypeDefs.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields\";\nimport { renderInputFields } from \"@webiny/api-headless-cms/utils/renderInputFields\";\nimport { renderListFilterFields } from \"@webiny/api-headless-cms/utils/renderListFilterFields\";\nimport { renderSortEnum } from \"@webiny/api-headless-cms/utils/renderSortEnum\";\n\nexport interface CreateFilesTypeDefsParams {\n model: CmsModel;\n models: CmsModel[];\n plugins: CmsFieldTypePlugins;\n}\n\nconst removeFieldRequiredValidation = (field: CmsModelField) => {\n if (field.validation) {\n field.validation = field.validation.filter(validation => validation.name !== \"required\");\n }\n if (field.listValidation) {\n field.listValidation = field.listValidation.filter(v => v.name !== \"required\");\n }\n return field;\n};\n\nconst createUpdateFields = (fields: CmsModelField[]): CmsModelField[] => {\n return fields.reduce<CmsModelField[]>((collection, field) => {\n collection.push(removeFieldRequiredValidation({ ...field }));\n return collection;\n }, []);\n};\n\nexport const createFilesTypeDefs = (params: CreateFilesTypeDefsParams): string => {\n const { model, models, plugins: fieldTypePlugins } = params;\n const { fields } = model;\n\n const fieldTypes = renderFields({\n models,\n model,\n fields,\n type: \"manage\",\n fieldTypePlugins\n });\n const inputCreateFields = renderInputFields({\n models,\n model,\n fields,\n fieldTypePlugins\n });\n const inputUpdateFields = renderInputFields({\n models,\n model,\n fields: createUpdateFields(fields),\n fieldTypePlugins\n });\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins,\n excludeFields: [\"entryId\", \"status\"]\n });\n\n const excludeFromSorterts = [\"tags\", \"aliases\"];\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields.filter(field => !excludeFromSorterts.includes(field.fieldId)),\n fieldTypePlugins,\n sorterPlugins: []\n });\n\n return /* GraphQL */ `\n ${fieldTypes.map(f => f.typeDefs).join(\"\\n\")}\n\n type FmFile {\n id: ID!\n savedOn: DateTime!\n createdOn: DateTime!\n createdBy: FmCreatedBy!\n src: String\n ${fieldTypes.map(f => f.fields).join(\"\\n\")}\n }\n\n ${inputCreateFields.map(f => f.typeDefs).join(\"\\n\")}\n\n input FmFileCreateInput {\n id: ID!\n ${inputCreateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n input FmFileUpdateInput {\n ${inputUpdateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n type FmFileResponse {\n data: FmFile\n error: FmError\n }\n\n input FmFileListWhereInput {\n ${listFilterFieldsRender}\n AND: [FmFileListWhereInput!]\n OR: [FmFileListWhereInput!]\n }\n\n type FmFileListResponse {\n data: [FmFile!]\n error: FmError\n meta: FmListMeta\n }\n\n enum FmFileListSorter {\n ${sortEnumRender}\n }\n\n input FmTagsListWhereInput {\n createdBy: String\n tags_startsWith: String\n tags_not_startsWith: String\n }\n\n type FmTag {\n tag: String!\n count: Number!\n }\n\n type FmTagsListResponse {\n data: [FmTag!]\n error: FmError\n }\n\n type FmCreateFilesResponse {\n data: [FmFile!]\n error: FmError\n }\n
|
|
1
|
+
{"version":3,"names":["_renderFields","require","_renderInputFields","_renderListFilterFields","_renderSortEnum","removeFieldRequiredValidation","field","validation","filter","name","listValidation","v","createUpdateFields","fields","reduce","collection","push","_objectSpread2","default","createFilesTypeDefs","params","model","models","plugins","fieldTypePlugins","fieldTypes","renderFields","type","inputCreateFields","renderInputFields","inputUpdateFields","listFilterFieldsRender","renderListFilterFields","excludeFields","excludeFromSorterts","sortEnumRender","renderSortEnum","includes","fieldId","sorterPlugins","map","f","typeDefs","join","exports"],"sources":["createFilesTypeDefs.ts"],"sourcesContent":["import { CmsFieldTypePlugins, CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields\";\nimport { renderInputFields } from \"@webiny/api-headless-cms/utils/renderInputFields\";\nimport { renderListFilterFields } from \"@webiny/api-headless-cms/utils/renderListFilterFields\";\nimport { renderSortEnum } from \"@webiny/api-headless-cms/utils/renderSortEnum\";\n\nexport interface CreateFilesTypeDefsParams {\n model: CmsModel;\n models: CmsModel[];\n plugins: CmsFieldTypePlugins;\n}\n\nconst removeFieldRequiredValidation = (field: CmsModelField) => {\n if (field.validation) {\n field.validation = field.validation.filter(validation => validation.name !== \"required\");\n }\n if (field.listValidation) {\n field.listValidation = field.listValidation.filter(v => v.name !== \"required\");\n }\n return field;\n};\n\nconst createUpdateFields = (fields: CmsModelField[]): CmsModelField[] => {\n return fields.reduce<CmsModelField[]>((collection, field) => {\n collection.push(removeFieldRequiredValidation({ ...field }));\n return collection;\n }, []);\n};\n\nexport const createFilesTypeDefs = (params: CreateFilesTypeDefsParams): string => {\n const { model, models, plugins: fieldTypePlugins } = params;\n const { fields } = model;\n\n const fieldTypes = renderFields({\n models,\n model,\n fields,\n type: \"manage\",\n fieldTypePlugins\n });\n const inputCreateFields = renderInputFields({\n models,\n model,\n fields,\n fieldTypePlugins\n });\n const inputUpdateFields = renderInputFields({\n models,\n model,\n fields: createUpdateFields(fields),\n fieldTypePlugins\n });\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins,\n excludeFields: [\"entryId\", \"status\"]\n });\n\n const excludeFromSorterts = [\"tags\", \"aliases\"];\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields.filter(field => !excludeFromSorterts.includes(field.fieldId)),\n fieldTypePlugins,\n sorterPlugins: []\n });\n\n return /* GraphQL */ `\n ${fieldTypes.map(f => f.typeDefs).join(\"\\n\")}\n\n type FmFile {\n id: ID!\n savedOn: DateTime!\n createdOn: DateTime!\n createdBy: FmCreatedBy!\n modifiedBy: FmCreatedBy\n src: String\n ${fieldTypes.map(f => f.fields).join(\"\\n\")}\n }\n\n ${inputCreateFields.map(f => f.typeDefs).join(\"\\n\")}\n \n input FmCreatedByInput {\n id: ID!\n displayName: String!\n type: String!\n }\n\n input FmFileCreateInput {\n id: ID!\n createdOn: DateTime\n savedOn: DateTime\n createdBy: FmCreatedByInput\n modifiedBy: FmCreatedByInput\n ${inputCreateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n input FmFileUpdateInput {\n createdOn: DateTime\n savedOn: DateTime\n createdBy: FmCreatedByInput\n modifiedBy: FmCreatedByInput\n ${inputUpdateFields.map(f => f.fields).join(\"\\n\")}\n }\n\n type FmFileResponse {\n data: FmFile\n error: FmError\n }\n\n input FmFileListWhereInput {\n ${listFilterFieldsRender}\n AND: [FmFileListWhereInput!]\n OR: [FmFileListWhereInput!]\n }\n\n type FmFileListResponse {\n data: [FmFile!]\n error: FmError\n meta: FmListMeta\n }\n\n enum FmFileListSorter {\n ${sortEnumRender}\n }\n\n input FmTagsListWhereInput {\n createdBy: String\n tags_startsWith: String\n tags_not_startsWith: String\n }\n\n type FmTag {\n tag: String!\n count: Number!\n }\n\n type FmTagsListResponse {\n data: [FmTag!]\n error: FmError\n }\n\n type FmCreateFilesResponse {\n data: [FmFile!]\n error: FmError\n }\n \n type FmFileModelResponse {\n data: JSON\n error: FmError\n }\n\n extend type FmQuery {\n getFileModel: FmFileModelResponse!\n getFile(id: ID!): FmFileResponse!\n listFiles(\n search: String\n where: FmFileListWhereInput\n limit: Int\n after: String\n sort: [FmFileListSorter!]\n ): FmFileListResponse!\n listTags(where: FmTagsListWhereInput): FmTagsListResponse!\n }\n\n extend type FmMutation {\n createFile(data: FmFileCreateInput!): FmFileResponse!\n createFiles(data: [FmFileCreateInput!]!): FmCreateFilesResponse!\n updateFile(id: ID!, data: FmFileUpdateInput!): FmFileResponse!\n deleteFile(id: ID!): FmBooleanResponse!\n }\n `;\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAQA,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A;AACA;AACA;AACA;AACA;AACA;AACA,cAAcZ,sBAAuB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAcI,cAAe;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAAK;AACL,CAAC;AAACS,OAAA,CAAAzB,mBAAA,GAAAA,mBAAA"}
|
package/graphql/filesSchema.js
CHANGED
|
@@ -56,13 +56,19 @@ const createFilesSchema = params => {
|
|
|
56
56
|
},
|
|
57
57
|
FmMutation: {
|
|
58
58
|
async createFile(_, args, context) {
|
|
59
|
-
return (0, _utils.resolve)(() =>
|
|
59
|
+
return (0, _utils.resolve)(() => {
|
|
60
|
+
return context.fileManager.createFile(args.data, args.meta);
|
|
61
|
+
});
|
|
60
62
|
},
|
|
61
63
|
async createFiles(_, args, context) {
|
|
62
|
-
return (0, _utils.resolve)(() =>
|
|
64
|
+
return (0, _utils.resolve)(() => {
|
|
65
|
+
return context.fileManager.createFilesInBatch(args.data, args.meta);
|
|
66
|
+
});
|
|
63
67
|
},
|
|
64
68
|
async updateFile(_, args, context) {
|
|
65
|
-
return (0, _utils.resolve)(() =>
|
|
69
|
+
return (0, _utils.resolve)(() => {
|
|
70
|
+
return context.fileManager.updateFile(args.id, args.data);
|
|
71
|
+
});
|
|
66
72
|
},
|
|
67
73
|
async deleteFile(_, args, context) {
|
|
68
74
|
return (0, _utils.resolve)(async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerGraphql","require","_utils","_createFilesTypeDefs","_apiSecurity","createFilesSchema","params","fileManagerGraphQL","GraphQLSchemaPlugin","typeDefs","createFilesTypeDefs","resolvers","Query","fileManager","emptyResolver","Mutation","FmFile","src","file","_","context","settings","getSettings","srcPrefix","key","FmQuery","getFileModel","__","identity","security","getIdentity","NotAuthorizedResponse","resolve","withoutAuthorization","cms","getModel","getFile","args","id","listFiles","data","meta","ListResponse","e","ErrorResponse","listTags","tags","Response","error","FmMutation","createFile","createFiles","createFilesInBatch","updateFile","deleteFile","storage","delete","name","exports"],"sources":["filesSchema.ts"],"sourcesContent":["import {\n ErrorResponse,\n GraphQLSchemaPlugin,\n ListResponse,\n Response\n} from \"@webiny/handler-graphql\";\nimport { FileManagerContext, FilesListOpts } from \"~/types\";\nimport { emptyResolver, resolve } from \"./utils\";\nimport { createFilesTypeDefs, CreateFilesTypeDefsParams } from \"~/graphql/createFilesTypeDefs\";\nimport { NotAuthorizedResponse } from \"@webiny/api-security\";\n\nexport const createFilesSchema = (params: CreateFilesTypeDefsParams) => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<FileManagerContext>({\n typeDefs: createFilesTypeDefs(params),\n resolvers: {\n Query: {\n fileManager: emptyResolver\n },\n Mutation: {\n fileManager: emptyResolver\n },\n FmFile: {\n async src(file, _, context: FileManagerContext) {\n const settings = await context.fileManager.getSettings();\n return (settings?.srcPrefix || \"\") + file.key;\n }\n },\n FmQuery: {\n getFileModel(_, __, context) {\n const identity = context.security.getIdentity();\n if (!identity) {\n return new NotAuthorizedResponse();\n }\n\n return resolve(() =>\n context.security.withoutAuthorization(() => {\n return context.cms.getModel(\"fmFile\");\n })\n );\n },\n getFile(_, args: any, context) {\n return resolve(() => context.fileManager.getFile(args.id));\n },\n async listFiles(_, args: FilesListOpts, context) {\n try {\n const [data, meta] = await context.fileManager.listFiles(args);\n\n return new ListResponse(data, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n async listTags(_, args: any, context) {\n try {\n const tags = await context.fileManager.listTags(args || {});\n\n return new Response(tags);\n } catch (error) {\n return new ErrorResponse(error);\n }\n }\n },\n FmMutation: {\n async createFile(_, args: any, context) {\n return resolve(() => context.fileManager.createFile(args.data, args.meta));\n },\n async createFiles(_, args: any, context) {\n return resolve(()
|
|
1
|
+
{"version":3,"names":["_handlerGraphql","require","_utils","_createFilesTypeDefs","_apiSecurity","createFilesSchema","params","fileManagerGraphQL","GraphQLSchemaPlugin","typeDefs","createFilesTypeDefs","resolvers","Query","fileManager","emptyResolver","Mutation","FmFile","src","file","_","context","settings","getSettings","srcPrefix","key","FmQuery","getFileModel","__","identity","security","getIdentity","NotAuthorizedResponse","resolve","withoutAuthorization","cms","getModel","getFile","args","id","listFiles","data","meta","ListResponse","e","ErrorResponse","listTags","tags","Response","error","FmMutation","createFile","createFiles","createFilesInBatch","updateFile","deleteFile","storage","delete","name","exports"],"sources":["filesSchema.ts"],"sourcesContent":["import {\n ErrorResponse,\n GraphQLSchemaPlugin,\n ListResponse,\n Response\n} from \"@webiny/handler-graphql\";\nimport { FileManagerContext, FilesListOpts } from \"~/types\";\nimport { emptyResolver, resolve } from \"./utils\";\nimport { createFilesTypeDefs, CreateFilesTypeDefsParams } from \"~/graphql/createFilesTypeDefs\";\nimport { NotAuthorizedResponse } from \"@webiny/api-security\";\n\nexport const createFilesSchema = (params: CreateFilesTypeDefsParams) => {\n const fileManagerGraphQL = new GraphQLSchemaPlugin<FileManagerContext>({\n typeDefs: createFilesTypeDefs(params),\n resolvers: {\n Query: {\n fileManager: emptyResolver\n },\n Mutation: {\n fileManager: emptyResolver\n },\n FmFile: {\n async src(file, _, context: FileManagerContext) {\n const settings = await context.fileManager.getSettings();\n return (settings?.srcPrefix || \"\") + file.key;\n }\n },\n FmQuery: {\n getFileModel(_, __, context) {\n const identity = context.security.getIdentity();\n if (!identity) {\n return new NotAuthorizedResponse();\n }\n\n return resolve(() =>\n context.security.withoutAuthorization(() => {\n return context.cms.getModel(\"fmFile\");\n })\n );\n },\n getFile(_, args: any, context) {\n return resolve(() => context.fileManager.getFile(args.id));\n },\n async listFiles(_, args: FilesListOpts, context) {\n try {\n const [data, meta] = await context.fileManager.listFiles(args);\n\n return new ListResponse(data, meta);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n async listTags(_, args: any, context) {\n try {\n const tags = await context.fileManager.listTags(args || {});\n\n return new Response(tags);\n } catch (error) {\n return new ErrorResponse(error);\n }\n }\n },\n FmMutation: {\n async createFile(_, args: any, context) {\n return resolve(() => {\n return context.fileManager.createFile(args.data, args.meta);\n });\n },\n async createFiles(_, args: any, context) {\n return resolve(() => {\n return context.fileManager.createFilesInBatch(args.data, args.meta);\n });\n },\n async updateFile(_, args: any, context) {\n return resolve(() => {\n return context.fileManager.updateFile(args.id, args.data);\n });\n },\n async deleteFile(_, args: any, context) {\n return resolve(async () => {\n // TODO: Ideally, this should work via a lifecycle hook; first we delete a record from DB, then from cloud storage.\n const file = await context.fileManager.getFile(args.id);\n return await context.fileManager.storage.delete({\n id: file.id,\n key: file.key\n });\n });\n }\n }\n }\n });\n fileManagerGraphQL.name = \"fm.graphql.files\";\n\n return fileManagerGraphQL;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAEO,MAAMI,iBAAiB,GAAIC,MAAiC,IAAK;EACpE,MAAMC,kBAAkB,GAAG,IAAIC,mCAAmB,CAAqB;IACnEC,QAAQ,EAAE,IAAAC,wCAAmB,EAACJ,MAAM,CAAC;IACrCK,SAAS,EAAE;MACPC,KAAK,EAAE;QACHC,WAAW,EAAEC;MACjB,CAAC;MACDC,QAAQ,EAAE;QACNF,WAAW,EAAEC;MACjB,CAAC;MACDE,MAAM,EAAE;QACJ,MAAMC,GAAGA,CAACC,IAAI,EAAEC,CAAC,EAAEC,OAA2B,EAAE;UAC5C,MAAMC,QAAQ,GAAG,MAAMD,OAAO,CAACP,WAAW,CAACS,WAAW,CAAC,CAAC;UACxD,OAAO,CAAC,CAAAD,QAAQ,aAARA,QAAQ,uBAAR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ACN;MACJ;IACJ;EACJ,CAAC,CAAC;EACFjB,kBAAkB,CAACkD,IAAI,GAAG,kBAAkB;EAE5C,OAAOlD,kBAAkB;AAC7B,CAAC;AAACmD,OAAA,CAAArD,iBAAA,GAAAA,iBAAA"}
|
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<
|
|
10
|
+
export declare const resolve: (fn: ResolveCallable) => Promise<Response<any> | ErrorResponse>;
|
|
11
11
|
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
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
|
+
declare type CmsModelField = Omit<BaseModelField, "storageId"> & {
|
|
5
|
+
bulkEdit?: boolean;
|
|
6
|
+
};
|
|
5
7
|
declare class CmsModelFieldsModifier {
|
|
6
8
|
private fields;
|
|
7
9
|
constructor(fields: BaseModelField[]);
|
|
@@ -6,17 +6,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.createFileModelModifier = exports.CmsModelModifierPlugin = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
9
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
11
|
var _plugins = require("@webiny/plugins");
|
|
11
12
|
var _file = require("../cmsFileStorage/file.model");
|
|
12
13
|
var _createModelField = require("../cmsFileStorage/createModelField");
|
|
14
|
+
const _excluded = ["bulkEdit", "tags"];
|
|
13
15
|
class CmsModelFieldsModifier {
|
|
14
16
|
constructor(fields) {
|
|
15
17
|
(0, _defineProperty2.default)(this, "fields", void 0);
|
|
16
18
|
this.fields = fields;
|
|
17
19
|
}
|
|
18
20
|
addField(field) {
|
|
19
|
-
|
|
21
|
+
const {
|
|
22
|
+
bulkEdit,
|
|
23
|
+
tags
|
|
24
|
+
} = field,
|
|
25
|
+
rest = (0, _objectWithoutProperties2.default)(field, _excluded);
|
|
26
|
+
this.fields.push((0, _objectSpread2.default)((0, _objectSpread2.default)({}, rest), {}, {
|
|
27
|
+
tags: (tags ?? []).concat(bulkEdit ? ["$bulk-edit"] : []),
|
|
20
28
|
storageId: `${field.type}@${field.id}`
|
|
21
29
|
}));
|
|
22
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","require","_file","_createModelField","CmsModelFieldsModifier","constructor","fields","_defineProperty2","default","addField","field","push","_objectSpread2","storageId","type","id","CmsModelModifierPlugin","Plugin","modelId","cb","modifyModel","model","extensionsField","find","fieldId","createModelField","label","settings","layout","modifier","exports","createFileModelModifier","FILE_MODEL_ID"],"sources":["CmsModelModifier.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsModelField as BaseModelField } from \"@webiny/api-headless-cms/types\";\nimport { FILE_MODEL_ID } from \"~/cmsFileStorage/file.model\";\nimport { createModelField } from \"~/cmsFileStorage/createModelField\";\nimport { CmsPrivateModelFull } from \"@webiny/api-headless-cms\";\n\ntype CmsModelField = Omit<BaseModelField, \"storageId\"
|
|
1
|
+
{"version":3,"names":["_plugins","require","_file","_createModelField","_excluded","CmsModelFieldsModifier","constructor","fields","_defineProperty2","default","addField","field","bulkEdit","tags","rest","_objectWithoutProperties2","push","_objectSpread2","concat","storageId","type","id","CmsModelModifierPlugin","Plugin","modelId","cb","modifyModel","model","extensionsField","find","fieldId","createModelField","label","settings","layout","modifier","exports","createFileModelModifier","FILE_MODEL_ID"],"sources":["CmsModelModifier.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsModelField as BaseModelField } from \"@webiny/api-headless-cms/types\";\nimport { FILE_MODEL_ID } from \"~/cmsFileStorage/file.model\";\nimport { createModelField } from \"~/cmsFileStorage/createModelField\";\nimport { CmsPrivateModelFull } from \"@webiny/api-headless-cms\";\n\ntype CmsModelField = Omit<BaseModelField, \"storageId\"> & { bulkEdit?: boolean };\n\nclass CmsModelFieldsModifier {\n private fields: BaseModelField[];\n\n constructor(fields: BaseModelField[]) {\n this.fields = fields;\n }\n\n addField(field: CmsModelField) {\n const { bulkEdit, tags, ...rest } = field;\n\n this.fields.push({\n ...rest,\n tags: (tags ?? []).concat(bulkEdit ? [\"$bulk-edit\"] : []),\n storageId: `${field.type}@${field.id}`\n });\n }\n}\n\ninterface CmsModelModifierCallableParams {\n modifier: CmsModelFieldsModifier;\n}\n\ninterface CmsModelModifierCallable {\n (params: CmsModelModifierCallableParams): Promise<void> | void;\n}\n\nexport class CmsModelModifierPlugin extends Plugin {\n public static override type = \"fm.cms-model-modifier\";\n private readonly modelId: string;\n private readonly cb: CmsModelModifierCallable;\n\n constructor(modelId: string, cb: CmsModelModifierCallable) {\n super();\n this.modelId = modelId;\n this.cb = cb;\n }\n\n async modifyModel(model: CmsPrivateModelFull): Promise<void> {\n if (model.modelId !== this.modelId) {\n return;\n }\n\n let extensionsField = model.fields.find(field => field.fieldId === \"extensions\");\n if (!extensionsField) {\n extensionsField = createModelField({\n label: \"Extensions\",\n type: \"object\",\n settings: {\n layout: [],\n fields: []\n }\n });\n model.fields.push(extensionsField);\n }\n\n const modifier = new CmsModelFieldsModifier(extensionsField.settings!.fields!);\n await this.cb({ modifier });\n }\n}\n\nexport const createFileModelModifier = (cb: CmsModelModifierCallable) => {\n return new CmsModelModifierPlugin(FILE_MODEL_ID, cb);\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAA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AAAG,kCAAgB,EAAC;QAC/BC,KAAK,EAAE,YAAY;QACnBZ,IAAI,EAAE,QAAQ;QACda,QAAQ,EAAE;UACNC,MAAM,EAAE,EAAE;UACV3B,MAAM,EAAE;QACZ;MACJ,CAAC,CAAC;MACFoB,KAAK,CAACpB,MAAM,CAACS,IAAI,CAACY,eAAe,CAAC;IACtC;IAEA,MAAMO,QAAQ,GAAG,IAAI9B,sBAAsB,CAACuB,eAAe,CAACK,QAAQ,CAAE1B,MAAO,CAAC;IAC9E,MAAM,IAAI,CAACkB,EAAE,CAAC;MAAEU;IAAS,CAAC,CAAC;EAC/B;AACJ;AAACC,OAAA,CAAAd,sBAAA,GAAAA,sBAAA;AAAA,IAAAd,gBAAA,CAAAC,OAAA,EAhCYa,sBAAsB,UACD,uBAAuB;AAiClD,MAAMe,uBAAuB,GAAIZ,EAA4B,IAAK;EACrE,OAAO,IAAIH,sBAAsB,CAACgB,mBAAa,EAAEb,EAAE,CAAC;AACxD,CAAC;AAACW,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-file-manager",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.39.0-beta.0",
|
|
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.39.0-beta.0",
|
|
24
|
+
"@webiny/api-headless-cms": "5.39.0-beta.0",
|
|
25
|
+
"@webiny/api-security": "5.39.0-beta.0",
|
|
26
|
+
"@webiny/api-tenancy": "5.39.0-beta.0",
|
|
27
|
+
"@webiny/error": "5.39.0-beta.0",
|
|
28
|
+
"@webiny/handler": "5.39.0-beta.0",
|
|
29
|
+
"@webiny/handler-aws": "5.39.0-beta.0",
|
|
30
|
+
"@webiny/handler-client": "5.39.0-beta.0",
|
|
31
|
+
"@webiny/handler-graphql": "5.39.0-beta.0",
|
|
32
|
+
"@webiny/plugins": "5.39.0-beta.0",
|
|
33
|
+
"@webiny/project-utils": "5.39.0-beta.0",
|
|
34
|
+
"@webiny/pubsub": "5.39.0-beta.0",
|
|
35
|
+
"@webiny/validation": "5.39.0-beta.0",
|
|
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.39.0-beta.0",
|
|
48
|
+
"@webiny/cli": "5.39.0-beta.0",
|
|
49
|
+
"@webiny/utils": "5.39.0-beta.0",
|
|
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": "df94742fba6658ed3507e1e17ab53dc77bb66330"
|
|
75
75
|
}
|
package/types/file.d.ts
CHANGED
package/types/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["file.ts"],"sourcesContent":["export interface File {\n id: string;\n key: string;\n size: number;\n type: string;\n name: string;\n meta: Record<string, any>;\n location: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n createdOn: string;\n savedOn: string;\n createdBy: CreatedBy;\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 [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":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["file.ts"],"sourcesContent":["export interface File {\n id: string;\n key: string;\n size: number;\n type: string;\n name: string;\n meta: Record<string, any>;\n location: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n createdOn: string;\n savedOn: string;\n createdBy: CreatedBy;\n modifiedBy?: CreatedBy | null;\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 [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":""}
|
package/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { TenancyContext } from "@webiny/api-tenancy/types";
|
|
|
4
4
|
import { SecurityContext, SecurityPermission } from "@webiny/api-security/types";
|
|
5
5
|
import { Context } from "@webiny/api/types";
|
|
6
6
|
import { FileLifecycleEvents } from "./types/file.lifecycle";
|
|
7
|
-
import { File } from "./types/file";
|
|
7
|
+
import { CreatedBy, File } from "./types/file";
|
|
8
8
|
import { Topic } from "@webiny/pubsub/types";
|
|
9
9
|
import { CmsContext } from "@webiny/api-headless-cms/types";
|
|
10
10
|
export * from "./types/file.lifecycle";
|
|
@@ -22,6 +22,10 @@ export interface FilePermission extends SecurityPermission {
|
|
|
22
22
|
}
|
|
23
23
|
export interface FileInput {
|
|
24
24
|
id: string;
|
|
25
|
+
createdOn?: string | Date | null;
|
|
26
|
+
savedOn?: string | Date | null;
|
|
27
|
+
createdBy?: CreatedBy | null;
|
|
28
|
+
modifiedBy?: CreatedBy | null;
|
|
25
29
|
key: string;
|
|
26
30
|
name: string;
|
|
27
31
|
size: number;
|
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 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"}
|
|
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\";\n\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 createdOn?: string | Date | null;\n savedOn?: string | Date | null;\n createdBy?: CreatedBy | null;\n modifiedBy?: CreatedBy | null;\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":";;;;;AAUA,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"}
|