@warp-drive/legacy 5.10.0-alpha.0 → 5.10.0-alpha.2

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 (101) hide show
  1. package/dist/adapter/-private.d.ts +6 -6
  2. package/dist/adapter/-private.d.ts.map +1 -1
  3. package/dist/compat/utils.d.ts +11 -12
  4. package/dist/compat/utils.d.ts.map +1 -1
  5. package/dist/{errors-BEEsrHbl.js → errors-CS110tMl.js} +9 -2
  6. package/dist/errors-CS110tMl.js.map +1 -0
  7. package/dist/index.d.ts +8 -9
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/model/-private.js +1 -1
  12. package/dist/model/migration-support.d.ts +8 -9
  13. package/dist/model/migration-support.d.ts.map +1 -1
  14. package/dist/model/migration-support.js +2 -2
  15. package/dist/model-62hn5_PD.d.ts.map +1 -1
  16. package/dist/{model-DcXZdNMu.js → model-DWH9f__L.js} +3 -3
  17. package/dist/{model-DcXZdNMu.js.map → model-DWH9f__L.js.map} +1 -1
  18. package/dist/model-fragments.d.ts +11 -11
  19. package/dist/model-fragments.d.ts.map +1 -1
  20. package/dist/model.d.ts +17 -17
  21. package/dist/model.d.ts.map +1 -1
  22. package/dist/model.js +2 -2
  23. package/dist/{schema-provider-H4zNXtry.js → schema-provider-DguGmQDS.js} +3 -7
  24. package/dist/schema-provider-DguGmQDS.js.map +1 -0
  25. package/dist/serializer/rest.d.ts +2 -2
  26. package/dist/serializer/rest.d.ts.map +1 -1
  27. package/dist/serializer/transform.d.ts +10 -11
  28. package/dist/serializer/transform.d.ts.map +1 -1
  29. package/dist/serializer.d.ts +1 -2
  30. package/dist/serializer.d.ts.map +1 -1
  31. package/dist/store.d.ts +2 -2
  32. package/dist/store.d.ts.map +1 -1
  33. package/dist/unpkg/dev/{compat-BqmMZNci.js → compat-DNQT2TQx.js} +2 -2
  34. package/dist/unpkg/dev/{compat-BqmMZNci.js.map → compat-DNQT2TQx.js.map} +1 -1
  35. package/dist/unpkg/dev/compat.js +1 -1
  36. package/dist/unpkg/dev/{errors-8GnRWcxo.js → errors-DnzvLM2A.js} +9 -2
  37. package/dist/unpkg/dev/errors-DnzvLM2A.js.map +1 -0
  38. package/dist/unpkg/dev/index.js +4 -2
  39. package/dist/unpkg/dev/index.js.map +1 -1
  40. package/dist/unpkg/dev/model/-private.js +1 -1
  41. package/dist/unpkg/dev/model/migration-support.js +2 -2
  42. package/dist/unpkg/dev/{model-LK7ethC5.js → model-BxPIR7m2.js} +3 -3
  43. package/dist/unpkg/dev/{model-LK7ethC5.js.map → model-BxPIR7m2.js.map} +1 -1
  44. package/dist/unpkg/dev/model.js +2 -2
  45. package/dist/unpkg/dev/{schema-provider-CRzoMoTO.js → schema-provider-CI_a48ja.js} +3 -7
  46. package/dist/unpkg/dev/schema-provider-CI_a48ja.js.map +1 -0
  47. package/dist/unpkg/dev-deprecated/compat/builders.js +1 -1
  48. package/dist/unpkg/dev-deprecated/{compat-D_T7cGfd.js → compat-CeT0PnVX.js} +2 -2
  49. package/dist/unpkg/dev-deprecated/{compat-D_T7cGfd.js.map → compat-CeT0PnVX.js.map} +1 -1
  50. package/dist/unpkg/dev-deprecated/compat.js +1 -1
  51. package/dist/unpkg/dev-deprecated/{errors-0ydn94s0.js → errors-jHQESeNQ.js} +9 -2
  52. package/dist/unpkg/dev-deprecated/errors-jHQESeNQ.js.map +1 -0
  53. package/dist/unpkg/dev-deprecated/index.js +5 -3
  54. package/dist/unpkg/dev-deprecated/index.js.map +1 -1
  55. package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
  56. package/dist/unpkg/dev-deprecated/model/migration-support.js +2 -2
  57. package/dist/unpkg/dev-deprecated/{model-C1ts6Mod.js → model-BeGORt6h.js} +5 -5
  58. package/dist/unpkg/dev-deprecated/{model-C1ts6Mod.js.map → model-BeGORt6h.js.map} +1 -1
  59. package/dist/unpkg/dev-deprecated/model.js +2 -2
  60. package/dist/unpkg/dev-deprecated/{schema-provider-D2ESMsA8.js → schema-provider-NmtdR4n_.js} +4 -8
  61. package/dist/unpkg/dev-deprecated/schema-provider-NmtdR4n_.js.map +1 -0
  62. package/dist/unpkg/dev-deprecated/{store-BX7GvXC_.js → store-BCOLSC6z.js} +3 -3
  63. package/dist/unpkg/dev-deprecated/{store-BX7GvXC_.js.map → store-BCOLSC6z.js.map} +1 -1
  64. package/dist/unpkg/dev-deprecated/store.js +1 -1
  65. package/dist/unpkg/dev-deprecated/{util-9mgEBJ3W.js → util-CXA3RNYH.js} +2 -2
  66. package/dist/unpkg/dev-deprecated/{util-9mgEBJ3W.js.map → util-CXA3RNYH.js.map} +1 -1
  67. package/dist/unpkg/dev-deprecated/{utils-Cl86-e7F.js → utils-DQkMqhDv.js} +2 -2
  68. package/dist/unpkg/dev-deprecated/{utils-Cl86-e7F.js.map → utils-DQkMqhDv.js.map} +1 -1
  69. package/dist/unpkg/prod/{errors-CVXWrUjP.js → errors-DQDfNqVx.js} +9 -2
  70. package/dist/unpkg/prod/errors-DQDfNqVx.js.map +1 -0
  71. package/dist/unpkg/prod/index.js +3 -1
  72. package/dist/unpkg/prod/index.js.map +1 -1
  73. package/dist/unpkg/prod/model/-private.js +1 -1
  74. package/dist/unpkg/prod/model/migration-support.js +2 -2
  75. package/dist/unpkg/prod/{model-D3WMsNNE.js → model-CYMA-e_S.js} +3 -3
  76. package/dist/unpkg/prod/{model-D3WMsNNE.js.map → model-CYMA-e_S.js.map} +1 -1
  77. package/dist/unpkg/prod/model.js +2 -2
  78. package/dist/unpkg/prod/{schema-provider-_pimTZ3P.js → schema-provider-05U1H-Kl.js} +3 -7
  79. package/dist/unpkg/prod/schema-provider-05U1H-Kl.js.map +1 -0
  80. package/dist/unpkg/prod-deprecated/{errors-9LXqpfRd.js → errors-ii4L43_1.js} +9 -2
  81. package/dist/unpkg/prod-deprecated/errors-ii4L43_1.js.map +1 -0
  82. package/dist/unpkg/prod-deprecated/index.js +3 -1
  83. package/dist/unpkg/prod-deprecated/index.js.map +1 -1
  84. package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
  85. package/dist/unpkg/prod-deprecated/model/migration-support.js +2 -2
  86. package/dist/unpkg/prod-deprecated/{model-aiVrr1fz.js → model-D3oCPHtM.js} +3 -3
  87. package/dist/unpkg/prod-deprecated/{model-aiVrr1fz.js.map → model-D3oCPHtM.js.map} +1 -1
  88. package/dist/unpkg/prod-deprecated/model.js +2 -2
  89. package/dist/unpkg/prod-deprecated/{schema-provider-DyfSd9Cv.js → schema-provider-CKH_bnnS.js} +3 -7
  90. package/dist/unpkg/prod-deprecated/schema-provider-CKH_bnnS.js.map +1 -0
  91. package/package.json +9 -9
  92. package/dist/errors-BEEsrHbl.js.map +0 -1
  93. package/dist/schema-provider-H4zNXtry.js.map +0 -1
  94. package/dist/unpkg/dev/errors-8GnRWcxo.js.map +0 -1
  95. package/dist/unpkg/dev/schema-provider-CRzoMoTO.js.map +0 -1
  96. package/dist/unpkg/dev-deprecated/errors-0ydn94s0.js.map +0 -1
  97. package/dist/unpkg/dev-deprecated/schema-provider-D2ESMsA8.js.map +0 -1
  98. package/dist/unpkg/prod/errors-CVXWrUjP.js.map +0 -1
  99. package/dist/unpkg/prod/schema-provider-_pimTZ3P.js.map +0 -1
  100. package/dist/unpkg/prod-deprecated/errors-9LXqpfRd.js.map +0 -1
  101. package/dist/unpkg/prod-deprecated/schema-provider-DyfSd9Cv.js.map +0 -1
@@ -3,17 +3,17 @@ import { a as RequestData } from "../rest-0NhtexIq.js";
3
3
  import { Store } from "@warp-drive/core";
4
4
  import { ModelSchema } from "@warp-drive/core/types";
5
5
  //#region src/adapter/-private/utils/parse-response-headers.d.ts
6
- declare function parseResponseHeaders(headersString: string): Record<string, string>;
6
+ export declare function parseResponseHeaders(headersString: string): Record<string, string>;
7
7
  //#endregion
8
8
  //#region src/adapter/-private/utils/determine-body-promise.d.ts
9
9
  type Payload = Error | Record<string, unknown> | unknown[] | string | undefined;
10
- declare function determineBodyPromise(response: Response, requestData: RequestData): Promise<Payload>;
10
+ export declare function determineBodyPromise(response: Response, requestData: RequestData): Promise<Payload>;
11
11
  //#endregion
12
12
  //#region src/adapter/-private/utils/serialize-query-params.d.ts
13
13
  interface PlainObject {
14
14
  [key: string]: string | PlainObject | PlainObject[] | string[];
15
15
  }
16
- declare function serializeQueryParams(queryParamsObject: PlainObject | string): string;
16
+ export declare function serializeQueryParams(queryParamsObject: PlainObject | string): string;
17
17
  //#endregion
18
18
  //#region src/adapter/-private/utils/fetch.d.ts
19
19
  type FetchFunction = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
@@ -22,12 +22,12 @@ type MockRequest = {
22
22
  get(key: string): string | undefined;
23
23
  };
24
24
  declare function getFetchFunction(): FetchFunction;
25
- declare function setupFastboot(fastBootRequest: MockRequest): void;
25
+ export declare function setupFastboot(fastBootRequest: MockRequest): void;
26
26
  //#endregion
27
27
  //#region src/adapter/-private/utils/serialize-into-hash.d.ts
28
- declare function serializeIntoHash(store: Store, modelClass: ModelSchema, snapshot: Snapshot, options?: {
28
+ export declare function serializeIntoHash(store: Store, modelClass: ModelSchema, snapshot: Snapshot, options?: {
29
29
  includeId?: boolean;
30
30
  }): object;
31
31
  //#endregion
32
- export { determineBodyPromise, getFetchFunction as fetch, parseResponseHeaders, serializeIntoHash, serializeQueryParams, setupFastboot };
32
+ export { getFetchFunction as fetch };
33
33
  //# sourceMappingURL=-private.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"-private.d.ts","names":[],"sources":["../../src/adapter/-private/utils/parse-response-headers.ts","../../src/adapter/-private/utils/determine-body-promise.ts","../../src/adapter/-private/utils/serialize-query-params.ts","../../src/adapter/-private/utils/fetch.ts","../../src/adapter/-private/utils/serialize-into-hash.ts"],"mappings":";;;;;iBAEgB,qBAAqB,wBAAwB;;;KCKxD,UAAU,QAAQ;iBA2DP,qBAAqB,UAAU,UAAU,aAAa,cAAc,QAAQ;;;UC9DlF;GACgB,uBAAA,cAAc;;iBA8DxB,qBAAqB,mBAAmB;;;KCjEnD,iBAAiB,OAAO,aAAa,OAAO,gBAAgB,QAAQ;KAGpE;EAAgB;EAAmB,IAAI;;iBAG5B,oBAAoB;iBAkEpB,cAAc,iBAAiB;;;iBC/D/B,kBACd,OAAO,OACP,YAAY,aACZ,UAAU,UACV;EAAW"}
1
+ {"version":3,"file":"-private.d.ts","names":[],"sources":["../../src/adapter/-private/utils/parse-response-headers.ts","../../src/adapter/-private/utils/determine-body-promise.ts","../../src/adapter/-private/utils/serialize-query-params.ts","../../src/adapter/-private/utils/fetch.ts","../../src/adapter/-private/utils/serialize-into-hash.ts"],"mappings":";;;;;wBAEgB,qBAAqB,wBAAwB;;;KCKxD,UAAU,QAAQ;wBA2DP,qBAAqB,UAAU,UAAU,aAAa,cAAc,QAAQ;;;UC9DlF;GACgB,uBAAA,cAAc;;wBA8DxB,qBAAqB,mBAAmB;;;KCjEnD,iBAAiB,OAAO,aAAa,OAAO,gBAAgB,QAAQ;KAGpE;EAAgB;EAAmB,IAAI;;iBAG5B,oBAAoB;wBAkEpB,cAAc,iBAAiB;;;wBC/D/B,kBACd,OAAO,OACP,YAAY,aACZ,UAAU,UACV;EAAW"}
@@ -8,7 +8,7 @@ type Reporter = (type: "formatted-id" | "formatted-type", actual: unknown, expec
8
8
  * @param fn - a function which takes a mismatch-type ('formatted-id' | 'formatted-type'), actual, and expected value
9
9
  * @public
10
10
  */
11
- declare function configureMismatchReporter(fn: Reporter): void;
11
+ export declare function configureMismatchReporter(fn: Reporter): void;
12
12
  /**
13
13
  * Configure a function to be called when an id or type
14
14
  * fails validation. This is useful for instrumenting
@@ -17,7 +17,7 @@ declare function configureMismatchReporter(fn: Reporter): void;
17
17
  * @param fn - a function which takes a message and a condition
18
18
  * @public
19
19
  */
20
- declare function configureAssertFn(fn: (message: string, condition: unknown) => void): void;
20
+ export declare function configureAssertFn(fn: (message: string, condition: unknown) => void): void;
21
21
  /**
22
22
  * Configure a function to be called to normalize
23
23
  * a resource type string. Used by both formattedType
@@ -31,7 +31,7 @@ declare function configureAssertFn(fn: (message: string, condition: unknown) =>
31
31
  * @param fn - a function which takes a string and returns a string
32
32
  * @public
33
33
  */
34
- declare function configureTypeNormalization(fn: (type: string) => string): void;
34
+ export declare function configureTypeNormalization(fn: (type: string) => string): void;
35
35
  /**
36
36
  * Converts a potentially unnormalized type into the format expected
37
37
  * by our WarpDrive Cache. Currently this is singular-dasherized.
@@ -61,7 +61,7 @@ declare function configureTypeNormalization(fn: (type: string) => string): void;
61
61
  * @return the normalized type
62
62
  * @public
63
63
  */
64
- declare function formattedType<T extends string>(type: T | string): T;
64
+ export declare function formattedType<T extends string>(type: T | string): T;
65
65
  /**
66
66
  * Format an id to the format expected by the WarpDrive Cache.
67
67
  * Currently this means that id should be `string | null`.
@@ -82,22 +82,22 @@ declare function formattedType<T extends string>(type: T | string): T;
82
82
  * @return the normalized id
83
83
  * @public
84
84
  */
85
- declare function formattedId(id: string | number): string;
86
- declare function formattedId(id: null): null;
87
- declare function formattedId(id: string | number | null): string | null;
85
+ export declare function formattedId(id: string | number): string;
86
+ export declare function formattedId(id: null): null;
87
+ export declare function formattedId(id: string | number | null): string | null;
88
88
  /**
89
89
  * Like {@link formattedId}, but asserts that `id` is not `null` rather
90
90
  * than allowing and passing through `null`.
91
91
  *
92
92
  * @public
93
93
  */
94
- declare function expectId(id: string | number): string;
94
+ export declare function expectId(id: string | number): string;
95
95
  /**
96
96
  * Throws, since `id` is `null`.
97
97
  *
98
98
  * @public
99
99
  */
100
- declare function expectId(id: null): never;
100
+ export declare function expectId(id: null): never;
101
101
  /**
102
102
  * Compares two types for strict equality, converting them to
103
103
  * the format expected by the WarpDrive Cache to ensure
@@ -123,7 +123,7 @@ declare function expectId(id: null): never;
123
123
  * @return true if the types are equivalent
124
124
  * @public
125
125
  */
126
- declare function isEquivType(expected: string, actual: string): boolean;
126
+ export declare function isEquivType(expected: string, actual: string): boolean;
127
127
  /**
128
128
  * Compares two IDs for strict equality, converting them to
129
129
  * the format expected by the WarpDrive Cache to ensure
@@ -145,7 +145,6 @@ declare function isEquivType(expected: string, actual: string): boolean;
145
145
  * @return true if the ids are equivalent
146
146
  * @public
147
147
  */
148
- declare function isEquivId(expected: string | number, actual: string | number | null): boolean;
148
+ export declare function isEquivId(expected: string | number, actual: string | number | null): boolean;
149
149
  //#endregion
150
- export { configureAssertFn, configureMismatchReporter, configureTypeNormalization, expectId, formattedId, formattedType, isEquivId, isEquivType };
151
150
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/compat/utils.ts"],"mappings":";KAcK,YAAY,yCAAyC,iBAAiB;;;;;;;;;iBA0B3D,0BAA0B,IAAI;;;;;;;;;iBAY9B,kBAAkB,KAAK,iBAAiB;;;;;;;;;;;;;;iBAiBxC,2BAA2B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmChC,cAAc,kBAAkB,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;iBAuCnD,YAAY;iBACZ,YAAY;iBACZ,YAAY;;;;;;;iBA0BZ,SAAS;;;;;;iBAMT,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgCT,YAAY,kBAAkB;;;;;;;;;;;;;;;;;;;;;;iBAmC9B,UAAU,2BAA2B"}
1
+ {"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/compat/utils.ts"],"mappings":";KAcK,YAAY,yCAAyC,iBAAiB;;;;;;;;;wBA0B3D,0BAA0B,IAAI;;;;;;;;;wBAY9B,kBAAkB,KAAK,iBAAiB;;;;;;;;;;;;;;wBAiBxC,2BAA2B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmChC,cAAc,kBAAkB,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;wBAuCnD,YAAY;wBACZ,YAAY;wBACZ,YAAY;;;;;;;wBA0BZ,SAAS;;;;;;wBAMT,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;wBAgCT,YAAY,kBAAkB;;;;;;;;;;;;;;;;;;;;;;wBAmC9B,UAAU,2BAA2B"}
@@ -1301,6 +1301,13 @@ defineNonEnumerableSignal(BelongsToReference.prototype, "_ref", 0);
1301
1301
  //#endregion
1302
1302
  //#region src/model/-private/legacy-relationships-support.ts
1303
1303
  const LEGACY_SUPPORT = getOrSetGlobal("LEGACY_SUPPORT", /* @__PURE__ */ new Map());
1304
+ function releaseLegacySupport(identifier) {
1305
+ const support = LEGACY_SUPPORT.get(identifier);
1306
+ if (support) {
1307
+ support.destroy();
1308
+ LEGACY_SUPPORT.delete(identifier);
1309
+ }
1310
+ }
1304
1311
  function lookupLegacySupport(record) {
1305
1312
  const identifier = recordIdentifierFor(record);
1306
1313
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) && ((test) => {
@@ -2130,5 +2137,5 @@ var Errors = class extends ArrayProxyWithCustomOverrides {
2130
2137
  };
2131
2138
 
2132
2139
  //#endregion
2133
- export { PromiseBelongsTo as a, PromiseManyArray as i, LEGACY_SUPPORT as n, lookupLegacySupport as r, Errors as t };
2134
- //# sourceMappingURL=errors-BEEsrHbl.js.map
2140
+ export { PromiseManyArray as a, releaseLegacySupport as i, LEGACY_SUPPORT as n, PromiseBelongsTo as o, lookupLegacySupport as r, Errors as t };
2141
+ //# sourceMappingURL=errors-CS110tMl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-CS110tMl.js","names":["computed","memoized","PromiseObject","macroCondition","getGlobalConfig","n","LegacyPromiseProxy","Symbol","for","Extended","PromiseBelongsTo","id","key","legacySupport","_belongsToState","ref","referenceFor","prototype","meta","WarpDrive","env","DEBUG","test","Error","modelName","reload","options","content","undefined","reloadBelongsTo","defineSignal","memoized","LegacyPromiseProxy","getGlobalConfig","macroCondition","n","PromiseManyArray","constructor","promise","content","_update","isDestroyed","length","WarpDrive","deprecations","DEPRECATE_COMPUTED_CHAINS","prototype","[]","forEach","cb","reload","options","env","DEBUG","test","Error","then","success","rejected","catch","finally","destroy","links","undefined","meta","tapPromise","create","proxy","isPending","isSettled","isFulfilled","isRejected","Promise","resolve","error","assertPolymorphicType","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","parentIdentifier","parentDefinition","addedIdentifier","store","inverseIsImplicit","isPolymorphic","meta","schema","fields","get","inverseKey","test","Error","type","kind","key","options","as","defineNonEnumerableSignal","memoized","assertPrivateStore","assertPolymorphicType","areAllInverseRecordsLoaded","LEGACY_SUPPORT","getGlobalConfig","macroCondition","n","isResourceIdentiferWithRelatedLinks","value","Boolean","links","related","HasManyReference","___token","___identifier","___relatedTokenMap","constructor","store","graph","parentIdentifier","hasManyRelationship","key","type","definition","notifications","subscribe","_","bucket","notifiedKey","_ref","Map","destroy","unsubscribe","forEach","token","clear","identifiers","ensureRefCanSubscribe","resource","_resource","map","data","resourceIdentifier","identifier","cacheKeyManager","getOrCreateRecordIdentifier","get","delete","set","prototype","cache","getRelationship","remoteType","ids","id","link","href","meta","push","doc","skipFetch","dataDoc","Array","isArray","isResourceData","length","isMaybeResource","WarpDrive","env","DEBUG","test","Error","_push","i","relationshipMeta","added","newData","_join","op","record","field","load","_isLoaded","hasRelationshipDataProperty","state","hasReceivedData","relationship","getData","every","_instanceCache","recordIsLoaded","support","getManyArray","options","fetchSyncRel","isAsync","reloadHasMany","getHasMany","reload","object","keys","Object","filter","k","rel","loaded","edge","accessed","defineNonEnumerableSignal","memoized","assertPrivateStore","assertPolymorphicType","areAllInverseRecordsLoaded","LEGACY_SUPPORT","isMaybeResource","getGlobalConfig","macroCondition","n","isResourceIdentiferWithRelatedLinks","value","Boolean","links","related","BelongsToReference","constructor","store","graph","parentIdentifier","belongsToRelationship","key","type","definition","___identifier","___relatedToken","___token","notifications","subscribe","_","bucket","notifiedKey","_ref","destroy","unsubscribe","identifier","resource","_resource","data","cacheKeyManager","getOrCreateRecordIdentifier","prototype","id","link","href","meta","cache","getRelationship","remoteType","push","doc","skipFetch","isResourceData","added","_push","WarpDrive","env","DEBUG","newData","_join","op","record","field","load","peekRecord","options","support","get","fetchSyncRel","isAsync","reloadBelongsTo","then","getBelongsTo","reload","Context","notifyInternalSignal","assertPrivateStore","createLegacyManyArray","fastPush","isPrivateStore","isResourceKey","recordIdentifierFor","storeFor","getOrSetGlobal","EnableHydration","upgradeStore","PromiseBelongsTo","PromiseManyArray","BelongsToReference","HasManyReference","getGlobalConfig","macroCondition","LEGACY_SUPPORT","Map","releaseLegacySupport","identifier","support","get","destroy","delete","lookupLegacySupport","record","WarpDrive","env","DEBUG","test","Error","isDestroyed","isDestroying","LegacySupport","set","constructor","store","cache","_graph","graph","_manyArrayCache","Object","create","_relationshipPromisesCache","_relationshipProxyCache","_pending","references","_syncArray","array","currentState","source","identifiers","jsonApi","_getCurrentState","key","meta","links","length","mutate","mutation","_findBelongsTo","resource","relationship","options","name","getRealFieldName","_findBelongsToByJsonApiResource","then","handleCompletedRelationshipRequest","e","reloadBelongsTo","loadingPromise","getRelationship","isBelongsTo","state","hasFailedLoadAttempt","shouldForceReload","promise","_updatePromiseProxyFor","getBelongsTo","relatedIdentifier","data","isAsync","definition","_belongsToState","legacySupport","modelName","type","isLoaded","_instanceCache","recordIsLoaded","content","getRecord","id","setDirtyBelongsTo","value","op","field","extractIdentifierFromRecord","i","push","getManyArray","manyArray","doc","getField","manager","editable","isPolymorphic","fetchAsyncHasMany","_findHasManyByJsonApiResource","Promise","resolve","reloadHasMany","getHasMany","anyUnloaded","kind","args","promiseProxy","_update","undefined","referenceFor","reference","actualRelationshipKind","relationshipKind","parentIdentifier","adapter","adapterFor","isStale","hasDematerializedInverse","hasReceivedData","isEmpty","allInverseRecordsAreLoaded","areAllInverseRecordsLoaded","shouldFindViaLink","related","findHasMany","schema","fields","inverseType","request","useLink","Array","isArray","every","req","linksMode","url","getRelatedLink","method","records","cacheOptions","Symbol","for","preferLocalCache","hasLocalPartialData","attemptLocalCache","hasData","reload","future","finally","localDataIsEmpty","resourceIsLocal","keys","forEach","proxy","href","recordExt","error","isHasMany","signal","notifications","_flush","peekRecord","relationshipData","getData","unloaded","find","s","instanceCache","context","cacheFields","sourceKey","A","ArrayProxy","computed","get","mapBy","not","n","g","i","ArrayProxyWithCustomOverrides","Errors","errorsByAttributeName","Map","prototype","errorsFor","attribute","map","errors","undefined","set","messages","content","unknownProperty","length","isEmpty","add","_findOrCreateMessages","addObjects","__record","currentState","notify","notifyPropertyChange","messagesArray","Array","isArray","_messages","message","err","findBy","remove","rejectBy","setObjects","replace","delete","clear","attributes","forEach","_","push","has"],"sources":["../src/model/-private/promise-proxy-base.js","../src/model/-private/promise-belongs-to.ts","../src/model/-private/promise-many-array.ts","../src/model/-private/debug/assert-polymorphic-type.ts","../src/model/-private/references/has-many.ts","../src/model/-private/references/belongs-to.ts","../src/model/-private/legacy-relationships-support.ts","../src/model/-private/errors.ts"],"sourcesContent":["import PromiseProxyMixin from '@ember/object/promise-proxy-mixin';\nimport ObjectProxy from '@ember/object/proxy';\n\nexport const PromiseObject = ObjectProxy.extend(PromiseProxyMixin);\n","import { computed } from '@ember/object';\nimport type PromiseProxyMixin from '@ember/object/promise-proxy-mixin';\nimport type ObjectProxy from '@ember/object/proxy';\n\nimport type { Store } from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { memoized } from '@warp-drive/core/signals/-leaked';\nimport type { OpaqueRecordInstance, TypeFromInstanceOrString } from '@warp-drive/core/types/record';\n\nimport type { LegacySupport } from './legacy-relationships-support.ts';\nimport { PromiseObject } from './promise-proxy-base';\n\nexport interface BelongsToProxyMeta<T = unknown> {\n key: string;\n store: Store;\n legacySupport: LegacySupport;\n modelName: TypeFromInstanceOrString<T>;\n}\nexport interface BelongsToProxyCreateArgs<T = unknown> {\n promise: Promise<T | null>;\n content?: T | null;\n _belongsToState: BelongsToProxyMeta<T>;\n}\n\nexport const LegacyPromiseProxy: unique symbol = Symbol.for('LegacyPromiseProxy');\n\ninterface PromiseObjectType<T> extends PromiseProxyMixin<T | null>, ObjectProxy<T> {\n // oxlint-disable-next-line typescript/no-misused-new\n new <PT>(...args: unknown[]): PromiseObjectType<PT>;\n}\n// oxlint-disable-next-line no-unused-vars, typescript/no-extraneous-class\ndeclare class PromiseObjectType<T> {}\n\nconst Extended: PromiseObjectType<OpaqueRecordInstance> =\n PromiseObject as unknown as PromiseObjectType<OpaqueRecordInstance>;\n\n// oxlint-disable-next-line no-unused-vars\ninterface PromiseBelongsTo<T> {\n [LegacyPromiseProxy]: true;\n}\n\n/**\n A PromiseBelongsTo is a PromiseObject that also proxies certain method calls\n to the underlying belongsTo model.\n Right now we proxy:\n * `reload()`\n @class PromiseBelongsTo\n @private\n*/\nclass PromiseBelongsTo<T = unknown> extends Extended<T> {\n declare _belongsToState: BelongsToProxyMeta<T>;\n\n @memoized\n get id(): string | null {\n const { key, legacySupport } = this._belongsToState;\n const ref = legacySupport.referenceFor('belongsTo', key);\n\n return ref.id();\n }\n\n // we don't proxy meta because we would need to proxy it to the relationship state container\n // however, meta on relationships does not trigger change notifications.\n // if you need relationship meta, you should do `record.belongsTo(relationshipName).meta()`\n @computed()\n get meta(): void {\n // oxlint-disable-next-line no-constant-condition\n if (1) {\n assert(\n 'You attempted to access meta on the promise for the async belongsTo relationship ' +\n `${this._belongsToState.modelName}:${this._belongsToState.key}'.` +\n '\\nUse `record.belongsTo(relationshipName).meta()` instead.',\n false\n );\n }\n return;\n }\n\n async reload(options: Record<string, unknown>): Promise<this> {\n assert('You are trying to reload an async belongsTo before it has been created', this.content !== undefined);\n const { key, legacySupport } = this._belongsToState;\n await legacySupport.reloadBelongsTo(key, options);\n return this;\n }\n}\nPromiseBelongsTo.prototype[LegacyPromiseProxy] = true as const;\n\nexport { PromiseBelongsTo };\n","import { DEPRECATE_COMPUTED_CHAINS } from '@warp-drive/core/build-config/deprecations';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { defineSignal, memoized } from '@warp-drive/core/signals/-leaked';\nimport type { RelatedCollection as ManyArray } from '@warp-drive/core/store/-private';\nimport type { BaseFinderOptions } from '@warp-drive/core/types';\nimport type { Links } from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { LegacyPromiseProxy } from './promise-belongs-to.ts';\n\nexport interface HasManyProxyCreateArgs<T = unknown> {\n promise: Promise<ManyArray<T>>;\n content?: ManyArray<T>;\n}\n\n// oxlint-disable-next-line no-unused-vars\nexport interface PromiseManyArray<T> {\n /**\n * A property signifying that this object implements the classic Ember\n * `PromiseProxyMixin`-like API. See {@link LegacyPromiseProxy}.\n */\n [LegacyPromiseProxy]: true;\n}\n\n/**\n This class is returned as the result of accessing an async hasMany relationship\n on an instance of a Model extending from `@warp-drive/legacy/model`.\n\n A PromiseManyArray is an iterable proxy that allows templates to consume related\n ManyArrays and update once their contents are no longer pending.\n\n In your JS code you should resolve the promise first.\n\n ```js\n const comments = await post.comments;\n ```\n\n @public\n*/\nexport class PromiseManyArray<T = unknown> {\n /**\n * The promise for the relationship's content, or `null` once\n * {@link PromiseManyArray.destroy | destroy} has been called.\n */\n declare promise: Promise<ManyArray<T>> | null;\n /**\n * Whether {@link PromiseManyArray.destroy | destroy} has been called.\n */\n declare isDestroyed: boolean;\n /**\n * The resolved `ManyArray` for the relationship, if the promise has\n * resolved, else `null`.\n */\n declare content: ManyArray<T> | null;\n\n constructor(promise: Promise<ManyArray<T>>, content?: ManyArray<T>) {\n this._update(promise, content);\n this.isDestroyed = false;\n this[LegacyPromiseProxy] = true;\n }\n\n /**\n * Retrieve the length of the content\n * @public\n */\n @memoized\n get length(): number {\n // shouldn't be needed, but ends up being needed\n // for computed chains even in 4.x\n if (DEPRECATE_COMPUTED_CHAINS) {\n // oxlint-disable-next-line no-unused-expressions\n this['[]'];\n }\n return this.content ? this.content.length : 0;\n }\n\n /**\n * @private\n */\n // this will error if someone tries to call\n // A(identifierArray) since it is not configurable\n // which is preferrable to the `meta` override we used\n // before which required importing all of Ember\n @memoized\n get '[]'(): 0 | ManyArray<T> | undefined {\n // ember-source < 3.23 (e.g. 3.20 lts)\n // requires that the tag `'[]'` be notified\n // on the ArrayProxy in order for `{{#each}}`\n // to recompute. We entangle content.\n return this.content?.length && this.content;\n }\n\n /**\n * Iterate the proxied content. Called by the glimmer iterator in #each\n * We do not guarantee that forEach will always be available. This\n * may eventually be made to use Symbol.Iterator once glimmer supports it.\n *\n * @param cb\n * @return\n * @private\n */\n forEach(cb: (item: T, index: number, array: T[]) => void): void {\n if (this.content && this.length) {\n this.content.forEach(cb);\n }\n }\n\n /**\n * Reload the relationship\n * @public\n */\n reload(options: Omit<BaseFinderOptions, ''>): this {\n assert('You are trying to reload an async manyArray before it has been created', this.content);\n void this.content.reload(options);\n return this;\n }\n\n //---- Properties/Methods from the PromiseProxyMixin that we will keep as our API\n\n /**\n * Whether the loading promise is still pending\n *\n * @public\n */\n declare isPending: boolean;\n /**\n * Whether the loading promise rejected\n *\n * @public\n */\n declare isRejected: boolean;\n /**\n * Whether the loading promise succeeded\n *\n * @public\n */\n declare isFulfilled: boolean;\n /**\n * Whether the loading promise completed (resolved or rejected)\n *\n * @public\n */\n declare isSettled: boolean;\n\n /**\n * chain this promise\n *\n * @public\n */\n then(\n success: Parameters<Promise<ManyArray<T>>['then']>[0],\n rejected?: Parameters<Promise<ManyArray<T>>['then']>[1]\n ): Promise<unknown> {\n return this.promise!.then(success, rejected);\n }\n\n /**\n * catch errors thrown by this promise\n * @public\n */\n catch(cb: Parameters<Promise<ManyArray<T>>['catch']>[0]): Promise<unknown> {\n return this.promise!.catch(cb);\n }\n\n /**\n * run cleanup after this promise completes\n *\n * @public\n */\n finally(cb: Parameters<Promise<ManyArray<T>>['finally']>[0]): Promise<unknown> {\n return this.promise!.finally(cb);\n }\n\n //---- Methods on EmberObject that we should keep\n\n /**\n * Tears down this proxy, releasing its {@link PromiseManyArray.content | content} and\n * {@link PromiseManyArray.promise | promise} and marking it as {@link PromiseManyArray.isDestroyed | destroyed}.\n *\n * @public\n */\n destroy(): void {\n this.isDestroyed = true;\n this.content = null;\n this.promise = null;\n }\n\n //---- Methods/Properties on ManyArray that we own and proxy to\n\n /**\n * Retrieve the links for this relationship\n * @public\n */\n @memoized\n get links(): Links | null | undefined {\n return this.content ? this.content.links : undefined;\n }\n\n /**\n * Retrieve the meta for this relationship\n * @public\n */\n @memoized\n get meta(): Record<string, unknown> | null | undefined {\n return this.content ? this.content.meta : undefined;\n }\n\n //---- Our own stuff\n\n /** @internal */\n _update(promise: Promise<ManyArray<T>>, content?: ManyArray<T>): void {\n if (content !== undefined) {\n this.content = content;\n }\n\n this.promise = tapPromise(this, promise);\n }\n\n static create<T>({ promise, content }: HasManyProxyCreateArgs<T>): PromiseManyArray<T> {\n return new this(promise, content);\n }\n}\ndefineSignal(PromiseManyArray.prototype, 'content', null);\ndefineSignal(PromiseManyArray.prototype, 'isPending', false);\ndefineSignal(PromiseManyArray.prototype, 'isRejected', false);\ndefineSignal(PromiseManyArray.prototype, 'isFulfilled', false);\ndefineSignal(PromiseManyArray.prototype, 'isSettled', false);\n\nfunction tapPromise<T>(proxy: PromiseManyArray<T>, promise: Promise<ManyArray<T>>) {\n proxy.isPending = true;\n proxy.isSettled = false;\n proxy.isFulfilled = false;\n proxy.isRejected = false;\n return Promise.resolve(promise).then(\n (content) => {\n proxy.isPending = false;\n proxy.isFulfilled = true;\n proxy.isSettled = true;\n proxy.content = content;\n return content;\n },\n (error) => {\n proxy.isPending = false;\n proxy.isFulfilled = false;\n proxy.isRejected = true;\n proxy.isSettled = true;\n throw error;\n }\n );\n}\n","import type { Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { UpgradedMeta } from '@warp-drive/core/graph/-private';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\n\n/*\n Assert that `addedRecord` has a valid type so it can be added to the\n relationship of the `record`.\n\n The assert basically checks if the `addedRecord` can be added to the\n relationship (specified via `relationshipMeta`) of the `record`.\n\n This utility should only be used internally, as both record parameters must\n be stable record identifiers and the `relationshipMeta` needs to be the meta\n information about the relationship, retrieved via\n `record.relationshipFor(key)`.\n*/\nlet assertPolymorphicType: (\n parentIdentifier: ResourceKey,\n parentDefinition: UpgradedMeta,\n addedIdentifier: ResourceKey,\n store: Store\n) => void;\n\nif (DEBUG) {\n // oxlint-disable-next-line no-shadow\n assertPolymorphicType = function assertPolymorphicType(\n parentIdentifier: ResourceKey,\n parentDefinition: UpgradedMeta,\n addedIdentifier: ResourceKey,\n store: Store\n ) {\n if (parentDefinition.inverseIsImplicit) {\n return;\n }\n if (parentDefinition.isPolymorphic) {\n const meta = store.schema.fields(addedIdentifier)?.get(parentDefinition.inverseKey);\n if (meta) {\n assert(\n `Expected the schema for the field ${parentDefinition.inverseKey} on ${addedIdentifier.type} to be for a legacy relationship`,\n meta.kind === 'belongsTo' || meta.kind === 'hasMany'\n );\n assert(\n `The schema for the relationship '${parentDefinition.inverseKey}' on '${addedIdentifier.type}' type does not implement '${parentDefinition.type}' and thus cannot be assigned to the '${parentDefinition.key}' relationship in '${parentIdentifier.type}'. The definition should specify 'as: \"${parentDefinition.type}\"' in options.`,\n meta?.options?.as === parentDefinition.type\n );\n }\n }\n };\n}\n\nexport { assertPolymorphicType };\n","import type { NotificationType, Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CollectionEdge, Graph } from '@warp-drive/core/graph/-private';\nimport { defineNonEnumerableSignal, memoized } from '@warp-drive/core/signals/-leaked';\nimport type { RelatedCollection as ManyArray } from '@warp-drive/core/store/-private';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { BaseFinderOptions } from '@warp-drive/core/types';\nimport type { CollectionRelationship } from '@warp-drive/core/types/cache/relationship';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypeFromInstanceOrString } from '@warp-drive/core/types/record';\nimport type {\n CollectionResourceDocument,\n CollectionResourceRelationship,\n ExistingResourceObject,\n LinkObject,\n Meta,\n PaginationLinks,\n} from '@warp-drive/core/types/spec/json-api-raw';\n\nimport type { IsUnknown } from '../belongs-to.ts';\nimport { assertPolymorphicType } from '../debug/assert-polymorphic-type.ts';\nimport type { LegacySupport } from '../legacy-relationships-support.ts';\nimport { areAllInverseRecordsLoaded, LEGACY_SUPPORT } from '../legacy-relationships-support.ts';\nimport type { MaybeHasManyFields } from '../type-utils.ts';\n\ninterface ResourceIdentifier {\n links?: {\n related?: string | LinkObject;\n };\n meta?: Meta;\n}\n\ntype ArrayItemType<T> = T extends (infer U)[] ? U : never;\n\nfunction isResourceIdentiferWithRelatedLinks(\n value: CollectionResourceRelationship | ResourceIdentifier | null\n): value is ResourceIdentifier & { links: { related: string | LinkObject | null } } {\n return Boolean(value && value.links && value.links.related);\n}\n/**\n A `HasManyReference` is a low-level API that allows access\n and manipulation of a hasMany relationship.\n\n It is especially useful when you're dealing with `async` relationships\n from `@warp-drive/legacy/model` as it allows synchronous access to\n the relationship data if loaded, as well as APIs for loading, reloading\n the data or accessing available information without triggering a load.\n\n It may also be useful when using `sync` relationships with `@warp-drive/legacy/model`\n that need to be loaded/reloaded with more precise timing than marking the\n relationship as `async` and relying on autofetch would have allowed.\n\n However,keep in mind that marking a relationship as `async: false` will introduce\n bugs into your application if the data is not always guaranteed to be available\n by the time the relationship is accessed. Ergo, it is recommended when using this\n approach to utilize `links` for unloaded relationship state instead of identifiers.\n\n Reference APIs are entangled with the relationship's underlying state,\n thus any getters or cached properties that utilize these will properly\n invalidate if the relationship state changes.\n\n References are \"stable\", meaning that multiple calls to retrieve the reference\n for a given relationship will always return the same HasManyReference.\n\n @class HasManyReference\n @public\n */\nexport default class HasManyReference<\n T = unknown,\n K extends string = IsUnknown<T> extends true ? string : MaybeHasManyFields<T>,\n Related = K extends keyof T ? ArrayItemType<Awaited<T[K]>> : unknown,\n> {\n declare graph: Graph;\n declare store: Store;\n declare hasManyRelationship: CollectionEdge;\n /**\n * The field name on the parent record for this has-many relationship.\n *\n * @property key\n * @type {String}\n * @public\n */\n declare key: K;\n\n /**\n * The type of resource this relationship will contain.\n *\n * @property type\n * @type {String}\n * @public\n */\n declare type: TypeFromInstanceOrString<Related>;\n\n // unsubscribe tokens given to us by the notification manager\n ___token!: object;\n ___identifier: ResourceKey<TypeFromInstanceOrString<T>>;\n ___relatedTokenMap!: Map<ResourceKey, object>;\n\n declare _ref: number;\n\n constructor(\n store: Store,\n graph: Graph,\n parentIdentifier: ResourceKey<TypeFromInstanceOrString<T>>,\n hasManyRelationship: CollectionEdge,\n key: K\n ) {\n this.graph = graph;\n this.key = key;\n this.hasManyRelationship = hasManyRelationship;\n this.type = hasManyRelationship.definition.type as TypeFromInstanceOrString<Related>;\n\n this.store = store;\n this.___identifier = parentIdentifier;\n this.___token = store.notifications.subscribe(\n parentIdentifier,\n (_: ResourceKey, bucket: NotificationType, notifiedKey?: string) => {\n if (bucket === 'relationships' && notifiedKey === key) {\n this._ref++;\n }\n }\n );\n this.___relatedTokenMap = new Map();\n // TODO inverse\n }\n\n /**\n * This method should never be called by user code.\n *\n * @internal\n */\n destroy(): void {\n this.store.notifications.unsubscribe(this.___token);\n this.___relatedTokenMap.forEach((token) => {\n this.store.notifications.unsubscribe(token);\n });\n this.___relatedTokenMap.clear();\n }\n\n /**\n * An array of identifiers for the records that this reference refers to.\n *\n * @property identifiers\n * @type {ResourceKey[]}\n * @public\n */\n @memoized\n get identifiers(): ResourceKey<TypeFromInstanceOrString<Related>>[] {\n ensureRefCanSubscribe(this);\n // oxlint-disable-next-line no-unused-expressions\n this._ref;\n\n const resource = this._resource();\n\n const map = this.___relatedTokenMap;\n this.___relatedTokenMap = new Map();\n\n if (resource && resource.data) {\n return resource.data.map((resourceIdentifier) => {\n const identifier = this.store.cacheKeyManager.getOrCreateRecordIdentifier(resourceIdentifier);\n let token = map.get(identifier);\n\n if (token) {\n map.delete(identifier);\n } else {\n token = this.store.notifications.subscribe(\n identifier,\n (_: ResourceKey, bucket: NotificationType, notifiedKey?: string) => {\n if (bucket === 'identity' || (bucket === 'attributes' && notifiedKey === 'id')) {\n this._ref++;\n }\n }\n );\n }\n this.___relatedTokenMap.set(identifier, token);\n\n return identifier as ResourceKey<TypeFromInstanceOrString<Related>>;\n });\n }\n\n map.forEach((token) => {\n this.store.notifications.unsubscribe(token);\n });\n map.clear();\n\n return [];\n }\n\n _resource() {\n const cache = this.store.cache;\n return cache.getRelationship(this.___identifier, this.key) as CollectionResourceRelationship;\n }\n\n /**\n This returns a string that represents how the reference will be\n looked up when it is loaded. If the relationship has a link it will\n use the \"link\" otherwise it defaults to \"id\".\n\n Example\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n // get the identifier of the reference\n if (commentsRef.remoteType() === \"ids\") {\n let ids = commentsRef.ids();\n } else if (commentsRef.remoteType() === \"link\") {\n let link = commentsRef.link();\n }\n ```\n\n @public\n @return The name of the remote type. This should either be `link` or `ids`\n */\n remoteType(): 'link' | 'ids' {\n const value = this._resource();\n if (value && value.links && value.links.related) {\n return 'link';\n }\n\n return 'ids';\n }\n\n /**\n `ids()` returns an array of the record IDs in this relationship.\n\n Example\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n commentsRef.ids(); // ['1']\n ```\n\n @public\n @return The ids in this has-many relationship\n */\n ids(): Array<string | null> {\n return this.identifiers.map((identifier) => identifier.id);\n }\n\n /**\n The link WarpDrive will use to fetch or reload this belongs-to\n relationship. By default it uses only the \"related\" resource linkage.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n export default Model.extend({\n user: belongsTo('user', { async: true, inverse: null })\n });\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n links: {\n related: '/articles/1/author'\n }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n // get the identifier of the reference\n if (userRef.remoteType() === \"link\") {\n let link = userRef.link();\n }\n ```\n\n @public\n @return The link WarpDrive will use to fetch or reload this belongs-to relationship.\n */\n link(): string | null {\n const resource = this._resource();\n\n if (isResourceIdentiferWithRelatedLinks(resource)) {\n if (resource.links) {\n const related = resource.links.related;\n return !related || typeof related === 'string' ? related : related.href;\n }\n }\n return null;\n }\n\n /**\n * any links that have been received for this relationship\n *\n * @public\n * @return\n */\n links(): PaginationLinks | null {\n const resource = this._resource();\n\n return resource && resource.links ? resource.links : null;\n }\n\n /**\n The meta data for the has-many relationship.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n export default Model.extend({\n users: hasMany('user', { async: true, inverse: null })\n });\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n users: {\n links: {\n related: {\n href: '/articles/1/authors'\n },\n },\n meta: {\n lastUpdated: 1458014400000\n }\n }\n }\n }\n });\n\n let usersRef = blog.hasMany('user');\n\n usersRef.meta() // { lastUpdated: 1458014400000 }\n ```\n\n @public\n @return The meta information for the belongs-to relationship.\n */\n meta(): Meta | null {\n let meta: Meta | null = null;\n const resource = this._resource();\n if (resource && resource.meta && typeof resource.meta === 'object') {\n meta = resource.meta;\n }\n return meta;\n }\n\n /**\n `push` can be used to update the data in the relationship and WarpDrive\n will treat the new data as the canonical value of this relationship on\n the backend. An empty array will signify the canonical value should be\n empty.\n\n Example model\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n Setup some initial state, note we haven't loaded the comments yet:\n\n ```js\n const post = store.push({\n data: {\n type: 'post',\n id: '1',\n relationships: {\n comments: {\n data: [{ type: 'comment', id: '1' }]\n }\n }\n }\n });\n\n const commentsRef = post.hasMany('comments');\n commentsRef.ids(); // ['1']\n ```\n\n Update the state using `push`, note we can do this even without\n having loaded these comments yet by providing resource identifiers.\n\n Both full resources and resource identifiers are supported.\n\n ```js\n await commentsRef.push({\n data: [\n { type: 'comment', id: '2' },\n { type: 'comment', id: '3' },\n ]\n });\n\n commentsRef.ids(); // ['2', '3']\n ```\n\n For convenience, you can also pass in an array of resources or resource identifiers\n without wrapping them in the `data` property:\n\n ```js\n await commentsRef.push([\n { type: 'comment', id: '4' },\n { type: 'comment', id: '5' },\n ]);\n\n commentsRef.ids(); // ['4', '5']\n ```\n\n When using the `data` property, you may also include other resource data via included,\n as well as provide new links and meta to the relationship.\n\n ```js\n await commentsRef.push({\n links: {\n related: '/posts/1/comments'\n },\n meta: {\n total: 2\n },\n data: [\n { type: 'comment', id: '4' },\n { type: 'comment', id: '5' },\n ],\n included: [\n { type: 'other-thing', id: '1', attributes: { foo: 'bar' },\n ]\n });\n ```\n\n By default, the store will attempt to fetch any unloaded records before resolving\n the returned promise with the ManyArray.\n\n Alternatively, pass `true` as the second argument to avoid fetching unloaded records\n and instead the promise will resolve with void without attempting to fetch. This is\n particularly useful if you want to update the state of the relationship without\n forcing the load of all of the associated records.\n\n @public\n @param doc a JSONAPI document object describing the new value of this relationship.\n @param skipFetch [optional] if `true`, do not attempt to fetch unloaded records\n */\n async push(\n doc: ExistingResourceObject[] | CollectionResourceDocument,\n skipFetch?: boolean\n ): Promise<ManyArray<Related> | void> {\n const { store } = this;\n const dataDoc = Array.isArray(doc) ? { data: doc } : doc;\n const isResourceData = Array.isArray(dataDoc.data) && dataDoc.data.length > 0 && isMaybeResource(dataDoc.data[0]);\n\n // enforce that one of links, meta or data is present\n assert(\n `You must provide at least one of 'links', 'meta' or 'data' when calling hasManyReference.push`,\n 'links' in dataDoc || 'meta' in dataDoc || 'data' in dataDoc\n );\n\n const identifiers = !Array.isArray(dataDoc.data)\n ? []\n : isResourceData\n ? (store._push(dataDoc, true) as ResourceKey[])\n : dataDoc.data.map((i) => store.cacheKeyManager.getOrCreateRecordIdentifier(i));\n const { identifier } = this.hasManyRelationship;\n\n if (DEBUG) {\n const relationshipMeta = this.hasManyRelationship.definition;\n\n identifiers.forEach((added) => {\n assertPolymorphicType(identifier, relationshipMeta, added, store);\n });\n }\n\n const newData: CollectionResourceRelationship = {};\n // only set data if it was passed in\n if (Array.isArray(dataDoc.data)) {\n newData.data = identifiers;\n }\n if ('links' in dataDoc) {\n newData.links = dataDoc.links;\n }\n if ('meta' in dataDoc) {\n newData.meta = dataDoc.meta;\n }\n assertPrivateStore(store);\n store._join(() => {\n this.graph.push({\n op: 'updateRelationship',\n record: identifier,\n field: this.key,\n value: newData,\n });\n });\n\n if (!skipFetch) return this.load();\n }\n\n _isLoaded(): boolean {\n const hasRelationshipDataProperty = this.hasManyRelationship.state.hasReceivedData;\n if (!hasRelationshipDataProperty) {\n return false;\n }\n\n const relationship = this.graph.getData(this.hasManyRelationship.identifier, this.key) as CollectionRelationship;\n\n return relationship.data\n ? relationship.data.every((identifier) => {\n assertPrivateStore(this.store);\n return this.store._instanceCache.recordIsLoaded(identifier, true) === true;\n })\n : false;\n }\n\n /**\n `value()` synchronously returns the current value of the has-many\n relationship. Unlike `record.relationshipName`, calling\n `value()` on a reference does not trigger a fetch if the async\n relationship is not yet loaded. If the relationship is not loaded\n it will always return `null`.\n\n Example\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n post.comments.then(function(comments) {\n commentsRef.value() === comments\n })\n ```\n\n @public\n */\n value(): ManyArray<Related> | null {\n const support: LegacySupport = (LEGACY_SUPPORT as Map<ResourceKey, LegacySupport>).get(this.___identifier)!;\n\n if (!ensureRefCanSubscribe(this)) {\n // oxlint-disable-next-line no-unused-expressions\n this._ref;\n return null;\n }\n\n return support.getManyArray<Related>(this.key);\n }\n\n /**\n Loads the relationship if it is not already loaded. If the\n relationship is already loaded this method does not trigger a new\n load. This causes a request to the specified\n relationship link or reloads all items currently in the relationship.\n\n Example\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n commentsRef.load().then(function(comments) {\n //...\n });\n ```\n\n You may also pass in an options object whose properties will be\n fed forward. This enables you to pass `adapterOptions` into the\n request given to the adapter via the reference.\n\n Example\n\n ```javascript\n commentsRef.load({ adapterOptions: { isPrivate: true } })\n .then(function(comments) {\n //...\n });\n ```\n\n ```js [app/adapters/comment.js]\n export default ApplicationAdapter.extend({\n findMany(store, type, id, snapshots) {\n // In the adapter you will have access to adapterOptions.\n let adapterOptions = snapshots[0].adapterOptions;\n }\n });\n ```\n\n @public\n @param options the options to pass in.\n @return a promise that resolves with the ManyArray in\n this has-many relationship.\n */\n async load(options?: BaseFinderOptions): Promise<ManyArray<Related>> {\n const support: LegacySupport = (LEGACY_SUPPORT as Map<ResourceKey, LegacySupport>).get(this.___identifier)!;\n const fetchSyncRel =\n !this.hasManyRelationship.definition.isAsync && !areAllInverseRecordsLoaded(this.store, this._resource());\n return fetchSyncRel\n ? (support.reloadHasMany(this.key, options) as Promise<ManyArray<Related>>)\n : // we cast to fix the return type since typescript and eslint don't understand async functions\n // properly\n (support.getHasMany(this.key, options) as Promise<ManyArray<Related>> | ManyArray<Related>);\n }\n\n /**\n Reloads this has-many relationship. This causes a request to the specified\n relationship link or reloads all items currently in the relationship.\n\n Example\n\n ```js [app/models/post.js]\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n commentsRef.reload().then(function(comments) {\n //...\n });\n ```\n\n You may also pass in an options object whose properties will be\n fed forward. This enables you to pass `adapterOptions` into the\n request given to the adapter via the reference. A full example\n can be found in the `load` method.\n\n Example\n\n ```javascript\n commentsRef.reload({ adapterOptions: { isPrivate: true } })\n ```\n\n @public\n @param options the options to pass in.\n @return a promise that resolves with the ManyArray in this has-many relationship.\n */\n reload(options?: BaseFinderOptions): Promise<ManyArray<Related>> {\n const support: LegacySupport = (LEGACY_SUPPORT as Map<ResourceKey, LegacySupport>).get(this.___identifier)!;\n return support.reloadHasMany(this.key, options) as Promise<ManyArray<Related>>;\n }\n}\ndefineNonEnumerableSignal(HasManyReference.prototype, '_ref', 0);\n\nexport function isMaybeResource(object: ExistingResourceObject | ResourceIdentifier): object is ExistingResourceObject {\n const keys = Object.keys(object).filter((k) => k !== 'id' && k !== 'type' && k !== 'lid');\n return keys.length > 0;\n}\n\nfunction ensureRefCanSubscribe(rel: HasManyReference) {\n const loaded = rel._isLoaded();\n\n if (!loaded) {\n // subscribe to changes\n // for when we are not loaded yet\n //\n // because the graph optimizes the case where a relationship has never been subscribed,\n // we force accessed to be true here. When we make the graph public we should create a\n // subscribe/unsubscribe API\n const edge = rel.graph.get(rel.___identifier, rel.key);\n assert(`Expected a hasMany relationship for ${rel.___identifier.type}:${rel.key}`, 'accessed' in edge);\n edge.accessed = true;\n\n return false;\n }\n return true;\n}\n","import type { NotificationType, Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport type { Graph, ResourceEdge } from '@warp-drive/core/graph/-private';\nimport { defineNonEnumerableSignal, memoized } from '@warp-drive/core/signals/-leaked';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { PersistedResourceKey, ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypeFromInstance, TypeFromInstanceOrString } from '@warp-drive/core/types/record';\nimport type {\n LinkObject,\n Links,\n Meta,\n SingleResourceDocument,\n SingleResourceRelationship,\n} from '@warp-drive/core/types/spec/json-api-raw';\n\nimport type { IsUnknown } from '../belongs-to.ts';\nimport { assertPolymorphicType } from '../debug/assert-polymorphic-type.ts';\nimport type { LegacySupport } from '../legacy-relationships-support.ts';\nimport { areAllInverseRecordsLoaded, LEGACY_SUPPORT } from '../legacy-relationships-support.ts';\nimport type { MaybeBelongsToFields } from '../type-utils.ts';\nimport { isMaybeResource } from './has-many.ts';\n\ninterface ResourceIdentifier {\n links?: {\n related?: string | LinkObject;\n };\n meta?: Meta;\n}\n\nfunction isResourceIdentiferWithRelatedLinks(\n value: SingleResourceRelationship | ResourceIdentifier | null\n): value is ResourceIdentifier & { links: { related: string | LinkObject | null } } {\n return Boolean(value && value.links && value.links.related);\n}\n\n/**\n A `BelongsToReference` is a low-level API that allows access\n and manipulation of a belongsTo relationship.\n\n It is especially useful when you're dealing with `async` relationships\n from `@warp-drive/legacy/model` as it allows synchronous access to\n the relationship data if loaded, as well as APIs for loading, reloading\n the data or accessing available information without triggering a load.\n\n It may also be useful when using `sync` relationships with `@warp-drive/legacy/model`\n that need to be loaded/reloaded with more precise timing than marking the\n relationship as `async` and relying on autofetch would have allowed.\n\n However,keep in mind that marking a relationship as `async: false` will introduce\n bugs into your application if the data is not always guaranteed to be available\n by the time the relationship is accessed. Ergo, it is recommended when using this\n approach to utilize `links` for unloaded relationship state instead of identifiers.\n\n Reference APIs are entangled with the relationship's underlying state,\n thus any getters or cached properties that utilize these will properly\n invalidate if the relationship state changes.\n\n References are \"stable\", meaning that multiple calls to retrieve the reference\n for a given relationship will always return the same HasManyReference.\n\n @public\n */\nexport default class BelongsToReference<\n T = unknown,\n K extends string = IsUnknown<T> extends true ? string : MaybeBelongsToFields<T>,\n Related = K extends keyof T ? Exclude<Awaited<T[K]>, null> : unknown,\n> {\n declare graph: Graph;\n declare store: Store;\n declare belongsToRelationship: ResourceEdge;\n /**\n * The field name on the parent record for this has-many relationship.\n *\n */\n declare key: K;\n\n /**\n * The type of resource this relationship will contain.\n *\n */\n declare type: TypeFromInstanceOrString<Related>;\n\n // unsubscribe tokens given to us by the notification manager\n declare ___token: object;\n declare ___identifier: ResourceKey<TypeFromInstanceOrString<T>>;\n declare ___relatedToken: object | null;\n\n declare _ref: number;\n\n constructor(\n store: Store,\n graph: Graph,\n parentIdentifier: ResourceKey<TypeFromInstanceOrString<T>>,\n belongsToRelationship: ResourceEdge,\n key: K\n ) {\n this.graph = graph;\n this.key = key;\n this.belongsToRelationship = belongsToRelationship;\n this.type = belongsToRelationship.definition.type as TypeFromInstanceOrString<Related>;\n this.store = store;\n this.___identifier = parentIdentifier;\n this.___relatedToken = null;\n\n this.___token = store.notifications.subscribe(\n parentIdentifier,\n (_: ResourceKey, bucket: NotificationType, notifiedKey?: string) => {\n if (bucket === 'relationships' && notifiedKey === key) {\n this._ref++;\n }\n }\n );\n\n // TODO inverse\n }\n\n destroy(): void {\n // TODO @feature we need the notification manager often enough\n // we should potentially just expose it fully public\n this.store.notifications.unsubscribe(this.___token);\n this.___token = null as unknown as object;\n if (this.___relatedToken) {\n this.store.notifications.unsubscribe(this.___relatedToken);\n this.___relatedToken = null;\n }\n }\n\n /**\n * The identifier of the record that this reference refers to.\n * `null` if no related record is known.\n *\n */\n @memoized\n get identifier(): ResourceKey<TypeFromInstanceOrString<Related>> | null {\n if (this.___relatedToken) {\n this.store.notifications.unsubscribe(this.___relatedToken);\n this.___relatedToken = null;\n }\n\n const resource = this._resource();\n if (resource && resource.data) {\n const identifier = this.store.cacheKeyManager.getOrCreateRecordIdentifier(resource.data);\n this.___relatedToken = this.store.notifications.subscribe(\n identifier,\n (_: ResourceKey, bucket: NotificationType, notifiedKey?: string) => {\n if (bucket === 'identity' || (bucket === 'attributes' && notifiedKey === 'id')) {\n this._ref++;\n }\n }\n );\n\n return identifier as ResourceKey<TypeFromInstanceOrString<Related>>;\n }\n\n return null;\n }\n\n /**\n The `id` of the record that this reference refers to. Together, the\n `type()` and `id()` methods form a composite key for the identity\n map. This can be used to access the id of an async relationship\n without triggering a fetch that would normally happen if you\n attempted to use `record.relationship.id`.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @belongsTo('user', { async: true, inverse: null }) user;\n }\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n data: { type: 'user', id: 1 }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n // get the identifier of the reference\n if (userRef.remoteType() === \"id\") {\n let id = userRef.id();\n }\n ```\n\n @public\n @return The id of the record in this belongsTo relationship.\n */\n id(): string | null {\n return this.identifier?.id || null;\n }\n\n /**\n The link WarpDrive will use to fetch or reload this belongs-to\n relationship. By default it uses only the \"related\" resource linkage.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n export default Model.extend({\n user: belongsTo('user', { async: true, inverse: null })\n });\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n links: {\n related: '/articles/1/author'\n }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n // get the identifier of the reference\n if (userRef.remoteType() === \"link\") {\n let link = userRef.link();\n }\n ```\n\n @public\n @return The link WarpDrive will use to fetch or reload this belongs-to relationship.\n */\n link(): string | null {\n const resource = this._resource();\n\n if (isResourceIdentiferWithRelatedLinks(resource)) {\n if (resource.links) {\n const related = resource.links.related;\n return !related || typeof related === 'string' ? related : related.href;\n }\n }\n return null;\n }\n\n /**\n * any links that have been received for this relationship\n *\n * @public\n * @return\n */\n links(): Links | null {\n const resource = this._resource();\n\n return resource && resource.links ? resource.links : null;\n }\n\n /**\n The meta data for the belongs-to relationship.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n export default Model.extend({\n user: belongsTo('user', { async: true, inverse: null })\n });\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n links: {\n related: {\n href: '/articles/1/author'\n },\n },\n meta: {\n lastUpdated: 1458014400000\n }\n }\n }\n }\n });\n\n let userRef = blog.belongsTo('user');\n\n userRef.meta() // { lastUpdated: 1458014400000 }\n ```\n\n @public\n @return The meta information for the belongs-to relationship.\n */\n meta(): Meta | null {\n let meta: Meta | null = null;\n const resource = this._resource();\n if (resource && resource.meta && typeof resource.meta === 'object') {\n meta = resource.meta;\n }\n return meta;\n }\n\n _resource() {\n // oxlint-disable-next-line no-unused-expressions\n this._ref; // subscribe\n const cache = this.store.cache;\n return cache.getRelationship(this.___identifier, this.key) as SingleResourceRelationship<\n ResourceKey<TypeFromInstance<Related>>\n >;\n }\n\n /**\n This returns a string that represents how the reference will be\n looked up when it is loaded. If the relationship has a link it will\n use the \"link\" otherwise it defaults to \"id\".\n\n Example\n\n ```js [app/models/post.js]\n import Model, { hasMany } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @hasMany('comment', { async: true, inverse: null }) comments;\n }\n ```\n\n ```javascript\n let post = store.push({\n data: {\n type: 'post',\n id: 1,\n relationships: {\n comments: {\n data: [{ type: 'comment', id: 1 }]\n }\n }\n }\n });\n\n let commentsRef = post.hasMany('comments');\n\n // get the identifier of the reference\n if (commentsRef.remoteType() === \"ids\") {\n let ids = commentsRef.ids();\n } else if (commentsRef.remoteType() === \"link\") {\n let link = commentsRef.link();\n }\n ```\n\n @public\n @return The name of the remote type. This should either be `link` or `id`\n */\n remoteType(): 'link' | 'id' {\n const value = this._resource();\n if (isResourceIdentiferWithRelatedLinks(value)) {\n return 'link';\n }\n return 'id';\n }\n\n /**\n `push` can be used to update the data in the relationship and WarpDrive\n will treat the new data as the canonical value of this relationship on\n the backend. A value of `null` (e.g. `{ data: null }`) can be passed to\n clear the relationship.\n\n Example model\n\n ```js [app/models/blog.js]\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @belongsTo('user', { async: true, inverse: null }) user;\n }\n ```\n\n Setup some initial state, note we haven't loaded the user yet:\n\n ```js\n const blog = store.push({\n data: {\n type: 'blog',\n id: '1',\n relationships: {\n user: {\n data: { type: 'user', id: '1' }\n }\n }\n }\n });\n\n const userRef = blog.belongsTo('user');\n userRef.id(); // '1'\n ```\n\n Update the state using `push`, note we can do this even without\n having loaded the user yet by providing a resource-identifier.\n\n Both full a resource and a resource-identifier are supported.\n\n ```js\n await userRef.push({\n data: {\n type: 'user',\n id: '2',\n }\n });\n\n userRef.id(); // '2'\n ```\n\n You may also pass in links and meta fore the relationship, and sideload\n additional resources that might be required.\n\n ```js\n await userRef.push({\n data: {\n type: 'user',\n id: '2',\n },\n links: {\n related: '/articles/1/author'\n },\n meta: {\n lastUpdated: Date.now()\n },\n included: [\n {\n type: 'user-preview',\n id: '2',\n attributes: {\n username: '@runspired'\n }\n }\n ]\n });\n ```\n\n By default, the store will attempt to fetch the record if it is not loaded or its\n resource data is not included in the call to `push` before resolving the returned\n promise with the new state..\n\n Alternatively, pass `true` as the second argument to avoid fetching unloaded records\n and instead the promise will resolve with void without attempting to fetch. This is\n particularly useful if you want to update the state of the relationship without\n forcing the load of all of the associated record.\n\n @public\n @param doc a JSONAPI document object describing the new value of this relationship.\n @param skipFetch [optional] if `true`, do not attempt to fetch unloaded records\n @return a promise that resolves with the record in this belongs-to relationship after the push has completed.\n */\n async push(doc: SingleResourceDocument, skipFetch?: boolean): Promise<Related | null | void> {\n const { store } = this;\n const isResourceData = doc.data && isMaybeResource(doc.data);\n const added = isResourceData\n ? (store._push(doc, true) as PersistedResourceKey)\n : doc.data\n ? store.cacheKeyManager.getOrCreateRecordIdentifier(doc.data)\n : null;\n const { identifier } = this.belongsToRelationship;\n\n if (DEBUG) {\n if (added) {\n assertPolymorphicType(identifier, this.belongsToRelationship.definition, added, store);\n }\n }\n\n const newData: SingleResourceRelationship = {};\n\n // only set data if it was passed in\n if (doc.data || doc.data === null) {\n newData.data = added;\n }\n if ('links' in doc) {\n newData.links = doc.links;\n }\n if ('meta' in doc) {\n newData.meta = doc.meta;\n }\n assertPrivateStore(store);\n store._join(() => {\n this.graph.push({\n op: 'updateRelationship',\n record: identifier,\n field: this.key,\n value: newData,\n });\n });\n\n if (!skipFetch) return this.load();\n }\n\n /**\n `value()` synchronously returns the current value of the belongs-to\n relationship. Unlike `record.relationshipName`, calling\n `value()` on a reference does not trigger a fetch if the async\n relationship is not yet loaded. If the relationship is not loaded\n it will always return `null`.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @belongsTo('user', { async: true, inverse: null }) user;\n }\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n data: { type: 'user', id: 1 }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n userRef.value(); // null\n\n // provide data for reference\n userRef.push({\n data: {\n type: 'user',\n id: 1,\n attributes: {\n username: \"@user\"\n }\n }\n }).then(function(user) {\n userRef.value(); // user\n });\n ```\n\n @public\n @return the record in this relationship\n */\n value(): Related | null {\n const resource = this._resource();\n return resource && resource.data ? this.store.peekRecord(resource.data) : null;\n }\n\n /**\n Loads a record in a belongs-to relationship if it is not already\n loaded. If the relationship is already loaded this method does not\n trigger a new load.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @belongsTo('user', { async: true, inverse: null }) user;\n }\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n data: { type: 'user', id: 1 }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n userRef.value(); // null\n\n userRef.load().then(function(user) {\n userRef.value() === user\n });\n ```\n\n You may also pass in an options object whose properties will be\n fed forward. This enables you to pass `adapterOptions` into the\n request given to the adapter via the reference.\n\n Example\n\n ```javascript\n userRef.load({ adapterOptions: { isPrivate: true } }).then(function(user) {\n userRef.value() === user;\n });\n ```\n ```js [app/adapters/user.js]\n import Adapter from '@warp-drive/legacy/adapter';\n\n export default class UserAdapter extends Adapter {\n findRecord(store, type, id, snapshot) {\n // In the adapter you will have access to adapterOptions.\n let adapterOptions = snapshot.adapterOptions;\n }\n });\n ```\n\n @public\n @param options the options to pass in.\n @return a promise that resolves with the record in this belongs-to relationship.\n */\n async load(options?: Record<string, unknown>): Promise<Related | null> {\n const support: LegacySupport = (LEGACY_SUPPORT as Map<ResourceKey, LegacySupport>).get(this.___identifier)!;\n const fetchSyncRel =\n !this.belongsToRelationship.definition.isAsync && !areAllInverseRecordsLoaded(this.store, this._resource());\n return fetchSyncRel\n ? support.reloadBelongsTo(this.key, options).then(() => this.value())\n : // we cast to fix the return type since typescript and eslint don't understand async functions\n // properly\n (support.getBelongsTo(this.key, options) as Promise<Related | null>);\n }\n\n /**\n Triggers a reload of the value in this relationship. If the\n remoteType is `\"link\"` WarpDrive will use the relationship link to\n reload the relationship. Otherwise it will reload the record by its\n id.\n\n Example\n\n ```javascript\n // models/blog.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class BlogModel extends Model {\n @belongsTo('user', { async: true, inverse: null }) user;\n }\n\n let blog = store.push({\n data: {\n type: 'blog',\n id: 1,\n relationships: {\n user: {\n data: { type: 'user', id: 1 }\n }\n }\n }\n });\n let userRef = blog.belongsTo('user');\n\n userRef.reload().then(function(user) {\n userRef.value() === user\n });\n ```\n\n You may also pass in an options object whose properties will be\n fed forward. This enables you to pass `adapterOptions` into the\n request given to the adapter via the reference. A full example\n can be found in the `load` method.\n\n Example\n\n ```javascript\n userRef.reload({ adapterOptions: { isPrivate: true } })\n ```\n\n @public\n @param options the options to pass in.\n @return a promise that resolves with the record in this belongs-to relationship after the reload has completed.\n */\n reload(options?: Record<string, unknown>): Promise<Related | null> {\n const support: LegacySupport = (LEGACY_SUPPORT as Map<ResourceKey, LegacySupport>).get(this.___identifier)!;\n return support.reloadBelongsTo(this.key, options).then(() => this.value());\n }\n}\ndefineNonEnumerableSignal(BelongsToReference.prototype, '_ref', 0);\n","import type { Store } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { CollectionEdge, Graph, GraphEdge, ResourceEdge, UpgradedMeta } from '@warp-drive/core/graph/-private';\nimport type { ReactiveDocument } from '@warp-drive/core/reactive';\nimport { Context } from '@warp-drive/core/reactive/-private';\nimport { notifyInternalSignal } from '@warp-drive/core/signals/-leaked';\nimport type { LegacyManyArray, PrivateReactiveResourceArray, PrivateStore } from '@warp-drive/core/store/-private';\nimport {\n assertPrivateStore,\n createLegacyManyArray,\n fastPush,\n isPrivateStore,\n isResourceKey,\n recordIdentifierFor,\n storeFor,\n} from '@warp-drive/core/store/-private';\nimport type { BaseFinderOptions, ResourceKey } from '@warp-drive/core/types';\nimport { getOrSetGlobal } from '@warp-drive/core/types/-private';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { CollectionRelationship } from '@warp-drive/core/types/cache/relationship';\nimport type { LocalRelationshipOperation } from '@warp-drive/core/types/graph';\nimport type { OpaqueRecordInstance, TypeFromInstanceOrString } from '@warp-drive/core/types/record';\nimport { EnableHydration } from '@warp-drive/core/types/request';\nimport type { LegacyBelongsToField, LegacyHasManyField } from '@warp-drive/core/types/schema/fields';\nimport type {\n CollectionResourceRelationship,\n InnerRelationshipDocument,\n SingleResourceRelationship,\n} from '@warp-drive/core/types/spec/json-api-raw';\n\nimport { upgradeStore } from '../../compat/-private.ts';\nimport type { MinimalLegacyRecord } from './model-methods.ts';\nimport type { BelongsToProxyCreateArgs, BelongsToProxyMeta } from './promise-belongs-to.ts';\nimport { PromiseBelongsTo } from './promise-belongs-to.ts';\nimport type { HasManyProxyCreateArgs } from './promise-many-array.ts';\nimport { PromiseManyArray } from './promise-many-array.ts';\nimport BelongsToReference from './references/belongs-to.ts';\nimport HasManyReference from './references/has-many.ts';\n\ntype PromiseBelongsToFactory<T = unknown> = { create(args: BelongsToProxyCreateArgs<T>): PromiseBelongsTo<T> };\n\nexport const LEGACY_SUPPORT: Map<ResourceKey | MinimalLegacyRecord, LegacySupport> = getOrSetGlobal(\n 'LEGACY_SUPPORT',\n new Map<ResourceKey | MinimalLegacyRecord, LegacySupport>()\n);\n\nexport function releaseLegacySupport(identifier: ResourceKey): void {\n const support = LEGACY_SUPPORT.get(identifier);\n if (support) {\n support.destroy();\n LEGACY_SUPPORT.delete(identifier);\n }\n}\n\nexport function lookupLegacySupport(record: MinimalLegacyRecord): LegacySupport {\n const identifier = recordIdentifierFor(record);\n assert(`Expected a record`, identifier);\n let support = LEGACY_SUPPORT.get(identifier);\n\n if (!support) {\n assert(`Memory Leak Detected`, !record.isDestroyed && !record.isDestroying);\n support = new LegacySupport(record, identifier);\n LEGACY_SUPPORT.set(identifier, support);\n }\n\n return support;\n}\n\n/**\n * @hideconstructor\n */\nexport class LegacySupport {\n /** @internal */\n declare private record: MinimalLegacyRecord;\n /** @internal */\n declare store: PrivateStore;\n /** @internal */\n declare private graph: Graph;\n /** @internal */\n declare private cache: Cache;\n /** @internal */\n declare private references: Record<string, BelongsToReference | HasManyReference>;\n declare identifier: ResourceKey;\n /** @internal */\n declare _manyArrayCache: Record<string, LegacyManyArray>;\n /** @internal */\n declare _relationshipPromisesCache: Record<string, Promise<LegacyManyArray | OpaqueRecordInstance>>;\n /** @internal */\n declare _relationshipProxyCache: Record<string, PromiseManyArray | PromiseBelongsTo | undefined>;\n /** @internal */\n declare private _pending: Record<string, Promise<ResourceKey | null> | undefined>;\n\n /** @internal */\n declare private isDestroying: boolean;\n /** @internal */\n declare private isDestroyed: boolean;\n\n constructor(record: MinimalLegacyRecord, identifier: ResourceKey) {\n this.record = record;\n this.store = isPrivateStore(storeFor(record, false)!);\n this.identifier = identifier;\n this.cache = this.store.cache;\n\n if (this.store._graph) {\n this.graph = this.store._graph;\n }\n\n this._manyArrayCache = Object.create(null) as Record<string, LegacyManyArray>;\n this._relationshipPromisesCache = Object.create(null) as Record<\n string,\n Promise<LegacyManyArray | OpaqueRecordInstance>\n >;\n this._relationshipProxyCache = Object.create(null) as Record<string, PromiseManyArray | PromiseBelongsTo>;\n this._pending = Object.create(null) as Record<string, Promise<ResourceKey | null>>;\n this.references = Object.create(null) as Record<string, BelongsToReference>;\n }\n\n /** @private */\n _syncArray(array: LegacyManyArray): void {\n // It’s possible the parent side of the relationship may have been destroyed by this point\n if (this.isDestroyed || this.isDestroying) {\n return;\n }\n const currentState = (array as unknown as PrivateReactiveResourceArray)[Context].source;\n const identifier = this.identifier;\n\n const [identifiers, jsonApi] = this._getCurrentState(identifier, array.key);\n\n if (jsonApi.meta) {\n array.meta = jsonApi.meta;\n }\n\n if (jsonApi.links) {\n array.links = jsonApi.links;\n }\n\n currentState.length = 0;\n fastPush(currentState, identifiers);\n }\n\n mutate(mutation: LocalRelationshipOperation): void {\n this.cache.mutate(mutation);\n }\n\n _findBelongsTo(\n key: string,\n resource: SingleResourceRelationship,\n relationship: ResourceEdge,\n options?: BaseFinderOptions\n ): Promise<OpaqueRecordInstance | null> {\n const name = getRealFieldName(this, key);\n\n // TODO @runspired follow up if parent isNew then we should not be attempting load here\n // TODO @runspired follow up on whether this should be in the relationship requests cache\n return this._findBelongsToByJsonApiResource(resource, this.identifier, relationship, options).then(\n (identifier: ResourceKey | null) => handleCompletedRelationshipRequest(this, name, relationship, identifier),\n (e: Error) => handleCompletedRelationshipRequest(this, name, relationship, null, e)\n );\n }\n\n reloadBelongsTo(key: string, options?: BaseFinderOptions): Promise<OpaqueRecordInstance | null> {\n const loadingPromise = this._relationshipPromisesCache[key] as Promise<OpaqueRecordInstance | null> | undefined;\n if (loadingPromise) {\n return loadingPromise;\n }\n\n const name = getRealFieldName(this, key);\n const resource = this.store.cache.getRelationship(this.identifier, name);\n\n const relationship = this.graph.get(this.identifier, name);\n assert(\n `Expected ${key === name ? name : `${key} (source: ${name})`} to be a belongs-to relationship`,\n isBelongsTo(relationship)\n );\n\n relationship.state.hasFailedLoadAttempt = false;\n relationship.state.shouldForceReload = true;\n const promise = this._findBelongsTo(name, resource as SingleResourceRelationship, relationship, options);\n if (this._relationshipProxyCache[name]) {\n // @ts-expect-error\n return this._updatePromiseProxyFor('belongsTo', name, { promise });\n }\n return promise;\n }\n\n getBelongsTo(key: string, options?: BaseFinderOptions): PromiseBelongsTo | OpaqueRecordInstance | null {\n const { identifier } = this;\n const name = getRealFieldName(this, key);\n const resource = this.store.cache.getRelationship(this.identifier, name);\n const relatedIdentifier = resource && resource.data ? resource.data : null;\n assert(`Expected a stable identifier`, !relatedIdentifier || isResourceKey(relatedIdentifier));\n\n const store = this.store;\n const relationship = this.graph.get(this.identifier, name);\n assert(\n `Expected ${key === name ? name : `${key} (source: ${name})`} to be a belongs-to relationship`,\n isBelongsTo(relationship)\n );\n\n const isAsync = relationship.definition.isAsync;\n const _belongsToState: BelongsToProxyMeta = {\n key,\n store,\n legacySupport: this,\n modelName: relationship.definition.type,\n };\n\n if (isAsync) {\n if (relationship.state.hasFailedLoadAttempt) {\n return this._relationshipProxyCache[name];\n }\n\n const promise = this._findBelongsTo(name, resource as SingleResourceRelationship, relationship, options);\n const isLoaded = relatedIdentifier && store._instanceCache.recordIsLoaded(relatedIdentifier);\n\n return this._updatePromiseProxyFor('belongsTo', name, {\n promise,\n content: isLoaded ? store._instanceCache.getRecord(relatedIdentifier) : null,\n _belongsToState,\n });\n } else {\n if (relatedIdentifier === null) {\n return null;\n } else {\n assert(\n `You looked up the '${key === name ? name : `${key} (source: ${name})`}' relationship on a '${identifier.type}' with id ${\n identifier.id || 'null'\n } but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async (\\`belongsTo(<type>, { async: true, inverse: <inverse> })\\`)`,\n store._instanceCache.recordIsLoaded(relatedIdentifier, true)\n );\n return store._instanceCache.getRecord(relatedIdentifier);\n }\n }\n }\n\n setDirtyBelongsTo(key: string, value: OpaqueRecordInstance | null): void {\n const name = getRealFieldName(this, key);\n return this.cache.mutate(\n {\n op: 'replaceRelatedRecord',\n record: this.identifier,\n field: name,\n value: extractIdentifierFromRecord(value),\n },\n // @ts-expect-error\n true\n );\n }\n\n _getCurrentState<T>(\n identifier: ResourceKey,\n field: string\n ): [ResourceKey<TypeFromInstanceOrString<T>>[], CollectionRelationship] {\n const jsonApi = this.cache.getRelationship(identifier, field) as CollectionRelationship;\n const cache = this.store._instanceCache;\n const identifiers: ResourceKey<TypeFromInstanceOrString<T>>[] = [];\n if (jsonApi.data) {\n for (let i = 0; i < jsonApi.data.length; i++) {\n const relatedIdentifier = jsonApi.data[i] as ResourceKey<TypeFromInstanceOrString<T>>;\n assert(`Expected a stable identifier`, isResourceKey(relatedIdentifier));\n if (cache.recordIsLoaded(relatedIdentifier, true)) {\n identifiers.push(relatedIdentifier);\n }\n }\n }\n\n return [identifiers, jsonApi];\n }\n\n getManyArray<T>(key: string, definition?: UpgradedMeta): LegacyManyArray<T> {\n const name = getRealFieldName(this, key);\n\n if (this.graph) {\n let manyArray: LegacyManyArray<T> | undefined = this._manyArrayCache[name] as LegacyManyArray<T> | undefined;\n if (!definition) {\n definition = this.graph.get(this.identifier, name).definition;\n }\n\n if (!manyArray) {\n const [identifiers, doc] = this._getCurrentState<T>(this.identifier, name);\n const field = getField(this, name);\n\n manyArray = createLegacyManyArray({\n store: this.store,\n // @ts-expect-error Typescript doesn't have a way for us to thread the generic backwards so it infers unknown instead of T\n manager: this,\n source: identifiers,\n type: definition.type,\n isLoaded: !definition.isAsync,\n editable: true,\n isAsync: definition.isAsync,\n isPolymorphic: definition.isPolymorphic,\n field: field as LegacyHasManyField,\n identifier: this.identifier,\n links: doc.links || null,\n meta: doc.meta || null,\n });\n\n this._manyArrayCache[name] = manyArray;\n }\n\n return manyArray;\n }\n assert('hasMany only works with the JSONAPICache');\n }\n\n fetchAsyncHasMany(\n key: string,\n relationship: CollectionEdge,\n manyArray: LegacyManyArray,\n options?: BaseFinderOptions\n ): Promise<LegacyManyArray> {\n const name = getRealFieldName(this, key);\n\n if (this.graph) {\n let loadingPromise = this._relationshipPromisesCache[name] as Promise<LegacyManyArray> | undefined;\n if (loadingPromise) {\n return loadingPromise;\n }\n\n const jsonApi = this.cache.getRelationship(this.identifier, name) as CollectionRelationship;\n const promise = this._findHasManyByJsonApiResource(jsonApi, this.identifier, relationship, options);\n\n if (!promise) {\n manyArray.isLoaded = true;\n return Promise.resolve(manyArray);\n }\n\n loadingPromise = promise.then(\n () => handleCompletedRelationshipRequest(this, name, relationship, manyArray),\n (e: Error) => handleCompletedRelationshipRequest(this, name, relationship, manyArray, e)\n );\n this._relationshipPromisesCache[name] = loadingPromise;\n return loadingPromise;\n }\n assert('hasMany only works with the JSONAPICache');\n }\n\n reloadHasMany<T>(key: string, options?: BaseFinderOptions): Promise<LegacyManyArray<T>> | PromiseManyArray<T> {\n const name = getRealFieldName(this, key);\n\n if (this.graph) {\n const loadingPromise = this._relationshipPromisesCache[name];\n if (loadingPromise) {\n return loadingPromise as Promise<LegacyManyArray<T>>;\n }\n const relationship = this.graph.get(this.identifier, name) as CollectionEdge;\n const { definition, state } = relationship;\n\n state.hasFailedLoadAttempt = false;\n state.shouldForceReload = true;\n const manyArray = this.getManyArray(name, definition);\n const promise = this.fetchAsyncHasMany(name, relationship, manyArray, options);\n\n if (this._relationshipProxyCache[name]) {\n return this._updatePromiseProxyFor('hasMany', name, { promise }) as PromiseManyArray<T>;\n }\n\n return promise as Promise<LegacyManyArray<T>>;\n }\n assert(`hasMany only works with the JSONAPICache`);\n }\n\n getHasMany(key: string, options?: BaseFinderOptions): PromiseManyArray | LegacyManyArray {\n const name = getRealFieldName(this, key);\n\n if (this.graph) {\n const relationship = this.graph.get(this.identifier, name) as CollectionEdge;\n const { definition, state } = relationship;\n const manyArray = this.getManyArray(name, definition);\n\n if (definition.isAsync) {\n if (state.hasFailedLoadAttempt) {\n return this._relationshipProxyCache[name] as PromiseManyArray;\n }\n\n const promise = this.fetchAsyncHasMany(name, relationship, manyArray, options);\n\n return this._updatePromiseProxyFor('hasMany', name, { promise, content: manyArray });\n } else {\n assert(\n `You looked up the '${key === name ? name : `${key} (source: ${name})`}' relationship on a '${this.identifier.type}' with id ${\n this.identifier.id || 'null'\n } but some of the associated records were not loaded. Either make sure they are all loaded together with the parent record, or specify that the relationship is async ('hasMany(<type>, { async: true, inverse: <inverse> })')`,\n !anyUnloaded(this.store, relationship)\n );\n\n return manyArray;\n }\n }\n assert(`hasMany only works with the JSONAPICache`);\n }\n\n _updatePromiseProxyFor(kind: 'hasMany', key: string, args: HasManyProxyCreateArgs): PromiseManyArray;\n _updatePromiseProxyFor(kind: 'belongsTo', key: string, args: BelongsToProxyCreateArgs): PromiseBelongsTo;\n _updatePromiseProxyFor(\n kind: 'belongsTo',\n key: string,\n args: { promise: Promise<OpaqueRecordInstance | null> }\n ): PromiseBelongsTo;\n _updatePromiseProxyFor(\n kind: 'hasMany' | 'belongsTo',\n key: string,\n args: BelongsToProxyCreateArgs | HasManyProxyCreateArgs | { promise: Promise<OpaqueRecordInstance | null> }\n ): PromiseBelongsTo | PromiseManyArray {\n let promiseProxy = this._relationshipProxyCache[key];\n if (kind === 'hasMany') {\n const { promise, content } = args as HasManyProxyCreateArgs;\n if (promiseProxy) {\n assert(`Expected a PromiseManyArray`, '_update' in promiseProxy);\n promiseProxy._update(promise, content);\n } else {\n promiseProxy = this._relationshipProxyCache[key] = new PromiseManyArray(promise, content);\n }\n return promiseProxy;\n }\n if (promiseProxy) {\n const { promise, content } = args as BelongsToProxyCreateArgs;\n assert(`Expected a PromiseBelongsTo`, '_belongsToState' in promiseProxy);\n\n if (content !== undefined) {\n promiseProxy.set('content', content);\n }\n void promiseProxy.set('promise', promise);\n } else {\n promiseProxy = (PromiseBelongsTo as unknown as PromiseBelongsToFactory).create(args as BelongsToProxyCreateArgs);\n this._relationshipProxyCache[key] = promiseProxy;\n }\n\n return promiseProxy;\n }\n\n referenceFor(kind: 'belongsTo', key: string): BelongsToReference;\n referenceFor(kind: 'hasMany', key: string): HasManyReference;\n referenceFor(kind: 'belongsTo' | 'hasMany', key: string) {\n const name = getRealFieldName(this, key);\n\n let reference = this.references[name];\n\n if (!reference) {\n if (!this.graph) {\n // TODO @runspired while this feels odd, it is not a regression in capability because we do\n // not today support references pulling from RecordDatas other than our own\n // because of the intimate API access involved. This is something we will need to redesign.\n assert(`snapshot.belongsTo only supported when using the JSONAPICache`);\n }\n const { graph, identifier } = this;\n const relationship = graph.get(identifier, name);\n\n if (DEBUG) {\n if (kind) {\n const modelName = identifier.type;\n const actualRelationshipKind = relationship.definition.kind;\n assert(\n `You tried to get the '${key === name ? name : `${key} (source: ${name})`}' relationship on a '${modelName}' via record.${kind}('${key}'), but the relationship is of kind '${actualRelationshipKind}'. Use record.${actualRelationshipKind}('${key}') instead.`,\n actualRelationshipKind === kind\n );\n }\n }\n\n const relationshipKind = relationship.definition.kind;\n\n if (relationshipKind === 'belongsTo') {\n reference = new BelongsToReference(this.store, graph, identifier, relationship as ResourceEdge, key);\n } else if (relationshipKind === 'hasMany') {\n reference = new HasManyReference(this.store, graph, identifier, relationship as CollectionEdge, key);\n }\n\n this.references[name] = reference;\n }\n\n return reference;\n }\n\n _findHasManyByJsonApiResource(\n resource: CollectionResourceRelationship,\n parentIdentifier: ResourceKey,\n relationship: CollectionEdge,\n options: BaseFinderOptions = {}\n ): Promise<void | unknown[]> | void {\n if (this.graph) {\n if (!resource) {\n return;\n }\n const { definition, state } = relationship;\n upgradeStore(this.store);\n const adapter = this.store.adapterFor?.(definition.type);\n const { isStale, hasDematerializedInverse, hasReceivedData, isEmpty, shouldForceReload } = state;\n const allInverseRecordsAreLoaded = areAllInverseRecordsLoaded(this.store, resource);\n const identifiers = resource.data;\n const shouldFindViaLink =\n resource.links &&\n resource.links.related &&\n (typeof adapter?.findHasMany === 'function' || typeof identifiers === 'undefined') &&\n (shouldForceReload || hasDematerializedInverse || isStale || (!allInverseRecordsAreLoaded && !isEmpty));\n\n const field = this.store.schema.fields({ type: definition.inverseType }).get(definition.key);\n assert(\n `Expected a hasMany field definition for ${definition.inverseType}.${definition.key}`,\n field && field.kind === 'hasMany'\n );\n\n const request = {\n useLink: shouldFindViaLink,\n field,\n links: resource.links,\n meta: resource.meta,\n options,\n record: parentIdentifier,\n };\n\n // fetch via link\n if (shouldFindViaLink) {\n assert(`Expected collection to be an array`, !identifiers || Array.isArray(identifiers));\n assert(`Expected stable identifiers`, !identifiers || identifiers.every(isResourceKey));\n\n const req = field.options.linksMode\n ? {\n url: getRelatedLink(resource),\n op: 'findHasMany',\n method: 'GET' as const,\n records: identifiers || [],\n data: request,\n [EnableHydration]: false,\n }\n : {\n op: 'findHasMany',\n records: identifiers || [],\n data: request,\n cacheOptions: { [Symbol.for('wd:skip-cache')]: true },\n };\n return this.store.request(req) as unknown as Promise<void>;\n }\n\n const preferLocalCache = hasReceivedData && !isEmpty;\n const hasLocalPartialData =\n hasDematerializedInverse || (isEmpty && Array.isArray(identifiers) && identifiers.length > 0);\n const attemptLocalCache = !shouldForceReload && !isStale && (preferLocalCache || hasLocalPartialData);\n\n if (attemptLocalCache && allInverseRecordsAreLoaded) {\n return;\n }\n\n const hasData = hasReceivedData && !isEmpty;\n if (attemptLocalCache || hasData || hasLocalPartialData) {\n assert(`Expected collection to be an array`, Array.isArray(identifiers));\n assert(`Expected stable identifiers`, identifiers.every(isResourceKey));\n\n options.reload = options.reload || !attemptLocalCache || undefined;\n return this.store.request({\n op: 'findHasMany',\n records: identifiers,\n data: request,\n cacheOptions: { [Symbol.for('wd:skip-cache')]: true },\n }) as unknown as Promise<void>;\n }\n\n // we were explicitly told we have no data and no links.\n // TODO if the relationshipIsStale, should we hit the adapter anyway?\n return;\n }\n assert(`hasMany only works with the JSONAPICache`);\n }\n\n _findBelongsToByJsonApiResource(\n resource: SingleResourceRelationship,\n parentIdentifier: ResourceKey,\n relationship: ResourceEdge,\n options: BaseFinderOptions = {}\n ): Promise<ResourceKey | null> {\n if (!resource) {\n return Promise.resolve(null);\n }\n const key = relationship.definition.key;\n const name = getRealFieldName(this, key);\n\n // interleaved promises mean that we MUST cache this here\n // in order to prevent infinite re-render if the request\n // fails.\n if (this._pending[name]) {\n return this._pending[name];\n }\n\n const identifier = resource.data ? resource.data : null;\n assert(`Expected a stable identifier`, !identifier || isResourceKey(identifier));\n\n const { isStale, hasDematerializedInverse, hasReceivedData, isEmpty, shouldForceReload } = relationship.state;\n\n const allInverseRecordsAreLoaded = areAllInverseRecordsLoaded(this.store, resource);\n const shouldFindViaLink =\n resource.links?.related &&\n (shouldForceReload || hasDematerializedInverse || isStale || (!allInverseRecordsAreLoaded && !isEmpty));\n\n const field = this.store.schema.fields(this.identifier).get(relationship.definition.key);\n assert(\n `Attempted to access a belongsTo relationship but no definition exists for it`,\n field && field.kind === 'belongsTo'\n );\n const request = {\n useLink: shouldFindViaLink,\n field,\n links: resource.links,\n meta: resource.meta,\n options,\n record: parentIdentifier,\n };\n\n // fetch via link\n if (shouldFindViaLink) {\n const req = field.options.linksMode\n ? {\n url: getRelatedLink(resource),\n op: 'findBelongsTo',\n method: 'GET' as const,\n records: identifier ? [identifier] : [],\n data: request,\n [EnableHydration]: false,\n }\n : {\n op: 'findBelongsTo',\n records: identifier ? [identifier] : [],\n data: request,\n cacheOptions: { [Symbol.for('wd:skip-cache')]: true },\n };\n const future = this.store.request<ResourceKey | null>(req);\n this._pending[name] = future\n .then((doc) =>\n field.options.linksMode ? (doc.content as unknown as ReactiveDocument<ResourceKey | null>).data! : doc.content\n )\n .finally(() => {\n this._pending[name] = undefined;\n });\n return this._pending[name];\n }\n\n const preferLocalCache = hasReceivedData && allInverseRecordsAreLoaded && !isEmpty;\n const hasLocalPartialData = hasDematerializedInverse || (isEmpty && resource.data);\n // null is explicit empty, undefined is \"we don't know anything\"\n const localDataIsEmpty = !identifier;\n const attemptLocalCache = !shouldForceReload && !isStale && (preferLocalCache || hasLocalPartialData);\n\n // we dont need to fetch and are empty\n if (attemptLocalCache && localDataIsEmpty) {\n return Promise.resolve(null);\n }\n\n // we dont need to fetch because we are local state\n const resourceIsLocal = identifier?.id === null;\n if ((attemptLocalCache && allInverseRecordsAreLoaded) || resourceIsLocal) {\n return Promise.resolve(identifier);\n }\n\n // we may need to fetch\n if (identifier) {\n assert(`Cannot fetch belongs-to relationship with no information`, identifier);\n options.reload = options.reload || !attemptLocalCache || undefined;\n\n this._pending[name] = this.store\n .request<ResourceKey | null>({\n op: 'findBelongsTo',\n records: [identifier],\n data: request,\n cacheOptions: { [Symbol.for('wd:skip-cache')]: true },\n })\n .then((doc) => doc.content)\n .finally(() => {\n this._pending[name] = undefined;\n });\n return this._pending[name];\n }\n\n // we were explicitly told we have no data and no links.\n // TODO if the relationshipIsStale, should we hit the adapter anyway?\n return Promise.resolve(null);\n }\n\n destroy(): void {\n this.isDestroying = true;\n\n let cache: Record<string, { destroy(): void } | undefined> = this._manyArrayCache;\n this._manyArrayCache = Object.create(null) as Record<string, LegacyManyArray>;\n Object.keys(cache).forEach((key) => {\n cache[key]!.destroy();\n });\n\n cache = this._relationshipProxyCache;\n this._relationshipProxyCache = Object.create(null) as Record<string, PromiseManyArray | PromiseBelongsTo>;\n Object.keys(cache).forEach((key) => {\n const proxy = cache[key]!;\n if (proxy.destroy) {\n proxy.destroy();\n }\n });\n\n cache = this.references;\n this.references = Object.create(null) as Record<string, BelongsToReference | HasManyReference>;\n Object.keys(cache).forEach((key) => {\n cache[key]!.destroy();\n });\n this.isDestroyed = true;\n }\n}\n\nfunction getRelatedLink(resource: SingleResourceRelationship | CollectionResourceRelationship): string {\n const related = resource.links?.related;\n assert(`Expected a related link`, related);\n\n return typeof related === 'object' ? related.href : related;\n}\n\nfunction handleCompletedRelationshipRequest(\n recordExt: LegacySupport,\n key: string,\n relationship: ResourceEdge,\n value: ResourceKey | null\n): OpaqueRecordInstance | null;\nfunction handleCompletedRelationshipRequest(\n recordExt: LegacySupport,\n key: string,\n relationship: CollectionEdge,\n value: LegacyManyArray\n): LegacyManyArray;\nfunction handleCompletedRelationshipRequest(\n recordExt: LegacySupport,\n key: string,\n relationship: ResourceEdge,\n value: null,\n error: Error\n): never;\nfunction handleCompletedRelationshipRequest(\n recordExt: LegacySupport,\n key: string,\n relationship: CollectionEdge,\n value: LegacyManyArray,\n error: Error\n): never;\nfunction handleCompletedRelationshipRequest(\n recordExt: LegacySupport,\n key: string,\n relationship: ResourceEdge | CollectionEdge,\n value: LegacyManyArray | ResourceKey | null,\n error?: Error\n): LegacyManyArray | OpaqueRecordInstance | null {\n delete recordExt._relationshipPromisesCache[key];\n relationship.state.shouldForceReload = false;\n const isHasMany = relationship.definition.kind === 'hasMany';\n\n if (isHasMany) {\n // we don't notify the record property here to avoid refetch\n // only the many array\n notifyInternalSignal((value as unknown as PrivateReactiveResourceArray)[Context].signal);\n }\n\n if (error) {\n relationship.state.hasFailedLoadAttempt = true;\n const proxy = recordExt._relationshipProxyCache[key];\n // belongsTo relationships are sometimes unloaded\n // when a load fails, in this case we need\n // to make sure that we aren't proxying\n // to destroyed content\n // for the sync belongsTo reload case there will be no proxy\n // for the async reload case there will be no proxy if the ui\n // has never been accessed\n if (proxy && !isHasMany) {\n // @ts-expect-error unsure why this is not resolving the boolean but async belongsTo is weird\n if (proxy.content && proxy.content.isDestroying) {\n (proxy as PromiseBelongsTo).set('content', null);\n }\n recordExt.store.notifications._flush();\n }\n\n throw error;\n }\n\n if (isHasMany) {\n (value as LegacyManyArray).isLoaded = true;\n } else {\n recordExt.store.notifications._flush();\n }\n\n relationship.state.hasFailedLoadAttempt = false;\n // only set to not stale if no error is thrown\n relationship.state.isStale = false;\n\n return isHasMany || !value ? value : recordExt.store.peekRecord(value as ResourceKey);\n}\n\ntype PromiseProxyRecord = { then(): void; content: OpaqueRecordInstance | null | undefined };\n\nfunction extractIdentifierFromRecord(record: PromiseProxyRecord | OpaqueRecordInstance | null) {\n if (!record) {\n return null;\n }\n\n return recordIdentifierFor(record);\n}\n\nfunction anyUnloaded(store: Store, relationship: CollectionEdge) {\n assertPrivateStore(store);\n const graph = store._graph;\n assert(`Expected a Graph instance to be available`, graph);\n const relationshipData = graph.getData(\n relationship.identifier,\n relationship.definition.key\n ) as CollectionRelationship;\n const state = relationshipData.data;\n const cache = store._instanceCache;\n const unloaded = state?.find((s) => {\n const isLoaded = cache.recordIsLoaded(s, true);\n return !isLoaded;\n });\n\n return unloaded || false;\n}\n\nexport function areAllInverseRecordsLoaded(store: Store, resource: InnerRelationshipDocument): boolean {\n assertPrivateStore(store);\n const instanceCache = store._instanceCache;\n const identifiers = resource.data;\n\n if (Array.isArray(identifiers)) {\n assert(`Expected stable identifiers`, identifiers.every(isResourceKey));\n // treat as collection\n // check for unloaded records\n return identifiers.every((identifier: ResourceKey) => instanceCache.recordIsLoaded(identifier));\n }\n\n // treat as single resource\n if (!identifiers) return true;\n\n assert(`Expected stable identifiers`, isResourceKey(identifiers));\n return instanceCache.recordIsLoaded(identifiers);\n}\n\nfunction isBelongsTo(relationship: GraphEdge): relationship is ResourceEdge {\n return relationship.definition.kind === 'belongsTo';\n}\n\nfunction getField(context: LegacySupport, key: string): LegacyHasManyField | LegacyBelongsToField {\n const { identifier, store } = context;\n return (store.schema.fields(identifier).get(key) ??\n store.schema.cacheFields?.(identifier).get(key)) as LegacyBelongsToField;\n}\n\nfunction getRealFieldName(context: LegacySupport, key: string): string {\n const field = getField(context, key);\n return field ? (field.sourceKey ?? field.name) : key;\n}\n","import { A, type NativeArray } from '@ember/array';\nimport ArrayProxy from '@ember/array/proxy';\nimport { computed, get } from '@ember/object';\nimport { mapBy, not } from '@ember/object/computed';\n\nimport type RecordState from './record-state.ts';\n\ntype ValidationError = {\n attribute: string;\n message: string;\n};\n\ninterface ArrayProxyWithCustomOverrides<T> extends Omit<ArrayProxy<T>, 'clear' | 'content'> {\n // Omit causes `content` to be merged with the class def for ArrayProxy\n // which then causes it to be seen as a property, disallowing defining it\n // as an accessor. This restores our ability to define it as an accessor.\n content: NativeArray<T>;\n clear(): void;\n _has(name: string): boolean;\n}\n\n// we force the type here to our own construct because mixin and extend patterns\n// lose generic signatures. We also do this because we need to Omit `clear` from\n// the type of ArrayProxy as we override it's signature.\nconst ArrayProxyWithCustomOverrides = ArrayProxy as unknown as new <T>() => ArrayProxyWithCustomOverrides<T>;\n\n/**\n Holds validation errors for a given record, organized by attribute names.\n\n This class is not directly instantiable.\n\n Every `Model` has an `errors` property that is an instance of\n `Errors`. This can be used to display validation error\n messages returned from the server when a `record.save()` rejects.\n\n For Example, if you had a `User` model that looked like this:\n\n ```js [app/models/user.js]\n import { Model, attr } from '@warp-drive/legacy/model';\n\n export default class UserModel extends Model {\n @attr('string') username;\n @attr('string') email;\n }\n ```\n And you attempted to save a record that did not validate on the backend:\n\n ```javascript\n let user = store.createRecord('user', {\n username: 'tomster',\n email: 'invalidEmail'\n });\n user.save();\n ```\n\n Your backend would be expected to return an error response that described\n the problem, so that error messages can be generated on the app.\n\n API responses will be translated into instances of `Errors` differently,\n depending on the specific combination of adapter and serializer used. You\n may want to check the documentation or the source code of the libraries\n that you are using, to know how they expect errors to be communicated.\n\n Errors can be displayed to the user by accessing their property name\n to get an array of all the error objects for that property. Each\n error object is a JavaScript object with two keys:\n\n - `message` A string containing the error message from the backend\n - `attribute` The name of the property associated with this error message\n\n ```handlebars\n <label>Username: <Input @value={{@model.username}} /> </label>\n {{#each @model.errors.username as |error|}}\n <div class=\"error\">\n {{error.message}}\n </div>\n {{/each}}\n\n <label>Email: <Input @value={{@model.email}} /> </label>\n {{#each @model.errors.email as |error|}}\n <div class=\"error\">\n {{error.message}}\n </div>\n {{/each}}\n ```\n\n You can also access the special `messages` property on the error\n object to get an array of all the error strings.\n\n ```handlebars\n {{#each @model.errors.messages as |message|}}\n <div class=\"error\">\n {{message}}\n </div>\n {{/each}}\n ```\n\n @class Errors\n @public\n */\nexport class Errors extends ArrayProxyWithCustomOverrides<ValidationError> {\n declare __record: { currentState: RecordState };\n /**\n @property errorsByAttributeName\n @type {MapWithDefault}\n @private\n */\n @computed()\n get errorsByAttributeName(): Map<string, NativeArray<ValidationError>> {\n return new Map();\n }\n\n /**\n Returns errors for a given attribute\n\n ```javascript\n let user = store.createRecord('user', {\n username: 'tomster',\n email: 'invalidEmail'\n });\n user.save().catch(function(){\n user.errors.errorsFor('email'); // returns:\n // [{attribute: \"email\", message: \"Doesn't look like a valid email.\"}]\n });\n ```\n\n @public\n @param {String} attribute\n @return {Array}\n */\n errorsFor(attribute: string): NativeArray<ValidationError> {\n const map = this.errorsByAttributeName;\n\n let errors = map.get(attribute);\n\n if (errors === undefined) {\n errors = A<ValidationError>();\n map.set(attribute, errors);\n }\n\n // Errors may be a native array with extensions turned on. Since we access\n // the array via a method, and not a computed or using `Ember.get`, it does\n // not entangle properly with autotracking, so we entangle manually by\n // getting the `[]` property.\n get(errors, '[]');\n\n return errors;\n }\n\n /**\n An array containing all of the error messages for this\n record. This is useful for displaying all errors to the user.\n\n ```handlebars\n {{#each @model.errors.messages as |message|}}\n <div class=\"error\">\n {{message}}\n </div>\n {{/each}}\n ```\n\n @property messages\n @public\n @type {Array}\n */\n @mapBy('content', 'message')\n declare messages: string[];\n\n /**\n @property content\n @type {Array}\n @private\n */\n @computed()\n get content(): NativeArray<ValidationError> {\n return A();\n }\n\n /**\n @private\n */\n unknownProperty(attribute: string): NativeArray<ValidationError> | undefined {\n const errors = this.errorsFor(attribute);\n if (errors.length === 0) {\n return undefined;\n }\n return errors;\n }\n\n /**\n Total number of errors.\n\n @property length\n @type {Number}\n @public\n @readonly\n */\n\n /**\n `true` if we have no errors.\n\n @property isEmpty\n @type {Boolean}\n @public\n @readonly\n */\n @not('length')\n declare isEmpty: boolean;\n\n /**\n Manually adds errors to the record. This will trigger the `becameInvalid` event/ lifecycle method on\n the record and transition the record into an `invalid` state.\n\n Example\n ```javascript\n let errors = user.errors;\n\n // add multiple errors\n errors.add('password', [\n 'Must be at least 12 characters',\n 'Must contain at least one symbol',\n 'Cannot contain your name'\n ]);\n\n errors.errorsFor('password');\n // =>\n // [\n // { attribute: 'password', message: 'Must be at least 12 characters' },\n // { attribute: 'password', message: 'Must contain at least one symbol' },\n // { attribute: 'password', message: 'Cannot contain your name' },\n // ]\n\n // add a single error\n errors.add('username', 'This field is required');\n\n errors.errorsFor('username');\n // =>\n // [\n // { attribute: 'username', message: 'This field is required' },\n // ]\n ```\n @public\n @param {String} attribute - the property name of an attribute or relationship\n @param {string[]|string} messages - an error message or array of error messages for the attribute\n */\n add(attribute: string, messages: string[] | string): void {\n const errors = this._findOrCreateMessages(attribute, messages);\n this.addObjects(errors);\n\n this.errorsFor(attribute).addObjects(errors);\n this.__record.currentState.notify('isValid');\n\n this.notifyPropertyChange(attribute);\n }\n\n /**\n @private\n */\n _findOrCreateMessages(attribute: string, messages: string | string[]): ValidationError[] {\n const errors = this.errorsFor(attribute);\n const messagesArray = Array.isArray(messages) ? messages : [messages];\n const _messages: ValidationError[] = new Array(messagesArray.length) as ValidationError[];\n\n for (let i = 0; i < messagesArray.length; i++) {\n const message = messagesArray[i];\n const err = errors.findBy('message', message);\n if (err) {\n _messages[i] = err;\n } else {\n _messages[i] = {\n attribute: attribute,\n message,\n };\n }\n }\n\n return _messages;\n }\n\n /**\n Manually removes all errors for a given member from the record.\n This will transition the record into a `valid` state, and\n triggers the `becameValid` event and lifecycle method.\n\n Example:\n\n ```javascript\n let errors = user.errors;\n errors.add('phone', ['error-1', 'error-2']);\n\n errors.errorsFor('phone');\n // =>\n // [\n // { attribute: 'phone', message: 'error-1' },\n // { attribute: 'phone', message: 'error-2' },\n // ]\n\n errors.remove('phone');\n\n errors.errorsFor('phone');\n // => undefined\n ```\n @public\n @param {String} member - the property name of an attribute or relationship\n */\n remove(attribute: string): void {\n if (this.isEmpty) {\n return;\n }\n\n const content = this.rejectBy('attribute', attribute);\n this.content.setObjects(content);\n\n // Although errorsByAttributeName.delete is technically enough to sync errors state, we also\n // must mutate the array as well for autotracking\n const errors = this.errorsFor(attribute);\n for (let i = 0; i < errors.length; i++) {\n if (errors[i].attribute === attribute) {\n // .replace from Ember.NativeArray is necessary. JS splice will not work.\n errors.replace(i, 1);\n }\n }\n this.errorsByAttributeName.delete(attribute);\n\n this.__record.currentState.notify('isValid');\n this.notifyPropertyChange(attribute);\n this.notifyPropertyChange('length');\n }\n\n /**\n Manually clears all errors for the record.\n This will transition the record into a `valid` state, and\n will trigger the `becameValid` event and lifecycle method.\n\n Example:\n\n ```javascript\n let errors = user.errors;\n errors.add('username', ['error-a']);\n errors.add('phone', ['error-1', 'error-2']);\n\n errors.errorsFor('username');\n // =>\n // [\n // { attribute: 'username', message: 'error-a' },\n // ]\n\n errors.errorsFor('phone');\n // =>\n // [\n // { attribute: 'phone', message: 'error-1' },\n // { attribute: 'phone', message: 'error-2' },\n // ]\n\n errors.clear();\n\n errors.errorsFor('username');\n // => undefined\n\n errors.errorsFor('phone');\n // => undefined\n\n errors.messages\n // => []\n ```\n @public\n */\n clear(): void {\n if (this.isEmpty) {\n return;\n }\n\n const errorsByAttributeName = this.errorsByAttributeName;\n const attributes: string[] = [];\n\n errorsByAttributeName.forEach(function (_, attribute) {\n attributes.push(attribute);\n });\n\n errorsByAttributeName.clear();\n attributes.forEach((attribute) => {\n this.notifyPropertyChange(attribute);\n });\n\n this.__record.currentState.notify('isValid');\n super.clear();\n }\n\n /**\n Checks if there are error messages for the given attribute.\n\n ```js [app/controllers/user/edit.js]\n export default class UserEditController extends Controller {\n @action\n save(user) {\n if (user.errors.has('email')) {\n return alert('Please update your email before attempting to save.');\n }\n user.save();\n }\n }\n ```\n\n @public\n @param {String} attribute\n @return {Boolean} true if there some errors on given attribute\n */\n has(attribute: string): boolean {\n return this.errorsFor(attribute).length > 0;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,MAAa,gBAAgB,YAAY,OAAO,iBAAiB;;;;ACqBjE,MAAaM,qBAAoCC,OAAOC,IAAI,oBAAoB;AAShF,MAAMC,WACJP;;;;;;;;;AAeF,IAAMQ,mBAAN,cAA4CD,SAAY;CAGtD,IACIE,KAAoB;EACtB,MAAM,EAAEC,KAAKC,kBAAkB,KAAKC;EAGpC,OAFYD,cAAcG,aAAa,aAAaJ,GAE7CG,CAAG,CAACJ,GAAG;CAChB;CAIA;EAAAN,iBAAA,KAAAY,WAAA,MAAA,CAVChB,QAAQ,CAAA;CAAA;CAWT,IACIiB,OAAa;EAGbf,eAAAC,gBAAA,CAAA,CAAAe,UAAAC,IAAAC,KAAA,OAAAC,SAAA;GAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,oFACK,KAAKT,gBAAgBU,UAAS,GAAI,KAAKV,gBAAgBF,IAAG;2DACD;EAAA,EAAA,CAC9D,KAAK;CAIX;CAAC;EAAAP,iBAAA,KAAAY,WAAA,QAAA,CAZAjB,SAAS,CAAC,CAAA;CAAA;CAcX,MAAMyB,OAAOC,SAAiD;EAC5DvB,eAAAC,gBAAA,CAAA,CAAAe,UAAAC,IAAAC,KAAA,OAAAC,SAAA;GAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,wEAAwE;EAAA,EAAA,CAAE,KAAKI,YAAYC,MAAS;EAC3G,MAAM,EAAEhB,KAAKC,kBAAkB,KAAKC;EACpC,MAAMD,cAAcgB,gBAAgBjB,KAAKc,OAAO;EAChD,OAAO;CACT;AACF;AACAhB,iBAAiBO,UAAUX,sBAAsB;;;;;;;;;;;;;;;;;;;AC9CjD,IAAa8B,mBAAb,MAA2C;;;;;;;;;;;;CAgBzCC,YAAYC,SA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,CAAC,CAACQ,SAAS;CAC5C;AACF"}
package/dist/index.d.ts CHANGED
@@ -28,7 +28,7 @@ interface _LegacyStoreSetupOptions<T extends Cache> extends Omit<StoreSetupOptio
28
28
  *
29
29
  * @public
30
30
  */
31
- interface LegacyModelStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {
31
+ export interface LegacyModelStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {
32
32
  /**
33
33
  * If true, it is presumed that no requests require use of the LegacyNetworkHandler
34
34
  * and associated adapters/serializer methods.
@@ -55,7 +55,7 @@ interface LegacyModelStoreSetupOptions<T extends Cache> extends _LegacyStoreSetu
55
55
  *
56
56
  * @public
57
57
  */
58
- interface LegacyModelAndNetworkStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {
58
+ export interface LegacyModelAndNetworkStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {
59
59
  /**
60
60
  * If true, it is presumed that no requests require use of the LegacyNetworkHandler
61
61
  * and associated adapters/serializer methods.
@@ -80,7 +80,7 @@ interface LegacyModelAndNetworkStoreSetupOptions<T extends Cache> extends _Legac
80
80
  *
81
81
  * @public
82
82
  */
83
- interface LegacyModelAndNetworkAndRequestStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {
83
+ export interface LegacyModelAndNetworkAndRequestStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {
84
84
  /**
85
85
  * If true, it is presumed that no requests require use of the LegacyNetworkHandler
86
86
  * and associated adapters/serializer methods.
@@ -106,8 +106,8 @@ interface LegacyModelAndNetworkAndRequestStoreSetupOptions<T extends Cache> exte
106
106
  * - {@link LegacyModelAndNetworkStoreSetupOptions}
107
107
  * - {@link LegacyModelAndNetworkAndRequestStoreSetupOptions}
108
108
  */
109
- type LegacyStoreSetupOptions<T extends Cache = Cache> = LegacyModelStoreSetupOptions<T> | LegacyModelAndNetworkStoreSetupOptions<T> | LegacyModelAndNetworkAndRequestStoreSetupOptions<T>;
110
- declare class ConfiguredStore<T extends {
109
+ export type LegacyStoreSetupOptions<T extends Cache = Cache> = LegacyModelStoreSetupOptions<T> | LegacyModelAndNetworkStoreSetupOptions<T> | LegacyModelAndNetworkAndRequestStoreSetupOptions<T>;
110
+ export declare class ConfiguredStore<T extends {
111
111
  /**
112
112
  * The {@link Cache} implementation this store was configured with.
113
113
  */
@@ -229,15 +229,14 @@ declare class ConfiguredStore<T extends {
229
229
  * explicitly, so a handler relying on it should treat it as optional (as
230
230
  * `LoggingHandler` does above).
231
231
  */
232
- declare function useLegacyStore<T extends Cache>(options: LegacyModelStoreSetupOptions<T>, StoreKlass?: typeof Store): typeof ConfiguredStore<{
232
+ export declare function useLegacyStore<T extends Cache>(options: LegacyModelStoreSetupOptions<T>, StoreKlass?: typeof Store): typeof ConfiguredStore<{
233
233
  cache: T;
234
234
  }>;
235
- declare function useLegacyStore<T extends Cache>(options: LegacyModelAndNetworkStoreSetupOptions<T>, StoreKlass?: typeof Store): typeof ConfiguredStore<{
235
+ export declare function useLegacyStore<T extends Cache>(options: LegacyModelAndNetworkStoreSetupOptions<T>, StoreKlass?: typeof Store): typeof ConfiguredStore<{
236
236
  cache: T;
237
237
  }>;
238
- declare function useLegacyStore<T extends Cache>(options: LegacyModelAndNetworkAndRequestStoreSetupOptions<T>, StoreKlass?: typeof Store): typeof ConfiguredStore<{
238
+ export declare function useLegacyStore<T extends Cache>(options: LegacyModelAndNetworkAndRequestStoreSetupOptions<T>, StoreKlass?: typeof Store): typeof ConfiguredStore<{
239
239
  cache: T;
240
240
  }>;
241
241
  //#endregion
242
- export { ConfiguredStore, LegacyModelAndNetworkAndRequestStoreSetupOptions, LegacyModelAndNetworkStoreSetupOptions, LegacyModelStoreSetupOptions, LegacyStoreSetupOptions, useLegacyStore };
243
242
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;UA0CU,yBA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AClD,6BAA6B,KAC7B,uCAAuC,KACvC,iDAAiD;qBAEhC,gBACnB;;;;EAIE,OAAO;WAED;EAER,YAAY,cAAc,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqHvC,eAAe,UAAU,OACvC,SAAS,6BAA6B,IACtC,oBAAoB,eACZ;EAAkB,OAAO;;wBACnB,eAAe,UAAU,OACvC,SAAS,uCAAuC,IAChD,oBAAoB,eACZ;EAAkB,OAAO;;wBACnB,eAAe,UAAU,OACvC,SAAS,iDAAiD,IAC1D,oBAAoB,eACZ;EAAkB,OAAO"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { a as serializeRecord, i as pushPayload, n as cleanup, o as serializerFor, r as normalize, s as LegacyNetworkHandler, t as adapterFor } from "./compat-DcHVxuuZ.js";
2
2
  import { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension } from "./compat/extensions.js";
3
- import { n as modelFor, r as teardownRecord$1, t as instantiateRecord$1 } from "./model-DcXZdNMu.js";
3
+ import { n as modelFor, r as teardownRecord$1, t as instantiateRecord$1 } from "./model-DWH9f__L.js";
4
+ import { i as releaseLegacySupport } from "./errors-CS110tMl.js";
4
5
  import { a as FragmentExtension, s as FragmentArrayExtension, t as fragmentsModelFor } from "./model-fragments-DSqu0ptR.js";
5
6
  import { DelegatingSchemaService, registerDerivations as registerDerivations$1 } from "./model/migration-support.js";
6
7
  import { t as restoreDeprecatedStoreBehaviors } from "./store-C4qYzXei.js";
@@ -223,6 +224,7 @@ function useLegacyStore(options, StoreKlass = Store) {
223
224
  teardownRecord(record) {
224
225
  const key = recordIdentifierFor(record);
225
226
  if (this.schema.isDelegated(key)) return teardownRecord$1.call(this, record);
227
+ releaseLegacySupport(key);
226
228
  return teardownRecord(record);
227
229
  }
228
230
  modelFor(type) {