mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge branch 'main' into 1018-bug---content-type-fields-edit-form-fields-name-do-not-reflect-db-names
This commit is contained in:
4
api/package-lock.json
generated
4
api/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "hexabot",
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.9",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "hexabot",
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.9",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hexabot",
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.9",
|
||||
"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",
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
/*
|
||||
* Copyright © 2024 Hexastack. All rights reserved.
|
||||
* Copyright © 2025 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).
|
||||
*/
|
||||
|
||||
import { SettingCreateDto } from '@/setting/dto/setting.dto';
|
||||
import { ExtensionSetting } from '@/setting/schemas/types';
|
||||
import { HyphenToUnderscore } from '@/utils/types/extension';
|
||||
|
||||
export type ChannelName = `${string}-channel`;
|
||||
|
||||
export type ChannelSetting<N extends string = string> = Omit<
|
||||
SettingCreateDto,
|
||||
'group' | 'weight'
|
||||
> & {
|
||||
export type ChannelSetting<N extends string = string> = ExtensionSetting<{
|
||||
group: HyphenToUnderscore<N>;
|
||||
};
|
||||
}>;
|
||||
|
||||
@@ -139,7 +139,7 @@ export class SubscriberRepository extends BaseRepository<
|
||||
* @returns The found subscriber entity with populated fields.
|
||||
*/
|
||||
async findOneByForeignIdAndPopulate(id: string): Promise<SubscriberFull> {
|
||||
const query = this.findByForeignIdQuery(id).populate(this.populate);
|
||||
const query = this.findByForeignIdQuery(id).populate(this.populatePaths);
|
||||
const [result] = await this.execute(query, SubscriberFull);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* 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 { SettingCreateDto } from '@/setting/dto/setting.dto';
|
||||
import { ExtensionSetting } from '@/setting/schemas/types';
|
||||
import { HyphenToUnderscore } from '@/utils/types/extension';
|
||||
|
||||
import BaseHelper from './lib/base-helper';
|
||||
@@ -116,9 +116,7 @@ export type HelperRegistry<H extends BaseHelper = BaseHelper> = Map<
|
||||
Map<string, H>
|
||||
>;
|
||||
|
||||
export type HelperSetting<N extends HelperName = HelperName> = Omit<
|
||||
SettingCreateDto,
|
||||
'group' | 'weight'
|
||||
> & {
|
||||
group: HyphenToUnderscore<N>;
|
||||
};
|
||||
export type HelperSetting<N extends HelperName = HelperName> =
|
||||
ExtensionSetting<{
|
||||
group: HyphenToUnderscore<N>;
|
||||
}>;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ChannelEvent } from '@/channel/lib/EventWrapper';
|
||||
import { BlockCreateDto } from '@/chat/dto/block.dto';
|
||||
import { Block } from '@/chat/schemas/block.schema';
|
||||
import { Conversation } from '@/chat/schemas/conversation.schema';
|
||||
import { SettingCreateDto } from '@/setting/dto/setting.dto';
|
||||
import { ExtensionSetting } from '@/setting/schemas/types';
|
||||
|
||||
export type PluginName = `${string}-plugin`;
|
||||
|
||||
@@ -23,7 +23,7 @@ export interface CustomBlocks {}
|
||||
|
||||
type BlockAttrs = Partial<BlockCreateDto> & { name: string };
|
||||
|
||||
export type PluginSetting = Omit<SettingCreateDto, 'weight'>;
|
||||
export type PluginSetting = ExtensionSetting;
|
||||
|
||||
export type PluginBlockTemplate = Omit<
|
||||
BlockAttrs,
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* 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 { BaseSchema } from '@/utils/generics/base-schema';
|
||||
|
||||
import { Setting } from './setting.schema';
|
||||
|
||||
export enum SettingType {
|
||||
@@ -128,3 +130,17 @@ export type AnySetting =
|
||||
| MultipleAttachmentSetting;
|
||||
|
||||
export type SettingDict = { [group: string]: Setting[] };
|
||||
|
||||
export type ExtensionSetting<
|
||||
E extends object = object,
|
||||
U extends AnySetting = AnySetting,
|
||||
K extends keyof BaseSchema = keyof BaseSchema,
|
||||
> = U extends any
|
||||
? {
|
||||
[P in keyof U as P extends K
|
||||
? never
|
||||
: U[P] extends never
|
||||
? never
|
||||
: P]: U[P];
|
||||
} & E
|
||||
: never;
|
||||
|
||||
@@ -94,14 +94,14 @@ export abstract class BaseRepository<
|
||||
constructor(
|
||||
readonly model: Model<T>,
|
||||
private readonly cls: new () => T,
|
||||
protected readonly populate: P[] = [],
|
||||
protected readonly populatePaths: P[] = [],
|
||||
protected readonly clsPopulate?: new () => TFull,
|
||||
) {
|
||||
this.registerLifeCycleHooks();
|
||||
}
|
||||
|
||||
canPopulate(populate: string[]): boolean {
|
||||
return populate.some((p) => this.populate.includes(p as P));
|
||||
return populate.some((p) => this.populatePaths.includes(p as P));
|
||||
}
|
||||
|
||||
getEventName(suffix: EHook) {
|
||||
@@ -303,7 +303,7 @@ export abstract class BaseRepository<
|
||||
): Promise<TFull | null> {
|
||||
this.ensureCanPopulate();
|
||||
const query = this.findOneQuery(criteria, projection).populate(
|
||||
this.populate,
|
||||
this.populatePaths,
|
||||
);
|
||||
return await this.executeOne(query, this.clsPopulate!);
|
||||
}
|
||||
@@ -375,7 +375,7 @@ export abstract class BaseRepository<
|
||||
}
|
||||
|
||||
private ensureCanPopulate(): void {
|
||||
if (!this.populate || !this.clsPopulate) {
|
||||
if (!this.populatePaths || !this.clsPopulate) {
|
||||
throw new Error('Cannot populate query');
|
||||
}
|
||||
}
|
||||
@@ -403,13 +403,13 @@ export abstract class BaseRepository<
|
||||
this.ensureCanPopulate();
|
||||
if (Array.isArray(pageQuery)) {
|
||||
const query = this.findQuery(filters, pageQuery, projection).populate(
|
||||
this.populate,
|
||||
this.populatePaths,
|
||||
);
|
||||
return await this.execute(query, this.clsPopulate!);
|
||||
}
|
||||
|
||||
const query = this.findQuery(filters, pageQuery, projection).populate(
|
||||
this.populate,
|
||||
this.populatePaths,
|
||||
);
|
||||
return await this.execute(query, this.clsPopulate!);
|
||||
}
|
||||
@@ -426,7 +426,7 @@ export abstract class BaseRepository<
|
||||
|
||||
async findAllAndPopulate(sort?: QuerySortDto<T>): Promise<TFull[]> {
|
||||
this.ensureCanPopulate();
|
||||
const query = this.findAllQuery(sort).populate(this.populate);
|
||||
const query = this.findAllQuery(sort).populate(this.populatePaths);
|
||||
return await this.execute(query, this.clsPopulate!);
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ export abstract class BaseRepository<
|
||||
): Promise<TFull[]> {
|
||||
this.ensureCanPopulate();
|
||||
const query = this.findPageQuery(filters, pageQuery).populate(
|
||||
this.populate,
|
||||
this.populatePaths,
|
||||
);
|
||||
return await this.execute(query, this.clsPopulate!);
|
||||
}
|
||||
|
||||
59
api/src/utils/pipes/zod.pipe.ts
Normal file
59
api/src/utils/pipes/zod.pipe.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright © 2025 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).
|
||||
*/
|
||||
|
||||
import {
|
||||
ArgumentMetadata,
|
||||
BadRequestException,
|
||||
Injectable,
|
||||
PipeTransform,
|
||||
} from '@nestjs/common';
|
||||
import { ZodError, ZodTypeAny } from 'zod';
|
||||
|
||||
/**
|
||||
* Validates a single query-parameter with a given Zod schema.
|
||||
*
|
||||
* @example
|
||||
* // Controller usage
|
||||
* @Get()
|
||||
* listUsers(
|
||||
* @Query(new ZodQueryParamPipe(z.coerce.number().int().min(1))) query: any,
|
||||
* ) {
|
||||
* // query.page is guaranteed to be a positive integer number
|
||||
* }
|
||||
*/
|
||||
@Injectable()
|
||||
export class ZodQueryParamPipe implements PipeTransform {
|
||||
constructor(
|
||||
private readonly schema: ZodTypeAny,
|
||||
private readonly accessor?: (query: any) => any,
|
||||
) {}
|
||||
|
||||
async transform(query: any, metadata: ArgumentMetadata) {
|
||||
const payload = this.accessor ? this.accessor(query) : query;
|
||||
// We care only about query params
|
||||
if (typeof payload === 'undefined' || metadata.type !== 'query') {
|
||||
return payload;
|
||||
}
|
||||
|
||||
const parsed = this.schema.safeParse(payload);
|
||||
|
||||
if (!parsed.success) {
|
||||
// Optionally format the error for client readability
|
||||
const error = parsed.error as ZodError;
|
||||
throw new BadRequestException({
|
||||
statusCode: 400,
|
||||
error: 'Bad Request',
|
||||
message: `Validation failed for query param`,
|
||||
details: error.flatten(),
|
||||
});
|
||||
}
|
||||
|
||||
// Return a new query object with the parsed value injected
|
||||
return parsed.data;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "hexabot-ui",
|
||||
"private": true,
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.9",
|
||||
"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",
|
||||
|
||||
@@ -87,7 +87,7 @@ const componentMap: { [key in FileType]: FC<AttachmentInterface> } = {
|
||||
<Box>
|
||||
<Typography
|
||||
component="span"
|
||||
className="cs-message__text-content"
|
||||
className="cs-message__custom-content"
|
||||
mr={2}
|
||||
>
|
||||
{props.name}
|
||||
|
||||
@@ -73,8 +73,9 @@ export const useInfiniteLiveSubscribers = (props: {
|
||||
if (event.op === "newSubscriber") {
|
||||
const { result } = normalizeAndCache(event.profile);
|
||||
|
||||
// Only update the unfiltered (all-subscribers) cache
|
||||
queryClient.setQueryData(
|
||||
[QueryType.infinite, EntityType.SUBSCRIBER, params],
|
||||
[QueryType.infinite, EntityType.SUBSCRIBER, { where: {} }],
|
||||
(oldData) => {
|
||||
if (oldData) {
|
||||
const data = oldData as InfiniteData<string[]>;
|
||||
|
||||
@@ -20,7 +20,7 @@ div .cs-message--outgoing .cs-message__content {
|
||||
background-color: var(--cs-message-outgoing-color) !important;
|
||||
}
|
||||
|
||||
div .cs-message--outgoing .cs-message__text-content {
|
||||
div .cs-message--outgoing .cs-message__custom-content {
|
||||
color: var(--cs-message-outgoing-text-color) !important;
|
||||
}
|
||||
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -45,7 +45,7 @@
|
||||
},
|
||||
"frontend": {
|
||||
"name": "hexabot-ui",
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.9",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@chatscope/chat-ui-kit-react": "^2.0.3",
|
||||
@@ -10308,7 +10308,7 @@
|
||||
},
|
||||
"widget": {
|
||||
"name": "hexabot-chat-widget",
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.9",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"autolinker": "^4.1.5",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"frontend",
|
||||
"widget"
|
||||
],
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.9",
|
||||
"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",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hexabot-chat-widget",
|
||||
"version": "2.2.8",
|
||||
"version": "2.2.9",
|
||||
"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",
|
||||
|
||||
@@ -24,11 +24,10 @@ const TextMessage: React.FC<TextMessageProps> = ({ message }) => {
|
||||
|
||||
useEffect(() => {
|
||||
autoLink();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [message]);
|
||||
|
||||
const autoLink = () => {
|
||||
if (message.direction === Direction.received && messageTextRef.current) {
|
||||
if (messageTextRef.current) {
|
||||
const text = messageTextRef.current.innerText;
|
||||
|
||||
messageTextRef.current.innerHTML = Autolinker.link(text, {
|
||||
|
||||
Reference in New Issue
Block a user