feat: refactor extensions as npm packages (be brave 1)

This commit is contained in:
Mohamed Marrouchi
2024-10-22 11:01:44 +01:00
parent 4cf5c57053
commit 35cf78c523
87 changed files with 394 additions and 331 deletions

View File

@@ -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,

View File

@@ -0,0 +1 @@
export default [];

View File

@@ -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,

View File

@@ -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,

View File

@@ -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: [] },

View File

@@ -25,7 +25,7 @@ export const subscriberInstance: Subscriber = {
lastvisit: new Date(),
retainedFrom: new Date(),
channel: {
name: 'offline',
name: 'offline-channel',
},
labels: [],
...modelInstance,