@webiny/api-file-manager 0.0.0-unstable.40876133bb → 0.0.0-unstable.496cf268ac
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/createFileManager/checkBasePermissions.d.ts +5 -0
- package/createFileManager/checkBasePermissions.js +24 -0
- package/createFileManager/checkBasePermissions.js.map +1 -0
- package/createFileManager/files.crud.d.ts +3 -0
- package/createFileManager/files.crud.js +325 -0
- package/createFileManager/files.crud.js.map +1 -0
- package/createFileManager/filevalidation.disabled.d.ts +0 -0
- package/createFileManager/filevalidation.disabled.js +55 -0
- package/createFileManager/filevalidation.disabled.js.map +1 -0
- package/createFileManager/index.d.ts +13 -0
- package/createFileManager/index.js +20 -0
- package/createFileManager/index.js.map +1 -0
- package/createFileManager/settings.crud.d.ts +3 -0
- package/createFileManager/settings.crud.js +91 -0
- package/createFileManager/settings.crud.js.map +1 -0
- package/createFileManager/system.crud.d.ts +3 -0
- package/createFileManager/system.crud.js +86 -0
- package/createFileManager/system.crud.js.map +1 -0
- package/graphql/index.d.ts +3 -0
- package/graphql/index.js +277 -0
- package/graphql/index.js.map +1 -0
- package/handlers/download/byAlias.d.ts +6 -0
- package/handlers/download/byAlias.js +89 -0
- package/handlers/download/byAlias.js.map +1 -0
- package/handlers/download/byExactKey.d.ts +2 -0
- package/handlers/download/byExactKey.js +57 -0
- package/handlers/download/byExactKey.js.map +1 -0
- package/handlers/download/extractFileInformation.d.ts +9 -0
- package/handlers/download/extractFileInformation.js +20 -0
- package/handlers/download/extractFileInformation.js.map +1 -0
- package/handlers/download/getS3Object.d.ts +10 -0
- package/handlers/download/getS3Object.js +57 -0
- package/handlers/download/getS3Object.js.map +1 -0
- package/handlers/download/index.d.ts +2 -3
- package/handlers/download/index.js +21 -126
- package/handlers/download/index.js.map +1 -1
- package/handlers/manage/index.js +0 -16
- package/handlers/manage/index.js.map +1 -1
- package/handlers/transform/index.js +19 -21
- package/handlers/transform/index.js.map +1 -1
- package/handlers/transform/legacyUtils.d.ts +17 -0
- package/handlers/transform/legacyUtils.js +42 -0
- package/handlers/transform/legacyUtils.js.map +1 -0
- package/handlers/transform/loaders/imageLoader.d.ts +1 -1
- package/handlers/transform/loaders/imageLoader.js +12 -23
- package/handlers/transform/loaders/imageLoader.js.map +1 -1
- package/handlers/transform/loaders/index.d.ts +1 -1
- package/handlers/transform/loaders/index.js +0 -3
- package/handlers/transform/loaders/index.js.map +1 -1
- package/handlers/transform/loaders/sanitizeImageTransformations.js +0 -13
- package/handlers/transform/loaders/sanitizeImageTransformations.js.map +1 -1
- package/handlers/transform/managers/imageManager.js +32 -21
- package/handlers/transform/managers/imageManager.js.map +1 -1
- package/handlers/transform/managers/index.js +0 -3
- package/handlers/transform/managers/index.js.map +1 -1
- package/handlers/transform/optimizeImage.js +0 -6
- package/handlers/transform/optimizeImage.js.map +1 -1
- package/handlers/transform/transformImage.js +0 -5
- package/handlers/transform/transformImage.js.map +1 -1
- package/handlers/transform/utils.d.ts +1 -1
- package/handlers/transform/utils.js +7 -17
- package/handlers/transform/utils.js.map +1 -1
- package/handlers/utils/getEnvironment.js +0 -2
- package/handlers/utils/getEnvironment.js.map +1 -1
- package/handlers/utils/getObjectParams.js +0 -4
- package/handlers/utils/getObjectParams.js.map +1 -1
- package/handlers/utils/index.js +0 -3
- package/handlers/utils/index.js.map +1 -1
- package/index.d.ts +6 -0
- package/index.js +68 -0
- package/index.js.map +1 -0
- package/package.json +21 -23
- package/plugins/FilePhysicalStoragePlugin.d.ts +21 -0
- package/plugins/FilePhysicalStoragePlugin.js +31 -0
- package/plugins/FilePhysicalStoragePlugin.js.map +1 -0
- package/plugins/FileStorageTransformPlugin.d.ts +34 -0
- package/plugins/FileStorageTransformPlugin.js +40 -0
- package/plugins/FileStorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +2 -2
- package/plugins/index.js +22 -19
- package/plugins/index.js.map +1 -1
- package/storage/FileStorage.d.ts +32 -0
- package/storage/FileStorage.js +86 -0
- package/storage/FileStorage.js.map +1 -0
- package/types/file.d.ts +33 -0
- package/types/file.js +5 -0
- package/types/file.js.map +1 -0
- package/types/file.lifecycle.d.ts +40 -0
- package/types/file.lifecycle.js +5 -0
- package/types/file.lifecycle.js.map +1 -0
- package/types.d.ts +34 -39
- package/types.js +22 -0
- package/types.js.map +1 -1
package/types.d.ts
CHANGED
|
@@ -1,54 +1,33 @@
|
|
|
1
1
|
import { I18NContext } from "@webiny/api-i18n/types";
|
|
2
|
-
import { FileStorage } from "./
|
|
2
|
+
import { FileStorage } from "./storage/FileStorage";
|
|
3
3
|
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
|
+
import { FileLifecycleEvents } from "./types/file.lifecycle";
|
|
7
|
+
import { File } from "./types/file";
|
|
8
|
+
import { Topic } from "@webiny/pubsub/types";
|
|
9
|
+
export * from "./types/file.lifecycle";
|
|
10
|
+
export * from "./types/file";
|
|
11
|
+
export interface FileManagerContextObject extends FilesCRUD, SettingsCRUD, SystemCRUD {
|
|
12
|
+
storage: FileStorage;
|
|
13
|
+
}
|
|
6
14
|
export interface FileManagerContext extends Context, SecurityContext, TenancyContext, I18NContext {
|
|
7
|
-
fileManager:
|
|
8
|
-
files: FilesCRUD;
|
|
9
|
-
settings: SettingsCRUD;
|
|
10
|
-
storage: FileStorage;
|
|
11
|
-
system: SystemCRUD;
|
|
12
|
-
};
|
|
15
|
+
fileManager: FileManagerContextObject;
|
|
13
16
|
}
|
|
14
17
|
export interface FilePermission extends SecurityPermission {
|
|
15
18
|
name: "fm.file";
|
|
16
19
|
rwd?: string;
|
|
17
20
|
own?: boolean;
|
|
18
21
|
}
|
|
19
|
-
export interface File {
|
|
20
|
-
id: string;
|
|
21
|
-
key: string;
|
|
22
|
-
size: number;
|
|
23
|
-
type: string;
|
|
24
|
-
name: string;
|
|
25
|
-
meta: Record<string, any>;
|
|
26
|
-
tags: string[];
|
|
27
|
-
createdOn: string;
|
|
28
|
-
createdBy: CreatedBy;
|
|
29
|
-
/**
|
|
30
|
-
* Added with new storage operations refactoring.
|
|
31
|
-
*/
|
|
32
|
-
tenant: string;
|
|
33
|
-
locale: string;
|
|
34
|
-
webinyVersion: string;
|
|
35
|
-
/**
|
|
36
|
-
* User can add new fields to the File object so we must allow it in the types.
|
|
37
|
-
*/
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
}
|
|
40
|
-
export interface CreatedBy {
|
|
41
|
-
id: string;
|
|
42
|
-
displayName: string | null;
|
|
43
|
-
type: string;
|
|
44
|
-
}
|
|
45
22
|
export interface FileInput {
|
|
23
|
+
id: string;
|
|
46
24
|
key: string;
|
|
47
25
|
name: string;
|
|
48
26
|
size: number;
|
|
49
27
|
type: string;
|
|
50
28
|
meta: Record<string, any>;
|
|
51
29
|
tags: string[];
|
|
30
|
+
aliases: string[];
|
|
52
31
|
}
|
|
53
32
|
export interface FileListWhereParams {
|
|
54
33
|
search?: string;
|
|
@@ -87,7 +66,7 @@ interface FilesCrudListTagsParams {
|
|
|
87
66
|
limit?: number;
|
|
88
67
|
after?: string;
|
|
89
68
|
}
|
|
90
|
-
export interface FilesCRUD {
|
|
69
|
+
export interface FilesCRUD extends FileLifecycleEvents {
|
|
91
70
|
getFile(id: string): Promise<File>;
|
|
92
71
|
listFiles(opts?: FilesListOpts): Promise<[File[], FileListMeta]>;
|
|
93
72
|
listTags(params: FilesCrudListTagsParams): Promise<string[]>;
|
|
@@ -97,14 +76,16 @@ export interface FilesCRUD {
|
|
|
97
76
|
createFilesInBatch(data: FileInput[]): Promise<File[]>;
|
|
98
77
|
}
|
|
99
78
|
export interface SystemCRUD {
|
|
79
|
+
onSystemBeforeInstall: Topic;
|
|
80
|
+
onSystemAfterInstall: Topic;
|
|
100
81
|
getVersion(): Promise<string | null>;
|
|
101
82
|
setVersion(version: string): Promise<void>;
|
|
102
83
|
install(args: {
|
|
103
84
|
srcPrefix: string;
|
|
104
85
|
}): Promise<boolean>;
|
|
105
|
-
upgrade(version: string, data?: Record<string, any>): Promise<boolean>;
|
|
106
86
|
}
|
|
107
87
|
export interface FileManagerSettings {
|
|
88
|
+
tenant: string;
|
|
108
89
|
key: string;
|
|
109
90
|
uploadMinFileSize: number;
|
|
110
91
|
uploadMaxFileSize: number;
|
|
@@ -149,6 +130,9 @@ export interface FileManagerSystemStorageOperationsCreateParams {
|
|
|
149
130
|
*/
|
|
150
131
|
data: FileManagerSystem;
|
|
151
132
|
}
|
|
133
|
+
export interface FileManagerSystemStorageOperationsGetParams {
|
|
134
|
+
tenant: string;
|
|
135
|
+
}
|
|
152
136
|
/**
|
|
153
137
|
* @category StorageOperations
|
|
154
138
|
* @category SystemStorageOperations
|
|
@@ -157,7 +141,7 @@ export interface FileManagerSystemStorageOperations {
|
|
|
157
141
|
/**
|
|
158
142
|
* Get the FileManager system data.
|
|
159
143
|
*/
|
|
160
|
-
get: () => Promise<FileManagerSystem | null>;
|
|
144
|
+
get: (params: FileManagerSystemStorageOperationsGetParams) => Promise<FileManagerSystem | null>;
|
|
161
145
|
/**
|
|
162
146
|
* Update the FileManager system data..
|
|
163
147
|
*/
|
|
@@ -193,6 +177,12 @@ export interface FileManagerSettingsStorageOperationsCreateParams {
|
|
|
193
177
|
*/
|
|
194
178
|
data: FileManagerSettings;
|
|
195
179
|
}
|
|
180
|
+
export interface FileManagerStorageOperationsGetSettingsParams {
|
|
181
|
+
tenant: string;
|
|
182
|
+
}
|
|
183
|
+
export interface FileManagerStorageOperationsDeleteSettings {
|
|
184
|
+
tenant: string;
|
|
185
|
+
}
|
|
196
186
|
/**
|
|
197
187
|
* @category StorageOperations
|
|
198
188
|
* @category SettingsStorageOperations
|
|
@@ -201,7 +191,7 @@ export interface FileManagerSettingsStorageOperations {
|
|
|
201
191
|
/**
|
|
202
192
|
* Get the FileManager system data.
|
|
203
193
|
*/
|
|
204
|
-
get: () => Promise<FileManagerSettings | null>;
|
|
194
|
+
get: (params: FileManagerStorageOperationsGetSettingsParams) => Promise<FileManagerSettings | null>;
|
|
205
195
|
/**
|
|
206
196
|
* Create the FileManagerSettingsData
|
|
207
197
|
*/
|
|
@@ -213,7 +203,7 @@ export interface FileManagerSettingsStorageOperations {
|
|
|
213
203
|
/**
|
|
214
204
|
* Delete the existing settings.
|
|
215
205
|
*/
|
|
216
|
-
delete: () => Promise<void>;
|
|
206
|
+
delete: (params: FileManagerStorageOperationsDeleteSettings) => Promise<void>;
|
|
217
207
|
}
|
|
218
208
|
/**
|
|
219
209
|
* @category StorageOperations
|
|
@@ -358,4 +348,9 @@ export interface FileManagerFilesStorageOperations {
|
|
|
358
348
|
*/
|
|
359
349
|
tags: (params: FileManagerFilesStorageOperationsTagsParams) => Promise<FileManagerFilesStorageOperationsTagsResponse>;
|
|
360
350
|
}
|
|
361
|
-
export {
|
|
351
|
+
export interface FileManagerStorageOperations<TContext = FileManagerContext> {
|
|
352
|
+
beforeInit?: (context: TContext) => Promise<void>;
|
|
353
|
+
files: FileManagerFilesStorageOperations;
|
|
354
|
+
settings: FileManagerSettingsStorageOperations;
|
|
355
|
+
system: FileManagerSystemStorageOperations;
|
|
356
|
+
}
|
package/types.js
CHANGED
|
@@ -2,4 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
+
});
|
|
6
|
+
var _file = require("./types/file.lifecycle");
|
|
7
|
+
Object.keys(_file).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _file[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _file[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _file2 = require("./types/file");
|
|
18
|
+
Object.keys(_file2).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _file2[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _file2[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
5
27
|
});
|
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 \"./plugins/storage/FileStorage\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { SecurityContext, SecurityPermission } from \"@webiny/api-security/types\";\nimport { Context } from \"@webiny/api/types\";\n\nexport interface FileManagerContext extends Context, SecurityContext, TenancyContext, I18NContext {\n fileManager: {\n files: FilesCRUD;\n settings: SettingsCRUD;\n storage: FileStorage;\n system: SystemCRUD;\n };\n}\n\nexport interface FilePermission extends SecurityPermission {\n name: \"fm.file\";\n rwd?: string;\n own?: boolean;\n}\n\nexport interface File {\n id: string;\n key: string;\n size: number;\n type: string;\n name: string;\n meta: Record<string, any>;\n tags: string[];\n createdOn: 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 CreatedBy {\n id: string;\n displayName: string | null;\n type: string;\n}\n\nexport interface FileInput {\n key: string;\n name: string;\n size: number;\n type: string;\n meta: Record<string, any>;\n tags: 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 {\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 getVersion(): Promise<string | null>;\n setVersion(version: string): Promise<void>;\n install(args: { srcPrefix: string }): Promise<boolean>;\n upgrade(version: string, data?: Record<string, any>): Promise<boolean>;\n}\n\nexport interface FileManagerSettings {\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\n/**\n * @category StorageOperations\n * @category SystemStorageOperations\n */\nexport interface FileManagerSystemStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: () => 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\n/**\n * @category StorageOperations\n * @category SettingsStorageOperations\n */\nexport interface FileManagerSettingsStorageOperations {\n /**\n * Get the FileManager system data.\n */\n get: () => 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: () => 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"],"mappings":""}
|
|
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"}
|