@sankhyalabs/core
Advanced tools
Comparing version 1.0.45 to 1.0.46
@@ -70,2 +70,3 @@ import { UnitMetadata, FieldDescriptor, SortingProvider, FilterProvider, Sort, Filter } from "./metadata/UnitMetadata.js"; | ||
INSERT = "INSERT", | ||
COPY = "COPY", | ||
UPDATE = "UPDATE", | ||
@@ -77,7 +78,9 @@ DELETE = "DELETE" | ||
record: Record; | ||
sourceId: string | undefined; | ||
updatingFields: any; | ||
private _operation; | ||
constructor(dataUnit: string, record: Record, updates: any, operation: ChangeOperation); | ||
constructor(dataUnit: string, record: Record, updates: any, operation: ChangeOperation, sourceId?: string); | ||
get operation(): string; | ||
isInsert(): boolean; | ||
isCopy(): boolean; | ||
isDelete(): boolean; | ||
@@ -84,0 +87,0 @@ isUpdate(): boolean; |
@@ -268,2 +268,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
ChangeOperation["INSERT"] = "INSERT"; | ||
ChangeOperation["COPY"] = "COPY"; | ||
ChangeOperation["UPDATE"] = "UPDATE"; | ||
@@ -273,5 +274,6 @@ ChangeOperation["DELETE"] = "DELETE"; | ||
export class Change { | ||
constructor(dataUnit, record, updates, operation) { | ||
constructor(dataUnit, record, updates, operation, sourceId) { | ||
this.dataUnit = dataUnit; | ||
this.record = record; | ||
this.sourceId = sourceId; | ||
this.updatingFields = updates; | ||
@@ -286,2 +288,5 @@ this._operation = operation; | ||
} | ||
isCopy() { | ||
return this._operation === ChangeOperation.COPY; | ||
} | ||
isDelete() { | ||
@@ -288,0 +293,0 @@ return this._operation === ChangeOperation.DELETE; |
@@ -24,4 +24,4 @@ import { Action } from "../action/DataUnitAction.js"; | ||
let index = (getAddedRecords(stateManager) || []).length; | ||
return source.map(item => { return Object.assign(Object.assign({}, item), { __record__id__: "NEW_" + (index++) }); }); | ||
return source.map(item => { return Object.assign(Object.assign({}, item), { __record__id__: "NEW_" + (index++), __record__source__id__: item.__record__id__ }); }); | ||
}; | ||
//# sourceMappingURL=AddedRecordsSlice.js.map |
@@ -64,3 +64,5 @@ import { Action } from "../action/DataUnitAction.js"; | ||
addedRecords.forEach(r => { | ||
result.push(new Change(dataUnit, r, changes === null || changes === void 0 ? void 0 : changes.get(r.__record__id__), ChangeOperation.INSERT)); | ||
const source = r.__record__source__id__; | ||
const operation = source ? ChangeOperation.COPY : ChangeOperation.INSERT; | ||
result.push(new Change(dataUnit, r, changes === null || changes === void 0 ? void 0 : changes.get(r.__record__id__), operation, source)); | ||
}); | ||
@@ -67,0 +69,0 @@ } |
{ | ||
"name": "@sankhyalabs/core", | ||
"version": "1.0.45", | ||
"version": "1.0.46", | ||
"description": "Modulo core JavaScript da Sankhya.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -335,4 +335,5 @@ import { UnitMetadata, FieldDescriptor, SortingProvider, FilterProvider, Sort, Filter } from "./metadata/UnitMetadata.js"; | ||
INSERT = "INSERT", | ||
COPY = "COPY", | ||
UPDATE = "UPDATE", | ||
DELETE = "DELETE" | ||
DELETE = "DELETE", | ||
} | ||
@@ -344,2 +345,3 @@ | ||
public record: Record; | ||
public sourceId: string|undefined; | ||
public updatingFields: any; | ||
@@ -349,5 +351,6 @@ | ||
constructor(dataUnit: string, record: Record, updates: any, operation: ChangeOperation) { | ||
constructor(dataUnit: string, record: Record, updates: any, operation: ChangeOperation, sourceId?: string) { | ||
this.dataUnit = dataUnit; | ||
this.record = record; | ||
this.sourceId = sourceId; | ||
this.updatingFields = updates; | ||
@@ -365,2 +368,6 @@ this._operation = operation; | ||
public isCopy(): boolean { | ||
return this._operation === ChangeOperation.COPY; | ||
} | ||
public isDelete(): boolean { | ||
@@ -367,0 +374,0 @@ return this._operation === ChangeOperation.DELETE; |
@@ -32,3 +32,3 @@ | ||
let index = (getAddedRecords(stateManager)||[]).length; | ||
return source.map(item=>{return {...item, __record__id__: "NEW_" + (index++)}}); | ||
return source.map(item=>{return {...item, __record__id__: "NEW_" + (index++), __record__source__id__: item.__record__id__}}); | ||
}; |
@@ -82,3 +82,5 @@ | ||
addedRecords.forEach(r => { | ||
result.push(new Change(dataUnit, r, changes?.get(r.__record__id__), ChangeOperation.INSERT)); | ||
const source: string = r.__record__source__id__; | ||
const operation: ChangeOperation = source ? ChangeOperation.COPY : ChangeOperation.INSERT; | ||
result.push(new Change(dataUnit, r, changes?.get(r.__record__id__), operation, source)); | ||
}); | ||
@@ -85,0 +87,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
305332
5836