@tstdl/base 0.92.68 → 0.92.69

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.
@@ -36,11 +36,11 @@ export const ENTITY_TYPE = injectionToken('EntityType');
36
36
  const entityTypeToken = Symbol('EntityType');
37
37
  const entityRepositoryConfigToken = Symbol('EntityRepositoryConfig');
38
38
  const TRANSACTION_TIMESTAMP = sql `transaction_timestamp()`;
39
- const { getCurrentEntityRepositoryContext, runInEntityRepositoryContext } = createContextProvider('EntityRepository');
39
+ const { getCurrentEntityRepositoryContext, runInEntityRepositoryContext, isInEntityRepositoryContext } = createContextProvider('EntityRepository');
40
40
  let EntityRepository = class EntityRepository {
41
41
  #repositoryConstructor;
42
42
  #withTransactionCache = new WeakMap();
43
- #encryptionSecret = inject(ENCRYPTION_SECRET, undefined, { optional: true });
43
+ #encryptionSecret = isInEntityRepositoryContext() ? getCurrentEntityRepositoryContext()?.encryptionSecret : inject(ENCRYPTION_SECRET, undefined, { optional: true });
44
44
  #transformContext;
45
45
  type;
46
46
  table;
@@ -51,13 +51,14 @@ let EntityRepository = class EntityRepository {
51
51
  constructor() {
52
52
  this.#repositoryConstructor = new.target;
53
53
  const entityRepositoryConfig = new.target[entityRepositoryConfigToken] ?? inject(EntityRepositoryConfig);
54
- const { type, table, columnDefinitions, columnDefinitionsMap, session } = getCurrentEntityRepositoryContext() ?? {};
54
+ const { type, table, columnDefinitions, columnDefinitionsMap, session, transformContext } = getCurrentEntityRepositoryContext() ?? {};
55
55
  this.type = type ?? injectArgument(this, { optional: true }) ?? assertDefinedPass(new.target[entityTypeToken], 'Missing entity type.');
56
56
  this.table = table ?? getDrizzleTableFromType(this.type, entityRepositoryConfig.schema);
57
57
  this.columnDefinitions = columnDefinitions ?? getColumnDefinitions(this.table);
58
58
  this.columnDefinitionsMap = columnDefinitionsMap ?? new Map(this.columnDefinitions.map((column) => [column.objectPath.path, column]));
59
59
  this.session = session ?? inject(Database);
60
60
  this.isInTransaction = this.session instanceof DrizzlePgTransaction;
61
+ this.#transformContext = transformContext;
61
62
  }
62
63
  withOptionalTransaction(transaction) {
63
64
  if (isUndefined(transaction)) {
@@ -74,7 +75,9 @@ let EntityRepository = class EntityRepository {
74
75
  table: this.table,
75
76
  columnDefinitions: this.columnDefinitions,
76
77
  columnDefinitionsMap: this.columnDefinitionsMap,
77
- session: transaction.transaction
78
+ session: transaction.transaction,
79
+ encryptionSecret: this.#encryptionSecret,
80
+ transformContext: this.#transformContext
78
81
  };
79
82
  const repositoryWithTransaction = runInEntityRepositoryContext(context, () => new this.#repositoryConstructor());
80
83
  this.#withTransactionCache.set(transaction, repositoryWithTransaction);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.92.68",
3
+ "version": "0.92.69",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"