cap-js / attachments

The @cap-js/attachments package is a CDS plugin that provides out-of-the box asset storage and handling by using an aspect Attachments. It also provides a CAP-level, easy to use integration of the SAP Object Store.
Apache License 2.0
6 stars 4 forks source link

Cannot add custom fields/logic to Attachments entity #65

Open Zahlii opened 2 weeks ago

Zahlii commented 2 weeks ago
using {Attachments} from '@cap-js/attachments';
// also using {Attahcment as BaseAttachments} and naming our entity Attachments : BaseAttachments same error

entity UIAttachments : Attachments {
    approvalStatus                  : Association to cdh.Status @readonly;
}

entity Bla {
  attachments                             : Composition of many UIAttachments;
}

Results in:

[cds] - ❗️Uncaught TypeError: Cannot read properties of undefined (reading 'xpr')
    at _addKeysToData (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js:67:22)
    at _addKeysToData (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js:69:12)
    at _addForeignKeys (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js:159:5)
    at getData (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/utils/data.js:284:5)
    at new ODataRequest (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/ODataRequest.js:141:20)
    at /Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/handlers/create.js:27:13
    at /Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/Dispatcher.js:135:7
    at new Promise (<anonymous>)
    at Dispatcher._handle (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/Dispatcher.js:134:12)
    at Dispatcher.dispatch (/Users/***/PycharmProjects/cockpit/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/core/Dispatcher.js:97:21) {
  id: '1350143',
  level: 'ERROR',
  timestamp: 1718184547532
}
Zahlii commented 2 weeks ago

I was able to work around this by simply extending the given Attachments entity:

extend Attachments with {
    approvalStatus                  : Association to cdh.Status @readonly;
}