Commit 51ae0e4
Add content overwrite support (#415)
# Add Content Overwrite Support for Attachments
### New Feature
✨ Introduces configurable content overwrite behavior for the
`@cap-js/attachments` plugin. By default, attachment content is
protected from being overwritten (returning a `409 Conflict` error).
Users can now opt-in to allow content overwrites on a per-composition
basis using the
`@Capabilities.UpdateRestrictions.NonUpdateableProperties` annotation.
### Changes
* `db/index.cds`: Added default annotation
`@Capabilities.UpdateRestrictions.NonUpdateableProperties: [content]` to
the `Attachments` aspect, preventing content overwrites out of the box.
* `srv/basic.js`: Introduced the `_isContentUpdateRestricted()` helper
method that inspects the
`@Capabilities.UpdateRestrictions.NonUpdateableProperties` annotation on
an attachment entity. The existing 409-conflict check in `put()` is now
gated behind this helper, so the restriction is only enforced when the
annotation includes `content`.
* `srv/aws-s3.js`, `srv/azure-blob-storage.js`, `srv/gcp.js`: Updated
the `put()` upload guard in all three storage backends to call
`_isContentUpdateRestricted()` before checking for an existing file,
enabling overwrite behavior when the annotation allows it.
* `tests/incidents-app/db/attachments.cds`: Added a new
`overwritableAttachments` composition annotated with
`@Capabilities.UpdateRestrictions.NonUpdateableProperties: []` for
testing the opt-in overwrite scenario.
* `tests/integration/attachments-non-draft.test.js`: Added an
integration test that verifies content can be successfully overwritten
when the annotation is set to an empty array.
* `README.md`: Added a new **Allow Overwriting Attachment Content**
section documenting the feature, including a CDS example and a note
about runtime evaluation across storage backends. Also updated the Table
of Contents.
* `CHANGELOG.md`: Documented the new feature under version `3.11.0`.
* `package.json`: Bumped version from `3.10.0` to `3.11.0`.
- [ ] 🔄 Regenerate and Update Summary
---
📬 [Subscribe to the Hyperspace PR Bot DL](https://url.sap/451kgs) to get
the latest announcements and pilot features!
<details>
<summary>PR Bot Information</summary>
**Version:** `1.19.15` | 📖 [Documentation](https://url.sap/dy9ocn) | 🚨
[Create Incident](https://url.sap/budnv9) | 💬
[Feedback](https://url.sap/my4dn3)
- Output Template: [Default
Template](https://github.tools.sap/intelligent-insights/i2-pull-request/blob/main/src/services/llm/prompts/summary_default_output_template.md)
- Summary Prompt: [Default
Prompt](https://github.tools.sap/intelligent-insights/i2-pull-request/blob/main/src/services/llm/prompts/summary_instructions_prompt.md)
- File Content Strategy: Full file content
- LLM: `anthropic--claude-4.6-sonnet`
- Correlation ID: `5ade5400-2e74-11f1-9f6b-5a4534e5aad0`
- Event Trigger: `pull_request.opened`
</details>
---------
Co-authored-by: Marten Schiwek <marten.schiwek@sap.com>1 parent 0619fac commit 51ae0e4
10 files changed
Lines changed: 136 additions & 13 deletions
File tree
- db
- srv
- tests
- incidents-app/db
- integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
7 | 15 | | |
8 | 16 | | |
9 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
446 | 449 | | |
447 | 450 | | |
448 | 451 | | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
449 | 476 | | |
450 | 477 | | |
451 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
175 | 178 | | |
176 | 179 | | |
177 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
160 | 163 | | |
161 | 164 | | |
162 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
73 | 95 | | |
74 | 96 | | |
75 | 97 | | |
| |||
81 | 103 | | |
82 | 104 | | |
83 | 105 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
92 | 116 | | |
93 | 117 | | |
94 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
166 | 169 | | |
167 | 170 | | |
168 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
227 | 272 | | |
228 | 273 | | |
229 | 274 | | |
| |||
0 commit comments