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: InternalModel burndown #8078

Merged
merged 16 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
106 changes: 51 additions & 55 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,16 @@ module.exports = {
'packages/unpublished-fastboot-test-app/app/config/environment.d.ts',
'packages/unpublished-fastboot-test-app/app/app.ts',
'packages/unpublished-fastboot-test-app/app/adapters/application.ts',
'packages/store/types/require/index.d.ts',
'packages/store/types/qunit/index.d.ts',
'packages/store/types/fastboot/index.d.ts',
'packages/store/types/ember/index.d.ts',
'packages/store/types/@glimmer/tracking.d.ts',
'packages/store/types/@ember/utils/index.d.ts',
'packages/store/types/@ember/runloop/index.d.ts',
'packages/store/types/@ember/runloop/-private/backburner.d.ts',
'packages/store/types/@ember/object/compat.d.ts',
'packages/store/types/@ember/debug/index.d.ts',
'@types/require/index.d.ts',
'@types/qunit/index.d.ts',
'@types/fastboot/index.d.ts',
'@types/ember/index.d.ts',
'@types/@glimmer/tracking.d.ts',
'@types/@ember/utils/index.d.ts',
'@types/@ember/runloop/index.d.ts',
'@types/@ember/runloop/-private/backburner.d.ts',
'@types/@ember/object/compat.d.ts',
'@types/@ember/debug/index.d.ts',
'packages/store/tests/dummy/app/routes/application/route.ts',
'packages/store/tests/dummy/app/router.ts',
'packages/store/tests/dummy/app/resolver.ts',
Expand All @@ -179,54 +179,49 @@ module.exports = {
'packages/store/addon/-private/utils/promise-record.ts',
'packages/store/addon/-private/utils/is-non-empty-string.ts',
'packages/store/addon/-private/utils/construct-resource.ts',
'packages/store/addon/-private/ts-interfaces/utils.ts',
'packages/store/addon/-private/ts-interfaces/schema-definition-service.ts',
'packages/store/addon/-private/ts-interfaces/record-instance.ts',
'packages/store/addon/-private/ts-interfaces/record-data.ts',
'packages/store/addon/-private/ts-interfaces/record-data-store-wrapper.ts',
'packages/store/addon/-private/ts-interfaces/record-data-schemas.ts',
'packages/store/addon/-private/ts-interfaces/record-data-record-wrapper.ts',
'packages/store/addon/-private/ts-interfaces/record-data-json-api.ts',
'packages/store/addon/-private/ts-interfaces/promise-proxies.ts',
'packages/store/addon/-private/ts-interfaces/minimum-serializer-interface.ts',
'packages/store/addon/-private/ts-interfaces/minimum-adapter-interface.ts',
'packages/store/addon/-private/ts-interfaces/identifier.ts',
'packages/store/addon/-private/ts-interfaces/fetch-manager.ts',
'packages/store/addon/-private/ts-interfaces/ember-data-json-api.ts',
'packages/store/addon/-private/ts-interfaces/ds-model.ts',
'packages/store/addon/-private/system/store/record-data-store-wrapper.ts',
'packages/store/addon/-private/system/store/internal-model-factory.ts',
'packages/store/addon/-private/system/snapshot.ts',
'packages/store/addon/-private/system/snapshot-record-array.ts',
'packages/store/addon/-private/system/schema-definition-service.ts',
'packages/store/addon/-private/system/request-cache.ts',
'packages/store/addon/-private/system/references/belongs-to.ts',
'packages/store/addon/-private/system/references/has-many.ts',
'packages/store/addon/-private/system/references/reference.ts',
'packages/store/addon/-private/system/references/record.ts',
'packages/store/addon/-private/system/record-notification-manager.ts',
'packages/store/addon/-private/system/record-data-for.ts',
'packages/store/addon/-private/system/record-arrays.ts',
'packages/store/addon/-private/system/normalize-model-name.ts',
'packages/store/addon/-private/system/model/shim-model-class.ts',
'packages/store/addon/-private/system/model/internal-model.ts',
'packages/store/addon/-private/system/internal-model-map.ts',
'packages/store/addon/-private/system/identity-map.ts',
'packages/store/addon/-private/system/fetch-manager.ts',
'packages/store/addon/-private/system/core-store.ts',
'packages/store/addon/-private/system/coerce-id.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.ts',
'ember-data-types/q/record-data-store-wrapper.ts',
'ember-data-types/q/record-data-schemas.ts',
'ember-data-types/q/record-data-record-wrapper.ts',
'ember-data-types/q/record-data-json-api.ts',
'ember-data-types/q/promise-proxies.ts',
'ember-data-types/q/minimum-serializer-interface.ts',
'ember-data-types/q/minimum-adapter-interface.ts',
'ember-data-types/q/identifier.ts',
'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/index.ts',
'packages/store/addon/-private/identifiers/utils/uuid-v4.ts',
'packages/store/addon/-private/identifiers/is-stable-identifier.ts',
'packages/store/addon/-private/identifiers/cache.ts',
'packages/store/addon/-private/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',
'packages/serializer/tests/dummy/app/config/environment.d.ts',
'packages/serializer/tests/dummy/app/app.ts',
'packages/serializer/addon/index.ts',
'packages/record-data/types/@ember/runloop/index.d.ts',
'packages/record-data/types/@ember/polyfills/index.d.ts',
'@types/@ember/runloop/index.d.ts',
'@types/@ember/polyfills/index.d.ts',
'packages/record-data/tests/integration/graph/polymorphism/implicit-keys-test.ts',
'packages/record-data/tests/integration/graph/graph-test.ts',
'packages/record-data/tests/integration/graph/edge-test.ts',
Expand All @@ -239,7 +234,7 @@ module.exports = {
'packages/record-data/tests/dummy/app/resolver.ts',
'packages/record-data/tests/dummy/app/config/environment.d.ts',
'packages/record-data/tests/dummy/app/app.ts',
'packages/record-data/addon/-private/ts-interfaces/relationship-record-data.ts',
'ember-data-types/q/relationship-record-data.ts',
'packages/record-data/addon/-private/relationships/state/implicit.ts',
'packages/record-data/addon/-private/relationships/state/has-many.ts',
'packages/record-data/addon/-private/relationships/state/belongs-to.ts',
Expand Down Expand Up @@ -268,9 +263,10 @@ module.exports = {
'packages/model/tests/dummy/app/app.ts',
'packages/model/addon/index.ts',
'packages/model/addon/-private/util.ts',
'packages/model/addon/-private/system/relationships/relationship-meta.ts',
'packages/model/addon/-private/system/promise-many-array.ts',
'packages/model/addon/-private/system/model-for-mixin.ts',
'packages/model/addon/-private/relationship-meta.ts',
'packages/model/addon/-private/legacy-relationships-support.ts',
'packages/model/addon/-private/promise-many-array.ts',
'packages/model/addon/-private/model-for-mixin.ts',
'packages/model/addon/-private/record-state.ts',
'packages/model/addon/-private/notify-changes.ts',
'packages/model/addon/-private/index.ts',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ import type NativeArray from '@ember/array/-private/native-array';
import type ComputedProperty from '@ember/object/computed';
import type Mixin from '@ember/object/mixin';

namespace Array {
// detect is an intimate Mixin API, likely should not be typed upstream
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function detect(arr: unknown): boolean;
}

/**
* This module implements Observer-friendly Array-like behavior. This mixin is picked up by the
* Array class as well as other controllers, etc. that want to appear to be arrays.
Expand Down Expand Up @@ -97,11 +91,15 @@ interface Array<T> extends Enumerable<T> {
}
// Ember.Array rather than Array because the `array-type` lint rule doesn't realize the global is shadowed
// tslint:disable-next-line:array-type
declare const Array: Mixin<Array<unknown>>;
export default Array;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
declare class Array<T> extends Mixin<Array<unknown>> {
static detect(arr: unknown): boolean;
}

export const NativeArray;

export default Array;

/**
* Creates an `Ember.NativeArray` from an Array like object.
* Does not modify the original object's contents. Ember.A is not needed if
Expand Down
2 changes: 2 additions & 0 deletions @types/@ember/object/compat.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export function dependentKeyCompat(desc: PropertyDescriptor): void;
export function dependentKeyCompat(target: object, key: string, desc: PropertyDescriptor): void;
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ interface PromiseProxyMixin<T> extends Promise<T> {
*/
promise: Promise<T>;
}
declare class PromiseProxyMixin extends Promise<T> {}
declare class PromiseProxyMixin<T> extends Promise<T> {}
export default PromiseProxyMixin;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
* `Ember.ObjectProxy` forwards all properties not defined by the proxy itself
* to a proxied `content` object.
*/
export default class ObjectProxy<T extends object = object> extends EmberObject {
export default class ObjectProxy<T> extends EmberObject {
/**
* The object whose properties will be forwarded.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { EmberRunTimer } from '@ember/runloop/types';

export interface QueueItem {
method: string;
target: object;
Expand All @@ -6,10 +8,17 @@ export interface QueueItem {
}

export interface DeferredActionQueues {
[index: string]: any;
[index: string]: unknown;
queues: object;
schedule(queueName: string, target: any, method: any, args: any, onceFlag: boolean, stack: any): any;
flush(fromAutorun: boolean): any;
schedule(
queueName: string,
target: unknown,
method: unknown,
args: unknown,
onceFlag: boolean,
stack: unknown
): unknown;
flush(fromAutorun: boolean): unknown;
}

export interface DebugInfo {
Expand All @@ -21,10 +30,10 @@ export interface DebugInfo {

export interface Backburner {
join<T>(fn: () => T): T;
on(...args: any[]): void;
scheduleOnce(...args: any[]): void;
on(...args: unknown[]): void;
scheduleOnce(...args: unknown[]): EmberRunTimer;
run<T>(fn: () => T): T;
schedule(queueName: string, target: object | null, method: (() => void) | string): void;
schedule(queueName: string, target: object | null, method: (() => void) | string): EmberRunTimer;
ensureInstance(): void;
DEBUG: boolean;
getDebugInfo(): DebugInfo;
Expand Down
35 changes: 35 additions & 0 deletions @types/@ember/utils/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/36809
export function typeOf(v: unknown): 'object' | 'undefined';

/**
* Compares two javascript values and returns:
*/
export function compare(v: unknown, w: unknown): number;

/**
* A value is blank if it is empty or a whitespace string.
*/
export function isBlank(obj?: unknown): boolean;

/**
* Verifies that a value is `null` or an empty string, empty array,
* or empty function.
*/
export function isEmpty(obj?: unknown): boolean;

/**
* Compares two objects, returning true if they are equal.
*/
export function isEqual(a: unknown, b: unknown): boolean;

/**
* Returns true if the passed value is null or undefined. This avoids errors
* from JSLint complaining about use of ==, which can be technically
* confusing.
*/
export function isNone(obj?: unknown): obj is null | undefined;

/**
* A value is present if it not `isBlank`.
*/
export function isPresent(obj?: unknown): boolean;
1 change: 1 addition & 0 deletions @types/@ember/version.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const VERSION: string;
3 changes: 3 additions & 0 deletions @types/@glimmer/tracking.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function cached(target: object, key: string, desc: PropertyDescriptor): void;

export function tracked(target: object, key: string): void;
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ declare global {
expectNoAssertion(callback: () => unknown): Promise<void>;
}

declare namespace QUnit {
namespace QUnit {
export interface Assert {
expectDeprecation(callback: () => unknown, options: DeprecationConfig | string | RegExp): Promise<void>;
expectNoDeprecation(callback: () => unknown): Promise<void>;
Expand All @@ -34,7 +34,7 @@ declare global {
}
}

declare interface QUnit {
interface QUnit {
assert: Assert;
}
}
Expand Down
9 changes: 9 additions & 0 deletions @types/ember/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import EmberArrayProtoExtensions from '@ember/array/types/prototype-extensions';

declare module 'ember' {
export function run(callback: Function);
export function meta(obj: Object): {
hasMixin(mixin: Object): boolean;
};
interface ArrayPrototypeExtensions<T> extends EmberArrayProtoExtensions<T> {}
}
13 changes: 13 additions & 0 deletions @types/fastboot/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
interface Request {
protocol: string;
host: string;
}
export interface FastBoot {
require(moduleName: string): unknown;
isFastBoot: boolean;
request: Request;
}

declare global {
const FastBoot: undefined | FastBoot;
}
3 changes: 3 additions & 0 deletions @types/require/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function (moduleName: string): unknown;

export function has(moduleName: string): boolean;
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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 CoreStore from '../system/core-store';
import type InternalModel from '../system/model/internal-model';
import type { JsonApiValidationError } from './record-data-json-api';
import type { AttributeSchema, RelationshipSchema, RelationshipsSchema } from './record-data-schemas';

// Placeholder until model.js is typed
export interface DSModel extends EmberObject {
constructor: DSModelSchema;
store: CoreStore;
store: Store;
errors: Errors;
_internalModel: InternalModel;
toString(): string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Dict } from '@ember-data/store/-private/ts-interfaces/utils';
import type { Dict } from '@ember-data/types/q/utils';

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

Expand All @@ -25,14 +25,10 @@ export interface Request {
options?: any;
}

export enum RequestStateEnum {
pending = 'pending',
fulfilled = 'fulfilled',
rejected = 'rejected',
}
export type RequestStates = 'pending' | 'fulfilled' | 'rejected';

export interface RequestState {
state: RequestStateEnum;
state: RequestStates;
type: 'query' | 'mutation';
request: Request;
response?: Response;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/**
@module @ember-data/store
*/

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

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

export type ResourceData = ResourceIdentifierObject | ExistingResourceObject;
export type IdentifierBucket = 'record';

// provided for additional debuggability
export const DEBUG_CLIENT_ORIGINATED: unique symbol = Symbol('record-originated-on-client');
export const DEBUG_IDENTIFIER_BUCKET: unique symbol = Symbol('identifier-bucket');

export interface Identifier {
lid: string;
clientId?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type Store from '../system/core-store';
import type AdapterPopulatedRecordArray from '../system/record-arrays/adapter-populated-record-array';
import type Snapshot from '../system/snapshot';
import type SnapshotRecordArray from '../system/snapshot-record-array';
import type { ModelSchema } from '../ts-interfaces/ds-model';
import type Store from '@ember-data/store';
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';
import type { Dict } from './utils';

Expand Down
Loading