@warp-drive/legacy 5.7.0-alpha.9 → 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,6 +1,6 @@
1
1
  import type { Store } from "@warp-drive/core";
2
2
  import type { SchemaService } from "@warp-drive/core/types";
3
- import type { RecordIdentifier, StableRecordIdentifier } from "@warp-drive/core/types/identifier";
3
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
4
4
  import type { ObjectValue } from "@warp-drive/core/types/json/raw";
5
5
  import type { Derivation, HashFn, Transformation } from "@warp-drive/core/types/schema/concepts";
6
6
  import type { ArrayField, DerivedField, GenericField, HashField, LegacyField, ObjectField, ObjectSchema, ResourceSchema } from "@warp-drive/core/types/schema/fields";
@@ -8,22 +8,19 @@ import type { ModelFactory, ModelStore } from "./model.js";
8
8
  type AttributesSchema = ReturnType<Exclude<SchemaService["attributesDefinitionFor"], undefined>>;
9
9
  type RelationshipsSchema = ReturnType<Exclude<SchemaService["relationshipsDefinitionFor"], undefined>>;
10
10
  export interface ModelSchemaProvider {
11
- attributesDefinitionFor(resource: RecordIdentifier | {
11
+ attributesDefinitionFor(resource: ResourceKey | {
12
12
  type: string;
13
13
  }): AttributesSchema;
14
- relationshipsDefinitionFor(resource: RecordIdentifier | {
14
+ relationshipsDefinitionFor(resource: ResourceKey | {
15
15
  type: string;
16
16
  }): RelationshipsSchema;
17
17
  doesTypeExist(type: string): boolean;
18
18
  }
19
19
  export declare class ModelSchemaProvider implements SchemaService {
20
- private store;
21
- private _schemas;
22
- private _typeMisses;
23
20
  constructor(store: ModelStore);
24
21
  resourceTypes(): Readonly<string[]>;
25
22
  hasTrait(type: string): boolean;
26
- resourceHasTrait(resource: StableRecordIdentifier | {
23
+ resourceHasTrait(resource: ResourceKey | {
27
24
  type: string;
28
25
  }, trait: string): boolean;
29
26
  transformation(field: GenericField | ObjectField | ArrayField | {
@@ -35,7 +32,7 @@ export declare class ModelSchemaProvider implements SchemaService {
35
32
  hashFn(field: HashField | {
36
33
  type: string;
37
34
  }): HashFn;
38
- resource(resource: StableRecordIdentifier | {
35
+ resource(resource: ResourceKey | {
39
36
  type: string;
40
37
  }): ResourceSchema | ObjectSchema;
41
38
  registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
@@ -47,8 +44,7 @@ export declare class ModelSchemaProvider implements SchemaService {
47
44
  FM extends ObjectValue | null
48
45
  >(derivation: Derivation<R, T, FM>): void;
49
46
  registerHashFn(hashFn: HashFn): void;
50
- private _loadModelSchema;
51
- fields(resource: RecordIdentifier | {
47
+ fields(resource: ResourceKey | {
52
48
  type: string;
53
49
  }): Map<string, LegacyField>;
54
50
  hasResource(resource: {
@@ -1,9 +1,8 @@
1
1
  export { type MinimalLegacyRecord } from "./-private/model-methods.js";
2
2
  export type { ModelStore } from "./-private/model.js";
3
3
  export { Errors } from "./-private/errors.js";
4
- export { RelatedCollection as ManyArray } from "@warp-drive/core/store/-private";
4
+ export type { LegacyManyArray as ManyArray } from "@warp-drive/core/store/-private";
5
5
  export { PromiseBelongsTo } from "./-private/promise-belongs-to.js";
6
6
  export { PromiseManyArray } from "./-private/promise-many-array.js";
7
- // // Used by tests, migration support
8
7
  export { lookupLegacySupport, LEGACY_SUPPORT } from "./-private/legacy-relationships-support.js";
9
8
  export type { MaybeHasManyFields, MaybeBelongsToFields, MaybeRelationshipFields } from "./-private/type-utils.js";
@@ -3,7 +3,7 @@ import type { CAUTION_MEGA_DANGER_ZONE_Extension, ProcessedExtension } from "@wa
3
3
  import type { ExtensibleField } from "@warp-drive/core/reactive/-private/schema";
4
4
  import type { SchemaService } from "@warp-drive/core/types";
5
5
  import type { ChangedAttributesHash } from "@warp-drive/core/types/cache";
6
- import type { StableRecordIdentifier } from "@warp-drive/core/types/identifier";
6
+ import type { ResourceKey } from "@warp-drive/core/types/identifier";
7
7
  import type { ObjectValue } from "@warp-drive/core/types/json/raw";
8
8
  import type { TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
9
9
  import type { Derivation, HashFn, Transformation } from "@warp-drive/core/types/schema/concepts";
@@ -198,10 +198,10 @@ export declare function registerDerivations(schema: SchemaService): void;
198
198
  * @public
199
199
  */
200
200
  export interface DelegatingSchemaService {
201
- attributesDefinitionFor?(resource: StableRecordIdentifier | {
201
+ attributesDefinitionFor?(resource: ResourceKey | {
202
202
  type: string;
203
203
  }): AttributesSchema;
204
- relationshipsDefinitionFor?(resource: StableRecordIdentifier | {
204
+ relationshipsDefinitionFor?(resource: ResourceKey | {
205
205
  type: string;
206
206
  }): RelationshipsSchema;
207
207
  doesTypeExist?(type: string): boolean;
@@ -210,18 +210,18 @@ export declare class DelegatingSchemaService implements SchemaService {
210
210
  _preferred: SchemaService;
211
211
  _secondary: SchemaService;
212
212
  constructor(store: Store, schema: SchemaService);
213
- isDelegated(resource: StableRecordIdentifier | {
213
+ isDelegated(resource: ResourceKey | {
214
214
  type: string;
215
215
  }): boolean;
216
216
  resourceTypes(): Readonly<string[]>;
217
- hasResource(resource: StableRecordIdentifier | {
217
+ hasResource(resource: ResourceKey | {
218
218
  type: string;
219
219
  }): boolean;
220
220
  hasTrait(type: string): boolean;
221
- resourceHasTrait(resource: StableRecordIdentifier | {
221
+ resourceHasTrait(resource: ResourceKey | {
222
222
  type: string;
223
223
  }, trait: string): boolean;
224
- fields(resource: StableRecordIdentifier | {
224
+ fields(resource: ResourceKey | {
225
225
  type: string;
226
226
  }): Map<string, FieldSchema>;
227
227
  transformation(field: GenericField | ObjectField | ArrayField | {
@@ -233,7 +233,7 @@ export declare class DelegatingSchemaService implements SchemaService {
233
233
  derivation(field: DerivedField | {
234
234
  type: string;
235
235
  }): Derivation;
236
- resource(resource: StableRecordIdentifier | {
236
+ resource(resource: ResourceKey | {
237
237
  type: string;
238
238
  }): ResourceSchema | ObjectSchema;
239
239
  registerResources(schemas: Array<ResourceSchema | ObjectSchema>): void;
@@ -246,34 +246,10 @@ export declare class DelegatingSchemaService implements SchemaService {
246
246
  >(derivation: Derivation<R, T, FM>): void;
247
247
  registerHashFn(hashFn: HashFn): void;
248
248
  CAUTION_MEGA_DANGER_ZONE_registerExtension(extension: CAUTION_MEGA_DANGER_ZONE_Extension): void;
249
- CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: StableRecordIdentifier | {
249
+ CAUTION_MEGA_DANGER_ZONE_resourceExtensions(resource: ResourceKey | {
250
250
  type: string;
251
251
  }): null | ProcessedExtension["features"];
252
252
  CAUTION_MEGA_DANGER_ZONE_objectExtensions(field: ExtensibleField, resolvedType: string | null): null | ProcessedExtension["features"];
253
253
  CAUTION_MEGA_DANGER_ZONE_arrayExtensions(field: ExtensibleField): null | ProcessedExtension["features"];
254
- /**
255
- * This is an internal method used to register behaviors for legacy mode.
256
- * It is not intended for public use.
257
- *
258
- * We do think a generalized `kind` registration system would be useful,
259
- * but we have not yet designed it.
260
- *
261
- * See https://github.com/emberjs/data/issues/9534
262
- *
263
- * @internal
264
- */
265
- _registerMode(mode: string, kinds: unknown): void;
266
- /**
267
- * This is an internal method used to enable legacy behaviors for legacy mode.
268
- * It is not intended for public use.
269
- *
270
- * We do think a generalized `kind` registration system would be useful,
271
- * but we have not yet designed it.
272
- *
273
- * See https://github.com/emberjs/data/issues/9534
274
- *
275
- * @internal
276
- */
277
- _kind(mode: string, kind: "belongsTo" | "hasMany"): () => unknown;
278
254
  }
279
255
  export {};
@@ -121,6 +121,5 @@ return normalizedRelationship;
121
121
  @class JSONAPISerializer
122
122
  @public
123
123
  */
124
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
125
124
  declare const JSONAPISerializer: any;
126
125
  export { JSONAPISerializer };
@@ -73,6 +73,5 @@ turn the record payload into the JSON API format.
73
73
  @class JSONSerializer
74
74
  @public
75
75
  */
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
76
  declare const JSONSerializer: any;
78
77
  export { JSONSerializer };
@@ -48,7 +48,6 @@ the method (`serialize` or `deserialize`) as the third parameter.
48
48
  @class RESTSerializer
49
49
  @public
50
50
  */
51
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
51
  declare const RESTSerializer: any;
53
52
  export { EmbeddedRecordsMixin } from "./-private/embedded-records-mixin.js";
54
53
  export { RESTSerializer };
@@ -1,18 +1,18 @@
1
1
  import { type InstanceCache } from "@warp-drive/core/store/-private";
2
- import type { StableNewRecordIdentifier, StableRecordIdentifier } from "@warp-drive/core/types/identifier";
2
+ import type { NewResourceKey, ResourceKey } from "@warp-drive/core/types/identifier";
3
3
  import type { Value } from "@warp-drive/core/types/json/raw";
4
- import type { Includes, OpaqueRecordInstance, TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
4
+ import type { OpaqueRecordInstance, TypedRecordInstance, TypeFromInstance } from "@warp-drive/core/types/record";
5
5
  import type { LegacyAttributeField, LegacyRelationshipField } from "@warp-drive/core/types/schema/fields";
6
6
  import type { SingleResourceDocument } from "@warp-drive/core/types/spec/json-api-raw";
7
7
  import type { Store } from "../store.js";
8
- export declare function preloadData(store: Store, identifier: StableNewRecordIdentifier, preload: Record<string, Value>): void;
9
- export interface BaseFinderOptions<T = unknown> {
8
+ export declare function preloadData(store: Store, identifier: NewResourceKey, preload: Record<string, Value>): void;
9
+ export interface BaseFinderOptions {
10
10
  reload?: boolean;
11
11
  backgroundReload?: boolean;
12
- include?: T extends TypedRecordInstance ? Includes<T>[] : string | string[];
12
+ include?: string | string[];
13
13
  adapterOptions?: Record<string, unknown>;
14
14
  }
15
- export interface FindRecordOptions<T = unknown> extends BaseFinderOptions<T> {
15
+ export interface FindRecordOptions extends BaseFinderOptions {
16
16
  /**
17
17
  * Data to preload into the store before the request is made.
18
18
  * This feature is *highly* discouraged and has no corresponding
@@ -31,9 +31,9 @@ export interface FindRecordOptions<T = unknown> extends BaseFinderOptions<T> {
31
31
  preload?: Record<string, Value>;
32
32
  }
33
33
  export type QueryOptions = { [K in string | "adapterOptions"]? : K extends "adapterOptions" ? Record<string, unknown> : unknown };
34
- export type FindAllOptions<T = unknown> = BaseFinderOptions<T>;
35
- export type LegacyResourceQuery<T = unknown> = {
36
- include?: T extends TypedRecordInstance ? Includes<T>[] : string | string[];
34
+ export type FindAllOptions = BaseFinderOptions;
35
+ export type LegacyResourceQuery = {
36
+ include?: string | string[];
37
37
  [key: string]: Value | undefined;
38
38
  };
39
39
  export type KeyOrString<T> = keyof T & string extends never ? string : keyof T & string;
@@ -55,7 +55,7 @@ export interface ModelSchema<T = unknown> {
55
55
  eachRelationship<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, relationship: LegacyRelationshipField) => void, binding?: T): void;
56
56
  eachTransformedAttribute<K extends KeyOrString<T>>(callback: (this: ModelSchema<T>, key: K, type: string | null) => void, binding?: T): void;
57
57
  }
58
- export declare function resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: StableRecordIdentifier): boolean;
58
+ export declare function resourceIsFullyDeleted(instanceCache: InstanceCache, identifier: ResourceKey): boolean;
59
59
  /**
60
60
  A `RecordReference` is a low-level API that allows users and
61
61
  addon authors to perform meta-operations on a record.
@@ -64,18 +64,7 @@ addon authors to perform meta-operations on a record.
64
64
  @public
65
65
  */
66
66
  export declare class RecordReference {
67
- /** @internal */
68
- private store;
69
- /** @internal */
70
- // unsubscribe token given to us by the notification manager
71
- private ___token;
72
- /** @internal */
73
- private ___identifier;
74
- /** @internal */
75
- private _ref;
76
- constructor(store: Store, identifier: StableRecordIdentifier);
77
- /** @internal */
78
- destroy(): void;
67
+ constructor(store: Store, identifier: ResourceKey);
79
68
  get type(): string;
80
69
  /**
81
70
  The `id` of the record that this reference refers to.
@@ -112,7 +101,7 @@ export declare class RecordReference {
112
101
  @public
113
102
  @return The identifier of the record.
114
103
  */
115
- identifier(): StableRecordIdentifier;
104
+ identifier(): ResourceKey;
116
105
  /**
117
106
  How the reference will be looked up when it is loaded. Currently
118
107
  this always returns `identity` to signify that a record will be
@@ -221,7 +210,6 @@ export declare class RecordReference {
221
210
  reload(): Promise<unknown>;
222
211
  }
223
212
  export declare function getShimClass<T>(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string): ShimModelClass<T>;
224
- // Mimics the static apis of @ember-data/model
225
213
  export declare class ShimModelClass<T = unknown> implements ModelSchema<T> {
226
214
  __store: Store;
227
215
  modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string;