cap-js / cds-types

Type definitions for CDS
Apache License 2.0
10 stars 10 forks source link

[BUG] Missing types for cds.minify and cds.compile.for.nodejs() #292

Closed BastiInnovation closed 1 month ago

BastiInnovation commented 1 month ago

Is there an existing issue for this?

Current Behavior

My Backend is running with nestjs. You can find my Project here: https://github.com/BastiInnovation/cap-template.

While compiling the project i received two errors:

Property 'minify' does not exist on type 'typeof import("@sap/cds")'.

Property 'nodejs' does not exist on type '{ odata(model: CSN, o?: _options): CSN; sql(model: CSN, o?: _options): CSN; }'.

Currently the typedefinitions for .minify and .nodejs are missing in cds-types

 const csn = await cds.load('cds').then(cds.minify) // Type is missing
 cds.model = cds.compile.for.nodejs(csn) // Type is missing

Expected Behavior

No response

References

Here the references to CAPier articles: cds.minify

cds.compile.for.nodejs as not yet been documented.

Versions

appname https://github.com/BastiInnovation/cap-template
@cap-js/asyncapi 1.0.2
@cap-js/cds-typer 0.27.0
@cap-js/openapi 1.0.6
@sap/cds 8.3.1
@sap/cds-compiler 5.3.2
@sap/cds-dk 8.3.0
@sap/eslint-plugin-cds 3.1.0
Node.js v20.11.0

Anything else? Logs?

No response

Markus-Schroeder-de commented 1 month ago

call in the root "npm rebuild" and check if you have the sym link in the npm-registry with the cds__ (double underscore) see https://github.com/cap-js/cds-types/issues/251

daogrady commented 1 month ago

Hi @BastiInnovation ,

I will look into the missing .minify, but compile.for.nodejs appears to not/ no longer be supported:

> cds c --help

  ...
  -4 | --for <target>

    Unfolds the compiled CSN for the specified <target> usages,
    or get a comma-separated list, without generating target formats.
    Currently supported:

    - odata
    - sql

Best, Daniel

BastiInnovation commented 1 month ago

Hi @daogrady, thank u for u quick reply. Yesterday I got the information from SAP support that i have to use compile.for.nodejs if I want to keep my own initialization logic...

Best regards, Bastian

David-Kunz commented 1 month ago

Hi @daogrady ,

Just to confirm: Stakeholders with an own initialization logic need to set cds.model, which requires compile.for.nodejs. It's also documented on capire.

daogrady commented 1 month ago

Hi @David-Kunz ,

thanks for confirming! I have prepared a fix, but I am still unclear on some details. Let's maybe take this opportunity to clear this and a few other questions up in a sync these days.

Best, Daniel