Skip to content

Commit

Permalink
feat: implement graph diffing (#8807)
Browse files Browse the repository at this point in the history
* feat: implement graph diffing

* fix test

* fix some tests and add deprecation infra for preserving legacy reset behavior

* fix more tests

* fix ts

* fix docs

* mroe tests

* update deprecations with urls

* update deprecation guide

* improve tests

* add more tests

* notification tests

* finish tests

* fix test

* fix lint
  • Loading branch information
runspired authored Sep 3, 2023
1 parent be9f3a8 commit 3473596
Show file tree
Hide file tree
Showing 48 changed files with 4,271 additions and 888 deletions.
6 changes: 4 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
**/dist-control/
**/dist-experiment/
**/tmp/
/packages/-ember-data/docs/
/packages/tracking/addon/
/packages/request/addon/
/packages/store/addon/
/packages/adapter/addon/
/packages/-ember-data/docs/
/packages/tracking/addon/
/packages/serializer/addon/
/packages/model/addon/
/packages/json-api/addon/
/packages/graph/addon/
/packages/legacy-compat/addon/
/packages/request-utils/addon/
/packages/rest/addon/
/packages/active-record/addon/

**/DEBUG/

Expand Down
33 changes: 33 additions & 0 deletions @types/ember-data-qunit-asserts/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import type { CacheOperation, NotificationType } from "@ember-data/store/-private/managers/notification-manager";
import type { StableDocumentIdentifier } from "@ember-data/types/cache/identifier";
import type { StableRecordIdentifier } from "@ember-data/types/q/identifier";

declare global {
interface DeprecationConfig {
id: string;
Expand All @@ -22,6 +26,26 @@ declare global {
expectNoWarning(callback: () => unknown): Promise<void>;
expectAssertion(callback: () => unknown, matcher: string | RegExp): Promise<void>;
expectNoAssertion(callback: () => unknown): Promise<void>;
/**
* Asserts that each member of actual strictly matches the corresponding member of expected.
* Asserts that actual is an array and has the same length as expected.
*/
arrayStrictEquals<T>(actual: unknown, expected: T[], message: string): void;
/**
* Asserts that the given identifier has been notified of a change to the given bucket
* and optional key the given number of times during the test.
*
* Clears the notification count for the given identifier, bucket and key after the assertion
* is made so that it is easy to assert notification counts in between steps of a test.
*/
notified(
identifier: StableDocumentIdentifier | StableRecordIdentifier,
bucket: NotificationType | CacheOperation,
key: string | null,
count: number
): void;

clearNotifications(): void;
}

namespace QUnit {
Expand All @@ -33,6 +57,15 @@ declare global {
expectNoWarning(callback: () => unknown): Promise<void>;
expectAssertion(callback: () => unknown, matcher: string | RegExp): Promise<void>;
expectNoAssertion(callback: () => unknown): Promise<void>;
arrayStrictEquals<T>(unknown, expected: T[], message: string): void;
notified(
identifier: StableDocumentIdentifier | StableRecordIdentifier,
bucket: NotificationType | CacheOperation,
key: string | null,
count: number
): void;

clearNotifications(): void;
}
}

Expand Down
1 change: 1 addition & 0 deletions ember-data-types/q/record-data-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface RelationshipSchema {
async: boolean; // controls inverse unloading "client side delete semantics" so we should replace that with a real flag
polymorphic?: boolean;
inverse: string | null; // property key on the related type (if any)
resetOnRemoteUpdate?: false; // manages the deprecation `DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE`
[key: string]: unknown;
};
// inverse?: string | null;
Expand Down
Loading

0 comments on commit 3473596

Please sign in to comment.