@wabot-dev/framework 0.9.6 → 0.9.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.
@@ -37,11 +37,12 @@ import { RepositoryAdapterRegistry } from '../repository/RepositoryAdapterRegist
37
37
  const logger = new Logger('wabot:project-runner');
38
38
  const TEST_FILE_PATTERNS = /\.(test|spec|unit|integration|e2e|multiprocess)\.(ts|js)$/;
39
39
  const DEFAULT_EXCLUDE = ['run.ts', 'cmd.ts'];
40
+ const MODULE_EXT = import.meta.url.endsWith('.ts') ? '.ts' : '.js';
40
41
  const DEFAULT_CHAT_ADAPTERS = [
41
- ['../../addon/chat-bot/openia', 'OpenaiChatAdapter'],
42
- ['../../addon/chat-bot/openrouter', 'OpenRouterChatAdapter'],
43
- ['../../addon/chat-bot/anthropic', 'AnthropicChatAdapter'],
44
- ['../../addon/chat-bot/google', 'GoogleChatAdapter'],
42
+ [`../../addon/chat-bot/openia/OpenaiChatAdapter${MODULE_EXT}`, 'OpenaiChatAdapter'],
43
+ [`../../addon/chat-bot/openrouter/OpenRouterChatAdapter${MODULE_EXT}`, 'OpenRouterChatAdapter'],
44
+ [`../../addon/chat-bot/anthropic/AnthropicChatAdapter${MODULE_EXT}`, 'AnthropicChatAdapter'],
45
+ [`../../addon/chat-bot/google/GoogleChatAdapter${MODULE_EXT}`, 'GoogleChatAdapter'],
45
46
  ];
46
47
  class ProjectRunner {
47
48
  directories;
@@ -176,23 +177,28 @@ class ProjectRunner {
176
177
  }
177
178
  async registerMemoryAdapters(components) {
178
179
  const needsJobs = components.commandHandlers.length > 0 || components.cronHandlers.length > 0;
179
- const [chatBotMod, lockMod, asyncMod] = await Promise.all([
180
- import('../../addon/chat-bot/in-memory/index.js'),
181
- import('../../addon/lock/index.js'),
182
- needsJobs ? import('../../addon/async/in-memory/index.js') : Promise.resolve(null),
180
+ const [chatBotMod, lockMod, jobMod, cronJobMod] = await Promise.all([
181
+ import('../../addon/chat-bot/in-memory/InMemoryChatRepository.js'),
182
+ import('../../addon/lock/InMemoryLocker.js'),
183
+ needsJobs
184
+ ? import('../../addon/async/in-memory/InMemoryJobRepository.js')
185
+ : Promise.resolve(null),
186
+ components.cronHandlers.length > 0
187
+ ? import('../../addon/async/in-memory/InMemoryCronJobRepository.js')
188
+ : Promise.resolve(null),
183
189
  ]);
184
190
  container.register(ChatRepository, { useToken: chatBotMod.InMemoryChatRepository });
185
191
  container.register(Locker, { useToken: lockMod.InMemoryLocker });
186
192
  const memoryAdapter = new MemoryRepositoryAdapter();
187
193
  container.resolve(RepositoryAdapterRegistry).setDefault(memoryAdapter);
188
194
  container.resolve(RepositoryMetadataStore).validateExtensionsRegistered(memoryAdapter.id);
189
- if (asyncMod) {
190
- container.register(JobRepository, { useToken: asyncMod.InMemoryJobRepository });
191
- if (components.cronHandlers.length > 0) {
192
- container.register(CronJobRepository, {
193
- useToken: asyncMod.InMemoryCronJobRepository,
194
- });
195
- }
195
+ if (jobMod) {
196
+ container.register(JobRepository, { useToken: jobMod.InMemoryJobRepository });
197
+ }
198
+ if (cronJobMod) {
199
+ container.register(CronJobRepository, {
200
+ useToken: cronJobMod.InMemoryCronJobRepository,
201
+ });
196
202
  }
197
203
  logger.info('Configured with in-memory adapters');
198
204
  }
@@ -200,25 +206,32 @@ class ProjectRunner {
200
206
  if (!this.pool) {
201
207
  throw new Error('Postgres pool was not initialized');
202
208
  }
203
- const [chatBotMod, pgMod, asyncMod] = await Promise.all([
204
- import('../../addon/chat-bot/pg/index.js'),
205
- import('../pg/index.js'),
206
- import('../../addon/async/pg/index.js'),
209
+ const hasCommandHandlers = components.commandHandlers.length > 0;
210
+ const hasCronHandlers = components.cronHandlers.length > 0;
211
+ const [chatBotMod, lockerMod, repoAdapterMod, txMod, jobMod, cronJobMod] = await Promise.all([
212
+ import('../../addon/chat-bot/pg/PgChatRepository.js'),
213
+ import('../pg/PgLocker.js'),
214
+ import('../pg/PgJsonRepositoryAdapter.js'),
215
+ import('../../addon/async/pg/PgTransactionAdapter.js'),
216
+ hasCommandHandlers || hasCronHandlers
217
+ ? import('../../addon/async/pg/PgJobRepository.js')
218
+ : Promise.resolve(null),
219
+ hasCronHandlers
220
+ ? import('../../addon/async/pg/PgCronJobRepository.js')
221
+ : Promise.resolve(null),
207
222
  ]);
208
223
  container.register(ChatRepository, { useToken: chatBotMod.PgChatRepository });
209
- container.register(Locker, { useToken: pgMod.PgLocker });
210
- const pgAdapter = new pgMod.PgJsonRepositoryAdapter(this.pool);
224
+ container.register(Locker, { useToken: lockerMod.PgLocker });
225
+ const pgAdapter = new repoAdapterMod.PgJsonRepositoryAdapter(this.pool);
211
226
  container.resolve(RepositoryAdapterRegistry).setDefault(pgAdapter);
212
227
  container.resolve(RepositoryMetadataStore).validateExtensionsRegistered(pgAdapter.id);
213
228
  const transactionStore = container.resolve(TransactionMetadataStore);
214
- transactionStore.registerAdapter('default', new asyncMod.PgTransactionAdapter(this.pool));
215
- const hasCommandHandlers = components.commandHandlers.length > 0;
216
- const hasCronHandlers = components.cronHandlers.length > 0;
217
- if (hasCommandHandlers || hasCronHandlers) {
218
- container.register(JobRepository, { useToken: asyncMod.PgJobRepository });
229
+ transactionStore.registerAdapter('default', new txMod.PgTransactionAdapter(this.pool));
230
+ if (jobMod) {
231
+ container.register(JobRepository, { useToken: jobMod.PgJobRepository });
219
232
  }
220
- if (hasCronHandlers) {
221
- container.register(CronJobRepository, { useToken: asyncMod.PgCronJobRepository });
233
+ if (cronJobMod) {
234
+ container.register(CronJobRepository, { useToken: cronJobMod.PgCronJobRepository });
222
235
  }
223
236
  logger.info('Configured with PostgreSQL adapters');
224
237
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wabot-dev/framework",
3
- "version": "0.9.6",
3
+ "version": "0.9.8",
4
4
  "description": "Framework for IA Chat Bots",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -1,2 +0,0 @@
1
- export { InMemoryJobRepository } from './InMemoryJobRepository.js';
2
- export { InMemoryCronJobRepository } from './InMemoryCronJobRepository.js';
@@ -1,3 +0,0 @@
1
- export { PgCronJobRepository } from './PgCronJobRepository.js';
2
- export { PgJobRepository } from './PgJobRepository.js';
3
- export { PgTransactionAdapter } from './PgTransactionAdapter.js';
@@ -1,2 +0,0 @@
1
- export { InMemoryChatMemory } from './InMemoryChatMemory.js';
2
- export { InMemoryChatRepository } from './InMemoryChatRepository.js';
@@ -1,2 +0,0 @@
1
- export { PgChatRepository } from './PgChatRepository.js';
2
- export { PgChatMemory } from './PgChatMemory.js';
@@ -1,2 +0,0 @@
1
- export { InMemoryLockKey } from './InMemoryLockKey.js';
2
- export { InMemoryLocker } from './InMemoryLocker.js';
@@ -1,10 +0,0 @@
1
- export { PG_ADAPTER_ID, pgExtension } from './@pgExtension.js';
2
- export { PgCrudRepository } from './PgCrudRepository.js';
3
- export { PgJsonRepositoryAdapter } from './PgJsonRepositoryAdapter.js';
4
- export { PgLocker } from './PgLocker.js';
5
- export { PgLockKey } from './PgLockKey.js';
6
- export { PgRepositoryBase, PgRepositoryBase as PgRepositoryExtension } from './PgRepositoryBase.js';
7
- export { getClientMap, pgStorage } from './pgStorage.js';
8
- export { buildQuerySql } from './buildQuerySql.js';
9
- export { getPgClient, withPgClient } from './withPgClient.js';
10
- export { withPgTransaction } from './withPgTransaction.js';