MCPcopy Create free account
hub / github.com/ember-learn/ember-api-docs / Application

Class Application

app/serializers/application.js:4–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2import { JSONAPISerializer } from '@warp-drive/legacy/serializer/json-api';
3
4export default class Application extends JSONAPISerializer {
5 @service
6 metaStore;
7
8 extractId(_, hash) {
9 return hash.id.toLowerCase();
10 }
11
12 extractRelationship(relationship) {
13 // for some reason we only need to update the id to lowercase when it's an object relationship and not an array 🤷
14 if (relationship?.data?.id) {
15 relationship.data.id = relationship.data.id.toLowerCase();
16 }
17 return super.extractRelationship(relationship);
18 }
19
20 normalizeFindRecordResponse(store, primaryModelClass, payload, id) {
21 let normalizedDocument = super.normalizeFindRecordResponse(...arguments);
22
23 // We do this because ember data doesn't handle meta data in accordance to json-api spec yet
24 if (primaryModelClass.modelName === 'project') {
25 this.metaStore.availableProjectVersions[id] =
26 normalizedDocument.meta.availableVersions;
27 } else if (primaryModelClass.modelName === 'project-version') {
28 this.metaStore.addToProjectRevMap(id, normalizedDocument.meta);
29 }
30
31 return normalizedDocument;
32 }
33}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected