@webiny/api-file-manager 0.0.0-unstable.99666aeb00 → 0.0.0-unstable.a9593f74dd
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.js +8 -6
- package/FileManagerContextSetup.js.map +1 -1
- package/cmsFileStorage/CmsFilesStorage.js +28 -25
- package/cmsFileStorage/CmsFilesStorage.js.map +1 -1
- package/cmsFileStorage/ListFilesWhereProcessor.js +8 -10
- package/cmsFileStorage/ListFilesWhereProcessor.js.map +1 -1
- package/cmsFileStorage/ListTagsWhereProcessor.js +8 -10
- package/cmsFileStorage/ListTagsWhereProcessor.js.map +1 -1
- package/cmsFileStorage/createFileManagerPlugins.d.ts +5 -3
- package/cmsFileStorage/createFileManagerPlugins.js +8 -25
- package/cmsFileStorage/createFileManagerPlugins.js.map +1 -1
- package/cmsFileStorage/createModelField.js +5 -1
- package/cmsFileStorage/createModelField.js.map +1 -1
- package/cmsFileStorage/file.model.d.ts +5 -3
- package/cmsFileStorage/file.model.js +64 -29
- package/cmsFileStorage/file.model.js.map +1 -1
- package/cmsFileStorage/isInstallationPending.js +3 -1
- package/cmsFileStorage/isInstallationPending.js.map +1 -1
- package/contants.js +3 -1
- package/contants.js.map +1 -1
- package/createFileManager/files.crud.js +83 -55
- package/createFileManager/files.crud.js.map +1 -1
- package/createFileManager/index.js +8 -5
- package/createFileManager/index.js.map +1 -1
- package/createFileManager/permissions/FilesPermissions.js +3 -1
- package/createFileManager/permissions/FilesPermissions.js.map +1 -1
- package/createFileManager/settings.crud.js +28 -12
- package/createFileManager/settings.crud.js.map +1 -1
- package/createFileManager/system.crud.js +6 -4
- package/createFileManager/system.crud.js.map +1 -1
- package/delivery/AssetDelivery/AliasAssetRequestResolver.d.ts +10 -0
- package/delivery/AssetDelivery/AliasAssetRequestResolver.js +74 -0
- package/delivery/AssetDelivery/AliasAssetRequestResolver.js.map +1 -0
- package/delivery/AssetDelivery/Asset.d.ts +30 -0
- package/delivery/AssetDelivery/Asset.js +64 -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 +24 -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 +33 -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 +5 -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 +4 -0
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js +18 -0
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.d.ts +7 -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 +62 -0
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/PublicCache.d.ts +4 -0
- package/delivery/AssetDelivery/privateFiles/PublicCache.js +18 -0
- package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +1 -0
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.d.ts +6 -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 +6 -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 +19 -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 +25 -0
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +1 -0
- package/delivery/index.d.ts +15 -0
- package/delivery/index.js +172 -0
- package/delivery/index.js.map +1 -0
- package/delivery/setupAssetDelivery.d.ts +6 -0
- package/delivery/setupAssetDelivery.js +124 -0
- package/delivery/setupAssetDelivery.js.map +1 -0
- package/graphql/baseSchema.js +4 -1
- package/graphql/baseSchema.js.map +1 -1
- package/graphql/createFilesTypeDefs.js +29 -6
- package/graphql/createFilesTypeDefs.js.map +1 -1
- package/graphql/filesSchema.js +13 -5
- package/graphql/filesSchema.js.map +1 -1
- 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 +2 -1
- package/graphql/index.js +24 -2
- package/graphql/index.js.map +1 -1
- package/graphql/utils.js +3 -1
- package/graphql/utils.js.map +1 -1
- package/handlers/{transform/managers → manage}/imageManager.d.ts +2 -3
- package/handlers/{transform/managers → manage}/imageManager.js +11 -9
- 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 → manage}/legacyUtils.d.ts +0 -5
- package/handlers/{transform → manage}/legacyUtils.js +3 -7
- package/handlers/manage/legacyUtils.js.map +1 -0
- package/handlers/{transform → manage}/utils.js +3 -1
- 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 +4 -1
- package/index.js +27 -7
- package/index.js.map +1 -1
- package/modelModifier/CmsModelModifier.d.ts +3 -1
- package/modelModifier/CmsModelModifier.js +13 -10
- package/modelModifier/CmsModelModifier.js.map +1 -1
- package/package.json +26 -26
- package/plugins/FilePhysicalStoragePlugin.js +3 -3
- package/plugins/FilePhysicalStoragePlugin.js.map +1 -1
- package/plugins/FileStorageTransformPlugin.js +3 -4
- package/plugins/FileStorageTransformPlugin.js.map +1 -1
- package/plugins/index.js +3 -1
- package/plugins/index.js.map +1 -1
- package/storage/FileStorage.d.ts +2 -1
- package/storage/FileStorage.js +20 -16
- package/storage/FileStorage.js.map +1 -1
- package/types/file.d.ts +11 -0
- package/types/file.js +3 -1
- package/types/file.js.map +1 -1
- package/types/file.lifecycle.js +3 -1
- package/types.d.ts +22 -2
- package/types.js +3 -1
- package/types.js.map +1 -1
- package/createFileManager/filevalidation.disabled.d.ts +0 -0
- package/createFileManager/filevalidation.disabled.js +0 -55
- package/createFileManager/filevalidation.disabled.js.map +0 -1
- package/handlers/download/byAlias.d.ts +0 -6
- package/handlers/download/byAlias.js +0 -89
- package/handlers/download/byAlias.js.map +0 -1
- package/handlers/download/byExactKey.d.ts +0 -2
- package/handlers/download/byExactKey.js +0 -57
- package/handlers/download/byExactKey.js.map +0 -1
- package/handlers/download/extractFileInformation.d.ts +0 -9
- package/handlers/download/extractFileInformation.js +0 -20
- package/handlers/download/extractFileInformation.js.map +0 -1
- package/handlers/download/getS3Object.d.ts +0 -12
- package/handlers/download/getS3Object.js +0 -72
- package/handlers/download/getS3Object.js.map +0 -1
- package/handlers/download/index.d.ts +0 -2
- package/handlers/download/index.js +0 -27
- package/handlers/download/index.js.map +0 -1
- package/handlers/transform/index.d.ts +0 -2
- package/handlers/transform/index.js +0 -92
- package/handlers/transform/index.js.map +0 -1
- package/handlers/transform/legacyUtils.js.map +0 -1
- package/handlers/transform/loaders/imageLoader.d.ts +0 -30
- package/handlers/transform/loaders/imageLoader.js +0 -94
- 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.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 -13
- package/handlers/transform/transformImage.js +0 -28
- package/handlers/transform/transformImage.js.map +0 -1
- package/handlers/transform/utils.js.map +0 -1
- /package/handlers/{transform → manage}/utils.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CreateDataModel","withFields","uploadMinFileSize","number","value","validation","create","uploadMaxFileSize","srcPrefix","onSet","endsWith","string","UpdateDataModel","createSettingsCrud","storageOperations","getTenantId","getSettings","settings","get","tenant","createSettings","data","populate","validate","settingsData","toJSON","updateSettings","updatedValue","existingSettings","updatedSettings","onlyDirty","
|
|
1
|
+
{"version":3,"names":["_pubsub","require","_fields","_validation","CreateDataModel","withFields","uploadMinFileSize","number","value","validation","create","uploadMaxFileSize","srcPrefix","onSet","endsWith","string","UpdateDataModel","createSettingsCrud","storageOperations","getTenantId","onSettingsBeforeUpdate","createTopic","onSettingsAfterUpdate","getSettings","settings","get","tenant","createSettings","data","populate","validate","settingsData","toJSON","updateSettings","updatedValue","existingSettings","updatedSettings","onlyDirty","publish","input","original","result","update","deleteSettings","delete","exports"],"sources":["settings.crud.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\n/**\n * Package @commodo/fields does not have types.\n */\n// @ts-expect-error\nimport { withFields, string, number, onSet } from \"@commodo/fields\";\nimport { validation } from \"@webiny/validation\";\nimport { FileManagerSettings, SettingsCRUD } from \"~/types\";\nimport { FileManagerConfig } from \"~/createFileManager/index\";\n\nconst CreateDataModel = withFields({\n uploadMinFileSize: number({ value: 0, validation: validation.create(\"gte:0\") }),\n uploadMaxFileSize: number({ value: 10737418240 }),\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\nexport const createSettingsCrud = ({\n storageOperations,\n getTenantId\n}: FileManagerConfig): SettingsCRUD => {\n return {\n onSettingsBeforeUpdate: createTopic(\"fileManager.onSettingsBeforeUpdate\"),\n onSettingsAfterUpdate: createTopic(\"fileManager.onSettingsAfterUpdate\"),\n async getSettings() {\n return storageOperations.settings.get({ tenant: getTenantId() });\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.settings.create({\n data: { ...settingsData, tenant: getTenantId() }\n });\n },\n async updateSettings(data) {\n const updatedValue = new UpdateDataModel().populate(data);\n await updatedValue.validate();\n\n const existingSettings = (await storageOperations.settings.get({\n tenant: getTenantId()\n })) as FileManagerSettings;\n\n const updatedSettings: Partial<FileManagerSettings> = await updatedValue.toJSON({\n onlyDirty: true\n });\n\n const settings: FileManagerSettings = {\n ...existingSettings,\n ...updatedSettings,\n tenant: getTenantId()\n };\n\n await this.onSettingsBeforeUpdate.publish({\n input: data,\n original: existingSettings,\n settings\n });\n const result = await storageOperations.settings.update({\n original: existingSettings,\n data: settings\n });\n await this.onSettingsAfterUpdate.publish({\n input: data,\n original: existingSettings,\n settings: result\n });\n\n return result;\n },\n async deleteSettings() {\n await storageOperations.settings.delete({ tenant: getTenantId() });\n\n return true;\n }\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AALA;AACA;AACA,GAFA,CAGA;AAMA,MAAMG,eAAe,GAAG,IAAAC,kBAAU,EAAC;EAC/BC,iBAAiB,EAAE,IAAAC,cAAM,EAAC;IAAEC,KAAK,EAAE,CAAC;IAAEC,UAAU,EAAEA,sBAAU,CAACC,MAAM,CAAC,OAAO;EAAE,CAAC,CAAC;EAC/EC,iBAAiB,EAAE,IAAAJ,cAAM,EAAC;IAAEC,KAAK,EAAE;EAAY,CAAC,CAAC;EACjDI,SAAS,EAAE,IAAAC,aAAK,EAAEL,KAAc,IAAK;IAC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AAM;IACjB,CAAC;IACD,MAAME,cAAcA,CAAA,EAAG;MACnB,MAAMzB,iBAAiB,CAACM,QAAQ,CAACoB,MAAM,CAAC;QAAElB,MAAM,EAAEP,WAAW,CAAC;MAAE,CAAC,CAAC;MAElE,OAAO,IAAI;IACf;EACJ,CAAC;AACL,CAAC;AAAC0B,OAAA,CAAA5B,kBAAA,GAAAA,kBAAA"}
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.createSystemCrud = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
8
|
var _pubsub = require("@webiny/pubsub");
|
|
10
9
|
var _apiSecurity = require("@webiny/api-security");
|
|
11
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
@@ -29,10 +28,11 @@ const createSystemCrud = ({
|
|
|
29
28
|
tenant: getTenantId()
|
|
30
29
|
});
|
|
31
30
|
if (system) {
|
|
32
|
-
const data =
|
|
31
|
+
const data = {
|
|
32
|
+
...system,
|
|
33
33
|
tenant: system.tenant || getTenantId(),
|
|
34
34
|
version
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
try {
|
|
37
37
|
await storageOperations.system.update({
|
|
38
38
|
original: system,
|
|
@@ -83,4 +83,6 @@ const createSystemCrud = ({
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
|
-
exports.createSystemCrud = createSystemCrud;
|
|
86
|
+
exports.createSystemCrud = createSystemCrud;
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=system.crud.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSystemCrud","storageOperations","getTenantId","getIdentity","WEBINY_VERSION","onSystemBeforeInstall","createTopic","onSystemAfterInstall","getVersion","system","get","tenant","version","setVersion","data","update","original","ex","WebinyError","create","install","srcPrefix","identity","NotAuthorizedError","publish","createSettings"],"sources":["system.crud.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport {\n FileManagerContextObject,\n FileManagerSettings,\n FileManagerSystem,\n SystemCRUD\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { FileManagerConfig } from \"~/createFileManager/index\";\n\nexport const createSystemCrud = ({\n storageOperations,\n getTenantId,\n getIdentity,\n WEBINY_VERSION\n}: FileManagerConfig): SystemCRUD => {\n return {\n onSystemBeforeInstall: createTopic(\"fileManager.onSystemBeforeInstall\"),\n onSystemAfterInstall: createTopic(\"fileManager.onSystemAfterInstall\"),\n async getVersion() {\n const system = await storageOperations.system.get({ tenant: getTenantId() });\n\n return system ? system.version : null;\n },\n async setVersion(version: string) {\n const system = await storageOperations.system.get({ tenant: getTenantId() });\n\n if (system) {\n const data: FileManagerSystem = {\n ...system,\n tenant: system.tenant || getTenantId(),\n version\n };\n try {\n await storageOperations.system.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.system.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(this: FileManagerContextObject, { srcPrefix }) {\n const identity = getIdentity();\n\n if (!identity) {\n throw new NotAuthorizedError();\n }\n\n const version = await this.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 await this.onSystemBeforeInstall.publish({});\n\n await this.createSettings(data);\n await this.setVersion(WEBINY_VERSION);\n\n await this.onSystemAfterInstall.publish({});\n\n return true;\n }\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_pubsub","require","_apiSecurity","_error","_interopRequireDefault","createSystemCrud","storageOperations","getTenantId","getIdentity","WEBINY_VERSION","onSystemBeforeInstall","createTopic","onSystemAfterInstall","getVersion","system","get","tenant","version","setVersion","data","update","original","ex","WebinyError","create","install","srcPrefix","identity","NotAuthorizedError","publish","createSettings","exports"],"sources":["system.crud.ts"],"sourcesContent":["import { createTopic } from \"@webiny/pubsub\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport {\n FileManagerContextObject,\n FileManagerSettings,\n FileManagerSystem,\n SystemCRUD\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { FileManagerConfig } from \"~/createFileManager/index\";\n\nexport const createSystemCrud = ({\n storageOperations,\n getTenantId,\n getIdentity,\n WEBINY_VERSION\n}: FileManagerConfig): SystemCRUD => {\n return {\n onSystemBeforeInstall: createTopic(\"fileManager.onSystemBeforeInstall\"),\n onSystemAfterInstall: createTopic(\"fileManager.onSystemAfterInstall\"),\n async getVersion() {\n const system = await storageOperations.system.get({ tenant: getTenantId() });\n\n return system ? system.version : null;\n },\n async setVersion(version: string) {\n const system = await storageOperations.system.get({ tenant: getTenantId() });\n\n if (system) {\n const data: FileManagerSystem = {\n ...system,\n tenant: system.tenant || getTenantId(),\n version\n };\n try {\n await storageOperations.system.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.system.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(this: FileManagerContextObject, { srcPrefix }) {\n const identity = getIdentity();\n\n if (!identity) {\n throw new NotAuthorizedError();\n }\n\n const version = await this.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 await this.onSystemBeforeInstall.publish({});\n\n await this.createSettings(data);\n await this.setVersion(WEBINY_VERSION);\n\n await this.onSystemAfterInstall.publish({});\n\n return true;\n }\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAGO,MAAMI,gBAAgB,GAAGA,CAAC;EAC7BC,iBAAiB;EACjBC,WAAW;EACXC,WAAW;EACXC;AACe,CAAC,KAAiB;EACjC,OAAO;IACHC,qBAAqB,EAAE,IAAAC,mBAAW,EAAC,mCAAmC,CAAC;IACvEC,oBAAoB,EAAE,IAAAD,mBAAW,EAAC,kCAAkC,CAAC;IACrE,MAAME,UAAUA,CAAA,EAAG;MACf,MAAMC,MAAM,GAAG,MAAMR,iBAAiB,CAACQ,MAAM,CAACC,GAAG,CAAC;QAAEC,MAAM,EAAET,WAAW,CAAC;MAAE,CAAC,CAAC;MAE5E,OAAOO,MAAM,GAAGA,MAAM,CAACG,OAAO,GAAG,IAAI;IACzC,CAAC;IACD,MAAMC,UAAUA,CAACD,OAAe,EAAE;MAC9B,MAAMH,MAAM,GAAG,MAAMR,iBAAiB,CAACQ,MAAM,CAACC,GAAG,CAAC;QAAEC,MAAM,EAAET,WAAW,CAAC;MAAE,CAAC,CAAC;MAE5E,IAAIO,MAAM,EAAE;QACR,MAAMK,IAAuB,GAAG;UAC5B,GAAGL,MAAM;UACTE,MAAM,EAAEF,MAAM,CAACE,MAAM,IAAIT,WAAW,CAAC,CAAC;UACtCU;QACJ,CAAC;QACD,IAAI;UACA,MAAMX,iBAAiB,CAACQ,MAAM,CAACM,MAAM,CAAC;YAClCC,QAAQ,EAAEP,MAAM;YAChBK;UACJ,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}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Request } from "@webiny/handler/types";
|
|
2
|
+
import { DynamoDBClient } from "@webiny/aws-sdk/client-dynamodb";
|
|
3
|
+
import { AssetRequest, AssetRequestResolver } from "..";
|
|
4
|
+
export declare class AliasAssetRequestResolver implements AssetRequestResolver {
|
|
5
|
+
private documentClient;
|
|
6
|
+
private resolver;
|
|
7
|
+
constructor(documentClient: DynamoDBClient, resolver: AssetRequestResolver);
|
|
8
|
+
resolve(request: Request): Promise<AssetRequest | undefined>;
|
|
9
|
+
private getFileByAlias;
|
|
10
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AliasAssetRequestResolver = void 0;
|
|
7
|
+
var _clientDynamodb = require("@webiny/aws-sdk/client-dynamodb");
|
|
8
|
+
var _ = require("./..");
|
|
9
|
+
class AliasAssetRequestResolver {
|
|
10
|
+
constructor(documentClient, resolver) {
|
|
11
|
+
this.documentClient = documentClient;
|
|
12
|
+
this.resolver = resolver;
|
|
13
|
+
}
|
|
14
|
+
async resolve(request) {
|
|
15
|
+
const resolvedAsset = await this.resolver.resolve(request);
|
|
16
|
+
if (resolvedAsset) {
|
|
17
|
+
return resolvedAsset;
|
|
18
|
+
}
|
|
19
|
+
const params = request.params ?? {};
|
|
20
|
+
const query = request.query ?? {};
|
|
21
|
+
const path = decodeURI(params["*"]);
|
|
22
|
+
const tenant = query.tenant || "root";
|
|
23
|
+
const fileKey = await this.getFileByAlias(tenant, path);
|
|
24
|
+
if (!fileKey) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const {
|
|
28
|
+
original,
|
|
29
|
+
...options
|
|
30
|
+
} = query;
|
|
31
|
+
return new _.AssetRequest({
|
|
32
|
+
key: fileKey,
|
|
33
|
+
context: {
|
|
34
|
+
url: request.url
|
|
35
|
+
},
|
|
36
|
+
options: {
|
|
37
|
+
original: original !== undefined,
|
|
38
|
+
...options
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async getFileByAlias(tenant, alias) {
|
|
43
|
+
const {
|
|
44
|
+
Items
|
|
45
|
+
} = await this.documentClient.send(new _clientDynamodb.QueryCommand({
|
|
46
|
+
TableName: String(process.env.DB_TABLE),
|
|
47
|
+
IndexName: "GSI1",
|
|
48
|
+
Limit: 1,
|
|
49
|
+
KeyConditionExpression: "GSI1_PK = :GSI1_PK AND GSI1_SK = :GSI1_SK",
|
|
50
|
+
ExpressionAttributeValues: {
|
|
51
|
+
":GSI1_PK": {
|
|
52
|
+
S: `T#${tenant}#FM#FILE_ALIASES`
|
|
53
|
+
},
|
|
54
|
+
":GSI1_SK": {
|
|
55
|
+
S: alias
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
if (!Array.isArray(Items)) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const [item] = Items;
|
|
63
|
+
if (!item) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const {
|
|
67
|
+
data
|
|
68
|
+
} = (0, _clientDynamodb.unmarshall)(item);
|
|
69
|
+
return data?.key ?? null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.AliasAssetRequestResolver = AliasAssetRequestResolver;
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=AliasAssetRequestResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_clientDynamodb","require","_","AliasAssetRequestResolver","constructor","documentClient","resolver","resolve","request","resolvedAsset","params","query","path","decodeURI","tenant","fileKey","getFileByAlias","undefined","original","options","AssetRequest","key","context","url","alias","Items","send","QueryCommand","TableName","String","process","env","DB_TABLE","IndexName","Limit","KeyConditionExpression","ExpressionAttributeValues","S","Array","isArray","item","data","unmarshall","exports"],"sources":["AliasAssetRequestResolver.ts"],"sourcesContent":["import { Request } from \"@webiny/handler/types\";\nimport { DynamoDBClient, QueryCommand, unmarshall } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { AssetRequest, AssetRequestResolver } from \"~/delivery\";\n\nexport class AliasAssetRequestResolver implements AssetRequestResolver {\n private documentClient: DynamoDBClient;\n private resolver: AssetRequestResolver;\n\n constructor(documentClient: DynamoDBClient, resolver: AssetRequestResolver) {\n this.documentClient = documentClient;\n this.resolver = resolver;\n }\n\n async resolve(request: Request): Promise<AssetRequest | undefined> {\n const resolvedAsset = await this.resolver.resolve(request);\n\n if (resolvedAsset) {\n return resolvedAsset;\n }\n\n const params = (request.params as Record<string, any>) ?? {};\n const query = (request.query as Record<string, any>) ?? {};\n const path = decodeURI(params[\"*\"]);\n\n const tenant = query.tenant || \"root\";\n const fileKey = await this.getFileByAlias(tenant, path);\n\n if (!fileKey) {\n return undefined;\n }\n\n const { original, ...options } = query;\n\n return new AssetRequest({\n key: fileKey,\n context: {\n url: request.url\n },\n options: {\n original: original !== undefined,\n ...options\n }\n });\n }\n\n private async getFileByAlias(tenant: string, alias: string): Promise<string | null> {\n const { Items } = await this.documentClient.send(\n new QueryCommand({\n TableName: String(process.env.DB_TABLE),\n IndexName: \"GSI1\",\n Limit: 1,\n KeyConditionExpression: \"GSI1_PK = :GSI1_PK AND GSI1_SK = :GSI1_SK\",\n ExpressionAttributeValues: {\n \":GSI1_PK\": { S: `T#${tenant}#FM#FILE_ALIASES` },\n \":GSI1_SK\": { S: alias }\n }\n })\n );\n\n if (!Array.isArray(Items)) {\n return null;\n }\n const [item] = Items;\n if (!item) {\n return null;\n }\n const { data } = unmarshall(item);\n\n return data?.key ?? null;\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,CAAA,GAAAD,OAAA;AAEO,MAAME,yBAAyB,CAAiC;EAInEC,WAAWA,CAACC,cAA8B,EAAEC,QAA8B,EAAE;IACxE,IAAI,C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EC,yBAAyB,EAAE;QACvB,UAAU,EAAE;UAAEC,CAAC,EAAG,KAAIvB,MAAO;QAAkB,CAAC;QAChD,UAAU,EAAE;UAAEuB,CAAC,EAAEb;QAAM;MAC3B;IACJ,CAAC,CACL,CAAC;IAED,IAAI,CAACc,KAAK,CAACC,OAAO,CAACd,KAAK,CAAC,EAAE;MACvB,OAAO,IAAI;IACf;IACA,MAAM,CAACe,IAAI,CAAC,GAAGf,KAAK;IACpB,IAAI,CAACe,IAAI,EAAE;MACP,OAAO,IAAI;IACf;IACA,MAAM;MAAEC;IAAK,CAAC,GAAG,IAAAC,0BAAU,EAACF,IAAI,CAAC;IAEjC,OAAOC,IAAI,EAAEpB,GAAG,IAAI,IAAI;EAC5B;AACJ;AAACsB,OAAA,CAAAxC,yBAAA,GAAAA,yBAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AssetContentsReader, AssetOutputStrategy } from "..";
|
|
3
|
+
declare type Setter<T> = (arg: T | undefined) => T;
|
|
4
|
+
export interface AssetData {
|
|
5
|
+
id: string;
|
|
6
|
+
tenant: string;
|
|
7
|
+
locale: string;
|
|
8
|
+
key: string;
|
|
9
|
+
size: number;
|
|
10
|
+
contentType: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class Asset {
|
|
13
|
+
protected readonly props: AssetData;
|
|
14
|
+
private outputStrategy;
|
|
15
|
+
private contentsReader;
|
|
16
|
+
constructor(props: AssetData);
|
|
17
|
+
clone(): Asset;
|
|
18
|
+
getId(): string;
|
|
19
|
+
getTenant(): string;
|
|
20
|
+
getLocale(): string;
|
|
21
|
+
getKey(): string;
|
|
22
|
+
getSize(): Promise<number>;
|
|
23
|
+
getContentType(): string;
|
|
24
|
+
getExtension(): string;
|
|
25
|
+
getContents(): Promise<Buffer>;
|
|
26
|
+
setContentsReader(reader: AssetContentsReader): void;
|
|
27
|
+
output(): Promise<import("..").AssetReply>;
|
|
28
|
+
setOutputStrategy(setter: Setter<AssetOutputStrategy> | AssetOutputStrategy): void;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Asset = void 0;
|
|
7
|
+
class Asset {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
this.props = props;
|
|
10
|
+
}
|
|
11
|
+
clone() {
|
|
12
|
+
const clonedAsset = new Asset(structuredClone(this.props));
|
|
13
|
+
clonedAsset.outputStrategy = this.outputStrategy;
|
|
14
|
+
clonedAsset.contentsReader = this.contentsReader;
|
|
15
|
+
return clonedAsset;
|
|
16
|
+
}
|
|
17
|
+
getId() {
|
|
18
|
+
return this.props.id;
|
|
19
|
+
}
|
|
20
|
+
getTenant() {
|
|
21
|
+
return this.props.tenant;
|
|
22
|
+
}
|
|
23
|
+
getLocale() {
|
|
24
|
+
return this.props.locale;
|
|
25
|
+
}
|
|
26
|
+
getKey() {
|
|
27
|
+
return this.props.key;
|
|
28
|
+
}
|
|
29
|
+
async getSize() {
|
|
30
|
+
const buffer = await this.getContents();
|
|
31
|
+
return buffer.length;
|
|
32
|
+
}
|
|
33
|
+
getContentType() {
|
|
34
|
+
return this.props.contentType;
|
|
35
|
+
}
|
|
36
|
+
getExtension() {
|
|
37
|
+
return this.getKey().split(".").pop() ?? "";
|
|
38
|
+
}
|
|
39
|
+
getContents() {
|
|
40
|
+
if (!this.contentsReader) {
|
|
41
|
+
throw Error(`Asset contents reader was not configured!`);
|
|
42
|
+
}
|
|
43
|
+
return this.contentsReader.read(this);
|
|
44
|
+
}
|
|
45
|
+
setContentsReader(reader) {
|
|
46
|
+
this.contentsReader = reader;
|
|
47
|
+
}
|
|
48
|
+
output() {
|
|
49
|
+
if (!this.outputStrategy) {
|
|
50
|
+
throw Error(`Asset output strategy was not configured!`);
|
|
51
|
+
}
|
|
52
|
+
return this.outputStrategy.output(this);
|
|
53
|
+
}
|
|
54
|
+
setOutputStrategy(setter) {
|
|
55
|
+
if (typeof setter === "function") {
|
|
56
|
+
this.outputStrategy = setter(this.outputStrategy);
|
|
57
|
+
} else {
|
|
58
|
+
this.outputStrategy = setter;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.Asset = Asset;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=Asset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Asset","constructor","props","clone","clonedAsset","structuredClone","outputStrategy","contentsReader","getId","id","getTenant","tenant","getLocale","locale","getKey","key","getSize","buffer","getContents","length","getContentType","contentType","getExtension","split","pop","Error","read","setContentsReader","reader","output","setOutputStrategy","setter","exports"],"sources":["Asset.ts"],"sourcesContent":["import { AssetContentsReader, AssetOutputStrategy } from \"~/delivery\";\n\ntype Setter<T> = (arg: T | undefined) => T;\n\nexport interface AssetData {\n id: string;\n tenant: string;\n locale: string;\n key: string;\n size: number;\n contentType: string;\n}\n\nexport class Asset {\n protected readonly props: AssetData;\n private outputStrategy: AssetOutputStrategy | undefined;\n private contentsReader: AssetContentsReader | undefined;\n\n constructor(props: AssetData) {\n this.props = props;\n }\n\n clone() {\n const clonedAsset = new Asset(structuredClone(this.props));\n clonedAsset.outputStrategy = this.outputStrategy;\n clonedAsset.contentsReader = this.contentsReader;\n return clonedAsset;\n }\n\n getId() {\n return this.props.id;\n }\n getTenant() {\n return this.props.tenant;\n }\n getLocale() {\n return this.props.locale;\n }\n getKey() {\n return this.props.key;\n }\n async getSize() {\n const buffer = await this.getContents();\n return buffer.length;\n }\n getContentType() {\n return this.props.contentType;\n }\n getExtension() {\n return this.getKey().split(\".\").pop() ?? \"\";\n }\n\n getContents() {\n if (!this.contentsReader) {\n throw Error(`Asset contents reader was not configured!`);\n }\n return this.contentsReader.read(this);\n }\n\n setContentsReader(reader: AssetContentsReader) {\n this.contentsReader = reader;\n }\n\n output() {\n if (!this.outputStrategy) {\n throw Error(`Asset output strategy was not configured!`);\n }\n\n return this.outputStrategy.output(this);\n }\n\n setOutputStrategy(setter: Setter<AssetOutputStrategy> | AssetOutputStrategy) {\n if (typeof setter === \"function\") {\n this.outputStrategy = setter(this.outputStrategy);\n } else {\n this.outputStrategy = setter;\n }\n }\n}\n"],"mappings":";;;;;;AAaO,MAAMA,KAAK,CAAC;EAKfC,WAAWA,CAACC,KAAgB,EAAE;IAC1B,IAAI,CAACA,KAAK,GAAGA,KAAK;EACtB;EAEAC,KAAKA,CAAA,EAAG;IACJ,MAAMC,WAAW,GAAG,IAAIJ,KAAK,CAACK,eAAe,CAAC,IAAI,CAACH,KAAK,CAAC,CAAC;IAC1DE,WAAW,CAACE,cAAc,GAAG,IAAI,CAACA,cAAc;IAChDF,WAAW,CAACG,cAAc,GAAG,IAAI,CAACA,cAAc;IAChD,OAAOH,WAAW;EACtB;EAEAI,KAAKA,CAAA,EAAG;IACJ,OAAO,IAAI,CAACN,KAAK,CAACO,EAAE;EACxB;EACAC,SAASA,CAAA,EAAG;IACR,OAAO,IAAI,CAACR,KAAK,CAACS,MAAM;EAC5B;EACAC,SAASA,CAAA,EAAG;IACR,OAAO,IAAI,CAACV,KAAK,CAACW,MAAM;EAC5B;EACAC,MAAMA,CAAA,EAAG;IACL,OAAO,IAAI,CAACZ,KAAK,CAACa,GAAG;EACzB;EACA,MAAMC,OAAOA,CAAA,EAAG;IACZ,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACC,WAAW,CAAC,CAAC;IACvC,OAAOD,MAAM,CAACE,MAAM;EACxB;EACAC,cAAcA,CAAA,EAAG;IACb,OAAO,IAAI,CAAClB,KAAK,CAACmB,WAAW;EACjC;EACAC,YAAYA,CAAA,EAAG;IACX,OAAO,IAAI,CAACR,MAAM,CAAC,CAAC,CAACS,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC,IAAI,EAAE;EAC/C;EAEAN,WAAWA,CAAA,EAAG;IACV,IAAI,CAAC,IAAI,CAACX,cAAc,EAAE;MACtB,MAAMkB,KAAK,CAAE,2CAA0C,CAAC;IAC5D;IACA,OAAO,IAAI,CAAClB,cAAc,CAACmB,IAAI,CAAC,IAAI,CAAC;EACzC;EAEAC,iBAAiBA,CAACC,MAA2B,EAAE;IAC3C,IAAI,CAACrB,cAAc,GAAGqB,MAAM;EAChC;EAEAC,MAAMA,CAAA,EAAG;IACL,IAAI,CAAC,IAAI,CAACvB,cAAc,EAAE;MACtB,MAAMmB,KAAK,CAAE,2CAA0C,CAAC;IAC5D;IAEA,OAAO,IAAI,CAACnB,cAAc,CAACuB,MAAM,CAAC,IAAI,CAAC;EAC3C;EAEAC,iBAAiBA,CAACC,MAAyD,EAAE;IACzE,IAAI,OAAOA,MAAM,KAAK,UAAU,EAAE;MAC9B,IAAI,CAACzB,cAAc,GAAGyB,MAAM,CAAC,IAAI,CAACzB,cAAc,CAAC;IACrD,CAAC,MAAM;MACH,IAAI,CAACA,cAAc,GAAGyB,MAAM;IAChC;EACJ;AACJ;AAACC,OAAA,CAAAhC,KAAA,GAAAA,KAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { AssetRequestResolver, AssetResolver, AssetProcessor, AssetOutputStrategy, AssetRequest, Asset, AssetTransformationStrategy, ResponseHeadersSetter } from "..";
|
|
3
|
+
import { FileManagerContext } from "../../types";
|
|
4
|
+
declare type Setter<TParams, TReturn> = (params: TParams) => TReturn;
|
|
5
|
+
export declare type AssetRequestResolverDecorator = Setter<{
|
|
6
|
+
assetRequestResolver: AssetRequestResolver;
|
|
7
|
+
}, AssetRequestResolver>;
|
|
8
|
+
export declare type AssetResolverDecorator = Setter<{
|
|
9
|
+
assetResolver: AssetResolver;
|
|
10
|
+
}, AssetResolver>;
|
|
11
|
+
export declare type AssetProcessorDecorator = Setter<{
|
|
12
|
+
context: FileManagerContext;
|
|
13
|
+
assetProcessor: AssetProcessor;
|
|
14
|
+
}, AssetProcessor>;
|
|
15
|
+
export declare type AssetTransformationDecorator = Setter<{
|
|
16
|
+
context: FileManagerContext;
|
|
17
|
+
assetTransformationStrategy: AssetTransformationStrategy;
|
|
18
|
+
}, AssetTransformationStrategy>;
|
|
19
|
+
export interface AssetOutputStrategyDecoratorParams {
|
|
20
|
+
context: FileManagerContext;
|
|
21
|
+
assetRequest: AssetRequest;
|
|
22
|
+
asset: Asset;
|
|
23
|
+
assetOutputStrategy: AssetOutputStrategy;
|
|
24
|
+
}
|
|
25
|
+
export declare type AssetOutputStrategyDecorator = Setter<AssetOutputStrategyDecoratorParams, AssetOutputStrategy>;
|
|
26
|
+
export declare class AssetDeliveryConfigBuilder {
|
|
27
|
+
private assetRequestResolverDecorators;
|
|
28
|
+
private assetResolverDecorators;
|
|
29
|
+
private assetProcessorDecorators;
|
|
30
|
+
private assetTransformationStrategyDecorators;
|
|
31
|
+
private assetOutputStrategyDecorators;
|
|
32
|
+
setResponseHeaders(setter: ResponseHeadersSetter): void;
|
|
33
|
+
decorateAssetRequestResolver(decorator: AssetRequestResolverDecorator): void;
|
|
34
|
+
decorateAssetResolver(decorator: AssetResolverDecorator): void;
|
|
35
|
+
decorateAssetProcessor(decorator: AssetProcessorDecorator): void;
|
|
36
|
+
decorateAssetTransformationStrategy(decorator: AssetTransformationDecorator): void;
|
|
37
|
+
decorateAssetOutputStrategy(decorator: AssetOutputStrategyDecorator): void;
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
getAssetRequestResolver(): AssetRequestResolver;
|
|
42
|
+
/**
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
getAssetResolver(): AssetResolver;
|
|
46
|
+
/**
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
getAssetProcessor(context: FileManagerContext): AssetProcessor;
|
|
50
|
+
getAssetOutputStrategy(context: FileManagerContext, assetRequest: AssetRequest, asset: Asset): AssetOutputStrategy;
|
|
51
|
+
getAssetTransformationStrategy(context: FileManagerContext): AssetTransformationStrategy;
|
|
52
|
+
}
|
|
53
|
+
export interface AssetDeliveryConfigModifier {
|
|
54
|
+
(config: AssetDeliveryConfigBuilder): Promise<void> | void;
|
|
55
|
+
}
|
|
56
|
+
export declare class AssetDeliveryConfigModifierPlugin extends Plugin {
|
|
57
|
+
static type: string;
|
|
58
|
+
private readonly cb;
|
|
59
|
+
constructor(cb: AssetDeliveryConfigModifier);
|
|
60
|
+
buildConfig(configBuilder: AssetDeliveryConfigBuilder): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export declare const createAssetDeliveryConfig: (cb: AssetDeliveryConfigModifier) => AssetDeliveryConfigModifierPlugin;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createAssetDeliveryConfig = exports.AssetDeliveryConfigModifierPlugin = exports.AssetDeliveryConfigBuilder = void 0;
|
|
7
|
+
var _plugins = require("@webiny/plugins");
|
|
8
|
+
var _ = require("./..");
|
|
9
|
+
var _NullRequestResolver = require("./NullRequestResolver");
|
|
10
|
+
var _NullAssetResolver = require("./NullAssetResolver");
|
|
11
|
+
var _NullAssetOutputStrategy = require("./NullAssetOutputStrategy");
|
|
12
|
+
var _TransformationAssetProcessor = require("./transformation/TransformationAssetProcessor");
|
|
13
|
+
var _PassthroughAssetTransformationStrategy = require("./transformation/PassthroughAssetTransformationStrategy");
|
|
14
|
+
class AssetDeliveryConfigBuilder {
|
|
15
|
+
assetRequestResolverDecorators = [];
|
|
16
|
+
assetResolverDecorators = [];
|
|
17
|
+
assetProcessorDecorators = [];
|
|
18
|
+
assetTransformationStrategyDecorators = [];
|
|
19
|
+
assetOutputStrategyDecorators = [];
|
|
20
|
+
setResponseHeaders(setter) {
|
|
21
|
+
this.decorateAssetOutputStrategy(params => {
|
|
22
|
+
return new _.SetResponseHeaders(setter, params);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
decorateAssetRequestResolver(decorator) {
|
|
26
|
+
this.assetRequestResolverDecorators.push(decorator);
|
|
27
|
+
}
|
|
28
|
+
decorateAssetResolver(decorator) {
|
|
29
|
+
this.assetResolverDecorators.push(decorator);
|
|
30
|
+
}
|
|
31
|
+
decorateAssetProcessor(decorator) {
|
|
32
|
+
this.assetProcessorDecorators.push(decorator);
|
|
33
|
+
}
|
|
34
|
+
decorateAssetTransformationStrategy(decorator) {
|
|
35
|
+
this.assetTransformationStrategyDecorators.push(decorator);
|
|
36
|
+
}
|
|
37
|
+
decorateAssetOutputStrategy(decorator) {
|
|
38
|
+
this.assetOutputStrategyDecorators.push(decorator);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
getAssetRequestResolver() {
|
|
45
|
+
return this.assetRequestResolverDecorators.reduce((value, decorator) => decorator({
|
|
46
|
+
assetRequestResolver: value
|
|
47
|
+
}), new _NullRequestResolver.NullRequestResolver());
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
getAssetResolver() {
|
|
54
|
+
return this.assetResolverDecorators.reduce((value, decorator) => decorator({
|
|
55
|
+
assetResolver: value
|
|
56
|
+
}), new _NullAssetResolver.NullAssetResolver());
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
getAssetProcessor(context) {
|
|
63
|
+
return this.assetProcessorDecorators.reduce((value, decorator) => decorator({
|
|
64
|
+
assetProcessor: value,
|
|
65
|
+
context
|
|
66
|
+
}), new _TransformationAssetProcessor.TransformationAssetProcessor(this.getAssetTransformationStrategy(context)));
|
|
67
|
+
}
|
|
68
|
+
getAssetOutputStrategy(context, assetRequest, asset) {
|
|
69
|
+
return this.assetOutputStrategyDecorators.reduce((value, decorator) => {
|
|
70
|
+
return decorator({
|
|
71
|
+
context,
|
|
72
|
+
assetRequest,
|
|
73
|
+
asset,
|
|
74
|
+
assetOutputStrategy: value
|
|
75
|
+
});
|
|
76
|
+
}, new _NullAssetOutputStrategy.NullAssetOutputStrategy());
|
|
77
|
+
}
|
|
78
|
+
getAssetTransformationStrategy(context) {
|
|
79
|
+
return this.assetTransformationStrategyDecorators.reduce((value, decorator) => decorator({
|
|
80
|
+
context,
|
|
81
|
+
assetTransformationStrategy: value
|
|
82
|
+
}), new _PassthroughAssetTransformationStrategy.PassthroughAssetTransformationStrategy());
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.AssetDeliveryConfigBuilder = AssetDeliveryConfigBuilder;
|
|
86
|
+
class AssetDeliveryConfigModifierPlugin extends _plugins.Plugin {
|
|
87
|
+
static type = "fm.config-modifier";
|
|
88
|
+
constructor(cb) {
|
|
89
|
+
super();
|
|
90
|
+
this.cb = cb;
|
|
91
|
+
}
|
|
92
|
+
async buildConfig(configBuilder) {
|
|
93
|
+
await this.cb(configBuilder);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.AssetDeliveryConfigModifierPlugin = AssetDeliveryConfigModifierPlugin;
|
|
97
|
+
const createAssetDeliveryConfig = cb => {
|
|
98
|
+
return new AssetDeliveryConfigModifierPlugin(cb);
|
|
99
|
+
};
|
|
100
|
+
exports.createAssetDeliveryConfig = createAssetDeliveryConfig;
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=AssetDeliveryConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","_","_NullRequestResolver","_NullAssetResolver","_NullAssetOutputStrategy","_TransformationAssetProcessor","_PassthroughAssetTransformationStrategy","AssetDeliveryConfigBuilder","assetRequestResolverDecorators","assetResolverDecorators","assetProcessorDecorators","assetTransformationStrategyDecorators","assetOutputStrategyDecorators","setResponseHeaders","setter","decorateAssetOutputStrategy","params","SetResponseHeaders","decorateAssetRequestResolver","decorator","push","decorateAssetResolver","decorateAssetProcessor","decorateAssetTransformationStrategy","getAssetRequestResolver","reduce","value","assetRequestResolver","NullRequestResolver","getAssetResolver","assetResolver","NullAssetResolver","getAssetProcessor","context","assetProcessor","TransformationAssetProcessor","getAssetTransformationStrategy","getAssetOutputStrategy","assetRequest","asset","assetOutputStrategy","NullAssetOutputStrategy","assetTransformationStrategy","PassthroughAssetTransformationStrategy","exports","AssetDeliveryConfigModifierPlugin","Plugin","type","constructor","cb","buildConfig","configBuilder","createAssetDeliveryConfig"],"sources":["AssetDeliveryConfig.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport {\n AssetRequestResolver,\n AssetResolver,\n AssetProcessor,\n AssetOutputStrategy,\n AssetRequest,\n Asset,\n AssetTransformationStrategy,\n ResponseHeadersSetter,\n SetResponseHeaders\n} from \"~/delivery\";\nimport { FileManagerContext } from \"~/types\";\nimport { NullRequestResolver } from \"~/delivery/AssetDelivery/NullRequestResolver\";\nimport { NullAssetResolver } from \"~/delivery/AssetDelivery/NullAssetResolver\";\nimport { NullAssetOutputStrategy } from \"./NullAssetOutputStrategy\";\nimport { TransformationAssetProcessor } from \"./transformation/TransformationAssetProcessor\";\nimport { PassthroughAssetTransformationStrategy } from \"./transformation/PassthroughAssetTransformationStrategy\";\n\ntype Setter<TParams, TReturn> = (params: TParams) => TReturn;\n\nexport type AssetRequestResolverDecorator = Setter<\n { assetRequestResolver: AssetRequestResolver },\n AssetRequestResolver\n>;\n\nexport type AssetResolverDecorator = Setter<{ assetResolver: AssetResolver }, AssetResolver>;\n\nexport type AssetProcessorDecorator = Setter<\n { context: FileManagerContext; assetProcessor: AssetProcessor },\n AssetProcessor\n>;\n\nexport type AssetTransformationDecorator = Setter<\n { context: FileManagerContext; assetTransformationStrategy: AssetTransformationStrategy },\n AssetTransformationStrategy\n>;\n\nexport interface AssetOutputStrategyDecoratorParams {\n context: FileManagerContext;\n assetRequest: AssetRequest;\n asset: Asset;\n assetOutputStrategy: AssetOutputStrategy;\n}\n\nexport type AssetOutputStrategyDecorator = Setter<\n AssetOutputStrategyDecoratorParams,\n AssetOutputStrategy\n>;\n\nexport class AssetDeliveryConfigBuilder {\n private assetRequestResolverDecorators: AssetRequestResolverDecorator[] = [];\n private assetResolverDecorators: AssetResolverDecorator[] = [];\n private assetProcessorDecorators: AssetProcessorDecorator[] = [];\n private assetTransformationStrategyDecorators: AssetTransformationDecorator[] = [];\n private assetOutputStrategyDecorators: AssetOutputStrategyDecorator[] = [];\n\n setResponseHeaders(setter: ResponseHeadersSetter) {\n this.decorateAssetOutputStrategy(params => {\n return new SetResponseHeaders(setter, params);\n });\n }\n\n decorateAssetRequestResolver(decorator: AssetRequestResolverDecorator) {\n this.assetRequestResolverDecorators.push(decorator);\n }\n\n decorateAssetResolver(decorator: AssetResolverDecorator) {\n this.assetResolverDecorators.push(decorator);\n }\n\n decorateAssetProcessor(decorator: AssetProcessorDecorator) {\n this.assetProcessorDecorators.push(decorator);\n }\n\n decorateAssetTransformationStrategy(decorator: AssetTransformationDecorator) {\n this.assetTransformationStrategyDecorators.push(decorator);\n }\n\n decorateAssetOutputStrategy(decorator: AssetOutputStrategyDecorator) {\n this.assetOutputStrategyDecorators.push(decorator);\n }\n\n /**\n * @internal\n */\n getAssetRequestResolver() {\n return this.assetRequestResolverDecorators.reduce<AssetRequestResolver>(\n (value, decorator) => decorator({ assetRequestResolver: value }),\n new NullRequestResolver()\n );\n }\n\n /**\n * @internal\n */\n getAssetResolver() {\n return this.assetResolverDecorators.reduce<AssetResolver>(\n (value, decorator) => decorator({ assetResolver: value }),\n new NullAssetResolver()\n );\n }\n\n /**\n * @internal\n */\n getAssetProcessor(context: FileManagerContext) {\n return this.assetProcessorDecorators.reduce<AssetProcessor>(\n (value, decorator) => decorator({ assetProcessor: value, context }),\n new TransformationAssetProcessor(this.getAssetTransformationStrategy(context))\n );\n }\n\n getAssetOutputStrategy(context: FileManagerContext, assetRequest: AssetRequest, asset: Asset) {\n return this.assetOutputStrategyDecorators.reduce<AssetOutputStrategy>(\n (value, decorator) => {\n return decorator({ context, assetRequest, asset, assetOutputStrategy: value });\n },\n new NullAssetOutputStrategy()\n );\n }\n\n getAssetTransformationStrategy(context: FileManagerContext) {\n return this.assetTransformationStrategyDecorators.reduce<AssetTransformationStrategy>(\n (value, decorator) => decorator({ context, assetTransformationStrategy: value }),\n new PassthroughAssetTransformationStrategy()\n );\n }\n}\n\nexport interface AssetDeliveryConfigModifier {\n (config: AssetDeliveryConfigBuilder): Promise<void> | void;\n}\n\nexport class AssetDeliveryConfigModifierPlugin extends Plugin {\n public static override type = \"fm.config-modifier\";\n private readonly cb: AssetDeliveryConfigModifier;\n\n constructor(cb: AssetDeliveryConfigModifier) {\n super();\n this.cb = cb;\n }\n\n async buildConfig(configBuilder: AssetDeliveryConfigBuilder): Promise<void> {\n await this.cb(configBuilder);\n }\n}\n\nexport const createAssetDeliveryConfig = (cb: AssetDeliveryConfigModifier) => {\n return new AssetDeliveryConfigModifierPlugin(cb);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,CAAA,GAAAD,OAAA;AAYA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,wBAAA,GAAAJ,OAAA;AACA,IAAAK,6BAAA,GAAAL,OAAA;AACA,IAAAM,uCAAA,GAAAN,OAAA;AAiCO,MAAMO,0BAA0B,CAAC;EAC5BC,8BAA8B,GAAoC,EAAE;EACpEC,uBAAuB,GAA6B,EAAE;EACtDC,wBAAwB,GAA8B,EAAE;EACxDC,qCAAqC,GAAmC,EAAE;EAC1EC,6BAA6B,GAAmC,EAAE;EAE1EC,kBAAkBA,CAACC,MAA6B,EAAE;IAC9C,IAAI,CAACC,2BAA2B,CAACC,MAAM,IAAI;MACvC,OAAO,IAAIC,oBAAkB,CA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|
|
5
|
+
export declare type AssetRequestContext<T extends Record<string, any> = Record<string, any>> = T & {
|
|
6
|
+
/**
|
|
7
|
+
* Asset request URL.
|
|
8
|
+
*/
|
|
9
|
+
url: string;
|
|
10
|
+
};
|
|
11
|
+
export interface AssetRequestData<TOptions> {
|
|
12
|
+
key: string;
|
|
13
|
+
context: AssetRequestContext;
|
|
14
|
+
options: TOptions;
|
|
15
|
+
}
|
|
16
|
+
export declare class AssetRequest<TOptions extends AssetRequestOptions = AssetRequestOptions> {
|
|
17
|
+
private data;
|
|
18
|
+
constructor(data: AssetRequestData<TOptions>);
|
|
19
|
+
getKey(): string;
|
|
20
|
+
getOptions(): TOptions;
|
|
21
|
+
setOptions(options: TOptions): void;
|
|
22
|
+
getContext<T>(): AssetRequestContext<T>;
|
|
23
|
+
getExtension(): string | undefined;
|
|
24
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AssetRequest = void 0;
|
|
7
|
+
class AssetRequest {
|
|
8
|
+
constructor(data) {
|
|
9
|
+
this.data = data;
|
|
10
|
+
}
|
|
11
|
+
getKey() {
|
|
12
|
+
return this.data.key;
|
|
13
|
+
}
|
|
14
|
+
getOptions() {
|
|
15
|
+
return this.data.options;
|
|
16
|
+
}
|
|
17
|
+
setOptions(options) {
|
|
18
|
+
this.data.options = options;
|
|
19
|
+
}
|
|
20
|
+
getContext() {
|
|
21
|
+
return this.data.context;
|
|
22
|
+
}
|
|
23
|
+
getExtension() {
|
|
24
|
+
return this.data.key.split(".").pop();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.AssetRequest = AssetRequest;
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=AssetRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AssetRequest","constructor","data","getKey","key","getOptions","options","setOptions","getContext","context","getExtension","split","pop","exports"],"sources":["AssetRequest.ts"],"sourcesContent":["export interface AssetRequestOptions {\n original?: boolean;\n width?: number;\n}\n\nexport type AssetRequestContext<T extends Record<string, any> = Record<string, any>> = T & {\n /**\n * Asset request URL.\n */\n url: string;\n};\n\nexport interface AssetRequestData<TOptions> {\n key: string;\n context: AssetRequestContext;\n options: TOptions;\n}\n\nexport class AssetRequest<TOptions extends AssetRequestOptions = AssetRequestOptions> {\n private data: AssetRequestData<TOptions>;\n\n constructor(data: AssetRequestData<TOptions>) {\n this.data = data;\n }\n\n getKey() {\n return this.data.key;\n }\n\n getOptions(): TOptions {\n return this.data.options;\n }\n\n setOptions(options: TOptions) {\n this.data.options = options;\n }\n\n getContext<T>() {\n return this.data.context as AssetRequestContext<T>;\n }\n\n getExtension() {\n return this.data.key.split(\".\").pop();\n }\n}\n"],"mappings":";;;;;;AAkBO,MAAMA,YAAY,CAA6D;EAGlFC,WAAWA,CAACC,IAAgC,EAAE;IAC1C,IAAI,CAACA,IAAI,GAAGA,IAAI;EACpB;EAEAC,MAAMA,CAAA,EAAG;IACL,OAAO,IAAI,CAACD,IAAI,CAACE,GAAG;EACxB;EAEAC,UAAUA,CAAA,EAAa;IACnB,OAAO,IAAI,CAACH,IAAI,CAACI,OAAO;EAC5B;EAEAC,UAAUA,CAACD,OAAiB,EAAE;IAC1B,IAAI,CAACJ,IAAI,CAACI,OAAO,GAAGA,OAAO;EAC/B;EAEAE,UAAUA,CAAA,EAAM;IACZ,OAAO,IAAI,CAACN,IAAI,CAACO,OAAO;EAC5B;EAEAC,YAAYA,CAAA,EAAG;IACX,OAAO,IAAI,CAACR,IAAI,CAACE,GAAG,CAACO,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAC,CAAC;EACzC;AACJ;AAACC,OAAA,CAAAb,YAAA,GAAAA,YAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Request } from "@webiny/handler/types";
|
|
2
|
+
import { AssetRequestResolver } from "./abstractions/AssetRequestResolver";
|
|
3
|
+
import { AssetRequest } from "./AssetRequest";
|
|
4
|
+
export declare class FilesAssetRequestResolver implements AssetRequestResolver {
|
|
5
|
+
resolve(request: Request): Promise<AssetRequest | undefined>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FilesAssetRequestResolver = void 0;
|
|
7
|
+
var _AssetRequest = require("./AssetRequest");
|
|
8
|
+
class FilesAssetRequestResolver {
|
|
9
|
+
async resolve(request) {
|
|
10
|
+
// Example: /files/65722cb5c7824a0008d05963/image-48.jpg?width=300
|
|
11
|
+
if (!request.url.startsWith("/files/")) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const params = request.params ?? {};
|
|
15
|
+
const query = request.query ?? {};
|
|
16
|
+
|
|
17
|
+
// Example: { '*': '/files/65722cb5c7824a0008d05963/image-48.jpg' },
|
|
18
|
+
const path = params["*"];
|
|
19
|
+
return new _AssetRequest.AssetRequest({
|
|
20
|
+
key: decodeURI(path).replace("/files/", ""),
|
|
21
|
+
context: {
|
|
22
|
+
url: request.url
|
|
23
|
+
},
|
|
24
|
+
options: {
|
|
25
|
+
...query,
|
|
26
|
+
width: query.width ? parseInt(query.width) : undefined
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.FilesAssetRequestResolver = FilesAssetRequestResolver;
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=FilesAssetRequestResolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_AssetRequest","require","FilesAssetRequestResolver","resolve","request","url","startsWith","undefined","params","query","path","AssetRequest","key","decodeURI","replace","context","options","width","parseInt","exports"],"sources":["FilesAssetRequestResolver.ts"],"sourcesContent":["import { Request } from \"@webiny/handler/types\";\nimport { AssetRequestResolver } from \"./abstractions/AssetRequestResolver\";\nimport { AssetRequest } from \"./AssetRequest\";\n\nexport class FilesAssetRequestResolver implements AssetRequestResolver {\n async resolve(request: Request): Promise<AssetRequest | undefined> {\n // Example: /files/65722cb5c7824a0008d05963/image-48.jpg?width=300\n if (!request.url.startsWith(\"/files/\")) {\n return undefined;\n }\n\n const params = (request.params as Record<string, any>) ?? {};\n const query = (request.query as Record<string, any>) ?? {};\n\n // Example: { '*': '/files/65722cb5c7824a0008d05963/image-48.jpg' },\n const path = params[\"*\"];\n\n return new AssetRequest({\n key: decodeURI(path).replace(\"/files/\", \"\"),\n context: {\n url: request.url\n },\n options: {\n ...query,\n width: query.width ? parseInt(query.width) : undefined\n }\n });\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AAEO,MAAMC,yBAAyB,CAAiC;EACnE,MAAMC,OAAOA,CAACC,OAAgB,EAAqC;IAC/D;IACA,IAAI,CAACA,OAAO,CAACC,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,EAAE;MACpC,OAAOC,SAAS;IACpB;IAEA,MAAMC,MAAM,GAAIJ,OAAO,CAACI,MAAM,IAA4B,CAAC,CAAC;IAC5D,MAAMC,KAAK,GAAIL,OAAO,CAACK,KAAK,IAA4B,CAAC,CAAC;;IAE1D;IACA,MAAMC,IAAI,GAAGF,MAAM,CAAC,GAAG,CAAC;IAExB,OAAO,IAAIG,0BAAY,CAAC;MACpBC,GAAG,EAAEC,SAAS,CAACH,IAAI,CAAC,CAACI,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;MAC3CC,OAAO,EAAE;QACLV,GAAG,EAAED,OAAO,CAACC;MACjB,CAAC;MACDW,OAAO,EAAE;QACL,GAAGP,KAAK;QACRQ,KAAK,EAAER,KAAK,CAACQ,KAAK,GAAGC,QAAQ,CAACT,KAAK,CAACQ,KAAK,CAAC,GAAGV;MACjD;IACJ,CAAC,CAAC;EACN;AACJ;AAACY,OAAA,CAAAjB,yBAAA,GAAAA,yBAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NullAssetOutputStrategy = void 0;
|
|
7
|
+
var _NullAssetReply = require("./NullAssetReply");
|
|
8
|
+
class NullAssetOutputStrategy {
|
|
9
|
+
async output() {
|
|
10
|
+
return new _NullAssetReply.NullAssetReply();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.NullAssetOutputStrategy = NullAssetOutputStrategy;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=NullAssetOutputStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_NullAssetReply","require","NullAssetOutputStrategy","output","NullAssetReply","exports"],"sources":["NullAssetOutputStrategy.ts"],"sourcesContent":["import { AssetOutputStrategy, AssetReply } from \"~/delivery\";\nimport { NullAssetReply } from \"./NullAssetReply\";\n\nexport class NullAssetOutputStrategy implements AssetOutputStrategy {\n async output(): Promise<AssetReply> {\n return new NullAssetReply();\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,eAAA,GAAAC,OAAA;AAEO,MAAMC,uBAAuB,CAAgC;EAChE,MAAMC,MAAMA,CAAA,EAAwB;IAChC,OAAO,IAAIC,8BAAc,CAAC,CAAC;EAC/B;AACJ;AAACC,OAAA,CAAAH,uBAAA,GAAAA,uBAAA"}
|