dxfrontier / cds-ts-dispatcher

SAP CAP TypeScript entity handler dispatcher.
11 stars 2 forks source link

[FEATURE] Ability to inject `outboxed` service #86

Closed hakimio closed 1 week ago

hakimio commented 1 month ago

Description

Would be nice to be able to directly inject outboxed service. TS types for cds.outboxed() were introduced in cds-types v0.3.0-beta.1.

Suggested solution

    @Inject(CDS_DISPATCHER.OUTBOXED_SRV)
    private readonly outboxedSrv: Service;
dragolea commented 1 month ago

I've never used this cds.outboxed, pls, give me a very simple use case so I know what's all about.

hakimio commented 1 month ago

Basically it allows you to:

EDIT: Unfortunately, cds-types v0.2.0 which works with cds v7 does not define cds.outboxed() function.

dragolea commented 1 month ago

Let's leave it open. Somehow the new version of cds@8 and all related packages like cds-types are not in great shape in terms of typescript, they have removed a lot of types in the new version.

hakimio commented 1 month ago

Ok, if anyone else wants to use outboxed() with cds v7 and cds-types v0.2.0, here is the type definition for outboxed():

declare module '@sap/cds' {
    import {Service} from '@cap-js/cds-types';

    export * from '@cap-js/cds-types';
    export declare const outboxed: (service: Service) => Service;
}
dragolea commented 1 month ago

Ok, just did a small feasability check, and this should not be that hard to implement. If you follow this feature in the new cds-types package, let me know once it's there and I will start impelemnting it.

hakimio commented 1 month ago

The type is already in the new cds-types package, starting with v0.3.0-beta.1. The only problem is that cds-types v0.3.0+ is not compatible with cds v7.

https://github.com/cap-js/cds-types/blob/526cbb1be82afdc3377469509278e546d71b9088/apis/services.d.ts#L452

dragolea commented 1 month ago

Ok, understood, once we have a stable cds-types I will work on this new feature.

lianas10tb commented 3 weeks ago

Help me do this