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

Love of Mine #8084

Merged
merged 29 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ecaa1ca
ill follow you into the dark
runspired Jul 27, 2022
3e8cc10
more sanity
runspired Jul 27, 2022
1be582e
fix imports
runspired Jul 28, 2022
506000a
get tests passing
runspired Jul 28, 2022
ee62785
replace usage of internalModel.isHiddenFromRecordArrays
runspired Jul 28, 2022
1b8c5dc
begin move of deleteRecord logic into the store
runspired Jul 31, 2022
abe6088
trim trim trim
runspired Aug 1, 2022
1949405
even more trim
runspired Aug 1, 2022
b728340
still a lot to do, but starting to take shape
runspired Aug 5, 2022
c3f3068
the shape of things
runspired Aug 5, 2022
e99428a
fix most tests, 44 to go
runspired Aug 5, 2022
04edfe9
71 test failures to go, implemente PromiseManyArray deprecation from …
runspired Aug 5, 2022
b12c830
add better debugging capabilities
runspired Aug 6, 2022
fe5af9c
cleanup
runspired Aug 6, 2022
4368276
further rationalization
runspired Aug 6, 2022
551e9fc
logging improvements
runspired Aug 6, 2022
41e3172
progress
runspired Aug 6, 2022
8ba573d
down to 36 failed tests
runspired Aug 7, 2022
fcd7a89
down to 17 failed tests
runspired Aug 7, 2022
1a983b5
cleanup
runspired Aug 8, 2022
6383273
All the cleanup
runspired Aug 8, 2022
d0532a3
fix lint
runspired Aug 8, 2022
bd332ae
all the main tests fixed
runspired Aug 9, 2022
25a8d05
bump some deps
runspired Aug 9, 2022
980fb72
make nice for deprecation stripping
runspired Aug 9, 2022
81a74b2
some minor cleanup
runspired Aug 9, 2022
8c06bce
fix some scenarios
runspired Aug 9, 2022
51603ba
fix lock
runspired Aug 9, 2022
8910696
fix node14
runspired Aug 9, 2022
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
33 changes: 14 additions & 19 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,26 +194,21 @@ module.exports = {
'ember-data-types/q/fetch-manager.ts',
'ember-data-types/q/ember-data-json-api.ts',
'ember-data-types/q/ds-model.ts',
'packages/store/addon/-private/record-data-store-wrapper.ts',
'packages/store/addon/-private/internal-model-factory.ts',
'packages/store/addon/-private/snapshot.ts',
'packages/store/addon/-private/snapshot-record-array.ts',
'packages/store/addon/-private/schema-definition-service.ts',
'packages/store/addon/-private/request-cache.ts',
'packages/store/addon/-private/references/reference.ts',
'packages/store/addon/-private/references/record.ts',
'packages/store/addon/-private/record-notification-manager.ts',
'packages/store/addon/-private/record-data-for.ts',
'packages/store/addon/-private/normalize-model-name.ts',
'packages/store/addon/-private/model/shim-model-class.ts',
'packages/store/addon/-private/model/internal-model.ts',
'packages/store/addon/-private/internal-model-map.ts',
'packages/store/addon/-private/identity-map.ts',
'packages/store/addon/-private/fetch-manager.ts',
'packages/store/addon/-private/core-store.ts',
'packages/store/addon/-private/coerce-id.ts',
'packages/store/addon/-private/managers/record-data-store-wrapper.ts',
'packages/store/addon/-private/network/snapshot.ts',
'packages/store/addon/-private/network/snapshot-record-array.ts',
'packages/store/addon/-private/legacy-model-support/schema-definition-service.ts',
'packages/store/addon/-private/network/request-cache.ts',
'packages/store/addon/-private/legacy-model-support/record-reference.ts',
'packages/store/addon/-private/managers/record-notification-manager.ts',
'packages/store/addon/-private/caches/record-data-for.ts',
'packages/store/addon/-private/utils/normalize-model-name.ts',
'packages/store/addon/-private/legacy-model-support/shim-model-class.ts',
'packages/store/addon/-private/network/fetch-manager.ts',
'packages/store/addon/-private/store-service.ts',
'packages/store/addon/-private/utils/coerce-id.ts',
'packages/store/addon/-private/index.ts',
'packages/store/addon/-private/identifier-cache.ts',
'packages/store/addon/-private/caches/identifier-cache.ts',
'packages/serializer/tests/dummy/app/routes/application/route.ts',
'packages/serializer/tests/dummy/app/router.ts',
'packages/serializer/tests/dummy/app/resolver.ts',
Expand Down
30 changes: 15 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2445,10 +2445,10 @@ it should be pretty straight forward to update current code to the public
Snapshot API:

```js
post.get('id') => postSnapshot.id
post.get('title') => postSnapshot.attr('title')
post.get('author') => postSnapshot.belongsTo('author')
post.get('comments') => postSnapshot.hasMany('comments')
post.id => postSnapshot.id
post.title => postSnapshot.attr('title')
post.author => postSnapshot.belongsTo('author')
post.comments => postSnapshot.hasMany('comments')
post.constructor => postSnapshot.type;
post.constructor.typeKey => postSnapshot.typeKey
```
Expand Down Expand Up @@ -2525,7 +2525,7 @@ To access attributes you should now use the `attr` function.

```js
// Ember Data 1.0.0-beta.14.1
post.get('title');
post.title;
// Ember Data 1.0.0-beta.15
postSnapshot.attr('title');
```
Expand All @@ -2534,7 +2534,7 @@ To access a belongsTo relationship you should use `.belongsTo()` method.

```js
// Ember Data 1.0.0-beta.14.1
post.get('author');
post.author;
// Ember Data 1.0.0-beta.15
postSnapshot.belongsTo('author');
```
Expand All @@ -2543,7 +2543,7 @@ To access a hasMany relationship you should use `.hasMany()` method.

```js
// Ember Data 1.0.0-beta.14.1
post.get('comments');
post.comments;
// Ember Data 1.0.0-beta.15
postSnapshot.hasMany('comments');
```
Expand Down Expand Up @@ -2619,13 +2619,13 @@ var post = store.push('post', {
author: 'Tomster',
});

post.get('title'); // => 'Ember.js is fantastic'
post.get('author'); // => 'Tomster'
post.title; // => 'Ember.js is fantastic'
post.author; // => 'Tomster'

store.push('post', { id: 1, author: 'Tom Dale' });

post.get('title'); // => 'Ember.js is fantastic'
post.get('author'); // => 'Tom Dale'
post.title; // => 'Ember.js is fantastic'
post.author; // => 'Tom Dale'
```

This also mean that properties missing in the payload will no longer be reset,
Expand Down Expand Up @@ -2698,10 +2698,10 @@ underlying array you will now need to use the `.toArray()` method.

```javascript
// Ember Data 1.0.0-beta.12
record.get('myHasManyRelationship').get('content').map(...);
record.myHasManyRelationship.content.map(...);

// Ember Data 1.0.0-beta.14
record.get('myHasManyRelationship').toArray().map(...);
record.myHasManyRelationship.toArray().map(...);
```

Additionally if you were using the `RecordArray`'s `.addRecord()` and
Expand Down Expand Up @@ -2736,7 +2736,7 @@ Additionally if you were using the `RecordArray`'s `.addRecord()` and
- [Feature thrownError] tag errorThrown from jQuery onto the jqXHR like ic-ajax does.
- Cache relationships meta in production
- Deprecate store.update()
- hasMany relationships are no longer `RecordArray`, but `ManyArray`. To access the underlying array use `relationship.toArray()` instead of `relationship.get('content')`.
- hasMany relationships are no longer `RecordArray`, but `ManyArray`. To access the underlying array use `relationship.toArray()` instead of `relationship.content`.

### Ember Data 1.0.0-beta.12 (November 25, 2014)

Expand Down Expand Up @@ -2765,7 +2765,7 @@ Ember Data's build. You should upgrade to Ember 1.8 as soon as you can.

##### Observing `data` For Changes Has Been Removed

Although `model.get('data')` has been private in Ember Data for a long time, we
Although `model.data` has been private in Ember Data for a long time, we
have noticed users may subscribe to changes on `data` for any change to the
model's attributes. This means that the following code:

Expand Down
2 changes: 0 additions & 2 deletions ember-data-types/q/ds-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type EmberObject from '@ember/object';

import type { Errors } from '@ember-data/model/-private';
import type Store from '@ember-data/store';
import type InternalModel from '@ember-data/store/-private/model/internal-model';

import type { JsonApiValidationError } from './record-data-json-api';
import type { AttributeSchema, RelationshipSchema, RelationshipsSchema } from './record-data-schemas';
Expand All @@ -12,7 +11,6 @@ export interface DSModel extends EmberObject {
constructor: DSModelSchema;
store: Store;
errors: Errors;
_internalModel: InternalModel;
toString(): string;
save(): Promise<DSModel>;
eachRelationship<T>(callback: (this: T, key: string, meta: RelationshipSchema) => void, binding?: T): void;
Expand Down
5 changes: 4 additions & 1 deletion ember-data-types/q/identifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
@module @ember-data/store
*/

import { DEBUG_CLIENT_ORIGINATED, DEBUG_IDENTIFIER_BUCKET } from '@ember-data/store/-private/identifer-debug-consts';
import {
DEBUG_CLIENT_ORIGINATED,
DEBUG_IDENTIFIER_BUCKET,
} from '@ember-data/store/-private/utils/identifer-debug-consts';

import type { ExistingResourceObject, ResourceIdentifierObject } from './ember-data-json-api';

Expand Down
4 changes: 2 additions & 2 deletions ember-data-types/q/minimum-adapter-interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type Store from '@ember-data/store';
import type Snapshot from '@ember-data/store/-private/network/snapshot';
import type SnapshotRecordArray from '@ember-data/store/-private/network/snapshot-record-array';
import type AdapterPopulatedRecordArray from '@ember-data/store/-private/record-arrays/adapter-populated-record-array';
import type Snapshot from '@ember-data/store/-private/snapshot';
import type SnapshotRecordArray from '@ember-data/store/-private/snapshot-record-array';

import type { ModelSchema } from './ds-model';
import type { RelationshipSchema } from './record-data-schemas';
Expand Down
2 changes: 1 addition & 1 deletion ember-data-types/q/minimum-serializer-interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Object as JSONObject } from 'json-typescript';

import type Store from '@ember-data/store';
import type Snapshot from '@ember-data/store/-private/snapshot';
import type Snapshot from '@ember-data/store/-private/network/snapshot';

import type { ModelSchema } from './ds-model';
import type { JsonApiDocument, SingleResourceDocument } from './ember-data-json-api';
Expand Down
12 changes: 5 additions & 7 deletions ember-data-types/q/record-data-record-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { JsonApiValidationError } from './record-data-json-api';
@module @ember-data/store
*/

export interface RecordDataRecordWrapper {
export interface RecordDataWrapper {
rollbackAttributes(): string[];
changedAttributes(): ChangedAttributesHash;
hasChangedAttributes(): boolean;
Expand All @@ -16,17 +16,15 @@ export interface RecordDataRecordWrapper {
getAttr(key: string): any;
getHasMany(key: string): CollectionResourceRelationship;

addToHasMany(key: string, recordDatas: RecordDataRecordWrapper[], idx?: number): void;
removeFromHasMany(key: string, recordDatas: RecordDataRecordWrapper[]): void;
setDirtyHasMany(key: string, recordDatas: RecordDataRecordWrapper[]): void;
addToHasMany(key: string, recordDatas: RecordDataWrapper[], idx?: number): void;
removeFromHasMany(key: string, recordDatas: RecordDataWrapper[]): void;
setDirtyHasMany(key: string, recordDatas: RecordDataWrapper[]): void;

getBelongsTo(key: string): SingleResourceRelationship;

setDirtyBelongsTo(name: string, recordData: RecordDataRecordWrapper | null): void;
setDirtyBelongsTo(name: string, recordData: RecordDataWrapper | null): void;

// ----- unspecced
isAttrDirty(key: string): boolean;
removeFromInverseRelationships(): void;
hasAttr(key: string): boolean;

// new
Expand Down
2 changes: 1 addition & 1 deletion ember-data-types/q/record-data-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface RelationshipSchema {
key: string; // TODO @runspired remove our uses
// TODO @runspired should RFC be updated to make this optional?
// TODO @runspired sohuld RFC be update to enforce async and inverse are set? else internals need to know
// that meta came from DS.Model vs not from DS.Model as defaults should switch.
// that meta came from @ember-data/model vs not from @ember-data/model as defaults should switch.
options: {
async?: boolean; // controls inverse unloading "client side delete semantics" so we should replace that with a real flag
polymorphic?: boolean;
Expand Down
2 changes: 0 additions & 2 deletions ember-data-types/q/record-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export interface RecordData {
didCommit(data: JsonApiResource | null): void;

// ----- unspecced
isAttrDirty(key: string): boolean;
removeFromInverseRelationships(): void;
hasAttr(key: string): boolean;

isRecordInUse(): boolean;
Expand Down
2 changes: 1 addition & 1 deletion ember-data-types/q/relationship-record-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface RelationshipRecordData extends RecordData {
storeWrapper: RecordDataStoreWrapper;
identifier: StableRecordIdentifier;
id: string | null;
clientId: string | null;
lid: string | null;
isEmpty(): boolean;
getResourceIdentifier(): RecordIdentifier;
getBelongsTo(key: string): DefaultSingleResourceRelationship;
Expand Down
2 changes: 0 additions & 2 deletions packages/-ember-data/addon/-private/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ export { default as DS } from './core';
export { Errors } from '@ember-data/model/-private';
export { Snapshot } from '@ember-data/store/-private';

// `ember-data-model-fragments` relies on `InternalModel`
// `ember-data-model-fragments' and `ember-data-change-tracker` rely on `normalizeModelName`
export {
AdapterPopulatedRecordArray,
InternalModel,
PromiseArray,
PromiseObject,
RecordArray,
Expand Down
2 changes: 0 additions & 2 deletions packages/-ember-data/addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
AdapterPopulatedRecordArray,
DS,
Errors,
InternalModel,
ManyArray,
PromiseArray,
PromiseManyArray,
Expand All @@ -52,7 +51,6 @@ DS.Model = Model;
DS.attr = attr;
DS.Errors = Errors;

DS.InternalModel = InternalModel;
DS.Snapshot = Snapshot;

DS.Adapter = Adapter;
Expand Down
4 changes: 2 additions & 2 deletions packages/-ember-data/config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function () {
},
npm: {
devDependencies: {
'ember-fetch': '*',
'ember-fetch': '^8.1.1',
'@ember/jquery': null,
},
},
Expand All @@ -23,7 +23,7 @@ module.exports = function () {
name: 'with-ember-fetch-and-jquery',
npm: {
devDependencies: {
'ember-fetch': '*',
'ember-fetch': '^8.1.1',
'@ember/jquery': '^2.0.0',
},
},
Expand Down
16 changes: 12 additions & 4 deletions packages/-ember-data/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ module.exports = function (defaults) {
terserSettings.enabled = false;
}

let app = new EmberAddon(defaults, {
emberData: {
compatWith,
let config = {
compatWith,
debug: {
LOG_NOTIFICATIONS: process.env.DEBUG_DATA ? true : false,
LOG_REQUEST_STATUS: process.env.DEBUG_DATA ? true : false,
LOG_IDENTIFIERS: process.env.DEBUG_DATA ? true : false,
LOG_GRAPH: process.env.DEBUG_DATA ? true : false,
LOG_INSTANCE_CACHE: process.env.DEBUG_DATA ? true : false,
},
};
let app = new EmberAddon(defaults, {
emberData: config,
babel: {
// this ensures that the same build-time code stripping that is done
// for library packages is also done for our tests and dummy app
plugins: [...require('@ember-data/private-build-infra/src/debug-macros')(null, isProd, compatWith)],
plugins: [...require('@ember-data/private-build-infra/src/debug-macros')(null, isProd, config)],
},
'ember-cli-babel': {
throwUnlessParallelizable: true,
Expand Down
4 changes: 0 additions & 4 deletions packages/-ember-data/node-tests/fixtures/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ module.exports = {
'(private) @ember-data/debug InspectorDataAdapter#watchTypeIfUnseen',
'(private) @ember-data/model Model#_createSnapshot',
'(private) @ember-data/model Model#_debugInfo',
'(private) @ember-data/model Model#_internalModel',
'(private) @ember-data/model Model#_notifyProperties',
'(private) @ember-data/model Model#create',
'(private) @ember-data/model Model#currentState',
Expand Down Expand Up @@ -74,8 +73,6 @@ module.exports = {
'(private) @ember-data/store IdentifierCache#_getRecordIdentifier',
'(private) @ember-data/store IdentifierCache#_mergeRecordIdentifiers',
'(private) @ember-data/store IdentifierCache#peekRecordIdentifier',
'(private) @ember-data/store InternalModelFactory#lookup',
'(private) @ember-data/store InternalModelFactory#peek',
'(private) @ember-data/store ManyArray#isPolymorphic',
'(private) @ember-data/store ManyArray#relationship',
'(private) @ember-data/store RecordArray#_createSnapshot',
Expand All @@ -90,7 +87,6 @@ module.exports = {
'(private) @ember-data/store Store#_push',
'(private) @ember-data/store Store#find',
'(private) @ember-data/store Store#init',
'(private) @ember-data/store Store#recordWasInvalid',
'(public) @ember-data/adapter Adapter#coalesceFindRequests',
'(public) @ember-data/adapter Adapter#createRecord',
'(public) @ember-data/adapter Adapter#deleteRecord',
Expand Down
Loading