mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
feat: refactor extensions as npm packages (be brave 1)
This commit is contained in:
@@ -15,23 +15,27 @@ import {
|
||||
import { LoggerService } from '@/logger/logger.service';
|
||||
import { BaseBlockPlugin } from '@/plugins/base-block-plugin';
|
||||
import { PluginService } from '@/plugins/plugins.service';
|
||||
import { PluginSetting } from '@/plugins/types';
|
||||
import { PluginBlockTemplate, PluginSetting } from '@/plugins/types';
|
||||
|
||||
@Injectable()
|
||||
export class DummyPlugin extends BaseBlockPlugin<PluginSetting[]> {
|
||||
template: PluginBlockTemplate = { name: 'Dummy Plugin' };
|
||||
|
||||
constructor(
|
||||
pluginService: PluginService,
|
||||
private logger: LoggerService,
|
||||
) {
|
||||
super('dummy', [], pluginService);
|
||||
|
||||
this.template = { name: 'Dummy Plugin' };
|
||||
super('dummy-plugin', pluginService);
|
||||
|
||||
this.effects = {
|
||||
onStoreContextData: () => {},
|
||||
};
|
||||
}
|
||||
|
||||
getPath(): string {
|
||||
return __dirname;
|
||||
}
|
||||
|
||||
async process() {
|
||||
const envelope: StdOutgoingTextEnvelope = {
|
||||
format: OutgoingMessageFormat.text,
|
||||
|
||||
1
api/src/utils/test/dummy/settings.ts
Normal file
1
api/src/utils/test/dummy/settings.ts
Normal file
@@ -0,0 +1 @@
|
||||
export default [];
|
||||
10
api/src/utils/test/fixtures/conversation.ts
vendored
10
api/src/utils/test/fixtures/conversation.ts
vendored
@@ -10,8 +10,8 @@ import mongoose from 'mongoose';
|
||||
|
||||
import { ConversationCreateDto } from '@/chat/dto/conversation.dto';
|
||||
import {
|
||||
ConversationModel,
|
||||
Conversation,
|
||||
ConversationModel,
|
||||
} from '@/chat/schemas/conversation.schema';
|
||||
|
||||
import { getFixturesWithDefaultValues } from '../defaultValues';
|
||||
@@ -25,7 +25,7 @@ const conversations: ConversationCreateDto[] = [
|
||||
sender: '0',
|
||||
active: true,
|
||||
context: {
|
||||
channel: 'messenger',
|
||||
channel: 'messenger-channel',
|
||||
text: 'Hi',
|
||||
payload: '',
|
||||
nlp: {
|
||||
@@ -60,7 +60,7 @@ const conversations: ConversationCreateDto[] = [
|
||||
foreign_id: '',
|
||||
labels: [],
|
||||
assignedTo: null,
|
||||
channel: { name: 'messenger' },
|
||||
channel: { name: 'messenger-channel' },
|
||||
},
|
||||
skip: {},
|
||||
attempt: 0,
|
||||
@@ -71,7 +71,7 @@ const conversations: ConversationCreateDto[] = [
|
||||
{
|
||||
sender: '1',
|
||||
context: {
|
||||
channel: 'offline',
|
||||
channel: 'offline-channel',
|
||||
text: 'Hello',
|
||||
payload: '',
|
||||
nlp: {
|
||||
@@ -106,7 +106,7 @@ const conversations: ConversationCreateDto[] = [
|
||||
foreign_id: '',
|
||||
labels: [],
|
||||
assignedTo: null,
|
||||
channel: { name: 'offline' },
|
||||
channel: { name: 'offline-channel' },
|
||||
},
|
||||
skip: {},
|
||||
attempt: 0,
|
||||
|
||||
8
api/src/utils/test/fixtures/subscriber.ts
vendored
8
api/src/utils/test/fixtures/subscriber.ts
vendored
@@ -27,7 +27,7 @@ const subscribers: SubscriberCreateDto[] = [
|
||||
gender: 'male',
|
||||
country: 'FR',
|
||||
channel: {
|
||||
name: 'messenger',
|
||||
name: 'messenger-channel',
|
||||
},
|
||||
labels: [],
|
||||
assignedAt: null,
|
||||
@@ -43,7 +43,7 @@ const subscribers: SubscriberCreateDto[] = [
|
||||
gender: 'male',
|
||||
country: 'US',
|
||||
channel: {
|
||||
name: 'offline',
|
||||
name: 'offline-channel',
|
||||
},
|
||||
labels: [],
|
||||
assignedAt: null,
|
||||
@@ -59,7 +59,7 @@ const subscribers: SubscriberCreateDto[] = [
|
||||
gender: 'male',
|
||||
country: 'US',
|
||||
channel: {
|
||||
name: 'offline',
|
||||
name: 'offline-channel',
|
||||
},
|
||||
labels: [],
|
||||
assignedAt: null,
|
||||
@@ -75,7 +75,7 @@ const subscribers: SubscriberCreateDto[] = [
|
||||
gender: 'male',
|
||||
country: 'US',
|
||||
channel: {
|
||||
name: 'offline',
|
||||
name: 'offline-channel',
|
||||
},
|
||||
labels: [],
|
||||
assignedAt: null,
|
||||
|
||||
@@ -16,7 +16,7 @@ import { modelInstance } from './misc';
|
||||
import { subscriberInstance } from './subscriber';
|
||||
|
||||
export const contextBlankInstance: Context = {
|
||||
channel: 'offline',
|
||||
channel: 'offline-channel',
|
||||
text: '',
|
||||
payload: undefined,
|
||||
nlp: { entities: [] },
|
||||
@@ -42,7 +42,7 @@ export const contextEmailVarInstance: Context = {
|
||||
};
|
||||
|
||||
export const contextGetStartedInstance: Context = {
|
||||
channel: 'offline',
|
||||
channel: 'offline-channel',
|
||||
text: 'Get Started',
|
||||
payload: 'GET_STARTED',
|
||||
nlp: { entities: [] },
|
||||
|
||||
@@ -25,7 +25,7 @@ export const subscriberInstance: Subscriber = {
|
||||
lastvisit: new Date(),
|
||||
retainedFrom: new Date(),
|
||||
channel: {
|
||||
name: 'offline',
|
||||
name: 'offline-channel',
|
||||
},
|
||||
labels: [],
|
||||
...modelInstance,
|
||||
|
||||
Reference in New Issue
Block a user