@hexabot-ai/api 3.2.2-alpha.6 → 3.2.2-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/channel/channel.service.js +3 -1
  2. package/dist/channel/channel.service.js.map +1 -1
  3. package/dist/channel/services/source.service.d.ts +2 -0
  4. package/dist/channel/services/source.service.js +22 -0
  5. package/dist/channel/services/source.service.js.map +1 -1
  6. package/dist/static/assets/{browser-ponyfill-BBXpV9Qm.js → browser-ponyfill-IkrOfrbH.js} +1 -1
  7. package/dist/static/assets/{cssMode-BfCVo5Gt.js → cssMode-BVh8Ojbf.js} +1 -1
  8. package/dist/static/assets/{freemarker2-C0N9KzZg.js → freemarker2-Cnk90W15.js} +1 -1
  9. package/dist/static/assets/{handlebars-Cix11MUq.js → handlebars-DDmCOyIG.js} +1 -1
  10. package/dist/static/assets/{html-Br5qjjAj.js → html-cDkAkcNZ.js} +1 -1
  11. package/dist/static/assets/{htmlMode-CA4ova7h.js → htmlMode-BKekdtGx.js} +1 -1
  12. package/dist/static/assets/{index-DLmsP5dI.js → index-CnXiX03v.js} +2028 -2028
  13. package/dist/static/assets/{javascript-DhXPxzbX.js → javascript-bO_Y-MtP.js} +1 -1
  14. package/dist/static/assets/{jsonMode-E0RPZxCT.js → jsonMode-p7oe1x6a.js} +1 -1
  15. package/dist/static/assets/{liquid-74Ul_KYb.js → liquid-DehK5Toi.js} +1 -1
  16. package/dist/static/assets/{lspLanguageFeatures-u4gW94kD.js → lspLanguageFeatures-C8ni2Y8s.js} +1 -1
  17. package/dist/static/assets/{mdx-D5Yq9R6B.js → mdx-BqE3GcoU.js} +1 -1
  18. package/dist/static/assets/{python-8ddAbGQY.js → python-DYGyqTrT.js} +1 -1
  19. package/dist/static/assets/{razor-y8F9KIDv.js → razor-CTOqYwI_.js} +1 -1
  20. package/dist/static/assets/{tsMode-C0dB5X8n.js → tsMode-n7ps72jb.js} +1 -1
  21. package/dist/static/assets/{typescript-SsRP__qV.js → typescript-B0sRB56_.js} +1 -1
  22. package/dist/static/assets/{xml-B-JbzDjN.js → xml-C4I4RxHC.js} +1 -1
  23. package/dist/static/assets/{yaml-jvIHWrQq.js → yaml-V_o23lNz.js} +1 -1
  24. package/dist/static/index.html +1 -1
  25. package/dist/static/locales/en/translation.json +2 -0
  26. package/dist/static/locales/fr/translation.json +2 -0
  27. package/dist/tsconfig.build.tsbuildinfo +1 -1
  28. package/package.json +4 -4
  29. package/src/channel/channel.service.ts +5 -2
  30. package/src/channel/services/source.service.ts +38 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hexabot-ai/api",
3
3
  "private": false,
4
- "version": "3.2.2-alpha.6",
4
+ "version": "3.2.2-alpha.8",
5
5
  "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.",
6
6
  "author": "Hexastack",
7
7
  "license": "FCL-1.0-ALv2",
@@ -90,8 +90,8 @@
90
90
  "typeorm": "^0.3.28",
91
91
  "yaml": "^2.8.3",
92
92
  "zod": "^4.3.6",
93
- "@hexabot-ai/agentic": "3.1.2-alpha.6",
94
- "@hexabot-ai/types": "3.0.2-alpha.6"
93
+ "@hexabot-ai/types": "3.0.2-alpha.8",
94
+ "@hexabot-ai/agentic": "3.1.2-alpha.8"
95
95
  },
96
96
  "devDependencies": {
97
97
  "@compodoc/compodoc": "^1.1.31",
@@ -142,7 +142,7 @@
142
142
  "tsconfig-paths": "^4.2.0",
143
143
  "tsconfig-paths-jest": "^0.0.1",
144
144
  "typescript": "^5.1.3",
145
- "@hexabot-ai/frontend": "3.2.2-alpha.6"
145
+ "@hexabot-ai/frontend": "3.2.2-alpha.8"
146
146
  },
147
147
  "optionalDependencies": {
148
148
  "@css-inline/css-inline-linux-arm64-musl": "^0.14.1",
@@ -42,9 +42,12 @@ export class ChannelService implements OnApplicationBootstrap {
42
42
  ) {}
43
43
 
44
44
  async onApplicationBootstrap(): Promise<void> {
45
- await this.sourceService.ensureDefaultSources(
46
- this.getAll().map((handler) => handler.getName()),
45
+ const registeredChannelNames = this.getAll().map((handler) =>
46
+ handler.getName(),
47
47
  );
48
+
49
+ await this.sourceService.ensureDefaultSources(registeredChannelNames);
50
+ await this.sourceService.disableUnregisteredSources(registeredChannelNames);
48
51
  }
49
52
 
50
53
  public setChannel<T extends ChannelName, C extends ChannelHandler<T>>(
@@ -11,7 +11,7 @@ import {
11
11
  MethodNotAllowedException,
12
12
  NotFoundException,
13
13
  } from '@nestjs/common';
14
- import { FindManyOptions, FindOneOptions } from 'typeorm';
14
+ import { FindManyOptions, FindOneOptions, In, Not } from 'typeorm';
15
15
  import { DeleteResult } from 'typeorm/driver/mongodb/typings';
16
16
  import z from 'zod';
17
17
 
@@ -107,6 +107,12 @@ export class SourceService extends BaseOrmService<SourceOrmEntity> {
107
107
  return defaultWorkflow;
108
108
  }
109
109
 
110
+ private isStateOnlyDisablePayload(payload: SourceUpdateDto): boolean {
111
+ const keys = Object.keys(payload);
112
+
113
+ return keys.length === 1 && keys[0] === 'state' && payload.state === false;
114
+ }
115
+
110
116
  private async buildCreatePayload(
111
117
  payload: SourceCreateDto,
112
118
  ): Promise<SourceCreateDto> {
@@ -141,6 +147,16 @@ export class SourceService extends BaseOrmService<SourceOrmEntity> {
141
147
  throw new NotFoundException('Source not found');
142
148
  }
143
149
 
150
+ if (!this.channelRegistry.findChannel(existing.channel)) {
151
+ if (this.isStateOnlyDisablePayload(payload)) {
152
+ return await super.updateOne(idOrOptions, { state: false }, options);
153
+ }
154
+
155
+ throw new BadRequestException(
156
+ `Channel "${existing.channel}" is not registered`,
157
+ );
158
+ }
159
+
144
160
  const channel = payload.channel ?? existing.channel;
145
161
  const shouldResetSettings =
146
162
  payload.channel !== undefined && payload.settings === undefined;
@@ -167,6 +183,27 @@ export class SourceService extends BaseOrmService<SourceOrmEntity> {
167
183
  );
168
184
  }
169
185
 
186
+ async disableUnregisteredSources(
187
+ registeredChannelNames: string[],
188
+ ): Promise<Source[]> {
189
+ const uniqueRegisteredChannelNames = Array.from(
190
+ new Set(registeredChannelNames),
191
+ );
192
+
193
+ return await super.updateMany(
194
+ {
195
+ where:
196
+ uniqueRegisteredChannelNames.length > 0
197
+ ? {
198
+ state: true,
199
+ channel: Not(In(uniqueRegisteredChannelNames)),
200
+ }
201
+ : { state: true },
202
+ },
203
+ { state: false },
204
+ );
205
+ }
206
+
170
207
  async findActiveByRef(sourceRef: string): Promise<Source> {
171
208
  const normalizedSourceRef = sourceRef.trim();
172
209
  const source = await this.findOne(normalizedSourceRef);