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]: Extract internalModel access to identifiers for Relationships #7262

Merged
merged 20 commits into from
Oct 30, 2020

Conversation

snewcomer
Copy link
Contributor

ref #6166
past work #6715

@snewcomer snewcomer self-assigned this Aug 2, 2020
@@ -1580,7 +1580,7 @@ abstract class CoreStore extends Service {
typeof modelName === 'string'
);

const resource = constructResource(modelName, ensureStringId(id));
const resource: ResourceIdentifierObject = constructResource(modelName, ensureStringId(id));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we like to type the return value? If no value, I can remove

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not super clear, it's 👍

} else {
this.parent = parentIMOrIdentifier.recordReference;
this.parentInternalModel = parentIMOrIdentifier;
}
Copy link
Contributor Author

@snewcomer snewcomer Aug 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the goal is to remove references to the internal model property as well, I can make this this.parentIdentifier and lookup by identifier in each corresponding spot that needs an internal model. Let me know what you think!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a path of fully getting away from internal model, we probably want to bundle this up together, landing just the lookup part might be bad for perf in hot paths

@@ -31,6 +34,10 @@ function isResourceIdentiferWithRelatedLinks(

export const INTERNAL_MODELS = new WeakMap<Reference, InternalModel>();
Copy link
Contributor Author

@snewcomer snewcomer Aug 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort of along the same lines as the other question - The API changed for creating References from InternalModel to identifiers. However, do we want to also change our caching layer as well with this refactor? Or does this seem right to keep as is (various places in belongs-to/has-many reference IM specific properties)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing the caching layer is 👍

@github-actions
Copy link

github-actions bot commented Aug 2, 2020

Asset Size Report for 84ea514

IE11 Builds

The size of the library EmberData has increased by 132.0 B (94.0 B compressed) which exceeds the failure threshold of 75 bytes.

Warnings

The uncompressed size of the package @ember-data/store has increased by 132.0 B.

Changeset


EmberData 161.26 KB +132.0 B (34.74 KB +94.0 B compressed)
    @ember-data/store 69.86 KB +132.0 B (15.05 KB +94.0 B compressed)
        @ember-data/store/-private 68.95 KB +132.0 B (14.85 KB +94.0 B compressed)

Full Asset Analysis (IE11)

Asset Size Report
=================


Library: EmberData
┌────────────┬─────────────┐
│  (index)   │   Values    │
├────────────┼─────────────┤
│   bytes    │ '161.26 KB' │
│ compressed │ '34.74 KB'  │
│  packages  │      9      │
│  modules   │     46      │
└────────────┴─────────────┘

Package: @ember-data/store
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '69.86 KB' │
│  compressed  │ '15.05 KB' │
│ % Of Library │   '43.3'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/store/-private                        | 68.95 KB  | 14.85 KB   | 98.7          | 42.8
	@ember-data/store/index                           | 936.00 B  | 201.64 B   | 1.3           | 0.6

Package: @ember-data/record-data
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '22.62 KB' │
│  compressed  │ '4.87 KB'  │
│ % Of Library │   '14.0'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/record-data/-private                  | 22.62 KB  | 4.87 KB    | 100.0         | 14.0

Package: @ember-data/serializer
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '19.33 KB' │
│  compressed  │ '4.16 KB'  │
│ % Of Library │   '12.0'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/serializer/json                       | 7.10 KB   | 1.53 KB    | 36.7          | 4.4
	@ember-data/serializer/-private                   | 5.37 KB   | 1.16 KB    | 27.8          | 3.3
	@ember-data/serializer/json-api                   | 3.71 KB   | 818.64 B   | 19.2          | 2.3
	@ember-data/serializer/rest                       | 2.71 KB   | 596.96 B   | 14.0          | 1.7
	@ember-data/serializer/index                      | 243.00 B  | 52.35 B    | 1.2           | 0.1
	@ember-data/serializer/transform                  | 215.00 B  | 46.31 B    | 1.1           | 0.1

Package: @ember-data/adapter
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '14.97 KB' │
│  compressed  │ '3.22 KB'  │
│ % Of Library │   '9.3'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/adapter/rest                          | 8.01 KB   | 1.73 KB    | 53.5          | 5.0
	@ember-data/adapter/-private                      | 3.54 KB   | 782.01 B   | 23.7          | 2.2
	@ember-data/adapter/error                         | 1.91 KB   | 422.03 B   | 12.8          | 1.2
	@ember-data/adapter/json-api                      | 897.00 B  | 193.24 B   | 5.9           | 0.5
	@ember-data/adapter/index                         | 635.00 B  | 136.79 B   | 4.1           | 0.4

Package: @ember-data/model
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '13.55 KB' │
│  compressed  │ '2.92 KB'  │
│ % Of Library │   '8.4'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/model/-private                        | 13.07 KB  | 2.82 KB    | 96.5          | 8.1
	@ember-data/model/index                           | 486.00 B  | 104.70 B   | 3.5           | 0.3

Package: ember-data
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '9.28 KB' │
│  compressed  │ '2.00 KB' │
│ % Of Library │   '5.8'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-data/index                                  | 2.32 KB   | 512.51 B   | 25.0          | 1.4
	ember-data/-private                               | 2.02 KB   | 446.59 B   | 21.8          | 1.3
	ember-data/adapters/errors                        | 1.19 KB   | 262.18 B   | 12.8          | 0.7
	ember-data/setup-container                        | 503.00 B  | 108.36 B   | 5.3           | 0.3
	ember-data/relationships                          | 318.00 B  | 68.50 B    | 3.3           | 0.2
	ember-data/serializers/embedded-records-mixin     | 274.00 B  | 59.02 B    | 2.9           | 0.2
	ember-data/serializers/json-api                   | 251.00 B  | 54.07 B    | 2.6           | 0.2
	ember-data/adapters/json-api                      | 245.00 B  | 52.78 B    | 2.6           | 0.1
	ember-data/serializers/json                       | 243.00 B  | 52.35 B    | 2.6           | 0.1
	ember-data/serializers/rest                       | 243.00 B  | 52.35 B    | 2.6           | 0.1
	ember-data/transform                              | 241.00 B  | 51.91 B    | 2.5           | 0.1
	ember-data/adapters/rest                          | 237.00 B  | 51.05 B    | 2.5           | 0.1
	ember-data/serializer                             | 232.00 B  | 49.98 B    | 2.4           | 0.1
	ember-data/adapter                                | 226.00 B  | 48.68 B    | 2.4           | 0.1
	ember-data/model                                  | 222.00 B  | 47.82 B    | 2.3           | 0.1
	ember-data/store                                  | 222.00 B  | 47.82 B    | 2.3           | 0.1
	ember-data/attr                                   | 218.00 B  | 46.96 B    | 2.3           | 0.1
	ember-data/version                                | 162.00 B  | 34.90 B    | 1.7           | 0.1

Package: ember-inflector
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '7.91 KB' │
│  compressed  │ '1.70 KB' │
│ % Of Library │   '4.9'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-inflector/lib/system/inflector              | 2.76 KB   | 609.02 B   | 34.9          | 1.7
	ember-inflector/lib/system/inflections            | 1.57 KB   | 346.84 B   | 19.9          | 1.0
	ember-inflector/index                             | 1.12 KB   | 247.31 B   | 14.2          | 0.7
	ember-inflector/lib/ext/string                    | 783.00 B  | 168.68 B   | 9.7           | 0.5
	ember-inflector/lib/system                        | 452.00 B  | 97.37 B    | 5.6           | 0.3
	ember-inflector/lib/system/string                 | 351.00 B  | 75.61 B    | 4.3           | 0.2
	ember-inflector/lib/helpers/pluralize             | 348.00 B  | 74.97 B    | 4.3           | 0.2
	ember-inflector/lib/utils/make-helper             | 308.00 B  | 66.35 B    | 3.8           | 0.2
	ember-inflector/lib/helpers/singularize           | 271.00 B  | 58.38 B    | 3.3           | 0.2

Package: @ember-data/debug
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '2.68 KB'  │
│  compressed  │ '591.79 B' │
│ % Of Library │   '1.7'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/debug/index                           | 2.20 KB   | 484.28 B   | 81.8          | 1.4
	@ember-data/debug/setup                           | 499.00 B  | 107.50 B   | 18.2          | 0.3

Package: @ember/ordered-set
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '1.05 KB'  │
│  compressed  │ '232.23 B' │
│ % Of Library │   '0.7'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember/ordered-set/index                          | 1.05 KB   | 232.23 B   | 100.0         | 0.7

Modern Builds

The size of the library EmberData has increased by 132.0 B (94.0 B compressed) which exceeds the failure threshold of 75 bytes.

Warnings

The uncompressed size of the package @ember-data/store has increased by 132.0 B.

Changeset


EmberData 161.26 KB +132.0 B (34.74 KB +94.0 B compressed)
    @ember-data/store 69.86 KB +132.0 B (15.05 KB +94.0 B compressed)
        @ember-data/store/-private 68.95 KB +132.0 B (14.85 KB +94.0 B compressed)

Full Asset Analysis (Modern)

Asset Size Report
=================


Library: EmberData
┌────────────┬─────────────┐
│  (index)   │   Values    │
├────────────┼─────────────┤
│   bytes    │ '161.26 KB' │
│ compressed │ '34.74 KB'  │
│  packages  │      9      │
│  modules   │     46      │
└────────────┴─────────────┘

Package: @ember-data/store
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '69.86 KB' │
│  compressed  │ '15.05 KB' │
│ % Of Library │   '43.3'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/store/-private                        | 68.95 KB  | 14.85 KB   | 98.7          | 42.8
	@ember-data/store/index                           | 936.00 B  | 201.64 B   | 1.3           | 0.6

Package: @ember-data/record-data
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '22.62 KB' │
│  compressed  │ '4.87 KB'  │
│ % Of Library │   '14.0'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/record-data/-private                  | 22.62 KB  | 4.87 KB    | 100.0         | 14.0

Package: @ember-data/serializer
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '19.33 KB' │
│  compressed  │ '4.16 KB'  │
│ % Of Library │   '12.0'   │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/serializer/json                       | 7.10 KB   | 1.53 KB    | 36.7          | 4.4
	@ember-data/serializer/-private                   | 5.37 KB   | 1.16 KB    | 27.8          | 3.3
	@ember-data/serializer/json-api                   | 3.71 KB   | 818.64 B   | 19.2          | 2.3
	@ember-data/serializer/rest                       | 2.71 KB   | 596.96 B   | 14.0          | 1.7
	@ember-data/serializer/index                      | 243.00 B  | 52.35 B    | 1.2           | 0.1
	@ember-data/serializer/transform                  | 215.00 B  | 46.31 B    | 1.1           | 0.1

Package: @ember-data/adapter
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '14.97 KB' │
│  compressed  │ '3.22 KB'  │
│ % Of Library │   '9.3'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/adapter/rest                          | 8.01 KB   | 1.73 KB    | 53.5          | 5.0
	@ember-data/adapter/-private                      | 3.54 KB   | 782.01 B   | 23.7          | 2.2
	@ember-data/adapter/error                         | 1.91 KB   | 422.03 B   | 12.8          | 1.2
	@ember-data/adapter/json-api                      | 897.00 B  | 193.24 B   | 5.9           | 0.5
	@ember-data/adapter/index                         | 635.00 B  | 136.79 B   | 4.1           | 0.4

Package: @ember-data/model
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '13.55 KB' │
│  compressed  │ '2.92 KB'  │
│ % Of Library │   '8.4'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/model/-private                        | 13.07 KB  | 2.82 KB    | 96.5          | 8.1
	@ember-data/model/index                           | 486.00 B  | 104.70 B   | 3.5           | 0.3

Package: ember-data
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '9.28 KB' │
│  compressed  │ '2.00 KB' │
│ % Of Library │   '5.8'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-data/index                                  | 2.32 KB   | 512.51 B   | 25.0          | 1.4
	ember-data/-private                               | 2.02 KB   | 446.59 B   | 21.8          | 1.3
	ember-data/adapters/errors                        | 1.19 KB   | 262.18 B   | 12.8          | 0.7
	ember-data/setup-container                        | 503.00 B  | 108.36 B   | 5.3           | 0.3
	ember-data/relationships                          | 318.00 B  | 68.50 B    | 3.3           | 0.2
	ember-data/serializers/embedded-records-mixin     | 274.00 B  | 59.02 B    | 2.9           | 0.2
	ember-data/serializers/json-api                   | 251.00 B  | 54.07 B    | 2.6           | 0.2
	ember-data/adapters/json-api                      | 245.00 B  | 52.78 B    | 2.6           | 0.1
	ember-data/serializers/json                       | 243.00 B  | 52.35 B    | 2.6           | 0.1
	ember-data/serializers/rest                       | 243.00 B  | 52.35 B    | 2.6           | 0.1
	ember-data/transform                              | 241.00 B  | 51.91 B    | 2.5           | 0.1
	ember-data/adapters/rest                          | 237.00 B  | 51.05 B    | 2.5           | 0.1
	ember-data/serializer                             | 232.00 B  | 49.98 B    | 2.4           | 0.1
	ember-data/adapter                                | 226.00 B  | 48.68 B    | 2.4           | 0.1
	ember-data/model                                  | 222.00 B  | 47.82 B    | 2.3           | 0.1
	ember-data/store                                  | 222.00 B  | 47.82 B    | 2.3           | 0.1
	ember-data/attr                                   | 218.00 B  | 46.96 B    | 2.3           | 0.1
	ember-data/version                                | 162.00 B  | 34.90 B    | 1.7           | 0.1

Package: ember-inflector
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '7.91 KB' │
│  compressed  │ '1.70 KB' │
│ % Of Library │   '4.9'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-inflector/lib/system/inflector              | 2.76 KB   | 609.02 B   | 34.9          | 1.7
	ember-inflector/lib/system/inflections            | 1.57 KB   | 346.84 B   | 19.9          | 1.0
	ember-inflector/index                             | 1.12 KB   | 247.31 B   | 14.2          | 0.7
	ember-inflector/lib/ext/string                    | 783.00 B  | 168.68 B   | 9.7           | 0.5
	ember-inflector/lib/system                        | 452.00 B  | 97.37 B    | 5.6           | 0.3
	ember-inflector/lib/system/string                 | 351.00 B  | 75.61 B    | 4.3           | 0.2
	ember-inflector/lib/helpers/pluralize             | 348.00 B  | 74.97 B    | 4.3           | 0.2
	ember-inflector/lib/utils/make-helper             | 308.00 B  | 66.35 B    | 3.8           | 0.2
	ember-inflector/lib/helpers/singularize           | 271.00 B  | 58.38 B    | 3.3           | 0.2

Package: @ember-data/debug
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '2.68 KB'  │
│  compressed  │ '591.79 B' │
│ % Of Library │   '1.7'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/debug/index                           | 2.20 KB   | 484.28 B   | 81.8          | 1.4
	@ember-data/debug/setup                           | 499.00 B  | 107.50 B   | 18.2          | 0.3

Package: @ember/ordered-set
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '1.05 KB'  │
│  compressed  │ '232.23 B' │
│ % Of Library │   '0.7'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember/ordered-set/index                          | 1.05 KB   | 232.23 B   | 100.0         | 0.7

Modern Builds (No Rollup)

The size of the library EmberData has increased by 509.0 B (132.0 B compressed) which exceeds the failure threshold of 75 bytes.

Warnings

The uncompressed size of the package @ember-data/store has increased by 509.0 B.

Changeset


EmberData 205.88 KB +509.0 B (39.26 KB +132.0 B compressed)
    @ember-data/store 102.46 KB +509.0 B (19.54 KB +132.0 B compressed)
        @ember-data/store/-private/system/core-store 17.51 KB +150.0 B (3.34 KB +38.9 B compressed)
        @ember-data/store/-private/system/model/internal-model 16.98 KB +25.0 B (3.24 KB +6.48 B compressed)
        @ember-data/store/-private/system/references/has-many 1.5 KB +35.0 B (292.55 B +9.08 B compressed)
        @ember-data/store/-private/system/references/belongs-to 1.23 KB +38.0 B (240.67 B +9.85 B compressed)
        @ember-data/store/-private/system/references/record 966.0 B +48.0 B (184.22 B +12.45 B compressed)
        @ember-data/store/-private/system/references/reference 942.0 B +213.0 B (179.65 B +55.24 B compressed)

Full Asset Analysis (Modern)

Asset Size Report
=================


Library: EmberData
┌────────────┬─────────────┐
│  (index)   │   Values    │
├────────────┼─────────────┤
│   bytes    │ '205.88 KB' │
│ compressed │ '39.26 KB'  │
│  packages  │      9      │
│  modules   │     144     │
└────────────┴─────────────┘

Package: @ember-data/store
┌──────────────┬─────────────┐
│   (index)    │   Values    │
├──────────────┼─────────────┤
│    bytes     │ '102.46 KB' │
│  compressed  │ '19.54 KB'  │
│ % Of Library │   '49.8'    │
└──────────────┴─────────────┘
	Module                                                                             | Bytes     | Compressed | % of Package  | % Of Library
	--------------------------------------------------------------------------------------------------------------------------------------
	@ember-data/store/-private/system/core-store                                       | 17.51 KB  | 3.34 KB    | 17.1          | 8.5
	@ember-data/store/-private/system/model/internal-model                             | 16.98 KB  | 3.24 KB    | 16.6          | 8.2
	@ember-data/store/-private/system/model/states                                     | 5.44 KB   | 1.04 KB    | 5.3           | 2.6
	@ember-data/store/-private/system/fetch-manager                                    | 4.93 KB   | 961.94 B   | 4.8           | 2.4
	@ember-data/store/-private/system/record-array-manager                             | 4.53 KB   | 883.94 B   | 4.4           | 2.2
	@ember-data/store/-private/index                                                   | 4.44 KB   | 866.21 B   | 4.3           | 2.2
	@ember-data/store/-private/system/store/finders                                    | 4.33 KB   | 845.61 B   | 4.2           | 2.1
	@ember-data/store/-private/identifiers/cache                                       | 3.74 KB   | 730.61 B   | 3.7           | 1.8
	@ember-data/store/-private/system/store/record-data-store-wrapper                  | 3.42 KB   | 666.91 B   | 3.3           | 1.7
	@ember-data/store/-private/system/store/internal-model-factory                     | 2.91 KB   | 568.12 B   | 2.8           | 1.4
	@ember-data/store/-private/system/snapshot                                         | 2.85 KB   | 555.92 B   | 2.8           | 1.4
	@ember-data/store/-private/system/record-arrays/record-array                       | 2.25 KB   | 440.35 B   | 2.2           | 1.1
	@ember-data/store/-private/system/ds-model-store                                   | 1.99 KB   | 387.90 B   | 1.9           | 1.0
	@ember-data/store/-private/system/request-cache                                    | 1.87 KB   | 365.59 B   | 1.8           | 0.9
	@ember-data/store/-private/system/references/has-many                              | 1.50 KB   | 292.55 B   | 1.5           | 0.7
	@ember-data/store/-private/system/schema-definition-service                        | 1.47 KB   | 287.02 B   | 1.4           | 0.7
	@ember-data/store/-private/system/relationship-meta                                | 1.45 KB   | 282.63 B   | 1.4           | 0.7
	@ember-data/store/-private/system/model/shim-model-class                           | 1.26 KB   | 246.01 B   | 1.2           | 0.6
	@ember-data/store/-private/system/references/belongs-to                            | 1.23 KB   | 240.67 B   | 1.2           | 0.6
	@ember-data/store/-private/system/store/serializer-response                        | 1.12 KB   | 219.50 B   | 1.1           | 0.5
	@ember-data/store/-private/identifiers/utils/uuid-v4                               | 1.05 KB   | 205.58 B   | 1.0           | 0.5
	@ember-data/store/-private/system/internal-model-map                               | 981.00 B  | 187.08 B   | 0.9           | 0.5
	@ember-data/store/-private/system/references/record                                | 966.00 B  | 184.22 B   | 0.9           | 0.5
	@ember-data/store/-private/system/references/reference                             | 942.00 B  | 179.65 B   | 0.9           | 0.4
	@ember-data/store/index                                                            | 936.00 B  | 178.50 B   | 0.9           | 0.4
	@ember-data/store/-private/system/record-arrays/adapter-populated-record-array     | 908.00 B  | 173.16 B   | 0.9           | 0.4
	@ember-data/store/-private/system/model/notify-changes                             | 862.00 B  | 164.39 B   | 0.8           | 0.4
	@ember-data/store/-private/system/errors-utils                                     | 759.00 B  | 144.74 B   | 0.7           | 0.4
	@ember-data/store/-private/system/snapshot-record-array                            | 753.00 B  | 143.60 B   | 0.7           | 0.4
	@ember-data/store/-private/system/record-notification-manager                      | 689.00 B  | 131.40 B   | 0.7           | 0.3
	@ember-data/store/-private/system/references                                       | 598.00 B  | 114.04 B   | 0.6           | 0.3
	@ember-data/store/-private/system/promise-proxies                                  | 556.00 B  | 106.03 B   | 0.5           | 0.3
	@ember-data/store/-private/utils/construct-resource                                | 506.00 B  | 96.49 B    | 0.5           | 0.2
	@ember-data/store/-private/system/store/common                                     | 499.00 B  | 95.16 B    | 0.5           | 0.2
	@ember-data/store/-private/system/coerce-id                                        | 494.00 B  | 94.21 B    | 0.5           | 0.2
	@ember-data/store/-private/system/record-arrays                                    | 487.00 B  | 92.87 B    | 0.5           | 0.2
	@ember-data/store/-private/system/identity-map                                     | 450.00 B  | 85.82 B    | 0.4           | 0.2
	@ember-data/store/-private/system/diff-array                                       | 438.00 B  | 83.53 B    | 0.4           | 0.2
	@ember-data/store/-private/ts-interfaces/identifier                                | 400.00 B  | 76.28 B    | 0.4           | 0.2
	@ember-data/store/-private/utils/symbol                                            | 393.00 B  | 74.94 B    | 0.4           | 0.2
	@ember-data/store/-private/identifiers/is-stable-identifier                        | 327.00 B  | 62.36 B    | 0.3           | 0.2
	@ember-data/store/-private/ts-interfaces/fetch-manager                             | 316.00 B  | 60.26 B    | 0.3           | 0.1
	@ember-data/store/-private/utils/promise-record                                    | 288.00 B  | 54.92 B    | 0.3           | 0.1
	@ember-data/store/-private/system/backburner                                       | 268.00 B  | 51.11 B    | 0.3           | 0.1
	@ember-data/store/-private/utils/brand                                             | 258.00 B  | 49.20 B    | 0.2           | 0.1
	@ember-data/store/-private/system/record-data-for                                  | 235.00 B  | 44.81 B    | 0.2           | 0.1
	@ember-data/store/-private/system/ts-upgrade-map                                   | 234.00 B  | 44.62 B    | 0.2           | 0.1
	@ember-data/store/-private/system/normalize-model-name                             | 220.00 B  | 41.95 B    | 0.2           | 0.1
	@ember-data/store/-private/utils/is-non-empty-string                               | 212.00 B  | 40.43 B    | 0.2           | 0.1
	@ember-data/store/-debug/index                                                     | 193.00 B  | 36.80 B    | 0.2           | 0.1
	@ember-data/store/-private/system/deprecated-evented                               | 190.00 B  | 36.23 B    | 0.2           | 0.1
	@ember-data/store/-private/ts-interfaces/record-data-store-wrapper                 | 136.00 B  | 25.93 B    | 0.1           | 0.1
	@ember-data/store/-private/ts-interfaces/record-data-schemas                       | 130.00 B  | 24.79 B    | 0.1           | 0.1
	@ember-data/store/-private/ts-interfaces/minimum-serializer-interface              | 98.00 B   | 18.68 B    | 0.1           | 0.0
	@ember-data/store/-private/ts-interfaces/record-data-record-wrapper                | 96.00 B   | 18.30 B    | 0.1           | 0.0
	@ember-data/store/-private/ts-interfaces/minimum-adapter-interface                 | 95.00 B   | 18.11 B    | 0.1           | 0.0
	@ember-data/store/-private/ts-interfaces/schema-definition-service                 | 95.00 B   | 18.11 B    | 0.1           | 0.0
	@ember-data/store/-private/ts-interfaces/record-data-json-api                      | 90.00 B   | 17.16 B    | 0.1           | 0.0
	@ember-data/store/-private/ts-interfaces/ember-data-json-api                       | 89.00 B   | 16.97 B    | 0.1           | 0.0
	@ember-data/store/-private/ts-interfaces/promise-proxies                           | 85.00 B   | 16.21 B    | 0.1           | 0.0
	@ember-data/store/-private/ts-interfaces/record-instance                           | 85.00 B   | 16.21 B    | 0.1           | 0.0
	@ember-data/store/-private/ts-interfaces/record-data                               | 81.00 B   | 15.44 B    | 0.1           | 0.0
	@ember-data/store/-private/ts-interfaces/ds-model                                  | 78.00 B   | 14.87 B    | 0.1           | 0.0
	@ember-data/store/-private/ts-interfaces/utils                                     | 75.00 B   | 14.30 B    | 0.1           | 0.0

Package: @ember-data/record-data
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '26.05 KB' │
│  compressed  │ '4.97 KB'  │
│ % Of Library │   '12.7'   │
└──────────────┴────────────┘
	Module                                                                      | Bytes     | Compressed | % of Package  | % Of Library
	-------------------------------------------------------------------------------------------------------------------------------
	@ember-data/record-data/-private/relationships/state/relationship           | 8.16 KB   | 1.56 KB    | 31.3          | 4.0
	@ember-data/record-data/-private/record-data                                | 8.11 KB   | 1.55 KB    | 31.1          | 3.9
	@ember-data/record-data/-private/relationships/state/belongs-to             | 3.02 KB   | 589.67 B   | 11.6          | 1.5
	@ember-data/record-data/-private/relationships/state/has-many               | 2.82 KB   | 549.82 B   | 10.8          | 1.4
	@ember-data/record-data/-private/relationships/state/create                 | 1.15 KB   | 224.65 B   | 4.4           | 0.6
	@ember-data/record-data/-private/index                                      | 1023.00 B | 195.09 B   | 3.8           | 0.5
	@ember-data/record-data/-private/ordered-set                                | 598.00 B  | 114.04 B   | 2.2           | 0.3
	@ember-data/record-data/-private/record-data-for                            | 481.00 B  | 91.73 B    | 1.8           | 0.2
	@ember-data/record-data/-private/coerce-id                                  | 406.00 B  | 77.42 B    | 1.5           | 0.2
	@ember-data/record-data/-private/normalize-link                             | 249.00 B  | 47.48 B    | 0.9           | 0.1
	@ember-data/record-data/-private/ts-interfaces/relationship-record-data     | 100.00 B  | 19.07 B    | 0.4           | 0.0

Package: @ember-data/serializer
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '21.72 KB' │
│  compressed  │ '4.14 KB'  │
│ % Of Library │   '10.6'   │
└──────────────┴────────────┘
	Module                                                     | Bytes     | Compressed | % of Package  | % Of Library
	--------------------------------------------------------------------------------------------------------------
	@ember-data/serializer/json                                | 7.10 KB   | 1.35 KB    | 32.7          | 3.4
	@ember-data/serializer/-private/embedded-records-mixin     | 4.29 KB   | 838.36 B   | 19.8          | 2.1
	@ember-data/serializer/json-api                            | 3.71 KB   | 724.70 B   | 17.1          | 1.8
	@ember-data/serializer/rest                                | 2.71 KB   | 528.46 B   | 12.5          | 1.3
	@ember-data/serializer/-private/index                      | 1.18 KB   | 230.76 B   | 5.4           | 0.6
	@ember-data/serializer/-private/transforms/date            | 523.00 B  | 99.74 B    | 2.4           | 0.2
	@ember-data/serializer/-private/transforms/boolean         | 490.00 B  | 93.44 B    | 2.2           | 0.2
	@ember-data/serializer/-private/transforms/number          | 446.00 B  | 85.05 B    | 2.0           | 0.2
	@ember-data/serializer/-private/transforms/string          | 351.00 B  | 66.93 B    | 1.6           | 0.2
	@ember-data/serializer/-private/utils                      | 286.00 B  | 54.54 B    | 1.3           | 0.1
	@ember-data/serializer/index                               | 243.00 B  | 46.34 B    | 1.1           | 0.1
	@ember-data/serializer/-private/transforms/transform       | 242.00 B  | 46.15 B    | 1.1           | 0.1
	@ember-data/serializer/transform                           | 215.00 B  | 41.00 B    | 1.0           | 0.1

Package: @ember-data/model
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '17.49 KB' │
│  compressed  │ '3.34 KB'  │
│ % Of Library │   '8.5'    │
└──────────────┴────────────┘
	Module                                                   | Bytes     | Compressed | % of Package  | % Of Library
	------------------------------------------------------------------------------------------------------------
	@ember-data/model/-private/model                         | 6.28 KB   | 1.20 KB    | 35.9          | 3.1
	@ember-data/model/-private/system/many-array             | 2.39 KB   | 466.47 B   | 13.7          | 1.2
	@ember-data/model/-private/errors                        | 2.03 KB   | 396.67 B   | 11.6          | 1.0
	@ember-data/model/-private/index                         | 1.29 KB   | 251.92 B   | 7.4           | 0.6
	@ember-data/model/-private/system/relationships/ext      | 1.19 KB   | 231.71 B   | 6.8           | 0.6
	@ember-data/model/-private/attr                          | 743.00 B  | 141.69 B   | 4.1           | 0.4
	@ember-data/model/-private/belongs-to                    | 663.00 B  | 126.44 B   | 3.7           | 0.3
	@ember-data/model/-private/system/promise-many-array     | 642.00 B  | 122.43 B   | 3.6           | 0.3
	@ember-data/model/-private/has-many                      | 626.00 B  | 119.38 B   | 3.5           | 0.3
	@ember-data/model/index                                  | 486.00 B  | 92.68 B    | 2.7           | 0.2
	@ember-data/model/-private/util                          | 442.00 B  | 84.29 B    | 2.5           | 0.2
	@ember-data/model/-private/system/promise-belongs-to     | 410.00 B  | 78.19 B    | 2.3           | 0.2
	@ember-data/model/-private/system/model-for-mixin        | 404.00 B  | 77.04 B    | 2.3           | 0.2

Package: @ember-data/adapter
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '17.01 KB' │
│  compressed  │ '3.24 KB'  │
│ % Of Library │   '8.3'    │
└──────────────┴────────────┘
	Module                                                        | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------------------
	@ember-data/adapter/rest                                      | 8.01 KB   | 1.53 KB    | 47.1          | 3.9
	@ember-data/adapter/error                                     | 1.91 KB   | 373.60 B   | 11.2          | 0.9
	@ember-data/adapter/-private/build-url-mixin                  | 1.81 KB   | 354.34 B   | 10.7          | 0.9
	@ember-data/adapter/-private/index                            | 1.03 KB   | 201.39 B   | 6.1           | 0.5
	@ember-data/adapter/json-api                                  | 897.00 B  | 171.06 B   | 5.1           | 0.4
	@ember-data/adapter/-private/utils/serialize-query-params     | 792.00 B  | 151.04 B   | 4.5           | 0.4
	@ember-data/adapter/index                                     | 635.00 B  | 121.10 B   | 3.6           | 0.3
	@ember-data/adapter/-private/utils/determine-body-promise     | 521.00 B  | 99.36 B    | 3.0           | 0.2
	@ember-data/adapter/-private/utils/parse-response-headers     | 480.00 B  | 91.54 B    | 2.8           | 0.2
	@ember-data/adapter/-private/utils/fetch                      | 454.00 B  | 86.58 B    | 2.6           | 0.2
	@ember-data/adapter/-private/utils/serialize-into-hash        | 347.00 B  | 66.17 B    | 2.0           | 0.2
	@ember-data/adapter/-private/utils/continue-on-reject         | 217.00 B  | 41.38 B    | 1.2           | 0.1

Package: ember-data
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '9.50 KB' │
│  compressed  │ '1.81 KB' │
│ % Of Library │   '4.6'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-data/index                                  | 2.32 KB   | 453.69 B   | 24.5          | 1.1
	ember-data/-private/index                         | 1.93 KB   | 376.46 B   | 20.3          | 0.9
	ember-data/adapters/errors                        | 1.19 KB   | 232.09 B   | 12.5          | 0.6
	ember-data/setup-container                        | 503.00 B  | 95.92 B    | 5.2           | 0.2
	ember-data/-private/core                          | 321.00 B  | 61.21 B    | 3.3           | 0.2
	ember-data/relationships                          | 318.00 B  | 60.64 B    | 3.3           | 0.2
	ember-data/serializers/embedded-records-mixin     | 274.00 B  | 52.25 B    | 2.8           | 0.1
	ember-data/serializers/json-api                   | 251.00 B  | 47.86 B    | 2.6           | 0.1
	ember-data/adapters/json-api                      | 245.00 B  | 46.72 B    | 2.5           | 0.1
	ember-data/serializers/json                       | 243.00 B  | 46.34 B    | 2.5           | 0.1
	ember-data/serializers/rest                       | 243.00 B  | 46.34 B    | 2.5           | 0.1
	ember-data/transform                              | 241.00 B  | 45.96 B    | 2.5           | 0.1
	ember-data/adapters/rest                          | 237.00 B  | 45.19 B    | 2.4           | 0.1
	ember-data/serializer                             | 232.00 B  | 44.24 B    | 2.4           | 0.1
	ember-data/adapter                                | 226.00 B  | 43.10 B    | 2.3           | 0.1
	ember-data/model                                  | 222.00 B  | 42.33 B    | 2.3           | 0.1
	ember-data/store                                  | 222.00 B  | 42.33 B    | 2.3           | 0.1
	ember-data/attr                                   | 218.00 B  | 41.57 B    | 2.2           | 0.1
	ember-data/version                                | 162.00 B  | 30.89 B    | 1.7           | 0.1

Package: ember-inflector
┌──────────────┬───────────┐
│   (index)    │  Values   │
├──────────────┼───────────┤
│    bytes     │ '7.91 KB' │
│  compressed  │ '1.51 KB' │
│ % Of Library │   '3.8'   │
└──────────────┴───────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	ember-inflector/lib/system/inflector              | 2.76 KB   | 539.14 B   | 34.9          | 1.3
	ember-inflector/lib/system/inflections            | 1.57 KB   | 307.04 B   | 19.9          | 0.8
	ember-inflector/index                             | 1.12 KB   | 218.93 B   | 14.2          | 0.5
	ember-inflector/lib/ext/string                    | 783.00 B  | 149.32 B   | 9.7           | 0.4
	ember-inflector/lib/system                        | 452.00 B  | 86.20 B    | 5.6           | 0.2
	ember-inflector/lib/system/string                 | 351.00 B  | 66.93 B    | 4.3           | 0.2
	ember-inflector/lib/helpers/pluralize             | 348.00 B  | 66.36 B    | 4.3           | 0.2
	ember-inflector/lib/utils/make-helper             | 308.00 B  | 58.73 B    | 3.8           | 0.1
	ember-inflector/lib/helpers/singularize           | 271.00 B  | 51.68 B    | 3.3           | 0.1

Package: @ember-data/debug
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '2.68 KB'  │
│  compressed  │ '523.88 B' │
│ % Of Library │   '1.3'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember-data/debug/index                           | 2.20 KB   | 428.71 B   | 81.8          | 1.1
	@ember-data/debug/setup                           | 499.00 B  | 95.16 B    | 18.2          | 0.2

Package: @ember/ordered-set
┌──────────────┬────────────┐
│   (index)    │   Values   │
├──────────────┼────────────┤
│    bytes     │ '1.05 KB'  │
│  compressed  │ '205.58 B' │
│ % Of Library │   '0.5'    │
└──────────────┴────────────┘
	Module                                            | Bytes     | Compressed | % of Package  | % Of Library
	-----------------------------------------------------------------------------------------------------
	@ember/ordered-set/index                          | 1.05 KB   | 205.58 B   | 100.0         | 0.5

@github-actions
Copy link

github-actions bot commented Aug 2, 2020

Performance Report for 84ea514

Relationship Analysis
                        -------------

__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
 _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
  _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
   _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
    _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
     _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
      _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
       _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
        _\///______________\///______________\///__\///////////////__


                          Runtime Edition

        PM2 is a Production Process Manager for Node.js applications
                     with a built-in Load Balancer.

                Start and Daemonize any application:
                $ pm2 start app.js

                Load Balance 4 instances of api.js:
                $ pm2 start api.js -i 4

                Monitor in production:
                $ pm2 monitor

                Make pm2 auto-boot at server restart:
                $ pm2 startup

                To go further checkout:
                http://pm2.io/


                        -------------

[PM2] Spawning PM2 daemon with pm2_home=/home/runner/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /home/runner/work/data/data/bin/relationship-performance-tracking/src/har-remix.js in fork_mode (1 instance)
[PM2] Done.
┌─────┬────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name       │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ control    │ default     │ N/A     │ fork    │ 3067     │ 0s     │ 0    │ online    │ 0%       │ 28.1mb   │ runner   │ disabled │
└─────┴────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[PM2] Starting /home/runner/work/data/data/bin/relationship-performance-tracking/src/har-remix.js in fork_mode (1 instance)
[PM2] Done.
┌─────┬───────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name          │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼───────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ control       │ default     │ N/A     │ fork    │ 3067     │ 0s     │ 0    │ online    │ 0%       │ 72.3mb   │ runner   │ disabled │
│ 1   │ experiment    │ default     │ N/A     │ fork    │ 3105     │ 0s     │ 0    │ online    │ 0%       │ 27.4mb   │ runner   │ disabled │
└─────┴───────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

===============================================================================
Processing CHANGELOG.md CODE_OF_CONDUCT.md CONTRIBUTING.md README.md RELEASE.md bin lerna.json node_modules package.json packages tmp tsconfig.json yarn.lock
[PM2] [v] Modules Stopped
[PM2] Applying action deleteProcessId on app [all](ids: [ 0, 1 ])
[PM2] [control](0) ✓
[PM2] [experiment](1) ✓
[PM2] [v] All Applications Stopped
[PM2] [v] PM2 Daemon Stopped

INTERNAL_MODELS.set(this, internalModel);
}
} else {
INTERNAL_MODELS.set(this, identifierOrInternalModel as InternalModel);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we ok coercing variables to a specific type?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, usually a type guard would be great, but we don't have one in this case.

@snewcomer snewcomer added the 🌲 Project Trim 🌲 PRs related to https://github.com/emberjs/data/issues/6166 label Aug 2, 2020
@@ -33,7 +33,6 @@ export interface ExistingResourceIdentifierObject {
type: string;

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an accident

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought lid was a part of the JSONAPI spec. But it looks like it is upcoming.

https://jsonapi.org/format/1.1/

@snewcomer snewcomer force-pushed the sn/relationships-identifiers branch 2 times, most recently from 84c4f38 to 420db2a Compare August 27, 2020 05:29
@snewcomer snewcomer added the code-review Tracks PRs that require a code-review label Sep 2, 2020
@snewcomer snewcomer force-pushed the sn/relationships-identifiers branch 2 times, most recently from f3f23f3 to 140b1d8 Compare September 27, 2020 00:30
@@ -144,8 +144,8 @@ module('integration/references/belongs-to', function(hooks) {
var personReference = store.getReference('person', 1);
var familyReference = person.belongsTo('family');

assert.ok(personReference);
assert.equal(familyReference.parent, personReference);
assert.ok(personReference, 'person reference is present');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@@ -1436,9 +1439,20 @@ abstract class CoreStore extends Service {
}
const type = normalizeModelName(modelName);
const normalizedId = ensureStringId(id);
const resource = constructResource(type, normalizedId);
const resource: ResourceIdentifierObject = constructResource(type, normalizedId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this type/id should be a recordIdentifer not a resource

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like we need to adjust the return type of constructResource to ResourceIdentifierObject | RecordIdentifier?

const resource: ResourceIdentifierObject = constructResource(type, normalizedId);

if (RECORD_ARRAY_MANAGER_IDENTIFIERS) {
const identifier: StableRecordIdentifier = identifierCacheFor(this).getOrCreateRecordIdentifier(resource);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't getOrCreateRecordIdentifier here

@@ -82,7 +88,7 @@ export default class BelongsToReference extends Reference {
}

_resource() {
return INTERNAL_MODELS.get(this)?._recordData.getBelongsTo(this.key);
return internalModelForReference(this)?._recordData.getBelongsTo(this.key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to get the record data if you have the identifier right?

let resource = this._resource();
if (resource && resource.data) {
let inverseInternalModel = store._internalModelForResource(resource.data);
let inverseInternalModel = this.store._internalModelForResource(resource.data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


// TODO inverse
}

_resource() {
return INTERNAL_MODELS.get(this)?._recordData.getHasMany(this.key);
return internalModelForReference(this)?._recordData.getHasMany(this.key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to get recordData via reference

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting we make a public getter for recordData on the Record instance?

If not, I was assuming here that the only way to get recordData was through the InternalModel. Perhaps there is a better way?

@@ -29,7 +32,15 @@ function isResourceIdentiferWithRelatedLinks(
return value && value.links && value.links.related;
}

export const INTERNAL_MODELS = new WeakMap<Reference, InternalModel>();
export const REFERENCE_CACHE = new WeakMap<Reference, InternalModel | StableRecordIdentifier>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once RECORD_ARRAY_MANAGER_IDENTIFIERS are turned on, lets make sure to simplify this, maybe leave a todo comment and rename to be more descriptive


export function internalModelForReference(reference: Reference): InternalModel | null | undefined {
if (RECORD_ARRAY_MANAGER_IDENTIFIERS) {
return internalModelFactoryFor(reference.store).peek(REFERENCE_CACHE.get(reference) as StableRecordIdentifier);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with the messy TS as we are turning this FF very soon

INTERNAL_MODELS.set(this, internalModel);
constructor(public store: CoreStore, identifierOrInternalModel: InternalModel | StableRecordIdentifier) {
if (RECORD_ARRAY_MANAGER_IDENTIFIERS) {
REFERENCE_CACHE.set(this, identifierOrInternalModel as StableRecordIdentifier);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs a cast

return null;
} else {
return internalModelForReference(this)!.id;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From meeting - an identifier getter probably makes sense. Will discuss in next week's meeting.

@@ -61,6 +61,10 @@ abstract class Reference {
}
}

get recordData() {
return internalModelForReference(this)?._recordData;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you get the identifier here as we for when we do have it and use it to lookup the record data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -16,6 +16,6 @@ import { dasherize } from '@ember/string';
@param {String} modelName
@return {String} normalizedModelName
*/
export default function normalizeModelName(modelName) {
export default function normalizeModelName(modelName: string): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@snewcomer snewcomer merged commit 1428e26 into master Oct 30, 2020
@delete-merged-branch delete-merged-branch bot deleted the sn/relationships-identifiers branch October 30, 2020 20:13
@sandstrom
Copy link
Contributor

sandstrom commented Dec 17, 2020

@snewcomer Have you thought about registering for Github Sponsorships? 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-review Tracks PRs that require a code-review 🌲 Project Trim 🌲 PRs related to https://github.com/emberjs/data/issues/6166
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants