Skip to content
Open
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
0e307f9
New test for discard deleting content
eric-pSAP Feb 5, 2026
16ddf40
Update tests/integration/attachments.test.js
eric-pSAP Feb 5, 2026
832532d
Merge branch 'main' into deletingDiscardDraft
eric-pSAP Feb 5, 2026
dace316
req.diff() replaced
eric-pSAP Feb 10, 2026
24ed48c
Remove semicolons
eric-pSAP Feb 10, 2026
7172d56
Better filter out attachment compositions
eric-pSAP Feb 11, 2026
256418b
Refactor columns selection
eric-pSAP Feb 11, 2026
d3aa0c0
Syntax adjustment
eric-pSAP Feb 11, 2026
ddb26cf
Remove initial *
eric-pSAP Feb 12, 2026
3925a82
Initial commit for single attachment
eric-pSAP Feb 18, 2026
ca1e765
Merge branch 'main' into singleAttachment
eric-pSAP Feb 18, 2026
8a1d26c
Update tests/incidents-app/db/schema.cds
eric-pSAP Feb 18, 2026
ee53aaa
Fix bot edit
eric-pSAP Feb 18, 2026
19e40c7
ID checks to make bot happy
eric-pSAP Feb 18, 2026
9771096
Remove reference to non-existent field
eric-pSAP Feb 18, 2026
8dd385a
Prettier should ignore test headers
eric-pSAP Feb 18, 2026
0edf07f
Clean up indentation
eric-pSAP Feb 18, 2026
f00bb12
Data added and tests updated
eric-pSAP Feb 20, 2026
06b68c0
Prettier
eric-pSAP Feb 20, 2026
888a2a0
Merge branch 'main' into singleAttachment
eric-pSAP Feb 20, 2026
531f68f
Code refactoring
eric-pSAP Apr 15, 2026
c516c04
Test bug fixes 1
eric-pSAP Apr 15, 2026
fd7d395
Basic size limit bug fix
eric-pSAP Apr 16, 2026
53ecb16
ESLint 10 for testing
eric-pSAP Apr 16, 2026
4bc262e
POST size limit bug fix
eric-pSAP Apr 16, 2026
863aa22
Merge remote-tracking branch 'origin/main' into singleAttachment
eric-pSAP Apr 16, 2026
f51f4c4
Merge
eric-pSAP Apr 16, 2026
2f3aefa
More merge conflict resolution
eric-pSAP Apr 16, 2026
1823042
Lint fixes
eric-pSAP Apr 16, 2026
3629fdd
Make lint happy
eric-pSAP Apr 16, 2026
2e2d6c6
Make Postgres happy
eric-pSAP Apr 16, 2026
b5f0012
Merge conflict
eric-pSAP Apr 17, 2026
e622052
Merge conflict
eric-pSAP Apr 17, 2026
b275606
Naming of tests fixed
eric-pSAP Apr 17, 2026
e50a472
Re-add conditional changes
eric-pSAP Apr 17, 2026
df5eecc
Remove attachment hard-coding
eric-pSAP Apr 17, 2026
0be1e75
Bug fixes
eric-pSAP Apr 17, 2026
c0f1e34
Waiter fixed for single attachment
eric-pSAP Apr 27, 2026
1d6ffad
AWS bug fix
eric-pSAP Apr 28, 2026
9bd113b
AWS bug fix
eric-pSAP Apr 28, 2026
bb9641e
Merge conflict resolution
eric-pSAP Apr 29, 2026
634bc7b
Adjustments
eric-pSAP Apr 29, 2026
ae95d3f
More tests, bug fixes, GH suggestions
eric-pSAP Apr 29, 2026
867edda
More bug tests and fixes
eric-pSAP Apr 29, 2026
58f0e83
Test adjustment for Postgres
eric-pSAP Apr 29, 2026
de122d8
UI bug fixes
eric-pSAP Apr 30, 2026
4268ce3
Prettier
eric-pSAP Apr 30, 2026
0f07775
Re-set tests
eric-pSAP May 4, 2026
39df9d8
Await scanning function
eric-pSAP May 6, 2026
4e3da4c
Revert
eric-pSAP May 6, 2026
d6442c8
Merge branch 'main' into singleAttachment
eric-pSAP May 7, 2026
9a6bf56
Remove race condition from test
eric-pSAP May 7, 2026
5fbf56c
Merge branch 'singleAttachment' of https://github.com/cap-js/attachme…
eric-pSAP May 7, 2026
d13ce95
Test adjustment
eric-pSAP May 7, 2026
d47c06c
Clean up tests after completing
eric-pSAP May 15, 2026
338d748
Clean up tests after completing
eric-pSAP May 15, 2026
064cb18
Hybrid UI fix
eric-pSAP May 15, 2026
4ddd103
Walk back Ui fix
eric-pSAP May 15, 2026
ebdd840
Prettier
eric-pSAP May 15, 2026
7a66e2b
Make scan status consistent after deleting
eric-pSAP May 19, 2026
d696d61
Helper functions for longer functions
eric-pSAP May 20, 2026
394bb94
Merge branch 'main' into singleAttachment
eric-pSAP May 20, 2026
91d9679
Direct cds query and adjust race condition test
eric-pSAP May 20, 2026
860e09c
Merge branch 'main' into singleAttachment
eric-pSAP May 20, 2026
a889854
Revert broken test
eric-pSAP May 21, 2026
3ffa207
Merge branch 'singleAttachment' of https://github.com/cap-js/attachme…
eric-pSAP May 21, 2026
9859673
feat: review comments
eric-pSAP May 27, 2026
5acf9cf
fix: timeout from race condition
eric-pSAP May 27, 2026
5abae74
Merge branch 'main' into singleAttachment
eric-pSAP May 28, 2026
a932cbe
feat: UI injection
eric-pSAP May 28, 2026
6426b29
prettier
eric-pSAP May 28, 2026
0f58e3e
fix: adjust race condition test
eric-pSAP May 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ InvalidContentLengthHeader=The 'Content-Length' header value '{contentLength}' i
AttachmentAlreadyExistsCannotBeOverwritten=Attachment {0} already exists and cannot be overwritten.
MaximumAmountExceeded=Cannot upload more than {0} attachments!
MinimumAmountNotFulfilled=At least {0} attachments must be uploaded!
UnableToDownloadAttachmentScanStatusExpired=The previous scan was more than 3 days ago, please try to download again in a moment, after the attachment was rescanned.
UnableToDownloadAttachmentScanStatusExpired=The previous scan was more than 3 days ago, please try to download again in a moment, after the attachment is rescanned.
16 changes: 10 additions & 6 deletions db/index.cds
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// The common root-level aspect used in applications like that:
// using { Attachments } from '@cap-js/attachments'
aspect Attachments : sap.attachments.Attachments {}
type Attachment : sap.attachments.Attachment;

using {
managed,
Expand All @@ -10,16 +11,19 @@ using {

context sap.attachments {

aspect MediaData @(_is_media_data) {
type Attachment @(_is_media_data) {
url : String @UI.Hidden;
content : LargeBinary @title: '{i18n>Attachment}'; // only for db-based services
content : LargeBinary @title: '{i18n>Attachment}' @Core.MediaType: 'application/octet-stream'; // only for db-based services
Comment thread
eric-pSAP marked this conversation as resolved.
mimeType : String default 'application/octet-stream' @title: '{i18n>MediaType}';
filename : String @title: '{i18n>FileName}';
hash : String @UI.Hidden @Core.Computed;
status : String default 'Unscanned' @title: '{i18n>ScanStatus}' @Common.Text: statusNav.name @Common.TextArrangement: #TextOnly;
hash : String @UI.Hidden @Core.Computed;
status : String default 'Unscanned' @title: '{i18n>ScanStatus}' @readonly;
lastScan : Timestamp @title: '{i18n>LastScan}' @Core.Computed @readonly;
}

aspect MediaData : Attachment {
statusNav : Association to one ScanStates
on statusNav.code = status;
lastScan : Timestamp @title: '{i18n>LastScan}' @Core.Computed;
}

entity ScanStates : CodeList {
Expand Down Expand Up @@ -48,7 +52,7 @@ context sap.attachments {
annotate MediaData with @UI.MediaResource: {Stream: content} {
content @Core.MediaType: mimeType @odata.draft.skip;
mimeType @Core.IsMediaType;
status @readonly;
status @Common.Text: statusNav.name @Common.TextArrangement: #TextOnly;
}

annotate Attachments with @UI: {
Expand Down
17 changes: 17 additions & 0 deletions lib/csn-runtime-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ function collectAttachments(
return resultSet
}

function getInlineAttachmentPrefixes(entity) {
Comment thread
eric-pSAP marked this conversation as resolved.
if (entity?.["@_is_media_data"]) return [] // entity itself is composition-based
const prefixes = []
for (const [name, elem] of Object.entries(entity?.elements ?? {})) {
if (name.endsWith("_content") && elem?.["@_is_media_data"]) {
prefixes.push(name.slice(0, -"_content".length))
}
}
return prefixes
}

function hasAttachmentsComposition(entity, visitedEdges = new Set()) {
if (!entity?.compositions) return false

Expand Down Expand Up @@ -57,6 +68,12 @@ Object.defineProperty(cds.builtin.classes.entity.prototype, "_attachments", {
get isAttachmentsEntity() {
return !!entity?.["@_is_media_data"]
},
get inlineAttachmentPrefixes() {
return getInlineAttachmentPrefixes(entity)
},
get hasInlineAttachments() {
return getInlineAttachmentPrefixes(entity).length > 0
Comment thread
eric-pSAP marked this conversation as resolved.
Outdated
},
}
},
})
Loading
Loading