@warp-drive/legacy 5.10.0-alpha.0 → 5.10.0-alpha.1
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.
- package/dist/{errors-BEEsrHbl.js → errors-CS110tMl.js} +9 -2
- package/dist/errors-CS110tMl.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/model/-private.js +1 -1
- package/dist/model/migration-support.js +2 -2
- package/dist/model-62hn5_PD.d.ts.map +1 -1
- package/dist/{model-DcXZdNMu.js → model-DWH9f__L.js} +3 -3
- package/dist/{model-DcXZdNMu.js.map → model-DWH9f__L.js.map} +1 -1
- package/dist/model.js +2 -2
- package/dist/{schema-provider-H4zNXtry.js → schema-provider-DguGmQDS.js} +3 -7
- package/dist/schema-provider-DguGmQDS.js.map +1 -0
- package/dist/unpkg/dev/{errors-8GnRWcxo.js → errors-DnzvLM2A.js} +9 -2
- package/dist/unpkg/dev/errors-DnzvLM2A.js.map +1 -0
- package/dist/unpkg/dev/index.js +3 -1
- package/dist/unpkg/dev/index.js.map +1 -1
- package/dist/unpkg/dev/model/-private.js +1 -1
- package/dist/unpkg/dev/model/migration-support.js +2 -2
- package/dist/unpkg/dev/{model-LK7ethC5.js → model-BxPIR7m2.js} +3 -3
- package/dist/unpkg/dev/{model-LK7ethC5.js.map → model-BxPIR7m2.js.map} +1 -1
- package/dist/unpkg/dev/model.js +2 -2
- package/dist/unpkg/dev/{schema-provider-CRzoMoTO.js → schema-provider-CI_a48ja.js} +3 -7
- package/dist/unpkg/dev/schema-provider-CI_a48ja.js.map +1 -0
- package/dist/unpkg/dev-deprecated/{errors-0ydn94s0.js → errors-jHQESeNQ.js} +9 -2
- package/dist/unpkg/dev-deprecated/errors-jHQESeNQ.js.map +1 -0
- package/dist/unpkg/dev-deprecated/index.js +3 -1
- package/dist/unpkg/dev-deprecated/index.js.map +1 -1
- package/dist/unpkg/dev-deprecated/model/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/model/migration-support.js +2 -2
- package/dist/unpkg/dev-deprecated/{model-C1ts6Mod.js → model-CdGKb7bA.js} +3 -3
- package/dist/unpkg/dev-deprecated/{model-C1ts6Mod.js.map → model-CdGKb7bA.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/model.js +2 -2
- package/dist/unpkg/dev-deprecated/{schema-provider-D2ESMsA8.js → schema-provider-C9wc6vGC.js} +3 -7
- package/dist/unpkg/dev-deprecated/schema-provider-C9wc6vGC.js.map +1 -0
- package/dist/unpkg/prod/{errors-CVXWrUjP.js → errors-DQDfNqVx.js} +9 -2
- package/dist/unpkg/prod/errors-DQDfNqVx.js.map +1 -0
- package/dist/unpkg/prod/index.js +3 -1
- package/dist/unpkg/prod/index.js.map +1 -1
- package/dist/unpkg/prod/model/-private.js +1 -1
- package/dist/unpkg/prod/model/migration-support.js +2 -2
- package/dist/unpkg/prod/{model-D3WMsNNE.js → model-CYMA-e_S.js} +3 -3
- package/dist/unpkg/prod/{model-D3WMsNNE.js.map → model-CYMA-e_S.js.map} +1 -1
- package/dist/unpkg/prod/model.js +2 -2
- package/dist/unpkg/prod/{schema-provider-_pimTZ3P.js → schema-provider-05U1H-Kl.js} +3 -7
- package/dist/unpkg/prod/schema-provider-05U1H-Kl.js.map +1 -0
- package/dist/unpkg/prod-deprecated/{errors-9LXqpfRd.js → errors-ii4L43_1.js} +9 -2
- package/dist/unpkg/prod-deprecated/errors-ii4L43_1.js.map +1 -0
- package/dist/unpkg/prod-deprecated/index.js +3 -1
- package/dist/unpkg/prod-deprecated/index.js.map +1 -1
- package/dist/unpkg/prod-deprecated/model/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/model/migration-support.js +2 -2
- package/dist/unpkg/prod-deprecated/{model-aiVrr1fz.js → model-D3oCPHtM.js} +3 -3
- package/dist/unpkg/prod-deprecated/{model-aiVrr1fz.js.map → model-D3oCPHtM.js.map} +1 -1
- package/dist/unpkg/prod-deprecated/model.js +2 -2
- package/dist/unpkg/prod-deprecated/{schema-provider-DyfSd9Cv.js → schema-provider-CKH_bnnS.js} +3 -7
- package/dist/unpkg/prod-deprecated/schema-provider-CKH_bnnS.js.map +1 -0
- package/package.json +7 -7
- package/dist/errors-BEEsrHbl.js.map +0 -1
- package/dist/schema-provider-H4zNXtry.js.map +0 -1
- package/dist/unpkg/dev/errors-8GnRWcxo.js.map +0 -1
- package/dist/unpkg/dev/schema-provider-CRzoMoTO.js.map +0 -1
- package/dist/unpkg/dev-deprecated/errors-0ydn94s0.js.map +0 -1
- package/dist/unpkg/dev-deprecated/schema-provider-D2ESMsA8.js.map +0 -1
- package/dist/unpkg/prod/errors-CVXWrUjP.js.map +0 -1
- package/dist/unpkg/prod/schema-provider-_pimTZ3P.js.map +0 -1
- package/dist/unpkg/prod-deprecated/errors-9LXqpfRd.js.map +0 -1
- package/dist/unpkg/prod-deprecated/schema-provider-DyfSd9Cv.js.map +0 -1
|
@@ -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 {
|
|
2134
|
-
//# sourceMappingURL=errors-
|
|
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,K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O5B,SAAS;EAE3C,KAAKa,SAASC,aAAaC,OAAO,SAAS;EAC3C,KAAKC,qBAAqBhB,SAAS;EACnC,KAAKgB,qBAAqB,QAAQ;CACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCAa,QAAc;EACZ,IAAI,KAAKpB,SACP;EAGF,MAAMb,wBAAwB,KAAKA;EACnC,MAAMkC,aAAuB,CAAA;EAE7BlC,sBAAsBmC,QAAQ,SAAUC,GAAGhC,WAAW;GACpD8B,WAAWG,KAAKjC,SAAS;EAC3B,CAAC;EAEDJ,sBAAsBiC,MAAM;EAC5BC,WAAWC,SAAS/B,cAAc;GAChC,KAAKgB,qBAAqBhB,SAAS;EACrC,CAAC;EAED,KAAKa,SAASC,aAAaC,OAAO,SAAS;EAC3C,MAAMc,MAAM;CACd;;;;;;;;;;;;;;;;;;CAqBAK,IAAIlC,WAA4B;EAC9B,OAAO,KAAKD,UAAUC,SAAS,CAAC,CAACQ,SAAS;CAC5C;AACF"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;UA2CU,yBAAyB,UAAU,eAAe,KAAK,kBAAkB;;;;;;;;;;;EAWjF,UAAU,MAAM,iBAAiB;;;;;;EAOjC;;;;;;;;UASe,6BAA6B,UAAU,eAAe,yBAAyB;;;;;;;;;EAS9F;;;;;;;;;EASA;;;;;;;;;UAUe,uCAAuC,UAAU,eAAe,yBAAyB;;;;;;;EAOxG;;;;;;;;;EASA;;;;;;;;;UAUe,iDAAiD,UAAU,eAAe,yBAAyB;;;;;;;EAOlH;;;;;;;;;EASA;;;;;;;;;;KAaU,wBAAwB,UAAU,QAAQ,SAClD,6BAA6B,KAC7B,uCAAuC,KACvC,iDAAiD;cAEhC,gBACnB;;;;EAIE,OAAO;WAED;EAER,YAAY,cAAc,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqHvC,eAAe,UAAU,OACvC,SAAS,6BAA6B,IACtC,oBAAoB,eACZ;EAAkB,OAAO;;iBACnB,eAAe,UAAU,OACvC,SAAS,uCAAuC,IAChD,oBAAoB,eACZ;EAAkB,OAAO;;iBACnB,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-
|
|
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) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["CacheHandler","Fetch","recordIdentifierFor","RequestManager","Store","instantiateRecord","registerDerivations","SchemaService","teardownRecord","DefaultCachePolicy","adapterFor","cleanup","LegacyNetworkHandler","normalize","pushPayload","serializeRecord","serializerFor","EmberArrayLikeExtension","EmberObjectArrayExtension","EmberObjectExtension","instantiateModel","modelFor","teardownModel","FragmentArrayExtension","FragmentExtension","fragmentsModelFor","DelegatingSchemaService","registerLegacyDerivations","restoreDeprecatedStoreBehaviors","macroCondition","getGlobalConfig","useLegacyStore","options","StoreKlass","WarpDrive","env","DEBUG","test","Error","linksMode","legacyRequests","BaseKlass","LegacyConfiguredStore","constructor","createArgs","requestManager","Object","defineProperty","configurable","enumerable","get","handlersOption","handlers","use","filter","Boolean","useCache","set","value","lifetimes","policy","apiCacheHardExpires","apiCacheSoftExpires","constraints","headers","Expires","createSchemaService","schema","schemas","registerResources","traits","trait","registerTrait","derivations","derivation","registerDerivation","transformations","transformation","registerTransformation","hashFns","hashFn","registerHashFn","CAUTION_MEGA_DANGER_ZONE_extensions","extension","CAUTION_MEGA_DANGER_ZONE_registerExtension","modelFragments","createCache","capabilities","cache","key","isDelegated","call","record","type","assertType","klass","modelName","_allowMissing","args","destroy","hasResource"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @module\n * @mergeModuleWith <project>\n */\n\nimport {\n CacheHandler,\n Fetch,\n recordIdentifierFor,\n RequestManager,\n Store,\n type StoreSetupOptions,\n} from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { instantiateRecord, registerDerivations, SchemaService, teardownRecord } from '@warp-drive/core/reactive';\nimport type { Handler } from '@warp-drive/core/request';\nimport { DefaultCachePolicy } from '@warp-drive/core/store';\nimport type { CacheCapabilitiesManager, ModelSchema, ResourceKey } from '@warp-drive/core/types';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestInfo } from '@warp-drive/core/types/request';\nimport type { ObjectSchema, ResourceSchema } from '@warp-drive/core/types/schema/fields';\n\nimport type { MinimumAdapterInterface } from './compat';\nimport {\n adapterFor,\n cleanup,\n LegacyNetworkHandler,\n normalize,\n pushPayload,\n serializeRecord,\n serializerFor,\n} from './compat';\nimport { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension } from './compat/extensions';\nimport type Model from './model';\nimport { instantiateRecord as instantiateModel, modelFor, teardownRecord as teardownModel } from './model';\nimport { FragmentArrayExtension, FragmentExtension } from './model-fragments';\nimport { fragmentsModelFor } from './model-fragments/hooks/model-for';\nimport { DelegatingSchemaService, registerDerivations as registerLegacyDerivations } from './model/migration-support';\nimport { restoreDeprecatedStoreBehaviors } from './store';\n\ninterface _LegacyStoreSetupOptions<T extends Cache> extends Omit<StoreSetupOptions<T>, 'schemas'> {\n /**\n * The {@link ResourceSchema | ResourceSchemas} or {@link ObjectSchema | ObjectSchemas} of entities\n * migrated to no longer use {@link Model}.\n *\n * :::caution\n * {@link Model} is still able to be used directly as a source of schema when using {@link useLegacyStore},\n * however, its reliance on EmberObject, classic computeds and resolver behaviors mean that Model\n * will stop working when these things are deprecated in Ember.\n * :::\n */\n schemas?: Array<ResourceSchema | ObjectSchema>;\n\n /**\n * Whether to include support for ModelFragments migrations.\n *\n * @default false\n */\n modelFragments?: boolean;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` with `linksMode`\n * enabled, meaning no legacy adapter/serializer request infrastructure is required.\n *\n * @public\n */\nexport interface LegacyModelStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n linksMode: true;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests?: false;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` along with the\n * legacy adapter/serializer network layer, but without the deprecated\n * `store.findRecord`/`findAll`/`query`/etc. request methods.\n *\n * @public\n */\nexport interface LegacyModelAndNetworkStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * @default false\n */\n linksMode: false;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests?: false;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` along with the\n * legacy adapter/serializer network layer and the deprecated\n * `store.findRecord`/`findAll`/`query`/etc. request methods.\n *\n * @public\n */\nexport interface LegacyModelAndNetworkAndRequestStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * @default false\n */\n linksMode: false;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests: true;\n}\n\n//export type ConfiguredStore<T = unknown> = typeof Store;\n\n/**\n * The available options when setting up the legacy store,\n * one of:\n *\n * - {@link LegacyModelStoreSetupOptions}\n * - {@link LegacyModelAndNetworkStoreSetupOptions}\n * - {@link LegacyModelAndNetworkAndRequestStoreSetupOptions}\n */\nexport type LegacyStoreSetupOptions<T extends Cache = Cache> =\n | LegacyModelStoreSetupOptions<T>\n | LegacyModelAndNetworkStoreSetupOptions<T>\n | LegacyModelAndNetworkAndRequestStoreSetupOptions<T>;\n\nexport declare class ConfiguredStore<\n T extends {\n /**\n * The {@link Cache} implementation this store was configured with.\n */\n cache: Cache;\n },\n> extends Store {\n // get cache(): T extends OptionsWithCache<infer R> ? R : never;\n createCache(capabilities: CacheCapabilitiesManager): T['cache'];\n}\n\n/**\n * Use the legacy store with the given options.\n *\n * See {@link LegacyStoreSetupOptions} for details on the available options.\n *\n * ```ts\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * schemas: [],\n * });\n * ```\n *\n * ### Adding Stateful Handlers\n *\n * A request {@link Handler} is sometimes more than a plain object or class\n * with a `request` method — it may need access to a stateful dependency such\n * as an Ember service (an auth token, a feature-flags service, an i18n\n * helper, etc.).\n *\n * A plain class handler that only relies on Ember's `@service` decorator will\n * not work here on its own: the handler is never instantiated *through*\n * Ember's container (it's just `new`'d up), so it has no owner and its\n * `@service` injections would fail to resolve.\n *\n * Instead, give `handlers` a function. It receives the {@link Store} instance\n * being configured, which by the time the function runs already has an owner\n * assigned. Use `getOwner`/`setOwner` from `@ember/owner` to transfer that\n * owner onto your handler instance before returning it, exactly as you would\n * when constructing any other DI-aware object outside of the container:\n *\n * ```ts\n * import { getOwner, setOwner } from '@ember/owner';\n * import { service } from '@ember/service';\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import type { NextFn } from '@warp-drive/core/request';\n * import type { RequestContext } from '@warp-drive/core/types/request';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * class AuthHandler {\n * @service session;\n *\n * request<T>(context: RequestContext, next: NextFn<T>) {\n * const headers = new Headers(context.request.headers);\n * headers.append('Authorization', `Bearer ${this.session.accessToken}`);\n * return next(Object.assign({}, context.request, { headers }));\n * }\n * }\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * handlers: (store) => {\n * const authHandler = new AuthHandler();\n * setOwner(authHandler, getOwner(store)!);\n * return [authHandler];\n * },\n * });\n * ```\n *\n * The `handlers` function is invoked lazily and only once per store instance,\n * the first time `store.requestManager` is accessed, so it is safe to do\n * owner-dependent setup like this inside of it.\n *\n * ### Accessing the Store from a Handler's Context\n *\n * If a handler only needs to read something *off of the store itself*\n * (its cache, or a property/service you've attached to a custom store\n * subclass) rather than an unrelated Ember service, there is a second,\n * simpler option that requires no DI/`setOwner` wiring at all.\n *\n * Every request issued via {@link Store.request | store.request(...)}\n * automatically carries the originating store along as\n * {@link RequestInfo.store | context.request.store}. Any handler — a plain\n * object, a function-built handler, or a class — can read it directly,\n * without needing the `handlers` callback form shown above:\n *\n * ```ts\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import type { NextFn } from '@warp-drive/core/request';\n * import type { RequestContext } from '@warp-drive/core/types/request';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * const LoggingHandler = {\n * request<T>(context: RequestContext, next: NextFn<T>) {\n * // only present when the request was made via `store.request(...)`\n * const store = context.request.store;\n * if (store) {\n * console.log(`[${store.constructor.name}] ${context.request.url ?? ''}`);\n * }\n * return next(context.request);\n * },\n * };\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * handlers: [LoggingHandler],\n * });\n * ```\n *\n * The trade-off versus the `getOwner`/`setOwner` pattern above is that\n * `context.request.store` is only populated for requests issued via\n * `store.request(...)`; a request made directly against a\n * {@link RequestManager} won't have it set unless the caller supplies it\n * explicitly, so a handler relying on it should treat it as optional (as\n * `LoggingHandler` does above).\n */\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelAndNetworkStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelAndNetworkAndRequestStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyStoreSetupOptions<T>,\n StoreKlass: typeof Store = Store\n): typeof ConfiguredStore<{ cache: T }> {\n assert(`If legacyRequests is true, linksMode must be false`, !(options.linksMode && options.legacyRequests));\n // we extend the store to ensure we don't leak our prototype overrides to other stores below.\n class BaseKlass extends StoreKlass {}\n class LegacyConfiguredStore extends BaseKlass {\n constructor(createArgs?: unknown) {\n super(createArgs);\n // installed via defineProperty (rather than a class field/accessor) so that\n // this lazy override of the inherited `requestManager` field does not\n // conflict with the documented pattern of assigning it directly on\n // consumer-authored Store subclasses. The setter preserves the ability\n // to replace `requestManager` outright after construction.\n let requestManager: RequestManager | undefined;\n Object.defineProperty(this, 'requestManager', {\n configurable: true,\n enumerable: true,\n get: (): RequestManager => {\n if (!requestManager) {\n const handlersOption = options.handlers;\n const handlers = typeof handlersOption === 'function' ? handlersOption(this) : (handlersOption ?? []);\n requestManager = new RequestManager()\n .use([options.linksMode ? null : LegacyNetworkHandler, ...handlers, Fetch].filter(Boolean) as Handler[])\n .useCache(CacheHandler);\n }\n return requestManager;\n },\n set: (value: RequestManager): void => {\n requestManager = value;\n },\n });\n }\n\n lifetimes =\n options.policy ??\n new DefaultCachePolicy({\n apiCacheHardExpires: 15 * 60 * 1000, // 15 minutes\n apiCacheSoftExpires: 1 * 30 * 1000, // 30 seconds\n constraints: {\n headers: {\n 'X-WarpDrive-Expires': true,\n 'Cache-Control': true,\n Expires: true,\n },\n },\n });\n\n createSchemaService(): DelegatingSchemaService {\n // prepare for PolarisMode\n const schema = new SchemaService();\n registerDerivations(schema);\n if (options.schemas) schema.registerResources(options.schemas);\n\n if (options.traits) {\n for (const trait of options.traits) {\n schema.registerTrait(trait);\n }\n }\n\n if (options.derivations) {\n for (const derivation of options.derivations) {\n schema.registerDerivation(derivation);\n }\n }\n\n if (options.transformations) {\n for (const transformation of options.transformations) {\n schema.registerTransformation(transformation);\n }\n }\n\n if (options.hashFns) {\n for (const hashFn of options.hashFns) {\n schema.registerHashFn(hashFn);\n }\n }\n\n if (options.CAUTION_MEGA_DANGER_ZONE_extensions) {\n for (const extension of options.CAUTION_MEGA_DANGER_ZONE_extensions) {\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(extension);\n }\n }\n\n // Add support for LegacyMode ReactiveResource with Maximal coverage\n // for upgrading from 4.x\n registerLegacyDerivations(schema);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberArrayLikeExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectArrayExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectExtension);\n\n // add support for fragments\n if (options.modelFragments) {\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentArrayExtension);\n }\n\n // Add fallback for Models\n return new DelegatingSchemaService(this, schema);\n }\n\n createCache(capabilities: CacheCapabilitiesManager) {\n // oxlint-disable-next-line new-cap\n return new options.cache(capabilities);\n }\n\n instantiateRecord(key: ResourceKey, createArgs?: Record<string, unknown>) {\n if (this.schema.isDelegated(key)) {\n return instantiateModel.call(this, key, createArgs);\n }\n return instantiateRecord(this, key, createArgs);\n }\n\n teardownRecord(record: unknown): void {\n const key = recordIdentifierFor(record);\n if (this.schema.isDelegated(key)) {\n return teardownModel.call(this, record as Model);\n }\n return teardownRecord(record);\n }\n\n modelFor<InstanceType>(type: TypeFromInstance<InstanceType>): ModelSchema<InstanceType>;\n modelFor(type: string): ModelSchema;\n modelFor(type: string): ModelSchema {\n assertType(this.schema, type);\n\n const klass =\n // prefer real models if present\n (modelFor.call(this, type) as ModelSchema) ||\n // fallback to ShimModelClass specific to fragments if fragments support in use\n (options.modelFragments ? (fragmentsModelFor.call(this, type) as ModelSchema) : false) ||\n // fallback to ShimModelClass\n super.modelFor(type);\n\n return klass;\n }\n\n adapterFor(this: Store, modelName: string): MinimumAdapterInterface;\n adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;\n adapterFor(this: Store, modelName: string, _allowMissing?: true): MinimumAdapterInterface | undefined {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n // @ts-expect-error\n return adapterFor.call(this, modelName, _allowMissing);\n }\n\n serializerFor(this: Store, ...args: Parameters<typeof serializerFor>): ReturnType<typeof serializerFor> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return serializerFor.call(this, ...args);\n }\n\n pushPayload(this: Store, ...args: Parameters<typeof pushPayload>): ReturnType<typeof pushPayload> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return pushPayload.call(this, ...args);\n }\n\n normalize(this: Store, ...args: Parameters<typeof normalize>): ReturnType<typeof normalize> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return normalize.call(this, ...args);\n }\n\n serializeRecord(this: Store, ...args: Parameters<typeof serializeRecord>): ReturnType<typeof serializeRecord> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return serializeRecord.call(this, ...args);\n }\n\n destroy() {\n if (!options.linksMode) {\n cleanup.call(this);\n }\n super.destroy();\n }\n }\n\n if (options.legacyRequests) {\n restoreDeprecatedStoreBehaviors(BaseKlass);\n }\n\n return LegacyConfiguredStore;\n}\n\nfunction assertType(schema: DelegatingSchemaService, type: string) {\n assert(`Expected type ${type} to be a valid ResourceType`, schema.hasResource({ type }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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gBAAgB4E,KAAK,MAAM,GAAGO,IAAI;EAC3C;EAEAC,UAAU;GACR,IAAI,CAACnE,QAAQO,WACX5B,QAAQgF,KAAK,IAAI;GAEnB,MAAMQ,QAAQ;EAChB;CACF;CAEA,IAAInE,QAAQQ,gBACVZ,gCAAgCa,SAAS;CAG3C,OAAOC;AACT;AAEA,SAASoD,WAAW3B,QAAiC0B,MAAc;CACjEhE,eAAAC,gBAAA,CAAA,CAAAI,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,iBAAiBuD,KAAI,4BAA6B;CAAA,EAAA,CAAE1B,OAAOiC,YAAY,EAAEP,KAAK,CAAC,CAAC;AACzF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["CacheHandler","Fetch","recordIdentifierFor","RequestManager","Store","instantiateRecord","registerDerivations","SchemaService","teardownRecord","DefaultCachePolicy","adapterFor","cleanup","LegacyNetworkHandler","normalize","pushPayload","serializeRecord","serializerFor","EmberArrayLikeExtension","EmberObjectArrayExtension","EmberObjectExtension","instantiateModel","modelFor","teardownModel","FragmentArrayExtension","FragmentExtension","fragmentsModelFor","releaseLegacySupport","DelegatingSchemaService","registerLegacyDerivations","restoreDeprecatedStoreBehaviors","macroCondition","getGlobalConfig","useLegacyStore","options","StoreKlass","WarpDrive","env","DEBUG","test","Error","linksMode","legacyRequests","BaseKlass","LegacyConfiguredStore","constructor","createArgs","requestManager","Object","defineProperty","configurable","enumerable","get","handlersOption","handlers","use","filter","Boolean","useCache","set","value","lifetimes","policy","apiCacheHardExpires","apiCacheSoftExpires","constraints","headers","Expires","createSchemaService","schema","schemas","registerResources","traits","trait","registerTrait","derivations","derivation","registerDerivation","transformations","transformation","registerTransformation","hashFns","hashFn","registerHashFn","CAUTION_MEGA_DANGER_ZONE_extensions","extension","CAUTION_MEGA_DANGER_ZONE_registerExtension","modelFragments","createCache","capabilities","cache","key","isDelegated","call","record","type","assertType","klass","modelName","_allowMissing","args","destroy","hasResource"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @module\n * @mergeModuleWith <project>\n */\n\nimport {\n CacheHandler,\n Fetch,\n recordIdentifierFor,\n RequestManager,\n Store,\n type StoreSetupOptions,\n} from '@warp-drive/core';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { instantiateRecord, registerDerivations, SchemaService, teardownRecord } from '@warp-drive/core/reactive';\nimport type { Handler } from '@warp-drive/core/request';\nimport { DefaultCachePolicy } from '@warp-drive/core/store';\nimport type { CacheCapabilitiesManager, ModelSchema, ResourceKey } from '@warp-drive/core/types';\nimport type { Cache } from '@warp-drive/core/types/cache';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\n// oxlint-disable-next-line no-unused-vars\nimport type { RequestInfo } from '@warp-drive/core/types/request';\nimport type { ObjectSchema, ResourceSchema } from '@warp-drive/core/types/schema/fields';\n\nimport type { MinimumAdapterInterface } from './compat';\nimport {\n adapterFor,\n cleanup,\n LegacyNetworkHandler,\n normalize,\n pushPayload,\n serializeRecord,\n serializerFor,\n} from './compat';\nimport { EmberArrayLikeExtension, EmberObjectArrayExtension, EmberObjectExtension } from './compat/extensions';\nimport type Model from './model';\nimport { instantiateRecord as instantiateModel, modelFor, teardownRecord as teardownModel } from './model';\nimport { FragmentArrayExtension, FragmentExtension } from './model-fragments';\nimport { fragmentsModelFor } from './model-fragments/hooks/model-for';\nimport { releaseLegacySupport } from './model/-private/legacy-relationships-support';\nimport { DelegatingSchemaService, registerDerivations as registerLegacyDerivations } from './model/migration-support';\nimport { restoreDeprecatedStoreBehaviors } from './store';\n\ninterface _LegacyStoreSetupOptions<T extends Cache> extends Omit<StoreSetupOptions<T>, 'schemas'> {\n /**\n * The {@link ResourceSchema | ResourceSchemas} or {@link ObjectSchema | ObjectSchemas} of entities\n * migrated to no longer use {@link Model}.\n *\n * :::caution\n * {@link Model} is still able to be used directly as a source of schema when using {@link useLegacyStore},\n * however, its reliance on EmberObject, classic computeds and resolver behaviors mean that Model\n * will stop working when these things are deprecated in Ember.\n * :::\n */\n schemas?: Array<ResourceSchema | ObjectSchema>;\n\n /**\n * Whether to include support for ModelFragments migrations.\n *\n * @default false\n */\n modelFragments?: boolean;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` with `linksMode`\n * enabled, meaning no legacy adapter/serializer request infrastructure is required.\n *\n * @public\n */\nexport interface LegacyModelStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n linksMode: true;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests?: false;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` along with the\n * legacy adapter/serializer network layer, but without the deprecated\n * `store.findRecord`/`findAll`/`query`/etc. request methods.\n *\n * @public\n */\nexport interface LegacyModelAndNetworkStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * @default false\n */\n linksMode: false;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests?: false;\n}\n\n/**\n * Setup options for a legacy store configured to use `Model` along with the\n * legacy adapter/serializer network layer and the deprecated\n * `store.findRecord`/`findAll`/`query`/etc. request methods.\n *\n * @public\n */\nexport interface LegacyModelAndNetworkAndRequestStoreSetupOptions<T extends Cache> extends _LegacyStoreSetupOptions<T> {\n /**\n * If true, it is presumed that no requests require use of the LegacyNetworkHandler\n * and associated adapters/serializer methods.\n *\n * @default false\n */\n linksMode: false;\n /**\n * if true, all legacy request methods and supporting infrastructure will\n * be available on the store.\n *\n * If legacyRequests is true, {@link linksMode} must be false\n *\n * @default false\n */\n legacyRequests: true;\n}\n\n//export type ConfiguredStore<T = unknown> = typeof Store;\n\n/**\n * The available options when setting up the legacy store,\n * one of:\n *\n * - {@link LegacyModelStoreSetupOptions}\n * - {@link LegacyModelAndNetworkStoreSetupOptions}\n * - {@link LegacyModelAndNetworkAndRequestStoreSetupOptions}\n */\nexport type LegacyStoreSetupOptions<T extends Cache = Cache> =\n | LegacyModelStoreSetupOptions<T>\n | LegacyModelAndNetworkStoreSetupOptions<T>\n | LegacyModelAndNetworkAndRequestStoreSetupOptions<T>;\n\nexport declare class ConfiguredStore<\n T extends {\n /**\n * The {@link Cache} implementation this store was configured with.\n */\n cache: Cache;\n },\n> extends Store {\n // get cache(): T extends OptionsWithCache<infer R> ? R : never;\n createCache(capabilities: CacheCapabilitiesManager): T['cache'];\n}\n\n/**\n * Use the legacy store with the given options.\n *\n * See {@link LegacyStoreSetupOptions} for details on the available options.\n *\n * ```ts\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * schemas: [],\n * });\n * ```\n *\n * ### Adding Stateful Handlers\n *\n * A request {@link Handler} is sometimes more than a plain object or class\n * with a `request` method — it may need access to a stateful dependency such\n * as an Ember service (an auth token, a feature-flags service, an i18n\n * helper, etc.).\n *\n * A plain class handler that only relies on Ember's `@service` decorator will\n * not work here on its own: the handler is never instantiated *through*\n * Ember's container (it's just `new`'d up), so it has no owner and its\n * `@service` injections would fail to resolve.\n *\n * Instead, give `handlers` a function. It receives the {@link Store} instance\n * being configured, which by the time the function runs already has an owner\n * assigned. Use `getOwner`/`setOwner` from `@ember/owner` to transfer that\n * owner onto your handler instance before returning it, exactly as you would\n * when constructing any other DI-aware object outside of the container:\n *\n * ```ts\n * import { getOwner, setOwner } from '@ember/owner';\n * import { service } from '@ember/service';\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import type { NextFn } from '@warp-drive/core/request';\n * import type { RequestContext } from '@warp-drive/core/types/request';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * class AuthHandler {\n * @service session;\n *\n * request<T>(context: RequestContext, next: NextFn<T>) {\n * const headers = new Headers(context.request.headers);\n * headers.append('Authorization', `Bearer ${this.session.accessToken}`);\n * return next(Object.assign({}, context.request, { headers }));\n * }\n * }\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * handlers: (store) => {\n * const authHandler = new AuthHandler();\n * setOwner(authHandler, getOwner(store)!);\n * return [authHandler];\n * },\n * });\n * ```\n *\n * The `handlers` function is invoked lazily and only once per store instance,\n * the first time `store.requestManager` is accessed, so it is safe to do\n * owner-dependent setup like this inside of it.\n *\n * ### Accessing the Store from a Handler's Context\n *\n * If a handler only needs to read something *off of the store itself*\n * (its cache, or a property/service you've attached to a custom store\n * subclass) rather than an unrelated Ember service, there is a second,\n * simpler option that requires no DI/`setOwner` wiring at all.\n *\n * Every request issued via {@link Store.request | store.request(...)}\n * automatically carries the originating store along as\n * {@link RequestInfo.store | context.request.store}. Any handler — a plain\n * object, a function-built handler, or a class — can read it directly,\n * without needing the `handlers` callback form shown above:\n *\n * ```ts\n * import { useLegacyStore } from '@warp-drive/legacy';\n * import type { NextFn } from '@warp-drive/core/request';\n * import type { RequestContext } from '@warp-drive/core/types/request';\n * import { JSONAPICache } from '@warp-drive/json-api';\n *\n * const LoggingHandler = {\n * request<T>(context: RequestContext, next: NextFn<T>) {\n * // only present when the request was made via `store.request(...)`\n * const store = context.request.store;\n * if (store) {\n * console.log(`[${store.constructor.name}] ${context.request.url ?? ''}`);\n * }\n * return next(context.request);\n * },\n * };\n *\n * export default useLegacyStore({\n * linksMode: false,\n * legacyRequests: true,\n * cache: JSONAPICache,\n * handlers: [LoggingHandler],\n * });\n * ```\n *\n * The trade-off versus the `getOwner`/`setOwner` pattern above is that\n * `context.request.store` is only populated for requests issued via\n * `store.request(...)`; a request made directly against a\n * {@link RequestManager} won't have it set unless the caller supplies it\n * explicitly, so a handler relying on it should treat it as optional (as\n * `LoggingHandler` does above).\n */\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelAndNetworkStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyModelAndNetworkAndRequestStoreSetupOptions<T>,\n StoreKlass?: typeof Store\n): typeof ConfiguredStore<{ cache: T }>;\nexport function useLegacyStore<T extends Cache>(\n options: LegacyStoreSetupOptions<T>,\n StoreKlass: typeof Store = Store\n): typeof ConfiguredStore<{ cache: T }> {\n assert(`If legacyRequests is true, linksMode must be false`, !(options.linksMode && options.legacyRequests));\n // we extend the store to ensure we don't leak our prototype overrides to other stores below.\n class BaseKlass extends StoreKlass {}\n class LegacyConfiguredStore extends BaseKlass {\n constructor(createArgs?: unknown) {\n super(createArgs);\n // installed via defineProperty (rather than a class field/accessor) so that\n // this lazy override of the inherited `requestManager` field does not\n // conflict with the documented pattern of assigning it directly on\n // consumer-authored Store subclasses. The setter preserves the ability\n // to replace `requestManager` outright after construction.\n let requestManager: RequestManager | undefined;\n Object.defineProperty(this, 'requestManager', {\n configurable: true,\n enumerable: true,\n get: (): RequestManager => {\n if (!requestManager) {\n const handlersOption = options.handlers;\n const handlers = typeof handlersOption === 'function' ? handlersOption(this) : (handlersOption ?? []);\n requestManager = new RequestManager()\n .use([options.linksMode ? null : LegacyNetworkHandler, ...handlers, Fetch].filter(Boolean) as Handler[])\n .useCache(CacheHandler);\n }\n return requestManager;\n },\n set: (value: RequestManager): void => {\n requestManager = value;\n },\n });\n }\n\n lifetimes =\n options.policy ??\n new DefaultCachePolicy({\n apiCacheHardExpires: 15 * 60 * 1000, // 15 minutes\n apiCacheSoftExpires: 1 * 30 * 1000, // 30 seconds\n constraints: {\n headers: {\n 'X-WarpDrive-Expires': true,\n 'Cache-Control': true,\n Expires: true,\n },\n },\n });\n\n createSchemaService(): DelegatingSchemaService {\n // prepare for PolarisMode\n const schema = new SchemaService();\n registerDerivations(schema);\n if (options.schemas) schema.registerResources(options.schemas);\n\n if (options.traits) {\n for (const trait of options.traits) {\n schema.registerTrait(trait);\n }\n }\n\n if (options.derivations) {\n for (const derivation of options.derivations) {\n schema.registerDerivation(derivation);\n }\n }\n\n if (options.transformations) {\n for (const transformation of options.transformations) {\n schema.registerTransformation(transformation);\n }\n }\n\n if (options.hashFns) {\n for (const hashFn of options.hashFns) {\n schema.registerHashFn(hashFn);\n }\n }\n\n if (options.CAUTION_MEGA_DANGER_ZONE_extensions) {\n for (const extension of options.CAUTION_MEGA_DANGER_ZONE_extensions) {\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(extension);\n }\n }\n\n // Add support for LegacyMode ReactiveResource with Maximal coverage\n // for upgrading from 4.x\n registerLegacyDerivations(schema);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberArrayLikeExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectArrayExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension(EmberObjectExtension);\n\n // add support for fragments\n if (options.modelFragments) {\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentExtension);\n schema.CAUTION_MEGA_DANGER_ZONE_registerExtension?.(FragmentArrayExtension);\n }\n\n // Add fallback for Models\n return new DelegatingSchemaService(this, schema);\n }\n\n createCache(capabilities: CacheCapabilitiesManager) {\n // oxlint-disable-next-line new-cap\n return new options.cache(capabilities);\n }\n\n instantiateRecord(key: ResourceKey, createArgs?: Record<string, unknown>) {\n if (this.schema.isDelegated(key)) {\n return instantiateModel.call(this, key, createArgs);\n }\n return instantiateRecord(this, key, createArgs);\n }\n\n teardownRecord(record: unknown): void {\n const key = recordIdentifierFor(record);\n if (this.schema.isDelegated(key)) {\n return teardownModel.call(this, record as Model);\n }\n releaseLegacySupport(key);\n return teardownRecord(record);\n }\n\n modelFor<InstanceType>(type: TypeFromInstance<InstanceType>): ModelSchema<InstanceType>;\n modelFor(type: string): ModelSchema;\n modelFor(type: string): ModelSchema {\n assertType(this.schema, type);\n\n const klass =\n // prefer real models if present\n (modelFor.call(this, type) as ModelSchema) ||\n // fallback to ShimModelClass specific to fragments if fragments support in use\n (options.modelFragments ? (fragmentsModelFor.call(this, type) as ModelSchema) : false) ||\n // fallback to ShimModelClass\n super.modelFor(type);\n\n return klass;\n }\n\n adapterFor(this: Store, modelName: string): MinimumAdapterInterface;\n adapterFor(this: Store, modelName: string, _allowMissing: true): MinimumAdapterInterface | undefined;\n adapterFor(this: Store, modelName: string, _allowMissing?: true): MinimumAdapterInterface | undefined {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n // @ts-expect-error\n return adapterFor.call(this, modelName, _allowMissing);\n }\n\n serializerFor(this: Store, ...args: Parameters<typeof serializerFor>): ReturnType<typeof serializerFor> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return serializerFor.call(this, ...args);\n }\n\n pushPayload(this: Store, ...args: Parameters<typeof pushPayload>): ReturnType<typeof pushPayload> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return pushPayload.call(this, ...args);\n }\n\n normalize(this: Store, ...args: Parameters<typeof normalize>): ReturnType<typeof normalize> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return normalize.call(this, ...args);\n }\n\n serializeRecord(this: Store, ...args: Parameters<typeof serializeRecord>): ReturnType<typeof serializeRecord> {\n assert(\n `useLegacyStore was setup in linksMode. linksMode assumes that all requests have been migrated away from adapters and serializers.`,\n !options.linksMode\n );\n return serializeRecord.call(this, ...args);\n }\n\n destroy() {\n if (!options.linksMode) {\n cleanup.call(this);\n }\n super.destroy();\n }\n }\n\n if (options.legacyRequests) {\n restoreDeprecatedStoreBehaviors(BaseKlass);\n }\n\n return LegacyConfiguredStore;\n}\n\nfunction assertType(schema: DelegatingSchemaService, type: string) {\n assert(`Expected type ${type} to be a valid ResourceType`, schema.hasResource({ type }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwSA,SAAgBgC,eACdC,SACAC,aAA2B9B,OACW;CACtC0B,eAAAC,gBAAA,CAAA,CAAAI,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,oDAAoD;CAAA,EAAA,CAAE,EAAEN,QAAQO,aAAaP,QAAQQ,eAAe;CAE3G,MAAMC,kBAAkBR,WAAW,CAAA;CACnC,MAAMS,8BAA8BD,UAAU;EAC5CE,YAAYC,YAAsB;GAChC,MAAMA,UAAU;GAMhB,IAAIC;GACJC,OAAOC,eAAe,MAAM,kBAAkB;IAC5CC,cAAc;IACdC,YAAY;IACZC,WAA2B;KACzB,IAAI,CAACL,gBAAgB;MACnB,MAAMM,iBAAiBnB,QAAQoB;MAC/B,MAAMA,WAAW,OAAOD,mBAAmB,aAAaA,eAAe,IAAI,IAAKA,kBAAkB,CAAA;MAClGN,iBAAiB,IAAI3C,eAAe,CAAC,CAClCmD,IAAI;OAACrB,QAAQO,YAAY,OAAO5B;OAAsB,GAAGyC;OAAUpD;MAAK,CAAC,CAACsD,OAAOC,OAAO,CAAc,CAAC,CACvGC,SAASzD,YAAY;KAC1B;KACA,OAAO8C;IACT;IACAY,MAAMC,UAAgC;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,KAAK,MAAM,GAAGO,IAAI;EACvC;EAEAtF,UAAuB,GAAGsF,MAAkE;GAC1FrE,eAAAC,gBAAA,CAAA,CAAAI,UAAAC,IAAAC,KAAA,OAAAC,SAAA;IAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,mIAAmI;GAAA,EAAA,CACnI,CAACN,QAAQO,SAAS;GAEpB,OAAO3B,UAAU+E,KAAK,MAAM,GAAGO,IAAI;EACrC;EAEApF,gBAA6B,GAAGoF,MAA8E;GAC5GrE,eAAAC,gBAAA,CAAA,CAAAI,UAAAC,IAAAC,KAAA,OAAAC,SAAA;IAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,mIAAmI;GAAA,EAAA,CACnI,CAACN,QAAQO,SAAS;GAEpB,OAAOzB,gBAAgB6E,KAAK,MAAM,GAAGO,IAAI;EAC3C;EAEAC,UAAU;GACR,IAAI,CAACnE,QAAQO,WACX7B,QAAQiF,KAAK,IAAI;GAEnB,MAAMQ,QAAQ;EAChB;CACF;CAEA,IAAInE,QAAQQ,gBACVZ,gCAAgCa,SAAS;CAG3C,OAAOC;AACT;AAEA,SAASoD,WAAW3B,QAAiC0B,MAAc;CACjEhE,eAAAC,gBAAA,CAAA,CAAAI,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,iBAAiBuD,KAAI,4BAA6B;CAAA,EAAA,CAAE1B,OAAOiC,YAAY,EAAEP,KAAK,CAAC,CAAC;AACzF"}
|
package/dist/model/-private.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as PromiseManyArray, n as LEGACY_SUPPORT, o as PromiseBelongsTo, r as lookupLegacySupport, t as Errors } from "../errors-CS110tMl.js";
|
|
2
2
|
|
|
3
3
|
export { Errors, LEGACY_SUPPORT, PromiseBelongsTo, PromiseManyArray, lookupLegacySupport };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as lookupLegacySupport, t as Errors } from "../errors-
|
|
2
|
-
import { _ as save, a as RecordState, c as _save, d as createSnapshot, f as deleteRecord, g as rollbackAttributes, h as reload, l as belongsTo, m as hasMany, o as _destroyRecord, p as destroyRecord, s as _reload, t as buildSchema, u as changedAttributes, v as serialize, y as unloadRecord } from "../schema-provider-
|
|
1
|
+
import { r as lookupLegacySupport, t as Errors } from "../errors-CS110tMl.js";
|
|
2
|
+
import { _ as save, a as RecordState, c as _save, d as createSnapshot, f as deleteRecord, g as rollbackAttributes, h as reload, l as belongsTo, m as hasMany, o as _destroyRecord, p as destroyRecord, s as _reload, t as buildSchema, u as changedAttributes, v as serialize, y as unloadRecord } from "../schema-provider-DguGmQDS.js";
|
|
3
3
|
import "./-private.js";
|
|
4
4
|
import { recordIdentifierFor } from "@warp-drive/core";
|
|
5
5
|
import { assertPrivateStore } from "@warp-drive/core/store/-private";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-62hn5_PD.d.ts","names":[],"sources":["../src/model/-private/belongs-to.ts","../src/model/-private/promise-many-array.ts","../src/model/-private/references/has-many.ts","../src/model/-private/legacy-relationships-support.ts","../src/model/-private/promise-belongs-to.ts","../src/model/-private/type-utils.ts","../src/model/-private/references/belongs-to.ts","../src/model/-private/model-methods.ts","../src/model/-private/record-state.ts","../src/model/-private/errors.ts","../src/model/-private/model.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KAeY,UAAU,qBAAqB;KAE/B,oBAAoB,GAAG;EACjC,OAAO;EACP,iBAAiB,UAAU,iCAAiC,OAAO;EACnE;EACA;EACA;EACA;;;;;;;;;;;;;;;;;;;;;EAsBA;;KAGU,OAAO,KAAK,QAAQ;KAQpB,sBAAsB,MAAM,MAAM,QAAQ,MAAM,aAAa,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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cAAY,yBAAyB;EACpD,oBAAqB,IAAI;EAEzB;EAEA,YACE,OAAO,OACP,OAAO,OACP,kBAAkB,cAAY,yBAAyB,KACvD,qBAAqB,gBACrB,KAAK;;;;;;EA0BP;;;;;;;;MAgBI,eAAe,cAAY,yBAAyB;EAyCxD,aAEgE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4ChE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CA,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCP;;;;;;;EAkBA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6CT,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyGR,KACE,KAAK,2BAA2B,4BAChC,sBACC,QAAQ,kBAAU;EAkDrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDA,SAAS,kBAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2EnB,KAAW,UAAU,oBAAoB,QAAQ,kBAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4D3D,OAAO,UAAU,oBAAoB,QAAQ,kBAAU;;;;cChrB5C,gBAAgB,IAAI,cAAc,qBAAqB;
|
|
1
|
+
{"version":3,"file":"model-62hn5_PD.d.ts","names":[],"sources":["../src/model/-private/belongs-to.ts","../src/model/-private/promise-many-array.ts","../src/model/-private/references/has-many.ts","../src/model/-private/legacy-relationships-support.ts","../src/model/-private/promise-belongs-to.ts","../src/model/-private/type-utils.ts","../src/model/-private/references/belongs-to.ts","../src/model/-private/model-methods.ts","../src/model/-private/record-state.ts","../src/model/-private/errors.ts","../src/model/-private/model.ts"],"mappings":";;;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