@tstdl/base 0.92.77 → 0.92.79

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.
package/ai/ai.service.js CHANGED
@@ -339,27 +339,29 @@ Always output the content and tags in ${options?.targetLanguage ?? 'the same lan
339
339
  convertGoogleContent(content) {
340
340
  return {
341
341
  role: content.role,
342
- parts: content.parts
343
- .map((part) => {
344
- if (isDefined(part.text)) {
345
- if (part.text.length == 0) {
346
- return null;
342
+ parts: isUndefined(content.parts)
343
+ ? []
344
+ : content.parts
345
+ .map((part) => {
346
+ if (isDefined(part.text)) {
347
+ if (part.text.length == 0) {
348
+ return null;
349
+ }
350
+ return { text: part.text };
347
351
  }
348
- return { text: part.text };
349
- }
350
- if (isDefined(part.fileData)) {
351
- const file = assertDefinedPass(this.#fileService.getFileByUri(part.fileData.fileUri), 'File not found.');
352
- return { file: file.id };
353
- }
354
- if (isDefined(part.functionResponse)) {
355
- return { functionResult: { name: part.functionResponse.name, value: part.functionResponse.response } };
356
- }
357
- if (isDefined(part.functionCall)) {
358
- return { functionCall: { name: part.functionCall.name, parameters: part.functionCall.args } };
359
- }
360
- throw new NotSupportedError('Unsupported content part.');
361
- })
362
- .filter(isNotNull)
352
+ if (isDefined(part.fileData)) {
353
+ const file = assertDefinedPass(this.#fileService.getFileByUri(part.fileData.fileUri), 'File not found.');
354
+ return { file: file.id };
355
+ }
356
+ if (isDefined(part.functionResponse)) {
357
+ return { functionResult: { name: part.functionResponse.name, value: part.functionResponse.response } };
358
+ }
359
+ if (isDefined(part.functionCall)) {
360
+ return { functionCall: { name: part.functionCall.name, parameters: part.functionCall.args } };
361
+ }
362
+ throw new NotSupportedError('Unsupported content part.');
363
+ })
364
+ .filter(isNotNull)
363
365
  };
364
366
  }
365
367
  getModel(model) {
@@ -13,7 +13,8 @@ import { PgTransaction as DrizzlePgTransaction } from 'drizzle-orm/pg-core';
13
13
  import { createContextProvider } from '../../context/context.js';
14
14
  import { NotFoundError } from '../../errors/not-found.error.js';
15
15
  import { Singleton } from '../../injector/decorators.js';
16
- import { inject, injectArgument } from '../../injector/inject.js';
16
+ import { Injector } from '../../injector/index.js';
17
+ import { inject, injectArgument, runInInjectionContext } from '../../injector/inject.js';
17
18
  import { resolveArgumentType } from '../../injector/interfaces.js';
18
19
  import { Schema } from '../../schema/schema.js';
19
20
  import { toArray } from '../../utils/array/array.js';
@@ -35,6 +36,7 @@ const entityTypeToken = Symbol('EntityType');
35
36
  const TRANSACTION_TIMESTAMP = sql `transaction_timestamp()`;
36
37
  const { getCurrentEntityRepositoryContext, runInEntityRepositoryContext, isInEntityRepositoryContext } = createContextProvider('EntityRepository');
37
38
  let EntityRepository = class EntityRepository {
39
+ #injector = inject(Injector);
38
40
  #repositoryConstructor;
39
41
  #withTransactionCache = new WeakMap();
40
42
  #encryptionSecret = isInEntityRepositoryContext() ? getCurrentEntityRepositoryContext()?.encryptionSecret : inject(ENCRYPTION_SECRET, undefined, { optional: true });
@@ -75,7 +77,7 @@ let EntityRepository = class EntityRepository {
75
77
  encryptionSecret: this.#encryptionSecret,
76
78
  transformContext: this.#transformContext
77
79
  };
78
- const repositoryWithTransaction = runInEntityRepositoryContext(context, () => new this.#repositoryConstructor());
80
+ const repositoryWithTransaction = runInInjectionContext(this.#injector, () => runInEntityRepositoryContext(context, () => new this.#repositoryConstructor()));
79
81
  this.#withTransactionCache.set(transaction, repositoryWithTransaction);
80
82
  return repositoryWithTransaction;
81
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.77",
3
+ "version": "0.92.79",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"