-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: PrimaryKeyCollection not include idIndex when buildIndex is called
Summary: Test Plan:
- Loading branch information
Tangent Lin
committed
Mar 19, 2024
1 parent
5c02887
commit 5cae086
Showing
15 changed files
with
394 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { ICollectionChangeDetail } from '../core/ICollectionChangeDetail'; | ||
|
||
export function mergeCollectionChangeDetail<T>( | ||
a: Partial<ICollectionChangeDetail<T>>, | ||
b: Partial<ICollectionChangeDetail<T>> | ||
): ICollectionChangeDetail<T> { | ||
const added = a.added | ||
? b.added | ||
? a.added.concat(b.added) | ||
: a.added | ||
: b.added; | ||
const removed = a.removed | ||
? b.removed | ||
? a.removed.concat(b.removed) | ||
: a.removed | ||
: b.removed; | ||
const updated = a.updated | ||
? b.updated | ||
? a.updated.concat(b.updated) | ||
: a.updated | ||
: b.updated; | ||
return { | ||
added: added ?? [], | ||
removed: removed ?? [], | ||
updated: updated ?? [], | ||
}; | ||
} | ||
|
||
export function filterCollectionChangeDetail<T>( | ||
change: Readonly<ICollectionChangeDetail<T>>, | ||
filter: (item: T) => boolean | ||
): ICollectionChangeDetail<T> { | ||
const added = change.added.filter(filter); | ||
const removed = change.removed.filter(filter); | ||
const updated = change.updated.filter((item) => filter(item.newValue)); | ||
return { | ||
added, | ||
removed, | ||
updated, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface ICollectionUpdateLineItem<T> { | ||
oldValue: T; | ||
newValue: T; | ||
} | ||
|
||
export interface ICollectionChangeDetail<T> { | ||
readonly added: T[]; | ||
readonly removed: T[]; | ||
readonly updated: ICollectionUpdateLineItem<T>[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { IReadonlyCollection } from '../core/IReadonlyCollection'; | ||
import { Signal } from './Signal'; | ||
|
||
export class CollectionAddSignal<T> extends Signal { | ||
static readonly type = Symbol('COLLECTION_ADD'); | ||
constructor( | ||
target: IReadonlyCollection<T>, | ||
public readonly added: readonly T[] | ||
) { | ||
super(CollectionAddSignal.type, target); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { Signal } from './Signal'; | ||
import { ICollectionChangeDetail } from '../core/ICollectionChangeDetail'; | ||
import { IReadonlyCollection } from '../core/IReadonlyCollection'; | ||
import { Signal } from './Signal'; | ||
|
||
export class CollectionChangeSignal<T> extends Signal { | ||
static readonly type = Symbol('COLLECTION_CHANGE'); | ||
constructor(target: IReadonlyCollection<T>) { | ||
constructor( | ||
target: IReadonlyCollection<T>, | ||
public readonly detail: Readonly<ICollectionChangeDetail<T>> | ||
) { | ||
super(CollectionChangeSignal.type, target); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { IReadonlyCollection } from '../core/IReadonlyCollection'; | ||
import { Signal } from './Signal'; | ||
|
||
export class CollectionRemoveSignal<T> extends Signal { | ||
static readonly type = Symbol('COLLECTION_REMOVE'); | ||
constructor( | ||
target: IReadonlyCollection<T>, | ||
public readonly removed: readonly T[] | ||
) { | ||
super(CollectionRemoveSignal.type, target); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ICollectionUpdateLineItem } from '../core/ICollectionChangeDetail'; | ||
import { IReadonlyCollection } from '../core/IReadonlyCollection'; | ||
import { Signal } from './Signal'; | ||
|
||
export class CollectionUpdateSignal<T> extends Signal { | ||
static readonly type = Symbol('COLLECTION_UPDATE'); | ||
constructor( | ||
target: IReadonlyCollection<T>, | ||
public readonly updated: readonly Readonly<ICollectionUpdateLineItem<T>>[] | ||
) { | ||
super(CollectionUpdateSignal.type, target); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
export { CollectionAddSignal } from './CollectionAddSignal'; | ||
export { CollectionChangeSignal } from './CollectionChangeSignal'; | ||
export { CollectionRemoveSignal } from './CollectionRemoveSignal'; | ||
export { CollectionUpdateSignal } from './CollectionUpdateSignal'; | ||
export { SignalHandler } from './ISignalObserver'; | ||
export { Signal, SignalType } from './Signal'; | ||
export { SignalObserver } from './SignalObserver'; |
Oops, something went wrong.