@webiny/api-file-manager 0.0.0-ee-vpcs.549378cf03
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/LICENSE +21 -0
- package/README.md +17 -0
- package/handlers/download/index.d.ts +3 -0
- package/handlers/download/index.js +132 -0
- package/handlers/download/index.js.map +1 -0
- package/handlers/manage/index.d.ts +5 -0
- package/handlers/manage/index.js +71 -0
- package/handlers/manage/index.js.map +1 -0
- package/handlers/transform/index.d.ts +2 -0
- package/handlers/transform/index.js +91 -0
- package/handlers/transform/index.js.map +1 -0
- package/handlers/transform/loaders/imageLoader.d.ts +30 -0
- package/handlers/transform/loaders/imageLoader.js +105 -0
- package/handlers/transform/loaders/imageLoader.js.map +1 -0
- package/handlers/transform/loaders/index.d.ts +8 -0
- package/handlers/transform/loaders/index.js +13 -0
- package/handlers/transform/loaders/index.js.map +1 -0
- package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +11 -0
- package/handlers/transform/loaders/sanitizeImageTransformations.js +58 -0
- package/handlers/transform/loaders/sanitizeImageTransformations.js.map +1 -0
- package/handlers/transform/managers/imageManager.d.ts +15 -0
- package/handlers/transform/managers/imageManager.js +63 -0
- package/handlers/transform/managers/imageManager.js.map +1 -0
- package/handlers/transform/managers/index.d.ts +5 -0
- package/handlers/transform/managers/index.js +13 -0
- package/handlers/transform/managers/index.js.map +1 -0
- package/handlers/transform/optimizeImage.d.ts +3 -0
- package/handlers/transform/optimizeImage.js +48 -0
- package/handlers/transform/optimizeImage.js.map +1 -0
- package/handlers/transform/transformImage.d.ts +10 -0
- package/handlers/transform/transformImage.js +30 -0
- package/handlers/transform/transformImage.js.map +1 -0
- package/handlers/transform/utils.d.ts +12 -0
- package/handlers/transform/utils.js +46 -0
- 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.d.ts +5 -0
- package/handlers/utils/getEnvironment.js +13 -0
- package/handlers/utils/getEnvironment.js.map +1 -0
- package/handlers/utils/getObjectParams.d.ts +9 -0
- package/handlers/utils/getObjectParams.js +25 -0
- package/handlers/utils/getObjectParams.js.map +1 -0
- package/handlers/utils/index.d.ts +2 -0
- package/handlers/utils/index.js +23 -0
- package/handlers/utils/index.js.map +1 -0
- package/package.json +76 -0
- package/plugins/crud/files/validation.d.ts +3 -0
- package/plugins/crud/files/validation.js +41 -0
- package/plugins/crud/files/validation.js.map +1 -0
- package/plugins/crud/files.crud.d.ts +4 -0
- package/plugins/crud/files.crud.js +431 -0
- package/plugins/crud/files.crud.js.map +1 -0
- package/plugins/crud/settings.crud.d.ts +5 -0
- package/plugins/crud/settings.crud.js +116 -0
- package/plugins/crud/settings.crud.js.map +1 -0
- package/plugins/crud/system.crud.d.ts +4 -0
- package/plugins/crud/system.crud.js +153 -0
- package/plugins/crud/system.crud.js.map +1 -0
- package/plugins/crud/utils/checkBasePermissions.d.ts +5 -0
- package/plugins/crud/utils/checkBasePermissions.js +33 -0
- package/plugins/crud/utils/checkBasePermissions.js.map +1 -0
- package/plugins/crud/utils/createFileModel.d.ts +5 -0
- package/plugins/crud/utils/createFileModel.js +77 -0
- package/plugins/crud/utils/createFileModel.js.map +1 -0
- package/plugins/crud/utils/lifecycleEvents.d.ts +6 -0
- package/plugins/crud/utils/lifecycleEvents.js +38 -0
- package/plugins/crud/utils/lifecycleEvents.js.map +1 -0
- package/plugins/definitions/FilePhysicalStoragePlugin.d.ts +21 -0
- package/plugins/definitions/FilePhysicalStoragePlugin.js +42 -0
- package/plugins/definitions/FilePhysicalStoragePlugin.js.map +1 -0
- package/plugins/definitions/FilePlugin.d.ts +136 -0
- package/plugins/definitions/FilePlugin.js +70 -0
- package/plugins/definitions/FilePlugin.js.map +1 -0
- package/plugins/definitions/FileStorageTransformPlugin.d.ts +34 -0
- package/plugins/definitions/FileStorageTransformPlugin.js +51 -0
- package/plugins/definitions/FileStorageTransformPlugin.js.map +1 -0
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +9 -0
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +17 -0
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +1 -0
- package/plugins/definitions/InstallationPlugin.d.ts +19 -0
- package/plugins/definitions/InstallationPlugin.js +42 -0
- package/plugins/definitions/InstallationPlugin.js.map +1 -0
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +9 -0
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +17 -0
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +1 -0
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +9 -0
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +17 -0
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +1 -0
- package/plugins/graphql.d.ts +4 -0
- package/plugins/graphql.js +290 -0
- package/plugins/graphql.js.map +1 -0
- package/plugins/index.d.ts +2 -0
- package/plugins/index.js +24 -0
- package/plugins/index.js.map +1 -0
- package/plugins/storage/FileStorage.d.ts +30 -0
- package/plugins/storage/FileStorage.js +103 -0
- package/plugins/storage/FileStorage.js.map +1 -0
- package/plugins/storage/index.d.ts +4 -0
- package/plugins/storage/index.js +26 -0
- package/plugins/storage/index.js.map +1 -0
- package/types.d.ts +361 -0
- package/types.js +5 -0
- package/types.js.map +1 -0
- package/utils.d.ts +4 -0
- package/utils.js +16 -0
- package/utils.js.map +1 -0
|
@@ -0,0 +1,103 @@
|
|
|
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.FileStorage = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
+
|
|
16
|
+
const storagePluginType = "api-file-manager-storage";
|
|
17
|
+
|
|
18
|
+
class FileStorage {
|
|
19
|
+
constructor({
|
|
20
|
+
context
|
|
21
|
+
}) {
|
|
22
|
+
(0, _defineProperty2.default)(this, "storagePlugin", void 0);
|
|
23
|
+
(0, _defineProperty2.default)(this, "context", void 0);
|
|
24
|
+
const storagePlugin = context.plugins.byType(storagePluginType).pop();
|
|
25
|
+
|
|
26
|
+
if (!storagePlugin) {
|
|
27
|
+
throw new _error.default(`Missing plugin of type "${storagePluginType}".`, "STORAGE_PLUGIN_ERROR");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.storagePlugin = storagePlugin;
|
|
31
|
+
this.context = context;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async upload(params) {
|
|
35
|
+
const settings = await this.context.fileManager.settings.getSettings();
|
|
36
|
+
|
|
37
|
+
if (!settings) {
|
|
38
|
+
throw new _error.default("Missing File Manager Settings.", "FILE_MANAGER_ERROR");
|
|
39
|
+
} // Add file to cloud storage.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const {
|
|
43
|
+
file: fileData
|
|
44
|
+
} = await this.storagePlugin.upload((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
45
|
+
settings
|
|
46
|
+
}));
|
|
47
|
+
const {
|
|
48
|
+
fileManager
|
|
49
|
+
} = this.context; // Save file in DB.
|
|
50
|
+
|
|
51
|
+
return await fileManager.files.createFile((0, _objectSpread2.default)((0, _objectSpread2.default)({}, fileData), {}, {
|
|
52
|
+
meta: {
|
|
53
|
+
private: Boolean(params.hideInFileManager)
|
|
54
|
+
},
|
|
55
|
+
tags: Array.isArray(params.tags) ? params.tags : []
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async uploadFiles(params) {
|
|
60
|
+
const settings = await this.context.fileManager.settings.getSettings();
|
|
61
|
+
|
|
62
|
+
if (!settings) {
|
|
63
|
+
throw new _error.default("Missing File Manager Settings.", "FILE_MANAGER_ERROR");
|
|
64
|
+
} // Upload files to cloud storage.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
const promises = [];
|
|
68
|
+
|
|
69
|
+
for (const item of params.files) {
|
|
70
|
+
promises.push(this.storagePlugin.upload((0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
|
|
71
|
+
settings
|
|
72
|
+
})));
|
|
73
|
+
} // Wait for all to resolve.
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
const uploadFileResponses = await Promise.all(promises);
|
|
77
|
+
const filesData = uploadFileResponses.map(response => response.file);
|
|
78
|
+
const {
|
|
79
|
+
fileManager
|
|
80
|
+
} = this.context; // Save files in DB.
|
|
81
|
+
|
|
82
|
+
return fileManager.files.createFilesInBatch(filesData);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async delete(params) {
|
|
86
|
+
const {
|
|
87
|
+
id,
|
|
88
|
+
key
|
|
89
|
+
} = params;
|
|
90
|
+
const {
|
|
91
|
+
fileManager
|
|
92
|
+
} = this.context; // Delete file from cloud storage.
|
|
93
|
+
|
|
94
|
+
await this.storagePlugin.delete({
|
|
95
|
+
key
|
|
96
|
+
}); // Delete file from the DB.
|
|
97
|
+
|
|
98
|
+
return await fileManager.files.deleteFile(id);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
exports.FileStorage = FileStorage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["storagePluginType","FileStorage","constructor","context","storagePlugin","plugins","byType","pop","WebinyError","upload","params","settings","fileManager","getSettings","file","fileData","files","createFile","meta","private","Boolean","hideInFileManager","tags","Array","isArray","uploadFiles","promises","item","push","uploadFileResponses","Promise","all","filesData","map","response","createFilesInBatch","delete","id","key","deleteFile"],"sources":["FileStorage.ts"],"sourcesContent":["import { FileManagerContext } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { FilePhysicalStoragePlugin } from \"~/plugins/definitions/FilePhysicalStoragePlugin\";\n\nexport type Result = Record<string, any>;\n\nconst storagePluginType = \"api-file-manager-storage\";\n\nexport interface FileStorageUploadParams {\n buffer: Buffer;\n hideInFileManager: boolean | string;\n tags?: string[];\n size: number;\n name: string;\n keyPrefix: string;\n type: string;\n}\nexport interface FileStorageDeleteParams {\n id: string;\n key: string;\n}\n\nexport interface FileStorageUploadMultipleParams {\n files: FileStorageUploadParams[];\n}\n\nexport interface FileStorageParams {\n context: FileManagerContext;\n}\nexport class FileStorage {\n private readonly storagePlugin: FilePhysicalStoragePlugin;\n private readonly context: FileManagerContext;\n\n constructor({ context }: FileStorageParams) {\n const storagePlugin = context.plugins\n .byType<FilePhysicalStoragePlugin>(storagePluginType)\n .pop();\n if (!storagePlugin) {\n throw new WebinyError(\n `Missing plugin of type \"${storagePluginType}\".`,\n \"STORAGE_PLUGIN_ERROR\"\n );\n }\n this.storagePlugin = storagePlugin;\n this.context = context;\n }\n\n async upload(params: FileStorageUploadParams): Promise<Result> {\n const settings = await this.context.fileManager.settings.getSettings();\n if (!settings) {\n throw new WebinyError(\"Missing File Manager Settings.\", \"FILE_MANAGER_ERROR\");\n }\n // Add file to cloud storage.\n const { file: fileData } = await this.storagePlugin.upload({\n ...params,\n settings\n });\n\n const { fileManager } = this.context;\n\n // Save file in DB.\n return await fileManager.files.createFile({\n ...(fileData as any),\n meta: {\n private: Boolean(params.hideInFileManager)\n },\n tags: Array.isArray(params.tags) ? params.tags : []\n });\n }\n\n async uploadFiles(params: FileStorageUploadMultipleParams) {\n const settings = await this.context.fileManager.settings.getSettings();\n if (!settings) {\n throw new WebinyError(\"Missing File Manager Settings.\", \"FILE_MANAGER_ERROR\");\n }\n // Upload files to cloud storage.\n const promises = [];\n for (const item of params.files) {\n promises.push(\n this.storagePlugin.upload({\n ...item,\n settings\n })\n );\n }\n // Wait for all to resolve.\n const uploadFileResponses = await Promise.all(promises);\n\n const filesData = uploadFileResponses.map(response => response.file);\n\n const { fileManager } = this.context;\n // Save files in DB.\n return fileManager.files.createFilesInBatch(filesData);\n }\n\n async delete(params: FileStorageDeleteParams) {\n const { id, key } = params;\n const { fileManager } = this.context;\n // Delete file from cloud storage.\n await this.storagePlugin.delete({\n key\n });\n // Delete file from the DB.\n return await fileManager.files.deleteFile(id);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA;;AAKA,MAAMA,iBAAiB,GAAG,0BAA1B;;AAuBO,MAAMC,WAAN,CAAkB;EAIrBC,WAAW,CAAC;IAAEC;EAAF,CAAD,EAAiC;IAAA;IAAA;IACxC,MAAMC,aAAa,GAAGD,OAAO,CAACE,OAAR,CACjBC,MADiB,CACiBN,iBADjB,EAEjBO,GAFiB,EAAtB;;IAGA,IAAI,CAACH,aAAL,EAAoB;MAChB,MAAM,IAAII,cAAJ,CACD,2BAA0BR,iBAAkB,IAD3C,EAEF,sBAFE,CAAN;IAIH;;IACD,KAAKI,aAAL,GAAqBA,aAArB;IACA,KAAKD,OAAL,GAAeA,OAAf;EACH;;EAEW,MAANM,MAAM,CAACC,MAAD,EAAmD;IAC3D,MAAMC,QAAQ,GAAG,MAAM,KAAKR,OAAL,CAAaS,WAAb,CAAyBD,QAAzB,CAAkCE,WAAlC,EAAvB;;IACA,IAAI,CAACF,QAAL,EAAe;MACX,MAAM,IAAIH,cAAJ,CAAgB,gCAAhB,EAAkD,oBAAlD,CAAN;IACH,CAJ0D,CAK3D;;;IACA,MAAM;MAAEM,IAAI,EAAEC;IAAR,IAAqB,MAAM,KAAKX,aAAL,CAAmBK,MAAnB,6DAC1BC,MAD0B;MAE7BC;IAF6B,GAAjC;IAKA,MAAM;MAAEC;IAAF,IAAkB,KAAKT,OAA7B,CAX2D,CAa3D;;IACA,OAAO,MAAMS,WAAW,CAACI,KAAZ,CAAkBC,UAAlB,6DACLF,QADK;MAETG,IAAI,EAAE;QACFC,OAAO,EAAEC,OAAO,CAACV,MAAM,CAACW,iBAAR;MADd,CAFG;MAKTC,IAAI,EAAEC,KAAK,CAACC,OAAN,CAAcd,MAAM,CAACY,IAArB,IAA6BZ,MAAM,CAACY,IAApC,GAA2C;IALxC,GAAb;EAOH;;EAEgB,MAAXG,WAAW,CAACf,MAAD,EAA0C;IACvD,MAAMC,QAAQ,GAAG,MAAM,KAAKR,OAAL,CAAaS,WAAb,CAAyBD,QAAzB,CAAkCE,WAAlC,EAAvB;;IACA,IAAI,CAACF,QAAL,EAAe;MACX,MAAM,IAAIH,cAAJ,CAAgB,gCAAhB,EAAkD,oBAAlD,CAAN;IACH,CAJsD,CAKvD;;;IACA,MAAMkB,QAAQ,GAAG,EAAjB;;IACA,KAAK,MAAMC,IAAX,IAAmBjB,MAAM,CAACM,KAA1B,EAAiC;MAC7BU,QAAQ,CAACE,IAAT,CACI,KAAKxB,aAAL,CAAmBK,MAAnB,6DACOkB,IADP;QAEIhB;MAFJ,GADJ;IAMH,CAdsD,CAevD;;;IACA,MAAMkB,mBAAmB,GAAG,MAAMC,OAAO,CAACC,GAAR,CAAYL,QAAZ,CAAlC;IAEA,MAAMM,SAAS,GAAGH,mBAAmB,CAACI,GAApB,CAAwBC,QAAQ,IAAIA,QAAQ,CAACpB,IAA7C,CAAlB;IAEA,MAAM;MAAEF;IAAF,IAAkB,KAAKT,OAA7B,CApBuD,CAqBvD;;IACA,OAAOS,WAAW,CAACI,KAAZ,CAAkBmB,kBAAlB,CAAqCH,SAArC,CAAP;EACH;;EAEW,MAANI,MAAM,CAAC1B,MAAD,EAAkC;IAC1C,MAAM;MAAE2B,EAAF;MAAMC;IAAN,IAAc5B,MAApB;IACA,MAAM;MAAEE;IAAF,IAAkB,KAAKT,OAA7B,CAF0C,CAG1C;;IACA,MAAM,KAAKC,aAAL,CAAmBgC,MAAnB,CAA0B;MAC5BE;IAD4B,CAA1B,CAAN,CAJ0C,CAO1C;;IACA,OAAO,MAAM1B,WAAW,CAACI,KAAZ,CAAkBuB,UAAlB,CAA6BF,EAA7B,CAAb;EACH;;AA3EoB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _api = require("@webiny/api");
|
|
9
|
+
|
|
10
|
+
var _FileStorage = require("./FileStorage");
|
|
11
|
+
|
|
12
|
+
const fileStorageContextPlugin = new _api.ContextPlugin(async context => {
|
|
13
|
+
if (!context.fileManager) {
|
|
14
|
+
/**
|
|
15
|
+
* We need to define the fileManager initial property as empty object.
|
|
16
|
+
* When casting as FileManagerContext, typescript is complaining.
|
|
17
|
+
*/
|
|
18
|
+
context.fileManager = {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
context.fileManager.storage = new _FileStorage.FileStorage({
|
|
22
|
+
context
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
var _default = fileStorageContextPlugin;
|
|
26
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fileStorageContextPlugin","ContextPlugin","context","fileManager","storage","FileStorage"],"sources":["index.ts"],"sourcesContent":["import { FileManagerContext } from \"~/types\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { FileStorage } from \"./FileStorage\";\n\nconst fileStorageContextPlugin = new ContextPlugin<FileManagerContext>(async context => {\n if (!context.fileManager) {\n /**\n * We need to define the fileManager initial property as empty object.\n * When casting as FileManagerContext, typescript is complaining.\n */\n context.fileManager = {} as any;\n }\n context.fileManager.storage = new FileStorage({\n context\n });\n});\n\nexport default fileStorageContextPlugin;\n"],"mappings":";;;;;;;AACA;;AACA;;AAEA,MAAMA,wBAAwB,GAAG,IAAIC,kBAAJ,CAAsC,MAAMC,OAAN,IAAiB;EACpF,IAAI,CAACA,OAAO,CAACC,WAAb,EAA0B;IACtB;AACR;AACA;AACA;IACQD,OAAO,CAACC,WAAR,GAAsB,EAAtB;EACH;;EACDD,OAAO,CAACC,WAAR,CAAoBC,OAApB,GAA8B,IAAIC,wBAAJ,CAAgB;IAC1CH;EAD0C,CAAhB,CAA9B;AAGH,CAXgC,CAAjC;eAaeF,wB"}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { I18NContext } from "@webiny/api-i18n/types";
|
|
2
|
+
import { FileStorage } from "./plugins/storage/FileStorage";
|
|
3
|
+
import { TenancyContext } from "@webiny/api-tenancy/types";
|
|
4
|
+
import { SecurityContext, SecurityPermission } from "@webiny/api-security/types";
|
|
5
|
+
import { Context } from "@webiny/api/types";
|
|
6
|
+
export interface FileManagerContext extends Context, SecurityContext, TenancyContext, I18NContext {
|
|
7
|
+
fileManager: {
|
|
8
|
+
files: FilesCRUD;
|
|
9
|
+
settings: SettingsCRUD;
|
|
10
|
+
storage: FileStorage;
|
|
11
|
+
system: SystemCRUD;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface FilePermission extends SecurityPermission {
|
|
15
|
+
name: "fm.file";
|
|
16
|
+
rwd?: string;
|
|
17
|
+
own?: boolean;
|
|
18
|
+
}
|
|
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
|
+
export interface FileInput {
|
|
46
|
+
key: string;
|
|
47
|
+
name: string;
|
|
48
|
+
size: number;
|
|
49
|
+
type: string;
|
|
50
|
+
meta: Record<string, any>;
|
|
51
|
+
tags: string[];
|
|
52
|
+
}
|
|
53
|
+
export interface FileListWhereParams {
|
|
54
|
+
search?: string;
|
|
55
|
+
type?: string;
|
|
56
|
+
type_in?: string[];
|
|
57
|
+
tag?: string;
|
|
58
|
+
tag_in?: string[];
|
|
59
|
+
tag_and_in?: string[];
|
|
60
|
+
id_in?: string[];
|
|
61
|
+
id?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface FilesListOpts {
|
|
64
|
+
search?: string;
|
|
65
|
+
types?: string[];
|
|
66
|
+
tags?: string[];
|
|
67
|
+
ids?: string[];
|
|
68
|
+
limit?: number;
|
|
69
|
+
after?: string;
|
|
70
|
+
where?: FileListWhereParams;
|
|
71
|
+
sort?: string[];
|
|
72
|
+
}
|
|
73
|
+
export interface FileListMeta {
|
|
74
|
+
cursor: string | null;
|
|
75
|
+
totalCount: number;
|
|
76
|
+
hasMoreItems: boolean;
|
|
77
|
+
}
|
|
78
|
+
interface FilesCrudListTagsWhere {
|
|
79
|
+
tag?: string;
|
|
80
|
+
tag_contains?: string;
|
|
81
|
+
tag_in?: string[];
|
|
82
|
+
tag_not_startsWith?: string;
|
|
83
|
+
tag_startsWith?: string;
|
|
84
|
+
}
|
|
85
|
+
interface FilesCrudListTagsParams {
|
|
86
|
+
where?: FilesCrudListTagsWhere;
|
|
87
|
+
limit?: number;
|
|
88
|
+
after?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface FilesCRUD {
|
|
91
|
+
getFile(id: string): Promise<File>;
|
|
92
|
+
listFiles(opts?: FilesListOpts): Promise<[File[], FileListMeta]>;
|
|
93
|
+
listTags(params: FilesCrudListTagsParams): Promise<string[]>;
|
|
94
|
+
createFile(data: FileInput): Promise<File>;
|
|
95
|
+
updateFile(id: string, data: Partial<FileInput>): Promise<File>;
|
|
96
|
+
deleteFile(id: string): Promise<boolean>;
|
|
97
|
+
createFilesInBatch(data: FileInput[]): Promise<File[]>;
|
|
98
|
+
}
|
|
99
|
+
export interface SystemCRUD {
|
|
100
|
+
getVersion(): Promise<string | null>;
|
|
101
|
+
setVersion(version: string): Promise<void>;
|
|
102
|
+
install(args: {
|
|
103
|
+
srcPrefix: string;
|
|
104
|
+
}): Promise<boolean>;
|
|
105
|
+
upgrade(version: string, data?: Record<string, any>): Promise<boolean>;
|
|
106
|
+
}
|
|
107
|
+
export interface FileManagerSettings {
|
|
108
|
+
key: string;
|
|
109
|
+
uploadMinFileSize: number;
|
|
110
|
+
uploadMaxFileSize: number;
|
|
111
|
+
srcPrefix: string;
|
|
112
|
+
}
|
|
113
|
+
export interface FileManagerSystem {
|
|
114
|
+
version: string;
|
|
115
|
+
tenant: string;
|
|
116
|
+
}
|
|
117
|
+
export declare type SettingsCRUD = {
|
|
118
|
+
getSettings(): Promise<FileManagerSettings | null>;
|
|
119
|
+
createSettings(data?: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
|
|
120
|
+
updateSettings(data: Partial<FileManagerSettings>): Promise<FileManagerSettings>;
|
|
121
|
+
deleteSettings(): Promise<boolean>;
|
|
122
|
+
};
|
|
123
|
+
/********
|
|
124
|
+
* Storage operations
|
|
125
|
+
*******/
|
|
126
|
+
/**
|
|
127
|
+
* @category StorageOperations
|
|
128
|
+
* @category SystemStorageOperations
|
|
129
|
+
* @category SystemStorageOperationsParams
|
|
130
|
+
*/
|
|
131
|
+
export interface FileManagerSystemStorageOperationsUpdateParams {
|
|
132
|
+
/**
|
|
133
|
+
* The system data to be updated.
|
|
134
|
+
*/
|
|
135
|
+
original: FileManagerSystem;
|
|
136
|
+
/**
|
|
137
|
+
* The system data with the updated fields.
|
|
138
|
+
*/
|
|
139
|
+
data: FileManagerSystem;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @category StorageOperations
|
|
143
|
+
* @category SystemStorageOperations
|
|
144
|
+
* @category SystemStorageOperationsParams
|
|
145
|
+
*/
|
|
146
|
+
export interface FileManagerSystemStorageOperationsCreateParams {
|
|
147
|
+
/**
|
|
148
|
+
* The system fields.
|
|
149
|
+
*/
|
|
150
|
+
data: FileManagerSystem;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @category StorageOperations
|
|
154
|
+
* @category SystemStorageOperations
|
|
155
|
+
*/
|
|
156
|
+
export interface FileManagerSystemStorageOperations {
|
|
157
|
+
/**
|
|
158
|
+
* Get the FileManager system data.
|
|
159
|
+
*/
|
|
160
|
+
get: () => Promise<FileManagerSystem | null>;
|
|
161
|
+
/**
|
|
162
|
+
* Update the FileManager system data..
|
|
163
|
+
*/
|
|
164
|
+
update: (params: FileManagerSystemStorageOperationsUpdateParams) => Promise<FileManagerSystem>;
|
|
165
|
+
/**
|
|
166
|
+
* Create the FileManagerSystemData
|
|
167
|
+
*/
|
|
168
|
+
create: (params: FileManagerSystemStorageOperationsCreateParams) => Promise<FileManagerSystem>;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* @category StorageOperations
|
|
172
|
+
* @category SettingsStorageOperations
|
|
173
|
+
* @category SettingsStorageOperationsParams
|
|
174
|
+
*/
|
|
175
|
+
export interface FileManagerSettingsStorageOperationsUpdateParams {
|
|
176
|
+
/**
|
|
177
|
+
* Original settings to be updated.
|
|
178
|
+
*/
|
|
179
|
+
original: FileManagerSettings;
|
|
180
|
+
/**
|
|
181
|
+
* The settings with the updated fields.
|
|
182
|
+
*/
|
|
183
|
+
data: FileManagerSettings;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* @category StorageOperations
|
|
187
|
+
* @category SettingsStorageOperations
|
|
188
|
+
* @category SettingsStorageOperationsParams
|
|
189
|
+
*/
|
|
190
|
+
export interface FileManagerSettingsStorageOperationsCreateParams {
|
|
191
|
+
/**
|
|
192
|
+
* The settings fields.
|
|
193
|
+
*/
|
|
194
|
+
data: FileManagerSettings;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* @category StorageOperations
|
|
198
|
+
* @category SettingsStorageOperations
|
|
199
|
+
*/
|
|
200
|
+
export interface FileManagerSettingsStorageOperations {
|
|
201
|
+
/**
|
|
202
|
+
* Get the FileManager system data.
|
|
203
|
+
*/
|
|
204
|
+
get: () => Promise<FileManagerSettings | null>;
|
|
205
|
+
/**
|
|
206
|
+
* Create the FileManagerSettingsData
|
|
207
|
+
*/
|
|
208
|
+
create: (params: FileManagerSettingsStorageOperationsCreateParams) => Promise<FileManagerSettings>;
|
|
209
|
+
/**
|
|
210
|
+
* Update the FileManager system data..
|
|
211
|
+
*/
|
|
212
|
+
update: (params: FileManagerSettingsStorageOperationsUpdateParams) => Promise<FileManagerSettings>;
|
|
213
|
+
/**
|
|
214
|
+
* Delete the existing settings.
|
|
215
|
+
*/
|
|
216
|
+
delete: () => Promise<void>;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* @category StorageOperations
|
|
220
|
+
* @category FilesStorageOperations
|
|
221
|
+
* @category FilesStorageOperationsParams
|
|
222
|
+
*/
|
|
223
|
+
export interface FileManagerFilesStorageOperationsGetParams {
|
|
224
|
+
where: {
|
|
225
|
+
id: string;
|
|
226
|
+
tenant: string;
|
|
227
|
+
locale: string;
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* @category StorageOperations
|
|
232
|
+
* @category FilesStorageOperations
|
|
233
|
+
* @category FilesStorageOperationsParams
|
|
234
|
+
*/
|
|
235
|
+
export interface FileManagerFilesStorageOperationsCreateParams {
|
|
236
|
+
file: File;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* @category StorageOperations
|
|
240
|
+
* @category FilesStorageOperations
|
|
241
|
+
* @category FilesStorageOperationsParams
|
|
242
|
+
*/
|
|
243
|
+
export interface FileManagerFilesStorageOperationsUpdateParams {
|
|
244
|
+
original: File;
|
|
245
|
+
file: File;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* @category StorageOperations
|
|
249
|
+
* @category FilesStorageOperations
|
|
250
|
+
* @category FilesStorageOperationsParams
|
|
251
|
+
*/
|
|
252
|
+
export interface FileManagerFilesStorageOperationsDeleteParams {
|
|
253
|
+
file: File;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* @category StorageOperations
|
|
257
|
+
* @category FilesStorageOperations
|
|
258
|
+
* @category FilesStorageOperationsParams
|
|
259
|
+
*/
|
|
260
|
+
export interface FileManagerFilesStorageOperationsCreateBatchParams {
|
|
261
|
+
files: File[];
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* @category StorageOperations
|
|
265
|
+
* @category FilesStorageOperations
|
|
266
|
+
* @category FilesStorageOperationsParams
|
|
267
|
+
*/
|
|
268
|
+
export interface FileManagerFilesStorageOperationsListParamsWhere {
|
|
269
|
+
id?: string;
|
|
270
|
+
id_in?: string[];
|
|
271
|
+
name?: string;
|
|
272
|
+
name_contains?: string;
|
|
273
|
+
tag?: string;
|
|
274
|
+
tag_contains?: string;
|
|
275
|
+
tag_in?: string[];
|
|
276
|
+
createdBy?: string;
|
|
277
|
+
locale: string;
|
|
278
|
+
tenant: string;
|
|
279
|
+
private?: boolean;
|
|
280
|
+
type?: string;
|
|
281
|
+
type_in?: string[];
|
|
282
|
+
search?: string;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* @category StorageOperations
|
|
286
|
+
* @category FilesStorageOperations
|
|
287
|
+
* @category FilesStorageOperationsParams
|
|
288
|
+
*/
|
|
289
|
+
export interface FileManagerFilesStorageOperationsListParams {
|
|
290
|
+
where: FileManagerFilesStorageOperationsListParamsWhere;
|
|
291
|
+
sort: string[];
|
|
292
|
+
limit: number;
|
|
293
|
+
after: string | null;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* @category StorageOperations
|
|
297
|
+
* @category FilesStorageOperations
|
|
298
|
+
* @category FilesStorageOperationsParams
|
|
299
|
+
*/
|
|
300
|
+
export interface FileManagerFilesStorageOperationsListResponseMeta {
|
|
301
|
+
hasMoreItems: boolean;
|
|
302
|
+
totalCount: number;
|
|
303
|
+
cursor: string | null;
|
|
304
|
+
}
|
|
305
|
+
export declare type FileManagerFilesStorageOperationsListResponse = [
|
|
306
|
+
File[],
|
|
307
|
+
FileManagerFilesStorageOperationsListResponseMeta
|
|
308
|
+
];
|
|
309
|
+
export declare type FileManagerFilesStorageOperationsTagsResponse = [
|
|
310
|
+
string[],
|
|
311
|
+
FileManagerFilesStorageOperationsListResponseMeta
|
|
312
|
+
];
|
|
313
|
+
export interface FileManagerFilesStorageOperationsTagsParamsWhere extends FilesCrudListTagsWhere {
|
|
314
|
+
locale: string;
|
|
315
|
+
tenant: string;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* @category StorageOperations
|
|
319
|
+
* @category FilesStorageOperations
|
|
320
|
+
* @category FilesStorageOperationsParams
|
|
321
|
+
*/
|
|
322
|
+
export interface FileManagerFilesStorageOperationsTagsParams {
|
|
323
|
+
where: FileManagerFilesStorageOperationsTagsParamsWhere;
|
|
324
|
+
limit: number;
|
|
325
|
+
after?: string;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* @category StorageOperations
|
|
329
|
+
* @category FilesStorageOperations
|
|
330
|
+
*/
|
|
331
|
+
export interface FileManagerFilesStorageOperations {
|
|
332
|
+
/**
|
|
333
|
+
* Get a single file with given ID from the storage.
|
|
334
|
+
*/
|
|
335
|
+
get: (params: FileManagerFilesStorageOperationsGetParams) => Promise<File | null>;
|
|
336
|
+
/**
|
|
337
|
+
* Insert the file data into the database.
|
|
338
|
+
*/
|
|
339
|
+
create: (params: FileManagerFilesStorageOperationsCreateParams) => Promise<File>;
|
|
340
|
+
/**
|
|
341
|
+
* Update the file data in the database.
|
|
342
|
+
*/
|
|
343
|
+
update: (params: FileManagerFilesStorageOperationsUpdateParams) => Promise<File>;
|
|
344
|
+
/**
|
|
345
|
+
* Delete the file from the database.
|
|
346
|
+
*/
|
|
347
|
+
delete: (params: FileManagerFilesStorageOperationsDeleteParams) => Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* Store multiple files at once to the database.
|
|
350
|
+
*/
|
|
351
|
+
createBatch: (params: FileManagerFilesStorageOperationsCreateBatchParams) => Promise<File[]>;
|
|
352
|
+
/**
|
|
353
|
+
* Get a list of files filtered by given parameters.
|
|
354
|
+
*/
|
|
355
|
+
list: (params: FileManagerFilesStorageOperationsListParams) => Promise<FileManagerFilesStorageOperationsListResponse>;
|
|
356
|
+
/**
|
|
357
|
+
* Get a list of all file tags filtered by given parameters.
|
|
358
|
+
*/
|
|
359
|
+
tags: (params: FileManagerFilesStorageOperationsTagsParams) => Promise<FileManagerFilesStorageOperationsTagsResponse>;
|
|
360
|
+
}
|
|
361
|
+
export {};
|
package/types.js
ADDED
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 \"./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":""}
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/types";
|
|
2
|
+
declare type CallbackFallback = (args: any) => void | Promise<void>;
|
|
3
|
+
export declare const executeCallbacks: <TCallbackFunction extends CallbackFallback = CallbackFallback>(plugins: Plugin[], hook: string, args: Parameters<TCallbackFunction>[0]) => Promise<void>;
|
|
4
|
+
export {};
|
package/utils.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.executeCallbacks = void 0;
|
|
7
|
+
|
|
8
|
+
const executeCallbacks = async (plugins, hook, args) => {
|
|
9
|
+
for (const plugin of plugins) {
|
|
10
|
+
if (typeof plugin[hook] === "function") {
|
|
11
|
+
await plugin[hook](args);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.executeCallbacks = executeCallbacks;
|
package/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["executeCallbacks","plugins","hook","args","plugin"],"sources":["utils.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\n\ntype CallbackFallback = (args: any) => void | Promise<void>;\n\nexport const executeCallbacks = async <\n TCallbackFunction extends CallbackFallback = CallbackFallback\n>(\n plugins: Plugin[],\n hook: string,\n args: Parameters<TCallbackFunction>[0]\n) => {\n for (const plugin of plugins) {\n if (typeof plugin[hook] === \"function\") {\n await plugin[hook](args);\n }\n }\n};\n"],"mappings":";;;;;;;AAIO,MAAMA,gBAAgB,GAAG,OAG5BC,OAH4B,EAI5BC,IAJ4B,EAK5BC,IAL4B,KAM3B;EACD,KAAK,MAAMC,MAAX,IAAqBH,OAArB,EAA8B;IAC1B,IAAI,OAAOG,MAAM,CAACF,IAAD,CAAb,KAAwB,UAA5B,EAAwC;MACpC,MAAME,MAAM,CAACF,IAAD,CAAN,CAAaC,IAAb,CAAN;IACH;EACJ;AACJ,CAZM"}
|