@warp-drive/legacy 5.7.0-alpha.8 → 5.7.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/declarations/adapter/-private/build-url-mixin.d.ts +0 -13
  2. package/declarations/adapter/-private/utils/continue-on-reject.d.ts +1 -7
  3. package/declarations/adapter/-private/utils/serialize-query-params.d.ts +0 -4
  4. package/declarations/adapter/error.d.ts +0 -1
  5. package/declarations/adapter/rest.d.ts +0 -2
  6. package/declarations/adapter.d.ts +0 -5
  7. package/declarations/compat/builders/find-all.d.ts +2 -2
  8. package/declarations/compat/builders/query.d.ts +2 -2
  9. package/declarations/compat/builders/save-record.d.ts +3 -3
  10. package/declarations/compat/legacy-network-handler/fetch-manager.d.ts +24 -17
  11. package/declarations/compat/legacy-network-handler/identifier-has-id.d.ts +2 -2
  12. package/declarations/compat/legacy-network-handler/legacy-data-fetch.d.ts +5 -5
  13. package/declarations/compat/legacy-network-handler/minimum-adapter-interface.d.ts +3 -8
  14. package/declarations/compat/legacy-network-handler/snapshot-record-array.d.ts +40 -18
  15. package/declarations/compat/legacy-network-handler/snapshot.d.ts +63 -44
  16. package/declarations/compat.d.ts +3 -6
  17. package/declarations/model/-private/attr.d.ts +1 -14
  18. package/declarations/model/-private/belongs-to.d.ts +0 -11
  19. package/declarations/model/-private/debug/assert-polymorphic-type.d.ts +2 -14
  20. package/declarations/model/-private/errors.d.ts +0 -6
  21. package/declarations/model/-private/has-many.d.ts +0 -4
  22. package/declarations/model/-private/hooks.d.ts +2 -2
  23. package/declarations/model/-private/legacy-relationships-support.d.ts +18 -27
  24. package/declarations/model/-private/model-for-mixin.d.ts +0 -16
  25. package/declarations/model/-private/model-methods.d.ts +0 -4
  26. package/declarations/model/-private/model.d.ts +13 -69
  27. package/declarations/model/-private/notify-changes.d.ts +2 -2
  28. package/declarations/model/-private/promise-belongs-to.d.ts +0 -6
  29. package/declarations/model/-private/promise-many-array.d.ts +0 -11
  30. package/declarations/model/-private/record-state.d.ts +2 -25
  31. package/declarations/model/-private/references/belongs-to.d.ts +6 -7
  32. package/declarations/model/-private/references/has-many.d.ts +6 -13
  33. package/declarations/model/-private/schema-provider.d.ts +6 -10
  34. package/declarations/model/-private.d.ts +1 -2
  35. package/declarations/model/migration-support.d.ts +9 -33
  36. package/declarations/serializer/json-api.d.ts +0 -1
  37. package/declarations/serializer/json.d.ts +0 -1
  38. package/declarations/serializer/rest.d.ts +0 -1
  39. package/declarations/store/-private.d.ts +12 -24
  40. package/dist/{-private-CKrP0ogQ.js → -private-8UmnAf9J.js} +169 -141
  41. package/dist/adapter/-private.js +1 -1
  42. package/dist/adapter/json-api.js +1 -1
  43. package/dist/adapter/rest.js +1 -1
  44. package/dist/compat/-private.js +1 -1
  45. package/dist/compat/builders.js +3 -2
  46. package/dist/compat.js +7 -2
  47. package/dist/{errors-BX5wowuz.js → errors-8kD2mSe_.js} +66 -36
  48. package/dist/model/-private.js +1 -2
  49. package/dist/model/migration-support.js +7 -4
  50. package/dist/model.js +13 -11
  51. package/dist/{schema-provider-Cbnf6sKm.js → schema-provider-DQu4Rjco.js} +62 -26
  52. package/dist/{serialize-into-hash-Bp58npke.js → serialize-into-hash-CS0MIv4F.js} +2 -1
  53. package/dist/store.js +8 -6
  54. package/package.json +15 -15
@@ -1,5 +1,5 @@
1
1
  import type { ArrayValue, ObjectValue, PrimitiveValue } from "@warp-drive/core/types/json/raw";
2
- import type { TransformName } from "@warp-drive/core/types/symbols";
2
+ import { type TransformName } from "@warp-drive/core/types/symbols";
3
3
  import type { DecoratorPropertyDescriptor } from "./util.js";
4
4
  /**
5
5
  * Options provided to the attr decorator are
@@ -37,13 +37,6 @@ export type AttrOptions<DV = PrimitiveValue | object | unknown[]> = {
37
37
  */
38
38
  defaultValue?: DV extends PrimitiveValue ? DV : () => DV;
39
39
  };
40
- // NOTE: Usage of Explicit ANY
41
- // -------------------------------------------------------------------
42
- // any is required here because we are the maximal not the minimal
43
- // subset of options allowed. If we used unknown, object, or
44
- // Record<string, unknown> we would get type errors when we try to
45
- // assert against a more specific implementation with precise options.
46
- // -------------------------------------------------------------------
47
40
  type LooseTransformInstance<
48
41
  V,
49
42
  Raw,
@@ -53,15 +46,11 @@ type LooseTransformInstance<
53
46
  * value type must match the return type of the deserialize method
54
47
  *
55
48
  */
56
- // see note on Explicit ANY above
57
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
49
  serialize: (value: V, options: any) => Raw;
59
50
  /**
60
51
  * defaultValue type must match the return type of the deserialize method
61
52
  *
62
53
  */
63
- // see note on Explicit ANY above
64
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
54
  deserialize: (value: Raw, options: any) => V;
66
55
  [TransformName]: Name;
67
56
  };
@@ -72,8 +61,6 @@ export type TypedTransformInstance<
72
61
  V,
73
62
  T extends string
74
63
  > = LooseTransformInstance<V, string, T> | LooseTransformInstance<V, number, T> | LooseTransformInstance<V, boolean, T> | LooseTransformInstance<V, null, T> | LooseTransformInstance<V, ObjectValue, T> | LooseTransformInstance<V, ArrayValue, T> | LooseTransformInstance<V, string | null, T> | LooseTransformInstance<V, number | null, T> | LooseTransformInstance<V, boolean | null, T> | LooseTransformInstance<V, ObjectValue | null, T> | LooseTransformInstance<V, ArrayValue | null, T>;
75
- // see note on Explicit ANY above
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
64
  export type GetMaybeDeserializeValue<T> = T extends {
78
65
  deserialize: (...args: any[]) => unknown;
79
66
  } ? ReturnType<T["deserialize"]> : never;
@@ -12,13 +12,6 @@ export type RelationshipOptions<
12
12
  resetOnRemoteUpdate?: boolean;
13
13
  };
14
14
  export type NoNull<T> = Exclude<T, null>;
15
- // type BelongsToDecoratorObject<getT> = {
16
- // get: () => getT;
17
- // // set: (value: Awaited<getT>) => void;
18
- // set: (value: getT) => void;
19
- // // init: () => getT;
20
- // };
21
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
15
  export type RelationshipDecorator<T> = <This>(target: This, key: string, desc?: PropertyDescriptor) => void;
23
16
  /**
24
17
  `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None
@@ -179,8 +172,4 @@ type each record satisfies on both sides.
179
172
  export declare function belongsTo(): never;
180
173
  export declare function belongsTo(type: string): never;
181
174
  export declare function belongsTo<T>(type: TypeFromInstance<NoNull<T>>, options: RelationshipOptions<T, boolean>): RelationshipDecorator<T>;
182
- // export function belongsTo<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(
183
- // type: TypeFromInstance<NoNull<T>>,
184
- // options: RelationshipOptions<T, true>
185
- // ): RelationshipDecorator<K>;
186
175
  export declare function belongsTo(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;
@@ -1,17 +1,5 @@
1
1
  import type { Store } from "@warp-drive/core";
2
2
  import type { UpgradedMeta } from "@warp-drive/core/graph/-private";
3
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
4
- /*
5
- Assert that `addedRecord` has a valid type so it can be added to the
6
- relationship of the `record`.
7
-
8
- The assert basically checks if the `addedRecord` can be added to the
9
- relationship (specified via `relationshipMeta`) of the `record`.
10
-
11
- This utility should only be used internally, as both record parameters must
12
- be stable record identifiers and the `relationshipMeta` needs to be the meta
13
- information about the relationship, retrieved via
14
- `record.relationshipFor(key)`.
15
- */
16
- declare let assertPolymorphicType: (parentIdentifier: StableRecordIdentifier, parentDefinition: UpgradedMeta, addedIdentifier: StableRecordIdentifier, store: Store) => void;
3
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
4
+ declare let assertPolymorphicType: (parentIdentifier: ResourceKey, parentDefinition: UpgradedMeta, addedIdentifier: ResourceKey, store: Store) => void;
17
5
  export { assertPolymorphicType };
@@ -6,16 +6,10 @@ type ValidationError = {
6
6
  message: string;
7
7
  };
8
8
  interface ArrayProxyWithCustomOverrides<T> extends Omit<ArrayProxy<T>, "clear" | "content"> {
9
- // Omit causes `content` to be merged with the class def for ArrayProxy
10
- // which then causes it to be seen as a property, disallowing defining it
11
- // as an accessor. This restores our ability to define it as an accessor.
12
9
  content: NativeArray<T>;
13
10
  clear(): void;
14
11
  _has(name: string): boolean;
15
12
  }
16
- // we force the type here to our own construct because mixin and extend patterns
17
- // lose generic signatures. We also do this because we need to Omit `clear` from
18
- // the type of ArrayProxy as we override it's signature.
19
13
  declare const ArrayProxyWithCustomOverrides: new <T>() => ArrayProxyWithCustomOverrides<T>;
20
14
  /**
21
15
  Holds validation errors for a given record, organized by attribute names.
@@ -160,8 +160,4 @@ type each record satisfies on both sides.
160
160
  export declare function hasMany(): never;
161
161
  export declare function hasMany(type: string): never;
162
162
  export declare function hasMany<T>(type: TypeFromInstance<NoNull<T>>, options: RelationshipOptions<T, boolean>): RelationshipDecorator<T>;
163
- // export function hasMany<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(
164
- // type: TypeFromInstance<NoNull<T>>,
165
- // options: RelationshipOptions<T, true>
166
- // ): RelationshipDecorator<K>;
167
163
  export declare function hasMany(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;
@@ -1,8 +1,8 @@
1
1
  import { type Store } from "@warp-drive/core/store/-private";
2
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
2
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
3
3
  import type { TypeFromInstance } from "@warp-drive/core/types/record";
4
4
  import type { Model } from "./model.js";
5
- export declare function instantiateRecord(this: Store, identifier: StableRecordIdentifier, createRecordArgs: {
5
+ export declare function instantiateRecord(this: Store, identifier: ResourceKey, createRecordArgs: {
6
6
  [key: string]: unknown;
7
7
  }): Model;
8
8
  export declare function teardownRecord(record: Model): void;
@@ -1,9 +1,7 @@
1
1
  import type { Store } from "@warp-drive/core";
2
- import type { CollectionEdge, Graph, ResourceEdge, UpgradedMeta } from "@warp-drive/core/graph/-private";
3
- import type { LiveArray } from "@warp-drive/core/store/-private";
4
- import { RelatedCollection as ManyArray } from "@warp-drive/core/store/-private";
5
- import type { BaseFinderOptions, StableRecordIdentifier } from "@warp-drive/core/types";
6
- import type { Cache } from "@warp-drive/core/types/cache";
2
+ import type { CollectionEdge, ResourceEdge, UpgradedMeta } from "@warp-drive/core/graph/-private";
3
+ import type { LegacyManyArray } from "@warp-drive/core/store/-private";
4
+ import type { BaseFinderOptions, ResourceKey } from "@warp-drive/core/types";
7
5
  import type { CollectionRelationship } from "@warp-drive/core/types/cache/relationship";
8
6
  import type { LocalRelationshipOperation } from "@warp-drive/core/types/graph";
9
7
  import type { OpaqueRecordInstance, TypeFromInstanceOrString } from "@warp-drive/core/types/record";
@@ -15,33 +13,26 @@ import type { HasManyProxyCreateArgs } from "./promise-many-array.js";
15
13
  import { PromiseManyArray } from "./promise-many-array.js";
16
14
  import BelongsToReference from "./references/belongs-to.js";
17
15
  import HasManyReference from "./references/has-many.js";
18
- export declare const LEGACY_SUPPORT: Map<StableRecordIdentifier | MinimalLegacyRecord, LegacySupport>;
16
+ export declare const LEGACY_SUPPORT: Map<ResourceKey | MinimalLegacyRecord, LegacySupport>;
19
17
  export declare function lookupLegacySupport(record: MinimalLegacyRecord): LegacySupport;
18
+ /**
19
+ * @hideconstructor
20
+ */
20
21
  export declare class LegacySupport {
21
- record: MinimalLegacyRecord;
22
- store: Store;
23
- graph: Graph;
24
- cache: Cache;
25
- references: Record<string, BelongsToReference | HasManyReference>;
26
- identifier: StableRecordIdentifier;
27
- _manyArrayCache: Record<string, ManyArray>;
28
- _relationshipPromisesCache: Record<string, Promise<ManyArray | OpaqueRecordInstance>>;
29
- _relationshipProxyCache: Record<string, PromiseManyArray | PromiseBelongsTo | undefined>;
30
- _pending: Record<string, Promise<StableRecordIdentifier | null> | undefined>;
31
- isDestroying: boolean;
32
- isDestroyed: boolean;
33
- constructor(record: MinimalLegacyRecord);
34
- _syncArray(array: LiveArray): void;
22
+ identifier: ResourceKey;
23
+ constructor(record: MinimalLegacyRecord, identifier: ResourceKey);
24
+ /** @private */
25
+ _syncArray(array: LegacyManyArray): void;
35
26
  mutate(mutation: LocalRelationshipOperation): void;
36
27
  _findBelongsTo(key: string, resource: SingleResourceRelationship, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
37
28
  reloadBelongsTo(key: string, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null>;
38
29
  getBelongsTo(key: string, options?: BaseFinderOptions): PromiseBelongsTo | OpaqueRecordInstance | null;
39
30
  setDirtyBelongsTo(key: string, value: OpaqueRecordInstance | null): void;
40
- _getCurrentState<T>(identifier: StableRecordIdentifier, field: string): [StableRecordIdentifier<TypeFromInstanceOrString<T>>[], CollectionRelationship];
41
- getManyArray<T>(key: string, definition?: UpgradedMeta): ManyArray<T>;
42
- fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray: ManyArray, options?: BaseFinderOptions): Promise<ManyArray>;
43
- reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<ManyArray<T>> | PromiseManyArray<T>;
44
- getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | ManyArray;
31
+ _getCurrentState<T>(identifier: ResourceKey, field: string): [ResourceKey<TypeFromInstanceOrString<T>>[], CollectionRelationship];
32
+ getManyArray<T>(key: string, definition?: UpgradedMeta): LegacyManyArray<T>;
33
+ fetchAsyncHasMany(key: string, relationship: CollectionEdge, manyArray: LegacyManyArray, options?: BaseFinderOptions): Promise<LegacyManyArray>;
34
+ reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<LegacyManyArray<T>> | PromiseManyArray<T>;
35
+ getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | LegacyManyArray;
45
36
  _updatePromiseProxyFor(kind: "hasMany", key: string, args: HasManyProxyCreateArgs): PromiseManyArray;
46
37
  _updatePromiseProxyFor(kind: "belongsTo", key: string, args: BelongsToProxyCreateArgs): PromiseBelongsTo;
47
38
  _updatePromiseProxyFor(kind: "belongsTo", key: string, args: {
@@ -49,8 +40,8 @@ export declare class LegacySupport {
49
40
  }): PromiseBelongsTo;
50
41
  referenceFor(kind: "belongsTo", name: string): BelongsToReference;
51
42
  referenceFor(kind: "hasMany", name: string): HasManyReference;
52
- _findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
53
- _findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: StableRecordIdentifier, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<StableRecordIdentifier | null>;
43
+ _findHasManyByJsonApiResource(resource: CollectionResourceRelationship, parentIdentifier: ResourceKey, relationship: CollectionEdge, options?: BaseFinderOptions): Promise<void | unknown[]> | void;
44
+ _findBelongsToByJsonApiResource(resource: SingleResourceRelationship, parentIdentifier: ResourceKey, relationship: ResourceEdge, options?: BaseFinderOptions): Promise<ResourceKey | null>;
54
45
  destroy(): void;
55
46
  }
56
47
  export declare function areAllInverseRecordsLoaded(store: Store, resource: InnerRelationshipDocument): boolean;
@@ -1,19 +1,3 @@
1
1
  import type { Store } from "@warp-drive/core";
2
2
  import { type ModelFactory } from "./model.js";
3
- /*
4
- In case someone defined a relationship to a mixin, for example:
5
- ```ts
6
- class CommentModel extends Model {
7
- @belongsTo('commentable', { polymorphic: true }) owner;
8
- }
9
-
10
- let Commentable = Mixin.create({
11
- @hasMany('comment') comments;
12
- });
13
- ```
14
- we want to look up a Commentable class which has all the necessary
15
- relationship meta data. Thus, we look up the mixin and create a mock
16
- Model, so we can access the relationship CPs of the mixin (`comments`)
17
- in this case
18
- */
19
3
  export default function modelForMixin(store: Store, normalizedModelName: string): ModelFactory | undefined;
@@ -1,6 +1,4 @@
1
- import type { Store } from "@warp-drive/core";
2
1
  import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
3
- import { RecordStore } from "@warp-drive/core/types/symbols";
4
2
  import type { Snapshot } from "../../compat/-private.js";
5
3
  import type { Errors } from "./errors.js";
6
4
  import type RecordState from "./record-state.js";
@@ -9,13 +7,11 @@ import type HasManyReference from "./references/has-many.js";
9
7
  import type { MaybeBelongsToFields, MaybeHasManyFields } from "./type-utils.js";
10
8
  export interface MinimalLegacyRecord {
11
9
  errors: Errors;
12
- ___recordState: RecordState;
13
10
  currentState: RecordState;
14
11
  isDestroyed: boolean;
15
12
  isDestroying: boolean;
16
13
  isReloading: boolean;
17
14
  isValid: boolean;
18
- [RecordStore]: Store;
19
15
  deleteRecord(): void;
20
16
  unloadRecord(): void;
21
17
  save<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<this>;
@@ -1,9 +1,8 @@
1
1
  import EmberObject from "@ember/object";
2
2
  import type { Store } from "@warp-drive/core";
3
- import type { ModelSchema, StableRecordIdentifier } from "@warp-drive/core/types";
4
- import type { Cache, ChangedAttributesHash } from "@warp-drive/core/types/cache";
3
+ import type { ModelSchema, ResourceKey } from "@warp-drive/core/types";
4
+ import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
5
5
  import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
6
- import { RecordStore } from "@warp-drive/core/types/symbols";
7
6
  import type { Snapshot } from "../../compat/-private.js";
8
7
  import { Errors } from "./errors.js";
9
8
  import type { MinimalLegacyRecord } from "./model-methods.js";
@@ -13,12 +12,10 @@ import type HasManyReference from "./references/has-many.js";
13
12
  import type { _MaybeBelongsToFields, isSubClass, MaybeAttrFields, MaybeHasManyFields, MaybeRelationshipFields } from "./type-utils.js";
14
13
  export type ModelCreateArgs = {
15
14
  _createProps: Record<string, unknown>;
16
- // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for
17
15
  _secretInit: {
18
- identifier: StableRecordIdentifier;
19
- cache: Cache;
16
+ identifier: ResourceKey;
20
17
  store: Store;
21
- cb: (record: Model, cache: Cache, identifier: StableRecordIdentifier, store: Store) => void;
18
+ cb: (record: Model, identifier: ResourceKey, store: Store) => void;
22
19
  };
23
20
  };
24
21
  export type StaticModel = typeof Model & {
@@ -28,8 +25,6 @@ export type ModelFactory = {
28
25
  class: StaticModel;
29
26
  };
30
27
  export type FactoryCache = Record<string, ModelFactory>;
31
- // we put this on the store for interop because it's used by modelFor and
32
- // instantiateRecord as well.
33
28
  export type ModelStore = Store & {
34
29
  _modelFactoryCache: FactoryCache;
35
30
  };
@@ -37,19 +32,10 @@ export type ModelStore = Store & {
37
32
  * @noInheritDoc
38
33
  */
39
34
  interface Model {
40
- // set during create by the store
41
35
  /**
42
36
  * The store service instance which created this record instance
43
37
  */
44
38
  store: Store;
45
- /** @internal */
46
- ___recordState: RecordState;
47
- /** @internal */
48
- ___private_notifications: object;
49
- /** @internal */
50
- _isReloading: boolean;
51
- /** @internal */
52
- [RecordStore]: Store;
53
39
  /**
54
40
  Create a JSON representation of the record, using the serialization
55
41
  strategy of the store's adapter.
@@ -179,7 +165,6 @@ interface Model {
179
165
  @public
180
166
  */
181
167
  rollbackAttributes<T extends MinimalLegacyRecord>(this: T): void;
182
- // TODO @deprecate in favor of a public API or examples of how to test successfully
183
168
  /**
184
169
  @private
185
170
  */
@@ -251,10 +236,6 @@ interface Model {
251
236
  with an error.
252
237
  */
253
238
  reload<T extends MinimalLegacyRecord>(this: T, options?: Record<string, unknown>): Promise<T>;
254
- // belongsTo<T extends MinimalLegacyRecord, K extends MaybeBelongsToFields<T>>(
255
- // this: T,
256
- // prop: K
257
- // ): BelongsToReference<T, K>;
258
239
  /**
259
240
  Get the reference for the specified belongsTo relationship.
260
241
 
@@ -436,10 +417,7 @@ interface Model {
436
417
  * @noInheritDoc
437
418
  */
438
419
  declare class Model extends EmberObject implements MinimalLegacyRecord {
439
- /** @internal */
440
- init(options: ModelCreateArgs): void;
441
- /** @internal */
442
- // @ts-expect-error destroy should not return a value, but ember's types force it to
420
+ /** @private */
443
421
  destroy(): this;
444
422
  /**
445
423
  If this property is `true` the record is in the `empty`
@@ -689,8 +667,6 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
689
667
  @property currentState
690
668
  @private
691
669
  */
692
- // TODO we can probably make this a computeOnce
693
- // we likely do not need to notify the currentState root anymore
694
670
  get currentState(): RecordState;
695
671
  set currentState(_v: RecordState);
696
672
  /**
@@ -760,18 +736,7 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
760
736
  */
761
737
  get adapterError(): unknown;
762
738
  set adapterError(v: unknown);
763
- /*
764
- We hook the default implementation to ensure
765
- our tagged properties are properly notified
766
- as well. We still super for everything because
767
- sync observers require a direct call occuring
768
- to trigger their flush. We wouldn't need to
769
- super in 4.0+ where sync observers are removed.
770
- */
771
- // @ts-expect-error no return is necessary, but Ember's types are forcing it
772
739
  notifyPropertyChange(prop: string): this;
773
- /** @internal */
774
- attr(): void;
775
740
  /**
776
741
  Given a callback, iterates over each of the relationships in the model,
777
742
  invoking the callback with the name of each relationship and its relationship
@@ -821,18 +786,14 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
821
786
  ```
822
787
 
823
788
  @public
824
- @param {Function} callback the callback to invoke
825
- @param {any} binding the value to which the callback's `this` should be bound
789
+ @param callback the callback to invoke
790
+ @param binding the value to which the callback's `this` should be bound
826
791
  */
827
792
  eachRelationship<T>(callback: (this: NoInfer<T> | undefined, key: MaybeRelationshipFields<this>, meta: LegacyRelationshipField) => void, binding?: T): void;
828
793
  relationshipFor(name: string): LegacyRelationshipField | undefined;
829
794
  inverseFor(name: string): LegacyRelationshipField | null;
830
795
  eachAttribute<T>(callback: (this: NoInfer<T> | undefined, key: isSubClass<this> extends true ? MaybeAttrFields<this> : string, meta: LegacyAttributeField) => void, binding?: T): void;
831
796
  /**
832
- * @internal
833
- */
834
- static isModel: boolean;
835
- /**
836
797
  Represents the model's class name as a string. This can be used to look up the model's class name through
837
798
  `Store`'s modelFor method.
838
799
 
@@ -862,22 +823,6 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
862
823
  @readonly
863
824
  */
864
825
  static modelName: string;
865
- /*
866
- These class methods below provide relationship
867
- introspection abilities about relationships.
868
-
869
- A note about the computed properties contained here:
870
-
871
- **These properties are effectively sealed once called for the first time.**
872
- To avoid repeatedly doing expensive iteration over a model's fields, these
873
- values are computed once and then cached for the remainder of the runtime of
874
- your application.
875
-
876
- If your application needs to modify a class after its initial definition
877
- (for example, using `reopen()` to add additional attributes), make sure you
878
- do it before using your model with the store, which uses these properties
879
- extensively.
880
- */
881
826
  /**
882
827
  For a given relationship name, returns the model type of the relationship.
883
828
 
@@ -894,9 +839,9 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
894
839
  Calling `store.modelFor('post').typeForRelationship('comments', store)` will return `Comment`.
895
840
 
896
841
  @public
897
- @param {String} name the name of the relationship
898
- @param {store} store an instance of Store
899
- @return {Model} the type of the relationship, or undefined
842
+ @param name the name of the relationship
843
+ @param store an instance of Store
844
+ @return the type of the relationship, or undefined
900
845
  */
901
846
  static typeForRelationship(name: string, store: Store): ModelSchema | undefined;
902
847
  static get inverseMap(): Record<string, LegacyRelationshipField | null>;
@@ -927,12 +872,11 @@ declare class Model extends EmberObject implements MinimalLegacyRecord {
927
872
  ```
928
873
 
929
874
  @public
930
- @param {String} name the name of the relationship
931
- @param {Store} store
932
- @return {Object} the inverse relationship, or null
875
+ @param name the name of the relationship
876
+ @param store
877
+ @return the inverse relationship, or null
933
878
  */
934
879
  static inverseFor(name: string, store: Store): LegacyRelationshipField | null;
935
- //Calculate the inverse, ignoring the cache
936
880
  static _findInverseFor(name: string, store: Store): LegacyRelationshipField | null;
937
881
  /**
938
882
  The model's relationships as a map, keyed on the type of the
@@ -1,4 +1,4 @@
1
1
  import type { NotificationType, Store } from "@warp-drive/core";
2
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
2
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
3
3
  import type { Model } from "./model.js";
4
- export default function notifyChanges(identifier: StableRecordIdentifier, value: NotificationType, key: string | undefined, record: Model, store: Store): void;
4
+ export default function notifyChanges(identifier: ResourceKey, value: NotificationType, key: string | undefined, record: Model, store: Store): void;
@@ -16,13 +16,10 @@ export interface BelongsToProxyCreateArgs<T = unknown> {
16
16
  }
17
17
  export declare const LegacyPromiseProxy: unique symbol;
18
18
  interface PromiseObjectType<T> extends PromiseProxyMixin<T | null>, ObjectProxy<T> {
19
- // eslint-disable-next-line @typescript-eslint/no-misused-new
20
19
  new <PT>(...args: unknown[]): PromiseObjectType<PT>;
21
20
  }
22
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-extraneous-class
23
21
  declare class PromiseObjectType<T> {}
24
22
  declare const Extended: PromiseObjectType<OpaqueRecordInstance>;
25
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
23
  interface PromiseBelongsTo<T> {
27
24
  [LegacyPromiseProxy]: true;
28
25
  }
@@ -37,9 +34,6 @@ Right now we proxy:
37
34
  declare class PromiseBelongsTo<T = unknown> extends Extended<T> {
38
35
  _belongsToState: BelongsToProxyMeta<T>;
39
36
  get id(): string | null;
40
- // we don't proxy meta because we would need to proxy it to the relationship state container
41
- // however, meta on relationships does not trigger change notifications.
42
- // if you need relationship meta, you should do `record.belongsTo(relationshipName).meta()`
43
37
  get meta(): void;
44
38
  reload(options: Record<string, unknown>): Promise<this>;
45
39
  }
@@ -6,7 +6,6 @@ export interface HasManyProxyCreateArgs<T = unknown> {
6
6
  promise: Promise<ManyArray<T>>;
7
7
  content?: ManyArray<T>;
8
8
  }
9
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
10
9
  export interface PromiseManyArray<T> {
11
10
  [LegacyPromiseProxy]: true;
12
11
  }
@@ -37,10 +36,6 @@ export declare class PromiseManyArray<T = unknown> {
37
36
  * @public
38
37
  */
39
38
  get length(): number;
40
- // this will error if someone tries to call
41
- // A(identifierArray) since it is not configurable
42
- // which is preferrable to the `meta` override we used
43
- // before which required importing all of Ember
44
39
  get "[]"(): 0 | ManyArray<T> | undefined;
45
40
  /**
46
41
  * Iterate the proxied content. Called by the glimmer iterator in #each
@@ -59,7 +54,6 @@ export declare class PromiseManyArray<T = unknown> {
59
54
  * @return
60
55
  */
61
56
  reload(options: Omit<BaseFinderOptions, "">): this;
62
- //---- Properties/Methods from the PromiseProxyMixin that we will keep as our API
63
57
  /**
64
58
  * Whether the loading promise is still pending
65
59
  *
@@ -113,9 +107,7 @@ export declare class PromiseManyArray<T = unknown> {
113
107
  * @return {Promise}
114
108
  */
115
109
  finally(cb: Parameters<Promise<ManyArray<T>>["finally"]>[0]): Promise<unknown>;
116
- //---- Methods on EmberObject that we should keep
117
110
  destroy(): void;
118
- //---- Methods/Properties on ManyArray that we own and proxy to
119
111
  /**
120
112
  * Retrieve the links for this relationship
121
113
  * @property links
@@ -128,8 +120,5 @@ export declare class PromiseManyArray<T = unknown> {
128
120
  * @public
129
121
  */
130
122
  get meta(): Record<string, unknown> | null | undefined;
131
- //---- Our own stuff
132
- /** @internal */
133
- _update(promise: Promise<ManyArray<T>>, content?: ManyArray<T>): void;
134
123
  static create<T>({ promise, content }: HasManyProxyCreateArgs<T>): PromiseManyArray<T>;
135
124
  }
@@ -1,8 +1,3 @@
1
- import type { Store } from "@warp-drive/core";
2
- import type { RequestCacheRequestState, RequestStateService } from "@warp-drive/core/store/-private";
3
- import type { Cache } from "@warp-drive/core/types/cache";
4
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
5
- import type { Errors } from "./errors.js";
6
1
  import type { MinimalLegacyRecord } from "./model-methods.js";
7
2
  /**
8
3
  Historically EmberData managed a state machine
@@ -41,29 +36,11 @@ uncommitted
41
36
  invalid
42
37
  inFlight
43
38
 
44
- @internal
39
+ @hideconstructor
40
+ @private
45
41
  */
46
42
  export default class RecordState {
47
- store: Store;
48
- identifier: StableRecordIdentifier;
49
- record: MinimalLegacyRecord;
50
- rs: RequestStateService;
51
- pendingCount: number;
52
- fulfilledCount: number;
53
- rejectedCount: number;
54
- cache: Cache;
55
- _errorRequests: RequestCacheRequestState[];
56
- _lastError: RequestCacheRequestState | null;
57
- handler: object;
58
43
  constructor(record: MinimalLegacyRecord);
59
- /** @internal */
60
- destroy(): void;
61
- /** @internal */
62
- notify(key: keyof this & string): void;
63
- /** @internal */
64
- updateInvalidErrors(errors: Errors): void;
65
- /** @internal */
66
- cleanErrorRequests(): void;
67
44
  isSaving: boolean;
68
45
  get isLoading(): boolean;
69
46
  get isLoaded(): boolean;
@@ -1,6 +1,6 @@
1
1
  import type { Store } from "@warp-drive/core";
2
2
  import type { Graph, ResourceEdge } from "@warp-drive/core/graph/-private";
3
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
3
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
4
4
  import type { TypeFromInstance, TypeFromInstanceOrString } from "@warp-drive/core/types/record";
5
5
  import type { Links, Meta, SingleResourceDocument, SingleResourceRelationship } from "@warp-drive/core/types/spec/json-api-raw";
6
6
  import type { IsUnknown } from "../belongs-to.js";
@@ -57,22 +57,21 @@ export default class BelongsToReference<
57
57
  * @public
58
58
  */
59
59
  type: TypeFromInstanceOrString<Related>;
60
- // unsubscribe tokens given to us by the notification manager
61
60
  ___token: object;
62
- ___identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>;
61
+ ___identifier: ResourceKey<TypeFromInstanceOrString<T>>;
63
62
  ___relatedToken: object | null;
64
63
  _ref: number;
65
- constructor(store: Store, graph: Graph, parentIdentifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>, belongsToRelationship: ResourceEdge, key: K);
64
+ constructor(store: Store, graph: Graph, parentIdentifier: ResourceKey<TypeFromInstanceOrString<T>>, belongsToRelationship: ResourceEdge, key: K);
66
65
  destroy(): void;
67
66
  /**
68
67
  * The identifier of the record that this reference refers to.
69
68
  * `null` if no related record is known.
70
69
  *
71
70
  * @property identifier
72
- * @type {StableRecordIdentifier | null}
71
+ * @type {ResourceKey | null}
73
72
  * @public
74
73
  */
75
- get identifier(): StableRecordIdentifier<TypeFromInstanceOrString<Related>> | null;
74
+ get identifier(): ResourceKey<TypeFromInstanceOrString<Related>> | null;
76
75
  /**
77
76
  The `id` of the record that this reference refers to. Together, the
78
77
  `type()` and `id()` methods form a composite key for the identity
@@ -198,7 +197,7 @@ export default class BelongsToReference<
198
197
  @return {Object} The meta information for the belongs-to relationship.
199
198
  */
200
199
  meta(): Meta | null;
201
- _resource(): SingleResourceRelationship<StableRecordIdentifier<TypeFromInstance<Related>>>;
200
+ _resource(): SingleResourceRelationship<ResourceKey<TypeFromInstance<Related>>>;
202
201
  /**
203
202
  This returns a string that represents how the reference will be
204
203
  looked up when it is loaded. If the relationship has a link it will
@@ -2,7 +2,7 @@ import type { Store } from "@warp-drive/core";
2
2
  import type { CollectionEdge, Graph } from "@warp-drive/core/graph/-private";
3
3
  import type { RelatedCollection as ManyArray } from "@warp-drive/core/store/-private";
4
4
  import type { BaseFinderOptions } from "@warp-drive/core/types";
5
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
5
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
6
6
  import type { TypeFromInstanceOrString } from "@warp-drive/core/types/record";
7
7
  import type { CollectionResourceDocument, CollectionResourceRelationship, ExistingResourceObject, LinkObject, Meta, PaginationLinks } from "@warp-drive/core/types/spec/json-api-raw";
8
8
  import type { IsUnknown } from "../belongs-to.js";
@@ -66,26 +66,19 @@ export default class HasManyReference<
66
66
  * @public
67
67
  */
68
68
  type: TypeFromInstanceOrString<Related>;
69
- // unsubscribe tokens given to us by the notification manager
70
69
  ___token: object;
71
- ___identifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>;
72
- ___relatedTokenMap: Map<StableRecordIdentifier, object>;
70
+ ___identifier: ResourceKey<TypeFromInstanceOrString<T>>;
71
+ ___relatedTokenMap: Map<ResourceKey, object>;
73
72
  _ref: number;
74
- constructor(store: Store, graph: Graph, parentIdentifier: StableRecordIdentifier<TypeFromInstanceOrString<T>>, hasManyRelationship: CollectionEdge, key: K);
75
- /**
76
- * This method should never be called by user code.
77
- *
78
- * @internal
79
- */
80
- destroy(): void;
73
+ constructor(store: Store, graph: Graph, parentIdentifier: ResourceKey<TypeFromInstanceOrString<T>>, hasManyRelationship: CollectionEdge, key: K);
81
74
  /**
82
75
  * An array of identifiers for the records that this reference refers to.
83
76
  *
84
77
  * @property identifiers
85
- * @type {StableRecordIdentifier[]}
78
+ * @type {ResourceKey[]}
86
79
  * @public
87
80
  */
88
- get identifiers(): StableRecordIdentifier<TypeFromInstanceOrString<Related>>[];
81
+ get identifiers(): ResourceKey<TypeFromInstanceOrString<Related>>[];
89
82
  _resource(): CollectionResourceRelationship;
90
83
  /**
91
84
  This returns a string that represents how the reference will be