N
Novu•3y ago
dr.really

Type 'MyProvider' is not assignable to type 'ISmsProvider'

This might be a little winded but go with me here lol I'm creating a new SMS provider to allow an enterprise SNPP connection. (more on that in the PR) - anyways, when creating the customSnpp.handler.ts file, and assigning this.provider = new CustomSnppSmsProvider(config); I'm getting an error that states Type 'CustomSnppSmsProvider' is not assignable to type 'ISmsProvider', however everything is set up properly. If I do this.provider = new CustomSnppSmsProvider(config) as any;, the project compiles and runs but I don't like do the any claim in typescript. Here is a snipping of the Provider:
export class CustomSnppSmsProvider implements ISmsProvider {
id = 'customsnpp';
channelType = ChannelTypeEnum.SMS as ChannelTypeEnum.SMS;

constructor(
private config: {
host: string;
port: number;
username: string;
password: string;
}
) {
this.config = config;
}

async sendMessage(
options: ISmsOptions
): Promise<ISendMessageSuccessResponse> {
const client = new net.Socket();
let responseCode = '';

......
export class CustomSnppSmsProvider implements ISmsProvider {
id = 'customsnpp';
channelType = ChannelTypeEnum.SMS as ChannelTypeEnum.SMS;

constructor(
private config: {
host: string;
port: number;
username: string;
password: string;
}
) {
this.config = config;
}

async sendMessage(
options: ISmsOptions
): Promise<ISendMessageSuccessResponse> {
const client = new net.Socket();
let responseCode = '';

......
and here is a snipping of the handler:
export class CustomSnppHandler extends BaseSmsHandler {
constructor() {
super('customsnpp', ChannelTypeEnum.SMS);
}

buildProvider(credentials: ICredentials) {
const config: {
host: string;
port: number;
username: string;
password: string;
} = {
host: credentials.host,
port: +credentials.port,
username: credentials.user,
password: credentials.password,
};

this.provider = new CustomSnppSmsProvider(config);
}
}
export class CustomSnppHandler extends BaseSmsHandler {
constructor() {
super('customsnpp', ChannelTypeEnum.SMS);
}

buildProvider(credentials: ICredentials) {
const config: {
host: string;
port: number;
username: string;
password: string;
} = {
host: credentials.host,
port: +credentials.port,
username: credentials.user,
password: credentials.password,
};

this.provider = new CustomSnppSmsProvider(config);
}
}
thoughts?
25 Replies
empe
empe•3y ago
@Support @Moderator Please have a look
BiswaViraj
BiswaViraj•3y ago
Could you send the import part of the handler file?
dr.really
dr.reallyOP•3y ago
yessir, one sec
dr.really
dr.reallyOP•3y ago
BiswaViraj
BiswaViraj•3y ago
and for the customSnpp.handler file as well
dr.really
dr.reallyOP•3y ago
Novu_Bot
Novu_Bot•3y ago
@dr.really, you just advanced to level 4!
Paweł T.
Paweł T.•3y ago
@dr.really have you tried to restart TS server, because the code looks ok to me 🙂
Novu_Bot
Novu_Bot•3y ago
@paweltymczuk, you just advanced to level 8!
dr.really
dr.reallyOP•3y ago
let me try that nope that didn't work 😦
dr.really
dr.reallyOP•3y ago
this is the full stack trace that it's dumping, for some reason it's not liking the sendMessage function lol
Paweł T.
Paweł T.•3y ago
in the logs I see that the @novu/stateless version that you use is 0.4.1 can you switch to the 0.9.0 ?
dr.really
dr.reallyOP•3y ago
woooow i'm dumb lol let me fix that that's the default version that comes from yarn run generate:provider just fyi
Paweł T.
Paweł T.•3y ago
please create a ticket for that 😉
dr.really
dr.reallyOP•3y ago
salute
BiswaViraj
BiswaViraj•3y ago
For anyone interested, change the version of @Novu/stateless inside this file 😉 _templates/provider/new/package.ejs.t
dr.really
dr.reallyOP•3y ago
let me build this out and i can pop in a PR for that if you guys are busy
BiswaViraj
BiswaViraj•3y ago
it will be cool, if you can create the PR for it 😄
dr.really
dr.reallyOP•3y ago
side note: updating that fixed my issues lol
Paweł T.
Paweł T.•3y ago
let's close this one then 😉
dr.really
dr.reallyOP•3y ago
so i just noticed, that when I make this PR my local branch is going to push up the outlook365 provider which i have a open PR that's ready for merging ( i think ) anyway we can get that merged before I make this PR so it doesn't do crazy git things? lol pr in question: https://github.com/novuhq/novu/pull/2052
BiswaViraj
BiswaViraj•3y ago
you can commit your changes for outlook365 in your outlook branch, then switch to the next branch and pull the latest changes and create a new branch to address this issue and then later go back to outlook branch to continue working on it
dr.really
dr.reallyOP•3y ago
sooo that's where I messed up at first, I did that in my local next branch 😬 granted in the future I'm doing things like you stated lol (apologies for being difficult)
dr.really
dr.reallyOP•3y ago
GitHub
chore: Updated stateless package to 0.9.0 by cryptic-ai · Pull Requ...
What change does this PR introduce? Bump the version of @novu/stateless to 0.9.0 Why was this change needed? When using the generate:provider feature, it was placing the wrong stateless version in ...
Novu_Bot
Novu_Bot•3y ago
@dr.really, you just advanced to level 6!
Want results from more Discord servers?
Add your server