fix: express session

This commit is contained in:
Mohamed Marrouchi 2024-10-26 09:02:34 +01:00
parent 1b1a0b4b35
commit c722b85d5d
11 changed files with 29 additions and 10 deletions

View File

@ -5,6 +5,11 @@
"description": "Hexabot is a solution for creating and managing chatbots across multiple channels, leveraging AI for advanced conversational capabilities. It provides a user-friendly interface for building, training, and deploying chatbots with integrated support for various messaging platforms.",
"author": "Hexastack",
"license": "AGPL-3.0-only",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"postinstall": "patch-package",
"build:clean": "rm -rf src/.hexabot",

View File

@ -20,6 +20,7 @@ import {
import { LoggerService } from '@/logger/logger.service';
import { SettingService } from '@/setting/services/setting.service';
import { Extension } from '@/utils/generics/extension';
import { HyphenToUnderscore } from '@/utils/types/extension';
import { SocketRequest } from '@/websocket/utils/socket-request';
import { SocketResponse } from '@/websocket/utils/socket-response';

View File

@ -7,6 +7,7 @@
*/
import { SettingCreateDto } from '@/setting/dto/setting.dto';
import { HyphenToUnderscore } from '@/utils/types/extension';
export type ChannelName = `${string}-channel`;

View File

@ -299,7 +299,7 @@ export default abstract class BaseWebChannelHandler<
*/
private async verifyToken(verificationToken: string) {
const settings =
(await this.getSettings()) as Settings[typeof WEB_CHANNEL_NAMESPACE];
(await this.getSettings()) as unknown as Settings[typeof WEB_CHANNEL_NAMESPACE];
const verifyToken = settings.verification_token;
if (!verifyToken) {

13
api/src/global.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
declare global {
type HyphenToUnderscore<S extends string> = S extends `${infer P}-${infer Q}`
? `${P}_${HyphenToUnderscore<Q>}`
: S;
}

View File

@ -12,6 +12,7 @@ import { LoggerService, OnModuleInit } from '@nestjs/common';
import { SettingService } from '@/setting/services/setting.service';
import { Extension } from '@/utils/generics/extension';
import { HyphenToUnderscore } from '@/utils/types/extension';
import { HelperService } from '../helper.service';
import { HelperName, HelperSetting, HelperType } from '../types';

View File

@ -7,6 +7,7 @@
*/
import { SettingCreateDto } from '@/setting/dto/setting.dto';
import { HyphenToUnderscore } from '@/utils/types/extension';
import BaseHelper from './lib/base-helper';
import BaseLlmHelper from './lib/base-llm-helper';

View File

@ -13,7 +13,7 @@ import { OnModuleInit } from '@nestjs/common';
import { I18nJsonLoader, I18nTranslation } from 'nestjs-i18n';
import { Observable } from 'rxjs';
import { ExtensionName } from '../types/extension';
import { ExtensionName, HyphenToUnderscore } from '../types/extension';
export abstract class Extension implements OnModuleInit {
private translations: I18nTranslation | Observable<I18nTranslation>;

View File

@ -11,3 +11,6 @@ import { HelperName } from '@/helper/types';
import { PluginName } from '@/plugins/types';
export type ExtensionName = ChannelName | HelperName | PluginName;
export type HyphenToUnderscore<S extends string> =
S extends `${infer P}-${infer Q}` ? `${P}_${HyphenToUnderscore<Q>}` : S;

View File

@ -26,6 +26,7 @@
},
"include": [
"src/**/*.ts",
"src/global.d.ts",
"types/**/*.d.ts",
"src/**/*.json",
"test/**/*.ts",

View File

@ -6,7 +6,6 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import 'mongoose';
import { SubscriberStub } from './chat/schemas/subscriber.schema';
declare module 'express-session' {
@ -41,9 +40,3 @@ declare module 'express-session' {
};
}
}
declare global {
type HyphenToUnderscore<S extends string> = S extends `${infer P}-${infer Q}`
? `${P}_${HyphenToUnderscore<Q>}`
: S;
}