// Package: com.lightningkite.lightningdb // Generated by Khrysalis - this file will be overwritten. import { EntryChange, xEntryChangeMap } from './EntryChange' import { HasId } from './HasId' import { Comparable, ReifiedType, listRemoveAll, runOrNull, safeEq, setUpDataClass } from '@lightningkite/khrysalis-runtime' //! Declares com.lightningkite.lightningdb.CollectionChanges export class CollectionChanges { public constructor(public readonly changes: Array> = []) { } public static properties = ["changes"] public static propertyTypes(T: ReifiedType) { return {changes: [Array, [EntryChange, T]]} } copy: (values: Partial>) => this; equals: (other: any) => boolean; hashCode: () => number; public static pair(old: (T | null) = null, _new: (T | null) = null) { let result = new CollectionChanges(old !== null || _new !== null ? [new EntryChange(old, _new)] : []); return result; } } setUpDataClass(CollectionChanges) //! Declares com.lightningkite.lightningdb.apply>kotlin.collections.Listcom.lightningkite.lightningdb.apply.T export function xListApply, ID extends Comparable>(this_: Array, changes: CollectionChanges): Array { const changeable = Array.from(this_); for (const change of changes.changes) { const old_0 = change.old; if (old_0 !== null) { listRemoveAll(changeable, (it: T): boolean => (safeEq(it._id, old_0._id))); } const new_2 = change._new; if (new_2 !== null) { changeable.push(new_2); } } return changeable; } //! Declares com.lightningkite.lightningdb.map>com.lightningkite.lightningdb.CollectionChangescom.lightningkite.lightningdb.map.T export function xCollectionChangesMap(this_: CollectionChanges, mapper: ((a: T) => B)): CollectionChanges { return new CollectionChanges(this_.changes.map((it: EntryChange): EntryChange => (xEntryChangeMap(it, mapper)))); }