Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODATAv4 client is missing bound function/action #4577

Closed
GoWale opened this issue Mar 20, 2024 · 4 comments
Closed

ODATAv4 client is missing bound function/action #4577

GoWale opened this issue Mar 20, 2024 · 4 comments

Comments

@GoWale
Copy link

GoWale commented Mar 20, 2024

Describe the bug
the documentation tell ther shoud be support for bound an unbound functions on:
https://sap.github.io/cloud-sdk/docs/js/features/odata/v4-client#using-operations

but the bound functions/actions are missing in my odata v4 example

To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/GoWale/issue-cloud_sdk-odatav4-action.git
npm i

  1. Set up npm run start
  2. Execute sdk_gen_client
  3. Confirm go to /srv/server.ts and uncomment the example coding
  4. See error

Expected behavior
Like the unbound function/action

  const {
    operations: { countOrders, cancelOrder, getOpenOrders },
  } = capOdatav4();
  await countOrders({}).execute(destination);
  await getOpenOrders({}).execute(destination);
  await cancelOrder({}).execute(destination);

also the bound function/action

  const entity = belegeApi.requestBuilder().getByKey("0292da0e-649d-4a4c-9a8b-fd47759e6e73").execute(destination);
  await entity.sendLetter({}).execute(destination);
  await entity.getViewsCount({}).execute(destination);

should work like stated in the documentation

Used Versions:

  • node version v20.10.0
  • npm version 10.2.5
  • SAP Cloud SDK version you used as dependency
    "@sap-cloud-sdk/generator": "^3.12.1",

Impact / Priority

medium: bound functions/action have to be implemented by hand an there are no types for parameter/results

Affected development phase: Development / CI/CD

@GoWale GoWale added the bug Something isn't working label Mar 20, 2024
@deekshas8 deekshas8 removed the bug Something isn't working label Mar 21, 2024
@deekshas8
Copy link
Contributor

Hi @GoWale ,

There seems to be an issue with your v4 spec. If I also include the reference to bound action import inside the EntityContainer tag, then the generation works as expected.

<EntityContainer Name="EntityContainer">
...
...
<ActionImport Name="sendLetter" Action="main_service.sendLetter"/>
</EntityContainer>

@GoWale
Copy link
Author

GoWale commented Mar 21, 2024

Hi @deekshas8 ,

thanks for the reply. But just to be sure.
As fare as I understand the OASIS OData documentation for bound actions there ist no need for an ActionImport.
But it is required for unbound actions.

See chapter 12

12.1 Element edm:Action
The edm:Action element represents an action in an entity model.
Actions MAY have observable side effects and MAY return a single instance or a collection of instances of any type. Actions cannot be composed with additional path segments.
The action MAY specify a return type using the edm:ReturnType element. The return type must be a primitive, entity or complex type, or a collection of primitive, entity or complex types.
The action may also define zero or more edm:Parameter elements to be used during the execution of the action.

12.1.2 Attribute IsBound
An action element MAY specify a Boolean value for the IsBound attribute.
Actions whose IsBound attribute is false or not specified are considered unbound. Unbound actions are invoked through an action import.
Actions whose IsBound attribute is true are considered bound. Bound actions are invoked by appending a segment containing the qualified action name to a segment of the appropriate binding parameter type within the resource path. Bound actions MUST contain at least one edm:Parameter element, and the first parameter is the binding parameter. The binding parameter can be of any type, and it MAY be nullable.
Action from CAP framework:
image

13.5 Element edm:ActionImport
The edm:ActionImport element allows exposing an unbound action as a top-level element in an entity container. Action imports are never advertised in the service document.

For that reason I have created the issue here.
But if you say also bound Actions have to be listed in the ActionImport I will create an OSS ticket for the CAP (JS) and RAP implementation.
It seams like both implementations are doing it the same way (No ActionImport for bound actions).

regards
Norbert

@ghost
Copy link

ghost commented Mar 22, 2024

I think this is related to #707 and also #4543

should we still ad a comment to #707 as mentioned here: https://sap.github.io/cloud-sdk/docs/js/features/odata/v4-client#known-issues

Currently, the Entity Type is not supported to be used as the parameters of the operation. Operations with such unsupported parameters are ignored during the generation. This feature will be implemented in the future. Please check this issue and comment if you need this feature.

@mr-flannery
Copy link
Contributor

Hi @nlaenger ,

sorry for the late response. While we're aware that this is a gap in our generator, we currently do not have the capacity to address this. You can open tickets with CAP and RAP, but if they're following the spec, I'm not sure how keen they are on implementing workarounds for gaps in the Cloud SDK. I'm afraid you will either need to find a workaround or make a contribution to the SDK.

Feel free to also comment #707 so that we have everything in one place.

Best regards,
Dennis

@mr-flannery mr-flannery closed this as not planned Won't fix, can't repro, duplicate, stale Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants