@webiny/api-file-manager 5.35.0 → 5.35.1
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/package.json +27 -27
- package/plugins/crud/files/validation.d.ts +0 -3
- package/plugins/crud/files/validation.js +0 -41
- package/plugins/crud/files/validation.js.map +0 -1
- package/plugins/crud/files.crud.d.ts +0 -4
- package/plugins/crud/files.crud.js +0 -431
- package/plugins/crud/files.crud.js.map +0 -1
- package/plugins/crud/settings.crud.d.ts +0 -5
- package/plugins/crud/settings.crud.js +0 -116
- package/plugins/crud/settings.crud.js.map +0 -1
- package/plugins/crud/system.crud.d.ts +0 -4
- package/plugins/crud/system.crud.js +0 -153
- package/plugins/crud/system.crud.js.map +0 -1
- package/plugins/crud/utils/checkBasePermissions.d.ts +0 -5
- package/plugins/crud/utils/checkBasePermissions.js +0 -33
- package/plugins/crud/utils/checkBasePermissions.js.map +0 -1
- package/plugins/crud/utils/createFileModel.d.ts +0 -5
- package/plugins/crud/utils/createFileModel.js +0 -77
- package/plugins/crud/utils/createFileModel.js.map +0 -1
- package/plugins/crud/utils/lifecycleEvents.d.ts +0 -6
- package/plugins/crud/utils/lifecycleEvents.js +0 -38
- package/plugins/crud/utils/lifecycleEvents.js.map +0 -1
- package/plugins/definitions/FilePhysicalStoragePlugin.d.ts +0 -21
- package/plugins/definitions/FilePhysicalStoragePlugin.js +0 -42
- package/plugins/definitions/FilePhysicalStoragePlugin.js.map +0 -1
- package/plugins/definitions/FilePlugin.d.ts +0 -136
- package/plugins/definitions/FilePlugin.js +0 -70
- package/plugins/definitions/FilePlugin.js.map +0 -1
- package/plugins/definitions/FileStorageTransformPlugin.d.ts +0 -34
- package/plugins/definitions/FileStorageTransformPlugin.js +0 -51
- package/plugins/definitions/FileStorageTransformPlugin.js.map +0 -1
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/definitions/InstallationPlugin.d.ts +0 -19
- package/plugins/definitions/InstallationPlugin.js +0 -42
- package/plugins/definitions/InstallationPlugin.js.map +0 -1
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +0 -17
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/graphql.d.ts +0 -4
- package/plugins/graphql.js +0 -290
- package/plugins/graphql.js.map +0 -1
- package/plugins/storage/FileStorage.d.ts +0 -30
- package/plugins/storage/FileStorage.js +0 -103
- package/plugins/storage/FileStorage.js.map +0 -1
- package/plugins/storage/index.d.ts +0 -4
- package/plugins/storage/index.js +0 -26
- package/plugins/storage/index.js.map +0 -1
- package/utils.d.ts +0 -4
- package/utils.js +0 -16
- package/utils.js.map +0 -1
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = exports.SETTINGS_KEY = void 0;
|
|
9
|
-
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
|
-
var _fields = require("@commodo/fields");
|
|
13
|
-
|
|
14
|
-
var _validation = require("@webiny/validation");
|
|
15
|
-
|
|
16
|
-
var _SettingsStorageOperationsProviderPlugin = require("../definitions/SettingsStorageOperationsProviderPlugin");
|
|
17
|
-
|
|
18
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
19
|
-
|
|
20
|
-
var _api = require("@webiny/api");
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Package @commodo/fields does not have types.
|
|
24
|
-
*/
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
// TODO @ts-refactor verify that this is not used and remove it
|
|
27
|
-
const SETTINGS_KEY = "file-manager";
|
|
28
|
-
exports.SETTINGS_KEY = SETTINGS_KEY;
|
|
29
|
-
const CreateDataModel = (0, _fields.withFields)({
|
|
30
|
-
uploadMinFileSize: (0, _fields.number)({
|
|
31
|
-
value: 0,
|
|
32
|
-
validation: _validation.validation.create("gte:0")
|
|
33
|
-
}),
|
|
34
|
-
uploadMaxFileSize: (0, _fields.number)({
|
|
35
|
-
value: 26214401
|
|
36
|
-
}),
|
|
37
|
-
srcPrefix: (0, _fields.onSet)(value => {
|
|
38
|
-
// Make sure srcPrefix always ends with forward slash.
|
|
39
|
-
if (typeof value === "string") {
|
|
40
|
-
return value.endsWith("/") ? value : value + "/";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return value;
|
|
44
|
-
})((0, _fields.string)({
|
|
45
|
-
value: "/files/"
|
|
46
|
-
}))
|
|
47
|
-
})();
|
|
48
|
-
const UpdateDataModel = (0, _fields.withFields)({
|
|
49
|
-
uploadMinFileSize: (0, _fields.number)({
|
|
50
|
-
validation: _validation.validation.create("gte:0")
|
|
51
|
-
}),
|
|
52
|
-
uploadMaxFileSize: (0, _fields.number)(),
|
|
53
|
-
srcPrefix: (0, _fields.onSet)(value => {
|
|
54
|
-
// Make sure srcPrefix always ends with forward slash.
|
|
55
|
-
if (typeof value === "string") {
|
|
56
|
-
return value.endsWith("/") ? value : value + "/";
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return value;
|
|
60
|
-
})((0, _fields.string)())
|
|
61
|
-
})();
|
|
62
|
-
const settingsCrudContextPlugin = new _api.ContextPlugin(async context => {
|
|
63
|
-
const pluginType = _SettingsStorageOperationsProviderPlugin.SettingsStorageOperationsProviderPlugin.type;
|
|
64
|
-
const providerPlugin = context.plugins.byType(pluginType).find(() => true);
|
|
65
|
-
|
|
66
|
-
if (!providerPlugin) {
|
|
67
|
-
throw new _error.default(`Missing "${pluginType}" plugin.`, "PLUGIN_NOT_FOUND", {
|
|
68
|
-
type: pluginType
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const storageOperations = await providerPlugin.provide({
|
|
73
|
-
context
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
if (!context.fileManager) {
|
|
77
|
-
context.fileManager = {};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
context.fileManager.settings = {
|
|
81
|
-
async getSettings() {
|
|
82
|
-
return storageOperations.get();
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
async createSettings(data) {
|
|
86
|
-
const settings = new CreateDataModel().populate(data);
|
|
87
|
-
await settings.validate();
|
|
88
|
-
const settingsData = await settings.toJSON();
|
|
89
|
-
return storageOperations.create({
|
|
90
|
-
data: settingsData
|
|
91
|
-
});
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
async updateSettings(data) {
|
|
95
|
-
const updatedValue = new UpdateDataModel().populate(data);
|
|
96
|
-
await updatedValue.validate();
|
|
97
|
-
const existingSettings = await storageOperations.get();
|
|
98
|
-
const updatedSettings = await updatedValue.toJSON({
|
|
99
|
-
onlyDirty: true
|
|
100
|
-
});
|
|
101
|
-
return storageOperations.update({
|
|
102
|
-
original: existingSettings,
|
|
103
|
-
data: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, existingSettings), updatedSettings)
|
|
104
|
-
});
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
async deleteSettings() {
|
|
108
|
-
await storageOperations.delete();
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
settingsCrudContextPlugin.name = "FileMangerSettingsCrud";
|
|
115
|
-
var _default = settingsCrudContextPlugin;
|
|
116
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["SETTINGS_KEY","CreateDataModel","withFields","uploadMinFileSize","number","value","validation","create","uploadMaxFileSize","srcPrefix","onSet","endsWith","string","UpdateDataModel","settingsCrudContextPlugin","ContextPlugin","context","pluginType","SettingsStorageOperationsProviderPlugin","type","providerPlugin","plugins","byType","find","WebinyError","storageOperations","provide","fileManager","settings","getSettings","get","createSettings","data","populate","validate","settingsData","toJSON","updateSettings","updatedValue","existingSettings","updatedSettings","onlyDirty","update","original","deleteSettings","delete","name"],"sources":["settings.crud.ts"],"sourcesContent":["/**\n * Package @commodo/fields does not have types.\n */\n// @ts-ignore\nimport { withFields, string, number, onSet } from \"@commodo/fields\";\nimport { validation } from \"@webiny/validation\";\nimport { FileManagerContext, FileManagerSettings } from \"~/types\";\nimport { SettingsStorageOperationsProviderPlugin } from \"~/plugins/definitions/SettingsStorageOperationsProviderPlugin\";\nimport WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\n\n// TODO @ts-refactor verify that this is not used and remove it\nexport const SETTINGS_KEY = \"file-manager\";\n\nconst CreateDataModel = withFields({\n uploadMinFileSize: number({ value: 0, validation: validation.create(\"gte:0\") }),\n uploadMaxFileSize: number({ value: 26214401 }),\n srcPrefix: onSet((value?: string) => {\n // Make sure srcPrefix always ends with forward slash.\n if (typeof value === \"string\") {\n return value.endsWith(\"/\") ? value : value + \"/\";\n }\n return value;\n })(string({ value: \"/files/\" }))\n})();\n\nconst UpdateDataModel = withFields({\n uploadMinFileSize: number({\n validation: validation.create(\"gte:0\")\n }),\n uploadMaxFileSize: number(),\n srcPrefix: onSet((value?: string) => {\n // Make sure srcPrefix always ends with forward slash.\n if (typeof value === \"string\") {\n return value.endsWith(\"/\") ? value : value + \"/\";\n }\n return value;\n })(string())\n})();\n\nconst settingsCrudContextPlugin = new ContextPlugin<FileManagerContext>(async context => {\n const pluginType = SettingsStorageOperationsProviderPlugin.type;\n\n const providerPlugin = context.plugins\n .byType<SettingsStorageOperationsProviderPlugin>(pluginType)\n .find(() => true);\n\n if (!providerPlugin) {\n throw new WebinyError(`Missing \"${pluginType}\" plugin.`, \"PLUGIN_NOT_FOUND\", {\n type: pluginType\n });\n }\n\n const storageOperations = await providerPlugin.provide({\n context\n });\n\n if (!context.fileManager) {\n context.fileManager = {} as any;\n }\n\n context.fileManager.settings = {\n async getSettings() {\n return storageOperations.get();\n },\n async createSettings(data) {\n const settings = new CreateDataModel().populate(data);\n await settings.validate();\n\n const settingsData: FileManagerSettings = await settings.toJSON();\n\n return storageOperations.create({\n data: settingsData\n });\n },\n async updateSettings(data) {\n const updatedValue = new UpdateDataModel().populate(data);\n await updatedValue.validate();\n\n const existingSettings = (await storageOperations.get()) as FileManagerSettings;\n\n const updatedSettings: Partial<FileManagerSettings> = await updatedValue.toJSON({\n onlyDirty: true\n });\n\n return storageOperations.update({\n original: existingSettings,\n data: {\n ...existingSettings,\n ...updatedSettings\n }\n });\n },\n async deleteSettings() {\n await storageOperations.delete();\n\n return true;\n }\n };\n});\n\nsettingsCrudContextPlugin.name = \"FileMangerSettingsCrud\";\n\nexport default settingsCrudContextPlugin;\n"],"mappings":";;;;;;;;;;;AAIA;;AACA;;AAEA;;AACA;;AACA;;AATA;AACA;AACA;AACA;AAQA;AACO,MAAMA,YAAY,GAAG,cAArB;;AAEP,MAAMC,eAAe,GAAG,IAAAC,kBAAA,EAAW;EAC/BC,iBAAiB,EAAE,IAAAC,cAAA,EAAO;IAAEC,KAAK,EAAE,CAAT;IAAYC,UAAU,EAAEA,sBAAA,CAAWC,MAAX,CAAkB,OAAlB;EAAxB,CAAP,CADY;EAE/BC,iBAAiB,EAAE,IAAAJ,cAAA,EAAO;IAAEC,KAAK,EAAE;EAAT,CAAP,CAFY;EAG/BI,SAAS,EAAE,IAAAC,aAAA,EAAOL,KAAD,IAAoB;IACjC;IACA,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;M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/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
|
-
var _apiSecurity = require("@webiny/api-security");
|
|
13
|
-
|
|
14
|
-
var _apiUpgrade = require("@webiny/api-upgrade");
|
|
15
|
-
|
|
16
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
17
|
-
|
|
18
|
-
var _api = require("@webiny/api");
|
|
19
|
-
|
|
20
|
-
var _utils = require("../../utils");
|
|
21
|
-
|
|
22
|
-
var _InstallationPlugin = require("../definitions/InstallationPlugin");
|
|
23
|
-
|
|
24
|
-
var _SystemStorageOperationsProviderPlugin = require("../definitions/SystemStorageOperationsProviderPlugin");
|
|
25
|
-
|
|
26
|
-
const systemCrudContextPlugin = new _api.ContextPlugin(async context => {
|
|
27
|
-
const pluginType = _SystemStorageOperationsProviderPlugin.SystemStorageOperationsProviderPlugin.type;
|
|
28
|
-
const providerPlugin = context.plugins.byType(pluginType).find(() => true);
|
|
29
|
-
|
|
30
|
-
if (!providerPlugin) {
|
|
31
|
-
throw new _error.default(`Missing "${pluginType}" plugin.`, "PLUGIN_NOT_FOUND", {
|
|
32
|
-
type: pluginType
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const storageOperations = await providerPlugin.provide({
|
|
37
|
-
context
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (!context.fileManager) {
|
|
41
|
-
context.fileManager = {};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const getTenantId = () => {
|
|
45
|
-
return context.tenancy.getCurrentTenant().id;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
context.fileManager.system = {
|
|
49
|
-
async getVersion() {
|
|
50
|
-
const system = await storageOperations.get();
|
|
51
|
-
return system ? system.version : null;
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
async setVersion(version) {
|
|
55
|
-
const system = await storageOperations.get();
|
|
56
|
-
|
|
57
|
-
if (system) {
|
|
58
|
-
const data = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), {}, {
|
|
59
|
-
tenant: system.tenant || getTenantId(),
|
|
60
|
-
version
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
await storageOperations.update({
|
|
65
|
-
original: system,
|
|
66
|
-
data
|
|
67
|
-
});
|
|
68
|
-
return;
|
|
69
|
-
} catch (ex) {
|
|
70
|
-
throw new _error.default("Could not update the system data.", "SYSTEM_UPDATE_ERROR", {
|
|
71
|
-
data
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const data = {
|
|
77
|
-
version,
|
|
78
|
-
tenant: getTenantId()
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
await storageOperations.create({
|
|
83
|
-
data
|
|
84
|
-
});
|
|
85
|
-
return;
|
|
86
|
-
} catch (ex) {
|
|
87
|
-
throw new _error.default("Could not create the system data.", "SYSTEM_CREATE_ERROR", {
|
|
88
|
-
data
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
async install({
|
|
94
|
-
srcPrefix
|
|
95
|
-
}) {
|
|
96
|
-
const identity = context.security.getIdentity();
|
|
97
|
-
|
|
98
|
-
if (!identity) {
|
|
99
|
-
throw new _apiSecurity.NotAuthorizedError();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const {
|
|
103
|
-
fileManager
|
|
104
|
-
} = context;
|
|
105
|
-
const version = await fileManager.system.getVersion();
|
|
106
|
-
|
|
107
|
-
if (version) {
|
|
108
|
-
throw new _error.default("File Manager is already installed.", "FILES_INSTALL_ABORTED");
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const data = {};
|
|
112
|
-
|
|
113
|
-
if (srcPrefix) {
|
|
114
|
-
data.srcPrefix = srcPrefix;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const installationPlugins = context.plugins.byType(_InstallationPlugin.InstallationPlugin.type);
|
|
118
|
-
await (0, _utils.executeCallbacks)(installationPlugins, "beforeInstall", {
|
|
119
|
-
context
|
|
120
|
-
});
|
|
121
|
-
await fileManager.settings.createSettings(data);
|
|
122
|
-
await fileManager.system.setVersion(context.WEBINY_VERSION);
|
|
123
|
-
await (0, _utils.executeCallbacks)(installationPlugins, "afterInstall", {
|
|
124
|
-
context
|
|
125
|
-
});
|
|
126
|
-
return true;
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
async upgrade(version) {
|
|
130
|
-
const identity = context.security.getIdentity();
|
|
131
|
-
|
|
132
|
-
if (!identity) {
|
|
133
|
-
throw new _apiSecurity.NotAuthorizedError();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const upgradePlugins = context.plugins.byType("api-upgrade").filter(pl => pl.app === "file-manager");
|
|
137
|
-
const plugin = (0, _apiUpgrade.getApplicablePlugin)({
|
|
138
|
-
deployedVersion: context.WEBINY_VERSION,
|
|
139
|
-
installedAppVersion: await this.getVersion(),
|
|
140
|
-
upgradePlugins,
|
|
141
|
-
upgradeToVersion: version
|
|
142
|
-
});
|
|
143
|
-
await plugin.apply(context); // Store new app version
|
|
144
|
-
|
|
145
|
-
await context.fileManager.system.setVersion(version);
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
};
|
|
150
|
-
});
|
|
151
|
-
systemCrudContextPlugin.name = "FileManagerSystemCrud";
|
|
152
|
-
var _default = systemCrudContextPlugin;
|
|
153
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["systemCrudContextPlugin","ContextPlugin","context","pluginType","SystemStorageOperationsProviderPlugin","type","providerPlugin","plugins","byType","find","WebinyError","storageOperations","provide","fileManager","getTenantId","tenancy","getCurrentTenant","id","system","getVersion","get","version","setVersion","data","tenant","update","original","ex","create","install","srcPrefix","identity","security","getIdentity","NotAuthorizedError","installationPlugins","InstallationPlugin","executeCallbacks","settings","createSettings","WEBINY_VERSION","upgrade","upgradePlugins","filter","pl","app","plugin","getApplicablePlugin","deployedVersion","installedAppVersion","upgradeToVersion","apply","name"],"sources":["system.crud.ts"],"sourcesContent":["import { NotAuthorizedError } from \"@webiny/api-security\";\nimport { getApplicablePlugin } from \"@webiny/api-upgrade\";\nimport { FileManagerContext, FileManagerSettings, FileManagerSystem } from \"~/types\";\nimport { UpgradePlugin } from \"@webiny/api-upgrade/types\";\nimport WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { executeCallbacks } from \"~/utils\";\nimport { InstallationPlugin } from \"~/plugins/definitions/InstallationPlugin\";\nimport { SystemStorageOperationsProviderPlugin } from \"~/plugins/definitions/SystemStorageOperationsProviderPlugin\";\n\nconst systemCrudContextPlugin = new ContextPlugin<FileManagerContext>(async context => {\n const pluginType = SystemStorageOperationsProviderPlugin.type;\n const providerPlugin = context.plugins\n .byType<SystemStorageOperationsProviderPlugin>(pluginType)\n .find(() => true);\n\n if (!providerPlugin) {\n throw new WebinyError(`Missing \"${pluginType}\" plugin.`, \"PLUGIN_NOT_FOUND\", {\n type: pluginType\n });\n }\n\n const storageOperations = await providerPlugin.provide({\n context\n });\n\n if (!context.fileManager) {\n context.fileManager = {} as any;\n }\n\n const getTenantId = (): string => {\n return context.tenancy.getCurrentTenant().id;\n };\n\n context.fileManager.system = {\n async getVersion() {\n const system = await storageOperations.get();\n\n return system ? system.version : null;\n },\n async setVersion(version: string) {\n const system = await storageOperations.get();\n\n if (system) {\n const data: FileManagerSystem = {\n ...system,\n tenant: system.tenant || getTenantId(),\n version\n };\n try {\n await storageOperations.update({\n original: system,\n data\n });\n return;\n } catch (ex) {\n throw new WebinyError(\n \"Could not update the system data.\",\n \"SYSTEM_UPDATE_ERROR\",\n {\n data\n }\n );\n }\n }\n\n const data: FileManagerSystem = {\n version,\n tenant: getTenantId()\n };\n try {\n await storageOperations.create({\n data\n });\n return;\n } catch (ex) {\n throw new WebinyError(\"Could not create the system data.\", \"SYSTEM_CREATE_ERROR\", {\n data\n });\n }\n },\n async install({ srcPrefix }) {\n const identity = context.security.getIdentity();\n if (!identity) {\n throw new NotAuthorizedError();\n }\n const { fileManager } = context;\n const version = await fileManager.system.getVersion();\n\n if (version) {\n throw new WebinyError(\n \"File Manager is already installed.\",\n \"FILES_INSTALL_ABORTED\"\n );\n }\n\n const data: Partial<FileManagerSettings> = {};\n\n if (srcPrefix) {\n data.srcPrefix = srcPrefix;\n }\n\n const installationPlugins = context.plugins.byType<InstallationPlugin>(\n InstallationPlugin.type\n );\n\n await executeCallbacks<InstallationPlugin[\"beforeInstall\"]>(\n installationPlugins,\n \"beforeInstall\",\n {\n context\n }\n );\n\n await fileManager.settings.createSettings(data);\n\n await fileManager.system.setVersion(context.WEBINY_VERSION);\n\n await executeCallbacks<InstallationPlugin[\"afterInstall\"]>(\n installationPlugins,\n \"afterInstall\",\n {\n context\n }\n );\n\n return true;\n },\n async upgrade(version) {\n const identity = context.security.getIdentity();\n if (!identity) {\n throw new NotAuthorizedError();\n }\n\n const upgradePlugins = context.plugins\n .byType<UpgradePlugin>(\"api-upgrade\")\n .filter(pl => pl.app === \"file-manager\");\n\n const plugin = getApplicablePlugin({\n deployedVersion: context.WEBINY_VERSION,\n installedAppVersion: await this.getVersion(),\n upgradePlugins,\n upgradeToVersion: version\n });\n\n await plugin.apply(context);\n\n // Store new app version\n await context.fileManager.system.setVersion(version);\n\n return true;\n }\n };\n});\n\nsystemCrudContextPlugin.name = \"FileManagerSystemCrud\";\n\nexport default systemCrudContextPlugin;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAEA,MAAMA,uBAAuB,GAAG,IAAIC,kBAAJ,CAAsC,MAAMC,OAAN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,CAAN;MAEA,MAAM,IAAAH,uBAAA,EACFF,mBADE,EAEF,cAFE,EAGF;QACIjC;MADJ,CAHE,CAAN;MAQA,OAAO,IAAP;IACH,CA7FwB;;IA8FzB,MAAMuC,OAAN,CAAcpB,OAAd,EAAuB;MACnB,MAAMU,QAAQ,GAAG7B,OAAO,CAAC8B,QAAR,CAAiBC,WAAjB,EAAjB;;MACA,IAAI,CAACF,QAAL,EAAe;QACX,MAAM,IAAIG,+BAAJ,EAAN;MACH;;MAED,MAAMQ,cAAc,GAAGxC,OAAO,CAACK,OAAR,CAClBC,MADkB,CACI,aADJ,EAElBmC,MAFkB,CAEXC,EAAE,IAAIA,EAAE,CAACC,GAAH,KAAW,cAFN,CAAvB;MAIA,MAAMC,MAAM,GAAG,IAAAC,+BAAA,EAAoB;QAC/BC,eAAe,EAAE9C,OAAO,CAACsC,cADM;QAE/BS,mBAAmB,EAAE,MAAM,KAAK9B,UAAL,EAFI;QAG/BuB,cAH+B;QAI/BQ,gBAAgB,EAAE7B;MAJa,CAApB,CAAf;MAOA,MAAMyB,MAAM,CAACK,KAAP,CAAajD,OAAb,CAAN,CAjBmB,CAmBnB;;MACA,MAAMA,OAAO,CAACW,WAAR,CAAoBK,MAApB,CAA2BI,UAA3B,CAAsCD,OAAtC,CAAN;MAEA,OAAO,IAAP;IACH;;EArHwB,CAA7B;AAuHH,CA/I+B,CAAhC;AAiJArB,uBAAuB,CAACoD,IAAxB,GAA+B,uBAA/B;eAEepD,uB"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _apiSecurity = require("@webiny/api-security");
|
|
9
|
-
|
|
10
|
-
var _default = async (context, check = {}) => {
|
|
11
|
-
await context.i18n.checkI18NContentPermission();
|
|
12
|
-
const filePermission = await context.security.getPermission("fm.file");
|
|
13
|
-
|
|
14
|
-
if (!filePermission) {
|
|
15
|
-
throw new _apiSecurity.NotAuthorizedError();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (check.rwd && !hasRwd(filePermission, check.rwd)) {
|
|
19
|
-
throw new _apiSecurity.NotAuthorizedError();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return filePermission;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
exports.default = _default;
|
|
26
|
-
|
|
27
|
-
const hasRwd = (filesFilePermission, rwd) => {
|
|
28
|
-
if (typeof filesFilePermission.rwd !== "string") {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return filesFilePermission.rwd.includes(rwd);
|
|
33
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["context","check","i18n","checkI18NContentPermission","filePermission","security","getPermission","NotAuthorizedError","rwd","hasRwd","filesFilePermission","includes"],"sources":["checkBasePermissions.ts"],"sourcesContent":["import { FileManagerContext, FilePermission } from \"~/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\n\nexport default async (\n context: FileManagerContext,\n check: { rwd?: string } = {}\n): Promise<FilePermission> => {\n await context.i18n.checkI18NContentPermission();\n const filePermission = await context.security.getPermission<FilePermission>(\"fm.file\");\n if (!filePermission) {\n throw new NotAuthorizedError();\n }\n if (check.rwd && !hasRwd(filePermission, check.rwd)) {\n throw new NotAuthorizedError();\n }\n\n return filePermission;\n};\n\nconst hasRwd = (filesFilePermission: FilePermission, rwd: string): boolean => {\n if (typeof filesFilePermission.rwd !== \"string\") {\n return true;\n }\n\n return filesFilePermission.rwd.includes(rwd);\n};\n"],"mappings":";;;;;;;AACA;;eAEe,OACXA,OADW,EAEXC,KAAuB,GAAG,EAFf,KAGe;EAC1B,MAAMD,OAAO,CAACE,IAAR,CAAaC,0BAAb,EAAN;EACA,MAAMC,cAAc,GAAG,MAAMJ,OAAO,CAACK,QAAR,CAAiBC,aAAjB,CAA+C,SAA/C,CAA7B;;EACA,IAAI,CAACF,cAAL,EAAqB;IACjB,MAAM,IAAIG,+BAAJ,EAAN;EACH;;EACD,IAAIN,KAAK,CAACO,GAAN,IAAa,CAACC,MAAM,CAACL,cAAD,EAAiBH,KAAK,CAACO,GAAvB,CAAxB,EAAqD;IACjD,MAAM,IAAID,+BAAJ,EAAN;EACH;;EAED,OAAOH,cAAP;AACH,C;;;;AAED,MAAMK,MAAM,GAAG,CAACC,mBAAD,EAAsCF,GAAtC,KAA+D;EAC1E,IAAI,OAAOE,mBAAmB,CAACF,GAA3B,KAAmC,QAAvC,EAAiD;IAC7C,OAAO,IAAP;EACH;;EAED,OAAOE,mBAAmB,CAACF,GAApB,CAAwBG,QAAxB,CAAiCH,GAAjC,CAAP;AACH,CAND"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _fields = require("@commodo/fields");
|
|
9
|
-
|
|
10
|
-
var _commodoFieldsObject = require("commodo-fields-object");
|
|
11
|
-
|
|
12
|
-
var _validation = require("@webiny/validation");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Package @commodo/fields does not have types
|
|
16
|
-
*/
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Package commodo-fields-object does not have types
|
|
21
|
-
*/
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* TODO @ts-refactor change for JOI or some other validation library
|
|
26
|
-
*/
|
|
27
|
-
var _default = (create = true) => {
|
|
28
|
-
return (0, _fields.withFields)({
|
|
29
|
-
key: (0, _fields.string)({
|
|
30
|
-
validation: _validation.validation.create(`${create ? "required," : ""}maxLength:1000`)
|
|
31
|
-
}),
|
|
32
|
-
name: (0, _fields.string)({
|
|
33
|
-
validation: _validation.validation.create("maxLength:1000")
|
|
34
|
-
}),
|
|
35
|
-
size: (0, _fields.number)(),
|
|
36
|
-
type: (0, _fields.string)({
|
|
37
|
-
validation: _validation.validation.create("maxLength:255")
|
|
38
|
-
}),
|
|
39
|
-
meta: (0, _commodoFieldsObject.object)({
|
|
40
|
-
value: {
|
|
41
|
-
private: false
|
|
42
|
-
}
|
|
43
|
-
}),
|
|
44
|
-
tags: (0, _fields.onSet)(value => {
|
|
45
|
-
if (!Array.isArray(value)) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return value.map(item => item.toLowerCase());
|
|
50
|
-
})((0, _fields.string)({
|
|
51
|
-
list: true,
|
|
52
|
-
validation: tags => {
|
|
53
|
-
if (!Array.isArray(tags)) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (tags.length > 15) {
|
|
58
|
-
throw Error("You cannot set more than 15 tags.");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
for (let i = 0; i < tags.length; i++) {
|
|
62
|
-
const tag = tags[i];
|
|
63
|
-
|
|
64
|
-
if (typeof tag !== "string") {
|
|
65
|
-
throw Error("Tag must be typeof string.");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (tag.length > 50) {
|
|
69
|
-
throw Error(`Tag ${tag} is more than 50 characters long.`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}))
|
|
74
|
-
})();
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["create","withFields","key","string","validation","name","size","number","type","meta","object","value","private","tags","onSet","Array","isArray","map","item","toLowerCase","list","length","Error","i","tag"],"sources":["createFileModel.ts"],"sourcesContent":["/**\n * Package @commodo/fields does not have types\n */\n// @ts-ignore\nimport { withFields, string, number, onSet } from \"@commodo/fields\";\n/**\n * Package commodo-fields-object does not have types\n */\n// @ts-ignore\nimport { object } from \"commodo-fields-object\";\nimport { validation } from \"@webiny/validation\";\n\n/**\n * TODO @ts-refactor change for JOI or some other validation library\n */\nexport default (create = true) => {\n return withFields({\n key: string({\n validation: validation.create(`${create ? \"required,\" : \"\"}maxLength:1000`)\n }),\n name: string({ validation: validation.create(\"maxLength:1000\") }),\n size: number(),\n type: string({ validation: validation.create(\"maxLength:255\") }),\n meta: object({ value: { private: false } }),\n tags: onSet((value: string[]) => {\n if (!Array.isArray(value)) {\n return null;\n }\n\n return value.map(item => item.toLowerCase());\n })(\n string({\n list: true,\n validation: (tags: string[]) => {\n if (!Array.isArray(tags)) {\n return;\n }\n\n if (tags.length > 15) {\n throw Error(\"You cannot set more than 15 tags.\");\n }\n\n for (let i = 0; i < tags.length; i++) {\n const tag = tags[i];\n if (typeof tag !== \"string\") {\n throw Error(\"Tag must be typeof string.\");\n }\n\n if (tag.length > 50) {\n throw Error(`Tag ${tag} is more than 50 characters long.`);\n }\n }\n }\n })\n )\n })();\n};\n"],"mappings":";;;;;;;AAIA;;AAKA;;AACA;;AAVA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAIA;AACA;AACA;eACe,CAACA,MAAM,GAAG,IAAV,KAAmB;EAC9B,OAAO,IAAAC,kBAAA,EAAW;IACdC,GAAG,EAAE,IAAAC,cAAA,EAAO;MACRC,UAAU,EAAEA,sBAAA,CAAWJ,MAAX,CAAmB,GAAEA,MAAM,GAAG,WAAH,GAAiB,EAAG,gBAA/C;IADJ,CAAP,CADS;IAIdK,IAAI,EAAE,IAAAF,cAAA,EAAO;MAAEC,UAAU,EAAEA,sBAAA,CAAWJ,MAAX,CAAkB,gBAAlB;IAAd,CAAP,CAJQ;IAKdM,IAAI,EAAE,IAAAC,cAAA,GALQ;IAMdC,IAAI,EAAE,IAAAL,cAAA,EAAO;MAAEC,UAAU,EAAEA,sBAAA,CAAWJ,MAAX,CAAkB,eAAlB;IAAd,CAAP,CANQ;IAOdS,IAAI,EAAE,IAAAC,2BAAA,EAAO;MAAEC,KAAK,EAAE;QAAEC,OAAO,EAAE;MAAX;IAAT,CAAP,CAPQ;IAQdC,IAAI,EAAE,IAAAC,aAAA,EAAOH,KAAD,IAAqB;MAC7B,IAAI,CAACI,KAAK,CAACC,OAAN,CAAcL,KAAd,CAAL,EAA2B;QACvB,OAAO,IAAP;MACH;;MAED,OAAOA,KAAK,CAACM,GAAN,CAAUC,IAAI,IAAIA,IAAI,CAACC,WAAL,EAAlB,CAAP;IACH,CANK,EAOF,IAAAhB,cAAA,EAAO;MACHiB,IAAI,EAAE,IADH;MAEHhB,UAAU,EAAGS,IAAD,IAAoB;QAC5B,IAAI,CAACE,KAAK,CAACC,OAAN,CAAcH,IAAd,CAAL,EAA0B;UACtB;QACH;;QAED,IAAIA,IAAI,CAACQ,MAAL,GAAc,EAAlB,EAAsB;UAClB,MAAMC,KAAK,CAAC,mCAAD,CAAX;QACH;;QAED,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGV,IAAI,CAACQ,MAAzB,EAAiCE,CAAC,EAAlC,EAAsC;UAClC,MAAMC,GAAG,GAAGX,IAAI,CAACU,CAAD,CAAhB;;UACA,IAAI,OAAOC,GAAP,KAAe,QAAnB,EAA6B;YACzB,MAAMF,KAAK,CAAC,4BAAD,CAAX;UACH;;UAED,IAAIE,GAAG,CAACH,MAAJ,GAAa,EAAjB,EAAqB;YACjB,MAAMC,KAAK,CAAE,OAAME,GAAI,mCAAZ,CAAX;UACH;QACJ;MACJ;IArBE,CAAP,CAPE;EARQ,CAAX,GAAP;AAwCH,C"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { FilePlugin, FilePluginParams } from "../../definitions/FilePlugin";
|
|
2
|
-
import { FileManagerContext } from "../../../types";
|
|
3
|
-
export declare const runLifecycleEvent: (hook: keyof FilePluginParams, params: {
|
|
4
|
-
context: FileManagerContext;
|
|
5
|
-
plugins: FilePlugin[];
|
|
6
|
-
} & Record<string, any>) => Promise<void>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.runLifecycleEvent = void 0;
|
|
9
|
-
|
|
10
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
-
|
|
12
|
-
const _excluded = ["plugins"];
|
|
13
|
-
|
|
14
|
-
// TODO @ts-refactor introduce pubsub methods
|
|
15
|
-
const runLifecycleEvent = async (hook, params) => {
|
|
16
|
-
const {
|
|
17
|
-
plugins
|
|
18
|
-
} = params,
|
|
19
|
-
rest = (0, _objectWithoutProperties2.default)(params, _excluded);
|
|
20
|
-
|
|
21
|
-
if (plugins.length === 0) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
for (const plugin of plugins) {
|
|
26
|
-
if (!plugin[hook]) {
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Keep any because we do not know which hook needs to be executed. This will be removed, so it does not matter.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
await plugin[hook](rest);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
exports.runLifecycleEvent = runLifecycleEvent;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["runLifecycleEvent","hook","params","plugins","rest","length","plugin"],"sources":["lifecycleEvents.ts"],"sourcesContent":["// TODO @ts-refactor introduce pubsub methods\nimport { FilePlugin, FilePluginParams } from \"~/plugins/definitions/FilePlugin\";\nimport { FileManagerContext } from \"~/types\";\n\nexport const runLifecycleEvent = async (\n hook: keyof FilePluginParams,\n params: { context: FileManagerContext; plugins: FilePlugin[] } & Record<string, any>\n): Promise<void> => {\n const { plugins, ...rest } = params;\n if (plugins.length === 0) {\n return;\n }\n for (const plugin of plugins) {\n if (!plugin[hook]) {\n continue;\n }\n /**\n * Keep any because we do not know which hook needs to be executed. This will be removed, so it does not matter.\n */\n await plugin[hook](rest as any);\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAAA;AAIO,MAAMA,iBAAiB,GAAG,OAC7BC,IAD6B,EAE7BC,MAF6B,KAGb;EAChB,MAAM;IAAEC;EAAF,IAAuBD,MAA7B;EAAA,MAAoBE,IAApB,0CAA6BF,MAA7B;;EACA,IAAIC,OAAO,CAACE,MAAR,KAAmB,CAAvB,EAA0B;IACtB;EACH;;EACD,KAAK,MAAMC,MAAX,IAAqBH,OAArB,EAA8B;IAC1B,IAAI,CAACG,MAAM,CAACL,IAAD,CAAX,EAAmB;MACf;IACH;IACD;AACR;AACA;;;IACQ,MAAMK,MAAM,CAACL,IAAD,CAAN,CAAaG,IAAb,CAAN;EACH;AACJ,CAjBM"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Plugin } from "@webiny/plugins";
|
|
3
|
-
import { FileManagerSettings } from "../../types";
|
|
4
|
-
export interface FilePhysicalStoragePluginParams<U extends FilePhysicalStoragePluginUploadParams, D extends FilePhysicalStoragePluginDeleteParams> {
|
|
5
|
-
upload: (args: U) => Promise<any>;
|
|
6
|
-
delete: (args: D) => Promise<void>;
|
|
7
|
-
}
|
|
8
|
-
export interface FilePhysicalStoragePluginUploadParams {
|
|
9
|
-
settings: FileManagerSettings;
|
|
10
|
-
buffer: Buffer;
|
|
11
|
-
}
|
|
12
|
-
export interface FilePhysicalStoragePluginDeleteParams {
|
|
13
|
-
key: string;
|
|
14
|
-
}
|
|
15
|
-
export declare class FilePhysicalStoragePlugin<U extends FilePhysicalStoragePluginUploadParams = FilePhysicalStoragePluginUploadParams, D extends FilePhysicalStoragePluginDeleteParams = FilePhysicalStoragePluginDeleteParams> extends Plugin {
|
|
16
|
-
static readonly type: string;
|
|
17
|
-
private readonly _params;
|
|
18
|
-
constructor(params: FilePhysicalStoragePluginParams<U, D>);
|
|
19
|
-
upload(params: U): Promise<any>;
|
|
20
|
-
delete(params: D): Promise<any>;
|
|
21
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.FilePhysicalStoragePlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
|
-
class FilePhysicalStoragePlugin extends _plugins.Plugin {
|
|
17
|
-
constructor(params) {
|
|
18
|
-
super();
|
|
19
|
-
(0, _defineProperty2.default)(this, "_params", void 0);
|
|
20
|
-
this._params = params;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async upload(params) {
|
|
24
|
-
if (!this._params.upload) {
|
|
25
|
-
throw new _error.default(`You must define the "upload" method of this plugin.`, "UPLOAD_METHOD_ERROR");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return this._params.upload(params);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async delete(params) {
|
|
32
|
-
if (!this._params.delete) {
|
|
33
|
-
throw new _error.default(`You must define the "delete" method of this plugin.`, "DELETE_METHOD_ERROR");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return this._params.delete(params);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
exports.FilePhysicalStoragePlugin = FilePhysicalStoragePlugin;
|
|
42
|
-
(0, _defineProperty2.default)(FilePhysicalStoragePlugin, "type", "api-file-manager-storage");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["FilePhysicalStoragePlugin","Plugin","constructor","params","_params","upload","WebinyError","delete"],"sources":["FilePhysicalStoragePlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { FileManagerSettings } from \"~/types\";\n\nexport interface FilePhysicalStoragePluginParams<\n U extends FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams\n> {\n upload: (args: U) => Promise<any>;\n delete: (args: D) => Promise<void>;\n}\n\nexport interface FilePhysicalStoragePluginUploadParams {\n settings: FileManagerSettings;\n buffer: Buffer;\n}\n\nexport interface FilePhysicalStoragePluginDeleteParams {\n key: string;\n}\n\nexport class FilePhysicalStoragePlugin<\n U extends FilePhysicalStoragePluginUploadParams = FilePhysicalStoragePluginUploadParams,\n D extends FilePhysicalStoragePluginDeleteParams = FilePhysicalStoragePluginDeleteParams\n> extends Plugin {\n public static override readonly type: string = \"api-file-manager-storage\";\n private readonly _params: FilePhysicalStoragePluginParams<U, D>;\n\n public constructor(params: FilePhysicalStoragePluginParams<U, D>) {\n super();\n this._params = params;\n }\n\n public async upload(params: U): Promise<any> {\n if (!this._params.upload) {\n throw new WebinyError(\n `You must define the \"upload\" method of this plugin.`,\n \"UPLOAD_METHOD_ERROR\"\n );\n }\n return this._params.upload(params);\n }\n\n public async delete(params: D): Promise<any> {\n if (!this._params.delete) {\n throw new WebinyError(\n `You must define the \"delete\" method of this plugin.`,\n \"DELETE_METHOD_ERROR\"\n );\n }\n return this._params.delete(params);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAoBO,MAAMA,yBAAN,SAGGC,eAHH,CAGU;EAINC,WAAW,CAACC,MAAD,EAAgD;IAC9D;IAD8D;IAE9D,KAAKC,OAAL,GAAeD,MAAf;EACH;;EAEkB,MAANE,MAAM,CAACF,MAAD,EAA0B;IACzC,IAAI,CAAC,KAAKC,OAAL,CAAaC,MAAlB,EAA0B;MACtB,MAAM,IAAIC,cAAJ,CACD,qDADC,EAEF,qBAFE,CAAN;IAIH;;IACD,OAAO,KAAKF,OAAL,CAAaC,MAAb,CAAoBF,MAApB,CAAP;EACH;;EAEkB,MAANI,MAAM,CAACJ,MAAD,EAA0B;IACzC,IAAI,CAAC,KAAKC,OAAL,CAAaG,MAAlB,EAA0B;MACtB,MAAM,IAAID,cAAJ,CACD,qDADC,EAEF,qBAFE,CAAN;IAIH;;IACD,OAAO,KAAKF,OAAL,CAAaG,MAAb,CAAoBJ,MAApB,CAAP;EACH;;AA3BY;;;8BAHJH,yB,UAIsC,0B"}
|