oak-general-business/lib/types/Message.d.ts

47 lines
2.1 KiB
TypeScript

import { EntityDict } from '../oak-app-domain';
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
import { EmailOptions } from './Email';
type WechatPublicTemplateMsgKeyword = 'keyword1' | 'keyword2' | 'keyword3' | 'keyword4' | 'keyword5' | 'keyword6' | 'keyword7';
export type Channel = 'wechatPublic' | 'jPush' | 'jim' | 'wechatMp' | 'sms' | 'email' | string;
export type Weight = 'high' | 'medium' | 'low';
type CommonMessageConverter<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> = {
wechatMp?: (message: ED['message']['OpSchema'], applications: EntityDict['application']['Schema'][], application: EntityDict['application']['Schema'], context: Cxt) => Promise<{
[K: string]: {
value: string;
};
} | undefined>;
wechatPublic?: (message: ED['message']['OpSchema'], applications: EntityDict['application']['Schema'][], application: EntityDict['application']['Schema'], context: Cxt) => Promise<{
data: {
first?: {
value: string;
color?: string;
};
remark?: {
value: string;
color?: string;
};
} & {
[K in WechatPublicTemplateMsgKeyword]?: {
value: string;
color?: string;
};
};
wechatMpAppId?: string;
} | undefined>;
sms?: (message: ED['message']['OpSchema'], context: Cxt) => Promise<{
signName?: string;
params?: Record<string, string>;
paramsArray?: Array<string>;
} | undefined>;
email?: (message: ED['message']['OpSchema'], context: Cxt) => Promise<EmailOptions | undefined>;
};
type CustomMessageConverter<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> = {
[type: string]: {
[channel: Channel]: (message: ED['message']['OpSchema'], context: Cxt) => Promise<Object | undefined>;
};
};
export interface MessageNotificationConverter<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>> {
[type: string]: CommonMessageConverter<ED, Cxt> & CustomMessageConverter<ED, Cxt>;
}
export {};