@webiny/api-file-manager 0.0.0-mt-3 → 0.0.0-unstable.085ff6572f
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.d.ts +3 -0
- package/createFileManager/files.crud.js +300 -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 +15 -0
- package/createFileManager/index.js +20 -0
- package/createFileManager/index.js.map +1 -0
- 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.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/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 +3 -0
- package/graphql/index.js +33 -0
- package/graphql/index.js.map +1 -0
- package/graphql/utils.d.ts +11 -0
- package/graphql/utils.js +22 -0
- package/graphql/utils.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 +60 -0
- package/handlers/download/getS3Object.js.map +1 -0
- package/handlers/download/index.d.ts +2 -3
- package/handlers/download/index.js +20 -118
- package/handlers/download/index.js.map +1 -0
- package/handlers/manage/index.d.ts +5 -3
- package/handlers/manage/index.js +43 -58
- package/handlers/manage/index.js.map +1 -0
- package/handlers/transform/index.d.ts +2 -3
- package/handlers/transform/index.js +71 -78
- package/handlers/transform/index.js.map +1 -0
- 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 +26 -9
- package/handlers/transform/loaders/imageLoader.js +13 -25
- package/handlers/transform/loaders/imageLoader.js.map +1 -0
- package/handlers/transform/loaders/index.d.ts +4 -9
- package/handlers/transform/loaders/index.js +1 -4
- package/handlers/transform/loaders/index.js.map +1 -0
- package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +7 -3
- package/handlers/transform/loaders/sanitizeImageTransformations.js +24 -30
- package/handlers/transform/loaders/sanitizeImageTransformations.js.map +1 -0
- package/handlers/transform/managers/imageManager.d.ts +12 -6
- package/handlers/transform/managers/imageManager.js +46 -27
- package/handlers/transform/managers/imageManager.js.map +1 -0
- package/handlers/transform/managers/index.d.ts +2 -6
- package/handlers/transform/managers/index.js +1 -4
- package/handlers/transform/managers/index.js.map +1 -0
- package/handlers/transform/optimizeImage.d.ts +2 -1
- package/handlers/transform/optimizeImage.js +4 -7
- package/handlers/transform/optimizeImage.js.map +1 -0
- package/handlers/transform/transformImage.d.ts +5 -4
- package/handlers/transform/transformImage.js +4 -9
- package/handlers/transform/transformImage.js.map +1 -0
- package/handlers/transform/utils.d.ts +2 -2
- package/handlers/transform/utils.js +8 -18
- package/handlers/transform/utils.js.map +1 -0
- package/handlers/types.d.ts +8 -0
- package/handlers/types.js +5 -0
- package/handlers/types.js.map +1 -0
- package/handlers/utils/getEnvironment.js +0 -2
- package/handlers/utils/getEnvironment.js.map +1 -0
- package/handlers/utils/getObjectParams.d.ts +3 -4
- package/handlers/utils/getObjectParams.js +1 -7
- package/handlers/utils/getObjectParams.js.map +1 -0
- package/handlers/utils/index.d.ts +0 -1
- package/handlers/utils/index.js +1 -12
- package/handlers/utils/index.js.map +1 -0
- package/index.d.ts +7 -0
- package/index.js +52 -0
- package/index.js.map +1 -0
- package/modelModifier/CmsModelModifier.d.ts +24 -0
- package/modelModifier/CmsModelModifier.js +59 -0
- package/modelModifier/CmsModelModifier.js.map +1 -0
- package/package.json +32 -32
- package/plugins/FilePhysicalStoragePlugin.d.ts +21 -0
- package/plugins/{definitions/FilePhysicalStoragePlugin.js → FilePhysicalStoragePlugin.js} +1 -12
- package/plugins/FilePhysicalStoragePlugin.js.map +1 -0
- package/plugins/{definitions/FileStorageTransformPlugin.d.ts → FileStorageTransformPlugin.d.ts} +10 -10
- package/plugins/{definitions/FileStorageTransformPlugin.js → FileStorageTransformPlugin.js} +2 -13
- 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 -0
- 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 +37 -0
- package/types/file.js +5 -0
- package/types/file.js.map +1 -0
- package/types/file.lifecycle.d.ts +44 -0
- package/types/file.lifecycle.js +5 -0
- package/types/file.lifecycle.js.map +1 -0
- package/types.d.ts +76 -83
- package/types.js +22 -0
- package/types.js.map +1 -0
- package/handlers/utils/createHandler.d.ts +0 -24
- package/handlers/utils/createHandler.js +0 -68
- package/plugins/crud/files/validation.d.ts +0 -3
- package/plugins/crud/files/validation.js +0 -41
- package/plugins/crud/files.crud.d.ts +0 -4
- package/plugins/crud/files.crud.js +0 -427
- package/plugins/crud/settings.crud.d.ts +0 -5
- package/plugins/crud/settings.crud.js +0 -115
- package/plugins/crud/system.crud.d.ts +0 -4
- package/plugins/crud/system.crud.js +0 -145
- package/plugins/crud/utils/checkBasePermissions.d.ts +0 -5
- package/plugins/crud/utils/checkBasePermissions.js +0 -33
- package/plugins/crud/utils/createFileModel.d.ts +0 -2
- package/plugins/crud/utils/createFileModel.js +0 -64
- package/plugins/crud/utils/lifecycleEvents.d.ts +0 -6
- package/plugins/crud/utils/lifecycleEvents.js +0 -33
- package/plugins/definitions/FilePhysicalStoragePlugin.d.ts +0 -22
- package/plugins/definitions/FilePlugin.d.ts +0 -133
- package/plugins/definitions/FilePlugin.js +0 -64
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/InstallationPlugin.d.ts +0 -19
- package/plugins/definitions/InstallationPlugin.js +0 -40
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +0 -17
- package/plugins/graphql.d.ts +0 -4
- package/plugins/graphql.js +0 -274
- package/plugins/storage/FileStorage.d.ts +0 -31
- package/plugins/storage/FileStorage.js +0 -95
- package/plugins/storage/index.d.ts +0 -4
- package/plugins/storage/index.js +0 -22
- package/utils.d.ts +0 -4
- package/utils.js +0 -16
package/types.d.ts
CHANGED
|
@@ -1,107 +1,92 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FileStorage } from "./
|
|
1
|
+
import { I18NContext } from "@webiny/api-i18n/types";
|
|
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
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
import { CmsContext } from "@webiny/api-headless-cms/types";
|
|
10
|
+
export * from "./types/file.lifecycle";
|
|
11
|
+
export * from "./types/file";
|
|
12
|
+
export interface FileManagerContextObject extends FilesCRUD, SettingsCRUD, SystemCRUD {
|
|
13
|
+
storage: FileStorage;
|
|
14
|
+
}
|
|
15
|
+
export interface FileManagerContext extends Context, SecurityContext, TenancyContext, I18NContext, CmsContext {
|
|
16
|
+
fileManager: FileManagerContextObject;
|
|
13
17
|
}
|
|
14
18
|
export interface FilePermission extends SecurityPermission {
|
|
15
19
|
name: "fm.file";
|
|
16
20
|
rwd?: string;
|
|
17
21
|
own?: boolean;
|
|
18
22
|
}
|
|
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;
|
|
43
|
-
type: string;
|
|
44
|
-
}
|
|
45
23
|
export interface FileInput {
|
|
24
|
+
id: string;
|
|
46
25
|
key: string;
|
|
47
26
|
name: string;
|
|
48
27
|
size: number;
|
|
49
28
|
type: string;
|
|
50
29
|
meta: Record<string, any>;
|
|
51
|
-
|
|
30
|
+
location?: {
|
|
31
|
+
folderId: string;
|
|
32
|
+
};
|
|
33
|
+
tags: string[];
|
|
34
|
+
aliases: string[];
|
|
35
|
+
extensions?: Record<string, any>;
|
|
52
36
|
}
|
|
53
37
|
export interface FileListWhereParams {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
tag?: string;
|
|
58
|
-
tag_in?: string[];
|
|
59
|
-
tag_and_in?: string[];
|
|
60
|
-
id_in?: string[];
|
|
61
|
-
id?: string;
|
|
38
|
+
AND?: FileListWhereParams[];
|
|
39
|
+
OR?: FileListWhereParams[];
|
|
40
|
+
[key: string]: any;
|
|
62
41
|
}
|
|
63
42
|
export interface FilesListOpts {
|
|
64
43
|
search?: string;
|
|
65
|
-
types?: string[];
|
|
66
|
-
tags?: string[];
|
|
67
|
-
ids?: string[];
|
|
68
44
|
limit?: number;
|
|
69
45
|
after?: string;
|
|
70
46
|
where?: FileListWhereParams;
|
|
71
47
|
sort?: string[];
|
|
72
48
|
}
|
|
73
49
|
export interface FileListMeta {
|
|
74
|
-
cursor: string;
|
|
50
|
+
cursor: string | null;
|
|
75
51
|
totalCount: number;
|
|
52
|
+
hasMoreItems: boolean;
|
|
76
53
|
}
|
|
77
54
|
interface FilesCrudListTagsWhere {
|
|
78
55
|
tag?: string;
|
|
79
56
|
tag_contains?: string;
|
|
80
57
|
tag_in?: string[];
|
|
58
|
+
tag_not_startsWith?: string;
|
|
59
|
+
tag_startsWith?: string;
|
|
81
60
|
}
|
|
82
61
|
interface FilesCrudListTagsParams {
|
|
83
62
|
where?: FilesCrudListTagsWhere;
|
|
84
63
|
limit?: number;
|
|
85
64
|
after?: string;
|
|
86
65
|
}
|
|
87
|
-
export interface
|
|
66
|
+
export interface ListTagsResponse {
|
|
67
|
+
tag: string;
|
|
68
|
+
count: number;
|
|
69
|
+
}
|
|
70
|
+
export interface FilesCRUD extends FileLifecycleEvents {
|
|
88
71
|
getFile(id: string): Promise<File>;
|
|
89
72
|
listFiles(opts?: FilesListOpts): Promise<[File[], FileListMeta]>;
|
|
90
|
-
listTags(params: FilesCrudListTagsParams): Promise<
|
|
91
|
-
createFile(data: FileInput): Promise<File>;
|
|
73
|
+
listTags(params: FilesCrudListTagsParams): Promise<ListTagsResponse[]>;
|
|
74
|
+
createFile(data: FileInput, meta?: Record<string, any>): Promise<File>;
|
|
92
75
|
updateFile(id: string, data: Partial<FileInput>): Promise<File>;
|
|
93
76
|
deleteFile(id: string): Promise<boolean>;
|
|
94
|
-
createFilesInBatch(data: FileInput[]): Promise<File[]>;
|
|
77
|
+
createFilesInBatch(data: FileInput[], meta?: Record<string, any>): Promise<File[]>;
|
|
95
78
|
}
|
|
96
79
|
export interface SystemCRUD {
|
|
97
|
-
|
|
80
|
+
onSystemBeforeInstall: Topic;
|
|
81
|
+
onSystemAfterInstall: Topic;
|
|
82
|
+
getVersion(): Promise<string | null>;
|
|
98
83
|
setVersion(version: string): Promise<void>;
|
|
99
84
|
install(args: {
|
|
100
85
|
srcPrefix: string;
|
|
101
86
|
}): Promise<boolean>;
|
|
102
|
-
upgrade(version: string, data?: Record<string, any>): Promise<boolean>;
|
|
103
87
|
}
|
|
104
88
|
export interface FileManagerSettings {
|
|
89
|
+
tenant: string;
|
|
105
90
|
key: string;
|
|
106
91
|
uploadMinFileSize: number;
|
|
107
92
|
uploadMaxFileSize: number;
|
|
@@ -109,9 +94,10 @@ export interface FileManagerSettings {
|
|
|
109
94
|
}
|
|
110
95
|
export interface FileManagerSystem {
|
|
111
96
|
version: string;
|
|
97
|
+
tenant: string;
|
|
112
98
|
}
|
|
113
99
|
export declare type SettingsCRUD = {
|
|
114
|
-
getSettings(): Promise<FileManagerSettings>;
|
|
100
|
+
getSettings(): Promise<FileManagerSettings | null>;
|
|
115
101
|
createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
|
|
116
102
|
updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
|
|
117
103
|
deleteSettings(): Promise<boolean>;
|
|
@@ -145,6 +131,9 @@ export interface FileManagerSystemStorageOperationsCreateParams {
|
|
|
145
131
|
*/
|
|
146
132
|
data: FileManagerSystem;
|
|
147
133
|
}
|
|
134
|
+
export interface FileManagerSystemStorageOperationsGetParams {
|
|
135
|
+
tenant: string;
|
|
136
|
+
}
|
|
148
137
|
/**
|
|
149
138
|
* @category StorageOperations
|
|
150
139
|
* @category SystemStorageOperations
|
|
@@ -153,7 +142,7 @@ export interface FileManagerSystemStorageOperations {
|
|
|
153
142
|
/**
|
|
154
143
|
* Get the FileManager system data.
|
|
155
144
|
*/
|
|
156
|
-
get: () => Promise<FileManagerSystem | null>;
|
|
145
|
+
get: (params: FileManagerSystemStorageOperationsGetParams) => Promise<FileManagerSystem | null>;
|
|
157
146
|
/**
|
|
158
147
|
* Update the FileManager system data..
|
|
159
148
|
*/
|
|
@@ -189,6 +178,12 @@ export interface FileManagerSettingsStorageOperationsCreateParams {
|
|
|
189
178
|
*/
|
|
190
179
|
data: FileManagerSettings;
|
|
191
180
|
}
|
|
181
|
+
export interface FileManagerStorageOperationsGetSettingsParams {
|
|
182
|
+
tenant: string;
|
|
183
|
+
}
|
|
184
|
+
export interface FileManagerStorageOperationsDeleteSettings {
|
|
185
|
+
tenant: string;
|
|
186
|
+
}
|
|
192
187
|
/**
|
|
193
188
|
* @category StorageOperations
|
|
194
189
|
* @category SettingsStorageOperations
|
|
@@ -197,7 +192,7 @@ export interface FileManagerSettingsStorageOperations {
|
|
|
197
192
|
/**
|
|
198
193
|
* Get the FileManager system data.
|
|
199
194
|
*/
|
|
200
|
-
get: () => Promise<FileManagerSettings | null>;
|
|
195
|
+
get: (params: FileManagerStorageOperationsGetSettingsParams) => Promise<FileManagerSettings | null>;
|
|
201
196
|
/**
|
|
202
197
|
* Create the FileManagerSettingsData
|
|
203
198
|
*/
|
|
@@ -209,7 +204,7 @@ export interface FileManagerSettingsStorageOperations {
|
|
|
209
204
|
/**
|
|
210
205
|
* Delete the existing settings.
|
|
211
206
|
*/
|
|
212
|
-
delete: () => Promise<void>;
|
|
207
|
+
delete: (params: FileManagerStorageOperationsDeleteSettings) => Promise<void>;
|
|
213
208
|
}
|
|
214
209
|
/**
|
|
215
210
|
* @category StorageOperations
|
|
@@ -262,20 +257,7 @@ export interface FileManagerFilesStorageOperationsCreateBatchParams {
|
|
|
262
257
|
* @category FilesStorageOperationsParams
|
|
263
258
|
*/
|
|
264
259
|
export interface FileManagerFilesStorageOperationsListParamsWhere {
|
|
265
|
-
|
|
266
|
-
id_in?: string[];
|
|
267
|
-
name?: string;
|
|
268
|
-
name_contains?: string;
|
|
269
|
-
tag?: string;
|
|
270
|
-
tag_contains?: string;
|
|
271
|
-
tag_in?: string[];
|
|
272
|
-
createdBy?: string;
|
|
273
|
-
locale: string;
|
|
274
|
-
tenant: string;
|
|
275
|
-
private?: boolean;
|
|
276
|
-
type?: string;
|
|
277
|
-
type_in?: string[];
|
|
278
|
-
search?: string;
|
|
260
|
+
[key: string]: any;
|
|
279
261
|
}
|
|
280
262
|
/**
|
|
281
263
|
* @category StorageOperations
|
|
@@ -287,25 +269,26 @@ export interface FileManagerFilesStorageOperationsListParams {
|
|
|
287
269
|
sort: string[];
|
|
288
270
|
limit: number;
|
|
289
271
|
after: string | null;
|
|
272
|
+
search?: string;
|
|
290
273
|
}
|
|
291
274
|
/**
|
|
292
275
|
* @category StorageOperations
|
|
293
276
|
* @category FilesStorageOperations
|
|
294
277
|
* @category FilesStorageOperationsParams
|
|
295
278
|
*/
|
|
296
|
-
interface FileManagerFilesStorageOperationsListResponseMeta {
|
|
279
|
+
export interface FileManagerFilesStorageOperationsListResponseMeta {
|
|
297
280
|
hasMoreItems: boolean;
|
|
298
281
|
totalCount: number;
|
|
299
|
-
cursor: string;
|
|
282
|
+
cursor: string | null;
|
|
300
283
|
}
|
|
301
284
|
export declare type FileManagerFilesStorageOperationsListResponse = [
|
|
302
285
|
File[],
|
|
303
286
|
FileManagerFilesStorageOperationsListResponseMeta
|
|
304
287
|
];
|
|
305
|
-
export
|
|
306
|
-
string
|
|
307
|
-
|
|
308
|
-
|
|
288
|
+
export interface FileManagerFilesStorageOperationsTagsResponse {
|
|
289
|
+
tag: string;
|
|
290
|
+
count: number;
|
|
291
|
+
}
|
|
309
292
|
export interface FileManagerFilesStorageOperationsTagsParamsWhere extends FilesCrudListTagsWhere {
|
|
310
293
|
locale: string;
|
|
311
294
|
tenant: string;
|
|
@@ -332,11 +315,11 @@ export interface FileManagerFilesStorageOperations {
|
|
|
332
315
|
/**
|
|
333
316
|
* Insert the file data into the database.
|
|
334
317
|
*/
|
|
335
|
-
create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File
|
|
318
|
+
create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File>;
|
|
336
319
|
/**
|
|
337
320
|
* Update the file data in the database.
|
|
338
321
|
*/
|
|
339
|
-
update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File
|
|
322
|
+
update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File>;
|
|
340
323
|
/**
|
|
341
324
|
* Delete the file from the database.
|
|
342
325
|
*/
|
|
@@ -352,6 +335,16 @@ export interface FileManagerFilesStorageOperations {
|
|
|
352
335
|
/**
|
|
353
336
|
* Get a list of all file tags filtered by given parameters.
|
|
354
337
|
*/
|
|
355
|
-
tags: (params: FileManagerFilesStorageOperationsTagsParams) => Promise<FileManagerFilesStorageOperationsTagsResponse>;
|
|
338
|
+
tags: (params: FileManagerFilesStorageOperationsTagsParams) => Promise<FileManagerFilesStorageOperationsTagsResponse[]>;
|
|
339
|
+
}
|
|
340
|
+
export interface FileManagerAliasesStorageOperations {
|
|
341
|
+
storeAliases(file: File): Promise<void>;
|
|
342
|
+
deleteAliases(file: File): Promise<void>;
|
|
343
|
+
}
|
|
344
|
+
export interface FileManagerStorageOperations<TContext = FileManagerContext> {
|
|
345
|
+
beforeInit?: (context: TContext) => Promise<void>;
|
|
346
|
+
files: FileManagerFilesStorageOperations;
|
|
347
|
+
aliases: FileManagerAliasesStorageOperations;
|
|
348
|
+
settings: FileManagerSettingsStorageOperations;
|
|
349
|
+
system: FileManagerSystemStorageOperations;
|
|
356
350
|
}
|
|
357
|
-
export {};
|
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
ADDED
|
@@ -0,0 +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\";\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
|
-
declare const _default: (handler: any) => (event: any) => Promise<{
|
|
2
|
-
body: string;
|
|
3
|
-
statusCode: number;
|
|
4
|
-
headers: {
|
|
5
|
-
"Cache-Control": string;
|
|
6
|
-
"Access-Control-Allow-Origin": string;
|
|
7
|
-
"Access-Control-Allow-Credentials": boolean;
|
|
8
|
-
};
|
|
9
|
-
isBase64Encoded?: undefined;
|
|
10
|
-
} | {
|
|
11
|
-
isBase64Encoded: boolean;
|
|
12
|
-
statusCode: any;
|
|
13
|
-
headers: any;
|
|
14
|
-
body: any;
|
|
15
|
-
} | {
|
|
16
|
-
statusCode: number;
|
|
17
|
-
headers: {
|
|
18
|
-
"Access-Control-Allow-Origin": string;
|
|
19
|
-
"Access-Control-Allow-Credentials": boolean;
|
|
20
|
-
};
|
|
21
|
-
body: string;
|
|
22
|
-
isBase64Encoded?: undefined;
|
|
23
|
-
}>;
|
|
24
|
-
export default _default;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* We need to respond with adequate CORS headers.
|
|
18
|
-
* @type {{"Access-Control-Allow-Origin": string, "Access-Control-Allow-Credentials": boolean}}
|
|
19
|
-
*/
|
|
20
|
-
const baseHeaders = {
|
|
21
|
-
"Access-Control-Allow-Origin": "*",
|
|
22
|
-
"Access-Control-Allow-Credentials": true
|
|
23
|
-
};
|
|
24
|
-
const DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year
|
|
25
|
-
|
|
26
|
-
var _default = handler => async event => {
|
|
27
|
-
if (event.httpMethod === "OPTIONS") {
|
|
28
|
-
return {
|
|
29
|
-
body: "",
|
|
30
|
-
statusCode: 204,
|
|
31
|
-
headers: _objectSpread(_objectSpread({}, baseHeaders), {}, {
|
|
32
|
-
"Cache-Control": "public, max-age=" + DEFAULT_CACHE_MAX_AGE
|
|
33
|
-
})
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
const {
|
|
39
|
-
data,
|
|
40
|
-
statusCode,
|
|
41
|
-
headers = {}
|
|
42
|
-
} = await handler(event);
|
|
43
|
-
const isBuffer = Buffer.isBuffer(data);
|
|
44
|
-
const body = isBuffer ? data.toString("base64") : JSON.stringify({
|
|
45
|
-
error: false,
|
|
46
|
-
data,
|
|
47
|
-
message: null
|
|
48
|
-
});
|
|
49
|
-
return {
|
|
50
|
-
isBase64Encoded: isBuffer,
|
|
51
|
-
statusCode: statusCode || 200,
|
|
52
|
-
headers: _objectSpread(_objectSpread({}, baseHeaders), headers),
|
|
53
|
-
body
|
|
54
|
-
};
|
|
55
|
-
} catch (e) {
|
|
56
|
-
return {
|
|
57
|
-
statusCode: 500,
|
|
58
|
-
headers: baseHeaders,
|
|
59
|
-
body: JSON.stringify({
|
|
60
|
-
error: true,
|
|
61
|
-
data: null,
|
|
62
|
-
message: e.message
|
|
63
|
-
})
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
exports.default = _default;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
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;
|