@webiny/api-file-manager 0.0.0-unstable.e3f4727c56 → 0.0.0-unstable.eb196ccd2f
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 +115 -0
- package/FileManagerContextSetup.js.map +1 -0
- package/README.md +1 -1
- package/cmsFileStorage/CmsFilesStorage.d.ts +27 -0
- package/cmsFileStorage/CmsFilesStorage.js +164 -0
- package/cmsFileStorage/CmsFilesStorage.js.map +1 -0
- package/cmsFileStorage/ListFilesWhereProcessor.d.ts +7 -0
- package/cmsFileStorage/ListFilesWhereProcessor.js +33 -0
- package/cmsFileStorage/ListFilesWhereProcessor.js.map +1 -0
- package/cmsFileStorage/ListTagsWhereProcessor.d.ts +7 -0
- package/cmsFileStorage/ListTagsWhereProcessor.js +33 -0
- package/cmsFileStorage/ListTagsWhereProcessor.js.map +1 -0
- package/cmsFileStorage/file.model.d.ts +6 -0
- package/cmsFileStorage/file.model.js +158 -0
- package/cmsFileStorage/file.model.js.map +1 -0
- package/contants.d.ts +1 -0
- package/contants.js +9 -0
- package/contants.js.map +1 -0
- package/createFileManager/files.crud.d.ts +3 -0
- package/createFileManager/files.crud.js +328 -0
- package/createFileManager/files.crud.js.map +1 -0
- package/createFileManager/index.d.ts +3 -0
- package/createFileManager/index.js +23 -0
- package/createFileManager/index.js.map +1 -0
- package/createFileManager/permissions/FilesPermissions.d.ts +4 -0
- package/createFileManager/permissions/FilesPermissions.js +11 -0
- package/createFileManager/permissions/FilesPermissions.js.map +1 -0
- package/createFileManager/permissions/SettingsPermissions.d.ts +4 -0
- package/createFileManager/permissions/SettingsPermissions.js +11 -0
- package/createFileManager/permissions/SettingsPermissions.js.map +1 -0
- package/createFileManager/settings.crud.d.ts +3 -0
- package/createFileManager/settings.crud.js +117 -0
- package/createFileManager/settings.crud.js.map +1 -0
- package/createFileManager/system.crud.d.ts +3 -0
- package/createFileManager/system.crud.js +88 -0
- package/createFileManager/system.crud.js.map +1 -0
- package/createFileManager/types.d.ts +16 -0
- package/createFileManager/types.js +7 -0
- package/createFileManager/types.js.map +1 -0
- package/delivery/AssetDelivery/AliasAssetRequestResolver.d.ts +11 -0
- package/delivery/AssetDelivery/AliasAssetRequestResolver.js +74 -0
- package/delivery/AssetDelivery/AliasAssetRequestResolver.js.map +1 -0
- package/delivery/AssetDelivery/Asset.d.ts +32 -0
- package/delivery/AssetDelivery/Asset.js +69 -0
- package/delivery/AssetDelivery/Asset.js.map +1 -0
- package/delivery/AssetDelivery/AssetDeliveryConfig.d.ts +63 -0
- package/delivery/AssetDelivery/AssetDeliveryConfig.js +102 -0
- package/delivery/AssetDelivery/AssetDeliveryConfig.js.map +1 -0
- package/delivery/AssetDelivery/AssetRequest.d.ts +25 -0
- package/delivery/AssetDelivery/AssetRequest.js +29 -0
- package/delivery/AssetDelivery/AssetRequest.js.map +1 -0
- package/delivery/AssetDelivery/FilesAssetRequestResolver.d.ts +6 -0
- package/delivery/AssetDelivery/FilesAssetRequestResolver.js +37 -0
- package/delivery/AssetDelivery/FilesAssetRequestResolver.js.map +1 -0
- package/delivery/AssetDelivery/NullAssetOutputStrategy.d.ts +4 -0
- package/delivery/AssetDelivery/NullAssetOutputStrategy.js +15 -0
- package/delivery/AssetDelivery/NullAssetOutputStrategy.js.map +1 -0
- package/delivery/AssetDelivery/NullAssetReply.d.ts +4 -0
- package/delivery/AssetDelivery/NullAssetReply.js +20 -0
- package/delivery/AssetDelivery/NullAssetReply.js.map +1 -0
- package/delivery/AssetDelivery/NullAssetResolver.d.ts +5 -0
- package/delivery/AssetDelivery/NullAssetResolver.js +14 -0
- package/delivery/AssetDelivery/NullAssetResolver.js.map +1 -0
- package/delivery/AssetDelivery/NullRequestResolver.d.ts +4 -0
- package/delivery/AssetDelivery/NullRequestResolver.js +14 -0
- package/delivery/AssetDelivery/NullRequestResolver.js.map +1 -0
- package/delivery/AssetDelivery/SetCacheControlHeaders.d.ts +8 -0
- package/delivery/AssetDelivery/SetCacheControlHeaders.js +25 -0
- package/delivery/AssetDelivery/SetCacheControlHeaders.js.map +1 -0
- package/delivery/AssetDelivery/SetResponseHeaders.d.ts +18 -0
- package/delivery/AssetDelivery/SetResponseHeaders.js +25 -0
- package/delivery/AssetDelivery/SetResponseHeaders.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.d.ts +6 -0
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.js +7 -0
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.d.ts +4 -0
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js +7 -0
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetProcessor.d.ts +4 -0
- package/delivery/AssetDelivery/abstractions/AssetProcessor.js +7 -0
- package/delivery/AssetDelivery/abstractions/AssetProcessor.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetReply.d.ts +25 -0
- package/delivery/AssetDelivery/abstractions/AssetReply.js +38 -0
- package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.d.ts +5 -0
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js +7 -0
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetResolver.d.ts +4 -0
- package/delivery/AssetDelivery/abstractions/AssetResolver.js +7 -0
- package/delivery/AssetDelivery/abstractions/AssetResolver.js.map +1 -0
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.d.ts +4 -0
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js +7 -0
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js.map +1 -0
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.d.ts +2 -0
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +15 -0
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.d.ts +4 -0
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js +7 -0
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.d.ts +4 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js +26 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.d.ts +4 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +15 -0
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.d.ts +7 -0
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +28 -0
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PrivateCache.d.ts +6 -0
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js +28 -0
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +8 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +37 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.d.ts +13 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js +63 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PublicCache.d.ts +6 -0
- package/delivery/AssetDelivery/privateFiles/PublicCache.js +28 -0
- package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +7 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +27 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.d.ts +7 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +27 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/internalIdentity.d.ts +7 -0
- package/delivery/AssetDelivery/privateFiles/internalIdentity.js +18 -0
- package/delivery/AssetDelivery/privateFiles/internalIdentity.js.map +1 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.d.ts +4 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js +14 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js.map +1 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.d.ts +4 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js +14 -0
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +1 -0
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.d.ts +6 -0
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js +26 -0
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +1 -0
- package/delivery/index.d.ts +17 -0
- package/delivery/index.js +194 -0
- package/delivery/index.js.map +1 -0
- package/delivery/setupAssetDelivery.d.ts +6 -0
- package/delivery/setupAssetDelivery.js +128 -0
- package/delivery/setupAssetDelivery.js.map +1 -0
- package/enterprise/applyThreatScanning.d.ts +2 -0
- package/enterprise/applyThreatScanning.js +20 -0
- package/enterprise/applyThreatScanning.js.map +1 -0
- package/graphql/baseSchema.d.ts +3 -0
- package/graphql/baseSchema.js +121 -0
- package/graphql/baseSchema.js.map +1 -0
- package/graphql/createFilesTypeDefs.d.ts +7 -0
- package/graphql/createFilesTypeDefs.js +184 -0
- package/graphql/createFilesTypeDefs.js.map +1 -0
- package/graphql/filesSchema.d.ts +4 -0
- package/graphql/filesSchema.js +89 -0
- package/graphql/filesSchema.js.map +1 -0
- package/graphql/getFileByUrl.d.ts +3 -0
- package/graphql/getFileByUrl.js +78 -0
- package/graphql/getFileByUrl.js.map +1 -0
- package/graphql/index.d.ts +4 -0
- package/graphql/index.js +55 -0
- package/graphql/index.js.map +1 -0
- package/graphql/utils.d.ts +11 -0
- package/graphql/utils.js +24 -0
- package/graphql/utils.js.map +1 -0
- package/handlers/{transform/managers → manage}/imageManager.d.ts +2 -3
- package/handlers/manage/imageManager.js +75 -0
- package/handlers/manage/imageManager.js.map +1 -0
- package/handlers/manage/index.d.ts +1 -1
- package/handlers/manage/index.js +9 -5
- package/handlers/manage/index.js.map +1 -1
- package/handlers/{transform/utils.js → manage/legacyUtils.js} +7 -9
- package/handlers/manage/legacyUtils.js.map +1 -0
- package/handlers/manage/utils.d.ts +12 -0
- package/handlers/manage/utils.js +34 -0
- package/handlers/manage/utils.js.map +1 -0
- package/handlers/types.d.ts +1 -1
- package/handlers/types.js +3 -1
- package/handlers/types.js.map +1 -1
- package/handlers/utils/getEnvironment.js +3 -1
- package/handlers/utils/getEnvironment.js.map +1 -1
- package/handlers/utils/getObjectParams.js +3 -1
- package/handlers/utils/getObjectParams.js.map +1 -1
- package/handlers/utils/index.js +3 -1
- package/handlers/utils/index.js.map +1 -1
- package/index.d.ts +10 -0
- package/index.js +76 -0
- package/index.js.map +1 -0
- package/modelModifier/CmsModelModifier.d.ts +26 -0
- package/modelModifier/CmsModelModifier.js +62 -0
- package/modelModifier/CmsModelModifier.js.map +1 -0
- package/package.json +26 -36
- package/plugins/{definitions/FilePhysicalStoragePlugin.d.ts → FilePhysicalStoragePlugin.d.ts} +2 -1
- package/plugins/{definitions/FilePhysicalStoragePlugin.js → FilePhysicalStoragePlugin.js} +3 -3
- package/plugins/FilePhysicalStoragePlugin.js.map +1 -0
- package/plugins/{definitions/FileStorageTransformPlugin.d.ts → FileStorageTransformPlugin.d.ts} +1 -1
- package/plugins/{definitions/FileStorageTransformPlugin.js → FileStorageTransformPlugin.js} +3 -4
- package/plugins/FileStorageTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +2 -2
- package/plugins/index.js +24 -10
- package/plugins/index.js.map +1 -1
- package/{plugins/storage → storage}/FileStorage.d.ts +10 -6
- package/storage/FileStorage.js +90 -0
- package/storage/FileStorage.js.map +1 -0
- package/types/file.d.ts +49 -0
- package/types/file.js +7 -0
- package/types/file.js.map +1 -0
- package/types/file.lifecycle.d.ts +44 -0
- package/types/file.lifecycle.js +7 -0
- package/types/file.lifecycle.js.map +1 -0
- package/types.d.ts +92 -80
- package/types.js +25 -1
- package/types.js.map +1 -1
- package/handlers/download/index.d.ts +0 -3
- package/handlers/download/index.js +0 -113
- package/handlers/download/index.js.map +0 -1
- package/handlers/transform/index.d.ts +0 -2
- package/handlers/transform/index.js +0 -81
- package/handlers/transform/index.js.map +0 -1
- package/handlers/transform/loaders/imageLoader.d.ts +0 -30
- package/handlers/transform/loaders/imageLoader.js +0 -88
- package/handlers/transform/loaders/imageLoader.js.map +0 -1
- package/handlers/transform/loaders/index.d.ts +0 -8
- package/handlers/transform/loaders/index.js +0 -10
- package/handlers/transform/loaders/index.js.map +0 -1
- package/handlers/transform/loaders/sanitizeImageTransformations.d.ts +0 -11
- package/handlers/transform/loaders/sanitizeImageTransformations.js +0 -45
- package/handlers/transform/loaders/sanitizeImageTransformations.js.map +0 -1
- package/handlers/transform/managers/imageManager.js +0 -55
- package/handlers/transform/managers/imageManager.js.map +0 -1
- package/handlers/transform/managers/index.d.ts +0 -5
- package/handlers/transform/managers/index.js +0 -10
- package/handlers/transform/managers/index.js.map +0 -1
- package/handlers/transform/optimizeImage.d.ts +0 -3
- package/handlers/transform/optimizeImage.js +0 -42
- package/handlers/transform/optimizeImage.js.map +0 -1
- package/handlers/transform/transformImage.d.ts +0 -10
- package/handlers/transform/transformImage.js +0 -25
- package/handlers/transform/transformImage.js.map +0 -1
- package/handlers/transform/utils.js.map +0 -1
- package/plugins/crud/files/validation.d.ts +0 -3
- package/plugins/crud/files/validation.js +0 -35
- 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 -372
- 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 -99
- 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 -104
- 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 -25
- 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 -65
- 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 -30
- package/plugins/crud/utils/lifecycleEvents.js.map +0 -1
- package/plugins/definitions/FilePhysicalStoragePlugin.js.map +0 -1
- package/plugins/definitions/FilePlugin.d.ts +0 -136
- package/plugins/definitions/FilePlugin.js +0 -52
- package/plugins/definitions/FilePlugin.js.map +0 -1
- package/plugins/definitions/FileStorageTransformPlugin.js.map +0 -1
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js +0 -12
- package/plugins/definitions/FilesStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/definitions/InstallationPlugin.d.ts +0 -19
- package/plugins/definitions/InstallationPlugin.js +0 -31
- package/plugins/definitions/InstallationPlugin.js.map +0 -1
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js +0 -12
- package/plugins/definitions/SettingsStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.d.ts +0 -9
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js +0 -12
- package/plugins/definitions/SystemStorageOperationsProviderPlugin.js.map +0 -1
- package/plugins/graphql.d.ts +0 -4
- package/plugins/graphql.js +0 -262
- package/plugins/graphql.js.map +0 -1
- package/plugins/storage/FileStorage.js +0 -85
- package/plugins/storage/FileStorage.js.map +0 -1
- package/plugins/storage/index.d.ts +0 -4
- package/plugins/storage/index.js +0 -22
- package/plugins/storage/index.js.map +0 -1
- package/utils.d.ts +0 -4
- package/utils.js +0 -14
- package/utils.js.map +0 -1
- /package/handlers/{transform/utils.d.ts → manage/legacyUtils.d.ts} +0 -0
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _sanitizeImageTransformations = _interopRequireDefault(require("./sanitizeImageTransformations"));
|
|
9
|
-
var _utils = require("../../utils");
|
|
10
|
-
var _utils2 = require("../utils");
|
|
11
|
-
const IMAGE_TRANSFORMER_FUNCTION = process.env.IMAGE_TRANSFORMER_FUNCTION;
|
|
12
|
-
const callImageTransformerLambda = async ({
|
|
13
|
-
key,
|
|
14
|
-
transformations,
|
|
15
|
-
context
|
|
16
|
-
}) => {
|
|
17
|
-
return await context.handlerClient.invoke({
|
|
18
|
-
name: IMAGE_TRANSFORMER_FUNCTION,
|
|
19
|
-
payload: {
|
|
20
|
-
body: {
|
|
21
|
-
key,
|
|
22
|
-
transformations
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
var _default = {
|
|
28
|
-
canProcess: params => {
|
|
29
|
-
return _utils2.SUPPORTED_IMAGES.includes(params.file.extension);
|
|
30
|
-
},
|
|
31
|
-
async process({
|
|
32
|
-
s3,
|
|
33
|
-
file,
|
|
34
|
-
options,
|
|
35
|
-
context
|
|
36
|
-
}) {
|
|
37
|
-
// Loaders must return {object, params} object.
|
|
38
|
-
let objectParams;
|
|
39
|
-
const transformations = (0, _sanitizeImageTransformations.default)(options);
|
|
40
|
-
if (transformations && _utils2.SUPPORTED_TRANSFORMABLE_IMAGES.includes(file.extension)) {
|
|
41
|
-
objectParams = (0, _utils.getObjectParams)((0, _utils2.getImageKey)({
|
|
42
|
-
key: file.name,
|
|
43
|
-
transformations
|
|
44
|
-
}));
|
|
45
|
-
try {
|
|
46
|
-
return {
|
|
47
|
-
object: await s3.getObject(objectParams).promise(),
|
|
48
|
-
params: objectParams
|
|
49
|
-
};
|
|
50
|
-
} catch (e) {
|
|
51
|
-
const imageTransformerLambdaResponse = await callImageTransformerLambda({
|
|
52
|
-
key: file.name,
|
|
53
|
-
transformations,
|
|
54
|
-
context
|
|
55
|
-
});
|
|
56
|
-
if (imageTransformerLambdaResponse.error) {
|
|
57
|
-
throw Error(imageTransformerLambdaResponse.message);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
object: await s3.getObject(objectParams).promise(),
|
|
61
|
-
params: objectParams
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
objectParams = (0, _utils.getObjectParams)((0, _utils2.getImageKey)({
|
|
66
|
-
key: file.name
|
|
67
|
-
}));
|
|
68
|
-
try {
|
|
69
|
-
return {
|
|
70
|
-
object: await s3.getObject(objectParams).promise(),
|
|
71
|
-
params: objectParams
|
|
72
|
-
};
|
|
73
|
-
} catch (e) {
|
|
74
|
-
const imageTransformerLambdaResponse = await callImageTransformerLambda({
|
|
75
|
-
key: file.name,
|
|
76
|
-
context
|
|
77
|
-
});
|
|
78
|
-
if (imageTransformerLambdaResponse.error) {
|
|
79
|
-
throw Error(imageTransformerLambdaResponse.message);
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
object: await s3.getObject(objectParams).promise(),
|
|
83
|
-
params: objectParams
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["IMAGE_TRANSFORMER_FUNCTION","process","env","callImageTransformerLambda","key","transformations","context","handlerClient","invoke","name","payload","body","canProcess","params","SUPPORTED_IMAGES","includes","file","extension","s3","options","objectParams","sanitizeImageTransformations","SUPPORTED_TRANSFORMABLE_IMAGES","getObjectParams","getImageKey","object","getObject","promise","e","imageTransformerLambdaResponse","error","Error","message"],"sources":["imageLoader.ts"],"sourcesContent":["import sanitizeImageTransformations from \"./sanitizeImageTransformations\";\nimport { getObjectParams } from \"../../utils\";\nimport { SUPPORTED_IMAGES, SUPPORTED_TRANSFORMABLE_IMAGES, getImageKey } from \"../utils\";\nimport { ClientContext } from \"@webiny/handler-client/types\";\nimport S3 from \"aws-sdk/clients/s3\";\n\nconst IMAGE_TRANSFORMER_FUNCTION = process.env.IMAGE_TRANSFORMER_FUNCTION as string;\n\ninterface TransformerParams {\n context: ClientContext;\n key: string;\n transformations?: {\n width?: number;\n };\n}\n\nconst callImageTransformerLambda = async ({ key, transformations, context }: TransformerParams) => {\n return await context.handlerClient.invoke({\n name: IMAGE_TRANSFORMER_FUNCTION,\n payload: {\n body: {\n key,\n transformations\n }\n }\n });\n};\ninterface File {\n extension: string;\n name: string;\n contentLength: number;\n}\ninterface Options {\n width?: string;\n}\nexport interface CanProcessParams {\n s3: S3;\n file: File;\n options?: Options;\n context: ClientContext;\n}\nexport interface ProcessParams {\n s3: S3;\n file: File;\n options?: Options;\n context: ClientContext;\n}\nexport default {\n canProcess: (params: CanProcessParams) => {\n return SUPPORTED_IMAGES.includes(params.file.extension);\n },\n async process({ s3, file, options, context }: ProcessParams) {\n // Loaders must return {object, params} object.\n let objectParams;\n\n const transformations = sanitizeImageTransformations(options);\n\n if (transformations && SUPPORTED_TRANSFORMABLE_IMAGES.includes(file.extension)) {\n objectParams = getObjectParams(getImageKey({ key: file.name, transformations }));\n try {\n return {\n object: await s3.getObject(objectParams).promise(),\n params: objectParams\n };\n } catch (e) {\n const imageTransformerLambdaResponse = await callImageTransformerLambda({\n key: file.name,\n transformations,\n context\n });\n\n if (imageTransformerLambdaResponse.error) {\n throw Error(imageTransformerLambdaResponse.message);\n }\n\n return {\n object: await s3.getObject(objectParams).promise(),\n params: objectParams\n };\n }\n }\n\n objectParams = getObjectParams(getImageKey({ key: file.name }));\n try {\n return {\n object: await s3.getObject(objectParams).promise(),\n params: objectParams\n };\n } catch (e) {\n const imageTransformerLambdaResponse = await callImageTransformerLambda({\n key: file.name,\n context\n });\n\n if (imageTransformerLambdaResponse.error) {\n throw Error(imageTransformerLambdaResponse.message);\n }\n\n return {\n object: await s3.getObject(objectParams).promise(),\n params: objectParams\n };\n }\n }\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAIA,MAAMA,0BAA0B,GAAGC,OAAO,CAACC,GAAG,CAACF,0BAAoC;AAUnF,MAAMG,0BAA0B,GAAG,OAAO;EAAEC,GAAG;EAAEC,eAAe;EAAEC;AAA2B,CAAC,KAAK;EAC/F,OAAO,MAAMA,OAAO,CAACC,aAAa,CAACC,MAAM,CAAC;IACtCC,IAAI,EAAET,0BAA0B;IAChCU,OAAO,EAAE;MACLC,IAAI,EAAE;QACFP,GAAG;QACHC;MACJ;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC,eAqBa;EACXO,UAAU,EAAGC,MAAwB,IAAK;IACtC,OAAOC,wBAAgB,CAACC,QAAQ,CAACF,MAAM,CAACG,IAAI,CAACC,SAAS,CAAC;EAC3D,CAAC;EACD,MAAMhB,OAAO,CAAC;IAAEiB,EAAE;IAAEF,IAAI;IAAEG,OAAO;IAAEb;EAAuB,CAAC,EAAE;IACzD;IACA,IAAIc,YAAY;IAEhB,MAAMf,eAAe,GAAG,IAAAgB,qCAA4B,EAACF,OAAO,CAAC;IAE7D,IAAId,eAAe,IAAIiB,sCAA8B,CAACP,QAAQ,CAACC,IAAI,CAACC,SAAS,CAAC,EAAE;MAC5EG,YAAY,GAAG,IAAAG,sBAAe,EAAC,IAAAC,mBAAW,EAAC;QAAEpB,GAAG,EAAEY,IAAI,CAACP,IAAI;QAAEJ;MAAgB,CAAC,CAAC,CAAC;MAChF,IAAI;QACA,OAAO;UACHoB,MAAM,EAAE,MAAMP,EAAE,CAACQ,SAAS,CAACN,YAAY,CAAC,CAACO,OAAO,EAAE;UAClDd,MAAM,EAAEO;QACZ,CAAC;MACL,CAAC,CAAC,OAAOQ,CAAC,EAAE;QACR,MAAMC,8BAA8B,GAAG,MAAM1B,0BAA0B,CAAC;UACpEC,GAAG,EAAEY,IAAI,CAACP,IAAI;UACdJ,eAAe;UACfC;QACJ,CAAC,CAAC;QAEF,IAAIuB,8BAA8B,CAACC,KAAK,EAAE;UACtC,MAAMC,KAAK,CAACF,8BAA8B,CAACG,OAAO,CAAC;QACvD;QAEA,OAAO;UACHP,MAAM,EAAE,MAAMP,EAAE,CAACQ,SAAS,CAACN,YAAY,CAAC,CAACO,OAAO,EAAE;UAClDd,MAAM,EAAEO;QACZ,CAAC;MACL;IACJ;IAEAA,YAAY,GAAG,IAAAG,sBAAe,EAAC,IAAAC,mBAAW,EAAC;MAAEpB,GAAG,EAAEY,IAAI,CAACP;IAAK,CAAC,CAAC,CAAC;IAC/D,IAAI;MACA,OAAO;QACHgB,MAAM,EAAE,MAAMP,EAAE,CAACQ,SAAS,CAACN,YAAY,CAAC,CAACO,OAAO,EAAE;QAClDd,MAAM,EAAEO;MACZ,CAAC;IACL,CAAC,CAAC,OAAOQ,CAAC,EAAE;MACR,MAAMC,8BAA8B,GAAG,MAAM1B,0BAA0B,CAAC;QACpEC,GAAG,EAAEY,IAAI,CAACP,IAAI;QACdH;MACJ,CAAC,CAAC;MAEF,IAAIuB,8BAA8B,CAACC,KAAK,EAAE;QACtC,MAAMC,KAAK,CAACF,8BAA8B,CAACG,OAAO,CAAC;MACvD;MAEA,OAAO;QACHP,MAAM,EAAE,MAAMP,EAAE,CAACQ,SAAS,CAACN,YAAY,CAAC,CAACO,OAAO,EAAE;QAClDd,MAAM,EAAEO;MACZ,CAAC;IACL;EACJ;AACJ,CAAC;AAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
canProcess: (params: import("./imageLoader").CanProcessParams) => boolean;
|
|
3
|
-
process({ s3, file, options, context }: import("./imageLoader").ProcessParams): Promise<{
|
|
4
|
-
object: import("aws-sdk/lib/request").PromiseResult<import("aws-sdk/clients/s3").GetObjectOutput, import("aws-sdk/lib/error").AWSError>;
|
|
5
|
-
params: import("../../utils/getObjectParams").ObjectParamsResponse;
|
|
6
|
-
}>;
|
|
7
|
-
}[];
|
|
8
|
-
export default _default;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _imageLoader = _interopRequireDefault(require("./imageLoader"));
|
|
9
|
-
var _default = [_imageLoader.default];
|
|
10
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["imageLoader"],"sources":["index.ts"],"sourcesContent":["import imageLoader from \"./imageLoader\";\n\nexport default [imageLoader];\n"],"mappings":";;;;;;;AAAA;AAAwC,eAEzB,CAACA,oBAAW,CAAC;AAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface SanitizeImageArgs {
|
|
2
|
-
width?: string;
|
|
3
|
-
}
|
|
4
|
-
export interface SanitizeImageTransformations {
|
|
5
|
-
width: number;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Takes only allowed transformations into consideration, and discards the rest.
|
|
9
|
-
*/
|
|
10
|
-
declare const _default: (args?: SanitizeImageArgs) => SanitizeImageTransformations | null;
|
|
11
|
-
export default _default;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
const SUPPORTED_IMAGE_RESIZE_WIDTHS = [100, 300, 500, 750, 1000, 1500, 2500];
|
|
8
|
-
/**
|
|
9
|
-
* Takes only allowed transformations into consideration, and discards the rest.
|
|
10
|
-
*/
|
|
11
|
-
var _default = args => {
|
|
12
|
-
const transformations = {};
|
|
13
|
-
if (!args || !args.width) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
const width = parseInt(args.width);
|
|
17
|
-
if (width <= 0) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
transformations.width = SUPPORTED_IMAGE_RESIZE_WIDTHS[0];
|
|
21
|
-
let i = SUPPORTED_IMAGE_RESIZE_WIDTHS.length;
|
|
22
|
-
while (i >= 0) {
|
|
23
|
-
if (width === SUPPORTED_IMAGE_RESIZE_WIDTHS[i]) {
|
|
24
|
-
transformations.width = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
if (width > SUPPORTED_IMAGE_RESIZE_WIDTHS[i]) {
|
|
28
|
-
// Use next larger width. If there isn't any, use current.
|
|
29
|
-
transformations.width = SUPPORTED_IMAGE_RESIZE_WIDTHS[i + 1];
|
|
30
|
-
if (!transformations.width) {
|
|
31
|
-
transformations.width = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];
|
|
32
|
-
}
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
i--;
|
|
36
|
-
}
|
|
37
|
-
if (Object.keys(transformations).length > 0) {
|
|
38
|
-
/**
|
|
39
|
-
* It is safe to cast.
|
|
40
|
-
*/
|
|
41
|
-
return transformations;
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
44
|
-
};
|
|
45
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["SUPPORTED_IMAGE_RESIZE_WIDTHS","args","transformations","width","parseInt","i","length","Object","keys"],"sources":["sanitizeImageTransformations.ts"],"sourcesContent":["const SUPPORTED_IMAGE_RESIZE_WIDTHS: number[] = [100, 300, 500, 750, 1000, 1500, 2500];\n\nexport interface SanitizeImageArgs {\n width?: string;\n}\n\nexport interface SanitizeImageTransformations {\n width: number;\n}\n/**\n * Takes only allowed transformations into consideration, and discards the rest.\n */\nexport default (args?: SanitizeImageArgs): SanitizeImageTransformations | null => {\n const transformations: Partial<SanitizeImageTransformations> = {};\n\n if (!args || !args.width) {\n return null;\n }\n const width = parseInt(args.width);\n if (width <= 0) {\n return null;\n }\n transformations.width = SUPPORTED_IMAGE_RESIZE_WIDTHS[0];\n let i = SUPPORTED_IMAGE_RESIZE_WIDTHS.length;\n while (i >= 0) {\n if (width === SUPPORTED_IMAGE_RESIZE_WIDTHS[i]) {\n transformations.width = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];\n break;\n }\n\n if (width > SUPPORTED_IMAGE_RESIZE_WIDTHS[i]) {\n // Use next larger width. If there isn't any, use current.\n transformations.width = SUPPORTED_IMAGE_RESIZE_WIDTHS[i + 1];\n if (!transformations.width) {\n transformations.width = SUPPORTED_IMAGE_RESIZE_WIDTHS[i];\n }\n break;\n }\n\n i--;\n }\n\n if (Object.keys(transformations).length > 0) {\n /**\n * It is safe to cast.\n */\n return transformations as SanitizeImageTransformations;\n }\n\n return null;\n};\n"],"mappings":";;;;;;AAAA,MAAMA,6BAAuC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;AAStF;AACA;AACA;AAFA,eAGgBC,IAAwB,IAA0C;EAC9E,MAAMC,eAAsD,GAAG,CAAC,CAAC;EAEjE,IAAI,CAACD,IAAI,IAAI,CAACA,IAAI,CAACE,KAAK,EAAE;IACtB,OAAO,IAAI;EACf;EACA,MAAMA,KAAK,GAAGC,QAAQ,CAACH,IAAI,CAACE,KAAK,CAAC;EAClC,IAAIA,KAAK,IAAI,CAAC,EAAE;IACZ,OAAO,IAAI;EACf;EACAD,eAAe,CAACC,KAAK,GAAGH,6BAA6B,CAAC,CAAC,CAAC;EACxD,IAAIK,CAAC,GAAGL,6BAA6B,CAACM,MAAM;EAC5C,OAAOD,CAAC,IAAI,CAAC,EAAE;IACX,IAAIF,KAAK,KAAKH,6BAA6B,CAACK,CAAC,CAAC,EAAE;MAC5CH,eAAe,CAACC,KAAK,GAAGH,6BAA6B,CAACK,CAAC,CAAC;MACxD;IACJ;IAEA,IAAIF,KAAK,GAAGH,6BAA6B,CAACK,CAAC,CAAC,EAAE;MAC1C;MACAH,eAAe,CAACC,KAAK,GAAGH,6BAA6B,CAACK,CAAC,GAAG,CAAC,CAAC;MAC5D,IAAI,CAACH,eAAe,CAACC,KAAK,EAAE;QACxBD,eAAe,CAACC,KAAK,GAAGH,6BAA6B,CAACK,CAAC,CAAC;MAC5D;MACA;IACJ;IAEAA,CAAC,EAAE;EACP;EAEA,IAAIE,MAAM,CAACC,IAAI,CAACN,eAAe,CAAC,CAACI,MAAM,GAAG,CAAC,EAAE;IACzC;AACR;AACA;IACQ,OAAOJ,eAAe;EAC1B;EAEA,OAAO,IAAI;AACf,CAAC;AAAA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _utils = require("../../utils");
|
|
8
|
-
var _utils2 = require("../utils");
|
|
9
|
-
var _default = {
|
|
10
|
-
canProcess: params => {
|
|
11
|
-
const {
|
|
12
|
-
key,
|
|
13
|
-
extension
|
|
14
|
-
} = params;
|
|
15
|
-
if (_utils2.SUPPORTED_IMAGES.includes(extension) === false) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// We only want to process original images, and delete all variations of it at once.
|
|
20
|
-
// We DO NOT want to process the event for the deletion of an optimized/transformed image.
|
|
21
|
-
// Unfortunately, there's no way to filter those events on the S3 bucket itself, so we have to do it this way.
|
|
22
|
-
return !(key.startsWith(_utils2.OPTIMIZED_IMAGE_PREFIX) || key.startsWith(_utils2.OPTIMIZED_TRANSFORMED_IMAGE_PREFIX));
|
|
23
|
-
},
|
|
24
|
-
async process({
|
|
25
|
-
s3,
|
|
26
|
-
key,
|
|
27
|
-
extension
|
|
28
|
-
}) {
|
|
29
|
-
// 1. Get optimized image's key.
|
|
30
|
-
|
|
31
|
-
await s3.deleteObject((0, _utils.getObjectParams)((0, _utils2.getImageKey)({
|
|
32
|
-
key
|
|
33
|
-
}))).promise();
|
|
34
|
-
|
|
35
|
-
// 2. Search for all transformed images and delete those too.
|
|
36
|
-
if (_utils2.SUPPORTED_TRANSFORMABLE_IMAGES.includes(extension) === false) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const env = (0, _utils.getEnvironment)();
|
|
40
|
-
const imagesList = await s3.listObjects({
|
|
41
|
-
Bucket: env.bucket,
|
|
42
|
-
Prefix: (0, _utils2.getOptimizedTransformedImageKeyPrefix)(key)
|
|
43
|
-
}).promise();
|
|
44
|
-
if (!imagesList.Contents) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
for (const imageObject of imagesList.Contents) {
|
|
48
|
-
if (!imageObject.Key) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
await s3.deleteObject((0, _utils.getObjectParams)(imageObject.Key)).promise();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["canProcess","params","key","extension","SUPPORTED_IMAGES","includes","startsWith","OPTIMIZED_IMAGE_PREFIX","OPTIMIZED_TRANSFORMED_IMAGE_PREFIX","process","s3","deleteObject","getObjectParams","getImageKey","promise","SUPPORTED_TRANSFORMABLE_IMAGES","env","getEnvironment","imagesList","listObjects","Bucket","bucket","Prefix","getOptimizedTransformedImageKeyPrefix","Contents","imageObject","Key"],"sources":["imageManager.ts"],"sourcesContent":["import S3 from \"aws-sdk/clients/s3\";\nimport { getObjectParams, getEnvironment } from \"~/handlers/utils\";\nimport {\n SUPPORTED_IMAGES,\n SUPPORTED_TRANSFORMABLE_IMAGES,\n OPTIMIZED_IMAGE_PREFIX,\n OPTIMIZED_TRANSFORMED_IMAGE_PREFIX,\n getImageKey,\n getOptimizedTransformedImageKeyPrefix\n} from \"../utils\";\n\nexport interface ImageManagerCanProcessParams {\n key: string;\n extension: string;\n}\nexport interface ImageManagerProcessParams {\n s3: S3;\n key: string;\n extension: string;\n}\nexport default {\n canProcess: (params: ImageManagerCanProcessParams) => {\n const { key, extension } = params;\n if (SUPPORTED_IMAGES.includes(extension) === false) {\n return false;\n }\n\n // We only want to process original images, and delete all variations of it at once.\n // We DO NOT want to process the event for the deletion of an optimized/transformed image.\n // Unfortunately, there's no way to filter those events on the S3 bucket itself, so we have to do it this way.\n return !(\n key.startsWith(OPTIMIZED_IMAGE_PREFIX) ||\n key.startsWith(OPTIMIZED_TRANSFORMED_IMAGE_PREFIX)\n );\n },\n async process({ s3, key, extension }: ImageManagerProcessParams) {\n // 1. Get optimized image's key.\n\n await s3.deleteObject(getObjectParams(getImageKey({ key }))).promise();\n\n // 2. Search for all transformed images and delete those too.\n if (SUPPORTED_TRANSFORMABLE_IMAGES.includes(extension) === false) {\n return;\n }\n const env = getEnvironment();\n const imagesList = await s3\n .listObjects({\n Bucket: env.bucket,\n Prefix: getOptimizedTransformedImageKeyPrefix(key)\n })\n .promise();\n\n if (!imagesList.Contents) {\n return;\n }\n\n for (const imageObject of imagesList.Contents) {\n if (!imageObject.Key) {\n continue;\n }\n await s3.deleteObject(getObjectParams(imageObject.Key)).promise();\n }\n }\n};\n"],"mappings":";;;;;;AACA;AACA;AAOkB,eAWH;EACXA,UAAU,EAAGC,MAAoC,IAAK;IAClD,MAAM;MAAEC,GAAG;MAAEC;IAAU,CAAC,GAAGF,MAAM;IACjC,IAAIG,wBAAgB,CAACC,QAAQ,CAACF,SAAS,CAAC,KAAK,KAAK,EAAE;MAChD,OAAO,KAAK;IAChB;;IAEA;IACA;IACA;IACA,OAAO,EACHD,GAAG,CAACI,UAAU,CAACC,8BAAsB,CAAC,IACtCL,GAAG,CAACI,UAAU,CAACE,0CAAkC,CAAC,CACrD;EACL,CAAC;EACD,MAAMC,OAAO,CAAC;IAAEC,EAAE;IAAER,GAAG;IAAEC;EAAqC,CAAC,EAAE;IAC7D;;IAEA,MAAMO,EAAE,CAACC,YAAY,CAAC,IAAAC,sBAAe,EAAC,IAAAC,mBAAW,EAAC;MAAEX;IAAI,CAAC,CAAC,CAAC,CAAC,CAACY,OAAO,EAAE;;IAEtE;IACA,IAAIC,sCAA8B,CAACV,QAAQ,CAACF,SAAS,CAAC,KAAK,KAAK,EAAE;MAC9D;IACJ;IACA,MAAMa,GAAG,GAAG,IAAAC,qBAAc,GAAE;IAC5B,MAAMC,UAAU,GAAG,MAAMR,EAAE,CACtBS,WAAW,CAAC;MACTC,MAAM,EAAEJ,GAAG,CAACK,MAAM;MAClBC,MAAM,EAAE,IAAAC,6CAAqC,EAACrB,GAAG;IACrD,CAAC,CAAC,CACDY,OAAO,EAAE;IAEd,IAAI,CAACI,UAAU,CAACM,QAAQ,EAAE;MACtB;IACJ;IAEA,KAAK,MAAMC,WAAW,IAAIP,UAAU,CAACM,QAAQ,EAAE;MAC3C,IAAI,CAACC,WAAW,CAACC,GAAG,EAAE;QAClB;MACJ;MACA,MAAMhB,EAAE,CAACC,YAAY,CAAC,IAAAC,sBAAe,EAACa,WAAW,CAACC,GAAG,CAAC,CAAC,CAACZ,OAAO,EAAE;IACrE;EACJ;AACJ,CAAC;AAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _imageManager = _interopRequireDefault(require("./imageManager"));
|
|
9
|
-
var _default = [_imageManager.default];
|
|
10
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["imageManager"],"sources":["index.ts"],"sourcesContent":["import imageManager from \"./imageManager\";\n\nexport default [imageManager];\n"],"mappings":";;;;;;;AAAA;AAA0C,eAE3B,CAACA,qBAAY,CAAC;AAAA"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _sharp = _interopRequireDefault(require("sharp"));
|
|
9
|
-
/**
|
|
10
|
-
* Sharp is included in the AWS Lambda layer
|
|
11
|
-
*/
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
var _default = async (buffer, type) => {
|
|
14
|
-
switch (type) {
|
|
15
|
-
case "image/png":
|
|
16
|
-
{
|
|
17
|
-
return await (0, _sharp.default)(buffer).resize({
|
|
18
|
-
width: 2560,
|
|
19
|
-
withoutEnlargement: true,
|
|
20
|
-
fit: "inside"
|
|
21
|
-
}).png({
|
|
22
|
-
compressionLevel: 9,
|
|
23
|
-
adaptiveFiltering: true,
|
|
24
|
-
force: true
|
|
25
|
-
}).withMetadata().toBuffer();
|
|
26
|
-
}
|
|
27
|
-
case "image/jpeg":
|
|
28
|
-
case "image/jpg":
|
|
29
|
-
{
|
|
30
|
-
return await (0, _sharp.default)(buffer).resize({
|
|
31
|
-
width: 2560,
|
|
32
|
-
withoutEnlargement: true,
|
|
33
|
-
fit: "inside"
|
|
34
|
-
}).toFormat("jpeg", {
|
|
35
|
-
quality: 90
|
|
36
|
-
}).toBuffer();
|
|
37
|
-
}
|
|
38
|
-
default:
|
|
39
|
-
return buffer;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["buffer","type","sharp","resize","width","withoutEnlargement","fit","png","compressionLevel","adaptiveFiltering","force","withMetadata","toBuffer","toFormat","quality"],"sources":["optimizeImage.ts"],"sourcesContent":["/**\n * Sharp is included in the AWS Lambda layer\n */\n// @ts-ignore\nimport sharp from \"sharp\";\nimport { Body } from \"aws-sdk/clients/s3\";\n\nexport default async (buffer: Body, type: string): Promise<Body> => {\n switch (type) {\n case \"image/png\": {\n return await sharp(buffer)\n .resize({ width: 2560, withoutEnlargement: true, fit: \"inside\" })\n .png({ compressionLevel: 9, adaptiveFiltering: true, force: true })\n .withMetadata()\n .toBuffer();\n }\n case \"image/jpeg\":\n case \"image/jpg\": {\n return await sharp(buffer)\n .resize({ width: 2560, withoutEnlargement: true, fit: \"inside\" })\n .toFormat(\"jpeg\", { quality: 90 })\n .toBuffer();\n }\n default:\n return buffer;\n }\n};\n"],"mappings":";;;;;;;AAIA;AAJA;AACA;AACA;AACA;AAAA,eAIe,OAAOA,MAAY,EAAEC,IAAY,KAAoB;EAChE,QAAQA,IAAI;IACR,KAAK,WAAW;MAAE;QACd,OAAO,MAAM,IAAAC,cAAK,EAACF,MAAM,CAAC,CACrBG,MAAM,CAAC;UAAEC,KAAK,EAAE,IAAI;UAAEC,kBAAkB,EAAE,IAAI;UAAEC,GAAG,EAAE;QAAS,CAAC,CAAC,CAChEC,GAAG,CAAC;UAAEC,gBAAgB,EAAE,CAAC;UAAEC,iBAAiB,EAAE,IAAI;UAAEC,KAAK,EAAE;QAAK,CAAC,CAAC,CAClEC,YAAY,EAAE,CACdC,QAAQ,EAAE;MACnB;IACA,KAAK,YAAY;IACjB,KAAK,WAAW;MAAE;QACd,OAAO,MAAM,IAAAV,cAAK,EAACF,MAAM,CAAC,CACrBG,MAAM,CAAC;UAAEC,KAAK,EAAE,IAAI;UAAEC,kBAAkB,EAAE,IAAI;UAAEC,GAAG,EAAE;QAAS,CAAC,CAAC,CAChEO,QAAQ,CAAC,MAAM,EAAE;UAAEC,OAAO,EAAE;QAAG,CAAC,CAAC,CACjCF,QAAQ,EAAE;MACnB;IACA;MACI,OAAOZ,MAAM;EAAC;AAE1B,CAAC;AAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Body } from "aws-sdk/clients/s3";
|
|
2
|
-
interface Transformation {
|
|
3
|
-
width: string;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* Only processing "width" at the moment.
|
|
7
|
-
* Check "sanitizeImageTransformations.js" to allow additional image processing transformations.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: (buffer: Body, transformations: Transformation) => Promise<Body>;
|
|
10
|
-
export default _default;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _sharp = _interopRequireDefault(require("sharp"));
|
|
9
|
-
/**
|
|
10
|
-
* Sharp is included in the AWS Lambda layer
|
|
11
|
-
*/
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
/**
|
|
14
|
-
* Only processing "width" at the moment.
|
|
15
|
-
* Check "sanitizeImageTransformations.js" to allow additional image processing transformations.
|
|
16
|
-
*/
|
|
17
|
-
var _default = async (buffer, transformations) => {
|
|
18
|
-
const {
|
|
19
|
-
width
|
|
20
|
-
} = transformations;
|
|
21
|
-
return await (0, _sharp.default)(buffer).resize({
|
|
22
|
-
width
|
|
23
|
-
}).toBuffer();
|
|
24
|
-
};
|
|
25
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["buffer","transformations","width","sharp","resize","toBuffer"],"sources":["transformImage.ts"],"sourcesContent":["/**\n * Sharp is included in the AWS Lambda layer\n */\n// @ts-ignore\nimport sharp from \"sharp\";\nimport { Body } from \"aws-sdk/clients/s3\";\n\ninterface Transformation {\n width: string;\n}\n/**\n * Only processing \"width\" at the moment.\n * Check \"sanitizeImageTransformations.js\" to allow additional image processing transformations.\n */\nexport default async (buffer: Body, transformations: Transformation): Promise<Body> => {\n const { width } = transformations;\n return await sharp(buffer).resize({ width }).toBuffer();\n};\n"],"mappings":";;;;;;;AAIA;AAJA;AACA;AACA;AACA;AAOA;AACA;AACA;AACA;AAHA,eAIe,OAAOA,MAAY,EAAEC,eAA+B,KAAoB;EACnF,MAAM;IAAEC;EAAM,CAAC,GAAGD,eAAe;EACjC,OAAO,MAAM,IAAAE,cAAK,EAACH,MAAM,CAAC,CAACI,MAAM,CAAC;IAAEF;EAAM,CAAC,CAAC,CAACG,QAAQ,EAAE;AAC3D,CAAC;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["SUPPORTED_IMAGES","SUPPORTED_TRANSFORMABLE_IMAGES","OPTIMIZED_TRANSFORMED_IMAGE_PREFIX","OPTIMIZED_IMAGE_PREFIX","getOptimizedImageKeyPrefix","key","objectHash","getOptimizedTransformedImageKeyPrefix","getImageKey","transformations","prefix"],"sources":["utils.ts"],"sourcesContent":["import objectHash from \"object-hash\";\n\nconst SUPPORTED_IMAGES = [\".jpg\", \".jpeg\", \".png\", \".svg\", \".gif\"];\nconst SUPPORTED_TRANSFORMABLE_IMAGES = [\".jpg\", \".jpeg\", \".png\"];\n\nconst OPTIMIZED_TRANSFORMED_IMAGE_PREFIX = \"img-o-t-\";\nconst OPTIMIZED_IMAGE_PREFIX = \"img-o-\";\n\nconst getOptimizedImageKeyPrefix = (key: string): string => {\n return `${OPTIMIZED_IMAGE_PREFIX}${objectHash(key)}-`;\n};\n\nconst getOptimizedTransformedImageKeyPrefix = (key: string): string => {\n return `${OPTIMIZED_TRANSFORMED_IMAGE_PREFIX}${objectHash(key)}-`;\n};\n\ninterface GetImageKeyParams {\n key: string;\n transformations?: any;\n}\n\nconst getImageKey = ({ key, transformations }: GetImageKeyParams): string => {\n if (!transformations) {\n const prefix = getOptimizedImageKeyPrefix(key);\n return prefix + key;\n }\n\n const prefix = getOptimizedTransformedImageKeyPrefix(key);\n return `${prefix}${objectHash(transformations)}-${key}`;\n};\n\nexport {\n SUPPORTED_IMAGES,\n SUPPORTED_TRANSFORMABLE_IMAGES,\n OPTIMIZED_TRANSFORMED_IMAGE_PREFIX,\n OPTIMIZED_IMAGE_PREFIX,\n getImageKey,\n getOptimizedImageKeyPrefix,\n getOptimizedTransformedImageKeyPrefix\n};\n"],"mappings":";;;;;;;AAAA;AAEA,MAAMA,gBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;AAAC;AACnE,MAAMC,8BAA8B,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC;AAAC;AAEjE,MAAMC,kCAAkC,GAAG,UAAU;AAAC;AACtD,MAAMC,sBAAsB,GAAG,QAAQ;AAAC;AAExC,MAAMC,0BAA0B,GAAIC,GAAW,IAAa;EACxD,OAAQ,GAAEF,sBAAuB,GAAE,IAAAG,mBAAU,EAACD,GAAG,CAAE,GAAE;AACzD,CAAC;AAAC;AAEF,MAAME,qCAAqC,GAAIF,GAAW,IAAa;EACnE,OAAQ,GAAEH,kCAAmC,GAAE,IAAAI,mBAAU,EAACD,GAAG,CAAE,GAAE;AACrE,CAAC;AAAC;AAOF,MAAMG,WAAW,GAAG,CAAC;EAAEH,GAAG;EAAEI;AAAmC,CAAC,KAAa;EACzE,IAAI,CAACA,eAAe,EAAE;IAClB,MAAMC,MAAM,GAAGN,0BAA0B,CAACC,GAAG,CAAC;IAC9C,OAAOK,MAAM,GAAGL,GAAG;EACvB;EAEA,MAAMK,MAAM,GAAGH,qCAAqC,CAACF,GAAG,CAAC;EACzD,OAAQ,GAAEK,MAAO,GAAE,IAAAJ,mBAAU,EAACG,eAAe,CAAE,IAAGJ,GAAI,EAAC;AAC3D,CAAC;AAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _FilePlugin = require("../../definitions/FilePlugin");
|
|
9
|
-
var _createFileModel = _interopRequireDefault(require("../utils/createFileModel"));
|
|
10
|
-
var _default = () => [new _FilePlugin.FilePlugin({
|
|
11
|
-
beforeCreate: async ({
|
|
12
|
-
data
|
|
13
|
-
}) => {
|
|
14
|
-
const FileModel = (0, _createFileModel.default)();
|
|
15
|
-
const fileData = new FileModel().populate(data);
|
|
16
|
-
await fileData.validate();
|
|
17
|
-
},
|
|
18
|
-
beforeUpdate: async ({
|
|
19
|
-
data
|
|
20
|
-
}) => {
|
|
21
|
-
const FileModel = (0, _createFileModel.default)(false);
|
|
22
|
-
const updatedFileData = new FileModel().populate(data);
|
|
23
|
-
await updatedFileData.validate();
|
|
24
|
-
},
|
|
25
|
-
beforeBatchCreate: async ({
|
|
26
|
-
data
|
|
27
|
-
}) => {
|
|
28
|
-
const FileModel = (0, _createFileModel.default)();
|
|
29
|
-
for (const input of data) {
|
|
30
|
-
const fileInstance = new FileModel().populate(input);
|
|
31
|
-
await fileInstance.validate();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
})];
|
|
35
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["FilePlugin","beforeCreate","data","FileModel","createFileModel","fileData","populate","validate","beforeUpdate","updatedFileData","beforeBatchCreate","input","fileInstance"],"sources":["validation.ts"],"sourcesContent":["import { FilePlugin } from \"~/plugins/definitions/FilePlugin\";\nimport createFileModel from \"~/plugins/crud/utils/createFileModel\";\n\nexport default (): FilePlugin[] => [\n new FilePlugin({\n beforeCreate: async ({ data }) => {\n const FileModel = createFileModel();\n const fileData = new FileModel().populate(data);\n await fileData.validate();\n },\n beforeUpdate: async ({ data }) => {\n const FileModel = createFileModel(false);\n const updatedFileData = new FileModel().populate(data);\n await updatedFileData.validate();\n },\n beforeBatchCreate: async ({ data }) => {\n const FileModel = createFileModel();\n for (const input of data) {\n const fileInstance = new FileModel().populate(input);\n await fileInstance.validate();\n }\n }\n })\n];\n"],"mappings":";;;;;;;AAAA;AACA;AAAmE,eAEpD,MAAoB,CAC/B,IAAIA,sBAAU,CAAC;EACXC,YAAY,EAAE,OAAO;IAAEC;EAAK,CAAC,KAAK;IAC9B,MAAMC,SAAS,GAAG,IAAAC,wBAAe,GAAE;IACnC,MAAMC,QAAQ,GAAG,IAAIF,SAAS,EAAE,CAACG,QAAQ,CAACJ,IAAI,CAAC;IAC/C,MAAMG,QAAQ,CAACE,QAAQ,EAAE;EAC7B,CAAC;EACDC,YAAY,EAAE,OAAO;IAAEN;EAAK,CAAC,KAAK;IAC9B,MAAMC,SAAS,GAAG,IAAAC,wBAAe,EAAC,KAAK,CAAC;IACxC,MAAMK,eAAe,GAAG,IAAIN,SAAS,EAAE,CAACG,QAAQ,CAACJ,IAAI,CAAC;IACtD,MAAMO,eAAe,CAACF,QAAQ,EAAE;EACpC,CAAC;EACDG,iBAAiB,EAAE,OAAO;IAAER;EAAK,CAAC,KAAK;IACnC,MAAMC,SAAS,GAAG,IAAAC,wBAAe,GAAE;IACnC,KAAK,MAAMO,KAAK,IAAIT,IAAI,EAAE;MACtB,MAAMU,YAAY,GAAG,IAAIT,SAAS,EAAE,CAACG,QAAQ,CAACK,KAAK,CAAC;MACpD,MAAMC,YAAY,CAACL,QAAQ,EAAE;IACjC;EACJ;AACJ,CAAC,CAAC,CACL;AAAA"}
|