Skip to content

Commit

Permalink
fix: Plugin schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Oct 8, 2020
1 parent d4450cd commit 1fedaa5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
24 changes: 23 additions & 1 deletion packages/daf-graphql/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
import 'cross-fetch/polyfill'
import { IAgentPlugin, IPluginMethodMap } from 'daf-core'
import { IAgentPlugin, IPluginMethodMap, IAgentPluginSchema } from 'daf-core'
import { GraphQLClient } from 'graphql-request'
import { IAgentGraphQLMethod } from './types'
import { supportedMethods } from './methods'
import IMessageHandler from 'daf-core/build/schemas/IMessageHandler'
import IDataStore from 'daf-core/build/schemas/IDataStore'
import IKeyManager from 'daf-core/build/schemas/IKeyManager'
import IResolver from 'daf-core/build/schemas/IResolver'

const schema: IAgentPluginSchema = {
components: {
schemas: {
...IMessageHandler.components.schemas,
...IDataStore.components.schemas,
...IKeyManager.components.schemas,
...IResolver.components.schemas,
},
methods: {
...IMessageHandler.components.methods,
...IDataStore.components.methods,
...IKeyManager.components.methods,
...IResolver.components.methods,
},
}
}

export class AgentGraphQLClient implements IAgentPlugin {
private client: GraphQLClient
readonly methods: IPluginMethodMap = {}
readonly schema = schema

constructor(options: {
url: string
Expand Down
2 changes: 2 additions & 0 deletions packages/daf-message-handler/src/message-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { EventEmitter } from 'events'
import { IDataStore, IAgentPlugin, IAgentContext, IMessageHandler, IHandleMessageArgs } from 'daf-core'
import { Message } from './message'
import { AbstractMessageHandler } from './abstract-message-handler'
import schema from 'daf-core/build/schemas/IMessageHandler'

import Debug from 'debug'
const debug = Debug('daf:message-handler')
Expand All @@ -21,6 +22,7 @@ export class MessageHandler extends EventEmitter implements IAgentPlugin {
* @public
*/
readonly methods: IMessageHandler
readonly schema = schema
private messageHandler?: AbstractMessageHandler

constructor(options: { messageHandlers: AbstractMessageHandler[] }) {
Expand Down
25 changes: 24 additions & 1 deletion packages/daf-rest/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
import 'cross-fetch/polyfill'
import { IAgentPlugin, IPluginMethodMap } from 'daf-core'
import { IAgentPlugin, IPluginMethodMap, IAgentPluginSchema } from 'daf-core'
import { supportedMethods } from './index'
import IMessageHandler from 'daf-core/build/schemas/IMessageHandler'
import IDataStore from 'daf-core/build/schemas/IDataStore'
import IKeyManager from 'daf-core/build/schemas/IKeyManager'
import IResolver from 'daf-core/build/schemas/IResolver'

const schema: IAgentPluginSchema = {
components: {
schemas: {
...IMessageHandler.components.schemas,
...IDataStore.components.schemas,
...IKeyManager.components.schemas,
...IResolver.components.schemas,
},
methods: {
...IMessageHandler.components.methods,
...IDataStore.components.methods,
...IKeyManager.components.methods,
...IResolver.components.methods,
},
}
}


export class AgentRestClient implements IAgentPlugin {
readonly methods: IPluginMethodMap = {}
readonly schema = schema
private url: string

constructor(options: {
Expand Down

0 comments on commit 1fedaa5

Please sign in to comment.