@punks/backend-entity-manager 0.0.254 → 0.0.255

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.
@@ -0,0 +1,12 @@
1
+ import { IEntityConnector } from "../../../../../../../../abstractions";
2
+ import { FooEntity, FooEntityId } from "../../../../database/core/entities/foo.entity";
3
+ import { FooMappedModel } from "./model";
4
+ export declare class FooCustomConnector implements IEntityConnector<FooEntity, FooEntityId, FooMappedModel> {
5
+ private readonly syncQueue;
6
+ private readonly deleteQueue;
7
+ constructor();
8
+ syncEntity(entity: FooMappedModel): Promise<void>;
9
+ deleteEntity(id: FooEntityId): Promise<void>;
10
+ getSynchedElements(): FooMappedModel[];
11
+ getDeletedElements(): string[];
12
+ }
@@ -0,0 +1,6 @@
1
+ import { IEntityMapper } from "../../../../../../../../abstractions";
2
+ import { FooEntity } from "../../../../database/core/entities/foo.entity";
3
+ import { FooMappedModel } from "./model";
4
+ export declare class FooConnectorMapper implements IEntityMapper<FooEntity, FooMappedModel> {
5
+ mapEntity(entity: FooEntity): Promise<FooMappedModel>;
6
+ }
@@ -0,0 +1,4 @@
1
+ export type FooMappedModel = {
2
+ id: string;
3
+ displayName: string;
4
+ };
@@ -0,0 +1,3 @@
1
+ import { FooCustomConnector } from "./custom/connector";
2
+ import { FooConnectorMapper as FooCustomConnectorMapper } from "./custom/mapper";
3
+ export declare const FooConnectors: (typeof FooCustomConnector | typeof FooCustomConnectorMapper)[];
package/dist/esm/index.js CHANGED
@@ -2362,8 +2362,6 @@ class EntityManagerServiceCollection {
2362
2362
  constructor(entityName, locator) {
2363
2363
  this.entityName = entityName;
2364
2364
  this.locator = locator;
2365
- this.replicas = new ReplicasConfiguration();
2366
- this.connectors = new ConnectorsConfiguration();
2367
2365
  this.resolver = new EntityServiceLocator(locator, entityName);
2368
2366
  }
2369
2367
  getServiceLocator() {
@@ -2456,11 +2454,15 @@ class EntityManagerServiceCollection {
2456
2454
  return this;
2457
2455
  }
2458
2456
  withReplica({ name, options, repository, }) {
2459
- this.replicas.configureReplica(name, options, repository);
2457
+ this.resolver
2458
+ .resolveReplicaConfiguration()
2459
+ .configureReplica(name, options, repository);
2460
2460
  return this;
2461
2461
  }
2462
2462
  withSynchronization({ name, options, connector, mapper, }) {
2463
- this.connectors.configureConnector(name, options, connector, mapper);
2463
+ this.resolver
2464
+ .resolveConnectorsConfiguration()
2465
+ .configureConnector(name, options, connector, mapper);
2464
2466
  return this;
2465
2467
  }
2466
2468
  }
@@ -4033,8 +4035,9 @@ let EntityManagerRegistry = class EntityManagerRegistry {
4033
4035
  if (!mapper.discoveredClass.injectType) {
4034
4036
  throw new Error(`No inject type found for entity connector mapper: ${entityName} - ${connector.meta.connectorName}`);
4035
4037
  }
4036
- const connectorInstance = (await app.resolve(connector.discoveredClass.injectType));
4037
- const mapperInstance = (await app.resolve(connector.discoveredClass.injectType));
4038
+ const connectorInstance = connector.discoveredClass
4039
+ .instance;
4040
+ const mapperInstance = mapper.discoveredClass.instance;
4038
4041
  registration.withSynchronization({
4039
4042
  name: connector.meta.connectorName,
4040
4043
  mapper: mapperInstance,