Skip to content

Commit

Permalink
refactor(echo): rename chimera to echo
Browse files Browse the repository at this point in the history
  • Loading branch information
djabarovgeorge committed Apr 16, 2024
1 parent 9fcefe0 commit 518e9f6
Show file tree
Hide file tree
Showing 34 changed files with 130 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .source
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"typescript": "4.9.5"
},
"optionalDependencies": {
"@novu/ee-chimera": "^0.24.1",
"@novu/ee-echo-api": "^0.24.1",
"@novu/ee-auth": "^0.24.1",
"@novu/ee-billing": "^0.24.1",
"@novu/ee-translation": "^0.24.1"
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const enterpriseImports = (): Array<Type | DynamicModule | Promise<DynamicModule
if (require('@novu/ee-auth')?.EEAuthModule) {
modules.push(require('@novu/ee-auth')?.EEAuthModule);
}
if (require('@novu/ee-chimera')?.ChimeraModule) {
modules.push(require('@novu/ee-chimera')?.ChimeraModule);
if (require('@novu/ee-echo-api')?.EchoModule) {
modules.push(require('@novu/ee-echo-api')?.EchoModule);
}
if (require('@novu/ee-translation')?.EnterpriseTranslationModule) {
modules.push(require('@novu/ee-translation')?.EnterpriseTranslationModule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ export class SendTestEmail {

if (command.chimera) {
if (process.env.NOVU_ENTERPRISE === 'true' || process.env.CI_EE_TEST === 'true') {
if (!require('@novu/ee-chimera')?.PreviewStep) {
if (!require('@novu/ee-echo-api')?.PreviewStep) {
throw new ApiException('Chimera module is not loaded');
}
const service = this.moduleRef.get(require('@novu/ee-chimera')?.PreviewStep, { strict: false });
const service = this.moduleRef.get(require('@novu/ee-echo-api')?.PreviewStep, { strict: false });
const data = await service.execute({
workflowId: command.workflowId,
stepId: command.stepId,
Expand Down
2 changes: 1 addition & 1 deletion apps/worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"typescript": "4.9.5"
},
"optionalDependencies": {
"@novu/ee-chimera-connect": "^0.24.1",
"@novu/ee-echo-worker": "^0.24.1",
"@novu/ee-auth": "^0.24.1",
"@novu/ee-billing": "^0.24.1",
"@novu/ee-translation": "^0.24.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { PlatformException } from '../../../shared/utils';

@Injectable()
export class SendMessage {
private chimeraConnector: IUseCaseInterfaceInline;
private resonateUsecase: IUseCaseInterfaceInline;

constructor(
private sendMessageEmail: SendMessageEmail,
Expand All @@ -74,7 +74,7 @@ export class SendMessage {
private analyticsService: AnalyticsService,
protected moduleRef: ModuleRef
) {
this.chimeraConnector = requireInject('chimera_connector', this.moduleRef);
this.resonateUsecase = requireInject('resonate', this.moduleRef);
}

@InstrumentUsecase()
Expand All @@ -88,7 +88,7 @@ export class SendMessage {

const stepType = command.step?.template?.type;

const chimeraResponse = await this.chimeraConnector.execute<
const resonateResponse = await this.resonateUsecase.execute<
SendMessageCommand & { variables: IFilterVariables },
ExecuteOutput<IChimeraChannelResponse> | null
>({
Expand Down Expand Up @@ -121,7 +121,7 @@ export class SendMessage {
* This is intentional, so that mixpanel can automatically reshard it.
*/
this.analyticsService.mixpanelTrack('Process Workflow Step - [Triggers]', '', {
workflowType: chimeraResponse?.outputs ? 'ECHO' : 'REGULAR',
workflowType: resonateResponse?.outputs ? 'ECHO' : 'REGULAR',
_template: command.job._templateId,
_organization: command.organizationId,
_environment: command.environmentId,
Expand Down Expand Up @@ -164,7 +164,7 @@ export class SendMessage {
const sendMessageCommand = SendMessageCommand.create({
...command,
compileContext: payload,
chimeraData: chimeraResponse,
chimeraData: resonateResponse,
});

switch (stepType) {
Expand Down
4 changes: 2 additions & 2 deletions apps/worker/src/app/workflow/workflow.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ const enterpriseImports = (): Array<Type | DynamicModule | Promise<DynamicModule
modules.push(require('@novu/ee-billing')?.BillingModule.forRoot(activeWorkers));
}

if (require('@novu/ee-chimera-connect')?.ChimeraConnectorModule) {
if (require('@novu/ee-echo-worker')?.EchoGatewayModule) {
Logger.log('Importing enterprise chimera connector module', 'EnterpriseImport');

modules.push(require('@novu/ee-chimera-connect')?.ChimeraConnectorModule);
modules.push(require('@novu/ee-echo-worker')?.EchoGatewayModule);
}
}
} catch (e) {
Expand Down
1 change: 0 additions & 1 deletion enterprise/packages/chimera-connect/src

This file was deleted.

1 change: 0 additions & 1 deletion enterprise/packages/chimera/src

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@novu/ee-chimera",
"name": "@novu/ee-echo-api",
"version": "0.24.1",
"private": true,
"main": "dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions enterprise/packages/echo/echo-api/src
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"outDir": "dist",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions enterprise/packages/echo/echo-web/src
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@novu/ee-chimera-connect",
"name": "@novu/ee-echo-worker",
"version": "0.24.1",
"private": true,
"main": "dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions enterprise/packages/echo/echo-worker/src
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"outDir": "dist",
Expand Down
1 change: 0 additions & 1 deletion enterprise/packages/web/echo/src

This file was deleted.

2 changes: 1 addition & 1 deletion packages/application-generic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"slugify": "^1.4.6"
},
"optionalDependencies": {
"@novu/ee-chimera-connect": "^0.24.1",
"@novu/ee-echo-worker": "^0.24.1",
"@novu/ee-shared-services": "^0.24.1",
"@taskforcesh/bullmq-pro": "5.1.14"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const LOG_CONTEXT = 'AddJob';

@Injectable()
export class AddJob {
private chimeraConnector: IUseCaseInterfaceInline;
private resonateUsecase: IUseCaseInterfaceInline;

constructor(
private jobRepository: JobRepository,
Expand All @@ -60,7 +60,7 @@ export class AddJob {
private conditionsFilter: ConditionsFilter,
private moduleRef: ModuleRef
) {
this.chimeraConnector = requireInject('chimera_connector', this.moduleRef);
this.resonateUsecase = requireInject('resonate', this.moduleRef);
}

@InstrumentUsecase()
Expand Down Expand Up @@ -108,7 +108,7 @@ export class AddJob {
let digestAmount: number | undefined;
let digestCreationResult: DigestCreationResultEnum | undefined;
if (job.type === StepTypeEnum.DIGEST) {
const chimeraResponse = await this.chimeraConnector.execute<
const resonateResponse = await this.resonateUsecase.execute<
AddJobCommand,
ExecuteOutput<IChimeraDigestResponse>
>(command);
Expand All @@ -119,7 +119,7 @@ export class AddJob {
stepMetadata: job.digest,
payload: job.payload,
overrides: job.overrides,
chimeraResponse: chimeraResponse?.outputs,
chimeraResponse: resonateResponse?.outputs,
});

Logger.debug(`Digest step amount is: ${digestAmount}`, LOG_CONTEXT);
Expand All @@ -128,7 +128,7 @@ export class AddJob {
MergeOrCreateDigestCommand.create({
job,
filtered,
chimeraData: chimeraResponse?.outputs,
chimeraData: resonateResponse?.outputs,
})
);

Expand Down Expand Up @@ -163,12 +163,12 @@ export class AddJob {
let delayAmount: number | undefined = undefined;

if (job.type === StepTypeEnum.DELAY) {
const chimeraResponse = await this.chimeraConnector.execute<
const resonateResponse = await this.resonateUsecase.execute<
AddJobCommand,
ExecuteOutput<IChimeraDigestResponse>
>(command);

command.chimeraResponse = chimeraResponse;
command.chimeraResponse = resonateResponse;
delayAmount = await this.addDelayJob.execute(command);

Logger.debug(`Delay step Amount is: ${delayAmount}`, LOG_CONTEXT);
Expand Down
23 changes: 10 additions & 13 deletions packages/application-generic/src/utils/require-inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,24 @@ import { ModuleRef } from '@nestjs/core';
import { ChatProviderIdEnum } from '@novu/shared';

export const requireInject = (inject: RequireInject, moduleRef?: ModuleRef) => {
if (inject === RequireInjectEnum.CHIMERA_CONNECT) {
return initiateChimeraConnector(moduleRef);
if (inject === RequireInjectEnum.RESONATE) {
return initiateResonateProvider(moduleRef);
}
};

const initiateChimeraConnector = (moduleRef: ModuleRef) => {
const initiateResonateProvider = (moduleRef: ModuleRef) => {
try {
if (
process.env.NOVU_ENTERPRISE === 'true' ||
process.env.CI_EE_TEST === 'true'
) {
if (!require('@novu/ee-chimera-connect')?.ChimeraConnector) {
throw new PlatformException('ChimeraConnector module is not loaded');
if (!require('@novu/ee-echo-worker')?.Resonate) {
throw new PlatformException('Resonate provider is not loaded');
}

return moduleRef.get(
require('@novu/ee-chimera-connect')?.ChimeraConnector,
{
strict: false,
}
);
return moduleRef.get(require('@novu/ee-echo-worker')?.Resonate, {
strict: false,
});
} else {
return {
execute: () => {
Expand All @@ -36,7 +33,7 @@ const initiateChimeraConnector = (moduleRef: ModuleRef) => {
Logger.error(
e,
`Unexpected error while importing enterprise modules`,
'ChimeraConnector'
'Resonate'
);
throw e;
}
Expand All @@ -45,7 +42,7 @@ const initiateChimeraConnector = (moduleRef: ModuleRef) => {
type RequireInject = `${RequireInjectEnum}`;

enum RequireInjectEnum {
CHIMERA_CONNECT = 'chimera_connector',
RESONATE = 'resonate',
}

export interface IChimeraDigestResponse {
Expand Down
Loading

0 comments on commit 518e9f6

Please sign in to comment.