Skip to content

Commit

Permalink
chore: remove 4.x deprecations (emberjs#8550)
Browse files Browse the repository at this point in the history
* chore: remove 4.x deprecations

* more test fixes

* fix tests

* fix embroider scenario
  • Loading branch information
runspired authored Apr 8, 2023
1 parent 47be78d commit 362b588
Show file tree
Hide file tree
Showing 126 changed files with 1,148 additions and 12,214 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ module.exports = {
'packages/store/src/index.ts',
'packages/store/src/-private/utils/is-non-empty-string.ts',
'packages/store/src/-private/utils/construct-resource.ts',
'ember-data-types/q/utils.ts',
'ember-data-types/q/schema-definition-service.ts',
'ember-data-types/q/record-instance.ts',
'ember-data-types/q/record-data-store-wrapper.ts',
Expand Down
1 change: 0 additions & 1 deletion ember-data-types/cache/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ export interface Cache {
*
* @method changedAttrs
* @public
* @deprecated
* @param identifier
* @returns { <field>: [<old>, <new>] }
*/
Expand Down
173 changes: 1 addition & 172 deletions ember-data-types/q/cache-store-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { IdentifierCache } from '@ember-data/store/-private/caches/identifier-ca
import { NotificationType } from '@ember-data/store/-private/managers/notification-manager';

import { StableDocumentIdentifier } from '../cache/identifier';
import type { Cache } from './cache';
import { StableRecordIdentifier } from './identifier';
import type { AttributesSchema, RelationshipsSchema } from './record-data-schemas';
import { SchemaService } from './schema-service';

/**
Expand All @@ -24,7 +22,7 @@ import { SchemaService } from './schema-service';
* @class CacheStoreWrapper
* @public
*/
export interface LegacyCacheStoreWrapper {
export interface CacheStoreWrapper {
/**
* Provides access to the IdentifierCache instance
* for this Store instance.
Expand All @@ -49,36 +47,6 @@ export interface LegacyCacheStoreWrapper {
*/
getSchemaDefinitionService(): SchemaService;

/**
* Proxies to the schema service's `relationshipsDefinitionFor`
* method.
*
* Use `wrapper.getSchemaDefinitionService().relationshipsDefinitionFor()`
* instead.
*
* @method relationshipsDefinitionFor
* @param {string} modelName
* @returns {RelationshipsSchema}
* @public
* @deprecated
*/
relationshipsDefinitionFor(modelName: string): RelationshipsSchema;

/**
* Proxies to the schema service's `attributesDefinitionFor`
* method.
*
* Use `wrapper.getSchemaDefinitionService().attributesDefinitionFor()`
* instead.
*
* @method attributesDefinitionFor
* @param {string} modelName
* @returns {AttributesSchema}
* @public
* @deprecated
*/
attributesDefinitionFor(modelName: string): AttributesSchema;

/**
* Update the `id` for the record corresponding to the identifier
* This operation can only be done for records whose `id` is `null`.
Expand All @@ -88,7 +56,6 @@ export interface LegacyCacheStoreWrapper {
* @param {string} id;
* @public
*/
setRecordId(modelName: string, id: string, clientId: string): void;
setRecordId(identifier: StableRecordIdentifier, id: string): void;

/**
Expand All @@ -101,25 +68,8 @@ export interface LegacyCacheStoreWrapper {
* @param {StableRecordIdentifier} identifier
* @public
*/
disconnectRecord(modelName: string, id: string | null, clientId: string): void;
disconnectRecord(modelName: string, id: string, clientId?: string | null): void;
disconnectRecord(modelName: string, id: string | null, clientId?: string | null): void;
disconnectRecord(identifier: StableRecordIdentifier): void;

/**
* Use hasRecord instead.
*
* @method isRecordInUse
* @param modelName
* @param id
* @param clientId
* @public
* @deprecated
*/
isRecordInUse(modelName: string, id: string | null, clientId: string): boolean;
isRecordInUse(modelName: string, id: string, clientId?: string | null): boolean;
isRecordInUse(modelName: string, id: string | null, clientId?: string | null): boolean;

/**
* Use this method to determine if the Store has an instantiated record associated
* with an identifier.
Expand All @@ -131,79 +81,6 @@ export interface LegacyCacheStoreWrapper {
*/
hasRecord(identifier: StableRecordIdentifier): boolean;

/**
* Use notifyChange
*
* @method notifyPropertyChange
* @param modelName
* @param id
* @param clientId
* @param key
* @deprecated
* @public
*/
notifyPropertyChange(modelName: string, id: string | null, clientId: string | null, key: string): void;

/**
* Use notifyChange
*
* @method notifyHasManyChange
* @param modelName
* @param id
* @param clientId
* @param key
* @public
* @deprecated
*/
notifyHasManyChange(modelName: string, id: string | null, clientId: string, key: string): void;
notifyHasManyChange(modelName: string, id: string, clientId: string | null | undefined, key: string): void;
notifyHasManyChange(modelName: string, id: string | null, clientId: string | null | undefined, key: string): void;

/**
* [DEPRECATED] RecordData has become Cache and Cache is now always
* a singleton.
*
* You may access the Cache via Store.cache. If you are interacting
* with this wrapped from the Cache you are the Cache instance and
* thus do not need to call this anymore.
*
* Used to retrieve the associated RecordData for a given identifier.
*
* To generate a RecordData for a new client-side resource that does not
* yet have an ID and place it in the new state, first create an identifier
* via `identifierCache.createIdentifierForNewRecord`
*
* Then once you have obtained the RecordData instance you should invoke
* `recordData.clientDidCreate` to ensure the cache entry is put into the
* correct "newly created" state.
*
* @method recordDataFor
* @deprecated
* @param {StableRecordIdentifier} identifier
* @return {Cache} the RecordData cache instance associated with the identifier
* @public
*/
recordDataFor(type: string, id: string, lid?: string | null): Cache;
recordDataFor(type: string, id: string | null, lid: string): Cache;
recordDataFor(type: string): Cache;
recordDataFor(type: string, id?: string | null, lid?: string | null): Cache;
recordDataFor(identifier: StableRecordIdentifier): Cache;

/**
* Use notifyChange
*
* @method notifyBelongsToChange
* @param modelName
* @param id
* @param clientId
* @param key
* @public
* @deprecated
*/
notifyBelongsToChange(modelName: string, id: string | null, clientId: string, key: string): void;
notifyBelongsToChange(modelName: string, id: string, clientId: string | null | undefined, key: string): void;
notifyBelongsToChange(modelName: string, id: string | null, clientId: string | null | undefined, key: string): void;

/**
* Notify subscribers of the NotificationManager that cache state has changed.
*
Expand All @@ -218,52 +95,6 @@ export interface LegacyCacheStoreWrapper {
* @param {string|undefined} key
* @public
*/
notifyChange(identifier: StableRecordIdentifier, namespace: 'added' | 'removed'): void;
notifyChange(identifier: StableRecordIdentifier, namespace: NotificationType, key?: string): void;
notifyChange(
identifier: StableRecordIdentifier,
namespace: NotificationType | 'added' | 'removed',
key?: string
): void;

/**
* Use notifyChange
*
* @method notifyErrorsChange
* @param modelName
* @param id
* @param clientId
* @public
* @deprecated
*/
notifyErrorsChange(modelName: string, id: string | null, clientId: string | null): void;

/**
* Use notifyChange
*
* @method notifyStateChange
* @param modelName
* @param id
* @param clientId
* @param key
* @public
* @deprecated
*/
notifyStateChange(modelName: string, id: string | null, clientId: string | null, key?: string): void;
}

export interface V2CacheStoreWrapper {
identifierCache: IdentifierCache;
getSchemaDefinitionService(): SchemaService;

setRecordId(identifier: StableRecordIdentifier, id: string): void;

disconnectRecord(identifier: StableRecordIdentifier): void;

hasRecord(identifier: StableRecordIdentifier): boolean;

recordDataFor(identifier: StableRecordIdentifier): Cache;

notifyChange(identifier: StableRecordIdentifier, namespace: 'added' | 'removed'): void;
notifyChange(identifier: StableDocumentIdentifier, namespace: 'added' | 'updated' | 'removed'): void;
notifyChange(identifier: StableRecordIdentifier, namespace: NotificationType, key?: string): void;
Expand All @@ -273,5 +104,3 @@ export interface V2CacheStoreWrapper {
key?: string
): void;
}

export type CacheStoreWrapper = LegacyCacheStoreWrapper | V2CacheStoreWrapper;
3 changes: 1 addition & 2 deletions ember-data-types/q/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Cache } from '../cache/cache';
import type { CollectionResourceRelationship, SingleResourceRelationship } from './ember-data-json-api';
import type { RecordIdentifier, StableRecordIdentifier } from './identifier';
import type { JsonApiError, JsonApiResource } from './record-data-json-api';
import { Dict } from './utils';
/**
@module @ember-data/store
*/
Expand All @@ -26,7 +25,7 @@ export interface CacheV1 {
pushData(data: JsonApiResource, calculateChange?: false): void;
pushData(data: JsonApiResource, calculateChange?: boolean): string[] | void;
clientDidCreate(): void;
_initRecordCreateOptions(options?: Dict<unknown>): { [key: string]: unknown };
_initRecordCreateOptions(options?: Record<string, unknown>): Record<string, unknown>;

willCommit(): void;
didCommit(data: JsonApiResource | null): void;
Expand Down
20 changes: 9 additions & 11 deletions ember-data-types/q/ember-data-json-api.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import type { Value as JSONValue } from 'json-typescript';

import type { Dict } from './utils';

/**
@module @ember-data/store
*/

export type Meta = Dict<JSONValue>;
export type LinkObject = { href: string; meta?: Dict<JSONValue> };
export type Meta = Record<string, JSONValue>;
export type LinkObject = { href: string; meta?: Record<string, JSONValue> };
export type Link = string | LinkObject;
export interface Links {
related?: Link;
Expand Down Expand Up @@ -101,13 +99,13 @@ export type ResourceIdentifierObject =
// TODO disallow NewResource, make narrowable
export interface SingleResourceRelationship {
data?: ExistingResourceIdentifierObject | NewResourceIdentifierObject | null;
meta?: Dict<JSONValue>;
meta?: Record<string, JSONValue>;
links?: Links;
}

export interface CollectionResourceRelationship {
data?: Array<ExistingResourceIdentifierObject | NewResourceIdentifierObject>;
meta?: Dict<JSONValue>;
meta?: Record<string, JSONValue>;
links?: PaginationLinks;
}

Expand All @@ -116,16 +114,16 @@ export interface CollectionResourceRelationship {
* @internal
*/
export interface ExistingResourceObject extends ExistingResourceIdentifierObject {
meta?: Dict<JSONValue>;
attributes?: Dict<JSONValue>;
relationships?: Dict<SingleResourceRelationship | CollectionResourceRelationship>;
meta?: Record<string, JSONValue>;
attributes?: Record<string, JSONValue>;
relationships?: Record<string, SingleResourceRelationship | CollectionResourceRelationship>;
links?: Links;
}

interface Document {
meta?: Dict<JSONValue>;
meta?: Record<string, JSONValue>;
included?: ExistingResourceObject[];
jsonapi?: Dict<JSONValue>;
jsonapi?: Record<string, JSONValue>;
links?: Links | PaginationLinks;
errors?: JSONValue[];
}
Expand Down
4 changes: 1 addition & 3 deletions ember-data-types/q/fetch-manager.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { Dict } from '@ember-data/types/q/utils';

import type { RecordIdentifier } from './identifier';

export interface Operation {
op: string;
options: Dict<unknown> | undefined;
options: Record<string, unknown> | undefined;
recordIdentifier: RecordIdentifier;
}

Expand Down
7 changes: 3 additions & 4 deletions ember-data-types/q/minimum-adapter-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import type { Collection } from '@ember-data/store/-private/record-arrays/identi

import type { ModelSchema } from './ds-model';
import type { RelationshipSchema } from './record-data-schemas';
import type { Dict } from './utils';

type Group = Snapshot[];
// TODO this should probably just alias unknown
// since in theory a user could pass a blob or a string
// however those deserialization cases are handled
// far easier in the adapter itself and are unlikely
// to be passed to the serializer today.
export type AdapterPayload = Dict<unknown> | unknown[];
export type AdapterPayload = Record<string, unknown> | unknown[];

/**
* <blockquote style="margin: 1em; padding: .1em 1em .1em 1em; border-left: solid 1em #E34C32; background: #e0e0e0;">
Expand Down Expand Up @@ -136,7 +135,7 @@ export interface MinimumAdapterInterface {
query(
store: Store,
schema: ModelSchema,
query: Dict<unknown>,
query: Record<string, unknown>,
recordArray: Collection,
options: { adapterOptions?: unknown }
): Promise<AdapterPayload>;
Expand Down Expand Up @@ -167,7 +166,7 @@ export interface MinimumAdapterInterface {
queryRecord(
store: Store,
schema: ModelSchema,
query: Dict<unknown>,
query: Record<string, unknown>,
options: { adapterOptions?: unknown }
): Promise<AdapterPayload>;

Expand Down
3 changes: 1 addition & 2 deletions ember-data-types/q/minimum-serializer-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import type Store from '@ember-data/store';
import type { ModelSchema } from './ds-model';
import type { JsonApiDocument, SingleResourceDocument } from './ember-data-json-api';
import type { AdapterPayload } from './minimum-adapter-interface';
import type { Dict } from './utils';

export type OptionsHash = Dict<unknown>;
export type OptionsHash = Record<string, unknown>;
export type RequestType =
| 'findRecord'
| 'queryRecord'
Expand Down
5 changes: 2 additions & 3 deletions ember-data-types/q/record-data-json-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ import type {
Meta,
SingleResourceRelationship,
} from './ember-data-json-api';
import type { Dict } from './utils';

/**
@module @ember-data/store
*/

export type AttributesHash = Dict<unknown>;
export type AttributesHash = Record<string, unknown>;

export interface JsonApiResource {
id?: string | null;
type?: string;
lid?: string;
attributes?: AttributesHash;
relationships?: Dict<SingleResourceRelationship | CollectionResourceRelationship>;
relationships?: Record<string, SingleResourceRelationship | CollectionResourceRelationship>;
meta?: Meta;
links?: Links;
}
Expand Down
Loading

0 comments on commit 362b588

Please sign in to comment.