Skip to content

Commit

Permalink
fix: IHandleMessage interface
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat authored and mirceanis committed Sep 7, 2020
1 parent b6d1e36 commit 0ab68fd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 34 deletions.
2 changes: 1 addition & 1 deletion packages/daf-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export {
IKeyManagerSignEthTXArgs,
IKeyManagerSignJWTArgs,
} from './key-manager'
export { MessageHandler, IHandleMessage } from './message-handler'
export { MessageHandler, IHandleMessage, IHandleMessageArgs } from './message-handler'
export { Message } from './message'
export { AbstractIdentityProvider } from './abstract/abstract-identity-provider'
export { AbstractKeyManagementSystem } from './abstract/abstract-key-management-system'
Expand Down
24 changes: 8 additions & 16 deletions packages/daf-core/src/message-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ export const EventTypes = {
error: 'error',
}

export interface IHandleMessageArgs {
raw: string
metaData?: IMetaData[]
save?: boolean
}

export interface IHandleMessage extends IPluginMethodMap {
handleMessage: (
args: {
raw: string
metaData?: IMetaData[]
save?: boolean
},
context: IAgentContext<IDataStore>,
) => Promise<Message>
handleMessage(args: IHandleMessageArgs, context: IAgentContext<IDataStore>): Promise<Message>
}

export class MessageHandler extends EventEmitter implements IAgentPlugin {
Expand Down Expand Up @@ -48,14 +47,7 @@ export class MessageHandler extends EventEmitter implements IAgentPlugin {
}
}

public async handleMessage(
args: {
raw: string
metaData?: IMetaData[]
save?: boolean
},
context: IAgentContext<IDataStore>,
): Promise<Message> {
public async handleMessage(args: IHandleMessageArgs, context: IAgentContext<IDataStore>): Promise<Message> {
const { raw, metaData, save } = args
debug('%o', { raw, metaData, save })
if (!this.messageHandler) {
Expand Down
28 changes: 12 additions & 16 deletions report/daf-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,17 @@ export class IdentityManager implements IAgentPlugin {
// @public (undocumented)
export interface IHandleMessage extends IPluginMethodMap {
// (undocumented)
handleMessage: (
args: {
raw: string
metaData?: IMetaData[]
save?: boolean
},
context: IAgentContext<IDataStore>,
) => Promise<Message>
handleMessage(args: IHandleMessageArgs, context: IAgentContext<IDataStore>): Promise<Message>
}

// @public (undocumented)
export interface IHandleMessageArgs {
// (undocumented)
metaData?: IMetaData[]
// (undocumented)
raw: string
// (undocumented)
save?: boolean
}

// @public (undocumented)
Expand Down Expand Up @@ -617,14 +620,7 @@ export class Message implements IMessage {
export class MessageHandler extends EventEmitter implements IAgentPlugin {
constructor(options: { messageHandlers: AbstractMessageHandler[] })
// (undocumented)
handleMessage(
args: {
raw: string
metaData?: IMetaData[]
save?: boolean
},
context: IAgentContext<IDataStore>,
): Promise<Message>
handleMessage(args: IHandleMessageArgs, context: IAgentContext<IDataStore>): Promise<Message>
// (undocumented)
readonly methods: IHandleMessage
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
const apiExtractorConfig = require('../api-extractor-base.json')

const agentPlugins: Record<string, Array<string>> = {
'daf-core': ['IResolveDid', 'IDataStore', 'IKeyManager', 'IIdentityManager'],
'daf-core': ['IResolveDid', 'IDataStore', 'IKeyManager', 'IIdentityManager', 'IHandleMessage'],
'daf-w3c': ['IW3c'],
}

Expand Down

0 comments on commit 0ab68fd

Please sign in to comment.