kalai-attach 1.0.1 → 1.0.3
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/lib/csn-runtime-extension.js +27 -16
- package/package.json +3 -3
|
@@ -13,19 +13,30 @@ function collectAttachments(ent, resultSet = [], path = []) {
|
|
|
13
13
|
return resultSet
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
16
|
+
// Check if the property already exists to prevent crashes
|
|
17
|
+
if (!Object.prototype.hasOwnProperty.call(cds.builtin.classes.entity.prototype, '_attachments')) {
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(cds.builtin.classes.entity.prototype, '_attachments', {
|
|
20
|
+
configurable: true, // <--- CRITICAL: Allows redefinition/extension without crashing
|
|
21
|
+
enumerable: false,
|
|
22
|
+
get() {
|
|
23
|
+
const entity = this;
|
|
24
|
+
return {
|
|
25
|
+
get hasAttachmentsComposition() {
|
|
26
|
+
return entity.compositions &&
|
|
27
|
+
Object.keys(entity.compositions).some(ele =>
|
|
28
|
+
entity.compositions[ele]._target?.["@_is_media_data"] ||
|
|
29
|
+
entity.compositions[ele]._target?._attachments?.hasAttachmentsComposition
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
get attachmentCompositions() {
|
|
33
|
+
// Ensure collectAttachments is imported/available in your lib
|
|
34
|
+
return collectAttachments(entity);
|
|
35
|
+
},
|
|
36
|
+
get isAttachmentsEntity() {
|
|
37
|
+
return !!entity?.["@_is_media_data"];
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kalai-attach",
|
|
3
3
|
"description": "CAP cds-plugin providing image and attachment storing out-of-the-box.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"repository": "capjsattachments-kalai",
|
|
6
6
|
"author": "Kalai",
|
|
7
7
|
"homepage": "https://github.com/Kalaikovan-airdit",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"requires": {
|
|
43
43
|
"kinds": {
|
|
44
44
|
"attachments-azure": {
|
|
45
|
-
"impl": "
|
|
45
|
+
"impl": "kalai-attach/srv/azure-blob-storage"
|
|
46
46
|
},
|
|
47
47
|
"malwareScanner-mocked": {
|
|
48
|
-
"model": "
|
|
48
|
+
"model": "kalai-attach/srv/malwareScanner-mocked"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"attachments": {
|