Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename record-data => json-api #8355

Merged
merged 6 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/packages/tracking/addon/
/packages/serializer/addon/
/packages/model/addon/
/packages/record-data/addon/
/packages/json-api/addon/

**/DEBUG/

Expand Down
30 changes: 15 additions & 15 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,21 @@ module.exports = {
'tests/graph/tests/integration/graph/edge-removal/helpers.ts',
'tests/graph/tests/integration/graph/edge-removal/abstract-edge-removal-test.ts',
'tests/graph/tests/integration/graph.ts',
'packages/record-data/src/-private/relationships/state/has-many.ts',
'packages/record-data/src/-private/relationships/state/belongs-to.ts',
'packages/record-data/src/-private/record-data.ts',
'packages/record-data/src/-private/normalize-link.ts',
'packages/record-data/src/-private/graph/operations/update-relationship.ts',
'packages/record-data/src/-private/graph/operations/replace-related-records.ts',
'packages/record-data/src/-private/graph/operations/replace-related-record.ts',
'packages/record-data/src/-private/graph/operations/remove-from-related-records.ts',
'packages/record-data/src/-private/graph/operations/add-to-related-records.ts',
'packages/record-data/src/-private/graph/index.ts',
'packages/record-data/src/-private/graph/-utils.ts',
'packages/record-data/src/-private/graph/-state.ts',
'packages/record-data/src/-private/graph/-operations.ts',
'packages/record-data/src/-private/graph/-edge-definition.ts',
'packages/record-data/src/-private/coerce-id.ts',
'packages/json-api/src/-private/relationships/state/has-many.ts',
'packages/json-api/src/-private/relationships/state/belongs-to.ts',
'packages/json-api/src/-private/record-data.ts',
'packages/json-api/src/-private/normalize-link.ts',
'packages/json-api/src/-private/graph/operations/update-relationship.ts',
'packages/json-api/src/-private/graph/operations/replace-related-records.ts',
'packages/json-api/src/-private/graph/operations/replace-related-record.ts',
'packages/json-api/src/-private/graph/operations/remove-from-related-records.ts',
'packages/json-api/src/-private/graph/operations/add-to-related-records.ts',
'packages/json-api/src/-private/graph/index.ts',
'packages/json-api/src/-private/graph/-utils.ts',
'packages/json-api/src/-private/graph/-state.ts',
'packages/json-api/src/-private/graph/-operations.ts',
'packages/json-api/src/-private/graph/-edge-definition.ts',
'packages/json-api/src/-private/coerce-id.ts',
'packages/private-build-infra/addon/index.ts',
'packages/private-build-infra/addon/deprecations.ts',
'packages/private-build-infra/addon/current-deprecations.ts',
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ packages/store/addon
packages/adapter/addon
packages/serializer/addon
packages/model/addon
packages/record-data/addon
packages/json-api/addon

# dependencies
bower_components
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ not wish to use `ember-data`, remove `ember-data` from your project's `package.j

- [@ember-data/store](./packages/store) is the core and handles coordination
- [@ember-data/tracking](./packages/tracking) is required when using the core and provides tracking primitives for change notification of Tracked properties
- [@ember-data/record-data](./packages/record-data) is a resource cache for JSON:API structured data. It integrates with the store via the hook `createRecordDataFor`
- [@ember-data/json-api](./packages/json-api) is a resource cache for JSON:API structured data. It integrates with the store via the hook `createRecordDataFor`
- [@ember-data/model](./packages/model) is a presentation layer, it integrates with the store via the hooks `instantiateRecord` and `teardownRecord`.
- [@ember-data/adapter](./packages/adapter) provides various network API integrations for APIS built over specific REST or JSON:API conventions.
- [@ember-data/serializer](./packages/serializer) pairs with `@ember-data/adapter` to normalize and serialize data to and from an API format into the `JSON:API` format understood by `@ember-data/record-data`.
- [@ember-data/serializer](./packages/serializer) pairs with `@ember-data/adapter` to normalize and serialize data to and from an API format into the `JSON:API` format understood by `@ember-data/json-api`.
- [@ember-data/debug](./packages/debug) provides debugging support for the `ember-inspector`.
- [ember-data](./packages/-ember-data) is a "meta" package which bundles all of these together for convenience

Expand Down
2 changes: 1 addition & 1 deletion docs-generator/yuidoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"../packages/model/src",
"../packages/serializer/src",
"../packages/store/src",
"../packages/record-data/src",
"../packages/json-api/src",
"../packages/debug/addon",
"../packages/private-build-infra/addon",
"../packages/canary-features/addon",
Expand Down
2 changes: 1 addition & 1 deletion ember-data-types/q/record-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LocalRelationshipOperation } from '@ember-data/record-data/-private/graph/-operations';
import { LocalRelationshipOperation } from '@ember-data/json-api/-private/graph/-operations';

import type { CollectionResourceRelationship, SingleResourceRelationship } from './ember-data-json-api';
import type { RecordIdentifier, StableRecordIdentifier } from './identifier';
Expand Down
4 changes: 2 additions & 2 deletions packages/-ember-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ not wish to use `ember-data`, remove `ember-data` from your project's `package.j
EmberData is organized into primitives that compose together via public APIs.

- [@ember-data/store](https://github.com/emberjs/data/tree/master/packages/store) is the core and handles coordination
- [@ember-data/record-data](https://github.com/emberjs/data/tree/master/packages/record-data) is a resource cache for JSON:API structured data. It integrates with the store via the hook `createRecordDataFor`
- [@ember-data/json-api](https://github.com/emberjs/data/tree/master/packages/record-data) is a resource cache for JSON:API structured data. It integrates with the store via the hook `createRecordDataFor`
- [@ember-data/model](https://github.com/emberjs/data/tree/master/packages/model) is a presentation layer, it integrates with the store via the hooks `instantiateRecord` and `teardownRecord`.
- [@ember-data/adapter](https://github.com/emberjs/data/tree/master/packages/adapter) provides various network API integrations for APIS built over specific REST or JSON:API conventions.
- [@ember-data/serializer](https://github.com/emberjs/data/tree/master/packages/serializer) pairs with `@ember-data/adapter` to normalize and serialize data to and from an API format into the `JSON:API` format understood by `@ember-data/record-data`.
- [@ember-data/serializer](https://github.com/emberjs/data/tree/master/packages/serializer) pairs with `@ember-data/adapter` to normalize and serialize data to and from an API format into the `JSON:API` format understood by `@ember-data/json-api`.
- [@ember-data/debug](https://github.com/emberjs/data/tree/master/packages/debug) provides debugging support for the `ember-inspector`.
- [ember-data](https://github.com/emberjs/data/tree/master/packages/-ember-data) is a "meta" package which bundles all of these together for convenience

Expand Down
2 changes: 1 addition & 1 deletion packages/-ember-data/addon/-private/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export { Snapshot } from '@ember-data/store/-private';
// `ember-data-model-fragments' and `ember-data-change-tracker` rely on `normalizeModelName`
export { RecordArrayManager, SnapshotRecordArray, normalizeModelName, coerceId } from '@ember-data/store/-private';
export { ManyArray, PromiseManyArray } from '@ember-data/model/-private';
export { RecordData } from '@ember-data/record-data/-private';
export { RecordData } from '@ember-data/json-api/-private';

export const PromiseArray = ArrayProxy.extend(PromiseProxyMixin);
export const PromiseObject = ObjectProxy.extend(PromiseProxyMixin);
4 changes: 2 additions & 2 deletions packages/-ember-data/addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ not wish to use `ember-data`, remove `ember-data` from your project's `package.j
*Ember*‍**Data** is organized into primitives that compose together via public APIs.

- [@ember-data/store](/ember-data/release/modules/@ember-data%2Fstore) is the core and handles coordination
- [@ember-data/record-data](/ember-data/release/modules/@ember-data%2Frecord-data) is a resource cache for JSON:API structured data. It integrates with the store via the hook `createRecordDataFor`
- [@ember-data/json-api](/ember-data/release/modules/@ember-data%2Fjson-api) is a resource cache for JSON:API structured data. It integrates with the store via the hook `createRecordDataFor`
- [@ember-data/model](/ember-data/release/modules/@ember-data%2Fmodel) is a presentation layer, it integrates with the store via the hooks `instantiateRecord` and `teardownRecord`.
- [@ember-data/adapter](/ember-data/release/modules/@ember-data%2Fadapter) provides various network API integrations for APIS built over specific REST or JSON:API conventions.
- [@ember-data/serializer](/ember-data/release/modules/@ember-data%2Fserializer) pairs with `@ember-data/adapter` to normalize and serialize data to and from an API format into the `JSON:API` format understood by `@ember-data/record-data`.
- [@ember-data/serializer](/ember-data/release/modules/@ember-data%2Fserializer) pairs with `@ember-data/adapter` to normalize and serialize data to and from an API format into the `JSON:API` format understood by `@ember-data/json-api`.
- [@ember-data/debug](/ember-data/release/modules/@ember-data%2Fdebug) provides debugging support for the `ember-inspector`.
- **ember-data** is a "meta" package which bundles all of these together for convenience

Expand Down
2 changes: 1 addition & 1 deletion packages/-ember-data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = Object.assign({}, addonBaseConfig, {
return [
'ember',
'@ember/application/namespace',
'@ember-data/record-data/-private',
'@ember-data/json-api/-private',
'ember-data/version',
'@ember-data/store/-private',
'@ember-data/store',
Expand Down
6 changes: 3 additions & 3 deletions packages/-ember-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@ember-data/debug": "workspace:4.10.0-alpha.4",
"@ember-data/model": "workspace:4.10.0-alpha.4",
"@ember-data/private-build-infra": "workspace:4.10.0-alpha.4",
"@ember-data/record-data": "workspace:4.10.0-alpha.4",
"@ember-data/json-api": "workspace:4.10.0-alpha.4",
"@ember-data/serializer": "workspace:4.10.0-alpha.4",
"@ember-data/store": "workspace:4.10.0-alpha.4",
"@ember-data/tracking": "workspace:4.10.0-alpha.4",
Expand All @@ -44,7 +44,7 @@
"@ember-data/model": {
"injected": true
},
"@ember-data/record-data": {
"@ember-data/json-api": {
"injected": true
},
"@ember-data/serializer": {
Expand Down Expand Up @@ -81,4 +81,4 @@
"extends": "../../package.json"
},
"packageManager": "[email protected]"
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# @ember-data/record-data
# @ember-data/json-api

Provides the default JSON:API Cache implementation for EmberData.

## Installation

```
ember install @ember-data/record-data
ember install @ember-data/json-api
```

## License
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@ember-data/record-data",
"name": "@ember-data/json-api",
"version": "4.10.0-alpha.4",
"description": "Provides the default resource cache (RecordData) implementation for ember-data",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export { graphFor, peekGraph } from './-private/graph/index';
and providing a class that conforms to the current record-data
interface specification.

@module @ember-data/record-data
@main @ember-data/record-data
@module @ember-data/json-api
@main @ember-data/json-api
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module @ember-data/record-data
* @module @ember-data/json-api
*/
import { assert } from '@ember/debug';
import { schedule } from '@ember/runloop';
Expand Down
4 changes: 2 additions & 2 deletions packages/model/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
"addon"
],
"peerDependencies": {
"@ember-data/record-data": "workspace:4.10.0-alpha.4",
"@ember-data/json-api": "workspace:4.10.0-alpha.4",
"@ember-data/store": "workspace:4.10.0-alpha.4",
"@ember-data/tracking": "workspace:4.10.0-alpha.4",
"@ember/string": "^3.0.0",
"ember-inflector": "^4.0.2"
},
"peerDependenciesMeta": {
"@ember-data/record-data": {
"@ember-data/json-api": {
"optional": true
}
},
Expand Down
52 changes: 23 additions & 29 deletions packages/model/src/-private/legacy-relationships-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { DEBUG } from '@glimmer/env';
import { importSync } from '@embroider/macros';
import { all, resolve } from 'rsvp';

import type { UpgradedMeta } from '@ember-data/json-api/-private/graph/-edge-definition';
import type { LocalRelationshipOperation } from '@ember-data/json-api/-private/graph/-operations';
import type { ImplicitRelationship } from '@ember-data/json-api/-private/graph/index';
import type BelongsToRelationship from '@ember-data/json-api/-private/relationships/state/belongs-to';
import type ManyRelationship from '@ember-data/json-api/-private/relationships/state/has-many';
import { HAS_RECORD_DATA_PACKAGE } from '@ember-data/private-build-infra';
import { DEPRECATE_PROMISE_PROXIES } from '@ember-data/private-build-infra/deprecations';
import type { UpgradedMeta } from '@ember-data/record-data/-private/graph/-edge-definition';
import type { LocalRelationshipOperation } from '@ember-data/record-data/-private/graph/-operations';
import type { ImplicitRelationship } from '@ember-data/record-data/-private/graph/index';
import type BelongsToRelationship from '@ember-data/record-data/-private/relationships/state/belongs-to';
import type ManyRelationship from '@ember-data/record-data/-private/relationships/state/has-many';
import type Store from '@ember-data/store';
import { fastPush, isStableIdentifier, recordIdentifierFor, SOURCE, storeFor } from '@ember-data/store/-private';
import type { NonSingletonRecordDataManager } from '@ember-data/store/-private/managers/record-data-manager';
Expand Down Expand Up @@ -107,9 +107,8 @@ export class LegacySupport {
return loadingPromise;
}

const graphFor = (
importSync('@ember-data/record-data/-private') as typeof import('@ember-data/record-data/-private')
).graphFor;
const graphFor = (importSync('@ember-data/json-api/-private') as typeof import('@ember-data/json-api/-private'))
.graphFor;
const relationship = graphFor(this.store).get(this.identifier, key);
assert(`Expected ${key} to be a belongs-to relationship`, isBelongsTo(relationship));

Expand All @@ -130,9 +129,8 @@ export class LegacySupport {
assert(`Expected a stable identifier`, !relatedIdentifier || isStableIdentifier(relatedIdentifier));

const store = this.store;
const graphFor = (
importSync('@ember-data/record-data/-private') as typeof import('@ember-data/record-data/-private')
).graphFor;
const graphFor = (importSync('@ember-data/json-api/-private') as typeof import('@ember-data/json-api/-private'))
.graphFor;
const relationship = graphFor(store).get(this.identifier, key);
assert(`Expected ${key} to be a belongs-to relationship`, isBelongsTo(relationship));

Expand Down Expand Up @@ -214,9 +212,8 @@ export class LegacySupport {
if (HAS_RECORD_DATA_PACKAGE) {
let manyArray: RelatedCollection | undefined = this._manyArrayCache[key];
if (!definition) {
const graphFor = (
importSync('@ember-data/record-data/-private') as typeof import('@ember-data/record-data/-private')
).graphFor;
const graphFor = (importSync('@ember-data/json-api/-private') as typeof import('@ember-data/json-api/-private'))
.graphFor;
definition = graphFor(this.store).get(this.identifier, key).definition;
}

Expand Down Expand Up @@ -244,7 +241,7 @@ export class LegacySupport {

return manyArray;
}
assert('hasMany only works with the @ember-data/record-data package');
assert('hasMany only works with the @ember-data/json-api package');
}

fetchAsyncHasMany(
Expand Down Expand Up @@ -274,7 +271,7 @@ export class LegacySupport {
this._relationshipPromisesCache[key] = loadingPromise;
return loadingPromise;
}
assert('hasMany only works with the @ember-data/record-data package');
assert('hasMany only works with the @ember-data/json-api package');
}

reloadHasMany(key: string, options?: FindOptions) {
Expand All @@ -283,9 +280,8 @@ export class LegacySupport {
if (loadingPromise) {
return loadingPromise;
}
const graphFor = (
importSync('@ember-data/record-data/-private') as typeof import('@ember-data/record-data/-private')
).graphFor;
const graphFor = (importSync('@ember-data/json-api/-private') as typeof import('@ember-data/json-api/-private'))
.graphFor;
const relationship = graphFor(this.store).get(this.identifier, key) as ManyRelationship;
const { definition, state } = relationship;

Expand All @@ -300,14 +296,13 @@ export class LegacySupport {

return promise;
}
assert(`hasMany only works with the @ember-data/record-data package`);
assert(`hasMany only works with the @ember-data/json-api package`);
}

getHasMany(key: string, options?: FindOptions): PromiseManyArray | RelatedCollection {
if (HAS_RECORD_DATA_PACKAGE) {
const graphFor = (
importSync('@ember-data/record-data/-private') as typeof import('@ember-data/record-data/-private')
).graphFor;
const graphFor = (importSync('@ember-data/json-api/-private') as typeof import('@ember-data/json-api/-private'))
.graphFor;
const relationship = graphFor(this.store).get(this.identifier, key) as ManyRelationship;
const { definition, state } = relationship;
let manyArray = this.getManyArray(key, definition);
Expand All @@ -331,7 +326,7 @@ export class LegacySupport {
return manyArray;
}
}
assert(`hasMany only works with the @ember-data/record-data package`);
assert(`hasMany only works with the @ember-data/json-api package`);
}

_updatePromiseProxyFor(kind: 'hasMany', key: string, args: HasManyProxyCreateArgs): PromiseManyArray;
Expand Down Expand Up @@ -381,11 +376,10 @@ export class LegacySupport {
// TODO @runspired while this feels odd, it is not a regression in capability because we do
// not today support references pulling from RecordDatas other than our own
// because of the intimate API access involved. This is something we will need to redesign.
assert(`snapshot.belongsTo only supported for @ember-data/record-data`);
assert(`snapshot.belongsTo only supported for @ember-data/json-api`);
}
const graphFor = (
importSync('@ember-data/record-data/-private') as typeof import('@ember-data/record-data/-private')
).graphFor;
const graphFor = (importSync('@ember-data/json-api/-private') as typeof import('@ember-data/json-api/-private'))
.graphFor;
const graph = graphFor(this.store);
const relationship = graph.get(this.identifier, name);

Expand Down Expand Up @@ -519,7 +513,7 @@ export class LegacySupport {
// TODO if the relationshipIsStale, should we hit the adapter anyway?
return;
}
assert(`hasMany only works with the @ember-data/record-data package`);
assert(`hasMany only works with the @ember-data/json-api package`);
}

_findBelongsToByJsonApiResource(
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 @@ -6,9 +6,9 @@ import { cached, tracked } from '@glimmer/tracking';
import type { Object as JSONObject, Value as JSONValue } from 'json-typescript';
import { resolve } from 'rsvp';

import type { Graph } from '@ember-data/json-api/-private/graph/graph';
import type BelongsToRelationship from '@ember-data/json-api/-private/relationships/state/belongs-to';
import { DEPRECATE_PROMISE_PROXIES } from '@ember-data/private-build-infra/deprecations';
import type { Graph } from '@ember-data/record-data/-private/graph/graph';
import type BelongsToRelationship from '@ember-data/record-data/-private/relationships/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/record-notification-manager';
Expand Down
Loading