@warp-drive/legacy 5.10.0-alpha.0 → 5.10.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/-private.d.ts +6 -6
- package/dist/adapter/-private.d.ts.map +1 -1
- package/dist/compat/utils.d.ts +11 -12
- package/dist/compat/utils.d.ts.map +1 -1
- package/dist/{errors-BEEsrHbl.js → errors-CS110tMl.js} +9 -2
- package/dist/errors-CS110tMl.js.map +1 -0
- package/dist/index.d.ts +8 -9
- 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.d.ts +8 -9
- package/dist/model/migration-support.d.ts.map +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-fragments.d.ts +11 -11
- package/dist/model-fragments.d.ts.map +1 -1
- package/dist/model.d.ts +17 -17
- package/dist/model.d.ts.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/serializer/rest.d.ts +2 -2
- package/dist/serializer/rest.d.ts.map +1 -1
- package/dist/serializer/transform.d.ts +10 -11
- package/dist/serializer/transform.d.ts.map +1 -1
- package/dist/serializer.d.ts +1 -2
- package/dist/serializer.d.ts.map +1 -1
- package/dist/store.d.ts +2 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/unpkg/dev/{compat-BqmMZNci.js → compat-DNQT2TQx.js} +2 -2
- package/dist/unpkg/dev/{compat-BqmMZNci.js.map → compat-DNQT2TQx.js.map} +1 -1
- package/dist/unpkg/dev/compat.js +1 -1
- 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 +4 -2
- 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/compat/builders.js +1 -1
- package/dist/unpkg/dev-deprecated/{compat-D_T7cGfd.js → compat-CeT0PnVX.js} +2 -2
- package/dist/unpkg/dev-deprecated/{compat-D_T7cGfd.js.map → compat-CeT0PnVX.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/compat.js +1 -1
- 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 +5 -3
- 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-BeGORt6h.js} +5 -5
- package/dist/unpkg/dev-deprecated/{model-C1ts6Mod.js.map → model-BeGORt6h.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/model.js +2 -2
- package/dist/unpkg/dev-deprecated/{schema-provider-D2ESMsA8.js → schema-provider-NmtdR4n_.js} +4 -8
- package/dist/unpkg/dev-deprecated/schema-provider-NmtdR4n_.js.map +1 -0
- package/dist/unpkg/dev-deprecated/{store-BX7GvXC_.js → store-BCOLSC6z.js} +3 -3
- package/dist/unpkg/dev-deprecated/{store-BX7GvXC_.js.map → store-BCOLSC6z.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/store.js +1 -1
- package/dist/unpkg/dev-deprecated/{util-9mgEBJ3W.js → util-CXA3RNYH.js} +2 -2
- package/dist/unpkg/dev-deprecated/{util-9mgEBJ3W.js.map → util-CXA3RNYH.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/{utils-Cl86-e7F.js → utils-DQkMqhDv.js} +2 -2
- package/dist/unpkg/dev-deprecated/{utils-Cl86-e7F.js.map → utils-DQkMqhDv.js.map} +1 -1
- 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 +9 -9
- 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
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuSA,SAAgB+B,eACdC,SACAC,aAA2B7B,OACW;CACtCyB,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,IAAI1C,eAAe,CAAC,CAClCkD,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UAAAC,IAAAC,KAAA,OAAAC,SAAA;IAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,mIAAmI;GAAA,EAAA,CACnI,CAACN,QAAQO,SAAS;GAEpB,OAAOzB,YAAY6E,KAAK,MAAM,GAAGO,IAAI;EACvC;EAEArF,UAAuB,GAAGqF,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,OAAO1B,UAAU8E,KAAK,MAAM,GAAGO,IAAI;EACrC;EAEAnF,gBAA6B,GAAGmF,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,OAAOxB,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,M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B,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 };
|
|
@@ -17,7 +17,7 @@ import { Derivation, HashFn, Transformation } from "@warp-drive/core/types/schem
|
|
|
17
17
|
* {@link TypedRecordInstance}, for use when migrating a resource from
|
|
18
18
|
* `Model` to a schema-based record while preserving these APIs.
|
|
19
19
|
*/
|
|
20
|
-
type WithLegacyDerivations<T extends TypedRecordInstance> = T & MinimalLegacyRecord & {
|
|
20
|
+
export type WithLegacyDerivations<T extends TypedRecordInstance> = T & MinimalLegacyRecord & {
|
|
21
21
|
/**
|
|
22
22
|
* see {@link belongsTo}
|
|
23
23
|
*/
|
|
@@ -102,7 +102,7 @@ interface LegacyModeRecord<T extends TypedRecordInstance> {
|
|
|
102
102
|
* ```
|
|
103
103
|
*
|
|
104
104
|
*/
|
|
105
|
-
type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;
|
|
105
|
+
export type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;
|
|
106
106
|
/**
|
|
107
107
|
* A function which adds the necessary fields to a schema and marks it as
|
|
108
108
|
* being in LegacyMode. This is used to support the legacy features of
|
|
@@ -157,7 +157,7 @@ type WithLegacy<T extends TypedRecordInstance> = T & LegacyModeRecord<T>;
|
|
|
157
157
|
* @return The schema with legacy support added.
|
|
158
158
|
* @public
|
|
159
159
|
*/
|
|
160
|
-
declare function withDefaults(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
|
|
160
|
+
export declare function withDefaults(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
|
|
161
161
|
/**
|
|
162
162
|
* Adds the necessasary fields to the schema for supporting
|
|
163
163
|
* the deprecated request methods on LegacyMode schemas.
|
|
@@ -177,7 +177,7 @@ declare function withDefaults(schema: WithPartial<LegacyResourceSchema, "legacy"
|
|
|
177
177
|
* });
|
|
178
178
|
* ```
|
|
179
179
|
*/
|
|
180
|
-
declare function withRestoredDeprecatedModelRequestBehaviors(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
|
|
180
|
+
export declare function withRestoredDeprecatedModelRequestBehaviors(schema: WithPartial<LegacyResourceSchema, "legacy" | "identity">): LegacyResourceSchema;
|
|
181
181
|
/**
|
|
182
182
|
* A function which registers the necessary derivations to support
|
|
183
183
|
* the LegacyMode features of @warp-drive/legacy/model while migrating to WarpDrive.
|
|
@@ -188,7 +188,7 @@ declare function withRestoredDeprecatedModelRequestBehaviors(schema: WithPartial
|
|
|
188
188
|
* @param schema The schema service to register the derivations with.
|
|
189
189
|
* @public
|
|
190
190
|
*/
|
|
191
|
-
declare function registerDerivations(schema: SchemaService$1): void;
|
|
191
|
+
export declare function registerDerivations(schema: SchemaService$1): void;
|
|
192
192
|
/**
|
|
193
193
|
* A class which provides a schema service that delegates between
|
|
194
194
|
* a primary schema service and one that supports legacy model
|
|
@@ -220,7 +220,7 @@ declare function registerDerivations(schema: SchemaService$1): void;
|
|
|
220
220
|
* @class DelegatingSchemaService
|
|
221
221
|
* @public
|
|
222
222
|
*/
|
|
223
|
-
interface DelegatingSchemaService {
|
|
223
|
+
export interface DelegatingSchemaService {
|
|
224
224
|
/**
|
|
225
225
|
* Delegates to whichever of the primary/fallback schema services has a
|
|
226
226
|
* schema for the resource, preferring the primary. See {@link DelegatingSchemaService.isDelegated | isDelegated}.
|
|
@@ -244,7 +244,7 @@ interface DelegatingSchemaService {
|
|
|
244
244
|
/**
|
|
245
245
|
* See the {@link DelegatingSchemaService | class documentation above} for usage.
|
|
246
246
|
*/
|
|
247
|
-
declare class DelegatingSchemaService implements SchemaService$1 {
|
|
247
|
+
export declare class DelegatingSchemaService implements SchemaService$1 {
|
|
248
248
|
/** @internal */
|
|
249
249
|
_preferred: SchemaService$1;
|
|
250
250
|
/** @internal */
|
|
@@ -326,10 +326,9 @@ declare class DelegatingSchemaService implements SchemaService$1 {
|
|
|
326
326
|
/**
|
|
327
327
|
* @internal
|
|
328
328
|
*/
|
|
329
|
-
interface PrivateDelegatingSchemaService extends DelegatingSchemaService {
|
|
329
|
+
export interface PrivateDelegatingSchemaService extends DelegatingSchemaService {
|
|
330
330
|
_preferred: SchemaService$1;
|
|
331
331
|
_secondary: SchemaService$1;
|
|
332
332
|
}
|
|
333
333
|
//#endregion
|
|
334
|
-
export { DelegatingSchemaService, PrivateDelegatingSchemaService, WithLegacy, WithLegacyDerivations, registerDerivations, withDefaults, withRestoredDeprecatedModelRequestBehaviors };
|
|
335
334
|
//# sourceMappingURL=migration-support.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-support.d.ts","names":[],"sources":["../../src/model/migration-support.ts"],"mappings":";;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"migration-support.d.ts","names":[],"sources":["../../src/model/migration-support.ts"],"mappings":";;;;;;;;;;;;;;;;;;;YAsFY,sBAAsB,UAAU,uBAAuB,IACjE;;;;EAIE,kBAAkB;;;;EAIlB,gBAAgB;;KAGf,mBAAmB,WAAW,QAAQ;KACtC,sBAAsB,WAAW,QAAQ;UAEpC,i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;MAAiB;EAGpD,SAAS,UAAU;IAAgB;MAAiB,iBAAiB;EAMrE,kBAAkB,SAAS,MAAM,iBAAiB;EAGlD,iBAAiB,QAAQ,iBAAiB;EAG1C,uBAAuB,WAAW;EAGlC,mBAAmB,GAAG,GAAG,WAAW,oBAAoB,YAAY,WAAW,GAAG,GAAG;EAGrF,eAAe,QAAQ;EAIvB,sCAAsC;IAAO;IAA0B;;EAIvE,2CAA2C,WAAW;EAItD,4CACE,UAAU;IAAgB;aAClB;EAIV,0CACE,OAAO,iBACP,qCACQ;EAIV,yCAAyC,OAAO,yBAAyB;;;;;;;;;;;;EAezE,cAAc,cAAc;;;;;;;;;;;;EAiB5B,MAAM,cAAc;;;;;iBAUL,uCAAuC;EACtD,YAAY;EACZ,YAAY"}
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiPhE;iBACA,YAAU;iBACV,YAAU,GACxB,MAAM,iBAAiB,OAAO,KAC9B,SAAS,oBAAoB,cAC5B,sBAAsB;iBAKT,YAAU,cAAc,SAAS,wCAAwC;;;UC1SxE,uBAAuB;EACtC,SAAS,QAAQ,kBAAU;EAC3B,UAAU,kBAAU;;UAIL,iBAAiB;;;;;GAK/B;;;;;;;;;;;;;;;;;cAkBU,iBAAiB;;;;;EAK5B,SAAiB,QAAQ,kBAAU;;;;EAInC;;;;;EAKA,SAAiB,kBAAU;EAE3B,YAAY,SAAS,QAAQ,kBAAU,KAAK,UAAU,kBAAU;;;;;MAW5D;;;;kBAkBY,kBAAU;;;;;;;;;;EAiB1B,QAAQ,KAAK,MAAM,GAAG,eAAe,OAAO;;;;;EAU5C,OAAO,SAAS,KAAK;;;;;;EAarB;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA;;;;;;EAOA,KACE,SAAS,WAAW,QAAQ,kBAAU,iBACtC,WAAW,WAAW,QAAQ,kBAAU,kBACvC;;;;;EAQH,MAAM,IAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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":";;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiPhE;iBACA,YAAU;iBACV,YAAU,GACxB,MAAM,iBAAiB,OAAO,KAC9B,SAAS,oBAAoB,cAC5B,sBAAsB;iBAKT,YAAU,cAAc,SAAS,wCAAwC;;;UC1SxE,uBAAuB;EACtC,SAAS,QAAQ,kBAAU;EAC3B,UAAU,kBAAU;;UAIL,iBAAiB;;;;;GAK/B;;;;;;;;;;;;;;;;;cAkBU,iBAAiB;;;;;EAK5B,SAAiB,QAAQ,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getModelFactory } from "./schema-provider-
|
|
2
|
+
import { r as lookupLegacySupport } from "./errors-CS110tMl.js";
|
|
3
|
+
import { n as getModelFactory } from "./schema-provider-DguGmQDS.js";
|
|
4
4
|
import { recordIdentifierFor } from "@warp-drive/core";
|
|
5
5
|
import { getOwner, setOwner } from "@ember/application";
|
|
6
6
|
import { StoreMap, assertPrivateStore, setRecordIdentifier } from "@warp-drive/core/store/-private";
|
|
@@ -680,4 +680,4 @@ function secretInit(record, identifier, store) {
|
|
|
680
680
|
|
|
681
681
|
//#endregion
|
|
682
682
|
export { belongsTo as a, hasMany as i, modelFor as n, attr as o, teardownRecord as r, instantiateRecord as t };
|
|
683
|
-
//# sourceMappingURL=model-
|
|
683
|
+
//# sourceMappingURL=model-DWH9f__L.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-DcXZdNMu.js","names":["computed","recordIdentifierFor","RecordStore","isElementDescriptor","getGlobalConfig","macroCondition","_attr","type","options","undefined","meta","kind","isAttribute","sourceKey","key","get","WarpDrive","env","DEBUG","includes","Error","constructor","toString","isDestroyed","isDestroying","cache","getAttr","set","value","identifier","test","id","lid","currentState","isDeleted","cacheKey","currentValue","setAttr","isValid","errors","remove","cleanErrorRequests","attr","desc","args","warn","computed","assertPrivateStore","RecordStore","lookupLegacySupport","isElementDescriptor","normalizeModelName","getGlobalConfig","macroCondition","_belongsTo","type","options","WarpDrive","env","DEBUG","test","Error","async","inverse","length","meta","kind","name","sourceKey","get","key","isDestroying","isDestroyed","support","includes","constructor","toString","Object","prototype","hasOwnProperty","call","identifier","id","getBelongsTo","set","value","_join","setDirtyBelongsTo","belongsTo","arguments","deprecate","computed","assertPrivateStore","RecordStore","dasherize","singularize","lookupLegacySupport","isElementDescriptor","getGlobalConfig","macroCondition","normalizeType","type","WarpDrive","deprecations","DEPRECATE_NON_STRICT_TYPES","result","id","until","for","since","available","enabled","_hasMany","options","env","DEBUG","test","Error","async","meta","kind","name","sourceKey","get","key","includes","constructor","toString","isDestroying","isDestroyed","getHasMany","set","records","support","manyArray","getManyArray","Array","isArray","_join","splice","length","hasMany","arguments","getOwner","setOwner","assertPrivateStore","setRecordIdentifier","StoreMap","getModelFactory","normalizeModelName","macroCondition","getGlobalConfig","recast","context","instantiateRecord","identifier","createRecordArgs","type","createOptions","_createProps","_secretInit","store","cb","secretInit","factory","WarpDrive","env","DEBUG","test","Error","class","create","teardownRecord","record","destroy","modelFor","modelName","isDestroyed","isDestroying","length","maybeFactory","klass","ignoreType","isModel","_forceShim","schema","hasResource","set"],"sources":["../src/model/-private/attr.ts","../src/model/-private/belongs-to.ts","../src/model/-private/has-many.ts","../src/model/-private/hooks.ts"],"sourcesContent":["import { computed } from '@ember/object';\n\nimport { recordIdentifierFor } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { ArrayValue, ObjectValue, PrimitiveValue, Value } from '@warp-drive/core/types/json/raw';\nimport { RecordStore, type TransformName } from '@warp-drive/core/types/symbols';\n\n// oxlint-disable-next-line no-unused-vars\nimport type { Transform } from '../../serializer/transform.ts';\nimport type { Model } from './model.ts';\nimport type { DecoratorPropertyDescriptor } from './util.ts';\nimport { isElementDescriptor } from './util.ts';\n/**\n * Options provided to the attr decorator are\n * supplied to the associated transform. Any\n * key-value pair is valid; however, it is highly\n * recommended to only use statically defined values\n * that could be serialized to JSON.\n *\n * If no transform is provided, the only valid\n * option is `defaultValue`.\n *\n * Examples:\n *\n * ```ts\n * class User extends Model {\n * @attr('string', { defaultValue: 'Anonymous' }) name;\n * @attr('date', { defaultValue: () => new Date() }) createdAt;\n * @attr({ defaultValue: () => ({}) }) preferences;\n * @attr('boolean') hasVerifiedEmail;\n * @attr address;\n * }\n *\n * @class NOTATHING\n */\nexport type AttrOptions<DV = PrimitiveValue | object | unknown[]> = {\n /**\n * The default value for this attribute.\n *\n * Default values can be provided as a value or a function that will be\n * executed to generate the default value.\n *\n * Default values *should not* be stateful (object, arrays, etc.) as\n * they will be shared across all instances of the record.\n *\n */\n defaultValue?: DV extends PrimitiveValue ? DV : () => DV;\n\n /**\n * The name of the field as returned by the API and inserted into the\n * cache if it differs from the name of the decorated property.\n *\n * For instance, if the API returns:\n *\n * ```ts\n * {\n * attributes: {\n * 'first-name': 'Chris'\n * }\n * }\n * ```\n *\n * But the app desires to use `record.firstName; // 'Chris'`, then the\n * property should be named `firstName` and `sourceKey` should be set\n * to `'first-name'`.\n *\n * This option is only needed when the value differs from the property name.\n */\n sourceKey?: string;\n};\n\nfunction _attr(type?: string | AttrOptions, options?: AttrOptions) {\n if (typeof type === 'object') {\n options = type;\n type = undefined;\n } else {\n options = options || {};\n }\n\n const meta = {\n type: type,\n kind: 'attribute',\n isAttribute: true,\n options: options,\n sourceKey: options.sourceKey,\n key: null,\n };\n\n return computed({\n get(this: Model, key: string) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroyed || this.isDestroying) {\n return;\n }\n const cache = this[RecordStore].cache;\n return cache.getAttr(recordIdentifierFor(this), meta.sourceKey ?? key);\n },\n set(this: Model, key: string, value: Value) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n const identifier = recordIdentifierFor(this);\n assert(\n `Attempted to set '${key}' on the deleted record ${identifier.type}:${identifier.id} (${identifier.lid})`,\n !this.currentState.isDeleted\n );\n const cache = this[RecordStore].cache;\n const cacheKey = meta.sourceKey ?? key;\n\n const currentValue = cache.getAttr(identifier, cacheKey);\n if (currentValue !== value) {\n cache.setAttr(identifier, cacheKey, value);\n\n if (!this.isValid) {\n const { errors } = this;\n\n if (errors.get(key)) {\n errors.remove(key);\n this.currentState.cleanErrorRequests();\n }\n }\n }\n\n return value;\n },\n }).meta(meta);\n}\n\n// NOTE: Usage of Explicit ANY\n// -------------------------------------------------------------------\n// any is required here because we are the maximal not the minimal\n// subset of options allowed. If we used unknown, object, or\n// Record<string, unknown> we would get type errors when we try to\n// assert against a more specific implementation with precise options.\n// -------------------------------------------------------------------\n\ntype LooseTransformInstance<V, Raw, Name extends string> = {\n /**\n * value type must match the return type of the deserialize method\n *\n */\n // see note on Explicit ANY above\n // oxlint-disable-next-line typescript/no-explicit-any\n serialize: (value: V, options: any) => Raw;\n /**\n * defaultValue type must match the return type of the deserialize method\n *\n */\n // see note on Explicit ANY above\n // oxlint-disable-next-line typescript/no-explicit-any\n deserialize: (value: Raw, options: any) => V;\n\n [TransformName]: Name;\n};\nexport type TransformHasType = { [TransformName]: string };\n\nexport type TypedTransformInstance<V, T extends string> =\n | LooseTransformInstance<V, string, T>\n | LooseTransformInstance<V, number, T>\n | LooseTransformInstance<V, boolean, T>\n | LooseTransformInstance<V, null, T>\n | LooseTransformInstance<V, ObjectValue, T>\n | LooseTransformInstance<V, ArrayValue, T>\n | LooseTransformInstance<V, string | null, T>\n | LooseTransformInstance<V, number | null, T>\n | LooseTransformInstance<V, boolean | null, T>\n | LooseTransformInstance<V, ObjectValue | null, T>\n | LooseTransformInstance<V, ArrayValue | null, T>;\n\n// see note on Explicit ANY above\n// oxlint-disable-next-line typescript/no-explicit-any\nexport type GetMaybeDeserializeValue<T> = T extends { deserialize: (...args: any[]) => unknown }\n ? ReturnType<T['deserialize']>\n : never;\n\nexport type TypeFromInstance<T> = T extends TransformHasType ? T[typeof TransformName] : never;\nexport type ExtractOptions<T extends TypedTransformInstance<GetMaybeDeserializeValue<T>, TypeFromInstance<T>>> =\n Parameters<T['deserialize']>[1] & Parameters<T['serialize']>[1] & AttrOptions<ReturnType<T['deserialize']>>;\nexport type OptionsFromInstance<T> =\n TypeFromInstance<T> extends never\n ? never\n : GetMaybeDeserializeValue<T> extends never\n ? never\n : T extends TypedTransformInstance<GetMaybeDeserializeValue<T>, TypeFromInstance<T>>\n ? Parameters<T['deserialize']>[1] & Parameters<T['serialize']>[1] & AttrOptions<ReturnType<T['deserialize']>>\n : never;\n\n/**\n * The return type of `void` is a lie to appease TypeScript. The actual return type\n * is a descriptor, but typescript incorrectly insists that decorator functions return\n * `void` or `any`.\n *\n */\nexport type DataDecorator = (target: object, key: string, desc?: DecoratorPropertyDescriptor) => void;\n\n/**\n `attr` defines an attribute on a {@link Model}.\n By default, attributes are passed through as-is, however you can specify an\n optional type to have the value automatically transformed.\n WarpDrive ships with four basic transform types: `string`, `number`,\n `boolean` and `date`. You can define your own transforms by subclassing\n {@link Transform}.\n\n Note that you cannot use `attr` to define an attribute of `id`.\n\n `attr` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `defaultValue`: Pass a string or a function to be called to set the attribute\n to a default value if and only if the key is absent from the payload response.\n\n Example\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 @attr('boolean', { defaultValue: false }) verified;\n }\n ```\n\n Default value can also be a function. This is useful it you want to return\n a new object for each attribute.\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 @attr({\n defaultValue() {\n return {};\n }\n })\n settings;\n }\n ```\n\n The `options` hash is passed as second argument to a transforms'\n `serialize` and `deserialize` method. This allows to configure a\n transformation and adapt the corresponding value, based on the config:\n\n ```js [app/models/post.js]\n import { Model, attr } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @attr('text', {\n uppercase: true\n })\n text;\n }\n ```\n\n ```js [app/transforms/text.js]\n export default class TextTransform {\n serialize(value, options) {\n if (options.uppercase) {\n return value.toUpperCase();\n }\n\n return value;\n }\n\n deserialize(value) {\n return value;\n }\n\n static create() {\n return new this();\n }\n }\n ```\n\n @public\n @param type the attribute type\n @param options a hash of options\n*/\nexport function attr(): DataDecorator;\nexport function attr<T>(type: TypeFromInstance<T>): DataDecorator;\nexport function attr(type: string): DataDecorator;\nexport function attr(options: AttrOptions): DataDecorator;\nexport function attr<T>(type: TypeFromInstance<T>, options?: OptionsFromInstance<T>): DataDecorator;\nexport function attr(type: string, options?: AttrOptions & object): DataDecorator;\nexport function attr(target: object, key: string | symbol, desc?: PropertyDescriptor): void; // see note on DataDecorator for why void\nexport function attr(\n type?: string | AttrOptions | object,\n options?: (AttrOptions & object) | string | symbol,\n desc?: PropertyDescriptor\n): DataDecorator | void {\n const args = [type, options, desc];\n // see note on DataDecorator for why void\n return isElementDescriptor(args) ? (_attr()(...args) as void) : _attr(type, options as object);\n}\n","import { warn } from '@ember/debug';\nimport { computed } from '@ember/object';\n\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport { RecordStore } from '@warp-drive/core/types/symbols';\n\nimport { lookupLegacySupport } from './legacy-relationships-support.ts';\nimport type { MinimalLegacyRecord } from './model-methods.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { Model } from './model.ts';\nimport { isElementDescriptor, normalizeModelName } from './util.ts';\n\nexport type IsUnknown<T> = unknown extends T ? true : false;\n\nexport type RelationshipOptions<T, Async extends boolean> = {\n async: Async;\n inverse: null | (IsUnknown<T> extends true ? string : keyof NoNull<T> & string);\n polymorphic?: boolean;\n as?: string;\n linksMode?: true;\n resetOnRemoteUpdate?: boolean;\n\n /**\n * The name of the field as returned by the API and inserted into the\n * cache if it differs from the name of the decorated property.\n *\n * For instance, if the API returns:\n *\n * ```ts\n * {\n * relationships: {\n * 'best-friend': { data: { type: 'user', id: '1' } }\n * }\n * }\n * ```\n *\n * But the app desires to use `record.bestFriend`, then the property\n * should be named `bestFriend` and `sourceKey` should be set to\n * `'best-friend'`.\n *\n * This option is only needed when the value differs from the property name.\n */\n sourceKey?: string;\n};\n\nexport type NoNull<T> = Exclude<T, null>;\n// type BelongsToDecoratorObject<getT> = {\n// get: () => getT;\n// // set: (value: Awaited<getT>) => void;\n// set: (value: getT) => void;\n// // init: () => getT;\n// };\n// oxlint-disable-next-line no-unused-vars\nexport type RelationshipDecorator<T> = <This>(target: This, key: string, desc?: PropertyDescriptor) => void; // BelongsToDecoratorObject<getT>;\n\nfunction _belongsTo<T, Async extends boolean>(\n type: string,\n options: RelationshipOptions<T, Async>\n): RelationshipDecorator<T> {\n assert(\n `Expected options.async from @belongsTo('${type}', options) to be a boolean`,\n options && typeof options.async === 'boolean'\n );\n assert(\n `Expected options.inverse from @belongsTo('${type}', options) to be either null or the string type of the related resource.`,\n options.inverse === null || (typeof options.inverse === 'string' && options.inverse.length > 0)\n );\n\n const meta = {\n type: normalizeModelName(type),\n options: options,\n kind: 'belongsTo',\n name: '<Unknown BelongsTo>',\n sourceKey: options.sourceKey,\n };\n\n return computed({\n get<R extends MinimalLegacyRecord>(this: R, key: string) {\n // this is a legacy behavior we may not carry into a new model setup\n // it's better to error on disconnected records so users find errors\n // in their logic.\n if (this.isDestroying || this.isDestroyed) {\n return null;\n }\n const support = lookupLegacySupport(this);\n\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n if (Object.prototype.hasOwnProperty.call(options, 'serialize')) {\n warn(\n `You provided a serialize option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See Serializer and it's implementations https://api.emberjs.com/ember-data/release/classes/Serializer`,\n false,\n {\n id: 'ds.model.serialize-option-in-belongs-to',\n }\n );\n }\n\n if (Object.prototype.hasOwnProperty.call(options, 'embedded')) {\n warn(\n `You provided an embedded option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See EmbeddedRecordsMixin https://api.emberjs.com/ember-data/release/classes/EmbeddedRecordsMixin`,\n false,\n {\n id: 'ds.model.embedded-option-in-belongs-to',\n }\n );\n }\n }\n\n return support.getBelongsTo(key);\n },\n set<R extends MinimalLegacyRecord>(this: R, key: string, value: unknown) {\n assert(`Cannot set belongsTo relationship ${key} on a destroyed record`, !this.isDestroying && !this.isDestroyed);\n if (this.isDestroying || this.isDestroyed) {\n return null;\n }\n const support = lookupLegacySupport(this);\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n }\n assertPrivateStore(this[RecordStore]);\n this[RecordStore]._join(() => {\n support.setDirtyBelongsTo(key, value);\n });\n\n return support.getBelongsTo(key);\n },\n }).meta(meta);\n}\n\n/**\n `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None\n relationships on a {@link Model}.\n\n `belongsTo` takes a configuration hash as a second parameter, currently\n supported options are:\n\n - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.\n - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.\n - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic\n - `as`: (*optional*) A string used to declare the abstract type \"this\" record satisfies for polymorphism.\n\n ### Examples\n\n To declare a **one-to-many** (or many-to-many) relationship, use\n `belongsTo` in combination with `hasMany`:\n\n ```js\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('post', { async: false, inverse: 'comments' }) post;\n }\n\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'post' }) comments;\n }\n ```\n\n To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides:\n\n ```js\n // app/models/author.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Author extends Model {\n @belongsTo('address', { async: true, inverse: 'owner' }) address;\n }\n\n // app/models/address.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Address extends Model {\n @belongsTo('author', { async: true, inverse: 'address' }) owner;\n }\n ```\n\n To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides\n with `null` as the inverse:\n\n ```js\n // app/models/author.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Author extends Model {\n @belongsTo('address', { async: true, inverse: null }) address;\n }\n\n // app/models/address.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Address extends Model {\n @belongsTo('author', { async: true, inverse: null }) owner;\n }\n ```\n\n To declare a one-to-none relationship between two models, use\n `belongsTo` with inverse set to `null` on just one side::\n\n ```js\n // app/models/person.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Person extends Model {\n @belongsTo('person', { async: false, inverse: null }) bestFriend;\n }\n ```\n\n #### Sync vs Async Relationships\n\n WarpDrive fulfills relationships using resource data available in\n the cache.\n\n Sync relationships point directly to the known related resources.\n\n When a relationship is declared as async, if any of the known related\n resources have not been loaded, they will be fetched. The property\n on the record when accessed provides a promise that resolves once\n all resources are loaded.\n\n Async relationships may take advantage of links. On access, if the related\n link has not been loaded, or if any known resources are not available in\n the cache, the fresh state will be fetched using the link.\n\n In contrast to async relationship, accessing a sync relationship\n will error on access when any of the known related resources have\n not been loaded.\n\n If you are using `links` with sync relationships, you have to use\n the BelongsTo reference API to fetch or refresh related resources\n that aren't loaded. For instance, for a `bestFriend` relationship:\n\n ```js\n person.belongsTo('bestFriend').reload();\n ```\n\n #### Polymorphic Relationships\n\n To declare a polymorphic relationship, use `hasMany` with the `polymorphic`\n option set to `true`:\n\n ```js\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;\n }\n ```\n\n `'commentable'` here is referred to as the \"abstract type\" for the polymorphic\n relationship.\n\n Polymorphic relationships with `inverse: null` will accept any type of record as their content.\n Polymorphic relationships with `inverse` set to a string will only accept records with a matching\n inverse relationships declaring itself as satisfying the abstract type.\n\n Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'\n for this relationship.\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;\n }\n ```\n\n Note: every Model that declares an inverse to a polymorphic relationship must\n declare itself exactly the same. This is because polymorphism is based on structural\n traits.\n\n Polymorphic to polymorphic relationships are supported. Both sides of the relationship\n must be declared as polymorphic, and the `as` option must be used to declare the abstract\n type each record satisfies on both sides.\n\n @public\n @param type the name of the related resource\n @param options a hash of options\n*/\n\nexport function belongsTo(): never;\nexport function belongsTo(type: string): never;\nexport function belongsTo<T>(\n type: TypeFromInstance<NoNull<T>>,\n options: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T>;\n// export function belongsTo<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(\n// type: TypeFromInstance<NoNull<T>>,\n// options: RelationshipOptions<T, true>\n// ): RelationshipDecorator<K>;\nexport function belongsTo(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;\nexport function belongsTo<T>(\n type?: TypeFromInstance<NoNull<T>>,\n options?: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T> {\n if (DEBUG) {\n assert(\n `belongsTo must be invoked with a type and options. Did you mean \\`@belongsTo(${type}, { async: false, inverse: null })\\`?`,\n !isElementDescriptor(arguments as unknown as unknown[])\n );\n }\n return _belongsTo(type!, options!);\n}\n","import { deprecate } from '@ember/debug';\nimport { computed } from '@ember/object';\n\nimport { DEPRECATE_NON_STRICT_TYPES } from '@warp-drive/core/build-config/deprecations';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport { RecordStore } from '@warp-drive/core/types/symbols';\nimport { dasherize, singularize } from '@warp-drive/utilities/string';\n\nimport type { NoNull, RelationshipDecorator, RelationshipOptions } from './belongs-to.ts';\nimport { lookupLegacySupport } from './legacy-relationships-support.ts';\nimport type { MinimalLegacyRecord } from './model-methods.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { Model } from './model.ts';\nimport { isElementDescriptor } from './util.ts';\n\nfunction normalizeType(type: string) {\n if (DEPRECATE_NON_STRICT_TYPES) {\n const result = singularize(dasherize(type));\n\n deprecate(\n `The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`,\n result === type,\n {\n id: 'ember-data:deprecate-non-strict-types',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '4.13',\n enabled: '5.3',\n },\n }\n );\n\n return result;\n }\n\n return type;\n}\n\nfunction _hasMany<T, Async extends boolean>(\n type: string,\n options: RelationshipOptions<T, Async>\n): RelationshipDecorator<T> {\n assert(`Expected hasMany options.async to be a boolean`, options && typeof options.async === 'boolean');\n\n // Metadata about relationships is stored on the meta of\n // the relationship. This is used for introspection and\n // serialization. Note that `key` is populated lazily\n // the first time the CP is called.\n const meta = {\n type: normalizeType(type),\n options,\n kind: 'hasMany',\n name: '<Unknown BelongsTo>',\n sourceKey: options.sourceKey,\n };\n\n return computed({\n get<R extends MinimalLegacyRecord>(this: R, key: string) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroying || this.isDestroyed) {\n return [];\n }\n return lookupLegacySupport(this).getHasMany(key);\n },\n set<R extends MinimalLegacyRecord>(this: R, key: string, records: T[]) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n const support = lookupLegacySupport(this);\n const manyArray = support.getManyArray(key);\n assert(`You must pass an array of records to set a hasMany relationship`, Array.isArray(records));\n\n assertPrivateStore(this[RecordStore]);\n this[RecordStore]._join(() => {\n manyArray.splice(0, manyArray.length, ...records);\n });\n\n return support.getHasMany(key);\n },\n }).meta(meta);\n}\n\n/**\n `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None\n relationships on a {@link Model}.\n\n `hasMany` takes a configuration hash as a second parameter, currently\n supported options are:\n\n - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.\n - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.\n - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic\n - `as`: (*optional*) A string used to declare the abstract type \"this\" record satisfies for polymorphism.\n\n ### Examples\n\n To declare a **many-to-one** (or one-to-many) relationship, use\n `belongsTo` in combination with `hasMany`:\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'post' }) comments;\n }\n\n\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('post', { async: false, inverse: 'comments' }) post;\n }\n ```\n\n To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides:\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('tag', { async: true, inverse: 'posts' }) tags;\n }\n\n // app/models/tag.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Tag extends Model {\n @hasMany('post', { async: true, inverse: 'tags' }) posts;\n }\n ```\n\n To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides\n with `null` as the inverse:\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('tag', { async: true, inverse: null }) tags;\n }\n\n // app/models/tag.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Tag extends Model {\n @hasMany('post', { async: true, inverse: null }) posts;\n }\n ```\n\n To declare a many-to-none relationship between two models, use\n `hasMany` with inverse set to `null` on just one side::\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('category', { async: true, inverse: null }) categories;\n }\n ```\n\n #### Sync vs Async Relationships\n\n WarpDrive fulfills relationships using resource data available in\n the cache.\n\n Sync relationships point directly to the known related resources.\n\n When a relationship is declared as async, if any of the known related\n resources have not been loaded, they will be fetched. The property\n on the record when accessed provides a promise that resolves once\n all resources are loaded.\n\n Async relationships may take advantage of links. On access, if the related\n link has not been loaded, or if any known resources are not available in\n the cache, the fresh state will be fetched using the link.\n\n In contrast to async relationship, accessing a sync relationship\n will error on access when any of the known related resources have\n not been loaded.\n\n If you are using `links` with sync relationships, you have to use\n the HasMany reference API to fetch or refresh related resources\n that aren't loaded. For instance, for a `comments` relationship:\n\n ```js\n post.hasMany('comments').reload();\n ```\n\n #### Polymorphic Relationships\n\n To declare a polymorphic relationship, use `hasMany` with the `polymorphic`\n option set to `true`:\n\n ```js\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;\n }\n ```\n\n `'commentable'` here is referred to as the \"abstract type\" for the polymorphic\n relationship.\n\n Polymorphic relationships with `inverse: null` will accept any type of record as their content.\n Polymorphic relationships with `inverse` set to a string will only accept records with a matching\n inverse relationships declaring itself as satisfying the abstract type.\n\n Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'\n for this relationship.\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;\n }\n ```\n\n Note: every Model that declares an inverse to a polymorphic relationship must\n declare itself exactly the same. This is because polymorphism is based on structural\n traits.\n\n Polymorphic to polymorphic relationships are supported. Both sides of the relationship\n must be declared as polymorphic, and the `as` option must be used to declare the abstract\n type each record satisfies on both sides.\n\n @public\n @param type the name of the related resource\n @param options a hash of options\n*/\nexport function hasMany(): never;\nexport function hasMany(type: string): never;\nexport function hasMany<T>(\n type: TypeFromInstance<NoNull<T>>,\n options: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T>;\n// export function hasMany<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(\n// type: TypeFromInstance<NoNull<T>>,\n// options: RelationshipOptions<T, true>\n// ): RelationshipDecorator<K>;\nexport function hasMany(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;\nexport function hasMany<T>(\n type?: TypeFromInstance<NoNull<T>>,\n options?: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T> {\n if (DEBUG) {\n assert(\n `hasMany must be invoked with a type and options. Did you mean \\`@hasMany(${type}, { async: false, inverse: null })\\`?`,\n !isElementDescriptor(arguments as unknown as unknown[])\n );\n }\n return _hasMany(type!, options!);\n}\n","import { getOwner, setOwner } from '@ember/application';\n\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore, setRecordIdentifier, type Store, StoreMap } from '@warp-drive/core/store/-private';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypeFromInstance, TypeFromInstanceOrString } from '@warp-drive/core/types/record';\n\nimport type { Model, ModelStore } from './model.ts';\nimport { getModelFactory } from './schema-provider.ts';\nimport { normalizeModelName } from './util.ts';\n\nfunction recast(context: Store): asserts context is ModelStore {}\n\n/**\n * The `instantiateRecord` hook implementation for use with `Model`. Pass\n * this to your store's `instantiateRecord` method when configuring the\n * store to use `Model` for schema/record instantiation.\n *\n * @public\n */\nexport function instantiateRecord(\n this: Store,\n identifier: ResourceKey,\n createRecordArgs?: { [key: string]: unknown }\n): Model {\n const type = identifier.type;\n\n recast(this);\n\n // TODO deprecate allowing unknown args setting\n const createOptions = {\n _createProps: createRecordArgs ?? {},\n // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for\n _secretInit: {\n identifier,\n store: this,\n cb: secretInit,\n },\n };\n\n // ensure that `getOwner(this)` works inside a model instance\n setOwner(createOptions, getOwner(this)!);\n const factory = getModelFactory(this, type);\n\n assert(`No model was found for '${type}'`, factory);\n return factory.class.create(createOptions);\n}\n\n/**\n * The `teardownRecord` hook implementation for use with `Model`. Pass this\n * to your store's `teardownRecord` method when configuring the store to\n * use `Model` for schema/record instantiation.\n *\n * @public\n */\nexport function teardownRecord(record: Model): void {\n assert(\n `expected to receive an instance of Model from @warp-drive/legacy/model. If using a custom model make sure you implement teardownRecord`,\n 'destroy' in record\n );\n record.destroy();\n}\n\n/**\n * The `modelFor` implementation for use with `Model`, exposed on the store\n * as `store.modelFor(type)` when the store is configured to use `Model`.\n * Returns the `Model` subclass registered for the given type, if any.\n *\n * @public\n */\nexport function modelFor<T>(type: TypeFromInstance<T>): typeof Model | void;\n/**\n * Overload accepting a raw type string instead of a typed record instance.\n *\n * @public\n */\nexport function modelFor(type: string): typeof Model | void;\nexport function modelFor<T>(this: Store, modelName: TypeFromInstanceOrString<T>): typeof Model | void {\n assertPrivateStore(this);\n assert(\n `Attempted to call store.modelFor(), but the store instance has already been destroyed.`,\n !this.isDestroyed && !this.isDestroying\n );\n assert(`You need to pass a model name to the store's modelFor method`, modelName);\n assert(\n `Please pass a proper model name to the store's modelFor method`,\n typeof modelName === 'string' && modelName.length\n );\n recast(this);\n\n const type = normalizeModelName(modelName);\n const maybeFactory = getModelFactory(this, type);\n const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;\n\n const ignoreType = !klass || !klass.isModel || this._forceShim;\n if (!ignoreType) {\n return klass;\n }\n assert(`No model was found for '${type}' and no schema handles the type`, this.schema.hasResource({ type }));\n}\n\nfunction secretInit(record: Model, identifier: ResourceKey, store: Store): void {\n setRecordIdentifier(record, identifier);\n StoreMap.set(record, store);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,SAASM,MAAMC,MAA6BC,SAAuB;CACjE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Ac,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,8DAA8D;CAAA,EAAA,CAAEO,SAAS;CAChF1B,eAAAC,gBAAA,CAAA,CAAAc,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MACE,gEAAgE;CAAA,EAAA,CAChE,OAAOO,cAAc,YAAYA,UAAUG,MAAM;CAInD,MAAMtB,OAAOR,mBAAmB2B,SAAS;CACzC,MAAMI,eAAehC,gBAAgB,MAAMS,IAAI;CAC/C,MAAMwB,QAAQD,gBAAgBA,aAAaV,QAAQU,aAAaV,QAAQ;CAGxE,IAAI,EADe,CAACW,SAAS,CAACA,MAAME,WAAW,KAAKC,aAElD,OAAOH;CAET/B,eAAAC,gBAAA,CAAA,CAAAc,UAAAC,IAAAC,KAAA,OAAAC,SAAA;EAAA,IAAA,CAAAA,MAAA,MAAA,IAAAC,MAAO,2BAA2BZ,KAAI,iCAAkC;CAAA,EAAA,CAAE,KAAK4B,OAAOC,YAAY,EAAE7B,KAAK,CAAC,CAAC;AAC7G;AAEA,SAASM,WAAWU,QAAelB,YAAyBM,OAAoB;CAC9Ef,oBAAoB2B,QAAQlB,UAAU;CACtCR,SAASwC,IAAId,QAAQZ,KAAK;AAC5B"}
|
|
1
|
+
{"version":3,"file":"model-DWH9f__L.js","names":["computed","recordIdentifierFor","RecordStore","isElementDescriptor","getGlobalConfig","macroCondition","_attr","type","options","undefined","meta","kind","isAttribute","sourceKey","key","get","WarpDrive","env","DEBUG","includes","Error","constructor","toString","isDestroyed","isDestroying","cache","getAttr","set","value","identifier","test","id","lid","currentState","isDeleted","cacheKey","currentValue","setAttr","isValid","errors","remove","cleanErrorRequests","attr","desc","args","warn","computed","assertPrivateStore","RecordStore","lookupLegacySupport","isElementDescriptor","normalizeModelName","getGlobalConfig","macroCondition","_belongsTo","type","options","WarpDrive","env","DEBUG","test","Error","async","inverse","length","meta","kind","name","sourceKey","get","key","isDestroying","isDestroyed","support","includes","constructor","toString","Object","prototype","hasOwnProperty","call","identifier","id","getBelongsTo","set","value","_join","setDirtyBelongsTo","belongsTo","arguments","deprecate","computed","assertPrivateStore","RecordStore","dasherize","singularize","lookupLegacySupport","isElementDescriptor","getGlobalConfig","macroCondition","normalizeType","type","WarpDrive","deprecations","DEPRECATE_NON_STRICT_TYPES","result","id","until","for","since","available","enabled","_hasMany","options","env","DEBUG","test","Error","async","meta","kind","name","sourceKey","get","key","includes","constructor","toString","isDestroying","isDestroyed","getHasMany","set","records","support","manyArray","getManyArray","Array","isArray","_join","splice","length","hasMany","arguments","getOwner","setOwner","assertPrivateStore","setRecordIdentifier","StoreMap","getModelFactory","normalizeModelName","macroCondition","getGlobalConfig","recast","context","instantiateRecord","identifier","createRecordArgs","type","createOptions","_createProps","_secretInit","store","cb","secretInit","factory","WarpDrive","env","DEBUG","test","Error","class","create","teardownRecord","record","destroy","modelFor","modelName","isDestroyed","isDestroying","length","maybeFactory","klass","ignoreType","isModel","_forceShim","schema","hasResource","set"],"sources":["../src/model/-private/attr.ts","../src/model/-private/belongs-to.ts","../src/model/-private/has-many.ts","../src/model/-private/hooks.ts"],"sourcesContent":["import { computed } from '@ember/object';\n\nimport { recordIdentifierFor } from '@warp-drive/core';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport type { ArrayValue, ObjectValue, PrimitiveValue, Value } from '@warp-drive/core/types/json/raw';\nimport { RecordStore, type TransformName } from '@warp-drive/core/types/symbols';\n\n// oxlint-disable-next-line no-unused-vars\nimport type { Transform } from '../../serializer/transform.ts';\nimport type { Model } from './model.ts';\nimport type { DecoratorPropertyDescriptor } from './util.ts';\nimport { isElementDescriptor } from './util.ts';\n/**\n * Options provided to the attr decorator are\n * supplied to the associated transform. Any\n * key-value pair is valid; however, it is highly\n * recommended to only use statically defined values\n * that could be serialized to JSON.\n *\n * If no transform is provided, the only valid\n * option is `defaultValue`.\n *\n * Examples:\n *\n * ```ts\n * class User extends Model {\n * @attr('string', { defaultValue: 'Anonymous' }) name;\n * @attr('date', { defaultValue: () => new Date() }) createdAt;\n * @attr({ defaultValue: () => ({}) }) preferences;\n * @attr('boolean') hasVerifiedEmail;\n * @attr address;\n * }\n *\n * @class NOTATHING\n */\nexport type AttrOptions<DV = PrimitiveValue | object | unknown[]> = {\n /**\n * The default value for this attribute.\n *\n * Default values can be provided as a value or a function that will be\n * executed to generate the default value.\n *\n * Default values *should not* be stateful (object, arrays, etc.) as\n * they will be shared across all instances of the record.\n *\n */\n defaultValue?: DV extends PrimitiveValue ? DV : () => DV;\n\n /**\n * The name of the field as returned by the API and inserted into the\n * cache if it differs from the name of the decorated property.\n *\n * For instance, if the API returns:\n *\n * ```ts\n * {\n * attributes: {\n * 'first-name': 'Chris'\n * }\n * }\n * ```\n *\n * But the app desires to use `record.firstName; // 'Chris'`, then the\n * property should be named `firstName` and `sourceKey` should be set\n * to `'first-name'`.\n *\n * This option is only needed when the value differs from the property name.\n */\n sourceKey?: string;\n};\n\nfunction _attr(type?: string | AttrOptions, options?: AttrOptions) {\n if (typeof type === 'object') {\n options = type;\n type = undefined;\n } else {\n options = options || {};\n }\n\n const meta = {\n type: type,\n kind: 'attribute',\n isAttribute: true,\n options: options,\n sourceKey: options.sourceKey,\n key: null,\n };\n\n return computed({\n get(this: Model, key: string) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroyed || this.isDestroying) {\n return;\n }\n const cache = this[RecordStore].cache;\n return cache.getAttr(recordIdentifierFor(this), meta.sourceKey ?? key);\n },\n set(this: Model, key: string, value: Value) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your attr on ${this.constructor.toString()}`\n );\n }\n }\n const identifier = recordIdentifierFor(this);\n assert(\n `Attempted to set '${key}' on the deleted record ${identifier.type}:${identifier.id} (${identifier.lid})`,\n !this.currentState.isDeleted\n );\n const cache = this[RecordStore].cache;\n const cacheKey = meta.sourceKey ?? key;\n\n const currentValue = cache.getAttr(identifier, cacheKey);\n if (currentValue !== value) {\n cache.setAttr(identifier, cacheKey, value);\n\n if (!this.isValid) {\n const { errors } = this;\n\n if (errors.get(key)) {\n errors.remove(key);\n this.currentState.cleanErrorRequests();\n }\n }\n }\n\n return value;\n },\n }).meta(meta);\n}\n\n// NOTE: Usage of Explicit ANY\n// -------------------------------------------------------------------\n// any is required here because we are the maximal not the minimal\n// subset of options allowed. If we used unknown, object, or\n// Record<string, unknown> we would get type errors when we try to\n// assert against a more specific implementation with precise options.\n// -------------------------------------------------------------------\n\ntype LooseTransformInstance<V, Raw, Name extends string> = {\n /**\n * value type must match the return type of the deserialize method\n *\n */\n // see note on Explicit ANY above\n // oxlint-disable-next-line typescript/no-explicit-any\n serialize: (value: V, options: any) => Raw;\n /**\n * defaultValue type must match the return type of the deserialize method\n *\n */\n // see note on Explicit ANY above\n // oxlint-disable-next-line typescript/no-explicit-any\n deserialize: (value: Raw, options: any) => V;\n\n [TransformName]: Name;\n};\nexport type TransformHasType = { [TransformName]: string };\n\nexport type TypedTransformInstance<V, T extends string> =\n | LooseTransformInstance<V, string, T>\n | LooseTransformInstance<V, number, T>\n | LooseTransformInstance<V, boolean, T>\n | LooseTransformInstance<V, null, T>\n | LooseTransformInstance<V, ObjectValue, T>\n | LooseTransformInstance<V, ArrayValue, T>\n | LooseTransformInstance<V, string | null, T>\n | LooseTransformInstance<V, number | null, T>\n | LooseTransformInstance<V, boolean | null, T>\n | LooseTransformInstance<V, ObjectValue | null, T>\n | LooseTransformInstance<V, ArrayValue | null, T>;\n\n// see note on Explicit ANY above\n// oxlint-disable-next-line typescript/no-explicit-any\nexport type GetMaybeDeserializeValue<T> = T extends { deserialize: (...args: any[]) => unknown }\n ? ReturnType<T['deserialize']>\n : never;\n\nexport type TypeFromInstance<T> = T extends TransformHasType ? T[typeof TransformName] : never;\nexport type ExtractOptions<T extends TypedTransformInstance<GetMaybeDeserializeValue<T>, TypeFromInstance<T>>> =\n Parameters<T['deserialize']>[1] & Parameters<T['serialize']>[1] & AttrOptions<ReturnType<T['deserialize']>>;\nexport type OptionsFromInstance<T> =\n TypeFromInstance<T> extends never\n ? never\n : GetMaybeDeserializeValue<T> extends never\n ? never\n : T extends TypedTransformInstance<GetMaybeDeserializeValue<T>, TypeFromInstance<T>>\n ? Parameters<T['deserialize']>[1] & Parameters<T['serialize']>[1] & AttrOptions<ReturnType<T['deserialize']>>\n : never;\n\n/**\n * The return type of `void` is a lie to appease TypeScript. The actual return type\n * is a descriptor, but typescript incorrectly insists that decorator functions return\n * `void` or `any`.\n *\n */\nexport type DataDecorator = (target: object, key: string, desc?: DecoratorPropertyDescriptor) => void;\n\n/**\n `attr` defines an attribute on a {@link Model}.\n By default, attributes are passed through as-is, however you can specify an\n optional type to have the value automatically transformed.\n WarpDrive ships with four basic transform types: `string`, `number`,\n `boolean` and `date`. You can define your own transforms by subclassing\n {@link Transform}.\n\n Note that you cannot use `attr` to define an attribute of `id`.\n\n `attr` takes an optional hash as a second parameter, currently\n supported options are:\n\n - `defaultValue`: Pass a string or a function to be called to set the attribute\n to a default value if and only if the key is absent from the payload response.\n\n Example\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 @attr('boolean', { defaultValue: false }) verified;\n }\n ```\n\n Default value can also be a function. This is useful it you want to return\n a new object for each attribute.\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 @attr({\n defaultValue() {\n return {};\n }\n })\n settings;\n }\n ```\n\n The `options` hash is passed as second argument to a transforms'\n `serialize` and `deserialize` method. This allows to configure a\n transformation and adapt the corresponding value, based on the config:\n\n ```js [app/models/post.js]\n import { Model, attr } from '@warp-drive/legacy/model';\n\n export default class PostModel extends Model {\n @attr('text', {\n uppercase: true\n })\n text;\n }\n ```\n\n ```js [app/transforms/text.js]\n export default class TextTransform {\n serialize(value, options) {\n if (options.uppercase) {\n return value.toUpperCase();\n }\n\n return value;\n }\n\n deserialize(value) {\n return value;\n }\n\n static create() {\n return new this();\n }\n }\n ```\n\n @public\n @param type the attribute type\n @param options a hash of options\n*/\nexport function attr(): DataDecorator;\nexport function attr<T>(type: TypeFromInstance<T>): DataDecorator;\nexport function attr(type: string): DataDecorator;\nexport function attr(options: AttrOptions): DataDecorator;\nexport function attr<T>(type: TypeFromInstance<T>, options?: OptionsFromInstance<T>): DataDecorator;\nexport function attr(type: string, options?: AttrOptions & object): DataDecorator;\nexport function attr(target: object, key: string | symbol, desc?: PropertyDescriptor): void; // see note on DataDecorator for why void\nexport function attr(\n type?: string | AttrOptions | object,\n options?: (AttrOptions & object) | string | symbol,\n desc?: PropertyDescriptor\n): DataDecorator | void {\n const args = [type, options, desc];\n // see note on DataDecorator for why void\n return isElementDescriptor(args) ? (_attr()(...args) as void) : _attr(type, options as object);\n}\n","import { warn } from '@ember/debug';\nimport { computed } from '@ember/object';\n\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport { RecordStore } from '@warp-drive/core/types/symbols';\n\nimport { lookupLegacySupport } from './legacy-relationships-support.ts';\nimport type { MinimalLegacyRecord } from './model-methods.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { Model } from './model.ts';\nimport { isElementDescriptor, normalizeModelName } from './util.ts';\n\nexport type IsUnknown<T> = unknown extends T ? true : false;\n\nexport type RelationshipOptions<T, Async extends boolean> = {\n async: Async;\n inverse: null | (IsUnknown<T> extends true ? string : keyof NoNull<T> & string);\n polymorphic?: boolean;\n as?: string;\n linksMode?: true;\n resetOnRemoteUpdate?: boolean;\n\n /**\n * The name of the field as returned by the API and inserted into the\n * cache if it differs from the name of the decorated property.\n *\n * For instance, if the API returns:\n *\n * ```ts\n * {\n * relationships: {\n * 'best-friend': { data: { type: 'user', id: '1' } }\n * }\n * }\n * ```\n *\n * But the app desires to use `record.bestFriend`, then the property\n * should be named `bestFriend` and `sourceKey` should be set to\n * `'best-friend'`.\n *\n * This option is only needed when the value differs from the property name.\n */\n sourceKey?: string;\n};\n\nexport type NoNull<T> = Exclude<T, null>;\n// type BelongsToDecoratorObject<getT> = {\n// get: () => getT;\n// // set: (value: Awaited<getT>) => void;\n// set: (value: getT) => void;\n// // init: () => getT;\n// };\n// oxlint-disable-next-line no-unused-vars\nexport type RelationshipDecorator<T> = <This>(target: This, key: string, desc?: PropertyDescriptor) => void; // BelongsToDecoratorObject<getT>;\n\nfunction _belongsTo<T, Async extends boolean>(\n type: string,\n options: RelationshipOptions<T, Async>\n): RelationshipDecorator<T> {\n assert(\n `Expected options.async from @belongsTo('${type}', options) to be a boolean`,\n options && typeof options.async === 'boolean'\n );\n assert(\n `Expected options.inverse from @belongsTo('${type}', options) to be either null or the string type of the related resource.`,\n options.inverse === null || (typeof options.inverse === 'string' && options.inverse.length > 0)\n );\n\n const meta = {\n type: normalizeModelName(type),\n options: options,\n kind: 'belongsTo',\n name: '<Unknown BelongsTo>',\n sourceKey: options.sourceKey,\n };\n\n return computed({\n get<R extends MinimalLegacyRecord>(this: R, key: string) {\n // this is a legacy behavior we may not carry into a new model setup\n // it's better to error on disconnected records so users find errors\n // in their logic.\n if (this.isDestroying || this.isDestroyed) {\n return null;\n }\n const support = lookupLegacySupport(this);\n\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n if (Object.prototype.hasOwnProperty.call(options, 'serialize')) {\n warn(\n `You provided a serialize option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See Serializer and it's implementations https://api.emberjs.com/ember-data/release/classes/Serializer`,\n false,\n {\n id: 'ds.model.serialize-option-in-belongs-to',\n }\n );\n }\n\n if (Object.prototype.hasOwnProperty.call(options, 'embedded')) {\n warn(\n `You provided an embedded option on the \"${key}\" property in the \"${support.identifier.type}\" class, this belongs in the serializer. See EmbeddedRecordsMixin https://api.emberjs.com/ember-data/release/classes/EmbeddedRecordsMixin`,\n false,\n {\n id: 'ds.model.embedded-option-in-belongs-to',\n }\n );\n }\n }\n\n return support.getBelongsTo(key);\n },\n set<R extends MinimalLegacyRecord>(this: R, key: string, value: unknown) {\n assert(`Cannot set belongsTo relationship ${key} on a destroyed record`, !this.isDestroying && !this.isDestroyed);\n if (this.isDestroying || this.isDestroyed) {\n return null;\n }\n const support = lookupLegacySupport(this);\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your belongsTo on ${this.constructor.toString()}`\n );\n }\n }\n assertPrivateStore(this[RecordStore]);\n this[RecordStore]._join(() => {\n support.setDirtyBelongsTo(key, value);\n });\n\n return support.getBelongsTo(key);\n },\n }).meta(meta);\n}\n\n/**\n `belongsTo` is used to define One-To-One and One-To-Many, and One-To-None\n relationships on a {@link Model}.\n\n `belongsTo` takes a configuration hash as a second parameter, currently\n supported options are:\n\n - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.\n - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.\n - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic\n - `as`: (*optional*) A string used to declare the abstract type \"this\" record satisfies for polymorphism.\n\n ### Examples\n\n To declare a **one-to-many** (or many-to-many) relationship, use\n `belongsTo` in combination with `hasMany`:\n\n ```js\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('post', { async: false, inverse: 'comments' }) post;\n }\n\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'post' }) comments;\n }\n ```\n\n To declare a **one-to-one** relationship with managed inverses, use `belongsTo` for both sides:\n\n ```js\n // app/models/author.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Author extends Model {\n @belongsTo('address', { async: true, inverse: 'owner' }) address;\n }\n\n // app/models/address.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Address extends Model {\n @belongsTo('author', { async: true, inverse: 'address' }) owner;\n }\n ```\n\n To declare a **one-to-one** relationship without managed inverses, use `belongsTo` for both sides\n with `null` as the inverse:\n\n ```js\n // app/models/author.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Author extends Model {\n @belongsTo('address', { async: true, inverse: null }) address;\n }\n\n // app/models/address.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Address extends Model {\n @belongsTo('author', { async: true, inverse: null }) owner;\n }\n ```\n\n To declare a one-to-none relationship between two models, use\n `belongsTo` with inverse set to `null` on just one side::\n\n ```js\n // app/models/person.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Person extends Model {\n @belongsTo('person', { async: false, inverse: null }) bestFriend;\n }\n ```\n\n #### Sync vs Async Relationships\n\n WarpDrive fulfills relationships using resource data available in\n the cache.\n\n Sync relationships point directly to the known related resources.\n\n When a relationship is declared as async, if any of the known related\n resources have not been loaded, they will be fetched. The property\n on the record when accessed provides a promise that resolves once\n all resources are loaded.\n\n Async relationships may take advantage of links. On access, if the related\n link has not been loaded, or if any known resources are not available in\n the cache, the fresh state will be fetched using the link.\n\n In contrast to async relationship, accessing a sync relationship\n will error on access when any of the known related resources have\n not been loaded.\n\n If you are using `links` with sync relationships, you have to use\n the BelongsTo reference API to fetch or refresh related resources\n that aren't loaded. For instance, for a `bestFriend` relationship:\n\n ```js\n person.belongsTo('bestFriend').reload();\n ```\n\n #### Polymorphic Relationships\n\n To declare a polymorphic relationship, use `hasMany` with the `polymorphic`\n option set to `true`:\n\n ```js\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;\n }\n ```\n\n `'commentable'` here is referred to as the \"abstract type\" for the polymorphic\n relationship.\n\n Polymorphic relationships with `inverse: null` will accept any type of record as their content.\n Polymorphic relationships with `inverse` set to a string will only accept records with a matching\n inverse relationships declaring itself as satisfying the abstract type.\n\n Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'\n for this relationship.\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;\n }\n ```\n\n Note: every Model that declares an inverse to a polymorphic relationship must\n declare itself exactly the same. This is because polymorphism is based on structural\n traits.\n\n Polymorphic to polymorphic relationships are supported. Both sides of the relationship\n must be declared as polymorphic, and the `as` option must be used to declare the abstract\n type each record satisfies on both sides.\n\n @public\n @param type the name of the related resource\n @param options a hash of options\n*/\n\nexport function belongsTo(): never;\nexport function belongsTo(type: string): never;\nexport function belongsTo<T>(\n type: TypeFromInstance<NoNull<T>>,\n options: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T>;\n// export function belongsTo<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(\n// type: TypeFromInstance<NoNull<T>>,\n// options: RelationshipOptions<T, true>\n// ): RelationshipDecorator<K>;\nexport function belongsTo(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;\nexport function belongsTo<T>(\n type?: TypeFromInstance<NoNull<T>>,\n options?: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T> {\n if (DEBUG) {\n assert(\n `belongsTo must be invoked with a type and options. Did you mean \\`@belongsTo(${type}, { async: false, inverse: null })\\`?`,\n !isElementDescriptor(arguments as unknown as unknown[])\n );\n }\n return _belongsTo(type!, options!);\n}\n","import { deprecate } from '@ember/debug';\nimport { computed } from '@ember/object';\n\nimport { DEPRECATE_NON_STRICT_TYPES } from '@warp-drive/core/build-config/deprecations';\nimport { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore } from '@warp-drive/core/store/-private';\nimport type { TypeFromInstance } from '@warp-drive/core/types/record';\nimport { RecordStore } from '@warp-drive/core/types/symbols';\nimport { dasherize, singularize } from '@warp-drive/utilities/string';\n\nimport type { NoNull, RelationshipDecorator, RelationshipOptions } from './belongs-to.ts';\nimport { lookupLegacySupport } from './legacy-relationships-support.ts';\nimport type { MinimalLegacyRecord } from './model-methods.ts';\n// oxlint-disable-next-line no-unused-vars\nimport type { Model } from './model.ts';\nimport { isElementDescriptor } from './util.ts';\n\nfunction normalizeType(type: string) {\n if (DEPRECATE_NON_STRICT_TYPES) {\n const result = singularize(dasherize(type));\n\n deprecate(\n `The resource type '${type}' is not normalized. Update your application code to use '${result}' instead of '${type}'.`,\n result === type,\n {\n id: 'ember-data:deprecate-non-strict-types',\n until: '6.0',\n for: 'ember-data',\n since: {\n available: '4.13',\n enabled: '5.3',\n },\n }\n );\n\n return result;\n }\n\n return type;\n}\n\nfunction _hasMany<T, Async extends boolean>(\n type: string,\n options: RelationshipOptions<T, Async>\n): RelationshipDecorator<T> {\n assert(`Expected hasMany options.async to be a boolean`, options && typeof options.async === 'boolean');\n\n // Metadata about relationships is stored on the meta of\n // the relationship. This is used for introspection and\n // serialization. Note that `key` is populated lazily\n // the first time the CP is called.\n const meta = {\n type: normalizeType(type),\n options,\n kind: 'hasMany',\n name: '<Unknown BelongsTo>',\n sourceKey: options.sourceKey,\n };\n\n return computed({\n get<R extends MinimalLegacyRecord>(this: R, key: string) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n if (this.isDestroying || this.isDestroyed) {\n return [];\n }\n return lookupLegacySupport(this).getHasMany(key);\n },\n set<R extends MinimalLegacyRecord>(this: R, key: string, records: T[]) {\n if (DEBUG) {\n if (['currentState'].includes(key)) {\n throw new Error(\n `'${key}' is a reserved property name on instances of classes extending Model. Please choose a different property name for your hasMany on ${this.constructor.toString()}`\n );\n }\n }\n const support = lookupLegacySupport(this);\n const manyArray = support.getManyArray(key);\n assert(`You must pass an array of records to set a hasMany relationship`, Array.isArray(records));\n\n assertPrivateStore(this[RecordStore]);\n this[RecordStore]._join(() => {\n manyArray.splice(0, manyArray.length, ...records);\n });\n\n return support.getHasMany(key);\n },\n }).meta(meta);\n}\n\n/**\n `hasMany` is used to define Many-To-One and Many-To-Many, and Many-To-None\n relationships on a {@link Model}.\n\n `hasMany` takes a configuration hash as a second parameter, currently\n supported options are:\n\n - `async`: (*required*) A boolean value used to declare whether this is a sync (false) or async (true) relationship.\n - `inverse`: (*required*) A string used to identify the inverse property on a related model, or `null`.\n - `polymorphic`: (*optional*) A boolean value to mark the relationship as polymorphic\n - `as`: (*optional*) A string used to declare the abstract type \"this\" record satisfies for polymorphism.\n\n ### Examples\n\n To declare a **many-to-one** (or one-to-many) relationship, use\n `belongsTo` in combination with `hasMany`:\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'post' }) comments;\n }\n\n\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('post', { async: false, inverse: 'comments' }) post;\n }\n ```\n\n To declare a **many-to-many** relationship with managed inverses, use `hasMany` for both sides:\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('tag', { async: true, inverse: 'posts' }) tags;\n }\n\n // app/models/tag.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Tag extends Model {\n @hasMany('post', { async: true, inverse: 'tags' }) posts;\n }\n ```\n\n To declare a **many-to-many** relationship without managed inverses, use `hasMany` for both sides\n with `null` as the inverse:\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('tag', { async: true, inverse: null }) tags;\n }\n\n // app/models/tag.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Tag extends Model {\n @hasMany('post', { async: true, inverse: null }) posts;\n }\n ```\n\n To declare a many-to-none relationship between two models, use\n `hasMany` with inverse set to `null` on just one side::\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('category', { async: true, inverse: null }) categories;\n }\n ```\n\n #### Sync vs Async Relationships\n\n WarpDrive fulfills relationships using resource data available in\n the cache.\n\n Sync relationships point directly to the known related resources.\n\n When a relationship is declared as async, if any of the known related\n resources have not been loaded, they will be fetched. The property\n on the record when accessed provides a promise that resolves once\n all resources are loaded.\n\n Async relationships may take advantage of links. On access, if the related\n link has not been loaded, or if any known resources are not available in\n the cache, the fresh state will be fetched using the link.\n\n In contrast to async relationship, accessing a sync relationship\n will error on access when any of the known related resources have\n not been loaded.\n\n If you are using `links` with sync relationships, you have to use\n the HasMany reference API to fetch or refresh related resources\n that aren't loaded. For instance, for a `comments` relationship:\n\n ```js\n post.hasMany('comments').reload();\n ```\n\n #### Polymorphic Relationships\n\n To declare a polymorphic relationship, use `hasMany` with the `polymorphic`\n option set to `true`:\n\n ```js\n // app/models/comment.js\n import { Model, belongsTo } from '@warp-drive/legacy/model';\n\n export default class Comment extends Model {\n @belongsTo('commentable', { async: false, inverse: 'comments', polymorphic: true }) parent;\n }\n ```\n\n `'commentable'` here is referred to as the \"abstract type\" for the polymorphic\n relationship.\n\n Polymorphic relationships with `inverse: null` will accept any type of record as their content.\n Polymorphic relationships with `inverse` set to a string will only accept records with a matching\n inverse relationships declaring itself as satisfying the abstract type.\n\n Below, 'as' is used to declare the that 'post' record satisfies the abstract type 'commentable'\n for this relationship.\n\n ```js\n // app/models/post.js\n import { Model, hasMany } from '@warp-drive/legacy/model';\n\n export default class Post extends Model {\n @hasMany('comment', { async: false, inverse: 'parent', as: 'commentable' }) comments;\n }\n ```\n\n Note: every Model that declares an inverse to a polymorphic relationship must\n declare itself exactly the same. This is because polymorphism is based on structural\n traits.\n\n Polymorphic to polymorphic relationships are supported. Both sides of the relationship\n must be declared as polymorphic, and the `as` option must be used to declare the abstract\n type each record satisfies on both sides.\n\n @public\n @param type the name of the related resource\n @param options a hash of options\n*/\nexport function hasMany(): never;\nexport function hasMany(type: string): never;\nexport function hasMany<T>(\n type: TypeFromInstance<NoNull<T>>,\n options: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T>;\n// export function hasMany<K extends Promise<unknown>, T extends Awaited<K> = Awaited<K>>(\n// type: TypeFromInstance<NoNull<T>>,\n// options: RelationshipOptions<T, true>\n// ): RelationshipDecorator<K>;\nexport function hasMany(type: string, options: RelationshipOptions<unknown, boolean>): RelationshipDecorator<unknown>;\nexport function hasMany<T>(\n type?: TypeFromInstance<NoNull<T>>,\n options?: RelationshipOptions<T, boolean>\n): RelationshipDecorator<T> {\n if (DEBUG) {\n assert(\n `hasMany must be invoked with a type and options. Did you mean \\`@hasMany(${type}, { async: false, inverse: null })\\`?`,\n !isElementDescriptor(arguments as unknown as unknown[])\n );\n }\n return _hasMany(type!, options!);\n}\n","import { getOwner, setOwner } from '@ember/application';\n\nimport { assert } from '@warp-drive/core/build-config/macros';\nimport { assertPrivateStore, setRecordIdentifier, type Store, StoreMap } from '@warp-drive/core/store/-private';\nimport type { ResourceKey } from '@warp-drive/core/types/identifier';\nimport type { TypeFromInstance, TypeFromInstanceOrString } from '@warp-drive/core/types/record';\n\nimport type { Model, ModelStore } from './model.ts';\nimport { getModelFactory } from './schema-provider.ts';\nimport { normalizeModelName } from './util.ts';\n\nfunction recast(context: Store): asserts context is ModelStore {}\n\n/**\n * The `instantiateRecord` hook implementation for use with `Model`. Pass\n * this to your store's `instantiateRecord` method when configuring the\n * store to use `Model` for schema/record instantiation.\n *\n * @public\n */\nexport function instantiateRecord(\n this: Store,\n identifier: ResourceKey,\n createRecordArgs?: { [key: string]: unknown }\n): Model {\n const type = identifier.type;\n\n recast(this);\n\n // TODO deprecate allowing unknown args setting\n const createOptions = {\n _createProps: createRecordArgs ?? {},\n // TODO @deprecate consider deprecating accessing record properties during init which the below is necessary for\n _secretInit: {\n identifier,\n store: this,\n cb: secretInit,\n },\n };\n\n // ensure that `getOwner(this)` works inside a model instance\n setOwner(createOptions, getOwner(this)!);\n const factory = getModelFactory(this, type);\n\n assert(`No model was found for '${type}'`, factory);\n return factory.class.create(createOptions);\n}\n\n/**\n * The `teardownRecord` hook implementation for use with `Model`. Pass this\n * to your store's `teardownRecord` method when configuring the store to\n * use `Model` for schema/record instantiation.\n *\n * @public\n */\nexport function teardownRecord(record: Model): void {\n assert(\n `expected to receive an instance of Model from @warp-drive/legacy/model. If using a custom model make sure you implement teardownRecord`,\n 'destroy' in record\n );\n record.destroy();\n}\n\n/**\n * The `modelFor` implementation for use with `Model`, exposed on the store\n * as `store.modelFor(type)` when the store is configured to use `Model`.\n * Returns the `Model` subclass registered for the given type, if any.\n *\n * @public\n */\nexport function modelFor<T>(type: TypeFromInstance<T>): typeof Model | void;\n/**\n * Overload accepting a raw type string instead of a typed record instance.\n *\n * @public\n */\nexport function modelFor(type: string): typeof Model | void;\nexport function modelFor<T>(this: Store, modelName: TypeFromInstanceOrString<T>): typeof Model | void {\n assertPrivateStore(this);\n assert(\n `Attempted to call store.modelFor(), but the store instance has already been destroyed.`,\n !this.isDestroyed && !this.isDestroying\n );\n assert(`You need to pass a model name to the store's modelFor method`, modelName);\n assert(\n `Please pass a proper model name to the store's modelFor method`,\n typeof modelName === 'string' && modelName.length\n );\n recast(this);\n\n const type = normalizeModelName(modelName);\n const maybeFactory = getModelFactory(this, type);\n const klass = maybeFactory && maybeFactory.class ? maybeFactory.class : null;\n\n const ignoreType = !klass || !klass.isModel || this._forceShim;\n if (!ignoreType) {\n return klass;\n }\n assert(`No model was found for '${type}' and no schema handles the type`, this.schema.hasResource({ type }));\n}\n\nfunction secretInit(record: Model, identifier: ResourceKey, store: Store): void {\n setRecordIdentifier(record, identifier);\n StoreMap.set(record, store);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,SAASM,MAAMC,MAA6BC,SAAuB;CACjE,IAAI,OAAOD,SAAS,UAAU;EAC5BC,UAAUD;EACVA,OAAOE;CACT,OACED,UAAUA,WAAW,CAAC;CAGxB,MAAME,OAAO;EACLH;EACNI,MAAM;EACNC,aAAa;EACJJ;EACTK,WAAWL,QAAQK;EACnBC,KAAK;CACP;CAEA,OAAOd,SAAS;EACde,IAAiBD,KAAa;GAC5B,IAAAT,eAAAD,gBAAA,CAAA,CAAAY,UAAAC,IAAAC,KAAA,GACE;QAAI,CAAC,cAAc,CAAC,CAACC,SAASL,GAAG,GAC/B,MAAM,IAAIM,MACR,IAAIN,IAAG,kIAAmI,KAAKO,YAAYC,SAAS,GACtK;GACF;GAEF,IAAI,KAAKC,eAAe,KAAKC,cAC3B;GAGF,OADc,KAAKtB,YAAY,CAACuB,MACnBC,QAAQzB,oBAAoB,IAAI,GAAGS,KAAKG,aAAaC,GAAG;EACvE;EACAa,IAAiBb,KAAac,OAAc;GAC1C,IAAAvB,eAAAD,gBAAA,CAAA,CAAAY,UAAAC,IAAAC,KAAA,GACE;QAAI,CAAC,cAAc,CAAC,CAACC,SAASL,GAAG,GAC/B,MAAM,IAAIM,MACR,IAAIN,IAAG,kIAAmI,KAAKO,YAAYC,SAAS,GACtK;GACF;GAEF,MAAMO,aAAa5B,oBAAoB,IAAI;GAC3CI,eAAAD,gBAAA,CAAA,CAAAY,UAAAC,IAAAC,KAAA,OAAAY,SAAA;IAAA,IAAA,CAAAA,MAAA,MAAA,IAAAV,M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