@webiny/api-file-manager 0.0.0-unstable.c2780f51fe → 0.0.0-unstable.c7dec08bb0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FileManagerContextSetup.d.ts +13 -0
- package/FileManagerContextSetup.js +113 -0
- package/FileManagerContextSetup.js.map +1 -0
- package/cmsFileStorage/CmsFilesStorage.d.ts +27 -0
- package/cmsFileStorage/CmsFilesStorage.js +173 -0
- package/cmsFileStorage/CmsFilesStorage.js.map +1 -0
- package/cmsFileStorage/ListFilesWhereProcessor.d.ts +7 -0
- package/cmsFileStorage/ListFilesWhereProcessor.js +35 -0
- package/cmsFileStorage/ListFilesWhereProcessor.js.map +1 -0
- package/cmsFileStorage/ListTagsWhereProcessor.d.ts +7 -0
- package/cmsFileStorage/ListTagsWhereProcessor.js +35 -0
- package/cmsFileStorage/ListTagsWhereProcessor.js.map +1 -0
- package/cmsFileStorage/createFileManagerPlugins.d.ts +5 -0
- package/cmsFileStorage/createFileManagerPlugins.js +34 -0
- package/cmsFileStorage/createFileManagerPlugins.js.map +1 -0
- package/cmsFileStorage/createModelField.d.ts +5 -0
- package/cmsFileStorage/createModelField.js +37 -0
- package/cmsFileStorage/createModelField.js.map +1 -0
- package/cmsFileStorage/file.model.d.ts +4 -0
- package/cmsFileStorage/file.model.js +118 -0
- package/cmsFileStorage/file.model.js.map +1 -0
- package/cmsFileStorage/isInstallationPending.d.ts +4 -0
- package/cmsFileStorage/isInstallationPending.js +21 -0
- package/cmsFileStorage/isInstallationPending.js.map +1 -0
- package/contants.d.ts +1 -0
- package/contants.js +8 -0
- package/contants.js.map +1 -0
- package/createFileManager/files.crud.js +51 -76
- package/createFileManager/files.crud.js.map +1 -1
- package/createFileManager/index.d.ts +4 -2
- package/createFileManager/index.js.map +1 -1
- package/createFileManager/permissions/FilesPermissions.d.ts +4 -0
- package/createFileManager/permissions/FilesPermissions.js +9 -0
- package/createFileManager/permissions/FilesPermissions.js.map +1 -0
- package/createFileManager/settings.crud.js +1 -1
- package/createFileManager/settings.crud.js.map +1 -1
- package/graphql/baseSchema.d.ts +3 -0
- package/graphql/baseSchema.js +117 -0
- package/graphql/baseSchema.js.map +1 -0
- package/graphql/createFilesTypeDefs.d.ts +7 -0
- package/graphql/createFilesTypeDefs.js +162 -0
- package/graphql/createFilesTypeDefs.js.map +1 -0
- package/graphql/filesSchema.d.ts +4 -0
- package/graphql/filesSchema.js +83 -0
- package/graphql/filesSchema.js.map +1 -0
- package/graphql/index.d.ts +2 -2
- package/graphql/index.js +23 -267
- package/graphql/index.js.map +1 -1
- package/graphql/utils.d.ts +11 -0
- package/graphql/utils.js +22 -0
- package/graphql/utils.js.map +1 -0
- package/handlers/download/byAlias.js +9 -9
- package/handlers/download/byAlias.js.map +1 -1
- package/handlers/download/byExactKey.js +9 -9
- package/handlers/download/byExactKey.js.map +1 -1
- package/handlers/download/getS3Object.d.ts +2 -0
- package/handlers/download/getS3Object.js +39 -24
- package/handlers/download/getS3Object.js.map +1 -1
- package/handlers/transform/index.js +5 -2
- package/handlers/transform/index.js.map +1 -1
- package/handlers/transform/transformImage.d.ts +5 -2
- package/handlers/transform/transformImage.js +7 -4
- package/handlers/transform/transformImage.js.map +1 -1
- package/handlers/transform/utils.js +2 -2
- package/handlers/transform/utils.js.map +1 -1
- package/index.d.ts +3 -2
- package/index.js +20 -36
- package/index.js.map +1 -1
- package/modelModifier/CmsModelModifier.d.ts +24 -0
- package/modelModifier/CmsModelModifier.js +59 -0
- package/modelModifier/CmsModelModifier.js.map +1 -0
- package/package.json +28 -27
- package/types/file.d.ts +5 -1
- package/types/file.js.map +1 -1
- package/types/file.lifecycle.d.ts +4 -0
- package/types/file.lifecycle.js.map +1 -1
- package/types.d.ts +28 -34
- package/types.js.map +1 -1
- package/createFileManager/checkBasePermissions.d.ts +0 -5
- package/createFileManager/checkBasePermissions.js +0 -24
- package/createFileManager/checkBasePermissions.js.map +0 -1
- package/plugins/crud/files/validation.d.ts +0 -3
- package/plugins/crud/files/validation.js +0 -41
- package/plugins/crud/files/validation.js.map +0 -1
- package/plugins/crud/files.crud.d.ts +0 -4
- package/plugins/crud/files.crud.js +0 -431
- package/plugins/crud/files.crud.js.map +0 -1
- package/plugins/crud/settings.crud.d.ts +0 -5
- package/plugins/crud/settings.crud.js +0 -116
- package/plugins/crud/settings.crud.js.map +0 -1
- package/plugins/crud/system.crud.d.ts +0 -4
- package/plugins/crud/system.crud.js +0 -153
- package/plugins/crud/system.crud.js.map +0 -1
- package/plugins/crud/utils/checkBasePermissions.d.ts +0 -5
- package/plugins/crud/utils/checkBasePermissions.js +0 -33
- package/plugins/crud/utils/checkBasePermissions.js.map +0 -1
- package/plugins/crud/utils/createFileModel.d.ts +0 -5
- package/plugins/crud/utils/createFileModel.js +0 -77
- package/plugins/crud/utils/createFileModel.js.map +0 -1
- package/plugins/crud/utils/lifecycleEvents.d.ts +0 -6
- package/plugins/crud/utils/lifecycleEvents.js +0 -38
- package/plugins/crud/utils/lifecycleEvents.js.map +0 -1
- package/plugins/definitions/FilePhysicalStoragePlugin.d.ts +0 -21
- package/plugins/definitions/FilePhysicalStoragePlugin.js +0 -42
- package/plugins/definitions/FilePhysicalStoragePlugin.js.map +0 -1
- package/plugins/definitions/FilePlugin.d.ts +0 -136
- package/plugins/definitions/FilePlugin.js +0 -70
- package/plugins/definitions/FilePlugin.js.map +0 -1
- package/plugins/definitions/FileStorageTransformPlugin.d.ts +0 -34
- package/plugins/definitions/FileStorageTransformPlugin.js +0 -51
- package/plugins/definitions/FileStorageTransformPlugin.js.map +0 -1
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/definitions/InstallationPlugin.d.ts +0 -19
- package/plugins/definitions/InstallationPlugin.js +0 -42
- package/plugins/definitions/InstallationPlugin.js.map +0 -1
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/graphql.d.ts +0 -4
- package/plugins/graphql.js +0 -290
- package/plugins/graphql.js.map +0 -1
- package/plugins/storage/FileStorage.d.ts +0 -30
- package/plugins/storage/FileStorage.js +0 -103
- package/plugins/storage/FileStorage.js.map +0 -1
- package/plugins/storage/index.d.ts +0 -4
- package/plugins/storage/index.js +0 -26
- package/plugins/storage/index.js.map +0 -1
- package/utils.d.ts +0 -4
- package/utils.js +0 -16
- package/utils.js.map +0 -1
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"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\";\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 extends Context, SecurityContext, TenancyContext, I18NContext {\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 tags: string[];\n aliases: string[];\n}\n\nexport interface FileListWhereParams {\n search?: string;\n type?: string;\n type_in?: string[];\n tag?: string;\n tag_in?: string[];\n tag_and_in?: string[];\n id_in?: string[];\n id?: string;\n}\nexport interface FilesListOpts {\n search?: string;\n types?: string[];\n tags?: string[];\n ids?: 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 FilesCRUD extends FileLifecycleEvents {\n getFile(id: string): Promise<File>;\n listFiles(opts?: FilesListOpts): Promise<[File[], FileListMeta]>;\n listTags(params: FilesCrudListTagsParams): Promise<string[]>;\n createFile(data: FileInput): Promise<File>;\n updateFile(id: string, data: Partial<FileInput>): Promise<File>;\n deleteFile(id: string): Promise<boolean>;\n createFilesInBatch(data: FileInput[]): Promise<File[]>;\n}\n\nexport interface SystemCRUD {\n onSystemBeforeInstall: Topic;\n onSystemAfterInstall: Topic;\n getVersion(): Promise<string | null>;\n setVersion(version: string): Promise<void>;\n install(args: { srcPrefix: string }): Promise<boolean>;\n}\n\nexport interface FileManagerSettings {\n tenant: string;\n key: string;\n uploadMinFileSize: number;\n uploadMaxFileSize: number;\n srcPrefix: string;\n}\n\nexport interface FileManagerSystem {\n version: string;\n tenant: string;\n}\n\nexport type SettingsCRUD = {\n getSettings(): Promise<FileManagerSettings | null>;\n createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n deleteSettings(): Promise<boolean>;\n};\n/********\n * Storage operations\n *******/\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsUpdateParams {\n /**\n * The system data to be updated.\n */\n original: FileManagerSystem;\n /**\n * The system data with the updated fields.\n */\n data: FileManagerSystem;\n}\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsCreateParams {\n /**\n * The system fields.\n */\n data: FileManagerSystem;\n}\n\nexport interface FileManagerSystemStorageOperationsGetParams {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n */\nexport interface FileManagerSystemStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (params: FileManagerSystemStorageOperationsGetParams) => Promise<FileManagerSystem | null>;\n /**\n * Update the FileManager system data..\n */\n update: (params: FileManagerSystemStorageOperationsUpdateParams) => Promise<FileManagerSystem>;\n /**\n * Create the FileManagerSystemData\n */\n create: (params: FileManagerSystemStorageOperationsCreateParams) => Promise<FileManagerSystem>;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsUpdateParams {\n /**\n * Original settings to be updated.\n */\n original: FileManagerSettings;\n /**\n * The settings with the updated fields.\n */\n data: FileManagerSettings;\n}\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsCreateParams {\n /**\n * The settings fields.\n */\n data: FileManagerSettings;\n}\n\nexport interface FileManagerStorageOperationsGetSettingsParams {\n tenant: string;\n}\n\nexport interface FileManagerStorageOperationsDeleteSettings {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n */\nexport interface FileManagerSettingsStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (\n params: FileManagerStorageOperationsGetSettingsParams\n ) => Promise<FileManagerSettings | null>;\n /**\n * Create the FileManagerSettingsData\n */\n create: (\n params: FileManagerSettingsStorageOperationsCreateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Update the FileManager system data..\n */\n update: (\n params: FileManagerSettingsStorageOperationsUpdateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Delete the existing settings.\n */\n delete: (params: FileManagerStorageOperationsDeleteSettings) => Promise<void>;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsUpdateParams {\n original: File;\n file: File;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsDeleteParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateBatchParams {\n files: File[];\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParamsWhere {\n id?: string;\n id_in?: string[];\n name?: string;\n name_contains?: string;\n tag?: string;\n tag_contains?: string;\n tag_in?: string[];\n createdBy?: string;\n locale: string;\n tenant: string;\n private?: boolean;\n type?: string;\n type_in?: string[];\n search?: string;\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}\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 type FileManagerFilesStorageOperationsTagsResponse = [\n string[],\n FileManagerFilesStorageOperationsListResponseMeta\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 FileManagerStorageOperations<TContext = FileManagerContext> {\n beforeInit?: (context: TContext) => Promise<void>;\n files: FileManagerFilesStorageOperations;\n settings: FileManagerSettingsStorageOperations;\n system: FileManagerSystemStorageOperations;\n}\n"],"mappings":";;;;;AAQA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { I18NContext } from \"@webiny/api-i18n/types\";\nimport { FileStorage } from \"./storage/FileStorage\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { SecurityContext, SecurityPermission } from \"@webiny/api-security/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { FileLifecycleEvents } from \"./types/file.lifecycle\";\nimport { File } from \"./types/file\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nexport * from \"./types/file.lifecycle\";\nexport * from \"./types/file\";\n\nexport interface FileManagerContextObject extends FilesCRUD, SettingsCRUD, SystemCRUD {\n storage: FileStorage;\n}\n\nexport interface FileManagerContext\n extends Context,\n SecurityContext,\n TenancyContext,\n I18NContext,\n CmsContext {\n fileManager: FileManagerContextObject;\n}\n\nexport interface FilePermission extends SecurityPermission {\n name: \"fm.file\";\n rwd?: string;\n own?: boolean;\n}\n\nexport interface FileInput {\n id: string;\n key: string;\n name: string;\n size: number;\n type: string;\n meta: Record<string, any>;\n location?: {\n folderId: string;\n };\n tags: string[];\n aliases: string[];\n extensions?: Record<string, any>;\n}\n\nexport interface FileListWhereParams {\n AND?: FileListWhereParams[];\n OR?: FileListWhereParams[];\n [key: string]: any;\n}\nexport interface FilesListOpts {\n search?: string;\n limit?: number;\n after?: string;\n where?: FileListWhereParams;\n sort?: string[];\n}\n\nexport interface FileListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\ninterface FilesCrudListTagsWhere {\n tag?: string;\n tag_contains?: string;\n tag_in?: string[];\n tag_not_startsWith?: string;\n tag_startsWith?: string;\n}\ninterface FilesCrudListTagsParams {\n where?: FilesCrudListTagsWhere;\n limit?: number;\n after?: string;\n}\n\nexport interface ListTagsResponse {\n tag: string;\n count: number;\n}\nexport interface FilesCRUD extends FileLifecycleEvents {\n getFile(id: string): Promise<File>;\n listFiles(opts?: FilesListOpts): Promise<[File[], FileListMeta]>;\n listTags(params: FilesCrudListTagsParams): Promise<ListTagsResponse[]>;\n createFile(data: FileInput, meta?: Record<string, any>): Promise<File>;\n updateFile(id: string, data: Partial<FileInput>): Promise<File>;\n deleteFile(id: string): Promise<boolean>;\n createFilesInBatch(data: FileInput[], meta?: Record<string, any>): Promise<File[]>;\n}\n\nexport interface SystemCRUD {\n onSystemBeforeInstall: Topic;\n onSystemAfterInstall: Topic;\n getVersion(): Promise<string | null>;\n setVersion(version: string): Promise<void>;\n install(args: { srcPrefix: string }): Promise<boolean>;\n}\n\nexport interface FileManagerSettings {\n tenant: string;\n key: string;\n uploadMinFileSize: number;\n uploadMaxFileSize: number;\n srcPrefix: string;\n}\n\nexport interface FileManagerSystem {\n version: string;\n tenant: string;\n}\n\nexport type SettingsCRUD = {\n getSettings(): Promise<FileManagerSettings | null>;\n createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;\n deleteSettings(): Promise<boolean>;\n};\n/********\n * Storage operations\n *******/\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsUpdateParams {\n /**\n * The system data to be updated.\n */\n original: FileManagerSystem;\n /**\n * The system data with the updated fields.\n */\n data: FileManagerSystem;\n}\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n * @category SystemStorageOperationsParams\n */\nexport interface FileManagerSystemStorageOperationsCreateParams {\n /**\n * The system fields.\n */\n data: FileManagerSystem;\n}\n\nexport interface FileManagerSystemStorageOperationsGetParams {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n */\nexport interface FileManagerSystemStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (params: FileManagerSystemStorageOperationsGetParams) => Promise<FileManagerSystem | null>;\n /**\n * Update the FileManager system data..\n */\n update: (params: FileManagerSystemStorageOperationsUpdateParams) => Promise<FileManagerSystem>;\n /**\n * Create the FileManagerSystemData\n */\n create: (params: FileManagerSystemStorageOperationsCreateParams) => Promise<FileManagerSystem>;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsUpdateParams {\n /**\n * Original settings to be updated.\n */\n original: FileManagerSettings;\n /**\n * The settings with the updated fields.\n */\n data: FileManagerSettings;\n}\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n * @category SettingsStorageOperationsParams\n */\nexport interface FileManagerSettingsStorageOperationsCreateParams {\n /**\n * The settings fields.\n */\n data: FileManagerSettings;\n}\n\nexport interface FileManagerStorageOperationsGetSettingsParams {\n tenant: string;\n}\n\nexport interface FileManagerStorageOperationsDeleteSettings {\n tenant: string;\n}\n\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n */\nexport interface FileManagerSettingsStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: (\n params: FileManagerStorageOperationsGetSettingsParams\n ) => Promise<FileManagerSettings | null>;\n /**\n * Create the FileManagerSettingsData\n */\n create: (\n params: FileManagerSettingsStorageOperationsCreateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Update the FileManager system data..\n */\n update: (\n params: FileManagerSettingsStorageOperationsUpdateParams\n ) => Promise<FileManagerSettings>;\n /**\n * Delete the existing settings.\n */\n delete: (params: FileManagerStorageOperationsDeleteSettings) => Promise<void>;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsGetParams {\n where: {\n id: string;\n tenant: string;\n locale: string;\n };\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsUpdateParams {\n original: File;\n file: File;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsDeleteParams {\n file: File;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsCreateBatchParams {\n files: File[];\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParamsWhere {\n [key: string]: any;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListParams {\n where: FileManagerFilesStorageOperationsListParamsWhere;\n sort: string[];\n limit: number;\n after: string | null;\n search?: string;\n}\n\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsListResponseMeta {\n hasMoreItems: boolean;\n totalCount: number;\n cursor: string | null;\n}\nexport type FileManagerFilesStorageOperationsListResponse = [\n File[],\n FileManagerFilesStorageOperationsListResponseMeta\n];\n\nexport interface FileManagerFilesStorageOperationsTagsResponse {\n tag: string;\n count: number;\n}\n\nexport interface FileManagerFilesStorageOperationsTagsParamsWhere extends FilesCrudListTagsWhere {\n locale: string;\n tenant: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n * @category FilesStorageOperationsParams\n */\nexport interface FileManagerFilesStorageOperationsTagsParams {\n where: FileManagerFilesStorageOperationsTagsParamsWhere;\n limit: number;\n after?: string;\n}\n/**\n * @category StorageOperations\n * @category FilesStorageOperations\n */\nexport interface FileManagerFilesStorageOperations {\n /**\n * Get a single file with given ID from the storage.\n */\n get: (params: FileManagerFilesStorageOperationsGetParams) => Promise<File | null>;\n /**\n * Insert the file data into the database.\n */\n create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File>;\n /**\n * Update the file data in the database.\n */\n update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File>;\n /**\n * Delete the file from the database.\n */\n delete: (params: FileManagerFilesStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Store multiple files at once to the database.\n */\n createBatch: (params: FileManagerFilesStorageOperationsCreateBatchParams) => Promise<File[]>;\n /**\n * Get a list of files filtered by given parameters.\n */\n list: (\n params: FileManagerFilesStorageOperationsListParams\n ) => Promise<FileManagerFilesStorageOperationsListResponse>;\n /**\n * Get a list of all file tags filtered by given parameters.\n */\n tags: (\n params: FileManagerFilesStorageOperationsTagsParams\n ) => Promise<FileManagerFilesStorageOperationsTagsResponse[]>;\n}\n\nexport interface FileManagerAliasesStorageOperations {\n storeAliases(file: File): Promise<void>;\n deleteAliases(file: File): Promise<void>;\n}\n\nexport interface FileManagerStorageOperations<TContext = FileManagerContext> {\n beforeInit?: (context: TContext) => Promise<void>;\n files: FileManagerFilesStorageOperations;\n aliases: FileManagerAliasesStorageOperations;\n settings: FileManagerSettingsStorageOperations;\n system: FileManagerSystemStorageOperations;\n}\n"],"mappings":";;;;;AASA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.checkBasePermissions = void 0;
|
|
7
|
-
var _apiSecurity = require("@webiny/api-security");
|
|
8
|
-
const checkBasePermissions = async (getPermission, check = {}) => {
|
|
9
|
-
const filePermission = await getPermission("fm.file");
|
|
10
|
-
if (!filePermission) {
|
|
11
|
-
throw new _apiSecurity.NotAuthorizedError();
|
|
12
|
-
}
|
|
13
|
-
if (check.rwd && !hasRwd(filePermission, check.rwd)) {
|
|
14
|
-
throw new _apiSecurity.NotAuthorizedError();
|
|
15
|
-
}
|
|
16
|
-
return filePermission;
|
|
17
|
-
};
|
|
18
|
-
exports.checkBasePermissions = checkBasePermissions;
|
|
19
|
-
const hasRwd = (filesFilePermission, rwd) => {
|
|
20
|
-
if (typeof filesFilePermission.rwd !== "string") {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
return filesFilePermission.rwd.includes(rwd);
|
|
24
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["checkBasePermissions","getPermission","check","filePermission","NotAuthorizedError","rwd","hasRwd","filesFilePermission","includes"],"sources":["checkBasePermissions.ts"],"sourcesContent":["import { NotAuthorizedError } from \"@webiny/api-security\";\nimport { GetPermission } from \"@webiny/api-security/types\";\nimport { FilePermission } from \"~/types\";\n\nexport const checkBasePermissions = async (\n getPermission: GetPermission,\n check: { rwd?: string } = {}\n): Promise<FilePermission> => {\n const filePermission = await getPermission<FilePermission>(\"fm.file\");\n\n if (!filePermission) {\n throw new NotAuthorizedError();\n }\n if (check.rwd && !hasRwd(filePermission, check.rwd)) {\n throw new NotAuthorizedError();\n }\n\n return filePermission;\n};\n\nconst hasRwd = (filesFilePermission: FilePermission, rwd: string): boolean => {\n if (typeof filesFilePermission.rwd !== \"string\") {\n return true;\n }\n\n return filesFilePermission.rwd.includes(rwd);\n};\n"],"mappings":";;;;;;AAAA;AAIO,MAAMA,oBAAoB,GAAG,OAChCC,aAA4B,EAC5BC,KAAuB,GAAG,CAAC,CAAC,KACF;EAC1B,MAAMC,cAAc,GAAG,MAAMF,aAAa,CAAiB,SAAS,CAAC;EAErE,IAAI,CAACE,cAAc,EAAE;IACjB,MAAM,IAAIC,+BAAkB,EAAE;EAClC;EACA,IAAIF,KAAK,CAACG,GAAG,IAAI,CAACC,MAAM,CAACH,cAAc,EAAED,KAAK,CAACG,GAAG,CAAC,EAAE;IACjD,MAAM,IAAID,+BAAkB,EAAE;EAClC;EAEA,OAAOD,cAAc;AACzB,CAAC;AAAC;AAEF,MAAMG,MAAM,GAAG,CAACC,mBAAmC,EAAEF,GAAW,KAAc;EAC1E,IAAI,OAAOE,mBAAmB,CAACF,GAAG,KAAK,QAAQ,EAAE;IAC7C,OAAO,IAAI;EACf;EAEA,OAAOE,mBAAmB,CAACF,GAAG,CAACG,QAAQ,CAACH,GAAG,CAAC;AAChD,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _FilePlugin = require("../../definitions/FilePlugin");
|
|
11
|
-
|
|
12
|
-
var _createFileModel = _interopRequireDefault(require("../utils/createFileModel"));
|
|
13
|
-
|
|
14
|
-
var _default = () => [new _FilePlugin.FilePlugin({
|
|
15
|
-
beforeCreate: async ({
|
|
16
|
-
data
|
|
17
|
-
}) => {
|
|
18
|
-
const FileModel = (0, _createFileModel.default)();
|
|
19
|
-
const fileData = new FileModel().populate(data);
|
|
20
|
-
await fileData.validate();
|
|
21
|
-
},
|
|
22
|
-
beforeUpdate: async ({
|
|
23
|
-
data
|
|
24
|
-
}) => {
|
|
25
|
-
const FileModel = (0, _createFileModel.default)(false);
|
|
26
|
-
const updatedFileData = new FileModel().populate(data);
|
|
27
|
-
await updatedFileData.validate();
|
|
28
|
-
},
|
|
29
|
-
beforeBatchCreate: async ({
|
|
30
|
-
data
|
|
31
|
-
}) => {
|
|
32
|
-
const FileModel = (0, _createFileModel.default)();
|
|
33
|
-
|
|
34
|
-
for (const input of data) {
|
|
35
|
-
const fileInstance = new FileModel().populate(input);
|
|
36
|
-
await fileInstance.validate();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
})];
|
|
40
|
-
|
|
41
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["FilePlugin","beforeCreate","data","FileModel","createFileModel","fileData","populate","validate","beforeUpdate","updatedFileData","beforeBatchCreate","input","fileInstance"],"sources":["validation.ts"],"sourcesContent":["import { FilePlugin } from \"~/plugins/definitions/FilePlugin\";\nimport createFileModel from \"~/plugins/crud/utils/createFileModel\";\n\nexport default (): FilePlugin[] => [\n new FilePlugin({\n beforeCreate: async ({ data }) => {\n const FileModel = createFileModel();\n const fileData = new FileModel().populate(data);\n await fileData.validate();\n },\n beforeUpdate: async ({ data }) => {\n const FileModel = createFileModel(false);\n const updatedFileData = new FileModel().populate(data);\n await updatedFileData.validate();\n },\n beforeBatchCreate: async ({ data }) => {\n const FileModel = createFileModel();\n for (const input of data) {\n const fileInstance = new FileModel().populate(input);\n await fileInstance.validate();\n }\n }\n })\n];\n"],"mappings":";;;;;;;;;AAAA;;AACA;;eAEe,MAAoB,CAC/B,IAAIA,sBAAJ,CAAe;EACXC,YAAY,EAAE,OAAO;IAAEC;EAAF,CAAP,KAAoB;IAC9B,MAAMC,SAAS,GAAG,IAAAC,wBAAA,GAAlB;IACA,MAAMC,QAAQ,GAAG,IAAIF,SAAJ,GAAgBG,QAAhB,CAAyBJ,IAAzB,CAAjB;IACA,MAAMG,QAAQ,CAACE,QAAT,EAAN;EACH,CALU;EAMXC,YAAY,EAAE,OAAO;IAAEN;EAAF,CAAP,KAAoB;IAC9B,MAAMC,SAAS,GAAG,IAAAC,wBAAA,EAAgB,KAAhB,CAAlB;IACA,MAAMK,eAAe,GAAG,IAAIN,SAAJ,GAAgBG,QAAhB,CAAyBJ,IAAzB,CAAxB;IACA,MAAMO,eAAe,CAACF,QAAhB,EAAN;EACH,CAVU;EAWXG,iBAAiB,EAAE,OAAO;IAAER;EAAF,CAAP,KAAoB;IACnC,MAAMC,SAAS,GAAG,IAAAC,wBAAA,GAAlB;;IACA,KAAK,MAAMO,KAAX,IAAoBT,IAApB,EAA0B;MACtB,MAAMU,YAAY,GAAG,IAAIT,SAAJ,GAAgBG,QAAhB,CAAyBK,KAAzB,CAArB;MACA,MAAMC,YAAY,CAACL,QAAb,EAAN;IACH;EACJ;AAjBU,CAAf,CAD+B,C"}
|
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
|
-
var _mdbid = _interopRequireDefault(require("mdbid"));
|
|
13
|
-
|
|
14
|
-
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
15
|
-
|
|
16
|
-
var _apiSecurity = require("@webiny/api-security");
|
|
17
|
-
|
|
18
|
-
var _checkBasePermissions = _interopRequireDefault(require("./utils/checkBasePermissions"));
|
|
19
|
-
|
|
20
|
-
var _api = require("@webiny/api");
|
|
21
|
-
|
|
22
|
-
var _FilePlugin = require("../definitions/FilePlugin");
|
|
23
|
-
|
|
24
|
-
var _FilesStorageOperationsProviderPlugin = require("../definitions/FilesStorageOperationsProviderPlugin");
|
|
25
|
-
|
|
26
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
27
|
-
|
|
28
|
-
var _lifecycleEvents = require("./utils/lifecycleEvents");
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Package mdbid does not have types.
|
|
32
|
-
*/
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
const BATCH_CREATE_MAX_FILES = 20;
|
|
35
|
-
/**
|
|
36
|
-
* If permission is limited to "own" files only, check that current identity owns the file.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
const checkOwnership = (file, permission, context) => {
|
|
40
|
-
if ((permission === null || permission === void 0 ? void 0 : permission.own) === true) {
|
|
41
|
-
const identity = context.security.getIdentity();
|
|
42
|
-
|
|
43
|
-
if (file.createdBy.id !== identity.id) {
|
|
44
|
-
throw new _apiSecurity.NotAuthorizedError();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const getLocaleCode = context => {
|
|
50
|
-
if (!context.i18n) {
|
|
51
|
-
throw new _error.default("Missing i18n on the FileManagerContext.", "MISSING_I18N");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const locale = context.i18n.getContentLocale();
|
|
55
|
-
|
|
56
|
-
if (!locale) {
|
|
57
|
-
throw new _error.default("Missing content locale on the FileManagerContext.", "MISSING_I18N_CONTENT_LOCALE");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (!locale.code) {
|
|
61
|
-
throw new _error.default("Missing content locale code on the FileManagerContext.", "MISSING_I18N_CONTENT_LOCALE_CODE");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return locale.code;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const filesContextCrudPlugin = new _api.ContextPlugin(async context => {
|
|
68
|
-
const pluginType = _FilesStorageOperationsProviderPlugin.FilesStorageOperationsProviderPlugin.type;
|
|
69
|
-
const providerPlugin = context.plugins.byType(pluginType).find(() => true);
|
|
70
|
-
|
|
71
|
-
if (!providerPlugin) {
|
|
72
|
-
throw new _error.default(`Missing "${pluginType}" plugin.`, "PLUGIN_NOT_FOUND", {
|
|
73
|
-
type: pluginType
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const storageOperations = await providerPlugin.provide({
|
|
78
|
-
context
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
if (!context.fileManager) {
|
|
82
|
-
context.fileManager = {};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const filePlugins = context.plugins.byType(_FilePlugin.FilePlugin.type);
|
|
86
|
-
context.fileManager.files = {
|
|
87
|
-
async getFile(id) {
|
|
88
|
-
const permission = await (0, _checkBasePermissions.default)(context, {
|
|
89
|
-
rwd: "r"
|
|
90
|
-
});
|
|
91
|
-
const file = await storageOperations.get({
|
|
92
|
-
where: {
|
|
93
|
-
id,
|
|
94
|
-
tenant: context.tenancy.getCurrentTenant().id,
|
|
95
|
-
locale: getLocaleCode(context)
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
if (!file) {
|
|
100
|
-
throw new _handlerGraphql.NotFoundError(`File with id "${id}" does not exists.`);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
checkOwnership(file, permission, context);
|
|
104
|
-
return file;
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
async createFile(input) {
|
|
108
|
-
await (0, _checkBasePermissions.default)(context, {
|
|
109
|
-
rwd: "w"
|
|
110
|
-
});
|
|
111
|
-
const identity = context.security.getIdentity();
|
|
112
|
-
const tenant = context.tenancy.getCurrentTenant();
|
|
113
|
-
const id = (0, _mdbid.default)();
|
|
114
|
-
const file = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
|
|
115
|
-
tags: Array.isArray(input.tags) ? input.tags : [],
|
|
116
|
-
id,
|
|
117
|
-
meta: (0, _objectSpread2.default)({
|
|
118
|
-
private: false
|
|
119
|
-
}, input.meta || {}),
|
|
120
|
-
tenant: tenant.id,
|
|
121
|
-
createdOn: new Date().toISOString(),
|
|
122
|
-
createdBy: {
|
|
123
|
-
id: identity.id,
|
|
124
|
-
displayName: identity.displayName,
|
|
125
|
-
type: identity.type
|
|
126
|
-
},
|
|
127
|
-
locale: getLocaleCode(context),
|
|
128
|
-
webinyVersion: context.WEBINY_VERSION
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
await (0, _lifecycleEvents.runLifecycleEvent)("beforeCreate", {
|
|
133
|
-
context,
|
|
134
|
-
plugins: filePlugins,
|
|
135
|
-
data: file
|
|
136
|
-
});
|
|
137
|
-
const result = await storageOperations.create({
|
|
138
|
-
file
|
|
139
|
-
});
|
|
140
|
-
await (0, _lifecycleEvents.runLifecycleEvent)("afterCreate", {
|
|
141
|
-
context,
|
|
142
|
-
plugins: filePlugins,
|
|
143
|
-
data: file,
|
|
144
|
-
file: result
|
|
145
|
-
});
|
|
146
|
-
return result;
|
|
147
|
-
} catch (ex) {
|
|
148
|
-
throw new _error.default(ex.message || "Could not create a file.", ex.code || "CREATE_FILE_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
|
|
149
|
-
file
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
async updateFile(id, input) {
|
|
155
|
-
const permission = await (0, _checkBasePermissions.default)(context, {
|
|
156
|
-
rwd: "w"
|
|
157
|
-
});
|
|
158
|
-
const original = await storageOperations.get({
|
|
159
|
-
where: {
|
|
160
|
-
id,
|
|
161
|
-
tenant: context.tenancy.getCurrentTenant().id,
|
|
162
|
-
locale: getLocaleCode(context)
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
if (!original) {
|
|
167
|
-
throw new _handlerGraphql.NotFoundError(`File with id "${id}" does not exists.`);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
checkOwnership(original, permission, context);
|
|
171
|
-
const file = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, original), input), {}, {
|
|
172
|
-
tags: Array.isArray(input.tags) ? input.tags : Array.isArray(original.tags) ? original.tags : [],
|
|
173
|
-
id: original.id,
|
|
174
|
-
webinyVersion: context.WEBINY_VERSION
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
try {
|
|
178
|
-
await (0, _lifecycleEvents.runLifecycleEvent)("beforeUpdate", {
|
|
179
|
-
context,
|
|
180
|
-
plugins: filePlugins,
|
|
181
|
-
original,
|
|
182
|
-
data: file
|
|
183
|
-
});
|
|
184
|
-
const result = await storageOperations.update({
|
|
185
|
-
original,
|
|
186
|
-
file
|
|
187
|
-
});
|
|
188
|
-
await (0, _lifecycleEvents.runLifecycleEvent)("afterUpdate", {
|
|
189
|
-
context,
|
|
190
|
-
plugins: filePlugins,
|
|
191
|
-
original,
|
|
192
|
-
data: file,
|
|
193
|
-
file: result
|
|
194
|
-
});
|
|
195
|
-
return result;
|
|
196
|
-
} catch (ex) {
|
|
197
|
-
throw new _error.default(ex.message || "Could not update a file.", ex.code || "UPDATE_FILE_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
|
|
198
|
-
original,
|
|
199
|
-
file
|
|
200
|
-
}));
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
async deleteFile(id) {
|
|
205
|
-
const permission = await (0, _checkBasePermissions.default)(context, {
|
|
206
|
-
rwd: "d"
|
|
207
|
-
});
|
|
208
|
-
const file = await storageOperations.get({
|
|
209
|
-
where: {
|
|
210
|
-
id,
|
|
211
|
-
tenant: context.tenancy.getCurrentTenant().id,
|
|
212
|
-
locale: getLocaleCode(context)
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
if (!file) {
|
|
217
|
-
throw new _handlerGraphql.NotFoundError(`File with id "${id}" does not exists.`);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
checkOwnership(file, permission, context);
|
|
221
|
-
|
|
222
|
-
try {
|
|
223
|
-
await (0, _lifecycleEvents.runLifecycleEvent)("beforeDelete", {
|
|
224
|
-
context,
|
|
225
|
-
plugins: filePlugins,
|
|
226
|
-
file
|
|
227
|
-
});
|
|
228
|
-
await storageOperations.delete({
|
|
229
|
-
file
|
|
230
|
-
});
|
|
231
|
-
await (0, _lifecycleEvents.runLifecycleEvent)("afterDelete", {
|
|
232
|
-
context,
|
|
233
|
-
plugins: filePlugins,
|
|
234
|
-
file
|
|
235
|
-
});
|
|
236
|
-
} catch (ex) {
|
|
237
|
-
throw new _error.default(ex.message || "Could not delete a file.", ex.code || "DELETE_FILE_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
|
|
238
|
-
id,
|
|
239
|
-
file
|
|
240
|
-
}));
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return true;
|
|
244
|
-
},
|
|
245
|
-
|
|
246
|
-
async createFilesInBatch(inputs) {
|
|
247
|
-
if (!Array.isArray(inputs)) {
|
|
248
|
-
throw new _error.default(`"data" must be an array.`, "CREATE_FILES_NON_ARRAY");
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (inputs.length === 0) {
|
|
252
|
-
throw new _error.default(`"data" argument must contain at least one file.`, "CREATE_FILES_MIN_FILES");
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (inputs.length > BATCH_CREATE_MAX_FILES) {
|
|
256
|
-
throw new _error.default(`"data" argument must not contain more than ${BATCH_CREATE_MAX_FILES} files.`, "CREATE_FILES_MAX_FILES");
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
await (0, _checkBasePermissions.default)(context, {
|
|
260
|
-
rwd: "w"
|
|
261
|
-
});
|
|
262
|
-
const identity = context.security.getIdentity();
|
|
263
|
-
const tenant = context.tenancy.getCurrentTenant();
|
|
264
|
-
const createdBy = {
|
|
265
|
-
id: identity.id,
|
|
266
|
-
displayName: identity.displayName,
|
|
267
|
-
type: identity.type
|
|
268
|
-
};
|
|
269
|
-
const files = inputs.map(input => {
|
|
270
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
|
|
271
|
-
tags: Array.isArray(input.tags) ? input.tags : [],
|
|
272
|
-
meta: (0, _objectSpread2.default)({
|
|
273
|
-
private: false
|
|
274
|
-
}, input.meta || {}),
|
|
275
|
-
id: (0, _mdbid.default)(),
|
|
276
|
-
tenant: tenant.id,
|
|
277
|
-
createdOn: new Date().toISOString(),
|
|
278
|
-
createdBy,
|
|
279
|
-
locale: getLocaleCode(context),
|
|
280
|
-
webinyVersion: context.WEBINY_VERSION
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
try {
|
|
285
|
-
await (0, _lifecycleEvents.runLifecycleEvent)("beforeBatchCreate", {
|
|
286
|
-
context,
|
|
287
|
-
plugins: filePlugins,
|
|
288
|
-
data: files
|
|
289
|
-
});
|
|
290
|
-
const results = await storageOperations.createBatch({
|
|
291
|
-
files
|
|
292
|
-
});
|
|
293
|
-
await (0, _lifecycleEvents.runLifecycleEvent)("afterBatchCreate", {
|
|
294
|
-
context,
|
|
295
|
-
plugins: filePlugins,
|
|
296
|
-
data: files,
|
|
297
|
-
files: results
|
|
298
|
-
});
|
|
299
|
-
return results;
|
|
300
|
-
} catch (ex) {
|
|
301
|
-
throw new _error.default(ex.message || "Could not create a batch of files.", ex.code || "CREATE_FILES_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
|
|
302
|
-
files
|
|
303
|
-
}));
|
|
304
|
-
}
|
|
305
|
-
},
|
|
306
|
-
|
|
307
|
-
async listFiles(params = {}) {
|
|
308
|
-
const permission = await (0, _checkBasePermissions.default)(context, {
|
|
309
|
-
rwd: "r"
|
|
310
|
-
});
|
|
311
|
-
const {
|
|
312
|
-
limit = 40,
|
|
313
|
-
search = "",
|
|
314
|
-
types = [],
|
|
315
|
-
tags = [],
|
|
316
|
-
ids = [],
|
|
317
|
-
after = null,
|
|
318
|
-
where: initialWhere,
|
|
319
|
-
sort: initialSort
|
|
320
|
-
} = params;
|
|
321
|
-
const where = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, initialWhere), {}, {
|
|
322
|
-
private: false,
|
|
323
|
-
locale: getLocaleCode(context),
|
|
324
|
-
tenant: context.tenancy.getCurrentTenant().id
|
|
325
|
-
});
|
|
326
|
-
/**
|
|
327
|
-
* Always override the createdBy received from the user, if any.
|
|
328
|
-
*/
|
|
329
|
-
|
|
330
|
-
if (permission.own === true) {
|
|
331
|
-
const identity = context.security.getIdentity();
|
|
332
|
-
where.createdBy = identity.id;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* We need to map the old GraphQL definition to the new one.
|
|
336
|
-
* That GQL definition is marked as deprecated.
|
|
337
|
-
*/
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* To have standardized where objects across the applications, we transform the types into type_in.
|
|
341
|
-
*/
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if (Array.isArray(types) && types.length > 0 && !where.type_in) {
|
|
345
|
-
where.type_in = types;
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* We are assigning search to tag and name search.
|
|
349
|
-
* This should be treated as OR condition in the storage operations.
|
|
350
|
-
*/
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
if (search && !where.search) {
|
|
354
|
-
where.search = search;
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Same as on types/type_in.
|
|
358
|
-
*/
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
if (Array.isArray(tags) && tags.length > 0 && !where.tag_in) {
|
|
362
|
-
where.tag_in = tags.map(tag => tag.toLowerCase());
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Same as on types/type_in.
|
|
366
|
-
*/
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
if (Array.isArray(ids) && ids.length > 0 && !where.id_in) {
|
|
370
|
-
where.id_in = ids;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
const sort = Array.isArray(initialSort) && initialSort.length > 0 ? initialSort : ["id_DESC"];
|
|
374
|
-
|
|
375
|
-
try {
|
|
376
|
-
return await storageOperations.list({
|
|
377
|
-
where,
|
|
378
|
-
after,
|
|
379
|
-
limit,
|
|
380
|
-
sort
|
|
381
|
-
});
|
|
382
|
-
} catch (ex) {
|
|
383
|
-
throw new _error.default(ex.message || "Could not list files by given parameters.", ex.code || "FILE_TAG_SEARCH_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
|
|
384
|
-
where,
|
|
385
|
-
after,
|
|
386
|
-
limit,
|
|
387
|
-
sort
|
|
388
|
-
}));
|
|
389
|
-
}
|
|
390
|
-
},
|
|
391
|
-
|
|
392
|
-
async listTags({
|
|
393
|
-
where: initialWhere,
|
|
394
|
-
after,
|
|
395
|
-
limit
|
|
396
|
-
}) {
|
|
397
|
-
await (0, _checkBasePermissions.default)(context);
|
|
398
|
-
const where = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, initialWhere), {}, {
|
|
399
|
-
tenant: context.tenancy.getCurrentTenant().id,
|
|
400
|
-
locale: getLocaleCode(context)
|
|
401
|
-
});
|
|
402
|
-
const params = {
|
|
403
|
-
where,
|
|
404
|
-
limit: limit || 100000,
|
|
405
|
-
after
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
try {
|
|
409
|
-
const [tags] = await storageOperations.tags(params);
|
|
410
|
-
|
|
411
|
-
if (Array.isArray(tags) === false) {
|
|
412
|
-
return [];
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* just to keep it standardized, sort by the tag ASC
|
|
416
|
-
*/
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
return tags.sort();
|
|
420
|
-
} catch (ex) {
|
|
421
|
-
throw new _error.default(ex.message || "Could not search for tags.", ex.code || "FILE_TAG_SEARCH_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, ex.data || {}), {}, {
|
|
422
|
-
params
|
|
423
|
-
}));
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
};
|
|
428
|
-
});
|
|
429
|
-
filesContextCrudPlugin.name = "FileManagerFilesCrud";
|
|
430
|
-
var _default = filesContextCrudPlugin;
|
|
431
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["BATCH_CREATE_MAX_FILES","checkOwnership","file","permission","context","own","identity","security","getIdentity","createdBy","id","NotAuthorizedError","getLocaleCode","i18n","WebinyError","locale","getContentLocale","code","filesContextCrudPlugin","ContextPlugin","pluginType","FilesStorageOperationsProviderPlugin","type","providerPlugin","plugins","byType","find","storageOperations","provide","fileManager","filePlugins","FilePlugin","files","getFile","checkBasePermissions","rwd","get","where","tenant","tenancy","getCurrentTenant","NotFoundError","createFile","input","mdbid","tags","Array","isArray","meta","private","createdOn","Date","toISOString","displayName","webinyVersion","WEBINY_VERSION","runLifecycleEvent","data","result","create","ex","message","updateFile","original","update","deleteFile","delete","createFilesInBatch","inputs","length","map","results","createBatch","listFiles","params","limit","search","types","ids","after","initialWhere","sort","initialSort","type_in","tag_in","tag","toLowerCase","id_in","list","listTags","name"],"sources":["files.crud.ts"],"sourcesContent":["/**\n * Package mdbid does not have types.\n */\n// @ts-ignore\nimport mdbid from \"mdbid\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport {\n CreatedBy,\n File,\n FileManagerContext,\n FileManagerFilesStorageOperationsListParamsWhere,\n FileManagerFilesStorageOperationsTagsParamsWhere,\n FilePermission,\n FilesListOpts\n} from \"~/types\";\nimport checkBasePermissions from \"./utils/checkBasePermissions\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { FilePlugin } from \"~/plugins/definitions/FilePlugin\";\nimport { FilesStorageOperationsProviderPlugin } from \"~/plugins/definitions/FilesStorageOperationsProviderPlugin\";\nimport WebinyError from \"@webiny/error\";\nimport { runLifecycleEvent } from \"~/plugins/crud/utils/lifecycleEvents\";\n\nconst BATCH_CREATE_MAX_FILES = 20;\n\n/**\n * If permission is limited to \"own\" files only, check that current identity owns the file.\n */\nconst checkOwnership = (file: File, permission: FilePermission, context: FileManagerContext) => {\n if (permission?.own === true) {\n const identity = context.security.getIdentity();\n if (file.createdBy.id !== identity.id) {\n throw new NotAuthorizedError();\n }\n }\n};\n\nconst getLocaleCode = (context: FileManagerContext): string => {\n if (!context.i18n) {\n throw new WebinyError(\"Missing i18n on the FileManagerContext.\", \"MISSING_I18N\");\n }\n\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale on the FileManagerContext.\",\n \"MISSING_I18N_CONTENT_LOCALE\"\n );\n }\n\n if (!locale.code) {\n throw new WebinyError(\n \"Missing content locale code on the FileManagerContext.\",\n \"MISSING_I18N_CONTENT_LOCALE_CODE\"\n );\n }\n return locale.code;\n};\n\nconst filesContextCrudPlugin = new ContextPlugin<FileManagerContext>(async context => {\n const pluginType = FilesStorageOperationsProviderPlugin.type;\n\n const providerPlugin = context.plugins\n .byType<FilesStorageOperationsProviderPlugin>(pluginType)\n .find(() => true);\n\n if (!providerPlugin) {\n throw new WebinyError(`Missing \"${pluginType}\" plugin.`, \"PLUGIN_NOT_FOUND\", {\n type: pluginType\n });\n }\n\n const storageOperations = await providerPlugin.provide({\n context\n });\n\n if (!context.fileManager) {\n context.fileManager = {} as any;\n }\n\n const filePlugins = context.plugins.byType<FilePlugin>(FilePlugin.type);\n\n context.fileManager.files = {\n async getFile(id: string) {\n const permission = await checkBasePermissions(context, { rwd: \"r\" });\n\n const file = await storageOperations.get({\n where: {\n id,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: getLocaleCode(context)\n }\n });\n\n if (!file) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n checkOwnership(file, permission, context);\n\n return file;\n },\n async createFile(input) {\n await checkBasePermissions(context, { rwd: \"w\" });\n const identity = context.security.getIdentity();\n const tenant = context.tenancy.getCurrentTenant();\n\n const id = mdbid();\n\n const file: File = {\n ...input,\n tags: Array.isArray(input.tags) ? input.tags : [],\n id,\n meta: {\n private: false,\n ...(input.meta || {})\n },\n tenant: tenant.id,\n createdOn: new Date().toISOString(),\n createdBy: {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n },\n locale: getLocaleCode(context),\n webinyVersion: context.WEBINY_VERSION\n };\n\n try {\n await runLifecycleEvent(\"beforeCreate\", {\n context,\n plugins: filePlugins,\n data: file\n });\n const result = await storageOperations.create({\n file\n });\n await runLifecycleEvent(\"afterCreate\", {\n context,\n plugins: filePlugins,\n data: file,\n file: result\n });\n return result;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create a file.\",\n ex.code || \"CREATE_FILE_ERROR\",\n {\n ...(ex.data || {}),\n file\n }\n );\n }\n },\n async updateFile(id, input) {\n const permission = await checkBasePermissions(context, { rwd: \"w\" });\n\n const original = await storageOperations.get({\n where: {\n id,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: getLocaleCode(context)\n }\n });\n\n if (!original) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n checkOwnership(original, permission, context);\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 id: original.id,\n webinyVersion: context.WEBINY_VERSION\n };\n\n try {\n await runLifecycleEvent(\"beforeUpdate\", {\n context,\n plugins: filePlugins,\n original,\n data: file\n });\n const result = await storageOperations.update({\n original,\n file\n });\n await runLifecycleEvent(\"afterUpdate\", {\n context,\n plugins: filePlugins,\n original,\n data: file,\n file: result\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 const permission = await checkBasePermissions(context, { rwd: \"d\" });\n\n const file = await storageOperations.get({\n where: {\n id,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: getLocaleCode(context)\n }\n });\n if (!file) {\n throw new NotFoundError(`File with id \"${id}\" does not exists.`);\n }\n\n checkOwnership(file, permission, context);\n\n try {\n await runLifecycleEvent(\"beforeDelete\", {\n context,\n plugins: filePlugins,\n file\n });\n await storageOperations.delete({\n file\n });\n await runLifecycleEvent(\"afterDelete\", {\n context,\n plugins: filePlugins,\n file\n });\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) {\n if (!Array.isArray(inputs)) {\n throw new WebinyError(`\"data\" must be an array.`, \"CREATE_FILES_NON_ARRAY\");\n }\n\n if (inputs.length === 0) {\n throw new WebinyError(\n `\"data\" argument must contain at least one file.`,\n \"CREATE_FILES_MIN_FILES\"\n );\n }\n\n if (inputs.length > BATCH_CREATE_MAX_FILES) {\n throw new WebinyError(\n `\"data\" argument must not contain more than ${BATCH_CREATE_MAX_FILES} files.`,\n \"CREATE_FILES_MAX_FILES\"\n );\n }\n\n await checkBasePermissions(context, { rwd: \"w\" });\n\n const identity = context.security.getIdentity();\n const tenant = context.tenancy.getCurrentTenant();\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 meta: {\n private: false,\n ...(input.meta || {})\n },\n id: mdbid(),\n tenant: tenant.id,\n createdOn: new Date().toISOString(),\n createdBy,\n locale: getLocaleCode(context),\n webinyVersion: context.WEBINY_VERSION\n };\n });\n\n try {\n await runLifecycleEvent(\"beforeBatchCreate\", {\n context,\n plugins: filePlugins,\n data: files\n });\n const results = await storageOperations.createBatch({\n files\n });\n await runLifecycleEvent(\"afterBatchCreate\", {\n context,\n plugins: filePlugins,\n data: files,\n files: results\n });\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 const permission = await checkBasePermissions(context, { rwd: \"r\" });\n\n const {\n limit = 40,\n search = \"\",\n types = [],\n tags = [],\n ids = [],\n after = null,\n where: initialWhere,\n sort: initialSort\n } = params;\n\n const where: FileManagerFilesStorageOperationsListParamsWhere = {\n ...initialWhere,\n private: false,\n locale: getLocaleCode(context),\n tenant: context.tenancy.getCurrentTenant().id\n };\n /**\n * Always override the createdBy received from the user, if any.\n */\n if (permission.own === true) {\n const identity = context.security.getIdentity();\n where.createdBy = identity.id;\n }\n /**\n * We need to map the old GraphQL definition to the new one.\n * That GQL definition is marked as deprecated.\n */\n /**\n * To have standardized where objects across the applications, we transform the types into type_in.\n */\n if (Array.isArray(types) && types.length > 0 && !where.type_in) {\n where.type_in = types;\n }\n /**\n * We are assigning search to tag and name search.\n * This should be treated as OR condition in the storage operations.\n */\n if (search && !where.search) {\n where.search = search;\n }\n /**\n * Same as on types/type_in.\n */\n if (Array.isArray(tags) && tags.length > 0 && !where.tag_in) {\n where.tag_in = tags.map(tag => tag.toLowerCase());\n }\n /**\n * Same as on types/type_in.\n */\n if (Array.isArray(ids) && ids.length > 0 && !where.id_in) {\n where.id_in = ids;\n }\n\n const sort =\n Array.isArray(initialSort) && initialSort.length > 0 ? initialSort : [\"id_DESC\"];\n try {\n return await storageOperations.list({\n where,\n after,\n limit,\n sort\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 checkBasePermissions(context);\n\n const where: FileManagerFilesStorageOperationsTagsParamsWhere = {\n ...initialWhere,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: getLocaleCode(context)\n };\n\n const params = {\n where,\n limit: limit || 100000,\n after\n };\n\n try {\n const [tags] = await storageOperations.tags(params);\n if (Array.isArray(tags) === false) {\n return [];\n }\n /**\n * just to keep it standardized, sort by the tag ASC\n */\n return tags.sort();\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\nfilesContextCrudPlugin.name = \"FileManagerF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H,aAAa,CAACR,OAAD;MAHoC,EAA7D;MAMA,MAAMsE,MAAM,GAAG;QACXrC,KADW;QAEXsC,KAAK,EAAEA,KAAK,IAAI,MAFL;QAGXI;MAHW,CAAf;;MAMA,IAAI;QACA,MAAM,CAAClC,IAAD,IAAS,MAAMlB,iBAAiB,CAACkB,IAAlB,CAAuB6B,MAAvB,CAArB;;QACA,IAAI5B,KAAK,CAACC,OAAN,CAAcF,IAAd,MAAwB,KAA5B,EAAmC;UAC/B,OAAO,EAAP;QACH;QACD;AAChB;AACA;;;QACgB,OAAOA,IAAI,CAACoC,IAAL,EAAP;MACH,CATD,CASE,OAAOrB,EAAP,EAAW;QACT,MAAM,IAAI9C,cAAJ,CACF8C,EAAE,CAACC,OAAH,IAAc,4BADZ,EAEFD,EAAE,CAAC3C,IAAH,IAAW,uBAFT,8DAIM2C,EAAE,CAACH,IAAH,IAAW,EAJjB;UAKEiB;QALF,GAAN;MAQH;IACJ;;EA5WuB,CAA5B;AA8WH,CArY8B,CAA/B;AAuYAxD,sBAAsB,CAACwE,IAAvB,GAA8B,sBAA9B;eAEexE,sB"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { FileManagerContext } from "../../types";
|
|
2
|
-
import { ContextPlugin } from "@webiny/api";
|
|
3
|
-
export declare const SETTINGS_KEY = "file-manager";
|
|
4
|
-
declare const settingsCrudContextPlugin: ContextPlugin<FileManagerContext>;
|
|
5
|
-
export default settingsCrudContextPlugin;
|