|
1 | 1 | import { Quad } from 'n3'; |
2 | 2 | import uniqid from 'uniqid'; |
3 | | -import { plainToClass } from 'class-transformer'; |
| 3 | + |
| 4 | +import { DiffTracker } from './diff-tracker'; |
| 5 | +import { FacetStorage } from './facet-storage'; |
| 6 | +import { PredicateImpl } from './predicate-impl'; |
| 7 | +import { MutationBuilder } from './mutation-builder'; |
4 | 8 |
|
5 | 9 | import { IPredicate } from '..'; |
6 | 10 | import { MetadataStorage } from '../metadata/storage'; |
7 | 11 | import { PredicateMetadata } from '../metadata/predicate'; |
8 | 12 | import { INode, IPlainPredicates } from '../types/data'; |
9 | 13 | import { Constructor } from '../utils/class'; |
10 | 14 | import { IObjectLiteral } from '../utils/type'; |
11 | | - |
12 | | -import { DiffTracker } from './diff-tracker'; |
13 | | -import { FacetStorage } from './facet-storage'; |
14 | | -import { PredicateImpl } from './predicate-impl'; |
15 | | -import { MutationBuilder } from './mutation-builder'; |
16 | 15 | import { IterableWeakMap } from '../utils/iterator'; |
| 16 | +import { transformer } from '../utils/transformer'; |
17 | 17 |
|
18 | 18 | /** |
19 | 19 | * Create an environment for a mapped tree. |
@@ -143,10 +143,7 @@ export class Transaction<T extends Object, V> implements ITransaction<T> { |
143 | 143 | } |
144 | 144 |
|
145 | 145 | // Build the entry class |
146 | | - const ins: T = plainToClass(cls, pln, { |
147 | | - enableCircularCheck: true, |
148 | | - strategy: 'exposeAll' |
149 | | - }); |
| 146 | + const ins: T = transformer(cls, pln); |
150 | 147 |
|
151 | 148 | // Keep reference to the instance so in case of circular we can simply get it from storage and complete the circle. |
152 | 149 | storage.set(pln, ins); |
@@ -271,7 +268,7 @@ export class Transaction<T extends Object, V> implements ITransaction<T> { |
271 | 268 | return acc; |
272 | 269 | }, {}); |
273 | 270 |
|
274 | | - const facetInstance = plainToClass(facet!, plain); |
| 271 | + const facetInstance = Object.assign(new facet!(), plain); |
275 | 272 | FacetStorage.attach(propertyName, instance, children[Number(idx)], facetInstance); |
276 | 273 |
|
277 | 274 | // Track each facet property in facet instance and reset it.. |
@@ -335,7 +332,7 @@ export interface ITransaction<T> { |
335 | 332 | /** |
336 | 333 | * Initialize a node object from data. |
337 | 334 | */ |
338 | | - nodeFor<N extends Object, V extends Object>(nodeCls: Constructor<N>, data: V): N; |
| 335 | + nodeFor<N extends Object, V extends Object>(nodeCls: Constructor<N>, data: V & { uid?: string }): N; |
339 | 336 |
|
340 | 337 | /** |
341 | 338 | * Get set nQuads for transaction. |
|
0 commit comments