Open MarvinWeitz opened 2 weeks ago
Hi Marvin,
What could be the cause of this problem?
Good question! I tried reproducing your issue using the minimal model you provided. I then ran cds build
, and there I see:
// file: gen/srv/@cds-models/ProcessorService/index.js
// This is an automatically generated file. Please do not change its contents manually!
const cds = require('@sap/cds')
const csn = cds.entities('ProcessorService')
// service
const ProcessorService = { name: 'ProcessorService' }
module.exports = ProcessorService
module.exports.ProcessorService = ProcessorService
// events
// actions
module.exports.test = 'test'
// enums
The line module.exports.test = 'test'
should facilitate the use of actions in .on(...)
, as this basically is a variable containing the string 'test'
.
Can you confirm this file is properly generated in your project?
Best, Daniel
Yes, this is the case. I just checked what the .mtar
archive contains after performing mbt build
. The main files (shortened):
./srv/services.js:
const cds_1 = require("@sap/cds");
const ProcessorService_1 = require("#cds-models/ProcessorService");
class ProcessorService extends cds_1.ApplicationService {
async init() {
this.on(ProcessorService_1.test, async (req) => {...}
}
./package.json:
{
"imports": {
"#cds-models/*": "./@cds-models/*/index.js"
}
}
./@cds-models/ProcessorService/index.js:
// This is an automatically generated file. Please do not change its contents manually!
const cds_1 = __importDefault(require("@sap/cds"));
const __ = __importStar(require("./../_"));
class ProcessorService extends cds_1.default.Service {
}
exports.ProcessorService = ProcessorService;
exports.default = ProcessorService;
With no sign of test
in sight...
Hi Marvin,
this actually looks like the final step of copying the untranspiled JS files over the transpiled ones in the build step has not run properly in your case. Could you please provide a repository with a minimal working sample so I can reproduce the issue for your particular case?
Best, Daniel
Question
Hi everyone. I have a problem regarding actions.
I am using a simple test action
that I want to define in my
service.ts
This works locally when trying it locally via
cds-ts watch
but after building the mta viamta build
and deploying it to cf viacf deploy test.mtar
, the ProcessorService is not able to load (It doesn't show any data in the ListView I am using). It also failes when usingrequire
as staed in the docs It does however work when I use the quoted action namethis.on("test", (req: Request) => {...}
.What could be the cause of this problem?