@webiny/api-file-manager 6.3.0-beta.4 → 6.4.0-beta.0
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/contants.js +2 -1
- package/contants.js.map +1 -1
- package/delivery/AssetDelivery/Asset.js +50 -56
- package/delivery/AssetDelivery/Asset.js.map +1 -1
- package/delivery/AssetDelivery/AssetDeliveryConfig.js +70 -83
- package/delivery/AssetDelivery/AssetDeliveryConfig.js.map +1 -1
- package/delivery/AssetDelivery/AssetRequest.js +20 -19
- package/delivery/AssetDelivery/AssetRequest.js.map +1 -1
- package/delivery/AssetDelivery/FilesAssetRequestResolver.js +19 -25
- package/delivery/AssetDelivery/FilesAssetRequestResolver.js.map +1 -1
- package/delivery/AssetDelivery/NullAssetOutputStrategy.js +5 -4
- package/delivery/AssetDelivery/NullAssetOutputStrategy.js.map +1 -1
- package/delivery/AssetDelivery/NullAssetReply.js +10 -9
- package/delivery/AssetDelivery/NullAssetReply.js.map +1 -1
- package/delivery/AssetDelivery/NullAssetResolver.js +5 -4
- package/delivery/AssetDelivery/NullAssetResolver.js.map +1 -1
- package/delivery/AssetDelivery/NullRequestResolver.js +5 -4
- package/delivery/AssetDelivery/NullRequestResolver.js.map +1 -1
- package/delivery/AssetDelivery/SetCacheControlHeaders.js +11 -14
- package/delivery/AssetDelivery/SetCacheControlHeaders.js.map +1 -1
- package/delivery/AssetDelivery/SetResponseHeaders.js +16 -15
- package/delivery/AssetDelivery/SetResponseHeaders.js.map +1 -1
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetProcessor.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetReply.js +28 -27
- package/delivery/AssetDelivery/abstractions/AssetReply.js.map +1 -1
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetResolver.js +0 -3
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js +0 -3
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js +4 -5
- package/delivery/AssetDelivery/createAssetDeliveryPluginLoader.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js +0 -3
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js +15 -14
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedAssetReply.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js +5 -4
- package/delivery/AssetDelivery/privateFiles/NotAuthorizedOutputStrategy.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js +14 -16
- package/delivery/AssetDelivery/privateFiles/PrivateAuthenticatedAuthorizer.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js +18 -17
- package/delivery/AssetDelivery/privateFiles/PrivateCache.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js +21 -25
- package/delivery/AssetDelivery/privateFiles/PrivateFileAssetRequestResolver.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js +44 -51
- package/delivery/AssetDelivery/privateFiles/PrivateFilesAssetProcessor.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/PublicCache.js +18 -17
- package/delivery/AssetDelivery/privateFiles/PublicCache.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js +16 -15
- package/delivery/AssetDelivery/privateFiles/RedirectToPrivateUrlOutputStrategy.js.map +1 -1
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js +16 -15
- package/delivery/AssetDelivery/privateFiles/RedirectToPublicUrlOutputStrategy.js.map +1 -1
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js +5 -4
- package/delivery/AssetDelivery/transformation/PassthroughAssetProcessor.js.map +1 -1
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js +5 -4
- package/delivery/AssetDelivery/transformation/PassthroughAssetTransformationStrategy.js.map +1 -1
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js +12 -15
- package/delivery/AssetDelivery/transformation/TransformationAssetProcessor.js.map +1 -1
- package/delivery/index.js +0 -2
- package/delivery/setupAssetDelivery.js +70 -101
- package/delivery/setupAssetDelivery.js.map +1 -1
- package/domain/file/abstractions.js +2 -5
- package/domain/file/abstractions.js.map +1 -1
- package/domain/file/errors.js +67 -76
- package/domain/file/errors.js.map +1 -1
- package/domain/file/file.model.js +57 -49
- package/domain/file/file.model.js.map +1 -1
- package/domain/file/types.js +0 -3
- package/domain/identity/Identity.js +9 -8
- package/domain/identity/Identity.js.map +1 -1
- package/domain/permissionsSchema.js +26 -15
- package/domain/permissionsSchema.js.map +1 -1
- package/domain/settings/constants.js +2 -1
- package/domain/settings/constants.js.map +1 -1
- package/domain/settings/errors.js +22 -24
- package/domain/settings/errors.js.map +1 -1
- package/domain/settings/types.js +0 -3
- package/domain/settings/validation.js +18 -27
- package/domain/settings/validation.js.map +1 -1
- package/exports/api/file-manager/file.js +0 -2
- package/exports/api/file-manager/permissions.js +0 -2
- package/exports/api/file-manager/settings.js +0 -2
- package/features/FileManagerFeature.js +16 -15
- package/features/FileManagerFeature.js.map +1 -1
- package/features/file/CreateFile/CreateFileRepository.js +20 -18
- package/features/file/CreateFile/CreateFileRepository.js.map +1 -1
- package/features/file/CreateFile/CreateFileUseCase.js +68 -75
- package/features/file/CreateFile/CreateFileUseCase.js.map +1 -1
- package/features/file/CreateFile/abstractions.js +3 -14
- package/features/file/CreateFile/abstractions.js.map +1 -1
- package/features/file/CreateFile/events.js +17 -26
- package/features/file/CreateFile/events.js.map +1 -1
- package/features/file/CreateFile/feature.js +7 -6
- package/features/file/CreateFile/feature.js.map +1 -1
- package/features/file/CreateFile/index.js +0 -2
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js +15 -17
- package/features/file/CreateFilesInBatch/CreateFilesInBatchRepository.js.map +1 -1
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js +59 -70
- package/features/file/CreateFilesInBatch/CreateFilesInBatchUseCase.js.map +1 -1
- package/features/file/CreateFilesInBatch/abstractions.js +3 -14
- package/features/file/CreateFilesInBatch/abstractions.js.map +1 -1
- package/features/file/CreateFilesInBatch/events.js +17 -26
- package/features/file/CreateFilesInBatch/events.js.map +1 -1
- package/features/file/CreateFilesInBatch/feature.js +7 -6
- package/features/file/CreateFilesInBatch/feature.js.map +1 -1
- package/features/file/CreateFilesInBatch/index.js +0 -2
- package/features/file/DeleteFile/DeleteFileRepository.js +21 -20
- package/features/file/DeleteFile/DeleteFileRepository.js.map +1 -1
- package/features/file/DeleteFile/DeleteFileUseCase.js +31 -33
- package/features/file/DeleteFile/DeleteFileUseCase.js.map +1 -1
- package/features/file/DeleteFile/abstractions.js +3 -14
- package/features/file/DeleteFile/abstractions.js.map +1 -1
- package/features/file/DeleteFile/events.js +17 -26
- package/features/file/DeleteFile/events.js.map +1 -1
- package/features/file/DeleteFile/feature.js +7 -6
- package/features/file/DeleteFile/feature.js.map +1 -1
- package/features/file/DeleteFile/index.js +1 -3
- package/features/file/FileUrlGenerator/abstractions.js +2 -2
- package/features/file/FileUrlGenerator/abstractions.js.map +1 -1
- package/features/file/GetFile/GetFileRepository.js +22 -22
- package/features/file/GetFile/GetFileRepository.js.map +1 -1
- package/features/file/GetFile/GetFileUseCase.js +19 -21
- package/features/file/GetFile/GetFileUseCase.js.map +1 -1
- package/features/file/GetFile/abstractions.js +3 -14
- package/features/file/GetFile/abstractions.js.map +1 -1
- package/features/file/GetFile/feature.js +7 -6
- package/features/file/GetFile/feature.js.map +1 -1
- package/features/file/GetFile/index.js +0 -2
- package/features/file/GetFileContentsById/abstractions.d.ts +20 -0
- package/features/file/GetFileContentsById/abstractions.js +5 -0
- package/features/file/GetFileContentsById/abstractions.js.map +1 -0
- package/features/file/GetFileContentsById/index.d.ts +1 -0
- package/features/file/GetFileContentsById/index.js +1 -0
- package/features/file/GetFileContentsByKey/abstractions.d.ts +17 -0
- package/features/file/GetFileContentsByKey/abstractions.js +5 -0
- package/features/file/GetFileContentsByKey/abstractions.js.map +1 -0
- package/features/file/GetFileContentsByKey/index.d.ts +1 -0
- package/features/file/GetFileContentsByKey/index.js +1 -0
- package/features/file/ListFiles/ListFilesRepository.js +42 -40
- package/features/file/ListFiles/ListFilesRepository.js.map +1 -1
- package/features/file/ListFiles/ListFilesUseCase.js +33 -34
- package/features/file/ListFiles/ListFilesUseCase.js.map +1 -1
- package/features/file/ListFiles/abstractions.js +3 -14
- package/features/file/ListFiles/abstractions.js.map +1 -1
- package/features/file/ListFiles/feature.js +7 -6
- package/features/file/ListFiles/feature.js.map +1 -1
- package/features/file/ListFiles/index.js +0 -2
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.js +31 -28
- package/features/file/ListImagesByTagTool/ListImagesByTagTool.js.map +1 -1
- package/features/file/ListImagesByTagTool/feature.js +6 -5
- package/features/file/ListImagesByTagTool/feature.js.map +1 -1
- package/features/file/ListTags/ListTagsRepository.js +31 -36
- package/features/file/ListTags/ListTagsRepository.js.map +1 -1
- package/features/file/ListTags/ListTagsUseCase.js +21 -21
- package/features/file/ListTags/ListTagsUseCase.js.map +1 -1
- package/features/file/ListTags/abstractions.js +3 -14
- package/features/file/ListTags/abstractions.js.map +1 -1
- package/features/file/ListTags/feature.js +7 -6
- package/features/file/ListTags/feature.js.map +1 -1
- package/features/file/ListTags/index.js +0 -2
- package/features/file/UpdateFile/UpdateFileRepository.js +26 -28
- package/features/file/UpdateFile/UpdateFileRepository.js.map +1 -1
- package/features/file/UpdateFile/UpdateFileUseCase.js +57 -65
- package/features/file/UpdateFile/UpdateFileUseCase.js.map +1 -1
- package/features/file/UpdateFile/abstractions.js +3 -14
- package/features/file/UpdateFile/abstractions.js.map +1 -1
- package/features/file/UpdateFile/events.js +17 -26
- package/features/file/UpdateFile/events.js.map +1 -1
- package/features/file/UpdateFile/feature.js +7 -6
- package/features/file/UpdateFile/feature.js.map +1 -1
- package/features/file/UpdateFile/index.js +1 -3
- package/features/file/shared/EntryToFileMapper.js +25 -24
- package/features/file/shared/EntryToFileMapper.js.map +1 -1
- package/features/file/shared/FileInputToEntryInputMapper.js +29 -28
- package/features/file/shared/FileInputToEntryInputMapper.js.map +1 -1
- package/features/file/shared/FileToEntryMapper.js +28 -27
- package/features/file/shared/FileToEntryMapper.js.map +1 -1
- package/features/permissions/abstractions.js +2 -1
- package/features/permissions/abstractions.js.map +1 -1
- package/features/permissions/feature.js +2 -1
- package/features/permissions/feature.js.map +1 -1
- package/features/settings/GetSettings/GetSettingsUseCase.js +19 -19
- package/features/settings/GetSettings/GetSettingsUseCase.js.map +1 -1
- package/features/settings/GetSettings/abstractions.js +2 -7
- package/features/settings/GetSettings/abstractions.js.map +1 -1
- package/features/settings/GetSettings/feature.js +6 -5
- package/features/settings/GetSettings/feature.js.map +1 -1
- package/features/settings/SettingsInstaller/SettingsInstaller.js +25 -24
- package/features/settings/SettingsInstaller/SettingsInstaller.js.map +1 -1
- package/features/settings/SettingsInstaller/feature.js +6 -5
- package/features/settings/SettingsInstaller/feature.js.map +1 -1
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js +41 -48
- package/features/settings/UpdateSettings/UpdateSettingsUseCase.js.map +1 -1
- package/features/settings/UpdateSettings/abstractions.js +2 -7
- package/features/settings/UpdateSettings/abstractions.js.map +1 -1
- package/features/settings/UpdateSettings/events.js +17 -26
- package/features/settings/UpdateSettings/events.js.map +1 -1
- package/features/settings/UpdateSettings/feature.js +6 -5
- package/features/settings/UpdateSettings/feature.js.map +1 -1
- package/features/settings/UpdateSettings/index.js +0 -2
- package/features/shared/abstractions.js +0 -2
- package/graphql/baseSchema.js +30 -33
- package/graphql/baseSchema.js.map +1 -1
- package/graphql/createFilesTypeDefs.js +49 -57
- package/graphql/createFilesTypeDefs.js.map +1 -1
- package/graphql/filesSchema.js +79 -99
- package/graphql/filesSchema.js.map +1 -1
- package/graphql/getFileByUrl.js +45 -53
- package/graphql/getFileByUrl.js.map +1 -1
- package/graphql/index.js +35 -42
- package/graphql/index.js.map +1 -1
- package/graphql/utils.js +9 -14
- package/graphql/utils.js.map +1 -1
- package/index.js +19 -30
- package/index.js.map +1 -1
- package/modelModifier/CmsModelModifier.js +40 -43
- package/modelModifier/CmsModelModifier.js.map +1 -1
- package/package.json +17 -20
- package/types.js +0 -2
- package/delivery/AssetDelivery/abstractions/AssetContentsReader.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetOutputStrategy.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetProcessor.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetRequestResolver.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetResolver.js.map +0 -1
- package/delivery/AssetDelivery/abstractions/AssetTransformationStrategy.js.map +0 -1
- package/delivery/AssetDelivery/privateFiles/AssetAuthorizer.js.map +0 -1
- package/delivery/index.js.map +0 -1
- package/domain/file/types.js.map +0 -1
- package/domain/settings/types.js.map +0 -1
- package/exports/api/file-manager/file.js.map +0 -1
- package/exports/api/file-manager/permissions.js.map +0 -1
- package/exports/api/file-manager/settings.js.map +0 -1
- package/features/ai/AiImageEnrichmentAfterCreateHandler.d.ts +0 -11
- package/features/ai/AiImageEnrichmentAfterCreateHandler.js +0 -28
- package/features/ai/AiImageEnrichmentAfterCreateHandler.js.map +0 -1
- package/features/ai/AiImageEnrichmentFeature.d.ts +0 -4
- package/features/ai/AiImageEnrichmentFeature.js +0 -12
- package/features/ai/AiImageEnrichmentFeature.js.map +0 -1
- package/features/file/CreateFile/index.js.map +0 -1
- package/features/file/CreateFilesInBatch/index.js.map +0 -1
- package/features/file/DeleteFile/index.js.map +0 -1
- package/features/file/GetFile/index.js.map +0 -1
- package/features/file/ListFiles/index.js.map +0 -1
- package/features/file/ListTags/index.js.map +0 -1
- package/features/file/UpdateFile/index.js.map +0 -1
- package/features/settings/UpdateSettings/index.js.map +0 -1
- package/features/shared/abstractions.js.map +0 -1
- package/tasks/AiImageEnrichmentTask.d.ts +0 -35
- package/tasks/AiImageEnrichmentTask.js +0 -136
- package/tasks/AiImageEnrichmentTask.js.map +0 -1
- package/types.js.map +0 -1
package/contants.js
CHANGED
package/contants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"contants.js","sources":["../src/contants.ts"],"sourcesContent":["export const ROOT_FOLDER = \"root\";\n"],"names":["ROOT_FOLDER"],"mappings":"AAAO,MAAMA,cAAc"}
|
|
@@ -1,59 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
setOutputStrategy(setter) {
|
|
51
|
-
if (typeof setter === "function") {
|
|
52
|
-
this.outputStrategy = setter(this.outputStrategy);
|
|
53
|
-
} else {
|
|
54
|
-
this.outputStrategy = setter;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
class Asset {
|
|
2
|
+
constructor(props){
|
|
3
|
+
this.props = props;
|
|
4
|
+
}
|
|
5
|
+
clone() {
|
|
6
|
+
return this.withProps(structuredClone(this.props));
|
|
7
|
+
}
|
|
8
|
+
withProps(props) {
|
|
9
|
+
const newAsset = new Asset({
|
|
10
|
+
...this.props,
|
|
11
|
+
...props
|
|
12
|
+
});
|
|
13
|
+
newAsset.contentsReader = this.contentsReader;
|
|
14
|
+
newAsset.outputStrategy = this.outputStrategy;
|
|
15
|
+
return newAsset;
|
|
16
|
+
}
|
|
17
|
+
getId() {
|
|
18
|
+
return this.props.id;
|
|
19
|
+
}
|
|
20
|
+
getTenant() {
|
|
21
|
+
return this.props.tenant;
|
|
22
|
+
}
|
|
23
|
+
getKey() {
|
|
24
|
+
return this.props.key;
|
|
25
|
+
}
|
|
26
|
+
getSize() {
|
|
27
|
+
return this.props.size;
|
|
28
|
+
}
|
|
29
|
+
getContentType() {
|
|
30
|
+
return this.props.contentType;
|
|
31
|
+
}
|
|
32
|
+
getExtension() {
|
|
33
|
+
return this.getKey().split(".").pop() ?? "";
|
|
34
|
+
}
|
|
35
|
+
getContents() {
|
|
36
|
+
if (!this.contentsReader) throw Error("Asset contents reader was not configured!");
|
|
37
|
+
return this.contentsReader.read(this);
|
|
38
|
+
}
|
|
39
|
+
setContentsReader(reader) {
|
|
40
|
+
this.contentsReader = reader;
|
|
41
|
+
}
|
|
42
|
+
output() {
|
|
43
|
+
if (!this.outputStrategy) throw Error("Asset output strategy was not configured!");
|
|
44
|
+
return this.outputStrategy.output(this);
|
|
45
|
+
}
|
|
46
|
+
setOutputStrategy(setter) {
|
|
47
|
+
if ("function" == typeof setter) this.outputStrategy = setter(this.outputStrategy);
|
|
48
|
+
else this.outputStrategy = setter;
|
|
49
|
+
}
|
|
57
50
|
}
|
|
51
|
+
export { Asset };
|
|
58
52
|
|
|
59
53
|
//# sourceMappingURL=Asset.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"delivery/AssetDelivery/Asset.js","sources":["../../../src/delivery/AssetDelivery/Asset.ts"],"sourcesContent":["import type { AssetContentsReader, AssetOutputStrategy } from \"~/delivery/index.js\";\n\ntype Setter<T> = (arg: T | undefined) => T;\n\nexport interface AssetData {\n id: string;\n tenant: 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 return this.withProps(structuredClone(this.props));\n }\n\n withProps(props: Partial<AssetData>) {\n const newAsset = new Asset({ ...this.props, ...props });\n newAsset.contentsReader = this.contentsReader;\n newAsset.outputStrategy = this.outputStrategy;\n return newAsset;\n }\n\n getId() {\n return this.props.id;\n }\n getTenant() {\n return this.props.tenant;\n }\n getKey() {\n return this.props.key;\n }\n getSize() {\n return this.props.size;\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"],"names":["Asset","props","structuredClone","newAsset","Error","reader","setter"],"mappings":"AAYO,MAAMA;IAKT,YAAYC,KAAgB,CAAE;QAC1B,IAAI,CAAC,KAAK,GAAGA;IACjB;IAEA,QAAQ;QACJ,OAAO,IAAI,CAAC,SAAS,CAACC,gBAAgB,IAAI,CAAC,KAAK;IACpD;IAEA,UAAUD,KAAyB,EAAE;QACjC,MAAME,WAAW,IAAIH,MAAM;YAAE,GAAG,IAAI,CAAC,KAAK;YAAE,GAAGC,KAAK;QAAC;QACrDE,SAAS,cAAc,GAAG,IAAI,CAAC,cAAc;QAC7CA,SAAS,cAAc,GAAG,IAAI,CAAC,cAAc;QAC7C,OAAOA;IACX;IAEA,QAAQ;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE;IACxB;IACA,YAAY;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM;IAC5B;IACA,SAAS;QACL,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG;IACzB;IACA,UAAU;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI;IAC1B;IACA,iBAAiB;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW;IACjC;IACA,eAAe;QACX,OAAO,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,GAAG,MAAM;IAC7C;IAEA,cAAc;QACV,IAAI,CAAC,IAAI,CAAC,cAAc,EACpB,MAAMC,MAAM;QAEhB,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI;IACxC;IAEA,kBAAkBC,MAA2B,EAAE;QAC3C,IAAI,CAAC,cAAc,GAAGA;IAC1B;IAEA,SAAS;QACL,IAAI,CAAC,IAAI,CAAC,cAAc,EACpB,MAAMD,MAAM;QAGhB,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI;IAC1C;IAEA,kBAAkBE,MAAyD,EAAE;QACzE,IAAI,AAAkB,cAAlB,OAAOA,QACP,IAAI,CAAC,cAAc,GAAGA,OAAO,IAAI,CAAC,cAAc;aAEhD,IAAI,CAAC,cAAc,GAAGA;IAE9B;AACJ"}
|
|
@@ -5,90 +5,77 @@ import { NullAssetResolver } from "./NullAssetResolver.js";
|
|
|
5
5
|
import { NullAssetOutputStrategy } from "./NullAssetOutputStrategy.js";
|
|
6
6
|
import { TransformationAssetProcessor } from "./transformation/TransformationAssetProcessor.js";
|
|
7
7
|
import { PassthroughAssetTransformationStrategy } from "./transformation/PassthroughAssetTransformationStrategy.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return decorator({
|
|
66
|
-
context,
|
|
67
|
-
assetRequest,
|
|
68
|
-
asset,
|
|
69
|
-
assetOutputStrategy: value
|
|
70
|
-
});
|
|
71
|
-
}, new NullAssetOutputStrategy());
|
|
72
|
-
}
|
|
73
|
-
getAssetTransformationStrategy(context) {
|
|
74
|
-
return this.assetTransformationStrategyDecorators.reduce((value, decorator) => decorator({
|
|
75
|
-
context,
|
|
76
|
-
assetTransformationStrategy: value
|
|
77
|
-
}), new PassthroughAssetTransformationStrategy());
|
|
78
|
-
}
|
|
8
|
+
class AssetDeliveryConfigBuilder {
|
|
9
|
+
setResponseHeaders(setter) {
|
|
10
|
+
this.decorateAssetOutputStrategy((params)=>new SetResponseHeaders(setter, params));
|
|
11
|
+
}
|
|
12
|
+
decorateAssetRequestResolver(decorator) {
|
|
13
|
+
this.assetRequestResolverDecorators.push(decorator);
|
|
14
|
+
}
|
|
15
|
+
decorateAssetResolver(decorator) {
|
|
16
|
+
this.assetResolverDecorators.push(decorator);
|
|
17
|
+
}
|
|
18
|
+
decorateAssetProcessor(decorator) {
|
|
19
|
+
this.assetProcessorDecorators.push(decorator);
|
|
20
|
+
}
|
|
21
|
+
decorateAssetTransformationStrategy(decorator) {
|
|
22
|
+
this.assetTransformationStrategyDecorators.push(decorator);
|
|
23
|
+
}
|
|
24
|
+
decorateAssetOutputStrategy(decorator) {
|
|
25
|
+
this.assetOutputStrategyDecorators.push(decorator);
|
|
26
|
+
}
|
|
27
|
+
getAssetRequestResolver() {
|
|
28
|
+
return this.assetRequestResolverDecorators.reduce((value, decorator)=>decorator({
|
|
29
|
+
assetRequestResolver: value
|
|
30
|
+
}), new NullRequestResolver());
|
|
31
|
+
}
|
|
32
|
+
getAssetResolver(container) {
|
|
33
|
+
return this.assetResolverDecorators.reduce((value, decorator)=>decorator({
|
|
34
|
+
container,
|
|
35
|
+
assetResolver: value
|
|
36
|
+
}), new NullAssetResolver());
|
|
37
|
+
}
|
|
38
|
+
getAssetProcessor(context) {
|
|
39
|
+
return this.assetProcessorDecorators.reduce((value, decorator)=>decorator({
|
|
40
|
+
assetProcessor: value,
|
|
41
|
+
context
|
|
42
|
+
}), new TransformationAssetProcessor(this.getAssetTransformationStrategy(context)));
|
|
43
|
+
}
|
|
44
|
+
getAssetOutputStrategy(context, assetRequest, asset) {
|
|
45
|
+
return this.assetOutputStrategyDecorators.reduce((value, decorator)=>decorator({
|
|
46
|
+
context,
|
|
47
|
+
assetRequest,
|
|
48
|
+
asset,
|
|
49
|
+
assetOutputStrategy: value
|
|
50
|
+
}), new NullAssetOutputStrategy());
|
|
51
|
+
}
|
|
52
|
+
getAssetTransformationStrategy(context) {
|
|
53
|
+
return this.assetTransformationStrategyDecorators.reduce((value, decorator)=>decorator({
|
|
54
|
+
context,
|
|
55
|
+
assetTransformationStrategy: value
|
|
56
|
+
}), new PassthroughAssetTransformationStrategy());
|
|
57
|
+
}
|
|
58
|
+
constructor(){
|
|
59
|
+
this.assetRequestResolverDecorators = [];
|
|
60
|
+
this.assetResolverDecorators = [];
|
|
61
|
+
this.assetProcessorDecorators = [];
|
|
62
|
+
this.assetTransformationStrategyDecorators = [];
|
|
63
|
+
this.assetOutputStrategyDecorators = [];
|
|
64
|
+
}
|
|
79
65
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
66
|
+
class AssetDeliveryConfigModifierPlugin extends Plugin {
|
|
67
|
+
static{
|
|
68
|
+
this.type = "fm.config-modifier";
|
|
69
|
+
}
|
|
70
|
+
constructor(cb){
|
|
71
|
+
super();
|
|
72
|
+
this.cb = cb;
|
|
73
|
+
}
|
|
74
|
+
async buildConfig(configBuilder) {
|
|
75
|
+
await this.cb(configBuilder);
|
|
76
|
+
}
|
|
89
77
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
};
|
|
78
|
+
const createAssetDeliveryConfig = (cb)=>new AssetDeliveryConfigModifierPlugin(cb);
|
|
79
|
+
export { AssetDeliveryConfigBuilder, AssetDeliveryConfigModifierPlugin, createAssetDeliveryConfig };
|
|
93
80
|
|
|
94
81
|
//# sourceMappingURL=AssetDeliveryConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"delivery/AssetDelivery/AssetDeliveryConfig.js","sources":["../../../src/delivery/AssetDelivery/AssetDeliveryConfig.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type {\n AssetRequestResolver,\n AssetResolver,\n AssetProcessor,\n AssetOutputStrategy,\n AssetRequest,\n Asset,\n AssetTransformationStrategy,\n ResponseHeadersSetter\n} from \"~/delivery/index.js\";\nimport { SetResponseHeaders } from \"~/delivery/index.js\";\nimport { NullRequestResolver } from \"~/delivery/AssetDelivery/NullRequestResolver.js\";\nimport { NullAssetResolver } from \"~/delivery/AssetDelivery/NullAssetResolver.js\";\nimport { NullAssetOutputStrategy } from \"./NullAssetOutputStrategy.js\";\nimport { TransformationAssetProcessor } from \"./transformation/TransformationAssetProcessor.js\";\nimport { PassthroughAssetTransformationStrategy } from \"./transformation/PassthroughAssetTransformationStrategy.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { Container } from \"@webiny/di\";\n\ntype Setter<TParams, TReturn> = (params: TParams) => TReturn;\n\nexport type AssetRequestResolverDecorator = Setter<\n { assetRequestResolver: AssetRequestResolver },\n AssetRequestResolver\n>;\n\nexport type AssetResolverDecorator = Setter<\n { assetResolver: AssetResolver; container: Container },\n AssetResolver\n>;\n\nexport type AssetProcessorDecorator = Setter<\n { context: ApiCoreContext; assetProcessor: AssetProcessor },\n AssetProcessor\n>;\n\nexport type AssetTransformationDecorator = Setter<\n { context: ApiCoreContext; assetTransformationStrategy: AssetTransformationStrategy },\n AssetTransformationStrategy\n>;\n\nexport interface AssetOutputStrategyDecoratorParams {\n context: ApiCoreContext;\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(container: Container) {\n return this.assetResolverDecorators.reduce<AssetResolver>(\n (value, decorator) => decorator({ container, assetResolver: value }),\n new NullAssetResolver()\n );\n }\n\n /**\n * @internal\n */\n getAssetProcessor(context: ApiCoreContext) {\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: ApiCoreContext, 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: ApiCoreContext) {\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"],"names":["AssetDeliveryConfigBuilder","setter","params","SetResponseHeaders","decorator","value","NullRequestResolver","container","NullAssetResolver","context","TransformationAssetProcessor","assetRequest","asset","NullAssetOutputStrategy","PassthroughAssetTransformationStrategy","AssetDeliveryConfigModifierPlugin","Plugin","cb","configBuilder","createAssetDeliveryConfig"],"mappings":";;;;;;;AAsDO,MAAMA;IAOT,mBAAmBC,MAA6B,EAAE;QAC9C,IAAI,CAAC,2BAA2B,CAACC,CAAAA,SACtB,IAAIC,mBAAmBF,QAAQC;IAE9C;IAEA,6BAA6BE,SAAwC,EAAE;QACnE,IAAI,CAAC,8BAA8B,CAAC,IAAI,CAACA;IAC7C;IAEA,sBAAsBA,SAAiC,EAAE;QACrD,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAACA;IACtC;IAEA,uBAAuBA,SAAkC,EAAE;QACvD,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAACA;IACvC;IAEA,oCAAoCA,SAAuC,EAAE;QACzE,IAAI,CAAC,qCAAqC,CAAC,IAAI,CAACA;IACpD;IAEA,4BAA4BA,SAAuC,EAAE;QACjE,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAACA;IAC5C;IAKA,0BAA0B;QACtB,OAAO,IAAI,CAAC,8BAA8B,CAAC,MAAM,CAC7C,CAACC,OAAOD,YAAcA,UAAU;gBAAE,sBAAsBC;YAAM,IAC9D,IAAIC;IAEZ;IAKA,iBAAiBC,SAAoB,EAAE;QACnC,OAAO,IAAI,CAAC,uBAAuB,CAAC,MAAM,CACtC,CAACF,OAAOD,YAAcA,UAAU;gBAAEG;gBAAW,eAAeF;YAAM,IAClE,IAAIG;IAEZ;IAKA,kBAAkBC,OAAuB,EAAE;QACvC,OAAO,IAAI,CAAC,wBAAwB,CAAC,MAAM,CACvC,CAACJ,OAAOD,YAAcA,UAAU;gBAAE,gBAAgBC;gBAAOI;YAAQ,IACjE,IAAIC,6BAA6B,IAAI,CAAC,8BAA8B,CAACD;IAE7E;IAEA,uBAAuBA,OAAuB,EAAEE,YAA0B,EAAEC,KAAY,EAAE;QACtF,OAAO,IAAI,CAAC,6BAA6B,CAAC,MAAM,CAC5C,CAACP,OAAOD,YACGA,UAAU;gBAAEK;gBAASE;gBAAcC;gBAAO,qBAAqBP;YAAM,IAEhF,IAAIQ;IAEZ;IAEA,+BAA+BJ,OAAuB,EAAE;QACpD,OAAO,IAAI,CAAC,qCAAqC,CAAC,MAAM,CACpD,CAACJ,OAAOD,YAAcA,UAAU;gBAAEK;gBAAS,6BAA6BJ;YAAM,IAC9E,IAAIS;IAEZ;;aA5EQ,8BAA8B,GAAoC,EAAE;aACpE,uBAAuB,GAA6B,EAAE;aACtD,wBAAwB,GAA8B,EAAE;aACxD,qCAAqC,GAAmC,EAAE;aAC1E,6BAA6B,GAAmC,EAAE;;AAyE9E;AAMO,MAAMC,0CAA0CC;;aAC5B,IAAI,GAAG;;IAG9B,YAAYC,EAA+B,CAAE;QACzC,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;IAEA,MAAM,YAAYC,aAAyC,EAAiB;QACxE,MAAM,IAAI,CAAC,EAAE,CAACA;IAClB;AACJ;AAEO,MAAMC,4BAA4B,CAACF,KAC/B,IAAIF,kCAAkCE"}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
class AssetRequest {
|
|
2
|
+
constructor(data){
|
|
3
|
+
this.data = data;
|
|
4
|
+
}
|
|
5
|
+
getKey() {
|
|
6
|
+
return this.data.key;
|
|
7
|
+
}
|
|
8
|
+
getOptions() {
|
|
9
|
+
return this.data.options;
|
|
10
|
+
}
|
|
11
|
+
setOptions(options) {
|
|
12
|
+
this.data.options = options;
|
|
13
|
+
}
|
|
14
|
+
getContext() {
|
|
15
|
+
return this.data.context;
|
|
16
|
+
}
|
|
17
|
+
getExtension() {
|
|
18
|
+
return this.data.key.split(".").pop();
|
|
19
|
+
}
|
|
20
20
|
}
|
|
21
|
+
export { AssetRequest };
|
|
21
22
|
|
|
22
23
|
//# sourceMappingURL=AssetRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"delivery/AssetDelivery/AssetRequest.js","sources":["../../../src/delivery/AssetDelivery/AssetRequest.ts"],"sourcesContent":["import type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface AssetRequestOptions {\n original?: boolean;\n width?: number;\n}\n\nexport type AssetRequestContext<T extends GenericRecord = GenericRecord> = 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 extends GenericRecord = GenericRecord>() {\n return this.data.context as AssetRequestContext<T>;\n }\n\n getExtension() {\n return this.data.key.split(\".\").pop();\n }\n}\n"],"names":["AssetRequest","data","options"],"mappings":"AAoBO,MAAMA;IAGT,YAAYC,IAAgC,CAAE;QAC1C,IAAI,CAAC,IAAI,GAAGA;IAChB;IAEA,SAAS;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG;IACxB;IAEA,aAAuB;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO;IAC5B;IAEA,WAAWC,OAAiB,EAAE;QAC1B,IAAI,CAAC,IAAI,CAAC,OAAO,GAAGA;IACxB;IAEA,aAAsD;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO;IAC5B;IAEA,eAAe;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG;IACvC;AACJ"}
|
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
import { AssetRequest } from "./AssetRequest.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
class FilesAssetRequestResolver {
|
|
3
|
+
async resolve(request) {
|
|
4
|
+
if (!request.url.startsWith("/files/")) return;
|
|
5
|
+
const params = request.params ?? {};
|
|
6
|
+
const query = request.query ?? {};
|
|
7
|
+
const path = params["*"];
|
|
8
|
+
const options = {
|
|
9
|
+
...query,
|
|
10
|
+
original: "original" in query
|
|
11
|
+
};
|
|
12
|
+
if (query.width) options.width = parseInt(query.width);
|
|
13
|
+
return new AssetRequest({
|
|
14
|
+
key: decodeURI(path).replace("/files/", ""),
|
|
15
|
+
context: {
|
|
16
|
+
url: request.url
|
|
17
|
+
},
|
|
18
|
+
options
|
|
19
|
+
});
|
|
7
20
|
}
|
|
8
|
-
const params = request.params ?? {};
|
|
9
|
-
const query = request.query ?? {};
|
|
10
|
-
|
|
11
|
-
// Example: { '*': '/files/65722cb5c7824a0008d05963/image-48.jpg' },
|
|
12
|
-
const path = params["*"];
|
|
13
|
-
const options = {
|
|
14
|
-
...query,
|
|
15
|
-
original: "original" in query
|
|
16
|
-
};
|
|
17
|
-
if (query.width) {
|
|
18
|
-
options.width = parseInt(query.width);
|
|
19
|
-
}
|
|
20
|
-
return new AssetRequest({
|
|
21
|
-
key: decodeURI(path).replace("/files/", ""),
|
|
22
|
-
context: {
|
|
23
|
-
url: request.url
|
|
24
|
-
},
|
|
25
|
-
options
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
21
|
}
|
|
22
|
+
export { FilesAssetRequestResolver };
|
|
29
23
|
|
|
30
24
|
//# sourceMappingURL=FilesAssetRequestResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"delivery/AssetDelivery/FilesAssetRequestResolver.js","sources":["../../../src/delivery/AssetDelivery/FilesAssetRequestResolver.ts"],"sourcesContent":["import type { Request } from \"@webiny/handler/types.js\";\nimport type { AssetRequestResolver } from \"./abstractions/AssetRequestResolver.js\";\nimport type { AssetRequestOptions } from \"./AssetRequest.js\";\nimport { AssetRequest } from \"./AssetRequest.js\";\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 const options: AssetRequestOptions = {\n ...query,\n original: \"original\" in query\n };\n\n if (query.width) {\n options.width = parseInt(query.width);\n }\n\n return new AssetRequest({\n key: decodeURI(path).replace(\"/files/\", \"\"),\n context: {\n url: request.url\n },\n options\n });\n }\n}\n"],"names":["FilesAssetRequestResolver","request","params","query","path","options","parseInt","AssetRequest","decodeURI"],"mappings":";AAKO,MAAMA;IACT,MAAM,QAAQC,OAAgB,EAAqC;QAE/D,IAAI,CAACA,QAAQ,GAAG,CAAC,UAAU,CAAC,YACxB;QAGJ,MAAMC,SAAUD,QAAQ,MAAM,IAA4B,CAAC;QAC3D,MAAME,QAASF,QAAQ,KAAK,IAA4B,CAAC;QAGzD,MAAMG,OAAOF,MAAM,CAAC,IAAI;QAExB,MAAMG,UAA+B;YACjC,GAAGF,KAAK;YACR,UAAU,cAAcA;QAC5B;QAEA,IAAIA,MAAM,KAAK,EACXE,QAAQ,KAAK,GAAGC,SAASH,MAAM,KAAK;QAGxC,OAAO,IAAII,aAAa;YACpB,KAAKC,UAAUJ,MAAM,OAAO,CAAC,WAAW;YACxC,SAAS;gBACL,KAAKH,QAAQ,GAAG;YACpB;YACAI;QACJ;IACJ;AACJ"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { NullAssetReply } from "./NullAssetReply.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
class NullAssetOutputStrategy {
|
|
3
|
+
async output() {
|
|
4
|
+
return new NullAssetReply();
|
|
5
|
+
}
|
|
6
6
|
}
|
|
7
|
+
export { NullAssetOutputStrategy };
|
|
7
8
|
|
|
8
9
|
//# sourceMappingURL=NullAssetOutputStrategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"delivery/AssetDelivery/NullAssetOutputStrategy.js","sources":["../../../src/delivery/AssetDelivery/NullAssetOutputStrategy.ts"],"sourcesContent":["import type { AssetOutputStrategy, AssetReply } from \"~/delivery/index.js\";\nimport { NullAssetReply } from \"./NullAssetReply.js\";\n\nexport class NullAssetOutputStrategy implements AssetOutputStrategy {\n async output(): Promise<AssetReply> {\n return new NullAssetReply();\n }\n}\n"],"names":["NullAssetOutputStrategy","NullAssetReply"],"mappings":";AAGO,MAAMA;IACT,MAAM,SAA8B;QAChC,OAAO,IAAIC;IACf;AACJ"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { AssetReply } from "./abstractions/AssetReply.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
class NullAssetReply extends AssetReply {
|
|
3
|
+
constructor(){
|
|
4
|
+
super({
|
|
5
|
+
code: 404,
|
|
6
|
+
body: ()=>({
|
|
7
|
+
error: "Asset output strategy is not implemented!"
|
|
8
|
+
})
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
11
|
}
|
|
12
|
+
export { NullAssetReply };
|
|
12
13
|
|
|
13
14
|
//# sourceMappingURL=NullAssetReply.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"delivery/AssetDelivery/NullAssetReply.js","sources":["../../../src/delivery/AssetDelivery/NullAssetReply.ts"],"sourcesContent":["import { AssetReply } from \"~/delivery/AssetDelivery/abstractions/AssetReply.js\";\n\nexport class NullAssetReply extends AssetReply {\n constructor() {\n super({\n code: 404,\n body: () => ({ error: \"Asset output strategy is not implemented!\" })\n });\n }\n}\n"],"names":["NullAssetReply","AssetReply"],"mappings":";AAEO,MAAMA,uBAAuBC;IAChC,aAAc;QACV,KAAK,CAAC;YACF,MAAM;YACN,MAAM,IAAO;oBAAE,OAAO;gBAA4C;QACtE;IACJ;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"delivery/AssetDelivery/NullAssetResolver.js","sources":["../../../src/delivery/AssetDelivery/NullAssetResolver.ts"],"sourcesContent":["import type { AssetResolver } from \"./abstractions/AssetResolver.js\";\nimport type { Asset } from \"./Asset.js\";\n\nexport class NullAssetResolver implements AssetResolver {\n resolve(): Promise<Asset | undefined> {\n return Promise.resolve(undefined);\n }\n}\n"],"names":["NullAssetResolver","Promise","undefined"],"mappings":"AAGO,MAAMA;IACT,UAAsC;QAClC,OAAOC,QAAQ,OAAO,CAACC;IAC3B;AACJ"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
class NullRequestResolver {
|
|
2
|
+
resolve() {
|
|
3
|
+
return Promise.resolve(void 0);
|
|
4
|
+
}
|
|
5
5
|
}
|
|
6
|
+
export { NullRequestResolver };
|
|
6
7
|
|
|
7
8
|
//# sourceMappingURL=NullRequestResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"delivery/AssetDelivery/NullRequestResolver.js","sources":["../../../src/delivery/AssetDelivery/NullRequestResolver.ts"],"sourcesContent":["import type { AssetRequest, AssetRequestResolver } from \"~/delivery/index.js\";\n\nexport class NullRequestResolver implements AssetRequestResolver {\n resolve(): Promise<AssetRequest | undefined> {\n return Promise.resolve(undefined);\n }\n}\n"],"names":["NullRequestResolver","Promise","undefined"],"mappings":"AAEO,MAAMA;IACT,UAA6C;QACzC,OAAOC,QAAQ,OAAO,CAACC;IAC3B;AACJ"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
class SetCacheControlHeaders {
|
|
2
|
+
constructor(headers, strategy){
|
|
3
|
+
this.headers = headers;
|
|
4
|
+
this.strategy = strategy;
|
|
5
|
+
}
|
|
6
|
+
async output(asset) {
|
|
7
|
+
if (!this.strategy) throw Error("No asset output strategy is configured!");
|
|
8
|
+
const reply = await this.strategy.output(asset);
|
|
9
|
+
reply.setHeaders((headers)=>headers.merge(this.headers));
|
|
10
|
+
return reply;
|
|
9
11
|
}
|
|
10
|
-
const reply = await this.strategy.output(asset);
|
|
11
|
-
reply.setHeaders(headers => {
|
|
12
|
-
return headers.merge(this.headers);
|
|
13
|
-
});
|
|
14
|
-
return reply;
|
|
15
|
-
}
|
|
16
12
|
}
|
|
13
|
+
export { SetCacheControlHeaders };
|
|
17
14
|
|
|
18
15
|
//# sourceMappingURL=SetCacheControlHeaders.js.map
|