Skip to content

Commit

Permalink
chore: simplify file structure in graph package (#8755)
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired authored Jul 30, 2023
1 parent b7ee27d commit de1c34d
Show file tree
Hide file tree
Showing 30 changed files with 52 additions and 53 deletions.
2 changes: 1 addition & 1 deletion packages/graph/src/-private.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { graphFor, peekGraph } from './-private/graph/index';
export { graphFor, peekGraph } from './-private/index';

/**
* <p align="center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type Store from '@ember-data/store';
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';
import type { RelationshipSchema } from '@ember-data/types/q/record-data-schemas';

import { assertInheritedSchema } from '../debug/assert-polymorphic-type';
import { expandingGet, expandingSet, getStore } from './-utils';
import { assertInheritedSchema } from './debug/assert-polymorphic-type';
import type { Graph } from './graph';

export type EdgeCache = Record<string, Record<string, EdgeDefinition | null>>;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-w
import { ResourceIdentifierObject } from '@ember-data/types/q/ember-data-json-api';
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';

import { coerceId } from '../coerce-id';
import type BelongsToRelationship from '../relationships/state/belongs-to';
import type ManyRelationship from '../relationships/state/has-many';
import { UpgradedMeta } from './-edge-definition';
import type { UpdateRelationshipOperation } from './-operations';
import { coerceId } from './coerce-id';
import type { Graph, ImplicitRelationship } from './graph';
import type BelongsToRelationship from './state/belongs-to';
import type ManyRelationship from './state/has-many';

export function getStore(wrapper: CacheCapabilitiesManager | { _store: Store }): Store {
assert(`expected a private _store property`, '_store' in wrapper);
Expand Down
3 changes: 1 addition & 2 deletions packages/graph/src/-private/debug/assert-polymorphic-type.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { assert } from '@ember/debug';
import { DEBUG } from '@ember-data/env';
import type { UpgradedMeta } from '../graph/-edge-definition';
import type { UpgradedMeta } from '../-edge-definition';
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';
import type Store from '@ember-data/store';
import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-wrapper';

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { MergeOperation } from '@ember-data/types/q/cache';
import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-wrapper';
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';

import BelongsToRelationship from '../relationships/state/belongs-to';
import ManyRelationship from '../relationships/state/has-many';
import type { EdgeCache, UpgradedMeta } from './-edge-definition';
import { isLHS, upgradeDefinition } from './-edge-definition';
import type {
Expand All @@ -33,6 +31,8 @@ import removeFromRelatedRecords from './operations/remove-from-related-records';
import replaceRelatedRecord from './operations/replace-related-record';
import replaceRelatedRecords, { syncRemoteToLocal } from './operations/replace-related-records';
import updateRelationshipOperation from './operations/update-relationship';
import BelongsToRelationship from './state/belongs-to';
import ManyRelationship from './state/has-many';

export interface ImplicitRelationship {
definition: UpgradedMeta;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { assert } from '@ember/debug';
import { DEBUG } from '@ember-data/env';
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';

import { assertPolymorphicType } from '../../debug/assert-polymorphic-type';
import type ManyRelationship from '../../relationships/state/has-many';
import type { AddToRelatedRecordsOperation } from '../-operations';
import { isHasMany, notifyChange } from '../-utils';
import { assertPolymorphicType } from '../debug/assert-polymorphic-type';
import type { Graph } from '../graph';
import type ManyRelationship from '../state/has-many';
import { addToInverse } from './replace-related-records';

export default function addToRelatedRecords(graph: Graph, op: AddToRelatedRecordsOperation, isRemote: boolean) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { MergeOperation } from '@ember-data/types/q/cache';

import type BelongsToRelationship from '../../relationships/state/belongs-to';
import type ManyRelationship from '../../relationships/state/has-many';
import { forAllRelatedIdentifiers, isBelongsTo, isHasMany, notifyChange } from '../-utils';
import type { Graph, ImplicitRelationship, RelationshipEdge } from '../graph';
import type BelongsToRelationship from '../state/belongs-to';
import type ManyRelationship from '../state/has-many';

export function mergeIdentifier(graph: Graph, op: MergeOperation, relationships: Record<string, RelationshipEdge>) {
Object.keys(relationships).forEach((key) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { assert } from '@ember/debug';

import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';

import type ManyRelationship from '../../relationships/state/has-many';
import type { RemoveFromRelatedRecordsOperation } from '../-operations';
import { isHasMany, notifyChange } from '../-utils';
import type { Graph } from '../graph';
import type ManyRelationship from '../state/has-many';
import { removeFromInverse } from './replace-related-records';

export default function removeFromRelatedRecords(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { assert } from '@ember/debug';
import { DEBUG } from '@ember-data/env';
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';

import { assertPolymorphicType } from '../../debug/assert-polymorphic-type';
import type { ReplaceRelatedRecordOperation } from '../-operations';
import { isBelongsTo, isNew, notifyChange } from '../-utils';
import { assertPolymorphicType } from '../debug/assert-polymorphic-type';
import type { Graph } from '../graph';
import { addToInverse, notifyInverseOfPotentialMaterialization, removeFromInverse } from './replace-related-records';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { assert } from '@ember/debug';
import { DEBUG } from '@ember-data/env';
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';

import { assertPolymorphicType } from '../../debug/assert-polymorphic-type';
import type ManyRelationship from '../../relationships/state/has-many';
import type { ReplaceRelatedRecordsOperation } from '../-operations';
import { isBelongsTo, isHasMany, isNew, notifyChange } from '../-utils';
import { assertPolymorphicType } from '../debug/assert-polymorphic-type';
import type { Graph } from '../graph';
import type ManyRelationship from '../state/has-many';

/*
case many:1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { assert, warn } from '@ember/debug';

import type { ExistingResourceIdentifierObject } from '@ember-data/types/q/ember-data-json-api';

import _normalizeLink from '../../normalize-link';
import type { UpdateRelationshipOperation } from '../-operations';
import { isBelongsTo, isHasMany, notifyChange } from '../-utils';
import type { Graph } from '../graph';
import _normalizeLink from '../normalize-link';

/*
Updates the "canonical" or "remote" state of a relationship, replacing any existing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Links, Meta, PaginationLinks, SingleResourceRelationship } from '@ember-data/types/q/ember-data-json-api';
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';

import type { UpgradedMeta } from '../../graph/-edge-definition';
import type { RelationshipState } from '../../graph/-state';
import { createState } from '../../graph/-state';
import type { UpgradedMeta } from '../-edge-definition';
import type { RelationshipState } from '../-state';
import { createState } from '../-state';

export default class BelongsToRelationship {
declare definition: UpgradedMeta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type {
} from '@ember-data/types/q/ember-data-json-api';
import type { StableRecordIdentifier } from '@ember-data/types/q/identifier';

import type { UpgradedMeta } from '../../graph/-edge-definition';
import type { RelationshipState } from '../../graph/-state';
import { createState } from '../../graph/-state';
import type { UpgradedMeta } from '../-edge-definition';
import type { RelationshipState } from '../-state';
import { createState } from '../-state';

export default class ManyRelationship {
declare definition: UpgradedMeta;
Expand Down
10 changes: 5 additions & 5 deletions packages/json-api/src/-private/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { schedule } from '@ember/runloop';
import { LOG_MUTATIONS, LOG_OPERATIONS } from '@ember-data/debugging';
import { DEBUG } from '@ember-data/env';
import { graphFor, peekGraph } from '@ember-data/graph/-private';
import type { LocalRelationshipOperation } from '@ember-data/graph/-private/graph/-operations';
import type { Graph } from '@ember-data/graph/-private/graph/graph';
import type { ImplicitRelationship } from '@ember-data/graph/-private/graph/index';
import type BelongsToRelationship from '@ember-data/graph/-private/relationships/state/belongs-to';
import type ManyRelationship from '@ember-data/graph/-private/relationships/state/has-many';
import type { LocalRelationshipOperation } from '@ember-data/graph/-private/-operations';
import type { Graph } from '@ember-data/graph/-private/graph';
import type { ImplicitRelationship } from '@ember-data/graph/-private/index';
import type BelongsToRelationship from '@ember-data/graph/-private/state/belongs-to';
import type ManyRelationship from '@ember-data/graph/-private/state/has-many';
import { StructuredErrorDocument } from '@ember-data/request/-private/types';
import { StoreRequestInfo } from '@ember-data/store/-private/cache-handler';
import type { IdentifierCache } from '@ember-data/store/-private/caches/identifier-cache';
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy-compat/src/legacy-network-handler/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { assert } from '@ember/debug';

import { importSync } from '@embroider/macros';

import type BelongsToRelationship from '@ember-data/graph/-private/relationships/state/belongs-to';
import type ManyRelationship from '@ember-data/graph/-private/relationships/state/has-many';
import type BelongsToRelationship from '@ember-data/graph/-private/state/belongs-to';
import type ManyRelationship from '@ember-data/graph/-private/state/has-many';
import { HAS_JSON_API_PACKAGE } from '@ember-data/packages';
import type Store from '@ember-data/store';
import type { ChangedAttributesHash } from '@ember-data/types/q/cache';
Expand Down
12 changes: 6 additions & 6 deletions packages/model/src/-private/legacy-relationships-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { assert } from '@ember/debug';
import { importSync } from '@embroider/macros';

import { DEBUG } from '@ember-data/env';
import type { UpgradedMeta } from '@ember-data/graph/-private/graph/-edge-definition';
import type { LocalRelationshipOperation } from '@ember-data/graph/-private/graph/-operations';
import type { Graph } from '@ember-data/graph/-private/graph/graph';
import type { ImplicitRelationship } from '@ember-data/graph/-private/graph/index';
import type BelongsToRelationship from '@ember-data/graph/-private/relationships/state/belongs-to';
import type ManyRelationship from '@ember-data/graph/-private/relationships/state/has-many';
import type { UpgradedMeta } from '@ember-data/graph/-private/-edge-definition';
import type { LocalRelationshipOperation } from '@ember-data/graph/-private/-operations';
import type { Graph } from '@ember-data/graph/-private/graph';
import type { ImplicitRelationship } from '@ember-data/graph/-private/index';
import type BelongsToRelationship from '@ember-data/graph/-private/state/belongs-to';
import type ManyRelationship from '@ember-data/graph/-private/state/has-many';
import { HAS_JSON_API_PACKAGE } from '@ember-data/packages';
import type Store from '@ember-data/store';
import {
Expand Down
4 changes: 2 additions & 2 deletions packages/model/src/-private/references/belongs-to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { cached, tracked } from '@glimmer/tracking';
import type { Object as JSONObject, Value as JSONValue } from 'json-typescript';

import { DEBUG } from '@ember-data/env';
import type { Graph } from '@ember-data/graph/-private/graph/graph';
import type BelongsToRelationship from '@ember-data/graph/-private/relationships/state/belongs-to';
import type { Graph } from '@ember-data/graph/-private/graph';
import type BelongsToRelationship from '@ember-data/graph/-private/state/belongs-to';
import type Store from '@ember-data/store';
import { recordIdentifierFor } from '@ember-data/store/-private';
import type { NotificationType } from '@ember-data/store/-private/managers/notification-manager';
Expand Down
4 changes: 2 additions & 2 deletions packages/model/src/-private/references/has-many.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { Object as JSONObject, Value as JSONValue } from 'json-typescript';
import { ManyArray } from 'ember-data/-private';

import { DEBUG } from '@ember-data/env';
import type { Graph } from '@ember-data/graph/-private/graph/graph';
import type ManyRelationship from '@ember-data/graph/-private/relationships/state/has-many';
import type { Graph } from '@ember-data/graph/-private/graph';
import type ManyRelationship from '@ember-data/graph/-private/state/has-many';
import type Store from '@ember-data/store';
import { recordIdentifierFor } from '@ember-data/store';
import type { NotificationType } from '@ember-data/store/-private/managers/notification-manager';
Expand Down
2 changes: 1 addition & 1 deletion packages/store/src/-private/managers/cache-manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { LocalRelationshipOperation } from '@ember-data/graph/-private/graph/-operations';
import type { LocalRelationshipOperation } from '@ember-data/graph/-private/-operations';
import type { StructuredDataDocument } from '@ember-data/request/-private/types';
import type { Change } from '@ember-data/types/cache/change';
import type {
Expand Down
2 changes: 1 addition & 1 deletion packages/store/src/-private/store-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { Object as JSONObject } from 'json-typescript';

import { LOG_PAYLOADS, LOG_REQUESTS } from '@ember-data/debugging';
import { DEBUG, TESTING } from '@ember-data/env';
import type { Graph } from '@ember-data/graph/-private/graph/graph';
import type { Graph } from '@ember-data/graph/-private/graph';
import type { FetchManager } from '@ember-data/legacy-compat/-private';
import type RequestManager from '@ember-data/request';
import type { Future } from '@ember-data/request/-private/types';
Expand Down
4 changes: 2 additions & 2 deletions tests/graph/tests/integration/graph/edge-removal/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { setupTest } from 'ember-qunit';

import { graphFor } from '@ember-data/graph/-private';
import type { ImplicitRelationship } from '@ember-data/graph/-private/graph';
import type BelongsToRelationship from '@ember-data/graph/-private/relationships/state/belongs-to';
import type ManyRelationship from '@ember-data/graph/-private/relationships/state/has-many';
import type BelongsToRelationship from '@ember-data/graph/-private/state/belongs-to';
import type ManyRelationship from '@ember-data/graph/-private/state/has-many';
import type Model from '@ember-data/model';
import type Store from '@ember-data/store';
import type {
Expand Down
2 changes: 1 addition & 1 deletion tests/graph/tests/integration/graph/operations-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

import { graphFor } from '@ember-data/graph/-private';
import type ManyRelationship from '@ember-data/graph/-private/relationships/state/has-many';
import type ManyRelationship from '@ember-data/graph/-private/state/has-many';
import Model, { attr, hasMany } from '@ember-data/model';
import type Store from '@ember-data/store';

Expand Down
4 changes: 2 additions & 2 deletions tests/graph/tests/integration/graph/unload-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

import { graphFor } from '@ember-data/graph/-private';
import type { Graph } from '@ember-data/graph/-private/graph/graph';
import BelongsToRelationship from '@ember-data/graph/-private/relationships/state/belongs-to';
import type { Graph } from '@ember-data/graph/-private/graph';
import BelongsToRelationship from '@ember-data/graph/-private/state/belongs-to';
import Model, { attr, belongsTo } from '@ember-data/model';
import type Store from '@ember-data/store';
import { StableRecordIdentifier } from '@ember-data/types/q/identifier';
Expand Down
4 changes: 2 additions & 2 deletions tests/main/tests/helpers/accessors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { graphFor } from '@ember-data/graph/-private';
import type { ImplicitRelationship } from '@ember-data/graph/-private/graph';
import type BelongsToRelationship from '@ember-data/graph/-private/relationships/state/belongs-to';
import type ManyRelationship from '@ember-data/graph/-private/relationships/state/has-many';
import type BelongsToRelationship from '@ember-data/graph/-private/state/belongs-to';
import type ManyRelationship from '@ember-data/graph/-private/state/has-many';
import type Store from '@ember-data/store';
import { recordIdentifierFor } from '@ember-data/store';
import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-wrapper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Store from 'ember-data/store';
import { setupTest } from 'ember-qunit';

import { InvalidError } from '@ember-data/adapter/error';
import type { LocalRelationshipOperation } from '@ember-data/graph/-private/graph/-operations';
import type { LocalRelationshipOperation } from '@ember-data/graph/-private/-operations';
import Model, { attr } from '@ember-data/model';
import { StructuredDataDocument } from '@ember-data/request/-private/types';
import { recordIdentifierFor } from '@ember-data/store';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Promise } from 'rsvp';
import Store from 'ember-data/store';
import { setupTest } from 'ember-qunit';

import { LocalRelationshipOperation } from '@ember-data/graph/-private/graph/-operations';
import { LocalRelationshipOperation } from '@ember-data/graph/-private/-operations';
import Model, { attr } from '@ember-data/model';
import { StructuredDataDocument } from '@ember-data/request/-private/types';
import JSONAPISerializer from '@ember-data/serializer/json-api';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Store from 'ember-data/store';
import { setupTest } from 'ember-qunit';

import JSONAPIAdapter from '@ember-data/adapter/json-api';
import type { LocalRelationshipOperation } from '@ember-data/graph/-private/graph/-operations';
import type { LocalRelationshipOperation } from '@ember-data/graph/-private/-operations';
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';
import { StructuredDataDocument } from '@ember-data/request/-private/types';
import JSONAPISerializer from '@ember-data/serializer/json-api';
Expand Down

0 comments on commit de1c34d

Please sign in to comment.