-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CHORE] redivide assets to move record-data into package (#6513)
* move files, some types are borked fix recordDataFor unentangle createRecordData creatively un-entangle the store from record-data DS.Store needs to also use the configured defaultRecordData none of record-data package should be JS :) make types for record-data package nice * rerun lint * TS feedback cleanup * fix test * type recordDataFor * rename Legit to Instance * improve typings
- Loading branch information
Showing
64 changed files
with
477 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
export { default } from '@ember-data/store'; | ||
import Store from '@ember-data/store'; | ||
import { RecordData } from '@ember-data/record-data/-private'; | ||
import { identifierCacheFor } from '@ember-data/store/-private'; | ||
import { IDENTIFIERS } from '@ember-data/canary-features'; | ||
|
||
type RecordDataStoreWrapper = import('@ember-data/store/-private/ts-interfaces/record-data-store-wrapper').RecordDataStoreWrapper; | ||
|
||
export default class DefaultStore extends Store { | ||
createRecordDataFor(modelName: string, id: string | null, clientId: string, storeWrapper: RecordDataStoreWrapper) { | ||
if (IDENTIFIERS) { | ||
let identifier = identifierCacheFor(this).getOrCreateRecordIdentifier({ | ||
type: modelName, | ||
id, | ||
lid: clientId, | ||
}); | ||
return new RecordData(identifier, storeWrapper); | ||
} else { | ||
return new RecordData(modelName, id, clientId, storeWrapper); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'ember-data/store'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/-serializer-encapsulation-test-app/app/services/store.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Store from '@ember-data/store'; | ||
import { RecordData } from '@ember-data/record-data/-private'; | ||
import { identifierCacheFor } from '@ember-data/store/-private'; | ||
import { IDENTIFIERS } from '@ember-data/canary-features'; | ||
|
||
export default class DefaultStore extends Store { | ||
createRecordDataFor(modelName, id, clientId, storeWrapper) { | ||
if (IDENTIFIERS) { | ||
let identifier = identifierCacheFor(this).getOrCreateRecordIdentifier({ | ||
type: modelName, | ||
id, | ||
lid: clientId, | ||
}); | ||
return new RecordData(identifier, storeWrapper); | ||
} else { | ||
return new RecordData(modelName, id, clientId, storeWrapper); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/-serializer-encapsulation-test-app/tests/integration/errors-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/-serializer-encapsulation-test-app/tests/integration/requests-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/-serializer-encapsulation-test-app/tests/integration/serialize-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { DEBUG } from '@glimmer/env'; | ||
|
||
// Used by the store to normalize IDs entering the store. Despite the fact | ||
// that developers may provide IDs as numbers (e.g., `store.findRecord('person', 1)`), | ||
// it is important that internally we use strings, since IDs may be serialized | ||
// and lose type information. For example, Ember's router may put a record's | ||
// ID into the URL, and if we later try to deserialize that URL and find the | ||
// corresponding record, we will not know if it is a string or a number. | ||
type Coercable = string | number | boolean | null | undefined | symbol; | ||
|
||
function coerceId(id: Coercable): string | null { | ||
if (id === null || id === undefined || id === '') { | ||
return null; | ||
} | ||
if (typeof id === 'string') { | ||
return id; | ||
} | ||
if (typeof id === 'symbol') { | ||
return id.toString(); | ||
} | ||
return '' + id; | ||
} | ||
|
||
export function ensureStringId(id: Coercable): string { | ||
let normalized: string | null = null; | ||
if (typeof id === 'string') { | ||
normalized = id.length > 0 ? id : null; | ||
} else if (typeof id === 'number' && !isNaN(id)) { | ||
normalized = '' + id; | ||
} | ||
|
||
if (DEBUG && normalized === null) { | ||
throw new Error(`Expected id to be a string or number, recieved ${String(id)}`); | ||
} | ||
|
||
return normalized!; | ||
} | ||
|
||
export default coerceId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { default as RecordData } from './record-data'; | ||
export { default as Relationship } from './relationships/state/relationship'; | ||
export { default as BelongsToRelationship } from './relationships/state/belongs-to'; | ||
export { default as ManyRelationship } from './relationships/state/has-many'; | ||
export { relationshipStateFor, relationshipsFor } from './record-data-for'; |
11 changes: 5 additions & 6 deletions
11
...e/addon/-private/system/normalize-link.js → ...ord-data/addon/-private/normalize-link.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
...tore/addon/-private/system/ordered-set.ts → ...record-data/addon/-private/ordered-set.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.